tcpdump mailing list archives

Problem with pcap_set_datalink DLT_IEEE802_11_RADIO


From: Elton Lika <tonlika () live com>
Date: Wed, 11 Sep 2013 09:56:39 +0200

I am using libpcap-dev 0.9.8 in Ubuntu 12.04 on my laptop.

Setting my wlan0 interface to monitor mode using iwconfig and tcpdump -i
wlan0 -y IEEE802_11_RADIO

works fine but when doing it in C it fails with an DLT not supported by
device error.

 

Here is the source code excerpt that fails:

 

            /* Set device in monitor mode */

            if(pcap_can_set_rfmon(handle)) {

                        if(pcap_set_rfmon(handle, 1) ==
PCAP_ERROR_ACTIVATED) {

 

                                   printf("Failed to activate monitor
mode\n");

                                   exit(EXIT_FAILURE);

                        }

            }else{

                        printf("Cannot set monitor mode\n");

                        exit(EXIT_FAILURE);

            }

            

            /* Set additional settings for pcap */

            pcap_set_snaplen(handle, 2048);

            pcap_set_promisc(handle, 1);

            pcap_set_timeout(handle, 100);

            pcap_activate(handle);

            

            /* Set datalink type */

            if(pcap_set_datalink(handle, DLT_IEEE802_11_RADIO) == -1) {   //
returns -1 on device that supports this DLT

                        printf("Couldn't set datalink type %s: %s\n",
device, pcap_geterr(handle));

            }

 

What could be the problem?

 

Thanks in advance.

Elton Lika

_______________________________________________
tcpdump-workers mailing list
tcpdump-workers () lists tcpdump org
https://lists.sandelman.ca/mailman/listinfo/tcpdump-workers


Current thread: