[mdns] Fix multicast routing error on esp32 (and likely other platforms)
According to the RFC (https://datatracker.ietf.org/doc/html/rfc2553#section-3.3), it is necessary to disambiguate link-local addresses with the interface index (in the scope_id field). Lacking this field, newer versions of lwip that support proper IPv6 scopes will yield EHOSTUNREACH (Host unreachable). Other implementations like on Linux and OS X will likely be affected by the lack of this field for more complex networking setups. Fixes #100 Run cargo fmt again Run cargo clippy again Revert "Run cargo clippy again" This reverts commit e3bba1f6367172d9ecd07c8c8fb7263cda40e8f6.
This commit is contained in:
parent
e39fd18b73
commit
d84402f571
2 changed files with 34 additions and 29 deletions
|
@ -8,7 +8,9 @@ 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};
|
use crate::transport::network::{
|
||||||
|
Address, IpAddr, 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,10 +219,14 @@ 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) {
|
}),
|
||||||
|
]
|
||||||
|
.into_iter()
|
||||||
|
.flatten()
|
||||||
|
{
|
||||||
loop {
|
loop {
|
||||||
let sent = {
|
let sent = {
|
||||||
let mut data = tx_pipe.data.lock().await;
|
let mut data = tx_pipe.data.lock().await;
|
||||||
|
@ -229,12 +235,12 @@ impl<'a> MdnsService<'a> {
|
||||||
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(());
|
||||||
|
@ -255,7 +261,6 @@ impl<'a> MdnsService<'a> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
async fn respond(&self, rx_pipe: &Pipe<'_>, tx_pipe: &Pipe<'_>) -> Result<(), Error> {
|
async fn respond(&self, rx_pipe: &Pipe<'_>, tx_pipe: &Pipe<'_>) -> Result<(), Error> {
|
||||||
loop {
|
loop {
|
||||||
|
|
|
@ -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