network interface ioctl()s problem

Hello all,

developing under QNX RTP 6.1.0, my application gathers the IP broadcast
addresses of all interfaces.

I’m traversing through the interface list as in the 4.4BSD way explained
in section 5.9 of An Advanced 4.4 BSD IPC Tutorial at:

However, proceeding through the ifconf structure’s buffer, containing an ifreq
structure for each interface, I fail to traverse through the buffer ifreq
structure’s properly (wrong offsets…)

for (n; --n >= 0; ifr+=sizeof(struct ifreq))

A snippet of source code in the QNX Knowledge database issue 10246 does a
similar thing, but uses a different way of traversing through the buffer,
which seems to work ok.

for (n; --n >= 0; ifr= (struct ifreq*)((char *)ifr + ifr->ifr_addr.sa_len + IFNAMSIZ))

I have no clue as why this other method is the better way.

My source code is small and online, at:

The second problem I’m encountering, is that once a get the ifflags using ioctl(), the
ifreq’s seem to become corrupted.

I hope someone can enlighten me,

Leon Woestenberg.
#/** PhEDIT attribute block
#** PhEDIT attribute block ends (-0000231)**/