[prev in list] [next in list] [prev in thread] [next in thread] 

List:       libnet
Subject:    Pb building ARP packet
From:       Thomas Heloin <htom () nortelnetworks ! com>
Date:       2002-08-20 16:04:43
[Download RAW message or body]



Hello,  
  
  
	I'm trying to write a ARP packet generator to  
determine on which network I'm connected to,  
basically it means sending ARP packet over an  
unconfigured interface, analysing the respons and  
select the right IP configuration (as divine does)  
but with the libnet-1.1.0.   
  
I based my program on arp.c from the example.  
  
I cannot use LIBNET_LINK* for the libnet_init since  
my interface is not configured.  
  
	So I tried to use LIBNET_RAW4, I removed the  
libnet_autobuild_ethernet (as far as I understood  
from the documentation, we don't need to build the  
ethernet part when we using LIBNET_RAW4*), but it  
fails because of;  
Write error: libnet_write_ipv4: -1 bytes written  
(Network is unreachable)  
  
	So I looked to the other programs and I found  
that the ping_of_death program is working with the  
interface unconfigured. So my conclusion is; when we  
build an IP packet, there is no problem sending it to  
the wire even when the interface is unconfigured, but  
for ARP, no hope here and I don't see why.  
  
Any idea please ??  
  
	Another weird thing is with the payload of  
the ARP packet; using LIBNET_RAW4, the payload is not  
taken into account, but if I use LIBNET_RAW4_ADV +  
libnet_autobuild_ethernet, it works ! Any bug here ??  
  
    ip_src = libnet_name2addr4( l, "192.168.10.250",  
LIBNET_DONT_RESOLVE );  
    ip_dst = libnet_name2addr4( l, "192.168.10.10",  
LIBNET_DONT_RESOLVE );  
    enet_dst[0] = 0xff;  
    enet_dst[1] = 0xff;  
    enet_dst[2] = 0xff;  
    enet_dst[3] = 0xff;  
    enet_dst[4] = 0xff;  
    enet_dst[5] = 0xff;  
  
  
    t = libnet_build_arp(  
            ARPHRD_ETHER,                            
/* hardware addr */  
            ETHERTYPE_IP,                            
/* protocol addr */  
            6,                                       
/* hardware addr size */  
            4,                                       
/* protocol addr size */  
            ARPOP_REQUEST,                             
/* operation type */  
            enet_src,                                
/* sender hardware addr */  
            (u_char *)&ip_src,                            
/* sender protocol addr */  
            enet_dst,                                
/* target hardware addr */  
            (u_char *)&ip_dst,                            
/* target protocol addr */  
            NULL,                                    
/* payload */  
            18,                                       
/* payload size */  
            l,                                       
/* libnet handle */  
            0);                                      
/* libnet id */  
 
 
    c = libnet_write(l); 
 
  
Thanks a lot  
Thomas.  
  
(PS: the new libnet is really much easier to use,  
this is great!!)  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: libnet-unsubscribe@securityfocus.com
For additional commands, e-mail: libnet-help@securityfocus.com

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic