Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys Add MI Econet support. This is lacking any interfaces t...



details:   https://anonhg.NetBSD.org/src/rev/2d3a60117576
branches:  trunk
changeset: 514813:2d3a60117576
user:      bjh21 <bjh21%NetBSD.org@localhost>
date:      Mon Sep 10 23:11:05 2001 +0000

description:
Add MI Econet support.  This is lacking any interfaces to higher-layer
protocols, and lacking any timeouts, but it basically works, doing four-way
handshakes in both directions and incoming Machine Peek operations.

Oh, and Econet is Acorn's ancient, proprietary 500kbit/s networking
technology.

diffstat:

 sys/conf/files       |    6 +-
 sys/net/bpf.c        |    8 +-
 sys/net/dlt.h        |    4 +-
 sys/net/if_eco.h     |  125 +++++++++++++
 sys/net/if_ecosubr.c |  463 +++++++++++++++++++++++++++++++++++++++++++++++++++
 5 files changed, 602 insertions(+), 4 deletions(-)

diffs (truncated from 665 to 300 lines):

diff -r e0e8ca96de51 -r 2d3a60117576 sys/conf/files
--- a/sys/conf/files    Mon Sep 10 23:05:19 2001 +0000
+++ b/sys/conf/files    Mon Sep 10 23:11:05 2001 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: files,v 1.456 2001/09/09 11:01:00 tls Exp $
+#      $NetBSD: files,v 1.457 2001/09/10 23:11:05 bjh21 Exp $
 
 #      @(#)files.newconf       7.5 (Berkeley) 5/10/93
 
@@ -186,9 +186,10 @@
 define rasops32
 
 # net device attributes - we have generic code for arc(net), ether(net),
-# fddi, token ring and atm.
+# fddi, token ring, atm and eco(net).
 define arc
 define atm
+define eco
 define ether
 define fddi
 define hippi
@@ -966,6 +967,7 @@
 file   net/if_atmsubr.c                atm
 file   net/if_bridge.c                 bridge                  needs-flag
 file   net/bridgestp.c                 bridge
+file   net/if_ecosubr.c                eco
 file   net/if_ethersubr.c              ether | fddi | netatalk | token |
                                            wlan | vlan | pppoe
 file   net/if_faith.c                  faith & inet & inet6    needs-flag
diff -r e0e8ca96de51 -r 2d3a60117576 sys/net/bpf.c
--- a/sys/net/bpf.c     Mon Sep 10 23:05:19 2001 +0000
+++ b/sys/net/bpf.c     Mon Sep 10 23:11:05 2001 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: bpf.c,v 1.61 2001/04/13 23:30:11 thorpej Exp $ */
+/*     $NetBSD: bpf.c,v 1.62 2001/09/10 23:11:06 bjh21 Exp $   */
 
 /*
  * Copyright (c) 1990, 1991, 1993
@@ -169,6 +169,12 @@
                align = 0;
                break;
 
+       case DLT_ECONET:
+               sockp->sa_family = AF_UNSPEC;
+               hlen = 6;
+               align = 2;
+               break;
+
        case DLT_NULL:
                sockp->sa_family = AF_UNSPEC;
                hlen = 0;
diff -r e0e8ca96de51 -r 2d3a60117576 sys/net/dlt.h
--- a/sys/net/dlt.h     Mon Sep 10 23:05:19 2001 +0000
+++ b/sys/net/dlt.h     Mon Sep 10 23:11:05 2001 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: dlt.h,v 1.2 2001/04/29 09:50:37 martin Exp $   */
+/*     $NetBSD: dlt.h,v 1.3 2001/09/10 23:11:06 bjh21 Exp $    */
 
 /*
  * Copyright (c) 1990, 1991, 1993
@@ -69,6 +69,8 @@
 #define        DLT_PPP_SERIAL  50      /* PPP over serial (async and sync) */
 #define        DLT_PPP_ETHER   51      /* XXX - depreceated! PPP over Ethernet; session only, w/o ether header */
 
