Yes, I see now from RFC 3261 that the Route header is a comma-delimited list. The RFC is a bit ambiguous about spaces (i.e., route,route is clearly acceptable, but is route, route also acceptable?), so as a simplification, I'll assume whitespace is not permitted between list elements. I will also assume that the Route header is not repeated. If it is, then you'll have to mix-in the logic above. I assume that there can be more than one instance of the route you wish to remove. If that's not the case, the logic can be somewhat simplified. Finally, I use a Data Group (called dg-route-blocks-to-remove) to match IP addresses in the Route entries.
when RULE_INIT {
set static::srm_route_remove_data_group "dg-route-blocks-to-remove"
}
when SIP_REQUEST {
set route_list [split [SIP::header Route] ,]
for { set i 0 } { $i < [llength $route_list] } { incr i } {
set ip [getfield [lindex $route_list $i] : 2]
if { [class match $ip equals $static::srm_route_remove_data_group] } {
lset route_list $i ""
}
}
if you are using 11.6, you may substitute "SIP::header replace" here
SIP::header remove Route
SIP::header insert Route [join [lsearch -all -inline -not $route_list ""] ,]
}
I will once again admit that I have not tested this rule. Let me know if it bombs somehow.