This commit was generated by cvs2svn to compensate for changes in r131826,

which included commits to RCS files with non-trunk default branches.
This commit is contained in:
harti 2004-07-08 16:39:03 +00:00
commit 43a26a9ece
55 changed files with 7612 additions and 149 deletions

View File

@ -26,7 +26,7 @@
*
* Author: Hartmut Brandt <harti@freebsd.org>
*
* $Begemot: libunimsg/atm/addr.h,v 1.2 2003/09/19 13:10:35 hbb Exp $
* $Begemot: libunimsg/netnatm/addr.h,v 1.3 2004/07/08 08:21:45 brandt Exp $
*/
#ifndef _NETNATM_ADDR_H_
#define _NETNATM_ADDR_H_

View File

@ -0,0 +1,291 @@
/*
* Copyright (c) 2003-2004
* Hartmut Brandt
* All rights reserved.
*
* Copyright (c) 2001-2002
* Fraunhofer Institute for Open Communication Systems (FhG Fokus).
* All rights reserved.
*
* Author: Harti Brandt <harti@freebsd.org>
*
* Redistribution of this software and documentation and use in source and
* binary forms, with or without modification, are permitted provided that
* the following conditions are met:
*
* 1. Redistributions of source code or documentation must retain the above
* copyright notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE AND DOCUMENTATION IS PROVIDED BY THE AUTHORS
* AND ITS CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
* THE AUTHORS OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* $Begemot: libunimsg/netnatm/api/atmapi.h,v 1.1 2004/07/08 08:21:48 brandt Exp $
*
* ATM API as defined per af-saa-0108
*/
#ifndef _NETNATM_API_ATMAPI_H_
#define _NETNATM_API_ATMAPI_H_
#include <sys/types.h>
/* size of an endpointlen including trailing \0 */
#define ATM_EPNAMSIZ 65
enum atmstate {
ATM_A0, /* non existent */
ATM_A1, /* initial */
ATM_A2, /* outgoing call preparation */
ATM_A3, /* outgoing call requested */
ATM_A4, /* incoming call preparation */
ATM_A5, /* wait incoming call */
ATM_A6, /* incoming call present */
ATM_A7, /* incoming call requested */
ATM_A8, /* p2p data transfer */
ATM_A9, /* p2mp root data transfer */
ATM_A10, /* p2mp leaf data transfer */
ATM_A11, /* terminated */
};
enum atmop {
ATMOP_RESP, /* 0 */
ATMOP_ABORT_CONNECTION,
ATMOP_ACCEPT_INCOMING_CALL,
ATMOP_ADD_PARTY,
ATMOP_ADD_PARTY_REJECT,
ATMOP_ADD_PARTY_SUCCESS, /* 5 */
ATMOP_ARRIVAL_OF_INCOMING_CALL,
ATMOP_CALL_RELEASE,
ATMOP_CONNECT_OUTGOING_CALL,
ATMOP_DROP_PARTY,
ATMOP_GET_LOCAL_PORT_INFO, /* 10 */
ATMOP_P2MP_CALL_ACTIVE,
ATMOP_P2P_CALL_ACTIVE,
ATMOP_PREPARE_INCOMING_CALL,
ATMOP_PREPARE_OUTGOING_CALL,
ATMOP_QUERY_CONNECTION_ATTRIBUTES, /* 15 */
ATMOP_REJECT_INCOMING_CALL,
ATMOP_SET_CONNECTION_ATTRIBUTES,
ATMOP_WAIT_ON_INCOMING_CALL,
ATMOP_SET_CONNECTION_ATTRIBUTES_X,
ATMOP_QUERY_CONNECTION_ATTRIBUTES_X, /* 20 */
ATMOP_QUERY_STATE,
};
#define ATM_DEFINE_ERRORS \
DEF(ATMERR_OK, 0, "OK") \
DEF(ATMERR_SYS, -1, "syscall error") \
DEF(ATMERR_BAD_OP, -2, "bad operation") \
DEF(ATMERR_BAD_ARGS, -3, "bad arguments for operation") \
DEF(ATMERR_BAD_STATE, -4, "operation in bad state") \
DEF(ATMERR_BAD_ATTR, -5, "unknown attribute") \
DEF(ATMERR_BAD_VALUE, -6, "bad attribute value") \
DEF(ATMERR_BUSY, -7, "busy") \
DEF(ATMERR_RDONLY, -8, "read-only attribute") \
DEF(ATMERR_BAD_SAP, -9, "bad SAP") \
DEF(ATMERR_OVERLAP, -10,"overlaping SAP") \
DEF(ATMERR_BAD_ENDPOINT, -11,"bad ATM endpoint") \
DEF(ATMERR_PREVIOUSLY_ABORTED,-12,"previously aborted") \
DEF(ATMERR_NO_CALL, -13,"no incoming call") \
DEF(ATMERR_BAD_LEAF_IDENT, -14,"bad leaf identifier") \
DEF(ATMERR_BAD_PORT, -15,"unknown port") \
DEF(ATMERR_BAD_SIGNAL, -29-UNIAPI_ERROR_BAD_SIGNAL, "bad signal")\
DEF(ATMERR_BADCU, -29-UNIAPI_ERROR_BADCU, "bad coordinator state")\
DEF(ATMERR_BAD_CALLSTATE, -29-UNIAPI_ERROR_BAD_CALLSTATE, "bad call state")\
DEF(ATMERR_BAD_EPSTATE, -29-UNIAPI_ERROR_BAD_EPSTATE, "bad party state")\
DEF(ATMERR_BAD_UNIARG, -29-UNIAPI_ERROR_BAD_ARG, "bad uni argument")\
DEF(ATMERR_BAD_CALL, -29-UNIAPI_ERROR_BAD_CALL, "unknown call")\
DEF(ATMERR_BAD_PARTY, -29-UNIAPI_ERROR_BAD_PARTY, "unknown party")\
DEF(ATMERR_BAD_CTYPE, -29-UNIAPI_ERROR_BAD_CTYPE, "wrong call type")\
DEF(ATMERR_BAD_IE, -29-UNIAPI_ERROR_BAD_IE, "bad information element")\
DEF(ATMERR_EPREF_INUSE, -29-UNIAPI_ERROR_EPREF_INUSE, "endpoint reference in use")\
DEF(ATMERR_MISSING_IE, -29-UNIAPI_ERROR_MISSING_IE, "missing information element")\
DEF(ATMERR_ENCODING, -29-UNIAPI_ERROR_ENCODING, "encoding error")\
DEF(ATMERR_NOMEM, -29-UNIAPI_ERROR_NOMEM, "no memory")\
DEF(ATMERR_UNIBUSY, -29-UNIAPI_ERROR_BUSY, "uni process busy")
#define ATM_MKUNIERR(E) (-29 - (E))
enum atm_error {
#define DEF(NAME,VAL,STR) NAME = (VAL),
ATM_DEFINE_ERRORS
#undef DEF
};
enum atm_attribute {
ATM_ATTR_NONE = 0,
ATM_ATTR_BLLI_SELECTOR,
ATM_ATTR_BLLI,
ATM_ATTR_BEARER,
ATM_ATTR_TRAFFIC,
ATM_ATTR_QOS,
ATM_ATTR_EXQOS,
ATM_ATTR_CALLED,
ATM_ATTR_CALLEDSUB,
ATM_ATTR_CALLING,
ATM_ATTR_CALLINGSUB,
ATM_ATTR_AAL,
ATM_ATTR_EPREF,
ATM_ATTR_CONNED,
ATM_ATTR_CONNEDSUB,
ATM_ATTR_EETD,
ATM_ATTR_ABRSETUP,
ATM_ATTR_ABRADD,
ATM_ATTR_CONNID,
ATM_ATTR_MDCR,
};
struct atm_resp {
int32_t resp;
uint32_t data; /* type of attached data */
};
enum {
ATMRESP_NONE, /* no data */
ATMRESP_ATTRS, /* attribute(s) */
ATMRESP_PORTS, /* port info */
ATMRESP_STATE, /* endpoint state */
ATMRESP_EXSTAT, /* extended status */
};
struct atm_abort_connection {
struct uni_ie_cause cause;
};
struct atm_query_connection_attributes {
uint32_t attr;
};
struct atm_set_connection_attributes {
uint32_t attr;
};
struct atm_query_connection_attributes_x {
uint32_t count;
#if defined(__GNUC__) && __GNUC__ < 3
uint32_t attr[0];
#else
uint32_t attr[];
#endif
};
struct atm_set_connection_attributes_x {
uint32_t count;
#if defined(__GNUC__) && __GNUC__ < 3
uint32_t attr[0];
#else
uint32_t attr[];
#endif
};
struct atm_prepare_incoming_call {
struct uni_sap sap;
uint32_t queue_size;
};
struct atm_connect_outgoing_call {
struct uni_ie_called called;
};
struct atm_call_release {
struct uni_ie_cause cause[2];
};
struct atm_p2p_call_active {
struct uni_ie_connid connid;
};
struct atm_p2mp_call_active {
struct uni_ie_connid connid;
};
struct atm_accept_incoming_call {
char newep[ATM_EPNAMSIZ];
};
struct atm_reject_incoming_call {
struct uni_ie_cause cause;
};
struct atm_add_party {
uint16_t leaf_ident;
struct uni_ie_called called;
};
struct atm_add_party_success {
uint16_t leaf_ident;
};
struct atm_add_party_reject {
uint16_t leaf_ident;
struct uni_ie_cause cause;
};
struct atm_drop_party {
uint16_t leaf_ident;
struct uni_ie_cause cause;
};
/*
* Get local port info. If port is 0, information on all ports is returned,
* otherwise only on the named port.
* The response consists of a header with two counters, a list of ports
* (struct atm_port_info) and a list of addresses (struct uni_addr).
* The port to which an address belongs is implicit in the num_addrs field
* of the port.
*/
struct atm_get_local_port_info {
uint32_t port;
};
struct atm_port_list {
uint32_t num_ports; /* number of ports */
uint32_t num_addrs; /* total number of addresses */
};
struct atm_port_info {
uint32_t port;
uint32_t pcr;
uint32_t max_vpi_bits;
uint32_t max_vci_bits;
uint32_t max_svpc_vpi;
uint32_t max_svcc_vpi;
uint32_t min_svcc_vci;
u_char esi[6];
uint32_t num_addrs; /* number of addresses on this port */
};
/*
* Endpoint state info
*/
struct atm_epstate {
char name[ATM_EPNAMSIZ];
uint8_t state;
};
/*
* Extended status information.
*/
struct atm_exstatus {
uint32_t neps; /* endpoints */
uint32_t nports; /* ports */
uint32_t nconns; /* connections */
uint32_t nparties; /* number of parties */
};
struct atm_exstatus_ep {
char name[ATM_EPNAMSIZ];
uint8_t state; /* Ux */
};
struct atm_exstatus_port {
uint32_t portno;
uint8_t state;
};
struct atm_exstatus_conn {
uint32_t id;
uint32_t cref; /* (flag << 23) | cref */
uint32_t port;
char ep[ATM_EPNAMSIZ]; /* \0 - none */
uint8_t state; /* Cx */
};
struct atm_exstatus_party {
uint32_t connid;
uint16_t epref;
uint8_t state; /* Px */
};
#endif

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,226 @@
/*
* Copyright (c) 2004
* Hartmut Brandt
* All rights reserved.
*
* Author: Harti Brandt <harti@freebsd.org>
*
* Redistribution of this software and documentation and use in source and
* binary forms, with or without modification, are permitted provided that
* the following conditions are met:
*
* 1. Redistributions of source code or documentation must retain the above
* copyright notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE AND DOCUMENTATION IS PROVIDED BY THE AUTHOR
* AND ITS CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
* THE AUTHOR OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* $Begemot: libunimsg/netnatm/api/cc_data.c,v 1.1 2004/07/08 08:21:50 brandt Exp $
*
* ATM API as defined per af-saa-0108
*/
#include <netnatm/unimsg.h>
#include <netnatm/msg/unistruct.h>
#include <netnatm/msg/unimsglib.h>
#include <netnatm/api/unisap.h>
#include <netnatm/sig/unidef.h>
#include <netnatm/api/atmapi.h>
#include <netnatm/api/ccatm.h>
#include <netnatm/api/ccpriv.h>
/*
* Create a new call control instance
*/
struct ccdata *
cc_create(const struct cc_funcs *vtab)
{
struct ccdata *cc;
cc = CCMALLOC(sizeof(*cc));
if (cc == NULL)
return (NULL);
LIST_INIT(&cc->user_list);
TAILQ_INIT(&cc->port_list);
LIST_INIT(&cc->orphaned_conns);
TAILQ_INIT(&cc->sigs);
TAILQ_INIT(&cc->def_sigs);
TAILQ_INIT(&cc->free_sigs);
cc->funcs = vtab;
cc->cookie = 0;
return (cc);
}
/*
* Reset everything the hard way by just freeing the data
*/
void
cc_reset(struct ccdata *cc)
{
while (!LIST_EMPTY(&cc->user_list))
cc_user_destroy(LIST_FIRST(&cc->user_list));
while (!TAILQ_EMPTY(&cc->port_list))
cc_port_destroy(TAILQ_FIRST(&cc->port_list), 1);
while (!LIST_EMPTY(&cc->orphaned_conns))
cc_conn_destroy(LIST_FIRST(&cc->orphaned_conns));
CCASSERT(LIST_EMPTY(&cc->user_list),
("user list not empty"));
CCASSERT(LIST_EMPTY(&cc->orphaned_conns),
("still orphaned conns"));
cc_sig_flush_all(cc);
cc->cookie = 0;
}
/*
* Destroy a call control instance and free all data
*/
void
cc_destroy(struct ccdata *cc)
{
cc_reset(cc);
CCFREE(cc);
}
/*
* set/get logging flags
*/
void
cc_set_log(struct ccdata *cc, u_int flags)
{
cc->log = flags;
}
u_int
cc_get_log(const struct ccdata *cc)
{
return (cc->log);
}
/* get extended status */
int
cc_get_extended_status(const struct ccdata *cc, struct atm_exstatus *status,
struct atm_exstatus_ep **pep, struct atm_exstatus_port **pport,
struct atm_exstatus_conn **pconn, struct atm_exstatus_party **pparty)
{
const struct ccuser *user;
const struct ccport *port;
const struct ccconn *conn;
const struct ccparty *party;
struct atm_exstatus_ep *eep;
struct atm_exstatus_port *eport;
struct atm_exstatus_conn *econn;
struct atm_exstatus_party *eparty;
/* count and allocate */
status->neps = 0;
LIST_FOREACH(user, &cc->user_list, node_link)
status->neps++;
status->nports = 0;
status->nconns = 0;
status->nparties = 0;
LIST_FOREACH(conn, &cc->orphaned_conns, port_link) {
status->nconns++;
LIST_FOREACH(party, &conn->parties, link)
status->nparties++;
}
TAILQ_FOREACH(port, &cc->port_list, node_link) {
status->nports++;
LIST_FOREACH(conn, &port->conn_list, port_link) {
status->nconns++;
LIST_FOREACH(party, &conn->parties, link)
status->nparties++;
}
}
*pep = CCMALLOC(sizeof(**pep) * status->neps);
*pport = CCMALLOC(sizeof(**pport) * status->nports);
*pconn = CCMALLOC(sizeof(**pconn) * status->nconns);
*pparty = CCMALLOC(sizeof(**pparty) * status->nparties);
if (*pep == NULL || *pport == NULL ||
*pconn == NULL || *pparty == NULL) {
CCFREE(*pep);
CCFREE(*pport);
CCFREE(*pconn);
CCFREE(*pparty);
return (ENOMEM);
}
eep = *pep;
eport = *pport;
econn = *pconn;
eparty = *pparty;
/* collect information */
LIST_FOREACH(user, &cc->user_list, node_link) {
strcpy(eep->name, user->name);
eep->state = user->state;
eep++;
}
LIST_FOREACH(conn, &cc->orphaned_conns, port_link) {
econn->id = econn - *pconn;
econn->port = 0;
if (conn->user != NULL)
strcpy(econn->ep, conn->user->name);
else
econn->ep[0] = '\0';
econn->state = conn->state;
econn->cref = conn->cref.cref;
if (conn->cref.flag)
econn->cref |= (1 << 23);
LIST_FOREACH(party, &conn->parties, link) {
eparty->connid = econn - *pconn;
eparty->epref = party->epref.epref;
eparty->state = party->state;
eparty++;
}
econn++;
}
TAILQ_FOREACH(port, &cc->port_list, node_link) {
eport->portno = port->param.port;
eport->state = port->admin;
LIST_FOREACH(conn, &port->conn_list, port_link) {
econn->id = econn - *pconn;
econn->port = port->param.port;
if (conn->user != NULL)
strcpy(econn->ep, conn->user->name);
else
econn->ep[0] = '\0';
econn->state = conn->state;
econn->cref = conn->cref.cref;
if (conn->cref.flag)
econn->cref |= (1 << 23);
LIST_FOREACH(party, &conn->parties, link) {
eparty->connid = econn - *pconn;
eparty->epref = party->epref.epref;
eparty->state = party->state;
eparty++;
}
econn++;
}
eport++;
}
return (0);
}

View File

