4 * userspace compatibility code for dummynet schedulers
17 #include <strings.h> /* bzero, ffs, ... */
18 #include <string.h> /* strcmp */
20 #include <sys/queue.h>
24 #define ND(fmt, args...) do {} while (0)
25 #define D1(fmt, args...) do {} while (0)
26 #define D(fmt, args...) fprintf(stderr, "%-10s %4d %-8s " fmt "\n", \
27 __FILE__, __LINE__, __FUNCTION__, ## args)
28 #define DX(lev, fmt, args...) do { \
29 if (debug > lev) D(fmt, ## args); } while (0)
33 #define offsetof(t,m) (int)(intptr_t)((&((t *)0L)->m))
36 #if defined(__APPLE__) // XXX osx
37 typedef unsigned int u_int;
42 /* prevent include of other system headers */
43 #define _NETINET_IP_VAR_H_ /* ip_fw_args */
56 /* from ip_dummynet.h, fields used in ip_dn_private.h */
58 uint16_t len; /* total len inc. this header */
61 // uint32_t id; /* generic id */
64 /* (from ip_dummynet.h)
65 * A flowset, which is a template for flows. Contains parameters
66 * from the command line: id, target scheduler, queue sizes, plr,
67 * flow masks, buckets for the flow hash, and possibly scheduler-
68 * specific parameters (weight, quantum and so on).
71 /* generic scheduler parameters. Leave them at -1 if unset.
72 * Now we use 0: weight, 1: lmax, 2: priority
74 int par[4]; /* flowset parameters */
76 /* simulation entries.
77 * 'index' is not strictly necessary
78 * y is used for the inverse mapping ,
81 int y; /* inverse mapping */
82 int base_y; /* inverse mapping */
83 int next_y; /* inverse mapping */
86 int next_flow; /* first_flow + n_flows */
88 * when generating, let 'cur' go from 0 to n_flows-1,
89 * then point to flow first_flow + cur
95 * scheduler template, indicating nam, number, mask and buckets
100 /* (from ip_dummynet.h)
101 * dn_flow collects flow_id and stats for queues and scheduler
102 * instances, and is used to pass these info to userland.
103 * oid.type/oid.subtype describe the object, oid.id is number
104 * of the parent object.
110 uint32_t length; /* Queue length, in packets */
111 uint32_t len_bytes; /* Queue length, in bytes */
115 /* the following fields are used by the traffic generator.
117 struct list_head h; /* used by the generator */
119 /* bytes served by the flow since the last backlog time */
121 /* bytes served by the system at the last backlog time */
136 struct mbuf *m_nextpkt;
137 uint32_t flow_id; /* for testing, index of a flow */
138 //int flowset_id; /* for testing, index of a flowset */
139 //void *cfg; /* config args */
142 #define MALLOC_DECLARE(x) extern volatile int __dummy__ ## x
143 #define KASSERT(x, y) do { if (!(x)) printf y ; exit(0); } while (0)
144 struct ipfw_flow_id {
147 typedef void * module_t;
151 int (*f)(module_t, int, void *);
155 typedef struct _md_t moduledata_t;
157 #define DECLARE_MODULE(name, b, c, d) \
158 moduledata_t *_g_##name = & b
159 #define MODULE_DEPEND(a, b, c, d, e)
162 #include <ip_dn_private.h>
163 #include <dn_sched.h>
170 mq_append(struct mq *q, struct mbuf *m)
175 q->tail->m_nextpkt = m;
184 #endif /* _DN_TEST_H */