[FIX] Correctly decrement counter in case of irregular descriptor
[platform/core/system/swap-probe.git] / probe_socket / libdasocket.c
1 /*
2  *  DA probe
3  *
4  * Copyright (c) 2000 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
5  *
6  * Contact:
7  *
8  * Hyunjong Park <phjwithyou.park@samsung.com>
9  * Juyoung Kim <j0.kim@samsung.com>
10  * Anastasia Lyupa <a.lyupa@samsung.com>
11  *
12  * This library is free software; you can redistribute it and/or modify it under
13  * the terms of the GNU Lesser General Public License as published by the
14  * Free Software Foundation; either version 2.1 of the License, or (at your option)
15  * any later version.
16  *
17  * This library is distributed in the hope that it will be useful, but WITHOUT ANY
18  * WARRANTY; without even the implied warranty of MERCHANTABILITY or
19  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
20  * License for more details.
21  *
22  * You should have received a copy of the GNU Lesser General Public License
23  * along with this library; if not, write to the Free Software Foundation, Inc., 51
24  * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
25  *
26  * Contributors:
27  * - S-Core Co., Ltd
28  * - Samsung RnD Institute Russia
29  *
30  */
31
32 #include <stdio.h>
33 #include <stdlib.h>
34 #include <string.h>
35 #include <dlfcn.h>
36 #include <stdbool.h>
37 #include <sys/types.h>
38 #include <sys/socket.h>
39 #include <arpa/inet.h>
40 #include <netdb.h>
41 #include <ifaddrs.h>
42 #include <sys/un.h>
43 #include <errno.h>
44 #include <time.h>
45 #include <sys/epoll.h>
46 #include <sys/poll.h>
47 #include "probeinfo.h"
48 #include "dautil.h"
49 #include "da_socket.h"
50 #include "daprobe.h"
51 #include "dahelper.h"
52 #include "api_id_mapping.h"
53 #include "binproto.h"
54
55 #define OBJ_DUMMY 0
56
57 static enum DaOptions _sopt = OPT_NETWORK;
58 char g_address[128];
59 char* getAddress(const struct sockaddr *sa) {
60         char buff[INET6_ADDRSTRLEN];
61         switch (sa->sa_family) {
62         case AF_INET:
63                 sprintf(g_address, "%s:%d",
64                                 inet_ntoa(((struct sockaddr_in*) sa)->sin_addr),
65                                 (int) ntohs(((struct sockaddr_in*) sa)->sin_port));
66                 break;
67         case AF_INET6:
68                 sprintf(g_address, "%s:%d",
69                                 inet_ntop(AF_INET6, &(((struct sockaddr_in6 *) sa)->sin6_addr),
70                                                 buff, sizeof(buff)),
71                                 ntohs(((struct sockaddr_in6*) sa)->sin6_port));
72                 break;
73         }
74         return g_address;
75 }
76
77 //FD
78 int socket(int domain, int type, int protocol) {
79         static int (*socketp)(int domain, int type, int protocol);
80         BEFORE_ORIGINAL_SOCK(socket, LIBC);
81         ret = socketp(domain, type, protocol);
82
83         AFTER_ORIGINAL_LIBC_SOCK(ret, OBJ_DUMMY, ret, SOCKET_API_FD_OPEN, "",
84                         0, NO_DESTINATIONINFO, "ddd", domain, type, protocol);
85
86         return ret;
87 }
88
89 int accept(int socket, struct sockaddr *address, socklen_t *address_len) {
90
91         static int (*acceptp)(int socket, struct sockaddr *address,
92                         socklen_t *address_len);
93
94         BEFORE_ORIGINAL_SOCK(accept, LIBC);
95
96         char* callAddress = getAddress(address);
97         AFTER_ORIGINAL_LIBC_SOCK_WAIT_FUNC_START(NULL, OBJ_DUMMY, socket,
98                         SOCKET_API_ACCEPT_START, "", 0, address, "dsp",
99                         socket, callAddress, address_len);
100
101         ret = acceptp(socket, address, address_len);
102
103         AFTER_ORIGINAL_LIBC_SOCK_WAIT_FUNC_END(ret, OBJ_DUMMY, socket,
104                         SOCKET_API_ACCEPT_END, "", 0, address, "dsp",
105                         socket, callAddress, address_len);
106
107         return ret;
108 }
109
110 int accept4(int sockfd, struct sockaddr *addr, socklen_t *addrlen, int flags) {
111         static int (*accept4p)(int sockfd, struct sockaddr *addr,
112                         socklen_t *addrlen, int flags);
113
114         BEFORE_ORIGINAL_SOCK(accept4, LIBC);
115         char* callAddress = getAddress(addr);
116
117         AFTER_ORIGINAL_LIBC_SOCK_WAIT_FUNC_START(NULL, OBJ_DUMMY, sockfd,
118                         SOCKET_API_ACCEPT_START, "", 0, addr, "dspd",
119                         sockfd, callAddress, addrlen, flags);
120
121         ret = accept4p(sockfd, addr, addrlen, flags);
122
123         AFTER_ORIGINAL_LIBC_SOCK_WAIT_FUNC_END(ret, OBJ_DUMMY, sockfd,
124                         SOCKET_API_ACCEPT_END, "", 0, addr, "dspd",
125                         sockfd, callAddress, addrlen, flags);
126
127         return ret;
128 }
129
130 int connect(int socket, const struct sockaddr *address, socklen_t address_len) {
131         static int (*connectp)(int socket, const struct sockaddr *address,
132                         socklen_t address_len);
133
134         BEFORE_ORIGINAL_SOCK(connect, LIBC);
135
136         ret = connectp(socket, address, address_len);
137
138         AFTER_ORIGINAL_LIBC_SOCK(ret, OBJ_DUMMY, socket, SOCKET_API_CONNECT,
139                         "", 0, address, "dsd",
140                         socket, getAddress(address), address_len);
141
142         return ret;
143 }
144
145 int shutdown(int socket, int how) {
146         static int (*shutdownp)(int socket, int how);
147
148         BEFORE_ORIGINAL_SOCK(shutdown, LIBC);
149
150         ret = shutdownp(socket, how);
151
152         AFTER_ORIGINAL_LIBC_SOCK(ret, OBJ_DUMMY, socket, SOCKET_API_FD_CLOSE,
153                         "", 0, NO_DESTINATIONINFO, "dd", socket, how);
154
155         return ret;
156 }
157
158 int bind(int socket, const struct sockaddr *address, socklen_t address_len) {
159         static int (*bindp)(int socket, const struct sockaddr *address,
160                         socklen_t address_len);
161
162         BEFORE_ORIGINAL_SOCK(bind, LIBC);
163
164         ret = bindp(socket, address, address_len);
165
166         AFTER_ORIGINAL_LIBC_SOCK(ret, OBJ_DUMMY, socket, SOCKET_API_BIND, "",
167                         0, address, "dsd",
168                         socket, getAddress(address), address_len);
169
170         return ret;
171 }
172
173 int listen(int socket, int backlog) {
174         static int (*listenp)(int socket, int backlog);
175         BEFORE_ORIGINAL_SOCK(listen, LIBC);
176         ret = listenp(socket, backlog);
177
178         AFTER_ORIGINAL_LIBC_SOCK(ret, OBJ_DUMMY, socket, SOCKET_API_LISTEN, "",
179                         0, NO_DESTINATIONINFO, "dd", socket, backlog);
180
181         return ret;
182 }
183
184 ssize_t send(int socket, const void *message, size_t length, int flags) {
185         static ssize_t (*sendp)(int socket, const void *message, size_t length,
186                         int flags);
187         ssize_t sret;
188         BEFORE_ORIGINAL_SOCK(send, LIBC);
189
190         int* messagP = (int*) message;
191
192         AFTER_ORIGINAL_LIBC_SOCK_WAIT_FUNC_START(NULL, OBJ_DUMMY, socket,
193                         SOCKET_API_SEND_START, "", 0, NO_DESTINATIONINFO, "dpdd",
194                         socket, messagP, length, flags);
195
196         sret = sendp(socket, message, length, flags);
197
198         int sendMaxSize = SOCKET_SEND_SIZE;
199         char* out = (char*) malloc(sendMaxSize + 5);
200         if (sret <= 0) {
201                 out[0] = '\0';
202         } else {
203                 memcpy(out, message, sendMaxSize + 5);
204                 if (sret > sendMaxSize + 5) {
205                         out[sendMaxSize] = '.';
206                         out[sendMaxSize + 1] = '.';
207                         out[sendMaxSize + 2] = '.';
208                         out[sendMaxSize + 3] = '\0';
209                 } else {
210                         out[sret] = '\0';
211                 }
212         }
213
214         AFTER_ORIGINAL_LIBC_SOCK_WAIT_FUNC_END(sret, OBJ_DUMMY, socket,
215                         SOCKET_API_SEND_END, out, sret, NO_DESTINATIONINFO, "dpdd",
216                         socket, messagP, length, flags);
217         free(out);
218         return sret;
219 }
220
221 ssize_t recv(int socket, void *buffer, size_t length, int flags) {
222         static ssize_t (*recvp)(int socket, void *buffer, size_t length, int flags);
223         ssize_t sret;
224
225         BEFORE_ORIGINAL_SOCK(recv, LIBC);
226
227         int* bufferP = (int*) buffer;
228
229         AFTER_ORIGINAL_LIBC_SOCK_WAIT_FUNC_START(NULL, OBJ_DUMMY, socket,
230                         SOCKET_API_RECV_START, "", 0, NO_DESTINATIONINFO, "dpdd",
231                         socket, bufferP, length, flags);
232
233         sret = recvp(socket, buffer, length, flags);
234
235         int sendMaxSize = SOCKET_SEND_SIZE;
236         char* out = (char*) malloc(sendMaxSize + 5);
237         if (sret <= 0) {
238                 out[0] = '\0';
239         } else {
240                 memcpy(out, buffer, sendMaxSize + 5);
241                 if (sret > sendMaxSize + 5) {
242                         out[sendMaxSize] = '.';
243                         out[sendMaxSize + 1] = '.';
244                         out[sendMaxSize + 2] = '.';
245                         out[sendMaxSize + 3] = '\0';
246                 } else {
247                         out[sret] = '\0';
248                 }
249         }
250
251         AFTER_ORIGINAL_LIBC_SOCK_WAIT_FUNC_END(sret, OBJ_DUMMY, socket,
252                         SOCKET_API_RECV_END, out, sret, NO_DESTINATIONINFO, "dpdd",
253                         socket, bufferP, length, flags);
254         free(out);
255         return sret;
256 }
257
258 ssize_t sendto(int socket, const void *message, size_t length, int flags,
259                 const struct sockaddr *dest_addr, socklen_t dest_len) {
260         static ssize_t (*sendtop)(int socket, const void *message, size_t length,
261                         int flags, const struct sockaddr *dest_addr, socklen_t dest_len);
262         ssize_t sret;
263
264         BEFORE_ORIGINAL_SOCK(sendto, LIBC);
265
266         int* bufferP = (int*) message;
267
268         AFTER_ORIGINAL_LIBC_SOCK_WAIT_FUNC_START(NULL, OBJ_DUMMY, socket,
269                         SOCKET_API_SEND_START, "", 0, dest_addr, "dpddpd",
270                         socket, bufferP, length, flags, dest_addr, dest_len);
271
272         sret = sendtop(socket, message, length, flags, dest_addr, dest_len);
273
274         int sendMaxSize = SOCKET_SEND_SIZE;
275         char* out = (char*) malloc(sendMaxSize + 5);
276         if (sret <= 0) {
277                 out[0] = '\0';
278         } else {
279                 memcpy(out, message, sendMaxSize + 5);
280                 if (sret > sendMaxSize + 5) {
281                         out[sendMaxSize] = '.';
282                         out[sendMaxSize + 1] = '.';
283                         out[sendMaxSize + 2] = '.';
284                         out[sendMaxSize + 3] = '\0';
285                 } else {
286                         out[sret] = '\0';
287                 }
288         }
289
290         AFTER_ORIGINAL_LIBC_SOCK_WAIT_FUNC_END(sret, OBJ_DUMMY, socket,
291                         SOCKET_API_SEND_END, out, sret, NO_DESTINATIONINFO, "dpddpd",
292                         socket, bufferP, length, flags, dest_addr, dest_len);
293         free(out);
294         return sret;
295 }
296
297 ssize_t recvfrom(int socket, void *buffer, size_t length, int flags,
298                 struct sockaddr *address, socklen_t *address_len) {
299         static ssize_t (*recvfromp)(int socket, void *buffer, size_t length,
300                         int flags, struct sockaddr *address, socklen_t *address_len);
301         ssize_t sret;
302
303         BEFORE_ORIGINAL_SOCK(recvfrom, LIBC);
304
305         int* bufferP = (int*) buffer;
306
307         AFTER_ORIGINAL_LIBC_SOCK_WAIT_FUNC_START(NULL, OBJ_DUMMY, socket,
308                         SOCKET_API_RECV_START, "", 0, NO_DESTINATIONINFO, "dpddpp",
309                         socket, bufferP, length, flags, address, address_len);
310
311         sret = recvfromp(socket, buffer, length, flags, address, address_len);
312
313         int sendMaxSize = SOCKET_SEND_SIZE;
314         char* out = (char*) malloc(sendMaxSize + 5);
315         if (sret <= 0) {
316                 out[0] = '\0';
317         } else {
318                 memcpy(out, buffer, sendMaxSize + 5);
319                 if (sret > sendMaxSize + 5) {
320                         out[sendMaxSize] = '.';
321                         out[sendMaxSize + 1] = '.';
322                         out[sendMaxSize + 2] = '.';
323                         out[sendMaxSize + 3] = '\0';
324                 } else {
325                         out[sret] = '\0';
326                 }
327         }
328
329         AFTER_ORIGINAL_LIBC_SOCK_WAIT_FUNC_END(sret, OBJ_DUMMY, socket,
330                         SOCKET_API_RECV_END, out, sret, NO_DESTINATIONINFO, "dpddpp",
331                         socket, bufferP, length, flags, address, address_len);
332         free(out);
333         return sret;
334 }
335
336 ssize_t recvmsg(int socket, struct msghdr *message, int flags) {
337         static ssize_t (*recvmsgp)(int socket, struct msghdr *message, int flags);
338         ssize_t sret;
339
340         BEFORE_ORIGINAL_SOCK(recvmsg, LIBC);
341
342         int* bufferP = (int*) message->msg_name;
343
344         AFTER_ORIGINAL_LIBC_SOCK_WAIT_FUNC_START(NULL, OBJ_DUMMY, socket,
345                         SOCKET_API_RECV_START, "", 0, NO_DESTINATIONINFO, "dpd",
346                         socket, message, flags);
347
348         sret = recvmsgp(socket, message, flags);
349         if (sret <= 0) {
350                 memset(&message, 0, sizeof(message));
351         }
352
353         int sendMaxSize = SOCKET_SEND_SIZE;
354         char* out = (char*) malloc(sendMaxSize + 5);
355         if (sret <= 0) {
356                 out[0] = '\0';
357         } else {
358                 memcpy(out, message, sendMaxSize + 5);
359                 if (sret > sendMaxSize + 5) {
360                         out[sendMaxSize] = '.';
361                         out[sendMaxSize + 1] = '.';
362                         out[sendMaxSize + 2] = '.';
363                         out[sendMaxSize + 3] = '\0';
364                 } else {
365                         out[sret] = '\0';
366                 }
367         }
368
369         AFTER_ORIGINAL_LIBC_SOCK_WAIT_FUNC_END(sret, OBJ_DUMMY, socket,
370                         SOCKET_API_RECV_END, out, sret, NO_DESTINATIONINFO, "dpd",
371                         socket, bufferP, flags);
372         free(out);
373         return sret;
374 }
375
376 ssize_t sendmsg(int socket, const struct msghdr *message, int flags) {
377         static ssize_t (*sendmsgp)(int socket, const struct msghdr *message,
378                         int flags);
379         ssize_t sret;
380
381         BEFORE_ORIGINAL_SOCK(sendmsg, LIBC);
382
383         int* bufferP = (int*) message->msg_name;
384
385         AFTER_ORIGINAL_LIBC_SOCK_WAIT_FUNC_START(NULL, OBJ_DUMMY, socket,
386                         SOCKET_API_SEND_START, "", 0, NO_DESTINATIONINFO, "dpd",
387                         socket, message, flags);
388
389         sret = sendmsgp(socket, message, flags);
390         if (sret <= 0) {
391                 memset(&message, 0, sizeof(message));
392         }
393         int sendMaxSize = SOCKET_SEND_SIZE;
394         char* out = (char*) malloc(sendMaxSize + 5);
395         if (sret <= 0) {
396                 out[0] = '\0';
397         } else {
398                 memcpy(out, message, sendMaxSize + 5);
399                 if (sret > sendMaxSize + 5) {
400                         out[sendMaxSize] = '.';
401                         out[sendMaxSize + 1] = '.';
402                         out[sendMaxSize + 2] = '.';
403                         out[sendMaxSize + 3] = '\0';
404                 } else {
405                         out[sret] = '\0';
406                 }
407         }
408
409         AFTER_ORIGINAL_LIBC_SOCK_WAIT_FUNC_END(sret, OBJ_DUMMY, socket,
410                         SOCKET_API_SEND_END, out, sret, NO_DESTINATIONINFO, "dpd",
411                         socket, bufferP, flags);
412         free(out);
413         return sret;
414 }
415
416 int getsockopt(int socket, int level, int option_name, void *option_value,
417                 socklen_t *option_len) {
418         static int (*getsockoptp)(int socket, int level, int option_name,
419                         void *option_value, socklen_t *option_len);
420
421         BEFORE_ORIGINAL_SOCK(getsockopt, LIBC);
422
423         ret = getsockoptp(socket, level, option_name, option_value, option_len);
424
425         AFTER_ORIGINAL_LIBC_SOCK(ret, OBJ_DUMMY, socket, SOCKET_API_OTHER, "",
426                         0, NO_DESTINATIONINFO, "dddpp",
427                         socket, level, option_name, option_value, option_len);
428
429         return ret;
430 }
431
432 int setsockopt(int socket, int level, int option_name, const void *option_value,
433                 socklen_t option_len) {
434         static int (*setsockoptp)(int socket, int level, int option_name,
435                         const void *option_value, socklen_t option_len);
436
437         BEFORE_ORIGINAL_SOCK(setsockopt, LIBC);
438
439         ret = setsockoptp(socket, level, option_name, option_value, option_len);
440
441         AFTER_ORIGINAL_LIBC_SOCK(ret, OBJ_DUMMY, socket, SOCKET_API_OTHER, "",
442                         0, NO_DESTINATIONINFO, "dddpd",
443                         socket, level, option_name, option_value, option_len);
444
445         return ret;
446 }
447
448 int getpeername(int fd, struct sockaddr *addr, socklen_t *len) {
449         static int (*getpeernamep)(int s, struct sockaddr *addr, socklen_t *len);
450
451         BEFORE_ORIGINAL_SOCK(getpeername, LIBC);
452
453         ret = getpeernamep(fd, addr, len);
454
455         AFTER_ORIGINAL_LIBC_SOCK(ret, OBJ_DUMMY, fd, SOCKET_API_OTHER, "", 0,
456                         getAddress(addr), "dsp", fd, getAddress(addr), len);
457         return ret;
458 }
459
460 int getsockname(int sockfd, struct sockaddr *addr, socklen_t *addrlen) {
461         static int (*getsocknamep)(int sockfd, struct sockaddr *addr,
462                         socklen_t *addrlen);
463
464         BEFORE_ORIGINAL_SOCK(getsockname, LIBC);
465
466         ret = getsocknamep(sockfd, addr, addrlen);
467
468         AFTER_ORIGINAL_LIBC_SOCK(ret, OBJ_DUMMY, sockfd, SOCKET_API_OTHER, "",
469                         0, getAddress(addr), "dsp",
470                         sockfd, getAddress(addr), addrlen);
471
472         return ret;
473 }
474
475 int socketpair(int domain, int type, int protocol, int socket_vector[2]) {
476         static int (*socketpairp)(int domain, int type, int protocol,
477                         int socket_vector[2]);
478
479         BEFORE_ORIGINAL_SOCK(socketpair, LIBC);
480
481         ret = socketpairp(domain, type, protocol, socket_vector);
482
483         AFTER_ORIGINAL_LIBC_SOCK(ret, OBJ_DUMMY, socket_vector[0],
484                         SOCKET_API_FD_OPEN, "", 0, NO_DESTINATIONINFO, "ddddd",
485                         domain, type, protocol, socket_vector[0], socket_vector[1]);
486
487         return ret;
488 }
489
490 int sockatmark(int __fd) {
491         static int (*sockatmarkp)(int __fd);
492
493         BEFORE_ORIGINAL_SOCK(sockatmark, LIBC);
494
495         ret = sockatmarkp(__fd);
496
497         AFTER_ORIGINAL_LIBC_SOCK(ret, OBJ_DUMMY, __fd,
498                         SOCKET_API_OTHER, "", 0, NO_DESTINATIONINFO, "d", __fd);
499         return ret;
500 }
501
502 int isfdtype(int __fd, int __fdtype) {
503         static int (*isfdtypep)(int __fd, int __fdtype);
504
505         BEFORE_ORIGINAL_SOCK(isfdtype, LIBC);
506
507         ret = isfdtypep(__fd, __fdtype);
508
509         AFTER_ORIGINAL_LIBC_SOCK(ret, OBJ_DUMMY, __fd, SOCKET_API_OTHER, "", 0,
510                         NO_DESTINATIONINFO, "dd", __fd, __fdtype);
511         return ret;
512 }
513
514 int select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds,
515                 struct timeval *timeout) {
516         static int (*selectp)(int nfds, fd_set *readfds, fd_set *writefds,
517                         fd_set *exceptfds, struct timeval *timeout);
518
519         BEFORE_ORIGINAL_SOCK(select, LIBC);
520
521         AFTER_ORIGINAL_LIBC_SOCK_WAIT_FUNC_START(NULL, OBJ_DUMMY, 0,
522                         SOCKET_API_EVENT_START, "", 0, NO_DESTINATIONINFO, "dpppp",
523                         nfds, readfds, writefds, exceptfds, timeout);
524
525         ret = selectp(nfds, readfds, writefds, exceptfds, timeout);
526
527         AFTER_ORIGINAL_LIBC_SOCK_WAIT_FUNC_END(ret, OBJ_DUMMY, 0,
528                         SOCKET_API_EVENT_END, "", 0, NO_DESTINATIONINFO, "dpppp",
529                         nfds, readfds, writefds, exceptfds, timeout);
530
531         return ret;
532 }
533
534 int pselect(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds,
535                 const struct timespec *ntimeout, const sigset_t *sigmask) {
536         static int (*pselectp)(int nfds, fd_set *readfds, fd_set *writefds,
537                         fd_set *exceptfds, const struct timespec *ntimeout,
538                         const sigset_t *sigmask);
539
540         BEFORE_ORIGINAL_SOCK(pselect, LIBC);
541
542         AFTER_ORIGINAL_LIBC_SOCK_WAIT_FUNC_START(NULL, OBJ_DUMMY, 0,
543                         SOCKET_API_EVENT_START, "", 0, NO_DESTINATIONINFO, "dppppp",
544                         nfds, readfds, writefds, exceptfds, ntimeout, sigmask);
545
546         ret = pselectp(nfds, readfds, writefds, exceptfds, ntimeout, sigmask);
547
548         AFTER_ORIGINAL_LIBC_SOCK_WAIT_FUNC_END(ret, OBJ_DUMMY, 0,
549                         SOCKET_API_EVENT_END, "", 0, NO_DESTINATIONINFO, "dppppp",
550                         nfds, readfds, writefds, exceptfds, ntimeout, sigmask);
551
552         return ret;
553 }
554
555 int poll(struct pollfd *fds, nfds_t nfds, int timeout) {
556         static int (*pollp)(struct pollfd *ufds, unsigned int nfds, int timeout);
557
558         BEFORE_ORIGINAL_SOCK(poll, LIBC);
559
560         AFTER_ORIGINAL_LIBC_SOCK_WAIT_FUNC_START(NULL, OBJ_DUMMY, fds->fd,
561                         SOCKET_API_EVENT_START, "", 0, NO_DESTINATIONINFO, "pxd",
562                         fds, nfds, timeout);
563
564         ret = pollp(fds, nfds, timeout);
565
566         AFTER_ORIGINAL_LIBC_SOCK_WAIT_FUNC_END(ret, OBJ_DUMMY, fds->fd,
567                         SOCKET_API_EVENT_END, "", 0, NO_DESTINATIONINFO, "pxd", fds, nfds, timeout);
568
569         return ret;
570 }
571
572 int ppoll(struct pollfd *fds, nfds_t nfds, const struct timespec *timeout_ts,
573                 const sigset_t *sigmask) {
574         static int (*ppollp)(struct pollfd *fds, nfds_t nfds,
575                         const struct timespec *timeout_ts, const sigset_t *sigmask);
576
577         BEFORE_ORIGINAL_SOCK(ppoll, LIBC);
578
579         AFTER_ORIGINAL_LIBC_SOCK_WAIT_FUNC_START(NULL, OBJ_DUMMY, fds->fd,
580                         SOCKET_API_EVENT_START, "", 0, NO_DESTINATIONINFO, "pxpp",
581                         fds, nfds, timeout_ts, sigmask);
582
583         ret = ppollp(fds, nfds, timeout_ts, sigmask);
584
585         AFTER_ORIGINAL_LIBC_SOCK_WAIT_FUNC_END(ret, OBJ_DUMMY, fds->fd,
586                         SOCKET_API_EVENT_END, "", 0, NO_DESTINATIONINFO, "pxpp",
587                         fds, nfds, timeout_ts, sigmask);
588
589         return ret;
590 }
591
592 int epoll_create(int __size) {
593         static int (*epoll_createp)(int __size);
594         BEFORE_ORIGINAL_SOCK(epoll_create, LIBC);
595
596         ret = epoll_createp(__size);
597
598         AFTER_ORIGINAL_LIBC_SOCK(ret, OBJ_DUMMY, ret, SOCKET_API_FD_OPEN, "",
599                         0, NO_DESTINATIONINFO, "d", __size);
600         return ret;
601 }
602
603 int epoll_create1(int __flags) {
604         static int (*epoll_create1p)(int __size);
605         BEFORE_ORIGINAL_SOCK(epoll_create1, LIBC);
606
607         ret = epoll_create1p(__flags);
608
609         AFTER_ORIGINAL_LIBC_SOCK(ret, OBJ_DUMMY, ret, SOCKET_API_FD_OPEN, "",
610                         0, NO_DESTINATIONINFO, "d", __flags);
611         return ret;
612 }
613
614 int epoll_wait(int __epfd, struct epoll_event *__events, int __maxevents,
615                 int __timeout) {
616         static int (*epoll_waitp)(int __epfd, struct epoll_event *__events,
617                         int __maxevents, int __timeout);
618         BEFORE_ORIGINAL_SOCK(epoll_wait, LIBC);
619
620         AFTER_ORIGINAL_LIBC_SOCK_WAIT_FUNC_START(NULL, OBJ_DUMMY, __epfd,
621                         SOCKET_API_EVENT_START, "", 0, NO_DESTINATIONINFO, "dpdd",
622                         __epfd, __events, __maxevents, __timeout);
623
624         ret = epoll_waitp(__epfd, __events, __maxevents, __timeout);
625
626         AFTER_ORIGINAL_LIBC_SOCK_WAIT_FUNC_END(ret, OBJ_DUMMY, __epfd,
627                         SOCKET_API_EVENT_END, "", 0, NO_DESTINATIONINFO, "dpdd",
628                         __epfd, __events, __maxevents, __timeout);
629
630         return ret;
631 }
632
633 int epoll_pwait(int __epfd, struct epoll_event *__events, int __maxevents,
634                 int __timeout, __const                          __sigset_t *__ss) {
635         static int (*epoll_pwaitp)(int __epfd, struct epoll_event *__events,
636                         int __maxevents, int __timeout, __const                          __sigset_t *__ss);
637         BEFORE_ORIGINAL_SOCK(epoll_pwait, LIBC);
638
639         AFTER_ORIGINAL_LIBC_SOCK_WAIT_FUNC_START(NULL, OBJ_DUMMY, __epfd,
640                         SOCKET_API_EVENT_START, "", 0, NO_DESTINATIONINFO, "dpdd %p",
641                         __epfd, __events, __maxevents, __timeout, __ss);
642
643         ret = epoll_pwaitp(__epfd, __events, __maxevents, __timeout, __ss);
644
645         AFTER_ORIGINAL_LIBC_SOCK_WAIT_FUNC_END(ret, OBJ_DUMMY, __epfd,
646                         SOCKET_API_EVENT_END, "", 0, NO_DESTINATIONINFO, "dpdd %p",
647                         __epfd, __events, __maxevents, __timeout, __ss);
648
649         return ret;
650 }
651
652 int epoll_ctl(int __epfd, int __op, int __fd, struct epoll_event *__event) {
653         static int (*epoll_ctlp)(int __epfd, int __op, int __fd,
654                         struct epoll_event *__event);
655
656         BEFORE_ORIGINAL_SOCK(epoll_ctl, LIBC);
657
658         ret = epoll_ctlp(__epfd, __op, __fd, __event);
659
660         AFTER_ORIGINAL_LIBC_SOCK(ret, OBJ_DUMMY, __fd, SOCKET_API_OTHER, "", 0,
661                         NO_DESTINATIONINFO, "dddp", __epfd, __op, __fd, __event);
662         return ret;
663 }
664
665 #if 0
666 //OPTION _//NO FD
667
668 uint32_t htonl(uint32_t hostlong) {
669         static uint32_t (*htonlp)(uint32_t hostlong);
670         uint32_t uret;
671
672         BEFORE_ORIGINAL_SOCK(htonl, LIBC);
673
674         uret = htonlp(hostlong);
675
676         AFTER_ORIGINAL_LIBC_SOCK(VT_UINT32_T, uret, OBJ_DUMMY, 0, SOCKET_API_OTHER,
677                         NO_DESTINATIONINFO, "", "d", hostlong);
678
679         return uret;
680 }
681
682 uint16_t htons(uint16_t hostshort) {
683         static uint16_t (*htonsp)(uint16_t hostshort);
684         uint16_t uret;
685
686         BEFORE_ORIGINAL_SOCK(htons, LIBC);
687
688         uret = htonsp(hostshort);
689
690         AFTER_ORIGINAL_LIBC_SOCK(VT_UINT16_T, uret, OBJ_DUMMY, 0, SOCKET_API_OTHER,
691                         NO_DESTINATIONINFO, "", "d", hostshort);
692
693         return uret;
694 }
695
696 int inet_aton(const char *cp, struct in_addr *inp) {
697         static int (*inet_atonp)(const char *cp, struct in_addr *inp);
698
699         BEFORE_ORIGINAL_SOCK(inet_aton, LIBC);
700
701         ret = inet_atonp(cp, inp);
702
703         AFTER_ORIGINAL_LIBC_SOCK(ret, OBJ_DUMMY, 0, SOCKET_API_OTHER, "",
704                         NO_DESTINATIONINFO, "pp", cp, inp);
705
706         return ret;
707 }
708
709 in_addr_t inet_addr(const char *cp) {
710         static in_addr_t (*inet_addrp)(const char *cp);
711         in_addr_t iret;
712
713         BEFORE_ORIGINAL_SOCK(inet_addr, LIBC);
714
715         iret = inet_addrp(cp);
716
717         AFTER_ORIGINAL_LIBC_SOCK(iret, OBJ_DUMMY, 0, SOCKET_API_OTHER, "",
718                         NO_DESTINATIONINFO, "p", cp);
719
720         return iret;
721 }
722
723 in_addr_t inet_network(const char *cp) {
724         static in_addr_t (*inet_networkp)(const char *cp);
725         in_addr_t iret;
726
727         BEFORE_ORIGINAL_SOCK(inet_network, LIBC);
728
729         iret = inet_networkp(cp);
730
731         AFTER_ORIGINAL_LIBC_SOCK(iret, OBJ_DUMMY, 0, SOCKET_API_OTHER, "",
732                         NO_DESTINATIONINFO, "p", cp);
733
734         return iret;
735 }
736
737 char *inet_ntoa(struct in_addr in) {
738         static char * (*inet_ntoap)(struct in_addr in);
739         char* sret;
740
741         BEFORE_ORIGINAL_SOCK(inet_ntoa, LIBC);
742
743         sret = inet_ntoap(in);
744
745         AFTER_ORIGINAL_LIBC_SOCK(sret, OBJ_DUMMY, 0, SOCKET_API_OTHER, "",
746                         NO_DESTINATIONINFO, "d", in.s_addr);
747
748         return sret;
749 }
750
751 uint32_t ntohl(uint32_t netlong) {
752         static uint32_t (*ntohlp)(uint32_t netlong);
753         uint32_t uret;
754
755         BEFORE_ORIGINAL_SOCK(ntohl, LIBC);
756
757         uret = ntohlp(netlong);
758
759         AFTER_ORIGINAL_LIBC_SOCK(VT_UINT32_T, uret, OBJ_DUMMY, 0, SOCKET_API_OTHER,
760                         NO_DESTINATIONINFO, "", "d", netlong);
761
762         return uret;
763 }
764
765 uint16_t ntohs(uint16_t netshort) {
766         static uint16_t (*ntohsp)(uint16_t netshort);
767         uint16_t uret;
768
769         BEFORE_ORIGINAL_SOCK(ntohs, LIBC);
770
771         uret = ntohsp(netshort);
772
773         AFTER_ORIGINAL_LIBC_SOCK(VT_UINT16_T, uret, OBJ_DUMMY, 0, SOCKET_API_OTHER,
774                         NO_DESTINATIONINFO, "", "d", netshort);
775
776         return uret;
777 }
778
779 in_addr_t inet_lnaof(struct in_addr in) {
780         static in_addr_t (*inet_lnaofp)(struct in_addr in);
781         in_addr_t iret;
782
783         BEFORE_ORIGINAL_SOCK(inet_lnaof, LIBC);
784
785         iret = inet_lnaofp(in);
786
787         AFTER_ORIGINAL_LIBC_SOCK(VT_UINT32_T, iret, OBJ_DUMMY, 0, SOCKET_API_OTHER,
788                         NO_DESTINATIONINFO, "", "d", in.s_addr);
789
790         return iret;
791 }
792
793 in_addr_t inet_netof(struct in_addr in) {
794         static in_addr_t (*inet_netofp)(struct in_addr in);
795         in_addr_t iret;
796
797         BEFORE_ORIGINAL_SOCK(inet_netof, LIBC);
798
799         iret = inet_netofp(in);
800
801         AFTER_ORIGINAL_LIBC_SOCK(VT_UINT32_T, iret, OBJ_DUMMY, 0, SOCKET_API_OTHER,
802                         NO_DESTINATIONINFO, "", "d", in.s_addr);
803
804         return iret;
805 }
806
807 const char *inet_ntop(int af, const void *src, char *dst, socklen_t size) {
808         static const char* (*inet_ntopp)(int af, const void *src, char *dst,
809                         socklen_t size);
810         const char* cret;
811
812         BEFORE_ORIGINAL_SOCK(inet_ntop, LIBC);
813
814         cret = inet_ntopp(af, src, dst, size);
815
816         AFTER_ORIGINAL_LIBC_SOCK(cret, OBJ_DUMMY, 0, SOCKET_API_OTHER, "",
817                         NO_DESTINATIONINFO, "dppd", af, src, dst, size);
818
819         return cret;
820 }
821
822 int inet_pton(int af, const char *src, void *dst) {
823         static int (*inet_ptonp)(int af, const char *src, void *dst);
824
825         BEFORE_ORIGINAL_SOCK(inet_pton, LIBC);
826
827         ret = inet_ptonp(af, src, dst);
828
829         AFTER_ORIGINAL_LIBC_SOCK(ret, OBJ_DUMMY, 0, SOCKET_API_OTHER, "",
830                         NO_DESTINATIONINFO, "dpp", af, src, dst);
831
832         return ret;
833 }
834
835 int getaddrinfo(const char *node, const char *service,
836                 const struct addrinfo *hints, struct addrinfo **res) {
837         static int (*getaddrinfop)(const char *node, const char *service,
838                         const struct addrinfo *hints, struct addrinfo **res);
839
840         BEFORE_ORIGINAL_NOFILTER(getaddrinfo, LIBC);
841
842         ret = getaddrinfop(node, service, hints, res);
843
844         AFTER_ORIGINAL_LIBC_SOCK(ret, OBJ_DUMMY, 0, SOCKET_API_OTHER, "",
845                         NO_DESTINATIONINFO, "pppp", node, service, hints, res);
846
847         return ret;
848 }
849
850 void freeaddrinfo(struct addrinfo *res) {
851         static void (*freeaddrinfop)(struct addrinfo *res);
852
853         BEFORE_ORIGINAL_NOFILTER(freeaddrinfo, LIBC);
854
855         freeaddrinfop(res);
856
857         AFTER_ORIGINAL_LIBC_SOCK(NULL, OBJ_DUMMY, 0, SOCKET_API_OTHER, "",
858                         NO_DESTINATIONINFO, "p", res);
859 }
860
861 const char *gai_strerror(int errcode) {
862         static const char * (*gai_strerrorp)(int errcode);
863         const char * cret;
864
865         BEFORE_ORIGINAL_SOCK(gai_strerror, LIBC);
866
867         cret = gai_strerrorp(errcode);
868
869         AFTER_ORIGINAL_LIBC_SOCK(cret, OBJ_DUMMY, 0, SOCKET_API_OTHER, "",
870                         NO_DESTINATIONINFO, "d", errcode);
871
872         return cret;
873 }
874
875 int gai_suspend(const struct gaicb* const list[], int nitems,
876                 const struct timespec *timeout) {
877         static int (*gai_suspendp)(const struct gaicb* const list[], int nitems,
878                         const struct timespec *timeout);
879
880         BEFORE_ORIGINAL_SOCK(gai_suspend, LIBC);
881
882         ret = gai_suspendp(list, nitems, timeout);
883
884         AFTER_ORIGINAL_LIBC_SOCK(ret, OBJ_DUMMY, 0, SOCKET_API_OTHER, "",
885                         NO_DESTINATIONINFO, "pdp", list, nitems, timeout);
886
887         return ret;
888 }
889
890 int gai_error(struct gaicb *req) {
891         static int (*gai_errorp)(struct gaicb *req);
892
893         BEFORE_ORIGINAL_SOCK(gai_error, LIBC);
894
895         ret = gai_errorp(req);
896
897         AFTER_ORIGINAL_LIBC_SOCK(ret, OBJ_DUMMY, 0, SOCKET_API_OTHER, "",
898                         NO_DESTINATIONINFO, "p", req);
899
900         return ret;
901 }
902
903 int gai_cancel(struct gaicb *req) {
904         static int (*gai_cancelp)(struct gaicb *req);
905
906         BEFORE_ORIGINAL_SOCK(gai_cancel, LIBC);
907
908         ret = gai_cancelp(req);
909
910         AFTER_ORIGINAL_LIBC_SOCK(ret, OBJ_DUMMY, 0, SOCKET_API_OTHER, "",
911                         NO_DESTINATIONINFO, "p", req);
912
913         return ret;
914 }
915
916 int getaddrinfo_a(int mode, struct gaicb *list[], int nitems,
917                 struct sigevent *sevp) {
918         static int (*getaddrinfo_ap)(int mode, struct gaicb *list[], int nitems,
919                         struct sigevent *sevp);
920
921         BEFORE_ORIGINAL_SOCK(getaddrinfo_a, LIBC);
922
923         ret = getaddrinfo_ap(mode, list, nitems, sevp);
924
925         AFTER_ORIGINAL_LIBC_SOCK(ret, OBJ_DUMMY, 0, SOCKET_API_OTHER, "",
926                         NO_DESTINATIONINFO, "dpdp", mode, list, nitems, sevp);
927
928         return ret;
929 }
930
931 int getdomainname(char *name, size_t len) {
932         static int (*getdomainnamep)(char *name, size_t len);
933
934         BEFORE_ORIGINAL_SOCK(getdomainname, LIBC);
935
936         ret = getdomainnamep(name, len);
937
938         //AFTER_ORIGINAL_NOSOCK(FD_API_OTHER, "pd", name, len);
939
940         AFTER_ORIGINAL_LIBC_SOCK(ret, OBJ_DUMMY, 0, SOCKET_API_OTHER, "",
941                         NO_DESTINATIONINFO, "pd", name, len);
942
943         return ret;
944 }
945
946 int setdomainname(const char *name, size_t len) {
947         static int (*setdomainnamep)(const char *name, size_t len);
948
949         BEFORE_ORIGINAL_SOCK(setdomainname, LIBC);
950
951         ret = setdomainnamep(name, len);
952
953         AFTER_ORIGINAL_LIBC_SOCK(ret, OBJ_DUMMY, 0, SOCKET_API_OTHER, "",
954                         NO_DESTINATIONINFO, "pd", name, len);
955
956         return ret;
957 }
958
959 int gethostname(char *name, size_t len) {
960         static int (*gethostnamep)(char *name, size_t len);
961
962         BEFORE_ORIGINAL_SOCK(gethostname, LIBC);
963
964         ret = gethostnamep(name, len);
965
966         AFTER_ORIGINAL_LIBC_SOCK(ret, OBJ_DUMMY, 0, SOCKET_API_OTHER, "",
967                         NO_DESTINATIONINFO, "pd", name, len);
968
969         return ret;
970 }
971
972 int sethostname(const char *name, size_t len) {
973         static int (*sethostnamep)(const char *name, size_t len);
974
975         BEFORE_ORIGINAL_SOCK(sethostname, LIBC);
976
977         ret = sethostnamep(name, len);
978
979         AFTER_ORIGINAL_LIBC_SOCK(ret, OBJ_DUMMY, 0, SOCKET_API_OTHER, "",
980                         NO_DESTINATIONINFO, "pd", name, len);
981
982         return ret;
983 }
984
985 int getnameinfo(const struct sockaddr *sa, socklen_t salen, char *host,
986                 socklen_t hostlen, char *serv, socklen_t servlen, unsigned int flags) {
987         static int (*getnameinfop)(const struct sockaddr *sa, socklen_t salen,
988                         char *host, socklen_t hostlen, char *serv, socklen_t servlen,
989                         unsigned int flags);
990
991         BEFORE_ORIGINAL_SOCK(getnameinfo, LIBC);
992
993         ret = getnameinfop(sa, salen, host, hostlen, serv, servlen, flags);
994
995         AFTER_ORIGINAL_LIBC_SOCK(ret, OBJ_DUMMY, 0, SOCKET_API_OTHER, "",
996                         NO_DESTINATIONINFO, "pdpdpdd",
997                         sa, salen, host, hostlen, serv, servlen, flags);
998
999         return ret;
1000 }
1001
1002 struct hostent *gethostbyname(const char *name) {
1003         static struct hostent * (*gethostbynamep)(const char *name);
1004         struct hostent* pret;
1005
1006         BEFORE_ORIGINAL_SOCK(gethostbyname, LIBC);
1007
1008         pret = gethostbynamep(name);
1009
1010         AFTER_ORIGINAL_LIBC_SOCK(pret, OBJ_DUMMY, 0, SOCKET_API_OTHER, "",
1011                         NO_DESTINATIONINFO, "p", name);
1012
1013         return pret;
1014 }
1015
1016 struct hostent *gethostbyaddr(const void *addr, socklen_t len, int type) {
1017         static struct hostent * (*gethostbyaddrp)(const void *addr, socklen_t len,
1018                         int type);
1019         struct hostent* pret;
1020
1021         BEFORE_ORIGINAL_SOCK(gethostbyaddr, LIBC);
1022
1023         pret = gethostbyaddrp(addr, len, type);
1024
1025         AFTER_ORIGINAL_LIBC_SOCK(pret, OBJ_DUMMY, 0, SOCKET_API_OTHER, "",
1026                         NO_DESTINATIONINFO, "pdd", addr, len, type);
1027
1028         return pret;
1029 }
1030
1031 void sethostent(int stayopen) {
1032         static void (*sethostentp)(int stayopen);
1033
1034         BEFORE_ORIGINAL_SOCK(sethostent, LIBC);
1035
1036         sethostentp(stayopen);
1037
1038         AFTER_ORIGINAL_LIBC_SOCK(NULL, OBJ_DUMMY, 0, SOCKET_API_OTHER, "",
1039                         NO_DESTINATIONINFO, "d", stayopen);
1040 }
1041
1042 void endhostent(void) {
1043         static void (*endhostentp)(void);
1044
1045         BEFORE_ORIGINAL_SOCK(endhostent, LIBC);
1046
1047         endhostentp();
1048
1049         //AFTER_ORIGINAL_NOSOCK_RET(NULL, 0, FD_API_OTHER, "s", "");
1050
1051         AFTER_ORIGINAL_LIBC_SOCK(NULL, OBJ_DUMMY, 0, SOCKET_API_OTHER, "",
1052                         NO_DESTINATIONINFO, "s", "");
1053 }
1054
1055 void herror(const char *s) {
1056         static void (*herrorp)(const char *s);
1057
1058         BEFORE_ORIGINAL_SOCK(herror, LIBC);
1059
1060         herrorp(s);
1061
1062         AFTER_ORIGINAL_LIBC_SOCK(NULL, OBJ_DUMMY, 0, SOCKET_API_OTHER, "",
1063                         NO_DESTINATIONINFO, "p", s);
1064 }
1065
1066 const char *hstrerror(int err) {
1067         static const char* (*hstrerrorp)(int err);
1068         const char* cret;
1069
1070         BEFORE_ORIGINAL_SOCK(hstrerror, LIBC);
1071
1072         cret = hstrerrorp(err);
1073
1074         AFTER_ORIGINAL_LIBC_SOCK(cret, OBJ_DUMMY, 0, SOCKET_API_OTHER, "",
1075                         NO_DESTINATIONINFO, "d", err);
1076
1077         return cret;
1078 }
1079
1080 struct hostent *gethostent(void) {
1081         static struct hostent* (*gethostentp)(void);
1082         struct hostent* pret;
1083
1084         BEFORE_ORIGINAL_SOCK(gethostent, LIBC);
1085
1086         pret = gethostentp();
1087
1088         AFTER_ORIGINAL_LIBC_SOCK(pret, OBJ_DUMMY, 0, SOCKET_API_OTHER, "",
1089                         NO_DESTINATIONINFO, "s", "");
1090
1091         return pret;
1092 }
1093
1094 struct hostent *gethostbyname2(const char *name, int af) {
1095         static struct hostent * (*gethostbyname2p)(const char *name, int af);
1096         struct hostent* pret;
1097
1098         BEFORE_ORIGINAL_SOCK(gethostbyname2, LIBC);
1099
1100         pret = gethostbyname2p(name, af);
1101
1102         AFTER_ORIGINAL_LIBC_SOCK(pret, OBJ_DUMMY, 0, SOCKET_API_OTHER, "",
1103                         NO_DESTINATIONINFO, "pd", name, af);
1104
1105         return pret;
1106 }
1107
1108 int gethostent_r(struct hostent *rret, char *buf, size_t buflen,
1109                 struct hostent **result, int *h_errnop) {
1110         static int (*gethostent_rp)(struct hostent *rret, char *buf, size_t buflen,
1111                         struct hostent **result, int *h_errnop);
1112
1113         BEFORE_ORIGINAL_SOCK(gethostent_r, LIBC);
1114
1115         ret = gethostent_rp(rret, buf, buflen, result, h_errnop);
1116
1117         AFTER_ORIGINAL_LIBC_SOCK(ret, OBJ_DUMMY, 0, SOCKET_API_OTHER, "",
1118                         NO_DESTINATIONINFO, "ppdpp", rret, buf, buflen, result, h_errnop);
1119
1120         return ret;
1121 }
1122
1123 int gethostbyaddr_r(const void *addr, socklen_t len, int type,
1124                 struct hostent *rret, char *buf, size_t buflen, struct hostent **result,
1125                 int *h_errnop) {
1126         static int (*gethostbyaddr_rp)(const void *addr, socklen_t len, int type,
1127                         struct hostent *rret, char *buf, size_t buflen,
1128                         struct hostent **result, int *h_errnop);
1129
1130         BEFORE_ORIGINAL_SOCK(gethostbyaddr_r, LIBC);
1131
1132         ret = gethostbyaddr_rp(addr, len, type, rret, buf, buflen, result,
1133                         h_errnop);
1134
1135         AFTER_ORIGINAL_LIBC_SOCK(ret, OBJ_DUMMY, 0, SOCKET_API_OTHER, "",
1136                         NO_DESTINATIONINFO, "pddppdpp",
1137                         addr, len, type, rret, buf, buflen, result, h_errnop);
1138
1139         return ret;
1140 }
1141
1142 int gethostbyname_r(const char *name, struct hostent *rret, char *buf,
1143                 size_t buflen, struct hostent **result, int *h_errnop) {
1144         static int (*gethostbyname_rp)(const char *name, struct hostent *rret,
1145                         char *buf, size_t buflen, struct hostent **result, int *h_errnop);
1146
1147         BEFORE_ORIGINAL_SOCK(gethostbyname_r, LIBC);
1148
1149         ret = gethostbyname_rp(name, rret, buf, buflen, result, h_errnop);
1150
1151         AFTER_ORIGINAL_LIBC_SOCK(ret, OBJ_DUMMY, 0, SOCKET_API_OTHER, "",
1152                         NO_DESTINATIONINFO, "pppdpp",
1153                         name, rret, buf, buflen, result, h_errnop);
1154
1155         return ret;
1156 }
1157
1158 int gethostbyname2_r(const char *name, int af, struct hostent *rret, char *buf,
1159                 size_t buflen, struct hostent **result, int *h_errnop) {
1160         static int (*gethostbyname2_rp)(const char *name, int af,
1161                         struct hostent *rret, char *buf, size_t buflen,
1162                         struct hostent **result, int *h_errnop);
1163
1164         BEFORE_ORIGINAL_SOCK(gethostbyname2_r, LIBC);
1165
1166         ret = gethostbyname2_rp(name, af, rret, buf, buflen, result, h_errnop);
1167
1168         AFTER_ORIGINAL_LIBC_SOCK(ret, OBJ_DUMMY, 0, SOCKET_API_OTHER, "",
1169                         NO_DESTINATIONINFO, "pdppdpp",
1170                         name, af, rret, buf, buflen, result, h_errnop);
1171
1172         return ret;
1173 }
1174
1175 struct servent *getservbyname(const char *name, const char *proto) {
1176         static struct servent * (*getservbynamep)(const char *name,
1177                         const char *proto);
1178         struct servent* pret;
1179
1180         BEFORE_ORIGINAL_SOCK(getservbyname, LIBC);
1181
1182         pret = getservbynamep(name, proto);
1183
1184         AFTER_ORIGINAL_LIBC_SOCK(pret, OBJ_DUMMY, 0, SOCKET_API_OTHER, "",
1185                         NO_DESTINATIONINFO, "pp", name, proto);
1186
1187         return pret;
1188 }
1189
1190 void setservent(int stayopen) {
1191         static void (*setserventp)(int stayopen);
1192
1193         BEFORE_ORIGINAL_SOCK(setservent, LIBC);
1194
1195         setserventp(stayopen);
1196
1197         AFTER_ORIGINAL_LIBC_SOCK(NULL, OBJ_DUMMY, 0, SOCKET_API_OTHER, "",
1198                         NO_DESTINATIONINFO, "d", stayopen);
1199 }
1200
1201 void endservent(void) {
1202         static void (*endserventp)(void);
1203
1204         BEFORE_ORIGINAL_SOCK(endservent, LIBC);
1205
1206         endserventp();
1207
1208         AFTER_ORIGINAL_LIBC_SOCK(NULL, OBJ_DUMMY, 0, SOCKET_API_OTHER, "",
1209                         NO_DESTINATIONINFO, "s", "");
1210 }
1211
1212 struct servent *getservent(void) {
1213         static struct servent * (*getserventp)(void);
1214         struct servent* pret;
1215
1216         BEFORE_ORIGINAL_SOCK(getservent, LIBC);
1217
1218         pret = getserventp();
1219
1220         AFTER_ORIGINAL_LIBC_SOCK(pret, OBJ_DUMMY, 0, SOCKET_API_OTHER, "",
1221                         NO_DESTINATIONINFO, "s", "");
1222
1223         return pret;
1224 }
1225
1226 struct servent *getservbyport(int port, const char *proto) {
1227         static struct servent * (*getservbyportp)(int port, const char *proto);
1228         struct servent* pret;
1229
1230         BEFORE_ORIGINAL_SOCK(getservbyport, LIBC);
1231
1232         pret = getservbyportp(port, proto);
1233
1234         AFTER_ORIGINAL_LIBC_SOCK(pret, OBJ_DUMMY, 0, SOCKET_API_OTHER, "",
1235                         NO_DESTINATIONINFO, "dp", port, proto);
1236
1237         return pret;
1238 }
1239
1240 int getservent_r(struct servent *result_buf, char *buf, size_t buflen,
1241                 struct servent **result) {
1242         static int (*getservent_rp)(struct servent *result_buf, char *buf,
1243                         size_t buflen, struct servent **result);
1244
1245         BEFORE_ORIGINAL_SOCK(getservent_r, LIBC);
1246
1247         ret = getservent_rp(result_buf, buf, buflen, result);
1248
1249         AFTER_ORIGINAL_LIBC_SOCK(ret, OBJ_DUMMY, 0, SOCKET_API_OTHER, "",
1250                         NO_DESTINATIONINFO, "ppdp", result_buf, buf, buflen, result);
1251
1252         return ret;
1253 }
1254
1255 int getservbyname_r(const char *name, const char *proto,
1256                 struct servent *result_buf, char *buf, size_t buflen,
1257                 struct servent **result) {
1258         static int (*getservbyname_rp)(const char *name, const char *proto,
1259                         struct servent *result_buf, char *buf, size_t buflen,
1260                         struct servent **result);
1261
1262         BEFORE_ORIGINAL_SOCK(getservbyname_r, LIBC);
1263
1264         ret = getservbyname_rp(name, proto, result_buf, buf, buflen, result);
1265
1266         AFTER_ORIGINAL_LIBC_SOCK(ret, OBJ_DUMMY, 0, SOCKET_API_OTHER, "",
1267                         NO_DESTINATIONINFO, "ppppdp",
1268                         name, proto, result_buf, buf, buflen, result);
1269
1270         return ret;
1271 }
1272
1273 int getservbyport_r(int port, const char *proto, struct servent *result_buf,
1274                 char *buf, size_t buflen, struct servent **result) {
1275         static int (*getservbyport_rp)(int port, const char *proto,
1276                         struct servent *result_buf, char *buf, size_t buflen,
1277                         struct servent **result);
1278
1279         BEFORE_ORIGINAL_SOCK(getservbyport_r, LIBC);
1280
1281         ret = getservbyport_rp(port, proto, result_buf, buf, buflen, result);
1282
1283         AFTER_ORIGINAL_LIBC_SOCK(ret, OBJ_DUMMY, 0, SOCKET_API_OTHER, "",
1284                         NO_DESTINATIONINFO, "dpppdp",
1285                         port, proto, result_buf, buf, buflen, result);
1286
1287         return ret;
1288 }
1289
1290 struct netent* getnetent(void) {
1291         static struct netent * (*getnetentp)(void);
1292         struct netent* pret;
1293
1294         BEFORE_ORIGINAL_SOCK(getnetent, LIBC);
1295
1296         pret = getnetentp();
1297
1298         AFTER_ORIGINAL_LIBC_SOCK(pret, OBJ_DUMMY, 0, SOCKET_API_OTHER, "",
1299                         NO_DESTINATIONINFO, "s", "");
1300
1301         return pret;
1302 }
1303
1304 struct netent *getnetbyname(const char *name) {
1305         static struct netent * (*getnetbynamep)(const char *name);
1306         struct netent* pret;
1307
1308         BEFORE_ORIGINAL_SOCK(getnetbyname, LIBC);
1309
1310         pret = getnetbynamep(name);
1311
1312         AFTER_ORIGINAL_LIBC_SOCK(pret, OBJ_DUMMY, 0, SOCKET_API_OTHER, "",
1313                         NO_DESTINATIONINFO, "p", name);
1314
1315         return pret;
1316 }
1317
1318 struct netent *getnetbyaddr(uint32_t net, int type) {
1319         static struct netent * (*getnetbyaddrp)(uint32_t net, int type);
1320         struct netent * pret;
1321
1322         BEFORE_ORIGINAL_SOCK(getnetbyaddr, LIBC);
1323
1324         pret = getnetbyaddrp(net, type);
1325
1326         AFTER_ORIGINAL_LIBC_SOCK(pret, OBJ_DUMMY, 0, SOCKET_API_OTHER, "",
1327                         NO_DESTINATIONINFO, "dd", net, type);
1328
1329         return pret;
1330 }
1331
1332 void setnetent(int stayopen) {
1333         static void (*setnetentp)(int stayopen);
1334
1335         BEFORE_ORIGINAL_SOCK(setnetent, LIBC);
1336
1337         setnetentp(stayopen);
1338
1339         AFTER_ORIGINAL_LIBC_SOCK(NULL, OBJ_DUMMY, 0, SOCKET_API_OTHER, "",
1340                         NO_DESTINATIONINFO, "d", stayopen);
1341 }
1342
1343 void endnetent(void) {
1344         static void (*endnetentp)(void);
1345
1346         BEFORE_ORIGINAL_SOCK(endnetent, LIBC);
1347
1348         endnetentp();
1349
1350         AFTER_ORIGINAL_LIBC_SOCK(NULL, OBJ_DUMMY, 0, SOCKET_API_OTHER, "",
1351                         NO_DESTINATIONINFO, "s", "");
1352 }
1353
1354 int getnetent_r(struct netent *result_buf, char *buf, size_t buflen,
1355                 struct netent **result, int *h_errnop) {
1356         static int (*getnetent_rp)(struct netent *result_buf, char *buf,
1357                         size_t buflen, struct netent **result, int *h_errnop);
1358
1359         BEFORE_ORIGINAL_SOCK(getnetent_r, LIBC);
1360
1361         ret = getnetent_rp(result_buf, buf, buflen, result, h_errnop);
1362
1363         AFTER_ORIGINAL_LIBC_SOCK(ret, OBJ_DUMMY, 0, SOCKET_API_OTHER, "",
1364                         NO_DESTINATIONINFO, "ppdpp",
1365                         result_buf, buf, buflen, result, h_errnop);
1366
1367         return ret;
1368 }
1369
1370 int getnetbyname_r(const char *name, struct netent *result_buf, char *buf,
1371                 size_t buflen, struct netent **result, int *h_errnop) {
1372         static int (*getnetbyname_rp)(const char *name, struct netent *result_buf,
1373                         char *buf, size_t buflen, struct netent **result, int *h_errnop);
1374
1375         BEFORE_ORIGINAL_SOCK(getnetbyname_r, LIBC);
1376
1377         ret = getnetbyname_rp(name, result_buf, buf, buflen, result, h_errnop);
1378
1379         AFTER_ORIGINAL_LIBC_SOCK(ret, OBJ_DUMMY, 0, SOCKET_API_OTHER, "",
1380                         NO_DESTINATIONINFO, "pppdpp",
1381                         name, result_buf, buf, buflen, result, h_errnop);
1382
1383         return ret;
1384 }
1385
1386 int getnetbyaddr_r(uint32_t net, int type, struct netent *result_buf, char *buf,
1387                 size_t buflen, struct netent **result, int *h_errnop) {
1388         static int (*getnetbyaddr_rp)(uint32_t net, int type,
1389                         struct netent *result_buf, char *buf, size_t buflen,
1390                         struct netent **result, int *h_errnop);
1391
1392         BEFORE_ORIGINAL_SOCK(getnetbyaddr_r, LIBC);
1393
1394         ret = getnetbyaddr_rp(net, type, result_buf, buf, buflen, result, h_errnop);
1395
1396         AFTER_ORIGINAL_LIBC_SOCK(ret, OBJ_DUMMY, 0, SOCKET_API_OTHER, "",
1397                         NO_DESTINATIONINFO, "ddppdpp",
1398                         net, type, result_buf, buf, buflen, result, h_errnop);
1399
1400         return ret;
1401 }
1402
1403 struct protoent *getprotoent(void) {
1404         static struct protoent * (*getprotoentp)(void);
1405         struct protoent * pret;
1406
1407         BEFORE_ORIGINAL_SOCK(getprotoent, LIBC);
1408
1409         pret = getprotoentp();
1410
1411         AFTER_ORIGINAL_LIBC_SOCK(pret, OBJ_DUMMY, 0, SOCKET_API_OTHER, "",
1412                         NO_DESTINATIONINFO, "s", "");
1413
1414         return pret;
1415 }
1416
1417 struct protoent *getprotobyname(const char *name) {
1418         static struct protoent * (*getprotobynamep)(const char *name);
1419         struct protoent * pret;
1420
1421         BEFORE_ORIGINAL_SOCK(getprotobyname, LIBC);
1422
1423         pret = getprotobynamep(name);
1424
1425         AFTER_ORIGINAL_LIBC_SOCK(pret, OBJ_DUMMY, 0, SOCKET_API_OTHER, "",
1426                         NO_DESTINATIONINFO, "p", name);
1427
1428         return pret;
1429 }
1430
1431 struct protoent *getprotobynumber(int proto) {
1432         static struct protoent * (*getprotobynumberp)(int proto);
1433         struct protoent * pret;
1434
1435         BEFORE_ORIGINAL_SOCK(getprotobynumber, LIBC);
1436
1437         pret = getprotobynumberp(proto);
1438
1439         AFTER_ORIGINAL_LIBC_SOCK(pret, OBJ_DUMMY, 0, SOCKET_API_OTHER, "",
1440                         NO_DESTINATIONINFO, "d", proto);
1441
1442         return pret;
1443 }
1444
1445 void setprotoent(int stayopen) {
1446         static void (*setprotoentp)(int stayopen);
1447
1448         BEFORE_ORIGINAL_SOCK(setprotoent, LIBC);
1449
1450         setprotoentp(stayopen);
1451
1452         AFTER_ORIGINAL_LIBC_SOCK(NULL, OBJ_DUMMY, 0, SOCKET_API_OTHER, "",
1453                         NO_DESTINATIONINFO, "d", stayopen);
1454 }
1455
1456 void endprotoent(void) {
1457         static void (*endprotoentp)(void);
1458
1459         BEFORE_ORIGINAL_SOCK(endprotoent, LIBC);
1460
1461         endprotoentp();
1462
1463         AFTER_ORIGINAL_LIBC_SOCK(NULL, OBJ_DUMMY, 0, SOCKET_API_OTHER, "",
1464                         NO_DESTINATIONINFO, "s", "");
1465 }
1466
1467 int getprotoent_r(struct protoent *result_buf, char *buf, size_t buflen,
1468                 struct protoent **result) {
1469         static int (*getprotoent_rp)(struct protoent *result_buf, char *buf,
1470                         size_t buflen, struct protoent **result);
1471
1472         BEFORE_ORIGINAL_SOCK(getprotoent_r, LIBC);
1473
1474         ret = getprotoent_rp(result_buf, buf, buflen, result);
1475
1476         AFTER_ORIGINAL_LIBC_SOCK(ret, OBJ_DUMMY, 0, SOCKET_API_OTHER, "",
1477                         NO_DESTINATIONINFO, "ppdp", result_buf, buf, buflen, result);
1478
1479         return ret;
1480 }
1481
1482 int getprotobyname_r(const char *name, struct protoent *result_buf, char *buf,
1483                 size_t buflen, struct protoent **result) {
1484         static int (*getprotobyname_rp)(const char *name,
1485                         struct protoent *result_buf, char *buf, size_t buflen,
1486                         struct protoent **result);
1487
1488         BEFORE_ORIGINAL_SOCK(getprotobyname_r, LIBC);
1489
1490         ret = getprotobyname_rp(name, result_buf, buf, buflen, result);
1491
1492         AFTER_ORIGINAL_LIBC_SOCK(ret, OBJ_DUMMY, 0, SOCKET_API_OTHER, "",
1493                         NO_DESTINATIONINFO, "pppdp", name, result_buf, buf, buflen, result);
1494
1495         return ret;
1496 }
1497
1498 int getprotobynumber_r(int proto, struct protoent *result_buf, char *buf,
1499                 size_t buflen, struct protoent **result) {
1500         static int (*getprotobynumber_rp)(int proto, struct protoent *result_buf,
1501                         char *buf, size_t buflen, struct protoent **result);
1502
1503         BEFORE_ORIGINAL_SOCK(getprotobynumber_r, LIBC);
1504
1505         ret = getprotobynumber_rp(proto, result_buf, buf, buflen, result);
1506
1507         AFTER_ORIGINAL_LIBC_SOCK(ret, OBJ_DUMMY, 0, SOCKET_API_OTHER, "",
1508                         NO_DESTINATIONINFO, "dppdp", proto, result_buf, buf, buflen, result);
1509
1510         return ret;
1511 }
1512
1513 unsigned int if_nametoindex(__const char *__ifname) {
1514         static unsigned int (*if_nametoindexp)(__const char *__ifname);
1515         unsigned int uret;
1516
1517         BEFORE_ORIGINAL_SOCK(if_nametoindex, LIBC);
1518
1519         uret = if_nametoindexp(__ifname);
1520
1521         AFTER_ORIGINAL_LIBC_SOCK(uret, OBJ_DUMMY, 0, SOCKET_API_OTHER, "",
1522                         NO_DESTINATIONINFO, "p", __ifname);
1523
1524         return uret;
1525 }
1526
1527 char *if_indextoname(unsigned int __ifindex, char *__ifname) {
1528         static char * (*if_indextonamep)(unsigned int __ifindex, char *__ifname);
1529         char * cret;
1530
1531         BEFORE_ORIGINAL_SOCK(if_indextoname, LIBC);
1532
1533         cret = if_indextonamep(__ifindex, __ifname);
1534
1535         AFTER_ORIGINAL_LIBC_SOCK(cret, OBJ_DUMMY, 0, SOCKET_API_OTHER, "",
1536                         NO_DESTINATIONINFO, "dp", __ifindex, __ifname);
1537
1538         return cret;
1539 }
1540
1541 struct if_nameindex *if_nameindex(void) {
1542         static struct if_nameindex * (*if_nameindexp)(void);
1543         struct if_nameindex * pret;
1544
1545         BEFORE_ORIGINAL_NOFILTER(if_nameindex, LIBC);
1546
1547         pret = if_nameindexp();
1548
1549         AFTER_ORIGINAL_LIBC_SOCK(pret, OBJ_DUMMY, 0, SOCKET_API_OTHER, "",
1550                         NO_DESTINATIONINFO, "s", "");
1551
1552         return pret;
1553 }
1554
1555 void if_freenameindex(struct if_nameindex *__ptr) {
1556         static void (*if_freenameindexp)(struct if_nameindex *__ptr);
1557
1558         BEFORE_ORIGINAL_NOFILTER(if_freenameindex, LIBC);
1559
1560         if_freenameindexp(__ptr);
1561
1562         AFTER_ORIGINAL_LIBC_SOCK(NULL, OBJ_DUMMY, 0, SOCKET_API_OTHER, "",
1563                         NO_DESTINATIONINFO, "p", __ptr);
1564 }
1565
1566 int getifaddrs(struct ifaddrs **ifap) {
1567         static int (*getifaddrsp)(struct ifaddrs **ifap);
1568
1569         BEFORE_ORIGINAL_NOFILTER(getifaddrs, LIBC);
1570
1571         ret = getifaddrsp(ifap);
1572
1573         AFTER_ORIGINAL_LIBC_SOCK(ret, OBJ_DUMMY, 0, SOCKET_API_OTHER, "",
1574                         NO_DESTINATIONINFO, "p", ifap);
1575
1576         return ret;
1577 }
1578
1579 void freeifaddrs(struct ifaddrs *ifa) {
1580         static void (*freeifaddrsp)(struct ifaddrs *ifa);
1581
1582         BEFORE_ORIGINAL_NOFILTER(freeifaddrs, LIBC);
1583
1584         freeifaddrsp(ifa);
1585
1586         AFTER_ORIGINAL_LIBC_SOCK(NULL, OBJ_DUMMY, 0, SOCKET_API_OTHER, "",
1587                         NO_DESTINATIONINFO, "p", ifa);
1588 }
1589
1590 //To do
1591
1592 uint16_t htobe16(uint16_t host_16bits)
1593 {
1594         static uint16_t (*htobe16p)(uint16_t host_16bits);
1595         uint16_t uret;
1596
1597         BEFORE_ORIGINAL_SOCK(htobe16, LIBC);
1598
1599         uret = htobe16p(host_16bits);
1600
1601         AFTER_ORIGINAL_NOSOCK_RET(VT_UINT16_T, uret, 0, FD_API_OTHER, "d", host_16bits);
1602
1603         return uret;
1604 }
1605
1606 uint16_t htole16(uint16_t host_16bits)
1607 {
1608         static uint16_t (*htole16p)(uint16_t host_16bits);
1609         uint16_t uret;
1610
1611         BEFORE_ORIGINAL_SOCK(htole16, LIBC);
1612
1613         uret = htole16p(host_16bits);
1614
1615         AFTER_ORIGINAL_NOSOCK_RET(VT_UINT16_T, uret, 0, FD_API_OTHER, "d", host_16bits);
1616
1617         return uret;
1618 }
1619
1620 uint16_t be16toh(uint16_t big_endian_16bits)
1621 {
1622         static uint16_t (*be16tohp)(uint16_t big_endian_16bits);
1623         uint16_t uret;
1624
1625         BEFORE_ORIGINAL_SOCK(be16toh, LIBC);
1626
1627         uret = be16tohp(big_endian_16bits);
1628
1629         AFTER_ORIGINAL_NOSOCK_RET(VT_UINT16_T, uret, 0, FD_API_OTHER,
1630                         "d", big_endian_16bits);
1631
1632         return uret;
1633 }
1634
1635 uint16_t le16toh(uint16_t little_endian_16bits)
1636 {
1637         static uint16_t (*le16tohp)(uint16_t little_endian_16bits);
1638         uint16_t uret;
1639
1640         BEFORE_ORIGINAL_SOCK(le16toh, LIBC);
1641
1642         uret = le16tohp(little_endian_16bits);
1643
1644         AFTER_ORIGINAL_NOSOCK_RET(VT_UINT16_T, uret, 0, FD_API_OTHER,
1645                         "d", little_endian_16bits);
1646
1647         return uret;
1648 }
1649
1650 uint32_t htobe32(uint32_t host_32bits)
1651 {
1652         static uint32_t (*htobe32p)(uint32_t host_32bits);
1653         uint32_t uret;
1654
1655         BEFORE_ORIGINAL_SOCK(htobe32, LIBC);
1656
1657         uret = htobe32p(host_32bits);
1658
1659         AFTER_ORIGINAL_NOSOCK_RET(VT_UINT32_T, uret, 0, FD_API_OTHER,
1660                         "d", host_32bits);
1661
1662         return uret;
1663 }
1664
1665 uint32_t htole32(uint32_t host_32bits)
1666 {
1667         static uint32_t (*htole32p)(uint32_t host_32bits);
1668         uint32_t uret;
1669
1670         BEFORE_ORIGINAL_SOCK(htole32, LIBC);
1671
1672         uret = htole32p(host_32bits);
1673
1674         AFTER_ORIGINAL_NOSOCK_RET(VT_UINT32_T, uret, 0, FD_API_OTHER,
1675                         "d", host_32bits);
1676
1677         return uret;
1678 }
1679
1680 uint32_t be32toh(uint32_t big_endian_32bits)
1681 {
1682         static uint32_t (*be32tohp)(uint32_t big_endian_32bits);
1683         uint32_t uret;
1684
1685         BEFORE_ORIGINAL_SOCK(be32toh, LIBC);
1686
1687         uret = be32tohp(big_endian_32bits);
1688
1689         AFTER_ORIGINAL_NOSOCK_RET(VT_UINT32_T, uret, 0, FD_API_OTHER,
1690                         "d", big_endian_32bits);
1691
1692         return uret;
1693 }
1694
1695 uint32_t le32toh(uint32_t little_endian_32bits)
1696 {
1697         static uint32_t (*le32tohp)(uint32_t little_endian_32bits);
1698         uint32_t uret;
1699
1700         BEFORE_ORIGINAL_SOCK(le32toh, LIBC);
1701
1702         uret = le32tohp(little_endian_32bits);
1703
1704         AFTER_ORIGINAL_NOSOCK_RET(VT_UINT32_T, uret, 0, FD_API_OTHER,
1705                         "d", little_endian_32bits);
1706
1707         return uret;
1708 }
1709
1710 uint64_t htobe64(uint64_t host_64bits)
1711 {
1712         static uint64_t (*htobe64p)(uint64_t host_64bits);
1713         uint64_t uret;
1714
1715         BEFORE_ORIGINAL_SOCK(htobe64, LIBC);
1716
1717         uret = htobe64p(host_64bits);
1718
1719         AFTER_ORIGINAL_NOSOCK_RET(VT_UINT64_T, uret, 0, FD_API_OTHER,
1720                         "d", host_64bits);
1721
1722         return uret;
1723 }
1724
1725 uint64_t htole64(uint64_t host_64bits)
1726 {
1727         static uint64_t (*htole64p)(uint64_t host_64bits);
1728         uint64_t uret;
1729
1730         BEFORE_ORIGINAL_SOCK(htole64, LIBC);
1731
1732         uret = htole64p(host_64bits);
1733
1734         AFTER_ORIGINAL_NOSOCK_RET(VT_UINT64_T, uret, 0, FD_API_OTHER,
1735                         "d", host_64bits);
1736
1737         return uret;
1738 }
1739
1740 uint64_t be64toh(uint64_t big_endian_64bits)
1741 {
1742         static uint64_t (*be64tohp)(uint64_t big_endian_64bits);
1743         uint64_t uret;
1744
1745         BEFORE_ORIGINAL_SOCK(be64toh, LIBC);
1746
1747         uret = be64tohp(big_endian_64bits);
1748
1749         AFTER_ORIGINAL_NOSOCK_RET(VT_UINT64_T, uret, 0, FD_API_OTHER,
1750                         "d", big_endian_64bits);
1751
1752         return uret;
1753 }
1754
1755 uint64_t le64toh(uint64_t little_endian_64bits)
1756 {
1757         static uint64_t (*le64tohp)(uint64_t little_endian_64bits);
1758         uint64_t uret;
1759
1760         BEFORE_ORIGINAL_SOCK(le64toh, LIBC);
1761
1762         uret = le64tohp(little_endian_64bits);
1763
1764         AFTER_ORIGINAL_NOSOCK_RET(VT_UINT64_T, uret, 0, FD_API_OTHER,
1765                         "d", little_endian_64bits);
1766
1767         return uret;
1768 }
1769
1770 struct in_addr inet_makeaddr(int net, int host)
1771 {
1772         static struct in_addr (*inet_makeaddrp)(int net, int host);
1773         struct in_addr iret;
1774
1775         BEFORE_ORIGINAL_SOCK(inet_makeaddr, LIBC);
1776
1777         iret = inet_makeaddrp(net,host);
1778
1779         AFTER_ORIGINAL_NOSOCK_RET(VT_UINT32_T, iret.s_addr, 0, FD_API_OTHER,
1780                         "dd", net, host);
1781
1782         return iret;
1783 }
1784
1785 #endif