@ -0,0 +1,334 @@
/*
* Copyright (c) 2003-2004
* Hartmut Brandt
* All rights reserved.
*
* Author: Harti Brandt <harti@freebsd.org>
*
* Redistribution of this software and documentation and use in source and
* binary forms, with or without modification, are permitted provided that
* the following conditions are met:
*
* 1. Redistributions of source code or documentation must retain the above
* copyright notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE AND DOCUMENTATION IS PROVIDED BY THE AUTHOR
* AND ITS CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
* THE AUTHOR OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* $Begemot: libunimsg/netnatm/api/cc_dump.c,v 1.1 2004/07/08 08:21:51 brandt Exp $
*
* ATM API as defined per af-saa-0108
*/
#include <netnatm/unimsg.h>
#include <netnatm/msg/unistruct.h>
#include <netnatm/msg/unimsglib.h>
#include <netnatm/api/unisap.h>
#include <netnatm/sig/unidef.h>
#include <netnatm/api/atmapi.h>
#include <netnatm/api/ccatm.h>
#include <netnatm/api/ccpriv.h>
#ifdef _KERNEL
#ifdef __FreeBSD__
#include <sys/stdarg.h>
#endif
#else /* !_KERNEL */
#include <stdarg.h>
#endif
/*
* local structure to reduce number of arguments to functions
*/
struct dump {
struct ccdata *cc; /* what to dump */
size_t maxsiz; /* size of user buffer */
cc_dump_f func; /* user function */
void *uarg; /* user supplied argument */
char *buf; /* user buffer */
size_t len; /* current string length */
int ret; /* return code */
};
static void cc_dumpf(struct dump *, const char *, ...) __printflike(2, 3);
static void
cc_dumpf(struct dump *d, const char *fmt, ...)
{
va_list ap;
int n;
if (d->ret != 0)
return;
if (d->len >= d->maxsiz - 1) {
d->ret = d->func(d->cc, d->uarg, d->buf);
if (d->ret != 0)
return;
d->buf[0] = '\0';
d->len = 0;
}
va_start(ap, fmt);
n = vsnprintf(d->buf + d->len, d->maxsiz - d->len, fmt, ap);
va_end(ap);
if (n < 0) {
d->ret = errno;
return;
}
if ((size_t)n < d->maxsiz - d->len) {
d->len += n;
return;
}
/* undo the vsnprintf() and flush */
d->buf[d->len] = '\0';
d->ret = d->func(d->cc, d->uarg, d->buf);
if (d->ret != 0)
return;
d->buf[0] = '\0';
d->len = 0;
va_start(ap, fmt);
n = vsnprintf(d->buf, d->maxsiz, fmt, ap);
va_end(ap);
if (n < 0) {
d->ret = errno;
return;
}
if ((size_t)n >= d->maxsiz) {
/* ok, truncate */
d->len = d->maxsiz - 1;
return;
}
d->len = n;
}
/*
* Dump a SAP
*/
static void
cc_dump_sap(struct dump *d, const struct uni_sap *sap)
{
static const char *const tagtab[] = {
[UNISVE_ABSENT] "absent",
[UNISVE_ANY] "any",
[UNISVE_PRESENT]"present"
};
static const char *const plantab[] = {
[UNI_ADDR_E164] "E164",
[UNI_ADDR_ATME] "ATME",
};
static const char *const hlitab[] = {
[UNI_BHLI_ISO] "ISO",
[UNI_BHLI_VENDOR] "VENDOR",
[UNI_BHLI_USER] "USER"
};
u_int i;
cc_dumpf(d, " sap(%p):\n", sap);
cc_dumpf(d, " addr=%s", tagtab[sap->addr.tag]);
if (sap->addr.tag == UNISVE_PRESENT) {
cc_dumpf(d, " %s %u ", plantab[sap->addr.plan], sap->addr.len);
if (sap->addr.plan == UNI_ADDR_E164)
for (i = 0; i < sap->addr.len; i++)
cc_dumpf(d, "%c", sap->addr.addr[i]);
else
for (i = 0; i < sap->addr.len; i++)
cc_dumpf(d, "%02x", sap->addr.addr[i]);
}
cc_dumpf(d, "\n");
cc_dumpf(d, " selector=%s", tagtab[sap->selector.tag]);
if (sap->selector.tag == UNISVE_PRESENT)
cc_dumpf(d, " %02x", sap->selector.selector);
cc_dumpf(d, "\n");
cc_dumpf(d, " blli_id2=%s", tagtab[sap->blli_id2.tag]);
if (sap->blli_id2.tag == UNISVE_PRESENT)
cc_dumpf(d, " %02x %02x", sap->blli_id2.proto,
sap->blli_id2.user);
cc_dumpf(d, "\n");
cc_dumpf(d, " blli_id3=%s", tagtab[sap->blli_id3.tag]);
if (sap->blli_id3.tag == UNISVE_PRESENT)
cc_dumpf(d, " %02x,%02x, %02x(%d),%03x,%02x",
sap->blli_id3.proto, sap->blli_id3.user,
sap->blli_id3.ipi, sap->blli_id3.noipi,
sap->blli_id3.oui, sap->blli_id3.pid);
cc_dumpf(d, "\n");
cc_dumpf(d, " bhli=%s", tagtab[sap->bhli.tag]);
if (sap->bhli.tag == UNISVE_PRESENT) {
cc_dumpf(d, " %s ", hlitab[sap->bhli.type]);
for (i = 0; i < sap->bhli.len; i++)
cc_dumpf(d, "%02x", sap->bhli.info[i]);
}
cc_dumpf(d, "\n");
}
/*
* Dump a user.
*/
static void
cc_dump_user(struct dump *d, const struct ccuser *user)
{
struct ccconn *conn;
cc_dumpf(d, "user(%p): %s '%s' %s\n", user,
cc_user_state2str(user->state), user->name,
(user->config == USER_P2P) ? "p2p" :
(user->config == USER_ROOT) ? "root" :
(user->config == USER_LEAF) ? "leaf" : "?");
if (user->sap)
cc_dump_sap(d, user->sap);
cc_dumpf(d, " queue=%u/%u accepted=%p aborted=%u\n", user->queue_max,
user->queue_act, user->accepted, user->aborted);
cc_dumpf(d, " connq:");
TAILQ_FOREACH(conn, &user->connq, connq_link)
cc_dumpf(d, "%p", conn);
cc_dumpf(d, "\n");
}
/*
* Dump a party
*/
static void
cc_dump_party(struct dump *d, const struct ccparty *party, const char *pfx)
{
cc_dumpf(d, "%s party(%p): %u.%u %s\n", pfx, party,
party->epref.flag, party->epref.epref,
cc_party_state2str(party->state));
}
/*
* Dump a connection
*/
static void
cc_dump_conn(struct dump *d, const struct ccconn *conn, const char *pfx)
{
const struct ccparty *party;
cc_dumpf(d, "%sconn(%p): %s\n", pfx, conn,
cc_conn_state2str(conn->state));
cc_dumpf(d, "%s user=%p cref=%u.%u acceptor=%p\n", pfx,
conn->user, conn->cref.cref, conn->cref.flag,
conn->acceptor);
cc_dumpf(d, "%s blli_sel=%u\n", pfx, conn->blli_selector);
LIST_FOREACH(party, &conn->parties, link)
cc_dump_party(d, party, pfx);
}
/*
* Dump a port
*/
static void
cc_dump_port(struct dump *d, const struct ccport *p)
{
u_int i;
const struct ccaddr *a;
const struct ccconn *c;
const struct ccreq *r;
static const char *const ttab[] = {
[UNI_ADDR_UNKNOWN] = "unknown",
[UNI_ADDR_INTERNATIONAL] = "international",
[UNI_ADDR_NATIONAL] = "national",
[UNI_ADDR_NETWORK] = "network",
[UNI_ADDR_SUBSCR] = "subscr",
[UNI_ADDR_ABBR] = "abbr",
};
static const char *const ptab[] = {
[UNI_ADDR_UNKNOWN] = "unknown",
[UNI_ADDR_E164] = "e164",
[UNI_ADDR_ATME] = "atme",
[UNI_ADDR_DATA] = "data",
[UNI_ADDR_PRIVATE] = "private",
};
cc_dumpf(d, "port(%p) %u: %s\n", p, p->param.port,
(p->admin == CCPORT_STOPPED) ? "STOPPED" :
(p->admin == CCPORT_RUNNING) ? "RUNNING" : "????");
cc_dumpf(d, " pcr=%u bits=%u.%u ids=%u/%u/%u esi=%02x:%02x:"
"%02x:%02x:%02x:%02x naddrs=%u\n", p->param.pcr,
p->param.max_vpi_bits, p->param.max_vci_bits, p->param.max_svpc_vpi,
p->param.max_svcc_vpi, p->param.min_svcc_vci, p->param.esi[0],
p->param.esi[1], p->param.esi[2], p->param.esi[3], p->param.esi[4],
p->param.esi[5], p->param.num_addrs);
cc_dumpf(d, " cookies:");
TAILQ_FOREACH(r, &p->cookies, link)
cc_dumpf(d, " %u(%p,%u)", r->cookie, r->conn, r->req);
cc_dumpf(d, "\n");
TAILQ_FOREACH(a, &p->addr_list, port_link) {
cc_dumpf(d, " addr(%p): %s %s %u ", a,
(a->addr.type < sizeof(ttab) / sizeof(ttab[0]) &&
ttab[a->addr.type] != NULL) ? ttab[a->addr.type] : "?",
(a->addr.plan < sizeof(ptab) / sizeof(ptab[0]) &&
ptab[a->addr.plan] != NULL) ? ptab[a->addr.plan] : "?",
a->addr.len);
for (i = 0; i < a->addr.len; i++)
cc_dumpf(d, "%02x", a->addr.addr[i]);
cc_dumpf(d, "\n");
}
LIST_FOREACH(c, &p->conn_list, port_link)
cc_dump_conn(d, c, " ");
}
/*
* Produce a textual dump of the state
*/
int
cc_dump(struct ccdata *cc, size_t maxsiz, cc_dump_f func, void *uarg)
{
struct dump d;
struct ccuser *user;
struct ccconn *conn;
struct ccport *port;
d.ret = 0;
d.uarg = uarg;
d.maxsiz = maxsiz;
d.cc = cc;
d.func = func;
d.buf = CCMALLOC(maxsiz);
if (d.buf == NULL)
return (ENOMEM);
d.len = 0;
cc_dumpf(&d, "dump of node %p\n", cc);
TAILQ_FOREACH(port, &cc->port_list, node_link)
cc_dump_port(&d, port);
LIST_FOREACH(user, &cc->user_list, node_link)
cc_dump_user(&d, user);
cc_dumpf(&d, "orphaned conns:\n");
LIST_FOREACH(conn, &cc->orphaned_conns, port_link)
cc_dump_conn(&d, conn, "");
if (d.len > 0 && d.ret == 0)
d.ret = d.func(d.cc, d.uarg, d.buf);
CCFREE(d.buf);
return (d.ret);
}

View File

