[SR-Users] My wish

Alex Balashov abalashov at evaristesys.com
Mon Apr 12 12:18:45 CEST 2010


Marius,

Well, if you ask me whether it is worth pushing to master, you will  
get a rather biased answer. This sounds like a call that should be  
made by the elders of the Kamailio tribal council.  :)

Thank you anyway for the patch; I will put it to good use!

-- Alex 

--
Alex Balashov - Principal
Evariste Systems LLC
1170 Peachtree Street
12th Floor, Suite 1200
Atlanta, GA 30309
Tel: +1-678-954-0670
Fax: +1-404-961-1892

On Apr 12, 2010, at 6:15 AM, marius zbihlei <marius.zbihlei at 1and1.ro>  
wrote:

> marius zbihlei wrote:
>>
>>>>
>>>> Hello Alex,
>>>>
>>>> How about a syntax like
>>>>
>>>> modparam("*", "db_url", ...) ?
>>>>
>>>> meaning that it matches all modules that have a db_url param.  
>>>> Maybe this
>>>> will also benefit something like module specific log level(when  
>>>> will be
>>>> implemented) and other common parameters.
>>>
>>> That would certainly solve the problem!
>>>
>>
>>
>> It seems that this is already implemented. Modparam function allows  
>> for a regexp match on the module name. Unfortunately, I can't text  
>> it right now, but browsing thru the code it seems that it supports  
>> the same regexp expression like the rest of Ser. Maybe something  
>> like this will work
>>
>> modparam(".*", "db_url", ...);
>>
>> Marius
>>
>> _______________________________________________
>> 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
>>
>
> Hello Alex
>
> I had the time to test the previous mail and it doesn't work. The  
> reason is that the if  a regex match succeeds , than the parameter  
> configured MUST exists in the module. I have created a patch that  
> modifies this behavior and now the modparam statement succeeds if  
> there is at least on module that can be configured with the desired  
> param.
>
> I have attached the patch.  And now the question : does it make  
> sense to push it to master?! In my opinion the relaxed approach  is  
> better that the greedy approach...
>
> Marius
>
> diff --git a/modparam.c b/modparam.c index ca34bef..115079a 100644  
> --- a/modparam.c +++ b/modparam.c @@ -57,7 +57,7 @@ int  
> set_mod_param_regex(char* regex, char* name, modparam_t type, void*  
> val) { struct sr_module* t; regex_t preg; -	int mod_found, len; +	 
> int mod_found, len, var_found; char* reg;  	void *ptr, *val2;  
> modparam_t param_type; @@ -90,6 +90,7 @@ int set_mod_param_regex 
> (char* regex, char* name, modparam_t type, void* val) } mod_found =  
> 0; +	var_found = 0; for(t = modules; t; t = t->next) { if (regexec 
> (&preg, t->exports->c.name, 0, 0, 0) == 0) { DBG 
> ("set_mod_param_regex: '%s' matches module '%s'\n", @@ -99,6 +100,7  
> @@ int set_mod_param_regex(char* regex, char* name, modparam_t type,  
> void* val) ptr = find_param_export(t, name, type | ((type &  
> (PARAM_STR|PARAM_STRING))?PARAM_STR|PARAM_STRING:0), &param_type);  
> if (ptr) { /* type casting */ +	 var_found = 1; if (type ==  
> PARAM_STRING && PARAM_TYPE_MASK(param_type) == PARAM_STR) { s.s =  
> (char*)val; s.len = s.s ? strlen(s.s) : 0; @@ -146,11 +148,8 @@ int  
> set_mod_param_regex(char* regex, char* name, modparam_t type, void*  
> val) } } else { -	 LOG(L_ERR, "set_mod_param_regex: parameter <%s>  
> not found in" +	 LOG(L_DBG, "set_mod_param_regex: parameter <%s> not  
> found in" " module <%s>\n", name, t->exports->c.name); -	 regfree 
> (&preg); -	 pkg_free(reg); - return -3; } } } @@ -161,5 +160,9 @@  
> int set_mod_param_regex(char* regex, char* name, modparam_t type,  
> void* val) LOG(L_ERR, "set_mod_param_regex: No module matching <%s>  
> found\n", regex); return -4; } +	if(!var_found) { + LOG(L_ERR,  
> "set_mod_param_regex: No module export matching <%s> found\n",  
> name); +	 return -3; +	} return 0; }




More information about the sr-users mailing list