[SR-Users] using a pseudo-variable as a parameter to a module function
abalashov at evaristesys.com
Fri Dec 13 19:47:37 CET 2019
There are internal API functions which handle pseudovariable
interpolation in string arguments, e.g. pv_get_spec_value().
You can see one-off uses of this for example in the fixup functions
(functions which preliminarily process and validate arguments, often,
but not always beginning with w_, for "wrapper").
You can see how this works in the 'uac' module, for example:
But in my opinion, the most sensible packaging of this functionality is
done in the dispatcher module. You'll note that ds_select_*() share a
wrapper called w_ds_select_addr():
There is this nice macro, proprietary to the dispatcher module, called
That's defined here:
And it takes advantage of a core API function called get_is_fparam():
As you can see, it can evaluate all kinds of interpolated values.
So, I'd just use that.
On Fri, Dec 13, 2019 at 12:10:02PM -0600, Michael Iedema wrote:
> Hi all,
> I’m trying to write a basic Kamailio module from scratch and have run into an area where I’m in need of a couple pointers (pun not intended). :-) I have the module loading correctly and can call a function in my routing script like this:
> This, for now, just triggers a print of the submitted parameter.
> What I’d like to do next is have it accept and print the From URI in configuration script like so:
> For now, this prints the string literal of “$fU” and I’m trying to extract the value of the referenced variable and print that. The example module “print” does not involve this concept of pseudo-variables. The skeleton module example in the wiki also does not mention variables.
> I’ve looked into other modules to see how it works but they all seem to have a slightly different handling of this task. Can someone point me to an example in the modules which accomplishes this?
> What I’ve been searching for is a replace_all function which accepts a string containing pseudo-variables and returns a new string with them all replaced with their corresponding values.
> Thanks in advance and apologies if I’ve overlooked a relevant piece of developer documentation or if I’m looking at this incorrectly.
> Kamailio (SER) - Users Mailing List
> sr-users at lists.kamailio.org
Alex Balashov | Principal | Evariste Systems LLC
Tel: +1-706-510-6800 / +1-800-250-5920 (toll-free)
Web: http://www.evaristesys.com/, http://www.csrpswitch.com/
More information about the sr-users