From 7b97ff470f21c7e2afcacfce16767acdf602120f Mon Sep 17 00:00:00 2001 From: kapil Date: Wed, 20 Jun 2012 13:53:51 +0530 Subject: [PATCH] adding "xmlshow m2ua clusterstatus" CLI command. --- .../ftmod_sangoma_ss7/ftmod_sangoma_ss7_cli.c | 142 ++++++++++++++---- .../ftmod_sangoma_ss7_m2ua.c | 24 ++- 2 files changed, 134 insertions(+), 32 deletions(-) diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_cli.c b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_cli.c index 594fdb97ad..1adf6dd607 100644 --- a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_cli.c +++ b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_cli.c @@ -124,6 +124,7 @@ static ftdm_status_t handle_show_sctp_profile(ftdm_stream_handle_t *stream, char static ftdm_status_t handle_show_m2ua_profiles(ftdm_stream_handle_t *stream); static ftdm_status_t handle_show_m2ua_profile(ftdm_stream_handle_t *stream, char* m2ua_profile_name); static ftdm_status_t handle_show_m2ua_peer_status(ftdm_stream_handle_t *stream, char* m2ua_profile_name); +static ftdm_status_t handle_show_m2ua_cluster_status(ftdm_stream_handle_t *stream, char* m2ua_profile_name); static ftdm_status_t handle_show_nif_profiles(ftdm_stream_handle_t *stream); static ftdm_status_t handle_show_nif_profile(ftdm_stream_handle_t *stream, char* profile_name); int get_assoc_resp_buf(char* buf,SbMgmt* cfm); @@ -427,10 +428,17 @@ ftdm_status_t ftdm_sngss7_handle_cli_cmd(ftdm_stream_handle_t *stream, const cha { char* profile_name = argv[++c]; c++; + /***************************************************************/ if(!strcasecmp(argv[c],"peerstatus")){ + /***************************************************************/ handle_show_m2ua_peer_status(stream, profile_name); - } - else{ + /***************************************************************/ + }else if(!strcasecmp(argv[c],"clusterstatus")){ + /***************************************************************/ + handle_show_m2ua_cluster_status(stream, profile_name); + /***************************************************************/ + } else{ + /***************************************************************/ stream->write_function(stream, "Unknown \"show m2ua \" command..\n"); goto handle_cli_error_argc; } @@ -933,6 +941,7 @@ static ftdm_status_t handle_print_usage(ftdm_stream_handle_t *stream) stream->write_function(stream, "ftdm ss7 xmlshow m2ua \n"); stream->write_function(stream, "ftdm ss7 xmlshow m2ua \n"); stream->write_function(stream, "ftdm ss7 xmlshow m2ua peerstatus\n"); + stream->write_function(stream, "ftdm ss7 xmlshow m2ua clusterstatus\n"); stream->write_function(stream, "ftdm ss7 xmlshow nif \n"); stream->write_function(stream, "ftdm ss7 xmlshow nif \n"); stream->write_function(stream, "\n"); @@ -3086,7 +3095,7 @@ static ftdm_status_t handle_show_m2ua_profiles(ftdm_stream_handle_t *stream) len = len + sprintf(buf + len, "\n"); if(ftmod_m2ua_ssta_req(STMWGEN, 0x00, &cfm)) { - stream->write_function(stream," Request to Trillium M2UA layer failed \n"); + stream->write_function(stream," Request to layer failed \n"); return FTDM_FAIL; } else { len = len + sprintf(buf + len, "\n"); @@ -3115,7 +3124,7 @@ static ftdm_status_t handle_show_m2ua_profiles(ftdm_stream_handle_t *stream) len = len + sprintf(buf + len, " %s \n", g_ftdm_sngss7_data.cfg.g_m2ua_cfg.m2ua[x].name); if(ftmod_m2ua_ssta_req(STMWDLSAP,x,&cfm)) { - stream->write_function(stream," Request to Trillium SCTP layer failed \n"); + stream->write_function(stream," Request to M2UA layer failed \n"); return FTDM_FAIL; } else { len = len + sprintf(buf + len, "\n"); @@ -3129,7 +3138,7 @@ static ftdm_status_t handle_show_m2ua_profiles(ftdm_stream_handle_t *stream) memset((U8 *)&cfm, 0, sizeof(MwMgmt)); if(ftmod_m2ua_ssta_req(STMWCLUSTER,g_ftdm_sngss7_data.cfg.g_m2ua_cfg.m2ua[x].clusterId,&cfm)) { - stream->write_function(stream," Request to Trillium SCTP layer failed \n"); + stream->write_function(stream," Request to M2UA layer failed \n"); return FTDM_FAIL; } else { len = len + sprintf(buf + len, "\n"); @@ -3160,7 +3169,7 @@ static ftdm_status_t handle_show_m2ua_profiles(ftdm_stream_handle_t *stream) if(LMW_PEER_DOWN != rsp.t.ssta.s.clusterSta.peerSt[idx].peerState){ if(ftmod_m2ua_ssta_req(STMWPEER, peer_id, &cfm)) { - stream->write_function(stream," Request to Trillium SCTP layer failed \n"); + stream->write_function(stream," Request to M2UA layer failed \n"); return FTDM_FAIL; } else { len = len + sprintf(buf + len, "\n"); @@ -3187,7 +3196,7 @@ static ftdm_status_t handle_show_m2ua_profiles(ftdm_stream_handle_t *stream) memset((U8 *)&cfm, 0, sizeof(MwMgmt)); if(ftmod_m2ua_ssta_req(STMWSCTSAP,x,&cfm)) { - stream->write_function(stream," Request to Trillium SCTP layer failed \n"); + stream->write_function(stream," Request to M2UA layer failed \n"); return FTDM_FAIL; } else { len = len + sprintf(buf + len, "\n"); @@ -3206,7 +3215,7 @@ static ftdm_status_t handle_show_m2ua_profiles(ftdm_stream_handle_t *stream) len = len + sprintf(buf + len, "\n"); stream->write_function(stream,"\n%s\n",buf); - return FTDM_FAIL; + return FTDM_SUCCESS; } @@ -3259,7 +3268,7 @@ static ftdm_status_t handle_show_m2ua_profile(ftdm_stream_handle_t *stream, char len = len + sprintf(buf + len, " %s \n", m2ua_profile_name); if(ftmod_m2ua_ssta_req(STMWDLSAP,x,&cfm)) { - stream->write_function(stream," Request to Trillium SCTP layer failed \n"); + stream->write_function(stream," Request to M2UA layer failed \n"); return FTDM_FAIL; } else { len = len + sprintf(buf + len, "\n"); @@ -3272,7 +3281,7 @@ static ftdm_status_t handle_show_m2ua_profile(ftdm_stream_handle_t *stream, char } if(ftmod_m2ua_ssta_req(STMWCLUSTER, g_ftdm_sngss7_data.cfg.g_m2ua_cfg.m2ua[x].clusterId, &cfm)) { - stream->write_function(stream," Request to Trillium SCTP layer failed \n"); + stream->write_function(stream," Request to M2UA layer failed \n"); return FTDM_FAIL; } else { len = len + sprintf(buf + len, "\n"); @@ -3298,7 +3307,7 @@ static ftdm_status_t handle_show_m2ua_profile(ftdm_stream_handle_t *stream, char memset((U8 *)&cfm, 0, sizeof(MwMgmt)); if(ftmod_m2ua_ssta_req(STMWPEER, rsp.t.ssta.s.clusterSta.peerSt[idx].peerId, &cfm)) { - stream->write_function(stream," Request to Trillium SCTP layer failed \n"); + stream->write_function(stream," Request to M2UA layer failed \n"); return FTDM_FAIL; } else { len = len + sprintf(buf + len, "\n"); @@ -3321,7 +3330,7 @@ static ftdm_status_t handle_show_m2ua_profile(ftdm_stream_handle_t *stream, char } if(ftmod_m2ua_ssta_req(STMWSCTSAP,x,&cfm)) { - stream->write_function(stream," Request to Trillium SCTP layer failed \n"); + stream->write_function(stream," Request to M2UA layer failed \n"); return FTDM_FAIL; } else { len = len + sprintf(buf + len, "\n"); @@ -3340,7 +3349,7 @@ static ftdm_status_t handle_show_m2ua_profile(ftdm_stream_handle_t *stream, char stream->write_function(stream,"\n%s\n",buf); - return FTDM_FAIL; + return FTDM_SUCCESS; } @@ -3366,7 +3375,7 @@ static ftdm_status_t handle_show_sctp_profiles(ftdm_stream_handle_t *stream) len = len + sprintf(buf + len, "\n"); if(ftmod_sctp_ssta_req(STSBGEN, 0x00, &cfm)) { - stream->write_function(stream," Request to Trillium SCTP layer failed \n"); + stream->write_function(stream," Request to SCTP layer failed \n"); return FTDM_FAIL; } else { len = len + sprintf(buf + len, "\n"); @@ -3386,7 +3395,7 @@ static ftdm_status_t handle_show_sctp_profiles(ftdm_stream_handle_t *stream) #ifdef LSB12 if(ftmod_sctp_ssta_req(STSBTMR, 0x00, &cfm)) { - stream->write_function(stream," Request to Trillium SCTP layer failed \n"); + stream->write_function(stream," Request to SCTP layer failed \n"); return FTDM_FAIL; } else { len = len + sprintf(buf + len, "\n"); @@ -3418,7 +3427,7 @@ static ftdm_status_t handle_show_sctp_profiles(ftdm_stream_handle_t *stream) len = len + sprintf(buf + len, "\n"); if(ftmod_sctp_ssta_req(STSBSCTSAP,x,&cfm)) { - stream->write_function(stream," Request to Trillium SCTP layer failed \n"); + stream->write_function(stream," Request to SCTP layer failed \n"); return FTDM_FAIL; } else { len = len + sprintf(buf + len, "\n"); @@ -3428,7 +3437,7 @@ static ftdm_status_t handle_show_sctp_profiles(ftdm_stream_handle_t *stream) } if(ftmod_sctp_ssta_req(STSBTSAP,x,&cfm)) { - stream->write_function(stream," Request to Trillium SCTP layer failed \n"); + stream->write_function(stream," Request to SCTP layer failed \n"); return FTDM_FAIL; } else { len = len + sprintf(buf + len, "\n"); @@ -3443,7 +3452,7 @@ static ftdm_status_t handle_show_sctp_profiles(ftdm_stream_handle_t *stream) len = len + sprintf(buf + len, " SCT_ASSOC_STATE_CLOSED \n"); len = len + sprintf(buf + len, "\n"); }else{ - stream->write_function(stream," Request to Trillium SCTP layer failed \n"); + stream->write_function(stream," Request to SCTP layer failed \n"); return FTDM_FAIL; } } else { @@ -3612,7 +3621,7 @@ static ftdm_status_t handle_show_sctp_profile(ftdm_stream_handle_t *stream, char len = len + sprintf(buf + len, "\n"); if(ftmod_sctp_ssta_req(STSBSCTSAP,x,&cfm)) { - stream->write_function(stream," Request to Trillium SCTP layer failed \n"); + stream->write_function(stream," Request to SCTP layer failed \n"); return FTDM_FAIL; } else { len = len + sprintf(buf + len, "\n"); @@ -3622,7 +3631,7 @@ static ftdm_status_t handle_show_sctp_profile(ftdm_stream_handle_t *stream, char } if(ftmod_sctp_ssta_req(STSBTSAP,x,&cfm)) { - stream->write_function(stream," Request to Trillium SCTP layer failed \n"); + stream->write_function(stream," Request to SCTP layer failed \n"); return FTDM_FAIL; } else { len = len + sprintf(buf + len, "\n"); @@ -3638,7 +3647,7 @@ static ftdm_status_t handle_show_sctp_profile(ftdm_stream_handle_t *stream, char len = len + sprintf(buf + len, " SCT_ASSOC_STATE_CLOSED \n"); len = len + sprintf(buf + len, "\n"); }else{ - stream->write_function(stream," Request to Trillium SCTP layer failed \n"); + stream->write_function(stream," Request to SCTP layer failed \n"); return FTDM_FAIL; } } else { @@ -3678,7 +3687,7 @@ static ftdm_status_t handle_show_nif_profiles(ftdm_stream_handle_t *stream) len = len + sprintf(buf + len, "\n"); if(ftmod_nif_ssta_req(STNWGEN, 0x00, &cfm)) { - stream->write_function(stream," Request to Trillium NIF layer failed \n"); + stream->write_function(stream," Request to NIF layer failed \n"); return FTDM_FAIL; } else { len = len + sprintf(buf + len, "\n"); @@ -3701,7 +3710,7 @@ static ftdm_status_t handle_show_nif_profiles(ftdm_stream_handle_t *stream) len = len + sprintf(buf + len, "\n"); if(ftmod_nif_ssta_req(STNWDLSAP,x,&cfm)) { - stream->write_function(stream," Request to Trillium SCTP layer failed \n"); + stream->write_function(stream," Request to NIF layer failed \n"); return FTDM_FAIL; } else { len = len + sprintf(buf + len, "\n"); @@ -3723,7 +3732,7 @@ static ftdm_status_t handle_show_nif_profiles(ftdm_stream_handle_t *stream) len = len + sprintf(buf + len, "\n"); stream->write_function(stream,"\n%s\n",buf); - return FTDM_FAIL; + return FTDM_SUCCESS; } /****************************************************************************** @@ -3770,7 +3779,7 @@ static ftdm_status_t handle_show_nif_profile(ftdm_stream_handle_t *stream, char* len = len + sprintf(buf + len, "\n"); if(ftmod_nif_ssta_req(STNWDLSAP,x,&cfm)) { - stream->write_function(stream," Request to Trillium SCTP layer failed \n"); + stream->write_function(stream," Request to NIF layer failed \n"); return FTDM_FAIL; } else { len = len + sprintf(buf + len, "\n"); @@ -3788,7 +3797,7 @@ static ftdm_status_t handle_show_nif_profile(ftdm_stream_handle_t *stream, char* stream->write_function(stream,"\n%s\n",buf); - return FTDM_FAIL; + return FTDM_SUCCESS; } /******************************************************************************/ @@ -3848,7 +3857,7 @@ static ftdm_status_t handle_show_m2ua_peer_status(ftdm_stream_handle_t *stream, peer = &g_ftdm_sngss7_data.cfg.g_m2ua_cfg.m2ua_peer[peer_id]; if(ftmod_m2ua_ssta_req(STMWPEER, peer_id, &cfm)) { - stream->write_function(stream," Request to Trillium M2UA layer failed \n"); + stream->write_function(stream," Request to M2UA layer failed \n"); return FTDM_FAIL; } else { len = len + sprintf(buf + len, "\n"); @@ -3867,7 +3876,7 @@ static ftdm_status_t handle_show_m2ua_peer_status(ftdm_stream_handle_t *stream, len = len + sprintf(buf + len, " SCT_ASSOC_STATE_CLOSED \n"); len = len + sprintf(buf + len, "\n"); }else{ - stream->write_function(stream," Request to Trillium SCTP layer failed \n"); + stream->write_function(stream," Request to SCTP layer failed \n"); return FTDM_FAIL; } } else { @@ -3879,7 +3888,82 @@ static ftdm_status_t handle_show_m2ua_peer_status(ftdm_stream_handle_t *stream, stream->write_function(stream,"\n%s\n",buf); - return FTDM_FAIL; + return FTDM_SUCCESS; +} + +/****************************************************************************** +* Fun: handle_show_m2ua_cluster_status() +* Desc: display requested m2ua profile cluster information +* Ret: FTDM_SUCCESS | FTDM_FAIL +* Note: +* author: Kapil Gupta +*******************************************************************************/ + +static ftdm_status_t handle_show_m2ua_cluster_status(ftdm_stream_handle_t *stream, char* m2ua_profile_name) +{ + char* xmlhdr = (char*)""; + char buf[4096]; + int x = 0x00; + int found = 0x00; + int len = 0x00; + int idx = 0x00; + MwMgmt cfm; + SbMgmt sctp_cfm; + sng_m2ua_cluster_cfg_t* clust = NULL; + sng_m2ua_cfg_t* m2ua = NULL; + + memset((U8 *)&cfm, 0, sizeof(MwMgmt)); + memset((U8 *)&sctp_cfm, 0, sizeof(SbMgmt)); + memset(&buf[0], 0, sizeof(buf)); + + len = len + sprintf(buf + len, "%s\n", xmlhdr); + + /*iterate through all the m2ua links and get required profile */ + x = 1; + while(xwrite_function(stream,"Requested M2UA profile[%s] not configured\n", m2ua_profile_name); + return FTDM_FAIL; + } + + m2ua = &g_ftdm_sngss7_data.cfg.g_m2ua_cfg.m2ua[x]; + clust = &g_ftdm_sngss7_data.cfg.g_m2ua_cfg.m2ua_clus[m2ua->clusterId]; + + if(ftmod_m2ua_ssta_req(STMWCLUSTER,g_ftdm_sngss7_data.cfg.g_m2ua_cfg.m2ua[x].clusterId,&cfm)) { + stream->write_function(stream," Request to M2UA layer failed \n"); + return FTDM_FAIL; + } else { + len = len + sprintf(buf + len, "\n"); + len = len + sprintf(buf + len, " %s \n",clust->name); + len = len + sprintf(buf + len," %s \n", PRNT_M2UA_CLUSTER_STATE(cfm.t.ssta.s.clusterSta.state)); + len = len + sprintf(buf + len, " %d \n",cfm.t.ssta.s.clusterSta.nmbPeer); + for(idx = 0; idx < cfm.t.ssta.s.clusterSta.nmbPeer; idx++) + { + len = len + sprintf(buf + len, "\n"); + len = len + sprintf(buf + len, " %s \n", g_ftdm_sngss7_data.cfg.g_m2ua_cfg.m2ua_peer[cfm.t.ssta.s.clusterSta.peerSt[idx].peerId].name); + len = len + sprintf(buf + len, " %d \n", cfm.t.ssta.s.clusterSta.peerSt[idx].peerId); + len = len + sprintf(buf + len, " %s \n", PRNT_M2UA_PEER_STATE(cfm.t.ssta.s.clusterSta.peerSt[idx].peerState)); + len = len + sprintf(buf + len, "\n"); + } + len = len + sprintf(buf + len, " %d \n",cfm.t.ssta.s.clusterSta.nmbActPeer); + + len = len + sprintf(buf + len, "\n"); + } + + stream->write_function(stream,"\n%s\n",buf); + + return FTDM_SUCCESS; } /******************************************************************************/ diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_m2ua.c b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_m2ua.c index ccaf3ce418..5b173bfc8b 100644 --- a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_m2ua.c +++ b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_m2ua.c @@ -793,10 +793,10 @@ static int ftmod_m2ua_peer_config(int id) ftdm_log (FTDM_LOG_INFO, " ftmod_m2ua_sctsap_config: M2UA SCTSAP for M2UA Intf Id[%d] config SUCCESS \n", id); } if(ftmod_m2ua_peer_config1(id, peer_id)){ - ftdm_log (FTDM_LOG_ERROR, " ftmod_m2ua_peer_config1: M2UA Peer configuration for M2UA Intf Id[%d] config FAILED \n", id); + ftdm_log (FTDM_LOG_ERROR, " ftmod_m2ua_peer_config1: M2UA Peer[%d] configuration for M2UA Intf Id[%d] config FAILED \n", peer_id, id); return 0x01; }else{ - ftdm_log (FTDM_LOG_INFO, " ftmod_m2ua_peer_config1: M2UA Peer configuration for M2UA Intf Id[%d] config SUCCESS \n", id); + ftdm_log (FTDM_LOG_INFO, " ftmod_m2ua_peer_config1: M2UA Peer[%d] configuration for M2UA Intf Id[%d] config SUCCESS \n", peer_id, id); } clust->sct_sap_id = id; @@ -813,13 +813,28 @@ static int ftmod_m2ua_peer_config(int id) static int ftmod_m2ua_sctsap_config(int sct_sap_id, int sctp_id) { int i; + int ret; Pst pst; MwMgmt cfg; + MwMgmt cfm; sng_sctp_link_t *sctp = &g_ftdm_sngss7_data.cfg.sctpCfg.linkCfg[sctp_id]; + + memset((U8 *)&cfg, 0, sizeof(MwMgmt)); + memset((U8 *)&cfm, 0, sizeof(MwMgmt)); memset((U8 *)&pst, 0, sizeof(Pst)); + /* check is sct_sap is already configured */ + if(!ftmod_m2ua_ssta_req(STMWSCTSAP, sct_sap_id, &cfm )){ + ftdm_log (FTDM_LOG_INFO, " ftmod_m2ua_sctsap_config: SCT SAP [%s] is already configured \n", sctp->name); + return 0x00; + } + + if(LCM_REASON_INVALID_SAP == cfm.cfm.reason){ + ftdm_log (FTDM_LOG_INFO, " ftmod_m2ua_sctsap_config: SCT SAP [%s] is not configured..configuring now \n", sctp->name); + } + smPstInit(&pst); pst.dstEnt = ENTMW; @@ -880,8 +895,11 @@ static int ftmod_m2ua_sctsap_config(int sct_sap_id, int sctp_id) cfg.t.cfg.s.sctSapCfg.reConfig.mem.region = S_REG; cfg.t.cfg.s.sctSapCfg.reConfig.mem.pool = S_POOL; - return (sng_cfg_m2ua (&pst, &cfg)); + if (0 == (ret = sng_cfg_m2ua (&pst, &cfg))){ + sctp->flags |= SNGSS7_CONFIGURED; + } + return ret; } /****************************************************************************************************/