This rule involves the following actions.
If there is a FROM header, look at the URI username and do a REGEX to see if it is a toll-free number.
If the URI username is a toll-free number, then look to see if a DIVERSION header exists. If a DIVERSION header does not exist, action is to add a DIVERSION header.
set profiles signaling sipAdaptorProfile "DIVERSION_ADD" rule "1" set profiles signaling sipAdaptorProfile "DIVERSION_ADD" rule "1" applyMatchHeader "one" set profiles signaling sipAdaptorProfile "DIVERSION_ADD" rule "1" criterion "1" type "message" set profiles signaling sipAdaptorProfile "DIVERSION_ADD" rule "1" criterion "1" message messageTypes "request" methodTypes "invite" set profiles signaling sipAdaptorProfile "DIVERSION_ADD" rule "1" criterion "2" type "header" set profiles signaling sipAdaptorProfile "DIVERSION_ADD" rule "1" criterion "2" header name "From" condition "exist" hdrInstance "all" set profiles signaling sipAdaptorProfile "DIVERSION_ADD" rule "1" criterion "3" type "token" set profiles signaling sipAdaptorProfile "DIVERSION_ADD" rule "1" criterion "3" token condition "regex-match" tokenType "uriusername" set profiles signaling sipAdaptorProfile "DIVERSION_ADD" rule "1" criterion "3" token regexp string "^(\+?1)?(8(00|44|55|66|77|88)[2-9]\d{6})$" set profiles signaling sipAdaptorProfile "DIVERSION_ADD" rule "1" action "1" type "variable" operation "store" set profiles signaling sipAdaptorProfile "DIVERSION_ADD" rule "1" action "1" from type "value" value "tollfree" set profiles signaling sipAdaptorProfile "DIVERSION_ADD" rule "1" action "1" to type "variable" variableValue "var1" variableScopeValue "local" set profiles signaling sipAdaptorProfile "DIVERSION_ADD" rule "2" set profiles signaling sipAdaptorProfile "DIVERSION_ADD" rule "2" applyMatchHeader "one" set profiles signaling sipAdaptorProfile "DIVERSION_ADD" rule "2" criterion "1" type "message" set profiles signaling sipAdaptorProfile "DIVERSION_ADD" rule "2" criterion "1" message messageTypes "request" methodTypes "invite" set profiles signaling sipAdaptorProfile "DIVERSION_ADD" rule "2" criterion "2" type "variable" set profiles signaling sipAdaptorProfile "DIVERSION_ADD" rule "2" criterion "2" variable condition "has-value" variableID "var1" value "tollfree" set profiles signaling sipAdaptorProfile "DIVERSION_ADD" rule "2" criterion "3" type "header" set profiles signaling sipAdaptorProfile "DIVERSION_ADD" rule "2" criterion "3" header name "Diversion" condition "absent" hdrInstance "all" set profiles signaling sipAdaptorProfile "DIVERSION_ADD" rule "2" action "1" type "header" operation "add" headerPosition "first" set profiles signaling sipAdaptorProfile "DIVERSION_ADD" rule "2" action "1" to type "header" value "Diversion" set profiles signaling sipAdaptorProfile "DIVERSION_ADD" rule "2" action "1" from type "header" value sip:5553004000@10.10.100.12;reason=unknown;privacy=off
Input PDU:
INVITE sip:5551234567@10.10.100.10 SIP/2.0 Via: SIP/2.0/UDP 10.10.100.11;branch=z9hG4bK883050be30F7072B From: "John Doe" sip:8005551000@10.10.100.11;tag=BE07D554-EB9ADD71 To: sip:5551234567@10.10.100.10 CSeq: 1 INVITE Call-ID: 34045e80-54dc09fd-192eb6e2@10.10.100.11 Contact: sip:5557654321@10.10.100.11 Allow: INVITE, ACK, BYE, CANCEL, OPTIONS, INFO, MESSAGE, SUBSCRIBE, NOTIFY, PRACK, UPDATE, REFER User-Agent: PolycomVVX-VVX_600-UA/5.0.1.4068 Accept-Language: en Supported: 100rel,replaces Allow-Events: conference,talk,hold Max-Forwards: 70 Content-Type: application/sdp Content-Length: 353
Transformed PDU:
INVITE sip:5551234567@172.00.000.000:5073 SIP/2.0 Diversion: sip:5553004000@10.10.100.12;reason=unknown;privacy=off Via: SIP/2.0/UDP 10.10.100.12:5060;branch=z9hG4bK00Befc6712f6c9974d7 From: "John Doe" sip:8005551000@10.10.100.12;tag=gK002bbbdf To: sip:5551234567@172.00.000.000 Call-ID: 7777_77777777@10.10.100.12 CSeq: 835645375 INVITE Max-Forwards: 70 Allow: INVITE,ACK,CANCEL,BYE,REFER,NOTIFY,PRACK,OPTIONS Accept: application/sdp, application/isup, application/dtmf, application/dtmf-relay, multipart/mixed Contact: "8005551000" sip:5557654321@10.10.100.12:5060 Supported: timer,100rel,precondition,replaces Session-Expires: 1800 Min-SE: 90 Content-Length: 248 Content-Disposition: session; handling=required Content-Type: application/sdp