OpenSS7
SS7 for the
Common Man

© Copyright 1997-2004,OpenSS7 Corporation, All Rights Reserved.
Last modified:

Home Overview Status News Documentation Resources About
   
 Overview
 Status
 News
 Documentation
 Resources
 About

   
Home Index Prev Next More Download Info FAQ Mail   Home -> Resources -> Browse Source -> strss7/drivers/tcap/tcap_ctrl.h


File /code/strss7/drivers/tcap/tcap_ctrl.h



#ifndef __TCAP_CTRL_H__
#define __TCAP_CTRL_H__

#ident "@(#) $RCSfile: tcap_ctrl.h,v $ $Name:  $($Revision: 0.8.2.1 $) $Date: 2002/10/18 02:29:52 $"

/*
 *  =========================================================================
 *
 *  Module --> Module (Control Messages)
 *
 *  =========================================================================
 */

static inline mblk_t *m_error(int r_error, int w_error)
{
	mblk_t *mp;
	if ((mp = allocb(2, BPRI_HI))) {
		mp->b_datap->db_type = M_ERROR;
		*(mp->b_wptr)++ = r_error;
		*(mp->b_wptr)++ = w_error;
	}
	return (mp);
}
static inline mblk_t *m_hangup(void)
{
	mblk_t *mp;
	if ((mp = allocb(0, BPRI_HI))) {
		mp->b_datap->db_type = M_HANGUP;
	}
	return (mp);
}
static inline mblk_t *m_flush(int flags, int band)
{
	mblk_t *mp;
	if ((mp = allocb(2, BPRI_HI))) {
		mp->b_datap->db_type = M_FLUSH;
		*(mp->b_wptr)++ = flags;
		*(mp->b_wptr)++ = band;
	}
	return (mp);
}
static inline int m_error_reply(queue_t * q, mblk_t * pdu, int r_error, int w_error)
{
	mblk_t *mp;
	if ((mp = m_error(r_error, w_error))) {
		qreply(q, mp);
		return (-EPROTO);
	}
	return (-ENOBUFS);
}
static inline int m_error_all(queue_t * q, mblk_t * pdu, int r_error, int w_error)
{
	int err = 0;
	mblk_t *mp;
	tcap_t *tcap;
	sccp_t *sccp = (sccp_t *) q->q_ptr;
	mp = m_error(r_error, w_error);
	for (tcap = sccp->tcap; tcap; tcap = tcap->sccp_next) {
		mblk_t *dp;
		tcap->state = TRS_NOSTATES;
		tcap->r_error = r_error;
		tcap->w_error = w_error;
		tcap->sccp = NULL;
		tcap->sccp_next = NULL;
		tcap->sccp_prev = NULL;
		if (!mp || !(dp = dupmsg(mp)))
			err = -ENOBUFS;
		else
			putnext(tcap->q, dp);
	}
	sccp->state = TRS_NOSTATES;
	sccp->r_error = r_error;
	sccp->w_error = w_error;
	sccp->tcap = NULL;
	sccp->use_count = 0;
	if (mp)
		freemsg(mp);
	if (!err && pdu)
		freemsg(pdu);
	return (err);
}
static inline int m_hangup_all(queue_t * q, mblk_t * pdu)
{
	int err = 0;
	mblk_t *mp;
	tcap_t *tcap;
	sccp_t *sccp = (sccp_t *) q->q_ptr;
	mp = m_hangup();
	for (tcap = sccp->tcap; tcap; tcap = tcap->sccp_next) {
		mblk_t *dp;
		tcap->state = TRS_NOSTATES;
		tcap->r_error = 0;
		tcap->w_error = 0;
		tcap->sccp = NULL;
		tcap->sccp_next = NULL;
		tcap->sccp_prev = NULL;
		if (!mp || !(dp = dupmsg(mp)))
			err = -ENOBUFS;
		else
			putnext(tcap->q, dp);
	}
	sccp->state = TRS_NOSTATES;
	sccp->r_error = 0;
	sccp->w_error = 0;
	sccp->tcap = NULL;
	sccp->use_count = 0;
	if (mp)
		freemsg(mp);
	if (!err && pdu)
		freemsg(pdu);
	return (err);
}
static inline int m_flush_all(queue_t * q, mblk_t * pdu, int flags, int band)
{
	int err = 0;
	mblk_t *mp;
	tcap_t *tcap;
	sccp_t *sccp = (sccp_t *) q->q_ptr;
	mp = m_flush(flags, band);
	for (tcap = sccp->tcap; tcap; tcap = tcap->sccp_next) {
		mblk_t *dp;
		if (!mp || !(dp = dupmsg(mp)))
			err = -ENOBUFS;
		else
			putnext(tcap->q, dp);
	}
	if (mp)
		freemsg(mp);
	if (!err && pdu)
		freemsg(pdu);
	return (err);
}

#endif				/* __TCAP_CTRL_H__ */


Home Index Prev Next More Download Info FAQ Mail   Home -> Resources -> Browse Source -> strss7/drivers/tcap/tcap_ctrl.h

OpenSS7
SS7 for the
Common Man
Home Overview Status News Documentation Resources About

© Copyright 1997-2004,OpenSS7 Corporation, All Rights Reserved.
Last modified: