d7ac37c
diff -up net-tools-1.60/config.in.hfi net-tools-1.60/config.in
d7ac37c
--- net-tools-1.60/config.in.hfi	2010-09-16 17:20:04.000000000 +0200
d7ac37c
+++ net-tools-1.60/config.in	2010-09-16 19:17:35.000000000 +0200
d7ac37c
@@ -83,6 +83,7 @@ bool '(Cisco)-HDLC/LAPB support' HAVE_HW
d7ac37c
 bool 'IrDA support' HAVE_HWIRDA y
d7ac37c
 bool 'Econet hardware support' HAVE_HWEC n
d7ac37c
 bool 'InfiniBand hardware support' HAVE_HWIB y
d7ac37c
+bool 'HFI support' HAVE_HWHFI y
d7ac37c
 *
d7ac37c
 *
d7ac37c
 *           Other Features.
d7ac37c
diff -up net-tools-1.60/lib/hfi.c.hfi net-tools-1.60/lib/hfi.c
d7ac37c
--- net-tools-1.60/lib/hfi.c.hfi	2010-09-16 19:17:58.000000000 +0200
d7ac37c
+++ net-tools-1.60/lib/hfi.c	2010-09-16 19:19:49.000000000 +0200
d7ac37c
@@ -0,0 +1,125 @@
d7ac37c
+#include "config.h"
d7ac37c
+
d7ac37c
+#if HAVE_HWHFI
d7ac37c
+#include <sys/types.h>
d7ac37c
+#include <sys/socket.h>
d7ac37c
+#include <net/if_arp.h>
d7ac37c
+#include <stdlib.h>
d7ac37c
+#include <stdio.h>
d7ac37c
+#include <errno.h>
d7ac37c
+#include <ctype.h>
d7ac37c
+#include <string.h>
d7ac37c
+#include <unistd.h>
d7ac37c
+#include "net-support.h"
d7ac37c
+#include "pathnames.h"
d7ac37c
+#include "intl.h"
d7ac37c
+#include "util.h"
d7ac37c
+
d7ac37c
+extern struct hwtype hfi_hwtype;
d7ac37c
+
d7ac37c
+#define HF_ALEN		6	/* from hf_if.h */
d7ac37c
+
d7ac37c
+/* Display an HFI address in readable format. */
d7ac37c
+static char *pr_hfi(unsigned char *ptr)
d7ac37c
+{
d7ac37c
+    static char buff[64];
d7ac37c
+
d7ac37c
+    snprintf(buff, sizeof(buff), "%02X:%02X:%02X:%02X:%02X:%02X",
d7ac37c
+	     (ptr[0] & 0377), (ptr[1] & 0377), (ptr[2] & 0377),
d7ac37c
+	     (ptr[3] & 0377), (ptr[4] & 0377), (ptr[5] & 0377)
d7ac37c
+	);
d7ac37c
+    return (buff);
d7ac37c
+}
d7ac37c
+
d7ac37c
+
d7ac37c
+/* Input an HFI address and convert to binary. */
d7ac37c
+static int in_hfi(char *bufp, struct sockaddr *sap)
d7ac37c
+{
d7ac37c
+    unsigned char *ptr;
d7ac37c
+    char c, *orig;
d7ac37c
+    int i;
d7ac37c
+    unsigned val;
d7ac37c
+
d7ac37c
+    sap->sa_family = hfi_hwtype.type;
d7ac37c
+    ptr = sap->sa_data;
d7ac37c
+
d7ac37c
+    i = 0;
d7ac37c
+    orig = bufp;
d7ac37c
+    while ((*bufp != '\0') && (i < HF_ALEN)) {
d7ac37c
+	val = 0;
d7ac37c
+	c = *bufp++;
d7ac37c
+	if (isdigit(c))
d7ac37c
+	    val = c - '0';
d7ac37c
+	else if (c >= 'a' && c <= 'f')
d7ac37c
+	    val = c - 'a' + 10;
d7ac37c
+	else if (c >= 'A' && c <= 'F')
d7ac37c
+	    val = c - 'A' + 10;
d7ac37c
+	else {
d7ac37c
+#ifdef DEBUG
d7ac37c
+	    fprintf(stderr, _("in_hfi(%s): invalid hfi address!\n"), orig);
d7ac37c
+#endif
d7ac37c
+	    errno = EINVAL;
d7ac37c
+	    return (-1);
d7ac37c
+	}
d7ac37c
+	val <<= 4;
d7ac37c
+	c = *bufp;
d7ac37c
+	if (isdigit(c))
d7ac37c
+	    val |= c - '0';
d7ac37c
+	else if (c >= 'a' && c <= 'f')
d7ac37c
+	    val |= c - 'a' + 10;
d7ac37c
+	else if (c >= 'A' && c <= 'F')
d7ac37c
+	    val |= c - 'A' + 10;
d7ac37c
+	else if (c == ':' || c == 0)
d7ac37c
+	    val >>= 4;
d7ac37c
+	else {
d7ac37c
+#ifdef DEBUG
d7ac37c
+	    fprintf(stderr, _("in_hfi(%s): invalid hfi address!\n"), orig);
d7ac37c
+#endif
d7ac37c
+	    errno = EINVAL;
d7ac37c
+	    return (-1);
d7ac37c
+	}
d7ac37c
+	if (c != 0)
d7ac37c
+	    bufp++;
d7ac37c
+	*ptr++ = (unsigned char) (val & 0377);
d7ac37c
+	i++;
d7ac37c
+
d7ac37c
+	/* We might get a semicolon here - not required. */
d7ac37c
+	if (*bufp == ':') {
d7ac37c
+	    if (i == HF_ALEN) {
d7ac37c
+#ifdef DEBUG
d7ac37c
+		fprintf(stderr, _("in_hfi(%s): trailing : ignored!\n"),
d7ac37c
+			orig)
d7ac37c
+#endif
d7ac37c
+		    ;		/* nothing */
d7ac37c
+	    }
d7ac37c
+	    bufp++;
d7ac37c
+	}
d7ac37c
+    }
d7ac37c
+
d7ac37c
+    /* That's it.  Any trailing junk? */
d7ac37c
+    if ((i == HF_ALEN) && (*bufp != '\0')) {
d7ac37c
+#ifdef DEBUG
d7ac37c
+	fprintf(stderr, _("in_hfi(%s): trailing junk!\n"), orig);
d7ac37c
+	errno = EINVAL;
d7ac37c
+	return (-1);
d7ac37c
+#endif
d7ac37c
+    }
d7ac37c
+#ifdef DEBUG
d7ac37c
+    fprintf(stderr, "in_hfi(%s): %s\n", orig, pr_hfi(sap->sa_data));
d7ac37c
+#endif
d7ac37c
+
d7ac37c
+    return (0);
d7ac37c
+}
d7ac37c
+
d7ac37c
+#if !defined(ARPHRD_HFI)
d7ac37c
+#define ARPHRD_HFI	37	/* goes into if_arp.h */
d7ac37c
+#endif
d7ac37c
+
d7ac37c
+struct hwtype hfi_hwtype =
d7ac37c
+{
d7ac37c
+    "hfi", NULL, /*"HFI", */ ARPHRD_HFI, HF_ALEN,
d7ac37c
+    pr_hfi, in_hfi, NULL
d7ac37c
+};
d7ac37c
+
d7ac37c
+
d7ac37c
+#endif				/* HAVE_HWHFI */
d7ac37c
diff -up net-tools-1.60/lib/hw.c.hfi net-tools-1.60/lib/hw.c
d7ac37c
--- net-tools-1.60/lib/hw.c.hfi	2010-09-16 17:20:04.000000000 +0200
d7ac37c
+++ net-tools-1.60/lib/hw.c	2010-09-16 19:21:28.000000000 +0200
d7ac37c
@@ -42,6 +42,7 @@ extern struct hwtype adaptive_hwtype;
d7ac37c
 extern struct hwtype strip_hwtype;
