/* packet-afs-macros.h * Helper macros for AFS packet dissection * Copyright 1999, Nathan Neulinger * Based on routines from tcpdump patches by * Ken Hornstein * Portions based on information retrieved from the RX definitions * in Arla, the free AFS client at http://www.stacken.kth.se/project/arla/ * Portions based on information/specs retrieved from the OpenAFS sources at * www.openafs.org, Copyright IBM. * * $Id: packet-afs-macros.h,v 1.16 2002/02/03 20:48:07 guy Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs * Copyright 1998 Gerald Combs * * Copied from packet-tftp.c * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ /* * Macros for helper dissection routines * * The macros are here to save on coding. They assume that * the current offset is in 'offset', and that the offset * should be incremented after performing the macro's operation. */ /* Output a unsigned integer, stored into field 'field' Assumes it is in network byte order, converts to host before using */ #define OUT_UINT(field) \ proto_tree_add_uint(tree, field, tvb, offset, sizeof(guint32), tvb_get_ntohl(tvb, offset)); \ offset += 4; /* Output a unsigned integer, stored into field 'field' Assumes it is in network byte order, converts to host before using */ #define OUT_INT(field) \ proto_tree_add_int(tree, field, tvb, offset, sizeof(gint32), tvb_get_ntohl(tvb, offset)); \ offset += 4; /* Output a unsigned integer, stored into field 'field' Assumes it is in network byte order, converts to host before using, Note - does not increment offset, so can be used repeatedly for bitfields */ #define DISP_UINT(field) \ proto_tree_add_uint(tree,field,tvb,offset,sizeof(guint32),tvb_get_ntohl(tvb, offset)); /* Output an IPv4 address, stored into field 'field' */ #define OUT_IP(field) \ proto_tree_add_ipv4(tree,field,tvb,offset,sizeof(gint32),\ tvb_get_letohl(tvb, offset));\ offset += 4; /* Output a UNIX seconds/microseconds timestamp, after converting to an nstime_t */ #define OUT_TIMESTAMP(field) \ { nstime_t ts; \ ts.secs = tvb_get_ntohl(tvb, offset); \ ts.nsecs = tvb_get_ntohl(tvb, offset)*1000; \ proto_tree_add_time(tree,field, tvb,offset,2*sizeof(guint32),&ts); \ offset += 8; \ } /* Output a UNIX seconds-only timestamp, after converting to an nstime_t */ #define OUT_DATE(field) \ { nstime_t ts; \ ts.secs = tvb_get_ntohl(tvb, offset); \ ts.nsecs = 0; \ proto_tree_add_time(tree,field, tvb,offset,sizeof(guint32),&ts); \ offset += 4; \ } /* Output a callback */ #define OUT_FS_AFSCallBack() \ { proto_tree *save, *ti; \ ti = proto_tree_add_text(tree, tvb, offset, 3*4, "Callback"); \ save = tree; \ tree = proto_item_add_subtree(ti, ett_afs_callback); \ OUT_UINT(hf_afs_fs_callback_version); \ OUT_DATE(hf_afs_fs_callback_expires); \ OUT_UINT(hf_afs_fs_callback_type); \ tree = save; \ } /* Output a callback */ #define OUT_CB_AFSCallBack() \ { proto_tree *save, *ti; \ ti = proto_tree_add_text(tree, tvb, offset, 3*4, "Callback"); \ save = tree; \ tree = proto_item_add_subtree(ti, ett_afs_callback); \ OUT_UINT(hf_afs_cb_callback_version); \ OUT_DATE(hf_afs_cb_callback_expires); \ OUT_UINT(hf_afs_cb_callback_type); \ tree = save; \ } /* Output a File ID */ #define OUT_FS_AFSFid(label) \ { proto_tree *save, *ti; \ ti = proto_tree_add_text(tree, tvb, offset, 3*4, \ "FileID (%s)", label); \ save = tree; \ tree = proto_item_add_subtree(ti, ett_afs_fid); \ OUT_UINT(hf_afs_fs_fid_volume); \ OUT_UINT(hf_afs_fs_fid_vnode); \ OUT_UINT(hf_afs_fs_fid_uniqifier); \ tree = save; \ } /* Output a Status mask */ #define OUT_FS_STATUSMASK() \ { proto_tree *save, *ti; \ guint32 mask; \ mask = tvb_get_ntohl(tvb, offset); \ ti = proto_tree_add_uint(tree, hf_afs_fs_status_mask, tvb, offset, \ sizeof(guint32), mask); \ save = tree; \ tree = proto_item_add_subtree(ti, ett_afs_status_mask); \ proto_tree_add_uint(tree, hf_afs_fs_status_mask_setmodtime, \ tvb,offset,sizeof(guint32), mask); \ proto_tree_add_uint(tree, hf_afs_fs_status_mask_setowner, \ tvb,offset,sizeof(guint32), mask); \ proto_tree_add_uint(tree, hf_afs_fs_status_mask_setgroup, \ tvb,offset,sizeof(guint32), mask); \ proto_tree_add_uint(tree, hf_afs_fs_status_mask_setmode, \ tvb,offset,sizeof(guint32), mask); \ proto_tree_add_uint(tree, hf_afs_fs_status_mask_setsegsize, \ tvb,offset,sizeof(guint32), mask); \ proto_tree_add_uint(tree, hf_afs_fs_status_mask_fsync, \ tvb,offset,sizeof(guint32), mask); \ offset += 4; \ tree = save; \ } /* Output vldb flags */ #define OUT_VLDB_Flags() \ { proto_tree *save, *ti; \ guint32 flags; \ flags = tvb_get_ntohl(tvb, offset); \ ti = proto_tree_add_uint(tree, hf_afs_vldb_flags, tvb, offset, \ sizeof(guint32), flags); \ save = tree; \ tree = proto_item_add_subtree(ti, ett_afs_vldb_flags); \ proto_tree_add_uint(tree, hf_afs_vldb_flags_rwexists, \ tvb,offset,sizeof(guint32), flags); \ proto_tree_add_uint(tree, hf_afs_vldb_flags_roexists, \ tvb,offset,sizeof(guint32), flags); \ proto_tree_add_uint(tree, hf_afs_vldb_flags_bkexists, \ tvb,offset,sizeof(guint32), flags); \ proto_tree_add_uint(tree, hf_afs_vldb_flags_dfsfileset, \ tvb,offset,sizeof(guint32), flags); \ offset += 4; \ tree = save; \ } /* Output a File ID */ #define OUT_CB_AFSFid(label) \ { proto_tree *save, *ti; \ ti = proto_tree_add_text(tree, tvb, offset, 3*4, \ "FileID (%s)", label); \ save = tree; \ tree = proto_item_add_subtree(ti, ett_afs_fid); \ OUT_UINT(hf_afs_cb_fid_volume); \ OUT_UINT(hf_afs_cb_fid_vnode); \ OUT_UINT(hf_afs_cb_fid_uniqifier); \ tree = save; \ } /* Output a StoreStatus */ #define OUT_FS_AFSStoreStatus(label) \ { proto_tree *save, *ti; \ ti = proto_tree_add_text(tree, tvb, offset, 6*4, \ label); \ save = tree; \ tree = proto_item_add_subtree(ti, ett_afs_status); \ OUT_FS_STATUSMASK(); \ OUT_DATE(hf_afs_fs_status_clientmodtime); \ OUT_UINT(hf_afs_fs_status_owner); \ OUT_UINT(hf_afs_fs_status_group); \ OUT_UINT(hf_afs_fs_status_mode); \ OUT_UINT(hf_afs_fs_status_segsize); \ tree = save; \ } /* Output a FetchStatus */ #define OUT_FS_AFSFetchStatus(label) \ { proto_tree *save, *ti; \ ti = proto_tree_add_text(tree, tvb, offset, 21*4, \ label); \ save = tree; \ tree = proto_item_add_subtree(ti, ett_afs_status); \ OUT_UINT(hf_afs_fs_status_interfaceversion); \ OUT_UINT(hf_afs_fs_status_filetype); \ OUT_UINT(hf_afs_fs_status_linkcount); \ OUT_UINT(hf_afs_fs_status_length); \ OUT_UINT(hf_afs_fs_status_dataversion); \ OUT_UINT(hf_afs_fs_status_author); \ OUT_UINT(hf_afs_fs_status_owner); \ OUT_UINT(hf_afs_fs_status_calleraccess); \ OUT_UINT(hf_afs_fs_status_anonymousaccess); \ OUT_UINT(hf_afs_fs_status_mode); \ OUT_UINT(hf_afs_fs_status_parentvnode); \ OUT_UINT(hf_afs_fs_status_parentunique); \ OUT_UINT(hf_afs_fs_status_segsize); \ OUT_DATE(hf_afs_fs_status_clientmodtime); \ OUT_DATE(hf_afs_fs_status_servermodtime); \ OUT_UINT(hf_afs_fs_status_group); \ OUT_UINT(hf_afs_fs_status_synccounter); \ OUT_UINT(hf_afs_fs_status_dataversionhigh); \ OUT_UINT(hf_afs_fs_status_spare2); \ OUT_UINT(hf_afs_fs_status_spare3); \ OUT_UINT(hf_afs_fs_status_spare4); \ tree = save; \ } /* Output a VolSync */ #define OUT_FS_AFSVolSync() \ { proto_tree *save, *ti; \ ti = proto_tree_add_text(tree, tvb, offset, 6*4, \ "VolSync"); \ save = tree; \ tree = proto_item_add_subtree(ti, ett_afs_volsync); \ OUT_DATE(hf_afs_fs_volsync_spare1); \ OUT_UINT(hf_afs_fs_volsync_spare2); \ OUT_UINT(hf_afs_fs_volsync_spare3); \ OUT_UINT(hf_afs_fs_volsync_spare4); \ OUT_UINT(hf_afs_fs_volsync_spare5); \ OUT_UINT(hf_afs_fs_volsync_spare6); \ tree = save; \ } /* Output a AFSCBFids */ #define OUT_FS_AFSCBFids() \ { \ guint32 j,i; \ j = tvb_get_ntohl(tvb, offset); \ offset += 4; \ for (i=0; i