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"
55 #define GCC_VERSION (__GNUC__ * 10000 \
56 + __GNUC__MINOR__ * 100 \
57 + __GNUC_PATCHLEVEL__ )
60 static enum DaOptions _sopt = OPT_FILE;
62 int socket(int domain, int type, int protocol)
64 static int (*socketp)(int domain, int type, int protocol);
66 BEFORE_ORIGINAL_NOFILTER(socket, LIBC);
68 ret = socketp(domain, type, protocol);
70 AFTER_PACK_ORIGINAL_SOCK(API_ID_socket,
71 ret, 0, ret, FD_API_OPEN, "ddd", domain, type, protocol);
76 int socketpair(int domain, int type, int protocol,int socket_vector[2])
78 static int (*socketpairp)(int domain, int type, int protocol,int socket_vector[2]);
80 BEFORE_ORIGINAL_NOFILTER(socketpair, LIBC);
82 ret = socketpairp(domain, type, protocol, socket_vector);
84 //TODO: socket pair: socket_vector[0]/socket_vector[1], FD - ?
85 AFTER_PACK_ORIGINAL_SOCK(API_ID_socketpair,
86 ret, 0, socket_vector[0], FD_API_OPEN,
87 "dddp", domain, type, protocol, socket_vector);
92 int shutdown(int socket, int how)
94 static int (*shutdownp)(int socket, int how);
96 BEFORE_ORIGINAL_NOFILTER(shutdown, LIBC);
98 ret = shutdownp(socket, how);
100 AFTER_PACK_ORIGINAL_SOCK(API_ID_shutdown,
101 ret, 0, socket, FD_API_OTHER, "dd", socket, how);
106 int bind(int socket, const struct sockaddr *address, socklen_t address_len)
108 static int (*bindp)(int socket, const struct sockaddr *address, socklen_t address_len);
110 BEFORE_ORIGINAL(bind, LIBC);
112 ret = bindp(socket, address, address_len);
114 AFTER_PACK_ORIGINAL_SOCK(API_ID_bind,
115 ret, 0, socket, FD_API_MANAGE,
116 "dpd", socket, address, address_len);
121 int listen(int socket, int backlog)
123 static int (*listenp)(int socket, int backlog);
125 BEFORE_ORIGINAL(listen, LIBC);
127 ret = listenp(socket, backlog);
129 AFTER_PACK_ORIGINAL_SOCK(API_ID_listen,
130 ret, 0, socket, FD_API_MANAGE, "dd", socket, backlog);
135 int accept(int socket, struct sockaddr *address, socklen_t *address_len)
137 static int (*acceptp)(int socket, struct sockaddr *address, socklen_t *address_len);
139 BEFORE_ORIGINAL_NOFILTER(accept, LIBC);
141 ret = acceptp(socket, address, address_len);
143 AFTER_PACK_ORIGINAL_SOCK(API_ID_accept,
144 ret, 0, socket, FD_API_MANAGE,
145 "dpp", socket, address, address_len);
150 int accept4(int sockfd, struct sockaddr *addr, socklen_t *addrlen, int flags)
152 static int (*accept4p)(int sockfd, struct sockaddr *addr, socklen_t *addrlen, int flags);
154 BEFORE_ORIGINAL_NOFILTER(accept4, LIBC);
156 ret = accept4p(sockfd, addr, addrlen, flags);
158 AFTER_PACK_ORIGINAL_SOCK(API_ID_accept4,
159 ret, 0, sockfd, FD_API_MANAGE,
160 "dppd", sockfd, addr, addrlen, flags);
165 int connect(int socket, const struct sockaddr *address, socklen_t address_len)
167 static int (*connectp)(int socket, const struct sockaddr *address, socklen_t address_len);
169 BEFORE_ORIGINAL(connect, LIBC);
171 ret = connectp(socket, address, address_len);
173 AFTER_PACK_ORIGINAL_SOCK(API_ID_connect,
174 ret, address_len, socket, FD_API_MANAGE,
175 "dpd", socket, address, address_len);
180 int select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct timeval *timeout)
182 static int (*selectp)(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct timeval *timeout);
184 BEFORE_ORIGINAL(select, LIBC);
186 ret = selectp(nfds, readfds, writefds,exceptfds, timeout);
188 AFTER_PACK_ORIGINAL_SOCK(API_ID_select,
189 ret, 0, nfds, FD_API_MANAGE,
190 "dpppp", nfds, readfds, writefds, exceptfds, timeout);
195 int pselect(int nfds, fd_set *readfds, fd_set *writefds,fd_set *exceptfds, const struct timespec *ntimeout, const sigset_t *sigmask)
197 static int (*pselectp)(int nfds, fd_set *readfds, fd_set *writefds,fd_set *exceptfds, const struct timespec *ntimeout, const sigset_t *sigmask);
199 BEFORE_ORIGINAL(pselect, LIBC);
201 ret = pselectp(nfds, readfds, writefds,exceptfds, ntimeout, sigmask);
203 AFTER_PACK_ORIGINAL_SOCK(API_ID_pselect,
204 ret, 0, nfds, FD_API_MANAGE, "dppppp",
205 nfds, readfds, writefds, exceptfds, ntimeout, sigmask);
210 ssize_t send(int socket, const void *message, size_t length, int flags)
212 static ssize_t (*sendp)(int socket, const void *message, size_t length, int flags);
215 BEFORE_ORIGINAL(send, LIBC);
217 sret = sendp(socket, message, length, flags);
219 AFTER_PACK_ORIGINAL_SOCK(API_ID_send,
220 sret, sret, socket, FD_API_SEND,
221 "dpxd", socket, message, length, flags);
226 ssize_t sendmsg(int socket, const struct msghdr *message, int flags)
228 static ssize_t (*sendmsgp)(int socket, const struct msghdr *message, int flags);
231 BEFORE_ORIGINAL(sendmsg, LIBC);
233 sret = sendmsgp(socket, message, flags);
235 AFTER_PACK_ORIGINAL_SOCK(API_ID_sendmsg,
236 sret, sret, socket, FD_API_SEND,
237 "dpd", socket, message, flags);
242 ssize_t sendto(int socket, const void *message, size_t length, int flags,const struct sockaddr *dest_addr, socklen_t dest_len)
244 static ssize_t (*sendtop)(int socket, const void *message, size_t length, int flags,const struct sockaddr *dest_addr, socklen_t dest_len);
247 BEFORE_ORIGINAL(sendto, LIBC);
249 sret = sendtop(socket, message, length, flags, dest_addr, dest_len);
251 AFTER_PACK_ORIGINAL_SOCK(API_ID_sendto,
252 sret, sret, socket, FD_API_SEND,
253 "dpxdpd", socket, message, length, flags, dest_addr, dest_len);
258 ssize_t recv(int socket, void *buffer, size_t length, int flags)
260 static ssize_t (*recvp)(int socket, void *buffer, size_t length, int flags);
263 BEFORE_ORIGINAL(recv, LIBC);
265 sret = recvp(socket, buffer, length, flags);
267 AFTER_PACK_ORIGINAL_SOCK(API_ID_recv,
268 sret, sret, socket, FD_API_RECEIVE,
269 "dpxd", socket, buffer, length, flags);
274 ssize_t recvfrom(int socket, void *buffer, size_t length, int flags, struct sockaddr *address, socklen_t *address_len)
276 static ssize_t (*recvfromp)(int socket, void *buffer, size_t length, int flags, struct sockaddr *address, socklen_t *address_len);
279 BEFORE_ORIGINAL(recvfrom, LIBC);
281 sret = recvfromp(socket, buffer, length, flags, address, address_len);
283 AFTER_PACK_ORIGINAL_SOCK(API_ID_recvfrom,
284 sret, sret, socket, FD_API_RECEIVE,
285 "dpxdpp", socket, buffer, length, flags, address, address_len);
290 ssize_t recvmsg(int socket, struct msghdr *message, int flags)
292 static ssize_t (*recvmsgp)(int socket, struct msghdr *message, int flags);
295 BEFORE_ORIGINAL(recvmsg, LIBC);
297 sret = recvmsgp(socket, message, flags);
299 AFTER_PACK_ORIGINAL_SOCK(API_ID_recvmsg,
300 sret, sret, socket, FD_API_RECEIVE,
301 "dpd", socket, message, flags);
306 uint32_t htonl(uint32_t hostlong)
308 static uint32_t (*htonlp)(uint32_t hostlong);
311 BEFORE_ORIGINAL(htonl, LIBC);
313 uret = htonlp(hostlong);
315 AFTER_PACK_ORIGINAL_SOCK(API_ID_htonl,
316 uret, 0, 0, FD_API_OTHER, "d", hostlong);
321 uint16_t htons(uint16_t hostshort)
323 static uint16_t (*htonsp)(uint16_t hostshort);
326 BEFORE_ORIGINAL(htons, LIBC);
328 uret = htonsp(hostshort);
330 AFTER_PACK_ORIGINAL_SOCK(API_ID_htons,
331 uret, 0, 0, FD_API_OTHER, "d", hostshort);
336 uint32_t ntohl(uint32_t netlong)
338 static uint32_t (*ntohlp)(uint32_t netlong);
341 BEFORE_ORIGINAL(ntohl, LIBC);
343 uret = ntohlp(netlong);
345 AFTER_PACK_ORIGINAL_SOCK(API_ID_ntohl,
346 uret, 0, 0, FD_API_OTHER, "d", netlong);
351 uint16_t ntohs(uint16_t netshort)
353 static uint16_t (*ntohsp)(uint16_t netshort);
356 BEFORE_ORIGINAL(ntohs, LIBC);
358 uret = ntohsp(netshort);
360 AFTER_PACK_ORIGINAL_SOCK(API_ID_ntohs,
361 uret, 0, 0, FD_API_OTHER, "d", netshort);
367 uint16_t htobe16(uint16_t host_16bits)
369 static uint16_t (*htobe16p)(uint16_t host_16bits);
372 BEFORE_ORIGINAL(htobe16, LIBC);
374 uret = htobe16p(host_16bits);
376 AFTER_PACK_ORIGINAL_SOCK(uret, 0, 0, FD_API_OTHER, "d", host_16bits);
381 uint16_t htole16(uint16_t host_16bits)
383 static uint16_t (*htole16p)(uint16_t host_16bits);
386 BEFORE_ORIGINAL(htole16, LIBC);
388 uret = htole16p(host_16bits);
390 AFTER_PACK_ORIGINAL_SOCK(uret, 0, 0, FD_API_OTHER, "d", host_16bits);
395 uint16_t be16toh(uint16_t big_endian_16bits)
397 static uint16_t (*be16tohp)(uint16_t big_endian_16bits);
400 BEFORE_ORIGINAL(be16toh, LIBC);
402 uret = be16tohp(big_endian_16bits);
404 AFTER_PACK_ORIGINAL_SOCK(uret, 0, 0, FD_API_OTHER, "d", big_endian_16bits);
409 uint16_t le16toh(uint16_t little_endian_16bits)
411 static uint16_t (*le16tohp)(uint16_t little_endian_16bits);
414 BEFORE_ORIGINAL(le16toh, LIBC);
416 uret = le16tohp(little_endian_16bits);
418 AFTER_PACK_ORIGINAL_SOCK(uret, 0, 0, FD_API_OTHER, "d", little_endian_16bits);
423 uint32_t htobe32(uint32_t host_32bits)
425 static uint32_t (*htobe32p)(uint32_t host_32bits);
428 BEFORE_ORIGINAL(htobe32, LIBC);
430 uret = htobe32p(host_32bits);
432 AFTER_PACK_ORIGINAL_SOCK(uret, 0, 0, FD_API_OTHER, "d", host_32bits);
437 uint32_t htole32(uint32_t host_32bits)
439 static uint32_t (*htole32p)(uint32_t host_32bits);
442 BEFORE_ORIGINAL(htole32, LIBC);
444 uret = htole32p(host_32bits);
446 AFTER_PACK_ORIGINAL_SOCK(uret, 0, 0, FD_API_OTHER, "d", host_32bits);
451 uint32_t be32toh(uint32_t big_endian_32bits)
453 static uint32_t (*be32tohp)(uint32_t big_endian_32bits);
456 BEFORE_ORIGINAL(be32toh, LIBC);
458 uret = be32tohp(big_endian_32bits);
460 AFTER_PACK_ORIGINAL_SOCK(uret, 0, 0, FD_API_OTHER, "d", big_endian_32bits);
465 uint32_t le32toh(uint32_t little_endian_32bits)
467 static uint32_t (*le32tohp)(uint32_t little_endian_32bits);
470 BEFORE_ORIGINAL(le32toh, LIBC);
472 uret = le32tohp(little_endian_32bits);
474 AFTER_PACK_ORIGINAL_SOCK(API_ID_le32toh,
475 uret, 0, 0, FD_API_OTHER, "d", little_endian_32bits);
480 uint64_t htobe64(uint64_t host_64bits)
482 static uint64_t (*htobe64p)(uint64_t host_64bits);
485 BEFORE_ORIGINAL(htobe64, LIBC);
487 uret = htobe64p(host_64bits);
489 AFTER_PACK_ORIGINAL_SOCK(uret, 0, 0, FD_API_OTHER, "x", host_64bits);
494 uint64_t htole64(uint64_t host_64bits)
496 static uint64_t (*htole64p)(uint64_t host_64bits);
499 BEFORE_ORIGINAL(htole64, LIBC);
501 uret = htole64p(host_64bits);
503 AFTER_PACK_ORIGINAL_SOCK(uret, 0, 0, FD_API_OTHER, "x", host_64bits);
508 uint64_t be64toh(uint64_t big_endian_64bits)
510 static uint64_t (*be64tohp)(uint64_t big_endian_64bits);
513 BEFORE_ORIGINAL(be64toh, LIBC);
515 uret = be64tohp(big_endian_64bits);
517 AFTER_PACK_ORIGINAL_SOCK(uret, 0, 0, FD_API_OTHER, "x", big_endian_64bits);
522 uint64_t le64toh(uint64_t little_endian_64bits)
524 static uint64_t (*le64tohp)(uint64_t little_endian_64bits);
527 BEFORE_ORIGINAL(le64toh, LIBC);
529 uret = le64tohp(little_endian_64bits);
531 AFTER_PACK_ORIGINAL_SOCK(API_ID_le64toh,
532 uret, 0, 0, FD_API_OTHER, "x", little_endian_64bits);
539 int inet_aton(const char *cp, struct in_addr *inp)
541 static int (*inet_atonp)(const char *cp, struct in_addr *inp);
543 BEFORE_ORIGINAL(inet_aton, LIBC);
545 ret = inet_atonp(cp,inp);
547 AFTER_PACK_ORIGINAL_SOCK(API_ID_inet_aton,
548 ret, 0, 0, FD_API_OTHER, "pp", cp, inp);
553 in_addr_t inet_addr(const char *cp)
555 static in_addr_t (*inet_addrp)(const char *cp);
558 BEFORE_ORIGINAL(inet_addr, LIBC);
560 iret = inet_addrp(cp);
562 AFTER_PACK_ORIGINAL_SOCK(API_ID_inet_addr,
563 iret, 0, 0, FD_API_OTHER, "p", cp);
568 in_addr_t inet_network(const char *cp)
570 static in_addr_t (*inet_networkp)(const char *cp);
573 BEFORE_ORIGINAL(inet_network, LIBC);
575 iret = inet_networkp(cp);
577 AFTER_PACK_ORIGINAL_SOCK(API_ID_inet_network,
578 iret, 0, 0, FD_API_OTHER, "p", cp);
583 char *inet_ntoa(struct in_addr in)
585 static char * (*inet_ntoap)(struct in_addr in);
588 BEFORE_ORIGINAL(inet_ntoa, LIBC);
590 sret = inet_ntoap(in);
592 AFTER_PACK_ORIGINAL_SOCK(API_ID_inet_ntoa, sret, 0, 0, FD_API_OTHER, "d", in.s_addr);
598 struct in_addr inet_makeaddr(int net, int host)
600 static struct in_addr (*inet_makeaddrp)(int net, int host);
603 BEFORE_ORIGINAL(inet_makeaddr, LIBC);
605 iret = inet_makeaddrp(net,host);
607 AFTER_PACK_ORIGINAL_SOCK(API_ID_inet_makeaddr,
608 iret.s_addr, 0, 0, FD_API_OTHER,
615 in_addr_t inet_lnaof(struct in_addr in)
617 static in_addr_t (*inet_lnaofp)(struct in_addr in);
620 BEFORE_ORIGINAL(inet_lnaof, LIBC);
622 iret = inet_lnaofp(in);
624 AFTER_PACK_ORIGINAL_SOCK(API_ID_inet_lnaof,
625 iret, 0, 0, FD_API_OTHER, "d", in.s_addr);
630 in_addr_t inet_netof(struct in_addr in)
632 static in_addr_t (*inet_netofp)(struct in_addr in);
635 BEFORE_ORIGINAL(inet_netof, LIBC);
637 iret = inet_netofp(in);
639 AFTER_PACK_ORIGINAL_SOCK(API_ID_inet_netof,
640 iret, 0, 0, FD_API_OTHER, "d", in.s_addr);
645 const char *inet_ntop(int af, const void *src, char *dst, socklen_t size)
647 static const char* (*inet_ntopp)(int af, const void *src, char *dst, socklen_t size);
650 BEFORE_ORIGINAL(inet_ntop, LIBC);
652 cret = inet_ntopp(af, src, dst, size);
654 AFTER_PACK_ORIGINAL_SOCK(API_ID_inet_ntop,
655 cret, size, 0, FD_API_OTHER,
656 "dppd", af, src, dst, size);
661 int inet_pton(int af, const char *src, void *dst)
663 static int (*inet_ptonp)(int af, const char *src, void *dst);
665 BEFORE_ORIGINAL(inet_pton, LIBC);
667 ret = inet_ptonp(af, src, dst);
669 AFTER_PACK_ORIGINAL_SOCK(API_ID_inet_pton,
670 ret, 0, 0, FD_API_OTHER, "%dpp", af, src, dst);
675 int getaddrinfo(const char *node, const char *service, const struct addrinfo *hints, struct addrinfo **res)
677 static int (*getaddrinfop)(const char *node, const char *service, const struct addrinfo *hints, struct addrinfo **res);
679 BEFORE_ORIGINAL_NOFILTER(getaddrinfo, LIBC);
681 ret = getaddrinfop(node, service, hints, res);
683 AFTER_PACK_ORIGINAL_SOCK(API_ID_getaddrinfo,
684 ret, 0, 0, FD_API_OTHER, "pppp", node, service, hints, res);
689 void freeaddrinfo(struct addrinfo *res)
691 static void (*freeaddrinfop)(struct addrinfo *res);
693 BEFORE_ORIGINAL_NOFILTER(freeaddrinfo, LIBC);
697 AFTER_PACK_ORIGINAL_SOCK(API_ID_freeaddrinfo,
698 0, 0, 0, FD_API_OTHER, "p", res);
701 const char *gai_strerror(int errcode)
703 static const char * (*gai_strerrorp)(int errcode);
706 BEFORE_ORIGINAL(gai_strerror, LIBC);
708 cret = gai_strerrorp(errcode);
710 AFTER_PACK_ORIGINAL_SOCK(API_ID_gai_strerror,
711 cret, 0, 0, FD_API_OTHER, "d", errcode);
716 int gai_suspend(const struct gaicb* const list[], int nitems, const struct timespec *timeout)
718 static int (*gai_suspendp)(const struct gaicb* const list[], int nitems, const struct timespec *timeout);
720 BEFORE_ORIGINAL(gai_suspend, LIBC);
722 ret = gai_suspendp(list,nitems,timeout);
724 AFTER_PACK_ORIGINAL_SOCK(API_ID_gai_suspend,
725 ret, 0, 0, FD_API_OTHER, "pdp", list, nitems, timeout);
730 int gai_error(struct gaicb *req)
732 static int (*gai_errorp)(struct gaicb *req);
734 BEFORE_ORIGINAL(gai_error, LIBC);
736 ret = gai_errorp(req);
738 AFTER_PACK_ORIGINAL_SOCK(API_ID_gai_error,
739 ret, 0, 0, FD_API_OTHER, "p", req);
744 int gai_cancel(struct gaicb *req)
746 static int (*gai_cancelp)(struct gaicb *req);
748 BEFORE_ORIGINAL(gai_cancel, LIBC);
750 ret = gai_cancelp(req);
752 AFTER_PACK_ORIGINAL_SOCK(API_ID_gai_cancel,
753 ret, 0, 0, FD_API_OTHER, "p", req);
758 int getaddrinfo_a(int mode, struct gaicb *list[], int nitems, struct sigevent *sevp)
760 static int (*getaddrinfo_ap)(int mode, struct gaicb *list[], int nitems, struct sigevent *sevp);
762 BEFORE_ORIGINAL(getaddrinfo_a, LIBC);
764 ret = getaddrinfo_ap(mode, list,nitems, sevp);
766 AFTER_PACK_ORIGINAL_SOCK(API_ID_getaddrinfo_a,
767 ret, 0, 0, FD_API_OTHER, "dpdp", mode, list, nitems, sevp);
773 int getsockopt(int socket, int level, int option_name, void *option_value, socklen_t *option_len)
775 static int (*getsockoptp)(int socket, int level, int option_name, void *option_value, socklen_t *option_len);
777 BEFORE_ORIGINAL(getsockopt, LIBC);
779 ret = getsockoptp(socket, level, option_name, option_value, option_len);
781 AFTER_PACK_ORIGINAL_SOCK(API_ID_getsockopt,
782 ret, 0, socket, FD_API_OPTION, "dddpp",
783 socket, level, option_name, option_value, option_len);
788 int setsockopt(int socket, int level, int option_name, const void *option_value, socklen_t option_len)
790 static int (*setsockoptp)(int socket, int level, int option_name, const void *option_value, socklen_t option_len);
792 BEFORE_ORIGINAL(setsockopt, LIBC);
794 ret = setsockoptp(socket, level, option_name, option_value, option_len);
796 AFTER_PACK_ORIGINAL_SOCK(API_ID_setsockopt,
797 ret, option_len, socket, FD_API_OPTION, "dddpd",
798 socket, level, option_name, option_value, option_len);
804 int getsockname(int sockfd, struct sockaddr *addr, socklen_t *addrlen )
806 static int (*getsocknamep)(int sockfd, struct sockaddr *addr, socklen_t *addrlen );
808 BEFORE_ORIGINAL(getsockname, LIBC);
810 ret = getsocknamep(sockfd, addr, addrlen);
812 AFTER_PACK_ORIGINAL_SOCK(API_ID_getsockname,
813 ret, 0, sockfd, FD_API_OTHER, "dpp", sockfd, addr, addrlen);
818 int getdomainname(char *name, size_t len)
820 static int (*getdomainnamep)(char *name, size_t len);
822 BEFORE_ORIGINAL(getdomainname, LIBC);
824 ret = getdomainnamep(name, len);
826 AFTER_PACK_ORIGINAL_SOCK(API_ID_getdomainname,
827 ret, len, 0, FD_API_OTHER, "px", name, len);
832 int setdomainname(const char *name, size_t len)
834 static int (*setdomainnamep)(const char *name, size_t len);
836 BEFORE_ORIGINAL(setdomainname, LIBC);
838 ret = setdomainnamep(name, len);
840 AFTER_PACK_ORIGINAL_SOCK(API_ID_setdomainname,
841 ret, len, 0, FD_API_OTHER, "px", name, len);
846 int gethostname(char *name, size_t len)
848 static int (*gethostnamep)(char *name, size_t len);
850 BEFORE_ORIGINAL(gethostname, LIBC);
852 ret = gethostnamep(name, len);
854 AFTER_PACK_ORIGINAL_SOCK(API_ID_gethostname,
855 ret, len, 0, FD_API_OTHER, "px", name, len);
860 int sethostname(const char *name, size_t len)
862 static int (*sethostnamep)(const char *name, size_t len);
864 BEFORE_ORIGINAL(sethostname, LIBC);
866 ret = sethostnamep(name, len);
868 AFTER_PACK_ORIGINAL_SOCK(API_ID_sethostname,
869 ret, len, 0, FD_API_OTHER, "px", name, len);
874 int getpeername(int s, struct sockaddr *addr, socklen_t *len)
876 static int (*getpeernamep)(int s, struct sockaddr *addr, socklen_t *len);
878 BEFORE_ORIGINAL(getpeername, LIBC);
880 ret = getpeernamep(s, addr, len);
882 AFTER_PACK_ORIGINAL_SOCK(API_ID_getpeername,
883 ret, 0, s, FD_API_OTHER, "dpp", s, addr, len);
888 #if GCC_VERSION < 40800
889 int getnameinfo(const struct sockaddr *sa, socklen_t salen, char *host, socklen_t hostlen, char *serv, socklen_t servlen, unsigned int flags)
891 static int (*getnameinfop)(const struct sockaddr *sa, socklen_t salen, char *host, socklen_t hostlen, char *serv, socklen_t servlen, unsigned int flags);
893 int getnameinfo(const struct sockaddr *sa, socklen_t salen, char *host, size_t hostlen, char *serv, size_t servlen, int flags)
895 static int (*getnameinfop)(const struct sockaddr *sa, socklen_t salen, char *host, size_t hostlen, char *serv, size_t servlen, int flags);
897 BEFORE_ORIGINAL(getnameinfo, LIBC);
899 ret = getnameinfop(sa, salen,host, hostlen, serv, servlen, flags);
901 AFTER_PACK_ORIGINAL_SOCK(API_ID_getnameinfo,
902 ret, 0, 0, FD_API_OTHER, "pdpdpdd",
903 sa, salen, host, hostlen, serv, servlen, flags);
908 struct hostent *gethostbyname(const char *name)
910 static struct hostent * (*gethostbynamep)(const char *name);
911 struct hostent* pret;
913 BEFORE_ORIGINAL(gethostbyname, LIBC);
915 pret = gethostbynamep(name);
917 AFTER_PACK_ORIGINAL_SOCK(API_ID_gethostbyname,
918 pret, 0, 0, FD_API_OTHER, "p", name);
923 struct hostent *gethostbyaddr(const void *addr, socklen_t len, int type)
925 static struct hostent * (*gethostbyaddrp)(const void *addr, socklen_t len, int type);
926 struct hostent* pret;
928 BEFORE_ORIGINAL(gethostbyaddr, LIBC);
930 pret = gethostbyaddrp(addr, len, type);
932 AFTER_PACK_ORIGINAL_SOCK(API_ID_gethostbyaddr,
933 pret, 0, 0, FD_API_OTHER, "pdd", addr, len, type);
938 void sethostent(int stayopen)
940 static void (*sethostentp)(int stayopen);
942 BEFORE_ORIGINAL(sethostent, LIBC);
944 sethostentp(stayopen);
946 AFTER_PACK_ORIGINAL_SOCK(API_ID_sethostent,
947 0, 0, 0, FD_API_OTHER, "d", stayopen);
950 void endhostent(void)
952 static void (*endhostentp)(void);
954 BEFORE_ORIGINAL(endhostent, LIBC);
958 AFTER_PACK_ORIGINAL_SOCK(API_ID_endhostent,
959 0, 0, 0, FD_API_OTHER, "", 0);
962 void herror(const char *s)
964 static void (*herrorp)(const char *s);
966 BEFORE_ORIGINAL(herror, LIBC);
970 AFTER_PACK_ORIGINAL_SOCK(API_ID_herror,
971 0, 0, 0, FD_API_OTHER, "p", s);
974 const char *hstrerror(int err)
976 static const char* (*hstrerrorp)(int err);
979 BEFORE_ORIGINAL(hstrerror, LIBC);
981 cret = hstrerrorp(err);
983 AFTER_PACK_ORIGINAL_SOCK(API_ID_hstrerror,
984 cret, 0, 0, FD_API_OTHER, "d", err);
989 struct hostent *gethostent(void)
991 static struct hostent* (*gethostentp)(void);
992 struct hostent* pret;
994 BEFORE_ORIGINAL(gethostent, LIBC);
996 pret = gethostentp();
998 AFTER_PACK_ORIGINAL_SOCK(API_ID_gethostent,
999 pret, 0, 0, FD_API_OTHER, "", 0);
1004 struct hostent *gethostbyname2(const char *name, int af)
1006 static struct hostent * (*gethostbyname2p)(const char *name, int af);
1007 struct hostent* pret;
1009 BEFORE_ORIGINAL(gethostbyname2, LIBC);
1011 pret = gethostbyname2p(name, af);
1013 AFTER_PACK_ORIGINAL_SOCK(API_ID_gethostbyname2,
1014 pret, 0, 0, FD_API_OTHER, "pd", name, af);
1019 int gethostent_r(struct hostent *rret, char *buf, size_t buflen, struct hostent **result, int *h_errnop)
1021 static int (*gethostent_rp)(struct hostent *rret, char *buf, size_t buflen, struct hostent **result, int *h_errnop);
1023 BEFORE_ORIGINAL(gethostent_r, LIBC);
1025 ret = gethostent_rp(rret, buf, buflen, result, h_errnop);
1027 AFTER_PACK_ORIGINAL_SOCK(API_ID_gethostent_r,
1028 ret, 0, 0, FD_API_OTHER, "ppxpp",
1029 rret, buf, buflen, result, h_errnop);
1034 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)
1036 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);
1038 BEFORE_ORIGINAL(gethostbyaddr_r, LIBC);
1040 ret = gethostbyaddr_rp(addr, len, type, rret, buf, buflen, result, h_errnop);
1042 AFTER_PACK_ORIGINAL_SOCK(API_ID_gethostbyaddr_r,
1043 ret, 0, 0, FD_API_OTHER, "pddppxpp",
1044 addr, len, type, rret, buf, buflen, result, h_errnop);
1049 int gethostbyname_r(const char *name, struct hostent *rret, char *buf, size_t buflen, struct hostent **result, int *h_errnop)
1051 static int (*gethostbyname_rp)(const char *name, struct hostent *rret, char *buf, size_t buflen, struct hostent **result, int *h_errnop);
1053 BEFORE_ORIGINAL(gethostbyname_r, LIBC);
1055 ret = gethostbyname_rp(name, rret, buf, buflen, result, h_errnop);
1057 AFTER_PACK_ORIGINAL_SOCK(API_ID_gethostbyname_r,
1058 ret, 0, 0, FD_API_OTHER, "pppxpp",
1059 name, rret, buf, buflen, result, h_errnop);
1064 int gethostbyname2_r(const char *name, int af, struct hostent *rret, char *buf, size_t buflen, struct hostent **result, int *h_errnop)
1066 static int (*gethostbyname2_rp)(const char *name, int af, struct hostent *rret, char *buf, size_t buflen, struct hostent **result, int *h_errnop);
1068 BEFORE_ORIGINAL(gethostbyname2_r, LIBC);
1070 ret = gethostbyname2_rp(name, af, rret, buf, buflen, result, h_errnop);
1072 AFTER_PACK_ORIGINAL_SOCK(API_ID_gethostbyname2_r,
1073 ret, 0, 0, FD_API_OTHER, "pdppxpp",
1074 name, af, rret, buf, buflen, result, h_errnop);
1079 struct servent *getservbyname(const char *name, const char *proto)
1081 static struct servent * (*getservbynamep)(const char *name, const char *proto);
1082 struct servent* pret;
1084 BEFORE_ORIGINAL(getservbyname, LIBC);
1086 pret = getservbynamep(name, proto);
1088 AFTER_PACK_ORIGINAL_SOCK(API_ID_getservbyname,
1089 pret, 0, 0, FD_API_OTHER, "pp", name, proto);
1094 void setservent(int stayopen)
1096 static void (*setserventp)(int stayopen);
1098 BEFORE_ORIGINAL(setservent, LIBC);
1100 setserventp(stayopen);
1102 AFTER_PACK_ORIGINAL_SOCK(API_ID_setservent,
1103 0, 0, 0, FD_API_OTHER, "d", stayopen);
1106 void endservent(void)
1108 static void (*endserventp)(void);
1110 BEFORE_ORIGINAL(endservent, LIBC);
1114 AFTER_PACK_ORIGINAL_SOCK(API_ID_endservent,
1115 0, 0, 0, FD_API_OTHER, "", 0);
1118 struct servent *getservent(void)
1120 static struct servent * (*getserventp)(void);
1121 struct servent* pret;
1123 BEFORE_ORIGINAL(getservent, LIBC);
1125 pret = getserventp();
1127 AFTER_PACK_ORIGINAL_SOCK(API_ID_getservent,
1128 pret, 0, 0, FD_API_OTHER, "", 0);
1133 struct servent *getservbyport(int port, const char *proto)
1135 static struct servent * (*getservbyportp)(int port, const char *proto);
1136 struct servent* pret;
1138 BEFORE_ORIGINAL(getservbyport, LIBC);
1140 pret = getservbyportp(port, proto);
1142 AFTER_PACK_ORIGINAL_SOCK(API_ID_getservbyport,
1143 pret, 0, 0, FD_API_OTHER, "dp", port, proto);
1148 int getservent_r(struct servent *result_buf, char *buf, size_t buflen, struct servent **result)
1150 static int (*getservent_rp)(struct servent *result_buf, char *buf, size_t buflen, struct servent **result);
1152 BEFORE_ORIGINAL(getservent_r, LIBC);
1154 ret = getservent_rp(result_buf, buf, buflen, result);
1156 AFTER_PACK_ORIGINAL_SOCK(API_ID_getservent_r,
1157 ret, 0, 0, FD_API_OTHER, "ppxp",
1158 result_buf, buf, buflen, result);
1163 int getservbyname_r(const char *name, const char *proto, struct servent *result_buf, char *buf, size_t buflen, struct servent **result)
1165 static int (*getservbyname_rp)(const char *name, const char *proto, struct servent *result_buf, char *buf, size_t buflen, struct servent **result);
1167 BEFORE_ORIGINAL(getservbyname_r, LIBC);
1169 ret = getservbyname_rp(name, proto, result_buf, buf, buflen, result);
1171 AFTER_PACK_ORIGINAL_SOCK(API_ID_getservbyname_r,
1172 ret, 0, 0, FD_API_OTHER, "ppppxp",
1173 name, proto, result_buf, buf, buflen, result);
1178 int getservbyport_r(int port, const char *proto, struct servent *result_buf, char *buf, size_t buflen, struct servent **result)
1180 static int (*getservbyport_rp)(int port, const char *proto, struct servent *result_buf, char *buf, size_t buflen, struct servent **result);
1182 BEFORE_ORIGINAL(getservbyport_r, LIBC);
1184 ret = getservbyport_rp(port, proto, result_buf, buf, buflen, result);
1186 AFTER_PACK_ORIGINAL_SOCK(API_ID_getservbyport_r,
1187 ret, 0, 0, FD_API_OTHER, "dpppxp",
1188 port, proto, result_buf, buf, buflen, result);
1193 struct netent* getnetent(void)
1195 static struct netent * (*getnetentp)(void);
1196 struct netent* pret;
1198 BEFORE_ORIGINAL(getnetent, LIBC);
1200 pret = getnetentp();
1202 AFTER_PACK_ORIGINAL_SOCK(API_ID_getnetent,
1203 pret, 0, 0, FD_API_OTHER, "", 0);
1208 struct netent *getnetbyname(const char *name)
1210 static struct netent * (*getnetbynamep)(const char *name);
1211 struct netent* pret;
1213 BEFORE_ORIGINAL(getnetbyname, LIBC);
1215 pret = getnetbynamep(name);
1217 AFTER_PACK_ORIGINAL_SOCK(API_ID_getnetbyname,
1218 pret, 0, 0, FD_API_OTHER, "p", name);
1223 struct netent *getnetbyaddr(uint32_t net, int type)
1225 static struct netent * (*getnetbyaddrp)(uint32_t net, int type);
1226 struct netent * pret;
1228 BEFORE_ORIGINAL(getnetbyaddr, LIBC);
1230 pret = getnetbyaddrp(net, type);
1232 AFTER_PACK_ORIGINAL_SOCK(API_ID_getnetbyaddr,
1233 pret, 0, 0, FD_API_OTHER, "dd", net, type);
1238 void setnetent(int stayopen)
1240 static void (*setnetentp)(int stayopen);
1242 BEFORE_ORIGINAL(setnetent, LIBC);
1244 setnetentp(stayopen);
1246 AFTER_PACK_ORIGINAL_SOCK(API_ID_setnetent,
1247 0, 0, 0, FD_API_OTHER, "d", stayopen);
1250 void endnetent(void)
1252 static void (*endnetentp)(void);
1254 BEFORE_ORIGINAL(endnetent, LIBC);
1258 AFTER_PACK_ORIGINAL_SOCK(API_ID_endnetent,
1259 0, 0, 0, FD_API_OTHER, "", 0);
1262 int getnetent_r(struct netent *result_buf, char *buf, size_t buflen, struct netent **result, int *h_errnop)
1264 static int (*getnetent_rp)(struct netent *result_buf, char *buf, size_t buflen, struct netent **result, int *h_errnop);
1266 BEFORE_ORIGINAL(getnetent_r, LIBC);
1268 ret = getnetent_rp(result_buf, buf, buflen, result, h_errnop);
1270 AFTER_PACK_ORIGINAL_SOCK(API_ID_getnetent_r,
1271 ret, 0, 0, FD_API_OTHER, "ppxpp",
1272 result_buf, buf, buflen, result, h_errnop);
1277 int getnetbyname_r(const char *name, struct netent *result_buf, char *buf, size_t buflen, struct netent **result, int *h_errnop)
1279 static int (*getnetbyname_rp)(const char *name, struct netent *result_buf, char *buf, size_t buflen, struct netent **result, int *h_errnop);
1281 BEFORE_ORIGINAL(getnetbyname_r, LIBC);
1283 ret = getnetbyname_rp(name,result_buf, buf, buflen, result, h_errnop);
1285 AFTER_PACK_ORIGINAL_SOCK(API_ID_getnetbyname_r,
1286 ret, 0, 0, FD_API_OTHER, "pppxpp",
1287 name, result_buf, buf, buflen, result, h_errnop);
1292 int getnetbyaddr_r(uint32_t net, int type, struct netent *result_buf, char *buf, size_t buflen, struct netent **result, int *h_errnop)
1294 static int (*getnetbyaddr_rp)(uint32_t net, int type, struct netent *result_buf, char *buf, size_t buflen, struct netent **result, int *h_errnop);
1296 BEFORE_ORIGINAL(getnetbyaddr_r, LIBC);
1298 ret = getnetbyaddr_rp(net, type, result_buf, buf, buflen, result, h_errnop);
1300 AFTER_PACK_ORIGINAL_SOCK(API_ID_getnetbyaddr_r,
1301 ret, 0, 0, FD_API_OTHER, "ddppxpp",
1302 net, type, result_buf, buf, buflen, result, h_errnop);
1307 struct protoent *getprotoent(void)
1309 static struct protoent * (*getprotoentp)(void);
1310 struct protoent * pret;
1312 BEFORE_ORIGINAL(getprotoent, LIBC);
1314 pret = getprotoentp();
1316 AFTER_PACK_ORIGINAL_SOCK(API_ID_getprotoent,
1317 pret, 0, 0, FD_API_OTHER, "", 0);
1322 struct protoent *getprotobyname(const char *name)
1324 static struct protoent * (*getprotobynamep)(const char *name);
1325 struct protoent * pret;
1327 BEFORE_ORIGINAL(getprotobyname, LIBC);
1329 pret = getprotobynamep(name);
1331 AFTER_PACK_ORIGINAL_SOCK(API_ID_getprotobyname,
1332 pret, 0, 0, FD_API_OTHER, "p", name);
1337 struct protoent *getprotobynumber(int proto)
1339 static struct protoent * (*getprotobynumberp)(int proto);
1340 struct protoent * pret;
1342 BEFORE_ORIGINAL(getprotobynumber, LIBC);
1344 pret = getprotobynumberp(proto);
1346 AFTER_PACK_ORIGINAL_SOCK(API_ID_getprotobynumber,
1347 pret, 0, 0, FD_API_OTHER, "d", proto);
1352 void setprotoent(int stayopen)
1354 static void (*setprotoentp)(int stayopen);
1356 BEFORE_ORIGINAL(setprotoent, LIBC);
1358 setprotoentp(stayopen);
1360 AFTER_PACK_ORIGINAL_SOCK(API_ID_setprotoent,
1361 0, 0, 0, FD_API_OTHER, "d", stayopen);
1364 void endprotoent(void)
1366 static void (*endprotoentp)(void);
1368 BEFORE_ORIGINAL(endprotoent, LIBC);
1372 AFTER_PACK_ORIGINAL_SOCK(API_ID_endprotoent,
1373 0, 0, 0, FD_API_OTHER, "", 0);
1376 int getprotoent_r(struct protoent *result_buf, char *buf, size_t buflen, struct protoent **result)
1378 static int (*getprotoent_rp)(struct protoent *result_buf, char *buf, size_t buflen, struct protoent **result);
1380 BEFORE_ORIGINAL(getprotoent_r, LIBC);
1382 ret = getprotoent_rp(result_buf, buf, buflen, result);
1384 AFTER_PACK_ORIGINAL_SOCK(API_ID_getprotoent_r,
1385 ret, 0, 0, FD_API_OTHER, "ppxp",
1386 result_buf, buf, buflen, result);
1391 int getprotobyname_r(const char *name, struct protoent *result_buf, char *buf, size_t buflen, struct protoent **result)
1393 static int (*getprotobyname_rp)(const char *name, struct protoent *result_buf, char *buf, size_t buflen, struct protoent **result);
1395 BEFORE_ORIGINAL(getprotobyname_r, LIBC);
1397 ret = getprotobyname_rp(name, result_buf, buf, buflen, result);
1399 AFTER_PACK_ORIGINAL_SOCK(API_ID_getprotobyname_r,
1400 ret, 0, 0, FD_API_OTHER, "pppxp",
1401 name, result_buf, buf, buflen, result);
1406 int getprotobynumber_r(int proto, struct protoent *result_buf, char *buf, size_t buflen, struct protoent **result)
1408 static int (*getprotobynumber_rp)(int proto, struct protoent *result_buf, char *buf, size_t buflen, struct protoent **result);
1410 BEFORE_ORIGINAL(getprotobynumber_r, LIBC);
1412 ret = getprotobynumber_rp(proto, result_buf, buf, buflen, result);
1414 AFTER_PACK_ORIGINAL_SOCK(API_ID_getprotobynumber_r,
1415 ret, 0, 0, FD_API_OTHER, "dppxp",
1416 proto, result_buf, buf, buflen, result);
1421 unsigned int if_nametoindex (__const char *__ifname)
1423 static unsigned int (*if_nametoindexp)(__const char *__ifname);
1426 BEFORE_ORIGINAL(if_nametoindex, LIBC);
1428 uret = if_nametoindexp(__ifname);
1430 AFTER_PACK_ORIGINAL_SOCK(API_ID_if_nametoindex,
1431 uret, 0, 0, FD_API_OTHER, "p", __ifname);
1436 char *if_indextoname (unsigned int __ifindex, char *__ifname)
1438 static char * (*if_indextonamep)(unsigned int __ifindex, char *__ifname);
1441 BEFORE_ORIGINAL(if_indextoname, LIBC);
1443 cret = if_indextonamep(__ifindex, __ifname);
1445 AFTER_PACK_ORIGINAL_SOCK(API_ID_if_indextoname,
1446 cret, 0, 0, FD_API_OTHER,
1447 "dp", __ifindex, __ifname);
1452 struct if_nameindex *if_nameindex (void)
1454 static struct if_nameindex * (*if_nameindexp)(void);
1455 struct if_nameindex * pret;
1457 BEFORE_ORIGINAL_NOFILTER(if_nameindex, LIBC);
1459 pret = if_nameindexp();
1461 AFTER_PACK_ORIGINAL_SOCK(API_ID_if_nameindex,
1462 pret, 0, 0, FD_API_OTHER, "", 0);
1467 void if_freenameindex (struct if_nameindex *__ptr)
1469 static void (*if_freenameindexp)(struct if_nameindex *__ptr);
1471 BEFORE_ORIGINAL_NOFILTER(if_freenameindex, LIBC);
1473 if_freenameindexp(__ptr);
1475 AFTER_PACK_ORIGINAL_SOCK(API_ID_if_freenameindex,
1476 0, 0, 0, FD_API_OTHER, "p", __ptr);
1479 int getifaddrs(struct ifaddrs **ifap)
1481 static int (*getifaddrsp)(struct ifaddrs **ifap);
1483 BEFORE_ORIGINAL_NOFILTER(getifaddrs, LIBC);
1485 ret = getifaddrsp(ifap);
1487 AFTER_PACK_ORIGINAL_SOCK(API_ID_getifaddrs,
1488 ret, 0, 0, FD_API_OTHER, "p", ifap);
1493 void freeifaddrs(struct ifaddrs *ifa)
1495 static void (*freeifaddrsp)(struct ifaddrs *ifa);
1497 BEFORE_ORIGINAL_NOFILTER(freeifaddrs, LIBC);
1501 AFTER_PACK_ORIGINAL_SOCK(API_ID_freeifaddrs,
1502 0, 0, 0, FD_API_OTHER, "p", ifa);
1506 int poll(struct pollfd *ufds, unsigned int nfds, int timeout)
1508 static int (*pollp)(struct pollfd *ufds, unsigned int nfds, int timeout);
1510 BEFORE_ORIGINAL(poll, LIBC);
1512 ret = pollp(ufds, nfds, timeout);
1514 AFTER_PACK_ORIGINAL_SOCK(ret, timeout, 0, FD_API_OTHER, "pdd", ufds, nfds, timeout);
1519 int ppoll(struct pollfd *fds, nfds_t nfds, const struct timespec *timeout_ts, const sigset_t *sigmask)
1521 static int (*ppollp)(struct pollfd *fds, nfds_t nfds, const struct timespec *timeout_ts, const sigset_t *sigmask);
1523 BEFORE_ORIGINAL(ppoll, LIBC);
1525 ret = ppollp(fds, nfds, timeout_ts, sigmask);
1527 AFTER_PACK_ORIGINAL_SOCK(ret, 0, 0, FD_API_OTHER, "pxpp",
1528 fds, nfds, timeout_ts, sigmask);