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 $
31 * ATM Forum UNI Support
32 * ---------------------
34 * SSCOP - SSCOP SAP interface processing
38 #include <netatm/kern_include.h>
40 #include <netatm/uni/sscop.h>
41 #include <netatm/uni/sscop_misc.h>
42 #include <netatm/uni/sscop_var.h>
45 __RCSID("@(#) $FreeBSD: src/sys/netatm/uni/sscop_lower.c,v 1.5 2000/01/17 20:49:51 mks Exp $");
53 * Stack commands with arg1 containing an buffer pointer
55 static u_char sscop_buf1[] = {
72 1, /* SSCOP_ESTABLISH_REQ */
74 1, /* SSCOP_ESTABLISH_RSP */
76 1, /* SSCOP_RELEASE_REQ */
79 1, /* SSCOP_DATA_REQ */
81 1, /* SSCOP_RESYNC_REQ */
83 0, /* SSCOP_RESYNC_RSP */
86 0, /* SSCOP_RECOVER_RSP */
87 1, /* SSCOP_UNITDATA_REQ */
89 0, /* SSCOP_RETRIEVE_REQ */
96 * SSCOP Lower Stack Command Handler
98 * This function will receive all of the stack commands issued from the
99 * layer above SSCOP (ie. using the SSCOP SAP). The appropriate processing
100 * function will be determined based on the received stack command and the
101 * current sscop control block state.
104 * cmd stack command code
106 * arg1 command specific argument
107 * arg2 command specific argument
114 sscop_lower(cmd, tok, arg1, arg2)
120 struct sscop *sop = (struct sscop *)tok;
121 void (**stab) __P((struct sscop *, int, int));
122 void (*func) __P((struct sscop *, int, int));
125 ATM_DEBUG5("sscop_lower: cmd=0x%x, sop=%p, state=%d, arg1=0x%x, arg2=0x%x\n",
126 cmd, sop, sop->so_state, arg1, arg2);
129 * Validate stack command
131 val = cmd & STKCMD_VAL_MASK;
132 if (((u_int)cmd < (u_int)SSCOP_CMD_MIN) ||
133 ((u_int)cmd > (u_int)SSCOP_CMD_MAX) ||
134 ((stab = (sop->so_vers == SSCOP_VERS_QSAAL ?
135 sscop_qsaal_aatab[val] :
136 sscop_q2110_aatab[val])) == NULL)) {
137 log(LOG_ERR, "sscop_lower: unknown cmd 0x%x, sop=%p\n",
143 * Validate sscop state
145 if (sop->so_state > SOS_MAXSTATE) {
146 log(LOG_ERR, "sscop_lower: invalid state sop=%p, state=%d\n",
149 * Release possible buffer
151 if (sscop_buf1[val]) {
153 KB_FREEALL((KBuffer *)arg1);
159 * Validate command/state combination
161 func = stab[sop->so_state];
164 "sscop_lower: invalid cmd/state: sop=%p, cmd=0x%x, state=%d\n",
165 sop, cmd, sop->so_state);
167 * Release possible buffer
169 if (sscop_buf1[val]) {
171 KB_FREEALL((KBuffer *)arg1);
177 * Call event processing function
179 (*func)(sop, arg1, arg2);
186 * No-op Processor (no buffers)
189 * sop pointer to sscop connection block
190 * arg1 command-specific argument
191 * arg2 command-specific argument
198 sscop_aa_noop_0(sop, arg1, arg2)
211 * No-op Processor (arg1 == buffer)
214 * sop pointer to sscop connection block
215 * arg1 command-specific argument (buffer pointer)
216 * arg2 command-specific argument
223 sscop_aa_noop_1(sop, arg1, arg2)
230 * Just free buffer chain
233 KB_FREEALL((KBuffer *)arg1);
240 * SSCOP_INIT / SOS_INST Command Processor
243 * sop pointer to sscop connection block
244 * arg1 command specific argument
245 * arg2 command specific argument
252 sscop_init_inst(sop, arg1, arg2)
260 * Make ourselves ready and pass on the INIT
262 sop->so_state = SOS_IDLE;
265 * Validate SSCOP version to use
267 switch ((enum sscop_vers)arg1) {
268 case SSCOP_VERS_QSAAL:
271 case SSCOP_VERS_Q2110:
275 sscop_abort(sop, "sscop: bad version\n");
278 sop->so_vers = (enum sscop_vers)arg1;
281 * Copy SSCOP connection parameters to use
283 sop->so_parm = *(struct sscop_parms *)arg2;
286 * Initialize lower layers
288 STACK_CALL(CPCS_INIT, sop->so_lower, sop->so_tokl, sop->so_connvc,
292 * Should never happen
294 sscop_abort(sop, "sscop: INIT failure\n");
302 * SSCOP_TERM / SOS_* Command Processor
305 * sop pointer to sscop connection block
306 * arg1 command specific argument
307 * arg2 command specific argument
314 sscop_term_all(sop, arg1, arg2)
322 * Set termination state
324 sop->so_state = SOS_TERM;
327 * Pass the TERM down the stack
329 STACK_CALL(CPCS_TERM, sop->so_lower, sop->so_tokl, sop->so_connvc,
333 * Should never happen
335 sscop_abort(sop, "sscop: TERM failure\n");
340 * Unlink and free the connection block
342 UNLINK(sop, struct sscop, sscop_head, so_next);
343 atm_free((caddr_t)sop);