-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Handle a message type for address advertisement/query
- Functions for MsgType::AddressAdvertisement (Byte value 14) and MsgType::AddressQuery (Byte value: 13) are added.
- Loading branch information
1 parent
1be07d2
commit 88873e8
Showing
4 changed files
with
147 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,4 +7,4 @@ edition = "2021" | |
|
||
[dependencies] | ||
byteorder = "1" | ||
priority-queue = "1.3.2" | ||
priority-queue = "2.0.2" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,15 +7,16 @@ use crate::message_record::message_record::InTransitMessageRecordQueue; | |
* @author Chadlia Jerad ([email protected]) | ||
* @author Chanhee Lee ([email protected]) | ||
* @author Hokeun Kim ([email protected]) | ||
* @copyright (c) 2020-2023, The University of California at Berkeley | ||
* @copyright (c) 2020-2024, The University of California at Berkeley | ||
* License in [BSD 2-clause](..) | ||
* @brief Declarations for runtime infrastructure (RTI) for distributed Lingua Franca programs. | ||
* This file extends rti_common.h with RTI features that are specific to federations and are not | ||
* used by scheduling enclaves. | ||
*/ | ||
use crate::rti_common::*; | ||
|
||
use std::net::TcpStream; | ||
use std::net::{IpAddr, Ipv4Addr, SocketAddr, TcpStream}; | ||
|
||
use std::option::Option; | ||
|
||
/** | ||
|
@@ -31,21 +32,23 @@ pub struct FederateInfo { | |
requested_stop: bool, // Indicates that the federate has requested stop or has replied | ||
// to a request for stop from the RTI. Used to prevent double-counting | ||
// a federate when handling lf_request_stop(). | ||
// TODO: lf_thread_t thread_id; // The ID of the thread handling communication with this federate. | ||
// TODO: lf_thread_t thread_id; | ||
stream: Option<TcpStream>, // The TCP socket descriptor for communicating with this federate. | ||
// TODO: struct sockaddr_in UDP_addr; // The UDP address for the federate. | ||
// TODO: struct sockaddr_in UDP_addr; | ||
clock_synchronization_enabled: bool, // Indicates the status of clock synchronization | ||
// for this federate. Enabled by default. | ||
in_transit_message_tags: InTransitMessageRecordQueue, // Record of in-transit messages to this federate that are not | ||
// yet processed. This record is ordered based on the time | ||
// value of each message for a more efficient access. | ||
server_hostname: String, // Human-readable IP address and | ||
server_port: i32, // port number of the socket server of the federate | ||
// if it has any incoming direct connections from other federates. | ||
// The port number will be -1 if there is no server or if the | ||
// RTI has not been informed of the port number. | ||
// TODO: struct in_addr server_ip_addr; // Information about the IP address of the socket | ||
// server of the federate. | ||
// if it has any incoming direct connections from other federates. | ||
// The port number will be -1 if there is no server or if the | ||
// RTI has not been informed of the port number. | ||
// TODO: struct in_addr server_ip_addr; | ||
// server of the federate. | ||
server_ip_addr: SocketAddr, // Information about the IP address of the socket | ||
// server of the federate. | ||
} | ||
|
||
impl FederateInfo { | ||
|
@@ -58,6 +61,7 @@ impl FederateInfo { | |
in_transit_message_tags: InTransitMessageRecordQueue::new(), | ||
server_hostname: String::from("localhost"), | ||
server_port: -1, | ||
server_ip_addr: SocketAddr::new(IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1)), 8080), | ||
} | ||
} | ||
|
||
|
@@ -81,6 +85,18 @@ impl FederateInfo { | |
self.clock_synchronization_enabled | ||
} | ||
|
||
pub fn server_hostname(&self) -> String { | ||
self.server_hostname.clone() | ||
} | ||
|
||
pub fn server_port(&self) -> i32 { | ||
self.server_port | ||
} | ||
|
||
pub fn server_ip_addr(&self) -> SocketAddr { | ||
self.server_ip_addr.clone() | ||
} | ||
|
||
pub fn set_requested_stop(&mut self, requested_stop: bool) { | ||
self.requested_stop = requested_stop; | ||
} | ||
|
@@ -104,4 +120,8 @@ impl FederateInfo { | |
pub fn set_server_port(&mut self, server_port: i32) { | ||
self.server_port = server_port; | ||
} | ||
|
||
pub fn set_server_ip_addr(&mut self, server_ip_addr: SocketAddr) { | ||
self.server_ip_addr = server_ip_addr; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters