Lines Matching refs:npc
413 npf_nat_inspect(npf_cache_t *npc, const unsigned di)
415 npf_t *npf = npc->npc_ctx;
421 rl = npf_ruleset_inspect(npc, rlset, di, NPF_RULE_LAYER_3);
433 npf_nat_algo_netmap(const npf_cache_t *npc, const npf_natpolicy_t *np,
436 const npf_addr_t *orig_addr = npc->npc_ips[which];
443 npf_addr_mask(&np->n_taddr, np->n_tmask, npc->npc_alen, addr);
444 npf_addr_bitor(orig_addr, np->n_tmask, npc->npc_alen, addr);
448 npf_nat_getaddr(npf_cache_t *npc, npf_natpolicy_t *np, const unsigned alen)
464 npc->npc_ips[NPF_SRC],
465 npc->npc_ips[NPF_DST]);
477 npf_nat_create(npf_cache_t *npc, npf_natpolicy_t *np, npf_conn_t *con)
479 const unsigned proto = npc->npc_proto;
480 const unsigned alen = npc->npc_alen;
481 const nbuf_t *nbuf = npc->npc_nbuf;
482 npf_t *npf = npc->npc_ctx;
486 KASSERT(npf_iscached(npc, NPC_IP46));
487 KASSERT(npf_iscached(npc, NPC_LAYER4));
514 taddr = npf_nat_getaddr(npc, np, alen);
525 npf_nat_algo_netmap(npc, np, which, &nt->nt_taddr);
537 memcpy(&nt->nt_oaddr, npc->npc_ips[NPF_SRC], alen);
541 memcpy(&nt->nt_oaddr, npc->npc_ips[NPF_DST], alen);
556 const struct tcphdr *th = npc->npc_l4.tcp;
560 const struct udphdr *uh = npc->npc_l4.udp;
584 npf_dnat_translate(npf_cache_t *npc, npf_nat_t *nt, npf_flow_t flow)
591 KASSERT(npf_iscached(npc, NPC_IP46));
592 KASSERT(npf_iscached(npc, NPC_LAYER4));
606 if ((npc->npc_info & NPC_ALG_EXEC) == 0) {
607 npc->npc_info |= NPC_ALG_EXEC;
608 npf_alg_exec(npc, nt, flow);
609 npf_recache(npc);
611 KASSERT(!nbuf_flag_p(npc->npc_nbuf, NBUF_DATAREF_RESET));
614 return npf_napt_rwr(npc, which, addr, port);
621 npf_snat_translate(npf_cache_t *npc, const npf_natpolicy_t *np, npf_flow_t flow)
631 npf_nat_algo_netmap(npc, np, which, &addr);
635 return npf_npt66_rwr(npc, which, &np->n_taddr,
641 return npf_napt_rwr(npc, which, taddr, np->n_tport);
648 npf_nat_share_policy(npf_cache_t *npc, npf_conn_t *con, npf_nat_t *src_nt)
655 nt = npf_nat_create(npc, np, con);
662 ret = npf_conn_setnat(npc, con, nt, np->n_type);
678 npf_nat_lookup(const npf_cache_t *npc, npf_conn_t *con,
681 const nbuf_t *nbuf = npc->npc_nbuf;
716 npf_do_nat(npf_cache_t *npc, npf_conn_t *con, const unsigned di)
718 nbuf_t *nbuf = npc->npc_nbuf;
726 if (!npf_iscached(npc, NPC_IP46) || !npf_iscached(npc, NPC_LAYER4)) {
736 if (con && (nt = npf_nat_lookup(npc, con, di, &flow)) != NULL) {
745 np = npf_nat_inspect(npc, di);
755 npf_recache(npc);
757 error = npf_snat_translate(npc, np, flow);
769 ncon = npf_conn_establish(npc, di, true);
781 nt = npf_nat_create(npc, np, con);
789 if (npf_alg_match(npc, nt, di)) {
794 error = npf_conn_setnat(npc, con, nt, np->n_type);
804 npf_recache(npc);
808 error = npf_dnat_translate(npc, nt, flow);