Re: [SR-Users] Using =~ to get the group identifier with longest match

2011-06-06 Thread Iñaki Baz Castillo
2011/6/6 Daniel-Constantin Mierla : > The module can load on db table in a memory tree or one db table in many > trees. For the second case, the db table name is a module parameter and in > addition it must have an extra column to specify the memory tree name. Great. So we can extract different mt

Re: [SR-Users] Using =~ to get the group identifier with longest match

2011-06-06 Thread Daniel-Constantin Mierla
On 6/6/11 5:26 PM, Iñaki Baz Castillo wrote: 2011/6/6 Iñaki Baz Castillo: Thanks Daniel, please let me one question more: does the mtree module allow setting two different tables (with maybe also different columns names)? The function mt_match(mtree, pv, mode) seems to allow, as first argument

Re: [SR-Users] Using =~ to get the group identifier with longest match

2011-06-06 Thread Daniel-Constantin Mierla
On 6/6/11 5:23 PM, Iñaki Baz Castillo wrote: 2011/6/6 Iñaki Baz Castillo: Thanks Daniel, please let me one question more: does the mtree module allow setting two different tables (with maybe also different columns names)? The function mt_match(mtree, pv, mode) seems to allow, as first argument

Re: [SR-Users] Using =~ to get the group identifier with longest match

2011-06-06 Thread Iñaki Baz Castillo
2011/6/6 Iñaki Baz Castillo : >> Thanks Daniel, please let me one question more: does the mtree module >> allow setting two different tables (with maybe also different columns >> names)? The function mt_match(mtree, pv, mode) seems to allow, as >> first argument, the "model/table" to use, but I see

Re: [SR-Users] Using =~ to get the group identifier with longest match

2011-06-06 Thread Iñaki Baz Castillo
2011/6/6 Iñaki Baz Castillo : > > Thanks Daniel, please let me one question more: does the mtree module > allow setting two different tables (with maybe also different columns > names)? The function mt_match(mtree, pv, mode) seems to allow, as > first argument, the "model/table" to use, but I see n

Re: [SR-Users] Using =~ to get the group identifier with longest match

2011-06-06 Thread Iñaki Baz Castillo
2011/6/6 Daniel-Constantin Mierla : >> - You say "It has option to return a value in a cfg variable, that can >> be the group id for example". Do you mean pv_value AVP?: >>     http://kamailio.org/docs/modules/3.1.x/modules/mtree.html#id2845134 > > yes, but it can be any kind of writable variable,

Re: [SR-Users] Using =~ to get the group identifier with longest match

2011-06-06 Thread Daniel-Constantin Mierla
Hello, On 6/6/11 3:29 PM, Iñaki Baz Castillo wrote: 2011/6/6 Iñaki Baz Castillo: 2011/6/6 Daniel-Constantine Mierla: Btw, very lightweight module for longest prefix matching is mtree. It has option to return a value in a cfg variable, that can be the group id for example. It does caching in

Re: [SR-Users] Using =~ to get the group identifier with longest match

2011-06-06 Thread Iñaki Baz Castillo
2011/6/6 Iñaki Baz Castillo : > 2011/6/6 Daniel-Constantine Mierla : >> Btw, very lightweight module for longest prefix matching is mtree. It has >> option to return a value in a cfg variable, that can be the group id for >> example. It does caching in memory trees, so it is really fast in matchi

Re: [SR-Users] Using =~ to get the group identifier with longest match

2011-06-06 Thread Iñaki Baz Castillo
2011/6/6 Daniel-Constantine Mierla : > Btw, very lightweight module for longest prefix matching is mtree. It has > option to return a value in a cfg variable, that can be the group id for > example. It does caching in memory trees, so it is really fast in matching. I also missed that module. Let

Re: [SR-Users] Using =~ to get the group identifier with longest match

2011-06-06 Thread Iñaki Baz Castillo
2011/6/6 David Villasmil : > I had much the same traffic, and with a good index that wouldn't be a > problem, IMHO. Hi David, your query cannot make usage of table indexes: select * from routes where '$rU' like concat(areacode,'%') order by len(areacode) desc limit 1; You are using "LIKE" and

Re: [SR-Users] Using =~ to get the group identifier with longest match

