diff --git a/.cproject b/.cproject
index e91f269..0e0c996 100644
--- a/.cproject
+++ b/.cproject
@@ -307,7 +307,6 @@
make
-
all
true
true
@@ -315,7 +314,6 @@
make
-
clean
true
true
@@ -323,11 +321,20 @@
make
+
uninstall
true
true
false
+
+ make
+
+ clean all DEBUG=1
+ true
+ true
+ false
+
diff --git a/configure/CONFIG_SITE b/configure/CONFIG_SITE
index 287667b..7f70b02 100644
--- a/configure/CONFIG_SITE
+++ b/configure/CONFIG_SITE
@@ -24,4 +24,11 @@
# take effect.
#IOCS_APPL_TOP =
-USR_LDFLAGS += -lpthread
+ifeq ($(DEBUG),1)
+ DEBUG_CFLAGS=-O0 -g -ggdb
+endif
+
+ifeq ($(EPICS_HOST_ARCH),linux-x86)
+ USR_LDFLAGS += -lpthread
+endif
+
diff --git a/pvAccessApp/utils/inetAddressUtil.cpp b/pvAccessApp/utils/inetAddressUtil.cpp
index 77eac47..7eeb41c 100644
--- a/pvAccessApp/utils/inetAddressUtil.cpp
+++ b/pvAccessApp/utils/inetAddressUtil.cpp
@@ -40,6 +40,8 @@ namespace epics {
int status;
struct ifconf ifconf;
struct ifreq* pIfreqList;
+ struct ifreq* pifreq;
+ struct ifreq ifrBuff;
osiSockAddr* pNewNode;
InetAddrVector* retVector = new InetAddrVector();
@@ -62,39 +64,53 @@ namespace epics {
ifconf.ifc_req = pIfreqList;
status = ioctl(sock, SIOCGIFCONF, &ifconf);
if(status<0||ifconf.ifc_len==0) {
- errlogSevPrintf(
- errlogMinor,
+ errlogSevPrintf(errlogMinor,
"getBroadcastAddresses(): unable to fetch network interface configuration");
delete[] pIfreqList;
return retVector;
}
- errlogPrintf("Found %d interfaces\n", ifconf.ifc_len);
+ int maxNodes = ifconf.ifc_len/sizeof(ifreq);
+ //errlogPrintf("Found %d interfaces\n", maxNodes);
+
+ pifreq = pIfreqList;
+
+ for(int i = 0; i<=maxNodes; i++) {
+ if(!(*pifreq->ifr_name)) break;
+
+ if(i>0) {
+ size_t n = sizeof(sockaddr)+sizeof(pifreq->ifr_name);
+ if(nifr_addr.sa_family!=AF_INET) continue;
- status = ioctl(sock, SIOCGIFFLAGS, &pIfreqList[i]);
+ strncpy(ifrBuff.ifr_name, pifreq->ifr_name,
+ sizeof(ifrBuff.ifr_name));
+ status = ioctl(sock, SIOCGIFFLAGS, &ifrBuff);
if(status) {
errlogSevPrintf(
errlogMinor,
"getBroadcastAddresses(): net intf flags fetch for \"%s\" failed",
- pIfreqList[i].ifr_name);
+ pifreq->ifr_name);
continue;
}
/*
* dont bother with interfaces that have been disabled
*/
- if(!(pIfreqList[i].ifr_flags&IFF_UP)) continue;
+ if(!(ifrBuff.ifr_flags&IFF_UP)) continue;
/*
* dont use the loop back interface
*/
- if(pIfreqList[i].ifr_flags&IFF_LOOPBACK) continue;
+ if(ifrBuff.ifr_flags&IFF_LOOPBACK) continue;
pNewNode = new osiSockAddr;
if(pNewNode==NULL) {
@@ -114,37 +130,41 @@ namespace epics {
* Otherwise CA will not query through the
* interface.
*/
- if(pIfreqList[i].ifr_flags&IFF_BROADCAST) {
- status = ioctl(sock, SIOCGIFBRDADDR, &pIfreqList[i]);
+ if(ifrBuff.ifr_flags&IFF_BROADCAST) {
+ strncpy(ifrBuff.ifr_name, pifreq->ifr_name,
+ sizeof(ifrBuff.ifr_name));
+ status = ioctl(sock, SIOCGIFBRDADDR, &ifrBuff);
if(status) {
errlogSevPrintf(
errlogMinor,
"getBroadcastAddresses(): net intf \"%s\": bcast addr fetch fail",
- pIfreqList->ifr_name);
+ pifreq->ifr_name);
delete pNewNode;
continue;
}
- pNewNode->sa = pIfreqList[i].ifr_broadaddr;
+ pNewNode->sa = ifrBuff.ifr_broadaddr;
}
#ifdef IFF_POINTOPOINT
- else if(pIfreqList->ifr_flags&IFF_POINTOPOINT) {
- status = ioctl(sock, SIOCGIFDSTADDR, &pIfreqList[i]);
+ else if(ifrBuff.ifr_flags&IFF_POINTOPOINT) {
+ strncpy(ifrBuff.ifr_name, pifreq->ifr_name,
+ sizeof(ifrBuff.ifr_name));
+ status = ioctl(sock, SIOCGIFDSTADDR, &ifrBuff);
if(status) {
errlogSevPrintf(
errlogMinor,
"getBroadcastAddresses(): net intf \"%s\": pt to pt addr fetch fail",
- pIfreqList[i].ifr_name);
+ pifreq->ifr_name);
delete pNewNode;
continue;
}
- pNewNode->sa = pIfreqList[i].ifr_dstaddr;
+ pNewNode->sa = ifrBuff.ifr_dstaddr;
}
#endif
else {
errlogSevPrintf(
errlogMinor,
"getBroadcastAddresses(): net intf \"%s\": not point to point or bcast?",
- pIfreqList[i].ifr_name);
+ pifreq->ifr_name);
delete pNewNode;
continue;
}
diff --git a/testApp/utils/inetAddressUtilsTest.cpp b/testApp/utils/inetAddressUtilsTest.cpp
index 5a594b7..8594254 100644
--- a/testApp/utils/inetAddressUtilsTest.cpp
+++ b/testApp/utils/inetAddressUtilsTest.cpp
@@ -6,6 +6,7 @@
*/
#include "inetAddressUtil.h"
+#include "logger.h"
#include
#include
@@ -23,6 +24,7 @@ using std::stringstream;
using std::hex;
int main(int argc, char *argv[]) {
+ createFileLogger("inetAddresUtils.log");
InetAddrVector *vec;
InetAddrVector *vec1;