aboutsummaryrefslogtreecommitdiffstats
path: root/epan/dissectors/packet-ixiatrailer.c
diff options
context:
space:
mode:
authorBill Meier <wmeier@newsguy.com>2014-09-28 19:25:09 -0400
committerBill Meier <wmeier@newsguy.com>2014-09-29 13:47:02 +0000
commit10406870f5c39617f57cc0a77f55100404505c17 (patch)
treeea566d2ff47afa6b53ccbb2709be65847e17b0e1 /epan/dissectors/packet-ixiatrailer.c
parent768e36fc4fae55932bcddb0b5435c81da475b01d (diff)
Add editor modelines; fix indentation as needed.
Change-Id: I1ad94654343e5a018a0b3159481d45ffb3a91263 Reviewed-on: https://code.wireshark.org/review/4363 Reviewed-by: Bill Meier <wmeier@newsguy.com>
Diffstat (limited to 'epan/dissectors/packet-ixiatrailer.c')
-rw-r--r--epan/dissectors/packet-ixiatrailer.c175
1 files changed, 94 insertions, 81 deletions
diff --git a/epan/dissectors/packet-ixiatrailer.c b/epan/dissectors/packet-ixiatrailer.c
index 07e843b217..3e98835ecf 100644
--- a/epan/dissectors/packet-ixiatrailer.c
+++ b/epan/dissectors/packet-ixiatrailer.c
@@ -75,87 +75,87 @@ static expert_field ei_ixiatrailer_field_length_invalid = EI_INIT;
static int
dissect_ixiatrailer(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, void *data _U_)
{
- proto_tree *ti;
- guint tvblen, trailer_length, time_length;
- proto_tree *ixiatrailer_tree = NULL;
- guint offset = 0;
- guint16 cksum, comp_cksum;
- vec_t vec;
- guint8 source;
-
- /* Need at least 5 bytes. TODO: should be 15? */
- tvblen = tvb_length(tvb);
- if (tvblen < 5) {
- return 0;
- }
-
- /* Depending upon the ethernet preference "Assume packets have FCS", we
- may be given those 4 bytes too. If we see 19 bytes, assume we are
- getting them and only look at first 15. */
- if (tvblen == 19) {
- tvblen = 15;
- }
-
- /* 3rd & 4th bytes from the end must match our pattern */
- if (tvb_get_ntohs(tvb, tvblen-4) != IXIA_PATTERN) {
- return 0;
- }
-
- /* Read Trailer-length field */
- trailer_length = tvb_get_guint8(tvb, tvblen-5);
- /* Should match overall length of trailer */
- if ((tvblen-5) != trailer_length) {
- return 0;
- }
-
- /* Last 2 bytes are the checksum */
- cksum = tvb_get_ntohs(tvb, tvblen-2);
-
- /* Verify the checksum; if not valid, it means that the trailer is not valid */
- SET_CKSUM_VEC_TVB(vec, tvb, offset, trailer_length + 3);
- comp_cksum = in_cksum(&vec, 1);
- if (pntoh16(&comp_cksum) != cksum) {
- return 0;
- }
-
- /* OK: We have our trailer - create protocol root */
- ti = proto_tree_add_item(tree, proto_ixiatrailer, tvb, offset, trailer_length + 5, ENC_NA);
-
- /* Append summary to item, if configured to */
- if (ixiatrailer_summary_in_tree) {
- proto_item_append_text(ti, ", Length: %u, Checksum: 0x%x", trailer_length, cksum);
- }
-
- /* Create subtree */
- ixiatrailer_tree = proto_item_add_subtree(ti, ett_ixiatrailer);
-
- source = tvb_get_guint8(tvb, offset++);
- time_length = tvb_get_guint8(tvb, offset++);
-
- switch (source) {
- case IXIATRAILER_FTYPE_TIMESTAMP_LOCAL:
- case IXIATRAILER_FTYPE_TIMESTAMP_NTP:
- case IXIATRAILER_FTYPE_TIMESTAMP_GPS:
- case IXIATRAILER_FTYPE_TIMESTAMP_1588:
- case IXIATRAILER_FTYPE_TIMESTAMP_HOLDOVER:
- if (time_length != 8) {
- expert_add_info_format(pinfo, ti, &ei_ixiatrailer_field_length_invalid, "Field length %u invalid", time_length);
- break;
- }
- /* Timestamp */
- ti = proto_tree_add_item(ixiatrailer_tree, hf_ixiatrailer_timestamp, tvb, offset, time_length, ENC_TIME_TIMESPEC|ENC_BIG_ENDIAN);
- proto_item_append_text(ti, "; Source: %s", val_to_str_const(source, ixiatrailer_ftype_timestamp, "Unknown"));
- break;
-
- default:
- /* Not a recognised time format - just show as bytes */
- ti = proto_tree_add_item(ixiatrailer_tree, hf_ixiatrailer_generic, tvb, offset, time_length, ENC_NA);
- proto_item_append_text(ti, " [Id: %u, Length: %u]", source, time_length);
- break;
- }
-
- /* We are claiming all of the bytes */
- return tvblen;
+ proto_tree *ti;
+ guint tvblen, trailer_length, time_length;
+ proto_tree *ixiatrailer_tree = NULL;
+ guint offset = 0;
+ guint16 cksum, comp_cksum;
+ vec_t vec;
+ guint8 source;
+
+ /* Need at least 5 bytes. TODO: should be 15? */
+ tvblen = tvb_length(tvb);
+ if (tvblen < 5) {
+ return 0;
+ }
+
+ /* Depending upon the ethernet preference "Assume packets have FCS", we
+ may be given those 4 bytes too. If we see 19 bytes, assume we are
+ getting them and only look at first 15. */
+ if (tvblen == 19) {
+ tvblen = 15;
+ }
+
+ /* 3rd & 4th bytes from the end must match our pattern */
+ if (tvb_get_ntohs(tvb, tvblen-4) != IXIA_PATTERN) {
+ return 0;
+ }
+
+ /* Read Trailer-length field */
+ trailer_length = tvb_get_guint8(tvb, tvblen-5);
+ /* Should match overall length of trailer */
+ if ((tvblen-5) != trailer_length) {
+ return 0;
+ }
+
+ /* Last 2 bytes are the checksum */
+ cksum = tvb_get_ntohs(tvb, tvblen-2);
+
+ /* Verify the checksum; if not valid, it means that the trailer is not valid */
+ SET_CKSUM_VEC_TVB(vec, tvb, offset, trailer_length + 3);
+ comp_cksum = in_cksum(&vec, 1);
+ if (pntoh16(&comp_cksum) != cksum) {
+ return 0;
+ }
+
+ /* OK: We have our trailer - create protocol root */
+ ti = proto_tree_add_item(tree, proto_ixiatrailer, tvb, offset, trailer_length + 5, ENC_NA);
+
+ /* Append summary to item, if configured to */
+ if (ixiatrailer_summary_in_tree) {
+ proto_item_append_text(ti, ", Length: %u, Checksum: 0x%x", trailer_length, cksum);
+ }
+
+ /* Create subtree */
+ ixiatrailer_tree = proto_item_add_subtree(ti, ett_ixiatrailer);
+
+ source = tvb_get_guint8(tvb, offset++);
+ time_length = tvb_get_guint8(tvb, offset++);
+
+ switch (source) {
+ case IXIATRAILER_FTYPE_TIMESTAMP_LOCAL:
+ case IXIATRAILER_FTYPE_TIMESTAMP_NTP:
+ case IXIATRAILER_FTYPE_TIMESTAMP_GPS:
+ case IXIATRAILER_FTYPE_TIMESTAMP_1588:
+ case IXIATRAILER_FTYPE_TIMESTAMP_HOLDOVER:
+ if (time_length != 8) {
+ expert_add_info_format(pinfo, ti, &ei_ixiatrailer_field_length_invalid, "Field length %u invalid", time_length);
+ break;
+ }
+ /* Timestamp */
+ ti = proto_tree_add_item(ixiatrailer_tree, hf_ixiatrailer_timestamp, tvb, offset, time_length, ENC_TIME_TIMESPEC|ENC_BIG_ENDIAN);
+ proto_item_append_text(ti, "; Source: %s", val_to_str_const(source, ixiatrailer_ftype_timestamp, "Unknown"));
+ break;
+
+ default:
+ /* Not a recognised time format - just show as bytes */
+ ti = proto_tree_add_item(ixiatrailer_tree, hf_ixiatrailer_generic, tvb, offset, time_length, ENC_NA);
+ proto_item_append_text(ti, " [Id: %u, Length: %u]", source, time_length);
+ break;
+ }
+
+ /* We are claiming all of the bytes */
+ return tvblen;
}
void
@@ -202,3 +202,16 @@ proto_reg_handoff_ixiatrailer(void)
/* Check for Ixia format in the ethernet trailer */
heur_dissector_add("eth.trailer", dissect_ixiatrailer, proto_ixiatrailer);
}
+
+/*
+ * Editor modelines - http://www.wireshark.org/tools/modelines.html
+ *
+ * Local Variables:
+ * c-basic-offset: 2
+ * tab-width: 8
+ * indent-tabs-mode: nil
+ * End:
+ *
+ * ex: set shiftwidth=2 tabstop=8 expandtab:
+ * :indentSize=2:tabSize=8:noTabs=true:
+ */