Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
I
iproute2
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
iproute2
Commits
63e989f5
Commit
63e989f5
authored
Jun 25, 2004
by
osdl.net!shemminger
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add loss paramater.
(Logical change 1.31)
parent
db72dd16
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
43 additions
and
0 deletions
+43
-0
tc/q_delay.c
tc/q_delay.c
+11
-0
tc/tc_util.c
tc/tc_util.c
+29
-0
tc/tc_util.h
tc/tc_util.h
+3
-0
No files found.
tc/q_delay.c
View file @
63e989f5
...
...
@@ -64,6 +64,13 @@ static int delay_parse_opt(struct qdisc_util *qu, int argc, char **argv,
return
-
1
;
}
ok
++
;
}
else
if
(
matches
(
*
argv
,
"loss"
)
==
0
)
{
NEXT_ARG
();
if
(
get_percent
(
&
opt
.
loss
,
*
argv
))
{
explain1
(
"loss"
);
return
-
1
;
}
ok
++
;
}
else
if
(
matches
(
*
argv
,
"rate"
)
==
0
)
{
NEXT_ARG
();
if
(
rate
)
{
...
...
@@ -125,11 +132,15 @@ static int delay_print_opt(struct qdisc_util *qu, FILE *f, struct rtattr *opt)
if
(
RTA_PAYLOAD
(
opt
)
<
sizeof
(
*
qopt
))
return
-
1
;
qopt
=
RTA_DATA
(
opt
);
fprintf
(
f
,
"delay limit %s latency %s "
,
sprint_size
(
qopt
->
limit
,
b1
),
sprint_usecs
(
qopt
->
latency
,
b2
));
if
(
qopt
->
loss
)
fprintf
(
f
,
"loss %s "
,
sprint_percent
(
qopt
->
loss
,
b1
));
return
0
;
}
...
...
tc/tc_util.c
View file @
63e989f5
...
...
@@ -314,6 +314,35 @@ char * sprint_size(__u32 size, char *buf)
return
buf
;
}
static
double
percent_scale
=
(
double
)(
1ull
<<
32
)
/
100
.;
int
get_percent
(
__u32
*
percent
,
const
char
*
str
)
{
char
*
p
;
double
per
=
strtod
(
str
,
&
p
);
if
(
per
>
100
.)
return
-
1
;
if
(
*
p
&&
strcmp
(
p
,
"%"
))
return
-
1
;
*
percent
=
per
*
percent_scale
;
return
0
;
}
int
print_percent
(
char
*
buf
,
int
len
,
__u32
per
)
{
snprintf
(
buf
,
len
,
"%g%%"
,
(
double
)
per
/
percent_scale
);
return
0
;
}
char
*
sprint_percent
(
__u32
per
,
char
*
buf
)
{
if
(
print_percent
(
buf
,
SPRINT_BSIZE
-
1
,
per
))
strcpy
(
buf
,
"???"
);
return
buf
;
}
int
print_qdisc_handle
(
char
*
buf
,
int
len
,
__u32
h
)
{
snprintf
(
buf
,
len
,
"%x:"
,
TC_H_MAJ
(
h
)
>>
16
);
...
...
tc/tc_util.h
View file @
63e989f5
...
...
@@ -31,11 +31,13 @@ extern struct filter_util *get_filter_kind(const char *str);
extern
int
get_qdisc_handle
(
__u32
*
h
,
const
char
*
str
);
extern
int
get_rate
(
unsigned
*
rate
,
const
char
*
str
);
extern
int
get_percent
(
unsigned
*
percent
,
const
char
*
str
);
extern
int
get_size
(
unsigned
*
size
,
const
char
*
str
);
extern
int
get_size_and_cell
(
unsigned
*
size
,
int
*
cell_log
,
char
*
str
);
extern
int
get_usecs
(
unsigned
*
usecs
,
const
char
*
str
);
extern
int
print_rate
(
char
*
buf
,
int
len
,
__u32
rate
);
extern
int
print_size
(
char
*
buf
,
int
len
,
__u32
size
);
extern
int
print_percent
(
char
*
buf
,
int
len
,
__u32
percent
);
extern
int
print_qdisc_handle
(
char
*
buf
,
int
len
,
__u32
h
);
extern
int
print_usecs
(
char
*
buf
,
int
len
,
__u32
usecs
);
extern
char
*
sprint_rate
(
__u32
rate
,
char
*
buf
);
...
...
@@ -43,6 +45,7 @@ extern char * sprint_size(__u32 size, char *buf);
extern
char
*
sprint_qdisc_handle
(
__u32
h
,
char
*
buf
);
extern
char
*
sprint_tc_classid
(
__u32
h
,
char
*
buf
);
extern
char
*
sprint_usecs
(
__u32
usecs
,
char
*
buf
);
extern
char
*
sprint_percent
(
__u32
percent
,
char
*
buf
);
extern
void
print_tcstats
(
FILE
*
fp
,
struct
tc_stats
*
st
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment