Skip to content

Commit dc59d6a

Browse files
committed
pjsip_header: Modify test to include new PJSIP_INHERITABLE_HEADER dialplan function
1 parent 4d80012 commit dc59d6a

File tree

6 files changed

+249
-1
lines changed

6 files changed

+249
-1
lines changed

tests/channels/pjsip/dialplan_functions/pjsip_header/configs/ast1/extensions.conf

Lines changed: 58 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
[default]
55

6-
; The inbound call.
6+
; An inbound call.
77

88
exten => inbound,1,NoOp()
99
same => n,Answer()
@@ -46,3 +46,60 @@ exten => outbound-handler,1,NoOp()
4646
same => n,Set(custom1_var=${PJSIP_HEADER(read,Custom-Header)})
4747
same => n,UserEvent(OutboundResult,result:${IF($[${LEN(${custom1_var})}=0]?pass:fail)})
4848
same => n,Return()
49+
50+
; Pre Dial handler to modify the passed headers
51+
52+
exten => modify-headers,1,noOp()
53+
same => n,Set(PJSIP_HEADER(add,X-custom-OB-1)=epsilon)
54+
same => n,Set(PJSIP_HEADER(add,X-custom-OB-2)=zeta)
55+
same => n,Set(PJSIP_HEADER(add,X-custom-OB-3)=theta)
56+
same => n,Set(PJSIP_HEADER(update,X-custom-OB-2)=zeta-two)
57+
same => n,Set(PJSIP_HEADER(remove,X-custom-OB-3)=)
58+
same => n,Set(PJSIP_INHERITABLE_HEADER(remove,X-custom-3)=)
59+
same => n,Set(PJSIP_INHERITABLE_HEADER(update,X-custom-6)=lambda)
60+
same => n,Return()
61+
62+
; An inbound call that uses PJSIP_HEADER pass function to set headers
63+
; that will be passed to the outbound call.
64+
65+
exten => inbound-pass,1,NoOp()
66+
same => n,Answer()
67+
same => n,Set(PJSIP_INHERITABLE_HEADER(add,X-custom-1)=alpha)
68+
same => n,Set(PJSIP_INHERITABLE_HEADER(add,X-custom-2)=beta)
69+
same => n,Set(PJSIP_INHERITABLE_HEADER(add,X-custom-3)=gamma)
70+
same => n,Set(PJSIP_INHERITABLE_HEADER(add,X-custom-4)=delta)
71+
same => n,Set(PJSIP_INHERITABLE_HEADER(add,X-custom-5)=sigma)
72+
same => n,Set(PJSIP_INHERITABLE_HEADER(add,X-custom-6)=omega)
73+
same => n,Set(PJSIP_INHERITABLE_HEADER(remove,X-custom-4)=)
74+
same => n,Set(PJSIP_INHERITABLE_HEADER(update,X-custom-5)=kappa)
75+
same => n,Dial(PJSIP/outbound-pass,,b(default^modify-headers^1))
76+
same => n,Echo()
77+
same => n,Hangup()
78+
79+
exten => inbound-pass-local,1,noOp()
80+
same => n,Answer()
81+
same => n,Dial(Local/inbound-pass@default,,)
82+
same => n,Hangup()
83+
84+
exten => inbound-pass-2,1,NoOp()
85+
same => n,Dial(PJSIP/outbound-pass,,b(default^modify-headers^1))
86+
same => n,Echo()
87+
same => n,Hangup()
88+
89+
exten => inbound-pass-local-2-extra,1,noOp()
90+
same => n,Answer()
91+
same => n,Dial(Local/inbound-pass-2@default,,)
92+
same => n,Hangup()
93+
94+
exten => inbound-pass-local-2,1,noOp()
95+
same => n,Answer()
96+
same => n,Set(PJSIP_INHERITABLE_HEADER(add,X-custom-1)=alpha)
97+
same => n,Set(PJSIP_INHERITABLE_HEADER(add,X-custom-2)=beta)
98+
same => n,Set(PJSIP_INHERITABLE_HEADER(add,X-custom-3)=gamma)
99+
same => n,Set(PJSIP_INHERITABLE_HEADER(add,X-custom-4)=delta)
100+
same => n,Set(PJSIP_INHERITABLE_HEADER(add,X-custom-5)=sigma)
101+
same => n,Set(PJSIP_INHERITABLE_HEADER(add,X-custom-6)=omega)
102+
same => n,Set(PJSIP_INHERITABLE_HEADER(remove,X-custom-4)=)
103+
same => n,Set(PJSIP_INHERITABLE_HEADER(update,X-custom-5)=kappa)
104+
same => n,Dial(Local/inbound-pass-local-2-extra@default,,)
105+
same => n,Hangup()

tests/channels/pjsip/dialplan_functions/pjsip_header/configs/ast1/pjsip.conf

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,14 @@ aors=inbound
2828
[inbound](aor_t)
2929
contact=sip:inbound@127.0.0.1:5061
3030

