Hi
I want to pass my structure to one function.That function only accepts "u_char *" pointer but my structure has another type,my structure has some "int" type.Unfortunately I can not modify that function!
Is there any solution for this problem?
Why don't you use Count_Packet(Packet_Type_counter * args, ...
Or well, you can cast it to void * too.
If you can't get it to compile, make sure your struct is defined before the function, and eventually try something like this:
Thanks again
I can not modify the function,because that is "callback" function and should has specific prototype.for more information, this callback is for "pcap_loop" function from "libpcap" library. [b]Can I pass "void" pointer to "Count_Packet" as "u_char *args" argument ?
[/b]
Thanks in advance
You can pass it pointer, yes.
But you should pass it NOT as a void *, but as a u_char *.
Nothing changes in fact, but you may get a warning/error giving a void *.
Then re-cast it back to a Packet_Type *.
Like this:
@beyonder2015 you will then need to use the -> operator instead of the . op., and i think he isn't so expert about that, just a guess.
@sandeepdas: You are right, but you also can explicitly call the callback in your code.