Rev 8687 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 8687 | Rev 8787 | ||
---|---|---|---|
Line 74... | Line 74... | ||
74 | unsigned int optlenght; |
74 | unsigned int optlenght; |
75 | unsigned char options; |
75 | unsigned char options; |
76 | }optstruct; |
76 | }optstruct; |
77 | #pragma pack(pop) |
77 | #pragma pack(pop) |
Line 78... | Line -... | ||
78 | - | ||
79 | static inline |
- | |
80 | void _conv_socket_err(){ |
- | |
81 | switch(errno){ |
- | |
82 | case 1: errno = ENOBUFS; break; |
- | |
83 | case 2: errno = EINPROGRESS; break; |
- | |
84 | case 4: errno = EOPNOTSUPP; break; |
- | |
85 | case 6: errno = EWOULDBLOCK; break; |
- | |
86 | case 9: errno = ENOTCONN; break; |
- | |
87 | case 10: errno = EALREADY; break; |
- | |
88 | case 11: errno = EINVAL; break; |
- | |
89 | case 12: errno = EMSGSIZE; break; |
- | |
90 | case 18: errno = ENOMEM; break; |
- | |
91 | case 20: errno = EADDRINUSE; break; |
- | |
92 | case 61: errno = ECONNREFUSED; break; |
- | |
93 | case 52: errno = ECONNRESET; break; |
- | |
94 | case 56: errno = EISCONN; break; |
- | |
95 | case 60: errno = ETIMEDOUT; break; |
- | |
96 | case 54: errno = ECONNABORTED; break; |
- | |
97 | default: errno = 0; break; |
- | |
98 | } |
- | |
99 | } |
- | |
100 | - | ||
101 | static inline |
78 | |
102 | int socket(int domain, int type, int protocol) |
- | |
103 | { |
- | |
104 | int socket; |
- | |
105 | asm_inline( |
- | |
106 | "int $0x40" |
- | |
107 | :"=b"(errno), "=a"(socket) |
- | |
108 | :"a"(75), "b"(0), "c"(domain), "d"(type), "S"(protocol) |
- | |
109 | ); |
- | |
110 | _conv_socket_err(); |
- | |
111 | return socket; |
- | |
112 | } |
- | |
113 | - | ||
114 | static inline |
79 | extern int _FUNC(socket)(int domain, int type, int protocol); |
115 | int close(int socket) |
- | |
116 | { |
- | |
117 | int status; |
- | |
118 | asm_inline( |
- | |
119 | "int $0x40" |
- | |
120 | :"=b"(errno), "=a"(status) |
- | |
121 | :"a"(75), "b"(1), "c"(socket) |
- | |
122 | ); |
- | |
123 | _conv_socket_err(); |
- | |
124 | return status; |
- | |
125 | } |
- | |
126 | - | ||
127 | static inline |
80 | extern int _FUNC(close)(int socket); |
128 | int bind(int socket, const struct sockaddr *addres, int addres_len) |
- | |
129 | { |
- | |
130 | int status; |
- | |
131 | asm_inline( |
- | |
132 | "int $0x40" |
- | |
133 | :"=b"(errno), "=a"(status) |
- | |
134 | :"a"(75), "b"(2), "c"(socket), "d"(addres), "S"(addres_len) |
- | |
135 | ); |
- | |
136 | _conv_socket_err(); |
- | |
137 | return status; |
- | |
138 | } |
- | |
139 | - | ||
140 | static inline |
81 | extern int _FUNC(bind)(int socket, const struct sockaddr *addres, int addres_len); |
141 | int listen(int socket, int backlog) |
- | |
142 | { |
- | |
143 | int status; |
- | |
144 | asm_inline( |
- | |
145 | "int $0x40" |
- | |
146 | :"=b"(errno), "=a"(status) |
- | |
147 | :"a"(75), "b"(3), "c"(socket), "d"(backlog) |
- | |
148 | ); |
- | |
149 | _conv_socket_err(); |
- | |
150 | return status; |
- | |
151 | } |
- | |
152 | - | ||
153 | static inline |
82 | extern int _FUNC(listen)(int socket, int backlog); |
154 | int connect(int socket, const struct sockaddr* address, int socket_len) |
- | |
155 | { |
- | |
156 | int status; |
- | |
157 | asm_inline( |
- | |
158 | "int $0x40" |
- | |
159 | :"=b"(errno), "=a"(status) |
- | |
160 | :"a"(75), "b"(4), "c"(socket), "d"(address), "S"(socket_len) |
- | |
161 | ); |
- | |
162 | _conv_socket_err(); |
- | |
163 | return status; |
- | |
164 | } |
- | |
165 | - | ||
166 | static inline int |
83 | extern int _FUNC(connect)(int socket, const struct sockaddr* address, int socket_len); |
167 | accept(int socket, const struct sockaddr *address, int address_len) |
- | |
168 | { |
- | |
169 | int new_socket; |
- | |
170 | asm_inline( |
- | |
171 | "int $0x40" |
- | |
172 | :"=b"(errno), "=a"(new_socket) |
- | |
173 | :"a"(75), "b"(5), "c"(socket), "d"(address), "S"(address_len) |
- | |
174 | ); |
- | |
175 | _conv_socket_err(); |
- | |
176 | return new_socket; |
- | |
177 | } |
- | |
178 | - | ||
179 | static inline |
84 | extern int _FUNC(accept)(int socket, const struct sockaddr *address, int address_len); |
180 | int send(int socket, const void *message, size_t msg_len, int flag) |
- | |
181 | { |
- | |
182 | int status; |
- | |
183 | asm_inline( |
- | |
184 | "int $0x40" |
- | |
185 | :"=b"(errno), "=a"(status) |
- | |
186 | :"a"(75), "b"(6), "c"(socket), "d"(message), "S"(msg_len), "D"(flag) |
- | |
187 | ); |
- | |
188 | _conv_socket_err(); |
- | |
189 | return status; |
- | |
190 | } |
- | |
191 | - | ||
192 | static inline |
85 | extern int _FUNC(send)(int socket, const void *message, size_t msg_len, int flag); |
193 | int recv(int socket, void *buffer, size_t buff_len, int flag) |
- | |
194 | { |
- | |
195 | int status; |
- | |
196 | asm_inline( |
- | |
197 | "int $0x40" |
- | |
198 | :"=b"(errno), "=a"(status) |
- | |
199 | :"a"(75), "b"(7), "c"(socket), "d"(buffer), "S"(buff_len), "D"(flag) |
- | |
200 | ); |
- | |
201 | _conv_socket_err(); |
- | |
202 | return status; |
- | |
203 | } |
- | |
204 | - | ||
205 | static inline |
86 | extern int _FUNC(recv)(int socket, void *buffer, size_t buff_len, int flag); |
206 | int setsockopt(int socket,const optstruct* opt) |
- | |
207 | { |
- | |
208 | int status; |
- | |
209 | asm_inline( |
- | |
210 | "int $0x40" |
- | |
211 | :"=b"(errno), "=a"(status) |
- | |
212 | :"a"(75), "b"(8), "c"(socket),"d"(opt) |
- | |
213 | ); |
- | |
214 | _conv_socket_err(); |
- | |
215 | return status; |
- | |
216 | } |
- | |
217 | - | ||
218 | static inline |
87 | extern int _FUNC(setsockopt)(int socket,const optstruct* opt); |
219 | int getsockopt(int socket, optstruct* opt) |
- | |
220 | { |
- | |
221 | int status; |
- | |
222 | asm_inline( |
- | |
223 | "int $0x40" |
- | |
224 | :"=b"(errno), "=a"(status) |
- | |
225 | :"a"(75), "b"(9), "c"(socket),"d"(opt) |
- | |
226 | ); |
- | |
227 | _conv_socket_err(); |
- | |
228 | return status; |
- | |
229 | } |
- | |
230 | - | ||
231 | static inline |
88 | extern int _FUNC(getsockopt)(int socket, optstruct* opt); |
232 | int socketpair(int *socket1, int *socket2) |
- | |
233 | { |
- | |
234 | asm_inline( |
- | |
235 | "int $0x40" |
- | |
236 | :"=b"(*socket2), "=a"(*socket1) |
- | |
237 | :"a"(75), "b"(10) |
- | |
238 | ); |
- | |
239 | errno=*socket2; |
- | |
240 | _conv_socket_err(); |
- | |
241 | return *socket1; |
- | |
Line 242... | Line 89... | ||
242 | } |
89 | extern int _FUNC(socketpair)(int *socket1, int *socket2); |