diff options
Diffstat (limited to 'sys/netinet/ip_icmp.c')
-rw-r--r-- | sys/netinet/ip_icmp.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/sys/netinet/ip_icmp.c b/sys/netinet/ip_icmp.c index ba1071a6a94..59a1d73863e 100644 --- a/sys/netinet/ip_icmp.c +++ b/sys/netinet/ip_icmp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ip_icmp.c,v 1.16 1999/01/08 11:35:09 deraadt Exp $ */ +/* $OpenBSD: ip_icmp.c,v 1.17 1999/09/23 07:20:35 deraadt Exp $ */ /* $NetBSD: ip_icmp.c,v 1.19 1996/02/13 23:42:22 christos Exp $ */ /* @@ -91,6 +91,8 @@ extern struct protosw inetsw[]; /* * Generate an error packet of type error * in response to bad packet ip. + * + * The ip packet inside has ip_off and ip_len in host byte order. */ void icmp_error(n, type, code, dest, destifp) @@ -116,7 +118,7 @@ icmp_error(n, type, code, dest, destifp) * Don't error if the old packet protocol was ICMP * error message, only known informational types. */ - if (ntohs(oip->ip_off) &~ (IP_MF|IP_DF)) + if (oip->ip_off &~ (IP_MF|IP_DF)) goto freeit; if (oip->ip_p == IPPROTO_ICMP && type != ICMP_REDIRECT && n->m_len >= oiplen + ICMP_MINLEN && @@ -133,7 +135,7 @@ icmp_error(n, type, code, dest, destifp) m = m_gethdr(M_DONTWAIT, MT_HEADER); if (m == NULL) goto freeit; - icmplen = oiplen + min(8, ntohs(oip->ip_len)); + icmplen = oiplen + min(8, oip->ip_len); m->m_len = icmplen + ICMP_MINLEN; MH_ALIGN(m, m->m_len); icp = mtod(m, struct icmp *); @@ -158,9 +160,10 @@ icmp_error(n, type, code, dest, destifp) } icp->icmp_code = code; + HTONS(oip->ip_off); + HTONS(oip->ip_len); bcopy((caddr_t)oip, (caddr_t)&icp->icmp_ip, icmplen); nip = &icp->icmp_ip; - nip->ip_len = htons((u_int16_t)(ntohs(nip->ip_len) + oiplen)); m0.m_next = NULL; /* correct nip->ip_sum */ m0.m_data = (char *)nip; |