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

This commit is contained in:
Mathieu Rene 2012-06-20 12:02:38 -04:00
commit badc31f927
12 changed files with 589 additions and 89 deletions

View File

@ -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

View File

@ -40,6 +40,7 @@
#define _GNU_SOURCE
#include "private/ftdm_core.h"
#include <stdarg.h>
#include <ctype.h>
#ifdef WIN32
#include <io.h>
#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 [!]<state_name> - List all channels in or not in the given state\n"
"ftdm core flag <flag-int-value> - List all channels with the given flag value set\n"
"ftdm core state [!]<state-name> - List all channels in or not in the given state\n"
"ftdm core flag [!]<flag-int-value|flag-name> [<span_id|span_name>] [<chan_id>] - 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 "invalid";
}
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);

View File

@ -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 <m2ua_interface_name>\n");
stream->write_function(stream, "ftdm ss7 xmlshow m2ua <m2ua_interface_name> peerstatus\n");
stream->write_function(stream, "ftdm ss7 xmlshow m2ua <m2ua_interface_name> clusterstatus\n");
stream->write_function(stream, "ftdm ss7 xmlshow nif \n");
stream->write_function(stream, "ftdm ss7 xmlshow nif <nif_interface_name>\n");
stream->write_function(stream, "\n");
@ -3086,12 +3095,17 @@ static ftdm_status_t handle_show_m2ua_profiles(ftdm_stream_handle_t *stream)
len = len + sprintf(buf + len, "<m2ua_profiles>\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, "<m2ua_gen>\n");
#ifdef BIT_64
len = len + sprintf(buf + len, "<mem_size> %d </mem_size>\n", cfm.t.ssta.s.genSta.memSize);
len = len + sprintf(buf + len, " <allocated_mem_size> %d </allocated_mem_size>\n", cfm.t.ssta.s.genSta.memAlloc);
#else
len = len + sprintf(buf + len, "<mem_size> %ld </mem_size>\n", cfm.t.ssta.s.genSta.memSize);
len = len + sprintf(buf + len, " <allocated_mem_size> %ld </allocated_mem_size>\n", cfm.t.ssta.s.genSta.memAlloc);
#endif
len = len + sprintf(buf + len, " <num_of_cluster> %d </num_of_cluster>\n", cfm.t.ssta.s.genSta.nmbClusters);
len = len + sprintf(buf + len, " <num_of_peers> %d </num_of_peers>\n", cfm.t.ssta.s.genSta.nmbPeers);
len = len + sprintf(buf + len, " <num_of_interfaces> %d </num_of_interfaces>\n", cfm.t.ssta.s.genSta.nmbIntf);
@ -3110,7 +3124,7 @@ static ftdm_status_t handle_show_m2ua_profiles(ftdm_stream_handle_t *stream)
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");
stream->write_function(stream," Request to M2UA layer failed \n");
return FTDM_FAIL;
} else {
len = len + sprintf(buf + len, "<m2ua_dlsap>\n");
@ -3124,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, "<m2ua_cluster>\n");
@ -3155,14 +3169,14 @@ 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, "<m2ua_peer>\n");
len = len + sprintf(buf + len, "<name> %s </name>\n",g_ftdm_sngss7_data.cfg.g_m2ua_cfg.m2ua_peer[peer_id].name);
len = len + sprintf(buf + len," <state> %s </state>\n", PRNT_M2UA_PEER_STATE(cfm.t.ssta.s.peerSta.state));
len = len + sprintf(buf + len, " <retry_count> %d </retry_count>\n",cfm.t.ssta.s.peerSta.retryCount);
len = len + sprintf(buf + len, " <assoc_id> %d </assoc_id>\n",cfm.t.ssta.s.peerSta.assocSta.spAssocId);
len = len + sprintf(buf + len, " <assoc_id> %d </assoc_id>\n", (int)cfm.t.ssta.s.peerSta.assocSta.spAssocId);
len = len + sprintf(buf + len, " <connected_status> %s </connected_status>\n",(cfm.t.ssta.s.peerSta.assocSta.connected)?"CONNECTED":"NOT CONNECTED");
len = len + sprintf(buf + len, " <flow_cntrl_progress> %d </flow_cntrl_progress>\n",cfm.t.ssta.s.peerSta.assocSta.flcInProg);
len = len + sprintf(buf + len, " <flow_cntrl_level> %d </flow_cntrl_level>\n",cfm.t.ssta.s.peerSta.assocSta.flcLevel);
@ -3182,13 +3196,13 @@ 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, "<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," <end_point_id> %d </end_point_id>\n", (int) 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");
}
@ -3201,7 +3215,7 @@ static ftdm_status_t handle_show_m2ua_profiles(ftdm_stream_handle_t *stream)
len = len + sprintf(buf + len, "</m2ua_profiles>\n");
stream->write_function(stream,"\n%s\n",buf);
return FTDM_FAIL;
return FTDM_SUCCESS;
}
@ -3254,7 +3268,7 @@ static ftdm_status_t handle_show_m2ua_profile(ftdm_stream_handle_t *stream, char
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");
stream->write_function(stream," Request to M2UA layer failed \n");
return FTDM_FAIL;
} else {
len = len + sprintf(buf + len, "<m2ua_dlsap>\n");
@ -3267,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, "<m2ua_cluster>\n");
@ -3293,14 +3307,18 @@ 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, "<m2ua_peer>\n");
len = len + sprintf(buf + len, "<name> %s </name>\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," <state> %s </state>\n", PRNT_M2UA_PEER_STATE(cfm.t.ssta.s.peerSta.state));
len = len + sprintf(buf + len, " <retry_count> %d </retry_count>\n",cfm.t.ssta.s.peerSta.retryCount);
len = len + sprintf(buf + len, " <assoc_id> %d </assoc_id>\n",cfm.t.ssta.s.peerSta.assocSta.spAssocId);
#ifdef BIT_64
len = len + sprintf(buf + len, " <assoc_id> %d </assoc_id>\n", cfm.t.ssta.s.peerSta.assocSta.spAssocId);
#else
len = len + sprintf(buf + len, " <assoc_id> %ld </assoc_id>\n", cfm.t.ssta.s.peerSta.assocSta.spAssocId);
#endif
len = len + sprintf(buf + len, " <connected_status> %s </connected_status>\n",(cfm.t.ssta.s.peerSta.assocSta.connected)?"CONNECTED":"NOT CONNECTED");
len = len + sprintf(buf + len, " <flow_cntrl_progress> %d </flow_cntrl_progress>\n",cfm.t.ssta.s.peerSta.assocSta.flcInProg);
len = len + sprintf(buf + len, " <flow_cntrl_level> %d </flow_cntrl_level>\n",cfm.t.ssta.s.peerSta.assocSta.flcLevel);
@ -3312,13 +3330,17 @@ 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, "<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");
#ifdef BIT_64
len = len + sprintf(buf + len," <end_point_id> %d </end_point_id>\n", cfm.t.ssta.s.sctSapSta.spEndpId);
#else
len = len + sprintf(buf + len," <end_point_id> %ld </end_point_id>\n", cfm.t.ssta.s.sctSapSta.spEndpId);
#endif
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");
}
@ -3327,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;
}
@ -3353,12 +3375,17 @@ static ftdm_status_t handle_show_sctp_profiles(ftdm_stream_handle_t *stream)
len = len + sprintf(buf + len, "<sctp_profiles>\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, "<sctp_gen>\n");
#ifdef BIT_64
len = len + sprintf(buf + len, "<mem_size> %d </mem_size>\n",cfm.t.ssta.s.genSta.memSize);
len = len + sprintf(buf + len, " <allocated_mem_size> %d </allocated_mem_size>\n",cfm.t.ssta.s.genSta.memAlloc);
#else
len = len + sprintf(buf + len, "<mem_size> %ld </mem_size>\n",cfm.t.ssta.s.genSta.memSize);
len = len + sprintf(buf + len, " <allocated_mem_size> %ld </allocated_mem_size>\n",cfm.t.ssta.s.genSta.memAlloc);
#endif
len = len + sprintf(buf + len, " <num_of_open_assoc> %d </num_of_open_assoc>\n",cfm.t.ssta.s.genSta.nmbAssoc);
len = len + sprintf(buf + len, " <num_of_open_end_points> %d </num_of_open_end_points>\n",cfm.t.ssta.s.genSta.nmbEndp);
len = len + sprintf(buf + len, " <num_of_lcl_addr_in_use> %d </num_of_lcl_addr_in_use>\n",cfm.t.ssta.s.genSta.nmbLocalAddr);
@ -3368,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, "<sctp_timers>\n");
@ -3400,7 +3427,7 @@ static ftdm_status_t handle_show_sctp_profiles(ftdm_stream_handle_t *stream)
len = len + sprintf(buf + len, "<sctp_profile>\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, "<sctp_sap>\n");
@ -3410,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, "<sctp_transport_sap>\n");
@ -3425,7 +3452,7 @@ static ftdm_status_t handle_show_sctp_profiles(ftdm_stream_handle_t *stream)
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");
stream->write_function(stream," Request to SCTP layer failed \n");
return FTDM_FAIL;
}
} else {
@ -3454,7 +3481,11 @@ int get_assoc_resp_buf(char* buf,SbMgmt* cfm)
char *asciiAddr;
CmInetIpAddr ip;
#ifdef BIT_64
len = len + sprintf(buf + len, " <assoc_id> %d </assoc_id>\n", cfm->t.ssta.s.assocSta.assocId);
#else
len = len + sprintf(buf + len, " <assoc_id> %ld </assoc_id>\n", cfm->t.ssta.s.assocSta.assocId);
#endif
len = len + sprintf(buf + len, " <assoc_status> %s </assoc_status>\n", PRNT_SCTP_ASSOC_STATE(cfm->t.ssta.s.assocSta.assocState));
len = len + sprintf(buf + len, " <assoc_dst_port> %d </assoc_dst_port>\n", cfm->t.ssta.s.assocSta.dstPort);
len = len + sprintf(buf + len, " <assoc_src_port> %d </assoc_src_port>\n", cfm->t.ssta.s.assocSta.srcPort);
@ -3590,7 +3621,7 @@ static ftdm_status_t handle_show_sctp_profile(ftdm_stream_handle_t *stream, char
len = len + sprintf(buf + len, "<sctp_profile>\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, "<sctp_sap>\n");
@ -3600,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, "<sctp_transport_sap>\n");
@ -3616,7 +3647,7 @@ static ftdm_status_t handle_show_sctp_profile(ftdm_stream_handle_t *stream, char
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");
stream->write_function(stream," Request to SCTP layer failed \n");
return FTDM_FAIL;
}
} else {
@ -3656,12 +3687,17 @@ static ftdm_status_t handle_show_nif_profiles(ftdm_stream_handle_t *stream)
len = len + sprintf(buf + len, "<nif_profiles>\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, "<nif_gen>\n");
#ifdef BIT_64
len = len + sprintf(buf + len, "<mem_size> %d </mem_size>\n",cfm.t.ssta.s.genSta.memSize);
len = len + sprintf(buf + len, " <allocated_mem_size> %d </allocated_mem_size>\n",cfm.t.ssta.s.genSta.memAlloc);
#else
len = len + sprintf(buf + len, "<mem_size> %ld </mem_size>\n",cfm.t.ssta.s.genSta.memSize);
len = len + sprintf(buf + len, " <allocated_mem_size> %ld </allocated_mem_size>\n",cfm.t.ssta.s.genSta.memAlloc);
#endif
len = len + sprintf(buf + len, "</nif_gen>\n");
}
@ -3674,13 +3710,17 @@ static ftdm_status_t handle_show_nif_profiles(ftdm_stream_handle_t *stream)
len = len + sprintf(buf + len, "<nif_profile>\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, "<nif_dlsap>\n");
len = len + sprintf(buf + len," <m2ua_sap_state> %s </m2ua_sap_state>\n", PRNT_NIF_SAP_STATE(cfm.t.ssta.s.dlSapSta.m2uaState));
len = len + sprintf(buf + len," <mtp2_sap_state> %s </mtp2_sap_state>\n", PRNT_NIF_SAP_STATE(cfm.t.ssta.s.dlSapSta.mtp2State));
#ifdef BIT_64
len = len + sprintf(buf + len," <nmb_of_retry> %d </nmb_of_retry>\n", cfm.t.ssta.s.dlSapSta.nmbRetry);
#else
len = len + sprintf(buf + len," <nmb_of_retry> %ld </nmb_of_retry>\n", cfm.t.ssta.s.dlSapSta.nmbRetry);
#endif
len = len + sprintf(buf + len, "</nif_dlsap>\n");
}
@ -3692,7 +3732,7 @@ static ftdm_status_t handle_show_nif_profiles(ftdm_stream_handle_t *stream)
len = len + sprintf(buf + len, "</nif_profiles>\n");
stream->write_function(stream,"\n%s\n",buf);
return FTDM_FAIL;
return FTDM_SUCCESS;
}
/******************************************************************************
@ -3739,13 +3779,17 @@ static ftdm_status_t handle_show_nif_profile(ftdm_stream_handle_t *stream, char*
len = len + sprintf(buf + len, "<nif_profile>\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, "<nif_dlsap>\n");
len = len + sprintf(buf + len," <m2ua_sap_state> %s </m2ua_sap_state>\n", PRNT_NIF_SAP_STATE(cfm.t.ssta.s.dlSapSta.m2uaState));
len = len + sprintf(buf + len," <mtp2_sap_state> %s </mtp2_sap_state>\n", PRNT_NIF_SAP_STATE(cfm.t.ssta.s.dlSapSta.mtp2State));
#ifdef BIT_64
len = len + sprintf(buf + len," <nmb_of_retry> %d </nmb_of_retry>\n", cfm.t.ssta.s.dlSapSta.nmbRetry);
#else
len = len + sprintf(buf + len," <nmb_of_retry> %ld </nmb_of_retry>\n", cfm.t.ssta.s.dlSapSta.nmbRetry);
#endif
len = len + sprintf(buf + len, "</nif_dlsap>\n");
}
@ -3753,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;
}
/******************************************************************************/
@ -3813,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, "<m2ua_peer>\n");
@ -3832,7 +3876,7 @@ static ftdm_status_t handle_show_m2ua_peer_status(ftdm_stream_handle_t *stream,
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");
stream->write_function(stream," Request to SCTP layer failed \n");
return FTDM_FAIL;
}
} else {
@ -3844,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*)"<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>";
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(x<MW_MAX_NUM_OF_INTF){
if((g_ftdm_sngss7_data.cfg.g_m2ua_cfg.m2ua[x].id !=0) &&
((g_ftdm_sngss7_data.cfg.g_m2ua_cfg.m2ua[x].flags & SNGSS7_ACTIVE))) {
if(!strcasecmp(m2ua_profile_name, g_ftdm_sngss7_data.cfg.g_m2ua_cfg.m2ua[x].name)){
found = 0x01;
break;
}
}
x++;
}
if(!found){
stream->write_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, "<m2ua_cluster>\n");
len = len + sprintf(buf + len, "<name> %s </name>\n",clust->name);
len = len + sprintf(buf + len," <state> %s </state>\n", PRNT_M2UA_CLUSTER_STATE(cfm.t.ssta.s.clusterSta.state));
len = len + sprintf(buf + len, "<num_of_peers> %d </num_of_peers>\n",cfm.t.ssta.s.clusterSta.nmbPeer);
for(idx = 0; idx < cfm.t.ssta.s.clusterSta.nmbPeer; idx++)
{
len = len + sprintf(buf + len, "<m2ua_cluster_peer>\n");
len = len + sprintf(buf + len, " <peer_name> %s </peer_name>\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, " <peer_id> %d </peer_id>\n", cfm.t.ssta.s.clusterSta.peerSt[idx].peerId);
len = len + sprintf(buf + len, " <peer_state> %s </peer_state>\n", PRNT_M2UA_PEER_STATE(cfm.t.ssta.s.clusterSta.peerSt[idx].peerState));
len = len + sprintf(buf + len, "</m2ua_cluster_peer>\n");
}
len = len + sprintf(buf + len, "<num_active_peer> %d </num_active_peer>\n",cfm.t.ssta.s.clusterSta.nmbActPeer);
len = len + sprintf(buf + len, "</m2ua_cluster>\n");
}
stream->write_function(stream,"\n%s\n",buf);
return FTDM_SUCCESS;
}
/******************************************************************************/

