Minor spelling etc updates.
[metze/wireshark/wip.git] / packet-ypserv.c
index 39e3008ce8f07f21795cf2a197ecfc0e853408e3..58d0c05fb97c06b0f7dcfdb2ac2e1f3d250aad0d 100644 (file)
@@ -1,7 +1,7 @@
 /* packet-ypserv.c
  * Routines for ypserv dissection
  *
- * $Id: packet-ypserv.c,v 1.20 2002/02/20 21:02:46 guy Exp $
+ * $Id: packet-ypserv.c,v 1.26 2002/10/24 20:59:21 guy Exp $
  *
  * Ethereal - Network traffic analyzer
  * By Gerald Combs <gerald@ethereal.com>
 #endif
 
 
-#ifdef HAVE_SYS_TYPES_H
-#include <sys/types.h>
-#endif
-
 
 #include "packet-rpc.h"
 #include "packet-ypserv.h"
 
 static int proto_ypserv = -1;
+static int hf_ypserv_procedure_v1 = -1;
+static int hf_ypserv_procedure_v2 = -1;
 static int hf_ypserv_domain = -1;
 static int hf_ypserv_servesdomain = -1;
 static int hf_ypserv_map = -1;
@@ -97,18 +95,18 @@ static const value_string xfrstat[] =
 };
 
 static int
-dissect_domain_call(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree)
+dissect_domain_call(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree)
 {
        if ( tree )
        {
-               offset = dissect_rpc_string(tvb,pinfo,tree,hf_ypserv_domain,offset,NULL);
+               offset = dissect_rpc_string(tvb,tree,hf_ypserv_domain,offset,NULL);
        }
-       
+
        return offset;
 }
 
 static int
-dissect_domain_reply(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree)
+dissect_domain_reply(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree)
 {
        if ( tree )
        {
@@ -116,39 +114,39 @@ dissect_domain_reply(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *
                        offset, 4, tvb_get_ntohl(tvb,offset));
        }
 
-       offset += 4;    
+       offset += 4;
        return offset;
 }
 
 static int
-dissect_match_call(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree)
+dissect_match_call(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree)
 {
        if ( tree )
        {
-               offset = dissect_rpc_string(tvb, pinfo, tree, hf_ypserv_domain, offset, NULL);
-               offset = dissect_rpc_string(tvb, pinfo, tree, hf_ypserv_map, offset, NULL);
-               offset = dissect_rpc_string(tvb, pinfo, tree, hf_ypserv_key, offset, NULL);
+               offset = dissect_rpc_string(tvb, tree, hf_ypserv_domain, offset, NULL);
+               offset = dissect_rpc_string(tvb, tree, hf_ypserv_map, offset, NULL);
+               offset = dissect_rpc_string(tvb, tree, hf_ypserv_key, offset, NULL);
        }
-       
+
        return offset;
 }
 
 static int
-dissect_match_reply(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree)
+dissect_match_reply(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree)
 {
        if ( tree )
        {
-               offset = dissect_rpc_uint32(tvb, pinfo, tree, hf_ypserv_status, offset);
+               offset = dissect_rpc_uint32(tvb, tree, hf_ypserv_status, offset);
 
-               offset = dissect_rpc_string(tvb, pinfo, tree, hf_ypserv_value,offset, NULL);
+               offset = dissect_rpc_string(tvb, tree, hf_ypserv_value,offset, NULL);
        }
-       
+
        return offset;
 }
 
 
 static int
-dissect_first_call(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree)
+dissect_first_call(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree)
 {
        /*
         * XXX - does Sun's "yp.x" lie, and claim that the argument to a
@@ -167,52 +165,51 @@ dissect_first_call(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tr
         * had a "ypreq_nokey" as the argument, I'm assuming that "yp.x"
         * is buggy.
         */
