View topic - Raw sockets QNX 6.4.1

Page 1 of 1

Raw sockets QNX 6.4.1

PostPosted: Mon May 10, 2010 10:25 am
by psns
Hi for all!
I'm making an assessment about the temporal behavior of the standard Protocol Stacks of different operating systems and I'm trying to send Ethernet Raw packets in the QNX Netrino OS. I want send only the most basic packet:
destination MAC (6 bytes) + source MAC (6 bytes) + Ethernet Type (2 bytes) + Payload (46 to 1500 bytes).

In other versions of Linux (eg Ubuntu) I use:

Code: Select all
SocketFD = socket(AF_PACKET,SOCK_RAW,htons(ETH_P_ALL));


and I pass the sockaddr_ll struct to the sendto syscall. But on QNX I don't know what domain and protocol I have to use on socket syscall neither what is the struct that I have to pass to the sendto syscall.

Can you help me with this please?
Thanks in advance!
Pedro Silva

PostPosted: Mon May 10, 2010 12:32 pm
by seanb
Check out BPF / libpcap. They're the 'BSD' way to
implement AF_PACKET.

-seanb

PostPosted: Tue May 11, 2010 4:31 pm
by psns
Where I can find this information?
I checked the http://canmore.annwfn.net/howtos/bpf/ webpage, which is very good, but I still had very problems because I'm not comfortable with the BPF interface.

When I try to change the length of the buffer to where the read call will store my packet (e.g. 1500 bytes), with the

if ( ioctl(buf, BIOCSBLEN, 1500) == -1) {
perror("BIOCSBLEN");
}


I get a error "BIOCSBLEN: Bad Address".

I really need help to handle with this...
Thanks in advance for all!

PostPosted: Wed May 19, 2010 10:20 am
by psns
Any help?

PostPosted: Wed May 19, 2010 10:31 am
by psns
I solved the BIOCSBLEN question...

int bufsize = PACKET_SIZE;
if ( ioctl(buf, BIOCSBLEN, &bufsize ) == -1) {
perror("BIOCSBLEN");
}