Fix some compile problems with BSD and win32
authorHenning Rogge <hrogge@googlemail.com>
Mon, 25 Jan 2010 19:05:31 +0000 (20:05 +0100)
committerHenning Rogge <hrogge@googlemail.com>
Mon, 25 Jan 2010 19:05:31 +0000 (20:05 +0100)
src/ipcalc.c
src/ipcalc.h
src/main.c

index 464a02a..269bf88 100644 (file)
 #include "defs.h"
 #include "ipcalc.h"
 
-/* ipv6 address ::ffff:0:0 */
-const uint8_t mapped_v4_gw[] = { 0,0,0,0,0,0,0,0,0,0,0xff,0xff,0,0,0,0};
+/* ipv6 prefix ::ffff:0:0/96 */
+const struct olsr_ip_prefix mapped_v4_gw =
+{
+    .prefix.v6.s6_addr = { 0,0,0,0,0,0,0,0,0,0,0xff,0xff,0,0,0,0 },
+    .prefix_len = 96
+};
 
 /* ipv6 prefix 2000::/3 */
 const struct olsr_ip_prefix ipv6_internet_route =
 {
-    { 0x20, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 }, 3
+    .prefix.v6.s6_addr = { 0x20, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 },
+    .prefix_len = 3
 };
 
 int
index 9ee7d0d..10a453c 100644 (file)
@@ -49,7 +49,7 @@
 #include <arpa/inet.h>
 #include <netinet/in.h>
 
-extern const uint8_t mapped_v4_gw[];
+extern const struct olsr_ip_prefix  mapped_v4_gw;
 extern const struct olsr_ip_prefix ipv6_internet_route;
 
 struct ipaddr_str {
@@ -183,8 +183,8 @@ olsr_ipv6_to_ipv4(const union olsr_ip_addr *ipv6, union olsr_ip_addr *ipv4) {
 
 static INLINE bool
 ip_prefix_is_mappedv4_gw(struct olsr_ip_prefix *prefix) {
-  return olsr_cnf->ip_version == AF_INET6 && prefix->prefix_len == 96
-      && memcmp(&prefix->prefix, mapped_v4_gw, sizeof(prefix->prefix)) == 0;
+  return olsr_cnf->ip_version == AF_INET6 && prefix->prefix_len == mapped_v4_gw.prefix_len
+      && memcmp(&prefix->prefix, &mapped_v4_gw.prefix, sizeof(prefix->prefix)) == 0;
 }
 
 extern bool ip_is_inetgw_prefix(union olsr_ip_addr *net, int prefixlen);
index 772a508..eaab344 100644 (file)
@@ -355,14 +355,14 @@ int main(int argc, char *argv[]) {
   if (olsr_cnf->lock_file) {
     strscpy(lock_file_name, olsr_cnf->lock_file, sizeof(lock_file_name));
   } else {
-    size_t len;
+    size_t l;
 #ifdef DEFAULT_LOCKFILE_PREFIX
     strscpy(lock_file_name, DEFAULT_LOCKFILE_PREFIX, sizeof(lock_file_name));
 #else
     strscpy(lock_file_name, conf_file_name, sizeof(lock_file_name));
 #endif
-    len = strlen(lock_file_name);
-    snprintf(&lock_file_name[len], sizeof(lock_file_name) - len, "-ipv%d.lock",
+    l = strlen(lock_file_name);
+    snprintf(&lock_file_name[l], sizeof(lock_file_name) - l, "-ipv%d.lock",
         olsr_cnf->ip_version == AF_INET ? 4 : 6);
   }