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

x-kamailio at sidell.org x-kamailio at sidell.org
Sun Feb 27 03:46:32 CET 2011


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?

-- 
Mark Sidell
Partner
Forte, Inc.
919-942-7068
fax 919-969-2844
www.forteinc.com



More information about the sr-users mailing list