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/sscop_lower.c,v 1.5 2000/01/17 20:49:51 mks Exp $
27 * @(#) $DragonFly: src/sys/netproto/atm/uni/sscop_lower.c,v 1.6 2006/01/14 13:36:39 swildner Exp $
31 * ATM Forum UNI Support
32 * ---------------------
34 * SSCOP - SSCOP SAP interface processing
38 #include <netproto/atm/kern_include.h>
41 #include "sscop_misc.h"
42 #include "sscop_var.h"
48 * Stack commands with arg1 containing an buffer pointer
50 static u_char sscop_buf1[] = {
67 1, /* SSCOP_ESTABLISH_REQ */
69 1, /* SSCOP_ESTABLISH_RSP */
71 1, /* SSCOP_RELEASE_REQ */
74 1, /* SSCOP_DATA_REQ */
76 1, /* SSCOP_RESYNC_REQ */
78 0, /* SSCOP_RESYNC_RSP */
81 0, /* SSCOP_RECOVER_RSP */
82 1, /* SSCOP_UNITDATA_REQ */
84 0, /* SSCOP_RETRIEVE_REQ */
91 * SSCOP Lower Stack Command Handler
93 * This function will receive all of the stack commands issued from the
94 * layer above SSCOP (ie. using the SSCOP SAP). The appropriate processing
95 * function will be determined based on the received stack command and the
96 * current sscop control block state.
99 * cmd stack command code
101 * arg1 command specific argument
102 * arg2 command specific argument
109 sscop_lower(int cmd, void *tok, int arg1, int arg2)
111 struct sscop *sop = (struct sscop *)tok;
112 void (**stab) (struct sscop *, int, int);
113 void (*func) (struct sscop *, int, int);
116 ATM_DEBUG5("sscop_lower: cmd=0x%x, sop=%p, state=%d, arg1=0x%x, arg2=0x%x\n",
117 cmd, sop, sop->so_state, arg1, arg2);
120 * Validate stack command
122 val = cmd & STKCMD_VAL_MASK;
123 if (((u_int)cmd < (u_int)SSCOP_CMD_MIN) ||
124 ((u_int)cmd > (u_int)SSCOP_CMD_MAX) ||
125 ((stab = (sop->so_vers == SSCOP_VERS_QSAAL ?
126 sscop_qsaal_aatab[val] :
127 sscop_q2110_aatab[val])) == NULL)) {
128 log(LOG_ERR, "sscop_lower: unknown cmd 0x%x, sop=%p\n",
134 * Validate sscop state
136 if (sop->so_state > SOS_MAXSTATE) {
137 log(LOG_ERR, "sscop_lower: invalid state sop=%p, state=%d\n",
140 * Release possible buffer
142 if (sscop_buf1[val]) {
144 KB_FREEALL((KBuffer *)arg1);
150 * Validate command/state combination
152 func = stab[sop->so_state];
155 "sscop_lower: invalid cmd/state: sop=%p, cmd=0x%x, state=%d\n",
156 sop, cmd, sop->so_state);
158 * Release possible buffer
160 if (sscop_buf1[val]) {
162 KB_FREEALL((KBuffer *)arg1);
168 * Call event processing function
170 (*func)(sop, arg1, arg2);
177 * No-op Processor (no buffers)
180 * sop pointer to sscop connection block
181 * arg1 command-specific argument
182 * arg2 command-specific argument
189 sscop_aa_noop_0(struct sscop *sop, int arg1, int arg2)
199 * No-op Processor (arg1 == buffer)
202 * sop pointer to sscop connection block
203 * arg1 command-specific argument (buffer pointer)
204 * arg2 command-specific argument
211 sscop_aa_noop_1(struct sscop *sop, int arg1, int arg2)
215 * Just free buffer chain
218 KB_FREEALL((KBuffer *)arg1);
225 * SSCOP_INIT / SOS_INST Command Processor
228 * sop pointer to sscop connection block
229 * arg1 command specific argument
230 * arg2 command specific argument
237 sscop_init_inst(struct sscop *sop, int arg1, int arg2)
242 * Make ourselves ready and pass on the INIT
244 sop->so_state = SOS_IDLE;
247 * Validate SSCOP version to use
249 switch ((enum sscop_vers)arg1) {
250 case SSCOP_VERS_QSAAL:
253 case SSCOP_VERS_Q2110:
257 sscop_abort(sop, "sscop: bad version\n");
260 sop->so_vers = (enum sscop_vers)arg1;
263 * Copy SSCOP connection parameters to use
265 sop->so_parm = *(struct sscop_parms *)arg2;
268 * Initialize lower layers
270 STACK_CALL(CPCS_INIT, sop->so_lower, sop->so_tokl, sop->so_connvc,
274 * Should never happen
276 sscop_abort(sop, "sscop: INIT failure\n");
284 * SSCOP_TERM / SOS_* Command Processor
287 * sop pointer to sscop connection block
288 * arg1 command specific argument
289 * arg2 command specific argument
296 sscop_term_all(struct sscop *sop, int arg1, int arg2)
301 * Set termination state
303 sop->so_state = SOS_TERM;
306 * Pass the TERM down the stack
308 STACK_CALL(CPCS_TERM, sop->so_lower, sop->so_tokl, sop->so_connvc,
312 * Should never happen
314 sscop_abort(sop, "sscop: TERM failure\n");
319 * Unlink and free the connection block
321 UNLINK(sop, struct sscop, sscop_head, so_next);
322 atm_free((caddr_t)sop);