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/sigpvc/sigpvc_subr.c,v 1.4 2000/01/17 20:49:46 mks Exp $
31 * PVC-only Signalling Manager
32 * ---------------------------
38 #include <netatm/kern_include.h>
40 #include <netatm/sigpvc/sigpvc_var.h>
43 __RCSID("@(#) $FreeBSD: src/sys/netatm/sigpvc/sigpvc_subr.c,v 1.4 2000/01/17 20:49:46 mks Exp $");
46 extern struct sp_info sigpvc_vcpool;
49 * Create a SigPVC Permanent Virtual Channel
51 * This function will construct a vccb for a "sigpvc-controlled" PVC
52 * and create the service stack requested by the user.
54 * Must be called at splnet.
57 * pvp pointer to sigpvc protocol instance
58 * cvp pointer to CM's connection VCC
59 * errp location to store an error code if CALL_FAILED is returned
62 * CALL_FAILED - pvc creation failed
63 * CALL_CONNECTED - pvc has been successfully created
67 sigpvc_create_pvc(pvp, cvp, errp)
76 pp = (Atm_addr_pvc *)cvp->cvc_attr.called.addr.address;
77 vpi = ATM_PVC_GET_VPI(pp);
78 vci = ATM_PVC_GET_VCI(pp);
81 * Verify requested VPI,VCI
83 if ((vpi > pvp->pv_pif->pif_maxvpi) ||
84 (vci == 0) || (vci > pvp->pv_pif->pif_maxvci)) {
89 for (vcp = Q_HEAD(pvp->pv_vccq, struct vccb); vcp;
90 vcp = Q_NEXT(vcp, struct vccb, vc_sigelem)) {
92 if ((vcp->vc_vpi == vpi) &&
93 (vcp->vc_vci == vci)) {
100 * Verify network interface
102 if (cvp->cvc_attr.nif) {
103 if (cvp->cvc_attr.nif->nif_pif != pvp->pv_pif) {
105 return (CALL_FAILED);
110 * Allocate control block for PVC
112 vcp = (struct vccb *)atm_allocate(&sigpvc_vcpool);
115 return (CALL_FAILED);
121 vcp->vc_type = VCC_PVC | VCC_IN | VCC_OUT;
122 vcp->vc_proto = ATM_SIG_PVC;
123 vcp->vc_sstate = VCCS_ACTIVE;
124 vcp->vc_ustate = VCCU_OPEN;
125 vcp->vc_pif = pvp->pv_pif;
126 vcp->vc_nif = cvp->cvc_attr.nif;
129 vcp->vc_connvc = cvp;
132 * Put VCCB on sigpvc queue
134 ENQUEUE(vcp, struct vccb, vc_sigelem, pvp->pv_vccq);
137 * Pass back VCCB to connection manager
142 * PVC is ready to go!
144 return (CALL_CONNECTED);
150 * Clean up vccb, note that it's closing and wait for its freeing.
153 * vcp pointer to connection's VCC control block
160 sigpvc_close_vcc(vcp)
165 * Sanity check (actually design-flaw check)
167 if (vcp->vc_connvc->cvc_upcnt || vcp->vc_connvc->cvc_downcnt)
168 panic("sigpvc_close_vcc: stack call");
171 * Set state variables
173 vcp->vc_ustate = VCCU_CLOSED;
174 vcp->vc_sstate = VCCS_FREE;
177 * Wait for user to free resources