|
OpenSS7 SS7 for the Common Man |
© Copyright 1997-2004,OpenSS7 Corporation, All Rights Reserved. |
||||||||||||||||||||||||||
| Home | Overview | Status | News | Documentation | Resources | About | |||||||||||||||||||||
File /code/strss7/drivers/ua/ua_tsp.c
#ident "@(#) $RCSfile: ua_tsp.c,v $ $Name: $($Revision: 0.8.2.1 $) $Date: 2002/10/18 02:26:20 $"
static char const ident[] =
"$RCSfile: ua_tsp.c,v $ $Name: $($Revision: 0.8.2.1 $) $Date: 2002/10/18 02:26:20 $";
/*
* =========================================================================
*
* T-Provider --> UA (Upstream primitives received from downstream)
*
* =========================================================================
*/
/*
* T_CONN_IND 11 - connection indication
* -------------------------------------------------------------------------
* We should not be getting connection indications. Notify management and
* let it decide what to do with the stream. We should unlink and abort the
* stream so that management can talk directly to the stream.
*/
static int tsp_conn_ind(queue_t * q, mblk_t * pdu)
{
int err;
/* notify management */
if ((err = m_link_ind(q, pdu)))
return (err);
/*
* FIXME: abort and unlink the stream...
*/
freemsg(pdu);
return (0);
}
/*
* T_CONN_CON 12 - connection confirmation
* -------------------------------------------------------------------------
* We should not be getting connection confirmations. Notify management and
* let it decide what to do with the stream. We should unlink and abort the
* stream so that management can talk directly to the stream.
*/
static int tsp_conn_con(queue_t * q, mblk_t * pdu)
{
int err;
/* notify management */
if ((err = m_link_ind(q, pdu)))
return (err);
/*
* FIXME: abort and unlink the stream...
*/
freemsg(pdu);
return (0);
}
/*
* T_DISCON_IND 13 - disconnect indication
* -------------------------------------------------------------------------
* The other end has gone bye-bye. Unlink and abort the stream so that
* management can attempt reconnection if necessary.
*/
static int tsp_discon_ind(queue_t * q, mblk_t * pdu)
{
int err;
if ((err = m_link_ind(q, pdu)))
return (err);
/*
* FIXME: abort and unlink the stream...
*/
freemsg(pdu);
return (0);
}
/*
* T_DATA_IND 14 - data indication
* -------------------------------------------------------------------------
* This is translated into UA messages and fed to the state machines.
* FIXME: this function is not memory exhaustion safe...
*/
static int tsp_data_ind(queue_t * q, mblk_t * pdu)
{
mblk_t *dp;
sp_t *sp = ((lp_t *) q->q_ptr)->u.sp;
struct T_data_ind *p = (struct T_data_ind *) pdu->b_rptr;
if (p->MORE_flag) {
/* we are reassembling at the SP */
if (sp->reassem)
linkb(sp->reassem, pdu->b_cont);
else
sp->reassem = pdu->b_cont;
freeb(pdu);
return (0);
}
if (sp->reassem) {
/* we are completing a reassembly at the SP */
linkb(sp->reassem, pdu->b_cont);
dp = sp->reassem;
sp->reassem = NULL;
} else {
dp = pdu->b_cont;
}
dp->b_band = 0;
if ((err = ua_recv_msg(q, dp)))
return (err);
freeb(pdu);
return (0);
}
/*
* T_EXDATA_IND 15 - expedited data indication
* -------------------------------------------------------------------------
* This is translated into UA messages and fed to the state machines.
* FIXME: this function is not memory exhaustion safe...
*/
static int tsp_exdata_ind(queue_t * q, mblk_t * pdu)
{
mblk_t *dp;
sp_t *sp = ((lp_t *) q->q_ptr)->u.sp;
struct T_exdata_ind *p = (struct T_exdata_ind *) pdu->b_rptr;
if (p->MORE_flag) {
/* reassembling exdata at the SP */
if (sp->exassem)
linkb(sp->reassem, pdu->b_cont);
else
sp->exassem = pdu->b_cont;
freeb(pdu);
return (0);
}
if (sp->exassem) {
/* we are completing a reassembly at the SP */
linkb(sp->exassem, pdu->b_cont);
dp = sp->exassem;
sp->exassem = NULL;
} else {
dp = pdu->b_cont;
}
dp->b_band = 1;
if ((err = ua_recv_msg(q, dp)))
return (err);
freeb(pdu);
return (0);
}
/*
* T_INFO_ACK 16 - information acknowledgement
* -------------------------------------------------------------------------
*/
static int tsp_info_ack(queue_t * q, mblk_t * pdu)
{
/*
* NOTE:- We might later want to copy out some of the pertinent
* information for ourselves.
*/
/* give it to management */
return m_link_ind(q, pdu);
}
/*
* T_BIND_ACK 17 - bind acknowledgement
* -------------------------------------------------------------------------
*/
static int tsp_bind_ack(queue_t * q, mblk_t * pdu)
{
/*
* NOTE:- We might later want to copy out some of the pertinent
* information for ourselves.
*/
/* give it to management */
return m_link_ind(q, pdu);
}
/*
* T_ERROR_ACK 18 - error acknowledgement
* -------------------------------------------------------------------------
*/
static int tsp_error_ack(queue_t * q, mblk_t * pdu)
{
/*
* FIXME: We should check what state we are in and decide what
* actions should be taken. Most often we will probably need to shut
* down the SP, abort the connection and unlink the stream.
*/
/* give it to management */
return m_link_ind(q, pdu);
}
/*
* T_OK_ACK 19 - ok acknowledgement
* -------------------------------------------------------------------------
*/
static int tsp_ok_ack(queue_t * q, mblk_t * pdu)
{
/*
* FIXME: We should check what state we are in and decide what
* actions should be taken. Most often we will probably need to shut
* down the SP, abort the connection and unlink the stream.
*/
/* give it to management */
return m_link_ind(q, pdu);
}
/*
* T_UNITDATA_IND 20 - unitdata indication
* -------------------------------------------------------------------------
* I don't know why we would get these, but maybe this is a connection-less
* transport which is sequenced...
*/
static int tsp_unitdata_ind(queue_t * q, mblk_t * pdu)
{
int err;
mblk_t *dp;
dp = pdu->b_cont;
dp->b_band = 0;
freeb(pdu);
if ((err = ua_recv_msg(q, dp)))
return (err);
return (0);
}
/*
* T_UDERROR_IND 21 - unitdata error indication
* -------------------------------------------------------------------------
*/
static int tsp_uderror_ind(queue_t * q, mblk_t * pdu)
{
(void) q;
(void) pdu;
/* FIXME */
return (-EFAULT);
}
/*
* T_OPTMGMT_ACK 22 - options management acknowledgement
* -------------------------------------------------------------------------
*/
static int tsp_optmgmt_ack(queue_t * q, mblk_t * pdu)
{
(void) q;
(void) pdu;
/* FIXME */
return (-EFAULT);
}
/*
* T_ORDREL_IND 23 - orderly release indication
* -------------------------------------------------------------------------
*/
static int tsp_ordrel_ind(queue_t * q, mblk_t * pdu)
{
(void) q;
(void) pdu;
/* FIXME */
return (-EFAULT);
}
/*
* T_OPTDATA_IND 26 - data with options indication
* -------------------------------------------------------------------------
*/
static int tsp_optdata_ind(queue_t * q, mblk_t * pdu)
{
(void) q;
(void) pdu;
/* FIXME */
return (-EFAULT);
}
/*
* T_ADDR_ACK 27 - address acknowledgement
* -------------------------------------------------------------------------
*/
static int tsp_addr_ack(queue_t * q, mblk_t * pdu)
{
(void) q;
(void) pdu;
/* FIXME */
return (-EFAULT);
}
static int (*tsp_prim[]) (queue_t *, mblk_t *) = {
NULL, /* T_CONN_REQ 0 - connection request */
NULL, /* T_CONN_RES 1 - connection response */
NULL, /* T_DISCON_REQ 2 - disconnect request */
NULL, /* T_DATA_REQ 3 - data request */
NULL, /* T_EXDATA_REQ 4 - expedited data request */
NULL, /* T_INFO_REQ 5 - information request */
NULL, /* T_BIND_REQ 6 - bind request */
NULL, /* T_UNBIND_REQ 7 - unbind request */
NULL, /* T_UNITDATA_REQ 8 - unitdata request */
NULL, /* T_OPTMGMT_REQ 9 - options management request */
NULL, /* T_ORDREL_REQ 10 - orderly release request */
#define TSP_USTR_FIRST T_CONN_IND
tsp_conn_ind, /* T_CONN_IND 11 - connection indication */
tsp_conn_con, /* T_CONN_CON 12 - connection confirmation */
tsp_discon_ind, /* T_DISCON_IND 13 - disconnect indication */
tsp_data_ind, /* T_DATA_IND 14 - data indication */
tsp_exdata_ind, /* T_EXDATA_IND 15 - expedited data indication */
tsp_info_ack, /* T_INFO_ACK 16 - information acknowledgement */
tsp_bind_ack, /* T_BIND_ACK 17 - bind acknowledgement */
tsp_error_ack, /* T_ERROR_ACK 18 - error acknowledgement */
tsp_ok_ack, /* T_OK_ACK 19 - ok acknowledgement */
tsp_unitdata_ind, /* T_UNITDATA_IND 20 - unitdata indication */
tsp_uderror_ind, /* T_UDERROR_IND 21 - unitdata error indication */
tsp_optmgmt_ack, /* T_OPTMGMT_ACK 22 - options management acknowledgement */
tsp_ordrel_ind, /* T_ORDREL_IND 23 - orderly release indication */
NULL, /* T_OPTDATA_REQ 24 - data with options request */
NULL, /* T_ADDR_REQ 25 - address request */
tsp_optdata_ind, /* T_OPTDATA_IND 26 - data with options indication */
tsp_addr_ack /* T_ADDR_ACK 27 - address acknowledgement */
#define TSP_USTR_LAST T_ADDR_ACK
};
/*
* =========================================================================
*
* M_DATA Processing
*
* =========================================================================
*/
int tsp_r_data(queue_t * q, mblk_t * msg)
{
(void) q;
(void) msg;
return (-EOPNOTSUPP);
}
/*
* =========================================================================
*
* M_PROTO, M_PCPROTO Processing
*
* =========================================================================
*/
int tsp_r_proto(queue_t * q, mblk_t * msg)
{
int prim = *((t_scalar_t *) msg->b_rptr);
if (0 <= prim && prim < sizeof(tsp_prim) / sizeof(int (*)(void)) && tsp_prim[prim])
return ((*tsp_prim[prim]) (q, msg));
return (-EOPNOTSUPP);
}
/*
* =========================================================================
*
* M_CTL Processing
*
* =========================================================================
*/
int tsp_r_ctl(queue_t * q, mblk_t * msg)
{
(void) q;
(void) msg;
return (-EOPNOTSUPP);
}
/*
* =========================================================================
*
* M_ERROR Processing
*
* =========================================================================
* This transport stream is toast. We have to inform management that this
* transport stream (with this muxid) has errored out. We need to inform the
* AS or SG that this SGP or ASP is dead and let the AS or SG recalculate the
* state of the AS(s) associated with this transport stream.
*/
int tsp_r_error(queue_t * q, mblk_t * msg)
{
int err;
sp_t *sp = ((lp_t *) q->q_ptr)->u.sp;
switch (msg->b_wptr - msg->b_rptr) {
case 1:
sp->r_error = msg->b_rptr[0];
sp->w_error = msg->b_rptr[0];
break;
case 2:
sp->r_error = msg->b_rptr[0];
sp->w_error = msg->b_rptr[1];
break;
}
if ((err = m_link_ind(q, msg)))
return (err);
if ((err = ua_sp_down(q)))
return (err);
qdisable(q);
return (0);
}
/*
* =========================================================================
*
* M_HANGUP Processing
*
* =========================================================================
*/
int tsp_r_hangup(queue_t * q, mblk_t * msg)
{
int err;
sp_t *sp = ((lp_t *) q->q_ptr)->u.sp;
sp->r_error = 0;
sp->w_error = 0;
if ((err = m_link_ind(q, msg)))
return (err);
if ((err = ua_sp_down(q)))
return (err);
qdisable(q);
return (0);
}
|
|||||||||||||||||||||||||||
|
OpenSS7 SS7 for the Common Man |
Home | Overview | Status | News | Documentation | Resources | About | ||||||||||||||||||||
|
© Copyright 1997-2004,OpenSS7 Corporation, All Rights Reserved. |
|||||||||||||||||||||||||||