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.5 2003/08/23 10:06:22 rob 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(cmd, tok, arg1, arg2)
115 struct sscop *sop = (struct sscop *)tok;
116 void (**stab) (struct sscop *, int, int);
117 void (*func) (struct sscop *, int, int);
120 ATM_DEBUG5("sscop_lower: cmd=0x%x, sop=%p, state=%d, arg1=0x%x, arg2=0x%x\n",
121 cmd, sop, sop->so_state, arg1, arg2);
124 * Validate stack command
126 val = cmd & STKCMD_VAL_MASK;
127 if (((u_int)cmd < (u_int)SSCOP_CMD_MIN) ||
128 ((u_int)cmd > (u_int)SSCOP_CMD_MAX) ||
129 ((stab = (sop->so_vers == SSCOP_VERS_QSAAL ?
130 sscop_qsaal_aatab[val] :
131 sscop_q2110_aatab[val])) == NULL)) {
132 log(LOG_ERR, "sscop_lower: unknown cmd 0x%x, sop=%p\n",
138 * Validate sscop state
140 if (sop->so_state > SOS_MAXSTATE) {
141 log(LOG_ERR, "sscop_lower: invalid state sop=%p, state=%d\n",
144 * Release possible buffer
146 if (sscop_buf1[val]) {
148 KB_FREEALL((KBuffer *)arg1);
154 * Validate command/state combination
156 func = stab[sop->so_state];
159 "sscop_lower: invalid cmd/state: sop=%p, cmd=0x%x, state=%d\n",
160 sop, cmd, sop->so_state);
162 * Release possible buffer
164 if (sscop_buf1[val]) {
166 KB_FREEALL((KBuffer *)arg1);
172 * Call event processing function
174 (*func)(sop, arg1, arg2);
181 * No-op Processor (no buffers)
184 * sop pointer to sscop connection block
185 * arg1 command-specific argument
186 * arg2 command-specific argument
193 sscop_aa_noop_0(sop, arg1, arg2)
206 * No-op Processor (arg1 == buffer)
209 * sop pointer to sscop connection block
210 * arg1 command-specific argument (buffer pointer)
211 * arg2 command-specific argument
218 sscop_aa_noop_1(sop, arg1, arg2)
225 * Just free buffer chain
228 KB_FREEALL((KBuffer *)arg1);
235 * SSCOP_INIT / SOS_INST Command Processor
238 * sop pointer to sscop connection block
239 * arg1 command specific argument
240 * arg2 command specific argument
247 sscop_init_inst(sop, arg1, arg2)
255 * Make ourselves ready and pass on the INIT
257 sop->so_state = SOS_IDLE;
260 * Validate SSCOP version to use
262 switch ((enum sscop_vers)arg1) {
263 case SSCOP_VERS_QSAAL:
266 case SSCOP_VERS_Q2110:
270 sscop_abort(sop, "sscop: bad version\n");
273 sop->so_vers = (enum sscop_vers)arg1;
276 * Copy SSCOP connection parameters to use
278 sop->so_parm = *(struct sscop_parms *)arg2;
281 * Initialize lower layers
283 STACK_CALL(CPCS_INIT, sop->so_lower, sop->so_tokl, sop->so_connvc,
287 * Should never happen
289 sscop_abort(sop, "sscop: INIT failure\n");
297 * SSCOP_TERM / SOS_* Command Processor
300 * sop pointer to sscop connection block
301 * arg1 command specific argument
302 * arg2 command specific argument
309 sscop_term_all(sop, arg1, arg2)
317 * Set termination state
319 sop->so_state = SOS_TERM;
322 * Pass the TERM down the stack
324 STACK_CALL(CPCS_TERM, sop->so_lower, sop->so_tokl, sop->so_connvc,
328 * Should never happen
330 sscop_abort(sop, "sscop: TERM failure\n");
335 * Unlink and free the connection block
337 UNLINK(sop, struct sscop, sscop_head, so_next);
338 atm_free((caddr_t)sop);