@ -0,0 +1,923 @@
/*
* Copyright (c) 2003-2004
* Hartmut Brandt
* All rights reserved.
*
* Copyright (c) 2001-2002
* Fraunhofer Institute for Open Communication Systems (FhG Fokus).
* All rights reserved.
*
* Author: Harti Brandt <harti@freebsd.org>
*
* Redistribution of this software and documentation and use in source and
* binary forms, with or without modification, are permitted provided that
* the following conditions are met:
*
* 1. Redistributions of source code or documentation must retain the above
* copyright notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE AND DOCUMENTATION IS PROVIDED BY THE AUTHOR
* AND ITS CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
* THE AUTHOR OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* $Begemot: libunimsg/netnatm/api/cc_port.c,v 1.1 2004/07/08 08:21:53 brandt Exp $
*
* ATM API as defined per af-saa-0108
*
* Port-global stuff (ILMI and Co.)
*/
#include <netnatm/unimsg.h>
#include <netnatm/msg/unistruct.h>
#include <netnatm/api/unisap.h>
#include <netnatm/sig/unidef.h>
#include <netnatm/api/atmapi.h>
#include <netnatm/api/ccatm.h>
#include <netnatm/api/ccpriv.h>
/*
* Find a port with a given number
*/
static struct ccport *
find_port(struct ccdata *cc, u_int portno)
{
struct ccport *port;
TAILQ_FOREACH(port, &cc->port_list, node_link)
if (port->param.port == portno)
return (port);
return (NULL);
}
/*
* Create a new port structure, initialize it and link it to the node.
* Returns 0 on success, an errno otherwise.
*/
struct ccport *
cc_port_create(struct ccdata *cc, void *uarg, u_int portno)
{
struct ccport *port, *p1;
if (portno == 0 || portno > 0xffffffff)
return (NULL);
TAILQ_FOREACH(port, &cc->port_list, node_link)
if (port->param.port == portno)
return (NULL);
port = CCZALLOC(sizeof(*port));
if (port == NULL)
return (NULL);
port->uarg = uarg;
port->cc = cc;
port->admin = CCPORT_STOPPED;
LIST_INIT(&port->conn_list);
TAILQ_INIT(&port->addr_list);
port->param.port = portno;
port->param.pcr = 350053;
port->param.max_vpi_bits = 0;
port->param.max_vci_bits = 8;
port->param.max_svpc_vpi = 0;
port->param.max_svcc_vpi = 0;
port->param.min_svcc_vci = 32;
port->param.num_addrs = 0;
TAILQ_INIT(&port->cookies);
TAILQ_FOREACH(p1, &cc->port_list, node_link)
if (p1->param.port > portno) {
TAILQ_INSERT_BEFORE(p1, port, node_link);
break;
}
if (p1 == NULL)
TAILQ_INSERT_TAIL(&cc->port_list, port, node_link);
return (port);
}
/*
* Destroy a port. This closes all connections and aborts all the users of
* these connections.
* This should be called only after work has returned so that no signals
* are pending.
*/
void
cc_port_destroy(struct ccport *port, int shutdown)
{
struct ccaddr *addr;
struct ccreq *r;
TAILQ_REMOVE(&port->cc->port_list, port, node_link);
while ((r = TAILQ_FIRST(&port->cookies)) != NULL) {
TAILQ_REMOVE(&port->cookies, r, link);
CCFREE(r);
}
/*
* Abort all connections.
*/
while (!LIST_EMPTY(&port->conn_list))
cc_conn_abort(LIST_FIRST(&port->conn_list), shutdown);
/*
* Free addresses.
*/
while ((addr = TAILQ_FIRST(&port->addr_list)) != NULL) {
TAILQ_REMOVE(&port->addr_list, addr, port_link);
CCFREE(addr);
}
CCFREE(port);
}
/*
* Management is given up on this node. Remove all addresses from the port.
*/
void
cc_unmanage(struct ccdata *cc)
{
struct ccport *port;
struct ccaddr *addr;
TAILQ_FOREACH(port, &cc->port_list, node_link) {
while ((addr = TAILQ_FIRST(&port->addr_list)) != NULL) {
TAILQ_REMOVE(&port->addr_list, addr, port_link);
CCFREE(addr);
}
}
}
/*
* Compare two addresses
*/
static __inline int
addr_eq(const struct uni_addr *a1, const struct uni_addr *a2)
{
return (a1->type == a2->type && a1->plan == a2->plan &&
a1->len == a2->len && memcmp(a1->addr, a2->addr, a1->len) == 0);
}
/*
* retrieve addresses
*/
int
cc_get_addrs(struct ccdata *cc, u_int portno,
struct uni_addr **pa, u_int **ports, u_int *count)
{
struct ccport *port = NULL;
struct ccaddr *addr;
struct uni_addr *buf, *ptr;
u_int *pports;
/*
* If a port number is specified and the port does not exist,
* return an error.
*/
if (portno != 0)
if ((port = find_port(cc, portno)) == NULL)
return (ENOENT);
/*
* Count the addresses
*/
*count = 0;
if (portno != 0) {
TAILQ_FOREACH(addr, &port->addr_list, port_link)
(*count)++;
} else {
TAILQ_FOREACH(port, &cc->port_list, node_link)
TAILQ_FOREACH(addr, &port->addr_list, port_link)
(*count)++;
}
buf = CCMALLOC(*count * sizeof(struct uni_addr));
if (buf == NULL)
return (ENOMEM);
ptr = buf;
*ports = CCMALLOC(*count * sizeof(u_int));
if (*ports == NULL) {
CCFREE(buf);
return (ENOMEM);
}
pports = *ports;
if (portno != 0) {
TAILQ_FOREACH(addr, &port->addr_list, port_link) {
*ptr++ = addr->addr;
*pports++ = portno;
}
} else {
TAILQ_FOREACH(port, &cc->port_list, node_link)
TAILQ_FOREACH(addr, &port->addr_list, port_link) {
*ptr++ = addr->addr;
*pports++ = port->param.port;
}
}
*pa = buf;
return (0);
}
/*
* return port number
*/
u_int
cc_port_no(struct ccport *port)
{
return (port->param.port);
}
/*
* Address unregisterd.
*/
int
cc_addr_unregister(struct ccdata *cc, u_int portno, const struct uni_addr *arg)
{
struct ccport *port;
struct ccaddr *a;
if ((port = find_port(cc, portno)) == NULL)
return (ENOENT);
/* Find the address */
TAILQ_FOREACH(a, &port->addr_list, port_link)
if (addr_eq(arg, &a->addr)) {
TAILQ_REMOVE(&port->addr_list, a, port_link);
CCFREE(a);
return (0);
}
return (ENOENT);
}
/*
* Address registerd.
*/
int
cc_addr_register(struct ccdata *cc, u_int portno, const struct uni_addr *arg)
{
struct ccport *port, *p1;
struct ccaddr *a;
if ((port = find_port(cc, portno)) == NULL)
return (ENOENT);
/* maybe we know it already? */
TAILQ_FOREACH(p1, &port->cc->port_list, node_link)
TAILQ_FOREACH(a, &p1->addr_list, port_link)
if (addr_eq(arg, &a->addr))
return (EISCONN);
a = CCZALLOC(sizeof(*a));
if (a == NULL)
return (ENOMEM);
a->addr = *arg;
TAILQ_INSERT_TAIL(&port->addr_list, a, port_link);
return (0);
}
/*
* Set/get port parameters.
*/
int
cc_port_get_param(struct ccdata *cc, u_int portno,
struct atm_port_info *param)
{
struct ccport *port;
if ((port = find_port(cc, portno)) == NULL)
return (ENOENT);
*param = port->param;
return (0);
}
/* XXX maybe allow only in stopped. */
int
cc_port_set_param(struct ccdata *cc, const struct atm_port_info *param)
{
struct ccport *port;
struct ccaddr *addr;
if ((port = find_port(cc, param->port)) == NULL)
return (ENOENT);
port->param = *param;
port->param.num_addrs = 0;
TAILQ_FOREACH(addr, &port->addr_list, port_link)
port->param.num_addrs++;
return (0);
}
/*
* get port list
*/
int
cc_port_getlist(struct ccdata *cc, u_int *cnt, u_int **ports)
{
struct ccport *p;
u_int n;
n = 0;
TAILQ_FOREACH(p, &cc->port_list, node_link)
n++;
*ports = CCMALLOC(n * sizeof(u_int));
if (*ports == NULL)
return (ENOMEM);
n = 0;
TAILQ_FOREACH(p, &cc->port_list, node_link)
(*ports)[n++] = p->param.port;
*cnt = n;
return (0);
}
/*
* START and STOP signalling
*/
int
cc_port_start(struct ccdata *cc, u_int portno)
{
struct ccport *port;
if ((port = find_port(cc, portno)) == NULL)
return (ENOENT);
if (port->admin != CCPORT_STOPPED)
return (EISCONN);
cc->funcs->send_uni_glob(port, port->uarg,
UNIAPI_LINK_ESTABLISH_request, 0, NULL);
port->admin = CCPORT_RUNNING;
return (0);
}
int
cc_port_stop(struct ccdata *cc, u_int portno)
{
struct ccport *port;
if ((port = find_port(cc, portno)) == NULL)
return (ENOENT);
if (port->admin != CCPORT_RUNNING)
return (ENOTCONN);
port->admin = CCPORT_STOPPED;
/*
* Abort all connections.
*/
while (!LIST_EMPTY(&port->conn_list))
cc_conn_destroy(LIST_FIRST(&port->conn_list));
return (0);
}
/*
* is port running?
*/
int
cc_port_isrunning(struct ccdata *cc, u_int portno, int *state)
{
struct ccport *port;
if ((port = find_port(cc, portno)) == NULL)
return (ENOENT);
if (port->admin == CCPORT_RUNNING)
*state = 1;
else
*state = 0;
return (0);
}
/*
* Clear address and prefix information from the named port.
*/
int
cc_port_clear(struct ccdata *cc, u_int portno)
{
struct ccaddr *addr;
struct ccport *port;
if ((port = find_port(cc, portno)) == NULL)
return (ENOENT);
while ((addr = TAILQ_FIRST(&port->addr_list)) != NULL) {
TAILQ_REMOVE(&port->addr_list, addr, port_link);
CCFREE(addr);
}
return (0);
}
/*
* retrieve info on local ports
*/
struct atm_port_list *
cc_get_local_port_info(struct ccdata *cc, u_int portno, size_t *lenp)
{
struct atm_port_list *list;
struct atm_port_info *pp;
struct uni_addr *aa;
struct ccaddr *addr;
struct ccport *port;
u_int nports, naddrs;
/*
* Count ports and addresses.
*/
nports = 0;
naddrs = 0;
TAILQ_FOREACH(port, &cc->port_list, node_link) {
if (portno == 0 || port->param.port == portno) {
nports++;
TAILQ_FOREACH(addr, &port->addr_list, port_link)
naddrs++;
}
}
/*
* Size and allocate message
*/
*lenp = sizeof(*list) + nports * sizeof(*pp) + naddrs * sizeof(*aa);
list = CCZALLOC(*lenp);
if (list == NULL)
return (NULL);
/*
* Fill the message.
*/
list->num_ports = nports;
list->num_addrs = naddrs;
pp = (void *)((u_char *)list + sizeof(*list));
aa = (void *)((u_char *)list + sizeof(*list) + nports * sizeof(*pp));
TAILQ_FOREACH(port, &cc->port_list, node_link) {
if (portno == 0 || port->param.port == portno) {
*pp = port->param;
pp->num_addrs = 0;
TAILQ_FOREACH(addr, &port->addr_list, port_link) {
*aa++ = addr->addr;
pp->num_addrs++;
}
pp++;
}
}
return (list);
}
static struct ccreq *
find_cookie(struct ccport *port, u_int cookie)
{
struct ccreq *r;
TAILQ_FOREACH(r, &port->cookies, link)
if (r->cookie == cookie)
return (r);
return (NULL);
}
/*
* input a response from the UNI layer to CC
*/
int
cc_uni_response(struct ccport *port, u_int cookie, u_int reason, u_int state)
{
struct ccconn *conn;
struct ccreq *req;
if (cookie == 0)
return (EINVAL);
if (port->admin != CCPORT_RUNNING)
return (ENOTCONN);
if ((req = find_cookie(port, cookie)) == NULL) {
cc_port_log(port, "UNI response for unknown cookie %u", cookie);
return (EINVAL);
}
conn = req->conn;
TAILQ_REMOVE(&port->cookies, req, link);
CCFREE(req);
if (reason == UNIAPI_OK)
return (cc_conn_resp(conn, CONN_SIG_OK,
cookie, reason, state));
else
return (cc_conn_resp(conn, CONN_SIG_ERROR,
cookie, reason, state));
}
static struct ccconn *
find_cref(const struct ccport *port, const struct uni_cref *cref)
{
struct ccconn *conn;
LIST_FOREACH(conn, &port->conn_list, port_link)
if (conn->cref.cref == cref->cref &&
conn->cref.flag == cref->flag)
return (conn);
return (NULL);
}
/*
* Signal from UNI on this port
*/
int
cc_uni_signal(struct ccport *port, u_int cookie, u_int sig, struct uni_msg *msg)
{
int error = 0;
size_t len, ilen = 0;
struct uni_cref *cref;
struct ccconn *conn;
if (port->admin != CCPORT_RUNNING) {
error = ENOTCONN;
goto out;
}
len = (msg != NULL) ? uni_msg_len(msg) : 0;
switch ((enum uni_sig)sig) {
case UNIAPI_ERROR:
/* handled above */
cc_port_log(port, "bad UNIAPI_ERROR cookie=%u", cookie);
error = EINVAL;
break;
case UNIAPI_CALL_CREATED:
ilen = sizeof(struct uniapi_call_created);
if (len != ilen)
goto bad_len;
if (cookie != 0) {
/* outgoing call */
struct ccreq *req;
if ((req = find_cookie(port, cookie)) == NULL) {
cc_port_log(port, "bad cookie %u in CREATE",
cookie);
error = EINVAL;
goto out;
}
conn = req->conn;
} else {
if ((conn = cc_conn_create(port->cc)) == NULL) {
error = ENOMEM;
goto out;
}
cc_conn_ins_port(conn, port);
}
cc_conn_sig_msg_nodef(conn, CONN_SIG_CREATED, msg);
msg = NULL;
goto out;
case UNIAPI_CALL_DESTROYED:
ilen = sizeof(struct uniapi_call_destroyed);
if (len != ilen)
goto bad_len;
cref = &uni_msg_rptr(msg, struct uniapi_call_destroyed *)->cref;
if ((conn = find_cref(port, cref)) == NULL)
goto unk_call;
error = cc_conn_sig(conn, CONN_SIG_DESTROYED, NULL);
goto out;
case UNIAPI_LINK_ESTABLISH_confirm:
goto out;
case UNIAPI_LINK_RELEASE_confirm:
/* Ups. If we administratively up, restart the link */
if (port->admin == CCPORT_RUNNING)
port->cc->funcs->send_uni_glob(port, port->uarg,
UNIAPI_LINK_ESTABLISH_request, 0, NULL);
goto out;
case UNIAPI_PARTY_CREATED:
ilen = sizeof(struct uniapi_party_created);
if (len != ilen)
goto bad_len;
cref = &uni_msg_rptr(msg, struct uniapi_party_created *)->cref;
if ((conn = find_cref(port, cref)) == NULL)
goto unk_call;
error = cc_conn_sig_msg_nodef(conn,
CONN_SIG_PARTY_CREATED, msg);
msg = NULL;
goto out;
case UNIAPI_PARTY_DESTROYED:
ilen = sizeof(struct uniapi_party_destroyed);
if (len != ilen)
goto bad_len;
cref = &uni_msg_rptr(msg,
struct uniapi_party_destroyed *)->cref;
if ((conn = find_cref(port, cref)) == NULL)
goto unk_call;
error = cc_conn_sig_msg(conn, CONN_SIG_PARTY_DESTROYED, msg);
msg = NULL;
goto out;
case UNIAPI_DROP_PARTY_ACK_indication: /* UNI -> API */
ilen = sizeof(struct uniapi_drop_party_ack_indication);
if (len != ilen)
goto bad_len;
cref = &uni_msg_rptr(msg,
struct uniapi_drop_party_ack_indication *)->drop.hdr.cref;
if ((conn = find_cref(port, cref)) == NULL)
goto unk_call;
error = cc_conn_sig_msg(conn, CONN_SIG_DROP_PARTY_ACK_IND, msg);
msg = NULL;
goto out;
case UNIAPI_RESET_indication: /* UNI -> API */
{
/*
* XXX - do the right thing
*/
struct uniapi_reset_indication *ind = uni_msg_rptr(msg,
struct uniapi_reset_indication *);
struct uniapi_reset_response *resp;
struct uni_msg *u;
/*
* Construct message to UNI.
*/
if ((u = uni_msg_alloc(sizeof(*resp))) == NULL)
return (ENOMEM);
resp = uni_msg_wptr(u, struct uniapi_reset_response *);
memset(resp, 0, sizeof(*resp));
u->b_wptr += sizeof(*resp);
resp->restart = ind->restart;
resp->connid = ind->connid;
port->cc->funcs->send_uni_glob(port, port->uarg,
UNIAPI_RESET_response, 0, u);
goto out;
}
case UNIAPI_RELEASE_indication: /* UNI -> API */
ilen = sizeof(struct uniapi_release_indication);
if (len != ilen)
goto bad_len;
cref = &uni_msg_rptr(msg, struct uniapi_release_indication *)
->release.hdr.cref;
if ((conn = find_cref(port, cref)) == NULL)
goto unk_call;
error = cc_conn_sig_msg(conn, CONN_SIG_REL_IND, msg);
msg = NULL;
goto out;
case UNIAPI_RELEASE_confirm: /* UNI -> API */
ilen = sizeof(struct uniapi_release_confirm);
if (len != ilen)
goto bad_len;
cref = &uni_msg_rptr(msg, struct uniapi_release_confirm *)
->release.hdr.cref;
if ((conn = find_cref(port, cref)) == NULL)
goto unk_call;
error = cc_conn_sig_msg(conn, CONN_SIG_REL_CONF, msg);
msg = NULL;
goto out;
case UNIAPI_SETUP_confirm: /* UNI -> API */
ilen = sizeof(struct uniapi_setup_confirm);
if (len != ilen)
goto bad_len;
cref = &uni_msg_rptr(msg, struct uniapi_setup_confirm *)
->connect.hdr.cref;
if ((conn = find_cref(port, cref)) == NULL)
goto unk_call;
error = cc_conn_sig_msg(conn, CONN_SIG_SETUP_CONFIRM, msg);
msg = NULL;
goto out;
case UNIAPI_ALERTING_indication: /* UNI -> API */
ilen = sizeof(struct uniapi_alerting_indication);
if (len != ilen)
goto bad_len;
cref = &uni_msg_rptr(msg, struct uniapi_alerting_indication *)
->alerting.hdr.cref;
if ((conn = find_cref(port, cref)) == NULL)
goto unk_call;
error = cc_conn_sig_msg(conn, CONN_SIG_ALERTING_IND, msg);
msg = NULL;
goto out;
case UNIAPI_PROCEEDING_indication: /* UNI -> API */
ilen = sizeof(struct uniapi_proceeding_indication);
if (len != ilen)
goto bad_len;
cref = &uni_msg_rptr(msg, struct uniapi_proceeding_indication *)
->call_proc.hdr.cref;
if ((conn = find_cref(port, cref)) == NULL)
goto unk_call;
error = cc_conn_sig_msg(conn, CONN_SIG_PROC_IND, msg);
msg = NULL;
goto out;
case UNIAPI_SETUP_indication: /* UNI -> API */
ilen = sizeof(struct uniapi_setup_indication);
if (len != ilen)
goto bad_len;
cref = &uni_msg_rptr(msg, struct uniapi_setup_indication *)
->setup.hdr.cref;
if ((conn = find_cref(port, cref)) == NULL)
goto unk_call;
error = cc_conn_sig_msg(conn, CONN_SIG_SETUP_IND, msg);
msg = NULL;
goto out;
case UNIAPI_SETUP_COMPLETE_indication: /* UNI -> API */
ilen = sizeof(struct uniapi_setup_complete_indication);
if (len != ilen)
goto bad_len;
cref = &uni_msg_rptr(msg,
struct uniapi_setup_complete_indication *)
->connect_ack.hdr.cref;
if ((conn = find_cref(port, cref)) == NULL)
goto unk_call;
error = cc_conn_sig_msg(conn, CONN_SIG_SETUP_COMPL, msg);
msg = NULL;
goto out;
case UNIAPI_PARTY_ALERTING_indication: /* UNI -> API */
ilen = sizeof(struct uniapi_party_alerting_indication);
if (len != ilen)
goto bad_len;
cref = &uni_msg_rptr(msg,
struct uniapi_party_alerting_indication *)->alert.hdr.cref;
if ((conn = find_cref(port, cref)) == NULL)
goto unk_call;
error = cc_conn_sig_msg(conn, CONN_SIG_PARTY_ALERTING_IND, msg);
msg = NULL;
goto out;
case UNIAPI_ADD_PARTY_ACK_indication: /* UNI -> API */
ilen = sizeof(struct uniapi_add_party_ack_indication);
if (len != ilen)
goto bad_len;
cref = &uni_msg_rptr(msg,
struct uniapi_add_party_ack_indication *)->ack.hdr.cref;
if ((conn = find_cref(port, cref)) == NULL)
goto unk_call;
error = cc_conn_sig_msg(conn, CONN_SIG_PARTY_ADD_ACK_IND, msg);
msg = NULL;
goto out;
case UNIAPI_ADD_PARTY_REJ_indication: /* UNI -> API */
ilen = sizeof(struct uniapi_add_party_rej_indication);
if (len != ilen)
goto bad_len;
cref = &uni_msg_rptr(msg,
struct uniapi_add_party_rej_indication *)->rej.hdr.cref;
if ((conn = find_cref(port, cref)) == NULL)
goto unk_call;
error = cc_conn_sig_msg(conn, CONN_SIG_PARTY_ADD_REJ_IND, msg);
msg = NULL;
goto out;
case UNIAPI_DROP_PARTY_indication: /* UNI -> API */
ilen = sizeof(struct uniapi_drop_party_indication);
if (len != ilen)
goto bad_len;
cref = &uni_msg_rptr(msg, struct uniapi_drop_party_indication *)
->drop.hdr.cref;
if ((conn = find_cref(port, cref)) == NULL)
goto unk_call;
error = cc_conn_sig_msg(conn, CONN_SIG_DROP_PARTY_IND, msg);
msg = NULL;
goto out;
case UNIAPI_RESET_confirm: /* UNI -> API */
case UNIAPI_RESET_ERROR_indication: /* UNI -> API */
case UNIAPI_RESET_STATUS_indication: /* UNI -> API */
/* XXX */
goto out;
case UNIAPI_NOTIFY_indication: /* UNI -> API */
case UNIAPI_STATUS_indication: /* UNI -> API */
break;
case UNIAPI_ADD_PARTY_indication: /* UNI -> API */
/* not supported by the API */
break;
/*
* All these are illegal in this direction
*/
case UNIAPI_LINK_ESTABLISH_request: /* API -> UNI */
case UNIAPI_LINK_RELEASE_request: /* API -> UNI */
case UNIAPI_RESET_request: /* API -> UNI */
case UNIAPI_RESET_response: /* API -> UNI */
case UNIAPI_RESET_ERROR_response: /* API -> UNI */
case UNIAPI_SETUP_request: /* API -> UNI */
case UNIAPI_SETUP_response: /* API -> UNI */
case UNIAPI_ALERTING_request: /* API -> UNI */
case UNIAPI_PROCEEDING_request: /* API -> UNI */
case UNIAPI_RELEASE_request: /* API -> UNI */
case UNIAPI_RELEASE_response: /* API -> UNI */
case UNIAPI_NOTIFY_request: /* API -> UNI */
case UNIAPI_STATUS_ENQUIRY_request: /* API -> UNI */
case UNIAPI_ADD_PARTY_request: /* API -> UNI */
case UNIAPI_PARTY_ALERTING_request: /* API -> UNI */
case UNIAPI_ADD_PARTY_ACK_request: /* API -> UNI */
case UNIAPI_ADD_PARTY_REJ_request: /* API -> UNI */
case UNIAPI_DROP_PARTY_request: /* API -> UNI */
case UNIAPI_DROP_PARTY_ACK_request: /* API -> UNI */
case UNIAPI_ABORT_CALL_request: /* API -> UNI */
case UNIAPI_SETUP_COMPLETE_request: /* API -> UNI */
case UNIAPI_MAXSIG:
break;
}
cc_port_log(port, "bad signal %u", sig);
error = EINVAL;
goto out;
bad_len:
cc_port_log(port, "signal %u bad length: %zu, need %zu", len, ilen);
error = EINVAL;
goto out;
unk_call:
cc_port_log(port, "unknown call %u/%u", cref->cref, cref->flag);
error = EINVAL;
out:
if (msg != NULL)
uni_msg_destroy(msg);
return (error);
}

View File

