aboutsummaryrefslogtreecommitdiffstats
path: root/packet-ypserv.c
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2001-03-17 21:16:56 +0000
committerGuy Harris <guy@alum.mit.edu>2001-03-17 21:16:56 +0000
commitd606be7973f371a06851b1136cace147b10c27b2 (patch)
tree22a04d0111274b089325f8761a5ef4b5ce1f65ed /packet-ypserv.c
parentf803074e83ded7dec96c88a84a6d35321d5ab03d (diff)
YPSERV tvbuffified, and additional dissection added, by Ronnie Sahlberg.
svn path=/trunk/; revision=3142
Diffstat (limited to 'packet-ypserv.c')
-rw-r--r--packet-ypserv.c322
1 files changed, 251 insertions, 71 deletions
diff --git a/packet-ypserv.c b/packet-ypserv.c
index 672143c903..5674f45b65 100644
--- a/packet-ypserv.c
+++ b/packet-ypserv.c
@@ -1,7 +1,7 @@
/* packet-ypserv.c
* Routines for ypserv dissection
*
- * $Id: packet-ypserv.c,v 1.14 2001/01/28 03:39:48 guy Exp $
+ * $Id: packet-ypserv.c,v 1.15 2001/03/17 21:16:56 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@@ -9,6 +9,9 @@
*
* Copied from packet-smb.c
*
+ * 2001 Ronnie Sahlberg <rsahlber@bigpond.net.au>
+ * Added all remaining dissectors for this protocol
+ *
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
@@ -42,109 +45,261 @@ static int hf_ypserv_domain = -1;
static int hf_ypserv_servesdomain = -1;
static int hf_ypserv_map = -1;
static int hf_ypserv_key = -1;
+static int hf_ypserv_peer = -1;
+static int hf_ypserv_more = -1;
+static int hf_ypserv_ordernum = -1;
+static int hf_ypserv_transid = -1;
+static int hf_ypserv_prog = -1;
+static int hf_ypserv_port = -1;
static int hf_ypserv_value = -1;
static int hf_ypserv_status = -1;
+static int hf_ypserv_map_parms = -1;
+static int hf_ypserv_xfrstat = -1;
static gint ett_ypserv = -1;
+static gint ett_ypserv_map_parms = -1;
+
+static const value_string ypstat[] =
+{
+ { 1, "YP_TRUE" },
+ { 2, "YP_NOMORE" },
+ { 0, "YP_FALSE" },
+ { -1, "YP_NOMAP" },
+ { -2, "YP_NODOM" },
+ { -3, "YP_NOKEY" },
+ { -4, "YP_BADOP" },
+ { -5, "YP_BADDB" },
+ { -6, "YP_YPERR" },
+ { -7, "YP_BADARGS" },
+ { -8, "YP_VERS" },
+ { 0, NULL },
+};
+
+static const value_string xfrstat[] =
+{
+ { 1, "YPXFR_SUCC" },
+ { 2, "YPXFR_AGE" },
+ { -1, "YPXFR_NOMAP" },
+ { -2, "YPXFR_NODOM" },
+ { -3, "YPXFR_RSRC" },
+ { -4, "YPXFR_RPC" },
+ { -5, "YPXFR_MADDR" },
+ { -6, "YPXFR_YPERR" },
+ { -7, "YPXFR_BADARGS" },
+ { -8, "YPXFR_DBM" },
+ { -9, "YPXFR_FILE" },
+ { -10, "YPXFR_SKEW" },
+ { -11, "YPXFR_CLEAR" },
+ { -12, "YPXFR_FORCE" },
+ { -13, "YPXFR_XFRERR" },
+ { -14, "YPXFR_REFUSED" },
+ { 0, NULL },
+};
-/* Dissect a domain call */
-int dissect_domain_call(const u_char *pd, int offset, frame_data *fd,
- proto_tree *tree)
+static int
+dissect_domain_call(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree)
{
if ( tree )
{
- offset = dissect_rpc_string(pd,offset,fd,tree,hf_ypserv_domain,NULL);
+ offset = dissect_rpc_string_tvb(tvb,pinfo,tree,hf_ypserv_domain,offset,NULL);
}
return offset;
}
-int dissect_domain_reply(const u_char *pd, int offset, frame_data *fd,
- proto_tree *tree)
+static int
+dissect_domain_reply(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree)
{
- if ( !BYTES_ARE_IN_FRAME(offset, 4)) return offset;
-
if ( tree )
{
- proto_tree_add_boolean(tree, hf_ypserv_servesdomain, NullTVB,
- offset, 4, pntohl(&pd[offset]));
+ proto_tree_add_boolean(tree, hf_ypserv_servesdomain, tvb,
+ offset, 4, tvb_get_ntohl(tvb,offset));
}
offset += 4;
return offset;
}
-/* Dissect a next call */
-int dissect_next_call(const u_char *pd, int offset, frame_data *fd,
- proto_tree *tree)
+static int
+dissect_match_call(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree)
{
if ( tree )
{
- offset = dissect_rpc_string(pd,offset,fd,tree,hf_ypserv_domain,NULL);
- offset = dissect_rpc_string(pd,offset,fd,tree,hf_ypserv_map,NULL);
- offset = dissect_rpc_string(pd,offset,fd,tree,hf_ypserv_key,NULL);
+ offset = dissect_rpc_string_tvb(tvb, pinfo, tree, hf_ypserv_domain, offset, NULL);
+ offset = dissect_rpc_string_tvb(tvb, pinfo, tree, hf_ypserv_map, offset, NULL);
+ offset = dissect_rpc_string_tvb(tvb, pinfo, tree, hf_ypserv_key, offset, NULL);
}
return offset;
}
-int dissect_first_call(const u_char *pd, int offset, frame_data *fd,
- proto_tree *tree)
+static int
+dissect_match_reply(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree)
{
if ( tree )
{
- offset = dissect_rpc_string(pd,offset,fd,tree,hf_ypserv_domain,NULL);
- offset = dissect_rpc_string(pd,offset,fd,tree,hf_ypserv_map,NULL);
+ offset = dissect_rpc_uint32_tvb(tvb, pinfo, tree, hf_ypserv_status, offset);
+
+ offset = dissect_rpc_string_tvb(tvb, pinfo, tree, hf_ypserv_value,offset, NULL);
}
return offset;
}
-int dissect_match_call(const u_char *pd, int offset, frame_data *fd,
- proto_tree *tree)
+
+static int
+dissect_first_call(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree)
{
if ( tree )
{
- offset = dissect_rpc_string(pd,offset,fd,tree,hf_ypserv_domain,NULL);
- offset = dissect_rpc_string(pd,offset,fd,tree,hf_ypserv_map,NULL);
- offset = dissect_rpc_string(pd,offset,fd,tree,hf_ypserv_key,NULL);
+ offset = dissect_rpc_string_tvb(tvb, pinfo, tree, hf_ypserv_domain, offset, NULL);
+ offset = dissect_rpc_string_tvb(tvb, pinfo, tree, hf_ypserv_map, offset, NULL);
+ offset = dissect_rpc_string_tvb(tvb, pinfo, tree, hf_ypserv_key, offset, NULL);
}
return offset;
}
-int dissect_match_reply(const u_char *pd, int offset, frame_data *fd,
- proto_tree *tree)
-{
- if ( !BYTES_ARE_IN_FRAME(offset, 4)) return offset;
+static int
+dissect_firstnext_reply(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree)
+{
if ( tree )
{
- proto_tree_add_boolean(tree, hf_ypserv_status, NullTVB,
- offset, 4, pntohl(&pd[offset]));
- offset += 4;
+ offset = dissect_rpc_uint32_tvb(tvb, pinfo, tree, hf_ypserv_status, offset);
- offset = dissect_rpc_string(pd,offset,fd,tree,hf_ypserv_value,NULL);
+ offset = dissect_rpc_string_tvb(tvb, pinfo, tree, hf_ypserv_value, offset, NULL);
+ offset = dissect_rpc_string_tvb(tvb, pinfo, tree, hf_ypserv_key, offset, NULL);
}
return offset;
}
-int dissect_firstnext_reply(const u_char *pd, int offset, frame_data *fd,
- proto_tree *tree)
-{
- if ( !BYTES_ARE_IN_FRAME(offset, 4)) return offset;
+static int
+dissect_next_call(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree)
+{
if ( tree )
{
- proto_tree_add_boolean(tree, hf_ypserv_status, NullTVB,
- offset, 4, pntohl(&pd[offset]));
- offset += 4;
+ offset = dissect_rpc_string_tvb(tvb, pinfo, tree, hf_ypserv_domain, offset, NULL);
+ offset = dissect_rpc_string_tvb(tvb, pinfo, tree, hf_ypserv_map, offset, NULL);
+ offset = dissect_rpc_string_tvb(tvb, pinfo, tree, hf_ypserv_key, offset, NULL);
+ }
+
+ return offset;
+}
- offset = dissect_rpc_string(pd,offset,fd,tree,hf_ypserv_value,NULL);
- offset = dissect_rpc_string(pd,offset,fd,tree,hf_ypserv_key,NULL);
+static int
+dissect_xfr_call(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree)
+{
+ proto_item *lock_item=NULL;
+ proto_tree *lock_tree=NULL;
+ guint32 tid;
+
+ if(tree){
+ lock_item = proto_tree_add_item(tree, hf_ypserv_map_parms, tvb,
+ offset, tvb_length_remaining(tvb, offset)-12, FALSE);
+ if(lock_item)
+ lock_tree = proto_item_add_subtree(lock_item, ett_ypserv_map_parms);
}
+
+ offset = dissect_rpc_string_tvb(tvb, pinfo, lock_tree, hf_ypserv_domain, offset, NULL);
+
+ offset = dissect_rpc_string_tvb(tvb, pinfo, lock_tree, hf_ypserv_map, offset, NULL);
+
+ offset = dissect_rpc_uint32_tvb(tvb, pinfo, lock_tree, hf_ypserv_ordernum, offset);
+
+ offset = dissect_rpc_string_tvb(tvb, pinfo, lock_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);
+ offset += 4;
+
+ offset = dissect_rpc_uint32_tvb(tvb, pinfo, tree, hf_ypserv_prog, offset);
+ offset = dissect_rpc_uint32_tvb(tvb, pinfo, tree, hf_ypserv_port, offset);
+
+ return offset;
+}
+
+static int
+dissect_xfr_reply(tvbuff_t *tvb, int offset, packet_info *pinfo, 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);
+ offset += 4;
+
+ offset = dissect_rpc_uint32_tvb(tvb, pinfo, tree, hf_ypserv_xfrstat, offset);
+
+ return offset;
+}
+
+static int
+dissect_ypreq_nokey(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree)
+{
+
+ offset = dissect_rpc_string_tvb(tvb, pinfo, tree, hf_ypserv_domain, offset, NULL);
+ offset = dissect_rpc_string_tvb(tvb, pinfo, tree, hf_ypserv_map, offset, NULL);
+
+ return offset;
+}
+
+static int
+dissect_ypresp_all(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree)
+{
+ gint32 more;
+
+ more = tvb_get_ntohl(tvb, offset);
+
+ offset = dissect_rpc_uint32_tvb(tvb, pinfo, tree, hf_ypserv_more, offset);
+ if (more) {
+ offset = dissect_rpc_uint32_tvb(tvb, pinfo, tree, hf_ypserv_status, offset);
+ offset = dissect_rpc_string_tvb(tvb, pinfo, tree, hf_ypserv_value, offset, NULL);
+ offset = dissect_rpc_string_tvb(tvb, pinfo, tree, hf_ypserv_key, offset, NULL);
+ }
+
+ return offset;
+}
+
+static int
+dissect_ypresp_master(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree)
+{
+
+ offset = dissect_rpc_uint32_tvb(tvb, pinfo, tree, hf_ypserv_status, offset);
+
+ offset = dissect_rpc_string_tvb(tvb, pinfo, tree, hf_ypserv_peer, offset, NULL);
+
+ return offset;
+}
+
+
+static int
+dissect_ypresp_order(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree)
+{
+
+ offset = dissect_rpc_uint32_tvb(tvb, pinfo, tree, hf_ypserv_status, offset);
+
+ offset = dissect_rpc_uint32_tvb(tvb, pinfo, tree, hf_ypserv_ordernum, offset);
+
+ return offset;
+}
+
+
+static int
+dissect_ypresp_maplist(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree)
+{
+ offset = dissect_rpc_uint32_tvb(tvb, pinfo, tree, hf_ypserv_status, offset);
+ while(tvb_get_ntohl(tvb,offset)){
+ offset = dissect_rpc_uint32_tvb(tvb, pinfo, tree, hf_ypserv_more, offset);
+ offset = dissect_rpc_string_tvb(tvb, pinfo, tree, hf_ypserv_map, offset, NULL);
+
+ }
+ offset = dissect_rpc_uint32_tvb(tvb, pinfo, tree, hf_ypserv_more, offset);
return offset;
}
@@ -153,58 +308,58 @@ int dissect_firstnext_reply(const u_char *pd, int offset, frame_data *fd,
/* NULL as function pointer means: type of arguments is "void". */
/* someone please get me a version 1 trace */
-static const old_vsff ypserv1_proc[] = {
+static const vsff ypserv1_proc[] = {
{ 0, "NULL", NULL, NULL },
- { YPPROC_ALL, "ALL",
- NULL, NULL },
- { YPPROC_CLEAR, "CLEAR",
- NULL, NULL },
{ YPPROC_DOMAIN, "DOMAIN",
NULL, NULL },
{ YPPROC_DOMAIN_NONACK, "DOMAIN_NONACK",
NULL, NULL },
+ { YPPROC_MATCH, "MATCH",
+ NULL, NULL },
{ YPPROC_FIRST, "FIRST",
NULL, NULL },
- { YPPROC_MAPLIST, "MAPLIST",
+ { YPPROC_NEXT, "NEXT",
NULL, NULL },
- { YPPROC_MASTER, "MASTER",
+ { YPPROC_XFR, "XFR",
NULL, NULL },
- { YPPROC_MATCH, "MATCH",
+ { YPPROC_CLEAR, "CLEAR",
NULL, NULL },
- { YPPROC_NEXT, "NEXT",
+ { YPPROC_ALL, "ALL",
+ NULL, NULL },
+ { YPPROC_MASTER, "MASTER",
NULL, NULL },
{ YPPROC_ORDER, "ORDER",
NULL, NULL },
- { YPPROC_XFR, "XFR",
+ { YPPROC_MAPLIST, "MAPLIST",
NULL, NULL },
{ 0, NULL, NULL, NULL }
};
/* end of YPServ version 2 */
-static const old_vsff ypserv2_proc[] = {
+static const vsff ypserv2_proc[] = {
{ 0, "NULL", NULL, NULL },
- { YPPROC_ALL, "ALL",
- NULL, NULL },
- { YPPROC_CLEAR, "CLEAR",
- NULL, NULL },
{ YPPROC_DOMAIN, "DOMAIN",
dissect_domain_call, dissect_domain_reply },
{ YPPROC_DOMAIN_NONACK, "DOMAIN_NONACK",
dissect_domain_call, dissect_domain_reply },
- { YPPROC_FIRST, "FIRST",
- dissect_first_call, dissect_firstnext_reply },
- { YPPROC_MAPLIST, "MAPLIST",
- NULL, NULL },
- { YPPROC_MASTER, "MASTER",
- NULL, NULL },
{ YPPROC_MATCH, "MATCH",
dissect_match_call, dissect_match_reply },
+ { YPPROC_FIRST, "FIRST",
+ dissect_first_call, dissect_firstnext_reply },
{ YPPROC_NEXT, "NEXT",
dissect_next_call, dissect_firstnext_reply },
- { YPPROC_ORDER, "ORDER",
- NULL, NULL },
{ YPPROC_XFR, "XFR",
+ dissect_xfr_call, dissect_xfr_reply },
+ { YPPROC_CLEAR, "CLEAR",
NULL, NULL },
+ { YPPROC_ALL, "ALL",
+ dissect_ypreq_nokey, dissect_ypresp_all },
+ { YPPROC_MASTER, "MASTER",
+ dissect_ypreq_nokey, dissect_ypresp_master },
+ { YPPROC_ORDER, "ORDER",
+ dissect_ypreq_nokey, dissect_ypresp_order },
+ { YPPROC_MAPLIST, "MAPLIST",
+ dissect_domain_call, dissect_ypresp_maplist },
{ 0, NULL, NULL, NULL }
};
/* end of YPServ version 2 */
@@ -213,7 +368,7 @@ static const old_vsff ypserv2_proc[] = {
void
proto_register_ypserv(void)
{
- static struct true_false_string okfailed = { "Ok", "Failed" };
+ /*static struct true_false_string okfailed = { "Ok", "Failed" };*/
static struct true_false_string yesno = { "Yes", "No" };
static hf_register_info hf[] = {
@@ -226,6 +381,24 @@ proto_register_ypserv(void)
{ &hf_ypserv_map, {
"Map Name", "ypserv.map", FT_STRING, BASE_DEC,
NULL, 0, "Map Name" }},
+ { &hf_ypserv_peer, {
+ "Peer Name", "ypserv.peer", FT_STRING, BASE_DEC,
+ NULL, 0, "Peer Name" }},
+ { &hf_ypserv_more, {
+ "More", "ypserv.more", FT_BOOLEAN, BASE_NONE,
+ &yesno, 0, "More" }},
+ { &hf_ypserv_ordernum, {
+ "Order Number", "ypserv.ordernum", FT_UINT32, BASE_DEC,
+ NULL, 0, "Order Number for XFR" }},
+ { &hf_ypserv_transid, {
+ "Host Transport ID", "ypserv.transid", FT_IPv4, BASE_DEC,
+ NULL, 0, "Host Transport ID to use for XFR Callback" }},
+ { &hf_ypserv_prog, {
+ "Program Number", "ypserv.prog", FT_UINT32, BASE_DEC,
+ NULL, 0, "Program Number to use for XFR Callback" }},
+ { &hf_ypserv_port, {
+ "Port", "ypserv.port", FT_UINT32, BASE_DEC,
+ NULL, 0, "Port to use for XFR Callback" }},
{ &hf_ypserv_key, {
"Key", "ypserv.key", FT_STRING, BASE_DEC,
NULL, 0, "Key" }},
@@ -233,11 +406,18 @@ proto_register_ypserv(void)
"Value", "ypserv.value", FT_STRING, BASE_DEC,
NULL, 0, "Value" }},
{ &hf_ypserv_status, {
- "Status", "ypserv.status", FT_BOOLEAN, BASE_DEC,
- &okfailed , 0, "Status" }},
+ "Status", "ypserv.status", FT_INT32, BASE_DEC,
+ VALS(ypstat) , 0, "Status" }},
+ { &hf_ypserv_map_parms, {
+ "YP Map Parameters", "ypserv.map_parms", FT_NONE, BASE_DEC,
+ NULL, 0, "YP Map Parameters" }},
+ { &hf_ypserv_xfrstat, {
+ "Xfrstat", "ypserv.xfrstat", FT_INT32, BASE_DEC,
+ VALS(xfrstat), 0, "Xfrstat" }},
};
static gint *ett[] = {
&ett_ypserv,
+ &ett_ypserv_map_parms,
};
proto_ypserv = proto_register_protocol("Yellow Pages Service",
@@ -252,6 +432,6 @@ proto_reg_handoff_ypserv(void)
/* Register the protocol as RPC */
rpc_init_prog(proto_ypserv, YPSERV_PROGRAM, ett_ypserv);
/* Register the procedure tables */
- old_rpc_init_proc_table(YPSERV_PROGRAM, 1, ypserv1_proc);
- old_rpc_init_proc_table(YPSERV_PROGRAM, 2, ypserv2_proc);
+ rpc_init_proc_table(YPSERV_PROGRAM, 1, ypserv1_proc);
+ rpc_init_proc_table(YPSERV_PROGRAM, 2, ypserv2_proc);
}