Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.sbin/traceroute it is highly unlikely that protocol # fo...



details:   https://anonhg.NetBSD.org/src/rev/5606af45b8be
branches:  trunk
changeset: 533401:5606af45b8be
user:      itojun <itojun%NetBSD.org@localhost>
date:      Sat Jun 29 12:12:57 2002 +0000

description:
it is highly unlikely that protocol # for ip/icmp to change.  from deraadt.

diffstat:

 usr.sbin/traceroute/traceroute.c |  20 ++++----------------
 1 files changed, 4 insertions(+), 16 deletions(-)

diffs (62 lines):

diff -r b9f2fc559fec -r 5606af45b8be usr.sbin/traceroute/traceroute.c
--- a/usr.sbin/traceroute/traceroute.c  Sat Jun 29 10:54:14 2002 +0000
+++ b/usr.sbin/traceroute/traceroute.c  Sat Jun 29 12:12:57 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: traceroute.c,v 1.46 2002/05/26 14:45:43 itojun Exp $   */
+/*     $NetBSD: traceroute.c,v 1.47 2002/06/29 12:12:57 itojun Exp $   */
 
 /*
  * Copyright (c) 1988, 1989, 1991, 1994, 1995, 1996, 1997
@@ -29,7 +29,7 @@
 #else
 __COPYRIGHT("@(#) Copyright (c) 1988, 1989, 1991, 1994, 1995, 1996, 1997\n\
 The Regents of the University of California.  All rights reserved.\n");
-__RCSID("$NetBSD: traceroute.c,v 1.46 2002/05/26 14:45:43 itojun Exp $");
+__RCSID("$NetBSD: traceroute.c,v 1.47 2002/06/29 12:12:57 itojun Exp $");
 #endif
 #endif
 
@@ -391,7 +391,6 @@
        register struct sockaddr_in *to = (struct sockaddr_in *)&whereto;
        register struct hostinfo *hi;
        int on = 1;
-       register struct protoent *pe;
        register int ttl, probe, i;
        register int seq = 0;
        int tos = 0, settos = 0, ttl_flag = 0;
@@ -637,12 +636,7 @@
                outmark = outudp + 1;
        }
 
-       cp = "icmp";
-       if ((pe = getprotobyname(cp)) == NULL) {
-               Fprintf(stderr, "%s: unknown protocol %s\n", prog, cp);
-               exit(1);
-       }
-       if ((s = socket(AF_INET, SOCK_RAW, pe->p_proto)) < 0) {
+       if ((s = socket(AF_INET, SOCK_RAW, IPPROTO_ICMP)) < 0) {
                Fprintf(stderr, "%s: icmp socket: %s\n", prog, strerror(errno));
                exit(1);
        }
@@ -736,12 +730,6 @@
        if (lsrr > 0) {
                u_char optlist[MAX_IPOPTLEN];
 
-               cp = "ip";
-               if ((pe = getprotobyname(cp)) == NULL) {
-                       Fprintf(stderr, "%s: unknown protocol %s\n", prog, cp);
-                       exit(1);
-               }
-
                /* final hop */
                gwlist[lsrr] = to->sin_addr.s_addr;
                ++lsrr;
@@ -756,7 +744,7 @@
                optlist[3] = IPOPT_MINOFF;
                memcpy(optlist + 4, gwlist, i);
 
-               if ((setsockopt(sndsock, pe->p_proto, IP_OPTIONS, optlist,
+               if ((setsockopt(sndsock, IPPROTO_IP, IP_OPTIONS, optlist,
                    i + sizeof(gwlist[0]))) < 0) {
                        Fprintf(stderr, "%s: IP_OPTIONS: %s\n",
                            prog, strerror(errno));



Home | Main Index | Thread Index | Old Index