Sending Arp reply packets using packet-sockets on linux

Sending Arp reply packets using packet-sockets on linux

Post by Shrish Agraw » Wed, 04 Jul 2001 09:58:37



I am trying to broadcast an arp response packet using packet-sockets on
linux. I created an arp response packet and then used sendto to dispatch it
from a socket created using socket(PF_PACKET, SOCK_RAW, htons(ETH_P_ARP))
and bound as follows:

struct sockaddr_ll sa;
memset((char *)&sa, 0, sizeof(sa));
sa.sll_family = AF_PACKET;
sa.sll_protocol = htons(ETH_P_ARP);
sa.sll_ifindex = 2;
sa.sll_hatype = htons(ARPHRD_ETHER);
sa.sll_pkttype = htons(PACKET_BROADCAST);
sa.sll_halen = htons(ETHER_ADDR_LEN);
memcpy(sa.sll_addr, mac, ETHER_ADDR_LEN);

[where mac is my mac address as an array of chars.]

bind(sock, (struct sockaddr *)&sa, sizeof(sa));

However, when I use tcpdump to print the sent packet it prints as follows:

17:25:50.268936 eth0 > arp-#0 for proto #0 (0) hardware #0 (0)
17:25:50.269001 eth0 > arp-#0 for proto #0 (0) hardware #0 (0)
17:25:50.269062 eth0 > arp-#0 for proto #0 (0) hardware #0 (0)
17:25:50.269124 eth0 > arp-#0 for proto #0 (0) hardware #0 (0)

Does anyone know what am I doing wrong? Can anyone point me to a working
example for sending broadcast arp responses.

Any help is deeply appreciated.

 
 
 

1. SPAK(Send PAcKets)- tools to send arbitrary packets

Hello,

        That Subject title was posted to comp.os.linux.announce about a month
ago. Unfortunately I lost the url/ftp address of where to grab the
source for
this package. My isp no longer contains the article in its news cache
and I
was unable to locate it from dejanews ( it seems dejanews doesnt store
.announce
groups ). Anyhow - does anyone have this , or know where to go for the
source?

THanks,

Corey

2. Adding a 2nd disk drive

3. How to send an ARP packet using the Netrain interface ?

4. Startup Service in Mandrake.

5. ARP Request packet??plz reply soon

6. Where can I get ipautofw?

7. How to force an ARP Reply Packet ?

8. Solaris 2.3 to 2.5 upgrade concerns

9. Packet socket losing packets

10. RH9 Router Constantly sending ARP packets

11. RH9 Router sending ARP packets

12. How to send an ARP Packet ?

13. First packets not being sent - ARP?