natm.h revision 31885
1/*	$NetBSD: natm.h,v 1.1 1996/07/04 03:20:12 chuck Exp $	*/
2
3/*
4 *
5 * Copyright (c) 1996 Charles D. Cranor and Washington University.
6 * All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 * 1. Redistributions of source code must retain the above copyright
12 *    notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 *    notice, this list of conditions and the following disclaimer in the
15 *    documentation and/or other materials provided with the distribution.
16 * 3. All advertising materials mentioning features or use of this software
17 *    must display the following acknowledgement:
18 *      This product includes software developed by Charles D. Cranor and
19 *      Washington University.
20 * 4. The name of the author may not be used to endorse or promote products
21 *    derived from this software without specific prior written permission.
22 *
23 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
24 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
25 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
26 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
27 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
28 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
29 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
30 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
32 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 */
34
35/*
36 * natm.h: native mode atm
37 */
38
39
40/*
41 * supported protocols
42 */
43
44#define PROTO_NATMAAL0		1
45#define PROTO_NATMAAL5		2
46
47/*
48 * sockaddr_natm
49 */
50
51struct sockaddr_natm {
52  u_int8_t	snatm_len;		/* length */
53  u_int8_t	snatm_family;		/* AF_NATM */
54  char		snatm_if[IFNAMSIZ];	/* interface name */
55  u_int16_t	snatm_vci;		/* vci */
56  u_int8_t	snatm_vpi;		/* vpi */
57};
58
59
60#if defined(__FreeBSD__) && defined(KERNEL)
61
62#ifndef _KERNEL
63#define _KERNEL
64#endif
65
66#define SPLSOFTNET() splnet()
67
68#elif defined(__NetBSD__) || defined(__OpenBSD__)
69
70#define SPLSOFTNET() splsoftnet()
71
72#endif
73
74#ifdef _KERNEL
75
76/*
77 * natm protocol control block
78 */
79
80struct natmpcb {
81  LIST_ENTRY(natmpcb) pcblist;		/* list pointers */
82  u_int	npcb_inq;			/* # of our pkts in proto q */
83  struct socket	*npcb_socket;		/* backpointer to socket */
84  struct ifnet *npcb_ifp;		/* pointer to hardware */
85  struct in_addr ipaddr;		/* remote IP address, if APCB_IP */
86  u_int16_t npcb_vci;			/* VCI */
87  u_int8_t npcb_vpi;			/* VPI */
88  u_int8_t npcb_flags;			/* flags */
89};
90
91/* flags */
92#define NPCB_FREE	0x01		/* free (not on any list) */
93#define NPCB_CONNECTED	0x02		/* connected */
94#define NPCB_IP		0x04		/* used by IP */
95#define NPCB_DRAIN	0x08		/* destory as soon as inq == 0 */
96#define NPCB_RAW	0x10		/* in 'raw' mode? */
97
98/* flag arg to npcb_free */
99#define NPCB_REMOVE	0		/* remove from global list */
100#define NPCB_DESTROY	1		/* destroy and be free */
101
102/*
103 * NPCB_RAWCC is a hack which applies to connections in 'raw' mode.   it
104 * is used to override the sbspace() macro when you *really* don't want
105 * to drop rcv data.   the recv socket buffer size is raised to this value.
106 *
107 * XXX: socket buffering needs to be looked at.
108 */
109
110#define NPCB_RAWCC (1024*1024)		/* 1MB */
111
112LIST_HEAD(npcblist, natmpcb);
113
114/* global data structures */
115
116extern struct npcblist natm_pcbs;	/* global list of pcbs */
117extern	struct ifqueue natmintrq;	/* natm packet input queue */
118#define	NATM_STAT
119#ifdef NATM_STAT
120extern	u_int natm_sodropcnt,
121		natm_sodropbytes;	/* account of droppage */
122extern	u_int natm_sookcnt,
123		natm_sookbytes;		/* account of ok */
124#endif
125
126/* atm_rawioctl: kernel's version of SIOCRAWATM [for internal use only!] */
127struct atm_rawioctl {
128  struct natmpcb *npcb;
129  int rawvalue;
130};
131#define SIOCXRAWATM     _IOWR('a', 125, struct atm_rawioctl)
132
133/* external functions */
134
135/* natm_pcb.c */
136struct	natmpcb *npcb_alloc __P((int));
137void	npcb_free __P((struct natmpcb *, int));
138struct	natmpcb *npcb_add __P((struct natmpcb *, struct ifnet *, int, int));
139
140/* natm.c */
141#if defined(__NetBSD__) || defined(__OpenBSD__)
142int	natm_usrreq __P((struct socket *, int, struct mbuf *,
143                             struct mbuf *, struct mbuf *, struct proc *));
144#elif defined(__FreeBSD__)
145#if __FreeBSD__ > 2
146/*
147 * FreeBSD new usrreqs style appeared since 2.2.  compatibility to old style
148 * has gone since 3.0.
149 */
150#define FREEBSD_USRREQS
151extern struct pr_usrreqs natm_usrreqs;
152#else /* !( __FreeBSD__ > 2) */
153int	natm_usrreq __P((struct socket *, int, struct mbuf *,
154                             struct mbuf *, struct mbuf *));
155#endif /* !( __FreeBSD__ > 2) */
156#endif
157int	natm0_sysctl __P((int *, u_int, void *, size_t *, void *, size_t));
158int	natm5_sysctl __P((int *, u_int, void *, size_t *, void *, size_t));
159void	natmintr __P((void));
160
161#endif
162