netns prototypes

This commit is contained in:
christos 1996-02-13 22:13:43 +00:00
parent 2d4af9a7f8
commit f0684ee41d
16 changed files with 353 additions and 110 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: idp_usrreq.c,v 1.8 1995/08/12 23:59:56 mycroft Exp $ */
/* $NetBSD: idp_usrreq.c,v 1.9 1996/02/13 22:13:43 christos Exp $ */
/*
* Copyright (c) 1984, 1985, 1986, 1987, 1993
@ -36,6 +36,7 @@
*/
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/malloc.h>
#include <sys/mbuf.h>
#include <sys/protosw.h>
@ -50,10 +51,12 @@
#include <netns/ns.h>
#include <netns/ns_pcb.h>
#include <netns/ns_if.h>
#include <netns/ns_var.h>
#include <netns/idp.h>
#include <netns/idp_var.h>
#include <netns/ns_error.h>
#include <machine/stdarg.h>
/*
* IDP protocol implementation.
*/
@ -63,12 +66,23 @@ struct sockaddr_ns idp_ns = { sizeof(idp_ns), AF_NS };
/*
* This may also be called for raw listeners.
*/
idp_input(m, nsp)
void
#if __STDC__
idp_input(struct mbuf *m, ...)
#else
idp_input(m, va_alist)
struct mbuf *m;
register struct nspcb *nsp;
va_dcl
#endif
{
register struct nspcb *nsp;
register struct idp *idp = mtod(m, struct idp *);
struct ifnet *ifp = m->m_pkthdr.rcvif;
va_list ap;
va_start(ap, m);
nsp = va_arg(ap, struct nspcb *);
va_end(ap);
if (nsp==0)
panic("No nspcb");
@ -104,6 +118,7 @@ bad:
m_freem(m);
}
void
idp_abort(nsp)
struct nspcb *nsp;
{
@ -116,39 +131,53 @@ idp_abort(nsp)
* Drop connection, reporting
* the specified error.
*/
struct nspcb *
void
idp_drop(nsp, errno)
register struct nspcb *nsp;
int errno;
{
struct socket *so = nsp->nsp_socket;
#if 0
/*
* someday, in the xerox world
* we will generate error protocol packets
* announcing that the socket has gone away.
*/
/*if (TCPS_HAVERCVDSYN(tp->t_state)) {
if (TCPS_HAVERCVDSYN(tp->t_state)) {
tp->t_state = TCPS_CLOSED;
(void) tcp_output(tp);
}*/
}
#endif
so->so_error = errno;
ns_pcbdisconnect(nsp);
soisdisconnected(so);
}
int noIdpRoute;
idp_output(nsp, m0)
struct nspcb *nsp;
int
#if __STDC__
idp_output(struct mbuf *m0, ...)
#else
idp_output(m0, va_alist)
struct mbuf *m0;
va_dcl
#endif
{
struct nspcb *nsp;
register struct mbuf *m;
register struct idp *idp;
register struct socket *so;
register int len = 0;
register struct route *ro;
struct mbuf *mprev;
struct mbuf *mprev = NULL;
extern int idpcksum;
va_list ap;
va_start(ap, m0);
nsp = va_arg(ap, struct nspcb *);
va_end(ap);
/*
* Calculate data length.
@ -261,6 +290,7 @@ idp_output(nsp, m0)
return (ns_output(m, ro, so->so_options & SO_BROADCAST));
}
/* ARGSUSED */
int
idp_ctloutput(req, so, level, name, value)
int req, level;
struct socket *so;
@ -372,6 +402,7 @@ idp_ctloutput(req, so, level, name, value)
}
/*ARGSUSED*/
int
idp_usrreq(so, req, m, nam, control)
struct socket *so;
int req;
@ -456,7 +487,7 @@ idp_usrreq(so, req, m, nam, control)
case PRU_SEND:
{
struct ns_addr laddr;
int s;
int s = 0;
if (nam) {
laddr = nsp->nsp_laddr;
@ -479,7 +510,7 @@ idp_usrreq(so, req, m, nam, control)
break;
}
}
error = idp_output(nsp, m);
error = idp_output(m, nsp);
m = NULL;
if (nam) {
ns_pcbdisconnect(nsp);
@ -533,7 +564,9 @@ release:
m_freem(m);
return (error);
}
/*ARGSUSED*/
int
idp_raw_usrreq(so, req, m, nam, control)
struct socket *so;
int req;

View File

