3 * ===================================
4 * HARP | Host ATM Research Platform
5 * ===================================
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.
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.
21 * Copyright 1994-1998 Network Computing Services, Inc.
23 * Copies of this Software may be made, however, the above copyright
24 * notice must be reproduced on all copies.
26 * @(#) $FreeBSD: src/sys/netatm/uni/unisig_decode.c,v 1.5 2000/01/17 20:49:56 mks Exp $
27 * @(#) $DragonFly: src/sys/netproto/atm/uni/unisig_decode.c,v 1.6 2006/01/14 13:36:39 swildner Exp $
31 * ATM Forum UNI 3.0/3.1 Signalling Manager
32 * ----------------------------------------
34 * Message formatting module
38 #include <netproto/atm/kern_include.h>
40 #include "unisig_var.h"
41 #include "unisig_msg.h"
42 #include "unisig_mbuf.h"
43 #include "unisig_decode.h"
45 #define ALLOC_IE(ie) \
46 (ie) = (struct ie_generic *) atm_allocate(&unisig_iepool); \
54 static int usf_dec_ie (struct usfmt *, struct unisig_msg *, struct ie_generic *);
55 static int usf_dec_ie_hdr (struct usfmt *, struct ie_generic *);
56 static int usf_dec_ie_aalp (struct usfmt *, struct ie_generic *);
57 static int usf_dec_ie_clrt (struct usfmt *, struct ie_generic *);
58 static int usf_dec_ie_bbcp (struct usfmt *, struct ie_generic *);
59 static int usf_dec_ie_bhli (struct usfmt *, struct ie_generic *);
60 static int usf_dec_ie_blli (struct usfmt *, struct ie_generic *);
61 static int usf_dec_ie_clst (struct usfmt *, struct ie_generic *);
62 static int usf_dec_ie_cdad (struct usfmt *, struct ie_generic *);
63 static int usf_dec_ie_cdsa (struct usfmt *, struct ie_generic *);
64 static int usf_dec_ie_cgad (struct usfmt *, struct ie_generic *);
65 static int usf_dec_ie_cgsa (struct usfmt *, struct ie_generic *);
66 static int usf_dec_ie_caus (struct usfmt *, struct ie_generic *);
67 static int usf_dec_ie_cnid (struct usfmt *, struct ie_generic *);
68 static int usf_dec_ie_qosp (struct usfmt *, struct ie_generic *);
69 static int usf_dec_ie_brpi (struct usfmt *, struct ie_generic *);
70 static int usf_dec_ie_rsti (struct usfmt *, struct ie_generic *);
71 static int usf_dec_ie_bsdc (struct usfmt *, struct ie_generic *);
72 static int usf_dec_ie_trnt (struct usfmt *, struct ie_generic *);
73 static int usf_dec_ie_uimp (struct usfmt *, struct ie_generic *);
74 static int usf_dec_ie_ident (struct usfmt *, struct ie_generic *,
75 struct ie_decode_tbl *);
76 static int usf_dec_atm_addr (struct usfmt *, Atm_addr *, int);
80 * Table associating IE type with IE vector index
82 u_char unisig_ie_ident_vec[] = {
108 * Tables specifying which IEs are mandatory, optional, and
109 * not allowed for each Q.2931 message type
111 static u_char uni_calp_ie_tbl[] = {
112 IE_NA, /* ATM AAL Parameters */
113 IE_NA, /* ATM User Cell Rate */
114 IE_NA, /* Broadband Bearer Capability */
115 IE_NA, /* Broadband High Layer Information */
116 IE_NA, /* Broadband Low Layer Information */
117 IE_NA, /* Call State */
118 IE_NA, /* Called Party Number */
119 IE_NA, /* Called Party Subaddress */
120 IE_NA, /* Calling Party Number */
121 IE_NA, /* Calling Party Subaddress */
123 IE_OPT, /* Connection Identifier */
124 IE_NA, /* Quality of Service Parameters */
125 IE_NA, /* Broadband Repeat Indicator */
126 IE_NA, /* Restart Indicator */
127 IE_NA, /* Broadband Locking Shift */
128 IE_NA, /* Broadband Non-locking Shift */
129 IE_NA, /* Broadband Sending Complete */
130 IE_NA, /* Transit Net */
131 IE_OPT, /* Endpoint Reference */
132 IE_NA /* Endpoint State */
135 static u_char uni_conn_ie_tbl[] = {
136 IE_OPT, /* ATM AAL Parameters */
137 IE_NA, /* ATM User Cell Rate */
138 IE_NA, /* Broadband Bearer Capability */
139 IE_NA, /* Broadband High Layer Information */
140 IE_OPT, /* Broadband Low Layer Information */
141 IE_NA, /* Call State */
142 IE_NA, /* Called Party Number */
143 IE_NA, /* Called Party Subaddress */
144 IE_NA, /* Calling Party Number */
145 IE_NA, /* Calling Party Subaddress */
147 IE_OPT, /* Connection Identifier */
148 IE_NA, /* Quality of Service Parameters */
149 IE_NA, /* Broadband Repeat Indicator */
150 IE_NA, /* Restart Indicator */
151 IE_NA, /* Broadband Locking Shift */
152 IE_NA, /* Broadband Non-locking Shift */
153 IE_NA, /* Broadband Sending Complete */
154 IE_NA, /* Transit Net */
155 IE_OPT, /* Endpoint Reference */
156 IE_NA /* Endpoint State */
159 static u_char uni_cack_ie_tbl[] = {
160 IE_NA, /* ATM AAL Parameters */
161 IE_NA, /* ATM User Cell Rate */
162 IE_NA, /* Broadband Bearer Capability */
163 IE_NA, /* Broadband High Layer Information */
164 IE_NA, /* Broadband Low Layer Information */
165 IE_NA, /* Call State */
166 IE_NA, /* Called Party Number */
167 IE_NA, /* Called Party Subaddress */
168 IE_NA, /* Calling Party Number */
169 IE_NA, /* Calling Party Subaddress */
171 IE_NA, /* Connection Identifier */
172 IE_NA, /* Quality of Service Parameters */
173 IE_NA, /* Broadband Repeat Indicator */
174 IE_NA, /* Restart Indicator */
175 IE_NA, /* Broadband Locking Shift */
176 IE_NA, /* Broadband Non-locking Shift */
177 IE_NA, /* Broadband Sending Complete */
178 IE_NA, /* Transit Net */
179 IE_NA, /* Endpoint Reference */
180 IE_NA /* Endpoint State */
183 static u_char uni_setu_ie_tbl[] = {
184 IE_MAND, /* ATM AAL Parameters (not required by
186 IE_MAND, /* ATM User Cell Rate */
187 IE_MAND, /* Broadband Bearer Capability */
188 IE_OPT, /* Broadband High Layer Information */
189 IE_MAND, /* Broadband Low Layer Information (not required by UNI 3.0 */
190 IE_NA, /* Call State */
191 IE_MAND, /* Called Party Number */
192 IE_OPT, /* Called Party Subaddress */
193 IE_OPT, /* Calling Party Number */
194 IE_OPT, /* Calling Party Subaddress */
196 IE_MAND, /* Connection Identifier */
197 IE_MAND, /* Quality of Service Parameters */
198 IE_OPT, /* Broadband Repeat Indicator */
199 IE_NA, /* Restart Indicator */
200 IE_NA, /* Broadband Locking Shift */
201 IE_NA, /* Broadband Non-locking Shift */
202 IE_OPT, /* Broadband Sending Complete */
203 IE_NA, /* Transit Net */
204 IE_OPT, /* Endpoint Reference */
205 IE_NA /* Endpoint State */
208 static u_char uni_rlse_ie_tbl[] = {
209 IE_NA, /* ATM AAL Parameters */
210 IE_NA, /* ATM User Cell Rate */
211 IE_NA, /* Broadband Bearer Capability */
212 IE_NA, /* Broadband High Layer Information */
213 IE_NA, /* Broadband Low Layer Information */
214 IE_NA, /* Call State */
215 IE_NA, /* Called Party Number */
216 IE_NA, /* Called Party Subaddress */
217 IE_NA, /* Calling Party Number */
218 IE_NA, /* Calling Party Subaddress */
220 IE_NA, /* Connection Identifier */
221 IE_NA, /* Quality of Service Parameters */
222 IE_NA, /* Broadband Repeat Indicator */
223 IE_NA, /* Restart Indicator */
224 IE_NA, /* Broadband Locking Shift */
225 IE_NA, /* Broadband Non-locking Shift */
226 IE_NA, /* Broadband Sending Complete */
227 IE_NA, /* Transit Net */
228 IE_NA, /* Endpoint Reference */
229 IE_NA /* Endpoint State */
232 static u_char uni_rlsc_ie_tbl[] = {
233 IE_NA, /* ATM AAL Parameters */
234 IE_NA, /* ATM User Cell Rate */
235 IE_NA, /* Broadband Bearer Capability */
236 IE_NA, /* Broadband High Layer Information */
237 IE_NA, /* Broadband Low Layer Information */
238 IE_NA, /* Call State */
239 IE_NA, /* Called Party Number */
240 IE_NA, /* Called Party Subaddress */
241 IE_NA, /* Calling Party Number */
242 IE_NA, /* Calling Party Subaddress */
244 IE_NA, /* Connection Identifier */
245 IE_NA, /* Quality of Service Parameters */
246 IE_NA, /* Broadband Repeat Indicator */
247 IE_NA, /* Restart Indicator */
248 IE_NA, /* Broadband Locking Shift */
249 IE_NA, /* Broadband Non-locking Shift */
250 IE_NA, /* Broadband Sending Complete */
251 IE_NA, /* Transit Net */
252 IE_NA, /* Endpoint Reference */
253 IE_NA /* Endpoint State */
256 static u_char uni_rstr_ie_tbl[] = {
257 IE_NA, /* ATM AAL Parameters */
258 IE_NA, /* ATM User Cell Rate */
259 IE_NA, /* Broadband Bearer Capability */
260 IE_NA, /* Broadband High Layer Information */
261 IE_NA, /* Broadband Low Layer Information */
262 IE_NA, /* Call State */
263 IE_NA, /* Called Party Number */
264 IE_NA, /* Called Party Subaddress */
265 IE_NA, /* Calling Party Number */
266 IE_NA, /* Calling Party Subaddress */
268 IE_OPT, /* Connection Identifier */
269 IE_NA, /* Quality of Service Parameters */
270 IE_NA, /* Broadband Repeat Indicator */
271 IE_MAND, /* Restart Indicator */
272 IE_NA, /* Broadband Locking Shift */
273 IE_NA, /* Broadband Non-locking Shift */
274 IE_NA, /* Broadband Sending Complete */
275 IE_NA, /* Transit Net */
276 IE_NA, /* Endpoint Reference */
277 IE_NA /* Endpoint State */
280 static u_char uni_rsta_ie_tbl[] = {
281 IE_NA, /* ATM AAL Parameters */
282 IE_NA, /* ATM User Cell Rate */
283 IE_NA, /* Broadband Bearer Capability */
284 IE_NA, /* Broadband High Layer Information */
285 IE_NA, /* Broadband Low Layer Information */
286 IE_NA, /* Call State */
287 IE_NA, /* Called Party Number */
288 IE_NA, /* Called Party Subaddress */
289 IE_NA, /* Calling Party Number */
290 IE_NA, /* Calling Party Subaddress */
292 IE_OPT, /* Connection Identifier */
293 IE_NA, /* Quality of Service Parameters */
294 IE_NA, /* Broadband Repeat Indicator */
295 IE_MAND, /* Restart Indicator */
296 IE_NA, /* Broadband Locking Shift */
297 IE_NA, /* Broadband Non-locking Shift */
298 IE_NA, /* Broadband Sending Complete */
299 IE_NA, /* Transit Net */
300 IE_NA, /* Endpoint Reference */
301 IE_NA /* Endpoint State */
304 static u_char uni_stat_ie_tbl[] = {
305 IE_NA, /* ATM AAL Parameters */
306 IE_NA, /* ATM User Cell Rate */
307 IE_NA, /* Broadband Bearer Capability */
308 IE_NA, /* Broadband High Layer Information */
309 IE_NA, /* Broadband Low Layer Information */
310 IE_MAND, /* Call State */
311 IE_NA, /* Called Party Number */
312 IE_NA, /* Called Party Subaddress */
313 IE_NA, /* Calling Party Number */
314 IE_NA, /* Calling Party Subaddress */
316 IE_NA, /* Connection Identifier */
317 IE_NA, /* Quality of Service Parameters */
318 IE_NA, /* Broadband Repeat Indicator */
319 IE_NA, /* Restart Indicator */
320 IE_NA, /* Broadband Locking Shift */
321 IE_NA, /* Broadband Non-locking Shift */
322 IE_NA, /* Broadband Sending Complete */
323 IE_NA, /* Transit Net */
324 IE_OPT, /* Endpoint Reference */
325 IE_OPT /* Endpoint State */
328 static u_char uni_senq_ie_tbl[] = {
329 IE_NA, /* ATM AAL Parameters */
330 IE_NA, /* ATM User Cell Rate */
331 IE_NA, /* Broadband Bearer Capability */
332 IE_NA, /* Broadband High Layer Information */
333 IE_NA, /* Broadband Low Layer Information */
334 IE_NA, /* Call State */
335 IE_NA, /* Called Party Number */
336 IE_NA, /* Called Party Subaddress */
337 IE_NA, /* Calling Party Number */
338 IE_NA, /* Calling Party Subaddress */
340 IE_NA, /* Connection Identifier */
341 IE_NA, /* Quality of Service Parameters */
342 IE_NA, /* Broadband Repeat Indicator */
343 IE_NA, /* Restart Indicator */
344 IE_NA, /* Broadband Locking Shift */
345 IE_NA, /* Broadband Non-locking Shift */
346 IE_NA, /* Broadband Sending Complete */
347 IE_NA, /* Transit Net */
348 IE_OPT, /* Endpoint Reference */
349 IE_NA /* Endpoint State */
352 static u_char uni_addp_ie_tbl[] = {
353 IE_OPT, /* ATM AAL Parameters */
354 IE_NA, /* ATM User Cell Rate */
355 IE_NA, /* Broadband Bearer Capability */
356 IE_OPT, /* Broadband High Layer Information */
357 IE_OPT, /* Broadband Low Layer Information */
358 IE_NA, /* Call State */
359 IE_MAND, /* Called Party Number */
360 IE_OPT, /* Called Party Subaddress */
361 IE_OPT, /* Calling Party Number */
362 IE_OPT, /* Calling Party Subaddress */
364 IE_NA, /* Connection Identifier */
365 IE_NA, /* Quality of Service Parameters */
366 IE_NA, /* Broadband Repeat Indicator */
367 IE_NA, /* Restart Indicator */
368 IE_NA, /* Broadband Locking Shift */
369 IE_NA, /* Broadband Non-locking Shift */
370 IE_OPT, /* Broadband Sending Complete */
371 IE_NA, /* Transit Net */
372 IE_MAND, /* Endpoint Reference */
373 IE_NA /* Endpoint State */
376 static u_char uni_adpa_ie_tbl[] = {
377 IE_NA, /* ATM AAL Parameters */
378 IE_NA, /* ATM User Cell Rate */
379 IE_NA, /* Broadband Bearer Capability */
380 IE_NA, /* Broadband High Layer Information */
381 IE_NA, /* Broadband Low Layer Information */
382 IE_NA, /* Call State */
383 IE_NA, /* Called Party Number */
384 IE_NA, /* Called Party Subaddress */
385 IE_NA, /* Calling Party Number */
386 IE_NA, /* Calling Party Subaddress */
388 IE_NA, /* Connection Identifier */
389 IE_NA, /* Quality of Service Parameters */
390 IE_NA, /* Broadband Repeat Indicator */
391 IE_NA, /* Restart Indicator */
392 IE_NA, /* Broadband Locking Shift */
393 IE_NA, /* Broadband Non-locking Shift */
394 IE_NA, /* Broadband Sending Complete */
395 IE_NA, /* Transit Net */
396 IE_MAND, /* Endpoint Reference */
397 IE_NA /* Endpoint State */
400 static u_char uni_adpr_ie_tbl[] = {
401 IE_NA, /* ATM AAL Parameters */
402 IE_NA, /* ATM User Cell Rate */
403 IE_NA, /* Broadband Bearer Capability */
404 IE_NA, /* Broadband High Layer Information */
405 IE_NA, /* Broadband Low Layer Information */
406 IE_NA, /* Call State */
407 IE_NA, /* Called Party Number */
408 IE_NA, /* Called Party Subaddress */
409 IE_NA, /* Calling Party Number */
410 IE_NA, /* Calling Party Subaddress */
412 IE_NA, /* Connection Identifier */
413 IE_NA, /* Quality of Service Parameters */
414 IE_NA, /* Broadband Repeat Indicator */
415 IE_NA, /* Restart Indicator */
416 IE_NA, /* Broadband Locking Shift */
417 IE_NA, /* Broadband Non-locking Shift */
418 IE_NA, /* Broadband Sending Complete */
419 IE_NA, /* Transit Net */
420 IE_MAND, /* Endpoint Reference */
421 IE_NA /* Endpoint State */
424 static u_char uni_drpp_ie_tbl[] = {
425 IE_NA, /* ATM AAL Parameters */
426 IE_NA, /* ATM User Cell Rate */
427 IE_NA, /* Broadband Bearer Capability */
428 IE_NA, /* Broadband High Layer Information */
429 IE_NA, /* Broadband Low Layer Information */
430 IE_NA, /* Call State */
431 IE_NA, /* Called Party Number */
432 IE_NA, /* Called Party Subaddress */
433 IE_NA, /* Calling Party Number */
434 IE_NA, /* Calling Party Subaddress */
436 IE_NA, /* Connection Identifier */
437 IE_NA, /* Quality of Service Parameters */
438 IE_NA, /* Broadband Repeat Indicator */
439 IE_NA, /* Restart Indicator */
440 IE_NA, /* Broadband Locking Shift */
441 IE_NA, /* Broadband Non-locking Shift */
442 IE_NA, /* Broadband Sending Complete */
443 IE_NA, /* Transit Net */
444 IE_MAND, /* Endpoint Reference */
445 IE_NA /* Endpoint State */
448 static u_char uni_drpa_ie_tbl[] = {
449 IE_NA, /* ATM AAL Parameters */
450 IE_NA, /* ATM User Cell Rate */
451 IE_NA, /* Broadband Bearer Capability */
452 IE_NA, /* Broadband High Layer Information */
453 IE_NA, /* Broadband Low Layer Information */
454 IE_NA, /* Call State */
455 IE_NA, /* Called Party Number */
456 IE_NA, /* Called Party Subaddress */
457 IE_NA, /* Calling Party Number */
458 IE_NA, /* Calling Party Subaddress */
460 IE_NA, /* Connection Identifier */
461 IE_NA, /* Quality of Service Parameters */
462 IE_NA, /* Broadband Repeat Indicator */
463 IE_NA, /* Restart Indicator */
464 IE_NA, /* Broadband Locking Shift */
465 IE_NA, /* Broadband Non-locking Shift */
466 IE_NA, /* Broadband Sending Complete */
467 IE_NA, /* Transit Net */
468 IE_MAND, /* Endpoint Reference */
469 IE_NA /* Endpoint State */
473 * Table of Q.2931 message types
478 } uni_msg_types[] = {
479 { UNI_MSG_CALP, uni_calp_ie_tbl },
480 { UNI_MSG_CONN, uni_conn_ie_tbl },
481 { UNI_MSG_CACK, uni_cack_ie_tbl },
482 { UNI_MSG_SETU, uni_setu_ie_tbl },
483 { UNI_MSG_RLSE, uni_rlse_ie_tbl },
484 { UNI_MSG_RLSC, uni_rlsc_ie_tbl },
485 { UNI_MSG_RSTR, uni_rstr_ie_tbl },
486 { UNI_MSG_RSTA, uni_rsta_ie_tbl },
487 { UNI_MSG_STAT, uni_stat_ie_tbl },
488 { UNI_MSG_SENQ, uni_senq_ie_tbl },
489 { UNI_MSG_ADDP, uni_addp_ie_tbl },
490 { UNI_MSG_ADPA, uni_adpa_ie_tbl },
491 { UNI_MSG_ADPR, uni_adpr_ie_tbl },
492 { UNI_MSG_DRPP, uni_drpp_ie_tbl },
493 { UNI_MSG_DRPA, uni_drpa_ie_tbl },
498 * Table of information elements
500 static struct ie_ent ie_table[] = {
501 { UNI_IE_AALP, 5, 16, UNI_MSG_IE_AALP, usf_dec_ie_aalp },
502 { UNI_IE_CLRT, 0, 26, UNI_MSG_IE_CLRT, usf_dec_ie_clrt },
503 { UNI_IE_BBCP, 2, 3, UNI_MSG_IE_BBCP, usf_dec_ie_bbcp },
504 { UNI_IE_BHLI, 1, 9, UNI_MSG_IE_BHLI, usf_dec_ie_bhli },
505 { UNI_IE_BLLI, 0, 13, UNI_MSG_IE_BLLI, usf_dec_ie_blli },
506 { UNI_IE_CLST, 1, 1, UNI_MSG_IE_CLST, usf_dec_ie_clst },
507 { UNI_IE_CDAD, 1, 21, UNI_MSG_IE_CDAD, usf_dec_ie_cdad },
508 { UNI_IE_CDSA, 1, 21, UNI_MSG_IE_CDSA, usf_dec_ie_cdsa },
509 { UNI_IE_CGAD, 1, 22, UNI_MSG_IE_CGAD, usf_dec_ie_cgad },
510 { UNI_IE_CGSA, 1, 21, UNI_MSG_IE_CGSA, usf_dec_ie_cgsa },
511 { UNI_IE_CAUS, 2, 30, UNI_MSG_IE_CAUS, usf_dec_ie_caus },
512 { UNI_IE_CNID, 5, 5, UNI_MSG_IE_CNID, usf_dec_ie_cnid },
513 { UNI_IE_QOSP, 2, 2, UNI_MSG_IE_QOSP, usf_dec_ie_qosp },
514 { UNI_IE_BRPI, 1, 1, UNI_MSG_IE_BRPI, usf_dec_ie_brpi },
515 { UNI_IE_RSTI, 1, 1, UNI_MSG_IE_RSTI, usf_dec_ie_rsti },
516 { UNI_IE_BLSH, 1, 1, UNI_MSG_IE_ERR, usf_dec_ie_uimp },
517 { UNI_IE_BNSH, 1, 1, UNI_MSG_IE_ERR, usf_dec_ie_uimp },
518 { UNI_IE_BSDC, 1, 1, UNI_MSG_IE_BSDC, usf_dec_ie_bsdc },
519 { UNI_IE_TRNT, 1, 5, UNI_MSG_IE_TRNT, usf_dec_ie_trnt },
520 { UNI_IE_EPRF, 3, 3, UNI_MSG_IE_ERR, usf_dec_ie_uimp },
521 { UNI_IE_EPST, 1, 1, UNI_MSG_IE_ERR, usf_dec_ie_uimp },
526 * Decoding table for AAL 1
528 struct ie_decode_tbl ie_aal1_tbl[] = {
529 { 133, 1, IE_OFF_SIZE(ie_aalp_1_subtype) },
530 { 134, 1, IE_OFF_SIZE(ie_aalp_1_cbr_rate) },
531 { 135, 2, IE_OFF_SIZE(ie_aalp_1_multiplier) },
532 { 136, 1, IE_OFF_SIZE(ie_aalp_1_clock_recovery) },
533 { 137, 1, IE_OFF_SIZE(ie_aalp_1_error_correction) },
534 { 138, 1, IE_OFF_SIZE(ie_aalp_1_struct_data_tran) },
535 { 139, 1, IE_OFF_SIZE(ie_aalp_1_partial_cells) },
540 * Decoding table for AAL 3/4
542 struct ie_decode_tbl ie_aal4_tbl_30[] = {
543 { 140, 2, IE_OFF_SIZE(ie_aalp_4_fwd_max_sdu) },
544 { 129, 2, IE_OFF_SIZE(ie_aalp_4_bkwd_max_sdu) },
545 { 130, 2, IE_OFF_SIZE(ie_aalp_4_mid_range) },
546 { 131, 1, IE_OFF_SIZE(ie_aalp_4_mode) },
547 { 132, 1, IE_OFF_SIZE(ie_aalp_4_sscs_type) },
550 struct ie_decode_tbl ie_aal4_tbl_31[] = {
551 { 140, 2, IE_OFF_SIZE(ie_aalp_4_fwd_max_sdu) },
552 { 129, 2, IE_OFF_SIZE(ie_aalp_4_bkwd_max_sdu) },
553 { 130, 4, IE_OFF_SIZE(ie_aalp_4_mid_range) },
554 { 132, 1, IE_OFF_SIZE(ie_aalp_4_sscs_type) },
559 * Decoding table for AAL 5
561 struct ie_decode_tbl ie_aal5_tbl_30[] = {
562 { 140, 2, IE_OFF_SIZE(ie_aalp_5_fwd_max_sdu) },
563 { 129, 2, IE_OFF_SIZE(ie_aalp_5_bkwd_max_sdu) },
564 { 131, 1, IE_OFF_SIZE(ie_aalp_5_mode) },
565 { 132, 1, IE_OFF_SIZE(ie_aalp_5_sscs_type) },
568 struct ie_decode_tbl ie_aal5_tbl_31[] = {
569 { 140, 2, IE_OFF_SIZE(ie_aalp_5_fwd_max_sdu) },
570 { 129, 2, IE_OFF_SIZE(ie_aalp_5_bkwd_max_sdu) },
571 { 132, 1, IE_OFF_SIZE(ie_aalp_5_sscs_type) },
576 * Decoding table for ATM user cell rate
578 struct ie_decode_tbl ie_clrt_tbl[] = {
579 {UNI_IE_CLRT_FWD_PEAK_ID, 3, IE_OFF_SIZE(ie_clrt_fwd_peak)},
580 {UNI_IE_CLRT_BKWD_PEAK_ID, 3, IE_OFF_SIZE(ie_clrt_bkwd_peak)},
581 {UNI_IE_CLRT_FWD_PEAK_01_ID, 3, IE_OFF_SIZE(ie_clrt_fwd_peak_01)},
582 {UNI_IE_CLRT_BKWD_PEAK_01_ID, 3, IE_OFF_SIZE(ie_clrt_bkwd_peak_01)},
583 {UNI_IE_CLRT_FWD_SUST_ID, 3, IE_OFF_SIZE(ie_clrt_fwd_sust)},
584 {UNI_IE_CLRT_BKWD_SUST_ID, 3, IE_OFF_SIZE(ie_clrt_bkwd_sust)},
585 {UNI_IE_CLRT_FWD_SUST_01_ID, 3, IE_OFF_SIZE(ie_clrt_fwd_sust_01)},
586 {UNI_IE_CLRT_BKWD_SUST_01_ID, 3, IE_OFF_SIZE(ie_clrt_bkwd_sust_01)},
587 {UNI_IE_CLRT_FWD_BURST_ID, 3, IE_OFF_SIZE(ie_clrt_fwd_burst)},
588 {UNI_IE_CLRT_BKWD_BURST_ID, 3, IE_OFF_SIZE(ie_clrt_bkwd_burst)},
589 {UNI_IE_CLRT_FWD_BURST_01_ID, 3, IE_OFF_SIZE(ie_clrt_fwd_burst_01)},
590 {UNI_IE_CLRT_BKWD_BURST_01_ID, 3, IE_OFF_SIZE(ie_clrt_bkwd_burst_01)},
591 {UNI_IE_CLRT_BEST_EFFORT_ID, 0, IE_OFF_SIZE(ie_clrt_best_effort)},
592 {UNI_IE_CLRT_TM_OPTIONS_ID, 1, IE_OFF_SIZE(ie_clrt_tm_options)},
597 * IEs initialized to empty values
599 struct ie_aalp ie_aalp_absent = {
603 struct ie_clrt ie_clrt_absent = {
620 struct ie_bbcp ie_bbcp_absent = {
628 struct ie_bhli ie_bhli_absent = {
630 { 0, 0, 0, 0, 0, 0, 0, 0 }
633 struct ie_blli ie_blli_absent = {
651 struct ie_clst ie_clst_absent = {
655 struct ie_cdad ie_cdad_absent = {
661 struct ie_cdsa ie_cdsa_absent = {
665 struct ie_cgad ie_cgad_absent = {
673 struct ie_cgsa ie_cgsa_absent = {
677 struct ie_caus ie_caus_absent = {
683 struct ie_cnid ie_cnid_absent = {
690 struct ie_qosp ie_qosp_absent = {
695 struct ie_brpi ie_brpi_absent = {
699 struct ie_rsti ie_rsti_absent = {
703 struct ie_blsh ie_blsh_absent = {
707 struct ie_bnsh ie_bnsh_absent = {
711 struct ie_bsdc ie_bsdc_absent = {
715 struct ie_trnt ie_trnt_absent = {
721 struct ie_eprf ie_eprf_absent = {
726 struct ie_epst ie_epst_absent = {
732 * Decode a UNI signalling message
735 * usf pointer to a unisig formatting structure
736 * msg pointer to a signalling message structure
740 * errno error encountered
744 usf_dec_msg(struct usfmt *usf, struct unisig_msg *msg)
749 struct ie_generic *ie;
751 ATM_DEBUG2("usf_dec_msg: usf=%p, msg=%p\n", usf, msg);
754 * Check the total message length
756 if (usf_count(usf) < UNI_MSG_MIN_LEN) {
761 * Get and check the protocol discriminator
763 rc = usf_byte(usf, &c);
766 if (c != UNI_MSG_DISC_Q93B)
770 * Get and check the call reference length
772 rc = usf_byte(usf, &c);
779 * Get the call reference
781 rc = usf_int3(usf, &msg->msg_call_ref);
786 * Get the message type
788 rc = usf_byte(usf, &msg->msg_type);
793 * Get the message type extension
795 rc = usf_byte(usf, &c);
798 msg->msg_type_flag = (c >> UNI_MSG_TYPE_FLAG_SHIFT) &
799 UNI_MSG_TYPE_FLAG_MASK;
800 msg->msg_type_action = c & UNI_MSG_TYPE_ACT_MASK;
803 * Get the message length and make sure we actually have
804 * enough data for the whole message
806 rc = usf_short(usf, &s);
810 if (usf_count(usf) != msg->msg_length) {
815 * Process information elements
817 len = msg->msg_length;
820 rc = usf_dec_ie(usf, msg, ie);
825 len -= (ie->ie_length + UNI_IE_HDR_LEN);
829 * Make sure that mandatory IEs are included and
830 * unwanted ones aren't
832 for (i=0; msg->msg_type!=uni_msg_types[i].msg_type &&
833 uni_msg_types[i].msg_type!=0; i++) {
835 if (!uni_msg_types[i].msg_ie_tbl)
839 * If the message type is in the table, check the IEs.
840 * If it isn't, the receive routine will catch the error.
842 ie_tbl = uni_msg_types[i].msg_ie_tbl;
843 for (i=0; i<UNI_MSG_IE_CNT-1; i++) {
846 if (!msg->msg_ie_vec[i]) {
848 * Mandatory IE missing
851 ie->ie_ident = unisig_ie_ident_vec[i];
852 ie->ie_err_cause = UNI_IE_CAUS_MISSING;
853 MSG_IE_ADD(msg, ie, UNI_MSG_IE_ERR);
857 if (msg->msg_ie_vec[i]) {
859 * Disallowed IE present
861 ie = msg->msg_ie_vec[i];
862 msg->msg_ie_vec[i] = NULL;
863 MSG_IE_ADD(msg, ie, UNI_MSG_IE_ERR);
882 * Decode an information element
884 * This routine will be called repeatedly as long as there are
885 * information elements left to be decoded. It will decode the
886 * first part of the IE, look its type up in a table, and call
887 * the appropriate routine to decode the rest. After an IE is
888 * successfully decoded, it is linked into the UNI signalling
889 * message structure. If an error is discovered, the IE is linked
890 * into the IE error chain and an error cause is set in the header.
893 * usf pointer to a UNISIG formatting structure
894 * msg pointer to a UNISIG message structure
895 * ie pointer to a generic IE structure
899 * errno error encountered
903 usf_dec_ie(struct usfmt *usf, struct unisig_msg *msg, struct ie_generic *ie)
908 * Decode the IE header (identifier, instruction field,
911 rc = usf_dec_ie_hdr(usf, ie);
915 * Ignore the IE if it is of zero length.
917 if (!ie->ie_length) {
923 * Look up the information element in the table
925 for (i=0; (ie->ie_ident != ie_table[i].ident) &&
926 (ie_table[i].decode != NULL); i++) {
928 if (ie_table[i].decode == NULL) {
932 ie_index = UNI_MSG_IE_ERR;
934 ie_index = ie_table[i].p_idx;
938 * Check for unimplemented or unrecognized IEs
940 if (ie_index == UNI_MSG_IE_ERR) {
941 ie->ie_err_cause = UNI_IE_CAUS_IEEXIST;
944 * Skip over the invalid IE
946 rc = usf_dec_ie_uimp(usf, ie);
953 * Check the length against the IE table
955 if (ie->ie_length < ie_table[i].min_len ||
956 ie->ie_length > ie_table[i].max_len) {
957 ie_index = UNI_MSG_IE_ERR;
958 ie->ie_err_cause = UNI_IE_CAUS_IECONTENT;
961 * Skip over the invalid IE
963 rc = usf_dec_ie_uimp(usf, ie);
970 * Process the IE by calling the function indicated
973 rc = ie_table[i].decode(usf, ie);
978 * Link the IE into the signalling message
981 if (ie->ie_err_cause) {
982 ie_index = UNI_MSG_IE_ERR;
984 MSG_IE_ADD(msg, ie, ie_index);
991 * Decode an information element header
994 * usf pointer to a UNISIG formatting structure
995 * ie pointer to a generic IE structure
999 * errno error encountered
1003 usf_dec_ie_hdr(struct usfmt *usf, struct ie_generic *ie)
1010 * Get the IE identifier
1012 rc = usf_byte(usf, &ie->ie_ident);
1017 * Get the extended type
1019 rc = usf_byte(usf, &c);
1022 ie->ie_coding = (c >> UNI_IE_CODE_SHIFT) & UNI_IE_CODE_MASK;
1023 ie->ie_flag = (c >> UNI_IE_FLAG_SHIFT) & UNI_IE_FLAG_MASK;
1024 ie->ie_action = c & UNI_IE_ACT_MASK;
1029 rc = usf_short(usf, &s);
1039 * Decode an AAL parameters information element
1042 * usf pointer to a unisig formatting structure
1043 * ie pointer to an AAL parms IE structure
1047 * errno error encountered
1051 usf_dec_ie_aalp(struct usfmt *usf, struct ie_generic *ie)
1058 KM_COPY(&ie_aalp_absent, &ie->ie_u.ie_aalp,
1059 sizeof(ie_aalp_absent));
1064 rc = usf_byte(usf, &ie->ie_aalp_aal_type);
1069 * Subtract the length of the AAL type from the total.
1070 * It will be readjusted after usf_dec_ie_ident is finished.
1075 * Process based on AAL type
1077 switch (ie->ie_aalp_aal_type) {
1078 case UNI_IE_AALP_AT_AAL1:
1080 * Clear the AAL 1 subparameters
1082 ie->ie_aalp_1_subtype = T_ATM_ABSENT;
1083 ie->ie_aalp_1_cbr_rate = T_ATM_ABSENT;
1084 ie->ie_aalp_1_multiplier = T_ATM_ABSENT;
1085 ie->ie_aalp_1_clock_recovery = T_ATM_ABSENT;
1086 ie->ie_aalp_1_error_correction = T_ATM_ABSENT;
1087 ie->ie_aalp_1_struct_data_tran = T_ATM_ABSENT;
1088 ie->ie_aalp_1_partial_cells = T_ATM_ABSENT;
1091 * Parse the AAL fields based on their IDs
1093 rc = usf_dec_ie_ident(usf, ie, ie_aal1_tbl);
1095 case UNI_IE_AALP_AT_AAL3:
1097 * Clear the AAL 3/4 subparameters
1099 ie->ie_aalp_4_fwd_max_sdu = T_ATM_ABSENT;
1100 ie->ie_aalp_4_bkwd_max_sdu = T_ATM_ABSENT;
1101 ie->ie_aalp_4_mid_range = T_ATM_ABSENT;
1102 ie->ie_aalp_4_mode = T_ATM_ABSENT;
1103 ie->ie_aalp_4_sscs_type = T_ATM_ABSENT;
1106 * Parse the AAL fields based on their IDs
1108 if (usf->usf_sig->us_proto == ATM_SIG_UNI30)
1109 rc = usf_dec_ie_ident(usf, ie, ie_aal4_tbl_30);
1111 rc = usf_dec_ie_ident(usf, ie, ie_aal4_tbl_31);
1114 * If either forward or backward maximum SDU
1115 * size is specified, the other must also be
1118 if ((ie->ie_aalp_4_fwd_max_sdu != T_ATM_ABSENT &&
1119 ie->ie_aalp_4_bkwd_max_sdu == T_ATM_ABSENT) ||
1120 (ie->ie_aalp_4_fwd_max_sdu == T_ATM_ABSENT &&
1121 ie->ie_aalp_4_bkwd_max_sdu != T_ATM_ABSENT)) {
1122 ie->ie_err_cause = UNI_IE_CAUS_IECONTENT;
1125 case UNI_IE_AALP_AT_AAL5:
1127 * Clear the AAL 5 subparameters
1129 ie->ie_aalp_5_fwd_max_sdu = T_ATM_ABSENT;
1130 ie->ie_aalp_5_bkwd_max_sdu = T_ATM_ABSENT;
1131 ie->ie_aalp_5_mode = T_ATM_ABSENT;
1132 ie->ie_aalp_5_sscs_type = T_ATM_ABSENT;
1135 * Parse the AAL fields based on their IDs
1137 if (usf->usf_sig->us_proto == ATM_SIG_UNI30)
1138 rc = usf_dec_ie_ident(usf, ie, ie_aal5_tbl_30);
1140 rc = usf_dec_ie_ident(usf, ie, ie_aal5_tbl_31);
1143 * If either forward or backward maximum SDU
1144 * size is specified, the other must also be
1147 if ((ie->ie_aalp_5_fwd_max_sdu != T_ATM_ABSENT &&
1148 ie->ie_aalp_5_bkwd_max_sdu == T_ATM_ABSENT) ||
1149 (ie->ie_aalp_5_fwd_max_sdu == T_ATM_ABSENT &&
1150 ie->ie_aalp_5_bkwd_max_sdu != T_ATM_ABSENT)) {
1151 ie->ie_err_cause = UNI_IE_CAUS_IECONTENT;
1154 case UNI_IE_AALP_AT_AALU:
1156 * Check user parameter length
1159 sizeof(ie->ie_aalp_user_info) +
1161 ie->ie_err_cause = UNI_IE_CAUS_IECONTENT;
1168 while (i < ie->ie_length - 2) {
1169 rc = usf_byte(usf, &ie->ie_aalp_user_info[i]);
1176 ie->ie_err_cause = UNI_IE_CAUS_IECONTENT;
1185 * Decode a user cell rate information element
1188 * usf pointer to a unisig formatting structure
1189 * ie pointer to a cell rate IE structure
1193 * errno error encountered
1197 usf_dec_ie_clrt(struct usfmt *usf, struct ie_generic *ie)
1204 KM_COPY(&ie_clrt_absent, &ie->ie_u.ie_clrt,
1205 sizeof(ie_clrt_absent));
1208 * Parse the IE using field identifiers
1210 rc = usf_dec_ie_ident(usf, ie, ie_clrt_tbl);
1216 * Decode a broadband bearer capability information element
1219 * usf pointer to a unisig formatting structure
1220 * ie pointer to a cell rate IE structure
1224 * errno error encountered
1228 usf_dec_ie_bbcp(struct usfmt *usf, struct ie_generic *ie)
1236 KM_COPY(&ie_bbcp_absent, &ie->ie_u.ie_bbcp,
1237 sizeof(ie_bbcp_absent));
1240 * Get the broadband bearer class
1242 rc = usf_byte(usf, &c);
1245 ie->ie_bbcp_bearer_class = c & UNI_IE_BBCP_BC_MASK;
1248 * If the broadband bearer class was X, the next
1249 * byte has the traffic type and timing requirements
1251 if (ie->ie_bbcp_bearer_class == UNI_IE_BBCP_BC_BCOB_X &&
1252 !(c & UNI_IE_EXT_BIT)) {
1253 rc = usf_byte(usf, &c);
1256 ie->ie_bbcp_traffic_type = (c >> UNI_IE_BBCP_TT_SHIFT) &
1257 UNI_IE_BBCP_TT_MASK;
1258 ie->ie_bbcp_timing_req = c & UNI_IE_BBCP_TR_MASK;
1262 * Get the clipping and user plane connection configuration
1264 if (c & UNI_IE_EXT_BIT) {
1265 rc = usf_byte(usf, &c);
1268 ie->ie_bbcp_clipping = (c >> UNI_IE_BBCP_SC_SHIFT) &
1269 UNI_IE_BBCP_SC_MASK;
1270 ie->ie_bbcp_conn_config = c & UNI_IE_BBCP_CC_MASK;
1278 * Decode a broadband high layer information element
1281 * usf pointer to a unisig formatting structure
1282 * ie pointer to a cell rate IE structure
1286 * errno error encountered
1290 usf_dec_ie_bhli(struct usfmt *usf, struct ie_generic *ie)
1298 KM_COPY(&ie_bhli_absent, &ie->ie_u.ie_bhli,
1299 sizeof(ie_bhli_absent));
1302 * Get the high layer information type
1304 rc = usf_ext(usf, &i);
1305 ie->ie_bhli_type = i & UNI_IE_EXT_MASK;
1310 * What comes next depends on the type
1312 switch (ie->ie_bhli_type) {
1313 case UNI_IE_BHLI_TYPE_ISO:
1314 case UNI_IE_BHLI_TYPE_USER:
1316 * ISO or user-specified parameters -- take the
1317 * length of information from the IE length
1319 for (i=0; i<ie->ie_length-1; i++) {
1320 rc = usf_byte(usf, &ie->ie_bhli_info[i]);
1325 case UNI_IE_BHLI_TYPE_HLP:
1327 * Make sure the IE is long enough for the high
1328 * layer profile information, then get it
1330 if (usf->usf_sig->us_proto != ATM_SIG_UNI30)
1331 ie->ie_err_cause = UNI_IE_CAUS_IECONTENT;
1332 if (ie->ie_length < UNI_IE_BHLI_HLP_LEN+1)
1333 ie->ie_err_cause = UNI_IE_CAUS_IECONTENT;
1334 for (i=0; i<ie->ie_length &&
1335 i<UNI_IE_BHLI_HLP_LEN; i++) {
1336 rc = usf_byte(usf, &ie->ie_bhli_info[i]);
1341 case UNI_IE_BHLI_TYPE_VSA:
1343 * Make sure the IE is long enough for the vendor-
1344 * specific application information, then get it
1346 if (ie->ie_length < UNI_IE_BHLI_VSA_LEN+1)
1347 ie->ie_err_cause = UNI_IE_CAUS_IECONTENT;
1348 for (i=0; i<ie->ie_length &&
1349 i<UNI_IE_BHLI_VSA_LEN; i++) {
1350 rc = usf_byte(usf, &ie->ie_bhli_info[i]);
1356 ie->ie_err_cause = UNI_IE_CAUS_IECONTENT;
1357 for (i=0; i<ie->ie_length; i++) {
1358 rc = usf_byte(usf, &c);
1369 * Decode a broadband low layer information element
1372 * usf pointer to a unisig formatting structure
1373 * ie pointer to a cell rate IE structure
1377 * errno error encountered
1381 usf_dec_ie_blli(struct usfmt *usf, struct ie_generic *ie)
1390 KM_COPY(&ie_blli_absent, &ie->ie_u.ie_blli,
1391 sizeof(ie_blli_absent));
1394 * Get paramteters for the protocol layers as long as
1395 * there is still information left in the IE
1400 * Get the type and process based on what it is
1402 rc = usf_byte(usf, &id);
1405 switch (((id & UNI_IE_EXT_MASK) >>
1406 UNI_IE_BLLI_LID_SHIFT) &
1407 UNI_IE_BLLI_LID_MASK) {
1408 case UNI_IE_BLLI_L1_ID:
1412 ie->ie_blli_l1_id = id & UNI_IE_BLLI_LP_MASK;
1415 case UNI_IE_BLLI_L2_ID:
1417 * Layer 2 info--contents vary based on type
1419 ie->ie_blli_l2_id = id & UNI_IE_BLLI_LP_MASK;
1421 if (id & UNI_IE_EXT_BIT)
1423 switch (ie->ie_blli_l2_id) {
1424 case UNI_IE_BLLI_L2P_X25L:
1425 case UNI_IE_BLLI_L2P_X25M:
1426 case UNI_IE_BLLI_L2P_HDLC1:
1427 case UNI_IE_BLLI_L2P_HDLC2:
1428 case UNI_IE_BLLI_L2P_HDLC3:
1429 case UNI_IE_BLLI_L2P_Q922:
1430 case UNI_IE_BLLI_L2P_ISO7776:
1431 rc = usf_byte(usf, &c);
1435 ie->ie_blli_l2_mode = (c >>
1436 UNI_IE_BLLI_L2MODE_SHIFT) &
1437 UNI_IE_BLLI_L2MODE_MASK;
1438 if (!(c & UNI_IE_EXT_BIT))
1440 rc = usf_byte(usf, &c);
1444 ie->ie_blli_l2_window =
1445 c & UNI_IE_EXT_MASK;
1447 case UNI_IE_BLLI_L2P_USER:
1448 rc = usf_byte(usf, &c);
1452 ie->ie_blli_l2_user_proto =
1453 c & UNI_IE_EXT_MASK;
1457 case UNI_IE_BLLI_L3_ID:
1459 * Layer 3 info--contents vary based on type
1461 ie->ie_blli_l3_id = id & UNI_IE_BLLI_LP_MASK;
1463 switch (ie->ie_blli_l3_id) {
1464 case UNI_IE_BLLI_L3P_X25:
1465 case UNI_IE_BLLI_L3P_ISO8208:
1466 case UNI_IE_BLLI_L3P_ISO8878:
1467 rc = usf_byte(usf, &c);
1471 ie->ie_blli_l3_mode = (c >>
1472 UNI_IE_BLLI_L3MODE_SHIFT) &
1473 UNI_IE_BLLI_L3MODE_MASK;
1474 if (!(c & UNI_IE_EXT_BIT))
1476 rc = usf_byte(usf, &c);
1480 ie->ie_blli_l3_packet_size =
1481 c & UNI_IE_BLLI_L3PS_MASK;
1482 if (!(c & UNI_IE_EXT_BIT))
1484 rc = usf_byte(usf, &c);
1488 ie->ie_blli_l3_window =
1489 c & UNI_IE_EXT_MASK;
1491 case UNI_IE_BLLI_L3P_USER:
1492 rc = usf_byte(usf, &c);
1496 ie->ie_blli_l3_mode =
1497 c & UNI_IE_EXT_MASK;
1499 case UNI_IE_BLLI_L3P_ISO9577:
1500 rc = usf_ext(usf, &ipi);
1504 ie->ie_blli_l3_ipi = ipi >>
1505 UNI_IE_BLLI_L3IPI_SHIFT;
1506 if (ie->ie_blli_l3_ipi !=
1507 UNI_IE_BLLI_L3IPI_SNAP)
1510 rc = usf_byte(usf, &c);
1511 ie->ie_blli_l3_snap_id = c & UNI_IE_EXT_MASK;
1517 &ie->ie_blli_l3_oui[0]);
1521 &ie->ie_blli_l3_oui[1]);
1525 &ie->ie_blli_l3_oui[2]);
1529 &ie->ie_blli_l3_pid[0]);
1533 &ie->ie_blli_l3_pid[1]);
1541 ie->ie_err_cause = UNI_IE_CAUS_IECONTENT;
1542 for (i=0; i<ie->ie_length; i++) {
1543 rc = usf_byte(usf, &c);
1555 * Decode a call state information element
1558 * usf pointer to a unisig formatting structure
1559 * ie pointer to a cell rate IE structure
1563 * errno error encountered
1567 usf_dec_ie_clst(struct usfmt *usf, struct ie_generic *ie)
1575 KM_COPY(&ie_clst_absent, &ie->ie_u.ie_clst,
1576 sizeof(ie_clst_absent));
1578 rc = usf_byte(usf, &c);
1581 ie->ie_clst_state = c & UNI_IE_CLST_STATE_MASK;
1588 * Decode a called party number information element
1591 * usf pointer to a unisig formatting structure
1592 * ie pointer to a cell rate IE structure
1596 * errno error encountered
1600 usf_dec_ie_cdad(struct usfmt *usf, struct ie_generic *ie)
1608 KM_COPY(&ie_cdad_absent, &ie->ie_u.ie_cdad,
1609 sizeof(ie_cdad_absent));
1612 * Get and check the numbering plan
1614 rc = usf_byte(usf, &c);
1617 ie->ie_cdad_plan = c & UNI_IE_CDAD_PLAN_MASK;
1618 len = ie->ie_length - 1;
1619 switch (ie->ie_cdad_plan) {
1620 case UNI_IE_CDAD_PLAN_E164:
1621 ie->ie_cdad_addr.address_format = T_ATM_E164_ADDR;
1623 case UNI_IE_CDAD_PLAN_NSAP:
1624 ie->ie_cdad_addr.address_format = T_ATM_ENDSYS_ADDR;
1628 * Invalid numbering plan
1630 ie->ie_err_cause = UNI_IE_CAUS_IECONTENT;
1632 rc = usf_byte(usf, &c);
1642 * Get the ATM address
1644 rc = usf_dec_atm_addr(usf, &ie->ie_cdad_addr, len);
1646 ie->ie_err_cause = UNI_IE_CAUS_IECONTENT;
1655 * Decode a called party subaddress information element
1658 * usf pointer to a unisig formatting structure
1659 * ie pointer to a cell rate IE structure
1663 * errno error encountered
1667 usf_dec_ie_cdsa(struct usfmt *usf, struct ie_generic *ie)
1675 KM_COPY(&ie_cdsa_absent, &ie->ie_u.ie_cdsa,
1676 sizeof(ie_cdsa_absent));
1679 * Get and check the subaddress type
1681 rc = usf_byte(usf, &c);
1684 len = ie->ie_length - 1;
1685 if (((c >> UNI_IE_CDSA_TYPE_SHIFT) & UNI_IE_CDSA_TYPE_MASK) !=
1686 UNI_IE_CDSA_TYPE_AESA) {
1688 * Invalid subaddress type
1690 ie->ie_err_cause = UNI_IE_CAUS_IECONTENT;
1692 rc = usf_byte(usf, &c);
1702 * Get the ATM address
1704 ie->ie_cdsa_addr.address_format = T_ATM_ENDSYS_ADDR;
1705 rc = usf_dec_atm_addr(usf, &ie->ie_cdsa_addr, len);
1707 ie->ie_err_cause = UNI_IE_CAUS_IECONTENT;
1716 * Decode a calling party number information element
1719 * usf pointer to a unisig formatting structure
1720 * ie pointer to a cell rate IE structure
1724 * errno error encountered
1728 usf_dec_ie_cgad(struct usfmt *usf, struct ie_generic *ie)
1736 KM_COPY(&ie_cgad_absent, &ie->ie_u.ie_cgad,
1737 sizeof(ie_cgad_absent));
1740 * Get and check the numbering plan
1742 len = ie->ie_length;
1743 rc = usf_byte(usf, &c);
1746 ie->ie_cgad_type = (c >> UNI_IE_CGAD_TYPE_SHIFT) &
1747 UNI_IE_CGAD_TYPE_MASK;
1748 ie->ie_cgad_plan = c & UNI_IE_CGAD_PLAN_MASK;
1750 switch (ie->ie_cgad_plan) {
1751 case UNI_IE_CGAD_PLAN_E164:
1752 ie->ie_cgad_addr.address_format = T_ATM_E164_ADDR;
1754 case UNI_IE_CGAD_PLAN_NSAP:
1755 ie->ie_cgad_addr.address_format = T_ATM_ENDSYS_ADDR;
1758 ie->ie_err_cause = UNI_IE_CAUS_IECONTENT;
1760 rc = usf_byte(usf, &c);
1770 * Get the presentation and screening indicators, if present
1772 if (!(c & UNI_IE_EXT_BIT)) {
1773 rc = usf_byte(usf, &c);
1777 ie->ie_cgad_pres_ind = (c >> UNI_IE_CGAD_PRES_SHIFT) &
1778 UNI_IE_CGAD_PRES_MASK;
1779 ie->ie_cgad_screen_ind = c & UNI_IE_CGAD_SCR_MASK;
1781 ie->ie_cgad_pres_ind = 0;
1782 ie->ie_cgad_screen_ind =0;
1786 * Get the ATM address
1788 rc = usf_dec_atm_addr(usf, &ie->ie_cgad_addr, len);
1790 ie->ie_err_cause = UNI_IE_CAUS_IECONTENT;
1799 * Decode a calling party subaddress information element
1802 * usf pointer to a unisig formatting structure
1803 * ie pointer to a cell rate IE structure
1807 * errno error encountered
1811 usf_dec_ie_cgsa(struct usfmt *usf, struct ie_generic *ie)
1819 KM_COPY(&ie_cgsa_absent, &ie->ie_u.ie_cgsa,
1820 sizeof(ie_cgsa_absent));
1823 * Get and check the subaddress type
1825 rc = usf_byte(usf, &c);
1828 len = ie->ie_length - 1;
1829 if (((c >> UNI_IE_CGSA_TYPE_SHIFT) & UNI_IE_CGSA_TYPE_MASK) !=
1830 UNI_IE_CGSA_TYPE_AESA) {
1832 * Invalid subaddress type
1834 ie->ie_err_cause = UNI_IE_CAUS_IECONTENT;
1836 rc = usf_byte(usf, &c);
1846 * Get the ATM address
1848 ie->ie_cgsa_addr.address_format = T_ATM_ENDSYS_ADDR;
1849 rc = usf_dec_atm_addr(usf, &ie->ie_cgsa_addr, len);
1851 ie->ie_err_cause = UNI_IE_CAUS_IECONTENT;
1860 * Decode a cause information element
1863 * usf pointer to a unisig formatting structure
1864 * ie pointer to a cell rate IE structure
1868 * errno error encountered
1872 usf_dec_ie_caus(struct usfmt *usf, struct ie_generic *ie)
1880 KM_COPY(&ie_caus_absent, &ie->ie_u.ie_caus,
1881 sizeof(ie_caus_absent));
1884 * Get the cause location
1886 rc = usf_byte(usf, &c);
1889 ie->ie_caus_loc = c & UNI_IE_CAUS_LOC_MASK;
1892 * Get the cause value
1894 rc = usf_byte(usf, &c);
1897 ie->ie_caus_cause = c & UNI_IE_EXT_MASK;
1900 * Get any included diagnostics
1902 len = ie->ie_length - 2;
1903 for (i = 0, ie->ie_caus_diag_len = 0;
1904 len && i < sizeof(ie->ie_caus_diagnostic);
1905 len--, i++, ie->ie_caus_diag_len++) {
1906 rc = usf_byte(usf, &ie->ie_caus_diagnostic[i]);
1916 * Decode a conection identifier information element
1919 * usf pointer to a unisig formatting structure
1920 * ie pointer to a cell rate IE structure
1924 * errno error encountered
1928 usf_dec_ie_cnid(struct usfmt *usf, struct ie_generic *ie)
1935 KM_COPY(&ie_cnid_absent, &ie->ie_u.ie_cnid,
1936 sizeof(ie_cnid_absent));
1938 rc = usf_ext(usf, &i);
1941 ie->ie_cnid_vp_sig = (i >> UNI_IE_CNID_VPSIG_SHIFT) &
1942 UNI_IE_CNID_VPSIG_MASK;
1943 ie->ie_cnid_pref_excl = i & UNI_IE_CNID_PREX_MASK;
1945 rc = usf_short(usf, &ie->ie_cnid_vpci);
1948 rc = usf_short(usf, &ie->ie_cnid_vci);
1954 * Decode a quality of service parameters information element
1957 * usf pointer to a unisig formatting structure
1958 * ie pointer to a cell rate IE structure
1962 * errno error encountered
1966 usf_dec_ie_qosp(struct usfmt *usf, struct ie_generic *ie)
1973 KM_COPY(&ie_qosp_absent, &ie->ie_u.ie_qosp,
1974 sizeof(ie_qosp_absent));
1977 * Get forward QoS class
1979 rc = usf_byte(usf, &ie->ie_qosp_fwd_class);
1984 * Get backward QoS class
1986 rc = usf_byte(usf, &ie->ie_qosp_bkwd_class);
1993 * Decode a broadband repeat indicator information element
1996 * usf pointer to a unisig formatting structure
1997 * ie pointer to a cell rate IE structure
2001 * errno error encountered
2005 usf_dec_ie_brpi(struct usfmt *usf, struct ie_generic *ie)
2013 KM_COPY(&ie_brpi_absent, &ie->ie_u.ie_brpi,
2014 sizeof(ie_brpi_absent));
2017 * Get the repeat indicator
2019 rc = usf_byte(usf, &c);
2023 ie->ie_brpi_ind = c & UNI_IE_BRPI_IND_MASK;
2030 * Decode a restart indicator information element
2033 * usf pointer to a unisig formatting structure
2034 * ie pointer to a cell rate IE structure
2038 * errno error encountered
2042 usf_dec_ie_rsti(struct usfmt *usf, struct ie_generic *ie)
2050 KM_COPY(&ie_rsti_absent, &ie->ie_u.ie_rsti,
2051 sizeof(ie_rsti_absent));
2054 * Get the restart class
2056 rc = usf_byte(usf, &c);
2060 ie->ie_rsti_class = c & UNI_IE_RSTI_CLASS_MASK;
2067 * Decode a broadband sending complete information element
2070 * usf pointer to a unisig formatting structure
2071 * ie pointer to a broadband sending complete IE structure
2075 * errno error encountered
2079 usf_dec_ie_bsdc(struct usfmt *usf, struct ie_generic *ie)
2087 KM_COPY(&ie_bsdc_absent, &ie->ie_u.ie_bsdc,
2088 sizeof(ie_bsdc_absent));
2091 * Get the sending complete indicator
2093 rc = usf_byte(usf, &c);
2098 * Validate the indicator
2100 c &= UNI_IE_EXT_MASK;
2101 if (c != UNI_IE_BSDC_IND)
2102 ie->ie_err_cause = UNI_IE_CAUS_IECONTENT;
2103 ie->ie_bsdc_ind = c;
2110 * Decode a transit network selection information element
2113 * usf pointer to a unisig formatting structure
2114 * ie pointer to a transit network selection IE structure
2118 * errno error encountered
2122 usf_dec_ie_trnt(struct usfmt *usf, struct ie_generic *ie)
2130 KM_COPY(&ie_trnt_absent, &ie->ie_u.ie_trnt,
2131 sizeof(ie_trnt_absent));
2134 * Get the network ID type and plan
2136 rc = usf_byte(usf, &c);
2139 ie->ie_trnt_id_type = (c >> UNI_IE_TRNT_IDT_SHIFT) &
2140 UNI_IE_TRNT_IDT_MASK;
2141 ie->ie_trnt_id_plan = c & UNI_IE_TRNT_IDP_MASK;
2144 * Get the length of the network ID
2146 len = ie->ie_length - 1;
2147 ie->ie_trnt_id_len = MIN(len, sizeof(ie->ie_trnt_id));
2150 * Get the network ID
2152 for (i=0; i<len; i++) {
2153 if (i<sizeof(ie->ie_trnt_id))
2154 rc = usf_byte(usf, &ie->ie_trnt_id[i]);
2156 rc = usf_byte(usf, &c);
2166 * Decode an unimplemented information element
2169 * usf pointer to a unisig formatting structure
2170 * ie pointer to a cell rate IE structure
2174 * errno error encountered
2178 usf_dec_ie_uimp(struct usfmt *usf, struct ie_generic *ie)
2184 * Skip over the IE contents
2186 for (i=0; i<ie->ie_length; i++) {
2187 rc = usf_byte(usf, &c);
2197 * Decode an information element using field identifiers
2199 * The AAL parameters and ATM user cell rate IEs are formatted
2200 * with a one-byte identifier preceeding each field. The routine
2201 * parses these IEs by using a table which relates the field
2202 * identifiers with the fields in the appropriate IE structure.
2203 * Field order in the received message is immaterial.
2206 * usf pointer to a unisig formatting structure
2207 * ie pointer to a cell rate IE structure
2208 * tbl pointer to an IE decoding table
2212 * errno error encountered
2216 usf_dec_ie_ident(struct usfmt *usf, struct ie_generic *ie,
2217 struct ie_decode_tbl *tbl)
2227 * Scan through the IE
2229 len = ie->ie_length;
2232 * Get the field identifier
2234 rc = usf_byte(usf, &c);
2240 * Look up the field in the table
2242 for (i=0; (tbl[i].ident != c) && tbl[i].len; i++) {
2244 if (tbl[i].ident == 0) {
2246 * Bad subfield identifier -- flag an
2247 * error and skip over the rest of the IE
2249 ie->ie_err_cause = UNI_IE_CAUS_IECONTENT;
2251 rc = usf_byte(usf, &c);
2259 * Save final destination address
2261 dest = (void *)((int)ie + tbl[i].f_offs);
2264 * Get the field value
2266 switch (tbl[i].len) {
2272 rc = usf_byte(usf, &cv);
2279 switch (tbl[i].f_size) {
2281 *(u_int8_t *)dest = cv;
2284 *(u_int16_t *)dest = cv;
2287 *(u_int32_t *)dest = cv;
2295 rc = usf_short(usf, &sv);
2302 switch (tbl[i].f_size) {
2304 *(u_int16_t *)dest = sv;
2307 *(u_int32_t *)dest = sv;
2315 rc = usf_int3(usf, &iv);
2319 rc = usf_int(usf, &iv);
2326 switch (tbl[i].f_size) {
2328 *(u_int32_t *)dest = iv;
2338 "uni decode: id=%d,len=%d,off=%d,size=%d\n",
2339 tbl[i].ident, tbl[i].len,
2340 tbl[i].f_offs, tbl[i].f_size);
2357 * Decode an ATM address
2360 * usf pointer to a unisig formatting structure
2361 * addr pointer to an ATM address structure
2362 * len length of data remainig in the IE
2366 * errno error encountered
2370 usf_dec_atm_addr(struct usfmt *usf, Atm_addr *addr, int len)
2376 * Check the address type
2378 addr->address_length = len;
2379 switch (addr->address_format) {
2380 case T_ATM_E164_ADDR:
2381 if (len > sizeof(Atm_addr_e164)) {
2384 cp = (u_char *) addr->address;
2386 case T_ATM_ENDSYS_ADDR:
2387 if (len != sizeof(Atm_addr_nsap)) {
2390 cp = (u_char *) addr->address;
2393 /* Silence the compiler */
2398 * Get the ATM address
2401 rc = usf_byte(usf, cp);
2412 rc = usf_byte(usf, &c);