-/* $NetBSD: idp_usrreq.c,v 1.8 1995/08/12 23:59:56 mycroft Exp $ */
+/* $OpenBSD: idp_usrreq.c,v 1.2 1996/03/04 08:20:20 niklas Exp $ */
+/* $NetBSD: idp_usrreq.c,v 1.9 1996/02/13 22:13:43 christos Exp $ */
/*
* Copyright (c) 1984, 1985, 1986, 1987, 1993
*/
#include <sys/param.h>
+#include <sys/systm.h>
#include <sys/malloc.h>
#include <sys/mbuf.h>
#include <sys/protosw.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 <machine/stdarg.h>
/*
* IDP protocol implementation.
*/
/*
* 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");
m_freem(m);
}
+void
idp_abort(nsp)
struct nspcb *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.
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;
}
/*ARGSUSED*/
+int
idp_usrreq(so, req, m, nam, control)
struct socket *so;
int req;
case PRU_SEND:
{
struct ns_addr laddr;
- int s;
+ int s = 0;
if (nam) {
laddr = nsp->nsp_laddr;
break;
}
}
- error = idp_output(nsp, m);
+ error = idp_output(m, nsp);
m = NULL;
if (nam) {
ns_pcbdisconnect(nsp);
m_freem(m);
return (error);
}
+
/*ARGSUSED*/
+int
idp_raw_usrreq(so, req, m, nam, control)
struct socket *so;
int req;
-/* $NetBSD: idp_var.h,v 1.6 1995/03/26 20:36:17 jtc Exp $ */
+/* $OpenBSD: idp_var.h,v 1.2 1996/03/04 08:20:21 niklas Exp $ */
+/* $NetBSD: idp_var.h,v 1.7 1996/02/13 22:13:47 christos Exp $ */
/*
* Copyright (c) 1984, 1985, 1986, 1987, 1993
};
#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
-/* $NetBSD: ns.c,v 1.9 1995/06/13 08:37:00 mycroft Exp $ */
+/* $OpenBSD: ns.c,v 1.2 1996/03/04 08:20:22 niklas Exp $ */
+/* $NetBSD: ns.c,v 1.10 1996/02/13 22:13:49 christos Exp $ */
/*
* Copyright (c) 1984, 1985, 1986, 1987, 1993
*/
#include <sys/param.h>
+#include <sys/systm.h>
#include <sys/mbuf.h>
#include <sys/ioctl.h>
#include <sys/protosw.h>
#include <netns/ns.h>
#include <netns/ns_if.h>
+#include <netns/ns_var.h>
#ifdef NS
* Generic internet control operations (ioctl's).
*/
/* ARGSUSED */
+int
ns_control(so, cmd, data, ifp)
struct socket *so;
u_long cmd;
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.
}
switch (cmd) {
- int error;
-
case SIOCSIFDSTADDR:
if ((ifp->if_flags & IFF_POINTOPOINT) == 0)
return (EINVAL);
}
if (ifp->if_ioctl) {
error = (*ifp->if_ioctl)(ifp, SIOCSIFDSTADDR,
- (caddr_t)ia);
+ (caddr_t)ia);
if (error)
return (error);
}
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:
/*
* Delete any previous route for an old address.
*/
+void
ns_ifscrub(ifp, ia)
register struct ifnet *ifp;
register struct ns_ifaddr *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;
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))
-/* $NetBSD: ns.h,v 1.7 1995/06/13 08:37:01 mycroft Exp $ */
+/* $OpenBSD: ns.h,v 1.2 1996/03/04 08:20:23 niklas Exp $ */
+/* $NetBSD: ns.h,v 1.8 1996/02/13 22:13:51 christos Exp $ */
/*
* Copyright (c) 1984, 1985, 1986, 1987, 1993
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))
-/* $NetBSD: ns_error.c,v 1.5 1994/06/29 06:41:36 cgd Exp $ */
+/* $OpenBSD: ns_error.c,v 1.2 1996/03/04 08:20:24 niklas Exp $ */
+/* $NetBSD: ns_error.c,v 1.6 1996/02/13 22:13:53 christos Exp $ */
/*
* Copyright (c) 1984, 1988, 1993
#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
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;
* 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;
m_freem(om);
}
+void
ns_printhost(p)
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;
#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;
}
#endif
+int
ns_echo(m)
struct mbuf *m;
{
-/* $NetBSD: ns_if.h,v 1.7 1995/06/13 08:37:02 mycroft Exp $ */
+/* $OpenBSD: ns_if.h,v 1.2 1996/03/04 08:20:25 niklas Exp $ */
+/* $NetBSD: ns_if.h,v 1.8 1996/02/13 22:13:54 christos Exp $ */
/*
* Copyright (c) 1984, 1985, 1986, 1987, 1993
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),
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
-/* $NetBSD: ns_input.c,v 1.8 1995/07/27 20:37:27 mycroft Exp $ */
+/* $OpenBSD: ns_input.c,v 1.2 1996/03/04 08:20:26 niklas Exp $ */
+/* $NetBSD: ns_input.c,v 1.9 1996/02/13 22:13:56 christos Exp $ */
/*
* Copyright (c) 1984, 1985, 1986, 1987, 1993
#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.
int idpcksum = 1;
long ns_pexseq;
+void
ns_init()
{
*/
int nsintr_getpck = 0;
int nsintr_swtch = 0;
+void
nsintr()
{
register struct idp *idp;
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 */
}
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;
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);
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;
struct route idp_droute;
struct route idp_sroute;
+void
idp_forward(m)
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;
m_freem(mcopy);
}
+int
idp_do_route(src, ro)
struct ns_addr *src;
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;
-/* $NetBSD: ns_ip.c,v 1.13 1995/06/13 08:37:05 mycroft Exp $ */
+/* $OpenBSD: ns_ip.c,v 1.2 1996/03/04 08:20:27 niklas Exp $ */
+/* $NetBSD: ns_ip.c,v 1.14 1996/02/13 22:13:58 christos Exp $ */
/*
* Copyright (c) 1984, 1985, 1986, 1987, 1993
(struct ifnet *)ifn));
}
+int
nsip_free(ifp)
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;
nsip_rtchange(&sin->sin_addr);
break;
}
+ return NULL;
}
+void
nsip_rtchange(dst)
register struct in_addr *dst;
{
-/* $NetBSD: ns_output.c,v 1.7 1995/06/13 08:37:07 mycroft Exp $ */
+/* $OpenBSD: ns_output.c,v 1.2 1996/03/04 08:20:28 niklas Exp $ */
+/* $NetBSD: ns_output.c,v 1.8 1996/02/13 22:14:01 christos Exp $ */
/*
* Copyright (c) 1984, 1985, 1986, 1987, 1993
*/
#include <sys/param.h>
+#include <sys/systm.h>
#include <sys/malloc.h>
#include <sys/mbuf.h>
#include <sys/errno.h>
#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) {
-/* $NetBSD: ns_pcb.c,v 1.8 1995/08/17 02:57:38 mycroft Exp $ */
+/* $OpenBSD: ns_pcb.c,v 1.2 1996/03/04 08:20:29 niklas Exp $ */
+/* $NetBSD: ns_pcb.c,v 1.9 1996/02/13 22:14:02 christos Exp $ */
/*
* Copyright (c) 1984, 1985, 1986, 1987, 1993
#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;
return (0);
}
+int
ns_pcbbind(nsp, nam)
register struct nspcb *nsp;
struct mbuf *nam;
* 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;
return (0);
}
+void
ns_pcbdisconnect(nsp)
struct nspcb *nsp;
{
ns_pcbdetach(nsp);
}
+void
ns_pcbdetach(nsp)
struct nspcb *nsp;
{
free(nsp, M_PCB);
}
+void
ns_setsockaddr(nsp, nam)
register struct nspcb *nsp;
struct mbuf *nam;
sns->sns_addr = nsp->nsp_laddr;
}
+void
ns_setpeeraddr(nsp, nam)
register struct nspcb *nsp;
struct mbuf *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();
* After a routing change, flush old routing
* and allocate a (hopefully) better one.
*/
+void
ns_rtchange(nsp)
struct nspcb *nsp;
{
ns_pcblookup(faddr, lport, wildp)
struct ns_addr *faddr;
u_short lport;
+ int wildp;
{
register struct nspcb *nsp, *match = 0;
int matchwild = 3, wildcard;
-/* $NetBSD: ns_pcb.h,v 1.6 1995/03/26 20:36:21 jtc Exp $ */
+/* $OpenBSD: ns_pcb.h,v 1.2 1996/03/04 08:20:30 niklas Exp $ */
+/* $NetBSD: ns_pcb.h,v 1.7 1996/02/13 22:14:05 christos Exp $ */
/*
* Copyright (c) 1984, 1985, 1986, 1987, 1993
#ifdef _KERNEL
struct nspcb nspcb; /* head of list */
-struct nspcb *ns_pcblookup();
#endif
-/* $NetBSD: ns_proto.c,v 1.5 1994/06/29 06:41:48 cgd Exp $ */
+/* $OpenBSD: ns_proto.c,v 1.2 1996/03/04 08:20:31 niklas Exp $ */
+/* $NetBSD: ns_proto.c,v 1.6 1996/02/13 22:14:08 christos Exp $ */
/*
* Copyright (c) 1984, 1985, 1986, 1987, 1993
#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;
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,
},
--- /dev/null
+/* $OpenBSD: ns_var.h,v 1.1 1996/03/04 08:20:32 niklas Exp $ */
+
+#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
-/* $NetBSD: spp_debug.c,v 1.5 1994/06/29 06:41:53 cgd Exp $ */
+/* $OpenBSD: spp_debug.c,v 1.2 1996/03/04 08:20:32 niklas Exp $ */
+/* $NetBSD: spp_debug.c,v 1.6 1996/02/13 22:14:11 christos Exp $ */
/*
* Copyright (c) 1984, 1985, 1986, 1987, 1993
/*
* 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;
-/* $NetBSD: spp_usrreq.c,v 1.8 1995/08/16 00:32:42 mycroft Exp $ */
+/* $OpenBSD: spp_usrreq.c,v 1.2 1996/03/04 08:20:34 niklas Exp $ */
+/* $NetBSD: spp_usrreq.c,v 1.9 1996/02/13 22:14:13 christos Exp $ */
/*
* Copyright (c) 1984, 1985, 1986, 1987, 1993
#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>
#include <netns/spp_var.h>
#include <netns/spp_debug.h>
+#include <machine/stdarg.h>
+
/*
* SP protocol implementation.
*/
+void
spp_init()
{
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++;
(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;
* 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;
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)
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)) {
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);
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,
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;
{
}
#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;
#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;
mm = mm->m_next;
}
}
- error = spp_output(cb, m);
+ error = spp_output(m, cb);
if (error) {
cb->s_cc |= oldEM;
m_freem(m0);
int spp_do_persist_panics = 0;
+void
spp_setpersist(cb)
register struct sppcb *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;
}
/*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)
* cb->s_dport.
*/
nsp->nsp_fport = 0;
- error = spp_output(cb, (struct mbuf *) 0);
+ error = spp_output(NULL, cb);
break;
case PRU_CONNECT2:
socantsendmore(so);
cb = spp_usrclosed(cb);
if (cb)
- error = spp_output(cb, (struct mbuf *) 0);
+ error = spp_output(NULL, cb);
break;
/*
*/
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;
m_freem(controlp);
}
controlp = NULL;
- error = spp_output(cb, m);
+ error = spp_output(m, cb);
m = NULL;
break;
return (error);
}
+int
spp_usrreq_sp(so, req, m, nam, controlp)
struct socket *so;
int req;
* 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;
{
return (spp_close(cb));
}
+void
spp_abort(nsp)
struct nspcb *nsp;
{
/*
* Fast timeout routine for processing delayed acks
*/
+void
spp_fasttimo()
{
register struct nspcb *nsp;
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);
}
* 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;
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;
}
win = 2;
cb->s_cwnd = CUNIT;
cb->s_ssthresh = win * CUNIT;
- (void) spp_output(cb, (struct mbuf *) 0);
+ (void) spp_output(NULL, cb);
break;
/*
case SPPT_PERSIST:
sppstat.spps_persisttimeo++;
spp_setpersist(cb);
- (void) spp_output(cb, (struct mbuf *) 0);
+ (void) spp_output(NULL, cb);
break;
/*
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;
-/* $NetBSD: spp_var.h,v 1.5 1995/03/26 20:36:23 jtc Exp $ */
+/* $OpenBSD: spp_var.h,v 1.2 1996/03/04 08:20:35 niklas Exp $ */
+/* $NetBSD: spp_var.h,v 1.6 1996/02/13 22:14:16 christos Exp $ */
/*
* Copyright (c) 1984, 1985, 1986, 1987, 1993
#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