2,6 → 2,7 |
#define __SOCKET_H__ |
|
#include <stddef.h> |
#include <errno.h> |
|
// Socket Types |
#define SOCK_STREAM 1 |
54,26 → 55,7 |
#define SO_BINDTODEVICE (1<<9) |
#define SO_NONBLOCK (1<<31) |
|
// Error Codes |
#define ENOBUFS 1 |
#define EINPROGRESS 2 |
#define EOPNOTSUPP 4 |
#define EWOULDBLOCK 6 |
#define ENOTCONN 9 |
#define EALREADY 10 |
#define EINVALUE 11 |
#define EMSGSIZE 12 |
#define ENOMEM 18 |
#define EADDRINUSE 20 |
#define ECONNREFUSED 61 |
#define ECONNRESET 52 |
#define EISCONN 56 |
#define ETIMEDOUT 60 |
#define ECONNABORTED 53 |
|
|
#define PORT(X) (X<<8) |
int err_code; |
|
#pragma pack(push,1) |
struct sockaddr{ |
98,7 → 80,7 |
int socket; |
asm volatile( |
"int $0x40" |
:"=b"(err_code), "=a"(socket) |
:"=b"(errno), "=a"(socket) |
:"a"(75), "b"(0), "c"(domain), "d"(type), "S"(protocol) |
); |
return socket; |
109,7 → 91,7 |
int status; |
asm volatile( |
"int $0x40" |
:"=b"(err_code), "=a"(status) |
:"=b"(errno), "=a"(status) |
:"a"(75), "b"(1), "c"(socket) |
); |
return status; |
120,7 → 102,7 |
int status; |
asm volatile( |
"int $0x40" |
:"=b"(err_code), "=a"(status) |
:"=b"(errno), "=a"(status) |
:"a"(75), "b"(2), "c"(socket), "d"(addres), "S"(addres_len) |
); |
return status; |
131,7 → 113,7 |
int status; |
asm volatile( |
"int $0x40" |
:"=b"(err_code), "=a"(status) |
:"=b"(errno), "=a"(status) |
:"a"(75), "b"(3), "c"(socket), "d"(backlog) |
); |
return status; |
142,7 → 124,7 |
int status; |
asm volatile( |
"int $0x40" |
:"=b"(err_code), "=a"(status) |
:"=b"(errno), "=a"(status) |
:"a"(75), "b"(4), "c"(socket), "d"(address), "S"(socket_len) |
); |
return status; |
153,7 → 135,7 |
int new_socket; |
asm volatile( |
"int $0x40" |
:"=b"(err_code), "=a"(new_socket) |
:"=b"(errno), "=a"(new_socket) |
:"a"(75), "b"(5), "c"(socket), "d"(address), "S"(address_len) |
); |
return new_socket; |
164,7 → 146,7 |
int status; |
asm volatile( |
"int $0x40" |
:"=b"(err_code), "=a"(status) |
:"=b"(errno), "=a"(status) |
:"a"(75), "b"(6), "c"(socket), "d"(message), "S"(msg_len), "D"(flag) |
); |
return status; |
175,7 → 157,7 |
int status; |
asm volatile( |
"int $0x40" |
:"=b"(err_code), "=a"(status) |
:"=b"(errno), "=a"(status) |
:"a"(75), "b"(7), "c"(socket), "d"(buffer), "S"(buff_len), "D"(flag) |
); |
return status; |
186,7 → 168,7 |
int status; |
asm volatile( |
"int $0x40" |
:"=b"(err_code), "=a"(status) |
:"=b"(errno), "=a"(status) |
:"a"(75), "b"(8), "c"(socket),"d"(opt) |
); |
return status; |
197,7 → 179,7 |
int status; |
asm volatile( |
"int $0x40" |
:"=b"(err_code), "=a"(status) |
:"=b"(errno), "=a"(status) |
:"a"(75), "b"(9), "c"(socket),"d"(opt) |
); |
return status; |
210,7 → 192,7 |
:"=b"(*socket2), "=a"(*socket1) |
:"a"(75), "b"(10) |
); |
err_code=*socket2; |
errno=*socket2; |
return *socket1; |
} |
#endif |