Skip to content

Commit

Permalink
Added comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Mallets committed Aug 27, 2021
1 parent 3003f25 commit f3209f1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 12 deletions.
6 changes: 4 additions & 2 deletions zenoh/src/net/link/endpoint.rs
Expand Up @@ -49,11 +49,12 @@ pub const STR_UNIXSOCK_STREAM: &str = "unixsock-stream";

// Parsing chars
pub const PROTO_SEPARATOR: char = '/';
pub const METADATA_SEPARATOR: char = '#';
pub const CONFIG_SEPARATOR: char = '?';
pub const METADATA_SEPARATOR: char = '?';
pub const CONFIG_SEPARATOR: char = '#';
pub const LIST_SEPARATOR: char = ';';
pub const FIELD_SEPARATOR: char = '=';

// @TODO: port it as a Properties parsing
fn str_to_properties(s: &str) -> Option<Properties> {
let mut hm = Properties::default();
for opt in s.split(LIST_SEPARATOR) {
Expand All @@ -64,6 +65,7 @@ fn str_to_properties(s: &str) -> Option<Properties> {
Some(hm)
}

// @TODO: port it as a Properties display
fn properties_to_str(hm: &Properties) -> String {
let mut s = "".to_string();
let mut count = hm.len();
Expand Down
14 changes: 4 additions & 10 deletions zenoh/src/net/link/udp/multicast.rs
Expand Up @@ -176,6 +176,7 @@ impl LinkManagerMulticastTrait for LinkManagerMulticastUdp {
let default_ipv4_addr = Ipv4Addr::new(0, 0, 0, 0);
let default_ipv6_addr = Ipv6Addr::new(0, 0, 0, 0, 0, 0, 0, 0);

// Get default iface address to bind the socket on if provided
let mut iface_addr: Option<IpAddr> = None;
if let Some(config) = endpoint.config.as_ref() {
if let Some(iface) = config.get(UDP_MULTICAST_SRC_IFACE) {
Expand All @@ -198,6 +199,7 @@ impl LinkManagerMulticastTrait for LinkManagerMulticastUdp {
}
}

// Get local unicast address to bind the socket on
let local_addr = match iface_addr {
Some(iface_addr) => iface_addr,
None => {
Expand Down Expand Up @@ -226,16 +228,9 @@ impl LinkManagerMulticastTrait for LinkManagerMulticastUdp {
};

// Establish a unicast UDP socket
let ucast_sock =
Socket::new(domain, Type::DGRAM, Some(Protocol::UDP)).map_err(|e| zerrmsg!(e))?;
ucast_sock
.set_reuse_address(true)
.map_err(|e| zerrmsg!(e))?;

let _ = ucast_sock
.bind(&SocketAddr::new(local_addr, 0).into())
let ucast_sock = UdpSocket::bind(SocketAddr::new(local_addr, 0))
.await
.map_err(|e| zerrmsg!(e))?;
let ucast_sock: UdpSocket = std::net::UdpSocket::from(ucast_sock).into();

// Establish a multicast UDP socket
let mcast_sock =
Expand Down Expand Up @@ -283,7 +278,6 @@ impl LinkManagerMulticastTrait for LinkManagerMulticastUdp {

let link = Arc::new(LinkMulticastUdp::new(
ucast_addr, ucast_sock, mcast_addr, mcast_sock,
// local_addrs,
));

Ok(LinkMulticast(link))
Expand Down

0 comments on commit f3209f1

Please sign in to comment.