]> The Tcpdump Group git mirrors - tcpdump/blobdiff - print-sunrpc.c
Handle very large -f files by rejecting them.
[tcpdump] / print-sunrpc.c
index e7b1d8ae91a13b7b57e56af192e92cf111e459c2..d2366c783b26c8a27acc95ceb84a9858888e1c92 100644 (file)
@@ -19,7 +19,8 @@
  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  */
 
-#define NETDISSECT_REWORKED
+/* \summary: Sun Remote Procedure Call printer */
+
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
@@ -39,7 +40,7 @@
  */
 #undef _XOPEN_SOURCE_EXTENDED
 
-#include <tcpdump-stdinc.h>
+#include <netdissect-stdinc.h>
 
 #if defined(HAVE_GETRPCBYNUMBER) && defined(HAVE_RPC_RPC_H)
 #include <rpc/rpc.h>
 #include <stdio.h>
 #include <string.h>
 
-#include "interface.h"
+#include "netdissect.h"
 #include "addrtoname.h"
 #include "extract.h"
 
 #include "ip.h"
-#ifdef INET6
 #include "ip6.h"
-#endif
 
 #include "rpc_auth.h"
 #include "rpc_msg.h"
  * The service supports remote procedure calls on udp/ip or tcp/ip socket 111.
  */
 
-#define SUNRPC_PMAPPORT                ((u_int16_t)111)
-#define SUNRPC_PMAPPROG                ((u_int32_t)100000)
-#define SUNRPC_PMAPVERS                ((u_int32_t)2)
-#define SUNRPC_PMAPVERS_PROTO  ((u_int32_t)2)
-#define SUNRPC_PMAPVERS_ORIG   ((u_int32_t)1)
-#define SUNRPC_PMAPPROC_NULL   ((u_int32_t)0)
-#define SUNRPC_PMAPPROC_SET    ((u_int32_t)1)
-#define SUNRPC_PMAPPROC_UNSET  ((u_int32_t)2)
-#define SUNRPC_PMAPPROC_GETPORT        ((u_int32_t)3)
-#define SUNRPC_PMAPPROC_DUMP   ((u_int32_t)4)
-#define SUNRPC_PMAPPROC_CALLIT ((u_int32_t)5)
+#define SUNRPC_PMAPPORT                ((uint16_t)111)
+#define SUNRPC_PMAPPROG                ((uint32_t)100000)
+#define SUNRPC_PMAPVERS                ((uint32_t)2)
+#define SUNRPC_PMAPVERS_PROTO  ((uint32_t)2)
+#define SUNRPC_PMAPVERS_ORIG   ((uint32_t)1)
+#define SUNRPC_PMAPPROC_NULL   ((uint32_t)0)
+#define SUNRPC_PMAPPROC_SET    ((uint32_t)1)
+#define SUNRPC_PMAPPROC_UNSET  ((uint32_t)2)
+#define SUNRPC_PMAPPROC_GETPORT        ((uint32_t)3)
+#define SUNRPC_PMAPPROC_DUMP   ((uint32_t)4)
+#define SUNRPC_PMAPPROC_CALLIT ((uint32_t)5)
 
 struct sunrpc_pmap {
-       u_int32_t pm_prog;
-       u_int32_t pm_vers;
-       u_int32_t pm_prot;
-       u_int32_t pm_port;
+       uint32_t pm_prog;
+       uint32_t pm_vers;
+       uint32_t pm_prot;
+       uint32_t pm_port;
 };
 
 static const struct tok proc2str[] = {
@@ -163,7 +162,7 @@ static const struct tok proc2str[] = {
 };
 
 /* Forwards */
-static char *progstr(u_int32_t);
+static char *progstr(uint32_t);
 
 void
 sunrpcrequest_print(netdissect_options *ndo, register const u_char *bp,
@@ -171,13 +170,11 @@ sunrpcrequest_print(netdissect_options *ndo, register const u_char *bp,
 {
        register const struct sunrpc_msg *rp;
        register const struct ip *ip;
-#ifdef INET6
        register const struct ip6_hdr *ip6;
-#endif
-       u_int32_t x;
+       uint32_t x;
        char srcid[20], dstid[20];      /*fits 32bit*/
 
-       rp = (struct sunrpc_msg *)bp;
+       rp = (const struct sunrpc_msg *)bp;
 
        if (!ndo->ndo_nflag) {
                snprintf(srcid, sizeof(srcid), "0x%x",
@@ -189,21 +186,19 @@ sunrpcrequest_print(netdissect_options *ndo, register const u_char *bp,
                snprintf(dstid, sizeof(dstid), "0x%x", SUNRPC_PMAPPORT);
        }
 
-       switch (IP_V((struct ip *)bp2)) {
+       switch (IP_V((const struct ip *)bp2)) {
        case 4:
-               ip = (struct ip *)bp2;
+               ip = (const struct ip *)bp2;
                ND_PRINT((ndo, "%s.%s > %s.%s: %d",
                    ipaddr_string(ndo, &ip->ip_src), srcid,
                    ipaddr_string(ndo, &ip->ip_dst), dstid, length));
                break;
-#ifdef INET6
        case 6:
-               ip6 = (struct ip6_hdr *)bp2;
+               ip6 = (const struct ip6_hdr *)bp2;
                ND_PRINT((ndo, "%s.%s > %s.%s: %d",
                    ip6addr_string(ndo, &ip6->ip6_src), srcid,
                    ip6addr_string(ndo, &ip6->ip6_dst), dstid, length));
                break;
-#endif
        default:
                ND_PRINT((ndo, "%s.%s > %s.%s: %d", "?", srcid, "?", dstid, length));
                break;
@@ -232,13 +227,13 @@ sunrpcrequest_print(netdissect_options *ndo, register const u_char *bp,
 }
 
 static char *
-progstr(u_int32_t prog)
+progstr(uint32_t prog)
 {
 #if defined(HAVE_GETRPCBYNUMBER) && defined(HAVE_RPC_RPC_H)
        register struct rpcent *rp;
 #endif
        static char buf[32];
-       static u_int32_t lastprog = 0;
+       static uint32_t lastprog = 0;
 
        if (lastprog != 0 && prog == lastprog)
                return (buf);