2005-01-07 01:45:51 +00:00
|
|
|
/*-
|
1997-05-09 07:48:14 +00:00
|
|
|
* 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.
|
2007-01-08 22:30:39 +00:00
|
|
|
*
|
|
|
|
* $NetBSD: natm.h,v 1.1 1996/07/04 03:20:12 chuck Exp $
|
|
|
|
* $FreeBSD$
|
1997-05-09 07:48:14 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* natm.h: native mode atm
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* supported protocols
|
|
|
|
*/
|
2003-08-06 13:46:15 +00:00
|
|
|
#define PROTO_NATMAAL0 1
|
|
|
|
#define PROTO_NATMAAL5 2
|
1997-05-09 07:48:14 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* sockaddr_natm
|
|
|
|
*/
|
|
|
|
|
|
|
|
struct sockaddr_natm {
|
2003-08-06 13:46:15 +00:00
|
|
|
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 */
|
1997-05-09 07:48:14 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#ifdef _KERNEL
|
|
|
|
|
|
|
|
/*
|
|
|
|
* natm protocol control block
|
|
|
|
*/
|
|
|
|
struct natmpcb {
|
2003-08-06 13:46:15 +00:00
|
|
|
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 */
|
1997-05-09 07:48:14 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/* flags */
|
2003-08-06 13:46:15 +00:00
|
|
|
#define NPCB_FREE 0x01 /* free (not on any list) */
|
|
|
|
#define NPCB_CONNECTED 0x02 /* connected */
|
|
|
|
#define NPCB_IP 0x04 /* used by IP */
|
2007-04-16 12:31:35 +00:00
|
|
|
#define NPCB_DRAIN 0x08 /* destroy as soon as inq == 0 */
|
1997-05-09 07:48:14 +00:00
|
|
|
|
|
|
|
/* flag arg to npcb_free */
|
2003-08-06 13:46:15 +00:00
|
|
|
#define NPCB_REMOVE 0 /* remove from global list */
|
|
|
|
#define NPCB_DESTROY 1 /* destroy and be free */
|
1997-05-09 07:48:14 +00:00
|
|
|
|
2000-05-26 02:09:24 +00:00
|
|
|
LIST_HEAD(npcblist, natmpcb);
|
1997-05-09 07:48:14 +00:00
|
|
|
|
|
|
|
/* global data structures */
|
|
|
|
|
Lock down netnatm and mark as MPSAFE:
- Introduce a subsystem mutex, natm_mtx, manipulated with accessor macros
NATM_LOCK_INIT(), NATM_LOCK(), NATM_UNLOCK(), NATM_LOCK_ASSERT(). It
protects the consistency of pcb-related data structures. Finer grained
locking is possible, but should be done in the context of specific
measurements (as very little work is done in netnatm -- most is in the
ATM device driver or socket layer, so there's probably not much
contention).
- Remove GIANT_REQUIRED, mark as NETISR_MPSAFE, remove
NET_NEEDS_GIANT("netnatm").
- Conditionally acquire Giant when entering network interfaces for
ifp->if_ioctl() using IFF_LOCKGIANT(ifp)/IFF_UNLOCKGIANT(ifp) in order
to coexist with non-MPSAFE atm ifnet drivers..
- De-spl.
MFC after: 2 weeks
Reviewed by: harti, bms (various versions)
2005-07-18 16:55:46 +00:00
|
|
|
extern struct mtx natm_mtx; /* global netnatm lock */
|
1997-12-20 00:13:51 +00:00
|
|
|
extern struct npcblist natm_pcbs; /* global list of pcbs */
|
1997-05-09 07:48:14 +00:00
|
|
|
#define NATM_STAT
|
|
|
|
#ifdef NATM_STAT
|
2003-08-06 13:46:15 +00:00
|
|
|
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 */
|
1997-05-09 07:48:14 +00:00
|
|
|
#endif
|
|
|
|
|
Lock down netnatm and mark as MPSAFE:
- Introduce a subsystem mutex, natm_mtx, manipulated with accessor macros
NATM_LOCK_INIT(), NATM_LOCK(), NATM_UNLOCK(), NATM_LOCK_ASSERT(). It
protects the consistency of pcb-related data structures. Finer grained
locking is possible, but should be done in the context of specific
measurements (as very little work is done in netnatm -- most is in the
ATM device driver or socket layer, so there's probably not much
contention).
- Remove GIANT_REQUIRED, mark as NETISR_MPSAFE, remove
NET_NEEDS_GIANT("netnatm").
- Conditionally acquire Giant when entering network interfaces for
ifp->if_ioctl() using IFF_LOCKGIANT(ifp)/IFF_UNLOCKGIANT(ifp) in order
to coexist with non-MPSAFE atm ifnet drivers..
- De-spl.
MFC after: 2 weeks
Reviewed by: harti, bms (various versions)
2005-07-18 16:55:46 +00:00
|
|
|
/* 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)
|
|
|
|
|
1997-05-09 07:48:14 +00:00
|
|
|
/* external functions */
|
|
|
|
|
|
|
|
/* natm_pcb.c */
|
2002-03-20 02:39:27 +00:00
|
|
|
struct natmpcb *npcb_alloc(int);
|
|
|
|
void npcb_free(struct natmpcb *, int);
|
2003-08-06 13:46:15 +00:00
|
|
|
struct natmpcb *npcb_add(struct natmpcb *, struct ifnet *, uint16_t, uint8_t);
|
1997-05-09 07:48:14 +00:00
|
|
|
|
|
|
|
/* natm.c */
|
|
|
|
extern struct pr_usrreqs natm_usrreqs;
|
2003-08-06 13:46:15 +00:00
|
|
|
|
|
|
|
#ifdef SYSCTL_HANDLER_ARGS
|
|
|
|
int natm0_sysctl(SYSCTL_HANDLER_ARGS);
|
|
|
|
int natm5_sysctl(SYSCTL_HANDLER_ARGS);
|
|
|
|
#endif
|
|
|
|
|
2003-03-04 23:19:55 +00:00
|
|
|
void natmintr(struct mbuf *);
|
1997-05-09 07:48:14 +00:00
|
|
|
|
|
|
|
#endif
|