Results 1 to 1 of 1
Hi,
I have a problem writhing an thin application based on libpcap. I have
this structure in my main() function and got_packet() as callback
function:
Code:
int main(int argc, char ...
- 11-11-2009 #1Just Joined!
- Join Date
- Nov 2009
- Posts
- 1
[libpcap] Passing a structure with the callback function
Hi,
I have a problem writhing an thin application based on libpcap. I have
this structure in my main() function and got_packet() as callback
function:
Do you see how can we edit this code in order to get the structureCode:int main(int argc, char **argv) { /* ... */ typedef struct _configuration Configuration; struct _configuration { int id; char title[255]; }; Configuration conf[2] = { {0, "foo"}, {1, "bar"}}; /* ... */ pcap_loop(handle, num_packets, got_packet, &conf); } void got_packet(u_char *args, const struct pcap_pkthdr *header, const u_char *packet) { /* ... */ printf("test: %d\n", *args[0]->id); }
conf and print it in got_packet()?
Many thanks for any help.


Reply With Quote