Переглянути джерело

Change MAXCHUNKSIZE to FRAME_SIZE and move it to enclave_api.h

Ian Goldberg 1 рік тому
батько
коміт
f98d4bd65c
4 змінених файлів з 9 додано та 7 видалено
  1. 2 2
      App/net.cpp
  2. 3 4
      App/net.hpp
  3. 1 1
      App/start.cpp
  4. 3 0
      Enclave/enclave_api.h

+ 2 - 2
App/net.cpp

@@ -29,7 +29,7 @@ uint8_t *NodeIO::request_frame()
         // _reuse_ the allocated data, though, so the used memory won't
         // grow forever, and will be limited to the amount of in-flight
         // data needed.
-        return new uint8_t[MAXCHUNKSIZE];
+        return new uint8_t[FRAME_SIZE];
     }
     // Copy the pointer to the frame out of the deque and remove it from
     // the deque.  Note this is _not_ taking the address of the element
@@ -110,7 +110,7 @@ void NodeIO::send_message_header(uint32_t tot_message_len)
 
 bool NodeIO::send_chunk(uint8_t *data, uint32_t chunk_len)
 {
-    assert(chunk_len <= MAXCHUNKSIZE);
+    assert(chunk_len <= FRAME_SIZE);
     uint64_t header = (uint64_t(chunk_len) << 8) + COMMAND_CHUNK;
     send_header_data(header, data, chunk_len);
     chunksize_inflight += chunk_len;

+ 3 - 4
App/net.hpp

@@ -10,8 +10,7 @@
 #include <boost/thread.hpp>
 
 #include "appconfig.hpp"
-
-#define MAXCHUNKSIZE (65536+16)
+#include "../Enclave/enclave_api.h"
 
 // The inter-node (untrusted node to untrusted node) communication
 // protocol is as follows.  Nodes are numbered 0 through num_nodes-1.
@@ -53,7 +52,7 @@
 // that MESSAGE command.
 
 // Data for chunks are stored in frames.  The frames are pre-allocated
-// to be MAXCHUNKSIZE bytes each, and reused as much as possible by the
+// to be FRAME_SIZE bytes each, and reused as much as possible by the
 // NodeIO class.  A node will request a frame from the NodeIO, which
 // will return a pointer.  The node will pass that pointer to the
 // enclave, which will write data into it, and also return to the node
@@ -89,7 +88,7 @@ class NodeIO {
     // The static uint64_t used to receive a header
     uint64_t receive_header;
     // The static frame used to receive a chunk
-    uint8_t receive_frame[MAXCHUNKSIZE];
+    uint8_t receive_frame[FRAME_SIZE];
 
     void send_header_data(uint64_t header, uint8_t *data, size_t len);
 

+ 1 - 1
App/start.cpp

@@ -20,7 +20,7 @@ void start(NetIO &netio, int argc, char **argv)
         uint32_t cl = 0;
         while (msgsize > 0) {
             uint8_t* frame = node.request_frame();
-            uint32_t chunk_size = (lrand48() % (MAXCHUNKSIZE-1)) + 1;
+            uint32_t chunk_size = (lrand48() % (FRAME_SIZE-1)) + 1;
             if (chunk_size > msgsize) {
                 chunk_size = msgsize;
             }

+ 3 - 0
Enclave/enclave_api.h

@@ -16,4 +16,7 @@ struct EnclaveAPINodeConfig {
 
 #define SEALED_PRIVKEY_SIZE 610
 
+// Must be a multiple of 16
+#define FRAME_SIZE (65536+16)
+
 #endif