Deleted Added
full compact
ip_dummynet.h (50477) ip_dummynet.h (55009)
1/*
2 * Copyright (c) 1998 Luigi Rizzo
3 *
4 * Redistribution and use in source forms, with and without modification,
5 * are permitted provided that this entire comment appears intact.
6 *
7 * Redistribution in binary form may occur without any restrictions.
8 * Obviously, it would be nice if you gave credit where credit is due
9 * but requiring it would be too onerous.
10 *
11 * This software is provided ``AS IS'' without any warranties of any kind.
12 *
1/*
2 * Copyright (c) 1998 Luigi Rizzo
3 *
4 * Redistribution and use in source forms, with and without modification,
5 * are permitted provided that this entire comment appears intact.
6 *
7 * Redistribution in binary form may occur without any restrictions.
8 * Obviously, it would be nice if you gave credit where credit is due
9 * but requiring it would be too onerous.
10 *
11 * This software is provided ``AS IS'' without any warranties of any kind.
12 *
13 * $FreeBSD: head/sys/netinet/ip_dummynet.h 50477 1999-08-28 01:08:13Z peter $
13 * $FreeBSD: head/sys/netinet/ip_dummynet.h 55009 1999-12-22 19:13:38Z shin $
14 */
15
16#ifndef _IP_DUMMYNET_H
17#define _IP_DUMMYNET_H
18
19/*
20 * Definition of dummynet data structures.
21 * Dummynet handles a list of pipes, each one identified by a unique
22 * number (hopefully the list is short so we use a linked list).
23 *
24 * Each list contains a set of parameters identifying the pipe, and
25 * a set of packets queued on the pipe itself.
26 *
27 * I could have used queue macros, but the management i have
28 * is pretty simple and this makes the code more portable.
29 */
30
31/*
32 * struct dn_pkt identifies a packet in the dummynet queue. The
33 * first part is really an m_hdr for implementation purposes, and some
34 * fields are saved there. When passing the packet back to the ip_input/
35 * ip_output(), the struct is prepended to the mbuf chain with type
36 * MT_DUMMYNET, and contains the pointer to the matching rule.
37 */
38struct dn_pkt {
39 struct m_hdr hdr ;
40#define dn_next hdr.mh_nextpkt /* next element in queue */
41#define dn_m hdr.mh_next /* packet to be forwarded */
42#define dn_dst hdr.mh_len /* dst, for ip_output */
43#define dn_dir hdr.mh_flags /* IP_FW_F_IN or IP_FW_F_OUT */
44 int delay; /* stays queued until delay=0 */
45 struct ifnet *ifp; /* interface, for ip_output */
46 struct route ro; /* route, for ip_output. MUST COPY */
14 */
15
16#ifndef _IP_DUMMYNET_H
17#define _IP_DUMMYNET_H
18
19/*
20 * Definition of dummynet data structures.
21 * Dummynet handles a list of pipes, each one identified by a unique
22 * number (hopefully the list is short so we use a linked list).
23 *
24 * Each list contains a set of parameters identifying the pipe, and
25 * a set of packets queued on the pipe itself.
26 *
27 * I could have used queue macros, but the management i have
28 * is pretty simple and this makes the code more portable.
29 */
30
31/*
32 * struct dn_pkt identifies a packet in the dummynet queue. The
33 * first part is really an m_hdr for implementation purposes, and some
34 * fields are saved there. When passing the packet back to the ip_input/
35 * ip_output(), the struct is prepended to the mbuf chain with type
36 * MT_DUMMYNET, and contains the pointer to the matching rule.
37 */
38struct dn_pkt {
39 struct m_hdr hdr ;
40#define dn_next hdr.mh_nextpkt /* next element in queue */
41#define dn_m hdr.mh_next /* packet to be forwarded */
42#define dn_dst hdr.mh_len /* dst, for ip_output */
43#define dn_dir hdr.mh_flags /* IP_FW_F_IN or IP_FW_F_OUT */
44 int delay; /* stays queued until delay=0 */
45 struct ifnet *ifp; /* interface, for ip_output */
46 struct route ro; /* route, for ip_output. MUST COPY */
47 int flags; /* flags, for ip_output */
47
48#ifdef DUMMYNET_DEBUG
49 struct timeval beg, mid; /* testing only */
50 int act_delay; /* testing only */
51 int in_delay; /* testing only */
52#endif
53};
54
55struct dn_queue {
56 struct dn_pkt *head, *tail;
57} ;
58
59/*
60 * descriptor of a pipe. The flags field will be used to speed up the
61 * forwarding code paths, in case some of the parameters are not
62 * used.
63 */
64struct dn_pipe { /* a pipe */
65 struct dn_pipe *next ;
66
67 u_short pipe_nr ; /* number */
68 u_short flags ; /* to speed up things */
69#define DN_HAVE_BW 1
70#define DN_HAVE_QUEUE 2
71#define DN_HAVE_DELAY 4
72 int bandwidth; /* really, bytes/tick. */
73 int queue_size ;
74 int queue_size_bytes ;
75 int delay ; /* really, ticks */
76 int plr ; /* pkt loss rate (2^31-1 means 100%) */
77
78 struct dn_queue r;
79 int r_len; /* elements in r_queue */
80 int r_len_bytes; /* bytes in r_queue */
81 int r_drops; /* drops from r_queue */
82 struct dn_queue p ;
83 int ticks_from_last_insert;
84 long numbytes; /* which can send or receive */
85};
86
87/*
88 * The following is used to define a new mbuf type that is
89 * prepended to the packet when it comes out of a pipe. The definition
90 * ought to go in /sys/sys/mbuf.h but here it is less intrusive.
91 */
92
93#define MT_DUMMYNET MT_CONTROL
94/*
95 * what to do of a packet when it comes out of a pipe
96 */
97#define DN_TO_IP_OUT 1
98#define DN_TO_IP_IN 2
99#define DN_TO_BDG_FWD 3
100
101#ifdef KERNEL
102
103MALLOC_DECLARE(M_IPFW);
104
105typedef int ip_dn_ctl_t __P((struct sockopt *)) ;
106extern ip_dn_ctl_t *ip_dn_ctl_ptr;
107
108void dn_rule_delete(void *r); /* used in ip_fw.c */
109int dummynet_io(int pipe, int dir,
110 struct mbuf *m, struct ifnet *ifp, struct route *ro,
111 struct sockaddr_in * dst,
48
49#ifdef DUMMYNET_DEBUG
50 struct timeval beg, mid; /* testing only */
51 int act_delay; /* testing only */
52 int in_delay; /* testing only */
53#endif
54};
55
56struct dn_queue {
57 struct dn_pkt *head, *tail;
58} ;
59
60/*
61 * descriptor of a pipe. The flags field will be used to speed up the
62 * forwarding code paths, in case some of the parameters are not
63 * used.
64 */
65struct dn_pipe { /* a pipe */
66 struct dn_pipe *next ;
67
68 u_short pipe_nr ; /* number */
69 u_short flags ; /* to speed up things */
70#define DN_HAVE_BW 1
71#define DN_HAVE_QUEUE 2
72#define DN_HAVE_DELAY 4
73 int bandwidth; /* really, bytes/tick. */
74 int queue_size ;
75 int queue_size_bytes ;
76 int delay ; /* really, ticks */
77 int plr ; /* pkt loss rate (2^31-1 means 100%) */
78
79 struct dn_queue r;
80 int r_len; /* elements in r_queue */
81 int r_len_bytes; /* bytes in r_queue */
82 int r_drops; /* drops from r_queue */
83 struct dn_queue p ;
84 int ticks_from_last_insert;
85 long numbytes; /* which can send or receive */
86};
87
88/*
89 * The following is used to define a new mbuf type that is
90 * prepended to the packet when it comes out of a pipe. The definition
91 * ought to go in /sys/sys/mbuf.h but here it is less intrusive.
92 */
93
94#define MT_DUMMYNET MT_CONTROL
95/*
96 * what to do of a packet when it comes out of a pipe
97 */
98#define DN_TO_IP_OUT 1
99#define DN_TO_IP_IN 2
100#define DN_TO_BDG_FWD 3
101
102#ifdef KERNEL
103
104MALLOC_DECLARE(M_IPFW);
105
106typedef int ip_dn_ctl_t __P((struct sockopt *)) ;
107extern ip_dn_ctl_t *ip_dn_ctl_ptr;
108
109void dn_rule_delete(void *r); /* used in ip_fw.c */
110int dummynet_io(int pipe, int dir,
111 struct mbuf *m, struct ifnet *ifp, struct route *ro,
112 struct sockaddr_in * dst,
112 struct ip_fw_chain *rule);
113 struct ip_fw_chain *rule, int flags);
113#endif /* KERNEL */
114
115#endif /* _IP_DUMMYNET_H */
114#endif /* KERNEL */
115
116#endif /* _IP_DUMMYNET_H */