sl@0
|
1 |
/** @file ../include/sys/ioccom.h
|
sl@0
|
2 |
@internalComponent
|
sl@0
|
3 |
*/
|
sl@0
|
4 |
|
sl@0
|
5 |
/** @fn ioctl(int aFid, unsigned long aCmd, ...)
|
sl@0
|
6 |
@param aFid
|
sl@0
|
7 |
@param aCmd
|
sl@0
|
8 |
@param ...
|
sl@0
|
9 |
@return If an error has occurred, a value of -1 is returned and errno is set to indicate the error.
|
sl@0
|
10 |
|
sl@0
|
11 |
@code
|
sl@0
|
12 |
#include < sys/ioctl.h >
|
sl@0
|
13 |
@endcode
|
sl@0
|
14 |
The ioctl system call manipulates the underlying device parameters of special files.
|
sl@0
|
15 |
In particular, many operating
|
sl@0
|
16 |
characteristics of character special files (e.g. terminals)
|
sl@0
|
17 |
may be controlled with ioctl requests.
|
sl@0
|
18 |
The argument aFid
|
sl@0
|
19 |
must be an open file descriptor.
|
sl@0
|
20 |
|
sl@0
|
21 |
The third argument to ioctl is traditionally named char *argp .
|
sl@0
|
22 |
Most uses of ioctl in 3.0,
|
sl@0
|
23 |
however require the third argument to be a caddr_t
|
sl@0
|
24 |
or an int.
|
sl@0
|
25 |
|
sl@0
|
26 |
An ioctl request has encoded in it whether the argument is an "in"
|
sl@0
|
27 |
argument
|
sl@0
|
28 |
or "out"
|
sl@0
|
29 |
argument, and the size of the argument argp in bytes.
|
sl@0
|
30 |
Macros and defines used in specifying an ioctl request are located in the file \#include \<sys/ioctl.h \>
|
sl@0
|
31 |
|
sl@0
|
32 |
Examples:
|
sl@0
|
33 |
@code
|
sl@0
|
34 |
/* Detailed description : Sample usage of ioctl system call ,for command SIOCGIFINDEX
|
sl@0
|
35 |
* which gets socket interface index , by passing socket interface home.*/
|
sl@0
|
36 |
#include <sys/types.h>
|
sl@0
|
37 |
#include <sys/socket.h>
|
sl@0
|
38 |
#include <stdio.h>
|
sl@0
|
39 |
#include <sys/ioctl.h>
|
sl@0
|
40 |
int main()
|
sl@0
|
41 |
{
|
sl@0
|
42 |
int ret = 0;
|
sl@0
|
43 |
struct ifreq ifr;
|
sl@0
|
44 |
int sockfd;
|
sl@0
|
45 |
|
sl@0
|
46 |
sockfd = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
|
sl@0
|
47 |
strncpy(ifr.ifr_name, "Ethernet with Daemon Dynamic IP", sizeof(ifr.ifr_name));
|
sl@0
|
48 |
|
sl@0
|
49 |
if (ioctl(sockfd, SIOCGIFINDEX, 𝔦) != -1)
|
sl@0
|
50 |
{
|
sl@0
|
51 |
ret = -1;
|
sl@0
|
52 |
}
|
sl@0
|
53 |
|
sl@0
|
54 |
close(sockfd);
|
sl@0
|
55 |
return ret; }
|
sl@0
|
56 |
|
sl@0
|
57 |
@endcode
|
sl@0
|
58 |
@see fcntl()
|
sl@0
|
59 |
|
sl@0
|
60 |
|
sl@0
|
61 |
|
sl@0
|
62 |
@capability Deferred @ref Rsocket::Open
|
sl@0
|
63 |
|
sl@0
|
64 |
@publishedAll
|
sl@0
|
65 |
@externallyDefinedApi
|
sl@0
|
66 |
*/
|
sl@0
|
67 |
|
sl@0
|
68 |
/** @def _IOR(g,n,t)
|
sl@0
|
69 |
|
sl@0
|
70 |
IO read.
|
sl@0
|
71 |
|
sl@0
|
72 |
@publishedAll
|
sl@0
|
73 |
@released
|
sl@0
|
74 |
*/
|
sl@0
|
75 |
|
sl@0
|
76 |
/** @def _IOW(g,n,t)
|
sl@0
|
77 |
|
sl@0
|
78 |
IO write.
|
sl@0
|
79 |
|
sl@0
|
80 |
@publishedAll
|
sl@0
|
81 |
@released
|
sl@0
|
82 |
*/
|
sl@0
|
83 |
|
sl@0
|
84 |
/** @def _IOWR(g,n,t)
|
sl@0
|
85 |
|
sl@0
|
86 |
IO read write.
|
sl@0
|
87 |
|
sl@0
|
88 |
@publishedAll
|
sl@0
|
89 |
@released
|
sl@0
|
90 |
*/
|
sl@0
|
91 |
|
sl@0
|
92 |
|