Changeset View
Changeset View
Standalone View
Standalone View
sys/netpfil/pf/pf_ruleset.c
Show First 20 Lines • Show All 331 Lines • ▼ Show 20 Lines | if (ruleset == NULL || ruleset->anchor == NULL) { | ||||
return (1); | return (1); | ||||
} | } | ||||
r->anchor = ruleset->anchor; | r->anchor = ruleset->anchor; | ||||
r->anchor->refcnt++; | r->anchor->refcnt++; | ||||
return (0); | return (0); | ||||
} | } | ||||
int | int | ||||
pf_kanchor_nvcopyout(const struct pf_kruleset *rs, const struct pf_krule *r, | |||||
nvlist_t *nvl) | |||||
{ | |||||
char anchor_call[MAXPATHLEN] = { 0 }; | |||||
if (r->anchor == NULL) | |||||
goto done; | |||||
if (!r->anchor_relative) { | |||||
strlcpy(anchor_call, "/", sizeof(anchor_call)); | |||||
strlcat(anchor_call, r->anchor->path, | |||||
sizeof(anchor_call)); | |||||
} else { | |||||
char a[MAXPATHLEN]; | |||||
char *p; | |||||
int i; | |||||
if (rs->anchor == NULL) | |||||
a[0] = 0; | |||||
else | |||||
strlcpy(a, rs->anchor->path, MAXPATHLEN); | |||||
for (i = 1; i < r->anchor_relative; ++i) { | |||||
if ((p = strrchr(a, '/')) == NULL) | |||||
p = a; | |||||
*p = 0; | |||||
strlcat(anchor_call, "../", | |||||
sizeof(anchor_call)); | |||||
} | |||||
if (strncmp(a, r->anchor->path, strlen(a))) { | |||||
printf("pf_anchor_copyout: '%s' '%s'\n", a, | |||||
r->anchor->path); | |||||
return (1); | |||||
} | |||||
if (strlen(r->anchor->path) > strlen(a)) | |||||
strlcat(anchor_call, r->anchor->path + (a[0] ? | |||||
strlen(a) + 1 : 0), sizeof(anchor_call)); | |||||
} | |||||
if (r->anchor_wildcard) | |||||
strlcat(anchor_call, anchor_call[0] ? "/*" : "*", | |||||
sizeof(anchor_call)); | |||||
done: | |||||
nvlist_add_string(nvl, "anchor_call", anchor_call); | |||||
return (0); | |||||
} | |||||
int | |||||
pf_kanchor_copyout(const struct pf_kruleset *rs, const struct pf_krule *r, | pf_kanchor_copyout(const struct pf_kruleset *rs, const struct pf_krule *r, | ||||
struct pfioc_rule *pr) | struct pfioc_rule *pr) | ||||
{ | { | ||||
pr->anchor_call[0] = 0; | pr->anchor_call[0] = 0; | ||||
if (r->anchor == NULL) | if (r->anchor == NULL) | ||||
return (0); | return (0); | ||||
if (!r->anchor_relative) { | if (!r->anchor_relative) { | ||||
strlcpy(pr->anchor_call, "/", sizeof(pr->anchor_call)); | strlcpy(pr->anchor_call, "/", sizeof(pr->anchor_call)); | ||||
▲ Show 20 Lines • Show All 51 Lines • Show Last 20 Lines |