Find the answer to your Linux question:
Page 2 of 2 FirstFirst 1 2
Results 11 to 12 of 12
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #11
    Linux User cyberinstru's Avatar
    Join Date
    Jan 2007

    Any way I was thinking of using the write() call to inject manually created packets to the ethernet device.
    The problem I am now facing is how to get the ethernet device descriptor?? Will this work??
    Well... to inject the packet manually, you generally do this:

    1. Create a RAW socket of proto ETH_P_ALL - opening the device
    2. Copy the device name (eth0, etc) to struct ifreq (ifr_name filled with device name)
    3. Use ioctl call to get inteface index

    ioctl (socketDesc, SIOCGIFINDEX, &(member of struct ifreq));
    4. Populate link layer details to struct sockaddr_ll (family and sll_ifindex)

    5. Get HW address for the device - again using ioctl - SIOCGIFHWADDR

    6. Send the packet with appropriate link layer protocol - here sll_protocol = Ether_type

    7. Close socket - or closing the device
    Registered Linux User #440311

  2. #12
    Hi...thankyou for the advice ...but I am a newbie to linux programming and it would be very difficult for me to write code for what u have told. Can u please assist me to write the code??

    And what about the write() call...can we use it to inject the packet manually...if to get the ethernet device descriptor which is an argument to write().

    Thank u sooo much!

Posting Permissions

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