Socket ioctl commands are a subset of the
ioctl
calls, which can perform a variety of
functions on sockets. sockfd shall contain
the value of a file descriptor that was created with the
socket
or accept
calls.
Socket ioctl commands apply to the underlying
network interfaces, and affect the entire system, not just the file
descriptor used to issue the ioctl
.
The following ioctl
s are provided:
Gets the interface configuration list for the system.
[1]
argp is a pointer to a
ifconf
structure. Before calling, the caller
shall allocate the ifc_ifcu.ifcu_req
field
to point to an array of ifreq
structures, and
set if_len
to the size of this allocated
array (in bytes). Upon return, if_len
will contain the amount of the array which was actually used (again,
in bytes). If it is the same as the length upon calling, the caller
should assume that the array was too small and try again with a
larger array.
On success, SIOCGIFCONF can return any nonnegative value. [2]
Gets the interface flags for the indicated interface.
argp is a pointer to a
ifreq
structure. Before calling, the
caller should fill in the ifr_name
field with the interface name, and upon return, the
ifr_ifru.ifru_flags
field is set
with the interface flags.
Gets the interface address list for the system.
argp is a pointer to a
ifreq
structure. Before calling, the
caller should fill in the ifr_name
field with the interface name, and upon return, the
ifr_ifru.ifru_addr
field is set
with the interface address.
Gets the network mask for the indicated interface.
argp is a pointer to a
ifreq
structure. Before calling, the
caller should fill in the ifr_name
field with the interface name, and upon return, the
ifr_ifru.ifru_netmask
field is set
with the network mask.
Returns the amount of queued unread data in the receive buffer. Argument is a pointer to an integer where the result is to be placed.
The sockaddr
structure is as specified in
the Single UNIX Specification.
On success, 0 is returned. On error, -1 is returned and the global variable errno is set appropriately.
sockfd is not a valid descriptor.
argp references an inaccessible memory area.
sockfd is not associated with a character special device.
The specified request does not apply to the kind of object that the descriptor sockfd references.
request and argp are not valid.
The operation is only defined on a connected socket, but the socket wasn't connected.
[1] | SIOCGIFCONF is similar to the
|
[2] | Historical UNIX systems disagree on the meaning of the return value. |