37c37
< "@(#) $Header: /tcpdump/master/libpcap/inet.c,v 1.66.2.1 2005/06/20 21:30:17 guy Exp $ (LBL)";
---
> "@(#) $Header: /tcpdump/master/libpcap/inet.c,v 1.66.2.6 2007/06/11 09:52:04 guy Exp $ (LBL)";
138,159d137
< * Can we open this interface for live capture?
< *
< * We do this check so that interfaces that ae supplied
< * by the interface enumeration mechanism we're using
< * but that don't support packet capture aren't included
< * in the list. An example of this is loopback interfaces
< * on Solaris; we don't just omit loopback interfaces
< * becaue you *can* capture on loopback interfaces on some
< * OSes.
< */
< p = pcap_open_live(name, 68, 0, 0, errbuf);
< if (p == NULL) {
< /*
< * No. Don't bother including it.
< * Don't treat this as an error, though.
< */
< *curdev_ret = NULL;
< return (0);
< }
< pcap_close(p);
<
< /*
165a144
>
168a148,211
> *
> * Can we open this interface for live capture?
> *
> * We do this check so that interfaces that are
> * supplied by the interface enumeration mechanism
> * we're using but that don't support packet capture
> * aren't included in the list. Loopback interfaces
> * on Solaris are an example of this; we don't just
> * omit loopback interfaces on all platforms because
> * you *can* capture on loopback interfaces on some
> * OSes.
> *
> * On OS X, we don't do this check if the device
> * name begins with "wlt"; at least some versions
> * of OS X offer monitor mode capturing by having
> * a separate "monitor mode" device for each wireless
> * adapter, rather than by implementing the ioctls
> * that {Free,Net,Open,DragonFly}BSD provide.
> * Opening that device puts the adapter into monitor
> * mode, which, at least for some adapters, causes
> * them to deassociate from the network with which
> * they're associated.
> *
> * Instead, we try to open the corresponding "en"
> * device (so that we don't end up with, for users
> * without sufficient privilege to open capture
> * devices, a list of adapters that only includes
> * the wlt devices).
> */
> #ifdef __APPLE__
> if (strncmp(name, "wlt", 3) == 0) {
> char *en_name;
> size_t en_name_len;
>
> /*
> * Try to allocate a buffer for the "en"
> * device's name.
> */
> en_name_len = strlen(name) - 1;
> en_name = malloc(en_name_len + 1);
> if (en_name == NULL) {
> (void)snprintf(errbuf, PCAP_ERRBUF_SIZE,
> "malloc: %s", pcap_strerror(errno));
> return (-1);
> }
> strcpy(en_name, "en");
> strcat(en_name, name + 3);
> p = pcap_open_live(en_name, 68, 0, 0, errbuf);
> free(en_name);
> } else
> #endif /* __APPLE */
> p = pcap_open_live(name, 68, 0, 0, errbuf);
> if (p == NULL) {
> /*
> * No. Don't bother including it.
> * Don't treat this as an error, though.
> */
> *curdev_ret = NULL;
> return (0);
> }
> pcap_close(p);
>
> /*
> * Yes, we can open it.
182,183c225,231
< curdev->name = malloc(strlen(name) + 1);
< strcpy(curdev->name, name);
---
> curdev->name = strdup(name);
> if (curdev->name == NULL) {
> (void)snprintf(errbuf, PCAP_ERRBUF_SIZE,
> "malloc: %s", pcap_strerror(errno));
> free(curdev);
> return (-1);
> }
188,189c236,243
< curdev->description = malloc(strlen(description) + 1);
< strcpy(curdev->description, description);
---
> curdev->description = strdup(description);
> if (curdev->description == NULL) {
> (void)snprintf(errbuf, PCAP_ERRBUF_SIZE,
> "malloc: %s", pcap_strerror(errno));
> free(curdev->name);
> free(curdev);
> return (-1);
> }
359a414,415
> if (curaddr->addr != NULL)
> free(curaddr->addr);
370a427,430
> if (curaddr->netmask != NULL)
> free(curaddr->netmask);
> if (curaddr->addr != NULL)
> free(curaddr->addr);
381a442,447
> if (curaddr->broadaddr != NULL)
> free(curaddr->broadaddr);
> if (curaddr->netmask != NULL)
> free(curaddr->netmask);
> if (curaddr->addr != NULL)
> free(curaddr->addr);
530c596
< register struct sockaddr_in *sin;
---
> register struct sockaddr_in *sin4;
574,575c640,641
< sin = (struct sockaddr_in *)&ifr.ifr_addr;
< *netp = sin->sin_addr.s_addr;
---
> sin4 = (struct sockaddr_in *)&ifr.ifr_addr;
> *netp = sin4->sin_addr.s_addr;
583c649
< *maskp = sin->sin_addr.s_addr;
---
> *maskp = sin4->sin_addr.s_addr;
< "@(#) $Header: /tcpdump/master/libpcap/inet.c,v 1.66.2.1 2005/06/20 21:30:17 guy Exp $ (LBL)";
---
> "@(#) $Header: /tcpdump/master/libpcap/inet.c,v 1.66.2.6 2007/06/11 09:52:04 guy Exp $ (LBL)";
138,159d137
< * Can we open this interface for live capture?
< *
< * We do this check so that interfaces that ae supplied
< * by the interface enumeration mechanism we're using
< * but that don't support packet capture aren't included
< * in the list. An example of this is loopback interfaces
< * on Solaris; we don't just omit loopback interfaces
< * becaue you *can* capture on loopback interfaces on some
< * OSes.
< */
< p = pcap_open_live(name, 68, 0, 0, errbuf);
< if (p == NULL) {
< /*
< * No. Don't bother including it.
< * Don't treat this as an error, though.
< */
< *curdev_ret = NULL;
< return (0);
< }
< pcap_close(p);
<
< /*
165a144
>
168a148,211
> *
> * Can we open this interface for live capture?
> *
> * We do this check so that interfaces that are
> * supplied by the interface enumeration mechanism
> * we're using but that don't support packet capture
> * aren't included in the list. Loopback interfaces
> * on Solaris are an example of this; we don't just
> * omit loopback interfaces on all platforms because
> * you *can* capture on loopback interfaces on some
> * OSes.
> *
> * On OS X, we don't do this check if the device
> * name begins with "wlt"; at least some versions
> * of OS X offer monitor mode capturing by having
> * a separate "monitor mode" device for each wireless
> * adapter, rather than by implementing the ioctls
> * that {Free,Net,Open,DragonFly}BSD provide.
> * Opening that device puts the adapter into monitor
> * mode, which, at least for some adapters, causes
> * them to deassociate from the network with which
> * they're associated.
> *
> * Instead, we try to open the corresponding "en"
> * device (so that we don't end up with, for users
> * without sufficient privilege to open capture
> * devices, a list of adapters that only includes
> * the wlt devices).
> */
> #ifdef __APPLE__
> if (strncmp(name, "wlt", 3) == 0) {
> char *en_name;
> size_t en_name_len;
>
> /*
> * Try to allocate a buffer for the "en"
> * device's name.
> */
> en_name_len = strlen(name) - 1;
> en_name = malloc(en_name_len + 1);
> if (en_name == NULL) {
> (void)snprintf(errbuf, PCAP_ERRBUF_SIZE,
> "malloc: %s", pcap_strerror(errno));
> return (-1);
> }
> strcpy(en_name, "en");
> strcat(en_name, name + 3);
> p = pcap_open_live(en_name, 68, 0, 0, errbuf);
> free(en_name);
> } else
> #endif /* __APPLE */
> p = pcap_open_live(name, 68, 0, 0, errbuf);
> if (p == NULL) {
> /*
> * No. Don't bother including it.
> * Don't treat this as an error, though.
> */
> *curdev_ret = NULL;
> return (0);
> }
> pcap_close(p);
>
> /*
> * Yes, we can open it.
182,183c225,231
< curdev->name = malloc(strlen(name) + 1);
< strcpy(curdev->name, name);
---
> curdev->name = strdup(name);
> if (curdev->name == NULL) {
> (void)snprintf(errbuf, PCAP_ERRBUF_SIZE,
> "malloc: %s", pcap_strerror(errno));
> free(curdev);
> return (-1);
> }
188,189c236,243
< curdev->description = malloc(strlen(description) + 1);
< strcpy(curdev->description, description);
---
> curdev->description = strdup(description);
> if (curdev->description == NULL) {
> (void)snprintf(errbuf, PCAP_ERRBUF_SIZE,
> "malloc: %s", pcap_strerror(errno));
> free(curdev->name);
> free(curdev);
> return (-1);
> }
359a414,415
> if (curaddr->addr != NULL)
> free(curaddr->addr);
370a427,430
> if (curaddr->netmask != NULL)
> free(curaddr->netmask);
> if (curaddr->addr != NULL)
> free(curaddr->addr);
381a442,447
> if (curaddr->broadaddr != NULL)
> free(curaddr->broadaddr);
> if (curaddr->netmask != NULL)
> free(curaddr->netmask);
> if (curaddr->addr != NULL)
> free(curaddr->addr);
530c596
< register struct sockaddr_in *sin;
---
> register struct sockaddr_in *sin4;
574,575c640,641
< sin = (struct sockaddr_in *)&ifr.ifr_addr;
< *netp = sin->sin_addr.s_addr;
---
> sin4 = (struct sockaddr_in *)&ifr.ifr_addr;
> *netp = sin4->sin_addr.s_addr;
583c649
< *maskp = sin->sin_addr.s_addr;
---
> *maskp = sin4->sin_addr.s_addr;