4 @@ -95,6 +95,18 @@ define Package/olsrd-mod-nameservice
5 TITLE:=Lightweight hostname resolver plugin
8 +define Package/olsrd-mod-ondataservice
9 + $(call Package/olsrd/
template)
10 + DEPENDS:=olsrd +libsqlite3 +sqlite3-cli
11 +
TITLE:=Opennet Dataservice SQLite3 plugin
14 +define Package/olsrd-mod-ondataservice_light
15 + $(call Package/olsrd/
template)
17 +
TITLE:=Opennet Dataservice JSON plugin
20 define Package/olsrd-mod-p2pd
21 $(call Package/olsrd/
template)
24 DESTDIR=
"$(PKG_INSTALL_DIR)" \
27 - SUBDIRS=
"arprefresh bmf dot_draw dyn_gw dyn_gw_plain httpinfo jsoninfo mdns nameservice p2pd pgraph pud quagga secure sgwdynspeed txtinfo watchdog"
28 + SUBDIRS=
"arprefresh bmf dot_draw dyn_gw dyn_gw_plain httpinfo jsoninfo mdns nameservice ondataservice ondataservice_light p2pd pgraph pud quagga secure sgwdynspeed txtinfo watchdog"
31 $(call Build/Compile/Default,all)
32 @@ -229,6 +241,16 @@ define Package/olsrd-mod-nameservice/
ins
33 $(INSTALL_BIN) $(PKG_BUILD_DIR)/lib/nameservice/olsrd_nameservice.so.* $(1)/usr/lib/
36 +define Package/olsrd-mod-ondataservice/install
37 + $(INSTALL_DIR) $(1)/usr/lib
38 + $(INSTALL_BIN) $(PKG_BUILD_DIR)/lib/ondataservice/olsrd_ondataservice.so.* $(1)/usr/lib/
41 +define Package/olsrd-mod-ondataservice_light/install
42 + $(INSTALL_DIR) $(1)/usr/lib
43 + $(INSTALL_BIN) $(PKG_BUILD_DIR)/lib/ondataservice_light/olsrd_ondataservice_light.so.* $(1)/usr/lib/
46 define Package/olsrd-mod-p2pd/install
47 $(INSTALL_DIR) $(1)/usr/lib
48 $(INSTALL_BIN) $(PKG_BUILD_DIR)/lib/p2pd/olsrd_p2pd.so.* $(1)/usr/lib/
49 @@ -287,6 +309,8 @@ $(eval $(call BuildPackage,olsrd-mod-htt
50 $(eval $(call BuildPackage,olsrd-mod-jsoninfo))
51 $(eval $(call BuildPackage,olsrd-mod-mdns))
52 $(eval $(call BuildPackage,olsrd-mod-nameservice))
53 +$(eval $(call BuildPackage,olsrd-mod-ondataservice))
54 +$(eval $(call BuildPackage,olsrd-mod-ondataservice_light))
55 $(eval $(call BuildPackage,olsrd-mod-p2pd))
56 $(eval $(call BuildPackage,olsrd-mod-pgraph))
57 $(eval $(call BuildPackage,olsrd-mod-pud))
59 +++ b/routing/olsrd/info.txt
67 +* wir verwenden ein olsrd-Plugin namens ondataservice zur Erfassung von AP-Informationen
68 +* das Plugin funktioniert (nach einem fluechtigen Test) nicht mit olsrd v0.6.6 (segfault innerhalb von Minuten)
69 + * diese Tests fanden auf dem yurika-Server statt
72 +Kurzfristiger Workaround
73 +------------------------
75 +Die Quelle der aktuellen olsrd-Version ist folgender Commit des routing-Repositories:
76 + commit f7dfc4f2a55b39cfb5ef06b075264d05c82761d3
77 + Author: Saverio Proto <zioproto@gmail.com>
78 + Date: Fri Jul 6 00:19:26 2012 +0000
84 +* Test und gegenenfalls Anpassung des ondataservice-Plugin auf eine aktuelle olsrd-Version
85 +* Übertragung des ondataservice-Patches (siehe patches-Verzeichnis im olsrd-Verzeichnis) in das Routing-Repository
86 +* Übertragung des
Makefile-Patches (Makefile_ondataservice.patch) in das meta-Patches-Verzeichnis
88 +Eine Integration des ondataservice-Plugin in den olsrd-Upstream-Code wurde im jahr 2013 kurz auf der Mailingliste erwogen, wird aber wohl nicht stattfinden.
91 +++ b/routing/olsrd/patches/023-ondataservice.
patch
94 +index 8ce6dc5..cf3b410 100644
97 +@@ -197,7 +197,7 @@ rpm:
99 +
# This is quite ugly but at least it works
101 +-SUBDIRS := arprefresh bmf dot_draw dyn_gw dyn_gw_plain httpinfo jsoninfo mdns mini nameservice p2pd pgraph pud quagga secure sgwdynspeed txtinfo watchdog
102 ++SUBDIRS := arprefresh bmf dot_draw dyn_gw dyn_gw_plain httpinfo jsoninfo mdns mini nameservice p2pd pgraph pud quagga secure sgwdynspeed txtinfo watchdog ondataservice ondataservice_light
105 + SUBDIRS := dot_draw httpinfo jsoninfo mini pgraph secure txtinfo
106 +@@ -449,6 +449,29 @@ watchdog_install:
107 + watchdog_uninstall:
108 + $(MAKECMDPREFIX)$(MAKECMD) -C lib/watchdog DESTDIR=$(DESTDIR) uninstall
111 ++ $(MAKECMDPREFIX)$(MAKECMD) -C lib/ondataservice
113 ++ondataservice_clean:
114 ++ $(MAKECMDPREFIX)$(MAKECMD) -C lib/ondataservice clean
116 ++ondataservice_install:
117 ++ $(MAKECMDPREFIX)$(MAKECMD) -C lib/ondataservice DESTDIR=$(DESTDIR) install
119 ++ondataservice_uninstall:
120 ++ $(MAKECMDPREFIX)$(MAKECMD) -C lib/ondataservice DESTDIR=$(DESTDIR) uninstall
122 ++ondataservice_light:
123 ++ $(MAKECMDPREFIX)$(MAKECMD) -C lib/ondataservice_light
125 ++ondataservice_light_clean:
126 ++ $(MAKECMDPREFIX)$(MAKECMD) -C lib/ondataservice_light clean
128 ++ondataservice_light_install:
129 ++ $(MAKECMDPREFIX)$(MAKECMD) -C lib/ondataservice_light DESTDIR=$(DESTDIR) install
131 ++ondataservice_light_uninstall:
132 ++ $(MAKECMDPREFIX)$(MAKECMD) -C lib/ondataservice_light DESTDIR=$(DESTDIR) uninstall
134 + build_all: all
switch libs
135 + install_all: install install_libs
136 +diff --git a/lib/ondataservice/Makefile b/lib/ondataservice/Makefile
137 +
new file mode 100644
138 +index 0000000..951ed28
140 ++++ b/lib/ondataservice/Makefile
142 ++# The olsr.org Optimized Link-State Routing daemon(olsrd)
143 ++# Copyright (
c) 2004, Andreas Tonnesen(andreto@olsr.org)
144 ++# All rights reserved.
146 ++# Redistribution and use in source and binary forms, with or without
147 ++# modification, are permitted provided that the following conditions
150 ++# * Redistributions of source
code must retain the above copyright
151 ++# notice,
this list of conditions and the following disclaimer.
152 ++# * Redistributions in binary form must reproduce the above copyright
153 ++# notice,
this list of conditions and the following disclaimer in
154 ++# the documentation and/or other materials provided with the
156 ++# * Neither the name of olsr.org, olsrd nor the names of its
157 ++# contributors may be used to endorse or promote products derived
158 ++# from
this software without specific prior written permission.
160 ++# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
161 ++#
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
162 ++# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
163 ++# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
164 ++# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
165 ++# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
166 ++# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
167 ++# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
168 ++# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
169 ++# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
170 ++# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
171 ++# POSSIBILITY OF SUCH DAMAGE.
175 ++# If you find
this software useful feel free to make a donation
176 ++# to the project. For more information see the website or contact
177 ++# the copyright holders.
180 ++OLSRD_PLUGIN =
true
181 ++PLUGIN_NAME = olsrd_ondataservice
182 ++# dont change version here
for backward-compatible changes,
183 ++# it will change the library name and won
't load with the
184 ++# olsrd-config already existing on the device
190 ++include $(TOPDIR)/Makefile.inc
193 ++default_target install clean:
194 ++ @echo "**** We use the regex library here. Does Win32 has something like this?"
196 ++ifeq ($(OS),android)
197 ++# On Android Google forgot to include regex engine code for Froyo version (but also there was
198 ++# no support in older versions for it) so we have here this missing code.
199 ++# http://groups.google.com/group/android-ndk/browse_thread/thread/5ea6f0650f0e3fc
200 ++SRCS += $(wildcard $(TOPDIR)/android/regex/reg*.c)
201 ++HDRS += $(wildcard $(TOPDIR)/android/regex/*.h)
202 ++CFLAGS += -D__POSIX_VISIBLE
205 ++default_target: $(PLUGIN_FULLNAME)
207 ++$(PLUGIN_FULLNAME): $(OBJS) version-script.txt
209 ++ @$(CC) $(LDFLAGS) -o $(PLUGIN_FULLNAME) $(OBJS) $(LIBS)
211 ++install: $(PLUGIN_FULLNAME)
212 ++ $(STRIP) $(PLUGIN_FULLNAME)
219 ++ rm -f $(OBJS) $(SRCS:%.c=%.d) $(PLUGIN_FULLNAME)
221 +diff --git a/lib/ondataservice/README_ONDATASERVICE b/lib/ondataservice/README_ONDATASERVICE
222 +new file mode 100644
223 +index 0000000..0aae865
225 ++++ b/lib/ondataservice/README_ONDATASERVICE
227 ++---------------------------------------------------------------------
228 ++ONDATASERVICE PLUGIN FOR OLSRD
229 ++by Rene Ejury <opennet@absorb.it>
230 ++based on and copied from:
231 ++NAMESERVICE PLUGIN FOR OLSRD
232 ++by Bruno Randolf <bruno.randolf@4g-systems.biz>
233 ++---------------------------------------------------------------------
234 ++ full version, can receive data but requires sqlite3-library
236 ++---------------------------------------------------------------------
237 ++PLUGIN PARAMETERS (PlParam)
238 ++---------------------------------------------------------------------
240 ++PlParam "interval" "SEC"
241 ++ interval for sending the DATABASE in seconds.
242 ++ (default: 10800 - 3 hours)
244 ++PlParam "inc_interval" "SEC"
245 ++ interval for continously sending TABLES from DATABASE in seconds.
246 ++ (default: 5 seconds)
248 ++PlParam "cleanup_interval" "SEC"
249 ++ Interval how often DATABASE should be checked for old DATASETS.
250 ++ (default: 1800 - 0.5 hours)
252 ++PlParam "timeout" "SEC"
253 ++ validity time for received NAME messages in seconds.
254 ++ (how long received data stays in the database)
255 ++ (default: 21600 - 6 hours)
257 ++PlParam "vtime" "SEC"
258 ++ validity time for sended message-packages in seconds.
259 ++ (how long this message-data is forwarded through the net)
260 ++ (default: 300 - 5 mins)
262 ++PlParam "database" "/path/to/database"
263 ++ Path to the database
265 ++PlParam "dbcreatescript" "/path/to/dbcreatescript"
266 ++ Path to some executable script to create the database. This will
267 ++ be called anytime the database can't be opened.
268 ++ script will be called with database-path (see PlParam above)
270 ++ (
default not
set, database is not created
if not existent)
272 ++PlParam
"dberrorscript" "/path/to/dberrorscript"
273 ++ Path to some executable script to check
if the database is ok and
274 ++ create the database in
case of error. This will be called anytime
275 ++ some data can
't be written to the database.
276 ++ script will be called with database-path (see PlParam above)
278 ++ (default not set, database is not re-created if there are problems)
280 ++PlParam "receive" "false|true"
281 ++ Set to true if you like to receive and store the values.
282 ++ Otherwise the values from other Nodes are ignored.
283 ++ (default: false - not stored)
285 ++PlParam "spreadall" "false|true"
286 ++ Set to true if you like to spread all data from the database.
287 ++ (default: false - only data for own mainip is spreaded)
289 ++---------------------------------------------------------------------
291 ++---------------------------------------------------------------------
293 ++add in /etc/olsrd.conf:
295 ++LoadPlugin "olsrd_ondataservice.so.0.1"
297 ++ PlParam "interval" "120"
298 ++ PlParam "timeout" "300"
299 ++ PlParam "database" "/tmp/database"
301 +diff --git a/lib/ondataservice/SAMPLE_DBCREATESCRIPT.sh b/lib/ondataservice/SAMPLE_DBCREATESCRIPT.sh
302 +new file mode 100755
303 +index 0000000..22dd4e9
305 ++++ b/lib/ondataservice/SAMPLE_DBCREATESCRIPT.sh
308 ++SQL_STRING="CREATE TABLE nodes
309 ++ (originator text, mainip text, sys_ver text, sys_board text, sys_cpu text, sys_mem int, sys_uptime text,
310 ++ sys_load text, sys_free int, sys_watchdog bool, sys_os_type text,
311 ++ sys_os_name text, sys_os_rel text, sys_os_ver text, sys_os_arc text,
312 ++ sys_os_insttime int, on_core_ver text, on_core_insttime int, on_packages text,
313 ++ on_id text, on_olsrd_status text, on_olsrd_mainip text,
314 ++ on_wifidog_status bool, on_wifidog_id text, on_vpn_cn text, on_vpn_status bool,
315 ++ on_vpn_gw text, on_vpn_autosearch bool, on_vpn_sort text, on_vpn_gws text, on_vpn_blist text,
316 ++ on_ugw_status bool, on_ugw_enabled bool, on_ugw_possible bool, on_ugw_tunnel bool,
317 ++ on_ugw_connected text, on_ugw_presetips text, on_ugw_presetnames text,
318 ++ on_old_autoadapttxpwr text, on_old_remoteconf text,
319 ++ db_time text, db_epoch int, db_ver text, db_update int, CONSTRAINT key_nodes PRIMARY KEY (mainip) ON CONFLICT REPLACE);
321 ++ CREATE TABLE ifaces
322 ++ (originator text, mainip text, if_name text, if_type_bridge text, if_type_bridgedif bool, if_hwaddr text,
323 ++ ip_label text, ip_addr text, ip_broadcast text,
324 ++ on_networks text, on_zones text, on_olsr bool,
325 ++ dhcp_start text, dhcp_limit text, dhcp_leasetime text, dhcp_fwd text,
326 ++ ifstat_collisions int, ifstat_rx_compressed int, ifstat_rx_errors int,
327 ++ ifstat_rx_length_errors int, ifstat_rx_packets int, ifstat_tx_carrier_errors int,
328 ++ ifstat_tx_errors int, ifstat_tx_packets int, ifstat_multicast int,
329 ++ ifstat_rx_crc_errors int, ifstat_rx_fifo_errors int, ifstat_rx_missed_errors int,
330 ++ ifstat_tx_aborted_errors int, ifstat_tx_compressed int, ifstat_tx_fifo_errors int,
331 ++ ifstat_tx_window_errors int, ifstat_rx_bytes int, ifstat_rx_dropped int,
332 ++ ifstat_rx_frame_errors int, ifstat_rx_over_errors int, ifstat_tx_bytes int,
333 ++ ifstat_tx_dropped int, ifstat_tx_heartbeat_errors int,
334 ++ wlan_essid text, wlan_apmac text, wlan_type text, wlan_hwmode text, wlan_mode text,
335 ++ wlan_channel text, wlan_freq text, wlan_txpower text, wlan_signal text, wlan_noise text,
336 ++ wlan_bitrate text, wlan_crypt text, wlan_vaps text,
337 ++ db_ver text, db_update int, CONSTRAINT key_ifaces PRIMARY KEY (mainip, if_name) ON CONFLICT REPLACE);"
339 ++sqlite3 -batch $1 "$SQL_STRING"
341 +diff --git a/lib/ondataservice/SAMPLE_DBERRORSCRIPT.sh b/lib/ondataservice/SAMPLE_DBERRORSCRIPT.sh
342 +new file mode 100755
343 +index 0000000..cd81e77
345 ++++ b/lib/ondataservice/SAMPLE_DBERRORSCRIPT.sh
348 ++SQL_STRING="CREATE TABLE nodes
349 ++ (originator text, mainip text, sys_ver text, sys_board text, sys_cpu text, sys_mem int, sys_uptime text,
350 ++ sys_load text, sys_free int, sys_watchdog bool, sys_os_type text,
351 ++ sys_os_name text, sys_os_rel text, sys_os_ver text, sys_os_arc text,
352 ++ sys_os_insttime int, on_core_ver text, on_core_insttime int, on_packages text,
353 ++ on_id text, on_olsrd_status text, on_olsrd_mainip text,
354 ++ on_wifidog_status bool, on_wifidog_id text, on_vpn_cn text, on_vpn_status bool,
355 ++ on_vpn_gw text, on_vpn_autosearch bool, on_vpn_sort text, on_vpn_gws text, on_vpn_blist text,
356 ++ on_ugw_status bool, on_ugw_enabled bool, on_ugw_possible bool, on_ugw_tunnel bool,
357 ++ on_ugw_connected text, on_ugw_presetips text, on_ugw_presetnames text,
358 ++ on_old_autoadapttxpwr text, on_old_remoteconf text,
359 ++ db_time text, db_epoch int, db_ver text, db_update int, CONSTRAINT key_nodes PRIMARY KEY (mainip) ON CONFLICT REPLACE);
361 ++ CREATE TABLE ifaces
362 ++ (originator text, mainip text, if_name text, if_type_bridge text, if_type_bridgedif bool, if_hwaddr text,
363 ++ ip_label text, ip_addr text, ip_broadcast text,
364 ++ on_networks text, on_zones text, on_olsr bool,
365 ++ dhcp_start text, dhcp_limit text, dhcp_leasetime text, dhcp_fwd text,
366 ++ ifstat_collisions int, ifstat_rx_compressed int, ifstat_rx_errors int,
367 ++ ifstat_rx_length_errors int, ifstat_rx_packets int, ifstat_tx_carrier_errors int,
368 ++ ifstat_tx_errors int, ifstat_tx_packets int, ifstat_multicast int,
369 ++ ifstat_rx_crc_errors int, ifstat_rx_fifo_errors int, ifstat_rx_missed_errors int,
370 ++ ifstat_tx_aborted_errors int, ifstat_tx_compressed int, ifstat_tx_fifo_errors int,
371 ++ ifstat_tx_window_errors int, ifstat_rx_bytes int, ifstat_rx_dropped int,
372 ++ ifstat_rx_frame_errors int, ifstat_rx_over_errors int, ifstat_tx_bytes int,
373 ++ ifstat_tx_dropped int, ifstat_tx_heartbeat_errors int,
374 ++ wlan_essid text, wlan_apmac text, wlan_type text, wlan_hwmode text, wlan_mode text,
375 ++ wlan_channel text, wlan_freq text, wlan_txpower text, wlan_signal text, wlan_noise text,
376 ++ wlan_bitrate text, wlan_crypt text, wlan_vaps text,
377 ++ db_ver text, db_update int, CONSTRAINT key_ifaces PRIMARY KEY (mainip, if_name) ON CONFLICT REPLACE);"
379 ++ifaces_columns=$(sqlite3 /tmp/ondatabase.sqlite "PRAGMA table_info(ifaces);" | wc -l)
380 ++nodes_columns=$(sqlite3 /tmp/ondatabase.sqlite "PRAGMA table_info(nodes);" | wc -l)
382 ++if [ "$ifaces_columns" != "54" ] || [ "$nodes_columns" != "44" ]; then
383 ++ sqlite3 -batch $1 "$SQL_STRING"
386 +diff --git a/lib/ondataservice/src/compat.c b/lib/ondataservice/src/compat.c
387 +new file mode 100644
388 +index 0000000..4d639be
390 ++++ b/lib/ondataservice/src/compat.c
392 ++#include "compat.h"
394 ++#if !defined(__linux__) && !defined(__GLIBC__)
395 ++#include <stdlib.h>
396 ++#include <string.h>
398 ++/* strndup() is a GNU extention */
400 ++strndup(const char *ptr, size_t size)
402 ++ size_t len = strlen(ptr);
408 ++ ret = malloc(len + 1);
413 ++ memcpy(ret, ptr, len);
422 ++ * Local Variables:
423 ++ * c-basic-offset: 2
424 ++ * indent-tabs-mode: nil
427 +diff --git a/lib/ondataservice/src/compat.h b/lib/ondataservice/src/compat.h
428 +new file mode 100644
429 +index 0000000..c607c91
431 ++++ b/lib/ondataservice/src/compat.h
433 ++#ifndef _NAMESERVICE_COMPAT
434 ++#define _NAMESERVICE_COMPAT
436 ++#include <sys/types.h>
438 ++#if !defined(__linux__) && !defined(__GLIBC__)
439 ++char *strndup(const char *ptr, size_t size);
445 ++ * Local Variables:
446 ++ * c-basic-offset: 2
447 ++ * indent-tabs-mode: nil
450 +diff --git a/lib/ondataservice/src/crc16.c b/lib/ondataservice/src/crc16.c
451 +new file mode 100644
452 +index 0000000..dc877ca
454 ++++ b/lib/ondataservice/src/crc16.c
456 ++#include <stdlib.h>
459 ++// ------------ http://stackoverflow.com/questions/3853670/are-there-any-free-crc-libraries-that-covers-a-lot-of-the-crc-algorithms
461 ++/******************************************/
462 ++/* CRC table for polynomial 0xA001 CCITT */
463 ++/******************************************/
465 ++#define CRC16(crc,c) crc = (crc >> 8) ^ crctab[(crc ^ c) & 0xff]
467 ++const u_int16_t crctab[256] = {
468 ++ 0x0000, 0xc0c1, 0xc181, 0x0140, 0xc301, 0x03c0, 0x0280, 0xc241,
469 ++ 0xc601, 0x06c0, 0x0780, 0xc741, 0x0500, 0xc5c1, 0xc481, 0x0440,
470 ++ 0xcc01, 0x0cc0, 0x0d80, 0xcd41, 0x0f00, 0xcfc1, 0xce81, 0x0e40,
471 ++ 0x0a00, 0xcac1, 0xcb81, 0x0b40, 0xc901, 0x09c0, 0x0880, 0xc841,
472 ++ 0xd801, 0x18c0, 0x1980, 0xd941, 0x1b00, 0xdbc1, 0xda81, 0x1a40,
473 ++ 0x1e00, 0xdec1, 0xdf81, 0x1f40, 0xdd01, 0x1dc0, 0x1c80, 0xdc41,
474 ++ 0x1400, 0xd4c1, 0xd581, 0x1540, 0xd701, 0x17c0, 0x1680, 0xd641,
475 ++ 0xd201, 0x12c0, 0x1380, 0xd341, 0x1100, 0xd1c1, 0xd081, 0x1040,
476 ++ 0xf001, 0x30c0, 0x3180, 0xf141, 0x3300, 0xf3c1, 0xf281, 0x3240,
477 ++ 0x3600, 0xf6c1, 0xf781, 0x3740, 0xf501, 0x35c0, 0x3480, 0xf441,
478 ++ 0x3c00, 0xfcc1, 0xfd81, 0x3d40, 0xff01, 0x3fc0, 0x3e80, 0xfe41,
479 ++ 0xfa01, 0x3ac0, 0x3b80, 0xfb41, 0x3900, 0xf9c1, 0xf881, 0x3840,
480 ++ 0x2800, 0xe8c1, 0xe981, 0x2940, 0xeb01, 0x2bc0, 0x2a80, 0xea41,
481 ++ 0xee01, 0x2ec0, 0x2f80, 0xef41, 0x2d00, 0xedc1, 0xec81, 0x2c40,
482 ++ 0xe401, 0x24c0, 0x2580, 0xe541, 0x2700, 0xe7c1, 0xe681, 0x2640,
483 ++ 0x2200, 0xe2c1, 0xe381, 0x2340, 0xe101, 0x21c0, 0x2080, 0xe041,
484 ++ 0xa001, 0x60c0, 0x6180, 0xa141, 0x6300, 0xa3c1, 0xa281, 0x6240,
485 ++ 0x6600, 0xa6c1, 0xa781, 0x6740, 0xa501, 0x65c0, 0x6480, 0xa441,
486 ++ 0x6c00, 0xacc1, 0xad81, 0x6d40, 0xaf01, 0x6fc0, 0x6e80, 0xae41,
487 ++ 0xaa01, 0x6ac0, 0x6b80, 0xab41, 0x6900, 0xa9c1, 0xa881, 0x6840,
488 ++ 0x7800, 0xb8c1, 0xb981, 0x7940, 0xbb01, 0x7bc0, 0x7a80, 0xba41,
489 ++ 0xbe01, 0x7ec0, 0x7f80, 0xbf41, 0x7d00, 0xbdc1, 0xbc81, 0x7c40,
490 ++ 0xb401, 0x74c0, 0x7580, 0xb541, 0x7700, 0xb7c1, 0xb681, 0x7640,
491 ++ 0x7200, 0xb2c1, 0xb381, 0x7340, 0xb101, 0x71c0, 0x7080, 0xb041,
492 ++ 0x5000, 0x90c1, 0x9181, 0x5140, 0x9301, 0x53c0, 0x5280, 0x9241,
493 ++ 0x9601, 0x56c0, 0x5780, 0x9741, 0x5500, 0x95c1, 0x9481, 0x5440,
494 ++ 0x9c01, 0x5cc0, 0x5d80, 0x9d41, 0x5f00, 0x9fc1, 0x9e81, 0x5e40,
495 ++ 0x5a00, 0x9ac1, 0x9b81, 0x5b40, 0x9901, 0x59c0, 0x5880, 0x9841,
496 ++ 0x8801, 0x48c0, 0x4980, 0x8941, 0x4b00, 0x8bc1, 0x8a81, 0x4a40,
497 ++ 0x4e00, 0x8ec1, 0x8f81, 0x4f40, 0x8d01, 0x4dc0, 0x4c80, 0x8c41,
498 ++ 0x4400, 0x84c1, 0x8581, 0x4540, 0x8701, 0x47c0, 0x4680, 0x8641,
499 ++ 0x8201, 0x42c0, 0x4380, 0x8341, 0x4100, 0x81c1, 0x8081, 0x4040
502 ++//=========================================================================
503 ++// Description: Calculate a CRC on a buffer
504 ++// Parameters: buffer - address of buffer
505 ++// length - length of buffer
507 ++//=========================================================================
508 ++u_int16_t crcCalculate(char *buffer, unsigned int length)
510 ++ u_int16_t Crc = 0;
512 ++ for (; length; --length) {
513 ++ CRC16(Crc, *buffer++);
518 +diff --git a/lib/ondataservice/src/crc16.h b/lib/ondataservice/src/crc16.h
519 +new file mode 100644
520 +index 0000000..729d784
522 ++++ b/lib/ondataservice/src/crc16.h
525 ++// copied from http://stackoverflow.com/questions/3853670/are-there-any-free-crc-libraries-that-covers-a-lot-of-the-crc-algorithms
528 ++u_int16_t crcCalculate(char *buffer, unsigned int length);
530 +diff --git a/lib/ondataservice/src/olsrd_plugin.c b/lib/ondataservice/src/olsrd_plugin.c
531 +new file mode 100644
532 +index 0000000..c6989c5
534 ++++ b/lib/ondataservice/src/olsrd_plugin.c
538 ++ * Copyright (c) 2005, Bruno Randolf <bruno.randolf@4g-systems.biz>
539 ++ * Copyright (c) 2004, Andreas Tonnesen(andreto-at-olsr.org)
540 ++ * All rights reserved.
542 ++ * Redistribution and use in source and binary forms, with or without
543 ++ * modification, are permitted provided that the following conditions
546 ++ * * Redistributions of source code must retain the above copyright notice,
547 ++ * this list of conditions and the following disclaimer.
548 ++ * * Redistributions in binary form must reproduce the above copyright notice,
549 ++ * this list of conditions and the following disclaimer in the documentation
550 ++ * and/or other materials provided with the distribution.
551 ++ * * Neither the name of the UniK olsr daemon nor the names of its contributors
552 ++ * may be used to endorse or promote products derived from this software
553 ++ * without specific prior written permission.
555 ++ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
556 ++ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
557 ++ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
558 ++ * IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
559 ++ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
560 ++ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
561 ++ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
562 ++ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
563 ++ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
564 ++ * OF THE POSSIBILITY OF SUCH DAMAGE.
569 ++ * Dynamic linked library for olsr.org olsrd
573 ++#include <string.h>
575 ++#include "olsrd_plugin.h"
576 ++#include "ondataservice.h"
578 ++#define MOD_DESC PLUGIN_NAME " " PLUGIN_VERSION
579 ++#define PLUGIN_INTERFACE_VERSION 5
581 ++static void __attribute__ ((constructor)) my_init(void);
583 ++static void __attribute__ ((destructor)) my_fini(void);
586 ++olsrd_plugin_interface_version(void)
588 ++ return PLUGIN_INTERFACE_VERSION;
592 ++olsrd_plugin_init(void)
594 ++ return ondata_init();
600 ++ /* Print plugin info to stdout */
601 ++ printf("%s\n", MOD_DESC);
603 ++ ondata_constructor();
611 ++ ondata_destructor();
615 ++ * Local Variables:
616 ++ * c-basic-offset: 2
617 ++ * indent-tabs-mode: nil
620 +diff --git a/lib/ondataservice/src/ondataservice.c b/lib/ondataservice/src/ondataservice.c
621 +new file mode 100644
622 +index 0000000..c1e1076
624 ++++ b/lib/ondataservice/src/ondataservice.c
628 ++ * Copyright (c) 2011, Rene Ejury <opennet@absorb.it>
629 ++ * Copyright (c) 2006, Jens Nachtigall <nachtigall@web.de>
630 ++ * Copyright (c) 2005, Bruno Randolf <bruno.randolf@4g-systems.biz>
631 ++ * Copyright (c) 2004, Andreas Tonnesen(andreto-at-olsr.org)
632 ++ * Copyright (c) 2007, Sven-Ola <sven-ola@gmx.de>
633 ++ * All rights reserved.
635 ++ * Redistribution and use in source and binary forms, with or without
636 ++ * modification, are permitted provided that the following conditions
639 ++ * * Redistributions of source code must retain the above copyright notice,
640 ++ * this list of conditions and the following disclaimer.
641 ++ * * Redistributions in binary form must reproduce the above copyright notice,
642 ++ * this list of conditions and the following disclaimer in the documentation
643 ++ * and/or other materials provided with the distribution.
644 ++ * * Neither the name of the UniK olsr daemon nor the names of its contributors
645 ++ * may be used to endorse or promote products derived from this software
646 ++ * without specific prior written permission.
648 ++ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
649 ++ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
650 ++ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
651 ++ * IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
652 ++ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
653 ++ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
654 ++ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
655 ++ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
656 ++ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
657 ++ * OF THE POSSIBILITY OF SUCH DAMAGE.
662 ++ * Dynamic linked library for UniK OLSRd
665 ++#define _GNU_SOURCE 1
668 ++#include <string.h>
669 ++#include <stdlib.h>
670 ++#include <unistd.h>
672 ++#include <sys/types.h>
673 ++#include <sys/stat.h>
674 ++#include <signal.h>
677 ++#include <sqlite3.h>
680 ++#include "net_olsr.h"
681 ++#include "parser.h"
683 ++#include "plugin_util.h"
684 ++#include "ondataservice.h"
685 ++#include "compat.h"
688 ++const char *DATABASE_TABLES[2] = {"nodes", "ifaces"};
689 ++const int unsigned numberOfTables = 2;
691 ++/* config parameters */
692 ++static int my_interval = EMISSION_INTERVAL;
693 ++static int my_inc_interval = EMISSION_INC_INTERVAL;
694 ++static int my_cleanup_interval = CLEANUP_INTERVAL; // how often database will be cleaned of outdated data
695 ++static int my_timeout = ONDATA_TIMEOUT; // how long the data stays valid
696 ++static int my_vtime = ONDATA_VALID_TIME; // how long the data will be spread trough the net
697 ++static char my_database[MAX_FILE + 1];
698 ++static char my_dbcreatescript[MAX_FILE + 1];
699 ++static char my_dberrorscript[MAX_FILE + 1];
700 ++static bool my_receive = false;
701 ++static bool my_spreadall = false;
703 ++/* periodic message generation */
704 ++struct timer_entry *msg_gen_timer = NULL;
705 ++struct timer_entry *db_cleanup_timer = NULL;
708 ++ * do initialization
711 ++ondata_constructor(void)
716 ++ GetWindowsDirectory(my_database, MAX_FILE - 12);
718 ++ len = strlen(my_database);
719 ++ if (my_database[len - 1] != '\\
')
720 ++ strscat(my_database, "\\", sizeof(my_database));
721 ++ strscat(my_database, DATABASE_FILE, sizeof(my_database));
723 ++ GetWindowsDirectory(my_dbcreatescript, MAX_FILE - 12);
725 ++ len = strlen(my_dbcreatescript);
726 ++ if (my_dbcreatescript[len - 1] != '\\
')
727 ++ strscat(my_dbcreatescript, "\\", sizeof(my_dbcreatescript));
728 ++ strscat(my_dbcreatescript, "", sizeof(my_dbcreatescript));
730 ++ strscpy(my_database, DATABASE_FILE, sizeof(my_database));
731 ++ strscpy(my_dbcreatescript, "", sizeof(my_dbcreatescript));
738 ++static const struct olsrd_plugin_parameters plugin_parameters[] = {
739 ++ { .name = "interval", .set_plugin_parameter = &set_plugin_int, .data = &my_interval },
740 ++ { .name = "inc_interval", .set_plugin_parameter = &set_plugin_int, .data = &my_inc_interval },
741 ++ { .name = "cleanup_interval", .set_plugin_parameter = &set_plugin_int, .data = &my_cleanup_interval },
742 ++ { .name = "timeout", .set_plugin_parameter = &set_plugin_int, .data = &my_timeout },
743 ++ { .name = "database", .set_plugin_parameter = &set_plugin_string, .data = &my_database, .addon = {sizeof(my_database)} },
744 ++ { .name = "dbcreatescript", .set_plugin_parameter = &set_plugin_string, .data = &my_dbcreatescript, .addon = {sizeof(my_dbcreatescript)} },
745 ++ { .name = "dberrorscript", .set_plugin_parameter = &set_plugin_string, .data = &my_dberrorscript, .addon = {sizeof(my_dberrorscript)} },
746 ++ { .name = "receive", .set_plugin_parameter = &set_plugin_boolean, .data = &my_receive },
747 ++ { .name = "spreadall", .set_plugin_parameter = &set_plugin_boolean, .data = &my_spreadall },
748 ++ { .name = "vtime", .set_plugin_parameter = &set_plugin_int, .data = &my_vtime },
753 ++olsrd_get_plugin_parameters(const struct olsrd_plugin_parameters **params, int *size)
755 ++ *params = plugin_parameters;
756 ++ *size = sizeof(plugin_parameters) / sizeof(*plugin_parameters);
760 ++ * last initialization
762 ++ * we have to do this here because some things like main_addr
763 ++ * or the dns suffix (for validation) are not known before
765 ++ * this is beause of the order in which the plugin is initialized
766 ++ * by the plugin loader:
767 ++ * - first the parameters are sent
768 ++ * - then register_olsr_data() from olsrd_plugin.c is called
769 ++ * which sets up main_addr and some other variables
770 ++ * - register_olsr_data() then then finally calls this function
775 ++ /* register functions with olsrd */
776 ++ if (my_receive) olsr_parser_add_function(&olsr_parser, PARSER_TYPE);
778 ++ /* periodic message generation */
779 ++ msg_gen_timer = olsr_start_timer(my_interval * MSEC_PER_SEC, EMISSION_JITTER, OLSR_TIMER_PERIODIC, &olsr_ondatasvc_gen, NULL, 0);
781 ++ /* periodic database cleanup generation */
782 ++ if (my_receive) db_cleanup_timer = olsr_start_timer(my_cleanup_interval * MSEC_PER_SEC, EMISSION_JITTER, OLSR_TIMER_PERIODIC, &olsr_ondataservice_expire_db_timer, NULL, 0);
788 ++ * called at unload: free everything
790 ++ * XXX: should I delete the hosts/services/resolv.conf files on exit?
793 ++ondata_destructor(void)
795 ++ olsr_stop_timer(msg_gen_timer);
797 ++ if (my_receive) olsr_stop_timer(db_cleanup_timer);
801 ++open_database(sqlite3 **localdb)
803 ++ int unsigned rc = sqlite3_open_v2(my_database, localdb, SQLITE_OPEN_READWRITE, NULL);
804 ++ if(rc != SQLITE_OK && strlen(my_dbcreatescript) != 0){
806 ++ fprintf(stderr, "Can't open database, trying to (re)create database: %s\n
", my_dbcreatescript);
807 ++ asprintf(&buf,"%
s %
s", my_dbcreatescript, my_database);
810 ++ rc = sqlite3_open_v2(my_database, localdb, SQLITE_OPEN_READWRITE, NULL);
812 ++ if(rc != SQLITE_OK && strlen(my_dberrorscript) != 0){
814 ++ fprintf(stderr, "Can
't open database, running database-error script: %s\n", my_dberrorscript);
815 ++ asprintf(&buf,"%s %s", my_dberrorscript, my_database);
818 ++ rc = sqlite3_open_v2(my_database, localdb, SQLITE_OPEN_READWRITE, NULL);
825 ++ * wrapper for sqlite3_prepare_v2, calls error handle script on error
828 ++local_sqlite3_prepare_v2(
829 ++ sqlite3 *db, /* Database handle */
830 ++ const char *zSql, /* SQL statement, UTF-8 encoded */
831 ++ int nByte, /* Maximum length of zSql in bytes. */
832 ++ sqlite3_stmt **ppStmt, /* OUT: Statement handle */
833 ++ const char **pzTail /* OUT: Pointer to unused portion of zSql */
837 ++ rc = sqlite3_prepare_v2(db, zSql, nByte, ppStmt, pzTail);
838 ++ if(rc != SQLITE_OK && strlen(my_dberrorscript) != 0){
840 ++ fprintf(stderr, "running database-error script: %s\n", my_dberrorscript);
841 ++ asprintf(&buf,"%s %s", my_dberrorscript, my_database);
844 ++ rc = sqlite3_prepare_v2(db, zSql, nByte, ppStmt, pzTail);
850 ++ * Callback for the db validity timer.
853 ++olsr_ondataservice_expire_db_timer(void *foo __attribute__ ((unused)))
856 ++ sqlite3_stmt *localppStmt;
858 ++ const char *pzTail; /* OUT of sqlite3_prepare_v2: Pointer to unused portion of zSql */
859 ++ const char *SQLframe = "DELETE FROM %s WHERE (originator != '' AND mainip != '%
s' AND db_update < %lu );";
860 ++ struct ipaddr_str main_addr;
861 ++ const char *mainip;
862 ++ int unsigned currentTable = 0, rc;
863 ++ long unsigned min_update_time;
865 ++ min_update_time = time(NULL) - my_timeout;
866 ++ mainip = olsr_ip_to_string(&main_addr, &olsr_cnf->main_addr);
868 ++ rc = open_database(&localdb);
869 ++ if( rc == SQLITE_OK ){
870 ++ while (currentTable < numberOfTables) {
872 ++ // build Database statement / assumption that time will not be bigger than 20chars long
873 ++ localzSql = olsr_malloc(strlen(SQLframe) + strlen(mainip) + strlen(DATABASE_TABLES[currentTable]) + 20 + 1, "update_ondata_entry: space for SQL query");
874 ++ sprintf(localzSql, SQLframe, DATABASE_TABLES[currentTable], mainip, min_update_time);
876 ++ // apply statement to database
877 ++ // use 1500 as max MTU and therefore as max SQL size (which is not quite accurate)
878 ++ rc = local_sqlite3_prepare_v2(localdb, localzSql, 1500, &localppStmt, &pzTail);
879 ++ if( rc == SQLITE_OK ){
880 ++ sqlite3_step(localppStmt);
881 ++ sqlite3_finalize(localppStmt);
882 ++ OLSR_PRINTF(5, "ONDATA PLUGIN: Database cleaned: %s\n", localzSql);
884 ++ else fprintf(stderr, "SQL error: %s\n", sqlite3_errmsg(localdb));
889 ++ else fprintf(stderr, "Can't open database: %s\n
", sqlite3_errmsg(localdb));
891 ++ sqlite3_close(localdb);
895 ++ * Scheduled event: generate and send ONDATA packet
898 ++olsr_ondatasvc_gen(void *foo __attribute__ ((unused)))
900 ++ /* send buffer: huge */
901 ++ char buffer[10240];
902 ++ union olsr_message *message = (union olsr_message *)buffer;
903 ++ struct interface *ifn;
906 ++ /* fill message */
907 ++ if (olsr_cnf->ip_version == AF_INET) {
909 ++ message->v4.olsr_msgtype = MESSAGE_TYPE;
910 ++ message->v4.olsr_vtime = reltime_to_me((double)my_vtime * MSEC_PER_SEC);
911 ++ memcpy(&message->v4.originator, &olsr_cnf->main_addr, olsr_cnf->ipsize);
912 ++ message->v4.ttl = MAX_TTL;
913 ++ message->v4.hopcnt = 0;
914 ++ message->v4.seqno = htons(get_msg_seqno());
916 ++ ondatasize = encap_ondatamsg((struct ondatamsg *)ARM_NOWARN_ALIGN(&message->v4.message));
917 ++ if (!ondatasize) return;
918 ++ ondatasize = ondatasize + sizeof(struct olsrmsg);
919 ++ message->v4.olsr_msgsize = htons(ondatasize);
922 ++ message->v6.olsr_msgtype = MESSAGE_TYPE;
923 ++ message->v6.olsr_vtime = reltime_to_me((double)my_vtime * MSEC_PER_SEC);
924 ++ memcpy(&message->v6.originator, &olsr_cnf->main_addr, olsr_cnf->ipsize);
925 ++ message->v6.ttl = MAX_TTL;
926 ++ message->v6.hopcnt = 0;
927 ++ message->v6.seqno = htons(get_msg_seqno());
929 ++ ondatasize = encap_ondatamsg((struct ondatamsg *)ARM_NOWARN_ALIGN(&message->v6.message));
930 ++ if (!ondatasize) return;
931 ++ ondatasize = ondatasize + sizeof(struct olsrmsg6);
933 ++ message->v6.olsr_msgsize = htons(ondatasize);
936 ++ /* looping trough interfaces */
937 ++ for (ifn = ifnet; ifn; ifn = ifn->int_next) {
938 ++ OLSR_PRINTF(3, "ONDATA PLUGIN: Generating packet - [%
s]\n
", ifn->int_name);
940 ++ if (net_outbuffer_push(ifn, message, ondatasize) != ondatasize) {
941 ++ /* send data and try again */
943 ++ if (net_outbuffer_push(ifn, message, ondatasize) != ondatasize) {
944 ++ OLSR_PRINTF(1, "ONDATA PLUGIN: could not send on interface: %s\n
", ifn->int_name);
951 ++ * Parse ondata olsr message of ONDATA type
954 ++olsr_parser(union olsr_message *m, struct interface *in_if __attribute__ ((unused)), union olsr_ip_addr *ipaddr __attribute__ ((unused)))
956 ++ struct ondatamsg *ondatamessage;
957 ++ union olsr_ip_addr originator;
960 ++ /* Fetch the originator of the messsage */
961 ++ if (olsr_cnf->ip_version == AF_INET) {
962 ++ memcpy(&originator, &m->v4.originator, olsr_cnf->ipsize);
964 ++ memcpy(&originator, &m->v6.originator, olsr_cnf->ipsize);
967 ++ /* Fetch the message based on IP version */
968 ++ if (olsr_cnf->ip_version == AF_INET) {
969 ++ size = ntohs(m->v4.olsr_msgsize);
970 ++ ondatamessage = (struct ondatamsg *)ARM_NOWARN_ALIGN(&m->v4.message);
972 ++ size = ntohs(m->v6.olsr_msgsize);
973 ++ ondatamessage = (struct ondatamsg *)ARM_NOWARN_ALIGN(&m->v6.message);
976 ++ /* Check if message originated from this node.
977 ++ If so - back off */
978 ++ if (ipequal(&originator, &olsr_cnf->main_addr))
981 ++ update_ondata_entry(&originator, ondatamessage, size);
982 ++ /* Forward the message */
986 ++// Database Variables / should be kept over different calls, therefore global
988 ++sqlite3_stmt *ppStmt;
991 ++int unsigned currentTable = 0;
993 ++bool table_open = 0;
996 ++ * Encapsulate a ondata message into a packet.
998 ++ * It assumed that there is enough space in the buffer to do this!
1000 ++ * Returns: the length of the message that was appended
1003 ++encap_ondatamsg(struct ondatamsg *msg)
1005 ++ const char *pzTail; /* OUT of sqlite3_prepare_v2: Pointer to unused portion of zSql */
1006 ++ const char *SQLframe = "SELECT * FROM %
s WHERE mainip =
'%s';
";
1007 ++ const char *SQLframeSpreadAll = "SELECT * FROM %
s WHERE originator =
'';
";
1009 ++ struct ipaddr_str main_addr;
1010 ++ const char *mainip;
1013 ++ uint16_t checksum;
1014 ++ uint16_t messageLength = 0;
1016 ++ // open Database if this not a 'continued Transmission - and Database is already open'
1017 ++ mainip = olsr_ip_to_string(&main_addr, &olsr_cnf->main_addr);
1020 ++ OLSR_PRINTF(5, "ONDATA PLUGIN: opening database\n
");
1022 ++ currentTable = 0;
1023 ++ rc = open_database(&db);
1025 ++ if( rc == SQLITE_OK) db_open = 1;
1027 ++ fprintf(stderr, "Can
't open database: %s\n", sqlite3_errmsg(db));
1028 ++ sqlite3_close(db); return 0;
1032 ++ // if there is no Data available, search next Table with Data
1033 ++ if (!table_open) {
1034 ++ while (currentTable < numberOfTables) {
1035 ++ OLSR_PRINTF(5, "ONDATA PLUGIN: using next table %s\n", DATABASE_TABLES[currentTable]);
1036 ++ // build SQL-query
1037 ++ if (!my_spreadall) {
1038 ++ zSql = olsr_malloc(strlen(SQLframe) + strlen(DATABASE_TABLES[currentTable]) + strlen(mainip) + 1, "encap_ondatamsg: space for SQL query");
1039 ++ sprintf(zSql, SQLframe, DATABASE_TABLES[currentTable], mainip);
1042 ++ zSql = olsr_malloc(strlen(SQLframeSpreadAll) + strlen(DATABASE_TABLES[currentTable])+ 1, "encap_ondatamsg: space for SQL query");
1043 ++ sprintf(zSql, SQLframeSpreadAll, DATABASE_TABLES[currentTable]);
1046 ++ rc = local_sqlite3_prepare_v2(db, zSql, 100, &ppStmt, &pzTail);
1047 ++ if( rc == SQLITE_OK) {
1052 ++ fprintf(stderr, "SQL error: %s\n", sqlite3_errmsg(db));
1059 ++ // if still no valid table found, give up
1060 ++ if (!table_open) {
1061 ++ OLSR_PRINTF(5, "ONDATA PLUGIN: no further table found\n");
1062 ++ sqlite3_close(db);
1064 ++ // reset timer to normal interval
1065 ++ olsr_change_timer(msg_gen_timer, my_interval * MSEC_PER_SEC, EMISSION_JITTER, OLSR_TIMER_PERIODIC);
1069 ++ // add all datasets
1070 ++ if (sqlite3_step(ppStmt) == SQLITE_ROW) {
1071 ++ OLSR_PRINTF(5, "ONDATA PLUGIN: adding all datasets\n");
1072 ++ // add all the entries after the ondatamsg header (and keep space for it)
1073 ++ pos = (char *)msg + sizeof(struct ondatamsg);
1075 ++ // always add the Table-Name as first field
1076 ++ pos = create_packet((struct ondata *)ARM_NOWARN_ALIGN(pos), DATABASE_TABLES[currentTable]);
1078 ++ // never transmit originator (col=0), this will be detected at the other end_pos
1079 ++ // skip last column, it will set at destination to the receiving-time
1081 ++ while (iCol < sqlite3_column_count(ppStmt) - 1) {
1082 ++ pos = create_packet((struct ondata *)ARM_NOWARN_ALIGN(pos), (const char *)sqlite3_column_text(ppStmt, iCol));
1085 ++ // write the ondatamsg header with the number of announced entries and the protocol version
1086 ++ msg->nr_datasets = htons(--iCol); // it won't count the
table-name as dataset (and neither mainip-Col)
1087 ++ msg->version = htons(ONDATA_PROTOCOL_VERSION);
1088 ++ messageLength = pos - (
char *)msg;
1089 ++ msg->length = htons(messageLength);
1090 ++ checksum = crcCalculate((
char *)msg +
sizeof(uint16_t), messageLength -
sizeof(uint16_t));
1091 ++ msg->checksum = htons(checksum);
1093 ++ OLSR_PRINTF(3,
"ONDATA PLUGIN: ##### finished creating packet, length=%d, crc16=0x%x\n", messageLength, checksum);
1096 ++ OLSR_PRINTF(5,
"ONDATA PLUGIN: finalize query\n");
1097 ++ sqlite3_finalize(ppStmt);
1104 ++ olsr_change_timer(msg_gen_timer, 1 * MSEC_PER_SEC, EMISSION_JITTER, OLSR_TIMER_PERIODIC);
1105 ++
return messageLength;
1115 ++create_packet(
struct ondata *to,
const char *value )
1117 ++
char *pos = (
char *)to;
int valuelen = strlen((
const char*)value);
1119 ++ to->valuelen = htons(valuelen);
1120 ++ OLSR_PRINTF(5,
"ONDATA PLUGIN: Announcing value %s %d\n", value, valuelen);
1121 ++ pos +=
sizeof(
struct ondata);
1122 ++ memcpy(pos, value, valuelen);
1125 ++
for (k =
sizeof(
struct ondata) + valuelen; (k & 3) != 0; k++)
1136 ++update_ondata_entry(
union olsr_ip_addr *originator,
struct ondatamsg *msg,
int msg_size)
1138 ++
struct ipaddr_str strbuf;
1139 ++
char *pos, *end_pos, *values, *valuepos, *
table;
1140 ++
const char *originatorIP;
1141 ++
struct ondata *from_packet;
1143 ++ uint16_t checksum;
1144 ++ sqlite3 *localdb;
1145 ++ sqlite3_stmt *localppStmt;
1147 ++
const char *SQLframe =
"INSERT OR REPLACE INTO %s VALUES (%s);", *pzTail;
1150 ++ originatorIP = olsr_ip_to_string(&strbuf, originator);
1151 ++ OLSR_PRINTF(3,
"ONDATA PLUGIN: Received Message from %s, version %d, msg_size %d, checksum 0x%x\n", originatorIP, ntohs(msg->version), ntohs(msg->length), ntohs(msg->checksum));
1153 ++
if (ntohs(msg->version) != ONDATA_PROTOCOL_VERSION) {
1154 ++ OLSR_PRINTF(3,
"ONDATA PLUGIN: ignoring wrong version %d\n", ntohs(msg->version));
1159 ++ checksum = crcCalculate((
char *)msg +
sizeof(uint16_t), ntohs(msg->length) -
sizeof(uint16_t));
1160 ++
if (ntohs(msg->checksum) != checksum) {
1161 ++ OLSR_PRINTF(3,
"ONDATA PLUGIN: ignoring checksum error 0x%x\n", checksum);
1164 ++
else OLSR_PRINTF(5,
"ONDATA PLUGIN: validated checksum 0x%x\n", checksum);
1169 ++ values = olsr_malloc(strlen(originatorIP) + 1 + ntohs(msg->length) + msg->nr_datasets*3,
"update_ondata_entry: space for SQL values");
1170 ++ valuepos = values;
1176 ++ pos = (
char *)msg +
sizeof(
struct ondatamsg);
1177 ++ end_pos = pos + msg_size -
sizeof(
struct ondata *);
1180 ++ from_packet = (
struct ondata *)ARM_NOWARN_ALIGN(pos);
1181 ++ table = olsr_malloc(ntohs(from_packet->valuelen) + 1,
"update_ondata_entry: space for Table Name");
1183 ++ memcpy(table, (
char *)from_packet +
sizeof(
struct ondata), ntohs(from_packet->valuelen));
1184 ++ *(table + ntohs(from_packet->valuelen)) =
'\0';
1187 ++ pos += ((
sizeof(
struct ondata) + ntohs(from_packet->valuelen) - 1) | 3) + 1;
1190 ++ memcpy(valuepos++,
"'", 1);
1191 ++ memcpy(valuepos, originatorIP, strlen(originatorIP));
1192 ++ valuepos += strlen(originatorIP);
1193 ++ memcpy(valuepos,
"',", 2);
1196 ++
for (i = ntohs(msg->nr_datasets); i > 0 && pos < end_pos; i--) {
1197 ++ from_packet = (
struct ondata *)ARM_NOWARN_ALIGN(pos);
1199 ++ memcpy(valuepos++,
"'", 1);
1200 ++ memcpy(valuepos, (
char *)from_packet +
sizeof(
struct ondata), ntohs(from_packet->valuelen));
1201 ++ valuepos += ntohs(from_packet->valuelen);
1202 ++ memcpy(valuepos,
"',", 2);
1206 ++ pos += ((
sizeof(
struct ondata) + ntohs(from_packet->valuelen) - 1) | 3) + 1;
1210 ++ sprintf(valuepos,
"'%lu'", (uintmax_t)time(NULL));
1213 ++ localzSql = olsr_malloc(strlen(SQLframe) + strlen(table) + strlen(values) + 1,
"update_ondata_entry: space for SQL query");
1214 ++ sprintf(localzSql, SQLframe, table, values);
1215 ++ free(table); free(values);
1218 ++ rc = open_database(&localdb);
1219 ++
if( rc == SQLITE_OK ){
1221 ++ rc = local_sqlite3_prepare_v2(localdb, localzSql, 1500, &localppStmt, &pzTail);
1222 ++
if( rc == SQLITE_OK ){
1223 ++ sqlite3_step(localppStmt);
1224 ++ sqlite3_finalize(localppStmt);
1225 ++ OLSR_PRINTF(5,
"ONDATA PLUGIN: Data added: %s\n", localzSql);
1227 ++
else fprintf(stderr,
"SQL error: %s\n", sqlite3_errmsg(localdb));
1229 ++
else fprintf(stderr,
"Can't open database: %s\n", sqlite3_errmsg(localdb));
1231 ++ sqlite3_close(localdb);
1245 +diff --git a/lib/ondataservice/src/ondataservice.h b/lib/ondataservice/src/ondataservice.h
1246 +
new file mode 100644
1247 +index 0000000..cc1251b
1249 ++++ b/lib/ondataservice/src/ondataservice.h
1287 ++#ifndef _ONDATASERVICE_PLUGIN
1288 ++#define _ONDATASERVICE_PLUGIN
1290 ++#include <sys/time.h>
1293 ++#include
"olsr_types.h"
1294 ++#include
"interfaces.h"
1295 ++#include
"olsr_protocol.h"
1296 ++#include
"common/list.h"
1298 ++#include
"olsrd_plugin.h"
1299 ++#include
"ondataservice_msg.h"
1300 ++#include
"hashing.h"
1304 ++#define PLUGIN_NAME
"OLSRD ondataservice plugin"
1305 ++#define PLUGIN_VERSION
"0.3"
1306 ++#define PLUGIN_AUTHOR
"Rene Ejury, Bruno Randolf, Jens Nachtigall, Sven-Ola Tuecke"
1307 ++#define DATABASE_FILE
"/tmp/database"
1309 ++#define MESSAGE_TYPE 222
1310 ++#define PARSER_TYPE MESSAGE_TYPE
1311 ++#define EMISSION_INTERVAL 10800
1312 ++#define EMISSION_INC_INTERVAL 5
1313 ++#define EMISSION_JITTER 25
1314 ++#define ONDATA_TIMEOUT 21600
1315 ++#define ONDATA_VALID_TIME 300
1316 ++#define CLEANUP_INTERVAL 1800
1318 ++#define ONDATA_PROTOCOL_VERSION 1
1320 ++#define MAX_FILE 255
1323 ++
bool olsr_parser(
union olsr_message *,
struct interface *,
union olsr_ip_addr *);
1326 ++
void olsr_ondatasvc_gen(
void *);
1329 ++#include <sqlite3.h>
1330 ++
int open_database(sqlite3 **localdb);
1331 ++
int unsigned local_sqlite3_prepare_v2(sqlite3 *db,
const char *zSql,
int nByte, sqlite3_stmt **ppStmt,
const char **pzTail);
1334 ++
void olsr_ondataservice_expire_db_timer(
void *);
1336 ++
int encap_ondatamsg(
struct ondatamsg *);
1338 ++
void update_ondata_entry(
union olsr_ip_addr *,
struct ondatamsg *,
int);
1340 ++
int register_olsr_param(
char *
key,
char *value);
1343 ++
char *create_packet(
struct ondata *to,
const char *value);
1345 ++
void ondata_constructor(
void);
1347 ++
void ondata_destructor(
void);
1349 ++
int ondata_init(
void);
1360 +diff --git a/lib/ondataservice/src/ondataservice_msg.h b/lib/ondataservice/src/ondataservice_msg.h
1361 +
new file mode 100644
1362 +index 0000000..b22fbee
1364 ++++ b/lib/ondataservice/src/ondataservice_msg.h
1402 ++#ifndef _ONDATASERVICE_MSG
1403 ++#define _ONDATASERVICE_MSG
1410 ++ uint16_t valuelen;
1416 ++
struct ondatamsg {
1417 ++ uint16_t checksum;
1418 ++ uint16_t version;
1419 ++ uint16_t nr_datasets;
1434 +diff --git a/lib/ondataservice/version-script.txt b/lib/ondataservice/version-script.txt
1435 +
new file mode 100644
1436 +index 0000000..a145659
1438 ++++ b/lib/ondataservice/version-script.txt
1443 ++ olsrd_plugin_interface_version;
1444 ++ olsrd_plugin_init;
1445 ++ olsrd_get_plugin_parameters;
1450 +diff --git a/lib/ondataservice_light/Makefile b/lib/ondataservice_light/Makefile
1451 +
new file mode 100644
1452 +index 0000000..01dd2db
1454 ++++ b/lib/ondataservice_light/Makefile
1456 ++# The olsr.org Optimized Link-State Routing daemon(olsrd)
1457 ++# Copyright (
c) 2004, Andreas Tonnesen(andreto@olsr.org)
1458 ++# All rights reserved.
1460 ++# Redistribution and use in source and binary forms, with or without
1461 ++# modification, are permitted provided that the following conditions
1464 ++# * Redistributions of source
code must retain the above copyright
1465 ++# notice,
this list of conditions and the following disclaimer.
1466 ++# * Redistributions in binary form must reproduce the above copyright
1467 ++# notice,
this list of conditions and the following disclaimer in
1468 ++# the documentation and/or other materials provided with the
1470 ++# * Neither the name of olsr.org, olsrd nor the names of its
1471 ++# contributors may be used to endorse or promote products derived
1472 ++# from
this software without specific prior written permission.
1474 ++# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
1475 ++#
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
1476 ++# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
1477 ++# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
1478 ++# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
1479 ++# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
1480 ++# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
1481 ++# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
1482 ++# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
1483 ++# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
1484 ++# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
1485 ++# POSSIBILITY OF SUCH DAMAGE.
1489 ++# If you find
this software useful feel free to make a donation
1490 ++# to the project. For more information see the website or contact
1491 ++# the copyright holders.
1494 ++OLSRD_PLUGIN =
true
1495 ++PLUGIN_NAME = olsrd_ondataservice_light
1496 ++# dont change version here
for backward-compatible changes,
1497 ++# it will change the library name and won
't load with the
1498 ++# olsrd-config already existing on the device
1504 ++include $(TOPDIR)/Makefile.inc
1506 ++ifeq ($(OS),win32)
1507 ++default_target install clean:
1508 ++ @echo "**** We use the regex library here. Does Win32 has something like this?"
1510 ++ifeq ($(OS),android)
1511 ++# On Android Google forgot to include regex engine code for Froyo version (but also there was
1512 ++# no support in older versions for it) so we have here this missing code.
1513 ++# http://groups.google.com/group/android-ndk/browse_thread/thread/5ea6f0650f0e3fc
1514 ++SRCS += $(wildcard $(TOPDIR)/android/regex/reg*.c)
1515 ++HDRS += $(wildcard $(TOPDIR)/android/regex/*.h)
1516 ++CFLAGS += -D__POSIX_VISIBLE
1519 ++default_target: $(PLUGIN_FULLNAME)
1521 ++$(PLUGIN_FULLNAME): $(OBJS) version-script.txt
1523 ++ @$(CC) $(LDFLAGS) -o $(PLUGIN_FULLNAME) $(OBJS) $(LIBS)
1525 ++install: $(PLUGIN_FULLNAME)
1526 ++ $(STRIP) $(PLUGIN_FULLNAME)
1533 ++ rm -f $(OBJS) $(SRCS:%.c=%.d) $(PLUGIN_FULLNAME)
1535 +diff --git a/lib/ondataservice_light/README_ONDATASERVICE_LIGHT b/lib/ondataservice_light/README_ONDATASERVICE_LIGHT
1536 +new file mode 100644
1537 +index 0000000..174cd28
1539 ++++ b/lib/ondataservice_light/README_ONDATASERVICE_LIGHT
1541 ++---------------------------------------------------------------------
1542 ++ONDATASERVICE_LIGHT PLUGIN FOR OLSRD
1543 ++by Rene Ejury <opennet@absorb.it>
1544 ++based on and copied from:
1545 ++NAMESERVICE PLUGIN FOR OLSRD
1546 ++by Bruno Randolf <bruno.randolf@4g-systems.biz>
1547 ++---------------------------------------------------------------------
1549 ++Plugin just to spread json-values stored in a json-database
1550 ++no reception possible, but does not require sqlite-library
1552 ++---------------------------------------------------------------------
1553 ++PLUGIN PARAMETERS (PlParam)
1554 ++---------------------------------------------------------------------
1556 ++PlParam "interval" "SEC"
1557 ++ interval for sending the DATABASE in seconds.
1558 ++ (default: 10800 - 3 hours)
1560 ++PlParam "inc_interval" "SEC"
1561 ++ interval for continously sending TABLES from DATABASE in seconds.
1562 ++ (default: 5 seconds)
1564 ++PlParam "database" "/path/to/database"
1565 ++ Path to the database (json)
1567 ++PlParam "vtime" "SEC"
1568 ++ validity time for sended message-packages in seconds.
1569 ++ (how long this message-data is forwarded through the net)
1570 ++ (default: 300 - 5 mins)
1572 ++---------------------------------------------------------------------
1574 ++---------------------------------------------------------------------
1576 ++add in /etc/olsrd.conf:
1578 ++LoadPlugin "olsrd_ondataservice_light.so.0.1"
1580 ++ PlParam "interval" "120"
1581 ++ PlParam "database" "/tmp/database.json"
1583 +diff --git a/lib/ondataservice_light/src/cJSON.c b/lib/ondataservice_light/src/cJSON.c
1584 +new file mode 100644
1585 +index 0000000..a5d910e
1587 ++++ b/lib/ondataservice_light/src/cJSON.c
1590 ++ Copyright (c) 2009 Dave Gamble
1592 ++ Permission is hereby granted, free of charge, to any person obtaining a copy
1593 ++ of this software and associated documentation files (the "Software"), to deal
1594 ++ in the Software without restriction, including without limitation the rights
1595 ++ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
1596 ++ copies of the Software, and to permit persons to whom the Software is
1597 ++ furnished to do so, subject to the following conditions:
1599 ++ The above copyright notice and this permission notice shall be included in
1600 ++ all copies or substantial portions of the Software.
1602 ++ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1603 ++ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
1604 ++ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
1605 ++ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
1606 ++ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
1607 ++ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
1612 ++/* JSON parser in C. */
1614 ++#include <string.h>
1615 ++#include <stdio.h>
1617 ++#include <stdlib.h>
1618 ++#include <float.h>
1619 ++#include <limits.h>
1620 ++#include <ctype.h>
1621 ++#include "cJSON.h"
1623 ++static const char *ep;
1625 ++// const char *cJSON_GetErrorPtr(void) {return ep;}
1627 ++// static int cJSON_strcasecmp(const char *s1,const char *s2)
1629 ++// if (!s1) return (s1==s2)?0:1;if (!s2) return 1;
1630 ++// for(; tolower(*s1) == tolower(*s2); ++s1, ++s2) if(*s1 == 0) return 0;
1631 ++// return tolower(*(const unsigned char *)s1) - tolower(*(const unsigned char *)s2);
1634 ++static void *(*cJSON_malloc)(size_t sz) = malloc;
1635 ++static void (*cJSON_free)(void *ptr) = free;
1637 ++static char* cJSON_strdup(const char* str)
1642 ++ len = strlen(str) + 1;
1643 ++ if (!(copy = (char*)cJSON_malloc(len))) return 0;
1644 ++ memcpy(copy,str,len);
1648 ++void cJSON_InitHooks(cJSON_Hooks* hooks)
1650 ++ if (!hooks) { /* Reset hooks */
1651 ++ cJSON_malloc = malloc;
1652 ++ cJSON_free = free;
1656 ++ cJSON_malloc = (hooks->malloc_fn)?hooks->malloc_fn:malloc;
1657 ++ cJSON_free = (hooks->free_fn)?hooks->free_fn:free;
1660 ++/* Internal constructor. */
1661 ++static cJSON *cJSON_New_Item(void)
1663 ++ cJSON* node = (cJSON*)cJSON_malloc(sizeof(cJSON));
1664 ++ if (node) memset(node,0,sizeof(cJSON));
1668 ++/* Delete a cJSON structure. */
1669 ++void cJSON_Delete(cJSON *c)
1675 ++ if (!(c->type&cJSON_IsReference) && c->child) cJSON_Delete(c->child);
1676 ++ if (!(c->type&cJSON_IsReference) && c->valuestring) cJSON_free(c->valuestring);
1677 ++ if (c->string) cJSON_free(c->string);
1683 ++// /* Parse the input text to generate a number, and populate the result into item. */
1684 ++// static const char *parse_number(cJSON *item,const char *num)
1686 ++// double n=0,sign=1,scale=0;int subscale=0,signsubscale=1;
1688 ++// /* Could use sscanf for this? */
1689 ++// if (*num=='-
') sign=-1,num++; /* Has sign? */
1690 ++// if (*num=='0
') num++; /* is zero */
1691 ++// if (*num>='1
' && *num<='9
') do n=(n*10.0)+(*num++ -'0
'); while (*num>='0
' && *num<='9
'); /* Number? */
1692 ++// if (*num=='.
' && num[1]>='0
' && num[1]<='9
') {num++; do n=(n*10.0)+(*num++ -'0
'),scale--; while (*num>='0
' && *num<='9
');} /* Fractional part? */
1693 ++// if (*num=='e
' || *num=='E
') /* Exponent? */
1694 ++// { num++;if (*num=='+
') num++; else if (*num=='-
') signsubscale=-1,num++; /* With sign? */
1695 ++// while (*num>='0
' && *num<='9
') subscale=(subscale*10)+(*num++ - '0
'); /* Number? */
1698 ++// n=sign*n*pow(10.0,(scale+subscale*signsubscale)); /* number = +/- number.fraction * 10^+/- exponent */
1700 ++// item->valuedouble=n;
1701 ++// item->valueint=(int)n;
1702 ++// item->type=cJSON_Number;
1706 ++// /* Render the number nicely from the given item into a string. */
1707 ++// static char *print_number(cJSON *item)
1710 ++// double d=item->valuedouble;
1711 ++// if (fabs(((double)item->valueint)-d)<=DBL_EPSILON && d<=INT_MAX && d>=INT_MIN)
1713 ++// str=(char*)cJSON_malloc(21); /* 2^64+1 can be represented in 21 chars. */
1714 ++// if (str) sprintf(str,"%d",item->valueint);
1718 ++// str=(char*)cJSON_malloc(64); /* This is a nice tradeoff. */
1721 ++// if (fabs(floor(d)-d)<=DBL_EPSILON) sprintf(str,"%.0f",d);
1722 ++// else if (fabs(d)<1.0e-6 || fabs(d)>1.0e9) sprintf(str,"%e",d);
1723 ++// else sprintf(str,"%f",d);
1729 ++/* Parse the input text into an unescaped cstring, and populate item. */
1730 ++static const unsigned char firstByteMark[7] = { 0x00, 0x00, 0xC0, 0xE0, 0xF0, 0xF8, 0xFC };
1731 ++static const char *parse_string(cJSON *item,const char *str)
1733 ++ const char *ptr=str+1;char *ptr2;char *out;int len=0;unsigned uc,uc2;
1734 ++ if (*str!='\
"') {ep=str;return 0;} /* not a string! */
1736 ++ while (*ptr!='\"' && *ptr && ++len) if (*ptr++ == '\\') ptr++; /* Skip escaped quotes. */
1738 ++ out=(char*)cJSON_malloc(len+1); /* This is how long we need for the string, roughly. */
1739 ++ if (!out) return 0;
1741 ++ ptr=str+1;ptr2=out;
1742 ++ while (*ptr!='\"' && *ptr)
1744 ++ if (*ptr!='\\') *ptr2++=*ptr++;
1750 ++ case 'b': *ptr2++='\b'; break;
1751 ++ case 'f': *ptr2++='\f'; break;
1752 ++ case 'n': *ptr2++='\n'; break;
1753 ++ case 'r': *ptr2++='\r'; break;
1754 ++ case 't': *ptr2++='\t'; break;
1755 ++ case 'u': /* transcode utf16 to utf8. */
1756 ++ sscanf(ptr+1,"%4x
",&uc);ptr+=4; /* get the unicode char. */
1758 ++ if ((uc>=0xDC00 && uc<=0xDFFF) || uc==0) break; // check for invalid.
1760 ++ if (uc>=0xD800 && uc<=0xDBFF) // UTF16 surrogate pairs.
1762 ++ if (ptr[1]!='\\' || ptr[2]!='u') break; // missing second-half of surrogate.
1763 ++ sscanf(ptr+3,"%4x
",&uc2);ptr+=6;
1764 ++ if (uc2<0xDC00 || uc2>0xDFFF) break; // invalid second-half of surrogate.
1765 ++ uc=0x10000 | ((uc&0x3FF)<<10) | (uc2&0x3FF);
1768 ++ len=4;if (uc<0x80) len=1;else if (uc<0x800) len=2;else if (uc<0x10000) len=3; ptr2+=len;
1771 ++ case 4: *--ptr2 =((uc | 0x80) & 0xBF); uc >>= 6;
1772 ++ case 3: *--ptr2 =((uc | 0x80) & 0xBF); uc >>= 6;
1773 ++ case 2: *--ptr2 =((uc | 0x80) & 0xBF); uc >>= 6;
1776 ++ *--ptr2 =(uc | firstByteMark[len]);
1780 ++ default: *ptr2++=*ptr; break;
1786 ++ if (*ptr=='\"') ptr++;
1787 ++ item->valuestring=out;
1788 ++ item->type=cJSON_String;
1792 ++// /* Render the cstring provided to an escaped version that can be printed. */
1793 ++// static char *print_string_ptr(const char *str)
1795 ++// const char *ptr;char *ptr2,*out;int len=0;unsigned char token;
1797 ++// if (!str) return cJSON_strdup("");
1798 ++// ptr=str;while ((token=*ptr) && ++len) {if (strchr("\
"\\\b\f\n\r\t",token)) len++;
else if (token<32) len+=5;ptr++;}
1831 ++
static const char *parse_value(cJSON *item,
const char *value);
1835 ++
static const char *parse_object(cJSON *item,
const char *value);
1839 ++
static const char *skip(
const char *in) {
while (in && *in && (
unsigned char)*in<=32) in++;
return in;}
1842 ++cJSON *cJSON_Parse(
const char *value)
1844 ++ cJSON *
c=cJSON_New_Item();
1846 ++
if (!c)
return 0;
1848 ++
if (!parse_value(c,skip(value))) {cJSON_Delete(c);
return 0;}
1857 ++
static const char *parse_value(cJSON *item,
const char *value)
1859 ++
if (!value)
return 0;
1863 ++
if (*value==
'\"') {
return parse_string(item,value); }
1866 ++
if (*value==
'{') {
return parse_object(item,value); }
1868 ++ ep=value;
return 0;
1969 ++
static const char *parse_object(cJSON *item,
const char *value)
1972 ++
if (*value!=
'{') {ep=value;
return 0;}
1974 ++ item->type=cJSON_Object;
1975 ++ value=skip(value+1);
1976 ++
if (*value==
'}')
return value+1;
1978 ++ item->child=child=cJSON_New_Item();
1979 ++
if (!item->child)
return 0;
1980 ++ value=skip(parse_string(child,skip(value)));
1981 ++
if (!value)
return 0;
1982 ++ child->string=child->valuestring;child->valuestring=0;
1983 ++
if (*value!=
':') {ep=value;
return 0;}
1984 ++ value=skip(parse_value(child,skip(value+1)));
1985 ++
if (!value)
return 0;
1987 ++
while (*value==
',')
1990 ++
if (!(new_item=cJSON_New_Item()))
return 0;
1991 ++ child->next=new_item;new_item->prev=child;child=new_item;
1992 ++ value=skip(parse_string(child,skip(value+1)));
1993 ++
if (!value)
return 0;
1994 ++ child->string=child->valuestring;child->valuestring=0;
1995 ++
if (*value!=
':') {ep=value;
return 0;}
1996 ++ value=skip(parse_value(child,skip(value+1)));
1997 ++
if (!value)
return 0;
2000 ++
if (*value==
'}')
return value+1;
2001 ++ ep=value;
return 0;
2096 ++cJSON *cJSON_CreateString(
const char *
string) {cJSON *item=cJSON_New_Item();
if(item){item->type=cJSON_String;item->valuestring=cJSON_strdup(
string);}
return item;}
2098 ++cJSON *cJSON_CreateObject(
void) {cJSON *item=cJSON_New_Item();
if(item)item->type=cJSON_Object;
return item;}
2105 +diff --git a/lib/ondataservice_light/src/cJSON.h b/lib/ondataservice_light/src/cJSON.h
2106 +
new file mode 100644
2107 +index 0000000..158160c
2109 ++++ b/lib/ondataservice_light/src/cJSON.h
2136 ++#ifdef __cplusplus
2142 ++#define cJSON_False 0
2143 ++#define cJSON_True 1
2144 ++#define cJSON_NULL 2
2145 ++#define cJSON_Number 3
2146 ++#define cJSON_String 4
2147 ++#define cJSON_Array 5
2148 ++#define cJSON_Object 6
2150 ++#define cJSON_IsReference 256
2153 ++
typedef struct cJSON {
2154 ++
struct cJSON *next,*prev;
2155 ++
struct cJSON *child;
2159 ++
char *valuestring;
2161 ++
double valuedouble;
2166 ++
typedef struct cJSON_Hooks {
2167 ++
void *(*malloc_fn)(
size_t sz);
2168 ++ void (*free_fn)(
void *ptr);
2172 ++
extern void cJSON_InitHooks(cJSON_Hooks* hooks);
2176 ++
extern cJSON *cJSON_Parse(
const char *value);
2182 ++
extern void cJSON_Delete(cJSON *c);
2200 ++
extern cJSON *cJSON_CreateString(
const char *
string);
2202 ++
extern cJSON *cJSON_CreateObject(
void);
2227 ++#define cJSON_AddNullToObject(
object,name) cJSON_AddItemToObject(
object, name, cJSON_CreateNull())
2228 ++
#define cJSON_AddTrueToObject(object,name) cJSON_AddItemToObject(object, name, cJSON_CreateTrue())
2229 ++#define cJSON_AddFalseToObject(
object,name) cJSON_AddItemToObject(
object, name, cJSON_CreateFalse())
2230 ++
#define cJSON_AddNumberToObject(object,name,n) cJSON_AddItemToObject(object, name, cJSON_CreateNumber(n))
2231 ++#define cJSON_AddStringToObject(
object,name,
s) cJSON_AddItemToObject(
object, name, cJSON_CreateString(
s))
2233 ++
#ifdef __cplusplus
2238 +diff --git a/lib/ondataservice_light/src/compat.c b/lib/ondataservice_light/src/compat.c
2239 +
new file mode 100644
2240 +index 0000000..4d639be
2242 ++++ b/lib/ondataservice_light/src/compat.c
2244 ++#include
"compat.h"
2246 ++#
if !defined(__linux__) && !defined(__GLIBC__)
2247 ++#include <stdlib.h>
2248 ++#include <
string.h>
2252 ++strndup(
const char *ptr,
size_t size)
2254 ++
size_t len = strlen(ptr);
2255 ++
char *ret = NULL;
2260 ++ ret = malloc(len + 1);
2265 ++ memcpy(ret, ptr, len);
2279 +diff --git a/lib/ondataservice_light/src/compat.h b/lib/ondataservice_light/src/compat.h
2280 +
new file mode 100644
2281 +index 0000000..c607c91
2283 ++++ b/lib/ondataservice_light/src/compat.h
2285 ++#ifndef _NAMESERVICE_COMPAT
2286 ++#define _NAMESERVICE_COMPAT
2288 ++#include <sys/types.h>
2290 ++#
if !defined(__linux__) && !defined(__GLIBC__)
2291 ++
char *strndup(
const char *ptr,
size_t size);
2302 +diff --git a/lib/ondataservice_light/src/crc16.c b/lib/ondataservice_light/src/crc16.c
2303 +
new file mode 100644
2304 +index 0000000..dc877ca
2306 ++++ b/lib/ondataservice_light/src/crc16.c
2308 ++#include <stdlib.h>
2309 ++#include
"crc16.h"
2317 ++#define CRC16(crc,c) crc = (crc >> 8) ^ crctab[(crc ^ c) & 0xff]
2319 ++const u_int16_t crctab[256] = {
2320 ++ 0x0000, 0xc0c1, 0xc181, 0x0140, 0xc301, 0x03c0, 0x0280, 0xc241,
2321 ++ 0xc601, 0x06c0, 0x0780, 0xc741, 0x0500, 0xc5c1, 0xc481, 0x0440,
2322 ++ 0xcc01, 0x0cc0, 0x0d80, 0xcd41, 0x0f00, 0xcfc1, 0xce81, 0x0e40,
2323 ++ 0x0a00, 0xcac1, 0xcb81, 0x0b40, 0xc901, 0x09c0, 0x0880, 0xc841,
2324 ++ 0xd801, 0x18c0, 0x1980, 0xd941, 0x1b00, 0xdbc1, 0xda81, 0x1a40,
2325 ++ 0x1e00, 0xdec1, 0xdf81, 0x1f40, 0xdd01, 0x1dc0, 0x1c80, 0xdc41,
2326 ++ 0x1400, 0xd4c1, 0xd581, 0x1540, 0xd701, 0x17c0, 0x1680, 0xd641,
2327 ++ 0xd201, 0x12c0, 0x1380, 0xd341, 0x1100, 0xd1c1, 0xd081, 0x1040,
2328 ++ 0xf001, 0x30c0, 0x3180, 0xf141, 0x3300, 0xf3c1, 0xf281, 0x3240,
2329 ++ 0x3600, 0xf6c1, 0xf781, 0x3740, 0xf501, 0x35c0, 0x3480, 0xf441,
2330 ++ 0x3c00, 0xfcc1, 0xfd81, 0x3d40, 0xff01, 0x3fc0, 0x3e80, 0xfe41,
2331 ++ 0xfa01, 0x3ac0, 0x3b80, 0xfb41, 0x3900, 0xf9c1, 0xf881, 0x3840,
2332 ++ 0x2800, 0xe8c1, 0xe981, 0x2940, 0xeb01, 0x2bc0, 0x2a80, 0xea41,
2333 ++ 0xee01, 0x2ec0, 0x2f80, 0xef41, 0x2d00, 0xedc1, 0xec81, 0x2c40,
2334 ++ 0xe401, 0x24c0, 0x2580, 0xe541, 0x2700, 0xe7c1, 0xe681, 0x2640,
2335 ++ 0x2200, 0xe2c1, 0xe381, 0x2340, 0xe101, 0x21c0, 0x2080, 0xe041,
2336 ++ 0xa001, 0x60c0, 0x6180, 0xa141, 0x6300, 0xa3c1, 0xa281, 0x6240,
2337 ++ 0x6600, 0xa6c1, 0xa781, 0x6740, 0xa501, 0x65c0, 0x6480, 0xa441,
2338 ++ 0x6c00, 0xacc1, 0xad81, 0x6d40, 0xaf01, 0x6fc0, 0x6e80, 0xae41,
2339 ++ 0xaa01, 0x6ac0, 0x6b80, 0xab41, 0x6900, 0xa9c1, 0xa881, 0x6840,
2340 ++ 0x7800, 0xb8c1, 0xb981, 0x7940, 0xbb01, 0x7bc0, 0x7a80, 0xba41,
2341 ++ 0xbe01, 0x7ec0, 0x7f80, 0xbf41, 0x7d00, 0xbdc1, 0xbc81, 0x7c40,
2342 ++ 0xb401, 0x74c0, 0x7580, 0xb541, 0x7700, 0xb7c1, 0xb681, 0x7640,
2343 ++ 0x7200, 0xb2c1, 0xb381, 0x7340, 0xb101, 0x71c0, 0x7080, 0xb041,
2344 ++ 0x5000, 0x90c1, 0x9181, 0x5140, 0x9301, 0x53c0, 0x5280, 0x9241,
2345 ++ 0x9601, 0x56c0, 0x5780, 0x9741, 0x5500, 0x95c1, 0x9481, 0x5440,
2346 ++ 0x9c01, 0x5cc0, 0x5d80, 0x9d41, 0x5f00, 0x9fc1, 0x9e81, 0x5e40,
2347 ++ 0x5a00, 0x9ac1, 0x9b81, 0x5b40, 0x9901, 0x59c0, 0x5880, 0x9841,
2348 ++ 0x8801, 0x48c0, 0x4980, 0x8941, 0x4b00, 0x8bc1, 0x8a81, 0x4a40,
2349 ++ 0x4e00, 0x8ec1, 0x8f81, 0x4f40, 0x8d01, 0x4dc0, 0x4c80, 0x8c41,
2350 ++ 0x4400, 0x84c1, 0x8581, 0x4540, 0x8701, 0x47c0, 0x4680, 0x8641,
2351 ++ 0x8201, 0x42c0, 0x4380, 0x8341, 0x4100, 0x81c1, 0x8081, 0x4040
2360 ++u_int16_t crcCalculate(
char *buffer,
unsigned int length)
2362 ++ u_int16_t Crc = 0;
2364 ++
for (; length; --length) {
2365 ++ CRC16(Crc, *buffer++);
2370 +diff --git a/lib/ondataservice_light/src/crc16.h b/lib/ondataservice_light/src/crc16.h
2371 +
new file mode 100644
2372 +index 0000000..729d784
2374 ++++ b/lib/ondataservice_light/src/crc16.h
2380 ++u_int16_t crcCalculate(
char *buffer,
unsigned int length);
2382 +diff --git a/lib/ondataservice_light/src/olsrd_plugin.c b/lib/ondataservice_light/src/olsrd_plugin.c
2383 +
new file mode 100644
2384 +index 0000000..c6989c5
2386 ++++ b/lib/ondataservice_light/src/olsrd_plugin.c
2424 ++#include <stdio.h>
2425 ++#include <
string.h>
2427 ++#include
"olsrd_plugin.h"
2428 ++#include
"ondataservice.h"
2430 ++#define MOD_DESC PLUGIN_NAME
" " PLUGIN_VERSION
2431 ++#define PLUGIN_INTERFACE_VERSION 5
2433 ++
static void __attribute__ ((constructor)) my_init(
void);
2435 ++static
void __attribute__ ((destructor)) my_fini(
void);
2438 ++olsrd_plugin_interface_version(
void)
2440 ++
return PLUGIN_INTERFACE_VERSION;
2444 ++olsrd_plugin_init(
void)
2446 ++
return ondata_init();
2453 ++ printf(
"%s\n", MOD_DESC);
2455 ++ ondata_constructor();
2463 ++ ondata_destructor();
2472 +diff --git a/lib/ondataservice_light/src/ondataservice.c b/lib/ondataservice_light/src/ondataservice.c
2473 +
new file mode 100644
2474 +index 0000000..4f685c9
2476 ++++ b/lib/ondataservice_light/src/ondataservice.c
2513 ++#define _GNU_SOURCE 1
2515 ++#include <stdio.h>
2516 ++#include <
string.h>
2517 ++#include <stdlib.h>
2518 ++#include <unistd.h>
2519 ++#include <ctype.h>
2520 ++#include <sys/types.h>
2521 ++#include <sys/stat.h>
2522 ++#include <signal.h>
2523 ++#include <fcntl.h>
2528 ++#include
"net_olsr.h"
2529 ++#include
"parser.h"
2531 ++#include
"plugin_util.h"
2532 ++#include
"ondataservice.h"
2533 ++#include
"compat.h"
2534 ++#include
"crc16.h"
2535 ++#include
"cJSON.h"
2538 ++
static int my_interval = EMISSION_INTERVAL;
2539 ++
static int my_inc_interval = EMISSION_INC_INTERVAL;
2540 ++
static char my_database[MAX_FILE + 1];
2541 ++
static int my_vtime = ONDATA_VALID_TIME;
2544 ++
struct timer_entry *msg_gen_timer = NULL;
2550 ++ondata_constructor(
void)
2555 ++ GetWindowsDirectory(my_database, MAX_FILE - 12);
2557 ++ len = strlen(my_database);
2558 ++
if (my_database[len - 1] !=
'\\')
2559 ++ strscat(my_database,
"\\",
sizeof(my_database));
2560 ++ strscat(my_database, DATABASE_FILE,
sizeof(my_database));
2563 ++ strscpy(my_database, DATABASE_FILE,
sizeof(my_database));
2569 ++
static const struct olsrd_plugin_parameters plugin_parameters[] = {
2570 ++ { .name =
"interval", .set_plugin_parameter = &set_plugin_int, .data = &my_interval },
2571 ++ { .name =
"inc_interval", .set_plugin_parameter = &set_plugin_int, .data = &my_inc_interval },
2572 ++ { .name =
"database", .set_plugin_parameter = &set_plugin_string, .data = &my_database, .addon = {
sizeof(my_database)} },
2573 ++ { .name =
"vtime", .set_plugin_parameter = &set_plugin_int, .data = &my_vtime },
2578 ++olsrd_get_plugin_parameters(
const struct olsrd_plugin_parameters **params,
int *size)
2580 ++ *params = plugin_parameters;
2581 ++ *size =
sizeof(plugin_parameters) /
sizeof(*plugin_parameters);
2601 ++ msg_gen_timer = olsr_start_timer(my_interval * MSEC_PER_SEC, EMISSION_JITTER, OLSR_TIMER_PERIODIC, &olsr_ondatasvc_gen, NULL, 0);
2612 ++ondata_destructor(
void)
2614 ++ olsr_stop_timer(msg_gen_timer);
2621 ++olsr_ondatasvc_gen(
void *foo __attribute__ ((unused)))
2624 ++
char buffer[10240];
2625 ++
union olsr_message *message = (
union olsr_message *)buffer;
2626 ++
struct interface *ifn;
2630 ++
if (olsr_cnf->ip_version == AF_INET) {
2632 ++ message->v4.olsr_msgtype = MESSAGE_TYPE;
2633 ++ message->v4.olsr_vtime = reltime_to_me((
double)my_vtime * MSEC_PER_SEC);
2634 ++ memcpy(&message->v4.originator, &olsr_cnf->main_addr, olsr_cnf->ipsize);
2635 ++ message->v4.ttl = MAX_TTL;
2636 ++ message->v4.hopcnt = 0;
2637 ++ message->v4.seqno = htons(get_msg_seqno());
2639 ++ ondatasize = encap_ondatamsg((
struct ondatamsg *)ARM_NOWARN_ALIGN(&message->v4.message));
2640 ++
if (!ondatasize)
return;
2641 ++ ondatasize = ondatasize +
sizeof(
struct olsrmsg);
2642 ++ message->v4.olsr_msgsize = htons(ondatasize);
2645 ++ message->v6.olsr_msgtype = MESSAGE_TYPE;
2646 ++ message->v6.olsr_vtime = reltime_to_me((
double)my_vtime * MSEC_PER_SEC);
2647 ++ memcpy(&message->v6.originator, &olsr_cnf->main_addr, olsr_cnf->ipsize);
2648 ++ message->v6.ttl = MAX_TTL;
2649 ++ message->v6.hopcnt = 0;
2650 ++ message->v6.seqno = htons(get_msg_seqno());
2652 ++ ondatasize = encap_ondatamsg((
struct ondatamsg *)ARM_NOWARN_ALIGN(&message->v6.message));
2653 ++
if (!ondatasize)
return;
2654 ++ ondatasize = ondatasize +
sizeof(
struct olsrmsg6);
2656 ++ message->v6.olsr_msgsize = htons(ondatasize);
2660 ++
for (ifn = ifnet; ifn; ifn = ifn->int_next) {
2661 ++ OLSR_PRINTF(3,
"ONDATA PLUGIN: Generating packet - [%s]\n", ifn->int_name);
2663 ++
if (net_outbuffer_push(ifn, message, ondatasize) != ondatasize) {
2666 ++
if (net_outbuffer_push(ifn, message, ondatasize) != ondatasize) {
2667 ++ OLSR_PRINTF(1,
"ONDATA PLUGIN: could not send on interface: %s\n", ifn->int_name);
2684 ++encap_ondatamsg(
struct ondatamsg *msg)
2686 ++
struct ipaddr_str main_addr;
2689 ++ uint16_t checksum;
2690 ++ uint16_t messageLength = 0;
2691 ++ cJSON *json = NULL, *elem;
2692 ++
char line [ 3000 ];
2695 ++
if (fp == NULL) {
2696 ++ OLSR_PRINTF(0,
"ONDATA PLUGIN: opening json file\n");
2698 ++ fp=fopen(my_database,
"r");
2701 ++ fprintf(stderr,
"Can't open json file %s\n", my_database);
2707 ++
if (fp != NULL) {
2708 ++
if ( fgets ( line,
sizeof line, fp ) != NULL ) {
2709 ++ json=cJSON_Parse(line);
2715 ++ OLSR_PRINTF(0,
"ONDATA PLUGIN: no further table found\n");
2716 ++ olsr_change_timer(msg_gen_timer, my_interval * MSEC_PER_SEC, EMISSION_JITTER, OLSR_TIMER_PERIODIC);
2722 ++ OLSR_PRINTF(0,
"ONDATA PLUGIN: using next table %s\n", json->child->string);
2725 ++ OLSR_PRINTF(0,
"ONDATA PLUGIN: adding all datasets\n");
2727 ++ pos = (
char *)msg +
sizeof(
struct ondatamsg);
2730 ++ pos = create_packet((
struct ondata *)ARM_NOWARN_ALIGN(pos), json->child->string);
2733 ++ elem = json->child->child->next;
2737 ++ pos = create_packet((
struct ondata *)ARM_NOWARN_ALIGN(pos), elem->valuestring);
2739 ++ elem = elem->next;
2740 ++ }
while(elem->next);
2741 ++ cJSON_Delete(json);
2744 ++ msg->nr_datasets = htons(--iCol);
2745 ++ msg->version = htons(ONDATA_PROTOCOL_VERSION);
2746 ++ messageLength = pos - (
char *)msg;
2747 ++ msg->length = htons(messageLength);
2748 ++ checksum = crcCalculate((
char *)msg +
sizeof(uint16_t), messageLength -
sizeof(uint16_t));
2749 ++ msg->checksum = htons(checksum);
2751 ++ OLSR_PRINTF(0,
"ONDATA PLUGIN: ##### finished creating packet, length=%d, crc16=0x%x\n", messageLength, checksum);
2754 ++ olsr_change_timer(msg_gen_timer, 1 * MSEC_PER_SEC, EMISSION_JITTER, OLSR_TIMER_PERIODIC);
2755 ++
return messageLength;
2765 ++create_packet(
struct ondata *to,
const char *value )
2767 ++
char *pos = (
char *)to;
int valuelen = strlen((
const char*)value);
2769 ++ to->valuelen = htons(valuelen);
2770 ++ OLSR_PRINTF(5,
"ONDATA PLUGIN: Announcing value %s %d\n", value, valuelen);
2771 ++ pos +=
sizeof(
struct ondata);
2772 ++ memcpy(pos, value, valuelen);
2775 ++
for (k =
sizeof(
struct ondata) + valuelen; (k & 3) != 0; k++)
2791 +diff --git a/lib/ondataservice_light/src/ondataservice.h b/lib/ondataservice_light/src/ondataservice.h
2792 +
new file mode 100644
2793 +index 0000000..aea2f4c
2795 ++++ b/lib/ondataservice_light/src/ondataservice.h
2832 ++#ifndef _ONDATASERVICE_PLUGIN
2833 ++#define _ONDATASERVICE_PLUGIN
2835 ++#include <sys/time.h>
2838 ++#include
"olsr_types.h"
2839 ++#include
"interfaces.h"
2840 ++#include
"olsr_protocol.h"
2841 ++#include
"common/list.h"
2843 ++#include
"olsrd_plugin.h"
2844 ++#include
"ondataservice_msg.h"
2845 ++#include
"hashing.h"
2849 ++#define PLUGIN_NAME
"OLSRD ondataservice plugin"
2850 ++#define PLUGIN_VERSION
"0.3"
2851 ++#define PLUGIN_AUTHOR
"Rene Ejury, Bruno Randolf, Jens Nachtigall, Sven-Ola Tuecke"
2852 ++#define DATABASE_FILE
"/tmp/database.json"
2854 ++#define MESSAGE_TYPE 222
2855 ++#define PARSER_TYPE MESSAGE_TYPE
2856 ++#define EMISSION_INTERVAL 10800
2857 ++#define EMISSION_INC_INTERVAL 5
2858 ++#define EMISSION_JITTER 25
2859 ++#define ONDATA_VALID_TIME 300
2861 ++#define ONDATA_PROTOCOL_VERSION 1
2863 ++#define MAX_FILE 255
2866 ++
bool olsr_parser(
union olsr_message *,
struct interface *,
union olsr_ip_addr *);
2869 ++
void olsr_ondatasvc_gen(
void *);
2872 ++
void olsr_ondataservice_expire_db_timer(
void *);
2874 ++
int encap_ondatamsg(
struct ondatamsg *);
2876 ++
void update_ondata_entry(
union olsr_ip_addr *,
struct ondatamsg *,
int);
2878 ++
int register_olsr_param(
char *
key,
char *value);
2881 ++
char *create_packet(
struct ondata *to,
const char *value);
2883 ++
void ondata_constructor(
void);
2885 ++
void ondata_destructor(
void);
2887 ++
int ondata_init(
void);
2898 +diff --git a/lib/ondataservice_light/src/ondataservice_msg.h b/lib/ondataservice_light/src/ondataservice_msg.h
2899 +
new file mode 100644
2900 +index 0000000..b22fbee
2902 ++++ b/lib/ondataservice_light/src/ondataservice_msg.h
2940 ++#ifndef _ONDATASERVICE_MSG
2941 ++#define _ONDATASERVICE_MSG
2948 ++ uint16_t valuelen;
2954 ++
struct ondatamsg {
2955 ++ uint16_t checksum;
2956 ++ uint16_t version;
2957 ++ uint16_t nr_datasets;
2972 +diff --git a/lib/ondataservice_light/version-script.txt b/lib/ondataservice_light/version-script.txt
2973 +
new file mode 100644
2974 +index 0000000..a145659
2976 ++++ b/lib/ondataservice_light/version-script.txt
2981 ++ olsrd_plugin_interface_version;
2982 ++ olsrd_plugin_init;
2983 ++ olsrd_get_plugin_parameters;