Basic HIPPI support - now to find out why arp can't figure out that an
authorJes Sorensen <jes.sorensen@cern.ch>
Thu, 7 May 1998 12:32:38 +0000 (12:32 +0000)
committerJes Sorensen <jes.sorensen@cern.ch>
Thu, 7 May 1998 12:32:38 +0000 (12:32 +0000)
address on the HIPPI NIC's network should be type HIPPI and not Ether.

config.in
lib/Makefile
lib/hippi.c [new file with mode: 0644]
lib/hw.c

index 852976a..0f7730c 100644 (file)
--- a/config.in
+++ b/config.in
@@ -78,4 +78,5 @@ bool 'NET/ROM (packet radio) support' HAVE_HWNETROM y
 bool 'DLCI/FRAD (frame relay) support' HAVE_HWFR y
 bool 'SIT (IPv6-in-IPv4) support' HAVE_HWSIT n
 bool 'FDDI (generic) support' HAVE_HWFDDI n
+bool 'HIPPI (generic) support' HAVE_HWHIPPI n
 bool 'Ash hardware support' HAVE_HWASH n
index 4c38f96..a36f989 100644 (file)
@@ -29,7 +29,7 @@
 #
 
 
-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
+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
 AFOBJS  = unix.o inet.o inet6.o ax25.o ipx.o ddp.o ipx.o netrom.o af.o rose.o econet.o
 AFGROBJS = inet_gr.o inet6_gr.o ipx_gr.o ddp_gr.o netrom_gr.o ax25_gr.o rose_gr.o getroute.o
 AFSROBJS = inet_sr.o inet6_sr.o netrom_sr.o ipx_sr.o setroute.o
