TCP/IP Programming Manual
Table 16 Socket I/O Control Operations (continued)
DescriptionPointer Type for argCommand
Set the broadcast address associated
with a subnet device. Returns the error
[EOPNOTSUPP].
struct ifreq *SIOCSIFBRDADDR
Get the broadcast address associated
with a subnet device.
struct ifreq *SIOCGIFBRDADDR
Set the network address mask.
SIOCSIFNETMASK specifies which
struct ifreq *SIOCSIFNETMASK
portion of the IP host ID and IP network
number should be masked to define a
subnet. Returns the error
[EOPNOTSUPP].
Get the network address mask.struct ifreq *SIOCGIFNETMASK
Set an ARP protocol (IP
address/hardware address pair)
struct arpreq *SIOCSARP
address entry in the translation table.
This address is distinct from the ARP
hardware address.
Get an ARP protocol address entry
(hardware address) from the translation
table.
struct arpreq *SIOCGARP
Delete an ARP protocol address (IP
address/hardware address pair) entry
from the translation table.
struct arpreq *SIOCDARP
Examples
See UDP Client Program (page 219) for examples that call the socket_ioctl function.
The following program excerpt shows an example of using both the SIOCGIFCONF and
SIOCGIFNUM functions. The names of all interfaces configured are displayed.
... /* 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++)
printf("Interface %d: %s\n",i,ifr[i].ifr_name);
.../*end of program extract*/
socket_set_inet_name
The socket_set_inet_name function specifies the name of the NonStop TCP/IP or TCP6SAM
process that the socket library is going to open.
200 Library Routines