kernel: Remove support for the Xerox Network Systems (NS) protocol.
authorSascha Wildner <saw@online.de>
Sun, 2 Jan 2011 19:16:05 +0000 (20:16 +0100)
committerSascha Wildner <saw@online.de>
Sun, 2 Jan 2011 19:16:19 +0000 (20:16 +0100)
It was previously removed from LINT with commit 67bf99c4 and its removal
was also announced here:

http://leaf.dragonflybsd.org/mailarchive/kernel/2010-09/msg00025.html

To be on the safe side, bump _DragonFly_version due to /usr/include/netns
going away. In the unlikely event of something breaking in pkgsrc we'll
have a version to patch against, if needed.

52 files changed:
Makefile_upgrade.inc
etc/mtree/BSD.include.dist
include/Makefile
sbin/route/extern.h
sbin/route/route.c
sbin/route/show.c
share/man/man7/hier.7
sys/conf/files
sys/conf/options
sys/config/LINT
sys/dev/netif/de/if_de.c
sys/dev/netif/fxp/if_fxp.c
sys/dev/netif/rdp/if_rdp.c
sys/dev/netif/sn/if_sn.c
sys/kern/Make.tags.inc
sys/kern/Makefile
sys/kern/Makefile.misc
sys/net/gre/Makefile
sys/net/gre/if_gre.c
sys/net/if_ethersubr.c
sys/net/if_loop.c
sys/net/sppp/if_spppsubr.c
sys/netinet/in_proto.c
sys/netinet/ip_gre.c
sys/netproto/ns/idp.h [deleted file]
sys/netproto/ns/idp_usrreq.c [deleted file]
sys/netproto/ns/idp_var.h [deleted file]
sys/netproto/ns/ns.c [deleted file]
sys/netproto/ns/ns.h [deleted file]
sys/netproto/ns/ns_cksum.c [deleted file]
sys/netproto/ns/ns_error.c [deleted file]
sys/netproto/ns/ns_error.h [deleted file]
sys/netproto/ns/ns_if.h [deleted file]
sys/netproto/ns/ns_input.c [deleted file]
sys/netproto/ns/ns_ip.c [deleted file]
sys/netproto/ns/ns_output.c [deleted file]
sys/netproto/ns/ns_pcb.c [deleted file]
sys/netproto/ns/ns_pcb.h [deleted file]
sys/netproto/ns/ns_proto.c [deleted file]
sys/netproto/ns/sp.h [deleted file]
sys/netproto/ns/spidp.h [deleted file]
sys/netproto/ns/spp_debug.c [deleted file]
sys/netproto/ns/spp_debug.h [deleted file]
sys/netproto/ns/spp_timer.h [deleted file]
sys/netproto/ns/spp_usrreq.c [deleted file]
sys/netproto/ns/spp_var.h [deleted file]
sys/sys/param.h
usr.bin/netstat/Makefile
usr.bin/netstat/if.c
usr.bin/netstat/main.c
usr.bin/netstat/ns.c [deleted file]
usr.bin/netstat/route.c

index 44865f5..d3de12b 100644 (file)
@@ -1550,6 +1550,8 @@ TO_REMOVE+=/usr/share/man/cat4/ahb.4.gz
 TO_REMOVE+=/usr/share/man/man4/ahb.4.gz
 TO_REMOVE+=/boot/kernel/ahc_eisa.ko
 TO_REMOVE+=/boot/kernel/ahc_isa.ko
+TO_REMOVE+=/usr/include/netproto/ns
+TO_REMOVE+=/usr/include/netns
 
 # XXX Remove when pfsync(4) has been fixed
 TO_REMOVE+=/usr/share/man/cat4/pfsync.4.gz
index 828e645..e829d12 100644 (file)
         ..
         ncp
         ..
-        ns
-        ..
         smb
         ..
     ..
index f004309..ae7d129 100644 (file)
@@ -68,7 +68,7 @@ LSUBDIRS=     bus/cam bus/cam/scsi \
        netgraph/tee netgraph/tty netgraph/vjc \
        bus/cam bus/usb bus/pccard bus/pci bus/isa bus/ppbus bus/smbus \
        netproto/atalk netproto/atm netproto/ipsec netproto/ipx \
-       netproto/key netproto/natm netproto/ncp netproto/ns netproto/smb \
+       netproto/key netproto/natm netproto/ncp netproto/smb \
        netproto/atm/ipatm netproto/atm/sigpvc netproto/atm/spans \
        netproto/atm/uni netproto/802_11 netproto/mpls \
        vfs/isofs/cd9660 net/i4b/include \
@@ -134,7 +134,6 @@ INCSLINKS+= netproto/ipx ${INCLUDEDIR}/netipx
 INCSLINKS+=    netproto/key ${INCLUDEDIR}/netkey
 INCSLINKS+=    netproto/natm ${INCLUDEDIR}/netnatm
 INCSLINKS+=    netproto/ncp ${INCLUDEDIR}/netncp
-INCSLINKS+=    netproto/ns ${INCLUDEDIR}/netns
 INCSLINKS+=    netproto/smb ${INCLUDEDIR}/netsmb
 INCSLINKS+=    bus/pccard ${INCLUDEDIR}/pccard
 
index bb2b306..1543211 100644 (file)
@@ -46,6 +46,3 @@ char  *routename(struct sockaddr *);
 char   *netname(struct sockaddr *);
 int     keyword(const char *);
 void    usage(const char *) __dead2;
-#ifdef NS
-char   *ns_print(struct sockaddr_ns *);
-#endif
index 432d968..26ae9ef 100644 (file)
@@ -49,9 +49,6 @@
 #include <netinet/in.h>
 #include <netinet/if_ether.h>
 #include <netatalk/at.h>
-#ifdef NS
-#include <netns/ns.h>
-#endif
 #include <arpa/inet.h>
 #include <netdb.h>
 
@@ -78,9 +75,6 @@ union sockunion {
        struct  sockaddr_in6 sin6;
 #endif
        struct  sockaddr_at sat;
-#ifdef NS
-       struct  sockaddr_ns sns;
-#endif
        struct  sockaddr_mpls smpls;
        struct  sockaddr_dl sdl;
        struct  sockaddr_inarp sinarp;
@@ -103,9 +97,6 @@ static int   locking, lockrest, debugonly;
 static int     mplsop, popcount, pushcount, swapcount;
 static u_long  rtm_inits;
 static uid_t   uid;
-#ifdef NS
-static short   ns_bh[] = {-1,-1,-1};
-#endif
 
 static int      atalk_aton(const char *, struct at_addr *);
 static char    *atalk_ntoa(struct at_addr);
@@ -251,11 +242,6 @@ flushroutes(int argc, char **argv)
                        case K_ATALK:
                                af = AF_APPLETALK;
                                break;
-#ifdef NS
-                       case K_XNS:
-                               af = AF_NS;
-                               break;
-#endif
                        case K_LINK:
                                af = AF_LINK;
                                break;
@@ -426,11 +412,6 @@ routename(struct sockaddr *sa)
                        atalk_ntoa(((struct sockaddr_at *)sa)->sat_addr));
                break;
 
-#ifdef NS
-       case AF_NS:
-               return(ns_print((struct sockaddr_ns *)sa));
-#endif
-
        case AF_LINK:
                return(link_ntoa((struct sockaddr_dl *)sa));
 
@@ -560,12 +541,6 @@ netname(struct sockaddr *sa)
                        atalk_ntoa(((struct sockaddr_at *)sa)->sat_addr));
                break;
 
-#ifdef NS
-       case AF_NS:
-               return(ns_print((struct sockaddr_ns *)sa));
-               break;
-#endif
-
        case AF_LINK:
                return(link_ntoa((struct sockaddr_dl *)sa));
 
@@ -654,12 +629,6 @@ newroute(int argc, char **argv)
                                af = PF_ROUTE;
                                aflen = sizeof(union sockunion);
                                break;
-#ifdef NS
-                       case K_XNS:
-                               af = AF_NS;
-                               aflen = sizeof(struct sockaddr_ns);
-                               break;
-#endif
                        case K_IFACE:
                        case K_INTERFACE:
                                iflag++;
@@ -1132,20 +1101,6 @@ getaddr(int which, const char *str, struct hostent **hpp)
        }
 #endif /* INET6 */
 
-#ifdef NS
-       case AF_NS:
-               if (which == RTA_DST) {
-                       struct sockaddr_ns *sms = &(so_mask.sns);
-                       memset(sms, 0, sizeof(*sms));
-                       sms->sns_family = 0;
-                       sms->sns_len = 6;
-                       sms->sns_addr.x_net = *(union ns_net *)ns_bh;
-                       rtm_addrs |= RTA_NETMASK;
-               }
-               su->sns.sns_addr = ns_addr(str);
-               return(!ns_nullhost(su->sns.sns_addr));
-#endif
-
        case AF_APPLETALK:
                if (!atalk_aton(str, &su->sat.sat_addr))
                        errx(EX_NOHOST, "bad address: %s", str);
@@ -1271,56 +1226,6 @@ prefixlen(const char *len_str)
                return(len);
 }
 
-#ifdef NS
-short ns_nullh[] = {0,0,0};
-
-char *
-ns_print(struct sockaddr_ns *sns)
-{
-       struct ns_addr work;
-       union { union ns_net net_e; u_long long_e; } net;
-       u_short port;
-       static char mybuf[50+MAXHOSTNAMELEN], cport[10], chost[25];
-       const char *host = "";
-       char *p;
-       u_char *q;
-
-       work = sns->sns_addr;
-       port = ntohs(work.x_port);
-       work.x_port = 0;
-       net.net_e  = work.x_net;
-       if (ns_nullhost(work) && net.long_e == 0) {
-               if (port == 0)
-                       strncpy(mybuf, "*.*", sizeof(mybuf));
-               else
-                       sprintf(mybuf, "*.%XH", port);
-               return(mybuf);
-       }
-
-       if (memcmp(ns_bh, work.x_host.c_host, 6) == 0)
-               host = "any";
-       else if (memcmp(ns_nullh, work.x_host.c_host, 6) == 0)
-               host = "*";
-       else {
-               q = work.x_host.c_host;
-               sprintf(chost, "%02X%02X%02X%02X%02X%02XH",
-                       q[0], q[1], q[2], q[3], q[4], q[5]);
-               for (p = chost; *p == '0' && p < chost + 12; p++)
-                       /* void */;
-               host = p;
-       }
-       if (port != 0)
-               sprintf(cport, ".%XH", htons(port));
-       else
-               *cport = 0;
-
-       snprintf(mybuf, sizeof(mybuf), "%lxH.%s%s",
-                       (unsigned long)ntohl(net.long_e),
-                       host, cport);
-       return(mybuf);
-}
-#endif
-
 static void
 interfaces(void)
 {
@@ -1458,9 +1363,6 @@ mask_addr(void)
        if ((rtm_addrs & RTA_DST) == 0)
                return;
        switch (so_dst.sa.sa_family) {
-#ifdef NS
-       case AF_NS:
-#endif
        case AF_INET:
 #ifdef INET6
        case AF_INET6:
@@ -1763,12 +1665,6 @@ sodump(sup su, const char *which)
                printf("%s: atalk %s; ",
                    which, atalk_ntoa(su->sat.sat_addr));
                break;
-#ifdef NS
-       case AF_NS:
-               printf("%s: xns %s; ",
-                   which, ns_ntoa(su->sns.sns_addr));
-               break;
-#endif
        }
        fflush(stdout);
 }
index 96dd9a4..e8956dd 100644 (file)
@@ -42,7 +42,6 @@
 #include <net/if_types.h>
 #include <net/route.h>
 #include <netinet/in.h>
-#include <netns/ns.h>
 #include <arpa/inet.h>
 
 #include <sys/sysctl.h>
@@ -366,12 +365,6 @@ p_sockaddr(struct sockaddr *sa, int flags, int width)
            }
 #endif /* INET6 */
 
-#ifdef NS
-       case AF_NS:
-               cp = ns_print((struct sockaddr_ns *)sa);
-               break;
-#endif
-
        default:
            {
                u_char *s = (u_char *)sa->sa_data, *slim;
index 4d8bf6a..1c12a59 100644 (file)
@@ -230,8 +230,6 @@ kernel key-management service
 NATM include files;
 see
 .Xr natm 4
-.It Pa netns/
-Xerox NS protocols
 .It Pa netsmb/
 SMB/CIFS requester
 .It Pa nfs/
index 6793b11..38a4b87 100644 (file)
@@ -1545,17 +1545,6 @@ netproto/ncp/ncp_nls.c           optional ncp
 netproto/ncp/ncp_rq.c          optional ncp
 netproto/ncp/ncp_sock.c                optional ncp
 netproto/ncp/ncp_subr.c                optional ncp
-netproto/ns/idp_usrreq.c       optional ns
-netproto/ns/ns.c               optional ns
-netproto/ns/ns_error.c         optional ns
-netproto/ns/ns_input.c         optional ns
-netproto/ns/ns_ip.c            optional ns
-netproto/ns/ns_output.c                optional ns
-netproto/ns/ns_pcb.c           optional ns
-netproto/ns/ns_proto.c         optional nowerror ns
-netproto/ns/ns_cksum.c         optional ns
-netproto/ns/spp_debug.c                optional ns
-netproto/ns/spp_usrreq.c       optional ns
 vfs/nfs/nfs_bio.c              optional nfs
 vfs/nfs/nfs_node.c             optional nfs
 vfs/nfs/nfs_serv.c             optional nfs
index 5d9d89b..a16ab11 100644 (file)
@@ -317,7 +317,6 @@ LIBMCHAIN
 MPLS                   opt_mpls.h
 NCP                    opt_ncp.h
 NETATALK               opt_atalk.h
-NS                     opt_ns.h
 PPP_BSDCOMP            opt_ppp.h
 PPP_DEFLATE            opt_ppp.h
 PPP_FILTER             opt_ppp.h
index 444cc88..bf3654e 100644 (file)
@@ -464,10 +464,6 @@ options    MPLS                    #Multi-Protocol Label Switching
 
 options        NETATALK                #Appletalk communications protocols
 
-# These are currently broken but are shipped due to interest.
-#options       NS                      #Xerox NS protocols
-#options       NSIP                    #XNS over IP
-
 #
 # SMB/CIFS requester
 # NETSMB enables support for SMB protocol, it requires LIBMCHAIN and LIBICONV
index 2d4f29a..3ebad9a 100644 (file)
 #include <netproto/ipx/ipx_if.h>
 #endif
 
-#ifdef NS
-#include <netproto/ns/ns.h>
-#include <netproto/ns/ns_if.h>
-#endif
-
 #include <vm/vm.h>
 
 #include <net/if_var.h>
@@ -3748,27 +3743,6 @@ tulip_ifioctl(struct ifnet *ifp, u_long cmd, caddr_t data, struct ucred * cr)
                }
 #endif /* IPX */
 
-#ifdef NS
-               /*
-                * This magic copied from if_is.c; I don't use XNS,
-                * so I have no way of telling if this actually
-                * works or not.
-                */
-               case AF_NS: {
-                   struct ns_addr *ina = &(IA_SNS(ifa)->sns_addr);
-                   if (ns_nullhost(*ina)) {
-                       ina->x_host = *(union ns_host *)(sc->tulip_enaddr);
-                   } else {
-                       ifp->if_flags &= ~IFF_RUNNING;
-                       bcopy((caddr_t)ina->x_host.c_host,
-                             (caddr_t)sc->tulip_enaddr,
-                             sizeof(sc->tulip_enaddr));
-                   }
-                   tulip_init(sc);
-                   break;
-               }
-#endif /* NS */
-
                default: {
                    tulip_init(sc);
                    break;
index 3db74fd..863a970 100644 (file)
 #include <net/if_dl.h>
 #include <net/if_media.h>
 
-#ifdef NS
-#include <netns/ns.h>
-#include <netns/ns_if.h>
-#endif
-
 #include <net/bpf.h>
 #include <sys/sockio.h>
 #include <sys/bus.h>
index 420a8f7..b489546 100644 (file)
 #include <netinet/if_ether.h>
 #endif
 
-#ifdef NS
-#include <netns/ns.h>
-#include <netns/ns_if.h>
-#endif
-
 #include <net/bpf.h>
 
 #include <machine/clock.h>
index 9bebe24..62086b2 100644 (file)
 #include <netinet/ip.h>
 #endif
 
-#ifdef NS
-#include <netns/ns.h>
-#include <netns/ns_if.h>
-#endif
-
 #include <net/bpf.h>
 #include <net/bpfdesc.h>
 
index 203e8bd..8e72dee 100644 (file)
@@ -46,7 +46,6 @@ COMM= ${SYS}/conf/*.[ch] \
        ${SYS}/netproto/ipx/*.[ch] \
        ${SYS}/netproto/key/*.[ch] \
        ${SYS}/netproto/natm/*.[ch] \
-       ${SYS}/netproto/ns/*.[ch] \
        ${SYS}/vfs/nfs/*.[ch] \
        ${SYS}/bus/pci/*.[ch] \
        ${SYS}/emulation/posix4/*.[ch] \
index b8d5d36..75d2033 100644 (file)
@@ -28,7 +28,7 @@ DGEN= conf \
        vfs/nullfs vfs/portal vfs/procfs \
        vfs/specfs vfs/union \
        vfs/ufs vfs/mfs vfs/nfs vfs/tmpfs \
-       net netinet netns sys \
+       net netinet sys \
        vm
 
 .include <bsd.subdir.mk>
index df0563a..4bb1272 100644 (file)
@@ -43,7 +43,7 @@ DGEN= conf \
        vfs/nullfs vfs/portal vfs/procfs \
        vfs/specfs vfs/union \
        vfs/ufs vfs/mfs vfs/nfs vfs/tmpfs \
-       net netinet netns sys \
+       net netinet sys \
        vm
 
 #tags::
index 8f19ed1..2c9936b 100644 (file)
@@ -1,19 +1,13 @@
-# $FreeBSD$
-# $DragonFly: src/sys/net/gre/Makefile,v 1.3 2006/10/25 20:56:03 dillon Exp $
-
 .PATH: ${.CURDIR}/../../net ${.CURDIR}/../../netinet 
 
 KMOD=  if_gre
-SRCS=  if_gre.c ip_gre.c opt_inet.h opt_ns.h opt_atalk.h
+SRCS=  if_gre.c ip_gre.c opt_inet.h opt_atalk.h
 SRCS+= device_if.h bus_if.h
 
 .if !defined(BUILDING_WITH_KERNEL)
 opt_inet.h:
        echo "#define INET 1" > ${.TARGET}
 
-opt_ns.h:
-       echo "#define NS 1" > ${.TARGET}
-
 opt_atalk.h:
        echo "#define NETATALK 1" > ${.TARGET}
 .endif
index 5c29c2d..d951154 100644 (file)
@@ -1,6 +1,5 @@
 /*     $NetBSD: if_gre.c,v 1.42 2002/08/14 00:23:27 itojun Exp $ */
 /*     $FreeBSD: src/sys/net/if_gre.c,v 1.9.2.3 2003/01/23 21:06:44 sam Exp $ */
-/*     $DragonFly: src/sys/net/gre/if_gre.c,v 1.22 2008/10/27 02:56:30 sephe Exp $ */
 
 /*
  * Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -49,7 +48,6 @@
 
 #include "opt_atalk.h"
 #include "opt_inet.h"
-#include "opt_ns.h"
 
 #include <sys/param.h>
 #include <sys/kernel.h>
@@ -355,11 +353,6 @@ gre_output_serialized(struct ifnet *ifp, struct mbuf *m, struct sockaddr *dst,
                case AF_APPLETALK:
                        etype = ETHERTYPE_ATALK;
                        break;
-#endif
-#ifdef NS
-               case AF_NS:
-                       etype = ETHERTYPE_NS;
-                       break;
 #endif
                default:
                        IF_DROP(&ifp->if_snd);
index 8f2c83e..0805908 100644 (file)
@@ -97,14 +97,6 @@ int (*ef_outputp)(struct ifnet *ifp, struct mbuf **mp, struct sockaddr *dst,
                  short *tp, int *hlen);
 #endif
 
-#ifdef NS
-#include <netns/ns.h>
-#include <netns/ns_if.h>
-ushort ns_nettype;
-int ether_outputdebug = 0;
-int ether_inputdebug = 0;
-#endif
-
 #ifdef NETATALK
 #include <netproto/atalk/at.h>
 #include <netproto/atalk/at_var.h>
@@ -326,44 +318,6 @@ ether_output(struct ifnet *ifp, struct mbuf *m, struct sockaddr *dst,
                rel_mplock();
                break;
          }
-#endif
-#ifdef NS
-       case AF_NS:
-               switch(ns_nettype) {
-               default:
-               case 0x8137:    /* Novell Ethernet_II Ethernet TYPE II */
-                       eh->ether_type = 0x8137;
-                       break;
-               case 0x0:       /* Novell 802.3 */
-                       eh->ether_type = htons(m->m_pkthdr.len);
-                       break;
-               case 0xe0e0:    /* Novell 802.2 and Token-Ring */
-                       M_PREPEND(m, 3, MB_DONTWAIT);
-                       eh = mtod(m, struct ether_header *);
-                       edst = eh->ether_dhost;
-                       eh->ether_type = htons(m->m_pkthdr.len);
-                       cp = mtod(m, u_char *) + sizeof(struct ether_header);
-                       *cp++ = 0xE0;
-                       *cp++ = 0xE0;
-                       *cp++ = 0x03;
-                       break;
-               }
-               bcopy(&(((struct sockaddr_ns *)dst)->sns_addr.x_host), edst,
-                     ETHER_ADDR_LEN);
-               /*
-                * XXX if ns_thishost is the same as the node's ethernet
-                * address then just the default code will catch this anyhow.
-                * So I'm not sure if this next clause should be here at all?
-                * [JRE]
-                */
-               if (bcmp(edst, &ns_thishost, ETHER_ADDR_LEN) == 0) {
-                       m->m_pkthdr.rcvif = ifp;
-                       netisr_queue(NETISR_NS, m);
-                       return (error);
-               }
-               if (bcmp(edst, &ns_broadhost, ETHER_ADDR_LEN) == 0)
-                       m->m_flags |= M_BCAST;
-               break;
 #endif
        case pseudo_AF_HDRCMPLT:
        case AF_UNSPEC:
@@ -728,28 +682,6 @@ do { \
                        IF_INIT(ifp);   /* Set new address. */
                        break;
                        }
-#endif
-#ifdef NS
-               /*
-                * XXX - This code is probably wrong
-                */
-               case AF_NS:
-               {
-                       struct ns_addr *ina = &(IA_SNS(ifa)->sns_addr);
-                       struct arpcom *ac = IFP2AC(ifp);
-
-                       if (ns_nullhost(*ina))
-                               ina->x_host = *(union ns_host *)(ac->ac_enaddr);
-                       else
-                               bcopy(ina->x_host.c_host, ac->ac_enaddr,
-                                     sizeof ac->ac_enaddr);
-
-                       /*
-                        * Set new address
-                        */
-                       IF_INIT(ifp);
-                       break;
-               }
 #endif
                default:
                        IF_INIT(ifp);
@@ -1250,13 +1182,6 @@ post_stats:
                break;
 #endif
 
-#ifdef NS
-       case 0x8137: /* Novell Ethernet_II Ethernet TYPE II */
-               isr = NETISR_NS;
-               break;
-
-#endif
-
 #ifdef NETATALK
        case ETHERTYPE_AT:
                isr = NETISR_ATALK1;
@@ -1293,20 +1218,6 @@ post_stats:
                        rel_mplock();
                }
 #endif
-#ifdef NS
-               checksum = mtod(m, ushort *);
-               /* Novell 802.3 */
-               if ((ether_type <= ETHERMTU) &&
-                   ((*checksum == 0xffff) || (*checksum == 0xE0E0))) {
-                       if (*checksum == 0xE0E0) {
-                               m->m_pkthdr.len -= 3;
-                               m->m_len -= 3;
-                               m->m_data += 3;
-                       }
-                       isr = NETISR_NS;
-                       break;
-               }
-#endif
 #ifdef NETATALK
                if (ether_type > ETHERMTU)
                        goto dropanyway;
@@ -1679,12 +1590,6 @@ ether_input_chain(struct ifnet *ifp, struct mbuf *m, const struct pktinfo *pi,
                break;
 #endif
 
-#ifdef NS
-       case 0x8137: /* Novell Ethernet_II Ethernet TYPE II */
-               isr = NETISR_NS;
-               break;
-#endif
-
 #ifdef NETATALK
        case ETHERTYPE_AT:
                isr = NETISR_ATALK1;
index ede54c8..0017ee4 100644 (file)
 #include <netinet/ip6.h>
 #endif
 
-#ifdef NS
-#include <netns/ns.h>
-#include <netns/ns_if.h>
-#endif
-
 #ifdef NETATALK
 #include <netproto/atalk/at.h>
 #include <netproto/atalk/at_var.h>
@@ -288,11 +283,6 @@ rel:
                isr = NETISR_IPX;
                break;
 #endif
-#ifdef NS
-       case AF_NS:
-               isr = NETISR_NS;
-               break;
-#endif
 #ifdef NETATALK
        case AF_APPLETALK:
                isr = NETISR_ATALK2;
@@ -346,11 +336,6 @@ lo_altqstart(struct ifnet *ifp)
                        isr = NETISR_IPX;
                        break;
 #endif
-#ifdef NS
-               case AF_NS:
-                       isr = NETISR_NS;
-                       break;
-#endif
 #ifdef ISO
                case AF_ISO:
                        isr = NETISR_ISO;
index b28a342..0654842 100644 (file)
 #include <netproto/ipx/ipx_if.h>
 #endif
 
-#ifdef NS
-#include <netns/ns.h>
-#include <netns/ns_if.h>
-#endif
-
 #include "if_sppp.h"
 
 #define IOCTL_CMD_T    u_long
@@ -654,15 +649,6 @@ sppp_input(struct ifnet *ifp, struct mbuf *m)
                        }
                        do_account++;
                        break;
-#endif
-#ifdef NS
-               case PPP_XNS:
-                       /* XNS IDPCP not implemented yet */
-                       if (sp->pp_phase == PHASE_NETWORK) {
-                               isr = NETISR_NS;
-                       }
-                       do_account++;
-                       break;
 #endif
                }
                break;
@@ -703,12 +689,6 @@ sppp_input(struct ifnet *ifp, struct mbuf *m)
                        isr = NETISR_IPX;
                        do_account++;
                        break;
-#endif
-#ifdef NS
-               case ETHERTYPE_NS:
-                       isr = NETISR_NS
-                       do_account++;
-                       break;
 #endif
                }
                break;
@@ -936,12 +916,6 @@ sppp_output_serialized(struct ifnet *ifp, struct mbuf *m,
                }
                break;
 #endif
