Rev 8514 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 8514 | Rev 8536 | ||
---|---|---|---|
Line 1... | Line 1... | ||
1 | #include |
1 | #include |
Line 2... | Line -... | ||
2 | - | ||
3 | int err_code=0; |
- | |
4 | 2 | ||
5 | int socket(int domain, int type, int protocol) |
3 | int socket(int domain, int type, int protocol) |
6 | { |
4 | { |
7 | asm volatile( |
5 | asm volatile( |
8 | "int $0x40" |
6 | "int $0x40" |
9 | :"=b"(err_code) |
7 | :"=b"(errno) |
10 | :"a"(75), "b"(0), "c"(domain), "d"(type), "S"(protocol) |
8 | :"a"(75), "b"(0), "c"(domain), "d"(type), "S"(protocol) |
11 | ); |
9 | ); |
Line 12... | Line 10... | ||
12 | } |
10 | } |
13 | 11 | ||
14 | int close(int socket) |
12 | int close(int socket) |
15 | { |
13 | { |
16 | asm volatile( |
14 | asm volatile( |
17 | "int $0x40" |
15 | "int $0x40" |
18 | :"=b"(err_code) |
16 | :"=b"(errno) |
19 | :"a"(75), "b"(1), "c"(socket) |
17 | :"a"(75), "b"(1), "c"(socket) |
20 | ); |
18 | ); |
21 | } |
19 | } |
22 | int bind(int socket, const struct sockaddr *addres, int addres_len) |
20 | int bind(int socket, const struct sockaddr *addres, int addres_len) |
23 | { |
21 | { |
24 | asm volatile( |
22 | asm volatile( |
25 | "int $0x40" |
23 | "int $0x40" |
26 | :"=b"(err_code) |
24 | :"=b"(errno) |
27 | :"a"(75), "b"(2), "c"(socket), "d"(addres), "S"(addres_len) |
25 | :"a"(75), "b"(2), "c"(socket), "d"(addres), "S"(addres_len) |
Line 28... | Line 26... | ||
28 | ); |
26 | ); |
29 | } |
27 | } |
30 | 28 | ||
31 | int listen(int socket, int backlog) |
29 | int listen(int socket, int backlog) |
32 | { |
30 | { |
33 | asm volatile( |
31 | asm volatile( |
34 | "int $0x40" |
32 | "int $0x40" |
35 | :"=b"(err_code) |
33 | :"=b"(errno) |
Line 36... | Line 34... | ||
36 | :"a"(75), "b"(3), "c"(socket), "d"(backlog) |
34 | :"a"(75), "b"(3), "c"(socket), "d"(backlog) |
37 | ); |
35 | ); |
38 | } |
36 | } |
39 | 37 | ||
40 | int connect(int socket,const struct sockaddr* address, int socket_len) |
38 | int connect(int socket,const struct sockaddr* address, int socket_len) |
41 | { |
39 | { |
42 | asm volatile( |
40 | asm volatile( |
43 | "int $0x40" |
41 | "int $0x40" |
Line 44... | Line 42... | ||
44 | :"=b"(err_code) |
42 | :"=b"(errno) |
45 | :"a"(75), "b"(4), "c"(socket), "d"(address), "S"(socket_len) |
43 | :"a"(75), "b"(4), "c"(socket), "d"(address), "S"(socket_len) |
46 | ); |
44 | ); |
47 | } |
45 | } |
48 | 46 | ||
49 | int accept(int socket, const struct sockaddr *address, int address_len) |
47 | int accept(int socket, const struct sockaddr *address, int address_len) |
50 | { |
48 | { |
51 | asm volatile( |
49 | asm volatile( |
Line 52... | Line 50... | ||
52 | "int $0x40" |
50 | "int $0x40" |
53 | :"=b"(err_code) |
51 | :"=b"(errno) |
54 | :"a"(75), "b"(5), "c"(socket), "d"(address), "S"(address_len) |
52 | :"a"(75), "b"(5), "c"(socket), "d"(address), "S"(address_len) |
55 | ); |
53 | ); |
56 | } |
54 | } |
57 | 55 | ||
58 | int send(int socket, const void *message, size_t msg_len, int flag) |
56 | int send(int socket, const void *message, size_t msg_len, int flag) |
59 | { |
57 | { |
Line 60... | Line 58... | ||
60 | asm volatile( |
58 | asm volatile( |
61 | "int $0x40" |
59 | "int $0x40" |
62 | :"=b"(err_code) |
60 | :"=b"(errno) |
63 | :"a"(75), "b"(6), "c"(socket), "d"(message), "S"(msg_len), "D"(flag) |
61 | :"a"(75), "b"(6), "c"(socket), "d"(message), "S"(msg_len), "D"(flag) |
64 | ); |
62 | ); |
65 | } |
63 | } |
66 | 64 | ||
67 | int recv(int socket, void *buffer, size_t buff_len, int flag) |
65 | int recv(int socket, void *buffer, size_t buff_len, int flag) |
Line 68... | Line 66... | ||
68 | { |
66 | { |
69 | asm volatile( |
67 | asm volatile( |
70 | "int $0x40" |
68 | "int $0x40" |
71 | :"=b"(err_code) |
69 | :"=b"(errno) |
72 | :"a"(75), "b"(7), "c"(socket), "d"(buffer), "S"(buff_len), "D"(flag) |
70 | :"a"(75), "b"(7), "c"(socket), "d"(buffer), "S"(buff_len), "D"(flag) |
73 | ); |
71 | ); |
74 | } |
72 | } |
75 | 73 | ||
Line 76... | Line 74... | ||
76 | int setsockopt(int socket,const optstruct* opt) |
74 | int setsockopt(int socket,const optstruct* opt) |
77 | { |
75 | { |
78 | asm volatile( |
76 | asm volatile( |
79 | "int $0x40" |
77 | "int $0x40" |
80 | :"=b"(err_code) |
78 | :"=b"(errno) |
81 | :"a"(75), "b"(8), "c"(socket),"d"(opt) |
79 | :"a"(75), "b"(8), "c"(socket),"d"(opt) |
82 | ); |
80 | ); |
83 | } |
81 | } |
Line 84... | Line 82... | ||
84 | 82 | ||
Line 96... | Line 94... | ||
96 | asm volatile( |
94 | asm volatile( |
97 | "int $0x40" |
95 | "int $0x40" |
98 | :"=b"(*sock2), "=a"(*sock1) |
96 | :"=b"(*sock2), "=a"(*sock1) |
99 | :"a"(75), "b"(10) |
97 | :"a"(75), "b"(10) |
100 | ); |
98 | ); |
101 | err_code = *sock2; |
99 | errno = *sock2; |
102 | return *sock1; |
100 | return *sock1; |
103 | } |
101 | } |