Source-Changes-HG archive

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

[src/trunk]: src/lib/libpcap improve message when IPv4 address is not assigne...



details:   https://anonhg.NetBSD.org/src/rev/9b894d2c84b6
branches:  trunk
changeset: 480474:9b894d2c84b6
user:      itojun <itojun%NetBSD.org@localhost>
date:      Thu Jan 13 17:14:56 2000 +0000

description:
improve message when IPv4 address is not assigned to interface
(and netmask-related directives can misbehave).

the change is in kame and tcpdump.org repository as well.

diffstat:

 lib/libpcap/inet.c |  14 ++++++++++----
 1 files changed, 10 insertions(+), 4 deletions(-)

diffs (35 lines):

diff -r 5e67a3f45f1b -r 9b894d2c84b6 lib/libpcap/inet.c
--- a/lib/libpcap/inet.c        Thu Jan 13 16:22:10 2000 +0000
+++ b/lib/libpcap/inet.c        Thu Jan 13 17:14:56 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: inet.c,v 1.6 1997/10/03 15:53:08 christos Exp $        */
+/*     $NetBSD: inet.c,v 1.7 2000/01/13 17:14:56 itojun Exp $  */
 
 /*
  * Copyright (c) 1994, 1995, 1996, 1997
@@ -39,7 +39,7 @@
 static const char rcsid[] =
     "@(#) Header: inet.c,v 1.21 97/07/17 14:24:58 leres Exp  (LBL)";
 #else
-__RCSID("$NetBSD: inet.c,v 1.6 1997/10/03 15:53:08 christos Exp $");
+__RCSID("$NetBSD: inet.c,v 1.7 2000/01/13 17:14:56 itojun Exp $");
 #endif
 #endif
 
@@ -197,8 +197,14 @@
 #endif
        (void)strncpy(ifr.ifr_name, device, sizeof(ifr.ifr_name));
        if (ioctl(fd, SIOCGIFADDR, (char *)&ifr) < 0) {
-               (void)snprintf(errbuf, PCAP_ERRBUF_SIZE, "SIOCGIFADDR: %s: %s",
-                   device, pcap_strerror(errno));
+               if (errno == EADDRNOTAVAIL) {
+                       (void)snprintf(errbuf, PCAP_ERRBUF_SIZE,
+                           "%s: no IPv4 address assigned", device);
+               } else {
+                       (void)snprintf(errbuf, PCAP_ERRBUF_SIZE,
+                           "SIOCGIFADDR: %s: %s",
+                           device, pcap_strerror(errno));
+               }
                (void)close(fd);
                return (-1);
        }



Home | Main Index | Thread Index | Old Index