[OpenSER-Users] isflagset from other peer ?

David Loh davidloh at vyke.com
Mon Mar 10 05:07:01 CET 2008


Hi Klaus,

I've tried setbflag and everything work fine except for caller (from 
Public IP) call to callee (behind NAT), it supposed to establish the 
call via RTP Proxy, but due to OpenSER doesn't detect any flag/bflag 
therefore the onreply route wasn't execute force_rtp_proxy. (but remote 
peer is NATed)
I'll paste my configuration here, can you point out what mistakes I've made?

------------------------------------------------------------------------
## Register route
route[1] {
    sl_send_reply("100", "Trying");

    if(!www_authorize("", "subscriber")) {
        www_challenge("", "0");
        exit;
    }

    consume_credentials();

    if(!check_to()) {
        xlog("L_INFO", "REGISTER Spoofed To-URI detected - RURI=$ru 
F=$fu T=$tu IP=$si ID=$ci\n");
        sl_send_reply("403", "Spoofed To-URI Detected");
        exit;
    }

    if(!search("^Contact:[ ]*\*") && nat_uac_test("19")) {
        xlog("L_INFO", "DBG: REGISTER [$fu]($si) is NATED");
        fix_nated_register();
        setbflag(5);
    }

    if(!save("location")) {
        sl_reply_error();
        exit;
    }

    xlog("L_INFO", "DBG: REGISTER [$fu]($si) ($ua) Registration 
SUCCESSFUL");
    exit;
}
------------------------------------------------------------------------
## Invite Route
route[3] {
    if(nat_uac_test("19")) {
        fix_nated_contact();
    }

    t_on_reply("1");

    if(uri=~"^sip:10\*.+ at .*" || uri=~"^sip:([A-Z][a-z])([A-Z][a-z]).+@*") {
        if(uri=~"^sip:10\*") {
            strip(3);
        }
        xlog("L_INFO", "DBG: P2P call [$fu]($si) to [$tu]");
        if(!lookup("location")) {
            xlog("L_INFO", "DBG: P2P Peer not found [$tu] from [$fu]($si)");
            sl_send_reply("404", "User Offline");
            exit;
        }
        if(nat_uac_test("19")) {
            t_on_reply("2");
            force_rtp_proxy();
            setflag(3);
            xlog("L_INFO", "DBG: P2P call in NATed Environment - Force 
RTP Proxy [$fu]($si) to [$tu]");
        }
    } else {
        if(!proxy_authorize("", "subscriber")) {
            xlog("L_INFO", "DBG: INVITE [$fu]($si) PROXY authentication 
FAILED");
            proxy_challenge("", "1");
            exit;
        }

        if(!check_from()) {
            xlog("L_INFO", "INVITE Spoofed From-URI detected - RURI=$ru 
F=$fu T=$tu IP=$si ID=$ci\n");
            sl_send_reply("403", "Spoofed From-URI Detected");
            exit;
        }

        rewritehostport("1.2.3.4:5060");
    }

    t_on_failure("1");
    t_relay();
    xlog("L_INFO", "DBG: INVITE F-[$fu] T-[$tu] IP-[$si] UA-[$ua] 
SUCCESSFUL");
}
------------------------------------------------------------------------
## Onreply route for P2P call
onreply_route[2] {
    if(nat_uac_test("1")) {
        fix_nated_contact();
    }

    if(status=~"(180)|(183)|2[0-9][0-9]") {
        if(!search("^Content-Length:[ ]*0")) {
            if (isflagset(3) || isbflagset(5)) {
                xlog("L_INFO", "DBG: [$fu]($si) - Onreply route need to 
RTP proxy.");
                force_rtp_proxy();
            }
        }
    }

    xlog("L_INFO", "DBG: On Reply - S=$rs D=$rr F=$fu T=$tu RURI=$ru");
}
------------------------------------------------------------------------


Thanks,
David Loh

Klaus Darilion wrote:
> David Loh wrote:
>> Hi All,
>>
>> I'm facing a situation for P2P call where it need to determine both 
>> caller and callee network type,
>> except for both parties having direct (internet) connection (on 
>> Public IP), the rest of combinations will implement force_rtp_proxy.
>> (the 4 combinations are: NAT-> NAT, NAT -> Public IP, Public IP -> 
>> NAT, Public IP -> Public IP).
>>
>> Wondering if I can use isflagset or fetch flag from remote peer 
>> (callee) ? or is there any function that allow this to be happen ?
>
>
> Usually you do it this way (pseudo code):
> - configure NAT flag (e.g. flag 5).
> http://www.openser.org/docs/modules/1.3.x/usrloc.html#AEN76
>
>
> if (REGISTER) {
>   if (behind NAT)
>     setbflag(5)
>   save();
>   exit;
> }
>
> ...call routing...
>   if (behind NAT)
>     setflag(6)
> ..
> activate branch route
> ....
> t_relay();
> exit;
>
>
>
> branch_route[1] {
>   if isflagset(6) || isbflagset(5)
>     force_rtpproxy();
>   ...
>   do other NAT traversal stuff
>   ...
> }
>
>
> regards
> klaus
> }

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.kamailio.org/pipermail/users/attachments/20080310/a3331334/attachment.htm 


More information about the Users mailing list