Add a field called "frame.protocols" which shows the protocols present

in the frame.   The filter "frame.protocols contains ip:icmp:ip" could
be used to find any ICMP packets containing IP headers.

Clean up whitespace.

svn path=/trunk/; revision=13118
This commit is contained in:
Gerald Combs 2005-01-19 04:49:29 +00:00
parent 5b84b7e764
commit 561fbc8b25
3 changed files with 37 additions and 11 deletions

View File

@ -46,6 +46,7 @@ static int hf_frame_p2p_dir = -1;
static int hf_frame_file_off = -1;
static int hf_frame_marked = -1;
static int hf_frame_ref_time = -1;
static int hf_frame_protocols = -1;
static int proto_short = -1;
int proto_malformed = -1;
@ -166,6 +167,10 @@ dissect_frame(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
0, 0, cap_len, "Capture Length: %d byte%s", cap_len,
plurality(cap_len, "", "s"));
ti = proto_tree_add_string(fh_tree, hf_frame_protocols, tvb,
0, 0, "");
pinfo->layer_names = g_string_new("");
/* Check for existences of P2P pseudo header */
if (pinfo->p2p_dir != P2P_DIR_UNKNOWN) {
proto_tree_add_uint(fh_tree, hf_frame_p2p_dir, tvb,
@ -180,7 +185,6 @@ dissect_frame(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
}
}
TRY {
if (!dissector_try_port(wtap_encap_dissector_table, pinfo->fd->lnk_t,
tvb, pinfo, tree)) {
@ -198,8 +202,14 @@ dissect_frame(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
}
ENDTRY;
if (tree) {
proto_item_append_string(ti, pinfo->layer_names->str);
g_string_free(pinfo->layer_names, TRUE);
pinfo->layer_names = NULL;
}
tap_queue_packet(frame_tap, pinfo, NULL);
if (mate_handle) call_dissector(mate_handle,tvb, pinfo, tree);
}
@ -313,6 +323,10 @@ proto_register_frame(void)
{ &hf_frame_ref_time,
{ "This is a Ref Time frame", "frame.ref_time", FT_NONE, 0, NULL, 0x0,
"This frame is a Reference Time frame", HFILL }},
{ &hf_frame_protocols,
{ "Protocols in frame", "frame.protocols", FT_STRING, 0, NULL, 0x0,
"Protocols carried by this frame", HFILL }},
};
static gint *ett[] = {
&ett_frame,

View File

@ -299,6 +299,7 @@ dissect_packet(epan_dissect_t *edt, union wtap_pseudo_header *pseudo_header,
edt->pi.vsan = 0;
edt->pi.dcectxid = 0;
edt->pi.dcetransporttype = -1;
edt->pi.layer_names = NULL;
TRY {
edt->tvb = tvb_new_real_data(pd, fd->cap_len, fd->pkt_len);
@ -431,6 +432,16 @@ call_dissector_work(dissector_handle_t handle, tvbuff_t *tvb,
if (handle->protocol != NULL) {
pinfo->current_proto =
proto_get_protocol_short_name(handle->protocol);
/*
* Add the protocol name to the layers
*/
if (pinfo->layer_names) {
if (pinfo->layer_names->len > 0)
g_string_append(pinfo->layer_names, ":");
g_string_append(pinfo->layer_names,
proto_get_protocol_filter_name(proto_get_id(handle->protocol)));
}
}
if (pinfo->in_error_pkt) {
@ -575,7 +586,7 @@ find_dissector_table(const char *name)
return g_hash_table_lookup( dissector_tables, name );
}
/* Find an entry in a uint dissector table. */
/* Find an entry in a uint dissector table. */
static dtbl_entry_t *
find_uint_dtbl_entry(dissector_table_t sub_dissectors, guint32 pattern)
{
@ -821,7 +832,7 @@ dissector_get_port_handle(dissector_table_t sub_dissectors, guint32 port)
return NULL;
}
/* Find an entry in a string dissector table. */
/* Find an entry in a string dissector table. */
static dtbl_entry_t *
find_string_dtbl_entry(dissector_table_t sub_dissectors, const gchar *pattern)
{

View File

@ -85,13 +85,13 @@ typedef struct _packet_info {
guint16 want_pdu_tracking; /* >0 if the subdissector has specified
a value in 'bytes_until_next_pdu'.
When a dissector detects that the next PDU
will start beyond the start of the next
segment, it can set this value to 2
and 'bytes_until_next_pdu' to the number of
bytes beyond the next segment where the
will start beyond the start of the next
segment, it can set this value to 2
and 'bytes_until_next_pdu' to the number of
bytes beyond the next segment where the
next PDU starts.
If the protocol dissector below this
If the protocol dissector below this
one is capable of PDU tracking it can
use this hint to detect PDUs that starts
unaligned to the segment boundaries.
@ -99,7 +99,7 @@ typedef struct _packet_info {
(some) protocols to detect when a new PDU
starts in the middle of a tcp segment.
There is intelligence in the glue between
There is intelligence in the glue between
dissector layers to make sure that this
request is only passed down to the protocol
immediately below the current one and not
@ -107,7 +107,7 @@ typedef struct _packet_info {
*/
guint32 bytes_until_next_pdu;
int iplen;
int iphdrlen;
int p2p_dir;
@ -131,6 +131,7 @@ typedef struct _packet_info {
* in the SCTP packet
*/
void *private_data; /* pointer to data passed from one dissector to another */
GString *layer_names; /* layers of each protocol */
} packet_info;
#endif /* __PACKET_INFO_H__ */