This repo is obsolete, please see git://git.code.sf.net/p/dummynet/code@master
[ipfw.git] / dummynet2 / missing.h
1 /*
2  * Copyright (C) 2009 Luigi Rizzo, Marta Carbone, Universita` di Pisa
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions
6  * are met:
7  * 1. Redistributions of source code must retain the above copyright
8  *    notice, this list of conditions and the following disclaimer.
9  * 2. Redistributions in binary form must reproduce the above copyright
10  *    notice, this list of conditions and the following disclaimer in the
11  *    documentation and/or other materials provided with the distribution.
12  *
13  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
14  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
17  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
19  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
20  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
21  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
22  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
23  * SUCH DAMAGE.
24  */
25
26 /*
27  * $Id: missing.h 11275 2012-06-10 17:27:40Z marta $
28  *
29  * Header for kernel variables and functions that are not available in
30  * userland.
31  */
32
33 #ifndef _MISSING_H_
34 #define _MISSING_H_
35
36 /* sysctl.h and module.h are included before cdefs.h 
37  * because of cdefs.h defines __unused */
38
39 #include <linux/sysctl.h>
40 #include <linux/module.h>
41 #include <sys/cdefs.h>
42 #include <linux/moduleparam.h>
43
44 /* portability features, to be set before the rest: */
45 #define HAVE_NET_IPLEN          /* iplen/ipoff in net format */
46 #define WITHOUT_BPF             /* do not use bpf logging */
47
48 #ifdef _WIN32
49
50 #ifndef DEFINE_SPINLOCK
51 #define DEFINE_SPINLOCK(x)      FAST_MUTEX x
52 #endif
53 /* spinlock --> Guarded Mutex KGUARDED_MUTEX */
54 /* http://www.reactos.org/wiki/index.php/Guarded_Mutex */
55 #define spin_lock_init(_l)
56 #define spin_lock_bh(_l)
57 #define spin_unlock_bh(_l)
58
59 #include <sys/socket.h>         /* bsd-compat.c */
60 #include <netinet/in.h>         /* bsd-compat.c */
61 #include <netinet/ip.h>         /* local version */
62 #define INADDR_TO_IFP(a, b) b = NULL
63
64 #else   /* __linux__ */
65
66 #define MALLOC_DECLARE(x)       /* nothing */
67 #include <linux/time.h>         /* do_gettimeofday */
68 #include <netinet/ip.h>         /* local version */
69 struct inpcb;
70
71 /*
72  * Kernel locking support.
73  * FreeBSD uses mtx in dummynet.c and struct rwlock ip_fw2.c
74  *
75  * In linux we use spinlock_bh to implement both.
76  * For 'struct rwlock' we need an #ifdef to change it to spinlock_t
77  */
78
79 #ifndef DEFINE_SPINLOCK /* this is for linux 2.4 */
80 #define DEFINE_SPINLOCK(x)   spinlock_t x = SPIN_LOCK_UNLOCKED
81 #endif
82
83
84 #define rw_assert(a, b)
85 #define rw_destroy(_l)
86 #define rw_init(_l, msg)        spin_lock_init(_l)
87 #define rw_rlock(_l)            spin_lock_bh(_l)
88 #define rw_runlock(_l)          spin_unlock_bh(_l)
89 #define rw_wlock(_l)            spin_lock_bh(_l)
90 #define rw_wunlock(_l)          spin_unlock_bh(_l)
91 #define rw_init_flags(_l, s, v)
92
93 #define mtx_assert(a, b)
94 #define mtx_destroy(m)
95 #define mtx_init(m, a,b,c)      spin_lock_init(m)
96 #define mtx_lock(_l)            spin_lock_bh(_l)
97 #define mtx_unlock(_l)          spin_unlock_bh(_l)
98
99 #endif  /* __linux__ */
100 /* end of locking support */
101
102 /*
103  * Reference to an ipfw rule that can be carried outside critical sections.
104  * A rule is identified by rulenum:rule_id which is ordered.
105  * In version chain_id the rule can be found in slot 'slot', so
106  * we don't need a lookup if chain_id == chain->id.
107  *
108  * On exit from the firewall this structure refers to the rule after
109  * the matching one (slot points to the new rule; rulenum:rule_id-1
110  * is the matching rule), and additional info (e.g. info often contains
111  * the insn argument or tablearg in the low 16 bits, in host format).
112  * On entry, the structure is valid if slot>0, and refers to the starting
113  * rules. 'info' contains the reason for reinject, e.g. divert port,
114  * divert direction, and so on.
115  */
116 struct ipfw_rule_ref {
117         uint32_t        slot;           /* slot for matching rule       */
118         uint32_t        rulenum;        /* matching rule number         */
119         uint32_t        rule_id;        /* matching rule id             */
120         uint32_t        chain_id;       /* ruleset id                   */
121         uint32_t        info;           /* see below                    */
122 };
123
124 enum {
125         IPFW_INFO_MASK  = 0x0000ffff,
126         IPFW_INFO_OUT   = 0x00000000,   /* outgoing, just for convenience */
127         IPFW_INFO_IN    = 0x80000000,   /* incoming, overloads dir */
128         IPFW_ONEPASS    = 0x40000000,   /* One-pass, do not reinject */
129         IPFW_IS_MASK    = 0x30000000,   /* which source ? */
130         IPFW_IS_DIVERT  = 0x20000000,
131         IPFW_IS_DUMMYNET =0x10000000,
132         IPFW_IS_PIPE    = 0x08000000,   /* pipe=1, queue = 0 */
133 };
134
135 /* in netinet/in.h */
136 #define        in_nullhost(x)  ((x).s_addr == INADDR_ANY)
137
138 /* bzero not present on linux, but this should go in glue.h */
139 #define bzero(s, n) memset(s, 0, n)
140 #define bcmp(p1, p2, n) memcmp(p1, p2, n)
141
142 /* ethernet stuff */
143 #define ETHERTYPE_IP            0x0800  /* IP protocol */
144 //#define       ETHER_ADDR_LEN          6       /* length of an Ethernet address */
145 struct ether_header {
146         u_char  ether_dhost[ETHER_ADDR_LEN];
147         u_char  ether_shost[ETHER_ADDR_LEN];
148         u_short ether_type;
149 };
150
151 #define ETHER_TYPE_LEN          2       /* length of the Ethernet type field */
152 #define ETHER_HDR_LEN           (ETHER_ADDR_LEN*2+ETHER_TYPE_LEN)
153
154 /*
155  * Historically, BSD keeps ip_len and ip_off in host format
156  * when doing layer 3 processing, and this often requires
157  * to translate the format back and forth.
158  * To make the process explicit, we define a couple of macros
159  * that also take into account the fact that at some point
160  * we may want to keep those fields always in net format.
161  */
162
163 #if (BYTE_ORDER == BIG_ENDIAN) || defined(HAVE_NET_IPLEN)
164 #define SET_NET_IPLEN(p)        do {} while (0)
165 #define SET_HOST_IPLEN(p)       do {} while (0)
166 #else /* never on linux */
167 #define SET_NET_IPLEN(p)        do {            \
168         struct ip *h_ip = (p);                  \
169         h_ip->ip_len = htons(h_ip->ip_len);     \
170         h_ip->ip_off = htons(h_ip->ip_off);     \
171         } while (0)
172
173 #define SET_HOST_IPLEN(p)       do {            \
174         struct ip *h_ip = (p);                  \
175         h_ip->ip_len = ntohs(h_ip->ip_len);     \
176         h_ip->ip_off = ntohs(h_ip->ip_off);     \
177         } while (0)
178 #endif /* !HAVE_NET_IPLEN */
179
180 /* ip_dummynet.c */
181 #define __FreeBSD_version 500035
182
183 #ifdef __linux__
184 struct moduledata;
185 int my_mod_register(const char *name,
186         int order, struct moduledata *mod, void *init, void *uninit);
187
188 /* define some macro for ip_dummynet */
189
190 struct malloc_type {
191 };
192
193 #define MALLOC_DEFINE(type, shortdesc, longdesc)        \
194         struct malloc_type type[1]; void *md_dummy_ ## type = type
195
196 #define CTASSERT(x)
197
198 /* log... does not use the first argument */
199 #define LOG_ERR         0x100
200 #define LOG_INFO        0x200
201 #define log(_level, fmt, arg...)  do {                  \
202         int __unused _qwerty=_level; printk(KERN_ERR fmt, ##arg); } while (0)
203
204 /*
205  * gettimeofday would be in sys/time.h but it is not
206  * visible if _KERNEL is defined
207  */
208 int gettimeofday(struct timeval *, struct timezone *);
209
210 #else  /* _WIN32 */
211 #define MALLOC_DEFINE(a,b,c)
212 #endif /* _WIN32 */
213
214 extern int      hz;
215 extern long     tick;           /* exists in 2.4 but not in 2.6 */
216 extern int      bootverbose;
217 extern struct timeval boottime;
218
219 /* The time_uptime a FreeBSD variable increased each second */
220 #ifdef __linux__
221 #if LINUX_VERSION_CODE > KERNEL_VERSION(2,4,37) /* revise boundaries */
222 #define time_uptime get_seconds()
223 #else /* OpenWRT */
224 #define time_uptime CURRENT_TIME
225 #endif
226 #else /* WIN32 */
227 #define time_uptime time_uptime_w32()
228 #endif
229
230 extern int      max_linkhdr;
231 extern int      ip_defttl;
232 extern u_long   in_ifaddrhmask;                         /* mask for hash table */
233 extern struct in_ifaddrhashhead *in_ifaddrhashtbl;    /* inet addr hash table  */
234
235 /*-------------------------------------------------*/
236
237 /* define, includes and functions missing in linux */
238 /* include and define */
239 #include <arpa/inet.h>          /* inet_ntoa */
240
241 struct mbuf;
242
243 /* used by ip_dummynet.c */
244 void reinject_drop(struct mbuf* m);
245
246 #include <linux/errno.h>        /* error define */
247 #include <linux/if.h>           /* IFNAMESIZ */
248
249 void rn_init(int);
250 /*
251  * some network structure can be defined in the bsd way
252  * by using the _FAVOR_BSD definition. This is not true
253  * for icmp structure.
254  * XXX struct icmp contains bsd names in 
255  * /usr/include/netinet/ip_icmp.h
256  */
257 #ifdef __linux__
258 #define icmp_code code
259 #define icmp_type type
260
261 /* linux in6_addr has no member __u6_addr
262  * replace the whole structure ?
263  */
264 #define __u6_addr       in6_u
265 #define __u6_addr32     u6_addr32
266 #endif /* __linux__ */
267
268 /* defined in linux/sctp.h with no bsd definition */
269 struct sctphdr {
270         uint16_t src_port;      /* source port */
271         uint16_t dest_port;     /* destination port */
272         uint32_t v_tag;         /* verification tag of packet */
273         uint32_t checksum;      /* Adler32 C-Sum */
274         /* chunks follow... */
275 };
276
277 /* missing definition */
278 #define TH_FIN  0x01
279 #define TH_SYN  0x02
280 #define TH_RST  0x04
281 #define TH_ACK  0x10
282
283 #define RTF_CLONING     0x100           /* generate new routes on use */
284
285 #define IPPROTO_OSPFIGP         89              /* OSPFIGP */
286 #define IPPROTO_CARP            112             /* CARP */
287 #ifndef _WIN32
288 #define IPPROTO_IPV4            IPPROTO_IPIP    /* for compatibility */
289 #endif
290
291 #define CARP_VERSION            2
292 #define CARP_ADVERTISEMENT      0x01
293
294 #define PRIV_NETINET_IPFW       491     /* Administer IPFW firewall. */
295
296 #define IP_FORWARDING           0x1             /* most of ip header exists */
297
298 #define NETISR_IP       2               /* same as AF_INET */
299
300 #define PRIV_NETINET_DUMMYNET   494     /* Administer DUMMYNET. */
301
302 extern int securelevel;
303
304 struct carp_header {
305 #if BYTE_ORDER == LITTLE_ENDIAN
306         u_int8_t        carp_type:4,
307                         carp_version:4;
308 #endif
309 #if BYTE_ORDER == BIG_ENDIAN
310         u_int8_t        carp_version:4,
311                         carp_type:4;
312 #endif
313 };
314
315 struct pim {
316         int dummy;      /* windows compiler does not like empty definition */
317 };
318
319 #ifndef _WIN32
320 struct route {
321         struct  rtentry *ro_rt;
322         struct  sockaddr ro_dst;
323 };
324 #endif
325
326 struct ifaltq {
327         void *ifq_head;
328 };
329
330 /*
331  * ifnet->if_snd is used in ip_dummynet.c to take the transmission
332  * clock.
333  */
334 #if defined( __linux__)
335 #define if_xname        name
336 #define if_snd          XXX
337 #elif defined( _WIN32 )
338 /* used in ip_dummynet.c */
339 struct ifnet {
340         char    if_xname[IFNAMSIZ];     /* external name (name + unit) */
341 //        struct ifaltq if_snd;          /* output queue (includes altq) */
342 };
343
344 struct net_device {
345         char    if_xname[IFNAMSIZ];     /* external name (name + unit) */
346 };
347 #endif
348
349 /* involves mbufs */
350 int in_cksum(struct mbuf *m, int len);
351 #define divert_cookie(mtag) 0
352 #define divert_info(mtag) 0
353 #define pf_find_mtag(a) NULL
354 #define pf_get_mtag(a) NULL
355 #ifndef _WIN32
356 #define AF_LINK AF_ASH  /* ? our sys/socket.h */
357 #endif
358
359 /* search local the ip addresses, used for the "me" keyword */
360 #include <linux/inetdevice.h>
361 #define INADDR_TO_IFP(ip, b)    \
362         b = ip_dev_find((struct net *)&init_net, ip.s_addr)
363
364 /* we don't pullup, either success or free and fail */
365 #define m_pullup(m, x)                                  \
366         ((m)->m_len >= x ? (m) : (FREE_PKT(m), NULL))
367
368 struct pf_mtag {
369         void            *hdr;           /* saved hdr pos in mbuf, for ECN */
370         sa_family_t      af;            /* for ECN */
371         u_int32_t        qid;           /* queue id */
372 };
373
374 #if 0 // ndef radix
375 /* radix stuff in radix.h and radix.c */
376 struct radix_node {
377         caddr_t rn_key;         /* object of search */
378         caddr_t rn_mask;        /* netmask, if present */
379 };
380 #endif /* !radix */
381
382 /* missing kernel functions */
383 char *inet_ntoa(struct in_addr ina);
384 int random(void);
385
386 /*
387  * Return the risult of a/b
388  *
389  * this is used in linux kernel space,
390  * since the 64bit division needs to
391  * be done using a macro
392  */
393 int64_t
394 div64(int64_t a, int64_t b);
395
396 char *
397 inet_ntoa_r(struct in_addr ina, char *buf);
398
399 /* from bsd sys/queue.h */
400 #define TAILQ_FOREACH_SAFE(var, head, field, tvar)                      \
401         for ((var) = TAILQ_FIRST((head));                               \
402             (var) && ((tvar) = TAILQ_NEXT((var), field), 1);            \
403             (var) = (tvar))
404
405 #define SLIST_FOREACH_SAFE(var, head, field, tvar)                      \
406         for ((var) = SLIST_FIRST((head));                               \
407             (var) && ((tvar) = SLIST_NEXT((var), field), 1);            \
408             (var) = (tvar))
409
410 /* depending of linux version */
411 #ifndef ETHERTYPE_IPV6
412 #define ETHERTYPE_IPV6          0x86dd          /* IP protocol version 6 */
413 #endif
414
415 /*-------------------------------------------------*/
416 #define RT_NUMFIBS 1
417 extern u_int rt_numfibs;
418
419 /* involves kernel locking function */
420 #ifdef RTFREE
421 #undef RTFREE
422 #define RTFREE(a) fprintf(stderr, "RTFREE: commented out locks\n");
423 #endif
424
425 void getmicrouptime(struct timeval *tv);
426
427 /* from sys/netinet/ip_output.c */
428 struct ip_moptions;
429 struct route;
430 struct ip;
431
432 struct mbuf *ip_reass(struct mbuf *);
433 u_short in_cksum_hdr(struct ip *);
434 int ip_output(struct mbuf *m, struct mbuf *opt, struct route *ro, int flags,
435     struct ip_moptions *imo, struct inpcb *inp);
436
437 /* from net/netisr.c */
438 void netisr_dispatch(int num, struct mbuf *m);
439
440 /* definition moved in missing.c */
441 int sooptcopyout(struct sockopt *sopt, const void *buf, size_t len);
442
443 int sooptcopyin(struct sockopt *sopt, void *buf, size_t len, size_t minlen);
444
445 /* defined in session.c */
446 int priv_check(struct thread *td, int priv);
447
448 /* struct ucred is in linux/socket.h and has pid, uid, gid.
449  * We need a 'bsd_ucred' to store also the extra info
450  */
451
452 struct bsd_ucred {
453         uid_t           uid;
454         gid_t           gid;
455         uint32_t        xid;
456         uint32_t        nid;
457 };
458
459 int
460 cred_check(void *insn, int proto, struct ifnet *oif,
461     struct in_addr dst_ip, u_int16_t dst_port, struct in_addr src_ip,
462     u_int16_t src_port, struct bsd_ucred *u, int *ugid_lookupp,
463     struct sk_buff *skb);
464
465 int securelevel_ge(struct ucred *cr, int level);
466
467 struct sysctl_oid;
468 struct sysctl_req;
469
470 #ifdef _WIN32
471 #define module_param_named(_name, _var, _ty, _perm)
472 #else /* !_WIN32 */
473
474 /* Linux 2.4 is mostly for openwrt */
475 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0)
476 #include <linux/bitops.h>        /* generic_ffs() used in ip_fw2.c */
477 typedef uint32_t __be32;
478 typedef uint16_t __be16;
479 struct sock;
480 struct net;
481 struct inet_hashinfo;
482 struct sock *inet_lookup(
483         struct inet_hashinfo *hashinfo,
484         const __be32 saddr, const __be16 sport,
485         const __be32 daddr, const __be16 dport,
486         const int dif);
487 struct sock *tcp_v4_lookup(u32 saddr, u16 sport, u32 daddr, u16 dport, int dif);
488 #endif /* Linux < 2.6 */
489
490 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,17) &&      \
491         LINUX_VERSION_CODE > KERNEL_VERSION(2,6,16)     /* XXX NOT sure, in 2.6.9 give an error */
492 #define module_param_named(_name, _var, _ty, _perm)     \
493         //module_param(_name, _ty, 0644)
494 #endif
495
496 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)
497 typedef unsigned long uintptr_t;
498
499 #ifdef __i386__
500 static inline unsigned long __fls(unsigned long word)
501 {
502         asm("bsr %1,%0"
503             : "=r" (word)
504             : "rm" (word));
505         return word;
506 }
507 #endif
508
509 #endif /* LINUX < 2.6.25 */
510
511 #endif /* !_WIN32 so maybe __linux__ */
512
513 #if defined (__linux__) && !defined (EMULATE_SYSCTL)
514 #define SYSCTL_DECL(_1)
515 #define SYSCTL_OID(_1, _2, _3, _4, _5, _6, _7, _8)
516 #define SYSCTL_NODE(_1, _2, _3, _4, _5, _6)
517 #define _SYSCTL_BASE(_name, _var, _ty, _perm)           \
518         module_param_named(_name, *(_var), _ty,         \
519                 ( (_perm) == CTLFLAG_RD) ? 0444: 0644 )
520 #define SYSCTL_PROC(_base, _oid, _name, _mode, _var, _val, _desc, _a, _b)
521
522 #define SYSCTL_INT(_base, _oid, _name, _mode, _var, _val, _desc)        \
523         _SYSCTL_BASE(_name, _var, int, _mode)
524
525 #define SYSCTL_LONG(_base, _oid, _name, _mode, _var, _val, _desc)       \
526         _SYSCTL_BASE(_name, _var, long, _mode)
527
528 #define SYSCTL_ULONG(_base, _oid, _name, _mode, _var, _val, _desc)      \
529         _SYSCTL_BASE(_name, _var, ulong, _mode)
530
531 #define SYSCTL_UINT(_base, _oid, _name, _mode, _var, _val, _desc)       \
532          _SYSCTL_BASE(_name, _var, uint, _mode)
533
534 #define TUNABLE_INT(_name, _ptr)
535
536 #define SYSCTL_VNET_PROC                SYSCTL_PROC
537 #define SYSCTL_VNET_INT                 SYSCTL_INT
538
539 #endif
540
541 #define SYSCTL_HANDLER_ARGS             \
542         struct sysctl_oid *oidp, void *arg1, int arg2, struct sysctl_req *req
543 int sysctl_handle_int(SYSCTL_HANDLER_ARGS);
544 int sysctl_handle_long(SYSCTL_HANDLER_ARGS); 
545
546
547 void ether_demux(struct ifnet *ifp, struct mbuf *m);
548
549 int ether_output_frame(struct ifnet *ifp, struct mbuf *m);
550
551 void in_rtalloc_ign(struct route *ro, u_long ignflags, u_int fibnum);
552
553 void icmp_error(struct mbuf *n, int type, int code, uint32_t dest, int mtu);
554
555 void rtfree(struct rtentry *rt);
556
557 u_short in_cksum_skip(struct mbuf *m, int len, int skip);
558
559 #ifdef INP_LOCK_ASSERT
560 #undef INP_LOCK_ASSERT
561 #define INP_LOCK_ASSERT(a)
562 #endif
563
564 int jailed(struct ucred *cred);
565
566 /*
567 * Return 1 if an internet address is for a ``local'' host
568 * (one to which we have a connection).  If subnetsarelocal
569 * is true, this includes other subnets of the local net.
570 * Otherwise, it includes only the directly-connected (sub)nets.
571 */
572 int in_localaddr(struct in_addr in);
573
574 /* the prototype is already in the headers */
575 //int ipfw_chg_hook(SYSCTL_HANDLER_ARGS); 
576
577 int fnmatch(const char *pattern, const char *string, int flags);
578
579 int
580 linux_lookup(const int proto, const __be32 saddr, const __be16 sport,
581         const __be32 daddr, const __be16 dport,
582         struct sk_buff *skb, int dir, struct bsd_ucred *u);
583
584 /* vnet wrappers, in vnet.h and ip_var.h */
585 //int ipfw_init(void);
586 //void ipfw_destroy(void);
587
588 #define MTAG_IPFW       1148380143      /* IPFW-tagged cookie */
589 #define MTAG_IPFW_RULE  1262273568      /* rule reference */
590
591 struct ip_fw_args;
592 extern int (*ip_dn_io_ptr)(struct mbuf **m, int dir, struct ip_fw_args *fwa);
593
594 #define curvnet                 NULL
595 #define CURVNET_SET(_v)
596 #define CURVNET_RESTORE()
597 #define VNET_ASSERT(condition)
598
599 #define VNET_NAME(n)            n
600 #define VNET_DECLARE(t, n)      extern t n
601 #define VNET_DEFINE(t, n)       t n
602 #define _VNET_PTR(b, n)         &VNET_NAME(n)
603 /*
604  * Virtualized global variable accessor macros.
605  */
606 #define VNET_VNET_PTR(vnet, n)          (&(n))
607 #define VNET_VNET(vnet, n)              (n)
608
609 #define VNET_PTR(n)             (&(n))
610 #define VNET(n)                 (n)
611
612 VNET_DECLARE(int, ip_defttl);
613 #define V_ip_defttl    VNET(ip_defttl);
614
615 int ipfw_check_hook(void *arg, struct mbuf **m0, struct ifnet *ifp,
616         int dir, struct inpcb *inp);
617
618 /* hooks for divert */
619 extern void (*ip_divert_ptr)(struct mbuf *m, int incoming);
620
621 extern int (*ip_dn_ctl_ptr)(struct sockopt *);
622 typedef int ip_fw_ctl_t(struct sockopt *);
623 extern ip_fw_ctl_t *ip_fw_ctl_ptr;
624
625 /* netgraph prototypes */
626 typedef int ng_ipfw_input_t(struct mbuf **, int, struct ip_fw_args *, int);
627 extern  ng_ipfw_input_t *ng_ipfw_input_p;
628
629 /* For kernel ipfw_ether and ipfw_bridge. */
630 struct ip_fw_args;
631 typedef int ip_fw_chk_t(struct ip_fw_args *args);
632 extern  ip_fw_chk_t     *ip_fw_chk_ptr;
633
634 #define V_ip_fw_chk_ptr         VNET(ip_fw_chk_ptr)
635 #define V_ip_fw_ctl_ptr         VNET(ip_fw_ctl_ptr)
636 #define V_tcbinfo               VNET(tcbinfo)
637 #define V_udbinfo               VNET(udbinfo)
638
639 #endif /* !_MISSING_H_ */