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 $
31 * ATM Forum UNI Support
32 * ---------------------
34 * SSCF UNI - SSCF_UNI SAP interface processing
38 #include <netatm/kern_include.h>
40 #include <netatm/uni/uni.h>
41 #include <netatm/uni/sscop.h>
42 #include <netatm/uni/sscf_uni.h>
43 #include <netatm/uni/sscf_uni_var.h>
46 __RCSID("@(#) $FreeBSD: src/sys/netatm/uni/sscf_uni_lower.c,v 1.4 1999/08/28 00:48:56 peter Exp $");
53 static struct sscop_parms sscf_uni_sscop_parms = {
54 4096, /* sp_maxinfo */
58 1 * ATM_HZ, /* sp_timecc */
59 2 * ATM_HZ, /* sp_timekeep */
60 7 * ATM_HZ, /* sp_timeresp */
61 1 * ATM_HZ, /* sp_timepoll */
62 15 * ATM_HZ, /* sp_timeidle */
68 * SSCF_UNI Lower Stack Command Handler
70 * This function will receive all of the stack commands issued from the
71 * layer above SSCF UNI (ie. Q.2931).
74 * cmd stack command code
76 * arg1 command specific argument
77 * arg2 command specific argument
84 sscf_uni_lower(cmd, tok, arg1, arg2)
90 struct univcc *uvp = (struct univcc *)tok;
91 Atm_connvc *cvp = uvp->uv_connvc;
95 ATM_DEBUG5("sscf_uni_lower: cmd=0x%x, uvp=%p, ustate=%d, arg1=0x%x, arg2=0x%x\n",
96 cmd, uvp, uvp->uv_ustate, arg1, arg2);
104 if (uvp->uv_ustate != UVU_INST) {
105 log(LOG_ERR, "sscf_uni_lower: SSCF_INIT in ustate=%d\n",
107 sscf_uni_abort(uvp, "sscf_uni: sequence err\n");
112 * Validate UNI version
114 if ((enum uni_vers)arg1 == UNI_VERS_3_0)
115 vers = SSCOP_VERS_QSAAL;
116 else if ((enum uni_vers)arg1 == UNI_VERS_3_1)
117 vers = SSCOP_VERS_Q2110;
119 sscf_uni_abort(uvp, "sscf_uni: bad version\n");
122 uvp->uv_vers = (enum uni_vers)arg1;
125 * Make ourselves ready and pass on the INIT
127 uvp->uv_ustate = UVU_RELEASED;
128 uvp->uv_lstate = UVL_IDLE;
130 STACK_CALL(SSCOP_INIT, uvp->uv_lower, uvp->uv_tokl, cvp,
131 (int)vers, (int)&sscf_uni_sscop_parms, err);
134 * Should never happen
136 sscf_uni_abort(uvp, "sscf_uni: INIT failure\n");
142 * Set termination states
144 uvp->uv_ustate = UVU_TERM;
145 uvp->uv_lstate = UVL_TERM;
148 * Pass the TERM down the stack
150 STACK_CALL(SSCOP_TERM, uvp->uv_lower, uvp->uv_tokl, cvp,
154 * Should never happen
156 sscf_uni_abort(uvp, "sscf_uni: TERM failure\n");
159 atm_free((caddr_t)uvp);
163 case SSCF_UNI_ESTABLISH_REQ:
165 * Validation based on user state
167 switch (uvp->uv_ustate) {
172 * Establishing a new connection
174 uvp->uv_ustate = UVU_PACTIVE;
175 uvp->uv_lstate = UVL_OUTCONN;
176 STACK_CALL(SSCOP_ESTABLISH_REQ, uvp->uv_lower,
178 SSCOP_UU_NULL, SSCOP_BR_YES, err);
180 sscf_uni_abort(uvp, "sscf_uni: stack memory\n");
187 * Resynchronizing a connection
189 uvp->uv_ustate = UVU_PACTIVE;
190 if (uvp->uv_vers == UNI_VERS_3_0) {
191 uvp->uv_lstate = UVL_OUTCONN;
192 STACK_CALL(SSCOP_ESTABLISH_REQ, uvp->uv_lower,
194 SSCOP_UU_NULL, SSCOP_BR_YES, err);
196 uvp->uv_lstate = UVL_OUTRESYN;
197 STACK_CALL(SSCOP_RESYNC_REQ, uvp->uv_lower,
199 SSCOP_UU_NULL, 0, err);
202 sscf_uni_abort(uvp, "sscf_uni: stack memory\n");
214 log(LOG_ERR, "sscf_uni_lower: cmd=0x%x, ustate=%d\n",
215 cmd, uvp->uv_ustate);
216 sscf_uni_abort(uvp, "sscf_uni: sequence err\n");
220 case SSCF_UNI_RELEASE_REQ:
222 * Validate re-establishment parameter
226 case SSCF_UNI_ESTIND_YES:
227 uvp->uv_flags &= ~UVF_NOESTIND;
230 case SSCF_UNI_ESTIND_NO:
231 uvp->uv_flags |= UVF_NOESTIND;
235 sscf_uni_abort(uvp, "sscf_uni: bad estind value\n");
240 * Validation based on user state
242 switch (uvp->uv_ustate) {
246 * Releasing a non-existant connection
248 STACK_CALL(SSCF_UNI_RELEASE_CNF, uvp->uv_upper,
252 sscf_uni_abort(uvp, "sscf_uni: stack memory\n");
260 * Releasing a connection
262 uvp->uv_ustate = UVU_PRELEASE;
263 uvp->uv_lstate = UVL_OUTDISC;
264 STACK_CALL(SSCOP_RELEASE_REQ, uvp->uv_lower,
266 SSCOP_UU_NULL, 0, err);
268 sscf_uni_abort(uvp, "sscf_uni: stack memory\n");
280 log(LOG_ERR, "sscf_uni_lower: cmd=0x%x, ustate=%d\n",
281 cmd, uvp->uv_ustate);
282 sscf_uni_abort(uvp, "sscf_uni: sequence err\n");
286 case SSCF_UNI_DATA_REQ:
288 sscf_uni_pdu_print(uvp, (KBuffer *)arg1, "DATA_REQ");
292 * Validation based on user state
294 switch (uvp->uv_ustate) {
298 * Send assured data on connection
300 STACK_CALL(SSCOP_DATA_REQ, uvp->uv_lower,
304 KB_FREEALL((KBuffer *)arg1);
305 sscf_uni_abort(uvp, "sscf_uni: stack memory\n");
313 * Release supplied buffers and ignore
315 KB_FREEALL((KBuffer *)arg1);
322 KB_FREEALL((KBuffer *)arg1);
323 log(LOG_ERR, "sscf_uni_lower: cmd=0x%x, ustate=%d\n",
324 cmd, uvp->uv_ustate);
325 sscf_uni_abort(uvp, "sscf_uni: sequence err\n");
329 case SSCF_UNI_UNITDATA_REQ:
331 sscf_uni_pdu_print(uvp, (KBuffer *)arg1, "UNITDATA_REQ");
335 * Validation based on user state
337 switch (uvp->uv_ustate) {
344 * Send unassured data on connection
346 STACK_CALL(SSCOP_UNITDATA_REQ, uvp->uv_lower,
350 KB_FREEALL((KBuffer *)arg1);
351 sscf_uni_abort(uvp, "sscf_uni: stack memory\n");
358 * Release supplied buffers and ignore
360 KB_FREEALL((KBuffer *)arg1);
365 KB_FREEALL((KBuffer *)arg1);
366 log(LOG_ERR, "sscf_uni_lower: cmd=0x%x, ustate=%d\n",
367 cmd, uvp->uv_ustate);
368 sscf_uni_abort(uvp, "sscf_uni: sequence err\n");
373 log(LOG_ERR, "sscf_uni_lower: unknown cmd 0x%x, uvp=%p\n",