[sr-dev] git:master:1822d974: core: dns cache - print status as field in rpc structure

Daniel-Constantin Mierla miconda at gmail.com
Sun May 6 22:53:04 CEST 2018


Module: kamailio
Branch: master
Commit: 1822d974ff1704cca3a1db5fce0507be47af3928
URL: https://github.com/kamailio/kamailio/commit/1822d974ff1704cca3a1db5fce0507be47af3928

Author: Daniel-Constantin Mierla <miconda at gmail.com>
Committer: Daniel-Constantin Mierla <miconda at gmail.com>
Date: 2018-05-06T22:52:46+02:00

core: dns cache - print status as field in rpc structure

---

Modified: src/core/dns_cache.c

---

Diff:  https://github.com/kamailio/kamailio/commit/1822d974ff1704cca3a1db5fce0507be47af3928.diff
Patch: https://github.com/kamailio/kamailio/commit/1822d974ff1704cca3a1db5fce0507be47af3928.patch

---

diff --git a/src/core/dns_cache.c b/src/core/dns_cache.c
index 88c0ae244f..908c378aad 100644
--- a/src/core/dns_cache.c
+++ b/src/core/dns_cache.c
@@ -4030,24 +4030,44 @@ void dns_cache_flush(int del_permanent)
 /* deletes all the non-permanent entries from the cache */
 void dns_cache_delete_all(rpc_t* rpc, void* ctx)
 {
+	void *th;
+
 	if (!cfg_get(core, core_cfg, use_dns_cache)){
 		rpc->fault(ctx, 500, "dns cache support disabled (see use_dns_cache)");
 		return;
 	}
 	dns_cache_flush(0);
-	rpc->rpl_printf(ctx, "OK");
+
+	if(rpc->add(ctx, "{", &th) < 0) {
+		rpc->fault(ctx, 500, "Internal error - root structure");
+		return;
+	}
+	if(rpc->struct_add(th, "s", "status", "ok") < 0) {
+		rpc->fault(ctx, 500, "Internal error - status");
+		return;
+	}
 }
 
 /* deletes all the entries from the cache,
  * even the permanent ones */
 void dns_cache_delete_all_force(rpc_t* rpc, void* ctx)
 {
+	void *th;
+
 	if (!cfg_get(core, core_cfg, use_dns_cache)){
 		rpc->fault(ctx, 500, "dns cache support disabled (see use_dns_cache)");
 		return;
 	}
 	dns_cache_flush(1);
-	rpc->rpl_printf(ctx, "OK");
+
+	if(rpc->add(ctx, "{", &th) < 0) {
+		rpc->fault(ctx, 500, "Internal error - root structure");
+		return;
+	}
+	if(rpc->struct_add(th, "s", "status", "ok") < 0) {
+		rpc->fault(ctx, 500, "Internal error - status");
+		return;
+	}
 }
 
 /* clones an entry and extends its memory area to hold a new rr.




More information about the sr-dev mailing list