aboutsummaryrefslogtreecommitdiffstats
path: root/epan/dissectors/packet-tftp.c
diff options
context:
space:
mode:
authorStephen Fisher <steve@stephen-fisher.com>2009-03-27 19:45:46 +0000
committerStephen Fisher <steve@stephen-fisher.com>2009-03-27 19:45:46 +0000
commit956c2e2dc67df7c620e5c1d1068d612c47d993b8 (patch)
treedac9d0dad1ae0ada53cd952edae8d902a1b03abc /epan/dissectors/packet-tftp.c
parentd3be9b80a90d43dc0491af3a210be397932ed525 (diff)
Add request/response like tracking to the TFTP dissector. In this case, it
is used to show the source or destination filename being trasnferred on every packet of that transfer as a generated item. svn path=/trunk/; revision=27870
Diffstat (limited to 'epan/dissectors/packet-tftp.c')
-rw-r--r--epan/dissectors/packet-tftp.c31
1 files changed, 28 insertions, 3 deletions
diff --git a/epan/dissectors/packet-tftp.c b/epan/dissectors/packet-tftp.c
index 80aeeda4b0..0ba9495c36 100644
--- a/epan/dissectors/packet-tftp.c
+++ b/epan/dissectors/packet-tftp.c
@@ -54,6 +54,7 @@
/* Things we may want to remember for a whole conversation */
typedef struct _tftp_conv_info_t {
guint16 blocksize;
+ gchar *source_file, *destination_file;
} tftp_conv_info_t;
@@ -185,6 +186,18 @@ static void dissect_tftp_message(tftp_conv_info_t *tftp_info,
ti = proto_tree_add_item(tree, proto_tftp, tvb, offset, -1, FALSE);
tftp_tree = proto_item_add_subtree(ti, ett_tftp);
+ if(tftp_info->source_file) {
+ ti = proto_tree_add_string(tftp_tree, hf_tftp_source_file, tvb,
+ 0, 0, tftp_info->source_file);
+ PROTO_ITEM_SET_GENERATED(ti);
+ }
+
+ if(tftp_info->destination_file) {
+ ti = proto_tree_add_string(tftp_tree, hf_tftp_destination_file, tvb,
+ 0, 0, tftp_info->destination_file);
+ PROTO_ITEM_SET_GENERATED(ti);
+ }
+
proto_tree_add_uint(tftp_tree, hf_tftp_opcode, tvb,
offset, 2, opcode);
}
@@ -198,6 +211,9 @@ static void dissect_tftp_message(tftp_conv_info_t *tftp_info,
proto_tree_add_item(tftp_tree, hf_tftp_source_file,
tvb, offset, i1, FALSE);
}
+
+ tftp_info->source_file = tvb_get_seasonal_string(tvb, offset, i1);
+
if (check_col(pinfo->cinfo, COL_INFO)) {
col_append_fstr(pinfo->cinfo, COL_INFO, ", File: %s",
tvb_format_text(tvb, offset, i1));
@@ -226,6 +242,10 @@ static void dissect_tftp_message(tftp_conv_info_t *tftp_info,
proto_tree_add_item(tftp_tree, hf_tftp_destination_file,
tvb, offset, i1, FALSE);
}
+
+ tftp_info->destination_file =
+ tvb_get_seasonal_string(tvb, offset, i1);
+
if (check_col(pinfo->cinfo, COL_INFO)) {
col_append_fstr(pinfo->cinfo, COL_INFO, ", File: %s",
tvb_format_text(tvb, offset, i1));
@@ -237,6 +257,7 @@ static void dissect_tftp_message(tftp_conv_info_t *tftp_info,
ti = proto_tree_add_item(tftp_tree, hf_tftp_transfer_type,
tvb, offset, i1, FALSE);
}
+
if (check_col(pinfo->cinfo, COL_INFO)) {
col_append_fstr(pinfo->cinfo, COL_INFO, ", Transfer type: %s",
tvb_format_text(tvb, offset, i1));
@@ -354,6 +375,8 @@ dissect_embeddedtftp_heur(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
if (!tftp_info) {
tftp_info = se_alloc(sizeof(tftp_conv_info_t));
tftp_info->blocksize = 512; /* TFTP default block size */
+ tftp_info->source_file = NULL;
+ tftp_info->destination_file = NULL;
conversation_add_proto_data(conversation, proto_tftp, tftp_info);
}
@@ -417,9 +440,11 @@ dissect_tftp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
}
tftp_info = conversation_get_proto_data(conversation, proto_tftp);
if (!tftp_info) {
- tftp_info = se_alloc(sizeof(tftp_conv_info_t));
- tftp_info->blocksize = 512; /* TFTP default block size */
- conversation_add_proto_data(conversation, proto_tftp, tftp_info);
+ tftp_info = se_alloc(sizeof(tftp_conv_info_t));
+ tftp_info->blocksize = 512; /* TFTP default block size */
+ tftp_info->source_file = NULL;
+ tftp_info->destination_file = NULL;
+ conversation_add_proto_data(conversation, proto_tftp, tftp_info);
}