01-16-2018 10:05 AM - edited 03-17-2019 11:57 AM
I'm trying to look for and copy a SPECIFIC number in the 'From' header into the 'Diversion' header of a SIP message in CUBE. For example, if we have an INVITE that has 7145551212 in the FROM header and there's a DIVERSION header that has 6144441212 as the number, I want to replace 6144441212 with 7145551212. Is this possible? So far I've found an example that copies anything in the From header into the Diversion header, but I can't find a way to target a specific number in the From header and if there's a match for that in a given SIP Invite take that number and place it into the Diversion header (remove the original number in the Diversion header).
Trying various combinations of the commands below, I was able to get this to work to copy anything in the From header into the Diversion header, but I really need to target a specific number in the From header. If we take just anything that's in the From header and put that in the Diversion header, it creates other problems.
request INVITE sip-header From copy "<sip:(.*)@(.*)>" u01
request INVITE sip-header Diversion modify ".*@(.*)" "Diversion: <sip:\u01@192.168.1.1>"
I used Cisco's SIP profile test page to test all my various entries and so far I just can't find a way to do this (match a specific number in the From header and copy that into the Diversion header). The reason I need to do this is to fix it so our service provider doesn't reject the call due to the diversion header containing a number we don't own on their SIP trunks.
https://cway.cisco.com/tools/SipProfileTest/
Solved! Go to Solution.
01-16-2018 02:31 PM
Good Afternoon,
When you get a free moment please try the sip profile below.
voice class sip-profiles XXX <-- number of the sip profile you would like to use
rule 10 request ANY sip-header From copy "(7145551212)" u01
rule 20 request ANY sip-header Diversion copy "sip:(.*)@" u02
rule 30 request ANY sip-header Diversion modify "sip:(.*)@" "sip:\u01@"
rule 40 request ANY sip-header Diversion modify "sip:@" "sip:\u02@"
!
Dial-peer voice YYY <-- outgoing dial-peer number
voice-class sip profile XXX
Received Invite matching from field
Received:
INVITE sip:6002@1.1.1.1:5060 SIP/2.0
From: <sip:7145551212@2.2.2.2>;tag=18644SIPpTag001
Diversion: <sip:6145551212@2.2.2.2>
Sent invite
Sent:
INVITE sip:6002@4.4.4.4:5080 SIP/2.0
From: <sip:7145551212@5.5.5.5>;tag=1CC20E-15EC
Diversion: <sip:7145551212@6.6.6.6>
Received Invite non matching from field
Received:
INVITE sip:6002@1.1.1.1:5060 SIP/2.0
From: <sip:7145551211@2.2.2.2>;tag=18644SIPpTag002
Diversion: <sip:6145551212@2.2.2.2>
Sent:
INVITE sip:6002@4.4.4.4:5080 SIP/2.0
From: <sip:7145551212@5.5.5.5>;tag=1CC20E-15ED
Diversion: <sip:6145551212@6.6.6.6>
01-16-2018 02:31 PM
Good Afternoon,
When you get a free moment please try the sip profile below.
voice class sip-profiles XXX <-- number of the sip profile you would like to use
rule 10 request ANY sip-header From copy "(7145551212)" u01
rule 20 request ANY sip-header Diversion copy "sip:(.*)@" u02
rule 30 request ANY sip-header Diversion modify "sip:(.*)@" "sip:\u01@"
rule 40 request ANY sip-header Diversion modify "sip:@" "sip:\u02@"
!
Dial-peer voice YYY <-- outgoing dial-peer number
voice-class sip profile XXX
Received Invite matching from field
Received:
INVITE sip:6002@1.1.1.1:5060 SIP/2.0
From: <sip:7145551212@2.2.2.2>;tag=18644SIPpTag001
Diversion: <sip:6145551212@2.2.2.2>
Sent invite
Sent:
INVITE sip:6002@4.4.4.4:5080 SIP/2.0
From: <sip:7145551212@5.5.5.5>;tag=1CC20E-15EC
Diversion: <sip:7145551212@6.6.6.6>
Received Invite non matching from field
Received:
INVITE sip:6002@1.1.1.1:5060 SIP/2.0
From: <sip:7145551211@2.2.2.2>;tag=18644SIPpTag002
Diversion: <sip:6145551212@2.2.2.2>
Sent:
INVITE sip:6002@4.4.4.4:5080 SIP/2.0
From: <sip:7145551212@5.5.5.5>;tag=1CC20E-15ED
Diversion: <sip:6145551212@6.6.6.6>
01-16-2018 03:13 PM
THANKS!!!!
I really appreciate your help. I just tried it on both our CUBEs and it works fine. The only thing I did different when adding it was I dropped the 'rule 10', 'rule 20', etc. Our existing entries under the SIP profile we use didn't have those so I just added it without that and it's working great. The new entries appear at the bottom of the list.
If you have time and don't mind and you know...would you mind explaining briefly each piece of these entries so I know how to build on this in the future if I need to? I think the syntax was one thing I had wrong, like not having ( and ) around the number I was looking for. Some of this is obvious to me but I was curious about how this all works together (all 4 entries). Anyway, not important if you don't explain but it would be helpful. Thanks again!
I added it like this (with the correct number I want to look for of course).
request ANY sip-header From copy "(7145551212)" u01
request ANY sip-header Diversion copy "sip:(.*)@" u02
request ANY sip-header Diversion modify "sip:(.*)@" "sip:\u01@"
request ANY sip-header Diversion modify "sip:@" "sip:\u02@"
01-16-2018 03:27 PM
request ANY sip-header From copy "(7145551212)" u01
if the from number equals what is between () IOS will assign that number to the variable u01
request ANY sip-header Diversion copy "sip:(.*)@" u02
If there is a diversion header assign copy whatever is between : and @ to the variable u02
request ANY sip-header Diversion modify "sip:(.*)@" "sip:\u01@"
assign the value of u01 between the : and @ sign
request ANY sip-header Diversion modify "sip:@" "sip:\u02@"
if the From field was not matched in step 1 the variable u01 will be empty
the diversion header would then be changed to sip:@, this rule looks for sip:@ and changes it back to the original number, because u02 is a copy of the original diverted number.
01-16-2018 03:29 PM
Awesome. Thank you.
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide