I have Google'd this a bunch, but I have no idea what the user
parameter is for pcap_loop()
. The best one I found online is from Stanford (link: http://yuba.stanford.edu/~casado/pcap/section3.html):
/* allright here we call pcap_loop(..) and pass in our callback function */
/* int pcap_loop(pcap_t *p, int cnt, pcap_handler callback, u_char *user)*/
/* If you are wondering what the user argument is all about, so am I!! */
pcap_loop(descr,atoi(argv[1]),my_callback,NULL);
The manpage only mentions the user
parameter once (outside the actual parameters in the functions):
...three arguments: a u_char pointer which is passed in the user argument to pcap_loop() or pcap_dispatch()...
I find that very unhelpful.
I can pass any string in the invocation of pcap_loop
and successfully print it out in the callback handler. Is this just meant to be a way the caller can pass a random string to the handler?
Does anyone know what this parameter is supposed to be used for?