From 61cc96317a1d67aca918d6f01e463719168f1648 Mon Sep 17 00:00:00 2001 From: deraadt Date: Thu, 30 Jan 1997 22:43:11 +0000 Subject: [PATCH] deal with IP_HDRINCL option network byte order change; lidl@va.pubnix.com --- sbin/ping/ping.c | 8 ++++---- usr.sbin/mrouted/igmp.c | 6 +++--- usr.sbin/traceroute/traceroute.c | 4 ++-- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/sbin/ping/ping.c b/sbin/ping/ping.c index 330326d126a..14c241f2399 100644 --- a/sbin/ping/ping.c +++ b/sbin/ping/ping.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ping.c,v 1.13 1997/01/15 23:41:36 millert Exp $ */ +/* $OpenBSD: ping.c,v 1.14 1997/01/30 22:43:14 deraadt Exp $ */ /* $NetBSD: ping.c,v 1.20 1995/08/11 22:37:58 cgd Exp $ */ /* @@ -47,7 +47,7 @@ static char copyright[] = #if 0 static char sccsid[] = "@(#)ping.c 8.1 (Berkeley) 6/5/93"; #else -static char rcsid[] = "$OpenBSD: ping.c,v 1.13 1997/01/15 23:41:36 millert Exp $"; +static char rcsid[] = "$OpenBSD: ping.c,v 1.14 1997/01/30 22:43:14 deraadt Exp $"; #endif #endif /* not lint */ @@ -377,7 +377,7 @@ main(argc, argv) ip->ip_hl = sizeof(struct ip) >> 2; ip->ip_tos = tos; ip->ip_id = 0; - ip->ip_off = (df?IP_DF:0); + ip->ip_off = htons(df?IP_DF:0); ip->ip_ttl = ttl; ip->ip_p = proto->p_proto; ip->ip_src.s_addr = INADDR_ANY; @@ -553,7 +553,7 @@ pinger() packet = (char*)ip; cc += sizeof(struct ip); - ip->ip_len = cc; + ip->ip_len = htons(cc); ip->ip_sum = in_cksum((u_short *)outpackhdr, cc); } diff --git a/usr.sbin/mrouted/igmp.c b/usr.sbin/mrouted/igmp.c index 1b623ba42ff..2efb6d319b3 100644 --- a/usr.sbin/mrouted/igmp.c +++ b/usr.sbin/mrouted/igmp.c @@ -55,7 +55,7 @@ init_igmp() ip->ip_hl = sizeof(struct ip) >> 2; ip->ip_v = IPVERSION; ip->ip_tos = 0; - ip->ip_off = 0; + ip->ip_off = htons(0); ip->ip_p = IPPROTO_IGMP; ip->ip_ttl = MAXTTL; /* applies to unicasts only */ @@ -314,7 +314,7 @@ send_igmp(src, dst, type, code, group, datalen) ip = (struct ip *)send_buf; ip->ip_src.s_addr = src; ip->ip_dst.s_addr = dst; - ip->ip_len = MIN_IP_HEADER_LEN + IGMP_MINLEN + datalen; + ip->ip_len = htons(MIN_IP_HEADER_LEN + IGMP_MINLEN + datalen); igmp = (struct igmp *)(send_buf + MIN_IP_HEADER_LEN); igmp->igmp_type = type; @@ -338,7 +338,7 @@ send_igmp(src, dst, type, code, group, datalen) sdst.sin_len = sizeof(sdst); #endif sdst.sin_addr.s_addr = dst; - if (sendto(igmp_socket, send_buf, ip->ip_len, 0, + if (sendto(igmp_socket, send_buf, ntohs(ip->ip_len), 0, (struct sockaddr *)&sdst, sizeof(sdst)) < 0) { if (errno == ENETDOWN) check_vif_state(); diff --git a/usr.sbin/traceroute/traceroute.c b/usr.sbin/traceroute/traceroute.c index da93f7b8411..ab33f769f7f 100644 --- a/usr.sbin/traceroute/traceroute.c +++ b/usr.sbin/traceroute/traceroute.c @@ -432,7 +432,7 @@ main(argc, argv) ip->ip_dst = gateway[0]; } else ip->ip_dst = to.sin_addr; - ip->ip_off = 0; + ip->ip_off = htons(0); ip->ip_hl = (sizeof(struct ip) + lsrrlen) >> 2; ip->ip_p = IPPROTO_UDP; ip->ip_v = IPVERSION; @@ -618,7 +618,7 @@ send_probe(seq, ttl, to) struct packetdata *op = (struct packetdata *)(up + 1); int i; - ip->ip_len = datalen; + ip->ip_len = htons(datalen); ip->ip_ttl = ttl; ip->ip_id = htons(ident+seq); -- 2.20.1