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