diff options
author | guy <guy> | 2002-12-11 07:13:49 +0000 |
---|---|---|
committer | guy <guy> | 2002-12-11 07:13:49 +0000 |
commit | fcc82f451d3e51fdf636abbf927edb287bada0e0 (patch) | |
tree | 938119171c0d1eb45c66c2f576b95293f04f468b /nfs.h | |
parent | 3a4254f5c662637cf669ff66b941240d7e456d6d (diff) | |
download | tcpdump-fcc82f451d3e51fdf636abbf927edb287bada0e0.tar.gz |
The "__attribute__((packed))" tag on structures causes some files not to
compile with Sun C, as "interface.h" isn't being included before the
structures are being declared.
Furthermore, in the files that Sun C *can* compile, it doesn't cause Sun
C to generate code that's safe with unaligned accesses, as
"__attribute__" is defined as a do-nothing macro with compilers that
don't support it.
Therefore, we get rid of that tag on the structures to which it was
added, and instead use "EXTRACT_16BIT()" and "EXTRACT_32BIT()" to fetch
16-bit and 32-bit big-endian quantities from packets. We also fix some
other references to multi-byte quantities to get rid of code that tries
to do unaligned loads on platforms that don't support them.
We also throw in a hack that makes those macros use
"__attribute__((packed))" on structures containing only one 16-bit or
32-bit integer to get the compiler to generate unaligned-safe code
rather than doing it by hand. (GCC on SPARC produces the same code that
doing it by hand does; I don't know if GCC on any other big-endian
strict-alignment processor generates better code for that case. On
little-endian processors, as "ntohs()" and "ntohl()" might be functions,
that might actually produce worse code.)
Fix some places to use "%u" rather than "%d" to print unsigned
quantities.
Diffstat (limited to 'nfs.h')
-rw-r--r-- | nfs.h | 26 |
1 files changed, 13 insertions, 13 deletions
@@ -1,4 +1,4 @@ -/* @(#) $Header: /tcpdump/master/tcpdump/nfs.h,v 1.6 2002-12-11 05:04:12 guy Exp $ (LBL) */ +/* @(#) $Header: /tcpdump/master/tcpdump/nfs.h,v 1.7 2002-12-11 07:13:55 guy Exp $ (LBL) */ /* $NetBSD: nfs.h,v 1.1 1996/05/23 22:49:53 fvdl Exp $ */ /* @@ -262,19 +262,19 @@ typedef enum { NFNON=0, NFREG=1, NFDIR=2, NFBLK=3, NFCHR=4, NFLNK=5, union nfsfh { /* fhandle_t fh_generic; */ u_char fh_bytes[NFS_SMALLFH]; -} __attribute__((packed)); +}; typedef union nfsfh nfsfh_t; struct nfsv2_time { u_int32_t nfsv2_sec; u_int32_t nfsv2_usec; -} __attribute__((packed)); +}; typedef struct nfsv2_time nfstime2; struct nfsv3_time { u_int32_t nfsv3_sec; u_int32_t nfsv3_nsec; -} __attribute__((packed)); +}; typedef struct nfsv3_time nfstime3; /* @@ -283,7 +283,7 @@ typedef struct nfsv3_time nfstime3; */ struct nfs_uquad { u_int32_t nfsuquad[2]; -} __attribute__((packed)); +}; typedef struct nfs_uquad nfsuint64; #if 0 /* XXX - this doesn't seemed to be used and it doesn't work @@ -296,7 +296,7 @@ typedef struct nfs_uquad nfsuint64; union nfs_quadconvert { u_int32_t lval[2]; u_int64_t qval; -} __attribute__((packed)); +}; typedef union nfs_quadconvert nfsquad_t; #endif @@ -307,7 +307,7 @@ typedef union nfs_quadconvert nfsquad_t; struct nfsv3_spec { u_int32_t specdata1; u_int32_t specdata2; -} __attribute__((packed)); +}; typedef struct nfsv3_spec nfsv3spec; /* @@ -348,7 +348,7 @@ struct nfs_fattr { nfstime3 nfsv3fa_ctime; } fa_nfsv3; } fa_un; -} __attribute__((packed)); +}; /* and some ugly defines for accessing union components */ #define fa2_size fa_un.fa_nfsv2.nfsv2fa_size @@ -376,7 +376,7 @@ struct nfsv2_sattr { u_int32_t sa_size; nfstime2 sa_atime; nfstime2 sa_mtime; -} __attribute__((packed)); +}; /* * NFS Version 3 sattr structure for the new node creation case. @@ -394,7 +394,7 @@ struct nfsv3_sattr { nfstime3 sa_atime; u_int32_t sa_mtimetype; nfstime3 sa_mtime; -} __attribute__((packed)); +}; struct nfs_statfs { union { @@ -415,7 +415,7 @@ struct nfs_statfs { u_int32_t nfsv3sf_invarsec; } sf_nfsv3; } sf_un; -} __attribute__((packed)); +}; #define sf_tsize sf_un.sf_nfsv2.nfsv2sf_tsize #define sf_bsize sf_un.sf_nfsv2.nfsv2sf_bsize @@ -441,7 +441,7 @@ struct nfsv3_fsinfo { nfsuint64 fs_maxfilesize; nfstime3 fs_timedelta; u_int32_t fs_properties; -} __attribute__((packed)); +}; struct nfsv3_pathconf { u_int32_t pc_linkmax; @@ -450,4 +450,4 @@ struct nfsv3_pathconf { u_int32_t pc_chownrestricted; u_int32_t pc_caseinsensitive; u_int32_t pc_casepreserving; -} __attribute__((packed)); +}; |