diff options
author | Angelos D. Keromytis <angelos@cvs.openbsd.org> | 1999-12-06 07:14:37 +0000 |
---|---|---|
committer | Angelos D. Keromytis <angelos@cvs.openbsd.org> | 1999-12-06 07:14:37 +0000 |
commit | 14cd26d40a0951eaf4cfd5436ffce5c26fae0607 (patch) | |
tree | 35a79f3fa03ee03935738d445721807daa954fee /sys/netinet/ip_esp.c | |
parent | 07fd058044fbd8138e453c2dd542b4a80aafc864 (diff) |
New ESP code that's v4 and v6 friendly.
Diffstat (limited to 'sys/netinet/ip_esp.c')
-rw-r--r-- | sys/netinet/ip_esp.c | 19 |
1 files changed, 17 insertions, 2 deletions
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 */ |