[Olsr-dev] [PATCH v1 101/115] info: add a function to initialise the config
Ferry Huberts
(spam-protected)
Wed Dec 2 21:29:14 CET 2015
From: Ferry Huberts <(spam-protected)>
Signed-off-by: Ferry Huberts <(spam-protected)>
---
lib/info/info_types.h | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)
diff --git a/lib/info/info_types.h b/lib/info/info_types.h
index 6a30ee7..de0c750 100644
--- a/lib/info/info_types.h
+++ b/lib/info/info_types.h
@@ -43,6 +43,8 @@
#define _OLSRD_LIB_INFO_INFO_TYPES_H_
#include <stdbool.h>
+#include <assert.h>
+#include <netinet/in.h>
#include "common/autobuf.h"
@@ -118,4 +120,22 @@ typedef struct {
{ .name = "allowlocalhost", .set_plugin_parameter = &set_plugin_boolean, .data = &config.allow_localhost }, \
{ .name = "ipv6only", .set_plugin_parameter = &set_plugin_boolean, .data = &config.ipv6_only }
+static inline void info_plugin_config_init(info_plugin_config_t *config, unsigned short port) {
+ assert(config);
+
+ if (olsr_cnf->ip_version == AF_INET) {
+ config->accept_ip.v4.s_addr = htonl(INADDR_LOOPBACK);
+ config->listen_ip.v4.s_addr = htonl(INADDR_ANY);
+ } else {
+ config->accept_ip.v6 = in6addr_loopback;
+ config->listen_ip.v6 = in6addr_any;
+ }
+
+ config->ipc_port = port;
+ config->nompr = 0;
+ config->http_headers = true;
+ config->allow_localhost = false;
+ config->ipv6_only = false;
+}
+
#endif /* _OLSRD_LIB_INFO_INFO_TYPES_H_ */
--
2.5.0
More information about the Olsr-dev
mailing list