MCPcopy Create free account
hub / github.com/F-Stack/f-stack / pfr_tst_addrs

Function pfr_tst_addrs

freebsd/netpfil/pf/pf_table.c:514–548  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

512}
513
514int
515pfr_tst_addrs(struct pfr_table *tbl, struct pfr_addr *addr, int size,
516 int *nmatch, int flags)
517{
518 struct pfr_ktable *kt;
519 struct pfr_kentry *p;
520 struct pfr_addr *ad;
521 int i, xmatch = 0;
522
523 PF_RULES_RASSERT();
524
525 ACCEPT_FLAGS(flags, PFR_FLAG_REPLACE);
526 if (pfr_validate_table(tbl, 0, 0))
527 return (EINVAL);
528 kt = pfr_lookup_table(tbl);
529 if (kt == NULL || !(kt->pfrkt_flags & PFR_TFLAG_ACTIVE))
530 return (ESRCH);
531
532 for (i = 0, ad = addr; i < size; i++, ad++) {
533 if (pfr_validate_addr(ad))
534 return (EINVAL);
535 if (ADDR_NETWORK(ad))
536 return (EINVAL);
537 p = pfr_lookup_addr(kt, ad, 0);
538 if (flags & PFR_FLAG_REPLACE)
539 pfr_copyout_addr(ad, p);
540 ad->pfra_fback = (p == NULL) ? PFR_FB_NONE :
541 (p->pfrke_not ? PFR_FB_NOTMATCH : PFR_FB_MATCH);
542 if (p != NULL && !p->pfrke_not)
543 xmatch++;
544 }
545 if (nmatch != NULL)
546 *nmatch = xmatch;
547 return (0);
548}
549
550int
551pfr_get_addrs(struct pfr_table *tbl, struct pfr_addr *addr, int *size,

Callers 1

pfioctlFunction · 0.85

Calls 5

pfr_validate_tableFunction · 0.85
pfr_lookup_tableFunction · 0.85
pfr_validate_addrFunction · 0.85
pfr_lookup_addrFunction · 0.85
pfr_copyout_addrFunction · 0.85

Tested by

no test coverage detected