Home | History | Annotate | Line # | Download | only in libnpftest
npf_test.h revision 1.19.2.1
      1       1.1     rmind /*
      2       1.1     rmind  * Public Domain.
      3       1.1     rmind  */
      4       1.1     rmind 
      5       1.1     rmind #ifndef _LIB_NPF_TEST_H_
      6       1.1     rmind #define _LIB_NPF_TEST_H_
      7       1.1     rmind 
      8      1.16  christos #ifdef _KERNEL
      9       1.1     rmind #include <sys/types.h>
     10       1.1     rmind #include <sys/mbuf.h>
     11       1.1     rmind 
     12       1.1     rmind #include <netinet/in_systm.h>
     13       1.1     rmind #include <netinet/in.h>
     14       1.1     rmind #include <netinet6/in6.h>
     15       1.1     rmind 
     16       1.1     rmind #include <netinet/ip.h>
     17       1.1     rmind #include <netinet/ip6.h>
     18       1.1     rmind #include <netinet/tcp.h>
     19       1.1     rmind #include <netinet/udp.h>
     20       1.1     rmind #include <netinet/ip_icmp.h>
     21       1.1     rmind 
     22       1.1     rmind #include <net/if.h>
     23       1.1     rmind #include <net/if_ether.h>
     24       1.1     rmind #include <net/ethertypes.h>
     25      1.16  christos #endif
     26       1.1     rmind 
     27      1.19     rmind #define	IFNAME_DUMMY	"npftest999"
     28      1.19     rmind 
     29       1.9     rmind /* Test interfaces and IP addresses. */
     30       1.9     rmind #define	IFNAME_EXT	"npftest0"
     31       1.9     rmind #define	IFNAME_INT	"npftest1"
     32      1.11     rmind #define	IFNAME_TEST	"npftest2"
     33       1.9     rmind 
     34       1.9     rmind #define	LOCAL_IP1	"10.1.1.1"
     35       1.9     rmind #define	LOCAL_IP2	"10.1.1.2"
     36       1.9     rmind #define	LOCAL_IP3	"10.1.1.3"
     37       1.9     rmind 
     38       1.9     rmind /* Note: RFC 5737 compliant addresses. */
     39       1.9     rmind #define	PUB_IP1		"192.0.2.1"
     40       1.9     rmind #define	PUB_IP2		"192.0.2.2"
     41      1.14     rmind #define	PUB_IP3		"192.0.2.3"
     42      1.14     rmind 
     43      1.14     rmind #define	REMOTE_IP1	"192.0.2.101"
     44      1.14     rmind #define	REMOTE_IP2	"192.0.2.102"
     45      1.14     rmind #define	REMOTE_IP3	"192.0.2.103"
     46      1.18     rmind #define	REMOTE_IP4	"192.0.2.104"
     47       1.9     rmind 
     48      1.15     rmind #define	LOCAL_IP6	"fd01:203:405:1::1234"
     49      1.15     rmind #define	REMOTE_IP6	"2001:db8:fefe::1010"
     50      1.15     rmind #define	EXPECTED_IP6	"2001:db8:1:d550::1234"
     51      1.15     rmind 
     52      1.18     rmind #define	NET_A_IP1	"10.100.7.126"
     53      1.18     rmind #define	NET_B_IP1	"10.255.7.126"
     54      1.18     rmind 
     55      1.16  christos #if defined(_NPF_STANDALONE)
     56      1.16  christos 
     57      1.16  christos #define	MLEN		512
     58      1.16  christos 
     59      1.16  christos struct mbuf {
     60      1.16  christos 	unsigned	m_flags;
     61      1.16  christos 	int		m_type;
     62      1.16  christos 	unsigned	m_len;
     63      1.16  christos 	void *		m_next;
     64      1.16  christos 	struct {
     65      1.16  christos 		int	len;
     66      1.16  christos 	} m_pkthdr;
     67      1.18     rmind 	void *		m_data;
     68      1.18     rmind 	unsigned char	m_data0[MLEN];
     69      1.16  christos };
     70      1.16  christos 
     71      1.16  christos #define	MT_FREE			0
     72      1.16  christos #define	M_UNWRITABLE(m, l)	false
     73      1.16  christos #define	M_NOWAIT		0x00001
     74      1.16  christos #define M_PKTHDR		0x00002
     75      1.16  christos 
     76  1.19.2.1    martin #define	m_get(x, y)		npfkern_m_get(NULL, 0, MLEN)
     77  1.19.2.1    martin #define	m_gethdr(x, y)		npfkern_m_get(NULL, M_PKTHDR, MLEN)
     78      1.16  christos #define	m_length(m)		npfkern_m_length(m)
     79      1.16  christos #define	m_freem(m)		npfkern_m_freem(m)
     80      1.16  christos #define	mtod(m, t)		((t)((m)->m_data))
     81      1.16  christos 
     82      1.16  christos #endif
     83      1.16  christos 
     84      1.19     rmind #define	CHECK_TRUE(x)	\
     85      1.19     rmind     if (!(x)) { printf("FAIL: %s line %d\n", __func__, __LINE__); return 0; }
     86      1.19     rmind 
     87      1.16  christos const npf_mbufops_t	npftest_mbufops;
     88      1.19     rmind const npf_ifops_t	npftest_ifops;
     89      1.16  christos 
     90  1.19.2.1    martin struct mbuf *	npfkern_m_get(npf_t *, unsigned, size_t);
     91      1.16  christos size_t		npfkern_m_length(const struct mbuf *);
     92      1.16  christos void		npfkern_m_freem(struct mbuf *);
     93      1.16  christos 
     94      1.15     rmind void		npf_test_init(int (*)(int, const char *, void *),
     95      1.15     rmind 		    const char *(*)(int, const void *, char *, socklen_t),
     96      1.15     rmind 		    long (*)(void));
     97      1.16  christos void		npf_test_fini(void);
     98      1.17     rmind int		npf_test_load(const void *, size_t, bool);
     99      1.11     rmind ifnet_t *	npf_test_addif(const char *, bool, bool);
    100      1.11     rmind ifnet_t *	npf_test_getif(const char *);
    101       1.9     rmind 
    102      1.11     rmind int		npf_test_statetrack(const void *, size_t, ifnet_t *,
    103       1.2     rmind 		    bool, int64_t *);
    104      1.10     rmind void		npf_test_conc(bool, unsigned);
    105       1.2     rmind 
    106       1.2     rmind struct mbuf *	mbuf_getwithdata(const void *, size_t);
    107       1.1     rmind struct mbuf *	mbuf_construct_ether(int);
    108       1.1     rmind struct mbuf *	mbuf_construct(int);
    109       1.4     rmind struct mbuf *	mbuf_construct6(int);
    110       1.1     rmind void *		mbuf_return_hdrs(struct mbuf *, bool, struct ip **);
    111      1.15     rmind void *		mbuf_return_hdrs6(struct mbuf *, struct ip6_hdr **);
    112       1.1     rmind void		mbuf_icmp_append(struct mbuf *, struct mbuf *);
    113       1.1     rmind 
    114      1.19     rmind struct mbuf *	mbuf_get_pkt(int, int, const char *, const char *, int, int);
    115      1.19     rmind npf_cache_t *	get_cached_pkt(struct mbuf *, const char *);
    116      1.19     rmind void		put_cached_pkt(npf_cache_t *);
    117      1.19     rmind 
    118       1.1     rmind bool		npf_nbuf_test(bool);
    119       1.7     rmind bool		npf_bpf_test(bool);
    120      1.13     rmind bool		npf_table_test(bool, void *, size_t);
    121       1.3     rmind bool		npf_state_test(bool);
    122       1.1     rmind 
    123       1.5     rmind bool		npf_rule_test(bool);
    124       1.5     rmind bool		npf_nat_test(bool);
    125  1.19.2.1    martin bool		npf_gc_test(bool);
    126       1.5     rmind 
    127      1.15     rmind int		npf_inet_pton(int, const char *, void *);
    128      1.15     rmind const char *	npf_inet_ntop(int, const void *, char *, socklen_t);
    129      1.15     rmind 
    130       1.1     rmind #endif
    131