Commits

jhwoodyatt  committed f32e61f

Submit cf-0.1 release.

  • Participants
  • Parent commits 496f185

Comments (0)

Files changed (1)

File cf/cf_ip6_addr_p.c

 /*---------------------------------------------------------------------------*
   C MODULE  cf_ip6_addr_p.c
 
-  Copyright (c) 2003, James H. Woodyatt
+  Copyright (c) 2003-2004, James H. Woodyatt
   All rights reserved.
 
   Redistribution and use in source and binary forms, with or without
     CAMLparam1(v);
     long result;
     const u_int32_t* u32Ptr;
-    u_int32_t hash;
+    u_int32_t hash, x;
     
     u32Ptr = (const u_int32_t*) Cf_ip6_addr_val(v)->s6_addr;
     hash = 0;
-    hash ^= *u32Ptr++;
-    hash ^= *u32Ptr++;
-    hash ^= *u32Ptr++;
-    hash ^= *u32Ptr;
+    hash ^= (x = *u32Ptr++, ntohl(x));
+    hash ^= (x = *u32Ptr++, ntohl(x));
+    hash ^= (x = *u32Ptr++, ntohl(x));
+    hash ^= (x = *u32Ptr, ntohl(x));
     result = (long) hash;
     
     CAMLreturn(result);
     CAMLreturn(cf_ip6_addr_alloc(&addr6));
 }
 
+#ifndef IN6ADDR_NODELOCAL_ALLNODES_INIT
+#define IN6ADDR_NODELOCAL_ALLNODES_INIT \
+        {{{ 0xff, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
+            0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 }}}
+#endif
+
+#ifndef IN6ADDR_LINKLOCAL_ALLNODES_INIT
+#define IN6ADDR_LINKLOCAL_ALLNODES_INIT \
+        {{{ 0xff, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
+            0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 }}}
+#endif
+
+#ifndef IN6ADDR_LINKLOCAL_ALLROUTERS_INIT
+#define IN6ADDR_LINKLOCAL_ALLROUTERS_INIT \
+        {{{ 0xff, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
+            0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02 }}}
+#endif
+
+static const struct in6_addr cf_in6addr_nodelocal_allnodes =
+    IN6ADDR_NODELOCAL_ALLNODES_INIT;
+
+static const struct in6_addr cf_in6addr_linklocal_allnodes =
+    IN6ADDR_LINKLOCAL_ALLNODES_INIT;
+
+static const struct in6_addr cf_in6addr_linklocal_allrouters =
+IN6ADDR_LINKLOCAL_ALLROUTERS_INIT;
+
 static value cf_ip6_addr_unspecified_val = Val_unit;
 static value cf_ip6_addr_loopback_val = Val_unit;
 static value cf_ip6_addr_node_local_all_nodes_val = Val_unit;
     
     register_global_root(&cf_ip6_addr_node_local_all_nodes_val);
     cf_ip6_addr_node_local_all_nodes_val =
-        cf_ip6_addr_alloc(&in6addr_nodelocal_allnodes);
+        cf_ip6_addr_alloc(&cf_in6addr_nodelocal_allnodes);
     
     register_global_root(&cf_ip6_addr_link_local_all_nodes_val);
     cf_ip6_addr_link_local_all_nodes_val =
-        cf_ip6_addr_alloc(&in6addr_linklocal_allnodes);
+        cf_ip6_addr_alloc(&cf_in6addr_linklocal_allnodes);
     
     register_global_root(&cf_ip6_addr_link_local_all_routers_val);
     cf_ip6_addr_link_local_all_routers_val =
-        cf_ip6_addr_alloc(&in6addr_linklocal_allrouters);
+        cf_ip6_addr_alloc(&cf_in6addr_linklocal_allrouters);
 
     return Val_unit;
 }