X-Git-Url: http://git.onelab.eu/?p=ipfw.git;a=blobdiff_plain;f=ipfw%2Fdummynet.c;h=12625fea01912ac84ab697db7cbe0ac0d3674b61;hp=e2c5ff142f7bd4ce0ef981fc98be58523406ddfa;hb=f1a44f1ebacf274e0f35970bfc8ee5aa07aa9aca;hpb=ecbf629b486a76fa4817cc73270af411eada5a1a diff --git a/ipfw/dummynet.c b/ipfw/dummynet.c index e2c5ff1..12625fe 100644 --- a/ipfw/dummynet.c +++ b/ipfw/dummynet.c @@ -70,11 +70,12 @@ static struct _s_x dummynet_params[] = { { "src-ipv6", TOK_SRCIP6}, { "src-ip6", TOK_SRCIP6}, { "profile", TOK_PIPE_PROFILE}, + { "burst", TOK_BURST}, { "dummynet-params", TOK_NULL }, { NULL, 0 } /* terminator */ }; -/* +/* * XXX to be updated to the new version, * without the global struct command_opts variable */ @@ -254,7 +255,7 @@ print_flowset_parms(struct dn_flow_set *fs, char *prefix) } static void -print_extra_delay_parms(struct dn_pipe *p, char *prefix) +print_extra_delay_parms(struct dn_pipe *p) { double loss; if (p->samples_no <= 0) @@ -262,8 +263,8 @@ print_extra_delay_parms(struct dn_pipe *p, char *prefix) loss = p->loss_level; loss /= p->samples_no; - printf("%s profile: name \"%s\" loss %f samples %d\n", - prefix, p->name, loss, p->samples_no); + printf("\t profile: name \"%s\" loss %f samples %d\n", + p->name, loss, p->samples_no); } void @@ -284,6 +285,7 @@ ipfw_list_pipes(void *data, uint nbytes, int ac, char *av[]) double b = p->bandwidth; char buf[30]; char prefix[80]; + char burst[5 + 7]; if (SLIST_NEXT(p, next) != (struct dn_pipe *)DN_IS_PIPE) break; /* done with pipes, now queues */ @@ -315,10 +317,16 @@ ipfw_list_pipes(void *data, uint nbytes, int ac, char *av[]) sprintf(prefix, "%05d: %s %4d ms ", p->pipe_nr, buf, p->delay); - print_extra_delay_parms(p, prefix); - print_flowset_parms(&(p->fs), prefix); + if (humanize_number(burst, sizeof(burst), p->burst, + "Byte", HN_AUTOSCALE, 0) < 0 || co.verbose) + printf("\t burst: %ju Byte\n", p->burst); + else + printf("\t burst: %s\n", burst); + + print_extra_delay_parms(p); + q = (struct dn_flow_queue *)(p+1); list_queues(&(p->fs), q); } @@ -645,6 +653,8 @@ load_extra_delays(const char *filename, struct dn_pipe *p) } } + fclose (f); + if (samples == -1) { warnx("'%s' not found, assuming 100", ED_TOK_SAMPLES); samples = 100; @@ -938,6 +948,21 @@ end_mask: --ac; ++av; break; + case TOK_BURST: + if (co.do_pipe != 1) + errx(EX_DATAERR, "burst only valid for pipes"); + NEED1("burst needs argument\n"); + errno = 0; + if (expand_number(av[0], (int64_t *)&p.burst) < 0) + if (errno != ERANGE) + errx(EX_DATAERR, + "burst: invalid argument"); + if (errno || p.burst > (1ULL << 48) - 1) + errx(EX_DATAERR, + "burst: out of range (0..2^48-1)"); + ac--; av++; + break; + default: errx(EX_DATAERR, "unrecognised option ``%s''", av[-1]); }