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.c,v 1.7.2.1 2001/09/30 22:54:35 kris Exp $
27 * @(#) $DragonFly: src/sys/netproto/atm/uni/sscf_uni.c,v 1.7 2006/12/20 18:14:43 dillon Exp $
31 * ATM Forum UNI Support
32 * ---------------------
34 * Signalling AAL SSCF at the UNI
38 #include <netproto/atm/kern_include.h>
41 #include "sscf_uni_var.h"
46 int sscf_uni_vccnt = 0;
51 static int sscf_uni_inst (struct stack_defn **, Atm_connvc *);
56 static struct sp_info sscf_uni_pool = {
57 "sscf uni pool", /* si_name */
58 sizeof(struct univcc), /* si_blksiz */
63 static struct stack_defn sscf_uni_service = {
73 static struct t_atm_cause sscf_uni_cause = {
76 T_ATM_CAUSE_TEMPORARY_FAILURE,
82 * Initialize SSCF UNI processing
84 * This will be called during module loading. We will register our stack
85 * service and wait for someone to talk to us.
91 * 0 initialization was successful
92 * errno initialization failed - reason indicated
101 * Register stack service
103 if ((err = atm_stack_register(&sscf_uni_service)) != 0)
112 * Terminate SSCF UNI processing
114 * This will be called just prior to unloading the module from memory. All
115 * signalling instances should have been terminated by now, so we just free
116 * up all of our resources.
124 * 0 termination was successful
125 * errno termination failed - reason indicated
132 * Any connections still exist??
134 if (sscf_uni_vccnt) {
137 * Yes, can't stop yet
143 * Deregister the stack service
145 atm_stack_deregister(&sscf_uni_service);
148 * Free our storage pools
150 atm_release_pool(&sscf_uni_pool);
157 * SSCF_UNI Stack Instantiation
162 * ssp pointer to array of stack definition pointers for connection
163 * ssp[0] points to upper layer's stack service definition
164 * ssp[1] points to this layer's stack service definition
165 * ssp[2] points to lower layer's stack service definition
166 * cvp pointer to connection vcc for this stack
169 * 0 instantiation successful
170 * errno instantiation failed - reason indicated
174 sscf_uni_inst(struct stack_defn **ssp, Atm_connvc *cvp)
176 struct stack_defn *sdp_up = ssp[0],
182 ATM_DEBUG2("sscf_uni_inst: ssp=%p, cvp=%p\n", ssp, cvp);
187 if (sdp_low->sd_sap != SAP_SSCOP)
191 * Allocate our control block
193 uvp = (struct univcc *)atm_allocate(&sscf_uni_pool);
197 uvp->uv_ustate = UVU_INST;
198 uvp->uv_lstate = UVL_INST;
199 uvp->uv_connvc = cvp;
200 uvp->uv_toku = sdp_up->sd_toku;
201 uvp->uv_upper = sdp_up->sd_upper;
205 * Store my token into service definition
207 sdp_me->sd_toku = uvp;
210 * Update and save input buffer headroom
213 /* uvp->uv_headin = cvp->cvc_attr.headin; */
216 * Pass instantiation down the stack
218 err = sdp_low->sd_inst(ssp + 1, cvp);
221 * Lower layer instantiation failed, free our resources
223 atm_free((caddr_t)uvp);
229 * Save and update output buffer headroom
231 /* uvp->uv_headout = cvp->cvc_attr.headout; */
235 * Save lower layer's interface info
237 uvp->uv_lower = sdp_low->sd_lower;
238 uvp->uv_tokl = sdp_low->sd_toku;
245 * Abort an SSCF_UNI connection
247 * Called when an unrecoverable or "should never happen" error occurs.
248 * We just log a message and request the signalling manager to abort the
252 * uvp pointer to univcc control block
253 * msg pointer to error message
260 sscf_uni_abort(struct univcc *uvp, char *msg)
265 log(LOG_ERR, "%s", msg);
268 * Set termination states
270 uvp->uv_ustate = UVU_TERM;
271 uvp->uv_lstate = UVL_TERM;
274 * Tell Connection Manager to abort this connection
276 atm_cm_abort(uvp->uv_connvc, &sscf_uni_cause);
284 * uvp pointer to univcc control block
285 * m pointer to pdu buffer chain
286 * msg pointer to message string
293 sscf_uni_pdu_print(struct univcc *uvp, KBuffer *m, char *msg)
298 vcp = uvp->uv_connvc->cvc_vcc;
299 ksnprintf(buf, sizeof(buf), "sscf_uni %s: vcc=(%d,%d)\n",
300 msg, vcp->vc_vpi, vcp->vc_vci);
301 atm_pdu_print(m, buf);