Skip to content

Commit

Permalink
move device check into existing loop
Browse files Browse the repository at this point in the history
  • Loading branch information
krruzic committed Jan 4, 2020
1 parent 1dd4ef6 commit 417d310
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/pcaploop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,23 +128,23 @@ int uv_pcap_init(uv_loop_t *loop, uv_pcap_t *handle, uv_pcap_cb cb, char *netif)

for (d = alldevs; d; d = d->next) {
i++;
if (netif != NULL) {
int netif_index = atoi(netif);
if (i == netif_index) {
netif = strdup(d->name);
}
}
}
if (i == 0) {
fprintf(stderr, "Error pcap_findalldevs 0 item\n");
exit(1);
}
inner->interfaces = new uv_pcap_interf_t[i];
i = 0;
if (netif != NULL) {
int sum = atoi(netif);
for (d = alldevs, i = 0; i < sum - 1; d = d->next, i++);
netif = strdup(d->name);
}
for (d = alldevs; d; d = d->next) {
pcap_t *dev;
int ret;
if (netif != NULL) {
printf("%s\n", netif);
if (!strcmp(d->name, netif)) {
printf("found interface: %s\n", d->name);
// found requested interface
Expand Down

0 comments on commit 417d310

Please sign in to comment.