[C++] How to construct ICMP echo request

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • NeoIndigo
    New Member
    • Feb 2009
    • 1

    [C++] How to construct ICMP echo request

    Hi guys,
    It's my first time trying to create a packet in C++. So, what i have done so far are:
    1. I have opened a packet level raw socket. Using this command:
    sd = socket(PF_PACKE T,SOCK_RAW,ETHE RTYPE_IP) ;

    2. I have gotten the interface number corresponding to interface name.
    Using the command:
    ioRtnCode = ioctl(sd,SIOCGI FINDEX,&ifioctl ) ;

    here, &ifioctl is supplied with eht1, in the ifrn_name from 0 to 4.

    3. I have also created the address structure used for a packet socket. This address will be loaded in the frame.

    So, my next step is to create the ICMP itself. How should I do this ? I mean, is there a special function or library to do so ? or should i just start from an array ?

    Of course, this ICMP message later on will be framed to IP and to Ethernet.

    Thanks,
Working...