-#ifdef NS
-       case AF_NS:     /* Xerox NS Protocol */
-               h->protocol = htons (sp->pp_mode == IFF_CISCO ?
-                       ETHERTYPE_NS : PPP_XNS);
-               break;
-#endif
 #ifdef IPX
        case AF_IPX:     /* Novell IPX Protocol */
                h->protocol = htons (sp->pp_mode == IFF_CISCO ?
index 08a71fd..21ba979 100644 (file)
 #include <netproto/ipx/ipx_ip.h>
 #endif
 
-#ifdef NSIP
-#include <netns/ns.h>
-#include <netns/ns_if.h>
-#endif
-
 #ifdef SCTP
 #include <netinet/in_pcb.h>
 #include <netinet/sctp_pcb.h>
@@ -459,22 +454,6 @@ struct protosw inetsw[] = {
        .pr_usrreqs = &rip_usrreqs
     },
 #endif
-#ifdef NSIP
-    {
-       .pr_type = SOCK_RAW,
-       .pr_domain = &inetdomain,
-       .pr_protocol = IPPROTO_IDP,
-       .pr_flags = PR_ATOMIC|PR_ADDR|PR_LASTHDR,
-
-       .pr_input = idpip_input,
-       .pr_output = NULL,
-       .pr_ctlinput = nsip_ctlinput,
-       .pr_ctloutput = NULL,
-
-       .pr_ctlport = cpu0_ctlport,
-       .pr_usrreqs = &rip_usrreqs
-    },
-#endif
 #ifdef PIM
     {
        .pr_type = SOCK_RAW,
index 77a6c3f..04023d8 100644 (file)
@@ -1,6 +1,5 @@
 /*
  * $NetBSD: ip_gre.c,v 1.21 2002/08/14 00:23:30 itojun Exp $
- * $DragonFly: src/sys/netinet/ip_gre.c,v 1.10 2006/01/14 11:33:50 swildner Exp $
  *
  * Copyright (c) 1998 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -44,7 +43,6 @@
  */
 
 #include "opt_inet.h"
-#include "opt_ns.h"
 #include "opt_atalk.h"
 
 #include <sys/param.h>
 #error ip_gre input without IP?
 #endif
 
-#ifdef NS
-#include <netproto/ns/ns.h>
-#include <netproto/ns/ns_if.h>
-#endif
-
 #ifdef NETATALK
 #include <netproto/atalk/at.h>
 #include <netproto/atalk/at_var.h>
@@ -180,11 +173,6 @@ gre_input2(struct mbuf *m ,int hlen, u_char proto)
                case WCCP_PROTOCOL_TYPE:
                        isr = NETISR_IP;
                        break;
-#ifdef NS
-               case ETHERTYPE_NS:
-                       isr = NETISR_NS;
-                       break;
-#endif
 #ifdef NETATALK
                case ETHERTYPE_ATALK:
                        isr = NETISR_ATALK1;
diff --git a/sys/netproto/ns/idp.h b/sys/netproto/ns/idp.h
deleted file mode 100644 (file)
index baae0b5..0000000
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * Copyright (c) 1984, 1985, 1986, 1987, 1993
- *     The Regents of the University of California.  All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- *    must display the following acknowledgement:
- *     This product includes software developed by the University of
- *     California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- *    may be used to endorse or promote products derived from this software
- *    without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- *     @(#)idp.h       8.1 (Berkeley) 6/10/93
- * $FreeBSD: src/sys/netns/idp.h,v 1.8 1999/08/28 00:49:46 peter Exp $
- * $DragonFly: src/sys/netproto/ns/idp.h,v 1.2 2003/06/17 04:28:53 dillon Exp $
- */
-
-#ifndef _NETNS_IDP_H_
-#define _NETNS_IDP_H_
-
-/*
- * Definitions for NS(tm) Internet Datagram Protocol
- */
-struct idp {
-       u_short idp_sum;        /* Checksum */
-       u_short idp_len;        /* Length, in bytes, including header */
-       u_char  idp_tc;         /* Transport Control (i.e. hop count) */
-       u_char  idp_pt;         /* Packet Type (i.e. level 2 protocol) */
-       struct ns_addr  idp_dna;        /* Destination Network Address */
-       struct ns_addr  idp_sna;        /* Source Network Address */
-};
-
-#endif
diff --git a/sys/netproto/ns/idp_usrreq.c b/sys/netproto/ns/idp_usrreq.c
deleted file mode 100644 (file)
index 129ae2d..0000000
+++ /dev/null
@@ -1,644 +0,0 @@
-/*
- * Copyright (c) 1984, 1985, 1986, 1987, 1993
- *     The Regents of the University of California.  All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- *    must display the following acknowledgement:
- *     This product includes software developed by the University of
- *     California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- *    may be used to endorse or promote products derived from this software
- *    without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- *     @(#)idp_usrreq.c        8.1 (Berkeley) 6/10/93
- * $FreeBSD: src/sys/netns/idp_usrreq.c,v 1.9 1999/08/28 00:49:47 peter Exp $
- * $DragonFly: src/sys/netproto/ns/idp_usrreq.c,v 1.15 2008/03/07 11:34:21 sephe Exp $
- */
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/malloc.h>
-#include <sys/mbuf.h>
-#include <sys/protosw.h>
-#include <sys/socket.h>
-#include <sys/socketvar.h>
-#include <sys/socketvar2.h>
-#include <sys/errno.h>
-#include <sys/stat.h>
-#include <sys/thread2.h>
-
-#include <net/if.h>
-#include <net/route.h>
-
-#include "ns.h"
-#include "ns_pcb.h"
-#include "ns_if.h"
-#include "idp.h"
-#include "idp_var.h"
-#include "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 */
-
-struct  idpstat idpstat;
-
-/*
- * IDP protocol implementation.
- */
-
-struct sockaddr_ns idp_ns = { sizeof(idp_ns), AF_NS };
-
-/*
- *  This may also be called for raw listeners.
- */
-void
-idp_input(struct mbuf *m, ...)
-{
-       struct idp *idp = mtod(m, struct idp *);
-       struct ifnet *ifp = m->m_pkthdr.rcvif;
-       struct nspcb *nsp;
-       __va_list ap;
-
-       __va_start(ap, m);
-       nsp = __va_arg(ap, struct nspcb *);
-       __va_end(ap);
-
-       if (nsp == NULL)
-               panic("No nspcb");
-       /*
-        * Construct sockaddr format source address.
-        * Stuff source address and datagram in user buffer.
-        */
-       idp_ns.sns_addr = idp->idp_sna;
-       if (ns_neteqnn(idp->idp_sna.x_net, ns_zeronet) && ifp) {
-               struct ifaddr_container *ifac;
-
-               TAILQ_FOREACH(ifac, &ifp->if_addrheads[mycpuid], ifa_link) {
-                       struct ifaddr *ifa = ifac->ifa;
-
-                       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) ) {
-               m->m_len -= sizeof (struct idp);
-               m->m_pkthdr.len -= sizeof (struct idp);
-               m->m_data += sizeof (struct idp);
-       }
-       if (ssb_appendaddr(&nsp->nsp_socket->so_rcv, (struct sockaddr *)&idp_ns,
-           m, NULL) == 0)
-               goto bad;
-       sorwakeup(nsp->nsp_socket);
-       return;
-bad:
-       m_freem(m);
-}
-
-void
-idp_abort(struct nspcb *nsp)
-{
-       struct socket *so = nsp->nsp_socket;
-
-       soreference(so);
-       ns_pcbdisconnect(nsp);
-       soisdisconnected(so);
-       sofree(so);
-}
-
-/*
- * Drop connection, reporting
- * the specified error.
- */
-void
-idp_drop(struct nspcb *nsp, int errno)
-{
-       struct socket *so = nsp->nsp_socket;
-
-       /*
-        * someday, in the xerox world
-        * we will generate error protocol packets
-        * announcing that the socket has gone away.
-        */
-       /*if (TCPS_HAVERCVDSYN(tp->t_state)) {
-               tp->t_state = TCPS_CLOSED;
-               tcp_output(tp);
-       }*/
-       so->so_error = errno;
-       soreference(so);
-       ns_pcbdisconnect(nsp);
-       soisdisconnected(so);
-       sofree(so);
-}
-
-int noIdpRoute;
-
-int
-idp_output(struct mbuf *m0, struct socket *so, ...)
-{
-       struct nspcb *nsp = sotonspcb(so);
-       struct mbuf *m;
-       struct idp *idp;
-       int len = 0;
-       struct route *ro;
-       struct mbuf *mprev = NULL;
-
-       /*
-        * Calculate data length.
-        */
-       for (m = m0; m; m = m->m_next) {
-               mprev = m;
-               len += m->m_len;
-       }
-       /*
-        * Make sure packet is actually of even length.
-        */
-
-       if (len & 1) {
-               m = mprev;
-               if ((m->m_flags & M_EXT) == 0 &&
-                       (m->m_len + m->m_data < &m->m_dat[MLEN])) {
-                       m->m_len++;
-               } else {
-                       struct mbuf *m1 = m_get(MB_DONTWAIT, MT_DATA);
-
-                       if (m1 == 0) {
-                               m_freem(m0);
-                               return (ENOBUFS);
-                       }
-                       m1->m_len = 1;
-                       * mtod(m1, char *) = 0;
-                       m->m_next = m1;
-               }
-               m0->m_pkthdr.len++;
-       }
-
-       /*
-        * Fill in mbuf with extended IDP header
-        * and addresses and length put into network format.
-        */
-       m = m0;
-       if (nsp->nsp_flags & NSP_RAWOUT) {
-               idp = mtod(m, struct idp *);
-       } else {
-               M_PREPEND(m, sizeof (struct idp), MB_DONTWAIT);
-               if (m == 0)
-                       return (ENOBUFS);
-               idp = mtod(m, struct idp *);
-               idp->idp_tc = 0;
-               idp->idp_pt = nsp->nsp_dpt;
-               idp->idp_sna = nsp->nsp_laddr;
-               idp->idp_dna = nsp->nsp_faddr;
-               len += sizeof (struct idp);
-       }
-
-       idp->idp_len = htons((u_short)len);
-
-       if (idpcksum) {
-               idp->idp_sum = 0;
-               len = ((len - 1) | 1) + 1;
-               idp->idp_sum = ns_cksum(m, len);
-       } else
-               idp->idp_sum = 0xffff;
-
-       /*
-        * Output datagram.
-        */
-       if (so->so_options & SO_DONTROUTE)
-               return (ns_output(m, NULL,
-                   (so->so_options & SO_BROADCAST) | NS_ROUTETOIF));
-       /*
-        * Use cached route for previous datagram if
-        * possible.  If the previous net was the same
-        * and the interface was a broadcast medium, or
-        * if the previous destination was identical,
-        * then we are ok.
-        *
-        * NB: We don't handle broadcasts because that
-        *     would require 3 subroutine calls.
-        */
-       ro = &nsp->nsp_route;
-#ifdef ancient_history
-       /*
-        * I think that this will all be handled in ns_pcbconnect!
-        */
-       if (ro->ro_rt) {
-               if(ns_neteq(nsp->nsp_lastdst, idp->idp_dna)) {
-                       /*
-                        * This assumes we have no GH type routes
-                        */
-                       if (ro->ro_rt->rt_flags & RTF_HOST) {
-                               if (!ns_hosteq(nsp->nsp_lastdst, idp->idp_dna))
-                                       goto re_route;
-
-                       }
-                       if ((ro->ro_rt->rt_flags & RTF_GATEWAY) == 0) {
-                               struct ns_addr *dst =
-                                               &satons_addr(ro->ro_dst);
-                               dst->x_host = idp->idp_dna.x_host;
-                       }
-                       /*
-                        * Otherwise, we go through the same gateway
-                        * and dst is already set up.
-                        */
-               } else {
-               re_route:
-                       RTFREE(ro->ro_rt);
-                       ro->ro_rt = NULL;
-               }
-       }
-       nsp->nsp_lastdst = idp->idp_dna;
-#endif /* ancient_history */
-       if (noIdpRoute) ro = 0;
-       return (ns_output(m, ro, so->so_options & SO_BROADCAST));
-}
-
-/* ARGSUSED */
-int
-idp_ctloutput(int req, struct socket *so, int level, int name,
-             struct mbuf **value)
-{
-       struct mbuf *m;
-       struct nspcb *nsp = sotonspcb(so);
-       int mask, error = 0;
-
-       if (nsp == NULL)
-               return (EINVAL);
-
-       switch (req) {
-
-       case PRCO_GETOPT:
-               if (value==NULL)
-                       return (EINVAL);
-               m = m_get(MB_DONTWAIT, MT_DATA);
-               if (m==NULL)
-                       return (ENOBUFS);
-               switch (name) {
-
-               case SO_ALL_PACKETS:
-                       mask = NSP_ALL_PACKETS;
-                       goto get_flags;
-
-               case SO_HEADERS_ON_INPUT:
-                       mask = NSP_RAWIN;
-                       goto get_flags;
-
-               case SO_HEADERS_ON_OUTPUT:
-                       mask = NSP_RAWOUT;
-               get_flags:
-                       m->m_len = sizeof(short);
-                       *mtod(m, short *) = nsp->nsp_flags & mask;
-                       break;
-
-               case SO_DEFAULT_HEADERS:
-                       m->m_len = sizeof(struct idp);
-                       {
-                               struct idp *idp = mtod(m, struct idp *);
-                               idp->idp_len = 0;
-                               idp->idp_sum = 0;
-                               idp->idp_tc = 0;
-                               idp->idp_pt = nsp->nsp_dpt;
-                               idp->idp_dna = nsp->nsp_faddr;
-                               idp->idp_sna = nsp->nsp_laddr;
-                       }
-                       break;
-
-               case SO_SEQNO:
-                       m->m_len = sizeof(long);
-                       *mtod(m, long *) = ns_pexseq++;
-                       break;
-
-               default:
-                       error = EINVAL;
-               }
-               *value = m;
-               break;
-
-       case PRCO_SETOPT:
-               switch (name) {
-                       int *ok;
-
-               case SO_ALL_PACKETS:
-                       mask = NSP_ALL_PACKETS;
-                       goto set_head;
-
-               case SO_HEADERS_ON_INPUT:
-                       mask = NSP_RAWIN;
-                       goto set_head;
-
-               case SO_HEADERS_ON_OUTPUT:
-                       mask = NSP_RAWOUT;
-               set_head:
-                       if (value && *value) {
-                               ok = mtod(*value, int *);
-                               if (*ok)
-                                       nsp->nsp_flags |= mask;
-                               else
-                                       nsp->nsp_flags &= ~mask;
-                       } else error = EINVAL;
-                       break;
-
-               case SO_DEFAULT_HEADERS:
-                       {
-                               struct idp *idp
-                                   = mtod(*value, struct idp *);
-                               nsp->nsp_dpt = idp->idp_pt;
-                       }
-                       break;
-#ifdef NSIP
-
-               case SO_NSIP_ROUTE:
-                       error = nsip_route(*value);
-                       break;
-#endif /* NSIP */
-               default:
-                       error = EINVAL;
-               }
-               if (value && *value)
-                       m_freem(*value);
-               break;
-       }
-       return (error);
-}
-
-
-/*
- *  IDP_USRREQ PROCEDURES
- */
-
-/*
- * NOTE: (so) is referenced from soabort*() and netmsg_pru_abort()
- *      will sofree() it when we return.
- */
-static int
-idp_usr_abort(struct socket *so)
-{
-       struct nspcb *nsp = sotonspcb(so);
-       int error;
-
-       if (nsp) {
-               ns_pcbdetach(nsp);
-               soisdisconnected(so);
-               error = 0;
-       } else {
-               error = EINVAL;
-       }
-
-       return(error);
-}
-
-static int
-idp_attach(struct socket *so, int proto, struct pru_attach_info *ai)
-{
-       struct nspcb *nsp = sotonspcb(so);
-       int error;
-
-       if (nsp != NULL)
-               return(EINVAL);
-       if ((error = ns_pcballoc(so, &nspcb)) != 0)
-               return(error);
-       error = soreserve(so, 2048, 2048, ai->sb_rlimit);
-       return(error);
-}
-
-static int
-idp_raw_attach(struct socket *so, int proto, struct pru_attach_info *ai)
-{
-       struct nspcb *nsp = sotonspcb(so);
-       int error;
-
-#ifdef NS_PRIV_SOCKETS
-       if ((so->so_state & SS_PRIV) == 0)
-               return(EINVAL);
-#endif
-       if (nsp != NULL)
-               return(EINVAL);
-       if ((error = ns_pcballoc(so, &nsrawpcb)) != 0)
-               return(error);
-       if ((error = soreserve(so, 2048, 2048, ai->sb_rlimit)) != 0)
-               return(error);
-       nsp = sotonspcb(so);
-       nsp->nsp_faddr.x_host = ns_broadhost;
-       nsp->nsp_flags = NSP_RAWIN | NSP_RAWOUT;
-       return(0);
-}
-
-static int
-idp_bind(struct socket *so, struct sockaddr *nam, struct thread *td)
-{
-       struct nspcb *nsp = sotonspcb(so);
-       int error;
-
-       if (nsp)
-               error = ns_pcbbind(nsp, nam);
-       else
-               error = EINVAL;
-       return(error);
-}
-
-static int
-idp_connect(struct socket *so, struct sockaddr *nam, struct thread *td)
-{
-       struct nspcb *nsp = sotonspcb(so);
-       int error;
-       
-       if (nsp) {
-               if (!ns_nullhost(nsp->nsp_faddr))
-                       error = EISCONN;
-               else if ((error = ns_pcbconnect(nsp, nam)) == 0)
-                       soisconnected(so);
-       } else {
-               error = EINVAL;
-       }
-       return(error);
-}
-
-static int
-idp_detach(struct socket *so)
-{
-       struct nspcb *nsp = sotonspcb(so);
-       int error;
-
-       if (nsp == NULL) {
-               error = ENOTCONN;
-       } else {
-               ns_pcbdetach(nsp);
-               error = 0;
-       }
-       return(error);
-}
-
-static int
-idp_usr_disconnect(struct socket *so)
-{
-       struct nspcb *nsp = sotonspcb(so);
-       int error;
-
-       if (nsp) {
-               if (ns_nullhost(nsp->nsp_faddr)) {
-                       error = ENOTCONN;
-               } else {
-                       error = 0;
-                       soreference(so);
-                       ns_pcbdisconnect(nsp);
-                       soisdisconnected(so);
-                       sofree(so);
-               }
-       } else {
-               error = EINVAL;
-       }
-       return(error);
-}
-
-static int
-idp_peeraddr(struct socket *so, struct sockaddr **pnam)
-{
-       struct nspcb *nsp = sotonspcb(so);
-       int error;
-
-       if (nsp) {
-               ns_setpeeraddr(nsp, pnam);
-               error = 0;
-       } else {
-               error = EINVAL;
-       }
-       return(error);
-}
-
-static int
-idp_send(struct socket *so, int flags, struct mbuf *m,
-       struct sockaddr *addr, struct mbuf *control,
-       struct thread *td)
-{
-       struct nspcb *nsp = sotonspcb(so);
-       struct ns_addr laddr;
-       int error;
-
-       if (nsp == NULL)
-               return(EINVAL);
-       if (control && control->m_len) {
-               error = EINVAL;
-               goto release;
-       }
-
-       crit_enter();
-       if (addr) {
-               laddr = nsp->nsp_laddr;
-               if (!ns_nullhost(nsp->nsp_faddr))
-                       error = EISCONN;
-               else
-                       error = ns_pcbconnect(nsp, addr);
-       } else {
-               if (ns_nullhost(nsp->nsp_faddr))
-                       error = ENOTCONN;
-               else
-                       error = 0;
-       }
-       if (error == 0) {
-               error = idp_output(m, so);
-               m = NULL;
-               if (addr) {
-                       ns_pcbdisconnect(nsp);
-                       nsp->nsp_laddr.x_host = laddr.x_host;
-                       nsp->nsp_laddr.x_port = laddr.x_port;
-               }
-       }
-       crit_exit();
-release:
-       if (control)
-               m_freem(control);
-       if (m)
-               m_freem(m);
-       return(error);
-}
-
-static int
-idp_sockaddr(struct socket *so, struct sockaddr **pnam)
-{
-       struct nspcb *nsp = sotonspcb(so);
-       int error;
-
-       if (nsp) {
-               ns_setsockaddr(nsp, pnam);
-               error = 0;
-       } else {
-               error = EINVAL;
-       }
-       return(error);
-}
-
-static int
-idp_shutdown(struct socket *so)
-{
-       socantsendmore(so);
-       return(0);
-}
-
-struct pr_usrreqs idp_usrreqs = {
-       .pru_abort = idp_usr_abort,
-       .pru_accept = pru_accept_notsupp,
-       .pru_attach = idp_attach,
-       .pru_bind = idp_bind,
-       .pru_connect = idp_connect,
-       .pru_connect2 = pru_connect2_notsupp,
-       .pru_control = ns_control,
-       .pru_detach = idp_detach,
-       .pru_disconnect = idp_usr_disconnect,
-       .pru_listen = pru_listen_notsupp,
-       .pru_peeraddr = idp_peeraddr,
-       .pru_rcvd = pru_rcvd_notsupp,
-       .pru_rcvoob = pru_rcvoob_notsupp,
-       .pru_send = idp_send,
-       .pru_sense = pru_sense_null,
-       .pru_shutdown = idp_shutdown,
-       .pru_sockaddr = idp_sockaddr,
-       .pru_sosend = sosend,
-       .pru_soreceive = soreceive
-};
-
-struct pr_usrreqs idp_raw_usrreqs = {
-       .pru_abort = idp_usr_abort,
-       .pru_accept = pru_accept_notsupp,
-       .pru_attach = idp_raw_attach,
-       .pru_bind = idp_bind,
-       .pru_connect = idp_connect,
-       .pru_connect2 = pru_connect2_notsupp,
-       .pru_control = ns_control,
-       .pru_detach = idp_detach,
-       .pru_disconnect = idp_usr_disconnect,
-       .pru_listen = pru_listen_notsupp,
-       .pru_peeraddr = idp_peeraddr,
-       .pru_rcvd = pru_rcvd_notsupp,
-       .pru_rcvoob = pru_rcvoob_notsupp,
-       .pru_send = idp_send,
-       .pru_sense = pru_sense_null,
-       .pru_shutdown = idp_shutdown,
-       .pru_sockaddr = idp_sockaddr,
-       .pru_sosend = sosend,
-       .pru_soreceive = soreceive
-};
-
diff --git a/sys/netproto/ns/idp_var.h b/sys/netproto/ns/idp_var.h
deleted file mode 100644 (file)
index d05c2cc..0000000
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * Copyright (c) 1984, 1985, 1986, 1987, 1993
- *     The Regents of the University of California.  All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- *    must display the following acknowledgement:
- *     This product includes software developed by the University of
- *     California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- *    may be used to endorse or promote products derived from this software
- *    without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- *     @(#)idp_var.h   8.1 (Berkeley) 6/10/93
- * $FreeBSD: src/sys/netns/idp_var.h,v 1.10 1999/12/29 04:46:18 peter Exp $
- * $DragonFly: src/sys/netproto/ns/idp_var.h,v 1.6 2005/01/23 13:21:44 joerg Exp $
- */
-
-#ifndef _NETNS_IDP_VAR_H_
-#define _NETNS_IDP_VAR_H_
-
-/*
- * IDP Kernel Structures and Variables
- */
-struct idpstat {
-       int     idps_badsum;            /* checksum bad */
-       int     idps_tooshort;          /* packet too short */
-       int     idps_toosmall;          /* not enough data */
-       int     idps_badhlen;           /* ip header length < data size */
-       int     idps_badlen;            /* ip length < ip header length */
-};
-
-#ifdef _KERNEL
-extern struct idpstat  idpstat;
-extern struct pr_usrreqs idp_usrreqs;
-extern struct pr_usrreqs idp_raw_usrreqs;
-struct nspcb;                  /* declare in scope for ptr parameter */
-
-void idp_abort (struct nspcb *);
-void idp_input (struct mbuf *, /* struct nspcb *, */ ...);
-void idp_drop (struct nspcb *, int);
-int idp_output(struct mbuf *, struct socket *, ...);
-int idp_ctloutput (int, struct socket *, int, int, struct mbuf **);
-
-#endif
-
-#endif
diff --git a/sys/netproto/ns/ns.c b/sys/netproto/ns/ns.c
deleted file mode 100644 (file)
index 5ae9f3e..0000000
+++ /dev/null
@@ -1,372 +0,0 @@
-/*
- * Copyright (c) 1984, 1985, 1986, 1987, 1993
- *     The Regents of the University of California.  All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- *    must display the following acknowledgement:
- *     This product includes software developed by the University of
- *     California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- *    may be used to endorse or promote products derived from this software
- *    without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- *     @(#)ns.c        8.2 (Berkeley) 11/15/93
- * $FreeBSD: src/sys/netns/ns.c,v 1.9 1999/08/28 00:49:47 peter Exp $
- * $DragonFly: src/sys/netproto/ns/ns.c,v 1.17 2008/03/07 11:34:21 sephe Exp $
- */
-
-#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>
-#include <sys/socketvar.h>
-#include <sys/thread2.h>
-
-#include <net/if.h>
-#include <net/route.h>
-
-#include "ns.h"
-#include "ns_if.h"
-
-#include "opt_ns.h"
-
-#ifdef NS
-
-struct ns_ifaddr *ns_ifaddr;
-int ns_interfaces;
-
-extern struct sockaddr_ns ns_netmask, ns_hostmask;
-
-/*
- * Generic internet control operations (ioctl's).
- */
-/* ARGSUSED */
-int
-ns_control(struct socket *so, u_long cmd, caddr_t data, struct ifnet *ifp,
-       struct thread *td)
-{
-       struct ifreq *ifr = (struct ifreq *)data;
-       struct ns_aliasreq *ifra = (struct ns_aliasreq *)data;
-       struct ns_ifaddr *ia;
-       struct ns_ifaddr *oia;
-       int dstIsNew, hostIsNew;
-       int error = 0; /* initalize because of scoping */
-
-       /*
-        * Find address for this interface, if it exists.
-        */
-       if (ifp == 0)
-               return (EADDRNOTAVAIL);
-       for (ia = ns_ifaddr; ia; ia = ia->ia_next)
-               if (ia->ia_ifp == ifp)
-                       break;
-
-       switch (cmd) {
-
-       case SIOCGIFADDR:
-               if (ia == NULL)
-                       return (EADDRNOTAVAIL);
-               *(struct sockaddr_ns *)&ifr->ifr_addr = ia->ia_addr;
-               return (0);
-
-
-       case SIOCGIFBRDADDR:
-               if (ia == NULL)
-                       return (EADDRNOTAVAIL);
-               if ((ifp->if_flags & IFF_BROADCAST) == 0)
-                       return (EINVAL);
-               *(struct sockaddr_ns *)&ifr->ifr_dstaddr = ia->ia_broadaddr;
-               return (0);
-
-       case SIOCGIFDSTADDR:
-               if (ia == NULL)
-                       return (EADDRNOTAVAIL);
-               if ((ifp->if_flags & IFF_POINTOPOINT) == 0)
-                       return (EINVAL);
-               *(struct sockaddr_ns *)&ifr->ifr_dstaddr = ia->ia_dstaddr;
-               return (0);
-       }
-
-#ifdef NS_PRIV_SOCKETS
-       if ((so->so_state & SS_PRIV) == 0)
-               return (EPERM);
-#endif
-
-       switch (cmd) {
-       case SIOCAIFADDR:
-       case SIOCDIFADDR:
-               if (ifra->ifra_addr.sns_family == AF_NS)
-                   for (oia = ia; ia; ia = ia->ia_next) {
-                       if (ia->ia_ifp == ifp  &&
-                           ns_neteq(ia->ia_addr.sns_addr,
-                                 ifra->ifra_addr.sns_addr))
-                           break;
-                   }
-               if (cmd == SIOCDIFADDR && ia == 0)
-                       return (EADDRNOTAVAIL);
-               /* FALLTHROUGH */
-
-       case SIOCSIFADDR:
-       case SIOCSIFDSTADDR:
-               if (ia == NULL) {
-                       oia = ifa_create(sizeof(*ia), M_WAITOK);
-                       if ((ia = ns_ifaddr) != NULL) {
-                               for ( ; ia->ia_next; ia = ia->ia_next)
-                                       ;
-                               ia->ia_next = oia;
-                       } else
-                               ns_ifaddr = oia;
-                       ia = oia;
-
-                       ifa_iflink(&ia->ia_ifa, ifp, 1);
-                       ia->ia_ifp = ifp;
-                       ia->ia_ifa.ifa_addr = (struct sockaddr *)&ia->ia_addr;
-
-                       ia->ia_ifa.ifa_netmask =
-                               (struct sockaddr *)&ns_netmask;
-
-                       ia->ia_ifa.ifa_dstaddr =
-                               (struct sockaddr *)&ia->ia_dstaddr;
-                       if (ifp->if_flags & IFF_BROADCAST) {
-                               ia->ia_broadaddr.sns_family = AF_NS;
-                               ia->ia_broadaddr.sns_len = sizeof(ia->ia_addr);
-                               ia->ia_broadaddr.sns_addr.x_host = ns_broadhost;
-                       }
-                       ns_interfaces++;
-               }
-       }
-
-       switch (cmd) {
-       case SIOCSIFDSTADDR:
-               if ((ifp->if_flags & IFF_POINTOPOINT) == 0)
-                       return (EINVAL);
-               if (ia->ia_flags & IFA_ROUTE) {
-                       rtinit(&(ia->ia_ifa), (int)RTM_DELETE, RTF_HOST);
-                       ia->ia_flags &= ~IFA_ROUTE;
-               }
-               if (ifp->if_ioctl) {
-                       ifnet_serialize_all(ifp);
-                       error = ifp->if_ioctl(ifp, SIOCSIFDSTADDR, (caddr_t)ia,
-                                             NULL);
-                       ifnet_deserialize_all(ifp);
-                       if (error)
-                               return (error);
-               }
-               *(struct sockaddr *)&ia->ia_dstaddr = ifr->ifr_dstaddr;
-               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;
-               ifa_ifunlink(&ia->ia_ifa, ifp);
-                if (oia == (ia = ns_ifaddr)) {
-                        ns_ifaddr = ia->ia_next;
-                } else {
-                        while (ia->ia_next && (ia->ia_next != oia)) {
-                                ia = ia->ia_next;
-                        }
-                        if (ia->ia_next)
-                            ia->ia_next = oia->ia_next;
-                        else
-                                kprintf("Didn't unlink nsifadr from list\n");
-                }
-               ifa_destroy(&oia->ia_ifa);
-               if (0 == --ns_interfaces) {
-                       /*
-                        * We reset to virginity and start all over again
-                        */
-                       ns_thishost = ns_zerohost;
-               }
-               return (0);
-
-       case SIOCAIFADDR:
-               dstIsNew = 0; hostIsNew = 1;
-               if (ia->ia_addr.sns_family == AF_NS) {
-                       if (ifra->ifra_addr.sns_len == 0) {
-                               ifra->ifra_addr = ia->ia_addr;
-                               hostIsNew = 0;
-                       } else if (ns_neteq(ifra->ifra_addr.sns_addr,
-                                        ia->ia_addr.sns_addr))
-                               hostIsNew = 0;
-               }
-               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:
-               if (ifp->if_ioctl == 0)
-                       return (EOPNOTSUPP);
-               ifnet_serialize_all(ifp);
-               error = ifp->if_ioctl(ifp, cmd, data, NULL);
-               ifnet_deserialize_all(ifp);
-               return (error);
-       }
-}
-
-/*
-* Delete any previous route for an old address.
-*/
-void
-ns_ifscrub(struct ifnet *ifp, struct ns_ifaddr *ia)
-{
-       if (ia->ia_flags & IFA_ROUTE) {
-               if (ifp->if_flags & IFF_POINTOPOINT) {
-                       rtinit(&(ia->ia_ifa), (int)RTM_DELETE, RTF_HOST);
-               } else
-                       rtinit(&(ia->ia_ifa), (int)RTM_DELETE, 0);
-               ia->ia_flags &= ~IFA_ROUTE;
-       }
-}
-/*
- * Initialize an interface's internet address
- * and routing table entry.
- */
-int
-ns_ifinit(struct ifnet *ifp, struct ns_ifaddr *ia, struct sockaddr_ns *sns, int scrub)
-{
-       struct sockaddr_ns oldaddr;
-       union ns_host *h = &ia->ia_addr.sns_addr.x_host;
-       int error;
-
-       crit_enter();
-
-       /*
-        * Set up new addresses.
-        */
-       oldaddr = ia->ia_addr;
-       ia->ia_addr = *sns;
-       /*
-        * The convention we shall adopt for naming is that
-        * a supplied address of zero means that "we don't care".
-        * if there is a single interface, use the address of that
-        * interface as our 6 byte host address.
-        * if there are multiple interfaces, use any address already
-        * used.
-        *
-        * Give the interface a chance to initialize
-        * if this is its first address,
-        * and to validate the address if necessary.
-        */
-       if (ns_hosteqnh(ns_thishost, ns_zerohost)) {
-               ifnet_serialize_all(ifp);
-               if (ifp->if_ioctl &&
-                    (error = ifp->if_ioctl(ifp, SIOCSIFADDR, 
-                                               (caddr_t)ia,
-                                               NULL))) {
-                       ia->ia_addr = oldaddr;
-                       ifnet_deserialize_all(ifp);
-                       crit_exit();
-                       return (error);
-               }
-               ifnet_deserialize_all(ifp);
-               ns_thishost = *h;
-       } else if (ns_hosteqnh(sns->sns_addr.x_host, ns_zerohost)
-           || ns_hosteqnh(sns->sns_addr.x_host, ns_thishost)) {
-               *h = ns_thishost;
-               ifnet_serialize_all(ifp);
-               if (ifp->if_ioctl &&
-                    (error = ifp->if_ioctl(ifp, SIOCSIFADDR, 
-                                               (caddr_t)ia,
-                                               NULL))) {
-                       ia->ia_addr = oldaddr;
-                       ifnet_deserialize_all(ifp);
-                       crit_exit();
-                       return (error);
-               }
-               ifnet_deserialize_all(ifp);
-               if (!ns_hosteqnh(ns_thishost,*h)) {
-                       ia->ia_addr = oldaddr;
-                       crit_exit();
-                       return (EINVAL);
-               }
-       } else {
-               ia->ia_addr = oldaddr;
-               crit_exit();
-               return (EINVAL);
-       }
-       ia->ia_ifa.ifa_metric = ifp->if_metric;
-       /*
-        * Add route for the network.
-        */
-       if (scrub) {
-               ia->ia_ifa.ifa_addr = (struct sockaddr *)&oldaddr;
-               ns_ifscrub(ifp, ia);
-               ia->ia_ifa.ifa_addr = (struct sockaddr *)&ia->ia_addr;
-       }
-       if (ifp->if_flags & IFF_POINTOPOINT)
-               rtinit(&(ia->ia_ifa), (int)RTM_ADD, RTF_HOST|RTF_UP);
-       else {
-               ia->ia_broadaddr.sns_addr.x_net = ia->ia_addr.sns_addr.x_net;
-               rtinit(&(ia->ia_ifa), (int)RTM_ADD, RTF_UP);
-       }
-       ia->ia_flags |= IFA_ROUTE;
-       return (0);
-}
-
-/*
- * Return address info for specified internet network.
- */
-struct ns_ifaddr *
-ns_iaonnetof(struct ns_addr *dst)
-{
-       struct ns_ifaddr *ia;
-       struct ns_addr *compare;
-       struct ifnet *ifp;
-       struct ns_ifaddr *ia_maybe = 0;
-       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))
-                                       return (ia);
-                               if (ns_neteqnn(net, ia->ia_addr.sns_addr.x_net))
-                                       ia_maybe = ia;
-                       } else {
-                               if (ns_neteqnn(net, ia->ia_addr.sns_addr.x_net))
-                                       return (ia);
-                       }
-               }
-       }
-       return (ia_maybe);
-}
-#endif
diff --git a/sys/netproto/ns/ns.h b/sys/netproto/ns/ns.h
deleted file mode 100644 (file)
index d5db079..0000000
+++ /dev/null
@@ -1,172 +0,0 @@
-/*
- * Copyright (c) 1984, 1985, 1986, 1987, 1993
- *     The Regents of the University of California.  All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- *    must display the following acknowledgement:
- *     This product includes software developed by the University of
- *     California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- *    may be used to endorse or promote products derived from this software
- *    without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- *     @(#)ns.h        8.1 (Berkeley) 6/10/93
- * $FreeBSD: src/sys/netns/ns.h,v 1.13.2.1 2002/12/01 14:03:09 sobomax Exp $
- * $DragonFly: src/sys/netproto/ns/ns.h,v 1.8 2004/07/27 13:50:15 hmp Exp $
- */
-
-#ifndef _NETNS_NS_H_
-#define _NETNS_NS_H_
-
-/*
- * Constants and Structures defined by the Xerox Network Software
- * per "Internet Transport Protocols", XSIS 028112, December 1981
- */
-
-/*
- * Protocols
- */
-#define NSPROTO_RI     1               /* Routing Information */
-#define NSPROTO_ECHO   2               /* Echo Protocol */
-#define NSPROTO_ERROR  3               /* Error Protocol */
-#define NSPROTO_PE     4               /* Packet Exchange */
-#define NSPROTO_SPP    5               /* Sequenced Packet */
-#define NSPROTO_RAW    255             /* Placemarker*/
-#define NSPROTO_MAX    256             /* Placemarker*/
-
-
-/*
- * Port/Socket numbers: network standard functions
- */
-
-#define NSPORT_RI      1               /* Routing Information */
-#define NSPORT_ECHO    2               /* Echo */
-#define NSPORT_RE      3               /* Router Error */
-
-/*
- * Ports < NSPORT_RESERVED are reserved for priveleged
- * processes (e.g. root).
- */
-#define NSPORT_RESERVED                3000
-
-/* flags passed to ns_output as last parameter */
-
-#define        NS_FORWARDING           0x1     /* most of idp header exists */
-#define        NS_ROUTETOIF            0x10    /* same as SO_DONTROUTE */
-#define        NS_ALLOWBROADCAST       SO_BROADCAST    /* can send broadcast packets */
-
-#define NS_MAXHOPS             15
-
-/* flags passed to get/set socket option */
-#define        SO_HEADERS_ON_INPUT     1
-#define        SO_HEADERS_ON_OUTPUT    2
-#define        SO_DEFAULT_HEADERS      3
-#define        SO_LAST_HEADER          4
-#define        SO_NSIP_ROUTE           5
-#define SO_SEQNO               6
-#define        SO_ALL_PACKETS          7
-#define SO_MTU                 8
-
-
-/*
- * NS addressing
- */
-union ns_host {
-       u_char  c_host[6];
-       u_short s_host[3];
-};
-
-union ns_net {
-       u_char  c_net[4];
-       u_short s_net[2];
-};
-
-union ns_net_u {
-       union ns_net    net_e;
-       u_long          long_e;
-};
-
-struct ns_addr {
-       union ns_net    x_net;
-       union ns_host   x_host;
-       u_short x_port;
-};
-
-/*
- * Socket address, Xerox style
- */
-struct sockaddr_ns {
-       u_char          sns_len;
-       u_char          sns_family;
-       struct ns_addr  sns_addr;
-       char            sns_zero[2];
-};
-#define sns_port sns_addr.x_port
-
-#define ns_neteqnn(a,b) (((a).s_net[0]==(b).s_net[0]) && \
-                                       ((a).s_net[1]==(b).s_net[1]))
-#define ns_neteq(a,b) ns_neteqnn((a).x_net, (b).x_net)
-#define satons_addr(sa)        (((struct sockaddr_ns *)&(sa))->sns_addr)
-#define ns_hosteqnh(s,t) ((s).s_host[0] == (t).s_host[0] && \
-       (s).s_host[1] == (t).s_host[1] && (s).s_host[2] == (t).s_host[2])
-#define ns_hosteq(s,t) (ns_hosteqnh((s).x_host,(t).x_host))
-#define ns_nullhost(x) (((x).x_host.s_host[0]==0) && \
-       ((x).x_host.s_host[1]==0) && ((x).x_host.s_host[2]==0))
-
-#ifdef _KERNEL
-extern struct domain nsdomain;
-extern union ns_host ns_thishost;
-extern union ns_host ns_zerohost;
-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 (struct mbuf *, int);
-int ns_output (struct mbuf *, struct route *, int);
-int ns_control (struct socket *, u_long, caddr_t, struct ifnet *, struct thread *);
-void ns_init (void);
-void idp_forward (struct mbuf *);
-void idp_ctlinput (int, caddr_t);
-int idp_do_route (struct ns_addr *, struct route *);
-void idp_undo_route (struct route *);
-void ns_watch_output (struct mbuf *, struct ifnet *);
-int ns_ifinit (struct ifnet *, struct ns_ifaddr *, struct sockaddr_ns *,
-                       int);
-void ns_ifscrub (struct ifnet *, struct ns_ifaddr *);
-
-#else
-
-#include <sys/cdefs.h>
-
-__BEGIN_DECLS
-extern struct ns_addr ns_addr (const char *);
-extern char *ns_ntoa (struct ns_addr);
-__END_DECLS
-
-#endif
-
-#endif
diff --git a/sys/netproto/ns/ns_cksum.c b/sys/netproto/ns/ns_cksum.c
deleted file mode 100644 (file)
index d0018cd..0000000
+++ /dev/null
@@ -1,206 +0,0 @@
-/*
- * Copyright (c) 1982, 1992, 1993
- *     The Regents of the University of California.  All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- *    must display the following acknowledgement:
- *     This product includes software developed by the University of
- *     California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- *    may be used to endorse or promote products derived from this software
- *    without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- *     @(#)ns_cksum.c  8.1 (Berkeley) 6/10/93
- * $FreeBSD: src/sys/netns/ns_cksum.c,v 1.7 1999/08/28 00:49:49 peter Exp $
- * $DragonFly: src/sys/netproto/ns/ns_cksum.c,v 1.5 2006/01/14 13:36:40 swildner Exp $
- */
-
-#include <sys/param.h>
-#include <sys/mbuf.h>
-#include <sys/socketvar.h>
-#include "ns.h"
-
-/*
- * Checksum routine for Network Systems Protocol Packets (Big-Endian).
- *
- * This routine is very heavily used in the network
- * code and should be modified for each CPU to be as fast as possible.
- */
-
-#define ADDCARRY(x)  { if ((x) > 65535) (x) -= 65535; }
-#define FOLD(x) {l_util.l = (x); (x) = l_util.s[0] + l_util.s[1]; ADDCARRY(x);}
-
-u_short
-ns_cksum(struct mbuf *m, int len)
-{
-       u_short *w;
-       int sum = 0;
-       int mlen = 0;
-       int sum2;
-
-       union {
-               u_short s[2];
-               long    l;
-       } l_util;
-
-       for (;m && len; m = m->m_next) {
-               if (m->m_len == 0)
-                       continue;
-               /*
-                * Each trip around loop adds in
-                * word from one mbuf segment.
-                */
-               w = mtod(m, u_short *);
-               if (mlen == -1) {
-                       /*
-                        * There is a byte left from the last segment;
-                        * ones-complement add it into the checksum.
-                        */
-#if BYTE_ORDER == BIG_ENDIAN
-                       sum  += *(u_char *)w;
-#else
-                       sum  += *(u_char *)w << 8;
-#endif
-                       sum += sum;
-                       w = (u_short *)(1 + (char *)w);
-                       mlen = m->m_len - 1;
-                       len--;
-                       FOLD(sum);
-               } else
-                       mlen = m->m_len;
-               if (len < mlen)
-                       mlen = len;
-               len -= mlen;
-               /*
-                * We can do a 16 bit ones complement sum using
-                * 32 bit arithmetic registers for adding,
-                * with carries from the low added
-                * into the high (by normal carry-chaining)
-                * so long as we fold back before 16 carries have occured.
-                */
-               if (1 & (int) w)
-                       goto uuuuglyy;
-#ifndef TINY
-/* -DTINY reduces the size from 1250 to 550, but slows it down by 22% */
-               while ((mlen -= 32) >= 0) {
-                       sum += w[0]; sum += sum; sum += w[1]; sum += sum;
-                       sum += w[2]; sum += sum; sum += w[3]; sum += sum;
-                       sum += w[4]; sum += sum; sum += w[5]; sum += sum;
-                       sum += w[6]; sum += sum; sum += w[7]; sum += sum;
-                       FOLD(sum);
-                       sum += w[8]; sum += sum; sum += w[9]; sum += sum;
-                       sum += w[10]; sum += sum; sum += w[11]; sum += sum;
-                       sum += w[12]; sum += sum; sum += w[13]; sum += sum;
-                       sum += w[14]; sum += sum; sum += w[15]; sum += sum;
-                       FOLD(sum);
-                       w += 16;
-               }
-               mlen += 32;
-#endif
-               while ((mlen -= 8) >= 0) {
-                       sum += w[0]; sum += sum; sum += w[1]; sum += sum;
-                       sum += w[2]; sum += sum; sum += w[3]; sum += sum;
-                       FOLD(sum);
-                       w += 4;
-               }
-               mlen += 8;
-               while ((mlen -= 2) >= 0) {
-                       sum += *w++; sum += sum;
-               }
-               goto commoncase;
-uuuuglyy:
-#if BYTE_ORDER == BIG_ENDIAN
-#define ww(n) (((u_char *)w)[n + n + 1])
-#define vv(n) (((u_char *)w)[n + n])
-#else
-#if BYTE_ORDER == LITTLE_ENDIAN
-#define vv(n) (((u_char *)w)[n + n + 1])
-#define ww(n) (((u_char *)w)[n + n])
-#endif
-#endif
-               sum2 = 0;
-#ifndef TINY
-               while ((mlen -= 32) >= 0) {
-                   sum += ww(0); sum += sum; sum += ww(1); sum += sum;
-                   sum += ww(2); sum += sum; sum += ww(3); sum += sum;
-                   sum += ww(4); sum += sum; sum += ww(5); sum += sum;
-                   sum += ww(6); sum += sum; sum += ww(7); sum += sum;
-                   FOLD(sum);
-                   sum += ww(8); sum += sum; sum += ww(9); sum += sum;
-                   sum += ww(10); sum += sum; sum += ww(11); sum += sum;
-                   sum += ww(12); sum += sum; sum += ww(13); sum += sum;
-                   sum += ww(14); sum += sum; sum += ww(15); sum += sum;
-                   FOLD(sum);
-                   sum2 += vv(0); sum2 += sum2; sum2 += vv(1); sum2 += sum2;
-                   sum2 += vv(2); sum2 += sum2; sum2 += vv(3); sum2 += sum2;
-                   sum2 += vv(4); sum2 += sum2; sum2 += vv(5); sum2 += sum2;
-                   sum2 += vv(6); sum2 += sum2; sum2 += vv(7); sum2 += sum2;
-                   FOLD(sum2);
-                   sum2 += vv(8); sum2 += sum2; sum2 += vv(9); sum2 += sum2;
-                   sum2 += vv(10); sum2 += sum2; sum2 += vv(11); sum2 += sum2;
-                   sum2 += vv(12); sum2 += sum2; sum2 += vv(13); sum2 += sum2;
-                   sum2 += vv(14); sum2 += sum2; sum2 += vv(15); sum2 += sum2;
-                   FOLD(sum2);
-                   w += 16;
-               }
-               mlen += 32;
-#endif
-               while ((mlen -= 8) >= 0) {
-                   sum += ww(0); sum += sum; sum += ww(1); sum += sum;
-                   sum += ww(2); sum += sum; sum += ww(3); sum += sum;
-                   FOLD(sum);
-                   sum2 += vv(0); sum2 += sum2; sum2 += vv(1); sum2 += sum2;
-                   sum2 += vv(2); sum2 += sum2; sum2 += vv(3); sum2 += sum2;
-                   FOLD(sum2);
-                   w += 4;
-               }
-               mlen += 8;
-               while ((mlen -= 2) >= 0) {
-                       sum += ww(0); sum += sum;
-                       sum2 += vv(0); sum2 += sum2;
-                       w++;
-               }
-               sum += (sum2 << 8);
-commoncase:
-               if (mlen == -1) {
-#if BYTE_ORDER == BIG_ENDIAN
-                       sum += *(u_char *)w << 8;
-#else
-                       sum += *(u_char *)w;
-#endif
-               }
-               FOLD(sum);
-       }
-       if (mlen == -1) {
-               /* We had an odd number of bytes to sum; assume a garbage
-                  byte of zero and clean up */
-               sum += sum;
-               FOLD(sum);
-       }
-       /*
-        * sum has already been kept to low sixteen bits.
-        * just examine result and exit.
-        */
-       if(sum==0xffff) sum = 0;
-       return (sum);
-}
diff --git a/sys/netproto/ns/ns_error.c b/sys/netproto/ns/ns_error.c
deleted file mode 100644 (file)
index 286687f..0000000
+++ /dev/null
@@ -1,319 +0,0 @@
-/*
- * Copyright (c) 1984, 1988, 1993
- *     The Regents of the University of California.  All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- *    must display the following acknowledgement:
- *     This product includes software developed by the University of
- *     California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- *    may be used to endorse or promote products derived from this software
- *    without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- *     @(#)ns_error.c  8.1 (Berkeley) 6/10/93
- * $FreeBSD: src/sys/netns/ns_error.c,v 1.9 1999/08/28 00:49:49 peter Exp $
- * $DragonFly: src/sys/netproto/ns/ns_error.c,v 1.11 2006/12/22 23:57:54 swildner Exp $
- */
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/malloc.h>
-#include <sys/mbuf.h>
-#include <sys/protosw.h>
-#include <sys/socket.h>
-#include <sys/time.h>
-#include <sys/kernel.h>
-
-#include <net/route.h>
-
-#include "ns.h"
-#include "ns_pcb.h"
-#include "idp.h"
-#include "ns_error.h"
-
-extern int idpcksum;           /* from ns_input.c */
-extern int idpchsum;           /* from ns_input.c */
-extern void spp_ctlinput( int, caddr_t);       /* from spp_usrreq.c XXX */
-
-struct   ns_errstat ns_errstat;
-
-#ifdef lint
-#define NS_ERRPRINTFS 1
-#endif
-
-#ifdef NS_ERRPRINTFS
-/*
- * NS_ERR routines: error generation, receive packet processing, and
- * routines to turnaround packets back to the originator.
- */
-int    ns_errprintfs = 0;
-#endif
-
-int
-ns_err_x(int c)
-{
-       u_short *w, *lim, *base = ns_errstat.ns_es_codes;
-       u_short x = c;
-
-       /*
-        * zero is a legit error code, handle specially
-        */
-       if (x == 0)
-               return (0);
-       lim = base + NS_ERR_MAX - 1;
-       for (w = base + 1; w < lim; w++) {
-               if (*w == 0)
-                       *w = x;
-               if (*w == x)
-                       break;
-       }
-       return (w - base);
-}
-
-/*
- * Generate an error packet of type error
- * in response to bad packet.
- */
-
-void
-ns_error(struct mbuf *om, int type, int param)
-{
-       struct ns_epidp *ep;
-       struct mbuf *m;
-       struct idp *nip;
-       struct idp *oip = mtod(om, struct idp *);
-
-       /*
-        * If this packet was sent to the echo port,
-        * and nobody was there, just echo it.
-        * (Yes, this is a wart!)
-        */
-       if (type == NS_ERR_NOSOCK &&
-           oip->idp_dna.x_port == htons(2) &&
-           (type = ns_echo(om))==0)
-               return;
-
-#ifdef NS_ERRPRINTFS
-       if (ns_errprintfs)
-               kprintf("ns_err_error(%x, %d, %d)\n", oip, type, param);
-#endif
-       /*
-        * Don't Generate error packets in response to multicasts.
-        */
-       if (oip->idp_dna.x_host.c_host[0] & 1)
-               goto freeit;
-
-       ns_errstat.ns_es_error++;
-       /*
-        * Make sure that the old IDP packet had 30 bytes of data to return;
-        * if not, don't bother.  Also don't EVER error if the old
-        * packet protocol was NS_ERR.
-        */
-       if (oip->idp_len < sizeof(struct idp)) {
-               ns_errstat.ns_es_oldshort++;
-               goto freeit;
-       }
-       if (oip->idp_pt == NSPROTO_ERROR) {
-               ns_errstat.ns_es_oldns_err++;
-               goto freeit;
-       }
-
-       /*
-        * First, formulate ns_err message
-        */
-       m = m_gethdr(MB_DONTWAIT, MT_HEADER);
-       if (m == NULL)
-               goto freeit;
-       m->m_len = sizeof(*ep);
-       MH_ALIGN(m, m->m_len);
-       ep = mtod(m, struct ns_epidp *);
-       if ((u_int)type > NS_ERR_TOO_BIG)
-               panic("ns_err_error");
-       ns_errstat.ns_es_outhist[ns_err_x(type)]++;
-       ep->ns_ep_errp.ns_err_num = htons((u_short)type);
-       ep->ns_ep_errp.ns_err_param = htons((u_short)param);
-       bcopy((caddr_t)oip, (caddr_t)&ep->ns_ep_errp.ns_err_idp, 42);
-       nip = &ep->ns_ep_idp;
-       nip->idp_len = sizeof(*ep);
-       nip->idp_len = htons((u_short)nip->idp_len);
-       nip->idp_pt = NSPROTO_ERROR;
-       nip->idp_tc = 0;
-       nip->idp_dna = oip->idp_sna;
-       nip->idp_sna = oip->idp_dna;
-       if (idpcksum) {
-               nip->idp_sum = 0;
-               nip->idp_sum = ns_cksum(m, sizeof(*ep));
-       } else
-               nip->idp_sum = 0xffff;
-       ns_output(m, NULL, 0);
-
-freeit:
-       m_freem(om);
-}
-
-void
-ns_printhost(struct ns_addr *p)
-{
-
-       kprintf("<net:%x%x,host:%x%x%x,port:%x>",
-                       p->x_net.s_net[0],
-                       p->x_net.s_net[1],
-                       p->x_host.s_host[0],
-                       p->x_host.s_host[1],
-                       p->x_host.s_host[2],
-                       p->x_port);
-
-}
-
-/*
- * Process a received NS_ERR message.
- */
-void
-ns_err_input(struct mbuf *m)
-{
-       struct ns_errp *ep;
-#ifdef NS_ERRPRINTFS
-       struct ns_epidp *epidp = mtod(m, struct ns_epidp *);
-#endif
-       int i;
-       int type, code, param;
-
-       /*
-        * Locate ns_err structure in mbuf, and check
-        * that not corrupted and of at least minimum length.
-        */
-#ifdef NS_ERRPRINTFS
-       if (ns_errprintfs) {
-               kprintf("ns_err_input from ");
-               ns_printhost(&epidp->ns_ep_idp.idp_sna);
-               kprintf("len %d\n", ntohs(epidp->ns_ep_idp.idp_len));
-       }
-#endif
-       i = sizeof (struct ns_epidp);
-       if (((m->m_flags & M_EXT) || m->m_len < i) &&
-               (m = m_pullup(m, i)) == 0)  {
-               ns_errstat.ns_es_tooshort++;
-               return;
-       }
-       ep = &(mtod(m, struct ns_epidp *)->ns_ep_errp);
-       type = ntohs(ep->ns_err_num);
-       param = ntohs(ep->ns_err_param);
-       ns_errstat.ns_es_inhist[ns_err_x(type)]++;
-
-#ifdef NS_ERRPRINTFS
-       /*
-        * Message type specific processing.
-        */
-       if (ns_errprintfs)
-               kprintf("ns_err_input, type %d param %d\n", type, param);
-#endif
-       if (type >= NS_ERR_TOO_BIG) {
-               goto badcode;
-       }
-       ns_errstat.ns_es_outhist[ns_err_x(type)]++;
-       switch (type) {
-
-       case NS_ERR_UNREACH_HOST:
-               code = PRC_UNREACH_NET;
-               goto deliver;
-
-       case NS_ERR_TOO_OLD:
-               code = PRC_TIMXCEED_INTRANS;
-               goto deliver;
-
-       case NS_ERR_TOO_BIG:
-               code = PRC_MSGSIZE;
-               goto deliver;
-
-       case NS_ERR_FULLUP:
-               code = PRC_QUENCH;
-               goto deliver;
-
-       case NS_ERR_NOSOCK:
-               code = PRC_UNREACH_PORT;
-               goto deliver;
-
-       case NS_ERR_UNSPEC_T:
-       case NS_ERR_BADSUM_T:
-       case NS_ERR_BADSUM:
-       case NS_ERR_UNSPEC:
-               code = PRC_PARAMPROB;
-               goto deliver;
-
-       deliver:
-               /*
-                * Problem with datagram; advise higher level routines.
-                */
-#ifdef NS_ERRPRINTFS
-               if (ns_errprintfs)
-                       kprintf("deliver to protocol %d\n",
-                                      ep->ns_err_idp.idp_pt);
-#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;
-
-       default:
-       badcode:
-               ns_errstat.ns_es_badcode++;
-               goto freeit;
-
-       }
-freeit:
-       m_freem(m);
-}
-
-int
-ns_echo(struct mbuf *m)
-{
-       struct idp *idp = mtod(m, struct idp *);
-       struct echo {
-           struct idp  ec_idp;
-           u_short             ec_op; /* Operation, 1 = request, 2 = reply */
-       } *ec = (struct echo *)idp;
-       struct ns_addr temp;
-
-       if (idp->idp_pt!=NSPROTO_ECHO) return(NS_ERR_NOSOCK);
-       if (ec->ec_op!=htons(1)) return(NS_ERR_UNSPEC);
-
-       ec->ec_op = htons(2);
-
-       temp = idp->idp_dna;
-       idp->idp_dna = idp->idp_sna;
-       idp->idp_sna = temp;
-
-       if (idp->idp_sum != 0xffff) {
-               idp->idp_sum = 0;
-               idp->idp_sum = ns_cksum(m,
-                   (int)(((ntohs(idp->idp_len) - 1)|1)+1));
-       }
-       ns_output(m, NULL, NS_FORWARDING);
-       return(0);
-}
diff --git a/sys/netproto/ns/ns_error.h b/sys/netproto/ns/ns_error.h
deleted file mode 100644 (file)
index bcf0964..0000000
+++ /dev/null
@@ -1,104 +0,0 @@
-/*
- * Copyright (c) 1984, 1988, 1993
- *     The Regents of the University of California.  All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- *    must display the following acknowledgement:
- *     This product includes software developed by the University of
- *     California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- *    may be used to endorse or promote products derived from this software
- *    without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- *     @(#)ns_error.h  8.1 (Berkeley) 6/10/93
- * $FreeBSD: src/sys/netns/ns_error.h,v 1.10 1999/12/29 04:46:19 peter Exp $
- * $DragonFly: src/sys/netproto/ns/ns_error.h,v 1.4 2004/02/16 20:37:20 dillon Exp $
- */
-
-#ifndef _NETNS_NS_ERROR_H_
-#define _NETNS_NS_ERROR_H_
-
-/*
- * Xerox NS error messages
- */
-
-struct ns_errp {
-       u_short         ns_err_num;             /* Error Number */
-       u_short         ns_err_param;           /* Error Parameter */
-       struct idp      ns_err_idp;             /* Initial segment of offending
-                                                  packet */
-       u_char          ns_err_lev2[12];        /* at least this much higher
-                                                  level protocol */
-};
-struct  ns_epidp {
-       struct idp ns_ep_idp;
-       struct ns_errp ns_ep_errp;
-};
-
-#define        NS_ERR_UNSPEC   0       /* Unspecified Error detected at dest. */
-#define        NS_ERR_BADSUM   1       /* Bad Checksum detected at dest */
-#define        NS_ERR_NOSOCK   2       /* Specified socket does not exist at dest*/
-#define        NS_ERR_FULLUP   3       /* Dest. refuses packet due to resource lim.*/
-#define        NS_ERR_UNSPEC_T 0x200   /* Unspec. Error occured before reaching dest*/
-#define        NS_ERR_BADSUM_T 0x201   /* Bad Checksum detected in transit */
-#define        NS_ERR_UNREACH_HOST     0x202   /* Dest cannot be reached from here*/
-#define        NS_ERR_TOO_OLD  0x203   /* Packet x'd 15 routers without delivery*/
-#define        NS_ERR_TOO_BIG  0x204   /* Packet too large to be forwarded through
-                                  some intermediate gateway.  The error
-                                  parameter field contains the max packet
-                                  size that can be accommodated */
-#define NS_ERR_MAX 20
-
-/*
- * Variables related to this implementation
- * of the network systems error message protocol.
- */
-struct ns_errstat {
-/* statistics related to ns_err packets generated */
-       int     ns_es_error;            /* # of calls to ns_error */
-       int     ns_es_oldshort;         /* no error 'cuz old ip too short */
-       int     ns_es_oldns_err;        /* no error 'cuz old was ns_err */
-       int     ns_es_outhist[NS_ERR_MAX];
-/* statistics related to input messages processed */
-       int     ns_es_badcode;          /* ns_err_code out of range */
-       int     ns_es_tooshort;         /* packet < IDP_MINLEN */
-       int     ns_es_checksum;         /* bad checksum */
-       int     ns_es_badlen;           /* calculated bound mismatch */
-       int     ns_es_reflect;          /* number of responses */
-       int     ns_es_inhist[NS_ERR_MAX];
-       u_short ns_es_codes[NS_ERR_MAX];/* which error code for outhist
-                                          since we might not know all */
-};
-
-#ifdef _KERNEL
-extern struct  ns_errstat ns_errstat;
-
-int ns_err_x (int);
-void ns_error (struct mbuf *, int, int);
-int ns_echo (struct mbuf *);
-void ns_printhost (struct ns_addr *);
-void ns_err_input (struct mbuf *);
-
-#endif
-
-#endif
diff --git a/sys/netproto/ns/ns_if.h b/sys/netproto/ns/ns_if.h
deleted file mode 100644 (file)
index 2d3ad23..0000000
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- * Copyright (c) 1984, 1985, 1986, 1987, 1993
- *     The Regents of the University of California.  All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- *    must display the following acknowledgement:
- *     This product includes software developed by the University of
- *     California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- *    may be used to endorse or promote products derived from this software
- *    without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- *     @(#)ns_if.h     8.1 (Berkeley) 6/10/93
- * $FreeBSD: src/sys/netns/ns_if.h,v 1.12.2.1 2002/12/01 14:03:09 sobomax Exp $
- * $DragonFly: src/sys/netproto/ns/ns_if.h,v 1.4 2003/09/15 23:38:15 hsu Exp $
- */
-
-#ifndef _NETNS_NS_IF_H_
-#define _NETNS_NS_IF_H_
-
-/*
- * Interface address, xerox version.  One of these structures
- * is allocated for each interface with an internet address.
- * The ifaddr structure contains the protocol-independent part
- * of the structure and is assumed to be first.
- */
-
-struct ns_ifaddr {
-       struct  ifaddr ia_ifa;          /* protocol-independent info */
-#define        ia_ifp          ia_ifa.ifa_ifp
-#define        ia_flags        ia_ifa.ifa_flags
-       struct  ns_ifaddr *ia_next;     /* next in list of xerox addresses */
-       struct  sockaddr_ns ia_addr;    /* reserve space for my address */
-       struct  sockaddr_ns ia_dstaddr; /* space for my broadcast address */
-#define ia_broadaddr   ia_dstaddr
-       struct  sockaddr_ns ia_netmask; /* space for my network mask */
-};
-
-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
-};
-/*
- * Given a pointer to an ns_ifaddr (ifaddr),
- * return a pointer to the addr as a sockadd_ns.
- */
-
-#define        IA_SNS(ia) (&(((struct ns_ifaddr *)(ia))->ia_addr))
-
-/* This is not the right place for this but where is? */
-#define        ETHERTYPE_NS    0x0600
-
-#ifdef NSIP
-struct nsip_req {
-       struct sockaddr rq_ns;  /* must be ns format destination */
-       struct sockaddr rq_ip;  /* must be ip format gateway */
-       short rq_flags;
-};
-#endif
-
-#ifdef _KERNEL
-extern struct ns_ifaddr        *ns_ifaddr;
-
-struct ns_ifaddr *ns_iaonnetof (struct ns_addr *);
-#endif
-
-#endif
diff --git a/sys/netproto/ns/ns_input.c b/sys/netproto/ns/ns_input.c
deleted file mode 100644 (file)
index f1866d6..0000000
+++ /dev/null
@@ -1,489 +0,0 @@
-/*
- * Copyright (c) 1984, 1985, 1986, 1987, 1993
- *     The Regents of the University of California.  All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- *    must display the following acknowledgement:
- *     This product includes software developed by the University of
- *     California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- *    may be used to endorse or promote products derived from this software
- *    without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- *     @(#)ns_input.c  8.1 (Berkeley) 6/10/93
- * $FreeBSD: src/sys/netns/ns_input.c,v 1.13 2000/02/13 03:32:04 peter Exp $
- * $DragonFly: src/sys/netproto/ns/ns_input.c,v 1.23 2008/09/24 14:26:39 sephe Exp $
- */
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/malloc.h>
-#include <sys/mbuf.h>
-#include <sys/domain.h>
-#include <sys/protosw.h>
-#include <sys/socket.h>
-#include <sys/socketvar.h>
-#include <sys/errno.h>
-#include <sys/time.h>
-#include <sys/kernel.h>
-
-#include <sys/thread2.h>
-#include <sys/msgport2.h>
-#include <sys/mplock2.h>
-
-#include <net/if.h>
-#include <net/route.h>
-#include <net/raw_cb.h>
-#include <net/netisr.h>
-
-#include "ns.h"
-#include "ns_if.h"
-#include "ns_pcb.h"
-#include "idp.h"
-#include "idp_var.h"
-#include "ns_error.h"
-
-extern void    spp_input(struct mbuf *, ...); /* spp_usrreq.c XXX */
-
-/*
- * 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};
-
-struct nspcb nsrawpcb;
-
-int    idpcksum = 1;
-long   ns_pexseq;
-
-static void nsintr(struct netmsg *msg);
-
-void
-ns_init(void)
-{
-       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 = ustick;
-       ns_netmask.sns_len = 6;
-       ns_netmask.sns_addr.x_net = ns_broadnet;
-       ns_hostmask.sns_len = 12;
-       ns_hostmask.sns_addr.x_net = ns_broadnet;
-       ns_hostmask.sns_addr.x_host = ns_broadhost;
-       netisr_register(NETISR_NS, nsintr, NULL);
-}
-
-/*
- * Idp input routine.  Pass to next level.
- */
-int nsintr_getpck = 0;
-int nsintr_swtch = 0;
-
-static void
-nsintr(struct netmsg *msg)
-{
-       struct mbuf *m = ((struct netmsg_packet *)msg)->nm_packet;
-       struct idp *idp;
-       struct nspcb *nsp;
-       int i;
-       int len, error;
-       char oddpacketp;
-
-       get_mplock();
-
-       /*
-        * Get IDP header in first mbuf.
-        */
-       nsintr_getpck++;
-       if ((m->m_flags & M_EXT || m->m_len < sizeof (struct idp)) &&
-           (m = m_pullup(m, sizeof (struct idp))) == 0) {
-               idpstat.idps_toosmall++;
-               goto out;
-       }
-
-       /*
-        * Give any raw listeners a crack at the packet
-        */
-       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 */
-       }
-
-       /*
-        * Check that the amount of data in the buffers
-        * is as at least much as the IDP header would have us expect.
-        * Trim mbufs if longer than we expect.
-        * Drop packet if shorter than we expect.
-        */
-       if (m->m_pkthdr.len < len) {
-               idpstat.idps_tooshort++;
-               goto bad;
-       }
-       if (m->m_pkthdr.len > len) {
-               if (m->m_len == m->m_pkthdr.len) {
-                       m->m_len = len;
-                       m->m_pkthdr.len = len;
-               } else
-                       m_adj(m, len - m->m_pkthdr.len);
-       }
-       if (idpcksum && ((i = idp->idp_sum)!=0xffff)) {
-               idp->idp_sum = 0;
-               if (i != (idp->idp_sum = ns_cksum(m, len))) {
-                       idpstat.idps_badsum++;
-                       idp->idp_sum = i;
-                       if (ns_hosteqnh(ns_thishost, idp->idp_dna.x_host))
-                               error = NS_ERR_BADSUM;
-                       else
-                               error = NS_ERR_BADSUM_T;
-                       ns_error(m, error, 0);
-                       goto out;
-               }
-       }
-       /*
-        * Is this a directed broadcast?
-        */
-       if (ns_hosteqnh(ns_broadhost,idp->idp_dna.x_host)) {
-               if ((!ns_neteq(idp->idp_dna, idp->idp_sna)) &&
-                   (!ns_neteqnn(idp->idp_dna.x_net, ns_broadnet)) &&
-                   (!ns_neteqnn(idp->idp_sna.x_net, ns_zeronet)) &&
-                   (!ns_neteqnn(idp->idp_dna.x_net, ns_zeronet)) ) {
-                       /*
-                        * Look to see if I need to eat this packet.
-                        * Algorithm is to forward all young packets
-                        * and prematurely age any packets which will
-                        * by physically broadcasted.
-                        * Any very old packets eaten without forwarding
-                        * would die anyway.
-                        *
-                        * Suggestion of Bill Nesheim, Cornell U.
-                        */
-                       if (idp->idp_tc < NS_MAXHOPS) {
-                               idp_forward(m);
-                               goto out;
-                       }
-               }
-       /*
-        * Is this our packet? If not, forward.
-        */
-       } else if (!ns_hosteqnh(ns_thishost,idp->idp_dna.x_host)) {
-               idp_forward(m);
-               goto out;
-       }
-       /*
-        * Locate pcb for datagram.
-        */
-       nsp = ns_pcblookup(&idp->idp_sna, idp->idp_dna.x_port, NS_WILDCARD);
-       /*
-        * Switch out to protocol's input routine.
-        */
-       nsintr_swtch++;
-       if (nsp) {
-               if (oddpacketp) {
-                       m_adj(m, -1);
-               }
-               if ((nsp->nsp_flags & NSP_ALL_PACKETS)==0)
-                       switch (idp->idp_pt) {
-
-                           case NSPROTO_SPP:
-                                   spp_input(m, nsp);
-                                   goto out;
-
-                           case NSPROTO_ERROR:
-                                   ns_err_input(m);
-                                   goto out;
-                       }
-               idp_input(m, nsp);
-       } else {
-               ns_error(m, NS_ERR_NOSOCK, 0);
-       }
-       goto out;
-
-bad:
-       m_freem(m);
-out:
-       rel_mplock();
-       /* msg was embedded in the mbuf, do not reply! */
-}
-
-u_char nsctlerrmap[PRC_NCMDS] = {
-       ECONNABORTED,   ECONNABORTED,   0,              0,
-       0,              0,              EHOSTDOWN,      EHOSTUNREACH,
-       ENETUNREACH,    EHOSTUNREACH,   ECONNREFUSED,   ECONNREFUSED,
-       EMSGSIZE,       0,              0,              0,
-       0,              0,              0,              0
-};
-
-int idp_donosocks = 1;
-
-void
-idp_ctlinput(int cmd, caddr_t 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)
-               return;
-       if (nsctlerrmap[cmd] == 0)
-               return;         /* 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;
-               if (sns->sns_family != AF_NS)
-                       return;
-               ns = &sns->sns_addr;
-               break;
-
-       default:
-               errp = (struct ns_errp *)arg;
-               ns = &errp->ns_err_idp.idp_dna;
-               type = errp->ns_err_num;
-               type = ntohs((u_short)type);
-       }
-       switch (type) {
-
-       case NS_ERR_UNREACH_HOST:
-               ns_pcbnotify(ns, (int)nsctlerrmap[cmd], idp_abort, (long)0);
-               break;
-
-       case NS_ERR_NOSOCK:
-               nsp = ns_pcblookup(ns, errp->ns_err_idp.idp_sna.x_port,
-                       NS_WILDCARD);
-               if(nsp && idp_donosocks && ! ns_nullhost(nsp->nsp_faddr))
-                       idp_drop(nsp, (int)nsctlerrmap[cmd]);
-       }
-}
-
-int    idpprintfs = 0;
-int    idpforwarding = 1;
-/*
- * Forward a packet.  If some error occurs return the sender
- * an error packet.  Note we can't always generate a meaningful
- * error message because the NS errors don't have a large enough repetoire
- * of codes and types.
- */
-struct route idp_droute;
-struct route idp_sroute;
-
-void
-idp_forward(struct mbuf *m)
-{
-       struct idp *idp = mtod(m, struct idp *);
-       int error, type, code;
-       struct mbuf *mcopy = NULL;
-       int agedelta = 1;
-       int flags = NS_FORWARDING;
-       int ok_there = 0;
-       int ok_back = 0;
-
-       if (idpprintfs) {
-               kprintf("forward: src ");
-               ns_printhost(&idp->idp_sna);
-               kprintf(", dst ");
-               ns_printhost(&idp->idp_dna);
-               kprintf("hop count %d\n", idp->idp_tc);
-       }
-       if (idpforwarding == 0) {
-               /* can't tell difference between net and host */
-               type = NS_ERR_UNREACH_HOST, code = 0;
-               goto senderror;
-       }
-       idp->idp_tc++;
-       if (idp->idp_tc > NS_MAXHOPS) {
-               type = NS_ERR_TOO_OLD, code = 0;
-               goto senderror;
-       }
-       /*
-        * Save at most 42 bytes of the packet in case
-        * we need to generate an NS error message to the src.
-        */
-       mcopy = m_copy(m, 0, imin((int)ntohs(idp->idp_len), 42));
-
-       if ((ok_there = idp_do_route(&idp->idp_dna,&idp_droute))==0) {
-               type = NS_ERR_UNREACH_HOST, code = 0;
-               goto senderror;
-       }
-       /*
-        * Here we think about  forwarding  broadcast packets,
-        * so we try to insure that it doesn't go back out
-        * on the interface it came in on.  Also, if we
-        * are going to physically broadcast this, let us
-        * age the packet so we can eat it safely the second time around.
-        */
-       if (idp->idp_dna.x_host.c_host[0] & 0x1) {
-               struct ns_ifaddr *ia = ns_iaonnetof(&idp->idp_dna);
-               struct ifnet *ifp;
-               if (ia) {
-                       /* I'm gonna hafta eat this packet */
-                       agedelta += NS_MAXHOPS - idp->idp_tc;
-                       idp->idp_tc = NS_MAXHOPS;
-               }
-               if ((ok_back = idp_do_route(&idp->idp_sna,&idp_sroute))==0) {
-                       /* error = ENETUNREACH; He'll never get it! */
-                       m_freem(m);
-                       goto cleanup;
-               }
-               if (idp_droute.ro_rt &&
-                   (ifp=idp_droute.ro_rt->rt_ifp) &&
-                   idp_sroute.ro_rt &&
-                   (ifp!=idp_sroute.ro_rt->rt_ifp)) {
-                       flags |= NS_ALLOWBROADCAST;
-               } else {
-                       type = NS_ERR_UNREACH_HOST, code = 0;
-                       goto senderror;
-               }
-       }
-       /* need to adjust checksum */
-       if (idp->idp_sum!=0xffff) {
-               union bytes {
-                       u_char c[4];
-                       u_short s[2];
-                       long l;
-               } x;
-               int shift;
-               x.l = 0; x.c[0] = agedelta;
-               shift = (((((int)ntohs(idp->idp_len))+1)>>1)-2) & 0xf;
-               x.l = idp->idp_sum + (x.s[0] << shift);
-               x.l = x.s[0] + x.s[1];
-               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)) &&
-           (mcopy!=NULL)) {
-               idp = mtod(mcopy, struct idp *);
-               type = NS_ERR_UNSPEC_T, code = 0;
-               switch (error) {
-
-               case ENETUNREACH:
-               case EHOSTDOWN:
-               case EHOSTUNREACH:
-               case ENETDOWN:
-               case EPERM:
-                       type = NS_ERR_UNREACH_HOST;
-                       break;
-
-               case EMSGSIZE:
-                       type = NS_ERR_TOO_BIG;
-                       code = 576; /* too hard to figure out mtu here */
-                       break;
-
-               case ENOBUFS:
-                       type = NS_ERR_UNSPEC_T;
-                       break;
-               }
-               mcopy = NULL;
-       senderror:
-               ns_error(m, type, code);
-       }
-cleanup:
-       if (ok_there)
-               idp_undo_route(&idp_droute);
-       if (ok_back)
-               idp_undo_route(&idp_sroute);
-       if (mcopy != NULL)
-               m_freem(mcopy);
-}
-
-int
-idp_do_route(struct ns_addr *src, struct route *ro)
-{
-
-       struct sockaddr_ns *dst;
-
-       bzero((caddr_t)ro, sizeof (*ro));
-       dst = (struct sockaddr_ns *)&ro->ro_dst;
-
-       dst->sns_len = sizeof(*dst);
-       dst->sns_family = AF_NS;
-       dst->sns_addr = *src;
-       dst->sns_addr.x_port = 0;
-       rtalloc(ro);
-       if (ro->ro_rt == 0 || ro->ro_rt->rt_ifp == 0) {
-               return (0);
-       }
-       ro->ro_rt->rt_use++;
-       return (1);
-}
-
-void
-idp_undo_route(struct route *ro)
-{
-       if (ro->ro_rt) {RTFREE(ro->ro_rt);}
-}
-
-void
-ns_watch_output(struct mbuf *m, struct ifnet *ifp)
-{
-       struct nspcb *nsp;
-       /*
-        * Give any raw listeners a crack at the packet
-        */
-       for (nsp = nsrawpcb.nsp_next; nsp != &nsrawpcb; nsp = nsp->nsp_next) {
-               struct mbuf *m0 = m_copy(m, 0, (int)M_COPYALL);
-               if (m0) {
-                       struct idp *idp;
-
-                       M_PREPEND(m0, sizeof (*idp), MB_DONTWAIT);
-                       if (m0 == NULL)
-                               continue;
-                       idp = mtod(m0, struct idp *);
-                       idp->idp_sna.x_net = ns_zeronet;
-                       idp->idp_sna.x_host = ns_thishost;
-                       if (ifp && (ifp->if_flags & IFF_POINTOPOINT)) {
-                               struct ifaddr_container *ifac;
-
-                               TAILQ_FOREACH(ifac,
-                               &ifp->if_addrheads[mycpuid], ifa_link) {
-                                       struct ifaddr *ifa = ifac->ifa;
-
-                                       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);
-               }
-       }
-}
diff --git a/sys/netproto/ns/ns_ip.c b/sys/netproto/ns/ns_ip.c
deleted file mode 100644 (file)
index 4e22f5d..0000000
+++ /dev/null
@@ -1,447 +0,0 @@
-/*
- * Copyright (c) 1984, 1985, 1986, 1987, 1993
- *     The Regents of the University of California.  All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- *    must display the following acknowledgement:
- *     This product includes software developed by the University of
- *     California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- *    may be used to endorse or promote products derived from this software
- *    without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- *     @(#)ns_ip.c     8.1 (Berkeley) 6/10/93
- * $FreeBSD: src/sys/netns/ns_ip.c,v 1.9 1999/08/28 00:49:50 peter Exp $
- * $DragonFly: src/sys/netproto/ns/ns_ip.c,v 1.15 2008/05/14 11:59:24 sephe Exp $
- */
-
-/*
- * Software interface driver for encapsulating ns in ip.
- */
-
-#ifdef NSIP
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/malloc.h>
-#include <sys/mbuf.h>
-#include <sys/socket.h>
-#include <sys/socketvar.h>
-#include <sys/errno.h>
-#include <sys/ioctl.h>
-#include <sys/protosw.h>
-
-#include <net/if.h>
-#include <net/netisr.h>
-#include <net/route.h>
-
-#include <netinet/in.h>
-#include <netinet/in_systm.h>
-#include <netinet/in_var.h>
-#include <netinet/ip.h>
-#include <netinet/ip_var.h>
-
-#include <machine/mtpr.h>
-#include <machine/stdarg.h>
-
-#include "ns.h"
-#include "ns_if.h"
-#include "idp.h"
-
-struct ifnet_en {
-       struct ifnet ifen_ifnet;
-       struct route ifen_route;
-       struct in_addr ifen_src;
-       struct in_addr ifen_dst;
-       struct ifnet_en *ifen_next;
-};
-
-int    nsipoutput(), nsipioctl(), nsipstart();
-#define LOMTU  (1024+512);
-
-struct ifnet nsipif;
-static int nsipif_units;
-struct ifnet_en *nsip_list;            /* list of all hosts and gateways or
-                                       broadcast addrs */
-
-struct ifnet_en *
-nsipattach(void)
-{
-       struct ifnet_en *m;
-       struct ifnet *ifp;
-
-       if (nsipif.if_mtu == 0) {
-               ifp = &nsipif;
-               if_initname(ifp, "nsip", nsipif_units);
-               ifp->if_mtu = LOMTU;
-               ifp->if_ioctl = nsipioctl;
-               ifp->if_output = nsipoutput;
-               ifp->if_start = nsipstart;
-               ifp->if_flags = IFF_POINTOPOINT;
-       }
-
-       MALLOC((m), struct ifnet_en *, sizeof(*m), M_PCB, M_WAITOK);
-       m->ifen_next = nsip_list;
-       nsip_list = m;
-       ifp = &m->ifen_ifnet;
-
-       ifp->if_softc = m;
-       if_initname(ifp, "nsip", nsipif_units++);
-       ifp->if_name = "nsip";
-       ifp->if_mtu = LOMTU;
-       ifp->if_ioctl = nsipioctl;
-       ifp->if_output = nsipoutput;
-       ifp->if_start = nsipstart;
-       ifp->if_flags = IFF_POINTOPOINT;
-       if_attach(ifp, NULL);
-
-       return (m);
-}
-
-
-/*
- * Process an ioctl request.
- */
-/* ARGSUSED */
-int
-nsipioctl(struct ifnet *ifp, int cmd, caddr_t data)
-{
-       int error = 0;
-       struct ifreq *ifr;
-
-       switch (cmd) {
-
-       case SIOCSIFADDR:
-               ifp->if_flags |= IFF_UP;
-               /* fall into: */
-
-       case SIOCSIFDSTADDR:
-               /*
-                * Everything else is done at a higher level.
-                */
-               break;
-
-       case SIOCSIFFLAGS:
-               ifr = (struct ifreq *)data;
-               if ((ifr->ifr_flags & IFF_UP) == 0)
-                       error = nsip_free(ifp);
-
-
-       default:
-               error = EINVAL;
-       }
-       return (error);
-}
-
-struct mbuf *nsip_badlen;
-struct mbuf *nsip_lastin;
-int nsip_hold_input;
-
-#warning "Audit the second argument, this expect ifp, but gets int from netinet"
-
-void
-idpip_input(struct mbuf *m, ...)
-{
-       struct ip *ip;
-       struct idp *idp;
-       int len, s;
-       struct ifnet *ifp;
-       __va_list ap;
-
-       __va_start(ap, m);
-       ifp = __va_arg(ap, struct ifnet *);
-       __va_end(ap);
-
-       if (nsip_hold_input) {
-               if (nsip_lastin) {
-                       m_freem(nsip_lastin);
-               }
-               nsip_lastin = m_copym(m, 0, (int)M_COPYALL, MB_DONTWAIT);
-       }
-       /*
-        * Get IP and IDP header together in first mbuf.
-        */
-       nsipif.if_ipackets++;
-       s = sizeof (struct ip) + sizeof (struct idp);
-       if (((m->m_flags & M_EXT) || m->m_len < s) &&
-           (m = m_pullup(m, s)) == 0) {
-               nsipif.if_ierrors++;
-               return;
-       }
-       ip = mtod(m, struct ip *);
-       if (ip->ip_hl > (sizeof (struct ip) >> 2)) {
-               ip_stripoptions(m);
-               if (m->m_len < s) {
-                       if ((m = m_pullup(m, s)) == 0) {
-                               nsipif.if_ierrors++;
-                               return;
-                       }
-                       ip = mtod(m, struct ip *);
-               }
-       }
-
-       /*
-        * Make mbuf data length reflect IDP length.
-        * If not enough data to reflect IDP length, drop.
-        */
-       m->m_data += sizeof (struct ip);
-       m->m_len -= sizeof (struct ip);
-       m->m_pkthdr.len -= sizeof (struct ip);
-       idp = mtod(m, struct idp *);
-       len = ntohs(idp->idp_len);
-       if (len & 1) len++;             /* Preserve Garbage Byte */
-       if (ip->ip_len != len) {
-               if (len > ip->ip_len) {
-                       nsipif.if_ierrors++;
-                       if (nsip_badlen) m_freem(nsip_badlen);
-                       nsip_badlen = m;
-                       return;
-               }
-               /* Any extra will be trimmed off by the NS routines */
-       }
-
-       /*
-        * Place interface pointer before the data
-        * for the receiving protocol.
-        */
-       m->m_pkthdr.rcvif = ifp;
-       /*
-        * Deliver to NS
-        */
-       netisr_queue(NETISR_NS, m);
-}
-
-/* ARGSUSED */
-static int
-nsipoutput_serialized(struct ifnet_en *ifn, struct mbuf *m,
-                     struct sockaddr *dst)
-{
-
-       struct ip *ip;
-       struct route *ro = &(ifn->ifen_route);
-       int len = 0;
-       struct idp *idp = mtod(m, struct idp *);
-       int error;
-
-       ifn->ifen_ifnet.if_opackets++;
-       nsipif.if_opackets++;
-
-
-       /*
-        * Calculate data length and make space
-        * for IP header.
-        */
-       len =  ntohs(idp->idp_len);
-       if (len & 1) len++;             /* Preserve Garbage Byte */
-       /* following clause not necessary on vax */
-       if (3 & (int)m->m_data) {
-               /* force longword alignment of ip hdr */
-               struct mbuf *m0 = m_gethdr(MT_HEADER, MB_DONTWAIT);
-               if (m0 == 0) {
-                       m_freem(m);
-                       return (ENOBUFS);
-               }
-               MH_ALIGN(m0, sizeof (struct ip));
-               m0->m_flags = m->m_flags & M_COPYFLAGS;
-               m0->m_next = m;
-               m0->m_len = sizeof (struct ip);
-               m0->m_pkthdr.len = m0->m_len + m->m_len;
-       } else {
-               M_PREPEND(m, sizeof (struct ip), MB_DONTWAIT);
-               if (m == 0)
-                       return (ENOBUFS);
-       }
-       /*
-        * Fill in IP header.
-        */
-       ip = mtod(m, struct ip *);
-       *(long *)ip = 0;
-       ip->ip_p = IPPROTO_IDP;
-       ip->ip_src = ifn->ifen_src;
-       ip->ip_dst = ifn->ifen_dst;
-       ip->ip_len = (u_short)len + sizeof (struct ip);
-       ip->ip_ttl = MAXTTL;
-
-       /*
-        * Output final datagram.
-        */
-       error =  (ip_output(m, NULL, ro, SO_BROADCAST, NULL));
-       if (error) {
-               ifn->ifen_ifnet.if_oerrors++;
-               ifn->ifen_ifnet.if_ierrors = error;
-       }
-       return (error);
-bad:
-       m_freem(m);
-       return (ENETUNREACH);
-}
-
-int
-nsipoutput(struct ifnet *ifp, struct mbuf *m, struct sockaddr *dst,
-          struct rtentry *rt __unused)
-{
-       int error;
-
-       ifnet_serialize_tx(ifp);
-       error = nsipoutput_serialized(ifp->if_softc, m, dst);
-       ifnet_deserialize_tx(ifp);
-
-       return error;
-}
-
-void
-nsipstart(struct ifnet *ifp)
-{
-       panic("nsip_start called");
-}
-
-struct ifreq ifr = {"nsip0"};
-
-int
-nsip_route(struct mbuf *m)
-{
-       struct nsip_req *rq = mtod(m, struct nsip_req *);
-       struct sockaddr_ns *ns_dst = (struct sockaddr_ns *)&rq->rq_ns;
-       struct sockaddr_in *ip_dst = (struct sockaddr_in *)&rq->rq_ip;
-       struct route ro;
-       struct ifnet_en *ifn;
-       struct sockaddr_in *src;
-
-       /*
-        * First, make sure we already have an ns address:
-        */
-       if (ns_hosteqnh(ns_thishost, ns_zerohost))
-               return (EADDRNOTAVAIL);
-       /*
-        * Now, determine if we can get to the destination
-        */
-       bzero((caddr_t)&ro, sizeof (ro));
-       ro.ro_dst = *(struct sockaddr *)ip_dst;
-       rtalloc(&ro);
-       if (ro.ro_rt == 0 || ro.ro_rt->rt_ifp == 0) {
-               return (ENETUNREACH);
-       }
-
-       /*
-        * And see how he's going to get back to us:
-        * i.e., what return ip address do we use?
-        */
-       {
-               struct in_ifaddr *ia;
-               struct ifnet *ifp = ro.ro_rt->rt_ifp;
-
-               for (ia = in_ifaddr; ia; ia = ia->ia_next)
-                       if (ia->ia_ifp == ifp)
-                               break;
-               if (ia == 0)
-                       ia = in_ifaddr;
-               if (ia == 0) {
-                       RTFREE(ro.ro_rt);
-                       return (EADDRNOTAVAIL);
-               }
-               src = (struct sockaddr_in *)&ia->ia_addr;
-       }
-
-       /*
-        * Is there a free (pseudo-)interface or space?
-        */
-       for (ifn = nsip_list; ifn; ifn = ifn->ifen_next) {
-               if ((ifn->ifen_ifnet.if_flags & IFF_UP) == 0)
-                       break;
-       }
-       if (ifn == NULL)
-               ifn = nsipattach();
-       if (ifn == NULL) {
-               RTFREE(ro.ro_rt);
-               return (ENOBUFS);
-       }
-       ifn->ifen_route = ro;
-       ifn->ifen_dst =  ip_dst->sin_addr;
-       ifn->ifen_src = src->sin_addr;
-
-       /*
-        * now configure this as a point to point link
-        */
-       ifr.ifr_name[4] = '0' + nsipif_units - 1;
-       ifr.ifr_dstaddr = * (struct sockaddr *) ns_dst;
-       ns_control(NULL, (int)SIOCSIFDSTADDR, (caddr_t)&ifr,
-                       (struct ifnet *)ifn, NULL);
-       satons_addr(ifr.ifr_addr).x_host = ns_thishost;
-       return (ns_control(NULL, (int)SIOCSIFADDR, (caddr_t)&ifr,
-                       (struct ifnet *)ifn, NULL));
-}
-
-int
-nsip_free(struct ifnet *ifp)
-{
-       struct ifnet_en *ifn = (struct ifnet_en *)ifp;
-       struct route *ro = & ifn->ifen_route;
-
-       if (ro->ro_rt) {
-               RTFREE(ro->ro_rt);
-               ro->ro_rt = 0;
-       }
-       ifp->if_flags &= ~IFF_UP;
-       return (0);
-}
-
-void
-nsip_ctlinput(int cmd, struct sockaddr *sa)
-{
-       extern u_char inetctlerrmap[];
-       struct sockaddr_in *sin;
-       int in_rtchange();
-
-       if ((unsigned)cmd >= PRC_NCMDS)
-               return;
-       if (sa->sa_family != AF_INET && sa->sa_family != AF_IMPLINK)
-               return;
-       sin = (struct sockaddr_in *)sa;
-       if (sin->sin_addr.s_addr == INADDR_ANY)
-               return;
-
-       switch (cmd) {
-
-       case PRC_ROUTEDEAD:
-       case PRC_REDIRECT_NET:
-       case PRC_REDIRECT_HOST:
-       case PRC_REDIRECT_TOSNET:
-       case PRC_REDIRECT_TOSHOST:
-               nsip_rtchange(&sin->sin_addr);
-               break;
-       }
-}
-
-void
-nsip_rtchange(struct in_addr *dst)
-{
-       struct ifnet_en *ifn;
-
-       for (ifn = nsip_list; ifn; ifn = ifn->ifen_next) {
-               if (ifn->ifen_dst.s_addr == dst->s_addr &&
-                       ifn->ifen_route.ro_rt) {
-                               RTFREE(ifn->ifen_route.ro_rt);
-                               ifn->ifen_route.ro_rt = 0;
-               }
-       }
-}
-#endif
diff --git a/sys/netproto/ns/ns_output.c b/sys/netproto/ns/ns_output.c
deleted file mode 100644 (file)
index aa9b2ea..0000000
+++ /dev/null
@@ -1,156 +0,0 @@
-/*
- * Copyright (c) 1984, 1985, 1986, 1987, 1993
- *     The Regents of the University of California.  All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- *    must display the following acknowledgement:
- *     This product includes software developed by the University of
- *     California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- *    may be used to endorse or promote products derived from this software
- *    without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- *     @(#)ns_output.c 8.1 (Berkeley) 6/10/93
- * $FreeBSD: src/sys/netns/ns_output.c,v 1.7 1999/08/28 00:49:51 peter Exp $
- * $DragonFly: src/sys/netproto/ns/ns_output.c,v 1.9 2008/05/14 11:59:24 sephe Exp $
- */
-
-#include <sys/param.h>
-#include <sys/malloc.h>
-#include <sys/mbuf.h>
-#include <sys/errno.h>
-#include <sys/socket.h>
-#include <sys/socketvar.h>
-
-#include <net/if.h>
-#include <net/route.h>
-
-#include "ns.h"
-#include "ns_if.h"
-#include "idp.h"
-#include "idp_var.h"
-
-int ns_hold_output = 0;
-int ns_copy_output = 0;
-int ns_output_cnt = 0;
-struct mbuf *ns_lastout;
-
-int
-ns_output(struct mbuf *m0, struct route *ro, int flags)
-{
-       struct idp *idp = mtod(m0, struct idp *);
-       struct ifnet *ifp = 0;
-       int error = 0;
-       struct route idproute;
-       struct sockaddr_ns *dst;
-
-       if (ns_hold_output) {
-               if (ns_lastout) {
-                       m_free(ns_lastout);
-               }
-               ns_lastout = m_copy(m0, 0, (int)M_COPYALL);
-       }
-       /*
-        * Route packet.
-        */
-       if (ro == 0) {
-               ro = &idproute;
-               bzero((caddr_t)ro, sizeof (*ro));
-       }
-       dst = (struct sockaddr_ns *)&ro->ro_dst;
-       if (ro->ro_rt == 0) {
-               dst->sns_family = AF_NS;
-               dst->sns_len = sizeof (*dst);
-               dst->sns_addr = idp->idp_dna;
-               dst->sns_addr.x_port = 0;
-               /*
-                * If routing to interface only,
-                * short circuit routing lookup.
-                */
-               if (flags & NS_ROUTETOIF) {
-                       struct ns_ifaddr *ia = ns_iaonnetof(&idp->idp_dna);
-
-                       if (ia == 0) {
-                               error = ENETUNREACH;
-                               goto bad;
-                       }
-                       ifp = ia->ia_ifp;
-                       goto gotif;
-               }
-               rtalloc(ro);
-       } else if ((ro->ro_rt->rt_flags & RTF_UP) == 0) {
-               /*
-                * The old route has gone away; try for a new one.
-                */
-               rtfree(ro->ro_rt);
-               ro->ro_rt = NULL;
-               rtalloc(ro);
-       }
-       if (ro->ro_rt == 0 || (ifp = ro->ro_rt->rt_ifp) == 0) {
-               error = ENETUNREACH;
-               goto bad;
-       }
-       ro->ro_rt->rt_use++;
-       if (ro->ro_rt->rt_flags & (RTF_GATEWAY|RTF_HOST))
-               dst = (struct sockaddr_ns *)ro->ro_rt->rt_gateway;
-gotif:
-
-       /*
-        * Look for multicast addresses and
-        * and verify user is allowed to send
-        * such a packet.
-        */
-       if (dst->sns_addr.x_host.c_host[0]&1) {
-               if ((ifp->if_flags & IFF_BROADCAST) == 0) {
-                       error = EADDRNOTAVAIL;
-                       goto bad;
-               }
-               if ((flags & NS_ALLOWBROADCAST) == 0) {
-                       error = EACCES;
-                       goto bad;
-               }
-       }
-
-       if (htons(idp->idp_len) <= ifp->if_mtu) {
-               ns_output_cnt++;
-               if (ns_copy_output) {
-                       ns_watch_output(m0, ifp);
-               }
-               error = ifp->if_output(ifp, m0, (struct sockaddr *)dst,
-                                      ro->ro_rt);
-               goto done;
-       } else error = EMSGSIZE;
-
-
-bad:
-       if (ns_copy_output) {
-               ns_watch_output(m0, ifp);
-       }
-       m_freem(m0);
-done:
-       if (ro == &idproute && (flags & NS_ROUTETOIF) == 0 && ro->ro_rt) {
-               RTFREE(ro->ro_rt);
-               ro->ro_rt = 0;
-       }
-       return (error);
-}
diff --git a/sys/netproto/ns/ns_pcb.c b/sys/netproto/ns/ns_pcb.c
deleted file mode 100644 (file)
index 9128110..0000000
+++ /dev/null
@@ -1,361 +0,0 @@
-/*
- * Copyright (c) 1984, 1985, 1986, 1987, 1993
- *     The Regents of the University of California.  All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- *    must display the following acknowledgement:
- *     This product includes software developed by the University of
- *     California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- *    may be used to endorse or promote products derived from this software
- *    without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- *     @(#)ns_pcb.c    8.1 (Berkeley) 6/10/93
- * $FreeBSD: src/sys/netns/ns_pcb.c,v 1.9 1999/08/28 00:49:51 peter Exp $
- * $DragonFly: src/sys/netproto/ns/ns_pcb.c,v 1.15 2006/09/05 00:55:49 dillon Exp $
- */
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/kernel.h>
-#include <sys/mbuf.h>
-#include <sys/errno.h>
-#include <sys/socket.h>
-#include <sys/socketvar.h>
-#include <sys/protosw.h>
-#include <sys/module.h>
-#include <sys/malloc.h>
-#include <sys/thread2.h>
-
-#include <net/if.h>
-#include <net/route.h>
-
-#include "ns.h"
-#include "ns_if.h"
-#include "ns_pcb.h"
-
-struct ns_addr zerons_addr;
-struct nspcb nspcb;            /* head of list */
-
-static MALLOC_DEFINE(M_NSPCB, "nspcb", "NS PCB Management");
-
-int
-ns_pcballoc(struct socket *so, struct nspcb *head)
-{
-       struct nspcb *nsp;
-
-       nsp = kmalloc(sizeof(struct nspcb), M_NSPCB, M_WAITOK|M_ZERO);
-       nsp->nsp_socket = so;
-       insque(nsp, head);
-       so->so_pcb = (caddr_t)nsp;
-       return (0);
-}
-
-int
-ns_pcbbind(struct nspcb *nsp, struct sockaddr *nam)
-{
-       struct sockaddr_ns *sns;
-       u_short lport = 0;
-
-       if (nsp->nsp_lport || !ns_nullhost(nsp->nsp_laddr))
-               return (EINVAL);
-       if (nam == NULL)
-               goto noname;
-       sns = (struct sockaddr_ns *)nam;
-       if (nam->sa_len != sizeof (*sns))
-               return (EINVAL);
-       if (!ns_nullhost(sns->sns_addr)) {
-               int tport = sns->sns_port;
-
-               sns->sns_port = 0;              /* yech... */
-               if (ifa_ifwithaddr((struct sockaddr *)sns) == 0)
-                       return (EADDRNOTAVAIL);
-               sns->sns_port = tport;
-       }
-       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);
-       }
-       nsp->nsp_laddr = sns->sns_addr;
-noname:
-       if (lport == 0)
-               do {
-                       if (nspcb.nsp_lport++ < NSPORT_RESERVED)
-                               nspcb.nsp_lport = NSPORT_RESERVED;
-                       lport = htons(nspcb.nsp_lport);
-               } while (ns_pcblookup(&zerons_addr, lport, 0));
-       nsp->nsp_lport = lport;
-       return (0);
-}
-
-/*
- * Connect from a socket to a specified address.
- * Both address and port must be specified in argument sns.
- * If don't have a local address for this socket yet,
- * then pick one.
- */
-int
-ns_pcbconnect(struct nspcb *nsp, struct sockaddr *nam)
-{
-       struct ns_ifaddr *ia;
-       struct sockaddr_ns *sns = (struct sockaddr_ns *)nam;
-       struct ns_addr *dst;
-       struct route *ro;
-       struct ifnet *ifp;
-
-       if (nam->sa_len != sizeof (*sns))
-               return (EINVAL);
-       if (sns->sns_family != AF_NS)
-               return (EAFNOSUPPORT);
-       if (sns->sns_port==0 || ns_nullhost(sns->sns_addr))
-               return (EADDRNOTAVAIL);
-       /*
-        * If we haven't bound which network number to use as ours,
-        * we will use the number of the outgoing interface.
-        * This depends on having done a routing lookup, which
-        * we will probably have to do anyway, so we might
-        * as well do it now.  On the other hand if we are
-        * sending to multiple destinations we may have already
-        * done the lookup, so see if we can use the route
-        * from before.  In any case, we only
-        * chose a port number once, even if sending to multiple
-        * destinations.
-        */
-       ro = &nsp->nsp_route;
-       dst = &satons_addr(ro->ro_dst);
-       if (nsp->nsp_socket->so_options & SO_DONTROUTE)
-               goto flush;
-       if (!ns_neteq(nsp->nsp_lastdst, sns->sns_addr))
-               goto flush;
-       if (!ns_hosteq(nsp->nsp_lastdst, sns->sns_addr)) {
-               if (ro->ro_rt && ! (ro->ro_rt->rt_flags & RTF_HOST)) {
-                       /* can patch route to avoid rtalloc */
-                       *dst = sns->sns_addr;
-               } else {
-       flush:
-                       if (ro->ro_rt)
-                               RTFREE(ro->ro_rt);
-                       ro->ro_rt = NULL;
-                       nsp->nsp_laddr.x_net = ns_zeronet;
-               }
-       }/* else cached route is ok; do nothing */
-       nsp->nsp_lastdst = sns->sns_addr;
-       if ((nsp->nsp_socket->so_options & SO_DONTROUTE) == 0 && /*XXX*/
-           (ro->ro_rt == NULL ||
-            ro->ro_rt->rt_ifp == NULL)) {
-                   /* No route yet, so try to acquire one */
-                   ro->ro_dst.sa_family = AF_NS;
-                   ro->ro_dst.sa_len = sizeof(ro->ro_dst);
-                   *dst = sns->sns_addr;
-                   dst->x_port = 0;
-                   rtalloc(ro);
-       }
-       if (ns_neteqnn(nsp->nsp_laddr.x_net, ns_zeronet)) {
-               /*
-                * If route is known or can be allocated now,
-                * our src addr is taken from the i/f, else punt.
-                */
-
-               ia = NULL;
-               /*
-                * If we found a route, use the address
-                * corresponding to the outgoing interface
-                */
-               if (ro->ro_rt && (ifp = ro->ro_rt->rt_ifp))
-                       for (ia = ns_ifaddr; ia; ia = ia->ia_next)
-                               if (ia->ia_ifp == ifp)
-                                       break;
-               if (ia == 0) {
-                       u_short fport = sns->sns_addr.x_port;
-                       sns->sns_addr.x_port = 0;
-                       ia = (struct ns_ifaddr *)
-                               ifa_ifwithdstaddr((struct sockaddr *)sns);
-                       sns->sns_addr.x_port = fport;
-                       if (ia == 0)
-                               ia = ns_iaonnetof(&sns->sns_addr);
-                       if (ia == 0)
-                               ia = ns_ifaddr;
-                       if (ia == 0)
-                               return (EADDRNOTAVAIL);
-               }
-               nsp->nsp_laddr.x_net = satons_addr(ia->ia_addr).x_net;
-       }
-       if (ns_pcblookup(&sns->sns_addr, nsp->nsp_lport, 0))
-               return (EADDRINUSE);
-       if (ns_nullhost(nsp->nsp_laddr)) {
-               if (nsp->nsp_lport == 0)
-                       ns_pcbbind(nsp, NULL);
-               nsp->nsp_laddr.x_host = ns_thishost;
-       }
-       nsp->nsp_faddr = sns->sns_addr;
-       /* Includes nsp->nsp_fport = sns->sns_port; */
-       return (0);
-}
-
-void
-ns_pcbdisconnect(struct nspcb *nsp)
-{
-       nsp->nsp_faddr = zerons_addr;
-       if (nsp->nsp_socket->so_state & SS_NOFDREF)
-               ns_pcbdetach(nsp);
-}
-
-void
-ns_pcbdetach(struct nspcb *nsp)
-{
-       struct socket *so = nsp->nsp_socket;
-
-       so->so_pcb = NULL;
-       sofree(so);
-       if (nsp->nsp_route.ro_rt)
-               rtfree(nsp->nsp_route.ro_rt);
-       remque(nsp);
-       kfree(nsp, M_NSPCB);
-}
-
-void
-ns_setsockaddr(struct nspcb *nsp, struct sockaddr **pnam)
-{
-       struct sockaddr_ns sns;
-
-       bzero(&sns, sizeof(sns));
-       sns.sns_len = sizeof(sns);
-       sns.sns_family = AF_NS;
-       sns.sns_addr = nsp->nsp_laddr;
-       *pnam = dup_sockaddr((struct sockaddr *)&sns);
-}
-
-void
-ns_setpeeraddr(struct nspcb *nsp, struct sockaddr **pnam)
-{
-       struct sockaddr_ns sns;
-
-       bzero(&sns, sizeof(sns));
-       sns.sns_len = sizeof(sns);
-       sns.sns_family = AF_NS;
-       sns.sns_addr  = nsp->nsp_faddr;
-       *pnam = dup_sockaddr((struct sockaddr *)&sns);
-}
-
-/*
- * Pass some notification to all connections of a protocol
- * associated with address dst.  Call the
- * protocol specific routine to handle each connection.
- * Also pass an extra paramter via the nspcb. (which may in fact
- * be a parameter list!)
- */
-void
-ns_pcbnotify(struct ns_addr *dst, int errno,
-           void (*notify)(struct nspcb *), long param)
-{
-       struct nspcb *nsp, *oinp;
-
-       crit_enter();
-
-       for (nsp = (&nspcb)->nsp_next; nsp != (&nspcb);) {
-               if (!ns_hosteq(*dst,nsp->nsp_faddr)) {
-       next:
-                       nsp = nsp->nsp_next;
-                       continue;
-               }
-               if (nsp->nsp_socket == 0)
-                       goto next;
-               if (errno)
-                       nsp->nsp_socket->so_error = errno;
-               oinp = nsp;
-               nsp = nsp->nsp_next;
-               oinp->nsp_notify_param = param;
-               (*notify)(oinp);
-       }
-       crit_exit();
-}
-
-#ifdef notdef
-/*
- * After a routing change, flush old routing
- * and allocate a (hopefully) better one.
- */
-void
-ns_rtchange(struct nspcb *nsp)
-{
-       if (nsp->nsp_route.ro_rt) {
-               rtfree(nsp->nsp_route.ro_rt);
-               nsp->nsp_route.ro_rt = 0;
-               /*
-                * A new route can be allocated the next time
-                * output is attempted.
-                */
-       }
-       /* SHOULD NOTIFY HIGHER-LEVEL PROTOCOLS */
-}
-#endif
-
-struct nspcb *
-ns_pcblookup(struct ns_addr *faddr, u_short lport, int wildp)
-{
-       struct nspcb *nsp, *match = 0;
-       int matchwild = 3, wildcard;
-       u_short fport;
-
-       fport = faddr->x_port;
-       for (nsp = (&nspcb)->nsp_next; nsp != (&nspcb); nsp = nsp->nsp_next) {
-               if (nsp->nsp_lport != lport)
-                       continue;
-               wildcard = 0;
-               if (ns_nullhost(nsp->nsp_faddr)) {
-                       if (!ns_nullhost(*faddr))
-                               wildcard++;
-               } else {
-                       if (ns_nullhost(*faddr))
-                               wildcard++;
-                       else {
-                               if (!ns_hosteq(nsp->nsp_faddr, *faddr))
-                                       continue;
-                               if (nsp->nsp_fport != fport) {
-                                       if (nsp->nsp_fport != 0)
-                                               continue;
-                                       else
-                                               wildcard++;
-                               }
-                       }
-               }
-               if (wildcard && wildp==0)
-                       continue;
-               if (wildcard < matchwild) {
-                       match = nsp;
-                       matchwild = wildcard;
-                       if (wildcard == 0)
-                               break;
-               }
-       }
-       return (match);
-}
diff --git a/sys/netproto/ns/ns_pcb.h b/sys/netproto/ns/ns_pcb.h
deleted file mode 100644 (file)
index abbdece..0000000
+++ /dev/null
@@ -1,96 +0,0 @@
-/*
- * Copyright (c) 1984, 1985, 1986, 1987, 1993
- *     The Regents of the University of California.  All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- *    must display the following acknowledgement:
- *     This product includes software developed by the University of
- *     California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- *    may be used to endorse or promote products derived from this software
- *    without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- *     @(#)ns_pcb.h    8.1 (Berkeley) 6/10/93
- * $FreeBSD: src/sys/netns/ns_pcb.h,v 1.11 1999/12/29 04:46:20 peter Exp $
- * $DragonFly: src/sys/netproto/ns/ns_pcb.h,v 1.5 2004/06/07 07:04:33 dillon Exp $
- */
-
-#ifndef _NETNS_NS_PCB_H_
-#define _NETNS_NS_PCB_H_
-
-/*
- * Ns protocol interface control block.
- */
-struct nspcb {
-       struct  nspcb *nsp_next;        /* doubly linked list */
-       struct  nspcb *nsp_prev;
-       struct  socket *nsp_socket;     /* back pointer to socket */
-       struct  ns_addr nsp_faddr;      /* destination address */
-       struct  ns_addr nsp_laddr;      /* socket's address */
-       caddr_t nsp_pcb;                /* protocol specific stuff */
-       struct  route nsp_route;        /* routing information */
-       struct  ns_addr nsp_lastdst;    /* validate cached route for dg socks*/
-       long    nsp_notify_param;       /* extra info passed via ns_pcbnotify*/
-       short   nsp_flags;
-       u_char  nsp_dpt;                /* default packet type for idp_output*/
-       u_char  nsp_rpt;                /* last received packet type by
-                                                               idp_input() */
-};
-
-/* possible flags */
-
-#define NSP_IN_ABORT   0x1             /* calling abort through socket */
-#define NSP_RAWIN      0x2             /* show headers on input */
-#define NSP_RAWOUT     0x4             /* show header on output */
-#define NSP_ALL_PACKETS        0x8             /* Turn off higher proto processing */
-
-#define        NS_WILDCARD     1
-
-#define nsp_lport nsp_laddr.x_port
-#define nsp_fport nsp_faddr.x_port
-
-#define        sotonspcb(so)           ((struct nspcb *)((so)->so_pcb))
-
-/*
- * Nominal space allocated to a ns socket.
- */
-#define        NSSNDQ          2048
-#define        NSRCVQ          2048
-
-
-#ifdef _KERNEL
-extern struct nspcb nspcb;                     /* head of list */
-
-struct nspcb *ns_pcblookup (struct ns_addr *, u_short, int);
-void ns_pcbdisconnect (struct nspcb *);
-void ns_pcbdetach (struct nspcb *);
-int ns_pcballoc (struct socket *, struct nspcb *);
-int ns_pcbbind(struct nspcb *nsp, struct sockaddr *nam);
-int ns_pcbconnect (struct nspcb *, struct sockaddr *);
-void ns_setsockaddr (struct nspcb *, struct sockaddr **);
-void ns_setpeeraddr (struct nspcb *, struct sockaddr **);
-void ns_pcbnotify (struct ns_addr *, int, void(*)(struct nspcb *), long);
-
-#endif
-
-#endif
diff --git a/sys/netproto/ns/ns_proto.c b/sys/netproto/ns/ns_proto.c
deleted file mode 100644 (file)
index 088c79d..0000000
+++ /dev/null
@@ -1,106 +0,0 @@
-/*
- * Copyright (c) 1984, 1985, 1986, 1987, 1993
- *     The Regents of the University of California.  All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- *    must display the following acknowledgement:
- *     This product includes software developed by the University of
- *     California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- *    may be used to endorse or promote products derived from this software
- *    without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- *     From: @(#)ns_proto.c    8.1 (Berkeley) 6/10/93
- * $FreeBSD: src/sys/netns/ns_proto.c,v 1.10 1999/08/28 00:49:51 peter Exp $
- * $DragonFly: src/sys/netproto/ns/ns_proto.c,v 1.8 2008/11/01 04:22:16 sephe Exp $
- */
-
-#include <sys/param.h>
-#include <sys/kernel.h>
-#include <sys/socket.h>
-#include <sys/protosw.h>
-#include <sys/domain.h>
-#include <sys/mbuf.h>
-
-#include <net/radix.h>
-
-#include "ns.h"
-#include "idp.h"
-#include "idp_var.h"
-#include "sp.h"
-#include "spidp.h"
-#include "spp_timer.h"
-#include "spp_var.h"
-
-/*
- * NS protocol family: IDP, ERR, PE, SPP, ROUTE.
- */
-
-static  struct pr_usrreqs nousrreqs;
-
-struct protosw nssw[] = {
-{ 0,           &nsdomain,      0,              0,
-  0,           idp_output,     0,              0,
-  cpu0_soport, NULL,
-  ns_init,     0,              0,              0,
-  &nousrreqs
-},
-{ SOCK_DGRAM,  &nsdomain,      0,              PR_ATOMIC|PR_ADDR,
-  0,           0,              idp_ctlinput,   idp_ctloutput,
-  cpu0_soport, cpu0_ctlport,
-  0,           0,              0,              0,
-  &idp_usrreqs
-},
-{ SOCK_STREAM, &nsdomain,      NSPROTO_SPP,    PR_CONNREQUIRED|PR_WANTRCVD,
-  spp_input,   0,              spp_ctlinput,   spp_ctloutput,
-  cpu0_soport, cpu0_ctlport,
-  spp_init,    spp_fasttimo,   spp_slowtimo,   0,
-  &spp_usrreqs
-},
-{ SOCK_SEQPACKET,&nsdomain,    NSPROTO_SPP,    PR_CONNREQUIRED|PR_WANTRCVD|PR_ATOMIC,
-  spp_input,   0,              spp_ctlinput,   spp_ctloutput,
-  cpu0_soport, cpu0_ctlport,
-  0,           0,              0,              0,
-  &spp_usrreqs_sp
-},
-{ SOCK_RAW,    &nsdomain,      NSPROTO_RAW,    PR_ATOMIC|PR_ADDR,
-  idp_input,   idp_output,     0,              idp_ctloutput,
-  cpu0_soport, NULL,
-  0,           0,              0,              0,
-  &idp_raw_usrreqs
-},
-{ SOCK_RAW,    &nsdomain,      NSPROTO_ERROR,  PR_ATOMIC|PR_ADDR,
-  idp_ctlinput,        idp_output,     0,              idp_ctloutput,
-  cpu0_soport, NULL,
-  0,           0,              0,              0,
-  &idp_raw_usrreqs
-}
-};
-
-struct domain nsdomain = {
-       AF_NS, "network systems", NULL, NULL, NULL,
-       nssw, &nssw[sizeof(nssw)/sizeof(nssw[0])], SLIST_ENTRY_INITIALIZER,
-       rn_inithead, 16, sizeof(struct sockaddr_ns),
-};
-
-DOMAIN_SET(ns);
diff --git a/sys/netproto/ns/sp.h b/sys/netproto/ns/sp.h
deleted file mode 100644 (file)
index 2bd2295..0000000
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * Copyright (c) 1984, 1985, 1986, 1987, 1993
- *     The Regents of the University of California.  All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- *    must display the following acknowledgement:
- *     This product includes software developed by the University of
- *     California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- *    may be used to endorse or promote products derived from this software
- *    without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- *     @(#)sp.h        8.1 (Berkeley) 6/10/93
- * $FreeBSD: src/sys/netns/sp.h,v 1.8 1999/08/28 00:49:52 peter Exp $
- * $DragonFly: src/sys/netproto/ns/sp.h,v 1.2 2003/06/17 04:28:53 dillon Exp $
- */
-
-#ifndef _NETNS_SP_H_
-#define _NETNS_SP_H_
-
-/*
- * Definitions for Xerox NS style sequenced packet protocol
- */
-
-struct sphdr {
-       u_char  sp_cc;          /* connection control */
-       u_char  sp_dt;          /* datastream type */
-#define        SP_SP   0x80            /* system packet */
-#define        SP_SA   0x40            /* send acknowledgement */
-#define        SP_OB   0x20            /* attention (out of band data) */
-#define        SP_EM   0x10            /* end of message */
-       u_short sp_sid;         /* source connection identifier */
-       u_short sp_did;         /* destination connection identifier */
-       u_short sp_seq;         /* sequence number */
-       u_short sp_ack;         /* acknowledge number */
-       u_short sp_alo;         /* allocation number */
-};
-
-#endif
diff --git a/sys/netproto/ns/spidp.h b/sys/netproto/ns/spidp.h
deleted file mode 100644 (file)
index eb629bb..0000000
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * Copyright (c) 1984, 1985, 1986, 1987, 1993
- *     The Regents of the University of California.  All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- *    must display the following acknowledgement:
- *     This product includes software developed by the University of
- *     California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- *    may be used to endorse or promote products derived from this software
- *    without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- *     @(#)spidp.h     8.1 (Berkeley) 6/10/93
- * $FreeBSD: src/sys/netns/spidp.h,v 1.8 1999/08/28 00:49:52 peter Exp $
- * $DragonFly: src/sys/netproto/ns/spidp.h,v 1.3 2004/06/04 20:27:32 dillon Exp $
- */
-
-#ifndef _NETNS_SPIDP_H_
-#define _NETNS_SPIDP_H_
-
-/*
- * Definitions for NS(tm) Internet Datagram Protocol
- * containing a Sequenced Packet Protocol packet.
- */
-struct spidp {
-       struct idp      si_i;
-       struct sphdr    si_s;
-};
-struct spidp_q {
-       struct spidp_q  *si_next;
-       struct spidp_q  *si_prev;
-       struct mbuf     *si_mbuf;       /* BAD HACK */
-};
-#define SI(x)  mtod((x)->si_mbuf, struct spidp *)
-#define si_sum si_i.idp_sum
-#define si_len si_i.idp_len
-#define si_tc  si_i.idp_tc
-#define si_pt  si_i.idp_pt
-#define si_dna si_i.idp_dna
-#define si_sna si_i.idp_sna
-#define si_sport       si_i.idp_sna.x_port
-#define si_cc  si_s.sp_cc
-#define si_dt  si_s.sp_dt
-#define si_sid si_s.sp_sid
-#define si_did si_s.sp_did
-#define si_seq si_s.sp_seq
-#define si_ack si_s.sp_ack
-#define si_alo si_s.sp_alo
-
-#endif
diff --git a/sys/netproto/ns/spp_debug.c b/sys/netproto/ns/spp_debug.c
deleted file mode 100644 (file)
index c36b496..0000000
+++ /dev/null
@@ -1,173 +0,0 @@
-/*
- * Copyright (c) 1984, 1985, 1986, 1987, 1993
- *     The Regents of the University of California.  All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- *    must display the following acknowledgement:
- *     This product includes software developed by the University of
- *     California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- *    may be used to endorse or promote products derived from this software
- *    without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- *     @(#)spp_debug.c 8.1 (Berkeley) 6/10/93
- * $FreeBSD: src/sys/netns/spp_debug.c,v 1.10 1999/08/28 00:49:52 peter Exp $
- * $DragonFly: src/sys/netproto/ns/spp_debug.c,v 1.7 2006/12/22 23:57:54 swildner Exp $
- */
-
-#include "opt_inet.h"
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/mbuf.h>
-#include <sys/socket.h>
-#include <sys/socketvar.h>
-#include <sys/protosw.h>
-#include <sys/errno.h>
-
-#include <net/route.h>
-#include <net/if.h>
-#include <netinet/tcp_fsm.h>
-
-#include "ns.h"
-#include "ns_pcb.h"
-#include "idp.h"
-#include "idp_var.h"
-#include "sp.h"
-#include "spidp.h"
-#define SPPTIMERS
-#include "spp_timer.h"
-#include "spp_var.h"
-#define        SANAMES
-#include "spp_debug.h"
-
-int    sppconsdebug = 0;
-struct   spp_debug spp_debug[SPP_NDEBUG];
-int      spp_debx;
-
-/*
- * spp debug routines
- */
-void
-spp_trace(short act, u_char ostate, struct sppcb *sp, struct spidp *si, int req)
-{
-#ifdef INET
-#ifdef TCPDEBUG
-       u_short seq, ack, len, alo;
-       unsigned long iptime();
-       int flags;
-       struct spp_debug *sd = &spp_debug[spp_debx++];
-       extern char *prurequests[];
-       extern char *sanames[];
-       extern char *tcpstates[];
-       extern char *spptimers[];
-
-       if (spp_debx == SPP_NDEBUG)
-               spp_debx = 0;
-       sd->sd_time = iptime();
-       sd->sd_act = act;
-       sd->sd_ostate = ostate;
-       sd->sd_cb = (caddr_t)sp;
-       if (sp)
-               sd->sd_sp = *sp;
-       else
-               bzero((caddr_t)&sd->sd_sp, sizeof (*sp));
-       if (si)
-               sd->sd_si = *si;
-       else
-               bzero((caddr_t)&sd->sd_si, sizeof (*si));
-       sd->sd_req = req;
-       if (sppconsdebug == 0)
-               return;
-       if (ostate >= TCP_NSTATES) ostate = 0;
-       if (act >= SA_DROP) act = SA_DROP;
-       if (sp)
-               kprintf("%x %s:", sp, tcpstates[ostate]);
-       else
-               kprintf("???????? ");
-       kprintf("%s ", sanames[act]);
-       switch (act) {
-
-       case SA_RESPOND:
-       case SA_INPUT:
-       case SA_OUTPUT:
-       case SA_DROP:
-               if (si == 0)
-                       break;
-               seq = si->si_seq;
-               ack = si->si_ack;
-               alo = si->si_alo;
-               len = si->si_len;
-               if (act == SA_OUTPUT) {
-                       seq = ntohs(seq);
-                       ack = ntohs(ack);
-                       alo = ntohs(alo);
-                       len = ntohs(len);
-               }
-#ifndef lint
-#define p1(f)  { kprintf("%s = %x, ", "f", f); }
-               p1(seq); p1(ack); p1(alo); p1(len);
-#endif
-               flags = si->si_cc;
-               if (flags) {
-                       char *cp = "<";
-#ifndef lint
-#define pf(f) { if (flags&SP_/**/f) { kprintf("%s%s", cp, "f"); cp = ","; } }
-                       pf(SP); pf(SA); pf(OB); pf(EM);
-#else
-                       cp = cp;
-#endif
-                       kprintf(">");
-               }
-#ifndef lint
-#define p2(f)  { kprintf("%s = %x, ", "f", si->si_/**/f); }
-               p2(sid);p2(did);p2(dt);p2(pt);
-#endif
-               ns_printhost(&si->si_sna);
-               ns_printhost(&si->si_dna);
-
-               if (act==SA_RESPOND) {
-                       kprintf("idp_len = %x, ",
-                               ((struct idp *)si)->idp_len);
-               }
-               break;
-
-       case SA_USER:
-               kprintf("%s", prurequests[req&0xff]);
-               if ((req & 0xff) == PRU_SLOWTIMO)
-                       kprintf("<%s>", spptimers[req>>8]);
-               break;
-       }
-       if (sp)
-               kprintf(" -> %s", tcpstates[sp->s_state]);
-       /* print out internal state of sp !?! */
-       kprintf("\n");
-       if (sp == 0)
-               return;
-#ifndef lint
-#define p3(f)  { kprintf("%s = %x, ", "f", sp->s_/**/f); }
-       kprintf("\t"); p3(rack);p3(ralo);p3(smax);p3(flags); kprintf("\n");
-#endif
-#endif
-#endif
-}
diff --git a/sys/netproto/ns/spp_debug.h b/sys/netproto/ns/spp_debug.h
deleted file mode 100644 (file)
index ad51df3..0000000
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * Copyright (c) 1984, 1985, 1986, 1987, 1993
- *     The Regents of the University of California.  All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- *    must display the following acknowledgement:
- *     This product includes software developed by the University of
- *     California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- *    may be used to endorse or promote products derived from this software
- *    without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- *     @(#)spp_debug.h 8.1 (Berkeley) 6/10/93
- * $FreeBSD: src/sys/netns/spp_debug.h,v 1.9 1999/08/28 00:49:53 peter Exp $
- * $DragonFly: src/sys/netproto/ns/spp_debug.h,v 1.4 2004/02/16 20:37:20 dillon Exp $
- */
-
-#ifndef _NETNS_SPP_DEBUG_H_
-#define _NETNS_SPP_DEBUG_H_
-
-struct spp_debug {
-       u_long  sd_time;
-       short   sd_act;
-       short   sd_ostate;
-       caddr_t sd_cb;
-       short   sd_req;
-       struct  spidp sd_si;
-       struct  sppcb sd_sp;
-};
-
-#define        SA_INPUT        0
-#define        SA_OUTPUT       1
-#define        SA_USER         2
-#define        SA_RESPOND      3
-#define        SA_DROP         4
-
-#ifdef SANAMES
-char   *sanames[] =
-    { "input", "output", "user", "respond", "drop" };
-#endif
-
-#define        SPP_NDEBUG 100
-extern struct  spp_debug spp_debug[SPP_NDEBUG];
-extern int     spp_debx;
-
-#endif
-
-#ifdef _KERNEL
-
-void spp_trace (short, u_char, struct sppcb *, struct spidp *, int);
-#endif
diff --git a/sys/netproto/ns/spp_timer.h b/sys/netproto/ns/spp_timer.h
deleted file mode 100644 (file)
index cbe7a45..0000000
+++ /dev/null
@@ -1,129 +0,0 @@
-/*
- * Copyright (c) 1982, 1986, 1988, 1993
- *     The Regents of the University of California.  All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- *    must display the following acknowledgement:
- *     This product includes software developed by the University of
- *     California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- *    may be used to endorse or promote products derived from this software
- *    without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- *     @(#)spp_timer.h 8.1 (Berkeley) 6/10/93
- * $FreeBSD: src/sys/netns/spp_timer.h,v 1.9 1999/12/29 04:46:20 peter Exp $
- * $DragonFly: src/sys/netproto/ns/spp_timer.h,v 1.2 2003/06/17 04:28:53 dillon Exp $
- */
-
-#ifndef _NETNS_SPP_TIMER_H_
-#define _NETNS_SPP_TIMER_H_
-
-/*
- * Definitions of the SPP timers.  These timers are counted
- * down PR_SLOWHZ times a second.
- */
-#define        SPPT_NTIMERS    4
-
-#define        SPPT_REXMT      0               /* retransmit */
-#define        SPPT_PERSIST    1               /* retransmit persistance */
-#define        SPPT_KEEP       2               /* keep alive */
-#define        SPPT_2MSL       3               /* 2*msl quiet time timer */
-
-/*
- * The SPPT_REXMT timer is used to force retransmissions.
- * The SPP has the SPPT_REXMT timer set whenever segments
- * have been sent for which ACKs are expected but not yet
- * received.  If an ACK is received which advances tp->snd_una,
- * then the retransmit timer is cleared (if there are no more
- * outstanding segments) or reset to the base value (if there
- * are more ACKs expected).  Whenever the retransmit timer goes off,
- * we retransmit one unacknowledged segment, and do a backoff
- * on the retransmit timer.
- *
- * The SPPT_PERSIST timer is used to keep window size information
- * flowing even if the window goes shut.  If all previous transmissions
- * have been acknowledged (so that there are no retransmissions in progress),
- * and the window is too small to bother sending anything, then we start
- * the SPPT_PERSIST timer.  When it expires, if the window is nonzero,
- * we go to transmit state.  Otherwise, at intervals send a single byte
- * into the peer's window to force him to update our window information.
- * We do this at most as often as SPPT_PERSMIN time intervals,
- * but no more frequently than the current estimate of round-trip
- * packet time.  The SPPT_PERSIST timer is cleared whenever we receive
- * a window update from the peer.
- *
- * The SPPT_KEEP timer is used to keep connections alive.  If an
- * connection is idle (no segments received) for SPPTV_KEEP amount of time,
- * but not yet established, then we drop the connection.  If the connection
- * is established, then we force the peer to send us a segment by sending:
- *     <SEQ=SND.UNA-1><ACK=RCV.NXT><CTL=ACK>
- * This segment is (deliberately) outside the window, and should elicit
- * an ack segment in response from the peer.  If, despite the SPPT_KEEP
- * initiated segments we cannot elicit a response from a peer in SPPT_MAXIDLE
- * amount of time, then we drop the connection.
- */
-
-#define        SPP_TTL         30              /* default time to live for SPP segs */
-/*
- * Time constants.
- */
-#define        SPPTV_MSL       ( 15*PR_SLOWHZ)         /* max seg lifetime */
-#define        SPPTV_SRTTBASE  0                       /* base roundtrip time;
-                                                  if 0, no idea yet */
-#define        SPPTV_SRTTDFLT  (  3*PR_SLOWHZ)         /* assumed RTT if no info */
-
-#define        SPPTV_PERSMIN   (  5*PR_SLOWHZ)         /* retransmit persistance */
-#define        SPPTV_PERSMAX   ( 60*PR_SLOWHZ)         /* maximum persist interval */
-
-#define        SPPTV_KEEP      ( 75*PR_SLOWHZ)         /* keep alive - 75 secs */
-#define        SPPTV_MAXIDLE   (  8*SPPTV_KEEP)        /* maximum allowable idle
-                                                  time before drop conn */
-
-#define        SPPTV_MIN       (  1*PR_SLOWHZ)         /* minimum allowable value */
-#define        SPPTV_REXMTMAX  ( 64*PR_SLOWHZ)         /* max allowable REXMT value */
-
-#define        SPP_LINGERTIME  120                     /* linger at most 2 minutes */
-
-#define        SPP_MAXRXTSHIFT 12                      /* maximum retransmits */
-
-#ifdef SPPTIMERS
-char *spptimers[] =
-    { "REXMT", "PERSIST", "KEEP", "2MSL" };
-#endif
-
-/*
- * Force a time value to be in a certain range.
- */
-#define        SPPT_RANGESET(tv, value, tvmin, tvmax) { \
-       (tv) = (value); \
-       if ((tv) < (tvmin)) \
-               (tv) = (tvmin); \
-       else if ((tv) > (tvmax)) \
-               (tv) = (tvmax); \
-}
-
-#ifdef _KERNEL
-extern int spp_backoff[];
-#endif
-
-#endif
diff --git a/sys/netproto/ns/spp_usrreq.c b/sys/netproto/ns/spp_usrreq.c
deleted file mode 100644 (file)
index 73edb07..0000000
+++ /dev/null
@@ -1,1951 +0,0 @@
-/*
- * Copyright (c) 1984, 1985, 1986, 1987, 1993
- *     The Regents of the University of California.  All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- *    must display the following acknowledgement:
- *     This product includes software developed by the University of
- *     California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- *    may be used to endorse or promote products derived from this software
- *    without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- *     @(#)spp_usrreq.c        8.1 (Berkeley) 6/10/93
- * $FreeBSD: src/sys/netns/spp_usrreq.c,v 1.11 1999/08/28 00:49:53 peter Exp $
- * $DragonFly: src/sys/netproto/ns/spp_usrreq.c,v 1.22 2007/04/22 01:13:16 dillon Exp $
- */
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/kernel.h>
-#include <sys/malloc.h>
-#include <sys/mbuf.h>
-#include <sys/protosw.h>
-#include <sys/socket.h>
-#include <sys/socketvar.h>
-#include <sys/socketvar2.h>
-#include <sys/errno.h>
-#include <sys/thread2.h>
-
-#include <net/if.h>
-#include <net/route.h>
-#include <netinet/tcp_fsm.h>
-
-#include "ns.h"
-#include "ns_pcb.h"
-#include "idp.h"
-#include "idp_var.h"
-#include "ns_error.h"
-#include "sp.h"
-#include "spidp.h"
-#include "spp_timer.h"
-#include "spp_var.h"
-#include "spp_debug.h"
-
-extern u_char nsctlerrmap[];           /* from ns_input.c */
-extern int idpcksum;                   /* from ns_input.c */
-
-static MALLOC_DEFINE(M_IDP, "ns_idp", "NS Packet Management");
-static MALLOC_DEFINE(M_SPIDP_Q, "ns_spidp_q", "NS Packet Management");
-static MALLOC_DEFINE(M_SPPCB, "ns_sppcb", "NS PCB Management");
-
-struct spp_istat spp_istat;
-u_short spp_iss;
-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(void)
-{
-       spp_iss = 1; /* WRONG !! should fish it out of TODR */
-}
-struct spidp spp_savesi;
-int traceallspps = 0;
-extern int sppconsdebug;
-int spp_hardnosed;
-int spp_use_delack = 0;
-u_short spp_newchecks[50];
-
-/*ARGSUSED*/
-void
-spp_input(struct mbuf *m, ...)
-{
-       struct sppcb *cb;
-       struct spidp *si;
-       struct socket *so;
-       short ostate = 0;
-       int dropsocket = 0;
-       struct nspcb *nsp;
-       __va_list ap;
-
-       __va_start(ap, m);
-       nsp = __va_arg(ap, struct nspcb *);
-       __va_end(ap);
-
-       sppstat.spps_rcvtotal++;
-       if (nsp == 0) {
-               panic("No nspcb in spp_input");
-               return;
-       }
-
-       cb = nstosppcb(nsp);
-       if (cb == 0) goto bad;
-
-       if (m->m_len < sizeof(struct spidp)) {
-               if ((m = m_pullup(m, sizeof(*si))) == 0) {
-                       sppstat.spps_rcvshort++;
-                       return;
-               }
-       }
-       si = mtod(m, struct spidp *);
-       si->si_seq = ntohs(si->si_seq);
-       si->si_ack = ntohs(si->si_ack);
-       si->si_alo = ntohs(si->si_alo);
-
-       so = nsp->nsp_socket;
-       if (so->so_options & SO_DEBUG || traceallspps) {
-               ostate = cb->s_state;
-               spp_savesi = *si;
-       }
-       if (so->so_options & SO_ACCEPTCONN) {
-               struct sppcb *ocb = cb;
-
-               so = sonewconn(so, 0);
-               if (so == 0) {
-                       goto drop;
-               }
-               /*
-                * This is ugly, but ....
-                *
-                * Mark socket as temporary until we're
-                * committed to keeping it.  The code at
-                * ``drop'' and ``dropwithreset'' check the
-                * flag dropsocket to see if the temporary
-                * socket created here should be discarded.
-                * We mark the socket as discardable until
-                * we're committed to it below in TCPS_LISTEN.
-                */
-               dropsocket++;
-               nsp = (struct nspcb *)so->so_pcb;
-               nsp->nsp_laddr = si->si_dna;
-               cb = nstosppcb(nsp);
-               cb->s_mtu = ocb->s_mtu;         /* preserve sockopts */
-               cb->s_flags = ocb->s_flags;     /* preserve sockopts */
-               cb->s_flags2 = ocb->s_flags2;   /* preserve sockopts */
-               cb->s_state = TCPS_LISTEN;
-       }
-
-       /*
-        * Packet received on connection.
-        * reset idle time and keep-alive timer;
-        */
-       cb->s_idle = 0;
-       cb->s_timer[SPPT_KEEP] = SPPTV_KEEP;
-
-       switch (cb->s_state) {
-
-       case TCPS_LISTEN:{
-               struct mbuf *am;
-               struct sockaddr_ns *sns;
-               struct ns_addr laddr;
-
-               /*
-                * If somebody here was carying on a conversation
-                * and went away, and his pen pal thinks he can
-                * still talk, we get the misdirected packet.
-                */
-               if (spp_hardnosed && (si->si_did != 0 || si->si_seq != 0)) {
-                       spp_istat.gonawy++;
-                       goto dropwithreset;
-               }
-               am = m_get(MB_DONTWAIT, MT_SONAME);
-               if (am == NULL)
-                       goto drop;
-               am->m_len = sizeof (struct sockaddr_ns);
-               sns = mtod(am, struct sockaddr_ns *);
-               sns->sns_len = sizeof(*sns);
-               sns->sns_family = AF_NS;
-               sns->sns_addr = si->si_sna;
-               laddr = nsp->nsp_laddr;
-               if (ns_nullhost(laddr))
-                       nsp->nsp_laddr = si->si_dna;
-               if (ns_pcbconnect(nsp, mtod(am, struct sockaddr *))) {
-                       nsp->nsp_laddr = laddr;
-                       m_free(am);
-                       spp_istat.noconn++;
-                       goto drop;
-               }
-               m_free(am);
-               spp_template(cb);
-               dropsocket = 0;         /* committed to socket */
-               cb->s_did = si->si_sid;
-               cb->s_rack = si->si_ack;
-               cb->s_ralo = si->si_alo;
-#define THREEWAYSHAKE
-#ifdef THREEWAYSHAKE
-               cb->s_state = TCPS_SYN_RECEIVED;
-               cb->s_force = 1 + SPPT_KEEP;
-               sppstat.spps_accepts++;
-               cb->s_timer[SPPT_KEEP] = SPPTV_KEEP;
-               }
-               break;
-       /*
-        * This state means that we have heard a response
-        * to our acceptance of their connection
-        * It is probably logically unnecessary in this
-        * implementation.
-        */
-        case TCPS_SYN_RECEIVED: {
-               if (si->si_did!=cb->s_sid) {
-                       spp_istat.wrncon++;
-                       goto drop;
-               }
-#endif
-               nsp->nsp_fport =  si->si_sport;
-               cb->s_timer[SPPT_REXMT] = 0;
-               cb->s_timer[SPPT_KEEP] = SPPTV_KEEP;
-               soisconnected(so);
-               cb->s_state = TCPS_ESTABLISHED;
-               sppstat.spps_accepts++;
-               }
-               break;
-
-       /*
-        * This state means that we have gotten a response
-        * to our attempt to establish a connection.
-        * We fill in the data from the other side,
-        * telling us which port to respond to, instead of the well-
-        * known one we might have sent to in the first place.
-        * We also require that this is a response to our
-        * connection id.
-        */
-       case TCPS_SYN_SENT:
-               if (si->si_did!=cb->s_sid) {
-                       spp_istat.notme++;
-                       goto drop;
-               }
-               sppstat.spps_connects++;
-               cb->s_did = si->si_sid;
-               cb->s_rack = si->si_ack;
-               cb->s_ralo = si->si_alo;
-               cb->s_dport = nsp->nsp_fport =  si->si_sport;
-               cb->s_timer[SPPT_REXMT] = 0;
-               cb->s_flags |= SF_ACKNOW;
-               soisconnected(so);
-               cb->s_state = TCPS_ESTABLISHED;
-               /* Use roundtrip time of connection request for initial rtt */
-               if (cb->s_rtt) {
-                       cb->s_srtt = cb->s_rtt << 3;
-                       cb->s_rttvar = cb->s_rtt << 1;
-                       SPPT_RANGESET(cb->s_rxtcur,
-                           ((cb->s_srtt >> 2) + cb->s_rttvar) >> 1,
-                           SPPTV_MIN, SPPTV_REXMTMAX);
-                           cb->s_rtt = 0;
-               }
-       }
-       if (so->so_options & SO_DEBUG || traceallspps)
-               spp_trace(SA_INPUT, (u_char)ostate, cb, &spp_savesi, 0);
-
-       m->m_len -= sizeof (struct idp);
-       m->m_pkthdr.len -= sizeof (struct idp);
-       m->m_data += sizeof (struct idp);
-
-       if (spp_reass(cb, si, m)) {
-               m_freem(m);
-       }
-       if (cb->s_force || (cb->s_flags & (SF_ACKNOW|SF_WIN|SF_RXT)))
-               spp_output(cb, NULL);
-       cb->s_flags &= ~(SF_WIN|SF_RXT);
-       return;
-
-dropwithreset:
-       if (dropsocket)
-               soabort(so);
-       si->si_seq = ntohs(si->si_seq);
-       si->si_ack = ntohs(si->si_ack);
-       si->si_alo = ntohs(si->si_alo);
-       ns_error(m, NS_ERR_NOSOCK, 0);
-       if (cb->s_nspcb->nsp_socket->so_options & SO_DEBUG || traceallspps)
-               spp_trace(SA_DROP, (u_char)ostate, cb, &spp_savesi, 0);
-       return;
-
-drop:
-bad:
-       if (cb == 0 || cb->s_nspcb->nsp_socket->so_options & SO_DEBUG ||
-            traceallspps)
-               spp_trace(SA_DROP, (u_char)ostate, cb, &spp_savesi, 0);
-       m_freem(m);
-}
-
-int spprexmtthresh = 3;
-
-/*
- * This is structurally similar to the tcp reassembly routine
- * but its function is somewhat different:  It merely queues
- * packets up, and suppresses duplicates.
- */
-int
-spp_reass(struct sppcb *cb, struct spidp *si, struct mbuf *si_m)
-{
-       struct spidp_q *q;
-       struct spidp_q *nq;
-       struct mbuf *m;
-       struct socket *so = cb->s_nspcb->nsp_socket;
-       char packetp = cb->s_flags & SF_HI;
-       int incr;
-       char wakeup = 0;
-
-       if (si == NULL)
-               goto present;
-       /*
-        * Update our news from them.
-        */
-       if (si->si_cc & SP_SA)
-               cb->s_flags |= (spp_use_delack ? SF_DELACK : SF_ACKNOW);
-       if (SSEQ_GT(si->si_alo, cb->s_ralo))
-               cb->s_flags |= SF_WIN;
-       if (SSEQ_LEQ(si->si_ack, cb->s_rack)) {
-               if ((si->si_cc & SP_SP) && cb->s_rack != (cb->s_smax + 1)) {
-                       sppstat.spps_rcvdupack++;
-                       /*
-                        * If this is a completely duplicate ack
-                        * and other conditions hold, we assume
-                        * a packet has been dropped and retransmit
-                        * it exactly as in tcp_input().
-                        */
-                       if (si->si_ack != cb->s_rack ||
-                           si->si_alo != cb->s_ralo)
-                               cb->s_dupacks = 0;
-                       else if (++cb->s_dupacks == spprexmtthresh) {
-                               u_short onxt = cb->s_snxt;
-                               int cwnd = cb->s_cwnd;
-
-                               cb->s_snxt = si->si_ack;
-                               cb->s_cwnd = CUNIT;
-                               cb->s_force = 1 + SPPT_REXMT;
-                               spp_output(cb, NULL);
-                               cb->s_timer[SPPT_REXMT] = cb->s_rxtcur;
-                               cb->s_rtt = 0;
-                               if (cwnd >= 4 * CUNIT)
-                                       cb->s_cwnd = cwnd / 2;
-                               if (SSEQ_GT(onxt, cb->s_snxt))
-                                       cb->s_snxt = onxt;
-                               return (1);
-                       }
-               } else
-                       cb->s_dupacks = 0;
-               goto update_window;
-       }
-       cb->s_dupacks = 0;
-       /*
-        * If our correspondent acknowledges data we haven't sent
-        * TCP would drop the packet after acking.  We'll be a little
-        * more permissive
-        */
-       if (SSEQ_GT(si->si_ack, (cb->s_smax + 1))) {
-               sppstat.spps_rcvacktoomuch++;
-               si->si_ack = cb->s_smax + 1;
-       }
-       sppstat.spps_rcvackpack++;
-       /*
-        * If transmit timer is running and timed sequence
-        * number was acked, update smoothed round trip time.
-        * See discussion of algorithm in tcp_input.c
-        */
-       if (cb->s_rtt && SSEQ_GT(si->si_ack, cb->s_rtseq)) {
-               sppstat.spps_rttupdated++;
-               if (cb->s_srtt != 0) {
-                       short delta;
-                       delta = cb->s_rtt - (cb->s_srtt >> 3);
-                       if ((cb->s_srtt += delta) <= 0)
-                               cb->s_srtt = 1;
-                       if (delta < 0)
-                               delta = -delta;
-                       delta -= (cb->s_rttvar >> 2);
-                       if ((cb->s_rttvar += delta) <= 0)
-                               cb->s_rttvar = 1;
-               } else {
-                       /*
-                        * No rtt measurement yet
-                        */
-                       cb->s_srtt = cb->s_rtt << 3;
-                       cb->s_rttvar = cb->s_rtt << 1;
-               }
-               cb->s_rtt = 0;
-               cb->s_rxtshift = 0;
-               SPPT_RANGESET(cb->s_rxtcur,
-                       ((cb->s_srtt >> 2) + cb->s_rttvar) >> 1,
-                       SPPTV_MIN, SPPTV_REXMTMAX);
-       }
-       /*
-        * If all outstanding data is acked, stop retransmit
-        * timer and remember to restart (more output or persist).
-        * If there is more data to be acked, restart retransmit
-        * timer, using current (possibly backed-off) value;
-        */
-       if (si->si_ack == cb->s_smax + 1) {
-               cb->s_timer[SPPT_REXMT] = 0;
-               cb->s_flags |= SF_RXT;
-       } else if (cb->s_timer[SPPT_PERSIST] == 0)
-               cb->s_timer[SPPT_REXMT] = cb->s_rxtcur;
-       /*
-        * When new data is acked, open the congestion window.
-        * If the window gives us less than ssthresh packets
-        * in flight, open exponentially (maxseg at a time).
-        * Otherwise open linearly (maxseg^2 / cwnd at a time).
-        */
-       incr = CUNIT;
-       if (cb->s_cwnd > cb->s_ssthresh)
-               incr = max(incr * incr / cb->s_cwnd, 1);
-       cb->s_cwnd = min(cb->s_cwnd + incr, cb->s_cwmx);
-       /*
-        * Trim Acked data from output queue.
-        */
-       while ((m = so->so_snd.ssb_mb) != NULL) {
-               if (SSEQ_LT((mtod(m, struct spidp *))->si_seq, si->si_ack))
-                       sbdroprecord(&so->so_snd.sb);
-               else
-                       break;
-       }
-       sowwakeup(so);
-       cb->s_rack = si->si_ack;
-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)) {
-                       sppstat.spps_rcvwinupd++;
-                       sppstat.spps_rcvdupack--;
-               }
-               cb->s_ralo = si->si_alo;
-               cb->s_swl1 = si->si_seq;
-               cb->s_swl2 = si->si_ack;
-               cb->s_swnd = (1 + si->si_alo - si->si_ack);
-               if (cb->s_swnd > cb->s_smxw)
-                       cb->s_smxw = cb->s_swnd;
-               cb->s_flags |= SF_WIN;
-       }
-       /*
-        * If this packet number is higher than that which
-        * we have allocated refuse it, unless urgent
-        */
-       if (SSEQ_GT(si->si_seq, cb->s_alo)) {
-               if (si->si_cc & SP_SP) {
-                       sppstat.spps_rcvwinprobe++;
-                       return (1);
-               } else
-                       sppstat.spps_rcvpackafterwin++;
-               if (si->si_cc & SP_OB) {
-                       if (SSEQ_GT(si->si_seq, cb->s_alo + 60)) {
-                               ns_error(si_m, NS_ERR_FULLUP, 0);
-                               return (0);
-                       } /* else queue this packet; */
-               } else {
-                       /*register struct socket *so = cb->s_nspcb->nsp_socket;
-                       if (so->so_state && SS_NOFDREF) {
-                               ns_error(si_m, NS_ERR_NOSOCK, 0);
-                               spp_close(cb);
-                       } else
-                                      would crash system*/
-                       spp_istat.notyet++;
-                       ns_error(si_m, NS_ERR_FULLUP, 0);
-                       return (0);
-               }
-       }
-       /*
-        * If this is a system packet, we don't need to
-        * queue it up, and won't update acknowledge #
-        */
-       if (si->si_cc & SP_SP) {
-               return (1);
-       }
-       /*
-        * We have already seen this packet, so drop.
-        */
-       if (SSEQ_LT(si->si_seq, cb->s_ack)) {
-               spp_istat.bdreas++;
-               sppstat.spps_rcvduppack++;
-               if (si->si_seq == cb->s_ack - 1)
-                       spp_istat.lstdup++;
-               return (1);
-       }
-       /*
-        * Loop through all packets queued up to insert in
-        * appropriate sequence.
-        */
-       for (q = cb->s_q.si_next; q!=&cb->s_q; q = q->si_next) {
-               if (si->si_seq == SI(q)->si_seq) {
-                       sppstat.spps_rcvduppack++;
-                       return (1);
-               }
-               if (SSEQ_LT(si->si_seq, SI(q)->si_seq)) {
-                       sppstat.spps_rcvoopack++;
-                       break;
-               }
-       }
-       nq = kmalloc(sizeof(struct spidp_q), M_SPIDP_Q, M_INTNOWAIT);
-       if (nq == NULL) {
-               m_freem(si_m);
-               return(0);
-       }
-       insque(nq, q->si_prev);
-       nq->si_mbuf = si_m;
-       /*
-        * If this packet is urgent, inform process
-        */
-       if (si->si_cc & SP_OB) {
-               cb->s_iobc = ((char *)si)[1 + sizeof(*si)];
-               sohasoutofband(so);
-               cb->s_oobflags |= SF_IOOB;
-       }
-present:
-#define SPINC sizeof(struct sphdr)
-       /*
-        * Loop through all packets queued up to update acknowledge
-        * number, and present all acknowledged data to user;
-        * If in packet interface mode, show packet headers.
-        */
-       for (q = cb->s_q.si_next; q!=&cb->s_q; q = q->si_next) {
-                 if (SI(q)->si_seq == cb->s_ack) {
-                       cb->s_ack++;
-                       m = q->si_mbuf;
-                       if (SI(q)->si_cc & SP_OB) {
-                               cb->s_oobflags &= ~SF_IOOB;
-                               if (so->so_rcv.ssb_cc)
-                                       so->so_oobmark = so->so_rcv.ssb_cc;
-                               else
-                                       sosetstate(so, SS_RCVATMARK);
-                       }
-                       nq = q;
-                       q = q->si_prev;
-                       remque(nq);
-                       kfree(nq, M_SPIDP_Q);
-                       wakeup = 1;
-                       sppstat.spps_rcvpack++;
-#ifdef SF_NEWCALL
-                       if (cb->s_flags2 & SF_NEWCALL) {
-                               struct sphdr *sp = mtod(m, struct sphdr *);
-                               u_char dt = sp->sp_dt;
-                               spp_newchecks[4]++;
-                               if (dt != cb->s_rhdr.sp_dt) {
-                                       struct mbuf *mm =
-                                          m_getclr(MB_DONTWAIT, MT_CONTROL);
-                                       spp_newchecks[0]++;
-                                       if (mm != NULL) {
-                                               u_short *s =
-                                                       mtod(mm, u_short *);
-                                               cb->s_rhdr.sp_dt = dt;
-                                               mm->m_len = 5; /*XXX*/
-                                               s[0] = 5;
-                                               s[1] = 1;
-                                               *(u_char *)(&s[2]) = dt;
-                                               sbappend(&so->so_rcv.sb, mm);
-                                       }
-                               }
-                               if (sp->sp_cc & SP_OB) {
-                                       m_chtype(m, MT_OOBDATA);
-                                       spp_newchecks[1]++;
-                                       so->so_oobmark = 0;
-                                       soclrstate(so, SS_RCVATMARK);
-                               }
-                               if (packetp == 0) {
-                                       m->m_data += SPINC;
-                                       m->m_len -= SPINC;
-                                       m->m_pkthdr.len -= SPINC;
-                               }
-                               if ((sp->sp_cc & SP_EM) || packetp) {
-                                       sbappendrecord(&so->so_rcv.sb, m);
-                                       spp_newchecks[9]++;
-                               } else
-                                       sbappend(&so->so_rcv.sb, m);
-                       } else
-#endif
-                       if (packetp) {
-                               sbappendrecord(&so->so_rcv.sb, m);
-                       } else {
-                               cb->s_rhdr = *mtod(m, struct sphdr *);
-                               m->m_data += SPINC;
-                               m->m_len -= SPINC;
-                               m->m_pkthdr.len -= SPINC;
-                               sbappend(&so->so_rcv.sb, m);
-                       }
-                 } else
-                       break;
-       }
-       if (wakeup) sorwakeup(so);
-       return (0);
-}
-
-void
-spp_ctlinput(int cmd, caddr_t arg)
-{
-       struct ns_addr *na;
-       struct ns_errp *errp = 0;
-       struct nspcb *nsp;
-       struct sockaddr_ns *sns;
-       int type;
-
-       if (cmd < 0 || cmd > PRC_NCMDS)
-               return;
-       type = NS_ERR_UNREACH_HOST;
-
-       switch (cmd) {
-
-       case PRC_ROUTEDEAD:
-               return;
-
-       case PRC_IFDOWN:
-       case PRC_HOSTDEAD:
-       case PRC_HOSTUNREACH:
-               sns = (struct sockaddr_ns *)arg;
-               if (sns->sns_family != AF_NS)
-                       return;
-               na = &sns->sns_addr;
-               break;
-
-       default:
-               errp = (struct ns_errp *)arg;
-               na = &errp->ns_err_idp.idp_dna;
-               type = errp->ns_err_num;
-               type = ntohs((u_short)type);
-       }
-       switch (type) {
-
-       case NS_ERR_UNREACH_HOST:
-               ns_pcbnotify(na, (int)nsctlerrmap[cmd], spp_abort, (long) 0);
-               break;
-
-       case NS_ERR_TOO_BIG:
-       case NS_ERR_NOSOCK:
-               nsp = ns_pcblookup(na, errp->ns_err_idp.idp_sna.x_port,
-                       NS_WILDCARD);
-               if (nsp) {
-                       if(nsp->nsp_pcb)
-                               spp_drop((struct sppcb *)nsp->nsp_pcb,
-                                        (int)nsctlerrmap[cmd]);
-                       else
-                               idp_drop(nsp, (int)nsctlerrmap[cmd]);
-               }
-               break;
-
-       case NS_ERR_FULLUP:
-               ns_pcbnotify(na, 0, spp_quench, (long) 0);
-       }
-}
-/*
- * When a source quench is received, close congestion window
- * to one packet.  We will gradually open it again as we proceed.
- */
-void
-spp_quench(struct nspcb *nsp)
-{
-       struct sppcb *cb = nstosppcb(nsp);
-
-       if (cb)
-               cb->s_cwnd = CUNIT;
-}
-
-#ifdef notdef
-int
-spp_fixmtu(struct nspcb *nsp)
-{
-       struct sppcb *cb = (struct sppcb *)(nsp->nsp_pcb);
-       struct mbuf *m;
-       struct spidp *si;
-       struct ns_errp *ep;
-       struct signalsockbuf *ssb;
-       int badseq, len;
-       struct mbuf *firstbad, *m0;
-
-       if (cb) {
-               /*
-                * The notification that we have sent
-                * too much is bad news -- we will
-                * have to go through queued up so far
-                * splitting ones which are too big and
-                * reassigning sequence numbers and checksums.
-                * we should then retransmit all packets from
-                * one above the offending packet to the last one
-                * we had sent (or our allocation)
-                * then the offending one so that the any queued
-                * data at our destination will be discarded.
-                */
-                ep = (struct ns_errp *)nsp->nsp_notify_param;
-                ssb = &nsp->nsp_socket->so_snd;
-                cb->s_mtu = ep->ns_err_param;
-                badseq = ep->ns_err_idp.si_seq;
-                for (m = ssb->ssb_mb; m; m = m->m_nextpkt) {
-                       si = mtod(m, struct spidp *);
-                       if (si->si_seq == badseq)
-                               break;
-                }
-                if (m == 0) return;
-                firstbad = m;
-                /*for (;;) {*/
-                       /* calculate length */
-                       for (m0 = m, len = 0; m ; m = m->m_next)
-                               len += m->m_len;
-                       if (len > cb->s_mtu) {
-                       }
-               /* FINISH THIS
-               } */
-       }
-}
-#endif
-
-int
-spp_output(struct sppcb *cb, struct mbuf *m0)
-{
-       struct socket *so = cb->s_nspcb->nsp_socket;
-       struct mbuf *m = NULL;
-       struct spidp *si = NULL;
-       struct signalsockbuf *ssb = &so->so_snd;
-       int len = 0, win, rcv_win;
-       short span, off, recordp = 0;
-       u_short alo;
-       int error = 0, sendalot;
-#ifdef notdef
-       int idle;
-#endif
-       struct mbuf *mprev;
-
-       if (m0) {
-               int mtu = cb->s_mtu;
-               int datalen;
-               /*
-                * Make sure that packet isn't too big.
-                */
-               for (m = m0; m ; m = m->m_next) {
-                       mprev = m;
-                       len += m->m_len;
-                       if (m->m_flags & M_EOR)
-                               recordp = 1;
-               }
-               datalen = (cb->s_flags & SF_HO) ?
-                               len - sizeof (struct sphdr) : len;
-               if (datalen > mtu) {
-                       if (cb->s_flags & SF_PI) {
-                               m_freem(m0);
-                               return (EMSGSIZE);
-                       } else {
-                               int oldEM = cb->s_cc & SP_EM;
-
-                               cb->s_cc &= ~SP_EM;
-                               while (len > mtu) {
-                                       /*
-                                        * Here we are only being called
-                                        * from usrreq(), so it is OK to
-                                        * block.
-                                        */
-                                       m = m_copym(m0, 0, mtu, MB_WAIT);
-                                       if (cb->s_flags & SF_NEWCALL) {
-                                           struct mbuf *mm = m;
-                                           spp_newchecks[7]++;
-                                           while (mm) {
-                                               mm->m_flags &= ~M_EOR;
-                                               mm = mm->m_next;
-                                           }
-                                       }
-                                       error = spp_output(cb, m);
-                                       if (error) {
-                                               cb->s_cc |= oldEM;
-                                               m_freem(m0);
-                                               return(error);
-                                       }
-                                       m_adj(m0, mtu);
-                                       len -= mtu;
-                               }
-                               cb->s_cc |= oldEM;
-                       }
-               }
-               /*
-                * Force length even, by adding a "garbage byte" if
-                * necessary.
-                */
-               if (len & 1) {
-                       m = mprev;
-                       if (M_TRAILINGSPACE(m) >= 1)
-                               m->m_len++;
-                       else {
-                               struct mbuf *m1 = m_get(MB_DONTWAIT, MT_DATA);
-
-                               if (m1 == 0) {
-                                       m_freem(m0);
-                                       return (ENOBUFS);
-                               }
-                               m1->m_len = 1;
-                               *(mtod(m1, u_char *)) = 0;
-                               m->m_next = m1;
-                       }
-               }
-               m = m_gethdr(MB_DONTWAIT, MT_HEADER);
-               if (m == 0) {
-                       m_freem(m0);
-                       return (ENOBUFS);
-               }
-               /*
-                * Fill in mbuf with extended SP header
-                * and addresses and length put into network format.
-                */
-               MH_ALIGN(m, sizeof (struct spidp));
-               m->m_len = sizeof (struct spidp);
-               m->m_next = m0;
-               si = mtod(m, struct spidp *);
-               si->si_i = *cb->s_idp;
-               si->si_s = cb->s_shdr;
-               if ((cb->s_flags & SF_PI) && (cb->s_flags & SF_HO)) {
-                       struct sphdr *sh;
-                       if (m0->m_len < sizeof (*sh)) {
-                               if((m0 = m_pullup(m0, sizeof(*sh))) == NULL) {
-                                       m_free(m);
-                                       m_freem(m0);
-                                       return (EINVAL);
-                               }
-                               m->m_next = m0;
-                       }
-                       sh = mtod(m0, struct sphdr *);
-                       si->si_dt = sh->sp_dt;
-                       si->si_cc |= sh->sp_cc & SP_EM;
-                       m0->m_len -= sizeof (*sh);
-                       m0->m_data += sizeof (*sh);
-                       len -= sizeof (*sh);
-               }
-               len += sizeof(*si);
-               if ((cb->s_flags2 & SF_NEWCALL) && recordp) {
-                       si->si_cc  |= SP_EM;
-                       spp_newchecks[8]++;
-               }
-               if (cb->s_oobflags & SF_SOOB) {
-                       /*
-                        * Per jqj@cornell:
-                        * make sure OB packets convey exactly 1 byte.
-                        * If the packet is 1 byte or larger, we
-                        * have already guaranted there to be at least
-                        * one garbage byte for the checksum, and
-                        * extra bytes shouldn't hurt!
-                        */
-                       if (len > sizeof(*si)) {
-                               si->si_cc |= SP_OB;
-                               len = (1 + sizeof(*si));
-                       }
-               }
-               si->si_len = htons((u_short)len);
-               m->m_pkthdr.len = ((len - 1) | 1) + 1;
-               /*
-                * queue stuff up for output
-                */
-               sbappendrecord(&ssb->sb, m);
-               cb->s_seq++;
-       }
-#ifdef notdef
-       idle = (cb->s_smax == (cb->s_rack - 1));
-#endif
-again:
-       sendalot = 0;
-       off = cb->s_snxt - cb->s_rack;
-       win = min(cb->s_swnd, (cb->s_cwnd/CUNIT));
-
-       /*
-        * If in persist timeout with window of 0, send a probe.
-        * Otherwise, if window is small but nonzero
-        * and timer expired, send what we can and go into
-        * transmit state.
-        */
-       if (cb->s_force == 1 + SPPT_PERSIST) {
-               if (win != 0) {
-                       cb->s_timer[SPPT_PERSIST] = 0;
-                       cb->s_rxtshift = 0;
-               }
-       }
-       span = cb->s_seq - cb->s_rack;
-       len = min(span, win) - off;
-
-       if (len < 0) {
-               /*
-                * Window shrank after we went into it.
-                * If window shrank to 0, cancel pending
-                * restransmission and pull s_snxt back
-                * to (closed) window.  We will enter persist
-                * state below.  If the widndow didn't close completely,
-                * just wait for an ACK.
-                */
-               len = 0;
-               if (win == 0) {
-                       cb->s_timer[SPPT_REXMT] = 0;
-                       cb->s_snxt = cb->s_rack;
-               }
-       }
-       if (len > 1)
-               sendalot = 1;
-       rcv_win = ssb_space(&so->so_rcv);
-
-       /*
-        * Send if we owe peer an ACK.
-        */
-       if (cb->s_oobflags & SF_SOOB) {
-               /*
-                * must transmit this out of band packet
-                */
-               cb->s_oobflags &= ~ SF_SOOB;
-               sendalot = 1;
-               sppstat.spps_sndurg++;
-               goto found;
-       }
-       if (cb->s_flags & SF_ACKNOW)
-               goto send;
-       if (cb->s_state < TCPS_ESTABLISHED)
-               goto send;
-       /*
-        * Silly window can't happen in spp.
-        * Code from tcp deleted.
-        */
-       if (len)
-               goto send;
-       /*
-        * Compare available window to amount of window
-        * known to peer (as advertised window less
-        * next expected input.)  If the difference is at least two
-        * packets or at least 35% of the mximum possible window,
-        * then want to send a window update to peer.
-        */
-       if (rcv_win > 0) {
-               u_short delta =  1 + cb->s_alo - cb->s_ack;
-               int adv = rcv_win - (delta * cb->s_mtu);
-
-               if ((so->so_rcv.ssb_cc == 0 && adv >= (2 * cb->s_mtu)) ||
-                   (100 * adv / so->so_rcv.ssb_hiwat >= 35)) {
-                       sppstat.spps_sndwinup++;
-                       cb->s_flags |= SF_ACKNOW;
-                       goto send;
-               }
-
-       }
-       /*
-        * Many comments from tcp_output.c are appropriate here
-        * including . . .
-        * If send window is too small, there is data to transmit, and no
-        * retransmit or persist is pending, then go to persist state.
-        * If nothing happens soon, send when timer expires:
-        * if window is nonzero, transmit what we can,
-        * otherwise send a probe.
-        */
-       if (so->so_snd.ssb_cc && cb->s_timer[SPPT_REXMT] == 0 &&
-               cb->s_timer[SPPT_PERSIST] == 0) {
-                       cb->s_rxtshift = 0;
-                       spp_setpersist(cb);
-       }
-       /*
-        * No reason to send a packet, just return.
-        */
-       cb->s_outx = 1;
-       return (0);
-
-send:
-       /*
-        * Find requested packet.
-        */
-       si = NULL;
-       if (len > 0) {
-               cb->s_want = cb->s_snxt;
-               for (m = ssb->ssb_mb; m; m = m->m_nextpkt) {
-                       si = mtod(m, struct spidp *);
-                       if (SSEQ_LEQ(cb->s_snxt, si->si_seq))
-                               break;
-               }
-       found:
-               if (si) {
-                       if (si->si_seq == cb->s_snxt)
-                                       cb->s_snxt++;
-                               else
-                                       sppstat.spps_sndvoid++, si = 0;
-               }
-       }
-       /*
-        * update window
-        */
-       if (rcv_win < 0)
-               rcv_win = 0;
-       alo = cb->s_ack - 1 + (rcv_win / ((short)cb->s_mtu));
-       if (SSEQ_LT(alo, cb->s_alo))
-               alo = cb->s_alo;
-
-       if (si) {
-               /*
-                * must make a copy of this packet for
-                * idp_output to monkey with
-                */
-               m = m_copy(m, 0, (int)M_COPYALL);
-               if (m == NULL) {
-                       return (ENOBUFS);
-               }
-               si = mtod(m, struct spidp *);
-               if (SSEQ_LT(si->si_seq, cb->s_smax))
-                       sppstat.spps_sndrexmitpack++;
-               else
-                       sppstat.spps_sndpack++;
-       } else if (cb->s_force || cb->s_flags & SF_ACKNOW) {
-               /*
-                * Must send an acknowledgement or a probe
-                */
-               if (cb->s_force)
-                       sppstat.spps_sndprobe++;
-               if (cb->s_flags & SF_ACKNOW)
-                       sppstat.spps_sndacks++;
-               m = m_gethdr(MB_DONTWAIT, MT_HEADER);
-               if (m == 0)
-                       return (ENOBUFS);
-               /*
-                * Fill in mbuf with extended SP header
-                * and addresses and length put into network format.
-                */
-               MH_ALIGN(m, sizeof (struct spidp));
-               m->m_len = sizeof (*si);
-               m->m_pkthdr.len = sizeof (*si);
-               si = mtod(m, struct spidp *);
-               si->si_i = *cb->s_idp;
-               si->si_s = cb->s_shdr;
-               si->si_seq = cb->s_smax + 1;
-               si->si_len = htons(sizeof (*si));
-               si->si_cc |= SP_SP;
-       } else {
-               cb->s_outx = 3;
-               if (so->so_options & SO_DEBUG || traceallspps)
-                       spp_trace(SA_OUTPUT, cb->s_state, cb, si, 0);
-               return (0);
-       }
-       /*
-        * Stuff checksum and output datagram.
-        */
-       if ((si->si_cc & SP_SP) == 0) {
-               if (cb->s_force != (1 + SPPT_PERSIST) ||
-                   cb->s_timer[SPPT_PERSIST] == 0) {
-                       /*
-                        * If this is a new packet and we are not currently
-                        * timing anything, time this one.
-                        */
-                       if (SSEQ_LT(cb->s_smax, si->si_seq)) {
-                               cb->s_smax = si->si_seq;
-                               if (cb->s_rtt == 0) {
-                                       sppstat.spps_segstimed++;
-                                       cb->s_rtseq = si->si_seq;
-                                       cb->s_rtt = 1;
-                               }
-                       }
-                       /*
-                        * Set rexmt timer if not currently set,
-                        * Initial value for retransmit timer is smoothed
-                        * round-trip time + 2 * round-trip time variance.
-                        * Initialize shift counter which is used for backoff
-                        * of retransmit time.
-                        */
-                       if (cb->s_timer[SPPT_REXMT] == 0 &&
-                           cb->s_snxt != cb->s_rack) {
-                               cb->s_timer[SPPT_REXMT] = cb->s_rxtcur;
-                               if (cb->s_timer[SPPT_PERSIST]) {
-                                       cb->s_timer[SPPT_PERSIST] = 0;
-                                       cb->s_rxtshift = 0;
-                               }
-                       }
-               } else if (SSEQ_LT(cb->s_smax, si->si_seq)) {
-                       cb->s_smax = si->si_seq;
-               }
-       } else if (cb->s_state < TCPS_ESTABLISHED) {
-               if (cb->s_rtt == 0)
-                       cb->s_rtt = 1; /* Time initial handshake */
-               if (cb->s_timer[SPPT_REXMT] == 0)
-                       cb->s_timer[SPPT_REXMT] = cb->s_rxtcur;
-       }
-       {
-               /*
-                * Do not request acks when we ack their data packets or
-                * when we do a gratuitous window update.
-                */
-               if (((si->si_cc & SP_SP) == 0) || cb->s_force)
-                               si->si_cc |= SP_SA;
-               si->si_seq = htons(si->si_seq);
-               si->si_alo = htons(alo);
-               si->si_ack = htons(cb->s_ack);
-
-               if (idpcksum) {
-                       si->si_sum = 0;
-                       len = ntohs(si->si_len);
-                       if (len & 1)
-                               len++;
-                       si->si_sum = ns_cksum(m, len);
-               } else
-                       si->si_sum = 0xffff;
-
-               cb->s_outx = 4;
-               if (so->so_options & SO_DEBUG || traceallspps)
-                       spp_trace(SA_OUTPUT, cb->s_state, cb, si, 0);
-
-               if (so->so_options & SO_DONTROUTE)
-                       error = ns_output(m, NULL, NS_ROUTETOIF);
-               else
-                       error = ns_output(m, &cb->s_nspcb->nsp_route, 0);
-       }
-       if (error) {
-               return (error);
-       }
-       sppstat.spps_sndtotal++;
-       /*
-        * Data sent (as far as we can tell).
-        * If this advertises a larger window than any other segment,
-        * then remember the size of the advertized window.
-        * Any pending ACK has now been sent.
-        */
-       cb->s_force = 0;
-       cb->s_flags &= ~(SF_ACKNOW|SF_DELACK);
-       if (SSEQ_GT(alo, cb->s_alo))
-               cb->s_alo = alo;
-       if (sendalot)
-               goto again;
-       cb->s_outx = 5;
-       return (0);
-}
-
-int spp_do_persist_panics = 0;
-
-void
-spp_setpersist(struct sppcb *cb)
-{
-       int t = ((cb->s_srtt >> 2) + cb->s_rttvar) >> 1;
-
-       if (cb->s_timer[SPPT_REXMT] && spp_do_persist_panics)
-               panic("spp_output REXMT");
-       /*
-        * Start/restart persistance timer.
-        */
-       SPPT_RANGESET(cb->s_timer[SPPT_PERSIST],
-           t*spp_backoff[cb->s_rxtshift],
-           SPPTV_PERSMIN, SPPTV_PERSMAX);
-       if (cb->s_rxtshift < SPP_MAXRXTSHIFT)
-               cb->s_rxtshift++;
-}
-/*ARGSUSED*/
-int
-spp_ctloutput(int req, struct socket *so, int level,
-               int name, struct mbuf **value)
-{
-       struct mbuf *m;
-       struct nspcb *nsp = sotonspcb(so);
-       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;
-               goto release;
-       } else
-               cb = nstosppcb(nsp);
-
-       switch (req) {
-
-       case PRCO_GETOPT:
-               if (value == NULL)
-                       return (EINVAL);
-               m = m_get(MB_DONTWAIT, MT_DATA);
-               if (m == NULL)
-                       return (ENOBUFS);
-               switch (name) {
-
-               case SO_HEADERS_ON_INPUT:
-                       mask = SF_HI;
-                       goto get_flags;
-
-               case SO_HEADERS_ON_OUTPUT:
-                       mask = SF_HO;
-               get_flags:
-                       m->m_len = sizeof(short);
-                       *mtod(m, short *) = cb->s_flags & mask;
-                       break;
-
-               case SO_MTU:
-                       m->m_len = sizeof(u_short);
-                       *mtod(m, short *) = cb->s_mtu;
-                       break;
-
-               case SO_LAST_HEADER:
-                       m->m_len = sizeof(struct sphdr);
-                       *mtod(m, struct sphdr *) = cb->s_rhdr;
-                       break;
-
-               case SO_DEFAULT_HEADERS:
-                       m->m_len = sizeof(struct spidp);
-                       *mtod(m, struct sphdr *) = cb->s_shdr;
-                       break;
-
-               default:
-                       error = EINVAL;
-               }
-               *value = m;
-               break;
-
-       case PRCO_SETOPT:
-               if (value == 0 || *value == 0) {
-                       error = EINVAL;
-                       break;
-               }
-               switch (name) {
-                       int *ok;
-
-               case SO_HEADERS_ON_INPUT:
-                       mask = SF_HI;
-                       goto set_head;
-
-               case SO_HEADERS_ON_OUTPUT:
-                       mask = SF_HO;
-               set_head:
-                       if (cb->s_flags & SF_PI) {
-                               ok = mtod(*value, int *);
-                               if (*ok)
-                                       cb->s_flags |= mask;
-                               else
-                                       cb->s_flags &= ~mask;
-                       } else error = EINVAL;
-                       break;
-
-               case SO_MTU:
-                       cb->s_mtu = *(mtod(*value, u_short *));
-                       break;
-
-#ifdef SF_NEWCALL
-               case SO_NEWCALL:
-                       ok = mtod(*value, int *);
-                       if (*ok) {
-                               cb->s_flags2 |= SF_NEWCALL;
-                               spp_newchecks[5]++;
-                       } else {
-                               cb->s_flags2 &= ~SF_NEWCALL;
-                               spp_newchecks[6]++;
-                       }
-                       break;
-#endif
-
-               case SO_DEFAULT_HEADERS:
-                       {
-                               struct sphdr *sp
-                                               = mtod(*value, struct sphdr *);
-                               cb->s_dt = sp->sp_dt;
-                               cb->s_cc = sp->sp_cc & SP_EM;
-                       }
-                       break;
-
-               default:
-                       error = EINVAL;
-               }
-               m_freem(*value);
-               break;
-       }
-       release:
-               return (error);
-}
-
-/*
- *  SPP_USRREQ PROCEDURES
- */
-
-/*
- * NOTE: (so) is referenced from soabort*() and netmsg_pru_abort()
- *      will sofree() it when we return.
- */
-static int
-spp_usr_abort(struct socket *so)
-{
-       struct nspcb *nsp = sotonspcb(so);
-       struct sppcb *cb;
-       int error;
-
-       if (nsp) {
-               cb = nstosppcb(nsp);
-               spp_drop(cb, ECONNABORTED);
-               error = 0;
-       } else {
-               error = EINVAL;
-       }
-
-       return(error);
-}
-
-static int
-spp_accept(struct socket *so, struct sockaddr **nam)
-{
-       struct nspcb *nsp = sotonspcb(so);
-       struct sppcb *cb;
-       struct sockaddr_ns sns;
-       int error;
-
-       if (nsp) {
-               cb = nstosppcb(nsp);
-               bzero(&sns, sizeof(sns));
-               sns.sns_family = AF_NS;
-               sns.sns_addr = nsp->nsp_faddr;
-               *nam = dup_sockaddr((struct sockaddr *)&sns);
-               error = 0;
-       } else {
-               error = EINVAL;
-       }
-       return(error);
-}
-
-static int
-spp_attach(struct socket *so, int proto, struct pru_attach_info *ai)
-{
-       struct nspcb *nsp = sotonspcb(so);
-       struct sppcb *cb;
-       struct signalsockbuf *ssb;
-       int error;
-
-       if (nsp != NULL)
-               return(EISCONN);
-       if ((error = ns_pcballoc(so, &nspcb)) != 0)
-               return(error);
-       if (so->so_snd.ssb_hiwat == 0 || so->so_rcv.ssb_hiwat == 0) {
-               if ((error = soreserve(so, 3072, 3072, ai->sb_rlimit)) != 0)
-                       return(error);
-       }
-       nsp = sotonspcb(so);
-
-       ssb = &so->so_snd;
-       cb = kmalloc(sizeof(struct sppcb), M_SPPCB, M_WAITOK|M_ZERO);
-       cb->s_idp = kmalloc(sizeof(struct idp), M_IDP, M_WAITOK|M_ZERO);
-       cb->s_state = TCPS_LISTEN;
-       cb->s_smax = -1;
-       cb->s_swl1 = -1;
-       cb->s_q.si_next = cb->s_q.si_prev = &cb->s_q;
-       cb->s_nspcb = nsp;
-       cb->s_mtu = 576 - sizeof (struct spidp);
-       cb->s_cwnd = ssb_space(ssb) * CUNIT / cb->s_mtu;
-       cb->s_ssthresh = cb->s_cwnd;
-       cb->s_cwmx = ssb_space(ssb) * CUNIT / (2 * sizeof (struct spidp));
-
-       /*
-        * Above is recomputed when connecting to account
-        * for changed buffering or mtu's
-        */
-       cb->s_rtt = SPPTV_SRTTBASE;
-       cb->s_rttvar = SPPTV_SRTTDFLT << 2;
-       SPPT_RANGESET(cb->s_rxtcur, 
-                   ((SPPTV_SRTTBASE >> 2) + (SPPTV_SRTTDFLT << 2)) >> 1,
-                   SPPTV_MIN, SPPTV_REXMTMAX);
-       nsp->nsp_pcb = (caddr_t)cb;
-       return(0);
-}
-
-static int
-spp_attach_sp(struct socket *so, int proto, struct pru_attach_info *ai)
-{
-       int error;
-       struct nspcb *nsp;
-
-       if ((error = spp_attach(so, proto, ai)) == 0) {
-               nsp = sotonspcb(so);
-               ((struct sppcb *)nsp->nsp_pcb)->s_flags |=
-                                       (SF_HI | SF_HO | SF_PI);
-       }
-       return (error);
-}
-
-static int
-spp_bind(struct socket *so, struct sockaddr *nam, struct thread *td)
-{
-       struct nspcb *nsp = sotonspcb(so);
-       int error;
-
-       if (nsp)
-               error = ns_pcbbind(nsp, nam);
-       else
-               error = EINVAL;
-       return(error);
-}
-
-/*
- * Initiate connection to peer.
- * Enter SYN_SENT state, and mark socket as connecting.
- * Start keep-alive timer, setup prototype header,
- * Send initial system packet requesting connection.
- */
-static int
-spp_connect(struct socket *so, struct sockaddr *nam, struct thread *td)
-{
-       struct nspcb *nsp = sotonspcb(so);
-       struct sppcb *cb;
-       int error;
-
-       if (nsp) {
-               cb = nstosppcb(nsp);
-                if (nsp->nsp_lport == 0) {
-                       if ((error = ns_pcbbind(nsp, NULL)) != 0)
-                               return(error);
-                }
-               if ((error = ns_pcbconnect(nsp, nam)) != 0)
-                       return(error);
-               soisconnecting(so);
-               sppstat.spps_connattempt++;
-               cb->s_state = TCPS_SYN_SENT;
-               cb->s_did = 0;
-               spp_template(cb);
-               cb->s_timer[SPPT_KEEP] = SPPTV_KEEP;
-               cb->s_force = 1 + SPPTV_KEEP;
-               /*
-                * Other party is required to respond to
-                * the port I send from, but he is not
-                * required to answer from where I am sending to,
-                * so allow wildcarding.
-                * original port I am sending to is still saved in
-                * cb->s_dport.
-                */
-               nsp->nsp_fport = 0;
-               error = spp_output(cb, NULL);
-       } else {
-               error = EINVAL;
-       }
-       return(error);
-}
-
-static int
-spp_detach(struct socket *so)
-{
-       struct nspcb *nsp = sotonspcb(so);
-       struct sppcb *cb;
-
-       if (nsp == NULL)
-               return(ENOTCONN);
-       cb = nstosppcb(nsp);
-       if (cb->s_state > TCPS_LISTEN)
-               spp_disconnect(cb);
-       else
-               spp_close(cb);
-       return(0);
-}
-
-/*
- * We may decide later to implement connection closing
- * handshaking at the spp level optionally.
- * here is the hook to do it:
- */
-static int
-spp_usr_disconnect(struct socket *so)
-{
-       struct nspcb *nsp = sotonspcb(so);
-       struct sppcb *cb;
-       int error;
-
-       if (nsp) {
-               cb = nstosppcb(nsp);
-               spp_disconnect(cb);
-               error = 0;
-       } else {
-               error = EINVAL;
-       }
-       return(error);
-}
-
-static int
-spp_listen(struct socket *so, struct thread *td)
-{
-       struct nspcb *nsp = sotonspcb(so);
-       struct sppcb *cb;
-       int error;
-
-       if (nsp) {
-               cb = nstosppcb(nsp);
-               error = 0;
-               if (nsp->nsp_lport == 0)
-                       error = ns_pcbbind(nsp, NULL);
-               if (error == 0)
-                       cb->s_state = TCPS_LISTEN;
-       } else {
-               error = EINVAL;
-       }
-       return(error);
-}
-
-static int
-spp_peeraddr(struct socket *so, struct sockaddr **nam)
-{
-       struct nspcb *nsp = sotonspcb(so);
-       int error;
-
-       if (nsp) {
-               ns_setpeeraddr(nsp, nam);
-               error = 0;
-       } else {
-               error = EINVAL;
-       }       
-       return(error);
-}
-
-static int
-spp_rcvd(struct socket *so, int flags)
-{
-       struct nspcb *nsp = sotonspcb(so);
-       struct sppcb *cb;
-       int error;
-
-       if (nsp) {
-               cb = nstosppcb(nsp);
-               cb->s_flags |= SF_RVD;
-               spp_output(cb, NULL);
-               cb->s_flags &= ~SF_RVD;
-               error = 0;
-       } else {
-               error = EINVAL;
-       }
-       return(error);
-}
-
-static int
-spp_rcvoob(struct socket *so, struct mbuf *m, int flags)
-{
-       struct nspcb *nsp = sotonspcb(so);
-       struct sppcb *cb;
-       int error;
-
-       if (nsp) {
-               cb = nstosppcb(nsp);
-               if ((cb->s_oobflags & SF_IOOB) || so->so_oobmark ||
-                   (so->so_state & SS_RCVATMARK)) {
-                       m->m_len = 1;
-                       *mtod(m, caddr_t) = cb->s_iobc;
-                       error = 0;
-               } else {
-                       error = EINVAL;
-               }
-       } else {
-               error = EINVAL;
-       }
-       return(error);
-}
-
-static int
-spp_send(struct socket *so, int flags, struct mbuf *m,
-       struct sockaddr *addr, struct mbuf *control,
-       struct thread *td)
-{
-       struct nspcb *nsp = sotonspcb(so);
-       struct sppcb *cb;
-       int error;
-
-       if (nsp) {
-               cb = nstosppcb(nsp);
-               error = 0;
-               if (flags & PRUS_OOB) {
-                       if (ssb_space(&so->so_snd) < -512) {
-                               error = ENOBUFS;
-                       } else {
-                               cb->s_oobflags |= SF_SOOB;
-                       }
-               }
-               if (error == 0) {
-                       if (control) {
-                               u_short *p = mtod(control, u_short *);
-                               spp_newchecks[2]++;
-                               /* XXXX, for testing */
-                               if ((p[0] == 5) && p[1] == 1) { 
-                                       cb->s_shdr.sp_dt = *(u_char *)(&p[2]);
-                                       spp_newchecks[3]++;
-                               }
-                               m_freem(control);
-                               control = NULL;
-                       }
-                       error = spp_output(cb, m);
-                       m = NULL;
-               }
-       } else {
-               error = EINVAL;
-       }
-       if (m)
-               m_freem(m);
-       if (control)
-               m_freem(control);
-       return(error);
-}
-
-static int
-spp_shutdown(struct socket *so)
-{
-       struct nspcb *nsp = sotonspcb(so);
-       struct sppcb *cb;
-       int error;
-
-       if (nsp) {
-               cb = nstosppcb(nsp);
-               socantsendmore(so);
-               if ((cb = spp_usrclosed(cb)) != NULL)
-                       error = spp_output(cb, NULL);
-               else
-                       error = 0;
-       } else {
-               error = EINVAL;
-       }
-       return(error);
-}
-
-static int
-spp_sockaddr(struct socket *so, struct sockaddr **nam)
-{
-       struct nspcb *nsp = sotonspcb(so);
-       int error;
-
-       if (nsp) {
-               ns_setsockaddr(nsp, nam);
-               error = 0;
-       } else {
-               error = EINVAL;
-       }       
-       return(error);
-}
-
-struct pr_usrreqs spp_usrreqs = {
-       .pru_abort = spp_usr_abort,
-       .pru_accept = spp_accept,
-       .pru_attach = spp_attach,
-       .pru_bind = spp_bind,
-       .pru_connect = spp_connect,
-       .pru_connect2 = pru_connect2_notsupp,
-       .pru_control = ns_control,
-       .pru_detach = spp_detach,
-       .pru_disconnect = spp_usr_disconnect,
-       .pru_listen = spp_listen,
-       .pru_peeraddr = spp_peeraddr,
-       .pru_rcvd = spp_rcvd,
-       .pru_rcvoob = spp_rcvoob,
-       .pru_send = spp_send,
-       .pru_sense = pru_sense_null,
-       .pru_shutdown = spp_shutdown,
-       .pru_sockaddr = spp_sockaddr,
-       .pru_sosend = sosend,
-       .pru_soreceive = soreceive
-};
-
-struct pr_usrreqs spp_usrreqs_sp = {
-       .pru_abort = spp_usr_abort,
-       .pru_accept = spp_accept,
-       .pru_attach = spp_attach_sp,
-       .pru_bind = spp_bind,
-       .pru_connect = spp_connect,
-       .pru_connect2 = pru_connect2_notsupp,
-       .pru_control = ns_control,
-       .pru_detach = spp_detach,
-       .pru_disconnect = spp_usr_disconnect,
-       .pru_listen = spp_listen,
-       .pru_peeraddr = spp_peeraddr,
-       .pru_rcvd = spp_rcvd,
-       .pru_rcvoob = spp_rcvoob,
-       .pru_send = spp_send,
-       .pru_sense = pru_sense_null,
-       .pru_shutdown = spp_shutdown,
-       .pru_sockaddr = spp_sockaddr,
-       .pru_sosend = sosend,
-       .pru_soreceive = soreceive
-};
-
-/*
- * Create template to be used to send spp packets on a connection.
- * Called after host entry created, fills
- * in a skeletal spp header (choosing connection id),
- * minimizing the amount of work necessary when the connection is used.
- */
-void
-spp_template(struct sppcb *cb)
-{
-       struct nspcb *nsp = cb->s_nspcb;
-       struct idp *idp = cb->s_idp;
-       struct signalsockbuf *ssb = &(nsp->nsp_socket->so_snd);
-
-       idp->idp_pt = NSPROTO_SPP;
-       idp->idp_sna = nsp->nsp_laddr;
-       idp->idp_dna = nsp->nsp_faddr;
-       cb->s_sid = htons(spp_iss);
-       spp_iss += SPP_ISSINCR/2;
-       cb->s_alo = 1;
-       cb->s_cwnd = (ssb_space(ssb) * CUNIT) / cb->s_mtu;
-       cb->s_ssthresh = cb->s_cwnd; /* Try to expand fast to full complement
-                                       of large packets */
-       cb->s_cwmx = (ssb_space(ssb) * CUNIT) / (2 * sizeof(struct spidp));
-       cb->s_cwmx = max(cb->s_cwmx, cb->s_cwnd);
-               /* But allow for lots of little packets as well */
-}
-
-/*
- * Close a SPIP control block:
- *     discard spp control block itself
- *     discard ns protocol control block
- *     wake up any sleepers
- */
-struct sppcb *
-spp_close(struct sppcb *cb)
-{
-       struct spidp_q *q;
-       struct spidp_q *oq;
-       struct nspcb *nsp = cb->s_nspcb;
-       struct socket *so = nsp->nsp_socket;
-       struct mbuf *m;
-
-       q = cb->s_q.si_next;
-       while (q != &(cb->s_q)) {
-               oq = q;
-               q = q->si_next;
-               m = oq->si_mbuf;
-               remque(oq);
-               m_freem(m);
-               kfree(oq, M_SPIDP_Q);
-       }
-       kfree(cb->s_idp, M_IDP);
-       kfree(cb, M_SPPCB);
-       nsp->nsp_pcb = NULL;
-       soisdisconnected(so);
-       ns_pcbdetach(nsp);
-       sppstat.spps_closed++;
-       return (NULL);
-}
-/*
- *     Someday we may do level 3 handshaking
- *     to close a connection or send a xerox style error.
- *     For now, just close.
- */
-struct sppcb *
-spp_usrclosed(struct sppcb *cb)
-{
-       return (spp_close(cb));
-}
-
-struct sppcb *
-spp_disconnect(struct sppcb *cb)
-{
-       return (spp_close(cb));
-}
-
-/*
- * Drop connection, reporting
- * the specified error.
- */
-struct sppcb *
-spp_drop(struct sppcb *cb, int error)
-{
-       struct socket *so = cb->s_nspcb->nsp_socket;
-
-       /*
-        * someday, in the xerox world
-        * we will generate error protocol packets
-        * announcing that the socket has gone away.
-        */
-       if (TCPS_HAVERCVDSYN(cb->s_state)) {
-               sppstat.spps_drops++;
-               cb->s_state = TCPS_CLOSED;
-               /*tcp_output(cb);*/
-       } else
-               sppstat.spps_conndrops++;
-       so->so_error = error;
-       return (spp_close(cb));
-}
-
-void
-spp_abort(struct nspcb *nsp)
-{
-       spp_close((struct sppcb *)nsp->nsp_pcb);
-}
-
-/*
- * Fast timeout routine for processing delayed acks
- */
-void
-spp_fasttimo(void)
-{
-       struct nspcb *nsp;
-       struct sppcb *cb;
-
-       crit_enter();
-       nsp = nspcb.nsp_next;
-       if (nsp) {
-           for (; nsp != &nspcb; nsp = nsp->nsp_next) {
-               if ((cb = (struct sppcb *)nsp->nsp_pcb) &&
-                   (cb->s_flags & SF_DELACK)) {
-                       cb->s_flags &= ~SF_DELACK;
-                       cb->s_flags |= SF_ACKNOW;
-                       sppstat.spps_delack++;
-                       spp_output(cb, NULL);
-               }
-           }
-       }
-       crit_exit();
-}
-
-/*
- * spp protocol timeout routine called every 500 ms.
- * Updates the timers in all active pcb's and
- * causes finite state machine actions if timers expire.
- */
-void
-spp_slowtimo(void)
-{
-       struct nspcb *ip, *ipnxt;
-       struct sppcb *cb;
-       int i;
-
-       /*
-        * Search through tcb's and update active timers.
-        */
-       crit_enter();
-       ip = nspcb.nsp_next;
-       if (ip == 0) {
-               crit_exit();
-               return;
-       }
-       while (ip != &nspcb) {
-               cb = nstosppcb(ip);
-               ipnxt = ip->nsp_next;
-               if (cb == 0)
-                       goto tpgone;
-               for (i = 0; i < SPPT_NTIMERS; i++) {
-                       if (cb->s_timer[i] && --cb->s_timer[i] == 0) {
-                               spp_timers(cb, i);
-                               if (ipnxt->nsp_prev != ip)
-                                       goto tpgone;
-                       }
-               }
-               cb->s_idle++;
-               if (cb->s_rtt)
-                       cb->s_rtt++;
-tpgone:
-               ip = ipnxt;
-       }
-       spp_iss += SPP_ISSINCR/PR_SLOWHZ;               /* increment iss */
-       crit_exit();
-}
-/*
- * SPP timer processing.
- */
-struct sppcb *
-spp_timers(struct sppcb *cb, int timer)
-{
-       long rexmt;
-       int win;
-
-       cb->s_force = 1 + timer;
-       switch (timer) {
-
-       /*
-        * 2 MSL timeout in shutdown went off.  TCP deletes connection
-        * control block.
-        */
-       case SPPT_2MSL:
-               kprintf("spp: SPPT_2MSL went off for no reason\n");
-               cb->s_timer[timer] = 0;
-               break;
-
-       /*
-        * Retransmission timer went off.  Message has not
-        * been acked within retransmit interval.  Back off
-        * to a longer retransmit interval and retransmit one packet.
-        */
-       case SPPT_REXMT:
-               if (++cb->s_rxtshift > SPP_MAXRXTSHIFT) {
-                       cb->s_rxtshift = SPP_MAXRXTSHIFT;
-                       sppstat.spps_timeoutdrop++;
-                       cb = spp_drop(cb, ETIMEDOUT);
-                       break;
-               }
-               sppstat.spps_rexmttimeo++;
-               rexmt = ((cb->s_srtt >> 2) + cb->s_rttvar) >> 1;
-               rexmt *= spp_backoff[cb->s_rxtshift];
-               SPPT_RANGESET(cb->s_rxtcur, rexmt, SPPTV_MIN, SPPTV_REXMTMAX);
-               cb->s_timer[SPPT_REXMT] = cb->s_rxtcur;
-               /*
-                * If we have backed off fairly far, our srtt
-                * estimate is probably bogus.  Clobber it
-                * so we'll take the next rtt measurement as our srtt;
-                * move the current srtt into rttvar to keep the current
-                * retransmit times until then.
-                */
-               if (cb->s_rxtshift > SPP_MAXRXTSHIFT / 4 ) {
-                       cb->s_rttvar += (cb->s_srtt >> 2);
-                       cb->s_srtt = 0;
-               }
-               cb->s_snxt = cb->s_rack;
-               /*
-                * If timing a packet, stop the timer.
-                */
-               cb->s_rtt = 0;
-               /*
-                * See very long discussion in tcp_timer.c about congestion
-                * window and sstrhesh
-                */
-               win = min(cb->s_swnd, (cb->s_cwnd/CUNIT)) / 2;
-               if (win < 2)
-                       win = 2;
-               cb->s_cwnd = CUNIT;
-               cb->s_ssthresh = win * CUNIT;
-               spp_output(cb, NULL);
-               break;
-
-       /*
-        * Persistance timer into zero window.
-        * Force a probe to be sent.
-        */
-       case SPPT_PERSIST:
-               sppstat.spps_persisttimeo++;
-               spp_setpersist(cb);
-               spp_output(cb, NULL);
-               break;
-
-       /*
-        * Keep-alive timer went off; send something
-        * or drop connection if idle for too long.
-        */
-       case SPPT_KEEP:
-               sppstat.spps_keeptimeo++;
-               if (cb->s_state < TCPS_ESTABLISHED)
-                       goto dropit;
-               if (cb->s_nspcb->nsp_socket->so_options & SO_KEEPALIVE) {
-                       if (cb->s_idle >= SPPTV_MAXIDLE)
-                               goto dropit;
-                       sppstat.spps_keepprobe++;
-                       spp_output(cb, NULL);
-               } else
-                       cb->s_idle = 0;
-               cb->s_timer[SPPT_KEEP] = SPPTV_KEEP;
-               break;
-       dropit:
-               sppstat.spps_keepdrops++;
-               cb = spp_drop(cb, ETIMEDOUT);
-               break;
-       }
-       return (cb);
-}
-#ifndef lint
-int SppcbSize = sizeof (struct sppcb);
-int NspcbSize = sizeof (struct nspcb);
-#endif /* lint */
diff --git a/sys/netproto/ns/spp_var.h b/sys/netproto/ns/spp_var.h
deleted file mode 100644 (file)
index 1ee5874..0000000
+++ /dev/null
@@ -1,241 +0,0 @@
-/*
- * Copyright (c) 1984, 1985, 1986, 1987, 1993
- *     The Regents of the University of California.  All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- *    must display the following acknowledgement:
- *     This product includes software developed by the University of
- *     California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- *    may be used to endorse or promote products derived from this software
- *    without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- *     @(#)spp_var.h   8.1 (Berkeley) 6/10/93
- * $FreeBSD: src/sys/netns/spp_var.h,v 1.11 1999/12/29 04:46:21 peter Exp $
- * $DragonFly: src/sys/netproto/ns/spp_var.h,v 1.7 2005/01/23 13:21:44 joerg Exp $
- */
-
-#ifndef _NETNS_SPP_VAR_H_
-#define _NETNS_SPP_VAR_H_
-
-/*
- * Sp control block, one per connection
- */
-struct sppcb {
-       struct  spidp_q s_q;            /* queue for out-of-order receipt */
-       struct  nspcb   *s_nspcb;       /* backpointer to internet pcb */
-       u_char  s_state;
-       u_char  s_flags;
-#define        SF_ACKNOW       0x01            /* Ack peer immediately */
-#define        SF_DELACK       0x02            /* Ack, but try to delay it */
-#define        SF_HI   0x04                    /* Show headers on input */
-#define        SF_HO   0x08                    /* Show headers on output */
-#define        SF_PI   0x10                    /* Packet (datagram) interface */
-#define SF_WIN 0x20                    /* Window info changed */
-#define SF_RXT 0x40                    /* Rxt info changed */
-#define SF_RVD 0x80                    /* Calling from read usrreq routine */
-       u_short s_mtu;                  /* Max packet size for this stream */
-/* use sequence fields in headers to store sequence numbers for this
-   connection */
-       struct  idp     *s_idp;
-       struct  sphdr   s_shdr;         /* prototype header to transmit */
-#define s_cc s_shdr.sp_cc              /* connection control (for EM bit) */
-#define s_dt s_shdr.sp_dt              /* datastream type */
-#define s_sid s_shdr.sp_sid            /* source connection identifier */
-#define s_did s_shdr.sp_did            /* destination connection identifier */
-#define s_seq s_shdr.sp_seq            /* sequence number */
-#define s_ack s_shdr.sp_ack            /* acknowledge number */
-#define s_alo s_shdr.sp_alo            /* allocation number */
-#define s_dport s_idp->idp_dna.x_port  /* where we are sending */
-       struct sphdr s_rhdr;            /* last received header (in effect!)*/
-       u_short s_rack;                 /* their acknowledge number */
-       u_short s_ralo;                 /* their allocation number */
-       u_short s_smax;                 /* highest packet # we have sent */
-       u_short s_snxt;                 /* which packet to send next */
-
-/* congestion control */
-#define        CUNIT   1024                    /* scaling for ... */
-       int     s_cwnd;                 /* Congestion-controlled window */
-                                       /* in packets * CUNIT */
-       short   s_swnd;                 /* == tcp snd_wnd, in packets */
-       short   s_smxw;                 /* == tcp max_sndwnd */
-                                       /* difference of two spp_seq's can be
-                                          no bigger than a short */
-       u_short s_swl1;                 /* == tcp snd_wl1 */
-       u_short s_swl2;                 /* == tcp snd_wl2 */
-       int     s_cwmx;                 /* max allowable cwnd */
-       int     s_ssthresh;             /* s_cwnd size threshhold for
-                                        * slow start exponential-to-
-                                        * linear switch */
-/* transmit timing stuff
- * srtt and rttvar are stored as fixed point, for convenience in smoothing.
- * srtt has 3 bits to the right of the binary point, rttvar has 2.
- */
-       short   s_idle;                 /* time idle */
-       short   s_timer[SPPT_NTIMERS];  /* timers */
-       short   s_rxtshift;             /* log(2) of rexmt exp. backoff */
-       short   s_rxtcur;               /* current retransmit value */
-       u_short s_rtseq;                /* packet being timed */
-       short   s_rtt;                  /* timer for round trips */
-       short   s_srtt;                 /* averaged timer */
-       short   s_rttvar;               /* variance in round trip time */
-       char    s_force;                /* which timer expired */
-       char    s_dupacks;              /* counter to intuit xmt loss */
-
-/* out of band data */
-       char    s_oobflags;
-#define SF_SOOB        0x08                    /* sending out of band data */
-#define SF_IOOB 0x10                   /* receiving out of band data */
-       char    s_iobc;                 /* input characters */
-/* debug stuff */
-       u_short s_want;                 /* Last candidate for sending */
-       char    s_outx;                 /* exit taken from spp_output */
-       char    s_inx;                  /* exit taken from spp_input */
-       u_short s_flags2;               /* more flags for testing */
-#define SF_NEWCALL     0x100           /* for new_recvmsg */
-#define SO_NEWCALL     10              /* for new_recvmsg */
-};
-
-#define        nstosppcb(np)   ((struct sppcb *)(np)->nsp_pcb)
-#define        sotosppcb(so)   (nstosppcb(sotonspcb(so)))
-
-struct sppstat {
-       long    spps_connattempt;       /* connections initiated */
-       long    spps_accepts;           /* connections accepted */
-       long    spps_connects;          /* connections established */
-       long    spps_drops;             /* connections dropped */
-       long    spps_conndrops;         /* embryonic connections dropped */
-       long    spps_closed;            /* conn. closed (includes drops) */
-       long    spps_segstimed;         /* segs where we tried to get rtt */
-       long    spps_rttupdated;        /* times we succeeded */
-       long    spps_delack;            /* delayed acks sent */
-       long    spps_timeoutdrop;       /* conn. dropped in rxmt timeout */
-       long    spps_rexmttimeo;        /* retransmit timeouts */
-       long    spps_persisttimeo;      /* persist timeouts */
-       long    spps_keeptimeo;         /* keepalive timeouts */
-       long    spps_keepprobe;         /* keepalive probes sent */
-       long    spps_keepdrops;         /* connections dropped in keepalive */
-
-       long    spps_sndtotal;          /* total packets sent */
-       long    spps_sndpack;           /* data packets sent */
-       long    spps_sndbyte;           /* data bytes sent */
-       long    spps_sndrexmitpack;     /* data packets retransmitted */
-       long    spps_sndrexmitbyte;     /* data bytes retransmitted */
-       long    spps_sndacks;           /* ack-only packets sent */
-       long    spps_sndprobe;          /* window probes sent */
-       long    spps_sndurg;            /* packets sent with URG only */
-       long    spps_sndwinup;          /* window update-only packets sent */
-       long    spps_sndctrl;           /* control (SYN|FIN|RST) packets sent */
-       long    spps_sndvoid;           /* couldn't find requested packet*/
-
-       long    spps_rcvtotal;          /* total packets received */
-       long    spps_rcvpack;           /* packets received in sequence */
-       long    spps_rcvbyte;           /* bytes received in sequence */
-       long    spps_rcvbadsum;         /* packets received with ccksum errs */
-       long    spps_rcvbadoff;         /* packets received with bad offset */
-       long    spps_rcvshort;          /* packets received too short */
-       long    spps_rcvduppack;        /* duplicate-only packets received */
-       long    spps_rcvdupbyte;        /* duplicate-only bytes received */
-       long    spps_rcvpartduppack;    /* packets with some duplicate data */
-       long    spps_rcvpartdupbyte;    /* dup. bytes in part-dup. packets */
-       long    spps_rcvoopack;         /* out-of-order packets received */
-       long    spps_rcvoobyte;         /* out-of-order bytes received */
-       long    spps_rcvpackafterwin;   /* packets with data after window */
-       long    spps_rcvbyteafterwin;   /* bytes rcvd after window */
-       long    spps_rcvafterclose;     /* packets rcvd after "close" */
-       long    spps_rcvwinprobe;       /* rcvd window probe packets */
-       long    spps_rcvdupack;         /* rcvd duplicate acks */
-       long    spps_rcvacktoomuch;     /* rcvd acks for unsent data */
-       long    spps_rcvackpack;        /* rcvd ack packets */
-       long    spps_rcvackbyte;        /* bytes acked by rcvd acks */
-       long    spps_rcvwinupd;         /* rcvd window update packets */
-};
-struct spp_istat {
-       short   hdrops;
-       short   badsum;
-       short   badlen;
-       short   slotim;
-       short   fastim;
-       short   nonucn;
-       short   noconn;
-       short   notme;
-       short   wrncon;
-       short   bdreas;
-       short   gonawy;
-       short   notyet;
-       short   lstdup;
-       struct sppstat newstats;
-};
-
-#ifdef _KERNEL
-extern struct spp_istat spp_istat;
-extern struct pr_usrreqs spp_usrreqs;
-extern struct pr_usrreqs spp_usrreqs_sp;
-extern u_short spp_iss;
-
-/* Following was struct sppstat sppstat; */
-#ifndef sppstat
-#define sppstat spp_istat.newstats
-#endif
-
-void spp_init (void);
-void spp_input (struct mbuf *, /* struct nspcb *, */ ...);
-void spp_ctlinput (int, caddr_t);
-int spp_ctloutput (int, struct socket *, int, int, struct mbuf **);
-void spp_fasttimo (void);
-void spp_slowtimo (void);
-void spp_template (struct sppcb *);
-int spp_reass (struct sppcb *, struct spidp *, struct mbuf *);
-int spp_output (struct sppcb *, struct mbuf *);
-void spp_quench (struct nspcb *);
-void spp_abort (struct nspcb *);
-void spp_setpersist (struct sppcb *);
-
-struct sppcb *spp_close (struct sppcb *);
-struct sppcb *spp_disconnect (struct sppcb *);
-struct sppcb *spp_usrclosed (struct sppcb *);
-struct sppcb *spp_timers (struct sppcb *, int);
-struct sppcb *spp_drop (struct sppcb *, int);
-
-#endif
-
-#define        SPP_ISSINCR     128
-/*
- * SPP sequence numbers are 16 bit integers operated
- * on with modular arithmetic.  These macros can be
- * used to compare such integers.
- */
-#ifdef sun
-short xnsCbug;
-#define        SSEQ_LT(a,b)    ((xnsCbug = (short)((a)-(b))) < 0)
-#define        SSEQ_LEQ(a,b)   ((xnsCbug = (short)((a)-(b))) <= 0)
-#define        SSEQ_GT(a,b)    ((xnsCbug = (short)((a)-(b))) > 0)
-#define        SSEQ_GEQ(a,b)   ((xnsCbug = (short)((a)-(b))) >= 0)
-#else
-#define        SSEQ_LT(a,b)    (((short)((a)-(b))) < 0)
-#define        SSEQ_LEQ(a,b)   (((short)((a)-(b))) <= 0)
-#define        SSEQ_GT(a,b)    (((short)((a)-(b))) > 0)
-#define        SSEQ_GEQ(a,b)   (((short)((a)-(b))) >= 0)
-#endif
-
-#endif
index 42a2d8e..b729ed0 100644 (file)
  * 200800 - 2.8 release                        October 2010
  * 200900 - 2.9 master
  * 200901 - prototype changes for alphasort(3) and scandir(3)
