aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLonginus00 <Longinus00@gmail.com>2013-10-17 16:56:18 -0700
committerDenis Ovsienko <infrastation@yandex.ru>2013-11-07 11:05:32 +0400
commitf3051bcbba8cf3e5e0f0fdae1bbbd9a2cfce3b6e (patch)
tree80d029532ecb3662377db02bee1f36309ee2fffb
parent68fe98a0fbe192222cfbf7f57f0e1bf34a17baaa (diff)
downloadpublic-f3051bcbba8cf3e5e0f0fdae1bbbd9a2cfce3b6e.tar.gz
print-tcp: move nfs specific dispacting to after the tcp header decoding
-rw-r--r--print-tcp.c66
1 files changed, 30 insertions, 36 deletions
diff --git a/print-tcp.c b/print-tcp.c
index 713778a..010dcf5 100644
--- a/print-tcp.c
+++ b/print-tcp.c
@@ -187,42 +187,6 @@ tcp_print(register const u_char *bp, register u_int length,
hlen = TH_OFF(tp) * 4;
- /*
- * If data present, header length valid, and NFS port used,
- * assume NFS.
- * Pass offset of data plus 4 bytes for RPC TCP msg length
- * to NFS print routines.
- */
- if (!qflag && hlen >= sizeof(*tp) && hlen <= length &&
- (length - hlen) >= 4) {
- u_char *fraglenp;
- u_int32_t fraglen;
- register struct sunrpc_msg *rp;
- enum sunrpc_msg_type direction;
-
- fraglenp = (u_char *)tp + hlen;
- if (TTEST2(*fraglenp, 4)) {
- fraglen = EXTRACT_32BITS(fraglenp) & 0x7FFFFFFF;
- if (fraglen > (length - hlen) - 4)
- fraglen = (length - hlen) - 4;
- rp = (struct sunrpc_msg *)(fraglenp + 4);
- if (TTEST(rp->rm_direction)) {
- direction = (enum sunrpc_msg_type)EXTRACT_32BITS(&rp->rm_direction);
- if (dport == NFS_PORT &&
- direction == SUNRPC_CALL) {
- nfsreq_print((u_char *)rp, fraglen,
- (u_char *)ip);
- return;
- }
- if (sport == NFS_PORT &&
- direction == SUNRPC_REPLY) {
- nfsreply_print((u_char *)rp, fraglen,
- (u_char *)ip);
- return;
- }
- }
- }
- }
#ifdef INET6
if (ip6) {
if (ip6->ip6_nxt == IPPROTO_TCP) {
@@ -739,6 +703,36 @@ tcp_print(register const u_char *bp, register u_int length,
else if (length > 0 && (sport == LDP_PORT || dport == LDP_PORT)) {
ldp_print(bp, length);
}
+ else if ((sport == NFS_PORT || dport == NFS_PORT) &&
+ length >= 4 && TTEST2(*bp, 4)) {
+ /*
+ * If data present, header length valid, and NFS port used,
+ * assume NFS.
+ * Pass offset of data plus 4 bytes for RPC TCP msg length
+ * to NFS print routines.
+ */
+ u_int32_t fraglen;
+ register struct sunrpc_msg *rp;
+ enum sunrpc_msg_type direction;
+
+ fraglen = EXTRACT_32BITS(bp) & 0x7FFFFFFF;
+ if (fraglen > (length) - 4)
+ fraglen = (length) - 4;
+ rp = (struct sunrpc_msg *)(bp + 4);
+ if (TTEST(rp->rm_direction)) {
+ direction = (enum sunrpc_msg_type)EXTRACT_32BITS(&rp->rm_direction);
+ if (dport == NFS_PORT && direction == SUNRPC_CALL) {
+ (void)printf(" | ");
+ nfsreq_print_noaddr((u_char *)rp, fraglen, (u_char *)ip);
+ return;
+ }
+ if (sport == NFS_PORT && direction == SUNRPC_REPLY) {
+ (void)printf(" | ");
+ nfsreply_print_noaddr((u_char *)rp, fraglen, (u_char *)ip);
+ return;
+ }
+ }
+ }
return;
bad: