Hi Iñaki,
the cpl module follows the IETF standard on this (RFC3880). There are
some reasons why the language is a bit tight, mainly:
1) not to be dependent of the SIP server implementation
2) not to allow any security hole
(see the RFC comments, as they do a better job then me here ;) )
As much as possible, the cpl interpretor in openser should stick to the
standard version. But trying to do a openser specific extension is a
different story ;)
Regards,
Bogdan
Iñaki Baz Castillo wrote:
Hi, in my opinion CPL language is not enough powerful,
the absence of regular
expression or any header reading makes it poor (IMHO). It would become really
cool if it could match AVP's but it can :(
I'm trying to give some power to CPL logic. I want to implement "addressbook
categories" for each user, this is: each user has its own addressbook in which
he can set a category for each contact:
- Work
- Friend
- Family
- Custom
And of course what I need it a way to match that category **inside** the CPL logic.
This is impossible with CPL itself so I'm thinking in a very very dirty trick:
** Addressbook Categories **
- In an incoming call for "bob(a)domain.org" OpenSer will match the callerid
against
Bob's addressbook. This will return a variable or AVP:
$avp(s:caller_category)
- CPL module just can match "Organization", "Subject", and
"User-Agent", so
OpenSer will do:
append_hf("Bak_Organization: $hdr(Organization)\r\n"); # To preserve
original Organization
remove_hf("Organization"); # Remove original Organization
append_hf("Organization: $avp(s:caller_category)\r\n"); # Set category as
Organization
- But since OpenSer appends/removes headers when the message leaves the proxy I
can't run CPL now (it will not read the new "Organization" header), so I
need to do a
dirty loop in order to append the header.
- When the message comes back into OpenSer the headers are updated so I do:
remove_hf("Organization"); # Remove current Organization (that is a hack)
append_hf("Organization: $hdr(Backup_Organization)\r\n"); # Restore
original Organization
(those changes will be applied again when message leaves OpenSer, not now).
- And I run CPL:
cpl_run_script("incoming","FORCE_STATEFUL");
- Into CPL I match "Organization" header by:
<string-switch field="Organization">
<string is="Friends">
<reject status="reject" reason="I have no friends"
/>
</string>
</string-switch>
Is it enough dirty or could I make it more?
Any suggestion? how do you people implement things like this?
Thank a lot.