I'm testing OpenSER with mediaproxy and I want to force the use of
mediaproxy in every situation (not only when one of the users is behind
a NAT); for this reason I have modified the attached configuration,
starting from features-callfwd.5.0.cfg by ONSip.
1. Caller is PUBLIC, called is PUBLIC.
RTP stream passes through mediaproxy (I verified with tcpdump)
2. Caller is PUBLIC, called is PRIVATE (NATed)
RTP stream from PUBLIC to PRIVATE is direct, from PRIVATE to PUBLIC
passes through mediaproxy
3. Caller is PRIVATE, called is PRIVATE
RTP stream is direct in both ways, no media proxy usage.
This behaviour is somehow weird... do you have any idea of what could be
the reason? I have tried to manipulate OpenSER configuration but I got
no behaviour change.
--
Marco Meinardi
m.meinardi@reteitaly.com
ReteItaly S.r.l.
www.reteitaly.com
_____________________________________________
C.so Svizzera, 185 - 10149 Torino - Italy
Tel. +39 011 7767694 - Mobile +39 335 7878604
Fax +39 011 746179
_____________________________________________
[...]
modparam("auth_db|permissions|uri_db|usrloc|acc|domain",
"db_url", "postgres://openser:openser@localhost/openser")
modparam("auth_db", "calculate_ha1", 1)
modparam("auth_db", "password_column", "password")
modparam("nathelper", "rtpproxy_disable", 1)
modparam("nathelper", "natping_interval", 0)
modparam("mediaproxy","natping_interval", 30)
modparam("mediaproxy","mediaproxy_socket", "/var/run/mediaproxy.sock")
modparam("mediaproxy","sip_asymmetrics","/usr/local/etc/ser/sip-clients")
modparam("mediaproxy","rtp_asymmetrics","/usr/local/etc/ser/rtp-clients")
modparam("usrloc", "db_mode", 1)
modparam("registrar", "nat_flag", 6)
modparam("rr", "enable_full_lr", 1)
modparam("tm", "fr_inv_timer", 27)
modparam("tm", "fr_inv_timer_avp", "inv_timeout")
modparam("permissions", "db_mode", 1)
modparam("permissions", "trusted_table", "trusted")
modparam("avpops", "avp_url", "postgres://openser:openser@localhost/openser")
modparam("avpops", "avp_table", "usr_preferences")
modparam("acc", "log_level", 1)
modparam("acc", "log_flag", 1)
modparam("acc", "db_flag", 2)
modparam("acc", "db_missed_flag", 3)
route {
# -----------------------------------------------------------------
# Sanity Check Section
# -----------------------------------------------------------------
if (!mf_process_maxfwd_header("10")) {
sl_send_reply("483", "Too Many Hops");
return;
};
if (msg:len > max_len) {
sl_send_reply("513", "Message Overflow");
return;
};
# -----------------------------------------------------------------
# Record Route Section
# -----------------------------------------------------------------
if (method=="INVITE" && client_nat_test("3")) {
# INSERT YOUR IP ADDRESS HERE
record_route_preset("<MY OPENSER PBULIC IP>:5060;nat=yes");
} else if (method!="REGISTER") {
record_route();
};
# -----------------------------------------------------------------
# Call Tear Down Section
# -----------------------------------------------------------------
if (method=="BYE" || method=="CANCEL") {
setflag(2);
end_media_session();
};
# -----------------------------------------------------------------
# Loose Route Section
# -----------------------------------------------------------------
if (loose_route()) {
route(1);
return;
};
# -----------------------------------------------------------------
# Call Type Processing Section
# -----------------------------------------------------------------
setflag(3);
if (!is_uri_host_local()) {
if (is_from_local() || allow_trusted()) {
route(1);
} else {
sl_send_reply("403", "Forbidden");
};
return;
};
if (method=="CANCEL") {
route(1);
return;
} else if (method=="INVITE") {
route(3);
return;
} else if (method=="REGISTER") {
route(2);
return;
};
lookup("aliases");
if (uri!=myself) {
route(1);
return;
};
if (!lookup("location")) {
sl_send_reply("404", "User Not Found");
return;
};
route(1);
}
route[1] {
# -----------------------------------------------------------------
# Default Message Handler
# -----------------------------------------------------------------
t_on_reply("1");
setflag(2);
if (!isflagset(8)) {
setflag(8);
log(1,"Uso Media Proxy");
use_media_proxy();
};
if (!t_relay()) {
if (method=="INVITE" || method=="ACK") {
end_media_session();
};
sl_reply_error();
};
}
route[2] {
# -----------------------------------------------------------------
# REGISTER Message Handler
# -----------------------------------------------------------------
sl_send_reply("100", "Trying");
if (!search("^Contact:[ ]**") && client_nat_test("7")) {
setflag(6);
fix_nated_register();
force_rport();
};
if (!www_authorize("","subscriber")) {
www_challenge("","0");
return;
};
if (!check_to()) {
sl_send_reply("401", "Unauthorized");
return;
};
consume_credentials();
if (!save("location")) {
sl_reply_error();
};
}
route[3] {
# -----------------------------------------------------------------
# INVITE Message Handler
# -----------------------------------------------------------------
if (!allow_trusted()) {
if (!proxy_authorize("","subscriber")) {
proxy_challenge("","0");
return;
} else if (!check_from()) {
sl_send_reply("403", "Use From=ID");
return;
};
consume_credentials();
};
if (client_nat_test("3")) {
setflag(7);
force_rport();
fix_nated_contact();
};
lookup("aliases");
if (uri!=myself) {
route(1);
return;
};
if (avp_db_load("$ruri/username", "s:callfwd")) {
setflag(22);
avp_pushto("$ruri", "s:callfwd");
route(6);
return;
};
if (!lookup("location")) {
sl_send_reply("404", "User Not Found");
return;
};
if (avp_db_load("$ruri/username", "s:fwdbusy")) {
if (!avp_check("s:fwdbusy", "eq/$ruri/i")) {
setflag(26);
};
};
if (avp_db_load("$ruri/username", "s:fwdnoanswer")) {
if (!avp_check("s:fwdnoanswer", "eq/$ruri/i")) {
setflag(27);
};
};
t_on_failure("1");
route(1);
}
route[6] {
# --------------------------------------------------------------------
# Call Forwarding Reply Route Handler
#
# This must be done as a route block because sl_send_reply() cannot be
# called from the failure_route block
# --------------------------------------------------------------------
lookup("aliases");
if (!isflagset(22)) {
append_branch();
};
if (uri!=myself) {
route(1);
return;
};
if (!lookup("location")) {
sl_send_reply("404", "User Not Found");
};
route(1);
}
onreply_route[1] {
if ((status=~"(180)|(183)|2[0-9][0-9]")) {
if (!search("^Content-Length:[ ]*0")) {
use_media_proxy();
};
};
if (client_nat_test("1")) {
fix_nated_contact();
};
}
failure_route[1] {
if (t_check_status("487")) {
return;
};
if (isflagset(26) && t_check_status("486")) {
if (avp_pushto("$ruri", "s:fwdbusy")) {
avp_delete("s:fwdbusy");
resetflag(26);
route(6);
return;
};
};
if (isflagset(27) && t_check_status("408")) {
if (avp_pushto("$ruri", "s:fwdnoanswer")) {
avp_delete("s:fwdnoanswer");
resetflag(27);
route(6);
return;
};
};
end_media_session();
}