Skip to content

Commit

Permalink
Add error messages.
Browse files Browse the repository at this point in the history
  • Loading branch information
Jakio815 committed Dec 20, 2024
1 parent e201df6 commit 02d4749
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions core/federated/federate.c
Original file line number Diff line number Diff line change
Expand Up @@ -1795,6 +1795,9 @@ void lf_connect_to_federate(uint16_t remote_federate_id) {
size_t buffer_length = 1 + sizeof(uint16_t) + 1;
unsigned char buffer[buffer_length];
buffer[0] = MSG_TYPE_P2P_SENDING_FED_ID;
if (_lf_my_fed_id == UINT16_MAX) {
lf_print_error_and_exit("Too many federates! More than %d.", UINT16_MAX - 1);
}
encode_uint16((uint16_t)_lf_my_fed_id, (unsigned char*)&(buffer[1]));
unsigned char federation_id_length = (unsigned char)strnlen(federation_metadata.federation_id, 255);
buffer[sizeof(uint16_t) + 1] = federation_id_length;
Expand Down Expand Up @@ -1914,6 +1917,9 @@ void lf_connect_to_rti(const char* hostname, int port) {
unsigned char buffer[4];
buffer[0] = MSG_TYPE_FED_IDS;
// Next send the federate ID.
if (_lf_my_fed_id == UINT16_MAX) {
lf_print_error_and_exit("Too many federates! More than %d.", UINT16_MAX - 1);
}
encode_uint16((uint16_t)_lf_my_fed_id, &buffer[1]);
// Next send the federation ID length.
// The federation ID is limited to 255 bytes.
Expand Down

0 comments on commit 02d4749

Please sign in to comment.