diff options
author | Steven <sluong@cisco.com> | 2017-10-12 17:10:33 -0700 |
---|---|---|
committer | Keith Burns <alagalah@gmail.com> | 2017-10-13 16:46:51 +0000 |
commit | b59f227ab010837874614551c1f86ed06f3075dd (patch) | |
tree | f88082ed69d70ca434213fce9fa78d706020d710 /extras/vcl-ldpreload/src/libvcl-ldpreload/vcom.c | |
parent | bccd339a59788435d67e37845cd2446626466e98 (diff) |
LDPRELOAD: Add ioctl, fcntl, and setsockopt support
Add support for the following system calls:
ioctl (FIONREAD)
fcntl (F_GETFL)
fcntl (F_SETFL)
setsockopt (SOL_IPV6, IPV6_V6ONLY)
setsockopt (SOL_TCP, TCP_NODELAY)
setsockopt (SOL_SOCKET, SO_REUSEADDR)
setsockopt (SOL_SOCKET, SO_BROADCAST)
This patch supersedes https://gerrit.fd.io/r/#/c/8765/
Change-Id: I5d5309d9f43d93a990b389d8cb667631de1903fe
Signed-off-by: Steven <sluong@cisco.com>
Diffstat (limited to 'extras/vcl-ldpreload/src/libvcl-ldpreload/vcom.c')
-rw-r--r-- | extras/vcl-ldpreload/src/libvcl-ldpreload/vcom.c | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/extras/vcl-ldpreload/src/libvcl-ldpreload/vcom.c b/extras/vcl-ldpreload/src/libvcl-ldpreload/vcom.c index 6245c5d2487..d5b3e127297 100644 --- a/extras/vcl-ldpreload/src/libvcl-ldpreload/vcom.c +++ b/extras/vcl-ldpreload/src/libvcl-ldpreload/vcom.c @@ -426,6 +426,61 @@ out: return rv; } +int +vcom_ioctl_va (int __fd, unsigned long int __cmd, va_list __ap) +{ + if (vcom_init () != 0) + { + return -1; + } + + return vcom_socket_ioctl_va (__fd, __cmd, __ap); +} + +int +vcom_ioctl (int __fd, unsigned long int __cmd, ...) +{ + int rv = -1; + va_list ap; + + if (is_vcom_socket_fd (__fd)) + { + va_start (ap, __cmd); + rv = vcom_ioctl_va (__fd, __cmd, ap); + va_end (ap); + } + return rv; +} + +int +ioctl (int __fd, unsigned long int __cmd, ...) +{ + int rv; + va_list ap; + pid_t pid = getpid (); + + va_start (ap, __cmd); + if (is_vcom_socket_fd (__fd)) + { + rv = vcom_ioctl_va (__fd, __cmd, ap); + if (VCOM_DEBUG > 0) + fprintf (stderr, + "[%d] ioctl: " + "'%04d'='%04d', '%04ld'\n", pid, rv, __fd, __cmd); + if (rv < 0) + { + errno = -rv; + rv = -1; + } + goto out; + } + rv = libc_vioctl (__fd, __cmd, ap); + +out: + va_end (ap); + return rv; +} + /* * Check the first NFDS descriptors each in READFDS (if not NULL) for * read readiness, in WRITEFDS (if not NULL) for write readiness, |