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

Function pf_test_rule

freebsd/netpfil/pf/pf.c:3326–3698  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3324}
3325
3326static int
3327pf_test_rule(struct pf_krule **rm, struct pf_state **sm, int direction,
3328 struct pfi_kkif *kif, struct mbuf *m, int off, struct pf_pdesc *pd,
3329 struct pf_krule **am, struct pf_kruleset **rsm, struct inpcb *inp)
3330{
3331 struct pf_krule *nr = NULL;
3332 struct pf_addr * const saddr = pd->src;
3333 struct pf_addr * const daddr = pd->dst;
3334 sa_family_t af = pd->af;
3335 struct pf_krule *r, *a = NULL;
3336 struct pf_kruleset *ruleset = NULL;
3337 struct pf_ksrc_node *nsn = NULL;
3338 struct tcphdr *th = pd->hdr.tcp;
3339 struct pf_state_key *sk = NULL, *nk = NULL;
3340 u_short reason;
3341 int rewrite = 0, hdrlen = 0;
3342 int tag = -1, rtableid = -1;
3343 int asd = 0;
3344 int match = 0;
3345 int state_icmp = 0;
3346 u_int16_t sport = 0, dport = 0;
3347 u_int16_t bproto_sum = 0, bip_sum = 0;
3348 u_int8_t icmptype = 0, icmpcode = 0;
3349 struct pf_kanchor_stackframe anchor_stack[PF_ANCHOR_STACKSIZE];
3350
3351 PF_RULES_RASSERT();
3352
3353 if (inp != NULL) {
3354 INP_LOCK_ASSERT(inp);
3355 pd->lookup.uid = inp->inp_cred->cr_uid;
3356 pd->lookup.gid = inp->inp_cred->cr_groups[0];
3357 pd->lookup.done = 1;
3358 }
3359
3360 switch (pd->proto) {
3361 case IPPROTO_TCP:
3362 sport = th->th_sport;
3363 dport = th->th_dport;
3364 hdrlen = sizeof(*th);
3365 break;
3366 case IPPROTO_UDP:
3367 sport = pd->hdr.udp->uh_sport;
3368 dport = pd->hdr.udp->uh_dport;
3369 hdrlen = sizeof(*pd->hdr.udp);
3370 break;
3371#ifdef INET
3372 case IPPROTO_ICMP:
3373 if (pd->af != AF_INET)
3374 break;
3375 sport = dport = pd->hdr.icmp->icmp_id;
3376 hdrlen = sizeof(*pd->hdr.icmp);
3377 icmptype = pd->hdr.icmp->icmp_type;
3378 icmpcode = pd->hdr.icmp->icmp_code;
3379
3380 if (icmptype == ICMP_UNREACH ||
3381 icmptype == ICMP_SOURCEQUENCH ||
3382 icmptype == ICMP_REDIRECT ||
3383 icmptype == ICMP_TIMXCEED ||

Callers 2

pf_testFunction · 0.85
pf_test6Function · 0.85

Calls 15

pf_get_translationFunction · 0.85
pf_change_apFunction · 0.85
pf_change_aFunction · 0.85
pf_cksum_fixupFunction · 0.85
m_copybackFunction · 0.85
pf_change_a6Function · 0.85
pfi_kkif_matchFunction · 0.85
pf_match_portFunction · 0.85
pf_socket_lookupFunction · 0.85
pf_match_uidFunction · 0.85
pf_match_gidFunction · 0.85
pf_match_ieee8021q_pcpFunction · 0.85

Tested by

no test coverage detected