From 74de83c6eb8742887a3be75801088bb03c4a0e8b Mon Sep 17 00:00:00 2001 From: David Yat Sin Date: Fri, 15 Jun 2012 16:48:53 -0400 Subject: [PATCH 01/18] Trying without rad_auth --- build/modules.conf.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/modules.conf.in b/build/modules.conf.in index daaa6084c7..2bdedc6237 100644 --- a/build/modules.conf.in +++ b/build/modules.conf.in @@ -5,7 +5,7 @@ applications/mod_dptools applications/mod_commands applications/mod_hash applications/mod_spandsp -applications/mod_rad_auth +#applications/mod_rad_auth dialplans/mod_dialplan_xml endpoints/mod_sofia endpoints/mod_media_gateway From 3b4c725b1c339233452a2832a05e9b8325bb8822 Mon Sep 17 00:00:00 2001 From: kapil Date: Mon, 18 Jun 2012 17:41:05 +0530 Subject: [PATCH 02/18] fixing cli issues --- libs/freetdm/configure.ac | 2 +- libs/freetdm/mod_freetdm/mod_freetdm.c | 8 +- .../ftmod_sangoma_ss7/ftmod_sangoma_ss7_cfg.c | 7 + .../ftmod_sangoma_ss7/ftmod_sangoma_ss7_cli.c | 96 ++++---- .../ftmod_sangoma_ss7_m2ua.c | 216 +++++++++--------- .../ftmod_sangoma_ss7_m2ua.h | 2 + .../ftmod_sangoma_ss7_m2ua_xml.c | 17 +- .../ftmod_sangoma_ss7_main.h | 5 +- 8 files changed, 178 insertions(+), 175 deletions(-) diff --git a/libs/freetdm/configure.ac b/libs/freetdm/configure.ac index 80f0c73070..292c1e7cfa 100644 --- a/libs/freetdm/configure.ac +++ b/libs/freetdm/configure.ac @@ -316,7 +316,7 @@ if test "${HAVE_SNG_SS7}" = "yes"; then case "${host}" in x86_64-*) # X86_64 machines need additional flags when compiling against libsng_isdn - CFLAGS="$CFLAGS -DBIT_64 -DALIGN_64BIT -DDEBUGP" + CFLAGS="$CFLAGS -DBIT_64 -DALIGN_64BIT" ;; esac fi diff --git a/libs/freetdm/mod_freetdm/mod_freetdm.c b/libs/freetdm/mod_freetdm/mod_freetdm.c index 35690b1e24..89524f0eca 100755 --- a/libs/freetdm/mod_freetdm/mod_freetdm.c +++ b/libs/freetdm/mod_freetdm/mod_freetdm.c @@ -3061,7 +3061,6 @@ static ftdm_conf_node_t *_get_ss7_config_node(switch_xml_t cfg, const char *conf return NULL; } - /* If ISUP is operating mode then only include mtp3_links/isup links */ if(is_isup) { /* add mtp3 links */ if (add_config_list_nodes(isup, rootnode, "mtp3_links", "mtp3_link", NULL, NULL)) { @@ -3097,10 +3096,9 @@ static ftdm_conf_node_t *_get_ss7_config_node(switch_xml_t cfg, const char *conf ftdm_conf_node_destroy(rootnode); return NULL; } - } - else { + } else { /* add sctp links */ - if (add_config_list_nodes(isup, rootnode, "sng_sctp_interfaces", "sng_sctp_interface", NULL, NULL)) { + if (add_config_nodes(isup, rootnode, "sng_sctp_interfaces", "sng_sctp_interface", "sng_source_addresses")) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "failed to process sng_sctp_interface for sng_isup config %s\n", confname); ftdm_conf_node_destroy(rootnode); return NULL; @@ -3124,13 +3122,11 @@ static ftdm_conf_node_t *_get_ss7_config_node(switch_xml_t cfg, const char *conf return NULL; } - if (add_config_nodes(isup, rootnode, "sng_m2ua_cluster_interfaces", "sng_m2ua_cluster_interface", "sng_m2ua_peers")) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "failed to process sng_m2ua_cluster_interfaces for sng_isup config %s\n", confname); ftdm_conf_node_destroy(rootnode); return NULL; } - } switch_core_hash_insert(globals.ss7_configs, confname, rootnode); diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_cfg.c b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_cfg.c index 170f03f8f3..1600e71016 100644 --- a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_cfg.c +++ b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_cfg.c @@ -209,6 +209,13 @@ int ft_to_sngss7_cfg_all(void) } } /* if (sngss7_test_flag(&g_ftdm_sngss7_data.cfg, SNGSS7_MTP2)) */ + if(SNG_SS7_OPR_MODE_M2UA_SG == g_ftdm_operating_mode){ + if(FTDM_SUCCESS != ftmod_ss7_m2ua_init()){ + ftdm_log (FTDM_LOG_ERROR, "ftmod_ss7_m2ua_init FAILED \n"); + return FTDM_FAIL; + } + } + g_ftdm_sngss7_data.gen_config = SNG_GEN_CFG_STATUS_DONE; } /* if (!(g_ftdm_sngss7_data.gen_config)) */ 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 89cfec14a7..6906b80290 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 @@ -3090,8 +3090,8 @@ static ftdm_status_t handle_show_m2ua_profiles(ftdm_stream_handle_t *stream) return FTDM_FAIL; } else { len = len + sprintf(buf + len, "\n"); - len = len + sprintf(buf + len, " %ld \n", cfm.t.ssta.s.genSta.memSize); - len = len + sprintf(buf + len, " %ld \n", cfm.t.ssta.s.genSta.memAlloc); + len = len + sprintf(buf + len, " %d \n", cfm.t.ssta.s.genSta.memSize); + len = len + sprintf(buf + len, " %d \n", cfm.t.ssta.s.genSta.memAlloc); len = len + sprintf(buf + len, " %d \n", cfm.t.ssta.s.genSta.nmbClusters); len = len + sprintf(buf + len, " %d \n", cfm.t.ssta.s.genSta.nmbPeers); len = len + sprintf(buf + len, " %d \n", cfm.t.ssta.s.genSta.nmbIntf); @@ -3102,7 +3102,9 @@ static ftdm_status_t handle_show_m2ua_profiles(ftdm_stream_handle_t *stream) x = 1; while(x\n"); len = len + sprintf(buf + len, " %s \n", g_ftdm_sngss7_data.cfg.g_m2ua_cfg.m2ua[x].name); @@ -3120,6 +3122,7 @@ static ftdm_status_t handle_show_m2ua_profiles(ftdm_stream_handle_t *stream) len = len + sprintf(buf + len, "\n"); } + 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"); return FTDM_FAIL; @@ -3137,34 +3140,47 @@ static ftdm_status_t handle_show_m2ua_profiles(ftdm_stream_handle_t *stream) len = len + sprintf(buf + len, " %d \n",cfm.t.ssta.s.clusterSta.nmbActPeer); len = len + sprintf(buf + len, "\n"); - } - memcpy((U8 *)&rsp, &cfm, sizeof(MwMgmt)); + memset((U8 *)&rsp, 0, sizeof(MwMgmt)); + memcpy(&rsp, &cfm, sizeof(MwMgmt)); - /* loop through configured peers */ - for(idx = 0; idx < rsp.t.ssta.s.clusterSta.nmbPeer; idx++) - { - 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"); - return FTDM_FAIL; - } else { - len = len + sprintf(buf + len, "\n"); - len = len + sprintf(buf + len, " %s \n",g_ftdm_sngss7_data.cfg.g_m2ua_cfg.m2ua_peer[rsp.t.ssta.s.clusterSta.peerSt[idx].peerId].name); - len = len + sprintf(buf + len," %s \n", PRNT_M2UA_PEER_STATE(cfm.t.ssta.s.peerSta.state)); - len = len + sprintf(buf + len, " %d \n",cfm.t.ssta.s.peerSta.retryCount); - len = len + sprintf(buf + len, " %ld \n",cfm.t.ssta.s.peerSta.assocSta.spAssocId); - len = len + sprintf(buf + len, " %s \n",(cfm.t.ssta.s.peerSta.assocSta.connected)?"CONNECTED":"NOT CONNECTED"); - len = len + sprintf(buf + len, " %d \n",cfm.t.ssta.s.peerSta.assocSta.flcInProg); - len = len + sprintf(buf + len, " %d \n",cfm.t.ssta.s.peerSta.assocSta.flcLevel); - len = len + sprintf(buf + len, " %d \n",cfm.t.ssta.s.peerSta.assocSta.sctpHBeatEnb); - len = len + sprintf(buf + len, " %d \n",cfm.t.ssta.s.peerSta.assocSta.locOutStrms); + /* loop through configured peers */ + for(idx = 0; idx < rsp.t.ssta.s.clusterSta.nmbPeer; idx++) + { + int peer_id = rsp.t.ssta.s.clusterSta.peerSt[idx].peerId; + + memset(&cfm, 0, sizeof(MwMgmt)); - len = len + sprintf(buf + len, "\n"); + 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"); + return FTDM_FAIL; + } else { + len = len + sprintf(buf + len, "\n"); + len = len + sprintf(buf + len, " %s \n",g_ftdm_sngss7_data.cfg.g_m2ua_cfg.m2ua_peer[peer_id].name); + len = len + sprintf(buf + len," %s \n", PRNT_M2UA_PEER_STATE(cfm.t.ssta.s.peerSta.state)); + len = len + sprintf(buf + len, " %d \n",cfm.t.ssta.s.peerSta.retryCount); + len = len + sprintf(buf + len, " %d \n",cfm.t.ssta.s.peerSta.assocSta.spAssocId); + len = len + sprintf(buf + len, " %s \n",(cfm.t.ssta.s.peerSta.assocSta.connected)?"CONNECTED":"NOT CONNECTED"); + len = len + sprintf(buf + len, " %d \n",cfm.t.ssta.s.peerSta.assocSta.flcInProg); + len = len + sprintf(buf + len, " %d \n",cfm.t.ssta.s.peerSta.assocSta.flcLevel); + len = len + sprintf(buf + len, " %d \n",cfm.t.ssta.s.peerSta.assocSta.sctpHBeatEnb); + len = len + sprintf(buf + len, " %d \n",cfm.t.ssta.s.peerSta.assocSta.locOutStrms); + + len = len + sprintf(buf + len, "\n"); + } + } else { + len = len + sprintf(buf + len, "\n"); + len = len + sprintf(buf + len, " %s \n",g_ftdm_sngss7_data.cfg.g_m2ua_cfg.m2ua_peer[peer_id].name); + len = len + sprintf(buf + len," %s \n", PRNT_M2UA_PEER_STATE(rsp.t.ssta.s.clusterSta.peerSt[idx].peerState)); + len = len + sprintf(buf + len, "\n"); + } } } + 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"); return FTDM_FAIL; @@ -3172,7 +3188,7 @@ static ftdm_status_t handle_show_m2ua_profiles(ftdm_stream_handle_t *stream) len = len + sprintf(buf + len, "\n"); len = len + sprintf(buf + len," %s \n", PRNT_M2UA_SAP_STATE(cfm.t.ssta.s.sctSapSta.state)); len = len + sprintf(buf + len," %s \n", (cfm.t.ssta.s.sctSapSta.endpOpen)?"END_POINT_OPENED_SUCCESSFULLY":"END_POINT_NOT_OPEN"); - len = len + sprintf(buf + len," %ld \n", cfm.t.ssta.s.sctSapSta.spEndpId); + len = len + sprintf(buf + len," %d \n", cfm.t.ssta.s.sctSapSta.spEndpId); len = len + sprintf(buf + len," %d \n", cfm.t.ssta.s.sctSapSta.nmbPrimRetry); len = len + sprintf(buf + len, "\n"); } @@ -3218,7 +3234,7 @@ static ftdm_status_t handle_show_m2ua_profile(ftdm_stream_handle_t *stream, char x = 1; while(x %s \n",g_ftdm_sngss7_data.cfg.g_m2ua_cfg.m2ua_peer[rsp.t.ssta.s.clusterSta.peerSt[idx].peerId].name); len = len + sprintf(buf + len," %s \n", PRNT_M2UA_PEER_STATE(cfm.t.ssta.s.peerSta.state)); len = len + sprintf(buf + len, " %d \n",cfm.t.ssta.s.peerSta.retryCount); - len = len + sprintf(buf + len, " %ld \n",cfm.t.ssta.s.peerSta.assocSta.spAssocId); + len = len + sprintf(buf + len, " %d \n",cfm.t.ssta.s.peerSta.assocSta.spAssocId); len = len + sprintf(buf + len, " %s \n",(cfm.t.ssta.s.peerSta.assocSta.connected)?"CONNECTED":"NOT CONNECTED"); len = len + sprintf(buf + len, " %d \n",cfm.t.ssta.s.peerSta.assocSta.flcInProg); len = len + sprintf(buf + len, " %d \n",cfm.t.ssta.s.peerSta.assocSta.flcLevel); @@ -3302,7 +3318,7 @@ static ftdm_status_t handle_show_m2ua_profile(ftdm_stream_handle_t *stream, char len = len + sprintf(buf + len, "\n"); len = len + sprintf(buf + len," %s \n", PRNT_M2UA_SAP_STATE(cfm.t.ssta.s.sctSapSta.state)); len = len + sprintf(buf + len," %s \n", (cfm.t.ssta.s.sctSapSta.endpOpen)?"END_POINT_OPENED_SUCCESSFULLY":"END_POINT_NOT_OPEN"); - len = len + sprintf(buf + len," %ld \n", cfm.t.ssta.s.sctSapSta.spEndpId); + len = len + sprintf(buf + len," %d \n", cfm.t.ssta.s.sctSapSta.spEndpId); len = len + sprintf(buf + len," %d \n", cfm.t.ssta.s.sctSapSta.nmbPrimRetry); len = len + sprintf(buf + len, "\n"); } @@ -3341,8 +3357,8 @@ static ftdm_status_t handle_show_sctp_profiles(ftdm_stream_handle_t *stream) return FTDM_FAIL; } else { len = len + sprintf(buf + len, "\n"); - len = len + sprintf(buf + len, " %ld \n",cfm.t.ssta.s.genSta.memSize); - len = len + sprintf(buf + len, " %ld \n",cfm.t.ssta.s.genSta.memAlloc); + len = len + sprintf(buf + len, " %d \n",cfm.t.ssta.s.genSta.memSize); + len = len + sprintf(buf + len, " %d \n",cfm.t.ssta.s.genSta.memAlloc); len = len + sprintf(buf + len, " %d \n",cfm.t.ssta.s.genSta.nmbAssoc); len = len + sprintf(buf + len, " %d \n",cfm.t.ssta.s.genSta.nmbEndp); len = len + sprintf(buf + len, " %d \n",cfm.t.ssta.s.genSta.nmbLocalAddr); @@ -3379,7 +3395,7 @@ static ftdm_status_t handle_show_sctp_profiles(ftdm_stream_handle_t *stream) x = 1; while(x\n"); @@ -3438,7 +3454,7 @@ int get_assoc_resp_buf(char* buf,SbMgmt* cfm) char *asciiAddr; CmInetIpAddr ip; - len = len + sprintf(buf + len, " %ld \n", cfm->t.ssta.s.assocSta.assocId); + len = len + sprintf(buf + len, " %d \n", cfm->t.ssta.s.assocSta.assocId); len = len + sprintf(buf + len, " %s \n", PRNT_SCTP_ASSOC_STATE(cfm->t.ssta.s.assocSta.assocState)); len = len + sprintf(buf + len, " %d \n", cfm->t.ssta.s.assocSta.dstPort); len = len + sprintf(buf + len, " %d \n", cfm->t.ssta.s.assocSta.srcPort); @@ -3558,7 +3574,7 @@ static ftdm_status_t handle_show_sctp_profile(ftdm_stream_handle_t *stream, char x = 1; while(x\n"); - len = len + sprintf(buf + len, " %ld \n",cfm.t.ssta.s.genSta.memSize); - len = len + sprintf(buf + len, " %ld \n",cfm.t.ssta.s.genSta.memAlloc); + len = len + sprintf(buf + len, " %d \n",cfm.t.ssta.s.genSta.memSize); + len = len + sprintf(buf + len, " %d \n",cfm.t.ssta.s.genSta.memAlloc); len = len + sprintf(buf + len, "\n"); } @@ -3653,7 +3669,7 @@ static ftdm_status_t handle_show_nif_profiles(ftdm_stream_handle_t *stream) x = 1; while(x\n"); @@ -3664,7 +3680,7 @@ static ftdm_status_t handle_show_nif_profiles(ftdm_stream_handle_t *stream) len = len + sprintf(buf + len, "\n"); len = len + sprintf(buf + len," %s \n", PRNT_NIF_SAP_STATE(cfm.t.ssta.s.dlSapSta.m2uaState)); len = len + sprintf(buf + len," %s \n", PRNT_NIF_SAP_STATE(cfm.t.ssta.s.dlSapSta.mtp2State)); - len = len + sprintf(buf + len," %ld \n", cfm.t.ssta.s.dlSapSta.nmbRetry); + len = len + sprintf(buf + len," %d \n", cfm.t.ssta.s.dlSapSta.nmbRetry); len = len + sprintf(buf + len, "\n"); } @@ -3704,7 +3720,7 @@ static ftdm_status_t handle_show_nif_profile(ftdm_stream_handle_t *stream, char* x = 1; while(x\n"); len = len + sprintf(buf + len," %s \n", PRNT_NIF_SAP_STATE(cfm.t.ssta.s.dlSapSta.m2uaState)); len = len + sprintf(buf + len," %s \n", PRNT_NIF_SAP_STATE(cfm.t.ssta.s.dlSapSta.mtp2State)); - len = len + sprintf(buf + len," %ld \n", cfm.t.ssta.s.dlSapSta.nmbRetry); + len = len + sprintf(buf + len," %d \n", cfm.t.ssta.s.dlSapSta.nmbRetry); len = len + sprintf(buf + len, "\n"); } @@ -3774,7 +3790,7 @@ static ftdm_status_t handle_show_m2ua_peer_status(ftdm_stream_handle_t *stream, x = 1; while(xid ; /* peer Id */ + ssta.t.ssta.id.peerId = id ; /* peer Id */ break; } case STMWCLUSTER: diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_m2ua.h b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_m2ua.h index 8e22e47b97..c7ce2e74eb 100644 --- a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_m2ua.h +++ b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_m2ua.h @@ -60,6 +60,7 @@ typedef struct sng_m2ua_cfg{ uint32_t flags; uint32_t id; /* ID */ uint8_t nodeType; /*Node Type SG/ASP */ + uint8_t end_point_opened; /* flag to check is end-point already opened */ uint16_t clusterId; /* idx to m2ua_cluster profile */ }sng_m2ua_cfg_t; @@ -122,6 +123,7 @@ int ftmod_ss7_m2ua_start(void); void ftmod_ss7_m2ua_free(void); ftdm_status_t ftmod_ss7_m2ua_cfg(void); +ftdm_status_t ftmod_ss7_m2ua_init(void); int ftmod_sctp_ssta_req(int elemt, int id, SbMgmt* cfm); int ftmod_m2ua_ssta_req(int elemt, int id, MwMgmt* cfm); diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_m2ua_xml.c b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_m2ua_xml.c index 57bca70e61..b9ae986402 100644 --- a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_m2ua_xml.c +++ b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_m2ua_xml.c @@ -146,9 +146,6 @@ static int ftmod_ss7_parse_nif_interface(ftdm_conf_node_t *nif_interface) /**************************************************************************/ } /* for (i = 0; i < num_parms; i++) */ - /* default the interface to paused state */ - sngss7_set_flag(&sng_nif, SNGSS7_PAUSED); - /* fill in the nif interface */ ftmod_ss7_fill_in_nif_interface(&sng_nif); @@ -259,9 +256,6 @@ static int ftmod_ss7_parse_m2ua_interface(ftdm_conf_node_t *m2ua_interface) sng_m2ua.nodeType = SNG_M2UA_NODE_TYPE_SGP; - /* default the interface to paused state */ - sngss7_set_flag(&sng_m2ua, SNGSS7_PAUSED); - /* fill in the nif interface */ ftmod_ss7_fill_in_m2ua_interface(&sng_m2ua); @@ -421,9 +415,6 @@ static int ftmod_ss7_parse_m2ua_peer_interface(ftdm_conf_node_t *m2ua_peer_inter /**************************************************************************/ } /* for (i = 0; i < num_parms; i++) */ - /* default the interface to paused state */ - sngss7_set_flag(&sng_m2ua_peer, SNGSS7_PAUSED); - /* fill in the sng_m2ua_peer interface */ ftmod_ss7_fill_in_m2ua_peer_interface(&sng_m2ua_peer); @@ -576,9 +567,6 @@ static int ftmod_ss7_parse_m2ua_clust_interface(ftdm_conf_node_t *m2ua_cluster_i /**************************************************************************/ } /* for (i = 0; i < num_parms; i++) */ - /* default the interface to paused state */ - sngss7_set_flag(&sng_m2ua_cluster, SNGSS7_PAUSED); - /* fill in the sng_m2ua_peer interface */ ftmod_ss7_fill_in_m2ua_clust_interface(&sng_m2ua_cluster); @@ -663,7 +651,7 @@ static int ftmod_ss7_parse_sctp_link(ftdm_conf_node_t *node) t_link.id = atoi(param->val); SS7_DEBUG("SCTP - Parsing with id = %s\n", param->val); } - else if (!strcasecmp(param->var, "src-addr")) { + else if (!strcasecmp(param->var, "address")) { if (t_link.numSrcAddr < SCT_MAX_NET_ADDRS) { t_link.srcAddrList[t_link.numSrcAddr+1] = iptoul (param->val); t_link.numSrcAddr++; @@ -671,7 +659,7 @@ static int ftmod_ss7_parse_sctp_link(ftdm_conf_node_t *node) } else { SS7_ERROR("SCTP - too many source address configured. dropping %s \n", param->val); } - } else if (!strcasecmp(param->var, "src-port")) { + } else if (!strcasecmp(param->var, "source-port")) { t_link.port = atoi(param->val); SS7_DEBUG("SCTP - Parsing with port = %s\n", param->val); } @@ -683,7 +671,6 @@ static int ftmod_ss7_parse_sctp_link(ftdm_conf_node_t *node) g_ftdm_sngss7_data.cfg.sctpCfg.linkCfg[t_link.id].id = t_link.id; g_ftdm_sngss7_data.cfg.sctpCfg.linkCfg[t_link.id].port = t_link.port; strncpy((char*)g_ftdm_sngss7_data.cfg.sctpCfg.linkCfg[t_link.id].name, t_link.name, strlen(t_link.name) ); - g_ftdm_sngss7_data.cfg.sctpCfg.linkCfg[t_link.id].flags = 0; g_ftdm_sngss7_data.cfg.sctpCfg.linkCfg[t_link.id].numSrcAddr = t_link.numSrcAddr; for (i=1; i<=t_link.numSrcAddr; i++) { g_ftdm_sngss7_data.cfg.sctpCfg.linkCfg[t_link.id].srcAddrList[i] = t_link.srcAddrList[i]; diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_main.h b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_main.h index 0e52f88710..9a5a8cbe95 100644 --- a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_main.h +++ b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_main.h @@ -768,9 +768,10 @@ typedef enum { SNGSS7_M2UA_PRESENT = (1 << 18), SNGSS7_M2UA_STARTED = (1 << 19), SNGSS7_M2UA_EP_OPENED = (1 << 20), + SNGSS7_M2UA_INIT_ASSOC_DONE = (1 << 21), - SNGSS7_NIF_PRESENT = (1 << 21), - SNGSS7_NIF_STARTED = (1 << 22), + SNGSS7_NIF_PRESENT = (1 << 22), + SNGSS7_NIF_STARTED = (1 << 23), } sng_task_flag_t; /******************************************************************************/ From 32106afc433b6e96f00742a3e55b9565f4e4f8a9 Mon Sep 17 00:00:00 2001 From: David Yat Sin Date: Mon, 18 Jun 2012 12:51:38 -0400 Subject: [PATCH 03/18] Fixed compile issues again on 32-bit --- .../ftmod_sangoma_ss7/ftmod_sangoma_ss7_cli.c | 38 ++++++++++++++++--- 1 file changed, 33 insertions(+), 5 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 6906b80290..620e4f3ece 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 @@ -3090,9 +3090,15 @@ static ftdm_status_t handle_show_m2ua_profiles(ftdm_stream_handle_t *stream) return FTDM_FAIL; } else { len = len + sprintf(buf + len, "\n"); +#ifdef BIT_64 len = len + sprintf(buf + len, " %d \n", cfm.t.ssta.s.genSta.memSize); - len = len + sprintf(buf + len, " %d \n", cfm.t.ssta.s.genSta.memAlloc); + len = len + sprintf(buf + len, " %d \n", (int64_t) cfm.t.ssta.s.genSta.memAlloc); len = len + sprintf(buf + len, " %d \n", cfm.t.ssta.s.genSta.nmbClusters); +#else + len = len + sprintf(buf + len, " %ld \n", cfm.t.ssta.s.genSta.memSize); + len = len + sprintf(buf + len, " %ld \n", (int64_t) cfm.t.ssta.s.genSta.memAlloc); + len = len + sprintf(buf + len, " %ld \n", cfm.t.ssta.s.genSta.nmbClusters); +#endif len = len + sprintf(buf + len, " %d \n", cfm.t.ssta.s.genSta.nmbPeers); len = len + sprintf(buf + len, " %d \n", cfm.t.ssta.s.genSta.nmbIntf); len = len + sprintf(buf + len, "\n"); @@ -3162,7 +3168,11 @@ 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_peer[peer_id].name); len = len + sprintf(buf + len," %s \n", PRNT_M2UA_PEER_STATE(cfm.t.ssta.s.peerSta.state)); len = len + sprintf(buf + len, " %d \n",cfm.t.ssta.s.peerSta.retryCount); - len = len + sprintf(buf + len, " %d \n",cfm.t.ssta.s.peerSta.assocSta.spAssocId); +#ifdef BIT_64 + len = len + sprintf(buf + len, " %d \n", (int64_t) cfm.t.ssta.s.peerSta.assocSta.spAssocId); +#else + len = len + sprintf(buf + len, " %ld \n", (int64_t) cfm.t.ssta.s.peerSta.assocSta.spAssocId); +#endif len = len + sprintf(buf + len, " %s \n",(cfm.t.ssta.s.peerSta.assocSta.connected)?"CONNECTED":"NOT CONNECTED"); len = len + sprintf(buf + len, " %d \n",cfm.t.ssta.s.peerSta.assocSta.flcInProg); len = len + sprintf(buf + len, " %d \n",cfm.t.ssta.s.peerSta.assocSta.flcLevel); @@ -3188,7 +3198,11 @@ static ftdm_status_t handle_show_m2ua_profiles(ftdm_stream_handle_t *stream) len = len + sprintf(buf + len, "\n"); len = len + sprintf(buf + len," %s \n", PRNT_M2UA_SAP_STATE(cfm.t.ssta.s.sctSapSta.state)); len = len + sprintf(buf + len," %s \n", (cfm.t.ssta.s.sctSapSta.endpOpen)?"END_POINT_OPENED_SUCCESSFULLY":"END_POINT_NOT_OPEN"); - len = len + sprintf(buf + len," %d \n", cfm.t.ssta.s.sctSapSta.spEndpId); +#ifdef BIT_64 + len = len + sprintf(buf + len," %d \n", (int64_t) cfm.t.ssta.s.sctSapSta.spEndpId); +#else + len = len + sprintf(buf + len," %ld \n", (int64_t) cfm.t.ssta.s.sctSapSta.spEndpId); +#endif len = len + sprintf(buf + len," %d \n", cfm.t.ssta.s.sctSapSta.nmbPrimRetry); len = len + sprintf(buf + len, "\n"); } @@ -3300,7 +3314,7 @@ static ftdm_status_t handle_show_m2ua_profile(ftdm_stream_handle_t *stream, char len = len + sprintf(buf + len, " %s \n",g_ftdm_sngss7_data.cfg.g_m2ua_cfg.m2ua_peer[rsp.t.ssta.s.clusterSta.peerSt[idx].peerId].name); len = len + sprintf(buf + len," %s \n", PRNT_M2UA_PEER_STATE(cfm.t.ssta.s.peerSta.state)); len = len + sprintf(buf + len, " %d \n",cfm.t.ssta.s.peerSta.retryCount); - len = len + sprintf(buf + len, " %d \n",cfm.t.ssta.s.peerSta.assocSta.spAssocId); + len = len + sprintf(buf + len, " %ld \n", (int64_t) cfm.t.ssta.s.peerSta.assocSta.spAssocId); len = len + sprintf(buf + len, " %s \n",(cfm.t.ssta.s.peerSta.assocSta.connected)?"CONNECTED":"NOT CONNECTED"); len = len + sprintf(buf + len, " %d \n",cfm.t.ssta.s.peerSta.assocSta.flcInProg); len = len + sprintf(buf + len, " %d \n",cfm.t.ssta.s.peerSta.assocSta.flcLevel); @@ -3318,7 +3332,7 @@ static ftdm_status_t handle_show_m2ua_profile(ftdm_stream_handle_t *stream, char len = len + sprintf(buf + len, "\n"); len = len + sprintf(buf + len," %s \n", PRNT_M2UA_SAP_STATE(cfm.t.ssta.s.sctSapSta.state)); len = len + sprintf(buf + len," %s \n", (cfm.t.ssta.s.sctSapSta.endpOpen)?"END_POINT_OPENED_SUCCESSFULLY":"END_POINT_NOT_OPEN"); - len = len + sprintf(buf + len," %d \n", cfm.t.ssta.s.sctSapSta.spEndpId); + len = len + sprintf(buf + len," %ld \n", (int64_t) cfm.t.ssta.s.sctSapSta.spEndpId); len = len + sprintf(buf + len," %d \n", cfm.t.ssta.s.sctSapSta.nmbPrimRetry); len = len + sprintf(buf + len, "\n"); } @@ -3357,8 +3371,13 @@ static ftdm_status_t handle_show_sctp_profiles(ftdm_stream_handle_t *stream) return FTDM_FAIL; } else { len = len + sprintf(buf + len, "\n"); +#ifdef BIT_64 len = len + sprintf(buf + len, " %d \n",cfm.t.ssta.s.genSta.memSize); len = len + sprintf(buf + len, " %d \n",cfm.t.ssta.s.genSta.memAlloc); +#else + len = len + sprintf(buf + len, " %ld \n",cfm.t.ssta.s.genSta.memSize); + len = len + sprintf(buf + len, " %ld \n",cfm.t.ssta.s.genSta.memAlloc); +#endif len = len + sprintf(buf + len, " %d \n",cfm.t.ssta.s.genSta.nmbAssoc); len = len + sprintf(buf + len, " %d \n",cfm.t.ssta.s.genSta.nmbEndp); len = len + sprintf(buf + len, " %d \n",cfm.t.ssta.s.genSta.nmbLocalAddr); @@ -3454,7 +3473,11 @@ int get_assoc_resp_buf(char* buf,SbMgmt* cfm) char *asciiAddr; CmInetIpAddr ip; +#ifdef BIT_64 len = len + sprintf(buf + len, " %d \n", cfm->t.ssta.s.assocSta.assocId); +#else + len = len + sprintf(buf + len, " %ld \n", cfm->t.ssta.s.assocSta.assocId); +#endif len = len + sprintf(buf + len, " %s \n", PRNT_SCTP_ASSOC_STATE(cfm->t.ssta.s.assocSta.assocState)); len = len + sprintf(buf + len, " %d \n", cfm->t.ssta.s.assocSta.dstPort); len = len + sprintf(buf + len, " %d \n", cfm->t.ssta.s.assocSta.srcPort); @@ -3660,8 +3683,13 @@ static ftdm_status_t handle_show_nif_profiles(ftdm_stream_handle_t *stream) return FTDM_FAIL; } else { len = len + sprintf(buf + len, "\n"); +#ifdef BIT_64 len = len + sprintf(buf + len, " %d \n",cfm.t.ssta.s.genSta.memSize); len = len + sprintf(buf + len, " %d \n",cfm.t.ssta.s.genSta.memAlloc); +#else + len = len + sprintf(buf + len, " %ld \n",cfm.t.ssta.s.genSta.memSize); + len = len + sprintf(buf + len, " %ld \n",cfm.t.ssta.s.genSta.memAlloc); +#endif len = len + sprintf(buf + len, "\n"); } From 56c8534827f980b773f20035d1385ed9f54160c7 Mon Sep 17 00:00:00 2001 From: David Yat Sin Date: Mon, 18 Jun 2012 14:34:12 -0400 Subject: [PATCH 04/18] Fixed compile issues again on 32-bit --- .../ftmod_sangoma_ss7/ftmod_sangoma_ss7_cli.c | 20 +++++++++++++++---- 1 file changed, 16 insertions(+), 4 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 620e4f3ece..80aad15ee8 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 @@ -3092,11 +3092,11 @@ static ftdm_status_t handle_show_m2ua_profiles(ftdm_stream_handle_t *stream) len = len + sprintf(buf + len, "\n"); #ifdef BIT_64 len = len + sprintf(buf + len, " %d \n", cfm.t.ssta.s.genSta.memSize); - len = len + sprintf(buf + len, " %d \n", (int64_t) cfm.t.ssta.s.genSta.memAlloc); + len = len + sprintf(buf + len, " %d \n", cfm.t.ssta.s.genSta.memAlloc); len = len + sprintf(buf + len, " %d \n", cfm.t.ssta.s.genSta.nmbClusters); #else len = len + sprintf(buf + len, " %ld \n", cfm.t.ssta.s.genSta.memSize); - len = len + sprintf(buf + len, " %ld \n", (int64_t) cfm.t.ssta.s.genSta.memAlloc); + len = len + sprintf(buf + len, " %ld \n", cfm.t.ssta.s.genSta.memAlloc); len = len + sprintf(buf + len, " %ld \n", cfm.t.ssta.s.genSta.nmbClusters); #endif len = len + sprintf(buf + len, " %d \n", cfm.t.ssta.s.genSta.nmbPeers); @@ -3314,7 +3314,11 @@ static ftdm_status_t handle_show_m2ua_profile(ftdm_stream_handle_t *stream, char len = len + sprintf(buf + len, " %s \n",g_ftdm_sngss7_data.cfg.g_m2ua_cfg.m2ua_peer[rsp.t.ssta.s.clusterSta.peerSt[idx].peerId].name); len = len + sprintf(buf + len," %s \n", PRNT_M2UA_PEER_STATE(cfm.t.ssta.s.peerSta.state)); len = len + sprintf(buf + len, " %d \n",cfm.t.ssta.s.peerSta.retryCount); - len = len + sprintf(buf + len, " %ld \n", (int64_t) cfm.t.ssta.s.peerSta.assocSta.spAssocId); +#ifdef BIT_64 + len = len + sprintf(buf + len, " %d \n", cfm.t.ssta.s.peerSta.assocSta.spAssocId); +#else + len = len + sprintf(buf + len, " %ld \n", cfm.t.ssta.s.peerSta.assocSta.spAssocId); +#endif len = len + sprintf(buf + len, " %s \n",(cfm.t.ssta.s.peerSta.assocSta.connected)?"CONNECTED":"NOT CONNECTED"); len = len + sprintf(buf + len, " %d \n",cfm.t.ssta.s.peerSta.assocSta.flcInProg); len = len + sprintf(buf + len, " %d \n",cfm.t.ssta.s.peerSta.assocSta.flcLevel); @@ -3332,7 +3336,11 @@ static ftdm_status_t handle_show_m2ua_profile(ftdm_stream_handle_t *stream, char len = len + sprintf(buf + len, "\n"); len = len + sprintf(buf + len," %s \n", PRNT_M2UA_SAP_STATE(cfm.t.ssta.s.sctSapSta.state)); len = len + sprintf(buf + len," %s \n", (cfm.t.ssta.s.sctSapSta.endpOpen)?"END_POINT_OPENED_SUCCESSFULLY":"END_POINT_NOT_OPEN"); - len = len + sprintf(buf + len," %ld \n", (int64_t) cfm.t.ssta.s.sctSapSta.spEndpId); +#ifdef BIT_64 + len = len + sprintf(buf + len," %d \n", cfm.t.ssta.s.sctSapSta.spEndpId); +#else + len = len + sprintf(buf + len," %ld \n", cfm.t.ssta.s.sctSapSta.spEndpId); +#endif len = len + sprintf(buf + len," %d \n", cfm.t.ssta.s.sctSapSta.nmbPrimRetry); len = len + sprintf(buf + len, "\n"); } @@ -3708,7 +3716,11 @@ static ftdm_status_t handle_show_nif_profiles(ftdm_stream_handle_t *stream) len = len + sprintf(buf + len, "\n"); len = len + sprintf(buf + len," %s \n", PRNT_NIF_SAP_STATE(cfm.t.ssta.s.dlSapSta.m2uaState)); len = len + sprintf(buf + len," %s \n", PRNT_NIF_SAP_STATE(cfm.t.ssta.s.dlSapSta.mtp2State)); +#ifdef BIT_64 len = len + sprintf(buf + len," %d \n", cfm.t.ssta.s.dlSapSta.nmbRetry); +#else + len = len + sprintf(buf + len," %ld \n", cfm.t.ssta.s.dlSapSta.nmbRetry); +#endif len = len + sprintf(buf + len, "\n"); } From 0cefb8d63337d3365a0c9a3ce9e27e06d6319db0 Mon Sep 17 00:00:00 2001 From: David Yat Sin Date: Mon, 18 Jun 2012 15:01:08 -0400 Subject: [PATCH 05/18] Fixed compile issues again on 32-bit --- .../src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_cli.c | 7 +++---- 1 file changed, 3 insertions(+), 4 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 80aad15ee8..951d0a3e49 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 @@ -3093,12 +3093,11 @@ static ftdm_status_t handle_show_m2ua_profiles(ftdm_stream_handle_t *stream) #ifdef BIT_64 len = len + sprintf(buf + len, " %d \n", cfm.t.ssta.s.genSta.memSize); len = len + sprintf(buf + len, " %d \n", cfm.t.ssta.s.genSta.memAlloc); - len = len + sprintf(buf + len, " %d \n", cfm.t.ssta.s.genSta.nmbClusters); #else len = len + sprintf(buf + len, " %ld \n", cfm.t.ssta.s.genSta.memSize); len = len + sprintf(buf + len, " %ld \n", cfm.t.ssta.s.genSta.memAlloc); - len = len + sprintf(buf + len, " %ld \n", cfm.t.ssta.s.genSta.nmbClusters); #endif + len = len + sprintf(buf + len, " %d \n", cfm.t.ssta.s.genSta.nmbClusters); len = len + sprintf(buf + len, " %d \n", cfm.t.ssta.s.genSta.nmbPeers); len = len + sprintf(buf + len, " %d \n", cfm.t.ssta.s.genSta.nmbIntf); len = len + sprintf(buf + len, "\n"); @@ -3171,7 +3170,7 @@ static ftdm_status_t handle_show_m2ua_profiles(ftdm_stream_handle_t *stream) #ifdef BIT_64 len = len + sprintf(buf + len, " %d \n", (int64_t) cfm.t.ssta.s.peerSta.assocSta.spAssocId); #else - len = len + sprintf(buf + len, " %ld \n", (int64_t) cfm.t.ssta.s.peerSta.assocSta.spAssocId); + len = len + sprintf(buf + len, " %lld \n", (int64_t) cfm.t.ssta.s.peerSta.assocSta.spAssocId); #endif len = len + sprintf(buf + len, " %s \n",(cfm.t.ssta.s.peerSta.assocSta.connected)?"CONNECTED":"NOT CONNECTED"); len = len + sprintf(buf + len, " %d \n",cfm.t.ssta.s.peerSta.assocSta.flcInProg); @@ -3201,7 +3200,7 @@ static ftdm_status_t handle_show_m2ua_profiles(ftdm_stream_handle_t *stream) #ifdef BIT_64 len = len + sprintf(buf + len," %d \n", (int64_t) cfm.t.ssta.s.sctSapSta.spEndpId); #else - len = len + sprintf(buf + len," %ld \n", (int64_t) cfm.t.ssta.s.sctSapSta.spEndpId); + len = len + sprintf(buf + len," %lld \n", (int64_t) cfm.t.ssta.s.sctSapSta.spEndpId); #endif len = len + sprintf(buf + len," %d \n", cfm.t.ssta.s.sctSapSta.nmbPrimRetry); len = len + sprintf(buf + len, "\n"); From 0a9f34aa09cbe60ae9bd8c8ceb855b8a261cc44e Mon Sep 17 00:00:00 2001 From: David Yat Sin Date: Mon, 18 Jun 2012 15:27:45 -0400 Subject: [PATCH 06/18] Fixed compile issues again on 32-bit --- .../src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_cli.c | 4 ++++ 1 file changed, 4 insertions(+) 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 951d0a3e49..b8cc34480f 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 @@ -3784,7 +3784,11 @@ static ftdm_status_t handle_show_nif_profile(ftdm_stream_handle_t *stream, char* len = len + sprintf(buf + len, "\n"); len = len + sprintf(buf + len," %s \n", PRNT_NIF_SAP_STATE(cfm.t.ssta.s.dlSapSta.m2uaState)); len = len + sprintf(buf + len," %s \n", PRNT_NIF_SAP_STATE(cfm.t.ssta.s.dlSapSta.mtp2State)); +#ifdef BIT_64 len = len + sprintf(buf + len," %d \n", cfm.t.ssta.s.dlSapSta.nmbRetry); +#else + len = len + sprintf(buf + len," %ld \n", cfm.t.ssta.s.dlSapSta.nmbRetry); +#endif len = len + sprintf(buf + len, "\n"); } From 743e91569e5ef10abc92198ed473d9ac561abb5f Mon Sep 17 00:00:00 2001 From: kapil Date: Tue, 19 Jun 2012 17:00:39 +0530 Subject: [PATCH 07/18] adding enable/disable MEGACO stack looging CLI command --- .../mod_media_gateway/media_gateway_cli.c | 25 +++++++++++++++- .../mod_media_gateway/media_gateway_stack.c | 30 +++++++++++++++++-- .../mod_media_gateway/media_gateway_stack.h | 2 ++ .../mod_media_gateway/mod_media_gateway.c | 2 ++ .../mod_media_gateway/mod_media_gateway.h | 2 ++ 5 files changed, 58 insertions(+), 3 deletions(-) diff --git a/src/mod/endpoints/mod_media_gateway/media_gateway_cli.c b/src/mod/endpoints/mod_media_gateway/media_gateway_cli.c index db50feaa57..720032673c 100644 --- a/src/mod/endpoints/mod_media_gateway/media_gateway_cli.c +++ b/src/mod/endpoints/mod_media_gateway/media_gateway_cli.c @@ -99,12 +99,35 @@ switch_status_t mg_process_cli_cmd(const char *cmd, switch_stream_handle_t *stre /**********************************************************************************/ goto usage; } +/**********************************************************************************/ + }else if (!strcmp(argv[0], "logging")) { +/**********************************************************************************/ + if (zstr(argv[1])) { + goto usage; + } + /******************************************************************/ + if(!strcasecmp(argv[1], "enable")){ + mg_enable_logging(); + /******************************************************************/ + }else if(!strcasecmp(argv[1], "disable")){ + /******************************************************************/ + mg_disable_logging(); + /******************************************************************/ + } else { + /******************************************************************/ + goto usage; + } +/**********************************************************************************/ + }else { +/**********************************************************************************/ + goto usage; } +/**********************************************************************************/ goto done; usage: - stream->write_function(stream, "-ERR Usage: "MEGACO_FUNCTION_SYNTAX"\n"); + stream->write_function(stream, "-ERR Usage: \n""\t"MEGACO_CLI_SYNTAX" \n \t"MEGACO_FUNCTION_SYNTAX"\n \t" MEGACO_LOGGING_CLI_SYNTAX "\n"); done: switch_safe_free(dup); diff --git a/src/mod/endpoints/mod_media_gateway/media_gateway_stack.c b/src/mod/endpoints/mod_media_gateway/media_gateway_stack.c index abe46a5837..d4717501ce 100644 --- a/src/mod/endpoints/mod_media_gateway/media_gateway_stack.c +++ b/src/mod/endpoints/mod_media_gateway/media_gateway_stack.c @@ -19,7 +19,6 @@ int mgco_mu_gen_config(void); int mgco_tucl_gen_config(void); int mgco_mu_ssap_config(int idx); int mgco_mg_tsap_config(megaco_profile_t* profile); -int mgco_mg_enble_debug(void); int mgco_mg_ssap_config(megaco_profile_t* profile); int mgco_mg_peer_config(megaco_profile_t* profile); int mgco_mg_tpt_server_config(megaco_profile_t* profile); @@ -571,7 +570,7 @@ int mgco_mg_ssap_cntrl(int idx) } /******************************************************************************/ -int mgco_mg_enble_debug() +int mg_enable_logging() { MgMngmt mgMngmt; Pst pst; /* Post for layer manager */ @@ -597,6 +596,33 @@ int mgco_mg_enble_debug() return(sng_cntrl_mg(&pst, &mgMngmt)); } +/******************************************************************************/ +int mg_disable_logging() +{ + MgMngmt mgMngmt; + Pst pst; /* Post for layer manager */ + MgCntrl* cntrl; + + memset(&mgMngmt, 0, sizeof(mgMngmt)); + cntrl = &mgMngmt.t.cntrl; + + /* initalize the post structure */ + smPstInit(&pst); + + /* insert the destination Entity */ + pst.dstEnt = ENTMG; + mgMngmt.hdr.msgType = TCFG; + mgMngmt.hdr.entId.ent = ENTHI; + mgMngmt.hdr.entId.inst = S_INST; + mgMngmt.hdr.elmId.elmnt = STGEN; + + cntrl->action = ADISIMM; + cntrl->subAction = SADBG; + cntrl->s.dbg.genDbgMask = 0xfffffdff; + + return(sng_cntrl_mg(&pst, &mgMngmt)); +} + /******************************************************************************/ int mgco_tucl_gen_config(void) { diff --git a/src/mod/endpoints/mod_media_gateway/media_gateway_stack.h b/src/mod/endpoints/mod_media_gateway/media_gateway_stack.h index ac5b911f9b..9bbe90b7df 100644 --- a/src/mod/endpoints/mod_media_gateway/media_gateway_stack.h +++ b/src/mod/endpoints/mod_media_gateway/media_gateway_stack.h @@ -53,6 +53,8 @@ void handle_mgco_txn_ind(Pst *pst, SuId suId, MgMgcoMsg* msg); void handle_mgco_audit_cfm(Pst *pst, SuId suId, MgMgtAudit* audit, Reason reason); void handle_mg_alarm(Pst *pst, MgMngmt *sta); void handle_tucl_alarm(Pst *pst, HiMngmt *sta); +int mg_enable_logging(void); +int mg_disable_logging(void); switch_status_t sng_mgco_cfg(megaco_profile_t* profile); diff --git a/src/mod/endpoints/mod_media_gateway/mod_media_gateway.c b/src/mod/endpoints/mod_media_gateway/mod_media_gateway.c index 58a8794fad..322dbd4221 100644 --- a/src/mod/endpoints/mod_media_gateway/mod_media_gateway.c +++ b/src/mod/endpoints/mod_media_gateway/mod_media_gateway.c @@ -73,6 +73,8 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_media_gateway_load) switch_console_set_complete("add megaco profile ::megaco::list_profiles status"); switch_console_set_complete("add megaco profile ::megaco::list_profiles xmlstatus"); switch_console_set_complete("add megaco profile ::megaco::list_profiles peerxmlstatus"); + switch_console_set_complete("add megaco logging ::megaco::list_profiles enable"); + switch_console_set_complete("add megaco logging ::megaco::list_profiles disable"); switch_console_add_complete_func("::megaco::list_profiles", list_profiles); diff --git a/src/mod/endpoints/mod_media_gateway/mod_media_gateway.h b/src/mod/endpoints/mod_media_gateway/mod_media_gateway.h index c55bb6744f..2e0db8cb62 100644 --- a/src/mod/endpoints/mod_media_gateway/mod_media_gateway.h +++ b/src/mod/endpoints/mod_media_gateway/mod_media_gateway.h @@ -15,6 +15,8 @@ #define MG_MAX_PEERS 5 +#define MEGACO_CLI_SYNTAX "profile|logging" +#define MEGACO_LOGGING_CLI_SYNTAX "logging [enable|disable]" #define MEGACO_FUNCTION_SYNTAX "profile [name] [start | stop] [status] [xmlstatus] [peerxmlstatus]" struct megaco_globals { From 8846e1fea1029ac8599762c4e219e9984b1cd70b Mon Sep 17 00:00:00 2001 From: kapil Date: Tue, 19 Jun 2012 23:36:38 +0530 Subject: [PATCH 08/18] issue fix --- src/mod/endpoints/mod_media_gateway/media_gateway_stack.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/mod/endpoints/mod_media_gateway/media_gateway_stack.c b/src/mod/endpoints/mod_media_gateway/media_gateway_stack.c index d4717501ce..591bb5f13d 100644 --- a/src/mod/endpoints/mod_media_gateway/media_gateway_stack.c +++ b/src/mod/endpoints/mod_media_gateway/media_gateway_stack.c @@ -96,6 +96,9 @@ switch_status_t sng_mgco_init(sng_mg_event_interface_t* event) /*****************************************************************************************************************/ switch_status_t sng_mgco_stack_shutdown() { + /* disable MG logging */ + mg_disable_logging(); + /* shutdown MG */ sng_mgco_mg_shutdown(); @@ -1256,7 +1259,7 @@ int sng_mgco_mg_get_status(int elemId, MgMngmt* cfm, megaco_profile_t* mg_cfg, case STSERVER: { cntrl.t.ssta.s.mgTptSrvSta.tptAddr.type = CM_INET_IPV4ADDR_TYPE; - cntrl.t.ssta.s.mgTptSrvSta.tptAddr.u.ipv4TptAddr.port = ntohl(ipAddr); + cntrl.t.ssta.s.mgTptSrvSta.tptAddr.u.ipv4TptAddr.port = atoi(mg_cfg->port); if(ROK == cmInetAddr((S8*)mg_cfg->my_ipaddr, &ipAddr)) { cntrl.t.ssta.s.mgTptSrvSta.tptAddr.u.ipv4TptAddr.address = ntohl(ipAddr); From cb73fdf2f6e2e1189bc7d93615079a17dc855a5f Mon Sep 17 00:00:00 2001 From: David Yat Sin Date: Tue, 19 Jun 2012 17:30:03 -0400 Subject: [PATCH 09/18] Added parsing for additional parameters for UI team to test their code --- .../mod_media_gateway/media_gateway_xml.c | 29 +++++++++++++-- .../mod_media_gateway/mod_media_gateway.h | 36 ++++++++++++------- 2 files changed, 51 insertions(+), 14 deletions(-) diff --git a/src/mod/endpoints/mod_media_gateway/media_gateway_xml.c b/src/mod/endpoints/mod_media_gateway/media_gateway_xml.c index 710cc7e6c4..2d584ed0ed 100644 --- a/src/mod/endpoints/mod_media_gateway/media_gateway_xml.c +++ b/src/mod/endpoints/mod_media_gateway/media_gateway_xml.c @@ -19,7 +19,7 @@ switch_status_t config_profile(megaco_profile_t *profile, switch_bool_t reload) switch_xml_t cfg, xml, param, mg_interfaces, mg_interface, mg_peers, mg_peer, peer_interfaces ; switch_status_t status = SWITCH_STATUS_FALSE; switch_event_t *event = NULL; - const char *file = "megaco.conf"; + const char *file = "media_gateway.conf"; switch_xml_config_item_t *instructions = (profile ? get_instructions(profile) : NULL); int count; int idx; @@ -63,6 +63,11 @@ switch_status_t config_profile(megaco_profile_t *profile, switch_bool_t reload) break; } + if (!mg_interface) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error profile %s not found\n", profile->name); + return SWITCH_STATUS_FALSE; + } + /* go through the peer configuration and get the mg profile associated peers only */ if (!(mg_peers = switch_xml_child(cfg, "mg_peers"))) { goto done; @@ -144,10 +149,25 @@ static switch_xml_config_item_t *get_instructions(megaco_profile_t *profile) { static switch_xml_config_int_options_t opt_version = { SWITCH_TRUE, /* enforce min */ 1, - SWITCH_TRUE, /* Enforce Max */ + SWITCH_TRUE, /* enforce Max */ 3 }; + static switch_xml_config_int_options_t opt_termination_id_len = { + SWITCH_TRUE, /* enforce min */ + 1, + SWITCH_TRUE, /* enforce Max */ + 9 + }; + + static switch_xml_config_enum_item_t opt_default_codec_enum[] = { + { "PCMA", MEGACO_CODEC_PCMA}, + { "PCMU", MEGACO_CODEC_PCMU}, + { "G.729", MEGACO_CODEC_G729}, + { "G.723.1", MEGACO_CODEC_G723_1}, + { "ILBC", MEGACO_CODEC_ILBC }, + }; + switch_xml_config_item_t instructions[] = { /* parameter name type reloadable pointer default value options structure */ SWITCH_CONFIG_ITEM("protocol", SWITCH_CONFIG_STRING, CONFIG_RELOADABLE, &profile->protocol_type, "MEGACO", &switch_config_string_strdup, "", "MG Protocol type"), @@ -156,6 +176,11 @@ static switch_xml_config_item_t *get_instructions(megaco_profile_t *profile) { SWITCH_CONFIG_ITEM("port", SWITCH_CONFIG_STRING, 0, &profile->port, "2944", &switch_config_string_strdup, "", "port"), SWITCH_CONFIG_ITEM("domain-name", SWITCH_CONFIG_STRING, 0, &profile->my_domain, "", &switch_config_string_strdup, "", "domain name"), SWITCH_CONFIG_ITEM("message-identifier", SWITCH_CONFIG_STRING, 0, &profile->mid, "", &switch_config_string_strdup, "", "message identifier "), + + SWITCH_CONFIG_ITEM("default-codec", SWITCH_CONFIG_ENUM, CONFIG_RELOADABLE, &profile->default_codec, "PCMU", &opt_default_codec_enum, "", "default codec"), + SWITCH_CONFIG_ITEM("rtp-port-range", SWITCH_CONFIG_STRING, CONFIG_REQUIRED, &profile->rtp_port_range, "1-65535", &switch_config_string_strdup, "", "rtp port range"), + SWITCH_CONFIG_ITEM("rtp-termination-id-prefix", SWITCH_CONFIG_STRING, CONFIG_RELOADABLE, &profile->rtp_termination_id_prefix, "", &switch_config_string_strdup, "", "rtp termination prefix"), + SWITCH_CONFIG_ITEM("rtp-termination-id-len", SWITCH_CONFIG_INT, CONFIG_RELOADABLE, &profile->rtp_termination_id_len, "", &opt_termination_id_len, "", "rtp termination id"), SWITCH_CONFIG_ITEM_END() }; diff --git a/src/mod/endpoints/mod_media_gateway/mod_media_gateway.h b/src/mod/endpoints/mod_media_gateway/mod_media_gateway.h index 2e0db8cb62..d4c6e43077 100644 --- a/src/mod/endpoints/mod_media_gateway/mod_media_gateway.h +++ b/src/mod/endpoints/mod_media_gateway/mod_media_gateway.h @@ -32,6 +32,14 @@ typedef enum { PF_RUNNING = (1 << 0) } megaco_profile_flags_t; +typedef enum { + MEGACO_CODEC_PCMA, + MEGACO_CODEC_PCMU, + MEGACO_CODEC_G729, + MEGACO_CODEC_G723_1, + MEGACO_CODEC_ILBC, +} megaco_codec_t; + typedef struct mg_peer_profile_s{ char *name; switch_memory_pool_t *pool; @@ -47,18 +55,22 @@ typedef struct mg_peer_profile_s{ typedef struct megaco_profile_s { char *name; - switch_memory_pool_t *pool; - switch_thread_rwlock_t *rwlock; /* < Reference counting rwlock */ - megaco_profile_flags_t flags; - int idx; /* Trillium MEGACO SAP identification*/ - char* mid; /* MG H.248 MID */ - char* my_domain; /* local domain name */ - char* my_ipaddr; /* local domain name */ - char* port; /* port */ - char* protocol_type; /* MEGACO/MGCP */ - int protocol_version; /* Protocol supported version */ - int total_peers; - char* peer_list[MG_MAX_PEERS]; /* MGC Peer ID LIST */ + switch_memory_pool_t *pool; + switch_thread_rwlock_t *rwlock; /* < Reference counting rwlock */ + megaco_profile_flags_t flags; + int idx; /* Trillium MEGACO SAP identification*/ + char* mid; /* MG H.248 MID */ + char* my_domain; /* local domain name */ + char* my_ipaddr; /* local domain name */ + char* port; /* port */ + char* protocol_type; /* MEGACO/MGCP */ + int protocol_version; /* Protocol supported version */ + int total_peers; + megaco_codec_t default_codec; + char* rtp_port_range; + char* rtp_termination_id_prefix; + int rtp_termination_id_len; + char* peer_list[MG_MAX_PEERS]; /* MGC Peer ID LIST */ } megaco_profile_t; From ae17b90f68f411d5d27420282adedaac26fab417 Mon Sep 17 00:00:00 2001 From: David Yat Sin Date: Tue, 19 Jun 2012 17:54:01 -0400 Subject: [PATCH 10/18] Changed megaco commands to mg --- .../mod_media_gateway/mod_media_gateway.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/mod/endpoints/mod_media_gateway/mod_media_gateway.c b/src/mod/endpoints/mod_media_gateway/mod_media_gateway.c index 322dbd4221..bcc66cc396 100644 --- a/src/mod/endpoints/mod_media_gateway/mod_media_gateway.c +++ b/src/mod/endpoints/mod_media_gateway/mod_media_gateway.c @@ -66,16 +66,16 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_media_gateway_load) switch_core_hash_init(&megaco_globals.peer_profile_hash, pool); switch_thread_rwlock_create(&megaco_globals.peer_profile_rwlock, pool); - SWITCH_ADD_API(api_interface, "megaco", "megaco", megaco_function, MEGACO_FUNCTION_SYNTAX); + SWITCH_ADD_API(api_interface, "mg", "media_gateway", megaco_function, MEGACO_FUNCTION_SYNTAX); - switch_console_set_complete("add megaco profile ::megaco::list_profiles start"); - switch_console_set_complete("add megaco profile ::megaco::list_profiles stop"); - switch_console_set_complete("add megaco profile ::megaco::list_profiles status"); - switch_console_set_complete("add megaco profile ::megaco::list_profiles xmlstatus"); - switch_console_set_complete("add megaco profile ::megaco::list_profiles peerxmlstatus"); - switch_console_set_complete("add megaco logging ::megaco::list_profiles enable"); - switch_console_set_complete("add megaco logging ::megaco::list_profiles disable"); - switch_console_add_complete_func("::megaco::list_profiles", list_profiles); + switch_console_set_complete("add mg profile ::mg::list_profiles start"); + switch_console_set_complete("add mg profile ::mg::list_profiles stop"); + switch_console_set_complete("add mg profile ::mg::list_profiles status"); + switch_console_set_complete("add mg profile ::mg::list_profiles xmlstatus"); + switch_console_set_complete("add mg profile ::mg::list_profiles peerxmlstatus"); + switch_console_set_complete("add mg logging ::mg::list_profiles enable"); + switch_console_set_complete("add mg logging ::mg::list_profiles disable"); + switch_console_add_complete_func("::mg::list_profiles", list_profiles); /* Initialize MEGACO Stack */ From 6aa8c9b80dcf77dba76b96f0da62a99953dfd04c Mon Sep 17 00:00:00 2001 From: David Yat Sin Date: Tue, 19 Jun 2012 22:35:37 -0400 Subject: [PATCH 11/18] freetdm: Improvements to ftdm core flag CLI command --- libs/freetdm/src/ftdm_io.c | 210 +++++++++++++++--- libs/freetdm/src/include/private/ftdm_types.h | 4 + 2 files changed, 186 insertions(+), 28 deletions(-) diff --git a/libs/freetdm/src/ftdm_io.c b/libs/freetdm/src/ftdm_io.c index 78e65dfe88..bdb66c635a 100644 --- a/libs/freetdm/src/ftdm_io.c +++ b/libs/freetdm/src/ftdm_io.c @@ -40,6 +40,7 @@ #define _GNU_SOURCE #include "private/ftdm_core.h" #include +#include #ifdef WIN32 #include #endif @@ -66,7 +67,8 @@ static ftdm_status_t ftdm_call_set_call_id(ftdm_channel_t *fchan, ftdm_caller_da static ftdm_status_t ftdm_call_clear_call_id(ftdm_caller_data_t *caller_data); static ftdm_status_t ftdm_channel_done(ftdm_channel_t *ftdmchan); static ftdm_status_t ftdm_channel_sig_indicate(ftdm_channel_t *ftdmchan, ftdm_channel_indication_t indication, ftdm_usrmsg_t *usrmsg); - +static const char *channel_val2str(unsigned long long flag); +static unsigned long long channel_str2val(const char *flag_name); static int time_is_init = 0; @@ -4339,7 +4341,7 @@ static struct { ftdm_io_interface_t *pika_interface; } interfaces; -static void print_channels_by_flag(ftdm_stream_handle_t *stream, int32_t flagval, int not, int *count) +static void print_channels_by_flag(ftdm_stream_handle_t *stream, ftdm_span_t *inspan, uint32_t inchan_id, int32_t flagval, int not, int *count) { ftdm_hash_iterator_t *i = NULL; ftdm_span_t *span; @@ -4349,40 +4351,85 @@ static void print_channels_by_flag(ftdm_stream_handle_t *stream, int32_t flagval const void *key = NULL; void *val = NULL; uint32_t flag = (1 << flagval); + int mycount = 0; *count = 0; ftdm_mutex_lock(globals.mutex); - for (i = hashtable_first(globals.span_hash); i; i = hashtable_next(i)) { - hashtable_this(i, &key, NULL, &val); - if (!key || !val) { - break; - } - span = val; - citer = ftdm_span_get_chan_iterator(span, NULL); + if (inspan) { + citer = ftdm_span_get_chan_iterator(inspan, NULL); if (!citer) { - continue; + goto end; } for (curr = citer ; curr; curr = ftdm_iterator_next(curr)) { fchan = ftdm_iterator_current(curr); - if (not && !ftdm_test_flag(fchan, flag)) { - stream->write_function(stream, "[s%dc%d][%d:%d] has not flag %d\n", - fchan->span_id, fchan->chan_id, - fchan->physical_span_id, fchan->physical_chan_id, - flagval); - (*count)++; - } else if (!not && ftdm_test_flag(fchan, flag)) { - stream->write_function(stream, "[s%dc%d][%d:%d] has flag %d\n", - fchan->span_id, fchan->chan_id, - fchan->physical_span_id, fchan->physical_chan_id, - flagval); - (*count)++; + if (!inchan_id || inchan_id == fchan->chan_id) { + if (not) { + if (!ftdm_test_flag(fchan, flag)) { + stream->write_function(stream, "[s%dc%d][%d:%d] flag !%d(!%s) ON \n", + fchan->span_id, fchan->chan_id, + fchan->physical_span_id, fchan->physical_chan_id, + flagval, channel_val2str(flagval)); + + mycount++; + } else { + stream->write_function(stream, "[s%dc%d][%d:%d] flag !%d(!%s) OFF \n", + fchan->span_id, fchan->chan_id, + fchan->physical_span_id, fchan->physical_chan_id, + flagval, channel_val2str(flagval)); + } + } else if (!not) { + if (ftdm_test_flag(fchan, flag)) { + stream->write_function(stream, "[s%dc%d][%d:%d] flag %d(%s) ON\n", + fchan->span_id, fchan->chan_id, + fchan->physical_span_id, fchan->physical_chan_id, + flagval, channel_val2str(flagval)); + + mycount++; + } else { + stream->write_function(stream, "[s%dc%d][%d:%d] flag %d(%s) OFF \n", + fchan->span_id, fchan->chan_id, + fchan->physical_span_id, fchan->physical_chan_id, + flagval, channel_val2str(flagval)); + } + } } } ftdm_iterator_free(citer); - } + } else { + for (i = hashtable_first(globals.span_hash); i; i = hashtable_next(i)) { + hashtable_this(i, &key, NULL, &val); + if (!key || !val) { + break; + } + span = val; + citer = ftdm_span_get_chan_iterator(span, NULL); + if (!citer) { + continue; + } + for (curr = citer ; curr; curr = ftdm_iterator_next(curr)) { + fchan = ftdm_iterator_current(curr); + if (not && !ftdm_test_flag(fchan, flag)) { + stream->write_function(stream, "[s%dc%d][%d:%d] has not flag %d\n", + fchan->span_id, fchan->chan_id, + fchan->physical_span_id, fchan->physical_chan_id, + flagval); + mycount++; + } else if (!not && ftdm_test_flag(fchan, flag)) { + stream->write_function(stream, "[s%dc%d][%d:%d] has flag %d\n", + fchan->span_id, fchan->chan_id, + fchan->physical_span_id, fchan->physical_chan_id, + flagval); + mycount++; + } + } + ftdm_iterator_free(citer); + } + } + *count = mycount; +end: ftdm_mutex_unlock(globals.mutex); } @@ -4434,12 +4481,88 @@ static void print_core_usage(ftdm_stream_handle_t *stream) { stream->write_function(stream, "--------------------------------------------------------------------------------\n" - "ftdm core state [!] - List all channels in or not in the given state\n" - "ftdm core flag - List all channels with the given flag value set\n" + "ftdm core state [!] - List all channels in or not in the given state\n" + "ftdm core flag [!] [] [] - List all channels with the given flag value set\n" "ftdm core calls - List all known calls to the FreeTDM core\n" "--------------------------------------------------------------------------------\n"); } +typedef struct channel_flags_str { + const char *name; + unsigned long long channel_flag; +} channel_flag_str_t; + +static channel_flag_str_t channel_flag_strs[] = { + { "configured" , FTDM_CHANNEL_CONFIGURED}, + { "ready", FTDM_CHANNEL_READY}, + { "open", FTDM_CHANNEL_OPEN}, + { "dtmf-detect", FTDM_CHANNEL_DTMF_DETECT}, + { "suppress-dtmf", FTDM_CHANNEL_SUPRESS_DTMF}, + { "transcode", FTDM_CHANNEL_TRANSCODE}, + { "buffer", FTDM_CHANNEL_BUFFER}, + { "in-thread", FTDM_CHANNEL_INTHREAD}, + { "wink", FTDM_CHANNEL_WINK}, + { "flash", FTDM_CHANNEL_FLASH}, + { "state-change", FTDM_CHANNEL_STATE_CHANGE}, + { "hold", FTDM_CHANNEL_HOLD}, + { "in-use", FTDM_CHANNEL_INUSE}, + { "off-hook", FTDM_CHANNEL_OFFHOOK}, + { "ringing", FTDM_CHANNEL_RINGING}, + { "progress-detect", FTDM_CHANNEL_PROGRESS_DETECT}, + { "callerid-detect", FTDM_CHANNEL_CALLERID_DETECT}, + { "outbound", FTDM_CHANNEL_OUTBOUND}, + { "suspended", FTDM_CHANNEL_SUSPENDED}, + { "3-way", FTDM_CHANNEL_3WAY}, + { "progress", FTDM_CHANNEL_PROGRESS}, + { "media", FTDM_CHANNEL_MEDIA}, + { "answered", FTDM_CHANNEL_ANSWERED}, + { "mute", FTDM_CHANNEL_MUTE}, + { "use-rx-gain", FTDM_CHANNEL_USE_RX_GAIN}, + { "use-tx-gain", FTDM_CHANNEL_USE_TX_GAIN}, + { "in-alarm", FTDM_CHANNEL_IN_ALARM}, + { "sig-up", FTDM_CHANNEL_SIG_UP}, + { "user-hangup", FTDM_CHANNEL_USER_HANGUP}, + { "rx-disabled", FTDM_CHANNEL_RX_DISABLED}, + { "tx-disabled", FTDM_CHANNEL_TX_DISABLED}, + { "call-started", FTDM_CHANNEL_CALL_STARTED}, + { "non-block", FTDM_CHANNEL_NONBLOCK}, + { "ind-ack-pending", FTDM_CHANNEL_IND_ACK_PENDING}, + { "blocking", FTDM_CHANNEL_BLOCKING}, + { "media", FTDM_CHANNEL_DIGITAL_MEDIA}, + { "native-sigbridge", FTDM_CHANNEL_NATIVE_SIGBRIDGE}, + { "invalid", FTDM_CHANNEL_MAX_FLAG}, +}; + +static unsigned long long channel_str2val(const char *flag_name) +{ + int i; + for (i = 0; i < ftdm_array_len(channel_flag_strs); i++) { + if (!strcasecmp(channel_flag_strs[i].name, flag_name)) { + return channel_flag_strs[i].channel_flag; + } + } + return FTDM_CHANNEL_MAX_FLAG; +} + +static const char *channel_val2str(unsigned long long flag) +{ + int i; + for (i = 0; i < ftdm_array_len(channel_flag_strs); i++) { + if (channel_flag_strs[i].channel_flag == flag) { + return channel_flag_strs[i].name; + } + } + return channel_flag_strs[FTDM_CHANNEL_MAX_FLAG].name; +} + +static void print_channel_flag_values(ftdm_stream_handle_t *stream) +{ + int i; + for (i = 0; i < ftdm_array_len(channel_flag_strs); i++) { + stream->write_function(stream, "%s\n", channel_flag_strs[i].name); + } +} + static char *handle_core_command(const char *cmd) { char *mycmd = NULL; @@ -4449,11 +4572,12 @@ static char *handle_core_command(const char *cmd) char *argv[10] = { 0 }; char *state = NULL; char *flag = NULL; - uint32_t flagval = 0; + unsigned long long flagval = 0; uint32_t current_call_id = 0; ftdm_caller_data_t *calldata = NULL; ftdm_channel_t *fchan = NULL; ftdm_channel_state_t i = FTDM_CHANNEL_STATE_INVALID; + ftdm_span_t *fspan = NULL; ftdm_stream_handle_t stream = { 0 }; FTDM_STANDARD_STREAM(stream); @@ -4494,6 +4618,7 @@ static char *handle_core_command(const char *cmd) print_channels_by_state(&stream, i, not, &count); stream.write_function(&stream, "\nTotal channels %s %s: %d\n", not ? "not in state" : "in state", ftdm_channel_state2str(i), count); } else if (!strcasecmp(argv[0], "flag")) { + uint32_t chan_id = 0; if (argc < 2) { stream.write_function(&stream, "core flag command requires an argument\n"); print_core_usage(&stream); @@ -4504,8 +4629,37 @@ static char *handle_core_command(const char *cmd) not = 1; flag++; } - flagval = atoi(flag); - print_channels_by_flag(&stream, flagval, not, &count); + + if (isalpha(flag[0])) { + flagval = channel_str2val(flag); + if (flagval == FTDM_CHANNEL_MAX_FLAG) { + stream.write_function(&stream, "\nInvalid channel flag value. Possible channel flags\n"); + print_channel_flag_values(&stream); + goto done; + } + } else { + flagval = atoi(flag); + } + + /* Specific span specified */ + if (argv[2]) { + ftdm_span_find_by_name(argv[2], &fspan); + if (!fspan) { + stream.write_function(&stream, "-ERR span:%s not found\n", argv[2]); + goto done; + } + } + + /* Specific channel specified */ + if (argv[3]) { + chan_id = atoi(argv[3]); + if (chan_id >= ftdm_span_get_chan_count(fspan)) { + stream.write_function(&stream, "-ERR invalid channel %d\n", chan_id); + goto done; + } + } + + print_channels_by_flag(&stream, fspan, chan_id, flagval, not, &count); stream.write_function(&stream, "\nTotal channels %s %d: %d\n", not ? "without flag" : "with flag", flagval, count); } else if (!strcasecmp(argv[0], "calls")) { ftdm_mutex_lock(globals.call_id_mutex); diff --git a/libs/freetdm/src/include/private/ftdm_types.h b/libs/freetdm/src/include/private/ftdm_types.h index 17e273c425..7df764e52f 100755 --- a/libs/freetdm/src/include/private/ftdm_types.h +++ b/libs/freetdm/src/include/private/ftdm_types.h @@ -268,6 +268,10 @@ typedef enum { /*!< Native signaling bridge is enabled */ #define FTDM_CHANNEL_NATIVE_SIGBRIDGE (1ULL << 37) +/*!< This no more flags after this flag */ +#define FTDM_CHANNEL_MAX_FLAG (1ULL << 38) +/*! Date: Wed, 20 Jun 2012 00:35:10 -0400 Subject: [PATCH 12/18] Changed megaco.conf.xml to media_gateway.conf.xml --- .../conf/media_gateway.conf.xml | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 src/mod/endpoints/mod_media_gateway/conf/media_gateway.conf.xml diff --git a/src/mod/endpoints/mod_media_gateway/conf/media_gateway.conf.xml b/src/mod/endpoints/mod_media_gateway/conf/media_gateway.conf.xml new file mode 100644 index 0000000000..91f8f0cc63 --- /dev/null +++ b/src/mod/endpoints/mod_media_gateway/conf/media_gateway.conf.xml @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + From 50e3e563da2a3e0ea795dcc2b226317749e8ab11 Mon Sep 17 00:00:00 2001 From: David Yat Sin Date: Wed, 20 Jun 2012 00:38:05 -0400 Subject: [PATCH 13/18] Updated conf --- .../conf/media_gateway.conf.xml | 74 ++++++++++++------- 1 file changed, 48 insertions(+), 26 deletions(-) mode change 100644 => 100755 src/mod/endpoints/mod_media_gateway/conf/media_gateway.conf.xml diff --git a/src/mod/endpoints/mod_media_gateway/conf/media_gateway.conf.xml b/src/mod/endpoints/mod_media_gateway/conf/media_gateway.conf.xml old mode 100644 new mode 100755 index 91f8f0cc63..aa314fbe5b --- a/src/mod/endpoints/mod_media_gateway/conf/media_gateway.conf.xml +++ b/src/mod/endpoints/mod_media_gateway/conf/media_gateway.conf.xml @@ -1,28 +1,50 @@ - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + - - + + + - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + From a54ec05fdbffd34097210abff84c27099e434dc1 Mon Sep 17 00:00:00 2001 From: David Yat Sin Date: Wed, 20 Jun 2012 02:06:31 -0400 Subject: [PATCH 14/18] fix for compilation error on 64-bit --- libs/freetdm/src/ftdm_io.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/freetdm/src/ftdm_io.c b/libs/freetdm/src/ftdm_io.c index bdb66c635a..4dca25e452 100644 --- a/libs/freetdm/src/ftdm_io.c +++ b/libs/freetdm/src/ftdm_io.c @@ -4552,7 +4552,7 @@ static const char *channel_val2str(unsigned long long flag) return channel_flag_strs[i].name; } } - return channel_flag_strs[FTDM_CHANNEL_MAX_FLAG].name; + return "invalid"; } static void print_channel_flag_values(ftdm_stream_handle_t *stream) From 31d48a8c3af263a0f6133c874d15cf53420bba29 Mon Sep 17 00:00:00 2001 From: kapil Date: Wed, 20 Jun 2012 12:01:04 +0530 Subject: [PATCH 15/18] adding "<>" or "[]" from the code itself , instead of passing from config xml for MID field --- .../mod_media_gateway/media_gateway_xml.c | 60 +++++++++++++++++++ 1 file changed, 60 insertions(+) diff --git a/src/mod/endpoints/mod_media_gateway/media_gateway_xml.c b/src/mod/endpoints/mod_media_gateway/media_gateway_xml.c index 2d584ed0ed..ba5c20aabb 100644 --- a/src/mod/endpoints/mod_media_gateway/media_gateway_xml.c +++ b/src/mod/endpoints/mod_media_gateway/media_gateway_xml.c @@ -12,6 +12,7 @@ static switch_xml_config_item_t *get_instructions(megaco_profile_t *profile) ; static switch_xml_config_item_t *get_peer_instructions(mg_peer_profile_t *profile) ; static int mg_sap_id; +static switch_status_t modify_mid(char* mid); /****************************************************************************************************************************/ switch_status_t config_profile(megaco_profile_t *profile, switch_bool_t reload) @@ -57,6 +58,10 @@ switch_status_t config_profile(megaco_profile_t *profile, switch_bool_t reload) profile->total_peers++; } + if(SWITCH_STATUS_FALSE == (status = modify_mid(profile->mid))){ + goto done; + } + profile->idx = ++mg_sap_id; /* we should break from here , profile name should be unique */ @@ -92,6 +97,10 @@ switch_status_t config_profile(megaco_profile_t *profile, switch_bool_t reload) goto done; } + if(SWITCH_STATUS_FALSE == (status = modify_mid(peer_profile->mid))){ + goto done; + } + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO,"peer_profile name[%s], ipaddr[%s] port[%s], mid[%s] transport_type[%s], encoding_type[%s] \n", peer_profile->name, peer_profile->ipaddr, peer_profile->port,peer_profile->mid, peer_profile->transport_type, peer_profile->encoding_type); @@ -190,3 +199,54 @@ static switch_xml_config_item_t *get_instructions(megaco_profile_t *profile) { } /****************************************************************************************************************************/ + +static switch_status_t modify_mid(char* mid) +{ + char* dup = NULL; + char* val[10]; + int count; + + switch_assert(mid); + + /* If MID type is IP then add mid into [] brackets , + * If MID type is domain then add mid into <> brackets * + */ + + dup = strdup(mid); + count = switch_split(dup, '.', val); + + if(!count) { + /* Input string is not separated by '.', check if its separated by '-' as format could be xxx-xx-xxx/xxx-xx-xx-xxx */ + free(dup); + dup = strdup(mid); + if(0 == (count = switch_split(dup, '-', val))){ + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid input MID string[%s]\n",mid); + return SWITCH_STATUS_FALSE; + } + } + + if(('<' == val[0][0]) || ('[' == val[0][0])){ + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "MID[%s] is already prefixed with proper brackets \n",mid); + return SWITCH_STATUS_SUCCESS; + } + + /*first check could be if count is 3 means domain name as generally we have xxx-xx-xxx/xxx.xx.xxx domain */ + if(3 == count){ + /* domain-type, add value into <> */ + free(dup); + dup = strdup(mid); + sprintf(mid,"<%s>",dup); + }else if(4 == count){ + /* IP address in xxx.xxx.xxx.xxx format */ + free(dup); + dup = strdup(mid); + sprintf(mid,"[%s]",dup); + }else { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid input MID string[%s]\n",mid); + return SWITCH_STATUS_FALSE; + } + + + free(dup); + return SWITCH_STATUS_SUCCESS; +} From 2512694e4313f4491a795c28bb010cbca0c9a8b6 Mon Sep 17 00:00:00 2001 From: kapil Date: Wed, 20 Jun 2012 12:12:28 +0530 Subject: [PATCH 16/18] removing warnings --- .../ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_cli.c | 12 ++---------- 1 file changed, 2 insertions(+), 10 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 b8cc34480f..594fdb97ad 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 @@ -3167,11 +3167,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_peer[peer_id].name); len = len + sprintf(buf + len," %s \n", PRNT_M2UA_PEER_STATE(cfm.t.ssta.s.peerSta.state)); len = len + sprintf(buf + len, " %d \n",cfm.t.ssta.s.peerSta.retryCount); -#ifdef BIT_64 - len = len + sprintf(buf + len, " %d \n", (int64_t) cfm.t.ssta.s.peerSta.assocSta.spAssocId); -#else - len = len + sprintf(buf + len, " %lld \n", (int64_t) cfm.t.ssta.s.peerSta.assocSta.spAssocId); -#endif + len = len + sprintf(buf + len, " %d \n", (int)cfm.t.ssta.s.peerSta.assocSta.spAssocId); len = len + sprintf(buf + len, " %s \n",(cfm.t.ssta.s.peerSta.assocSta.connected)?"CONNECTED":"NOT CONNECTED"); len = len + sprintf(buf + len, " %d \n",cfm.t.ssta.s.peerSta.assocSta.flcInProg); len = len + sprintf(buf + len, " %d \n",cfm.t.ssta.s.peerSta.assocSta.flcLevel); @@ -3197,11 +3193,7 @@ static ftdm_status_t handle_show_m2ua_profiles(ftdm_stream_handle_t *stream) len = len + sprintf(buf + len, "\n"); len = len + sprintf(buf + len," %s \n", PRNT_M2UA_SAP_STATE(cfm.t.ssta.s.sctSapSta.state)); len = len + sprintf(buf + len," %s \n", (cfm.t.ssta.s.sctSapSta.endpOpen)?"END_POINT_OPENED_SUCCESSFULLY":"END_POINT_NOT_OPEN"); -#ifdef BIT_64 - len = len + sprintf(buf + len," %d \n", (int64_t) cfm.t.ssta.s.sctSapSta.spEndpId); -#else - len = len + sprintf(buf + len," %lld \n", (int64_t) cfm.t.ssta.s.sctSapSta.spEndpId); -#endif + len = len + sprintf(buf + len," %d \n", (int) cfm.t.ssta.s.sctSapSta.spEndpId); len = len + sprintf(buf + len," %d \n", cfm.t.ssta.s.sctSapSta.nmbPrimRetry); len = len + sprintf(buf + len, "\n"); } From 7b97ff470f21c7e2afcacfce16767acdf602120f Mon Sep 17 00:00:00 2001 From: kapil Date: Wed, 20 Jun 2012 13:53:51 +0530 Subject: [PATCH 17/18] 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; } /****************************************************************************************************/ From eae74df4e680a2e465512a59fbe8743a2c788b3b Mon Sep 17 00:00:00 2001 From: Mathieu Rene Date: Wed, 20 Jun 2012 12:02:10 -0400 Subject: [PATCH 18/18] change loglevels and enable debug --- src/mod/endpoints/mod_media_gateway/media_gateway_stack.c | 2 ++ src/mod/endpoints/mod_media_gateway/mod_media_gateway.c | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/mod/endpoints/mod_media_gateway/media_gateway_stack.c b/src/mod/endpoints/mod_media_gateway/media_gateway_stack.c index abe46a5837..37fdabfda5 100644 --- a/src/mod/endpoints/mod_media_gateway/media_gateway_stack.c +++ b/src/mod/endpoints/mod_media_gateway/media_gateway_stack.c @@ -255,6 +255,8 @@ switch_status_t sng_mgco_start(megaco_profile_t* profile ) switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, " mgco_mg_tsap_enable_cntrl SUCCESS \n"); } + mgco_mg_enble_debug(); + return SWITCH_STATUS_SUCCESS; } diff --git a/src/mod/endpoints/mod_media_gateway/mod_media_gateway.c b/src/mod/endpoints/mod_media_gateway/mod_media_gateway.c index 58a8794fad..026151a6f2 100644 --- a/src/mod/endpoints/mod_media_gateway/mod_media_gateway.c +++ b/src/mod/endpoints/mod_media_gateway/mod_media_gateway.c @@ -116,14 +116,14 @@ void handle_sng_log(uint8_t level, char *fmt, ...) case SNG_LOGLEVEL_DEBUG: log_level = SWITCH_LOG_DEBUG; break; case SNG_LOGLEVEL_INFO: log_level = SWITCH_LOG_INFO; break; case SNG_LOGLEVEL_WARN: log_level = SWITCH_LOG_WARNING; break; - case SNG_LOGLEVEL_ERROR: log_level = SWITCH_LOG_ERROR; break; + case SNG_LOGLEVEL_ERROR: log_level = SWITCH_LOG_DEBUG; break; case SNG_LOGLEVEL_CRIT: log_level = SWITCH_LOG_CRIT; break; default: log_level = SWITCH_LOG_DEBUG; break; }; vsprintf(&print_buf[0], fmt, ptr); - switch_log_printf(SWITCH_CHANNEL_LOG, log_level, " MOD_MEGACO: %s \n", &print_buf[0]); + switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, log_level, " MOD_MEGACO: %s \n", &print_buf[0]); va_end(ptr); }