OpenQNX :: The QNX Community Portal

Jul 19, 2008 - 03:30 PM
Google
  Web openqnx.com   
     Create an account Home · Submit News · QNX Forums · QNX Download · Search   
_
Main Menu
Who's Online
There are 37 unlogged users and 1 registered user online.

You can log-in or register for a user account here.

Post new topic   Reply to topic
View previous topic Printable version Log in to check your private messages View next topic
Author Message
gauravgarg
Post subject: Libpcap (PCAP) porting - pcap_sendpacket or pcap_open_live()  PostPosted: Feb 19, 2008 - 05:48 PM
New Member


Joined: Feb 19, 2008
Posts: 4

Dear All,

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?

Thanks a lot in advance!
Kind Regards,
Gaurav
 
 View user's profile Send private message  
Reply with quote Back to top
Tim
Post subject:   PostPosted: Feb 19, 2008 - 06:10 PM
Senior Member


Joined: Mar 10, 2004
Posts: 541

Guarav,

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.

Tim
 
 View user's profile Send private message Visit poster's website  
Reply with quote Back to top
gauravgarg
Post subject:   PostPosted: Feb 20, 2008 - 07:47 AM
New Member


Joined: Feb 19, 2008
Posts: 4

Hi Tim,
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().

Thanks a lot !!
Gaurav





Thanks again!
Gaurav
 
 View user's profile Send private message  
Reply with quote Back to top
Tim
Post subject:   PostPosted: Feb 20, 2008 - 06:12 PM
Senior Member


Joined: Mar 10, 2004
Posts: 541

Gaurav,

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?

Tim
 
 View user's profile Send private message Visit poster's website  
Reply with quote Back to top
gauravgarg
Post subject:   PostPosted: Feb 21, 2008 - 08:33 AM
New Member


Joined: Feb 19, 2008
Posts: 4

Hi Tim,

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!!!

Thanks again Tim!
Gaurav
 
 View user's profile Send private message  
Reply with quote Back to top
AG
Post subject:   PostPosted: Feb 21, 2008 - 02:26 PM
Active Member


Joined: Oct 21, 2003
Posts: 49

Hi Tim,

as alternative to pcap-approach you may think about implementation of own protocol module for io-net (or io-pkt).

--
AG
 
 View user's profile Send private message Visit poster's website ICQ Number 
Reply with quote Back to top
rgallen
Post subject:   PostPosted: Feb 21, 2008 - 07:44 PM
QNX Master


Joined: Jul 11, 2002
Posts: 600

AG wrote:
Hi Tim,

as alternative to pcap-approach you may think about implementation of own protocol module for io-net (or io-pkt).

--
AG


I recommend io-pkt, as this is the new architecture going forward.
 
 View user's profile Send private message Visit poster's website  
Reply with quote Back to top
rgallen
Post subject:   PostPosted: Feb 21, 2008 - 07:47 PM
QNX Master


Joined: Jul 11, 2002
Posts: 600

gauravgarg wrote:
Hi Tim,

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!!!

Thanks again Tim!
Gaurav


Hi Gaurav,

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).

The source for the stack is available on Foundry27 (community.qnx.com).
 
 View user's profile Send private message Visit poster's website  
Reply with quote Back to top
gauravgarg
Post subject:   PostPosted: Feb 22, 2008 - 11:18 AM
New Member


Joined: Feb 19, 2008
Posts: 4

Hi AG, rgallen,
Thanks a lot for your replies!
I would try to implement the io-pkt module to plug into the stack.
 
 View user's profile Send private message  
Reply with quote Back to top
xtang
Post subject:   PostPosted: Feb 25, 2008 - 04:02 PM
QNX Master


Joined: Jul 18, 2002
Posts: 291

If you choose to use io-pkt, then BPF interface is supported, the standard libpcap/tcpdump should "just work". (configure libpcap using BPF interface if you have to).
 
 View user's profile Send private message Visit poster's website  
Reply with quote Back to top
Display posts from previous:     
Jump to:  
All times are GMT
Post new topic   Reply to topic
View previous topic Printable version Log in to check your private messages View next topic
Powered by PNphpBB2 © 2003-2007 The PNphpBB Group
Credits
All logos and trademarks in this site are property of their respective owners. The comments are property of their posters.
Powered by OpenQNX: The QNX Community Portal Site
QNX and the QNX logo are registered trademarks of QNX Software Systems.