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/m2ua/m2ua_sm.c


File /code/strss7/drivers/m2ua/m2ua_sm.c



static char const ident[] = "$Name:  $($Revision: 0.8.2.1 $) $Date: 2002/10/18 03:28:38 $";

/*
 *  =========================================================================
 *
 *  STATE MACHINE FUNCTIONS
 *
 *  =========================================================================
 *  These are some state machine functions which are rather complicated and
 *  need to be called from several places.  These include state transitioning
 *  for ASPs.
 */
/*
 *  AS State Recalc
 *  -------------------------------------------------------------------------
 *  An ASP has changed its state in this AS, so we need to recalculate the
 *  current state of the AS and take appropriate actions.
 */
static void m2_as_state_recalc(const as_t * as)
{
	gp_t *gp;
	uint as_state = AS_STATE_DOWN;
	uint asps_ac = 0;
	uint asps_ia = 0;
	uint asps_dn = 0;
	for (gp = as->list; gp; gp = gp->m2ua_next) {
		switch (gp->m2ua->state) {
		case ASP_STATE_DOWN:
			asps_dn++;
			break;
		case ASP_STATE_INACTIVE:
			asps_ia++;
			if (as_state == AS_STATE_DOWN)
				as_state = AS_STATE_INACTIVE;
			break;
		case ASP_STATE_ACTIVE:
			asps_ac++;
			as_state = AS_STATE_ACTIVE;
			break;
		}
	}
	if (as_state == AS_STATE_ACTIVE && asps_ac < sp->min_num_asps) {
		/* we don't have enough active asps */
		as_state = AS_STATE_INACTIVE;
		if (as->state == AS_STATE_ACTIVE) {
			/* need to send notify to all inactive ASPs */
			mblk_t *mp = msg_ntfy(M2UA_STATUS_AS_RESOURCE, as->iid);
			for (gp = as->list; gp; gp = gp->m2ua_next)
				if (gp->m2ua->state == ASP_STATE_INACTIVE)
					putq(WR(asp->q), dupmsg(mp));
			freemsg(mp);
		}
	}
	if (as->state == AS_STATE_ACTIVE && as_state != AS_STATE_ACTIVE) {
		/* we need to push this ASP to the pending state */
		as_state = AS_STATE_PENDING;
		/* 
		 *  FIXME: set pending timer for this AS so that messages will
		 *  only be collected for a time.
		 */
	}
	as->state = as_state;
	as->asps_ac = asps_ac;
	as->asps_ia = asps_ia;
	as->asps_dn = asps_dn;
	return;
}

/*
 *  ASP State Recalc
 *  -------------------------------------------------------------------------
 *  An ASP has changed state so we need to recalculate the current state of
 *  all of the AS of which the ASP is a part.
 */
static void m2_asp_state_recalc(const asp_t * asp)
{
	gp_t *gp;
	/* for each of the AS which own this ASP */
	for (gp = asp->list; gp; gp = gp->node_next)
		m2_as_state_recalc(gp->node);
	return;
}

/*
 *  SSP goes INACTIVE/DOWN within an SP
 *  -------------------------------------------------------------------------
 *  An ASP/SGP/SPP has transitioned to the inactive (or down) state from the
 *  active state within an AS/SG/SP.  We must see what effect this has on the
 *  caching of data routing and on the overall state of the AS.
 */
static void m2_sp_spp_inactive(const sp_t * spp, const sp_t * sp)
{
	uint old_state = sp->state;
	switch (sp->tmode) {
	case M2UA_TMODE_OVERRIDE:
		switch (sp->state) {
		case AS_STATE_DOWN:
		case AS_STATE_ACTIVE:
		case AS_STATE_INACTIVE:
		case AS_STATE_PENDING:
		}
	case M2UA_TMODE_LOADSHARE:
		switch (sp->state) {
		case AS_STATE_DOWN:
		case AS_STATE_ACTIVE:
		case AS_STATE_INACTIVE:
		case AS_STATE_PENDING:
		}
	case M2UA_TMODE_BROADCAST:
		switch (sp->state) {
		case AS_STATE_DOWN:
		case AS_STATE_ACTIVE:
		case AS_STATE_INACTIVE:
		case AS_STATE_PENDING:
		}
	}
	/* inform all ASPs of any state changes */
	if (old_state != sp->state) {
		mblk_t *mp;
		uint status;
		switch (sp->state) {
		case AS_STATE_DOWN:
			status = M2UA_STATUS_AS_DOWN;
			break;
		case AS_STATE_ACTIVE:
			status = M2UA_STATUS_AS_ACTIVE;
			break;
		case AS_STATE_INACTIVE:
			status = M2UA_STATUS_AS_INACTIVE;
			break;
		case AS_STATE_PENDING:
			status = M2UA_STATUS_AS_PENDING;
			break;
		}
		for (gp = spp->list; gp; gp = gp->node_next) {
	sl_t *}}
	return;
}

