Changeset View
Changeset View
Standalone View
Standalone View
sys/netpfil/pf/pf_norm.c
Show First 20 Lines • Show All 1,209 Lines • ▼ Show 20 Lines | pf_normalize_tcp(int dir, struct pfi_kif *kif, struct mbuf *m, int ipoff, | ||||
if (flags != th->th_flags || th->th_x2 != 0) { | if (flags != th->th_flags || th->th_x2 != 0) { | ||||
u_int16_t ov, nv; | u_int16_t ov, nv; | ||||
ov = *(u_int16_t *)(&th->th_ack + 1); | ov = *(u_int16_t *)(&th->th_ack + 1); | ||||
th->th_flags = flags; | th->th_flags = flags; | ||||
th->th_x2 = 0; | th->th_x2 = 0; | ||||
nv = *(u_int16_t *)(&th->th_ack + 1); | nv = *(u_int16_t *)(&th->th_ack + 1); | ||||
th->th_sum = pf_cksum_fixup(th->th_sum, ov, nv, 0); | th->th_sum = pf_proto_cksum_fixup(m, th->th_sum, ov, nv, 0); | ||||
rewrite = 1; | rewrite = 1; | ||||
} | } | ||||
/* Remove urgent pointer, if TH_URG is not set */ | /* Remove urgent pointer, if TH_URG is not set */ | ||||
if (!(flags & TH_URG) && th->th_urp) { | if (!(flags & TH_URG) && th->th_urp) { | ||||
th->th_sum = pf_cksum_fixup(th->th_sum, th->th_urp, 0, 0); | th->th_sum = pf_proto_cksum_fixup(m, th->th_sum, th->th_urp, | ||||
0, 0); | |||||
th->th_urp = 0; | th->th_urp = 0; | ||||
rewrite = 1; | rewrite = 1; | ||||
} | } | ||||
/* Process options */ | /* Process options */ | ||||
if (r->max_mss && pf_normalize_tcpopt(r, m, th, off, pd->af)) | if (r->max_mss && pf_normalize_tcpopt(r, m, th, off, pd->af)) | ||||
rewrite = 1; | rewrite = 1; | ||||
▲ Show 20 Lines • Show All 184 Lines • ▼ Show 20 Lines | while (hlen >= TCPOLEN_TIMESTAMP) { | ||||
} | } | ||||
if (opt[1] >= TCPOLEN_TIMESTAMP) { | if (opt[1] >= TCPOLEN_TIMESTAMP) { | ||||
memcpy(&tsval, &opt[2], | memcpy(&tsval, &opt[2], | ||||
sizeof(u_int32_t)); | sizeof(u_int32_t)); | ||||
if (tsval && src->scrub && | if (tsval && src->scrub && | ||||
(src->scrub->pfss_flags & | (src->scrub->pfss_flags & | ||||
PFSS_TIMESTAMP)) { | PFSS_TIMESTAMP)) { | ||||
tsval = ntohl(tsval); | tsval = ntohl(tsval); | ||||
pf_change_a(&opt[2], | pf_change_proto_a(m, &opt[2], | ||||
&th->th_sum, | &th->th_sum, | ||||
htonl(tsval + | htonl(tsval + | ||||
src->scrub->pfss_ts_mod), | src->scrub->pfss_ts_mod), | ||||
0); | 0); | ||||
copyback = 1; | copyback = 1; | ||||
} | } | ||||
/* Modulate TS reply iff valid (!0) */ | /* Modulate TS reply iff valid (!0) */ | ||||
memcpy(&tsecr, &opt[6], | memcpy(&tsecr, &opt[6], | ||||
sizeof(u_int32_t)); | sizeof(u_int32_t)); | ||||
if (tsecr && dst->scrub && | if (tsecr && dst->scrub && | ||||
(dst->scrub->pfss_flags & | (dst->scrub->pfss_flags & | ||||
PFSS_TIMESTAMP)) { | PFSS_TIMESTAMP)) { | ||||
tsecr = ntohl(tsecr) | tsecr = ntohl(tsecr) | ||||
- dst->scrub->pfss_ts_mod; | - dst->scrub->pfss_ts_mod; | ||||
pf_change_a(&opt[6], | pf_change_proto_a(m, &opt[6], | ||||
&th->th_sum, htonl(tsecr), | &th->th_sum, htonl(tsecr), | ||||
0); | 0); | ||||
copyback = 1; | copyback = 1; | ||||
} | } | ||||
got_ts = 1; | got_ts = 1; | ||||
} | } | ||||
/* FALLTHROUGH */ | /* FALLTHROUGH */ | ||||
default: | default: | ||||
▲ Show 20 Lines • Show All 310 Lines • ▼ Show 20 Lines | else { | ||||
optlen = optp[1]; | optlen = optp[1]; | ||||
if (optlen < 2 || optlen > cnt) | if (optlen < 2 || optlen > cnt) | ||||
break; | break; | ||||
} | } | ||||
switch (opt) { | switch (opt) { | ||||
case TCPOPT_MAXSEG: | case TCPOPT_MAXSEG: | ||||
mss = (u_int16_t *)(optp + 2); | mss = (u_int16_t *)(optp + 2); | ||||
if ((ntohs(*mss)) > r->max_mss) { | if ((ntohs(*mss)) > r->max_mss) { | ||||
th->th_sum = pf_cksum_fixup(th->th_sum, | th->th_sum = pf_proto_cksum_fixup(m, | ||||
*mss, htons(r->max_mss), 0); | th->th_sum, *mss, htons(r->max_mss), 0); | ||||
*mss = htons(r->max_mss); | *mss = htons(r->max_mss); | ||||
rewrite = 1; | rewrite = 1; | ||||
} | } | ||||
break; | break; | ||||
default: | default: | ||||
break; | break; | ||||
} | } | ||||
} | } | ||||
▲ Show 20 Lines • Show All 63 Lines • Show Last 20 Lines |