diff options
-rw-r--r-- | epan/dissectors/packet-9p.c | 2207 |
1 files changed, 2006 insertions, 201 deletions
diff --git a/epan/dissectors/packet-9p.c b/epan/dissectors/packet-9p.c index 62833393da..14a84b33a5 100644 --- a/epan/dissectors/packet-9p.c +++ b/epan/dissectors/packet-9p.c @@ -33,6 +33,750 @@ #include <epan/packet.h> #include <epan/strutil.h> +#include <epan/conversation.h> + +/** + * enum _9p_msg_t - 9P message types + * @_9P_TLERROR: not used + * @_9P_RLERROR: response for any failed request for 9P2000.L + * @_9P_TSTATFS: file system status request + * @_9P_RSTATFS: file system status response + * @_9P_TSYMLINK: make symlink request + * @_9P_RSYMLINK: make symlink response + * @_9P_TMKNOD: create a special file object request + * @_9P_RMKNOD: create a special file object response + * @_9P_TLCREATE: prepare a handle for I/O on an new file for 9P2000.L + * @_9P_RLCREATE: response with file access information for 9P2000.L + * @_9P_TRENAME: rename request + * @_9P_RRENAME: rename response + * @_9P_TMKDIR: create a directory request + * @_9P_RMKDIR: create a directory response + * @_9P_TVERSION: version handshake request + * @_9P_RVERSION: version handshake response + * @_9P_TAUTH: request to establish authentication channel + * @_9P_RAUTH: response with authentication information + * @_9P_TATTACH: establish user access to file service + * @_9P_RATTACH: response with top level handle to file hierarchy + * @_9P_TERROR: not used + * @_9P_RERROR: response for any failed request + * @_9P_TFLUSH: request to abort a previous request + * @_9P_RFLUSH: response when previous request has been cancelled + * @_9P_TWALK: descend a directory hierarchy + * @_9P_RWALK: response with new handle for position within hierarchy + * @_9P_TOPEN: prepare a handle for I/O on an existing file + * @_9P_ROPEN: response with file access information + * @_9P_TCREATE: prepare a handle for I/O on a new file + * @_9P_RCREATE: response with file access information + * @_9P_TREAD: request to transfer data from a file or directory + * @_9P_RREAD: response with data requested + * @_9P_TWRITE: reuqest to transfer data to a file + * @_9P_RWRITE: response with out much data was transfered to file + * @_9P_TCLUNK: forget about a handle to an entity within the file system + * @_9P_RCLUNK: response when server has forgotten about the handle + * @_9P_TREMOVE: request to remove an entity from the hierarchy + * @_9P_RREMOVE: response when server has removed the entity + * @_9P_TSTAT: request file entity attributes + * @_9P_RSTAT: response with file entity attributes + * @_9P_TWSTAT: request to update file entity attributes + * @_9P_RWSTAT: response when file entity attributes are updated + * + * There are 14 basic operations in 9P2000, paired as + * requests and responses. The one special case is ERROR + * as there is no @_9P_TERROR request for clients to transmit to + * the server, but the server may respond to any other request + * with an @_9P_RERROR. + * + * See Also: http://plan9.bell-labs.com/sys/man/5/INDEX.html + */ + +enum _9p_msg_t { + _9P_TLERROR = 6, + _9P_RLERROR, + _9P_TSTATFS = 8, + _9P_RSTATFS, + _9P_TLOPEN = 12, + _9P_RLOPEN, + _9P_TLCREATE = 14, + _9P_RLCREATE, + _9P_TSYMLINK = 16, + _9P_RSYMLINK, + _9P_TMKNOD = 18, + _9P_RMKNOD, + _9P_TRENAME = 20, + _9P_RRENAME, + _9P_TREADLINK = 22, + _9P_RREADLINK, + _9P_TGETATTR = 24, + _9P_RGETATTR, + _9P_TSETATTR = 26, + _9P_RSETATTR, + _9P_TXATTRWALK = 30, + _9P_RXATTRWALK, + _9P_TXATTRCREATE = 32, + _9P_RXATTRCREATE, + _9P_TREADDIR = 40, + _9P_RREADDIR, + _9P_TFSYNC = 50, + _9P_RFSYNC, + _9P_TLOCK = 52, + _9P_RLOCK, + _9P_TGETLOCK = 54, + _9P_RGETLOCK, + _9P_TLINK = 70, + _9P_RLINK, + _9P_TMKDIR = 72, + _9P_RMKDIR, + _9P_TRENAMEAT = 74, + _9P_RRENAMEAT, + _9P_TUNLINKAT = 76, + _9P_RUNLINKAT, + _9P_TVERSION = 100, + _9P_RVERSION, + _9P_TAUTH = 102, + _9P_RAUTH, + _9P_TATTACH = 104, + _9P_RATTACH, + _9P_TERROR = 106, + _9P_RERROR, + _9P_TFLUSH = 108, + _9P_RFLUSH, + _9P_TWALK = 110, + _9P_RWALK, + _9P_TOPEN = 112, + _9P_ROPEN, + _9P_TCREATE = 114, + _9P_RCREATE, + _9P_TREAD = 116, + _9P_RREAD, + _9P_TWRITE = 118, + _9P_RWRITE, + _9P_TCLUNK = 120, + _9P_RCLUNK, + _9P_TREMOVE = 122, + _9P_RREMOVE, + _9P_TSTAT = 124, + _9P_RSTAT, + _9P_TWSTAT = 126, + _9P_RWSTAT, +}; + +/* 9P Msg types to name mapping */ +static const value_string ninep_msg_type[] = +{ + {_9P_TLERROR, "Tlerror"}, + {_9P_RLERROR, "Rlerror"}, + {_9P_TSTATFS, "Tstatfs"}, + {_9P_RSTATFS, "Rstatfs"}, + {_9P_TLOPEN, "Tlopen"}, + {_9P_RLOPEN, "Rlopen"}, + {_9P_TLCREATE, "Tlcreate"}, + {_9P_RLCREATE, "Rlcreate"}, + {_9P_TSYMLINK, "Tsymlink"}, + {_9P_RSYMLINK, "Rsymlink"}, + {_9P_TMKNOD, "Tmknod"}, + {_9P_RMKNOD, "Rmknod"}, + {_9P_TRENAME, "Trename"}, + {_9P_RRENAME, "Rrename"}, + {_9P_TREADLINK, "Treadlink"}, + {_9P_RREADLINK, "Rreadlink"}, + {_9P_TGETATTR, "Tgetattr"}, + {_9P_RGETATTR, "Rgetattr"}, + {_9P_TSETATTR, "Tsetattr"}, + {_9P_RSETATTR, "Rsetattr"}, + {_9P_TXATTRWALK, "Txattrwalk"}, + {_9P_RXATTRWALK, "Rxattrwalk"}, + {_9P_TXATTRCREATE, "Txattrcreate"}, + {_9P_RXATTRCREATE, "Rxattrcreate"}, + {_9P_TREADDIR, "Treaddir"}, + {_9P_RREADDIR, "Rreaddir"}, + {_9P_TFSYNC, "Tfsync"}, + {_9P_RFSYNC, "Rfsync"}, + {_9P_TLOCK, "Tlock"}, + {_9P_RLOCK, "Rlock"}, + {_9P_TGETLOCK, "Tgetlock"}, + {_9P_RGETLOCK, "Rgetlock"}, + {_9P_TLINK, "Tlink"}, + {_9P_RLINK, "Rlink"}, + {_9P_TMKDIR, "Tmkdir"}, + {_9P_RMKDIR, "Rmkdir"}, + {_9P_TRENAMEAT, "Trenameat"}, + {_9P_RRENAMEAT, "Rrenameat"}, + {_9P_TUNLINKAT, "Tunlinkat"}, + {_9P_RUNLINKAT, "Runlinkat"}, + {_9P_TVERSION, "Tversion"}, + {_9P_RVERSION, "Rversion"}, + {_9P_TAUTH, "Tauth"}, + {_9P_RAUTH, "Rauth"}, + {_9P_TATTACH, "Tattach"}, + {_9P_RATTACH, "Rattach"}, + {_9P_TERROR, "Terror"}, + {_9P_RERROR, "Rerror"}, + {_9P_TFLUSH, "Tflush"}, + {_9P_RFLUSH, "Rflush"}, + {_9P_TWALK, "Twalk"}, + {_9P_RWALK, "Rwalk"}, + {_9P_TOPEN, "Topen"}, + {_9P_ROPEN, "Ropen"}, + {_9P_TCREATE, "Tcreate"}, + {_9P_RCREATE, "Rcreate"}, + {_9P_TREAD, "Tread"}, + {_9P_RREAD, "Rread"}, + {_9P_TWRITE, "Twrite"}, + {_9P_RWRITE, "Rwrite"}, + {_9P_TCLUNK, "Tclunk"}, + {_9P_RCLUNK, "Rclunk"}, + {_9P_TREMOVE, "Tremove"}, + {_9P_RREMOVE, "Rremove"}, + {_9P_TSTAT, "Tstat"}, + {_9P_RSTAT, "Rstat"}, + {_9P_TWSTAT, "Twstat"}, + {_9P_RWSTAT, "Rwstat"}, + {0, NULL}, +}; +static value_string_ext ninep_msg_type_ext = VALUE_STRING_EXT_INIT(ninep_msg_type); + +enum _9p_version { + _9P = 1, + _9P2000, + _9P2000_L, + _9P2000_u +}; + +static const value_string ninep_version[] = +{ + {_9P, "9P"}, + {_9P2000, "9P2000"}, + {_9P2000_L, "9P2000.L"}, + {_9P2000_u, "9P2000.u"}, + {0, NULL}, +}; +static value_string_ext ninep_version_ext = VALUE_STRING_EXT_INIT(ninep_version); + + +/* File open modes */ +#define _9P_OREAD 0x0 +#define _9P_OWRITE 0x1 +#define _9P_ORDWR 0x2 +#define _9P_OEXEC 0x3 +#define _9P_MODEMASK 0x3 +#define _9P_OTRUNC 0x10 +#define _9P_ORCLOSE 0x40 + +/* Open/Create modes */ +static const value_string ninep_mode_vals[] = +{ + {_9P_OREAD, "Read Access"}, + {_9P_OWRITE, "Write Access"}, + {_9P_ORDWR, "Read/Write Access "}, + {_9P_OEXEC, "Execute Access"}, + {0, NULL}, +}; +static value_string_ext ninep_mode_vals_ext = VALUE_STRING_EXT_INIT(ninep_mode_vals); + + +/* stat mode flags */ +#define DMDIR 0x80000000 /* Directory */ +#define DMAPPEND 0x40000000 /* Append only */ +#define DMEXCL 0x20000000 /* Exclusive use */ +#define DMMOUNT 0x10000000 /* Mounted channel */ +#define DMAUTH 0x08000000 /* Authentication */ +#define DMTMP 0x04000000 /* Temporary */ + + +/** + * enum _9p_qid_t - QID types + * @_9P_QTDIR: directory + * @_9P_QTAPPEND: append-only + * @_9P_QTEXCL: excluse use (only one open handle allowed) + * @_9P_QTMOUNT: mount points + * @_9P_QTAUTH: authentication file + * @_9P_QTTMP: non-backed-up files + * @_9P_QTSYMLINK: symbolic links (9P2000.u) + * @_9P_QTLINK: hard-link (9P2000.u) + * @_9P_QTFILE: normal files + * + * QID types are a subset of permissions - they are primarily + * used to differentiate semantics for a file system entity via + * a jump-table. Their value is also the most signifigant 16 bits + * of the permission_t + * + * See Also: http://plan9.bell-labs.com/magic/man2html/2/stat + */ +enum _9p_qid_t { + _9P_QTDIR = 0x80, + _9P_QTAPPEND = 0x40, + _9P_QTEXCL = 0x20, + _9P_QTMOUNT = 0x10, + _9P_QTAUTH = 0x08, + _9P_QTTMP = 0x04, + _9P_QTSYMLINK = 0x02, + _9P_QTLINK = 0x01, + _9P_QTFILE = 0x00, +}; + +/* 9P Magic Numbers */ +#define _9P_NOTAG (guint16)(~0) +#define _9P_NOFID (guint32)(~0) +#define _9P_NONUNAME (guint32)(~0) +#define _9P_MAXWELEM 16 + +#ifndef MAXPATHLEN +#define MAXPATHLEN 1024 +#endif + + +/** + * @brief Length prefixed string type + * + * The protocol uses length prefixed strings for all + * string data, so we replicate that for our internal + * string members. + */ + +struct _9p_str { + guint16 len; /*< Length of the string */ + char *str; /*< The string */ +}; + +/** + * @brief file system entity information + * + * qids are /identifiers used by 9P servers to track file system + * entities. The type is used to differentiate semantics for operations + * on the entity (ie. read means something different on a directory than + * on a file). The path provides a server unique index for an entity + * (roughly analogous to an inode number), while the version is updated + * every time a file is modified and can be used to maintain cache + * coherency between clients and serves. + * Servers will often differentiate purely synthetic entities by setting + * their version to 0, signaling that they should never be cached and + * should be accessed synchronously. + * + * See Also://plan9.bell-labs.com/magic/man2html/2/stat + */ + +struct _9p_qid { + guint8 type; /*< Type */ + guint32 version; /*< Monotonically incrementing version number */ + guint64 path; /*< Per-server-unique ID for a file system element */ +}; + + +/* Bit values for getattr valid field. + */ +#define _9P_GETATTR_MODE 0x00000001ULL +#define _9P_GETATTR_NLINK 0x00000002ULL +#define _9P_GETATTR_UID 0x00000004ULL +#define _9P_GETATTR_GID 0x00000008ULL +#define _9P_GETATTR_RDEV 0x00000010ULL +#define _9P_GETATTR_ATIME 0x00000020ULL +#define _9P_GETATTR_MTIME 0x00000040ULL +#define _9P_GETATTR_CTIME 0x00000080ULL +#define _9P_GETATTR_INO 0x00000100ULL +#define _9P_GETATTR_SIZE 0x00000200ULL +#define _9P_GETATTR_BLOCKS 0x00000400ULL + +#define _9P_GETATTR_BTIME 0x00000800ULL +#define _9P_GETATTR_GEN 0x00001000ULL +#define _9P_GETATTR_DATA_VERSION 0x00002000ULL + +#define _9P_GETATTR_BASIC 0x000007ffULL /* Mask for fields up to BLOCKS */ +#define _9P_GETATTR_ALL 0x00003fffULL /* Mask for All fields above */ + + +/* Bit values for setattr valid field from <linux/fs.h>. + */ +#define _9P_SETATTR_MODE 0x00000001UL +#define _9P_SETATTR_UID 0x00000002UL +#define _9P_SETATTR_GID 0x00000004UL +#define _9P_SETATTR_SIZE 0x00000008UL +#define _9P_SETATTR_ATIME 0x00000010UL +#define _9P_SETATTR_MTIME 0x00000020UL +#define _9P_SETATTR_CTIME 0x00000040UL +#define _9P_SETATTR_ATIME_SET 0x00000080UL +#define _9P_SETATTR_MTIME_SET 0x00000100UL + +#define _9P_SETATTR_ALL 0x000001FFUL + +/* 9p2000.L open flags */ +#define _9P_DOTL_RDONLY 00000000 +#define _9P_DOTL_WRONLY 00000001 +#define _9P_DOTL_RDWR 00000002 +#define _9P_DOTL_NOACCESS 00000003 +#define _9P_DOTL_CREATE 00000100 +#define _9P_DOTL_EXCL 00000200 +#define _9P_DOTL_NOCTTY 00000400 +#define _9P_DOTL_TRUNC 00001000 +#define _9P_DOTL_APPEND 00002000 +#define _9P_DOTL_NONBLOCK 00004000 +#define _9P_DOTL_DSYNC 00010000 +#define _9P_DOTL_FASYNC 00020000 +#define _9P_DOTL_DIRECT 00040000 +#define _9P_DOTL_LARGEFILE 00100000 +#define _9P_DOTL_DIRECTORY 00200000 +#define _9P_DOTL_NOFOLLOW 00400000 +#define _9P_DOTL_NOATIME 01000000 +#define _9P_DOTL_CLOEXEC 02000000 +#define _9P_DOTL_SYNC 04000000 + + +/* Bit values for lock type. + */ +#define _9P_LOCK_TYPE_RDLCK 0 +#define _9P_LOCK_TYPE_WRLCK 1 +#define _9P_LOCK_TYPE_UNLCK 2 + +/* 9P lock type to string table */ +static const value_string ninep_lock_type[] = +{ + {_9P_LOCK_TYPE_RDLCK, "Read lock"}, + {_9P_LOCK_TYPE_WRLCK, "Write lock"}, + {_9P_LOCK_TYPE_UNLCK, "Unlock"}, + { 0, NULL}, +}; +static value_string_ext ninep_lock_type_ext = VALUE_STRING_EXT_INIT(ninep_lock_type); + +/* Bit values for lock status. + */ +#define _9P_LOCK_SUCCESS 0 +#define _9P_LOCK_BLOCKED 1 +#define _9P_LOCK_ERROR 2 +#define _9P_LOCK_GRACE 3 + +/* 9P lock status to string table */ +static const value_string ninep_lock_status[] = +{ + {_9P_LOCK_SUCCESS, "Success"}, + {_9P_LOCK_BLOCKED, "Blocked"}, + {_9P_LOCK_ERROR, "Error"}, + {_9P_LOCK_GRACE, "Grace"}, + { 0, NULL}, +}; +static value_string_ext ninep_lock_status_ext = VALUE_STRING_EXT_INIT(ninep_lock_status); + +/* Bit values for lock flags. + */ +#define _9P_LOCK_FLAGS_NONE 0 +#define _9P_LOCK_FLAGS_BLOCK 1 +#define _9P_LOCK_FLAGS_RECLAIM 2 + +/* 9P lock flag to string table */ +static const value_string ninep_lock_flag[] = +{ + {_9P_LOCK_FLAGS_NONE, "No flag"}, + {_9P_LOCK_FLAGS_BLOCK, "Block"}, + {_9P_LOCK_BLOCKED, "Reclaim"}, + { 0, NULL}, +}; +static value_string_ext ninep_lock_flag_ext = VALUE_STRING_EXT_INIT(ninep_lock_flag); + + +/* Structures for Protocol Operations */ +struct _9p_rlerror { + guint32 ecode; +}; +struct _9p_tstatfs { + guint32 fid; +}; +struct _9p_rstatfs { + guint32 type; + guint32 bsize; + guint64 blocks; + guint64 bfree; + guint64 bavail; + guint64 files; + guint64 ffree; + guint64 fsid; + guint32 namelen; +}; +struct _9p_tlopen { + guint32 fid; + guint32 flags; +}; +struct _9p_rlopen { + struct _9p_qid qid; + guint32 iounit; +}; +struct _9p_tlcreate { + guint32 fid; + struct _9p_str name; + guint32 flags; + guint32 mode; + guint32 gid; +}; +struct _9p_rlcreate { + struct _9p_qid qid; + guint32 iounit; +}; +struct _9p_tsymlink { + guint32 fid; + struct _9p_str name; + struct _9p_str symtgt; + guint32 gid; +}; +struct _9p_rsymlink { + struct _9p_qid qid; +}; +struct _9p_tmknod { + guint32 fid; + struct _9p_str name; + guint32 mode; + guint32 major; + guint32 minor; + guint32 gid; +}; +struct _9p_rmknod { + struct _9p_qid qid; +}; +struct _9p_trename { + guint32 fid; + guint32 dfid; + struct _9p_str name; +}; +struct _9p_rrename { +}; +struct _9p_treadlink { + guint32 fid; +}; +struct _9p_rreadlink { + struct _9p_str target; +}; +struct _9p_tgetattr { + guint32 fid; + guint64 request_mask; +}; +struct _9p_rgetattr { + guint64 valid; + struct _9p_qid qid; + guint32 mode; + guint32 uid; + guint32 gid; + guint64 nlink; + guint64 rdev; + guint64 size; + guint64 blksize; + guint64 blocks; + guint64 atime_sec; + guint64 atime_nsec; + guint64 mtime_sec; + guint64 mtime_nsec; + guint64 ctime_sec; + guint64 ctime_nsec; + guint64 btime_sec; + guint64 btime_nsec; + guint64 gen; + guint64 data_version; +}; +struct _9p_tsetattr { + guint32 fid; + guint32 valid; + guint32 mode; + guint32 uid; + guint32 gid; + guint64 size; + guint64 atime_sec; + guint64 atime_nsec; + guint64 mtime_sec; + guint64 mtime_nsec; +}; +struct _9p_rsetattr { +}; +struct _9p_txattrwalk { + guint32 fid; + guint32 attrfid; + struct _9p_str name; +}; +struct _9p_rxattrwalk { + guint64 size; +}; +struct _9p_txattrcreate { + guint32 fid; + struct _9p_str name; + guint64 size; + guint32 flag; +}; +struct _9p_rxattrcreate { +}; +struct _9p_treaddir { + guint32 fid; + guint64 offset; + guint32 count; +}; +struct _9p_rreaddir { + guint32 count; + guint8 *data; +}; +struct _9p_tfsync { + guint32 fid; +}; +struct _9p_rfsync { +}; +struct _9p_tlock { + guint32 fid; + guint8 type; + guint32 flags; + guint64 start; + guint64 length; + guint32 proc_id; + struct _9p_str client_id; +}; +struct _9p_rlock { + guint8 status; +}; +struct _9p_tgetlock { + guint32 fid; + guint8 type; + guint64 start; + guint64 length; + guint32 proc_id; + struct _9p_str client_id; +}; +struct _9p_rgetlock { + guint8 type; + guint64 start; + guint64 length; + guint32 proc_id; + struct _9p_str client_id; +}; +struct _9p_tlink { + guint32 dfid; + guint32 fid; + struct _9p_str name; +}; +struct _9p_rlink { +}; +struct _9p_tmkdir { + guint32 fid; + struct _9p_str name; + guint32 mode; + guint32 gid; +}; +struct _9p_rmkdir { + struct _9p_qid qid; +}; +struct _9p_trenameat { + guint32 olddirfid; + struct _9p_str oldname; + guint32 newdirfid; + struct _9p_str newname; +}; +struct _9p_rrenameat { +}; +struct _9p_tunlinkat { + guint32 dirfid; + struct _9p_str name; + guint32 flags; +}; +struct _9p_runlinkat { +}; +struct _9p_tawrite { + guint32 fid; + guint8 datacheck; + guint64 offset; + guint32 count; + guint32 rsize; + guint8 *data; + guint32 check; +}; +struct _9p_rawrite { + guint32 count; +}; +struct _9p_tversion { + guint32 msize ; + struct _9p_str version ; +}; +struct _9p_rversion { + guint32 msize; + struct _9p_str version; +}; +struct _9p_tauth { + guint32 afid; + struct _9p_str uname; + struct _9p_str aname; + guint32 n_uname; /* 9P2000.u extensions */ +}; +struct _9p_rauth { + struct _9p_qid qid; +}; +struct _9p_rerror { + struct _9p_str error; + guint32 errnum; /* 9p2000.u extension */ +}; +struct _9p_tflush { + guint16 oldtag; +}; +struct _9p_rflush { +}; +struct _9p_tattach { + guint32 fid; + guint32 afid; + struct _9p_str uname; + struct _9p_str aname; + guint32 n_uname; /* 9P2000.u extensions */ +}; +struct _9p_rattach { + struct _9p_qid qid; +}; +struct _9p_twalk { + guint32 fid; + guint32 newfid; + guint16 nwname; + struct _9p_str wnames[_9P_MAXWELEM]; +}; +struct _9p_rwalk { + guint16 nwqid; + struct _9p_qid wqids[_9P_MAXWELEM]; +}; +struct _9p_topen { + guint32 fid; + guint8 mode; +}; +struct _9p_ropen { + struct _9p_qid qid; + guint32 iounit; +}; +struct _9p_tcreate { + guint32 fid; + struct _9p_str name; + guint32 perm; + guint8 mode; + struct _9p_str extension; +}; +struct _9p_rcreate { + struct _9p_qid qid; + guint32 iounit; +}; +struct _9p_tread { + guint32 fid; + guint64 offset; + guint32 count; +}; +struct _9p_rread { + guint32 count; + guint8 *data; +}; +struct _9p_twrite { + guint32 fid; + guint64 offset; + guint32 count; + guint8 *data; +}; +struct _9p_rwrite { + guint32 count; +}; +struct _9p_tclunk { + guint32 fid; +}; +struct _9p_rclunk { +}; +struct _9p_tremove { + guint32 fid; +}; +struct _9p_rremove { +}; + +union _9p_tmsg { +} ; #define NINEPORT 564 @@ -40,49 +784,6 @@ void proto_register_9P(void); void proto_reg_handoff_9P(void); -/*Message types for 9P */ -/*See man 5 intro on Plan 9 - or; - http://www.cs.bell-labs.com/sys/man/5/INDEX.html -*/ -enum { - TVERSION = 100, - RVERSION = 101, - TAUTH = 102, - RAUTH = 103, - TATTACH = 104, - RATTACH = 105, - TERROR = 106, /* Not used */ - RERROR = 107, - TFLUSH = 108, - RFLUSH = 109, - TWALK = 110, - RWALK = 111, - TOPEN = 112, - ROPEN, - TCREATE = 114, - RCREATE, - TREAD = 116, - RREAD, - TWRITE = 118, - RWRITE, - TCLUNK = 120, - RCLUNK, - TREMOVE = 122, - RREMOVE, - TSTAT = 124, - RSTAT, - TWSTAT = 126, - RWSTAT -}; -/* File open modes */ -#define P9_OREAD 0x0 -#define P9_OWRITE 0x1 -#define P9_ORDWR 0x2 -#define P9_OEXEC 0x3 -#define P9_MODEMASK 0x3 -#define P9_OTRUNC 0x10 -#define P9_ORCLOSE 0x40 - /* Initialize the protocol and registered fields */ static int proto_9P = -1; static int hf_9P_msgsz = -1; @@ -129,6 +830,8 @@ static int hf_9P_stattype = -1; static int hf_9P_statmode = -1; static int hf_9P_atime = -1; static int hf_9P_mtime = -1; +static int hf_9P_ctime = -1; +static int hf_9P_btime = -1; static int hf_9P_length = -1; static int hf_9P_dev = -1; static int hf_9P_wname = -1; @@ -137,14 +840,85 @@ static int hf_9P_afid = -1; static int hf_9P_uname = -1; static int hf_9P_aname = -1; static int hf_9P_ename = -1; +static int hf_9P_enum = -1; static int hf_9P_name = -1; static int hf_9P_filename = -1; static int hf_9P_sdlen = -1; +static int hf_9P_user = -1; +static int hf_9P_group = -1; static int hf_9P_uid = -1; static int hf_9P_gid = -1; static int hf_9P_muid = -1; static int hf_9P_nwalk = -1; static int hf_9P_newfid = -1; +static int hf_9P_dfid = -1; +static int hf_9P_getattr_flags = -1; +static int hf_9P_getattr_mode = -1; +static int hf_9P_getattr_nlink = -1; +static int hf_9P_getattr_uid = -1; +static int hf_9P_getattr_gid = -1; +static int hf_9P_getattr_rdev = -1; +static int hf_9P_getattr_atime = -1; +static int hf_9P_getattr_mtime = -1; +static int hf_9P_getattr_ctime = -1; +static int hf_9P_getattr_ino = -1; +static int hf_9P_getattr_size = -1; +static int hf_9P_getattr_blocks = -1; +static int hf_9P_getattr_btime = -1; +static int hf_9P_getattr_gen = -1; +static int hf_9P_getattr_dataversion = -1; +static int hf_9P_setattr_flags = -1; +static int hf_9P_setattr_mode = -1; +static int hf_9P_setattr_uid = -1; +static int hf_9P_setattr_gid = -1; +static int hf_9P_setattr_size = -1; +static int hf_9P_setattr_atime = -1; +static int hf_9P_setattr_mtime = -1; +static int hf_9P_setattr_ctime = -1; +static int hf_9P_setattr_atime_set = -1; +static int hf_9P_setattr_mtime_set = -1; +static int hf_9P_nlink = -1; +static int hf_9P_rdev = -1; +static int hf_9P_size = -1; +static int hf_9P_blksize = -1; +static int hf_9P_blocks = -1; +static int hf_9P_gen = -1; +static int hf_9P_dataversion = -1; +static int hf_9P_fstype = -1; +static int hf_9P_bfree = -1; +static int hf_9P_bavail = -1; +static int hf_9P_files = -1; +static int hf_9P_ffree = -1; +static int hf_9P_fsid = -1; +static int hf_9P_namelen = -1; +static int hf_9P_mknod_major = -1; +static int hf_9P_mknod_minor = -1; +static int hf_9P_lflags = -1; +static int hf_9P_lflags_rdonly = -1; +static int hf_9P_lflags_wronly = -1; +static int hf_9P_lflags_rdwr = -1; +static int hf_9P_lflags_create = -1; +static int hf_9P_lflags_excl = -1; +static int hf_9P_lflags_noctty = -1; +static int hf_9P_lflags_trunc = -1; +static int hf_9P_lflags_append = -1; +static int hf_9P_lflags_nonblock = -1; +static int hf_9P_lflags_dsync = -1; +static int hf_9P_lflags_fasync = -1; +static int hf_9P_lflags_direct = -1; +static int hf_9P_lflags_largefile = -1; +static int hf_9P_lflags_directory = -1; +static int hf_9P_lflags_nofollow = -1; +static int hf_9P_lflags_noatime = -1; +static int hf_9P_lflags_cloexec = -1; +static int hf_9P_lflags_sync = -1; +static int hf_9P_xattr_flag = -1; +static int hf_9P_lock_type = -1; +static int hf_9P_lock_flag = -1; +static int hf_9P_lock_start = -1; +static int hf_9P_lock_length = -1; +static int hf_9P_lock_procid = -1; +static int hf_9P_lock_status = -1; /*handle for dissecting data in 9P msgs*/ static dissector_handle_t data_handle; @@ -157,92 +931,255 @@ static gint ett_9P_wname = -1; static gint ett_9P_aname = -1; static gint ett_9P_ename = -1; static gint ett_9P_uname = -1; -static gint ett_9P_uid = -1; -static gint ett_9P_gid = -1; +static gint ett_9P_user = -1; +static gint ett_9P_group = -1; static gint ett_9P_muid = -1; static gint ett_9P_filename = -1; static gint ett_9P_version = -1; static gint ett_9P_qid = -1; static gint ett_9P_qidtype = -1; +static gint ett_9P_getattr_flags = -1; +static gint ett_9P_setattr_flags = -1; +static gint ett_9P_lflags = -1; -/*9P Msg types to name mapping */ -static const value_string ninep_msg_type[] = -{ {TVERSION, "Tversion"}, - {RVERSION, "Rversion"}, - {TAUTH, "Tauth"}, - {RAUTH, "Rauth"}, - {TATTACH, "Tattach"}, - {RATTACH, "Rattach"}, - {RERROR, "Rerror"}, - {TFLUSH, "Tflush"}, - {RFLUSH, "Rflush"}, - {TWALK, "Twalk"}, - {RWALK, "Rwalk"}, - {TOPEN, "Topen"}, - {ROPEN, "Ropen"}, - {TCREATE, "Tcreate"}, - {RCREATE, "Rcreate"}, - {TREAD, "Tread"}, - {RREAD, "Rread"}, - {TWRITE, "Twrite"}, - {RWRITE, "Rwrite"}, - {TCLUNK, "Tclunk"}, - {RCLUNK, "Rclunk"}, - {TREMOVE, "Tremove"}, - {RREMOVE, "Rremove"}, - {TSTAT, "Tstat"}, - {RSTAT, "Rstat"}, - {TWSTAT, "Twstat"}, - {RWSTAT, "Rwstat"}, - {0, NULL}, -}; -static value_string_ext ninep_msg_type_ext = VALUE_STRING_EXT_INIT(ninep_msg_type); -/* Open/Create modes */ -static const value_string ninep_mode_vals[] = -{ - {P9_OREAD, "Read Access"}, - {P9_OWRITE, "Write Access"}, - {P9_ORDWR, "Read/Write Access "}, - {P9_OEXEC, "Execute Access"}, - {0, NULL} -}; +static GHashTable *_9p_hashtable = NULL; static void dissect_9P_mode(tvbuff_t * tvb, proto_item * tree,int offset); static void dissect_9P_dm(tvbuff_t * tvb, proto_item * tree,int offset,int iscreate); static void dissect_9P_qid(tvbuff_t * tvb, proto_tree * tree,int offset); +static void dissect_9P_lflags(tvbuff_t * tvb, proto_tree * tree, int offset); +static void dissect_9P_getattrflags(tvbuff_t * tvb, proto_tree * tree, int offset); +static void dissect_9P_setattrflags(tvbuff_t * tvb, proto_tree * tree, int offset); + +struct _9p_hashkey { + guint32 conv_index; + guint16 tag; + guint32 fid; +}; + +struct _9p_hashval { + int len; + char *data; +}; + +struct _9p_taginfo { + enum _9p_msg_t msgtype; + guint32 fid; +}; + +static gint _9p_hash_equal(gconstpointer k1, gconstpointer k2) { + const struct _9p_hashkey *key1 = (struct _9p_hashkey *)k1, *key2 = (struct _9p_hashkey *)k2; + + return ((key1->conv_index == key2->conv_index) && (key1->tag == key2->tag) && (key1->fid == key2->fid)); +} + +static guint _9p_hash_hash(gconstpointer k) +{ + const struct _9p_hashkey *key = (struct _9p_hashkey *)k; + + return (key->conv_index ^ key->tag ^ key->fid); +} + +static gboolean _9p_hash_free_all(gpointer key _U_, gpointer value _U_, gpointer user_data _U_) +{ + return TRUE; +} + +static void _9p_hash_free_val(gpointer value) +{ + struct _9p_hashval *val = (struct _9p_hashval *)value; + + if (val->data) { + g_free(val->data); + val->data = NULL; + } + + g_free(value); +} + +static struct _9p_hashval *_9p_hash_new_val(int len) +{ + struct _9p_hashval *val; + val = (struct _9p_hashval *)g_malloc(sizeof(struct _9p_hashval)); + + val->data = (char *)g_malloc(len); + val->len = len; + + return val; +} + +static void _9p_hash_init(void) +{ + if (_9p_hashtable != NULL) { + g_hash_table_foreach_remove(_9p_hashtable, _9p_hash_free_all, NULL); + } else { + _9p_hashtable = g_hash_table_new_full(_9p_hash_hash, _9p_hash_equal, g_free, _9p_hash_free_val); + } +} + +static void _9p_hash_set(packet_info *pinfo, guint16 tag, guint32 fid, struct _9p_hashval *val) +{ + struct _9p_hashkey *key; + struct _9p_hashval *oldval; + conversation_t *conv; + + conv = find_or_create_conversation(pinfo); + + key = (struct _9p_hashkey *)g_malloc(sizeof(struct _9p_hashkey)); + + key->conv_index = conv->index; + key->tag = tag; + key->fid = fid; + + /* remove eventual old entry */ + oldval = (struct _9p_hashval *)g_hash_table_lookup(_9p_hashtable, key); + if (oldval) { + g_hash_table_remove(_9p_hashtable, key); + } + g_hash_table_insert(_9p_hashtable, key, val); +} + +static struct _9p_hashval *_9p_hash_get(packet_info *pinfo, guint16 tag, guint32 fid) +{ + struct _9p_hashkey key; + conversation_t *conv; + + conv = find_or_create_conversation(pinfo); + + key.conv_index = conv->index; + key.tag = tag; + key.fid = fid; + + return (struct _9p_hashval *)g_hash_table_lookup(_9p_hashtable, &key); +} + +static void _9p_hash_free(packet_info *pinfo, guint16 tag, guint32 fid) +{ + struct _9p_hashkey key; + conversation_t *conv; + + conv = find_or_create_conversation(pinfo); + + key.conv_index = conv->index; + key.tag = tag; + key.fid = fid; + + g_hash_table_remove(_9p_hashtable, &key); +} + +static void conv_set_version(packet_info *pinfo, enum _9p_version version) +{ + struct _9p_hashval *val; + + val = _9p_hash_new_val(sizeof(version)); + + *(int*)val->data = version; + + _9p_hash_set(pinfo, _9P_NOTAG, _9P_NOFID, val); +} + +static enum _9p_version conv_get_version(packet_info *pinfo) +{ + struct _9p_hashval *val; + + val = _9p_hash_get(pinfo, _9P_NOTAG, _9P_NOFID); + + return val ? *(enum _9p_version*)val->data : _9P; +} + +static void conv_set_fid(packet_info *pinfo, guint32 fid, const char *path, int len) +{ + struct _9p_hashval *val; + + val = _9p_hash_new_val(len); + + /* Check this is len long? */ + g_strlcpy(val->data, path, len); + + _9p_hash_set(pinfo, _9P_NOTAG, fid, val); +} + +static char *conv_get_fid(packet_info *pinfo, guint32 fid) +{ + struct _9p_hashval *val; + + val = _9p_hash_get(pinfo, _9P_NOTAG, fid); + + return val ? val->data : (char*)""; +} + +static inline void conv_free_fid(packet_info *pinfo, guint32 fid) +{ + if (fid != _9P_NOFID) + _9p_hash_free(pinfo, _9P_NOTAG, fid); +} + +static void conv_set_tag(packet_info *pinfo, guint16 tag, enum _9p_msg_t msgtype, guint32 fid) +{ + struct _9p_hashval *val; + struct _9p_taginfo *taginfo; + + val = _9p_hash_new_val(sizeof(struct _9p_taginfo)); + taginfo = (struct _9p_taginfo*)val->data; + + taginfo->msgtype = msgtype; + taginfo->fid = fid; + + _9p_hash_set(pinfo, tag, _9P_NOFID, val); +} + +static inline struct _9p_taginfo *conv_get_tag(packet_info *pinfo, guint16 tag) +{ + struct _9p_hashval *val; + + /* check that length matches? */ + val = _9p_hash_get(pinfo, tag, _9P_NOFID); + + return val ? (struct _9p_taginfo*)val->data : NULL; +} + +static inline void conv_free_tag(packet_info *pinfo, guint16 tag) +{ + _9p_hash_free(pinfo, tag, _9P_NOFID); +} /* Dissect 9P messages*/ static int dissect_9P(tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree, void * data _U_) { - guint32 /*ninesz,*/tmp,i; - guint16 tmp16; - guint8 ninemsg; + guint32 /*ninesz,*/tmp, i, fid; + guint16 tmp16, tag; + enum _9p_msg_t ninemsg; guint offset = 0; const char *mname; - gint len,reportedlen; + char *tmppath, *tmps; + gint len, reportedlen; tvbuff_t *next_tvb; proto_item *ti; - proto_tree *ninep_tree,*tmp_tree; + proto_tree *ninep_tree, *tmp_tree; nstime_t tv; + struct _9p_taginfo *taginfo; + int _9p_version = conv_get_version(pinfo); + + col_set_str(pinfo->cinfo, COL_PROTOCOL, val_to_str_ext_const(_9p_version, &ninep_version_ext, "9P")); - col_set_str(pinfo->cinfo, COL_PROTOCOL, "9P"); col_clear(pinfo->cinfo, COL_INFO); /*ninesz = tvb_get_letohl(tvb, offset);*/ - ninemsg = tvb_get_guint8(tvb, offset + 4); + ninemsg = (enum _9p_msg_t)tvb_get_guint8(tvb, offset + 4); mname = val_to_str_ext_const(ninemsg, &ninep_msg_type_ext, "Unknown"); if(strcmp(mname,"Unknown") == 0) { - col_add_fstr(pinfo->cinfo, COL_INFO, "9P Data Continuation(?) (Tag %u)",(guint)ninemsg); + col_add_fstr(pinfo->cinfo, COL_INFO, "9P Data (Message type %u)",(guint)ninemsg); return 0; } - col_append_fstr(pinfo->cinfo, COL_INFO, "%s Tag=%u",mname,(guint)tvb_get_letohs(tvb,offset+5)); + tag = tvb_get_letohs(tvb,offset+5); + col_append_fstr(pinfo->cinfo, COL_INFO, "%s Tag=%u",mname,(guint)tag); - if (!tree) /*not much more of one line summary interrest yet.. */ + if (!tree) /*not much more of one line summary interest yet.. */ return 0; ti = proto_tree_add_item(tree, proto_9P, tvb, 0, -1, ENC_NA); @@ -256,18 +1193,32 @@ static int dissect_9P(tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree, vo offset += 2; switch(ninemsg) { - case RVERSION: - case TVERSION: + case _9P_RVERSION: + case _9P_TVERSION: proto_tree_add_item(ninep_tree, hf_9P_maxsize, tvb, offset, 4, ENC_LITTLE_ENDIAN); offset +=4; tmp16 = tvb_get_letohs(tvb,offset); + tmps = tvb_get_string(tvb, offset+2, tmp16); ti = proto_tree_add_item(ninep_tree, hf_9P_version, tvb, offset+2, tmp16, ENC_UTF_8|ENC_NA); tmp_tree = proto_item_add_subtree(ti,ett_9P_version); proto_tree_add_item(tmp_tree, hf_9P_parmsz, tvb, offset, 2, ENC_LITTLE_ENDIAN); offset += 2; + + if (!strncmp(tmps, "9P2000", tmp16)) { + tmp = _9P2000; + } else if (!strncmp(tmps, "9P2000.L", tmp16)) { + tmp = _9P2000_L; + } else if (!strncmp(tmps, "9P2000.u", tmp16)) { + tmp = _9P2000_u; + } else { + tmp = _9P; + } + + conv_set_version(pinfo, (enum _9p_version)tmp); + g_free(tmps); break; - case TAUTH: + case _9P_TAUTH: proto_tree_add_item(ninep_tree, hf_9P_afid, tvb, offset, 4, ENC_LITTLE_ENDIAN); offset +=4; @@ -282,25 +1233,36 @@ static int dissect_9P(tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree, vo tmp_tree = proto_item_add_subtree(ti,ett_9P_aname); proto_tree_add_item(tmp_tree, hf_9P_parmsz, tvb, offset, 2, ENC_LITTLE_ENDIAN); offset +=2; + + conv_set_tag(pinfo, tag, ninemsg, _9P_NOFID); break; - case RAUTH: - dissect_9P_qid(tvb,ninep_tree,offset); - offset += 13; - break; - case RERROR: - tmp16 = tvb_get_letohs(tvb,offset); - ti = proto_tree_add_item(ninep_tree, hf_9P_ename, tvb, offset+2, tmp16, ENC_UTF_8|ENC_NA); - tmp_tree = proto_item_add_subtree(ti,ett_9P_ename); - proto_tree_add_item(tmp_tree, hf_9P_parmsz, tvb, offset, 2, ENC_LITTLE_ENDIAN); - offset +=2; + case _9P_RERROR: + if (_9p_version == _9P2000_L) { + tmp = tvb_get_letohl(tvb, offset); + ti = proto_tree_add_item(ninep_tree, hf_9P_enum, tvb, offset, 4, ENC_LITTLE_ENDIAN); + proto_item_append_text(ti, " (%s)", g_strerror(tmp)); + offset += 4; + } else { + tmp16 = tvb_get_letohs(tvb,offset); + ti = proto_tree_add_item(ninep_tree, hf_9P_ename, tvb, offset+2, tmp16, ENC_UTF_8|ENC_NA); + tmp_tree = proto_item_add_subtree(ti,ett_9P_ename); + proto_tree_add_item(tmp_tree, hf_9P_parmsz, tvb, offset, 2, ENC_LITTLE_ENDIAN); + offset += 2 + tmp16; + } + + taginfo = conv_get_tag(pinfo, tag); + if (taginfo && (taginfo->msgtype == _9P_TWALK || taginfo->msgtype == _9P_TATTACH)) + conv_free_fid(pinfo, taginfo->fid); break; - case TFLUSH: + case _9P_TFLUSH: + tmp16 = tvb_get_letohs(tvb, offset); proto_tree_add_item(ninep_tree, hf_9P_oldtag, tvb, offset, 2, ENC_LITTLE_ENDIAN); + conv_set_tag(pinfo, tag, ninemsg, _9P_NOFID); + conv_free_tag(pinfo, tmp16); break; - case RFLUSH: - break; - case TATTACH: + case _9P_TATTACH: + fid = tvb_get_letohl(tvb, offset); proto_tree_add_item(ninep_tree, hf_9P_fid, tvb, offset, 4, ENC_LITTLE_ENDIAN); offset +=4; @@ -314,19 +1276,25 @@ static int dissect_9P(tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree, vo offset += tmp16 + 2; tmp16 = tvb_get_letohs(tvb,offset); + tmps = tvb_get_string(tvb, offset+2, tmp16); + conv_set_fid(pinfo, fid, tmps, tmp16+1); + g_free(tmps); ti = proto_tree_add_item(ninep_tree, hf_9P_aname, tvb, offset+2, tmp16, ENC_UTF_8|ENC_NA); tmp_tree = proto_item_add_subtree(ti,ett_9P_aname); proto_tree_add_item(tmp_tree, hf_9P_parmsz, tvb, offset, 2, ENC_LITTLE_ENDIAN); offset += tmp16+2; + conv_set_tag(pinfo, tag, ninemsg, fid); break; - case RATTACH: - dissect_9P_qid(tvb,ninep_tree,offset); - offset += 13; - break; - case TWALK: - proto_tree_add_item(ninep_tree, hf_9P_fid, tvb, offset, 4, ENC_LITTLE_ENDIAN); + case _9P_TWALK: + fid = tvb_get_letohl(tvb, offset); + ti = proto_tree_add_item(ninep_tree, hf_9P_fid, tvb, offset, 4, ENC_LITTLE_ENDIAN); offset +=4; + tmppath = (char*)g_malloc(MAXPATHLEN); + len = g_strlcpy(tmppath, conv_get_fid(pinfo, fid), MAXPATHLEN); + proto_item_append_text(ti, " (%s)", tmppath); + + fid = tvb_get_letohl(tvb, offset); proto_tree_add_item(ninep_tree, hf_9P_newfid, tvb, offset, 4, ENC_LITTLE_ENDIAN); offset +=4; @@ -343,19 +1311,26 @@ static int dissect_9P(tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree, vo for(i = 0 ; i < tmp16; i++) { guint16 tmplen; - proto_item *wname; - proto_tree *wname_tree; tmplen = tvb_get_letohs(tvb,offset); - wname = proto_tree_add_item(ninep_tree, hf_9P_wname, tvb, offset+2, tmplen, ENC_UTF_8|ENC_NA); - wname_tree = proto_item_add_subtree(wname,ett_9P_wname); - proto_tree_add_item(wname_tree, hf_9P_parmsz, tvb, offset, 2, ENC_LITTLE_ENDIAN); + ti = proto_tree_add_item(ninep_tree, hf_9P_wname, tvb, offset+2, tmplen, ENC_UTF_8|ENC_NA); + tmp_tree = proto_item_add_subtree(ti, ett_9P_wname); + proto_tree_add_item(tmp_tree, hf_9P_parmsz, tvb, offset, 2, ENC_LITTLE_ENDIAN); + + tmps = tvb_get_string(tvb, offset+2, tmplen); + len += g_strlcat(tmppath, "/", MAXPATHLEN); + len += g_strlcat(tmppath, tmps, MAXPATHLEN); + g_free(tmps); offset += tmplen + 2; } + conv_set_fid(pinfo, fid, tmppath, len+1); + g_free(tmppath); + + conv_set_tag(pinfo, tag, ninemsg, fid); break; - case RWALK: + case _9P_RWALK: tmp16 = tvb_get_letohs(tvb,offset); proto_tree_add_item(ninep_tree, hf_9P_nqid, tvb, offset, 2, ENC_LITTLE_ENDIAN); offset +=2; @@ -371,20 +1346,37 @@ static int dissect_9P(tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree, vo dissect_9P_qid(tvb,ninep_tree,offset); offset += 13; } + conv_free_tag(pinfo, tag); break; - case TOPEN: - proto_tree_add_item(ninep_tree, hf_9P_fid, tvb, offset, 4, ENC_LITTLE_ENDIAN); + case _9P_TLOPEN: + fid = tvb_get_letohl(tvb, offset); + ti = proto_tree_add_item(ninep_tree, hf_9P_fid, tvb, offset, 4, ENC_LITTLE_ENDIAN); + proto_item_append_text(ti, " (%s)", conv_get_fid(pinfo, fid)); offset +=4; + + ti = proto_tree_add_item(ninep_tree, hf_9P_statmode, tvb, offset, 4, ENC_LITTLE_ENDIAN); + dissect_9P_lflags(tvb,ti,offset); + offset += 4; + + conv_set_tag(pinfo, tag, ninemsg, fid); + break; + + case _9P_TOPEN: + fid = tvb_get_letohl(tvb, offset); + ti = proto_tree_add_item(ninep_tree, hf_9P_fid, tvb, offset, 4, ENC_LITTLE_ENDIAN); + proto_item_append_text(ti, " (%s)", conv_get_fid(pinfo, fid)); + offset +=4; + ti = proto_tree_add_item(ninep_tree, hf_9P_mode, tvb, offset, 1, ENC_LITTLE_ENDIAN); dissect_9P_mode(tvb,ti,offset); + offset += 1; + + conv_set_tag(pinfo, tag, ninemsg, fid); break; - case ROPEN: - dissect_9P_qid(tvb,ninep_tree,offset); - offset += 13; - proto_tree_add_item(ninep_tree, hf_9P_iounit, tvb, offset, 4, ENC_LITTLE_ENDIAN); - break; - case TCREATE: - proto_tree_add_item(ninep_tree, hf_9P_fid, tvb, offset, 4, ENC_LITTLE_ENDIAN); + case _9P_TCREATE: + fid = tvb_get_letohl(tvb, offset); + ti = proto_tree_add_item(ninep_tree, hf_9P_fid, tvb, offset, 4, ENC_LITTLE_ENDIAN); + proto_item_append_text(ti, " (%s)", conv_get_fid(pinfo, fid)); offset +=4; tmp16 = tvb_get_letohs(tvb,offset); @@ -399,23 +1391,56 @@ static int dissect_9P(tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree, vo ti = proto_tree_add_item(ninep_tree, hf_9P_mode, tvb, offset, 1, ENC_LITTLE_ENDIAN); dissect_9P_mode(tvb,ti,offset); + offset +=1; + proto_tree_add_item(ninep_tree, hf_9P_gid, tvb, offset, 4, ENC_LITTLE_ENDIAN); + offset += 4; + + conv_set_tag(pinfo, tag, ninemsg, fid); break; - case RCREATE: - dissect_9P_qid(tvb,ninep_tree,offset); - offset += 13; - proto_tree_add_item(ninep_tree, hf_9P_iounit, tvb, offset, 4, ENC_LITTLE_ENDIAN); + + case _9P_TLCREATE: + fid = tvb_get_letohl(tvb, offset); + ti = proto_tree_add_item(ninep_tree, hf_9P_fid, tvb, offset, 4, ENC_LITTLE_ENDIAN); + proto_item_append_text(ti, " (%s)", conv_get_fid(pinfo, fid)); + offset +=4; + + tmp16 = tvb_get_letohs(tvb,offset); + ti = proto_tree_add_item(ninep_tree, hf_9P_name, tvb, offset+2, tmp16, ENC_UTF_8|ENC_NA); + tmp_tree = proto_item_add_subtree(ti,ett_9P_filename); + proto_tree_add_item(tmp_tree, hf_9P_parmsz, tvb, offset, 2, ENC_LITTLE_ENDIAN); + offset += tmp16 + 2; + + ti = proto_tree_add_item(ninep_tree, hf_9P_lflags, tvb, offset, 4, ENC_LITTLE_ENDIAN); + dissect_9P_lflags(tvb, ti, offset); + offset += 4; + + ti = proto_tree_add_item(ninep_tree, hf_9P_statmode, tvb, offset, 4, ENC_LITTLE_ENDIAN); + dissect_9P_dm(tvb,ti,offset,0); + offset += 4; + + proto_tree_add_item(ninep_tree, hf_9P_gid, tvb, offset, 4, ENC_LITTLE_ENDIAN); + offset += 4; + + conv_set_tag(pinfo, tag, ninemsg, fid); break; - case TREAD: - proto_tree_add_item(ninep_tree, hf_9P_fid, tvb, offset, 4, ENC_LITTLE_ENDIAN); + + case _9P_TREAD: + case _9P_TREADDIR: + fid = tvb_get_letohl(tvb, offset); + ti = proto_tree_add_item(ninep_tree, hf_9P_fid, tvb, offset, 4, ENC_LITTLE_ENDIAN); + proto_item_append_text(ti, " (%s)", conv_get_fid(pinfo, fid)); offset +=4; proto_tree_add_item(ninep_tree, hf_9P_offset, tvb, offset, 8, ENC_LITTLE_ENDIAN); offset +=8; proto_tree_add_item(ninep_tree, hf_9P_count, tvb, offset, 4, ENC_LITTLE_ENDIAN); + offset +=4; + conv_set_tag(pinfo, tag, ninemsg, fid); break; - case RREAD: + case _9P_RREAD: + case _9P_RREADDIR: tmp = tvb_get_letohl(tvb,offset); proto_tree_add_item(ninep_tree, hf_9P_count, tvb, offset, 4, ENC_LITTLE_ENDIAN); offset += 4; @@ -424,9 +1449,12 @@ static int dissect_9P(tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree, vo reportedlen = ((gint)tmp&0xffff) > len ? len : (gint)tmp&0xffff; next_tvb = tvb_new_subset(tvb, offset, len, reportedlen); call_dissector(data_handle,next_tvb, pinfo, tree); + conv_free_tag(pinfo, tag); break; - case TWRITE: - proto_tree_add_item(ninep_tree, hf_9P_fid, tvb, offset, 4, ENC_LITTLE_ENDIAN); + case _9P_TWRITE: + fid = tvb_get_letohl(tvb, offset); + ti = proto_tree_add_item(ninep_tree, hf_9P_fid, tvb, offset, 4, ENC_LITTLE_ENDIAN); + proto_item_append_text(ti, " (%s)", conv_get_fid(pinfo, fid)); offset +=4; proto_tree_add_item(ninep_tree, hf_9P_offset, tvb, offset, 8, ENC_LITTLE_ENDIAN); @@ -439,26 +1467,14 @@ static int dissect_9P(tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree, vo reportedlen = ((gint)tmp&0xffff) > len ? len : (gint)tmp&0xffff; next_tvb = tvb_new_subset(tvb, offset, len, reportedlen); call_dissector(data_handle,next_tvb, pinfo, tree); + conv_set_tag(pinfo, tag, ninemsg, fid); break; - case RWRITE: + case _9P_RWRITE: proto_tree_add_item(ninep_tree, hf_9P_count, tvb, offset, 4, ENC_LITTLE_ENDIAN); + conv_free_tag(pinfo, tag); break; - case TCLUNK: - proto_tree_add_item(ninep_tree, hf_9P_fid, tvb, offset, 4, ENC_LITTLE_ENDIAN); - break; - case RCLUNK: - break; - case TREMOVE: - proto_tree_add_item(ninep_tree, hf_9P_fid, tvb, offset, 4, ENC_LITTLE_ENDIAN); - - break; - case RREMOVE: - break; - case TSTAT: - proto_tree_add_item(ninep_tree, hf_9P_fid, tvb, offset, 4, ENC_LITTLE_ENDIAN); - break; - case RSTAT: + case _9P_RSTAT: proto_tree_add_item(ninep_tree, hf_9P_parmsz, tvb, offset, 2, ENC_LITTLE_ENDIAN); offset +=2; @@ -498,14 +1514,14 @@ static int dissect_9P(tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree, vo offset += tmp16+2; tmp16 = tvb_get_letohs(tvb,offset); - ti = proto_tree_add_item(ninep_tree, hf_9P_uid, tvb, offset+2, tmp16, ENC_UTF_8|ENC_NA); - tmp_tree = proto_item_add_subtree(ti,ett_9P_uid); + ti = proto_tree_add_item(ninep_tree, hf_9P_user, tvb, offset+2, tmp16, ENC_UTF_8|ENC_NA); + tmp_tree = proto_item_add_subtree(ti,ett_9P_user); proto_tree_add_item(tmp_tree, hf_9P_parmsz, tvb, offset, 2, ENC_LITTLE_ENDIAN); offset += tmp16+2; tmp16 = tvb_get_letohs(tvb,offset); - ti = proto_tree_add_item(ninep_tree, hf_9P_gid, tvb, offset+2, tmp16, ENC_UTF_8|ENC_NA); - tmp_tree = proto_item_add_subtree(ti,ett_9P_gid); + ti = proto_tree_add_item(ninep_tree, hf_9P_group, tvb, offset+2, tmp16, ENC_UTF_8|ENC_NA); + tmp_tree = proto_item_add_subtree(ti,ett_9P_group); proto_tree_add_item(tmp_tree, hf_9P_parmsz, tvb, offset, 2, ENC_LITTLE_ENDIAN); offset += tmp16+2; @@ -515,8 +1531,10 @@ static int dissect_9P(tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree, vo proto_tree_add_item(tmp_tree, hf_9P_parmsz, tvb, offset, 2, ENC_LITTLE_ENDIAN); offset += tmp16+2; break; - case TWSTAT: - proto_tree_add_item(ninep_tree, hf_9P_fid, tvb, offset, 4, ENC_LITTLE_ENDIAN); + case _9P_TWSTAT: + fid = tvb_get_letohl(tvb, offset); + ti = proto_tree_add_item(ninep_tree, hf_9P_fid, tvb, offset, 4, ENC_LITTLE_ENDIAN); + proto_item_append_text(ti, " (%s)", conv_get_fid(pinfo, fid)); offset += 4; proto_tree_add_item(ninep_tree, hf_9P_parmsz, tvb, offset, 2, ENC_LITTLE_ENDIAN); @@ -558,14 +1576,14 @@ static int dissect_9P(tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree, vo offset += tmp16+2; tmp16 = tvb_get_letohs(tvb,offset); - ti = proto_tree_add_item(ninep_tree, hf_9P_uid, tvb, offset+2, tmp16, ENC_UTF_8|ENC_NA); - tmp_tree = proto_item_add_subtree(ti,ett_9P_uid); + ti = proto_tree_add_item(ninep_tree, hf_9P_user, tvb, offset+2, tmp16, ENC_UTF_8|ENC_NA); + tmp_tree = proto_item_add_subtree(ti,ett_9P_user); proto_tree_add_item(tmp_tree, hf_9P_parmsz, tvb, offset, 2, ENC_LITTLE_ENDIAN); offset += tmp16+2; tmp16 = tvb_get_letohs(tvb,offset); - ti = proto_tree_add_item(ninep_tree, hf_9P_gid, tvb, offset+2, tmp16, ENC_UTF_8|ENC_NA); - tmp_tree = proto_item_add_subtree(ti,ett_9P_gid); + ti = proto_tree_add_item(ninep_tree, hf_9P_group, tvb, offset+2, tmp16, ENC_UTF_8|ENC_NA); + tmp_tree = proto_item_add_subtree(ti,ett_9P_group); proto_tree_add_item(tmp_tree, hf_9P_parmsz, tvb, offset, 2, ENC_LITTLE_ENDIAN); offset += tmp16+2; @@ -574,6 +1592,494 @@ static int dissect_9P(tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree, vo tmp_tree = proto_item_add_subtree(ti,ett_9P_muid); proto_tree_add_item(tmp_tree, hf_9P_parmsz, tvb, offset, 2, ENC_LITTLE_ENDIAN); offset += tmp16+2; + conv_free_tag(pinfo, tag); + break; + + case _9P_TGETATTR: + fid = tvb_get_letohl(tvb, offset); + ti = proto_tree_add_item(ninep_tree, hf_9P_fid, tvb, offset, 4, ENC_LITTLE_ENDIAN); + proto_item_append_text(ti, " (%s)", conv_get_fid(pinfo, fid)); + offset += 4; + + ti = proto_tree_add_item(ninep_tree, hf_9P_getattr_flags, tvb, offset, 8, ENC_LITTLE_ENDIAN); + dissect_9P_getattrflags(tvb,ti,offset); + offset += 8; + conv_set_tag(pinfo, tag, ninemsg, fid); + break; + + case _9P_RGETATTR: + ti = proto_tree_add_item(ninep_tree, hf_9P_getattr_flags, tvb, offset, 8, ENC_LITTLE_ENDIAN); + dissect_9P_getattrflags(tvb,ti,offset); + offset += 8; + + dissect_9P_qid(tvb,ninep_tree,offset); + offset += 13; + + ti = proto_tree_add_item(ninep_tree, hf_9P_statmode, tvb, offset, 4, ENC_LITTLE_ENDIAN); + dissect_9P_dm(tvb,ti,offset,0); + offset += 4; + + proto_tree_add_item(ninep_tree, hf_9P_uid, tvb, offset, 4, ENC_LITTLE_ENDIAN); + offset += 4; + + proto_tree_add_item(ninep_tree, hf_9P_gid, tvb, offset, 4, ENC_LITTLE_ENDIAN); + offset += 4; + + proto_tree_add_item(ninep_tree, hf_9P_nlink, tvb, offset, 8, ENC_LITTLE_ENDIAN); + offset += 8; + + proto_tree_add_item(ninep_tree, hf_9P_rdev, tvb, offset, 8, ENC_LITTLE_ENDIAN); + offset += 8; + + proto_tree_add_item(ninep_tree, hf_9P_size, tvb, offset, 8, ENC_LITTLE_ENDIAN); + offset += 8; + + proto_tree_add_item(ninep_tree, hf_9P_blksize, tvb, offset, 8, ENC_LITTLE_ENDIAN); + offset += 8; + + proto_tree_add_item(ninep_tree, hf_9P_blocks, tvb, offset, 8, ENC_LITTLE_ENDIAN); + offset += 8; + + tv.secs = tvb_get_letoh64(tvb,offset); + tv.nsecs = tvb_get_letoh64(tvb,offset+8);; + proto_tree_add_time(ninep_tree, hf_9P_atime, tvb, offset, 16, &tv); + offset += 16; + + tv.secs = tvb_get_letoh64(tvb,offset); + tv.nsecs = tvb_get_letoh64(tvb,offset+8);; + proto_tree_add_time(ninep_tree, hf_9P_mtime, tvb, offset, 16, &tv); + offset += 16; + + tv.secs = tvb_get_letoh64(tvb,offset); + tv.nsecs = tvb_get_letoh64(tvb,offset+8);; + proto_tree_add_time(ninep_tree, hf_9P_ctime, tvb, offset, 16, &tv); + offset += 16; + + tv.secs = tvb_get_letoh64(tvb,offset); + tv.nsecs = tvb_get_letoh64(tvb,offset+8);; + proto_tree_add_time(ninep_tree, hf_9P_btime, tvb, offset, 16, &tv); + offset += 16; + + proto_tree_add_item(ninep_tree, hf_9P_gen, tvb, offset, 8, ENC_LITTLE_ENDIAN); + offset += 8; + + proto_tree_add_item(ninep_tree, hf_9P_dataversion, tvb, offset, 8, ENC_LITTLE_ENDIAN); + offset += 8; + + conv_free_tag(pinfo, tag); + break; + + case _9P_TSETATTR: + fid = tvb_get_letohl(tvb, offset); + ti = proto_tree_add_item(ninep_tree, hf_9P_fid, tvb, offset, 4, ENC_LITTLE_ENDIAN); + proto_item_append_text(ti, " (%s)", conv_get_fid(pinfo, fid)); + offset += 4; + + ti = proto_tree_add_item(ninep_tree, hf_9P_setattr_flags, tvb, offset, 4, ENC_LITTLE_ENDIAN); + dissect_9P_setattrflags(tvb,ti,offset); + offset += 4; + + ti = proto_tree_add_item(ninep_tree, hf_9P_statmode, tvb, offset, 4, ENC_LITTLE_ENDIAN); + dissect_9P_dm(tvb,ti,offset,0); + offset += 4; + + proto_tree_add_item(ninep_tree, hf_9P_uid, tvb, offset, 4, ENC_LITTLE_ENDIAN); + offset += 4; + + proto_tree_add_item(ninep_tree, hf_9P_gid, tvb, offset, 4, ENC_LITTLE_ENDIAN); + offset += 4; + + proto_tree_add_item(ninep_tree, hf_9P_size, tvb, offset, 8, ENC_LITTLE_ENDIAN); + offset += 8; + + tv.secs = tvb_get_letoh64(tvb,offset); + tv.nsecs = tvb_get_letoh64(tvb,offset+8);; + proto_tree_add_time(ninep_tree, hf_9P_atime, tvb, offset, 16, &tv); + offset += 16; + + tv.secs = tvb_get_letoh64(tvb,offset); + tv.nsecs = tvb_get_letoh64(tvb,offset+8);; + proto_tree_add_time(ninep_tree, hf_9P_mtime, tvb, offset, 16, &tv); + offset += 16; + + conv_set_tag(pinfo, tag, ninemsg, fid); + break; + + case _9P_RSTATFS: + proto_tree_add_item(ninep_tree, hf_9P_fstype, tvb, offset, 4, ENC_LITTLE_ENDIAN); + offset += 4; + + proto_tree_add_item(ninep_tree, hf_9P_blksize, tvb, offset, 4, ENC_LITTLE_ENDIAN); + offset += 4; + + proto_tree_add_item(ninep_tree, hf_9P_blocks, tvb, offset, 8, ENC_LITTLE_ENDIAN); + offset += 8; + + proto_tree_add_item(ninep_tree, hf_9P_bfree, tvb, offset, 8, ENC_LITTLE_ENDIAN); + offset += 8; + + proto_tree_add_item(ninep_tree, hf_9P_bavail, tvb, offset, 8, ENC_LITTLE_ENDIAN); + offset += 8; + + proto_tree_add_item(ninep_tree, hf_9P_files, tvb, offset, 8, ENC_LITTLE_ENDIAN); + offset += 8; + + proto_tree_add_item(ninep_tree, hf_9P_ffree, tvb, offset, 8, ENC_LITTLE_ENDIAN); + offset += 8; + + proto_tree_add_item(ninep_tree, hf_9P_fsid, tvb, offset, 8, ENC_LITTLE_ENDIAN); + offset += 8; + + proto_tree_add_item(ninep_tree, hf_9P_namelen, tvb, offset, 4, ENC_LITTLE_ENDIAN); + offset += 4; + + conv_free_tag(pinfo, tag); + break; + + case _9P_TSYMLINK: + fid = tvb_get_letohl(tvb, offset); + ti = proto_tree_add_item(ninep_tree, hf_9P_fid, tvb, offset, 4, ENC_LITTLE_ENDIAN); + proto_item_append_text(ti, " (%s)", conv_get_fid(pinfo, fid)); + offset += 4; + + tmp16 = tvb_get_letohs(tvb,offset); + ti = proto_tree_add_item(ninep_tree, hf_9P_wname, tvb, offset+2, tmp16, ENC_UTF_8|ENC_NA); + tmp_tree = proto_item_add_subtree(ti, ett_9P_wname); + proto_tree_add_item(tmp_tree, hf_9P_parmsz, tvb, offset, 2, ENC_LITTLE_ENDIAN); + offset += tmp16 + 2; + + tmp16 = tvb_get_letohs(tvb,offset); + ti = proto_tree_add_item(ninep_tree, hf_9P_wname, tvb, offset+2, tmp16, ENC_UTF_8|ENC_NA); + tmp_tree = proto_item_add_subtree(ti, ett_9P_wname); + proto_tree_add_item(tmp_tree, hf_9P_parmsz, tvb, offset, 2, ENC_LITTLE_ENDIAN); + offset += tmp16 + 2; + + proto_tree_add_item(ninep_tree, hf_9P_gid, tvb, offset, 4, ENC_LITTLE_ENDIAN); + offset += 4; + + conv_set_tag(pinfo, tag, ninemsg, fid); + break; + + case _9P_TMKNOD: + fid = tvb_get_letohl(tvb, offset); + ti = proto_tree_add_item(ninep_tree, hf_9P_fid, tvb, offset, 4, ENC_LITTLE_ENDIAN); + proto_item_append_text(ti, " (%s)", conv_get_fid(pinfo, fid)); + offset += 4; + + tmp16 = tvb_get_letohs(tvb,offset); + ti = proto_tree_add_item(ninep_tree, hf_9P_wname, tvb, offset+2, tmp16, ENC_UTF_8|ENC_NA); + tmp_tree = proto_item_add_subtree(ti, ett_9P_wname); + proto_tree_add_item(tmp_tree, hf_9P_parmsz, tvb, offset, 2, ENC_LITTLE_ENDIAN); + offset += tmp16 + 2; + + ti = proto_tree_add_item(ninep_tree, hf_9P_statmode, tvb, offset, 4, ENC_LITTLE_ENDIAN); + dissect_9P_dm(tvb,ti,offset,0); + offset += 4; + + proto_tree_add_item(ninep_tree, hf_9P_mknod_major, tvb, offset, 4, ENC_LITTLE_ENDIAN); + offset += 4; + + proto_tree_add_item(ninep_tree, hf_9P_mknod_minor, tvb, offset, 4, ENC_LITTLE_ENDIAN); + offset += 4; + + proto_tree_add_item(ninep_tree, hf_9P_gid, tvb, offset, 4, ENC_LITTLE_ENDIAN); + offset += 4; + + conv_set_tag(pinfo, tag, ninemsg, fid); + break; + + case _9P_TRENAME: + fid = tvb_get_letohl(tvb, offset); + ti = proto_tree_add_item(ninep_tree, hf_9P_fid, tvb, offset, 4, ENC_LITTLE_ENDIAN); + proto_item_append_text(ti, " (%s)", conv_get_fid(pinfo, fid)); + offset += 4; + + fid = tvb_get_letohl(tvb, offset); + ti = proto_tree_add_item(ninep_tree, hf_9P_dfid, tvb, offset, 4, ENC_LITTLE_ENDIAN); + proto_item_append_text(ti, " (%s)", conv_get_fid(pinfo, fid)); + offset += 4; + + tmp16 = tvb_get_letohs(tvb,offset); + ti = proto_tree_add_item(ninep_tree, hf_9P_wname, tvb, offset+2, tmp16, ENC_UTF_8|ENC_NA); + tmp_tree = proto_item_add_subtree(ti, ett_9P_wname); + proto_tree_add_item(tmp_tree, hf_9P_parmsz, tvb, offset, 2, ENC_LITTLE_ENDIAN); + offset += tmp16 + 2; + + conv_set_tag(pinfo, tag, ninemsg, fid); + break; + + case _9P_RREADLINK: + tmp16 = tvb_get_letohs(tvb,offset); + ti = proto_tree_add_item(ninep_tree, hf_9P_wname, tvb, offset+2, tmp16, ENC_UTF_8|ENC_NA); + tmp_tree = proto_item_add_subtree(ti, ett_9P_wname); + proto_tree_add_item(tmp_tree, hf_9P_parmsz, tvb, offset, 2, ENC_LITTLE_ENDIAN); + offset += tmp16 + 2; + + conv_free_tag(pinfo, tag); + break; + + case _9P_TXATTRWALK: + fid = tvb_get_letohl(tvb, offset); + ti = proto_tree_add_item(ninep_tree, hf_9P_fid, tvb, offset, 4, ENC_LITTLE_ENDIAN); + tmps = conv_get_fid(pinfo, fid); + proto_item_append_text(ti, " (%s)", tmps); + offset +=4; + + fid = tvb_get_letohl(tvb, offset); + proto_tree_add_item(ninep_tree, hf_9P_newfid, tvb, offset, 4, ENC_LITTLE_ENDIAN); + conv_set_fid(pinfo, fid, tmps, strlen(tmps)+1); + offset +=4; + + tmp16 = tvb_get_letohs(tvb,offset); + ti = proto_tree_add_item(ninep_tree, hf_9P_wname, tvb, offset+2, tmp16, ENC_UTF_8|ENC_NA); + tmp_tree = proto_item_add_subtree(ti, ett_9P_wname); + proto_tree_add_item(tmp_tree, hf_9P_parmsz, tvb, offset, 2, ENC_LITTLE_ENDIAN); + offset += tmp16 + 2; + + conv_set_tag(pinfo, tag, ninemsg, fid); + break; + + case _9P_RXATTRWALK: + proto_tree_add_item(ninep_tree, hf_9P_size, tvb, offset, 8, ENC_LITTLE_ENDIAN); + offset += 8; + + conv_free_tag(pinfo, tag); + break; + + case _9P_TXATTRCREATE: + fid = tvb_get_letohl(tvb, offset); + ti = proto_tree_add_item(ninep_tree, hf_9P_fid, tvb, offset, 4, ENC_LITTLE_ENDIAN); + proto_item_append_text(ti, " (%s)", conv_get_fid(pinfo, fid)); + offset +=4; + + tmp16 = tvb_get_letohs(tvb,offset); + ti = proto_tree_add_item(ninep_tree, hf_9P_wname, tvb, offset+2, tmp16, ENC_UTF_8|ENC_NA); + tmp_tree = proto_item_add_subtree(ti, ett_9P_wname); + proto_tree_add_item(tmp_tree, hf_9P_parmsz, tvb, offset, 2, ENC_LITTLE_ENDIAN); + offset += tmp16 + 2; + + proto_tree_add_item(ninep_tree, hf_9P_size, tvb, offset, 8, ENC_LITTLE_ENDIAN); + offset += 8; + + proto_tree_add_item(ninep_tree, hf_9P_xattr_flag, tvb, offset, 4, ENC_LITTLE_ENDIAN); + offset += 4; + + conv_set_tag(pinfo, tag, ninemsg, fid); + break; + + case _9P_TLOCK: + case _9P_TGETLOCK: + fid = tvb_get_letohl(tvb, offset); + ti = proto_tree_add_item(ninep_tree, hf_9P_fid, tvb, offset, 4, ENC_LITTLE_ENDIAN); + proto_item_append_text(ti, " (%s)", conv_get_fid(pinfo, fid)); + offset += 4; + + proto_tree_add_item(ninep_tree, hf_9P_lock_type, tvb, offset, 1, ENC_LITTLE_ENDIAN); + offset += 1; + + proto_tree_add_item(ninep_tree, hf_9P_lock_flag, tvb, offset, 4, ENC_LITTLE_ENDIAN); + offset += 4; + + proto_tree_add_item(ninep_tree, hf_9P_lock_start, tvb, offset, 8, ENC_LITTLE_ENDIAN); + offset += 8; + + proto_tree_add_item(ninep_tree, hf_9P_lock_length, tvb, offset, 8, ENC_LITTLE_ENDIAN); + offset += 8; + + proto_tree_add_item(ninep_tree, hf_9P_lock_procid, tvb, offset, 4, ENC_LITTLE_ENDIAN); + offset += 4; + + tmp16 = tvb_get_letohs(tvb,offset); + ti = proto_tree_add_item(ninep_tree, hf_9P_wname, tvb, offset+2, tmp16, ENC_UTF_8|ENC_NA); + tmp_tree = proto_item_add_subtree(ti, ett_9P_wname); + proto_tree_add_item(tmp_tree, hf_9P_parmsz, tvb, offset, 2, ENC_LITTLE_ENDIAN); + offset += tmp16 + 2; + + conv_set_tag(pinfo, tag, ninemsg, fid); + break; + + case _9P_RLOCK: + proto_tree_add_item(ninep_tree, hf_9P_lock_status, tvb, offset, 1, ENC_LITTLE_ENDIAN); + offset += 1; + + conv_free_tag(pinfo, tag); + break; + + case _9P_RGETLOCK: + proto_tree_add_item(ninep_tree, hf_9P_lock_type, tvb, offset, 1, ENC_LITTLE_ENDIAN); + offset += 1; + + proto_tree_add_item(ninep_tree, hf_9P_lock_flag, tvb, offset, 4, ENC_LITTLE_ENDIAN); + offset += 4; + + proto_tree_add_item(ninep_tree, hf_9P_lock_start, tvb, offset, 8, ENC_LITTLE_ENDIAN); + offset += 8; + + proto_tree_add_item(ninep_tree, hf_9P_lock_length, tvb, offset, 8, ENC_LITTLE_ENDIAN); + offset += 8; + + proto_tree_add_item(ninep_tree, hf_9P_lock_procid, tvb, offset, 4, ENC_LITTLE_ENDIAN); + offset += 4; + + tmp16 = tvb_get_letohs(tvb,offset); + ti = proto_tree_add_item(ninep_tree, hf_9P_wname, tvb, offset+2, tmp16, ENC_UTF_8|ENC_NA); + tmp_tree = proto_item_add_subtree(ti, ett_9P_wname); + proto_tree_add_item(tmp_tree, hf_9P_parmsz, tvb, offset, 2, ENC_LITTLE_ENDIAN); + offset += tmp16 + 2; + + conv_free_tag(pinfo, tag); + break; + + case _9P_TLINK: + fid = tvb_get_letohl(tvb, offset); + ti = proto_tree_add_item(ninep_tree, hf_9P_dfid, tvb, offset, 4, ENC_LITTLE_ENDIAN); + proto_item_append_text(ti, " (%s)", conv_get_fid(pinfo, fid)); + offset += 4; + + fid = tvb_get_letohl(tvb, offset); + ti = proto_tree_add_item(ninep_tree, hf_9P_fid, tvb, offset, 4, ENC_LITTLE_ENDIAN); + proto_item_append_text(ti, " (%s)", conv_get_fid(pinfo, fid)); + offset += 4; + + tmp16 = tvb_get_letohs(tvb,offset); + ti = proto_tree_add_item(ninep_tree, hf_9P_wname, tvb, offset+2, tmp16, ENC_UTF_8|ENC_NA); + tmp_tree = proto_item_add_subtree(ti, ett_9P_wname); + proto_tree_add_item(tmp_tree, hf_9P_parmsz, tvb, offset, 2, ENC_LITTLE_ENDIAN); + offset += tmp16 + 2; + + conv_set_tag(pinfo, tag, ninemsg, fid); + break; + + case _9P_TMKDIR: + fid = tvb_get_letohl(tvb, offset); + ti = proto_tree_add_item(ninep_tree, hf_9P_fid, tvb, offset, 4, ENC_LITTLE_ENDIAN); + proto_item_append_text(ti, " (%s)", conv_get_fid(pinfo, fid)); + offset += 4; + + tmp16 = tvb_get_letohs(tvb,offset); + ti = proto_tree_add_item(ninep_tree, hf_9P_wname, tvb, offset+2, tmp16, ENC_UTF_8|ENC_NA); + tmp_tree = proto_item_add_subtree(ti, ett_9P_wname); + proto_tree_add_item(tmp_tree, hf_9P_parmsz, tvb, offset, 2, ENC_LITTLE_ENDIAN); + offset += tmp16 + 2; + + ti = proto_tree_add_item(ninep_tree, hf_9P_statmode, tvb, offset, 4, ENC_LITTLE_ENDIAN); + dissect_9P_dm(tvb,ti,offset,0); + offset += 4; + + proto_tree_add_item(ninep_tree, hf_9P_gid, tvb, offset, 4, ENC_LITTLE_ENDIAN); + offset += 4; + + conv_set_tag(pinfo, tag, ninemsg, fid); + break; + + case _9P_TRENAMEAT: + fid = tvb_get_letohl(tvb, offset); + ti = proto_tree_add_item(ninep_tree, hf_9P_dfid, tvb, offset, 4, ENC_LITTLE_ENDIAN); + proto_item_append_text(ti, " (%s)", conv_get_fid(pinfo, fid)); + offset += 4; + + tmp16 = tvb_get_letohs(tvb,offset); + ti = proto_tree_add_item(ninep_tree, hf_9P_wname, tvb, offset+2, tmp16, ENC_UTF_8|ENC_NA); + tmp_tree = proto_item_add_subtree(ti, ett_9P_wname); + proto_tree_add_item(tmp_tree, hf_9P_parmsz, tvb, offset, 2, ENC_LITTLE_ENDIAN); + offset += tmp16 + 2; + + fid = tvb_get_letohl(tvb, offset); + ti = proto_tree_add_item(ninep_tree, hf_9P_newfid, tvb, offset, 4, ENC_LITTLE_ENDIAN); + proto_item_append_text(ti, " (%s)", conv_get_fid(pinfo, fid)); + offset += 4; + + tmp16 = tvb_get_letohs(tvb,offset); + ti = proto_tree_add_item(ninep_tree, hf_9P_wname, tvb, offset+2, tmp16, ENC_UTF_8|ENC_NA); + tmp_tree = proto_item_add_subtree(ti, ett_9P_wname); + proto_tree_add_item(tmp_tree, hf_9P_parmsz, tvb, offset, 2, ENC_LITTLE_ENDIAN); + offset += tmp16 + 2; + + conv_set_tag(pinfo, tag, ninemsg, fid); + break; + + case _9P_TUNLINKAT: + fid = tvb_get_letohl(tvb, offset); + ti = proto_tree_add_item(ninep_tree, hf_9P_dfid, tvb, offset, 4, ENC_LITTLE_ENDIAN); + proto_item_append_text(ti, " (%s)", conv_get_fid(pinfo, fid)); + offset += 4; + + tmp16 = tvb_get_letohs(tvb,offset); + ti = proto_tree_add_item(ninep_tree, hf_9P_wname, tvb, offset+2, tmp16, ENC_UTF_8|ENC_NA); + tmp_tree = proto_item_add_subtree(ti, ett_9P_wname); + proto_tree_add_item(tmp_tree, hf_9P_parmsz, tvb, offset, 2, ENC_LITTLE_ENDIAN); + offset += tmp16 + 2; + + /* missing 32bit flag, no clue what meaning it has */ + + conv_set_tag(pinfo, tag, ninemsg, fid); + break; + + /* Request with only fid */ + case _9P_TSTATFS: + case _9P_TREADLINK: + case _9P_TFSYNC: + case _9P_TREMOVE: + case _9P_TSTAT: + fid = tvb_get_letohl(tvb, offset); + ti = proto_tree_add_item(ninep_tree, hf_9P_fid, tvb, offset, 4, ENC_LITTLE_ENDIAN); + proto_item_append_text(ti, " (%s)", conv_get_fid(pinfo, fid)); + conv_set_tag(pinfo, tag, ninemsg, fid); + break; + + case _9P_TCLUNK: + fid = tvb_get_letohl(tvb, offset); + ti = proto_tree_add_item(ninep_tree, hf_9P_fid, tvb, offset, 4, ENC_LITTLE_ENDIAN); + proto_item_append_text(ti, " (%s)", conv_get_fid(pinfo, fid)); + + conv_free_fid(pinfo, fid); + conv_set_tag(pinfo, tag, ninemsg, fid); + break; + + /* Reply with qid and ionuit */ + case _9P_ROPEN: + case _9P_RLOPEN: + case _9P_RCREATE: + case _9P_RLCREATE: + dissect_9P_qid(tvb,ninep_tree,offset); + offset += 13; + proto_tree_add_item(ninep_tree, hf_9P_iounit, tvb, offset, 4, ENC_LITTLE_ENDIAN); + offset += 4; + conv_free_tag(pinfo, tag); + break; + + /* Reply with only qid */ + case _9P_RSYMLINK: + case _9P_RMKNOD: + case _9P_RMKDIR: + case _9P_RAUTH: + case _9P_RATTACH: + dissect_9P_qid(tvb,ninep_tree,offset); + offset += 13; + conv_free_tag(pinfo, tag); + break; + + /* Empty reply */ + case _9P_RRENAME: + case _9P_RSETATTR: + case _9P_RXATTRCREATE: + case _9P_RFSYNC: + case _9P_RLINK: + case _9P_RRENAMEAT: + case _9P_RUNLINKAT: + case _9P_RFLUSH: + case _9P_RCLUNK: + case _9P_RREMOVE: + /* Unhandled reply */ + case _9P_RWSTAT: + case _9P_RLERROR: + conv_free_tag(pinfo, tag); + break; + + /* Should-not-happen query */ + case _9P_TLERROR: + case _9P_TERROR: + conv_set_tag(pinfo, tag, ninemsg, _9P_NOFID); break; } return offset; @@ -615,12 +2121,12 @@ static void dissect_9P_qid(tvbuff_t * tvb, proto_tree * tree,int offset) qidtype_item = proto_tree_add_item(qid_tree, hf_9P_qidtype, tvb, offset, 1, ENC_LITTLE_ENDIAN); qidtype_tree = proto_item_add_subtree(qidtype_item,ett_9P_qidtype); - proto_tree_add_item(qidtype_tree, hf_9P_qidtype_dir, tvb, offset, 1, ENC_LITTLE_ENDIAN); - proto_tree_add_item(qidtype_tree, hf_9P_qidtype_append, tvb, offset, 1, ENC_LITTLE_ENDIAN); - proto_tree_add_item(qidtype_tree, hf_9P_qidtype_exclusive, tvb, offset, 1, ENC_LITTLE_ENDIAN); - proto_tree_add_item(qidtype_tree, hf_9P_qidtype_mount, tvb, offset, 1, ENC_LITTLE_ENDIAN); - proto_tree_add_item(qidtype_tree, hf_9P_qidtype_auth_file, tvb, offset, 1, ENC_LITTLE_ENDIAN); - proto_tree_add_item(qidtype_tree, hf_9P_qidtype_temp_file, tvb, offset, 1, ENC_LITTLE_ENDIAN); + proto_tree_add_item(qidtype_tree, hf_9P_qidtype_dir, tvb, offset, 1, ENC_LITTLE_ENDIAN); + proto_tree_add_item(qidtype_tree, hf_9P_qidtype_append, tvb, offset, 1, ENC_LITTLE_ENDIAN); + proto_tree_add_item(qidtype_tree, hf_9P_qidtype_exclusive, tvb, offset, 1, ENC_LITTLE_ENDIAN); + proto_tree_add_item(qidtype_tree, hf_9P_qidtype_mount, tvb, offset, 1, ENC_LITTLE_ENDIAN); + proto_tree_add_item(qidtype_tree, hf_9P_qidtype_auth_file, tvb, offset, 1, ENC_LITTLE_ENDIAN); + proto_tree_add_item(qidtype_tree, hf_9P_qidtype_temp_file, tvb, offset, 1, ENC_LITTLE_ENDIAN); proto_tree_add_item(qid_tree, hf_9P_qidvers, tvb, offset+1, 4, ENC_LITTLE_ENDIAN); proto_tree_add_item(qid_tree, hf_9P_qidpath, tvb, offset+1+4, 8, ENC_LITTLE_ENDIAN); @@ -636,26 +2142,102 @@ static void dissect_9P_dm(tvbuff_t * tvb, proto_item * item,int offset,int iscr if(!mode_tree) return; - proto_tree_add_item(mode_tree, hf_9P_dm_dir, tvb, offset, 4, ENC_LITTLE_ENDIAN); + proto_tree_add_item(mode_tree, hf_9P_dm_dir, tvb, offset, 4, ENC_LITTLE_ENDIAN); if(!iscreate) { /* Not applicable to Tcreate (?) */ - proto_tree_add_item(mode_tree, hf_9P_dm_append, tvb, offset, 4, ENC_LITTLE_ENDIAN); - proto_tree_add_item(mode_tree, hf_9P_dm_exclusive, tvb, offset, 4, ENC_LITTLE_ENDIAN); - proto_tree_add_item(mode_tree, hf_9P_dm_mount, tvb, offset, 4, ENC_LITTLE_ENDIAN); - proto_tree_add_item(mode_tree, hf_9P_dm_auth_file, tvb, offset, 4, ENC_LITTLE_ENDIAN); - proto_tree_add_item(mode_tree, hf_9P_dm_temp_file, tvb, offset, 4, ENC_LITTLE_ENDIAN); + proto_tree_add_item(mode_tree, hf_9P_dm_append, tvb, offset, 4, ENC_LITTLE_ENDIAN); + proto_tree_add_item(mode_tree, hf_9P_dm_exclusive, tvb, offset, 4, ENC_LITTLE_ENDIAN); + proto_tree_add_item(mode_tree, hf_9P_dm_mount, tvb, offset, 4, ENC_LITTLE_ENDIAN); + proto_tree_add_item(mode_tree, hf_9P_dm_auth_file, tvb, offset, 4, ENC_LITTLE_ENDIAN); + proto_tree_add_item(mode_tree, hf_9P_dm_temp_file, tvb, offset, 4, ENC_LITTLE_ENDIAN); } - proto_tree_add_item(mode_tree, hf_9P_dm_read_owner, tvb, offset, 4, ENC_LITTLE_ENDIAN); - proto_tree_add_item(mode_tree, hf_9P_dm_write_owner, tvb, offset, 4, ENC_LITTLE_ENDIAN); - proto_tree_add_item(mode_tree, hf_9P_dm_exec_owner, tvb, offset, 4, ENC_LITTLE_ENDIAN); - proto_tree_add_item(mode_tree, hf_9P_dm_read_group, tvb, offset, 4, ENC_LITTLE_ENDIAN); - proto_tree_add_item(mode_tree, hf_9P_dm_write_group, tvb, offset, 4, ENC_LITTLE_ENDIAN); - proto_tree_add_item(mode_tree, hf_9P_dm_exec_group, tvb, offset, 4, ENC_LITTLE_ENDIAN); - proto_tree_add_item(mode_tree, hf_9P_dm_read_others, tvb, offset, 4, ENC_LITTLE_ENDIAN); - proto_tree_add_item(mode_tree, hf_9P_dm_write_others, tvb, offset, 4, ENC_LITTLE_ENDIAN); - proto_tree_add_item(mode_tree, hf_9P_dm_exec_others, tvb, offset, 4, ENC_LITTLE_ENDIAN); + proto_tree_add_item(mode_tree, hf_9P_dm_read_owner, tvb, offset, 4, ENC_LITTLE_ENDIAN); + proto_tree_add_item(mode_tree, hf_9P_dm_write_owner, tvb, offset, 4, ENC_LITTLE_ENDIAN); + proto_tree_add_item(mode_tree, hf_9P_dm_exec_owner, tvb, offset, 4, ENC_LITTLE_ENDIAN); + proto_tree_add_item(mode_tree, hf_9P_dm_read_group, tvb, offset, 4, ENC_LITTLE_ENDIAN); + proto_tree_add_item(mode_tree, hf_9P_dm_write_group, tvb, offset, 4, ENC_LITTLE_ENDIAN); + proto_tree_add_item(mode_tree, hf_9P_dm_exec_group, tvb, offset, 4, ENC_LITTLE_ENDIAN); + proto_tree_add_item(mode_tree, hf_9P_dm_read_others, tvb, offset, 4, ENC_LITTLE_ENDIAN); + proto_tree_add_item(mode_tree, hf_9P_dm_write_others, tvb, offset, 4, ENC_LITTLE_ENDIAN); + proto_tree_add_item(mode_tree, hf_9P_dm_exec_others, tvb, offset, 4, ENC_LITTLE_ENDIAN); +} + +/* Dissect 9P getattr_flags */ +static void dissect_9P_getattrflags(tvbuff_t *tvb, proto_item *item, int offset) +{ + proto_item *attrmask_tree; + + attrmask_tree = proto_item_add_subtree(item, ett_9P_getattr_flags); + if(!attrmask_tree) + return; + + /* fixme: This is actually 8 bytes (64bit) long, but masks have to fit on 32bit. */ + proto_tree_add_item(attrmask_tree, hf_9P_getattr_mode, tvb, offset, 4, ENC_LITTLE_ENDIAN); + proto_tree_add_item(attrmask_tree, hf_9P_getattr_nlink, tvb, offset, 4, ENC_LITTLE_ENDIAN); + proto_tree_add_item(attrmask_tree, hf_9P_getattr_uid, tvb, offset, 4, ENC_LITTLE_ENDIAN); + proto_tree_add_item(attrmask_tree, hf_9P_getattr_gid, tvb, offset, 4, ENC_LITTLE_ENDIAN); + proto_tree_add_item(attrmask_tree, hf_9P_getattr_rdev, tvb, offset, 4, ENC_LITTLE_ENDIAN); + proto_tree_add_item(attrmask_tree, hf_9P_getattr_atime, tvb, offset, 4, ENC_LITTLE_ENDIAN); + proto_tree_add_item(attrmask_tree, hf_9P_getattr_mtime, tvb, offset, 4, ENC_LITTLE_ENDIAN); + proto_tree_add_item(attrmask_tree, hf_9P_getattr_ctime, tvb, offset, 4, ENC_LITTLE_ENDIAN); + proto_tree_add_item(attrmask_tree, hf_9P_getattr_ino, tvb, offset, 4, ENC_LITTLE_ENDIAN); + proto_tree_add_item(attrmask_tree, hf_9P_getattr_size, tvb, offset, 4, ENC_LITTLE_ENDIAN); + proto_tree_add_item(attrmask_tree, hf_9P_getattr_blocks, tvb, offset, 4, ENC_LITTLE_ENDIAN); + proto_tree_add_item(attrmask_tree, hf_9P_getattr_btime, tvb, offset, 4, ENC_LITTLE_ENDIAN); + proto_tree_add_item(attrmask_tree, hf_9P_getattr_gen, tvb, offset, 4, ENC_LITTLE_ENDIAN); + proto_tree_add_item(attrmask_tree, hf_9P_getattr_dataversion, tvb, offset, 4, ENC_LITTLE_ENDIAN); +} + +/* Dissect 9P setattr_flags */ +static void dissect_9P_setattrflags(tvbuff_t *tvb, proto_item *item, int offset) +{ + proto_item *attrmask_tree; + + attrmask_tree = proto_item_add_subtree(item, ett_9P_setattr_flags); + if(!attrmask_tree) + return; + + proto_tree_add_item(attrmask_tree, hf_9P_setattr_mode, tvb, offset, 4, ENC_LITTLE_ENDIAN); + proto_tree_add_item(attrmask_tree, hf_9P_setattr_uid, tvb, offset, 4, ENC_LITTLE_ENDIAN); + proto_tree_add_item(attrmask_tree, hf_9P_setattr_gid, tvb, offset, 4, ENC_LITTLE_ENDIAN); + proto_tree_add_item(attrmask_tree, hf_9P_setattr_size, tvb, offset, 4, ENC_LITTLE_ENDIAN); + proto_tree_add_item(attrmask_tree, hf_9P_setattr_atime, tvb, offset, 4, ENC_LITTLE_ENDIAN); + proto_tree_add_item(attrmask_tree, hf_9P_setattr_mtime, tvb, offset, 4, ENC_LITTLE_ENDIAN); + proto_tree_add_item(attrmask_tree, hf_9P_setattr_ctime, tvb, offset, 4, ENC_LITTLE_ENDIAN); + proto_tree_add_item(attrmask_tree, hf_9P_setattr_atime_set, tvb, offset, 4, ENC_LITTLE_ENDIAN); + proto_tree_add_item(attrmask_tree, hf_9P_setattr_mtime_set, tvb, offset, 4, ENC_LITTLE_ENDIAN); +} + +/* Dissect 9P lflags */ +static void dissect_9P_lflags(tvbuff_t *tvb, proto_item *item, int offset) +{ + proto_item *attrmask_tree; + + attrmask_tree = proto_item_add_subtree(item, ett_9P_lflags); + if(!attrmask_tree) + return; + + proto_tree_add_item(attrmask_tree, hf_9P_lflags_rdonly, tvb, offset, 4, ENC_LITTLE_ENDIAN); + proto_tree_add_item(attrmask_tree, hf_9P_lflags_wronly, tvb, offset, 4, ENC_LITTLE_ENDIAN); + proto_tree_add_item(attrmask_tree, hf_9P_lflags_rdwr, tvb, offset, 4, ENC_LITTLE_ENDIAN); + proto_tree_add_item(attrmask_tree, hf_9P_lflags_create, tvb, offset, 4, ENC_LITTLE_ENDIAN); + proto_tree_add_item(attrmask_tree, hf_9P_lflags_excl, tvb, offset, 4, ENC_LITTLE_ENDIAN); + proto_tree_add_item(attrmask_tree, hf_9P_lflags_noctty, tvb, offset, 4, ENC_LITTLE_ENDIAN); + proto_tree_add_item(attrmask_tree, hf_9P_lflags_trunc, tvb, offset, 4, ENC_LITTLE_ENDIAN); + proto_tree_add_item(attrmask_tree, hf_9P_lflags_append, tvb, offset, 4, ENC_LITTLE_ENDIAN); + proto_tree_add_item(attrmask_tree, hf_9P_lflags_nonblock, tvb, offset, 4, ENC_LITTLE_ENDIAN); + proto_tree_add_item(attrmask_tree, hf_9P_lflags_dsync, tvb, offset, 4, ENC_LITTLE_ENDIAN); + proto_tree_add_item(attrmask_tree, hf_9P_lflags_fasync, tvb, offset, 4, ENC_LITTLE_ENDIAN); + proto_tree_add_item(attrmask_tree, hf_9P_lflags_direct, tvb, offset, 4, ENC_LITTLE_ENDIAN); + proto_tree_add_item(attrmask_tree, hf_9P_lflags_largefile, tvb, offset, 4, ENC_LITTLE_ENDIAN); + proto_tree_add_item(attrmask_tree, hf_9P_lflags_directory, tvb, offset, 4, ENC_LITTLE_ENDIAN); + proto_tree_add_item(attrmask_tree, hf_9P_lflags_nofollow, tvb, offset, 4, ENC_LITTLE_ENDIAN); + proto_tree_add_item(attrmask_tree, hf_9P_lflags_noatime, tvb, offset, 4, ENC_LITTLE_ENDIAN); + proto_tree_add_item(attrmask_tree, hf_9P_lflags_cloexec, tvb, offset, 4, ENC_LITTLE_ENDIAN); + proto_tree_add_item(attrmask_tree, hf_9P_lflags_sync, tvb, offset, 4, ENC_LITTLE_ENDIAN); } + /* Register 9P with Wireshark */ void proto_register_9P(void) { @@ -688,13 +2270,13 @@ void proto_register_9P(void) {"Mode", "9p.mode", FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL}}, {&hf_9P_mode_rwx, - {"Open/Create Mode", "9p.mode.rwx", FT_UINT8, BASE_DEC,VALS(ninep_mode_vals),P9_MODEMASK, + {"Open/Create Mode", "9p.mode.rwx", FT_UINT8, BASE_OCT | BASE_EXT_STRING, &ninep_mode_vals_ext, _9P_MODEMASK, NULL, HFILL}}, {&hf_9P_mode_t, - {"Trunc", "9p.mode.trunc", FT_BOOLEAN, 8, TFS(&tfs_set_notset), P9_OTRUNC, + {"Trunc", "9p.mode.trunc", FT_BOOLEAN, 8, TFS(&tfs_set_notset), _9P_OTRUNC, "Truncate", HFILL}}, {&hf_9P_mode_c, - {"Remove on close", "9p.mode.orclose", FT_BOOLEAN, 8, TFS(&tfs_set_notset), P9_ORCLOSE, + {"Remove on close", "9p.mode.orclose", FT_BOOLEAN, 8, TFS(&tfs_set_notset), _9P_ORCLOSE, NULL, HFILL}}, {&hf_9P_iounit, {"I/O Unit", "9p.iounit", FT_UINT32, BASE_DEC, NULL, 0x0, @@ -792,6 +2374,12 @@ void proto_register_9P(void) {&hf_9P_mtime, {"Mtime", "9p.mtime", FT_ABSOLUTE_TIME, ABSOLUTE_TIME_LOCAL, NULL, 0x0, "Modified Time", HFILL}}, + {&hf_9P_ctime, + {"Ctime", "9p.ctime", FT_ABSOLUTE_TIME, ABSOLUTE_TIME_LOCAL, NULL, 0x0, + "Creation Time", HFILL}}, + {&hf_9P_btime, + {"Btime", "9p.btime", FT_ABSOLUTE_TIME, ABSOLUTE_TIME_LOCAL, NULL, 0x0, + "Btime (Synchronization information)", HFILL}}, {&hf_9P_length, {"Length", "9p.length", FT_UINT64, BASE_DEC, NULL, 0x0, "File Length", HFILL}}, @@ -816,6 +2404,9 @@ void proto_register_9P(void) {&hf_9P_ename, {"Ename", "9p.ename", FT_STRING, BASE_NONE, NULL, 0x0, "Error", HFILL}}, + {&hf_9P_enum, + {"Enum", "9p.enum", FT_UINT32, BASE_DEC, NULL, 0x0, + "Error", HFILL}}, {&hf_9P_name, {"Name", "9p.name", FT_STRING, BASE_NONE, NULL, 0x0, "Name of file", HFILL}}, @@ -825,11 +2416,17 @@ void proto_register_9P(void) {&hf_9P_filename, {"File name", "9p.filename", FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL}}, + {&hf_9P_user, + {"User", "9p.user", FT_STRING, BASE_NONE, NULL, 0x0, + "User name", HFILL}}, + {&hf_9P_group, + {"Group", "9p.group", FT_STRING, BASE_NONE, NULL, 0x0, + "Group name", HFILL}}, {&hf_9P_uid, - {"Uid", "9p.uid", FT_STRING, BASE_NONE, NULL, 0x0, + {"Uid", "9p.uid", FT_UINT32, BASE_DEC, NULL, 0x0, "User id", HFILL}}, {&hf_9P_gid, - {"Gid", "9p.gid", FT_STRING, BASE_NONE, NULL, 0x0, + {"Gid", "9p.gid", FT_UINT32, BASE_DEC, NULL, 0x0, "Group id", HFILL}}, {&hf_9P_muid, {"Muid", "9p.muid", FT_STRING, BASE_NONE, NULL, 0x0, @@ -837,10 +2434,214 @@ void proto_register_9P(void) {&hf_9P_newfid, {"New fid", "9p.newfid", FT_UINT32, BASE_DEC, NULL, 0x0, "New file ID", HFILL}}, + {&hf_9P_dfid, + {"Directory fid", "9p.dfid", FT_UINT32, BASE_DEC, NULL, 0x0, + "Directory ID", HFILL}}, {&hf_9P_nwalk, {"Nr Walks", "9p.nwalk", FT_UINT32, BASE_DEC, NULL, 0x0, - "Nr of walk items", HFILL}} - + "Nr of walk items", HFILL}}, + {&hf_9P_nlink, + {"nlink", "9p.nlink", FT_UINT64, BASE_DEC, NULL, 0x0, + "Number of links", HFILL}}, + {&hf_9P_getattr_flags, + {"getattr_flags", "9p.getattr.flags", FT_UINT64, BASE_HEX, NULL, _9P_GETATTR_ALL, + "Getattr flags", HFILL}}, + {&hf_9P_getattr_mode, + {"Mode", "9p.getattr.mode", FT_BOOLEAN, 32, TFS(&tfs_yes_no), _9P_GETATTR_MODE, + NULL, HFILL}}, + {&hf_9P_getattr_nlink, + {"Nlink", "9p.getattr.nlink", FT_BOOLEAN, 32, TFS(&tfs_yes_no), _9P_GETATTR_NLINK, + NULL, HFILL}}, + {&hf_9P_getattr_uid, + {"UID", "9p.getattr.uid", FT_BOOLEAN, 32, TFS(&tfs_yes_no), _9P_GETATTR_UID, + NULL, HFILL}}, + {&hf_9P_getattr_gid, + {"GID", "9p.getattr.gid", FT_BOOLEAN, 32, TFS(&tfs_yes_no), _9P_GETATTR_GID, + NULL, HFILL}}, + {&hf_9P_getattr_rdev, + {"Rdev", "9p.getattr.rdev", FT_BOOLEAN, 32, TFS(&tfs_yes_no), _9P_GETATTR_RDEV, + NULL, HFILL}}, + {&hf_9P_getattr_atime, + {"Atime", "9p.getattr.atime", FT_BOOLEAN, 32, TFS(&tfs_yes_no), _9P_GETATTR_ATIME, + NULL, HFILL}}, + {&hf_9P_getattr_mtime, + {"Mtime", "9p.getattr.mtime", FT_BOOLEAN, 32, TFS(&tfs_yes_no), _9P_GETATTR_MTIME, + NULL, HFILL}}, + {&hf_9P_getattr_ctime, + {"Ctime", "9p.getattr.ctime", FT_BOOLEAN, 32, TFS(&tfs_yes_no), _9P_GETATTR_CTIME, + NULL, HFILL}}, + {&hf_9P_getattr_ino, + {"Inode", "9p.getattr.inode", FT_BOOLEAN, 32, TFS(&tfs_yes_no), _9P_GETATTR_INO, + NULL, HFILL}}, + {&hf_9P_getattr_size, + {"Size", "9p.getattr.size", FT_BOOLEAN, 32, TFS(&tfs_yes_no), _9P_GETATTR_SIZE, + NULL, HFILL}}, + {&hf_9P_getattr_blocks, + {"Blocks", "9p.getattr.blocks", FT_BOOLEAN, 32, TFS(&tfs_yes_no), _9P_GETATTR_BLOCKS, + NULL, HFILL}}, + {&hf_9P_getattr_btime, + {"Btime", "9p.getattr.btime", FT_BOOLEAN, 32, TFS(&tfs_yes_no), _9P_GETATTR_BTIME, + NULL, HFILL}}, + {&hf_9P_getattr_gen, + {"Gen", "9p.getattr.gen", FT_BOOLEAN, 32, TFS(&tfs_yes_no), _9P_GETATTR_GEN, + NULL, HFILL}}, + {&hf_9P_getattr_dataversion, + {"Data version", "9p.getattr.dataversion", FT_BOOLEAN, 32, TFS(&tfs_yes_no), _9P_GETATTR_DATA_VERSION, + NULL, HFILL}}, + {&hf_9P_setattr_flags, + {"setattr_flags", "9p.setattr.flags", FT_UINT32, BASE_HEX, NULL, _9P_SETATTR_ALL, + "Setattr flags", HFILL}}, + {&hf_9P_setattr_mode, + {"Mode", "9p.setattr.mode", FT_BOOLEAN, 32, TFS(&tfs_yes_no), _9P_SETATTR_MODE, + NULL, HFILL}}, + {&hf_9P_setattr_uid, + {"UID", "9p.setattr.uid", FT_BOOLEAN, 32, TFS(&tfs_yes_no), _9P_SETATTR_UID, + NULL, HFILL}}, + {&hf_9P_setattr_gid, + {"GID", "9p.setattr.gid", FT_BOOLEAN, 32, TFS(&tfs_yes_no), _9P_SETATTR_GID, + NULL, HFILL}}, + {&hf_9P_setattr_size, + {"Size", "9p.setattr.size", FT_BOOLEAN, 32, TFS(&tfs_yes_no), _9P_SETATTR_SIZE, + NULL, HFILL}}, + {&hf_9P_setattr_atime, + {"Atime", "9p.setattr.atime", FT_BOOLEAN, 32, TFS(&tfs_yes_no), _9P_SETATTR_ATIME, + NULL, HFILL}}, + {&hf_9P_setattr_mtime, + {"Mtime", "9p.setattr.mtime", FT_BOOLEAN, 32, TFS(&tfs_yes_no), _9P_SETATTR_MTIME, + NULL, HFILL}}, + {&hf_9P_setattr_ctime, + {"Ctime", "9p.setattr.ctime", FT_BOOLEAN, 32, TFS(&tfs_yes_no), _9P_SETATTR_CTIME, + NULL, HFILL}}, + {&hf_9P_setattr_atime_set, + {"Atime set", "9p.setattr.atimeset", FT_BOOLEAN, 32, TFS(&tfs_yes_no), _9P_SETATTR_ATIME_SET, + NULL, HFILL}}, + {&hf_9P_setattr_mtime_set, + {"Mtime set", "9p.setattr.mtimeset", FT_BOOLEAN, 32, TFS(&tfs_yes_no), _9P_SETATTR_MTIME_SET, + NULL, HFILL}}, + {&hf_9P_rdev, + {"rdev", "9p.rdev", FT_UINT64, BASE_DEC, NULL, 0x0, + "Device associated with file", HFILL}}, + {&hf_9P_size, + {"Size", "9p.size", FT_UINT64, BASE_DEC, NULL, 0x0, + NULL, HFILL}}, + {&hf_9P_blksize, + {"Blksize", "9p.blksize", FT_UINT64, BASE_DEC, NULL, 0x0, + "Block size", HFILL}}, + {&hf_9P_blocks, + {"Blocks", "9p.blocks", FT_UINT64, BASE_DEC, NULL, 0x0, + NULL, HFILL}}, + {&hf_9P_gen, + {"Gen", "9p.gen", FT_UINT64, BASE_DEC, NULL, 0x0, + "inode generation number", HFILL}}, + {&hf_9P_dataversion, + {"Dataversion", "9p.dataversion", FT_UINT64, BASE_DEC, NULL, 0x0, + "Data version", HFILL}}, + {&hf_9P_fstype, + {"fstype", "9p.fstype", FT_UINT32, BASE_HEX, NULL, 0x0, + "Filesystem type", HFILL}}, + {&hf_9P_bfree, + {"bfree", "9p.bfree", FT_UINT64, BASE_DEC, NULL, 0x0, + "Free blocks", HFILL}}, + {&hf_9P_bavail, + {"bavail", "9p.bavail", FT_UINT64, BASE_DEC, NULL, 0x0, + "Available blocks", HFILL}}, + {&hf_9P_files, + {"files", "9p.files", FT_UINT64, BASE_DEC, NULL, 0x0, + "Total files", HFILL}}, + {&hf_9P_ffree, + {"ffree", "9p.ffree", FT_UINT64, BASE_DEC, NULL, 0x0, + "Free files", HFILL}}, + {&hf_9P_fsid, + {"fsid", "9p.fsid", FT_UINT64, BASE_DEC, NULL, 0x0, + "Filesystem id", HFILL}}, + {&hf_9P_namelen, + {"namelen", "9p.namelen", FT_UINT32, BASE_DEC, NULL, 0x0, + "Max name length", HFILL}}, + {&hf_9P_mknod_major, + {"mknod_major", "9p.mknod.major", FT_UINT32, BASE_DEC, NULL, 0x0, + "Major node number", HFILL}}, + {&hf_9P_mknod_minor, + {"mknod_minor", "9p.mknod.minor", FT_UINT32, BASE_DEC, NULL, 0x0, + "Minor node number", HFILL}}, + {&hf_9P_lflags, + {"lflags", "9p.lcreate.flags", FT_UINT32, BASE_HEX, NULL, 0x0, + "Lcreate flags", HFILL}}, + /* rdonly is 0x00, check instead that we are neither wronly nor rdwrite */ + {&hf_9P_lflags_rdonly, + {"Read only", "9p.lflags.rdonly", FT_BOOLEAN, 32, TFS(&tfs_no_yes), _9P_DOTL_WRONLY|_9P_DOTL_RDWR, + NULL, HFILL}}, + {&hf_9P_lflags_wronly, + {"Write only", "9p.lflags.wronly", FT_BOOLEAN, 32, TFS(&tfs_yes_no), _9P_DOTL_WRONLY, + NULL, HFILL}}, + {&hf_9P_lflags_rdwr, + {"Read Write", "9p.lflags.rdwr", FT_BOOLEAN, 32, TFS(&tfs_yes_no), _9P_DOTL_RDWR, + NULL, HFILL}}, + {&hf_9P_lflags_create, + {"Create", "9p.lflags.create", FT_BOOLEAN, 32, TFS(&tfs_yes_no), _9P_DOTL_CREATE, + NULL, HFILL}}, + {&hf_9P_lflags_excl, + {"Exclusive", "9p.lflags.excl", FT_BOOLEAN, 32, TFS(&tfs_yes_no), _9P_DOTL_EXCL, + NULL, HFILL}}, + {&hf_9P_lflags_noctty, + {"noctty", "9p.lflags.noctty", FT_BOOLEAN, 32, TFS(&tfs_yes_no), _9P_DOTL_NOCTTY, + NULL, HFILL}}, + {&hf_9P_lflags_trunc, + {"Truncate", "9p.lflags.trunc", FT_BOOLEAN, 32, TFS(&tfs_yes_no), _9P_DOTL_TRUNC, + NULL, HFILL}}, + {&hf_9P_lflags_append, + {"Append", "9p.lflags.append", FT_BOOLEAN, 32, TFS(&tfs_yes_no), _9P_DOTL_APPEND, + NULL, HFILL}}, + {&hf_9P_lflags_nonblock, + {"Nonblock", "9p.lflags.nonblock", FT_BOOLEAN, 32, TFS(&tfs_yes_no), _9P_DOTL_NONBLOCK, + NULL, HFILL}}, + {&hf_9P_lflags_dsync, + {"dsync", "9p.lflags.dsync", FT_BOOLEAN, 32, TFS(&tfs_yes_no), _9P_DOTL_DSYNC, + NULL, HFILL}}, + {&hf_9P_lflags_fasync, + {"fasync", "9p.lflags.fasync", FT_BOOLEAN, 32, TFS(&tfs_yes_no), _9P_DOTL_FASYNC, + NULL, HFILL}}, + {&hf_9P_lflags_direct, + {"Direct", "9p.lflags.direct", FT_BOOLEAN, 32, TFS(&tfs_yes_no), _9P_DOTL_DIRECT, + NULL, HFILL}}, + {&hf_9P_lflags_largefile, + {"Large File", "9p.lflags.largefile", FT_BOOLEAN, 32, TFS(&tfs_yes_no), _9P_DOTL_LARGEFILE, + NULL, HFILL}}, + {&hf_9P_lflags_directory, + {"Directory", "9p.lflags.directory", FT_BOOLEAN, 32, TFS(&tfs_yes_no), _9P_DOTL_DIRECTORY, + NULL, HFILL}}, + {&hf_9P_lflags_nofollow, + {"No follow", "9p.lflags.nofollow", FT_BOOLEAN, 32, TFS(&tfs_yes_no), _9P_DOTL_NOFOLLOW, + NULL, HFILL}}, + {&hf_9P_lflags_noatime, + {"No atime", "9p.lflags.noatime", FT_BOOLEAN, 32, TFS(&tfs_yes_no), _9P_DOTL_NOATIME, + NULL, HFILL}}, + {&hf_9P_lflags_cloexec, + {"cloexec", "9p.lflags.cloexec", FT_BOOLEAN, 32, TFS(&tfs_yes_no), _9P_DOTL_CLOEXEC, + NULL, HFILL}}, + {&hf_9P_lflags_sync, + {"Sync", "9p.lflags.sync", FT_BOOLEAN, 32, TFS(&tfs_yes_no), _9P_DOTL_SYNC, + NULL, HFILL}}, + {&hf_9P_xattr_flag, + {"xattr_flag", "9p.xattr.flag", FT_UINT32, BASE_HEX, NULL, 0x0, + "Xattr flag", HFILL}}, + {&hf_9P_lock_type, + {"lock_type", "9p.lock.type", FT_UINT32, BASE_HEX | BASE_EXT_STRING, &ninep_lock_type_ext, 0x0, + "Lock type", HFILL}}, + {&hf_9P_lock_flag, + {"lock_flag", "9p.lock.flag", FT_UINT32, BASE_HEX | BASE_EXT_STRING, &ninep_lock_flag_ext, 0x0, + "Lock flag", HFILL}}, + {&hf_9P_lock_start, + {"lock_start", "9p.lock.start", FT_UINT64, BASE_DEC, NULL, 0x0, + "Lock start", HFILL}}, + {&hf_9P_lock_length, + {"lock_length", "9p.lock.length", FT_UINT64, BASE_DEC, NULL, 0x0, + "Lock length", HFILL}}, + {&hf_9P_lock_procid, + {"lock_procid", "9p.lock.procid", FT_UINT32, BASE_HEX, NULL, 0x0, + "Lock procid", HFILL}}, + {&hf_9P_lock_status, + {"lock_status", "9p.lock.status", FT_UINT8, BASE_HEX | BASE_EXT_STRING, &ninep_lock_status_ext, 0x0, + "Lock status", HFILL}} }; static gint *ett[] = { @@ -851,20 +2652,25 @@ void proto_register_9P(void) &ett_9P_aname, &ett_9P_ename, &ett_9P_uname, - &ett_9P_uid, - &ett_9P_gid, + &ett_9P_user, + &ett_9P_group, &ett_9P_muid, &ett_9P_filename, &ett_9P_version, &ett_9P_qid, &ett_9P_qidtype, + &ett_9P_getattr_flags, + &ett_9P_setattr_flags, + &ett_9P_lflags, }; - proto_9P = proto_register_protocol("Plan 9 9P", "9P", "9p"); + proto_9P = proto_register_protocol("Plan 9", "9P", "9p"); proto_register_field_array(proto_9P, hf, array_length(hf)); proto_register_subtree_array(ett, array_length(ett)); + + register_init_routine(_9p_hash_init); } void proto_reg_handoff_9P(void) @@ -878,4 +2684,3 @@ void proto_reg_handoff_9P(void) dissector_add_uint("tcp.port", NINEPORT, ninep_handle); } - |