1 #ifndef SOCK_INTERNAL_H |
1 #ifndef SOCK_INTERNAL_H |
2 #define SOCK_INTERNAL_H |
2 #define SOCK_INTERNAL_H |
3 |
3 |
|
4 /** |
|
5 * @file |
|
6 * |
|
7 * internal sock_* interface |
|
8 */ |
4 #include "sock.h" |
9 #include "sock.h" |
5 |
10 |
6 /* |
11 /** |
7 * Global config related to all sock_streams |
12 * Global config related to all sock_streams |
8 */ |
13 */ |
9 extern struct sock_stream_ctx { |
14 extern struct sock_stream_ctx { |
10 /* Event core */ |
15 /* Event core */ |
11 struct event_base *ev_base; |
16 struct event_base *ev_base; |
12 |
17 |
13 } _sock_stream_ctx; |
18 } _sock_stream_ctx; |
14 |
19 |
15 /* |
20 /** |
16 * The base type struct, which defines the method table. |
21 * The base type struct, which defines the method table. |
17 */ |
22 */ |
18 struct sock_stream_type { |
23 struct sock_stream_type { |
19 /* method table */ |
24 /** Method table */ |
20 struct sock_stream_methods { |
25 struct sock_stream_methods { |
21 /* Normal read(2) */ |
26 /** As read(2) */ |
22 err_t (*read) (struct sock_stream *sock, void *buf, size_t *len); |
27 err_t (*read) (struct sock_stream *sock, void *buf, size_t *len); |
23 |
28 |
24 /* Normal write(2) */ |
29 /** As write(2) */ |
25 err_t (*write) (struct sock_stream *sock, const void *buf, size_t *len); |
30 err_t (*write) (struct sock_stream *sock, const void *buf, size_t *len); |
26 |
31 |
27 /* Initialize events. cb_info/cb_arg are already updated */ |
32 /** Initialize events. cb_info/cb_arg are already updated */ |
28 err_t (*event_init) (struct sock_stream *sock); |
33 err_t (*event_init) (struct sock_stream *sock); |
29 |
34 |
30 /* Enable events as specified */ |
35 /** Enable events as specified */ |
31 err_t (*event_enable) (struct sock_stream *sock, short mask); |
36 err_t (*event_enable) (struct sock_stream *sock, short mask); |
32 |
37 |
|
38 /** Release all resources and free the sock_stream */ |
|
39 void (*release) (struct sock_stream *sock); |
33 } methods; |
40 } methods; |
34 }; |
41 }; |
35 |
42 |
36 /* |
43 /* |
37 * The base sock_stream type, as used by the sock_stream_* functions. |
44 * The base sock_stream type, as used by the sock_stream_* functions. |