]> git.pld-linux.org Git - packages/iproute2.git/commitdiff
- bitrate calcualtion fix.
authorPaweł Sikora <pluto@pld-linux.org>
Thu, 20 May 2004 15:04:31 +0000 (15:04 +0000)
committercvs2git <feedback@pld-linux.org>
Sun, 24 Jun 2012 12:13:13 +0000 (12:13 +0000)
Changed files:
    iproute2-rates-1024-fix.patch -> 1.1

iproute2-rates-1024-fix.patch [new file with mode: 0644]

diff --git a/iproute2-rates-1024-fix.patch b/iproute2-rates-1024-fix.patch
new file mode 100644 (file)
index 0000000..7764738
--- /dev/null
@@ -0,0 +1,35 @@
+--- iproute2/tc/tc_util.c.orig 2000-04-16 19:42:55.000000000 +0200
++++ iproute2/tc/tc_util.c      2004-05-13 10:20:19.438544176 +0200
+@@ -108,13 +108,13 @@
+       if (*p) {
+               if (strcasecmp(p, "kbps") == 0)
+-                      bps *= 1024;
++                      bps *= 1000;
+               else if (strcasecmp(p, "mbps") == 0)
+-                      bps *= 1024*1024;
++                      bps *= 1000*1000;
+               else if (strcasecmp(p, "mbit") == 0)
+-                      bps *= 1024*1024/8;
++                      bps *= 1000*1000/8;
+               else if (strcasecmp(p, "kbit") == 0)
+-                      bps *= 1024/8;
++                      bps *= 1000/8;
+               else if (strcasecmp(p, "bps") != 0)
+                       return -1;
+       } else
+@@ -158,10 +158,10 @@
+ {
+       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/1024));
++      if (tmp >= 1000*999 && fabs(1000*1000*rint(tmp/(1000*1000)) - tmp) < 1000)
++              snprintf(buf, len, "%gMbit", rint(tmp/(1000*1000)));
++      else if (tmp >= 1000-10 && fabs(1000*rint(tmp/1000) - tmp) < 10)
++              snprintf(buf, len, "%gKbit", rint(tmp/1000));
+       else
+               snprintf(buf, len, "%ubps", rate);
+       return 0;
This page took 0.038877 seconds and 4 git commands to generate.