Sending ARP packets

This is a discussion on Sending ARP packets within the C Programming forums, part of the General Programming Boards category; I want to write a program to send a ARP packet. Is there some method where I can load up ...

  1. #1
    Registered User
    Join Date
    Jan 2009
    Posts
    103

    Sending ARP packets

    I want to write a program to send a ARP packet. Is there some method where I can load up all the hex as an array and then it just sends it off to a specified IP address? How would I do this? Could someone forward me to a good raw sockets tutorial or just show me how to do this (latter prefered, I learn faster with just code)?


    Thanks

  2. #2
    Registered User slingerland3g's Avatar
    Join Date
    Jan 2008
    Location
    Seattle
    Posts
    602
    Something like this maybe:

    Code:
       fd = socket( AF_PACKET, SOCK_RAW, htons(ETH_P_ARP));
    A simple google search on this brought me to some example using ETH_P_ARP

    ARP-Request!!!!1

  3. #3
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,600
    >> I want to write a program to send a ARP packet. Is there some method where I can load up all the hex as an array and then it just sends it off to a specified IP address? How would I do this? Could someone forward me to a good raw sockets tutorial or just show me how to do this (latter prefered, I learn faster with just code)?

    Do your own research, write some code, and ask *specific* questions pertaining to the problems you encounter. Don't just expect others to hand you everything on a silver platter.
    Code:
    if( numeric_limits< byte >::digits != bits_per_byte )
        error( "program requires bits_per_byte-bit bytes" );
    24bbs.cpp

  4. #4
    Registered User
    Join Date
    Jan 2009
    Posts
    103
    Quote Originally Posted by Sebastiani View Post
    >> I want to write a program to send a ARP packet. Is there some method where I can load up all the hex as an array and then it just sends it off to a specified IP address? How would I do this? Could someone forward me to a good raw sockets tutorial or just show me how to do this (latter prefered, I learn faster with just code)?

    Do your own research, write some code, and ask *specific* questions pertaining to the problems you encounter. Don't just expect others to hand you everything on a silver platter.
    Sigh...
    I should have expected this. See, I've been working on this for two days and I have found lots of results and programs but all of them have been written in like the 90's and skip a lot of the includes and their makefiles have errors and gcc pukes upon compiling.

  5. #5
    spurious conceit MK27's Avatar
    Join Date
    Jul 2008
    Location
    segmentation fault
    Posts
    8,300
    Quote Originally Posted by Poincare View Post
    Sigh...
    I should have expected this. See, I've been working on this for two days and I have found lots of results and programs but all of them have been written in like the 90's and skip a lot of the includes and their makefiles have errors and gcc pukes upon compiling.
    You're whining.

    Have you done stuff already using tcp/ip sockets, or is this your first socket based experience? There is definitely much less material about raw sockets around, possibly because if you can already use the tcp/ip stuff, raw sockets should seem simple. But I don't know that for sure...just a suggestion.
    C programming resources:
    GNU C Function and Macro Index -- glibc reference manual
    The C Book -- nice online learner guide
    Current ISO draft standard
    CCAN -- new CPAN like open source library repository
    3 (different) GNU debugger tutorials: #1 -- #2 -- #3
    cpwiki -- our wiki on sourceforge

  6. #6
    Registered User slingerland3g's Avatar
    Join Date
    Jan 2008
    Location
    Seattle
    Posts
    602
    Written back in the '90s? Hmm, most of the Kernel API has not changed much. Also if you are simply trying to compile a simple 'one off' ARP request/reply app, there should be no make files to contend with. I take it that you are bitting off more than you can chew here. Start off very simple and small.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. sending and recieveing packets with dynamic size.
    By c++.prog.newbie in forum Game Programming
    Replies: 1
    Last Post: 05-31-2006, 01:06 PM
  2. Sending requests with packets
    By joeprogrammer in forum Networking/Device Communication
    Replies: 14
    Last Post: 05-21-2006, 07:33 PM
  3. Sending Raw Packets?
    By Coder87C in forum Networking/Device Communication
    Replies: 7
    Last Post: 12-03-2003, 12:27 PM
  4. Sending data packets
    By neandrake in forum Networking/Device Communication
    Replies: 6
    Last Post: 11-26-2003, 12:41 PM
  5. Sending raw packets.
    By Denethor2000 in forum C++ Programming
    Replies: 3
    Last Post: 06-04-2002, 02:08 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21