Module: sip-router
Branch: tma0/iptrtpproxy-v2
Commit: df7555de5100e9571f0b7d32132a25e85cdb58c4
URL:
http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=df7555d…
Author: Tomas Mandys <tomas.mandys(a)iptel.org>
Committer: Tomas Mandys <tomas.mandys(a)iptel.org>
Date: Wed Dec 14 20:52:37 2011 +0100
RTP proxy PRACK without SDP fix
- new flag added to cope with 180/PRACK without SDP
---
.../oob/sip-router-oob-RTPPROXY.cfg.inc | 44 ++++++++++++++------
1 files changed, 31 insertions(+), 13 deletions(-)
diff --git a/modules/iptrtpproxy/oob/sip-router-oob-RTPPROXY.cfg.inc
b/modules/iptrtpproxy/oob/sip-router-oob-RTPPROXY.cfg.inc
index 34baf2c..41f0f10 100644
--- a/modules/iptrtpproxy/oob/sip-router-oob-RTPPROXY.cfg.inc
+++ b/modules/iptrtpproxy/oob/sip-router-oob-RTPPROXY.cfg.inc
@@ -22,6 +22,7 @@
# $rtp_dlg_sess_ids ... list of confirmed (INVITE/200OK/ACK, INVITE/180/PRACK,
UPDATE/200OK ) RTP sessions
# $rtp_dlg_sess_ids2 ... list of non-confirmed sessions
# $rtp_method_flag ... request method passed to onreply/failure
+# $rtp_dlg_state ... ""..no offer yet, "o"..offered,
"a"..answered
#
# rtpproxy.* configuration params
#
@@ -35,7 +36,7 @@ loadmodule "iptrtpproxy"
modparam("iptrtpproxy", "config", "/etc/iptrtpproxy.cfg");
#DEBCONF-RTTPPROXY-START
-modparam("iptrtpproxy", "switchboard",
"name=*;sip-addr=213.192.59.75"); ## TODO change back to .75
+modparam("iptrtpproxy", "switchboard",
"name=*;sip-addr=213.192.30.136");
#modparam("iptrtpproxy", "switchboard",
"name=gate_a;sip-addr=1.2.3.4;aggregation=AA")
#modparam("iptrtpproxy", "switchboard",
"name=gate_b;aggregation=A")
modparam("iptrtpproxy", "codec_set",
"name=any;media_type=*;rights=0;codecs=*;max_streams=9999");
@@ -81,7 +82,7 @@ route[RTPPROXY_PROCESS_REQUEST] {
}
if (!defined $dialog_id) { # AVP loaded from route cookie
if (@method != "ACK")
- t_reply("400", "Missing cookie"); # 500 (=our bug) in case of
init request because it'd been generated by ourselves
+ t_reply("400", "Missing cookie"); # 500 (=our bug) in case of
init request because it had been generated by ourselves
xlog("L_EDEBUG", "RTPPROXY_PROCESS_REQUEST: missing cookie:
%(a)hf_value.route[0]\n")uot;);
drop;
}
@@ -125,7 +126,7 @@ route[RTPPROXY_PROCESS_REQUEST] {
}
}
- if ((method == "INVITE" || method == "UPDATE") &&
@msg.body!="") {
+ if ((method == "INVITE" || method == "UPDATE" || method ==
"PRACK") && @msg.body!="") {
if (@iptrtpproxy.active_media_num == "0") break;
iptrtpproxy_set_param("codec_set",
"(a)cfg_get.rtp_proxy.codec_set")set");
iptrtpproxy_set_param("remove_codec_mask", "1");
@@ -146,7 +147,7 @@ route[RTPPROXY_PROCESS_REQUEST] {
xlog("L_EDEBUG", "RTPPROXY_PROCESS_REQUEST: find switchboard-a for
'%(a)received.ip'\n")#39;\n");
if (!iptrtpproxy_set_param("switchboard_by_sip_ip_a",
"(a)received.ip")) {
xlog("L_ERR", "RTPPROXY_PROCESS_REQUEST: Cannot find switchboard-a for
routing '%(a)received.ip'\n")#39;\n");
- t_reply("500", "RTP proxy error");
+ t_reply("500", "RTP proxy error (switchboard-a)");
drop;
}
eval_push("x:%@next_hop.src_ip");
@@ -157,7 +158,7 @@ route[RTPPROXY_PROCESS_REQUEST] {
xlog("L_EDEBUG", "RTPPROXY_PROCESS_REQUEST: find switchboard-b for
'%(a)eval.get[-1]'\n")#39;\n");
if (!iptrtpproxy_set_param("switchboard_by_sip_ip_b",
"(a)eval.get[-1]")) {
xlog("L_ERR", "RTPPROXY_PROCESS_REQUEST: Cannot find switchboard for
routing '%(a)eval.get[-1]'\n")#39;\n");
- t_reply("500", "RTP proxy error");
+ t_reply("500", "RTP proxy error (switchboard-b)");
drop;
}
}
@@ -215,16 +216,19 @@ route[RTPPROXY_PROCESS_REQUEST] {
} else {
eval_push("1"); # caller -> callee
}
- if (!iptrtpproxy_alloc("(a)eval.pop[-1]")) {
- t_reply("500", "RTP proxy error");
+ if (!iptrtpproxy_alloc("(a)eval.pop[-1]")) {
+ t_reply("503", "RTP proxy error (no free port)");
drop;
}
# we need save in dialog as non-confirmed sess_ids (not only in transaction) because
# UPDATE in non-confirmed INVITE and ACK to 200OK are considered as separate
transactions.
- if (@iptrtpproxy.session_ids != "")
+ if (@iptrtpproxy.session_ids != "") {
$rtp_dlg_sess_ids2 = @iptrtpproxy.session_ids;
- else
+ $rtp_dlg_state = "o"; # offered
+ } else {
del_attr("$rtp_dlg_sess_ids2");
+ del_attr("$rtp_dlg_state");
+ }
xlog("L_EDEBUG", "RTPPROXY_PROCESS_REQUEST: allocated
ids2=%$rtp_dlg_sess_ids2\n");
# session_ids are stored in AVP to let commit (on_reply) or rollback (on_failure)
allocated sessions
@@ -245,10 +249,14 @@ route[RTPPROXY_PROCESS_REQUEST] {
if (strempty($rtp_dlg_sess_ids2)) {
break; /* do not save, non SDP related re-INVITE or retrasmission which is not eaten
by tm module, SDP in ACK is not supported */
}
+ if (!defined $rtp_dlg_state || $rtp_dlg_state != "a") {
+ break; /* e.g. PRACK to 180 without SDP */
+ }
iptrtpproxy_set_param("protected_session_ids",
"$rtp_dlg_sess_ids2");
iptrtpproxy_delete("$rtp_dlg_sess_ids");
$rtp_dlg_sess_ids = $rtp_dlg_sess_ids2;
del_attr("$rtp_dlg_sess_ids2");
+ del_attr("$rtp_dlg_state");
route("RTPPROXY_SAVE_ATTRS");
}
else if (method == "BYE") { # CANCEL ???
@@ -291,7 +299,7 @@ route[RTPPROXY_PROCESS_REPLY] {
# (probably) no retransmission
route("RTPPROXY_LOAD_ATTRS");
$rtp_last_code = @msg.res.code;
- if (isflagset(FLAG_INIT_DLG) && status=~"18[0-9]") {
+ if (isflagset(FLAG_INIT_DLG) && status=~"1[0-9][0-9]") { # 100 is
impossible, eaten by tm
iptrtpproxy_set_param("learning_timeout",
"(a)cfg_get.rtp_proxy.ringing_timeout")out");
}
else {
@@ -342,6 +350,7 @@ route[RTPPROXY_PROCESS_REPLY] {
;
# drop; ???
}
+ $rtp_dlg_state = "a"; # answered
route("RTPPROXY_SAVE_ATTRS");
}
else {
@@ -362,9 +371,13 @@ route[RTPPROXY_PROCESS_REPLY] {
else if ($rtp_method_flag == "UPDATE" &&
status=~"2[0-9][0-9]" && $rtp_dlg_sess_ids2!="") {
# confirm pending offer (UPDATE is not followed by ACK/PRACK)
route("RTPPROXY_LOAD_ATTRS");
- xlog("L_EDEBUG", "RTPPROXY_PROCESS_REPLY: %@method,
delete(ids=%$rtp_dlg_sess_ids), protect(ids2=%$rtp_dlg_sess_ids2)\n");
+ xlog("L_EDEBUG", "RTPPROXY_PROCESS_REPLY: %@method,
delete(ids=%$rtp_dlg_sess_ids), protect(ids2=%$rtp_dlg_sess_ids2,
state=%$rtp_dlg_state)\n");
+ if (!defined $rtp_dlg_state || $rtp_dlg_state != "o") {
+ break;
+ }
iptrtpproxy_set_param("protected_session_ids",
"$rtp_dlg_sess_ids2");
iptrtpproxy_delete("$rtp_dlg_sess_ids");
+ $rtp_dlg_state = "a"; # answered
$rtp_dlg_sess_ids = $rtp_dlg_sess_ids2;
del_attr("$rtp_dlg_sess_ids2");
route("RTPPROXY_SAVE_ATTRS");
@@ -385,13 +398,14 @@ route[RTPPROXY_PROCESS_FAILURE] {
iptrtpproxy_delete("$rtp_dlg_sess_ids"); # early media are considered as
confirmed
iptrtpproxy_delete("$rtp_dlg_sess_ids2");
route("RTPPROXY_REMOVE_ATTRS");
- } else if ($rtp_method_flag == "INVITE" || $rtp_method_flag ==
"UPDATE") {
+ } else if ($rtp_method_flag == "INVITE" || $rtp_method_flag ==
"UPDATE" || $rtp_method_flag == "PRACK") {
route("RTPPROXY_LOAD_ATTRS");
#remove only unconfirmed sessiosn
xlog("L_EDEBUG", "RTPPROXY_PROCESS_FAILURE: %@method,
delete(ids2=%$rtp_dlg_sess_ids2), protect(ids=%$rtp_dlg_sess_ids)\n");
iptrtpproxy_set_param("protected_session_ids",
"$rtp_dlg_sess_ids");
iptrtpproxy_delete("$rtp_dlg_sess_ids2");
del_attr("$rtp_dlg_sess_ids2");
+ del_attr("$rtp_dlg_state");
route("RTPPROXY_SAVE_ATTRS");
}
@@ -407,23 +421,27 @@ route[RTPPROXY_PROCESS_FAILURE] {
route[RTPPROXY_LOAD_ATTRS] {
del_attr("$rtp_dlg_sess_ids");
del_attr("$rtp_dlg_sess_ids2");
+ del_attr("$rtp_dlg_state");
load_extra_attrs("rtp_dlg", "$dialog_id");
- xlog("L_EDEBUG", "RTPPROXY_LOAD_ATTRS: dialog_id=%$dialog_id,
method/flag='%@method'/'%$rtp_method_flag', ids=%$rtp_dlg_sess_ids,
ids2=%$rtp_dlg_sess_ids2\n");
+ xlog("L_EDEBUG", "RTPPROXY_LOAD_ATTRS: dialog_id=%$dialog_id,
method/flag='%@method'/'%$rtp_method_flag', ids=%$rtp_dlg_sess_ids,
ids2=%$rtp_dlg_sess_ids2, state=%$rtp_dlg_state\n");
}
route[RTPPROXY_SAVE_ATTRS] {
xlog("L_EDEBUG", "RTPPROXY_SAVE_ATTRS: dialog_id=%$dialog_id,
method='%@method', ids=%$rtp_dlg_sess_ids, ids2=%$rtp_dlg_sess_ids2\n");
setavpflag("$f.rtp_dlg_sess_ids", "rtpproxy_dlg");
setavpflag("$f.rtp_dlg_sess_ids2", "rtpproxy_dlg");
+ setavpflag("$f.rtp_dlg_state", "rtpproxy_dlg");
save_extra_attrs("rtp_dlg", "$dialog_id");
del_attr("$rtp_dlg_sess_ids");
del_attr("$rtp_dlg_sess_ids2");
+ del_attr("$rtp_dlg_state");
}
route[RTPPROXY_REMOVE_ATTRS] {
xlog("L_EDEBUG", "RTPPROXY_REMOVE_ATTRS: dialog_id=%$dialog_id,
method='%@method'\n");
del_attr("$rtp_dlg_sess_ids");
del_attr("$rtp_dlg_sess_ids2");
+ del_attr("$rtp_dlg_state");
remove_extra_attrs("rtp_dlg", "$dialog_id");
}