@ -0,0 +1,350 @@
/*
* Copyright (c) 2004
* Hartmut Brandt
* All rights reserved.
*
* Author: Harti Brandt <harti@freebsd.org>
*
* Redistribution of this software and documentation and use in source and
* binary forms, with or without modification, are permitted provided that
* the following conditions are met:
*
* 1. Redistributions of source code or documentation must retain the above
* copyright notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE AND DOCUMENTATION IS PROVIDED BY THE AUTHOR
* AND ITS CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
* THE AUTHOR OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* $Begemot: libunimsg/netnatm/api/cc_sig.c,v 1.1 2004/07/08 08:21:54 brandt Exp $
*
* ATM API as defined per af-saa-0108
*
* Generic signal handling
*/
#include <netnatm/unimsg.h>
#include <netnatm/msg/unistruct.h>
#include <netnatm/msg/unimsglib.h>
#include <netnatm/api/unisap.h>
#include <netnatm/sig/unidef.h>
#include <netnatm/api/atmapi.h>
#include <netnatm/api/ccatm.h>
#include <netnatm/api/ccpriv.h>
enum {
SIG_USER,
SIG_CONN,
};
struct ccsig {
u_char type; /* type of target */
u_char has_msg; /* arg1 is a message */
void *target; /* target instance */
u_int sig; /* signal */
void *arg1; /* argument */
u_int arg2; /* argument */
TAILQ_ENTRY(ccsig) link;
};
#if defined(__GNUC__) && __GNUC__ < 3
#define cc_sig_log(CC, FMT, ARGS...) do { \
if ((CC)->log & CCLOG_SIGS) \
(CC)->funcs->log("%s: " FMT, __FUNCTION__ , ## ARGS); \
} while (0)
#else
#define cc_sig_log(CC, FMT, ...) do { \
if ((CC)->log & CCLOG_SIGS) \
(CC)->funcs->log("%s: " FMT, __func__, __VA_ARGS__); \
} while (0)
#endif
const char *const cc_user_sigtab[] = {
#define DEF(N) [USER_SIG_##N] = #N,
USER_SIGS
#undef DEF
};
const char *const cc_conn_sigtab[] = {
#define DEF(N) [CONN_SIG_##N] = #N,
CONN_SIGS
#undef DEF
};
/*
* Allocate and populate a signal
*/
static /* __inline */ struct ccsig *
sig_alloc(struct ccdata *cc, u_int type, void *target, u_int has_msg,
u_int sig, void *arg1, u_int arg2)
{
struct ccsig *s;
if ((s = TAILQ_FIRST(&cc->free_sigs)) == NULL) {
s = CCZALLOC(sizeof(struct ccsig));
if (s == NULL) {
cc_log(cc, "signal %u/%u lost - ENOMEM", type, sig);
return (NULL);
}
} else
TAILQ_REMOVE(&cc->free_sigs, s, link);
s->type = type;
s->has_msg = has_msg;
s->target = target;
s->sig = sig;
s->arg1 = arg1;
s->arg2 = arg2;
return (s);
}
/*
* Queue a signal to this user
*/
int
cc_user_sig(struct ccuser *user, enum user_sig sig, void *arg1, u_int arg2)
{
struct ccsig *s;
s = sig_alloc(user->cc, SIG_USER, user, 0, sig, arg1, arg2);
if (s == NULL)
return (ENOMEM);
TAILQ_INSERT_TAIL(&user->cc->sigs, s, link);
cc_sig_log(user->cc, "queuing sig %s to user %p", cc_user_sigtab[sig],
user);
return (0);
}
/* Queue a signal with message to this user */
int
cc_user_sig_msg(struct ccuser *user, enum user_sig sig, struct uni_msg *msg)
{
struct ccsig *s;
s = sig_alloc(user->cc, SIG_USER, user, msg != NULL, sig, msg, 0);
if (s == NULL)
return (ENOMEM);
TAILQ_INSERT_TAIL(&user->cc->sigs, s, link);
cc_sig_log(user->cc, "queuing sig %s to user %p", cc_user_sigtab[sig],
user);
return (0);
}
/*
* Signal to connection
*/
static int
sig_conn(struct ccconn *conn, enum conn_sig sig, u_int has_msg, void *arg)
{
struct ccsig *s;
const struct ccreq *r = NULL;
s = sig_alloc(conn->cc, SIG_CONN, conn, has_msg, sig, arg, 0);
if (s == NULL)
return (ENOMEM);
if (conn->port != NULL) {
/* argh */
TAILQ_FOREACH(r, &conn->port->cookies, link)
if (r->conn == conn)
break;
}
if (r == NULL) {
TAILQ_INSERT_TAIL(&conn->cc->sigs, s, link);
cc_sig_log(conn->cc, "queuing sig %s to conn %p",
cc_conn_sigtab[sig], conn);
} else {
TAILQ_INSERT_TAIL(&conn->cc->def_sigs, s, link);
cc_sig_log(conn->cc, "queuing defered sig %s to conn %p",
cc_conn_sigtab[sig], conn);
}
return (0);
}
/*
* Queue a signal to a connection.
*/
int
cc_conn_sig(struct ccconn *conn, enum conn_sig sig, void *arg1)
{
return (sig_conn(conn, sig, 0, arg1));
}
/*
* signal with message to connection
*/
int
cc_conn_sig_msg(struct ccconn *conn, enum conn_sig sig, struct uni_msg *msg)
{
return (sig_conn(conn, sig, (msg != NULL), msg));
}
int
cc_conn_sig_msg_nodef(struct ccconn *conn, enum conn_sig sig,
struct uni_msg *msg)
{
struct ccsig *s;
s = sig_alloc(conn->cc, SIG_CONN, conn, (msg != NULL), sig, msg, 0);
if (s == NULL)
return (ENOMEM);
TAILQ_INSERT_TAIL(&conn->cc->sigs, s, link);
cc_sig_log(conn->cc, "queuing sig %s to conn %p",
cc_conn_sigtab[sig], conn);
return (0);
}
/*
* Queue a response signal to a connection.
*/
int
cc_conn_resp(struct ccconn *conn, enum conn_sig sig, u_int cookie __unused,
u_int reason, u_int state)
{
struct ccsig *s, *s1, *s2;
s = sig_alloc(conn->cc, SIG_CONN, conn, 0, sig, NULL,
((reason & 0xffff) << 16) | (state & 0xffff));
if (s == NULL)
return (ENOMEM);
TAILQ_INSERT_TAIL(&conn->cc->sigs, s, link);
cc_sig_log(conn->cc, "queuing response %s to conn %p",
cc_conn_sigtab[sig], conn);
s1 = TAILQ_FIRST(&conn->cc->def_sigs);
while (s1 != NULL) {
s2 = TAILQ_NEXT(s1, link);
if (s1->type == SIG_CONN && s1->target == conn) {
TAILQ_REMOVE(&conn->cc->def_sigs, s1, link);
TAILQ_INSERT_AFTER(&conn->cc->sigs, s, s1, link);
cc_sig_log(conn->cc, "undefering sig %s to conn %p",
cc_conn_sigtab[s1->sig], conn);
s = s1;
}
s1 = s2;
}
return (0);
}
/*
* Flush all signals to a given target from both queues
*/
static /* __inline */ void
sig_flush(struct ccdata *cc, u_int type, void *target)
{
struct ccsig *s, *s1;
s = TAILQ_FIRST(&cc->sigs);
while (s != NULL) {
s1 = TAILQ_NEXT(s, link);
if (s->type == type && s->target == target) {
if (s->has_msg)
uni_msg_destroy((struct uni_msg *)s->arg1);
TAILQ_REMOVE(&cc->sigs, s, link);
TAILQ_INSERT_HEAD(&cc->free_sigs, s, link);
}
s = s1;
}
s = TAILQ_FIRST(&cc->def_sigs);
while (s != NULL) {
s1 = TAILQ_NEXT(s, link);
if (s->type == type && s->target == target) {
if (s->has_msg)
uni_msg_destroy((struct uni_msg *)s->arg1);
TAILQ_REMOVE(&cc->def_sigs, s, link);
TAILQ_INSERT_HEAD(&cc->free_sigs, s, link);
}
s = s1;
}
}
/*
* Flush all signals to this user
*/
void
cc_user_sig_flush(struct ccuser *user)
{
cc_sig_log(user->cc, "flushing signals to user %p", user);
sig_flush(user->cc, SIG_USER, user);
}
/*
* Flush all signals to this connection
*/
void
cc_conn_sig_flush(struct ccconn *conn)
{
cc_sig_log(conn->cc, "flushing signals to conn %p", conn);
sig_flush(conn->cc, SIG_CONN, conn);
}
/*
* Do the work
*/
void
cc_work(struct ccdata *cc)
{
struct ccsig *s;
cc_sig_log(cc, "start %s", "work");
while ((s = TAILQ_FIRST(&cc->sigs)) != NULL) {
TAILQ_REMOVE(&cc->sigs, s, link);
if (s->type == SIG_USER)
cc_user_sig_handle(s->target, s->sig, s->arg1, s->arg2);
else {
cc_conn_sig_handle(s->target, s->sig, s->arg1, s->arg2);
if (s->has_msg)
uni_msg_destroy(s->arg1);
}
TAILQ_INSERT_HEAD(&cc->free_sigs, s, link);
}
cc_sig_log(cc, "end %s", "work");
}
/*
* flush all signals
*/
void
cc_sig_flush_all(struct ccdata *cc)
{
struct ccsig *s;
while ((s = TAILQ_FIRST(&cc->sigs)) != NULL) {
if (s->has_msg)
uni_msg_destroy((struct uni_msg *)s->arg1);
TAILQ_REMOVE(&cc->sigs, s, link);
CCFREE(s);
}
while ((s = TAILQ_FIRST(&cc->def_sigs)) != NULL) {
if (s->has_msg)
uni_msg_destroy((struct uni_msg *)s->arg1);
TAILQ_REMOVE(&cc->def_sigs, s, link);
CCFREE(s);
}
while ((s = TAILQ_FIRST(&cc->free_sigs)) != NULL) {
TAILQ_REMOVE(&cc->free_sigs, s, link);
CCFREE(s);
}
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,154 @@
/*
* Copyright (c) 2003-2004
* Hartmut Brandt
* All rights reserved.
*
* Author: Harti Brandt <harti@freebsd.org>
*
* Redistribution of this software and documentation and use in source and
* binary forms, with or without modification, are permitted provided that
* the following conditions are met:
*
* 1. Redistributions of source code or documentation must retain the above
* copyright notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE AND DOCUMENTATION IS PROVIDED BY THE AUTHOR
* AND ITS CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
* THE AUTHOR OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* $Begemot: libunimsg/netnatm/api/ccatm.h,v 1.1 2004/07/08 08:21:58 brandt Exp $
*
* ATM API as defined per af-saa-0108
*
* Interface to the supporting code.
*/
#ifndef _API_CCATM_H_
#define _API_CCATM_H_
struct ccuser;
struct ccconn;
struct ccport;
struct ccdata;
struct cc_funcs {
/* send signal to API user */
void (*send_user)(struct ccuser *, void *, u_int, void *, size_t);
/* respond API user */
void (*respond_user)(struct ccuser *, void *, int, u_int,
void *, size_t);
/* send signal to uni for connection */
void (*send_uni)(struct ccconn *, void *, u_int, u_int,
struct uni_msg *);
/* send global signal to uni */
void (*send_uni_glob)(struct ccport *, void *, u_int, u_int,
struct uni_msg *);
/* log a message */
void (*log)(const char *, ...);
};
enum {
CCLOG_USER_STATE = 0x00000001,
CCLOG_USER_INST = 0x00000002,
CCLOG_USER_SIG = 0x00000004,
CCLOG_CONN_STATE = 0x00000010,
CCLOG_CONN_INST = 0x00000020,
CCLOG_CONN_SIG = 0x00000040,
CCLOG_PARTY_STATE = 0x00000100,
CCLOG_PARTY_INST = 0x00000200,
CCLOG_PARTY_SIG = 0x00000400,
CCLOG_SIGS = 0x00001000,
};
/* instance handling */
struct ccdata *cc_create(const struct cc_funcs *);
void cc_destroy(struct ccdata *);
void cc_reset(struct ccdata *);
/* input a response from the UNI layer to CC */
int cc_uni_response(struct ccport *, u_int cookie, u_int reason, u_int state);
/* Signal from UNI on this port */
int cc_uni_signal(struct ccport *, u_int cookie, u_int sig, struct uni_msg *);
/* retrieve addresses */
int cc_get_addrs(struct ccdata *, u_int, struct uni_addr **, u_int **, u_int *);
/* dump state */
typedef int (*cc_dump_f)(struct ccdata *, void *, const char *);
int cc_dump(struct ccdata *, size_t, cc_dump_f, void *);
/* start/stop port */
int cc_port_stop(struct ccdata *, u_int);
int cc_port_start(struct ccdata *, u_int);
/* is port running? */
int cc_port_isrunning(struct ccdata *, u_int, int *);
/* return port number */
u_int cc_port_no(struct ccport *);
/* Clear address and prefix information from the named port. */
int cc_port_clear(struct ccdata *, u_int);
/* Address registered. */
int cc_addr_register(struct ccdata *, u_int, const struct uni_addr *);
/* Address unregistered. */
int cc_addr_unregister(struct ccdata *, u_int, const struct uni_addr *);
/* get port info */
int cc_port_get_param(struct ccdata *, u_int, struct atm_port_info *);
/* set port info */
int cc_port_set_param(struct ccdata *, const struct atm_port_info *);
/* get port list */
int cc_port_getlist(struct ccdata *, u_int *, u_int **);
/* create a port */
struct ccport *cc_port_create(struct ccdata *, void *, u_int);
/* destroy a port */
void cc_port_destroy(struct ccport *, int);
/* New endpoint created */
struct ccuser *cc_user_create(struct ccdata *, void *, const char *);
/* destroy user endpoint */
void cc_user_destroy(struct ccuser *);
/* signal from user */
int cc_user_signal(struct ccuser *, u_int, struct uni_msg *);
/* Management is given up on this node. */
void cc_unmanage(struct ccdata *);
/* handle all queued signals */
void cc_work(struct ccdata *);
/* set/get logging flags */
void cc_set_log(struct ccdata *, u_int);
u_int cc_get_log(const struct ccdata *);
/* get extended status */
int cc_get_extended_status(const struct ccdata *, struct atm_exstatus *,
struct atm_exstatus_ep **, struct atm_exstatus_port **,
struct atm_exstatus_conn **, struct atm_exstatus_party **);
#endif

View File

@ -0,0 +1,562 @@
/*
* Copyright (c) 2003-2004
* Hartmut Brandt
* All rights reserved.
*
* Author: Harti Brandt <harti@freebsd.org>
*
* Redistribution of this software and documentation and use in source and
* binary forms, with or without modification, are permitted provided that
* the following conditions are met:
*
* 1. Redistributions of source code or documentation must retain the above
* copyright notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE AND DOCUMENTATION IS PROVIDED BY THE AUTHOR
* AND ITS CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
* THE AUTHOR OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* $FreeBSD$
*
* ATM API as defined per af-saa-0108
*
* Private declarations.
*/
#ifdef _KERNEL
#ifdef __FreeBSD__
#include <netgraph/atm/ccatm/ng_ccatm_cust.h>
#endif
#else /* !_KERNEL */
#include "cccust.h"
#endif
struct ccuser;
struct ccconn;
struct ccaddr;
struct ccport;
struct ccdata;
struct ccsig;
struct ccparty;
LIST_HEAD(ccuser_list, ccuser);
LIST_HEAD(ccconn_list, ccconn);
TAILQ_HEAD(ccaddr_list, ccaddr);
TAILQ_HEAD(ccport_list, ccport);
TAILQ_HEAD(ccsig_list, ccsig);
LIST_HEAD(ccparty_list, ccparty);
/*
* Private node data.
*/
struct ccdata {
struct ccuser_list user_list; /* instance list */
struct ccport_list port_list; /* list of ports */
struct ccconn_list orphaned_conns; /* list of connections */
struct ccsig_list sigs; /* current signals */
struct ccsig_list def_sigs; /* deferred signals */
struct ccsig_list free_sigs; /* free signals */
const struct cc_funcs *funcs;
uint32_t cookie; /* cookie generator */
u_int log; /* logging flags */
};
/* retrieve info on local ports */
struct atm_port_list *cc_get_local_port_info(struct ccdata *,
u_int, size_t *);
/* log */
#ifdef CCATM_DEBUG
#if defined(__GNUC__) && __GNUC__ < 3
#define cc_log(CC, FMT, ARGS...) do { \
(CC)->funcs->log("%s (data=%p): " FMT, __FUNCTION__, \
(CC) , ## ARGS); \
} while (0)
#else
#define cc_log(CC, FMT, ...) do { \
(CC)->funcs->log("%s (data=%p): " FMT, __func__, \
(CC), __VA_ARGS__); \
} while (0)
#endif
#else
#if defined(__GNUC__) && __GNUC__ < 3
#define cc_log(CC, FMT, ARGS...) do { } while (0)
#else
#define cc_log(CC, FMT, ...) do { } while (0)
#endif
#endif
/*
* structure to remember cookies for outstanding requests
* we also remember the request itself but don't use it.
*/
struct ccreq {
TAILQ_ENTRY(ccreq) link;
uint32_t cookie;
uint32_t req;
struct ccconn *conn;
};
TAILQ_HEAD(ccreq_list, ccreq);
/*
* Port data. Each port has one UNI stack below.
* The port number is in param.port. The number is assigned when the
* hook to the uni is connected. This hook has the name 'uni<port>'.
*/
struct ccport {
void *uarg; /* hook to UNI protocol */
struct ccdata *cc; /* back pointer to node */
enum {
CCPORT_STOPPED, /* halted */
CCPORT_RUNNING, /* ok */
} admin; /* admin status */
struct ccconn_list conn_list; /* list of connections */
struct ccaddr_list addr_list; /* list of network addresses */
struct atm_port_info param; /* parameters */
/* list of outstanding requests */
struct ccreq_list cookies;
TAILQ_ENTRY(ccport) node_link;
};
#ifdef CCATM_DEBUG
#if defined(__GNUC__) && __GNUC__ < 3
#define cc_port_log(P, FMT, ARGS...) do { \
(P)->cc->funcs->log("%s (port=%p/%u): " FMT, __FUNCTION__, \
(P), (P)->param.port , ## ARGS); \
} while (0)
#else
#define cc_port_log(P, FMT, ...) do { \
(P)->cc->funcs->log("%s (port=%p/%u): " FMT, __func__, \
(P), (P)->param.port, __VA_ARGS__); \
} while (0)
#endif
#else
#if defined(__GNUC__) && __GNUC__ < 3
#define cc_port_log(P, FMT, ARGS...) do { } while (0)
#else
#define cc_port_log(P, FMT, ...) do { } while (0)
#endif
#endif
#define CONN_STATES \
DEF(CONN_NULL) /* C0 */ \
DEF(CONN_OUT_PREPARING) /* C1 */ \
DEF(CONN_OUT_WAIT_CREATE) /* C2 */ \
DEF(CONN_OUT_WAIT_OK) /* C3 */ \
DEF(CONN_OUT_WAIT_CONF) /* C4 */ \
\
DEF(CONN_ACTIVE) /* C5 */ \
\
DEF(CONN_IN_PREPARING) /* C10 */ \
DEF(CONN_IN_WAITING) /* C21 */ \
DEF(CONN_IN_ARRIVED) /* C11 */ \
DEF(CONN_IN_WAIT_ACCEPT_OK) /* C12 */ \
DEF(CONN_IN_WAIT_COMPL) /* C13 */ \
\
DEF(CONN_REJ_WAIT_OK) /* C14 */ \
DEF(CONN_REL_IN_WAIT_OK) /* C15 */ \
DEF(CONN_REL_WAIT_OK) /* C20 */ \
\
DEF(CONN_AB_WAIT_REQ_OK) /* C33 */ \
DEF(CONN_AB_WAIT_RESP_OK) /* C34 */ \
DEF(CONN_AB_FLUSH_IND) /* C35 */ \
DEF(CONN_OUT_WAIT_DESTROY) /* C37 */
enum conn_state {
#define DEF(N) N,
CONN_STATES
#undef DEF
};
#define CONN_SIGS \
DEF(CONNECT_OUTGOING) /* U */ \
DEF(ARRIVAL) /* U */ \
DEF(RELEASE) /* U */ \
DEF(REJECT) /* U */ \
DEF(ACCEPT) /* U newuser */ \
DEF(ADD_PARTY) /* U ident */ \
DEF(DROP_PARTY) /* U ident */ \
DEF(USER_ABORT) /* U */ \
\
DEF(CREATED) /* P msg */ \
DEF(DESTROYED) /* P */ \
DEF(SETUP_CONFIRM) /* P msg */ \
DEF(SETUP_IND) /* P msg */ \
DEF(SETUP_COMPL) /* P msg */ \
DEF(PROC_IND) /* P msg */ \
DEF(ALERTING_IND) /* P msg */ \
DEF(REL_CONF) /* P msg */ \
DEF(REL_IND) /* P msg */ \
DEF(PARTY_CREATED) /* P msg */ \
DEF(PARTY_DESTROYED) /* P msg */ \
DEF(PARTY_ALERTING_IND) /* P msg */ \
DEF(PARTY_ADD_ACK_IND) /* P msg */ \
DEF(PARTY_ADD_REJ_IND) /* P msg */ \
DEF(DROP_PARTY_IND) /* P msg */ \
DEF(DROP_PARTY_ACK_IND) /* P msg */ \
\
DEF(OK) /* P msg */ \
DEF(ERROR) /* P msg */
enum conn_sig {
#define DEF(NAME) CONN_SIG_##NAME,
CONN_SIGS
#undef DEF
};
extern const char *const cc_conn_sigtab[];
/*
* This describes a connection and must be in sync with the UNI
* stack.
*/
struct ccconn {
enum conn_state state; /* API state of the connection */
struct ccdata *cc; /* owner node */
struct ccport *port; /* the port we belong to */
struct ccuser *user; /* user instance we belong to */
TAILQ_ENTRY(ccconn) connq_link; /* queue of the owner */
LIST_ENTRY(ccconn) port_link; /* link in list of port */
struct uni_cref cref;
uint8_t reason;
struct ccuser *acceptor;
/* attributes */
uint32_t blli_selector;
struct uni_ie_blli blli[UNI_NUM_IE_BLLI];
struct uni_ie_bearer bearer;
struct uni_ie_traffic traffic;
struct uni_ie_qos qos;
struct uni_ie_exqos exqos;
struct uni_ie_called called;
struct uni_ie_calledsub calledsub;
struct uni_ie_aal aal;
struct uni_ie_epref epref;
struct uni_ie_conned conned;
struct uni_ie_connedsub connedsub;
struct uni_ie_eetd eetd;
struct uni_ie_abrsetup abrsetup;
struct uni_ie_abradd abradd;
struct uni_ie_mdcr mdcr;
struct uni_ie_calling calling;
struct uni_ie_callingsub callingsub;
struct uni_ie_connid connid;
struct uni_ie_tns tns[UNI_NUM_IE_TNS];
struct uni_ie_atraffic atraffic;
struct uni_ie_mintraffic mintraffic;
struct uni_ie_cscope cscope;
struct uni_ie_bhli bhli;
/* bit mask of written attributes in A6 */
u_int dirty_attr;
struct uni_ie_cause cause[2];
struct ccparty_list parties;
};
/* dirty attribute mask values */
enum {
CCDIRTY_AAL = 0x0001,
CCDIRTY_BLLI = 0x0002,
CCDIRTY_CONNID = 0x0004,
CCDIRTY_NOTIFY = 0x0008, /* XXX */
CCDIRTY_EETD = 0x0010,
CCDIRTY_GIT = 0x0020, /* XXX */
CCDIRTY_UU = 0x0040, /* XXX */
CCDIRTY_TRAFFIC = 0x0080,
CCDIRTY_EXQOS = 0x0100,
CCDIRTY_ABRSETUP = 0x0200,
CCDIRTY_ABRADD = 0x0400,
};
/* set conn to new state */
void cc_conn_set_state(struct ccconn *, enum conn_state);
/* return string for state */
const char *cc_conn_state2str(u_int);
/* connect connection to user */
void cc_connect_to_user(struct ccconn *, struct ccuser *);
/* disconnect from the user */
void cc_disconnect_from_user(struct ccconn *);
/* abort the connection */
void cc_conn_abort(struct ccconn *, int);
/* destroy a connection */
void cc_conn_destroy(struct ccconn *);
/* create a connection */
struct ccconn *cc_conn_create(struct ccdata *);
/* assign to port */
void cc_conn_ins_port(struct ccconn *, struct ccport *);
/* remove from port */
void cc_conn_rem_port(struct ccconn *);
/* dispatch a connection to a user or reject it */
void cc_conn_dispatch(struct ccconn *);
/* disconnect from acceptor */
void cc_conn_reset_acceptor(struct ccconn *);
/* log on a connection */
#ifdef CCATM_DEBUG
#if defined(__GNUC__) && __GNUC__ < 3
#define cc_conn_log(C, FMT, ARGS...) do { \
(C)->cc->funcs->log("%s (conn=%p): " FMT, __FUNCTION__, \
(C) , ## ARGS); \
} while (0)
#else
#define cc_conn_log(C, FMT, ...) do { \
(C)->cc->funcs->log("%s (conn=%p): " FMT, __func__, \
(C), __VA_ARGS__); \
} while (0)
#endif
#else
#if defined(__GNUC__) && __GNUC__ < 3
#define cc_conn_log(C, FMT, ARGS...) do { } while (0)
#else
#define cc_conn_log(C, FMT, ...) do { } while (0)
#endif
#endif
/* handle signal to connection */
void cc_conn_sig_handle(struct ccconn *, enum conn_sig, void *arg, u_int iarg);
/*
* Mp connection parties
*/
#define PARTY_STATES \
DEF(NULL) /* 0 created */ \
DEF(ACTIVE) /* 1 active */ \
DEF(ADD_WAIT_CREATE) /* 2 wait for PARTY_CREATE */ \
DEF(ADD_WAIT_OK) /* 3 wait for OK for ADD.request */ \
DEF(ADD_WAIT_ACK) /* 4 wait for ADD.ack/rej */ \
DEF(DROP_WAIT_OK) /* 5 wait for OK for DROP.request */ \
DEF(DROP_WAIT_ACK) /* 6 wait for DROP.ack */ \
DEF(WAIT_DESTROY) /* 7 wait for destroy */ \
DEF(WAIT_SETUP_COMPL) /* 8 wait for setup.complete */ \
DEF(WAIT_DROP_ACK_OK) /* 9 wait for OK for DROP_ACK.request */\
DEF(WAIT_SETUP_CONF) /* 10 wait for setup.confirm */ \
DEF(ADD_DROP_WAIT_OK) /* 11 wait for ok to DROP.request */ \
DEF(ADD_DROPACK_WAIT_OK)/* 12 wait for ok to DROP_ACK.req */
enum party_state {
#define DEF(N) PARTY_##N,
PARTY_STATES
#undef DEF
};
struct ccparty {
struct ccconn *conn; /* owner */
LIST_ENTRY(ccparty) link;
enum party_state state;
struct uni_ie_called called;
struct uni_ie_epref epref;
};
/* set party to new state */
void cc_party_set_state(struct ccparty *, enum party_state);
/* return string for state */
const char *cc_party_state2str(u_int);
/* create new party */
struct ccparty *cc_party_create(struct ccconn *, u_int ident, u_int flag);
/* log on a party */
#ifdef CCATM_DEBUG
#if defined(__GNUC__) && __GNUC__ < 3
#define cc_party_log(P, FMT, ARGS...) do { \
(P)->conn->cc->funcs->log("%s (conn=%p, party=%p): " FMT, \
__FUNCTION__, (P)->conn, (P) , ## ARGS); \
} while (0)
#else
#define cc_party_log(P, FMT, ...) do { \
(P)->conn->cc->funcs->log("%s (conn=%p, party=%p): " FMT, \
__func__, (P)->conn, (P), __VA_ARGS__); \
} while (0)
#endif
#else
#if defined(__GNUC__) && __GNUC__ < 3
#define cc_party_log(P, FMT, ARGS...) do { } while (0)
#else
#define cc_party_log(P, FMT, ...) do { } while (0)
#endif
#endif
/*
* This is kind of a user socket, i.e. the entity managed towards the
* upper layer.
*/
#define USER_STATES \
DEF(USER_NULL) /* U0 none */ \
DEF(USER_OUT_PREPARING) /* U1 process set/query requests */ \
DEF(USER_OUT_WAIT_OK) /* U2 wait for OK to setup */ \
DEF(USER_OUT_WAIT_CONF) /* U3 wait for SETUP.confirm */ \
DEF(USER_ACTIVE) /* U4 A8-9-10/U10 */ \
DEF(USER_REL_WAIT) /* U5 wait for release to compl */ \
DEF(USER_IN_PREPARING) /* U6 set SAP */ \
DEF(USER_IN_WAITING) /* U7 wait and dispatch */ \
DEF(USER_IN_ARRIVED) /* U8 waiting for rej/acc */ \
DEF(USER_IN_WAIT_REJ) /* U9 wait for rejecting */ \
DEF(USER_IN_WAIT_ACC) /* U10 wait for accepting */ \
DEF(USER_IN_ACCEPTING) /* U11 wait for SETUP_complete */ \
DEF(USER_REL_WAIT_SCOMP)/* U12 wait for SETUP_complete */ \
DEF(USER_REL_WAIT_SCONF)/* U13 wait for SETUP.confirm */ \
DEF(USER_REL_WAIT_CONF) /* U14 wait for confirm */ \
DEF(USER_REL_WAIT_CONN) /* U15 wait for CONN_OK */
enum user_state {
#define DEF(N) N,
USER_STATES
#undef DEF
};
#define USER_SIGS \
DEF(PREPARE_OUTGOING) /* U */ \
DEF(CONNECT_OUTGOING) /* U msg */ \
DEF(PREPARE_INCOMING) /* U msg */ \
DEF(WAIT_ON_INCOMING) /* U msg */ \
DEF(REJECT_INCOMING) /* U msg */ \
DEF(ACCEPT_INCOMING) /* U msg */ \
DEF(CALL_RELEASE) /* U msg */ \
DEF(ADD_PARTY) /* U msg */ \
DEF(DROP_PARTY) /* U msg */ \
DEF(QUERY_ATTR) /* U msg */ \
DEF(QUERY_ATTR_X) /* U msg */ \
DEF(SET_ATTR) /* U msg */ \
DEF(SET_ATTR_X) /* U msg */ \
DEF(QUERY_STATE) /* U */ \
DEF(GET_LOCAL_PORT_INFO) /* U msg */ \
DEF(ABORT_CONNECTION) /* U msg */ \
\
DEF(CONNECT_OUTGOING_OK) /* */ \
DEF(CONNECT_OUTGOING_ERR) /* reason */ \
DEF(SETUP_CONFIRM) /* */ \
DEF(SETUP_IND) /* */ \
DEF(REJECT_OK) /* */ \
DEF(REJECT_ERR) /* reason */ \
DEF(ACCEPT_OK) /* */ \
DEF(ACCEPT_ERR) /* reason */ \
DEF(ACCEPTING) /* */ \
DEF(SETUP_COMPL) /* */ \
DEF(RELEASE_CONFIRM) /* */ \
DEF(RELEASE_ERR) /* reason */ \
DEF(ADD_PARTY_ERR) /* reason */ \
DEF(ADD_PARTY_OK) /* */ \
DEF(ADD_PARTY_ACK) /* leaf-ident */ \
DEF(ADD_PARTY_REJ) /* leaf-ident */ \
DEF(DROP_PARTY_ERR) /* reason */ \
DEF(DROP_PARTY_OK) /* */ \
DEF(DROP_PARTY_IND) /* leaf-ident */ \
enum user_sig {
#define DEF(NAME) USER_SIG_##NAME,
USER_SIGS
#undef DEF
};
extern const char *const cc_user_sigtab[];
struct ccuser {
LIST_ENTRY(ccuser) node_link; /* link in list of node */
enum user_state state; /* type of this instance */
struct ccdata *cc; /* the node */
void *uarg; /* the hook (if any) */
char name[ATM_EPNAMSIZ];
enum {
USER_P2P,
USER_ROOT,
USER_LEAF
} config; /* configuration */
struct uni_sap *sap; /* listening SAP */
u_int queue_max; /* maximum queue size */
u_int queue_act; /* actual queue size */
TAILQ_HEAD(,ccconn) connq; /* pending connections */
struct ccconn *accepted;
struct uni_ie_cause cause[2]; /* cause from connection */
u_int aborted;
};
/* set user to new state */
void cc_user_set_state(struct ccuser *, enum user_state);
/* return string for state */
const char *cc_user_state2str(u_int);
/* log on a user */
#ifdef CCATM_DEBUG
#if defined(__GNUC__) && __GNUC__ < 3
#define cc_user_log(U, FMT, ARGS...) do { \
(U)->cc->funcs->log("%s (user=%p): " FMT, __FUNCTION__, \
(U) , ## ARGS); \
} while (0)
#else
#define cc_user_log(U, FMT, ...) do { \
(U)->cc->funcs->log("%s (user=%p): " FMT, __func__, \
(U), __VA_ARGS__); \
} while (0)
#endif
#else
#if defined(__GNUC__) && __GNUC__ < 3
#define cc_user_log(U, FMT, ARGS...) do { } while (0)
#else
#define cc_user_log(U, FMT, ...) do { } while (0)
#endif
#endif
/* Handle a signal to this user */
void cc_user_sig_handle(struct ccuser *, enum user_sig, void *, u_int);
/*
* Addresses
*/
struct ccaddr {
TAILQ_ENTRY(ccaddr) port_link;
struct uni_addr addr;
};
/* signal to connection */
int cc_conn_sig(struct ccconn *, enum conn_sig, void *arg);
/* signal with message to connection */
int cc_conn_sig_msg(struct ccconn *, enum conn_sig, struct uni_msg *);
int cc_conn_sig_msg_nodef(struct ccconn *, enum conn_sig, struct uni_msg *);
/* response signal to connection */
int cc_conn_resp(struct ccconn *, enum conn_sig, u_int, u_int, u_int);
/* flush all signals to a given connection */
void cc_conn_sig_flush(struct ccconn *);
/* Queue a signal to this user */
int cc_user_sig(struct ccuser *, enum user_sig, void *, u_int);
/* Queue a signal with message to this user */
int cc_user_sig_msg(struct ccuser *, enum user_sig, struct uni_msg *);
/* Flush all signals to a given user */
void cc_user_sig_flush(struct ccuser *);
/* flush all signals */
void cc_sig_flush_all(struct ccdata *);

