2 * ===================================
3 * HARP | Host ATM Research Platform
4 * ===================================
7 * This Host ATM Research Platform ("HARP") file (the "Software") is
8 * made available by Network Computing Services, Inc. ("NetworkCS")
9 * "AS IS". NetworkCS does not provide maintenance, improvements or
10 * support of any kind.
12 * NETWORKCS MAKES NO WARRANTIES OR REPRESENTATIONS, EXPRESS OR IMPLIED,
13 * INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY
14 * AND FITNESS FOR A PARTICULAR PURPOSE, AS TO ANY ELEMENT OF THE
15 * SOFTWARE OR ANY SUPPORT PROVIDED IN CONNECTION WITH THIS SOFTWARE.
16 * In no event shall NetworkCS be responsible for any damages, including
17 * but not limited to consequential damages, arising from or relating to
18 * any use of the Software or related support.
20 * Copyright 1994-1998 Network Computing Services, Inc.
22 * Copies of this Software may be made, however, the above copyright
23 * notice must be reproduced on all copies.
27 * ATM Forum UNI Support
28 * ---------------------
30 * SSCF UNI - SSCF_UNI SAP interface processing
33 #include <sys/cdefs.h>
34 __FBSDID("$FreeBSD$");
36 #include <sys/param.h>
37 #include <sys/types.h>
38 #include <sys/systm.h>
40 #include <sys/socket.h>
41 #include <sys/socketvar.h>
42 #include <sys/syslog.h>
44 #include <netatm/port.h>
45 #include <netatm/queue.h>
46 #include <netatm/atm.h>
47 #include <netatm/atm_sys.h>
48 #include <netatm/atm_sap.h>
49 #include <netatm/atm_cm.h>
50 #include <netatm/atm_if.h>
51 #include <netatm/atm_stack.h>
52 #include <netatm/atm_pcb.h>
53 #include <netatm/atm_var.h>
55 #include <netatm/uni/uni.h>
56 #include <netatm/uni/sscop.h>
57 #include <netatm/uni/sscf_uni.h>
58 #include <netatm/uni/sscf_uni_var.h>
62 extern uma_zone_t sscf_uni_zone;
67 static struct sscop_parms sscf_uni_sscop_parms = {
68 4096, /* sp_maxinfo */
72 1 * ATM_HZ, /* sp_timecc */
73 2 * ATM_HZ, /* sp_timekeep */
74 7 * ATM_HZ, /* sp_timeresp */
75 1 * ATM_HZ, /* sp_timepoll */
76 15 * ATM_HZ, /* sp_timeidle */
82 * SSCF_UNI Lower Stack Command Handler
84 * This function will receive all of the stack commands issued from the
85 * layer above SSCF UNI (ie. Q.2931).
88 * cmd stack command code
90 * arg1 command specific argument
91 * arg2 command specific argument
98 sscf_uni_lower(cmd, tok, arg1, arg2)
104 struct univcc *uvp = (struct univcc *)tok;
105 Atm_connvc *cvp = uvp->uv_connvc;
106 enum sscop_vers vers;
109 ATM_DEBUG5("sscf_uni_lower: cmd=0x%x, uvp=%p, ustate=%d, arg1=%p, arg2=%p\n",
110 cmd, uvp, uvp->uv_ustate, (void *)arg1, (void *)arg2);
118 if (uvp->uv_ustate != UVU_INST) {
119 log(LOG_ERR, "sscf_uni_lower: SSCF_INIT in ustate=%d\n",
121 sscf_uni_abort(uvp, "sscf_uni: sequence err\n");
126 * Validate UNI version
128 if ((enum uni_vers)arg1 == UNI_VERS_3_0)
129 vers = SSCOP_VERS_QSAAL;
130 else if ((enum uni_vers)arg1 == UNI_VERS_3_1)
131 vers = SSCOP_VERS_Q2110;
133 sscf_uni_abort(uvp, "sscf_uni: bad version\n");
136 uvp->uv_vers = (enum uni_vers)arg1;
139 * Make ourselves ready and pass on the INIT
141 uvp->uv_ustate = UVU_RELEASED;
142 uvp->uv_lstate = UVL_IDLE;
144 STACK_CALL(SSCOP_INIT, uvp->uv_lower, uvp->uv_tokl, cvp,
145 (int)vers, (int)&sscf_uni_sscop_parms, err);
148 * Should never happen
150 sscf_uni_abort(uvp, "sscf_uni: INIT failure\n");
156 * Set termination states
158 uvp->uv_ustate = UVU_TERM;
159 uvp->uv_lstate = UVL_TERM;
162 * Pass the TERM down the stack
164 STACK_CALL(SSCOP_TERM, uvp->uv_lower, uvp->uv_tokl, cvp,
168 * Should never happen
170 sscf_uni_abort(uvp, "sscf_uni: TERM failure\n");
173 uma_zfree(sscf_uni_zone, uvp);
177 case SSCF_UNI_ESTABLISH_REQ:
179 * Validation based on user state
181 switch (uvp->uv_ustate) {
186 * Establishing a new connection
188 uvp->uv_ustate = UVU_PACTIVE;
189 uvp->uv_lstate = UVL_OUTCONN;
190 STACK_CALL(SSCOP_ESTABLISH_REQ, uvp->uv_lower,
192 SSCOP_UU_NULL, SSCOP_BR_YES, err);
194 sscf_uni_abort(uvp, "sscf_uni: stack memory\n");
201 * Resynchronizing a connection
203 uvp->uv_ustate = UVU_PACTIVE;
204 if (uvp->uv_vers == UNI_VERS_3_0) {
205 uvp->uv_lstate = UVL_OUTCONN;
206 STACK_CALL(SSCOP_ESTABLISH_REQ, uvp->uv_lower,
208 SSCOP_UU_NULL, SSCOP_BR_YES, err);
210 uvp->uv_lstate = UVL_OUTRESYN;
211 STACK_CALL(SSCOP_RESYNC_REQ, uvp->uv_lower,
213 SSCOP_UU_NULL, 0, err);
216 sscf_uni_abort(uvp, "sscf_uni: stack memory\n");
228 log(LOG_ERR, "sscf_uni_lower: cmd=0x%x, ustate=%d\n",
229 cmd, uvp->uv_ustate);
230 sscf_uni_abort(uvp, "sscf_uni: sequence err\n");
234 case SSCF_UNI_RELEASE_REQ:
236 * Validate re-establishment parameter
240 case SSCF_UNI_ESTIND_YES:
241 uvp->uv_flags &= ~UVF_NOESTIND;
244 case SSCF_UNI_ESTIND_NO:
245 uvp->uv_flags |= UVF_NOESTIND;
249 sscf_uni_abort(uvp, "sscf_uni: bad estind value\n");
254 * Validation based on user state
256 switch (uvp->uv_ustate) {
260 * Releasing a non-existant connection
262 STACK_CALL(SSCF_UNI_RELEASE_CNF, uvp->uv_upper,
266 sscf_uni_abort(uvp, "sscf_uni: stack memory\n");
274 * Releasing a connection
276 uvp->uv_ustate = UVU_PRELEASE;
277 uvp->uv_lstate = UVL_OUTDISC;
278 STACK_CALL(SSCOP_RELEASE_REQ, uvp->uv_lower,
280 SSCOP_UU_NULL, 0, err);
282 sscf_uni_abort(uvp, "sscf_uni: stack memory\n");
294 log(LOG_ERR, "sscf_uni_lower: cmd=0x%x, ustate=%d\n",
295 cmd, uvp->uv_ustate);
296 sscf_uni_abort(uvp, "sscf_uni: sequence err\n");
300 case SSCF_UNI_DATA_REQ:
302 sscf_uni_pdu_print(uvp, (KBuffer *)arg1, "DATA_REQ");
306 * Validation based on user state
308 switch (uvp->uv_ustate) {
312 * Send assured data on connection
314 STACK_CALL(SSCOP_DATA_REQ, uvp->uv_lower,
318 KB_FREEALL((KBuffer *)arg1);
319 sscf_uni_abort(uvp, "sscf_uni: stack memory\n");
327 * Release supplied buffers and ignore
329 KB_FREEALL((KBuffer *)arg1);
336 KB_FREEALL((KBuffer *)arg1);
337 log(LOG_ERR, "sscf_uni_lower: cmd=0x%x, ustate=%d\n",
338 cmd, uvp->uv_ustate);
339 sscf_uni_abort(uvp, "sscf_uni: sequence err\n");
343 case SSCF_UNI_UNITDATA_REQ:
345 sscf_uni_pdu_print(uvp, (KBuffer *)arg1, "UNITDATA_REQ");
349 * Validation based on user state
351 switch (uvp->uv_ustate) {
358 * Send unassured data on connection
360 STACK_CALL(SSCOP_UNITDATA_REQ, uvp->uv_lower,
364 KB_FREEALL((KBuffer *)arg1);
365 sscf_uni_abort(uvp, "sscf_uni: stack memory\n");
372 * Release supplied buffers and ignore
374 KB_FREEALL((KBuffer *)arg1);
379 KB_FREEALL((KBuffer *)arg1);
380 log(LOG_ERR, "sscf_uni_lower: cmd=0x%x, ustate=%d\n",
381 cmd, uvp->uv_ustate);
382 sscf_uni_abort(uvp, "sscf_uni: sequence err\n");
387 log(LOG_ERR, "sscf_uni_lower: unknown cmd 0x%x, uvp=%p\n",