-       
+
        if ( tree )
        {
-               offset = dissect_rpc_string(tvb, pinfo, tree, hf_ypserv_domain, offset, NULL);
-               offset = dissect_rpc_string(tvb, pinfo, tree, hf_ypserv_map, offset, NULL);
+               offset = dissect_rpc_string(tvb, tree, hf_ypserv_domain, offset, NULL);
+               offset = dissect_rpc_string(tvb, tree, hf_ypserv_map, offset, NULL);
        }
-       
+
        return offset;
 }
 
 
 static int
-dissect_firstnext_reply(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree)
+dissect_firstnext_reply(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree)
 {
        if ( tree )
        {
-               offset = dissect_rpc_uint32(tvb, pinfo, tree, hf_ypserv_status, offset);
+               offset = dissect_rpc_uint32(tvb, tree, hf_ypserv_status, offset);
 
-               offset = dissect_rpc_string(tvb, pinfo, tree, hf_ypserv_value, offset, NULL);
-               offset = dissect_rpc_string(tvb, pinfo, tree, hf_ypserv_key, offset, NULL);
+               offset = dissect_rpc_string(tvb, tree, hf_ypserv_value, offset, NULL);
+               offset = dissect_rpc_string(tvb, tree, hf_ypserv_key, offset, NULL);
        }
-       
+
        return offset;
 }
 
 
 static int
-dissect_next_call(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree)
+dissect_next_call(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree)
 {
        if ( tree )
        {
-               offset = dissect_rpc_string(tvb, pinfo, tree, hf_ypserv_domain, offset, NULL);
-               offset = dissect_rpc_string(tvb, pinfo, tree, hf_ypserv_map, offset, NULL);
-               offset = dissect_rpc_string(tvb, pinfo, tree, hf_ypserv_key, offset, NULL);
+               offset = dissect_rpc_string(tvb, tree, hf_ypserv_domain, offset, NULL);
+               offset = dissect_rpc_string(tvb, tree, hf_ypserv_map, offset, NULL);
+               offset = dissect_rpc_string(tvb, tree, hf_ypserv_key, offset, NULL);
        }
-       
+
        return offset;
 }
 
 static int