View File

@ -0,0 +1,415 @@
/*
* Copyright (c) 2001-2003
* Fraunhofer Institute for Open Communication Systems (FhG Fokus).
* All rights reserved.
* Copyright (c) 2004
* Hartmut Brandt
*
* Author: Hartmut Brandt <harti@freebsd.org>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Begemot: libunimsg/netnatm/api/unisap.c,v 1.4 2004/07/08 08:22:01 brandt Exp $
*/
#include <sys/types.h>
#ifdef _KERNEL
#include <sys/ctype.h>
#include <sys/libkern.h>
#else
#include <ctype.h>
#include <string.h>
#endif
#include <netnatm/msg/unistruct.h>
#include <netnatm/api/unisap.h>
int
unisve_check_addr(const struct unisve_addr *sve)
{
if (sve->tag == UNISVE_ABSENT)
return (UNISVE_OK);
if (sve->tag == UNISVE_ANY)
return (UNISVE_OK);
if (sve->tag != UNISVE_PRESENT)
return (UNISVE_ERROR_BAD_TAG);
if (sve->type == UNI_ADDR_INTERNATIONAL) {
if (sve->plan != UNI_ADDR_E164)
return (UNISVE_ERROR_TYPE_PLAN_CONFLICT);
if (sve->len == 0 || sve->len > 15)
return (UNISVE_ERROR_ADDR_LEN);
} else if (sve->type == UNI_ADDR_UNKNOWN) {
if (sve->plan != UNI_ADDR_ATME)
return (UNISVE_ERROR_TYPE_PLAN_CONFLICT);
if (sve->len != 19)
return (UNISVE_ERROR_ADDR_LEN);
} else
return (UNISVE_ERROR_BAD_ADDR_TYPE);
return (UNISVE_OK);
}
int
unisve_check_selector(const struct unisve_selector *sve)
{
if (sve->tag != UNISVE_PRESENT &&
sve->tag != UNISVE_ABSENT &&
sve->tag != UNISVE_ANY)
return (UNISVE_ERROR_BAD_TAG);
return (UNISVE_OK);
}
/*
* We don't want to check the protocol values here.
*/
int
unisve_check_blli_id2(const struct unisve_blli_id2 *sve)
{
if (sve->tag != UNISVE_PRESENT &&
sve->tag != UNISVE_ABSENT &&
sve->tag != UNISVE_ANY)
return (UNISVE_ERROR_BAD_TAG);
return (UNISVE_OK);
}
/*
* We don't want to check the protocol values here.
*/
int
unisve_check_blli_id3(const struct unisve_blli_id3 *sve)
{
if (sve->tag != UNISVE_PRESENT &&
sve->tag != UNISVE_ABSENT &&
sve->tag != UNISVE_ANY)
return (UNISVE_ERROR_BAD_TAG);
return (UNISVE_OK);
}
int
unisve_check_bhli(const struct unisve_bhli *sve)
{
if (sve->tag == UNISVE_ABSENT)
return (UNISVE_OK);
if (sve->tag == UNISVE_ANY)
return (UNISVE_OK);
if (sve->tag != UNISVE_PRESENT)
return (UNISVE_ERROR_BAD_TAG);
if (sve->type != UNI_BHLI_ISO &&
sve->type != UNI_BHLI_USER &&
sve->type != UNI_BHLI_VENDOR)
return (UNISVE_ERROR_BAD_BHLI_TYPE);
if (sve->len > sizeof(sve->info))
return (UNISVE_ERROR_BAD_BHLI_LEN);
return (UNISVE_OK);
}
int
unisve_check_sap(const struct uni_sap *sap)
{
int err;
if ((err = unisve_check_addr(&sap->addr)) != 0 ||
(err = unisve_check_selector(&sap->selector)) != 0 ||
(err = unisve_check_blli_id2(&sap->blli_id2)) != 0 ||
(err = unisve_check_blli_id3(&sap->blli_id3)) != 0 ||
(err = unisve_check_bhli(&sap->bhli)) != 0)
return (err);
if (sap->addr.plan == UNI_ADDR_E164) {
if (sap->selector.tag == UNISVE_PRESENT)
return (UNISVE_ERROR_ADDR_SEL_CONFLICT);
} else if (sap->addr.plan == UNI_ADDR_ATME) {
if (sap->selector.tag == UNISVE_ABSENT)
return (UNISVE_ERROR_ADDR_SEL_CONFLICT);
}
return (0);
}
#define COMMON_OVERLAP(A1,A2) \
if ((A1->tag == UNISVE_ABSENT && A2->tag == UNISVE_ABSENT) || \
A1->tag == UNISVE_ANY || A2->tag == UNISVE_ANY) \
return (1); \
if ((A1->tag == UNISVE_ABSENT && A2->tag == UNISVE_PRESENT) || \
(A2->tag == UNISVE_ABSENT && A1->tag == UNISVE_PRESENT)) \
return (0);
int
unisve_overlap_addr(const struct unisve_addr *s1, const struct unisve_addr *s2)
{
COMMON_OVERLAP(s1, s2);
return (s1->type == s2->type && s1->plan == s2->plan &&
s1->len == s2->len && memcmp(s1->addr, s2->addr, s1->len) == 0);
}
int
unisve_overlap_selector(const struct unisve_selector *s1,
const struct unisve_selector *s2)
{
COMMON_OVERLAP(s1, s2);
return (s1->selector == s2->selector);
}
int
unisve_overlap_blli_id2(const struct unisve_blli_id2 *s1,
const struct unisve_blli_id2 *s2)
{
COMMON_OVERLAP(s1, s2);
return (s1->proto == s2->proto &&
(s1->proto != UNI_BLLI_L2_USER || s1->user == s2->user));
}
int
unisve_overlap_blli_id3(const struct unisve_blli_id3 *s1,
const struct unisve_blli_id3 *s2)
{
COMMON_OVERLAP(s1, s2);
if (s1->proto != s2->proto)
return (0);
if (s1->proto == UNI_BLLI_L3_USER)
return (s1->user == s2->user);
if (s1->proto == UNI_BLLI_L3_TR9577) {
if (s1->noipi && s2->noipi)
return (1);
if (!s1->noipi && !s2->noipi) {
if (s1->ipi == s2->ipi) {
if (s1->ipi != UNI_BLLI_L3_SNAP)
return (1);
if (s1->oui == s2->oui && s1->pid == s2->pid)
return (1);
}
}
return (0);
}
return (1);
}
int
unisve_overlap_bhli(const struct unisve_bhli *s1, const struct unisve_bhli *s2)
{
COMMON_OVERLAP(s1, s2);
return (s1->type == s2->type && s1->len == s2->len &&
memcmp(s1->info, s2->info, s1->len) == 0);
}
int
unisve_overlap_sap(const struct uni_sap *s1, const struct uni_sap *s2)
{
int any1, any2;
/*
* Two catch-all's SAP's are not allowed. A catch-all does never
* overlap with a non-catch all SAP.
*/
any1 = unisve_is_catchall(s1);
any2 = unisve_is_catchall(s2);
if (any1 && any2)
return (1);
if(any1 || any2)
return (0);
return (unisve_overlap_addr(&s1->addr, &s2->addr) &&
unisve_overlap_selector(&s1->selector, &s2->selector) &&
unisve_overlap_blli_id2(&s1->blli_id2, &s2->blli_id2) &&
unisve_overlap_blli_id3(&s1->blli_id3, &s2->blli_id3) &&
unisve_overlap_bhli(&s1->bhli, &s2->bhli));
}
int
unisve_is_catchall(const struct uni_sap *sap)
{
return (sap->addr.tag == UNISVE_ANY &&
sap->selector.tag == UNISVE_ANY &&
sap->blli_id2.tag == UNISVE_ANY &&
sap->blli_id3.tag == UNISVE_ANY &&
sap->bhli.tag == UNISVE_ANY);
}
int
unisve_match(const struct uni_sap *sap, const struct uni_ie_called *called,
const struct uni_ie_blli *blli, const struct uni_ie_bhli *bhli)
{
switch (sap->addr.tag) {
case UNISVE_ABSENT:
if (IE_ISGOOD(*called))
return (0);
break;
case UNISVE_ANY:
break;
case UNISVE_PRESENT:
if (!IE_ISGOOD(*called))
return (0);
if (called->addr.type != sap->addr.type ||
called->addr.plan != sap->addr.plan)
return (0);
if (called->addr.plan == UNI_ADDR_E164) {
if (called->addr.len != sap->addr.len ||
memcmp(called->addr.addr, sap->addr.addr,
called->addr.len) != 0)
return (0);
} else if (called->addr.plan == UNI_ADDR_ATME) {
if (called->addr.len != 20 ||
memcmp(called->addr.addr, sap->addr.addr, 19) != 0)
return (0);
}
break;
default:
return (0);
}
switch (sap->selector.tag) {
case UNISVE_ABSENT:
if (IE_ISGOOD(*called) && called->addr.plan == UNI_ADDR_ATME)
return (0);
break;
case UNISVE_ANY:
break;
case UNISVE_PRESENT:
if (!IE_ISGOOD(*called))
return (0);
if (called->addr.plan != UNI_ADDR_ATME)
return (0);
if (called->addr.addr[19] != sap->selector.selector)
return (0);
break;
default:
return (0);
}
switch (sap->blli_id2.tag) {
case UNISVE_ABSENT:
if (IE_ISGOOD(*blli) && (blli->h.present & UNI_BLLI_L2_P))
return (0);
break;
case UNISVE_ANY:
break;
case UNISVE_PRESENT:
if (!IE_ISGOOD(*blli) || (blli->h.present & UNI_BLLI_L2_P) == 0)
return (0);
if (blli->l2 != sap->blli_id2.proto)
return (0);
if (blli->l2 == UNI_BLLI_L2_USER) {
if ((blli->h.present & UNI_BLLI_L2_USER_P) == 0)
return (0);
if (blli->l2_user != sap->blli_id2.user)
return (0);
}
break;
default:
return (0);
}
switch (sap->blli_id3.tag) {
case UNISVE_ABSENT:
if (IE_ISGOOD(*blli) && (blli->h.present & UNI_BLLI_L3_P))
return (0);
break;
case UNISVE_ANY:
break;
case UNISVE_PRESENT:
if (!IE_ISGOOD(*blli) || (blli->h.present & UNI_BLLI_L3_P) == 0)
return (0);
if (blli->l3 != sap->blli_id3.proto)
return (0);
if (blli->l3 == UNI_BLLI_L3_USER) {
if ((blli->h.present & UNI_BLLI_L3_USER_P) == 0)
return (0);
if (blli->l3_user != sap->blli_id3.user)
return (0);
break;
}
if (blli->l3 == UNI_BLLI_L3_TR9577) {
if (sap->blli_id3.noipi) {
if (blli->h.present & UNI_BLLI_L3_IPI_P)
return (0);
} else {
if (!(blli->h.present & UNI_BLLI_L3_IPI_P))
return (0);
if (blli->l3_ipi != sap->blli_id3.ipi)
return (0);
if (blli->l3_ipi == UNI_BLLI_L3_SNAP) {
if (!(blli->h.present &
UNI_BLLI_L3_SNAP_P))
return (0);
if (blli->oui != sap->blli_id3.oui ||
blli->pid != sap->blli_id3.pid)
return (0);
}
}
}
break;
default:
return (0);
}
switch (sap->bhli.tag) {
case UNISVE_ABSENT:
if (IE_ISGOOD(*bhli))
return (0);
break;
case UNISVE_ANY:
break;
case UNISVE_PRESENT:
if (!IE_ISGOOD(*bhli))
return (0);
if (sap->bhli.type != bhli->type)
return (0);
if (sap->bhli.len != bhli->len)
return (0);
if (memcmp(sap->bhli.info, bhli->info, bhli->len) != 0)
return (0);
break;
default:
return (0);
}
/* Uff */
return (1);
}

