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