提交 84d56ee5 authored 作者: Mathieu Rene's avatar Mathieu Rene

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

...@@ -74,6 +74,7 @@ mg_context_t *megaco_get_context(megaco_profile_t *profile, uint32_t context_id) ...@@ -74,6 +74,7 @@ mg_context_t *megaco_get_context(megaco_profile_t *profile, uint32_t context_id)
mg_context_t *megaco_choose_context(megaco_profile_t *profile) mg_context_t *megaco_choose_context(megaco_profile_t *profile)
{ {
mg_context_t *ctx; mg_context_t *ctx;
int i = 0x0;;
switch_thread_rwlock_wrlock(profile->contexts_rwlock); switch_thread_rwlock_wrlock(profile->contexts_rwlock);
/* Try the next one */ /* Try the next one */
...@@ -86,7 +87,7 @@ mg_context_t *megaco_choose_context(megaco_profile_t *profile) ...@@ -86,7 +87,7 @@ mg_context_t *megaco_choose_context(megaco_profile_t *profile)
if ((profile->contexts_bitmap[profile->next_context_id % 8] & (1 << (profile->next_context_id / 8))) == 0) { if ((profile->contexts_bitmap[profile->next_context_id % 8] & (1 << (profile->next_context_id / 8))) == 0) {
/* Found! */ /* Found! */
profile->contexts_bitmap[profile->next_context_id % 8] |= 1 << (profile->next_context_id / 8); profile->contexts_bitmap[profile->next_context_id % 8] |= 1 << (profile->next_context_id / 8);
int i = profile->next_context_id % MG_CONTEXT_MODULO; i = profile->next_context_id % MG_CONTEXT_MODULO;
ctx = malloc(sizeof *ctx); ctx = malloc(sizeof *ctx);
ctx->context_id = profile->next_context_id; ctx->context_id = profile->next_context_id;
ctx->profile = profile; ctx->profile = profile;
......
...@@ -26,6 +26,7 @@ switch_status_t mg_process_cli_cmd(const char *cmd, switch_stream_handle_t *stre ...@@ -26,6 +26,7 @@ switch_status_t mg_process_cli_cmd(const char *cmd, switch_stream_handle_t *stre
int argc; int argc;
char* argv[10]; char* argv[10];
char* dup = NULL; char* dup = NULL;
int wild = 0x00;
megaco_profile_t* profile = NULL; megaco_profile_t* profile = NULL;
if (zstr(cmd)) { if (zstr(cmd)) {
...@@ -107,12 +108,16 @@ switch_status_t mg_process_cli_cmd(const char *cmd, switch_stream_handle_t *stre ...@@ -107,12 +108,16 @@ switch_status_t mg_process_cli_cmd(const char *cmd, switch_stream_handle_t *stre
} }
if (profile) { if (profile) {
if(!zstr(argv[7]) && !strcasecmp(argv[7],"wild")){
wild = 0x01;
}
printf("Input to Send Service Change command : " printf("Input to Send Service Change command : "
"Profile Name[%s], term-id[%s] method[%s] reason[%s] \n", "Profile Name[%s], term-id[%s] method[%s] reason[%s] \n",
profile->name, argv[4], argv[5], argv[6]); profile->name, argv[4], argv[5], argv[6]);
megaco_profile_release(profile); megaco_profile_release(profile);
mg_send_service_change(profile->idx, argv[4], atoi(argv[5]), atoi(argv[6])); mg_send_service_change(profile->idx, argv[4], atoi(argv[5]), atoi(argv[6]),wild);
} else { } else {
stream->write_function(stream, "-ERR No such profile\n"); stream->write_function(stream, "-ERR No such profile\n");
} }
......
...@@ -273,10 +273,14 @@ switch_status_t handle_mg_audit_cmd( SuId suId, MgMgcoCommand *auditReq) ...@@ -273,10 +273,14 @@ switch_status_t handle_mg_audit_cmd( SuId suId, MgMgcoCommand *auditReq)
MgMgcoMediaDesc* media; MgMgcoMediaDesc* media;
MgMgcoCtxt ctxt; MgMgcoCtxt ctxt;
switch_status_t ret; switch_status_t ret;
uint8_t wild = 0x00;
memset(&reply, 0, sizeof(reply)); memset(&reply, 0, sizeof(reply));
audit = &auditReq->u.mgCmdReq[0]->cmd.u.aval; audit = &auditReq->u.mgCmdReq[0]->cmd.u.aval;
wild = auditReq->u.mgCmdReq[0]->wild.pres;
switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_INFO,"%s :: wild card request = %s \n",__FUNCTION__,(1==wild)?"TRUE":"FALSE");
if(NOTPRSNT == audit->pres.pres){ if(NOTPRSNT == audit->pres.pres){
switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_ERROR,"Audit structure not present..rejecting \n"); switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_ERROR,"Audit structure not present..rejecting \n");
...@@ -498,6 +502,11 @@ switch_status_t handle_mg_audit_cmd( SuId suId, MgMgcoCommand *auditReq) ...@@ -498,6 +502,11 @@ switch_status_t handle_mg_audit_cmd( SuId suId, MgMgcoCommand *auditReq)
reply.cmdType.pres = PRSNT_NODEF; reply.cmdType.pres = PRSNT_NODEF;
reply.cmdType.val = CH_CMD_TYPE_RSP; reply.cmdType.val = CH_CMD_TYPE_RSP;
if(wild){
reply.u.mgCmdRsp[0]->wild.pres = PRSNT_NODEF;
}
/* send command reply */ /* send command reply */
sng_mgco_send_cmd(suId, &reply); sng_mgco_send_cmd(suId, &reply);
...@@ -942,9 +951,12 @@ switch_status_t mg_send_subtract_rsp(SuId suId, MgMgcoCommand *req) ...@@ -942,9 +951,12 @@ switch_status_t mg_send_subtract_rsp(SuId suId, MgMgcoCommand *req)
int ret = 0x00; int ret = 0x00;
MgMgcoTermId *termId; MgMgcoTermId *termId;
MgMgcoCtxt ctxt; MgMgcoCtxt ctxt;
uint8_t wild = 0x00;
memset(&cmd,0, sizeof(cmd)); memset(&cmd,0, sizeof(cmd));
wild = req->u.mgCmdReq[0]->wild.pres;
/*copy transaction-id*/ /*copy transaction-id*/
memcpy(&cmd.transId, &req->transId,sizeof(MgMgcoTransId)); memcpy(&cmd.transId, &req->transId,sizeof(MgMgcoTransId));
...@@ -959,6 +971,10 @@ switch_status_t mg_send_subtract_rsp(SuId suId, MgMgcoCommand *req) ...@@ -959,6 +971,10 @@ switch_status_t mg_send_subtract_rsp(SuId suId, MgMgcoCommand *req)
return ret; return ret;
} }
if(wild){
cmd.u.mgCmdRsp[0]->wild.pres = PRSNT_NODEF;
}
cmd.u.mgCmdRsp[0]->pres.pres = PRSNT_NODEF; cmd.u.mgCmdRsp[0]->pres.pres = PRSNT_NODEF;
cmd.u.mgCmdRsp[0]->type.pres = PRSNT_NODEF; cmd.u.mgCmdRsp[0]->type.pres = PRSNT_NODEF;
cmd.u.mgCmdRsp[0]->type.val = MGT_SUB; cmd.u.mgCmdRsp[0]->type.val = MGT_SUB;
...@@ -1007,7 +1023,7 @@ U32 get_txn_id(){ ...@@ -1007,7 +1023,7 @@ U32 get_txn_id(){
* SuId - Service User ID for MG SAP - it will be same like mg_profile_t->idx (refer to media_gateway_xml.c->mg_sap_id) * SuId - Service User ID for MG SAP - it will be same like mg_profile_t->idx (refer to media_gateway_xml.c->mg_sap_id)
* term_name - String format defined termination name * term_name - String format defined termination name
*/ */
switch_status_t mg_send_service_change(SuId suId, const char* term_name, uint8_t method, MgServiceChangeReason_e reason) switch_status_t mg_send_service_change(SuId suId, const char* term_name, uint8_t method, MgServiceChangeReason_e reason,uint8_t wild)
{ {
MgMgcoSvcChgPar srvPar; MgMgcoSvcChgPar srvPar;
MgMgcoTermId* termId; MgMgcoTermId* termId;
...@@ -1054,9 +1070,6 @@ switch_status_t mg_send_service_change(SuId suId, const char* term_name, uint8_t ...@@ -1054,9 +1070,6 @@ switch_status_t mg_send_service_change(SuId suId, const char* term_name, uint8_t
/*mgUtlCpyMgMgcoSvcChgPar(&svc->parm, &srvPar, &request.u.mgCmdReq[0]->memCp);*/ /*mgUtlCpyMgMgcoSvcChgPar(&svc->parm, &srvPar, &request.u.mgCmdReq[0]->memCp);*/
printf("reason[%p = %s], len[%d]\n",svc->parm.reason.val, svc->parm.reason.val, svc->parm.reason.len);
if (mgUtlGrowList((void ***)&svc->termIdLst.terms, sizeof(MgMgcoTermIdLst), if (mgUtlGrowList((void ***)&svc->termIdLst.terms, sizeof(MgMgcoTermIdLst),
&svc->termIdLst.num, &request.u.mgCmdReq[0]->memCp) != ROK) &svc->termIdLst.num, &request.u.mgCmdReq[0]->memCp) != ROK)
{ {
...@@ -1073,8 +1086,12 @@ switch_status_t mg_send_service_change(SuId suId, const char* term_name, uint8_t ...@@ -1073,8 +1086,12 @@ switch_status_t mg_send_service_change(SuId suId, const char* term_name, uint8_t
mg_fill_mgco_termid(termId, (char*)term_name ,strlen(term_name), &request.u.mgCmdReq[0]->memCp); mg_fill_mgco_termid(termId, (char*)term_name ,strlen(term_name), &request.u.mgCmdReq[0]->memCp);
if(wild){
request.u.mgCmdReq[0]->wild.pres = PRSNT_NODEF;
}
printf("reason[%p = %s], len[%d]\n",svc->parm.reason.val, svc->parm.reason.val, svc->parm.reason.len); switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_INFO,"Sending %s Service Change for termId[%s] with reason[%s], len[%d]\n",
((1==wild)?"WildCard":"Non Wild Card"), term_name, svc->parm.reason.val, svc->parm.reason.len);
sng_mgco_send_cmd(suId, &request); sng_mgco_send_cmd(suId, &request);
......
...@@ -155,7 +155,7 @@ switch_status_t mg_send_heartbeat_audit_rsp( SuId suId, MgMgcoCommand *auditReq) ...@@ -155,7 +155,7 @@ switch_status_t mg_send_heartbeat_audit_rsp( SuId suId, MgMgcoCommand *auditReq)
void mg_get_time_stamp(MgMgcoTimeStamp *timeStamp); void mg_get_time_stamp(MgMgcoTimeStamp *timeStamp);
switch_status_t mg_fill_svc_change(MgMgcoSvcChgPar *srvPar, uint8_t method, const char *reason); switch_status_t mg_fill_svc_change(MgMgcoSvcChgPar *srvPar, uint8_t method, const char *reason);
void mg_fill_null_context(MgMgcoContextId* ctxt); void mg_fill_null_context(MgMgcoContextId* ctxt);
switch_status_t mg_send_service_change(SuId suId, const char* term_name, uint8_t method, MgServiceChangeReason_e reason); switch_status_t mg_send_service_change(SuId suId, const char* term_name, uint8_t method, MgServiceChangeReason_e reason,uint8_t wild);
switch_status_t mg_create_mgco_command(MgMgcoCommand *cmd, uint8_t apiType, uint8_t cmdType); switch_status_t mg_create_mgco_command(MgMgcoCommand *cmd, uint8_t apiType, uint8_t cmdType);
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论