equal
deleted
inserted
replaced
8 */ |
8 */ |
9 struct sock_stream_type { |
9 struct sock_stream_type { |
10 /* method table */ |
10 /* method table */ |
11 struct sock_stream_methods { |
11 struct sock_stream_methods { |
12 /* Normal read(2) */ |
12 /* Normal read(2) */ |
13 int (*read) (struct sock_stream *sock, void *buf, size_t len); |
13 err_t (*read) (struct sock_stream *sock, void *buf, size_t len); |
14 |
14 |
15 /* Normal write(2) */ |
15 /* Normal write(2) */ |
16 int (*write) (struct sock_stream *sock, const void *buf, size_t len); |
16 err_t (*write) (struct sock_stream *sock, const void *buf, size_t len); |
17 |
17 |
18 } methods; |
18 } methods; |
19 }; |
19 }; |
20 |
20 |
21 /* |
21 /* |
23 * |
23 * |
24 * The specific implementations should embed this at the start of their type-specific struct, and then cast around |
24 * The specific implementations should embed this at the start of their type-specific struct, and then cast around |
25 * as appropriate. |
25 * as appropriate. |
26 */ |
26 */ |
27 struct sock_stream { |
27 struct sock_stream { |
|
28 /* The sock_stream_type for this socket */ |
28 struct sock_stream_type *type; |
29 struct sock_stream_type *type; |
|
30 |
|
31 /* Last error info */ |
|
32 struct error_info err; |
29 }; |
33 }; |
30 |
34 |
31 #define SOCK_FROM_BASE(sock, type) ((type*) sock) |
35 #define SOCK_FROM_BASE(sock, type) ((type*) sock) |
|
36 #define SOCK_ERR(sock) ((sock)->err) |
|
37 |
|
38 /* |
|
39 * Initialize a sock_stream with the given sock_stream_type. |
|
40 * |
|
41 * The sock_stream should be initialized to zero. It is a bug to call this twice. |
|
42 */ |
|
43 void sock_stream_init (struct sock_stream *sock, struct sock_stream_type *type); |
32 |
44 |
33 #endif /* SOCK_INTERNAL_H */ |
45 #endif /* SOCK_INTERNAL_H */ |