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/sscf_uni_upper.c,v 1.5 2000/01/17 20:49:50 mks Exp $
31 * ATM Forum UNI Support
32 * ---------------------
34 * SSCF UNI - SSCOP SAP interface processing
38 #include <netatm/kern_include.h>
40 #include <netatm/uni/uni.h>
41 #include <netatm/uni/sscop.h>
42 #include <netatm/uni/sscf_uni_var.h>
45 __RCSID("@(#) $FreeBSD: src/sys/netatm/uni/sscf_uni_upper.c,v 1.5 2000/01/17 20:49:50 mks Exp $");
50 * SSCF_UNI Upper Stack Command Handler
52 * This function will receive all of the stack commands issued from the
53 * layer below SSCF UNI (ie. SSCOP).
56 * cmd stack command code
58 * arg1 command specific argument
59 * arg2 command specific argument
66 sscf_uni_upper(cmd, tok, arg1, arg2)
72 struct univcc *uvp = (struct univcc *)tok;
73 Atm_connvc *cvp = uvp->uv_connvc;
76 ATM_DEBUG5("sscf_uni_upper: cmd=0x%x, uvp=%p, lstate=%d, arg1=0x%x, arg2=0x%x\n",
77 cmd, uvp, uvp->uv_lstate, arg1, arg2);
81 case SSCOP_ESTABLISH_IND:
83 * We don't support SSCOP User-to-User data, so just
84 * get rid of any supplied to us
86 if (arg1 != SSCOP_UU_NULL)
87 KB_FREEALL((KBuffer *)arg1);
90 * Validation based on sscop state
92 switch (uvp->uv_lstate) {
95 if (uvp->uv_vers != UNI_VERS_3_0) {
102 * Incoming connection establishment request
106 * If user doesn't want any more incoming sessions
107 * accepted, then refuse request
109 if (uvp->uv_flags & UVF_NOESTIND) {
110 STACK_CALL(SSCOP_RELEASE_REQ, uvp->uv_lower,
112 SSCOP_UU_NULL, 0, err);
115 "sscf_uni: stack memory\n");
123 * Tell sscop we've accepted the new connection
125 uvp->uv_lstate = UVL_READY;
126 STACK_CALL(SSCOP_ESTABLISH_RSP, uvp->uv_lower,
128 SSCOP_UU_NULL, SSCOP_BR_YES, err);
130 sscf_uni_abort(uvp, "sscf_uni: stack memory\n");
135 * Now notify the user of the new connection
137 uvp->uv_ustate = UVU_ACTIVE;
138 STACK_CALL(SSCF_UNI_ESTABLISH_IND, uvp->uv_upper,
140 SSCOP_UU_NULL, 0, err);
142 sscf_uni_abort(uvp, "sscf_uni: stack memory\n");
149 * Ignoring everything
162 log(LOG_ERR, "sscf_uni_upper: cmd=0x%x, lstate=%d\n",
163 cmd, uvp->uv_lstate);
164 sscf_uni_abort(uvp, "sscf_uni: sequence err\n");
168 case SSCOP_ESTABLISH_CNF:
170 * We don't support SSCOP User-to-User data, so just
171 * get rid of any supplied to us
173 if (arg1 != SSCOP_UU_NULL)
174 KB_FREEALL((KBuffer *)arg1);
177 * Validation based on sscop state
179 switch (uvp->uv_lstate) {
183 * Outgoing connection establishment completed
187 * Tell the user that the connection is established
189 uvp->uv_ustate = UVU_ACTIVE;
190 uvp->uv_lstate = UVL_READY;
191 STACK_CALL(SSCF_UNI_ESTABLISH_CNF, uvp->uv_upper,
193 SSCOP_UU_NULL, 0, err);
195 sscf_uni_abort(uvp, "sscf_uni: stack memory\n");
202 * Ignoring everything
215 log(LOG_ERR, "sscf_uni_upper: cmd=0x%x, lstate=%d\n",
216 cmd, uvp->uv_lstate);
217 sscf_uni_abort(uvp, "sscf_uni: sequence err\n");
221 case SSCOP_RELEASE_IND:
223 * We don't support SSCOP User-to-User data, so just
224 * get rid of any supplied to us
226 if (arg1 != SSCOP_UU_NULL)
227 KB_FREEALL((KBuffer *)arg1);
230 * Validation based on sscop state
232 switch (uvp->uv_lstate) {
238 * Peer requesting connection termination
242 * Notify the user that the connection
243 * has been terminated
245 uvp->uv_ustate = UVU_RELEASED;
246 uvp->uv_lstate = UVL_IDLE;
247 STACK_CALL(SSCF_UNI_RELEASE_IND, uvp->uv_upper,
249 SSCOP_UU_NULL, 0, err);
251 sscf_uni_abort(uvp, "sscf_uni: stack memory\n");
258 * Ignoring everything
269 log(LOG_ERR, "sscf_uni_upper: cmd=0x%x, lstate=%d\n",
270 cmd, uvp->uv_lstate);
271 sscf_uni_abort(uvp, "sscf_uni: sequence err\n");
275 case SSCOP_RELEASE_CNF:
277 * Validation based on sscop state
279 switch (uvp->uv_lstate) {
283 * Peer acknowledging connection termination
287 * Notify the user that the connection
288 * termination is completed
290 uvp->uv_ustate = UVU_RELEASED;
291 uvp->uv_lstate = UVL_IDLE;
292 STACK_CALL(SSCF_UNI_RELEASE_CNF, uvp->uv_upper,
294 SSCOP_UU_NULL, 0, err);
296 sscf_uni_abort(uvp, "sscf_uni: stack memory\n");
303 * Ignoring everything
316 log(LOG_ERR, "sscf_uni_upper: cmd=0x%x, lstate=%d\n",
317 cmd, uvp->uv_lstate);
318 sscf_uni_abort(uvp, "sscf_uni: sequence err\n");
324 sscf_uni_pdu_print(uvp, (KBuffer *)arg1, "DATA_IND");
328 * Validation based on sscop state
330 switch (uvp->uv_lstate) {
334 * Incoming assured data from peer
338 * Pass the data up to the user
340 STACK_CALL(SSCF_UNI_DATA_IND, uvp->uv_upper,
344 KB_FREEALL((KBuffer *)arg1);
345 sscf_uni_abort(uvp, "sscf_uni: stack memory\n");
352 * Ignoring everything
354 KB_FREEALL((KBuffer *)arg1);
366 KB_FREEALL((KBuffer *)arg1);
367 log(LOG_ERR, "sscf_uni_upper: cmd=0x%x, lstate=%d\n",
368 cmd, uvp->uv_lstate);
369 sscf_uni_abort(uvp, "sscf_uni: sequence err\n");
373 case SSCOP_RESYNC_IND:
375 * We don't support SSCOP User-to-User data, so just
376 * get rid of any supplied to us
378 if (arg1 != SSCOP_UU_NULL)
379 KB_FREEALL((KBuffer *)arg1);
382 * Validation based on sscop state
384 switch (uvp->uv_lstate) {
388 * Incoming connection resynchronization request
392 * Send resynch acknowledgement to sscop
394 STACK_CALL(SSCOP_RESYNC_RSP, uvp->uv_lower,
398 sscf_uni_abort(uvp, "sscf_uni: stack memory\n");
402 if (uvp->uv_vers != UNI_VERS_3_0) {
405 * Notify the user that the connection
408 STACK_CALL(SSCF_UNI_ESTABLISH_IND,
409 uvp->uv_upper, uvp->uv_toku, cvp,
410 SSCOP_UU_NULL, 0, err);
413 "sscf_uni: stack memory\n");
421 * Ignoring everything
434 log(LOG_ERR, "sscf_uni_upper: cmd=0x%x, lstate=%d\n",
435 cmd, uvp->uv_lstate);
436 sscf_uni_abort(uvp, "sscf_uni: sequence err\n");
440 case SSCOP_RESYNC_CNF:
442 * Not supported in version 3.0
444 if (uvp->uv_vers == UNI_VERS_3_0) {
446 "sscf_uni: SSCOP_RESYNC_CNF in 3.0\n");
451 * Validation based on sscop state
453 switch (uvp->uv_lstate) {
457 * Peer acknowledging connection resynchronization
461 * Now notify the user that the connection
464 uvp->uv_ustate = UVU_ACTIVE;
465 uvp->uv_lstate = UVL_READY;
466 STACK_CALL(SSCF_UNI_ESTABLISH_CNF, uvp->uv_upper,
468 SSCOP_UU_NULL, 0, err);
470 sscf_uni_abort(uvp, "sscf_uni: stack memory\n");
477 * Ignoring everything
490 log(LOG_ERR, "sscf_uni_upper: cmd=0x%x, lstate=%d\n",
491 cmd, uvp->uv_lstate);
492 sscf_uni_abort(uvp, "sscf_uni: sequence err\n");
496 case SSCOP_RECOVER_IND:
498 * Not supported in version 3.0
500 if (uvp->uv_vers == UNI_VERS_3_0) {
502 "sscf_uni: SSCOP_RECOVER_IND in 3.0\n");
507 * Validation based on sscop state
509 switch (uvp->uv_lstate) {
513 * Recover connection due to internal problems
517 * Send recovery acknowledgement to sscop
519 STACK_CALL(SSCOP_RECOVER_RSP, uvp->uv_lower,
523 sscf_uni_abort(uvp, "sscf_uni: stack memory\n");
528 * Now notify the user that the connection
531 STACK_CALL(SSCF_UNI_ESTABLISH_IND, uvp->uv_upper,
533 SSCOP_UU_NULL, 0, err);
535 sscf_uni_abort(uvp, "sscf_uni: stack memory\n");
542 * Ignoring everything
555 log(LOG_ERR, "sscf_uni_upper: cmd=0x%x, lstate=%d\n",
556 cmd, uvp->uv_lstate);
557 sscf_uni_abort(uvp, "sscf_uni: sequence err\n");
561 case SSCOP_UNITDATA_IND:
563 sscf_uni_pdu_print(uvp, (KBuffer *)arg1, "UNITDATA_IND");
567 * Validation based on sscop state
569 switch (uvp->uv_lstate) {
580 * Incoming unassured data from peer
584 * Pass the data up to the user
586 STACK_CALL(SSCF_UNI_UNITDATA_IND, uvp->uv_upper,
590 KB_FREEALL((KBuffer *)arg1);
591 sscf_uni_abort(uvp, "sscf_uni: stack memory\n");
598 * Ignoring everything
600 KB_FREEALL((KBuffer *)arg1);
605 KB_FREEALL((KBuffer *)arg1);
606 log(LOG_ERR, "sscf_uni_upper: cmd=0x%x, lstate=%d\n",
607 cmd, uvp->uv_lstate);
608 sscf_uni_abort(uvp, "sscf_uni: sequence err\n");
612 case SSCOP_RETRIEVE_IND:
613 case SSCOP_RETRIEVECMP_IND:
618 log(LOG_ERR, "sscf_uni_upper: unknown cmd 0x%x, uvp=%p\n",