Raw Sockets

I have a need to receive packets that are not ether type IP or ARP. I don’t need to send them, but I do need to receive them. Is there any way to accomplish this? I don’t care if I have to use an API other than the sockets api. Right now I’m using the NS7520 development board. Thanks! Kevin

In Net+OS 6.0 raw sockets are possible. Just use SOCK_RAW as type of socket. Unfortunately this is NOT described in the API reference…

With the current releases of Net+Os there is no raw socket api that would allow you to accomplish what you are looking for however this api will be part of Net+Os v6.0. You may want to contact Technical support department to see if they have any other solution as an add on.

I found a fairly easy way to do it. I hooked into the bsp ethernet code in eth_recv_up() and after a quick look at the packet, I use a message queue to send the message structure to my app code via a message queue if the packet is the type I’m looking for. It is only a little bit hacky this way. :slight_smile:

I’ve tried the SOCK_RAW parameter too, but I doesn’t get any packets. Could anybody take a look on my codesample please?!

Try to enable socket option IP_HDRINCL. This option name is not predefined by Net+OS. #define IP_HDRINCL 2 int on = 1; setsockopt(sock,IPPROTO_IP,IP_HDRINCL,(char *)&on,sizeof(on));

I’m working on a product, which need transfer raw data between ethernet and serial port transparently. Does raw socket can do this function?

i think you rather should use a protocol like udp.