Linux ioctl() Primer |
|
|
Vipul Gupta
In general an ioctl call in a user program looks like ioctl(int fd, int command, (char *) argstruct). For ioctl calls related to the networking code (these are the only ones we will deal with in this note), the file descriptor fd is actually a socket descriptor returned by the socket() system call. The command could be any one of those listed in /usr/include/linux/sockios.h. These commands are subdivided into a number of categories depending on what aspect of networking they deal with:
changing the routing table (e.g. SIOCADDRT, SIOCDELRT),
reading/updating the ARP/RARP caches (e.g. SIOCDARP, SIOCSRARP),
generic functions related to network interfaces (e.g. SIOCGIFNAME, SIOCSIFADDR etc)
The Goodies directory contains a number of sample programs illustrating the use of networking ioctl calls. As you look at these programs, notice how the structure used for argstruct depends on the ioctl command type. For example, routing table related ioctls use the rte < 1 > < 2 > |
|
|
在百度搜索:Linux ioctl() Primer
|