]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
Disallow arp claim for IEEE1394 per RFC 2734 thanks to pawka.
authorRoy Marples <roy@marples.name>
Wed, 9 Jan 2008 13:41:16 +0000 (13:41 +0000)
committerRoy Marples <roy@marples.name>
Wed, 9 Jan 2008 13:41:16 +0000 (13:41 +0000)
arp.c

diff --git a/arp.c b/arp.c
index b221d3800f988bb97f347e41c967047fbcb783a0..514914dd2e5b117a2d25352e0b34bbfd6fe2485d 100644 (file)
--- a/arp.c
+++ b/arp.c
@@ -80,6 +80,7 @@ static int send_arp (const interface_t *iface, int op, struct in_addr sip,
 {
        struct arphdr *arp;
        int arpsize = arphdr_len2 (iface->hwlen, sizeof (struct in_addr));
+       char *tha;
        int retval;
 
        arp = xmalloc (arpsize);
@@ -92,8 +93,16 @@ static int send_arp (const interface_t *iface, int op, struct in_addr sip,
        arp->ar_op = htons (op);
        memcpy (ar_sha (arp), iface->hwaddr, arp->ar_hln);
        memcpy (ar_spa (arp), &sip, arp->ar_pln);
-       if (taddr)
-               memcpy (ar_tha (arp), taddr, arp->ar_hln); 
+       if (taddr) {
+               /* NetBSD can return NULL from ar_tha, which is probably wrong
+                * but we still need to deal with it */
+               if (! (tha = ar_tha (arp))) {
+                       free (arp);
+                       errno = EINVAL;
+                       return (-1);
+               }
+               memcpy (tha, taddr, arp->ar_hln);
+       }
        memcpy (ar_tpa (arp), &tip, arp->ar_pln);
 
        retval = send_packet (iface, ETHERTYPE_ARP,
@@ -173,6 +182,12 @@ int arp_claim (interface_t *iface, struct in_addr address)
                                if (send_arp (iface, ARPOP_REQUEST,
                                                          null_address, NULL, address) == -1)
                                        break;
+
+                               /* IEEE1394 cannot set ARP target address
+                                * according to RFC2734 */
+                               if (nprobes >= NPROBES &&
+                                   iface->family == ARPHRD_IEEE1394)
+                                       nclaims = NCLAIMS;
                        } else if (nclaims < NCLAIMS) {
                                nclaims ++;
                                timeout = CLAIM_INTERVAL;