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