@ -1,4 +1,4 @@
/* $NetBSD: idp_var.h,v 1.6 1995/03/26 20:36:17 jtc Exp $ */
/* $NetBSD: idp_var.h,v 1.7 1996/02/13 22:13:47 christos Exp $ */
/*
* Copyright (c) 1984, 1985, 1986, 1987, 1993
@ -47,5 +47,18 @@ struct idpstat {
};
#ifdef _KERNEL
struct idpstat idpstat;
struct nspcb;
struct mbuf;
struct socket;
struct idpstat idpstat;
void idp_input __P((struct mbuf *, ...));
void idp_abort __P((struct nspcb *));
void idp_drop __P((struct nspcb *, int));
int idp_output __P((struct mbuf *, ...));
int idp_ctloutput __P((int, struct socket *, int , int, struct mbuf **));
int idp_usrreq __P((struct socket *, int, struct mbuf *, struct mbuf *,
struct mbuf *));
int idp_raw_usrreq __P((struct socket *, int, struct mbuf *, struct mbuf *,
struct mbuf *));
#endif

View File

@ -1,4 +1,4 @@
/* $NetBSD: ns.c,v 1.9 1995/06/13 08:37:00 mycroft Exp $ */
/* $NetBSD: ns.c,v 1.10 1996/02/13 22:13:49 christos Exp $ */
/*
* Copyright (c) 1984, 1985, 1986, 1987, 1993
@ -36,6 +36,7 @@
*/
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/mbuf.h>
#include <sys/ioctl.h>
#include <sys/protosw.h>
@ -48,6 +49,7 @@
#include <netns/ns.h>
#include <netns/ns_if.h>
#include <netns/ns_var.h>
#ifdef NS
@ -59,6 +61,7 @@ extern struct sockaddr_ns ns_netmask, ns_hostmask;
* Generic internet control operations (ioctl's).
*/
/* ARGSUSED */
int
ns_control(so, cmd, data, ifp)
struct socket *so;
u_long cmd;
@ -68,8 +71,7 @@ ns_control(so, cmd, data, ifp)
register struct ifreq *ifr = (struct ifreq *)data;
register struct ns_aliasreq *ifra = (struct ns_aliasreq *)data;
register struct ns_ifaddr *ia;
struct ifaddr *ifa;
int error, dstIsNew, hostIsNew;
int dstIsNew, hostIsNew, error = 0;
/*
* Find address for this interface, if it exists.
@ -148,8 +150,6 @@ ns_control(so, cmd, data, ifp)
}
switch (cmd) {
int error;
case SIOCSIFDSTADDR:
if ((ifp->if_flags & IFF_POINTOPOINT) == 0)
return (EINVAL);
@ -159,7 +159,7 @@ ns_control(so, cmd, data, ifp)
}
if (ifp->if_ioctl) {
error = (*ifp->if_ioctl)(ifp, SIOCSIFDSTADDR,
(caddr_t)ia);
(caddr_t)ia);
if (error)
return (error);
}
@ -202,6 +202,8 @@ ns_control(so, cmd, data, ifp)
if (ifra->ifra_addr.sns_family == AF_NS &&
(hostIsNew || dstIsNew))
error = ns_ifinit(ifp, ia, &ifra->ifra_addr, 0);
else
error = 0;
return (error);
default:
@ -214,6 +216,7 @@ ns_control(so, cmd, data, ifp)
/*
* Delete any previous route for an old address.
*/
void
ns_ifscrub(ifp, ia)
register struct ifnet *ifp;
register struct ns_ifaddr *ia;
@ -230,10 +233,12 @@ ns_ifscrub(ifp, ia)
* Initialize an interface's internet address
* and routing table entry.
*/
int
ns_ifinit(ifp, ia, sns, scrub)
register struct ifnet *ifp;
register struct ns_ifaddr *ia;
register struct sockaddr_ns *sns;
int scrub;
{
struct sockaddr_ns oldaddr;
register union ns_host *h = &ia->ia_addr.sns_addr.x_host;
@ -315,7 +320,7 @@ ns_iaonnetof(dst)
union ns_net net = dst->x_net;
for (ia = ns_ifaddr.tqh_first; ia != 0; ia = ia->ia_list.tqe_next) {
if (ifp = ia->ia_ifp) {
if ((ifp = ia->ia_ifp) != NULL) {
if (ifp->if_flags & IFF_POINTOPOINT) {
compare = &satons_addr(ia->ia_dstaddr);
if (ns_hosteq(*dst, *compare))

View File

@ -1,4 +1,4 @@
/* $NetBSD: ns.h,v 1.7 1995/06/13 08:37:01 mycroft Exp $ */
/* $NetBSD: ns.h,v 1.8 1996/02/13 22:13:51 christos Exp $ */
/*
* Copyright (c) 1984, 1985, 1986, 1987, 1993
@ -140,7 +140,6 @@ union ns_host ns_zerohost;
union ns_host ns_broadhost;
union ns_net ns_zeronet;
union ns_net ns_broadnet;
u_short ns_cksum();
#define satosns(sa) ((struct sockaddr_ns *)(sa))
#define snstosa(sns) ((struct sockaddr *)(sns))

View File

@ -1,4 +1,4 @@
/* $NetBSD: ns_error.c,v 1.5 1994/06/29 06:41:36 cgd Exp $ */
/* $NetBSD: ns_error.c,v 1.6 1996/02/13 22:13:53 christos Exp $ */
/*
* Copyright (c) 1984, 1988, 1993
@ -44,12 +44,20 @@
#include <sys/time.h>
#include <sys/kernel.h>
#include <net/if.h>
#include <net/route.h>
#include <netns/ns.h>
#include <netns/ns_pcb.h>
#include <netns/ns_if.h>
#include <netns/ns_var.h>
#include <netns/idp.h>
#include <netns/idp_var.h>
#include <netns/ns_error.h>
#include <netns/sp.h>
#include <netns/spidp.h>
#include <netns/spp_timer.h>
#include <netns/spp_var.h>
#ifdef lint
#define NS_ERRPRINTFS 1
@ -63,7 +71,9 @@
int ns_errprintfs = 0;
#endif
int
ns_err_x(c)
int c;
{
register u_short *w, *lim, *base = ns_errstat.ns_es_codes;
u_short x = c;
@ -87,10 +97,11 @@ ns_err_x(c)
* Generate an error packet of type error
* in response to bad packet.
*/
void
ns_error(om, type, param)
struct mbuf *om;
int type;
int param;
{
register struct ns_epidp *ep;
struct mbuf *m;
@ -166,6 +177,7 @@ freeit:
m_freem(om);
}
void
ns_printhost(p)
register struct ns_addr *p;
{
@ -183,11 +195,14 @@ register struct ns_addr *p;
/*
* Process a received NS_ERR message.
*/
void
ns_err_input(m)
struct mbuf *m;
{
register struct ns_errp *ep;
#ifdef NS_ERRPRINTFS
register struct ns_epidp *epidp = mtod(m, struct ns_epidp *);
#endif
register int i;
int type, code, param;
@ -264,11 +279,11 @@ ns_err_input(m)
#endif
switch(ep->ns_err_idp.idp_pt) {
case NSPROTO_SPP:
spp_ctlinput(code, (caddr_t)ep);
spp_ctlinput(code, NULL, ep);
break;
default:
idp_ctlinput(code, (caddr_t)ep);
idp_ctlinput(code, NULL, ep);
}
goto freeit;
@ -296,6 +311,7 @@ nstime()
}
#endif
int
ns_echo(m)
struct mbuf *m;
{

View File

@ -1,4 +1,4 @@
/* $NetBSD: ns_if.h,v 1.7 1995/06/13 08:37:02 mycroft Exp $ */
/* $NetBSD: ns_if.h,v 1.8 1996/02/13 22:13:54 christos Exp $ */
/*
* Copyright (c) 1984, 1985, 1986, 1987, 1993
@ -56,8 +56,8 @@ struct ns_ifaddr {
struct ns_aliasreq {
char ifra_name[IFNAMSIZ]; /* if name, e.g. "en0" */
struct sockaddr_ns ifra_addr;
struct sockaddr_ns ifra_broadaddr;
#define ifra_dstaddr ifra_broadaddr
struct sockaddr_ns ifra_dstaddr;
#define ifra_broadaddr ifra_dstaddr
};
/*
* Given a pointer to an ns_ifaddr (ifaddr),
@ -81,5 +81,4 @@ struct nsip_req {
TAILQ_HEAD(ns_ifaddrhead, ns_ifaddr);
extern struct ns_ifaddrhead ns_ifaddr;
extern struct ifqueue nsintrq; /* XNS input packet queue */
struct ns_ifaddr *ns_iaonnetof();
#endif

View File

@ -1,4 +1,4 @@
/* $NetBSD: ns_input.c,v 1.8 1995/07/27 20:37:27 mycroft Exp $ */
/* $NetBSD: ns_input.c,v 1.9 1996/02/13 22:13:56 christos Exp $ */
/*
* Copyright (c) 1984, 1985, 1986, 1987, 1993
@ -52,11 +52,16 @@
#include <net/raw_cb.h>
#include <netns/ns.h>
#include <netns/ns_if.h>
#include <netns/ns_pcb.h>
#include <netns/ns_if.h>
#include <netns/ns_var.h>
#include <netns/idp.h>
#include <netns/idp_var.h>
#include <netns/ns_error.h>
#include <netns/sp.h>
#include <netns/spidp.h>
#include <netns/spp_timer.h>
#include <netns/spp_var.h>
/*
* NS initialization.
@ -79,6 +84,7 @@ int nsqmaxlen = IFQ_MAXLEN;
int idpcksum = 1;
long ns_pexseq;
void
ns_init()
{
@ -101,6 +107,7 @@ ns_init()
*/
int nsintr_getpck = 0;
int nsintr_swtch = 0;
void
nsintr()
{
register struct idp *idp;
@ -137,7 +144,7 @@ next:
idp = mtod(m, struct idp *);
len = ntohs(idp->idp_len);
if (oddpacketp = len & 1) {
if ((oddpacketp = len & 1) != 0) {
len++; /* If this packet is of odd length,
preserve garbage byte for checksum */
}
@ -246,21 +253,21 @@ u_char nsctlerrmap[PRC_NCMDS] = {
int idp_donosocks = 1;
idp_ctlinput(cmd, arg)
void *
idp_ctlinput(cmd, sa, arg)
int cmd;
caddr_t arg;
struct sockaddr *sa;
void *arg;
{
struct ns_addr *ns;
struct nspcb *nsp;
struct ns_errp *errp;
int idp_abort();
extern struct nspcb *idp_drop();
struct ns_errp *errp = NULL;
int type;
if (cmd < 0 || cmd > PRC_NCMDS)
return;
return NULL;
if (nsctlerrmap[cmd] == 0)
return; /* XXX */
return NULL; /* XXX */
type = NS_ERR_UNREACH_HOST;
switch (cmd) {
struct sockaddr_ns *sns;
@ -268,14 +275,14 @@ idp_ctlinput(cmd, arg)
case PRC_IFDOWN:
case PRC_HOSTDEAD:
case PRC_HOSTUNREACH:
sns = (struct sockaddr_ns *)arg;
sns = arg;
if (sns->sns_family != AF_NS)
return;
return NULL;
ns = &sns->sns_addr;
break;
default:
errp = (struct ns_errp *)arg;
errp = arg;
ns = &errp->ns_err_idp.idp_dna;
type = errp->ns_err_num;
type = ntohs((u_short)type);
@ -288,10 +295,11 @@ idp_ctlinput(cmd, arg)
case NS_ERR_NOSOCK:
nsp = ns_pcblookup(ns, errp->ns_err_idp.idp_sna.x_port,
NS_WILDCARD);
NS_WILDCARD);
if(nsp && idp_donosocks && ! ns_nullhost(nsp->nsp_faddr))
(void) idp_drop(nsp, (int)nsctlerrmap[cmd]);
}
return NULL;
}
int idpprintfs = 0;
@ -305,6 +313,7 @@ int idpforwarding = 1;
struct route idp_droute;
struct route idp_sroute;
void
idp_forward(m)
struct mbuf *m;
{
@ -388,7 +397,7 @@ struct mbuf *m;
x.l = x.s[0] + x.s[1];
if (x.l==0xffff) idp->idp_sum = 0; else idp->idp_sum = x.l;
}
if ((error = ns_output(m, &idp_droute, flags)) &&
if ((error = ns_output(m, &idp_droute, flags)) != 0 &&
(mcopy!=NULL)) {
idp = mtod(mcopy, struct idp *);
type = NS_ERR_UNSPEC_T, code = 0;
@ -424,6 +433,7 @@ cleanup:
m_freem(mcopy);
}
int
idp_do_route(src, ro)
struct ns_addr *src;
struct route *ro;
@ -446,12 +456,14 @@ struct route *ro;
return (1);
}
void
idp_undo_route(ro)
register struct route *ro;
{
if (ro->ro_rt) {RTFREE(ro->ro_rt);}
}
void
ns_watch_output(m, ifp)
struct mbuf *m;
struct ifnet *ifp;

View File

@ -1,4 +1,4 @@
/* $NetBSD: ns_ip.c,v 1.13 1995/06/13 08:37:05 mycroft Exp $ */
/* $NetBSD: ns_ip.c,v 1.14 1996/02/13 22:13:58 christos Exp $ */
/*
* Copyright (c) 1984, 1985, 1986, 1987, 1993
@ -385,6 +385,7 @@ nsip_route(m)
(struct ifnet *)ifn));
}
int
nsip_free(ifp)
struct ifnet *ifp;
{
@ -399,13 +400,14 @@ struct ifnet *ifp;
return (0);
}
nsip_ctlinput(cmd, sa)
void *
nsip_ctlinput(cmd, sa, v)
int cmd;
struct sockaddr *sa;
void *v;
{
extern u_char inetctlerrmap[];
struct sockaddr_in *sin;
int in_rtchange();
if ((unsigned)cmd >= PRC_NCMDS)
return;
@ -425,8 +427,10 @@ nsip_ctlinput(cmd, sa)
nsip_rtchange(&sin->sin_addr);
break;
}
return NULL;
}
void
nsip_rtchange(dst)
register struct in_addr *dst;
{

View File

@ -1,4 +1,4 @@
/* $NetBSD: ns_output.c,v 1.7 1995/06/13 08:37:07 mycroft Exp $ */
/* $NetBSD: ns_output.c,v 1.8 1996/02/13 22:14:01 christos Exp $ */
/*
* Copyright (c) 1984, 1985, 1986, 1987, 1993
@ -36,6 +36,7 @@
*/
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/malloc.h>
#include <sys/mbuf.h>
#include <sys/errno.h>
@ -47,25 +48,39 @@
#include <netns/ns.h>
#include <netns/ns_if.h>
#include <netns/ns_var.h>
#include <netns/idp.h>
#include <netns/idp_var.h>
#include <machine/stdarg.h>
int ns_hold_output = 0;
int ns_copy_output = 0;
int ns_output_cnt = 0;
struct mbuf *ns_lastout;
ns_output(m0, ro, flags)
int
#if __STDC__
ns_output(struct mbuf *m0, ...)
#else
ns_output(m0, va_alist)
struct mbuf *m0;
va_dcl
#endif
{
struct route *ro;
int flags;
{
register struct idp *idp = mtod(m0, struct idp *);
register struct ifnet *ifp = 0;
int error = 0;
struct route idproute;
struct sockaddr_ns *dst;
extern int idpcksum;
va_list ap;
va_start(ap, m0);
ro = va_arg(ap, struct route *);
flags = va_arg(ap, int);
va_end(ap);
if (ns_hold_output) {
if (ns_lastout) {

View File

@ -1,4 +1,4 @@
/* $NetBSD: ns_pcb.c,v 1.8 1995/08/17 02:57:38 mycroft Exp $ */
/* $NetBSD: ns_pcb.c,v 1.9 1996/02/13 22:14:02 christos Exp $ */
/*
* Copyright (c) 1984, 1985, 1986, 1987, 1993
@ -49,9 +49,11 @@
#include <netns/ns.h>
#include <netns/ns_if.h>
#include <netns/ns_pcb.h>
#include <netns/ns_var.h>
struct ns_addr zerons_addr;
int
ns_pcballoc(so, head)
struct socket *so;
struct nspcb *head;
@ -68,6 +70,7 @@ ns_pcballoc(so, head)
return (0);
}
int
ns_pcbbind(nsp, nam)
register struct nspcb *nsp;
struct mbuf *nam;
@ -118,6 +121,7 @@ noname:
* If don't have a local address for this socket yet,
* then pick one.
*/
int
ns_pcbconnect(nsp, nam)
struct nspcb *nsp;
struct mbuf *nam;
@ -218,6 +222,7 @@ ns_pcbconnect(nsp, nam)
return (0);
}
void
ns_pcbdisconnect(nsp)
struct nspcb *nsp;
{
@ -227,6 +232,7 @@ ns_pcbdisconnect(nsp)
ns_pcbdetach(nsp);
}
void
ns_pcbdetach(nsp)
struct nspcb *nsp;
{
@ -240,6 +246,7 @@ ns_pcbdetach(nsp)
free(nsp, M_PCB);
}
void
ns_setsockaddr(nsp, nam)
register struct nspcb *nsp;
struct mbuf *nam;
@ -254,6 +261,7 @@ ns_setsockaddr(nsp, nam)
sns->sns_addr = nsp->nsp_laddr;
}
void
ns_setpeeraddr(nsp, nam)
register struct nspcb *nsp;
struct mbuf *nam;
@ -275,10 +283,12 @@ ns_setpeeraddr(nsp, nam)
* Also pass an extra paramter via the nspcb. (which may in fact
* be a parameter list!)
*/
void
ns_pcbnotify(dst, errno, notify, param)
register struct ns_addr *dst;
long param;
int errno, (*notify)();
int errno;
void (*notify) __P((struct nspcb *));
{
register struct nspcb *nsp, *oinp;
int s = splimp();
@ -306,6 +316,7 @@ ns_pcbnotify(dst, errno, notify, param)
* After a routing change, flush old routing
* and allocate a (hopefully) better one.
*/
void
ns_rtchange(nsp)
struct nspcb *nsp;
{
@ -325,6 +336,7 @@ struct nspcb *
ns_pcblookup(faddr, lport, wildp)
struct ns_addr *faddr;
u_short lport;
int wildp;
{
register struct nspcb *nsp, *match = 0;
int matchwild = 3, wildcard;

View File

@ -1,4 +1,4 @@
/* $NetBSD: ns_pcb.h,v 1.6 1995/03/26 20:36:21 jtc Exp $ */
/* $NetBSD: ns_pcb.h,v 1.7 1996/02/13 22:14:05 christos Exp $ */
/*
* Copyright (c) 1984, 1985, 1986, 1987, 1993
@ -78,5 +78,4 @@ struct nspcb {
#ifdef _KERNEL
struct nspcb nspcb; /* head of list */
struct nspcb *ns_pcblookup();
#endif

View File

@ -1,4 +1,4 @@
/* $NetBSD: ns_proto.c,v 1.5 1994/06/29 06:41:48 cgd Exp $ */
/* $NetBSD: ns_proto.c,v 1.6 1996/02/13 22:14:08 christos Exp $ */
/*
* Copyright (c) 1984, 1985, 1986, 1987, 1993
@ -41,21 +41,24 @@
#include <sys/domain.h>
#include <sys/mbuf.h>
#include <net/if.h>
#include <net/radix.h>
#include <netns/ns.h>
#include <net/route.h>
/*
* NS protocol family: IDP, ERR, PE, SPP, ROUTE.
*/
void ns_init();
int idp_output(), idp_usrreq();
void idp_input(), idp_ctlinput();
int idp_raw_usrreq(), idp_ctloutput();
void spp_input(), spp_ctlinput();
int spp_usrreq(), spp_usrreq_sp(), spp_ctloutput();
void spp_init(), spp_fasttimo(), spp_slowtimo();
int raw_usrreq();
#include <netns/ns.h>
#include <netns/ns_pcb.h>
#include <netns/ns_if.h>
#include <netns/ns_var.h>
#include <netns/idp.h>
#include <netns/idp_var.h>
#include <netns/ns_error.h>
#include <netns/sp.h>
#include <netns/spidp.h>
#include <netns/spp_timer.h>
#include <netns/spp_var.h>
extern struct domain nsdomain;
@ -86,7 +89,7 @@ struct protosw nssw[] = {
0, 0, 0, 0,
},
{ SOCK_RAW, &nsdomain, NSPROTO_ERROR, PR_ATOMIC|PR_ADDR,
idp_ctlinput, idp_output, 0, idp_ctloutput,
0, idp_output, idp_ctlinput, idp_ctloutput,
idp_raw_usrreq,
0, 0, 0, 0,
},

67
sys/netns/ns_var.h Normal file
View File

@ -0,0 +1,67 @@
#ifdef _KERNEL
struct socket;
struct nspcb;
struct ifnet;
struct ns_ifaddr;
struct sockaddr_ns;
struct mbuf;
struct ns_addr;
struct route;
struct ifnet_en;
struct in_addr;
/* ns.c */
int ns_control __P((struct socket *, u_long, caddr_t, struct ifnet *));
void ns_ifscrub __P((struct ifnet *, struct ns_ifaddr *));
int ns_ifinit __P((struct ifnet *, struct ns_ifaddr *, struct sockaddr_ns *,
int));
struct ns_ifaddr *ns_iaonnetof __P((struct ns_addr *));
/* ns_cksum.c */
u_short ns_cksum __P((struct mbuf *, int));
/* ns_error.c */
int ns_err_x __P((int));
void ns_error __P((struct mbuf *, int, int ));
void ns_printhost __P((struct ns_addr *));
void ns_err_input __P((struct mbuf *));
u_long nstime __P((void));
int ns_echo __P((struct mbuf *));
/* ns_input.c */
void ns_init __P((void));
void nsintr __P((void));
void *idp_ctlinput __P((int, struct sockaddr *, void *));
void idp_forward __P((struct mbuf *));
int idp_do_route __P((struct ns_addr *, struct route *));
void idp_undo_route __P((struct route *));
void ns_watch_output __P((struct mbuf *, struct ifnet *));
/* ns_ip.c */
struct ifnet_en *nsipattach __P((void));
int nsipioctl __P((struct ifnet *, u_long, caddr_t));
int idpip_input __P((struct mbuf *, struct ifnet *));
int nsipoutput __P((struct ifnet_en *, struct mbuf *, struct sockaddr *));
void nsipstart __P((struct ifnet *));
int nsip_route __P((struct mbuf *));
int nsip_free __P((struct ifnet *));
void *nsip_ctlinput __P((int, struct sockaddr *, void *));
int nsip_rtchange __P((struct in_addr *));
/* ns_output.c */
int ns_output __P((struct mbuf *, ...));
/* ns_pcb.c */
int ns_pcballoc __P((struct socket *, struct nspcb *));
int ns_pcbbind __P((struct nspcb *, struct mbuf *));
int ns_pcbconnect __P((struct nspcb *, struct mbuf *));
void ns_pcbdisconnect __P((struct nspcb *));
void ns_pcbdetach __P((struct nspcb *));
void ns_setsockaddr __P((struct nspcb *, struct mbuf *));
void ns_setpeeraddr __P((struct nspcb *, struct mbuf *));
void ns_pcbnotify __P((struct ns_addr *, int, void (*)(struct nspcb *), long));
int ns_rtchange __P((struct nspcb *));
struct nspcb *ns_pcblookup __P((struct ns_addr *, u_short, int));
#endif

View File

@ -1,4 +1,4 @@
/* $NetBSD: spp_debug.c,v 1.5 1994/06/29 06:41:53 cgd Exp $ */
/* $NetBSD: spp_debug.c,v 1.6 1996/02/13 22:14:11 christos Exp $ */
/*
* Copyright (c) 1984, 1985, 1986, 1987, 1993
@ -63,9 +63,10 @@ int sppconsdebug = 0;
/*
* spp debug routines
*/
void
spp_trace(act, ostate, sp, si, req)
short act;
u_char ostate;
u_int ostate;
struct sppcb *sp;
struct spidp *si;
int req;

View File

@ -1,4 +1,4 @@
/* $NetBSD: spp_usrreq.c,v 1.8 1995/08/16 00:32:42 mycroft Exp $ */
/* $NetBSD: spp_usrreq.c,v 1.9 1996/02/13 22:14:13 christos Exp $ */
/*
* Copyright (c) 1984, 1985, 1986, 1987, 1993
@ -50,6 +50,7 @@
#include <netns/ns.h>
#include <netns/ns_pcb.h>
#include <netns/ns_var.h>
#include <netns/idp.h>
#include <netns/idp_var.h>
#include <netns/ns_error.h>
@ -59,9 +60,12 @@
#include <netns/spp_var.h>
#include <netns/spp_debug.h>
#include <machine/stdarg.h>
/*
* SP protocol implementation.
*/
void
spp_init()
{
@ -75,15 +79,26 @@ int spp_use_delack = 0;
u_short spp_newchecks[50];
/*ARGSUSED*/
spp_input(m, nsp)
register struct mbuf *m;
register struct nspcb *nsp;
void
#if __STDC__
spp_input(struct mbuf *m, ...)
#else
spp_input(m, va_alist)
struct mbuf *m;
va_dcl
#endif
{
register struct nspcb *nsp;
register struct sppcb *cb;
register struct spidp *si = mtod(m, struct spidp *);
register struct socket *so;
short ostate;
short ostate = 0;
int dropsocket = 0;
va_list ap;
va_start(ap, m);
nsp = va_arg(ap, struct nspcb *);
va_end(ap);
sppstat.spps_rcvtotal++;
@ -258,7 +273,7 @@ spp_input(m, nsp)
(void) m_freem(m);
}
if (cb->s_force || (cb->s_flags & (SF_ACKNOW|SF_WIN|SF_RXT)))
(void) spp_output(cb, (struct mbuf *)0);
(void) spp_output(NULL, cb);
cb->s_flags &= ~(SF_WIN|SF_RXT);
return;
@ -288,6 +303,7 @@ int spprexmtthresh = 3;
* but its function is somewhat different: It merely queues
* packets up, and suppresses duplicates.
*/
int
spp_reass(cb, si)
register struct sppcb *cb;
register struct spidp *si;
@ -327,7 +343,7 @@ register struct spidp *si;
cb->s_snxt = si->si_ack;
cb->s_cwnd = CUNIT;
cb->s_force = 1 + SPPT_REXMT;
(void) spp_output(cb, (struct mbuf *)0);
(void) spp_output(NULL, cb);
cb->s_timer[SPPT_REXMT] = cb->s_rxtcur;
cb->s_rtt = 0;
if (cwnd >= 4 * CUNIT)
@ -416,9 +432,9 @@ register struct spidp *si;
update_window:
if (SSEQ_LT(cb->s_snxt, cb->s_rack))
cb->s_snxt = cb->s_rack;
if (SSEQ_LT(cb->s_swl1, si->si_seq) || cb->s_swl1 == si->si_seq &&
if (SSEQ_LT(cb->s_swl1, si->si_seq) || (cb->s_swl1 == si->si_seq &&
(SSEQ_LT(cb->s_swl2, si->si_ack) ||
cb->s_swl2 == si->si_ack && SSEQ_LT(cb->s_ralo, si->si_alo))) {
(cb->s_swl2 == si->si_ack && SSEQ_LT(cb->s_ralo, si->si_alo))))) {
/* keep track of pure window updates */
if ((si->si_cc & SP_SP) && cb->s_swl2 == si->si_ack
&& SSEQ_LT(cb->s_ralo, si->si_alo)) {
@ -576,39 +592,39 @@ present:
return (0);
}
spp_ctlinput(cmd, arg)
void *
spp_ctlinput(cmd, sa, arg)
int cmd;
caddr_t arg;
struct sockaddr *sa;
void *arg;
{
struct ns_addr *na;
extern u_char nsctlerrmap[];
extern spp_abort(), spp_quench();
extern struct nspcb *idp_drop();
struct ns_errp *errp;
struct ns_errp *errp = NULL;
struct nspcb *nsp;
struct sockaddr_ns *sns;
int type;
if (cmd < 0 || cmd > PRC_NCMDS)
return;
return NULL;
type = NS_ERR_UNREACH_HOST;
switch (cmd) {
case PRC_ROUTEDEAD:
return;
return NULL;
case PRC_IFDOWN:
case PRC_HOSTDEAD:
case PRC_HOSTUNREACH:
sns = (struct sockaddr_ns *)arg;
sns = arg;
if (sns->sns_family != AF_NS)
return;
return NULL;
na = &sns->sns_addr;
break;
default:
errp = (struct ns_errp *)arg;
errp = arg;
na = &errp->ns_err_idp.idp_dna;
type = errp->ns_err_num;
type = ntohs((u_short)type);
@ -622,7 +638,7 @@ spp_ctlinput(cmd, arg)
case NS_ERR_TOO_BIG:
case NS_ERR_NOSOCK:
nsp = ns_pcblookup(na, errp->ns_err_idp.idp_sna.x_port,
NS_WILDCARD);
NS_WILDCARD);
if (nsp) {
if(nsp->nsp_pcb)
(void) spp_drop((struct sppcb *)nsp->nsp_pcb,
@ -635,11 +651,14 @@ spp_ctlinput(cmd, arg)
case NS_ERR_FULLUP:
ns_pcbnotify(na, 0, spp_quench, (long) 0);
}
return NULL;
}
/*
* When a source quench is received, close congestion window
* to one packet. We will gradually open it again as we proceed.
*/
void
spp_quench(nsp)
struct nspcb *nsp;
{
@ -698,10 +717,16 @@ register struct nspcb *nsp;
}
#endif
spp_output(cb, m0)
register struct sppcb *cb;
int
#if __STDC__
spp_output(struct mbuf *m0, ...)
#else
spp_output(m0, va_alist)
struct mbuf *m0;
va_dcl
#endif
{
register struct sppcb *cb = NULL;
struct socket *so = cb->s_nspcb->nsp_socket;
register struct mbuf *m;
register struct spidp *si = (struct spidp *) 0;
@ -713,8 +738,14 @@ spp_output(cb, m0)
#ifdef notdef
int idle;
#endif
struct mbuf *mprev;
struct mbuf *mprev = NULL;
extern int idpcksum;
va_list ap;
va_start(ap, m0);
cb = va_arg(ap, struct sppcb *);
va_end(ap);
if (m0) {
int mtu = cb->s_mtu;
@ -753,7 +784,7 @@ spp_output(cb, m0)
mm = mm->m_next;
}
}
error = spp_output(cb, m);
error = spp_output(m, cb);
if (error) {
cb->s_cc |= oldEM;
m_freem(m0);
@ -1113,6 +1144,7 @@ send:
int spp_do_persist_panics = 0;
void
spp_setpersist(cb)
register struct sppcb *cb;
{
@ -1130,11 +1162,13 @@ spp_setpersist(cb)
if (cb->s_rxtshift < SPP_MAXRXTSHIFT)
cb->s_rxtshift++;
}
/*ARGSUSED*/
int
spp_ctloutput(req, so, level, name, value)
int req;
struct socket *so;
int name;
int name, level;
struct mbuf **value;
{
register struct mbuf *m;
@ -1256,16 +1290,16 @@ spp_ctloutput(req, so, level, name, value)
}
/*ARGSUSED*/
int
spp_usrreq(so, req, m, nam, controlp)
struct socket *so;
int req;
struct mbuf *m, *nam, *controlp;
{
struct nspcb *nsp = sotonspcb(so);
register struct sppcb *cb;
register struct sppcb *cb = NULL;
int s = splsoftnet();
int error = 0, ostate;
struct mbuf *mm;
register struct sockbuf *sb;
if (req == PRU_CONTROL)
@ -1385,7 +1419,7 @@ spp_usrreq(so, req, m, nam, controlp)
* cb->s_dport.
*/
nsp->nsp_fport = 0;
error = spp_output(cb, (struct mbuf *) 0);
error = spp_output(NULL, cb);
break;
case PRU_CONNECT2:
@ -1419,7 +1453,7 @@ spp_usrreq(so, req, m, nam, controlp)
socantsendmore(so);
cb = spp_usrclosed(cb);
if (cb)
error = spp_output(cb, (struct mbuf *) 0);
error = spp_output(NULL, cb);
break;
/*
@ -1428,7 +1462,7 @@ spp_usrreq(so, req, m, nam, controlp)
*/
case PRU_RCVD:
cb->s_flags |= SF_RVD;
(void) spp_output(cb, (struct mbuf *) 0);
(void) spp_output(NULL, cb);
cb->s_flags &= ~SF_RVD;
break;
@ -1470,7 +1504,7 @@ spp_usrreq(so, req, m, nam, controlp)
m_freem(controlp);
}
controlp = NULL;
error = spp_output(cb, m);
error = spp_output(m, cb);
m = NULL;
break;
@ -1507,6 +1541,7 @@ release:
return (error);
}
int
spp_usrreq_sp(so, req, m, nam, controlp)
struct socket *so;
int req;
@ -1528,6 +1563,7 @@ spp_usrreq_sp(so, req, m, nam, controlp)
* in a skeletal spp header (choosing connection id),
* minimizing the amount of work necessary when the connection is used.
*/
void
spp_template(cb)
register struct sppcb *cb;
{
@ -1622,6 +1658,7 @@ spp_drop(cb, errno)
return (spp_close(cb));
}
void
spp_abort(nsp)
struct nspcb *nsp;
{
@ -1634,6 +1671,7 @@ int spp_backoff[SPP_MAXRXTSHIFT+1] =
/*
* Fast timeout routine for processing delayed acks
*/
void
spp_fasttimo()
{
register struct nspcb *nsp;
@ -1648,7 +1686,7 @@ spp_fasttimo()
cb->s_flags &= ~SF_DELACK;
cb->s_flags |= SF_ACKNOW;
sppstat.spps_delack++;
(void) spp_output(cb, (struct mbuf *) 0);
(void) spp_output(NULL, cb);
}
splx(s);
}
@ -1658,6 +1696,7 @@ spp_fasttimo()
* Updates the timers in all active pcb's and
* causes finite state machine actions if timers expire.
*/
void
spp_slowtimo()
{
register struct nspcb *ip, *ipnxt;
@ -1682,8 +1721,7 @@ spp_slowtimo()
if (cb->s_timer[i] && --cb->s_timer[i] == 0) {
(void) spp_usrreq(cb->s_nspcb->nsp_socket,
PRU_SLOWTIMO, (struct mbuf *)0,
(struct mbuf *)i, (struct mbuf *)0,
(struct mbuf *)0);
(struct mbuf *)i, (struct mbuf *)0);
if (ipnxt->nsp_prev != ip)
goto tpgone;
}
@ -1762,7 +1800,7 @@ spp_timers(cb, timer)
win = 2;
cb->s_cwnd = CUNIT;
cb->s_ssthresh = win * CUNIT;
(void) spp_output(cb, (struct mbuf *) 0);
(void) spp_output(NULL, cb);
break;
/*
@ -1772,7 +1810,7 @@ spp_timers(cb, timer)
case SPPT_PERSIST:
sppstat.spps_persisttimeo++;
spp_setpersist(cb);
(void) spp_output(cb, (struct mbuf *) 0);
(void) spp_output(NULL, cb);
break;
/*
@ -1787,7 +1825,7 @@ spp_timers(cb, timer)
if (cb->s_idle >= SPPTV_MAXIDLE)
goto dropit;
sppstat.spps_keepprobe++;
(void) spp_output(cb, (struct mbuf *) 0);
(void) spp_output(NULL, cb);
} else
cb->s_idle = 0;
cb->s_timer[SPPT_KEEP] = SPPTV_KEEP;

View File

@ -1,4 +1,4 @@
/* $NetBSD: spp_var.h,v 1.5 1995/03/26 20:36:23 jtc Exp $ */
/* $NetBSD: spp_var.h,v 1.6 1996/02/13 22:14:16 christos Exp $ */
/*
* Copyright (c) 1984, 1985, 1986, 1987, 1993
@ -193,8 +193,35 @@ struct spp_istat spp_istat;
#endif
u_short spp_iss;
extern struct sppcb *spp_close(), *spp_disconnect(),
*spp_usrclosed(), *spp_timers(), *spp_drop();
struct sppcb;
struct spidp;
/* spp_debug.c */
void spp_trace __P((int, u_int, struct sppcb *, struct spidp *, int));
/* spp_usrreq.c */
void spp_init __P((void));
void spp_input __P((struct mbuf *, ...));
int spp_reass __P((struct sppcb *, struct spidp *));
void *spp_ctlinput __P((int, struct sockaddr *, void *));
void spp_quench __P((struct nspcb *));
int spp_fixmtu __P((struct nspcb *));
int spp_output __P((struct mbuf *, ...));
void spp_setpersist __P((struct sppcb *));
int spp_ctloutput __P((int, struct socket *, int, int, struct mbuf **));
int spp_usrreq __P((struct socket *, int, struct mbuf *, struct mbuf *,
struct mbuf *));
int spp_usrreq_sp __P((struct socket *, int, struct mbuf *, struct mbuf *,
struct mbuf *));
void spp_template __P((struct sppcb *));
struct sppcb *spp_close __P((struct sppcb *));
struct sppcb *spp_usrclosed __P((struct sppcb *));
struct sppcb *spp_disconnect __P((struct sppcb *));
struct sppcb *spp_drop __P((struct sppcb *, int));
void spp_abort __P((struct nspcb *));
void spp_fasttimo __P((void));
void spp_slowtimo __P((void));
struct sppcb *spp_timers __P((struct sppcb *, long));
#endif
#define SPP_ISSINCR 128