From 4cf72c7afeb8e442285b786d160d0caffee44c9d Mon Sep 17 00:00:00 2001 From: David du Colombier <0intro@gmail.com> Date: Thu, 23 Apr 1998 00:00:00 +0000 Subject: [PATCH] Plan 9 from Bell Labs 1998-04-23 --- ip/devip.c | 5 +++++ ip/ethermedium.c | 6 ++++++ ip/ip.h | 1 + ip/ipifc.c | 21 ++++++++++++++++----- ip/nullmedium.c | 6 ++++++ ip/pktmedium.c | 6 ++++++ pc/etherif.h | 1 + 7 files changed, 41 insertions(+), 5 deletions(-) diff --git a/ip/devip.c b/ip/devip.c index dd71a5579c9f5b1e44091132f0a6fa0a05b456ef..a3d213a79cb6f061dc9164061977dfa7f06e1250 100644 --- a/ip/devip.c +++ b/ip/devip.c @@ -54,6 +54,9 @@ QLock fslock; Fs *ipfs[Nfs]; /* attached fs's */ Queue *qlog; +extern void nullmediumlink(void); +extern void pktmediumlink(void); + static int ip3gen(Chan *c, int i, Dir *dp) { @@ -215,6 +218,8 @@ ipgen(Chan *c, Dirtab*, int, int s, Dir *dp) static void ipreset(void) { + nullmediumlink(); + pktmediumlink(); } static void diff --git a/ip/ethermedium.c b/ip/ethermedium.c index c5e9424b64fbbd5621eef6ff339caf8c8a2a0fea..44e2654889d6c6bdba9bd487038038729327f48d 100644 --- a/ip/ethermedium.c +++ b/ip/ethermedium.c @@ -515,3 +515,9 @@ multicastarp(Fs *f, Arpent *a, uchar *mac) /* let arp take care of it */ return nil; } + +void +ethermediumlink(void) +{ + addipmedium(ðermedium); +} diff --git a/ip/ip.h b/ip/ip.h index 103c218fd6afd60e650c1a65e7550cc7f0321c47..c4ce94c3417b9bf9c2b7460069589613fd3b354f 100644 --- a/ip/ip.h +++ b/ip/ip.h @@ -446,6 +446,7 @@ extern Medium tripmedium; * ipifc.c */ extern Medium* ipfindmedium(char *name); +extern void addipmedium(Medium *med); extern int ipforme(Fs*, uchar *addr); extern int ipismulticast(uchar *); extern Ipifc* findipifc(Fs*, uchar *remote, int type); diff --git a/ip/ipifc.c b/ip/ipifc.c index f17e42e18984fffa57112473ae13b153f5fe156e..96d43fab3866c8d5d8599eee14a3d38e3cf97836 100644 --- a/ip/ipifc.c +++ b/ip/ipifc.c @@ -17,12 +17,8 @@ enum { QMAX = 64*1024-1, }; -Medium *media[] = +Medium *media[32] = { - ðermedium, - &pktmedium, - &nullmedium, - &tripmedium, 0 }; @@ -71,6 +67,21 @@ static void remselfcache(Fs *f, Ipifc *ifc, Iplifc *lifc, uchar *a); static char* ipifcjoinmulti(Ipifc *ifc, char **argv, int argc); static char* ipifcleavemulti(Ipifc *ifc, char **argv, int argc); +/* + * link in a new medium + */ +void +addipmedium(Medium *med) +{ + int i; + + for(i = 0; i < nelem(media)-1; i++) + if(media[i] == nil){ + media[i] = med; + break; + } +} + /* * find the medium with this name */ diff --git a/ip/nullmedium.c b/ip/nullmedium.c index b848d29fbe94574024fcb2ece8c55d427cdc8399..7f44c0f764b8fe839c49151397a935a4885a3830 100644 --- a/ip/nullmedium.c +++ b/ip/nullmedium.c @@ -45,3 +45,9 @@ Medium nullmedium = nil, /* leave multi */ 0, /* don't unbind on last close */ }; + +void +nullmediumlink(void) +{ + addipmedium(&nullmedium); +} diff --git a/ip/pktmedium.c b/ip/pktmedium.c index 6dc1a2ba336232551b66c3324efa10ba8193829b..3f17ec12349f2830f08f8bb7e9ac5bdc71f807be 100644 --- a/ip/pktmedium.c +++ b/ip/pktmedium.c @@ -74,3 +74,9 @@ pktin(Fs *f, Ipifc *ifc, Block *bp) else ipiput(f, ifc->lifc->local, bp); } + +void +pktmediumlink(void) +{ + addipmedium(&pktmedium); +} diff --git a/pc/etherif.h b/pc/etherif.h index cc82e05e5f8dd731866e208b63d8bb11970d1404..271b506b0fca23a14f1e271cad6d0310a7ddc16b 100644 --- a/pc/etherif.h +++ b/pc/etherif.h @@ -6,6 +6,7 @@ enum { typedef struct Ether Ether; struct Ether { ISAConf; /* hardware info */ + int ctlrno; int tbdf; /* type+busno+devno+funcno */ int mbps; /* Mbps */