Purpose
Performs network related control operations.
Syntax
#include <sys/ioctl.h>
int ioctl (fd, cmd, .../* arg */)
int fd;
int cmd;
int ... /* arg */
Description
The socket ioctl commands perform a variety of network-related control. The fd argument is a socket descriptor. For non-socket descriptors, the functions performed by this call are unspecified.
The cmd argument and an optional third argument (with varying type) are passed to and interpreted by the socket ioctl function to perform an appropriate control operation specified by the user.
The socket ioctl control operations can be in the following control operations categories:
Parameters
Socket Control Operations
The following ioctl commands operate on sockets:
ioctl command | Description |
---|---|
SIOCATMARK | Determines whether the read pointer is currently pointing to the logical mark in the data stream. The logical mark indicates the point at which the out-of-band data is sent. If atmark is set to 1 on return, the read pointer points to the mark and the next read returns data after the mark. Ifatmark is set to 0 on return, (assuming out-of-band data is present on the data stream), the next read returns data sent prior to the out-of-band mark.
Note:
The out-of-band data is a logically independent data channel that is delivered to the user independently of normal data; in addition, a signal is also sent because of the immediate attention required. Ctrl-C characters are an example.
|
SIOCSPGRP SIOCGPGRP | SIOCSPGRP sets the process group information for a socket. SIOCGPGRP gets the process group ID associated with a socket.
|
Routing Table Control Operations
The following ioctl commands operate on the kernel routing table:
ioctl command | Description |
---|---|
SIOCADDRT SIOCDELRT | SIOCADDRT adds a route entry in the routing table. SIOCDELRT deletes a route entry from the routing table.
|
SIOUPDROUTE | Updates the routing table using the information passed in the ifreq structure.
Note:
SIOUPDROUTE is available beginning with AIX® 5100-002 (maintenance level 2) and later.
|
ARP Table Control Operations
The following ioctl commands operate on the kernel ARP table. The net/if_arp.h header file must be included.
ioctl command | Description |
---|---|
SIOCSARP SIOCDARP SIOCGARP | SIOCSARP adds or modifies an ARP entry in the ARP table. SIOCDARP deletes an ARP entry from the ARP table. SIOCGARP gets an ARP entry from the ARP table.
|
Global Network Parameters Control Operations
The following ioctl commands operate as global network parameters:
ioctl command | Description |
---|---|
SIOCSNETOPT SIOCGNETOPT SIOCDNETOPT SIOCGNETOPT1 | SIOCSNETOPT sets the value of a network option. SIOCGNETOPT gets the value of a network option. SIOCDNETOPT sets the default values of a network option.
SIOCGNETOPT1 gets the current value, default value, and the range of a network option. The network option information is stored in the optreq1 structure upon return The optreq and optreq1 structures are defined in net/netopt.h.
Note:
SIOCGNETOPT1 is available beginning with AIX® 5.2 and later.
|
SIOCGNMTUS SIOCGETMTUS SIOCADDMTU SIOCDELMTU | SIOCGNMTUS gets the number of MTUs maintained in the list of common MTUs. SIOCADDMTU adds an MTU in the list of common MTUs. SIOCDELMTU deletes an MTU from the list of common MTUs.
SIOCGETMTUS gets the MTUs maintained in the list of common MTUs. The get_mtus structure is defined in netinet/in.h. |
Interface Control Operations
The following ioctl commands operate on interfaces. The net/if.h header file must be included.
ioctl command | Description |
---|---|
SIOCSIFADDR SIOCAIFADDR SIOCDIFADDR SIOCGIFADDR | SIOCSIFADDR sets an interface address. SIOCAIFADDR adds or changes an interface address. SIOCDIFADDR deletes an interface address. The interface address is specified in the ifr.ifr_addr field. SIOCGIFADDR gets an interface address. The address is returned in the ifr.ifr_addr field.
|
SIOCGIFADDRS | Gets the list of addresses associated with an interface. The interface name is passed in the ifaddrsp->ifr_name field. The addresses associated with the interface are stored in ifaddrsp->ifrasu[] array on return.
Note:
The
ifreqaddrs structure contains space for storing only one
sockaddr_in/sockaddr_in6 structure (array of one
sockaddr_in/sockaddr_in6 element). In order to get
n addresses associated with an interface, the caller of the ioctl command must allocate space for
{sizeof (struct ifreqaddrs) + (n * sizeof (struct sockaddr_in)}bytes.
Note:
SIOCGIFADDRS is available beginning with AIX® 5.3 and later.
|
SIOCSIFDSTADDR SIOCGIFDSTADDR | SIOCSIFDSTADDR sets the point-to-point address for an interface specified in the ifr.ifr_dstaddr field. SIOCGIFDSTADDR gets the point-to-point address associated with an interface. The address is stored in theifr.ifr_dstaddr field on return.
|
SIOCSIFNETMASK SIOCGIFNETMASK | SIOCSIFNETMASK sets the interface netmask specified in the ifr.ifr_addr field. SIOCGIFNETMASK gets the interface netmask.
|
SIOCSIFBRDADDR SIOCGIFBRDADDR | SIOCSIFBRDADDR sets the interface broadcast address specified in the ifr.ifr_broadaddr field. SIOCGIFBRDADDR gets the interface broadcast address. The broadcast address is placed in the ifr.ifr_broadaddr field.
|
SIOCGSIZIFCONF | Gets the size of memory required to get configuration information for all interfaces returned by SIOCGIFCONF. |
SIOCGIFCONF | Returns configuration information for all the interfaces configured on the system. The configuration information is returned in a list of ifreq structures pointed to by the ifc.ifc_req field, with one ifreqstructure per interface.
Note:
The caller of the ioctl command must allocate sufficient space to store the configuration information, returned as a list of
ifreq structures for all of the interfaces configured on the system. For example, if
n interfaces are configured on the system,
ifc.ifc_req must point to
{n * sizeof (struct ifreq)} bytes of space allocated.
Note:
Alternatively, the SIOCGSIZIFCONF ioctl command can be used for this purpose.
|
SIOCSIFFLAGS SIOCGIFFLAGS | SIOCSIFFLAGS sets the interface flags. SIOCGIFFLAGS gets the interface flags. Refer to /usr/include/net/if.h for the interface flags, denoted by IFF_xxx.
Note:
The
IFF_BROADCAST,
IFF_POINTTOPOINT,
IFF_SIMPLEX,
IFF_RUNNING,
IFF_OACTIVE, and
IFF_MULTICAST flags cannot be changed using ioctl.
|
SIOCSIFMETRIC SIOCGIFMETRIC | SIOCSIFMETRIC sets the interface metric specified in the ifr.ifr_metric field. SIOCGIFMETRIC gets the interface metric. The interface metric is placed in the ifr.ifr_metric field on return.
|
SIOCSIFSUBCHAN SIOCGIFSUBCHAN | SIOCSIFSUBCHAN sets the subchannel address specified in the ifr.ifr_flags field. SIOCGIFSUBCHAN gets the subchannel address in the ifr.ifr_flags field. |
SIOCSIFOPTIONS SIOCGIFOPTIONS | SIOCSIFOPTIONS sets the interface options. SIOCGIFOPTIONS gets the interface options. The interface options are stored in the ifr_flags field of the ifreq structure. Refer to /usr/include/net/if.h file for the list of interface options denoted by IFO_xxx. |
ioctl command | Description |
---|---|
SIOCADDMULTI SIOCDELMULTI | SIOCADDMULTI adds an address to the list of multicast addresses for an interface. SIOCDELMULTI deletes a multicast address from the list of multicast addresses for an interface.
|
SIOCGETVIFCNT | Gets the packet count information for a virtual interface. The information is specified in the sioc_vif_reqstructure. |
SIOCGETSGCNT | Gets the packet count information for the source group specified. The information is stored in the sioc_sg_reqstructure on return. |
SIOCSIFMTU SIOCGIFMTU | SIOCSIFMTU sets the interface maximum transmission unit (MTU). SIOCGIFMTU gets the interface MTU. The MTU value is stored in ifr.ifr_mtu field.
Note:
The range of valid values for MTU varies for an interface depending on the interface type.
|
SIOCIFATTACH SIOCIFDETACH | SIOCIFATTACH attaches an interface. This initializes and adds an interface in the network interface list. SIOCIFDETACH detaches an interface broadcast address. This removes the interface from the network interface list. The interface name is specified in the ifr.ifr_name field. |
SIOCSIFGIDLIST SIOCGIFGIDLIST | SIOCSIFGIDLIST adds or deletes the list of group IDs specified in the ifrg.ifrg_gidlist field to the gidlist interface. The interface name is specified in the ifrg.ifrg_name field. An operation code, ADD_GRP/DEL_GRP, specified in theifrg.ifrg_gidlist field indicates whether the specified list of group IDs must be added to or deleted from the gidlistinterface. SIOCGIFGIDLIST gets the list of group IDs associated with an interface. The group IDs are placed in the ifrg.ifrg_gidlist field on return. |
SIOCIF_ATM_UBR SIOCIF_ATM_SNMPARP SIOCIF_ATM_DUMPARP SIOCIF_ATM_IDLE SIOCIF_ATM_SVC SIOCIF_ATM_DARP SIOCIF_ATM_GARP SIOCIF_ATM_SARP | SIOCIF_ATM_UBR sets the UBR rate for an ATM interface. SIOCIF_ATM_SNMPARP gets the SNMP ATM ARP entries. SIOCIF_ATM_DUMPARP gets the specified number of ATM ARP entries. SIOCIF_ATM_DARP deletes an ATM ARP entry from the ARP table. SIOCIF_ATM_GARP gets an ATM ARP entry to the ARP table. SIOCIF_ATM_SARP adds an ATM ARP entry. The ARP information is specified in the atm_arpreq structure. SIOCIF_ATM_SVC specifies whether this interface supports Permanent Virtual Circuit (PVC) and Switched Virtual Circuit (SVC) types of virtual connections. It also specifies whether this interface will be an ARP client or an ARP server for this Logical IP Subnetwork (LIS) based on the flag set in the ifatm_svc_arg structure. SIOCIF_ATM_IDLE specifies the idle time limit on the interface. |
SIOCSISNO SIOCGISNO | SIOCSISNO sets interface specific network options for an interface. SIOCGISNO gets interface specific network options associated with an interface.
|
SIOCGIFBAUDRATE | Gets the value of the interface baud rate in the ifr_baudrate field. The baud rate is stored in the ifr.ifr_baudrate field. |
SIOCADDIFVIPA SIOCDELIFVIPA SIOCLISTIFVIPA | SIOCADDIFVIPA associates the specified list of interfaces pointed to by ifrv.ifrv_ifname with the virtual interface specified by ifrv.ifrv_name. This causes the source address for all outgoing packets on these interfaces to be set to the virtual interface address. SIOCDELIFVIPA removes the list of specified interfaces pointed to by ifrv.ifrv_ifname, that are associated with the virtual interface specified by ifrv.ifrv_name, using SIOCADDIFVIPA. SIOCLISTIFVIPA lists all the interfaces associated with the virtual interface specified by ifrv.ifrv_name. The virtual interface information is stored in the ifvireq structure.
Note:
These flags operate on a virtual interface only. Also, these flags are available beginning with AIX® 5.2 and later.
|
SIOCSIFADDR6 | Set or Add an IPv6 address. |
SIOCGIFADDR6 | Gets an IPv6 address. |
SIOCSIFDSTADDR6 | Set the destination (point-to-point) address for a IPv6 address. |
SIOCGIFDSTADDR6 | Get the destination (point-to-point) address for a IPv6 address. |
SIOCSIFNETMASK6 | Set the netmask for an IPv6 address as specified in the ifr.ifr_Addr structure. |
SIOCGIFNETMASK6 | Get the netmask for an IPv6 address as specified in the ifr.ifr_Addr structure.
Note:
![]()
The
ifr structure can be filled by calling the ioctl function for the
SIOCGIFADDR6 command before calling the
SIOCGIFNETMASK6 command.
![]() |
SIOCDIFADDR6 | Delete an IPv6 address. |
SIOCFIFADDR6 | Put an IPv6 address at the beginning of the address list. |
SIOCAIFADDR6 | Add or change an IPv6 alias address. |
SIOCADDANY6 | Add an IPv6 anycast address. |
SIOCDELANY6 | Delete an IPv6 anycast address. |
SIOCSIFZONE6 | Set the IPv6 zone ID of an interface at a particular address scope. |
SIOCGIFZONE6 | Get the IPv6 scope zone IDs of an interface. |
SIOCSIFADDRORI6 | Set the configuration origin for an IPv6 address. |
SIOCAIFADDR6T | Add or change an IPv6 alias address and type. |
SIOCGIFADDR6T | Get the type of an IPv6 address. |
SIOCSIFADDRSTATE6 | Change the state of an IPv6 address. |
SIOCGIFADDRSTATE6 | Get the state of an IPv6 address. |
SIOCGSRCFILTER6 | Get the IPv6 multicast group source filter for an interface. |
SIOCACLADDR6 | Add an IPv6 cluster alias address. |
SIOCDCLADDR6 | Delete an IPv6 cluster address. |
SIOCSIFADDRFLAG6 | Set address source flag for an IPv6 address. |
SIOCGIFADDRFLAG6 | Get address source flag for an IPv6 address. |
Return Values
Upon successful completion, ioctl returns 0. Otherwise, it returns -1 and sets errno to indicate the error.
Error Codes
The ioctl commands fail under the following general conditions:
EBADF | The file descriptor fd is not a valid open socket file descriptor. |
EINTR | A signal was caught during ioctl operation. |
EINVAL | An invalid command or argument was specified. |
If the underlying operation specified by the ioctl command cmd failed, ioctl fails with one of the following error codes:
EACCES | Permission denied for the specified operation. |
EADDRNOTAVAIL | Specified address not available for interface. |
EAFNOSUPPORT | Operation not supported on sockets. |
EBUSY | Resource is busy. |
EEXIST | An entry or file already exists. |
EFAULT | Argument references an inaccessible memory area. |
EIO | I/O error. |
ENETUNREACH | Gateway unreachable. |
ENOBUFS | Routing table overflow. |
ENOCONNECT | No connection. |
ENOMEM | Not enough memory available. |
ENOTCONN | The operation is only defined on a connected socket, but the socket was not connected. |
ENXIO | Device does not exist. |
ESRCH | No such process. |
----
====
http://publib.boulder.ibm.com/infocenter/aix/v6r1/index.jsp?topic=%2Fcom.ibm.aix.commtechref%2Fdoc%2Fcommtrf2%2Fioctl_socket_control_operations.htm