changeset 278:56e825a9440a draft

Disallow arp claim for IEEE1394 per RFC 2734 thanks to pawka.
author Roy Marples <roy@marples.name>
date Wed, 09 Jan 2008 13:41:16 +0000
parents 5e9863f8a821
children ecb3251a1479
files arp.c
diffstat 1 files changed, 17 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/arp.c	Wed Jan 09 12:34:34 2008 +0000
+++ b/arp.c	Wed Jan 09 13:41:16 2008 +0000
@@ -80,6 +80,7 @@
 {
 	struct arphdr *arp;
 	int arpsize = arphdr_len2 (iface->hwlen, sizeof (struct in_addr));
+	char *tha;
 	int retval;
 
 	arp = xmalloc (arpsize);
@@ -92,8 +93,16 @@
 	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 @@
 				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;