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.5 2006/01/14 13:36:39 swildner 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(int cmd, void *tok, int arg1, int arg2)
81 struct univcc *uvp = (struct univcc *)tok;
82 Atm_connvc *cvp = uvp->uv_connvc;
86 ATM_DEBUG5("sscf_uni_lower: cmd=0x%x, uvp=%p, ustate=%d, arg1=0x%x, arg2=0x%x\n",
87 cmd, uvp, uvp->uv_ustate, arg1, arg2);
95 if (uvp->uv_ustate != UVU_INST) {
96 log(LOG_ERR, "sscf_uni_lower: SSCF_INIT in ustate=%d\n",
98 sscf_uni_abort(uvp, "sscf_uni: sequence err\n");
103 * Validate UNI version
105 if ((enum uni_vers)arg1 == UNI_VERS_3_0)
106 vers = SSCOP_VERS_QSAAL;
107 else if ((enum uni_vers)arg1 == UNI_VERS_3_1)
108 vers = SSCOP_VERS_Q2110;
110 sscf_uni_abort(uvp, "sscf_uni: bad version\n");
113 uvp->uv_vers = (enum uni_vers)arg1;
116 * Make ourselves ready and pass on the INIT
118 uvp->uv_ustate = UVU_RELEASED;
119 uvp->uv_lstate = UVL_IDLE;
121 STACK_CALL(SSCOP_INIT, uvp->uv_lower, uvp->uv_tokl, cvp,
122 (int)vers, (int)&sscf_uni_sscop_parms, err);
125 * Should never happen
127 sscf_uni_abort(uvp, "sscf_uni: INIT failure\n");
133 * Set termination states
135 uvp->uv_ustate = UVU_TERM;
136 uvp->uv_lstate = UVL_TERM;
139 * Pass the TERM down the stack
141 STACK_CALL(SSCOP_TERM, uvp->uv_lower, uvp->uv_tokl, cvp,
145 * Should never happen
147 sscf_uni_abort(uvp, "sscf_uni: TERM failure\n");
150 atm_free((caddr_t)uvp);
154 case SSCF_UNI_ESTABLISH_REQ:
156 * Validation based on user state
158 switch (uvp->uv_ustate) {
163 * Establishing a new connection
165 uvp->uv_ustate = UVU_PACTIVE;
166 uvp->uv_lstate = UVL_OUTCONN;
167 STACK_CALL(SSCOP_ESTABLISH_REQ, uvp->uv_lower,
169 SSCOP_UU_NULL, SSCOP_BR_YES, err);
171 sscf_uni_abort(uvp, "sscf_uni: stack memory\n");
178 * Resynchronizing a connection
180 uvp->uv_ustate = UVU_PACTIVE;
181 if (uvp->uv_vers == UNI_VERS_3_0) {
182 uvp->uv_lstate = UVL_OUTCONN;
183 STACK_CALL(SSCOP_ESTABLISH_REQ, uvp->uv_lower,
185 SSCOP_UU_NULL, SSCOP_BR_YES, err);
187 uvp->uv_lstate = UVL_OUTRESYN;
188 STACK_CALL(SSCOP_RESYNC_REQ, uvp->uv_lower,
190 SSCOP_UU_NULL, 0, err);
193 sscf_uni_abort(uvp, "sscf_uni: stack memory\n");
205 log(LOG_ERR, "sscf_uni_lower: cmd=0x%x, ustate=%d\n",
206 cmd, uvp->uv_ustate);
207 sscf_uni_abort(uvp, "sscf_uni: sequence err\n");
211 case SSCF_UNI_RELEASE_REQ:
213 * Validate re-establishment parameter
217 case SSCF_UNI_ESTIND_YES:
218 uvp->uv_flags &= ~UVF_NOESTIND;
221 case SSCF_UNI_ESTIND_NO:
222 uvp->uv_flags |= UVF_NOESTIND;
226 sscf_uni_abort(uvp, "sscf_uni: bad estind value\n");
231 * Validation based on user state
233 switch (uvp->uv_ustate) {
237 * Releasing a non-existant connection
239 STACK_CALL(SSCF_UNI_RELEASE_CNF, uvp->uv_upper,
243 sscf_uni_abort(uvp, "sscf_uni: stack memory\n");
251 * Releasing a connection
253 uvp->uv_ustate = UVU_PRELEASE;
254 uvp->uv_lstate = UVL_OUTDISC;
255 STACK_CALL(SSCOP_RELEASE_REQ, uvp->uv_lower,
257 SSCOP_UU_NULL, 0, err);
259 sscf_uni_abort(uvp, "sscf_uni: stack memory\n");
271 log(LOG_ERR, "sscf_uni_lower: cmd=0x%x, ustate=%d\n",
272 cmd, uvp->uv_ustate);
273 sscf_uni_abort(uvp, "sscf_uni: sequence err\n");
277 case SSCF_UNI_DATA_REQ:
279 sscf_uni_pdu_print(uvp, (KBuffer *)arg1, "DATA_REQ");
283 * Validation based on user state
285 switch (uvp->uv_ustate) {
289 * Send assured data on connection
291 STACK_CALL(SSCOP_DATA_REQ, uvp->uv_lower,
295 KB_FREEALL((KBuffer *)arg1);
296 sscf_uni_abort(uvp, "sscf_uni: stack memory\n");
304 * Release supplied buffers and ignore
306 KB_FREEALL((KBuffer *)arg1);
313 KB_FREEALL((KBuffer *)arg1);
314 log(LOG_ERR, "sscf_uni_lower: cmd=0x%x, ustate=%d\n",
315 cmd, uvp->uv_ustate);
316 sscf_uni_abort(uvp, "sscf_uni: sequence err\n");
320 case SSCF_UNI_UNITDATA_REQ:
322 sscf_uni_pdu_print(uvp, (KBuffer *)arg1, "UNITDATA_REQ");
326 * Validation based on user state
328 switch (uvp->uv_ustate) {
335 * Send unassured data on connection
337 STACK_CALL(SSCOP_UNITDATA_REQ, uvp->uv_lower,
341 KB_FREEALL((KBuffer *)arg1);
342 sscf_uni_abort(uvp, "sscf_uni: stack memory\n");
349 * Release supplied buffers and ignore
351 KB_FREEALL((KBuffer *)arg1);
356 KB_FREEALL((KBuffer *)arg1);
357 log(LOG_ERR, "sscf_uni_lower: cmd=0x%x, ustate=%d\n",
358 cmd, uvp->uv_ustate);
359 sscf_uni_abort(uvp, "sscf_uni: sequence err\n");
364 log(LOG_ERR, "sscf_uni_lower: unknown cmd 0x%x, uvp=%p\n",