Find the answer to your Linux question:
Results 1 to 2 of 2
hi i am new to linux socket programming and was studying about raw sockets. i was able to read icmp packets through packet sockets=socket(PF_PACKET,SOCK_RAW,htons(ETH_P_ALL) ); The recvfrom functions returns bytes ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Jun 2007
    Location
    India
    Posts
    4

    Question writing to raw sockets


    hi i am new to linux socket programming and was studying about raw sockets.
    i was able to read icmp packets through packet sockets=socket(PF_PACKET,SOCK_RAW,htons(ETH_P_ALL) );

    The recvfrom functions returns bytes read as 98.
    The total lenght field in ip header is 84.
    Now i copy the same read packet , interchange the source and destination mac addresses as well as the source and destination ip addresses and send it using struct sockaddr_ll with sll_ifindex field set to 2(eth0 index on my comp).
    but i am not able to send any packets.
    its showing error=EINVAL.

    i went throught the man pages and found that i need to add the physical layer headers myself. so i did first 7 bytes containg 0xaa and 8th byte as 0xab for standard 802.3 frames but i am still not able to send packets.

    i will be grateful for any of yours help.
    Thank you in advance.

  2. #2
    Just Joined!
    Join Date
    Jun 2007
    Location
    India
    Posts
    4

    any idea?

    maybe this is not the right place to post a programming query .
    can anybody plz tell me a place where i can find help.
    thanks in advance.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •