summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenis Ovsienko <infrastation@yandex.ru>2013-10-12 13:36:02 +0400
committerDenis Ovsienko <infrastation@yandex.ru>2013-10-12 13:43:45 +0400
commit16cfec8b37de56c8f24d0a87e2149e645da3785e (patch)
tree9382f8c23108c4890b5032fca7f77139258b92af
parente237de2104bb6e4f7957768cbc056e85a26818ce (diff)
downloadtcpdump-16cfec8b37de56c8f24d0a87e2149e645da3785e.tar.gz
NFS: replace ino_t with u_int32_t (GH #335 pt. 1)
NFS file handle is an opaque server-issued sequence of bytes. Parse_fh() function implements heuristics to decode file handles generated by some NFS servers, among other information extracting the node (inode) number. It decodes only 32-bit node numbers. NFS implementations use ino_t C type to represent the node number. The type size may vary across implementations/encodings and may be missing during compile time. Tcpdump used to have its own typedef for ino_t. Gisle Vanem points that it caused a problem with MSVC v.16.00.40219.01 for 80x86, which defines the same type in <sys/types.h>. This change fixes tcpdump code to use u_int32_t and removes the typedef.
-rw-r--r--nfsfh.h2
-rw-r--r--parsenfsfh.c29
-rw-r--r--print-nfs.c2
-rw-r--r--tcpdump-stdinc.h2
4 files changed, 12 insertions, 23 deletions
diff --git a/nfsfh.h b/nfsfh.h
index 0bca424a..1d96f13e 100644
--- a/nfsfh.h
+++ b/nfsfh.h
@@ -65,4 +65,4 @@ typedef struct {
#define fsid_eq(a,b) ((a.fsid_code == b.fsid_code) &&\
dev_eq(a.Fsid_dev, b.Fsid_dev))
-extern void Parse_fh(const unsigned char *, int, my_fsid *, ino_t *, const char **, const char **, int);
+extern void Parse_fh(const unsigned char *, int, my_fsid *, u_int32_t *, const char **, const char **, int);
diff --git a/parsenfsfh.c b/parsenfsfh.c
index d5f877d8..5ee7e68e 100644
--- a/parsenfsfh.c
+++ b/parsenfsfh.c
@@ -114,7 +114,7 @@ Parse_fh(fh, len, fsidp, inop, osnamep, fsnamep, ourself)
register const unsigned char *fh;
int len _U_;
my_fsid *fsidp;
-ino_t *inop;
+u_int32_t *inop;
const char **osnamep; /* if non-NULL, return OS name here */
const char **fsnamep; /* if non-NULL, return server fs name here (for VMS) */
int ourself; /* true if file handle was generated on this host */
@@ -264,8 +264,7 @@ int ourself; /* true if file handle was generated on this host */
fsidp->Fsid_dev.Major = fhp[6];
fsidp->fsid_code = 0;
- temp = make_uint32(fhp[12], fhp[13], fhp[14], fhp[15]);
- *inop = temp;
+ *inop = make_uint32(fhp[12], fhp[13], fhp[14], fhp[15]);
if (osnamep)
*osnamep = "Auspex";
@@ -276,8 +275,7 @@ int ourself; /* true if file handle was generated on this host */
fsidp->Fsid_dev.Major = fhp[1];
fsidp->fsid_code = 0;
- temp = make_uint32(fhp[15], fhp[14], fhp[13], fhp[12]);
- *inop = temp;
+ *inop = make_uint32(fhp[15], fhp[14], fhp[13], fhp[12]);
if (osnamep)
*osnamep = "BSD 4.4";
@@ -291,8 +289,7 @@ int ourself; /* true if file handle was generated on this host */
fsidp->Fsid_dev.Minor = temp & 0xFFFFF;
fsidp->Fsid_dev.Major = (temp>>20) & 0xFFF;
- temp = make_uint32(fhp[15], fhp[14], fhp[13], fhp[12]);
- *inop = temp;
+ *inop = make_uint32(fhp[15], fhp[14], fhp[13], fhp[12]);
if (osnamep)
*osnamep = "OSF";
break;
@@ -302,8 +299,7 @@ int ourself; /* true if file handle was generated on this host */
fsidp->Fsid_dev.Major = fhp[2];
fsidp->fsid_code = 0;
- temp = make_uint32(fhp[8], fhp[9], fhp[10], fhp[11]);
- *inop = temp;
+ *inop = make_uint32(fhp[8], fhp[9], fhp[10], fhp[11]);
if (osnamep)
*osnamep = "IRIX4";
@@ -314,8 +310,7 @@ int ourself; /* true if file handle was generated on this host */
fsidp->Fsid_dev.Major = make_uint16(fhp[0], fhp[1]);
fsidp->fsid_code = make_uint32(fhp[4], fhp[5], fhp[6], fhp[7]);
- temp = make_uint32(fhp[12], fhp[13], fhp[14], fhp[15]);
- *inop = temp;
+ *inop = make_uint32(fhp[12], fhp[13], fhp[14], fhp[15]);
if (osnamep)
*osnamep = "IRIX5";
@@ -337,8 +332,7 @@ int ourself; /* true if file handle was generated on this host */
fsidp->Fsid_dev.Major = fhp[2];
fsidp->fsid_code = make_uint32(fhp[4], fhp[5], fhp[6], fhp[7]);
- temp = make_uint32(fhp[12], fhp[13], fhp[14], fhp[15]);
- *inop = temp;
+ *inop = make_uint32(fhp[12], fhp[13], fhp[14], fhp[15]);
if (osnamep)
*osnamep = "SUNOS4";
@@ -351,8 +345,7 @@ int ourself; /* true if file handle was generated on this host */
fsidp->Fsid_dev.Minor = temp & 0x3FFFF;
fsidp->fsid_code = make_uint32(fhp[4], fhp[5], fhp[6], fhp[7]);
- temp = make_uint32(fhp[12], fhp[13], fhp[14], fhp[15]);
- *inop = temp;
+ *inop = make_uint32(fhp[12], fhp[13], fhp[14], fhp[15]);
if (osnamep)
*osnamep = "SUNOS5";
@@ -403,8 +396,7 @@ int ourself; /* true if file handle was generated on this host */
fsidp->Fsid_dev.Major = make_uint16(fhp[0], fhp[1]);
fsidp->fsid_code = make_uint32(fhp[4], fhp[5], fhp[6], fhp[7]);
- temp = make_uint32(fhp[12], fhp[13], fhp[14], fhp[15]);
- *inop = temp;
+ *inop = make_uint32(fhp[12], fhp[13], fhp[14], fhp[15]);
if (osnamep)
*osnamep = "AIX32";
@@ -416,8 +408,7 @@ int ourself; /* true if file handle was generated on this host */
fsidp->Fsid_dev.Minor = temp;
fsidp->fsid_code = make_uint32(fhp[4], fhp[5], fhp[6], fhp[7]);
- temp = make_uint32(fhp[12], fhp[13], fhp[14], fhp[15]);
- *inop = temp;
+ *inop = make_uint32(fhp[12], fhp[13], fhp[14], fhp[15]);
if (osnamep)
*osnamep = "HPUX9";
diff --git a/print-nfs.c b/print-nfs.c
index d5816cee..9f04e0bc 100644
--- a/print-nfs.c
+++ b/print-nfs.c
@@ -853,7 +853,7 @@ static void
nfs_printfh(register const u_int32_t *dp, const u_int len)
{
my_fsid fsid;
- ino_t ino;
+ u_int32_t ino;
const char *sfsname = NULL;
char *spacep;
diff --git a/tcpdump-stdinc.h b/tcpdump-stdinc.h
index 1e5fc3a9..a5634fb0 100644
--- a/tcpdump-stdinc.h
+++ b/tcpdump-stdinc.h
@@ -69,8 +69,6 @@
#define read _read
#define close _close
#define O_RDONLY _O_RDONLY
-
-typedef short ino_t;
#endif /* __MINGW32__ */
#ifdef __MINGW32__