[Olsr-dev] [PATCH v1 18/44] txtinfo: add httpheaders configuration parameter

Ferry Huberts (spam-protected)
Fri Nov 27 10:43:11 CET 2015


From: Ferry Huberts <(spam-protected)>

Signed-off-by: Ferry Huberts <(spam-protected)>
---
 lib/txtinfo/README_TXTINFO      | 3 +++
 lib/txtinfo/src/olsrd_plugin.c  | 3 +++
 lib/txtinfo/src/olsrd_txtinfo.c | 6 ++++--
 lib/txtinfo/src/olsrd_txtinfo.h | 1 +
 4 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/lib/txtinfo/README_TXTINFO b/lib/txtinfo/README_TXTINFO
index 219ed5a..ab5f828 100644
--- a/lib/txtinfo/README_TXTINFO
+++ b/lib/txtinfo/README_TXTINFO
@@ -71,6 +71,9 @@ LoadPlugin "olsrd_txtinfo.so.0.1"
     # will be used, others will be ignored.
     # PlParam     "listen"             "0.0.0.0"
 
+    # Set to true to prepend HTTP headers before the reply
+    # PlParam     "httpheaders"        "true"
+
     # Set to true to only listen on IPv6 addresses when running in IPv6 mode.
     # PlParam     "ipv6only"           "false"
 }
\ No newline at end of file
diff --git a/lib/txtinfo/src/olsrd_plugin.c b/lib/txtinfo/src/olsrd_plugin.c
index cdc9a87..adb56d8 100644
--- a/lib/txtinfo/src/olsrd_plugin.c
+++ b/lib/txtinfo/src/olsrd_plugin.c
@@ -63,6 +63,7 @@ union olsr_ip_addr txtinfo_accept_ip;
 union olsr_ip_addr txtinfo_listen_ip;
 int ipc_port;
 int nompr;
+bool http_headers;
 int txtinfo_ipv6_only;
 
 static void my_init(void) __attribute__ ((constructor));
@@ -77,6 +78,7 @@ static void my_init(void) {
 
   /* defaults for parameters */
   ipc_port = 2006;
+  http_headers = true;
   txtinfo_ipv6_only = false;
 
   if (olsr_cnf->ip_version == AF_INET) {
@@ -113,6 +115,7 @@ static const struct olsrd_plugin_parameters plugin_parameters[] = { //
         { .name = "port", .set_plugin_parameter = &set_plugin_port, .data = &ipc_port }, //
         { .name = "accept", .set_plugin_parameter = &set_plugin_ipaddress, .data = &txtinfo_accept_ip }, //
         { .name = "listen", .set_plugin_parameter = &set_plugin_ipaddress, .data = &txtinfo_listen_ip }, //
+        { .name = "httpheaders", .set_plugin_parameter = &set_plugin_boolean, .data = &http_headers }, //
         { .name = "ipv6only", .set_plugin_parameter = &set_plugin_boolean, .data = &txtinfo_ipv6_only } //
     };
 
diff --git a/lib/txtinfo/src/olsrd_txtinfo.c b/lib/txtinfo/src/olsrd_txtinfo.c
index df9be77..8ea9bd9 100644
--- a/lib/txtinfo/src/olsrd_txtinfo.c
+++ b/lib/txtinfo/src/olsrd_txtinfo.c
@@ -814,8 +814,10 @@ static void send_info(unsigned int send_what, int the_socket) {
   abuf_init(&abuf, 4096);
 
   /* Print minimal http header */
-  abuf_puts(&abuf, "HTTP/1.0 200 OK\n");
-  abuf_puts(&abuf, "Content-type: text/plain\n\n");
+  if (http_headers) {
+    abuf_puts(&abuf, "HTTP/1.0 200 OK\n");
+    abuf_puts(&abuf, "Content-type: text/plain\n\n");
+  }
 
   /* Print tables to IPC socket */
 
diff --git a/lib/txtinfo/src/olsrd_txtinfo.h b/lib/txtinfo/src/olsrd_txtinfo.h
index 4f61c44..c0659ba 100644
--- a/lib/txtinfo/src/olsrd_txtinfo.h
+++ b/lib/txtinfo/src/olsrd_txtinfo.h
@@ -60,6 +60,7 @@ extern union olsr_ip_addr txtinfo_accept_ip;
 extern union olsr_ip_addr txtinfo_listen_ip;
 extern int ipc_port;
 extern int nompr;
+extern bool http_headers;
 extern int txtinfo_ipv6_only;
 
 int olsrd_plugin_interface_version(void);
-- 
2.5.0




More information about the Olsr-dev mailing list