Changeset View
Changeset View
Standalone View
Standalone View
sys/contrib/ipfilter/netinet/ip_nat.c
Show First 20 Lines • Show All 313 Lines • ▼ Show 20 Lines | ipf_nat_soft_create(softc) | ||||
ipf_nat_softc_t *softn; | ipf_nat_softc_t *softn; | ||||
KMALLOC(softn, ipf_nat_softc_t *); | KMALLOC(softn, ipf_nat_softc_t *); | ||||
if (softn == NULL) | if (softn == NULL) | ||||
return NULL; | return NULL; | ||||
bzero((char *)softn, sizeof(*softn)); | bzero((char *)softn, sizeof(*softn)); | ||||
softn->ipf_nat_ip_id = ip_initid(); | |||||
softn->ipf_nat_tune = ipf_tune_array_copy(softn, | softn->ipf_nat_tune = ipf_tune_array_copy(softn, | ||||
sizeof(ipf_nat_tuneables), | sizeof(ipf_nat_tuneables), | ||||
ipf_nat_tuneables); | ipf_nat_tuneables); | ||||
if (softn->ipf_nat_tune == NULL) { | if (softn->ipf_nat_tune == NULL) { | ||||
ipf_nat_soft_destroy(softc, softn); | ipf_nat_soft_destroy(softc, softn); | ||||
return NULL; | return NULL; | ||||
} | } | ||||
if (ipf_tune_array_link(softc, softn->ipf_nat_tune) == -1) { | if (ipf_tune_array_link(softc, softn->ipf_nat_tune) == -1) { | ||||
▲ Show 20 Lines • Show All 4,886 Lines • ▼ Show 20 Lines | case NAT_DIVERTOUT : | ||||
m = M_DUP(np->in_divmp); | m = M_DUP(np->in_divmp); | ||||
if (m == NULL) { | if (m == NULL) { | ||||
NBUMPSIDED(1, ns_divert_dup); | NBUMPSIDED(1, ns_divert_dup); | ||||
return -1; | return -1; | ||||
} | } | ||||
ip = MTOD(m, ip_t *); | ip = MTOD(m, ip_t *); | ||||
ip_fillid(ip); | ip_fillid(ip, &softn->ipf_nat_ip_id); | ||||
s2 = ntohs(ip->ip_id); | s2 = ntohs(ip->ip_id); | ||||
s1 = ip->ip_len; | s1 = ip->ip_len; | ||||
ip->ip_len = ntohs(ip->ip_len); | ip->ip_len = ntohs(ip->ip_len); | ||||
ip->ip_len += fin->fin_plen; | ip->ip_len += fin->fin_plen; | ||||
ip->ip_len = htons(ip->ip_len); | ip->ip_len = htons(ip->ip_len); | ||||
s2 += ntohs(ip->ip_len); | s2 += ntohs(ip->ip_len); | ||||
CALC_SUMD(s1, s2, sumd); | CALC_SUMD(s1, s2, sumd); | ||||
▲ Show 20 Lines • Show All 428 Lines • ▼ Show 20 Lines | case NAT_DIVERTIN : | ||||
m = M_DUP(np->in_divmp); | m = M_DUP(np->in_divmp); | ||||
if (m == NULL) { | if (m == NULL) { | ||||
NBUMPSIDED(0, ns_divert_dup); | NBUMPSIDED(0, ns_divert_dup); | ||||
return -1; | return -1; | ||||
} | } | ||||
ip = MTOD(m, ip_t *); | ip = MTOD(m, ip_t *); | ||||
ip_fillid(ip); | ip_fillid(ip, &softn->ipf_nat_ip_id); | ||||
sum1 = ntohs(ip->ip_len); | sum1 = ntohs(ip->ip_len); | ||||
ip->ip_len = ntohs(ip->ip_len); | ip->ip_len = ntohs(ip->ip_len); | ||||
ip->ip_len += fin->fin_plen; | ip->ip_len += fin->fin_plen; | ||||
ip->ip_len = htons(ip->ip_len); | ip->ip_len = htons(ip->ip_len); | ||||
uh = (udphdr_t *)(ip + 1); | uh = (udphdr_t *)(ip + 1); | ||||
uh->uh_ulen += fin->fin_plen; | uh->uh_ulen += fin->fin_plen; | ||||
uh->uh_ulen = htons(uh->uh_ulen); | uh->uh_ulen = htons(uh->uh_ulen); | ||||
▲ Show 20 Lines • Show All 2,919 Lines • Show Last 20 Lines |