aboutsummaryrefslogtreecommitdiff
path: root/sys/netnatm
diff options
context:
space:
mode:
authorBrooks Davis <brooks@FreeBSD.org>2017-04-24 21:21:49 +0000
committerBrooks Davis <brooks@FreeBSD.org>2017-04-24 21:21:49 +0000
commita7dc31283a053a6c0444813d1432fa83e6ccba9f (patch)
treecab348e253d3e66aa30638e8abd69d74bf8d502e /sys/netnatm
parent858f6fe3271409354e450a193e98f1720d8c1863 (diff)
Notes
Diffstat (limited to 'sys/netnatm')
-rw-r--r--sys/netnatm/natm.c490
-rw-r--r--sys/netnatm/natm.h120
-rw-r--r--sys/netnatm/natm_pcb.c167
-rw-r--r--sys/netnatm/natm_proto.c116
4 files changed, 0 insertions, 893 deletions
diff --git a/sys/netnatm/natm.c b/sys/netnatm/natm.c
deleted file mode 100644
index 56b8539941a6..000000000000
--- a/sys/netnatm/natm.c
+++ /dev/null
@@ -1,490 +0,0 @@
-/*-
- * Copyright (c) 2005-2006 Robert N. M. Watson
- * 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.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
- *
- * Copyright (c) 1996 Charles D. Cranor and Washington University.
- * 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 Charles D. Cranor and
- * Washington University.
- * 4. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
- *
- * $NetBSD: natm.c,v 1.5 1996/11/09 03:26:26 chuck Exp $
- */
-
-/*
- * natm.c: Native mode ATM access (both aal0 and aal5).
- */
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
-#include <sys/param.h>
-#include <sys/conf.h>
-#include <sys/kernel.h>
-#include <sys/lock.h>
-#include <sys/malloc.h>
-#include <sys/mbuf.h>
-#include <sys/protosw.h>
-#include <sys/signalvar.h>
-#include <sys/socket.h>
-#include <sys/socketvar.h>
-#include <sys/sockio.h>
-#include <sys/sx.h>
-#include <sys/systm.h>
-#include <sys/sysctl.h>
-
-#include <net/if.h>
-#include <net/if_var.h>
-#include <net/if_atm.h>
-#include <net/netisr.h>
-
-#include <netinet/in.h>
-
-#include <netnatm/natm.h>
-
-static const u_long natm5_sendspace = 16*1024;
-static const u_long natm5_recvspace = 16*1024;
-
-static const u_long natm0_sendspace = 16*1024;
-static const u_long natm0_recvspace = 16*1024;
-
-/*
- * netnatm global subsystem lock, protects all global data structures in
- * netnatm.
- */
-struct mtx natm_mtx;
-
-/*
- * User socket requests.
- */
-static int natm_usr_attach(struct socket *, int, struct thread *);
-static void natm_usr_detach(struct socket *);
-static int natm_usr_connect(struct socket *, struct sockaddr *,
- struct thread *);
-static int natm_usr_disconnect(struct socket *);
-static int natm_usr_shutdown(struct socket *);
-static int natm_usr_send(struct socket *, int, struct mbuf *,
- struct sockaddr *, struct mbuf *, struct thread *);
-static int natm_usr_peeraddr(struct socket *, struct sockaddr **);
-static int natm_usr_control(struct socket *, u_long, caddr_t,
- struct ifnet *, struct thread *);
-static void natm_usr_abort(struct socket *);
-static int natm_usr_bind(struct socket *, struct sockaddr *,
- struct thread *);
-static int natm_usr_sockaddr(struct socket *, struct sockaddr **);
-
-static int
-natm_usr_attach(struct socket *so, int proto, struct thread *p)
-{
- struct natmpcb *npcb;
- int error = 0;
-
- npcb = (struct natmpcb *)so->so_pcb;
- KASSERT(npcb == NULL, ("natm_usr_attach: so_pcb != NULL"));
-
- if (so->so_snd.sb_hiwat == 0 || so->so_rcv.sb_hiwat == 0) {
- if (proto == PROTO_NATMAAL5)
- error = soreserve(so, natm5_sendspace,
- natm5_recvspace);
- else
- error = soreserve(so, natm0_sendspace,
- natm0_recvspace);
- if (error)
- return (error);
- }
- so->so_pcb = npcb = npcb_alloc(M_WAITOK);
- npcb->npcb_socket = so;
- return (error);
-}
-
-static void
-natm_usr_detach(struct socket *so)
-{
- struct natmpcb *npcb;
-
- npcb = (struct natmpcb *)so->so_pcb;
- KASSERT(npcb != NULL, ("natm_usr_detach: npcb == NULL"));
-
- NATM_LOCK();
- npcb_free(npcb, NPCB_DESTROY); /* drain */
- so->so_pcb = NULL;
- NATM_UNLOCK();
-}
-
-static int
-natm_usr_connect(struct socket *so, struct sockaddr *nam, struct thread *p)
-{
- struct natmpcb *npcb;
- struct sockaddr_natm *snatm;
- struct atmio_openvcc op;
- struct ifnet *ifp;
- int error = 0;
- int proto = so->so_proto->pr_protocol;
-
- npcb = (struct natmpcb *)so->so_pcb;
- KASSERT(npcb != NULL, ("natm_usr_connect: npcb == NULL"));
-
- /*
- * Validate nam and npcb.
- */
- NATM_LOCK();
- snatm = (struct sockaddr_natm *)nam;
- if (snatm->snatm_len != sizeof(*snatm) ||
- (npcb->npcb_flags & NPCB_FREE) == 0) {
- NATM_UNLOCK();
- return (EINVAL);
- }
- if (snatm->snatm_family != AF_NATM) {
- NATM_UNLOCK();
- return (EAFNOSUPPORT);
- }
-
- snatm->snatm_if[IFNAMSIZ - 1] = '\0'; /* XXX ensure null termination
- since ifunit() uses strcmp */
-
- /*
- * Convert interface string to ifp, validate.
- */
- ifp = ifunit(snatm->snatm_if);
- if (ifp == NULL || (ifp->if_drv_flags & IFF_DRV_RUNNING) == 0) {
- NATM_UNLOCK();
- return (ENXIO);
- }
- if (ifp->if_output != atm_output) {
- NATM_UNLOCK();
- return (EAFNOSUPPORT);
- }
-
- /*
- * Register us with the NATM PCB layer.
- */
- if (npcb_add(npcb, ifp, snatm->snatm_vci, snatm->snatm_vpi) != npcb) {
- NATM_UNLOCK();
- return (EADDRINUSE);
- }
-
- /*
- * Open the channel.
- *
- * XXXRW: Eventually desirable to hold mutex over ioctl?
- */
- bzero(&op, sizeof(op));
- op.rxhand = npcb;
- op.param.flags = ATMIO_FLAG_PVC;
- op.param.vpi = npcb->npcb_vpi;
- op.param.vci = npcb->npcb_vci;
- op.param.rmtu = op.param.tmtu = ifp->if_mtu;
- op.param.aal = (proto == PROTO_NATMAAL5) ? ATMIO_AAL_5 : ATMIO_AAL_0;
- op.param.traffic = ATMIO_TRAFFIC_UBR;
- NATM_UNLOCK();
-
- if (ifp->if_ioctl == NULL ||
- ifp->if_ioctl(ifp, SIOCATMOPENVCC, (caddr_t)&op) != 0)
- return (EIO);
- soisconnected(so);
- return (error);
-}
-
-static int
-natm_usr_disconnect(struct socket *so)
-{
- struct natmpcb *npcb;
- struct atmio_closevcc cl;
- struct ifnet *ifp;
- int error = 0;
-
- npcb = (struct natmpcb *)so->so_pcb;
- KASSERT(npcb != NULL, ("natm_usr_disconnect: npcb == NULL"));
-
- NATM_LOCK();
- if ((npcb->npcb_flags & NPCB_CONNECTED) == 0) {
- NATM_UNLOCK();
- printf("natm: disconnected check\n");
- return (EIO);
- }
- ifp = npcb->npcb_ifp;
-
- /*
- * Disable rx.
- *
- * XXXRW: Eventually desirable to hold mutex over ioctl?
- */
- cl.vpi = npcb->npcb_vpi;
- cl.vci = npcb->npcb_vci;
- NATM_UNLOCK();
- if (ifp->if_ioctl != NULL)
- ifp->if_ioctl(ifp, SIOCATMCLOSEVCC, (caddr_t)&cl);
- soisdisconnected(so);
- return (error);
-}
-
-static int
-natm_usr_shutdown(struct socket *so)
-{
-
- socantsendmore(so);
- return (0);
-}
-
-static int
-natm_usr_send(struct socket *so, int flags, struct mbuf *m,
- struct sockaddr *nam, struct mbuf *control, struct thread *p)
-{
- struct natmpcb *npcb;
- struct atm_pseudohdr *aph;
- int error = 0;
- int proto = so->so_proto->pr_protocol;
-
- npcb = (struct natmpcb *)so->so_pcb;
- KASSERT(npcb != NULL, ("natm_usr_send: npcb == NULL"));
-
- NATM_LOCK();
- if (control && control->m_len) {
- NATM_UNLOCK();
- m_freem(control);
- m_freem(m);
- return (EINVAL);
- }
-
- /*
- * Send the data. We must put an atm_pseudohdr on first.
- */
- M_PREPEND(m, sizeof(*aph), M_NOWAIT);
- if (m == NULL) {
- NATM_UNLOCK();
- m_freem(control);
- return (ENOBUFS);
- }
- aph = mtod(m, struct atm_pseudohdr *);
- ATM_PH_VPI(aph) = npcb->npcb_vpi;
- ATM_PH_SETVCI(aph, npcb->npcb_vci);
- ATM_PH_FLAGS(aph) = (proto == PROTO_NATMAAL5) ? ATM_PH_AAL5 : 0;
- error = atm_output(npcb->npcb_ifp, m, NULL, NULL);
- NATM_UNLOCK();
- return (error);
-}
-
-static int
-natm_usr_peeraddr(struct socket *so, struct sockaddr **nam)
-{
- struct natmpcb *npcb;
- struct sockaddr_natm *snatm, ssnatm;
-
- npcb = (struct natmpcb *)so->so_pcb;
- KASSERT(npcb != NULL, ("natm_usr_peeraddr: npcb == NULL"));
-
- NATM_LOCK();
- snatm = &ssnatm;
- bzero(snatm, sizeof(*snatm));
- snatm->snatm_len = sizeof(*snatm);
- snatm->snatm_family = AF_NATM;
- strlcpy(snatm->snatm_if, npcb->npcb_ifp->if_xname,
- sizeof(snatm->snatm_if));
- snatm->snatm_vci = npcb->npcb_vci;
- snatm->snatm_vpi = npcb->npcb_vpi;
- NATM_UNLOCK();
- *nam = sodupsockaddr((struct sockaddr *)snatm, M_WAITOK);
- return (0);
-}
-
-static int
-natm_usr_control(struct socket *so, u_long cmd, caddr_t arg,
- struct ifnet *ifp, struct thread *p)
-{
- struct natmpcb *npcb;
-
- npcb = (struct natmpcb *)so->so_pcb;
- KASSERT(npcb != NULL, ("natm_usr_control: npcb == NULL"));
-
- switch (cmd) {
- case SIOCSIFADDR:
- case SIOCSIFBRDADDR:
- case SIOCSIFDSTADDR:
- case SIOCSIFNETMASK:
- /*
- * Although we should pass any non-ATM ioctl requests
- * down to driver, we filter some legacy INET requests.
- * Drivers trust SIOCSIFADDR et al to come from an already
- * privileged layer, and do not perform any credentials
- * checks or input validation.
- */
- return (EINVAL);
- }
-
- if (ifp == NULL || ifp->if_ioctl == NULL)
- return (EOPNOTSUPP);
- return ((*ifp->if_ioctl)(ifp, cmd, arg));
-}
-
-static void
-natm_usr_abort(struct socket *so)
-{
-
-}
-
-static void
-natm_usr_close(struct socket *so)
-{
-
-}
-
-static int
-natm_usr_bind(struct socket *so, struct sockaddr *nam, struct thread *p)
-{
-
- return (EOPNOTSUPP);
-}
-
-static int
-natm_usr_sockaddr(struct socket *so, struct sockaddr **nam)
-{
-
- return (EOPNOTSUPP);
-}
-
-/* xxx - should be const */
-struct pr_usrreqs natm_usrreqs = {
- .pru_abort = natm_usr_abort,
- .pru_attach = natm_usr_attach,
- .pru_bind = natm_usr_bind,
- .pru_connect = natm_usr_connect,
- .pru_control = natm_usr_control,
- .pru_detach = natm_usr_detach,
- .pru_disconnect = natm_usr_disconnect,
- .pru_peeraddr = natm_usr_peeraddr,
- .pru_send = natm_usr_send,
- .pru_shutdown = natm_usr_shutdown,
- .pru_sockaddr = natm_usr_sockaddr,
- .pru_close = natm_usr_close,
-};
-
-/*
- * natmintr: interrupt
- *
- * Note: we expect a socket pointer in rcvif rather than an interface
- * pointer. We can get the interface pointer from the so's PCB if we really
- * need it.
- */
-void
-natmintr(struct mbuf *m)
-{
- struct socket *so;
- struct natmpcb *npcb;
-
-#ifdef DIAGNOSTIC
- M_ASSERTPKTHDR(m);
-#endif
-
- NATM_LOCK();
- npcb = (struct natmpcb *)m->m_pkthdr.rcvif; /* XXX: overloaded */
- so = npcb->npcb_socket;
-
- npcb->npcb_inq--;
-
- if (npcb->npcb_flags & NPCB_DRAIN) {
- if (npcb->npcb_inq == 0)
- free(npcb, M_PCB); /* done! */
- NATM_UNLOCK();
- m_freem(m);
- return;
- }
-
- if (npcb->npcb_flags & NPCB_FREE) {
- NATM_UNLOCK();
- m_freem(m); /* drop */
- return;
- }
-
-#ifdef NEED_TO_RESTORE_IFP
- m->m_pkthdr.rcvif = npcb->npcb_ifp;
-#else
-#ifdef DIAGNOSTIC
- m->m_pkthdr.rcvif = NULL; /* null it out to be safe */
-#endif
-#endif
-
- if (sbspace(&so->so_rcv) > m->m_pkthdr.len) {
-#ifdef NATM_STAT
- natm_sookcnt++;
- natm_sookbytes += m->m_pkthdr.len;
-#endif
- sbappendrecord(&so->so_rcv, m);
- sorwakeup(so);
- NATM_UNLOCK();
- } else {
-#ifdef NATM_STAT
- natm_sodropcnt++;
- natm_sodropbytes += m->m_pkthdr.len;
-#endif
- NATM_UNLOCK();
- m_freem(m);
- }
-}
-
-/*
- * natm0_sysctl: not used, but here in case we want to add something
- * later...
- */
-int
-natm0_sysctl(SYSCTL_HANDLER_ARGS)
-{
-
- /* All sysctl names at this level are terminal. */
- return (ENOENT);
-}
-
-/*
- * natm5_sysctl: not used, but here in case we want to add something
- * later...
- */
-int
-natm5_sysctl(SYSCTL_HANDLER_ARGS)
-{
-
- /* All sysctl names at this level are terminal. */
- return (ENOENT);
-}
diff --git a/sys/netnatm/natm.h b/sys/netnatm/natm.h
deleted file mode 100644
index 5603b9e77d57..000000000000
--- a/sys/netnatm/natm.h
+++ /dev/null
@@ -1,120 +0,0 @@
-/*-
- * Copyright (c) 1996 Charles D. Cranor and Washington University.
- * 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 Charles D. Cranor and
- * Washington University.
- * 4. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
- *
- * $NetBSD: natm.h,v 1.1 1996/07/04 03:20:12 chuck Exp $
- * $FreeBSD$
- */
-
-/*
- * natm.h: native mode atm
- */
-
-/*
- * supported protocols
- */
-#define PROTO_NATMAAL0 1
-#define PROTO_NATMAAL5 2
-
-/*
- * sockaddr_natm
- */
-
-struct sockaddr_natm {
- unsigned char snatm_len; /* length */
- sa_family_t snatm_family; /* AF_NATM */
- char snatm_if[IFNAMSIZ]; /* interface name */
- u_int16_t snatm_vci; /* vci */
- u_int8_t snatm_vpi; /* vpi */
-};
-
-#ifdef _KERNEL
-
-/*
- * natm protocol control block
- */
-struct natmpcb {
- LIST_ENTRY(natmpcb) pcblist; /* list pointers */
- u_int npcb_inq; /* # of our pkts in proto q */
- struct socket *npcb_socket; /* backpointer to socket */
- struct ifnet *npcb_ifp; /* pointer to hardware */
- struct in_addr ipaddr; /* remote IP address, if APCB_IP */
- u_int16_t npcb_vci; /* VCI */
- u_int8_t npcb_vpi; /* VPI */
- u_int8_t npcb_flags; /* flags */
-};
-
-/* flags */
-#define NPCB_FREE 0x01 /* free (not on any list) */
-#define NPCB_CONNECTED 0x02 /* connected */
-#define NPCB_IP 0x04 /* used by IP */
-#define NPCB_DRAIN 0x08 /* destroy as soon as inq == 0 */
-
-/* flag arg to npcb_free */
-#define NPCB_REMOVE 0 /* remove from global list */
-#define NPCB_DESTROY 1 /* destroy and be free */
-
-LIST_HEAD(npcblist, natmpcb);
-
-/* global data structures */
-
-extern struct mtx natm_mtx; /* global netnatm lock */
-extern struct npcblist natm_pcbs; /* global list of pcbs */
-#define NATM_STAT
-#ifdef NATM_STAT
-extern u_int natm_sodropcnt;
-extern u_int natm_sodropbytes; /* account of droppage */
-extern u_int natm_sookcnt;
-extern u_int natm_sookbytes; /* account of ok */
-#endif
-
-/* locking macros */
-#define NATM_LOCK_INIT() mtx_init(&natm_mtx, "natm_mtx", NULL, MTX_DEF)
-#define NATM_LOCK() mtx_lock(&natm_mtx)
-#define NATM_UNLOCK() mtx_unlock(&natm_mtx)
-#define NATM_LOCK_ASSERT() mtx_assert(&natm_mtx, MA_OWNED)
-
-/* external functions */
-
-/* natm_pcb.c */
-struct natmpcb *npcb_alloc(int);
-void npcb_free(struct natmpcb *, int);
-struct natmpcb *npcb_add(struct natmpcb *, struct ifnet *, uint16_t, uint8_t);
-
-/* natm.c */
-extern struct pr_usrreqs natm_usrreqs;
-
-#ifdef SYSCTL_HANDLER_ARGS
-int natm0_sysctl(SYSCTL_HANDLER_ARGS);
-int natm5_sysctl(SYSCTL_HANDLER_ARGS);
-#endif
-
-void natmintr(struct mbuf *);
-
-#endif
diff --git a/sys/netnatm/natm_pcb.c b/sys/netnatm/natm_pcb.c
deleted file mode 100644
index 602d438ea51e..000000000000
--- a/sys/netnatm/natm_pcb.c
+++ /dev/null
@@ -1,167 +0,0 @@
-/*-
- * Copyright (c) 1996 Charles D. Cranor and Washington University.
- * 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 Charles D. Cranor and
- * Washington University.
- * 4. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
- *
- * $NetBSD: natm_pcb.c,v 1.4 1996/11/09 03:26:27 chuck Exp $
- */
-
-/*
- * atm_pcb.c: manage atm protocol control blocks and keep IP and NATM
- * from trying to use each other's VCs.
- */
-
-#include "opt_ddb.h"
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
-#include <sys/param.h>
-#include <sys/kernel.h>
-#include <sys/lock.h>
-#include <sys/malloc.h>
-#include <sys/mutex.h>
-#include <sys/systm.h>
-#include <sys/socket.h>
-#include <sys/socketvar.h>
-
-#include <net/if.h>
-#include <net/if_var.h> /* XXX: db_show_natm() */
-
-#include <netinet/in.h>
-
-#include <netnatm/natm.h>
-
-#include <ddb/ddb.h>
-
-struct npcblist natm_pcbs;
-
-/*
- * npcb_alloc: allocate a npcb [in the free state]
- */
-struct natmpcb *
-npcb_alloc(int wait)
-
-{
- struct natmpcb *npcb;
-
- npcb = malloc(sizeof(*npcb), M_PCB, wait | M_ZERO);
- if (npcb != NULL)
- npcb->npcb_flags = NPCB_FREE;
- return (npcb);
-}
-
-
-/*
- * npcb_free: free a npcb
- */
-void
-npcb_free(struct natmpcb *npcb, int op)
-{
-
- NATM_LOCK_ASSERT();
-
- if ((npcb->npcb_flags & NPCB_FREE) == 0) {
- LIST_REMOVE(npcb, pcblist);
- npcb->npcb_flags = NPCB_FREE;
- }
- if (op == NPCB_DESTROY) {
- if (npcb->npcb_inq) {
- npcb->npcb_flags = NPCB_DRAIN; /* flag for distruct. */
- } else {
- free(npcb, M_PCB); /* kill it! */
- }
- }
-}
-
-
-/*
- * npcb_add: add or remove npcb from main list
- * returns npcb if ok
- */
-struct natmpcb *
-npcb_add(struct natmpcb *npcb, struct ifnet *ifp, u_int16_t vci, u_int8_t vpi)
-{
- struct natmpcb *cpcb = NULL; /* current pcb */
-
- NATM_LOCK_ASSERT();
-
- /*
- * lookup required
- */
- LIST_FOREACH(cpcb, &natm_pcbs, pcblist)
- if (ifp == cpcb->npcb_ifp && vci == cpcb->npcb_vci &&
- vpi == cpcb->npcb_vpi)
- break;
-
- /*
- * add & something already there?
- */
- if (cpcb) {
- cpcb = NULL;
- goto done; /* fail */
- }
-
- /*
- * need to allocate a pcb?
- */
- if (npcb == NULL) {
- /* could be called from lower half */
- cpcb = npcb_alloc(M_NOWAIT);
- if (cpcb == NULL)
- goto done; /* fail */
- } else {
- cpcb = npcb;
- }
-
- cpcb->npcb_ifp = ifp;
- cpcb->ipaddr.s_addr = 0;
- cpcb->npcb_vci = vci;
- cpcb->npcb_vpi = vpi;
- cpcb->npcb_flags = NPCB_CONNECTED;
-
- LIST_INSERT_HEAD(&natm_pcbs, cpcb, pcblist);
-
-done:
- return (cpcb);
-}
-
-#ifdef DDB
-DB_SHOW_COMMAND(natm, db_show_natm)
-{
- struct natmpcb *cpcb;
-
- db_printf("npcb dump:\n");
- LIST_FOREACH(cpcb, &natm_pcbs, pcblist) {
- db_printf("if=%s, vci=%d, vpi=%d, IP=0x%x, sock=%p, "
- "flags=0x%x, inq=%d\n", cpcb->npcb_ifp->if_xname,
- cpcb->npcb_vci, cpcb->npcb_vpi, cpcb->ipaddr.s_addr,
- cpcb->npcb_socket, cpcb->npcb_flags, cpcb->npcb_inq);
- }
-}
-#endif
diff --git a/sys/netnatm/natm_proto.c b/sys/netnatm/natm_proto.c
deleted file mode 100644
index aa7fa2cd8511..000000000000
--- a/sys/netnatm/natm_proto.c
+++ /dev/null
@@ -1,116 +0,0 @@
-/*-
- * Copyright (c) 1996 Charles D. Cranor and Washington University.
- * 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 Charles D. Cranor and
- * Washington University.
- * 4. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
- *
- * $NetBSD: natm_proto.c,v 1.3 1996/09/18 00:56:41 chuck Exp $
- */
-
-/*
- * protocol layer for access to native mode ATM
- */
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/kernel.h>
-#include <sys/lock.h>
-#include <sys/mutex.h>
-#include <sys/socket.h>
-#include <sys/protosw.h>
-#include <sys/domain.h>
-
-#include <net/if.h>
-#include <net/netisr.h>
-
-#include <netinet/in.h>
-
-#include <netnatm/natm.h>
-
-static void natm_init(void);
-
-static struct domain natmdomain;
-
-static struct protosw natmsw[] = {
-{
- .pr_type = SOCK_STREAM,
- .pr_domain = &natmdomain,
- .pr_protocol = PROTO_NATMAAL5,
- .pr_flags = PR_CONNREQUIRED,
- .pr_usrreqs = &natm_usrreqs
-},
-{
- .pr_type = SOCK_DGRAM,
- .pr_domain = &natmdomain,
- .pr_protocol = PROTO_NATMAAL5,
- .pr_flags = PR_CONNREQUIRED|PR_ATOMIC,
- .pr_usrreqs = &natm_usrreqs
-},
-{
- .pr_type = SOCK_STREAM,
- .pr_domain = &natmdomain,
- .pr_protocol = PROTO_NATMAAL0,
- .pr_flags = PR_CONNREQUIRED,
- .pr_usrreqs = &natm_usrreqs
-},
-};
-
-static struct domain natmdomain = {
- .dom_family = AF_NATM,
- .dom_name = "natm",
- .dom_init = natm_init,
- .dom_protosw = natmsw,
- .dom_protoswNPROTOSW = &natmsw[nitems(natmsw)],
-};
-
-static struct netisr_handler natm_nh = {
- .nh_name = "natm",
- .nh_handler = natmintr,
- .nh_proto = NETISR_NATM,
- .nh_qlimit = 1000,
- .nh_policy = NETISR_POLICY_SOURCE,
-};
-
-#ifdef NATM_STAT
-u_int natm_sodropcnt; /* # mbufs dropped due to full sb */
-u_int natm_sodropbytes; /* # of bytes dropped */
-u_int natm_sookcnt; /* # mbufs ok */
-u_int natm_sookbytes; /* # of bytes ok */
-#endif
-
-static void
-natm_init(void)
-{
- LIST_INIT(&natm_pcbs);
- NATM_LOCK_INIT();
- netisr_register(&natm_nh);
-}
-
-DOMAIN_SET(natm);