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
4703e08a
Commit
4703e08a
authored
Jun 09, 2004
by
osdl.org!shemminger
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Display rates ad mutiple of 1000 not 1024
(Logical change 1.22)
parent
26bfe439
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
11 deletions
+14
-11
tc/tc_util.c
tc/tc_util.c
+14
-11
No files found.
tc/tc_util.c
View file @
4703e08a
...
...
@@ -97,7 +97,10 @@ char * sprint_tc_classid(__u32 h, char *buf)
return
buf
;
}
/*
* NB: rates are in Kilo = 1000 but sizes are in Kilo = 1024
* according to standard usage.
*/
int
get_rate
(
unsigned
*
rate
,
const
char
*
str
)
{
char
*
p
;
...
...
@@ -108,17 +111,17 @@ int get_rate(unsigned *rate, const char *str)
if
(
*
p
)
{
if
(
strcasecmp
(
p
,
"kbps"
)
==
0
)
bps
*=
10
24
;
bps
*=
10
00
;
else
if
(
strcasecmp
(
p
,
"gbps"
)
==
0
)
bps
*=
10
24
*
1024
*
1024
;
bps
*=
10
00000000
.
;
else
if
(
strcasecmp
(
p
,
"gbit"
)
==
0
)
bps
*=
1024
*
1024
*
1024
/
8
;
bps
=
(
bps
*
1000000000
.)
/
8
;
else
if
(
strcasecmp
(
p
,
"mbps"
)
==
0
)
bps
*=
10
24
*
1024
;
bps
*=
10
00000
.
;
else
if
(
strcasecmp
(
p
,
"mbit"
)
==
0
)
bps
*=
1024
*
1024
/
8
;
bps
=
(
bps
*
1000000
.)
/
8
;
else
if
(
strcasecmp
(
p
,
"kbit"
)
==
0
)
bps
*=
1024
/
8
;
bps
=
(
bps
*
1000
.)
/
8
;
else
if
(
strcasecmp
(
p
,
"bps"
)
!=
0
)
return
-
1
;
}
else
...
...
@@ -162,10 +165,10 @@ int print_rate(char *buf, int len, __u32 rate)
{
double
tmp
=
(
double
)
rate
*
8
;
if
(
tmp
>=
1024
*
1023
&&
fabs
(
1024
*
1024
*
rint
(
tmp
/
(
1024
*
1024
))
-
tmp
)
<
1024
)
snprintf
(
buf
,
len
,
"%gMbit"
,
rint
(
tmp
/
(
1024
*
1024
)
));
else
if
(
tmp
>=
1024
-
16
&&
fabs
(
1024
*
rint
(
tmp
/
1024
)
-
tmp
)
<
16
)
snprintf
(
buf
,
len
,
"%gKbit"
,
rint
(
tmp
/
10
24
));
if
(
tmp
>=
999999
&&
fabs
(
1000000
.
*
rint
(
tmp
/
1000000
.)
-
tmp
)
<
1000
)
snprintf
(
buf
,
len
,
"%gMbit"
,
rint
(
tmp
/
1000000
.
));
else
if
(
tmp
>=
990
&&
fabs
(
1000
.
*
rint
(
tmp
/
1000
.)
-
tmp
)
<
10
)
snprintf
(
buf
,
len
,
"%gKbit"
,
rint
(
tmp
/
10
00
.
));
else
snprintf
(
buf
,
len
,
"%ubps"
,
rate
);
return
0
;
...
...
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