[SR-Users] Pseudo variables and uid_domain module compatibility
Daniel-Constantin Mierla
miconda at gmail.com
Fri Jan 25 21:03:29 CET 2013
Hello,
On 1/25/13 2:57 PM, Philippe Sultan wrote:
> I was using this module in version 3.1.0. The thing is that I used the
> provisioning python scripts (ser_domain, ser_attrs) to create my
> domains and their attributes (see :
> http://www.mail-archive.com/sr-users@lists.sip-router.org/msg12415.html).
the mentiond scripts should work fine if they use uid_domain and
uid_domain_attrs tables. It might be configuration option or a small
change -- not using them I cannot comment more.
Anyhow, I committed your patch in master. You can send another patch if
you want to add commands for uid_domain_attrs.
Cheers,
Daniel
>
> The default value for the flag field when creating a domain was 37,
> which according to
> kamailio-3.1.0/lib/python2.4/site-packages/serctl/flag.py equals to
> LOAD_SER | CANON | FOR_SERWEB :
> LOAD_SER = 1L << 0 # The row should be loaded by SER
> DISABLED = 1L << 1 # The row is disabled
> CANON = 1L << 2 # Canonical entry (domain or uri)
> IS_TO = 1L << 3 # The URI can be used in To
> IS_FROM = 1L << 4 # The URI can be used in From
> FOR_SERWEB = 1L << 5 # Credentials instance can be used by serweb
>
> As kamctl does not handle the uid_domain and uid_domain_attrs tables,
> I must rely on MySQL default value (0), set in
> utils/kamctl/mysql/uid_domain-create.sql.
>
> And 0 for the flag field will make lookup_domain fail in uid_domain if
> caching is used. So, 37 seems to be the right default value to
> provision (the flags from the former python script are all reflected
> in lib/srdb2/db.h).
>
> I have written a patch that adds uid_domain commands to kamctl with
> the default values from 3.1.0, attached to this message. Will work on
> something for uid_domain_attrs too if needed.
>
> Cheers,
>
> Philippe
>
> 2013/1/24 Daniel-Constantin Mierla <miconda at gmail.com
> <mailto:miconda at gmail.com>>
>
> I am not using this module and I don't know what are supposed to
> be the right default values for flags. But it should be like it
> was in the past. If you used with an older version 3.x, apart of
> renaming, nothing was touched in the code for 4.x.
>
> Cheers,
> Daniel
>
>
> On 1/24/13 4:27 PM, Philippe Sultan wrote:
>> Thank you Daniel, your answer helped a lot.
>>
>> With :
>> #!KAMAILIO
>> loadmodule "pv.so"
>> $avp(fd.did)
>>
>> Everything works fine, but only if I turn off caching with :
>> modparam("uid_domain", "db_mode", 0)
>>
>> Otherwise, avps are not loaded from the db. Digging into
>> modules/uid_domain/domain.c, I figured out that the default flag
>> value 0 for records in the uid_domain table would make the
>> load_domains function skip the records, see (in load_domains) :
>> /* Skip entries that are disabled/scheduled for
>> removal */
>> if (flags & SRDB_DISABLED) goto skip;
>> /* Skip entries that are for serweb/ser-ctl only */
>> if (!(flags & SRDB_LOAD_SER)) goto skip;
>>
>> Setting the flag value to 1 does make the load_domains function
>> work as expected, and load the records from the db.
>>
>> Maybe the uid_domain-create.sql file under utils should be modifed.
>>
>> Thanks again Daniel,
>>
>> Philippe
>>
>> 2013/1/24 Daniel-Constantin Mierla <miconda at gmail.com
>> <mailto:miconda at gmail.com>>
>>
>> The sript compatibility was set to kamailio strict mode,
>> throwing error if $xy was not a pv. You can fetch latest
>> master and should work like if no pv found as $xy, then is
>> set as avp.
>>
>> Even if with your version, adding #!SER as first line should
>> make it work with $fd.did...
>>
>> Cheers,
>> Daniel
>>
>>
>> On 1/24/13 10:58 AM, Daniel-Constantin Mierla wrote:
>>> Hi Philippe,
>>>
>>> On 1/23/13 11:54 PM, Philippe Sultan wrote:
>>>> Hey Daniel,
>>>>
>>>> Thanks a lot for your help.
>>>>
>>>> do you have #!SER as first line? This part should be
>>>> the same ... if pv not found, then it should be
>>>> considered avp. I will try to see what is the issue.
>>>>
>>>>
>>>> I don't have #!SER
>>>
>>> it should not be needed for this case, if $xyz is not found
>>> as pv, it is considered avp.
>>>
>>>> Anyhow, for the moment, if not working, load pv and
>>>> then try:
>>>> - $fd and $td must stay as parameters for lookup_domain()
>>>> - for strempty() try to use $avp(fd.did) and $avp(td.did)
>>>>
>>>>
>>>> I loaded pv, and modified the script accordingly. No syntax
>>>> errors anymore, but avps are not populated from the data
>>>> stored in the db. Maybe a problem with lookup_domain?
>>>
>>> the modules_s/domain was only renamed to uid_domain to avoid
>>> conflict with the other domain module. No other recent
>>> changes to my knowledge. Can you try to put IF around it and
>>> see if returns true or false? Can you check the sql queries
>>> in the server to see if they are returning something?
>>>
>>> Cheers,
>>> Daniel
>>>
>>>>
>>>> Here's the excerpt of the script (I replaced the selects
>>>> with '@' by '$sel()', and added a dump_attrs()) :
>>>> xlog("L_INFO", "from.uri.host :
>>>> $sel(from.uri.host)\n");
>>>> xlog("L_INFO", "ruri.host : $sel(ruri.host)\n");
>>>>
>>>> lookup_domain("$fd", "$sel(from.uri.host)");
>>>> lookup_domain("$td", "$sel(ruri.host)");
>>>>
>>>> xlog("L_INFO", "fd : $avp(fd.did)\n");
>>>>
>>>> dump_attrs();
>>>>
>>>> if (strempty($avp(fd.did)) && strempty($avp(td.did))) {
>>>> # Neither the calling nor the called domain
>>>> is local
>>>> # This is a relaying attempt which should
>>>> be forbidden
>>>> sl_reply("403", "Relaying Forbidden");
>>>> drop;
>>>> }
>>>>
>>>> And as a result :
>>>> 0(22008) INFO: <script>: from.uri.host : ext.test.r3load.voip
>>>> 0(22008) INFO: <script>: ruri.host : ext.test.r3load.voip
>>>> 0(22008) INFO: <script>: fd : <null>
>>>> 0(22008) INFO: avp [avp.c:573]: class=GLOBAL
>>>> 0(22008) INFO: avp [avp.c:575]: INFO: No AVP present
>>>> 0(22008) INFO: avp [avp.c:583]: track=FROM class=DOMAIN
>>>> 0(22008) INFO: avp [avp.c:585]: INFO: No AVP present
>>>> 0(22008) INFO: avp [avp.c:593]: track=TO class=DOMAIN
>>>> 0(22008) INFO: avp [avp.c:595]: INFO: No AVP present
>>>> 0(22008) INFO: avp [avp.c:603]: track=FROM class=USER
>>>> 0(22008) INFO: avp [avp.c:605]: INFO: No AVP present
>>>> 0(22008) INFO: avp [avp.c:613]: track=TO class=USER
>>>> 0(22008) INFO: avp [avp.c:615]: INFO: No AVP present
>>>> 0(22008) INFO: avp [avp.c:623]: track=FROM class=URI
>>>> 0(22008) INFO: avp [avp.c:625]: INFO: No AVP present
>>>> 0(22008) INFO: avp [avp.c:633]: track=TO class=URI
>>>> 0(22008) INFO: avp [avp.c:635]: INFO: No AVP present
>>>>
>>>> In the db :
>>>> +----+----------------------+----------------------+-------+
>>>> | id | did | domain | flags |
>>>> +----+----------------------+----------------------+-------+
>>>> | 1 | ext.test.r3load.voip | ext.test.r3load.voip | 0 |
>>>> +----+----------------------+----------------------+-------+
>>>>
>>>> Thanks again!
>>>>
>>>> Philippe
>>>>
>>>>
>>>>
>>>> _______________________________________________
>>>> SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list
>>>> sr-users at lists.sip-router.org <mailto:sr-users at lists.sip-router.org>
>>>> http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users
>>>
>>> --
>>> Daniel-Constantin Mierla -http://www.asipto.com
>>> http://twitter.com/#!/miconda <http://twitter.com/#%21/miconda> -http://www.linkedin.com/in/miconda
>>> Kamailio World Conference, April 16-17, 2013, Berlin
>>> -http://conference.kamailio.com -
>>
>> --
>> Daniel-Constantin Mierla -http://www.asipto.com
>> http://twitter.com/#!/miconda <http://twitter.com/#%21/miconda> -http://www.linkedin.com/in/miconda
>> Kamailio World Conference, April 16-17, 2013, Berlin
>> -http://conference.kamailio.com -
>>
>>
>> _______________________________________________
>> SIP Express Router (SER) and Kamailio (OpenSER) - sr-users
>> mailing list
>> sr-users at lists.sip-router.org
>> <mailto:sr-users at lists.sip-router.org>
>> http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users
>>
>>
>>
>>
>> --
>> Philippe Sultan
>>
>>
>> _______________________________________________
>> SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list
>> sr-users at lists.sip-router.org <mailto:sr-users at lists.sip-router.org>
>> http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users
>
> --
> Daniel-Constantin Mierla -http://www.asipto.com
> http://twitter.com/#!/miconda <http://twitter.com/#%21/miconda> -http://www.linkedin.com/in/miconda
> Kamailio World Conference, April 16-17, 2013, Berlin
> -http://conference.kamailio.com -
>
>
> _______________________________________________
> SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing
> list
> sr-users at lists.sip-router.org <mailto:sr-users at lists.sip-router.org>
> http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users
>
>
>
>
> --
> Philippe Sultan
>
>
> _______________________________________________
> SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list
> sr-users at lists.sip-router.org
> http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users
--
Daniel-Constantin Mierla - http://www.asipto.com
http://twitter.com/#!/miconda - http://www.linkedin.com/in/miconda
Kamailio World Conference, April 16-17, 2013, Berlin
- http://conference.kamailio.com -
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.sip-router.org/pipermail/sr-users/attachments/20130125/cb7c850a/attachment-0001.htm>
More information about the sr-users
mailing list