[OpenSER-Users] Avoid Loops between Openser and Asterisk

Adrian A adrianvoip at gmail.com
Fri Apr 11 01:00:28 CEST 2008


Here is how I solve this.

In Asterisk, I add a SIP header just before sending it to OpenSER using the
function: SipAddHeader(P-hint: From Asterisk).

Then, in OpenSER I have the following:

                # check to see if user is online
                if (!lookup("location")) {
                        # SIP from Asterisk or not a call attempt
                        if (search("(P-hint):.From Asterisk") ||
!(method==INVITE)) {
                                sl_send_reply("480","User Temporarily
Unavailable");
                                        exit;
                        } else {
                                route(2);
                                exit;
                        };
                };

route[2] {
        # Let Asterisk deal with voicemail/forward
        sl_send_reply("181", "Forward to Voicemail");
        prefix("vm");
        setflag(9);       # forward to Asterisk
        route(1);
}



On Thu, Apr 3, 2008 at 12:50 AM, Cosimo Fadda <cosimo.fadda at klarya.it>
wrote:

> Hi everybody,
> I'm using Opeser as Proxy and one Asterisk as Gateway and Voicemail
> server.
> Suppose that an incoming calls arrives to Ser from Asterisk and the user
> is offline;
> Then Openser sends back the Invite to Asterisk that should activate the
> voicemail application but
> unfortunately it detects a Loop (482) and rejects the invite.
> I think I have to mangle the SIP message in Openser before the send to
> Asterisk again.
> This is what I currently do:
>
> if(!lookup("location"))
>    {
>        #send to voicemail if active but not registerd
>        xlog("L_INFO", "Local user offline - M=$rm RURI=$ru F=$fu T=$tu
> IP=$si ID=$ci\n");
>        if($avp(s:vmail) == "1")
>        {
>         route(11);
>        }
>        else
>        {
>         route(20);
>        }
>    }
>    else
>    {
>       xlog("L_INFO", "Local user online - M=$rm RURI=$ru F=$fu T=$tu
> IP=$si ID=$ci\n");
>        route(9);
>    }
>    exit;
>
> ....
>
> route[11]
> {
>    xlog("L_INFO", "Forwarding request to VM\n");
>    prefix("vm");
>    sethostport("asterisk-gw:5060");
>    #append_branch();
>    if (!t_relay())
>    {
>        xlog("L_INFO", "Unable TO Forward the request to VM\n");
>           route(20);
>           exit;
>    }
>
>
> What can I do to avoid Loop Detection?
>
> Thanks in advance,
>
> Cosimo Fadda
> ___________
>
> _______________________________________________
> Users mailing list
> Users at lists.openser.org
> http://lists.openser.org/cgi-bin/mailman/listinfo/users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.sip-router.org/pipermail/sr-users/attachments/20080410/f8aca420/attachment.htm>


More information about the sr-users mailing list