[SR-Users] how to combine alias_db_lookup() with lookup()

Daniel-Constantin Mierla miconda at gmail.com
Wed Mar 2 09:44:42 CET 2011


Hello,

On 2/27/11 3:46 AM, x-kamailio at sidell.org wrote:
> I'm trying to use the db_alias module as a way to define "generic"
> addresses that map to a set of actual phones. For example, I'd like
> the alias "home at foo.bar" to map to "kitchen at foo.bar" and
> "office at foo.bar", so that both phones ring when a call comes in to
> "home".
>
> I have set the append_branches param to 1:
>
>     modparam("alias_db", "append_branches", 1)
>
> I also modified the dbaliases database table so that key "alias_idx"
> isn't unique, thereby allow me to add multiple rows for the same
> alias.
>
> The relevant script section is taken verbatim from 3.1 kamailio.cfg:
>
>     # USER location service
>     route[LOCATION] {
>
>     #!ifdef WITH_ALIASDB
>        # search in DB-based aliases
>        alias_db_lookup("dbaliases");
>
>     #!endif
>
>        if (!lookup("location")) {
>           switch ($rc) {
>              case -1:
>              case -3:
>                 xlog( "L_WARN", "XXX $ru $fu\n");
>                 t_newtran();
>                 t_reply("404", "Not Found");
>                 exit;
>              case -2:
>                 sl_send_reply("405", "Method Not Allowed");
>                 exit;
>           }
>        }
>
>        # when routing via usrloc, log the missed calls also
>        if (is_method("INVITE"))
>        {
>           setflag(FLT_ACCMISSED);
>        }
>     }
>
> When I place a call to an alias, the kamailio debug log shows that
> alias_db_lookup() is correctly setting the ruri to the first entry
> found in the table, and using append_branch() to add the others. But
> only the first matching phone gets an INVITE, not the others. I
> suspect that the lookup() call is blowing away the branches set up by
> alias_db_lookup() and replacing them with the single phone that
> matches the ruri for the first alias entry.
>
> Is there a way to get alias_db_lookup() and lookup() to play together,
> so that the first function can set up a list of branches, and the
> second function can resolve all of the branches to the actual device
> locations?
the branches added by alias_db are not lost, but they are sent back to 
you over loopback. They get dropped probably because they are authenticated.

Try to watch the traffic on loopback with ngrep just to see if I am right:
ngrep -d any -qt -W byline port 5060

The solution in this case is to have a condition in route[AUTH] for 
non-REGISTER requests, something like:

if(src_ip==myself)
    return;

before doing proxy_authenticate().

Cheers,
Daniel

-- 
Daniel-Constantin Mierla
http://www.asipto.com




More information about the sr-users mailing list