31+
;; inbound-pass
32+
33+
[inbound-pass](endpoint_t)
34+
aors=inbound-pass
35+
36+
[inbound-pass](aor_t)
37+
contact=sip:inbound@127.0.0.1:5064
38+
3139
;; outbound
3240

3341
[outbound](endpoint_t)
@@ -43,3 +51,11 @@ aors=outbound-recv
4351

4452
[outbound-recv](aor_t)
4553
contact=sip:outbound-recv@127.0.0.1:5063
54+
55+
;; outbound-pass
56+
57+
[outbound-pass](endpoint_t)
58+
aors=outbound-pass
59+
60+
[outbound-pass](aor_t)
61+
contact=sip:outbound-pass@127.0.0.1:5065

tests/channels/pjsip/dialplan_functions/pjsip_header/sipp/outbound-recv-headers.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@
5555

5656
<recv request="ACK" rtd="true" crlf="true" />
5757

58+
<pause milliseconds="1000"/>
59+
5860
<send retrans="500">
5961
<![CDATA[
6062
BYE sip:outbound@[remote_ip]:[remote_port] SIP/2.0
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
<?xml version="1.0" encoding="ISO-8859-1" ?>
2+
<!DOCTYPE scenario SYSTEM "sipp.dtd">
3+
4+
<scenario name="Send INVITE from an inbound channel">
5+
<send retrans="500">
6+
<![CDATA[
7+
INVITE sip:[service]@[remote_ip]:[remote_port] SIP/2.0
8+
Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]
9+
From: sipp <sip:inbound@[local_ip]:[local_port]>;tag=[pid]SIPpTag00[call_number]
10+
To: sut <sip:[service]@[remote_ip]:[remote_port]>
11+
Call-ID: [call_id]
12+
CSeq: 1 INVITE
13+
Contact: sip:sipp@[local_ip]:[local_port]
14+
Max-Forwards: 70
15+
Subject: Test
16+
Content-Type: application/sdp
17+
Content-Length: [len]
18+
19+
v=0
20+
o=phoneA 53655765 2353687637 IN IP[local_ip_type] [local_ip]
21+
s=-
22+
c=IN IP[media_ip_type] [media_ip]
23+
t=0 0
24+
m=audio [media_port] RTP/AVP 0
25+
a=rtpmap:0 PCMU/8000
26+
]]>
27+
</send>
28+
29+
<recv response="100" optional="true">
30+
</recv>
31+
32+
<recv response="200" rtd="true">
33+
</recv>
34+
35+
<send>
36+
<![CDATA[
37+
ACK sip:[service]@[remote_ip]:[remote_port] SIP/2.0
38+
Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]
39+
From: sipp <sip:inbound@[local_ip]:[local_port]>;tag=[pid]SIPpTag00[call_number]
40+
To: sut <sip:[service]@[remote_ip]:[remote_port]>[peer_tag_param]
41+
Call-ID: [call_id]
42+
CSeq: 1 ACK
43+
Contact: sip:sipp@[local_ip]:[local_port]
44+
Max-Forwards: 70
45+
Subject: Test
46+
Content-Length: 0
47+
]]>
48+
</send>
49+
50+
<recv request="BYE" crlf="true" />
51+
52+
<send retrans="500">
53+
<![CDATA[
54+
SIP/2.0 200 OK
55+
[last_Via:]
56+
[last_From:]
57+
[last_To:];tag=[call_number]
58+
[last_Call-ID:]
59+
[last_CSeq:]
60+
Contact: <sip:outbound@[local_ip]:[local_port];transport=[transport]>
61+
Allow: INVITE, ACK, MESSAGE, BYE
62+
Content-Lnegth: 0
63+
]]>
64+
</send>
65+
66+
<!-- definition of the response time repartition table (unit is ms) -->
67+
<ResponseTimeRepartition value="10, 20, 30, 40, 50, 100, 150, 200"/>
68+
69+
<!-- definition of the call length repartition table (unit is ms) -->
70+
<CallLengthRepartition value="10, 50, 100, 500, 1000, 5000, 10000"/>
71+
72+
</scenario>
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
<?xml version="1.0" encoding="ISO-8859-1" ?>
2+
<!DOCTYPE scenario SYSTEM "sipp.dtd">
3+
4+
<scenario name="Receive INVITE">
5+
<Global variables="remote_tag" />
6+
<User variables="OB1,OB2,OB3,IB1,IB2,IB3,IB4,IB5,IB6" />
7+
<recv request="INVITE" crlf="true">
8+
<!-- Save the from tag. We'll need it when we send our BYE -->
9+
<action>
10+
<ereg regexp=".*(;tag=.*)" search_in="hdr" header="From:" check_it="true" assign_to="1,remote_tag"/>
11+
<ereg regexp="epsilon" search_in="hdr" header="X-custom-OB-1:" check_it="true" assign_to="OB1"/>
12+
<ereg regexp="zeta-two" search_in="hdr" header="X-custom-OB-2:" check_it="true" assign_to="OB2"/>
13+
<ereg regexp="X-custom-OB-3:.*" search_in="msg" check_it_inverse="true" assign_to="OB3"/>
14+
<ereg regexp="alpha" search_in="hdr" header="X-custom-1:" check_it="true" assign_to="IB1"/>
15+
<ereg regexp="beta" search_in="hdr" header="X-custom-2:" check_it="true" assign_to="IB2"/>
16+
<ereg regexp="X-custom-3:.*" search_in="msg" check_it_inverse="true" assign_to="IB3"/>
17+
<ereg regexp="X-custom-4:.*" search_in="msg" check_it_inverse="true" assign_to="IB4"/>
18+
<ereg regexp="kappa" search_in="hdr" header="X-custom-5:" check_it="true" assign_to="IB5"/>
19+
<ereg regexp="lambda" search_in="hdr" header="X-custom-6:" check_it="true" assign_to="IB6"/>
20+
</action>
21+
</recv>
22+
23+
<Reference variables="1","OB1","OB2","IB1","IB2","IB5","IB6" />
24+
25+
<send>
26+
<![CDATA[
27+
SIP/2.0 180 Ringing
28+
[last_Via:]
29+
[last_From:]
30+
[last_To:];tag=[pid]SIPpTag01[call_number]
31+
[last_Call-ID:]
32+
[last_CSeq:]
33+
Contact: <sip:[local_ip]:[local_port];transport=[transport]>
34+
Content-Length: 0
35+
]]>
36+
</send>
37+
38+
<send retrans="500">
39+
<![CDATA[
40+
SIP/2.0 200 OK
41+
[last_Via:]
42+
[last_From:]
43+
[last_To:];tag=[pid]SIPpTag01[call_number]
44+
[last_Call-ID:]
45+
[last_CSeq:]
46+
Contact: <sip:[local_ip]:[local_port];transport=[transport]>
47+
Content-Type: application/sdp
48+
Content-Length: [len]
49+
50+
v=0
51+
o=- 1324901698 1324901698 IN IP[local_ip_type] [local_ip]
52+
s=-
53+
c=IN IP[media_ip_type] [media_ip]
54+
t=0 0
55+
m=audio [media_port] RTP/AVP 0 101
56+
a=sendrecv
57+
a=rtpmap:0 PCMU/8000
58+
a=rtpmap:101 telephone-event/8000
59+
]]>
60+
</send>
61+
62+
<recv request="ACK" rtd="true" crlf="true" />
63+
64+
<pause />
65+
66+
<send retrans="500">
67+
<![CDATA[
68+
BYE sip:outbound@[remote_ip]:[remote_port] SIP/2.0
69+
Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]
70+
From: <sip:outbound-recv@[local_ip]:[local_port]>;tag=[pid]SIPpTag01[call_number]
71+
To: <sip:outbound@[remote_ip]:[remote_port]>[$remote_tag]
72+
[last_Call-ID:]
73+
CSeq: [cseq] BYE
74+
Contact: sip:outbound-recv@[local_ip]:[local_port]
75+
Max-Forwards: 70
76+
Subject: Test
77+
Content-Length: 0
78+
]]>
79+
</send>
80+
81+
<recv response="200" />
82+
</scenario>