+ * 200902 - Xerox NS protocol removal
  */
 #undef __DragonFly_version
-#define __DragonFly_version 200901     /* propagated to newvers */
+#define __DragonFly_version 200902     /* propagated to newvers */
 
 #include <sys/_null.h>
 
index 5e908b1..e347dbb 100644 (file)
@@ -1,10 +1,9 @@
 # $FreeBSD: src/usr.bin/netstat/Makefile,v 1.14.2.3 2001/08/10 09:07:08 ru Exp $
-# $DragonFly: src/usr.bin/netstat/Makefile,v 1.4 2007/08/27 16:50:56 pavalos Exp $
 #      @(#)Makefile    8.1 (Berkeley) 6/12/93
 
 PROG=  netstat
 SRCS=  if.c inet.c inet6.c main.c mbuf.c mroute.c ipx.c route.c \
-       unix.c atalk.c netgraph.c mroute6.c ipsec.c # iso.c ns.c tp_astring.c 
+       unix.c atalk.c netgraph.c mroute6.c ipsec.c # iso.c tp_astring.c
 CFLAGS+=-DIPSEC
 CFLAGS+=-DINET6
 
index b79fd58..4938c28 100644 (file)
 #include <netinet/in_var.h>
 #include <netproto/ipx/ipx.h>
 #include <netproto/ipx/ipx_if.h>
