/*1*2* userspace compatibility code for dummynet schedulers3*/45#ifndef _DN_TEST_H6#define _DN_TEST_H78#ifdef __cplusplus9extern "C" {10#endif1112#include <inttypes.h>13#include <stdio.h>14#include <stdlib.h>15#include <strings.h> /* bzero, ffs, ... */16#include <string.h> /* strcmp */17#include <errno.h>18#include <sys/queue.h>19#include <sys/time.h>2021extern int debug;22#define ND(fmt, args...) do {} while (0)23#define D1(fmt, args...) do {} while (0)24#define D(fmt, args...) fprintf(stderr, "%-10s %4d %-8s " fmt "\n", \25__FILE__, __LINE__, __FUNCTION__, ## args)26#define DX(lev, fmt, args...) do { \27if (debug > lev) D(fmt, ## args); } while (0)2829#ifndef offsetof30#define offsetof(t,m) (int)(intptr_t)((&((t *)0L)->m))31#endif3233#if defined(__APPLE__) // XXX osx34typedef unsigned int u_int;35#endif /* osx */3637#include <mylist.h>3839/* prevent include of other system headers */40#define _NETINET_IP_VAR_H_ /* ip_fw_args */41#define _IPFW2_H42#define _SYS_MBUF_H_4344enum {45DN_QUEUE,46};4748enum {49DN_SCHED_FIFO,50DN_SCHED_WF2QP,51};5253/* from ip_dummynet.h, fields used in ip_dn_private.h */54struct dn_id {55uint16_t len; /* total len inc. this header */56uint8_t type;57uint8_t subtype;58// uint32_t id; /* generic id */59};6061/* (from ip_dummynet.h)62* A flowset, which is a template for flows. Contains parameters63* from the command line: id, target scheduler, queue sizes, plr,64* flow masks, buckets for the flow hash, and possibly scheduler-65* specific parameters (weight, quantum and so on).66*/67struct dn_fs {68/* generic scheduler parameters. Leave them at -1 if unset.69* Now we use 0: weight, 1: lmax, 2: priority70*/71int par[4]; /* flowset parameters */7273/* simulation entries.74* 'index' is not strictly necessary75* y is used for the inverse mapping ,76*/77int index;78int y; /* inverse mapping */79int base_y; /* inverse mapping */80int next_y; /* inverse mapping */81int n_flows;82int first_flow;83int next_flow; /* first_flow + n_flows */84/*85* when generating, let 'cur' go from 0 to n_flows-1,86* then point to flow first_flow + cur87*/88int cur;89};9091/* (ip_dummynet.h)92* scheduler template, indicating nam, number, mask and buckets93*/94struct dn_sch {95};9697/* (from ip_dummynet.h)98* dn_flow collects flow_id and stats for queues and scheduler99* instances, and is used to pass these info to userland.100* oid.type/oid.subtype describe the object, oid.id is number101* of the parent object.102*/103struct dn_flow {104struct dn_id oid;105uint64_t tot_pkts;106uint64_t tot_bytes;107uint32_t length; /* Queue length, in packets */108uint32_t len_bytes; /* Queue length, in bytes */109uint32_t drops;110//uint32_t flow_id;111112/* the following fields are used by the traffic generator.113*/114struct list_head h; /* used by the generator */115116/* bytes served by the flow since the last backlog time */117uint64_t bytes;118/* bytes served by the system at the last backlog time */119uint64_t sch_bytes;120};121122/* the link */123struct dn_link {124};125126struct ip_fw_args {127};128129struct mbuf {130struct {131int len;132} m_pkthdr;133struct mbuf *m_nextpkt;134uint32_t flow_id; /* for testing, index of a flow */135//int flowset_id; /* for testing, index of a flowset */136//void *cfg; /* config args */137};138139#define MALLOC_DECLARE(x) extern volatile int __dummy__ ## x140#define KASSERT(x, y) do { if (!(x)) printf y ; exit(0); } while (0)141struct ipfw_flow_id {142};143144typedef void * module_t;145146struct _md_t {147const char *name;148int (*f)(module_t, int, void *);149void *p;150};151152typedef struct _md_t moduledata_t;153154#define DECLARE_MODULE(name, b, c, d) \155moduledata_t *_g_##name = & b156#define MODULE_DEPEND(a, b, c, d, e)157158#include <dn_heap.h>159#include <ip_dn_private.h>160#include <dn_sched.h>161162#ifndef __FreeBSD__163int fls(int);164#endif165166static inline void167mq_append(struct mq *q, struct mbuf *m)168{169if (q->head == NULL)170q->head = m;171else172q->tail->m_nextpkt = m;173q->tail = m;174m->m_nextpkt = NULL;175}176177#ifdef __cplusplus178}179#endif180181#endif /* _DN_TEST_H */182183184