I am currently performing porting of Libpcap from windows to QNX. I am unable to port the pcap_sendpacket function. A linux ported version of the function exists, i.e. if I use libpcap 0.9.1 or later, pcap_sendpacket() is in pcap.c. It, and pcap_inject(), both just call the function pointed to by the
inject_op member of the pcap_t structure.That pointer is set, in pcap_open_live(), to point to the appropriate function.
However, I am unable to port the pcap_open_live function to QNX. The linux version calls N number of functions and I tried porting all of them, but did not succeed.
Has somebody tried out some function to send packets using pcap_sendpacket or pcap_inject on QNX?
There is an existing libpcap library available in the 3rd party package. I just took a look at it and unfortunately it only seems to support reading packets, not injecting or sending them. But at the least it may save you the port on the reading side if you have trouble with that.
Looking at that port might give you some idea’s though.
The package you want is the tcpdump development package.
Thanks a lot for your quick reply!
Are you referring to libpcap-0.9.8 from tcpdump.org? If not, It would be great if you could some detailed pointers on how I could donwload the libpcap available in the 3rd party package. I have a version of ported code with me where I can read packets actually.
Regarding sending the packets, could you please tell whether this thought process seems fine to you. The pcap_sendpacket function uses inject_op member of the pcap_t structure.That pointer is set, in pcap_open_live(), to point to the appropriate function. Hence, if I modify all the code which is written in pcap_open_live() function in say, pcap-linux.c, and make it QNX compatible and also point the inject_op member to pcap_sendpacket function, then I would be able to use pcap_sendpacket function to send packets.
Does it sound logical or do I need to take care of a number of other things? To do this, I would need to port a number of function called within pcap_open_live().
I just checked and the ported version I was talking about is an earlier one from tcpdump.org than 0.9.8 so it may not be useful to you if you need the latest.
If you start the Installer under Photon, and go to the QNX 3rd Party repository, you will find a ported tcpdump and tcpdump development package.
I have both installed on my machine and frequently use tcpdump to aid with network debugging.
As far as injecting packets, I’ve never done that with the pcap library under QNX. I did it under VxWorks several years ago and it was a pain because I had to play with the MUX level in order to inject packets. I don’t think you need to do that under QNX but I can’t be sure since I’ve never done it.
I do have a question tho. Why do you need to inject packets with pcap? What are you trying to accomplish that a normal application couldn’t do?
Thanks again for your reply!
Actually, I had a complete HSDPA protocol stack running on windows, which I needed to port to QNX as our system runs on QNX. As part of core network porting, I was required to port a core network element ( called GGSN) which is used to send and receive packets ( from network and then to Layer 2/3).
The code used windows version of PCAP, and hence I was trying to port it.
Do you think that I could instead use some other way to send packet and remove the PCAP functionality totally?
Any pointers on this would be very helpful!!!
The most efficient approach is to write your own io-pkt module to plug into the stack. This is actually very simple to do, once you understand the architecture (someone who knows what they’re doing can do it in less than an hour).