Removed port0-hack from is_6bed4() -- conceptual confusion with negation
authorRick van Rein <rick@openfortress.nl>
Fri, 15 Sep 2017 13:29:53 +0000 (15:29 +0200)
committerRick van Rein <rick@openfortress.nl>
Fri, 15 Sep 2017 13:29:53 +0000 (15:29 +0200)
Take care: The option LOCAL_OVERRIDES_PORT0 is needed to enable port0 override

6bed4router.c
nonstd.h [new file with mode: 0644]
nonstd.h.in

index 0b634e7..5f77672 100644 (file)
@@ -340,10 +340,25 @@ size_t icmp6_dest_linkaddr (size_t optidx) {
 
 
 /*
+ * Test if an address is a local override.  This function is compiled-in
+ * to support hosts with a /64 from their own ISP and nothing more; they
+ * need to access local IPv6 addresses.  We rely on the 6bed4 port being
+ * 0 to decide that an address cannot be anything but a local override.
+ * Define LOCAL_OVERRIDES_PORT0 to enable this feature.
+ */
+#ifdef LOCAL_OVERRIDES_PORT0
+static inline bool is_local_override (struct in6_addr *ip6) {
+       return ip6->s6addr [6] == 0;
+}
+#else
+#define is_local_override (ip6) false
+#endif
+
+/*
  * Test if the provided IPv6 address matches the prefix used for 6bed4.
  */
 static inline bool is_6bed4 (struct in6_addr *ip6) {
-       return memcmp (&v6listen, ip6->s6_addr, 8) == 0 && (ip6->s6_addr[12] != 0 || ip6->s6_addr[13] != 0);
+       return memcmp (&v6listen, ip6->s6_addr, 8) == 0;
 }
 
 
@@ -563,7 +578,9 @@ void handle_4to6 (void) {
        } else if ((v4dst6->s6_addr [0] != 0xff) && !(v4dst6->s6_addr [8] & 0x01)) {
                //
                // Plain Unicast
-               if (validate_originator (&v4name, v4src6)) {
+               if (is_local_override (v4dst6)) {
+                       handle_4to6_plain_unicast (buflen);
+               } else if (validate_originator (&v4name, v4src6)) {
                        if (v4v6hoplimit-- <= 1) {
                                return;
                        }
diff --git a/nonstd.h b/nonstd.h
new file mode 100644 (file)
index 0000000..7e5470d
--- /dev/null
+++ b/nonstd.h
@@ -0,0 +1,41 @@
+/* The error line below is here to satisfy RFC requirements: We cannot
+ * distribute code that has non-standard protocol numbers built in as
+ * defaults.  So you must read this and understand that you are running
+ * a non-compliant, experimental code version.  When you agree, please
+ * change the error directives to warnings -- then, the code will build.
+ *
+ * Sincerely, Rick van Rein, OpenFortress.
+ */
+
+#error "Build uses experimental Neighbor Discovery Option Type 253 for Destination Link-Layer Address"
+
+#define ND_OPT_DESTINATION_LINKADDR 253
+
+
+#error "Build uses experimental UDP port number 27629 or 0x6bed"
+
+#define UDP_PORT_6BED4 25788
+
+
+#warning "Build uses temporary IPv4 address information"
+
+#define SERVER_6BED4_IPV4_TXT                  "145.100.190.242"
+#define SERVER_6BED4_IPV4_INT32                        ( (145L << 24) | (100L << 16) | (190L << 8) | 242L )
+#define SERVER_6BED4_IPV4_INT0                 145
+#define SERVER_6BED4_IPV4_INT1                 100
+#define SERVER_6BED4_IPV4_INT2                 190
+#define SERVER_6BED4_IPV4_INT3                 242
+#define SERVER_6BED4_IPV4_BINSTR               "\x91\x64\xbe\xf2"
+
+#define SERVER_6BED4_PORT_TXT                  "25788"
+#define SERVER_6BED4_PORT_BINSTR               "\xbc\x64"
+
+#define SERVER_6BED4_IPV4_PORT_TXT             "145.100.190.242:27629"
+#define SERVER_6BED4_PORT_IPV4_ADDRSTR         "\xbe\x64\x91\x64\xbe\xf2"
+#define SERVER_6BED4_PORT_IPV4_MACSTR          "\xbc\x64\x91\x64\xbe\xf2"
+
+/* Define LOCAL_OVERRIDES_PORT0 to forcefully detect 6bed4 port 0 as an
+ * override to a local address.  This is used when a host uses its own /64
+ * and has no other addresses available.
+ */
+#define LOCAL_OVERRIDES_PORT0 yes
index e3ab958..53bc1be 100644 (file)
@@ -34,3 +34,8 @@
 #define SERVER_6BED4_PORT_IPV4_ADDRSTR         "\xbe\x64\x91\x64\xbe\xf2"
 #define SERVER_6BED4_PORT_IPV4_MACSTR          "\xbc\x64\x91\x64\xbe\xf2"
 
+/* Define LOCAL_OVERRIDES_PORT0 to forcefully detect 6bed4 port 0 as an
+ * override to a local address.  This is used when a host uses its own /64
+ * and has no other addresses available.
+ */
+// #define LOCAL_OVERRIDES_PORT0 yes