Merge pull request #110 from jasta/fix-ipv6-mcast
[mdns] Fix multicast routing error on esp32 (and likely other platforms)
This commit is contained in:
commit
7b55e7fbfb
2 changed files with 36 additions and 29 deletions
|
@ -8,7 +8,11 @@ use log::info;
|
||||||
|
|
||||||
use crate::data_model::cluster_basic_information::BasicInfoConfig;
|
use crate::data_model::cluster_basic_information::BasicInfoConfig;
|
||||||
use crate::error::{Error, ErrorCode};
|
use crate::error::{Error, ErrorCode};
|
||||||
use crate::transport::network::{Address, IpAddr, Ipv4Addr, Ipv6Addr, SocketAddr};
|
#[cfg(any(feature = "std", feature = "embassy-net"))]
|
||||||
|
use crate::transport::network::IpAddr;
|
||||||
|
use crate::transport::network::{
|
||||||
|
Address, Ipv4Addr, Ipv6Addr, SocketAddr, SocketAddrV4, SocketAddrV6,
|
||||||
|
};
|
||||||
use crate::transport::pipe::{Chunk, Pipe};
|
use crate::transport::pipe::{Chunk, Pipe};
|
||||||
use crate::utils::select::{EitherUnwrap, Notification};
|
use crate::utils::select::{EitherUnwrap, Notification};
|
||||||
|
|
||||||
|
@ -217,40 +221,43 @@ impl<'a> MdnsService<'a> {
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
for addr in [
|
for addr in [
|
||||||
IpAddr::V4(IP_BROADCAST_ADDR),
|
Some(SocketAddr::V4(SocketAddrV4::new(IP_BROADCAST_ADDR, PORT))),
|
||||||
IpAddr::V6(IPV6_BROADCAST_ADDR),
|
self.interface.map(|interface| {
|
||||||
] {
|
SocketAddr::V6(SocketAddrV6::new(IPV6_BROADCAST_ADDR, PORT, 0, interface))
|
||||||
if self.interface.is_some() || addr == IpAddr::V4(IP_BROADCAST_ADDR) {
|
}),
|
||||||
loop {
|
]
|
||||||
let sent = {
|
.into_iter()
|
||||||
let mut data = tx_pipe.data.lock().await;
|
.flatten()
|
||||||
|
{
|
||||||
|
loop {
|
||||||
|
let sent = {
|
||||||
|
let mut data = tx_pipe.data.lock().await;
|
||||||
|
|
||||||
if data.chunk.is_none() {
|
if data.chunk.is_none() {
|
||||||
let len = self.host.broadcast(self, data.buf, 60)?;
|
let len = self.host.broadcast(self, data.buf, 60)?;
|
||||||
|
|
||||||
if len > 0 {
|
if len > 0 {
|
||||||
info!("Broadcasting mDNS entry to {}:{}", addr, PORT);
|
info!("Broadcasting mDNS entry to {addr}");
|
||||||
|
|
||||||
data.chunk = Some(Chunk {
|
data.chunk = Some(Chunk {
|
||||||
start: 0,
|
start: 0,
|
||||||
end: len,
|
end: len,
|
||||||
addr: Address::Udp(SocketAddr::new(addr, PORT)),
|
addr: Address::Udp(addr),
|
||||||
});
|
});
|
||||||
|
|
||||||
tx_pipe.data_supplied_notification.signal(());
|
tx_pipe.data_supplied_notification.signal(());
|
||||||
}
|
|
||||||
|
|
||||||
true
|
|
||||||
} else {
|
|
||||||
false
|
|
||||||
}
|
}
|
||||||
};
|
|
||||||
|
|
||||||
if sent {
|
true
|
||||||
break;
|
|
||||||
} else {
|
} else {
|
||||||
tx_pipe.data_consumed_notification.wait().await;
|
false
|
||||||
}
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
if sent {
|
||||||
|
break;
|
||||||
|
} else {
|
||||||
|
tx_pipe.data_consumed_notification.wait().await;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,9 +17,9 @@
|
||||||
|
|
||||||
use core::fmt::{Debug, Display};
|
use core::fmt::{Debug, Display};
|
||||||
#[cfg(not(feature = "std"))]
|
#[cfg(not(feature = "std"))]
|
||||||
pub use no_std_net::{IpAddr, Ipv4Addr, Ipv6Addr, SocketAddr};
|
pub use no_std_net::{IpAddr, Ipv4Addr, Ipv6Addr, SocketAddr, SocketAddrV4, SocketAddrV6};
|
||||||
#[cfg(feature = "std")]
|
#[cfg(feature = "std")]
|
||||||
pub use std::net::{IpAddr, Ipv4Addr, Ipv6Addr, SocketAddr};
|
pub use std::net::{IpAddr, Ipv4Addr, Ipv6Addr, SocketAddr, SocketAddrV4, SocketAddrV6};
|
||||||
|
|
||||||
#[derive(Eq, PartialEq, Copy, Clone)]
|
#[derive(Eq, PartialEq, Copy, Clone)]
|
||||||
pub enum Address {
|
pub enum Address {
|
||||||
|
|
Loading…
Add table
Reference in a new issue