fad-gifc.c (214518) | fad-gifc.c (251129) |
---|---|
1/* -*- Mode: c; tab-width: 8; indent-tabs-mode: 1; c-basic-offset: 8; -*- */ 2/* 3 * Copyright (c) 1994, 1995, 1996, 1997, 1998 4 * The Regents of the University of California. All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: --- 119 unchanged lines hidden (view full) --- 128 * The list, as returned through "alldevsp", may be null if no interfaces 129 * were up and could be opened. 130 * 131 * This is the implementation used on platforms that have SIOCGIFCONF but 132 * don't have any other mechanism for getting a list of interfaces. 133 * 134 * XXX - or platforms that have other, better mechanisms but for which 135 * we don't yet have code to use that mechanism; I think there's a better | 1/* -*- Mode: c; tab-width: 8; indent-tabs-mode: 1; c-basic-offset: 8; -*- */ 2/* 3 * Copyright (c) 1994, 1995, 1996, 1997, 1998 4 * The Regents of the University of California. All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: --- 119 unchanged lines hidden (view full) --- 128 * The list, as returned through "alldevsp", may be null if no interfaces 129 * were up and could be opened. 130 * 131 * This is the implementation used on platforms that have SIOCGIFCONF but 132 * don't have any other mechanism for getting a list of interfaces. 133 * 134 * XXX - or platforms that have other, better mechanisms but for which 135 * we don't yet have code to use that mechanism; I think there's a better |
136 * way on Linux, for example. | 136 * way on Linux, for example, but if that better way is "getifaddrs()", 137 * we already have that. |
137 */ 138int | 138 */ 139int |
139pcap_findalldevs(pcap_if_t **alldevsp, char *errbuf) | 140pcap_findalldevs_interfaces(pcap_if_t **alldevsp, char *errbuf) |
140{ 141 pcap_if_t *devlist = NULL; 142 register int fd; 143 register struct ifreq *ifrp, *ifend, *ifnext; 144 int n; 145 struct ifconf ifc; 146 char *buf = NULL; 147 unsigned buf_size; --- 256 unchanged lines hidden (view full) --- 404 errbuf) < 0) { 405 ret = -1; 406 break; 407 } 408 } 409 free(buf); 410 (void)close(fd); 411 | 141{ 142 pcap_if_t *devlist = NULL; 143 register int fd; 144 register struct ifreq *ifrp, *ifend, *ifnext; 145 int n; 146 struct ifconf ifc; 147 char *buf = NULL; 148 unsigned buf_size; --- 256 unchanged lines hidden (view full) --- 405 errbuf) < 0) { 406 ret = -1; 407 break; 408 } 409 } 410 free(buf); 411 (void)close(fd); 412 |
412 if (ret != -1) { 413 /* 414 * We haven't had any errors yet; do any platform-specific 415 * operations to add devices. 416 */ 417 if (pcap_platform_finddevs(&devlist, errbuf) < 0) 418 ret = -1; 419 } 420 | |
421 if (ret == -1) { 422 /* 423 * We had an error; free the list we've been constructing. 424 */ 425 if (devlist != NULL) { 426 pcap_freealldevs(devlist); 427 devlist = NULL; 428 } 429 } 430 431 *alldevsp = devlist; 432 return (ret); 433} | 413 if (ret == -1) { 414 /* 415 * We had an error; free the list we've been constructing. 416 */ 417 if (devlist != NULL) { 418 pcap_freealldevs(devlist); 419 devlist = NULL; 420 } 421 } 422 423 *alldevsp = devlist; 424 return (ret); 425} |