-#ifdef NS
-#include <netproto/ns/ns.h>
-#include <netproto/ns/ns_if.h>
-#endif
 #ifdef ISO
 #include <netiso/iso.h>
 #include <netiso/iso_var.h>
@@ -115,9 +111,6 @@ intpr(int interval1, u_long ifnetaddr, void (*pfunc)(char *))
                struct in6_ifaddr in6;
 #endif
                struct ipx_ifaddr ipx;
-#ifdef NS
-               struct ns_ifaddr ns;
-#endif
 #ifdef ISO
                struct iso_ifaddr iso;
 #endif
@@ -321,23 +314,6 @@ intpr(int interval1, u_long ifnetaddr, void (*pfunc)(char *))
                                printf("atalk:%-12.12s ",atalk_print(sa,0x10) );
                                printf("%-9.9s  ",atalk_print(sa,0x0b) );
                                break;
-#ifdef NS
-                       case AF_NS:
-                               {
-                               struct sockaddr_ns *sns =
-                                       (struct sockaddr_ns *)sa;
-                               u_long net;
-                               char netnum[10];
-
-                               *(union ns_net *) &net = sns->sns_addr.x_net;
-                               sprintf(netnum, "%lxH", ntohl(net));
-                               upHex(netnum);
-                               printf("ns:%-8s ", netnum);
-                               printf("%-15s ",
-                                   ns_phost((struct sockaddr *)sns));
-                               }
-                               break;
-#endif
                        case AF_LINK:
                                {
                                struct sockaddr_dl *sdl =
index e2bc2f9..b5586eb 100644 (file)
@@ -248,19 +248,6 @@ struct protox ipxprotox[] = {
          0,            NULL,           0,      0 }
 };
 
