Skip to content

Commit

Permalink
Fixed handle_port_absent_message.
Browse files Browse the repository at this point in the history
  • Loading branch information
Jakio815 committed Feb 1, 2024
1 parent c89de1e commit baa8793
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 15 deletions.
16 changes: 5 additions & 11 deletions core/federated/RTI/rti_remote.c
Original file line number Diff line number Diff line change
Expand Up @@ -312,16 +312,9 @@ void update_federate_next_event_tag_locked(uint16_t federate_id, tag_t next_even
}

void handle_port_absent_message(federate_info_t *sending_federate, unsigned char *buffer) {
size_t message_size = sizeof(uint16_t) + sizeof(uint16_t) + sizeof(int64_t) + sizeof(uint32_t);

read_from_socket_fail_on_error(
&sending_federate->socket, message_size, &(buffer[1]), NULL,
" RTI failed to read port absent message from federate %u.",
sending_federate->enclave.id);

uint16_t reactor_port_id = extract_uint16(&(buffer[1]));
uint16_t federate_id = extract_uint16(&(buffer[1 + sizeof(uint16_t)]));
tag_t tag = extract_tag(&(buffer[1 + 2 * sizeof(uint16_t)]));
uint16_t reactor_port_id = extract_uint16(buffer + 1);
uint16_t federate_id = extract_uint16(buffer + 1 + sizeof(uint16_t));
tag_t tag = extract_tag(buffer + 1 + 2 * sizeof(uint16_t));

if (rti_remote->base.tracing_enabled) {
tracepoint_rti_from_federate(rti_remote->base.trace, receive_PORT_ABS, sending_federate->enclave.id, &tag);
Expand Down Expand Up @@ -370,7 +363,8 @@ void handle_port_absent_message(federate_info_t *sending_federate, unsigned char
}

// Forward the message.
write_to_socket_fail_on_error(&fed->socket, message_size + 1, buffer, &rti_mutex,
size_t message_size = sizeof(uint16_t) + sizeof(uint16_t) + sizeof(int64_t) + sizeof(uint32_t);
write_to_netdrv_fail_on_error(&fed->socket, message_size + 1, buffer, &rti_mutex,
"RTI failed to forward message to federate %d.", federate_id);

LF_MUTEX_UNLOCK(rti_mutex);
Expand Down
8 changes: 4 additions & 4 deletions core/federated/network/lf_socket_support.c
Original file line number Diff line number Diff line change
Expand Up @@ -578,7 +578,7 @@ int read_from_netdrv(netdrv_t* netdrv, unsigned char* buffer) {
return net_read_from_socket(priv->socket_descriptor, sizeof(uint16_t), buffer);
break;
case MSG_TYPE_ADDRESS_ADVERTISEMENT:
net_read_from_socket_fail_on_error(&priv->socket_descriptor, sizeof(int32_t), (unsigned char *)buffer, NULL,
net_read_from_socket_fail_on_error(&priv->socket_descriptor, sizeof(int32_t), buffer, NULL,
"Error reading port data.");
break;

Expand Down Expand Up @@ -612,9 +612,9 @@ int read_from_netdrv(netdrv_t* netdrv, unsigned char* buffer) {
// break;
// case MSG_TYPE_CLOCK_SYNC_CODED_PROBE:
// break;
// case MSG_TYPE_PORT_ABSENT:
// handle_port_absent_message(my_fed, buffer);
// break;
case MSG_TYPE_PORT_ABSENT:
net_read_from_socket_fail_on_error(&priv->socket_descriptor, sizeof(uint16_t) + sizeof(uint16_t) + sizeof(int64_t) + sizeof(uint32_t), buffer, NULL,
"RTI failed to read port absent message.");

case MSG_TYPE_NEIGHBOR_STRUCTURE:
net_read_from_socket(priv->socket_descriptor, MSG_TYPE_NEIGHBOR_STRUCTURE_HEADER_SIZE - 1, buffer);
Expand Down

0 comments on commit baa8793

Please sign in to comment.