-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathsocket.h
More file actions
107 lines (88 loc) · 2.53 KB
/
socket.h
File metadata and controls
107 lines (88 loc) · 2.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
#include <bits/socket.h>
#include <bits/types.h>
#include <bits/iovec.h>
#include <syscall.h>
#define SHUT_RD 0
#define SHUT_WR 1
#define SHUT_RDWR 2
struct msghdr {
void* name;
unsigned namelen;
struct iovec* iov;
size_t iovlen;
void* control;
size_t controllen;
int flags;
};
inline static long sys_socket(int domain, int type, int proto)
{
return syscall3(NR_socket, domain, type, proto);
}
inline static long sys_socketpair(int af, int sock, int prot, int* fds)
{
return syscall4(NR_socketpair, af, sock, prot, (long)fds);
}
inline static long sys_bind(int fd, void* addr, int len)
{
return syscall3(NR_bind, fd, (long)addr, len);
}
inline static long sys_accept(int fd, void* addr, int* len)
{
return syscall4(NR_accept4, fd, (long)addr, (long)len, 0);
}
inline static long sys_accept4(int fd, void* addr, int* len, int flags)
{
return syscall4(NR_accept4, fd, (long)addr, (long)len, flags);
}
inline static long sys_listen(int fd, int backlog)
{
return syscall2(NR_listen, fd, backlog);
}
inline static long sys_connect(int fd, void* addr, int len)
{
return syscall3(NR_connect, fd, (long)addr, len);
}
inline static long sys_shutdown(int fd, int how)
{
return syscall2(NR_shutdown, fd, how);
}
inline static long sys_getsockopt(int fd, int lvl, int opt, void* val, int* len)
{
return syscall5(NR_getsockopt, fd, lvl, opt, (long)val, (long)len);
}
inline static long sys_setsockopt(int fd, int lvl, int opt, void* val, int len)
{
return syscall5(NR_setsockopt, fd, lvl, opt, (long)val, len);
}
inline static long sys_setsockopti(int fd, int lvl, int opt, int val)
{
return syscall5(NR_setsockopt, fd, lvl, opt, (long)&val, sizeof(val));
}
inline static long sys_recv(int fd, void* buf, size_t len, int flags)
{
return syscall6(NR_recvfrom, fd, (long)buf, len, flags, 0, 0);
}
inline static long sys_recvfrom(int fd, void* buf, size_t len, int flags,
void* addr, int* alen)
{
return syscall6(NR_recvfrom, fd, (long)buf, len, flags,
(long)addr, (long)alen);
}
inline static long sys_recvmsg(int fd, struct msghdr* msg, int flags)
{
return syscall3(NR_recvmsg, fd, (long)msg, flags);
}
inline static long sys_send(int fd, const char* buf, int len, int flags)
{
return syscall6(NR_sendto, fd, (long)buf, len, flags, 0, 0);
}
inline static long sys_sendto(int fd, const void* buf, int len, int flags,
void* addr, int addrlen)
{
return syscall6(NR_sendto, fd, (long)buf, len, flags,
(long)addr, addrlen);
}
inline static long sys_sendmsg(int fd, const struct msghdr* msg, int flags)
{
return syscall3(NR_sendmsg, fd, (long)msg, flags);
}