-#ifdef NS
-struct protox nsprotox[] = {
-       { N_IDP,        N_IDPSTAT,      1,      nsprotopr,
-         idp_stats,    NULL,           "idp" },
-       { N_IDP,        N_SPPSTAT,      1,      nsprotopr,
-         spp_stats,    NULL,           "spp" },
-       { -1,           N_NSERR,        1,      0,
-         nserr_stats,  NULL,           "ns_err" },
-       { -1,           -1,             0,      0,
-         0,            NULL,           0 }
-};
-#endif
-
 #ifdef ISO
 struct protox isoprotox[] = {
        { ISO_TP,       N_TPSTAT,       1,      iso_protopr,
@@ -285,9 +272,6 @@ struct protox *protoprotox[] = {
                                         pfkeyprotox,
 #endif
                                         ipxprotox, atalkprotox,
-#ifdef NS
-                                        nsprotox, 
-#endif
 #ifdef ISO
                                         isoprotox, 
 #endif
@@ -359,11 +343,6 @@ main(int argc, char **argv)
                        dflag = 1;
                        break;
                case 'f':
-#ifdef NS
-                       if (strcmp(optarg, "ns") == 0)
-                               af = AF_NS;
-                       else
-#endif
                        if (strcmp(optarg, "ipx") == 0)
                                af = AF_IPX;
                        else if (strcmp(optarg, "inet") == 0)
@@ -588,11 +567,6 @@ main(int argc, char **argv)
        if (af == AF_NETGRAPH || af == AF_UNSPEC)
                for (tp = netgraphprotox; tp->pr_name; tp++)
                        printproto(tp, tp->pr_name);
-#ifdef NS
-       if (af == AF_NS || af == AF_UNSPEC)
-               for (tp = nsprotox; tp->pr_name; tp++)
-                       printproto(tp, tp->pr_name);
-#endif
 #ifdef ISO
        if (af == AF_ISO || af == AF_UNSPEC)
                for (tp = isoprotox; tp->pr_name; tp++)
diff --git a/usr.bin/netstat/ns.c b/usr.bin/netstat/ns.c
deleted file mode 100644 (file)
index 48675ab..0000000
+++ /dev/null
@@ -1,341 +0,0 @@
-/*
- * Copyright (c) 1983, 1988, 1993
- *     The Regents of the University of California.  All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- *    must display the following acknowledgement:
- *     This product includes software developed by the University of
- *     California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- *    may be used to endorse or promote products derived from this software
- *    without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * @(#)ns.c    8.1 (Berkeley) 6/6/93
- * $FreeBSD: src/usr.bin/netstat/ns.c,v 1.1.1.1.14.1 2001/08/10 09:07:09 ru Exp $
- * $DragonFly: src/usr.bin/netstat/ns.c,v 1.5 2007/05/17 08:19:02 swildner Exp $
- */
-
-#include <sys/param.h>
-#include <sys/socket.h>
-#include <sys/socketvar.h>
-#include <sys/mbuf.h>
-#include <sys/protosw.h>
-
-#include <net/route.h>
-#include <net/if.h>
-
-#include <netinet/tcp_fsm.h>
-
-#include <netns/ns.h>
-#include <netns/ns_pcb.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>
-#define SANAMES
-#include <netns/spp_debug.h>
-
-#include <nlist.h>
-#include <errno.h>
-#include <stdio.h>
-#include <string.h>
-#include "netstat.h"
-
-struct nspcb nspcb;
-struct sppcb sppcb;
-struct socket sockb;
-
-static char *ns_prpr (struct ns_addr *);
-static void ns_erputil (int, int);
-
-static int first = 1;
-
-/*
- * Print a summary of connections related to a Network Systems
- * protocol.  For SPP, also give state of connection.
- * Listening processes (aflag) are suppressed unless the
- * -a (all) flag is specified.
- */
-
-void
-nsprotopr(u_long off, char *name, int af __unused)
-{
-       struct nspcb cb;
-       struct nspcb *prev, *next;
-       int isspp;
-
-       if (off == 0)
-               return;
-       isspp = strcmp(name, "spp") == 0;
-       kread(off, (char *)&cb, sizeof (struct nspcb));
-       nspcb = cb;
-       prev = (struct nspcb *)off;
-       if (nspcb.nsp_next == (struct nspcb *)off)
-               return;
-       for (;nspcb.nsp_next != (struct nspcb *)off; prev = next) {
-               u_long ppcb;
-
-               next = nspcb.nsp_next;
-               kread((u_long)next, (char *)&nspcb, sizeof (nspcb));
-               if (nspcb.nsp_prev != prev) {
-                       printf("???\n");
-                       break;
-               }
-               if (!aflag && ns_nullhost(nspcb.nsp_faddr) ) {
-                       continue;
-               }
-               kread((u_long)nspcb.nsp_socket,
-                               (char *)&sockb, sizeof (sockb));
-               ppcb = (u_long) nspcb.nsp_pcb;
-               if (ppcb) {
-                       if (isspp) {
-                               kread(ppcb, (char *)&sppcb, sizeof (sppcb));
-                       } else continue;
-               } else
-                       if (isspp) continue;
-               if (first) {
-                       printf("Active NS connections");
-                       if (aflag)
-                               printf(" (including servers)");
-                       putchar('\n');
-                       if (Aflag)
-                               printf("%-8.8s ", "PCB");
-                       printf(Aflag ?
-                               "%-5.5s %-6.6s %-6.6s  %-18.18s %-18.18s %s\n" :
-                               "%-5.5s %-6.6s %-6.6s  %-22.22s %-22.22s %s\n",
-                               "Proto", "Recv-Q", "Send-Q",
-                               "Local Address", "Foreign Address", "(state)");
-                       first = 0;
-               }
-               if (Aflag)
-                       printf("%8x ", ppcb);
-               printf("%-5.5s %6d %6d ", name, sockb.so_rcv.ssb_cc,
-                       sockb.so_snd.ssb_cc);
-               printf("  %-22.22s", ns_prpr(&nspcb.nsp_laddr));
-               printf(" %-22.22s", ns_prpr(&nspcb.nsp_faddr));
-               if (isspp) {
-                       extern char *tcpstates[];
-                       if (sppcb.s_state >= TCP_NSTATES)
-                               printf(" %d", sppcb.s_state);
-                       else
-                               printf(" %s", tcpstates[sppcb.s_state]);
-               }
-               putchar('\n');
-               prev = next;
-       }
-}
-#define ANY(x,y,z) \
-       ((x) ? printf("\t%d %s%s%s -- %s\n",x,y,plural(x),z,"x") : 0)
-
-/*
- * Dump SPP statistics structure.
- */
-void
-spp_stats(u_long off, char *name, int af __unused)
-{
-       struct spp_istat spp_istat;
-#define sppstat spp_istat.newstats
-
-       if (off == 0)
-               return;
-       kread(off, (char *)&spp_istat, sizeof (spp_istat));
-       printf("%s:\n", name);
-       ANY(spp_istat.nonucn, "connection", " dropped due to no new sockets ");
-       ANY(spp_istat.gonawy, "connection", " terminated due to our end dying");
-       ANY(spp_istat.nonucn, "connection",
-           " dropped due to inability to connect");
-       ANY(spp_istat.noconn, "connection",
-           " dropped due to inability to connect");
-       ANY(spp_istat.notme, "connection",
-           " incompleted due to mismatched id's");
-       ANY(spp_istat.wrncon, "connection", " dropped due to mismatched id's");
-       ANY(spp_istat.bdreas, "packet", " dropped out of sequence");
-       ANY(spp_istat.lstdup, "packet", " duplicating the highest packet");
-       ANY(spp_istat.notyet, "packet", " refused as exceeding allocation");
-       ANY(sppstat.spps_connattempt, "connection", " initiated");
-       ANY(sppstat.spps_accepts, "connection", " accepted");
-       ANY(sppstat.spps_connects, "connection", " established");
-       ANY(sppstat.spps_drops, "connection", " dropped");
-       ANY(sppstat.spps_conndrops, "embryonic connection", " dropped");
-       ANY(sppstat.spps_closed, "connection", " closed (includes drops)");
-       ANY(sppstat.spps_segstimed, "packet", " where we tried to get rtt");
-       ANY(sppstat.spps_rttupdated, "time", " we got rtt");
-       ANY(sppstat.spps_delack, "delayed ack", " sent");
-       ANY(sppstat.spps_timeoutdrop, "connection", " dropped in rxmt timeout");
-       ANY(sppstat.spps_rexmttimeo, "retransmit timeout", "");
-       ANY(sppstat.spps_persisttimeo, "persist timeout", "");
-       ANY(sppstat.spps_keeptimeo, "keepalive timeout", "");
-       ANY(sppstat.spps_keepprobe, "keepalive probe", " sent");
-       ANY(sppstat.spps_keepdrops, "connection", " dropped in keepalive");
-       ANY(sppstat.spps_sndtotal, "total packet", " sent");
-       ANY(sppstat.spps_sndpack, "data packet", " sent");
-       ANY(sppstat.spps_sndbyte, "data byte", " sent");
-       ANY(sppstat.spps_sndrexmitpack, "data packet", " retransmitted");
-       ANY(sppstat.spps_sndrexmitbyte, "data byte", " retransmitted");
-       ANY(sppstat.spps_sndacks, "ack-only packet", " sent");
-       ANY(sppstat.spps_sndprobe, "window probe", " sent");
-       ANY(sppstat.spps_sndurg, "packet", " sent with URG only");
-       ANY(sppstat.spps_sndwinup, "window update-only packet", " sent");
-       ANY(sppstat.spps_sndctrl, "control (SYN|FIN|RST) packet", " sent");
-       ANY(sppstat.spps_sndvoid, "request", " to send a non-existent packet");
-       ANY(sppstat.spps_rcvtotal, "total packet", " received");
-       ANY(sppstat.spps_rcvpack, "packet", " received in sequence");
-       ANY(sppstat.spps_rcvbyte, "byte", " received in sequence");
-       ANY(sppstat.spps_rcvbadsum, "packet", " received with ccksum errs");
-       ANY(sppstat.spps_rcvbadoff, "packet", " received with bad offset");
-       ANY(sppstat.spps_rcvshort, "packet", " received too short");
-       ANY(sppstat.spps_rcvduppack, "duplicate-only packet", " received");
-       ANY(sppstat.spps_rcvdupbyte, "duplicate-only byte", " received");
-       ANY(sppstat.spps_rcvpartduppack, "packet", " with some duplicate data");
-       ANY(sppstat.spps_rcvpartdupbyte, "dup. byte", " in part-dup. packet");
-       ANY(sppstat.spps_rcvoopack, "out-of-order packet", " received");
-       ANY(sppstat.spps_rcvoobyte, "out-of-order byte", " received");
-       ANY(sppstat.spps_rcvpackafterwin, "packet", " with data after window");
-       ANY(sppstat.spps_rcvbyteafterwin, "byte", " rcvd after window");
-       ANY(sppstat.spps_rcvafterclose, "packet", " rcvd after 'close'");
-       ANY(sppstat.spps_rcvwinprobe, "rcvd window probe packet", "");
-       ANY(sppstat.spps_rcvdupack, "rcvd duplicate ack", "");
-       ANY(sppstat.spps_rcvacktoomuch, "rcvd ack", " for unsent data");
-       ANY(sppstat.spps_rcvackpack, "rcvd ack packet", "");
-       ANY(sppstat.spps_rcvackbyte, "byte", " acked by rcvd acks");
-       ANY(sppstat.spps_rcvwinupd, "rcvd window update packet", "");
-}
-#undef ANY
-#define ANY(x,y,z)  ((x) ? printf("\t%d %s%s%s\n",x,y,plural(x),z) : 0)
-
-/*
- * Dump IDP statistics structure.
- */
-void
-idp_stats(u_long off, char *name, int af __unused)
-{
-       struct idpstat idpstat;
-
-       if (off == 0)
-               return;
-       kread(off, (char *)&idpstat, sizeof (idpstat));
-       printf("%s:\n", name);
-       ANY(idpstat.idps_toosmall, "packet", " smaller than a header");
-       ANY(idpstat.idps_tooshort, "packet", " smaller than advertised");
-       ANY(idpstat.idps_badsum, "packet", " with bad checksums");
-}
-
-static struct {
-       u_short code;
-       char *name;
-       char *where;
-} ns_errnames[] = {
-       {0, "Unspecified Error", " at Destination"},
-       {1, "Bad Checksum", " at Destination"},
-       {2, "No Listener", " at Socket"},
-       {3, "Packet", " Refused due to lack of space at Destination"},
-       {01000, "Unspecified Error", " while gatewayed"},
-       {01001, "Bad Checksum", " while gatewayed"},
-       {01002, "Packet", " forwarded too many times"},
-       {01003, "Packet", " too large to be forwarded"},
-       {-1, 0, 0},
-};
-
-/*
- * Dump NS Error statistics structure.
- */
-/*ARGSUSED*/
-void
-nserr_stats(u_long off, char *name, int af __unused)
-{
-       struct ns_errstat ns_errstat;
-       int j;
-       int histoprint = 1;
-       int z;
-
-       if (off == 0)
-               return;
-       kread(off, (char *)&ns_errstat, sizeof (ns_errstat));
-       printf("NS error statistics:\n");
-       ANY(ns_errstat.ns_es_error, "call", " to ns_error");
-       ANY(ns_errstat.ns_es_oldshort, "error",
-               " ignored due to insufficient addressing");
-       ANY(ns_errstat.ns_es_oldns_err, "error request",
- &nbs