diff options
author | Gilbert Ramirez <gram@alumni.rice.edu> | 2002-05-09 23:50:34 +0000 |
---|---|---|
committer | Gilbert Ramirez <gram@alumni.rice.edu> | 2002-05-09 23:50:34 +0000 |
commit | 41cc7f0707c5c62ae5651fcd70a9e9b12a4ce387 (patch) | |
tree | 46737517f86dbb9ec37210737dd521c9c3920608 /epan | |
parent | 9625720a39eddda6ef4c34725fe8017160cf05d9 (diff) | |
download | wireshark-41cc7f0707c5c62ae5651fcd70a9e9b12a4ce387.tar.gz wireshark-41cc7f0707c5c62ae5651fcd70a9e9b12a4ce387.tar.bz2 wireshark-41cc7f0707c5c62ae5651fcd70a9e9b12a4ce387.zip |
Merge the work in Novell_NCP_branch into the mainline code.
A little work still needs to be done on the new NCP dissector -- make
some of the COL_INFO texts more useful, handle a Unicode issue, and
modify some of the cases that use "request conditions".
But the NCP dissector as it stands is very usable now.
Note: I didn't merge in the PROTO_LENGTH_UNTIL_END macro... I wanted
to think about the various possible macros and review an email conversation
I had with Guy on the subject.
svn path=/trunk/; revision=5432
Diffstat (limited to 'epan')
-rw-r--r-- | epan/dfilter/dfilter.c | 13 | ||||
-rw-r--r-- | epan/dfilter/dfilter.h | 9 | ||||
-rw-r--r-- | epan/dfilter/dfvm.c | 5 | ||||
-rw-r--r-- | epan/dfilter/dfvm.h | 4 | ||||
-rw-r--r-- | epan/dfilter/semcheck.c | 7 | ||||
-rw-r--r-- | epan/epan.c | 14 | ||||
-rw-r--r-- | epan/ftypes/ftype-bytes.c | 52 | ||||
-rw-r--r-- | epan/ftypes/ftypes.h | 3 | ||||
-rw-r--r-- | epan/packet.c | 35 | ||||
-rw-r--r-- | epan/packet.h | 16 | ||||
-rw-r--r-- | epan/proto.c | 65 |
11 files changed, 159 insertions, 64 deletions
diff --git a/epan/dfilter/dfilter.c b/epan/dfilter/dfilter.c index 19af1c3179..e76029c225 100644 --- a/epan/dfilter/dfilter.c +++ b/epan/dfilter/dfilter.c @@ -1,5 +1,5 @@ /* - * $Id: dfilter.c,v 1.9 2002/04/29 07:55:32 guy Exp $ + * $Id: dfilter.c,v 1.10 2002/05/09 23:50:30 gram Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> @@ -284,26 +284,25 @@ FAILURE: gboolean -dfilter_apply(dfilter_t *df, tvbuff_t *tvb, proto_tree *tree) +dfilter_apply(dfilter_t *df, proto_tree *tree) { - return dfvm_apply(df, tvb, tree); + return dfvm_apply(df, tree); } gboolean dfilter_apply_edt(dfilter_t *df, epan_dissect_t* edt) { - return dfvm_apply(df, edt->tvb, edt->tree); + return dfvm_apply(df, edt->tree); } void -dfilter_foreach_interesting_field(dfilter_t *df, GFunc func, - gpointer user_data) +dfilter_prime_proto_tree(dfilter_t *df, proto_tree *tree) { int i; for (i = 0; i < df->num_interesting_fields; i++) { - func(GINT_TO_POINTER(df->interesting_fields[i]), user_data); + proto_tree_prime_hfid(tree, df->interesting_fields[i]); } } diff --git a/epan/dfilter/dfilter.h b/epan/dfilter/dfilter.h index aa6ef4321e..2956547d16 100644 --- a/epan/dfilter/dfilter.h +++ b/epan/dfilter/dfilter.h @@ -1,5 +1,5 @@ /* - * $Id: dfilter.h,v 1.4 2002/01/21 07:37:37 guy Exp $ + * $Id: dfilter.h,v 1.5 2002/05/09 23:50:30 gram Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> @@ -74,12 +74,11 @@ dfilter_apply_edt(dfilter_t *df, epan_dissect_t* edt); /* Apply compiled dfilter */ gboolean -dfilter_apply(dfilter_t *df, tvbuff_t *tvb, proto_tree *tree); +dfilter_apply(dfilter_t *df, proto_tree *tree); -/* Run a callback for each interesting field in the dfilter. */ +/* Prime a proto_tree using the fields/protocols used in a dfilter. */ void -dfilter_foreach_interesting_field(dfilter_t *df, GFunc func, - gpointer user_data); +dfilter_prime_proto_tree(dfilter_t *df, proto_tree *tree); /* Print bytecode of dfilter to stdout */ void diff --git a/epan/dfilter/dfvm.c b/epan/dfilter/dfvm.c index 24621c8730..bab20e3564 100644 --- a/epan/dfilter/dfvm.c +++ b/epan/dfilter/dfvm.c @@ -1,5 +1,5 @@ /* - * $Id: dfvm.c,v 1.6 2002/04/08 20:11:31 gram Exp $ + * $Id: dfvm.c,v 1.7 2002/05/09 23:50:30 gram Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@zing.org> @@ -300,7 +300,7 @@ mk_range(dfilter_t *df, int from_reg, int to_reg, drange *drange) gboolean -dfvm_apply(dfilter_t *df, tvbuff_t *tvb, proto_tree *tree) +dfvm_apply(dfilter_t *df, proto_tree *tree) { int i, id, length; gboolean accum = TRUE; @@ -309,7 +309,6 @@ dfvm_apply(dfilter_t *df, tvbuff_t *tvb, proto_tree *tree) dfvm_value_t *arg2; dfvm_value_t *arg3; - g_assert(tvb); g_assert(tree); diff --git a/epan/dfilter/dfvm.h b/epan/dfilter/dfvm.h index 414f486ddf..53dd9b46d6 100644 --- a/epan/dfilter/dfvm.h +++ b/epan/dfilter/dfvm.h @@ -1,5 +1,5 @@ /* - * $Id: dfvm.h,v 1.5 2002/04/08 20:11:31 gram Exp $ + * $Id: dfvm.h,v 1.6 2002/05/09 23:50:30 gram Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> @@ -93,7 +93,7 @@ void dfvm_dump(FILE *f, GPtrArray *insns); gboolean -dfvm_apply(dfilter_t *df, tvbuff_t *tvb, proto_tree *tree); +dfvm_apply(dfilter_t *df, proto_tree *tree); #endif diff --git a/epan/dfilter/semcheck.c b/epan/dfilter/semcheck.c index de1b030491..87c3a41158 100644 --- a/epan/dfilter/semcheck.c +++ b/epan/dfilter/semcheck.c @@ -1,5 +1,5 @@ /* - * $Id: semcheck.c,v 1.10 2002/03/02 20:48:11 guy Exp $ + * $Id: semcheck.c,v 1.11 2002/05/09 23:50:30 gram Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> @@ -59,7 +59,8 @@ compatible_ftypes(ftenum_t a, ftenum_t b) case FT_ETHER: case FT_BYTES: - return (b == FT_ETHER || b == FT_BYTES); + case FT_UINT_BYTES: + return (b == FT_ETHER || b == FT_BYTES || b == FT_UINT_BYTES); case FT_BOOLEAN: case FT_UINT8: @@ -140,6 +141,7 @@ mk_fvalue_from_val_string(header_field_info *hfinfo, char *s) case FT_IPXNET: case FT_ETHER: case FT_BYTES: + case FT_UINT_BYTES: case FT_STRING: case FT_STRINGZ: case FT_UINT_STRING: @@ -212,6 +214,7 @@ is_bytes_type(enum ftenum type) switch(type) { case FT_ETHER: case FT_BYTES: + case FT_UINT_BYTES: case FT_IPv6: return TRUE; diff --git a/epan/epan.c b/epan/epan.c index d503078dd3..5de00d7cfc 100644 --- a/epan/epan.c +++ b/epan/epan.c @@ -1,6 +1,6 @@ /* epan.h * - * $Id: epan.c,v 1.17 2002/02/18 01:08:41 guy Exp $ + * $Id: epan.c,v 1.18 2002/05/09 23:50:28 gram Exp $ * * Ethereal Protocol Analyzer Library * @@ -50,6 +50,7 @@ epan_init(const char *plugin_dir, void (register_all_protocols)(void), proto_init(plugin_dir,register_all_protocols,register_all_handoffs); packet_init(); dfilter_init(); + final_registration_all_protocols(); } void @@ -116,19 +117,10 @@ epan_dissect_free(epan_dissect_t* edt) g_free(edt); } -static void -prime_dfilter(gpointer data, gpointer user_data) -{ - int hfid = GPOINTER_TO_INT(data); - proto_tree *tree = user_data; - - proto_tree_prime_hfid(tree, hfid); -} - void epan_dissect_prime_dfilter(epan_dissect_t *edt, dfilter_t* dfcode) { - dfilter_foreach_interesting_field(dfcode, prime_dfilter, edt->tree); + dfilter_prime_proto_tree(dfcode, edt->tree); } void diff --git a/epan/ftypes/ftype-bytes.c b/epan/ftypes/ftype-bytes.c index 4a6e59db9d..0a2c4b3432 100644 --- a/epan/ftypes/ftype-bytes.c +++ b/epan/ftypes/ftype-bytes.c @@ -1,5 +1,5 @@ /* - * $Id: ftype-bytes.c,v 1.10 2002/02/05 22:50:17 guy Exp $ + * $Id: ftype-bytes.c,v 1.11 2002/05/09 23:50:32 gram Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> @@ -551,19 +551,46 @@ ftype_register_bytes(void) { static ftype_t bytes_type = { - "FT_BYTES", - "sequence of bytes", - 0, - bytes_fvalue_new, - bytes_fvalue_free, - val_from_string, - - bytes_fvalue_set, - NULL, + "FT_BYTES", /* name */ + "sequence of bytes", /* pretty_name */ + 0, /* wire_size */ + bytes_fvalue_new, /* new_value */ + bytes_fvalue_free, /* free_value */ + val_from_string, /* val_from_string */ + + bytes_fvalue_set, /* set_value */ + NULL, /* set_value_integer */ + NULL, /* set_value_floating */ + + value_get, /* get_value */ + NULL, /* get_value_integer */ NULL, - value_get, - NULL, + cmp_eq, + cmp_ne, + cmp_gt, + cmp_ge, + cmp_lt, + cmp_le, + + len, + slice, + }; + + static ftype_t uint_bytes_type = { + "FT_UINT_BYTES", /* name */ + "sequence of bytes", /* pretty_name */ + 0, /* wire_size */ + bytes_fvalue_new, /* new_value */ + bytes_fvalue_free, /* free_value */ + val_from_string, /* val_from_string */ + + bytes_fvalue_set, /* set_value */ + NULL, /* set_value_integer */ + NULL, /* set_value_floating */ + + value_get, /* get_value */ + NULL, /* get_value_integer */ NULL, cmp_eq, @@ -686,6 +713,7 @@ ftype_register_bytes(void) }; ftype_register(FT_BYTES, &bytes_type); + ftype_register(FT_UINT_BYTES, &bytes_type); ftype_register(FT_ETHER, ðer_type); ftype_register(FT_IPv6, &ipv6_type); ftype_register(FT_UINT64, &u64_type); diff --git a/epan/ftypes/ftypes.h b/epan/ftypes/ftypes.h index 820a9d5139..82f13471ea 100644 --- a/epan/ftypes/ftypes.h +++ b/epan/ftypes/ftypes.h @@ -1,7 +1,7 @@ /* ftypes.h * Definitions for field types * - * $Id: ftypes.h,v 1.9 2002/02/15 09:01:21 gram Exp $ + * $Id: ftypes.h,v 1.10 2002/05/09 23:50:32 gram Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> @@ -53,6 +53,7 @@ enum ftenum { /*FT_UCS2_LE, */ /* Unicode, 2 byte, Little Endian */ FT_ETHER, FT_BYTES, + FT_UINT_BYTES, FT_IPv4, FT_IPv6, FT_IPXNET, diff --git a/epan/packet.c b/epan/packet.c index 769c0df11d..d7a7fe2507 100644 --- a/epan/packet.c +++ b/epan/packet.c @@ -1,7 +1,7 @@ /* packet.c * Routines for packet disassembly * - * $Id: packet.c,v 1.68 2002/04/28 00:13:05 guy Exp $ + * $Id: packet.c,v 1.69 2002/05/09 23:50:28 gram Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> @@ -237,6 +237,39 @@ free_data_sources(frame_data *fd) fd->data_src = NULL; } +/* Allow dissectors to register a "final_registration" routine + * that is run like the proto_register_XXX() routine, but the end + * end of the epan_init() function; that is, *after* all other + * subsystems, liked dfilters, have finished initializing. This is + * useful for dissector registration routines which need to compile + * display filters. dfilters can't initialize itself until all protocols + * have registereed themselvs. */ +static GSList *final_registration_routines; + +void +register_final_registration_routine(void (*func)(void)) +{ + final_registration_routines = g_slist_append(final_registration_routines, + func); +} + +/* Call all the registered "final_registration" routines. */ +static void +call_final_registration_routine(gpointer routine, gpointer dummy) +{ + void (*func)(void) = routine; + + (*func)(); +} + +void +final_registration_all_protocols(void) +{ + g_slist_foreach(final_registration_routines, + &call_final_registration_routine, NULL); +} + + /* Creates the top-most tvbuff and calls dissect_frame() */ void dissect_packet(epan_dissect_t *edt, union wtap_pseudo_header *pseudo_header, diff --git a/epan/packet.h b/epan/packet.h index 24e0cb29f4..1b4900bfdc 100644 --- a/epan/packet.h +++ b/epan/packet.h @@ -1,7 +1,7 @@ /* packet.h * Definitions for packet disassembly structures and routines * - * $Id: packet.h,v 1.55 2002/04/28 00:13:05 guy Exp $ + * $Id: packet.h,v 1.56 2002/05/09 23:50:28 gram Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> @@ -248,6 +248,20 @@ extern void register_postseq_cleanup_routine(void (*func)(void)); /* Call all the registered "postseq_cleanup" routines. */ extern void postseq_cleanup_all_protocols(void); +/* Allow dissectors to register a "final_registration" routine + * that is run like the proto_register_XXX() routine, but the end + * end of the epan_init() function; that is, *after* all other + * subsystems, liked dfilters, have finished initializing. This is + * useful for dissector registration routines which need to compile + * display filters. dfilters can't initialize itself until all protocols + * have registereed themselvs. */ +void +register_final_registration_routine(void (*func)(void)); + +/* Call all the registered "final_registration" routines. */ +void +final_registration_all_protocols(void); + /* * Add a new data source to the list of data sources for a frame, given * the tvbuff for the data source and its name. diff --git a/epan/proto.c b/epan/proto.c index 131e74d0b7..f5b00a3422 100644 --- a/epan/proto.c +++ b/epan/proto.c @@ -1,7 +1,7 @@ /* proto.c * Routines for protocol tree * - * $Id: proto.c,v 1.67 2002/04/29 07:55:31 guy Exp $ + * $Id: proto.c,v 1.68 2002/05/09 23:50:28 gram Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> @@ -633,6 +633,15 @@ proto_tree_add_item(proto_tree *tree, int hfindex, tvbuff_t *tvb, proto_tree_set_bytes_tvb(new_fi, tvb, start, length); break; + case FT_UINT_BYTES: + n = get_uint_value(tvb, start, length, little_endian); + proto_tree_set_bytes_tvb(new_fi, tvb, start + length, n); + + /* Instead of calling proto_item_set_len(), since we don't yet + * have a proto_item, we set the field_info's length ourselves. */ + new_fi->length = n + length; + break; + case FT_BOOLEAN: proto_tree_set_boolean(new_fi, get_uint_value(tvb, start, length, little_endian)); @@ -690,19 +699,30 @@ proto_tree_add_item(proto_tree *tree, int hfindex, tvbuff_t *tvb, break; case FT_STRINGZ: - /* In this case, length signifies maximum length. */ + if (length == -1) { + /* This can throw an exception */ + length = tvb_strsize(tvb, start); - /* This g_strdup'ed memory is freed in proto_tree_free_node() */ - string = g_malloc(length); + /* This g_strdup'ed memory is freed in proto_tree_free_node() */ + string = g_malloc(length); + + tvb_memcpy(tvb, string, start, length); + new_fi->length = length; + } + else { + /* In this case, length signifies maximum length. */ - CLEANUP_PUSH(g_free, string); + /* This g_strdup'ed memory is freed in proto_tree_free_node() */ + string = g_malloc(length); - found_length = tvb_get_nstringz0(tvb, start, length, string); + CLEANUP_PUSH(g_free, string); - CLEANUP_POP; + found_length = tvb_get_nstringz0(tvb, start, length, string); + CLEANUP_POP; + new_fi->length = found_length + 1; + } proto_tree_set_string(new_fi, string, TRUE); - new_fi->length = found_length + 1; break; @@ -1749,7 +1769,8 @@ alloc_field_info(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start, g_assert(hfinfo->type == FT_PROTOCOL || hfinfo->type == FT_NONE || hfinfo->type == FT_BYTES || - hfinfo->type == FT_STRING); + hfinfo->type == FT_STRING || + hfinfo->type == FT_STRINGZ); *length = tvb_ensure_length_remaining(tvb, start); } @@ -1885,13 +1906,17 @@ proto_tree_create_root(void) return (proto_tree*) g_node_new(pnode); } + +/* "prime" a proto_tree with a single hfid that a dfilter + * is interested in. */ void -proto_tree_prime_hfid(proto_tree *tree, int hfid) +proto_tree_prime_hfid(proto_tree *tree, gint hfid) { g_hash_table_insert(PTREE_DATA(tree)->interesting_hfids, - GINT_TO_POINTER(hfid), g_ptr_array_new()); + GINT_TO_POINTER(hfid), g_ptr_array_new()); } + proto_tree* proto_item_add_subtree(proto_item *pi, gint idx) { field_info *fi; @@ -2214,11 +2239,12 @@ proto_item_fill_label(field_info *fi, gchar *label_str) break; case FT_BYTES: + case FT_UINT_BYTES: bytes = fvalue_get(fi->value); if (bytes) { snprintf(label_str, ITEM_LABEL_LENGTH, "%s: %s", hfinfo->name, - bytes_to_str(bytes, fi->length)); + bytes_to_str(bytes, fvalue_length(fi->value))); } else { snprintf(label_str, ITEM_LABEL_LENGTH, @@ -3093,7 +3119,10 @@ proto_can_match_selected(field_info *finfo) case FT_ABSOLUTE_TIME: case FT_RELATIVE_TIME: case FT_STRING: + case FT_STRINGZ: + case FT_UINT_STRING: case FT_BYTES: + case FT_UINT_BYTES: /* * These all have values, so we can match. */ @@ -3218,11 +3247,6 @@ proto_alloc_dfilter_string(field_info *finfo, guint8 *pd) hfinfo->abbrev, value_str); break; -#if 0 - case FT_TEXT_ONLY: - ; /* nothing */ - break; -#endif case FT_STRING: value_str = fvalue_get(finfo->value); @@ -3233,12 +3257,15 @@ proto_alloc_dfilter_string(field_info *finfo, guint8 *pd) break; case FT_BYTES: - dfilter_len = finfo->length*3 - 1; + case FT_UINT_BYTES: + dfilter_len = fvalue_length(finfo->value)*3 - 1; dfilter_len += abbrev_len + 7; buf = g_malloc0(dfilter_len); snprintf(buf, dfilter_len, "%s == %s", hfinfo->abbrev, - bytes_to_str_punct(fvalue_get(finfo->value), finfo->length,':')); + /* XXX - bytes_to_str_punct() will truncate long strings with '...' */ + bytes_to_str_punct(fvalue_get(finfo->value), + fvalue_length(finfo->value),':')); break; default: |