2012-10-19 2 views
1

연구용으로 Mac에서 모니터 모드로 패킷을 캡처하려고합니다. 이러한 패킷에서 나는 특별한 정보가 필요하다. rssi. 불행히도, linktype DLT_IEEE802_11_RADIO 말합니다,하지만 실제로 DLT_PRISM_HEADER 기대, 모니터 모드를 켜야하기 때문에. 이것은 radiotap 헤더가 RSSI 값이나 내가 필요한 다른 것들을 제공하지 않기 때문에 문제가된다.mac osx prism header pcap

int main(int argc, char *argv[]) 
{ 
pcap_t *handle; /* Session handle */ 
char *dev; /* The device to sniff on */ 
char errbuf[PCAP_ERRBUF_SIZE]; /* Error string */ 
struct pcap_pkthdr header; /* The header that pcap gives us */ 
const u_char *packet; /* The actual packet */ 
struct ether_header *ether; /* net/ethernet.h */ 

/* Define the device */ 
dev = pcap_lookupdev(errbuf); 
if(dev == NULL) { 
    printf("Couldn't find default device: %s\n", errbuf); 
    exit(EXIT_FAILURE); 
} 
printf("Device: %s\n", dev); 

//handle = pcap_open_live(dev, 1562, 1, 500, errbuf); 
handle = pcap_create(dev, errbuf); 
if(handle == NULL) { 
    printf("pcap_create failed: %s\n", errbuf); 
    exit(EXIT_FAILURE); 
} 

/* set monitor mode on */ 
if(pcap_set_rfmon(handle, 1) != 0) { 
    printf("monitor mode not available\n"); 
    exit(EXIT_FAILURE); 
} 
pcap_set_snaplen(handle, 2048); // Set the snapshot length to 2048 
pcap_set_promisc(handle, 1); // Turn promiscuous mode on 
pcap_set_timeout(handle, 512); // Set the timeout to 512 milliseconds 

int status = pcap_activate(handle); 
if(status != 0) { 
    printf("activation failed: %d\n", status); 
} 

printf("link-type: %s\n", pcap_datalink_val_to_name(pcap_datalink(handle))); 

int loop = pcap_loop(handle, 1, process_packet, NULL); 
if(loop != 0) { 
    printf("loop terminated before exhaustion: %d\n", loop); 
} 

/* And close the session */ 
pcap_close(handle); 

return(0); 
} 

그래서 아무도 알고 있지, 왜 내가 radiotap하지 프리즘 내가 대신 할 방법을 수신하고 있습니다 : 여기

(나는 등 콜백 방법을두고) 내 코드? 다시 OSX에서 코딩하고 있습니다.

답변

0

이러한 패킷에서 나는 특별한 정보가 필요합니다. rssi. 즉 DLT_PPI가 포함 된 경우, pcap_activate()를 호출 한 후 모니터 모드에서 pcap_list_datalinks()를 사용하고 pcap_set_datalink()와 DLT_PPI 할 수있는 링크 계층 헤더 유형을 설정 - 드라이버 드릴 것입니다하지 않는

그런 다음, 당신은 오히려 radiotap 헤더보다 PPI 헤더를 요청 - 운이 없어. PPI 헤더를 요청할 수 있으면 해당 헤더에서 RSSI 값을 가져올 수 있습니다. the PPI specification을 참조하십시오.

링크 유형에 DLT_IEEE802_11_RADIO이 (가) 있지만 실제로 DLT_PRISM_HEADER가 예상됩니다. 왜냐하면 모니터 모드가 켜져 있어야하기 때문입니다.

임의의 Wi-Fi 장치 및 드라이버가있는 임의의 운영 체제에서 모니터 모드로 프리즘 헤더를 가져올 이유는 없습니다. 라디오 정보를 전혀 얻지 못하면 드라이버 작성자가 제공하는 헤더를 얻게됩니다. 요즘, 드라이버는 radiotap - Linux mac80211 드라이버, 대부분의 * BSD 드라이버 및 OS X 드라이버를 사용하는 경향이 있습니다.

+0

감사합니다. PPI 프레임 형식을 사용하여 도움을 받았습니다. – Cravid