6 * Author: Harti Brandt <harti@freebsd.org>
8 * Redistribution of this software and documentation and use in source and
9 * binary forms, with or without modification, are permitted provided that
10 * the following conditions are met:
12 * 1. Redistributions of source code or documentation must retain the above
13 * copyright notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in the
16 * documentation and/or other materials provided with the distribution.
18 * THIS SOFTWARE AND DOCUMENTATION IS PROVIDED BY THE AUTHOR
19 * AND ITS CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
20 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
21 * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
22 * THE AUTHOR OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
23 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
25 * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
26 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
27 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
28 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 * $Begemot: libunimsg/netnatm/api/cc_data.c,v 1.1 2004/07/08 08:21:50 brandt Exp $
32 * ATM API as defined per af-saa-0108
34 #include <netnatm/unimsg.h>
35 #include <netnatm/msg/unistruct.h>
36 #include <netnatm/msg/unimsglib.h>
37 #include <netnatm/api/unisap.h>
38 #include <netnatm/sig/unidef.h>
39 #include <netnatm/api/atmapi.h>
40 #include <netnatm/api/ccatm.h>
41 #include <netnatm/api/ccpriv.h>
44 * Create a new call control instance
47 cc_create(const struct cc_funcs *vtab)
51 cc = CCMALLOC(sizeof(*cc));
55 LIST_INIT(&cc->user_list);
56 TAILQ_INIT(&cc->port_list);
57 LIST_INIT(&cc->orphaned_conns);
58 TAILQ_INIT(&cc->sigs);
59 TAILQ_INIT(&cc->def_sigs);
60 TAILQ_INIT(&cc->free_sigs);
68 * Reset everything the hard way by just freeing the data
71 cc_reset(struct ccdata *cc)
74 while (!LIST_EMPTY(&cc->user_list))
75 cc_user_destroy(LIST_FIRST(&cc->user_list));
77 while (!TAILQ_EMPTY(&cc->port_list))
78 cc_port_destroy(TAILQ_FIRST(&cc->port_list), 1);
80 while (!LIST_EMPTY(&cc->orphaned_conns))
81 cc_conn_destroy(LIST_FIRST(&cc->orphaned_conns));
83 CCASSERT(LIST_EMPTY(&cc->user_list),
84 ("user list not empty"));
85 CCASSERT(LIST_EMPTY(&cc->orphaned_conns),
86 ("still orphaned conns"));
94 * Destroy a call control instance and free all data
97 cc_destroy(struct ccdata *cc)
105 * set/get logging flags
108 cc_set_log(struct ccdata *cc, u_int flags)
113 cc_get_log(const struct ccdata *cc)
118 /* get extended status */
120 cc_get_extended_status(const struct ccdata *cc, struct atm_exstatus *status,
121 struct atm_exstatus_ep **pep, struct atm_exstatus_port **pport,
122 struct atm_exstatus_conn **pconn, struct atm_exstatus_party **pparty)
124 const struct ccuser *user;
125 const struct ccport *port;
126 const struct ccconn *conn;
127 const struct ccparty *party;
128 struct atm_exstatus_ep *eep;
129 struct atm_exstatus_port *eport;
130 struct atm_exstatus_conn *econn;
131 struct atm_exstatus_party *eparty;
133 /* count and allocate */
135 LIST_FOREACH(user, &cc->user_list, node_link)
140 status->nparties = 0;
141 LIST_FOREACH(conn, &cc->orphaned_conns, port_link) {
143 LIST_FOREACH(party, &conn->parties, link)
146 TAILQ_FOREACH(port, &cc->port_list, node_link) {
148 LIST_FOREACH(conn, &port->conn_list, port_link) {
150 LIST_FOREACH(party, &conn->parties, link)
155 *pep = CCMALLOC(sizeof(**pep) * status->neps);
156 *pport = CCMALLOC(sizeof(**pport) * status->nports);
157 *pconn = CCMALLOC(sizeof(**pconn) * status->nconns);
158 *pparty = CCMALLOC(sizeof(**pparty) * status->nparties);
160 if (*pep == NULL || *pport == NULL ||
161 *pconn == NULL || *pparty == NULL) {
174 /* collect information */
175 LIST_FOREACH(user, &cc->user_list, node_link) {
176 strcpy(eep->name, user->name);
177 eep->state = user->state;
181 LIST_FOREACH(conn, &cc->orphaned_conns, port_link) {
182 econn->id = econn - *pconn;
184 if (conn->user != NULL)
185 strcpy(econn->ep, conn->user->name);
188 econn->state = conn->state;
189 econn->cref = conn->cref.cref;
191 econn->cref |= (1 << 23);
192 LIST_FOREACH(party, &conn->parties, link) {
193 eparty->connid = econn - *pconn;
194 eparty->epref = party->epref.epref;
195 eparty->state = party->state;
201 TAILQ_FOREACH(port, &cc->port_list, node_link) {
202 eport->portno = port->param.port;
203 eport->state = port->admin;
204 LIST_FOREACH(conn, &port->conn_list, port_link) {
205 econn->id = econn - *pconn;
206 econn->port = port->param.port;
207 if (conn->user != NULL)
208 strcpy(econn->ep, conn->user->name);
211 econn->state = conn->state;
212 econn->cref = conn->cref.cref;
214 econn->cref |= (1 << 23);
215 LIST_FOREACH(party, &conn->parties, link) {
216 eparty->connid = econn - *pconn;
217 eparty->epref = party->epref.epref;
218 eparty->state = party->state;