I’ve recently upgraded to the new versions of tcprt and tcptk from 4.25 to
5.0 for QNX 4.25J in order to take advantage of the multicasting features it
provides. I’m running the new Tcpip socket manager since Socket and Socklet
have been removed. I’ve got software which no longer runs correctly because
it now fails during an ioctl of a socket file descriptor. The errno
returned now is #6 ENXIO, no such device or address.
Here’s the line of code that is failing, the remainder of the function is
below:
if( (code = ioctl( socketfd, SIOCGIFBRDADDR, (caddr_t)&brd_ifreq )) < 0 )
Does anyone know what may have changed in this 4.25 to 5.0 tcp upgrade to
cause this error??
The file descriptor socketfd passed in is established prior to this call in
a call:
socketfd = socket( AF_INET, SOCK_DGRAM, 0 );
and is bind()'d and has socket options:
int on;
…
on=1;
setsockopt (socketfd, SOL_SOCKET, SO_BROADCAST, &on, sizeof(on)
Here’s the function:
long
getbroadcastaddr( int socketfd, long net_addr, int family )
{
struct ifconf host_conf; // Host configuration structure
struct ifreq my_ifreqs[20]; // Arrayt of host interfaces
struct ifreq *ifreqptr;
struct ifreq brd_ifreq;
struct sockaddr_in *my_sin;
int code;
char *module = “getbroadcastaddr()”;
host_conf.ifc_len = sizeof( my_ifreqs );
host_conf.ifc_req = my_ifreqs;
if( (code = ioctl( socketfd, SIOCGIFCONF, (caddr_t)&host_conf)) < 0 )
{
debug( 0, module, “Unable to ioctl socket, errno = (%d)”, errno );
return( 0 );
}
for( ifreqptr = host_conf.ifc_req; strlen( ifreqptr->ifr_name) > 0;
ifreqptr = (struct ifreq *)((caddr_t)ifreqptr + IFNAMSIZ +
ifreqptr->ifr_ifru.ifru_addr.sa_len ))
{
debug( 0, module, “interface (%s)”, ifreqptr->ifr_name );
my_sin = (struct sockaddr_in *)&ifreqptr->ifr_addr;
if( family != my_sin->sin_family )
continue;
if( net_addr != my_sin->sin_addr.s_addr )
continue;
// We found a match so get the broadcast address
debug( 0, module, “Match on interface” );
bzero( (char *)&brd_ifreq, sizeof( brd_ifreq ));
strncpy( brd_ifreq.ifr_name, ifreqptr->ifr_name, sizeof(
brd_ifreq.ifr_name ));
if( (code = ioctl( socketfd, SIOCGIFBRDADDR, (caddr_t)&brd_ifreq )) < 0 )
{
debug( 0, module, “Unable to ioctl socket, errno = (%d)”, errno );
return( 0 );
}
my_sin = (struct sockaddr_in *)&brd_ifreq.ifr_addr;
debug( 0, module, “Broadcast addr (%s)”, inet_ntoa(my_sin->sin_addr ));
return( my_sin->sin_addr.s_addr );
}