Skip to content

Commit

Permalink
PCAP_IF_LOOPBACK flag in pcap_if_t struct will be set for "Npcap Loop…
Browse files Browse the repository at this point in the history
…back Adapter" now, only for DLT_NULL mode.
  • Loading branch information
hsluoyz committed Dec 29, 2015
1 parent 156f199 commit 9d43e8f
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions wpcap/libpcap/inet.c
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ add_or_find_if(pcap_if_t **curdev_ret, pcap_if_t **alldevs, const char *name,
pcap_t *p;
pcap_if_t *curdev, *prevdev, *nextdev;
int this_instance;
int npcap_loopback = 0;

/*
* Is there already an entry in the list for this interface?
Expand Down Expand Up @@ -205,6 +206,24 @@ add_or_find_if(pcap_if_t **curdev_ret, pcap_if_t **alldevs, const char *name,
*curdev_ret = NULL;
return (0);
}
else {
NetType type;
/*
* Set PCAP_IF_LOOPBACK for "Npcap Loopback Adapter".
*/
if (PacketGetNetType(p->adapter, &type) == FALSE) {
(void)snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
"Cannot determine the network type: %s", pcap_win32strerror());
}
else {
if (type.LinkType == NdisMediumNull) {
npcap_loopback = 1;
}
else {
npcap_loopback = 0;
}
}
}
pcap_close(p);

/*
Expand Down Expand Up @@ -251,6 +270,8 @@ add_or_find_if(pcap_if_t **curdev_ret, pcap_if_t **alldevs, const char *name,
curdev->flags = 0;
if (ISLOOPBACK(name, flags))
curdev->flags |= PCAP_IF_LOOPBACK;
if (npcap_loopback)
curdev->flags |= PCAP_IF_LOOPBACK;

/*
* Add it to the list, in the appropriate location.
Expand Down

0 comments on commit 9d43e8f

Please sign in to comment.