]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
fixing cli issues
authorkapil <kgupta@sangoma.com>
Thu, 14 Jun 2012 10:10:57 +0000 (15:40 +0530)
committerkapil <kgupta@sangoma.com>
Thu, 14 Jun 2012 10:10:57 +0000 (15:40 +0530)
libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_cli.c
libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_m2ua.c
libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_m2ua.h
libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_main.h

index 6fece294ccd6b05a72101a8649906f8b3c57592f..8c76bb6f125e9ee896cba52f5ab4e12206304bf5 100644 (file)
@@ -403,8 +403,8 @@ ftdm_status_t ftdm_sngss7_handle_cli_cmd(ftdm_stream_handle_t *stream, const cha
        /**************************************************************************/
 
                if (check_arg_count(argc, 2)) {
-                       cli_ss7_show_general(stream); 
-                       return FTDM_SUCCESS;
+                       stream->write_function(stream, "Unknown \"xmlshow\" command\n");
+                       goto handle_cli_error;
                }
                c++;
        /**************************************************************************/
@@ -3071,7 +3071,7 @@ static ftdm_status_t cli_ss7_show_all_spans_general(ftdm_stream_handle_t *stream
 static ftdm_status_t handle_show_m2ua_profiles(ftdm_stream_handle_t *stream)
 {
        char*  xmlhdr = (char*)"<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>";
-       char  buf[2048];
+       char  buf[6144];
        int x = 0x00;
        int idx = 0x00;
        int len = 0x00;
@@ -3105,6 +3105,7 @@ static ftdm_status_t handle_show_m2ua_profiles(ftdm_stream_handle_t *stream)
                                 (!(g_ftdm_sngss7_data.cfg.g_m2ua_cfg.m2ua[x].flags & SNGSS7_CONFIGURED))) {
 
                         len = len + sprintf(buf + len, "<m2ua_profile>\n");
+                        len = len + sprintf(buf + len, "<name> %s </name>\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");
@@ -3164,17 +3165,17 @@ static ftdm_status_t handle_show_m2ua_profiles(ftdm_stream_handle_t *stream)
                                 }
                         }
 
-                        if(ftmod_m2ua_ssta_req(STMWSCTSAP,x,&cfm)) {
-                                stream->write_function(stream," Request to Trillium SCTP layer failed \n");
-                                return FTDM_FAIL;
-                        } else {
-                                len = len + sprintf(buf + len, "<m2ua_sctp_sap>\n");
-                                len = len + sprintf(buf + len," <state> %s </state>\n", PRNT_M2UA_SAP_STATE(cfm.t.ssta.s.sctSapSta.state));
-                                len = len + sprintf(buf + len," <end_point_open_state> %s </end_point_open_state>\n", (cfm.t.ssta.s.sctSapSta.endpOpen)?"END_POINT_OPENED_SUCCESSFULLY":"END_POINT_NOT_OPEN");
-                                len = len + sprintf(buf + len," <end_point_id> %d </end_point_id>\n", cfm.t.ssta.s.sctSapSta.spEndpId);
-                                len = len + sprintf(buf + len," <nmb_of_retry_attemp> %d </nmb_of_retry_attemp>\n", cfm.t.ssta.s.sctSapSta.nmbPrimRetry);
-                                len = len + sprintf(buf + len, "</m2ua_sctp_sap>\n");
-                        }
+                                if(ftmod_m2ua_ssta_req(STMWSCTSAP,x,&cfm)) {
+                                        stream->write_function(stream," Request to Trillium SCTP layer failed \n");
+                                        return FTDM_FAIL;
+                                } else {
+                                        len = len + sprintf(buf + len, "<m2ua_sctp_sap>\n");
+                                        len = len + sprintf(buf + len," <state> %s </state>\n", PRNT_M2UA_SAP_STATE(cfm.t.ssta.s.sctSapSta.state));
+                                        len = len + sprintf(buf + len," <end_point_open_state> %s </end_point_open_state>\n", (cfm.t.ssta.s.sctSapSta.endpOpen)?"END_POINT_OPENED_SUCCESSFULLY":"END_POINT_NOT_OPEN");
+                                        len = len + sprintf(buf + len," <end_point_id> %d </end_point_id>\n", cfm.t.ssta.s.sctSapSta.spEndpId);
+                                        len = len + sprintf(buf + len," <nmb_of_retry_attemp> %d </nmb_of_retry_attemp>\n", cfm.t.ssta.s.sctSapSta.nmbPrimRetry);
+                                        len = len + sprintf(buf + len, "</m2ua_sctp_sap>\n");
+                                }
 
                         len = len + sprintf(buf + len, "</m2ua_profile>\n");
                 }