+#define DLT_ECONET     115     /* Acorn Econet */
+
 /*
  * NetBSD-specific generic "raw" link type.  The upper 16-bits indicate
  * that this is the generic raw type, and the lower 16-bits are the
diff -r e0e8ca96de51 -r 2d3a60117576 sys/net/if_eco.h
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/net/if_eco.h  Mon Sep 10 23:11:05 2001 +0000
@@ -0,0 +1,125 @@
+/*     $NetBSD: if_eco.h,v 1.1 2001/09/10 23:11:06 bjh21 Exp $ */
+
+/*-
+ * Copyright (c) 2001 Ben Harris
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ *    derived from this software without specific prior written permission.
+ * 
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _NET_IF_ECO_H_
+#define _NET_IF_ECO_H_
+
+#include <sys/mbuf.h>
+
+#include <net/if.h>
+
+/*
+ * Econet headers come in two forms.  The initial frame of an exchange
+ * has source and destination addresses, a control byte and a port.
+ * Later frames just have source and destination addresses.
+ *
+ * Complete packets are generally passed around with the full header on,
+ * even if this means assembling them from two separate frames.
+ */
+#define ECO_ADDR_LEN   2       /* Length of an Econet address */
+#define ECO_HDR_LEN    6       /* Two addresses, a port and a control byte */
+#define ECO_SHDR_LEN   4       /* "Short" Econet header: just two addresses */
+#define ECO_MTU        8192    /* Default MTU */
+
+struct eco_header {
+       u_int8_t        eco_dhost[ECO_ADDR_LEN];
+       u_int8_t        eco_shost[ECO_ADDR_LEN];
+       u_int8_t        eco_control;
+       u_int8_t        eco_port;
+} __attribute__((__packed__));
+
+#define ECO_PORT_IMMEDIATE     0x00
+#define ECO_PORT_DSTAPE                0x54 /* DigitalServicesTapeStore */
+#define ECO_PORT_FS            0x99 /* FileServerCommand */
+#define ECO_PORT_BRIDGE                0x9C /* Bridge */
+#define ECO_PORT_PSINQREP      0x9E /* PrinterServerInquiryReply */
+#define ECO_PORT_PSINQ         0x9F /* PrinterServerInquiry */
+#define ECO_PORT_FAST          0xA0 /* SJ *FAST protocol */
+#define ECO_PORT_NEXNETFIND    0xA1 /* SJ Nexus net find reply port */
+#define ECO_PORT_FINDSRV       0xB0 /* FindServer */
+#define ECO_PORT_FINDSRVREP    0xB1 /* FindServerReply */
+#define ECO_PORT_TTXTCMD       0xB2 /* TeletextServerCommand */
+#define ECO_PORT_TTXTPAGE      0xB3 /* TeletextServerPage */
+#define ECO_PORT_OLDPSDATA     0xD0 /* OldPrinterServer */
+#define ECO_PORT_PSDATA                0xD1 /* PrinterServer */
+#define ECO_PORT_IP            0xD2 /* TCPIPProtocolSuite */
+#define ECO_PORT_SIDSLAVE      0xD3 /* SIDFrameSlave */
+#define ECO_PORT_SCROLLARAMA   0xD4 /* Scrollarama */
+#define ECO_PORT_PHONE         0xD5 /* Phone */
+#define ECO_PORT_BCASTCTL      0xD6 /* BroadcastControl */
+#define ECO_PORT_BCASTDATA     0xD7 /* BroadcastData */
+#define ECO_PORT_IMPLICENCE    0xD8 /* ImpressionLicenceChecker */
+#define ECO_PORT_SQUIRREL      0xD9 /* DigitalServicesSquirrel */
+#define ECO_PORT_SID2NDARY     0xDA /* SIDSecondary */
+#define ECO_PORT_SQUIRREL2     0xDB /* DigitalServicesSquirrel2 */
+#define ECO_PORT_DDCTL         0xDC /* DataDistributionControl */
+#define ECO_PORT_DDDATA                0xDD /* DataDistributionData */
+#define ECO_PORT_CLASSROM      0xDE /* ClassROM */
+#define ECO_PORT_PSCMD         0xDF /* PrinterSpoolerCommand */
+
+/* Control bytes for immediate operations. */
+#define ECO_CTL_PEEK           0x81
+#define ECO_CTL_POKE           0x82
+#define ECO_CTL_JSR            0x83
+#define ECO_CTL_USERPROC       0x84
+#define ECO_CTL_OSPROC         0x85
+#define ECO_CTL_HALT           0x86
+#define ECO_CTL_CONTINUE       0x87
+#define ECO_CTL_MACHINEPEEK    0x88
+#define ECO_CTL_GETREGISTERS   0x89
+
+/*
+ * Common structure used to store state about an Econet interface.
+ */
+enum eco_state {
+       ECO_IDLE, ECO_SCOUT_RCVD,
+       ECO_SCOUT_SENT, ECO_DATA_SENT, ECO_IMMED_SENT,
+       ECO_DONE
+};
+
+struct ecocom {
+       struct ifnet    ec_if;
+       int     (*ec_claimwire)(struct ifnet *);
+       void    (*ec_txframe)(struct ifnet *, struct mbuf *);
+       enum eco_state  ec_state;
+       struct mbuf     *ec_scout;
+       struct mbuf     *ec_packet;
+};
+
+#ifdef _KERNEL
+void   eco_ifattach(struct ifnet *, const u_int8_t *);
+void   eco_ifdetach(struct ifnet *);
+
+char   *eco_sprintf(const u_int8_t *);
+
+struct mbuf *  eco_inputframe(struct ifnet *, struct mbuf *);
+void   eco_inputidle(struct ifnet *);
+#endif
+
+#endif
diff -r e0e8ca96de51 -r 2d3a60117576 sys/net/if_ecosubr.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/net/if_ecosubr.c      Mon Sep 10 23:11:05 2001 +0000
@@ -0,0 +1,463 @@
+/*     $NetBSD: if_ecosubr.c,v 1.1 2001/09/10 23:11:06 bjh21 Exp $     */
+
+/*-
+ * Copyright (c) 2001 Ben Harris
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ *    derived from this software without specific prior written permission.
+ * 
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "bpfilter.h"
+
+#include <sys/param.h>
+
+__KERNEL_RCSID(0, "$NetBSD: if_ecosubr.c,v 1.1 2001/09/10 23:11:06 bjh21 Exp $");
+
+#include <sys/errno.h>
+#include <sys/socket.h>
+#include <sys/sockio.h>
+#include <sys/syslog.h>
+#include <sys/systm.h>
+
+#include <net/if.h>
+#include <net/if_dl.h>
+#include <net/if_eco.h>
+#include <net/if_types.h>
+
+#if NBPFILTER > 0
+#include <net/bpf.h>
+#endif
+
+/* Default broadcast address */
+static const u_int8_t eco_broadcastaddr[] = { 0xff, 0xff };
+
+static int eco_output(struct ifnet *, struct mbuf *, struct sockaddr *,
+    struct rtentry *);
+static void eco_input(struct ifnet *, struct mbuf *);
+static void eco_start(struct ifnet *);
+static int eco_ioctl(struct ifnet *, u_long, caddr_t);
+
+static int eco_interestingp(struct ifnet *ifp, struct mbuf *m);
+static struct mbuf *eco_immediate(struct ifnet *ifp, struct mbuf *m);
+static struct mbuf *eco_ack(struct ifnet *ifp, struct mbuf *m);
+
+void
+eco_ifattach(struct ifnet *ifp, const u_int8_t *lla)
+{
+       struct ecocom *ec = (void *)ifp;
+
+       ifp->if_type = IFT_OTHER;
+       ifp->if_addrlen = ECO_ADDR_LEN;
+       ifp->if_hdrlen = ECO_HDR_LEN;
+       ifp->if_dlt = DLT_ECONET;
+       ifp->if_mtu = ECO_MTU;
+
+       ifp->if_output   = eco_output;
+       ifp->if_input    = eco_input;
+       ifp->if_start    = eco_start;
+       ifp->if_ioctl    = eco_ioctl;
+
+/*     ifp->if_baudrate...; */
+       if_alloc_sadl(ifp);
+       memcpy(LLADDR(ifp->if_sadl), lla, ifp->if_addrlen);
+
+       /* XXX cast safe? */
+       ifp->if_broadcastaddr = (u_int8_t *)eco_broadcastaddr;
+       ec->ec_state = ECO_IDLE;
+#if NBPFILTER > 0
+       bpfattach(ifp, ifp->if_dlt, ECO_HDR_LEN);
+#endif
+}
+
+#define senderr(e) do {                                                        \
+       error = (e);                                                    \
+       goto bad;                                                       \
+} while (/*CONSTCOND*/0)
+
+static int
+eco_output(struct ifnet *ifp, struct mbuf *m0, struct sockaddr *dst,



Home | Main Index | Thread Index | Old Index