Changeset View
Changeset View
Standalone View
Standalone View
sys/netpfil/ipfw/nat64/nat64clat.c
| Show First 20 Lines • Show All 53 Lines • ▼ Show 20 Lines | |||||
| #include <netinet6/ip_fw_nat64.h> | #include <netinet6/ip_fw_nat64.h> | ||||
| #include <netpfil/ipfw/ip_fw_private.h> | #include <netpfil/ipfw/ip_fw_private.h> | ||||
| #include <netpfil/pf/pf.h> | #include <netpfil/pf/pf.h> | ||||
| #include "nat64clat.h" | #include "nat64clat.h" | ||||
| #define NAT64_LOOKUP(chain, cmd) \ | #define NAT64_LOOKUP(chain, cmd) \ | ||||
| (struct nat64clat_cfg *)SRV_OBJECT((chain), (cmd)->arg1) | (struct nat64clat_cfg *)SRV_OBJECT((chain), insntod(cmd, kidx)->kidx) | ||||
| static void | static void | ||||
| nat64clat_log(struct pfloghdr *plog, struct mbuf *m, sa_family_t family, | nat64clat_log(struct pfloghdr *plog, struct mbuf *m, sa_family_t family, | ||||
| uint32_t kidx) | uint32_t kidx) | ||||
| { | { | ||||
| static uint32_t pktid = 0; | static uint32_t pktid = 0; | ||||
| memset(plog, 0, sizeof(*plog)); | memset(plog, 0, sizeof(*plog)); | ||||
| plog->length = PFLOG_HDRLEN; | plog->length = PFLOG_REAL_HDRLEN; | ||||
| plog->af = family; | plog->af = family; | ||||
| plog->action = PF_NAT; | plog->action = PF_NAT; | ||||
| plog->dir = PF_IN; | plog->dir = PF_IN; | ||||
| plog->rulenr = htonl(kidx); | plog->rulenr = htonl(kidx); | ||||
| pktid++; | pktid++; | ||||
| plog->subrulenr = htonl(pktid); | plog->subrulenr = htonl(pktid); | ||||
| plog->ruleset[0] = '\0'; | plog->ruleset[0] = '\0'; | ||||
| strlcpy(plog->ifname, "NAT64CLAT", sizeof(plog->ifname)); | strlcpy(plog->ifname, "NAT64CLAT", sizeof(plog->ifname)); | ||||
| ▲ Show 20 Lines • Show All 125 Lines • ▼ Show 20 Lines | |||||
| { | { | ||||
| ipfw_insn *icmd; | ipfw_insn *icmd; | ||||
| struct nat64clat_cfg *cfg; | struct nat64clat_cfg *cfg; | ||||
| int ret; | int ret; | ||||
| IPFW_RLOCK_ASSERT(chain); | IPFW_RLOCK_ASSERT(chain); | ||||
| *done = 0; /* try next rule if not matched */ | *done = 0; /* try next rule if not matched */ | ||||
| icmd = cmd + 1; | icmd = cmd + F_LEN(cmd); | ||||
| if (cmd->opcode != O_EXTERNAL_ACTION || | if (cmd->opcode != O_EXTERNAL_ACTION || | ||||
| cmd->arg1 != V_nat64clat_eid || | insntod(cmd, kidx)->kidx != V_nat64clat_eid || | ||||
| icmd->opcode != O_EXTERNAL_INSTANCE || | icmd->opcode != O_EXTERNAL_INSTANCE || | ||||
| (cfg = NAT64_LOOKUP(chain, icmd)) == NULL) | (cfg = NAT64_LOOKUP(chain, icmd)) == NULL) | ||||
| return (0); | return (0); | ||||
| switch (args->f_id.addr_type) { | switch (args->f_id.addr_type) { | ||||
| case 4: | case 4: | ||||
| ret = nat64clat_handle_ip4(chain, cfg, args->m); | ret = nat64clat_handle_ip4(chain, cfg, args->m); | ||||
| break; | break; | ||||
| Show All 29 Lines | |||||