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 * Signalling AAL SSCF at the UNI
33 #include <sys/cdefs.h>
34 __FBSDID("$FreeBSD$");
36 #include <sys/param.h>
37 #include <sys/types.h>
38 #include <sys/systm.h>
39 #include <sys/errno.h>
41 #include <sys/socket.h>
42 #include <sys/socketvar.h>
43 #include <sys/syslog.h>
45 #include <netatm/port.h>
46 #include <netatm/queue.h>
47 #include <netatm/atm.h>
48 #include <netatm/atm_sys.h>
49 #include <netatm/atm_sap.h>
50 #include <netatm/atm_cm.h>
51 #include <netatm/atm_if.h>
52 #include <netatm/atm_vc.h>
53 #include <netatm/atm_stack.h>
54 #include <netatm/atm_pcb.h>
55 #include <netatm/atm_var.h>
57 #include <netatm/uni/uni.h>
58 #include <netatm/uni/sscf_uni_var.h>
65 int sscf_uni_vccnt = 0;
70 static int sscf_uni_inst(struct stack_defn **, Atm_connvc *);
76 uma_zone_t sscf_uni_zone;
78 static struct stack_defn sscf_uni_service = {
88 static struct t_atm_cause sscf_uni_cause = {
91 T_ATM_CAUSE_TEMPORARY_FAILURE,
97 * Initialize SSCF UNI processing
99 * This will be called during module loading. We will register our stack
100 * service and wait for someone to talk to us.
106 * 0 initialization was successful
107 * errno initialization failed - reason indicated
115 sscf_uni_zone = uma_zcreate("sscf uni", sizeof(struct univcc), NULL,
116 NULL, NULL, NULL, UMA_ALIGN_PTR, 0);
117 if (sscf_uni_zone == NULL)
118 panic("sscf_uni_start: uma_zcreate");
121 * Register stack service
123 err = atm_stack_register(&sscf_uni_service);
129 * Terminate SSCF UNI processing
131 * This will be called just prior to unloading the module from memory. All
132 * signalling instances should have been terminated by now, so we just free
133 * up all of our resources.
141 * 0 termination was successful
142 * errno termination failed - reason indicated
149 * Any connections still exist??
151 if (sscf_uni_vccnt) {
154 * Yes, can't stop yet
160 * Deregister the stack service
162 (void)atm_stack_deregister(&sscf_uni_service);
163 uma_zdestroy(sscf_uni_zone);
169 * SSCF_UNI Stack Instantiation
174 * ssp pointer to array of stack definition pointers for connection
175 * ssp[0] points to upper layer's stack service definition
176 * ssp[1] points to this layer's stack service definition
177 * ssp[2] points to lower layer's stack service definition
178 * cvp pointer to connection vcc for this stack
181 * 0 instantiation successful
182 * errno instantiation failed - reason indicated
186 sscf_uni_inst(ssp, cvp)
187 struct stack_defn **ssp;
190 struct stack_defn *sdp_up = ssp[0],
196 ATM_DEBUG2("sscf_uni_inst: ssp=%p, cvp=%p\n", ssp, cvp);
201 if (sdp_low->sd_sap != SAP_SSCOP)
205 * Allocate our control block
207 uvp = uma_zalloc(sscf_uni_zone, M_WAITOK);
210 uvp->uv_ustate = UVU_INST;
211 uvp->uv_lstate = UVL_INST;
212 uvp->uv_connvc = cvp;
213 uvp->uv_toku = sdp_up->sd_toku;
214 uvp->uv_upper = sdp_up->sd_upper;
218 * Store my token into service definition
220 sdp_me->sd_toku = uvp;
223 * Update and save input buffer headroom
226 /* uvp->uv_headin = cvp->cvc_attr.headin; */
229 * Pass instantiation down the stack
231 err = sdp_low->sd_inst(ssp + 1, cvp);
234 * Lower layer instantiation failed, free our resources
236 uma_zfree(sscf_uni_zone, uvp);
242 * Save and update output buffer headroom
244 /* uvp->uv_headout = cvp->cvc_attr.headout; */
248 * Save lower layer's interface info
250 uvp->uv_lower = sdp_low->sd_lower;
251 uvp->uv_tokl = sdp_low->sd_toku;
258 * Abort an SSCF_UNI connection
260 * Called when an unrecoverable or "should never happen" error occurs.
261 * We just log a message and request the signalling manager to abort the
265 * uvp pointer to univcc control block
266 * msg pointer to error message
273 sscf_uni_abort(uvp, msg)
280 log(LOG_ERR, "%s", msg);
283 * Set termination states
285 uvp->uv_ustate = UVU_TERM;
286 uvp->uv_lstate = UVL_TERM;
289 * Tell Connection Manager to abort this connection
291 (void) atm_cm_abort(uvp->uv_connvc, &sscf_uni_cause);
299 * uvp pointer to univcc control block
300 * m pointer to pdu buffer chain
301 * msg pointer to message string
308 sscf_uni_pdu_print(const struct univcc *uvp, const KBuffer *m, const char *msg)
313 vcp = uvp->uv_connvc->cvc_vcc;
314 snprintf(buf, sizeof(buf), "sscf_uni %s: vcc=(%d,%d)\n",
315 msg, vcp->vc_vpi, vcp->vc_vci);
316 atm_pdu_print(m, buf);