]> git.meshlink.io Git - meshlink/commitdiff
Revert "Guus please check this, I had to fix because my sptps where randomly failing...
authorSaverio Proto <zioproto@gmail.com>
Thu, 17 Apr 2014 22:06:18 +0000 (00:06 +0200)
committerSaverio Proto <zioproto@gmail.com>
Thu, 17 Apr 2014 22:06:18 +0000 (00:06 +0200)
This reverts commit 67103e5e08616983a9b81b88695c3c4cc38cc9ab.

src/net_packet.c

index a61ec0e07b8e4426dfbca9b22093c5a3aeb8dcf2..818dd3883b3f53ddaeea9a3e6c6743cb485eeeac 100644 (file)
@@ -562,7 +562,6 @@ bool receive_sptps_record(void *handle, uint8_t type, const char *data, uint16_t
        }
 
        int offset = (type & PKT_MAC) ? 0 : 14;
-       offset = 0; //TODO: This is just a dirty hack. We dont have IP packets inside libmeshlink
        if(type & PKT_COMPRESSED) {
                length_t ulen = uncompress_packet(inpkt.data + offset, (const uint8_t *)data, len, from->incompression);
                if(ulen < 0) {
@@ -577,6 +576,25 @@ bool receive_sptps_record(void *handle, uint8_t type, const char *data, uint16_t
                inpkt.len = len + offset;
        }
 
+       /* Generate the Ethernet packet type if necessary */
+       if(offset) {
+               switch(inpkt.data[14] >> 4) {
+                       case 4:
+                               inpkt.data[12] = 0x08;
+                               inpkt.data[13] = 0x00;
+                               break;
+                       case 6:
+                               inpkt.data[12] = 0x86;
+                               inpkt.data[13] = 0xDD;
+                               break;
+                       default:
+                               logger(DEBUG_TRAFFIC, LOG_ERR,
+                                                  "Unknown IP version %d while reading packet from %s (%s)",
+                                                  inpkt.data[14] >> 4, from->name, from->hostname);
+                               return false;
+               }
+       }
+
        receive_packet(from, &inpkt);
        return true;
 }