[mod_sofia] Add a unit-test for the 3pcc telephone event.
This commit is contained in:
parent
3e93f2423d
commit
8308233819
|
@ -584,6 +584,13 @@
|
||||||
</condition>
|
</condition>
|
||||||
</extension>
|
</extension>
|
||||||
|
|
||||||
|
<extension name="sipp_telephone_check">
|
||||||
|
<condition field="destination_number" expression="^1212121212$">
|
||||||
|
<action application="answer"/>
|
||||||
|
<action application="set" data="park_after_bridge=true"/>
|
||||||
|
<action application="park"/>
|
||||||
|
</condition>
|
||||||
|
</extension>
|
||||||
|
|
||||||
<extension name="sipp">
|
<extension name="sipp">
|
||||||
<condition>
|
<condition>
|
||||||
|
|
|
@ -37,6 +37,23 @@
|
||||||
int test_success = 0;
|
int test_success = 0;
|
||||||
int test_sofia_debug = 1;
|
int test_sofia_debug = 1;
|
||||||
|
|
||||||
|
static const char *test_wait_for_chan_var(switch_channel_t *channel, const char *seq)
|
||||||
|
{
|
||||||
|
int loop_count = 50;
|
||||||
|
const char *var=NULL;
|
||||||
|
do {
|
||||||
|
if (!strcmp(switch_channel_get_variable(channel, "sip_cseq"),seq)){
|
||||||
|
switch_sleep(100 * 1000);
|
||||||
|
var = switch_channel_get_variable(channel, "rtp_local_sdp_str");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch_sleep(100 * 1000);
|
||||||
|
} while(loop_count--);
|
||||||
|
|
||||||
|
return var;
|
||||||
|
}
|
||||||
|
|
||||||
static switch_bool_t has_ipv6()
|
static switch_bool_t has_ipv6()
|
||||||
{
|
{
|
||||||
switch_stream_handle_t stream = { 0 };
|
switch_stream_handle_t stream = { 0 };
|
||||||
|
@ -73,9 +90,9 @@ static void unregister_gw()
|
||||||
switch_safe_free(stream.data);
|
switch_safe_free(stream.data);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int start_sipp_uac(const char *ip, int remote_port,const char *scenario_uac, const char *extra)
|
static int start_sipp_uac(const char *ip, int remote_port, const char *dialed_number, const char *scenario_uac, const char *extra)
|
||||||
{
|
{
|
||||||
char *cmd = switch_mprintf("sipp %s:%d -nr -p 5062 -m 1 -s 1001 -recv_timeout 10000 -timeout 10s -sf %s -bg %s", ip, remote_port, scenario_uac, extra);
|
char *cmd = switch_mprintf("sipp %s:%d -nr -p 5062 -m 1 -s %s -recv_timeout 10000 -timeout 10s -sf %s -bg %s", ip, remote_port, dialed_number, scenario_uac, extra);
|
||||||
int sys_ret = switch_system(cmd, SWITCH_TRUE);
|
int sys_ret = switch_system(cmd, SWITCH_TRUE);
|
||||||
|
|
||||||
printf("%s\n", cmd);
|
printf("%s\n", cmd);
|
||||||
|
@ -199,9 +216,98 @@ FST_CORE_EX_BEGIN("./conf-sipp", SCF_VG | SCF_USE_SQL)
|
||||||
}
|
}
|
||||||
FST_TEARDOWN_END()
|
FST_TEARDOWN_END()
|
||||||
|
|
||||||
|
FST_TEST_BEGIN(uac_telephone_event_check)
|
||||||
|
{
|
||||||
|
const char *local_ip_v4 = switch_core_get_variable("local_ip_v4");
|
||||||
|
char *channel_data = NULL;
|
||||||
|
char uuid[100] = "";
|
||||||
|
int sipp_ret;
|
||||||
|
int sdp_count = 0 , loop_count =50;
|
||||||
|
switch_stream_handle_t stream = { 0 };
|
||||||
|
|
||||||
|
sipp_ret = start_sipp_uac(local_ip_v4, 5080, "1212121212", "sipp-scenarios/uac_telephone_event.xml", "");
|
||||||
|
if (sipp_ret < 0 || sipp_ret == 127) {
|
||||||
|
fst_requires(0); /* sipp not found */
|
||||||
|
}
|
||||||
|
|
||||||
|
do {
|
||||||
|
SWITCH_STANDARD_STREAM(stream);
|
||||||
|
switch_api_execute("show", "channels", NULL, &stream);
|
||||||
|
if (!strncmp((char *)stream.data, "uuid,", 5)) {
|
||||||
|
channel_data = switch_mprintf("%s", (char *)stream.data);
|
||||||
|
switch_safe_free(stream.data);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch_safe_free(stream.data);
|
||||||
|
switch_sleep(100 * 1000);
|
||||||
|
} while (loop_count--);
|
||||||
|
|
||||||
|
if (channel_data) {
|
||||||
|
char *temp = NULL;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
if ((temp = strchr(channel_data, '\n'))) {
|
||||||
|
temp++;
|
||||||
|
for (i = 0; temp[i] != ',' && i < 99; i++){
|
||||||
|
uuid[i] = temp[i];
|
||||||
|
}
|
||||||
|
uuid[i] = '\0';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!zstr(uuid)) {
|
||||||
|
switch_core_session_t *session = switch_core_session_locate(uuid);
|
||||||
|
switch_channel_t *channel;
|
||||||
|
const char *sdp_str1 = NULL, *sdp_str2 = NULL;
|
||||||
|
|
||||||
|
fst_requires(session);
|
||||||
|
channel = switch_core_session_get_channel(session);
|
||||||
|
|
||||||
|
sdp_str1 = test_wait_for_chan_var(channel,"1");
|
||||||
|
sdp_str2 = test_wait_for_chan_var(channel,"2");
|
||||||
|
|
||||||
|
if (sdp_str1 && sdp_str2 && (strstr(sdp_str1,"telephone-event")) && (strstr(sdp_str2,"telephone-event"))){
|
||||||
|
temp = NULL;
|
||||||
|
sdp_count = 1;
|
||||||
|
|
||||||
|
if ((temp = strstr(sdp_str2,"RTP/AVP"))) {
|
||||||
|
int count = 0;
|
||||||
|
|
||||||
|
for (i = 7; temp[i] != '\n' && i < 99; i++) {
|
||||||
|
/* checking for payload-type 101.*/
|
||||||
|
if(temp[i++] == '1' && temp[i++] == '0' && temp[i++] == '1') {
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (count > 1) {
|
||||||
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Duplicate entry of payload in SDP.\n");
|
||||||
|
sdp_count = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Telephone-event missing in SDP.\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
switch_core_session_rwunlock(session);
|
||||||
|
} else {
|
||||||
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Uuid not found in Channel Data.\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
free(channel_data);
|
||||||
|
} else {
|
||||||
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Unable to find Channel Data.\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
fst_check(sdp_count == 1);
|
||||||
|
/* sipp should timeout, attempt kill, just in case.*/
|
||||||
|
kill_sipp();
|
||||||
|
}
|
||||||
|
FST_TEST_END()
|
||||||
|
|
||||||
FST_TEST_BEGIN(uac_digest_leak_udp)
|
FST_TEST_BEGIN(uac_digest_leak_udp)
|
||||||
{
|
{
|
||||||
switch_core_session_t *session;
|
switch_core_session_t *session;
|
||||||
switch_call_cause_t cause;
|
switch_call_cause_t cause;
|
||||||
switch_status_t status;
|
switch_status_t status;
|
||||||
switch_channel_t *channel;
|
switch_channel_t *channel;
|
||||||
|
@ -211,7 +317,7 @@ FST_CORE_EX_BEGIN("./conf-sipp", SCF_VG | SCF_USE_SQL)
|
||||||
switch_event_bind("sofia", SWITCH_EVENT_CUSTOM, NULL, event_handler, NULL);
|
switch_event_bind("sofia", SWITCH_EVENT_CUSTOM, NULL, event_handler, NULL);
|
||||||
|
|
||||||
status = switch_ivr_originate(NULL, &session, &cause, "loopback/+15553334444", 2, NULL, NULL, NULL, NULL, NULL, SOF_NONE, NULL, NULL);
|
status = switch_ivr_originate(NULL, &session, &cause, "loopback/+15553334444", 2, NULL, NULL, NULL, NULL, NULL, SOF_NONE, NULL, NULL);
|
||||||
sipp_ret = start_sipp_uac(local_ip_v4, 5080, "sipp-scenarios/uac_digest_leak.xml", "");
|
sipp_ret = start_sipp_uac(local_ip_v4, 5080, "1001", "sipp-scenarios/uac_digest_leak.xml", "");
|
||||||
if (sipp_ret < 0 || sipp_ret == 127) {
|
if (sipp_ret < 0 || sipp_ret == 127) {
|
||||||
fst_requires(0); /* sipp not found */
|
fst_requires(0); /* sipp not found */
|
||||||
}
|
}
|
||||||
|
@ -250,7 +356,7 @@ FST_CORE_EX_BEGIN("./conf-sipp", SCF_VG | SCF_USE_SQL)
|
||||||
|
|
||||||
FST_TEST_BEGIN(uac_digest_leak_tcp)
|
FST_TEST_BEGIN(uac_digest_leak_tcp)
|
||||||
{
|
{
|
||||||
switch_core_session_t *session;
|
switch_core_session_t *session;
|
||||||
switch_call_cause_t cause;
|
switch_call_cause_t cause;
|
||||||
switch_status_t status;
|
switch_status_t status;
|
||||||
switch_channel_t *channel;
|
switch_channel_t *channel;
|
||||||
|
@ -260,7 +366,7 @@ FST_CORE_EX_BEGIN("./conf-sipp", SCF_VG | SCF_USE_SQL)
|
||||||
switch_event_bind("sofia", SWITCH_EVENT_CUSTOM, NULL, event_handler, NULL);
|
switch_event_bind("sofia", SWITCH_EVENT_CUSTOM, NULL, event_handler, NULL);
|
||||||
|
|
||||||
status = switch_ivr_originate(NULL, &session, &cause, "loopback/+15553334444", 2, NULL, NULL, NULL, NULL, NULL, SOF_NONE, NULL, NULL);
|
status = switch_ivr_originate(NULL, &session, &cause, "loopback/+15553334444", 2, NULL, NULL, NULL, NULL, NULL, SOF_NONE, NULL, NULL);
|
||||||
sipp_ret = start_sipp_uac(local_ip_v4, 5080, "sipp-scenarios/uac_digest_leak-tcp.xml", "-t t1");
|
sipp_ret = start_sipp_uac(local_ip_v4, 5080, "1001", "sipp-scenarios/uac_digest_leak-tcp.xml", "-t t1");
|
||||||
if (sipp_ret < 0 || sipp_ret == 127) {
|
if (sipp_ret < 0 || sipp_ret == 127) {
|
||||||
fst_requires(0); /* sipp not found */
|
fst_requires(0); /* sipp not found */
|
||||||
}
|
}
|
||||||
|
@ -299,7 +405,7 @@ FST_CORE_EX_BEGIN("./conf-sipp", SCF_VG | SCF_USE_SQL)
|
||||||
|
|
||||||
FST_TEST_BEGIN(uac_digest_leak_udp_ipv6)
|
FST_TEST_BEGIN(uac_digest_leak_udp_ipv6)
|
||||||
{
|
{
|
||||||
switch_core_session_t *session;
|
switch_core_session_t *session;
|
||||||
switch_call_cause_t cause;
|
switch_call_cause_t cause;
|
||||||
switch_status_t status;
|
switch_status_t status;
|
||||||
switch_channel_t *channel;
|
switch_channel_t *channel;
|
||||||
|
@ -318,9 +424,9 @@ FST_CORE_EX_BEGIN("./conf-sipp", SCF_VG | SCF_USE_SQL)
|
||||||
status = switch_ivr_originate(NULL, &session, &cause, "loopback/+15553334444", 2, NULL, NULL, NULL, NULL, NULL, SOF_NONE, NULL, NULL);
|
status = switch_ivr_originate(NULL, &session, &cause, "loopback/+15553334444", 2, NULL, NULL, NULL, NULL, NULL, SOF_NONE, NULL, NULL);
|
||||||
|
|
||||||
if (!ipv6) {
|
if (!ipv6) {
|
||||||
sipp_ret = start_sipp_uac(local_ip_v6, 6060, "sipp-scenarios/uac_digest_leak-ipv6.xml", "-i [::1]");
|
sipp_ret = start_sipp_uac(local_ip_v6, 6060, "1001", "sipp-scenarios/uac_digest_leak-ipv6.xml", "-i [::1]");
|
||||||
} else {
|
} else {
|
||||||
sipp_ret = start_sipp_uac(ipv6, 6060, "sipp-scenarios/uac_digest_leak-ipv6.xml", "-i [::1] -mi [::1]");
|
sipp_ret = start_sipp_uac(ipv6, 6060, "1001", "sipp-scenarios/uac_digest_leak-ipv6.xml", "-i [::1] -mi [::1]");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sipp_ret < 0 || sipp_ret == 127) {
|
if (sipp_ret < 0 || sipp_ret == 127) {
|
||||||
|
|
|
@ -0,0 +1,159 @@
|
||||||
|
<?xml version="1.0" encoding="ISO-8859-1" ?>
|
||||||
|
<scenario name="UAC with media">
|
||||||
|
<!-- In client mode (sipp placing calls), the Call-ID MUST be -->
|
||||||
|
<!-- generated by sipp. To do so, use [call_id] keyword. -->
|
||||||
|
<send retrans="500">
|
||||||
|
<![CDATA[
|
||||||
|
|
||||||
|
INVITE sip:[service]@[remote_ip]:[remote_port] SIP/2.0
|
||||||
|
Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]
|
||||||
|
From: t_sipp <sip:t_sipp@[local_ip]:[local_port]>;tag=[call_number]
|
||||||
|
To: sut <sip:[service]@[remote_ip]:[remote_port]>
|
||||||
|
Call-ID: [call_id]
|
||||||
|
CSeq: 1 INVITE
|
||||||
|
Contact: sip:t_sipp@[local_ip]:[local_port]
|
||||||
|
Max-Forwards: 70
|
||||||
|
Subject: Performance Test
|
||||||
|
Content-Type: application/sdp
|
||||||
|
Content-Length: [len]
|
||||||
|
|
||||||
|
v=0
|
||||||
|
o=user1 53655765 2353687637 IN IP[local_ip_type] [local_ip]
|
||||||
|
s=-
|
||||||
|
c=IN IP[local_ip_type] [local_ip]
|
||||||
|
t=0 0
|
||||||
|
m=audio [auto_media_port] RTP/AVP 8 0 18 101
|
||||||
|
a=rtpmap:8 PCMA/8000
|
||||||
|
a=rtpmap:0 PCMU/8000
|
||||||
|
a=rtpmap:18 G729/8000
|
||||||
|
a=fmtp:18 annexb=no
|
||||||
|
a=rtpmap:101 telephone-event/8000
|
||||||
|
a=fmtp:101 0-11,16
|
||||||
|
a=sendrecv
|
||||||
|
a=ptime:20
|
||||||
|
]]>
|
||||||
|
</send>
|
||||||
|
|
||||||
|
<recv response="100" optional="true">
|
||||||
|
</recv>
|
||||||
|
|
||||||
|
<recv response="180" optional="true">
|
||||||
|
</recv>
|
||||||
|
|
||||||
|
<!-- By adding rrs="true" (Record Route Sets), the route sets -->
|
||||||
|
<!-- are saved and used for following messages sent. Useful to test -->
|
||||||
|
<!-- against stateful SIP proxies/B2BUAs. -->
|
||||||
|
<recv response="200" rtd="true" crlf="true">
|
||||||
|
</recv>
|
||||||
|
|
||||||
|
<!-- Packet lost can be simulated in any send/recv message by -->
|
||||||
|
<!-- by adding the 'lost = "10"'. Value can be [1-100] percent. -->
|
||||||
|
<send>
|
||||||
|
<![CDATA[
|
||||||
|
|
||||||
|
ACK sip:[service]@[remote_ip]:[remote_port] SIP/2.0
|
||||||
|
Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]
|
||||||
|
From: t_sipp <sip:t_sipp@[local_ip]:[local_port]>;tag=[call_number]
|
||||||
|
To: sut <sip:[service]@[remote_ip]:[remote_port]>[peer_tag_param]
|
||||||
|
Call-ID: [call_id]
|
||||||
|
CSeq: 1 ACK
|
||||||
|
Contact: sip:t_sipp@[local_ip]:[local_port]
|
||||||
|
Max-Forwards: 70
|
||||||
|
Subject: Performance Test
|
||||||
|
Content-Length: 0
|
||||||
|
|
||||||
|
]]>
|
||||||
|
</send>
|
||||||
|
|
||||||
|
<pause milliseconds="1500"/>
|
||||||
|
|
||||||
|
<send retrans="500">
|
||||||
|
<![CDATA[
|
||||||
|
|
||||||
|
INVITE sip:[service]@[remote_ip]:[remote_port] SIP/2.0
|
||||||
|
Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]
|
||||||
|
From: t_sipp <sip:t_sipp@[local_ip]:[local_port]>;tag=[call_number]
|
||||||
|
To: sut <sip:[service]@[remote_ip]:[remote_port]>
|
||||||
|
Call-ID: [call_id]
|
||||||
|
CSeq: 2 INVITE
|
||||||
|
Contact: sip:t_sipp@[local_ip]:[local_port]
|
||||||
|
Max-Forwards: 70
|
||||||
|
Subject: Performance Test
|
||||||
|
Content-Length: [len]
|
||||||
|
|
||||||
|
]]>
|
||||||
|
</send>
|
||||||
|
|
||||||
|
|
||||||
|
<recv response="100" optional="true">
|
||||||
|
</recv>
|
||||||
|
<recv response="200" rtd="true" crlf="true">
|
||||||
|
<!--<action>
|
||||||
|
<ereg regexp="m=audio.*[0-9][1-5].*101.*"
|
||||||
|
<ereg regexp="101 telephone-event"
|
||||||
|
search_in="body"
|
||||||
|
check_it="true"
|
||||||
|
assign_to="5"/>
|
||||||
|
</action>-->
|
||||||
|
</recv>
|
||||||
|
|
||||||
|
<send>
|
||||||
|
<![CDATA[
|
||||||
|
|
||||||
|
ACK sip:[service]@[remote_ip]:[remote_port] SIP/2.0
|
||||||
|
Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]
|
||||||
|
From: t_sipp <sip:t_sipp@[local_ip]:[local_port]>;tag=[call_number]
|
||||||
|
To: sut <sip:[service]@[remote_ip]:[remote_port]>[peer_tag_param]
|
||||||
|
Call-ID: [call_id]
|
||||||
|
CSeq: 2 ACK
|
||||||
|
Contact: sip:t_sipp@[local_ip]:[local_port]
|
||||||
|
Max-Forwards: 70
|
||||||
|
Subject: Performance Test
|
||||||
|
Content-Type: application/sdp
|
||||||
|
Content-Length: [len]
|
||||||
|
|
||||||
|
v=0
|
||||||
|
o=user1 53655765 2353687637 IN IP[local_ip_type] [local_ip]
|
||||||
|
s=
|
||||||
|
c=IN IP[local_ip_type] [local_ip]
|
||||||
|
t=0 0
|
||||||
|
m=audio [auto_media_port] RTP/AVP 8 0 101
|
||||||
|
a=rtpmap:8 PCMA/8000
|
||||||
|
a=rtpmap:0 PCMU/8000
|
||||||
|
a=rtpmap:101 telephone-event/8000
|
||||||
|
a=fmtp:101 0-15
|
||||||
|
a=sendrecv
|
||||||
|
a=ptime:20
|
||||||
|
|
||||||
|
]]>
|
||||||
|
</send>
|
||||||
|
|
||||||
|
<send retrans="500">
|
||||||
|
<![CDATA[
|
||||||
|
|
||||||
|
BYE sip:[service]@[remote_ip]:[remote_port] SIP/2.0
|
||||||
|
Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]
|
||||||
|
From: t_sipp <sip:t_sipp@[local_ip]:[local_port]>;tag=[call_number]
|
||||||
|
To: sut <sip:[service]@[remote_ip]:[remote_port]>[peer_tag_param]
|
||||||
|
Call-ID: [call_id]
|
||||||
|
CSeq: 3 BYE
|
||||||
|
Contact: sip:t_sipp@[local_ip]:[local_port]
|
||||||
|
Max-Forwards: 70
|
||||||
|
Subject: Performance Test
|
||||||
|
Content-Length: 0
|
||||||
|
|
||||||
|
]]>
|
||||||
|
</send>
|
||||||
|
|
||||||
|
<recv response="200" crlf="true">
|
||||||
|
</recv>
|
||||||
|
|
||||||
|
|
||||||
|
<!-- definition of the response time repartition table (unit is ms) -->
|
||||||
|
<ResponseTimeRepartition value="10, 20, 30, 40, 50, 100, 150, 200"/>
|
||||||
|
|
||||||
|
<!-- definition of the call length repartition table (unit is ms) -->
|
||||||
|
<CallLengthRepartition value="10, 50, 100, 500, 1000, 5000, 10000"/>
|
||||||
|
|
||||||
|
</scenario>
|
||||||
|
|
Loading…
Reference in New Issue