From: niklas Date: Mon, 4 Mar 1996 08:20:20 +0000 (+0000) Subject: From NetBSD: 960217 merge X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=f5ea9d5f834becfb804891d4b1d637ac4a74d930;p=openbsd From NetBSD: 960217 merge --- diff --git a/sys/netns/idp_usrreq.c b/sys/netns/idp_usrreq.c index c5406011ecf..c047fdb02f4 100644 --- a/sys/netns/idp_usrreq.c +++ b/sys/netns/idp_usrreq.c @@ -1,4 +1,5 @@ -/* $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 @@ -36,6 +37,7 @@ */ #include +#include #include #include #include @@ -50,10 +52,12 @@ #include #include #include +#include #include #include #include +#include /* * IDP protocol implementation. */ @@ -63,12 +67,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 +119,7 @@ bad: m_freem(m); } +void idp_abort(nsp) struct nspcb *nsp; { @@ -116,39 +132,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 +291,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 +403,7 @@ idp_ctloutput(req, so, level, name, value) } /*ARGSUSED*/ +int idp_usrreq(so, req, m, nam, control) struct socket *so; int req; @@ -456,7 +488,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 +511,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 +565,9 @@ release: m_freem(m); return (error); } + /*ARGSUSED*/ +int idp_raw_usrreq(so, req, m, nam, control) struct socket *so; int req; diff --git a/sys/netns/idp_var.h b/sys/netns/idp_var.h index dc95be7df52..f49cd5c5fe0 100644 --- a/sys/netns/idp_var.h +++ b/sys/netns/idp_var.h @@ -1,4 +1,5 @@ -/* $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 @@ -47,5 +48,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 diff --git a/sys/netns/ns.c b/sys/netns/ns.c index 7e2675833f5..338c3701394 100644 --- a/sys/netns/ns.c +++ b/sys/netns/ns.c @@ -1,4 +1,5 @@ -/* $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 @@ -36,6 +37,7 @@ */ #include +#include #include #include #include @@ -48,6 +50,7 @@ #include #include +#include #ifdef NS @@ -59,6 +62,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 +72,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 +151,6 @@ ns_control(so, cmd, data, ifp) } switch (cmd) { - int error; - case SIOCSIFDSTADDR: if ((ifp->if_flags & IFF_POINTOPOINT) == 0) return (EINVAL); @@ -159,7 +160,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 +203,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 +217,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 +234,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 +321,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)) diff --git a/sys/netns/ns.h b/sys/netns/ns.h index 2d3907a66ce..c94e811a128 100644 --- a/sys/netns/ns.h +++ b/sys/netns/ns.h @@ -1,4 +1,5 @@ -/* $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 @@ -140,7 +141,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)) diff --git a/sys/netns/ns_error.c b/sys/netns/ns_error.c index eb4a03999c8..9023a7e4e35 100644 --- a/sys/netns/ns_error.c +++ b/sys/netns/ns_error.c @@ -1,4 +1,5 @@ -/* $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 @@ -44,12 +45,20 @@ #include #include +#include #include #include #include +#include +#include #include +#include #include +#include +#include +#include +#include #ifdef lint #define NS_ERRPRINTFS 1 @@ -63,7 +72,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 +98,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 +178,7 @@ freeit: m_freem(om); } +void ns_printhost(p) register struct ns_addr *p; { @@ -183,11 +196,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 +280,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 +312,7 @@ nstime() } #endif +int ns_echo(m) struct mbuf *m; { diff --git a/sys/netns/ns_if.h b/sys/netns/ns_if.h index 6fdea4b3169..d0844d149e9 100644 --- a/sys/netns/ns_if.h +++ b/sys/netns/ns_if.h @@ -1,4 +1,5 @@ -/* $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 @@ -56,8 +57,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 +82,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 diff --git a/sys/netns/ns_input.c b/sys/netns/ns_input.c index 16927880871..af48cbf7df7 100644 --- a/sys/netns/ns_input.c +++ b/sys/netns/ns_input.c @@ -1,4 +1,5 @@ -/* $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 @@ -52,11 +53,16 @@ #include #include -#include #include +#include +#include #include #include #include +#include +#include +#include +#include /* * NS initialization. @@ -79,6 +85,7 @@ int nsqmaxlen = IFQ_MAXLEN; int idpcksum = 1; long ns_pexseq; +void ns_init() { @@ -101,6 +108,7 @@ ns_init() */ int nsintr_getpck = 0; int nsintr_swtch = 0; +void nsintr() { register struct idp *idp; @@ -137,7 +145,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 +254,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 +276,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 +296,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 +314,7 @@ int idpforwarding = 1; struct route idp_droute; struct route idp_sroute; +void idp_forward(m) struct mbuf *m; { @@ -388,7 +398,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 +434,7 @@ cleanup: m_freem(mcopy); } +int idp_do_route(src, ro) struct ns_addr *src; struct route *ro; @@ -446,12 +457,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; diff --git a/sys/netns/ns_ip.c b/sys/netns/ns_ip.c index 607ba7b64c3..a36320a2268 100644 --- a/sys/netns/ns_ip.c +++ b/sys/netns/ns_ip.c @@ -1,4 +1,5 @@ -/* $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 @@ -385,6 +386,7 @@ nsip_route(m) (struct ifnet *)ifn)); } +int nsip_free(ifp) struct ifnet *ifp; { @@ -399,13 +401,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 +428,10 @@ nsip_ctlinput(cmd, sa) nsip_rtchange(&sin->sin_addr); break; } + return NULL; } +void nsip_rtchange(dst) register struct in_addr *dst; { diff --git a/sys/netns/ns_output.c b/sys/netns/ns_output.c index 4fc7320475d..fe5c1320674 100644 --- a/sys/netns/ns_output.c +++ b/sys/netns/ns_output.c @@ -1,4 +1,5 @@ -/* $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 @@ -36,6 +37,7 @@ */ #include +#include #include #include #include @@ -47,25 +49,39 @@ #include #include +#include #include #include +#include + 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) { diff --git a/sys/netns/ns_pcb.c b/sys/netns/ns_pcb.c index d8435ca46b9..261653881db 100644 --- a/sys/netns/ns_pcb.c +++ b/sys/netns/ns_pcb.c @@ -1,4 +1,5 @@ -/* $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 @@ -49,9 +50,11 @@ #include #include #include +#include struct ns_addr zerons_addr; +int ns_pcballoc(so, head) struct socket *so; struct nspcb *head; @@ -68,6 +71,7 @@ ns_pcballoc(so, head) return (0); } +int ns_pcbbind(nsp, nam) register struct nspcb *nsp; struct mbuf *nam; @@ -118,6 +122,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 +223,7 @@ ns_pcbconnect(nsp, nam) return (0); } +void ns_pcbdisconnect(nsp) struct nspcb *nsp; { @@ -227,6 +233,7 @@ ns_pcbdisconnect(nsp) ns_pcbdetach(nsp); } +void ns_pcbdetach(nsp) struct nspcb *nsp; { @@ -240,6 +247,7 @@ ns_pcbdetach(nsp) free(nsp, M_PCB); } +void ns_setsockaddr(nsp, nam) register struct nspcb *nsp; struct mbuf *nam; @@ -254,6 +262,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 +284,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 +317,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 +337,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; diff --git a/sys/netns/ns_pcb.h b/sys/netns/ns_pcb.h index eca3d14817c..5253005447f 100644 --- a/sys/netns/ns_pcb.h +++ b/sys/netns/ns_pcb.h @@ -1,4 +1,5 @@ -/* $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 @@ -78,5 +79,4 @@ struct nspcb { #ifdef _KERNEL struct nspcb nspcb; /* head of list */ -struct nspcb *ns_pcblookup(); #endif diff --git a/sys/netns/ns_proto.c b/sys/netns/ns_proto.c index 7ecbdf60093..db1f67f76b8 100644 --- a/sys/netns/ns_proto.c +++ b/sys/netns/ns_proto.c @@ -1,4 +1,5 @@ -/* $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 @@ -41,21 +42,24 @@ #include #include +#include #include - -#include +#include /* * 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 +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include extern struct domain nsdomain; @@ -86,7 +90,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, }, diff --git a/sys/netns/ns_var.h b/sys/netns/ns_var.h new file mode 100644 index 00000000000..7f9d4aa1ea6 --- /dev/null +++ b/sys/netns/ns_var.h @@ -0,0 +1,68 @@ +/* $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 diff --git a/sys/netns/spp_debug.c b/sys/netns/spp_debug.c index cbb9aec7135..75db75e5820 100644 --- a/sys/netns/spp_debug.c +++ b/sys/netns/spp_debug.c @@ -1,4 +1,5 @@ -/* $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 @@ -63,9 +64,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; diff --git a/sys/netns/spp_usrreq.c b/sys/netns/spp_usrreq.c index b01ace450e6..1963c644fe3 100644 --- a/sys/netns/spp_usrreq.c +++ b/sys/netns/spp_usrreq.c @@ -1,4 +1,5 @@ -/* $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 @@ -50,6 +51,7 @@ #include #include +#include #include #include #include @@ -59,9 +61,12 @@ #include #include +#include + /* * SP protocol implementation. */ +void spp_init() { @@ -75,15 +80,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 +274,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 +304,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 +344,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 +433,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 +593,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 +639,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 +652,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 +718,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 +739,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 +785,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 +1145,7 @@ send: int spp_do_persist_panics = 0; +void spp_setpersist(cb) register struct sppcb *cb; { @@ -1130,11 +1163,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 +1291,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 +1420,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 +1454,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 +1463,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 +1505,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 +1542,7 @@ release: return (error); } +int spp_usrreq_sp(so, req, m, nam, controlp) struct socket *so; int req; @@ -1528,6 +1564,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 +1659,7 @@ spp_drop(cb, errno) return (spp_close(cb)); } +void spp_abort(nsp) struct nspcb *nsp; { @@ -1634,6 +1672,7 @@ int spp_backoff[SPP_MAXRXTSHIFT+1] = /* * Fast timeout routine for processing delayed acks */ +void spp_fasttimo() { register struct nspcb *nsp; @@ -1648,7 +1687,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 +1697,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 +1722,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 +1801,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 +1811,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 +1826,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; diff --git a/sys/netns/spp_var.h b/sys/netns/spp_var.h index 51104d4f7d5..5710e737e94 100644 --- a/sys/netns/spp_var.h +++ b/sys/netns/spp_var.h @@ -1,4 +1,5 @@ -/* $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 @@ -193,8 +194,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