-/* $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 $ */
/*
#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 */
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;
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);
}
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 */
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;
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();
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;
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);