--- embedaddon/arping/src/findif_getifaddrs.c 2014/06/15 16:26:43 1.1.1.1 +++ embedaddon/arping/src/findif_getifaddrs.c 2016/10/18 13:16:10 1.1.1.2 @@ -1,16 +1,16 @@ /* arping/src/findif_getifaddrs.c * - * Copyright (C) 2000-2011 Thomas Habets + * Copyright (C) 2000-2014 Thomas Habets * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. * - * This library is distributed in the hope that it will be useful, + * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., @@ -33,6 +33,10 @@ #include #include +#if HAVE_LIBNET_H +#include +#endif + #include "arping.h" const char * @@ -52,10 +56,14 @@ arping_lookupdev(uint32_t srcip, /* Results */ static char ifname[IFNAMSIZ]; + *ebuf = 0; + if (getifaddrs(&ifa)) { if (verbose) { - printf("getifaddrs(): %s\n", strerror(errno)); + printf("arping: getifaddrs(): %s\n", strerror(errno)); } + snprintf(ebuf, LIBNET_ERRBUF_SIZE, + "getifaddrs(): %s", strerror(errno)); goto out; } for (cur = ifa; cur; cur = cur->ifa_next) { @@ -91,12 +99,15 @@ arping_lookupdev(uint32_t srcip, if (match_count) { ret = ifname; if (verbose) { - printf("Autodetected interface %s\n", ret); + printf("arping: Autodetected interface %s\n", ret); } } else { - if (verbose) { - printf("Failed to find iface using getifaddrs().\n"); + if (verbose > 1) { + printf("arping: Failed to find iface using" + " getifaddrs().\n"); } + snprintf(ebuf, LIBNET_ERRBUF_SIZE, + "No matching interface found using getifaddrs()."); } out: if (ifa) {