Browse code

dns_get_server_state() implemented which returns the state of the DNS servers

Miklos Tirpak authored on 22/08/2007 15:10:13
Showing 3 changed files
... ...
@@ -122,6 +122,15 @@ static const char* dns_set_server_state_doc[] = {
122 122
 	"(0: all the servers are down, 1: at least one server is up)",    /* Documentation string */
123 123
 	0                              /* Method signature(s) */
124 124
 };
125
+
126
+void dns_get_server_state_rpc(rpc_t* rpc, void* ctx);
127
+
128
+static const char* dns_get_server_state_doc[] = {
129
+	"prints the state of the DNS servers " \
130
+	"(0: all the servers are down, 1: at least one server is up)",	/* Documentation string */
131
+	0				/* Method signature(s) */
132
+};
133
+
125 134
 #endif /* DNS_WATCHDOG_SUPPORT */
126 135
 #endif /* USE_DNS_CACHE */
127 136
 #ifdef USE_DST_BLACKLIST
... ...
@@ -573,6 +582,7 @@ rpc_export_t core_rpc_methods[] = {
573 573
 #endif /* USE_DNS_CACHE_STATS */
574 574
 #ifdef DNS_WATCHDOG_SUPPORT
575 575
 	{"dns.set_server_state",   dns_set_server_state_rpc, dns_set_server_state_doc, 0 },
576
+	{"dns.get_server_state",   dns_get_server_state_rpc, dns_get_server_state_doc, 0 },
576 577
 #endif
577 578
 #endif
578 579
 #ifdef USE_DST_BLACKLIST
... ...
@@ -3120,6 +3120,12 @@ void dns_set_server_state(int state)
3120 3120
 {
3121 3121
 	atomic_set(dns_servers_up, state);
3122 3122
 }
3123
+
3124
+/* returns the state of the DNS servers */
3125
+int dns_get_server_state(void)
3126
+{
3127
+	return atomic_get(dns_servers_up);
3128
+}
3123 3129
 #endif /* DNS_WATCHDOG_SUPPORT */
3124 3130
 
3125 3131
 /* rpc functions */
... ...
@@ -3796,6 +3802,12 @@ void dns_set_server_state_rpc(rpc_t* rpc, void* ctx)
3796 3796
 		return;
3797 3797
 	dns_set_server_state(state);
3798 3798
 }
3799
+
3800
+/* prints the DNS server state */
3801
+void dns_get_server_state_rpc(rpc_t* rpc, void* ctx)
3802
+{
3803
+	rpc->add(ctx, "d", dns_get_server_state());
3804
+}
3799 3805
 #endif /* DNS_WATCHDOG_SUPPORT */
3800 3806
 
3801 3807
 #endif
... ...
@@ -327,6 +327,9 @@ void dns_cache_flush(void);
327 327
  * 0: all the servers are down
328 328
  */
329 329
 void dns_set_server_state(int state);
330
+
331
+/* returns the state of the DNS servers */
332
+int dns_get_server_state(void);
330 333
 #endif /* DNS_WATCHDOG_SUPPORT */
331 334
 
332 335
 #endif