Skip navigation.
Home
The QNX Community Portal

View topic - BPF Devices

BPF Devices

QNX Application portings.

BPF Devices

Postby nagarjunab » Wed Aug 17, 2011 12:44 pm

Hi,

I am using QNX 6.3.2. In /dev/socket/ there is one bpf device with name bpf.
I did a sample program to open bpf device and attached with en0. It is successful. Now I need to get data from multiple interfaces ,say en0,en1 ...and so. Can I attache the same bpf to multiple interfaces??
For example:
if ( 0 > ( fd = open( "/dev/bpf0", O_RDWR ) ) )
err( 1, "open" );

Attaching to "en0", bound_if has "en0"
if( ioctl( fd, BIOCSETIF, &bound_if ) > 0 )

Now can I attach same 'fd' to en1?? If I can,do it gets detach from en0?
Please provide me some idea.Thanks in advance.
nagarjunab
New Member
 
Posts: 3
Joined: Tue Aug 16, 2011 8:32 am

Re: BPF Devices

Postby maschoen » Thu Aug 18, 2011 7:17 am

You may know more about this than I do, but I can't tell from your post whether that is true or whether you are lost.

I would never open the /dev/bpf device and attach it they way you have.
Instead I would configure en0 with ifconfig.
As far as "receiving data from multiple interfaces", I would use the socket interface to create a server program that can receive connections on any interface. The connections can then be either TCP or UDP depending on your needs.
maschoen
QNX Master
 
Posts: 2640
Joined: Wed Jun 25, 2003 5:18 pm

Re: BPF Devices

Postby nagarjunab » Thu Aug 18, 2011 8:50 am

Hi maschoen,
Thanks for your reply.
Actual motive behind using BPF is to receive all kinds of packets,not only TCP/IP. We need to receive raw ethernet packets on my interface. For this the only way to achive in QNX 6.3.2 is to use BPF. That is the reason I am opening a bpf device and attaching to interface.
So could you please let me know,whether I can attach a file descriptor to multiple interfaces?
nagarjunab
New Member
 
Posts: 3
Joined: Tue Aug 16, 2011 8:32 am

Re: BPF Devices

Postby maschoen » Fri Aug 19, 2011 5:22 am

Well I understand that you want to get all packets, raw and otherwise.

I'm not that familiar with the QNX 6 raw packet interface. But something doesn't sound right about what you are doing. As I understand it io-pkt(-v4) is the process that you are getting information from. Various types of drivers can attach to this process at various points in the stack, on the top or bottom. NIC drivers are at one end, filters and protocols in the middle.

What doesn't sound right is that you are attaching to an "interface". My understanding of an interface is that it is the IP protocol's virtualized notion of a hardware NIC. So you configure an interface with an IP address. On a Unix system this might be the way to do things, but in QNX I would suspect you want to create a component that sits on the stack above the NIC drivers and watch the packets go by.
maschoen
QNX Master
 
Posts: 2640
Joined: Wed Jun 25, 2003 5:18 pm

Re: BPF Devices

Postby denkelly » Tue Aug 30, 2011 2:32 pm

>>>Now I need to get data from multiple interfaces ,say en0,en1 ...and so. Can I attache the same bpf to multiple interfaces??

Not sure about 6.3.2 (io-net) but with io-pkt-v4... here is some working code to transmit and receive a frame with arbitrary id between locally connected macs. See readme.txt.
Attachments
bpf1.zip
(23.78 KiB) Downloaded 269 times
denkelly
Senior Member
 
Posts: 160
Joined: Sat Aug 02, 2008 3:27 pm


Return to Porting

Who is online

Users browsing this forum: No registered users and 2 guests