Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix tagged message length from int32_t to uint32_t #368

Merged
merged 6 commits into from
Feb 27, 2024
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion core/federated/RTI/rti_remote.c
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ void handle_port_absent_message(federate_info_t *sending_federate, unsigned char
}

void handle_timed_message(federate_info_t *sending_federate, unsigned char *buffer) {
size_t header_size = 1 + sizeof(uint16_t) + sizeof(uint16_t) + sizeof(int32_t)
size_t header_size = 1 + sizeof(uint16_t) + sizeof(uint16_t) + sizeof(uint32_t)
+ sizeof(int64_t) + sizeof(uint32_t);
// Read the header, minus the first byte which has already been read.
read_from_socket_fail_on_error(
Expand Down
4 changes: 2 additions & 2 deletions core/federated/federate.c
Original file line number Diff line number Diff line change
Expand Up @@ -528,7 +528,7 @@ static int handle_tagged_message(int* socket, int fed_id) {
_lf_get_environments(&env);

// Read the header which contains the timestamp.
size_t bytes_to_read = sizeof(uint16_t) + sizeof(uint16_t) + sizeof(int32_t)
size_t bytes_to_read = sizeof(uint16_t) + sizeof(uint16_t) + sizeof(uint32_t)
+ sizeof(instant_t) + sizeof(microstep_t);
unsigned char buffer[bytes_to_read];
if (read_from_socket_close_on_error(socket, bytes_to_read, buffer)) {
Expand Down Expand Up @@ -2653,7 +2653,7 @@ int lf_send_tagged_message(environment_t* env,
buffer_head += sizeof(uint16_t);

// The next four bytes are the message length.
encode_int32((int32_t)length, &(header_buffer[buffer_head]));
encode_uint32((uint32_t)length, &(header_buffer[buffer_head]));
buffer_head += sizeof(int32_t);

// Apply the additional delay to the current tag and use that as the intended
Expand Down
2 changes: 1 addition & 1 deletion core/federated/network/net_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,7 @@ void extract_header(
// printf("DEBUG: Message for port %d of federate %d.\n", *port_id, *federate_id);

// The next four bytes are the message length.
int32_t local_length_signed = extract_int32(&(buffer[sizeof(uint16_t) + sizeof(uint16_t)]));
uint32_t local_length_signed = extract_uint32(&(buffer[sizeof(uint16_t) + sizeof(uint16_t)]));
if (local_length_signed < 0) {
lf_print_error_and_exit(
"Received an invalid message length (%d) from federate %d.",
Expand Down
Loading