Replace pcap_lookupdev with pcap_findalldevs 60/260260/1 accepted/tizen_6.5_unified accepted/tizen/6.5/unified/20211028.101009 accepted/tizen/unified/20210624.131854 submit/tizen/20210622.224907 submit/tizen_6.5/20211028.162201 tizen_6.5.m2_release
authorhyunuk.tak <hyunuk.tak@samsung.com>
Tue, 22 Jun 2021 22:41:29 +0000 (07:41 +0900)
committerhyunuk.tak <hyunuk.tak@samsung.com>
Tue, 22 Jun 2021 22:42:01 +0000 (07:42 +0900)
'pcap_lookupdev' is deprecated: use 'pcap_findalldevs' and use the first device

Change-Id: I5451f10f9f6db9f5a1106e02fba60b90569519af
Signed-off-by: hyunuk.tak <hyunuk.tak@samsung.com>
plugin/pcap/stcplugin-pcap.c

index be7f2f00108caeeb731038ed995744eb807102bb..65429596b89d2a3bee50d43d01ece0f3408f7446 100644 (file)
@@ -1505,23 +1505,23 @@ int stc_plugin_pcap_deinitialize(void)
 
 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];
@@ -1529,15 +1529,15 @@ int stc_plugin_pcap_lookup_net(void)
        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;