Module: sip-router Branch: master Commit: c8e928a2c78ee963f807791bea5aacdd31e05936 URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=c8e928a2...
Author: Daniel-Constantin Mierla miconda@gmail.com Committer: Daniel-Constantin Mierla miconda@gmail.com Date: Thu Jun 6 09:05:28 2013 +0200
siputils: added new function is_first_hop()
- detect if it is first hop after original sender - added section ids for functions, remove a duplicate content for is_rpid_user_e164()
---
modules/siputils/README | 188 +++++++++++++++--------------- modules/siputils/doc/siputils_admin.xml | 104 +++++++++--------- modules/siputils/sipops.c | 89 +++++++++++++-- modules/siputils/sipops.h | 1 + modules/siputils/siputils.c | 2 + 5 files changed, 229 insertions(+), 155 deletions(-)
Diff: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commitdiff;h=c8e9...
daniel,
is_first_hop() readme has this on replies:
For incoming SIP replies, it means that top Record-Route URI is 'myself' and source address is not matching it (to avoid detecting in case of local loops). Note that it does not detect spirals, which can have the condition for replies true also in the case of additional SIP reply receival.
in contact alias tutorial
https://sip-router.org/wiki/tutorials/alias-example?&#in-dialog_requests
i have implemented "is first hop" check by checking that reply does not have any other r-r headers except the ones added by the proxy itself when it relayed the request:
in request route i set
$avp("rr_count") = $rr_count;
and in reply route, i test
if ($rr_count == $avp(rr_count) + $rr_top_count) ...
i think that this method also works in case of spirals if i understand correctly what spirals are.
do you have any comment about possible equivalence or non-equivalence of the two methods? could i safely use is_first_hop test also for replies in contact alias tutorial?
-- juha
it came to my mind that if sip ua runs on the same host as sip proxy (which is very common in test environments at least) then it seem that is_first_hop does not work for replies.
it may not be a good idea to introduce this function for replies if it has such a hole.
-- juha
On 6/8/13 8:59 AM, Juha Heinanen wrote:
it came to my mind that if sip ua runs on the same host as sip proxy (which is very common in test environments at least) then it seem that is_first_hop does not work for replies.
it may not be a good idea to introduce this function for replies if it has such a hole.
The check is on ip, port and protocol, if ua is on same host, it will use a different port. It is similar situation with record-routing and UA on same host. Without port matching of 'myself', then contact of UA which appears as R-URI in subsequent requests will be detected as myself and eaten by loose_route() by considering a strict routing case.
For now use the test with rr count, it is good for replies.
Cheers, Daniel
Daniel-Constantin Mierla writes:
The check is on ip, port and protocol, if ua is on same host, it will use a different port. It is similar situation with record-routing and UA on same host. Without port matching of 'myself', then contact of UA which appears as R-URI in subsequent requests will be detected as myself and eaten by loose_route() by considering a strict routing case.
For now use the test with rr count, it is good for replies.
thanks for the explanation. i got confused about source address, because readme does not mention that also port is used for matching.
-- juha
Hello,
On 6/8/13 8:55 AM, Juha Heinanen wrote:
daniel,
is_first_hop() readme has this on replies:
For incoming SIP replies, it means that top Record-Route URI is 'myself' and source address is not matching it (to avoid detecting in case of local loops). Note that it does not detect spirals, which can have the condition for replies true also in the case of additional SIP reply receival.
in contact alias tutorial
https://sip-router.org/wiki/tutorials/alias-example?&#in-dialog_requests
i have implemented "is first hop" check by checking that reply does not have any other r-r headers except the ones added by the proxy itself when it relayed the request:
in request route i set
$avp("rr_count") = $rr_count;
and in reply route, i test
if ($rr_count == $avp(rr_count) + $rr_top_count) ...
i think that this method also works in case of spirals if i understand correctly what spirals are.
do you have any comment about possible equivalence or non-equivalence of the two methods? could i safely use is_first_hop test also for replies in contact alias tutorial?
Using your approach is safer and good for spirals as well, but requires tm module to keep the avp. I need it for a stateless outbound proxy. I considered storing the number of r-r as a parameter in the new r-r header, but could become too big with ftag, nat, etc...
Detecting the spiral would require to iterate through r-r headers in reply, see if there is another match to 'myself' and if yes, check if source ip/port/proto matches the previous r-r header. That should make it complete. Right now I know if there is a spiral inside my network, like:
UA1 ==== K ==== Media Server ==== K ==== UA2
but is easy to check that source ip is media server.
Cheers, Daniel