} idata;
struct {
struct ip6_hdr v6hdr;
+ union {
+ struct icmp6_hdr v6icmphdr;
- #ifndef BE_SO_LAME_TO_SUPPRESS_SCTP
- struct sctphdr v6sctphdr;
- #endif
++ struct my_sctphdr v6sctphdr;
+ struct tcphdr v6tcphdr ;
+ struct udphdr v6udphdr ;
+ } adata;
+ struct icmp6_hdr v6icmphdr;
+ struct my_sctphdr v6sctphdr;
+ struct tcphdr v6tcphdr ;
+ struct udphdr v6udphdr ;
} ndata;
} udata;
} v4data6;
}
+/*
+ * Forward a message to the masquerading target, or drop it. This is done
+ * with non-6bed4 packets that are sent from a 6bed4peer node to its
+ * 6bed4router address; see is_mine() for the definition. The general idea
+ * is that the address that is to be masqueraded can later be reconstructed
+ * from the 6bed4peer's address.
+ */
+void handle_4to6_masquerading (ssize_t v4datalen) {
+ fprintf (stderr, "Traffic to 6bed4router may be fit for masquerading\n");
+ uint16_t *portpairs = NULL;
+ uint16_t numpairs = 0;
+ uint16_t port;
+ switch (v4v6nexthdr) {
- #ifndef BE_SO_LAME_TO_SUPPRESS_SCTP
+ case IPPROTO_SCTP:
+ portpairs = masqportpairs [0]; // 's'
+ numpairs = num_masqportpairs [0];
+ port = ntohs (v4v6sctpdstport);
+ break;
- #endif
+ case IPPROTO_TCP:
+ portpairs = masqportpairs [1]; // 't'
+ numpairs = num_masqportpairs [1];
+ port = ntohs (v4v6tcpdstport);
+ break;
+ case IPPROTO_UDP:
+ portpairs = masqportpairs [2]; // 'u'
+ numpairs = num_masqportpairs [2];
+ port = ntohs (v4v6udpdstport);
+ break;
+ default:
+ break;
+ }
+ fprintf (stderr, "DEBUG: Looking for masquerading of port %d in %d entries\n", port, numpairs);
+ while (numpairs-- > 0) {
+ if ((port >= portpairs [0]) && (port <= portpairs [1])) {
+ //
+ // Replace masqueraded address by 6bed4router's
+ fprintf (stderr, "DEBUG: Passing traffic to masquerading address number %d\n", portpairs [2]);
+ memcpy (v4dst6, masqhost [portpairs [2]], 16);
+ //
+ // Forward immediately, and return from this function
+printf ("Writing Masqueraded IPv6, result = %zd\n",
+ write (v6sox, &v4data6, sizeof (struct tun_pi) + v4datalen));
+ return;
+ }
+ portpairs += 3;
+ }
+ //
+ // Silently skip the offered packet
+}
+
+
/*
* Forward a message received over the 6bed4 Network over IPv6.
* Note that existing checksums will work well, as only the