Merge babeld configuration fix by zorun
authorGabriel Kerneis <gabriel@kerneis.info>
Mon, 9 Jun 2014 08:58:39 +0000 (09:58 +0100)
committerGabriel Kerneis <gabriel@kerneis.info>
Mon, 9 Jun 2014 08:58:39 +0000 (09:58 +0100)
12 files changed:
olsrd/Makefile
olsrd/files/olsrd.config [deleted file]
olsrd/files/olsrd.hotplug.sh
olsrd/files/olsrd.init
olsrd/files/olsrd4.config [new file with mode: 0644]
olsrd/files/olsrd4.init [new file with mode: 0644]
olsrd/files/olsrd6.config [new file with mode: 0644]
olsrd/files/olsrd6.init [new file with mode: 0644]
olsrd/patches/001-Fix-processing-error-for-fragmented-hellos.patch [deleted file]
olsrd/patches/002-hotfix-long-http-headers-txtinfo.patch [deleted file]
olsrd/patches/003-hotfix-long-http-headers-json.patch [deleted file]
olsrd/patches/004-jsonplugin-http-headers.patch [deleted file]

index 2faadd82b975bae2eb99d39b22c69c37692ac32e..d1516744e6d65f3d7855242d466267789f4dd021 100644 (file)
@@ -8,13 +8,13 @@
 include $(TOPDIR)/rules.mk
 
 PKG_NAME:=olsrd
-PKG_VERSION:=0.6.6.1
-PKG_RELEASE:=3
+PKG_VERSION:=0.6.6.2
+PKG_RELEASE:=2
 
 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
 PKG_SOURCE_URL:=http://www.olsr.org/releases/0.6
 
-PKG_MD5SUM:=ef480495f307232f1df931ae5df18bf9
+PKG_MD5SUM:=e4e04bb033cffd99b3be397fa9063a54
 PKG_BUILD_PARALLEL:=1
 
 include $(INCLUDE_DIR)/package.mk
@@ -37,7 +37,8 @@ define Package/olsrd
 endef
 
 define Package/olsrd/conffiles
-/etc/config/olsrd
+/etc/config/olsrd4
+/etc/config/olsrd6
 endef
 
 define Package/olsrd-mod-arprefresh
@@ -169,12 +170,16 @@ define Build/Compile
 endef
 
 define Package/olsrd/install
+       $(INSTALL_DIR) $(1)/lib/functions
+       $(INSTALL_DATA) ./files/olsrd.init $(1)/lib/functions/olsrd.sh
        $(INSTALL_DIR) $(1)/etc/config
-       $(INSTALL_DATA) ./files/olsrd.config $(1)/etc/config/olsrd
+       $(INSTALL_DATA) ./files/olsrd4.config $(1)/etc/config/olsrd4
+       $(INSTALL_DATA) ./files/olsrd6.config $(1)/etc/config/olsrd6
        $(INSTALL_DIR) $(1)/usr/sbin
        $(INSTALL_BIN) $(PKG_BUILD_DIR)/olsrd $(1)/usr/sbin/
        $(INSTALL_DIR) $(1)/etc/init.d
-       $(INSTALL_BIN) ./files/olsrd.init $(1)/etc/init.d/olsrd
+       $(INSTALL_BIN) ./files/olsrd4.init $(1)/etc/init.d/olsrd4
+       $(INSTALL_BIN) ./files/olsrd6.init $(1)/etc/init.d/olsrd6
        $(INSTALL_DIR) $(1)/etc/hotplug.d/iface
        $(INSTALL_BIN) ./files/olsrd.hotplug.sh $(1)/etc/hotplug.d/iface/50-olsrd
 endef
