Skip to content

Commit

Permalink
Merge pull request #1345 from eclipse-zenoh/dev/scouting_ipv6
Browse files Browse the repository at this point in the history
Scouting accepts IPv6 addresses
  • Loading branch information
Mallets authored Sep 2, 2024
2 parents 3ccb1bb + 3e00456 commit 983908b
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions zenoh/src/net/runtime/orchestrator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -614,7 +614,7 @@ impl Runtime {
ifaces: &[IpAddr],
multicast_ttl: u32,
) -> ZResult<UdpSocket> {
let socket = match Socket::new(Domain::IPV4, Type::DGRAM, None) {
let socket = match Socket::new(Domain::for_address(*sockaddr), Type::DGRAM, None) {
Ok(socket) => socket,
Err(err) => {
tracing::error!("Unable to create datagram socket: {}", err);
Expand Down Expand Up @@ -704,21 +704,22 @@ impl Runtime {
}

pub fn bind_ucast_port(addr: IpAddr, multicast_ttl: u32) -> ZResult<UdpSocket> {
let socket = match Socket::new(Domain::IPV4, Type::DGRAM, None) {
let sockaddr = || SocketAddr::new(addr, 0);
let socket = match Socket::new(Domain::for_address(sockaddr()), Type::DGRAM, None) {
Ok(socket) => socket,
Err(err) => {
tracing::warn!("Unable to create datagram socket: {}", err);
bail!(err=> "Unable to create datagram socket");
}
};
match socket.bind(&SocketAddr::new(addr, 0).into()) {
match socket.bind(&sockaddr().into()) {
Ok(()) => {
#[allow(clippy::or_fun_call)]
let local_addr = socket
.local_addr()
.unwrap_or(SocketAddr::new(addr, 0).into())
.unwrap_or(sockaddr().into())
.as_socket()
.unwrap_or(SocketAddr::new(addr, 0));
.unwrap_or(sockaddr());
tracing::debug!("UDP port bound to {}", local_addr);
}
Err(err) => {
Expand Down

0 comments on commit 983908b

Please sign in to comment.