Module: kamailio Branch: master Commit: ac376471d95ab7a350d9d7cc124c06a157776dff URL: https://github.com/kamailio/kamailio/commit/ac376471d95ab7a350d9d7cc124c06a1...
Author: Daniel-Constantin Mierla miconda@gmail.com Committer: Daniel-Constantin Mierla miconda@gmail.com Date: 2022-04-11T08:31:20+02:00
ipops: added function to set local ttl for dns queries
---
Modified: src/modules/ipops/ipops_mod.c
---
Diff: https://github.com/kamailio/kamailio/commit/ac376471d95ab7a350d9d7cc124c06a1... Patch: https://github.com/kamailio/kamailio/commit/ac376471d95ab7a350d9d7cc124c06a1...
---
diff --git a/src/modules/ipops/ipops_mod.c b/src/modules/ipops/ipops_mod.c index 273f232fa7..49b9ceb653 100644 --- a/src/modules/ipops/ipops_mod.c +++ b/src/modules/ipops/ipops_mod.c @@ -46,6 +46,7 @@ #include "../../core/mod_fix.h" #include "../../core/pvar.h" #include "../../core/resolve.h" +#include "../../core/dns_cache.h" #include "../../core/lvalue.h" #include "../../core/kemi.h" #include "api.h" @@ -110,6 +111,7 @@ static int fixup_free_detailed_ip_type(void** param, int param_no); static int w_dns_query(sip_msg_t* msg, char* str1, char* str2); static int w_srv_query(sip_msg_t* msg, char* str1, char* str2); static int w_naptr_query(sip_msg_t* msg, char* str1, char* str2); +static int w_dns_set_local_ttl(sip_msg_t*, char*, char*); static int mod_init(void);
static pv_export_t mod_pvs[] = { @@ -165,6 +167,8 @@ static cmd_export_t cmds[] = ANY_ROUTE }, { "naptr_query", (cmd_function)w_naptr_query, 2, fixup_spve_spve, 0, ANY_ROUTE }, + { "dns_set_local_ttl", (cmd_function)w_dns_set_local_ttl, 1, fixup_igp_null, + fixup_free_igp_null, ANY_ROUTE }, { "bind_ipops", (cmd_function)bind_ipops, 0, 0, 0, 0}, { 0, 0, 0, 0, 0, 0 } }; @@ -1358,6 +1362,30 @@ static int ki_naptr_query(sip_msg_t* msg, str* naptrname, str* pvid) return naptr_update_pv(naptrname, pvid); }
+/** + * + */ +static int ki_dns_set_local_ttl(sip_msg_t* msg, int vttl) +{ + dns_set_local_ttl(vttl); + return 1; +} + +/** + * + */ +static int w_dns_set_local_ttl(sip_msg_t *msg, char *pttl, char *p2) +{ + int vttl = 0; + + if(fixup_get_ivalue(msg, (gparam_t*)pttl, &vttl)<0) { + LM_ERR("cannot get the ttl value\n"); + return -1; + } + + return ki_dns_set_local_ttl(msg, vttl); +} + /** * */ @@ -1458,6 +1486,11 @@ static sr_kemi_t sr_kemi_ipops_exports[] = { { SR_KEMIP_STR, SR_KEMIP_STR, SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE } }, + { str_init("ipops"), str_init("dns_set_local_ttl"), + SR_KEMIP_INT, ki_dns_set_local_ttl, + { SR_KEMIP_INT, SR_KEMIP_NONE, SR_KEMIP_NONE, + SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE } + },
{ {0, 0}, {0, 0}, 0, NULL, { 0, 0, 0, 0, 0, 0 } } };