Many thanks for all responses to my question. I still don’t particularly know
what I need to do with thish, though.
Xiaodan Tang wrote:
What exactly is the application you trying to port use?
To send/receive a ethernet packet is easy, to make that
fit into “socket like API” might be harder.
Well, I need to use a standard ethernet card to get data onto the network in the
format:
U8 destAddr[6];
U8 destAddr[6];
U16 ether_type;
U8 userData[X];
U8 userDataByte;
U8 CPI;
U16 length;
U32 CRC;
If there is an easy way to do this without using sockets, I would be happy to do it
that way. I suspect this requires writing an io-net conversion module. I have the
DDK for this, but I have no idea how easy/difficult it would be.
We wrote a Linux driver for our network card and we used sockets send raw ethernet
data to our network card. We cannot use TCP/IP or any other protocol, as the other
devices on the network are our own devices that do not support these protocols.
Now, we are trying to port our application to a POSIX compatible OS and QNX seems
to be our best bet, so we writing lots of little programs to make sure it will
work. Some of the sockets packet functionality that we have been using does not
seem to be supported in QNX, though. Here are the calls we use to send data to the
network card:
/* First we opened the socket. */
soc = socket (PF_PACKET, SOCK_RAW, htons (ETH_P_TELAN));
/* Then we used ioctl to find our network card */
strcpy (ifInfo.ifr_name, “eth0”);
ioctl (soc, SIOCGIFINDEX, &ifInfo);
ioctl (soc, SIOCGIFHWADDR, &ifInfo);
/* Then we the data through the socket using a destination in the format of
sockaddr_ll */
struct sockaddr_ll destAddr;
/* Create a destination structure for sending through the socket. */
destAddr.sll_family = AF_PACKET;
destAddr.sll_protocol = htons(ETH_P_TELAN);
destAddr.sll_ifindex = ifInfo.ifr_ifindex;
destAddr.sll_hatype = ARPHRD_ETHER;
destAddr.sll_pkttype = PACKET_OUTGOING;
destAddr.sll_halen = 6;
memcpy (destAddr.sll_addr, ðHeader.h_dest[0], 6);
sendto (soc, cell, cellSize, 0, (sockaddr*)&destAddr, sizeof (destAddr);
It seems to me that PF_PACKET is a newer protocol family, or domain which QNX
doesn’t support. I believe it is a replacement for the older PF_INET/SOCK_RAW
combination, but I’m not sure.
I’m also not sure if using PF_INET/SOCK_RAW will add any TCP/IP header
information to the packet before it gets sent over the network.
I’m also not sure what the difference between SOCK_RAW and SOCK_SEQPACKET is
and if we should be using SOCK_SEQPACKET.
Also, the PF_PACKET uses a sockaddr_ll structure to locate the NIC in the
sendto function; however, I don’t know which structure I should be using now that
sockaddr_ll is no longer available.
I’m pretty sure that some of the ioctl functions seem to be significantly
different as well, but there seems to be sufficient documentation on that, so I may
be able to figure that part out myself. All the QNX documentation for sockets
seems to deal with strictly TCP/IP and nothing more.
Now back to your orignal problem, to send raw ethernet packet,
bpf is not the way to go.
Thanks, I didn’t think it was quite what I was looking for, but it did give me
a better understanding of the PF_INET/SOCK_RAW to PF_PACKET conversion, as the
libpcap source code supports both.
Your best bet is get the DDK and learn to write you own filter
module to load into io-net. You can also download the ipfilter-src
package, and check out the ipf_npi.[ch] as an reference.
Yeah, I was afraid I might have to do that, but I thought I’d investigate the
PF_INET/SOCK_RAW capabilites before I investigated that too much.
Again, thanks for the replies,
Adam.
adamt@tri-linktech.com
Tel: (604)451-9113 Ext. 208
Fax: (604)451-9118
http://www.tri-linktech.com
Xiaodan Tang wrote:
Guess I have to jump in here >
Yes, Igor is right, BPF stands for berkeley packet filter.
nfm-bpf.so is intended to support tcpdump, so not ALL bpf
ioctls are implemented. This is the list of “not supported”
BPF cmds.
BIOCSRTIMEOUT:
BIOCGRTIMEOUT:
BIOCIMMEDIATE:
BIOCGHDRCMPLT:
BIOCSHDRCMPLT:
FIOASYNC:
TIOCSPGRP:
TIOCGPGRP:
BIOCGDLT, BIOCVERSION is supported, the device you want to
“devctl()” is “/dev/socket/bpf”.
Now back to your orignal problem, to send raw ethernet packet,
bpf is not the way to go.
Your best bet is get the DDK and learn to write you own filter
module to load into io-net. You can also download the ipfilter-src
package, and check out the ipf_npi.[ch] as an reference.
What exactly is the application you trying to port use?
To send/receive a ethernet packet is easy, to make that
fit into “socket like API” might be harder.
-xtang
Igor Kovalenko <> Igor.Kovalenko@motorola.com> > wrote:
I think ‘bpf’ in the name stands for ‘berkeley packet filter’.
Jiri Kristek wrote:
Chris McKillop <> cdm@qnx.com> > pí¹e v diskusním
pøíspìvku:9dp08c$4ld$> 1@nntp.qnx.com> …
Jiri Kristek <> jkristek@retia.cz> > wrote:
There is no “tcpdump” located on > www.qnxstart.com> . I found it on
http://staff.qnx.com/~cdm/repository
Package consists of “tcpdump” and “nfm-bpf.so” library but with no
interface
description.
Can we have “nfm-bpf.so” library interface description?
Yeah, sorry about that. I thought for sure it was on qnxstart. >
If you look online you should be able to find a lot of references.
Also take a look at the sources to tcpdump (found online). A quick
search on google.com got me this hit…
http://www.gsp.com/cgi-bin/man.cgi?section=4&topic=bpf
chris
What type of interface “nfm-bpf.so” provides. Is it raw packet access or is
it BSD Packet Filter Support? Allong to the name of the device nfm-bpf.so
creates ("/dev/io-net/en_en0") I would guest it is raw packet interface.
I tested ioctl commands ( BIOCGDLT, BIOCVERSION, …) from bpf description,
but they are unsupported. So were can we find “nfm-bpf.so” library interface
description?
Jiri
–
cdm@qnx.com > “The faster I go, the behinder I get.”
Chris McKillop – Lewis Carroll –
Software Engineer, QSSL