Skip to content

Commit

Permalink
Clarify int types && Change clock-sync to send uint16_t types not int…
Browse files Browse the repository at this point in the history
…32_t types.
  • Loading branch information
Jakio815 committed Jun 24, 2024
1 parent 587a8f9 commit 5cd75ab
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions core/federated/RTI/rti_remote.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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.
Expand Down
6 changes: 3 additions & 3 deletions core/federated/clock-sync.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion core/utils/util.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 5cd75ab

Please sign in to comment.