diff -Nru olsrd-0.6.6.1/CHANGELOG olsrd-0.6.6.2/CHANGELOG --- olsrd-0.6.6.1/CHANGELOG 2013-10-21 15:56:50.000000000 +0000 +++ olsrd-0.6.6.2/CHANGELOG 2014-06-02 10:15:27.000000000 +0000 @@ -1,3 +1,26 @@ +0.6.6.2 ------------------------------------------------------------------- + +Alessio Caiazza (2): + Hotfix for very long http headers also for jsoninfo + jsoninfo: HTTP headers with CORS (if requested) + +Ferry Huberts (8): + pud: fix java detection in the wireformat java bindings (again) + pud: do the same fix as in the previous commit, now for i386 + Make sure to save/restore errno in signal handlers + main: olsr_create_lock_file: fix return value check on 'open' call + pud: fix readIPAddress function + tok: improve the nmea_calc_crc function a bit + neighbor table: fix crash in olsr_print_neighbor_table on MinGW + Fix strange coding in the 'long headers' fix + +Henning Rogge (5): + Update version after release of v0.6.6.1 + Fix processing error for fragmented hellos + Fix some spelling mistakes + Hotfix for much too long http headers + Release v0.6.6.2 + 0.6.6.1 ------------------------------------------------------------------- Henning Rogge (2): diff -Nru olsrd-0.6.6.1/contrib/netsimpcap/src/netsimpcap.c olsrd-0.6.6.2/contrib/netsimpcap/src/netsimpcap.c --- olsrd-0.6.6.1/contrib/netsimpcap/src/netsimpcap.c 2013-10-21 15:56:50.000000000 +0000 +++ olsrd-0.6.6.2/contrib/netsimpcap/src/netsimpcap.c 2014-06-02 10:15:27.000000000 +0000 @@ -70,6 +70,10 @@ static void signalHandler(int signo __attribute__ ((unused))) { + /* + * Normally errno must be saved here and restored before returning but since + * we do a simple assignment we don't need to do that in this signal handler. + */ running = 0; } diff -Nru olsrd-0.6.6.1/debian/changelog olsrd-0.6.6.2/debian/changelog --- olsrd-0.6.6.1/debian/changelog 2013-10-25 18:07:19.000000000 +0000 +++ olsrd-0.6.6.2/debian/changelog 2014-09-11 13:04:59.000000000 +0000 @@ -1,3 +1,16 @@ +olsrd (0.6.6.2-1ubuntu1) utopic; urgency=medium + + * Build using -fPIC everywhere except on ix86. + + -- Matthias Klose Thu, 11 Sep 2014 15:04:29 +0200 + +olsrd (0.6.6.2-1) unstable; urgency=medium + + * New upstream release + * debian/control: Standards-Version: 3.9.5 + + -- Roland Stigge Sun, 08 Jun 2014 20:54:01 +0200 + olsrd (0.6.6.1-1) unstable; urgency=low * New upstream release diff -Nru olsrd-0.6.6.1/debian/control olsrd-0.6.6.2/debian/control --- olsrd-0.6.6.1/debian/control 2013-04-02 04:07:11.000000000 +0000 +++ olsrd-0.6.6.2/debian/control 2014-06-08 19:02:51.000000000 +0000 @@ -10,7 +10,7 @@ libgtk2.0-dev, python-gtk2-dev, liblua50-dev -Standards-Version: 3.9.4 +Standards-Version: 3.9.5 Homepage: http://olsr.org/ Vcs-Svn: svn://svn.debian.org/svn/collab-maint/deb-maint/olsrd/ Vcs-Browser: http://svn.debian.org/wsvn/collab-maint/deb-maint/olsrd/ diff -Nru olsrd-0.6.6.1/debian/patches/111-build-mips-and-armhf.patch olsrd-0.6.6.2/debian/patches/111-build-mips-and-armhf.patch --- olsrd-0.6.6.1/debian/patches/111-build-mips-and-armhf.patch 2013-10-25 18:30:47.000000000 +0000 +++ olsrd-0.6.6.2/debian/patches/111-build-mips-and-armhf.patch 2014-09-11 13:04:26.000000000 +0000 @@ -2,14 +2,16 @@ make/Makefile.linux | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) ---- olsrd-0.6.6.1.orig/make/Makefile.linux -+++ olsrd-0.6.6.1/make/Makefile.linux +Index: b/make/Makefile.linux +=================================================================== +--- a/make/Makefile.linux ++++ b/make/Makefile.linux @@ -39,7 +39,7 @@ UNINSTALL_LIB = rm -f $(LIBDIR)/$(PLUGIN ifdef OLSRD_PLUGIN GENERATE_PIC = true endif -ifeq ($(filter-out mips mips64 alpha x86_64 parisc64 ia64, $(ARCH)),) -+ifeq ($(filter-out armv7l mips mips64 alpha x86_64 parisc64 ia64, $(ARCH)),) ++ifeq (,$(filter $(ARCH), i386 i486 i586 i686)) GENERATE_PIC = true endif diff -Nru olsrd-0.6.6.1/gui/linux-gtk/src/main.c olsrd-0.6.6.2/gui/linux-gtk/src/main.c --- olsrd-0.6.6.1/gui/linux-gtk/src/main.c 2013-10-21 15:56:50.000000000 +0000 +++ olsrd-0.6.6.2/gui/linux-gtk/src/main.c 2014-06-02 10:15:27.000000000 +0000 @@ -129,12 +129,14 @@ void shutdown_(int sig) { + int errNr = errno; printf("Cleaning up...\n"); if (ipc_close() < 0) printf("Could not close socket!\n"); printf("BYE-BYE!\n"); + errno = errNr; exit(sig); } diff -Nru olsrd-0.6.6.1/gui/win32/Inst/installer.nsi olsrd-0.6.6.2/gui/win32/Inst/installer.nsi --- olsrd-0.6.6.1/gui/win32/Inst/installer.nsi 2013-10-21 15:56:50.000000000 +0000 +++ olsrd-0.6.6.2/gui/win32/Inst/installer.nsi 2014-06-02 10:15:27.000000000 +0000 @@ -54,7 +54,7 @@ UninstPage instfiles Function .onInit - MessageBox MB_YESNO "This will install olsr.org 0.6.6.1 on your computer. Continue?" IDYES NoAbort + MessageBox MB_YESNO "This will install olsr.org 0.6.6.2 on your computer. Continue?" IDYES NoAbort Abort NoAbort: FunctionEnd diff -Nru olsrd-0.6.6.1/gui/win32/Main/Frontend.rc olsrd-0.6.6.2/gui/win32/Main/Frontend.rc --- olsrd-0.6.6.1/gui/win32/Main/Frontend.rc 2013-10-21 15:56:50.000000000 +0000 +++ olsrd-0.6.6.2/gui/win32/Main/Frontend.rc 2014-06-02 10:15:27.000000000 +0000 @@ -68,7 +68,7 @@ STYLE DS_MODALFRAME | WS_MINIMIZEBOX | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU EXSTYLE WS_EX_APPWINDOW -CAPTION "olsr.org Switch 0.6.6.1" +CAPTION "olsr.org Switch 0.6.6.2" FONT 8, "MS Sans Serif", 0, 0, 0x1 BEGIN CONTROL "Tab1",IDC_TAB1,"SysTabControl32",0x0,7,7,383,256 diff -Nru olsrd-0.6.6.1/lib/jsoninfo/README_JSONINFO olsrd-0.6.6.2/lib/jsoninfo/README_JSONINFO --- olsrd-0.6.6.1/lib/jsoninfo/README_JSONINFO 2013-10-21 15:56:50.000000000 +0000 +++ olsrd-0.6.6.2/lib/jsoninfo/README_JSONINFO 2014-06-02 10:15:27.000000000 +0000 @@ -73,6 +73,14 @@ # 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 -Nru olsrd-0.6.6.1/lib/jsoninfo/src/olsrd_jsoninfo.c olsrd-0.6.6.2/lib/jsoninfo/src/olsrd_jsoninfo.c --- olsrd-0.6.6.1/lib/jsoninfo/src/olsrd_jsoninfo.c 2013-10-21 15:56:50.000000000 +0000 +++ olsrd-0.6.6.2/lib/jsoninfo/src/olsrd_jsoninfo.c 2014-06-02 10:15:27.000000000 +0000 @@ -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_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 */ @@ -508,8 +523,15 @@ 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)); + } if (0 < s) { requ[s] = 0; /* print out the requested tables */ @@ -1275,6 +1297,9 @@ 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; @@ -1313,12 +1338,17 @@ 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) { @@ -1333,6 +1363,53 @@ 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 -Nru olsrd-0.6.6.1/lib/jsoninfo/src/olsrd_jsoninfo.h olsrd-0.6.6.2/lib/jsoninfo/src/olsrd_jsoninfo.h --- olsrd-0.6.6.1/lib/jsoninfo/src/olsrd_jsoninfo.h 2013-10-21 15:56:50.000000000 +0000 +++ olsrd-0.6.6.2/lib/jsoninfo/src/olsrd_jsoninfo.h 2014-06-02 10:15:27.000000000 +0000 @@ -62,6 +62,7 @@ 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 -Nru olsrd-0.6.6.1/lib/jsoninfo/src/olsrd_plugin.c olsrd-0.6.6.2/lib/jsoninfo/src/olsrd_plugin.c --- olsrd-0.6.6.1/lib/jsoninfo/src/olsrd_plugin.c 2013-10-21 15:56:50.000000000 +0000 +++ olsrd-0.6.6.2/lib/jsoninfo/src/olsrd_plugin.c 2014-06-02 10:15:27.000000000 +0000 @@ -64,6 +64,7 @@ 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 @@ /* 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 @@ 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 diff -Nru olsrd-0.6.6.1/lib/pud/nmealib/src/tok.c olsrd-0.6.6.2/lib/pud/nmealib/src/tok.c --- olsrd-0.6.6.1/lib/pud/nmealib/src/tok.c 2013-10-21 15:56:50.000000000 +0000 +++ olsrd-0.6.6.2/lib/pud/nmealib/src/tok.c 2014-06-02 10:15:27.000000000 +0000 @@ -35,20 +35,25 @@ #define NMEA_CONVSTR_BUF 64 /** - * Calculate crc control sum of a string + * Calculate crc control sum of a string. + * If the string starts with a '$' then that character is skipped as per + * the NMEA spec. * * @param s the string * @param len the length of the string * @return the crc */ int nmea_calc_crc(const char *s, const int len) { - int chksum = 0; - int it; + int chksum = 0; + int it = 0; - for (it = 0; it < len; it++) - chksum ^= (int) s[it]; + if (s[it] == '$') + it++; - return chksum; + for (; it < len; it++) + chksum ^= (int) s[it]; + + return chksum; } /** diff -Nru olsrd-0.6.6.1/lib/pud/src/configTools.c olsrd-0.6.6.2/lib/pud/src/configTools.c --- olsrd-0.6.6.1/lib/pud/src/configTools.c 2013-10-21 15:56:50.000000000 +0000 +++ olsrd-0.6.6.2/lib/pud/src/configTools.c 2014-06-02 10:15:27.000000000 +0000 @@ -263,6 +263,7 @@ union olsr_sockaddr * dst, bool * dstSet) { union olsr_sockaddr ip; int conversion; + in_port_t port; assert(parameterName != NULL); assert(str != NULL); @@ -288,10 +289,14 @@ } if (!*dstSet) { - setOlsrSockaddrPort(&ip, htons(portDefault)); + port = htons(portDefault); + } else { + port = getOlsrSockaddrPort(dst, portDefault); } - setOlsrSockaddrAddr(dst, &ip); + dst->in.sa_family = ip.in.sa_family; + setOlsrSockaddrPort(dst, port); + setOlsrSockaddrAddr(dst, &ip); *dstSet = true; return true; } diff -Nru olsrd-0.6.6.1/lib/pud/src/netTools.h olsrd-0.6.6.2/lib/pud/src/netTools.h --- olsrd-0.6.6.1/lib/pud/src/netTools.h 2013-10-21 15:56:50.000000000 +0000 +++ olsrd-0.6.6.2/lib/pud/src/netTools.h 2014-06-02 10:15:27.000000000 +0000 @@ -68,15 +68,15 @@ @param addr A pointer to the IP address (in network byte order) */ -static inline void setOlsrSockaddrAddr(union olsr_sockaddr * addr, void * ip) { +static inline void setOlsrSockaddrAddr(union olsr_sockaddr * addr, union olsr_sockaddr * ip) { if (!addr) { return; } if (addr->in.sa_family == AF_INET) { - addr->in4.sin_addr = *((struct in_addr *)ip); + addr->in4.sin_addr = ip->in4.sin_addr; } else { - addr->in6.sin6_addr = *((struct in6_addr *)ip); + addr->in6.sin6_addr = ip->in6.sin6_addr; } } diff -Nru olsrd-0.6.6.1/lib/pud/wireformat-java/Makefile olsrd-0.6.6.2/lib/pud/wireformat-java/Makefile --- olsrd-0.6.6.1/lib/pud/wireformat-java/Makefile 2013-10-21 15:56:50.000000000 +0000 +++ olsrd-0.6.6.2/lib/pud/wireformat-java/Makefile 2014-06-02 10:15:27.000000000 +0000 @@ -43,8 +43,10 @@ MACHINE=$(shell uname -m) ARCH= +ARCH2=-i386 ifeq ($(strip $(MACHINE)),x86_64) ARCH=.$(MACHINE) + ARCH2=-amd64 endif @@ -58,11 +60,11 @@ ifneq ($(wildcard /usr/lib/jvm/java),) INC_DIR_JVM = /usr/lib/jvm/java/include else - ifneq ($(wildcard /usr/lib/jvm/default-java),) - INC_DIR_JVM = /usr/lib/jvm/default-java/include + ifneq ($(wildcard /usr/lib/jvm/java-1.7.0-openjdk$(ARCH)),) + INC_DIR_JVM = /usr/lib/jvm/java-1.7.0-openjdk$(ARCH)/include else - ifneq ($(wildcard /usr/lib/jvm/java-1.7.0-openjdk$(ARCH)),) - INC_DIR_JVM = /usr/lib/jvm/java-1.7.0-openjdk$(ARCH)/include + ifneq ($(wildcard /usr/lib/jvm/java-1.7.0-openjdk$(ARCH2)),) + INC_DIR_JVM = /usr/lib/jvm/java-1.7.0-openjdk$(ARCH2)/include else ifneq ($(wildcard /usr/lib/jvm/java-1.7.0-openjdk),) INC_DIR_JVM = /usr/lib/jvm/java-1.7.0-openjdk/include @@ -70,10 +72,14 @@ ifneq ($(wildcard /usr/lib/jvm/java-1.6.0-openjdk$(ARCH)),) INC_DIR_JVM = /usr/lib/jvm/java-1.6.0-openjdk$(ARCH)/include else - ifneq ($(wildcard /usr/lib/jvm/java-1.6.0-openjdk),) - INC_DIR_JVM = /usr/lib/jvm/java-1.6.0-openjdk/include + ifneq ($(wildcard /usr/lib/jvm/java-1.6.0-openjdk$(ARCH2)),) + INC_DIR_JVM = /usr/lib/jvm/java-1.6.0-openjdk$(ARCH2)/include else - $(error No java detected) + ifneq ($(wildcard /usr/lib/jvm/java-1.6.0-openjdk),) + INC_DIR_JVM = /usr/lib/jvm/java-1.6.0-openjdk/include + else + $(error No java detected) + endif endif endif endif diff -Nru olsrd-0.6.6.1/lib/txtinfo/src/olsrd_txtinfo.c olsrd-0.6.6.2/lib/txtinfo/src/olsrd_txtinfo.c --- olsrd-0.6.6.1/lib/txtinfo/src/olsrd_txtinfo.c 2013-10-21 15:56:50.000000000 +0000 +++ olsrd-0.6.6.2/lib/txtinfo/src/olsrd_txtinfo.c 2014-06-02 10:15:27.000000000 +0000 @@ -301,8 +301,15 @@ 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)); + } if (0 < s) { requ[s] = 0; /* To print out neighbours only on the Freifunk Status @@ -329,6 +336,7 @@ if (0 != strstr(requ, "/ver")) send_what |= SIW_VERSION; } } + if ( send_what == 0 ) send_what = SIW_ALL; } diff -Nru olsrd-0.6.6.1/Makefile olsrd-0.6.6.2/Makefile --- olsrd-0.6.6.1/Makefile 2013-10-21 15:56:50.000000000 +0000 +++ olsrd-0.6.6.2/Makefile 2014-06-02 10:15:27.000000000 +0000 @@ -39,7 +39,7 @@ # Please also write a new version to: # gui/win32/Main/Frontend.rc (line 71, around "CAPTION [...]") # gui/win32/Inst/installer.nsi (line 57, around "MessageBox MB_YESNO [...]") -VERS = 0.6.6.1 +VERS = 0.6.6.2 TOPDIR = . INSTALLOVERWRITE ?= diff -Nru olsrd-0.6.6.1/src/lq_packet.c olsrd-0.6.6.2/src/lq_packet.c --- olsrd-0.6.6.1/src/lq_packet.c 2013-10-21 15:56:50.000000000 +0000 +++ olsrd-0.6.6.2/src/lq_packet.c 2014-06-02 10:15:27.000000000 +0000 @@ -360,8 +360,8 @@ /* * Initially, we want to put the complete lq_hello into the message. * For this flush the output buffer (if there are some bytes in). - * This is a hack/fix, which prevents message fragementation resulting - * in instable links. The ugly lq/genmsg code should be reworked anyhow. + * This is a hack/fix, which prevents message fragmentation resulting + * in unstable links. The ugly lq/genmsg code should be reworked anyhow. */ if (0 < net_output_pending(outif)) { for (i = 0; i <= MAX_NEIGH; i++) { @@ -408,7 +408,7 @@ req = olsr_cnf->ipsize + olsr_sizeof_hello_lqdata(); // no, we also need space for an info header, as this is the - // first neighbor with the current neighor type and link type + // first neighbor with the current neighbor type and link type if (is_first) req += sizeof(struct lq_hello_info_header); @@ -552,8 +552,8 @@ /* * Initially, we want to put the complete lq_tc into the message. * For this flush the output buffer (if there are some bytes in). - * This is a hack/fix, which prevents message fragementation resulting - * in instable links. The ugly lq/genmsg code should be reworked anyhow. + * This is a hack/fix, which prevents message fragmentation resulting + * in unstable links. The ugly lq/genmsg code should be reworked anyhow. */ if (0 < net_output_pending(outif)) { for (neigh = lq_tc->neigh; neigh != NULL; neigh = neigh->next) { diff -Nru olsrd-0.6.6.1/src/main.c olsrd-0.6.6.2/src/main.c --- olsrd-0.6.6.1/src/main.c 2013-10-21 15:56:50.000000000 +0000 +++ olsrd-0.6.6.2/src/main.c 2014-06-02 10:15:27.000000000 +0000 @@ -180,7 +180,7 @@ /* create file for lock */ lock_fd = open(lock_file_name, O_WRONLY | O_CREAT, S_IRWXU); - if (lock_fd == 0) { + if (lock_fd < 0) { if (noExitOnFail) { return -1; } @@ -733,6 +733,9 @@ *@param signo the signal that triggered this callback */ void olsr_reconfigure(int signo __attribute__ ((unused))) { +#ifndef _WIN32 + int errNr = errno; +#endif /* if we are started with -nofork, we do not want to go into the * background here. So we can simply stop on -HUP */ @@ -758,6 +761,9 @@ olsr_syslog(OLSR_LOG_INFO, "RECONFIGURING!\n"); } } +#ifndef _WIN32 + errno = errNr; +#endif olsr_shutdown(0); } #endif /* _WIN32 */ @@ -795,6 +801,9 @@ static void olsr_shutdown(int signo __attribute__ ((unused))) #endif /* _WIN32 */ { +#ifndef _WIN32 + int errNr = errno; +#endif struct interface *ifn; int exit_value; @@ -917,6 +926,9 @@ exit_value = olsr_cnf->exit_value; olsrd_free_cnf(olsr_cnf); +#ifndef _WIN32 + errno = errNr; +#endif exit(exit_value); } diff -Nru olsrd-0.6.6.1/src/neighbor_table.c olsrd-0.6.6.2/src/neighbor_table.c --- olsrd-0.6.6.1/src/neighbor_table.c 2013-10-21 15:56:50.000000000 +0000 +++ olsrd-0.6.6.2/src/neighbor_table.c 2014-06-02 10:15:27.000000000 +0000 @@ -385,15 +385,10 @@ /* The whole function doesn't do anything else. */ const int iplen = olsr_cnf->ip_version == AF_INET ? (INET_ADDRSTRLEN - 1) : (INET6_ADDRSTRLEN - 1); int idx; - struct tm * nowtm; - struct timeval now; - - (void)gettimeofday(&now, NULL); - nowtm = localtime((time_t *)&now.tv_sec); OLSR_PRINTF(1, - "\n--- %02d:%02d:%02d.%02d ------------------------------------------------ NEIGHBORS\n\n" - "%*s LQ NLQ SYM MPR MPRS will\n", nowtm->tm_hour, nowtm->tm_min, nowtm->tm_sec, (int)now.tv_usec / 10000, + "\n--- %s ------------------------------------------------ NEIGHBORS\n\n" + "%*s LQ NLQ SYM MPR MPRS will\n", olsr_wallclock_string(), iplen, "IP address"); for (idx = 0; idx < HASHSIZE; idx++) { diff -Nru olsrd-0.6.6.1/src/olsr_switch/main.c olsrd-0.6.6.2/src/olsr_switch/main.c --- olsrd-0.6.6.1/src/olsr_switch/main.c 2013-10-21 15:56:50.000000000 +0000 +++ olsrd-0.6.6.2/src/olsr_switch/main.c 2014-06-02 10:15:27.000000000 +0000 @@ -105,10 +105,14 @@ ohs_close(int signo __attribute__ ((unused))) #endif /* _WIN32 */ { +#ifndef _WIN32 + int errNr = errno; +#endif printf("OHS: exit\n"); - close(srv_socket); - +#ifndef _WIN32 + errno = errNr; +#endif exit(0); } diff -Nru olsrd-0.6.6.1/src/process_package.c olsrd-0.6.6.2/src/process_package.c --- olsrd-0.6.6.1/src/process_package.c 2013-10-21 15:56:50.000000000 +0000 +++ olsrd-0.6.6.2/src/process_package.c 2014-06-02 10:15:27.000000000 +0000 @@ -441,21 +441,15 @@ /* 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 @@ 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);