summaryrefslogtreecommitdiff
path: root/sys/net
diff options
context:
space:
mode:
authorsvn2git <svn2git@FreeBSD.org>1994-05-01 08:00:00 +0000
committersvn2git <svn2git@FreeBSD.org>1994-05-01 08:00:00 +0000
commita16f65c7d117419bd266c28a1901ef129a337569 (patch)
tree2626602f66dc3551e7a7c7bc9ad763c3bc7ab40a /sys/net
parent8503f4f13f77abf7adc8f7e329c6f9c1d52b6a20 (diff)
Diffstat (limited to 'sys/net')
-rw-r--r--sys/net/af.c47
-rw-r--r--sys/net/af.h65
-rw-r--r--sys/net/bpf.c45
-rw-r--r--sys/net/bpf.h6
-rw-r--r--sys/net/bpf_filter.c7
-rw-r--r--sys/net/bpfdesc.h6
-rw-r--r--sys/net/if.c73
-rw-r--r--sys/net/if.h57
-rw-r--r--sys/net/if_arp.h25
-rw-r--r--sys/net/if_dl.h6
-rw-r--r--sys/net/if_ethersubr.c8
-rw-r--r--sys/net/if_llc.h6
-rw-r--r--sys/net/if_loop.c35
-rw-r--r--sys/net/if_ppp.c25
-rw-r--r--sys/net/if_ppp.h6
-rw-r--r--sys/net/if_sl.c97
-rw-r--r--sys/net/if_slvar.h6
-rw-r--r--sys/net/if_tun.c4
-rw-r--r--sys/net/if_types.h6
-rw-r--r--sys/net/netisr.h9
-rw-r--r--sys/net/radix.c17
-rw-r--r--sys/net/radix.h6
-rw-r--r--sys/net/raw_cb.c7
-rw-r--r--sys/net/raw_cb.h17
-rw-r--r--sys/net/raw_usrreq.c10
-rw-r--r--sys/net/route.c39
-rw-r--r--sys/net/route.h32
-rw-r--r--sys/net/rtsock.c78
-rw-r--r--sys/net/slcompress.h6
-rw-r--r--sys/net/slip.h6
30 files changed, 434 insertions, 323 deletions
diff --git a/sys/net/af.c b/sys/net/af.c
deleted file mode 100644
index e7c7a4cd3c18..000000000000
--- a/sys/net/af.c
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Copyright (c) 1983, 1986 Regents of the University of California.
- * 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. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``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 REGENTS OR CONTRIBUTORS 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.
- *
- * from: @(#)af.c 7.6 (Berkeley) 6/28/90
- * $Id: af.c,v 1.2 1993/10/16 17:43:00 rgrimes Exp $
- */
-
-#include "param.h"
-#include "mbuf.h"
-#include "protosw.h"
-#include "socket.h"
-#include "socketvar.h"
-#include "af.h"
-
-/*
- * Nothing in the file should be needed anymore.
- */
-int SocketSizeForInspection = sizeof (struct socket);
diff --git a/sys/net/af.h b/sys/net/af.h
deleted file mode 100644
index e280ef280cd9..000000000000
--- a/sys/net/af.h
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * Copyright (c) 1980, 1986 Regents of the University of California.
- * 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. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``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 REGENTS OR CONTRIBUTORS 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.
- *
- * from: @(#)af.h 7.5 (Berkeley) 6/28/90
- * $Id: af.h,v 1.2 1993/10/16 17:43:01 rgrimes Exp $
- */
-
-/*
- * This file is obsolete, I think. kls 12/21/88
-
- * Address family routines,
- * used in handling generic sockaddr structures.
- *
- * Hash routine is called
- * af_hash(addr, h);
- * struct sockaddr *addr; struct afhash *h;
- * producing an afhash structure for addr.
- *
- * Netmatch routine is called
- * af_netmatch(addr1, addr2);
- * where addr1 and addr2 are sockaddr *. Returns 1 if network
- * values match, 0 otherwise.
-struct afswitch {
- int (*af_hash)();
- int (*af_netmatch)();
-};
-
-struct afhash {
- u_int afh_hosthash;
- u_int afh_nethash;
-};
-
-#ifdef KERNEL
-struct afswitch afswitch[];
-#endif
- */
diff --git a/sys/net/bpf.c b/sys/net/bpf.c
index 981275b112fb..49e628783e2e 100644
--- a/sys/net/bpf.c
+++ b/sys/net/bpf.c
@@ -36,7 +36,7 @@
* SUCH DAMAGE.
*
* from: @(#)bpf.c 7.5 (Berkeley) 7/15/91
- * $Id: bpf.c,v 1.2 1993/10/16 17:43:03 rgrimes Exp $
+ * $Id: bpf.c,v 1.4 1994/01/31 07:34:36 davidg Exp $
*/
#include "bpfilter.h"
@@ -200,6 +200,14 @@ bpf_movein(uio, linktype, mp, sockp)
error = UIOMOVE((caddr_t)sockp->sa_data, hlen, UIO_WRITE, uio);
if (error)
goto bad;
+
+ if (linktype == DLT_EN10MB) {
+ /* Adjust the protocol field. */
+ struct ether_header *eh;
+ eh = (struct ether_header *)sockp->sa_data;
+ eh->ether_type = ntohs(eh->ether_type);
+ }
+
}
error = UIOMOVE(mtod(m, caddr_t), len - hlen, UIO_WRITE, uio);
if (!error)
@@ -1221,41 +1229,6 @@ bpfattach(driverp, ifp, dlt, hdrlen)
printf("bpf: %s%d attached\n", ifp->if_name, ifp->if_unit);
}
-#if BSD >= 199103
-/* XXX This routine belongs in net/if.c. */
-/*
- * Set/clear promiscuous mode on interface ifp based on the truth value
- * of pswitch. The calls are reference counted so that only the first
- * "on" request actually has an effect, as does the final "off" request.
- * Results are undefined if the "off" and "on" requests are not matched.
- */
-int
-ifpromisc(ifp, pswitch)
- struct ifnet *ifp;
- int pswitch;
-{
- struct ifreq ifr;
- /*
- * If the device is not configured up, we cannot put it in
- * promiscuous mode.
- */
- if ((ifp->if_flags & IFF_UP) == 0)
- return (ENETDOWN);
-
- if (pswitch) {
- if (ifp->if_pcount++ != 0)
- return (0);
- ifp->if_flags |= IFF_PROMISC;
- } else {
- if (--ifp->if_pcount > 0)
- return (0);
- ifp->if_flags &= ~IFF_PROMISC;
- }
- ifr.ifr_flags = ifp->if_flags;
- return ((*ifp->if_ioctl)(ifp, SIOCSIFFLAGS, (caddr_t)&ifr));
-}
-#endif
-
#if BSD < 199103
/*
* Allocate some memory for bpf. This is temporary SunOS support, and
diff --git a/sys/net/bpf.h b/sys/net/bpf.h
index 2019f83d90f0..4e27d7ece4ec 100644
--- a/sys/net/bpf.h
+++ b/sys/net/bpf.h
@@ -36,9 +36,12 @@
* SUCH DAMAGE.
*
* from: @(#)bpf.h 7.1 (Berkeley) 5/7/91
- * $Id: bpf.h,v 1.2 1993/10/16 17:43:05 rgrimes Exp $
+ * $Id: bpf.h,v 1.3 1993/11/07 17:46:50 wollman Exp $
*/
+#ifndef _NET_BPF_H_
+#define _NET_BPF_H_ 1
+
/*
* Alignment macros. BPF_WORDALIGN rounds up to the next
* even multiple of BPF_ALIGNMENT.
@@ -241,3 +244,4 @@ extern void bpf_mtap();
*/
#define BPF_MEMWORDS 16
+#endif /* _NET_BPF_H_ */
diff --git a/sys/net/bpf_filter.c b/sys/net/bpf_filter.c
index c8fb0bb06262..833eb88451ee 100644
--- a/sys/net/bpf_filter.c
+++ b/sys/net/bpf_filter.c
@@ -36,10 +36,13 @@
* SUCH DAMAGE.
*
* from: @(#)bpf.c 7.5 (Berkeley) 7/15/91
- * $Id: bpf_filter.c,v 1.2 1993/10/16 17:43:07 rgrimes Exp $
+ * $Id: bpf_filter.c,v 1.4 1993/12/19 00:51:58 wollman Exp $
*/
#include <sys/param.h>
+#ifdef KERNEL
+#include "systm.h"
+#endif
#include <sys/types.h>
#include <sys/time.h>
#include <net/bpf.h>
@@ -172,7 +175,7 @@ bpf_filter(pc, p, wirelen, buflen)
u_int wirelen;
register u_int buflen;
{
- register u_long A, X;
+ register u_long A = 0, X = 0;
register int k;
long mem[BPF_MEMWORDS];
diff --git a/sys/net/bpfdesc.h b/sys/net/bpfdesc.h
index 9313b3208494..f684e30dbbe1 100644
--- a/sys/net/bpfdesc.h
+++ b/sys/net/bpfdesc.h
@@ -36,9 +36,12 @@
* SUCH DAMAGE.
*
* from: @(#)bpfdesc.h 7.1 (Berkeley) 5/7/91
- * $Id: bpfdesc.h,v 1.2 1993/10/16 17:43:09 rgrimes Exp $
+ * $Id: bpfdesc.h,v 1.3 1993/11/07 17:46:51 wollman Exp $
*/
+#ifndef _NET_BPFDESC_H_
+#define _NET_BPFDESC_H_ 1
+
/*
* Descriptor associated with each open bpf file.
*/
@@ -86,3 +89,4 @@ struct bpf_if {
u_int bif_hdrlen; /* length of header (with padding) */
struct ifnet *bif_ifp; /* correspoding interface */
};
+#endif /* _NET_BPFDESC_H_ */
diff --git a/sys/net/if.c b/sys/net/if.c
index fb2ed43d37a0..fc51448e9ef5 100644
--- a/sys/net/if.c
+++ b/sys/net/if.c
@@ -31,7 +31,7 @@
* SUCH DAMAGE.
*
* from: @(#)if.c 7.14 (Berkeley) 4/20/91
- * $Id: if.c,v 1.4 1993/10/16 17:43:10 rgrimes Exp $
+ * $Id: if.c,v 1.7 1993/12/19 00:52:00 wollman Exp $
*/
#include "param.h"
@@ -45,13 +45,18 @@
#include "ioctl.h"
#include "if.h"
-#include "af.h"
#include "if_dl.h"
#include "if_types.h"
#include "ether.h"
int ifqmaxlen = IFQ_MAXLEN;
+struct ifqueue rawintrq; /* raw packet input queue */
+struct ifnet *ifnet; /* list of configured interfaces */
+
+static void link_rtrequest(int, struct rtentry *, struct sockaddr *);
+static void if_qflush(struct ifqueue *);
+static void if_slowtimo(caddr_t, int);
/*
* Network interface utility routines.
@@ -60,6 +65,7 @@ int ifqmaxlen = IFQ_MAXLEN;
* parameters.
*/
+void
ifinit()
{
register struct ifnet *ifp;
@@ -67,7 +73,7 @@ ifinit()
for (ifp = ifnet; ifp; ifp = ifp->if_next)
if (ifp->if_snd.ifq_maxlen == 0)
ifp->if_snd.ifq_maxlen = ifqmaxlen;
- if_slowtimo();
+ if_slowtimo((caddr_t)0, 0);
}
#ifdef vax
@@ -93,6 +99,7 @@ static char *sprint_d();
* Attach an interface to the
* list of "active" interfaces.
*/
+void
if_attach(ifp)
struct ifnet *ifp;
{
@@ -103,7 +110,6 @@ if_attach(ifp)
register struct sockaddr_dl *sdl;
register struct ifaddr *ifa;
static int if_indexlim = 8;
- extern link_rtrequest(), ether_output();
while (*p)
p = &((*p)->if_next);
@@ -119,14 +125,7 @@ if_attach(ifp)
}
ifnet_addrs = q;
}
-#if defined(INET) && NETHER > 0
- /* XXX -- Temporary fix before changing 10 ethernet drivers */
- if (ifp->if_output == ether_output) {
- ifp->if_type = IFT_ETHER;
- ifp->if_addrlen = 6;
- ifp->if_hdrlen = 14;
- }
-#endif
+
/*
* create a Link Level name for this device
*/
@@ -311,9 +310,11 @@ ifaof_ifpforaddr(addr, ifp)
* Lookup an appropriate real ifa to point to.
* This should be moved to /sys/net/link.c eventually.
*/
+void
link_rtrequest(cmd, rt, sa)
-register struct rtentry *rt;
-struct sockaddr *sa;
+ int cmd;
+ register struct rtentry *rt;
+ struct sockaddr *sa;
{
register struct ifaddr *ifa;
struct sockaddr *dst;
@@ -334,6 +335,7 @@ struct sockaddr *sa;
* the transition.
* NOTE: must be called at splnet or eqivalent.
*/
+void
if_down(ifp)
register struct ifnet *ifp;
{
@@ -348,6 +350,7 @@ if_down(ifp)
/*
* Flush an interface queue.
*/
+static void
if_qflush(ifq)
register struct ifqueue *ifq;
{
@@ -368,7 +371,8 @@ if_qflush(ifq)
* from softclock, we decrement timers (if set) and
* call the appropriate interface routine on expiration.
*/
-if_slowtimo()
+static void
+if_slowtimo(caddr_t dummy1, int dummy2)
{
register struct ifnet *ifp;
int s = splimp();
@@ -426,6 +430,7 @@ ifunit(name)
/*
* Interface ioctls.
*/
+int
ifioctl(so, cmd, data, p)
struct socket *so;
int cmd;
@@ -540,7 +545,10 @@ ifioctl(so, cmd, data, p)
cmd = SIOCGIFNETMASK;
}
error = ((*so->so_proto->pr_usrreq)(so, PRU_CONTROL,
- cmd, data, ifp));
+ (struct mbuf *)cmd,
+ (struct mbuf *)data,
+ (struct mbuf *)ifp,
+ (struct mbuf *)0));
switch (ocmd) {
case OSIOCGIFADDR:
@@ -564,6 +572,7 @@ ifioctl(so, cmd, data, p)
* other information.
*/
/*ARGSUSED*/
+int
ifconf(cmd, data)
int cmd;
caddr_t data;
@@ -644,3 +653,35 @@ sprint_d(n, buf, buflen)
} while (n != 0);
return (cp);
}
+
+/*
+ * Set/clear promiscuous mode on interface ifp based on the truth value
+ * of pswitch. The calls are reference counted so that only the first
+ * "on" request actually has an effect, as does the final "off" request.
+ * Results are undefined if the "off" and "on" requests are not matched.
+ */
+int
+ifpromisc(ifp, pswitch)
+ struct ifnet *ifp;
+ int pswitch;
+{
+ struct ifreq ifr;
+ /*
+ * If the device is not configured up, we cannot put it in
+ * promiscuous mode.
+ */
+ if ((ifp->if_flags & IFF_UP) == 0)
+ return (ENETDOWN);
+
+ if (pswitch) {
+ if (ifp->if_pcount++ != 0)
+ return (0);
+ ifp->if_flags |= IFF_PROMISC;
+ } else {
+ if (--ifp->if_pcount > 0)
+ return (0);
+ ifp->if_flags &= ~IFF_PROMISC;
+ }
+ ifr.ifr_flags = ifp->if_flags;
+ return ((*ifp->if_ioctl)(ifp, SIOCSIFFLAGS, (caddr_t)&ifr));
+}
diff --git a/sys/net/if.h b/sys/net/if.h
index 310f9c069674..e1d7f316b04a 100644
--- a/sys/net/if.h
+++ b/sys/net/if.h
@@ -31,9 +31,12 @@
* SUCH DAMAGE.
*
* from: @(#)if.h 7.11 (Berkeley) 3/19/91
- * $Id: if.h,v 1.5 1993/10/16 17:43:12 rgrimes Exp $
+ * $Id: if.h,v 1.11 1993/12/19 00:52:02 wollman Exp $
*/
+#ifndef _NET_IF_H_
+#define _NET_IF_H_ 1
+
/*
* Structures defining a network interface, providing a packet
* transport mechanism (ala level 0 of the PUP protocols).
@@ -72,10 +75,12 @@
* (Would like to call this struct ``if'', but C isn't PL/1.)
*/
+struct rtentry;
+
struct ifnet {
char *if_name; /* name, e.g. ``en'' or ``lo'' */
short if_unit; /* sub-unit for lower level driver */
- short if_mtu; /* maximum transmission unit */
+ u_short if_mtu; /* maximum transmission unit */
short if_flags; /* up/down, broadcast, etc. */
short if_timer; /* time 'til if_watchdog called */
int if_metric; /* routing metric (external only) */
@@ -88,13 +93,14 @@ struct ifnet {
int ifq_drops;
} if_snd; /* output queue */
/* procedure handles */
- int (*if_init)(); /* init routine */
- int (*if_output)(); /* output routine (enqueue) */
- int (*if_start)(); /* initiate output routine */
- int (*if_done)(); /* output complete routine */
- int (*if_ioctl)(); /* ioctl routine */
- int (*if_reset)(); /* bus reset routine */
- int (*if_watchdog)(); /* timer routine */
+ void (*if_init)(int); /* init routine */
+ int (*if_output)(struct ifnet *, struct mbuf *, struct sockaddr *,
+ struct rtentry *); /* output routine (enqueue) */
+ void (*if_start)(struct ifnet *); /* initiate output routine */
+ int (*if_done)(struct ifnet *); /* output complete routine */
+ int (*if_ioctl)(struct ifnet *, int, caddr_t); /* ioctl routine */
+ void (*if_reset)(int, int); /* bus reset routine */
+ void (*if_watchdog)(int); /* timer routine */
/* generic interface statistics */
int if_ipackets; /* packets received on interface */
int if_ierrors; /* input errors on interface */
@@ -132,13 +138,17 @@ struct ifnet {
#define IFF_ALLMULTI 0x200 /* receive all multicast packets */
#define IFF_OACTIVE 0x400 /* transmission in progress */
#define IFF_SIMPLEX 0x800 /* can't hear own transmissions */
-#define IFF_LLC0 0x1000 /* interface driver control/status */
-#define IFF_LLC1 0x2000 /* interface driver control/status */
-#define IFF_LLC2 0x4000 /* interface driver control/status */
+#define IFF_LLC0 0x1000 /* IEEE 802.2 LLC class 0 */
+#define IFF_LLC1 0x2000 /* IEEE 802.2 LLC class 1 */
+#define IFF_LLC2 0x4000 /* IEEE 802.2 LLC class 2 */
+#define IFF_ALTPHYS 0x8000 /* alternative physical connection */
+#define IFF_MULTICAST 0x10000 /* i'face supports multicast */
+#define IFF_VIRTUAL 0x20000 /* i'face is really a VIF */
/* flags set internally only: */
#define IFF_CANTCHANGE \
- (IFF_BROADCAST|IFF_POINTOPOINT|IFF_RUNNING|IFF_OACTIVE|IFF_SIMPLEX)
+ (IFF_BROADCAST|IFF_POINTOPOINT|IFF_RUNNING|IFF_OACTIVE|IFF_SIMPLEX\
+ |IFF_MULTICAST|IFF_VIRTUAL)
/*
* Output queues (ifp->if_snd) and internetwork datagram level (pup level 1)
@@ -183,6 +193,8 @@ struct ifnet {
* are allocated and attached when an address is set, and are linked
* together so all addresses for an interface can be located.
*/
+struct rtentry;
+
struct ifaddr {
struct sockaddr *ifa_addr; /* address of interface */
struct sockaddr *ifa_dstaddr; /* other end of p-to-p link */
@@ -190,7 +202,8 @@ struct ifaddr {
struct sockaddr *ifa_netmask; /* used to determine subnet */
struct ifnet *ifa_ifp; /* back-pointer to interface */
struct ifaddr *ifa_next; /* next address for interface */
- int (*ifa_rtrequest)(); /* check or clean routes (+ or -)'d */
+ void (*ifa_rtrequest)(int, struct rtentry *, struct sockaddr *);
+ /* check or clean routes (+ or -)'d */
struct rtentry *ifa_rt; /* ??? for ROUTETOIF */
u_short ifa_flags; /* mostly rt_flags for cloning */
u_short ifa_llinfolen; /* extra to malloc for link info */
@@ -246,10 +259,18 @@ struct ifconf {
#ifdef KERNEL
#include "../net/if_arp.h"
-struct ifqueue rawintrq; /* raw packet input queue */
-struct ifnet *ifnet;
+extern struct ifqueue rawintrq; /* raw packet input queue */
+extern struct ifnet *ifnet;
struct ifaddr *ifa_ifwithaddr(), *ifa_ifwithnet();
struct ifaddr *ifa_ifwithdstaddr();
-#else KERNEL
+extern int ifpromisc(struct ifnet *, int);
+
+/* Loopback interface, used internally by non-loopback code */
+extern struct ifnet loif;
+extern int looutput(struct ifnet *, struct mbuf *, struct sockaddr *,
+ struct rtentry *);
+
+#else /* KERNEL */
#include <net/if_arp.h>
-#endif KERNEL
+#endif /* KERNEL */
+#endif /* _NET_IF_H_ */
diff --git a/sys/net/if_arp.h b/sys/net/if_arp.h
index 37c3f8711174..2468c7327900 100644
--- a/sys/net/if_arp.h
+++ b/sys/net/if_arp.h
@@ -31,9 +31,12 @@
* SUCH DAMAGE.
*
* from: @(#)if_arp.h 7.4 (Berkeley) 6/28/90
- * $Id: if_arp.h,v 1.2 1993/10/16 17:43:13 rgrimes Exp $
+ * $Id: if_arp.h,v 1.5 1993/11/25 01:34:00 wollman Exp $
*/
+#ifndef _NET_IF_ARP_H_
+#define _NET_IF_ARP_H_ 1
+
/*
* Address Resolution Protocol.
*
@@ -57,10 +60,10 @@ struct arphdr {
* The remaining fields are variable in size,
* according to the sizes above.
*/
-/* u_char ar_sha[]; /* sender hardware address */
-/* u_char ar_spa[]; /* sender protocol address */
-/* u_char ar_tha[]; /* target hardware address */
-/* u_char ar_tpa[]; /* target protocol address */
+/* u_char ar_sha[];*/ /* sender hardware address */
+/* u_char ar_spa[];*/ /* sender protocol address */
+/* u_char ar_tha[];*/ /* target hardware address */
+/* u_char ar_tpa[];*/ /* target protocol address */
};
/*
@@ -71,9 +74,21 @@ struct arpreq {
struct sockaddr arp_ha; /* hardware address */
int arp_flags; /* flags */
};
+
/* arp_flags and at_flags field values */
#define ATF_INUSE 0x01 /* entry in use */
#define ATF_COM 0x02 /* completed entry (enaddr valid) */
#define ATF_PERM 0x04 /* permanent entry */
#define ATF_PUBL 0x08 /* publish entry (respond for other host) */
#define ATF_USETRAILERS 0x10 /* has requested trailers */
+
+/*
+ * This doesn't really belong here, but there is no obvious other place
+ * to put it that will get seen by every client...
+ */
+struct mbuf; struct sockaddr; struct ifnet; struct rtentry;
+
+extern int
+ether_output(struct ifnet *, struct mbuf*, struct sockaddr*, struct rtentry *);
+
+#endif /* _NET_IF_ARP_H_ */
diff --git a/sys/net/if_dl.h b/sys/net/if_dl.h
index 4793bcb2a828..69f7c7cc8186 100644
--- a/sys/net/if_dl.h
+++ b/sys/net/if_dl.h
@@ -31,9 +31,12 @@
* SUCH DAMAGE.
*
* from: @(#)if_dl.h 7.2 (Berkeley) 2/22/91
- * $Id: if_dl.h,v 1.2 1993/10/16 17:43:15 rgrimes Exp $
+ * $Id: if_dl.h,v 1.3 1993/11/07 17:46:57 wollman Exp $
*/
+#ifndef _NET_IF_DL_H_
+#define _NET_IF_DL_H_ 1
+
/*
* A Link-Level Sockaddr may specify the interface in one of two
* ways: either by means of a system-provided index number (computed
@@ -79,3 +82,4 @@ char *link_ntoa __P((const struct sockaddr_dl *));
__END_DECLS
#endif /* !KERNEL */
+#endif /* _NET_IF_DL_H_ */
diff --git a/sys/net/if_ethersubr.c b/sys/net/if_ethersubr.c
index a3f76dbfa7ce..348d51dd148f 100644
--- a/sys/net/if_ethersubr.c
+++ b/sys/net/if_ethersubr.c
@@ -31,7 +31,7 @@
* SUCH DAMAGE.
*
* from: @(#)if_ethersubr.c 7.13 (Berkeley) 4/20/91
- * $Id: if_ethersubr.c,v 1.3 1993/10/16 17:43:16 rgrimes Exp $
+ * $Id: if_ethersubr.c,v 1.4 1993/11/25 01:34:02 wollman Exp $
*/
#include "param.h"
@@ -81,6 +81,7 @@ extern struct ifnet loif;
* packet leaves a multiple of 512 bytes of data in remainder.
* Assumes that ifp is actually pointer to arpcom structure.
*/
+int
ether_output(ifp, m0, dst, rt)
register struct ifnet *ifp;
struct mbuf *m0;
@@ -280,6 +281,7 @@ bad:
* the packet is in the mbuf chain m without
* the ether header, which is provided separately.
*/
+void
ether_input(ifp, eh, m)
struct ifnet *ifp;
register struct ether_header *eh;
@@ -376,7 +378,7 @@ ether_input(ifp, eh, m)
eh->ether_dhost[i] = eh->ether_shost[i];
eh->ether_shost[i] = c;
}
- ifp->if_output(ifp, m, &sa);
+ ifp->if_output(ifp, m, &sa, (struct rtentry *)0);
return;
}
dropanyway:
@@ -387,7 +389,7 @@ ether_input(ifp, eh, m)
#else
m_freem(m);
return;
-#endif ISO
+#endif /* ISO */
}
s = splimp();
diff --git a/sys/net/if_llc.h b/sys/net/if_llc.h
index a672be41a3d1..93352e79effc 100644
--- a/sys/net/if_llc.h
+++ b/sys/net/if_llc.h
@@ -31,9 +31,12 @@
* SUCH DAMAGE.
*
* from: @(#)if_llc.h 7.2 (Berkeley) 6/28/90
- * $Id: if_llc.h,v 1.2 1993/10/16 17:43:17 rgrimes Exp $
+ * $Id: if_llc.h,v 1.3 1993/11/07 17:46:58 wollman Exp $
*/
+#ifndef _NET_IF_LLC_H_
+#define _NET_IF_LLC_H_ 1
+
/*
* IEEE 802.2 Link Level Control headers, for use in conjunction with
* 802.{3,4,5} media access control methods.
@@ -81,3 +84,4 @@ struct llc {
#define LLC_ISO_LSAP 0xfe
#define LLC_SNAP_LSAP 0xaa
+#endif /* _NET_IF_LLC_H_ */
diff --git a/sys/net/if_loop.c b/sys/net/if_loop.c
index 40492d421843..163712a66fd1 100644
--- a/sys/net/if_loop.c
+++ b/sys/net/if_loop.c
@@ -31,7 +31,7 @@
* SUCH DAMAGE.
*
* from: @(#)if_loop.c 7.13 (Berkeley) 4/26/91
- * $Id: if_loop.c,v 1.2 1993/10/16 17:43:19 rgrimes Exp $
+ * $Id: if_loop.c,v 1.6 1993/12/20 19:31:29 wollman Exp $
*/
/*
@@ -44,6 +44,7 @@
#include "socket.h"
#include "errno.h"
#include "ioctl.h"
+#include "kernel.h"
#include "../net/if.h"
#include "../net/if_types.h"
@@ -71,17 +72,24 @@
#include "bpfilter.h"
#if NBPFILTER > 0
-#include <sys/time.h>
-#include <net/bpf.h>
+#include "sys/time.h"
+#include "net/bpf.h"
static caddr_t lo_bpf;
#endif
+#ifdef TINY_LOMTU
#define LOMTU (1024+512)
+#else /* reasonable MTU */
+#define LOMTU 65535 /* maximum MTU for IP */
+#endif /* reasonable MTU */
struct ifnet loif;
-int looutput(), loioctl();
+int looutput(struct ifnet *, struct mbuf *, struct sockaddr *, struct rtentry *);
+int loioctl(struct ifnet *, int, caddr_t);
+void lortrequest(int, struct rtentry *, struct sockaddr *);
-loattach()
+void
+loattach(void)
{
register struct ifnet *ifp = &loif;
@@ -99,6 +107,9 @@ loattach()
#endif
}
+TEXT_SET(pseudo_set, loattach);
+
+int
looutput(ifp, m, dst, rt)
struct ifnet *ifp;
register struct mbuf *m;
@@ -179,18 +190,26 @@ looutput(ifp, m, dst, rt)
}
/* ARGSUSED */
+void
lortrequest(cmd, rt, sa)
-struct rtentry *rt;
-struct sockaddr *sa;
+ int cmd;
+ struct rtentry *rt;
+ struct sockaddr *sa;
{
- if (rt)
+ if (rt) {
+#ifdef DEBUG
+ printf("lo0: lortrequest: setting route MTU to %u\n",
+ LOMTU);
+#endif
rt->rt_rmx.rmx_mtu = LOMTU;
+ }
}
/*
* Process an ioctl request.
*/
/* ARGSUSED */
+int
loioctl(ifp, cmd, data)
register struct ifnet *ifp;
int cmd;
diff --git a/sys/net/if_ppp.c b/sys/net/if_ppp.c
index 1baa79659136..efda46dbe54a 100644
--- a/sys/net/if_ppp.c
+++ b/sys/net/if_ppp.c
@@ -70,7 +70,7 @@
*/
/*
- * $Id: if_ppp.c,v 1.4 1993/10/07 02:19:37 rgrimes Exp $
+ * $Id: if_ppp.c,v 1.7 1993/12/20 19:31:30 wollman Exp $
* From: if_ppp.c,v 1.22 1993/08/31 23:20:40 paulus Exp
* From: if_ppp.c,v 1.21 1993/08/29 11:22:37 paulus Exp
* From: if_sl.c,v 1.11 84/10/04 12:54:47 rick Exp
@@ -85,14 +85,13 @@
#include "systm.h"
#include "proc.h"
#include "mbuf.h"
-#include "buf.h"
-#include "dkstat.h"
#include "socket.h"
#include "ioctl.h"
#include "file.h"
#include "tty.h"
#include "kernel.h"
#include "conf.h"
+#include "dkstat.h"
#include "if.h"
#include "if_types.h"
@@ -155,7 +154,7 @@ int pppread __P((struct tty *tp, struct uio *uio, int flag));
int pppwrite __P((struct tty *tp, struct uio *uio, int flag));
int ppptioctl __P((struct tty *tp, int cmd, caddr_t data, int flag));
int pppoutput __P((struct ifnet *ifp, struct mbuf *m0,
- struct sockaddr *dst));
+ struct sockaddr *dst, struct rtentry *rt));
void pppstart __P((struct tty *tp));
void pppinput __P((int c, struct tty *tp));
int pppioctl __P((struct ifnet *ifp, int cmd, caddr_t data));
@@ -223,6 +222,8 @@ pppattach()
}
}
+TEXT_SET(pseudo_set, pppattach);
+
/*
* Line specific open routine.
* Attach the given tty to the first available ppp unit.
@@ -252,7 +253,7 @@ pppopen(dev, tp)
sc->sc_flags = 0;
sc->sc_ilen = 0;
- sc->sc_asyncmap = 0xffffffff;
+ sc->sc_asyncmap = ~0;
sc->sc_rasyncmap = 0;
sc->sc_mru = PPP_MRU;
#ifdef VJC
@@ -344,7 +345,7 @@ pppread(tp, uio, flag)
register struct ppp_softc *sc = (struct ppp_softc *)tp->t_sc;
struct mbuf *m, *m0;
register int s;
- int error;
+ int error = 0;
if ((tp->t_state & TS_CARR_ON)==0)
return (EIO);
@@ -420,7 +421,7 @@ pppwrite(tp, uio, flag)
*ph1 = *ph2;
m0->m_data += PPP_HEADER_LEN;
m0->m_len -= PPP_HEADER_LEN;
- return (pppoutput(&sc->sc_if, m0, &dst));
+ return (pppoutput(&sc->sc_if, m0, &dst, 0));
}
/*
@@ -569,10 +570,11 @@ pppfcs(fcs, cp, len)
* Packet is placed in Information field of PPP frame.
*/
int
-pppoutput(ifp, m0, dst)
- struct ifnet *ifp;
- struct mbuf *m0;
- struct sockaddr *dst;
+pppoutput(ifp, m0, dst, rt)
+ struct ifnet *ifp;
+ struct mbuf *m0;
+ struct sockaddr *dst;
+ struct rtentry *rt;
{
register struct ppp_softc *sc = &ppp_softc[ifp->if_unit];
struct ppp_header *ph;
@@ -1330,6 +1332,7 @@ pppinput(c, tp)
/*
* Process an ioctl request to interface.
*/
+int
pppioctl(ifp, cmd, data)
register struct ifnet *ifp;
int cmd;
diff --git a/sys/net/if_ppp.h b/sys/net/if_ppp.h
index adc3fd52d3fe..e3801d34aff1 100644
--- a/sys/net/if_ppp.h
+++ b/sys/net/if_ppp.h
@@ -19,10 +19,13 @@
* Modified by Paul Mackerras (paulus@cs.anu.edu.au)
* Added PPP_MRU, sc_outm, sc_fastq, sc_bpf.
*
- * $Id: if_ppp.h,v 1.2 1993/08/31 05:40:38 rgrimes Exp $
+ * $Id: if_ppp.h,v 1.3 1993/11/07 17:46:59 wollman Exp $
* From: if_ppp.h,v 1.4 1993/08/29 11:22:37 paulus Exp $
*/
+#ifndef _NET_IF_PPP_H_
+#define _NET_IF_PPP_H_ 1
+
/*
* Standard PPP header.
*/
@@ -117,3 +120,4 @@ struct ppp_softc {
#define ifr_mtu ifr_metric
#endif
+#endif /* _NET_IF_PPP_H_ */
diff --git a/sys/net/if_sl.c b/sys/net/if_sl.c
index 3b02c15e768a..223281337a53 100644
--- a/sys/net/if_sl.c
+++ b/sys/net/if_sl.c
@@ -31,7 +31,7 @@
* SUCH DAMAGE.
*
* from: @(#)if_sl.c 7.22 (Berkeley) 4/20/91
- * $Id: if_sl.c,v 1.4 1993/10/16 17:43:20 rgrimes Exp $
+ * $Id: if_sl.c,v 1.7 1993/12/20 19:31:32 wollman Exp $
*/
/*
@@ -65,7 +65,7 @@
* interrupts and network activity; thus, splimp must be >= spltty.
*/
-/* $Header: /a/cvs/386BSD/src/sys/net/if_sl.c,v 1.4 1993/10/16 17:43:20 rgrimes Exp $ */
+/* $Id: if_sl.c,v 1.7 1993/12/20 19:31:32 wollman Exp $ */
/* from if_sl.c,v 1.11 84/10/04 12:54:47 rick Exp */
#include "sl.h"
@@ -73,6 +73,7 @@
#include "param.h"
#include "systm.h"
+#include "kernel.h" /* sigh */
#include "proc.h"
#include "mbuf.h"
#include "buf.h"
@@ -94,7 +95,7 @@
#include "netinet/in_var.h"
#include "netinet/ip.h"
#else
-Huh? Slip without inet?
+#error "Huh? Slip without inet?"
#endif
#include "machine/mtpr.h"
@@ -105,8 +106,8 @@ Huh? Slip without inet?
#include "bpfilter.h"
#if NBPFILTER > 0
-#include <sys/time.h>
-#include <net/bpf.h>
+#include "sys/time.h"
+#include "net/bpf.h"
#endif
/*
@@ -156,7 +157,24 @@ Huh? Slip without inet?
#endif
#define SLMAX (MCLBYTES - BUFOFFSET)
#define SLBUFSIZE (SLMAX + BUFOFFSET)
-#define SLMTU 296
+
+#ifdef experimental
+/*
+ * In this code, the SLMTU is the actual interface MTU as advertised
+ * in our ifnet structures. SLRMTU is the MTU we stick into routes
+ * via slrtrequest() to tell TCP to produce small packets.
+ */
+#ifndef SLMTU
+#define SLMTU 1500 /* same as Ethernet */
+#endif
+#ifndef SLRMTU
+#define SLRMTU 296 /* for good latency */
+#endif
+#else
+#define SLMTU 296
+#define SLRMTU SLMTU
+#endif
+
#define SLIP_HIWAT roundup(50,CBSIZE)
/*
@@ -195,13 +213,26 @@ struct sl_softc sl_softc[NSL];
#define t_sc T_LINEP
-int sloutput(), slioctl(), ttrstrt();
-extern struct timeval time;
+/*
+ * Prototypes.
+ */
+void slattach(void);
+static int slinit(struct sl_softc *);
+int slopen(int /*dev_t*/, struct tty *);
+int slclose(struct tty *);
+int sltioctl(struct tty *, int, caddr_t, int);
+int sloutput(struct ifnet *, struct mbuf *, struct sockaddr *, struct rtentry *);
+void slstart(struct tty *);
+static struct mbuf *sl_btom(struct sl_softc *, int);
+void slinput(int, struct tty *);
+static int slrtrequest(int, struct rtentry *, struct sockaddr *);
+int slioctl(struct ifnet *, int, caddr_t);
/*
* Called from boot code to establish sl interfaces.
*/
-slattach()
+void
+slattach(void)
{
register struct sl_softc *sc;
register int i = 0;
@@ -211,6 +242,13 @@ slattach()
sc->sc_if.if_unit = i++;
sc->sc_if.if_mtu = SLMTU;
sc->sc_if.if_flags = IFF_POINTOPOINT;
+ /*
+ * Multicast support is trivial for point-to-point
+ * netifs.
+ */
+#ifdef MULTICAST
+ sc->sc_if.if_flags |= IFF_MULTICAST;
+#endif
sc->sc_if.if_type = IFT_SLIP;
sc->sc_if.if_ioctl = slioctl;
sc->sc_if.if_output = sloutput;
@@ -224,6 +262,8 @@ slattach()
}
}
+TEXT_SET(pseudo_set, slattach);
+
static int
slinit(sc)
register struct sl_softc *sc;
@@ -251,6 +291,7 @@ slinit(sc)
* Attach the given tty to the first available sl unit.
*/
/* ARGSUSED */
+int
slopen(dev, tp)
dev_t dev;
register struct tty *tp;
@@ -284,6 +325,7 @@ slopen(dev, tp)
* Detach the tty from the sl unit.
* Mimics part of ttyclose().
*/
+int
slclose(tp)
struct tty *tp;
{
@@ -304,6 +346,7 @@ slclose(tp)
sc->sc_buf = 0;
}
splx(s);
+ return 0;
}
/*
@@ -311,9 +354,12 @@ slclose(tp)
* Provide a way to get the sl unit number.
*/
/* ARGSUSED */
+int
sltioctl(tp, cmd, data, flag)
struct tty *tp;
+ int cmd;
caddr_t data;
+ int flag;
{
struct sl_softc *sc = (struct sl_softc *)tp->t_sc;
int s;
@@ -344,10 +390,12 @@ sltioctl(tp, cmd, data, flag)
/*
* Queue a packet. Start transmission if not active.
*/
-sloutput(ifp, m, dst)
+int
+sloutput(ifp, m, dst, rt)
struct ifnet *ifp;
register struct mbuf *m;
struct sockaddr *dst;
+ struct rtentry *rt;
{
register struct sl_softc *sc = &sl_softc[ifp->if_unit];
register struct ip *ip;
@@ -408,6 +456,7 @@ sloutput(ifp, m, dst)
* to send from the interface queue and map it to
* the interface before starting output.
*/
+void
slstart(tp)
register struct tty *tp;
{
@@ -419,7 +468,7 @@ slstart(tp)
struct mbuf *m2;
#if NBPFILTER > 0
u_char bpfbuf[SLMTU + SLIP_HDRLEN];
- register int len;
+ register int len = 0;
#endif
for (;;) {
@@ -630,6 +679,7 @@ sl_btom(sc, len)
/*
* tty interface receiver interrupt.
*/
+void
slinput(c, tp)
register int c;
register struct tty *tp;
@@ -794,9 +844,25 @@ newpack:
sc->sc_escape = 0;
}
+#ifdef experimental
+/*
+ * Get a route change request.
+ * We fill in the MTU and lock it so that MTU discovery won't try
+ * to change it back to the interface MTU.
+ */
+static int
+slrtrequest(int cmd, struct rtentry *rt, struct sockaddr *gate) {
+ if(rt) {
+ rt->rt_rmx.rmx_mtu = SLRMTU;
+ rt->rt_rmx.rmx_locks |= RTV_MTU;
+ }
+}
+#endif
+
/*
* Process an ioctl request.
*/
+int
slioctl(ifp, cmd, data)
register struct ifnet *ifp;
int cmd;
@@ -807,11 +873,16 @@ slioctl(ifp, cmd, data)
switch (cmd) {
+ case SIOCAIFADDR:
case SIOCSIFADDR:
- if (ifa->ifa_addr->sa_family == AF_INET)
+ if (ifa->ifa_addr->sa_family == AF_INET) {
ifp->if_flags |= IFF_UP;
- else
+#ifdef experimental
+ ifa->ifa_rtrequest = slrtrequest;
+#endif
+ } else {
error = EAFNOSUPPORT;
+ }
break;
case SIOCSIFDSTADDR:
diff --git a/sys/net/if_slvar.h b/sys/net/if_slvar.h
index 0121927411db..94e4773b8b08 100644
--- a/sys/net/if_slvar.h
+++ b/sys/net/if_slvar.h
@@ -31,9 +31,12 @@
* SUCH DAMAGE.
*
* from: @(#)if_slvar.h 7.7 (Berkeley) 5/7/91
- * $Id: if_slvar.h,v 1.2 1993/10/16 17:43:22 rgrimes Exp $
+ * $Id: if_slvar.h,v 1.3 1993/11/07 17:47:00 wollman Exp $
*/
+#ifndef _NET_IF_SLVAR_H_
+#define _NET_IF_SLVAR_H_ 1
+
/*
* Definitions for SLIP interface data structures
*
@@ -72,3 +75,4 @@ struct sl_softc {
#define SLIOCGFLAGS _IOR('t', 90, int) /* get configuration flags */
#define SLIOCSFLAGS _IOW('t', 89, int) /* set configuration flags */
#define SLIOCGUNIT _IOR('t', 88, int) /* get slip unit number */
+#endif /* _NET_IF_SLVAR_H_ */
diff --git a/sys/net/if_tun.c b/sys/net/if_tun.c
index 11eaa7f24cd5..eb390b75f6b2 100644
--- a/sys/net/if_tun.c
+++ b/sys/net/if_tun.c
@@ -7,7 +7,7 @@
* from: Revision 1.13 88/07/11 08:28:51 jpo
* from: 90/02/06 15:03 - Fixed a bug in where
* TIOCGPGRP and TIOCSPGRP were mixed up
- * $Id: if_tun.c,v 1.2 1993/10/16 17:43:24 rgrimes Exp $
+ * $Id: if_tun.c,v 1.3 1993/11/07 21:47:52 wollman Exp $
*/
/* if_tun.c - tunnel interface module & driver */
@@ -429,7 +429,7 @@ struct uio *uio;
return EWOULDBLOCK;
}
tp->tun_flags |= TUN_RWAIT;
- sleep ((caddr_t) tp, PZERO + 1);
+ tsleep ((caddr_t) tp, PZERO + 1, "tunread", 0);
}
} while (m0 == 0);
splx (s);
diff --git a/sys/net/if_types.h b/sys/net/if_types.h
index a6ee046052c0..d45708f4e9b7 100644
--- a/sys/net/if_types.h
+++ b/sys/net/if_types.h
@@ -31,9 +31,12 @@
* SUCH DAMAGE.
*
* from: @(#)if_types.h 7.3 (Berkeley) 6/28/90
- * $Id: if_types.h,v 1.3 1993/10/16 17:43:25 rgrimes Exp $
+ * $Id: if_types.h,v 1.4 1993/11/07 17:47:01 wollman Exp $
*/
+#ifndef _NET_IF_TYPES_H_
+#define _NET_IF_TYPES_H_ 1
+
/* interface types for benefit of parsing media address headers */
#define IFT_OTHER 0x1 /* none of the following */
@@ -64,3 +67,4 @@
#define IFT_NSIP 0x1b /* XNS over IP */
#define IFT_SLIP 0x1c /* IP over generic TTY */
#define IFT_PPP 0x1d /* PPP over generic TTY */
+#endif /* _NET_IF_TYPES_H_ */
diff --git a/sys/net/netisr.h b/sys/net/netisr.h
index e2962cf77979..b543791db6fb 100644
--- a/sys/net/netisr.h
+++ b/sys/net/netisr.h
@@ -31,9 +31,12 @@
* SUCH DAMAGE.
*
* from: @(#)netisr.h 7.8 (Berkeley) 5/7/91
- * $Id: netisr.h,v 1.2.2.1 1993/11/14 18:51:06 rgrimes Exp $
+ * $Id: netisr.h,v 1.5 1993/12/20 14:58:31 wollman Exp $
*/
+#ifndef _NET_NETISR_H_
+#define _NET_NETISR_H_ 1
+
/*
* The networking code runs off software interrupts.
*
@@ -57,7 +60,8 @@
#define NETISR_IMP 3 /* same as AF_IMPLINK */
#define NETISR_NS 6 /* same as AF_NS */
#define NETISR_ISO 7 /* same as AF_ISO */
-#define NETISR_CCITT 10 /* same as AF_CCITT */
+#define NETISR_X25 9 /* hope nobody wants AF_DATAKIT */
+#define NETISR_HDLC 10 /* same as AF_CCITT */
#define schednetisr(anisr) { netisr |= 1<<(anisr); setsoftnet(); }
@@ -77,3 +81,4 @@
extern int netisr; /* scheduling bits for network */
#endif
#endif
+#endif /* _NET_NETISR_H_ */
diff --git a/sys/net/radix.c b/sys/net/radix.c
index 40749968511d..2a7593f2e632 100644
--- a/sys/net/radix.c
+++ b/sys/net/radix.c
@@ -31,7 +31,7 @@
* SUCH DAMAGE.
*
* from: @(#)radix.c 7.9 (Berkeley) 2/4/91
- * $Id: radix.c,v 1.3 1993/10/16 17:43:30 rgrimes Exp $
+ * $Id: radix.c,v 1.4 1993/11/25 01:34:07 wollman Exp $
*/
/*
@@ -213,6 +213,7 @@ int rn_saveinfo;
struct radix_node *
rn_newpair(v, b, nodes)
caddr_t v;
+ int b;
struct radix_node nodes[2];
{
register struct radix_node *tt = nodes, *t = tt + 1;
@@ -293,7 +294,9 @@ on1:
struct radix_node *
rn_addmask(netmask, search, skip)
-caddr_t netmask;
+ caddr_t netmask;
+ int search;
+ int skip;
{
register struct radix_node *x;
register caddr_t cp, cplim;
@@ -343,9 +346,9 @@ struct radix_node *head;
{
register int j;
register caddr_t cp;
- register struct radix_node *t, *x, *tt;
+ register struct radix_node *t, *x = 0, *tt;
short b = 0, b_leaf;
- int vlen = *(u_char *)v, mlen, keyduplicated;
+ int vlen = *(u_char *)v, mlen = 0, keyduplicated;
caddr_t cplim; unsigned char *maskp;
struct radix_mask *m, **mp;
struct radix_node *saved_tt;
@@ -599,9 +602,11 @@ out:
}
char rn_zeros[MAXKEYLEN], rn_ones[MAXKEYLEN];
+int
rn_inithead(head, off, af)
-struct radix_node_head **head;
-int off;
+ struct radix_node_head **head;
+ int off;
+ int af;
{
register struct radix_node_head *rnh;
register struct radix_node *t, *tt, *ttt;
diff --git a/sys/net/radix.h b/sys/net/radix.h
index b71d89fbc687..118fe20662a2 100644
--- a/sys/net/radix.h
+++ b/sys/net/radix.h
@@ -31,9 +31,12 @@
* SUCH DAMAGE.
*
* from: @(#)radix.h 7.4 (Berkeley) 6/28/90
- * $Id: radix.h,v 1.2 1993/10/16 17:43:32 rgrimes Exp $
+ * $Id: radix.h,v 1.3 1993/11/07 17:47:03 wollman Exp $
*/
+#ifndef _NET_RADIX_H_
+#define _NET_RADIX_H_ 1
+
/*
* Radix search tree node layout.
*/
@@ -117,3 +120,4 @@ extern struct radix_node_head {
#define R_Malloc(p, t, n) (p = (t) malloc((unsigned long)(n), M_RTABLE, M_DONTWAIT))
#define Free(p) free((caddr_t)p, M_RTABLE);
#endif /*KERNEL*/
+#endif /* _NET_RADIX_H_ */
diff --git a/sys/net/raw_cb.c b/sys/net/raw_cb.c
index 81371469390b..d0631173dc0d 100644
--- a/sys/net/raw_cb.c
+++ b/sys/net/raw_cb.c
@@ -31,7 +31,7 @@
* SUCH DAMAGE.
*
* from: @(#)raw_cb.c 7.11 (Berkeley) 6/28/90
- * $Id: raw_cb.c,v 1.2 1993/10/16 17:43:34 rgrimes Exp $
+ * $Id: raw_cb.c,v 1.4 1993/11/25 01:34:08 wollman Exp $
*/
#include "param.h"
@@ -62,10 +62,13 @@
u_long raw_sendspace = RAWSNDQ;
u_long raw_recvspace = RAWRCVQ;
+struct rawcb rawcb;
+
/*
* Allocate a control block and a nominal amount
* of buffer space for the socket.
*/
+int
raw_attach(so, proto)
register struct socket *so;
int proto;
@@ -93,6 +96,7 @@ raw_attach(so, proto)
* Detach the raw connection block and discard
* socket resources.
*/
+void
raw_detach(rp)
register struct rawcb *rp;
{
@@ -112,6 +116,7 @@ raw_detach(rp)
/*
* Disconnect and possibly release resources.
*/
+void
raw_disconnect(rp)
struct rawcb *rp;
{
diff --git a/sys/net/raw_cb.h b/sys/net/raw_cb.h
index cd562b43f044..5d64b60d9d9a 100644
--- a/sys/net/raw_cb.h
+++ b/sys/net/raw_cb.h
@@ -31,9 +31,12 @@
* SUCH DAMAGE.
*
* from: @(#)raw_cb.h 7.6 (Berkeley) 6/28/90
- * $Id: raw_cb.h,v 1.2 1993/10/16 17:43:36 rgrimes Exp $
+ * $Id: raw_cb.h,v 1.4 1993/12/19 00:52:05 wollman Exp $
*/
+#ifndef _NET_RAW_CB_H_
+#define _NET_RAW_CB_H_ 1
+
/*
* Raw protocol interface control block. Used
* to tie a socket to the generic raw interface.
@@ -56,5 +59,13 @@ struct rawcb {
#define RAWRCVQ 8192
#ifdef KERNEL
-struct rawcb rawcb; /* head of list */
-#endif
+extern struct rawcb rawcb; /* head of list */
+extern void raw_init(void);
+extern int raw_input(struct mbuf *, struct sockproto *, struct sockaddr *,
+ struct sockaddr *);
+extern void raw_ctlinput(int, struct sockaddr *);
+extern int raw_usrreq(struct socket *, int, struct mbuf *, struct mbuf *,
+ struct mbuf *, struct mbuf *);
+
+#endif /* KERNEL */
+#endif /* _NET_RAW_CB_H_ */
diff --git a/sys/net/raw_usrreq.c b/sys/net/raw_usrreq.c
index 5b4061afa71e..3d8d16b4be73 100644
--- a/sys/net/raw_usrreq.c
+++ b/sys/net/raw_usrreq.c
@@ -31,7 +31,7 @@
* SUCH DAMAGE.
*
* from: @(#)raw_usrreq.c 7.9 (Berkeley) 6/28/90
- * $Id: raw_usrreq.c,v 1.3 1993/10/16 17:43:38 rgrimes Exp $
+ * $Id: raw_usrreq.c,v 1.5 1993/12/19 00:52:05 wollman Exp $
*/
#include "param.h"
@@ -53,6 +53,7 @@
/*
* Initialize raw connection block q.
*/
+void
raw_init()
{
@@ -69,6 +70,7 @@ raw_init()
/*
* Raw protocol interface.
*/
+int
raw_input(m0, proto, src, dst)
struct mbuf *m0;
register struct sockproto *proto;
@@ -129,6 +131,7 @@ raw_input(m0, proto, src, dst)
}
/*ARGSUSED*/
+void
raw_ctlinput(cmd, arg)
int cmd;
struct sockaddr *arg;
@@ -140,10 +143,12 @@ raw_ctlinput(cmd, arg)
}
/*ARGSUSED*/
-raw_usrreq(so, req, m, nam, control)
+int
+raw_usrreq(so, req, m, nam, control, dummy)
struct socket *so;
int req;
struct mbuf *m, *nam, *control;
+ struct mbuf *dummy;
{
register struct rawcb *rp = sotorawcb(so);
register int error = 0;
@@ -307,4 +312,3 @@ release:
return (error);
}
-rawintr() {} /* XXX - referenced by locore. will soon go away */
diff --git a/sys/net/route.c b/sys/net/route.c
index 6f9afaf8bdf7..5cf0cb72d556 100644
--- a/sys/net/route.c
+++ b/sys/net/route.c
@@ -31,7 +31,7 @@
* SUCH DAMAGE.
*
* from: @(#)route.c 7.22 (Berkeley) 6/27/91
- * $Id: route.c,v 1.2 1993/10/16 17:43:39 rgrimes Exp $
+ * $Id: route.c,v 1.5.2.1 1994/03/24 07:42:12 rgrimes Exp $
*/
#include "param.h"
@@ -45,7 +45,6 @@
#include "ioctl.h"
#include "if.h"
-#include "af.h"
#include "route.h"
#include "raw_cb.h"
@@ -60,6 +59,15 @@
#define SA(p) ((struct sockaddr *)(p))
+#if 1 /* XXX these are obsolete, should be */
+ /* deleted if nobody depends on them in */
+ /* user-land */
+struct mbuf *rthost[RTHASHSIZ];
+struct mbuf *rtnet[RTHASHSIZ];
+#endif
+
+struct rtstat rtstat;
+
int rttrash; /* routes not in table but not freed */
struct sockaddr wildcard; /* zero valued cookie for wildcard searches */
int rthashsize = RTHASHSIZ; /* for netstat, etc. */
@@ -68,6 +76,7 @@ static int rtinits_done = 0;
struct radix_node_head *ns_rnhead, *in_rnhead;
struct radix_node *rn_match(), *rn_delete(), *rn_addroute();
+void
rtinitheads()
{
if (rtinits_done == 0 &&
@@ -81,6 +90,7 @@ rtinitheads()
/*
* Packet routing routines.
*/
+void
rtalloc(ro)
register struct route *ro;
{
@@ -123,6 +133,7 @@ rtalloc1(dst, report)
return (newrt);
}
+void
rtfree(rt)
register struct rtentry *rt;
{
@@ -147,9 +158,11 @@ rtfree(rt)
* N.B.: must be called at splnet
*
*/
+void
rtredirect(dst, gateway, netmask, flags, src, rtp)
- struct sockaddr *dst, *gateway, *netmask, *src;
+ struct sockaddr *dst, *gateway, *netmask;
int flags;
+ struct sockaddr *src;
struct rtentry **rtp;
{
register struct rtentry *rt = 0;
@@ -231,6 +244,7 @@ done:
/*
* Routing table ioctl interface.
*/
+int
rtioctl(req, data, p)
int req;
caddr_t data;
@@ -346,6 +360,7 @@ struct sockaddr *dst, *gateway;
#define ROUNDUP(a) (a>0 ? (1 + (((a) - 1) | (sizeof(long) - 1))) : sizeof(long))
+int
rtrequest(req, dst, gateway, netmask, flags, ret_nrt)
int req, flags;
struct sockaddr *dst, *gateway, *netmask;
@@ -355,6 +370,7 @@ rtrequest(req, dst, gateway, netmask, flags, ret_nrt)
register struct rtentry *rt;
register struct radix_node *rn;
register struct radix_node_head *rnh;
+ struct ifnet *ifp;
struct ifaddr *ifa, *ifa_ifwithdstaddr();
struct sockaddr *ndst;
u_char af = dst->sa_family;
@@ -381,8 +397,17 @@ rtrequest(req, dst, gateway, netmask, flags, ret_nrt)
panic ("rtrequest delete");
rt = (struct rtentry *)rn;
rt->rt_flags &= ~RTF_UP;
- if ((ifa = rt->rt_ifa) && ifa->ifa_rtrequest)
- ifa->ifa_rtrequest(RTM_DELETE, rt, SA(0));
+ if ((ifa = rt->rt_ifa) && ifa->ifa_rtrequest){
+ if(ifp = rt->rt_ifp){
+ struct ifaddr *tifa;
+ for (tifa = ifp->if_addrlist; tifa; tifa = tifa->ifa_next) {
+ if(tifa == ifa){
+ ifa->ifa_rtrequest(RTM_DELETE, rt, SA(0));
+ break;
+ }
+ }
+ }
+ }
rttrash++;
if (rt->rt_refcnt <= 0)
rtfree(rt);
@@ -440,8 +465,9 @@ bad:
return (error);
}
+void
rt_maskedcopy(src, dst, netmask)
-struct sockaddr *src, *dst, *netmask;
+ struct sockaddr *src, *dst, *netmask;
{
register u_char *cp1 = (u_char *)src;
register u_char *cp2 = (u_char *)dst;
@@ -462,6 +488,7 @@ struct sockaddr *src, *dst, *netmask;
* Set up a routing table entry, normally
* for an interface.
*/
+int
rtinit(ifa, cmd, flags)
register struct ifaddr *ifa;
int cmd, flags;
diff --git a/sys/net/route.h b/sys/net/route.h
index 2d27b3586021..c7c609d5df62 100644
--- a/sys/net/route.h
+++ b/sys/net/route.h
@@ -31,9 +31,12 @@
* SUCH DAMAGE.
*
* from: @(#)route.h 7.13 (Berkeley) 4/25/91
- * $Id: route.h,v 1.2 1993/10/16 17:43:41 rgrimes Exp $
+ * $Id: route.h,v 1.5 1993/12/19 00:52:07 wollman Exp $
*/
+#ifndef _NET_ROUTE_H_
+#define _NET_ROUTE_H_ 1
+
/*
* Kernel resident routing tables.
*
@@ -197,7 +200,7 @@ struct route_cb {
#define RTA_AUTHOR 0x40 /* sockaddr for author of redirect */
#ifdef KERNEL
-struct route_cb route_cb;
+extern struct route_cb route_cb;
#endif
#ifdef KERNEL
@@ -217,8 +220,23 @@ struct route_cb route_cb;
#else
#define RTHASHMOD(h) ((h) % RTHASHSIZ)
#endif
-struct mbuf *rthost[RTHASHSIZ];
-struct mbuf *rtnet[RTHASHSIZ];
-struct rtstat rtstat;
-struct rtentry *rtalloc1();
-#endif
+extern struct mbuf *rthost[RTHASHSIZ];
+extern struct mbuf *rtnet[RTHASHSIZ];
+extern struct rtstat rtstat;
+
+extern void rtalloc(struct route *);
+extern struct rtentry *rtalloc1(struct sockaddr *, int);
+extern void rtfree(struct rtentry *);
+extern void rt_maskedcopy(struct sockaddr *, struct sockaddr *,
+ struct sockaddr *);
+extern int rtrequest(int, struct sockaddr *, struct sockaddr *,
+ struct sockaddr *, int, struct rtentry **);
+extern void rtredirect(struct sockaddr *, struct sockaddr *, struct sockaddr *,
+ int, struct sockaddr *, struct rtentry **);
+extern void rt_missmsg(int, struct sockaddr *, struct sockaddr *,
+ struct sockaddr *, struct sockaddr *,
+ int, int);
+extern int rtinit(struct ifaddr *, int, int);
+
+#endif /* KERNEL */
+#endif /* _NET_ROUTE_H_ */
diff --git a/sys/net/rtsock.c b/sys/net/rtsock.c
index 47550ee05b31..969821faa8f5 100644
--- a/sys/net/rtsock.c
+++ b/sys/net/rtsock.c
@@ -31,7 +31,7 @@
* SUCH DAMAGE.
*
* from: @(#)rtsock.c 7.18 (Berkeley) 6/27/91
- * $Id: rtsock.c,v 1.3 1993/10/16 17:43:43 rgrimes Exp $
+ * $Id: rtsock.c,v 1.6 1993/12/19 00:52:08 wollman Exp $
*/
#include "param.h"
@@ -43,18 +43,21 @@
#include "domain.h"
#include "protosw.h"
-#include "af.h"
#include "if.h"
#include "route.h"
#include "raw_cb.h"
#include "machine/mtpr.h"
+static void rt_setmetrics(u_long, struct rt_metrics *, struct rt_metrics *);
+
+struct route_cb route_cb;
struct sockaddr route_dst = { 2, PF_ROUTE, };
struct sockaddr route_src = { 2, PF_ROUTE, };
struct sockproto route_proto = { PF_ROUTE, };
/*ARGSUSED*/
+int
route_usrreq(so, req, m, nam, control)
register struct socket *so;
int req;
@@ -80,7 +83,7 @@ route_usrreq(so, req, m, nam, control)
route_cb.any_count--;
}
s = splnet();
- error = raw_usrreq(so, req, m, nam, control);
+ error = raw_usrreq(so, req, m, nam, control, 0);
rp = sotorawcb(so);
if (req == PRU_ATTACH && rp) {
int af = rp->rcb_proto.sp_protocol;
@@ -108,6 +111,7 @@ route_usrreq(so, req, m, nam, control)
#define ADVANCE(x, n) (x += ROUNDUP((n)->sa_len))
/*ARGSUSED*/
+int
route_output(m, so)
register struct mbuf *m;
struct socket *so;
@@ -366,6 +370,7 @@ cleanup:
return (error);
}
+void
rt_setmetrics(which, in, out)
u_long which;
register struct rt_metrics *in, *out;
@@ -382,66 +387,19 @@ rt_setmetrics(which, in, out)
#undef metric
}
-/*
- * Copy data from a buffer back into the indicated mbuf chain,
- * starting "off" bytes from the beginning, extending the mbuf
- * chain if necessary.
- */
-m_copyback(m0, off, len, cp)
- struct mbuf *m0;
- register int off;
- register int len;
- caddr_t cp;
-
-{
- register int mlen;
- register struct mbuf *m = m0, *n;
- int totlen = 0;
-
- if (m0 == 0)
- return;
- while (off > (mlen = m->m_len)) {
- off -= mlen;
- totlen += mlen;
- if (m->m_next == 0) {
- n = m_getclr(M_DONTWAIT, m->m_type);
- if (n == 0)
- goto out;
- n->m_len = min(MLEN, len + off);
- m->m_next = n;
- }
- m = m->m_next;
- }
- while (len > 0) {
- mlen = min (m->m_len - off, len);
- bcopy(cp, off + mtod(m, caddr_t), (unsigned)mlen);
- cp += mlen;
- len -= mlen;
- mlen += off;
- off = 0;
- totlen += mlen;
- if (len == 0)
- break;
- if (m->m_next == 0) {
- n = m_get(M_DONTWAIT, m->m_type);
- if (n == 0)
- break;
- n->m_len = min(MLEN, len);
- m->m_next = n;
- }
- m = m->m_next;
- }
-out: if (((m = m0)->m_flags & M_PKTHDR) && (m->m_pkthdr.len < totlen))
- m->m_pkthdr.len = totlen;
-}
-
/*
* The miss message and losing message are very similar.
*/
+void
rt_missmsg(type, dst, gate, mask, src, flags, error)
-register struct sockaddr *dst;
-struct sockaddr *gate, *mask, *src;
+ int type;
+ register struct sockaddr *dst;
+ struct sockaddr *gate;
+ struct sockaddr *mask;
+ struct sockaddr *src;
+ int flags;
+ int error;
{
register struct rt_msghdr *rtm;
register struct mbuf *m;
@@ -508,6 +466,7 @@ struct walkarg {
/*
* This is used in dumping the kernel table via getkinfo().
*/
+int
rt_dumpentry(rn, w)
struct radix_node *rn;
register struct walkarg *w;
@@ -575,6 +534,7 @@ rt_dumpentry(rn, w)
#undef next
}
+int
kinfo_rtable(op, where, given, arg, needed)
int op, arg;
caddr_t where;
@@ -618,6 +578,7 @@ kinfo_rtable(op, where, given, arg, needed)
return (error);
}
+int
rt_walk(rn, f, w)
register struct radix_node *rn;
register int (*f)();
@@ -642,7 +603,6 @@ rt_walk(rn, f, w)
* Definitions of protocols supported in the ROUTE domain.
*/
-int raw_init(),raw_usrreq(),raw_input(),raw_ctlinput();
extern struct domain routedomain; /* or at least forward */
struct protosw routesw[] = {
diff --git a/sys/net/slcompress.h b/sys/net/slcompress.h
index f713e47f32d1..3f31e6bb2773 100644
--- a/sys/net/slcompress.h
+++ b/sys/net/slcompress.h
@@ -2,7 +2,7 @@
/*
* Definitions for tcp compression routines.
*
- * $Id: slcompress.h,v 1.2 1993/08/27 02:10:32 rgrimes Exp $
+ * $Id: slcompress.h,v 1.3 1993/11/07 17:47:11 wollman Exp $
* From: slcompress.h,v 1.13 1993/08/09 02:37:32 paulus Exp
* From: slcompress.h,v 1.10 89/12/31 08:53:02 van Exp
*
@@ -44,6 +44,9 @@
* - added sl_uncompress_tcp_part.
*/
+#ifndef _NET_SLCOMPRESS_H_
+#define _NET_SLCOMPRESS_H_ 1
+
#define MAX_STATES 16 /* must be > 2 and < 256 */
#define MAX_HDR MLEN /* XXX 4bsd-ism: should really be 128 */
@@ -164,3 +167,4 @@ extern int sl_uncompress_tcp __P((u_char **bufp, int len, u_int type,
extern int sl_uncompress_tcp_part __P((u_char **bufp, int buflen,
int total_len, u_int type,
struct slcompress *));
+#endif /* _NET_SLCOMPRESS_H_ */
diff --git a/sys/net/slip.h b/sys/net/slip.h
index e70a6a4377d0..0532b39ee841 100644
--- a/sys/net/slip.h
+++ b/sys/net/slip.h
@@ -15,9 +15,12 @@
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
* from: unknown
- * $Id: slip.h,v 1.2 1993/10/16 17:43:44 rgrimes Exp $
+ * $Id: slip.h,v 1.3 1993/11/07 17:47:12 wollman Exp $
*/
+#ifndef _NET_SLIP_H_
+#define _NET_SLIP_H_ 1
+
/*
* Definitions that user level programs might need to know to interact
* with serial line IP (slip) lines.
@@ -46,3 +49,4 @@
#define SLIPDIR_IN 0
#define SLIPDIR_OUT 1
+#endif /* _NET_SLIP_H_ */