@@ -3199,7 +3200,7 @@ 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) 
 {
        char*  xmlhdr = (char*)"<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>";
-       char  buf[2048];
+       char  buf[4096];
        int x = 0x00;
        int idx = 0x00;
        int found = 0x00;
@@ -3234,6 +3235,7 @@ static ftdm_status_t handle_show_m2ua_profile(ftdm_stream_handle_t *stream, char
 
 
        len = len + sprintf(buf + len, "<m2ua_profile>\n");
+       len = len + sprintf(buf + len, "<name> %s </name>\n", m2ua_profile_name);
 
        if(ftmod_m2ua_ssta_req(STMWDLSAP,x,&cfm)) {
                stream->write_function(stream," Request to Trillium SCTP layer failed \n");
@@ -3248,7 +3250,7 @@ static ftdm_status_t handle_show_m2ua_profile(ftdm_stream_handle_t *stream, char
                len = len + sprintf(buf + len, "</m2ua_dlsap>\n");
        }
 
-       if(ftmod_m2ua_ssta_req(STMWCLUSTER,x,&cfm)) {
+       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;
        } else {
@@ -3323,7 +3325,7 @@ static ftdm_status_t handle_show_m2ua_profile(ftdm_stream_handle_t *stream, char
 static ftdm_status_t handle_show_sctp_profiles(ftdm_stream_handle_t *stream)
 {
        char*  xmlhdr = (char*)"<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>";
-       char  buf[2048];
+       char  buf[4096];
        int x = 0x00;
        int len = 0x00;
        SbMgmt cfm;
@@ -3402,8 +3404,14 @@ static ftdm_status_t handle_show_sctp_profiles(ftdm_stream_handle_t *stream)
                        }
 
                        if(ftmod_sctp_ssta_req(STSBASSOC,x,&cfm)) {
-                               stream->write_function(stream," Request to Trillium SCTP layer failed \n");
-                               return FTDM_FAIL;
+                               if(LCM_REASON_INVALID_PAR_VAL == cfm.cfm.reason){
+                                       len = len + sprintf(buf + len, "<sctp_association>\n");
+                                       len = len + sprintf(buf + len, " <status> SCT_ASSOC_STATE_CLOSED </status>\n");
+                                       len = len + sprintf(buf + len, "</sctp_association>\n");
+                               }else{
+                                       stream->write_function(stream," Request to Trillium SCTP layer failed \n");
+                                       return FTDM_FAIL;
+                               }
                        } else {
                                len = len + sprintf(buf + len, "<sctp_association>\n");
                                len = len + get_assoc_resp_buf(buf + len, &cfm);
@@ -3535,7 +3543,7 @@ int get_assoc_resp_buf(char* buf,SbMgmt* cfm)
 static ftdm_status_t handle_show_sctp_profile(ftdm_stream_handle_t *stream, char* sctp_profile_name)
 {
        char*  xmlhdr = (char*)"<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>";
-       char  buf[2048];
+       char  buf[4096];
        int x = 0x00;
        int len = 0x00;
        SbMgmt cfm;
@@ -3586,8 +3594,15 @@ static ftdm_status_t handle_show_sctp_profile(ftdm_stream_handle_t *stream, char
        }
 
        if(ftmod_sctp_ssta_req(STSBASSOC,x,&cfm)) {
-               stream->write_function(stream," Request to Trillium SCTP layer failed \n");
-               return FTDM_FAIL;
+               /* it means assoc id not yet allocated */
+               if(LCM_REASON_INVALID_PAR_VAL == cfm.cfm.reason){
+                       len = len + sprintf(buf + len, "<sctp_association>\n");
+                       len = len + sprintf(buf + len, " <status> SCT_ASSOC_STATE_CLOSED </status>\n");
+                       len = len + sprintf(buf + len, "</sctp_association>\n");
+               }else{
+                       stream->write_function(stream," Request to Trillium SCTP layer failed \n");
+                       return FTDM_FAIL;
+               }
        } else {
                len = len + sprintf(buf + len, "<sctp_association>\n");
                len = len + get_assoc_resp_buf(buf + len, &cfm);
@@ -3613,7 +3628,7 @@ static ftdm_status_t handle_show_sctp_profile(ftdm_stream_handle_t *stream, char
 static ftdm_status_t handle_show_nif_profiles(ftdm_stream_handle_t *stream)
 {
        char*  xmlhdr = (char*)"<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>";
-       char  buf[2048];
+       char  buf[4096];
        int x = 0x00;
        int len = 0x00;
        NwMgmt cfm;
@@ -3674,7 +3689,7 @@ 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* nif_profile_name) 
 {
        char*  xmlhdr = (char*)"<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>";
-       char  buf[2048];
+       char  buf[4096];
        int x = 0x00;
        int found = 0x00;
        int len = 0x00;
@@ -3737,7 +3752,7 @@ static ftdm_status_t handle_show_nif_profile(ftdm_stream_handle_t *stream, char*
 static ftdm_status_t handle_show_m2ua_peer_status(ftdm_stream_handle_t *stream, char* m2ua_profile_name) 
 {
        char*  xmlhdr = (char*)"<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>";
-       char  buf[2048];
+       char  buf[4096];
        int x = 0x00;
        int found = 0x00;
        int len = 0x00;
index 0639165e978d8d263c32c92bcdd2fdfd377724c8..a5ff80a63611651a2fbc44405f47f501ad2b59c2 100644 (file)
@@ -51,7 +51,7 @@ static int ftmod_sctp_config(int id);
 static ftdm_status_t ftmod_sctp_sap_config(int id);
 static ftdm_status_t ftmod_sctp_tsap_config(int id);
 static int ftmod_m2ua_gen_config(void);
-static int ftmod_m2ua_sctsap_config(int m2ua_inf_id, int sctp_id);
+static int ftmod_m2ua_sctsap_config(int sct_sap_id, int sctp_id);
 static int ftmod_m2ua_peer_config(int id);
 static int ftmod_m2ua_peer_config1(int m2ua_inf_id, int peer_id);
 static int ftmod_m2ua_cluster_config(int idx);
@@ -782,6 +782,14 @@ static int ftmod_m2ua_peer_config(int id)
        sng_m2ua_cluster_cfg_t*     clust = &g_ftdm_sngss7_data.cfg.g_m2ua_cfg.m2ua_clus[m2ua->clusterId];
        sng_m2ua_peer_cfg_t*        peer  = NULL;
 
+       if((clust->flags & SNGSS7_CONFIGURED)){
+               ftdm_log (FTDM_LOG_INFO, " ftmod_m2ua_peer_config: Cluster [%s] is already configured \n", clust->name);
+               return 0x00;
+       }
+
+       /*NOTE : SCTSAP is based on per source address , so if we have same Cluster / peer shared across many <m2ua_interface> then 
+        * we dont have do configuration for each time */
+
        /* loop through peer list from cluster to configure SCTSAP */
 
        for(x = 0; x < clust->numOfPeers;x++){
@@ -800,13 +808,18 @@ static int ftmod_m2ua_peer_config(int id)
                        ftdm_log (FTDM_LOG_INFO, " ftmod_m2ua_peer_config1: M2UA Peer configuration for M2UA Intf Id[%d] config SUCCESS \n", id);
                }
 
+               clust->sct_sap_id = id;
 
+               /* set configured flag for cluster and peer */
+               clust->flags |= SNGSS7_CONFIGURED;
+               peer->flags |= SNGSS7_CONFIGURED;
        }
 
        return 0x0;;
 }
 
-static int ftmod_m2ua_sctsap_config(int m2ua_inf_id, int sctp_id)
+
+static int ftmod_m2ua_sctsap_config(int sct_sap_id, int sctp_id)
 {
    int    i;
    Pst    pst; 
@@ -836,7 +849,7 @@ static int ftmod_m2ua_sctsap_config(int m2ua_inf_id, int sctp_id)
    cfg.t.cfg.s.sctSapCfg.reConfig.selector     = 0;
 
    /* service user SAP ID */
-   cfg.t.cfg.s.sctSapCfg.suId                   = m2ua_inf_id;
+   cfg.t.cfg.s.sctSapCfg.suId                   = sct_sap_id;
    /* service provider ID   */
    cfg.t.cfg.s.sctSapCfg.spId                   = sctp_id;
    /* source port number */
@@ -1275,7 +1288,7 @@ int ftmod_ss7_m2ua_start(void){
        x = 1;
        while (x < (MW_MAX_NUM_OF_PEER)) {
                if ((g_ftdm_sngss7_data.cfg.g_m2ua_cfg.m2ua_peer[x].id !=0) &&
-                               (!(g_ftdm_sngss7_data.cfg.g_m2ua_cfg.m2ua_peer[x].flags & SNGSS7_CONFIGURED)) && 
+                               ((g_ftdm_sngss7_data.cfg.g_m2ua_cfg.m2ua_peer[x].flags & SNGSS7_CONFIGURED)) && 
                                (g_ftdm_sngss7_data.cfg.g_m2ua_cfg.m2ua_peer[x].init_sctp_assoc)) {
                        if(ftmod_init_sctp_assoc(x)) {
                                ftdm_log (FTDM_LOG_ERROR ,"ftmod_init_sctp_assoc FAIL for peerId[%d] \n", x);
@@ -1296,9 +1309,16 @@ int ftmod_ss7_m2ua_start(void){
 
 static int ftmod_open_endpoint(int id)
 {
+       int ret = 0x00;
        Pst pst;
        MwMgmt cntrl;  
        sng_m2ua_cfg_t* m2ua  = &g_ftdm_sngss7_data.cfg.g_m2ua_cfg.m2ua[id];
+       sng_m2ua_cluster_cfg_t*     clust = &g_ftdm_sngss7_data.cfg.g_m2ua_cfg.m2ua_clus[m2ua->clusterId];
+
+       if(clust->flags & SNGSS7_M2UA_EP_OPENED) {
+               ftdm_log (FTDM_LOG_INFO ," END-POINT already opened\n");
+               return ret;
+       }
 
        memset((U8 *)&pst, 0, sizeof(Pst));
        memset((U8 *)&cntrl, 0, sizeof(MwMgmt));
@@ -1324,7 +1344,12 @@ static int ftmod_open_endpoint(int id)
        cntrl.t.cntrl.action = AMWENDPOPEN;
        cntrl.t.cntrl.s.suId = m2ua->id; /* M2UA sct sap Id */
 
-       return (sng_cntrl_m2ua (&pst, &cntrl));
+       
+       if(0 == (ret = sng_cntrl_m2ua (&pst, &cntrl))){
+               clust->flags |= SNGSS7_M2UA_EP_OPENED;
+       }
+       return ret;
+
 }
 
 /***********************************************************************************************************************/
@@ -1400,9 +1425,17 @@ static int ftmod_sctp_tucl_tsap_bind(int id)
 
 static int ftmod_m2ua_sctp_sctsap_bind(int id)
 {
+  int ret = 0x00;
   Pst pst;
   MwMgmt cntrl;  
   sng_m2ua_cfg_t* m2ua  = &g_ftdm_sngss7_data.cfg.g_m2ua_cfg.m2ua[id];
+  sng_m2ua_cluster_cfg_t*     clust = &g_ftdm_sngss7_data.cfg.g_m2ua_cfg.m2ua_clus[m2ua->clusterId];
+
+  if(clust->flags & SNGSS7_ACTIVE) {
+         ftdm_log (FTDM_LOG_INFO ," SCT-SAP is already enabled\n");
+         return ret;
+  }
+
 
   memset((U8 *)&pst, 0, sizeof(Pst));
   memset((U8 *)&cntrl, 0, sizeof(MwMgmt));
@@ -1427,8 +1460,10 @@ static int ftmod_m2ua_sctp_sctsap_bind(int id)
    cntrl.t.cntrl.action = ABND;
    cntrl.t.cntrl.s.suId = m2ua->id;
 
-     return (sng_cntrl_m2ua (&pst, &cntrl));
-
+   if(0 == (ret = sng_cntrl_m2ua (&pst, &cntrl))){
+          clust->flags |= SNGSS7_ACTIVE;
+   }
+   return ret;
 }   
 /***********************************************************************************************************************/
 static int ftmod_nif_m2ua_dlsap_bind(int id)
@@ -1668,7 +1703,8 @@ int ftmod_m2ua_ssta_req(int elemt, int id, MwMgmt* cfm)
           case STMWSCTSAP:
                 {
                   m2ua  = &g_ftdm_sngss7_data.cfg.g_m2ua_cfg.m2ua[id];
-                   ssta.t.ssta.id.suId = m2ua->id ; /* lower sap Id */            
+                  clust = &g_ftdm_sngss7_data.cfg.g_m2ua_cfg.m2ua_clus[m2ua->clusterId];
+                   ssta.t.ssta.id.suId = clust->sct_sap_id ; /* lower sap Id */            
                    break;
                 }       
           case STMWDLSAP:
index 2b44426102471d640da5833cde94c7fca2fdba7f..8e22e47b978caf21f612d91baa44314d44807f43 100644 (file)
@@ -96,6 +96,7 @@ typedef struct sng_m2ua_cluster_cfg{
        char                     name[MAX_NAME_LEN];
        uint32_t                 flags;
        uint32_t                 id;            /* ID */
+       uint32_t                 sct_sap_id;   /* Internal - sct_sap_id */
        uint8_t                  trfMode;       /* Traffic mode. This parameter defines the mode in which this m2ua cluster is supposed to work */ 
        uint8_t                  loadShareAlgo; /* This parameter defines the M2UA load share algorithm which is used to distribute the traffic */ 
        uint16_t                 numOfPeers;    /* idx to m2ua_peer profile */
index 63e146c029919c9079a01430c8b983d1f2e2770e..0e52f88710d26c26c47455f5bb1be67a148d818e 100644 (file)
@@ -767,9 +767,10 @@ typedef enum {
 
        SNGSS7_M2UA_PRESENT      = (1 << 18),
        SNGSS7_M2UA_STARTED      = (1 << 19),
+       SNGSS7_M2UA_EP_OPENED    = (1 << 20),
 
-       SNGSS7_NIF_PRESENT       = (1 << 20),
-       SNGSS7_NIF_STARTED       = (1 << 21),
+       SNGSS7_NIF_PRESENT       = (1 << 21),
+       SNGSS7_NIF_STARTED       = (1 << 22),
 
 } sng_task_flag_t;
 /******************************************************************************/