提交 8de2568c authored 作者: David Yat Sin's avatar David Yat Sin

Merge branch 'nsg-4.3' of ssh://git.sangoma.com/smg_freeswitch into nsg-4.3

Conflicts:
	build/modules.conf.in
......@@ -199,3 +199,6 @@ src/mod/formats/mod_shout/*/*/mod_shout.log
/src/mod/languages/mod_managed/x64/Release_CLR/FREESWITCH.MANAGED.DLL.metagen
/src/mod/languages/mod_managed/x64/Release_CLR/RSAENH.DLL.bi
/src/mod/languages/mod_managed/x64/Release_CLR/TZRES.DLL.bi
src/include/switch_apr.h
.gitignore
\ No newline at end of file
......@@ -11,4 +11,3 @@ endpoints/mod_sofia
xml_int/mod_xml_cdr
event_handlers/mod_event_socket
codecs/mod_sangoma_codec
......@@ -60,7 +60,7 @@
<load module="mod_g723_1"/>
<load module="mod_g729"/>
<load module="mod_amr"/>
<load module="mod_ilbc"/>
<!-- <load module="mod_ilbc"/> -->
<load module="mod_speex"/>
<load module="mod_h26x"/>
<!--<load module="mod_siren"/>-->
......
......@@ -80,7 +80,7 @@
<load module="mod_g723_1"/>
<load module="mod_g729"/>
<load module="mod_amr"/>
<load module="mod_ilbc"/>
<!-- <load module="mod_ilbc"/> -->
<load module="mod_speex"/>
<load module="mod_h26x"/>
<load module="mod_siren"/>
......
......@@ -109,7 +109,7 @@ static switch_call_cause_t channel_outgoing_channel(switch_core_session_t *sessi
ftdm_codec_t codec;
uint32_t interval;
ctdm_private_t *tech_pvt;
ctdm_private_t *tech_pvt = NULL;
if (zstr(szchanid) || zstr(szspanid)) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Both "kSPAN_ID" and "kCHAN_ID" have to be set.\n");
......
......@@ -773,7 +773,8 @@ typedef gid_t switch_gid_t;
typedef ino_t switch_ino_t;
typedef dev_t switch_dev_t;
#endif
typedef off64_t switch_off_t;
typedef off_t switch_off_t;
/**
* Structure for referencing file information
......
......@@ -107,6 +107,21 @@ switch_status_t megaco_profile_destroy(megaco_profile_t **profile)
return SWITCH_STATUS_SUCCESS;
}
switch_status_t megaco_peer_profile_destroy(mg_peer_profile_t **profile)
{
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Stopping peer profile: %s\n", (*profile)->name);
switch_core_hash_delete_wrlock(megaco_globals.peer_profile_hash, (*profile)->name, megaco_globals.peer_profile_rwlock);
mg_peer_config_cleanup(*profile);
switch_core_destroy_memory_pool(&(*profile)->pool);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Stopped peer profile: %s\n", (*profile)->name);
return SWITCH_STATUS_SUCCESS;
}
/* For Emacs:
* Local Variables:
* mode:c
......
......@@ -138,6 +138,7 @@ done:
switch_status_t megaco_profile_peer_xmlstatus(switch_stream_handle_t *stream, megaco_profile_t* mg_cfg)
{
int idx = 0x00;
int peerIdx = 0x00;
int len = 0x00;
MgMngmt cfm;
char* xmlhdr = "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>";
......@@ -152,22 +153,23 @@ switch_status_t megaco_profile_peer_xmlstatus(switch_stream_handle_t *stream, me
memset((U8 *)&cfm, 0, sizeof(cfm));
memset((char *)&prntBuf, 0, sizeof(prntBuf));
mg_peer = megaco_peer_profile_locate(mg_cfg->peer_list[0]);
idx = mg_cfg->idx;
if(!mg_peer){
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR," No MG peer configuration found for peername[%s] against profilename[%s]\n",mg_cfg->peer_list[0],mg_cfg->name);
return SWITCH_STATUS_FALSE;
}
len = len + sprintf(&prntBuf[0] + len,"%s\n",xmlhdr);
len = len + sprintf(&prntBuf[0] + len,"<mg_peers>\n");
idx = mg_cfg->idx;
for(peerIdx =0; peerIdx < mg_cfg->total_peers; peerIdx++){
len = len + sprintf(&prntBuf[0] + len,"%s\n",xmlhdr);
mg_peer = megaco_peer_profile_locate(mg_cfg->peer_list[peerIdx]);
len = len + sprintf(&prntBuf[0] + len,"<mg_peer>\n");
len = len + sprintf(&prntBuf[0] + len,"<name>%s</name>\n",mg_cfg->peer_list[0]);
if(!mg_peer){
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR," No MG peer configuration found for peername[%s] against profilename[%s]\n",mg_cfg->peer_list[peerIdx],mg_cfg->name);
return SWITCH_STATUS_FALSE;
}
/* TODO - as of now supporting only one peer .. need to add logic to iterate through all the peers associated with this profile..*/
len = len + sprintf(&prntBuf[0] + len,"<mg_peer>\n");
len = len + sprintf(&prntBuf[0] + len,"<name>%s</name>\n",mg_peer->name);
/* send request to MEGACO Trillium stack to get peer information*/
sng_mgco_mg_get_status(STGCPENT, &cfm, mg_cfg, mg_peer);
......@@ -179,6 +181,9 @@ switch_status_t megaco_profile_peer_xmlstatus(switch_stream_handle_t *stream, me
len = len + sprintf(prntBuf+len, "<peer_state>%s</peer_state>\n",PRNT_MG_PEER_STATE(cfm.t.ssta.s.mgPeerSta.peerState));
len = len + sprintf(&prntBuf[0] + len,"</mg_peer>\n");
}
len = len + sprintf(&prntBuf[0] + len,"</mg_peers>\n");
stream->write_function(stream, "\n%s\n",&prntBuf[0]);
......@@ -190,6 +195,7 @@ switch_status_t megaco_profile_peer_xmlstatus(switch_stream_handle_t *stream, me
switch_status_t megaco_profile_xmlstatus(switch_stream_handle_t *stream, megaco_profile_t* mg_cfg)
{
int idx = 0x00;
int peerIdx = 0x00;
int len = 0x00;
MgMngmt cfm;
char* xmlhdr = "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>";
......@@ -204,12 +210,6 @@ switch_status_t megaco_profile_xmlstatus(switch_stream_handle_t *stream, megaco_
memset((U8 *)&cfm, 0, sizeof(cfm));
memset((char *)&prntBuf, 0, sizeof(prntBuf));
mg_peer = megaco_peer_profile_locate(mg_cfg->peer_list[0]);
if(!mg_peer){
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR," No MG peer configuration found for peername[%s] against profilename[%s]\n",mg_cfg->peer_list[0],mg_cfg->name);
return SWITCH_STATUS_FALSE;
}
idx = mg_cfg->idx;
......@@ -221,9 +221,17 @@ switch_status_t megaco_profile_xmlstatus(switch_stream_handle_t *stream, megaco_
/****************************************************************************************************************/
/* Print Peer Information ***************************************************************************************/
/* TODO - as of now supporting only one peer .. need to add logic to iterate through all the peers associated with this profile..*/
len = len + sprintf(&prntBuf[0] + len,"<mg_peers>\n");
for(peerIdx =0; peerIdx < mg_cfg->total_peers; peerIdx++){
mg_peer = megaco_peer_profile_locate(mg_cfg->peer_list[peerIdx]);
if(!mg_peer){
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR," No MG peer configuration found for peername[%s] against profilename[%s]\n",mg_cfg->peer_list[peerIdx],mg_cfg->name);
return SWITCH_STATUS_FALSE;
}
len = len + sprintf(&prntBuf[0] + len,"<mg_peer name=%s>\n",mg_peer->name);
/* send request to MEGACO Trillium stack to get peer information*/
......@@ -232,6 +240,7 @@ switch_status_t megaco_profile_xmlstatus(switch_stream_handle_t *stream, megaco_
get_peer_xml_buffer(&prntBuf[0] + len, &cfm.t.ssta.s.mgPeerSta);
len = len + sprintf(&prntBuf[0] + len,"</mg_peer>\n");
}
len = len + sprintf(&prntBuf[0] + len,"</mg_peers>\n");
......
......@@ -183,7 +183,6 @@ switch_status_t sng_mgco_cfg(megaco_profile_t* profile)
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO," mgco_mu_ssap_config SUCCESS \n");
}
if(mgco_mg_tsap_config(profile)) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR," mgco_mg_tsap_config FAILED \n");
return SWITCH_STATUS_FALSE;
......@@ -783,6 +782,8 @@ int mgco_mg_gen_config(void)
cfg->noEDInst = 1;
#endif /* CM_ABNF_MT_LIB */
cfg->entType = LMG_ENT_GW;
#ifdef GCP_CH
cfg->numBinsPeerCmdHl = 20;
cfg->numBinsTransReqHl = 50;
......@@ -944,6 +945,8 @@ int mgco_mg_ssap_config(megaco_profile_t* profile)
return SWITCH_STATUS_FALSE;
}
pCfg->chEnabled = 0x01;
pCfg->userInfo.pres.pres = PRSNT_NODEF;
pCfg->userInfo.id.pres = NOTPRSNT;
pCfg->userInfo.mid.pres = PRSNT_NODEF;
......@@ -1001,7 +1004,7 @@ int mgco_mg_tsap_config(megaco_profile_t* profile)
/* FILL TSAP config */
cfg->tSAPId = profile->idx;
cfg->spId = profile->idx;
cfg->provType = mg_get_tpt_type(profile);
cfg->provType = LMG_PROV_TYPE_TUCL;
/* FILL TUCL Information */
cfg->memId.region = S_REG;
......@@ -1045,7 +1048,7 @@ int mgco_mg_peer_config(megaco_profile_t* mg_cfg)
Pst pst; /* Post for layer manager */
U32 peerIdx = 0;
CmInetIpAddr ipAddr = 0;
mg_peer_profile_t* mg_peer = megaco_peer_profile_locate(mg_cfg->peer_list[0]);
mg_peer_profile_t* mg_peer = NULL;
memset(&mgMngmt, 0, sizeof(mgMngmt));
cfg = &(mgMngmt.t.cfg.c.mgGcpEntCfg);
......@@ -1063,13 +1066,16 @@ int mgco_mg_peer_config(megaco_profile_t* mg_cfg)
mgMngmt.hdr.elmId.elmnt = STGCPENT;
cfg->numPeer = mg_cfg->total_peers;
for(peerIdx =0; peerIdx < mg_cfg->total_peers; peerIdx++){
mg_peer = megaco_peer_profile_locate(mg_cfg->peer_list[peerIdx]);
cfg->peerCfg[peerIdx].sSAPId = mg_cfg->idx; /* SSAP ID */;
cfg->peerCfg[peerIdx].port = atoi(mg_peer->port);
cfg->peerCfg[peerIdx].tsapId = mg_cfg->idx;
cfg->peerCfg[peerIdx].mtuSize = MG_MAX_MTU_SIZE;
cfg->peerCfg[peerIdx].peerAddrTbl.count = 1;
cfg->peerCfg[peerIdx].peerAddrTbl.netAddr[0].type =
CM_NETADDR_IPV4;
......@@ -1087,7 +1093,7 @@ int mgco_mg_peer_config(megaco_profile_t* mg_cfg)
#ifdef GCP_MG
cfg->peerCfg[peerIdx].transportType = mg_get_tpt_type_from_str(mg_peer->transport_type);
cfg->peerCfg[peerIdx].encodingScheme = mg_get_enc_type_from_str(mg_peer->encoding_type);
cfg->peerCfg[peerIdx].mgcPriority = 0;
cfg->peerCfg[peerIdx].mgcPriority = peerIdx;
cfg->peerCfg[peerIdx].useAHScheme = FALSE;
cfg->peerCfg[peerIdx].mid.pres = PRSNT_NODEF;
cfg->peerCfg[peerIdx].mid.len = strlen((char*)mg_peer->mid);
......@@ -1096,6 +1102,7 @@ int mgco_mg_peer_config(megaco_profile_t* mg_cfg)
cfg->peerCfg[peerIdx].mid.len);
#endif /* GCP_MG */
}
return(sng_cfg_mg(&pst, &mgMngmt));
}
......@@ -1305,7 +1312,6 @@ sng_mg_transport_types_e mg_get_tpt_type_from_str(char* tpt_type)
if(!strcasecmp(tpt_type, "UDP")){
return SNG_MG_TPT_UDP;
}else if(!strcasecmp(tpt_type,"TCP")){
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "TCP Transport for H.248 Protocol Not Yet Supported \n");
return SNG_MG_TPT_TCP;
}else if(!strcasecmp(tpt_type,"STCP")){
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "STCP Transport for H.248 Protocol Not Yet Supported \n");
......
......@@ -62,4 +62,12 @@ switch_status_t sng_mgco_init(sng_mg_event_interface_t* event);
switch_status_t sng_mgco_stack_shutdown(void);
int sng_mgco_mg_get_status(int elemId, MgMngmt* cfm, megaco_profile_t* mg_cfg, mg_peer_profile_t* mg_peer);
/****************************************************************************************************************/
/* MG Stack defines */
/* Free Commands inside MG CH command */
#define mg_free_cmd(_cmd) mgFreeEventMem(_cmd)
/****************************************************************************************************************/
#endif /* _MEGACO_STACK_H_ */
......@@ -27,6 +27,7 @@ switch_status_t config_profile(megaco_profile_t *profile, switch_bool_t reload)
char *var, *val;
mg_peer_profile_t* peer_profile = NULL;
switch_xml_config_item_t *instructions1 = NULL;
switch_memory_pool_t *pool;
if (!(xml = switch_xml_open_cfg(file, &cfg, NULL))) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Could not open %s\n", file);
......@@ -78,15 +79,17 @@ switch_status_t config_profile(megaco_profile_t *profile, switch_bool_t reload)
goto done;
}
count = 0x00;
event = NULL;
for (mg_peer = switch_xml_child(mg_peers, "mg_peer"); mg_peer; mg_peer = mg_peer->next) {
const char *name = switch_xml_attr_soft(mg_peer, "name");
for(idx=0; idx<profile->total_peers; idx++){
count = 0x00;
event = NULL;
peer_profile = NULL;
if (!strcmp(name, profile->peer_list[idx])) {
/* peer profile */
peer_profile = switch_core_alloc(profile->pool, sizeof(*peer_profile));
peer_profile->pool = profile->pool;
switch_core_new_memory_pool(&pool);
peer_profile = switch_core_alloc(pool, sizeof(*peer_profile));
peer_profile->pool = pool;
peer_profile->name = switch_core_strdup(peer_profile->pool, name);
switch_thread_rwlock_create(&peer_profile->rwlock, peer_profile->pool);
instructions1 = (peer_profile ? get_peer_instructions(peer_profile) : NULL);
......@@ -132,10 +135,20 @@ switch_status_t mg_config_cleanup(megaco_profile_t* profile)
return SWITCH_STATUS_SUCCESS;
}
/****************************************************************************************************************************/
switch_status_t mg_peer_config_cleanup(mg_peer_profile_t* profile)
{
switch_xml_config_item_t *instructions = (profile ? get_peer_instructions(profile) : NULL);
switch_xml_config_cleanup(instructions);
return SWITCH_STATUS_SUCCESS;
}
/****************************************************************************************************************************/
static switch_xml_config_item_t *get_peer_instructions(mg_peer_profile_t *profile) {
switch_xml_config_item_t *dup;
switch_xml_config_item_t instructions[] = {
/* parameter name type reloadable pointer default value options structure */
SWITCH_CONFIG_ITEM("ip", SWITCH_CONFIG_STRING, CONFIG_RELOADABLE, &profile->ipaddr, "", &switch_config_string_strdup, "", "Peer IP"),
......@@ -243,6 +256,7 @@ static switch_status_t modify_mid(char* mid)
sprintf(mid,"[%s]",dup);
}else {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid input MID string[%s]\n",mid);
free(dup);
return SWITCH_STATUS_FALSE;
}
......
......@@ -84,6 +84,8 @@ switch_status_t config_profile(megaco_profile_t *profile, switch_bool_t reload);
switch_status_t sng_mgco_start(megaco_profile_t* profile);
switch_status_t sng_mgco_stop(megaco_profile_t* profile);
switch_status_t mg_config_cleanup(megaco_profile_t* profile);
switch_status_t mg_peer_config_cleanup(mg_peer_profile_t* profile);
switch_status_t megaco_peer_profile_destroy(mg_peer_profile_t **profile);
switch_status_t mg_process_cli_cmd(const char *cmd, switch_stream_handle_t *stream);
......
......@@ -502,7 +502,7 @@ static switch_call_cause_t channel_outgoing_channel(switch_core_session_t *sessi
char name[128];
const char *dname = "PCMU";
uint32_t interval = 20;
crtp_private_t *tech_pvt;
crtp_private_t *tech_pvt = NULL;
#if 0
const char *r_sdp = switch_event_get_header(var_event, kRSDP);
#endif
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论