From 14cd26d40a0951eaf4cfd5436ffce5c26fae0607 Mon Sep 17 00:00:00 2001 From: "Angelos D. Keromytis" Date: Mon, 6 Dec 1999 07:14:37 +0000 Subject: New ESP code that's v4 and v6 friendly. --- sys/netinet/ip_esp.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) (limited to 'sys/netinet/ip_esp.c') diff --git a/sys/netinet/ip_esp.c b/sys/netinet/ip_esp.c index 10c16389760..ab3eae18fea 100644 --- a/sys/netinet/ip_esp.c +++ b/sys/netinet/ip_esp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ip_esp.c,v 1.26 1999/11/04 11:23:43 ho Exp $ */ +/* $OpenBSD: ip_esp.c,v 1.27 1999/12/06 07:14:35 angelos Exp $ */ /* * The authors of this code are John Ioannidis (ji@tla.org), @@ -84,6 +84,10 @@ extern struct enc_softc encif[]; #define DPRINTF(x) #endif +#ifndef offsetof +#define offsetof(s, e) ((int)&((s *)0)->e) +#endif + int esp_enable = 0; /* @@ -188,7 +192,8 @@ esp_input(m, va_alist) ipn = *ipo; - m = (*(tdbp->tdb_xform->xf_input))(m, tdbp); + m = (*(tdbp->tdb_xform->xf_input))(m, tdbp, ipo->ip_hl << 2, + offsetof(struct ip, ip_p)); if (m == NULL) { @@ -197,7 +202,17 @@ esp_input(m, va_alist) return; } + if ((m = m_pullup(m, ipn.ip_hl << 2)) == 0) + { + espstat.esps_hdrops++; + return; + } + ipo = mtod(m, struct ip *); + ipo->ip_len = htons(m->m_pkthdr.len); + ipo->ip_sum = 0; + ipo->ip_sum = in_cksum(m, ipo->ip_hl << 2); + if (ipo->ip_p == IPPROTO_IPIP) /* IP-in-IP encapsulation */ { /* ipn will now contain the inner IP header */ -- cgit v1.2.3