View File

@ -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;
}
/****************************************************************************************************/

View File

@ -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)
/*!<When adding a new flag, need to update ftdm_io.c:channel_flag_strs */
#include "ftdm_state.h"
typedef enum ftdm_channel_hw_link_status {

View File

@ -0,0 +1,50 @@
<configuration name="media_gateway.conf" description="Media Gateway Configuration">
<mg_profiles>
<mg_profile name="profile-1">
<param name="protocol" value="MEGACO"/>
<param name="local-ip" value="192.168.1.50"/>
<param name="port" value="2944" />
<param name="domain-name" value="lab.sangoma.com" />
<param name="message-identifier" value="<mg.sangoma.com>" />
<param name="version" value="3"/>
<param name="default-codec" value="PCMA"/>
<param name="rtp-port-range" value="5000-6000"/>
<param name="rtp-termination-id-prefix" value="TermRtp"/>
<param name="rtp-termination-id-len" value="4"/> <!-- /* Allowed values = any digit from 0 to 9 */ -->
<physical_terminations>
<map termination-id-prefix="Term1/" termination-id-base="1" tech="freetdm" channel-prefix="wp2" channel-map="1-15,17-31"/>
<map termination-id-prefix="Term2/" termination-id-base="1" tech="freetdm" channel-prefix="wp3" channel-map="1-31"/>
</physical_terminations>
<peers>
<param name="peer" value = "peer-1" />
<param name="peer" value = "peer-2" />
<param name="peer" value = "peer-3" />
</peers>
</mg_profile>
</mg_profiles>
<mg_peers>
<mg_peer name="peer-1">
<param name="ip" value="192.168.1.49"/>
<param name="port" value="2944"/>
<param name="encoding-scheme" value="TEXT"/>
<param name="transport-type" value="UDP"/>
<param name="message-identifier" value="<remote1.mgc.com>" />
</mg_peer>
<mg_peer name="peer-2">
<param name="ip" value="192.168.1.55"/>
<param name="port" value="2944"/>
<param name="encoding-scheme" value="BINARY"/>
<param name="transport-type" value="UDP"/>
<param name="message-identifier" value="<remote2.mgc.com>" />
</mg_peer>
<mg_peer name="peer-3">
<param name="ip" value="192.168.1.44"/>
<param name="port" value="2944"/>
<param name="transport-type" value="UDP"/>
<param name="encoding-scheme" value="TEXT"/>
<param name="message-identifier" value="<remote3.mgc.com>" />
</mg_peer>
</mg_peers>
</configuration>

View File

@ -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);

View File

@ -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);
@ -97,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();
@ -573,7 +575,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 */
@ -599,6 +601,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)
{
@ -1232,7 +1261,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);

View File

@ -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);

View File

@ -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)
@ -19,7 +20,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;
@ -57,12 +58,21 @@ 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 */
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;
@ -87,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);
@ -144,10 +158,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 +185,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()
};
@ -165,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;
}

View File

@ -66,14 +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_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 */

View File

@ -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 {
@ -30,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;
@ -45,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;