SCTP support is so inconsistent that we define our own header overlays
authorRick van Rein <rick@openfortress.nl>
Fri, 22 Sep 2017 08:35:56 +0000 (22:35 -1000)
committerRick van Rein <rick@openfortress.nl>
Fri, 22 Sep 2017 08:35:56 +0000 (22:35 -1000)
6bed4router.c

index b2fa893..9a40d44 100644 (file)
 #include <netinet/icmp6.h>
 #include <arpa/inet.h>
 
-#ifndef BE_SO_LAME_TO_SUPPRESS_SCTP
-#include <linux/sctp.h>
-#endif
-
 #include <linux/if.h>
 #include <linux/if_tun.h>
 #include <linux/if_ether.h>
 
 /* Global variables */
 
+/* SCTP structures are far from standardised, so we define our own header */
+struct my_sctphdr {
+       uint16_t source, dest;
+       uint32_t vtag;
+       uint32_t checksum;
+};
+
 char *program;
 
 int v4sox = -1;
@@ -110,9 +113,7 @@ struct {
                struct {
                        struct ip6_hdr v6hdr;
                        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 ;
                } ndata;
@@ -598,13 +599,11 @@ void handle_4to6_plain_unicast (ssize_t v4datalen) {
                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 (v4v6srcport);
+                       port = ntohs (v4v6sctpsrcport);
                        break;
-#endif
                case IPPROTO_TCP:
                        portpairs = masqportpairs [1];  // 't'
                        numpairs  = num_masqportpairs [1];