Hello,
I'm not sure this is the best or even the right way, but i do that by figuring out where the call is coming from.
In my case, an INVITE from an RFC1918 IP address will always be internal to external and vice versa.
i.e.:
# If the Source IP is an RFC1918 address, it's coming from an internal endpoint, so the call is going out
if (is_ip_rfc1918("$si")) {
$dlg_var(rtp_direction) = "direction=internal direction=external";
} else {
$dlg_var(rtp_direction) = "direction=external direction=internal";
}
You may even check both origin and destination domain ($du) and configure rtpengine accordingly.
onsend_route {
xlog("L_ERR", "[onsend_route] Packet going to $du\n" );
if (is_ip_rfc1918("$si") && is_ip_rfc1918("$du") ) {
# call is internal to internal
} else if (is_ip_rfc1918("$si") && !is_ip_rfc1918("$du")) {
# call is internal to external
} else if (!is_ip_rfc1918("$si") && !is_ip_rfc1918("$du")) {
# call is external to external
} else if (!is_ip_rfc1918("$si") && is_ip_rfc1918("$du")) {
# call is external to internal
}
}
Hope that makes sense and help you a little.
Regards,
David Villasmil
phone: +34669448337