[OpenSIPS-Users] Feature request for OpenSIPS 1.9: support for macro definitions

Michael Renzmann mrenzmann at otaku42.de
Thu Nov 8 12:22:21 CET 2012


Hi all.

I'm relatively new to OpenSIPS and still am at the very beginning of
learning how to tame this wonderful beast ;-).

One thing that I, personally, find pretty uncomfortable is that in various
places in the opensips.cfg one needs to use plain numbers to define or
modify the behaviour. That easily results in constructs like:

=== cut ===
route {
    ...
    route(42);
    ...
}

route[42] {
    ...
    setflag(8);
    ...
}
=== cut ===

Obviously, it is possible to memorize the meaning of the different numbers
depending on the context they are used in - this is what people do now
when they work with OpenSIPS. But I guess things may become pretty painful
when you have a complex configuration and need to urgently debug an issue
in it which just has brought down a heavily loaded, productively used
OpenSIPS instance...

Using comments certainly helps to relieve the problem a bit, but they can
not solve it. However, things would become much easier if one could use
"speaking names" instead of plain numbers:

=== cut ===
define(ROUTE_NAT_DETECTION, 42);
define(FLAG_NAT_DETECTED, 8);

route {
   ...
   route(ROUTE_NAT_DETECTION);
   ...
}

route[ROUTE_NAT_DETECTION] {
   ...
   setflag(FLAG_NAT_DETECTED);
   ...
}
=== cut ===

Yes, I am aware that this could also be achieved by using an external
macro preprocessor such as M4. But that would add another dependency - one
which could be avoided if OpenSIPS had built-in support for simple macro
definitions like those shown in the example above.

Bye, Mike



More information about the Users mailing list