1
2 #include <sys/types.h>
3 #include <sys/socket.h>
4
5 /* Derived from android-3/arch-arm/include/asm/socket.h */
6
7 #define SOL_SOCKET_PORTABLE 1
8
9 #define SO_DEBUG_PORTABLE 1
10 #define SO_REUSEADDR_PORTABLE 2
11 #define SO_TYPE_PORTABLE 3
12 #define SO_ERROR_PORTABLE 4
13 #define SO_DONTROUTE_PORTABLE 5
14 #define SO_BROADCAST_PORTABLE 6
15 #define SO_SNDBUF_PORTABLE 7
16 #define SO_RCVBUF_PORTABLE 8
17 #define SO_SNDBUFFORCE_PORTABLE 32
18 #define SO_RCVBUFFORCE_PORTABLE 33
19 #define SO_KEEPALIVE_PORTABLE 9
20 #define SO_OOBINLINE_PORTABLE 10
21 #define SO_NO_CHECK_PORTABLE 11
22 #define SO_PRIORITY_PORTABLE 12
23 #define SO_LINGER_PORTABLE 13
24 #define SO_BSDCOMPAT_PORTABLE 14
25
26 #define SO_PASSCRED_PORTABLE 16
27 #define SO_PEERCRED_PORTABLE 17
28 #define SO_RCVLOWAT_PORTABLE 18
29 #define SO_SNDLOWAT_PORTABLE 19
30 #define SO_RCVTIMEO_PORTABLE 20
31 #define SO_SNDTIMEO_PORTABLE 21
32
33 #define SO_SECURITY_AUTHENTICATION_PORTABLE 22
34 #define SO_SECURITY_ENCRYPTION_TRANSPORT_PORTABLE 23
35 #define SO_SECURITY_ENCRYPTION_NETWORK_PORTABLE 24
36
37 #define SO_BINDTODEVICE_PORTABLE 25
38
39 #define SO_ATTACH_FILTER_PORTABLE 26
40 #define SO_DETACH_FILTER_PORTABLE 27
41
42 #define SO_PEERNAME_PORTABLE 28
43 #define SO_TIMESTAMP_PORTABLE 29
44 #define SCM_TIMESTAMP_PORTABLE SO_TIMESTAMP_PORTABLE
45
46 #define SO_ACCEPTCONN_PORTABLE 30
47
48 #define SO_PEERSEC_PORTABLE 31
49 #define SO_PASSSEC_PORTABLE 34
50
51 #if SOL_SOCKET_PORTABLE==SOL_SOCKET
52 #error Build environment
53 #endif
54
mips_change_level(int level)55 static inline int mips_change_level(int level)
56 {
57 switch (level) {
58 case SOL_SOCKET_PORTABLE:
59 level = SOL_SOCKET;
60 break;
61 }
62 return level;
63 }
64
65
mips_change_optname(int optname)66 static inline int mips_change_optname(int optname)
67 {
68 switch (optname) {
69 case SO_DEBUG_PORTABLE:
70 return SO_DEBUG;
71 case SO_REUSEADDR_PORTABLE:
72 return SO_REUSEADDR;
73 case SO_TYPE_PORTABLE:
74 return SO_TYPE;
75 case SO_ERROR_PORTABLE:
76 return SO_ERROR;
77 case SO_DONTROUTE_PORTABLE:
78 return SO_DONTROUTE;
79 case SO_BROADCAST_PORTABLE:
80 return SO_BROADCAST;
81 case SO_SNDBUF_PORTABLE:
82 return SO_SNDBUF;
83 case SO_RCVBUF_PORTABLE:
84 return SO_RCVBUF;
85 case SO_SNDBUFFORCE_PORTABLE:
86 return SO_SNDBUFFORCE;
87 case SO_RCVBUFFORCE_PORTABLE:
88 return SO_RCVBUFFORCE;
89 case SO_KEEPALIVE_PORTABLE:
90 return SO_KEEPALIVE;
91 case SO_OOBINLINE_PORTABLE:
92 return SO_OOBINLINE;
93 case SO_NO_CHECK_PORTABLE:
94 return SO_NO_CHECK;
95 case SO_PRIORITY_PORTABLE:
96 return SO_PRIORITY;
97 case SO_LINGER_PORTABLE:
98 return SO_LINGER;
99 case SO_BSDCOMPAT_PORTABLE:
100 return SO_BSDCOMPAT;
101 case SO_PASSCRED_PORTABLE:
102 return SO_PASSCRED;
103 case SO_PEERCRED_PORTABLE:
104 return SO_PEERCRED;
105 case SO_RCVLOWAT_PORTABLE:
106 return SO_RCVLOWAT;
107 case SO_SNDLOWAT_PORTABLE:
108 return SO_SNDLOWAT;
109 case SO_RCVTIMEO_PORTABLE:
110 return SO_RCVTIMEO;
111 case SO_SNDTIMEO_PORTABLE:
112 return SO_SNDTIMEO;
113 case SO_SECURITY_AUTHENTICATION_PORTABLE:
114 return SO_SECURITY_AUTHENTICATION;
115 case SO_SECURITY_ENCRYPTION_TRANSPORT_PORTABLE:
116 return SO_SECURITY_ENCRYPTION_TRANSPORT;
117 case SO_SECURITY_ENCRYPTION_NETWORK_PORTABLE:
118 return SO_SECURITY_ENCRYPTION_NETWORK;
119 case SO_BINDTODEVICE_PORTABLE:
120 return SO_BINDTODEVICE;
121 case SO_ATTACH_FILTER_PORTABLE:
122 return SO_ATTACH_FILTER;
123 case SO_DETACH_FILTER_PORTABLE:
124 return SO_DETACH_FILTER;
125 case SO_PEERNAME_PORTABLE:
126 return SO_PEERNAME;
127 case SO_TIMESTAMP_PORTABLE:
128 return SO_TIMESTAMP;
129 case SO_ACCEPTCONN_PORTABLE:
130 return SO_ACCEPTCONN;
131 case SO_PEERSEC_PORTABLE:
132 return SO_PEERSEC;
133 case SO_PASSSEC_PORTABLE:
134 return SO_PASSSEC;
135 }
136 return optname;
137 }
138
139 extern int setsockopt(int, int, int, const void *, socklen_t);
setsockopt_portable(int s,int level,int optname,const void * optval,socklen_t optlen)140 int setsockopt_portable(int s, int level, int optname, const void *optval, socklen_t optlen)
141 {
142 return setsockopt(s, mips_change_level(level), mips_change_optname(optname), optval, optlen);
143 }
144
145 extern int getsockopt (int, int, int, void *, socklen_t *);
getsockopt_portable(int s,int level,int optname,void * optval,socklen_t * optlen)146 int getsockopt_portable(int s, int level, int optname, void *optval, socklen_t *optlen)
147 {
148 return getsockopt(s, mips_change_level(level), mips_change_optname(optname), optval, optlen);
149 }
150