~ubuntu-branches/ubuntu/precise/iproute/precise

« back to all changes in this revision

Viewing changes to tc/q_tbf.c

  • Committer: Bazaar Package Importer
  • Author(s): Alexander Wirt, Andreas Henriksson, Justin B Rye, Alexander Wirt
  • Date: 2008-05-11 11:18:29 UTC
  • mfrom: (1.1.6 upstream)
  • Revision ID: james.westby@ubuntu.com-20080511111829-rfewew7s6kiev0bh
Tags: 20080417-1
[ Andreas Henriksson ]
* New upstream release, v2.6.25 a.k.a. snapshot 20080417.
  - Initial documentation for xfrm (Partially fixes #451337)
  - Fixes manpage error caught by lintian!
* Fix typos (syntax error) in ip(8) manpage.
  - Introduced by upstream, caught by lintian yet again!
* Don't ship useless headers in iproute-dev (Closes: #467557)
* Cherry-pick "Fix bad hash calculation because of signed address" from
  upstream. (Closes: #480173)

[ Justin B Rye ]
* Update package description (Closes: #464521)

[ Alexander Wirt ]
* Fix typo in short package description.

Show diffs side-by-side

added added

removed removed

Lines of Context:
26
26
static void explain(void)
27
27
{
28
28
        fprintf(stderr, "Usage: ... tbf limit BYTES burst BYTES[/BYTES] rate KBPS [ mtu BYTES[/BYTES] ]\n");
29
 
        fprintf(stderr, "               [ peakrate KBPS ] [ latency TIME ]\n");
 
29
        fprintf(stderr, "               [ peakrate KBPS ] [ latency TIME ] ");
 
30
        fprintf(stderr, "[ overhead BYTES ] [ linklayer TYPE ]\n");
30
31
}
31
32
 
32
33
static void explain1(char *arg)
45
46
        __u32 ptab[256];
46
47
        unsigned buffer=0, mtu=0, mpu=0, latency=0;
47
48
        int Rcell_log=-1, Pcell_log = -1;
 
49
        unsigned short overhead=0;
 
50
        unsigned int linklayer = LINKLAYER_ETHERNET; /* Assume ethernet */
48
51
        struct rtattr *tail;
49
52
 
50
53
        memset(&opt, 0, sizeof(opt));
130
133
                                return -1;
131
134
                        }
132
135
                        ok++;
 
136
                } else if (matches(*argv, "overhead") == 0) {
 
137
                        NEXT_ARG();
 
138
                        if (overhead) {
 
139
                                fprintf(stderr, "Double \"overhead\" spec\n");
 
140
                                return -1;
 
141
                        }
 
142
                        if (get_u16(&overhead, *argv, 10)) {
 
143
                                explain1("overhead"); return -1;
 
144
                        }
 
145
                } else if (matches(*argv, "linklayer") == 0) {
 
146
                        NEXT_ARG();
 
147
                        if (get_linklayer(&linklayer, *argv)) {
 
148
                                explain1("linklayer"); return -1;
 
149
                        }
133
150
                } else if (strcmp(*argv, "help") == 0) {
134
151
                        explain();
135
152
                        return -1;
170
187
                opt.limit = lim;
171
188
        }
172
189
 
173
 
        if ((Rcell_log = tc_calc_rtable(opt.rate.rate, rtab, Rcell_log, mtu, mpu)) < 0) {
 
190
        opt.rate.mpu      = mpu;
 
191
        opt.rate.overhead = overhead;
 
192
        if (tc_calc_rtable(&opt.rate, rtab, Rcell_log, mtu, linklayer) < 0) {
174
193
                fprintf(stderr, "TBF: failed to calculate rate table.\n");
175
194
                return -1;
176
195
        }
177
196
        opt.buffer = tc_calc_xmittime(opt.rate.rate, buffer);
178
 
        opt.rate.cell_log = Rcell_log;
179
 
        opt.rate.mpu = mpu;
 
197
 
180
198
        if (opt.peakrate.rate) {
181
 
                if ((Pcell_log = tc_calc_rtable(opt.peakrate.rate, ptab, Pcell_log, mtu, mpu)) < 0) {
 
199
                opt.peakrate.mpu      = mpu;
 
200
                opt.peakrate.overhead = overhead;
 
201
                if (tc_calc_rtable(&opt.peakrate, ptab, Pcell_log, mtu, linklayer) < 0) {
182
202
                        fprintf(stderr, "TBF: failed to calculate peak rate table.\n");
183
203
                        return -1;
184
204
                }
185
205
                opt.mtu = tc_calc_xmittime(opt.peakrate.rate, mtu);
186
 
                opt.peakrate.cell_log = Pcell_log;
187
 
                opt.peakrate.mpu = mpu;
188
206
        }
189
207
 
190
208
        tail = NLMSG_TAIL(n);
253
271
        }
254
272
        fprintf(f, "lat %s ", sprint_time(latency, b1));
255
273
 
 
274
        if (qopt->rate.overhead) {
 
275
                fprintf(f, "overhead %d", qopt->rate.overhead);
 
276
        }
 
277
 
256
278
        return 0;
257
279
}
258
280