diff --git a/lib/hippi.c b/lib/hippi.c
new file mode 100644 (file)
index 0000000..c525eac
--- /dev/null
@@ -0,0 +1,150 @@
+/*
+ * lib/hippi.c This file contains an implementation of the "HIPPI"
+ *             support functions for the NET-2 base distribution.
+ *
+ * Version:    @(#)hippi.c     1.0     06/06/97
+ *
+ * Author:     Fred N. van Kempen, <waltje@uwalt.nl.mugnet.org>
+ *             Copyright 1993 MicroWalt Corporation
+ *
+ *             Modified for HIPPI by Jes Sorensen, <Jes.Sorensen@cern.ch>
+ *
+ *             This program is free software; you can redistribute it
+ *             and/or  modify it under  the terms of  the GNU General
+ *             Public  License as  published  by  the  Free  Software
+ *             Foundation;  either  version 2 of the License, or  (at
+ *             your option) any later version.
+ */
+#include "config.h"
+
+#if HAVE_HWHIPPI
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <net/if_arp.h>
+#ifndef ARPHRD_HIPPI
+#error "No HIPPI Support in your current Kernelsource Tree."
+#error "Disable HW Type HIPPI"
+#endif
+#include <linux/if_hippi.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <errno.h>
+#include <ctype.h>
+#include <string.h>
+#include <unistd.h>
+#include "net-support.h"
+#include "pathnames.h"
+#define  EXTERN
+#include "net-locale.h"
+
+
+extern struct hwtype hippi_hwtype;
+
+
+/* Display an HIPPI address in readable format. */
+static char *
+pr_hippi(unsigned char *ptr)
+{
+  static char buff[64];
+
+  sprintf(buff, "%02X:%02X:%02X:%02X:%02X:%02X",
+       (ptr[0] & 0377), (ptr[1] & 0377), (ptr[2] & 0377),
+       (ptr[3] & 0377), (ptr[4] & 0377), (ptr[5] & 0377)
+  );
+  return(buff);
+}
+
+
+/* Display an HIPPI socket address. */
+static char *
+pr_shippi(struct sockaddr *sap)
+{
+  static char buf[64];
+
+  if (sap->sa_family == 0xFFFF || sap->sa_family == 0)
+    return(NLS_CATBUFF (catfd, hippiSet, hippi_none, "[NONE SET]", buf, 64));
+  return(pr_hippi(sap->sa_data));
+}
+
+
+/* Input an HIPPI address and convert to binary. */
+static int
+in_hippi(char *bufp, struct sockaddr *sap)
+{
+  unsigned char *ptr;
+  char c, *orig;
+  int i, val;
+
+  sap->sa_family = hippi_hwtype.type;
+  ptr = sap->sa_data;
+
+  i = 0;
+  orig = bufp;
+  while((*bufp != '\0') && (i < HIPPI_ALEN)) {
+       val = 0;
+       c = *bufp++;
+       if (isdigit(c)) val = c - '0';
+         else if (c >= 'a' && c <= 'f') val = c - 'a' + 10;
+         else if (c >= 'A' && c <= 'F') val = c - 'A' + 10;
+         else {
+#ifdef DEBUG
+               fprintf(stderr, NLS_CATGETS(catfd, hippiSet, hippi_debug1,
+                                           "in_hippi(%s): invalid hippi address!\n"), orig);
+#endif
+               errno = EINVAL;
+               return(-1);
+       }
+       val <<= 4;
+       c = *bufp++;
+       if (isdigit(c)) val |= c - '0';
+         else if (c >= 'a' && c <= 'f') val |= c - 'a' + 10;
+         else if (c >= 'A' && c <= 'F') val |= c - 'A' + 10;
+         else {
+#ifdef DEBUG
+               fprintf(stderr, NLS_CATGETS(catfd, hippiSet, hippi_debug2,
+                                           "in_hippi(%s): invalid hippi address!\n"), orig);
+#endif
+               errno = EINVAL;
+               return(-1);
+       }
+       *ptr++ = (unsigned char) (val & 0377);
+       i++;
+
+       /* We might get a semicolon here - not required. */
+       if (*bufp == ':') {
+               if (i == HIPPI_ALEN) {
+#ifdef DEBUG
+                       fprintf(stderr, NLS_CATGETS(catfd, hippiSet, hippi_debug3,
+                                                   "in_hippi(%s): trailing : ignored!\n"),
+                                                                       orig)
+#endif
+                                               ; /* nothing */
+               }
+               bufp++;
+       }
+  }
+
+  /* That's it.  Any trailing junk? */
+  if ((i == HIPPI_ALEN) && (*bufp != '\0')) {
+#ifdef DEBUG
+       fprintf(stderr, NLS_CATGETS(catfd, hippiSet, hippi_debug4, "in_hippi(%s): trailing junk!\n"), orig);
+       errno = EINVAL;
+       return(-1);
+#endif
+  }
+
+#ifdef DEBUG
+  fprintf(stderr, "in_hippi(%s): %s\n", orig, pr_hippi(sap->sa_data));
+#endif
+
+  return(0);
+}
+
+
+struct hwtype hippi_hwtype = {
+  "hippi",     NULL, /*"HIPPI",*/              ARPHRD_HIPPI,   HIPPI_ALEN,
+  pr_hippi,    pr_shippi,      in_hippi,       NULL
+};
+
+
+#endif /* HAVE_HWHIPPI */
index ab4fb64..d9e9ec6 100644 (file)
--- a/lib/hw.c
+++ b/lib/hw.c
@@ -41,6 +41,7 @@ extern        struct hwtype   adaptive_hwtype;
 
 extern struct hwtype   ether_hwtype;
 extern struct hwtype   fddi_hwtype;
+extern struct hwtype   hippi_hwtype;
 extern struct hwtype   tr_hwtype;
 
 extern struct hwtype   ax25_hwtype;
@@ -107,6 +108,9 @@ static struct hwtype *hwtypes[] = {
 #if HAVE_HWFDDI
   &fddi_hwtype,
 #endif
+#if HAVE_HWHIPPI
+  &hippi_hwtype,
+#endif
   &unspec_hwtype,
   NULL
 };
@@ -133,6 +137,9 @@ void hwinit ()
 #if HAVE_HWFDDI
   fddi_hwtype.title = NLS_CATSAVE (catfd, fddiSet, fddi_fddi, "Fiber Distributed Data Interface");
 #endif
+#if HAVE_HWHIPPI
+  hippi_hwtype.title = NLS_CATSAVE (catfd, hippiSet, hippi_hippi, "HIPPI");
+#endif
 #if HAVE_HWAX25
   ax25_hwtype.title = NLS_CATSAVE (catfd, ax25Set, ax25_hw, "AMPR AX.25");
 #endif