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 $
27 * @(#) $DragonFly: src/sys/netproto/atm/uni/sscf_uni_upper.c,v 1.3 2003/08/07 21:17:35 dillon Exp $
31 * ATM Forum UNI Support
32 * ---------------------
34 * SSCF UNI - SSCOP SAP interface processing
38 #include <netatm/kern_include.h>
42 #include "sscf_uni_var.h"
45 * SSCF_UNI Upper Stack Command Handler
47 * This function will receive all of the stack commands issued from the
48 * layer below SSCF UNI (ie. SSCOP).
51 * cmd stack command code
53 * arg1 command specific argument
54 * arg2 command specific argument
61 sscf_uni_upper(cmd, tok, arg1, arg2)
67 struct univcc *uvp = (struct univcc *)tok;
68 Atm_connvc *cvp = uvp->uv_connvc;
71 ATM_DEBUG5("sscf_uni_upper: cmd=0x%x, uvp=%p, lstate=%d, arg1=0x%x, arg2=0x%x\n",
72 cmd, uvp, uvp->uv_lstate, arg1, arg2);
76 case SSCOP_ESTABLISH_IND:
78 * We don't support SSCOP User-to-User data, so just
79 * get rid of any supplied to us
81 if (arg1 != SSCOP_UU_NULL)
82 KB_FREEALL((KBuffer *)arg1);
85 * Validation based on sscop state
87 switch (uvp->uv_lstate) {
90 if (uvp->uv_vers != UNI_VERS_3_0) {
97 * Incoming connection establishment request
101 * If user doesn't want any more incoming sessions
102 * accepted, then refuse request
104 if (uvp->uv_flags & UVF_NOESTIND) {
105 STACK_CALL(SSCOP_RELEASE_REQ, uvp->uv_lower,
107 SSCOP_UU_NULL, 0, err);
110 "sscf_uni: stack memory\n");
118 * Tell sscop we've accepted the new connection
120 uvp->uv_lstate = UVL_READY;
121 STACK_CALL(SSCOP_ESTABLISH_RSP, uvp->uv_lower,
123 SSCOP_UU_NULL, SSCOP_BR_YES, err);
125 sscf_uni_abort(uvp, "sscf_uni: stack memory\n");
130 * Now notify the user of the new connection
132 uvp->uv_ustate = UVU_ACTIVE;
133 STACK_CALL(SSCF_UNI_ESTABLISH_IND, uvp->uv_upper,
135 SSCOP_UU_NULL, 0, err);
137 sscf_uni_abort(uvp, "sscf_uni: stack memory\n");
144 * Ignoring everything
157 log(LOG_ERR, "sscf_uni_upper: cmd=0x%x, lstate=%d\n",
158 cmd, uvp->uv_lstate);
159 sscf_uni_abort(uvp, "sscf_uni: sequence err\n");
163 case SSCOP_ESTABLISH_CNF:
165 * We don't support SSCOP User-to-User data, so just
166 * get rid of any supplied to us
168 if (arg1 != SSCOP_UU_NULL)
169 KB_FREEALL((KBuffer *)arg1);
172 * Validation based on sscop state
174 switch (uvp->uv_lstate) {
178 * Outgoing connection establishment completed
182 * Tell the user that the connection is established
184 uvp->uv_ustate = UVU_ACTIVE;
185 uvp->uv_lstate = UVL_READY;
186 STACK_CALL(SSCF_UNI_ESTABLISH_CNF, uvp->uv_upper,
188 SSCOP_UU_NULL, 0, err);
190 sscf_uni_abort(uvp, "sscf_uni: stack memory\n");
197 * Ignoring everything
210 log(LOG_ERR, "sscf_uni_upper: cmd=0x%x, lstate=%d\n",
211 cmd, uvp->uv_lstate);
212 sscf_uni_abort(uvp, "sscf_uni: sequence err\n");
216 case SSCOP_RELEASE_IND:
218 * We don't support SSCOP User-to-User data, so just
219 * get rid of any supplied to us
221 if (arg1 != SSCOP_UU_NULL)
222 KB_FREEALL((KBuffer *)arg1);
225 * Validation based on sscop state
227 switch (uvp->uv_lstate) {
233 * Peer requesting connection termination
237 * Notify the user that the connection
238 * has been terminated
240 uvp->uv_ustate = UVU_RELEASED;
241 uvp->uv_lstate = UVL_IDLE;
242 STACK_CALL(SSCF_UNI_RELEASE_IND, uvp->uv_upper,
244 SSCOP_UU_NULL, 0, err);
246 sscf_uni_abort(uvp, "sscf_uni: stack memory\n");
253 * Ignoring everything
264 log(LOG_ERR, "sscf_uni_upper: cmd=0x%x, lstate=%d\n",
265 cmd, uvp->uv_lstate);
266 sscf_uni_abort(uvp, "sscf_uni: sequence err\n");
270 case SSCOP_RELEASE_CNF:
272 * Validation based on sscop state
274 switch (uvp->uv_lstate) {
278 * Peer acknowledging connection termination
282 * Notify the user that the connection
283 * termination is completed
285 uvp->uv_ustate = UVU_RELEASED;
286 uvp->uv_lstate = UVL_IDLE;
287 STACK_CALL(SSCF_UNI_RELEASE_CNF, uvp->uv_upper,
289 SSCOP_UU_NULL, 0, err);
291 sscf_uni_abort(uvp, "sscf_uni: stack memory\n");
298 * Ignoring everything
311 log(LOG_ERR, "sscf_uni_upper: cmd=0x%x, lstate=%d\n",
312 cmd, uvp->uv_lstate);
313 sscf_uni_abort(uvp, "sscf_uni: sequence err\n");
319 sscf_uni_pdu_print(uvp, (KBuffer *)arg1, "DATA_IND");
323 * Validation based on sscop state
325 switch (uvp->uv_lstate) {
329 * Incoming assured data from peer
333 * Pass the data up to the user
335 STACK_CALL(SSCF_UNI_DATA_IND, uvp->uv_upper,
339 KB_FREEALL((KBuffer *)arg1);
340 sscf_uni_abort(uvp, "sscf_uni: stack memory\n");
347 * Ignoring everything
349 KB_FREEALL((KBuffer *)arg1);
361 KB_FREEALL((KBuffer *)arg1);
362 log(LOG_ERR, "sscf_uni_upper: cmd=0x%x, lstate=%d\n",
363 cmd, uvp->uv_lstate);
364 sscf_uni_abort(uvp, "sscf_uni: sequence err\n");
368 case SSCOP_RESYNC_IND:
370 * We don't support SSCOP User-to-User data, so just
371 * get rid of any supplied to us
373 if (arg1 != SSCOP_UU_NULL)
374 KB_FREEALL((KBuffer *)arg1);
377 * Validation based on sscop state
379 switch (uvp->uv_lstate) {
383 * Incoming connection resynchronization request
387 * Send resynch acknowledgement to sscop
389 STACK_CALL(SSCOP_RESYNC_RSP, uvp->uv_lower,
393 sscf_uni_abort(uvp, "sscf_uni: stack memory\n");
397 if (uvp->uv_vers != UNI_VERS_3_0) {
400 * Notify the user that the connection
403 STACK_CALL(SSCF_UNI_ESTABLISH_IND,
404 uvp->uv_upper, uvp->uv_toku, cvp,
405 SSCOP_UU_NULL, 0, err);
408 "sscf_uni: stack memory\n");
416 * Ignoring everything
429 log(LOG_ERR, "sscf_uni_upper: cmd=0x%x, lstate=%d\n",
430 cmd, uvp->uv_lstate);
431 sscf_uni_abort(uvp, "sscf_uni: sequence err\n");
435 case SSCOP_RESYNC_CNF:
437 * Not supported in version 3.0
439 if (uvp->uv_vers == UNI_VERS_3_0) {
441 "sscf_uni: SSCOP_RESYNC_CNF in 3.0\n");
446 * Validation based on sscop state
448 switch (uvp->uv_lstate) {
452 * Peer acknowledging connection resynchronization
456 * Now notify the user that the connection
459 uvp->uv_ustate = UVU_ACTIVE;
460 uvp->uv_lstate = UVL_READY;
461 STACK_CALL(SSCF_UNI_ESTABLISH_CNF, uvp->uv_upper,
463 SSCOP_UU_NULL, 0, err);
465 sscf_uni_abort(uvp, "sscf_uni: stack memory\n");
472 * Ignoring everything
485 log(LOG_ERR, "sscf_uni_upper: cmd=0x%x, lstate=%d\n",
486 cmd, uvp->uv_lstate);
487 sscf_uni_abort(uvp, "sscf_uni: sequence err\n");
491 case SSCOP_RECOVER_IND:
493 * Not supported in version 3.0
495 if (uvp->uv_vers == UNI_VERS_3_0) {
497 "sscf_uni: SSCOP_RECOVER_IND in 3.0\n");
502 * Validation based on sscop state
504 switch (uvp->uv_lstate) {
508 * Recover connection due to internal problems
512 * Send recovery acknowledgement to sscop
514 STACK_CALL(SSCOP_RECOVER_RSP, uvp->uv_lower,
518 sscf_uni_abort(uvp, "sscf_uni: stack memory\n");
523 * Now notify the user that the connection
526 STACK_CALL(SSCF_UNI_ESTABLISH_IND, uvp->uv_upper,
528 SSCOP_UU_NULL, 0, err);
530 sscf_uni_abort(uvp, "sscf_uni: stack memory\n");
537 * Ignoring everything
550 log(LOG_ERR, "sscf_uni_upper: cmd=0x%x, lstate=%d\n",
551 cmd, uvp->uv_lstate);
552 sscf_uni_abort(uvp, "sscf_uni: sequence err\n");
556 case SSCOP_UNITDATA_IND:
558 sscf_uni_pdu_print(uvp, (KBuffer *)arg1, "UNITDATA_IND");
562 * Validation based on sscop state
564 switch (uvp->uv_lstate) {
575 * Incoming unassured data from peer
579 * Pass the data up to the user
581 STACK_CALL(SSCF_UNI_UNITDATA_IND, uvp->uv_upper,
585 KB_FREEALL((KBuffer *)arg1);
586 sscf_uni_abort(uvp, "sscf_uni: stack memory\n");
593 * Ignoring everything
595 KB_FREEALL((KBuffer *)arg1);
600 KB_FREEALL((KBuffer *)arg1);
601 log(LOG_ERR, "sscf_uni_upper: cmd=0x%x, lstate=%d\n",
602 cmd, uvp->uv_lstate);
603 sscf_uni_abort(uvp, "sscf_uni: sequence err\n");
607 case SSCOP_RETRIEVE_IND:
608 case SSCOP_RETRIEVECMP_IND:
613 log(LOG_ERR, "sscf_uni_upper: unknown cmd 0x%x, uvp=%p\n",