* Craig Newell <CraigN@cheque.uq.edu.au>
* RFC2347 TFTP Option Extension
*
- * $Id: packet-tftp.c,v 1.29 2001/11/03 02:19:10 guy Exp $
+ * $Id: packet-tftp.c,v 1.33 2001/12/03 03:59:40 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
static gint ett_tftp = -1;
+static dissector_handle_t tftp_handle;
+
#define UDP_PORT_TFTP 69
#define TFTP_RRQ 1
gint offset = 0;
guint16 opcode;
u_int i1;
-
- CHECK_DISPLAY_AS_DATA(proto_tftp, tvb, pinfo, tree);
-
- pinfo->current_proto = "TFTP";
+ guint16 error;
/*
* The first TFTP packet goes to the TFTP port; the second one
if (conversation == NULL) {
conversation = conversation_new(&pinfo->src, &pinfo->dst, PT_UDP,
pinfo->srcport, 0, NO_PORT2);
- conversation_set_dissector(conversation, dissect_tftp);
+ conversation_set_dissector(conversation, tftp_handle);
}
}
break;
case TFTP_ERROR:
+ error = tvb_get_ntohs(tvb, offset);
if (tree) {
- proto_tree_add_item(tftp_tree, hf_tftp_error_code, tvb, offset, 2,
- FALSE);
+ proto_tree_add_uint(tftp_tree, hf_tftp_error_code, tvb, offset, 2,
+ error);
}
if (check_col(pinfo->fd, COL_INFO)) {
- col_append_fstr(pinfo->fd, COL_INFO, ", Code: %i",
- tvb_get_ntohs(tvb, offset));
+ col_append_fstr(pinfo->fd, COL_INFO, ", Code: %s",
+ val_to_str(error, tftp_error_code_vals, "Unknown (%u)"));
}
offset += 2;
+ i1 = tvb_strsize(tvb, offset);
if (tree) {
- i1 = tvb_strsize(tvb, offset);
proto_tree_add_item(tftp_tree, hf_tftp_error_string, tvb, offset,
i1, FALSE);
}
+ if (check_col(pinfo->fd, COL_INFO)) {
+ col_append_fstr(pinfo->fd, COL_INFO, ", Message: %s",
+ tvb_get_ptr(tvb, offset, i1));
+ }
break;
case TFTP_OACK:
"TFTP", "tftp");
proto_register_field_array(proto_tftp, hf, array_length(hf));
proto_register_subtree_array(ett, array_length(ett));
+
+ tftp_handle = create_dissector_handle(dissect_tftp, proto_tftp);
}
void
proto_reg_handoff_tftp(void)
{
- dissector_add("udp.port", UDP_PORT_TFTP, dissect_tftp, proto_tftp);
+ dissector_add("udp.port", UDP_PORT_TFTP, tftp_handle);
}