Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
O
opentrafficshaper
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Yuriy
opentrafficshaper
Commits
2b82d5cb
Commit
2b82d5cb
authored
11 years ago
by
Nigel Kukard
Browse files
Options
Downloads
Patches
Plain Diff
Added framework for TC
parent
c1431809
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
opentrafficshaper/plugins/tc/tc.pm
+127
-0
127 additions, 0 deletions
opentrafficshaper/plugins/tc/tc.pm
with
127 additions
and
0 deletions
opentrafficshaper/plugins/tc/tc.pm
0 → 100644
+
127
−
0
View file @
2b82d5cb
# OpenTrafficShaper Linux tc traffic shaping
# Copyright (C) 2007-2013, AllWorldIT
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
package
opentrafficshaper::plugins::
tc
;
use
strict
;
use
warnings
;
use
POE
;
use
opentrafficshaper::
constants
;
use
opentrafficshaper::
logger
;
# Exporter stuff
require
Exporter
;
our
(
@ISA
,
@EXPORT
,
@EXPORT_OK
);
@ISA
=
qw(Exporter)
;
@EXPORT
=
qw(
)
;
@EXPORT_OK
=
qw(
)
;
use
constant
{
VERSION
=>
'
0.0.1
',
};
# Plugin info
our
$pluginInfo
=
{
Name
=>
"
Linux tc Interface
",
Version
=>
VERSION
,
Init
=>
\
&init
,
};
# Copy of system globals
my
$globals
;
my
$logger
;
# Initialize plugin
sub
init
{
$globals
=
shift
;
# Setup our environment
$logger
=
$globals
->
{'
logger
'};
# This is our configuration processing session
POE::
Session
->
create
(
inline_states
=>
{
_start
=>
\
&session_init
,
add
=>
\
&do_add
,
change
=>
\
&do_change
,
remove
=>
\
&do_remove
,
}
);
$logger
->
log
(
LOG_NOTICE
,"
[TC] OpenTrafficShaper tc Integration v
"
.
VERSION
.
"
- Copyright (c) 2013, AllWorldIT
")
}
# Initialize config manager
sub
session_init
{
my
$kernel
=
$_
[
KERNEL
];
# Set our alias
$kernel
->
alias_set
("
shaper
");
}
# Add event for tc
sub
do_add
{
my
(
$kernel
,
$uid
)
=
@_
[
KERNEL
,
ARG0
];
# Pull in global
my
$users
=
%globals
->
{'
users
'};
my
$user
=
$users
->
{
$uid
};
$users
->
{
$uid
}
->
{'
shaper_live
'}
=
SHAPER_LIVE
;
print
STDERR
"
TC => add
$user
->{'Username'}
\n
";
}
# Change event for tc
sub
do_change
{
my
(
$kernel
,
$user
)
=
@_
[
KERNEL
,
ARG0
];
print
STDERR
"
TC => change
$user
->{'Username'}
\n
";
}
# Remove event for tc
sub
do_remove
{
my
(
$kernel
,
$user
)
=
@_
[
KERNEL
,
ARG0
];
$users
->
{
$uid
}
->
{'
shaper_live
'}
=
0
;
print
STDERR
"
TC => remove
$user
->{'Username'}
\n
";
}
1
;
# vim: ts=4
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment