Forum Discussion

nshelton85's avatar
nshelton85
Icon for Altostratus rankAltostratus
Sep 28, 2018

Trying to use an iRule to match a pattern of dialed digits in a SIP message

I am trying to make an iRule to look at the called number in a SIP call to perform an action when a specific pattern of digits is dialed. For instance, if terminating phone number is an international call that starts with 011 and then has at least 7 more digits that can be anything in the range of 0-9 in each position. For instance 011[0-9][0-9][0-9][0-9][0-9][0-9][0-9]. What would be the best way to handle this?

when SIP_REQUEST {
     Set SRC_IP variable to the client's IP address
    set SRC_IP [clientside {IP::remote_addr}]
     Set DST_IP to the server's IP address
    set DST_IP [IP::server_addr]
     Defines how long an IP address is blocked on the dynamic blacklist (in seconds)
    set static::holdtime 3600
if {([SIP::method] == "INVITE") and ([class match $DST_IP equals SBCAdresses]) and ([class match $SRC_IP != SIP_Whitelist])}
{
    set ToNumber [SIP::to]
    set FromNumber [SIP::from]
            if {$FromNumber contains "011[0-9][0-9][0-9][0-9][0-9][0-9][0-9]"}
            {
            drop
            }
}

}