2011-06-06 Thread Daniel-Constantine Mierla
On Jun 6, 2011, at 2:52 PM, Iñaki Baz Castillo wrote: > 2011/6/6 David Villasmil : >> I connected to mysql and ran something like: >> select * from routes where '$rU' like concat(areacode,'%') order by >> len(areacode) desc limit 1; > > Hi David, that would work indeed, but I prefer not to sat

Re: [SR-Users] Using =~ to get the group identifier with longest match

2011-06-06 Thread David Villasmil
Hello Iñaki, I had much the same traffic, and with a good index that wouldn't be a problem, IMHO. You could also load the table in memory, can't be faster than that. Of course, doing it in the config script is faster, but it limits your flexibility... just a thought... I even got the rate and cre

Re: [SR-Users] Using =~ to get the group identifier with longest match

2011-06-06 Thread Iñaki Baz Castillo
2011/6/6 David Villasmil : > I connected to mysql and ran something like: > select * from routes where '$rU' like concat(areacode,'%') order by > len(areacode) desc limit 1; Hi David, that would work indeed, but I prefer not to saturate the DB with such a query which cannot use table indexes. My k

Re: [SR-Users] Using =~ to get the group identifier with longest match

2011-06-06 Thread David Villasmil
Hello Iñaki, I did this a long time ago using a db backend, i can't remember exactly how. the table would be: areacode, route 1 route1 13 route2 I connected to mysql and ran something like: select * from routes where '$rU' like concat(areacode,'%') order by len(ar

Re: [SR-Users] Using =~ to get the group identifier with longest match

2011-06-06 Thread Iñaki Baz Castillo
2011/6/6 Juha Heinanen : > sure, but i was asking about cr and the other module that henning was > recommending. Well, for sure cr and userblacklist implements regular expression matching by taking the prefix from the DB and internally using "^PREFIX" (I expect). Same as LCR. The fact is that I d

Re: [SR-Users] Using =~ to get the group identifier with longest match

2011-06-06 Thread Juha Heinanen
Iñaki Baz Castillo writes: > > Dialplan module allows setting a regular expression per table entry > (by setting the column match_op to 1 (regexp). sure, but i was asking about cr and the other module that henning was recommending. -- juha ___ SIP Exp

Re: [SR-Users] Using =~ to get the group identifier with longest match

2011-06-06 Thread Iñaki Baz Castillo
2011/6/6 Juha Heinanen : > do both of them also support regular expressions, what inaki was asking > for? Dialplan module allows setting a regular expression per table entry (by setting the column match_op to 1 (regexp). -- Iñaki Baz Castillo ___ SI

Re: [SR-Users] Using =~ to get the group identifier with longest match

2011-06-06 Thread Juha Heinanen
Iñaki Baz Castillo writes: > > We use the userblacklist module for this, it works with the same > > longest prefix match logic as cr. do both of them also support regular expressions, what inaki was asking for? -- juha ___ SIP Express Router (SER) and

Re: [SR-Users] Using =~ to get the group identifier with longest match

2011-06-06 Thread Henning Westerholt
On Monday 06 June 2011, Iñaki Baz Castillo wrote: > It's not valid for my custom case as I need a function returning an id > of the matched groups. This is, I have various geo-zone groups: > > 1: Europe (prefixes of Europe) > 2: North America (prefixes of North America) > ... > > Each clien

Re: [SR-Users] Using =~ to get the group identifier with longest match

2011-06-06 Thread Iñaki Baz Castillo
2011/6/6 Iñaki Baz Castillo : > 2011/6/6 Henning Westerholt : >> We use the userblacklist module for this, it works with the same >> longest prefix match logic as cr. > > Ops, I missed that module :) > I'll take a look to it. Thanks. It's not valid for my custom case as I need a function returning

Re: [SR-Users] Using =~ to get the group identifier with longest match

2011-06-06 Thread Iñaki Baz Castillo
2011/6/6 Henning Westerholt : > We use the userblacklist module for this, it works with the same > longest prefix match logic as cr. Ops, I missed that module :) I'll take a look to it. Thanks. -- Iñaki Baz Castillo ___ SIP Express Router (SER) and K

Re: [SR-Users] Using =~ to get the group identifier with longest match

