void sngisdn_rcv_q921_ind(BdMngmt *status)
{	
	ftdm_span_t *ftdmspan;

	sngisdn_span_data_t	*signal_data = g_sngisdn_data.dchans[status->t.usta.lnkNmb].spans[1];
	
	if (!signal_data) {
		ftdm_log(FTDM_LOG_INFO, "Received q921 status on unconfigured span (lnkNmb:%d)\n", status->t.usta.lnkNmb);
		return;
	}
	ftdmspan = signal_data->ftdm_span;

	if (!ftdmspan) {
		ftdm_log(FTDM_LOG_INFO, "Received q921 status on unconfigured span (lnkNmb:%d)\n", status->t.usta.lnkNmb);
		return;
	}

	switch (status->t.usta.alarm.category) {
		case (LCM_CATEGORY_PROTOCOL):
			ftdm_log(FTDM_LOG_DEBUG, "[SNGISDN Q921] %s: %s: %s(%d): %s(%d)\n",
						ftdmspan->name,
						DECODE_LCM_CATEGORY(status->t.usta.alarm.category),
						DECODE_LLD_EVENT(status->t.usta.alarm.event), status->t.usta.alarm.event,
						DECODE_LLD_CAUSE(status->t.usta.alarm.cause), status->t.usta.alarm.cause);

			if (FTDM_SPAN_IS_BRI(ftdmspan) && (status->t.usta.alarm.event == PROT_ST_DN)) {
				/* Q.921 link is down - This is a line where the Q.921 stops transmitting
					after the line goes idle.

					Do not drop current calls, but set sigstatus do down so that we
					can try to re-initialize link before trying new outbound calls */

				sngisdn_set_span_sig_status(ftdmspan, FTDM_SIG_STATE_DOWN);
				sngisdn_set_span_avail_rate(ftdmspan, SNGISDN_AVAIL_PWR_SAVING);
			}
			break;
		default:
			ftdm_log(FTDM_LOG_INFO, "[SNGISDN Q921] %s: %s: %s(%d): %s(%d)\n",
						ftdmspan->name,
						DECODE_LCM_CATEGORY(status->t.usta.alarm.category),
						DECODE_LLD_EVENT(status->t.usta.alarm.event), status->t.usta.alarm.event,
						DECODE_LLD_CAUSE(status->t.usta.alarm.cause), status->t.usta.alarm.cause);
			
			switch (status->t.usta.alarm.event) {
				case ENTR_CONG: /* Entering Congestion */
					ftdm_log(FTDM_LOG_WARNING, "s%d: Entering Congestion\n", ftdmspan->span_id);
					ftdm_set_flag(ftdmspan, FTDM_SPAN_SUSPENDED);
					break;
				case EXIT_CONG: /* Exiting Congestion */
					ftdm_log(FTDM_LOG_WARNING, "s%d: Exiting Congestion\n", ftdmspan->span_id);
					ftdm_clear_flag(ftdmspan, FTDM_SPAN_SUSPENDED);
					break;
			}
			break;
	}
    return;
}
void sngisdn_rcv_q931_ind(InMngmt *status)
{	
	if (status->t.usta.alarm.cause == 287) {
		get_memory_info();
		return;
	}

	switch (status->t.usta.alarm.event) {
		case LCM_EVENT_UP:
		case LCM_EVENT_DOWN:
		{
			ftdm_span_t *ftdmspan;
			sngisdn_span_data_t	*signal_data = g_sngisdn_data.dchans[status->t.usta.suId].spans[1];
			if (!signal_data) {
				ftdm_log(FTDM_LOG_INFO, "Received q931 status on unconfigured span (lnkNmb:%d)\n", status->t.usta.suId);
				return;
			}
			ftdmspan = signal_data->ftdm_span;
			
			if (status->t.usta.alarm.event == LCM_EVENT_UP) {
				uint32_t chan_no = status->t.usta.evntParm[2];
				ftdm_log(FTDM_LOG_INFO, "[SNGISDN Q931] s%d: %s: %s(%d): %s(%d)\n",
						 status->t.usta.suId,
								DECODE_LCM_CATEGORY(status->t.usta.alarm.category),
								DECODE_LCM_EVENT(status->t.usta.alarm.event), status->t.usta.alarm.event,
								DECODE_LCM_CAUSE(status->t.usta.alarm.cause), status->t.usta.alarm.cause);

				if (chan_no) {
					ftdm_channel_t *ftdmchan = ftdm_span_get_channel(ftdmspan, chan_no);
					if (ftdmchan) {
						sngisdn_set_chan_sig_status(ftdmchan, FTDM_SIG_STATE_UP);
						sngisdn_set_chan_avail_rate(ftdmchan, SNGISDN_AVAIL_UP);
					} else {
						ftdm_log(FTDM_LOG_CRIT, "stack alarm event on invalid channel :%d\n", chan_no);
					}
				} else {
					sngisdn_set_span_sig_status(ftdmspan, FTDM_SIG_STATE_UP);
					sngisdn_set_span_avail_rate(ftdmspan, SNGISDN_AVAIL_UP);
				}
			} else {
				ftdm_log(FTDM_LOG_WARNING, "[SNGISDN Q931] s%d: %s: %s(%d): %s(%d)\n",
						 		status->t.usta.suId,
								DECODE_LCM_CATEGORY(status->t.usta.alarm.category),
								DECODE_LCM_EVENT(status->t.usta.alarm.event), status->t.usta.alarm.event,
								DECODE_LCM_CAUSE(status->t.usta.alarm.cause), status->t.usta.alarm.cause);
				
				sngisdn_set_span_sig_status(ftdmspan, FTDM_SIG_STATE_DOWN);
				sngisdn_set_span_avail_rate(ftdmspan, SNGISDN_AVAIL_PWR_SAVING);
			}
		}
		break;
		default:
			ftdm_log(FTDM_LOG_WARNING, "[SNGISDN Q931] s%d: %s: %s(%d): %s(%d)\n",
					 						status->t.usta.suId,
	  										DECODE_LCM_CATEGORY(status->t.usta.alarm.category),
						  					DECODE_LCM_EVENT(status->t.usta.alarm.event), status->t.usta.alarm.event,
											DECODE_LCM_CAUSE(status->t.usta.alarm.cause), status->t.usta.alarm.cause);
	}
	
	ISDN_FUNC_TRACE_EXIT(__FUNCTION__);
	return;
}