From 61600b730aa5778bb09789a499ef589f82fafca0 Mon Sep 17 00:00:00 2001 From: Ralph Lange Date: Thu, 21 Sep 2006 20:28:55 +0000 Subject: [PATCH] Fix for skipping over the first ifreq list element, += ifreqSize wrapper function. --- src/libCom/osi/os/default/osdNetIntf.c | 28 +++++++++++++++----------- 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/src/libCom/osi/os/default/osdNetIntf.c b/src/libCom/osi/os/default/osdNetIntf.c index b9f62e740..de683387a 100644 --- a/src/libCom/osi/os/default/osdNetIntf.c +++ b/src/libCom/osi/os/default/osdNetIntf.c @@ -31,22 +31,30 @@ #endif /* - * Move to the next ifreq structure + * Determine the size of an ifreq structure * Made difficult by the fact that addresses larger than the structure * size may be returned from the kernel. */ -static struct ifreq * ifreqNext ( struct ifreq *pifreq ) +static size_t ifreqSize ( struct ifreq *pifreq ) { size_t size; - struct ifreq *ifr; size = ifreq_size ( pifreq ); if ( size < sizeof ( *pifreq ) ) { size = sizeof ( *pifreq ); } + return size; +} - ifr = ( struct ifreq * )( size + ( char * ) pifreq ); - ifDepenDebugPrintf( ("ifreqNext() pifreq 0x%08x, size 0x%08x, ifr 0x%08x\n", pifreq, size, ifr) ); +/* + * Move to the next ifreq structure + */ +static struct ifreq * ifreqNext ( struct ifreq *pifreq ) +{ + struct ifreq *ifr; + + ifr = ( struct ifreq * )( ifreqSize (pifreq) + ( char * ) pifreq ); + ifDepenDebugPrintf( ("ifreqNext() pifreq 0x%08x, size 0x%08x, ifr 0x%08x\n", pifreq, ifreqSize (pifreq), ifr) ); return ifr; } @@ -110,18 +118,14 @@ epicsShareFunc void epicsShareAPI osiSockDiscoverBroadcastAddresses uint32_t current_ifreqsize; /* - * find the next if req + * find the next ifreq */ pnextifreq = ifreqNext (pifreq); - /* determine ifreq size */ - current_ifreqsize = ifreq_size ( pifreq ); - if ( current_ifreqsize < sizeof ( *pifreq ) ) { - current_ifreqsize = sizeof ( *pifreq ); - } + current_ifreqsize = ifreqSize ( pifreq ); /* copy current ifreq to aligned bufferspace (to start of pIfreqList buffer) */ - memmove(pIfreqList, pnextifreq, current_ifreqsize); + memmove(pIfreqList, pifreq, current_ifreqsize); ifDepenDebugPrintf (("osiSockDiscoverBroadcastAddresses(): found IFACE: %s len: 0x%x current_ifreqsize: 0x%x \n", pIfreqList->ifr_name,