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 * PVC-only Signalling Manager
28 * ---------------------------
33 #include <sys/cdefs.h>
34 __FBSDID("$FreeBSD$");
36 #include <sys/param.h>
37 #include <sys/systm.h>
38 #include <sys/socket.h>
40 #include <netatm/port.h>
41 #include <netatm/queue.h>
42 #include <netatm/atm.h>
43 #include <netatm/atm_sys.h>
44 #include <netatm/atm_cm.h>
45 #include <netatm/atm_if.h>
46 #include <netatm/atm_vc.h>
47 #include <netatm/atm_sigmgr.h>
49 #include <netatm/sigpvc/sigpvc_var.h>
53 extern uma_zone_t sigpvc_vc_zone;
56 * Create a SigPVC Permanent Virtual Channel
58 * This function will construct a vccb for a "sigpvc-controlled" PVC
59 * and create the service stack requested by the user.
61 * Must be called at splnet.
64 * pvp pointer to sigpvc protocol instance
65 * cvp pointer to CM's connection VCC
66 * errp location to store an error code if CALL_FAILED is returned
69 * CALL_FAILED - pvc creation failed
70 * CALL_CONNECTED - pvc has been successfully created
74 sigpvc_create_pvc(pvp, cvp, errp)
83 pp = (Atm_addr_pvc *)cvp->cvc_attr.called.addr.address;
84 vpi = ATM_PVC_GET_VPI(pp);
85 vci = ATM_PVC_GET_VCI(pp);
88 * Verify requested VPI,VCI
90 if ((vpi > pvp->pv_pif->pif_maxvpi) ||
91 (vci == 0) || (vci > pvp->pv_pif->pif_maxvci)) {
96 for (vcp = Q_HEAD(pvp->pv_vccq, struct vccb); vcp;
97 vcp = Q_NEXT(vcp, struct vccb, vc_sigelem)) {
99 if ((vcp->vc_vpi == vpi) &&
100 (vcp->vc_vci == vci)) {
102 return (CALL_FAILED);
107 * Verify network interface
109 if (cvp->cvc_attr.nif) {
110 if (cvp->cvc_attr.nif->nif_pif != pvp->pv_pif) {
112 return (CALL_FAILED);
117 * Allocate control block for PVC
119 vcp = uma_zalloc(sigpvc_vc_zone, M_WAITOK | M_ZERO);
122 return (CALL_FAILED);
128 vcp->vc_type = VCC_PVC | VCC_IN | VCC_OUT;
129 vcp->vc_proto = ATM_SIG_PVC;
130 vcp->vc_sstate = VCCS_ACTIVE;
131 vcp->vc_ustate = VCCU_OPEN;
132 vcp->vc_pif = pvp->pv_pif;
133 vcp->vc_nif = cvp->cvc_attr.nif;
136 vcp->vc_connvc = cvp;
139 * Put VCCB on sigpvc queue
141 ENQUEUE(vcp, struct vccb, vc_sigelem, pvp->pv_vccq);
144 * Pass back VCCB to connection manager
149 * PVC is ready to go!
151 return (CALL_CONNECTED);
157 * Clean up vccb, note that it's closing and wait for its freeing.
160 * vcp pointer to connection's VCC control block
167 sigpvc_close_vcc(vcp)
172 * Sanity check (actually design-flaw check)
174 if (vcp->vc_connvc->cvc_upcnt || vcp->vc_connvc->cvc_downcnt)
175 panic("sigpvc_close_vcc: stack call");
178 * Set state variables
180 vcp->vc_ustate = VCCU_CLOSED;
181 vcp->vc_sstate = VCCS_FREE;
184 * Wait for user to free resources