2011-06-06 Thread Henning Westerholt
On Monday 06 June 2011, Iñaki Baz Castillo wrote: > > Its works a bit differently, but this is similar to the logic that we > > use. You've a bunch of specific prefixes with special routing, normal > > country prefixes that you want to route differently and then a default > > routing for the rest >

Re: [SR-Users] Using =~ to get the group identifier with longest match

2011-06-06 Thread Iñaki Baz Castillo
2011/6/6 Henning Westerholt : > if you just want to have the longest match on a prefix tree, this is what > carrierroute was build for. > >> In case $rU = "99" I need to get "null", in case $rU = >> "122323" I need to get "1". > > Its works a bit differently, but this is similar to the logi

Re: [SR-Users] Using =~ to get the group identifier with longest match

2011-06-06 Thread Henning Westerholt
On Monday 06 June 2011, Iñaki Baz Castillo wrote: > [..] > I want to match the RURI user, let's suppose $rU = "138787686223". In > this case the above regexp matches groups 1 and 2, but since group 2 > matching is longest ("13" is longest than "1") I want to get value 2. Hi Iñaki, if you just wan

Re: [SR-Users] Using =~ to get the group identifier with longest match

2011-06-06 Thread Iñaki Baz Castillo
2011/6/6 Juha Heinanen : >> Thanks. I don't need different priorities, I just need that, in case >> of multiple matching (i.e. ^1 ,  ^10) the longest matching wins. Does >> the dialplan module allow it? > > try by giving rule ^1 lower priority than ^10. Yes, the trick will be: priority = 20 - s

Re: [SR-Users] Using =~ to get the group identifier with longest match

2011-06-06 Thread Juha Heinanen
Iñaki Baz Castillo writes: > Thanks. I don't need different priorities, I just need that, in case > of multiple matching (i.e. ^1 , ^10) the longest matching wins. Does > the dialplan module allow it? try by giving rule ^1 lower priority than ^10. -- juha __

Re: [SR-Users] Using =~ to get the group identifier with longest match

2011-06-06 Thread Iñaki Baz Castillo
2011/6/6 Juha Heinanen : > perhaps you could use dialplan module.  it there is overlapping regular > expressions, one is selected based on its priority. Thanks. I don't need different priorities, I just need that, in case of multiple matching (i.e. ^1 , ^10) the longest matching wins. Does the di

Re: [SR-Users] Using =~ to get the group identifier with longest match

2011-06-06 Thread Daniel-Constantin Mierla
Hello, On 6/6/11 10:39 AM, Iñaki Baz Castillo wrote: 2011/6/6 Daniel-Constantin Mierla: one option that comes in my mind is to break it in several if conditions, matching one group at a time, written in the order of preferences. The problem is that it would require perform N regular expression

Re: [SR-Users] Using =~ to get the group identifier with longest match

2011-06-06 Thread Juha Heinanen
Iñaki Baz Castillo writes: > The problem is that it would require perform N regular expression > matching and such expressions will be very long (all the country > prefixes in the world). The main problem is that some groups would > contain prefixes starting with, for example, 12, while in other g

Re: [SR-Users] Using =~ to get the group identifier with longest match

2011-06-06 Thread Iñaki Baz Castillo
2011/6/6 Daniel-Constantin Mierla : > one option that comes in my mind is to break it in several if conditions, > matching one group at a time, written in the order of preferences. The problem is that it would require perform N regular expression matching and such expressions will be very long (al

Re: [SR-Users] Using =~ to get the group identifier with longest match

2011-06-06 Thread Daniel-Constantin Mierla
Hello, On 6/6/11 10:25 AM, Iñaki Baz Castillo wrote: Hi, I wonder how feasible is the folowing: I have a regular expresion like: REGEXP = "^((1|20)|(13|3|4)|(5|6))" There are 3 matching groups: 1) (1|20) 2) (13|3|4) 3) (5|6) I want to match the RURI user, let's suppose $rU =

[SR-Users] Using =~ to get the group identifier with longest match

2011-06-06 Thread Iñaki Baz Castillo
Hi, I wonder how feasible is the folowing: I have a regular expresion like: REGEXP = "^((1|20)|(13|3|4)|(5|6))" There are 3 matching groups: 1) (1|20) 2) (13|3|4) 3) (5|6) I want to match the RURI user, let's suppose $rU = "138787686223". In this case the above regexp matches groups