natm.h revision 118541
125603Skjc/*	$NetBSD: natm.h,v 1.1 1996/07/04 03:20:12 chuck Exp $	*/
255205Speter/* $FreeBSD: head/sys/netnatm/natm.h 118541 2003-08-06 13:46:15Z harti $ */
325603Skjc
425603Skjc/*
525603Skjc *
625603Skjc * Copyright (c) 1996 Charles D. Cranor and Washington University.
725603Skjc * All rights reserved.
825603Skjc *
925603Skjc * Redistribution and use in source and binary forms, with or without
1025603Skjc * modification, are permitted provided that the following conditions
1125603Skjc * are met:
1225603Skjc * 1. Redistributions of source code must retain the above copyright
1325603Skjc *    notice, this list of conditions and the following disclaimer.
1425603Skjc * 2. Redistributions in binary form must reproduce the above copyright
1525603Skjc *    notice, this list of conditions and the following disclaimer in the
1625603Skjc *    documentation and/or other materials provided with the distribution.
1725603Skjc * 3. All advertising materials mentioning features or use of this software
1825603Skjc *    must display the following acknowledgement:
1925603Skjc *      This product includes software developed by Charles D. Cranor and
2025603Skjc *      Washington University.
2125603Skjc * 4. The name of the author may not be used to endorse or promote products
2225603Skjc *    derived from this software without specific prior written permission.
2325603Skjc *
2425603Skjc * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
2525603Skjc * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
2625603Skjc * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
2725603Skjc * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
2825603Skjc * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
2925603Skjc * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
3025603Skjc * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
3125603Skjc * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
3225603Skjc * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
3325603Skjc * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3425603Skjc */
3525603Skjc
3625603Skjc/*
3725603Skjc * natm.h: native mode atm
3825603Skjc */
3925603Skjc
4025603Skjc/*
4125603Skjc * supported protocols
4225603Skjc */
43118541Sharti#define	PROTO_NATMAAL0		1
44118541Sharti#define	PROTO_NATMAAL5		2
4525603Skjc
4625603Skjc/*
4725603Skjc * sockaddr_natm
4825603Skjc */
4925603Skjc
5025603Skjcstruct sockaddr_natm {
51118541Sharti	unsigned char	snatm_len;		/* length */
52118541Sharti	sa_family_t	snatm_family;		/* AF_NATM */
53118541Sharti	char		snatm_if[IFNAMSIZ];	/* interface name */
54118541Sharti	u_int16_t	snatm_vci;		/* vci */
55118541Sharti	u_int8_t	snatm_vpi;		/* vpi */
5625603Skjc};
5725603Skjc
5855205Speter#if defined(__FreeBSD__) && defined(_KERNEL)
5925603Skjc
60118541Sharti#define	SPLSOFTNET() splnet()
6125603Skjc
6225603Skjc#elif defined(__NetBSD__) || defined(__OpenBSD__)
6325603Skjc
64118541Sharti#define	SPLSOFTNET() splsoftnet()
6525603Skjc
6625603Skjc#endif
6725603Skjc
6825603Skjc#ifdef _KERNEL
6925603Skjc
7025603Skjc/*
7125603Skjc * natm protocol control block
7225603Skjc */
7325603Skjcstruct natmpcb {
74118541Sharti	LIST_ENTRY(natmpcb) pcblist;	/* list pointers */
75118541Sharti	u_int		npcb_inq;	/* # of our pkts in proto q */
76118541Sharti	struct socket	*npcb_socket;	/* backpointer to socket */
77118541Sharti	struct ifnet	*npcb_ifp;	/* pointer to hardware */
78118541Sharti	struct in_addr	ipaddr;		/* remote IP address, if APCB_IP */
79118541Sharti	u_int16_t	npcb_vci;	/* VCI */
80118541Sharti	u_int8_t	npcb_vpi;	/* VPI */
81118541Sharti	u_int8_t	npcb_flags;	/* flags */
8225603Skjc};
8325603Skjc
8425603Skjc/* flags */
85118541Sharti#define	NPCB_FREE	0x01		/* free (not on any list) */
86118541Sharti#define	NPCB_CONNECTED	0x02		/* connected */
87118541Sharti#define	NPCB_IP		0x04		/* used by IP */
88118541Sharti#define	NPCB_DRAIN	0x08		/* destory as soon as inq == 0 */
89118541Sharti#define	NPCB_RAW	0x10		/* in 'raw' mode? */
9025603Skjc
9125603Skjc/* flag arg to npcb_free */
92118541Sharti#define	NPCB_REMOVE	0		/* remove from global list */
93118541Sharti#define	NPCB_DESTROY	1		/* destroy and be free */
9425603Skjc
9525603Skjc/*
9625603Skjc * NPCB_RAWCC is a hack which applies to connections in 'raw' mode.   it
9725603Skjc * is used to override the sbspace() macro when you *really* don't want
9825603Skjc * to drop rcv data.   the recv socket buffer size is raised to this value.
9925603Skjc *
10025603Skjc * XXX: socket buffering needs to be looked at.
10125603Skjc */
102118541Sharti#define	NPCB_RAWCC (1024*1024)		/* 1MB */
10325603Skjc
10460938SjakeLIST_HEAD(npcblist, natmpcb);
10525603Skjc
10625603Skjc/* global data structures */
10725603Skjc
10831885Sbdeextern struct npcblist natm_pcbs;	/* global list of pcbs */
10925603Skjc#define	NATM_STAT
11025603Skjc#ifdef NATM_STAT
111118541Shartiextern	u_int	natm_sodropcnt;
112118541Shartiextern	u_int	natm_sodropbytes;	/* account of droppage */
113118541Shartiextern	u_int	natm_sookcnt;
114118541Shartiextern	u_int	natm_sookbytes;		/* account of ok */
11525603Skjc#endif
11625603Skjc
11725603Skjc/* atm_rawioctl: kernel's version of SIOCRAWATM [for internal use only!] */
11825603Skjcstruct atm_rawioctl {
11925603Skjc  struct natmpcb *npcb;
12025603Skjc  int rawvalue;
12125603Skjc};
122118541Sharti#define	SIOCXRAWATM     _IOWR('a', 125, struct atm_rawioctl)
12325603Skjc
12425603Skjc/* external functions */
12525603Skjc
12625603Skjc/* natm_pcb.c */
12792745Salfredstruct	natmpcb *npcb_alloc(int);
12892745Salfredvoid	npcb_free(struct natmpcb *, int);
129118541Shartistruct	natmpcb *npcb_add(struct natmpcb *, struct ifnet *, uint16_t, uint8_t);
13025603Skjc
13125603Skjc/* natm.c */
13225603Skjc#if defined(__NetBSD__) || defined(__OpenBSD__)
13392745Salfredint	natm_usrreq(struct socket *, int, struct mbuf *,
134118541Sharti	    struct mbuf *, struct mbuf *, struct proc *);
13525603Skjc#elif defined(__FreeBSD__)
13625603Skjc#if __FreeBSD__ > 2
13725603Skjc/*
13825603Skjc * FreeBSD new usrreqs style appeared since 2.2.  compatibility to old style
13925603Skjc * has gone since 3.0.
14025603Skjc */
141118541Sharti#define	FREEBSD_USRREQS
14225603Skjcextern struct pr_usrreqs natm_usrreqs;
14325603Skjc#else /* !( __FreeBSD__ > 2) */
14492745Salfredint	natm_usrreq(struct socket *, int, struct mbuf *,
145118541Sharti	    struct mbuf *, struct mbuf *);
14625603Skjc#endif /* !( __FreeBSD__ > 2) */
14725603Skjc#endif
148118541Sharti
149118541Sharti#ifdef SYSCTL_HANDLER_ARGS
150118541Shartiint	natm0_sysctl(SYSCTL_HANDLER_ARGS);
151118541Shartiint	natm5_sysctl(SYSCTL_HANDLER_ARGS);
152118541Sharti#endif
153118541Sharti
154111888Sjlemonvoid	natmintr(struct mbuf *);
15525603Skjc
15625603Skjc#endif
157