Peter Wemm wrote:
> Terry Lambert wrote:
> > Here are two patches. The first fixes missing pieces in /sys/conf/files
> > and /sys/conf/options, the second fixes all the files that need it in
> > /sys/netns/.
>
> You seem to have posted the wrong patch.
>
> This is against 4.x, not -current, and this is [EMAIL PROTECTED]
Here is a single patch vs. 5.x.
I believe this makes it actually work. I have addressed all
the protosw issues in this patch.
Please apply this to the code, even if you are intent on putting
working code in the Attic.
Thanks,
-- Terry
Index: conf/files
===================================================================
RCS file: /cvs/src/sys/conf/files,v
retrieving revision 1.765
diff -c -r1.765 files
*** conf/files 4 Mar 2003 23:19:55 -0000 1.765
--- conf/files 5 Mar 2003 06:03:11 -0000
***************
*** 1429,1434 ****
--- 1429,1435 ----
netns/ns_output.c optional ns
netns/ns_pcb.c optional ns
netns/ns_proto.c optional ns
+ netns/ns_cksum.c optional ns
netns/spp_debug.c optional ns
netns/spp_usrreq.c optional ns
netsmb/smb_conn.c optional netsmb
Index: netns/idp_usrreq.c
===================================================================
RCS file: /cvs/src/sys/netns/idp_usrreq.c,v
retrieving revision 1.15
diff -c -r1.15 idp_usrreq.c
*** netns/idp_usrreq.c 19 Feb 2003 05:47:37 -0000 1.15
--- netns/idp_usrreq.c 5 Mar 2003 08:04:20 -0000
***************
*** 54,59 ****
--- 54,63 ----
#include <netns/idp_var.h>
#include <netns/ns_error.h>
+ extern int idpcksum; /* from ns_input.c */
+ extern long ns_pexseq; /* from ns_input.c */
+ extern struct nspcb nsrawpcb; /* from ns_input.c */
+
/*
* IDP protocol implementation.
*/
***************
*** 63,72 ****
/*
* This may also be called for raw listeners.
*/
! idp_input(m, nsp)
struct mbuf *m;
! register struct nspcb *nsp;
{
register struct idp *idp = mtod(m, struct idp *);
struct ifnet *ifp = m->m_pkthdr.rcvif;
--- 67,78 ----
/*
* This may also be called for raw listeners.
*/
! void
! idp_input(m, nsp0)
struct mbuf *m;
! int nsp0; /* XXX offset */
{
+ register struct nspcb *nsp = ns_pcblookupm(m);
register struct idp *idp = mtod(m, struct idp *);
struct ifnet *ifp = m->m_pkthdr.rcvif;
***************
*** 79,92 ****
idp_ns.sns_addr = idp->idp_sna;
if (ns_neteqnn(idp->idp_sna.x_net, ns_zeronet) && ifp) {
register struct ifaddr *ifa;
! for (ifa = ifp->if_addrlist; ifa; ifa = ifa->ifa_next) {
if (ifa->ifa_addr->sa_family == AF_NS) {
idp_ns.sns_addr.x_net =
IA_SNS(ifa)->sns_addr.x_net;
break;
}
! }
}
nsp->nsp_rpt = idp->idp_pt;
if ( ! (nsp->nsp_flags & NSP_RAWIN) ) {
--- 85,100 ----
idp_ns.sns_addr = idp->idp_sna;
if (ns_neteqnn(idp->idp_sna.x_net, ns_zeronet) && ifp) {
register struct ifaddr *ifa;
+ int s;
! s = splimp();
! TAILQ_FOREACH(ifa, &ifp->if_addrhead, ifa_link)
if (ifa->ifa_addr->sa_family == AF_NS) {
idp_ns.sns_addr.x_net =
IA_SNS(ifa)->sns_addr.x_net;
break;
}
! splx(s);
}
nsp->nsp_rpt = idp->idp_pt;
if ( ! (nsp->nsp_flags & NSP_RAWIN) ) {
***************
*** 103,108 ****
--- 111,117 ----
m_freem(m);
}
+ void
idp_abort(nsp)
struct nspcb *nsp;
{
***************
*** 134,153 ****
so->so_error = errno;
ns_pcbdisconnect(nsp);
soisdisconnected(so);
}
int noIdpRoute;
! idp_output(nsp, m0)
! struct nspcb *nsp;
struct mbuf *m0;
{
! register struct mbuf *m;
register struct idp *idp;
- register struct socket *so;
register int len;
register struct route *ro;
! struct mbuf *mprev;
! extern int idpcksum;
len = m_length(m0, &mprev);
/*
--- 143,164 ----
so->so_error = errno;
ns_pcbdisconnect(nsp);
soisdisconnected(so);
+ return(NULL); /* XXX */
}
int noIdpRoute;
!
! int
! idp_output(m0, so)
struct mbuf *m0;
+ struct socket *so;
{
! struct nspcb *nsp = sotonspcb(so);
! struct mbuf *m;
register struct idp *idp;
register int len;
register struct route *ro;
! struct mbuf *mprev = NULL;
len = m_length(m0, &mprev);
/*
***************
*** 204,210 ****
/*
* Output datagram.
*/
- so = nsp->nsp_socket;
if (so->so_options & SO_DONTROUTE)
return (ns_output(m, (struct route *)0,
(so->so_options & SO_BROADCAST) | NS_ROUTETOIF));
--- 215,220 ----
***************
*** 253,274 ****
if (noIdpRoute) ro = 0;
return (ns_output(m, ro, so->so_options & SO_BROADCAST));
}
/* ARGSUSED */
! idp_ctloutput(req, so, level, name, value)
! int req, level;
struct socket *so;
! int name;
! struct mbuf **value;
{
register struct mbuf *m;
struct nspcb *nsp = sotonspcb(so);
int mask, error = 0;
- extern long ns_pexseq;
if (nsp == NULL)
return (EINVAL);
! switch (req) {
case PRCO_GETOPT:
if (value==NULL)
--- 263,284 ----
if (noIdpRoute) ro = 0;
return (ns_output(m, ro, so->so_options & SO_BROADCAST));
}
+
/* ARGSUSED */
! int
! idp_ctloutput( so, sopt)
struct socket *so;
! struct sockopt *sopt;
{
register struct mbuf *m;
+ struct mbuf **value = sopt->sopt_val; /* XXX dangerous */
struct nspcb *nsp = sotonspcb(so);
int mask, error = 0;
if (nsp == NULL)
return (EINVAL);
! switch (sopt->sopt_dir) {
case PRCO_GETOPT:
if (value==NULL)
***************
*** 276,282 ****
m = m_get(M_DONTWAIT, MT_DATA);
if (m==NULL)
return (ENOBUFS);
! switch (name) {
case SO_ALL_PACKETS:
mask = NSP_ALL_PACKETS;
--- 286,292 ----
m = m_get(M_DONTWAIT, MT_DATA);
if (m==NULL)
return (ENOBUFS);
! switch (sopt->sopt_name) {
case SO_ALL_PACKETS:
mask = NSP_ALL_PACKETS;
***************
*** 318,324 ****
break;
case PRCO_SETOPT:
! switch (name) {
int *ok;
case SO_ALL_PACKETS:
--- 328,334 ----
break;
case PRCO_SETOPT:
! switch (sopt->sopt_name) {
int *ok;
case SO_ALL_PACKETS:
***************
*** 365,374 ****
}
/*ARGSUSED*/
! idp_usrreq(so, req, m, nam, control)
struct socket *so;
int req;
struct mbuf *m, *nam, *control;
{
struct nspcb *nsp = sotonspcb(so);
int error = 0;
--- 375,386 ----
}
/*ARGSUSED*/
! int
! idp_usrreq(so, req, m, nam, control, td)
struct socket *so;
int req;
struct mbuf *m, *nam, *control;
+ struct thread *td;
{
struct nspcb *nsp = sotonspcb(so);
int error = 0;
***************
*** 449,455 ****
case PRU_SEND:
{
struct ns_addr laddr;
! int s;
if (nam) {
laddr = nsp->nsp_laddr;
--- 461,467 ----
case PRU_SEND:
{
struct ns_addr laddr;
! int s = -1; /* XXX compiler warns improperly */
if (nam) {
laddr = nsp->nsp_laddr;
***************
*** 472,478 ****
break;
}
}
! error = idp_output(nsp, m);
m = NULL;
if (nam) {
ns_pcbdisconnect(nsp);
--- 484,490 ----
break;
}
}
! error = idp_output(m, so);
m = NULL;
if (nam) {
ns_pcbdisconnect(nsp);
***************
*** 526,549 ****
m_freem(m);
return (error);
}
/*ARGSUSED*/
! idp_raw_usrreq(so, req, m, nam, control)
struct socket *so;
int req;
struct mbuf *m, *nam, *control;
{
int error = 0;
struct nspcb *nsp = sotonspcb(so);
- extern struct nspcb nsrawpcb;
switch (req) {
case PRU_ATTACH:
if (!(so->so_state & SS_PRIV) || (nsp != NULL)) {
error = EINVAL;
break;
}
error = ns_pcballoc(so, &nsrawpcb);
if (error)
break;
--- 538,566 ----
m_freem(m);
return (error);
}
+
/*ARGSUSED*/
! int
! idp_raw_usrreq(so, req, m, nam, control, td)
struct socket *so;
int req;
struct mbuf *m, *nam, *control;
+ struct thread *td;
{
int error = 0;
struct nspcb *nsp = sotonspcb(so);
switch (req) {
case PRU_ATTACH:
+ #ifdef NS_PRIV_SOCKETS
if (!(so->so_state & SS_PRIV) || (nsp != NULL)) {
error = EINVAL;
break;
}
+ #endif /* NS_PRIV_SOCKETS */
+
error = ns_pcballoc(so, &nsrawpcb);
if (error)
break;
***************
*** 555,561 ****
nsp->nsp_flags = NSP_RAWIN | NSP_RAWOUT;
break;
default:
! error = idp_usrreq(so, req, m, nam, control);
}
return (error);
}
--- 572,578 ----
nsp->nsp_flags = NSP_RAWIN | NSP_RAWOUT;
break;
default:
! error = idp_usrreq(so, req, m, nam, control, td);
}
return (error);
}
Index: netns/idp_var.h
===================================================================
RCS file: /cvs/src/sys/netns/idp_var.h,v
retrieving revision 1.10
diff -c -r1.10 idp_var.h
*** netns/idp_var.h 29 Dec 1999 04:46:18 -0000 1.10
--- netns/idp_var.h 5 Mar 2003 07:51:33 -0000
***************
*** 50,55 ****
--- 50,67 ----
#ifdef _KERNEL
struct idpstat idpstat;
+ struct nspcb; /* declare in scope for ptr parameter */
+ struct thread; /* XXX not used */
+
+ void idp_abort __P((struct nspcb *));
+ void idp_input __P((struct mbuf *, int));
+ struct nspcb *idp_drop __P((struct nspcb *, int));
+ int idp_output __P(( struct mbuf *, struct socket *));
+ int idp_ctloutput __P((struct socket *, struct sockopt *));
+ int idp_usrreq __P(( struct socket *, int, struct mbuf *, struct mbuf *,
+ struct mbuf *, struct thread *));
+ int idp_raw_usrreq __P(( struct socket *, int, struct mbuf *, struct mbuf *,
+ struct mbuf *, struct thread *));
#endif
#endif
Index: netns/ns.c
===================================================================
RCS file: /cvs/src/sys/netns/ns.c,v
retrieving revision 1.13
diff -c -r1.13 ns.c
*** netns/ns.c 19 Feb 2003 05:47:37 -0000 1.13
--- netns/ns.c 5 Mar 2003 06:32:52 -0000
***************
*** 36,43 ****
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/mbuf.h>
! #include <sys/ioctl.h>
#include <sys/protosw.h>
#include <sys/errno.h>
#include <sys/socket.h>
--- 36,44 ----
#include <sys/param.h>
#include <sys/systm.h>
+ #include <sys/malloc.h>
#include <sys/mbuf.h>
! #include <sys/sockio.h>
#include <sys/protosw.h>
#include <sys/errno.h>
#include <sys/socket.h>
***************
*** 49,54 ****
--- 50,57 ----
#include <netns/ns.h>
#include <netns/ns_if.h>
+ #include "opt_ns.h"
+
#ifdef NS
struct ns_ifaddr *ns_ifaddr;
***************
*** 59,64 ****
--- 62,68 ----
* Generic internet control operations (ioctl's).
*/
/* ARGSUSED */
+ int
ns_control(so, cmd, data, ifp)
struct socket *so;
int cmd;
***************
*** 68,76 ****
register struct ifreq *ifr = (struct ifreq *)data;
register struct ns_aliasreq *ifra = (struct ns_aliasreq *)data;
register struct ns_ifaddr *ia;
! struct ifaddr *ifa;
struct ns_ifaddr *oia;
! int error, dstIsNew, hostIsNew;
/*
* Find address for this interface, if it exists.
--- 72,81 ----
register struct ifreq *ifr = (struct ifreq *)data;
register struct ns_aliasreq *ifra = (struct ns_aliasreq *)data;
register struct ns_ifaddr *ia;
! struct ifaddr *ifa = NULL; /* XXX used uninitialized ?*/
struct ns_ifaddr *oia;
! int dstIsNew, hostIsNew;
! int error = 0; /* initialize because of scoping */
/*
* Find address for this interface, if it exists.
***************
*** 107,114 ****
--- 112,121 ----
return (0);
}
+ #ifdef NS_PRIV_SOCKETS
if ((so->so_state & SS_PRIV) == 0)
return (EPERM);
+ #endif /* NS_PRIV_SOCKETS */
switch (cmd) {
case SIOCAIFADDR:
***************
*** 132,150 ****
if (oia == (struct ns_ifaddr *)NULL)
return (ENOBUFS);
bzero((caddr_t)oia, sizeof(*oia));
! if (ia = ns_ifaddr) {
for ( ; ia->ia_next; ia = ia->ia_next)
;
ia->ia_next = oia;
} else
ns_ifaddr = oia;
ia = oia;
! if (ifa = ifp->if_addrlist) {
! for ( ; ifa->ifa_next; ifa = ifa->ifa_next)
! ;
! ifa->ifa_next = (struct ifaddr *) ia;
! } else
! ifp->if_addrlist = (struct ifaddr *) ia;
ia->ia_ifp = ifp;
ia->ia_ifa.ifa_addr = (struct sockaddr *)&ia->ia_addr;
--- 139,153 ----
if (oia == (struct ns_ifaddr *)NULL)
return (ENOBUFS);
bzero((caddr_t)oia, sizeof(*oia));
! if ((ia = ns_ifaddr) != NULL) {
for ( ; ia->ia_next; ia = ia->ia_next)
;
ia->ia_next = oia;
} else
ns_ifaddr = oia;
ia = oia;
!
! TAILQ_INSERT_TAIL(&ifp->if_addrhead, ifa, ifa_link);
ia->ia_ifp = ifp;
ia->ia_ifa.ifa_addr = (struct sockaddr *)&ia->ia_addr;
***************
*** 163,170 ****
}
switch (cmd) {
- int error;
-
case SIOCSIFDSTADDR:
if ((ifp->if_flags & IFF_POINTOPOINT) == 0)
return (EINVAL);
--- 166,171 ----
***************
*** 173,179 ****
ia->ia_flags &= ~IFA_ROUTE;
}
if (ifp->if_ioctl) {
! error = (*ifp->if_ioctl)(ifp, SIOCSIFDSTADDR, ia);
if (error)
return (error);
}
--- 174,181 ----
ia->ia_flags &= ~IFA_ROUTE;
}
if (ifp->if_ioctl) {
! error = (*ifp->if_ioctl)(ifp, SIOCSIFDSTADDR,
! (caddr_t)ia);
if (error)
return (error);
}
***************
*** 181,203 ****
return (0);
case SIOCSIFADDR:
! return (ns_ifinit(ifp, ia,
(struct sockaddr_ns *)&ifr->ifr_addr, 1));
case SIOCDIFADDR:
! ns_ifscrub(ifp, ia);
! if ((ifa = ifp->if_addrlist) == (struct ifaddr *)ia)
! ifp->if_addrlist = ifa->ifa_next;
! else {
! while (ifa->ifa_next &&
! (ifa->ifa_next != (struct ifaddr *)ia))
! ifa = ifa->ifa_next;
! if (ifa->ifa_next)
! ifa->ifa_next = ((struct ifaddr *)ia)->ifa_next;
! else
! printf("Couldn't unlink nsifaddr from ifp\n");
! }
oia = ia;
if (oia == (ia = ns_ifaddr)) {
ns_ifaddr = ia->ia_next;
} else {
--- 183,196 ----
return (0);
case SIOCSIFADDR:
! return (ns_ifinit(ifp, (struct ns_ifaddr *)ia,
(struct sockaddr_ns *)&ifr->ifr_addr, 1));
case SIOCDIFADDR:
! ns_ifscrub(ifp, (struct ns_ifaddr *)ia);
! /* XXX not on list? */
oia = ia;
+ TAILQ_REMOVE(&ifp->if_addrhead, (struct ifaddr *)ia, ifa_link);
if (oia == (ia = ns_ifaddr)) {
ns_ifaddr = ia->ia_next;
} else {
***************
*** 231,243 ****
if ((ifp->if_flags & IFF_POINTOPOINT) &&
(ifra->ifra_dstaddr.sns_family == AF_NS)) {
if (hostIsNew == 0)
! ns_ifscrub(ifp, ia);
ia->ia_dstaddr = ifra->ifra_dstaddr;
dstIsNew = 1;
}
if (ifra->ifra_addr.sns_family == AF_NS &&
(hostIsNew || dstIsNew))
! error = ns_ifinit(ifp, ia, &ifra->ifra_addr, 0);
return (error);
default:
--- 224,237 ----
if ((ifp->if_flags & IFF_POINTOPOINT) &&
(ifra->ifra_dstaddr.sns_family == AF_NS)) {
if (hostIsNew == 0)
! ns_ifscrub(ifp, (struct ns_ifaddr *)ia);
ia->ia_dstaddr = ifra->ifra_dstaddr;
dstIsNew = 1;
}
if (ifra->ifra_addr.sns_family == AF_NS &&
(hostIsNew || dstIsNew))
! error = ns_ifinit(ifp, (struct ns_ifaddr *)ia,
! &ifra->ifra_addr, 0);
return (error);
default:
***************
*** 250,255 ****
--- 244,250 ----
/*
* Delete any previous route for an old address.
*/
+ void
ns_ifscrub(ifp, ia)
register struct ifnet *ifp;
register struct ns_ifaddr *ia;
***************
*** 266,275 ****
--- 261,272 ----
* 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;
***************
*** 294,300 ****
*/
if (ns_hosteqnh(ns_thishost, ns_zerohost)) {
if (ifp->if_ioctl &&
! (error = (*ifp->if_ioctl)(ifp, SIOCSIFADDR, ia))) {
ia->ia_addr = oldaddr;
splx(s);
return (error);
--- 291,298 ----
*/
if (ns_hosteqnh(ns_thishost, ns_zerohost)) {
if (ifp->if_ioctl &&
! (error = (*ifp->if_ioctl)(ifp, SIOCSIFADDR,
! (caddr_t)ia))) {
ia->ia_addr = oldaddr;
splx(s);
return (error);
***************
*** 304,310 ****
|| ns_hosteqnh(sns->sns_addr.x_host, ns_thishost)) {
*h = ns_thishost;
if (ifp->if_ioctl &&
! (error = (*ifp->if_ioctl)(ifp, SIOCSIFADDR, ia))) {
ia->ia_addr = oldaddr;
splx(s);
return (error);
--- 302,309 ----
|| ns_hosteqnh(sns->sns_addr.x_host, ns_thishost)) {
*h = ns_thishost;
if (ifp->if_ioctl &&
! (error = (*ifp->if_ioctl)(ifp, SIOCSIFADDR,
! (caddr_t)ia))) {
ia->ia_addr = oldaddr;
splx(s);
return (error);
***************
*** 352,358 ****
union ns_net net = dst->x_net;
for (ia = ns_ifaddr; ia; ia = ia->ia_next) {
! if (ifp = ia->ia_ifp) {
if (ifp->if_flags & IFF_POINTOPOINT) {
compare = &satons_addr(ia->ia_dstaddr);
if (ns_hosteq(*dst, *compare))
--- 351,357 ----
union ns_net net = dst->x_net;
for (ia = ns_ifaddr; ia; ia = ia->ia_next) {
! if ((ifp = ia->ia_ifp) != NULL) {
if (ifp->if_flags & IFF_POINTOPOINT) {
compare = &satons_addr(ia->ia_dstaddr);
if (ns_hosteq(*dst, *compare))
Index: netns/ns.h
===================================================================
RCS file: /cvs/src/sys/netns/ns.h,v
retrieving revision 1.16
diff -c -r1.16 ns.h
*** netns/ns.h 6 Sep 2002 16:58:13 -0000 1.16
--- netns/ns.h 5 Mar 2003 07:03:40 -0000
***************
*** 139,145 ****
extern union ns_host ns_broadhost;
extern union ns_net ns_zeronet;
extern union ns_net ns_broadnet;
! u_short ns_cksum(void);
#else
#include <sys/cdefs.h>
--- 139,160 ----
extern union ns_host ns_broadhost;
extern union ns_net ns_zeronet;
extern union ns_net ns_broadnet;
!
! struct route;
! struct ns_ifaddr;
!
! u_short ns_cksum __P(( struct mbuf *, int));
! int ns_output __P((struct mbuf *, struct route *, int));
! int ns_control __P((struct socket *, int, caddr_t, struct ifnet *));
! void ns_init __P((void));
! void idp_forward __P((struct mbuf *));
! void idp_ctlinput __P((int, struct sockaddr *, void *));
! 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 *));
! int ns_ifinit __P((struct ifnet *, struct ns_ifaddr *, struct sockaddr_ns *,
! int));
! void ns_ifscrub __P((struct ifnet *, struct ns_ifaddr *));
#else
#include <sys/cdefs.h>
Index: netns/ns_cksum.c
===================================================================
RCS file: /cvs/src/sys/netns/ns_cksum.c,v
retrieving revision 1.7
diff -c -r1.7 ns_cksum.c
*** netns/ns_cksum.c 28 Aug 1999 00:49:49 -0000 1.7
--- netns/ns_cksum.c 5 Mar 2003 08:08:55 -0000
***************
*** 37,42 ****
--- 37,47 ----
#include <sys/param.h>
#include <sys/mbuf.h>
+ #include <sys/systm.h>
+ #include <sys/socket.h>
+ #include <sys/socketvar.h>
+ #include <netns/ns.h> /* prototype in scope */
+
/*
* Checksum routine for Network Systems Protocol Packets (Big-Endian).
*
Index: netns/ns_error.c
===================================================================
RCS file: /cvs/src/sys/netns/ns_error.c,v
retrieving revision 1.11
diff -c -r1.11 ns_error.c
*** netns/ns_error.c 19 Feb 2003 05:47:37 -0000 1.11
--- netns/ns_error.c 5 Mar 2003 07:09:51 -0000
***************
*** 50,55 ****
--- 50,60 ----
#include <netns/idp.h>
#include <netns/ns_error.h>
+ extern int idpcksum; /* from ns_input.c */
+ /* from spp_usrreq.c XXX */
+ extern void spp_ctlinput( int, struct sockaddr *, void *);
+
+
#ifdef lint
#define NS_ERRPRINTFS 1
#endif
***************
*** 62,68 ****
--- 67,75 ----
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;
***************
*** 86,101 ****
* Generate an error packet of type error
* in response to bad packet.
*/
!
ns_error(om, type, param)
struct mbuf *om;
int type;
{
register struct ns_epidp *ep;
struct mbuf *m;
struct idp *nip;
register struct idp *oip = mtod(om, struct idp *);
- extern int idpcksum;
/*
* If this packet was sent to the echo port,
--- 93,108 ----
* 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;
struct idp *nip;
register struct idp *oip = mtod(om, struct idp *);
/*
* If this packet was sent to the echo port,
***************
*** 165,170 ****
--- 172,178 ----
m_freem(om);
}
+ void
ns_printhost(p)
register struct ns_addr *p;
{
***************
*** 182,192 ****
--- 190,203 ----
/*
* 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;
***************
*** 263,273 ****
#endif
switch(ep->ns_err_idp.idp_pt) {
case NSPROTO_SPP:
! spp_ctlinput(code, (caddr_t)ep);
break;
default:
! idp_ctlinput(code, (caddr_t)ep);
}
goto freeit;
--- 274,284 ----
#endif
switch(ep->ns_err_idp.idp_pt) {
case NSPROTO_SPP:
! spp_ctlinput(code, NULL, ep);
break;
default:
! idp_ctlinput(code, NULL, ep);
}
goto freeit;
***************
*** 295,300 ****
--- 306,312 ----
}
#endif
+ int
ns_echo(m)
struct mbuf *m;
{
Index: netns/ns_error.h
===================================================================
RCS file: /cvs/src/sys/netns/ns_error.h,v
retrieving revision 1.10
diff -c -r1.10 ns_error.h
*** netns/ns_error.h 29 Dec 1999 04:46:19 -0000 1.10
--- netns/ns_error.h 5 Mar 2003 06:03:54 -0000
***************
*** 91,96 ****
--- 91,102 ----
#ifdef _KERNEL
struct ns_errstat ns_errstat;
+
+ int ns_err_x __P((int));
+ void ns_error __P((struct mbuf *, int, int));
+ int ns_echo __P((struct mbuf *));
+ void ns_printhost __P((struct ns_addr *));
+ void ns_err_input __P((struct mbuf *));
#endif
#endif
Index: netns/ns_if.h
===================================================================
RCS file: /cvs/src/sys/netns/ns_if.h,v
retrieving revision 1.16
diff -c -r1.16 ns_if.h
*** netns/ns_if.h 4 Mar 2003 23:19:53 -0000 1.16
--- netns/ns_if.h 5 Mar 2003 06:44:13 -0000
***************
*** 80,88 ****
#endif
#ifdef _KERNEL
! extern struct ns_ifaddr *ns_ifaddr;
! struct ns_ifaddr *ns_iaonnetof(void);
! void nsintr(struct mbuf *);
#endif
#endif
--- 80,91 ----
#endif
#ifdef _KERNEL
! extern struct ns_ifaddr *ns_ifaddr;
!
! struct ns_ifaddr *ns_iaonnetof __P((struct ns_addr *));
! void nsintr __P((struct mbuf *));
!
! extern struct ifqueue nsintrq; /* XNS input packet queue */
#endif
#endif
Index: netns/ns_input.c
===================================================================
RCS file: /cvs/src/sys/netns/ns_input.c,v
retrieving revision 1.19
diff -c -r1.19 ns_input.c
*** netns/ns_input.c 4 Mar 2003 23:19:53 -0000 1.19
--- netns/ns_input.c 5 Mar 2003 08:00:43 -0000
***************
*** 58,77 ****
#include <netns/idp_var.h>
#include <netns/ns_error.h>
/*
* NS initialization.
*/
- union ns_host ns_thishost;
- union ns_host ns_zerohost;
- union ns_host ns_broadhost;
- union ns_net ns_zeronet;
- union ns_net ns_broadnet;
struct sockaddr_ns ns_netmask, ns_hostmask;
static u_short allones[] = {-1, -1, -1};
static struct ifqueue nsintrq;
- struct nspcb nspcb;
struct nspcb nsrawpcb;
int nsqmaxlen = IFQ_MAXLEN;
--- 58,73 ----
#include <netns/idp_var.h>
#include <netns/ns_error.h>
+ extern void spp_input(struct mbuf *, struct nspcb *); /* spp_usrreq.c XXX */
+
/*
* NS initialization.
*/
struct sockaddr_ns ns_netmask, ns_hostmask;
static u_short allones[] = {-1, -1, -1};
static struct ifqueue nsintrq;
struct nspcb nsrawpcb;
int nsqmaxlen = IFQ_MAXLEN;
***************
*** 79,93 ****
int idpcksum = 1;
long ns_pexseq;
ns_init()
{
- extern struct timeval time;
-
ns_broadhost = * (union ns_host *) allones;
ns_broadnet = * (union ns_net *) allones;
nspcb.nsp_next = nspcb.nsp_prev = &nspcb;
nsrawpcb.nsp_next = nsrawpcb.nsp_prev = &nsrawpcb;
! ns_pexseq = time.tv_usec;
ns_netmask.sns_len = 6;
ns_netmask.sns_addr.x_net = ns_broadnet;
ns_hostmask.sns_len = 12;
--- 75,88 ----
int idpcksum = 1;
long ns_pexseq;
+ void
ns_init()
{
ns_broadhost = * (union ns_host *) allones;
ns_broadnet = * (union ns_net *) allones;
nspcb.nsp_next = nspcb.nsp_prev = &nspcb;
nsrawpcb.nsp_next = nsrawpcb.nsp_prev = &nsrawpcb;
! ns_pexseq = tick;
ns_netmask.sns_len = 6;
ns_netmask.sns_addr.x_net = ns_broadnet;
ns_hostmask.sns_len = 12;
***************
*** 109,115 ****
register struct idp *idp;
register struct nspcb *nsp;
register int i;
! int len, s, error;
char oddpacketp;
/*
--- 104,110 ----
register struct idp *idp;
register struct nspcb *nsp;
register int i;
! int len, error;
char oddpacketp;
/*
***************
*** 128,139 ****
*/
for (nsp = nsrawpcb.nsp_next; nsp != &nsrawpcb; nsp = nsp->nsp_next) {
struct mbuf *m1 = m_copy(m, 0, (int)M_COPYALL);
! if (m1) idp_input(m1, nsp);
}
idp = mtod(m, struct idp *);
len = ntohs(idp->idp_len);
! if (oddpacketp = len & 1) {
len++; /* If this packet is of odd length,
preserve garbage byte for checksum */
}
--- 123,134 ----
*/
for (nsp = nsrawpcb.nsp_next; nsp != &nsrawpcb; nsp = nsp->nsp_next) {
struct mbuf *m1 = m_copy(m, 0, (int)M_COPYALL);
! if (m1) idp_input(m1, (int)nsp);
}
idp = mtod(m, struct idp *);
len = ntohs(idp->idp_len);
! if ((oddpacketp = (len & 1))) {
len++; /* If this packet is of odd length,
preserve garbage byte for checksum */
}
***************
*** 221,227 ****
ns_err_input(m);
return;
}
! idp_input(m, nsp);
} else {
ns_error(m, NS_ERR_NOSOCK, 0);
}
--- 216,222 ----
ns_err_input(m);
return;
}
! idp_input(m, (int)nsp);
} else {
ns_error(m, NS_ERR_NOSOCK, 0);
}
***************
*** 242,256 ****
int idp_donosocks = 1;
! idp_ctlinput(cmd, arg)
int cmd;
! caddr_t arg;
{
struct ns_addr *ns;
struct nspcb *nsp;
! struct ns_errp *errp;
! int idp_abort();
! extern struct nspcb *idp_drop();
int type;
if (cmd < 0 || cmd > PRC_NCMDS)
--- 237,252 ----
int idp_donosocks = 1;
! /* ARGSUSED */
! void
! idp_ctlinput(cmd, sa, arg)
int cmd;
! struct sockaddr *sa;
! void *arg;
{
struct ns_addr *ns;
struct nspcb *nsp;
! struct ns_errp *errp = (struct ns_errp *)arg; /* XXX */
int type;
if (cmd < 0 || cmd > PRC_NCMDS)
***************
*** 301,306 ****
--- 297,303 ----
struct route idp_droute;
struct route idp_sroute;
+ void
idp_forward(m)
struct mbuf *m;
{
***************
*** 420,425 ****
--- 417,423 ----
m_freem(mcopy);
}
+ int
idp_do_route(src, ro)
struct ns_addr *src;
struct route *ro;
***************
*** 442,453 ****
--- 440,453 ----
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;
***************
*** 469,483 ****
idp->idp_sna.x_net = ns_zeronet;
idp->idp_sna.x_host = ns_thishost;
if (ifp && (ifp->if_flags & IFF_POINTOPOINT))
! for(ifa = ifp->if_addrlist; ifa;
! ifa = ifa->ifa_next) {
if (ifa->ifa_addr->sa_family==AF_NS) {
idp->idp_sna = IA_SNS(ifa)->sns_addr;
break;
}
- }
idp->idp_len = ntohl(m0->m_pkthdr.len);
! idp_input(m0, nsp);
}
}
}
--- 469,481 ----
idp->idp_sna.x_net = ns_zeronet;
idp->idp_sna.x_host = ns_thishost;
if (ifp && (ifp->if_flags & IFF_POINTOPOINT))
! TAILQ_FOREACH(ifa, &ifp->if_addrhead, ifa_link)
if (ifa->ifa_addr->sa_family==AF_NS) {
idp->idp_sna = IA_SNS(ifa)->sns_addr;
break;
}
idp->idp_len = ntohl(m0->m_pkthdr.len);
! idp_input(m0, (int)nsp);
}
}
}
Index: netns/ns_output.c
===================================================================
RCS file: /cvs/src/sys/netns/ns_output.c,v
retrieving revision 1.8
diff -c -r1.8 ns_output.c
*** netns/ns_output.c 3 Nov 2001 13:35:07 -0000 1.8
--- netns/ns_output.c 5 Mar 2003 06:45:54 -0000
***************
*** 35,40 ****
--- 35,41 ----
*/
#include <sys/param.h>
+ #include <sys/systm.h>
#include <sys/malloc.h>
#include <sys/mbuf.h>
#include <sys/errno.h>
***************
*** 54,59 ****
--- 55,61 ----
int ns_output_cnt = 0;
struct mbuf *ns_lastout;
+ int
ns_output(m0, ro, flags)
struct mbuf *m0;
struct route *ro;
***************
*** 64,70 ****
int error = 0;
struct route idproute;
struct sockaddr_ns *dst;
- extern int idpcksum;
if (ns_hold_output) {
if (ns_lastout) {
--- 66,71 ----
Index: netns/ns_pcb.c
===================================================================
RCS file: /cvs/src/sys/netns/ns_pcb.c,v
retrieving revision 1.14
diff -c -r1.14 ns_pcb.c
*** netns/ns_pcb.c 19 Feb 2003 05:47:37 -0000 1.14
--- netns/ns_pcb.c 5 Mar 2003 08:06:16 -0000
***************
*** 51,56 ****
--- 51,57 ----
struct ns_addr zerons_addr;
+ int
ns_pcballoc(so, head)
struct socket *so;
struct nspcb *head;
***************
*** 58,64 ****
struct mbuf *m;
register struct nspcb *nsp;
! m = m_getclr(M_DONTWAIT, MT_PCB);
if (m == NULL)
return (ENOBUFS);
nsp = mtod(m, struct nspcb *);
--- 59,65 ----
struct mbuf *m;
register struct nspcb *nsp;
! m = m_getclr(M_DONTWAIT, MT_CONTROL); /* protocol private PCB */
if (m == NULL)
return (ENOBUFS);
nsp = mtod(m, struct nspcb *);
***************
*** 68,73 ****
--- 69,75 ----
return (0);
}
+ int
ns_pcbbind(nsp, nam)
register struct nspcb *nsp;
struct mbuf *nam;
***************
*** 92,102 ****
--- 94,107 ----
}
lport = sns->sns_port;
if (lport) {
+ #ifdef NS_PRIV_SOCKETS
u_short aport = ntohs(lport);
if (aport < NSPORT_RESERVED &&
(nsp->nsp_socket->so_state & SS_PRIV) == 0)
return (EACCES);
+ #endif /* NS_PRIV_SOCKETS */
+
if (ns_pcblookup(&zerons_addr, lport, 0))
return (EADDRINUSE);
}
***************
*** 118,123 ****
--- 123,129 ----
* 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;
***************
*** 217,222 ****
--- 223,229 ----
return (0);
}
+ void
ns_pcbdisconnect(nsp)
struct nspcb *nsp;
{
***************
*** 226,231 ****
--- 233,239 ----
ns_pcbdetach(nsp);
}
+ void
ns_pcbdetach(nsp)
struct nspcb *nsp;
{
***************
*** 239,244 ****
--- 247,253 ----
(void) m_free(dtom(nsp));
}
+ void
ns_setsockaddr(nsp, nam)
register struct nspcb *nsp;
struct mbuf *nam;
***************
*** 253,258 ****
--- 262,268 ----
sns->sns_addr = nsp->nsp_laddr;
}
+ void
ns_setpeeraddr(nsp, nam)
register struct nspcb *nsp;
struct mbuf *nam;
***************
*** 274,283 ****
* Also pass an extra paramter via the nspcb. (which may in fact
* be a parameter list!)
*/
ns_pcbnotify(dst, errno, notify, param)
register struct ns_addr *dst;
long param;
! int errno, (*notify)();
{
register struct nspcb *nsp, *oinp;
int s = splimp();
--- 284,295 ----
* 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;
! void (*notify)(struct nspcb *);
! int errno;
{
register struct nspcb *nsp, *oinp;
int s = splimp();
***************
*** 361,364 ****
--- 373,401 ----
}
}
return (match);
+ }
+
+ #include <netns/idp.h>
+ #include <netns/idp_var.h>
+
+ /*
+ * Given an mbuf with a struct idp in it, return the npcb that matches
+ *
+ * XXX Dirty; sorry
+ */
+ struct nspcb *
+ ns_pcblookupm(struct mbuf *m)
+ {
+ register struct idp *idp;
+ register struct nspcb *nsp;
+
+ if ((m->m_flags & M_EXT || m->m_len < sizeof (struct idp)) &&
+ (m = m_pullup(m, sizeof (struct idp))) == 0) {
+ idpstat.idps_toosmall++;
+ return( NULL); /* XXX */
+ }
+ idp = mtod(m, struct idp *);
+ nsp = ns_pcblookup(&idp->idp_sna, idp->idp_dna.x_port, NS_WILDCARD);
+
+ return(nsp);
}
Index: netns/ns_pcb.h
===================================================================
RCS file: /cvs/src/sys/netns/ns_pcb.h,v
retrieving revision 1.11
diff -c -r1.11 ns_pcb.h
*** netns/ns_pcb.h 29 Dec 1999 04:46:20 -0000 1.11
--- netns/ns_pcb.h 5 Mar 2003 08:02:19 -0000
***************
*** 79,85 ****
#ifdef _KERNEL
struct nspcb nspcb; /* head of list */
! struct nspcb *ns_pcblookup();
#endif
#endif
--- 79,94 ----
#ifdef _KERNEL
struct nspcb nspcb; /* head of list */
! struct nspcb *ns_pcblookupm __P((struct mbuf *m));
! struct nspcb *ns_pcblookup __P((struct ns_addr *, u_short, int));
! void ns_pcbdisconnect __P((struct nspcb *));
! void ns_pcbdetach __P((struct nspcb *));
! 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_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));
#endif
#endif
Index: netns/ns_proto.c
===================================================================
RCS file: /cvs/src/sys/netns/ns_proto.c,v
retrieving revision 1.10
diff -c -r1.10 ns_proto.c
*** netns/ns_proto.c 28 Aug 1999 00:49:51 -0000 1.10
--- netns/ns_proto.c 5 Mar 2003 07:49:28 -0000
***************
*** 44,62 ****
#include <net/radix.h>
#include <netns/ns.h>
/*
* NS protocol family: IDP, ERR, PE, SPP, ROUTE.
*/
- int ns_init();
- int idp_input(), idp_output(), idp_ctlinput(), idp_usrreq();
- int idp_raw_usrreq(), idp_ctloutput();
- int spp_input(), spp_ctlinput();
- int spp_usrreq(), spp_usrreq_sp(), spp_ctloutput();
- int spp_init(), spp_fasttimo(), spp_slowtimo();
- extern int raw_usrreq();
- extern struct domain nsdomain;
struct protosw nssw[] = {
{ 0, &nsdomain, 0, 0,
--- 44,70 ----
#include <net/radix.h>
#include <netns/ns.h>
+ #include <netns/idp_var.h>
+
+ /* XXX+ */
+ void spp_input( struct mbuf *, int);
+ void spp_ctlinput( int, struct sockaddr *, void *);
+ int spp_ctloutput( struct socket *, struct sockopt *);
+ int spp_usrreq( struct socket *, int, struct mbuf *, struct mbuf *,
+ struct mbuf *, struct thread *);
+ int spp_usrreq_sp( struct socket *, int, struct mbuf *, struct mbuf *,
+ struct mbuf *, struct thread *);
+ void spp_init(void);
+ void spp_fasttimo(void);
+ void spp_slowtimo(void);
+
+ /* XXX- */
+
/*
* NS protocol family: IDP, ERR, PE, SPP, ROUTE.
*/
struct protosw nssw[] = {
{ 0, &nsdomain, 0, 0,
***************
*** 85,91 ****
0, 0, 0, 0,
},
{ SOCK_RAW, &nsdomain, NSPROTO_ERROR, PR_ATOMIC|PR_ADDR,
! idp_ctlinput, idp_output, 0, idp_ctloutput,
idp_raw_usrreq,
0, 0, 0, 0,
},
--- 93,99 ----
0, 0, 0, 0,
},
{ SOCK_RAW, &nsdomain, NSPROTO_ERROR, PR_ATOMIC|PR_ADDR,
! /* XXX idp_ctlinput*/ 0, idp_output, 0, idp_ctloutput,
idp_raw_usrreq,
0, 0, 0, 0,
},
Index: netns/spp_debug.c
===================================================================
RCS file: /cvs/src/sys/netns/spp_debug.c,v
retrieving revision 1.10
diff -c -r1.10 spp_debug.c
*** netns/spp_debug.c 28 Aug 1999 00:49:52 -0000 1.10
--- netns/spp_debug.c 5 Mar 2003 06:03:54 -0000
***************
*** 64,69 ****
--- 64,70 ----
/*
* spp debug routines
*/
+ void
spp_trace(act, ostate, sp, si, req)
short act;
u_char ostate;
Index: netns/spp_debug.h
===================================================================
RCS file: /cvs/src/sys/netns/spp_debug.h,v
retrieving revision 1.9
diff -c -r1.9 spp_debug.h
*** netns/spp_debug.h 28 Aug 1999 00:49:53 -0000 1.9
--- netns/spp_debug.h 5 Mar 2003 06:03:55 -0000
***************
*** 63,65 ****
--- 63,70 ----
int spp_debx;
#endif
+
+ #ifdef _KERNEL
+
+ void spp_trace __P(( short, u_char, struct sppcb *, struct spidp *, int));
+ #endif
Index: netns/spp_usrreq.c
===================================================================
RCS file: /cvs/src/sys/netns/spp_usrreq.c,v
retrieving revision 1.19
diff -c -r1.19 spp_usrreq.c
*** netns/spp_usrreq.c 19 Feb 2003 05:47:38 -0000 1.19
--- netns/spp_usrreq.c 5 Mar 2003 08:12:56 -0000
***************
*** 58,66 ****
--- 58,73 ----
#include <netns/spp_var.h>
#include <netns/spp_debug.h>
+ extern u_char nsctlerrmap[]; /* from ns_input.c */
+ extern int idpcksum; /* from ns_input.c */
+
+ int spp_backoff[SPP_MAXRXTSHIFT+1] =
+ { 1, 2, 4, 8, 16, 32, 64, 64, 64, 64, 64, 64, 64 };
+
/*
* SP protocol implementation.
*/
+ void
spp_init()
{
***************
*** 74,87 ****
u_short spp_newchecks[50];
/*ARGSUSED*/
! spp_input(m, nsp)
register struct mbuf *m;
! register struct nspcb *nsp;
{
register struct sppcb *cb;
register struct spidp *si = mtod(m, struct spidp *);
register struct socket *so;
! short ostate;
int dropsocket = 0;
--- 81,96 ----
u_short spp_newchecks[50];
/*ARGSUSED*/
! void
! spp_input(m, nsp0)
register struct mbuf *m;
! int nsp0; /* XXX offset */
{
+ register struct nspcb *nsp = ns_pcblookupm(m);
register struct sppcb *cb;
register struct spidp *si = mtod(m, struct spidp *);
register struct socket *so;
! short ostate = 0; /* compiler erroneously flags */
int dropsocket = 0;
***************
*** 287,292 ****
--- 296,302 ----
* 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;
***************
*** 415,423 ****
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 &&
(SSEQ_LT(cb->s_swl2, si->si_ack) ||
! 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)) {
--- 425,433 ----
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 &&
(SSEQ_LT(cb->s_swl2, si->si_ack) ||
! (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)) {
***************
*** 575,589 ****
return (0);
}
! spp_ctlinput(cmd, arg)
int cmd;
! caddr_t arg;
{
struct ns_addr *na;
! extern u_char nsctlerrmap[];
! extern spp_abort(), spp_quench();
! extern struct nspcb *idp_drop();
! struct ns_errp *errp;
struct nspcb *nsp;
struct sockaddr_ns *sns;
int type;
--- 585,599 ----
return (0);
}
! /* ARGSUSED */
! void
! spp_ctlinput(cmd, sa, arg)
int cmd;
! struct sockaddr *sa;
! void *arg;
{
struct ns_addr *na;
! struct ns_errp *errp = 0; /* compiler erroneously flags */
struct nspcb *nsp;
struct sockaddr_ns *sns;
int type;
***************
*** 639,644 ****
--- 649,655 ----
* 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;
{
***************
*** 696,701 ****
--- 707,713 ----
}
#endif
+ int
spp_output(cb, m0)
register struct sppcb *cb;
struct mbuf *m0;
***************
*** 712,718 ****
int idle;
#endif
struct mbuf *mprev;
- extern int idpcksum;
if (m0) {
int mtu = cb->s_mtu;
--- 724,729 ----
***************
*** 1111,1121 ****
int spp_do_persist_panics = 0;
spp_setpersist(cb)
register struct sppcb *cb;
{
! register t = ((cb->s_srtt >> 2) + cb->s_rttvar) >> 1;
! extern int spp_backoff[];
if (cb->s_timer[SPPT_REXMT] && spp_do_persist_panics)
panic("spp_output REXMT");
--- 1122,1132 ----
int spp_do_persist_panics = 0;
+ void
spp_setpersist(cb)
register struct sppcb *cb;
{
! register int t = ((cb->s_srtt >> 2) + cb->s_rttvar) >> 1;
if (cb->s_timer[SPPT_REXMT] && spp_do_persist_panics)
panic("spp_output REXMT");
***************
*** 1129,1149 ****
cb->s_rxtshift++;
}
/*ARGSUSED*/
! spp_ctloutput(req, so, level, name, value)
! int req;
struct socket *so;
! int name;
! struct mbuf **value;
{
register struct mbuf *m;
struct nspcb *nsp = sotonspcb(so);
register struct sppcb *cb;
int mask, error = 0;
! if (level != NSPROTO_SPP) {
/* This will have to be changed when we do more general
stacking of protocols */
! return (idp_ctloutput(req, so, level, name, value));
}
if (nsp == NULL) {
error = EINVAL;
--- 1140,1160 ----
cb->s_rxtshift++;
}
/*ARGSUSED*/
! int
! spp_ctloutput( so, sopt)
struct socket *so;
! struct sockopt *sopt;
{
+ struct mbuf **value = sopt->sopt_val; /* XXX dangerous */
register struct mbuf *m;
struct nspcb *nsp = sotonspcb(so);
register struct sppcb *cb;
int mask, error = 0;
! if (sopt->sopt_level != NSPROTO_SPP) {
/* This will have to be changed when we do more general
stacking of protocols */
! return (idp_ctloutput(so, sopt));
}
if (nsp == NULL) {
error = EINVAL;
***************
*** 1151,1157 ****
} else
cb = nstosppcb(nsp);
! switch (req) {
case PRCO_GETOPT:
if (value == NULL)
--- 1162,1168 ----
} else
cb = nstosppcb(nsp);
! switch (sopt->sopt_dir) {
case PRCO_GETOPT:
if (value == NULL)
***************
*** 1159,1165 ****
m = m_get(M_DONTWAIT, MT_DATA);
if (m == NULL)
return (ENOBUFS);
! switch (name) {
case SO_HEADERS_ON_INPUT:
mask = SF_HI;
--- 1170,1176 ----
m = m_get(M_DONTWAIT, MT_DATA);
if (m == NULL)
return (ENOBUFS);
! switch (sopt->sopt_name) {
case SO_HEADERS_ON_INPUT:
mask = SF_HI;
***************
*** 1198,1204 ****
error = EINVAL;
break;
}
! switch (name) {
int *ok;
case SO_HEADERS_ON_INPUT:
--- 1209,1215 ----
error = EINVAL;
break;
}
! switch (sopt->sopt_name) {
int *ok;
case SO_HEADERS_ON_INPUT:
***************
*** 1254,1266 ****
}
/*ARGSUSED*/
! 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;
int s = splnet();
int error = 0, ostate;
struct mbuf *mm;
--- 1265,1279 ----
}
/*ARGSUSED*/
! int
! spp_usrreq(so, req, m, nam, controlp, td)
struct socket *so;
int req;
struct mbuf *m, *nam, *controlp;
+ struct thread *td;
{
struct nspcb *nsp = sotonspcb(so);
! register struct sppcb *cb = NULL;
int s = splnet();
int error = 0, ostate;
struct mbuf *mm;
***************
*** 1296,1302 ****
}
nsp = sotonspcb(so);
! mm = m_getclr(M_DONTWAIT, MT_PCB);
sb = &so->so_snd;
if (mm == NULL) {
--- 1309,1316 ----
}
nsp = sotonspcb(so);
! /* private PCB */
! mm = m_getclr(M_DONTWAIT, MT_CONTROL);
sb = &so->so_snd;
if (mm == NULL) {
***************
*** 1506,1517 ****
return (error);
}
! spp_usrreq_sp(so, req, m, nam, controlp)
struct socket *so;
int req;
struct mbuf *m, *nam, *controlp;
{
! int error = spp_usrreq(so, req, m, nam, controlp);
if (req == PRU_ATTACH && error == 0) {
struct nspcb *nsp = sotonspcb(so);
--- 1520,1533 ----
return (error);
}
! int
! spp_usrreq_sp(so, req, m, nam, controlp, td)
struct socket *so;
int req;
struct mbuf *m, *nam, *controlp;
+ struct thread *td;
{
! int error = spp_usrreq(so, req, m, nam, controlp, td);
if (req == PRU_ATTACH && error == 0) {
struct nspcb *nsp = sotonspcb(so);
***************
*** 1527,1532 ****
--- 1543,1549 ----
* 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;
{
***************
*** 1621,1626 ****
--- 1638,1644 ----
return (spp_close(cb));
}
+ void
spp_abort(nsp)
struct nspcb *nsp;
{
***************
*** 1628,1638 ****
(void) spp_close((struct sppcb *)nsp->nsp_pcb);
}
- int spp_backoff[SPP_MAXRXTSHIFT+1] =
- { 1, 2, 4, 8, 16, 32, 64, 64, 64, 64, 64, 64, 64 };
/*
* Fast timeout routine for processing delayed acks
*/
spp_fasttimo()
{
register struct nspcb *nsp;
--- 1646,1655 ----
(void) spp_close((struct sppcb *)nsp->nsp_pcb);
}
/*
* Fast timeout routine for processing delayed acks
*/
+ void
spp_fasttimo()
{
register struct nspcb *nsp;
***************
*** 1657,1662 ****
--- 1674,1680 ----
* 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,1688 ****
(void) spp_usrreq(cb->s_nspcb->nsp_socket,
PRU_SLOWTIMO, (struct mbuf *)0,
(struct mbuf *)i, (struct mbuf *)0,
! (struct mbuf *)0);
if (ipnxt->nsp_prev != ip)
goto tpgone;
}
--- 1700,1706 ----
(void) spp_usrreq(cb->s_nspcb->nsp_socket,
PRU_SLOWTIMO, (struct mbuf *)0,
(struct mbuf *)i, (struct mbuf *)0,
! (struct thread *)0);
if (ipnxt->nsp_prev != ip)
goto tpgone;
}
Index: netns/spp_var.h
===================================================================
RCS file: /cvs/src/sys/netns/spp_var.h,v
retrieving revision 1.11
diff -c -r1.11 spp_var.h
*** netns/spp_var.h 29 Dec 1999 04:46:21 -0000 1.11
--- netns/spp_var.h 5 Mar 2003 08:10:06 -0000
***************
*** 194,202 ****
#define sppstat spp_istat.newstats
#endif
u_short spp_iss;
! extern struct sppcb *spp_close(), *spp_disconnect(),
! *spp_usrclosed(), *spp_timers(), *spp_drop();
#endif
#define SPP_ISSINCR 128
--- 194,226 ----
#define sppstat spp_istat.newstats
#endif
+ struct thread; /* not used */
+
u_short spp_iss;
!
! void spp_init __P((void));
! void spp_input __P((struct mbuf *, int));
! void spp_ctlinput __P((int, struct sockaddr *, void *));
! int spp_ctloutput __P((struct socket *, struct sockopt *));
! int spp_usrreq __P((struct socket *, int, struct mbuf *, struct mbuf *,
! struct mbuf *, struct thread *));
! int spp_usrreq_sp __P((struct socket *, int, struct mbuf *, struct mbuf *,
! struct mbuf *, struct thread *));
! void spp_fasttimo __P((void));
! void spp_slowtimo __P((void));
! void spp_template __P((struct sppcb *));
! int spp_reass __P((struct sppcb *, struct spidp *));
! int spp_output __P((struct sppcb *, struct mbuf *));
! void spp_quench __P((struct nspcb *));
! void spp_abort __P((struct nspcb *));
! void spp_setpersist __P((struct sppcb *));
!
! struct sppcb *spp_close __P((struct sppcb *));
! struct sppcb *spp_disconnect __P((struct sppcb *));
! struct sppcb *spp_usrclosed __P((struct sppcb *));
! struct sppcb *spp_timers __P((struct sppcb *, int));
! struct sppcb *spp_drop __P((struct sppcb *, int));
!
#endif
#define SPP_ISSINCR 128