View File

@ -0,0 +1,131 @@
/*
* Copyright (c) 2001-2003
* Fraunhofer Institute for Open Communication Systems (FhG Fokus).
* All rights reserved.
*
* Author: Hartmut Brandt <harti@freebsd.org>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Begemot: libunimsg/netnatm/api/unisap.h,v 1.5 2004/07/08 08:22:01 brandt Exp $
* $FreeBSD$
*/
#ifndef _NETNATM_API_UNISAP_H_
#define _NETNATM_API_UNISAP_H_
#include <netnatm/msg/uni_config.h>
enum unisve_tag {
UNISVE_ABSENT, /* Element is absent */
UNISVE_PRESENT, /* Element is present with specific value */
UNISVE_ANY /* Any values is acceptable */
};
struct unisve_addr {
enum unisve_tag tag;
enum uni_addr_type type; /* type of address */
enum uni_addr_plan plan; /* addressing plan */
uint32_t len; /* length of address */
u_char addr[UNI_ADDR_MAXLEN];
};
struct unisve_selector {
enum unisve_tag tag;
uint8_t selector;
};
struct unisve_blli_id2 {
enum unisve_tag tag;
u_int proto:5; /* the protocol */
u_int user:7; /* user specific protocol */
};
struct unisve_blli_id3 {
enum unisve_tag tag;
u_int proto:5; /* L3 protocol */
u_int user:7; /* user specific protocol */
u_int ipi:8; /* ISO/IEC TR 9557 IPI */
u_int oui:24; /* IEEE 802.1 OUI */
u_int pid:16; /* IEEE 802.1 PID */
uint32_t noipi; /* ISO/IEC TR 9557 per frame */
};
struct unisve_bhli {
enum unisve_tag tag;
enum uni_bhli type; /* type of info */
uint32_t len; /* length of info */
uint8_t info[8]; /* info itself */
};
struct uni_sap {
struct unisve_addr addr;
struct unisve_selector selector;
struct unisve_blli_id2 blli_id2;
struct unisve_blli_id3 blli_id3;
struct unisve_bhli bhli;
};
int unisve_check_addr(const struct unisve_addr *);
int unisve_check_selector(const struct unisve_selector *);
int unisve_check_blli_id2(const struct unisve_blli_id2 *);
int unisve_check_blli_id3(const struct unisve_blli_id3 *);
int unisve_check_bhli(const struct unisve_bhli *);
int unisve_check_sap(const struct uni_sap *);
int unisve_overlap_addr(const struct unisve_addr *, const struct unisve_addr *);
int unisve_overlap_selector(const struct unisve_selector *,
const struct unisve_selector *);
int unisve_overlap_blli_id2(const struct unisve_blli_id2 *,
const struct unisve_blli_id2 *);
int unisve_overlap_blli_id3(const struct unisve_blli_id3 *,
const struct unisve_blli_id3 *);
int unisve_overlap_bhli(const struct unisve_bhli *,
const struct unisve_bhli *);
int unisve_overlap_sap(const struct uni_sap *, const struct uni_sap *);
int unisve_is_catchall(const struct uni_sap *);
int unisve_match(const struct uni_sap *, const struct uni_ie_called *,
const struct uni_ie_blli *, const struct uni_ie_bhli *);
enum {
UNISVE_OK = 0,
UNISVE_ERROR_BAD_TAG,
UNISVE_ERROR_TYPE_PLAN_CONFLICT,
UNISVE_ERROR_ADDR_SEL_CONFLICT,
UNISVE_ERROR_ADDR_LEN,
UNISVE_ERROR_BAD_ADDR_TYPE,
UNISVE_ERROR_BAD_BHLI_TYPE,
UNISVE_ERROR_BAD_BHLI_LEN,
};
#define UNISVE_ERRSTR \
"no error", \
"bad SVE tag", \
"bad address type/plan combination", \
"bad address plan/selector tag combination", \
"bad address length in SVE", \
"unknown address type in SVE", \
"bad BHLI type in SVE", \
"BHLI info too long in SVE",
#endif

View File

@ -3,10 +3,10 @@
# Fraunhofer Institute for Open Communication Systems (FhG Fokus).
# All rights reserved.
#
# $Begemot: libunimsg/atm/genfiles,v 1.3 2003/09/19 11:51:57 hbb Exp $
#
# Author: Harti Brandt <harti@freebsd.org>
#
# $Begemot: libunimsg/netnatm/genfiles,v 1.4 2004/07/08 08:21:45 brandt Exp $
#
awk -f ${SRC}msg/parseie.awk -f ${SRC}msg/geniec.awk ${SRC}msg/ie.def >${DST}msg/uni_ietab.h
awk -f ${SRC}msg/parseie.awk -f ${SRC}msg/genieh.awk ${SRC}msg/ie.def >${DST}msg/uni_ie.h
awk -f ${SRC}msg/parsemsg.awk -f ${SRC}msg/genmsgc.awk ${SRC}msg/msg.def >${DST}msg/uni_msg.c

View File

@ -3,6 +3,8 @@
* Fraunhofer Institute for Open Communication Systems (FhG Fokus).
* All rights reserved.
*
* Author: Hartmut Brandt <harti@freebsd.org>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
@ -24,9 +26,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* Author: Hartmut Brandt <harti@freebsd.org>
*
* $Begemot: libunimsg/atm/misc/straddr.c,v 1.3 2003/09/19 12:05:45 hbb Exp $
* $Begemot: libunimsg/netnatm/misc/straddr.c,v 1.4 2004/07/08 08:22:02 brandt Exp $
*/
#include <sys/types.h>

View File

@ -3,6 +3,8 @@
* Fraunhofer Institute for Open Communication Systems (FhG Fokus).
* All rights reserved.
*
* Author: Hartmut Brandt <harti@freebsd.org>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
@ -24,9 +26,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* Author: Hartmut Brandt <harti@freebsd.org>
*
* $Begemot: libunimsg/atm/misc/unimsg_common.c,v 1.2 2003/09/19 12:05:45 hbb Exp $
* $Begemot: libunimsg/netnatm/misc/unimsg_common.c,v 1.3 2004/07/08 08:22:03 brandt Exp $
*/
#include <netnatm/unimsg.h>

View File

@ -26,7 +26,7 @@
#
# Author: Hartmut Brandt <harti@freebsd.org>
#
# $Begemot: libunimsg/atm/msg/geniec.awk,v 1.3 2003/09/19 11:58:15 hbb Exp $
# $Begemot: libunimsg/netnatm/msg/geniec.awk,v 1.4 2003/10/10 14:50:05 hbb Exp $
#
# Generate table for IE parsing.
#

View File

@ -26,7 +26,7 @@
#
# Author: Hartmut Brandt <harti@freebsd.org>
#
# $Begemot: libunimsg/atm/msg/genieh.awk,v 1.3 2003/09/19 11:58:15 hbb Exp $
# $Begemot: libunimsg/netnatm/msg/genieh.awk,v 1.4 2004/07/08 08:22:03 brandt Exp $
#
# Generate IE header file
#

View File

@ -26,7 +26,7 @@
#
# Author: Hartmut Brandt <harti@freebsd.org>
#
# $Begemot: libunimsg/atm/msg/genmsgc.awk,v 1.3 2003/09/19 11:58:15 hbb Exp $
# $Begemot: libunimsg/netnatm/msg/genmsgc.awk,v 1.6 2004/07/08 08:22:04 brandt Exp $
#
# Generate message functions.
#

View File

@ -26,7 +26,7 @@
#
# Author: Hartmut Brandt <harti@freebsd.org>
#
# $Begemot: libunimsg/atm/msg/genmsgh.awk,v 1.3 2003/09/19 11:58:15 hbb Exp $
# $Begemot: libunimsg/netnatm/msg/genmsgh.awk,v 1.4 2004/07/08 08:22:04 brandt Exp $
#
# Generate message header
#

View File

@ -26,7 +26,7 @@
#
# Author: Hartmut Brandt <harti@freebsd.org>
#
# $Begemot: libunimsg/atm/msg/ie.def,v 1.3 2003/09/19 11:58:15 hbb Exp $
# $Begemot: libunimsg/netnatm/msg/ie.def,v 1.4 2003/09/29 10:47:18 hbb Exp $
#
# Define information elements --- no content definition
#

View File

@ -26,7 +26,7 @@
#
# Author: Hartmut Brandt <harti@freebsd.org>
#
# $Begemot: libunimsg/atm/msg/msg.def,v 1.3 2003/09/19 11:58:15 hbb Exp $
# $Begemot: libunimsg/netnatm/msg/msg.def,v 1.4 2003/09/29 10:47:18 hbb Exp $
#
# Define message contents
#

View File

@ -26,7 +26,7 @@
#
# Author: Hartmut Brandt <harti@freebsd.org>
#
# $Begemot: libunimsg/atm/msg/parseie.awk,v 1.3 2003/09/19 11:58:15 hbb Exp $
# $Begemot: libunimsg/netnatm/msg/parseie.awk,v 1.3 2003/09/19 11:58:15 hbb Exp $
#
# Parse the IE definition file
#

View File

@ -26,7 +26,7 @@
#
# Author: Hartmut Brandt <harti@freebsd.org>
#
# $Begemot: libunimsg/atm/msg/parsemsg.awk,v 1.3 2003/09/19 11:58:15 hbb Exp $
# $Begemot: libunimsg/netnatm/msg/parsemsg.awk,v 1.3 2003/09/19 11:58:15 hbb Exp $
#
# Parse the message definition file
#

View File

@ -26,7 +26,7 @@
*
* Author: Hartmut Brandt <harti@freebsd.org>
*
* $Begemot: libunimsg/atm/msg/priv.h,v 1.3 2003/09/19 11:58:15 hbb Exp $
* $Begemot: libunimsg/netnatm/msg/priv.h,v 1.4 2003/10/10 14:50:05 hbb Exp $
*
* Private definitions for the IE code file.
*/

View File

@ -26,7 +26,7 @@
*
* Author: Hartmut Brandt <harti@freebsd.org>
*
* $Begemot: libunimsg/atm/msg/privmsg.c,v 1.3 2003/09/19 11:58:15 hbb Exp $
* $Begemot: libunimsg/netnatm/msg/privmsg.c,v 1.8 2003/10/10 14:50:05 hbb Exp $
*
* Private definitions for the MSG code file.
*

View File

@ -26,7 +26,7 @@
*
* Author: Hartmut Brandt <harti@freebsd.org>
*
* $Begemot: libunimsg/atm/msg/traffic.c,v 1.3 2003/09/19 11:58:15 hbb Exp $
* $Begemot: libunimsg/netnatm/msg/traffic.c,v 1.4 2004/07/08 08:22:05 brandt Exp $
*
* Traffic classification
*/

View File

@ -26,7 +26,7 @@
*
* Author: Hartmut Brandt <harti@freebsd.org>
*
* $Begemot: libunimsg/atm/msg/uni_config.h,v 1.3 2003/09/19 11:58:15 hbb Exp $
* $Begemot: libunimsg/netnatm/msg/uni_config.h,v 1.3 2003/09/19 11:58:15 hbb Exp $
*/
#ifndef _uni_uni_config_h_
#define _uni_uni_config_h_

View File

@ -26,12 +26,17 @@
*
* Author: Hartmut Brandt <harti@freebsd.org>
*
* $Begemot: libunimsg/atm/msg/uni_hdr.h,v 1.3 2003/09/19 11:58:15 hbb Exp $
* $Begemot: libunimsg/netnatm/msg/uni_hdr.h,v 1.6 2004/07/08 08:22:05 brandt Exp $
*/
#ifndef _NETNATM_MSG_UNI_HDR_H_
#define _NETNATM_MSG_UNI_HDR_H_
#include <sys/types.h>
#ifdef _KERNEL
#include <sys/stdint.h>
#else
#include <stdint.h>
#endif
#include <netnatm/msg/uni_config.h>

View File

@ -26,7 +26,7 @@
*
* Author: Hartmut Brandt <harti@freebsd.org>
*
* $Begemot: libunimsg/atm/msg/uni_ie.c,v 1.12 2003/10/14 15:02:22 hbb Exp $
* $Begemot: libunimsg/netnatm/msg/uni_ie.c,v 1.14 2004/07/08 08:22:06 brandt Exp $
*
* Private definitions for the IE code file.
*

View File

@ -26,7 +26,7 @@
*
* Author: Hartmut Brandt <harti@freebsd.org>
*
* $Begemot: libunimsg/atm/msg/unimsglib.h,v 1.3 2003/09/19 11:58:16 hbb Exp $
* $Begemot: libunimsg/netnatm/msg/unimsglib.h,v 1.6 2004/07/08 08:22:07 brandt Exp $
*/
#ifndef _NETNATM_MSG_UNIMSGLIB_H_
#define _NETNATM_MSG_UNIMSGLIB_H_

View File

@ -26,7 +26,7 @@
*
* Author: Hartmut Brandt <harti@freebsd.org>
*
* $Begemot: libunimsg/atm/msg/uniprint.h,v 1.3 2003/09/19 11:58:16 hbb Exp $
* $Begemot: libunimsg/netnatm/msg/uniprint.h,v 1.4 2004/07/08 08:22:08 brandt Exp $
*
* Print utility functions. These are only needed if you want to hook to
* the format of the uni printing routines.

View File

@ -3,6 +3,8 @@
* Fraunhofer Institute for Open Communication Systems (FhG Fokus).
* All rights reserved.
*
* Author: Hartmut Brandt <harti@freebsd.org>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
@ -24,9 +26,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* Author: Hartmut Brandt <harti@freebsd.org>
*
* $Begemot: libunimsg/atm/msg/unistruct.h,v 1.4 2003/09/19 11:58:16 hbb Exp $
* $Begemot: libunimsg/netnatm/msg/unistruct.h,v 1.6 2004/07/08 08:22:08 brandt Exp $
*
* This file defines all structures that are used by
* API users.

View File

@ -26,7 +26,7 @@
*
* Author: Hartmut Brandt <harti@freebsd.org>
*
* $Begemot: libunimsg/atm/saal/saal_sscfu.c,v 1.3 2003/09/19 12:02:03 hbb Exp $
* $Begemot: libunimsg/netnatm/saal/saal_sscfu.c,v 1.4 2004/07/08 08:22:10 brandt Exp $
*
* SSCF on the UNI
*/

View File

@ -26,7 +26,7 @@
*
* Author: Hartmut Brandt <harti@freebsd.org>
*
* $Begemot: libunimsg/atm/saal/saal_sscop.c,v 1.10 2003/09/19 12:02:03 hbb Exp $
* $Begemot: libunimsg/netnatm/saal/saal_sscop.c,v 1.11 2004/07/08 08:22:13 brandt Exp $
*
* Core SSCOP code (ITU-T Q.2110)
*/

View File

@ -26,7 +26,7 @@
*
* Author: Hartmut Brandt <harti@freebsd.org>
*
* $Begemot: libunimsg/atm/saal/sscfu.h,v 1.3 2003/09/19 12:02:03 hbb Exp $
* $Begemot: libunimsg/netnatm/saal/sscfu.h,v 1.4 2004/07/08 08:22:15 brandt Exp $
*
* Public include file for UNI SSCF
*/

View File

