Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
277 views
in Technique[技术] by (71.8m points)

Opensips - variables and strings

Dears,

I use Opensips 2.4

How to use mid_registrar_save("$(rd{ip.resolve})") to mean variable $(rd{ip.resolve}) instead of string "$(rd{ip.resolve})"

Thank you for your help.

User Location


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Traditionally, the save() and mid_registrar_save() functions have always received static parameters for the table name parameter, which is why your string does not get expanded -- it's not meant to. By requiring static strings, the modules are able to initialize their internal data structures on startup for each domain, thus being ready to populate it immediately with AoRs and contacts.

If require a dynamic number of location tables (domains), then I don't see a solution to the problem. However, if the number of such tables is finite on your system, you could use a switch statement:

switch ($(rd{ip.resolve})) {
case "location":
    mid_registrar_save("location");
    break;

case "location_1":
    mid_registrar_save("location_1");
    break;

...
}

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...