int stc_plugin_pcap_lookup_dev(void)
{
- char *dev = NULL;
+ pcap_if_t *alldevs = NULL;
char errbuf[PCAP_ERRBUF_SIZE];
- dev = pcap_lookupdev(errbuf);
- if (dev == NULL) {
- STC_LOGE("Failed to look up dev [%s]", errbuf);
+ if (pcap_findalldevs(&alldevs, errbuf) < 0 ||
+ alldevs == NULL) {
+ STC_LOGE("Failed to find all devs [%s]", errbuf);
return STC_ERROR_FAIL;
}
- STC_LOGD("Dev [%s]", dev);
+ STC_LOGD("Dev [%s]", alldevs->name);
return STC_ERROR_NONE;
}
int stc_plugin_pcap_lookup_net(void)
{
- char *dev = NULL;
+ pcap_if_t *alldevs = NULL;
char net[BUFF_SIZE_IP];
char mask[BUFF_SIZE_IP];
char errbuf[PCAP_ERRBUF_SIZE];
bpf_u_int32 netp;
bpf_u_int32 maskp;
- dev = pcap_lookupdev(errbuf);
- if (dev == NULL) {
- STC_LOGE("Failed to look up dev [%s]", errbuf);
+ if (pcap_findalldevs(&alldevs, errbuf) < 0 ||
+ alldevs == NULL) {
+ STC_LOGE("Failed to find all devs [%s]", errbuf);
return STC_ERROR_FAIL;
}
- STC_LOGD("Dev [%s]", dev);
+ STC_LOGD("Dev [%s]", alldevs->name);
- ret = pcap_lookupnet(dev, &netp, &maskp, errbuf);
+ ret = pcap_lookupnet(alldevs->name, &netp, &maskp, errbuf);
if (ret == -1) {
STC_LOGE("Failed to look up net [%s]", errbuf);
return STC_ERROR_FAIL;