terom@1: #ifndef SOCK_INTERNAL_H terom@1: #define SOCK_INTERNAL_H terom@1: terom@1: #include "sock.h" terom@1: terom@1: /* terom@1: * The base type struct, which defines the method table. terom@1: */ terom@1: struct sock_stream_type { terom@1: /* method table */ terom@1: struct sock_stream_methods { terom@1: /* Normal read(2) */ terom@3: err_t (*read) (struct sock_stream *sock, void *buf, size_t len); terom@1: terom@1: /* Normal write(2) */ terom@3: err_t (*write) (struct sock_stream *sock, const void *buf, size_t len); terom@1: terom@1: } methods; terom@1: }; terom@1: terom@1: /* terom@1: * The base sock_stream type, as used by the sock_stream_* functions. terom@1: * terom@1: * The specific implementations should embed this at the start of their type-specific struct, and then cast around terom@1: * as appropriate. terom@1: */ terom@1: struct sock_stream { terom@3: /* The sock_stream_type for this socket */ terom@1: struct sock_stream_type *type; terom@3: terom@3: /* Last error info */ terom@3: struct error_info err; terom@1: }; terom@1: terom@1: #define SOCK_FROM_BASE(sock, type) ((type*) sock) terom@3: #define SOCK_ERR(sock) ((sock)->err) terom@3: terom@3: /* terom@3: * Initialize a sock_stream with the given sock_stream_type. terom@3: * terom@3: * The sock_stream should be initialized to zero. It is a bug to call this twice. terom@3: */ terom@3: void sock_stream_init (struct sock_stream *sock, struct sock_stream_type *type); terom@1: terom@1: #endif /* SOCK_INTERNAL_H */