Thu Apr 23 00:27:45 2020 UTC ()
npftest_mbufops and npftest_ifops are owned by npf_mbuf_subr.c


(joerg)
diff -r1.19 -r1.20 src/usr.sbin/npf/npftest/libnpftest/npf_test.h

cvs diff -r1.19 -r1.20 src/usr.sbin/npf/npftest/libnpftest/npf_test.h (switch to unified diff)

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