fixup point to point interface handling.

with bcast interfaces, send searches to bcast address
and !WIN32 binds bcast address to receive searches.

with point to point, send searches to dest address.
can't bind dest address (not local).

quiets spurious error message:

> Error binding socket: Cannot assign requested address.

Encountered with a P2P link setup by openvpn.
This commit is contained in:
Michael Davidsaver
2017-09-06 10:10:15 -05:00
parent 9bf307712b
commit 90e8276758
3 changed files with 30 additions and 15 deletions

View File

@@ -211,7 +211,14 @@ int getLoopbackNIF(osiSockAddr &loAddr, string const & localNIF, unsigned short
return 1;
}
ifaceNode::ifaceNode()
{
memset(&ifaceAddr, 0, sizeof(ifaceAddr));
memset(&ifaceBCast, 0, sizeof(ifaceBCast));
memset(&ifaceDest, 0, sizeof(ifaceDest));
// redundant as AF_UNSPEC==0
ifaceAddr.sa.sa_family = ifaceBCast.sa.sa_family = ifaceDest.sa.sa_family = AF_UNSPEC;
}
#include <osiSock.h>
//#include <epicsAssert.h>
@@ -371,7 +378,7 @@ int discoverInterfaces(IfaceNodeVector &list, SOCKET socket, const osiSockAddr *
errlogPrintf ("discoverInterfaces(): net intf \"%s\": bcast addr fetch fail\n", pIfreqList->ifr_name);
continue;
}
node.ifaceBCast.sa = pIfreqList->ifr_broadaddr;
node.ifaceBCast.sa = node.ifaceDest.sa = pIfreqList->ifr_broadaddr;
/*ifDepenDebugPrintf ( ( "found broadcast addr = %x\n", ntohl ( pNewNode->addr.ia.sin_addr.s_addr ) ) );*/
}
#if defined (IFF_POINTOPOINT)
@@ -381,16 +388,12 @@ int discoverInterfaces(IfaceNodeVector &list, SOCKET socket, const osiSockAddr *
/*ifDepenDebugPrintf ( ("discoverInterfaces(): net intf \"%s\": pt to pt addr fetch fail\n", pIfreqList->ifr_name) );*/
continue;
}
node.ifaceBCast.sa = pIfreqList->ifr_dstaddr;
node.ifaceDest.sa = pIfreqList->ifr_dstaddr;
}
#endif
else {
// if it is a match, accept the interface even if it does not support broadcast (i.e. 127.0.0.1)
if (match) {
memset(&node.ifaceBCast, 0, sizeof(node.ifaceBCast));
node.ifaceBCast.sa.sa_family = AF_UNSPEC;
}
else
// if it is a match, accept the interface even if it does not support broadcast (i.e. 127.0.0.1 or point to point)
if (!match)
{
/*ifDepenDebugPrintf ( ( "discoverInterfaces(): net intf \"%s\": not point to point or bcast?\n", pIfreqList->ifr_name ) );*/
continue;