Initial import from FreeBSD RELENG_4:
[dragonfly.git] / sys / netproto / atm / uni / unisig_var.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/uni/unisig_var.h,v 1.3 1999/08/28 00:49:09 peter Exp $
27  *
28  */
29
30 /*
31  * ATM Forum UNI 3.0/3.1 Signalling Manager
32  * ----------------------------------------
33  *
34  * Protocol control blocks
35  *
36  */
37
38 #ifndef _UNISIG_VAR_H
39 #define _UNISIG_VAR_H
40
41 #ifndef TRUE
42 #define TRUE    1
43 #define FALSE   0
44 #endif
45
46 #ifdef ATM_KERNEL
47 /*
48  * Structure containing state information for each UNI protocol
49  * instance.  There will be one instance for each ATM device interface
50  * using the UNI signalling manager.
51  */
52 struct  unisig {
53         struct siginst  us_inst;        /* Header */
54         struct atm_time us_time;        /* Timer controls */
55         void            (*us_lower)     /* Lower command handler */
56                                 __P((int, void *, int, int));
57         Atm_connection  *us_conn;       /* Signalling connection */
58         int             us_cref;        /* Call reference allocation */
59         u_int           us_retry;       /* Protocol retry count */
60         u_short         us_headout;     /* Headroom on sig ch output */
61         u_char          us_proto;       /* Signalling version */
62 };
63
64 #define us_next         us_inst.si_next
65 #define us_pif          us_inst.si_pif
66 #define us_addr         us_inst.si_addr
67 #define us_subaddr      us_inst.si_subaddr
68 #define us_vccq         us_inst.si_vccq
69 #define us_state        us_inst.si_state
70 #define us_ipserv       us_inst.si_ipserv
71 #endif  /* ATM_KERNEL */
72
73 /*
74  * Signalling manager states
75  */
76 #define UNISIG_NULL             0
77 #define UNISIG_ADDR_WAIT        1
78 #define UNISIG_INIT             2
79 #define UNISIG_ACTIVE           3
80 #define UNISIG_DETACH           4
81
82 /*
83  * Signalling manager events
84  */
85 #define UNISIG_SIGMGR_TIMEOUT           0
86 #define UNISIG_SIGMGR_SSCF_EST_IND      1
87 #define UNISIG_SIGMGR_SSCF_EST_CNF      2
88 #define UNISIG_SIGMGR_SSCF_RLS_IND      3
89 #define UNISIG_SIGMGR_SSCF_RLS_CNF      4
90 #define UNISIG_SIGMGR_SSCF_DATA_IND     5
91 #define UNISIG_SIGMGR_SSCF_UDATA_IND    6
92 #define UNISIG_SIGMGR_CALL_CLEARED      7
93 #define UNISIG_SIGMGR_DETACH            8
94 #define UNISIG_SIGMGR_ADDR_SET          9
95
96 /*
97  * Signalling manager timer values
98  */
99 #define UNISIG_SSCF_TIMEOUT     (3 * ATM_HZ)
100
101
102 #ifdef ATM_KERNEL
103 /*
104  * UNI Virtual Channel Connection control block.  All information
105  * regarding the state of a UNI-controlled VCC will be recorded here.
106  * There will be one UNI VCC control block for each UNI-controlled
107  * VCC.
108  */
109 struct unisig_vccb {
110         struct vccb     vcp_hdr;        /* Generic VCCB */
111         u_short         uv_retry;       /* Xmit retry count */
112         u_int           uv_call_ref;    /* Q.2931 call reference */
113 };
114
115 #define uv_type         vcp_hdr.vc_type
116 #define uv_proto        vcp_hdr.vc_proto
117 #define uv_sstate       vcp_hdr.vc_sstate
118 #define uv_ustate       vcp_hdr.vc_ustate
119 #define uv_pif          vcp_hdr.vc_pif
120 #define uv_nif          vcp_hdr.vc_nif
121 #define uv_sigelem      vcp_hdr.vc_sigelem
122 #define uv_time         vcp_hdr.vc_time
123 #define uv_vpi          vcp_hdr.vc_vpi
124 #define uv_vci          vcp_hdr.vc_vci
125 #define uv_connvc       vcp_hdr.vc_connvc
126 #define uv_ipdus        vcp_hdr.vc_ipdus
127 #define uv_opdus        vcp_hdr.vc_opdus
128 #define uv_ibytes       vcp_hdr.vc_ibytes
129 #define uv_obytes       vcp_hdr.vc_obytes
130 #define uv_ierrors      vcp_hdr.vc_ierrors
131 #define uv_oerrors      vcp_hdr.vc_oerrors
132 #define uv_tstamp       vcp_hdr.vc_tstamp
133 #endif  /* ATM_KERNEL */
134
135 /*
136  * UNI VCC protocol states.  Taken from The ATM Forum UNI 3.0 (section
137  * 5.2.1.1)
138  */
139 #define UNI_NULL                0       /* No call exists */
140 #define UNI_CALL_INITIATED      1       /* Initiating call */
141 #define UNI_CALL_OUT_PROC       3       /* Outgoing call proceeding */
142 #define UNI_CALL_DELIVERED      4       /* Not supported */
143 #define UNI_CALL_PRESENT        6       /* Call coming in */
144 #define UNI_CALL_RECEIVED       7       /* Not supported */
145 #define UNI_CONNECT_REQUEST     8       /* Call coming in */
146 #define UNI_CALL_IN_PROC        9       /* Incoming call proceeding */
147 #define UNI_ACTIVE              10      /* Call is established */
148 #define UNI_RELEASE_REQUEST     11      /* Clearing call */
149 #define UNI_RELEASE_IND         12      /* Network disconnecting */
150
151 /*
152  * Additional states required for internal management of VCCs
153  */
154 #define UNI_SSCF_RECOV          13      /* Signalling chan recovery */
155 #define UNI_FREE                14      /* Waiting for user to free */
156 #define UNI_PVC_ACTIVE          15      /* PVC Active */
157 #define UNI_PVC_ACT_DOWN        16      /* PVC Active - i/f down */
158
159 /*
160  * UNI VCC events
161  */
162 #define UNI_VC_TIMEOUT          0       /* Timer expired */
163 #define UNI_VC_CALLP_MSG        1       /* CALL PROCEEDING message */
164 #define UNI_VC_CONNECT_MSG      2       /* CONNECT message */
165 #define UNI_VC_CNCTACK_MSG      3       /* CONNECT ACK message */
166 #define UNI_VC_SETUP_MSG        4       /* SETUP message */
167 #define UNI_VC_RELEASE_MSG      5       /* RELEASE message */
168 #define UNI_VC_RLSCMP_MSG       6       /* RELEASE COMPLETE message */
169 #define UNI_VC_STATUS_MSG       7       /* STATUS message */
170 #define UNI_VC_STATUSENQ_MSG    8       /* STATUS ENQ message */
171 #define UNI_VC_ADDP_MSG         9       /* ADD PARTY message */
172 #define UNI_VC_ADDPACK_MSG      10      /* ADD PARTY ACK message */
173 #define UNI_VC_ADDPREJ_MSG      11      /* ADD PARTY REJ message */
174 #define UNI_VC_DROP_MSG         12      /* DROP PARTY message */
175 #define UNI_VC_DROPACK_MSG      13      /* DROP PARTY ACK message */
176 #define UNI_VC_SETUP_CALL       14      /* Setup routine called */
177 #define UNI_VC_ACCEPT_CALL      15      /* Accept call routine called */
178 #define UNI_VC_REJECT_CALL      16      /* Reject call routine called */
179 #define UNI_VC_RELEASE_CALL     17      /* Release routine called */
180 #define UNI_VC_ABORT_CALL       18      /* Abort routine called */
181 #define UNI_VC_SAAL_FAIL        19      /* Signalling AAL failed */
182 #define UNI_VC_SAAL_ESTAB       20      /* Signalling AAL back up */
183
184
185 #ifdef ATM_KERNEL
186 /*
187  * UNI Timer Values.  These values (except for T317) are taken from
188  * The ATM Forum UNI 3.0 (section 5.7.2).
189  */
190 #define UNI_T303        (4 * ATM_HZ)
191 #define UNI_T308        (30 * ATM_HZ)
192 #define UNI_T309        (10 * ATM_HZ)
193 #define UNI_T310        (10 * ATM_HZ)
194 #define UNI_T313        (4 * ATM_HZ)
195 #define UNI_T316        (120 * ATM_HZ)
196 #define UNI_T317        (60 * ATM_HZ)
197 #define UNI_T322        (4 * ATM_HZ)
198 #define UNI_T398        (4 * ATM_HZ)
199 #define UNI_T399        (14 * ATM_HZ)
200
201
202 /*
203  * Timer macros
204  */
205 #define UNISIG_TIMER(s, t)      atm_timeout(&(s)->us_time, (t), unisig_timer)
206 #define UNISIG_CANCEL(s)        atm_untimeout(&(s)->us_time)
207 #define UNISIG_VC_TIMER(v, t)   atm_timeout(&(v)->vc_time, (t), unisig_vctimer)
208 #define UNISIG_VC_CANCEL(v)     atm_untimeout(&(v)->vc_time)
209
210
211 /*
212  * Global function declarations
213  */
214 struct usfmt;
215 struct unisig_msg;
216
217         /* unisig_decode.c */
218 int             usf_dec_msg __P((struct usfmt *, struct unisig_msg *));
219
220         /* unisig_encode.c */
221 int             usf_enc_msg __P((struct usfmt *, struct unisig_msg *));
222
223         /* unisig_if.c */
224 int             unisig_start __P((void));
225 int             unisig_stop __P((void));
226 int             unisig_free __P((struct vccb *));
227
228         /* unisig_mbuf.c */
229 int             usf_init __P((struct usfmt *, struct unisig *, KBuffer *, int, int));
230 int             usf_byte __P((struct usfmt *, u_char *));
231 int             usf_short __P((struct usfmt *, u_short *));
232 int             usf_int3 __P((struct usfmt *, u_int *));
233 int             usf_int __P((struct usfmt *, u_int *));
234 int             usf_ext __P((struct usfmt *, u_int *));
235 int             usf_count __P((struct usfmt *));
236 int             usf_byte_mark __P((struct usfmt *, u_char *, u_char **));
237
238         /* unisig_msg.c */
239 struct          ie_generic;
240 void            unisig_cause_from_attr __P((struct ie_generic *,
241                                 Atm_attributes *));
242 void            unisig_cause_from_msg __P((struct ie_generic *,
243                                 struct unisig_msg *, int));
244 int             unisig_send_msg __P((struct unisig *,
245                                 struct unisig_msg *));
246 int             unisig_send_setup __P((struct unisig *,
247                                 struct unisig_vccb *));
248 int             unisig_send_release __P((struct unisig *,
249                                 struct unisig_vccb *,
250                                 struct unisig_msg *,
251                                 int));
252 int             unisig_send_release_complete __P((struct unisig *,
253                                 struct unisig_vccb *,
254                                 struct unisig_msg *,
255                                 int));
256 int             unisig_send_status __P((struct unisig *,
257                                 struct unisig_vccb *,
258                                 struct unisig_msg *,
259                                 int));
260 int             unisig_rcv_msg __P((struct unisig *, KBuffer *));
261
262         /* unisig_print.c */
263 void            usp_print_msg __P((struct unisig_msg *, int));
264
265         /* unisig_proto.c */
266 void            unisig_timer __P((struct atm_time *));
267 void            unisig_vctimer __P((struct atm_time *));
268 void            unisig_saal_ctl __P((int, void *, void *));
269 void            unisig_saal_data __P((void *, KBuffer *));
270 caddr_t         unisig_getname __P((void *));
271 void            unisig_connected __P((void *));
272 void            unisig_cleared __P((void *, struct t_atm_cause *));
273
274         /* unisig_sigmgr_state.c */
275 int             unisig_sigmgr_state __P((struct unisig *, int,
276                                 KBuffer *));
277
278         /* unisig_subr.c */
279 void            unisig_cause_attr_from_user __P((Atm_attributes *, int));
280 void            unisig_cause_attr_from_ie __P((Atm_attributes *,
281                                 struct ie_generic *));
282 int             unisig_open_vcc __P((struct unisig *, Atm_connvc *));
283 int             unisig_close_vcc __P((struct unisig *,
284                                 struct unisig_vccb *));
285 int             unisig_clear_vcc __P((struct unisig *,
286                                 struct unisig_vccb *, int));
287 void            unisig_switch_reset __P((struct unisig *, int));
288 void            unisig_save_attrs __P((struct unisig *, struct unisig_msg *,
289                                 Atm_attributes *));
290 int             unisig_set_attrs __P((struct unisig *, struct unisig_msg *,
291                                 Atm_attributes *));
292
293         /* unisig_util.c */
294 void            unisig_free_msg __P((struct unisig_msg *));
295 int             unisig_verify_vccb __P((struct unisig *,
296                                 struct unisig_vccb *));
297 struct unisig_vccb *
298                 unisig_find_conn __P((struct unisig *, u_int));
299 struct unisig_vccb *
300                 unisig_find_vpvc __P((struct unisig *, int, int,
301                                 u_char));
302 int             unisig_alloc_call_ref __P((struct unisig *));
303 char *          unisig_addr_print __P((Atm_addr *));
304 void            unisig_print_mbuf __P((KBuffer *));
305 void            unisig_print_buffer __P((KBuffer *));
306
307         /* unisig_vc_state.c */
308 int             unisig_vc_state __P((struct unisig *,
309                                 struct unisig_vccb *,
310                                 int,
311                                 struct unisig_msg *));
312
313
314 /*
315  * External variables
316  */
317 extern struct sp_info   unisig_vcpool;
318 extern struct sp_info   unisig_msgpool;
319 extern struct sp_info   unisig_iepool;
320
321 #endif  /* ATM_KERNEL */
322
323 #endif  /* _UNISIG_VAR_H */