tests/channels/pjsip/dialplan_functions/pjsip_header/test-config.yaml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,25 @@ test-object-config:
2424
- { 'key-args': {'scenario': 'outbound-headers.xml', '-i': '127.0.0.1', '-p': '5062'} }
2525
# Outbound-recv-headers receives the call
2626
- { 'key-args': {'scenario': 'outbound-recv-headers.xml', '-i': '127.0.0.1', '-p': '5063'} }
27+
-
28+
scenarios:
29+
# Use pass function to add headers on the inbound channel that are inherited to the outbound channel
30+
- { 'key-args': {'scenario': 'pass-headers.xml', '-i': '127.0.0.1', '-p': '5064', '-s': 'inbound-pass'} }
31+
# Outbound-recv-headers receives the call
32+
- { 'key-args': {'scenario': 'pass-recv-headers.xml', '-i': '127.0.0.1', '-p': '5065', '-d': '3000'} }
33+
-
34+
scenarios:
35+
# Use pass function to add headers on the inbound channel that are inherited to the outbound channel via local channel
36+
- { 'key-args': {'scenario': 'pass-headers.xml', '-i': '127.0.0.1', '-p': '5064', '-s': 'inbound-pass-local'} }
37+
# Outbound-recv-headers receives the call
38+
- { 'key-args': {'scenario': 'pass-recv-headers.xml', '-i': '127.0.0.1', '-p': '5065', '-d': '3000'} }
39+
-
40+
scenarios:
41+
# Use pass function to add headers on a local channel that are inherited to the outbound channel via local channel
42+
- { 'key-args': {'scenario': 'pass-headers.xml', '-i': '127.0.0.1', '-p': '5064', '-s': 'inbound-pass-local-2'} }
43+
# Outbound-recv-headers receives the call
44+
- { 'key-args': {'scenario': 'pass-recv-headers.xml', '-i': '127.0.0.1', '-p': '5065', '-d': '3000'} }
45+
2746

2847
ami-config:
2948
-

0 commit comments

Comments
 (0)