Portable capture of destination interface and IP address
Use recvmsg() and control messages IP_PKTINFO (Linux, OSX, Windows) or IP_ORIGDSTADDR and IP_RECVIF (RTEMS w/ libbsd) to find the index of the logical interface through which a UDP packet was received, and the destination address from the IPv4 header. Also, clear IP_MULTICAST_ALL on Linux to disable non-compliant legacy brokenness and receive only those multicasts we are interested in.
This commit is contained in:
+5
-6
@@ -750,14 +750,13 @@ bool ContextImpl::onSearch()
|
||||
{
|
||||
searchMsg.resize(0x10000);
|
||||
SockAddr src;
|
||||
uint32_t ndrop = 0u;
|
||||
|
||||
osiSocklen_t alen = src.size();
|
||||
const int nrx = recvfromx(searchTx.sock, (char*)&searchMsg[0], searchMsg.size()-1, &src->sa, &alen, &ndrop);
|
||||
recvfromx rx{searchTx.sock, (char*)&searchMsg[0], searchMsg.size()-1, &src};
|
||||
const int nrx = rx.call();
|
||||
|
||||
if(nrx>=0 && ndrop!=0 && prevndrop!=ndrop) {
|
||||
log_debug_printf(io, "UDP search reply buffer overflow %u -> %u\n", unsigned(prevndrop), unsigned(ndrop));
|
||||
prevndrop = ndrop;
|
||||
if(nrx>=0 && rx.ndrop!=0 && prevndrop!=rx.ndrop) {
|
||||
log_debug_printf(io, "UDP search reply buffer overflow %u -> %u\n", unsigned(prevndrop), unsigned(rx.ndrop));
|
||||
prevndrop = rx.ndrop;
|
||||
}
|
||||
|
||||
if(nrx<0) {
|
||||
|
||||
Reference in New Issue
Block a user