4 * Copyright (c) 2000 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
8 * Jaewon Lim <jaewon81.lim@samsung.com>
9 * Woojin Jung <woojin2.jung@samsung.com>
10 * Juyoung Kim <j0.kim@samsung.com>
11 * Anastasia Lyupa <a.lyupa@samsung.com>
13 * This library is free software; you can redistribute it and/or modify it under
14 * the terms of the GNU Lesser General Public License as published by the
15 * Free Software Foundation; either version 2.1 of the License, or (at your option)
18 * This library is distributed in the hope that it will be useful, but WITHOUT ANY
19 * WARRANTY; without even the implied warranty of MERCHANTABILITY or
20 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
21 * License for more details.
23 * You should have received a copy of the GNU Lesser General Public License
24 * along with this library; if not, write to the Free Software Foundation, Inc., 51
25 * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
29 * - Samsung RnD Institute Russia
39 #include <sys/types.h>
40 #include <sys/socket.h>
43 #include <arpa/inet.h>
47 #include "probeinfo.h"
50 #include "da_socket.h"
54 static enum DaOptions _sopt = OPT_FILE;
56 int socket(int domain, int type, int protocol)
58 static int (*socketp)(int domain, int type, int protocol);
60 BEFORE_ORIGINAL_NOFILTER(socket, LIBC);
62 ret = socketp(domain, type, protocol);
64 AFTER_PACK_ORIGINAL_SOCK(API_ID_socket,
65 ret, 0, ret, FD_API_OPEN, "ddd", domain, type, protocol);
70 int socketpair(int domain, int type, int protocol,int socket_vector[2])
72 static int (*socketpairp)(int domain, int type, int protocol,int socket_vector[2]);
74 BEFORE_ORIGINAL_NOFILTER(socketpair, LIBC);
76 ret = socketpairp(domain, type, protocol, socket_vector);
78 //TODO: socket pair: socket_vector[0]/socket_vector[1], FD - ?
79 AFTER_PACK_ORIGINAL_SOCK(API_ID_socketpair,
80 ret, 0, socket_vector[0], FD_API_OPEN,
81 "dddp", domain, type, protocol, socket_vector);
86 int shutdown(int socket, int how)
88 static int (*shutdownp)(int socket, int how);
90 BEFORE_ORIGINAL_NOFILTER(shutdown, LIBC);
92 ret = shutdownp(socket, how);
94 AFTER_PACK_ORIGINAL_SOCK(API_ID_shutdown,
95 ret, 0, socket, FD_API_OTHER, "dd", socket, how);
100 int bind(int socket, const struct sockaddr *address, socklen_t address_len)
102 static int (*bindp)(int socket, const struct sockaddr *address, socklen_t address_len);
104 BEFORE_ORIGINAL(bind, LIBC);
106 ret = bindp(socket, address, address_len);
108 AFTER_PACK_ORIGINAL_SOCK(API_ID_bind,
109 ret, 0, socket, FD_API_MANAGE,
110 "dpd", socket, address, address_len);
115 int listen(int socket, int backlog)
117 static int (*listenp)(int socket, int backlog);
119 BEFORE_ORIGINAL(listen, LIBC);
121 ret = listenp(socket, backlog);
123 AFTER_PACK_ORIGINAL_SOCK(API_ID_listen,
124 ret, 0, socket, FD_API_MANAGE, "dd", socket, backlog);
129 int accept(int socket, struct sockaddr *address, socklen_t *address_len)
131 static int (*acceptp)(int socket, struct sockaddr *address, socklen_t *address_len);
133 BEFORE_ORIGINAL_NOFILTER(accept, LIBC);
135 ret = acceptp(socket, address, address_len);
137 AFTER_PACK_ORIGINAL_SOCK(API_ID_accept,
138 ret, 0, socket, FD_API_MANAGE,
139 "dpp", socket, address, address_len);
144 int accept4(int sockfd, struct sockaddr *addr, socklen_t *addrlen, int flags)
146 static int (*accept4p)(int sockfd, struct sockaddr *addr, socklen_t *addrlen, int flags);
148 BEFORE_ORIGINAL_NOFILTER(accept4, LIBC);
150 ret = accept4p(sockfd, addr, addrlen, flags);
152 AFTER_PACK_ORIGINAL_SOCK(API_ID_accept4,
153 ret, 0, sockfd, FD_API_MANAGE,
154 "dppd", sockfd, addr, addrlen, flags);
159 int connect(int socket, const struct sockaddr *address, socklen_t address_len)
161 static int (*connectp)(int socket, const struct sockaddr *address, socklen_t address_len);
163 BEFORE_ORIGINAL(connect, LIBC);
165 ret = connectp(socket, address, address_len);
167 AFTER_PACK_ORIGINAL_SOCK(API_ID_connect,
168 ret, address_len, socket, FD_API_MANAGE,
169 "dpd", socket, address, address_len);
174 int select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct timeval *timeout)
176 static int (*selectp)(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct timeval *timeout);
178 BEFORE_ORIGINAL(select, LIBC);
180 ret = selectp(nfds, readfds, writefds,exceptfds, timeout);
182 AFTER_PACK_ORIGINAL_SOCK(API_ID_select,
183 ret, 0, nfds, FD_API_MANAGE,
184 "dpppp", nfds, readfds, writefds, exceptfds, timeout);
189 int pselect(int nfds, fd_set *readfds, fd_set *writefds,fd_set *exceptfds, const struct timespec *ntimeout, const sigset_t *sigmask)
191 static int (*pselectp)(int nfds, fd_set *readfds, fd_set *writefds,fd_set *exceptfds, const struct timespec *ntimeout, const sigset_t *sigmask);
193 BEFORE_ORIGINAL(pselect, LIBC);
195 ret = pselectp(nfds, readfds, writefds,exceptfds, ntimeout, sigmask);
197 AFTER_PACK_ORIGINAL_SOCK(API_ID_pselect,
198 ret, 0, nfds, FD_API_MANAGE, "dppppp",
199 nfds, readfds, writefds, exceptfds, ntimeout, sigmask);
204 ssize_t send(int socket, const void *message, size_t length, int flags)
206 static ssize_t (*sendp)(int socket, const void *message, size_t length, int flags);
209 BEFORE_ORIGINAL(send, LIBC);
211 sret = sendp(socket, message, length, flags);
213 AFTER_PACK_ORIGINAL_SOCK(API_ID_send,
214 sret, sret, socket, FD_API_SEND,
215 "dpxd", socket, message, length, flags);
220 ssize_t sendmsg(int socket, const struct msghdr *message, int flags)
222 static ssize_t (*sendmsgp)(int socket, const struct msghdr *message, int flags);
225 BEFORE_ORIGINAL(sendmsg, LIBC);
227 sret = sendmsgp(socket, message, flags);
229 AFTER_PACK_ORIGINAL_SOCK(API_ID_sendmsg,
230 sret, sret, socket, FD_API_SEND,
231 "dpd", socket, message, flags);
236 ssize_t sendto(int socket, const void *message, size_t length, int flags,const struct sockaddr *dest_addr, socklen_t dest_len)
238 static ssize_t (*sendtop)(int socket, const void *message, size_t length, int flags,const struct sockaddr *dest_addr, socklen_t dest_len);
241 BEFORE_ORIGINAL(sendto, LIBC);
243 sret = sendtop(socket, message, length, flags, dest_addr, dest_len);
245 AFTER_PACK_ORIGINAL_SOCK(API_ID_sendto,
246 sret, sret, socket, FD_API_SEND,
247 "dpxdpd", socket, message, length, flags, dest_addr, dest_len);
252 ssize_t recv(int socket, void *buffer, size_t length, int flags)
254 static ssize_t (*recvp)(int socket, void *buffer, size_t length, int flags);
257 BEFORE_ORIGINAL(recv, LIBC);
259 sret = recvp(socket, buffer, length, flags);
261 AFTER_PACK_ORIGINAL_SOCK(API_ID_recv,
262 sret, sret, socket, FD_API_RECEIVE,
263 "dpxd", socket, buffer, length, flags);
268 ssize_t recvfrom(int socket, void *buffer, size_t length, int flags, struct sockaddr *address, socklen_t *address_len)
270 static ssize_t (*recvfromp)(int socket, void *buffer, size_t length, int flags, struct sockaddr *address, socklen_t *address_len);
273 BEFORE_ORIGINAL(recvfrom, LIBC);
275 sret = recvfromp(socket, buffer, length, flags, address, address_len);
277 AFTER_PACK_ORIGINAL_SOCK(API_ID_recvfrom,
278 sret, sret, socket, FD_API_RECEIVE,
279 "dpxdpp", socket, buffer, length, flags, address, address_len);
284 ssize_t recvmsg(int socket, struct msghdr *message, int flags)
286 static ssize_t (*recvmsgp)(int socket, struct msghdr *message, int flags);
289 BEFORE_ORIGINAL(recvmsg, LIBC);
291 sret = recvmsgp(socket, message, flags);
293 AFTER_PACK_ORIGINAL_SOCK(API_ID_recvmsg,
294 sret, sret, socket, FD_API_RECEIVE,
295 "dpd", socket, message, flags);
300 uint32_t htonl(uint32_t hostlong)
302 static uint32_t (*htonlp)(uint32_t hostlong);
305 BEFORE_ORIGINAL(htonl, LIBC);
307 uret = htonlp(hostlong);
309 AFTER_PACK_ORIGINAL_SOCK(API_ID_htonl,
310 uret, 0, 0, FD_API_OTHER, "d", hostlong);
315 uint16_t htons(uint16_t hostshort)
317 static uint16_t (*htonsp)(uint16_t hostshort);
320 BEFORE_ORIGINAL(htons, LIBC);
322 uret = htonsp(hostshort);
324 AFTER_PACK_ORIGINAL_SOCK(API_ID_htons,
325 uret, 0, 0, FD_API_OTHER, "d", hostshort);
330 uint32_t ntohl(uint32_t netlong)
332 static uint32_t (*ntohlp)(uint32_t netlong);
335 BEFORE_ORIGINAL(ntohl, LIBC);
337 uret = ntohlp(netlong);
339 AFTER_PACK_ORIGINAL_SOCK(API_ID_ntohl,
340 uret, 0, 0, FD_API_OTHER, "d", netlong);
345 uint16_t ntohs(uint16_t netshort)
347 static uint16_t (*ntohsp)(uint16_t netshort);
350 BEFORE_ORIGINAL(ntohs, LIBC);
352 uret = ntohsp(netshort);
354 AFTER_PACK_ORIGINAL_SOCK(API_ID_ntohs,
355 uret, 0, 0, FD_API_OTHER, "d", netshort);
361 uint16_t htobe16(uint16_t host_16bits)
363 static uint16_t (*htobe16p)(uint16_t host_16bits);
366 BEFORE_ORIGINAL(htobe16, LIBC);
368 uret = htobe16p(host_16bits);
370 AFTER_PACK_ORIGINAL_SOCK(uret, 0, 0, FD_API_OTHER, "d", host_16bits);
375 uint16_t htole16(uint16_t host_16bits)
377 static uint16_t (*htole16p)(uint16_t host_16bits);
380 BEFORE_ORIGINAL(htole16, LIBC);
382 uret = htole16p(host_16bits);
384 AFTER_PACK_ORIGINAL_SOCK(uret, 0, 0, FD_API_OTHER, "d", host_16bits);
389 uint16_t be16toh(uint16_t big_endian_16bits)
391 static uint16_t (*be16tohp)(uint16_t big_endian_16bits);
394 BEFORE_ORIGINAL(be16toh, LIBC);
396 uret = be16tohp(big_endian_16bits);
398 AFTER_PACK_ORIGINAL_SOCK(uret, 0, 0, FD_API_OTHER, "d", big_endian_16bits);
403 uint16_t le16toh(uint16_t little_endian_16bits)
405 static uint16_t (*le16tohp)(uint16_t little_endian_16bits);
408 BEFORE_ORIGINAL(le16toh, LIBC);
410 uret = le16tohp(little_endian_16bits);
412 AFTER_PACK_ORIGINAL_SOCK(uret, 0, 0, FD_API_OTHER, "d", little_endian_16bits);
417 uint32_t htobe32(uint32_t host_32bits)
419 static uint32_t (*htobe32p)(uint32_t host_32bits);
422 BEFORE_ORIGINAL(htobe32, LIBC);
424 uret = htobe32p(host_32bits);
426 AFTER_PACK_ORIGINAL_SOCK(uret, 0, 0, FD_API_OTHER, "d", host_32bits);
431 uint32_t htole32(uint32_t host_32bits)
433 static uint32_t (*htole32p)(uint32_t host_32bits);
436 BEFORE_ORIGINAL(htole32, LIBC);
438 uret = htole32p(host_32bits);
440 AFTER_PACK_ORIGINAL_SOCK(uret, 0, 0, FD_API_OTHER, "d", host_32bits);
445 uint32_t be32toh(uint32_t big_endian_32bits)
447 static uint32_t (*be32tohp)(uint32_t big_endian_32bits);
450 BEFORE_ORIGINAL(be32toh, LIBC);
452 uret = be32tohp(big_endian_32bits);
454 AFTER_PACK_ORIGINAL_SOCK(uret, 0, 0, FD_API_OTHER, "d", big_endian_32bits);
459 uint32_t le32toh(uint32_t little_endian_32bits)
461 static uint32_t (*le32tohp)(uint32_t little_endian_32bits);
464 BEFORE_ORIGINAL(le32toh, LIBC);
466 uret = le32tohp(little_endian_32bits);
468 AFTER_PACK_ORIGINAL_SOCK(API_ID_le32toh,
469 uret, 0, 0, FD_API_OTHER, "d", little_endian_32bits);
474 uint64_t htobe64(uint64_t host_64bits)
476 static uint64_t (*htobe64p)(uint64_t host_64bits);
479 BEFORE_ORIGINAL(htobe64, LIBC);
481 uret = htobe64p(host_64bits);
483 AFTER_PACK_ORIGINAL_SOCK(uret, 0, 0, FD_API_OTHER, "x", host_64bits);
488 uint64_t htole64(uint64_t host_64bits)
490 static uint64_t (*htole64p)(uint64_t host_64bits);
493 BEFORE_ORIGINAL(htole64, LIBC);
495 uret = htole64p(host_64bits);
497 AFTER_PACK_ORIGINAL_SOCK(uret, 0, 0, FD_API_OTHER, "x", host_64bits);
502 uint64_t be64toh(uint64_t big_endian_64bits)
504 static uint64_t (*be64tohp)(uint64_t big_endian_64bits);
507 BEFORE_ORIGINAL(be64toh, LIBC);
509 uret = be64tohp(big_endian_64bits);
511 AFTER_PACK_ORIGINAL_SOCK(uret, 0, 0, FD_API_OTHER, "x", big_endian_64bits);
516 uint64_t le64toh(uint64_t little_endian_64bits)
518 static uint64_t (*le64tohp)(uint64_t little_endian_64bits);
521 BEFORE_ORIGINAL(le64toh, LIBC);
523 uret = le64tohp(little_endian_64bits);
525 AFTER_PACK_ORIGINAL_SOCK(API_ID_le64toh,
526 uret, 0, 0, FD_API_OTHER, "x", little_endian_64bits);
533 int inet_aton(const char *cp, struct in_addr *inp)
535 static int (*inet_atonp)(const char *cp, struct in_addr *inp);
537 BEFORE_ORIGINAL(inet_aton, LIBC);
539 ret = inet_atonp(cp,inp);
541 AFTER_PACK_ORIGINAL_SOCK(API_ID_inet_aton,
542 ret, 0, 0, FD_API_OTHER, "pp", cp, inp);
547 in_addr_t inet_addr(const char *cp)
549 static in_addr_t (*inet_addrp)(const char *cp);
552 BEFORE_ORIGINAL(inet_addr, LIBC);
554 iret = inet_addrp(cp);
556 AFTER_PACK_ORIGINAL_SOCK(API_ID_inet_addr,
557 iret, 0, 0, FD_API_OTHER, "p", cp);
562 in_addr_t inet_network(const char *cp)
564 static in_addr_t (*inet_networkp)(const char *cp);
567 BEFORE_ORIGINAL(inet_network, LIBC);
569 iret = inet_networkp(cp);
571 AFTER_PACK_ORIGINAL_SOCK(API_ID_inet_network,
572 iret, 0, 0, FD_API_OTHER, "p", cp);
577 char *inet_ntoa(struct in_addr in)
579 static char * (*inet_ntoap)(struct in_addr in);
582 BEFORE_ORIGINAL(inet_ntoa, LIBC);
584 sret = inet_ntoap(in);
586 AFTER_PACK_ORIGINAL_SOCK(API_ID_inet_ntoa, sret, 0, 0, FD_API_OTHER, "d", in.s_addr);
592 struct in_addr inet_makeaddr(int net, int host)
594 static struct in_addr (*inet_makeaddrp)(int net, int host);
597 BEFORE_ORIGINAL(inet_makeaddr, LIBC);
599 iret = inet_makeaddrp(net,host);
601 AFTER_PACK_ORIGINAL_SOCK(API_ID_inet_makeaddr,
602 iret.s_addr, 0, 0, FD_API_OTHER,
609 in_addr_t inet_lnaof(struct in_addr in)
611 static in_addr_t (*inet_lnaofp)(struct in_addr in);
614 BEFORE_ORIGINAL(inet_lnaof, LIBC);
616 iret = inet_lnaofp(in);
618 AFTER_PACK_ORIGINAL_SOCK(API_ID_inet_lnaof,
619 iret, 0, 0, FD_API_OTHER, "d", in.s_addr);
624 in_addr_t inet_netof(struct in_addr in)
626 static in_addr_t (*inet_netofp)(struct in_addr in);
629 BEFORE_ORIGINAL(inet_netof, LIBC);
631 iret = inet_netofp(in);
633 AFTER_PACK_ORIGINAL_SOCK(API_ID_inet_netof,
634 iret, 0, 0, FD_API_OTHER, "d", in.s_addr);
639 const char *inet_ntop(int af, const void *src, char *dst, socklen_t size)
641 static const char* (*inet_ntopp)(int af, const void *src, char *dst, socklen_t size);
644 BEFORE_ORIGINAL(inet_ntop, LIBC);
646 cret = inet_ntopp(af, src, dst, size);
648 AFTER_PACK_ORIGINAL_SOCK(API_ID_inet_ntop,
649 cret, size, 0, FD_API_OTHER,
650 "dppd", af, src, dst, size);
655 int inet_pton(int af, const char *src, void *dst)
657 static int (*inet_ptonp)(int af, const char *src, void *dst);
659 BEFORE_ORIGINAL(inet_pton, LIBC);
661 ret = inet_ptonp(af, src, dst);
663 AFTER_PACK_ORIGINAL_SOCK(API_ID_inet_pton,
664 ret, 0, 0, FD_API_OTHER, "%dpp", af, src, dst);
669 int getaddrinfo(const char *node, const char *service, const struct addrinfo *hints, struct addrinfo **res)
671 static int (*getaddrinfop)(const char *node, const char *service, const struct addrinfo *hints, struct addrinfo **res);
673 BEFORE_ORIGINAL_NOFILTER(getaddrinfo, LIBC);
675 ret = getaddrinfop(node, service, hints, res);
677 AFTER_PACK_ORIGINAL_SOCK(API_ID_getaddrinfo,
678 ret, 0, 0, FD_API_OTHER, "pppp", node, service, hints, res);
683 void freeaddrinfo(struct addrinfo *res)
685 static void (*freeaddrinfop)(struct addrinfo *res);
687 BEFORE_ORIGINAL_NOFILTER(freeaddrinfo, LIBC);
691 AFTER_PACK_ORIGINAL_SOCK(API_ID_freeaddrinfo,
692 0, 0, 0, FD_API_OTHER, "p", res);
695 const char *gai_strerror(int errcode)
697 static const char * (*gai_strerrorp)(int errcode);
700 BEFORE_ORIGINAL(gai_strerror, LIBC);
702 cret = gai_strerrorp(errcode);
704 AFTER_PACK_ORIGINAL_SOCK(API_ID_gai_strerror,
705 cret, 0, 0, FD_API_OTHER, "d", errcode);
710 int gai_suspend(const struct gaicb* const list[], int nitems, const struct timespec *timeout)
712 static int (*gai_suspendp)(const struct gaicb* const list[], int nitems, const struct timespec *timeout);
714 BEFORE_ORIGINAL(gai_suspend, LIBC);
716 ret = gai_suspendp(list,nitems,timeout);
718 AFTER_PACK_ORIGINAL_SOCK(API_ID_gai_suspend,
719 ret, 0, 0, FD_API_OTHER, "pdp", list, nitems, timeout);
724 int gai_error(struct gaicb *req)
726 static int (*gai_errorp)(struct gaicb *req);
728 BEFORE_ORIGINAL(gai_error, LIBC);
730 ret = gai_errorp(req);
732 AFTER_PACK_ORIGINAL_SOCK(API_ID_gai_error,
733 ret, 0, 0, FD_API_OTHER, "p", req);
738 int gai_cancel(struct gaicb *req)
740 static int (*gai_cancelp)(struct gaicb *req);
742 BEFORE_ORIGINAL(gai_cancel, LIBC);
744 ret = gai_cancelp(req);
746 AFTER_PACK_ORIGINAL_SOCK(API_ID_gai_cancel,
747 ret, 0, 0, FD_API_OTHER, "p", req);
752 int getaddrinfo_a(int mode, struct gaicb *list[], int nitems, struct sigevent *sevp)
754 static int (*getaddrinfo_ap)(int mode, struct gaicb *list[], int nitems, struct sigevent *sevp);
756 BEFORE_ORIGINAL(getaddrinfo_a, LIBC);
758 ret = getaddrinfo_ap(mode, list,nitems, sevp);
760 AFTER_PACK_ORIGINAL_SOCK(API_ID_getaddrinfo_a,
761 ret, 0, 0, FD_API_OTHER, "dpdp", mode, list, nitems, sevp);
767 int getsockopt(int socket, int level, int option_name, void *option_value, socklen_t *option_len)
769 static int (*getsockoptp)(int socket, int level, int option_name, void *option_value, socklen_t *option_len);
771 BEFORE_ORIGINAL(getsockopt, LIBC);
773 ret = getsockoptp(socket, level, option_name, option_value, option_len);
775 AFTER_PACK_ORIGINAL_SOCK(API_ID_getsockopt,
776 ret, 0, socket, FD_API_OPTION, "dddpp",
777 socket, level, option_name, option_value, option_len);
782 int setsockopt(int socket, int level, int option_name, const void *option_value, socklen_t option_len)
784 static int (*setsockoptp)(int socket, int level, int option_name, const void *option_value, socklen_t option_len);
786 BEFORE_ORIGINAL(setsockopt, LIBC);
788 ret = setsockoptp(socket, level, option_name, option_value, option_len);
790 AFTER_PACK_ORIGINAL_SOCK(API_ID_setsockopt,
791 ret, option_len, socket, FD_API_OPTION, "dddpd",
792 socket, level, option_name, option_value, option_len);
798 int getsockname(int sockfd, struct sockaddr *addr, socklen_t *addrlen )
800 static int (*getsocknamep)(int sockfd, struct sockaddr *addr, socklen_t *addrlen );
802 BEFORE_ORIGINAL(getsockname, LIBC);
804 ret = getsocknamep(sockfd, addr, addrlen);
806 AFTER_PACK_ORIGINAL_SOCK(API_ID_getsockname,
807 ret, 0, sockfd, FD_API_OTHER, "dpp", sockfd, addr, addrlen);
812 int getdomainname(char *name, size_t len)
814 static int (*getdomainnamep)(char *name, size_t len);
816 BEFORE_ORIGINAL(getdomainname, LIBC);
818 ret = getdomainnamep(name, len);
820 AFTER_PACK_ORIGINAL_SOCK(API_ID_getdomainname,
821 ret, len, 0, FD_API_OTHER, "px", name, len);
826 int setdomainname(const char *name, size_t len)
828 static int (*setdomainnamep)(const char *name, size_t len);
830 BEFORE_ORIGINAL(setdomainname, LIBC);
832 ret = setdomainnamep(name, len);
834 AFTER_PACK_ORIGINAL_SOCK(API_ID_setdomainname,
835 ret, len, 0, FD_API_OTHER, "px", name, len);
840 int gethostname(char *name, size_t len)
842 static int (*gethostnamep)(char *name, size_t len);
844 BEFORE_ORIGINAL(gethostname, LIBC);
846 ret = gethostnamep(name, len);
848 AFTER_PACK_ORIGINAL_SOCK(API_ID_gethostname,
849 ret, len, 0, FD_API_OTHER, "px", name, len);
854 int sethostname(const char *name, size_t len)
856 static int (*sethostnamep)(const char *name, size_t len);
858 BEFORE_ORIGINAL(sethostname, LIBC);
860 ret = sethostnamep(name, len);
862 AFTER_PACK_ORIGINAL_SOCK(API_ID_sethostname,
863 ret, len, 0, FD_API_OTHER, "px", name, len);
868 int getpeername(int s, struct sockaddr *addr, socklen_t *len)
870 static int (*getpeernamep)(int s, struct sockaddr *addr, socklen_t *len);
872 BEFORE_ORIGINAL(getpeername, LIBC);
874 ret = getpeernamep(s, addr, len);
876 AFTER_PACK_ORIGINAL_SOCK(API_ID_getpeername,
877 ret, 0, s, FD_API_OTHER, "dpp", s, addr, len);
882 int getnameinfo(const struct sockaddr *sa, socklen_t salen, char *host, socklen_t hostlen, char *serv, socklen_t servlen, unsigned int flags)
884 static int (*getnameinfop)(const struct sockaddr *sa, socklen_t salen, char *host, socklen_t hostlen, char *serv, socklen_t servlen, unsigned int flags);
886 BEFORE_ORIGINAL(getnameinfo, LIBC);
888 ret = getnameinfop(sa, salen,host, hostlen, serv, servlen, flags);
890 AFTER_PACK_ORIGINAL_SOCK(API_ID_getnameinfo,
891 ret, 0, 0, FD_API_OTHER, "pdpdpdd",
892 sa, salen, host, hostlen, serv, servlen, flags);
897 struct hostent *gethostbyname(const char *name)
899 static struct hostent * (*gethostbynamep)(const char *name);
900 struct hostent* pret;
902 BEFORE_ORIGINAL(gethostbyname, LIBC);
904 pret = gethostbynamep(name);
906 AFTER_PACK_ORIGINAL_SOCK(API_ID_gethostbyname,
907 pret, 0, 0, FD_API_OTHER, "p", name);
912 struct hostent *gethostbyaddr(const void *addr, socklen_t len, int type)
914 static struct hostent * (*gethostbyaddrp)(const void *addr, socklen_t len, int type);
915 struct hostent* pret;
917 BEFORE_ORIGINAL(gethostbyaddr, LIBC);
919 pret = gethostbyaddrp(addr, len, type);
921 AFTER_PACK_ORIGINAL_SOCK(API_ID_gethostbyaddr,
922 pret, 0, 0, FD_API_OTHER, "pdd", addr, len, type);
927 void sethostent(int stayopen)
929 static void (*sethostentp)(int stayopen);
931 BEFORE_ORIGINAL(sethostent, LIBC);
933 sethostentp(stayopen);
935 AFTER_PACK_ORIGINAL_SOCK(API_ID_sethostent,
936 0, 0, 0, FD_API_OTHER, "d", stayopen);
939 void endhostent(void)
941 static void (*endhostentp)(void);
943 BEFORE_ORIGINAL(endhostent, LIBC);
947 AFTER_PACK_ORIGINAL_SOCK(API_ID_endhostent,
948 0, 0, 0, FD_API_OTHER, "", 0);
951 void herror(const char *s)
953 static void (*herrorp)(const char *s);
955 BEFORE_ORIGINAL(herror, LIBC);
959 AFTER_PACK_ORIGINAL_SOCK(API_ID_herror,
960 0, 0, 0, FD_API_OTHER, "p", s);
963 const char *hstrerror(int err)
965 static const char* (*hstrerrorp)(int err);
968 BEFORE_ORIGINAL(hstrerror, LIBC);
970 cret = hstrerrorp(err);
972 AFTER_PACK_ORIGINAL_SOCK(API_ID_hstrerror,
973 cret, 0, 0, FD_API_OTHER, "d", err);
978 struct hostent *gethostent(void)
980 static struct hostent* (*gethostentp)(void);
981 struct hostent* pret;
983 BEFORE_ORIGINAL(gethostent, LIBC);
985 pret = gethostentp();
987 AFTER_PACK_ORIGINAL_SOCK(API_ID_gethostent,
988 pret, 0, 0, FD_API_OTHER, "", 0);
993 struct hostent *gethostbyname2(const char *name, int af)
995 static struct hostent * (*gethostbyname2p)(const char *name, int af);
996 struct hostent* pret;
998 BEFORE_ORIGINAL(gethostbyname2, LIBC);
1000 pret = gethostbyname2p(name, af);
1002 AFTER_PACK_ORIGINAL_SOCK(API_ID_gethostbyname2,
1003 pret, 0, 0, FD_API_OTHER, "pd", name, af);
1008 int gethostent_r(struct hostent *rret, char *buf, size_t buflen, struct hostent **result, int *h_errnop)
1010 static int (*gethostent_rp)(struct hostent *rret, char *buf, size_t buflen, struct hostent **result, int *h_errnop);
1012 BEFORE_ORIGINAL(gethostent_r, LIBC);
1014 ret = gethostent_rp(rret, buf, buflen, result, h_errnop);
1016 AFTER_PACK_ORIGINAL_SOCK(API_ID_gethostent_r,
1017 ret, 0, 0, FD_API_OTHER, "ppxpp",
1018 rret, buf, buflen, result, h_errnop);
1023 int gethostbyaddr_r(const void *addr, socklen_t len, int type, struct hostent *rret, char *buf, size_t buflen, struct hostent **result, int *h_errnop)
1025 static int (*gethostbyaddr_rp)(const void *addr, socklen_t len, int type, struct hostent *rret, char *buf, size_t buflen, struct hostent **result, int *h_errnop);
1027 BEFORE_ORIGINAL(gethostbyaddr_r, LIBC);
1029 ret = gethostbyaddr_rp(addr, len, type, rret, buf, buflen, result, h_errnop);
1031 AFTER_PACK_ORIGINAL_SOCK(API_ID_gethostbyaddr_r,
1032 ret, 0, 0, FD_API_OTHER, "pddppxpp",
1033 addr, len, type, rret, buf, buflen, result, h_errnop);
1038 int gethostbyname_r(const char *name, struct hostent *rret, char *buf, size_t buflen, struct hostent **result, int *h_errnop)
1040 static int (*gethostbyname_rp)(const char *name, struct hostent *rret, char *buf, size_t buflen, struct hostent **result, int *h_errnop);
1042 BEFORE_ORIGINAL(gethostbyname_r, LIBC);
1044 ret = gethostbyname_rp(name, rret, buf, buflen, result, h_errnop);
1046 AFTER_PACK_ORIGINAL_SOCK(API_ID_gethostbyname_r,
1047 ret, 0, 0, FD_API_OTHER, "pppxpp",
1048 name, rret, buf, buflen, result, h_errnop);
1053 int gethostbyname2_r(const char *name, int af, struct hostent *rret, char *buf, size_t buflen, struct hostent **result, int *h_errnop)
1055 static int (*gethostbyname2_rp)(const char *name, int af, struct hostent *rret, char *buf, size_t buflen, struct hostent **result, int *h_errnop);
1057 BEFORE_ORIGINAL(gethostbyname2_r, LIBC);
1059 ret = gethostbyname2_rp(name, af, rret, buf, buflen, result, h_errnop);
1061 AFTER_PACK_ORIGINAL_SOCK(API_ID_gethostbyname2_r,
1062 ret, 0, 0, FD_API_OTHER, "pdppxpp",
1063 name, af, rret, buf, buflen, result, h_errnop);
1068 struct servent *getservbyname(const char *name, const char *proto)
1070 static struct servent * (*getservbynamep)(const char *name, const char *proto);
1071 struct servent* pret;
1073 BEFORE_ORIGINAL(getservbyname, LIBC);
1075 pret = getservbynamep(name, proto);
1077 AFTER_PACK_ORIGINAL_SOCK(API_ID_getservbyname,
1078 pret, 0, 0, FD_API_OTHER, "pp", name, proto);
1083 void setservent(int stayopen)
1085 static void (*setserventp)(int stayopen);
1087 BEFORE_ORIGINAL(setservent, LIBC);
1089 setserventp(stayopen);
1091 AFTER_PACK_ORIGINAL_SOCK(API_ID_setservent,
1092 0, 0, 0, FD_API_OTHER, "d", stayopen);
1095 void endservent(void)
1097 static void (*endserventp)(void);
1099 BEFORE_ORIGINAL(endservent, LIBC);
1103 AFTER_PACK_ORIGINAL_SOCK(API_ID_endservent,
1104 0, 0, 0, FD_API_OTHER, "", 0);
1107 struct servent *getservent(void)
1109 static struct servent * (*getserventp)(void);
1110 struct servent* pret;
1112 BEFORE_ORIGINAL(getservent, LIBC);
1114 pret = getserventp();
1116 AFTER_PACK_ORIGINAL_SOCK(API_ID_getservent,
1117 pret, 0, 0, FD_API_OTHER, "", 0);
1122 struct servent *getservbyport(int port, const char *proto)
1124 static struct servent * (*getservbyportp)(int port, const char *proto);
1125 struct servent* pret;
1127 BEFORE_ORIGINAL(getservbyport, LIBC);
1129 pret = getservbyportp(port, proto);
1131 AFTER_PACK_ORIGINAL_SOCK(API_ID_getservbyport,
1132 pret, 0, 0, FD_API_OTHER, "dp", port, proto);
1137 int getservent_r(struct servent *result_buf, char *buf, size_t buflen, struct servent **result)
1139 static int (*getservent_rp)(struct servent *result_buf, char *buf, size_t buflen, struct servent **result);
1141 BEFORE_ORIGINAL(getservent_r, LIBC);
1143 ret = getservent_rp(result_buf, buf, buflen, result);
1145 AFTER_PACK_ORIGINAL_SOCK(API_ID_getservent_r,
1146 ret, 0, 0, FD_API_OTHER, "ppxp",
1147 result_buf, buf, buflen, result);
1152 int getservbyname_r(const char *name, const char *proto, struct servent *result_buf, char *buf, size_t buflen, struct servent **result)
1154 static int (*getservbyname_rp)(const char *name, const char *proto, struct servent *result_buf, char *buf, size_t buflen, struct servent **result);
1156 BEFORE_ORIGINAL(getservbyname_r, LIBC);
1158 ret = getservbyname_rp(name, proto, result_buf, buf, buflen, result);
1160 AFTER_PACK_ORIGINAL_SOCK(API_ID_getservbyname_r,
1161 ret, 0, 0, FD_API_OTHER, "ppppxp",
1162 name, proto, result_buf, buf, buflen, result);
1167 int getservbyport_r(int port, const char *proto, struct servent *result_buf, char *buf, size_t buflen, struct servent **result)
1169 static int (*getservbyport_rp)(int port, const char *proto, struct servent *result_buf, char *buf, size_t buflen, struct servent **result);
1171 BEFORE_ORIGINAL(getservbyport_r, LIBC);
1173 ret = getservbyport_rp(port, proto, result_buf, buf, buflen, result);
1175 AFTER_PACK_ORIGINAL_SOCK(API_ID_getservbyport_r,
1176 ret, 0, 0, FD_API_OTHER, "dpppxp",
1177 port, proto, result_buf, buf, buflen, result);
1182 struct netent* getnetent(void)
1184 static struct netent * (*getnetentp)(void);
1185 struct netent* pret;
1187 BEFORE_ORIGINAL(getnetent, LIBC);
1189 pret = getnetentp();
1191 AFTER_PACK_ORIGINAL_SOCK(API_ID_getnetent,
1192 pret, 0, 0, FD_API_OTHER, "", 0);
1197 struct netent *getnetbyname(const char *name)
1199 static struct netent * (*getnetbynamep)(const char *name);
1200 struct netent* pret;
1202 BEFORE_ORIGINAL(getnetbyname, LIBC);
1204 pret = getnetbynamep(name);
1206 AFTER_PACK_ORIGINAL_SOCK(API_ID_getnetbyname,
1207 pret, 0, 0, FD_API_OTHER, "p", name);
1212 struct netent *getnetbyaddr(uint32_t net, int type)
1214 static struct netent * (*getnetbyaddrp)(uint32_t net, int type);
1215 struct netent * pret;
1217 BEFORE_ORIGINAL(getnetbyaddr, LIBC);
1219 pret = getnetbyaddrp(net, type);
1221 AFTER_PACK_ORIGINAL_SOCK(API_ID_getnetbyaddr,
1222 pret, 0, 0, FD_API_OTHER, "dd", net, type);
1227 void setnetent(int stayopen)
1229 static void (*setnetentp)(int stayopen);
1231 BEFORE_ORIGINAL(setnetent, LIBC);
1233 setnetentp(stayopen);
1235 AFTER_PACK_ORIGINAL_SOCK(API_ID_setnetent,
1236 0, 0, 0, FD_API_OTHER, "d", stayopen);
1239 void endnetent(void)
1241 static void (*endnetentp)(void);
1243 BEFORE_ORIGINAL(endnetent, LIBC);
1247 AFTER_PACK_ORIGINAL_SOCK(API_ID_endnetent,
1248 0, 0, 0, FD_API_OTHER, "", 0);
1251 int getnetent_r(struct netent *result_buf, char *buf, size_t buflen, struct netent **result, int *h_errnop)
1253 static int (*getnetent_rp)(struct netent *result_buf, char *buf, size_t buflen, struct netent **result, int *h_errnop);
1255 BEFORE_ORIGINAL(getnetent_r, LIBC);
1257 ret = getnetent_rp(result_buf, buf, buflen, result, h_errnop);
1259 AFTER_PACK_ORIGINAL_SOCK(API_ID_getnetent_r,
1260 ret, 0, 0, FD_API_OTHER, "ppxpp",
1261 result_buf, buf, buflen, result, h_errnop);
1266 int getnetbyname_r(const char *name, struct netent *result_buf, char *buf, size_t buflen, struct netent **result, int *h_errnop)
1268 static int (*getnetbyname_rp)(const char *name, struct netent *result_buf, char *buf, size_t buflen, struct netent **result, int *h_errnop);
1270 BEFORE_ORIGINAL(getnetbyname_r, LIBC);
1272 ret = getnetbyname_rp(name,result_buf, buf, buflen, result, h_errnop);
1274 AFTER_PACK_ORIGINAL_SOCK(API_ID_getnetbyname_r,
1275 ret, 0, 0, FD_API_OTHER, "pppxpp",
1276 name, result_buf, buf, buflen, result, h_errnop);
1281 int getnetbyaddr_r(uint32_t net, int type, struct netent *result_buf, char *buf, size_t buflen, struct netent **result, int *h_errnop)
1283 static int (*getnetbyaddr_rp)(uint32_t net, int type, struct netent *result_buf, char *buf, size_t buflen, struct netent **result, int *h_errnop);
1285 BEFORE_ORIGINAL(getnetbyaddr_r, LIBC);
1287 ret = getnetbyaddr_rp(net, type, result_buf, buf, buflen, result, h_errnop);
1289 AFTER_PACK_ORIGINAL_SOCK(API_ID_getnetbyaddr_r,
1290 ret, 0, 0, FD_API_OTHER, "ddppxpp",
1291 net, type, result_buf, buf, buflen, result, h_errnop);
1296 struct protoent *getprotoent(void)
1298 static struct protoent * (*getprotoentp)(void);
1299 struct protoent * pret;
1301 BEFORE_ORIGINAL(getprotoent, LIBC);
1303 pret = getprotoentp();
1305 AFTER_PACK_ORIGINAL_SOCK(API_ID_getprotoent,
1306 pret, 0, 0, FD_API_OTHER, "", 0);
1311 struct protoent *getprotobyname(const char *name)
1313 static struct protoent * (*getprotobynamep)(const char *name);
1314 struct protoent * pret;
1316 BEFORE_ORIGINAL(getprotobyname, LIBC);
1318 pret = getprotobynamep(name);
1320 AFTER_PACK_ORIGINAL_SOCK(API_ID_getprotobyname,
1321 pret, 0, 0, FD_API_OTHER, "p", name);
1326 struct protoent *getprotobynumber(int proto)
1328 static struct protoent * (*getprotobynumberp)(int proto);
1329 struct protoent * pret;
1331 BEFORE_ORIGINAL(getprotobynumber, LIBC);
1333 pret = getprotobynumberp(proto);
1335 AFTER_PACK_ORIGINAL_SOCK(API_ID_getprotobynumber,
1336 pret, 0, 0, FD_API_OTHER, "d", proto);
1341 void setprotoent(int stayopen)
1343 static void (*setprotoentp)(int stayopen);
1345 BEFORE_ORIGINAL(setprotoent, LIBC);
1347 setprotoentp(stayopen);
1349 AFTER_PACK_ORIGINAL_SOCK(API_ID_setprotoent,
1350 0, 0, 0, FD_API_OTHER, "d", stayopen);
1353 void endprotoent(void)
1355 static void (*endprotoentp)(void);
1357 BEFORE_ORIGINAL(endprotoent, LIBC);
1361 AFTER_PACK_ORIGINAL_SOCK(API_ID_endprotoent,
1362 0, 0, 0, FD_API_OTHER, "", 0);
1365 int getprotoent_r(struct protoent *result_buf, char *buf, size_t buflen, struct protoent **result)
1367 static int (*getprotoent_rp)(struct protoent *result_buf, char *buf, size_t buflen, struct protoent **result);
1369 BEFORE_ORIGINAL(getprotoent_r, LIBC);
1371 ret = getprotoent_rp(result_buf, buf, buflen, result);
1373 AFTER_PACK_ORIGINAL_SOCK(API_ID_getprotoent_r,
1374 ret, 0, 0, FD_API_OTHER, "ppxp",
1375 result_buf, buf, buflen, result);
1380 int getprotobyname_r(const char *name, struct protoent *result_buf, char *buf, size_t buflen, struct protoent **result)
1382 static int (*getprotobyname_rp)(const char *name, struct protoent *result_buf, char *buf, size_t buflen, struct protoent **result);
1384 BEFORE_ORIGINAL(getprotobyname_r, LIBC);
1386 ret = getprotobyname_rp(name, result_buf, buf, buflen, result);
1388 AFTER_PACK_ORIGINAL_SOCK(API_ID_getprotobyname_r,
1389 ret, 0, 0, FD_API_OTHER, "pppxp",
1390 name, result_buf, buf, buflen, result);
1395 int getprotobynumber_r(int proto, struct protoent *result_buf, char *buf, size_t buflen, struct protoent **result)
1397 static int (*getprotobynumber_rp)(int proto, struct protoent *result_buf, char *buf, size_t buflen, struct protoent **result);
1399 BEFORE_ORIGINAL(getprotobynumber_r, LIBC);
1401 ret = getprotobynumber_rp(proto, result_buf, buf, buflen, result);
1403 AFTER_PACK_ORIGINAL_SOCK(API_ID_getprotobynumber_r,
1404 ret, 0, 0, FD_API_OTHER, "dppxp",
1405 proto, result_buf, buf, buflen, result);
1410 unsigned int if_nametoindex (__const char *__ifname)
1412 static unsigned int (*if_nametoindexp)(__const char *__ifname);
1415 BEFORE_ORIGINAL(if_nametoindex, LIBC);
1417 uret = if_nametoindexp(__ifname);
1419 AFTER_PACK_ORIGINAL_SOCK(API_ID_if_nametoindex,
1420 uret, 0, 0, FD_API_OTHER, "p", __ifname);
1425 char *if_indextoname (unsigned int __ifindex, char *__ifname)
1427 static char * (*if_indextonamep)(unsigned int __ifindex, char *__ifname);
1430 BEFORE_ORIGINAL(if_indextoname, LIBC);
1432 cret = if_indextonamep(__ifindex, __ifname);
1434 AFTER_PACK_ORIGINAL_SOCK(API_ID_if_indextoname,
1435 cret, 0, 0, FD_API_OTHER,
1436 "dp", __ifindex, __ifname);
1441 struct if_nameindex *if_nameindex (void)
1443 static struct if_nameindex * (*if_nameindexp)(void);
1444 struct if_nameindex * pret;
1446 BEFORE_ORIGINAL_NOFILTER(if_nameindex, LIBC);
1448 pret = if_nameindexp();
1450 AFTER_PACK_ORIGINAL_SOCK(API_ID_if_nameindex,
1451 pret, 0, 0, FD_API_OTHER, "", 0);
1456 void if_freenameindex (struct if_nameindex *__ptr)
1458 static void (*if_freenameindexp)(struct if_nameindex *__ptr);
1460 BEFORE_ORIGINAL_NOFILTER(if_freenameindex, LIBC);
1462 if_freenameindexp(__ptr);
1464 AFTER_PACK_ORIGINAL_SOCK(API_ID_if_freenameindex,
1465 0, 0, 0, FD_API_OTHER, "p", __ptr);
1468 int getifaddrs(struct ifaddrs **ifap)
1470 static int (*getifaddrsp)(struct ifaddrs **ifap);
1472 BEFORE_ORIGINAL_NOFILTER(getifaddrs, LIBC);
1474 ret = getifaddrsp(ifap);
1476 AFTER_PACK_ORIGINAL_SOCK(API_ID_getifaddrs,
1477 ret, 0, 0, FD_API_OTHER, "p", ifap);
1482 void freeifaddrs(struct ifaddrs *ifa)
1484 static void (*freeifaddrsp)(struct ifaddrs *ifa);
1486 BEFORE_ORIGINAL_NOFILTER(freeifaddrs, LIBC);
1490 AFTER_PACK_ORIGINAL_SOCK(API_ID_freeifaddrs,
1491 0, 0, 0, FD_API_OTHER, "p", ifa);
1495 int poll(struct pollfd *ufds, unsigned int nfds, int timeout)
1497 static int (*pollp)(struct pollfd *ufds, unsigned int nfds, int timeout);
1499 BEFORE_ORIGINAL(poll, LIBC);
1501 ret = pollp(ufds, nfds, timeout);
1503 AFTER_PACK_ORIGINAL_SOCK(ret, timeout, 0, FD_API_OTHER, "pdd", ufds, nfds, timeout);
1508 int ppoll(struct pollfd *fds, nfds_t nfds, const struct timespec *timeout_ts, const sigset_t *sigmask)
1510 static int (*ppollp)(struct pollfd *fds, nfds_t nfds, const struct timespec *timeout_ts, const sigset_t *sigmask);
1512 BEFORE_ORIGINAL(ppoll, LIBC);
1514 ret = ppollp(fds, nfds, timeout_ts, sigmask);
1516 AFTER_PACK_ORIGINAL_SOCK(ret, 0, 0, FD_API_OTHER, "pxpp",
1517 fds, nfds, timeout_ts, sigmask);