Thanks a lot HKO
Now I have one more question
I wrote a program to send arp
--------------------START OF CODE-------------------------------------------------------------------
#include <libnet.h>
int main(int argc,char** argv){
u_long ip_src;
u_char ip_dst[4] = {0x0a,0x00,0x00,0x04};
u_char enet_src[6] = {0x00,0x01,0x02,0x03,0x04,0x05};
u_char enet_dst[6] = {0xff,0xff,0xff,0xff,0xff,0xff};
libnet_t* l;
libnet_ptag_t t;
char* device;
char errorBuffer[LIBNET_ERRBUF_SIZE];
if(argc>=2) device=argv[1];
l = libnet_init(LIBNET_LINK_ADV,device,errorBuffer);
if(l==NULL){
fprintf(stderr,"\nError in libnet_init(): %s",errorBuffer);
return -1;
}
ip_src = libnet_get_ipaddr4(l);
t = libnet_build_arp(ARPHRD_ETHER,ETHERTYPE_IP,6,4,ARPOP_REPLY,enet_src,(u_char*)&ip_src,enet_dst,ip_dst ,NULL,0,l,0);
if(t==-1){
fprintf(stderr,"\nError in libnet_build_arp(): %s",libnet_geterror(l));
libnet_destroy(l);
return -1;
}
t = libnet_autobuild_ethernet(enet_dst,ETHERTYPE_ARP,l);
if(t==-1){
fprintf(stderr,"\nError in libnet_autobuild_ethernet(): %s",libnet_geterror(l));
libnet_destroy(l);
return -1;
}
int x=libnet_write(l);
if(x==-1){
fprintf(stderr,"\nError in libnet_write(): %s \n",libnet_geterror(l));
libnet_destroy(l);
return -1;
}
libnet_destroy(l);
}
--------------------------END OF CODE-------------------------------------------
And whenever I run it the computer hangs !!
So does anyone know what's wrong with it ??
|