xref: /netbsd-src/usr.sbin/npf/npftest/libnpftest/npf_test.h (revision 946379e7b37692fc43f68eb0d1c10daa0a7f3b6c)
1 /*	$NetBSD: npf_test.h,v 1.15 2014/02/13 03:34:40 rmind Exp $	*/
2 
3 /*
4  * Public Domain.
5  */
6 
7 #ifndef _LIB_NPF_TEST_H_
8 #define _LIB_NPF_TEST_H_
9 
10 #include <sys/types.h>
11 #include <sys/mbuf.h>
12 
13 #include <netinet/in_systm.h>
14 #include <netinet/in.h>
15 #include <netinet6/in6.h>
16 
17 #include <netinet/ip.h>
18 #include <netinet/ip6.h>
19 #include <netinet/tcp.h>
20 #include <netinet/udp.h>
21 #include <netinet/ip_icmp.h>
22 
23 #include <net/if.h>
24 #include <net/if_ether.h>
25 #include <net/ethertypes.h>
26 
27 /* Test interfaces and IP addresses. */
28 #define	IFNAME_EXT	"npftest0"
29 #define	IFNAME_INT	"npftest1"
30 #define	IFNAME_TEST	"npftest2"
31 
32 #define	LOCAL_IP1	"10.1.1.1"
33 #define	LOCAL_IP2	"10.1.1.2"
34 #define	LOCAL_IP3	"10.1.1.3"
35 
36 /* Note: RFC 5737 compliant addresses. */
37 #define	PUB_IP1		"192.0.2.1"
38 #define	PUB_IP2		"192.0.2.2"
39 #define	PUB_IP3		"192.0.2.3"
40 
41 #define	REMOTE_IP1	"192.0.2.101"
42 #define	REMOTE_IP2	"192.0.2.102"
43 #define	REMOTE_IP3	"192.0.2.103"
44 
45 #define	LOCAL_IP6	"fd01:203:405:1::1234"
46 #define	REMOTE_IP6	"2001:db8:fefe::1010"
47 #define	EXPECTED_IP6	"2001:db8:1:d550::1234"
48 
49 void		npf_test_init(int (*)(int, const char *, void *),
50 		    const char *(*)(int, const void *, char *, socklen_t),
51 		    long (*)(void));
52 int		npf_test_load(const void *);
53 ifnet_t *	npf_test_addif(const char *, bool, bool);
54 ifnet_t *	npf_test_getif(const char *);
55 
56 int		npf_test_statetrack(const void *, size_t, ifnet_t *,
57 		    bool, int64_t *);
58 void		npf_test_conc(bool, unsigned);
59 
60 struct mbuf *	mbuf_getwithdata(const void *, size_t);
61 struct mbuf *	mbuf_construct_ether(int);
62 struct mbuf *	mbuf_construct(int);
63 struct mbuf *	mbuf_construct6(int);
64 void *		mbuf_return_hdrs(struct mbuf *, bool, struct ip **);
65 void *		mbuf_return_hdrs6(struct mbuf *, struct ip6_hdr **);
66 void		mbuf_icmp_append(struct mbuf *, struct mbuf *);
67 
68 bool		npf_nbuf_test(bool);
69 bool		npf_bpf_test(bool);
70 bool		npf_table_test(bool, void *, size_t);
71 bool		npf_state_test(bool);
72 
73 bool		npf_rule_test(bool);
74 bool		npf_nat_test(bool);
75 
76 int		npf_inet_pton(int, const char *, void *);
77 const char *	npf_inet_ntop(int, const void *, char *, socklen_t);
78 
79 #endif
80