-dissect_xfr_call(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree)
+dissect_xfr_call(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree)
 {
        proto_item *sub_item=NULL;
        proto_tree *sub_tree=NULL;
        int start_offset = offset;
-       guint32 tid;
 
        if(tree){
                sub_item = proto_tree_add_item(tree, hf_ypserv_map_parms, tvb,
@@ -221,22 +218,19 @@ dissect_xfr_call(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree
                        sub_tree = proto_item_add_subtree(sub_item, ett_ypserv_map_parms);
        }
 
-       offset = dissect_rpc_string(tvb, pinfo, sub_tree, hf_ypserv_domain, offset, NULL);
-       
-       offset = dissect_rpc_string(tvb, pinfo, sub_tree, hf_ypserv_map, offset, NULL);
+       offset = dissect_rpc_string(tvb, sub_tree, hf_ypserv_domain, offset, NULL);
 
-       offset = dissect_rpc_uint32(tvb, pinfo, sub_tree, hf_ypserv_ordernum, offset);
+       offset = dissect_rpc_string(tvb, sub_tree, hf_ypserv_map, offset, NULL);
 
-       offset = dissect_rpc_string(tvb, pinfo, sub_tree, hf_ypserv_peer, offset, NULL);
+       offset = dissect_rpc_uint32(tvb, sub_tree, hf_ypserv_ordernum, offset);
 
+       offset = dissect_rpc_string(tvb, sub_tree, hf_ypserv_peer, offset, NULL);
 
-       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_ypserv_transid, tvb, offset, 4, tid);
+       proto_tree_add_item(tree, hf_ypserv_transid, tvb, offset, 4, FALSE);
        offset += 4;
 
-       offset = dissect_rpc_uint32(tvb, pinfo, tree, hf_ypserv_prog, offset);
-       offset = dissect_rpc_uint32(tvb, pinfo, tree, hf_ypserv_port, offset);
+       offset = dissect_rpc_uint32(tvb, tree, hf_ypserv_prog, offset);
+       offset = dissect_rpc_uint32(tvb, tree, hf_ypserv_port, offset);
 
        if(sub_item)
                proto_item_set_len(sub_item, offset - start_offset);
@@ -245,84 +239,80 @@ dissect_xfr_call(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree
 }
 
 static int
-dissect_xfr_reply(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree)
+dissect_xfr_reply(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree)
 {
-       guint32 tid;
-
-       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_ypserv_transid, tvb, offset, 4, tid);
+       proto_tree_add_item(tree, hf_ypserv_transid, tvb, offset, 4, FALSE);
        offset += 4;
 
-       offset = dissect_rpc_uint32(tvb, pinfo, tree, hf_ypserv_xfrstat, offset);
+       offset = dissect_rpc_uint32(tvb, tree, hf_ypserv_xfrstat, offset);
 
        return offset;
 }
 
 static int
-dissect_ypreq_nokey(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree)
+dissect_ypreq_nokey(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree)
 {
 
-       offset = dissect_rpc_string(tvb, pinfo, tree, hf_ypserv_domain, offset, NULL);
-       
-       offset = dissect_rpc_string(tvb, pinfo, tree, hf_ypserv_map, offset, NULL);
+       offset = dissect_rpc_string(tvb, tree, hf_ypserv_domain, offset, NULL);
+
+       offset = dissect_rpc_string(tvb, tree, hf_ypserv_map, offset, NULL);
 
        return offset;
 }
 
 static int
-dissect_ypresp_all(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree)
+dissect_ypresp_all(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree)
 {
        guint32 more;
 
        for (;;) {
                more = tvb_get_ntohl(tvb, offset);
 
-               offset = dissect_rpc_uint32(tvb, pinfo, tree, hf_ypserv_more, offset);
+               offset = dissect_rpc_uint32(tvb, tree, hf_ypserv_more, offset);
                if (!more)
                        break;
-               offset = dissect_rpc_uint32(tvb, pinfo, tree, hf_ypserv_status, offset);
-               offset = dissect_rpc_string(tvb, pinfo, tree, hf_ypserv_value, offset, NULL);
-               offset = dissect_rpc_string(tvb, pinfo, tree, hf_ypserv_key, offset, NULL);
+               offset = dissect_rpc_uint32(tvb, tree, hf_ypserv_status, offset);
+               offset = dissect_rpc_string(tvb, tree, hf_ypserv_value, offset, NULL);
+               offset = dissect_rpc_string(tvb, tree, hf_ypserv_key, offset, NULL);
        }
 
        return offset;
 }
 
 static int
-dissect_ypresp_master(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree)
+dissect_ypresp_master(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree)
 {
 
-       offset = dissect_rpc_uint32(tvb, pinfo, tree, hf_ypserv_status, offset);
+       offset = dissect_rpc_uint32(tvb, tree, hf_ypserv_status, offset);
 
-       offset = dissect_rpc_string(tvb, pinfo, tree, hf_ypserv_peer, offset, NULL);
+       offset = dissect_rpc_string(tvb, tree, hf_ypserv_peer, offset, NULL);
 
        return offset;
 }
 
 
 static int
-dissect_ypresp_order(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree)
+dissect_ypresp_order(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree)
 {
 
-       offset = dissect_rpc_uint32(tvb, pinfo, tree, hf_ypserv_status, offset);
+       offset = dissect_rpc_uint32(tvb, tree, hf_ypserv_status, offset);
 
-       offset = dissect_rpc_uint32(tvb, pinfo, tree, hf_ypserv_ordernum, offset);
+       offset = dissect_rpc_uint32(tvb, tree, hf_ypserv_ordernum, offset);
 
        return offset;
 }
 
 
 static int
-dissect_ypresp_maplist(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree)
+dissect_ypresp_maplist(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree)
 {
-       offset = dissect_rpc_uint32(tvb, pinfo, tree, hf_ypserv_status, offset);
+       offset = dissect_rpc_uint32(tvb, tree, hf_ypserv_status, offset);
        while(tvb_get_ntohl(tvb,offset)){
-               offset = dissect_rpc_uint32(tvb, pinfo, tree, hf_ypserv_more, offset);
-               offset = dissect_rpc_string(tvb, pinfo, tree, hf_ypserv_map, offset, NULL);
+               offset = dissect_rpc_uint32(tvb, tree, hf_ypserv_more, offset);
+               offset = dissect_rpc_string(tvb, tree, hf_ypserv_map, offset, NULL);
 
        }
-       offset = dissect_rpc_uint32(tvb, pinfo, tree, hf_ypserv_more, offset);
+       offset = dissect_rpc_uint32(tvb, tree, hf_ypserv_more, offset);
        return offset;
 }
 
@@ -331,33 +321,53 @@ dissect_ypresp_maplist(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree
 /* NULL as function pointer means: type of arguments is "void". */
 
 /* someone please get me a version 1 trace */
+
 static const vsff ypserv1_proc[] = {
     { 0, "NULL", NULL, NULL },
     { YPPROC_DOMAIN, "DOMAIN",
                NULL, NULL },
     { YPPROC_DOMAIN_NONACK, "DOMAIN_NONACK",
                NULL, NULL },
-    { YPPROC_MATCH, "MATCH",        
+    { YPPROC_MATCH, "MATCH",
                NULL, NULL },
-    { YPPROC_FIRST, "FIRST",        
+    { YPPROC_FIRST, "FIRST",
                NULL, NULL },
-    { YPPROC_NEXT,  "NEXT",     
+    { YPPROC_NEXT,  "NEXT",
                NULL, NULL },
-    { YPPROC_XFR,   "XFR",      
+    { YPPROC_XFR,   "XFR",
                NULL, NULL },
-    { YPPROC_CLEAR, "CLEAR",        
+    { YPPROC_CLEAR, "CLEAR",
                NULL, NULL },
-    { YPPROC_ALL,   "ALL",      
+    { YPPROC_ALL,   "ALL",
                NULL, NULL },
-    { YPPROC_MASTER,    "MASTER",       
+    { YPPROC_MASTER,    "MASTER",
                NULL, NULL },
-    { YPPROC_ORDER, "ORDER",        
+    { YPPROC_ORDER, "ORDER",
                NULL, NULL },
-    { YPPROC_MAPLIST,   "MAPLIST",      
+    { YPPROC_MAPLIST,   "MAPLIST",
                NULL, NULL },
     { 0, NULL, NULL, NULL }
 };
-/* end of YPServ version 2 */
+
+static const value_string ypserv1_proc_vals[] = {
+    { YPPROC_DOMAIN, "DOMAIN" },
+    { YPPROC_DOMAIN_NONACK, "DOMAIN_NONACK" },
+    { YPPROC_MATCH, "MATCH" },
+    { YPPROC_FIRST, "FIRST" },
+    { YPPROC_NEXT,  "NEXT" },
+    { YPPROC_XFR,   "XFR" },
+    { YPPROC_CLEAR, "CLEAR" },
+    { YPPROC_ALL,   "ALL" },
+    { YPPROC_MASTER,    "MASTER" },
+    { YPPROC_ORDER, "ORDER" },
+    { YPPROC_MAPLIST,   "MAPLIST" },
+    { 0, NULL }
+};
+
+/* end of YPServ version 1 */
+
+/* proc number, "proc name", dissect_request, dissect_reply */
+/* NULL as function pointer means: type of arguments is "void". */
 
 static const vsff ypserv2_proc[] = {
     { 0, "NULL", NULL, NULL },
@@ -365,26 +375,42 @@ static const vsff ypserv2_proc[] = {
                dissect_domain_call, dissect_domain_reply },
     { YPPROC_DOMAIN_NONACK, "DOMAIN_NONACK",
                dissect_domain_call, dissect_domain_reply },
-    { YPPROC_MATCH, "MATCH",        
+    { YPPROC_MATCH, "MATCH",
                dissect_match_call, dissect_match_reply },
-    { YPPROC_FIRST, "FIRST",        
+    { YPPROC_FIRST, "FIRST",
                dissect_first_call, dissect_firstnext_reply },
-    { YPPROC_NEXT,  "NEXT",     
+    { YPPROC_NEXT,  "NEXT",
                dissect_next_call, dissect_firstnext_reply },
-    { YPPROC_XFR,   "XFR",      
+    { YPPROC_XFR,   "XFR",
                dissect_xfr_call, dissect_xfr_reply },
-    { YPPROC_CLEAR, "CLEAR",        
+    { YPPROC_CLEAR, "CLEAR",
                NULL, NULL },
-    { YPPROC_ALL,   "ALL",      
+    { YPPROC_ALL,   "ALL",
                dissect_ypreq_nokey, dissect_ypresp_all },
-    { YPPROC_MASTER,    "MASTER",       
+    { YPPROC_MASTER,    "MASTER",
                dissect_ypreq_nokey, dissect_ypresp_master },
-    { YPPROC_ORDER, "ORDER",        
+    { YPPROC_ORDER, "ORDER",
                dissect_ypreq_nokey, dissect_ypresp_order },
-    { YPPROC_MAPLIST,   "MAPLIST",      
+    { YPPROC_MAPLIST,   "MAPLIST",
                dissect_domain_call, dissect_ypresp_maplist },
     { 0, NULL, NULL, NULL }
 };
+
+static const value_string ypserv2_proc_vals[] = {
+    { YPPROC_DOMAIN, "DOMAIN" },
+    { YPPROC_DOMAIN_NONACK, "DOMAIN_NONACK" },
+    { YPPROC_MATCH, "MATCH" },
+    { YPPROC_FIRST, "FIRST" },
+    { YPPROC_NEXT,  "NEXT" },
+    { YPPROC_XFR,   "XFR" },
+    { YPPROC_CLEAR, "CLEAR" },
+    { YPPROC_ALL,   "ALL" },
+    { YPPROC_MASTER,    "MASTER" },
+    { YPPROC_ORDER, "ORDER" },
+    { YPPROC_MAPLIST,   "MAPLIST" },
+    { 0, NULL }
+};
+
 /* end of YPServ version 2 */
 
 
@@ -393,8 +419,14 @@ proto_register_ypserv(void)
 {
        /*static struct true_false_string okfailed = { "Ok", "Failed" };*/
        static struct true_false_string yesno = { "Yes", "No" };
-               
+
        static hf_register_info hf[] = {
+               { &hf_ypserv_procedure_v1, {
+                       "V1 Procedure", "ypserv.procedure_v1", FT_UINT32, BASE_DEC,
+                       VALS(ypserv1_proc_vals), 0, "V1 Procedure", HFILL }},
+               { &hf_ypserv_procedure_v2, {
+                       "V2 Procedure", "ypserv.procedure_v2", FT_UINT32, BASE_DEC,
+                       VALS(ypserv2_proc_vals), 0, "V2 Procedure", HFILL }},
                { &hf_ypserv_domain, {
                        "Domain", "ypserv.domain", FT_STRING, BASE_DEC,
                        NULL, 0, "Domain", HFILL }},
@@ -455,6 +487,8 @@ proto_reg_handoff_ypserv(void)
        /* Register the protocol as RPC */
        rpc_init_prog(proto_ypserv, YPSERV_PROGRAM, ett_ypserv);
        /* Register the procedure tables */
-       rpc_init_proc_table(YPSERV_PROGRAM, 1, ypserv1_proc);
-       rpc_init_proc_table(YPSERV_PROGRAM, 2, ypserv2_proc);
+       rpc_init_proc_table(YPSERV_PROGRAM, 1, ypserv1_proc,
+           hf_ypserv_procedure_v1);
+       rpc_init_proc_table(YPSERV_PROGRAM, 2, ypserv2_proc,
+           hf_ypserv_procedure_v2);
 }