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_lower.c,v 1.4 1999/08/28 00:48:56 peter Exp $
27 * @(#) $DragonFly: src/sys/netproto/atm/uni/sscf_uni_lower.c,v 1.4 2003/08/07 21:54:34 dillon Exp $
31 * ATM Forum UNI Support
32 * ---------------------
34 * SSCF UNI - SSCF_UNI SAP interface processing
38 #include <netproto/atm/kern_include.h>
43 #include "sscf_uni_var.h"
48 static struct sscop_parms sscf_uni_sscop_parms = {
49 4096, /* sp_maxinfo */
53 1 * ATM_HZ, /* sp_timecc */
54 2 * ATM_HZ, /* sp_timekeep */
55 7 * ATM_HZ, /* sp_timeresp */
56 1 * ATM_HZ, /* sp_timepoll */
57 15 * ATM_HZ, /* sp_timeidle */
63 * SSCF_UNI Lower Stack Command Handler
65 * This function will receive all of the stack commands issued from the
66 * layer above SSCF UNI (ie. Q.2931).
69 * cmd stack command code
71 * arg1 command specific argument
72 * arg2 command specific argument
79 sscf_uni_lower(cmd, tok, arg1, arg2)
85 struct univcc *uvp = (struct univcc *)tok;
86 Atm_connvc *cvp = uvp->uv_connvc;
90 ATM_DEBUG5("sscf_uni_lower: cmd=0x%x, uvp=%p, ustate=%d, arg1=0x%x, arg2=0x%x\n",
91 cmd, uvp, uvp->uv_ustate, arg1, arg2);
99 if (uvp->uv_ustate != UVU_INST) {
100 log(LOG_ERR, "sscf_uni_lower: SSCF_INIT in ustate=%d\n",
102 sscf_uni_abort(uvp, "sscf_uni: sequence err\n");
107 * Validate UNI version
109 if ((enum uni_vers)arg1 == UNI_VERS_3_0)
110 vers = SSCOP_VERS_QSAAL;
111 else if ((enum uni_vers)arg1 == UNI_VERS_3_1)
112 vers = SSCOP_VERS_Q2110;
114 sscf_uni_abort(uvp, "sscf_uni: bad version\n");
117 uvp->uv_vers = (enum uni_vers)arg1;
120 * Make ourselves ready and pass on the INIT
122 uvp->uv_ustate = UVU_RELEASED;
123 uvp->uv_lstate = UVL_IDLE;
125 STACK_CALL(SSCOP_INIT, uvp->uv_lower, uvp->uv_tokl, cvp,
126 (int)vers, (int)&sscf_uni_sscop_parms, err);
129 * Should never happen
131 sscf_uni_abort(uvp, "sscf_uni: INIT failure\n");
137 * Set termination states
139 uvp->uv_ustate = UVU_TERM;
140 uvp->uv_lstate = UVL_TERM;
143 * Pass the TERM down the stack
145 STACK_CALL(SSCOP_TERM, uvp->uv_lower, uvp->uv_tokl, cvp,
149 * Should never happen
151 sscf_uni_abort(uvp, "sscf_uni: TERM failure\n");
154 atm_free((caddr_t)uvp);
158 case SSCF_UNI_ESTABLISH_REQ:
160 * Validation based on user state
162 switch (uvp->uv_ustate) {
167 * Establishing a new connection
169 uvp->uv_ustate = UVU_PACTIVE;
170 uvp->uv_lstate = UVL_OUTCONN;
171 STACK_CALL(SSCOP_ESTABLISH_REQ, uvp->uv_lower,
173 SSCOP_UU_NULL, SSCOP_BR_YES, err);
175 sscf_uni_abort(uvp, "sscf_uni: stack memory\n");
182 * Resynchronizing a connection
184 uvp->uv_ustate = UVU_PACTIVE;
185 if (uvp->uv_vers == UNI_VERS_3_0) {
186 uvp->uv_lstate = UVL_OUTCONN;
187 STACK_CALL(SSCOP_ESTABLISH_REQ, uvp->uv_lower,
189 SSCOP_UU_NULL, SSCOP_BR_YES, err);
191 uvp->uv_lstate = UVL_OUTRESYN;
192 STACK_CALL(SSCOP_RESYNC_REQ, uvp->uv_lower,
194 SSCOP_UU_NULL, 0, err);
197 sscf_uni_abort(uvp, "sscf_uni: stack memory\n");
209 log(LOG_ERR, "sscf_uni_lower: cmd=0x%x, ustate=%d\n",
210 cmd, uvp->uv_ustate);
211 sscf_uni_abort(uvp, "sscf_uni: sequence err\n");
215 case SSCF_UNI_RELEASE_REQ:
217 * Validate re-establishment parameter
221 case SSCF_UNI_ESTIND_YES:
222 uvp->uv_flags &= ~UVF_NOESTIND;
225 case SSCF_UNI_ESTIND_NO:
226 uvp->uv_flags |= UVF_NOESTIND;
230 sscf_uni_abort(uvp, "sscf_uni: bad estind value\n");
235 * Validation based on user state
237 switch (uvp->uv_ustate) {
241 * Releasing a non-existant connection
243 STACK_CALL(SSCF_UNI_RELEASE_CNF, uvp->uv_upper,
247 sscf_uni_abort(uvp, "sscf_uni: stack memory\n");
255 * Releasing a connection
257 uvp->uv_ustate = UVU_PRELEASE;
258 uvp->uv_lstate = UVL_OUTDISC;
259 STACK_CALL(SSCOP_RELEASE_REQ, uvp->uv_lower,
261 SSCOP_UU_NULL, 0, err);
263 sscf_uni_abort(uvp, "sscf_uni: stack memory\n");
275 log(LOG_ERR, "sscf_uni_lower: cmd=0x%x, ustate=%d\n",
276 cmd, uvp->uv_ustate);
277 sscf_uni_abort(uvp, "sscf_uni: sequence err\n");
281 case SSCF_UNI_DATA_REQ:
283 sscf_uni_pdu_print(uvp, (KBuffer *)arg1, "DATA_REQ");
287 * Validation based on user state
289 switch (uvp->uv_ustate) {
293 * Send assured data on connection
295 STACK_CALL(SSCOP_DATA_REQ, uvp->uv_lower,
299 KB_FREEALL((KBuffer *)arg1);
300 sscf_uni_abort(uvp, "sscf_uni: stack memory\n");
308 * Release supplied buffers and ignore
310 KB_FREEALL((KBuffer *)arg1);
317 KB_FREEALL((KBuffer *)arg1);
318 log(LOG_ERR, "sscf_uni_lower: cmd=0x%x, ustate=%d\n",
319 cmd, uvp->uv_ustate);
320 sscf_uni_abort(uvp, "sscf_uni: sequence err\n");
324 case SSCF_UNI_UNITDATA_REQ:
326 sscf_uni_pdu_print(uvp, (KBuffer *)arg1, "UNITDATA_REQ");
330 * Validation based on user state
332 switch (uvp->uv_ustate) {
339 * Send unassured data on connection
341 STACK_CALL(SSCOP_UNITDATA_REQ, uvp->uv_lower,
345 KB_FREEALL((KBuffer *)arg1);
346 sscf_uni_abort(uvp, "sscf_uni: stack memory\n");
353 * Release supplied buffers and ignore
355 KB_FREEALL((KBuffer *)arg1);
360 KB_FREEALL((KBuffer *)arg1);
361 log(LOG_ERR, "sscf_uni_lower: cmd=0x%x, ustate=%d\n",
362 cmd, uvp->uv_ustate);
363 sscf_uni_abort(uvp, "sscf_uni: sequence err\n");
368 log(LOG_ERR, "sscf_uni_lower: unknown cmd 0x%x, uvp=%p\n",