void handle_sng_alarm(sng_alrm_t t_alarm)
{

    switch (t_alarm.entity) {
    /**************************************************************************/
    case (ENTL1):
        ftdm_log(FTDM_LOG_WARNING,"[SNG-MTP1] %s : %s : %s \n",
                                    DECODE_LL1_EVENT(t_alarm.event),
                                    DECODE_LL1_CAUSE(t_alarm.cause),
                                    DECODE_LL1_PARM(t_alarm.eventParm[0]));
        break;
    /**************************************************************************/
    case (ENTSD):
        ftdm_log(FTDM_LOG_WARNING,"[SNG-MTP2] %s : %s \n",
                                    DECODE_LSD_EVENT(t_alarm.event),
                                    DECODE_LSD_CAUSE(t_alarm.cause));
        break;
    /**************************************************************************/
    case (ENTSN):
        ftdm_log(FTDM_LOG_WARNING,"[SNG-MTP3] %s on %d: %s \n",
                                    DECODE_LSN_EVENT(t_alarm.event),
                                    t_alarm.id,
                                    DECODE_LSN_CAUSE(t_alarm.cause));
        break;
    /**************************************************************************/
    case (ENTSI):
        handle_entsi_alarm(t_alarm);
        break;
    /**************************************************************************/
    case (ENTCC):
        ftdm_log(FTDM_LOG_DEBUG,"[SNG-CC] %s : %s \n",
                                    DECODE_LCC_EVENT(t_alarm.event),
                                    DECODE_LCC_CAUSE(t_alarm.cause));
        break;
    /**************************************************************************/
    default:
        ftdm_log(FTDM_LOG_WARNING,"Received alarm from unknown entity");
        break;
    /**************************************************************************/
    } /* switch (t_alarm.entity) */

    return;
}
void handle_sng_mtp2_alarm(Pst *pst, SdMngmt *sta)
{
	char	buf[50];
	int		x = 1;

	memset(buf, '\0', sizeof(buf));

	switch (sta->t.usta.alarm.category) {
	/**************************************************************************/
	case (LCM_CATEGORY_PROTOCOL):
	case (LCM_CATEGORY_INTERFACE):

		switch (sta->t.usta.alarm.event) {
		/**********************************************************************/
		case (LSD_EVENT_ENTR_CONG):
		case (LSD_EVENT_EXIT_CONG):
		case (LSD_EVENT_PROT_ST_UP):
		case (LSD_EVENT_PROT_ST_DN):
		case (LSD_EVENT_LINK_ALIGNED):
		case (LSD_EVENT_REMOTE_CONG_START):
		case (LSD_EVENT_REMOTE_CONG_END):
		case (LSD_EVENT_RX_REMOTE_SIPO):

			/* find the name for the sap in question */
			x = 1;
			while (x < (MAX_MTP_LINKS+1)) {
				if (g_ftdm_sngss7_data.cfg.mtp2Link[x].id == sta->t.usta.evntParm[0]) {
					break;
				}
				x++;
			}

			if (g_ftdm_sngss7_data.cfg.mtp2Link[x].id == 0) {
				sprintf(buf, "[SAPID:%d]", sta->t.usta.evntParm[0]);
			} else {
				sprintf(buf, "[%s]", g_ftdm_sngss7_data.cfg.mtp2Link[x].name);
			}
					

			switch (sta->t.usta.alarm.cause) {
				case (LCM_CAUSE_MGMT_INITIATED):
					ftdm_log(FTDM_LOG_DEBUG,"[MTP2]%s[MGMT] cause:%s event:%s\n",
												buf,
												DECODE_LCM_CAUSE(sta->t.usta.alarm.cause),
												DECODE_LSD_EVENT(sta->t.usta.alarm.event));
					break;			
				case (LCM_CAUSE_UNKNOWN):
				default:
						ftdm_log(FTDM_LOG_DEBUG,"[MTP2]%s cause:%s event:%s\n",
								buf,
								DECODE_LCM_CAUSE(sta->t.usta.alarm.cause),
								DECODE_LSD_EVENT(sta->t.usta.alarm.event));
						break;
			/******************************************************************/
			} /* switch (sta->t.usta.alarm.cause) */
			break;
		/**********************************************************************/
		case (LSD_EVENT_PROT_ERR):
			
			/* find the name for the sap in question */
			x = 1;
			while (x < (MAX_MTP_LINKS+1)) {
				if (g_ftdm_sngss7_data.cfg.mtp2Link[x].id == sta->t.usta.evntParm[0]) {
					break;
				}
				x++;
			}

			if (g_ftdm_sngss7_data.cfg.mtp2Link[x].id == 0) {
				sprintf(buf, "[SAPID:%d]", sta->t.usta.evntParm[0]);
			} else {
				sprintf(buf, "[%s]", g_ftdm_sngss7_data.cfg.mtp2Link[x].name);
			}

			ftdm_log(FTDM_LOG_ERROR,"[MTP2]%s %s : %s\n",
										buf,
										DECODE_LSD_EVENT(sta->t.usta.alarm.event),
										DECODE_LSD_CAUSE(sta->t.usta.alarm.cause));
			break;
		/**********************************************************************/
		case (LSD_EVENT_ALIGN_LOST):
			
			/* find the name for the sap in question */
			x = 1;
			while (x < (MAX_MTP_LINKS+1)) {
				if (g_ftdm_sngss7_data.cfg.mtp2Link[x].id == sta->t.usta.evntParm[0]) {
					break;
				}
				x++;
			}

			if (g_ftdm_sngss7_data.cfg.mtp2Link[x].id == 0) {
				sprintf(buf, "[SAPID:%d]", sta->t.usta.evntParm[0]);
			} else {
				sprintf(buf, "[%s]", g_ftdm_sngss7_data.cfg.mtp2Link[x].name);
			}

			ftdm_log(FTDM_LOG_DEBUG,"[MTP2]%s %s : %s\n",
										buf,
										DECODE_LSD_EVENT(sta->t.usta.alarm.event),
										DECODE_DISC_REASON(sta->t.usta.evntParm[1]));
			break;
		/**********************************************************************/
		case (LSD_EVENT_RTB_FULL):
		case (LSD_EVENT_RTB_FULL_OVER):

			/* find the name for the sap in question */
			x = 1;
			while (x < (MAX_MTP_LINKS+1)) {
				if (g_ftdm_sngss7_data.cfg.mtp2Link[x].id == sta->t.usta.evntParm[0]) {
					break;
				}
				x++;
			}

			if (g_ftdm_sngss7_data.cfg.mtp2Link[x].id == 0) {
				sprintf(buf, "[SAPID:%d]", sta->t.usta.evntParm[0]);
			} else {
				sprintf(buf, "[%s]", g_ftdm_sngss7_data.cfg.mtp2Link[x].name);
			}

			ftdm_log(FTDM_LOG_ERROR,"[MTP2]%s %s : RTB Queue Len(%d)|Oldest BSN(%d)|Tx Queue Len(%d)|Outstanding Frames(%d)\n",
										buf,
										DECODE_LSD_EVENT(sta->t.usta.alarm.event),
										sta->t.usta.evntParm[1],
										sta->t.usta.evntParm[2],
										sta->t.usta.evntParm[3],
										sta->t.usta.evntParm[4]);
			break;
		/**********************************************************************/
		case (LSD_EVENT_NEG_ACK):

			/* find the name for the sap in question */
			x = 1;
			while (x < (MAX_MTP_LINKS+1)) {
				if (g_ftdm_sngss7_data.cfg.mtp2Link[x].id == sta->t.usta.evntParm[0]) {
					break;
				}
				x++;
			}

			if (g_ftdm_sngss7_data.cfg.mtp2Link[x].id == 0) {
				sprintf(buf, "[SAPID:%d]", sta->t.usta.evntParm[0]);
			} else {
				sprintf(buf, "[%s]", g_ftdm_sngss7_data.cfg.mtp2Link[x].name);
			}

			ftdm_log(FTDM_LOG_ERROR,"[MTP2]%s %s : RTB Queue Len(%d)\n",
										buf,
										DECODE_LSD_EVENT(sta->t.usta.alarm.event),
										sta->t.usta.evntParm[1]);
			break;
		/**********************************************************************/
		case (LSD_EVENT_DAT_CFM_SDT):

			/* find the name for the sap in question */
			x = 1;
			while (x < (MAX_MTP_LINKS+1)) {
				if (g_ftdm_sngss7_data.cfg.mtp2Link[x].id == sta->t.usta.evntParm[0]) {
					break;
				}
				x++;
			}

			if (g_ftdm_sngss7_data.cfg.mtp2Link[x].id == 0) {
				sprintf(buf, "[SAPID:%d]", sta->t.usta.evntParm[0]);
			} else {
				sprintf(buf, "[%s]", g_ftdm_sngss7_data.cfg.mtp2Link[x].name);
			}

			ftdm_log(FTDM_LOG_ERROR,"[MTP2]%s %s : %s\n",
										buf,
										DECODE_LSD_EVENT(sta->t.usta.alarm.event),
										DECODE_DISC_REASON(sta->t.usta.evntParm[1]));
			break;
		/**********************************************************************/
		case (LCM_EVENT_UI_INV_EVT):
		case (LCM_EVENT_LI_INV_EVT):
			ftdm_log(FTDM_LOG_ERROR,"[MTP2] %s(%d) : %s(%d) : Primitive (%d)\n",
										DECODE_LSD_EVENT(sta->t.usta.alarm.event),
										sta->t.usta.alarm.event,
										DECODE_LCM_CAUSE(sta->t.usta.alarm.cause),
										sta->t.usta.alarm.cause,
										sta->t.usta.evntParm[0]);
			break;
		/**********************************************************************/
		case (LCM_EVENT_INV_EVT):

			switch (sta->t.usta.alarm.cause) {
			/******************************************************************/
			case (LCM_CAUSE_UNKNOWN):
			case (LCM_CAUSE_SWVER_NAVAIL):
				ftdm_log(FTDM_LOG_ERROR,"[MTP2] %s : %s : Event (%d)\n",
											DECODE_LSD_EVENT(sta->t.usta.alarm.event),
											DECODE_LCM_CAUSE(sta->t.usta.alarm.cause),
											sta->t.usta.evntParm[0]);
				break;
			/******************************************************************/
			case (LCM_CAUSE_DECODE_ERR):
				ftdm_log(FTDM_LOG_ERROR,"[MTP2] %s : %s : Primitive (%d)|Version (%d)\n",
											DECODE_LSD_EVENT(sta->t.usta.alarm.event),
											DECODE_LCM_CAUSE(sta->t.usta.alarm.cause),
											sta->t.usta.evntParm[0],
											sta->t.usta.evntParm[1]);
				break;
			/******************************************************************/
			default:
				ftdm_log(FTDM_LOG_ERROR,"[MTP2] %s(%d) : %s(%d)\n",
											DECODE_LSD_EVENT(sta->t.usta.alarm.event),
											sta->t.usta.alarm.event,
											DECODE_LSD_CAUSE(sta->t.usta.alarm.cause),
											sta->t.usta.alarm.cause);
				break;
			/******************************************************************/
			} /* switch (sta->t.usta.alarm.cause) */
			break;
		/**********************************************************************/
		default:
			ftdm_log(FTDM_LOG_ERROR,"[MTP2] %s(%d) : %s(%d)\n",
										DECODE_LSD_EVENT(sta->t.usta.alarm.event),
										sta->t.usta.alarm.event,
										DECODE_LSD_CAUSE(sta->t.usta.alarm.cause),
										sta->t.usta.alarm.cause);
			break;
		/**********************************************************************/
		} /* switch (sta->t.usta.alarm.event) */
		break;
	/**************************************************************************/
	default:
		ftdm_log(FTDM_LOG_ERROR,"[MTP2] Unknown alarm category %d\n",
									sta->t.usta.alarm.category);
		break;
	/**************************************************************************/
	} /* switch(sta->t.usta.alarm.category) */

	return;
}   /* handle_mtp2_alarm */