Rizin
unix-like reverse engineering framework and cli tools
sfsocketcall.h
Go to the documentation of this file.
1 /*
2  * sfsocketcall.h -- linux socket implementation
3  * see http://www.secdev.org/projects/shellforge.html
4  * for more informations
5  *
6  * Copyright (C) 2003 Philippe Biondi <biondi@cartel-securite.fr>
7  *
8  * This program is free software; you can redistribute it and/or modify it
9  * under the terms of the GNU Lesser General Public License as published by
10  * the Free Software Foundation.
11  *
12  * This program is distributed in the hope that it will be useful, but
13  * WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  * Lesser General Public License for more details.
16  */
17 
18 /* $Id$ */
19 
20 #ifndef SFSOCKETCALL_H
21 #define SFSOCKETCALL_H
22 
23 int socketcall(int call, unsigned long *args);
24 
25 #define SYS_socket 1 /* sys_socket(2) */
26 #define SYS_bind 2 /* sys_bind(2) */
27 #define SYS_connect 3 /* sys_connect(2) */
28 #define SYS_listen 4 /* sys_listen(2) */
29 #define SYS_accept 5 /* sys_accept(2) */
30 #define SYS_getsockname 6 /* sys_getsockname(2) */
31 #define SYS_getpeername 7 /* sys_getpeername(2) */
32 #define SYS_socketpair 8 /* sys_socketpair(2) */
33 #define SYS_send 9 /* sys_send(2) */
34 #define SYS_recv 10 /* sys_recv(2) */
35 #define SYS_sendto 11 /* sys_sendto(2) */
36 #define SYS_recvfrom 12 /* sys_recvfrom(2) */
37 #define SYS_shutdown 13 /* sys_shutdown(2) */
38 #define SYS_setsockopt 14 /* sys_setsockopt(2) */
39 #define SYS_getsockopt 15 /* sys_getsockopt(2) */
40 #define SYS_sendmsg 16 /* sys_sendmsg(2) */
41 #define SYS_recvmsg 17 /* sys_recvmsg(2) */
42 
43 
44 #define __sys_socketcall0(type, name) \
45 type name(void) \
46 { \
47  return socketcall(SYS_##name, 0); \
48 }
49 
50 #define __sys_socketcall1(type, name, type0, arg0) \
51 type name(type0 arg0) \
52 { \
53  unsigned long arr[1]; \
54  arr[0] = (long)arg0; \
55  return socketcall(SYS_##name, arr); \
56 }
57 
58 #define __sys_socketcall2(type, name, type0,arg0, type1,arg1) \
59 type name(type0 arg0, type1 arg1) \
60 { \
61  unsigned long arr[2]; \
62  arr[0] = (long)arg0; \
63  arr[1] = (long)arg1; \
64  return socketcall(SYS_##name, arr); \
65 }
66 
67 #define __sys_socketcall3(type, name, type0,arg0, type1,arg1, type2,arg2) \
68 type name(type0 arg0, type1 arg1, type2 arg2) \
69 { \
70  unsigned long arr[3]; \
71  arr[0] = (long)arg0; \
72  arr[1] = (long)arg1; \
73  arr[2] = (long)arg2; \
74  return socketcall(SYS_##name, arr); \
75 }
76 
77 #define __sys_socketcall4(type, name, type0,arg0, type1,arg1, type2,arg2, type3,arg3) \
78 type name(type0 arg0, type1 arg1, type2 arg2, type3 arg3) \
79 { \
80  unsigned long arr[4]; \
81  arr[0] = (long)arg0; \
82  arr[1] = (long)arg1; \
83  arr[2] = (long)arg2; \
84  arr[3] = (long)arg3; \
85  return socketcall(SYS_##name, arr); \
86 }
87 
88 #define __sys_socketcall5(type, name, type0,arg0, type1,arg1, type2,arg2, type3,arg3, type4,arg4) \
89 type name(type0 arg0, type1 arg1, type2 arg2, type3 arg3, type4 arg4) \
90 { \
91  unsigned long arr[5]; \
92  arr[0] = (long)arg0; \
93  arr[1] = (long)arg1; \
94  arr[2] = (long)arg2; \
95  arr[3] = (long)arg3; \
96  arr[4] = (long)arg4; \
97  return socketcall(SYS_##name, arr); \
98 }
99 
100 #define __sys_socketcall6(type, name, type0,arg0, type1,arg1, type2,arg2, type3,arg3, type4,arg4, type5,arg5) \
101 type name(type0 arg0, type1 arg1, type2 arg2, type3 arg3, type4 arg4, type5 arg5) \
102 { \
103  unsigned long arr[6]; \
104  arr[0] = (long)arg0; \
105  arr[1] = (long)arg1; \
106  arr[2] = (long)arg2; \
107  arr[3] = (long)arg3; \
108  arr[4] = (long)arg4; \
109  arr[5] = (long)arg5; \
110  return socketcall(SYS_##name, arr); \
111 }
112 
113 inline static __sys_socketcall3(int,socket, int,domain, int,type, int,protocol)
115 inline static __sys_socketcall3(int,connect, int,sockfd, const struct sockaddr *,serv_addr, socklen_t,addrlen)
116 inline static __sys_socketcall2(int,listen, int,s, int,backlog)
118 
119 inline static __sys_socketcall4(int,send, int,s, const void *,msg, size_t,len, int,flags)
120 inline static __sys_socketcall4(ssize_t,recv, int,s, void *,buf, size_t,len, int,flags)
121 
122 
123 inline static __sys_socketcall6(ssize_t,recvfrom, int,s, void *,buf, size_t,len, int,flags, struct sockaddr *,from, socklen_t *,fromlen)
124 inline static __sys_socketcall3(ssize_t,recvmsg, int,s, struct msghdr *,msg, int,flags)
125 inline static __sys_socketcall6(ssize_t,sendto, int,s, const void *,buf, size_t,len, int,flags, const struct sockaddr *,to, socklen_t,tolen)
126 inline static __sys_socketcall3(ssize_t,sendmsg, int,s, const struct msghdr *,msg, int,flags)
127 
128 
129 
130 #endif /* SFSOCKETCALL_H */
int call(int a, int b)
Definition: bcj_test.c:25
static static sync static getppid static getegid const char static filename char static len const char char static bufsiz static mask static vfork const void static prot static getpgrp const char static swapflags static arg static fd domain
Definition: sflib.h:79
static static sync static getppid static getegid const char static filename char static len const char char static bufsiz static mask static vfork const void static prot static getpgrp const char static swapflags static arg static fd socket
Definition: sflib.h:79
voidpf void * buf
Definition: ioapi.h:138
#define inline
Definition: ansidecl.h:243
#define const
Definition: ansidecl.h:240
static const void static count static fd struct stat static buf struct pollfd unsigned static timeout void static offset void static length char static len const struct iovec static count unsigned long static filedes static sched_yield static flags static oldfd static pause unsigned static seconds static protocol accept
Definition: sflib.h:75
static const void static count static fd struct stat static buf struct pollfd unsigned static timeout void static offset void static length char static len const struct iovec static count unsigned long static filedes static sched_yield static flags static oldfd static pause unsigned static seconds static protocol struct sockaddr addrlen
Definition: sflib.h:75
int args
Definition: mipsasm.c:18
int type
Definition: mipsasm.c:17
static struct sockaddr static addrlen static backlog send
Definition: sfsocketcall.h:119
int socketcall(int call, unsigned long *args)
static struct sockaddr static addrlen static backlog const void static flags void struct sockaddr from
Definition: sfsocketcall.h:123
static struct sockaddr static addrlen listen
Definition: sfsocketcall.h:116
static struct sockaddr static addrlen static backlog const void static flags recvfrom
Definition: sfsocketcall.h:123
static struct sockaddr static addrlen static backlog const void static flags void struct sockaddr socklen_t static fromlen const void const struct sockaddr to
Definition: sfsocketcall.h:125
static sockfd
Definition: sfsocketcall.h:114
static struct sockaddr static addrlen static backlog const void static flags void flags
Definition: sfsocketcall.h:123
#define __sys_socketcall2(type, name, type0, arg0, type1, arg1)
Definition: sfsocketcall.h:58
static bind
Definition: sfsocketcall.h:114
#define __sys_socketcall3(type, name, type0, arg0, type1, arg1, type2, arg2)
Definition: sfsocketcall.h:67
#define __sys_socketcall4(type, name, type0, arg0, type1, arg1, type2, arg2, type3, arg3)
Definition: sfsocketcall.h:77
static struct sockaddr static addrlen static backlog const void len
Definition: sfsocketcall.h:119
static struct sockaddr static addrlen static backlog const void static flags void struct sockaddr socklen_t static fromlen sendto
Definition: sfsocketcall.h:125
static struct sockaddr static addrlen s
Definition: sfsocketcall.h:116
static struct sockaddr my_addr
Definition: sfsocketcall.h:114
#define __sys_socketcall6(type, name, type0, arg0, type1, arg1, type2, arg2, type3, arg3, type4, arg4, type5, arg5)
Definition: sfsocketcall.h:100
static struct sockaddr static addrlen static backlog const void msg
Definition: sfsocketcall.h:119
unsigned int socklen_t
Definition: sftypes.h:219
int ssize_t
Definition: sftypes.h:39
static int addr
Definition: z80asm.c:58