MCPcopy Index your code
hub / github.com/F-Stack/f-stack / ioctl_va

Function ioctl_va

tools/compat/ioctl.c:49–167  ·  view source on GitHub ↗

* In general, we always call like this: ioctl(fd, com, data), * but if there is a pointer in the data and the pointer points to * a memory area, for example, data is struct ifreq, and it uses * ifreq.ifr_ifru.ifru_data, we must copy the memory to msg->buf_addr, * after this, it can be used to communicate with F-Stack process. * Otherwise, an unknown error will occur. * * Two cases: * 1.Nor

Source from the content-addressed store, hash-verified

47 *
48 */
49int
50ioctl_va(int fd, unsigned long com, void *data, int argc, ...)
51{
52 struct ff_msg *msg, *retmsg = NULL;
53 unsigned size;
54 void *cpy_mem;
55 size_t offset, clen;
56 int af = AF_INET;
57
58 if (argc != 0 && argc != 3 && argc != 1) {
59 errno = EINVAL;
60 return -1;
61 }
62
63 if (argc == 3) {
64 va_list ap;
65 va_start(ap, argc);
66 offset = va_arg(ap, size_t);
67 cpy_mem = va_arg(ap, void *);
68 clen = va_arg(ap, size_t);
69 va_end(ap);
70 } else if (argc == 1) {
71 va_list ap;
72 va_start(ap, argc);
73 af = va_arg(ap, int);
74 va_end(ap);
75 }
76
77 if (com > 0xffffffff) {
78 printf("WARNING: ioctl sign-extension ioctl %lx\n", com);
79 com &= 0xffffffff;
80 }
81
82 size = IOCPARM_LEN(com);
83 if ((size > IOCPARM_MAX) ||
84 ((com & (IOC_IN | IOC_OUT)) == 0) ||
85 (size == 0) ||
86 (com & IOC_VOID))
87 return (ENOTTY);
88
89 msg = ff_ipc_msg_alloc();
90 if (msg == NULL) {
91 errno = ENOMEM;
92 return -1;
93 }
94
95 if (size > msg->buf_len) {
96 errno = ENOMEM;
97 ff_ipc_msg_free(msg);
98 return -1;
99 }
100
101#ifdef INET6
102 if (af == AF_INET6) {
103 msg->msg_type = FF_IOCTL6;
104 } else
105#endif
106 if (af == AF_INET)

Callers 15

inet6.cFile · 0.85
group_memberFunction · 0.85
ifconfigFunction · 0.85
ifconfig.cFile · 0.85
setifdescrFunction · 0.85
ipsec_statusFunction · 0.85
ifipsec.cFile · 0.85
gif_statusFunction · 0.85
ifgif.cFile · 0.85
ifgre.cFile · 0.85
setifgrekeyFunction · 0.85
setifgreportFunction · 0.85

Calls 6

ff_ipc_msg_allocFunction · 0.85
ff_ipc_msg_freeFunction · 0.85
ff_ipc_sendFunction · 0.85
ff_ipc_recvFunction · 0.85
printfFunction · 0.50
memcpyFunction · 0.50

Tested by

no test coverage detected