Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 334
  • Last Modified:

PF_PACKET and Orinoco driver

Hi, I am currently writing a program to send Raw packet( 802.3 compliance) using PF_PACKET with SOCK_RAW option. However, in using sendto() function, some strange thing happened. If I declare my data as
char message[60]
and contruct my message as a 802.3 frame

then I call: sendto(packet_socket, message, sizeof(message), 0, (struct sockaddr *) &recv_addr, tolen)

the sendto function return normal, send out 60 bytes, however. if I check: /proc/net/dev, I have the number of packet that I have transmitted (in this case 1) at transmit/errs column. 0 at transmit/packet column

If then I declare: char *message
contruct my message
and call: sendto(packet_socket, message, sizeof(message), 0, (struct sockaddr *) &recv_addr, tolen)

the sendto function also return sucessful transmit, and /proc/net/dev then return 1 packet is transmit and no errs. However I receiver sde, I received 0 length message

Any ideas why? I am using kernel version: 2.4.18-14 and trying to send and receive data through Orinoco card (with Orinoco driver build in)

Thank you for your time


1 Solution
For you second configuration (using char *), you mentioned that at the receiver side, you received "0 length" message. Where did you get that? Did you use Ethereal or IPTraf to double check that?

I have done something very similar to your case. I've tried using char[] and char*, and i successfully sent the packet out (sendto() return the packet size). I am not sure if those are "transmit/errs" or "transmit/packet" (this is the first time i came across them), but at least at the receiver side, my Ethereal and IPTraf had verified that they had received such packets.

Maybe the error is from your IP header's checksum field. Did you fill in the correct checksum value for that particular packet?? Maybe that's where the problem came from.

pinegrassAuthor Commented:
Hi, I have sucessful send out the packet by just changing the SOCK_RAW option to SOCK_DGRAM option. I don't know how it works but simply working correctly after changing the field ;)

Anyway, thanks for your answer
This old question needs to be finalized -- accept an answer, split points, or get a refund.  For information on your options, please click here-> http:/help/closing.jsp#1 
Post your closing recommendations!  No comment means you don't care.
PAQed with points refunded (80)

Community Support Moderator

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now