Changeset View
Changeset View
Standalone View
Standalone View
sys/netipsec/ipsec_input.c
Show First 20 Lines • Show All 270 Lines • ▼ Show 20 Lines | |||||
int | int | ||||
ipsec4_ctlinput(int code, struct sockaddr *sa, void *v) | ipsec4_ctlinput(int code, struct sockaddr *sa, void *v) | ||||
{ | { | ||||
struct in_conninfo inc; | struct in_conninfo inc; | ||||
struct secasvar *sav; | struct secasvar *sav; | ||||
struct icmp *icp; | struct icmp *icp; | ||||
struct ip *ip = v; | struct ip *ip = v; | ||||
uint32_t pmtu, spi; | uint32_t pmtu, spi; | ||||
uint8_t proto; | |||||
if (code != PRC_MSGSIZE || ip == NULL) | if (code != PRC_MSGSIZE || ip == NULL) | ||||
return (EINVAL); | return (EINVAL); | ||||
if (sa->sa_family != AF_INET || | if (sa->sa_family != AF_INET || | ||||
sa->sa_len != sizeof(struct sockaddr_in)) | sa->sa_len != sizeof(struct sockaddr_in)) | ||||
return (EAFNOSUPPORT); | return (EAFNOSUPPORT); | ||||
icp = __containerof(ip, struct icmp, icmp_ip); | icp = __containerof(ip, struct icmp, icmp_ip); | ||||
pmtu = ntohs(icp->icmp_nextmtu); | pmtu = ntohs(icp->icmp_nextmtu); | ||||
if (pmtu < V_ip4_ipsec_min_pmtu) | if (pmtu < V_ip4_ipsec_min_pmtu) | ||||
return (EINVAL); | return (EINVAL); | ||||
proto = ip->ip_p; | |||||
if (proto != IPPROTO_ESP && proto != IPPROTO_AH && | |||||
proto != IPPROTO_IPCOMP) | |||||
return (EINVAL); | |||||
memcpy(&spi, (caddr_t)ip + (ip->ip_hl << 2), sizeof(spi)); | memcpy(&spi, (caddr_t)ip + (ip->ip_hl << 2), sizeof(spi)); | ||||
sav = key_allocsa((union sockaddr_union *)sa, ip->ip_p, spi); | sav = key_allocsa((union sockaddr_union *)sa, proto, spi); | ||||
if (sav == NULL) | if (sav == NULL) | ||||
return (ENOENT); | return (ENOENT); | ||||
key_freesav(&sav); | key_freesav(&sav); | ||||
memset(&inc, 0, sizeof(inc)); | memset(&inc, 0, sizeof(inc)); | ||||
inc.inc_faddr = satosin(sa)->sin_addr; | inc.inc_faddr = satosin(sa)->sin_addr; | ||||
tcp_hc_updatemtu(&inc, pmtu); | tcp_hc_updatemtu(&inc, pmtu); | ||||
▲ Show 20 Lines • Show All 427 Lines • Show Last 20 Lines |