git://git.onelab.eu
/
ipfw.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Remove the old dummynet directory and update the new code with the missing files...
[ipfw.git]
/
ipfw
/
dummynet.c
diff --git
a/ipfw/dummynet.c
b/ipfw/dummynet.c
index
fd8fc4d
..
c50962d
100644
(file)
--- a/
ipfw/dummynet.c
+++ b/
ipfw/dummynet.c
@@
-32,6
+32,8
@@
#include <ctype.h>
#include <err.h>
#include <ctype.h>
#include <err.h>
+#include <errno.h>
+#include <libutil.h>
#include <netdb.h>
#include <stdio.h>
#include <stdlib.h>
#include <netdb.h>
#include <stdio.h>
#include <stdlib.h>
@@
-70,12
+72,13
@@
static struct _s_x dummynet_params[] = {
{ "src-ipv6", TOK_SRCIP6},
{ "src-ip6", TOK_SRCIP6},
{ "profile", TOK_PIPE_PROFILE},
{ "src-ipv6", TOK_SRCIP6},
{ "src-ip6", TOK_SRCIP6},
{ "profile", TOK_PIPE_PROFILE},
+ { "burst", TOK_BURST},
{ "dummynet-params", TOK_NULL },
{ NULL, 0 } /* terminator */
};
static int
{ "dummynet-params", TOK_NULL },
{ NULL, 0 } /* terminator */
};
static int
-sort_q(const void *pa, const void *pb)
+sort_q(
void *arg,
const void *pa, const void *pb)
{
int rev = (co.do_sort < 0);
int field = rev ? -co.do_sort : co.do_sort;
{
int rev = (co.do_sort < 0);
int field = rev ? -co.do_sort : co.do_sort;
@@
-118,7
+121,7
@@
list_queues(struct dn_flow_set *fs, struct dn_flow_queue *q)
return;
if (co.do_sort != 0)
return;
if (co.do_sort != 0)
-
heapsort(q, fs->rq_elements, sizeof *q
, sort_q);
+
qsort_r(q, fs->rq_elements, sizeof *q, NULL
, sort_q);
/* Print IPv4 flows */
index_printed = 0;
/* Print IPv4 flows */
index_printed = 0;
@@
-250,7
+253,7
@@
print_flowset_parms(struct dn_flow_set *fs, char *prefix)
}
static void
}
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)
{
double loss;
if (p->samples_no <= 0)
@@
-258,8
+261,8
@@
print_extra_delay_parms(struct dn_pipe *p, char *prefix)
loss = p->loss_level;
loss /= p->samples_no;
loss = p->loss_level;
loss /= p->samples_no;
- printf("
%s
profile: name \"%s\" loss %f samples %d\n",
- p
refix, p
->name, loss, p->samples_no);
+ printf("
\t
profile: name \"%s\" loss %f samples %d\n",
+ p->name, loss, p->samples_no);
}
void
}
void
@@
-280,6
+283,7
@@
ipfw_list_pipes(void *data, uint nbytes, int ac, char *av[])
double b = p->bandwidth;
char buf[30];
char prefix[80];
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 */
if (SLIST_NEXT(p, next) != (struct dn_pipe *)DN_IS_PIPE)
break; /* done with pipes, now queues */
@@
-311,10
+315,16
@@
ipfw_list_pipes(void *data, uint nbytes, int ac, char *av[])
sprintf(prefix, "%05d: %s %4d ms ",
p->pipe_nr, buf, p->delay);
sprintf(prefix, "%05d: %s %4d ms ",
p->pipe_nr, buf, p->delay);
- print_extra_delay_parms(p, prefix);
-
print_flowset_parms(&(p->fs), 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);
}
q = (struct dn_flow_queue *)(p+1);
list_queues(&(p->fs), q);
}
@@
-446,7
+456,6
@@
ipfw_delete_pipe(int pipe_or_queue, int i)
*
*/
*
*/
-/* XXX move to an array definition ? */
#define ED_MAX_LINE_LEN 256+ED_MAX_NAME_LEN
#define ED_TOK_SAMPLES "samples"
#define ED_TOK_LOSS "loss-level"
#define ED_MAX_LINE_LEN 256+ED_MAX_NAME_LEN
#define ED_TOK_SAMPLES "samples"
#define ED_TOK_LOSS "loss-level"
@@
-477,7
+486,7
@@
is_valid_number(const char *s)
* and return the numeric bandwidth value.
* set clocking interface or bandwidth value
*/
* and return the numeric bandwidth value.
* set clocking interface or bandwidth value
*/
-void
+
static
void
read_bandwidth(char *arg, int *bandwidth, char *if_name, int namelen)
{
if (*bandwidth != -1)
read_bandwidth(char *arg, int *bandwidth, char *if_name, int namelen)
{
if (*bandwidth != -1)
@@
-521,7
+530,7
@@
struct point {
double delay;
};
double delay;
};
-int
+
static
int
compare_points(const void *vp1, const void *vp2)
{
const struct point *p1 = vp1;
compare_points(const void *vp1, const void *vp2)
{
const struct point *p1 = vp1;
@@
-641,6
+650,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;
if (samples == -1) {
warnx("'%s' not found, assuming 100", ED_TOK_SAMPLES);
samples = 100;
@@
-934,6
+945,21
@@
end_mask:
--ac; ++av;
break;
--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]);
}
default:
errx(EX_DATAERR, "unrecognised option ``%s''", av[-1]);
}