npf_impl.h revision 1.84 1 /*-
2 * Copyright (c) 2009-2025 The NetBSD Foundation, Inc.
3 * All rights reserved.
4 *
5 * This material is based upon work partially supported by The
6 * NetBSD Foundation under a contract with Mindaugas Rasiukevicius.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
18 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
19 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
20 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
21 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27 * POSSIBILITY OF SUCH DAMAGE.
28 */
29
30 /*
31 * Private NPF structures and interfaces.
32 * For internal use within NPF core only.
33 */
34
35 #ifndef _NPF_IMPL_H_
36 #define _NPF_IMPL_H_
37
38 #if !defined(_KERNEL) && !defined(_NPF_STANDALONE)
39 #error "Kernel-level header only"
40 #endif
41
42 #ifdef _KERNEL_OPT
43 /* For INET/INET6 definitions. */
44 #include "opt_inet.h"
45 #include "opt_inet6.h"
46 #endif
47
48 #ifdef _KERNEL
49 #include <sys/types.h>
50 #include <sys/queue.h>
51
52 #include <net/bpf.h>
53 #include <net/bpfjit.h>
54 #include <net/if.h>
55 #endif
56 #include <dnv.h>
57 #include <nv.h>
58
59 #include "npf.h"
60 #include "npfkern.h"
61
62 #ifdef _NPF_DEBUG
63 #define NPF_PRINTF(x) printf x
64 #else
65 #define NPF_PRINTF(x)
66 #endif
67
68 /*
69 * STRUCTURE DECLARATIONS.
70 */
71
72 struct npf_ruleset;
73 struct npf_rule;
74 struct npf_rprocset;
75 struct npf_portmap;
76 struct npf_nat;
77 struct npf_conn;
78
79 typedef struct npf_ruleset npf_ruleset_t;
80 typedef struct npf_rule npf_rule_t;
81 typedef struct npf_portmap npf_portmap_t;
82 typedef struct npf_nat npf_nat_t;
83 typedef struct npf_rprocset npf_rprocset_t;
84 typedef struct npf_alg npf_alg_t;
85 typedef struct npf_natpolicy npf_natpolicy_t;
86 typedef struct npf_conn npf_conn_t;
87
88 struct npf_conndb;
89 struct npf_table;
90 struct npf_tableset;
91 struct npf_algset;
92 struct npf_ifmap;
93
94 typedef struct npf_conndb npf_conndb_t;
95 typedef struct npf_table npf_table_t;
96 typedef struct npf_tableset npf_tableset_t;
97 typedef struct npf_algset npf_algset_t;
98
99 typedef uint32_t (*get_rid_t)(kauth_cred_t);
100
101 #ifdef __NetBSD__
102 typedef void ebr_t;
103 #endif
104
105 /*
106 * DEFINITIONS.
107 */
108
109 typedef struct {
110 npf_ruleset_t * ruleset;
111 npf_ruleset_t * nat_ruleset;
112 npf_rprocset_t * rule_procs;
113 npf_tableset_t * tableset;
114 bool default_pass;
115 } npf_config_t;
116
117 typedef void (*npf_workfunc_t)(npf_t *);
118
119 typedef struct {
120 uint64_t mi_rid;
121 unsigned mi_retfl;
122 unsigned mi_di;
123 } npf_match_info_t;
124
125 /*
126 * Some artificial limits.
127 * Note: very unlikely to have many ALGs.
128 */
129 #define NPF_MAX_RULES (1024 * 1024)
130 #define NPF_MAX_TABLES 128
131 #define NPF_MAX_RPROCS 128
132 #define NPF_MAX_IFMAP 64
133 #define NPF_MAX_ALGS 4
134 #define NPF_MAX_WORKS 4
135
136 /*
137 * CONNECTION STATE STRUCTURES
138 */
139
140 typedef enum {
141 NPF_FLOW_FORW = 0,
142 NPF_FLOW_BACK = 1,
143 } npf_flow_t;
144
145 typedef struct {
146 uint32_t nst_end;
147 uint32_t nst_maxend;
148 uint32_t nst_maxwin;
149 int nst_wscale;
150 } npf_tcpstate_t;
151
152 typedef struct {
153 unsigned nst_state;
154 npf_tcpstate_t nst_tcpst[2];
155 } npf_state_t;
156
157 /*
158 * ALG FUNCTIONS.
159 */
160
161 typedef struct {
162 bool (*match)(npf_cache_t *, npf_nat_t *, int);
163 bool (*translate)(npf_cache_t *, npf_nat_t *, npf_flow_t);
164 npf_conn_t * (*inspect)(npf_cache_t *, int);
165 void (*destroy)(npf_t *, npf_nat_t *, npf_conn_t *);
166 } npfa_funcs_t;
167
168 /*
169 * NBUF STRUCTURE.
170 */
171
172 struct nbuf {
173 struct mbuf * nb_mbuf0;
174 struct mbuf * nb_mbuf;
175 void * nb_nptr;
176 const ifnet_t * nb_ifp;
177 unsigned nb_ifid;
178 int nb_flags;
179 const npf_mbufops_t *nb_mops;
180 };
181
182 /*
183 * PARAMS.
184 */
185
186 typedef struct npf_paraminfo npf_paraminfo_t;
187
188 typedef struct {
189 const char * name;
190 int * valp;
191 int default_val;
192 /*
193 * Minimum and maximum allowed values (inclusive).
194 */
195 int min;
196 int max;
197 } npf_param_t;
198
199 typedef enum {
200 NPF_PARAMS_CONN = 0,
201 NPF_PARAMS_CONNDB,
202 NPF_PARAMS_GENERIC_STATE,
203 NPF_PARAMS_TCP_STATE,
204 NPF_PARAMS_COUNT
205 } npf_paramgroup_t;
206
207 /*
208 * NPF INSTANCE (CONTEXT) STRUCTURE AND AUXILIARY OPERATIONS.
209 */
210
211 struct npf {
212 /* Active NPF configuration. */
213 kmutex_t config_lock;
214 ebr_t * ebr;
215 npf_config_t * config;
216
217 /*
218 * BPF byte-code context, mbuf operations an arbitrary user argument.
219 */
220 bpf_ctx_t * bpfctx;
221 const npf_mbufops_t * mbufops;
222 void * arg;
223
224 /* Parameters. */
225 npf_paraminfo_t * paraminfo;
226 void * params[NPF_PARAMS_COUNT];
227 int ip4_reassembly;
228 int ip6_reassembly;
229
230 /*
231 * Connection tracking state: disabled (off) or enabled (on).
232 * Connection tracking database, connection cache and the lock.
233 * There are two caches (pools): for IPv4 and IPv6.
234 */
235 volatile int conn_tracking;
236 kmutex_t conn_lock;
237 npf_conndb_t * conn_db;
238 pool_cache_t conn_cache[2];
239
240 /* NAT and ALGs. */
241 npf_portmap_t * portmap;
242 npf_algset_t * algset;
243
244 /* Interface mapping. */
245 const npf_ifops_t * ifops;
246 struct npf_ifmap * ifmap;
247 unsigned ifmap_cnt;
248 unsigned ifmap_off;
249 kmutex_t ifmap_lock;
250
251 /* List of extensions and its lock. */
252 LIST_HEAD(, npf_ext) ext_list;
253 kmutex_t ext_lock;
254
255 /* Associated worker information. */
256 unsigned worker_flags;
257 LIST_ENTRY(npf) worker_entry;
258 unsigned worker_wait_time;
259 npf_workfunc_t worker_funcs[NPF_MAX_WORKS];
260
261 /* Statistics. */
262 percpu_t * stats_percpu;
263 };
264
265 /*
266 * NPF extensions and rule procedure interface.
267 */
268
269 struct npf_rproc;
270 typedef struct npf_rproc npf_rproc_t;
271
272 typedef struct {
273 u_int version;
274 void * ctx;
275 int (*ctor)(npf_rproc_t *, const nvlist_t *);
276 void (*dtor)(npf_rproc_t *, void *);
277 bool (*proc)(npf_cache_t *, void *, const npf_match_info_t *, int *);
278 } npf_ext_ops_t;
279
280 void * npf_ext_register(npf_t *, const char *, const npf_ext_ops_t *);
281 int npf_ext_unregister(npf_t *, void *);
282 void npf_rproc_assign(npf_rproc_t *, void *);
283
284 /*
285 * INTERFACES.
286 */
287
288 /* NPF config, statistics, etc. */
289 void npf_config_init(npf_t *);
290 void npf_config_fini(npf_t *);
291
292 npf_config_t * npf_config_enter(npf_t *);
293 void npf_config_exit(npf_t *);
294 void npf_config_sync(npf_t *);
295 bool npf_config_locked_p(npf_t *);
296 int npf_config_read_enter(npf_t *);
297 void npf_config_read_exit(npf_t *, int);
298
299 npf_config_t * npf_config_create(void);
300 void npf_config_destroy(npf_config_t *);
301 void npf_config_load(npf_t *, npf_config_t *, npf_conndb_t *, bool);
302 npf_ruleset_t * npf_config_ruleset(npf_t *npf);
303 npf_ruleset_t * npf_config_natset(npf_t *npf);
304 npf_tableset_t *npf_config_tableset(npf_t *npf);
305 bool npf_default_pass(npf_t *);
306 bool npf_active_p(void);
307
308 int npf_worker_sysinit(unsigned);
309 void npf_worker_sysfini(void);
310 int npf_worker_addfunc(npf_t *, npf_workfunc_t);
311 void npf_worker_enlist(npf_t *);
312 void npf_worker_discharge(npf_t *);
313 void npf_worker_signal(npf_t *);
314
315 int npfctl_run_op(npf_t *, unsigned, const nvlist_t *, nvlist_t *);
316 int npfctl_table(npf_t *, void *);
317
318 void npf_stats_inc(npf_t *, npf_stats_t);
319 void npf_stats_dec(npf_t *, npf_stats_t);
320
321 void npf_param_init(npf_t *);
322 void npf_param_fini(npf_t *);
323 void npf_param_register(npf_t *, npf_param_t *, unsigned);
324 void * npf_param_allocgroup(npf_t *, npf_paramgroup_t, size_t);
325 void npf_param_freegroup(npf_t *, npf_paramgroup_t, size_t);
326 int npf_param_check(npf_t *, const char *, int);
327 int npf_params_export(const npf_t *, nvlist_t *);
328
329 void npf_ifmap_init(npf_t *, const npf_ifops_t *);
330 void npf_ifmap_fini(npf_t *);
331 u_int npf_ifmap_register(npf_t *, const char *);
332 void npf_ifmap_flush(npf_t *);
333 u_int npf_ifmap_getid(npf_t *, const ifnet_t *);
334 void npf_ifmap_copylogname(npf_t *, unsigned, char *, size_t);
335 void npf_ifmap_copyname(npf_t *, unsigned, char *, size_t);
336
337 void npf_ifaddr_sync(npf_t *, ifnet_t *);
338 void npf_ifaddr_flush(npf_t *, ifnet_t *);
339 void npf_ifaddr_syncall(npf_t *);
340
341 /* Protocol helpers. */
342 int npf_cache_all(npf_cache_t *);
343 void npf_recache(npf_cache_t *);
344
345 bool npf_rwrip(const npf_cache_t *, u_int, const npf_addr_t *);
346 bool npf_rwrport(const npf_cache_t *, u_int, const in_port_t);
347 bool npf_rwrcksum(const npf_cache_t *, u_int,
348 const npf_addr_t *, const in_port_t);
349 int npf_napt_rwr(const npf_cache_t *, u_int, const npf_addr_t *,
350 const in_addr_t);
351 int npf_npt66_rwr(const npf_cache_t *, u_int, const npf_addr_t *,
352 npf_netmask_t, uint16_t);
353
354 uint16_t npf_fixup16_cksum(uint16_t, uint16_t, uint16_t);
355 uint16_t npf_fixup32_cksum(uint16_t, uint32_t, uint32_t);
356 uint16_t npf_addr_cksum(uint16_t, int, const npf_addr_t *,
357 const npf_addr_t *);
358 uint32_t npf_addr_mix(const int, const npf_addr_t *, const npf_addr_t *);
359 int npf_addr_cmp(const npf_addr_t *, const npf_netmask_t,
360 const npf_addr_t *, const npf_netmask_t, const int);
361 void npf_addr_mask(const npf_addr_t *, const npf_netmask_t,
362 const int, npf_addr_t *);
363 void npf_addr_bitor(const npf_addr_t *, const npf_netmask_t,
364 const int, npf_addr_t *);
365 int npf_netmask_check(const int, npf_netmask_t);
366
367 int npf_tcpsaw(const npf_cache_t *, tcp_seq *, tcp_seq *,
368 uint32_t *);
369 bool npf_fetch_tcpopts(npf_cache_t *, uint16_t *, int *);
370 bool npf_set_mss(npf_cache_t *, uint16_t, uint16_t *, uint16_t *,
371 bool *);
372 bool npf_return_block(npf_cache_t *, const int);
373
374 /* BPF interface. */
375 void npf_bpf_sysinit(void);
376 void npf_bpf_sysfini(void);
377 void npf_bpf_prepare(npf_cache_t *, bpf_args_t *, uint32_t *);
378 int npf_bpf_filter(bpf_args_t *, const void *, bpfjit_func_t);
379 void * npf_bpf_compile(void *, size_t);
380 bool npf_bpf_validate(const void *, size_t);
381
382 /* Tableset interface. */
383 void npf_tableset_sysinit(void);
384 void npf_tableset_sysfini(void);
385
386 npf_tableset_t *npf_tableset_create(u_int);
387 void npf_tableset_destroy(npf_tableset_t *);
388 int npf_tableset_insert(npf_tableset_t *, npf_table_t *);
389 npf_table_t * npf_tableset_getbyname(npf_tableset_t *, const char *);
390 npf_table_t * npf_tableset_getbyid(npf_tableset_t *, u_int);
391 npf_table_t * npf_tableset_swap(npf_tableset_t *, npf_table_t *);
392 void npf_tableset_reload(npf_t *, npf_tableset_t *, npf_tableset_t *);
393 int npf_tableset_export(npf_t *, const npf_tableset_t *, nvlist_t *);
394
395 npf_table_t * npf_table_create(const char *, u_int, int, const void *, size_t);
396 void npf_table_destroy(npf_table_t *);
397
398 u_int npf_table_getid(npf_table_t *);
399 int npf_table_check(npf_tableset_t *, const char *, uint64_t, uint64_t, bool);
400 int npf_table_insert(npf_table_t *, const int,
401 const npf_addr_t *, const npf_netmask_t);
402 int npf_table_remove(npf_table_t *, const int,
403 const npf_addr_t *, const npf_netmask_t);
404 int npf_table_lookup(npf_table_t *, const int, const npf_addr_t *);
405 npf_addr_t * npf_table_getsome(npf_table_t *, const int, unsigned);
406 int npf_table_list(npf_table_t *, void *, size_t);
407 int npf_table_flush(npf_table_t *);
408 void npf_table_gc(npf_t *, npf_table_t *);
409
410 /* Ruleset interface. */
411 npf_ruleset_t * npf_ruleset_create(size_t);
412 void npf_ruleset_destroy(npf_ruleset_t *);
413 void npf_ruleset_insert(npf_ruleset_t *, npf_rule_t *);
414 void npf_ruleset_reload(npf_t *, npf_ruleset_t *,
415 npf_ruleset_t *, bool);
416 npf_natpolicy_t *npf_ruleset_findnat(npf_ruleset_t *, uint64_t);
417 void npf_ruleset_freealg(npf_ruleset_t *, npf_alg_t *);
418 int npf_ruleset_export(npf_t *, const npf_ruleset_t *,
419 const char *, nvlist_t *);
420
421 npf_rule_t * npf_ruleset_lookup(npf_ruleset_t *, const char *);
422 int npf_ruleset_add(npf_ruleset_t *, const char *, npf_rule_t *);
423 int npf_ruleset_remove(npf_ruleset_t *, const char *, uint64_t);
424 int npf_ruleset_remkey(npf_ruleset_t *, const char *,
425 const void *, size_t);
426 int npf_ruleset_list(npf_t *, npf_ruleset_t *, const char *, nvlist_t *);
427 int npf_ruleset_flush(npf_ruleset_t *, const char *);
428 void npf_ruleset_gc(npf_ruleset_t *);
429
430 npf_rule_t * npf_ruleset_inspect(npf_cache_t *, const npf_ruleset_t *,
431 const int, const int);
432 int npf_rule_conclude(const npf_rule_t *, npf_match_info_t *);
433 int npf_rule_reverse(npf_cache_t *, npf_match_info_t *, int);
434
435 /* Rule interface. */
436 npf_rule_t * npf_rule_alloc(npf_t *, const nvlist_t *);
437 void npf_rule_setcode(npf_rule_t *, int, void *, size_t);
438 void npf_rule_setrproc(npf_rule_t *, npf_rproc_t *);
439 void npf_rule_free(npf_rule_t *);
440 uint64_t npf_rule_getid(const npf_rule_t *);
441 npf_natpolicy_t *npf_rule_getnat(const npf_rule_t *);
442 void npf_rule_setnat(npf_rule_t *, npf_natpolicy_t *);
443 npf_rproc_t * npf_rule_getrproc(const npf_rule_t *);
444
445 int npf_socket_lookup_rid(npf_cache_t *, get_rid_t, uint32_t *, int);
446 void npf_rule_setrid(const nvlist_t *, npf_rule_t *, const char *);
447 int npf_rule_match_rid(npf_rule_t *, npf_cache_t *, int);
448
449 void npf_ext_init(npf_t *);
450 void npf_ext_fini(npf_t *);
451 int npf_ext_construct(npf_t *, const char *,
452 npf_rproc_t *, const nvlist_t *);
453
454 npf_rprocset_t *npf_rprocset_create(void);
455 void npf_rprocset_destroy(npf_rprocset_t *);
456 npf_rproc_t * npf_rprocset_lookup(npf_rprocset_t *, const char *);
457 void npf_rprocset_insert(npf_rprocset_t *, npf_rproc_t *);
458 int npf_rprocset_export(const npf_rprocset_t *, nvlist_t *);
459
460 npf_rproc_t * npf_rproc_create(const nvlist_t *);
461 void npf_rproc_acquire(npf_rproc_t *);
462 void npf_rproc_release(npf_rproc_t *);
463 const char * npf_rproc_getname(const npf_rproc_t *);
464 bool npf_rproc_run(npf_cache_t *, npf_rproc_t *,
465 const npf_match_info_t *, int *);
466
467 /* State handling. */
468 void npf_state_sysinit(npf_t *);
469 void npf_state_sysfini(npf_t *);
470
471 bool npf_state_init(npf_cache_t *, npf_state_t *);
472 bool npf_state_inspect(npf_cache_t *, npf_state_t *, npf_flow_t);
473 int npf_state_etime(npf_t *, const npf_state_t *, const int);
474 void npf_state_destroy(npf_state_t *);
475 void npf_state_tcp_sysinit(npf_t *);
476 void npf_state_tcp_sysfini(npf_t *);
477 bool npf_state_tcp(npf_cache_t *, npf_state_t *, npf_flow_t);
478 int npf_state_tcp_timeout(npf_t *, const npf_state_t *);
479
480 /* uid/gid process matching */
481 int npf_match_rid(rid_t *, uint32_t);
482
483 /* Portmap. */
484 void npf_portmap_sysinit(void);
485 void npf_portmap_sysfini(void);
486
487 void npf_portmap_init(npf_t *);
488 void npf_portmap_fini(npf_t *);
489
490 npf_portmap_t * npf_portmap_create(int, int);
491 void npf_portmap_destroy(npf_portmap_t *);
492
493 in_port_t npf_portmap_get(npf_portmap_t *, int, const npf_addr_t *);
494 bool npf_portmap_take(npf_portmap_t *, int, const npf_addr_t *, in_port_t);
495 void npf_portmap_put(npf_portmap_t *, int, const npf_addr_t *, in_port_t);
496 void npf_portmap_flush(npf_portmap_t *);
497
498 /* NAT. */
499 void npf_nat_sysinit(void);
500 void npf_nat_sysfini(void);
501 npf_natpolicy_t *npf_natpolicy_create(npf_t *, const nvlist_t *, npf_ruleset_t *);
502 int npf_natpolicy_export(const npf_natpolicy_t *, nvlist_t *);
503 void npf_natpolicy_destroy(npf_natpolicy_t *);
504 bool npf_natpolicy_cmp(npf_natpolicy_t *, npf_natpolicy_t *);
505 void npf_nat_setid(npf_natpolicy_t *, uint64_t);
506 uint64_t npf_nat_getid(const npf_natpolicy_t *);
507 void npf_nat_freealg(npf_natpolicy_t *, npf_alg_t *);
508
509 int npf_do_nat(npf_cache_t *, npf_conn_t *, const unsigned);
510 npf_nat_t * npf_nat_share_policy(npf_cache_t *, npf_conn_t *, npf_nat_t *);
511 void npf_nat_destroy(npf_conn_t *, npf_nat_t *);
512 void npf_nat_getorig(npf_nat_t *, npf_addr_t **, in_port_t *);
513 void npf_nat_gettrans(npf_nat_t *, npf_addr_t **, in_port_t *);
514 void npf_nat_setalg(npf_nat_t *, npf_alg_t *, uintptr_t);
515 npf_alg_t * npf_nat_getalg(const npf_nat_t *);
516 uintptr_t npf_nat_getalgarg(const npf_nat_t *);
517
518 void npf_nat_export(npf_t *, const npf_nat_t *, nvlist_t *);
519 npf_nat_t * npf_nat_import(npf_t *, const nvlist_t *, npf_ruleset_t *,
520 npf_conn_t *);
521
522 /* ALG interface. */
523 void npf_alg_sysinit(void);
524 void npf_alg_sysfini(void);
525 void npf_alg_init(npf_t *);
526 void npf_alg_fini(npf_t *);
527 npf_alg_t * npf_alg_register(npf_t *, const char *, const npfa_funcs_t *);
528 int npf_alg_unregister(npf_t *, npf_alg_t *);
529 npf_alg_t * npf_alg_construct(npf_t *, const char *);
530 bool npf_alg_match(npf_cache_t *, npf_nat_t *, int);
531 void npf_alg_exec(npf_cache_t *, npf_nat_t *, const npf_flow_t);
532 npf_conn_t * npf_alg_conn(npf_cache_t *, int);
533 int npf_alg_export(npf_t *, nvlist_t *);
534 void npf_alg_destroy(npf_t *, npf_alg_t *, npf_nat_t *, npf_conn_t *);
535
536 /* Wrappers for the reclamation mechanism. */
537 ebr_t * npf_ebr_create(void);
538 void npf_ebr_destroy(ebr_t *);
539 void npf_ebr_register(ebr_t *);
540 void npf_ebr_unregister(ebr_t *);
541 int npf_ebr_enter(ebr_t *);
542 void npf_ebr_exit(ebr_t *, int);
543 void npf_ebr_full_sync(ebr_t *);
544 bool npf_ebr_incrit_p(ebr_t *);
545
546 /* Debugging routines. */
547 const char * npf_addr_dump(const npf_addr_t *, int);
548 void npf_state_dump(const npf_state_t *);
549 void npf_nat_dump(const npf_nat_t *);
550 void npf_ruleset_dump(npf_t *, const char *);
551 void npf_state_setsampler(void (*)(npf_state_t *, bool));
552
553 /* In-kernel routines. */
554 void npf_setkernctx(npf_t *);
555 npf_t * npf_getkernctx(void);
556
557 #endif /* _NPF_IMPL_H_ */
558