diff --git a/olsrd/files/olsrd.config b/olsrd/files/olsrd.config
deleted file mode 100644 (file)
index 9a19eb9..0000000
+++ /dev/null
@@ -1,26 +0,0 @@
-config olsrd
-       # uncomment the following line to use a custom config file instead:
-       #option config_file '/etc/olsrd.conf'
-
-       option IpVersion '4'
-
-config LoadPlugin
-       option library 'olsrd_arprefresh.so.0.1'
-
-config LoadPlugin
-       option library 'olsrd_dyn_gw.so.0.5'
-
-config LoadPlugin
-       option library 'olsrd_httpinfo.so.0.1'
-       option port '1978'
-       list Net '0.0.0.0 0.0.0.0'
-
-config LoadPlugin
-       option library 'olsrd_nameservice.so.0.3'
-
-config LoadPlugin
-       option library 'olsrd_txtinfo.so.0.1'
-       option accept '0.0.0.0'
-
-config Interface
-       list interface 'wlan'
index 2094463fc1a8c512eb1e03bbb6006fd9fec87d93..9e5f0ca72cff5126dbeff80c1cb99ab92c0daaf3 100755 (executable)
@@ -5,8 +5,8 @@ olsrd_list_configured_interfaces()
        local i=0
        local interface
 
-       while interface="$( uci -q get olsrd.@Interface[$i].interface )"; do {
-               case "$( uci -q get olsrd.@Interface[$i].ignore )" in
+       while interface="$( uci -q get $OLSRD.@Interface[$i].interface )"; do {
+               case "$( uci -q get $OLSRD.@Interface[$i].ignore )" in
                        1|on|true|enabled|yes)
                                # is disabled
                        ;;
@@ -22,7 +22,7 @@ olsrd_list_configured_interfaces()
 olsrd_interface_already_in_config()
 {
        # e.g.: 'Interface "eth0.1" "eth0.2" "wlan0"'
-       if grep -s ^'Interface ' '/var/etc/olsrd.conf' | grep -q "\"$DEVICE\""; then
+       if grep -s ^'Interface ' '/var/etc/$OLSRD.conf' | grep -q "\"$DEVICE\""; then
                logger -t olsrd_hotplug -p daemon.debug "[OK] already_active: '$INTERFACE' => '$DEVICE'"
                return 0
        else
@@ -44,7 +44,7 @@ olsrd_interface_needs_adding()
                }
        } done
 
-       logger -t olsrd_hotplug -p daemon.debug "[OK] interface '$INTERFACE' => '$DEVICE' not used for olsrd"
+       logger -t olsrd_hotplug -p daemon.debug "[OK] interface '$INTERFACE' => '$DEVICE' not used for $OLSRD"
        return 1
 }
 
@@ -52,11 +52,19 @@ case "$ACTION" in
        ifup)
                # only work after the first normal startup
                # also: no need to test, if enabled
