Browse Source

Change message->bytes to message->msgbytes in prep for privatizing it

Caleb James DeLisle 3 years ago
parent
commit
8e3011cb6e
61 changed files with 283 additions and 283 deletions
  1. 10 10
      admin/Admin.c
  2. 5 5
      benc/serialization/json/JsonBencMessageReader.c
  3. 4 4
      benc/serialization/standard/BencMessageWriter.c
  4. 2 2
      client/AdminClient.c
  5. 1 1
      client/cjdroute2.c
  6. 9 9
      crypto/CryptoAuth.c
  7. 6 6
      crypto/Sign.c
  8. 1 1
      crypto/Sign_admin.c
  9. 3 3
      crypto/test/CryptoAuthFuzz.c
  10. 2 2
      crypto/test/CryptoAuth_randnonce_test.c
  11. 4 4
      crypto/test/CryptoAuth_test.c
  12. 4 4
      crypto/test/CryptoAuth_unit_test.c
  13. 4 4
      crypto/test/TestCa.c
  14. 4 4
      dht/Pathfinder.c
  15. 1 1
      dht/ReplyModule.c
  16. 2 2
      dht/SerializationModule.c
  17. 4 4
      interface/ETHInterface_darwin.c
  18. 4 4
      interface/ETHInterface_linux.c
  19. 5 5
      interface/FramingIface.c
  20. 1 1
      interface/UDPInterface.c
  21. 1 1
      interface/addressable/AddrIface.h
  22. 2 2
      interface/addressable/AddrIfaceMuxer.c
  23. 3 3
      interface/addressable/PacketHeaderToUDPAddrIface.c
  24. 5 5
      interface/test/FramingIface_fuzz_test.c
  25. 3 3
      interface/tuntap/AndroidWrapper.c
  26. 6 6
      interface/tuntap/BSDMessageTypeWrapper.c
  27. 3 3
      interface/tuntap/NDPServer.c
  28. 3 3
      interface/tuntap/TUNInterface_sunos.c
  29. 3 3
      interface/tuntap/TUNMessageType.h
  30. 1 1
      interface/tuntap/test/TUNInterface_ipv4_root_test.c
  31. 1 1
      interface/tuntap/test/TUNTools.c
  32. 2 2
      interface/tuntap/windows/TAPInterface.c
  33. 13 13
      net/ControlHandler.c
  34. 2 2
      net/EventEmitter.c
  35. 10 10
      net/InterfaceController.c
  36. 8 8
      net/SessionManager.c
  37. 16 16
      net/SwitchPinger.c
  38. 5 5
      net/TUNAdapter.c
  39. 9 9
      net/UpperDistributor.c
  40. 1 1
      node_build/make.js
  41. 10 10
      subnode/LinkState.h
  42. 2 2
      subnode/MsgCore.c
  43. 6 6
      subnode/ReachabilityAnnouncer.c
  44. 3 3
      subnode/SubnodePathfinder.c
  45. 1 1
      subnode/test/LinkState_test.c
  46. 4 4
      switch/SwitchCore.c
  47. 3 3
      test/Beacon_test.c
  48. 4 4
      test/Main_fuzz_test.c
  49. 3 3
      test/TestFramework.c
  50. 17 17
      tunnel/IpTunnel.c
  51. 17 17
      tunnel/test/IpTunnel_test.c
  52. 5 5
      util/events/libuv/Pipe.c
  53. 5 5
      util/events/libuv/UDPAddrIface.c
  54. 2 2
      util/platform/netdev/NetPlatform_darwin.c
  55. 3 3
      util/platform/netdev/NetPlatform_linux.c
  56. 1 1
      util/test/Base10_test.c
  57. 2 2
      util/test/Process_test.c
  58. 1 1
      util/test/Seccomp_test.c
  59. 7 7
      wire/Announce.h
  60. 4 4
      wire/Message.c
  61. 10 10
      wire/Message.h

+ 10 - 10
admin/Admin.c

@@ -131,7 +131,7 @@ static struct Error_s sendBenc(Dict* message,
     Message_reset(admin->tempSendMsg);
     Er_assert(BencMessageWriter_write(message, admin->tempSendMsg));
     struct Message* msg = Message_new(0, Message_getLength(admin->tempSendMsg) + 32, alloc);
-    Er_assert(Message_epush(msg, admin->tempSendMsg->bytes, Message_getLength(admin->tempSendMsg)));
+    Er_assert(Message_epush(msg, admin->tempSendMsg->msgbytes, Message_getLength(admin->tempSendMsg)));
     Message_setAssociatedFd(msg, fd);
     return sendMessage(msg, dest, admin);
 }
@@ -234,7 +234,7 @@ static inline bool authValid(Dict* message, struct Message* messageBytes, struct
         return false;
     }
 
