Changeset View
Changeset View
Standalone View
Standalone View
sys/netpfil/ipfw/nat64/nat64stl.c
| Show First 20 Lines • Show All 52 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 "nat64stl.h" | #include "nat64stl.h" | ||||
| #define NAT64_LOOKUP(chain, cmd) \ | #define NAT64_LOOKUP(chain, cmd) \ | ||||
| (struct nat64stl_cfg *)SRV_OBJECT((chain), (cmd)->arg1) | (struct nat64stl_cfg *)SRV_OBJECT((chain), insntod(cmd, kidx)->kidx) | ||||
| static void | static void | ||||
| nat64stl_log(struct pfloghdr *plog, struct mbuf *m, sa_family_t family, | nat64stl_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, "NAT64STL", sizeof(plog->ifname)); | strlcpy(plog->ifname, "NAT64STL", sizeof(plog->ifname)); | ||||
| ▲ Show 20 Lines • Show All 120 Lines • ▼ Show 20 Lines | nat64stl_handle_icmp6(struct ip_fw_chain *chain, struct nat64stl_cfg *cfg, | ||||
| return (nat64_handle_icmp6(m, 0, | return (nat64_handle_icmp6(m, 0, | ||||
| htonl(TARG_VAL(chain, tablearg, nh4)), 0, &cfg->base, logdata)); | htonl(TARG_VAL(chain, tablearg, nh4)), 0, &cfg->base, logdata)); | ||||
| } | } | ||||
| int | int | ||||
| ipfw_nat64stl(struct ip_fw_chain *chain, struct ip_fw_args *args, | ipfw_nat64stl(struct ip_fw_chain *chain, struct ip_fw_args *args, | ||||
| ipfw_insn *cmd, int *done) | ipfw_insn *cmd, int *done) | ||||
| { | { | ||||
| ipfw_insn *icmd; | |||||
| struct nat64stl_cfg *cfg; | struct nat64stl_cfg *cfg; | ||||
| ipfw_insn *icmd; | |||||
| in_addr_t dst4; | in_addr_t dst4; | ||||
| uint32_t tablearg; | uint32_t tablearg; | ||||
| 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_nat64stl_eid || | insntod(cmd, kidx)->kidx != V_nat64stl_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: | ||||
| dst4 = htonl(args->f_id.dst_ip); | dst4 = htonl(args->f_id.dst_ip); | ||||
| ret = ipfw_lookup_table(chain, cfg->map46, sizeof(in_addr_t), | ret = ipfw_lookup_table(chain, cfg->map46, sizeof(in_addr_t), | ||||
| Show All 36 Lines | |||||