As per Bernd Becker's suggestion, add "register_giop_user_module()" and
[obnox/wireshark/wip.git] / packet-ypbind.c
index 813bdab019959c2115ce07babf52edf7ceecd94b..320eaf6d95d7550a33b926a25b207aac3129da8a 100644 (file)
@@ -1,10 +1,10 @@
 /* packet-ypbind.c
  * Routines for ypbind dissection
  *
- * $Id: packet-ypbind.c,v 1.8 2001/12/29 22:23:07 guy Exp $
+ * $Id: packet-ypbind.c,v 1.15 2002/11/01 00:48:39 sahlberg 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-ypbind.h"
 
 static int proto_ypbind = -1;
+static int hf_ypbind_procedure_v1 = -1;
+static int hf_ypbind_procedure_v2 = -1;
 static int hf_ypbind_domain = -1;
 static int hf_ypbind_resp_type = -1;
 static int hf_ypbind_error = -1;
@@ -51,10 +49,10 @@ static gint ett_ypbind = -1;
 
 
 static int
-dissect_ypbind_domain_v2_request(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree)
+dissect_ypbind_domain_v2_request(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree)
 {
        /* domain */
-       offset = dissect_rpc_string(tvb, pinfo, tree, 
+       offset = dissect_rpc_string(tvb, tree,
                        hf_ypbind_domain, offset, NULL);
 
        return offset;
@@ -79,33 +77,29 @@ static const value_string error_vals[] = {
 };
 
 static int
-dissect_ypbind_domain_v2_reply(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree)
+dissect_ypbind_domain_v2_reply(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree)
 {
        guint32 type;
-       guint32 tid;
 
        /* response type */
        type=tvb_get_ntohl(tvb, offset);
-       offset = dissect_rpc_uint32(tvb, pinfo, tree, hf_ypbind_resp_type, offset);
+       offset = dissect_rpc_uint32(tvb, tree, hf_ypbind_resp_type, offset);
 
        switch(type){
        case YPBIND_RESP_TYPE_SUCC_VAL:
                /* ip address */
-               tid=tvb_get_ntohl(tvb,offset);
-               tid=((tid&0x000000ff)<<24)|((tid&0x0000ff00)<<8)
-                       |((tid&0x00ff0000)>>8)|((tid&0xff000000)>>24);
-               proto_tree_add_ipv4(tree, hf_ypbind_addr, 
-                       tvb, offset, 4, tid);
+               proto_tree_add_item(tree, hf_ypbind_addr,
+                       tvb, offset, 4, FALSE);
                offset += 4;
 
                /* port */
-               offset = dissect_rpc_uint32(tvb, pinfo, tree, 
+               offset = dissect_rpc_uint32(tvb, tree,
                                hf_ypbind_port, offset);
-               
+
                break;
        case YPBIND_RESP_TYPE_FAIL_VAL:
                /* error */
-               offset = dissect_rpc_uint32(tvb, pinfo, tree, 
+               offset = dissect_rpc_uint32(tvb, tree,
                                hf_ypbind_resp_type, offset);
                break;
        }
@@ -114,30 +108,25 @@ dissect_ypbind_domain_v2_reply(tvbuff_t *tvb, int offset, packet_info *pinfo, pr
 }
 
 static int
-dissect_ypbind_setdomain_v2_request(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree)
+dissect_ypbind_setdomain_v2_request(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree)
 {
-       guint32 tid;
-
        /* domain */
-       offset = dissect_rpc_string(tvb, pinfo, tree, 
+       offset = dissect_rpc_string(tvb, tree,
                        hf_ypbind_domain, offset, NULL);
 
        /* ip address */
-       tid=tvb_get_ntohl(tvb,offset);
-       tid=((tid&0x000000ff)<<24)|((tid&0x0000ff00)<<8)
-               |((tid&0x00ff0000)>>8)|((tid&0xff000000)>>24);
-       proto_tree_add_ipv4(tree, hf_ypbind_addr, 
-               tvb, offset, 4, tid);
+       proto_tree_add_item(tree, hf_ypbind_addr,
+               tvb, offset, 4, FALSE);
        offset += 4;
 
        /* port */
-       offset = dissect_rpc_uint32(tvb, pinfo, tree, 
+       offset = dissect_rpc_uint32(tvb, tree,
                        hf_ypbind_port, offset);
-               
+
        /* version */
-       offset = dissect_rpc_uint32(tvb, pinfo, tree, 
+       offset = dissect_rpc_uint32(tvb, tree,
                        hf_ypbind_setdom_version, offset);
-               
+
        return offset;
 }
 
@@ -151,16 +140,28 @@ static const vsff ypbind1_proc[] = {
        { YPBINDPROC_SETDOM,    "SETDOMAIN",            NULL,                           NULL },
        { 0,    NULL,           NULL,                           NULL }
 };
+static const value_string ypbind1_proc_vals[] = {
+       { YPBINDPROC_NULL,      "NULL" },
+       { YPBINDPROC_DOMAIN,    "DOMAIN" },
+       { YPBINDPROC_SETDOM,    "SETDOMAIN" },
+       { 0,    NULL }
+};
 /* end of YPBind version 1 */
 
 static const vsff ypbind2_proc[] = {
        { YPBINDPROC_NULL,      "NULL",         NULL,                           NULL },
-       { YPBINDPROC_DOMAIN,    "DOMAIN",       
+       { YPBINDPROC_DOMAIN,    "DOMAIN",
                dissect_ypbind_domain_v2_request, dissect_ypbind_domain_v2_reply},
-       { YPBINDPROC_SETDOM,    "SETDOMAN",
+       { YPBINDPROC_SETDOM,    "SETDOMAIN",
                dissect_ypbind_setdomain_v2_request, NULL},
        { 0,    NULL,       NULL,               NULL }
 };
+static const value_string ypbind2_proc_vals[] = {
+       { YPBINDPROC_NULL,      "NULL" },
+       { YPBINDPROC_DOMAIN,    "DOMAIN" },
+       { YPBINDPROC_SETDOM,    "SETDOMAIN" },
+       { 0,    NULL }
+};
 /* end of YPBind version 2 */
 
 
@@ -168,6 +169,12 @@ void
 proto_register_ypbind(void)
 {
        static hf_register_info hf[] = {
+               { &hf_ypbind_procedure_v1, {
+                       "V1 Procedure", "ypbind.procedure_v1", FT_UINT32, BASE_DEC,
+                       VALS(ypbind1_proc_vals), 0, "V1 Procedure", HFILL }},
+               { &hf_ypbind_procedure_v2, {
+                       "V2 Procedure", "ypbind.procedure_v2", FT_UINT32, BASE_DEC,
+                       VALS(ypbind2_proc_vals), 0, "V2 Procedure", HFILL }},
                { &hf_ypbind_domain, {
                        "Domain", "ypbind.domain", FT_STRING, BASE_DEC,
                        NULL, 0, "Name of the NIS/YP Domain", HFILL }},
@@ -210,6 +217,6 @@ proto_reg_handoff_ypbind(void)
        /* Register the protocol as RPC */
        rpc_init_prog(proto_ypbind, YPBIND_PROGRAM, ett_ypbind);
        /* Register the procedure tables */
-       rpc_init_proc_table(YPBIND_PROGRAM, 1, ypbind1_proc);
-       rpc_init_proc_table(YPBIND_PROGRAM, 2, ypbind2_proc);
+       rpc_init_proc_table(YPBIND_PROGRAM, 1, ypbind1_proc, hf_ypbind_procedure_v1);
+       rpc_init_proc_table(YPBIND_PROGRAM, 2, ypbind2_proc, hf_ypbind_procedure_v2);
 }