-    uint8_t* hashPtr = CString_strstr(messageBytes->bytes, submittedHash->bytes);
+    uint8_t* hashPtr = CString_strstr(messageBytes->msgbytes, submittedHash->bytes);
 
     if (!hashPtr || !admin->password) {
         return false;
@@ -246,7 +246,7 @@ static inline bool authValid(Dict* message, struct Message* messageBytes, struct
     crypto_hash_sha256(hash, passAndCookie, CString_strlen((char*) passAndCookie));
     Hex_encode(hashPtr, 64, hash, 32);
 
-    crypto_hash_sha256(hash, messageBytes->bytes, Message_getLength(messageBytes));
+    crypto_hash_sha256(hash, messageBytes->msgbytes, Message_getLength(messageBytes));
     Hex_encode(hashPtr, 64, hash, 32);
     int res = crypto_verify_32(hashPtr, submittedHash->bytes);
     res |= crypto_verify_32(hashPtr + 32, submittedHash->bytes + 32);
@@ -421,18 +421,18 @@ static void handleMessage(struct Message* message,
                           struct Admin_pvt* admin)
 {
     if (Defined(Log_KEYS)) {
-        uint8_t lastChar = message->bytes[Message_getLength(message) - 1];
-        message->bytes[Message_getLength(message) - 1] = '\0';
+        uint8_t lastChar = message->msgbytes[Message_getLength(message) - 1];
+        message->msgbytes[Message_getLength(message) - 1] = '\0';
         Log_keys(admin->logger, "Got message from [%s] [%s]",
-                 Sockaddr_print(src, alloc), message->bytes);
-        message->bytes[Message_getLength(message) - 1] = lastChar;
+                 Sockaddr_print(src, alloc), message->msgbytes);
+        message->msgbytes[Message_getLength(message) - 1] = lastChar;
     }
 
     // handle non empty message data
     if (Message_getLength(message) > Admin_MAX_REQUEST_SIZE) {
         #define TOO_BIG "d5:error16:Request too big.e"
         #define TOO_BIG_STRLEN (sizeof(TOO_BIG) - 1)
-        Bits_memcpy(message->bytes, TOO_BIG, TOO_BIG_STRLEN);
+        Bits_memcpy(message->msgbytes, TOO_BIG, TOO_BIG_STRLEN);
         Er_assert(Message_truncate(message, TOO_BIG_STRLEN));
         sendMessage(message, src, admin);
         return;
@@ -445,7 +445,7 @@ static void handleMessage(struct Message* message,
         Log_warn(admin->logger,
                  "Unparsable data from [%s] content: [%s] error: [%s]",
                  Sockaddr_print(src, alloc),
-                 Hex_print(message->bytes, Message_getLength(message), alloc),
+                 Hex_print(message->msgbytes, Message_getLength(message), alloc),
                  err);
         return;
     }
@@ -453,7 +453,7 @@ static void handleMessage(struct Message* message,
     if (Message_getLength(message)) {
         Log_warn(admin->logger,
                  "Message from [%s] contained garbage after byte [%d] content: [%s]",
-                 Sockaddr_print(src, alloc), Message_getLength(message), message->bytes);
+                 Sockaddr_print(src, alloc), Message_getLength(message), message->msgbytes);
         return;
     }
 

+ 5 - 5
benc/serialization/json/JsonBencMessageReader.c

@@ -36,7 +36,7 @@ struct Context {
 
 static int getColumn(struct Context* ctx)
 {
-    return (uintptr_t) ctx->msg->bytes - ctx->beginningLastLine;
+    return (uintptr_t) ctx->msg->msgbytes - ctx->beginningLastLine;
 }
 
 #define ERROR0(ctx, message) \
@@ -51,15 +51,15 @@ static int getColumn(struct Context* ctx)
 static Er_DEFUN(uint8_t peak(struct Context* ctx))
 {
     if (!Message_getLength(ctx->msg)) { ERROR0(ctx, "Out of content while reading"); }
-    Er_ret(ctx->msg->bytes[0]);
+    Er_ret(ctx->msg->msgbytes[0]);
 }
 
 static Er_DEFUN(void skip(struct Context* ctx, int num))
 {
     if (num > Message_getLength(ctx->msg)) { ERROR0(ctx, "Out of content while reading"); }
     for (int i = 0; i < num; i++) {
-        if (ctx->msg->bytes[i] == '\n') {
-            ctx->beginningLastLine = (uintptr_t) &ctx->msg->bytes[i];
+        if (ctx->msg->msgbytes[i] == '\n') {
+            ctx->beginningLastLine = (uintptr_t) &ctx->msg->msgbytes[i];
             ctx->line++;
         }
     }
@@ -314,7 +314,7 @@ Er_DEFUN(Dict* JsonBencMessageReader_read(
         .alloc = alloc,
         .lax = lax,
         .line = 1,
-        .beginningLastLine = (uintptr_t) msg->bytes
+        .beginningLastLine = (uintptr_t) msg->msgbytes
     };
     Er_ret( Er(parseDict(&ctx)) );
 }

+ 4 - 4
benc/serialization/standard/BencMessageWriter.c

@@ -90,15 +90,15 @@ Er_DEFUN(void BencMessageWriter_write(Dict* toWrite, struct Message* msg))
     Er(writeDict(toWrite, msg));
 
     // lucky
-    if (!((uintptr_t)msg->bytes % 8)) { Er_ret(); }
+    if (!((uintptr_t)msg->msgbytes % 8)) { Er_ret(); }
 
     char d = Er(Message_epop8(msg));
     Assert_true(d == 'd');
-    Assert_true(msg->bytes[0] != 'e' && "Can't serialize empty messages");
-    Assert_true(msg->bytes[0] >= '1' && msg->bytes[0] <= '9');
+    Assert_true(msg->msgbytes[0] != 'e' && "Can't serialize empty messages");
+    Assert_true(msg->msgbytes[0] >= '1' && msg->msgbytes[0] <= '9');
 
     // put the message into alignment by padding out the number with leading zeros :)
-    do { Er(Message_epush8(msg, '0')); } while ((uintptr_t)msg->bytes % 8);
+    do { Er(Message_epush8(msg, '0')); } while ((uintptr_t)msg->msgbytes % 8);
 
     Er(Message_epop8(msg));
     Er(Message_epush8(msg, 'd'));

+ 2 - 2
client/AdminClient.c

@@ -93,7 +93,7 @@ static int calculateAuth(Dict* message,
     Er_assert(BencMessageWriter_write(message, msg));
 
     // calculate the hash of the message with the password hash
-    crypto_hash_sha256(hash, msg->bytes, Message_getLength(msg));
+    crypto_hash_sha256(hash, msg->msgbytes, Message_getLength(msg));
 
     // swap the hash of the message with the password hash into the location
     // where the password hash was.
@@ -157,7 +157,7 @@ static Iface_DEFUN receiveMessage(struct Message* msg, struct Iface* addrIface)
         ? AdminClient_MAX_MESSAGE_SIZE
         : Message_getLength(msg);
     Bits_memset(req->res.messageBytes, 0, AdminClient_MAX_MESSAGE_SIZE);
-    Bits_memcpy(req->res.messageBytes, msg->bytes, len);
+    Bits_memcpy(req->res.messageBytes, msg->msgbytes, len);
     done(req, AdminClient_Error_NONE);
     return Error(NONE);
 }

+ 1 - 1
client/cjdroute2.c

@@ -676,7 +676,7 @@ int cjdroute2_main(int argc, char** argv)
     // and if the old parser fails or the parsed content contains "version": 2,
     // fail to launch
     struct Message* confMsg = readToMsg(stdin, allocator);
-    struct Reader* confReader = ArrayReader_new(confMsg->bytes, Message_getLength(confMsg), allocator);
+    struct Reader* confReader = ArrayReader_new(confMsg->msgbytes, Message_getLength(confMsg), allocator);
     Dict _config;
     Dict* config = &_config;
     const char* err = JsonBencMessageReader_readNoExcept(confMsg, allocator, &config, false);

+ 9 - 9
crypto/CryptoAuth.c

@@ -187,7 +187,7 @@ static inline Gcc_USE_RET int decryptRndNonce(const uint8_t nonce[24],
         return -1;
     }
     Assert_true(Message_getPadding(msg) >= 16);
-    uint8_t* startAt = msg->bytes - 16;
+    uint8_t* startAt = msg->msgbytes - 16;
     uint8_t paddingSpace[16];
     Bits_memcpy(paddingSpace, startAt, 16);
     Bits_memset(startAt, 0, 16);
@@ -217,7 +217,7 @@ static inline void encryptRndNonce(const uint8_t nonce[24],
                                    const uint8_t secret[32])
 {
     Assert_true(Message_getPadding(msg) >= 32);
-    uint8_t* startAt = msg->bytes - 32;
+    uint8_t* startAt = msg->msgbytes - 32;
     // This function trashes 16 bytes of the padding so we will put it back
     uint8_t paddingSpace[16];
     Bits_memcpy(paddingSpace, startAt, 16);
@@ -345,7 +345,7 @@ static void encryptHandshake(struct Message* message,
 {
     Er_assert(Message_eshift(message, CryptoHeader_SIZE));
 
-    struct CryptoHeader* header = (struct CryptoHeader*) message->bytes;
+    struct CryptoHeader* header = (struct CryptoHeader*) message->msgbytes;
 
     // garbage the auth challenge and set the nonce which follows it
     Random_bytes(session->context->rand, (uint8_t*) &header->auth,
@@ -459,7 +459,7 @@ static void encryptHandshake(struct Message* message,
         uint8_t nonceHex[49];
         Hex_encode(nonceHex, 49, header->handshakeNonce, 24);
         uint8_t cipherHex[65];
-        printHexKey(cipherHex, message->bytes);
+        printHexKey(cipherHex, message->msgbytes);
         Log_keys(session->context->logger,
                   "Encrypting message with:\n"
                   "    nonce: %s\n"
@@ -485,7 +485,7 @@ static int encryptPacket(struct CryptoAuth_Session_pvt* session, struct Message*
         reset(session);
     }
 
-    Assert_true(!((uintptr_t)msg->bytes % 4) || !"alignment fault");
+    Assert_true(!((uintptr_t)msg->msgbytes % 4) || !"alignment fault");
 
     // nextNonce 0: sending hello, we are initiating connection.
     // nextNonce 1: sending another hello, nothing received yet.
@@ -644,7 +644,7 @@ static enum CryptoAuth_DecryptErr decryptHandshake(struct CryptoAuth_Session_pvt
         uint8_t nonceHex[49];
         Hex_encode(nonceHex, 49, header->handshakeNonce, 24);
         uint8_t cipherHex[65];
-        printHexKey(cipherHex, message->bytes);
+        printHexKey(cipherHex, message->msgbytes);
         Log_keys(session->context->logger,
                   "Decrypting message with:\n"
                   "    nonce: %s\n"
@@ -830,14 +830,14 @@ static enum CryptoAuth_DecryptErr decryptHandshake(struct CryptoAuth_Session_pvt
 static enum CryptoAuth_DecryptErr decryptPacket(struct CryptoAuth_Session_pvt* session,
                                                 struct Message* msg)
 {
-    struct CryptoHeader* header = (struct CryptoHeader*) msg->bytes;
+    struct CryptoHeader* header = (struct CryptoHeader*) msg->msgbytes;
 
     if (Message_getLength(msg) < 20) {
         cryptoAuthDebug0(session, "DROP runt");
         return CryptoAuth_DecryptErr_RUNT;
     }
     Assert_true(Message_getPadding(msg) >= 12 || "need at least 12 bytes of padding in incoming message");
-    Assert_true(!((uintptr_t)msg->bytes % 4) || !"alignment fault");
+    Assert_true(!((uintptr_t)msg->msgbytes % 4) || !"alignment fault");
     Assert_true(!(Message_getCapacity(msg) % 4) || !"length fault");
 
     Er_assert(Message_eshift(msg, -4));
@@ -1057,7 +1057,7 @@ static Iface_DEFUN ciphertextMsg(struct Message* msg, struct Iface* iface)
         return Error(RUNT);
     }
     uint8_t firstSixteen[16];
-    Bits_memcpy(firstSixteen, msg->bytes, 16);
+    Bits_memcpy(firstSixteen, msg->msgbytes, 16);
     enum CryptoAuth_DecryptErr e = decryptPacket(sess, msg);
     if (e == CryptoAuth_DecryptErr_NONE) {
         Er_assert(Message_epush32be(msg, CryptoAuth_DecryptErr_NONE));

+ 6 - 6
crypto/Sign.c

@@ -146,10 +146,10 @@ void Sign_signMsg(uint8_t keyPair[64], struct Message* msg, struct Random* rand)
     // hash message + secret number, this is the same as crypto_sign()
     // If there isn't enough space in the message, we abort the process
     Er_assert(Message_epush(msg, &az[32], 32));
-    crypto_hash_sha512(r, msg->bytes, Message_getLength(msg));
+    crypto_hash_sha512(r, msg->msgbytes, Message_getLength(msg));
 
     // Replace secret number with public key, this is the same as crypto_sign()
-    Bits_memcpy(msg->bytes, &keyPair[32], 32);
+    Bits_memcpy(msg->msgbytes, &keyPair[32], 32);
 
     // Now we scalar multiply the hash of the message + unique secret and push that
     // to the message, nothing different from crypto_sign()
@@ -157,14 +157,14 @@ void Sign_signMsg(uint8_t keyPair[64], struct Message* msg, struct Random* rand)
     ge_scalarmult_base(&R,r);
     // If there isn't enough space in the message, we abort the process
     Er_assert(Message_eshift(msg, 32));
-    ge_p3_tobytes(msg->bytes,&R);
+    ge_p3_tobytes(msg->msgbytes,&R);
 
     // This final step is the same as crypto_sign()
     // Overwrite the public key which the verifier will replace in order to recompute
     // the hash.
-    crypto_hash_sha512(hram, msg->bytes, Message_getLength(msg));
+    crypto_hash_sha512(hram, msg->msgbytes, Message_getLength(msg));
     sc_reduce(hram);
-    sc_muladd(&msg->bytes[32], hram, az, r);
+    sc_muladd(&msg->msgbytes[32], hram, az, r);
 }
 
 // For verify, we're just using the normal sign_open() function, nothing special here.
@@ -174,7 +174,7 @@ int Sign_verifyMsg(uint8_t publicSigningKey[32], struct Message* msg)
     struct Allocator* alloc = Allocator_child(Message_getAlloc(msg));
     uint8_t* buff = Allocator_malloc(alloc, Message_getLength(msg));
     unsigned long long ml = Message_getLength(msg);
-    int ret = crypto_sign_ed25519_open(buff, &ml, msg->bytes, Message_getLength(msg), publicSigningKey);
+    int ret = crypto_sign_ed25519_open(buff, &ml, msg->msgbytes, Message_getLength(msg), publicSigningKey);
     Allocator_free(alloc);
     if (ret) {
         return -1;

+ 1 - 1
crypto/Sign_admin.c

@@ -93,7 +93,7 @@ static void sign(Dict* args, void* vctx, String* txid, struct Allocator* request
         Er_assert(Message_epush(msg, msgHash->bytes, msgHash->len));
         Sign_signMsg(ctx->signingKeypair, msg, ctx->rand);
         uint8_t signB64[128];
-        Assert_true(Base32_encode(signB64, 128, msg->bytes, 64) > 0);
+        Assert_true(Base32_encode(signB64, 128, msg->msgbytes, 64) > 0);
         String* sig = String_printf(requestAlloc, "%s_%s", ctx->pubSigningKey, signB64);
         Dict_putStringC(out, "signature", sig, requestAlloc);
         Dict_putStringCC(out, "error", "none", requestAlloc);

+ 3 - 3
crypto/test/CryptoAuthFuzz.c

@@ -117,7 +117,7 @@ static bool isMutableBit(int bitNum)
 static void flipBit(struct Message* msg, uint32_t bitNum)
 {
     Assert_true(Message_getLength(msg) * 8 > (int)bitNum);
-    msg->bytes[bitNum / 8] ^= 128 >> (bitNum % 8);
+    msg->msgbytes[bitNum / 8] ^= 128 >> (bitNum % 8);
 }
 
 static void flipMutableBit(struct Context* ctx, struct Node* from, struct Message* msg)
@@ -279,7 +279,7 @@ static Iface_DEFUN afterDecrypt(struct Message* msg, struct Iface* iface)
     enum CryptoAuth_DecryptErr e = Er_assert(Message_epop32h(msg));
     if (!e) {
         Assert_true(!flippedImmutable);
-        Assert_true(Message_getLength(msg) == 4 && !Bits_memcmp(msg->bytes, "hey", 4));
+        Assert_true(Message_getLength(msg) == 4 && !Bits_memcmp(msg->msgbytes, "hey", 4));
         if (to == &to->ctx->nodeB) {
             // 1/10 chance the node decides not to reply.
             if (maybe(to->ctx, 10)) {
@@ -340,7 +340,7 @@ void CryptoAuthFuzz_main(void* vctx, struct Message* fuzz)
     struct Context* ctx = Identity_check((struct Context*) vctx);
 
     // This is not ideal, but this test was already written before AFL.
-    RandomSeed_t* rs = DeterminentRandomSeed_new(ctx->alloc, fuzz->bytes);
+    RandomSeed_t* rs = DeterminentRandomSeed_new(ctx->alloc, fuzz->msgbytes);
     ctx->rand = Random_newWithSeed(ctx->alloc, NULL, rs, NULL);
 
     if (maybe(ctx, 2)) {

+ 2 - 2
crypto/test/CryptoAuth_randnonce_test.c

@@ -40,14 +40,14 @@ static void encryptRndNonceTest()
 
     uint8_t* expected = (uint8_t*) "1391ac5d03ba9f7099bffbb6e6c69d67ae5bd79391a5b94399b293dc";
     uint8_t output[57];
-    Hex_encode(output, 57, m.bytes, Message_getLength(&m));
+    Hex_encode(output, 57, m.msgbytes, Message_getLength(&m));
 
     printf("\n%s\n%s\n", (char*) expected, (char*) output);
     Assert_true(!Bits_memcmp(expected, output, 56));
 
     Assert_true(!CryptoAuth_decryptRndNonce(nonce, &m, secret));
     Assert_true(Message_getLength(&m) == HELLOWORLDLEN
-        && !Bits_memcmp(m.bytes, HELLOWORLDLOWER, Message_getLength(&m)));
+        && !Bits_memcmp(m.msgbytes, HELLOWORLDLOWER, Message_getLength(&m)));
 }
 
 int main()

+ 4 - 4
crypto/test/CryptoAuth_test.c

@@ -84,13 +84,13 @@ static Iface_DEFUN afterDecrypt(struct Message* msg, struct Iface* if1)
         if (e) {
             return Error(NONE);
         }
-        Assert_failure("expected <NULL>, got [%s](%d)\n", msg->bytes, Message_getLength(msg));
+        Assert_failure("expected <NULL>, got [%s](%d)\n", msg->msgbytes, Message_getLength(msg));
     }
     if ((int)CString_strlen(n->expectPlaintext) != Message_getLength(msg) ||
-        CString_strncmp(msg->bytes, n->expectPlaintext, Message_getLength(msg)))
+        CString_strncmp(msg->msgbytes, n->expectPlaintext, Message_getLength(msg)))
     {
         Assert_failure("expected [%s](%d), got [%s](%d)\n",
-            n->expectPlaintext, (int)CString_strlen(n->expectPlaintext), msg->bytes, Message_getLength(msg));
+            n->expectPlaintext, (int)CString_strlen(n->expectPlaintext), msg->msgbytes, Message_getLength(msg));
     }
     n->expectPlaintext = NULL;
     return Error(NONE);
@@ -160,7 +160,7 @@ static struct Message* encryptMsg(struct Context* ctx,
     struct Allocator* alloc = Allocator_child(ctx->alloc);
     int len = (((CString_strlen(x)+1) / 8) + 1) * 8;
     struct Message* msg = Message_new(len, CryptoHeader_SIZE + 32, alloc);
-    CString_strcpy(msg->bytes, x);
+    CString_strcpy(msg->msgbytes, x);
     Er_assert(Message_truncate(msg, CString_strlen(x)));
     //msg->bytes[Message_getLength(msg)] = 0;
     struct Error_s e = Iface_send(&n->plaintext, msg);

+ 4 - 4
crypto/test/CryptoAuth_unit_test.c

@@ -97,7 +97,7 @@ static void testHello(uint8_t* password, uint8_t* expectedOutput, enum TestCa_Co
 
     Iface_send(&ctx->plaintext, msg);
 
-    char* actual = Hex_print(msg->bytes, Message_getLength(msg), alloc);
+    char* actual = Hex_print(msg->msgbytes, Message_getLength(msg), alloc);
     if (CString_strcmp(actual, expectedOutput)) {
         Assert_failure("Test failed.\n"
                        "Expected %s\n"
@@ -134,7 +134,7 @@ static void receiveHelloWithNoAuth(enum TestCa_Config cfg)
     struct Allocator* alloc = MallocAllocator_new(1<<20);
     struct Context* ctx = setUp(PRIVATEKEY, herPublic, NULL, alloc, cfg);
     struct Message* msg = Message_new(132, 32, alloc);
-    Assert_true(Hex_decode(msg->bytes, Message_getLength(msg),
+    Assert_true(Hex_decode(msg->msgbytes, Message_getLength(msg),
         "0000000000ffffffffffffff7fffffffffffffffffffffffffffffffffffffff"
         "ffffffffffffffff847c0d2c375234f365e660955187a3735a0f7613d1609d3a"
         "6a4d8c53aeaa5a22ea9cf275eee0185edf7f211192f12e8e642a325ed76925fe"
@@ -146,7 +146,7 @@ static void receiveHelloWithNoAuth(enum TestCa_Config cfg)
     Assert_true(!err);
 
     Assert_true(Message_getLength(msg) == HELLOWORLDLEN);
-    Assert_true(Bits_memcmp(HELLOWORLD, msg->bytes, HELLOWORLDLEN) == 0);
+    Assert_true(Bits_memcmp(HELLOWORLD, msg->msgbytes, HELLOWORLDLEN) == 0);
     Allocator_free(alloc);
     //printf("bytes=%s  length=%u\n", finalOut->bytes, finalOut->length);
 }
@@ -172,7 +172,7 @@ static void repeatHello(enum TestCa_Config cfg)
 
     Iface_send(&ctx->plaintext, msg);
 
-    char* actual = Hex_print(msg->bytes, Message_getLength(msg), alloc);
+    char* actual = Hex_print(msg->msgbytes, Message_getLength(msg), alloc);
     if (CString_strcmp(actual, expectedOutput)) {
         Assert_failure("Test failed.\n"
                        "Expected %s\n"

+ 4 - 4
crypto/test/TestCa.c

@@ -204,12 +204,12 @@ static bool check(Message_t *msg, TestCa_Session_pvt_t* sess)
             Assert_failure("Message_getLength(msg) != m2->length: %d != %d",
                 Message_getLength(msg), Message_getLength(m2));
         }
-        if (Bits_memcmp(msg->bytes, m2->bytes, Message_getLength(msg))) {
-            const char* msgH = Hex_print(msg->bytes, Message_getLength(msg), Message_getAlloc(msg));
-            const char* m2H = Hex_print(m2->bytes, Message_getLength(m2), Message_getAlloc(m2));
+        if (Bits_memcmp(msg->msgbytes, m2->msgbytes, Message_getLength(msg))) {
+            const char* msgH = Hex_print(msg->msgbytes, Message_getLength(msg), Message_getAlloc(msg));
+            const char* m2H = Hex_print(m2->msgbytes, Message_getLength(m2), Message_getAlloc(m2));
             Assert_failure("msg->bytes != m2->bytes:\n%s\n%s\n", msgH, m2H);
         }
-        Assert_true(!Bits_memcmp(msg->bytes, m2->bytes, Message_getLength(msg)));
+        Assert_true(!Bits_memcmp(msg->msgbytes, m2->msgbytes, Message_getLength(msg)));
     } else {
         Assert_failure("unexpected flag [%d]", flag);
     }

+ 4 - 4
dht/Pathfinder.c

@@ -93,7 +93,7 @@ static int incomingFromDHT(struct DHTMessage* dmessage, void* vpf)
     Assert_true(AddressCalc_validAddress(addr->ip6.bytes));
 
     Er_assert(Message_eshift(msg, PFChan_Msg_MIN_SIZE));
-    struct PFChan_Msg* emsg = (struct PFChan_Msg*) msg->bytes;
+    struct PFChan_Msg* emsg = (struct PFChan_Msg*) msg->msgbytes;
     Bits_memset(emsg, 0, PFChan_Msg_MIN_SIZE);
 
     DataHeader_setVersion(&emsg->data, DataHeader_CURRENT_VERSION);
@@ -141,9 +141,9 @@ static Iface_DEFUN sendNode(struct Message* msg,
 {
     Message_reset(msg);
     Er_assert(Message_eshift(msg, PFChan_Node_SIZE));
-    nodeForAddress((struct PFChan_Node*) msg->bytes, addr, metric);
+    nodeForAddress((struct PFChan_Node*) msg->msgbytes, addr, metric);
     if (addr->path == UINT64_MAX) {
-        ((struct PFChan_Node*) msg->bytes)->path_be = 0;
+        ((struct PFChan_Node*) msg->msgbytes)->path_be = 0;
     }
     Er_assert(Message_epush32be(msg, PFChan_Pathfinder_NODE));
     return Iface_next(&pf->pub.eventIf, msg);
@@ -401,7 +401,7 @@ static Iface_DEFUN handlePong(struct Message* msg, struct Pathfinder_pvt* pf)
 static Iface_DEFUN incomingMsg(struct Message* msg, struct Pathfinder_pvt* pf)
 {
     struct Address addr;
-    struct RouteHeader* hdr = (struct RouteHeader*) msg->bytes;
+    struct RouteHeader* hdr = (struct RouteHeader*) msg->msgbytes;
     Er_assert(Message_eshift(msg, -(RouteHeader_SIZE + DataHeader_SIZE)));
     Bits_memcpy(addr.ip6.bytes, hdr->ip6, 16);
     Bits_memcpy(addr.key, hdr->publicKey, 32);

+ 1 - 1
dht/ReplyModule.c

@@ -68,7 +68,7 @@ static int handleIncoming(struct DHTMessage* message, void* vcontext)
         Address_toString(message->address, message->allocator)->bytes);
 
     Message_reset(message->binMessage);
-    Assert_true(!((uintptr_t)message->binMessage->bytes % 4) || !"alignment fault0");
+    Assert_true(!((uintptr_t)message->binMessage->msgbytes % 4) || !"alignment fault0");
 
     struct DHTMessage* reply = Allocator_clone(message->allocator, (&(struct DHTMessage) {
         .replyTo = message,

+ 2 - 2
dht/SerializationModule.c

@@ -72,7 +72,7 @@ static int handleOutgoing(struct DHTMessage* message,
 {
    // This is always at the end of the message.
     Assert_true(!Message_getLength(message->binMessage));
-    Assert_true(!((uintptr_t)message->binMessage->bytes % 4) || !"alignment fault0");
+    Assert_true(!((uintptr_t)message->binMessage->msgbytes % 4) || !"alignment fault0");
 
     if (Dict_getStringC(message->asDict, "q")) {
         String* txid = Dict_getStringC(message->asDict, "txid");
@@ -86,7 +86,7 @@ static int handleOutgoing(struct DHTMessage* message,
 
     Er_assert(BencMessageWriter_write(message->asDict, message->binMessage));
 
-    Assert_true(!((uintptr_t)message->binMessage->bytes % 4) || !"alignment fault");
+    Assert_true(!((uintptr_t)message->binMessage->msgbytes % 4) || !"alignment fault");
 
     return 0;
 }

+ 4 - 4
interface/ETHInterface_darwin.c

@@ -73,7 +73,7 @@ static Iface_DEFUN sendMessage(struct Message* msg, struct Iface* iface)
     struct ETHInterface_pvt* ctx =
         Identity_containerOf(iface, struct ETHInterface_pvt, pub.generic.iface);
 
-    struct Sockaddr* sa = (struct Sockaddr*) msg->bytes;
+    struct Sockaddr* sa = (struct Sockaddr*) msg->msgbytes;
     Assert_true(Message_getLength(msg) >= Sockaddr_OVERHEAD);
     Assert_true(sa->addrLen <= ETHInterface_Sockaddr_SIZE);
 
@@ -106,7 +106,7 @@ static Iface_DEFUN sendMessage(struct Message* msg, struct Iface* iface)
     };
     Er_assert(Message_epush(msg, &bpfPkt, bpfPkt.bh_hdrlen));
 */
-    if (Message_getLength(msg) != write(ctx->socket, msg->bytes, Message_getLength(msg))) {
+    if (Message_getLength(msg) != write(ctx->socket, msg->msgbytes, Message_getLength(msg))) {
         Log_debug(ctx->logger, "Error writing to eth device [%s]", strerror(errno));
     }
     return Error(NONE);
@@ -130,7 +130,7 @@ static void handleEvent2(struct ETHInterface_pvt* context,
     struct ETHInterface_Header hdr;
     Bits_memcpy(&hdr, data, ETHInterface_Header_SIZE);
 
-    Bits_memcpy(msg->bytes, &data[ETHInterface_Header_SIZE], contentLength);
+    Bits_memcpy(msg->msgbytes, &data[ETHInterface_Header_SIZE], contentLength);
 
     // here we could put a switch statement to handle different versions differently.
     if (hdr.version != ETHInterface_CURRENT_VERSION) {
@@ -161,7 +161,7 @@ static void handleEvent2(struct ETHInterface_pvt* context,
 
     Er_assert(Message_epush(msg, &sockaddr, ETHInterface_Sockaddr_SIZE));
 
-    Assert_true(!((uintptr_t)msg->bytes % 4) && "Alignment fault");
+    Assert_true(!((uintptr_t)msg->msgbytes % 4) && "Alignment fault");
 
     Iface_send(&context->pub.generic.iface, msg);
 }

+ 4 - 4
interface/ETHInterface_linux.c

@@ -80,7 +80,7 @@ static void sendMessageInternal(struct Message* message,
     */
 
     if (sendto(context->socket,
-               message->bytes,
+               message->msgbytes,
                Message_getLength(message),
                0,
                (struct sockaddr*) addr,
@@ -105,7 +105,7 @@ static Iface_DEFUN sendMessage(struct Message* msg, struct Iface* iface)
     struct ETHInterface_pvt* ctx =
         Identity_containerOf(iface, struct ETHInterface_pvt, pub.generic.iface);
 
-    struct Sockaddr* sa = (struct Sockaddr*) msg->bytes;
+    struct Sockaddr* sa = (struct Sockaddr*) msg->msgbytes;
     Assert_true(Message_getLength(msg) >= Sockaddr_OVERHEAD);
     Assert_true(sa->addrLen <= ETHInterface_Sockaddr_SIZE);
 
@@ -144,7 +144,7 @@ static void handleEvent2(struct ETHInterface_pvt* context, struct Allocator* mes
     Er_assert(Message_eshift(msg, 2));
 
     int rc = recvfrom(context->socket,
-                      msg->bytes,
+                      msg->msgbytes,
                       Message_getLength(msg),
                       0,
                       (struct sockaddr*) &addr,
@@ -191,7 +191,7 @@ static void handleEvent2(struct ETHInterface_pvt* context, struct Allocator* mes
 
     Er_assert(Message_epush(msg, &sockaddr, ETHInterface_Sockaddr_SIZE));
 
-    Assert_true(!((uintptr_t)msg->bytes % 4) && "Alignment fault");
+    Assert_true(!((uintptr_t)msg->msgbytes % 4) && "Alignment fault");
 
     Iface_send(&context->pub.generic.iface, msg);
 }

+ 5 - 5
interface/FramingIface.c

@@ -59,10 +59,10 @@ static struct Message* mergeMessage(struct FramingIface_pvt* fi, struct Message*
     }
 
     struct Message* out = Message_new(0, length + REQUIRED_PADDING, fi->frameAlloc);
-    Er_assert(Message_epush(out, last->bytes, Message_getLength(last)));
+    Er_assert(Message_epush(out, last->msgbytes, Message_getLength(last)));
     int fd = Message_getAssociatedFd(last);
     for (part = fi->frameParts; part; part = part->next) {
-        Er_assert(Message_epush(out, part->msg->bytes, Message_getLength(part->msg)));
+        Er_assert(Message_epush(out, part->msg->msgbytes, Message_getLength(part->msg)));
         if (fd == -1) {
             fd = Message_getAssociatedFd(part->msg);
         }
@@ -111,7 +111,7 @@ static Iface_DEFUN receiveMessage(struct Message* msg, struct Iface* streamIf)
             if (!Message_getLength(msg)) {
                 return Error(NONE);
             }
-            fi->header.bytes[fi->headerIndex] = msg->bytes[0];
+            fi->header.bytes[fi->headerIndex] = msg->msgbytes[0];
             Er_assert(Message_eshift(msg, -1));
             fi->headerIndex++;
         }
@@ -132,7 +132,7 @@ static Iface_DEFUN receiveMessage(struct Message* msg, struct Iface* streamIf)
             struct Allocator* alloc = Allocator_child(Message_getAlloc(msg));
             struct Message* m = Message_new(fi->bytesRemaining, REQUIRED_PADDING, alloc);
             Message_setAssociatedFd(m, Message_getAssociatedFd(msg));
-            Bits_memcpy(m->bytes, msg->bytes, fi->bytesRemaining);
+            Bits_memcpy(m->msgbytes, msg->msgbytes, fi->bytesRemaining);
             Er_assert(Message_eshift(msg, -fi->bytesRemaining));
             fi->bytesRemaining = 0;
             Iface_send(&fi->messageIf, m);
@@ -143,7 +143,7 @@ static Iface_DEFUN receiveMessage(struct Message* msg, struct Iface* streamIf)
             fi->frameAlloc = Allocator_child(fi->alloc);
             struct Message* m = Message_new(0, Message_getLength(msg) + 4, fi->frameAlloc);
             Message_setAssociatedFd(m, Message_getAssociatedFd(msg));
-            Er_assert(Message_epush(m, msg->bytes, Message_getLength(msg)));
+            Er_assert(Message_epush(m, msg->msgbytes, Message_getLength(msg)));
             Er_assert(Message_epush(m, fi->header.bytes, 4));
 
             fi->bytesRemaining -= Message_getLength(msg);

+ 1 - 1
interface/UDPInterface.c

@@ -117,7 +117,7 @@ static Iface_DEFUN sendPacket(struct Message* m, struct Iface* iface)
         Identity_containerOf(iface, struct UDPInterface_pvt, pub.generic.iface);
 
     Assert_true(Message_getLength(m) > Sockaddr_OVERHEAD);
-    struct Sockaddr* sa = (struct Sockaddr*) m->bytes;
+    struct Sockaddr* sa = (struct Sockaddr*) m->msgbytes;
     Assert_true(Message_getLength(m) > sa->addrLen);
 
     // Regular traffic

+ 1 - 1
interface/addressable/AddrIface.h

@@ -48,7 +48,7 @@ static inline Er_DEFUN(void AddrIface_pushAddr(struct Message* msg, struct Socka
 
 static inline Er_DEFUN(struct Sockaddr* AddrIface_popAddr(struct Message* msg))
 {
-    struct Sockaddr* out = (struct Sockaddr*) msg->bytes;
+    struct Sockaddr* out = (struct Sockaddr*) msg->msgbytes;
     uint16_t len = Er(Message_epop16h(msg));
     Er(Message_epop(msg, NULL, len - 2));
     Er_ret(out);

+ 2 - 2
interface/addressable/AddrIfaceMuxer.c

@@ -76,11 +76,11 @@ static Iface_DEFUN incomingFromInputIf(struct Message* msg, struct Iface* inputI
         return Error(RUNT);
     }
 
-    uint16_t addrLen = Bits_get16(msg->bytes);
+    uint16_t addrLen = Bits_get16(msg->msgbytes);
     Er_assert(AddrIface_pushAddr(msg, &cli->addr));
 
     // After pushing the address, tweak the length
-    Bits_put16(msg->bytes, cli->addr.addrLen + addrLen);
+    Bits_put16(msg->msgbytes, cli->addr.addrLen + addrLen);
 
     return Iface_next(&ctx->pub.iface.iface, msg);
 }

+ 3 - 3
interface/addressable/PacketHeaderToUDPAddrIface.c

@@ -56,8 +56,8 @@ static Iface_DEFUN incomingFromUdpIf(struct Message* message, struct Iface* udpI
     Assert_true(Sockaddr_getAddress(context->pub.udpIf.addr, &addrPtr) == 16);
     Bits_memcpy(ip.sourceAddr, addrPtr, 16);
 
-    uint16_t checksum_be = Checksum_udpIp6_be(ip.sourceAddr, message->bytes, Message_getLength(message));
-    ((struct Headers_UDPHeader*)message->bytes)->checksum_be = checksum_be;
+    uint16_t checksum_be = Checksum_udpIp6_be(ip.sourceAddr, message->msgbytes, Message_getLength(message));
+    ((struct Headers_UDPHeader*)message->msgbytes)->checksum_be = checksum_be;
 
     Er_assert(Message_epush(message, &ip, sizeof(struct Headers_IP6Header)));
 
@@ -75,7 +75,7 @@ static Iface_DEFUN incomingFromHeaderIf(struct Message* message, struct Iface* i
         return Error(RUNT);
     }
 
-    struct Headers_IP6Header* ip = (struct Headers_IP6Header*) message->bytes;
+    struct Headers_IP6Header* ip = (struct Headers_IP6Header*) message->msgbytes;
 
     // udp
     if (ip->nextHeader != 17) {

+ 5 - 5
interface/test/FramingIface_fuzz_test.c

@@ -38,7 +38,7 @@ static Iface_DEFUN ifaceRecvMsg(struct Message* message, struct Iface* thisInter
     Assert_true(!ctx->success);
     Assert_true(Message_getLength(message) == ctx->messageLen);
     Assert_true(Message_getLength(ctx->buf) == 0);
-    Assert_true(!Bits_memcmp(ctx->bufPtr, message->bytes, ctx->messageLen));
+    Assert_true(!Bits_memcmp(ctx->bufPtr, message->msgbytes, ctx->messageLen));
     ctx->success = 1;
     return Error(NONE);
 }
@@ -51,13 +51,13 @@ void CJDNS_FUZZ_MAIN(void* vctx, struct Message* fuzz)
     Er_assert(Message_truncate(ctx->buf, ctx->messageLen));
     Er_assert(Message_epush32be(ctx->buf, ctx->messageLen));
     for (int i = 0; ; i++) {
-        uint8_t len = fuzz->bytes[i % Message_getLength(fuzz)] + 1;
+        uint8_t len = fuzz->msgbytes[i % Message_getLength(fuzz)] + 1;
         if (len > Message_getLength(ctx->buf)) {
             len = Message_getLength(ctx->buf);
         }
         struct Allocator* a = Allocator_child(ctx->alloc);
         struct Message* m = Message_new(len, 0, a);
-        Er_assert(Message_epop(ctx->buf, m->bytes, len));
+        Er_assert(Message_epop(ctx->buf, m->msgbytes, len));
         Iface_send(&ctx->outer, m);
         Allocator_free(a);
         if (ctx->success) {
@@ -74,8 +74,8 @@ void* CJDNS_FUZZ_INIT(struct Allocator* alloc, struct Random* rand)
     Iface_plumb(&ctx->iface, ctx->fi);
     ctx->alloc = alloc;
     ctx->buf = Message_new(BUF_SZ, 4, alloc);
-    Random_bytes(rand, ctx->buf->bytes, BUF_SZ);
-    ctx->bufPtr = ctx->buf->bytes;
+    Random_bytes(rand, ctx->buf->msgbytes, BUF_SZ);
+    ctx->bufPtr = ctx->buf->msgbytes;
     Identity_set(ctx);
     return ctx;
 }

+ 3 - 3
interface/tuntap/AndroidWrapper.c

@@ -46,7 +46,7 @@ Iface_DEFUN AndroidWrapper_incomingFromWire(struct Message* msg, struct Iface* e
         return Error(UNHANDLED);
     }
 
-    int version = Headers_getIpVersion(msg->bytes);
+    int version = Headers_getIpVersion(msg->msgbytes);
     uint16_t ethertype = 0;
     if (version == 4) {
         ethertype = Ethernet_TYPE_IP4;
@@ -58,8 +58,8 @@ Iface_DEFUN AndroidWrapper_incomingFromWire(struct Message* msg, struct Iface* e
     }
 
     Er_assert(Message_eshift(msg, 4));
-    ((uint16_t*) msg->bytes)[0] = 0;
-    ((uint16_t*) msg->bytes)[1] = ethertype;
+    ((uint16_t*) msg->msgbytes)[0] = 0;
+    ((uint16_t*) msg->msgbytes)[1] = ethertype;
 
     return Iface_next(&ctx->pub.internalIf, msg);
 }

+ 6 - 6
interface/tuntap/BSDMessageTypeWrapper.c

@@ -44,7 +44,7 @@ static Iface_DEFUN receiveMessage(struct Message* msg, struct Iface* wireSide)
 
     if (Message_getLength(msg) < 4) { return Error(RUNT); }
 
-    uint16_t afType_be = ((uint16_t*) msg->bytes)[1];
+    uint16_t afType_be = ((uint16_t*) msg->msgbytes)[1];
     uint16_t ethertype = 0;
     if (afType_be == ctx->afInet_be) {
         ethertype = Ethernet_TYPE_IP4;
@@ -55,8 +55,8 @@ static Iface_DEFUN receiveMessage(struct Message* msg, struct Iface* wireSide)
                   Endian_bigEndianToHost16(afType_be));
         return Error(INVALID);
     }
-    ((uint16_t*) msg->bytes)[0] = 0;
-    ((uint16_t*) msg->bytes)[1] = ethertype;
+    ((uint16_t*) msg->msgbytes)[0] = 0;
+    ((uint16_t*) msg->msgbytes)[1] = ethertype;
 
     return Iface_next(&ctx->pub.inside, msg);
 }
@@ -68,7 +68,7 @@ static Iface_DEFUN sendMessage(struct Message* msg, struct Iface* inside)
 
     Assert_true(Message_getLength(msg) >= 4);
 
-    uint16_t ethertype = ((uint16_t*) msg->bytes)[1];
+    uint16_t ethertype = ((uint16_t*) msg->msgbytes)[1];
     uint16_t afType_be = 0;
     if (ethertype == Ethernet_TYPE_IP6) {
         afType_be = ctx->afInet6_be;
@@ -77,8 +77,8 @@ static Iface_DEFUN sendMessage(struct Message* msg, struct Iface* inside)
     } else {
         Assert_true(!"Unsupported ethertype");
     }
-    ((uint16_t*) msg->bytes)[0] = 0;
-    ((uint16_t*) msg->bytes)[1] = afType_be;
+    ((uint16_t*) msg->msgbytes)[0] = 0;
+    ((uint16_t*) msg->msgbytes)[1] = afType_be;
 
     return Iface_next(&ctx->pub.wireSide, msg);
 }

+ 3 - 3
interface/tuntap/NDPServer.c

@@ -47,7 +47,7 @@ static bool isNeighborSolicitation(struct Message* msg, struct NDPServer_pvt* ns
         return false;
     }
 
-    struct Headers_IP6Header* ip6 = (struct Headers_IP6Header*) msg->bytes;
+    struct Headers_IP6Header* ip6 = (struct Headers_IP6Header*) msg->msgbytes;
     struct NDPHeader_NeighborSolicitation* sol = (struct NDPHeader_NeighborSolicitation*) &ip6[1];
 
     if (sol->oneThirtyFive != 135 || sol->zero != 0) {
@@ -105,8 +105,8 @@ static Iface_DEFUN answerNeighborSolicitation(struct Message* msg, struct NDPSer
     ip6.hopLimit = 255;
     ip6.payloadLength_be = Endian_hostToBigEndian16(Message_getLength(msg));
 
-    struct NDPHeader_RouterAdvert* adv = (struct NDPHeader_RouterAdvert*) msg->bytes;
-    adv->checksum = Checksum_icmp6_be(ip6.sourceAddr, msg->bytes, Message_getLength(msg));
+    struct NDPHeader_RouterAdvert* adv = (struct NDPHeader_RouterAdvert*) msg->msgbytes;
+    adv->checksum = Checksum_icmp6_be(ip6.sourceAddr, msg->msgbytes, Message_getLength(msg));
 
     Er_assert(Message_epush(msg, &ip6, sizeof(struct Headers_IP6Header)));
 

+ 3 - 3
interface/tuntap/TUNInterface_sunos.c

@@ -69,8 +69,8 @@ static Iface_DEFUN incomingFromWire(struct Message* message, struct Iface* exter
     }
 
     Er_assert(Message_eshift(message, 4));
-    ((uint16_t*) message->bytes)[0] = 0;
-    ((uint16_t*) message->bytes)[1] = ethertypeForPacketType(message->bytes[4]);
+    ((uint16_t*) message->msgbytes)[0] = 0;
+    ((uint16_t*) message->msgbytes)[1] = ethertypeForPacketType(message->msgbytes[4]);
 
     return Iface_next(&ctx->internalIf, message);
 }
@@ -81,7 +81,7 @@ static Iface_DEFUN incomingFromUs(struct Message* message, struct Iface* interna
         Identity_containerOf(internalIf, struct TUNInterface_Illumos_pvt, internalIf);
 
     Er_assert(Message_eshift(message, -4));
-    uint16_t ethertype = ((uint16_t*) message->bytes)[-1];
+    uint16_t ethertype = ((uint16_t*) message->msgbytes)[-1];
     if (ethertype != Ethernet_TYPE_IP6 && ethertype != Ethernet_TYPE_IP4) {
         Assert_true(!"Unsupported ethertype");
     }

+ 3 - 3
interface/tuntap/TUNMessageType.h

@@ -22,15 +22,15 @@ static inline Er_DEFUN(void TUNMessageType_push(struct Message* message,
                                        uint16_t ethertype))
 {
     Er(Message_eshift(message, 4));
-    ((uint16_t*) message->bytes)[0] = 0;
-    ((uint16_t*) message->bytes)[1] = ethertype;
+    ((uint16_t*) message->msgbytes)[0] = 0;
+    ((uint16_t*) message->msgbytes)[1] = ethertype;
     Er_ret();
 }
 
 static inline Er_DEFUN(uint16_t TUNMessageType_pop(struct Message* message))
 {
     Er(Message_eshift(message, -4));
-    Er_ret( ((uint16_t*) message->bytes)[-1] );
+    Er_ret( ((uint16_t*) message->msgbytes)[-1] );
 }
 
 enum TUNMessageType {

+ 1 - 1
interface/tuntap/test/TUNInterface_ipv4_root_test.c

@@ -39,7 +39,7 @@ static Iface_DEFUN receiveMessageTUN(struct Message* msg, struct TUNTools* tt)
         return Error(INVALID);
     }
 
-    struct Headers_IP4Header* header = (struct Headers_IP4Header*) msg->bytes;
+    struct Headers_IP4Header* header = (struct Headers_IP4Header*) msg->msgbytes;
 
     Assert_true(Message_getLength(msg) == Headers_IP4Header_SIZE + Headers_UDPHeader_SIZE + 12);
 

+ 1 - 1
interface/tuntap/test/TUNTools.c

@@ -86,7 +86,7 @@ Iface_DEFUN TUNTools_genericIP6Echo(struct Message* msg, struct TUNTools* tt)
         return Error(INVALID);
     }
 
-    struct Headers_IP6Header* header = (struct Headers_IP6Header*) msg->bytes;
+    struct Headers_IP6Header* header = (struct Headers_IP6Header*) msg->msgbytes;
 
     if (Message_getLength(msg) != Headers_IP6Header_SIZE + Headers_UDPHeader_SIZE + 12) {
         int type = (Message_getLength(msg) >= Headers_IP6Header_SIZE) ? header->nextHeader : -1;

+ 2 - 2
interface/tuntap/windows/TAPInterface.c

@@ -127,7 +127,7 @@ static void postRead(struct TAPInterface_pvt* tap)
     // Choose odd numbers so that the message will be aligned despite the weird header size.
     struct Message* msg = tap->readMsg = Message_new(1534, 514, alloc);
     OVERLAPPED* readol = (OVERLAPPED*) tap->readIocp.overlapped;
-    if (!ReadFile(tap->handle, msg->bytes, 1534, NULL, readol)) {
+    if (!ReadFile(tap->handle, msg->msgbytes, 1534, NULL, readol)) {
         switch (GetLastError()) {
             case ERROR_IO_PENDING:
             case ERROR_IO_INCOMPLETE: break;
@@ -172,7 +172,7 @@ static void postWrite(struct TAPInterface_pvt* tap)
     tap->isPendingWrite = 1;
     struct Message* msg = tap->writeMsgs[0];
     OVERLAPPED* writeol = (OVERLAPPED*) tap->writeIocp.overlapped;
-    if (!WriteFile(tap->handle, msg->bytes, Message_getLength(msg), NULL, writeol)) {
+    if (!WriteFile(tap->handle, msg->msgbytes, Message_getLength(msg), NULL, writeol)) {
         switch (GetLastError()) {
             case ERROR_IO_PENDING:
             case ERROR_IO_INCOMPLETE: break;

+ 13 - 13
net/ControlHandler.c

@@ -71,11 +71,11 @@ static Iface_DEFUN handlePing(struct Message* msg,
         return Error(RUNT);
     }
 
-    struct Control* ctrl = (struct Control*) msg->bytes;
+    struct Control* ctrl = (struct Control*) msg->msgbytes;
     Er_assert(Message_eshift(msg, -Control_Header_SIZE));
 
     // Ping and keyPing share version location
-    struct Control_Ping* ping = (struct Control_Ping*) msg->bytes;
+    struct Control_Ping* ping = (struct Control_Ping*) msg->msgbytes;
     uint32_t herVersion = Endian_bigEndianToHost32(ping->version_be);
     if (!Version_isCompatible(Version_CURRENT_PROTOCOL, herVersion)) {
         Log_debug(ch->log, "DROP ping from incompatible version [%d]", herVersion);
@@ -98,7 +98,7 @@ static Iface_DEFUN handlePing(struct Message* msg,
             return Error(INVALID);
         }
 
-        struct Control_KeyPing* keyPing = (struct Control_KeyPing*) msg->bytes;
+        struct Control_KeyPing* keyPing = (struct Control_KeyPing*) msg->msgbytes;
         keyPing->magic = Control_KeyPong_MAGIC;
         ctrl->header.type_be = Control_KEYPONG_be;
         Bits_memcpy(keyPing->key, ch->myPublicKey, 32);
@@ -122,11 +122,11 @@ static Iface_DEFUN handlePing(struct Message* msg,
     Er_assert(Message_eshift(msg, Control_Header_SIZE));
 
     ctrl->header.checksum_be = 0;
-    ctrl->header.checksum_be = Checksum_engine_be(msg->bytes, Message_getLength(msg));
+    ctrl->header.checksum_be = Checksum_engine_be(msg->msgbytes, Message_getLength(msg));
 
     Er_assert(Message_eshift(msg, RouteHeader_SIZE));
 
-    struct RouteHeader* routeHeader = (struct RouteHeader*) msg->bytes;
+    struct RouteHeader* routeHeader = (struct RouteHeader*) msg->msgbytes;
     Bits_memset(routeHeader, 0, RouteHeader_SIZE);
     SwitchHeader_setVersion(&routeHeader->sh, SwitchHeader_CURRENT_VERSION);
     routeHeader->sh.label_be = Endian_hostToBigEndian64(label);
@@ -150,7 +150,7 @@ static Iface_DEFUN handleRPathQuery(struct Message* msg,
         return Error(RUNT);
     }
 
-    struct Control* ctrl = (struct Control*) msg->bytes;
+    struct Control* ctrl = (struct Control*) msg->msgbytes;
     struct Control_RPath* rpa = &ctrl->content.rpath;
 
     if (rpa->magic != Control_RPATH_QUERY_MAGIC) {
@@ -165,10 +165,10 @@ static Iface_DEFUN handleRPathQuery(struct Message* msg,
     Bits_memcpy(rpa->rpath_be, &label_be, 8);
 
     ctrl->header.checksum_be = 0;
-    ctrl->header.checksum_be = Checksum_engine_be(msg->bytes, Message_getLength(msg));
+    ctrl->header.checksum_be = Checksum_engine_be(msg->msgbytes, Message_getLength(msg));
 
     Er_assert(Message_eshift(msg, RouteHeader_SIZE));
-    struct RouteHeader* routeHeader = (struct RouteHeader*) msg->bytes;
+    struct RouteHeader* routeHeader = (struct RouteHeader*) msg->msgbytes;
     Bits_memset(routeHeader, 0, RouteHeader_SIZE);
     SwitchHeader_setVersion(&routeHeader->sh, SwitchHeader_CURRENT_VERSION);
     routeHeader->sh.label_be = label_be;
@@ -191,7 +191,7 @@ static Iface_DEFUN handleGetSnodeQuery(struct Message* msg,
         return Error(RUNT);
     }
 
-    struct Control* ctrl = (struct Control*) msg->bytes;
+    struct Control* ctrl = (struct Control*) msg->msgbytes;
     struct Control_GetSnode* snq = &ctrl->content.getSnode;
 
     if (snq->magic != Control_GETSNODE_QUERY_MAGIC) {
@@ -226,10 +226,10 @@ static Iface_DEFUN handleGetSnodeQuery(struct Message* msg,
     }
 
     ctrl->header.checksum_be = 0;
-    ctrl->header.checksum_be = Checksum_engine_be(msg->bytes, Message_getLength(msg));
+    ctrl->header.checksum_be = Checksum_engine_be(msg->msgbytes, Message_getLength(msg));
 
     Er_assert(Message_eshift(msg, RouteHeader_SIZE));
-    struct RouteHeader* routeHeader = (struct RouteHeader*) msg->bytes;
+    struct RouteHeader* routeHeader = (struct RouteHeader*) msg->msgbytes;
     Bits_memset(routeHeader, 0, RouteHeader_SIZE);
     SwitchHeader_setVersion(&routeHeader->sh, SwitchHeader_CURRENT_VERSION);
     routeHeader->sh.label_be = Endian_hostToBigEndian64(label);
@@ -270,12 +270,12 @@ static Iface_DEFUN incomingFromCore(struct Message* msg, struct Iface* coreIf)
 
     Assert_true(routeHdr.flags & RouteHeader_flags_CTRLMSG);
 
-    if (Checksum_engine_be(msg->bytes, Message_getLength(msg))) {
+    if (Checksum_engine_be(msg->msgbytes, Message_getLength(msg))) {
         Log_info(ch->log, "DROP ctrl packet from [%s] with invalid checksum", labelStr);
         return Error(INVALID);
     }
 
-    struct Control* ctrl = (struct Control*) msg->bytes;
+    struct Control* ctrl = (struct Control*) msg->msgbytes;
 
     if (ctrl->header.type_be == Control_ERROR_be) {
         return handleError(msg, ch, label, labelStr, &routeHdr);

+ 2 - 2
net/EventEmitter.c

@@ -175,7 +175,7 @@ Assert_compileTime(PFChan_Core__TOO_HIGH == 1040);
 static Iface_DEFUN incomingFromCore(struct Message* msg, struct Iface* trickIf)
 {
     struct EventEmitter_pvt* ee = Identity_containerOf(trickIf, struct EventEmitter_pvt, trickIf);
-    Assert_true(!((uintptr_t)msg->bytes % 4) && "alignment");
+    Assert_true(!((uintptr_t)msg->msgbytes % 4) && "alignment");
     enum PFChan_Core ev = Er_assert(Message_epop32be(msg));
     Assert_true(PFChan_Core_sizeOk(ev, Message_getLength(msg)+4));
     uint32_t pathfinderNum = Er_assert(Message_epop32be(msg));
@@ -200,7 +200,7 @@ static struct Message* pathfinderMsg(enum PFChan_Core ev,
                                      struct Allocator* alloc)
 {
     struct Message* msg = Message_new(PFChan_Core_Pathfinder_SIZE, 512, alloc);
-    struct PFChan_Core_Pathfinder* pathfinder = (struct PFChan_Core_Pathfinder*) msg->bytes;
+    struct PFChan_Core_Pathfinder* pathfinder = (struct PFChan_Core_Pathfinder*) msg->msgbytes;
     pathfinder->superiority_be = Endian_hostToBigEndian32(pf->superiority);
     pathfinder->pathfinderId_be = Endian_hostToBigEndian32(pf->pathfinderId);
     Bits_memcpy(pathfinder->userAgent, pf->userAgent, 64);

+ 10 - 10
net/InterfaceController.c

@@ -246,7 +246,7 @@ static void sendPeer(uint32_t pathfinderId,
     struct InterfaceController_pvt* ic = Identity_check(peer->ici->ic);
     struct Allocator* alloc = Allocator_child(ic->alloc);
     struct Message* msg = Message_new(PFChan_Node_SIZE, 512, alloc);
-    struct PFChan_Node* node = (struct PFChan_Node*) msg->bytes;
+    struct PFChan_Node* node = (struct PFChan_Node*) msg->msgbytes;
     Bits_memcpy(node->ip6, peer->addr.ip6.bytes, 16);
     Bits_memcpy(node->publicKey, peer->addr.key, 32);
     node->path_be = Endian_hostToBigEndian64(peer->addr.path);
@@ -591,7 +591,7 @@ static Iface_DEFUN handleBeacon(struct Message* msg, struct InterfaceController_
         return Error(RUNT);
     }
 
-    struct Sockaddr* lladdrInmsg = (struct Sockaddr*) msg->bytes;
+    struct Sockaddr* lladdrInmsg = (struct Sockaddr*) msg->msgbytes;
 
     if (Message_getLength(msg) < lladdrInmsg->addrLen + Headers_Beacon_SIZE) {
         Log_debug(ic->logger, "[%s] Dropping runt beacon", ici->pub.name->bytes);
@@ -684,15 +684,15 @@ static Iface_DEFUN handleBeacon(struct Message* msg, struct InterfaceController_
 static Iface_DEFUN handleUnexpectedIncoming(struct Message* msg,
                                             struct InterfaceController_Iface_pvt* ici)
 {
-    struct Sockaddr* lladdr = (struct Sockaddr*) msg->bytes;
+    struct Sockaddr* lladdr = (struct Sockaddr*) msg->msgbytes;
     Er_assert(Message_eshift(msg, -lladdr->addrLen));
     if (Message_getLength(msg) < CryptoHeader_SIZE) {
         return Error(RUNT);
     }
 
-    Assert_true(!((uintptr_t)msg->bytes % 4) && "alignment fault");
+    Assert_true(!((uintptr_t)msg->msgbytes % 4) && "alignment fault");
 
-    struct CryptoHeader* ch = (struct CryptoHeader*) msg->bytes;
+    struct CryptoHeader* ch = (struct CryptoHeader*) msg->msgbytes;
     if (ch->nonce & Endian_bigEndianToHost32(~1)) {
         // This cuts down on processing and logger noise because any packet
         // which is not a setup packet will be summarily dropped.
@@ -719,13 +719,13 @@ static Iface_DEFUN handleIncomingFromWire(struct Message* msg, struct Iface* add
     struct InterfaceController_Iface_pvt* ici =
         Identity_containerOf(addrIf, struct InterfaceController_Iface_pvt, pub.addrIf);
 
-    struct Sockaddr* lladdr = (struct Sockaddr*) msg->bytes;
+    struct Sockaddr* lladdr = (struct Sockaddr*) msg->msgbytes;
     if (Message_getLength(msg) < Sockaddr_OVERHEAD || Message_getLength(msg) < lladdr->addrLen) {
         Log_debug(ici->ic->logger, "DROP runt");
         return Error(RUNT);
     }
 
-    Assert_true(!((uintptr_t)msg->bytes % 4) && "alignment fault");
+    Assert_true(!((uintptr_t)msg->msgbytes % 4) && "alignment fault");
     Assert_true(!((uintptr_t)lladdr->addrLen % 4) && "alignment fault");
 
     // noisy
@@ -758,7 +758,7 @@ static Iface_DEFUN handleIncomingFromWire(struct Message* msg, struct Iface* add
 
     CryptoAuth_resetIfTimeout(ep->caSession);
 
-    uint32_t nonce = Endian_bigEndianToHost32( ((uint32_t*)msg->bytes)[0] );
+    uint32_t nonce = Endian_bigEndianToHost32( ((uint32_t*)msg->msgbytes)[0] );
     Er_assert(Message_epushAd(msg, &nonce, sizeof nonce));
     bool unexpected = false;
     Er_assert(Message_epushAd(msg, &unexpected, sizeof unexpected));
@@ -818,7 +818,7 @@ static Iface_DEFUN afterDecrypt(struct Message* msg, struct Iface* plaintext)
         // prevent some kinds of nasty things which could be done with packet replay.
         // This is checking the message switch header and will drop it unless the label
         // directs it to *this* router.
-        if (Message_getLength(msg) < 8 || msg->bytes[7] != 1) {
+        if (Message_getLength(msg) < 8 || msg->msgbytes[7] != 1) {
             Log_info(ic->logger, "DROP message because CA is not established.");
             return Error(UNHANDLED);
         } else {
@@ -896,7 +896,7 @@ static void sendBeacon(struct InterfaceController_Iface_pvt* ici, struct Allocat
     Er_assert(Message_epush(msg, &ici->ic->beacon, Headers_Beacon_SIZE));
 
     if (Defined(Log_DEBUG)) {
-        char* content = Hex_print(msg->bytes, Message_getLength(msg), tempAlloc);
+        char* content = Hex_print(msg->msgbytes, Message_getLength(msg), tempAlloc);
         Log_debug(ici->ic->logger, "SEND BEACON CONTENT[%s]", content);
     }
 

+ 8 - 8
net/SessionManager.c

@@ -309,7 +309,7 @@ static Iface_DEFUN failedDecrypt(struct Message* msg,
     Er_assert(Message_epush32be(msg, Error_AUTHENTICATION));
     Er_assert(Message_epush16be(msg, Control_ERROR));
     Er_assert(Message_epush16be(msg, 0));
-    uint16_t csum_be = Checksum_engine_be(msg->bytes, Message_getLength(msg));
+    uint16_t csum_be = Checksum_engine_be(msg->msgbytes, Message_getLength(msg));
     Er_assert(Message_epop16h(msg));
     Er_assert(Message_epush16h(msg, csum_be));
 
@@ -497,7 +497,7 @@ static Iface_DEFUN incomingFromSwitchIf(struct Message* msg, struct Iface* iface
     switchHeader.label_be = Bits_bitReverse64(switchHeader.label_be);
 
     struct SessionManager_Session_pvt* session = NULL;
-    uint32_t nonceOrHandle = Endian_bigEndianToHost32(((uint32_t*)msg->bytes)[0]);
+    uint32_t nonceOrHandle = Endian_bigEndianToHost32(((uint32_t*)msg->msgbytes)[0]);
     if (nonceOrHandle == 0xffffffff) {
         Er_assert(Message_epush(msg, &switchHeader, SwitchHeader_SIZE));
         return ctrlFrame(msg, sm);
@@ -517,7 +517,7 @@ static Iface_DEFUN incomingFromSwitchIf(struct Message* msg, struct Iface* iface
             return Error(INVALID);
         }
         Er_assert(Message_eshift(msg, -4));
-        uint32_t nonce = Endian_bigEndianToHost32(((uint32_t*)msg->bytes)[0]);
+        uint32_t nonce = Endian_bigEndianToHost32(((uint32_t*)msg->msgbytes)[0]);
         if (nonce < 4) {
             Log_debug(sm->log, "DROP setup message [%u] with specified handle [%u]",
                 nonce, nonceOrHandle);
@@ -529,7 +529,7 @@ static Iface_DEFUN incomingFromSwitchIf(struct Message* msg, struct Iface* iface
             Log_debug(sm->log, "DROP runt");
             return Error(RUNT);
         }
-        struct CryptoHeader* caHeader = (struct CryptoHeader*) msg->bytes;
+        struct CryptoHeader* caHeader = (struct CryptoHeader*) msg->msgbytes;
         uint8_t ip6[16];
         // a packet which claims to be "from us" causes problems
         if (!AddressCalc_addressForPublicKey(ip6, caHeader->publicKey)) {
@@ -663,7 +663,7 @@ static void periodically(void* vSessionManager)
 static void bufferPacket(struct SessionManager_pvt* sm, struct Message* msg)
 {
     Assert_true(Message_getLength(msg) >= (RouteHeader_SIZE + DataHeader_SIZE));
-    struct RouteHeader* header = (struct RouteHeader*) msg->bytes;
+    struct RouteHeader* header = (struct RouteHeader*) msg->msgbytes;
 
     // We should never be sending CJDHT messages without full version, key, path known.
     struct DataHeader* dataHeader = (struct DataHeader*) &header[1];
@@ -701,7 +701,7 @@ static void bufferPacket(struct SessionManager_pvt* sm, struct Message* msg)
 
 static void needsLookup(struct SessionManager_pvt* sm, struct Message* msg)
 {
-    struct RouteHeader* header = (struct RouteHeader*) msg->bytes;
+    struct RouteHeader* header = (struct RouteHeader*) msg->msgbytes;
     bufferPacket(sm, msg);
     triggerSearch(sm, header->ip6, Endian_hostToBigEndian32(header->version_be));
 }
@@ -730,7 +730,7 @@ static Iface_DEFUN readyToSend(struct Message* msg,
 static Iface_DEFUN outgoingCtrlFrame(struct Message* msg, struct SessionManager_pvt* sm)
 {
     Assert_true(Message_getLength(msg) >= RouteHeader_SIZE);
-    struct RouteHeader* header = (struct RouteHeader*) msg->bytes;
+    struct RouteHeader* header = (struct RouteHeader*) msg->msgbytes;
     if (!Bits_isZero(header->publicKey, 32) || !Bits_isZero(header->ip6, 16)) {
         Log_debug(sm->log, "DROP Ctrl frame with non-zero destination key or IP");
         return Error(INVALID);
@@ -752,7 +752,7 @@ static Iface_DEFUN incomingFromInsideIf(struct Message* msg, struct Iface* iface
     struct SessionManager_pvt* sm =
         Identity_containerOf(iface, struct SessionManager_pvt, pub.insideIf);
     Assert_true(Message_getLength(msg) >= RouteHeader_SIZE);
-    struct RouteHeader* header = (struct RouteHeader*) msg->bytes;
+    struct RouteHeader* header = (struct RouteHeader*) msg->msgbytes;
     if (header->flags & RouteHeader_flags_CTRLMSG) {
         return outgoingCtrlFrame(msg, sm);
     }

+ 16 - 16
net/SwitchPinger.c

@@ -94,12 +94,12 @@ static Iface_DEFUN messageFromControlHandler(struct Message* msg, struct Iface*
     ctx->incomingSnodeKbps = 0;
     ctx->rpath = 0;
 
-    struct Control* ctrl = (struct Control*) msg->bytes;
+    struct Control* ctrl = (struct Control*) msg->msgbytes;
     if (ctrl->header.type_be == Control_PONG_be) {
         Er_assert(Message_eshift(msg, -Control_Header_SIZE));
         ctx->error = Error_NONE;
         if (Message_getLength(msg) >= Control_Pong_MIN_SIZE) {
-            struct Control_Ping* pongHeader = (struct Control_Ping*) msg->bytes;
+            struct Control_Ping* pongHeader = (struct Control_Ping*) msg->msgbytes;
             ctx->incomingVersion = Endian_bigEndianToHost32(pongHeader->version_be);
             if (pongHeader->magic != Control_Pong_MAGIC) {
                 Log_debug(ctx->logger, "dropped invalid switch pong");
@@ -115,7 +115,7 @@ static Iface_DEFUN messageFromControlHandler(struct Message* msg, struct Iface*
         Er_assert(Message_eshift(msg, -Control_Header_SIZE));
         ctx->error = Error_NONE;
         if (Message_getLength(msg) >= Control_KeyPong_HEADER_SIZE && Message_getLength(msg) <= Control_KeyPong_MAX_SIZE) {
-            struct Control_KeyPing* pongHeader = (struct Control_KeyPing*) msg->bytes;
+            struct Control_KeyPing* pongHeader = (struct Control_KeyPing*) msg->msgbytes;
             ctx->incomingVersion = Endian_bigEndianToHost32(pongHeader->version_be);
             if (pongHeader->magic != Control_KeyPong_MAGIC) {
                 Log_debug(ctx->logger, "dropped invalid switch key-pong");
@@ -138,7 +138,7 @@ static Iface_DEFUN messageFromControlHandler(struct Message* msg, struct Iface*
             Log_debug(ctx->logger, "got runt GetSnode message, length: [%d]", Message_getLength(msg));
             return Error(RUNT);
         }
-        struct Control_GetSnode* hdr = (struct Control_GetSnode*) msg->bytes;
+        struct Control_GetSnode* hdr = (struct Control_GetSnode*) msg->msgbytes;
         if (hdr->magic != Control_GETSNODE_REPLY_MAGIC) {
             Log_debug(ctx->logger, "dropped invalid GetSnode");
             return Error(INVALID);
@@ -167,7 +167,7 @@ static Iface_DEFUN messageFromControlHandler(struct Message* msg, struct Iface*
             Log_debug(ctx->logger, "got runt RPath message, length: [%d]", Message_getLength(msg));
             return Error(RUNT);
         }
-        struct Control_RPath* hdr = (struct Control_RPath*) msg->bytes;
+        struct Control_RPath* hdr = (struct Control_RPath*) msg->msgbytes;
         if (hdr->magic != Control_RPATH_REPLY_MAGIC) {
             Log_debug(ctx->logger, "dropped invalid RPATH (bad magic)");
             return Error(INVALID);
@@ -180,7 +180,7 @@ static Iface_DEFUN messageFromControlHandler(struct Message* msg, struct Iface*
 
     } else if (ctrl->header.type_be == Control_ERROR_be) {
         Er_assert(Message_eshift(msg, -Control_Header_SIZE));
-        Assert_true((uint8_t*)&ctrl->content.error.errorType_be == msg->bytes);
+        Assert_true((uint8_t*)&ctrl->content.error.errorType_be == msg->msgbytes);
         if (Message_getLength(msg) < (Control_Error_HEADER_SIZE + SwitchHeader_SIZE + Control_Header_SIZE)) {
             Log_debug(ctx->logger, "runt error packet");
             return Error(RUNT);
@@ -191,7 +191,7 @@ static Iface_DEFUN messageFromControlHandler(struct Message* msg, struct Iface*
 
         Er_assert(Message_eshift(msg, -(Control_Error_HEADER_SIZE + SwitchHeader_SIZE)));
 
-        struct Control* origCtrl = (struct Control*) msg->bytes;
+        struct Control* origCtrl = (struct Control*) msg->msgbytes;
 
         Log_debug(ctx->logger, "error [%s] was caused by our [%s]",
                   Error_strerror(ctx->error),
@@ -215,7 +215,7 @@ static Iface_DEFUN messageFromControlHandler(struct Message* msg, struct Iface*
         Assert_true(false);
     }
 
-    String* msgStr = &(String) { .bytes = (char*) msg->bytes, .len = Message_getLength(msg) };
+    String* msgStr = &(String) { .bytes = (char*) msg->msgbytes, .len = Message_getLength(msg) };
     Pinger_pongReceived(msgStr, ctx->pinger);
     Bits_memset(ctx->incomingKey, 0, 32);
     return Error(NONE);
@@ -264,30 +264,30 @@ static void sendPing(String* data, void* sendPingContext)
 
     struct Message* msg = Message_new(0, data->len + 512, p->pub.pingAlloc);
 
-    while (((uintptr_t)msg->bytes - data->len) % 4) {
+    while (((uintptr_t)msg->msgbytes - data->len) % 4) {
         Er_assert(Message_epush8(msg, 0));
     }
     Er_assert(Message_truncate(msg, 0));
 
     Er_assert(Message_epush(msg, data->bytes, data->len));
-    Assert_true(!((uintptr_t)msg->bytes % 4) && "alignment fault");
+    Assert_true(!((uintptr_t)msg->msgbytes % 4) && "alignment fault");
 
     if (p->pub.type == SwitchPinger_Type_KEYPING) {
         Er_assert(Message_epush(msg, NULL, Control_KeyPing_HEADER_SIZE));
-        struct Control_KeyPing* keyPingHeader = (struct Control_KeyPing*) msg->bytes;
+        struct Control_KeyPing* keyPingHeader = (struct Control_KeyPing*) msg->msgbytes;
         keyPingHeader->magic = Control_KeyPing_MAGIC;
         keyPingHeader->version_be = Endian_hostToBigEndian32(Version_CURRENT_PROTOCOL);
         Bits_memcpy(keyPingHeader->key, p->context->myAddr->key, 32);
 
     } else if (p->pub.type == SwitchPinger_Type_PING) {
         Er_assert(Message_epush(msg, NULL, Control_Ping_HEADER_SIZE));
-        struct Control_Ping* pingHeader = (struct Control_Ping*) msg->bytes;
+        struct Control_Ping* pingHeader = (struct Control_Ping*) msg->msgbytes;
         pingHeader->magic = Control_Ping_MAGIC;
         pingHeader->version_be = Endian_hostToBigEndian32(Version_CURRENT_PROTOCOL);
 
     } else if (p->pub.type == SwitchPinger_Type_GETSNODE) {
         Er_assert(Message_epush(msg, NULL, Control_GetSnode_HEADER_SIZE));
-        struct Control_GetSnode* hdr = (struct Control_GetSnode*) msg->bytes;
+        struct Control_GetSnode* hdr = (struct Control_GetSnode*) msg->msgbytes;
         hdr->magic = Control_GETSNODE_QUERY_MAGIC;
         hdr->version_be = Endian_hostToBigEndian32(Version_CURRENT_PROTOCOL);
         hdr->kbps_be = Endian_hostToBigEndian32(p->pub.kbpsLimit);
@@ -298,7 +298,7 @@ static void sendPing(String* data, void* sendPingContext)
 
     } else if (p->pub.type == SwitchPinger_Type_RPATH) {
         Er_assert(Message_epush(msg, NULL, Control_RPath_HEADER_SIZE));
-        struct Control_RPath* hdr = (struct Control_RPath*) msg->bytes;
+        struct Control_RPath* hdr = (struct Control_RPath*) msg->msgbytes;
         hdr->magic = Control_RPATH_QUERY_MAGIC;
         hdr->version_be = Endian_hostToBigEndian32(Version_CURRENT_PROTOCOL);
         uint64_t path_be = Endian_hostToBigEndian64(p->label);
@@ -309,7 +309,7 @@ static void sendPing(String* data, void* sendPingContext)
     }
 
     Er_assert(Message_eshift(msg, Control_Header_SIZE));
-    struct Control* ctrl = (struct Control*) msg->bytes;
+    struct Control* ctrl = (struct Control*) msg->msgbytes;
     ctrl->header.checksum_be = 0;
     if (p->pub.type == SwitchPinger_Type_PING) {
         ctrl->header.type_be = Control_PING_be;
@@ -322,7 +322,7 @@ static void sendPing(String* data, void* sendPingContext)
     } else {
         Assert_failure("unexpected type");
     }
-    ctrl->header.checksum_be = Checksum_engine_be(msg->bytes, Message_getLength(msg));
+    ctrl->header.checksum_be = Checksum_engine_be(msg->msgbytes, Message_getLength(msg));
 
     struct RouteHeader rh;
     Bits_memset(&rh, 0, RouteHeader_SIZE);

+ 5 - 5
net/TUNAdapter.c

@@ -39,7 +39,7 @@ static Iface_DEFUN incomingFromTunIf(struct Message* msg, struct Iface* tunIf)
 
     uint16_t ethertype = Er_assert(TUNMessageType_pop(msg));
 
-    int version = Headers_getIpVersion(msg->bytes);
+    int version = Headers_getIpVersion(msg->msgbytes);
     if ((ethertype == Ethernet_TYPE_IP4 && version != 4)
         || (ethertype == Ethernet_TYPE_IP6 && version != 6))
     {
@@ -62,7 +62,7 @@ static Iface_DEFUN incomingFromTunIf(struct Message* msg, struct Iface* tunIf)
         return Error(RUNT);
     }
 
-    struct Headers_IP6Header* header = (struct Headers_IP6Header*) msg->bytes;
+    struct Headers_IP6Header* header = (struct Headers_IP6Header*) msg->msgbytes;
     if (!AddressCalc_validAddress(header->destinationAddr)) {
         return Iface_next(&ud->pub.ipTunnelIf, msg);
     }
@@ -88,7 +88,7 @@ static Iface_DEFUN incomingFromTunIf(struct Message* msg, struct Iface* tunIf)
     Bits_memmove(header->destinationAddr - DataHeader_SIZE, header->destinationAddr, 16);
 
     Er_assert(Message_eshift(msg, DataHeader_SIZE + RouteHeader_SIZE - Headers_IP6Header_SIZE));
-    struct RouteHeader* rh = (struct RouteHeader*) msg->bytes;
+    struct RouteHeader* rh = (struct RouteHeader*) msg->msgbytes;
 
     struct DataHeader* dh = (struct DataHeader*) &rh[1];
     Bits_memset(dh, 0, DataHeader_SIZE);
@@ -124,7 +124,7 @@ static Iface_DEFUN incomingFromUpperDistributorIf(struct Message* msg,
     struct TUNAdapter_pvt* ud =
         Identity_containerOf(upperDistributorIf, struct TUNAdapter_pvt, pub.upperDistributorIf);
     Assert_true(Message_getLength(msg) >= RouteHeader_SIZE + DataHeader_SIZE);
-    struct RouteHeader* hdr = (struct RouteHeader*) msg->bytes;
+    struct RouteHeader* hdr = (struct RouteHeader*) msg->msgbytes;
     struct DataHeader* dh = (struct DataHeader*) &hdr[1];
     enum ContentType type = DataHeader_getContentType(dh);
     Assert_true(type <= ContentType_IP6_MAX);
@@ -135,7 +135,7 @@ static Iface_DEFUN incomingFromUpperDistributorIf(struct Message* msg,
     Bits_memcpy(&hdr->ip6[DataHeader_SIZE], ud->myIp6, 16);
 
     Er_assert(Message_eshift(msg, Headers_IP6Header_SIZE - DataHeader_SIZE - RouteHeader_SIZE));
-    struct Headers_IP6Header* ip6 = (struct Headers_IP6Header*) msg->bytes;
+    struct Headers_IP6Header* ip6 = (struct Headers_IP6Header*) msg->msgbytes;
     Bits_memset(ip6, 0, Headers_IP6Header_SIZE - 32);
     Headers_setIpVersion(ip6);
     ip6->payloadLength_be = Endian_bigEndianToHost16(Message_getLength(msg) - Headers_IP6Header_SIZE);

+ 9 - 9
net/UpperDistributor.c

@@ -71,8 +71,8 @@ static Iface_DEFUN fromHandler(struct Message* msg, struct UpperDistributor_pvt*
     uint8_t srcAndDest[32] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1};
     AddressCalc_makeValidAddress(&srcAndDest[16]);
     Bits_memcpy(srcAndDest, ud->myAddress->ip6.bytes, 16);
-    struct Headers_UDPHeader* udp = (struct Headers_UDPHeader*) msg->bytes;
-    if (Checksum_udpIp6_be(srcAndDest, msg->bytes, Message_getLength(msg))) {
+    struct Headers_UDPHeader* udp = (struct Headers_UDPHeader*) msg->msgbytes;
+    if (Checksum_udpIp6_be(srcAndDest, msg->msgbytes, Message_getLength(msg))) {
         Log_debug(ud->log, "DROP Bad checksum");
         return Error(INVALID);
     }
@@ -90,7 +90,7 @@ static Iface_DEFUN fromHandler(struct Message* msg, struct UpperDistributor_pvt*
     Er_assert(Message_epop(msg, NULL, Headers_UDPHeader_SIZE));
 
     Assert_true(Message_getLength(msg) >= RouteHeader_SIZE);
-    struct RouteHeader* hdr = (struct RouteHeader*) msg->bytes;
+    struct RouteHeader* hdr = (struct RouteHeader*) msg->msgbytes;
     if (!Bits_memcmp(hdr->ip6, ud->myAddress->ip6.bytes, 16)) {
         ud->noSendToHandler = 1;
         Log_debug(ud->log, "Message to self");
@@ -137,8 +137,8 @@ static void sendToHandlers(struct Message* msg,
             uint8_t srcAndDest[32] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1};
             AddressCalc_makeValidAddress(srcAndDest);
             Bits_memcpy(&srcAndDest[16], ud->myAddress->ip6.bytes, 16);
-            uint16_t checksum_be = Checksum_udpIp6_be(srcAndDest, cmsg->bytes, Message_getLength(cmsg));
-            ((struct Headers_UDPHeader*)cmsg->bytes)->checksum_be = checksum_be;
+            uint16_t checksum_be = Checksum_udpIp6_be(srcAndDest, cmsg->msgbytes, Message_getLength(cmsg));
+            ((struct Headers_UDPHeader*)cmsg->msgbytes)->checksum_be = checksum_be;
         }
         {
             struct DataHeader dh = { .unused = 0 };
@@ -163,7 +163,7 @@ static void sendToHandlers(struct Message* msg,
 static Iface_DEFUN toSessionManagerIf(struct Message* msg, struct UpperDistributor_pvt* ud)
 {
     Assert_true(Message_getLength(msg) >= RouteHeader_SIZE + DataHeader_SIZE);
-    struct RouteHeader* hdr = (struct RouteHeader*) msg->bytes;
+    struct RouteHeader* hdr = (struct RouteHeader*) msg->msgbytes;
     struct DataHeader* dh = (struct DataHeader*) &hdr[1];
     enum ContentType type = DataHeader_getContentType(dh);
     sendToHandlers(msg, type, ud);
@@ -185,7 +185,7 @@ static Iface_DEFUN incomingFromTunAdapterIf(struct Message* msg, struct Iface* t
 {
     struct UpperDistributor_pvt* ud =
         Identity_containerOf(tunAdapterIf, struct UpperDistributor_pvt, pub.tunAdapterIf);
-    struct RouteHeader* rh = (struct RouteHeader*) msg->bytes;
+    struct RouteHeader* rh = (struct RouteHeader*) msg->msgbytes;
     Assert_true(Message_getLength(msg) >= RouteHeader_SIZE);
     uint8_t expected_ip6[16] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1};
     AddressCalc_makeValidAddress(expected_ip6);
@@ -207,7 +207,7 @@ static Iface_DEFUN incomingFromControlHandlerIf(struct Message* msg, struct Ifac
     struct UpperDistributor_pvt* ud =
         Identity_containerOf(iface, struct UpperDistributor_pvt, pub.controlHandlerIf);
     Assert_true(Message_getLength(msg) >= RouteHeader_SIZE);
-    struct RouteHeader* hdr = (struct RouteHeader*) msg->bytes;
+    struct RouteHeader* hdr = (struct RouteHeader*) msg->msgbytes;
     Assert_true(hdr->flags & RouteHeader_flags_CTRLMSG);
     Assert_true(!(hdr->flags & RouteHeader_flags_INCOMING));
     sendToHandlers(msg, ContentType_CTRL, ud);
@@ -219,7 +219,7 @@ static Iface_DEFUN incomingFromSessionManagerIf(struct Message* msg, struct Ifac
     struct UpperDistributor_pvt* ud =
         Identity_containerOf(sessionManagerIf, struct UpperDistributor_pvt, pub.sessionManagerIf);
     Assert_true(Message_getLength(msg) >= RouteHeader_SIZE);
-    struct RouteHeader* hdr = (struct RouteHeader*) msg->bytes;
+    struct RouteHeader* hdr = (struct RouteHeader*) msg->msgbytes;
     if (hdr->flags & RouteHeader_flags_CTRLMSG) {
         sendToHandlers(msg, ContentType_CTRL, ud);
         return Iface_next(&ud->pub.controlHandlerIf, msg);

+ 1 - 1
node_build/make.js

@@ -34,7 +34,7 @@ Builder.configure({
 }, function (builder, waitFor) {
 
     builder.config.crossCompiling = process.env['CROSS'] !== undefined;
-    let optimizeLevel = '-O3';
+    let optimizeLevel = '-O0';
 
     builder.config.cflags.push(
         '-std=c99',

+ 10 - 10
subnode/LinkState.h

@@ -45,9 +45,9 @@ static inline int LinkState_encode(
     if (Message_getPadding(msg) < 255) { return 1; }
 
     struct VarInt_Iter iter = {
-        .ptr = msg->bytes,
-        .end = msg->bytes,
-        .start = &msg->bytes[-Message_getPadding(msg)]
+        .ptr = msg->msgbytes,
+        .end = msg->msgbytes,
+        .start = &msg->msgbytes[-Message_getPadding(msg)]
     };
 
     // Take the newest X entries where X = MIN(ls->samples - lastSamples, LinkState_SLOTS)
@@ -68,11 +68,11 @@ static inline int LinkState_encode(
     Assert_true(!VarInt_push(&iter, ls->nodeId));
 
     int beginLength = Message_getLength(msg);
-    Er_assert(Message_eshift(msg, (msg->bytes - iter.ptr)));
-    Assert_true(msg->bytes == iter.ptr);
+    Er_assert(Message_eshift(msg, (msg->msgbytes - iter.ptr)));
+    Assert_true(msg->msgbytes == iter.ptr);
 
     int padCount = 0;
-    while ((uintptr_t)(&msg->bytes[-3]) & 7) {
+    while ((uintptr_t)(&msg->msgbytes[-3]) & 7) {
         Er_assert(Message_epush8(msg, 0));
         padCount++;
     }
@@ -82,19 +82,19 @@ static inline int LinkState_encode(
     int finalLength = Message_getLength(msg) - beginLength;
     Er_assert(Message_epush8(msg, finalLength + 1));
 
-    Assert_true(!(((uintptr_t)msg->bytes) & 7));
+    Assert_true(!(((uintptr_t)msg->msgbytes) & 7));
     return 0;
 }
 
 static inline int LinkState_mkDecoder(struct Message* msg, struct VarInt_Iter* it)
 {
     if (!Message_getLength(msg)) { return 1; }
-    uint8_t len = msg->bytes[0];
+    uint8_t len = msg->msgbytes[0];
     if (Message_getLength(msg) < len) { return 1; }
     if (len < 3) { return 1; }
-    it->ptr = &msg->bytes[1];
+    it->ptr = &msg->msgbytes[1];
     it->start = it->ptr;
-    it->end = &msg->bytes[len];
+    it->end = &msg->msgbytes[len];
     // Ok to pop this using VarInt because it's supposed to be 3, which is less than 253
     uint64_t type = 0;
     if (VarInt_pop(it, &type)) { return 1; }

+ 2 - 2
subnode/MsgCore.c

@@ -282,7 +282,7 @@ static Iface_DEFUN incoming(struct Message* msg, struct Iface* interRouterIf)
         Identity_containerOf(interRouterIf, struct MsgCore_pvt, pub.interRouterIf);
 
     struct Address addr = { .padding = 0 };
-    struct RouteHeader* hdr = (struct RouteHeader*) msg->bytes;
+    struct RouteHeader* hdr = (struct RouteHeader*) msg->msgbytes;
     Er_assert(Message_eshift(msg, -(RouteHeader_SIZE + DataHeader_SIZE)));
     Bits_memcpy(addr.ip6.bytes, hdr->ip6, 16);
     Bits_memcpy(addr.key, hdr->publicKey, 32);
@@ -290,7 +290,7 @@ static Iface_DEFUN incoming(struct Message* msg, struct Iface* interRouterIf)
     addr.path = Endian_bigEndianToHost64(hdr->sh.label_be);
 
     Dict* content = NULL;
-    uint8_t* msgBytes = msg->bytes;
+    uint8_t* msgBytes = msg->msgbytes;
     int length = Message_getLength(msg);
     //Log_debug(mcp->log, "Receive msg [%s] from [%s]",
     //    Escape_getEscaped(msg->bytes, Message_getLength(msg), Message_getAlloc(msg)),

+ 6 - 6
subnode/ReachabilityAnnouncer.c

@@ -80,7 +80,7 @@ static int64_t timeUntilReannounce(
 
 static int64_t timestampFromMsg(struct Message* msg)
 {
-    struct Announce_Header* hdr = (struct Announce_Header*) msg->bytes;
+    struct Announce_Header* hdr = (struct Announce_Header*) msg->msgbytes;
     Assert_true(Message_getLength(msg) >= Announce_Header_SIZE);
     return Announce_Header_getTimestamp(hdr);
 }
@@ -110,7 +110,7 @@ static void hashMsgList(struct ArrayList_OfMessages* msgList, uint8_t out[64])
     for (int i = 0; i < msgList->length; i++) {
         struct Message* msg = ArrayList_OfMessages_get(msgList, i);
         Er_assert(Message_epush(msg, hash, 64));
-        crypto_hash_sha512(hash, msg->bytes, Message_getLength(msg));
+        crypto_hash_sha512(hash, msg->msgbytes, Message_getLength(msg));
         Er_assert(Message_epop(msg, NULL, 64));
     }
     Bits_memcpy(out, hash, 64);
@@ -358,7 +358,7 @@ static int updateItem(struct ReachabilityAnnouncer_pvt* rap,
     }
 
     Er_assert(Message_epush(msg, refItem, refItem->length));
-    while ((uintptr_t)msg->bytes % 4) {
+    while ((uintptr_t)msg->msgbytes % 4) {
         // Ensure alignment
         Er_assert(Message_epush8(msg, 1));
     }
@@ -686,7 +686,7 @@ static void onAnnounceCycle(void* vRap)
 
     Er_assert(Message_epush(msg, NULL, Announce_Header_SIZE));
 
-    struct Announce_Header* hdr = (struct Announce_Header*) msg->bytes;
+    struct Announce_Header* hdr = (struct Announce_Header*) msg->msgbytes;
     Bits_memset(hdr, 0, Announce_Header_SIZE);
     Announce_Header_setVersion(hdr, Announce_Header_CURRENT_VERSION);
     Announce_Header_setReset(hdr, rap->resetState);
@@ -711,7 +711,7 @@ static void onAnnounceCycle(void* vRap)
     qp->target = &q->target;
 
     Dict_putStringCC(dict, "sq", "ann", qp->alloc);
-    String* annString = String_newBinary(msg->bytes, Message_getLength(msg), qp->alloc);
+    String* annString = String_newBinary(msg->msgbytes, Message_getLength(msg), qp->alloc);
     Dict_putStringC(dict, "ann", annString, qp->alloc);
 
     rap->onTheWire = q;
@@ -773,7 +773,7 @@ static struct Announce_ItemHeader* mkEncodingSchemeItem(
     Er_assert(Message_epush8(esMsg, compressedScheme->len + 2));
 
     struct Announce_ItemHeader* item = Allocator_calloc(alloc, Message_getLength(esMsg), 1);
-    Bits_memcpy(item, esMsg->bytes, Message_getLength(esMsg));
+    Bits_memcpy(item, esMsg->msgbytes, Message_getLength(esMsg));
     Allocator_free(tmpAlloc);
     return item;
 }

+ 3 - 3
subnode/SubnodePathfinder.c

@@ -106,9 +106,9 @@ static Iface_DEFUN sendNode(struct Message* msg,
 {
     Message_reset(msg);
     Er_assert(Message_eshift(msg, PFChan_Node_SIZE));
-    nodeForAddress((struct PFChan_Node*) msg->bytes, addr, metric);
+    nodeForAddress((struct PFChan_Node*) msg->msgbytes, addr, metric);
     if (addr->path == UINT64_MAX) {
-        ((struct PFChan_Node*) msg->bytes)->path_be = 0;
+        ((struct PFChan_Node*) msg->msgbytes)->path_be = 0;
     }
     Er_assert(Message_epush32be(msg, msgType));
     return Iface_next(&pf->pub.eventIf, msg);
@@ -473,7 +473,7 @@ static Iface_DEFUN incomingFromMsgCore(struct Message* msg, struct Iface* iface)
     struct SubnodePathfinder_pvt* pf =
         Identity_containerOf(iface, struct SubnodePathfinder_pvt, msgCoreIf);
     Assert_true(Message_getLength(msg) >= (RouteHeader_SIZE + DataHeader_SIZE));
-    struct RouteHeader* rh = (struct RouteHeader*) msg->bytes;
+    struct RouteHeader* rh = (struct RouteHeader*) msg->msgbytes;
     struct DataHeader* dh = (struct DataHeader*) &rh[1];
     Assert_true(DataHeader_getContentType(dh) == ContentType_CJDHT);
     Assert_true(!Bits_isZero(rh->publicKey, 32));

+ 1 - 1
subnode/test/LinkState_test.c

@@ -75,7 +75,7 @@ static void randomLsUpdate(struct Random* rand, struct LinkState* ls)
 static void applyStateUpdates(struct LinkState* local, struct Message* msg)
 {
     if (!Message_getLength(msg)) { return; }
-    uint8_t length = msg->bytes[0];
+    uint8_t length = msg->msgbytes[0];
     struct VarInt_Iter it;
     Assert_true(!LinkState_mkDecoder(msg, &it));
     uint32_t id = 0;

+ 4 - 4
switch/SwitchCore.c

@@ -74,7 +74,7 @@ static inline Iface_DEFUN sendError(struct SwitchInterface* iface,
         return Error(RUNT);
     }
 
-    struct SwitchHeader* causeHeader = (struct SwitchHeader*) cause->bytes;
+    struct SwitchHeader* causeHeader = (struct SwitchHeader*) cause->msgbytes;
 
     if (SwitchHeader_getSuppressErrors(causeHeader)) {
         // don't send errors if they're asking us to suppress them!
@@ -90,7 +90,7 @@ static inline Iface_DEFUN sendError(struct SwitchInterface* iface,
     Er_assert(Message_epush(cause,
                  NULL,
                  SwitchHeader_SIZE + 4 + Control_Header_SIZE + Control_Error_HEADER_SIZE));
-    struct ErrorPacket8* err = (struct ErrorPacket8*) cause->bytes;
+    struct ErrorPacket8* err = (struct ErrorPacket8*) cause->msgbytes;
 
     err->switchHeader.label_be = Bits_bitReverse64(causeHeader->label_be);
     SwitchHeader_setSuppressErrors(&err->switchHeader, true);
@@ -123,7 +123,7 @@ static Iface_DEFUN receiveMessage(struct Message* message, struct Iface* iface)
         return Error(RUNT);
     }
 
-    struct SwitchHeader* header = (struct SwitchHeader*) message->bytes;
+    struct SwitchHeader* header = (struct SwitchHeader*) message->msgbytes;
     const uint64_t label = Endian_bigEndianToHost64(header->label_be);
     uint32_t bits = NumberCompress_bitsUsedForLabel(label);
     const uint32_t sourceIndex = sourceIf - core->interfaces;
@@ -207,7 +207,7 @@ static Iface_DEFUN receiveMessage(struct Message* message, struct Iface* iface)
     int cloneLength = (Message_getLength(message) < Control_Error_MAX_SIZE) ?
         Message_getLength(message) : Control_Error_MAX_SIZE;
     uint8_t messageClone[Control_Error_MAX_SIZE];
-    Bits_memcpy(messageClone, message->bytes, cloneLength);
+    Bits_memcpy(messageClone, message->msgbytes, cloneLength);
 
     // Update the header
     header->label_be = Endian_hostToBigEndian64(targetLabel);

+ 3 - 3
test/Beacon_test.c

@@ -74,7 +74,7 @@ static Iface_DEFUN incomingTunB(struct Message* msg, struct Iface* tunB)
     uint16_t t = Er_assert(TUNMessageType_pop(msg));
     Assert_true(t == Ethernet_TYPE_IP6);
     Er_assert(Message_eshift(msg, -Headers_IP6Header_SIZE));
-    printf("Message from TUN in node B [%s]\n", msg->bytes);
+    printf("Message from TUN in node B [%s]\n", msg->msgbytes);
     tn->messageFrom = TUNB;
     return Error(NONE);
 }
@@ -86,8 +86,8 @@ static Iface_DEFUN incomingTunA(struct Message* msg, struct Iface* tunA)
     Assert_true(t == Ethernet_TYPE_IP6);
     Er_assert(Message_eshift(msg, -Headers_IP6Header_SIZE));
     uint8_t buff[1024];
-    Hex_encode(buff, 1024, msg->bytes, Message_getLength(msg));
-    printf("Message from TUN in node A [%s] [%d] [%s]\n", msg->bytes, Message_getLength(msg), buff);
+    Hex_encode(buff, 1024, msg->msgbytes, Message_getLength(msg));
+    printf("Message from TUN in node A [%s] [%d] [%s]\n", msg->msgbytes, Message_getLength(msg), buff);
     tn->messageFrom = TUNA;
     return Error(NONE);
 }

+ 4 - 4
test/Main_fuzz_test.c

@@ -150,7 +150,7 @@ void CJDNS_FUZZ_MAIN(void* vctx, struct Message* msg)
     // Lets fill in the ipv6, pubkey & label so that any
     // old packet dump will work fine for testing
     {
-        struct RouteHeader* rh = (struct RouteHeader*) msg->bytes;
+        struct RouteHeader* rh = (struct RouteHeader*) msg->msgbytes;
         Bits_memcpy(rh->ip6, to->ip, 16);
         Bits_memcpy(rh->publicKey, to->publicKey, 32);
         rh->version_be = Endian_hostToBigEndian32(Version_CURRENT_PROTOCOL);
@@ -176,11 +176,11 @@ void CJDNS_FUZZ_MAIN(void* vctx, struct Message* msg)
     // fc00::1
     AddressCalc_makeValidAddress(&srcAndDest[16]);
     Bits_memcpy(&srcAndDest, from->ip, 16);
-    uint16_t checksum_be = Checksum_udpIp6_be(srcAndDest, msg->bytes, Message_getLength(msg));
-    ((struct Headers_UDPHeader*)msg->bytes)->checksum_be = checksum_be;
+    uint16_t checksum_be = Checksum_udpIp6_be(srcAndDest, msg->msgbytes, Message_getLength(msg));
+    ((struct Headers_UDPHeader*)msg->msgbytes)->checksum_be = checksum_be;
 
     TestFramework_craftIPHeader(msg, srcAndDest, &srcAndDest[16]);
-    ((struct Headers_IP6Header*) msg->bytes)->nextHeader = 17;
+    ((struct Headers_IP6Header*) msg->msgbytes)->nextHeader = 17;
 
     Er_assert(TUNMessageType_push(msg, Ethernet_TYPE_IP6));
 

+ 3 - 3
test/TestFramework.c

@@ -61,7 +61,7 @@ static Iface_DEFUN sendTo(struct Message* msg,
                           struct TestFramework* srcTf,
                           struct TestFramework* destTf)
 {
-    Assert_true(!((uintptr_t)msg->bytes % 4) || !"alignment fault");
+    Assert_true(!((uintptr_t)msg->msgbytes % 4) || !"alignment fault");
     Assert_true(!(Message_getCapacity(msg) % 4) || !"length fault");
     Assert_true(((int)Message_getCapacity(msg) >= Message_getLength(msg)) || !"length fault0");
 
@@ -179,7 +179,7 @@ void TestFramework_assertLastMessageUnaltered(struct TestFramework* tf)
     struct Message* b = tf->lastMsgBackup;
     Assert_true(Message_getLength(a) == Message_getLength(b));
     Assert_true(Message_getPadding(a) == Message_getPadding(b));
-    Assert_true(!Bits_memcmp(a->bytes, b->bytes, Message_getLength(a)));
+    Assert_true(!Bits_memcmp(a->msgbytes, b->msgbytes, Message_getLength(a)));
 }
 
 void TestFramework_linkNodes(struct TestFramework* client,
@@ -233,7 +233,7 @@ void TestFramework_linkNodes(struct TestFramework* client,
 void TestFramework_craftIPHeader(struct Message* msg, uint8_t srcAddr[16], uint8_t destAddr[16])
 {
     Er_assert(Message_eshift(msg, Headers_IP6Header_SIZE));
-    struct Headers_IP6Header* ip = (struct Headers_IP6Header*) msg->bytes;
+    struct Headers_IP6Header* ip = (struct Headers_IP6Header*) msg->msgbytes;
 
     ip->versionClassAndFlowLabel = 0;
     ip->flowLabelLow_be = 0;

+ 17 - 17
tunnel/IpTunnel.c

@@ -200,7 +200,7 @@ static Iface_DEFUN sendToNode(struct Message* message,
                               struct IpTunnel_pvt* context)
 {
     Er_assert(Message_epush(message, NULL, DataHeader_SIZE));
-    struct DataHeader* dh = (struct DataHeader*) message->bytes;
+    struct DataHeader* dh = (struct DataHeader*) message->msgbytes;
     DataHeader_setContentType(dh, ContentType_IPTUN);
     DataHeader_setVersion(dh, DataHeader_CURRENT_VERSION);
     Er_assert(Message_epush(message, &connection->routeHeader, RouteHeader_SIZE));
@@ -219,7 +219,7 @@ static void sendControlMessage(Dict* dict,
 
     // do UDP header.
     Er_assert(Message_eshift(msg, Headers_UDPHeader_SIZE));
-    struct Headers_UDPHeader* uh = (struct Headers_UDPHeader*) msg->bytes;
+    struct Headers_UDPHeader* uh = (struct Headers_UDPHeader*) msg->msgbytes;
     uh->srcPort_be = 0;
     uh->destPort_be = 0;
     uh->length_be = Endian_hostToBigEndian16(length);
@@ -228,7 +228,7 @@ static void sendControlMessage(Dict* dict,
     uint16_t payloadLength = Message_getLength(msg);
 
     Er_assert(Message_eshift(msg, Headers_IP6Header_SIZE));
-    struct Headers_IP6Header* header = (struct Headers_IP6Header*) msg->bytes;
+    struct Headers_IP6Header* header = (struct Headers_IP6Header*) msg->msgbytes;
     header->versionClassAndFlowLabel = 0;
     header->flowLabelLow_be = 0;
     header->nextHeader = 17;
@@ -318,7 +318,7 @@ int IpTunnel_removeConnection(int connectionNumber, struct IpTunnel* tunnel)
 
 static bool isControlMessageInvalid(struct Message* message, struct IpTunnel_pvt* context)
 {
-    struct Headers_IP6Header* header = (struct Headers_IP6Header*) message->bytes;
+    struct Headers_IP6Header* header = (struct Headers_IP6Header*) message->msgbytes;
     uint16_t length = Endian_bigEndianToHost16(header->payloadLength_be);
     if (header->nextHeader != 17 || Message_getLength(message) < length + Headers_IP6Header_SIZE) {
         Log_warn(context->logger, "Invalid IPv6 packet (not UDP or length field too big)");
@@ -326,9 +326,9 @@ static bool isControlMessageInvalid(struct Message* message, struct IpTunnel_pvt
     }
 
     Er_assert(Message_eshift(message, -Headers_IP6Header_SIZE));
-    struct Headers_UDPHeader* udp = (struct Headers_UDPHeader*) message->bytes;
+    struct Headers_UDPHeader* udp = (struct Headers_UDPHeader*) message->msgbytes;
 
-    if (Checksum_udpIp6_be(header->sourceAddr, message->bytes, length)) {
+    if (Checksum_udpIp6_be(header->sourceAddr, message->msgbytes, length)) {
         Log_warn(context->logger, "Checksum mismatch");
         return true;
     }
@@ -585,7 +585,7 @@ static Iface_DEFUN incomingControlMessage(struct Message* message,
     }
 
     Log_debug(context->logger, "Message content [%s]",
-        Escape_getEscaped(message->bytes, Message_getLength(message), Message_getAlloc(message)));
+        Escape_getEscaped(message->msgbytes, Message_getLength(message), Message_getAlloc(message)));
 
     struct Allocator* alloc = Allocator_child(Message_getAlloc(message));
 
@@ -705,11 +705,11 @@ static Iface_DEFUN incomingFromTun(struct Message* message, struct Iface* tunIf)
     struct IpTunnel_Connection* conn = NULL;
     if (!context->pub.connectionList.connections) {
         // No connections authorized, fall through to "unrecognized address"
-    } else if (Message_getLength(message) > 40 && Headers_getIpVersion(message->bytes) == 6) {
-        struct Headers_IP6Header* header = (struct Headers_IP6Header*) message->bytes;
+    } else if (Message_getLength(message) > 40 && Headers_getIpVersion(message->msgbytes) == 6) {
+        struct Headers_IP6Header* header = (struct Headers_IP6Header*) message->msgbytes;
         conn = findConnection(header->sourceAddr, NULL, true, context);
-    } else if (Message_getLength(message) > 20 && Headers_getIpVersion(message->bytes) == 4) {
-        struct Headers_IP4Header* header = (struct Headers_IP4Header*) message->bytes;
+    } else if (Message_getLength(message) > 20 && Headers_getIpVersion(message->msgbytes) == 4) {
+        struct Headers_IP4Header* header = (struct Headers_IP4Header*) message->msgbytes;
         conn = findConnection(NULL, header->sourceAddr, true, context);
     } else {
         Log_debug(context->logger, "Message of unknown type from TUN");
@@ -728,7 +728,7 @@ static Iface_DEFUN ip6FromNode(struct Message* message,
                                struct IpTunnel_Connection* conn,
                                struct IpTunnel_pvt* context)
 {
-    struct Headers_IP6Header* header = (struct Headers_IP6Header*) message->bytes;
+    struct Headers_IP6Header* header = (struct Headers_IP6Header*) message->msgbytes;
     if (Bits_isZero(header->sourceAddr, 16) || Bits_isZero(header->destinationAddr, 16)) {
         if (Bits_isZero(header->sourceAddr, 32)) {
             return incomingControlMessage(message, conn, context);
@@ -751,7 +751,7 @@ static Iface_DEFUN ip4FromNode(struct Message* message,
                                struct IpTunnel_Connection* conn,
                                struct IpTunnel_pvt* context)
 {
-    struct Headers_IP4Header* header = (struct Headers_IP4Header*) message->bytes;
+    struct Headers_IP4Header* header = (struct Headers_IP4Header*) message->msgbytes;
     if (Bits_isZero(header->sourceAddr, 4) || Bits_isZero(header->destAddr, 4)) {
         Log_debug(context->logger, "Got message with zero address");
         return Error(INVALID);
@@ -778,7 +778,7 @@ static Iface_DEFUN incomingFromNode(struct Message* message, struct Iface* nodeI
     //Log_debug(context->logger, "Got incoming message");
 
     Assert_true(Message_getLength(message) >= RouteHeader_SIZE + DataHeader_SIZE);
-    struct RouteHeader* rh = (struct RouteHeader*) message->bytes;
+    struct RouteHeader* rh = (struct RouteHeader*) message->msgbytes;
     struct DataHeader* dh = (struct DataHeader*) &rh[1];
     Assert_true(DataHeader_getContentType(dh) == ContentType_IPTUN);
     struct IpTunnel_Connection* conn = connectionByPubKey(rh->publicKey, context);
@@ -793,10 +793,10 @@ static Iface_DEFUN incomingFromNode(struct Message* message, struct Iface* nodeI
 
     Er_assert(Message_eshift(message, -(RouteHeader_SIZE + DataHeader_SIZE)));
 
-    if (Message_getLength(message) > 40 && Headers_getIpVersion(message->bytes) == 6) {
+    if (Message_getLength(message) > 40 && Headers_getIpVersion(message->msgbytes) == 6) {
         return ip6FromNode(message, conn, context);
     }
-    if (Message_getLength(message) > 20 && Headers_getIpVersion(message->bytes) == 4) {
+    if (Message_getLength(message) > 20 && Headers_getIpVersion(message->msgbytes) == 4) {
         return ip4FromNode(message, conn, context);
     }
 
@@ -806,7 +806,7 @@ static Iface_DEFUN incomingFromNode(struct Message* message, struct Iface* nodeI
         Log_debug(context->logger,
                   "Got message of unknown type, length: [%d], IP version [%d] from [%s]",
                   Message_getLength(message),
-                  (Message_getLength(message) > 1) ? Headers_getIpVersion(message->bytes) : 0,
+                  (Message_getLength(message) > 1) ? Headers_getIpVersion(message->msgbytes) : 0,
                   addr);
     }
     return Error(INVALID);

+ 17 - 17
tunnel/test/IpTunnel_test.c

@@ -60,12 +60,12 @@ struct IfaceContext
 static Iface_DEFUN responseWithIpCallback(struct Message* message, struct Iface* iface)
 {
     struct Context* ctx = Identity_check(((struct IfaceContext*)iface)->ctx);
-    struct RouteHeader* rh = (struct RouteHeader*) message->bytes;
+    struct RouteHeader* rh = (struct RouteHeader*) message->msgbytes;
     Assert_true(!Bits_memcmp(ctx->ipv6, rh->ip6, 16));
     Assert_true(!Bits_memcmp(ctx->pubKey, rh->publicKey, 32));
 
     Er_assert(Message_eshift(message, -(RouteHeader_SIZE + DataHeader_SIZE)));
-    struct Headers_IP6Header* ip = (struct Headers_IP6Header*) message->bytes;
+    struct Headers_IP6Header* ip = (struct Headers_IP6Header*) message->msgbytes;
     Assert_true(Headers_getIpVersion(ip) == 6);
     uint16_t length = Endian_bigEndianToHost16(ip->payloadLength_be);
     Assert_true(length + Headers_IP6Header_SIZE == Message_getLength(message));
@@ -73,8 +73,8 @@ static Iface_DEFUN responseWithIpCallback(struct Message* message, struct Iface*
     Assert_true(Bits_isZero(ip->sourceAddr, 32));
 
     Er_assert(Message_eshift(message, -Headers_IP6Header_SIZE));
-    struct Headers_UDPHeader* uh = (struct Headers_UDPHeader*) message->bytes;
-    Assert_true(!Checksum_udpIp6_be(ip->sourceAddr, message->bytes, length));
+    struct Headers_UDPHeader* uh = (struct Headers_UDPHeader*) message->msgbytes;
+    Assert_true(!Checksum_udpIp6_be(ip->sourceAddr, message->msgbytes, length));
 
     Assert_true(uh->srcPort_be == 0);
     Assert_true(uh->destPort_be == 0);
@@ -83,7 +83,7 @@ static Iface_DEFUN responseWithIpCallback(struct Message* message, struct Iface*
     Er_assert(Message_eshift(message, -Headers_UDPHeader_SIZE));
 
     struct Allocator* alloc = Allocator_child(ctx->alloc);
-    char* messageContent = Escape_getEscaped(message->bytes, Message_getLength(message), alloc);
+    char* messageContent = Escape_getEscaped(message->msgbytes, Message_getLength(message), alloc);
     char* expectedContent =
         Escape_getEscaped(ctx->expectedResponse->bytes, ctx->expectedResponse->len, alloc);
     Log_debug(ctx->log, "Response: [%s]", messageContent);
@@ -94,7 +94,7 @@ static Iface_DEFUN responseWithIpCallback(struct Message* message, struct Iface*
     // alignment of the output but we can make sure the right content is there...
     // Message should start with "d0000" (with some number of zeros)
     Assert_true((int)ctx->expectedResponse->len == Message_getLength(message));
-    Assert_true(!Bits_memcmp(message->bytes, ctx->expectedResponse->bytes, Message_getLength(message)));
+    Assert_true(!Bits_memcmp(message->msgbytes, ctx->expectedResponse->bytes, Message_getLength(message)));
     ctx->called |= 2;
 
     return Error(NONE);
@@ -105,13 +105,13 @@ static Iface_DEFUN messageToTun(struct Message* msg, struct Iface* iface)
     struct Context* ctx = Identity_check(((struct IfaceContext*)iface)->ctx);
     uint16_t type = Er_assert(TUNMessageType_pop(msg));
     if (type == Ethernet_TYPE_IP6) {
-        struct Headers_IP6Header* ip = (struct Headers_IP6Header*) msg->bytes;
+        struct Headers_IP6Header* ip = (struct Headers_IP6Header*) msg->msgbytes;
         Assert_true(Headers_getIpVersion(ip) == 6);
         Assert_true(!Bits_memcmp(ip->sourceAddr, ctx->sendingAddress, 16));
         Er_assert(Message_eshift(msg, -Headers_IP6Header_SIZE));
         ctx->called |= 4;
     } else if (type == Ethernet_TYPE_IP4) {
-        struct Headers_IP4Header* ip = (struct Headers_IP4Header*) msg->bytes;
+        struct Headers_IP4Header* ip = (struct Headers_IP4Header*) msg->msgbytes;
         Assert_true(Headers_getIpVersion(ip) == 4);
         Assert_true(!Bits_memcmp(ip->sourceAddr, ctx->sendingAddress, 4));
         Er_assert(Message_eshift(msg, -Headers_IP4Header_SIZE));
@@ -119,14 +119,14 @@ static Iface_DEFUN messageToTun(struct Message* msg, struct Iface* iface)
     } else {
         Assert_failure("unrecognized message type %u", (unsigned int)type);
     }
-    Assert_true(Message_getLength(msg) == 12 && CString_strcmp(msg->bytes, "hello world") == 0);
+    Assert_true(Message_getLength(msg) == 12 && CString_strcmp(msg->msgbytes, "hello world") == 0);
     return Error(NONE);
 }
 
 static void pushRouteDataHeaders(struct Context* ctx, struct Message* message)
 {
     Er_assert(Message_eshift(message, RouteHeader_SIZE + DataHeader_SIZE));
-    struct RouteHeader* rh = (struct RouteHeader*) message->bytes;
+    struct RouteHeader* rh = (struct RouteHeader*) message->msgbytes;
     struct DataHeader* dh = (struct DataHeader*) &rh[1];
     Bits_memset(rh, 0, RouteHeader_SIZE + DataHeader_SIZE);
     Bits_memcpy(rh->ip6, ctx->ipv6, 16);
@@ -142,7 +142,7 @@ static bool trySend4(struct Allocator* alloc,
     struct Message* msg4 = Message_new(0, 512, alloc);
     Er_assert(Message_epush(msg4, "hello world", 12));
     Er_assert(Message_epush(msg4, NULL, Headers_IP4Header_SIZE));
-    struct Headers_IP4Header* iph = (struct Headers_IP4Header*) msg4->bytes;
+    struct Headers_IP4Header* iph = (struct Headers_IP4Header*) msg4->msgbytes;
     Headers_setIpVersion(iph);
     uint32_t addr_be = Endian_hostToBigEndian32(addr);
     Bits_memcpy(iph->sourceAddr, &addr_be, 4);
@@ -167,7 +167,7 @@ static bool trySend6(struct Allocator* alloc,
     struct Message* msg6 = Message_new(0, 512, alloc);
     Er_assert(Message_epush(msg6, "hello world", 12));
     Er_assert(Message_epush(msg6, NULL, Headers_IP6Header_SIZE));
-    struct Headers_IP6Header* iph = (struct Headers_IP6Header*) msg6->bytes;
+    struct Headers_IP6Header* iph = (struct Headers_IP6Header*) msg6->msgbytes;
     Headers_setIpVersion(iph);
     uint64_t addrHigh_be = Endian_hostToBigEndian64(addrHigh);
     uint64_t addrLow_be = Endian_hostToBigEndian64(addrLow);
@@ -217,7 +217,7 @@ static String* getExpectedResponse(struct Sockaddr* sa4, int prefix4, int alloc4
     struct Message* msg = Message_new(0, 512, alloc);
     Er_assert(BencMessageWriter_write(output, msg));
 
-    String* outStr = String_newBinary(msg->bytes, Message_getLength(msg), allocator);
+    String* outStr = String_newBinary(msg->msgbytes, Message_getLength(msg), allocator);
     Allocator_free(alloc);
     return outStr;
 }
@@ -256,20 +256,20 @@ static void testAddr(struct Context* ctx,
           "1:q" "21:IpTunnel_getAddresses"
           "4:txid" "4:abcd"
         "e";
-    CString_strcpy(msg->bytes, requestForAddresses);
+    CString_strcpy(msg->msgbytes, requestForAddresses);
     Er_assert(Message_truncate(msg, CString_strlen(requestForAddresses)));
 
     Er_assert(Message_epush(msg, NULL, Headers_UDPHeader_SIZE));
-    struct Headers_UDPHeader* uh = (struct Headers_UDPHeader*) msg->bytes;
+    struct Headers_UDPHeader* uh = (struct Headers_UDPHeader*) msg->msgbytes;
     uh->length_be = Endian_hostToBigEndian16(Message_getLength(msg) - Headers_UDPHeader_SIZE);
 
-    uint16_t* checksum_be = &((struct Headers_UDPHeader*) msg->bytes)->checksum_be;
+    uint16_t* checksum_be = &((struct Headers_UDPHeader*) msg->msgbytes)->checksum_be;
     *checksum_be = 0;
     uint32_t length = Message_getLength(msg);
 
     // Because of old reasons, we need to have at least an empty IPv6 header
     Er_assert(Message_epush(msg, NULL, Headers_IP6Header_SIZE));
-    struct Headers_IP6Header* ip = (struct Headers_IP6Header*) msg->bytes;
+    struct Headers_IP6Header* ip = (struct Headers_IP6Header*) msg->msgbytes;
     Headers_setIpVersion(ip);
     ip->payloadLength_be = Endian_hostToBigEndian16(Message_getLength(msg) - Headers_IP6Header_SIZE);
     ip->nextHeader = 17;

+ 5 - 5
util/events/libuv/Pipe.c

@@ -92,7 +92,7 @@ static void sendMessage2(struct Pipe_WriteRequest_pvt* req)
     struct Message* m = req->msg;
 
     uv_buf_t buffers[] = {
-        { .base = (char*)m->bytes, .len = Message_getLength(m) }
+        { .base = (char*)m->msgbytes, .len = Message_getLength(m) }
     };
 
     int ret = -1;
@@ -155,9 +155,9 @@ static Iface_DEFUN sendMessage(struct Message* m, struct Iface* iface)
             Log_debug(pipe->log, "Appending to the buffered message");
             struct Message* m2 = Message_new(0,
                 Message_getLength(m) + Message_getLength(pipe->bufferedRequest->msg), reqAlloc);
-            Er_assert(Message_epush(m2, m->bytes, Message_getLength(m)));
+            Er_assert(Message_epush(m2, m->msgbytes, Message_getLength(m)));
             Er_assert(Message_epush(m2,
-                pipe->bufferedRequest->msg->bytes,
+                pipe->bufferedRequest->msg->msgbytes,
                 Message_getLength(pipe->bufferedRequest->msg)));
             req->msg = m2;
             Allocator_free(pipe->bufferedRequest->alloc);
@@ -235,9 +235,9 @@ static void allocate(uv_handle_t* handle, size_t size, uv_buf_t* buf)
     struct Allocator* child = Allocator_child(pipe->alloc);
     struct Message* msg = Message_new(size, Pipe_PADDING_AMOUNT, child);
 
-    ALLOC(msg->bytes) = msg;
+    ALLOC(msg->msgbytes) = msg;
 
-    buf->base = msg->bytes;
+    buf->base = msg->msgbytes;
     buf->len = size;
 }
 

+ 5 - 5
util/events/libuv/UDPAddrIface.c

@@ -83,7 +83,7 @@ static Iface_DEFUN incomingFromIface(struct Message* m, struct Iface* iface)
     struct UDPAddrIface_pvt* context = Identity_check((struct UDPAddrIface_pvt*) iface);
 
     Assert_true(Message_getLength(m) >= Sockaddr_OVERHEAD);
-    if (((struct Sockaddr*)m->bytes)->flags & Sockaddr_flags_BCAST) {
+    if (((struct Sockaddr*)m->msgbytes)->flags & Sockaddr_flags_BCAST) {
         Log_debug(context->logger, "Attempted bcast, bcast unsupported");
         // bcast not supported.
         return Error(UNHANDLED);
@@ -114,7 +114,7 @@ static Iface_DEFUN incomingFromIface(struct Message* m, struct Iface* iface)
     req->length = Message_getLength(m);
 
     uv_buf_t buffers[] = {
-        { .base = (char*)m->bytes, .len = Message_getLength(m) }
+        { .base = (char*)m->msgbytes, .len = Message_getLength(m) }
     };
 
     int ret = uv_udp_send(&req->uvReq, &context->uvHandle, buffers, 1,
@@ -160,7 +160,7 @@ static void incoming(uv_udp_t* handle,
 
         // make sure the sockaddr doesn't have crap in it which will
         // prevent it from being used as a lookup key
-        Sockaddr_normalizeNative((struct sockaddr*) msg->bytes);
+        Sockaddr_normalizeNative((struct sockaddr*) msg->msgbytes);
 
         Er_assert(Message_epush(msg, context->pub.generic.addr, Sockaddr_OVERHEAD));
 
@@ -195,9 +195,9 @@ static void allocate(uv_handle_t* handle, size_t size, uv_buf_t* buf)
         child
     );
 
-    ALLOC(msg->bytes) = msg;
+    ALLOC(msg->msgbytes) = msg;
 
-    buf->base = msg->bytes;
+    buf->base = msg->msgbytes;
     buf->len = size;
 }
 

+ 2 - 2
util/platform/netdev/NetPlatform_darwin.c

@@ -141,7 +141,7 @@ static Er_DEFUN(void setRoutes(uint32_t ifIndex,
         struct Message* msg = Message_new(0, 1024, alloc);
         Er(mkRouteMsg(msg, pfx, ifIndex, ifName, seq++, true));
         //printf("DELETE ROUTE %s\n", Hex_print(msg->bytes, Message_getLength(msg), alloc));
-        returnLen = write(sock, msg->bytes, Message_getLength(msg));
+        returnLen = write(sock, msg->msgbytes, Message_getLength(msg));
         if (returnLen < Message_getLength(msg)) { err = true; break; }
     }
     for (int i = 0; !err && i < toAdd->length; i++) {
@@ -150,7 +150,7 @@ static Er_DEFUN(void setRoutes(uint32_t ifIndex,
         struct Message* msg = Message_new(0, 1024, alloc);
         Er(mkRouteMsg(msg, pfx, ifIndex, ifName, seq++, false));
         //printf("ADD ROUTE %s\n", Hex_print(msg->bytes, Message_getLength(msg), alloc));
-        returnLen = write(sock, msg->bytes, Message_getLength(msg));
+        returnLen = write(sock, msg->msgbytes, Message_getLength(msg));
         if (returnLen < Message_getLength(msg)) { err = true; break; }
     }
 

+ 3 - 3
util/platform/netdev/NetPlatform_linux.c

@@ -241,7 +241,7 @@ static Er_DEFUN(bool getMoreMessages(struct RouteInfo** rio,
     bool retVal = false;
     struct Allocator* tempAlloc = Allocator_child(alloc);
     struct Message* msg = Message_new(BUFF_SZ, 0, tempAlloc);
-    ssize_t sz = recv(sock, msg->bytes, BUFF_SZ, MSG_TRUNC);
+    ssize_t sz = recv(sock, msg->msgbytes, BUFF_SZ, MSG_TRUNC);
     if (sz < (ssize_t)sizeof(struct nlmsghdr)) {
         Er_raise(tempAlloc, "recv() -> %s", strerror(errno));
     } else if (sz > BUFF_SZ) {
@@ -377,7 +377,7 @@ static Er_DEFUN(void addDeleteRoutes(int sock,
         Er(Message_epush(msg, &ifa, sizeof(struct IfIndexAttr)));
         int addrLen = (ri->af == AF_INET6) ? 16 : 4;
         Er(Message_epush(msg, ri->dstAddr, addrLen));
-        bitShave(msg->bytes, ri->prefix, ri->af);
+        bitShave(msg->msgbytes, ri->prefix, ri->af);
         struct rtattr rta = { .rta_len = sizeof(struct rtattr) + addrLen, .rta_type = RTA_DST };
         Er(Message_epush(msg, &rta, sizeof(struct rtattr)));
         struct rtmsg route = {
@@ -395,7 +395,7 @@ static Er_DEFUN(void addDeleteRoutes(int sock,
             .nlmsg_flags = NLM_F_REQUEST | ((delete) ? 0 : NLM_F_CREATE) // | NLM_F_ACK,
         };
         Er(Message_epush(msg, &hdr, sizeof(struct nlmsghdr)));
-        ssize_t sz = send(sock, msg->bytes, Message_getLength(msg), 0);
+        ssize_t sz = send(sock, msg->msgbytes, Message_getLength(msg), 0);
         if (sz < 0) {
             Er_raise(tempAlloc, "send() -> %s", strerror(errno));
         }

+ 1 - 1
util/test/Base10_test.c

@@ -43,7 +43,7 @@ int main()
         snprintf(buff, 31, "%lld", num);
 
         Assert_true(Message_getLength(msg) == (int)CString_strlen(buff));
-        Assert_true(!Bits_memcmp(msg->bytes, buff, Message_getLength(msg)));
+        Assert_true(!Bits_memcmp(msg->msgbytes, buff, Message_getLength(msg)));
 
         int64_t read = Er_assert(Base10_read(msg));
         Assert_true(read == num);

+ 2 - 2
util/test/Process_test.c

@@ -72,7 +72,7 @@ static Iface_DEFUN receiveMessageParent(struct Message* msg, struct Iface* iface
     struct Context* c = Identity_check((struct Context*) iface);
     Er_assert(AddrIface_popAddr(msg));
     Assert_true(Message_getLength(msg) == (int)CString_strlen(MESSAGEB)+1);
-    Assert_true(!Bits_memcmp(msg->bytes, MESSAGEB, CString_strlen(MESSAGEB)+1));
+    Assert_true(!Bits_memcmp(msg->msgbytes, MESSAGEB, CString_strlen(MESSAGEB)+1));
     Allocator_free(c->alloc);
     return Error(NONE);
 }
@@ -94,7 +94,7 @@ static Iface_DEFUN receiveMessageChild(struct Message* msg, struct Iface* iface)
     struct Message* m = Message_clone(msg, c->alloc);
     printf("Child received message\n");
     Assert_true(Message_getLength(m) == (int)CString_strlen(MESSAGE)+1);
-    Assert_true(!Bits_memcmp(m->bytes, MESSAGE, CString_strlen(MESSAGE)+1));
+    Assert_true(!Bits_memcmp(m->msgbytes, MESSAGE, CString_strlen(MESSAGE)+1));
 
     if (!Defined(win32)) {
         int fd = Message_getAssociatedFd(msg);

+ 1 - 1
util/test/Seccomp_test.c

@@ -100,7 +100,7 @@ static Iface_DEFUN receiveMessageParent(struct Message* msg, struct Iface* iface
     // PipeServer pushes a uint32 identifier of the client who sent the message
     Er_assert(AddrIface_popAddr(msg));
     Assert_true(Message_getLength(msg) == 3);
-    Assert_true(!Bits_memcmp(msg->bytes, "OK", 3));
+    Assert_true(!Bits_memcmp(msg->msgbytes, "OK", 3));
     EventBase_endLoop(ctx->eventBase);
     return Error(NONE);
 }

+ 7 - 7
wire/Announce.h

@@ -77,7 +77,7 @@ static inline void Announce_EncodingScheme_push(struct Message* pushTo, String*
     Er_assert(Message_epush(pushTo, compressedScheme->bytes, compressedScheme->len));
     Er_assert(Message_epush8(pushTo, Announce_Type_ENCODING_SCHEME));
     Er_assert(Message_epush8(pushTo, compressedScheme->len + 2));
-    while ((uintptr_t)pushTo->bytes % 4) {
+    while ((uintptr_t)pushTo->msgbytes % 4) {
         Er_assert(Message_epush8(pushTo, 1));
     }
 }
@@ -331,16 +331,16 @@ static inline struct Announce_ItemHeader* Announce_ItemHeader_next(struct Messag
 {
     struct Announce_ItemHeader* ih = (struct Announce_ItemHeader*) last;
     if (ih) {
-        Assert_true((uint8_t*)ih > &msg->bytes[-Message_getPadding(msg)]);
-        Assert_true((uint8_t*)ih < &msg->bytes[Message_getLength(msg)]);
+        Assert_true((uint8_t*)ih > &msg->msgbytes[-Message_getPadding(msg)]);
+        Assert_true((uint8_t*)ih < &msg->msgbytes[Message_getLength(msg)]);
         ih = (struct Announce_ItemHeader*) ( &((uint8_t*) ih)[ih->length] );
     } else {
-        ih = (struct Announce_ItemHeader*) &msg->bytes[Announce_Header_SIZE];
+        ih = (struct Announce_ItemHeader*) &msg->msgbytes[Announce_Header_SIZE];
     }
-    while ((uint8_t*)ih < &msg->bytes[Message_getLength(msg)]) {
+    while ((uint8_t*)ih < &msg->msgbytes[Message_getLength(msg)]) {
         if (!ih->length) { return NULL; } // invalid message
         if (ih->length > 1) {
-            if ( &((uint8_t*) ih)[ih->length] > &msg->bytes[Message_getLength(msg)] ) {
+            if ( &((uint8_t*) ih)[ih->length] > &msg->msgbytes[Message_getLength(msg)] ) {
                 // invalid message, overflow...
                 return NULL;
             }
@@ -411,7 +411,7 @@ static inline bool Announce_isValid(struct Message* msg)
     for (;;) {
         ih = Announce_ItemHeader_next(msg, ih);
         if (!ih) { return false; }
-        if ((uint8_t*)ih == &msg->bytes[Message_getLength(msg) - ih->length]) { return true; }
+        if ((uint8_t*)ih == &msg->msgbytes[Message_getLength(msg) - ih->length]) { return true; }
     }
 }
 

+ 4 - 4
wire/Message.c

@@ -23,7 +23,7 @@ struct Message* Message_new(uint32_t messageLength,
     struct Message* out = Allocator_calloc(alloc, sizeof(struct Message), 1);
     out->_ad = buff;
     out->_adLen = 0;
-    out->bytes = &buff[amountOfPadding];
+    out->msgbytes = &buff[amountOfPadding];
     out->_length = out->_capacity = messageLength;
     out->_padding = amountOfPadding;
     out->_alloc = alloc;
@@ -57,14 +57,14 @@ struct Message* Message_clone(struct Message* toClone, struct Allocator* alloc)
     Assert_true(toClone->_capacity >= toClone->_length);
     int32_t len = toClone->_capacity + toClone->_padding + toClone->_adLen;
     uint8_t* allocation = Allocator_malloc(alloc, len + 8);
-    while (((uintptr_t)allocation % 8) != (((uintptr_t)toClone->bytes - toClone->_padding - toClone->_adLen) % 8)) {
+    while (((uintptr_t)allocation % 8) != (((uintptr_t)toClone->msgbytes - toClone->_padding - toClone->_adLen) % 8)) {
         allocation++;
     }
-    Bits_memcpy(allocation, toClone->bytes - toClone->_padding - toClone->_adLen, len);
+    Bits_memcpy(allocation, toClone->msgbytes - toClone->_padding - toClone->_adLen, len);
     return Allocator_clone(alloc, (&(struct Message) {
         ._length = toClone->_length,
         ._padding = toClone->_padding,
-        .bytes = allocation + toClone->_adLen + toClone->_padding,
+        .msgbytes = allocation + toClone->_adLen + toClone->_padding,
         ._ad = allocation + toClone->_adLen,
         ._adLen = toClone->_adLen,
         ._capacity = toClone->_capacity,

+ 10 - 10
wire/Message.h

@@ -33,7 +33,7 @@ typedef struct Message
     int32_t _padding;
 
     /** The content. */
-    uint8_t* bytes;
+    uint8_t* msgbytes;
 
     /** Amount of bytes of storage space available in the message. */
     int32_t _capacity;
@@ -65,7 +65,7 @@ static inline struct Allocator* Message_getAlloc(struct Message* msg)
     return msg->_alloc;
 }
 
-static inline uint32_t Message_getLength(struct Message* msg)
+static inline int32_t Message_getLength(struct Message* msg)
 {
     return msg->_length;
 }
@@ -79,19 +79,19 @@ static inline Er_DEFUN(void Message_truncate(struct Message* msg, int32_t newLen
     Er_ret();
 }
 
-static inline uint32_t Message_getPadding(struct Message* msg)
+static inline int32_t Message_getPadding(struct Message* msg)
 {
     return msg->_padding;
 }
 
-static inline uint32_t Message_getCapacity(struct Message* msg)
+static inline int32_t Message_getCapacity(struct Message* msg)
 {
     return msg->_capacity;
 }
 
 static inline Message_t Message_foreign(uint32_t len, uint8_t* bytes)
 {
-    return (Message_t){ ._length = len, .bytes = bytes, ._capacity = len };
+    return (Message_t){ ._length = len, .msgbytes = bytes, ._capacity = len };
 }
 
 // static inline Er_DEFUN(void Message_ecopy(struct Message* to, struct Message* from, uint32_t amt))
@@ -114,7 +114,7 @@ static inline Er_DEFUN(uint8_t* Message_peakBytes(struct Message* msg, int32_t l
     if (len > msg->_length) {
         Er_raise(msg->_alloc, "peakBytes(%d) too big, message length is %d", len, msg->_length);
     }
-    Er_ret(msg->bytes);
+    Er_ret(msg->msgbytes);
 }
 
 /**
@@ -132,7 +132,7 @@ static inline Er_DEFUN(void Message_eshift(struct Message* toShift, int32_t amou
 
     toShift->_length += amount;
     toShift->_capacity += amount;
-    toShift->bytes -= amount;
+    toShift->msgbytes -= amount;
     toShift->_padding -= amount;
 
     Er_ret();
@@ -186,9 +186,9 @@ static inline Er_DEFUN(void Message_epush(struct Message* restrict msg,
 {
     Er(Message_eshift(msg, (int)size));
     if (object) {
-        Bits_memcpy(msg->bytes, object, size);
+        Bits_memcpy(msg->msgbytes, object, size);
     } else {
-        Bits_memset(msg->bytes, 0x00, size);
+        Bits_memset(msg->msgbytes, 0x00, size);
     }
     Er_ret();
 }
@@ -199,7 +199,7 @@ static inline Er_DEFUN(void Message_epop(struct Message* restrict msg,
 {
     Er(Message_eshift(msg, -(int)size));
     if (object) {
-        Bits_memcpy(object, &msg->bytes[-((int)size)], size);
+        Bits_memcpy(object, &msg->msgbytes[-((int)size)], size);
     }
     Er_ret();
 }