Merge branch 'nsg-4.3' of git.sangoma.com:smg_freeswitch into nsg-4.3
This commit is contained in:
commit
92af41c0b3
|
@ -5,13 +5,9 @@ applications/mod_dptools
|
||||||
applications/mod_commands
|
applications/mod_commands
|
||||||
applications/mod_hash
|
applications/mod_hash
|
||||||
applications/mod_spandsp
|
applications/mod_spandsp
|
||||||
#applications/mod_rad_auth
|
|
||||||
dialplans/mod_dialplan_xml
|
dialplans/mod_dialplan_xml
|
||||||
endpoints/mod_sofia
|
endpoints/mod_sofia
|
||||||
#endpoints/mod_media_gateway
|
|
||||||
../../libs/freetdm/mod_freetdm
|
../../libs/freetdm/mod_freetdm
|
||||||
xml_int/mod_xml_cdr
|
xml_int/mod_xml_cdr
|
||||||
event_handlers/mod_event_socket
|
event_handlers/mod_event_socket
|
||||||
codecs/mod_sangoma_codec
|
codecs/mod_sangoma_codec
|
||||||
#event_handlers/mod_radius_cdr
|
|
||||||
|
|
||||||
|
|
|
@ -43,6 +43,35 @@ typedef enum{
|
||||||
(_val == SNG_MG_ENCODING_BINARY)?"SNG_MG_ENCODING_BINARY":\
|
(_val == SNG_MG_ENCODING_BINARY)?"SNG_MG_ENCODING_BINARY":\
|
||||||
"SNG_MG_ENCODING_NONE")
|
"SNG_MG_ENCODING_NONE")
|
||||||
|
|
||||||
|
typedef struct _mgStr
|
||||||
|
{
|
||||||
|
U8 len;
|
||||||
|
U8 val[128];
|
||||||
|
} MgStr;
|
||||||
|
|
||||||
|
#define MG_TXN_INVALID 0
|
||||||
|
|
||||||
|
#define mg_zero(_buf, _size) {cmMemset((U8 *)(_buf), 0, _size);}
|
||||||
|
|
||||||
|
/* Set pres field */
|
||||||
|
#define mg_util_set_pres(_pres) \
|
||||||
|
(_pres) = PRSNT_NODEF;
|
||||||
|
|
||||||
|
/* Set token value */
|
||||||
|
#define mg_util_set_val_pres(tkn,_val) \
|
||||||
|
mg_util_set_pres((tkn).pres); \
|
||||||
|
(tkn).val = _val;
|
||||||
|
|
||||||
|
|
||||||
|
#define mg_mem_copy(_dst, _src, _len) \
|
||||||
|
cmMemcpy((U8*) (_dst), (const U8*) (_src), _len)
|
||||||
|
|
||||||
|
#define mg_get_mem(_memPtr, _size, _allocPtr, ret) \
|
||||||
|
{ \
|
||||||
|
(*ret) = cmGetMem((Ptr *)(_memPtr),(_size) ,(Ptr *)&(_allocPtr)); \
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void handle_sng_log(uint8_t level, char *fmt, ...);
|
void handle_sng_log(uint8_t level, char *fmt, ...);
|
||||||
void handle_mgco_sta_ind(Pst *pst, SuId suId, MgMgtSta* msg);
|
void handle_mgco_sta_ind(Pst *pst, SuId suId, MgMgtSta* msg);
|
||||||
|
|
|
@ -155,7 +155,7 @@ static switch_xml_config_item_t *get_peer_instructions(mg_peer_profile_t *profil
|
||||||
/* parameter name type reloadable pointer default value options structure */
|
/* 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"),
|
SWITCH_CONFIG_ITEM("ip", SWITCH_CONFIG_STRING, CONFIG_RELOADABLE, &profile->ipaddr, "", &switch_config_string_strdup, "", "Peer IP"),
|
||||||
SWITCH_CONFIG_ITEM("port", SWITCH_CONFIG_STRING, 0, &profile->port, "", &switch_config_string_strdup, "", "peer port"),
|
SWITCH_CONFIG_ITEM("port", SWITCH_CONFIG_STRING, 0, &profile->port, "", &switch_config_string_strdup, "", "peer port"),
|
||||||
SWITCH_CONFIG_ITEM("encoding-scheme", SWITCH_CONFIG_STRING, 0, &profile->encoding_type, "TEXT", &switch_config_string_strdup, "", "peer encoding type"),
|
SWITCH_CONFIG_ITEM("encoding-scheme", SWITCH_CONFIG_STRING, 0, &profile->encoding_type, "", &switch_config_string_strdup, "", "peer encoding type"),
|
||||||
SWITCH_CONFIG_ITEM("transport-type", SWITCH_CONFIG_STRING, 0, &profile->transport_type, "", &switch_config_string_strdup, "", "peer transport type "),
|
SWITCH_CONFIG_ITEM("transport-type", SWITCH_CONFIG_STRING, 0, &profile->transport_type, "", &switch_config_string_strdup, "", "peer transport type "),
|
||||||
SWITCH_CONFIG_ITEM("message-identifier", SWITCH_CONFIG_STRING, 0, &profile->mid, "", &switch_config_string_strdup, "", "peer message identifier "),
|
SWITCH_CONFIG_ITEM("message-identifier", SWITCH_CONFIG_STRING, 0, &profile->mid, "", &switch_config_string_strdup, "", "peer message identifier "),
|
||||||
SWITCH_CONFIG_ITEM_END()
|
SWITCH_CONFIG_ITEM_END()
|
||||||
|
@ -241,6 +241,7 @@ static switch_status_t modify_mid(char* mid)
|
||||||
}
|
}
|
||||||
|
|
||||||
if(('<' == val[0][0]) || ('[' == val[0][0])){
|
if(('<' == val[0][0]) || ('[' == val[0][0])){
|
||||||
|
free(dup);
|
||||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "MID[%s] is already prefixed with proper brackets \n",mid);
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "MID[%s] is already prefixed with proper brackets \n",mid);
|
||||||
return SWITCH_STATUS_SUCCESS;
|
return SWITCH_STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
@ -258,7 +259,7 @@ static switch_status_t modify_mid(char* mid)
|
||||||
sprintf(mid,"[%s]",dup);
|
sprintf(mid,"[%s]",dup);
|
||||||
}else {
|
}else {
|
||||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid input MID string[%s]\n",mid);
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid input MID string[%s]\n",mid);
|
||||||
free(dup);
|
free(dup);
|
||||||
return SWITCH_STATUS_FALSE;
|
return SWITCH_STATUS_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -24,6 +24,8 @@ switch_status_t mg_stack_free_mem(MgMgcoMsg* msg);
|
||||||
switch_status_t mg_stack_alloc_mem( Ptr* _memPtr, Size _memSize );
|
switch_status_t mg_stack_alloc_mem( Ptr* _memPtr, Size _memSize );
|
||||||
switch_status_t mg_send_add_rsp(SuId suId, MgMgcoCommand *req);
|
switch_status_t mg_send_add_rsp(SuId suId, MgMgcoCommand *req);
|
||||||
S16 mg_fill_mgco_termid ( MgMgcoTermId *termId, CONSTANT U8 *str, CmMemListCp *memCp);
|
S16 mg_fill_mgco_termid ( MgMgcoTermId *termId, CONSTANT U8 *str, CmMemListCp *memCp);
|
||||||
|
void mg_util_set_txn_string(MgStr *errTxt, U32 *txnId);
|
||||||
|
switch_status_t mg_build_mgco_err_request(MgMgcoInd **errcmd,U32 trans_id, MgMgcoContextId *ctxt_id, U32 err, MgStr *errTxt);
|
||||||
|
|
||||||
/**************************************************************************************************************/
|
/**************************************************************************************************************/
|
||||||
|
|
||||||
|
@ -477,6 +479,10 @@ void handle_mgco_txn_ind(Pst *pst, SuId suId, MgMgcoMsg* msg)
|
||||||
void handle_mgco_cmd_ind(Pst *pst, SuId suId, MgMgcoCommand* cmd)
|
void handle_mgco_cmd_ind(Pst *pst, SuId suId, MgMgcoCommand* cmd)
|
||||||
{
|
{
|
||||||
uint32_t txn_id = 0x00;
|
uint32_t txn_id = 0x00;
|
||||||
|
MgMgcoInd *mgErr;
|
||||||
|
MgStr errTxt;
|
||||||
|
MgMgcoContextId ctxtId;
|
||||||
|
|
||||||
|
|
||||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "%s: Received Command Type[%s] \n", __PRETTY_FUNCTION__, PRNT_MG_CMD_TYPE(cmd->cmdType.val));
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "%s: Received Command Type[%s] \n", __PRETTY_FUNCTION__, PRNT_MG_CMD_TYPE(cmd->cmdType.val));
|
||||||
|
|
||||||
|
@ -486,7 +492,20 @@ void handle_mgco_cmd_ind(Pst *pst, SuId suId, MgMgcoCommand* cmd)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "%s: Transaction Id not present, rejecting\n", __PRETTY_FUNCTION__);
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "%s: Transaction Id not present, rejecting\n", __PRETTY_FUNCTION__);
|
||||||
/*TODO - can invoke "MgUiMgtMgcoErrReq" to report error to MEGACO stack */
|
|
||||||
|
/*-- Send Error to MG Stack --*/
|
||||||
|
mg_zero(&ctxtId, sizeof(MgMgcoContextId));
|
||||||
|
ctxtId.type.pres = NOTPRSNT;
|
||||||
|
ctxtId.val.pres = NOTPRSNT;
|
||||||
|
|
||||||
|
mg_util_set_txn_string(&errTxt, &txn_id);
|
||||||
|
|
||||||
|
if (SWITCH_STATUS_FALSE == mg_build_mgco_err_request(&mgErr, txn_id, &ctxtId,
|
||||||
|
MGT_MGCO_RSP_CODE_INVLD_IDENTIFIER, &errTxt))
|
||||||
|
{
|
||||||
|
sng_mgco_send_err(suId, mgErr);
|
||||||
|
}
|
||||||
|
|
||||||
/* deallocate the msg */
|
/* deallocate the msg */
|
||||||
mg_free_cmd(cmd);
|
mg_free_cmd(cmd);
|
||||||
return ;
|
return ;
|
||||||
|
@ -976,6 +995,78 @@ S16 mg_fill_mgco_termid ( MgMgcoTermId *termId, CONSTANT U8 *str, CmMemListCp
|
||||||
RETVALUE(ROK);
|
RETVALUE(ROK);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
switch_status_t mg_build_mgco_err_request(MgMgcoInd **errcmd,U32 trans_id, MgMgcoContextId *ctxt_id, U32 err, MgStr *errTxt)
|
||||||
|
{
|
||||||
|
MgMgcoInd *mgErr;
|
||||||
|
S16 ret;
|
||||||
|
|
||||||
|
mgErr = NULLP;
|
||||||
|
ret = ROK;
|
||||||
|
|
||||||
|
/* Allocate for AG error */
|
||||||
|
mg_stack_alloc_mem((Ptr*)&mgErr, sizeof(MgMgcoInd));
|
||||||
|
if (NULL == mgErr) {
|
||||||
|
switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_ERROR, " mg_build_mgco_err_request Failed : memory alloc \n");
|
||||||
|
return SWITCH_STATUS_FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Set transaction Id in the error request */
|
||||||
|
mg_util_set_val_pres(mgErr->transId, trans_id);
|
||||||
|
|
||||||
|
/* Copy the context Id */
|
||||||
|
mg_mem_copy(&mgErr->cntxtId,
|
||||||
|
ctxt_id,
|
||||||
|
sizeof(MgMgcoContextId));
|
||||||
|
|
||||||
|
/* Set the peerId */
|
||||||
|
mgErr->peerId.pres = NOTPRSNT;
|
||||||
|
|
||||||
|
/* Set the error code */
|
||||||
|
mg_util_set_pres(mgErr->err.pres.pres);
|
||||||
|
mg_util_set_pres(mgErr->err.code.pres);
|
||||||
|
mg_util_set_val_pres(mgErr->err.code, err);
|
||||||
|
|
||||||
|
if(errTxt->len)
|
||||||
|
{
|
||||||
|
mg_get_mem(&mgErr->memCp, (errTxt->len)*sizeof(U8), mgErr->err.text.val, &ret);
|
||||||
|
if (ROK != ret) {
|
||||||
|
switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_ERROR, " mg_build_mgco_err_request Failed : memory alloc \n");
|
||||||
|
return SWITCH_STATUS_FALSE;
|
||||||
|
}
|
||||||
|
mgErr->err.text.pres = PRSNT_NODEF;
|
||||||
|
mgErr->err.text.len = errTxt->len;
|
||||||
|
mg_mem_copy(mgErr->err.text.val, errTxt->val, errTxt->len);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Set the output value */
|
||||||
|
*errcmd = mgErr;
|
||||||
|
|
||||||
|
return SWITCH_STATUS_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
void mg_util_set_txn_string(MgStr *errTxt, U32 *txnId)
|
||||||
|
{
|
||||||
|
mg_zero((errTxt->val), sizeof(errTxt->val));
|
||||||
|
errTxt->len = 0;
|
||||||
|
|
||||||
|
errTxt->val[errTxt->len] = '\"';
|
||||||
|
errTxt->len += 1;
|
||||||
|
|
||||||
|
if (MG_TXN_INVALID == txnId )
|
||||||
|
{
|
||||||
|
mg_mem_copy((&errTxt->val[errTxt->len]), "TransactionId=0", 15);
|
||||||
|
errTxt->len += 15;
|
||||||
|
}
|
||||||
|
|
||||||
|
errTxt->val[errTxt->len] = '\"';
|
||||||
|
errTxt->len += 1;
|
||||||
|
|
||||||
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "%s:"
|
||||||
|
"info, error-text is: %s\n", __PRETTY_FUNCTION__,errTxt->val);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*****************************************************************************************************************************/
|
/*****************************************************************************************************************************/
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue