diff options
author | Gilbert Ramirez <gram@alumni.rice.edu> | 2002-05-09 04:24:40 +0000 |
---|---|---|
committer | Gilbert Ramirez <gram@alumni.rice.edu> | 2002-05-09 04:24:40 +0000 |
commit | 367ef2b71b90644d016c3f58a61f4603c789ccd8 (patch) | |
tree | 4d474df2bd32ba0796e1c352b6c003c12cd675b9 | |
parent | 957ce941774592c92accd6deb7965eff41338c70 (diff) | |
download | wireshark-Novell_NCP_branch.tar.gz wireshark-Novell_NCP_branch.tar.bz2 wireshark-Novell_NCP_branch.zip |
Add the ability to modify COL_INFO based on field values.backups/Novell_NCP_branch@18706Novell_NCP_branch
svn path=/branches/Novell_NCP_branch/; revision=5422
-rw-r--r-- | epan/dfilter/dfilter.c | 4 | ||||
-rw-r--r-- | epan/proto.c | 7 | ||||
-rw-r--r-- | epan/proto.h | 4 | ||||
-rwxr-xr-x | ncp2222.py | 41 | ||||
-rw-r--r-- | packet-ncp-int.h | 9 | ||||
-rw-r--r-- | packet-ncp2222.inc | 48 |
6 files changed, 92 insertions, 21 deletions
diff --git a/epan/dfilter/dfilter.c b/epan/dfilter/dfilter.c index 1204513117..7a6fbe6f4f 100644 --- a/epan/dfilter/dfilter.c +++ b/epan/dfilter/dfilter.c @@ -1,5 +1,5 @@ /* - * $Id: dfilter.c,v 1.7.2.1 2002/02/24 20:42:47 gram Exp $ + * $Id: dfilter.c,v 1.7.2.2 2002/05/09 04:24:40 gram Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> @@ -395,7 +395,7 @@ dfilter_prime_proto_tree(dfilter_t *df, proto_tree *tree) int i; for (i = 0; i < df->num_interesting_fields; i++) { - proto_tree_prime_hfid(GINT_TO_POINTER(df->interesting_fields[i]), tree); + proto_tree_prime_hfid(tree, df->interesting_fields[i]); } } diff --git a/epan/proto.c b/epan/proto.c index 66e78b1de7..dfaf8680e2 100644 --- a/epan/proto.c +++ b/epan/proto.c @@ -1,7 +1,7 @@ /* proto.c * Routines for protocol tree * - * $Id: proto.c,v 1.51.2.4 2002/03/08 04:32:32 gram Exp $ + * $Id: proto.c,v 1.51.2.5 2002/05/09 04:24:38 gram Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> @@ -1787,11 +1787,8 @@ proto_tree_create_root(void) /* "prime" a proto_tree with a single hfid that a dfilter * is interested in. */ void -proto_tree_prime_hfid(gpointer data, gpointer user_data) +proto_tree_prime_hfid(proto_tree *tree, gint hfid) { - int hfid = GPOINTER_TO_INT(data); - proto_tree *tree = user_data; - g_hash_table_insert(PTREE_DATA(tree)->interesting_hfids, GINT_TO_POINTER(hfid), g_ptr_array_new()); } diff --git a/epan/proto.h b/epan/proto.h index b4f2881405..536e6cd3de 100644 --- a/epan/proto.h +++ b/epan/proto.h @@ -1,7 +1,7 @@ /* proto.h * Definitions for protocol display * - * $Id: proto.h,v 1.27.2.2 2002/02/24 20:42:45 gram Exp $ + * $Id: proto.h,v 1.27.2.3 2002/05/09 04:24:39 gram Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> @@ -181,7 +181,7 @@ extern proto_tree* proto_tree_create_root(void); /* Mark fields/protocol IDs as "interesting". * data = hfid as pointer, user_data = proto_tree* */ void -proto_tree_prime_hfid(gpointer data, gpointer user_data); +proto_tree_prime_hfid(proto_tree *tree, gint hfid); /* Clear memory for entry proto_tree. Clears proto_tree struct also. */ extern void proto_tree_free(proto_tree *tree); diff --git a/ncp2222.py b/ncp2222.py index 71d3d201ea..bbd2694fd5 100755 --- a/ncp2222.py +++ b/ncp2222.py @@ -24,7 +24,7 @@ http://developer.novell.com/ndk/doc/docui/index.htm#../ncp/ncp__enu/data/ for a badly-formatted HTML version of the same PDF. -$Id: ncp2222.py,v 1.14.2.25 2002/03/30 17:08:08 gram Exp $ +$Id: ncp2222.py,v 1.14.2.26 2002/05/09 04:24:30 gram Exp $ Copyright (c) 2000-2002 by Gilbert Ramirez <gram@alumni.rice.edu> @@ -421,6 +421,7 @@ class NCP: self.reply_records = None self.has_length = has_length self.req_cond_size = None + self.req_info_str = None if not groups.has_key(group): msg.write("NCP 0x%x has invalid group '%s'\n" % \ @@ -483,7 +484,7 @@ class NCP: def PTVCReply(self): return self.ptvc_reply - def Request(self, size, records=[]): + def Request(self, size, records=[], **kwargs): self.request_size = size self.request_records = records if self.HasSubFunction(): @@ -495,6 +496,9 @@ class NCP: self.CheckRecords(size, records, "Request", 7) self.ptvc_request = self.MakePTVC(records, "request") + if kwargs.has_key("info_str"): + self.req_info_str = kwargs["info_str"] + def Reply(self, size, records=[]): self.reply_size = size self.reply_records = records @@ -552,6 +556,10 @@ class NCP: "Returns a C symbol based on the NCP function code" return "ncp_0x%x" % (self.func_code) + def InfoStrName(self): + "Returns a C symbol based on the NCP function code, for the info_str" + return "info_str_0x%x" % (self.func_code) + def Variables(self): """Returns a list of variables used in the request and reply records. A variable is listed only once, even if it is used twice (once in @@ -5449,6 +5457,19 @@ static int hf_ncp_connection_status = -1; # Functions without length parameter funcs_without_length = {} + # Print info string structures + print "/* Info Strings */" + for pkt in packets: + if pkt.req_info_str: + name = pkt.InfoStrName() + "_req" + var = pkt.req_info_str[0] + print "static const info_string_t %s = {" % (name,) + print "\t&%s," % (var.HFName(),) + print '\t"%s",' % (pkt.req_info_str[1],) + print '\t"%s"' % (pkt.req_info_str[2],) + print "};\n" + + # Print ncp_record packet records print "#define SUBFUNC_WITH_LENGTH 0x02" @@ -5504,13 +5525,17 @@ static int hf_ncp_connection_status = -1; msg.write("NCP packet %s nees a ReqCondSize*() call\n" \ % (pkt.CName(),)) sys.exit(1) - + + if pkt.req_info_str: + req_info_str = "&" + pkt.InfoStrName() + "_req" + else: + req_info_str = "NULL" - print '\t\t%s, %s, %s, %s, %s },\n' % \ + print '\t\t%s, %s, %s, %s, %s, %s },\n' % \ (ptvc_request, ptvc_reply, errors.Name(), req_conds, - req_cond_size) + req_cond_size, req_info_str) - print '\t{ 0, 0, 0, NULL, 0, NULL, NULL, NULL, NULL, NO_REQ_COND_SIZE }' + print '\t{ 0, 0, 0, NULL, 0, NULL, NULL, NULL, NULL, NO_REQ_COND_SIZE, NULL }' print "};\n" print "/* ncp funcs that require a subfunc */" @@ -9652,8 +9677,8 @@ def define_ncp2222(): rec( 19, 4, DirectoryBase ), rec( 23, 1, HandleFlag ), rec( 24, 1, PathCount, var="x" ), - rec( 25, (1,255), Path, repeat="x" ), - ]) + rec( 25, (1,255), Path, repeat="x",), + ], info_str=(Path, "Obtain File Info: %s", ", %s")) pkt.Reply(NO_LENGTH_CHECK, [ srec( DSSpaceAllocateStruct, req_cond="ncp.ret_info_mask_alloc == TRUE" ), srec( AttributesStruct, req_cond="ncp.ret_info_mask_attr == TRUE" ), diff --git a/packet-ncp-int.h b/packet-ncp-int.h index 01b54e90fc..4ffc1d7957 100644 --- a/packet-ncp-int.h +++ b/packet-ncp-int.h @@ -2,7 +2,7 @@ * Structures and functions for NetWare Core Protocol. * Gilbert Ramirez <gram@alumni.rice.edu> * - * $Id: packet-ncp-int.h,v 1.6.2.8 2002/03/04 05:35:07 gram Exp $ + * $Id: packet-ncp-int.h,v 1.6.2.9 2002/05/09 04:24:36 gram Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@zing.org> @@ -57,6 +57,12 @@ typedef struct { } conditional_record; typedef struct { + int *hf_ptr; + const char *first_string; + const char *repeat_string; +} info_string_t; + +typedef struct { guint8 error_in_packet; gint ncp_error_index; } error_equivalency; @@ -72,6 +78,7 @@ typedef struct { const error_equivalency *errors; const int *req_cond_indexes; unsigned int req_cond_size_type; + const info_string_t *req_info_str; } ncp_record; diff --git a/packet-ncp2222.inc b/packet-ncp2222.inc index 1a542a0667..9c12d0f551 100644 --- a/packet-ncp2222.inc +++ b/packet-ncp2222.inc @@ -7,7 +7,7 @@ * * Gilbert Ramirez <gram@alumni.rice.edu> * - * $Id: packet-ncp2222.inc,v 1.8.2.9 2002/03/30 17:08:14 gram Exp $ + * $Id: packet-ncp2222.inc,v 1.8.2.10 2002/05/09 04:24:36 gram Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> @@ -578,7 +578,7 @@ ncp_error_string(const error_equivalency *errors, guint8 completion_code) static const ncp_record ncp1111_request = { 0x01, 0x00, NO_SUBFUNC, "Create Connection Service", NCP_GROUP_CONNECTION, - NULL, NULL, ncp_0x2_errors, NULL, NO_REQ_COND_SIZE }; + NULL, NULL, ncp_0x2_errors, NULL, NO_REQ_COND_SIZE, NULL }; /* Wrapper around proto_tree_free() */ void free_proto_tree(void *tree) @@ -602,6 +602,7 @@ dissect_ncp_request(tvbuff_t *tvb, packet_info *pinfo, ptvcursor_t *ptvc = NULL; proto_tree *temp_tree = NULL; gboolean run_req_cond = FALSE; + gboolean run_info_str = FALSE; func = tvb_get_guint8(tvb, 6); @@ -677,7 +678,12 @@ dissect_ncp_request(tvbuff_t *tvb, packet_info *pinfo, if (ncp_rec->req_cond_indexes) { run_req_cond = TRUE; } - if (ncp_rec->req_cond_indexes && !ncp_tree) { + /* Only create info string if COL_INFO is available. */ + if (ncp_rec->req_info_str && check_col(pinfo->cinfo, COL_INFO)) { + run_info_str = TRUE; + } + /* We also have to use a tree if we have to construct an info_str */ + if ((run_info_str || run_req_cond) && !ncp_tree) { proto_item *ti; temp_tree = proto_tree_create_root(); @@ -715,6 +721,12 @@ dissect_ncp_request(tvbuff_t *tvb, packet_info *pinfo, } } + /* Before the dissection, if we need a field for the info_str, + * prime the tree. */ + if (run_info_str) { + proto_tree_prime_hfid(ncp_tree, *ncp_rec->req_info_str->hf_ptr); + } + conversation = find_conversation(&pinfo->src, &pinfo->dst, PT_NCP, nw_connection, nw_connection, 0); @@ -791,6 +803,36 @@ dissect_ncp_request(tvbuff_t *tvb, packet_info *pinfo, request_value->req_cond_results = results; } + /* Construct the info string if necessary */ + if (run_info_str) { + GPtrArray *parray; + int i, len; + field_info *finfo; + + parray = proto_get_finfo_ptr_array(ncp_tree, + *ncp_rec->req_info_str->hf_ptr); + len = g_ptr_array_len(parray); + if (len > 0) { + col_set_str(pinfo->cinfo, COL_INFO, "C "); + + finfo = g_ptr_array_index(parray, 0); + col_append_fstr(pinfo->cinfo, COL_INFO, + (gchar*) ncp_rec->req_info_str->first_string, + /* XXX - this only works for certain ftypes */ + fvalue_get(finfo->value)); + } + if (len > 1) { + for (i = 1; i < len; i++) { + finfo = g_ptr_array_index(parray, i); + col_append_fstr(pinfo->cinfo, COL_INFO, + (gchar*) ncp_rec->req_info_str->repeat_string, + /* XXX - this only works for certain ftypes */ + fvalue_get(finfo->value)); + } + } + } + + /* Free the temporary proto_tree */ CLEANUP_CALL_AND_POP; } |