Explicitly print gratuitous arp requests as such
[metze/wireshark/wip.git] / packet-portmap.c
index 125f43a1b9454237c91170b1ae154820ab2fd1ad..ce5aa72deeba95dc8876108400928d6bebe3097c 100644 (file)
@@ -1,10 +1,10 @@
 /* packet-portmap.c
  * Routines for portmap dissection
  *
- * $Id: packet-portmap.c,v 1.19 2000/08/14 11:36:04 girlich Exp $
+ * $Id: packet-portmap.c,v 1.42 2004/01/09 00:56:04 guy Exp $
  *
  * Ethereal - Network traffic analyzer
- * By Gerald Combs <gerald@zing.org>
+ * By Gerald Combs <gerald@ethereal.com>
  * Copyright 1998 Gerald Combs
  *
  * Copied from packet-smb.c
 #endif
 
 
-#ifdef HAVE_SYS_TYPES_H
-#include <sys/types.h>
-#endif
-
 
 #include "packet-rpc.h"
 #include "packet-portmap.h"
+#include "ipproto.h"
+#include "epan/conversation.h"
+#include "epan/packet_info.h"
 
+/*
+ * See:
+ *
+ *     RFC 1833, "Binding Protocols for ONC RPC Version 2".
+ */
 
 static int proto_portmap = -1;
+static int hf_portmap_procedure_v1 = -1;
+static int hf_portmap_procedure_v2 = -1;
+static int hf_portmap_procedure_v3 = -1;
+static int hf_portmap_procedure_v4 = -1;
 static int hf_portmap_proto = -1;
 static int hf_portmap_prog = -1;
 static int hf_portmap_proc = -1;
 static int hf_portmap_version = -1;
 static int hf_portmap_port = -1;
 static int hf_portmap_answer = -1;
+static int hf_portmap_args = -1;
+static int hf_portmap_result = -1;
 static int hf_portmap_rpcb = -1;
 static int hf_portmap_rpcb_prog = -1;
 static int hf_portmap_rpcb_version = -1;
@@ -58,177 +68,270 @@ static gint ett_portmap = -1;
 static gint ett_portmap_rpcb = -1;
 static gint ett_portmap_entry = -1;
 
+static dissector_handle_t rpc_handle;
+static dissector_handle_t rpc_tcp_handle;
 
 /* Dissect a getport call */