@ -26,7 +26,7 @@
*
* Author: Hartmut Brandt <harti@freebsd.org>
*
* $Begemot: libunimsg/atm/saal/sscfudef.h,v 1.3 2003/09/19 12:02:03 hbb Exp $
* $Begemot: libunimsg/netnatm/saal/sscfudef.h,v 1.4 2004/07/08 08:22:16 brandt Exp $
*
* Definitions of UNI SSCF constants.
*/

View File

@ -26,7 +26,7 @@
*
* Author: Hartmut Brandt <harti@freebsd.org>
*
* $Begemot: libunimsg/atm/saal/sscfupriv.h,v 1.3 2003/09/19 12:02:03 hbb Exp $
* $Begemot: libunimsg/netnatm/saal/sscfupriv.h,v 1.3 2003/09/19 12:02:03 hbb Exp $
*
* Private SSCF-UNI definitions.
*/

View File

@ -26,7 +26,7 @@
*
* Author: Hartmut Brandt <harti@freebsd.org>
*
* $Begemot: libunimsg/atm/saal/sscop.h,v 1.3 2003/09/19 12:02:03 hbb Exp $
* $Begemot: libunimsg/netnatm/saal/sscop.h,v 1.4 2004/07/08 08:22:16 brandt Exp $
*
* External interface to sscop.
*/

View File

@ -26,7 +26,7 @@
*
* Author: Hartmut Brandt <harti@freebsd.org>
*
* $Begemot: libunimsg/atm/saal/sscopdef.h,v 1.3 2003/09/19 12:02:03 hbb Exp $
* $Begemot: libunimsg/netnatm/saal/sscopdef.h,v 1.4 2004/07/08 08:22:17 brandt Exp $
*
* Definitions of SSCOP constants and parameter blocks. This is seen by
* the outside world.
@ -35,6 +35,11 @@
#define _NETNATM_SAAL_SSCOPDEF_H_
#include <sys/types.h>
#ifdef _KERNEL
#include <sys/stdint.h>
#else
#include <stdint.h>
#endif
/*
* AA-interface signals

View File

@ -26,7 +26,7 @@
*
* Author: Hartmut Brandt <harti@freebsd.org>
*
* $Begemot: libunimsg/atm/saal/sscoppriv.h,v 1.3 2003/09/19 12:02:03 hbb Exp $
* $Begemot: libunimsg/netnatm/saal/sscoppriv.h,v 1.4 2004/07/08 08:22:17 brandt Exp $
*
* Private SSCOP definitions.
*
@ -39,6 +39,16 @@
#include "sscopcust.h"
#endif
/* Argh. BSDi */
#ifndef _BYTE_ORDER
#ifndef BYTE_ORDER
#error "_BYTE_ORDER not defined"
#endif
#define _BYTE_ORDER BYTE_ORDER
#define _LITTLE_ENDIAN LITTLE_ENDIAN
#define _BIG_ENDIAN BIG_ENDIAN
#endif
/*
* PDU trailer
*/

View File

@ -26,7 +26,7 @@
#
# Author: Hartmut Brandt <harti@freebsd.org>
#
# $Begemot: libunimsg/atm/sig/genmsgcpyc.awk,v 1.3 2003/09/19 12:03:33 hbb Exp $
# $Begemot: libunimsg/netnatm/sig/genmsgcpyc.awk,v 1.4 2004/07/08 08:22:18 brandt Exp $
#
# Generate copy functions for messages
#

View File

@ -26,7 +26,7 @@
#
# Author: Hartmut Brandt <harti@freebsd.org>
#
# $Begemot: libunimsg/atm/sig/genmsgcpyh.awk,v 1.3 2003/09/19 12:03:33 hbb Exp $
# $Begemot: libunimsg/netnatm/sig/genmsgcpyh.awk,v 1.4 2004/07/08 08:22:19 brandt Exp $
#
# Generate copy functions for messages
#

View File

