Hi all,
Edit for brevity:
My current code:
Code:
for( x = 0; x < 5; x++ ) {
libnet_write( context ); // sends ARP who-has
// The following line blocks until a packet is captured, then passes it to
// pcap_callback_fct, which dissembles and puts the source MAC in
// temp_mac, a global char*
pcap_dispatch( pkt_descriptor, 0, ( void * )pcap_callback_fct, NULL );
memcpy( target_mac[ x ], temp_mac, MAX_SIZE_ETHADDR );
}
This will not work, as Linux does not implement the read timeout in pcap_open_live(), so if I am sending packets to a non-replying address, pcap_dispatch blocks indefinitely. I need to:
1. Fork a child that will execute pcap_dispatch and return when a packet is captured
2. Have the parent wait for pehaps a second for the child to return and if it does not, then kill it
3. Implement temp_mac as shared memory so that when the child's pcap_dispatch call in turn calls pcap_callback_fct, that last will be able to write to memory space that the parent can read.
There, I think I have removed excess varbiage. TIA!