diff --git a/src/iface.cc b/src/iface.cc index b2df7b7..74d2fd6 100644 --- a/src/iface.cc +++ b/src/iface.cc @@ -34,6 +34,7 @@ #include +#include #include #include #include @@ -341,7 +342,11 @@ ssize_t iface::write(int fd, const address& daddr, const uint8_t* msg, size_t si int len; if ((len = sendmsg(fd,& mhdr, 0)) < 0) + { + int e = errno; + logger::error() << "iface::write() failed! errno=" << e; return -1; + } return len; } @@ -427,7 +432,7 @@ ssize_t iface::write_advert(const address& daddr, const address& taddr, bool rou opt->nd_opt_len = 1; na->nd_na_type = ND_NEIGHBOR_ADVERT; - na->nd_na_flags_reserved = ND_NA_FLAG_SOLICITED | (router ? ND_NA_FLAG_ROUTER : 0); + na->nd_na_flags_reserved = (daddr.is_multicast() ? 0 : ND_NA_FLAG_SOLICITED) | (router ? ND_NA_FLAG_ROUTER : 0); memcpy(&na->nd_na_target,& taddr.const_addr(), sizeof(struct in6_addr)); diff --git a/src/session.cc b/src/session.cc index 2c3e65c..05091f4 100644 --- a/src/session.cc +++ b/src/session.cc @@ -24,6 +24,8 @@ NDPPD_NS_BEGIN std::list > session::_sessions; +static address all_nodes = address("ff02::1"); + void session::update_all(int elapsed_time) { for (std::list >::iterator it = _sessions.begin(); @@ -69,7 +71,7 @@ ptr session::create(const ptr& pr, const address& saddr, se->_ptr = se; se->_pr = pr; - se->_saddr = saddr; + se->_saddr = address("::") == saddr ? all_nodes : saddr; se->_taddr = taddr; se->_daddr = daddr; se->_ttl = pr->timeout();