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