2 * SPDX-License-Identifier: BSD-2-Clause
4 * Copyright (c) 2021 Rubicon Communications, LLC (Netgate)
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
11 * - Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * - Redistributions in binary form must reproduce the above
14 * copyright notice, this list of conditions and the following
15 * disclaimer in the documentation and/or other materials provided
16 * with the distribution.
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
21 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
22 * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
23 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
24 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
25 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
26 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
28 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE.
34 #include <sys/cdefs.h>
36 #include <sys/ioctl.h>
38 #include <sys/queue.h>
39 #include <sys/types.h>
42 #include <net/pfvar.h>
43 #include <netinet/in.h>
53 static int _pfctl_clear_states(int , const struct pfctl_kill *,
54 unsigned int *, uint64_t);
57 pf_nvuint_8_array(const nvlist_t *nvl, const char *name, size_t maxelems,
58 u_int8_t *numbers, size_t *nelems)
63 tmp = nvlist_get_number_array(nvl, name, &elems);
64 assert(elems <= maxelems);
66 for (size_t i = 0; i < elems; i++)
74 pf_nvuint_16_array(const nvlist_t *nvl, const char *name, size_t maxelems,
75 u_int16_t *numbers, size_t *nelems)
80 tmp = nvlist_get_number_array(nvl, name, &elems);
81 assert(elems <= maxelems);
83 for (size_t i = 0; i < elems; i++)
91 pf_nvuint_32_array(const nvlist_t *nvl, const char *name, size_t maxelems,
92 u_int32_t *numbers, size_t *nelems)
97 tmp = nvlist_get_number_array(nvl, name, &elems);
98 assert(elems <= maxelems);
100 for (size_t i = 0; i < elems; i++)
108 pf_nvuint_64_array(const nvlist_t *nvl, const char *name, size_t maxelems,
109 u_int64_t *numbers, size_t *nelems)
114 tmp = nvlist_get_number_array(nvl, name, &elems);
115 assert(elems <= maxelems);
117 for (size_t i = 0; i < elems; i++)
125 pfctl_nv_add_addr(nvlist_t *nvparent, const char *name,
126 const struct pf_addr *addr)
128 nvlist_t *nvl = nvlist_create(0);
130 nvlist_add_binary(nvl, "addr", addr, sizeof(*addr));
132 nvlist_add_nvlist(nvparent, name, nvl);
136 pf_nvaddr_to_addr(const nvlist_t *nvl, struct pf_addr *addr)
141 data = nvlist_get_binary(nvl, "addr", &len);
142 assert(len == sizeof(struct pf_addr));
143 memcpy(addr, data, len);
147 pfctl_nv_add_addr_wrap(nvlist_t *nvparent, const char *name,
148 const struct pf_addr_wrap *addr)
150 nvlist_t *nvl = nvlist_create(0);
152 nvlist_add_number(nvl, "type", addr->type);
153 nvlist_add_number(nvl, "iflags", addr->iflags);
154 if (addr->type == PF_ADDR_DYNIFTL)
155 nvlist_add_string(nvl, "ifname", addr->v.ifname);
156 if (addr->type == PF_ADDR_TABLE)
157 nvlist_add_string(nvl, "tblname", addr->v.tblname);
158 pfctl_nv_add_addr(nvl, "addr", &addr->v.a.addr);
159 pfctl_nv_add_addr(nvl, "mask", &addr->v.a.mask);
161 nvlist_add_nvlist(nvparent, name, nvl);
165 pf_nvaddr_wrap_to_addr_wrap(const nvlist_t *nvl, struct pf_addr_wrap *addr)
167 addr->type = nvlist_get_number(nvl, "type");
168 addr->iflags = nvlist_get_number(nvl, "iflags");
169 if (addr->type == PF_ADDR_DYNIFTL)
170 strlcpy(addr->v.ifname, nvlist_get_string(nvl, "ifname"),
172 if (addr->type == PF_ADDR_TABLE)
173 strlcpy(addr->v.tblname, nvlist_get_string(nvl, "tblname"),
176 pf_nvaddr_to_addr(nvlist_get_nvlist(nvl, "addr"), &addr->v.a.addr);
177 pf_nvaddr_to_addr(nvlist_get_nvlist(nvl, "mask"), &addr->v.a.mask);
181 pfctl_nv_add_rule_addr(nvlist_t *nvparent, const char *name,
182 const struct pf_rule_addr *addr)
185 nvlist_t *nvl = nvlist_create(0);
187 pfctl_nv_add_addr_wrap(nvl, "addr", &addr->addr);
188 ports[0] = addr->port[0];
189 ports[1] = addr->port[1];
190 nvlist_add_number_array(nvl, "port", ports, 2);
191 nvlist_add_number(nvl, "neg", addr->neg);
192 nvlist_add_number(nvl, "port_op", addr->port_op);
194 nvlist_add_nvlist(nvparent, name, nvl);
198 pf_nvrule_addr_to_rule_addr(const nvlist_t *nvl, struct pf_rule_addr *addr)
200 pf_nvaddr_wrap_to_addr_wrap(nvlist_get_nvlist(nvl, "addr"), &addr->addr);
202 pf_nvuint_16_array(nvl, "port", 2, addr->port, NULL);
203 addr->neg = nvlist_get_number(nvl, "neg");
204 addr->port_op = nvlist_get_number(nvl, "port_op");
208 pfctl_nv_add_mape(nvlist_t *nvparent, const char *name,
209 const struct pf_mape_portset *mape)
211 nvlist_t *nvl = nvlist_create(0);
213 nvlist_add_number(nvl, "offset", mape->offset);
214 nvlist_add_number(nvl, "psidlen", mape->psidlen);
215 nvlist_add_number(nvl, "psid", mape->psid);
216 nvlist_add_nvlist(nvparent, name, nvl);
220 pfctl_nv_add_pool(nvlist_t *nvparent, const char *name,
221 const struct pfctl_pool *pool)
224 nvlist_t *nvl = nvlist_create(0);
226 nvlist_add_binary(nvl, "key", &pool->key, sizeof(pool->key));
227 pfctl_nv_add_addr(nvl, "counter", &pool->counter);
228 nvlist_add_number(nvl, "tblidx", pool->tblidx);
230 ports[0] = pool->proxy_port[0];
231 ports[1] = pool->proxy_port[1];
232 nvlist_add_number_array(nvl, "proxy_port", ports, 2);
233 nvlist_add_number(nvl, "opts", pool->opts);
234 pfctl_nv_add_mape(nvl, "mape", &pool->mape);
236 nvlist_add_nvlist(nvparent, name, nvl);
240 pf_nvmape_to_mape(const nvlist_t *nvl, struct pf_mape_portset *mape)
242 mape->offset = nvlist_get_number(nvl, "offset");
243 mape->psidlen = nvlist_get_number(nvl, "psidlen");
244 mape->psid = nvlist_get_number(nvl, "psid");
248 pf_nvpool_to_pool(const nvlist_t *nvl, struct pfctl_pool *pool)
253 data = nvlist_get_binary(nvl, "key", &len);
254 assert(len == sizeof(pool->key));
255 memcpy(&pool->key, data, len);
257 pf_nvaddr_to_addr(nvlist_get_nvlist(nvl, "counter"), &pool->counter);
259 pool->tblidx = nvlist_get_number(nvl, "tblidx");
260 pf_nvuint_16_array(nvl, "proxy_port", 2, pool->proxy_port, NULL);
261 pool->opts = nvlist_get_number(nvl, "opts");
263 if (nvlist_exists_nvlist(nvl, "mape"))
264 pf_nvmape_to_mape(nvlist_get_nvlist(nvl, "mape"), &pool->mape);
268 pfctl_nv_add_uid(nvlist_t *nvparent, const char *name,
269 const struct pf_rule_uid *uid)
272 nvlist_t *nvl = nvlist_create(0);
274 uids[0] = uid->uid[0];
275 uids[1] = uid->uid[1];
276 nvlist_add_number_array(nvl, "uid", uids, 2);
277 nvlist_add_number(nvl, "op", uid->op);
279 nvlist_add_nvlist(nvparent, name, nvl);
283 pf_nvrule_uid_to_rule_uid(const nvlist_t *nvl, struct pf_rule_uid *uid)
285 pf_nvuint_32_array(nvl, "uid", 2, uid->uid, NULL);
286 uid->op = nvlist_get_number(nvl, "op");
290 pfctl_nv_add_divert(nvlist_t *nvparent, const char *name,
291 const struct pfctl_rule *r)
293 nvlist_t *nvl = nvlist_create(0);
295 pfctl_nv_add_addr(nvl, "addr", &r->divert.addr);
296 nvlist_add_number(nvl, "port", r->divert.port);
298 nvlist_add_nvlist(nvparent, name, nvl);
302 pf_nvdivert_to_divert(const nvlist_t *nvl, struct pfctl_rule *rule)
304 pf_nvaddr_to_addr(nvlist_get_nvlist(nvl, "addr"), &rule->divert.addr);
305 rule->divert.port = nvlist_get_number(nvl, "port");
309 pf_nvrule_to_rule(const nvlist_t *nvl, struct pfctl_rule *rule)
311 const uint64_t *skip;
312 const char *const *labels;
313 size_t skipcount, labelcount;
315 rule->nr = nvlist_get_number(nvl, "nr");
317 pf_nvrule_addr_to_rule_addr(nvlist_get_nvlist(nvl, "src"), &rule->src);
318 pf_nvrule_addr_to_rule_addr(nvlist_get_nvlist(nvl, "dst"), &rule->dst);
320 skip = nvlist_get_number_array(nvl, "skip", &skipcount);
322 assert(skipcount == PF_SKIP_COUNT);
323 for (int i = 0; i < PF_SKIP_COUNT; i++)
324 rule->skip[i].nr = skip[i];
326 labels = nvlist_get_string_array(nvl, "labels", &labelcount);
327 assert(labelcount <= PF_RULE_MAX_LABEL_COUNT);
328 for (size_t i = 0; i < labelcount; i++)
329 strlcpy(rule->label[i], labels[i], PF_RULE_LABEL_SIZE);
330 strlcpy(rule->ifname, nvlist_get_string(nvl, "ifname"), IFNAMSIZ);
331 strlcpy(rule->qname, nvlist_get_string(nvl, "qname"), PF_QNAME_SIZE);
332 strlcpy(rule->pqname, nvlist_get_string(nvl, "pqname"), PF_QNAME_SIZE);
333 strlcpy(rule->tagname, nvlist_get_string(nvl, "tagname"),
335 strlcpy(rule->match_tagname, nvlist_get_string(nvl, "match_tagname"),
338 strlcpy(rule->overload_tblname, nvlist_get_string(nvl, "overload_tblname"),
341 pf_nvpool_to_pool(nvlist_get_nvlist(nvl, "rpool"), &rule->rpool);
343 rule->evaluations = nvlist_get_number(nvl, "evaluations");
344 pf_nvuint_64_array(nvl, "packets", 2, rule->packets, NULL);
345 pf_nvuint_64_array(nvl, "bytes", 2, rule->bytes, NULL);
347 rule->os_fingerprint = nvlist_get_number(nvl, "os_fingerprint");
349 rule->rtableid = nvlist_get_number(nvl, "rtableid");
350 pf_nvuint_32_array(nvl, "timeout", PFTM_MAX, rule->timeout, NULL);
351 rule->max_states = nvlist_get_number(nvl, "max_states");
352 rule->max_src_nodes = nvlist_get_number(nvl, "max_src_nodes");
353 rule->max_src_states = nvlist_get_number(nvl, "max_src_states");
354 rule->max_src_conn = nvlist_get_number(nvl, "max_src_conn");
355 rule->max_src_conn_rate.limit =
356 nvlist_get_number(nvl, "max_src_conn_rate.limit");
357 rule->max_src_conn_rate.seconds =
358 nvlist_get_number(nvl, "max_src_conn_rate.seconds");
359 rule->qid = nvlist_get_number(nvl, "qid");
360 rule->pqid = nvlist_get_number(nvl, "pqid");
361 rule->prob = nvlist_get_number(nvl, "prob");
362 rule->cuid = nvlist_get_number(nvl, "cuid");
363 rule->cpid = nvlist_get_number(nvl, "cpid");
365 rule->return_icmp = nvlist_get_number(nvl, "return_icmp");
366 rule->return_icmp6 = nvlist_get_number(nvl, "return_icmp6");
367 rule->max_mss = nvlist_get_number(nvl, "max_mss");
368 rule->scrub_flags = nvlist_get_number(nvl, "scrub_flags");
370 pf_nvrule_uid_to_rule_uid(nvlist_get_nvlist(nvl, "uid"), &rule->uid);
371 pf_nvrule_uid_to_rule_uid(nvlist_get_nvlist(nvl, "gid"),
372 (struct pf_rule_uid *)&rule->gid);
374 rule->rule_flag = nvlist_get_number(nvl, "rule_flag");
375 rule->action = nvlist_get_number(nvl, "action");
376 rule->direction = nvlist_get_number(nvl, "direction");
377 rule->log = nvlist_get_number(nvl, "log");
378 rule->logif = nvlist_get_number(nvl, "logif");
379 rule->quick = nvlist_get_number(nvl, "quick");
380 rule->ifnot = nvlist_get_number(nvl, "ifnot");
381 rule->match_tag_not = nvlist_get_number(nvl, "match_tag_not");
382 rule->natpass = nvlist_get_number(nvl, "natpass");
384 rule->keep_state = nvlist_get_number(nvl, "keep_state");
385 rule->af = nvlist_get_number(nvl, "af");
386 rule->proto = nvlist_get_number(nvl, "proto");
387 rule->type = nvlist_get_number(nvl, "type");
388 rule->code = nvlist_get_number(nvl, "code");
389 rule->flags = nvlist_get_number(nvl, "flags");
390 rule->flagset = nvlist_get_number(nvl, "flagset");
391 rule->min_ttl = nvlist_get_number(nvl, "min_ttl");
392 rule->allow_opts = nvlist_get_number(nvl, "allow_opts");
393 rule->rt = nvlist_get_number(nvl, "rt");
394 rule->return_ttl = nvlist_get_number(nvl, "return_ttl");
395 rule->tos = nvlist_get_number(nvl, "tos");
396 rule->set_tos = nvlist_get_number(nvl, "set_tos");
397 rule->anchor_relative = nvlist_get_number(nvl, "anchor_relative");
398 rule->anchor_wildcard = nvlist_get_number(nvl, "anchor_wildcard");
400 rule->flush = nvlist_get_number(nvl, "flush");
401 rule->prio = nvlist_get_number(nvl, "prio");
402 pf_nvuint_8_array(nvl, "set_prio", 2, rule->set_prio, NULL);
404 pf_nvdivert_to_divert(nvlist_get_nvlist(nvl, "divert"), rule);
406 rule->states_cur = nvlist_get_number(nvl, "states_cur");
407 rule->states_tot = nvlist_get_number(nvl, "states_tot");
408 rule->src_nodes = nvlist_get_number(nvl, "src_nodes");
412 pfctl_add_rule(int dev, const struct pfctl_rule *r, const char *anchor,
413 const char *anchor_call, u_int32_t ticket, u_int32_t pool_ticket)
416 u_int64_t timeouts[PFTM_MAX];
417 u_int64_t set_prio[2];
418 nvlist_t *nvl, *nvlr;
422 nvl = nvlist_create(0);
423 nvlr = nvlist_create(0);
425 nvlist_add_number(nvl, "ticket", ticket);
426 nvlist_add_number(nvl, "pool_ticket", pool_ticket);
427 nvlist_add_string(nvl, "anchor", anchor);
428 nvlist_add_string(nvl, "anchor_call", anchor_call);
430 nvlist_add_number(nvlr, "nr", r->nr);
431 pfctl_nv_add_rule_addr(nvlr, "src", &r->src);
432 pfctl_nv_add_rule_addr(nvlr, "dst", &r->dst);
435 while (r->label[labelcount][0] != 0 &&
436 labelcount < PF_RULE_MAX_LABEL_COUNT) {
437 nvlist_append_string_array(nvlr, "labels",
438 r->label[labelcount]);
442 nvlist_add_string(nvlr, "ifname", r->ifname);
443 nvlist_add_string(nvlr, "qname", r->qname);
444 nvlist_add_string(nvlr, "pqname", r->pqname);
445 nvlist_add_string(nvlr, "tagname", r->tagname);
446 nvlist_add_string(nvlr, "match_tagname", r->match_tagname);
447 nvlist_add_string(nvlr, "overload_tblname", r->overload_tblname);
449 pfctl_nv_add_pool(nvlr, "rpool", &r->rpool);
451 nvlist_add_number(nvlr, "os_fingerprint", r->os_fingerprint);
453 nvlist_add_number(nvlr, "rtableid", r->rtableid);
454 for (int i = 0; i < PFTM_MAX; i++)
455 timeouts[i] = r->timeout[i];
456 nvlist_add_number_array(nvlr, "timeout", timeouts, PFTM_MAX);
457 nvlist_add_number(nvlr, "max_states", r->max_states);
458 nvlist_add_number(nvlr, "max_src_nodes", r->max_src_nodes);
459 nvlist_add_number(nvlr, "max_src_states", r->max_src_states);
460 nvlist_add_number(nvlr, "max_src_conn", r->max_src_conn);
461 nvlist_add_number(nvlr, "max_src_conn_rate.limit",
462 r->max_src_conn_rate.limit);
463 nvlist_add_number(nvlr, "max_src_conn_rate.seconds",
464 r->max_src_conn_rate.seconds);
465 nvlist_add_number(nvlr, "prob", r->prob);
466 nvlist_add_number(nvlr, "cuid", r->cuid);
467 nvlist_add_number(nvlr, "cpid", r->cpid);
469 nvlist_add_number(nvlr, "return_icmp", r->return_icmp);
470 nvlist_add_number(nvlr, "return_icmp6", r->return_icmp6);
472 nvlist_add_number(nvlr, "max_mss", r->max_mss);
473 nvlist_add_number(nvlr, "scrub_flags", r->scrub_flags);
475 pfctl_nv_add_uid(nvlr, "uid", &r->uid);
476 pfctl_nv_add_uid(nvlr, "gid", (const struct pf_rule_uid *)&r->gid);
478 nvlist_add_number(nvlr, "rule_flag", r->rule_flag);
479 nvlist_add_number(nvlr, "action", r->action);
480 nvlist_add_number(nvlr, "direction", r->direction);
481 nvlist_add_number(nvlr, "log", r->log);
482 nvlist_add_number(nvlr, "logif", r->logif);
483 nvlist_add_number(nvlr, "quick", r->quick);
484 nvlist_add_number(nvlr, "ifnot", r->ifnot);
485 nvlist_add_number(nvlr, "match_tag_not", r->match_tag_not);
486 nvlist_add_number(nvlr, "natpass", r->natpass);
488 nvlist_add_number(nvlr, "keep_state", r->keep_state);
489 nvlist_add_number(nvlr, "af", r->af);
490 nvlist_add_number(nvlr, "proto", r->proto);
491 nvlist_add_number(nvlr, "type", r->type);
492 nvlist_add_number(nvlr, "code", r->code);
493 nvlist_add_number(nvlr, "flags", r->flags);
494 nvlist_add_number(nvlr, "flagset", r->flagset);
495 nvlist_add_number(nvlr, "min_ttl", r->min_ttl);
496 nvlist_add_number(nvlr, "allow_opts", r->allow_opts);
497 nvlist_add_number(nvlr, "rt", r->rt);
498 nvlist_add_number(nvlr, "return_ttl", r->return_ttl);
499 nvlist_add_number(nvlr, "tos", r->tos);
500 nvlist_add_number(nvlr, "set_tos", r->set_tos);
501 nvlist_add_number(nvlr, "anchor_relative", r->anchor_relative);
502 nvlist_add_number(nvlr, "anchor_wildcard", r->anchor_wildcard);
504 nvlist_add_number(nvlr, "flush", r->flush);
506 nvlist_add_number(nvlr, "prio", r->prio);
507 set_prio[0] = r->set_prio[0];
508 set_prio[1] = r->set_prio[1];
509 nvlist_add_number_array(nvlr, "set_prio", set_prio, 2);
511 pfctl_nv_add_divert(nvlr, "divert", r);
513 nvlist_add_nvlist(nvl, "rule", nvlr);
515 /* Now do the call. */
516 nv.data = nvlist_pack(nvl, &nv.len);
519 ret = ioctl(dev, DIOCADDRULENV, &nv);
528 pfctl_get_rule(int dev, u_int32_t nr, u_int32_t ticket, const char *anchor,
529 u_int32_t ruleset, struct pfctl_rule *rule, char *anchor_call)
531 return (pfctl_get_clear_rule(dev, nr, ticket, anchor, ruleset, rule,
532 anchor_call, false));
535 int pfctl_get_clear_rule(int dev, u_int32_t nr, u_int32_t ticket,
536 const char *anchor, u_int32_t ruleset, struct pfctl_rule *rule,
537 char *anchor_call, bool clear)
544 nvl = nvlist_create(0);
548 nvlist_add_number(nvl, "nr", nr);
549 nvlist_add_number(nvl, "ticket", ticket);
550 nvlist_add_string(nvl, "anchor", anchor);
551 nvlist_add_number(nvl, "ruleset", ruleset);
554 nvlist_add_bool(nvl, "clear_counter", true);
556 nvlpacked = nvlist_pack(nvl, &nv.len);
557 if (nvlpacked == NULL) {
561 nv.data = malloc(8182);
563 assert(nv.len <= nv.size);
564 memcpy(nv.data, nvlpacked, nv.len);
569 ret = ioctl(dev, DIOCGETRULENV, &nv);
575 nvl = nvlist_unpack(nv.data, nv.len, 0);
581 pf_nvrule_to_rule(nvlist_get_nvlist(nvl, "rule"), rule);
584 strlcpy(anchor_call, nvlist_get_string(nvl, "anchor_call"),
594 pfctl_set_keepcounters(int dev, bool keep)
600 nvl = nvlist_create(0);
602 nvlist_add_bool(nvl, "keep_counters", keep);
604 nv.data = nvlist_pack(nvl, &nv.len);
609 ret = ioctl(dev, DIOCKEEPCOUNTERS, &nv);
616 pfctl_nv_add_state_cmp(nvlist_t *nvl, const char *name,
617 const struct pfctl_state_cmp *cmp)
621 nv = nvlist_create(0);
623 nvlist_add_number(nv, "id", cmp->id);
624 nvlist_add_number(nv, "creatorid", cmp->creatorid);
625 nvlist_add_number(nv, "direction", cmp->direction);
627 nvlist_add_nvlist(nvl, name, nv);
631 _pfctl_clear_states(int dev, const struct pfctl_kill *kill,
632 unsigned int *killed, uint64_t ioctlval)
638 nvl = nvlist_create(0);
640 pfctl_nv_add_state_cmp(nvl, "cmp", &kill->cmp);
641 nvlist_add_number(nvl, "af", kill->af);
642 nvlist_add_number(nvl, "proto", kill->proto);
643 pfctl_nv_add_rule_addr(nvl, "src", &kill->src);
644 pfctl_nv_add_rule_addr(nvl, "dst", &kill->dst);
645 nvlist_add_string(nvl, "ifname", kill->ifname);
646 nvlist_add_string(nvl, "label", kill->label);
648 nv.data = nvlist_pack(nvl, &nv.len);
653 ret = ioctl(dev, ioctlval, &nv);
659 nvl = nvlist_unpack(nv.data, nv.len, 0);
666 *killed = nvlist_get_number(nvl, "killed");
675 pfctl_clear_states(int dev, const struct pfctl_kill *kill,
676 unsigned int *killed)
678 return (_pfctl_clear_states(dev, kill, killed, DIOCCLRSTATESNV));
682 pfctl_kill_states(int dev, const struct pfctl_kill *kill, unsigned int *killed)
684 return (_pfctl_clear_states(dev, kill, killed, DIOCKILLSTATESNV));