]> The Tcpdump Group git mirrors - tcpdump/blobdiff - print-sunrpc.c
gre: add support for MikroTik Ethernet-over-IP hack.
[tcpdump] / print-sunrpc.c
index 94b867075b543d6ef7ca4a37a4270efbae6f2536..7eeb42dcc243963ca1c839f1eec16fd61bc7ba5a 100644 (file)
@@ -52,6 +52,7 @@
 #include <stdio.h>
 #include <string.h>
 
+#define ND_LONGJMP_FROM_TCHECK
 #include "netdissect.h"
 #include "addrtoname.h"
 #include "extract.h"
  * The following procedures are supported by the protocol:
  *
  * PMAPPROC_NULL() returns ()
- *     takes nothing, returns nothing
+ *     takes nothing, returns nothing
  *
  * PMAPPROC_SET(struct pmap) returns (bool_t)
- *     TRUE is success, FALSE is failure.  Registers the tuple
+ *     TRUE is success, FALSE is failure.  Registers the tuple
  *     [prog, vers, prot, port].
  *
  * PMAPPROC_UNSET(struct pmap) returns (bool_t)
  * PMAPPROC_DUMP() RETURNS (struct pmaplist *)
  *
  * PMAPPROC_CALLIT(unsigned, unsigned, unsigned, string<>)
- *     RETURNS (port, string<>);
+ *     RETURNS (port, string<>);
  * usage: encapsulatedresults = PMAPPROC_CALLIT(prog, vers, proc, encapsulatedargs);
- *     Calls the procedure on the local machine.  If it is not registered,
+ *     Calls the procedure on the local machine.  If it is not registered,
  *     this procedure is quite; ie it does not return error information!!!
  *     This procedure only is supported on rpc/udp and calls via
  *     rpc/udp.  This routine only passes null authentication parameters.
  */
 
 #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)
@@ -185,14 +182,14 @@ sunrpc_print(netdissect_options *ndo, const u_char *bp,
        case 4:
                ip = (const struct ip *)bp2;
                ND_PRINT("%s.%s > %s.%s: %u",
-                   ipaddr_string(ndo, ip->ip_src), srcid,
-                   ipaddr_string(ndo, ip->ip_dst), dstid, length);
+                   GET_IPADDR_STRING(ip->ip_src), srcid,
+                   GET_IPADDR_STRING(ip->ip_dst), dstid, length);
                break;
        case 6:
                ip6 = (const struct ip6_hdr *)bp2;
                ND_PRINT("%s.%s > %s.%s: %u",
-                   ip6addr_string(ndo, ip6->ip6_src), srcid,
-                   ip6addr_string(ndo, ip6->ip6_dst), dstid, length);
+                   GET_IP6ADDR_STRING(ip6->ip6_src), srcid,
+                   GET_IP6ADDR_STRING(ip6->ip6_dst), dstid, length);
                break;
        default:
                ND_PRINT("%s.%s > %s.%s: %u", "?", srcid, "?", dstid, length);
@@ -202,7 +199,7 @@ sunrpc_print(netdissect_options *ndo, const u_char *bp,
        ND_PRINT(" %s", tok2str(proc2str, " proc #%u",
            GET_BE_U_4(rp->rm_call.cb_proc)));
        x = GET_BE_U_4(rp->rm_call.cb_rpcvers);
-       if (x != 2)
+       if (x != SUNRPC_MSG_VERSION)
                ND_PRINT(" [rpcver %u]", x);
 
        switch (GET_BE_U_4(rp->rm_call.cb_proc)) {
@@ -219,10 +216,6 @@ sunrpc_print(netdissect_options *ndo, const u_char *bp,
                ND_PRINT(".%u", GET_BE_U_4(rp->rm_call.cb_vers));
                break;
        }
-       return;
-
-trunc:
-       nd_print_trunc(ndo);
 }
 
 static char *
@@ -238,12 +231,11 @@ progstr(uint32_t prog)
                return (buf);
 #if defined(HAVE_GETRPCBYNUMBER) && defined(HAVE_RPC_RPC_H)
        rp = getrpcbynumber(prog);
-       if (rp == NULL)
-#endif
-               (void) snprintf(buf, sizeof(buf), "#%u", prog);
-#if defined(HAVE_GETRPCBYNUMBER) && defined(HAVE_RPC_RPC_H)
-       else
+       if (rp != NULL)
                strlcpy(buf, rp->r_name, sizeof(buf));
+       else
 #endif
+               (void) snprintf(buf, sizeof(buf), "#%u", prog);
+       lastprog = prog;
        return (buf);
 }