IPX/SPX Programming Manual
Library Routines
HP NonStop IPX/SPX Programming Manual—528022-001
5-65
socket_ioctl, socket_ioctl_nw
•
For SIOCGIFNUM, aliases are not included in the count.
For information on error checking, see Nowait Call Errors on page 5-5.
Socket I/O Control Operations
Table 5-3 gives the I/O control operations that can be specified in command, the
corresponding pointer types for arg_ptr, and descriptions of the commands. The
definitions of the structures pointed to by arg_ptr are provided in Section 4, Data
Structures.
Example
The following program excerpt shows an example of using both the SIOCGIFCONF
and SIOCGIFNUM functions. This program displays the names of all the interfaces
configured.
... /* declarations */
struct ifreq* ifr;
struct ifconf* ifc;
int ifcount,res,datasize,bufsize,i,ifr_count;
... /* procedure code */
... /* assume socket is already created, descriptor ‘sd’ */
res = socket_ioctl(sd,SIOCGIFNUM, (char*)&ifcount);
... /* error checking */
/* bufsize * 2 to allow for alias entries */
datasize = sizeof(struct ifreq) * ifcount * 2;
bufsize = sizeof(struct ifconf) + datasize;
ifc = (struct ifconf*)malloc(bufsize);
... /* error checking */
ifc->ifc_len = datasize;
ifc->ifc_buf = (char*)&ifc[1];
res = socket_ioctl(sd,SIOCGIFCONF,(char*)ifc);
... /* error checking */
ifr_count = ifc->ifc_len / sizeof(struct ifreq);
ifr = (struct ifreq*)&ifc[1];
for (i=0; i<ifr_count;i++)
Table 5-3. Socket I/O Control Operations
Command Pointer Type for arg Description
FIONREAD int * Get the number of bytes waiting to be
read.
SIOCGIFCONF struct ifconf * Get the interface configuration list. See
Usage Guidelines above.
SIOCGIFNUM int * Get the number of interfaces that have
been configured. See Usage Guidelines
above.
SIOCDELRT char * Delete a specific source route entry
from the Token Ring route table (the
route entry is a 6-byte MAC address).