Browse code

sctp: rpc info command

- added core.sctp_info which returns some very general sctp
information (opened associations, tracked ones, total
associations opened from startup).
E.g.:
$ sercmd core.sctp_info
{
opened_connections: 0
tracked_connections: 0
total_connections: 50007
}

Andrei Pelinescu-Onciul authored on 04/03/2009 20:56:11
Showing 1 changed files
... ...
@@ -41,6 +41,7 @@
41 41
 #include "core_cmd.h"
42 42
 #ifdef USE_SCTP
43 43
 #include "sctp_options.h"
44
+#include "sctp_server.h"
44 45
 #endif
45 46
 
46 47
 #ifdef USE_DNS_CACHE
... ...
@@ -622,6 +623,35 @@ static void core_sctp_options(rpc_t* rpc, void* c)
622 623
 
623 624
 
624 625
 
626
+static const char* core_sctpinfo_doc[] = {
627
+	"Returns sctp related info.",    /* Documentation string */
628
+	0                               /* Method signature(s) */
629
+};
630
+
631
+static void core_sctpinfo(rpc_t* rpc, void* c)
632
+{
633
+#ifdef USE_SCTP
634
+	void *handle;
635
+	struct sctp_gen_info i;
636
+
637
+	if (!sctp_disable){
638
+		sctp_get_info(&i);
639
+		rpc->add(c, "{", &handle);
640
+		rpc->struct_add(handle, "ddd",
641
+			"opened_connections", i.sctp_connections_no,
642
+			"tracked_connections", i.sctp_tracked_no,
643
+			"total_connections", i.sctp_total_connections
644
+		);
645
+	}else{
646
+		rpc->fault(c, 500, "sctp support disabled");
647
+	}
648
+#else
649
+	rpc->fault(c, 500, "sctp support not compiled");
650
+#endif
651
+}
652
+
653
+
654
+
625 655
 /*
626 656
  * RPC Methods exported by this module
627 657
  */
... ...
@@ -644,6 +674,7 @@ rpc_export_t core_rpc_methods[] = {
644 674
 	{"core.tcp_options",       core_tcp_options,       core_tcp_options_doc,0},
645 675
 	{"core.sctp_options",      core_sctp_options,      core_sctp_options_doc,
646 676
 		0},
677
+	{"core.sctp_info",         core_sctpinfo,          core_sctpinfo_doc,   0},
647 678
 #ifdef USE_DNS_CACHE
648 679
 	{"dns.mem_info",          dns_cache_mem_info,     dns_cache_mem_info_doc,     0	},
649 680
 	{"dns.debug",          dns_cache_debug,           dns_cache_debug_doc,        0	},