diff options
-rw-r--r-- | sbin/ping/ping.c | 11 | ||||
-rw-r--r-- | usr.sbin/traceroute/traceroute.c | 11 |
2 files changed, 7 insertions, 15 deletions
diff --git a/sbin/ping/ping.c b/sbin/ping/ping.c index 652ae109cf4..57d4deaf0d6 100644 --- a/sbin/ping/ping.c +++ b/sbin/ping/ping.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ping.c,v 1.54 2002/06/22 22:47:45 jakob Exp $ */ +/* $OpenBSD: ping.c,v 1.55 2002/06/29 07:56:44 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.54 2002/06/22 22:47:45 jakob Exp $"; +static char rcsid[] = "$OpenBSD: ping.c,v 1.55 2002/06/29 07:56:44 deraadt Exp $"; #endif #endif /* not lint */ @@ -188,7 +188,6 @@ main(argc, argv) struct timeval timeout; struct hostent *hp; struct sockaddr_in *to; - struct protoent *proto; struct in_addr saddr; int i; int ch, hold = 1, packlen, preload; @@ -202,9 +201,7 @@ main(argc, argv) #endif fd_set *fdmaskp; - if (!(proto = getprotobyname("icmp"))) - errx(1, "unknown protocol icmp"); - if ((s = socket(AF_INET, SOCK_RAW, proto->p_proto)) < 0) + if ((s = socket(AF_INET, SOCK_RAW, IPPROTO_ICMP)) < 0) err(1, "socket"); /* revoke privs */ @@ -404,7 +401,7 @@ main(argc, argv) ip->ip_id = 0; ip->ip_off = htons(df?IP_DF:0); ip->ip_ttl = ttl; - ip->ip_p = proto->p_proto; + ip->ip_p = IPPROTO_ICMP; ip->ip_src.s_addr = INADDR_ANY; ip->ip_dst = to->sin_addr; } diff --git a/usr.sbin/traceroute/traceroute.c b/usr.sbin/traceroute/traceroute.c index 38d0a515b40..9405498884d 100644 --- a/usr.sbin/traceroute/traceroute.c +++ b/usr.sbin/traceroute/traceroute.c @@ -1,4 +1,4 @@ -/* $OpenBSD: traceroute.c,v 1.45 2002/06/29 07:46:29 deraadt Exp $ */ +/* $OpenBSD: traceroute.c,v 1.46 2002/06/29 07:56:44 deraadt Exp $ */ /* $NetBSD: traceroute.c,v 1.10 1995/05/21 15:50:45 mycroft Exp $ */ /*- @@ -47,7 +47,7 @@ static char copyright[] = #if 0 static char sccsid[] = "@(#)traceroute.c 8.1 (Berkeley) 6/6/93";*/ #else -static char rcsid[] = "$OpenBSD: traceroute.c,v 1.45 2002/06/29 07:46:29 deraadt Exp $"; +static char rcsid[] = "$OpenBSD: traceroute.c,v 1.46 2002/06/29 07:56:44 deraadt Exp $"; #endif #endif /* not lint */ @@ -304,7 +304,6 @@ main(argc, argv) char *argv[]; { struct hostent *hp; - struct protoent *pe; struct sockaddr_in from, to; int ch, i, lsrr, on, probe, seq, tos, ttl; int ttl_flag, incflag = 1, protoset = 0; @@ -314,11 +313,7 @@ main(argc, argv) int mib[4] = { CTL_NET, PF_INET, IPPROTO_IP, IPCTL_DEFTTL }; size_t size = sizeof(max_ttl); - if ((pe = getprotobyname("icmp")) == NULL) { - fprintf(stderr, "icmp: unknown protocol\n"); - exit(10); - } - if ((s = socket(AF_INET, SOCK_RAW, pe->p_proto)) < 0) + if ((s = socket(AF_INET, SOCK_RAW, IPPROTO_ICMP)) < 0) err(5, "icmp socket"); if ((sndsock = socket(AF_INET, SOCK_RAW, IPPROTO_RAW)) < 0) err(5, "raw socket"); |