d7ac37c
 
d7ac37c
 extern struct hwtype ether_hwtype;
d7ac37c
+extern struct hwtype hfi_hwtype;
d7ac37c
 extern struct hwtype fddi_hwtype;
d7ac37c
 extern struct hwtype hippi_hwtype;
d7ac37c
 extern struct hwtype tr_hwtype;
d7ac37c
@@ -146,6 +147,9 @@ static struct hwtype *hwtypes[] =
d7ac37c
 #if HAVE_HWX25
d7ac37c
     &x25_hwtype,
d7ac37c
 #endif
d7ac37c
+#if HAVE_HWHFI
d7ac37c
+    &hfi_hwtype,
d7ac37c
+#endif
d7ac37c
 #if HAVE_HWIB
d7ac37c
     &ib_hwtype,
d7ac37c
 #endif
d7ac37c
@@ -222,6 +226,9 @@ void hwinit()
d7ac37c
 #if HAVE_HWEC
d7ac37c
     ec_hwtype.title = _("Econet");
d7ac37c
 #endif
d7ac37c
+#if HAVE_HWHFI
d7ac37c
+    hfi_hwtype.title = _("HFI");
d7ac37c
+#endif
d7ac37c
 #if HAVE_HWIB
d7ac37c
     ib_hwtype.title = _("InfiniBand");
d7ac37c
 #endif
d7ac37c
diff -up net-tools-1.60/lib/Makefile.hfi net-tools-1.60/lib/Makefile
d7ac37c
--- net-tools-1.60/lib/Makefile.hfi	2010-09-16 17:20:04.000000000 +0200
d7ac37c
+++ net-tools-1.60/lib/Makefile	2010-09-16 19:22:34.000000000 +0200
d7ac37c
@@ -16,7 +16,7 @@
d7ac37c
 #
d7ac37c
 
d7ac37c
 
d7ac37c
-HWOBJS	 = hw.o loopback.o slip.o ether.o ax25.o ppp.o arcnet.o tr.o tunnel.o frame.o sit.o rose.o ash.o fddi.o hippi.o hdlclapb.o strip.o irda.o ec_hw.o x25.o ib.o
d7ac37c
+HWOBJS	 = hw.o loopback.o slip.o ether.o ax25.o ppp.o arcnet.o tr.o tunnel.o frame.o sit.o rose.o ash.o fddi.o hippi.o hdlclapb.o strip.o irda.o ec_hw.o x25.o ib.o hfi.o
d7ac37c
 AFOBJS	 = unix.o inet.o inet6.o ax25.o ipx.o ddp.o ipx.o netrom.o af.o rose.o econet.o x25.o
d7ac37c
 AFGROBJS = inet_gr.o inet6_gr.o ipx_gr.o ddp_gr.o netrom_gr.o ax25_gr.o rose_gr.o getroute.o x25_gr.o
d7ac37c
 AFSROBJS = inet_sr.o inet6_sr.o netrom_sr.o ipx_sr.o setroute.o x25_sr.o