@ -26,7 +26,7 @@
*
* Author: Hartmut Brandt <harti@freebsd.org>
*
* $Begemot: libunimsg/atm/sig/sig_call.c,v 1.61 2003/10/16 13:35:44 hbb Exp $
* $Begemot: libunimsg/netnatm/sig/sig_call.c,v 1.64 2004/07/08 08:22:19 brandt Exp $
*
* Call instance handling
*
@ -144,7 +144,7 @@ uni_find_callx(struct uni *uni, u_int cref, u_int mine)
* Create a new call instance. The type must be set by the caller.
*/
struct call *
uni_create_call(struct uni *uni, u_int cref, u_int mine, u_int32_t cookie)
uni_create_call(struct uni *uni, u_int cref, u_int mine, uint32_t cookie)
{
struct call *c;
struct uniapi_call_created *ind;
@ -185,10 +185,10 @@ uni_create_call(struct uni *uni, u_int cref, u_int mine, u_int32_t cookie)
}
struct call *
uni_create_new_call(struct uni *uni, u_int32_t cookie)
uni_create_new_call(struct uni *uni, uint32_t cookie)
{
struct call *c;
u_int32_t old = uni->cref_alloc++;
uint32_t old = uni->cref_alloc++;
again:
if (uni->cref_alloc == (1 << 23))
@ -254,7 +254,7 @@ static void
allocate_epref(struct call *c, struct uni_ie_epref *epref)
{
struct party *p;
u_int32_t old = c->epref_alloc++;
uint32_t old = c->epref_alloc++;
again:
if (c->epref_alloc == (1 << 15))
@ -466,7 +466,7 @@ un0_setup(struct call *c, struct uni_msg *m, struct uni_all *u,
* Q.2971:Call-Control-N 4/39 (N0)
*/
static void
un0_setup_request(struct call *c, struct uni_msg *m, u_int32_t cookie,
un0_setup_request(struct call *c, struct uni_msg *m, uint32_t cookie,
enum call_state new_state)
{
struct uniapi_setup_request *arg =
@ -829,7 +829,7 @@ unx_alerting(struct call *c, struct uni_msg *m, struct uni_all *u,
* Q.2971:Call-Control-N 6/39 (N1)
*/
static void
u6n1_proceeding_request(struct call *c, struct uni_msg *m, u_int32_t cookie,
u6n1_proceeding_request(struct call *c, struct uni_msg *m, uint32_t cookie,
enum call_state new_state)
{
struct uni_all *msg;
@ -866,7 +866,7 @@ u6n1_proceeding_request(struct call *c, struct uni_msg *m, u_int32_t cookie,
* Q.2971:Call-Control-N 7/39 (N3)
*/
static void
unx_alerting_request(struct call *c, struct uni_msg *m, u_int32_t cookie,
unx_alerting_request(struct call *c, struct uni_msg *m, uint32_t cookie,
enum call_state new_state)
{
struct uni_all *msg;
@ -915,7 +915,7 @@ unx_alerting_request(struct call *c, struct uni_msg *m, u_int32_t cookie,
* Q.2971:Call-Control-N 8/39 (N4)
*/
static void
unx_setup_response(struct call *c, struct uni_msg *m, u_int32_t cookie,
unx_setup_response(struct call *c, struct uni_msg *m, uint32_t cookie,
enum call_state new_state)
{
struct uni_all *msg;
@ -947,6 +947,7 @@ unx_setup_response(struct call *c, struct uni_msg *m, u_int32_t cookie,
p->flags |= PARTY_CONNECT;
} else if (c->type == CALL_LEAF) {
/* XXX don't mandate if only one party */
uniapi_call_error(c, UNIAPI_ERROR_BAD_PARTY, cookie);
UNI_FREE(msg);
uni_msg_destroy(m);
@ -979,7 +980,7 @@ unx_setup_response(struct call *c, struct uni_msg *m, u_int32_t cookie,
* Q.2971:Call-Control-N 15/39 (N8)
*/
static void
n8_setup_compl_request(struct call *c, struct uni_msg *m, u_int32_t cookie,
n8_setup_compl_request(struct call *c, struct uni_msg *m, uint32_t cookie,
enum call_state new_state)
{
struct uni_all *msg;
@ -1289,7 +1290,7 @@ n10_connect_ack(struct call *c, struct uni_msg *m, struct uni_all *u)
* Q.2971:Call-Control-N 29/39 (N11)
*/
static void
unx_release_response(struct call *c, struct uni_msg *m, u_int32_t cookie)
unx_release_response(struct call *c, struct uni_msg *m, uint32_t cookie)
{
struct party *p;
struct uni_all *msg;
@ -1544,7 +1545,7 @@ unx_notify(struct call *c, struct uni_msg *m, struct uni_all *u)
* Q.2971:Call-Control-N 19/39
*/
static void
unx_notify_request(struct call *c, struct uni_msg *m, u_int32_t cookie)
unx_notify_request(struct call *c, struct uni_msg *m, uint32_t cookie)
{
struct uni_all *msg;
struct uniapi_notify_request *arg =
@ -1575,7 +1576,7 @@ unx_notify_request(struct call *c, struct uni_msg *m, u_int32_t cookie)
* Q.2971:Call-Control-N 28/39
*/
static void
unx_release_request(struct call *c, struct uni_msg *m, u_int32_t cookie,
unx_release_request(struct call *c, struct uni_msg *m, uint32_t cookie,
enum call_state new_state)
{
struct uni_all *msg;
@ -1942,7 +1943,7 @@ unx_status(struct call *c, struct uni_msg *m, struct uni_all *u)
* Q.2971:Call-Control-N 32/39
*/
static void
unx_status_enquiry_request(struct call *c, struct uni_msg *msg, u_int32_t cookie)
unx_status_enquiry_request(struct call *c, struct uni_msg *msg, uint32_t cookie)
{
struct uniapi_status_enquiry_request *arg =
uni_msg_rptr(msg, struct uniapi_status_enquiry_request *);
@ -2457,7 +2458,7 @@ nx_add_party_rej_indication(struct call *c, struct uni_msg *api)
* Q.2971:Call-Control-N 22/39 (N10)
*/
static void
unx_add_party_request(struct call *c, struct uni_msg *msg, u_int32_t cookie)
unx_add_party_request(struct call *c, struct uni_msg *msg, uint32_t cookie)
{
struct uniapi_add_party_request *add =
uni_msg_rptr(msg, struct uniapi_add_party_request *);
@ -2503,7 +2504,7 @@ unx_add_party_request(struct call *c, struct uni_msg *msg, u_int32_t cookie)
* Q.2971:Call-Control-N 22/39
*/
static void
un10_add_party_ack_request(struct call *c, struct uni_msg *msg, u_int32_t cookie)
un10_add_party_ack_request(struct call *c, struct uni_msg *msg, uint32_t cookie)
{
struct uniapi_add_party_ack_request *ack =
uni_msg_rptr(msg, struct uniapi_add_party_ack_request *);
@ -2538,7 +2539,7 @@ un10_add_party_ack_request(struct call *c, struct uni_msg *msg, u_int32_t cookie
* Q.2971:Call-Control-N 22/39 N10
*/
static void
unx_party_alerting_request(struct call *c, struct uni_msg *msg, u_int32_t cookie)
unx_party_alerting_request(struct call *c, struct uni_msg *msg, uint32_t cookie)
{
struct uniapi_party_alerting_request *alert =
uni_msg_rptr(msg, struct uniapi_party_alerting_request *);
@ -2573,7 +2574,7 @@ unx_party_alerting_request(struct call *c, struct uni_msg *msg, u_int32_t cookie
* Q.2971:Call-Control-N 22/39 N10
*/
static void
unx_add_party_rej_request(struct call *c, struct uni_msg *msg, u_int32_t cookie)
unx_add_party_rej_request(struct call *c, struct uni_msg *msg, uint32_t cookie)
{
struct uniapi_add_party_rej_request *rej =
uni_msg_rptr(msg, struct uniapi_add_party_rej_request *);
@ -2607,7 +2608,7 @@ unx_add_party_rej_request(struct call *c, struct uni_msg *msg, u_int32_t cookie)
* Q.2971:Call-Control-N 27/39 N1-N9
*/
static void
unx_drop_party_request(struct call *c, struct uni_msg *msg, u_int32_t cookie)
unx_drop_party_request(struct call *c, struct uni_msg *msg, uint32_t cookie)
{
struct uniapi_drop_party_request *drop =
uni_msg_rptr(msg, struct uniapi_drop_party_request *);
@ -2637,7 +2638,7 @@ unx_drop_party_request(struct call *c, struct uni_msg *msg, u_int32_t cookie)
*/
static void
unx_drop_party_ack_request(struct call *c, struct uni_msg *msg,
u_int32_t cookie)
uint32_t cookie)
{
struct uniapi_drop_party_ack_request *ack =
uni_msg_rptr(msg, struct uniapi_drop_party_ack_request *);
@ -2667,6 +2668,7 @@ unx_drop_party_ack_request(struct call *c, struct uni_msg *msg,
* Q.2971:Call-Control-N 21/39 N10
*
* Body already decoded
* XXX check EPREF flag
*/
static void
unx_add_party(struct call *c, struct uni_msg *m, struct uni_all *u,
@ -2751,6 +2753,14 @@ unx_add_party(struct call *c, struct uni_msg *m, struct uni_all *u,
&u->u.add_party.epref, -1);
return;
}
if (IE_ISGOOD(u->u.add_party.epref) && p == NULL &&
u->u.add_party.epref.flag) {
IE_SETERROR(u->u.add_party.epref);
UNI_SAVE_IERR(&c->uni->cx, UNI_IE_EPREF,
u->u.add_party.epref.h.act, UNI_IERR_BAD);
}
if (!IE_ISGOOD(u->u.add_party.epref)) {
/* 9.5.3.2.2 */
if (vfy == VFY_OK) {
@ -3321,7 +3331,7 @@ unx_unknown(struct call *c, struct uni_msg *m, struct uni_all *u)
/**********************************************************************/
void
uni_sig_call(struct call *c, enum call_sig sig, u_int32_t cookie,
uni_sig_call(struct call *c, enum call_sig sig, uint32_t cookie,
struct uni_msg *msg, struct uni_all *u)
{
if (sig >= SIGC_END) {
@ -3859,7 +3869,7 @@ uni_sig_call(struct call *c, enum call_sig sig, u_int32_t cookie,
unx_alerting_request(c, msg, cookie, CALLST_U7);
break;
}
if (c->cstate == CALLST_N1 || c->cstate == CALLST_N1) {
if (c->cstate == CALLST_N1 || c->cstate == CALLST_N3) {
/* Q.2971:Call-Control-N 38/39 (N1) */
/* Q.2971:Call-Control-N 7/39 (N3) */
unx_alerting_request(c, msg, cookie, CALLST_N4);

View File

@ -26,7 +26,7 @@
*
* Author: Hartmut Brandt <harti@freebsd.org>
*
* $Begemot: libunimsg/atm/sig/sig_coord.c,v 1.6 2003/09/24 10:27:50 hbb Exp $
* $Begemot: libunimsg/netnatm/sig/sig_coord.c,v 1.11 2004/07/08 08:22:20 brandt Exp $
*
* Coordinator
*/
@ -200,7 +200,7 @@ coord_saal_release_indication(struct uni *uni)
* a call instance. In this case 'cookie' is zero.
*/
static void
coord_link_establish_request(struct uni *uni, u_int32_t cookie)
coord_link_establish_request(struct uni *uni, uint32_t cookie)
{
switch (uni->custat) {
@ -650,7 +650,7 @@ input_call(struct call *c, struct uni_msg *m, struct uni_all *u)
* Signal handler of the coordinator
*/
void
uni_sig_coord(struct uni *uni, enum coord_sig sig, u_int32_t cookie,
uni_sig_coord(struct uni *uni, enum coord_sig sig, uint32_t cookie,
struct uni_msg *msg)
{
struct call *c;

View File

@ -26,7 +26,7 @@
*
* Author: Hartmut Brandt <harti@freebsd.org>
*
* $Begemot: libunimsg/atm/sig/sig_party.c,v 1.12 2003/10/10 14:37:28 hbb Exp $
* $Begemot: libunimsg/netnatm/sig/sig_party.c,v 1.17 2004/07/08 08:22:21 brandt Exp $
*
* Party instance handling
*/
@ -71,7 +71,7 @@ set_party_state(struct party *p, enum uni_epstate state)
* No check is done, that a party with this epref does not alreay exist.
*/
struct party *
uni_create_partyx(struct call *c, u_int epref, u_int mine, u_int32_t cookie)
uni_create_partyx(struct call *c, u_int epref, u_int mine, uint32_t cookie)
{
struct party *p;
struct uni_msg *api;
@ -232,7 +232,7 @@ stop_all_party_timers(struct party *p)
* Q.2971:Party-control-N 3 (PN0)
*/
static void
pun0_add_party_request(struct party *p, struct uni_msg *api, u_int32_t cookie)
pun0_add_party_request(struct party *p, struct uni_msg *api, uint32_t cookie)
{
struct uni_all *add;
struct uniapi_add_party_request *req =
@ -266,7 +266,7 @@ pun0_add_party_request(struct party *p, struct uni_msg *api, u_int32_t cookie)
* Q.2971:Party-Control-N 7 PN3
*/
static void
punx_add_party_ack_request(struct party *p, struct uni_msg *m, u_int32_t cookie)
punx_add_party_ack_request(struct party *p, struct uni_msg *m, uint32_t cookie)
{
struct uni_all *ack;
struct uniapi_add_party_ack_request *req =
@ -295,7 +295,7 @@ punx_add_party_ack_request(struct party *p, struct uni_msg *m, u_int32_t cookie)
* Q.2971:Party-Control-N 6 PN2
*/
static void
pun2_add_party_rej_request(struct party *p, struct uni_msg *m, u_int32_t cookie)
pun2_add_party_rej_request(struct party *p, struct uni_msg *m, uint32_t cookie)
{
struct uni_all *rej;
struct uniapi_add_party_rej_request *req =
@ -352,7 +352,7 @@ pun0_add_party(struct party *p, struct uni_msg *m, struct uni_all *u)
*/
static void
pun2_party_alerting_request(struct party *p, struct uni_msg *api,
u_int32_t cookie)
uint32_t cookie)
{
struct uni_all *alert;
struct uniapi_party_alerting_request *req =
@ -751,7 +751,7 @@ drop_partyE(struct party *p)
* Q.2971:Party-Control-N 8
*/
static void
punx_drop_party_request(struct party *p, struct uni_msg *api, u_int32_t cookie)
punx_drop_party_request(struct party *p, struct uni_msg *api, uint32_t cookie)
{
struct uniapi_drop_party_request *req =
uni_msg_rptr(api, struct uniapi_drop_party_request *);
@ -784,7 +784,7 @@ punx_drop_party_request(struct party *p, struct uni_msg *api, u_int32_t cookie)
* Q.2971:Party-Control-N 9
*/
static void
pun6_drop_party_ack_request(struct party *p, struct uni_msg *api, u_int32_t cookie)
pun6_drop_party_ack_request(struct party *p, struct uni_msg *api, uint32_t cookie)
{
struct uniapi_drop_party_ack_request *req =
uni_msg_rptr(api, struct uniapi_drop_party_ack_request *);
@ -814,7 +814,7 @@ pun6_drop_party_ack_request(struct party *p, struct uni_msg *api, u_int32_t cook
* Q.2971:Party-Control-N 12
*/
static void
punx_status_enquiry_request(struct party *p, u_int32_t cookie)
punx_status_enquiry_request(struct party *p, uint32_t cookie)
{
struct uni_all *enq;
@ -911,7 +911,7 @@ pun5_status(struct party *p, struct uni_msg *m, struct uni_all *u)
/************************************************************/
void
uni_sig_party(struct party *p, enum party_sig sig, u_int32_t cookie,
uni_sig_party(struct party *p, enum party_sig sig, uint32_t cookie,
struct uni_msg *msg, struct uni_all *u)
{
if (sig >= SIGP_END) {

View File

@ -27,7 +27,7 @@
* Author: Hartmut Brandt <harti@freebsd.org>
* Kendy Kutzner <kutzner@fokus.fraunhofer.de>
*
* $Begemot: libunimsg/atm/sig/sig_print.c,v 1.4 2003/09/19 12:03:34 hbb Exp $
* $Begemot: libunimsg/netnatm/sig/sig_print.c,v 1.5 2004/07/08 08:22:22 brandt Exp $
*/
#include <sys/types.h>

View File

@ -3,6 +3,8 @@
* Fraunhofer Institute for Open Communication Systems (FhG Fokus).
* All rights reserved.
*
* Author: Hartmut Brandt <harti@freebsd.org>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
@ -24,9 +26,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* Author: Hartmut Brandt <harti@freebsd.org>
*
* $Begemot: libunimsg/atm/sig/sig_reset.c,v 1.5 2003/09/24 10:27:50 hbb Exp $
* $Begemot: libunimsg/netnatm/sig/sig_reset.c,v 1.10 2004/07/08 08:22:22 brandt Exp $
*
* Reset-start and reset-respond
*/
@ -45,10 +45,13 @@ static void response_status(struct uni *, struct uni_msg *, struct uni_all *);
static void response_t317(struct uni *);
static void response_error(struct uni *, struct uniapi_reset_error_response *, u_int32_t cookie);
static void response_response(struct uni *, struct uniapi_reset_response *, u_int32_t);
static void response_error(struct uni *, struct uniapi_reset_error_response *,
uint32_t cookie);
static void response_response(struct uni *, struct uniapi_reset_response *,
uint32_t);
static void start_request(struct uni *, struct uniapi_reset_request *, u_int32_t);
static void start_request(struct uni *, struct uniapi_reset_request *,
uint32_t);
static void start_t316(struct uni *);
@ -76,7 +79,7 @@ TIMER_FUNC_UNI(t316, t316_func)
* Reset-Start process.
*/
void
uni_sig_start(struct uni *uni, u_int sig, u_int32_t cookie,
uni_sig_start(struct uni *uni, u_int sig, uint32_t cookie,
struct uni_msg *m, struct uni_all *u)
{
if (sig >= SIGS_END) {
@ -137,7 +140,7 @@ uni_sig_start(struct uni *uni, u_int sig, u_int32_t cookie,
* Q.2931:Reset-Start 1/2
*/
static void
start_request(struct uni *uni, struct uniapi_reset_request *req, u_int32_t cookie)
start_request(struct uni *uni, struct uniapi_reset_request *req, uint32_t cookie)
{
struct uni_all *resp;
int err;
@ -432,7 +435,7 @@ start_status(struct uni *uni, struct uni_msg *m, struct uni_all *u)
* Reset-Respond process.
*/
void
uni_sig_respond(struct uni *uni, u_int sig, u_int32_t cookie,
uni_sig_respond(struct uni *uni, u_int sig, uint32_t cookie,
struct uni_msg *m, struct uni_all *u)
{
if (sig >= SIGR_END) {
@ -639,7 +642,7 @@ response_t317(struct uni *uni)
*/
static void
response_error(struct uni *uni, struct uniapi_reset_error_response *c,
u_int32_t cookie)
uint32_t cookie)
{
struct uni_all *resp;
@ -681,7 +684,7 @@ response_error(struct uni *uni, struct uniapi_reset_error_response *c,
*/
static void
response_response(struct uni *uni, struct uniapi_reset_response *arg,
u_int32_t cookie)
uint32_t cookie)
{
struct uni_all *resp;

View File

@ -26,7 +26,7 @@
*
* Author: Hartmut Brandt <harti@freebsd.org>
*
* $Begemot: libunimsg/atm/sig/sig_uni.c,v 1.4 2003/09/24 10:27:50 hbb Exp $
* $Begemot: libunimsg/netnatm/sig/sig_uni.c,v 1.10 2004/07/08 08:22:23 brandt Exp $
*
* Instance handling
*/
@ -363,7 +363,7 @@ static struct {
};
void
uni_uni_input(struct uni *uni, enum uni_sig sig, u_int32_t cookie,
uni_uni_input(struct uni *uni, enum uni_sig sig, uint32_t cookie,
struct uni_msg *m)
{
u_int i;
@ -462,7 +462,7 @@ uni_work(struct uni *uni)
*/
void
uni_enq_sig(struct uni *uni, u_int type, struct call *call,
struct party *party, u_int32_t sig, u_int32_t cookie,
struct party *party, uint32_t sig, uint32_t cookie,
struct uni_msg *msg, struct uni_all *u)
{
struct sig *s;
@ -484,7 +484,7 @@ uni_enq_sig(struct uni *uni, u_int type, struct call *call,
*/
void
uni_delenq_sig(struct uni *uni, u_int type, struct call *call,
struct party *party, u_int32_t sig, u_int32_t cookie,
struct party *party, uint32_t sig, uint32_t cookie,
struct uni_msg *msg, struct uni_all *u)
{
struct sig *s;
@ -504,8 +504,8 @@ uni_delenq_sig(struct uni *uni, u_int type, struct call *call,
/**************************************************************/
void
uniapi_uni_error(struct uni *uni, u_int32_t reason, u_int32_t cookie,
u_int32_t state)
uniapi_uni_error(struct uni *uni, uint32_t reason, uint32_t cookie,
uint32_t state)
{
struct uni_msg *resp;
struct uniapi_error *err;
@ -524,12 +524,12 @@ uniapi_uni_error(struct uni *uni, u_int32_t reason, u_int32_t cookie,
}
void
uniapi_call_error(struct call *c, u_int32_t reason, u_int32_t cookie)
uniapi_call_error(struct call *c, uint32_t reason, uint32_t cookie)
{
uniapi_uni_error(c->uni, reason, cookie, callstates[c->cstate].ext);
}
void
uniapi_party_error(struct party *p, u_int32_t reason, u_int32_t cookie)
uniapi_party_error(struct party *p, uint32_t reason, uint32_t cookie)
{
uniapi_uni_error(p->call->uni, reason, cookie,
callstates[p->call->cstate].ext);
@ -657,7 +657,7 @@ uni_get_config(const struct uni *uni, struct uni_config *config)
void
uni_set_config(struct uni *uni, const struct uni_config *config,
u_int32_t *mask, u_int32_t *popt_mask, u_int32_t *opt_mask)
uint32_t *mask, uint32_t *popt_mask, uint32_t *opt_mask)
{
int idle;

View File

@ -26,7 +26,7 @@
*
* Author: Hartmut Brandt <harti@freebsd.org>
*
* $Begemot: libunimsg/atm/sig/sig_verify.c,v 1.16 2003/10/10 14:37:28 hbb Exp $
* $Begemot: libunimsg/netnatm/sig/sig_verify.c,v 1.19 2004/07/08 08:22:23 brandt Exp $
*
* Message verification with explicit action indicators.
*/

View File

@ -26,7 +26,7 @@
*
* Author: Hartmut Brandt <harti@freebsd.org>
*
* $Begemot: libunimsg/atm/sig/uni.h,v 1.3 2003/09/19 12:03:34 hbb Exp $
* $Begemot: libunimsg/netnatm/sig/uni.h,v 1.5 2004/07/08 08:22:24 brandt Exp $
*
* Public UNI interface
*/
@ -41,7 +41,7 @@ struct uni;
struct uni_funcs {
/* output to the upper layer */
void (*uni_output)(struct uni *, void *, enum uni_sig,
u_int32_t, struct uni_msg *);
uint32_t, struct uni_msg *);
/* output to the SAAL */
void (*saal_output)(struct uni *, void *, enum saal_sig,
@ -79,13 +79,13 @@ void uni_get_config(const struct uni *, struct uni_config *);
/* set new instance configuration */
void uni_set_config(struct uni *, const struct uni_config *,
u_int32_t *, u_int32_t *, u_int32_t *);
uint32_t *, uint32_t *, uint32_t *);
/* input from the SAAL to the instance */
void uni_saal_input(struct uni *, enum saal_sig, struct uni_msg *);
/* input from the upper layer to the instance */
void uni_uni_input(struct uni *, enum uni_sig, u_int32_t, struct uni_msg *);
void uni_uni_input(struct uni *, enum uni_sig, uint32_t, struct uni_msg *);
/* do work on pending signals */
void uni_work(struct uni *);

View File

@ -26,13 +26,19 @@
*
* Author: Hartmut Brandt <harti@freebsd.org>
*
* $Begemot: libunimsg/atm/sig/unidef.h,v 1.6 2003/09/19 12:03:34 hbb Exp $
* $Begemot: libunimsg/netnatm/sig/unidef.h,v 1.9 2004/07/08 08:22:24 brandt Exp $
*
* UNI public definitions.
*/
#ifndef _ATM_SIG_UNIDEF_H_
#define _ATM_SIG_UNIDEF_H_
#ifdef _KERNEL
#include <sys/stdint.h>
#else
#include <stdint.h>
#endif
/*
* Debug facilities
*/
@ -109,25 +115,25 @@ enum uni_option {
* UNI configuration
*/
struct uni_config {
u_int32_t proto; /* which protocol */
u_int32_t popt; /* protocol option */
u_int32_t option; /* other options */
u_int32_t timer301; /* T301 */
u_int32_t timer303; /* T303 */
u_int32_t init303; /* T303 retransmission count */
u_int32_t timer308; /* T308 */
u_int32_t init308; /* T308 retransmission count */
u_int32_t timer309; /* T309 */
u_int32_t timer310; /* T310 */
u_int32_t timer313; /* T313 */
u_int32_t timer316; /* T316 */
u_int32_t init316; /* T316 retransmission count */
u_int32_t timer317; /* T317 */
u_int32_t timer322; /* T322 */
u_int32_t init322; /* T322 retransmission count */
u_int32_t timer397; /* T397 */
u_int32_t timer398; /* T398 */
u_int32_t timer399; /* T399 */
uint32_t proto; /* which protocol */
uint32_t popt; /* protocol option */
uint32_t option; /* other options */
uint32_t timer301; /* T301 */
uint32_t timer303; /* T303 */
uint32_t init303; /* T303 retransmission count */
uint32_t timer308; /* T308 */
uint32_t init308; /* T308 retransmission count */
uint32_t timer309; /* T309 */
uint32_t timer310; /* T310 */
uint32_t timer313; /* T313 */
uint32_t timer316; /* T316 */
uint32_t init316; /* T316 retransmission count */
uint32_t timer317; /* T317 */
uint32_t timer322; /* T322 */
uint32_t init322; /* T322 retransmission count */
uint32_t timer397; /* T397 */
uint32_t timer398; /* T398 */
uint32_t timer399; /* T399 */
};
enum uni_config_mask {
UNICFG_PROTO = 0x00000001,
@ -213,8 +219,8 @@ enum uni_sig {
};
struct uniapi_error {
u_int32_t reason;
u_int32_t state;
uint32_t reason;
uint32_t state;
};
/* keep this in sync with atmapi.h:enum atmerr */
@ -275,8 +281,8 @@ struct uniapi_reset_indication {
};
struct uniapi_reset_error_indication {
u_int32_t source; /* 0 - start, 1 - response */
u_int32_t reason;
uint32_t source; /* 0 - start, 1 - response */
uint32_t reason;
};
#define UNIAPI_DEF_RESET_ERRORS(MACRO) \

View File

@ -26,7 +26,7 @@
*
* Author: Hartmut Brandt <harti@freebsd.org>
*
* $Begemot: libunimsg/atm/sig/unimkmsg.h,v 1.4 2003/09/19 12:03:34 hbb Exp $
* $Begemot: libunimsg/netnatm/sig/unimkmsg.h,v 1.4 2003/09/19 12:03:34 hbb Exp $
*
* Macros to make messages.
*/

View File

@ -26,7 +26,7 @@
*
* Author: Hartmut Brandt <harti@freebsd.org>
*
* $Begemot: libunimsg/atm/sig/unipriv.h,v 1.5 2003/09/24 10:27:50 hbb Exp $
* $Begemot: libunimsg/netnatm/sig/unipriv.h,v 1.17 2004/07/08 08:22:25 brandt Exp $
*
* Private UNI stuff.
*/
@ -229,8 +229,8 @@ struct sig {
u_int type; /* one of the above */
struct call *call; /* call to send to */
struct party *party; /* party to send to */
u_int32_t sig; /* the signal */
u_int32_t cookie; /* user cookie */
uint32_t sig; /* the signal */
uint32_t cookie; /* user cookie */
struct uni_msg *msg; /* attached message */
struct uni_all *u; /* dito */
};
@ -248,15 +248,15 @@ TAILQ_HEAD(sigqueue, sig);
} \
} while(0)
void uni_sig_party(struct party *, enum party_sig, u_int32_t cookie,
void uni_sig_party(struct party *, enum party_sig, uint32_t cookie,
struct uni_msg *, struct uni_all *);
void uni_sig_call(struct call *, enum call_sig, u_int32_t cookie,
void uni_sig_call(struct call *, enum call_sig, uint32_t cookie,
struct uni_msg *, struct uni_all *);
void uni_sig_coord(struct uni *, enum coord_sig, u_int32_t cookie,
void uni_sig_coord(struct uni *, enum coord_sig, uint32_t cookie,
struct uni_msg *);
void uni_sig_start(struct uni *, enum start_sig, u_int32_t cookie,
void uni_sig_start(struct uni *, enum start_sig, uint32_t cookie,
struct uni_msg *, struct uni_all *);
void uni_sig_respond(struct uni *, enum respond_sig, u_int32_t cookie,
void uni_sig_respond(struct uni *, enum respond_sig, uint32_t cookie,
struct uni_msg *, struct uni_all *);
/*************************************************************
@ -283,7 +283,8 @@ void uni_destroy_party(struct party *, int);
struct party *uni_find_party(struct call *, struct uni_ie_epref *);
struct party *uni_find_partyx(struct call *, u_int epref, u_int mine);
struct party *uni_create_party(struct call *, struct uni_ie_epref *);
struct party *uni_create_partyx(struct call *, u_int epref, u_int mine, u_int32_t cookie);
struct party *uni_create_partyx(struct call *, u_int epref, u_int mine,
uint32_t cookie);
u_int uni_party_act_count(struct call *, int);
enum call_type {
@ -336,8 +337,8 @@ TAILQ_HEAD(callqueue, call);
struct call *uni_find_call(struct uni *, struct uni_cref *);
struct call *uni_find_callx(struct uni *, u_int cref, u_int mine);
struct call *uni_create_call(struct uni *, u_int cref, u_int mine,
u_int32_t cookie);
struct call *uni_create_new_call(struct uni *, u_int32_t cookie);
uint32_t cookie);
struct call *uni_create_new_call(struct uni *, uint32_t cookie);
void uni_destroy_call(struct call *, int);
void uni_bad_message(struct call *, struct uni_all *, u_int,
@ -364,7 +365,7 @@ struct uni {
struct sigqueue delq; /* delayed signal queue */
int working;
u_int32_t cref_alloc;
uint32_t cref_alloc;
enum cu_stat custat; /* coordinator state */
struct uni_timer t309;
@ -403,10 +404,10 @@ struct uni {
u_int debug[UNI_MAXFACILITY];
};
void uniapi_uni_error(struct uni *uni, u_int32_t reason, u_int32_t cookie,
u_int32_t state);
void uniapi_call_error(struct call *c, u_int32_t reason, u_int32_t cookie);
void uniapi_party_error(struct party *p, u_int32_t reason, u_int32_t cookie);
void uniapi_uni_error(struct uni *uni, uint32_t reason, uint32_t cookie,
uint32_t state);
void uniapi_call_error(struct call *c, uint32_t reason, uint32_t cookie);
void uniapi_party_error(struct party *p, uint32_t reason, uint32_t cookie);
/*************************************************************
*
@ -513,18 +514,36 @@ void uni_respond_status_mtype(struct uni *uni, struct uni_cref *cref,
_tmp; \
})
#define VERBOSE(UNI, FAC, LEVEL, FMT, ARGS...) do { \
#if defined(__GNUC__) && __GNUC__ < 3
#define VERBOSE(UNI, FAC, LEVEL, ARGS...) do { \
if ((UNI)->debug[(FAC)] >= (LEVEL)) { \
(UNI)->funcs->verbose((UNI), (UNI)->arg, (FAC), \
FMT , ## ARGS); \
(UNI)->funcs->verbose((UNI), (UNI)->arg, (FAC) ,\
## ARGS); \
} \
} while(0)
#define VERBOSE0(UNI, FAC, FMT, ARGS...) do { \
(UNI)->funcs->verbose((UNI), (UNI)->arg, (FAC), FMT , \
#define VERBOSE0(UNI, FAC, ARGS...) do { \
(UNI)->funcs->verbose((UNI), (UNI)->arg, (FAC) , \
## ARGS); \
} while(0)
#else
#define VERBOSE(UNI, FAC, LEVEL, ...) do { \
if ((UNI)->debug[(FAC)] >= (LEVEL)) { \
(UNI)->funcs->verbose((UNI), (UNI)->arg, (FAC), \
__VA_ARGS__); \
} \
} while(0)
#define VERBOSE0(UNI, FAC, ...) do { \
(UNI)->funcs->verbose((UNI), (UNI)->arg, (FAC), \
__VA_ARGS__); \
} while(0)
#endif
#define TIMER_INIT_UNI(U,T) _TIMER_INIT(U,T)
#define TIMER_INIT_CALL(C,T) _TIMER_INIT(C,T)
#define TIMER_INIT_PARTY(P,T) _TIMER_INIT(P,T)

View File

@ -26,7 +26,7 @@
*
* Author: Hartmut Brandt <harti@freebsd.org>
*
* $Begemot: libunimsg/atm/sig/unisig.h,v 1.3 2003/09/19 12:03:34 hbb Exp $
* $Begemot: libunimsg/netnatm/sig/unisig.h,v 1.4 2004/07/08 08:22:26 brandt Exp $
*
* Utility functions for signalling stuff
*/

View File

@ -3,6 +3,8 @@
* Fraunhofer Institute for Open Communication Systems (FhG Fokus).
* All rights reserved.
*
* Author: Hartmut Brandt <harti@freebsd.org>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
@ -24,9 +26,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* Author: Hartmut Brandt <harti@freebsd.org>
*
* $Begemot: libunimsg/atm/unimsg.h,v 1.3 2003/09/19 11:52:40 hbb Exp $
* $Begemot: libunimsg/netnatm/unimsg.h,v 1.4 2004/07/08 08:21:46 brandt Exp $
*
* This defines the structure of messages as handled by this library.
*/
@ -38,8 +38,10 @@
#ifdef __FreeBSD__
#include <sys/systm.h>
#endif
#include <sys/stdint.h>
#else
#include <string.h>
#include <stdint.h>
#endif
struct uni_msg {