diff --git a/core/federated/RTI/rti_remote.c b/core/federated/RTI/rti_remote.c index cc0252843..d006ab3f3 100644 --- a/core/federated/RTI/rti_remote.c +++ b/core/federated/RTI/rti_remote.c @@ -923,7 +923,7 @@ void* clock_synchronization_thread(void* noargs) { send_physical_clock(MSG_TYPE_CLOCK_SYNC_T1, fed, UDP); // Listen for reply message, which should be T3. - size_t message_size = 1 + sizeof(int32_t); + size_t message_size = 1 + sizeof(uint16_t); unsigned char buffer[message_size]; // Maximum number of messages that we discard before giving up on this cycle. // If the T3 message from this federate does not arrive and we keep receiving @@ -935,7 +935,7 @@ void* clock_synchronization_thread(void* noargs) { // If any errors occur, either discard the message or the clock sync round. if (!read_failed) { if (buffer[0] == MSG_TYPE_CLOCK_SYNC_T3) { - int32_t fed_id_2 = extract_int32(&(buffer[1])); + int32_t fed_id_2 = (int32_t) extract_uint16(&(buffer[1])); // Check that this message came from the correct federate. if (fed_id_2 != fed->enclave.id) { // Message is from the wrong federate. Discard the message. diff --git a/core/federated/clock-sync.c b/core/federated/clock-sync.c index b18efb650..ef5403c89 100644 --- a/core/federated/clock-sync.c +++ b/core/federated/clock-sync.c @@ -275,13 +275,13 @@ int handle_T1_clock_sync_message(unsigned char* buffer, int socket, instant_t t2 // T3-T2 between receiving the T1 message and replying. // Reply will have the federate ID as a payload. - unsigned char reply_buffer[1 + sizeof(int)]; + unsigned char reply_buffer[1 + sizeof(uint16_t)]; reply_buffer[0] = MSG_TYPE_CLOCK_SYNC_T3; - encode_int32(_lf_my_fed_id, &(reply_buffer[1])); + encode_uint16(_lf_my_fed_id, &(reply_buffer[1])); // Write the reply to the socket. LF_PRINT_DEBUG("Sending T3 message to RTI."); - if (write_to_socket(socket, 1 + sizeof(int), reply_buffer)) { + if (write_to_socket(socket, 1 + sizeof(uint16_t), reply_buffer)) { lf_print_error("Clock sync: Failed to send T3 message to RTI."); return -1; } diff --git a/core/utils/util.c b/core/utils/util.c index 62de9fd27..721c2d977 100644 --- a/core/utils/util.c +++ b/core/utils/util.c @@ -58,7 +58,7 @@ THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * The ID of this federate. For a non-federated execution, this will be -1. * For a federated execution, it will be assigned in the generated code. */ -int _lf_my_fed_id = -1; +int32_t _lf_my_fed_id = -1; /** * If non-null, this function will be used instead of the printf to