Add STRIP support.
authorPhil Blundell <philb@gnu.org>
Sun, 2 Apr 2000 12:56:41 +0000 (12:56 +0000)
committerPhil Blundell <philb@gnu.org>
Sun, 2 Apr 2000 12:56:41 +0000 (12:56 +0000)
README
config.in
lib/Makefile
lib/hw.c
lib/strip.c [new file with mode: 0644]

diff --git a/README b/README
index b2409cd..6154cdb 100644 (file)
--- a/README
+++ b/README
@@ -32,10 +32,11 @@ Contents:
                           Notes
                           -----
 
-This is net-tools 1.54.  Notable changes since 1.53 include:
+This is net-tools 1.55.  Since 1.54, various bugs have been fixed.
+
+Notable changes since 1.53 include:
 
  - Jiri Pavlovsky supplied a Czech translation
- - various small bugs have been fixed
 
 Notable changes since 1.52 include:
 
@@ -43,13 +44,11 @@ Notable changes since 1.52 include:
    David Wagner)
  - Meelis Roos contributed an Estonian translation
  - netstat recognizes ESP and GRE protocols, courtesy John D. Hardin.
- - various other bugs have been fixed
 
 Notable changes since 1.51 include:
 
  - Jean-Michel Vansteene updated the French translation.
  - Dag Brattli contributed support for IrDA
- - some bugs have been fixed
 
 Notable changes since 1.50 include:
 
@@ -58,7 +57,6 @@ Notable changes since 1.50 include:
  - Jan Kratochvil added support to netstat for displaying details of
    the process owning a socket (option --programs)
  - Steve Whitehouse contributed support for DECnet
- - some bugs and compilation problems have been fixed
  - Ralf Bächle provided a translation to German
 
 You need kernel 2.0 or later to use these programs.  These programs
index 1f17b19..5be184b 100644 (file)
--- a/config.in
+++ b/config.in
@@ -67,6 +67,7 @@ bool 'ARCnet support' HAVE_HWARC y
 bool 'SLIP (serial line) support' HAVE_HWSLIP y
 bool 'PPP (serial line) support' HAVE_HWPPP y
 bool 'IPIP Tunnel support' HAVE_HWTUNNEL y
+bool 'STRIP (Metricom radio) support' HAVE_HWSTRIP y
 bool 'Token ring (generic) support' HAVE_HWTR y
 bool 'AX25 (packet radio) support' HAVE_HWAX25 y
 bool 'Rose (packet radio) support' HAVE_HWROSE n
index d8070bf..e5720e0 100644 (file)
@@ -16,7 +16,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 hippi.o hdlclapb.o irda.o ec_hw.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 hdlclapb.o strip.o irda.o ec_hw.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
index 97f5025..19329c1 100644 (file)
--- a/lib/hw.c
+++ b/lib/hw.c
@@ -2,7 +2,7 @@
  * lib/hw.c   This file contains the top-level part of the hardware
  *              support functions module.
  *
- * Version:     $Id: hw.c,v 1.15 1999/12/11 12:09:23 philip Exp $
+ * Version:     $Id: hw.c,v 1.16 2000/04/02 12:56:44 philip Exp $
  *
  * Maintainer:  Bernd 'eckes' Eckenfels, <net-tools@lina.inka.de>
  *
@@ -39,6 +39,7 @@ extern struct hwtype cslip_hwtype;
 extern struct hwtype slip6_hwtype;
 extern struct hwtype cslip6_hwtype;
 extern struct hwtype adaptive_hwtype;
+extern struct hwtype strip_hwtype;
 
 extern struct hwtype ether_hwtype;
 extern struct hwtype fddi_hwtype;
@@ -83,6 +84,9 @@ static struct hwtype *hwtypes[] =
     &cslip6_hwtype,
     &adaptive_hwtype,
 #endif
+#if HAVE_HWSTRIP
+    &strip_hwtype,
+#endif
 #if HAVE_HWASH
     &ash_hwtype,
 #endif
diff --git a/lib/strip.c b/lib/strip.c
new file mode 100644 (file)
index 0000000..eb74ce8
--- /dev/null
@@ -0,0 +1,98 @@
+/*
+ * lib/strip.c This file contains an implementation of the STRIP
+ *             support functions.
+ *
+ * Version:    strip.c 1.20 1999/04/22 eswierk
+ *
+ * Author:     Stuart Cheshire <cheshire@cs.stanford.edu>
+ *
+ *             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_HWSTRIP
+
+#include <sys/types.h>
+#include <sys/ioctl.h>
+#include <sys/socket.h>
+#include <net/if_arp.h>
+#include <linux/types.h>
+#include <linux/if_strip.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <ctype.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <string.h>
+#include <termios.h>
+#include <unistd.h>
+#include "net-support.h"
+#include "pathnames.h"
+#include "util.h"
+#include "intl.h"
+
+
+extern struct hwtype strip_hwtype;
+
+static char *
+pr_strip(unsigned char *ptr)
+{
+  static char buff[64];
+
+  sprintf(buff, "%02x%02x-%02x%02x", *(ptr+2), *(ptr+3), *(ptr+4),
+         *(ptr+5));
+  return buff;
+}
+
+static int
+in_strip(char *bufp, struct sockaddr *sap)
+{
+  int i;
+  MetricomAddress *haddr = (MetricomAddress *) (sap->sa_data);
+
+
+  sap->sa_family = strip_hwtype.type;
+
+  /* figure out what the device-address should be */
+  i = (bufp[0] == '*') ? 1 : 0;
+  haddr->c[2] = strtol(&bufp[i], 0, 16) >> 8;
+  haddr->c[3] = strtol(&bufp[i], 0, 16) & 0xFF;
+
+  while (bufp[i] && (bufp[i] != '-'))
+    i++;
+
+  if (bufp[i] != '-')
+    return -1;
+
+  haddr->c[4] = strtol(&bufp[i+1], 0, 16) >> 8;
+  haddr->c[5] = strtol(&bufp[i+1], 0, 16) & 0xFF;
+  haddr->c[0] = 0;
+  haddr->c[1] = 0;
+
+  return 0;
+}
+
+
+
+/* Start the STRIP encapsulation on the file descriptor. */
+static int do_strip(int fd)
+       {
+       int disc = N_STRIP;
+       if (ioctl(fd, TIOCSETD, &disc) < 0)
+               {
+               fprintf(stderr, "STRIP_set_disc(%d): %s\n", disc, strerror(errno));
+               return(-errno);
+               }
+       return(0);
+       }
+
+struct hwtype strip_hwtype = {
+  "strip", "Metricom Starmode IP", ARPHRD_METRICOM, sizeof(MetricomAddress),
+  pr_strip, in_strip, do_strip, 0
+};
+
+#endif /* HAVE_HWSTRIP */