Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
F
freeswitch
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
张华
freeswitch
Commits
badc31f9
提交
badc31f9
authored
6月 20, 2012
作者:
Mathieu Rene
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'nsg-4.3' of git.sangoma.com:smg_freeswitch into nsg/4.3
上级
eae74df4
7b97ff47
全部展开
隐藏空白字符变更
内嵌
并排
正在显示
12 个修改的文件
包含
589 行增加
和
89 行删除
+589
-89
modules.conf.in
build/modules.conf.in
+1
-1
ftdm_io.c
libs/freetdm/src/ftdm_io.c
+182
-28
ftmod_sangoma_ss7_cli.c
...eetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_cli.c
+151
-32
ftmod_sangoma_ss7_m2ua.c
...etdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_m2ua.c
+21
-3
ftdm_types.h
libs/freetdm/src/include/private/ftdm_types.h
+4
-0
media_gateway.conf.xml
...d/endpoints/mod_media_gateway/conf/media_gateway.conf.xml
+50
-0
media_gateway_cli.c
src/mod/endpoints/mod_media_gateway/media_gateway_cli.c
+24
-1
media_gateway_stack.c
src/mod/endpoints/mod_media_gateway/media_gateway_stack.c
+32
-3
media_gateway_stack.h
src/mod/endpoints/mod_media_gateway/media_gateway_stack.h
+2
-0
media_gateway_xml.c
src/mod/endpoints/mod_media_gateway/media_gateway_xml.c
+87
-2
mod_media_gateway.c
src/mod/endpoints/mod_media_gateway/mod_media_gateway.c
+9
-7
mod_media_gateway.h
src/mod/endpoints/mod_media_gateway/mod_media_gateway.h
+26
-12
没有找到文件。
build/modules.conf.in
浏览文件 @
badc31f9
...
...
@@ -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
...
...
libs/freetdm/src/ftdm_io.c
浏览文件 @
badc31f9
...
...
@@ -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
;
u
int32_t
flagval
=
0
;
u
nsigned
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
,
"
\n
Total 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
,
"
\n
Invalid 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
,
"
\n
Total 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
);
...
...
libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_cli.c
浏览文件 @
badc31f9
差异被折叠。
点击展开。
libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_m2ua.c
浏览文件 @
badc31f9
...
...
@@ -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
;
}
/****************************************************************************************************/
...
...
libs/freetdm/src/include/private/ftdm_types.h
浏览文件 @
badc31f9
...
...
@@ -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
{
...
...
src/mod/endpoints/mod_media_gateway/conf/media_gateway.conf.xml
0 → 100755
浏览文件 @
badc31f9
<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>
src/mod/endpoints/mod_media_gateway/media_gateway_cli.c
浏览文件 @
badc31f9
...
...
@@ -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
);
...
...
src/mod/endpoints/mod_media_gateway/media_gateway_stack.c
浏览文件 @
badc31f9
...
...
@@ -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
mg
co_mg_enble_debu
g
()
int
mg
_enable_loggin
g
()
{
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
);
...
...
src/mod/endpoints/mod_media_gateway/media_gateway_stack.h
浏览文件 @
badc31f9
...
...
@@ -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
);
...
...
src/mod/endpoints/mod_media_gateway/media_gateway_xml.c
浏览文件 @
badc31f9
...
...
@@ -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
=
"me
gaco
.conf"
;
const
char
*
file
=
"me
dia_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
,
/*
E
nforce Max */
SWITCH_TRUE
,
/*
e
nforce 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
;
}
src/mod/endpoints/mod_media_gateway/mod_media_gateway.c
浏览文件 @
badc31f9
...
...
@@ -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
,
"m
egaco"
,
"megaco
"
,
megaco_function
,
MEGACO_FUNCTION_SYNTAX
);
SWITCH_ADD_API
(
api_interface
,
"m
g"
,
"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 */
...
...
src/mod/endpoints/mod_media_gateway/mod_media_gateway.h
浏览文件 @
badc31f9
...
...
@@ -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
;
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论