-int dissect_getport_call(const u_char *pd, int offset, frame_data *fd,
+static int
+dissect_getport_call(tvbuff_t *tvb, int offset, packet_info *pinfo _U_,
        proto_tree *tree)
 {
        guint32 proto;
        guint32 prog;
-       if ( !BYTES_ARE_IN_FRAME(offset, 16)) return offset;
+
+       /* make sure we remember protocol type until the reply packet */
+       if(!pinfo->fd->flags.visited){
+               rpc_call_info_value *rpc_call=pinfo->private_data;
+               if(rpc_call){
+                       proto = tvb_get_ntohl(tvb, offset+8);
+                       if(proto==IP_PROTO_UDP){  /* only do this for UDP */
+                               rpc_call->private_data=(void *)PT_UDP;
+                       }
+               }
+       }
 
        if ( tree )
        {
-               prog = pntohl(&pd[offset+0]);
-               proto_tree_add_uint_format(tree, hf_portmap_prog, NullTVB,
+               prog = tvb_get_ntohl(tvb, offset+0);
+               proto_tree_add_uint_format(tree, hf_portmap_prog, tvb,
                        offset, 4, prog, "Program: %s (%u)",
                        rpc_prog_name(prog), prog);
-               proto_tree_add_uint(tree, hf_portmap_version, NullTVB,
-                       offset+4, 4, pntohl(&pd[offset+4]));
+               proto_tree_add_item(tree, hf_portmap_version, tvb,
+                       offset+4, 4, FALSE);
 
-               proto = pntohl(&pd[offset+8]);
-               proto_tree_add_uint_format(tree, hf_portmap_proto, NullTVB,
+               proto = tvb_get_ntohl(tvb, offset+8);
+               proto_tree_add_uint_format(tree, hf_portmap_proto, tvb,
                        offset+8, 4, proto, "Proto: %s (%u)", ipprotostr(proto), proto);
 
-               proto_tree_add_uint(tree, hf_portmap_port, NullTVB,
-                       offset+12, 4, pntohl(&pd[offset+12]));
+               proto_tree_add_item(tree, hf_portmap_port, tvb,
+                       offset+12, 4, FALSE);
        }
-       
+
        return offset+16;
 }
 
-int dissect_getport_reply(const u_char *pd, int offset, frame_data *fd,
+static int
+dissect_getport_reply(tvbuff_t *tvb, int offset, packet_info *pinfo _U_,
        proto_tree *tree)
 {
-       if ( !BYTES_ARE_IN_FRAME(offset, 4)) return offset;
-       if ( tree )
-       {
-               proto_tree_add_uint(tree, hf_portmap_port, NullTVB,
-                       offset, 4, pntohl(&pd[offset+0]));
+       /* we might have learnt a <ipaddr><protocol><port> mapping for ONC-RPC*/
+       if(!pinfo->fd->flags.visited){
+               rpc_call_info_value *rpc_call=pinfo->private_data;
+               /* only do this for UDP, TCP does not need anything like this */
+               if(rpc_call && ((int)rpc_call->private_data==PT_UDP) ){
+                       guint32 port;
+                       port=tvb_get_ntohl(tvb, offset);
+                       if(port){
+                               conversation_t *conv;
+                               conv=find_conversation(&pinfo->src, &pinfo->dst, (port_type)rpc_call->private_data, port, 0, NO_ADDR_B|NO_PORT_B);
+                               if(!conv){
+                                       conv=conversation_new(&pinfo->src, &pinfo->dst, (port_type)rpc_call->private_data, port, 0, NO_ADDR2|NO_PORT2);
+                               }
+                               conversation_set_dissector(conv, rpc_handle);
+                       }
+               }
        }
-    return offset+=4;
+
+       offset = dissect_rpc_uint32(tvb, tree, hf_portmap_port,
+           offset);
+       return offset;
 }
 
 /* Dissect a 'set' call */
-int dissect_set_call(const u_char *pd, int offset, frame_data *fd,
+static int
+dissect_set_call(tvbuff_t *tvb, int offset, packet_info *pinfo _U_,
        proto_tree *tree)
 {
        guint32 proto;
        guint32 prog;
-       if ( !BYTES_ARE_IN_FRAME(offset, 16)) return offset;
 
        if ( tree )
        {
-               prog = pntohl(&pd[offset+0]);
-               proto_tree_add_uint_format(tree, hf_portmap_prog, NullTVB,
+               prog = tvb_get_ntohl(tvb, offset+0);
+               proto_tree_add_uint_format(tree, hf_portmap_prog, tvb,
                        offset, 4, prog, "Program: %s (%d)",
                        rpc_prog_name(prog), prog);
-               proto_tree_add_uint(tree, hf_portmap_version, NullTVB,
-                       offset+4, 4, pntohl(&pd[offset+4]));
+               proto_tree_add_item(tree, hf_portmap_version, tvb,
+                       offset+4, 4, FALSE);
 
-               proto = pntohl(&pd[offset+8]);
-               proto_tree_add_uint_format(tree, hf_portmap_proto, NullTVB,
+               proto = tvb_get_ntohl(tvb, offset+8);
+               proto_tree_add_uint_format(tree, hf_portmap_proto,tvb,
                        offset+8, 4, proto, "Proto: %s (%d)", ipprotostr(proto), proto);
 
-               proto_tree_add_uint(tree, hf_portmap_port, NullTVB,
-                       offset+12, 4, pntohl(&pd[offset+12]));
+               proto_tree_add_item(tree, hf_portmap_port, tvb,
+                       offset+12, 4, FALSE);
        }
-       
+
        return offset+16;
 }
 
 /* Dissect a 'unset' call */
-int dissect_unset_call(const u_char *pd, int offset, frame_data *fd,
+static int
+dissect_unset_call(tvbuff_t *tvb, int offset, packet_info *pinfo _U_,
        proto_tree *tree)
 {
        guint32 proto;
        guint32 prog;
-       if ( !BYTES_ARE_IN_FRAME(offset, 16)) return offset;
 
        if ( tree )
        {
-               prog = pntohl(&pd[offset+0]);
-               proto_tree_add_uint_format(tree, hf_portmap_prog, NullTVB,
+               prog = tvb_get_ntohl(tvb, offset+0);
+               proto_tree_add_uint_format(tree, hf_portmap_prog, tvb,
                        offset, 4, prog, "Program: %s (%d)",
                        rpc_prog_name(prog), prog);
-               proto_tree_add_uint(tree, hf_portmap_version, NullTVB,
-                       offset+4, 4, pntohl(&pd[offset+4]));
+               proto_tree_add_item(tree, hf_portmap_version, tvb,
+                       offset+4, 4, FALSE);
 
-               proto = pntohl(&pd[offset+8]);
-               proto_tree_add_uint(tree, hf_portmap_proto, NullTVB,
+               proto = tvb_get_ntohl(tvb, offset+8);
+               proto_tree_add_uint(tree, hf_portmap_proto, tvb,
                        offset+8, 4, proto);
 
-               proto_tree_add_uint(tree, hf_portmap_port, NullTVB,
-                       offset+12, 4, pntohl(&pd[offset+12]));
+               proto_tree_add_item(tree, hf_portmap_port, tvb,
+                       offset+12, 4, FALSE);
        }
-       
+
        return offset+16;
 }
 
-int dissect_set_reply(const u_char *pd, int offset, frame_data *fd,
+static int
+dissect_set_reply(tvbuff_t *tvb, int offset, packet_info *pinfo _U_,
        proto_tree *tree)
 {
-       if ( tree )
-       {
-               if ( !BYTES_ARE_IN_FRAME(offset, 4)) return offset;
-
-               proto_tree_add_boolean(tree, hf_portmap_answer, NullTVB,
-                       offset, 4, pntohl(&pd[offset+0]));
-               offset += 4;
-       }
-    return offset;
+       offset = dissect_rpc_bool(tvb, tree, hf_portmap_answer,
+           offset);
+       return offset;
 }
 
 static int
-dissect_dump_entry(const u_char* pd, int offset, frame_data* fd, proto_tree* tree)
+dissect_dump_entry(tvbuff_t *tvb, int offset, packet_info *pinfo _U_,
+       proto_tree *tree)
 {
        int prog, version, proto, port;
        proto_item *ti, *subtree;
 
-       if ( ! BYTES_ARE_IN_FRAME(offset, 16) )
-       {
-               if ( tree )
-               {
-                       proto_tree_add_text(tree, NullTVB, offset, END_OF_FRAME, "Map Entry: <TRUNCATED>");
-               }
-               return pi.captured_len;
-       }
-       prog = pntohl(&pd[offset+0]);
-       version = pntohl(&pd[offset+4]);
-       proto = pntohl(&pd[offset+8]);
-       port = pntohl(&pd[offset+12]);
+       prog = tvb_get_ntohl(tvb, offset+0);
+       version = tvb_get_ntohl(tvb, offset+4);
+       proto = tvb_get_ntohl(tvb, offset+8);
+       port = tvb_get_ntohl(tvb, offset+12);
        if ( tree )
        {
-               ti = proto_tree_add_text(tree, NullTVB, offset, 16, "Map Entry: %s (%u) V%d",
+               ti = proto_tree_add_text(tree, tvb, offset, 16,
+                       "Map Entry: %s (%u) V%d",
                        rpc_prog_name(prog), prog, version);
                subtree = proto_item_add_subtree(ti, ett_portmap_entry);
 
-               proto_tree_add_uint_format(subtree, hf_portmap_prog, NullTVB,
+               proto_tree_add_uint_format(subtree, hf_portmap_prog, tvb,
                        offset+0, 4, prog,
                        "Program: %s (%u)", rpc_prog_name(prog), prog);
-               proto_tree_add_uint(subtree, hf_portmap_version, NullTVB,
+               proto_tree_add_uint(subtree, hf_portmap_version, tvb,
                        offset+4, 4, version);
-               proto_tree_add_uint_format(subtree, hf_portmap_proto, NullTVB,
-                       offset+8, 4, proto, 
+               proto_tree_add_uint_format(subtree, hf_portmap_proto, tvb,
+                       offset+8, 4, proto,
                        "Protocol: %s (0x%02x)", ipprotostr(proto), proto);
-               proto_tree_add_uint(subtree, hf_portmap_port, NullTVB,
+               proto_tree_add_uint(subtree, hf_portmap_port, tvb,
                        offset+12, 4, port);
        }
        offset += 16;
        return offset;
 }
 
-int dissect_dump_reply(const u_char *pd, int offset, frame_data *fd,
+static int
+dissect_dump_reply(tvbuff_t *tvb, int offset, packet_info *pinfo,
        proto_tree *tree)
 {
-       offset = dissect_rpc_list(pd, offset, fd, tree, dissect_dump_entry);
+       offset = dissect_rpc_list(tvb, pinfo, tree, offset,
+               dissect_dump_entry);
+       return offset;
+}
+
+/* Dissect a callit call */
+static int
+dissect_callit_call(tvbuff_t *tvb, int offset, packet_info *pinfo,
+       proto_tree *tree)
+{
+       guint32 prog, vers, proc;
+
+       prog = tvb_get_ntohl(tvb, offset+0);
+       if ( tree )
+       {
+               proto_tree_add_uint_format(tree, hf_portmap_prog, tvb,
+                       offset, 4, prog, "Program: %s (%u)",
+                       rpc_prog_name(prog), prog);
+       }
+
+       vers = tvb_get_ntohl(tvb, offset+4);
+       if ( tree )
+       {
+               proto_tree_add_uint(tree, hf_portmap_version, tvb,
+                       offset+4, 4, vers);
+       }
+
+       proc = tvb_get_ntohl(tvb, offset+8);
+       if ( tree )
+       {
+               proto_tree_add_uint_format(tree, hf_portmap_proc, tvb,
+                       offset+8, 4, proc, "Procedure: %s (%u)",
+                       rpc_proc_name(prog, vers, proc), proc);
+       }
+
+       offset += 12;
+
+       /* Dissect the arguments for this procedure.
+          Make the columns non-writable, so the dissector won't change
+          them out from under us. */
+       col_set_writable(pinfo->cinfo, FALSE);
+       offset = dissect_rpc_indir_call(tvb, pinfo, tree, offset,
+               hf_portmap_args, prog, vers, proc);
+
+       return offset;
+}
+
+/* Dissect a callit reply */
+static int
+dissect_callit_reply(tvbuff_t *tvb, int offset, packet_info *pinfo,
+       proto_tree *tree)
+{
+       if ( tree )
+       {
+               proto_tree_add_item(tree, hf_portmap_port, tvb,
+                       offset, 4, FALSE);
+       }
+       offset += 4;
+
+       /* Dissect the result of this procedure.
+          Make the columns non-writable, so the dissector won't change
+          them out from under us. */
+       col_set_writable(pinfo->cinfo, FALSE);
+       offset = dissect_rpc_indir_reply(tvb, pinfo, tree, offset,
+               hf_portmap_result, hf_portmap_prog, hf_portmap_version,
+               hf_portmap_proc);
+
        return offset;
 }
 
 /* proc number, "proc name", dissect_request, dissect_reply */
-/* NULL as function pointer means: take the generic one. */
-const vsff portmap1_proc[] = {
-       { PORTMAPPROC_NULL,     "NULL",         NULL,                           NULL },
-       { PORTMAPPROC_SET,      "SET",          NULL,                           NULL },
-       { PORTMAPPROC_UNSET,    "UNSET",                NULL,                           NULL },
-       { PORTMAPPROC_GETPORT,  "GETPORT",              NULL,                           NULL },
-       { PORTMAPPROC_DUMP,     "DUMP",         NULL,                           NULL },
-       { PORTMAPPROC_CALLIT,   "CALLIT",               NULL,                           NULL },
-       { 0,    NULL,           NULL,                           NULL }
+/* NULL as function pointer means: type of arguments is "void". */
+static const vsff portmap1_proc[] = {
+       { PORTMAPPROC_NULL,     "NULL",         NULL,   NULL },
+       { PORTMAPPROC_SET,      "SET",          NULL,   NULL },
+       { PORTMAPPROC_UNSET,    "UNSET",        NULL,   NULL },
+       { PORTMAPPROC_GETPORT,  "GETPORT",      NULL,   NULL },
+       { PORTMAPPROC_DUMP,     "DUMP",         NULL,   NULL },
+       { PORTMAPPROC_CALLIT,   "CALLIT",       NULL,   NULL },
+       { 0,                    NULL,           NULL,   NULL }
+};
+static const value_string portmap1_proc_vals[] = {
+       { PORTMAPPROC_NULL,     "NULL" },
+       { PORTMAPPROC_SET,      "SET" },
+       { PORTMAPPROC_UNSET,    "UNSET" },
+       { PORTMAPPROC_GETPORT,  "GETPORT" },
+       { PORTMAPPROC_DUMP,     "DUMP" },
+       { PORTMAPPROC_CALLIT,   "CALLIT" },
+       { 0,                    NULL }
 };
 /* end of Portmap version 1 */
 
-const vsff portmap2_proc[] = {
+static const vsff portmap2_proc[] = {
        { PORTMAPPROC_NULL, "NULL",
                NULL, NULL },
        { PORTMAPPROC_SET, "SET",
@@ -240,47 +343,52 @@ const vsff portmap2_proc[] = {
        { PORTMAPPROC_DUMP, "DUMP",
                NULL, dissect_dump_reply },
        { PORTMAPPROC_CALLIT, "CALLIT",
-               NULL, NULL },
-    { 0, NULL, NULL, NULL }
+               dissect_callit_call, dissect_callit_reply },
+       { 0, NULL, NULL, NULL }
+};
+static const value_string portmap2_proc_vals[] = {
+       { PORTMAPPROC_NULL, "NULL" },
+       { PORTMAPPROC_SET, "SET" },
+       { PORTMAPPROC_UNSET, "UNSET" },
+       { PORTMAPPROC_GETPORT,  "GETPORT" },
+       { PORTMAPPROC_DUMP, "DUMP" },
+       { PORTMAPPROC_CALLIT, "CALLIT" },
+       { 0, NULL }
 };
 /* end of Portmap version 2 */
 
 
 /* RFC 1833, Page 3 */
 static int
-dissect_rpcb(const u_char *pd, int offset, frame_data *fd, proto_tree *tree)
+dissect_rpcb(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree)
 {
        proto_item* rpcb_item = NULL;
        proto_tree* rpcb_tree = NULL;
        int old_offset = offset;
        guint32 prog;
-       guint32 version;
 
        if (tree) {
-               rpcb_item = proto_tree_add_item(tree, hf_portmap_rpcb, NullTVB,
-                       offset+0, END_OF_FRAME, FALSE);
+               rpcb_item = proto_tree_add_item(tree, hf_portmap_rpcb, tvb,
+                       offset, -1, FALSE);
                if (rpcb_item)
                        rpcb_tree = proto_item_add_subtree(rpcb_item, ett_portmap_rpcb);
        }
 
-       if (!BYTES_ARE_IN_FRAME(offset, 4)) return offset;
-       prog = EXTRACT_UINT(pd, offset + 0);
+       prog = tvb_get_ntohl(tvb, offset);
        if (rpcb_tree)
-               proto_tree_add_uint_format(rpcb_tree, hf_portmap_rpcb_prog, NullTVB,
-                       offset+0, 4, prog, 
+               proto_tree_add_uint_format(rpcb_tree, hf_portmap_rpcb_prog, tvb,
+                       offset, 4, prog,
                        "Program: %s (%u)", rpc_prog_name(prog), prog);
        offset += 4;
 
-       if (!BYTES_ARE_IN_FRAME(offset, 4)) return offset;
-       version = EXTRACT_UINT(pd, offset + 0);
-       if (rpcb_tree)
-               proto_tree_add_uint(rpcb_tree, hf_portmap_rpcb_version, NullTVB,
-                       offset+0, 4, version);
-       offset += 4;
-
-       offset = dissect_rpc_string(pd, offset, fd, rpcb_tree, hf_portmap_rpcb_netid,NULL);
-       offset = dissect_rpc_string(pd, offset, fd, rpcb_tree, hf_portmap_rpcb_addr,NULL);
-       offset = dissect_rpc_string(pd, offset, fd, rpcb_tree, hf_portmap_rpcb_owner,NULL);
+       offset = dissect_rpc_uint32(tvb, rpcb_tree,
+           hf_portmap_rpcb_version, offset);
+       offset = dissect_rpc_string(tvb, rpcb_tree,
+           hf_portmap_rpcb_netid, offset, NULL);
+       offset = dissect_rpc_string(tvb, rpcb_tree,
+           hf_portmap_rpcb_addr, offset, NULL);
+       offset = dissect_rpc_string(tvb, rpcb_tree,
+           hf_portmap_rpcb_owner, offset, NULL);
 
        /* now we know, that rpcb is shorter */
        if (rpcb_item) {
@@ -293,36 +401,60 @@ dissect_rpcb(const u_char *pd, int offset, frame_data *fd, proto_tree *tree)
 
 
 /* RFC 1833, Page 7 */
-int dissect_rpcb3_getaddr_call(const u_char *pd, int offset, frame_data *fd,
+static int
+dissect_rpcb3_getaddr_call(tvbuff_t *tvb, int offset, packet_info *pinfo,
        proto_tree *tree)
 {
-       offset = dissect_rpcb(pd, offset, fd, tree);
+       offset = dissect_rpcb(tvb, offset, pinfo, tree);
 
        return offset;
 }
 
 
 /* RFC 1833, Page 7 */
-int dissect_rpcb3_getaddr_reply(const u_char *pd, int offset, frame_data *fd,
+static int
+dissect_rpcb3_getaddr_reply(tvbuff_t *tvb, int offset, packet_info *pinfo _U_,
        proto_tree *tree)
 {
-       offset = dissect_rpc_string(pd, offset, fd, tree, hf_portmap_uaddr,NULL);
+       offset = dissect_rpc_string(tvb, tree,
+           hf_portmap_uaddr, offset, NULL);
 
        return offset;
 }
 
 
 /* RFC 1833, Page 7 */
-int dissect_rpcb3_dump_reply(const u_char *pd, int offset, frame_data *fd,
+static int
+dissect_rpcb3_dump_reply(tvbuff_t *tvb, int offset, packet_info *pinfo,
        proto_tree *tree)
 {
-       offset = dissect_rpc_list(pd, offset, fd, tree, dissect_rpcb);
+       offset = dissect_rpc_list(tvb, pinfo, tree, offset, dissect_rpcb);
+       return offset;
+}
+
+/* RFC 1833, page 4 */
+static int
+dissect_rpcb_rmtcallres(tvbuff_t *tvb, int offset, packet_info *pinfo _U_,
+       proto_tree *tree)
+{
+       /* Dissect the remote universal address. */
+       offset = dissect_rpc_string(tvb, tree,
+           hf_portmap_rpcb_addr, offset, NULL);
+
+       /* Dissect the result of this procedure.
+          Make the columns non-writable, so the dissector won't change
+          them out from under us. */
+       col_set_writable(pinfo->cinfo, FALSE);
+       offset = dissect_rpc_indir_reply(tvb, pinfo, tree, offset,
+               hf_portmap_result, hf_portmap_prog, hf_portmap_version,
+               hf_portmap_proc);
+
        return offset;
 }
 
 
 /* Portmapper version 3, RFC 1833, Page 7 */
-const vsff portmap3_proc[] = {
+static const vsff portmap3_proc[] = {
        { RPCBPROC_NULL,        "NULL",
                NULL, NULL },
        { RPCBPROC_SET,         "SET",
@@ -334,7 +466,7 @@ const vsff portmap3_proc[] = {
        { RPCBPROC_DUMP,        "DUMP",
                NULL, dissect_rpcb3_dump_reply },
        { RPCBPROC_CALLIT,      "CALLIT",
-               NULL, NULL },
+               dissect_callit_call, dissect_rpcb_rmtcallres },
        { RPCBPROC_GETTIME,     "GETTIME",
                NULL, NULL },
        { RPCBPROC_UADDR2TADDR, "UADDR2TADDR",
@@ -343,11 +475,23 @@ const vsff portmap3_proc[] = {
                NULL, NULL },
        { 0, NULL, NULL, NULL }
 };
+static const value_string portmap3_proc_vals[] = {
+       { RPCBPROC_NULL,        "NULL" },
+       { RPCBPROC_SET,         "SET" },
+       { RPCBPROC_UNSET,       "UNSET" },
+       { RPCBPROC_GETADDR,     "GETADDR" },
+       { RPCBPROC_DUMP,        "DUMP" },
+       { RPCBPROC_CALLIT,      "CALLIT" },
+       { RPCBPROC_GETTIME,     "GETTIME" },
+       { RPCBPROC_UADDR2TADDR, "UADDR2TADDR" },
+       { RPCBPROC_TADDR2UADDR, "TADDR2UADDR" },
+       { 0, NULL }
+};
 /* end of Portmap version 3 */
 
 
 /* Portmapper version 4, RFC 1833, Page 8 */
-const vsff portmap4_proc[] = {
+static const vsff portmap4_proc[] = {
        { RPCBPROC_NULL,        "NULL",
                NULL, NULL },
        { RPCBPROC_SET,         "SET",
@@ -359,7 +503,7 @@ const vsff portmap4_proc[] = {
        { RPCBPROC_DUMP,        "DUMP",
                NULL, dissect_rpcb3_dump_reply },
        { RPCBPROC_BCAST,       "BCAST",
-               NULL, NULL },
+               dissect_callit_call, dissect_rpcb_rmtcallres },
        { RPCBPROC_GETTIME,     "GETTIME",
                NULL, NULL },
        { RPCBPROC_UADDR2TADDR, "UADDR2TADDR",
@@ -369,58 +513,92 @@ const vsff portmap4_proc[] = {
        { RPCBPROC_GETVERSADDR, "GETVERSADDR",
                NULL, NULL },
        { RPCBPROC_INDIRECT,    "INDIRECT",
-               NULL, NULL },
+               dissect_callit_call, dissect_rpcb_rmtcallres },
        { RPCBPROC_GETADDRLIST, "GETADDRLIST",
                NULL, NULL },
        { RPCBPROC_GETSTAT,     "GETSTAT",
                NULL, NULL },
        { 0, NULL, NULL, NULL }
 };
+static const value_string portmap4_proc_vals[] = {
+       { RPCBPROC_NULL,        "NULL" },
+       { RPCBPROC_SET,         "SET" },
+       { RPCBPROC_UNSET,       "UNSET" },
+       { RPCBPROC_GETADDR,     "GETADDR" },
+       { RPCBPROC_DUMP,        "DUMP" },
+       { RPCBPROC_BCAST,       "BCAST" },
+       { RPCBPROC_GETTIME,     "GETTIME" },
+       { RPCBPROC_UADDR2TADDR, "UADDR2TADDR" },
+       { RPCBPROC_TADDR2UADDR, "TADDR2UADDR" },
+       { RPCBPROC_GETVERSADDR, "GETVERSADDR" },
+       { RPCBPROC_INDIRECT,    "INDIRECT" },
+       { RPCBPROC_GETADDRLIST, "GETADDRLIST" },
+       { RPCBPROC_GETSTAT,     "GETSTAT" },
+       { 0, NULL }
+};
 /* end of Portmap version 4 */
 
 void
 proto_register_portmap(void)
 {
        static hf_register_info hf[] = {
+               { &hf_portmap_procedure_v1, {
+                       "V1 Procedure", "portmap.procedure_v1", FT_UINT32, BASE_DEC,
+                       VALS(portmap1_proc_vals), 0, "V1 Procedure", HFILL }},
+               { &hf_portmap_procedure_v2, {
+                       "V2 Procedure", "portmap.procedure_v2", FT_UINT32, BASE_DEC,
+                       VALS(portmap2_proc_vals), 0, "V2 Procedure", HFILL }},
+               { &hf_portmap_procedure_v3, {
+                       "V3 Procedure", "portmap.procedure_v3", FT_UINT32, BASE_DEC,
+                       VALS(portmap3_proc_vals), 0, "V3 Procedure", HFILL }},
+               { &hf_portmap_procedure_v4, {
+                       "V4 Procedure", "portmap.procedure_v4", FT_UINT32, BASE_DEC,
+                       VALS(portmap4_proc_vals), 0, "V4 Procedure", HFILL }},
                { &hf_portmap_prog, {
                        "Program", "portmap.prog", FT_UINT32, BASE_DEC,
-                       NULL, 0, "Program" }},
+                       NULL, 0, "Program", HFILL }},
                { &hf_portmap_port, {
                        "Port", "portmap.port", FT_UINT32, BASE_DEC,
-                       NULL, 0, "Port" }},
+                       NULL, 0, "Port", HFILL }},
                { &hf_portmap_proc, {
                        "Procedure", "portmap.proc", FT_UINT32, BASE_DEC,
-                       NULL, 0, "Procedure" }},
+                       NULL, 0, "Procedure", HFILL }},
                { &hf_portmap_proto, {
                        "Protocol", "portmap.proto", FT_UINT32, BASE_DEC,
-                       NULL, 0, "Protocol" }},
+                       NULL, 0, "Protocol", HFILL }},
                { &hf_portmap_version, {
                        "Version", "portmap.version", FT_UINT32, BASE_DEC,
-                       NULL, 0, "Version" }},
+                       NULL, 0, "Version", HFILL }},
                { &hf_portmap_answer, {
                        "Answer", "portmap.answer", FT_BOOLEAN, BASE_DEC,
-                       NULL, 0, "Answer" }},
+                       NULL, 0, "Answer", HFILL }},
+               { &hf_portmap_args, {
+                       "Arguments", "portmap.args", FT_BYTES, BASE_HEX,
+                       NULL, 0, "Arguments", HFILL }},
+               { &hf_portmap_result, {
+                       "Result", "portmap.result", FT_BYTES, BASE_HEX,
+                       NULL, 0, "Result", HFILL }},
                { &hf_portmap_rpcb, {
                        "RPCB", "portmap.rpcb", FT_NONE, 0,
-                       NULL, 0, "RPCB" }},
+                       NULL, 0, "RPCB", HFILL }},
                { &hf_portmap_rpcb_prog, {
                        "Program", "portmap.rpcb.prog", FT_UINT32, BASE_DEC,
-                       NULL, 0, "Program" }},
+                       NULL, 0, "Program", HFILL }},
                { &hf_portmap_rpcb_version, {
                        "Version", "portmap.rpcb.version", FT_UINT32, BASE_DEC,
-                       NULL, 0, "Version" }},
+                       NULL, 0, "Version", HFILL }},
                { &hf_portmap_rpcb_netid, {
                        "Network Id", "portmap.rpcb.netid", FT_STRING, BASE_DEC,
-                       NULL, 0, "Network Id" }},
-               { &hf_portmap_rpcb_addr, {
+                       NULL, 0, "Network Id", HFILL }},
+               { &hf_portmap_rpcb_addr, {      /* address in rpcb structure in request */
                        "Universal Address", "portmap.rpcb.addr", FT_STRING, BASE_DEC,
-                       NULL, 0, "Universal Address" }},
+                       NULL, 0, "Universal Address", HFILL }},
                { &hf_portmap_rpcb_owner, {
                        "Owner of this Service", "portmap.rpcb.owner", FT_STRING, BASE_DEC,
-                       NULL, 0, "Owner of this Service" }},
-               { &hf_portmap_uaddr, {
+                       NULL, 0, "Owner of this Service", HFILL }},
+               { &hf_portmap_uaddr, {  /* address in RPCBPROC_GETADDR reply */
                        "Universal Address", "portmap.uaddr", FT_STRING, BASE_DEC,
-                       NULL, 0, "Universal Address" }},
+                       NULL, 0, "Universal Address", HFILL }},
        };
        static gint *ett[] = {
                &ett_portmap,
@@ -428,7 +606,7 @@ proto_register_portmap(void)
                &ett_portmap_entry
        };
 
-       proto_portmap = proto_register_protocol("Portmap", "portmap");
+       proto_portmap = proto_register_protocol("Portmap", "Portmap", "portmap");
        proto_register_field_array(proto_portmap, hf, array_length(hf));
        proto_register_subtree_array(ett, array_length(ett));
 }
@@ -439,8 +617,10 @@ proto_reg_handoff_portmap(void)
        /* Register the protocol as RPC */
        rpc_init_prog(proto_portmap, PORTMAP_PROGRAM, ett_portmap);
        /* Register the procedure tables */
-       rpc_init_proc_table(PORTMAP_PROGRAM, 1, portmap1_proc);
-       rpc_init_proc_table(PORTMAP_PROGRAM, 2, portmap2_proc);
-       rpc_init_proc_table(PORTMAP_PROGRAM, 3, portmap3_proc);
-       rpc_init_proc_table(PORTMAP_PROGRAM, 4, portmap4_proc);
+       rpc_init_proc_table(PORTMAP_PROGRAM, 1, portmap1_proc, hf_portmap_procedure_v1);
+       rpc_init_proc_table(PORTMAP_PROGRAM, 2, portmap2_proc, hf_portmap_procedure_v2);
+       rpc_init_proc_table(PORTMAP_PROGRAM, 3, portmap3_proc, hf_portmap_procedure_v3);
+       rpc_init_proc_table(PORTMAP_PROGRAM, 4, portmap4_proc, hf_portmap_procedure_v4);
+       rpc_handle = find_dissector("rpc");
+       rpc_tcp_handle = find_dissector("rpc-tcp");
 }