diff options
Diffstat (limited to 'lib9p/include')
-rw-r--r-- | lib9p/include/lib9p/_types.h | 45 | ||||
-rw-r--r-- | lib9p/include/lib9p/srv.h | 14 |
2 files changed, 19 insertions, 40 deletions
diff --git a/lib9p/include/lib9p/_types.h b/lib9p/include/lib9p/_types.h index 7f320a5..94accc0 100644 --- a/lib9p/include/lib9p/_types.h +++ b/lib9p/include/lib9p/_types.h @@ -8,13 +8,15 @@ /* versions *******************************************************************/ enum lib9p_version { - LIB9P_VER_UNINITIALIZED = 0, - LIB9P_VER_9P2000, /* "9P2000" */ - LIB9P_VER_9P2000_e, /* "9P2000.e" */ - LIB9P_VER_9P2000_u, /* "9P2000.u" */ + LIB9P_VER_unknown = 0, /* "unknown" */ + LIB9P_VER_9P2000, /* "9P2000" */ + LIB9P_VER_9P2000_e, /* "9P2000.e" */ + LIB9P_VER_9P2000_u, /* "9P2000.u" */ LIB9P_VER_NUM, }; +const char *lib9p_version_str(enum lib9p_version); + /* non-message structs ********************************************************/ struct lib9p_d { @@ -90,40 +92,7 @@ enum lib9p_msg_type { /* uint8_t */ LIB9P_TYP_Rswrite = 155, /* 9P2000.e */ }; -#define LIB9P_TYPECODE_FOR_CTYPE(msg) _Generic((msg), \ - struct lib9p_msg_Tversion: LIB9P_TYP_Tversion, \ - struct lib9p_msg_Rversion: LIB9P_TYP_Rversion, \ - struct lib9p_msg_Tauth: LIB9P_TYP_Tauth, \ - struct lib9p_msg_Rauth: LIB9P_TYP_Rauth, \ - struct lib9p_msg_Tattach: LIB9P_TYP_Tattach, \ - struct lib9p_msg_Rattach: LIB9P_TYP_Rattach, \ - struct lib9p_msg_Rerror: LIB9P_TYP_Rerror, \ - struct lib9p_msg_Tflush: LIB9P_TYP_Tflush, \ - struct lib9p_msg_Rflush: LIB9P_TYP_Rflush, \ - struct lib9p_msg_Twalk: LIB9P_TYP_Twalk, \ - struct lib9p_msg_Rwalk: LIB9P_TYP_Rwalk, \ - struct lib9p_msg_Topen: LIB9P_TYP_Topen, \ - struct lib9p_msg_Ropen: LIB9P_TYP_Ropen, \ - struct lib9p_msg_Tcreate: LIB9P_TYP_Tcreate, \ - struct lib9p_msg_Rcreate: LIB9P_TYP_Rcreate, \ - struct lib9p_msg_Tread: LIB9P_TYP_Tread, \ - struct lib9p_msg_Rread: LIB9P_TYP_Rread, \ - struct lib9p_msg_Twrite: LIB9P_TYP_Twrite, \ - struct lib9p_msg_Rwrite: LIB9P_TYP_Rwrite, \ - struct lib9p_msg_Tclunk: LIB9P_TYP_Tclunk, \ - struct lib9p_msg_Rclunk: LIB9P_TYP_Rclunk, \ - struct lib9p_msg_Tremove: LIB9P_TYP_Tremove, \ - struct lib9p_msg_Rremove: LIB9P_TYP_Rremove, \ - struct lib9p_msg_Tstat: LIB9P_TYP_Tstat, \ - struct lib9p_msg_Rstat: LIB9P_TYP_Rstat, \ - struct lib9p_msg_Twstat: LIB9P_TYP_Twstat, \ - struct lib9p_msg_Rwstat: LIB9P_TYP_Rwstat, \ - struct lib9p_msg_Tsession: LIB9P_TYP_Tsession, \ - struct lib9p_msg_Rsession: LIB9P_TYP_Rsession, \ - struct lib9p_msg_Tsread: LIB9P_TYP_Tsread, \ - struct lib9p_msg_Rsread: LIB9P_TYP_Rsread, \ - struct lib9p_msg_Tswrite: LIB9P_TYP_Tswrite, \ - struct lib9p_msg_Rswrite: LIB9P_TYP_Rswrite) +const char *lib9p_msg_type_str(enum lib9p_msg_type); struct lib9p_msg_Tversion { uint32_t max_msg_size; diff --git a/lib9p/include/lib9p/srv.h b/lib9p/include/lib9p/srv.h index a8bd9c7..3ca8b4d 100644 --- a/lib9p/include/lib9p/srv.h +++ b/lib9p/include/lib9p/srv.h @@ -4,13 +4,23 @@ #include <libcr/coroutine.h> #include <libcr_ipc/chan.h> -struct lib9p_srvreq; +struct lib9p_srv_req; struct lib9p_srv { int sockfd; - cr_chan_t(struct lib9p_srvreq *) reqch; + + cr_chan_t(struct lib9p_srv_req *) reqch; }; +/** + * Will just close the connection if a T-message has a size[4] <7. + * @errno LINUX_EMSGSIZE T-message has size[4] bigger than max_msg_size + * @errno LINUX_EDOM Tversion specified an impossibly small max_msg_size + * @errno LINUX_EOPNOTSUPP T-message has an R-message type, or an unrecognized T-message type + * @errno LINUX_EBADMSG T-message has wrong size[4] for its content, or has invalid UTF-8 + * @errno LINUX_ERANGE R-message does not fit into max_msg_size + */ + COROUTINE lib9p_srv_read_cr(void *_srv); COROUTINE lib9p_srv_write_cr(void *_srv); |