Browse code

raw sockets: added info rpc

Added core.udp4_raw_info RPC for getting information about the raw
mode state.
E.g.:
sercmd> core.udp4_raw_info
{
udp4_raw: 1
udp4_raw_mtu: 1500
udp4_raw_ttl: 64
}

Andrei Pelinescu-Onciul authored on 11/08/2010 14:02:10
Showing 1 changed files
... ...
@@ -44,6 +44,7 @@
44 44
 #include "tcp_info.h"
45 45
 #include "tcp_options.h"
46 46
 #include "core_cmd.h"
47
+#include "cfg_core.h"
47 48
 #ifdef USE_SCTP
48 49
 #include "sctp_options.h"
49 50
 #include "sctp_server.h"
... ...
@@ -807,6 +808,30 @@ static void core_sctpinfo(rpc_t* rpc, void* c)
807 807
 
808 808
 
809 809
 
810
+
811
+static const char* core_udp4rawinfo_doc[] = {
812
+	"Returns udp4_raw related info.",    /* Documentation string */
813
+	0                                     /* Method signature(s) */
814
+};
815
+
816
+static void core_udp4rawinfo(rpc_t* rpc, void* c)
817
+{
818
+#ifdef USE_RAW_SOCKS
819
+	void *handle;
820
+
821
+	rpc->add(c, "{", &handle);
822
+	rpc->struct_add(handle, "ddd",
823
+		"udp4_raw", cfg_get(core, core_cfg, udp4_raw),
824
+		"udp4_raw_mtu", cfg_get(core, core_cfg, udp4_raw_mtu),
825
+		"udp4_raw_ttl", cfg_get(core, core_cfg, udp4_raw_ttl)
826
+	);
827
+#else /* USE_RAW_SOCKS */
828
+	rpc->fault(c, 500, "udp4_raw mode support not compiled");
829
+#endif /* USE_RAW_SOCKS */
830
+}
831
+
832
+
833
+
810 834
 /*
811 835
  * RPC Methods exported by this module
812 836
  */
... ...
@@ -835,6 +860,8 @@ static rpc_export_t core_rpc_methods[] = {
835 835
 	{"core.sctp_options",      core_sctp_options,      core_sctp_options_doc,
836 836
 		0},
837 837
 	{"core.sctp_info",         core_sctpinfo,          core_sctpinfo_doc,   0},
838
+	{"core.udp4_raw_info",     core_udp4rawinfo,       core_udp4rawinfo_doc,
839
+		0},
838 840
 #ifdef USE_DNS_CACHE
839 841
 	{"dns.mem_info",          dns_cache_mem_info,     dns_cache_mem_info_doc,
840 842
 		0	},