-               [ -e '/var/etc/olsrd.conf' ] && {
+               OLSRD=olsrd4
+               [ -e "/var/etc/$OLSRD.conf" ] && {
                        # INTERFACE = e.g. 'wlanadhocRADIO1' or 'cfg144d8f'
                        # DEVICE    = e.g. 'wlan1-1'
                        olsrd_interface_needs_adding && {
-                               . /etc/rc.common /etc/init.d/olsrd restart
+                               . /etc/rc.common /etc/init.d/$OLSRD restart
+                       }
+               }
+
+               OLSRD=olsrd6
+               [ -e "/var/etc/$OLSRD.conf" ] && {
+                       olsrd_interface_needs_adding && {
+                               . /etc/rc.common /etc/init.d/$OLSRD restart
                        }
                }
        ;;
index c8f1df566c1b1b975fbf717d3d6f615c3444709b..5864756465a9b2a465650af8698e8df86430e470 100644 (file)
@@ -6,10 +6,6 @@ START=65
 SERVICE_DAEMONIZE=1
 SERVICE_WRITE_PID=1
 
-CONF=/var/etc/olsrd.conf
-PID=/var/run/olsrd.pid
-PID6=/var/run/olsrd.ipv6.pid
-
 OLSRD_OLSRD_SCHEMA='ignore:internal config_file:internal DebugLevel=0 AllowNoInt=yes'
 OLSRD_IPCCONNECT_SCHEMA='ignore:internal Host:list Net:list2'
 OLSRD_LOADPLUGIN_SCHEMA='ignore:internal library:internal Host4:list Net4:list2 Host:list Net:list2 Host6:list Net6:list2 Ping:list redistribute:list NonOlsrIf:list name:list lat lon latlon_infile HNA:list2 hosts:list2'
@@ -395,10 +391,6 @@ olsrd_write_olsrd() {
        [ "$OLSRD_COUNT" -gt 0 ] && return 0
 
        config_get ipversion "$cfg" IpVersion
-       if [ "$ipversion" = "6and4" ]; then
-               OLSRD_IPVERSION_6AND4=1
-               config_set "$cfg" IpVersion '6'
-       fi
        config_get smartgateway "$cfg" SmartGateway
        config_get smartgatewayuplink "$cfg" SmartGatewayUplink
 
@@ -622,9 +614,21 @@ olsrd_update_schema() {
 }
 
 olsrd_write_config() {
-       OLSRD_IPVERSION_6AND4=0
        OLSRD_COUNT=0
        config_foreach olsrd_write_olsrd olsrd
+
+       if [ ! -z "$ipversion" ]; then
+               if [ "$ipversion" = "6and4" ]; then
+                       error "IpVersion 6and4 is no longer supported!"
+                       error "You must use /etc/config/olsrd4 for IPv4 and /etc/config/olsrd6 for IPv4"
+               else
+                       error "Option IpVersion is no longer supported!"
+                       error "Please remove it from /etc/config/$UCI_CONF_NAME"
+               fi
+
+               return 1
+       fi
+
        IPCCONNECT_COUNT=0
        config_foreach olsrd_write_ipcconnect IpcConnect
        HNA4_COUNT=0
@@ -750,6 +754,13 @@ olsrd_setup_smartgw_rules() {
 }
 
 start() {
+        if [ -f /etc/config/olsrd ]; then
+              error "/etc/config/olsrd no longer supported!"
+              error "please move your config file to /etc/config/olsrd4 and/or /etc/config/olsrd6"
+
+              return 1
+       fi
+
        SYSTEM_HOSTNAME=
        SYSTEM_LAT=
        SYSTEM_LON=
@@ -766,7 +777,7 @@ start() {
 
        . /lib/functions/network.sh
 
-       config_load olsrd
+       config_load $UCI_CONF_NAME
        reset_cb
 
        OLSRD_CONFIG_FILE=
@@ -774,61 +785,24 @@ start() {
 
        if [ -z "$OLSRD_CONFIG_FILE" ]; then
                mkdir -p -- /var/etc/
-               olsrd_write_config > /var/etc/olsrd.conf
+               olsrd_write_config > /var/etc/$UCI_CONF_NAME.conf || return 1
                if [ "$INTERFACES_COUNT" -gt 0 -a "$OLSRD_COUNT" -gt 0 ]; then
-                       OLSRD_CONFIG_FILE=/var/etc/olsrd.conf
+                       OLSRD_CONFIG_FILE=/var/etc/$UCI_CONF_NAME.conf
                fi
        fi
 
        [ -z "$OLSRD_CONFIG_FILE" ] && return 1
 
-       local bindv6only='0'
-       if [ "$OLSRD_IPVERSION_6AND4" -ne 0 ]; then
-               bindv6only="$(sysctl -n net.ipv6.bindv6only)"
-               sysctl -w net.ipv6.bindv6only=1 > /dev/null
-               sed -e '/[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}/d' < "$OLSRD_CONFIG_FILE" > /var/etc/olsrd.conf.ipv6
-               sed -e 's/^IpVersion[ ][ ]*6$/IpVersion 4/' -e 's/^\t\t[A-Fa-f0-9.:]*[:][A-Fa-f0-9.:]*[ ][0-9]*$//' < "$OLSRD_CONFIG_FILE" > /var/etc/olsrd.conf.ipv4
-               rm $OLSRD_CONFIG_FILE
-
-               # some filenames should get the suffix .ipv6
-               for file in $latlon_file $hosts_file $services_file $resolv_file $macs_file $wd_file;do
-                       f=$(echo $file|sed 's/\//\\\//g')
-                       sed -i "s/$f/$f.ipv6/g" /var/etc/olsrd.conf.ipv6
-               done
-
-               SERVICE_PID_FILE="$PID6"
-               if service_check /usr/sbin/olsrd; then
-                       error "there is already an IPv6 instance of olsrd running (pid: '$(cat $PID6)'), not starting."
-               else
-                       service_start /usr/sbin/olsrd -f /var/etc/olsrd.conf.ipv6 -nofork
-               fi
-
-               SERVICE_PID_FILE="$PID"
-               if service_check /usr/sbin/olsrd; then
-                       error "there is already an IPv4 instance of olsrd running (pid: '$(cat $PID)'), not starting."
-               else
-                       service_start /usr/sbin/olsrd -f /var/etc/olsrd.conf.ipv4 -nofork
-               fi
-
-               sleep 3
-               sysctl -w net.ipv6.bindv6only="$bindv6only" > /dev/null
-
+       SERVICE_PID_FILE="$PID"
+       if service_check /usr/sbin/olsrd; then
+               error "there is already an instance of $UCI_CONF_NAME running (pid: '$(cat $PID)'), not starting."
+               return 1
        else
-
-               if [ "$ipversion" = "6" ]; then
-                       sed -i '/[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}/d' "$OLSRD_CONFIG_FILE"
-               fi
-
-               SERVICE_PID_FILE="$PID"
-               if service_check /usr/sbin/olsrd; then
-                       error "there is already an IPv4 instance of olsrd running (pid: '$(cat $PID)'), not starting."
-                       return 1
-               else
-                       service_start /usr/sbin/olsrd -f "$OLSRD_CONFIG_FILE" -nofork
-                       service_check /usr/sbin/olsrd || {
-                               log "startup-error: check via: '/usr/sbin/olsrd -f \"$OLSRD_CONFIG_FILE\" -nofork'"
-                       }
-               fi
+               service_start /usr/sbin/olsrd -f "$OLSRD_CONFIG_FILE" -nofork
+               sleep 1
+               service_check /usr/sbin/olsrd || {
+                       log "startup-error: check via: '/usr/sbin/olsrd -f \"$OLSRD_CONFIG_FILE\" -nofork'"
+               }
        fi
 
        olsrd_setup_smartgw_rules
@@ -837,7 +811,4 @@ start() {
 stop() {
        SERVICE_PID_FILE="$PID"
        service_stop /usr/sbin/olsrd
-
-       SERVICE_PID_FILE="$PID6"
-       service_stop /usr/sbin/olsrd
 }
diff --git a/olsrd/files/olsrd4.config b/olsrd/files/olsrd4.config
new file mode 100644 (file)
index 0000000..f4ddfd0
--- /dev/null
@@ -0,0 +1,24 @@
+config olsrd
+       # uncomment the following line to use a custom config file instead:
+       #option config_file '/etc/olsrd.conf'
+
+config LoadPlugin
+       option library 'olsrd_arprefresh.so.0.1'
+
+config LoadPlugin
+       option library 'olsrd_dyn_gw.so.0.5'
+
+config LoadPlugin
+       option library 'olsrd_httpinfo.so.0.1'
+       option port '1978'
+       list Net '0.0.0.0 0.0.0.0'
+
+config LoadPlugin
+       option library 'olsrd_nameservice.so.0.3'
+
+config LoadPlugin
+       option library 'olsrd_txtinfo.so.0.1'
+       option accept '0.0.0.0'
+
+config Interface
+       list interface 'wlan'
diff --git a/olsrd/files/olsrd4.init b/olsrd/files/olsrd4.init
new file mode 100644 (file)
index 0000000..2afa434
--- /dev/null
@@ -0,0 +1,15 @@
+#!/bin/sh /etc/rc.common
+# Copyright (C) 2008-2013 OpenWrt.org
+
+. /lib/functions/olsrd.sh
+
+START=65
+
+SERVICE_DAEMONIZE=1
+SERVICE_WRITE_PID=1
+
+CONF=/var/etc/olsrd4.conf
+PID=/var/run/olsrd4.pid
+
+UCI_CONF_NAME=olsrd4
+OLSRD_OLSRD_SCHEMA="$OLSRD_OLSRD_SCHEMA IpVersion=4"
diff --git a/olsrd/files/olsrd6.config b/olsrd/files/olsrd6.config
new file mode 100644 (file)
index 0000000..37349e4
--- /dev/null
@@ -0,0 +1,11 @@
+config olsrd
+       # uncomment the following line to use a custom config file instead:
+       #option config_file '/etc/olsrd6.conf'
+
+config LoadPlugin
+       option library 'olsrd_txtinfo.so.0.1'
+       option accept '::'
+       option port '2007'
+
+config Interface
+       list interface 'wlan'
diff --git a/olsrd/files/olsrd6.init b/olsrd/files/olsrd6.init
new file mode 100644 (file)
index 0000000..35fba5b
--- /dev/null
@@ -0,0 +1,15 @@
+#!/bin/sh /etc/rc.common
+# Copyright (C) 2008-2013 OpenWrt.org
+
+. /lib/functions/olsrd.sh
+
+START=65
+
+SERVICE_DAEMONIZE=1
+SERVICE_WRITE_PID=1
+
+CONF=/var/etc/olsrd6.conf
+PID=/var/run/olsrd6.pid
+
+UCI_CONF_NAME=olsrd6
+OLSRD_OLSRD_SCHEMA="$OLSRD_OLSRD_SCHEMA IpVersion=6"
diff --git a/olsrd/patches/001-Fix-processing-error-for-fragmented-hellos.patch b/olsrd/patches/001-Fix-processing-error-for-fragmented-hellos.patch
deleted file mode 100644 (file)
index a1bc5a7..0000000
+++ /dev/null
@@ -1,47 +0,0 @@
-commit bdca59455c9b91b112a5c27eba2ccba3f606797d
-Author: Henning Rogge <henning.rogge@fkie.fraunhofer.de>
-Date:   Mon Mar 31 11:18:30 2014 +0200
-
-    Fix processing error for fragmented hellos
-
-diff --git a/src/process_package.c b/src/process_package.c
-index 780efab..b39b692 100644
---- a/src/process_package.c
-+++ b/src/process_package.c
-@@ -441,21 +441,15 @@ olsr_hello_tap(struct hello_message *message, struct interface *in_if, const uni
-     /* find the input interface in the list of neighbor interfaces */
-     for (walker = message->neighbors; walker != NULL; walker = walker->next) {
--      if (walker->link != UNSPEC_LINK
--          && ipequal(&walker->address, &in_if->ip_addr)) {
-+      if (ipequal(&walker->address, &in_if->ip_addr)) {
-+        /*
-+         * memorize our neighbour's idea of the link quality, so that we
-+         * know the link quality in both directions
-+         */
-+        olsr_memorize_foreign_hello_lq(lnk, walker->link != UNSPEC_LINK ? walker : NULL);
-         break;
-       }
-     }
--
--    /*
--     * memorize our neighbour's idea of the link quality, so that we
--     * know the link quality in both directions
--     *
--     * walker is NULL if there the current interface was not included in
--     * the message (or was included as an UNSPEC_LINK)
--     */
--    olsr_memorize_foreign_hello_lq(lnk, walker);
--
-     /* update packet loss for link quality calculation */
-     olsr_received_hello_handler(lnk);
-   }
-@@ -493,7 +487,7 @@ olsr_hello_tap(struct hello_message *message, struct interface *in_if, const uni
-   if (neighbor->willingness != WILL_NEVER)
-     process_message_neighbors(neighbor, message);
--  /* Process changes immedeatly in case of MPR updates */
-+  /* Process changes immediately in case of MPR updates */
-   olsr_process_changes();
-   olsr_free_hello_packet(message);
diff --git a/olsrd/patches/002-hotfix-long-http-headers-txtinfo.patch b/olsrd/patches/002-hotfix-long-http-headers-txtinfo.patch
deleted file mode 100644 (file)
index e04e815..0000000
+++ /dev/null
@@ -1,36 +0,0 @@
-commit d68c96cf53f188030452aadec466aa6389e81511
-Author: Henning Rogge <hrogge@gmail.com>
-Date:   Tue May 13 21:23:36 2014 +0200
-
-    Hotfix for much too long http headers
-
-diff --git a/lib/txtinfo/src/olsrd_txtinfo.c b/lib/txtinfo/src/olsrd_txtinfo.c
-index b56545d..2bcce41 100644
---- a/lib/txtinfo/src/olsrd_txtinfo.c
-+++ b/lib/txtinfo/src/olsrd_txtinfo.c
-@@ -301,8 +301,15 @@ ipc_action(int fd, void *data __attribute__ ((unused)), unsigned int flags __att
-   FD_ZERO(&rfds);
-   FD_SET((unsigned int)ipc_connection, &rfds);  /* Win32 needs the cast here */
-   if (0 <= select(ipc_connection + 1, &rfds, NULL, NULL, &tv)) {
--    char requ[128];
--    ssize_t s = recv(ipc_connection, (void *)&requ, sizeof(requ), 0);   /* Win32 needs the cast here */
-+    char requ[1024];
-+    ssize_t s = recv(ipc_connection, (void *)&requ, sizeof(requ)-1, 0);   /* Win32 needs the cast here */
-+
-+    if (s == sizeof(requ)-1) {
-+      /* input was much too long, just skip the rest */
-+      char dummy[1024];
-+
-+      while (recv(ipc_connection, (void *)&dummy, sizeof(dummy), 0) == sizeof(dummy), 0);
-+    }
-     if (0 < s) {
-       requ[s] = 0;
-       /* To print out neighbours only on the Freifunk Status
-@@ -329,6 +336,7 @@ ipc_action(int fd, void *data __attribute__ ((unused)), unsigned int flags __att
-         if (0 != strstr(requ, "/ver")) send_what |= SIW_VERSION;
-       }
-     }
-+
-     if ( send_what == 0 ) send_what = SIW_ALL;
-   }
diff --git a/olsrd/patches/003-hotfix-long-http-headers-json.patch b/olsrd/patches/003-hotfix-long-http-headers-json.patch
deleted file mode 100644 (file)
index 8774856..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-commit 528176910ee1d00278e4108cc23d9f4f2de8a639
-Author: Alessio Caiazza <nolith@abisso.org>
-Date:   Wed May 14 22:45:33 2014 +0200
-
-    Hotfix for very long http headers also for jsoninfo
-
-diff --git a/lib/jsoninfo/src/olsrd_jsoninfo.c b/lib/jsoninfo/src/olsrd_jsoninfo.c
-index 966292c..817c64a 100644
---- a/lib/jsoninfo/src/olsrd_jsoninfo.c
-+++ b/lib/jsoninfo/src/olsrd_jsoninfo.c
-@@ -508,8 +508,15 @@ ipc_action(int fd, void *data __attribute__ ((unused)), unsigned int flags __att
-   FD_ZERO(&rfds);
-   FD_SET((unsigned int)ipc_connection, &rfds);  /* Win32 needs the cast here */
-   if (0 <= select(ipc_connection + 1, &rfds, NULL, NULL, &tv)) {
--    char requ[128];
--    ssize_t s = recv(ipc_connection, (void *)&requ, sizeof(requ), 0);   /* Win32 needs the cast here */
-+    char requ[1024];
-+    ssize_t s = recv(ipc_connection, (void *)&requ, sizeof(requ)-1, 0);   /* Win32 needs the cast here */
-+
-+    if (s == sizeof(requ)-1) {
-+      /* input was too much long, just skip the rest */
-+      char dummy[1024];
-+
-+      while (recv(ipc_connection, (void *)&dummy, sizeof(dummy), 0) == sizeof(dummy), 0);
-+    }
-     if (0 < s) {
-       requ[s] = 0;
-       /* print out the requested tables */
diff --git a/olsrd/patches/004-jsonplugin-http-headers.patch b/olsrd/patches/004-jsonplugin-http-headers.patch
deleted file mode 100644 (file)
index cd76006..0000000
+++ /dev/null
@@ -1,211 +0,0 @@
-commit b342385531c18b8afb42db64c7a38d7879668566
-Author: Alessio Caiazza <nolith@abisso.org>
-Date:   Fri May 16 12:53:15 2014 +0200
-
-    jsoninfo: HTTP headers with CORS (if requested)
-    
-    The new "httpheaders" parameter prepends HTTP headers to the reply.
-    If not set it will default to "no" and have the same behaviour as before.
-    Cross-origin resource sharing headers (CORS) are included in reply allowing the
-    json retrieval by javascript applications not served by olsrd itself.
-    This will allow to easily develop js applications running directly in the
-    browser.
-    
-    Reviewed-by: Ferry Huberts <ferry.huberts@pelagic.nl>
-
-diff --git a/lib/jsoninfo/README_JSONINFO b/lib/jsoninfo/README_JSONINFO
-index 709c975..8311ade 100644
---- a/lib/jsoninfo/README_JSONINFO
-+++ b/lib/jsoninfo/README_JSONINFO
-@@ -73,6 +73,14 @@ LoadPlugin "olsrd_jsoninfo.so.0.0"
-     # if you set it to 0.0.0.0, it will accept all connections
-     #PlParam      "accept" "0.0.0.0"
-+    # The "httpheaders" parameter prepends HTTP headers to the reply.
-+    # If not set it will default to "no" and have the same behaviour as before.
-+    # Among with a minimal set of headers also Cross-origin resource sharing
-+    # headers (CORS) are included in reply allowing the json retrieval by
-+    # javascript applications not served by olsrd itself.
-+    # You can enable it uncommenting the following line:
-+    #PlParam      "httpheaders" "yes"
-+
-     # specify a UUID for this node to track it for debugging
-     #PlParam      "UUIDFile" "/etc/olsrd/olsrd.uuid"
- }
-diff --git a/lib/jsoninfo/src/olsrd_jsoninfo.c b/lib/jsoninfo/src/olsrd_jsoninfo.c
-index 817c64a..f29a37c 100644
---- a/lib/jsoninfo/src/olsrd_jsoninfo.c
-+++ b/lib/jsoninfo/src/olsrd_jsoninfo.c
-@@ -96,6 +96,9 @@
- static int ipc_socket;
-+/* Response types */
-+#define HTTP_200 "HTTP/1.1 200 OK"
-+
- /* IPC initialization function */
- static int plugin_ipc_init(void);
-@@ -126,6 +129,18 @@ static void ipc_print_interfaces(struct autobuf *);
- static void ipc_print_plugins(struct autobuf *);
- static void ipc_print_olsrd_conf(struct autobuf *abuf);
-+static size_t build_http_header(const char *status, const char *mime,
-+  uint32_t msgsize, char *buf, uint32_t bufsize);
-+
-+/*
-+ * this is the size of the buffer used for build_http_header
-+ * the amount of data written into the buffer will be less than
-+ * 400 bytes approximatively.
-+ * The size may vary because the Content-Length header contains
-+ * the length of the json data
-+ */
-+#define MAX_HTTPHEADER_SIZE 512
-+
- #define TXT_IPC_BUFSIZE 256
- /* these provide all of the runtime status info */
-@@ -1282,6 +1297,9 @@ static void
- send_info(unsigned int send_what, int the_socket)
- {
-   struct autobuf abuf;
-+  size_t header_len = 0;
-+  char header_buf[MAX_HTTPHEADER_SIZE];
-+  const char *content_type = "application/json";
-   /* global variables for tracking when to put a comma in for JSON */
-   entrynumber[0] = 0;
-@@ -1320,12 +1338,17 @@ send_info(unsigned int send_what, int the_socket)
-     ipc_print_olsrd_conf(&abuf);
-   }
--  outbuffer[outbuffer_count] = olsr_malloc(abuf.len, "txt output buffer");
--  outbuffer_size[outbuffer_count] = abuf.len;
-+  if(http_headers) {
-+    header_len = build_http_header(HTTP_200, content_type, abuf.len, header_buf, sizeof(header_buf));
-+  }
-+
-+  outbuffer[outbuffer_count] = olsr_malloc(header_len + abuf.len, "json output buffer");
-+  outbuffer_size[outbuffer_count] = header_len + abuf.len;
-   outbuffer_written[outbuffer_count] = 0;
-   outbuffer_socket[outbuffer_count] = the_socket;
--  memcpy(outbuffer[outbuffer_count], abuf.buf, abuf.len);
-+  memcpy(outbuffer[outbuffer_count], header_buf, header_len);
-+  memcpy((outbuffer[outbuffer_count]) + header_len, abuf.buf, abuf.len);
-   outbuffer_count++;
-   if (outbuffer_count == 1) {
-@@ -1340,6 +1363,53 @@ send_info(unsigned int send_what, int the_socket)
-   abuf_free(&abuf);
- }
-+static size_t
-+build_http_header(const char *status, const char *mime, uint32_t msgsize,
-+  char *buf, uint32_t bufsize)
-+{
-+  time_t currtime;
-+  size_t size;
-+
-+  size = snprintf(buf, bufsize, "%s\r\n", status);
-+
-+  /* Date */
-+  time(&currtime);
-+  size += strftime(&buf[size], bufsize - size, "Date: %a, %d %b %Y %H:%M:%S GMT\r\n", localtime(&currtime));
-+
-+  /* Server version */
-+  size += snprintf(&buf[size], bufsize - size, "Server: OLSRD JSONInfo plugin\r\n");
-+
-+  /* connection-type */
-+  size += snprintf(&buf[size], bufsize - size, "Connection: closed\r\n");
-+
-+  /* MIME type */
-+  if(mime != NULL) {
-+    size += snprintf(&buf[size], bufsize - size, "Content-type: %s\r\n", mime);
-+  }
-+
-+  /* CORS data */
-+  /**No needs to be strict here, access control is based on source IP*/
-+  size += snprintf(&buf[size], bufsize - size, "Access-Control-Allow-Origin: *\r\n");
-+  size += snprintf(&buf[size], bufsize - size, "Access-Control-Allow-Methods: GET, POST, OPTIONS\r\n");
-+  size += snprintf(&buf[size], bufsize - size, "Access-Control-Allow-Headers: Accept, Origin, X-Requested-With\r\n");
-+  size += snprintf(&buf[size], bufsize - size, "Access-Control-Max-Age: 1728000\r\n");
-+
-+  /* Content length */
-+  if (msgsize > 0) {
-+    size += snprintf(&buf[size], bufsize - size, "Content-length: %i\r\n", msgsize);
-+  }
-+
-+  /* Cache-control
-+   * No caching dynamic pages
-+   */
-+  size += snprintf(&buf[size], bufsize - size, "Cache-Control: no-cache\r\n");
-+
-+  /* End header */
-+  size += snprintf(&buf[size], bufsize - size, "\r\n");
-+
-+  return size;
-+}
-+
- /*
-  * Local Variables:
-  * mode: c
-diff --git a/lib/jsoninfo/src/olsrd_jsoninfo.h b/lib/jsoninfo/src/olsrd_jsoninfo.h
-index 8478f62..56acb70 100644
---- a/lib/jsoninfo/src/olsrd_jsoninfo.h
-+++ b/lib/jsoninfo/src/olsrd_jsoninfo.h
-@@ -62,6 +62,7 @@ extern union olsr_ip_addr jsoninfo_accept_ip;
- extern union olsr_ip_addr jsoninfo_listen_ip;
- extern int ipc_port;
- extern int nompr;
-+extern bool http_headers;
- int olsrd_plugin_interface_version(void);
- int olsrd_plugin_init(void);
-diff --git a/lib/jsoninfo/src/olsrd_plugin.c b/lib/jsoninfo/src/olsrd_plugin.c
-index 36550a8..03aa45f 100644
---- a/lib/jsoninfo/src/olsrd_plugin.c
-+++ b/lib/jsoninfo/src/olsrd_plugin.c
-@@ -64,6 +64,7 @@ union olsr_ip_addr jsoninfo_accept_ip;
- union olsr_ip_addr jsoninfo_listen_ip;
- int ipc_port;
- int nompr;
-+bool http_headers;
- static void my_init(void) __attribute__ ((constructor));
- static void my_fini(void) __attribute__ ((destructor));
-@@ -79,6 +80,7 @@ my_init(void)
-   /* defaults for parameters */
-   ipc_port = 9090;
-+  http_headers = false;
-   if (olsr_cnf->ip_version == AF_INET) {
-     jsoninfo_accept_ip.v4.s_addr = htonl(INADDR_LOOPBACK);
-     jsoninfo_listen_ip.v4.s_addr = htonl(INADDR_ANY);
-@@ -120,11 +122,26 @@ store_string(const char *value, void *data, set_plugin_parameter_addon addon __a
-   return 0;
- }
-+static int
-+store_boolean(const char *value, void *data, set_plugin_parameter_addon addon __attribute__ ((unused)))
-+{
-+  bool *dest = data;
-+  if(strcmp(value, "yes") == 0)
-+    *dest = true;
-+  else if (strcmp(value, "no") == 0)
-+    *dest = false;
-+  else
-+    return 1; //error
-+
-+  return 0;
-+}
-+
- 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 = &jsoninfo_accept_ip},
-   {.name = "listen",.set_plugin_parameter = &set_plugin_ipaddress,.data = &jsoninfo_listen_ip},
-   {.name = "uuidfile",.set_plugin_parameter = &store_string,.data = uuidfile},
-+  {.name = "httpheaders",.set_plugin_parameter = &store_boolean,.data = &http_headers},
- };
- void