/*
 *  SSP goes ACTIVE within an SP
 *  -------------------------------------------------------------------------
 *  An ASP/SGP/SPP has transitioned to the active state from the inactive (or
 *  down) state within an AS/SG/SP.  We must see what effect this has on the
 *  caching of data routing and on the overall state of the AS.
 */
static void m2_sp_spp_active(const sp_t * spp, const sp_t * sp)
{
	switch (sp->tmode) {
	case M2UA_TMODE_OVERRIDE:
		switch (sp->state) {
		case M2UA_AS_DOWN:
		case M2UA_AS_ACTIVE:
		case M2UA_AS_INACTIVE:
		case M2UA_AS_PENDING:
		}
	case M2UA_TMODE_LOADSHARE:
		switch (sp->state) {
		case M2UA_AS_DOWN:
		case M2UA_AS_ACTIVE:
		case M2UA_AS_INACTIVE:
		case M2UA_AS_PENDING:
		}
	case M2UA_TMODE_BROADCAST:
		switch (sp->state) {
		case M2UA_AS_DOWN:
		case M2UA_AS_ACTIVE:
		case M2UA_AS_INACTIVE:
		case M2UA_AS_PENDING:
		}
	}
	return;
}

/*
 *  SPP DOWN
 *  -------------------------------------------------------------------------
 *  This includes all of the actions require to transition an SPP to the down
 *  state from the current state at the serving SP.  For example, this
 *  includes all of the actions necessary to transition an ASP to the down
 *  state at an SG.
 */
static void m2_spp_down(const queue_t * q)
{
	sp_t *m2p = ((nsp_t *) q->q_ptr)->m2ua;
	uint old_state = m2p->state;
	m2p->state = ASP_STATE_DOWN;

	if (m2p->state == ASP_STATE_DOWN)
		return;

	/* inform management that an ASP has gone down */

	m2_asp_state_recalc(m2p);

	switch (m2p->state) {
	case M2UA_ASP_DOWN:
		/* already in down state: nothing to do */
		return;
	case M2UA_ASP_INACTIVE:
		m2_asp_state_recalc(m2p->node);
		/* trivial, just transition the state and inform management */
		break;
	case M2UA_ASP_ACTIVE:
		/* we must inform all owning SP of the loss of an active SPP */
	{
		sp_t *sp;
	}
		break;
	}
	m2p->state = M2UA_ASP_DOWN;
	return;
}

/*
 *  SPP UP
 *  -------------------------------------------------------------------------
 *  This includes all of the actions necessary to transition an SPP to the up
 *  state from the current state at the serving SP (with the exception of
 *  sending peer pdus).
 */
static void m2_spp_up(const queue_t * q)
{
	sp_t *m2p = ((nsp_t *) q->q_ptr)->m2ua;
	sp_t *spp = m2p->list;
}

/*
 *  SPP ACTIVE
 *  -------------------------------------------------------------------------
 *  This includes all of the actions necessary to transition an SPP to the
 *  active state from the current state at the serving SP (with the exception
 *  of sending peer pdus).
 */
static void m2_spp_active(const queue_t * q)
{
	sp_t *m2p = ((nsp_t *) q->q_ptr)->m2ua;
	sp_t *spp = m2p->list;
}

/*
 *  SPP INACTIVE
 *  -------------------------------------------------------------------------
 *  This includes all of the actions necessary to transition an SPP to the
 *  inactive state from the current state at the serving SP (with the
 *  exception of sending peer pdus).
 */
static void m2_spp_inactive(const queue_t * q)
{
	sp_t *m2p = ((nsp_t *) q->q_ptr)->m2ua;
	sp_t *spp = m2p->list;
}


Home Index Prev Next More Download Info FAQ Mail   Home -> Resources -> Browse Source -> strss7/drivers/m2ua/m2ua_sm.c

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

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