Initial import from FreeBSD RELENG_4:
[dragonfly.git] / sys / netproto / atm / atm_cm.h
1 /*
2  *
3  * ===================================
4  * HARP  |  Host ATM Research Platform
5  * ===================================
6  *
7  *
8  * This Host ATM Research Platform ("HARP") file (the "Software") is
9  * made available by Network Computing Services, Inc. ("NetworkCS")
10  * "AS IS".  NetworkCS does not provide maintenance, improvements or
11  * support of any kind.
12  *
13  * NETWORKCS MAKES NO WARRANTIES OR REPRESENTATIONS, EXPRESS OR IMPLIED,
14  * INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY
15  * AND FITNESS FOR A PARTICULAR PURPOSE, AS TO ANY ELEMENT OF THE
16  * SOFTWARE OR ANY SUPPORT PROVIDED IN CONNECTION WITH THIS SOFTWARE.
17  * In no event shall NetworkCS be responsible for any damages, including
18  * but not limited to consequential damages, arising from or relating to
19  * any use of the Software or related support.
20  *
21  * Copyright 1994-1998 Network Computing Services, Inc.
22  *
23  * Copies of this Software may be made, however, the above copyright
24  * notice must be reproduced on all copies.
25  *
26  *      @(#) $FreeBSD: src/sys/netatm/atm_cm.h,v 1.2 1999/08/28 00:48:35 peter Exp $
27  *
28  */
29
30 /*
31  * Core ATM Services
32  * -----------------
33  *
34  * ATM Connection Management definitions
35  *
36  */
37
38 #ifndef _NETATM_ATM_CM_H
39 #define _NETATM_ATM_CM_H
40
41 /*
42  * Forward declaration
43  */
44 struct atm_connection;
45 struct atm_attributes;
46
47
48 #ifdef ATM_KERNEL
49 /*
50  * Structure used to define a kernel ATM endpoint service module and its 
51  * associated entry points.  An endpoint service is defined as a kernel 
52  * entity which will serve as the endpoint of an ATM connection, i.e. it is
53  * responsible for issuing/receiving requests to/from the connection manager.
54  */
55 struct atm_endpoint {
56         struct atm_endpoint *ep_next;   /* Next in registry list */
57         u_int           ep_id;          /* Endpoint ID (see below) */
58
59 /* Exported functions: Miscellaneous */
60         int             (*ep_ioctl)     /* Ioctl */
61                                 __P((int, caddr_t, caddr_t));
62         caddr_t         (*ep_getname)   /* Get application/owner name */
63                                 __P((void *));
64
65 /* Exported functions: Connection Manager Control API */
66         void            (*ep_connected) /* Call connected */
67                                 __P((void *));
68         void            (*ep_cleared)   /* Call cleared */
69                                 __P((void *, struct t_atm_cause *));
70         int             (*ep_incoming)  /* Incoming call */
71                                 __P((void *, struct atm_connection *,
72                                         struct atm_attributes *, void **));
73         int             (*ep_addparty)  /* Add Party notification */
74                                 __P((void *, int, int));
75         int             (*ep_dropparty) /* Drop Party notification */
76                                 __P((void *, int, int));
77
78 /* Exported functions: Connection Manager Data API: CPCS */ 
79         void            (*ep_cpcs_ctl)  /* Control operation */
80                                 __P((int, void *, void *));
81         void            (*ep_cpcs_data) /* Received data */
82                                 __P((void *, KBuffer *));
83
84 /* Exported functions: Connection Manager Data API: SAAL */ 
85         void            (*ep_saal_ctl)  /* Control operation */
86                                 __P((int, void *, void *));
87         void            (*ep_saal_data) /* Received data */
88                                 __P((void *, KBuffer *));
89
90 /* Exported functions: Connection Manager Data API: SSCOP */ 
91         void            (*ep_sscop_ctl) /* Control operation */
92                                 __P((int, void *, void *, void *));
93         void            (*ep_sscop_data)        /* Received data */
94                                 __P((void *, KBuffer *, u_int));
95 };
96 typedef struct atm_endpoint     Atm_endpoint;
97 #endif  /* ATM_KERNEL */
98
99 /*
100  * Endpoint IDs
101  */
102 #define ENDPT_UNKNOWN           0       /* Unknown */
103 #define ENDPT_IP                1       /* IP over ATM */
104 #define ENDPT_ATMARP            2       /* ATMARP */
105 #define ENDPT_SPANS_SIG         3       /* SPANS Signalling */
106 #define ENDPT_SPANS_CLS         4       /* SPANS CLS */
107 #define ENDPT_UNI_SIG           5       /* UNI Signalling */
108 #define ENDPT_SOCK_AAL5         6       /* Socket - AAL5 */
109 #define ENDPT_SOCK_SSCOP        7       /* Socket - SSCOP */
110 #define ENDPT_MAX               7
111
112
113 /*
114  * ATM Connection Attributes
115  *
116  * Note: Attribute tag values are the same as the SVE_tag values.
117  *       Unless otherwise specified, attribute field values are the same 
118  *       as the corresponding socket option values.
119  *       The above values are all defined in netatm/atm.h.  
120  */
121
122 /* AAL Attributes */
123 struct t_atm_aal4 {
124         int32_t         forward_max_SDU_size;
125         int32_t         backward_max_SDU_size;
126         int32_t         SSCS_type;
127         int32_t         mid_low;
128         int32_t         mid_high;
129 };
130
131 struct attr_aal {
132         int             tag;            /* Attribute tag */
133         Aal_t           type;           /* AAL type (discriminator) */
134         union {
135                 struct t_atm_aal4 aal4;
136                 struct t_atm_aal5 aal5;
137         } v;                            /* Attribute value */
138 };
139
140 /* Traffic Descriptor Attributes */
141 struct attr_traffic {
142         int             tag;            /* Attribute tag */
143         struct t_atm_traffic    v;      /* Attribute value */
144 };
145
146 /* Broadband Bearer Attributes */
147 struct attr_bearer {
148         int             tag;            /* Attribute tag */
149         struct t_atm_bearer     v;      /* Attribute value */
150 };
151
152 /* Broadband High Layer Information Attributes */
153 struct attr_bhli {
154         int             tag;            /* Attribute tag */
155         struct t_atm_bhli       v;      /* Attribute value */
156 };
157
158 /* Broadband Low Layer Information Attributes */
159 struct attr_blli {
160         int             tag_l2;         /* Layer 2 attribute tag */
161         int             tag_l3;         /* Layer 3 attribute tag */
162         struct t_atm_blli       v;      /* Attribute value */
163 };
164
165 /* Logical Link Control Attributes (multiplexing use only, not signalled) */
166 struct attr_llc {
167         int             tag;            /* Attribute tag */
168         struct t_atm_llc        v;      /* Attribute value */
169 };
170
171 /* Called Party Attributes */
172 struct attr_called {
173         int             tag;            /* Attribute tag */
174         Atm_addr        addr;           /* Called party address */
175         Atm_addr        subaddr;        /* Called party subaddress */
176 };
177
178 /* Calling Party Attributes */
179 struct attr_calling {
180         int             tag;            /* Attribute tag */
181         Atm_addr        addr;           /* Calling party address */
182         Atm_addr        subaddr;        /* Calling party subaddress */
183         struct t_atm_caller_id  cid;    /* Caller ID */
184 };
185
186 /* Quality of Service Attributes */
187 struct attr_qos {
188         int             tag;            /* Attribute tag */
189         struct t_atm_qos        v;      /* Attribute value */
190 };
191
192 /* Transit Network Attributes */
193 struct attr_transit {
194         int             tag;            /* Attribute tag */
195         struct t_atm_transit    v;      /* Attribute value */
196 };
197
198 /* Cause Attributes */
199 struct attr_cause {
200         int             tag;            /* Attribute tag */
201         struct t_atm_cause      v;      /* Attribute value */
202 };
203
204
205 struct atm_attributes {
206         struct atm_nif          *nif;   /* Network interface */
207         u_int                   api;    /* Connect Mgr Data API (see below) */
208         int                     api_init;/* API initialization parameter */
209         u_short                 headin; /* Input buffer headroom */
210         u_short                 headout;/* Output buffer headroom */
211         struct attr_aal         aal;    /* AAL attributes */
212         struct attr_traffic     traffic;/* Traffic descriptor attributes */
213         struct attr_bearer      bearer; /* Broadband bearer attributes */
214         struct attr_bhli        bhli;   /* Broadband high layer attributes */
215         struct attr_blli        blli;   /* Broadband low layer attributes */
216         struct attr_llc         llc;    /* Logical link control attributes */
217         struct attr_called      called; /* Called party attributes */
218         struct attr_calling     calling;/* Calling party attributes */
219         struct attr_qos         qos;    /* Quality of service attributes */
220         struct attr_transit     transit;/* Transit network attributes */
221         struct attr_cause       cause;  /* Cause attributes */
222 };
223 typedef struct atm_attributes   Atm_attributes;
224
225 /*
226  * Connection Manager Data APIs
227  */
228 #define CMAPI_CPCS      0               /* AAL CPCS */
229 #define CMAPI_SAAL      1               /* Signalling AAL */
230 #define CMAPI_SSCOP     2               /* Reliable data (SSCOP) */
231
232
233 #ifdef ATM_KERNEL
234 /*
235  * ATM Connection Instance
236  *
237  * There will be one connection block for each endpoint <-> Connection Manager 
238  * API instance.  Note that with connection multiplexors (e.g. LLC), there 
239  * may be multiple connections per VCC.
240  */
241 struct atm_connection {
242         struct atm_connection *co_next; /* Multiplexor/listen queue link */
243         struct atm_connection *co_mxh;  /* Connection multiplexor head */
244         u_char          co_flags;       /* Connection flags (see below) */
245         u_char          co_state;       /* User <-> CM state (see below) */
246         Encaps_t        co_mpx;         /* Multiplexor type */
247         void            *co_toku;       /* Endpoint's session token */
248         Atm_endpoint    *co_endpt;      /* Endpoint service */
249         struct atm_connvc *co_connvc;   /* Connection VCC */
250         struct attr_llc co_llc;         /* Connection LLC header */
251         Atm_attributes  *co_lattr;      /* Listening attributes */
252 };
253 typedef struct atm_connection   Atm_connection;
254
255 /*
256  * Connection Flags
257  */
258 #define COF_P2P         0x01            /* Point-to-point */
259 #define COF_P2MP        0x02            /* Point-to-multipoint */
260
261 /*
262  * Endpoint <-> Connection Manager States
263  */
264 #define COS_FREE        0               /* Not allocated */
265 #define COS_OUTCONN     1               /* Outgoing connection pending */
266 #define COS_LISTEN      2               /* Listening for connection */
267 #define COS_INCONN      3               /* Incoming connection pending */
268 #define COS_INACCEPT    4               /* Incoming connection accepted */
269 #define COS_ACTIVE      5               /* Connection active */
270 #define COS_CLEAR       6               /* Connection is clearing */
271
272
273 /*
274  * ATM Connection VCC Instance
275  *
276  * There will be one connection-vcc block for each VCC created by the
277  * Connection Manager. For multiplexed connections, there may be multiple
278  * connection blocks associated with each connection-vcc.  This block is
279  * used to control the Connection Manager <-> VCC interface, including the 
280  * interfaces to stack management and the signalling manager.
281  */
282 struct atm_connvc {
283         Qelem_t         cvc_q;          /* Queueing links */
284         Atm_connection  *cvc_conn;      /* Connection head */
285         struct vccb     *cvc_vcc;       /* VCC for connection */
286         struct sigmgr   *cvc_sigmgr;    /* VCC signalling manager */
287         u_char          cvc_flags;      /* Connection flags (see below) */
288         u_char          cvc_state;      /* CM - VCC state (see below) */
289         void            *cvc_tokl;      /* Stack lower layer token */
290         void            (*cvc_lower)    /* Stack lower layer handler */
291                                 __P((int, void *, int, int));
292         u_short         cvc_upcnt;      /* Up stack calls in progress */
293         u_short         cvc_downcnt;    /* Down stack calls in progress */
294         KBuffer         *cvc_rcvq;      /* Packet receive queue */
295         int             cvc_rcvqlen;    /* Receive queue length */
296         Atm_attributes  cvc_attr;       /* VCC attributes */
297         struct atm_time cvc_time;       /* Timer controls */
298 };
299 typedef struct atm_connvc       Atm_connvc;
300
301 /*
302  * Connection Flags
303  */
304 #define CVCF_ABORTING   0x01            /* VCC abort is pending */
305 #define CVCF_INCOMQ     0x02            /* VCC is on incoming queue */
306 #define CVCF_CONNQ      0x04            /* VCC is on connection queue */
307 #define CVCF_CALLER     0x08            /* We are the call originator */
308
309 /*
310  * Connection Manager <-> VCC States
311  */
312 #define CVCS_FREE       0               /* Not allocated */
313 #define CVCS_SETUP      1               /* Call setup pending */
314 #define CVCS_INIT       2               /* Stack INIT pending */
315 #define CVCS_INCOMING   3               /* Incoming call present */
316 #define CVCS_ACCEPT     4               /* Incoming call accepted */
317 #define CVCS_REJECT     5               /* Incoming call rejected */
318 #define CVCS_ACTIVE     6               /* Stack active */
319 #define CVCS_RELEASE    7               /* Connection release pending */
320 #define CVCS_CLEAR      8               /* Call has been cleared */
321 #define CVCS_TERM       9               /* Stack TERM pending */
322
323
324 /*
325  * Connection VCC variables
326  */
327 #define CVC_RCVQ_MAX    3               /* Max length of receive queue */
328
329
330 /*
331  * Timer macros
332  */
333 #define CVC_TIMER(s, t)         atm_timeout(&(s)->cvc_time, (t), atm_cm_timeout)
334 #define CVC_CANCEL(s)           atm_untimeout(&(s)->cvc_time)
335
336
337 /*
338  * Connection Manager Statistics
339  */
340 struct atm_cm_stat {
341         u_long          cms_llcdrop;    /* Packets dropped by llc demux'ing */
342         u_long          cms_llcid;      /* Packets with unknown llc id */
343         u_long          cms_rcvconn;    /* Packets dropped, bad conn state */
344         u_long          cms_rcvconnvc;  /* Packets dropped, bad connvc state */
345 };
346 #endif  /* ATM_KERNEL */
347
348 #endif  /* _NETATM_ATM_CM_H */