aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--colorfilters2
-rw-r--r--debian/libwireshark0.symbols1
-rw-r--r--doc/README.dissector3
-rw-r--r--docbook/release-notes.asciidoc7
-rw-r--r--epan/dissectors/asn1/c1222/packet-c1222-template.c24
-rw-r--r--epan/dissectors/packet-6lowpan.c3
-rw-r--r--epan/dissectors/packet-aol.c2
-rw-r--r--epan/dissectors/packet-artnet.c3
-rw-r--r--epan/dissectors/packet-asap.c5
-rw-r--r--epan/dissectors/packet-atalk.c102
-rw-r--r--epan/dissectors/packet-ax25-kiss.c12
-rw-r--r--epan/dissectors/packet-bitcoin.c2
-rw-r--r--epan/dissectors/packet-btatt.c2
-rw-r--r--epan/dissectors/packet-c1222.c28
-rw-r--r--epan/dissectors/packet-carp.c14
-rw-r--r--epan/dissectors/packet-cattp.c29
-rw-r--r--epan/dissectors/packet-cdp.c70
-rw-r--r--epan/dissectors/packet-cfdp.c2
-rw-r--r--epan/dissectors/packet-clnp.c48
-rw-r--r--epan/dissectors/packet-dccp.c36
-rw-r--r--epan/dissectors/packet-dec-dnart.c20
-rw-r--r--epan/dissectors/packet-dji-uav.c3
-rw-r--r--epan/dissectors/packet-dmp.c56
-rw-r--r--epan/dissectors/packet-dmx.c48
-rw-r--r--epan/dissectors/packet-dvb-s2-bb.c12
-rw-r--r--epan/dissectors/packet-dvmrp.c12
-rw-r--r--epan/dissectors/packet-eigrp.c17
-rw-r--r--epan/dissectors/packet-epon.c12
-rw-r--r--epan/dissectors/packet-esis.c37
-rw-r--r--epan/dissectors/packet-eth.c57
-rw-r--r--epan/dissectors/packet-extreme.c49
-rw-r--r--epan/dissectors/packet-fc.c46
-rw-r--r--epan/dissectors/packet-fcoe.c42
-rw-r--r--epan/dissectors/packet-fcoib.c42
-rw-r--r--epan/dissectors/packet-fcswils.c2
-rw-r--r--epan/dissectors/packet-fefd.c41
-rw-r--r--epan/dissectors/packet-foundry.c2
-rw-r--r--epan/dissectors/packet-gdb.c3
-rw-r--r--epan/dissectors/packet-gfp.c76
-rw-r--r--epan/dissectors/packet-gre.c18
-rw-r--r--epan/dissectors/packet-h223.c16
-rw-r--r--epan/dissectors/packet-hartip.c2
-rw-r--r--epan/dissectors/packet-hip.c32
-rw-r--r--epan/dissectors/packet-homeplug-av.c8
-rw-r--r--epan/dissectors/packet-icmp.c68
-rw-r--r--epan/dissectors/packet-icmpv6.c75
-rw-r--r--epan/dissectors/packet-idp.c2
-rw-r--r--epan/dissectors/packet-ieee80211.c57
-rw-r--r--epan/dissectors/packet-igap.c10
-rw-r--r--epan/dissectors/packet-igmp.c43
-rw-r--r--epan/dissectors/packet-igmp.h2
-rw-r--r--epan/dissectors/packet-igrp.c2
-rw-r--r--epan/dissectors/packet-ip.c90
-rw-r--r--epan/dissectors/packet-ipv6.c4
-rw-r--r--epan/dissectors/packet-ipx.c2
-rw-r--r--epan/dissectors/packet-isis-hello.c31
-rw-r--r--epan/dissectors/packet-isis-lsp.c70
-rw-r--r--epan/dissectors/packet-isis-snp.c27
-rw-r--r--epan/dissectors/packet-itdm.c4
-rw-r--r--epan/dissectors/packet-kingfisher.c8
-rw-r--r--epan/dissectors/packet-lapd.c41
-rw-r--r--epan/dissectors/packet-lmp.c19
-rw-r--r--epan/dissectors/packet-manolito.c4
-rw-r--r--epan/dissectors/packet-mbtcp.c13
-rw-r--r--epan/dissectors/packet-mip6.c4
-rw-r--r--epan/dissectors/packet-mpeg-dsmcc.c4
-rw-r--r--epan/dissectors/packet-mpeg-sect.c35
-rw-r--r--epan/dissectors/packet-mrdisc.c12
-rw-r--r--epan/dissectors/packet-msnip.c14
-rw-r--r--epan/dissectors/packet-mstp.c97
-rw-r--r--epan/dissectors/packet-mswsp.c3
-rw-r--r--epan/dissectors/packet-mtp2.c16
-rw-r--r--epan/dissectors/packet-netsync.c4
-rw-r--r--epan/dissectors/packet-nhrp.c27
-rw-r--r--epan/dissectors/packet-nlsp.c8
-rw-r--r--epan/dissectors/packet-nsrp.c4
-rw-r--r--epan/dissectors/packet-osi.c71
-rw-r--r--epan/dissectors/packet-osi.h15
-rw-r--r--epan/dissectors/packet-ositp.c61
-rw-r--r--epan/dissectors/packet-ospf.c2
-rw-r--r--epan/dissectors/packet-pgm.c28
-rw-r--r--epan/dissectors/packet-pim.c37
-rw-r--r--epan/dissectors/packet-ppp.c29
-rw-r--r--epan/dissectors/packet-quake2.c5
-rw-r--r--epan/dissectors/packet-rdm.c48
-rw-r--r--epan/dissectors/packet-rfid-pn532-hci.c6
-rw-r--r--epan/dissectors/packet-rgmp.c10
-rw-r--r--epan/dissectors/packet-rohc.c4
-rw-r--r--epan/dissectors/packet-roofnet.c4
-rw-r--r--epan/dissectors/packet-rtp-midi.c12
-rw-r--r--epan/dissectors/packet-rtps.c4
-rw-r--r--epan/dissectors/packet-rudp.c2
-rw-r--r--epan/dissectors/packet-s7comm.c2
-rw-r--r--epan/dissectors/packet-sbus.c31
-rw-r--r--epan/dissectors/packet-sctp.c68
-rw-r--r--epan/dissectors/packet-selfm.c14
-rw-r--r--epan/dissectors/packet-shim6.c49
-rw-r--r--epan/dissectors/packet-simple.c23
-rw-r--r--epan/dissectors/packet-sml.c48
-rw-r--r--epan/dissectors/packet-stt.c75
-rw-r--r--epan/dissectors/packet-synphasor.c4
-rw-r--r--epan/dissectors/packet-sysex.c12
-rw-r--r--epan/dissectors/packet-tcp.c101
-rw-r--r--epan/dissectors/packet-teamspeak2.c33
-rw-r--r--epan/dissectors/packet-tnef.c2
-rw-r--r--epan/dissectors/packet-tns.c12
-rw-r--r--epan/dissectors/packet-ua3g.c2
-rw-r--r--epan/dissectors/packet-udld.c2
-rw-r--r--epan/dissectors/packet-udp.c107
-rw-r--r--epan/dissectors/packet-v5dl.c34
-rw-r--r--epan/dissectors/packet-vines.c2
-rw-r--r--epan/dissectors/packet-vrrp.c37
-rw-r--r--epan/dissectors/packet-wcp.c3
-rw-r--r--epan/dissectors/packet-xip-serval.c25
-rw-r--r--epan/dissectors/packet-xtp.c17
-rw-r--r--epan/dissectors/packet-zrtp.c46
-rw-r--r--epan/proto.c128
-rw-r--r--epan/proto.h43
-rw-r--r--plugins/irda/packet-sir.c42
-rw-r--r--plugins/profinet/packet-pn-rt.c51
-rw-r--r--plugins/wimax/mac_hd_generic_decoder.c12
-rw-r--r--plugins/wimax/msg_dlmap.c96
-rw-r--r--plugins/wimax/msg_ulmap.c109
-rw-r--r--plugins/wimax/wimax_harq_map_decoder.c12
-rw-r--r--profiles/Bluetooth/colorfilters2
-rw-r--r--profiles/Classic/colorfilters2
-rwxr-xr-xtools/checkAPIs.pl2
127 files changed, 1117 insertions, 2317 deletions
diff --git a/colorfilters b/colorfilters
index ca0e03f9c6..5dd37ce09e 100644
--- a/colorfilters
+++ b/colorfilters
@@ -9,7 +9,7 @@
@TCP RST@tcp.flags.reset eq 1@[42148,0,0][65535,64764,40092]
@SCTP ABORT@sctp.chunk_type eq ABORT@[42148,0,0][65535,64764,40092]
@TTL low or unexpected@( ! ip.dst == 224.0.0.0/4 && ip.ttl < 5 && !pim && !ospf) || (ip.dst == 224.0.0.0/24 && ip.dst != 224.0.0.251 && ip.ttl != 1 && !(vrrp || carp))@[42148,0,0][60652,61680,60395]
-@Checksum Errors@eth.fcs_bad==1 || ip.checksum_bad==1 || tcp.checksum_bad==1 || udp.checksum_bad==1 || sctp.checksum_bad==1 || mstp.checksum_bad==1 || cdp.checksum_bad==1 || edp.checksum_bad==1 || wlan.fcs_bad==1 || stt.checksum.bad==1@[4718,10030,11796][63479,34695,34695]
+@Checksum Errors@eth.fcs.status=="Bad" || ip.checksum.status=="Bad" || tcp.checksum.status=="Bad" || udp.checksum.status=="Bad" || sctp.checksum.status=="Bad" || mstp.checksum.status=="Bad" || cdp.checksum.status=="Bad" || edp.checksum.status=="Bad" || wlan.fcs.status=="Bad" || stt.checksum.status=="Bad"@[4718,10030,11796][63479,34695,34695]
@SMB@smb || nbss || nbns || nbipx || ipxsap || netbios@[65278,65535,53456][4718,10030,11796]
@HTTP@http || tcp.port == 80 || http2@[58596,65535,51143][4718,10030,11796]
@IPX@ipx || spx@[65534,58325,58808][4718,10030,11796]
diff --git a/debian/libwireshark0.symbols b/debian/libwireshark0.symbols
index af7736636c..23ed83067c 100644
--- a/debian/libwireshark0.symbols
+++ b/debian/libwireshark0.symbols
@@ -1053,6 +1053,7 @@ libwireshark.so.0 libwireshark0 #MINVER#
proto_tree_add_bytes_format_value@Base 1.9.1
proto_tree_add_bytes_item@Base 1.12.0~rc1
proto_tree_add_bytes_with_length@Base 1.99.3
+ proto_tree_add_checksum@Base 2.1.1
proto_tree_add_debug_text@Base 1.9.1
proto_tree_add_double@Base 1.9.1
proto_tree_add_double_format@Base 1.9.1
diff --git a/doc/README.dissector b/doc/README.dissector
index 17b3273336..74409bd390 100644
--- a/doc/README.dissector
+++ b/doc/README.dissector
@@ -1996,8 +1996,7 @@ presented as a subtree, where the result is enclosed in square brackets
indicating a generated field.
Header checksum: 0x3d42 [correct]
- [Good: True]
- [Bad: False]
+ [Checksum Status: Good (1)]
PROTO_ITEM_SET_HIDDEN()
-----------------------
diff --git a/docbook/release-notes.asciidoc b/docbook/release-notes.asciidoc
index 9dc5aa45e7..897b7e15c9 100644
--- a/docbook/release-notes.asciidoc
+++ b/docbook/release-notes.asciidoc
@@ -41,6 +41,13 @@ since version 2.1.0:
* The RTP player now allows up to 30 minutes of silence frames.
* Packet bytes can now be displayed as EBCDIC.
* The Qt UI loads captures faster on Windows.
+* proto_tree_add_checksum was added as an API. This attempts to
+ standardize how checksums are reported and filtered for within
+ *Shark. There are no more individual "good" and "bad" filter
+ fields, protocols now have a "checksum.status" field that records
+ "Good", "Bad" and "Unverified" (neither good or bad). Color filters
+ provided with Wireshark have been adjusted to the new display filter
+ names, but custom ones may need to be updated.
The following features are new (or have been significantly updated)
since version 2.0.0:
diff --git a/epan/dissectors/asn1/c1222/packet-c1222-template.c b/epan/dissectors/asn1/c1222/packet-c1222-template.c
index c01a342ea0..bf4269dc5f 100644
--- a/epan/dissectors/asn1/c1222/packet-c1222-template.c
+++ b/epan/dissectors/asn1/c1222/packet-c1222-template.c
@@ -123,6 +123,7 @@ static int hf_c1222_write_size = -1;
static int hf_c1222_write_data = -1;
static int hf_c1222_procedure_num = -1;
static int hf_c1222_write_chksum = -1;
+static int hf_c1222_write_chksum_status = -1;
static int hf_c1222_wait_secs = -1;
static int hf_c1222_neg_pkt_size = -1;
static int hf_c1222_neg_nbr_pkts = -1;
@@ -380,7 +381,6 @@ parse_c1222_detailed(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int cm
gchar *auth_req = NULL;
guint16 table = 0;
guint16 tblsize = 0;
- guint8 chksum = 0;
guint16 calcsum = 0;
guint8 wait_seconds = 0;
int numrates = 0;
@@ -392,7 +392,6 @@ parse_c1222_detailed(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int cm
guint8 inter_char;
guint8 resp_to;
guint8 nbr_retries;
- proto_item *item = NULL;
/* special case to simplify handling of Negotiate service */
if ((cmd & 0xF0) == C1222_CMD_NEGOTIATE) {
@@ -509,16 +508,14 @@ parse_c1222_detailed(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int cm
proto_tree_add_item(tree, hf_c1222_write_data, tvb, *offset, tblsize, ENC_NA);
*offset += tblsize;
*length -= tblsize;
- chksum = tvb_get_guint8(tvb, *offset);
- item = proto_tree_add_uint(tree, hf_c1222_write_chksum, tvb, *offset, 1, chksum);
if (table == 7) {/* is it a procedure call? */
calcsum = c1222_cksum(tvb, (*offset)-tblsize-2, tblsize+2);
} else {
calcsum = c1222_cksum(tvb, (*offset)-tblsize, tblsize);
}
- if (chksum != calcsum) {
- expert_add_info_format(pinfo, item, &ei_c1222_bad_checksum, "Bad checksum [should be 0x%02x]", calcsum);
- }
+ proto_tree_add_checksum(tree, tvb, *offset, hf_c1222_write_chksum, hf_c1222_write_chksum_status,
+ &ei_c1222_bad_checksum, pinfo, calcsum, ENC_NA, PROTO_CHECKSUM_VERIFY);
+
if (table == 7) {/* is it a procedure call? */
proto_item_set_text(tree, "C12.22 EPSEM: %s (%s-%d, %s-%d)",
val_to_str(cmd,commandnames,"Unknown (0x%02x)"),
@@ -555,12 +552,9 @@ parse_c1222_detailed(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int cm
proto_tree_add_item(tree, hf_c1222_write_data, tvb, *offset, tblsize, ENC_NA);
*offset += tblsize;
*length -= tblsize;
- chksum = tvb_get_guint8(tvb, *offset);
- item = proto_tree_add_uint(tree, hf_c1222_write_chksum, tvb, *offset, 1, chksum);
calcsum = c1222_cksum(tvb, (*offset)-tblsize, tblsize);
- if (chksum != calcsum) {
- expert_add_info_format(pinfo, item, &ei_c1222_bad_checksum, "Bad checksum [should be 0x%02x]", calcsum);
- }
+ proto_tree_add_checksum(tree, tvb, *offset, hf_c1222_write_chksum, hf_c1222_write_chksum_status,
+ &ei_c1222_bad_checksum, pinfo, calcsum, ENC_NA, PROTO_CHECKSUM_VERIFY);
proto_item_set_text(tree, "C12.22 EPSEM: %s (%s-%d)",
val_to_str(cmd,commandnames,"Unknown (0x%02x)"),
val_to_str((table >> 8) & 0xF8, tableflags,"Unknown (0x%04x)"), table & 0x7FF);
@@ -1259,6 +1253,12 @@ void proto_register_c1222(void) {
NULL, 0x0,
NULL, HFILL }
},
+ { &hf_c1222_write_chksum_status,
+ { "C12.22 Table Data Checksum Status", "c1222.write.chksum.status",
+ FT_UINT8, BASE_NONE,
+ VALS(proto_checksum_vals), 0x0,
+ NULL, HFILL }
+ },
{ &hf_c1222_procedure_num,
{ "C12.22 Procedure Number", "c1222.procedure.num",
FT_UINT16, BASE_DEC,
diff --git a/epan/dissectors/packet-6lowpan.c b/epan/dissectors/packet-6lowpan.c
index 52483e6fcd..9dd6620644 100644
--- a/epan/dissectors/packet-6lowpan.c
+++ b/epan/dissectors/packet-6lowpan.c
@@ -2088,9 +2088,8 @@ dissect_6lowpan_iphc_nhc(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gi
if (!(udp_flags & LOWPAN_NHC_UDP_CHECKSUM)) {
/* Parse the checksum. */
udp.checksum = tvb_get_ntohs(tvb, offset);
- proto_tree_add_uint(tree, hf_6lowpan_udp_checksum, tvb, offset, 2, udp.checksum);
+ proto_tree_add_checksum(tree, tvb, offset, hf_6lowpan_udp_checksum, -1, NULL, pinfo, 0, ENC_BIG_ENDIAN, PROTO_CHECKSUM_NO_FLAGS);
offset += 2;
- udp.checksum = g_ntohs(udp.checksum);
}
else {
udp.checksum = 0;
diff --git a/epan/dissectors/packet-aol.c b/epan/dissectors/packet-aol.c
index eaccc991b7..c5f3072181 100644
--- a/epan/dissectors/packet-aol.c
+++ b/epan/dissectors/packet-aol.c
@@ -226,7 +226,7 @@ static int dissect_aol_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
/* Add the first few P3 fields */
proto_tree_add_item(aol_tree,hf_aol_start,tvb,offset,1,ENC_NA); offset += 1;
- proto_tree_add_item(aol_tree,hf_aol_crc, tvb,offset,2,ENC_BIG_ENDIAN); offset += 2;
+ proto_tree_add_checksum(aol_tree, tvb, offset, hf_aol_crc, -1, NULL, pinfo, 0, ENC_BIG_ENDIAN, PROTO_CHECKSUM_NO_FLAGS); offset += 2;
proto_tree_add_item(aol_tree,hf_aol_len, tvb,offset,2,ENC_BIG_ENDIAN); offset += 2;
/* Add sequence fields */
diff --git a/epan/dissectors/packet-artnet.c b/epan/dissectors/packet-artnet.c
index 90b29c2e6e..3f4f3f01e6 100644
--- a/epan/dissectors/packet-artnet.c
+++ b/epan/dissectors/packet-artnet.c
@@ -3141,8 +3141,7 @@ dissect_artnet_file_tn_master(tvbuff_t *tvb, guint offset, proto_tree *tree)
offset, 14, ENC_ASCII|ENC_NA);
offset += 14;
- proto_tree_add_item(tree, hf_artnet_file_tn_master_checksum, tvb,
- offset, 2, ENC_BIG_ENDIAN);
+ proto_tree_add_checksum(tree, tvb, offset, hf_artnet_file_tn_master_checksum, -1, NULL, NULL, 0, ENC_BIG_ENDIAN, PROTO_CHECKSUM_NO_FLAGS);
offset += 2;
proto_tree_add_item(tree, hf_artnet_file_tn_master_spare, tvb,
diff --git a/epan/dissectors/packet-asap.c b/epan/dissectors/packet-asap.c
index 579e15ebb4..fa860996a1 100644
--- a/epan/dissectors/packet-asap.c
+++ b/epan/dissectors/packet-asap.c
@@ -567,13 +567,12 @@ dissect_pe_identifier_parameter(tvbuff_t *parameter_tvb, proto_tree *parameter_t
proto_item_append_text(parameter_item, " (0x%x)", tvb_get_ntohl(parameter_tvb, PE_IDENTIFIER_OFFSET));
}
-#define PE_CHECKSUM_LENGTH 2
#define PE_CHECKSUM_OFFSET PARAMETER_VALUE_OFFSET
static void
dissect_pe_checksum_parameter(tvbuff_t *parameter_tvb, proto_tree *parameter_tree, proto_item *parameter_item)
{
- proto_tree_add_item(parameter_tree, hf_pe_checksum, parameter_tvb, PE_CHECKSUM_OFFSET, PE_CHECKSUM_LENGTH, ENC_BIG_ENDIAN);
+ proto_tree_add_checksum(parameter_tree, parameter_tvb, PE_CHECKSUM_OFFSET, hf_pe_checksum, -1, NULL, NULL, 0, ENC_BIG_ENDIAN, PROTO_CHECKSUM_NO_FLAGS);
proto_item_append_text(parameter_item, " (0x%x)", tvb_get_ntohs(parameter_tvb, PE_CHECKSUM_OFFSET));
}
@@ -893,7 +892,7 @@ proto_register_asap(void)
{ &hf_reg_life, { "Registration Life", "asap.pool_element_registration_life", FT_INT32, BASE_DEC, NULL, 0x0, NULL, HFILL } },
{ &hf_cookie, { "Cookie", "asap.cookie", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL } },
{ &hf_pe_identifier, { "PE Identifier", "asap.pe_identifier", FT_UINT32, BASE_HEX, NULL, 0x0, NULL, HFILL } },
- { &hf_pe_checksum, { "PE Checksum", "asap.pe_checksum", FT_UINT32, BASE_HEX, NULL, 0x0, NULL, HFILL } },
+ { &hf_pe_checksum, { "PE Checksum", "asap.pe_checksum", FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL } },
{ &hf_hropt_items, { "Items", "asap.hropt_items", FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL } },
{ &hf_server_identifier, { "Server Identifier", "asap.server_identifier", FT_UINT32, BASE_HEX, NULL, 0x0, NULL, HFILL } },
{ &hf_home_enrp_server_bit, { "H Bit", "asap.h_bit", FT_BOOLEAN, 8, TFS(&home_enrp_server_bit_value), HOME_ENRP_SERVER_BIT_MASK, NULL, HFILL } },
diff --git a/epan/dissectors/packet-atalk.c b/epan/dissectors/packet-atalk.c
index f7b9a23e21..4b0d8e616d 100644
--- a/epan/dissectors/packet-atalk.c
+++ b/epan/dissectors/packet-atalk.c
@@ -367,23 +367,6 @@ static dissector_table_t ddp_dissector_table;
#define DDP_SHORT_HEADER_SIZE 5
-/*
- * P = Padding, H = Hops, L = Len
- *
- * PPHHHHLL LLLLLLLL
- *
- * Assumes the argument is in host byte order.
- */
-#define ddp_hops(x) ( ( x >> 10) & 0x3C )
-#define ddp_len(x) ( x & 0x03ff )
-typedef struct _e_ddp {
- guint16 hops_len; /* combines pad, hops, and len */
- guint16 sum,dnet,snet;
- guint8 dnode,snode;
- guint8 dport,sport;
- guint8 type;
-} e_ddp;
-
#define DDP_HEADER_SIZE 13
@@ -1484,76 +1467,55 @@ dissect_ddp_short(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* dat
static int
dissect_ddp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
{
- e_ddp ddp;
proto_tree *ddp_tree;
proto_item *ti, *hidden_item;
struct atalk_ddp_addr *src = wmem_new0(pinfo->pool, struct atalk_ddp_addr),
*dst = wmem_new0(pinfo->pool, struct atalk_ddp_addr);
tvbuff_t *new_tvb;
+ guint type;
col_set_str(pinfo->cinfo, COL_PROTOCOL, "DDP");
col_clear(pinfo->cinfo, COL_INFO);
- tvb_memcpy(tvb, (guint8 *)&ddp, 0, sizeof(e_ddp));
- ddp.dnet=g_ntohs(ddp.dnet);
- ddp.snet=g_ntohs(ddp.snet);
- ddp.sum=g_ntohs(ddp.sum);
- ddp.hops_len=g_ntohs(ddp.hops_len);
-
- src->net = ddp.snet;
- src->node = ddp.snode;
- dst->net = ddp.dnet;
- dst->node = ddp.dnode;
- set_address(&pinfo->net_src, atalk_address_type, sizeof(struct atalk_ddp_addr), src);
- copy_address_shallow(&pinfo->src, &pinfo->net_src);
- set_address(&pinfo->net_dst, atalk_address_type, sizeof(struct atalk_ddp_addr), dst);
- copy_address_shallow(&pinfo->dst, &pinfo->net_dst);
-
pinfo->ptype = PT_DDP;
- pinfo->destport = ddp.dport;
- pinfo->srcport = ddp.sport;
- col_add_str(pinfo->cinfo, COL_INFO,
- val_to_str_ext(ddp.type, &op_vals_ext, "Unknown DDP protocol (%02x)"));
-
- if (tree) {
- ti = proto_tree_add_item(tree, proto_ddp, tvb, 0, DDP_HEADER_SIZE,
- ENC_NA);
- ddp_tree = proto_item_add_subtree(ti, ett_ddp);
+ ti = proto_tree_add_item(tree, proto_ddp, tvb, 0, DDP_HEADER_SIZE, ENC_NA);
+ ddp_tree = proto_item_add_subtree(ti, ett_ddp);
- hidden_item = proto_tree_add_string(ddp_tree, hf_ddp_src, tvb,
+ hidden_item = proto_tree_add_string(ddp_tree, hf_ddp_src, tvb,
4, 3, address_to_str(wmem_packet_scope(), &pinfo->src));
- PROTO_ITEM_SET_HIDDEN(hidden_item);
+ PROTO_ITEM_SET_HIDDEN(hidden_item);
- hidden_item = proto_tree_add_string(ddp_tree, hf_ddp_dst, tvb,
+ hidden_item = proto_tree_add_string(ddp_tree, hf_ddp_dst, tvb,
6, 3, address_to_str(wmem_packet_scope(), &pinfo->dst));
- PROTO_ITEM_SET_HIDDEN(hidden_item);
+ PROTO_ITEM_SET_HIDDEN(hidden_item);
+
+ proto_tree_add_item(ddp_tree, hf_ddp_hopcount, tvb, 0, 2, ENC_BIG_ENDIAN);
+ proto_tree_add_item(ddp_tree, hf_ddp_len, tvb, 0, 2, ENC_BIG_ENDIAN);
+ proto_tree_add_checksum(ddp_tree, tvb, 0, hf_ddp_checksum, -1, NULL, pinfo, 0, ENC_BIG_ENDIAN, PROTO_CHECKSUM_NO_FLAGS);
+ dst->net = tvb_get_ntohs(tvb, 4);
+ proto_tree_add_uint(ddp_tree, hf_ddp_dst_net, tvb, 4, 2, dst->net);
+ src->net = tvb_get_ntohs(tvb, 6);
+ proto_tree_add_uint(ddp_tree, hf_ddp_src_net, tvb, 6, 2, src->net);
+ dst->node = tvb_get_guint8(tvb, 8);
+ proto_tree_add_uint(ddp_tree, hf_ddp_dst_node, tvb, 8, 1, dst->node);
+ src->node = tvb_get_guint8(tvb, 9);
+ proto_tree_add_uint(ddp_tree, hf_ddp_src_node, tvb, 9, 1, src->node);
+ proto_tree_add_item_ret_uint(ddp_tree, hf_ddp_dst_socket, tvb, 10, 1, ENC_NA, &pinfo->destport);
+ proto_tree_add_item_ret_uint(ddp_tree, hf_ddp_src_socket, tvb, 11, 1, ENC_NA, &pinfo->srcport);
+ proto_tree_add_item_ret_uint(ddp_tree, hf_ddp_type, tvb, 12, 1, ENC_NA, &type);
- proto_tree_add_uint(ddp_tree, hf_ddp_hopcount, tvb, 0, 1,
- ddp_hops(ddp.hops_len));
- proto_tree_add_uint(ddp_tree, hf_ddp_len, tvb, 0, 2,
- ddp_len(ddp.hops_len));
- proto_tree_add_uint(ddp_tree, hf_ddp_checksum, tvb, 2, 2,
- ddp.sum);
- proto_tree_add_uint(ddp_tree, hf_ddp_dst_net, tvb, 4, 2,
- ddp.dnet);
- proto_tree_add_uint(ddp_tree, hf_ddp_src_net, tvb, 6, 2,
- ddp.snet);
- proto_tree_add_uint(ddp_tree, hf_ddp_dst_node, tvb, 8, 1,
- ddp.dnode);
- proto_tree_add_uint(ddp_tree, hf_ddp_src_node, tvb, 9, 1,
- ddp.snode);
- proto_tree_add_uint(ddp_tree, hf_ddp_dst_socket, tvb, 10, 1,
- ddp.dport);
- proto_tree_add_uint(ddp_tree, hf_ddp_src_socket, tvb, 11, 1,
- ddp.sport);
- proto_tree_add_uint(ddp_tree, hf_ddp_type, tvb, 12, 1,
- ddp.type);
- }
+ col_add_str(pinfo->cinfo, COL_INFO,
+ val_to_str_ext(type, &op_vals_ext, "Unknown DDP protocol (%02x)"));
+
+ set_address(&pinfo->net_src, atalk_address_type, sizeof(struct atalk_ddp_addr), src);
+ copy_address_shallow(&pinfo->src, &pinfo->net_src);
+ set_address(&pinfo->net_dst, atalk_address_type, sizeof(struct atalk_ddp_addr), dst);
+ copy_address_shallow(&pinfo->dst, &pinfo->net_dst);
new_tvb = tvb_new_subset_remaining(tvb, DDP_HEADER_SIZE);
- if (!dissector_try_uint(ddp_dissector_table, ddp.type, new_tvb, pinfo, tree))
+ if (!dissector_try_uint(ddp_dissector_table, type, new_tvb, pinfo, tree))
{
call_data_dissector(new_tvb, pinfo, tree);
}
@@ -1666,11 +1628,11 @@ proto_register_atalk(void)
static hf_register_info hf_ddp[] = {
{ &hf_ddp_hopcount,
- { "Hop count", "ddp.hopcount", FT_UINT8, BASE_DEC, NULL, 0x0,
+ { "Hop count", "ddp.hopcount", FT_UINT16, BASE_DEC, NULL, 0x3C00,
NULL, HFILL }},
{ &hf_ddp_len,
- { "Datagram length", "ddp.len", FT_UINT16, BASE_DEC, NULL, 0x0,
+ { "Datagram length", "ddp.len", FT_UINT16, BASE_DEC, NULL, 0x0300,
NULL, HFILL }},
{ &hf_ddp_checksum,
diff --git a/epan/dissectors/packet-ax25-kiss.c b/epan/dissectors/packet-ax25-kiss.c
index d007d4e456..56a308b21c 100644
--- a/epan/dissectors/packet-ax25-kiss.c
+++ b/epan/dissectors/packet-ax25-kiss.c
@@ -335,17 +335,17 @@ dissect_ax25_kiss( tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, v
}
if ( gPREF_CKSUM_MODE )
- {
+ {
kiss_cksum = 0;
- kiss_tvb_length = tvb_captured_length_remaining( tvb, 0 ) - 1;
+ kiss_tvb_length = tvb_captured_length(tvb) - 1;
if ( kiss_tvb_length > 0 )
- {
+ {
for ( kiss_cksum_index = 0; kiss_cksum_index < kiss_tvb_length; kiss_cksum_index++ )
kiss_cksum ^= (tvb_get_guint8( tvb, kiss_cksum_index ) & 0xff);
- proto_tree_add_uint( kiss_tree, hf_ax25_kiss_cksum,
- tvb, kiss_cksum_index, 1, kiss_cksum );
- }
+
+ proto_tree_add_checksum(kiss_tree, tvb, 0, hf_ax25_kiss_cksum, -1, NULL, pinfo, kiss_cksum, ENC_NA, PROTO_CHECKSUM_GENERATED);
}
+ }
}
/* Call sub-dissectors here */
diff --git a/epan/dissectors/packet-bitcoin.c b/epan/dissectors/packet-bitcoin.c
index 56c8259aa6..cc3cbbd02c 100644
--- a/epan/dissectors/packet-bitcoin.c
+++ b/epan/dissectors/packet-bitcoin.c
@@ -1554,7 +1554,7 @@ static int dissect_bitcoin_tcp_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree
proto_tree_add_item(tree, &hfi_bitcoin_magic, tvb, 0, 4, ENC_BIG_ENDIAN);
proto_tree_add_item_ret_string(tree, hfi_bitcoin_command.id, tvb, 4, 12, ENC_ASCII|ENC_NA, wmem_packet_scope(), &command);
proto_tree_add_item(tree, &hfi_bitcoin_length, tvb, 16, 4, ENC_LITTLE_ENDIAN);
- proto_tree_add_item(tree, &hfi_bitcoin_checksum, tvb, 20, 4, ENC_BIG_ENDIAN);
+ proto_tree_add_checksum(tree, tvb, 20, hfi_bitcoin_checksum.id, -1, NULL, pinfo, 0, ENC_BIG_ENDIAN, PROTO_CHECKSUM_NO_FLAGS);
offset = 24;
diff --git a/epan/dissectors/packet-btatt.c b/epan/dissectors/packet-btatt.c
index 785b9b981e..00e8aae35f 100644
--- a/epan/dissectors/packet-btatt.c
+++ b/epan/dissectors/packet-btatt.c
@@ -8960,7 +8960,7 @@ dissect_attribute_value(proto_tree *tree, proto_item *patron_item, packet_info *
break;
case 0x03: /* Calculate Checksum */
- proto_tree_add_item(tree, hf_btatt_ots_checksum, tvb, offset, 4, ENC_LITTLE_ENDIAN);
+ proto_tree_add_checksum(tree, tvb, offset, hf_btatt_ots_checksum, -1, NULL, pinfo, 0, ENC_BIG_ENDIAN, PROTO_CHECKSUM_NO_FLAGS);
offset += 4;
break;
diff --git a/epan/dissectors/packet-c1222.c b/epan/dissectors/packet-c1222.c
index b83fcd7541..a1873c07e3 100644
--- a/epan/dissectors/packet-c1222.c
+++ b/epan/dissectors/packet-c1222.c
@@ -161,6 +161,7 @@ static int hf_c1222_write_size = -1;
static int hf_c1222_write_data = -1;
static int hf_c1222_procedure_num = -1;
static int hf_c1222_write_chksum = -1;
+static int hf_c1222_write_chksum_status = -1;
static int hf_c1222_wait_secs = -1;
static int hf_c1222_neg_pkt_size = -1;
static int hf_c1222_neg_nbr_pkts = -1;
@@ -224,7 +225,7 @@ static gint ett_c1222_Calling_authentication_value_c1222_U = -1;
static gint ett_c1222_Calling_authentication_value_c1221_U = -1;
/*--- End of included file: packet-c1222-ett.c ---*/
-#line 177 "./asn1/c1222/packet-c1222-template.c"
+#line 178 "./asn1/c1222/packet-c1222-template.c"
static expert_field ei_c1222_command_truncated = EI_INIT;
static expert_field ei_c1222_bad_checksum = EI_INIT;
@@ -431,7 +432,6 @@ parse_c1222_detailed(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int cm
gchar *auth_req = NULL;
guint16 table = 0;
guint16 tblsize = 0;
- guint8 chksum = 0;
guint16 calcsum = 0;
guint8 wait_seconds = 0;
int numrates = 0;
@@ -443,7 +443,6 @@ parse_c1222_detailed(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int cm
guint8 inter_char;
guint8 resp_to;
guint8 nbr_retries;
- proto_item *item = NULL;
/* special case to simplify handling of Negotiate service */
if ((cmd & 0xF0) == C1222_CMD_NEGOTIATE) {
@@ -560,16 +559,14 @@ parse_c1222_detailed(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int cm
proto_tree_add_item(tree, hf_c1222_write_data, tvb, *offset, tblsize, ENC_NA);
*offset += tblsize;
*length -= tblsize;
- chksum = tvb_get_guint8(tvb, *offset);
- item = proto_tree_add_uint(tree, hf_c1222_write_chksum, tvb, *offset, 1, chksum);
if (table == 7) {/* is it a procedure call? */
calcsum = c1222_cksum(tvb, (*offset)-tblsize-2, tblsize+2);
} else {
calcsum = c1222_cksum(tvb, (*offset)-tblsize, tblsize);
}
- if (chksum != calcsum) {
- expert_add_info_format(pinfo, item, &ei_c1222_bad_checksum, "Bad checksum [should be 0x%02x]", calcsum);
- }
+ proto_tree_add_checksum(tree, tvb, *offset, hf_c1222_write_chksum, hf_c1222_write_chksum_status,
+ &ei_c1222_bad_checksum, pinfo, calcsum, ENC_NA, PROTO_CHECKSUM_VERIFY);
+
if (table == 7) {/* is it a procedure call? */
proto_item_set_text(tree, "C12.22 EPSEM: %s (%s-%d, %s-%d)",
val_to_str(cmd,commandnames,"Unknown (0x%02x)"),
@@ -606,12 +603,9 @@ parse_c1222_detailed(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int cm
proto_tree_add_item(tree, hf_c1222_write_data, tvb, *offset, tblsize, ENC_NA);
*offset += tblsize;
*length -= tblsize;
- chksum = tvb_get_guint8(tvb, *offset);
- item = proto_tree_add_uint(tree, hf_c1222_write_chksum, tvb, *offset, 1, chksum);
calcsum = c1222_cksum(tvb, (*offset)-tblsize, tblsize);
- if (chksum != calcsum) {
- expert_add_info_format(pinfo, item, &ei_c1222_bad_checksum, "Bad checksum [should be 0x%02x]", calcsum);
- }
+ proto_tree_add_checksum(tree, tvb, *offset, hf_c1222_write_chksum, hf_c1222_write_chksum_status,
+ &ei_c1222_bad_checksum, pinfo, calcsum, ENC_NA, PROTO_CHECKSUM_VERIFY);
proto_item_set_text(tree, "C12.22 EPSEM: %s (%s-%d)",
val_to_str(cmd,commandnames,"Unknown (0x%02x)"),
val_to_str((table >> 8) & 0xF8, tableflags,"Unknown (0x%04x)"), table & 0x7FF);
@@ -1566,7 +1560,7 @@ static int dissect_MESSAGE_PDU(tvbuff_t *tvb _U_, packet_info *pinfo _U_, proto_
/*--- End of included file: packet-c1222-fn.c ---*/
-#line 1048 "./asn1/c1222/packet-c1222-template.c"
+#line 1042 "./asn1/c1222/packet-c1222-template.c"
/**
* Dissects a a full (reassembled) C12.22 message.
@@ -1781,6 +1775,12 @@ void proto_register_c1222(void) {
NULL, 0x0,
NULL, HFILL }
},
+ { &hf_c1222_write_chksum_status,
+ { "C12.22 Table Data Checksum Status", "c1222.write.chksum.status",
+ FT_UINT8, BASE_NONE,
+ VALS(proto_checksum_vals), 0x0,
+ NULL, HFILL }
+ },
{ &hf_c1222_procedure_num,
{ "C12.22 Procedure Number", "c1222.procedure.num",
FT_UINT16, BASE_DEC,
diff --git a/epan/dissectors/packet-carp.c b/epan/dissectors/packet-carp.c
index cbb21725e5..a5a276d529 100644
--- a/epan/dissectors/packet-carp.c
+++ b/epan/dissectors/packet-carp.c
@@ -90,7 +90,6 @@ dissect_carp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data)
proto_item *ti, *tv;
proto_tree *carp_tree, *ver_type_tree;
guint8 ver_type;
- guint16 cksum, computed_cksum;
/* Make sure it's a CARP packet */
if (!test_carp_packet(tvb, pinfo, tree, data))
@@ -133,20 +132,15 @@ dissect_carp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data)
proto_tree_add_item(carp_tree, hf_carp_advbase, tvb, offset, 1, ENC_BIG_ENDIAN);
offset++;
- cksum = tvb_get_ntohs(tvb, offset);
- ti = proto_tree_add_item(carp_tree, hf_carp_checksum, tvb, offset, 2, ENC_BIG_ENDIAN);
carp_len = tvb_reported_length(tvb);
if (!pinfo->fragmented && tvb_captured_length(tvb) >= carp_len) {
/* The packet isn't part of a fragmented datagram
and isn't truncated, so we can checksum it. */
SET_CKSUM_VEC_TVB(cksum_vec[0], tvb, 0, carp_len);
- computed_cksum = in_cksum(&cksum_vec[0], 1);
- if (computed_cksum == 0) {
- proto_item_append_text(ti, " [correct]");
- } else {
- proto_item_append_text(ti, " [incorrect, should be 0x%04x]",
- in_cksum_shouldbe(cksum, computed_cksum));
- }
+ proto_tree_add_checksum(carp_tree, tvb, offset, hf_carp_checksum, -1, NULL, pinfo, in_cksum(&cksum_vec[0], 1),
+ ENC_BIG_ENDIAN, PROTO_CHECKSUM_VERIFY|PROTO_CHECKSUM_IN_CKSUM);
+ } else {
+ proto_tree_add_checksum(carp_tree, tvb, offset, hf_carp_checksum, -1, NULL, pinfo, 0, ENC_BIG_ENDIAN, PROTO_CHECKSUM_NO_FLAGS);
}
offset+=2;
diff --git a/epan/dissectors/packet-cattp.c b/epan/dissectors/packet-cattp.c
index 277a1e1376..10e489c536 100644
--- a/epan/dissectors/packet-cattp.c
+++ b/epan/dissectors/packet-cattp.c
@@ -87,6 +87,7 @@ static int hf_cattp_seq = -1;
static int hf_cattp_ack = -1;
static int hf_cattp_windowsize = -1;
static int hf_cattp_checksum = -1;
+static int hf_cattp_checksum_status = -1;
static int hf_cattp_identification = -1;
static int hf_cattp_iccid = -1;
static int hf_cattp_idlen = -1;
@@ -218,12 +219,11 @@ dissect_cattp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U
const char *pdutype = "[Unknown PDU]";
proto_item *ti, *cattp_tree;
guint32 offset;
- gushort computed_chksum;
vec_t cksum_vec[1];
int header_offset;
guint cksum_data_len;
guint8 flags, first_byte, hlen, ver;
- guint16 plen, chksum, ackno, seqno, wsize, sport, dport;
+ guint16 plen, ackno, seqno, wsize, sport, dport;
col_set_str(pinfo->cinfo, COL_PROTOCOL, CATTP_SHORTNAME);
@@ -294,28 +294,16 @@ dissect_cattp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U
/* Parse and verify checksum */
header_offset = 0;
cksum_data_len = hlen + plen;
- chksum = tvb_get_ntohs(tvb, offset);
if (!cattp_check_checksum) {
/* We have turned checksum checking off; we do NOT checksum it. */
- proto_tree_add_uint_format_value(cattp_tree, hf_cattp_checksum, tvb, offset, 2,
- chksum, "0x%X [validation disabled]", chksum);
+ proto_tree_add_checksum(cattp_tree, tvb, offset, hf_cattp_checksum, hf_cattp_checksum_status, NULL, pinfo, 0, ENC_BIG_ENDIAN, PROTO_CHECKSUM_NO_FLAGS);
} else {
/* We haven't turned checksum checking off; checksum it. */
/* Unlike TCP, CATTP does not make use of a pseudo-header for checksum */
SET_CKSUM_VEC_TVB(cksum_vec[0], tvb, header_offset, cksum_data_len);
- computed_chksum = in_cksum(cksum_vec, 1);
-
- if (computed_chksum == 0) {
- /* Checksum is valid */
- proto_tree_add_uint_format_value(cattp_tree, hf_cattp_checksum, tvb, offset, 2,
- chksum, "0x%X [validated]", chksum);
- } else {
- /* Checksum is invalid. Let's compute the expected checksum, based on the data we have */
- proto_tree_add_uint_format_value(cattp_tree, hf_cattp_checksum, tvb, offset, 2, chksum,
- "0x%X [incorrect, correct: 0x%X]", chksum,
- in_cksum_shouldbe(chksum, computed_chksum));
- }
+ proto_tree_add_checksum(cattp_tree, tvb, offset, hf_cattp_checksum, hf_cattp_checksum_status, NULL, pinfo, in_cksum(cksum_vec, 1),
+ ENC_BIG_ENDIAN, PROTO_CHECKSUM_VERIFY|PROTO_CHECKSUM_IN_CKSUM);
} /* End of checksum code */
offset += 2;
@@ -478,6 +466,13 @@ proto_register_cattp(void)
}
},
{
+ &hf_cattp_checksum_status,
+ {
+ "Checksum Status", "cattp.checksum.status", FT_UINT8, BASE_NONE, VALS(proto_checksum_vals), 0x0,
+ NULL, HFILL
+ }
+ },
+ {
&hf_cattp_identification,
{
"Identification", "cattp.identification", FT_BYTES, BASE_NONE, NULL, 0x0,
diff --git a/epan/dissectors/packet-cdp.c b/epan/dissectors/packet-cdp.c
index fb975fa89a..b61a7097cc 100644
--- a/epan/dissectors/packet-cdp.c
+++ b/epan/dissectors/packet-cdp.c
@@ -53,8 +53,7 @@ void proto_reg_handoff_cdp(void);
static int proto_cdp = -1;
static int hf_cdp_version = -1;
static int hf_cdp_checksum = -1;
-static int hf_cdp_checksum_good = -1;
-static int hf_cdp_checksum_bad = -1;
+static int hf_cdp_checksum_status = -1;
static int hf_cdp_ttl = -1;
static int hf_cdp_tlvtype = -1;
static int hf_cdp_tlvlength = -1;
@@ -271,12 +270,11 @@ static const value_string type_nrgyz_vals[] = {
static int
dissect_cdp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
{
- proto_item *ti, *checksum_item;
- proto_tree *cdp_tree = NULL, *checksum_tree;
+ proto_item *ti;
+ proto_tree *cdp_tree;
int offset = 0;
guint16 type;
- guint16 length, packet_checksum, computed_checksum, data_length;
- gboolean checksum_good, checksum_bad;
+ guint16 length, data_length;
proto_item *tlvi = NULL;
proto_tree *tlv_tree = NULL;
int real_length;
@@ -289,25 +287,20 @@ dissect_cdp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
col_set_str(pinfo->cinfo, COL_PROTOCOL, "CDP");
col_clear(pinfo->cinfo, COL_INFO);
- if (tree) {
- ti = proto_tree_add_item(tree, proto_cdp, tvb, offset, -1, ENC_NA);
- cdp_tree = proto_item_add_subtree(ti, ett_cdp);
+ ti = proto_tree_add_item(tree, proto_cdp, tvb, offset, -1, ENC_NA);
+ cdp_tree = proto_item_add_subtree(ti, ett_cdp);
- /* CDP header */
- proto_tree_add_item(cdp_tree, hf_cdp_version, tvb, offset, 1, ENC_BIG_ENDIAN);
- offset += 1;
+ /* CDP header */
+ proto_tree_add_item(cdp_tree, hf_cdp_version, tvb, offset, 1, ENC_BIG_ENDIAN);
+ offset += 1;
- proto_tree_add_uint_format_value(cdp_tree, hf_cdp_ttl, tvb, offset, 1,
- tvb_get_guint8(tvb, offset),
- "%u seconds",
- tvb_get_guint8(tvb, offset));
- offset += 1;
- } else {
- offset += 2; /* The version/ttl fields from above */
- }
+ proto_tree_add_uint_format_value(cdp_tree, hf_cdp_ttl, tvb, offset, 1,
+ tvb_get_guint8(tvb, offset),
+ "%u seconds",
+ tvb_get_guint8(tvb, offset));
+ offset += 1;
/* Checksum display & verification code */
- packet_checksum = tvb_get_ntohs(tvb, offset);
data_length = tvb_reported_length(tvb);
@@ -343,29 +336,8 @@ dissect_cdp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
SET_CKSUM_VEC_TVB(cksum_vec[0], tvb, 0, data_length);
}
- computed_checksum = in_cksum(cksum_vec, 1);
- checksum_good = (computed_checksum == 0);
- checksum_bad = !checksum_good;
- if (checksum_good) {
- checksum_item = proto_tree_add_uint_format_value(cdp_tree,
- hf_cdp_checksum, tvb, offset, 2, packet_checksum,
- "0x%04x [correct]", packet_checksum);
- } else {
- checksum_item = proto_tree_add_uint_format_value(cdp_tree,
- hf_cdp_checksum, tvb, offset, 2, packet_checksum,
- "0x%04x [incorrect, should be 0x%04x]",
- packet_checksum,
- in_cksum_shouldbe(packet_checksum, computed_checksum));
- }
-
- checksum_tree = proto_item_add_subtree(checksum_item, ett_cdp_checksum);
- checksum_item = proto_tree_add_boolean(checksum_tree, hf_cdp_checksum_good,
- tvb, offset, 2, checksum_good);
- PROTO_ITEM_SET_GENERATED(checksum_item);
- checksum_item = proto_tree_add_boolean(checksum_tree, hf_cdp_checksum_bad,
- tvb, offset, 2, checksum_bad);
- PROTO_ITEM_SET_GENERATED(checksum_item);
-
+ proto_tree_add_checksum(cdp_tree, tvb, offset, hf_cdp_checksum, hf_cdp_checksum_status, NULL, pinfo, in_cksum(cksum_vec, 1),
+ ENC_BIG_ENDIAN, PROTO_CHECKSUM_VERIFY|PROTO_CHECKSUM_IN_CKSUM);
offset += 2;
while (tvb_reported_length_remaining(tvb, offset) != 0) {
@@ -1290,13 +1262,9 @@ proto_register_cdp(void)
{ "Checksum", "cdp.checksum", FT_UINT16, BASE_HEX, NULL, 0x0,
NULL, HFILL }},
- { &hf_cdp_checksum_good,
- { "Good", "cdp.checksum_good", FT_BOOLEAN, BASE_NONE, NULL, 0x0,
- "True: checksum matches packet content; False: doesn't match content or not checked", HFILL }},
-
- { &hf_cdp_checksum_bad,
- { "Bad", "cdp.checksum_bad", FT_BOOLEAN, BASE_NONE, NULL, 0x0,
- "True: checksum doesn't match packet content; False: matches content or not checked", HFILL }},
+ { &hf_cdp_checksum_status,
+ { "Checksum Status", "cdp.checksum.status", FT_UINT8, BASE_NONE, VALS(proto_checksum_vals), 0x0,
+ NULL, HFILL }},
{ &hf_cdp_tlvtype,
{ "Type", "cdp.tlv.type", FT_UINT16, BASE_HEX, VALS(type_vals), 0x0,
diff --git a/epan/dissectors/packet-cfdp.c b/epan/dissectors/packet-cfdp.c
index af727f003b..82ee1512fd 100644
--- a/epan/dissectors/packet-cfdp.c
+++ b/epan/dissectors/packet-cfdp.c
@@ -927,7 +927,7 @@ static guint32 dissect_cfdp_eof_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tre
col_add_fstr(pinfo->cinfo, COL_INFO, "EOF (%s)", val_to_str_const((aux_byte & 0xF0) >> 4, cfdp_condition_codes, "Reserved Code"));
- proto_tree_add_item(tree, hf_cfdp_file_checksum, tvb, offset, 4, ENC_BIG_ENDIAN);
+ proto_tree_add_checksum(tree, tvb, offset, hf_cfdp_file_checksum, -1, NULL, pinfo, 0, ENC_BIG_ENDIAN, PROTO_CHECKSUM_NO_FLAGS);
offset += 4;
proto_tree_add_item(tree, hf_cfdp_file_size, tvb, offset, 4, ENC_BIG_ENDIAN);
diff --git a/epan/dissectors/packet-clnp.c b/epan/dissectors/packet-clnp.c
index 99997180ad..94b95cb54c 100644
--- a/epan/dissectors/packet-clnp.c
+++ b/epan/dissectors/packet-clnp.c
@@ -221,7 +221,7 @@ dissect_clnp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_
guint16 segment_offset = 0;
guint16 total_length;
guint16 cnf_cksum;
- cksum_status_t cksum_status;
+ gboolean cksum_valid = TRUE;
int offset;
guchar src_len, dst_len, nsel, opt_len = 0;
guint next_length;
@@ -320,39 +320,19 @@ dissect_clnp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_
return 7;
}
cnf_cksum = tvb_get_ntohs(tvb, P_CLNP_CKSUM);
- cksum_status = calc_checksum(tvb, 0, cnf_hdr_len, cnf_cksum);
- switch (cksum_status) {
- default:
- /*
- * No checksum present, or not enough of the header present to
- * checksum it.
- */
- proto_tree_add_uint(clnp_tree, hf_clnp_checksum, tvb,
- P_CLNP_CKSUM, 2,
- cnf_cksum);
- break;
+ if (cnf_cksum == 0) {
+ /* No checksum present */
+ proto_tree_add_checksum(clnp_tree, tvb, P_CLNP_CKSUM, hf_clnp_checksum, -1, NULL, pinfo, 0, ENC_BIG_ENDIAN, PROTO_CHECKSUM_NOT_PRESENT);
+ } else {
+ guint32 c0 = 0, c1 = 0;
- case CKSUM_OK:
- /*
- * Checksum is correct.
- */
- proto_tree_add_uint_format_value(clnp_tree, hf_clnp_checksum, tvb,
- P_CLNP_CKSUM, 2,
- cnf_cksum,
- "0x%04x (correct)",
- cnf_cksum);
- break;
-
- case CKSUM_NOT_OK:
- /*
- * Checksum is not correct.
- */
- proto_tree_add_uint_format_value(clnp_tree, hf_clnp_checksum, tvb,
- P_CLNP_CKSUM, 2,
- cnf_cksum,
- "0x%04x (incorrect)",
- cnf_cksum);
- break;
+ if (osi_calc_checksum(tvb, 0, cnf_hdr_len, &c0, &c1)) {
+ /* Successfully processed checksum, verify it */
+ proto_tree_add_checksum(clnp_tree, tvb, P_CLNP_CKSUM, hf_clnp_checksum, -1, NULL, pinfo, c0 | c1, ENC_BIG_ENDIAN, PROTO_CHECKSUM_VERIFY|PROTO_CHECKSUM_ZERO);
+ cksum_valid = (c0 | c1) ? FALSE : TRUE;
+ } else {
+ proto_tree_add_checksum(clnp_tree, tvb, P_CLNP_CKSUM, hf_clnp_checksum, -1, NULL, pinfo, 0, ENC_BIG_ENDIAN, PROTO_CHECKSUM_NO_FLAGS);
+ }
}
opt_len = cnf_hdr_len;
@@ -475,7 +455,7 @@ dissect_clnp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_
((cnf_type & CNF_MORE_SEGS) || segment_offset != 0) &&
tvb_bytes_exist(tvb, offset, segment_length - cnf_hdr_len) &&
segment_length > cnf_hdr_len &&
- cksum_status != CKSUM_NOT_OK) {
+ cksum_valid != FALSE) {
fd_head = fragment_add_check(&clnp_reassembly_table,
tvb, offset, pinfo, du_id, NULL,
segment_offset, segment_length - cnf_hdr_len,
diff --git a/epan/dissectors/packet-dccp.c b/epan/dissectors/packet-dccp.c
index 0ff2021087..779845d001 100644
--- a/epan/dissectors/packet-dccp.c
+++ b/epan/dissectors/packet-dccp.c
@@ -175,7 +175,7 @@ static int hf_dccp_data_offset = -1;
static int hf_dccp_ccval = -1;
static int hf_dccp_cscov = -1;
static int hf_dccp_checksum = -1;
-static int hf_dccp_checksum_bad = -1;
+static int hf_dccp_checksum_status = -1;
static int hf_dccp_res1 = -1;
static int hf_dccp_type = -1;
static int hf_dccp_x = -1;
@@ -600,7 +600,6 @@ dissect_dccp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_
proto_item *hidden_item, *offset_item;
vec_t cksum_vec[4];
guint32 phdr[2];
- guint16 computed_cksum;
guint offset = 0;
guint len = 0;
guint reported_len = 0;
@@ -695,30 +694,11 @@ dissect_dccp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_
break;
}
SET_CKSUM_VEC_TVB(cksum_vec[3], tvb, 0, csum_coverage_len);
- computed_cksum = in_cksum(&cksum_vec[0], 4);
- if (computed_cksum == 0) {
- proto_tree_add_uint_format_value(dccp_tree,
- hf_dccp_checksum, tvb,
- offset, 2,
- dccph->checksum,
- "0x%04x [correct]",
- dccph->checksum);
- } else {
- hidden_item =
- proto_tree_add_boolean(dccp_tree, hf_dccp_checksum_bad,
- tvb, offset, 2, TRUE);
- PROTO_ITEM_SET_HIDDEN(hidden_item);
- proto_tree_add_uint_format_value(
- dccp_tree, hf_dccp_checksum, tvb, offset, 2,
- dccph->checksum,
- "0x%04x [incorrect, should be 0x%04x]",
- dccph->checksum,
- in_cksum_shouldbe(dccph->checksum, computed_cksum));
- }
+ proto_tree_add_checksum(dccp_tree, tvb, offset, hf_dccp_checksum, hf_dccp_checksum_status, NULL, pinfo, in_cksum(&cksum_vec[0], 4),
+ ENC_BIG_ENDIAN, PROTO_CHECKSUM_VERIFY|PROTO_CHECKSUM_IN_CKSUM);
} else {
- proto_tree_add_uint_format_value(dccp_tree, hf_dccp_checksum, tvb,
- offset, 2, dccph->checksum,
- "0x%04x", dccph->checksum);
+ proto_tree_add_checksum(dccp_tree, tvb, offset, hf_dccp_checksum, hf_dccp_checksum_status, NULL, pinfo, 0,
+ ENC_BIG_ENDIAN, PROTO_CHECKSUM_NO_FLAGS);
}
offset += 2;
@@ -1078,10 +1058,10 @@ proto_register_dccp(void)
}
},
{
- &hf_dccp_checksum_bad,
+ &hf_dccp_checksum_status,
{
- "Bad Checksum", "dccp.checksum_bad",
- FT_BOOLEAN, BASE_NONE, NULL, 0x0,
+ "Checksum Status", "dccp.checksum.status",
+ FT_UINT8, BASE_NONE, VALS(proto_checksum_vals), 0x0,
NULL, HFILL
}
},
diff --git a/epan/dissectors/packet-dec-dnart.c b/epan/dissectors/packet-dec-dnart.c
index 1738f7e70e..6c476f94ad 100644
--- a/epan/dissectors/packet-dec-dnart.c
+++ b/epan/dissectors/packet-dec-dnart.c
@@ -123,6 +123,7 @@ static int hf_dec_rt_reserved = -1;
static int hf_dec_rt_fcnval = -1;
static int hf_dec_rt_test_data = -1;
static int hf_dec_rt_segment = -1;
+static int hf_dec_rt_checksum = -1;
static int hf_dec_rt_id = -1;
static int hf_dec_rt_iinfo = -1;
static int hf_dec_rt_iinfo_node_type = -1;
@@ -632,7 +633,6 @@ do_routing_msg(
{
guint my_offset = offset;
guint32 my_checksum = 1;
- guint16 checksum;
guint16 count, startid, rtginfo;
guint remainder_count;
@@ -667,18 +667,8 @@ do_routing_msg(
/* fold 32 bit sum into 16 bits */
while (my_checksum>>16)
my_checksum = (my_checksum & 0xffff) + (my_checksum >> 16);
- checksum = tvb_get_letohs(tvb, my_offset);
- if (checksum != my_checksum) {
- proto_tree_add_none_format(tree, hf_dec_rt_segment, tvb,
- my_offset, 2,
- "Checksum mismatch(computed 0x%x <> received 0x%x)",
- my_checksum, checksum);
- } else {
- proto_tree_add_none_format(tree, hf_dec_rt_segment, tvb,
- my_offset, 2,
- "Checksum: match (computed 0x%x = received 0x%x)",
- my_checksum, checksum);
- }
+
+ proto_tree_add_checksum(tree, tvb, my_offset, hf_dec_rt_checksum, -1, NULL, pinfo, my_checksum, ENC_LITTLE_ENDIAN, PROTO_CHECKSUM_VERIFY);
my_offset += 2;
return (my_offset);
}
@@ -1343,6 +1333,10 @@ proto_register_dec_rt(void)
{ "Segment", "dec_dna.ctl.segment",
FT_NONE, BASE_NONE, NULL, 0x0,
"Routing Segment", HFILL }},
+ { &hf_dec_rt_checksum,
+ { "Checksum", "dec_dna.ctl.checksum",
+ FT_UINT16, BASE_HEX, NULL, 0x0,
+ NULL, HFILL }},
{ &hf_dec_rt_id,
{ "Transmitting system ID", "dec_dna.ctl.id",
FT_ETHER, BASE_NONE, NULL, 0x0,
diff --git a/epan/dissectors/packet-dji-uav.c b/epan/dissectors/packet-dji-uav.c
index 75030abeb1..dc7b81e6a5 100644
--- a/epan/dissectors/packet-dji-uav.c
+++ b/epan/dissectors/packet-dji-uav.c
@@ -245,8 +245,7 @@ dissect_djiuav_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *da
offset += pdu_length - 1 - offset;
}
/* FIXME: calculate XOR and validate transmitted value */
- proto_tree_add_item(djiuav_tree, hf_djiuav_checksum, tvb, offset, 1,
- ENC_BIG_ENDIAN);
+ proto_tree_add_checksum(djiuav_tree, tvb, offset, hf_djiuav_checksum, -1, NULL, pinfo, 0, ENC_BIG_ENDIAN, PROTO_CHECKSUM_NO_FLAGS);
offset += 1;
}
diff --git a/epan/dissectors/packet-dmp.c b/epan/dissectors/packet-dmp.c
index aa19f85d36..bdad234635 100644
--- a/epan/dissectors/packet-dmp.c
+++ b/epan/dissectors/packet-dmp.c
@@ -358,8 +358,7 @@ static int hf_ack_diagnostic = -1;
static int hf_ack_recips = -1;
static int hf_checksum = -1;
-static int hf_checksum_good = -1;
-static int hf_checksum_bad = -1;
+static int hf_checksum_status = -1;
static int hf_analysis_ack_time = -1;
static int hf_analysis_total_time = -1;
@@ -371,10 +370,10 @@ static int hf_analysis_retrans_no = -1;
static int hf_analysis_ack_num = -1;
static int hf_analysis_ack_missing = -1;
static int hf_analysis_ack_dup_no = -1;
-static int hf_analysis_rep_num = -1;
+/* static int hf_analysis_rep_num = -1; */
static int hf_analysis_acks_rep_num = -1;
static int hf_analysis_rep_time = -1;
-static int hf_analysis_not_num = -1;
+/* static int hf_analysis_not_num = -1; */
static int hf_analysis_acks_not_num = -1;
static int hf_analysis_not_time = -1;
static int hf_analysis_msg_resend_from = -1;
@@ -475,8 +474,6 @@ static gint ett_notif_acp127recip = -1;
static gint ett_ack = -1;
static gint ett_ack_recips = -1;
-static gint ett_checksum = -1;
-
static gint ett_analysis = -1;
static expert_field ei_reserved_value = EI_INIT;
@@ -3968,8 +3965,8 @@ static gint dissect_dmp_extensions (tvbuff_t *tvb, packet_info *pinfo _U_,
static int dissect_dmp (tvbuff_t *tvb, packet_info *pinfo,
proto_tree *tree, void *data _U_)
{
- proto_tree *dmp_tree = NULL, *checksum_tree = NULL;
- proto_item *ti = NULL, *en = NULL;
+ proto_tree *dmp_tree;
+ proto_item *ti;
guint16 checksum1 = 0, checksum2 = 1;
gint length, offset = 0;
gboolean retrans_or_dup_ack = FALSE;
@@ -4006,29 +4003,8 @@ static int dissect_dmp (tvbuff_t *tvb, packet_info *pinfo,
if (dmp.checksum) {
length = tvb_captured_length (tvb);
checksum1 = crc16_x25_ccitt_tvb (tvb, length - 2);
- checksum2 = tvb_get_ntohs (tvb, offset);
-
- en = proto_tree_add_item (dmp_tree, hf_checksum, tvb, offset, 2, ENC_BIG_ENDIAN);
- checksum_tree = proto_item_add_subtree (en, ett_checksum);
- if (checksum1 == checksum2) {
- proto_item_append_text (en, " (correct)");
- en = proto_tree_add_boolean (checksum_tree, hf_checksum_good, tvb,
- offset, 2, TRUE);
- PROTO_ITEM_SET_GENERATED (en);
- en = proto_tree_add_boolean (checksum_tree, hf_checksum_bad, tvb,
- offset, 2, FALSE);
- PROTO_ITEM_SET_GENERATED (en);
- } else {
- proto_item_append_text (en, " (incorrect, should be 0x%04x)",
- checksum1);
- expert_add_info(pinfo, en, &ei_checksum_bad);
- en = proto_tree_add_boolean (checksum_tree, hf_checksum_good, tvb,
- offset, 2, FALSE);
- PROTO_ITEM_SET_GENERATED (en);
- en = proto_tree_add_boolean (checksum_tree, hf_checksum_bad, tvb,
- offset, 2, TRUE);
- PROTO_ITEM_SET_GENERATED (en);
- }
+
+ proto_tree_add_checksum(dmp_tree, tvb, offset, hf_checksum, hf_checksum_status, &ei_checksum_bad, pinfo, checksum1, ENC_BIG_ENDIAN, PROTO_CHECKSUM_VERIFY);
offset += 2;
}
@@ -4773,12 +4749,9 @@ void proto_register_dmp (void)
{ &hf_checksum,
{ "Checksum", "dmp.checksum", FT_UINT16, BASE_HEX,
NULL, 0x0, NULL, HFILL } },
- { &hf_checksum_good,
- { "Good", "dmp.checksum_good", FT_BOOLEAN, BASE_NONE,
- NULL, 0x0, "True: checksum matches packet content; False: doesn't match content or not checked", HFILL } },
- { &hf_checksum_bad,
- { "Bad", "dmp.checksum_bad", FT_BOOLEAN, BASE_NONE,
- NULL, 0x0, "True: checksum doesn't match packet content; False: matches content or not checked", HFILL } },
+ { &hf_checksum_status,
+ { "Checksum Status", "dmp.checksum.status", FT_UINT8, BASE_NONE,
+ VALS(proto_checksum_vals), 0x0, NULL, HFILL } },
/*
** Ack matching / Resend
@@ -4810,15 +4783,17 @@ void proto_register_dmp (void)
{ &hf_analysis_ack_num,
{ "Acknowledgement in", "dmp.analysis.ack_in", FT_FRAMENUM, BASE_NONE,
NULL, 0x0, "This packet has an Acknowledgement in this frame", HFILL } },
- { &hf_analysis_rep_num,
- { "Report in", "dmp.analysis.report_in", FT_FRAMENUM, BASE_NONE,
- NULL, 0x0, "This packet has a Report in this frame", HFILL } },
{ &hf_analysis_acks_rep_num,
{ "This is an Ack to the Report in", "dmp.analysis.acks_report_in", FT_FRAMENUM, BASE_NONE,
FRAMENUM_TYPE(FT_FRAMENUM_ACK), 0x0, "This packet ACKs a Report in this frame", HFILL } },
+#if 0
+ { &hf_analysis_rep_num,
+ { "Report in", "dmp.analysis.report_in", FT_FRAMENUM, BASE_NONE,
+ NULL, 0x0, "This packet has a Report in this frame", HFILL } },
{ &hf_analysis_not_num,
{ "Notification in", "dmp.analysis.notif_in", FT_FRAMENUM, BASE_NONE,
NULL, 0x0, "This packet has a Notification in this frame", HFILL } },
+#endif
{ &hf_analysis_acks_not_num,
{ "This is an Ack to the Notification in", "dmp.analysis.acks_notif_in", FT_FRAMENUM, BASE_NONE,
FRAMENUM_TYPE(FT_FRAMENUM_ACK), 0x0, "This packet ACKs a Notification in this frame", HFILL } },
@@ -4962,7 +4937,6 @@ void proto_register_dmp (void)
&ett_notif_acp127recip,
&ett_ack,
&ett_ack_recips,
- &ett_checksum,
&ett_analysis
};
diff --git a/epan/dissectors/packet-dmx.c b/epan/dissectors/packet-dmx.c
index 0e6900a86f..7b3fe46414 100644
--- a/epan/dissectors/packet-dmx.c
+++ b/epan/dissectors/packet-dmx.c
@@ -92,8 +92,7 @@ static int hf_dmx_sip_fourth_dev_id = -1;
static int hf_dmx_sip_fifth_dev_id = -1;
static int hf_dmx_sip_reserved = -1;
static int hf_dmx_sip_checksum = -1;
-static int hf_dmx_sip_checksum_good = -1;
-static int hf_dmx_sip_checksum_bad = -1;
+static int hf_dmx_sip_checksum_status = -1;
static int hf_dmx_sip_trailer = -1;
static int hf_dmx_test_data = -1;
@@ -201,9 +200,6 @@ dissect_dmx_sip(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data
if (tree != NULL) {
guint offset = 0;
guint byte_count;
- guint checksum, checksum_shouldbe;
- proto_item *item;
- proto_tree *checksum_tree;
proto_tree *ti = proto_tree_add_item(tree, proto_dmx_sip, tvb,
offset, -1, ENC_NA);
@@ -273,34 +269,7 @@ dissect_dmx_sip(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data
offset += (byte_count - offset);
}
- dmx_sip_checksum(tvb, offset);
-
- checksum_shouldbe = dmx_sip_checksum(tvb, offset);
- checksum = tvb_get_guint8(tvb, offset);
- item = proto_tree_add_item(dmx_sip_tree, hf_dmx_sip_checksum, tvb,
- offset, 1, ENC_BIG_ENDIAN);
- if (checksum == checksum_shouldbe) {
- proto_item_append_text(item, " [correct]");
-
- checksum_tree = proto_item_add_subtree(item, ett_dmx_sip);
- item = proto_tree_add_boolean(checksum_tree, hf_dmx_sip_checksum_good, tvb,
- offset, 1, TRUE);
- PROTO_ITEM_SET_GENERATED(item);
- item = proto_tree_add_boolean(checksum_tree, hf_dmx_sip_checksum_bad, tvb,
- offset, 1, FALSE);
- PROTO_ITEM_SET_GENERATED(item);
- } else {
- proto_item_append_text(item, " [incorrect, should be 0x%02x]", checksum_shouldbe);
-
- checksum_tree = proto_item_add_subtree(item, ett_dmx_sip);
- item = proto_tree_add_boolean(checksum_tree, hf_dmx_sip_checksum_good, tvb,
- offset, 1, FALSE);
- PROTO_ITEM_SET_GENERATED(item);
- item = proto_tree_add_boolean(checksum_tree, hf_dmx_sip_checksum_bad, tvb,
- offset, 1, TRUE);
- PROTO_ITEM_SET_GENERATED(item);
- }
-
+ proto_tree_add_checksum(dmx_sip_tree, tvb, offset, hf_dmx_sip_checksum, hf_dmx_sip_checksum_status, NULL, pinfo, dmx_sip_checksum(tvb, offset), ENC_NA, PROTO_CHECKSUM_VERIFY);
offset += 1;
if (offset < tvb_reported_length(tvb))
@@ -600,15 +569,10 @@ proto_register_dmx_sip(void)
FT_UINT8, BASE_HEX, NULL, 0x0,
NULL, HFILL }},
- { &hf_dmx_sip_checksum_good,
- { "Good Checksum", "dmx_sip.checksum_good",
- FT_BOOLEAN, BASE_NONE, NULL, 0x0,
- "True: checksum matches packet content; False: doesn't match content", HFILL }},
-
- { &hf_dmx_sip_checksum_bad,
- { "Bad Checksum", "dmx_sip.checksum_bad",
- FT_BOOLEAN, BASE_NONE, NULL, 0x0,
- "True: checksum doesn't match packet content; False: matches content", HFILL }},
+ { &hf_dmx_sip_checksum_status,
+ { "Checksum Status", "dmx_sip.checksum.status",
+ FT_UINT8, BASE_NONE, VALS(proto_checksum_vals), 0x0,
+ NULL, HFILL }},
{ &hf_dmx_sip_trailer,
{ "Trailer", "dmx_sip.trailer",
diff --git a/epan/dissectors/packet-dvb-s2-bb.c b/epan/dissectors/packet-dvb-s2-bb.c
index 1dc0f2fb09..71d4c1dbd1 100644
--- a/epan/dissectors/packet-dvb-s2-bb.c
+++ b/epan/dissectors/packet-dvb-s2-bb.c
@@ -784,13 +784,9 @@ static int dissect_dvb_s2_bb(tvbuff_t *tvb, int cur_off, proto_tree *tree, packe
input8 = tvb_get_guint8(tvb, cur_off + DVB_S2_BB_OFFS_CRC);
new_off += 1;
- if (check_crc8(tvb, DVB_S2_BB_HEADER_LEN - 1, cur_off, input8)) {
- proto_tree_add_uint_format(dvb_s2_bb_tree, hf_dvb_s2_bb_crc, tvb,
- cur_off + DVB_S2_BB_OFFS_CRC, 1, 1, "Checksum: correct (0x%2.2x)", input8);
- } else {
- proto_tree_add_uint_format(dvb_s2_bb_tree, hf_dvb_s2_bb_crc, tvb,
- cur_off + DVB_S2_BB_OFFS_CRC, 1, -1, "Checksum: incorrect! (0x%2.2x)", input8);
- }
+
+ proto_tree_add_checksum(dvb_s2_bb_tree, tvb, cur_off + DVB_S2_BB_OFFS_CRC, hf_dvb_s2_bb_crc, -1, NULL, pinfo,
+ check_crc8(tvb, DVB_S2_BB_HEADER_LEN - 1, cur_off, input8), ENC_NA, PROTO_CHECKSUM_VERIFY);
while (bb_data_len) {
/* start DVB-GSE dissector */
@@ -987,7 +983,7 @@ void proto_register_dvb_s2_modeadapt(void)
"Distance to first user packet", HFILL}
},
{&hf_dvb_s2_bb_crc, {
- "CRC", "dvb-s2_bb.crc",
+ "Checksum", "dvb-s2_bb.crc",
FT_UINT8, BASE_HEX, NULL, 0x0,
"CRC-8", HFILL}
}
diff --git a/epan/dissectors/packet-dvmrp.c b/epan/dissectors/packet-dvmrp.c
index e115339922..fead40077f 100644
--- a/epan/dissectors/packet-dvmrp.c
+++ b/epan/dissectors/packet-dvmrp.c
@@ -63,7 +63,7 @@ static int hf_version = -1;
static int hf_type = -1;
static int hf_code_v1 = -1;
static int hf_checksum = -1;
-static int hf_checksum_bad = -1;
+static int hf_checksum_status = -1;
static int hf_reserved = -1;
static int hf_commands = -1;
static int hf_command = -1;
@@ -336,7 +336,7 @@ dissect_dvmrp_v3(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, int
"Unknown Type:0x%02x"));
/* checksum */
- igmp_checksum(parent_tree, tvb, hf_checksum, hf_checksum_bad, pinfo, 0);
+ igmp_checksum(parent_tree, tvb, hf_checksum, hf_checksum_status, pinfo, 0);
offset += 2;
/* skip unused byte */
@@ -525,7 +525,7 @@ dissect_dvmrp_v1(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, int
"Unknown Type:0x%02x"));
/* checksum */
- igmp_checksum(parent_tree, tvb, hf_checksum, hf_checksum_bad, pinfo, 0);
+ igmp_checksum(parent_tree, tvb, hf_checksum, hf_checksum_status, pinfo, 0);
offset += 2;
/* decode all the v1 commands */
@@ -720,9 +720,9 @@ proto_register_dvmrp(void)
{ "Checksum", "dvmrp.checksum", FT_UINT16, BASE_HEX,
NULL, 0, "DVMRP Checksum", HFILL }},
- { &hf_checksum_bad,
- { "Bad Checksum", "dvmrp.checksum_bad", FT_BOOLEAN, BASE_NONE,
- NULL, 0x0, "Bad DVMRP Checksum", HFILL }},
+ { &hf_checksum_status,
+ { "Checksum Status", "dvmrp.checksum.status", FT_UINT8, BASE_NONE,
+ VALS(proto_checksum_vals), 0x0, NULL, HFILL }},
{ &hf_reserved,
{ "Reserved", "dvmrp.reserved", FT_UINT16, BASE_HEX,
diff --git a/epan/dissectors/packet-eigrp.c b/epan/dissectors/packet-eigrp.c
index b42d23d1e3..a925930b6e 100644
--- a/epan/dissectors/packet-eigrp.c
+++ b/epan/dissectors/packet-eigrp.c
@@ -2416,9 +2416,9 @@ static int
dissect_eigrp (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_)
{
proto_item *ti;
- proto_tree *eigrp_tree = NULL, *tlv_tree;
+ proto_tree *eigrp_tree, *tlv_tree;
guint opcode, vrid;
- guint16 tlv, checksum, cacl_checksum;
+ guint16 tlv;
guint32 ack, size, offset = EIGRP_HEADER_LENGTH;
/* Make entries in Protocol column and Info column on summary display */
@@ -2463,18 +2463,7 @@ dissect_eigrp (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _
ENC_BIG_ENDIAN);
size = tvb_captured_length(tvb);
- checksum = tvb_get_ntohs(tvb, 2);
- cacl_checksum = ip_checksum_tvb(tvb, 0, size);
-
- if (cacl_checksum == checksum) {
- proto_tree_add_uint_format_value(eigrp_tree, hf_eigrp_checksum, tvb, 2, 2,
- checksum, "0x%02x [incorrect]",
- checksum);
- expert_add_info(pinfo, ti, &ei_eigrp_checksum_bad);
- } else {
- proto_tree_add_uint_format_value(eigrp_tree, hf_eigrp_checksum, tvb, 2, 2,
- checksum, "0x%02x [correct]", checksum);
- }
+ proto_tree_add_checksum(eigrp_tree, tvb, 2, hf_eigrp_checksum, -1, &ei_eigrp_checksum_bad, pinfo, ip_checksum_tvb(tvb, 0, size), ENC_BIG_ENDIAN, PROTO_CHECKSUM_VERIFY);
/* Decode the EIGRP Flags Field */
proto_tree_add_bitmask(eigrp_tree, tvb, 4, hf_eigrp_flags, ett_eigrp_flags,
diff --git a/epan/dissectors/packet-epon.c b/epan/dissectors/packet-epon.c
index 5bc4046dca..be29d7ba18 100644
--- a/epan/dissectors/packet-epon.c
+++ b/epan/dissectors/packet-epon.c
@@ -172,16 +172,8 @@ dissect_epon(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
sent_checksum = tvb_get_guint8(tvb, 5+offset);
checksum = get_crc8_ieee8023_epon(tvb, 5, 0+offset);
- if (sent_checksum == checksum) {
- proto_tree_add_uint_format_value(epon_tree, hf_epon_checksum, tvb,
- 5+offset, 1, sent_checksum,
- "0x%01x [correct]", sent_checksum);
- } else {
- item = proto_tree_add_uint_format_value(epon_tree, hf_epon_checksum, tvb,
- 5+offset, 1, sent_checksum,
- "0x%01x [incorrect, should be 0x%01x]",
- sent_checksum, checksum);
- expert_add_info(pinfo, item, &ei_epon_checksum_bad);
+ proto_tree_add_checksum(epon_tree, tvb, 5+offset, hf_epon_checksum, -1, &ei_epon_checksum_bad, pinfo, checksum, ENC_NA, PROTO_CHECKSUM_VERIFY);
+ if (sent_checksum != checksum) {
col_append_str(pinfo->cinfo, COL_INFO, " [EPON PREAMBLE CHECKSUM INCORRECT]");
}
diff --git a/epan/dissectors/packet-esis.c b/epan/dissectors/packet-esis.c
index 759c1dcef5..67e7ea4d41 100644
--- a/epan/dissectors/packet-esis.c
+++ b/epan/dissectors/packet-esis.c
@@ -250,7 +250,6 @@ dissect_esis(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_
proto_tree *esis_tree = NULL;
guint8 variable_len, type;
guint16 holdtime, checksum;
- const char *cksum_status;
col_set_str(pinfo->cinfo, COL_PROTOCOL, "ESIS");
col_clear(pinfo->cinfo, COL_INFO);
@@ -285,31 +284,19 @@ dissect_esis(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_
holdtime, "%u seconds", holdtime);
checksum = tvb_get_ntohs(tvb, 7);
- switch (calc_checksum( tvb, 0, length, checksum)) {
-
- case NO_CKSUM:
- cksum_status = "Not Used";
- break;
-
- case DATA_MISSING:
- cksum_status = "Not checkable - not all of packet was captured";
- break;
-
- case CKSUM_OK:
- cksum_status = "Is good";
- break;
-
- case CKSUM_NOT_OK:
- cksum_status = "Is wrong";
- break;
-
- default:
- cksum_status = NULL;
- DISSECTOR_ASSERT_NOT_REACHED();
+ if (checksum == 0) {
+ /* No checksum present */
+ proto_tree_add_checksum(esis_tree, tvb, 7, hf_esis_checksum, -1, NULL, pinfo, 0, ENC_BIG_ENDIAN, PROTO_CHECKSUM_NOT_PRESENT);
+ } else {
+ guint32 c0 = 0, c1 = 0;
+
+ if (osi_calc_checksum(tvb, 0, length, &c0, &c1)) {
+ /* Successfully processed checksum, verify it */
+ proto_tree_add_checksum(esis_tree, tvb, 7, hf_esis_checksum, -1, NULL, pinfo, c0 | c1, ENC_BIG_ENDIAN, PROTO_CHECKSUM_VERIFY|PROTO_CHECKSUM_ZERO);
+ } else {
+ proto_tree_add_checksum(esis_tree, tvb, 7, hf_esis_checksum, -1, NULL, pinfo, 0, ENC_BIG_ENDIAN, PROTO_CHECKSUM_NO_FLAGS);
+ }
}
- proto_tree_add_uint_format_value( esis_tree, hf_esis_checksum, tvb, 7, 2,
- checksum, "0x%x ( %s )", checksum, cksum_status );
-
/*
* Let us make sure we use the same names for all our decodes
diff --git a/epan/dissectors/packet-eth.c b/epan/dissectors/packet-eth.c
index bfb6cc5270..4d82e8f448 100644
--- a/epan/dissectors/packet-eth.c
+++ b/epan/dissectors/packet-eth.c
@@ -78,14 +78,12 @@ static int hf_eth_ig = -1;
static int hf_eth_padding = -1;
static int hf_eth_trailer = -1;
static int hf_eth_fcs = -1;
-static int hf_eth_fcs_good = -1;
-static int hf_eth_fcs_bad = -1;
+static int hf_eth_fcs_status = -1;
static gint ett_ieee8023 = -1;
static gint ett_ether2 = -1;
static gint ett_ether = -1;
static gint ett_addr = -1;
-static gint ett_eth_fcs = -1;
static expert_field ei_eth_invalid_lentype = EI_INIT;
static expert_field ei_eth_src_not_group = EI_INIT;
@@ -647,8 +645,6 @@ add_ethernet_trailer(packet_info *pinfo, proto_tree *tree, proto_tree *fh_tree,
have had 64 or more bytes - i.e., it was at least an FCS worth of data
longer than the minimum payload size - we could assume the last 4 bytes
of the trailer are an FCS. */
- proto_item *item;
- proto_tree *checksum_tree;
heur_dtbl_entry_t *hdtbl_entry;
if (trailer_tvb) {
@@ -749,43 +745,13 @@ add_ethernet_trailer(packet_info *pinfo, proto_tree *tree, proto_tree *fh_tree,
guint32 sent_fcs = tvb_get_ntohl(trailer_tvb, padding_length+trailer_length);
if(eth_check_fcs){
guint32 fcs = crc32_802_tvb(tvb, tvb_captured_length(tvb) - 4);
- if (fcs == sent_fcs) {
- item = proto_tree_add_uint_format_value(fh_tree, hf_eth_fcs, trailer_tvb,
- padding_length+trailer_length, 4, sent_fcs,
- "0x%08x [correct]", sent_fcs);
- checksum_tree = proto_item_add_subtree(item, ett_eth_fcs);
- item = proto_tree_add_boolean(checksum_tree, hf_eth_fcs_good, trailer_tvb,
- padding_length+trailer_length, 4, TRUE);
- PROTO_ITEM_SET_GENERATED(item);
- item = proto_tree_add_boolean(checksum_tree, hf_eth_fcs_bad, trailer_tvb,
- padding_length+trailer_length, 4, FALSE);
- PROTO_ITEM_SET_GENERATED(item);
- } else {
- item = proto_tree_add_uint_format_value(fh_tree, hf_eth_fcs, trailer_tvb,
- padding_length+trailer_length, 4, sent_fcs,
- "0x%08x [incorrect, should be 0x%08x]",
- sent_fcs, fcs);
- checksum_tree = proto_item_add_subtree(item, ett_eth_fcs);
- item = proto_tree_add_boolean(checksum_tree, hf_eth_fcs_good, trailer_tvb,
- padding_length+trailer_length, 4, FALSE);
- PROTO_ITEM_SET_GENERATED(item);
- item = proto_tree_add_boolean(checksum_tree, hf_eth_fcs_bad, trailer_tvb,
- padding_length+trailer_length, 4, TRUE);
- PROTO_ITEM_SET_GENERATED(item);
- expert_add_info(pinfo, item, &ei_eth_fcs_bad);
+ proto_tree_add_checksum(fh_tree, trailer_tvb, padding_length+trailer_length, hf_eth_fcs, hf_eth_fcs_status, &ei_eth_fcs_bad, pinfo, fcs, ENC_BIG_ENDIAN, PROTO_CHECKSUM_VERIFY);
+
+ if (fcs != sent_fcs) {
col_append_str(pinfo->cinfo, COL_INFO, " [ETHERNET FRAME CHECK SEQUENCE INCORRECT]");
}
}else{
- item = proto_tree_add_uint_format_value(fh_tree, hf_eth_fcs, trailer_tvb,
- padding_length+trailer_length, 4, sent_fcs,
- "0x%08x [validation disabled]", sent_fcs);
- checksum_tree = proto_item_add_subtree(item, ett_eth_fcs);
- item = proto_tree_add_boolean(checksum_tree, hf_eth_fcs_good, trailer_tvb,
- padding_length+trailer_length, 4, FALSE);
- PROTO_ITEM_SET_GENERATED(item);
- item = proto_tree_add_boolean(checksum_tree, hf_eth_fcs_bad, trailer_tvb,
- padding_length+trailer_length, 4, FALSE);
- PROTO_ITEM_SET_GENERATED(item);
+ proto_tree_add_checksum(fh_tree, trailer_tvb, padding_length+trailer_length, hf_eth_fcs, hf_eth_fcs_status, &ei_eth_fcs_bad, pinfo, 0, ENC_BIG_ENDIAN, PROTO_CHECKSUM_NO_FLAGS);
}
trailer_length += 4;
}
@@ -919,13 +885,9 @@ proto_register_eth(void)
{ "Frame check sequence", "eth.fcs", FT_UINT32, BASE_HEX, NULL, 0x0,
"Ethernet checksum", HFILL }},
- { &hf_eth_fcs_good,
- { "FCS Good", "eth.fcs_good", FT_BOOLEAN, BASE_NONE, NULL, 0x0,
- "True: checksum matches packet content; False: doesn't match content or not checked", HFILL }},
-
- { &hf_eth_fcs_bad,
- { "FCS Bad", "eth.fcs_bad", FT_BOOLEAN, BASE_NONE, NULL, 0x0,
- "True: checksum doesn't match packet content; False: does match content or not checked", HFILL }},
+ { &hf_eth_fcs_status,
+ { "FCS Status", "eth.fcs.status", FT_UINT8, BASE_NONE, VALS(proto_checksum_vals), 0x0,
+ NULL, HFILL }},
{ &hf_eth_lg,
{ "LG bit", "eth.lg", FT_BOOLEAN, 24,
@@ -942,13 +904,12 @@ proto_register_eth(void)
&ett_ether2,
&ett_ether,
&ett_addr,
- &ett_eth_fcs
};
static ei_register_info ei[] = {
{ &ei_eth_invalid_lentype, { "eth.invalid_lentype.expert", PI_PROTOCOL, PI_WARN, "Invalid length/type", EXPFILL }},
{ &ei_eth_src_not_group, { "eth.src_not_group", PI_PROTOCOL, PI_WARN, "Source MAC must not be a group address: IEEE 802.3-2002, Section 3.2.3(b)", EXPFILL }},
- { &ei_eth_fcs_bad, { "eth.fcs_bad.expert", PI_CHECKSUM, PI_ERROR, "Bad checksum", EXPFILL }},
+ { &ei_eth_fcs_bad, { "eth.fcs_bad", PI_CHECKSUM, PI_ERROR, "Bad checksum", EXPFILL }},
{ &ei_eth_len, { "eth.len.past_end", PI_MALFORMED, PI_ERROR, "Length field value goes past the end of the payload", EXPFILL }},
};
diff --git a/epan/dissectors/packet-extreme.c b/epan/dissectors/packet-extreme.c
index 92693063fa..17a39e52e5 100644
--- a/epan/dissectors/packet-extreme.c
+++ b/epan/dissectors/packet-extreme.c
@@ -159,8 +159,7 @@ static int hf_edp_version = -1;
static int hf_edp_reserved = -1;
static int hf_edp_length = -1;
static int hf_edp_checksum = -1;
-static int hf_edp_checksum_good = -1;
-static int hf_edp_checksum_bad = -1;
+static int hf_edp_checksum_status = -1;
static int hf_edp_seqno = -1;
static int hf_edp_midtype = -1;
@@ -255,7 +254,6 @@ static int hf_edp_null = -1;
static expert_field ei_edp_short_tlv = EI_INIT;
static gint ett_edp = -1;
-static gint ett_edp_checksum = -1;
static gint ett_edp_tlv_header = -1;
static gint ett_edp_display = -1;
static gint ett_edp_info = -1;
@@ -950,11 +948,7 @@ dissect_edp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
{
proto_item *ti;
proto_tree *edp_tree;
- proto_item *checksum_item;
- proto_tree *checksum_tree;
guint32 offset = 0;
- guint16 packet_checksum, computed_checksum;
- gboolean checksum_good, checksum_bad;
gboolean last = FALSE;
guint8 tlv_type;
guint16 tlv_length;
@@ -982,40 +976,18 @@ dissect_edp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
data_length);
offset += 2;
- packet_checksum = tvb_get_ntohs(tvb, offset);
/*
* If we have the entire ESP packet available, check the checksum.
*/
if (tvb_captured_length(tvb) >= data_length) {
/* Checksum from version to null tlv */
SET_CKSUM_VEC_TVB(cksum_vec[0], tvb, 0, data_length);
- computed_checksum = in_cksum(&cksum_vec[0], 1);
- checksum_good = (computed_checksum == 0);
- checksum_bad = !checksum_good;
- if (checksum_good) {
- checksum_item = proto_tree_add_uint_format(edp_tree,
- hf_edp_checksum, tvb, offset, 2, packet_checksum,
- "Checksum: 0x%04x [correct]",
- packet_checksum);
- } else {
- checksum_item = proto_tree_add_uint_format(edp_tree,
- hf_edp_checksum, tvb, offset, 2, packet_checksum,
- "Checksum: 0x%04x [incorrect, should be 0x%04x]",
- packet_checksum,
- in_cksum_shouldbe(packet_checksum, computed_checksum));
- }
+
+ proto_tree_add_checksum(edp_tree, tvb, offset, hf_edp_checksum, hf_edp_checksum_status, NULL, pinfo, in_cksum(&cksum_vec[0], 1),
+ ENC_BIG_ENDIAN, PROTO_CHECKSUM_VERIFY|PROTO_CHECKSUM_IN_CKSUM);
} else {
- checksum_good = checksum_bad = FALSE;
- checksum_item = proto_tree_add_uint(edp_tree, hf_edp_checksum,
- tvb, offset, 2, packet_checksum);
+ proto_tree_add_checksum(edp_tree, tvb, offset, hf_edp_checksum, hf_edp_checksum_status, NULL, pinfo, 0, ENC_BIG_ENDIAN, PROTO_CHECKSUM_NO_FLAGS);
}
- checksum_tree = proto_item_add_subtree(checksum_item, ett_edp_checksum);
- checksum_item = proto_tree_add_boolean(checksum_tree, hf_edp_checksum_good,
- tvb, offset, 2, checksum_good);
- PROTO_ITEM_SET_GENERATED(checksum_item);
- checksum_item = proto_tree_add_boolean(checksum_tree, hf_edp_checksum_bad,
- tvb, offset, 2, checksum_bad);
- PROTO_ITEM_SET_GENERATED(checksum_item);
offset += 2;
seqno = tvb_get_ntohs(tvb, offset);
@@ -1114,13 +1086,9 @@ proto_register_edp(void)
{ "EDP checksum", "edp.checksum", FT_UINT16, BASE_HEX, NULL, 0x0,
NULL, HFILL }},
- { &hf_edp_checksum_good,
- { "Good", "edp.checksum_good", FT_BOOLEAN, BASE_NONE, NULL, 0x0,
- "True: checksum matches packet content; False: doesn't match content or not checked", HFILL }},
-
- { &hf_edp_checksum_bad,
- { "Bad", "edp.checksum_bad", FT_BOOLEAN, BASE_NONE, NULL, 0x0,
- "True: checksum doesn't match packet content; False: matches content or not checked", HFILL }},
+ { &hf_edp_checksum_status,
+ { "EDP checksum status", "edp.checksum.status", FT_UINT8, BASE_NONE, VALS(proto_checksum_vals), 0x0,
+ NULL, HFILL }},
{ &hf_edp_seqno,
{ "Sequence number", "edp.seqno", FT_UINT16, BASE_DEC, NULL,
@@ -1455,7 +1423,6 @@ proto_register_edp(void)
static gint *ett[] = {
&ett_edp,
- &ett_edp_checksum,
&ett_edp_tlv_header,
&ett_edp_vlan_flags,
&ett_edp_display,
diff --git a/epan/dissectors/packet-fc.c b/epan/dissectors/packet-fc.c
index 839b667e3b..7bfb35d79a 100644
--- a/epan/dissectors/packet-fc.c
+++ b/epan/dissectors/packet-fc.c
@@ -1270,37 +1270,28 @@ dissect_fc_ifcp (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data
static int
dissect_fcsof(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_) {
- proto_item *it = NULL;
- proto_tree *fcsof_tree = NULL;
- tvbuff_t *next_tvb, *checksum_tvb;
- guint32 sof = 0;
- guint32 crc = 0;
- guint32 crc_computed = 0;
- guint32 eof = 0;
- gint crc_offset = 0;
- gint eof_offset = 0;
- gint sof_offset = 0;
+ proto_item *it;
+ proto_tree *fcsof_tree;
+ tvbuff_t *next_tvb;
+ guint32 sof;
+ guint32 crc_computed;
+ guint32 eof;
const gint FCSOF_TRAILER_LEN = 8;
const gint FCSOF_HEADER_LEN = 4;
- gint frame_len_for_checksum = 0;
+ gint crc_offset = tvb_reported_length(tvb) - FCSOF_TRAILER_LEN;
+ gint eof_offset = crc_offset + 4;
+ gint sof_offset = 0;
+ gint frame_len_for_checksum;
fc_data_t fc_data;
col_set_str(pinfo->cinfo, COL_PROTOCOL, "FC");
- crc_offset = tvb_reported_length(tvb) - FCSOF_TRAILER_LEN;
- eof_offset = crc_offset + 4;
- sof_offset = 0;
-
/* Get SOF */
sof = tvb_get_ntohl(tvb, 0);
- /* GET CRC */
- crc = tvb_get_ntohl(tvb, crc_offset);
-
/* GET Computed CRC */
frame_len_for_checksum = crc_offset - FCSOF_HEADER_LEN;
- checksum_tvb = tvb_new_subset_length(tvb, 4, frame_len_for_checksum);
- crc_computed = crc32_802_tvb(checksum_tvb, frame_len_for_checksum);
+ crc_computed = crc32_802_tvb(tvb_new_subset_length(tvb, 4, frame_len_for_checksum), frame_len_for_checksum);
/* Get EOF */
eof = tvb_get_ntohl(tvb, eof_offset);
@@ -1314,20 +1305,7 @@ dissect_fcsof(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U
proto_tree_add_uint(fcsof_tree, hf_fcsof, tvb, sof_offset, 4, sof);
- if (crc == crc_computed) {
- proto_tree_add_uint_format_value(fcsof_tree, hf_fccrc, tvb,
- crc_offset, 4, crc,
- "%8.8x [valid]", crc);
- } else {
- it = proto_tree_add_uint_format_value(fcsof_tree, hf_fccrc, tvb,
- crc_offset, 4, crc,
- "%8.8x [error: should be %8.8x]",
- crc, crc_computed);
-
- expert_add_info_format(pinfo, it, &ei_fccrc,
- "Bad FC CRC %8.8x %8.x",
- crc, crc_computed);
- }
+ proto_tree_add_checksum(fcsof_tree, tvb, crc_offset, hf_fccrc, -1, &ei_fccrc, pinfo, crc_computed, ENC_BIG_ENDIAN, PROTO_CHECKSUM_VERIFY);
proto_tree_add_uint(fcsof_tree, hf_fceof, tvb, eof_offset, 4, eof);
diff --git a/epan/dissectors/packet-fcoe.c b/epan/dissectors/packet-fcoe.c
index 08bb769d21..fee88470e4 100644
--- a/epan/dissectors/packet-fcoe.c
+++ b/epan/dissectors/packet-fcoe.c
@@ -95,11 +95,9 @@ static int hf_fcoe_len = -1;
static int hf_fcoe_sof = -1;
static int hf_fcoe_eof = -1;
static int hf_fcoe_crc = -1;
-static int hf_fcoe_crc_bad = -1;
-static int hf_fcoe_crc_good = -1;
+static int hf_fcoe_crc_status = -1;
static int ett_fcoe = -1;
-static int ett_fcoe_crc = -1;
static expert_field ei_fcoe_crc = EI_INIT;
@@ -122,9 +120,7 @@ dissect_fcoe(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_
const char *crc_msg;
const char *len_msg;
proto_item *ti;
- proto_item *item;
proto_tree *fcoe_tree;
- proto_tree *crc_tree;
tvbuff_t *next_tvb;
gboolean crc_exists;
guint32 crc_computed = 0;
@@ -213,34 +209,12 @@ dissect_fcoe(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_
* Create the CRC information.
*/
if (crc_exists) {
- if (crc == crc_computed) {
- item = proto_tree_add_uint_format_value(fcoe_tree, hf_fcoe_crc, tvb,
- crc_offset, 4, crc,
- "%8.8x [valid]", crc);
- } else {
- item = proto_tree_add_uint_format_value(fcoe_tree, hf_fcoe_crc, tvb,
- crc_offset, 4, crc,
- "%8.8x [error: should be %8.8x]",
- crc, crc_computed);
- expert_add_info_format(pinfo, item, &ei_fcoe_crc,
- "Bad FC CRC %8.8x %8.x",
- crc, crc_computed);
- }
+ proto_tree_add_checksum(fcoe_tree, tvb, crc_offset, hf_fcoe_crc, hf_fcoe_crc_status, &ei_fcoe_crc, pinfo, crc_computed, ENC_BIG_ENDIAN, PROTO_CHECKSUM_VERIFY);
proto_tree_set_appendix(fcoe_tree, tvb, crc_offset,
tvb_captured_length_remaining (tvb, crc_offset));
} else {
- item = proto_tree_add_uint_format_value(fcoe_tree, hf_fcoe_crc, tvb, crc_offset, 0,
- 0, "CRC: [missing]");
+ proto_tree_add_checksum(fcoe_tree, tvb, crc_offset, hf_fcoe_crc, hf_fcoe_crc_status, &ei_fcoe_crc, pinfo, 0, ENC_BIG_ENDIAN, PROTO_CHECKSUM_NOT_PRESENT);
}
- crc_tree = proto_item_add_subtree(item, ett_fcoe_crc);
- ti = proto_tree_add_boolean(crc_tree, hf_fcoe_crc_bad, tvb,
- crc_offset, 4,
- crc_exists && crc != crc_computed);
- PROTO_ITEM_SET_GENERATED(ti);
- ti = proto_tree_add_boolean(crc_tree, hf_fcoe_crc_good, tvb,
- crc_offset, 4,
- crc_exists && crc == crc_computed);
- PROTO_ITEM_SET_GENERATED(ti);
/*
* Interpret the EOF.
@@ -294,16 +268,12 @@ proto_register_fcoe(void)
BASE_DEC, NULL, 0, NULL, HFILL}},
{ &hf_fcoe_crc,
{"CRC", "fcoe.crc", FT_UINT32, BASE_HEX, NULL, 0, NULL, HFILL}},
- { &hf_fcoe_crc_good,
- {"CRC good", "fcoe.crc_good", FT_BOOLEAN, BASE_NONE, NULL, 0x0,
- "True: CRC matches packet content; False: doesn't match or not checked.", HFILL }},
- { &hf_fcoe_crc_bad,
- {"CRC bad", "fcoe.crc_bad", FT_BOOLEAN, BASE_NONE, NULL, 0x0,
- "True: CRC doesn't match packet content; False: matches or not checked.", HFILL }}
+ { &hf_fcoe_crc_status,
+ {"CRC Status", "fcoe.crc.status", FT_UINT8, BASE_NONE, VALS(proto_checksum_vals), 0x0,
+ NULL, HFILL }}
};
static gint *ett[] = {
&ett_fcoe,
- &ett_fcoe_crc
};
static ei_register_info ei[] = {
diff --git a/epan/dissectors/packet-fcoib.c b/epan/dissectors/packet-fcoib.c
index de50bd3373..0278fc4b14 100644
--- a/epan/dissectors/packet-fcoib.c
+++ b/epan/dissectors/packet-fcoib.c
@@ -96,11 +96,9 @@ static int hf_fcoib_sig = -1;
static int hf_fcoib_sof = -1;
static int hf_fcoib_eof = -1;
static int hf_fcoib_crc = -1;
-static int hf_fcoib_crc_bad = -1;
-static int hf_fcoib_crc_good = -1;
+static int hf_fcoib_crc_status = -1;
static int ett_fcoib = -1;
-static int ett_fcoib_crc = -1;
static expert_field ei_fcoib_crc = EI_INIT;
@@ -161,9 +159,7 @@ dissect_fcoib(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U
const char *crc_msg;
const char *len_msg;
proto_item *ti;
- proto_item *item;
proto_tree *fcoib_tree;
- proto_tree *crc_tree;
tvbuff_t *next_tvb;
gboolean crc_exists;
guint32 crc_computed = 0;
@@ -268,34 +264,12 @@ dissect_fcoib(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U
* Create the CRC information.
*/
if (crc_exists) {
- if (crc == crc_computed) {
- item = proto_tree_add_uint_format_value(fcoib_tree, hf_fcoib_crc, tvb,
- crc_offset, 4, crc,
- "%8.8x [valid]", crc);
- } else {
- item = proto_tree_add_uint_format_value(fcoib_tree, hf_fcoib_crc, tvb,
- crc_offset, 4, crc,
- "%8.8x [error: should be %8.8x]",
- crc, crc_computed);
- expert_add_info_format(pinfo, item, &ei_fcoib_crc,
- "Bad FC CRC %8.8x %8.x",
- crc, crc_computed);
- }
+ proto_tree_add_checksum(fcoib_tree, tvb, crc_offset, hf_fcoib_crc, hf_fcoib_crc_status, &ei_fcoib_crc, pinfo, crc_computed, ENC_BIG_ENDIAN, PROTO_CHECKSUM_VERIFY);
proto_tree_set_appendix(fcoib_tree, tvb, crc_offset,
tvb_captured_length_remaining (tvb, crc_offset));
} else {
- item = proto_tree_add_uint_format_value(fcoib_tree, hf_fcoib_crc, tvb, crc_offset, 0,
- 0, "CRC: [missing]");
+ proto_tree_add_checksum(fcoib_tree, tvb, crc_offset, hf_fcoib_crc, hf_fcoib_crc_status, &ei_fcoib_crc, pinfo, 0, ENC_BIG_ENDIAN, PROTO_CHECKSUM_NOT_PRESENT);
}
- crc_tree = proto_item_add_subtree(item, ett_fcoib_crc);
- ti = proto_tree_add_boolean(crc_tree, hf_fcoib_crc_bad, tvb,
- crc_offset, 4,
- crc_exists && crc != crc_computed);
- PROTO_ITEM_SET_GENERATED(ti);
- ti = proto_tree_add_boolean(crc_tree, hf_fcoib_crc_good, tvb,
- crc_offset, 4,
- crc_exists && crc == crc_computed);
- PROTO_ITEM_SET_GENERATED(ti);
/*
* Interpret the EOF.
@@ -349,16 +323,12 @@ proto_register_fcoib(void)
{"Version", "fcoib.ver", FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL}},
{ &hf_fcoib_crc,
{"CRC", "fcoib.crc", FT_UINT32, BASE_HEX, NULL, 0, NULL, HFILL}},
- { &hf_fcoib_crc_good,
- {"CRC good", "fcoib.crc_good", FT_BOOLEAN, BASE_NONE, NULL, 0x0,
- "True: CRC matches packet content; False: doesn't match or not checked.", HFILL }},
- { &hf_fcoib_crc_bad,
- {"CRC bad", "fcoib.crc_bad", FT_BOOLEAN, BASE_NONE, NULL, 0x0,
- "True: CRC doesn't match packet content; False: matches or not checked.", HFILL }}
+ { &hf_fcoib_crc_status,
+ {"CRC Status", "fcoib.crc.status", FT_UINT8, BASE_NONE, VALS(proto_checksum_vals), 0x0,
+ NULL, HFILL }},
};
static gint *ett[] = {
&ett_fcoib,
- &ett_fcoib_crc
};
static ei_register_info ei[] = {
diff --git a/epan/dissectors/packet-fcswils.c b/epan/dissectors/packet-fcswils.c
index 0e4e43aa19..8befc40de5 100644
--- a/epan/dissectors/packet-fcswils.c
+++ b/epan/dissectors/packet-fcswils.c
@@ -1015,7 +1015,7 @@ dissect_swils_fspf_lsrechdr(tvbuff_t *tvb, proto_tree *tree, int offset)
proto_tree_add_item(tree, hf_swils_lsrh_lsid, tvb, offset+11, 1, ENC_BIG_ENDIAN);
proto_tree_add_item(tree, hf_swils_lsrh_adv_domid, tvb, offset+15, 1, ENC_BIG_ENDIAN);
proto_tree_add_item(tree, hf_swils_lsrh_ls_incid, tvb, offset+16, 4, ENC_BIG_ENDIAN);
- proto_tree_add_item(tree, hf_swils_lsrh_checksum, tvb, offset+20, 2, ENC_BIG_ENDIAN);
+ proto_tree_add_checksum(tree, tvb, offset+20, hf_swils_lsrh_checksum, -1, NULL, NULL, 0, ENC_BIG_ENDIAN, PROTO_CHECKSUM_NO_FLAGS);
proto_tree_add_item(tree, hf_swils_lsrh_lsr_length, tvb, offset+22, 2, ENC_BIG_ENDIAN);
}
diff --git a/epan/dissectors/packet-fefd.c b/epan/dissectors/packet-fefd.c
index 26982e63db..489315c070 100644
--- a/epan/dissectors/packet-fefd.c
+++ b/epan/dissectors/packet-fefd.c
@@ -94,31 +94,30 @@ dissect_fefd(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_
guint16 length;
proto_tree *tlv_tree;
int real_length;
+ static const int * flags[] = {
+ &hf_fefd_flags_rt,
+ &hf_fefd_flags_rsy,
+ NULL
+ };
+ static const int * headers[] = {
+ &hf_fefd_version,
+ &hf_fefd_opcode,
+ NULL
+ };
col_set_str(pinfo->cinfo, COL_PROTOCOL, "FEFD");
col_clear(pinfo->cinfo, COL_INFO);
- if (tree) {
- proto_item *flags_ti;
- proto_tree *flags_tree;
-
- ti = proto_tree_add_item(tree, proto_fefd, tvb, offset, -1, ENC_NA);
- fefd_tree = proto_item_add_subtree(ti, ett_fefd);
-
- /* FEFD header */
- proto_tree_add_item(fefd_tree, hf_fefd_version, tvb, offset, 1, ENC_BIG_ENDIAN);
- proto_tree_add_item(fefd_tree, hf_fefd_opcode, tvb, offset, 1, ENC_BIG_ENDIAN);
- offset += 1;
- flags_ti = proto_tree_add_item(fefd_tree, hf_fefd_flags, tvb, offset, 1, ENC_BIG_ENDIAN);
- flags_tree = proto_item_add_subtree(flags_ti, ett_fefd_flags);
- proto_tree_add_item(flags_tree, hf_fefd_flags_rt, tvb, offset, 1, ENC_BIG_ENDIAN);
- proto_tree_add_item(flags_tree, hf_fefd_flags_rsy, tvb, offset, 1, ENC_BIG_ENDIAN);
- offset += 1;
- proto_tree_add_item(fefd_tree, hf_fefd_checksum, tvb, offset, 2, ENC_BIG_ENDIAN);
- offset += 2;
- } else {
- offset += 4; /* The version/opcode/flags/checksum fields from above */
- }
+ ti = proto_tree_add_item(tree, proto_fefd, tvb, offset, -1, ENC_NA);
+ fefd_tree = proto_item_add_subtree(ti, ett_fefd);
+
+ /* FEFD header */
+ proto_tree_add_bitmask_list(fefd_tree, tvb, offset, 1, headers, ENC_BIG_ENDIAN);
+ offset += 1;
+ proto_tree_add_bitmask(fefd_tree, tvb, offset, hf_fefd_flags, ett_fefd_flags, flags, ENC_BIG_ENDIAN);
+ offset += 1;
+ proto_tree_add_checksum(fefd_tree, tvb, offset, hf_fefd_checksum, -1, NULL, pinfo, 0, ENC_BIG_ENDIAN, PROTO_CHECKSUM_NO_FLAGS);
+ offset += 2;
while (tvb_reported_length_remaining(tvb, offset) != 0) {
type = tvb_get_ntohs(tvb, offset + TLV_TYPE);
diff --git a/epan/dissectors/packet-foundry.c b/epan/dissectors/packet-foundry.c
index 5c046d8d84..9da0111684 100644
--- a/epan/dissectors/packet-foundry.c
+++ b/epan/dissectors/packet-foundry.c
@@ -284,7 +284,7 @@ dissect_fdp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
offset += 1;
proto_tree_add_item(fdp_tree, hf_fdp_holdtime, tvb, offset, 1, ENC_BIG_ENDIAN);
offset += 1;
- proto_tree_add_item(fdp_tree, hf_fdp_checksum, tvb, offset, 2, ENC_BIG_ENDIAN);
+ proto_tree_add_checksum(fdp_tree, tvb, offset, hf_fdp_checksum, -1, NULL, pinfo, 0, ENC_BIG_ENDIAN, PROTO_CHECKSUM_NO_FLAGS);
offset += 2;
/* Decode the individual TLVs */
diff --git a/epan/dissectors/packet-gdb.c b/epan/dissectors/packet-gdb.c
index dd976a719f..e5c9187df9 100644
--- a/epan/dissectors/packet-gdb.c
+++ b/epan/dissectors/packet-gdb.c
@@ -104,8 +104,7 @@ dissect_gdb_token(void *tvbparse_data, const void *wanted_data, tvbparse_elem_t
case GDB_TOK_CHKSUM:
/* the spec is not really explicit but it seems that the
checksum is big endian */
- proto_tree_add_item(tree, hf_gdb_chksum,
- tok->tvb, tok->offset, tok->len, ENC_BIG_ENDIAN);
+ proto_tree_add_checksum(tree, tok->tvb, tok->offset, hf_gdb_chksum, -1, NULL, NULL, 0, ENC_BIG_ENDIAN, PROTO_CHECKSUM_NO_FLAGS);
break;
default:
break;
diff --git a/epan/dissectors/packet-gfp.c b/epan/dissectors/packet-gfp.c
index dd8282921a..df96244d71 100644
--- a/epan/dissectors/packet-gfp.c
+++ b/epan/dissectors/packet-gfp.c
@@ -53,8 +53,7 @@ void proto_register_gfp(void);
static int proto_gfp = -1;
static int hf_gfp_pli = -1;
static int hf_gfp_chec = -1;
-static int hf_gfp_chec_good = -1;
-static int hf_gfp_chec_bad = -1;
+static int hf_gfp_chec_status = -1;
static int hf_gfp_type = -1;
static int hf_gfp_pti = -1;
static int hf_gfp_pfi = -1;
@@ -62,12 +61,10 @@ static int hf_gfp_exi = -1;
static int hf_gfp_upi_data = -1;
static int hf_gfp_upi_management = -1;
static int hf_gfp_thec = -1;
-static int hf_gfp_thec_good = -1;
-static int hf_gfp_thec_bad = -1;
+static int hf_gfp_thec_status = -1;
static int hf_gfp_cid = -1;
static int hf_gfp_ehec = -1;
-static int hf_gfp_ehec_good = -1;
-static int hf_gfp_ehec_bad = -1;
+static int hf_gfp_ehec_status = -1;
static int hf_gfp_fcs = -1;
static int hf_gfp_fcs_good = -1;
static int hf_gfp_fcs_bad = -1;
@@ -93,10 +90,7 @@ static expert_field ei_gfp_fcs_bad = EI_INIT;
/* Initialize the subtree pointers */
static gint ett_gfp = -1;
-static gint ett_gfp_chec = -1;
static gint ett_gfp_type = -1;
-static gint ett_gfp_thec = -1;
-static gint ett_gfp_ehec = -1;
static gint ett_gfp_fcs = -1;
static dissector_table_t gfp_dissector_table;
@@ -205,34 +199,15 @@ static gpointer gfp_value(packet_info *pinfo)
/* GFP has several identical 16 bit CRCs in its header (HECs). Note that
* this function increases the offset. */
static void
-gfp_add_hec_tree(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint *offset, const guint len, const int field, const int field_good, const int field_bad, const gint ett, expert_field *ei_bad)
+gfp_add_hec_tree(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint *offset, const guint len, const int field, const int field_status, expert_field *ei_bad)
{
- proto_item* ti = NULL;
- proto_tree* hec_tree = NULL;
- guint hec, hec_calc;
+ guint hec_calc;
hec_calc = crc16_r3_ccitt_tvb(tvb, *offset, len);
*offset += len;
- hec = tvb_get_ntohs(tvb, *offset);
-
- if ( hec == hec_calc ) {
- ti = proto_tree_add_uint_format_value(tree, field, tvb, *offset, 2, hec, "0x%04x [correct]", hec);
- hec_tree = proto_item_add_subtree(ti, ett);
- ti = proto_tree_add_boolean(hec_tree, field_good, tvb, *offset, 2, TRUE);
- PROTO_ITEM_SET_GENERATED(ti);
- ti = proto_tree_add_boolean(hec_tree, field_bad, tvb, *offset, 2, FALSE);
- PROTO_ITEM_SET_GENERATED(ti);
- } else {
- ti = proto_tree_add_uint_format_value(tree, field, tvb, *offset, 2, hec, "0x%04x [incorrect, should be 0x%04x]", hec, hec_calc);
- hec_tree = proto_item_add_subtree(ti, ett);
- ti = proto_tree_add_boolean(hec_tree, field_good, tvb, *offset, 2, FALSE);
- PROTO_ITEM_SET_GENERATED(ti);
- ti = proto_tree_add_boolean(hec_tree, field_bad, tvb, *offset, 2, TRUE);
- PROTO_ITEM_SET_GENERATED(ti);
- expert_add_info(pinfo, ti, ei_bad);
- }
+ proto_tree_add_checksum(tree, tvb, *offset, field, field_status, ei_bad, pinfo, hec_calc, ENC_BIG_ENDIAN, PROTO_CHECKSUM_VERIFY);
*offset += 2;
}
@@ -283,7 +258,7 @@ dissect_gfp_payload(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, proto_t
}
/* G.7041 6.1.2.1.2 Type HEC (tHEC) - mandatory 2 bytes */
- gfp_add_hec_tree(tvb, pinfo, gfp_tree, offset, 2, hf_gfp_thec, hf_gfp_thec_good, hf_gfp_thec_bad, ett_gfp_thec, &ei_gfp_thec_bad);
+ gfp_add_hec_tree(tvb, pinfo, gfp_tree, offset, 2, hf_gfp_thec, hf_gfp_thec_status, &ei_gfp_thec_bad);
switch (exi) {
case GFP_EXT_NULL:
@@ -303,7 +278,7 @@ dissect_gfp_payload(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, proto_t
/* Next byte spare field, reserved */
/* 6.1.2.1.4 Extension HEC field */
- gfp_add_hec_tree(tvb, pinfo, gfp_tree, offset, 2, hf_gfp_ehec, hf_gfp_ehec_good, hf_gfp_ehec_bad, ett_gfp_ehec, &ei_gfp_ehec_bad);
+ gfp_add_hec_tree(tvb, pinfo, gfp_tree, offset, 2, hf_gfp_ehec, hf_gfp_ehec_status, &ei_gfp_ehec_bad);
break;
case GFP_EXT_RING:
/* 6.1.2.1.3.3 Extension header for a ring frame */
@@ -429,7 +404,7 @@ dissect_gfp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
col_set_str(pinfo->cinfo, COL_INFO, rval_to_str_const(pli, gfp_pli_rvals, "Unknown"));
/* 6.1.1.2 Core HEC field */
- gfp_add_hec_tree(tvb, pinfo, gfp_tree, &offset, len, hf_gfp_chec, hf_gfp_chec_good, hf_gfp_chec_bad, ett_gfp_chec, &ei_gfp_chec_bad);
+ gfp_add_hec_tree(tvb, pinfo, gfp_tree, &offset, len, hf_gfp_chec, hf_gfp_chec_status, &ei_gfp_chec_bad);
if (pli == 0) { /* 6.2.1 GFP idle frames */
if (tvb_reported_length_remaining(tvb, offset)) {
@@ -465,13 +440,9 @@ proto_register_gfp(void)
{ "Core HEC", "gfp.chec", FT_UINT16, BASE_HEX,
NULL, 0x0, NULL, HFILL }
},
- { &hf_gfp_chec_good,
- { "Good cHEC", "gfp.chec_good", FT_BOOLEAN, BASE_NONE, NULL, 0x0,
- "True: cHEC matches core header; False: doesn't match", HFILL }
- },
- { &hf_gfp_chec_bad,
- { "Bad cHEC", "gfp.chec_bad", FT_BOOLEAN, BASE_NONE, NULL, 0x0,
- "True: cHEC doesn't match core header; False: matches", HFILL }
+ { &hf_gfp_chec_status,
+ { "cHEC Status", "gfp.chec.status", FT_UINT8, BASE_NONE, VALS(proto_checksum_vals), 0x0,
+ NULL, HFILL }
},
{ &hf_gfp_type,
{ "Type Field", "gfp.type", FT_UINT16, BASE_HEX, NULL, 0x0,
@@ -503,13 +474,9 @@ proto_register_gfp(void)
{ "Type HEC", "gfp.thec", FT_UINT16, BASE_HEX, NULL, 0x0,
NULL, HFILL }
},
- { &hf_gfp_thec_good,
- { "Good tHEC", "gfp.thec_good", FT_BOOLEAN, BASE_NONE, NULL, 0x0,
- "True: tHEC matches type header; False: doesn't match", HFILL }
- },
- { &hf_gfp_thec_bad,
- { "Bad tHEC", "gfp.thec_bad", FT_BOOLEAN, BASE_NONE, NULL, 0x0,
- "True: tHEC doesn't match type header; False: matches", HFILL }
+ { &hf_gfp_thec_status,
+ { "tHEC Status", "gfp.thec.status", FT_UINT8, BASE_NONE, VALS(proto_checksum_vals), 0x0,
+ NULL, HFILL }
},
{ &hf_gfp_cid,
{ "Channel ID", "gfp.cid", FT_UINT8, BASE_HEX, NULL, 0x0,
@@ -519,13 +486,9 @@ proto_register_gfp(void)
{ "Extension HEC", "gfp.ehec", FT_UINT16, BASE_HEX, NULL, 0x0,
NULL, HFILL }
},
- { &hf_gfp_ehec_good,
- { "Good eHEC", "gfp.ehec_good", FT_BOOLEAN, BASE_NONE, NULL, 0x0,
- "True: eHEC matches extension header; False: doesn't match", HFILL }
- },
- { &hf_gfp_ehec_bad,
- { "Bad eHEC", "gfp.ehec_bad", FT_BOOLEAN, BASE_NONE, NULL, 0x0,
- "True: eHEC doesn't match extension header; False: matches", HFILL }
+ { &hf_gfp_ehec_status,
+ { "eHEC Status", "gfp.ehec.status", FT_UINT8, BASE_NONE, VALS(proto_checksum_vals), 0x0,
+ NULL, HFILL }
},
{ &hf_gfp_fcs,
{ "Payload FCS", "gfp.fcs", FT_UINT32, BASE_HEX, NULL, 0x0,
@@ -544,10 +507,7 @@ proto_register_gfp(void)
/* Setup protocol subtree array */
static gint *ett[] = {
&ett_gfp,
- &ett_gfp_chec,
&ett_gfp_type,
- &ett_gfp_thec,
- &ett_gfp_ehec,
&ett_gfp_fcs
};
diff --git a/epan/dissectors/packet-gre.c b/epan/dissectors/packet-gre.c
index f81f42885a..4d60a57370 100644
--- a/epan/dissectors/packet-gre.c
+++ b/epan/dissectors/packet-gre.c
@@ -410,29 +410,21 @@ dissect_gre(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
if (flags_and_ver & GRE_CHECKSUM || flags_and_ver & GRE_ROUTING) {
guint length, reported_length;
- proto_item *it_checksum;
vec_t cksum_vec[1];
- guint16 cksum, computed_cksum;
- it_checksum = proto_tree_add_item(gre_tree, hf_gre_checksum, tvb, offset, 2, ENC_BIG_ENDIAN);
/* Checksum check !... */
- cksum = tvb_get_ntohs(tvb, offset);
length = tvb_captured_length(tvb);
reported_length = tvb_reported_length(tvb);
/* The Checksum Present bit is set, and the packet isn't part of a
fragmented datagram and isn't truncated, so we can checksum it. */
if ((flags_and_ver & GRE_CHECKSUM) && !pinfo->fragmented && length >= reported_length) {
SET_CKSUM_VEC_TVB(cksum_vec[0], tvb, 0, reported_length);
- computed_cksum = in_cksum(cksum_vec, 1);
- if (computed_cksum == 0) {
- proto_item_append_text(it_checksum," [correct]");
- } else {
- proto_item_append_text(it_checksum," [incorrect, should be 0x%04x]",in_cksum_shouldbe(cksum, computed_cksum));
- expert_add_info(pinfo, it_checksum, &ei_gre_checksum_incorrect);
- }
+ proto_tree_add_checksum(gre_tree, tvb, offset, hf_gre_checksum, -1, &ei_gre_checksum_incorrect, pinfo, in_cksum(cksum_vec, 1),
+ ENC_BIG_ENDIAN, PROTO_CHECKSUM_VERIFY|PROTO_CHECKSUM_IN_CKSUM);
+ } else {
+ proto_tree_add_checksum(gre_tree, tvb, offset, hf_gre_checksum, -1, &ei_gre_checksum_incorrect, pinfo, 0,
+ ENC_BIG_ENDIAN, PROTO_CHECKSUM_NO_FLAGS);
}
-
-
offset += 2;
proto_tree_add_item(gre_tree, hf_gre_offset, tvb, offset, 2, ENC_BIG_ENDIAN);
diff --git a/epan/dissectors/packet-h223.c b/epan/dissectors/packet-h223.c
index 3a66b4bbd8..7d942f83df 100644
--- a/epan/dissectors/packet-h223.c
+++ b/epan/dissectors/packet-h223.c
@@ -95,7 +95,7 @@ static int hf_h223_al2_sequenced = -1;
static int hf_h223_al2_unsequenced = -1;
static int hf_h223_al2_seqno = -1;
static int hf_h223_al2_crc = -1;
-static int hf_h223_al2_crc_bad = -1;
+static int hf_h223_al2_crc_status = -1;
static int hf_h223_al_payload = -1;
@@ -697,15 +697,9 @@ dissect_mux_al_pdu( tvbuff_t *tvb, packet_info *pinfo, proto_tree *vc_tree,
calc_checksum = h223_al2_crc8bit(tvb);
real_checksum = tvb_get_guint8(tvb, len - 1);
- if( calc_checksum == real_checksum ) {
- proto_tree_add_uint_format_value(al_tree, hf_h223_al2_crc, tvb, len - 1, 1, real_checksum,
- "0x%02x (correct)", real_checksum );
- } else {
- proto_tree_add_uint_format_value(al_tree, hf_h223_al2_crc, tvb, len - 1, 1, real_checksum,
- "0x%02x (incorrect, should be 0x%02x)", real_checksum, calc_checksum );
- tmp_item = proto_tree_add_boolean( al_tree, hf_h223_al2_crc_bad, tvb, len - 1, 1, TRUE );
- PROTO_ITEM_SET_GENERATED(tmp_item);
+ proto_tree_add_checksum(al_tree, tvb, len - 1, hf_h223_al2_crc, hf_h223_al2_crc_status, NULL, pinfo, calc_checksum, ENC_NA, PROTO_CHECKSUM_VERIFY);
+ if( calc_checksum != real_checksum ) {
/* don't pass pdus which fail checksums on to the subdissector */
subdissector = data_handle;
}
@@ -1610,8 +1604,8 @@ void proto_register_h223 (void)
{ "CRC", "h223.al2.crc", FT_UINT8, BASE_HEX, NULL, 0x0,
NULL, HFILL }},
- { &hf_h223_al2_crc_bad,
- { "Bad CRC","h223.al2.crc_bad", FT_BOOLEAN, BASE_NONE, NULL, 0x0,
+ { &hf_h223_al2_crc_status,
+ { "CRC Status","h223.al2.crc.status", FT_UINT8, BASE_NONE, VALS(proto_checksum_vals), 0x0,
NULL, HFILL }},
{ &hf_h223_al_payload,
diff --git a/epan/dissectors/packet-hartip.c b/epan/dissectors/packet-hartip.c
index 2c55544fe8..2f7e7f3ce8 100644
--- a/epan/dissectors/packet-hartip.c
+++ b/epan/dissectors/packet-hartip.c
@@ -788,7 +788,7 @@ dissect_pass_through(proto_tree *body_tree, tvbuff_t *tvb, gint offset,
length = 1;
}
if (length > 0) {
- proto_tree_add_item(body_tree, hf_hartip_pt_checksum, tvb, offset, 1, ENC_BIG_ENDIAN);
+ proto_tree_add_checksum(body_tree, tvb, offset, hf_hartip_pt_checksum, -1, NULL, NULL, 0, ENC_BIG_ENDIAN, PROTO_CHECKSUM_NO_FLAGS);
}
return bodylen;
diff --git a/epan/dissectors/packet-hip.c b/epan/dissectors/packet-hip.c
index 928e446293..c98a52956b 100644
--- a/epan/dissectors/packet-hip.c
+++ b/epan/dissectors/packet-hip.c
@@ -421,7 +421,7 @@ dissect_hip_common(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gboolean
proto_tree *hip_tree, *hip_tlv_tree=NULL;
proto_item *ti, *ti_tlv;
int length, offset = 0, newoffset = 0;
- guint16 control_h, checksum_h, computed_checksum;
+ guint16 control_h, checksum_h;
guint16 tlv_type_h, tlv_length_h; /* For storing in host order */
guint len;
guint reported_len;
@@ -510,32 +510,16 @@ dissect_hip_common(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gboolean
}
/* pointer to the HIP header (packet data) */
SET_CKSUM_VEC_TVB(cksum_vec[3], tvb, 0, reported_len);
- computed_checksum = in_cksum(cksum_vec, 4);
- if (computed_checksum == 0) {
- proto_tree_add_uint_format_value(hip_tree, hf_hip_checksum, tvb,
- offset+4, 2, checksum_h,
- "0x%04x (correct)",
- checksum_h);
+ if (checksum_h == 0 && udp) {
+ proto_tree_add_checksum(hip_tree, tvb, offset+4, hf_hip_checksum, -1, NULL, pinfo, 0,
+ ENC_BIG_ENDIAN, PROTO_CHECKSUM_VERIFY);
} else {
- if (checksum_h == 0 && udp) {
- proto_tree_add_uint_format_value(hip_tree, hf_hip_checksum, tvb,
- offset+4, 2, checksum_h,
- "0x%04x (correct)",
- checksum_h);
- } else {
- proto_tree_add_uint_format_value(hip_tree, hf_hip_checksum, tvb,
- offset+4, 2, checksum_h,
- "0x%04x (incorrect, should be 0x%04x)",
- checksum_h,
- in_cksum_shouldbe(checksum_h,
- computed_checksum));
- }
+ proto_tree_add_checksum(hip_tree, tvb, offset+4, hf_hip_checksum, -1, NULL, pinfo, in_cksum(cksum_vec, 4),
+ ENC_BIG_ENDIAN, PROTO_CHECKSUM_VERIFY|PROTO_CHECKSUM_IN_CKSUM);
}
} else {
- proto_tree_add_uint_format_value(hip_tree, hf_hip_checksum, tvb,
- offset+4, 2, checksum_h,
- "0x%04x (unverified)",
- checksum_h);
+ proto_tree_add_checksum(hip_tree, tvb, offset+4, hf_hip_checksum, -1, NULL, pinfo, 0,
+ ENC_BIG_ENDIAN, PROTO_CHECKSUM_NO_FLAGS);
}
ti = proto_tree_add_item(hip_tree, hf_hip_controls, tvb, offset+6, 2, ENC_BIG_ENDIAN);
diff --git a/epan/dissectors/packet-homeplug-av.c b/epan/dissectors/packet-homeplug-av.c
index bff72d68b2..c983701179 100644
--- a/epan/dissectors/packet-homeplug-av.c
+++ b/epan/dissectors/packet-homeplug-av.c
@@ -3674,19 +3674,19 @@ proto_register_homeplug_av(void)
},
{ &hf_homeplug_av_st_mac_req_img_load,
{ "Image Load Starting Address", "homeplug_av.st_mac_req.img_load",
- FT_UINT32, BASE_HEX, NULL, 0x00, "Unknown", HFILL }
+ FT_UINT32, BASE_HEX, NULL, 0x00, NULL, HFILL }
},
{ &hf_homeplug_av_st_mac_req_img_len,
{ "Image Length", "homeplug_av.st_mac_req.img_len",
- FT_UINT32, BASE_HEX, NULL, 0x00, "Unknown", HFILL }
+ FT_UINT32, BASE_HEX, NULL, 0x00, NULL, HFILL }
},
{ &hf_homeplug_av_st_mac_req_img_chksum,
{ "Image Checksum", "homeplug_av.st_mac_req.img_chksum",
- FT_UINT32, BASE_HEX, NULL, 0x00, "Unknown", HFILL }
+ FT_UINT32, BASE_HEX, NULL, 0x00, NULL, HFILL }
},
{ &hf_homeplug_av_st_mac_req_img_start,
{ "Image Starting Address", "homeplug_av.st_mac_req.img_start",
- FT_UINT32, BASE_HEX, NULL, 0x00, "Unknown", HFILL }
+ FT_UINT32, BASE_HEX, NULL, 0x00, NULL, HFILL }
},
/* Start MAC Confirmation */
{ &hf_homeplug_av_st_mac_cnf,
diff --git a/epan/dissectors/packet-icmp.c b/epan/dissectors/packet-icmp.c
index 6e21bbead8..01afaa93fc 100644
--- a/epan/dissectors/packet-icmp.c
+++ b/epan/dissectors/packet-icmp.c
@@ -80,7 +80,7 @@ int proto_icmp = -1;
static int hf_icmp_type = -1;
static int hf_icmp_code = -1;
static int hf_icmp_checksum = -1;
-static int hf_icmp_checksum_bad = -1;
+static int hf_icmp_checksum_status = -1;
static int hf_icmp_unused = -1;
static int hf_icmp_reserved = -1;
static int hf_icmp_ident = -1;
@@ -129,7 +129,7 @@ static int hf_icmp_ext = -1;
static int hf_icmp_ext_version = -1;
static int hf_icmp_ext_reserved = -1;
static int hf_icmp_ext_checksum = -1;
-static int hf_icmp_ext_checksum_bad = -1;
+static int hf_icmp_ext_checksum_status = -1;
static int hf_icmp_ext_length = -1;
static int hf_icmp_ext_class = -1;
static int hf_icmp_ext_c_type = -1;
@@ -760,9 +760,8 @@ dissect_extensions(tvbuff_t * tvb, gint offset, proto_tree * tree)
guint8 version;
guint8 class_num;
guint8 c_type;
- guint16 cksum, computed_cksum;
guint16 obj_length, obj_trunc_length;
- proto_item *ti, *tf_object, *hidden_item;
+ proto_item *ti, *tf_object;
proto_tree *ext_tree, *ext_object_tree;
gint obj_end_offset;
guint reported_length;
@@ -798,31 +797,8 @@ dissect_extensions(tvbuff_t * tvb, gint offset, proto_tree * tree)
tvb, offset, 2, ENC_BIG_ENDIAN);
/* Checksum */
- cksum = tvb_get_ntohs(tvb, offset + 2);
-
- computed_cksum = ip_checksum_tvb(tvb, offset, reported_length);
-
- if (computed_cksum == 0) {
- proto_tree_add_uint_format_value(ext_tree, hf_icmp_ext_checksum,
- tvb, offset + 2, 2, cksum,
- "0x%04x [correct]",
- cksum);
- hidden_item =
- proto_tree_add_boolean(ext_tree,
- hf_icmp_ext_checksum_bad, tvb,
- offset + 2, 2, FALSE);
- } else {
- proto_tree_add_uint_format_value(ext_tree, hf_icmp_ext_checksum,
- tvb, offset + 2, 2, cksum,
- "0x%04x [incorrect, should be 0x%04x]",
- cksum, in_cksum_shouldbe(cksum,
- computed_cksum));
- hidden_item =
- proto_tree_add_boolean(ext_tree,
- hf_icmp_ext_checksum_bad, tvb,
- offset + 2, 2, TRUE);
- }
- PROTO_ITEM_SET_HIDDEN(hidden_item);
+ proto_tree_add_checksum(ext_tree, tvb, offset + 2, hf_icmp_ext_checksum, hf_icmp_ext_checksum_status, NULL, NULL, ip_checksum_tvb(tvb, 0, reported_length),
+ ENC_BIG_ENDIAN, PROTO_CHECKSUM_VERIFY|PROTO_CHECKSUM_IN_CKSUM);
if (version != 1 && version != 2) {
/* Unsupported version */
@@ -1194,14 +1170,12 @@ dissect_icmp(tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree, void* data)
guint8 icmp_code;
guint8 icmp_original_dgram_length;
guint captured_length, reported_length;
- guint16 cksum, computed_cksum;
const gchar *type_str, *code_str;
guint32 num_addrs = 0;
guint32 addr_entry_size = 0;
guint32 i;
gboolean save_in_error_pkt;
tvbuff_t *next_tvb;
- proto_item *item;
guint32 conv_key[2];
icmp_transaction_t *trans = NULL;
nstime_t ts, time_relative;
@@ -1213,7 +1187,6 @@ dissect_icmp(tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree, void* data)
/* To do: check for runts, errs, etc. */
icmp_type = tvb_get_guint8(tvb, 0);
icmp_code = tvb_get_guint8(tvb, 1);
- cksum = tvb_get_ntohs(tvb, 2);
/*length of original datagram carried in the ICMP payload. In terms of 32 bit
* words.*/
icmp_original_dgram_length = tvb_get_guint8(tvb, 5);
@@ -1291,27 +1264,16 @@ dissect_icmp(tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree, void* data)
proto_item_append_text(ti, " (%s)", code_str);
}
- checksum_item = proto_tree_add_item(icmp_tree, hf_icmp_checksum, tvb, 2, 2, ENC_BIG_ENDIAN);
-
if (!pinfo->fragmented && captured_length >= reported_length
&& !pinfo->flags.in_error_pkt) {
/* The packet isn't part of a fragmented datagram, isn't
truncated, and isn't the payload of an error packet, so we can checksum
it. */
-
- computed_cksum = ip_checksum_tvb(tvb, 0, reported_length);
- if (computed_cksum == 0) {
- item = proto_tree_add_boolean(icmp_tree, hf_icmp_checksum_bad, tvb, 2, 2, FALSE);
- PROTO_ITEM_SET_HIDDEN(item);
- proto_item_append_text(checksum_item, " [correct]");
- } else {
- item = proto_tree_add_boolean(icmp_tree, hf_icmp_checksum_bad, tvb, 2, 2, TRUE);
- PROTO_ITEM_SET_HIDDEN(item);
- proto_item_append_text(checksum_item, " [incorrect, should be 0x%04x]", in_cksum_shouldbe(cksum, computed_cksum));
- expert_add_info_format(pinfo, checksum_item, &ei_icmp_checksum,
- "ICMPv4 Checksum Incorrect, should be 0x%04x", in_cksum_shouldbe(cksum, computed_cksum));
- }
+ proto_tree_add_checksum(icmp_tree, tvb, 2, hf_icmp_checksum, hf_icmp_checksum_status, &ei_icmp_checksum, pinfo, ip_checksum_tvb(tvb, 0, reported_length),
+ ENC_BIG_ENDIAN, PROTO_CHECKSUM_VERIFY|PROTO_CHECKSUM_IN_CKSUM);
} else {
+ checksum_item = proto_tree_add_checksum(icmp_tree, tvb, 2, hf_icmp_checksum, hf_icmp_checksum_status, &ei_icmp_checksum, pinfo, 0,
+ ENC_BIG_ENDIAN, PROTO_CHECKSUM_NO_FLAGS);
proto_item_append_text(checksum_item, " [%s]",
pinfo->flags.in_error_pkt ? "in ICMP error packet" : "fragmented datagram");
}
@@ -1631,9 +1593,9 @@ void proto_register_icmp(void)
0x0,
NULL, HFILL}},
- {&hf_icmp_checksum_bad,
- {"Bad Checksum", "icmp.checksum_bad", FT_BOOLEAN,
- BASE_NONE, NULL, 0x0,
+ {&hf_icmp_checksum_status,
+ {"Checksum Status", "icmp.checksum.status", FT_UINT8, BASE_NONE,
+ VALS(proto_checksum_vals), 0x0,
NULL, HFILL}},
{&hf_icmp_unused,
@@ -1844,9 +1806,9 @@ void proto_register_icmp(void)
NULL, 0x0,
NULL, HFILL}},
- {&hf_icmp_ext_checksum_bad,
- {"Bad Checksum", "icmp.ext.checksum_bad", FT_BOOLEAN,
- BASE_NONE, NULL,
+ {&hf_icmp_ext_checksum_status,
+ {"Checksum Status", "icmp.ext.checksum.status", FT_UINT8, BASE_NONE,
+ VALS(proto_checksum_vals),
0x0,
NULL, HFILL}},
diff --git a/epan/dissectors/packet-icmpv6.c b/epan/dissectors/packet-icmpv6.c
index 642b7edf39..3d830c7248 100644
--- a/epan/dissectors/packet-icmpv6.c
+++ b/epan/dissectors/packet-icmpv6.c
@@ -97,7 +97,7 @@ static int proto_icmpv6 = -1;
static int hf_icmpv6_type = -1;
static int hf_icmpv6_code = -1;
static int hf_icmpv6_checksum = -1;
-static int hf_icmpv6_checksum_bad = -1;
+static int hf_icmpv6_checksum_status = -1;
static int hf_icmpv6_reserved = -1;
static int hf_icmpv6_data = -1;
static int hf_icmpv6_unknown_data = -1;
@@ -3470,12 +3470,12 @@ static int
dissect_icmpv6(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data)
{
proto_tree *icmp6_tree = NULL, *flag_tree = NULL;
- proto_item *ti = NULL, *hidden_item, *checksum_item = NULL, *code_item = NULL, *ti_flag = NULL;
+ proto_item *ti = NULL, *checksum_item = NULL, *code_item = NULL, *ti_flag = NULL;
const char *code_name = NULL;
guint length = 0, reported_length;
vec_t cksum_vec[4];
guint32 phdr[2];
- guint16 cksum, computed_cksum;
+ guint16 cksum;
int offset;
tvbuff_t *next_tvb;
guint8 icmp6_type, icmp6_code;
@@ -3540,46 +3540,32 @@ dissect_icmpv6(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data)
col_set_str(pinfo->cinfo, COL_INFO, "Direct IPv6 Connectivity Test");
}
- if (tree) {
- if (code_name)
- proto_item_append_text(code_item, " (%s)", code_name);
- checksum_item = proto_tree_add_item(icmp6_tree, hf_icmpv6_checksum, tvb, offset, 2, ENC_BIG_ENDIAN);
- }
+ if (code_name)
+ proto_item_append_text(code_item, " (%s)", code_name);
cksum = tvb_get_ntohs(tvb, offset);
-
- if (1) { /* There's an expert info in here so always execute */
- length = tvb_captured_length(tvb);
- reported_length = tvb_reported_length(tvb);
- if (!pinfo->fragmented && length >= reported_length && !pinfo->flags.in_error_pkt) {
- /* The packet isn't part of a fragmented datagram, isn't truncated,
- * and we aren't in an ICMP error packet, so we can checksum it.
- */
-
- /* Set up the fields of the pseudo-header. */
- SET_CKSUM_VEC_PTR(cksum_vec[0], (const guint8 *)pinfo->src.data, pinfo->src.len);
- SET_CKSUM_VEC_PTR(cksum_vec[1], (const guint8 *)pinfo->dst.data, pinfo->dst.len);
- phdr[0] = g_htonl(reported_length);
- phdr[1] = g_htonl(IP_PROTO_ICMPV6);
- SET_CKSUM_VEC_PTR(cksum_vec[2], (const guint8 *)&phdr, 8);
- SET_CKSUM_VEC_TVB(cksum_vec[3], tvb, 0, reported_length);
- computed_cksum = in_cksum(cksum_vec, 4);
-
- if (computed_cksum == 0) {
- hidden_item = proto_tree_add_boolean(icmp6_tree, hf_icmpv6_checksum_bad, tvb, offset, 2, FALSE);
- PROTO_ITEM_SET_HIDDEN(hidden_item);
- proto_item_append_text(checksum_item, " [correct]");
- } else {
- hidden_item = proto_tree_add_boolean(icmp6_tree, hf_icmpv6_checksum_bad, tvb, offset, 2, TRUE);
- PROTO_ITEM_SET_HIDDEN(hidden_item);
- proto_item_append_text(checksum_item, " [incorrect, should be 0x%04x]", in_cksum_shouldbe(cksum, computed_cksum));
- expert_add_info_format(pinfo, checksum_item, &ei_icmpv6_checksum,
- "ICMPv6 Checksum Incorrect, should be 0x%04x", in_cksum_shouldbe(cksum, computed_cksum));
- }
- } else {
- proto_item_append_text(checksum_item, " [%s]",
- pinfo->flags.in_error_pkt ? "in ICMP error packet" : "fragmented datagram");
- }
+ length = tvb_captured_length(tvb);
+ reported_length = tvb_reported_length(tvb);
+ if (!pinfo->fragmented && length >= reported_length && !pinfo->flags.in_error_pkt) {
+ /* The packet isn't part of a fragmented datagram, isn't truncated,
+ * and we aren't in an ICMP error packet, so we can checksum it.
+ */
+
+ /* Set up the fields of the pseudo-header. */
+ SET_CKSUM_VEC_PTR(cksum_vec[0], (const guint8 *)pinfo->src.data, pinfo->src.len);
+ SET_CKSUM_VEC_PTR(cksum_vec[1], (const guint8 *)pinfo->dst.data, pinfo->dst.len);
+ phdr[0] = g_htonl(reported_length);
+ phdr[1] = g_htonl(IP_PROTO_ICMPV6);
+ SET_CKSUM_VEC_PTR(cksum_vec[2], (const guint8 *)&phdr, 8);
+ SET_CKSUM_VEC_TVB(cksum_vec[3], tvb, 0, reported_length);
+
+ proto_tree_add_checksum(icmp6_tree, tvb, 2, hf_icmpv6_checksum, hf_icmpv6_checksum_status, &ei_icmpv6_checksum, pinfo, in_cksum(cksum_vec, 4),
+ ENC_BIG_ENDIAN, PROTO_CHECKSUM_VERIFY|PROTO_CHECKSUM_IN_CKSUM);
+ } else {
+ checksum_item = proto_tree_add_checksum(icmp6_tree, tvb, 2, hf_icmpv6_checksum, hf_icmpv6_checksum_status, &ei_icmpv6_checksum, pinfo, 0,
+ ENC_BIG_ENDIAN, PROTO_CHECKSUM_NO_FLAGS);
+ proto_item_append_text(checksum_item, " [%s]",
+ pinfo->flags.in_error_pkt ? "in ICMP error packet" : "fragmented datagram");
}
offset += 2;
@@ -3612,8 +3598,7 @@ dissect_icmpv6(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data)
* Shouldn't the nonce be at least 8 then? Why not just use (-1),
* as it could really be any length, couldn't it?
*/
- if (tree)
- proto_tree_add_item(icmp6_tree, hf_icmpv6_nonce, tvb, offset, 4, ENC_NA);
+ proto_tree_add_item(icmp6_tree, hf_icmpv6_nonce, tvb, offset, 4, ENC_NA);
offset += 4;
} else {
if (!pinfo->flags.in_error_pkt) {
@@ -4158,8 +4143,8 @@ proto_register_icmpv6(void)
{ &hf_icmpv6_checksum,
{ "Checksum", "icmpv6.checksum", FT_UINT16, BASE_HEX, NULL, 0x0,
"Used to detect data corruption in the ICMPv6 message and parts of the IPv6 header", HFILL }},
- { &hf_icmpv6_checksum_bad,
- { "Bad Checksum", "icmpv6.checksum_bad", FT_BOOLEAN, BASE_NONE, NULL, 0x0,
+ { &hf_icmpv6_checksum_status,
+ { "Checksum Status", "icmpv6.checksum.status", FT_UINT8, BASE_NONE, VALS(proto_checksum_vals), 0x0,
NULL, HFILL }},
{ &hf_icmpv6_reserved,
{ "Reserved", "icmpv6.reserved", FT_BYTES, BASE_NONE, NULL, 0x0,
diff --git a/epan/dissectors/packet-idp.c b/epan/dissectors/packet-idp.c
index 18ecf46679..a83e813f23 100644
--- a/epan/dissectors/packet-idp.c
+++ b/epan/dissectors/packet-idp.c
@@ -88,7 +88,7 @@ dissect_idp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
ti = proto_tree_add_item(tree, proto_idp, tvb, 0, IDP_HEADER_LEN, ENC_NA);
idp_tree = proto_item_add_subtree(ti, ett_idp);
- proto_tree_add_item(idp_tree, hf_idp_checksum, tvb, 0, 2, ENC_BIG_ENDIAN);
+ proto_tree_add_checksum(idp_tree, tvb, 0, hf_idp_checksum, -1, NULL, pinfo, 0, ENC_BIG_ENDIAN, PROTO_CHECKSUM_NO_FLAGS);
length = tvb_get_ntohs(tvb, 2);
proto_tree_add_uint_format_value(idp_tree, hf_idp_len, tvb, 2, 2, length,
"%u bytes", length);
diff --git a/epan/dissectors/packet-ieee80211.c b/epan/dissectors/packet-ieee80211.c
index 6c534e43ba..7e557654db 100644
--- a/epan/dissectors/packet-ieee80211.c
+++ b/epan/dissectors/packet-ieee80211.c
@@ -2978,8 +2978,7 @@ static int hf_ieee80211_seq_number = -1;
/* Header values for Frame Check field */
/* ************************************************************************* */
static int hf_ieee80211_fcs = -1;
-static int hf_ieee80211_fcs_good = -1;
-static int hf_ieee80211_fcs_bad = -1;
+static int hf_ieee80211_fcs_status = -1;
/* ************************************************************************* */
/* Header values for reassembly */
@@ -16429,14 +16428,12 @@ dissect_ieee80211_common(tvbuff_t *tvb, packet_info *pinfo,
guint32 seq_number, frag_number;
gboolean more_frags;
proto_item *ti = NULL;
- proto_item *fcs_item = NULL;
proto_item *cw_item = NULL;
proto_item *hidden_item;
- proto_tree *fcs_tree = NULL;
proto_tree *cw_tree = NULL;
guint16 hdr_len, ohdr_len;
guint16 htc_len = 0;
- gboolean has_fcs, fcs_good, fcs_bad;
+ gboolean has_fcs;
gint len, reported_len, ivlen;
gint sta_addr_offset = 0;
const gchar *station_name;
@@ -17527,7 +17524,7 @@ dissect_ieee80211_common(tvbuff_t *tvb, packet_info *pinfo,
*/
len -= 4;
reported_len -= 4;
- if (tree)
+ if (wlan_check_checksum)
{
guint32 sent_fcs = tvb_get_ntohl(tvb, hdr_len + len);
guint32 fcs;
@@ -17536,40 +17533,13 @@ dissect_ieee80211_common(tvbuff_t *tvb, packet_info *pinfo,
fcs = crc32_802_tvb_padded(tvb, ohdr_len, hdr_len, len);
else
fcs = crc32_802_tvb(tvb, hdr_len + len);
- if (fcs == sent_fcs) {
- fcs_good = TRUE;
- fcs_bad = FALSE;
- } else {
- fcs_good = FALSE;
- fcs_bad = TRUE;
- }
-
- fcs_item = proto_tree_add_item(hdr_tree, hf_ieee80211_fcs, tvb,
- hdr_len + len, 4, ENC_LITTLE_ENDIAN);
- if (fcs_good) {
- proto_item_append_text(fcs_item, " [correct]");
- } else {
- proto_item_append_text(fcs_item, " [incorrect, should be 0x%08x]", fcs);
+ if (fcs != sent_fcs) {
flag_str[8] = '.';
}
- proto_tree_set_appendix(hdr_tree, tvb, hdr_len + len, 4);
-
- if(wlan_check_checksum) {
- fcs_tree = proto_item_add_subtree(fcs_item, ett_fcs);
-
- fcs_item = proto_tree_add_boolean(fcs_tree,
- hf_ieee80211_fcs_good, tvb,
- hdr_len + len, 4,
- fcs_good);
- PROTO_ITEM_SET_GENERATED(fcs_item);
-
- fcs_item = proto_tree_add_boolean(fcs_tree,
- hf_ieee80211_fcs_bad, tvb,
- hdr_len + len, 4,
- fcs_bad);
- PROTO_ITEM_SET_GENERATED(fcs_item);
- }
+ proto_tree_add_checksum(hdr_tree, tvb, hdr_len + len, hf_ieee80211_fcs, hf_ieee80211_fcs_status, NULL, pinfo, fcs, ENC_LITTLE_ENDIAN, PROTO_CHECKSUM_VERIFY);
+ } else {
+ proto_tree_add_checksum(hdr_tree, tvb, hdr_len + len, hf_ieee80211_fcs, hf_ieee80211_fcs_status, NULL, pinfo, 0, ENC_LITTLE_ENDIAN, PROTO_CHECKSUM_NO_FLAGS);
}
}
}
@@ -19154,15 +19124,10 @@ proto_register_ieee80211(void)
FT_UINT32, BASE_HEX, NULL, 0,
"Frame Check Sequence (FCS)", HFILL }},
- {&hf_ieee80211_fcs_good,
- {"Good", "wlan.fcs_good",
- FT_BOOLEAN, BASE_NONE, NULL, 0x0,
- "True if the FCS is correct", HFILL }},
-
- {&hf_ieee80211_fcs_bad,
- {"Bad", "wlan.fcs_bad",
- FT_BOOLEAN, BASE_NONE, NULL, 0x0,
- "True if the FCS is incorrect", HFILL }},
+ {&hf_ieee80211_fcs_status,
+ {"FCS Status", "wlan.fcs.status",
+ FT_UINT8, BASE_NONE, VALS(proto_checksum_vals), 0x0,
+ NULL, HFILL }},
{&hf_ieee80211_fragment_overlap,
{"Fragment overlap", "wlan.fragment.overlap",
diff --git a/epan/dissectors/packet-igap.c b/epan/dissectors/packet-igap.c
index a85a1c60c5..6df6ff498f 100644
--- a/epan/dissectors/packet-igap.c
+++ b/epan/dissectors/packet-igap.c
@@ -52,7 +52,7 @@ static int proto_igap = -1;
static int hf_type = -1;
static int hf_max_resp = -1;
static int hf_checksum = -1;
-static int hf_checksum_bad = -1;
+static int hf_checksum_status = -1;
static int hf_maddr = -1;
static int hf_version = -1;
static int hf_subtype = -1;
@@ -157,7 +157,7 @@ dissect_igap(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, void* d
"%.1f sec (0x%02x)", tsecs * 0.1, tsecs);
offset += 1;
- igmp_checksum(tree, tvb, hf_checksum, hf_checksum_bad, pinfo, 0);
+ igmp_checksum(tree, tvb, hf_checksum, hf_checksum_status, pinfo, 0);
offset += 2;
proto_tree_add_item(tree, hf_maddr, tvb, offset, 4, ENC_BIG_ENDIAN);
@@ -256,9 +256,9 @@ proto_register_igap(void)
FT_UINT16, BASE_HEX, NULL, 0,
NULL, HFILL }
},
- { &hf_checksum_bad,
- { "Bad Checksum", "igap.checksum_bad",
- FT_BOOLEAN, BASE_NONE, NULL, 0x0,
+ { &hf_checksum_status,
+ { "Checksum Status", "igap.checksum.status",
+ FT_UINT8, BASE_NONE, VALS(proto_checksum_vals), 0x0,
NULL, HFILL }
},
{ &hf_maddr,
diff --git a/epan/dissectors/packet-igmp.c b/epan/dissectors/packet-igmp.c
index 6e9d20da75..f976130c24 100644
--- a/epan/dissectors/packet-igmp.c
+++ b/epan/dissectors/packet-igmp.c
@@ -127,7 +127,7 @@ static int hf_group_type = -1;
static int hf_reply_code = -1;
static int hf_reply_pending = -1;
static int hf_checksum = -1;
-static int hf_checksum_bad = -1;
+static int hf_checksum_status = -1;
static int hf_identifier = -1;
static int hf_access_key = -1;
static int hf_max_resp = -1;
@@ -282,11 +282,9 @@ static const value_string mtrace_fwd_code_vals[] = {
};
void igmp_checksum(proto_tree *tree, tvbuff_t *tvb, int hf_index,
- int hf_index_bad, packet_info *pinfo, guint len)
+ int hf_index_status, packet_info *pinfo, guint len)
{
- guint16 cksum, hdrcksum;
vec_t cksum_vec[1];
- proto_item *hidden_item;
if (len == 0) {
/*
@@ -295,29 +293,16 @@ void igmp_checksum(proto_tree *tree, tvbuff_t *tvb, int hf_index,
len = tvb_reported_length(tvb);
}
- hdrcksum = tvb_get_ntohs(tvb, 2);
if (!pinfo->fragmented && tvb_captured_length(tvb) >= len) {
/*
* The packet isn't part of a fragmented datagram and isn't
* truncated, so we can checksum it.
*/
SET_CKSUM_VEC_TVB(cksum_vec[0], tvb, 0, len);
-
- cksum = in_cksum(&cksum_vec[0],1);
-
- if (cksum == 0) {
- proto_tree_add_uint_format(tree, hf_index, tvb, 2, 2, hdrcksum,
- "Header checksum: 0x%04x [correct]", hdrcksum);
- } else {
- hidden_item = proto_tree_add_boolean(tree, hf_index_bad,
- tvb, 2, 2, TRUE);
- PROTO_ITEM_SET_HIDDEN(hidden_item);
- proto_tree_add_uint_format(tree, hf_index, tvb, 2, 2, hdrcksum,
- "Header checksum: 0x%04x [incorrect, should be 0x%04x]",
- hdrcksum, in_cksum_shouldbe(hdrcksum,cksum));
- }
+ proto_tree_add_checksum(tree, tvb, 2, hf_index, hf_index_status, NULL, pinfo, in_cksum(&cksum_vec[0], 1),
+ ENC_BIG_ENDIAN, PROTO_CHECKSUM_VERIFY|PROTO_CHECKSUM_IN_CKSUM);
} else
- proto_tree_add_uint(tree, hf_index, tvb, 2, 2, hdrcksum);
+ proto_tree_add_checksum(tree, tvb, 2, hf_index, -1, NULL, pinfo, 0, ENC_BIG_ENDIAN, PROTO_CHECKSUM_NO_FLAGS);
return;
}
@@ -563,7 +548,7 @@ dissect_igmp_v3_report(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tre
offset += 1;
/* checksum */
- igmp_checksum(tree, tvb, hf_checksum, hf_checksum_bad, pinfo, 0);
+ igmp_checksum(tree, tvb, hf_checksum, hf_checksum_status, pinfo, 0);
offset += 2;
proto_tree_add_item(tree, hf_reserved, tvb, offset, 2, ENC_NA);
@@ -598,7 +583,7 @@ dissect_igmp_v3_query(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree
offset = dissect_v3_max_resp(tvb, tree, offset);
/* checksum */
- igmp_checksum(tree, tvb, hf_checksum, hf_checksum_bad, pinfo, 0);
+ igmp_checksum(tree, tvb, hf_checksum, hf_checksum_status, pinfo, 0);
offset += 2;
/* group address */
@@ -653,7 +638,7 @@ dissect_igmp_v2(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, void
offset += 1;
/* checksum */
- igmp_checksum(tree, tvb, hf_checksum, hf_checksum_bad, pinfo, 8);
+ igmp_checksum(tree, tvb, hf_checksum, hf_checksum_status, pinfo, 8);
offset += 2;
/* group address */
@@ -695,7 +680,7 @@ dissect_igmp_v1(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, void
offset += 1;
/* checksum */
- igmp_checksum(tree, tvb, hf_checksum, hf_checksum_bad, pinfo, 8);
+ igmp_checksum(tree, tvb, hf_checksum, hf_checksum_status, pinfo, 8);
offset += 2;
/* group address */
@@ -730,7 +715,7 @@ dissect_igmp_v0(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, void
offset += 1;
/* checksum */
- igmp_checksum(tree, tvb, hf_checksum, hf_checksum_bad, pinfo, 20);
+ igmp_checksum(tree, tvb, hf_checksum, hf_checksum_status, pinfo, 20);
offset += 2;
/* identifier */
@@ -813,7 +798,7 @@ dissect_igmp_mtrace(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree,
offset += 1;
/* checksum */
- igmp_checksum(tree, tvb, hf_checksum, hf_checksum_bad, pinfo, 0);
+ igmp_checksum(tree, tvb, hf_checksum, hf_checksum_status, pinfo, 0);
offset += 2;
/* group address to be traced */
@@ -952,9 +937,9 @@ proto_register_igmp(void)
{ "Checksum", "igmp.checksum", FT_UINT16, BASE_HEX,
NULL, 0, "IGMP Checksum", HFILL }},
- { &hf_checksum_bad,
- { "Bad Checksum", "igmp.checksum_bad", FT_BOOLEAN, BASE_NONE,
- NULL, 0x0, "Bad IGMP Checksum", HFILL }},
+ { &hf_checksum_status,
+ { "Checksum Status", "igmp.checksum.status", FT_UINT8, BASE_NONE,
+ VALS(proto_checksum_vals), 0x0, NULL, HFILL }},
{ &hf_identifier,
{ "Identifier", "igmp.identifier", FT_UINT32, BASE_DEC,
diff --git a/epan/dissectors/packet-igmp.h b/epan/dissectors/packet-igmp.h
index b0abb74299..8709dd8013 100644
--- a/epan/dissectors/packet-igmp.h
+++ b/epan/dissectors/packet-igmp.h
@@ -55,7 +55,7 @@
#define IGMP_RGMP_HELLO 0xFF
void igmp_checksum(proto_tree *tree, tvbuff_t *tvb, int hf_index,
- int hf_index_bad, packet_info *pinfo, guint len);
+ int hf_index_status, packet_info *pinfo, guint len);
#endif
diff --git a/epan/dissectors/packet-igrp.c b/epan/dissectors/packet-igrp.c
index 0b290ec329..0c2ab10f11 100644
--- a/epan/dissectors/packet-igrp.c
+++ b/epan/dissectors/packet-igrp.c
@@ -147,7 +147,7 @@ static int dissect_igrp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, voi
offset+=IGRP_ENTRY_LENGTH;
}
- proto_tree_add_item(igrp_tree, hf_igrp_checksum, tvb, 10, 2, ENC_BIG_ENDIAN);
+ proto_tree_add_checksum(igrp_tree, tvb, 10, hf_igrp_checksum, -1, NULL, pinfo, 0, ENC_BIG_ENDIAN, PROTO_CHECKSUM_NO_FLAGS);
}
return tvb_captured_length(tvb);
}
diff --git a/epan/dissectors/packet-ip.c b/epan/dissectors/packet-ip.c
index aac46b2cd1..c72b0dbee6 100644
--- a/epan/dissectors/packet-ip.c
+++ b/epan/dissectors/packet-ip.c
@@ -124,8 +124,7 @@ static int hf_ip_ttl = -1;
static int hf_ip_proto = -1;
static int hf_ip_checksum = -1;
static int hf_ip_checksum_calculated = -1;
-static int hf_ip_checksum_good = -1;
-static int hf_ip_checksum_bad = -1;
+static int hf_ip_checksum_status = -1;
/* IP option fields */
static int hf_ip_opt_type = -1;
@@ -243,7 +242,6 @@ static gint ett_ip_option_qs = -1;
static gint ett_ip_option_other = -1;
static gint ett_ip_fragments = -1;
static gint ett_ip_fragment = -1;
-static gint ett_ip_checksum = -1;
static gint ett_ip_opt_type = -1;
static gint ett_ip_opt_sec_prot_auth_flags = -1;
static gint ett_unknown_ip_tcp_opt = -1;
@@ -1999,7 +1997,6 @@ dissect_ip_v4(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, void*
guint hlen, optlen;
guint16 flags;
guint16 ipsum;
- guint16 expected_cksum;
fragment_head *ipfd_head = NULL;
tvbuff_t *next_tvb;
gboolean update_col_info = TRUE;
@@ -2008,7 +2005,6 @@ dissect_ip_v4(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, void*
guint32 src32, dst32;
proto_tree *tree;
proto_item *item = NULL, *ttl_item;
- proto_tree *checksum_tree;
guint16 ttl;
int bit_offset;
tree = parent_tree;
@@ -2207,55 +2203,25 @@ dissect_ip_v4(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, void*
*/
if (ip_check_checksum && tvb_bytes_exist(tvb, offset, hlen)&&(!pinfo->flags.in_error_pkt)) {
ipsum = ip_checksum_tvb(tvb, offset, hlen);
- if (tree) {
- if (ipsum == 0) {
- item = proto_tree_add_uint_format_value(ip_tree, hf_ip_checksum, tvb,
- offset + 10, 2, iph->ip_sum,
- "0x%04x [correct]",
- iph->ip_sum);
- checksum_tree = proto_item_add_subtree(item, ett_ip_checksum);
- item = proto_tree_add_uint(checksum_tree, hf_ip_checksum_calculated, tvb,
- offset + 10, 2, iph->ip_sum);
- PROTO_ITEM_SET_GENERATED(item);
- item = proto_tree_add_boolean(checksum_tree, hf_ip_checksum_good, tvb,
- offset + 10, 2, TRUE);
- PROTO_ITEM_SET_GENERATED(item);
- item = proto_tree_add_boolean(checksum_tree, hf_ip_checksum_bad, tvb,
- offset + 10, 2, FALSE);
- PROTO_ITEM_SET_GENERATED(item);
- } else {
- expected_cksum = in_cksum_shouldbe(iph->ip_sum, ipsum);
-
- item = proto_tree_add_uint_format_value(ip_tree, hf_ip_checksum, tvb,
- offset + 10, 2, iph->ip_sum,
- "0x%04x "
- "[incorrect, should be 0x%04x "
- "(may be caused by \"IP checksum "
- "offload\"?)]", iph->ip_sum,
- expected_cksum);
- checksum_tree = proto_item_add_subtree(item, ett_ip_checksum);
- item = proto_tree_add_uint(checksum_tree, hf_ip_checksum_calculated, tvb,
- offset + 10, 2, expected_cksum);
- PROTO_ITEM_SET_GENERATED(item);
- item = proto_tree_add_boolean(checksum_tree, hf_ip_checksum_good, tvb,
- offset + 10, 2, FALSE);
- PROTO_ITEM_SET_GENERATED(item);
- item = proto_tree_add_boolean(checksum_tree, hf_ip_checksum_bad, tvb,
- offset + 10, 2, TRUE);
- PROTO_ITEM_SET_GENERATED(item);
- }
- }
- if (ipsum != 0) {
- /* Add expert item always (so tap gets called if present);
- if (tree == NULL) then item will be NULL
- else item should be from the
- add_boolean(..., hf_ip_checksum_bad, ...) above */
- expert_add_info(pinfo, item, &ei_ip_checksum_bad);
+ item = proto_tree_add_checksum(ip_tree, tvb, offset + 10, hf_ip_checksum, hf_ip_checksum_status, &ei_ip_checksum_bad, pinfo, ipsum,
+ ENC_BIG_ENDIAN, PROTO_CHECKSUM_VERIFY|PROTO_CHECKSUM_IN_CKSUM);
+ if (ipsum == 0) {
+ /* XXX - Keeping hf_ip_checksum_calculated field for now. Doesn't fit into the
+ proto_tree_add_checksum design, but IP is a popular enough dissector that somebody
+ may have a legitimate reason for wanting it filtered */
+ item = proto_tree_add_uint(ip_tree, hf_ip_checksum_calculated, tvb,
+ offset + 10, 2, iph->ip_sum);
+ PROTO_ITEM_SET_GENERATED(item);
+ } else {
+ proto_item_append_text(item, "(may be caused by \"IP checksum offload\"?)");
+
+ item = proto_tree_add_uint(ip_tree, hf_ip_checksum_calculated, tvb,
+ offset + 10, 2, in_cksum_shouldbe(iph->ip_sum, ipsum));
+ PROTO_ITEM_SET_GENERATED(item);
}
} else {
ipsum = 0;
- if (tree) {
- item = proto_tree_add_uint_format_value(ip_tree, hf_ip_checksum, tvb,
+ proto_tree_add_uint_format_value(ip_tree, hf_ip_checksum, tvb,
offset + 10, 2, iph->ip_sum,
"0x%04x [%s]",
iph->ip_sum,
@@ -2264,14 +2230,9 @@ dissect_ip_v4(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, void*
"in ICMP error packet" :
"not all data available") :
"validation disabled");
- checksum_tree = proto_item_add_subtree(item, ett_ip_checksum);
- item = proto_tree_add_boolean(checksum_tree, hf_ip_checksum_good, tvb,
- offset + 10, 2, FALSE);
- PROTO_ITEM_SET_GENERATED(item);
- item = proto_tree_add_boolean(checksum_tree, hf_ip_checksum_bad, tvb,
- offset + 10, 2, FALSE);
- PROTO_ITEM_SET_GENERATED(item);
- }
+ item = proto_tree_add_uint(ip_tree, hf_ip_checksum_status, tvb,
+ offset + 10, 0, PROTO_CHECKSUM_E_UNVERIFIED);
+ PROTO_ITEM_SET_GENERATED(item);
}
src32 = tvb_get_ntohl(tvb, offset + IPH_SRC);
set_address_tvb(&pinfo->net_src, AT_IPv4, 4, tvb, offset + IPH_SRC);
@@ -2801,13 +2762,9 @@ proto_register_ip(void)
{ "Calculated Checksum", "ip.checksum_calculated", FT_UINT16, BASE_HEX, NULL, 0x0,
"The expected IP checksum field as calculated from the IP datagram", HFILL }},
- { &hf_ip_checksum_good,
- { "Good", "ip.checksum_good", FT_BOOLEAN, BASE_NONE, NULL, 0x0,
- "True: checksum matches packet content; False: doesn't match content or not checked", HFILL }},
-
- { &hf_ip_checksum_bad,
- { "Bad", "ip.checksum_bad", FT_BOOLEAN, BASE_NONE, NULL, 0x0,
- "True: checksum doesn't match packet content; False: matches content or not checked", HFILL }},
+ { &hf_ip_checksum_status,
+ { "Header checksum status", "ip.checksum.status", FT_UINT8, BASE_NONE, VALS(proto_checksum_vals), 0x0,
+ NULL, HFILL }},
/* IP options related fields */
{ &hf_ip_opt_type,
@@ -3080,7 +3037,6 @@ proto_register_ip(void)
&ett_ip_option_other,
&ett_ip_fragments,
&ett_ip_fragment,
- &ett_ip_checksum,
&ett_ip_opt_type,
&ett_ip_opt_sec_prot_auth_flags,
&ett_unknown_ip_tcp_opt,
diff --git a/epan/dissectors/packet-ipv6.c b/epan/dissectors/packet-ipv6.c
index 3bc221b30f..e096b661a7 100644
--- a/epan/dissectors/packet-ipv6.c
+++ b/epan/dissectors/packet-ipv6.c
@@ -1426,8 +1426,8 @@ dissect_opt_calipso(tvbuff_t *tvb, gint offset, packet_info *pinfo, proto_tree *
offset, 1, ENC_BIG_ENDIAN);
offset += 1;
- proto_tree_add_item(opt_tree, hf_ipv6_opt_calipso_checksum, tvb,
- offset, 2, ENC_BIG_ENDIAN);
+ proto_tree_add_checksum(opt_tree, tvb, offset, hf_ipv6_opt_calipso_checksum, -1,
+ NULL, pinfo, 0, ENC_BIG_ENDIAN, PROTO_CHECKSUM_NO_FLAGS);
offset += 2;
proto_tree_add_item(opt_tree, hf_ipv6_opt_calipso_cmpt_bitmap, tvb,
diff --git a/epan/dissectors/packet-ipx.c b/epan/dissectors/packet-ipx.c
index 4ebb8597a0..309617fcba 100644
--- a/epan/dissectors/packet-ipx.c
+++ b/epan/dissectors/packet-ipx.c
@@ -345,7 +345,7 @@ dissect_ipx(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
hidden_item = proto_tree_add_string(ipx_tree, hf_ipx_addr, tvb, 0, 0, str);
PROTO_ITEM_SET_HIDDEN(hidden_item);
- proto_tree_add_item(ipx_tree, hf_ipx_checksum, tvb, 0, 2, ENC_BIG_ENDIAN);
+ proto_tree_add_checksum(ipx_tree, tvb, 0, hf_ipx_checksum, -1, NULL, pinfo, 0, ENC_BIG_ENDIAN, PROTO_CHECKSUM_NO_FLAGS);
proto_tree_add_uint_format_value(ipx_tree, hf_ipx_len, tvb, 2, 2, ipxh->ipx_length,
"%d bytes", ipxh->ipx_length);
ipx_hops = tvb_get_guint8(tvb, 4);
diff --git a/epan/dissectors/packet-isis-hello.c b/epan/dissectors/packet-isis-hello.c
index 2a8fef35a3..5371667c4d 100644
--- a/epan/dissectors/packet-isis-hello.c
+++ b/epan/dissectors/packet-isis-hello.c
@@ -765,29 +765,18 @@ dissect_hello_checksum_clv(tvbuff_t *tvb, packet_info* pinfo,
* which is offseted 17 bytes in IIHs (relative to the beginning of the IS-IS packet) */
pdu_length = tvb_get_ntohs(tvb, 17);
- /* unlike the LSP checksum verification which starts at an offset of 12 we start at offset 0*/
- switch (check_and_get_checksum(tvb, 0, pdu_length, checksum, offset, &cacl_checksum))
- {
- case NO_CKSUM :
- proto_tree_add_uint_format_value( tree, hf_isis_hello_checksum, tvb, offset, length, checksum,
- "0x%04x [unused]", checksum);
- break;
- case DATA_MISSING :
+ if (checksum == 0) {
+ /* No checksum present */
+ proto_tree_add_checksum(tree, tvb, offset, hf_isis_hello_checksum, -1, NULL, pinfo, 0, ENC_BIG_ENDIAN, PROTO_CHECKSUM_NOT_PRESENT);
+ } else {
+ if (osi_check_and_get_checksum(tvb, 0, pdu_length, offset, &cacl_checksum)) {
+ /* Successfully processed checksum, verify it */
+ proto_tree_add_checksum(tree, tvb, offset, hf_isis_hello_checksum, -1, NULL, pinfo, cacl_checksum, ENC_BIG_ENDIAN, PROTO_CHECKSUM_VERIFY);
+ } else {
+ proto_tree_add_checksum(tree, tvb, offset, hf_isis_hello_checksum, -1, NULL, pinfo, 0, ENC_BIG_ENDIAN, PROTO_CHECKSUM_NO_FLAGS);
proto_tree_add_expert_format(tree, pinfo, &ei_isis_hello_long_packet, tvb, offset, -1,
"Packet length %d went beyond packet", tvb_captured_length(tvb) );
- break;
- case CKSUM_NOT_OK :
- proto_tree_add_uint_format_value( tree, hf_isis_hello_checksum, tvb, offset, length, checksum,
- "0x%04x [incorrect, should be 0x%04x]",
- checksum,
- cacl_checksum);
- break;
- case CKSUM_OK :
- proto_tree_add_uint_format_value( tree, hf_isis_hello_checksum, tvb, offset, length, checksum,
- "0x%04x [correct]", checksum);
- break;
- default :
- g_message("'check_and_get_checksum' returned an invalid value");
+ }
}
}
diff --git a/epan/dissectors/packet-isis-lsp.c b/epan/dissectors/packet-isis-lsp.c
index 827c6c8b16..3c5e82db14 100644
--- a/epan/dissectors/packet-isis-lsp.c
+++ b/epan/dissectors/packet-isis-lsp.c
@@ -156,8 +156,7 @@ static int hf_isis_lsp_srlg_ipv4_local = -1;
static int hf_isis_lsp_srlg_ipv4_remote = -1;
static int hf_isis_lsp_srlg_value = -1;
static int hf_isis_lsp_checksum = -1;
-static int hf_isis_lsp_checksum_bad = -1;
-static int hf_isis_lsp_checksum_good = -1;
+static int hf_isis_lsp_checksum_status = -1;
static int hf_isis_lsp_clv_ipv4_int_addr = -1;
static int hf_isis_lsp_clv_ipv6_int_addr = -1;
static int hf_isis_lsp_clv_te_router_id = -1;
@@ -3105,25 +3104,6 @@ dissect_lsp_prefix_neighbors_clv(tvbuff_t *tvb, packet_info* pinfo, proto_tree *
}
}
-static void isis_lsp_checkum_additional_info(tvbuff_t * tvb, packet_info * pinfo,
- proto_item * it_cksum, int offset, gboolean is_cksum_correct)
-{
- proto_tree * checksum_tree;
- proto_item * item;
-
- checksum_tree = proto_item_add_subtree(it_cksum, ett_isis_lsp_cksum);
- item = proto_tree_add_boolean(checksum_tree, hf_isis_lsp_checksum_good, tvb,
- offset, 2, is_cksum_correct);
- PROTO_ITEM_SET_GENERATED(item);
- item = proto_tree_add_boolean(checksum_tree, hf_isis_lsp_checksum_bad, tvb,
- offset, 2, !is_cksum_correct);
- PROTO_ITEM_SET_GENERATED(item);
- if (!is_cksum_correct) {
- expert_add_info(pinfo, item, &ie_isis_lsp_checksum_bad);
- col_append_str(pinfo->cinfo, COL_INFO, " [ISIS CHECKSUM INCORRECT]");
- }
-}
-
static const isis_clv_handle_t clv_l1_lsp_opts[] = {
{
ISIS_CLV_AREA_ADDRESS,
@@ -3475,7 +3455,6 @@ dissect_isis_lsp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset
guint16 pdu_length, lifetime, checksum, cacl_checksum=0;
guint8 lsp_info;
int len, offset_checksum;
- proto_item *it_cksum;
char* system_id;
col_set_str(pinfo->cinfo, COL_PROTOCOL, "ISIS LSP");
@@ -3511,28 +3490,23 @@ dissect_isis_lsp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset
offset += 4;
checksum = lifetime ? tvb_get_ntohs(tvb, offset) : 0;
- switch (check_and_get_checksum(tvb, offset_checksum, pdu_length-12, checksum, offset, &cacl_checksum)) {
- case NO_CKSUM :
- checksum = tvb_get_ntohs(tvb, offset);
- proto_tree_add_uint_format_value(lsp_tree, hf_isis_lsp_checksum, tvb, offset, 2, checksum,
- "0x%04x [unused]", checksum);
- break;
- case DATA_MISSING :
+ if (checksum == 0) {
+ /* No checksum present */
+ proto_tree_add_checksum(lsp_tree, tvb, offset_checksum, hf_isis_lsp_checksum, hf_isis_lsp_checksum_status, &ie_isis_lsp_checksum_bad, pinfo, 0, ENC_BIG_ENDIAN, PROTO_CHECKSUM_NOT_PRESENT);
+ } else {
+ if (osi_check_and_get_checksum(tvb, offset_checksum, pdu_length-12, offset, &cacl_checksum)) {
+ /* Successfully processed checksum, verify it */
+ proto_tree_add_checksum(lsp_tree, tvb, offset_checksum, hf_isis_lsp_checksum, hf_isis_lsp_checksum_status, &ie_isis_lsp_checksum_bad, pinfo, cacl_checksum, ENC_BIG_ENDIAN, PROTO_CHECKSUM_VERIFY);
+ if (cacl_checksum != checksum) {
+ col_append_str(pinfo->cinfo, COL_INFO, " [ISIS CHECKSUM INCORRECT]");
+ }
+
+ } else {
+ proto_tree_add_checksum(lsp_tree, tvb, offset_checksum, hf_isis_lsp_checksum, hf_isis_lsp_checksum_status, &ie_isis_lsp_checksum_bad, pinfo, 0, ENC_BIG_ENDIAN, PROTO_CHECKSUM_NO_FLAGS);
proto_tree_add_expert_format(tree, pinfo, &ei_isis_lsp_long_packet, tvb, offset, -1,
"Packet length %d went beyond packet",
tvb_reported_length_remaining(tvb, offset_checksum));
- break;
- case CKSUM_NOT_OK :
- it_cksum = proto_tree_add_uint_format_value(lsp_tree, hf_isis_lsp_checksum, tvb, offset, 2, checksum,
- "0x%04x [incorrect, should be 0x%04x]",
- checksum, cacl_checksum);
- isis_lsp_checkum_additional_info(tvb, pinfo, it_cksum, offset, FALSE);
- break;
- case CKSUM_OK :
- it_cksum = proto_tree_add_uint_format_value(lsp_tree, hf_isis_lsp_checksum, tvb, offset, 2, checksum,
- "0x%04x [correct]", checksum);
- isis_lsp_checkum_additional_info(tvb, pinfo, it_cksum, offset, TRUE);
- break;
+ }
}
offset += 2;
@@ -3675,16 +3649,10 @@ proto_register_isis_lsp(void)
NULL, HFILL }
},
- { &hf_isis_lsp_checksum_good,
- { "Good Checksum", "isis.lsp.checksum_good",
- FT_BOOLEAN, BASE_NONE, NULL, 0x0,
- "Good IS-IS LSP Checksum", HFILL }
- },
-
- { &hf_isis_lsp_checksum_bad,
- { "Bad Checksum", "isis.lsp.checksum_bad",
- FT_BOOLEAN, BASE_NONE, NULL, 0x0,
- "Bad IS-IS LSP Checksum", HFILL }
+ { &hf_isis_lsp_checksum_status,
+ { "Checksum Status", "isis.lsp.checksum.status",
+ FT_UINT8, BASE_NONE, VALS(proto_checksum_vals), 0x0,
+ NULL, HFILL }
},
{ &hf_isis_lsp_clv_ipv4_int_addr,
diff --git a/epan/dissectors/packet-isis-snp.c b/epan/dissectors/packet-isis-snp.c
index cecd0655c6..9041de3c61 100644
--- a/epan/dissectors/packet-isis-snp.c
+++ b/epan/dissectors/packet-isis-snp.c
@@ -134,7 +134,6 @@ dissect_snp_checksum_clv(tvbuff_t *tvb, packet_info* pinfo,
return;
}
- ti = proto_tree_add_item( tree, hf_isis_csnp_checksum, tvb, offset, length, ENC_BIG_ENDIAN);
checksum = tvb_get_ntohs(tvb, offset);
@@ -145,22 +144,18 @@ dissect_snp_checksum_clv(tvbuff_t *tvb, packet_info* pinfo,
pdu_length = tvb_get_ntohs(tvb, 8);
- /* unlike the LSP checksum verification which starts at an offset of 12 we start at offset 0*/
- switch (check_and_get_checksum(tvb, 0, pdu_length, checksum, offset, &cacl_checksum))
- {
- case NO_CKSUM :
- proto_item_append_text(ti, " [unused]");
- break;
- case DATA_MISSING :
- expert_add_info_format(pinfo, ti, &ei_isis_csnp_long_packet,
+ if (checksum == 0) {
+ /* No checksum present */
+ proto_tree_add_checksum(tree, tvb, offset, hf_isis_csnp_checksum, -1, NULL, pinfo, 0, ENC_BIG_ENDIAN, PROTO_CHECKSUM_NOT_PRESENT);
+ } else {
+ if (osi_check_and_get_checksum(tvb, 0, pdu_length, offset, &cacl_checksum)) {
+ /* Successfully processed checksum, verify it */
+ proto_tree_add_checksum(tree, tvb, offset, hf_isis_csnp_checksum, -1, NULL, pinfo, cacl_checksum, ENC_BIG_ENDIAN, PROTO_CHECKSUM_VERIFY);
+ } else {
+ ti = proto_tree_add_checksum(tree, tvb, offset, hf_isis_csnp_checksum, -1, NULL, pinfo, 0, ENC_BIG_ENDIAN, PROTO_CHECKSUM_NO_FLAGS);
+ expert_add_info_format(pinfo, ti, &ei_isis_csnp_long_packet,
"Packet length %d went beyond packet", tvb_captured_length(tvb));
- break;
- case CKSUM_NOT_OK :
- proto_item_append_text(ti, " [incorrect, should be 0x%04x]", cacl_checksum);
- break;
- case CKSUM_OK :
- proto_item_append_text(ti, " [correct]");
- break;
+ }
}
}
diff --git a/epan/dissectors/packet-itdm.c b/epan/dissectors/packet-itdm.c
index 81ca8172d0..cbadee8d3c 100644
--- a/epan/dissectors/packet-itdm.c
+++ b/epan/dissectors/packet-itdm.c
@@ -225,7 +225,7 @@ dissect_itdm_125usec(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
proto_tree_add_item(itdm_tree, hf_itdm_last_pack, tvb, offset, 1, ENC_BIG_ENDIAN);
proto_tree_add_item(itdm_tree, hf_itdm_pktlen, tvb, offset, 2, ENC_BIG_ENDIAN);
offset += 2;
- proto_tree_add_item(itdm_tree, hf_itdm_chksum, tvb, offset, 2, ENC_BIG_ENDIAN);
+ proto_tree_add_checksum(itdm_tree, tvb, offset, hf_itdm_chksum, -1, NULL, pinfo, 0, ENC_BIG_ENDIAN, PROTO_CHECKSUM_NO_FLAGS);
offset += 2;
proto_tree_add_item(itdm_tree, hf_itdm_uid, tvb, offset, 3, ENC_BIG_ENDIAN);
offset += 3;
@@ -318,7 +318,7 @@ dissect_itdm_control(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
proto_tree_add_item(itdm_ctl_tree, hf_itdm_last_pack, tvb, offset, 1, ENC_BIG_ENDIAN);
proto_tree_add_item(itdm_ctl_tree, hf_itdm_pktlen, tvb, offset, 2, ENC_BIG_ENDIAN);
offset += 2;
- proto_tree_add_item(itdm_ctl_tree, hf_itdm_chksum, tvb, offset, 2, ENC_BIG_ENDIAN);
+ proto_tree_add_checksum(itdm_ctl_tree, tvb, offset, hf_itdm_chksum, -1, NULL, pinfo, 0, ENC_BIG_ENDIAN, PROTO_CHECKSUM_NO_FLAGS);
offset += 2;
proto_tree_add_item(itdm_ctl_tree, hf_itdm_uid, tvb, offset, 3, ENC_BIG_ENDIAN);
offset += 3;
diff --git a/epan/dissectors/packet-kingfisher.c b/epan/dissectors/packet-kingfisher.c
index 66d0b60ea9..5686bb7350 100644
--- a/epan/dissectors/packet-kingfisher.c
+++ b/epan/dissectors/packet-kingfisher.c
@@ -294,7 +294,7 @@ dissect_kingfisher(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gboolean
proto_tree_add_uint_format_value(kingfisher_tree, hf_kingfisher_message, tvb, 5, 1, kfp.message, "%u (0x%02X, %s)", message, kfp.message, ((kfp.message & 0xf0)?"Response":"Request"));
/* message function code */
- proto_tree_add_uint_format(kingfisher_tree, hf_kingfisher_function, tvb, 6, 1, kfp.function, "Message Function Code: %u (0x%02X, %s)", kfp.function, kfp.function, func_string);
+ proto_tree_add_uint_format_value(kingfisher_tree, hf_kingfisher_function, tvb, 6, 1, kfp.function, "%u (0x%02X, %s)", kfp.function, kfp.function, func_string);
/* message data */
if(kfp.length > ((kfp.version==3)?11:8)){
@@ -302,9 +302,7 @@ dissect_kingfisher(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gboolean
}
/* checksum */
- proto_tree_add_uint_format_value(kingfisher_tree, hf_kingfisher_checksum, tvb, kfp.length-1, 2, kfp.checksum, "0x%04X [%s]", kfp.checksum, ((checksum != kfp.checksum)?"incorrect":"correct"));
-
-
+ proto_tree_add_checksum(kingfisher_tree, tvb, kfp.length-1, hf_kingfisher_checksum, -1, NULL, pinfo, checksum, ENC_BIG_ENDIAN, PROTO_CHECKSUM_VERIFY);
return TRUE;
}
@@ -351,7 +349,7 @@ proto_register_kingfisher( void )
{ &hf_kingfisher_target, { "Target RTU", "kingfisher.target", FT_UINT16, BASE_DEC_HEX, NULL, 0x0, NULL, HFILL } },
{ &hf_kingfisher_via, { "Via RTU", "kingfisher.via", FT_UINT16, BASE_DEC_HEX, NULL, 0x0, NULL, HFILL } },
{ &hf_kingfisher_message, { "Message Number", "kingfisher.message", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL } },
- { &hf_kingfisher_function, { "Function Code", "kingfisher.function", FT_UINT8, BASE_DEC, VALS( function_code_vals ), 0x0, NULL, HFILL } },
+ { &hf_kingfisher_function, { "Message Function Code", "kingfisher.function", FT_UINT8, BASE_DEC, VALS( function_code_vals ), 0x0, NULL, HFILL } },
{ &hf_kingfisher_checksum, { "Checksum", "kingfisher.checksum", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL } },
{ &hf_kingfisher_message_data, { "Message Data", "kingfisher.message_data", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL } },
};
diff --git a/epan/dissectors/packet-lapd.c b/epan/dissectors/packet-lapd.c
index 467977cd8b..8f782c0aad 100644
--- a/epan/dissectors/packet-lapd.c
+++ b/epan/dissectors/packet-lapd.c
@@ -74,8 +74,7 @@ static int hf_lapd_ftype_i = -1;
static int hf_lapd_ftype_s_u = -1;
static int hf_lapd_ftype_s_u_ext = -1;
static int hf_lapd_checksum = -1;
-static int hf_lapd_checksum_good = -1;
-static int hf_lapd_checksum_bad = -1;
+static int hf_lapd_checksum_status = -1;
static gint ett_lapd = -1;
static gint ett_lapd_address = -1;
@@ -417,10 +416,10 @@ dissect_lapd(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_
static void
dissect_lapd_full(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gboolean has_crc)
{
- proto_tree *lapd_tree, *addr_tree, *checksum_tree;
- proto_item *lapd_ti, *addr_ti, *checksum_ti;
+ proto_tree *lapd_tree, *addr_tree;
+ proto_item *lapd_ti, *addr_ti;
int direction;
- guint16 control, checksum, checksum_calculated;
+ guint16 control;
int lapd_header_len, checksum_offset;
guint16 addr, cr, sapi, tei;
gboolean is_response = 0;
@@ -543,25 +542,9 @@ dissect_lapd_full(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gboolean
/* check checksum */
checksum_offset = tvb_reported_length(tvb) - 2;
- checksum = tvb_get_guint8(tvb, checksum_offset); /* high byte */
- checksum <<= 8;
- checksum |= tvb_get_guint8(tvb, checksum_offset+1) & 0x00FF; /* low byte */
- checksum_calculated = crc16_ccitt_tvb(tvb, tvb_reported_length(tvb) - 2);
- checksum_calculated = g_htons(checksum_calculated); /* Note: g_htons() macro may eval arg multiple times */
-
- if (checksum == checksum_calculated) {
- checksum_ti = proto_tree_add_uint_format_value(lapd_tree, hf_lapd_checksum, tvb, checksum_offset, 2, 0,"0x%04x [correct]", checksum);
- checksum_tree = proto_item_add_subtree(checksum_ti, ett_lapd_checksum);
- proto_tree_add_boolean(checksum_tree, hf_lapd_checksum_good, tvb, checksum_offset, 2, TRUE);
- proto_tree_add_boolean(checksum_tree, hf_lapd_checksum_bad, tvb, checksum_offset, 2, FALSE);
- } else {
- proto_item *pi;
- checksum_ti = proto_tree_add_uint_format_value(lapd_tree, hf_lapd_checksum, tvb, checksum_offset, 2, 0,"0x%04x [incorrect, should be 0x%04x]", checksum, checksum_calculated);
- checksum_tree = proto_item_add_subtree(checksum_ti, ett_lapd_checksum);
- proto_tree_add_boolean(checksum_tree, hf_lapd_checksum_good, tvb, checksum_offset, 2, FALSE);
- pi = proto_tree_add_boolean(checksum_tree, hf_lapd_checksum_bad, tvb, checksum_offset, 2, TRUE);
- expert_add_info(pinfo, pi, &ei_lapd_checksum_bad);
- }
+
+ proto_tree_add_checksum(lapd_tree, tvb, checksum_offset, hf_lapd_checksum, hf_lapd_checksum_status, &ei_lapd_checksum_bad, pinfo,
+ crc16_ccitt_tvb(tvb, tvb_reported_length(tvb) - 2), ENC_BIG_ENDIAN, PROTO_CHECKSUM_VERIFY);
next_tvb = tvb_new_subset_length(tvb, lapd_header_len, tvb_reported_length_remaining(tvb,lapd_header_len) - 2);
@@ -702,13 +685,9 @@ proto_register_lapd(void)
{ "Checksum", "lapd.checksum", FT_UINT16, BASE_HEX,
NULL, 0x0, "Details at: http://www.wireshark.org/docs/wsug_html_chunked/ChAdvChecksums.html", HFILL }},
- { &hf_lapd_checksum_good,
- { "Good Checksum", "lapd.checksum_good", FT_BOOLEAN, BASE_NONE,
- NULL, 0x0, "True: checksum matches packet content; False: doesn't match content or not checked", HFILL }},
-
- { &hf_lapd_checksum_bad,
- { "Bad Checksum", "lapd.checksum_bad", FT_BOOLEAN, BASE_NONE,
- NULL, 0x0, "True: checksum doesn't match packet content; False: matches content or not checked", HFILL }},
+ { &hf_lapd_checksum_status,
+ { "Checksum Status", "lapd.checksum.status", FT_UINT8, BASE_NONE,
+ VALS(proto_checksum_vals), 0x0, NULL, HFILL }},
};
static gint *ett[] = {
&ett_lapd,
diff --git a/epan/dissectors/packet-lmp.c b/epan/dissectors/packet-lmp.c
index 500a7e0b7f..9b93e235aa 100644
--- a/epan/dissectors/packet-lmp.c
+++ b/epan/dissectors/packet-lmp.c
@@ -707,7 +707,6 @@ dissect_lmp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_)
proto_item *hidden_item, *msg_item;
guint8 message_type;
- guint16 cksum, computed_cksum;
vec_t cksum_vec[1];
int j, k, l, len;
int msg_length;
@@ -759,24 +758,16 @@ dissect_lmp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_)
}
if (lmp_checksum_config) {
- cksum = tvb_get_ntohs(tvb, offset+6);
- ti = proto_tree_add_item(lmp_header_tree, hf_lmp_filter[LMPF_CHECKSUM], tvb,
- offset+6, 2, ENC_BIG_ENDIAN);
if (!pinfo->fragmented && (int) tvb_captured_length(tvb) >= msg_length) {
/* The packet isn't part of a fragmented datagram and isn't truncated, so we can checksum it. */
SET_CKSUM_VEC_TVB(cksum_vec[0], tvb, 0, msg_length);
- computed_cksum = in_cksum(cksum_vec, 1);
-
- if (computed_cksum == 0) {
- proto_item_append_text( ti, " [correct]");
- }
- else {
- expert_add_info_format(pinfo, ti, &ei_lmp_checksum_incorrect, "[incorrect, should be 0x%04x]",
- in_cksum_shouldbe(cksum, computed_cksum));
- }
+ proto_tree_add_checksum(lmp_header_tree, tvb, offset+6, hf_lmp_filter[LMPF_CHECKSUM], -1, &ei_lmp_checksum_incorrect, pinfo,
+ in_cksum(cksum_vec, 1), ENC_BIG_ENDIAN, PROTO_CHECKSUM_VERIFY|PROTO_CHECKSUM_IN_CKSUM);
+ } else {
+ proto_tree_add_checksum(lmp_header_tree, tvb, offset+6, hf_lmp_filter[LMPF_CHECKSUM], -1, &ei_lmp_checksum_incorrect, pinfo, 0, ENC_BIG_ENDIAN, PROTO_CHECKSUM_NO_FLAGS);
}
} else {
- proto_tree_add_uint_format_value(lmp_header_tree, hf_lmp_filter[LMPF_CHECKSUM], tvb, offset+6, 2, 0, "[None]");
+ proto_tree_add_checksum(lmp_header_tree, tvb, offset+6, hf_lmp_filter[LMPF_CHECKSUM], -1, &ei_lmp_checksum_incorrect, pinfo, 0, ENC_BIG_ENDIAN, PROTO_CHECKSUM_NOT_PRESENT);
}
offset += 8;
diff --git a/epan/dissectors/packet-manolito.c b/epan/dissectors/packet-manolito.c
index c94e646cbf..fecbcecb25 100644
--- a/epan/dissectors/packet-manolito.c
+++ b/epan/dissectors/packet-manolito.c
@@ -90,8 +90,8 @@ dissect_manolito(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* diss
manolito_tree = proto_item_add_subtree(ti, ett_manolito);
/* MANOLITO packet header (network byte order) */
- proto_tree_add_item(manolito_tree,
- hf_manolito_checksum, tvb, offset, 4, ENC_BIG_ENDIAN);
+ proto_tree_add_checksum(manolito_tree, tvb, offset, hf_manolito_checksum,
+ -1, NULL, pinfo, 0, ENC_BIG_ENDIAN, PROTO_CHECKSUM_NO_FLAGS);
offset += 4;
proto_tree_add_item(manolito_tree,
hf_manolito_seqno, tvb, offset, 4, ENC_BIG_ENDIAN);
diff --git a/epan/dissectors/packet-mbtcp.c b/epan/dissectors/packet-mbtcp.c
index c388a90c1a..a1b0b80ae2 100644
--- a/epan/dissectors/packet-mbtcp.c
+++ b/epan/dissectors/packet-mbtcp.c
@@ -517,14 +517,14 @@ static int
dissect_mbrtu_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
{
/* Set up structures needed to add the protocol subtree and manage it */
- proto_item *mi, *crc_item;
+ proto_item *mi;
proto_tree *mbrtu_tree;
int offset, packet_type;
tvbuff_t *next_tvb;
const char *func_string = "";
const char *pkt_type_str = "";
const char *err_str = "";
- guint16 len, crc16, calc_crc16;
+ guint16 len, calc_crc16;
guint8 unit_id, function_code, exception_code, subfunction_code;
/* Make entries in Protocol column on summary display */
@@ -535,7 +535,6 @@ dissect_mbrtu_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* dat
unit_id = tvb_get_guint8(tvb, 0);
function_code = tvb_get_guint8(tvb, 1) & 0x7F;
- crc16 = tvb_get_ntohs(tvb, len-2);
offset = 0;
@@ -618,14 +617,16 @@ dissect_mbrtu_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* dat
/* Add items to protocol tree specific to Modbus RTU */
proto_tree_add_uint(mbrtu_tree, hf_mbrtu_unitid, tvb, offset, 1, unit_id);
- crc_item = proto_tree_add_uint(mbrtu_tree, hf_mbrtu_crc16, tvb, len-2, 2, crc16);
/* CRC validation */
if (mbrtu_crc)
{
calc_crc16 = crc16_plain_tvb_offset_seed(tvb, offset, len-2, 0xFFFF);
- if (g_htons(calc_crc16) != crc16)
- expert_add_info_format(pinfo, crc_item, &ei_mbrtu_crc16_incorrect, "Incorrect CRC - should be 0x%04x", g_htons(calc_crc16));
+ proto_tree_add_checksum(mbrtu_tree, tvb, len-2, hf_mbrtu_crc16, -1, &ei_mbrtu_crc16_incorrect, pinfo, g_htons(calc_crc16), ENC_BIG_ENDIAN, PROTO_CHECKSUM_VERIFY);
+ }
+ else
+ {
+ proto_tree_add_checksum(mbrtu_tree, tvb, len-2, hf_mbrtu_crc16, -1, &ei_mbrtu_crc16_incorrect, pinfo, 0, ENC_BIG_ENDIAN, PROTO_CHECKSUM_NO_FLAGS);
}
/* when determining payload length, make sure to ignore the unit ID header & CRC-16 footer bytes */
diff --git a/epan/dissectors/packet-mip6.c b/epan/dissectors/packet-mip6.c
index e96c00c25f..98c8b5dea4 100644
--- a/epan/dissectors/packet-mip6.c
+++ b/epan/dissectors/packet-mip6.c
@@ -4093,8 +4093,8 @@ dissect_mip6(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_
proto_tree_add_item(mip6_tree, hf_mip6_reserved, tvb,
MIP6_RES_OFF, 1, ENC_BIG_ENDIAN);
- proto_tree_add_item(mip6_tree, hf_mip6_csum, tvb,
- MIP6_CSUM_OFF, 2, ENC_BIG_ENDIAN);
+ proto_tree_add_checksum(mip6_tree, tvb, MIP6_CSUM_OFF, hf_mip6_csum,
+ -1, NULL, pinfo, 0, ENC_BIG_ENDIAN, PROTO_CHECKSUM_NO_FLAGS);
/* Process mobility header */
type = tvb_get_guint8(tvb, MIP6_TYPE_OFF);
diff --git a/epan/dissectors/packet-mpeg-dsmcc.c b/epan/dissectors/packet-mpeg-dsmcc.c
index 1c8f9c13d0..191f15289f 100644
--- a/epan/dissectors/packet-mpeg-dsmcc.c
+++ b/epan/dissectors/packet-mpeg-dsmcc.c
@@ -800,8 +800,8 @@ dissect_dsmcc_ts(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree_in, void *d
}
} else {
/* TODO: actually check the checksum */
- proto_tree_add_item(tree, hf_dsmcc_checksum, tvb,
- crc_len, 4, ENC_BIG_ENDIAN);
+ proto_tree_add_checksum(tree, tvb, crc_len, hf_dsmcc_checksum,
+ -1, NULL, pinfo, 0, ENC_BIG_ENDIAN, PROTO_CHECKSUM_NO_FLAGS);
}
return tvb_reported_length(tvb);
diff --git a/epan/dissectors/packet-mpeg-sect.c b/epan/dissectors/packet-mpeg-sect.c
index 5ab94ef483..12af8aaf5b 100644
--- a/epan/dissectors/packet-mpeg-sect.c
+++ b/epan/dissectors/packet-mpeg-sect.c
@@ -37,6 +37,7 @@ static int hf_mpeg_sect_syntax_indicator = -1;
static int hf_mpeg_sect_reserved = -1;
static int hf_mpeg_sect_length = -1;
static int hf_mpeg_sect_crc = -1;
+static int hf_mpeg_sect_crc_status = -1;
static gint ett_mpeg_sect = -1;
@@ -247,30 +248,12 @@ guint
packet_mpeg_sect_crc(tvbuff_t *tvb, packet_info *pinfo,
proto_tree *tree, guint start, guint end)
{
- guint32 crc, calculated_crc;
- const char *label;
-
- crc = tvb_get_ntohl(tvb, end);
-
- calculated_crc = crc;
- label = "Unverified";
if (mpeg_sect_check_crc) {
- label = "Verified";
- calculated_crc = crc32_mpeg2_tvb_offset(tvb, start, end);
- }
-
- if (calculated_crc == crc) {
- proto_tree_add_uint_format( tree, hf_mpeg_sect_crc, tvb,
- end, 4, crc, "CRC: 0x%08x [%s]", crc, label);
+ proto_tree_add_checksum(tree, tvb, end, hf_mpeg_sect_crc, hf_mpeg_sect_crc_status, &ei_mpeg_sect_crc, pinfo, crc32_mpeg2_tvb_offset(tvb, start, end),
+ ENC_BIG_ENDIAN, PROTO_CHECKSUM_VERIFY);
} else {
- proto_item *msg_error;
-
- msg_error = proto_tree_add_uint_format( tree, hf_mpeg_sect_crc, tvb,
- end, 4, crc,
- "CRC: 0x%08x [Failed Verification (Calculated: 0x%08x)]",
- crc, calculated_crc );
- PROTO_ITEM_SET_GENERATED(msg_error);
- expert_add_info( pinfo, msg_error, &ei_mpeg_sect_crc);
+ proto_tree_add_checksum(tree, tvb, end, hf_mpeg_sect_crc, hf_mpeg_sect_crc_status, &ei_mpeg_sect_crc, pinfo, crc32_mpeg2_tvb_offset(tvb, start, end),
+ ENC_BIG_ENDIAN, PROTO_CHECKSUM_NO_FLAGS);
}
return 4;
@@ -348,7 +331,13 @@ proto_register_mpeg_sect(void)
{ &hf_mpeg_sect_crc, {
"CRC 32", "mpeg_sect.crc",
FT_UINT32, BASE_HEX, NULL, 0, NULL, HFILL
- } }
+ } },
+
+ { &hf_mpeg_sect_crc_status, {
+ "CRC 32 Status", "mpeg_sect.crc.status",
+ FT_UINT8, BASE_NONE, VALS(proto_checksum_vals), 0, NULL, HFILL
+ } },
+
};
static gint *ett[] = {
diff --git a/epan/dissectors/packet-mrdisc.c b/epan/dissectors/packet-mrdisc.c
index 25637fc8cf..45fa7f4349 100644
--- a/epan/dissectors/packet-mrdisc.c
+++ b/epan/dissectors/packet-mrdisc.c
@@ -46,7 +46,7 @@ void proto_reg_handoff_mrdisc(void);
static int proto_mrdisc = -1;
static int hf_checksum = -1;
-static int hf_checksum_bad = -1;
+static int hf_checksum_status = -1;
static int hf_type = -1;
static int hf_advint = -1;
static int hf_numopts = -1;
@@ -91,7 +91,7 @@ dissect_mrdisc_mra(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, i
offset += 1;
/* checksum */
- igmp_checksum(parent_tree, tvb, hf_checksum, hf_checksum_bad, pinfo, 0);
+ igmp_checksum(parent_tree, tvb, hf_checksum, hf_checksum_status, pinfo, 0);
offset += 2;
/* skip unused bytes */
@@ -160,7 +160,7 @@ dissect_mrdisc_mrst(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree,
offset += 1;
/* checksum */
- igmp_checksum(parent_tree, tvb, hf_checksum, hf_checksum_bad, pinfo, 0);
+ igmp_checksum(parent_tree, tvb, hf_checksum, hf_checksum_status, pinfo, 0);
offset += 2;
return offset;
@@ -222,9 +222,9 @@ proto_register_mrdisc(void)
{ "Checksum", "mrdisc.checksum", FT_UINT16, BASE_HEX,
NULL, 0, "MRDISC Checksum", HFILL }},
- { &hf_checksum_bad,
- { "Bad Checksum", "mrdisc.checksum_bad", FT_BOOLEAN, BASE_NONE,
- NULL, 0x0, "Bad MRDISC Checksum", HFILL }},
+ { &hf_checksum_status,
+ { "Checksum Status", "mrdisc.checksum.status", FT_UINT8, BASE_NONE,
+ VALS(proto_checksum_vals), 0x0, NULL, HFILL }},
{ &hf_advint,
{ "Advertising Interval", "mrdisc.adv_int", FT_UINT8, BASE_DEC,
diff --git a/epan/dissectors/packet-msnip.c b/epan/dissectors/packet-msnip.c
index e1544a418e..46ea45e359 100644
--- a/epan/dissectors/packet-msnip.c
+++ b/epan/dissectors/packet-msnip.c
@@ -44,7 +44,7 @@ void proto_reg_handoff_msnip(void);
static int proto_msnip = -1;
static int hf_checksum = -1;
-static int hf_checksum_bad = -1;
+static int hf_checksum_status = -1;
static int hf_type = -1;
static int hf_count = -1;
static int hf_holdtime = -1;
@@ -89,7 +89,7 @@ dissect_msnip_rmr(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, in
offset += 1;
/* checksum */
- igmp_checksum(parent_tree, tvb, hf_checksum, hf_checksum_bad, pinfo, 0);
+ igmp_checksum(parent_tree, tvb, hf_checksum, hf_checksum_status, pinfo, 0);
offset += 2;
while (count--) {
@@ -135,7 +135,7 @@ dissect_msnip_is(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, int
offset += 1;
/* checksum */
- igmp_checksum(parent_tree, tvb, hf_checksum, hf_checksum_bad, pinfo, 0);
+ igmp_checksum(parent_tree, tvb, hf_checksum, hf_checksum_status, pinfo, 0);
offset += 2;
/* 16 bit holdtime */
@@ -161,7 +161,7 @@ dissect_msnip_gm(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, int
offset += 1;
/* checksum */
- igmp_checksum(parent_tree, tvb, hf_checksum, hf_checksum_bad, pinfo, 0);
+ igmp_checksum(parent_tree, tvb, hf_checksum, hf_checksum_status, pinfo, 0);
offset += 2;
/* holdtime */
@@ -264,9 +264,9 @@ proto_register_msnip(void)
{ "Checksum", "msnip.checksum", FT_UINT16, BASE_HEX,
NULL, 0, "MSNIP Checksum", HFILL }},
- { &hf_checksum_bad,
- { "Bad Checksum", "msnip.checksum_bad", FT_BOOLEAN, BASE_NONE,
- NULL, 0x0, "Bad MSNIP Checksum", HFILL }},
+ { &hf_checksum_status,
+ { "Checksum Status", "msnip.checksum.status", FT_UINT8, BASE_NONE,
+ VALS(proto_checksum_vals), 0x0, NULL, HFILL }},
{ &hf_count,
{ "Count", "msnip.count", FT_UINT8, BASE_DEC,
diff --git a/epan/dissectors/packet-mstp.c b/epan/dissectors/packet-mstp.c
index a97365f655..5b3c3a842f 100644
--- a/epan/dissectors/packet-mstp.c
+++ b/epan/dissectors/packet-mstp.c
@@ -86,8 +86,7 @@ static int hf_mstp_frame_vendor_id = -1;
static int hf_mstp_frame_pdu_len = -1;
static int hf_mstp_frame_crc8 = -1;
static int hf_mstp_frame_crc16 = -1;
-static int hf_mstp_frame_checksum_bad = -1;
-static int hf_mstp_frame_checksum_good = -1;
+static int hf_mstp_frame_checksum_status = -1;
static expert_field ei_mstp_frame_pdu_len = EI_INIT;
static expert_field ei_mstp_frame_checksum_bad = EI_INIT;
@@ -190,12 +189,11 @@ dissect_mstp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
proto_item *item;
#if defined(BACNET_MSTP_CHECKSUM_VALIDATE)
/* used to calculate the crc value */
- guint8 crc8 = 0xFF, framecrc8;
- guint16 crc16 = 0xFFFF, framecrc16;
+ guint8 crc8 = 0xFF;
+ guint16 crc16 = 0xFFFF;
guint8 crcdata;
guint16 i; /* loop counter */
guint16 max_len = 0;
- proto_tree *checksum_tree;
#endif
col_set_str(pinfo->cinfo, COL_PROTOCOL, "BACnet");
@@ -228,39 +226,11 @@ dissect_mstp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
crc8 = CRC_Calc_Header(crcdata, crc8);
}
crc8 = ~crc8;
- framecrc8 = tvb_get_guint8(tvb, offset+5);
- if (framecrc8 == crc8) {
- item = proto_tree_add_uint_format_value(subtree, hf_mstp_frame_crc8,
- tvb, offset+5, 1, framecrc8,
- "0x%02x [correct]", framecrc8);
- checksum_tree = proto_item_add_subtree(item, ett_bacnet_mstp_checksum);
- item = proto_tree_add_boolean(checksum_tree,
- hf_mstp_frame_checksum_good,
- tvb, offset+5, 1, TRUE);
- PROTO_ITEM_SET_GENERATED(item);
- item = proto_tree_add_boolean(checksum_tree,
- hf_mstp_frame_checksum_bad,
- tvb, offset+5, 1, FALSE);
- PROTO_ITEM_SET_GENERATED(item);
- } else {
- item = proto_tree_add_uint_format_value(subtree, hf_mstp_frame_crc8,
- tvb, offset+5, 1, framecrc8,
- "0x%02x [incorrect, should be 0x%02x]",
- framecrc8, crc8);
- checksum_tree = proto_item_add_subtree(item, ett_bacnet_mstp_checksum);
- item = proto_tree_add_boolean(checksum_tree,
- hf_mstp_frame_checksum_good,
- tvb, offset+5, 1, FALSE);
- PROTO_ITEM_SET_GENERATED(item);
- item = proto_tree_add_boolean(checksum_tree,
- hf_mstp_frame_checksum_bad,
- tvb, offset+5, 1, TRUE);
- PROTO_ITEM_SET_GENERATED(item);
- expert_add_info(pinfo, item, &ei_mstp_frame_checksum_bad);
- }
+ proto_tree_add_checksum(subtree, tvb, offset+5, hf_mstp_frame_crc8, hf_mstp_frame_checksum_status, &ei_mstp_frame_checksum_bad, pinfo, crc8,
+ ENC_BIG_ENDIAN, PROTO_CHECKSUM_VERIFY);
#else
- proto_tree_add_item(subtree, hf_mstp_frame_crc8,
- tvb, offset+5, 1, ENC_LITTLE_ENDIAN);
+ proto_tree_add_checksum(subtree, tvb, offset+5, hf_mstp_frame_crc8, hf_mstp_frame_checksum_status, &ei_mstp_frame_checksum_bad, pinfo, 0,
+ PROTO_CHECKSUM_NO_FLAGS);
#endif
/* dissect BACnet PDU if there is one */
@@ -300,42 +270,12 @@ dissect_mstp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
crc16 = ~crc16;
/* convert it to on-the-wire format */
crc16 = g_htons(crc16);
- /* get the actual CRC from the frame */
- framecrc16 = tvb_get_ntohs(tvb, offset+mstp_frame_pdu_len);
- if (framecrc16 == crc16) {
- item = proto_tree_add_uint_format_value(subtree, hf_mstp_frame_crc16,
- tvb, offset+mstp_frame_pdu_len, 2, framecrc16,
- "0x%04x [correct]", framecrc16);
- checksum_tree = proto_item_add_subtree(item,
- ett_bacnet_mstp_checksum);
- item = proto_tree_add_boolean(checksum_tree,
- hf_mstp_frame_checksum_good,
- tvb, offset+mstp_frame_pdu_len, 2, TRUE);
- PROTO_ITEM_SET_GENERATED(item);
- item = proto_tree_add_boolean(checksum_tree,
- hf_mstp_frame_checksum_bad,
- tvb, offset+mstp_frame_pdu_len, 2, FALSE);
- PROTO_ITEM_SET_GENERATED(item);
- } else {
- item = proto_tree_add_uint_format_value(subtree, hf_mstp_frame_crc16,
- tvb, offset+mstp_frame_pdu_len, 2, framecrc16,
- "0x%04x [incorrect, should be 0x%04x]",
- framecrc16, crc16);
- checksum_tree = proto_item_add_subtree(item,
- ett_bacnet_mstp_checksum);
- item = proto_tree_add_boolean(checksum_tree,
- hf_mstp_frame_checksum_good,
- tvb, offset+mstp_frame_pdu_len, 2, FALSE);
- PROTO_ITEM_SET_GENERATED(item);
- item = proto_tree_add_boolean(checksum_tree,
- hf_mstp_frame_checksum_bad,
- tvb, offset+mstp_frame_pdu_len, 2, TRUE);
- PROTO_ITEM_SET_GENERATED(item);
- expert_add_info(pinfo, item, &ei_mstp_frame_checksum_bad);
- }
+
+ proto_tree_add_checksum(subtree, tvb, offset+mstp_frame_pdu_len, hf_mstp_frame_crc16, hf_mstp_frame_checksum_status, &ei_mstp_frame_checksum_bad, pinfo, crc16,
+ ENC_BIG_ENDIAN, PROTO_CHECKSUM_VERIFY);
#else
- proto_tree_add_item(subtree, hf_mstp_frame_crc16,
- tvb, offset+mstp_frame_pdu_len, 2, ENC_LITTLE_ENDIAN);
+ proto_tree_add_checksum(subtree, tvb, offset+mstp_frame_pdu_len, hf_mstp_frame_crc16, hf_mstp_frame_checksum_status, &ei_mstp_frame_checksum_bad, pinfo, 0,
+ ENC_BIG_ENDIAN, PROTO_CHECKSUM_NO_FLAGS);
#endif
}
}
@@ -427,16 +367,11 @@ proto_register_mstp(void)
FT_UINT16, BASE_HEX, NULL, 0,
"MS/TP Data CRC", HFILL }
},
- { &hf_mstp_frame_checksum_bad,
- { "Bad", "mstp.checksum_bad",
- FT_BOOLEAN, BASE_NONE, NULL, 0x0,
- "True: checksum doesn't match packet content; False: matches content or not checked", HFILL }
+ { &hf_mstp_frame_checksum_status,
+ { "Checksum status", "mstp.checksum.status",
+ FT_UINT8, BASE_NONE, VALS(proto_checksum_vals), 0x0,
+ NULL, HFILL }
},
- { &hf_mstp_frame_checksum_good,
- { "Good", "mstp.checksum_good",
- FT_BOOLEAN, BASE_NONE, NULL, 0x0,
- "True: checksum matches packet content; False: doesn't match content or not checked", HFILL }
- }
};
static gint *ett[] = {
diff --git a/epan/dissectors/packet-mswsp.c b/epan/dissectors/packet-mswsp.c
index de3d0826d2..c025d428b9 100644
--- a/epan/dissectors/packet-mswsp.c
+++ b/epan/dissectors/packet-mswsp.c
@@ -6324,8 +6324,7 @@ dissect_mswsp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gboolean in,
"(Unknown: 0x%x)"));
}
- proto_tree_add_item(hdr_tree, hf_mswsp_hdr_checksum, tvb,
- 8, 4, ENC_LITTLE_ENDIAN);
+ proto_tree_add_checksum(hdr_tree, tvb, 8, hf_mswsp_hdr_checksum, -1, NULL, pinfo, 0, ENC_LITTLE_ENDIAN, PROTO_CHECKSUM_NO_FLAGS);
/* todo: validate checksum */
proto_tree_add_item(hdr_tree, hf_mswsp_hdr_reserved, tvb,
diff --git a/epan/dissectors/packet-mtp2.c b/epan/dissectors/packet-mtp2.c
index 76fb4be073..bc82b455c5 100644
--- a/epan/dissectors/packet-mtp2.c
+++ b/epan/dissectors/packet-mtp2.c
@@ -148,11 +148,7 @@ mtp2_decode_crc16(tvbuff_t *tvb, proto_tree *fh_tree, packet_info *pinfo)
{
tvbuff_t *next_tvb;
gint len, reported_len;
- int rx_fcs_offset;
- guint32 rx_fcs_exp;
- guint32 rx_fcs_got;
int proto_offset=0;
- proto_item *cause;
/*
* Do we have the entire packet, and does it include a 2-byte FCS?
@@ -191,16 +187,8 @@ mtp2_decode_crc16(tvbuff_t *tvb, proto_tree *fh_tree, packet_info *pinfo)
/*
* Compute the FCS and put it into the tree.
*/
- rx_fcs_offset = proto_offset + len;
- rx_fcs_exp = mtp2_fcs16(tvb);
- rx_fcs_got = tvb_get_letohs(tvb, rx_fcs_offset);
- cause=proto_tree_add_item(fh_tree, hf_mtp2_fcs_16, tvb, rx_fcs_offset, 2, ENC_LITTLE_ENDIAN);
- if (rx_fcs_got != rx_fcs_exp) {
- proto_item_append_text(cause, " [incorrect, should be 0x%04x]", rx_fcs_exp);
- expert_add_info(pinfo, cause, &ei_mtp2_checksum_error);
- } else {
- proto_item_append_text(cause, " [correct]");
- }
+ proto_tree_add_checksum(fh_tree, tvb, proto_offset + len, hf_mtp2_fcs_16, -1, &ei_mtp2_checksum_error, pinfo, mtp2_fcs16(tvb),
+ ENC_BIG_ENDIAN, PROTO_CHECKSUM_VERIFY);
}
return next_tvb;
}
diff --git a/epan/dissectors/packet-netsync.c b/epan/dissectors/packet-netsync.c
index 90ba55bce5..f399b9423a 100644
--- a/epan/dissectors/packet-netsync.c
+++ b/epan/dissectors/packet-netsync.c
@@ -535,8 +535,8 @@ dissect_netsync_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* d
offset += size;
- proto_tree_add_item(netsync_tree, hf_netsync_checksum, tvb,
- offset, 4, ENC_BIG_ENDIAN );
+ proto_tree_add_checksum(netsync_tree, tvb, offset, hf_netsync_checksum,
+ -1, NULL, pinfo, 0, ENC_BIG_ENDIAN, PROTO_CHECKSUM_NO_FLAGS );
offset += 4;
diff --git a/epan/dissectors/packet-nhrp.c b/epan/dissectors/packet-nhrp.c
index c073a5b838..a09b730840 100644
--- a/epan/dissectors/packet-nhrp.c
+++ b/epan/dissectors/packet-nhrp.c
@@ -282,14 +282,6 @@ typedef struct _e_nhrp {
guint8 ar_sstl;
} e_nhrp_hdr;
-static guint16 nhrp_checksum(tvbuff_t *tvb, int len)
-{
- vec_t cksum_vec[1];
-
- SET_CKSUM_VEC_TVB(cksum_vec[0], tvb, 0, len);
- return in_cksum(&cksum_vec[0], 1);
-}
-
static void dissect_nhrp_hdr(tvbuff_t *tvb,
packet_info *pinfo,
proto_tree *tree,
@@ -302,7 +294,6 @@ static void dissect_nhrp_hdr(tvbuff_t *tvb,
gint offset = *pOffset;
const gchar *pro_type_str;
guint total_len = tvb_reported_length(tvb);
- guint16 ipcsum, rx_chksum;
proto_tree *nhrp_tree;
proto_item *shtl_tree_item;
@@ -379,20 +370,14 @@ static void dissect_nhrp_hdr(tvbuff_t *tvb,
proto_tree_add_item(nhrp_tree, hf_nhrp_hdr_pktsz, tvb, offset, 2, ENC_BIG_ENDIAN);
offset += 2;
- rx_chksum = tvb_get_ntohs(tvb, offset);
if (tvb_bytes_exist(tvb, 0, total_len)) {
- ipcsum = nhrp_checksum(tvb, total_len);
- if (ipcsum == 0) {
- proto_tree_add_uint_format_value(nhrp_tree, hf_nhrp_hdr_chksum, tvb, offset, 2, rx_chksum,
- "0x%04x [correct]", rx_chksum);
- } else {
- proto_tree_add_uint_format_value(nhrp_tree, hf_nhrp_hdr_chksum, tvb, offset, 2, rx_chksum,
- "0x%04x [incorrect, should be 0x%04x]", rx_chksum,
- in_cksum_shouldbe(rx_chksum, ipcsum));
- }
+ vec_t cksum_vec[1];
+ SET_CKSUM_VEC_TVB(cksum_vec[0], tvb, 0, total_len);
+
+ proto_tree_add_checksum(nhrp_tree, tvb, offset, hf_nhrp_hdr_chksum, -1, NULL, pinfo, in_cksum(&cksum_vec[0], 1),
+ ENC_BIG_ENDIAN, PROTO_CHECKSUM_VERIFY|PROTO_CHECKSUM_IN_CKSUM);
} else {
- proto_tree_add_uint_format_value(nhrp_tree, hf_nhrp_hdr_chksum, tvb, offset, 2, rx_chksum,
- "0x%04x [not all data available]", rx_chksum);
+ proto_tree_add_checksum(nhrp_tree, tvb, offset, hf_nhrp_hdr_chksum, -1, NULL, pinfo, 0, ENC_BIG_ENDIAN, PROTO_CHECKSUM_NO_FLAGS);
}
offset += 2;
diff --git a/epan/dissectors/packet-nlsp.c b/epan/dissectors/packet-nlsp.c
index c23356ee63..37a2ea3fef 100644
--- a/epan/dissectors/packet-nlsp.c
+++ b/epan/dissectors/packet-nlsp.c
@@ -945,9 +945,7 @@ nlsp_dissect_nlsp_lsp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
offset += 4;
/* XXX -> we could validate the cksum here! */
- proto_tree_add_item(tree, hf_nlsp_lsp_checksum, tvb,
- offset, 2, ENC_BIG_ENDIAN );
-
+ proto_tree_add_checksum(tree, tvb, offset, hf_nlsp_lsp_checksum, -1, NULL, pinfo, 0, ENC_BIG_ENDIAN, PROTO_CHECKSUM_NO_FLAGS);
offset += 2;
if (tree) {
@@ -1027,7 +1025,7 @@ dissect_csnp_lsp_entries(tvbuff_t *tvb, packet_info* pinfo, proto_tree *tree, in
proto_tree_add_uint_format_value(subtree, hf_nlsp_csnp_remaining_lifetime, tvb, offset, 2,
tvb_get_ntohs(tvb, offset), "%us", tvb_get_ntohs(tvb, offset));
- proto_tree_add_item(subtree, hf_nlsp_csnp_lsp_checksum, tvb, offset+14, 2, ENC_BIG_ENDIAN);
+ proto_tree_add_checksum(subtree, tvb, offset+14, hf_nlsp_csnp_lsp_checksum, -1, NULL, pinfo, 0, ENC_BIG_ENDIAN, PROTO_CHECKSUM_NO_FLAGS);
length -= 16;
offset += 16;
@@ -1063,7 +1061,7 @@ dissect_psnp_lsp_entries(tvbuff_t *tvb, packet_info* pinfo, proto_tree *tree, in
proto_tree_add_uint_format_value(subtree, hf_nlsp_psnp_remaining_lifetime, tvb, offset, 2,
tvb_get_ntohs(tvb, offset), "%us", tvb_get_ntohs(tvb, offset));
- proto_tree_add_item(subtree, hf_nlsp_psnp_lsp_checksum, tvb, offset+14, 2, ENC_BIG_ENDIAN);
+ proto_tree_add_checksum(subtree, tvb, offset+14, hf_nlsp_psnp_lsp_checksum, -1, NULL, pinfo, 0, ENC_BIG_ENDIAN, PROTO_CHECKSUM_NO_FLAGS);
length -= 16;
offset += 16;
diff --git a/epan/dissectors/packet-nsrp.c b/epan/dissectors/packet-nsrp.c
index 70dc51c995..90c11ab2f4 100644
--- a/epan/dissectors/packet-nsrp.c
+++ b/epan/dissectors/packet-nsrp.c
@@ -243,7 +243,7 @@ dissect_nsrp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_
proto_tree_add_item(nsrp_tree, hf_nsrp_no_used, tvb, offset, 2, ENC_BIG_ENDIAN);
offset += 2;
- proto_tree_add_item(nsrp_tree, hf_nsrp_checksum, tvb, offset, 2, ENC_BIG_ENDIAN);
+ proto_tree_add_checksum(nsrp_tree, tvb, offset, hf_nsrp_checksum, -1, NULL, pinfo, 0, ENC_BIG_ENDIAN, PROTO_CHECKSUM_NO_FLAGS);
offset += 2;
proto_tree_add_item(nsrp_tree, hf_nsrp_data, tvb, offset, -1, ENC_ASCII|ENC_NA);
@@ -293,7 +293,7 @@ dissect_nsrp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_
proto_tree_add_item(nsrp_tree, hf_nsrp_dummy, tvb, offset, 1, ENC_BIG_ENDIAN);
offset += 1;
- proto_tree_add_item(nsrp_tree, hf_nsrp_authchecksum, tvb, offset, 2, ENC_BIG_ENDIAN);
+ proto_tree_add_checksum(nsrp_tree, tvb, offset, hf_nsrp_authchecksum, -1, NULL, pinfo, 0, ENC_BIG_ENDIAN, PROTO_CHECKSUM_NO_FLAGS);
offset += 2;
proto_tree_add_item(nsrp_tree, hf_nsrp_data, tvb, offset, -1, ENC_ASCII|ENC_NA);
diff --git a/epan/dissectors/packet-osi.c b/epan/dissectors/packet-osi.c
index 5f829c3314..abfeb42567 100644
--- a/epan/dissectors/packet-osi.c
+++ b/epan/dissectors/packet-osi.c
@@ -52,23 +52,18 @@ static dissector_handle_t osi_handle;
static gboolean tpkt_desegment = FALSE;
static guint global_tcp_port_osi_over_tpkt = 0;
-cksum_status_t
-calc_checksum( tvbuff_t *tvb, int offset, guint len, guint checksum) {
- const gchar *buffer;
+gboolean
+osi_calc_checksum( tvbuff_t *tvb, int offset, guint len, guint32* c0, guint32* c1) {
guint available_len;
const guint8 *p;
- guint32 c0, c1;
guint seglen;
guint i;
- if ( 0 == checksum )
- return( NO_CKSUM );
-
available_len = tvb_captured_length_remaining( tvb, offset );
if ( available_len < len )
- return( DATA_MISSING );
+ return FALSE;
- buffer = tvb_get_ptr( tvb, offset, len );
+ p = tvb_get_ptr( tvb, offset, len );
/*
* The maximum values of c0 and c1 will occur if all bytes have the
@@ -81,33 +76,29 @@ calc_checksum( tvbuff_t *tvb, int offset, guint len, guint checksum) {
* we can solve this by taking c0 and c1 mod 255 every
* 5803 bytes.
*/
- p = buffer;
- c0 = 0;
- c1 = 0;
+ *c0 = 0;
+ *c1 = 0;
while (len != 0) {
seglen = len;
if (seglen > 5803)
seglen = 5803;
for (i = 0; i < seglen; i++) {
- c0 = c0 + *(p++);
- c1 += c0;
+ (*c0) += *(p++);
+ (*c1) += (*c0);
}
- c0 = c0 % 255;
- c1 = c1 % 255;
+ (*c0) = (*c0) % 255;
+ (*c1) = (*c1) % 255;
len -= seglen;
}
- if (c0 != 0 || c1 != 0)
- return( CKSUM_NOT_OK ); /* XXX - what should the checksum field be? */
- else
- return( CKSUM_OK );
+
+ return TRUE;
}
-cksum_status_t
-check_and_get_checksum( tvbuff_t *tvb, int offset, guint len, guint checksum, int offset_check, guint16* result) {
- const gchar *buffer;
+gboolean
+osi_check_and_get_checksum( tvbuff_t *tvb, int offset, guint len, int offset_check, guint16* result) {
guint available_len;
const guint8 *p;
guint8 discard = 0;
@@ -116,15 +107,12 @@ check_and_get_checksum( tvbuff_t *tvb, int offset, guint len, guint checksum, in
guint i;
int block, x, y;
- if ( 0 == checksum )
- return( NO_CKSUM );
-
available_len = tvb_captured_length_remaining( tvb, offset );
offset_check -= offset;
if ( ( available_len < len ) || ( offset_check < 0 ) || ( (guint)(offset_check+2) > len ) )
- return( DATA_MISSING );
+ return FALSE;
- buffer = tvb_get_ptr( tvb, offset, len );
+ p = tvb_get_ptr( tvb, offset, len );
block = offset_check / 5803;
/*
@@ -138,7 +126,6 @@ check_and_get_checksum( tvbuff_t *tvb, int offset, guint len, guint checksum, in
* we can solve this by taking c0 and c1 mod 255 every
* 5803 bytes.
*/
- p = buffer;
c0 = 0;
c1 = 0;
@@ -189,11 +176,7 @@ check_and_get_checksum( tvbuff_t *tvb, int offset, guint len, guint checksum, in
if (y == 0) y = 0x01;
*result = ( x << 8 ) | ( y & 0xFF );
-
- if (*result != checksum)
- return( CKSUM_NOT_OK ); /* XXX - what should the checksum field be? */
- else
- return( CKSUM_OK );
+ return TRUE;
}
/* 4 octet ATN extended checksum: ICAO doc 9705 Ed3 Volume V section 5.5.4.6.4 */
@@ -201,7 +184,7 @@ check_and_get_checksum( tvbuff_t *tvb, int offset, guint len, guint checksum, in
/* of length SRC-NSAP, SRC-NSAP, length DST-NSAP, DST-NSAP and ATN extended checksum. */
/* In case of a CR TPDU, the value of the ISO 8073 16-bit fletcher checksum parameter shall */
/* be set to zero. */
-gboolean check_atn_ec_32(
+guint32 check_atn_ec_32(
tvbuff_t *tvb, guint tpdu_len,
guint offset_ec_32_val, /* offset ATN extended checksum value, calculated at last as part of pseudo trailer */
guint offset_iso8073_val, /* offset ISO 8073 fletcher checksum, CR only*/
@@ -314,12 +297,8 @@ gboolean check_atn_ec_32(
c3 -= 0x000000FF;
}
- sum = (c3 << 24) + (c2 << 16 ) + (c1 << 8) + c0 ;
-
- if(!sum)
- return TRUE;
- else
- return FALSE;
+ sum = (c3 << 24) + (c2 << 16 ) + (c1 << 8) + c0;
+ return sum;
}
/* 2 octet ATN extended checksum: ICAO doc 9705 Ed3 Volume V section 5.5.4.6.4 */
@@ -328,7 +307,7 @@ gboolean check_atn_ec_32(
/* In case of a CR TPDU, the value of the ISO 8073 16-bit fletcher checksum parameter shall */
/* be set to zero. */
/* this routine is currently *untested* because of the unavailability of samples.*/
-gboolean check_atn_ec_16(
+guint16 check_atn_ec_16(
tvbuff_t *tvb,
guint tpdu_len,
guint offset_ec_16_val, /* offset ATN extended checksum value, calculated at last as part of pseudo trailer */
@@ -341,7 +320,7 @@ gboolean check_atn_ec_16(
guint i = 0;
guint16 c0 = 0;
guint16 c1 = 0;
- guint16 sum = 0;
+ guint16 sum;
/* sum across complete TPDU */
for ( i =0; i< tpdu_len; i++){
@@ -405,11 +384,7 @@ gboolean check_atn_ec_16(
}
sum = (c1 << 8) + c0 ;
-
- if(!sum)
- return TRUE;
- else
- return FALSE;
+ return sum;
}
diff --git a/epan/dissectors/packet-osi.h b/epan/dissectors/packet-osi.h
index ca8d92f832..b32f6accb4 100644
--- a/epan/dissectors/packet-osi.h
+++ b/epan/dissectors/packet-osi.h
@@ -57,19 +57,12 @@
* published API functions
*/
-typedef enum {
- NO_CKSUM, /* checksum field is 0 */
- DATA_MISSING, /* not all the data covered by the checksum was captured */
- CKSUM_OK, /* checksum is OK */
- CKSUM_NOT_OK /* checksum is not OK */
-} cksum_status_t;
-
/* Exposed to be used by packet-osi-options.c */
extern int proto_osi;
-extern cksum_status_t calc_checksum(tvbuff_t *, int, guint, guint);
-extern cksum_status_t check_and_get_checksum(tvbuff_t *, int, guint, guint, int, guint16*);
-extern gboolean check_atn_ec_32(tvbuff_t *tvb, guint tpdu_len, guint offset_ec_32_val, guint offset_iso8073_val, guint clnp_dst_len, const guint8 *clnp_dst, guint clnp_src_len, const guint8 *clnp_src);
-extern gboolean check_atn_ec_16(tvbuff_t *tvb, guint tpdu_len, guint offset_ec_16_val, guint offset_iso8073_val, guint clnp_dst_len, const guint8 *clnp_dst, guint clnp_src_len, const guint8 *clnp_src);
+extern gboolean osi_calc_checksum( tvbuff_t *tvb, int offset, guint len, guint32* c0, guint32* c1);
+extern gboolean osi_check_and_get_checksum( tvbuff_t *tvb, int offset, guint len, int offset_check, guint16* result);
+extern guint32 check_atn_ec_32(tvbuff_t *tvb, guint tpdu_len, guint offset_ec_32_val, guint offset_iso8073_val, guint clnp_dst_len, const guint8 *clnp_dst, guint clnp_src_len, const guint8 *clnp_src);
+extern guint16 check_atn_ec_16(tvbuff_t *tvb, guint tpdu_len, guint offset_ec_16_val, guint offset_iso8073_val, guint clnp_dst_len, const guint8 *clnp_dst, guint clnp_src_len, const guint8 *clnp_src);
#endif /* _PACKET_OSI_H */
diff --git a/epan/dissectors/packet-ositp.c b/epan/dissectors/packet-ositp.c
index 53d7328b75..08c671211d 100644
--- a/epan/dissectors/packet-ositp.c
+++ b/epan/dissectors/packet-ositp.c
@@ -68,7 +68,8 @@ static int hf_cotp_eot_extended = -1;
static int hf_cotp_parameter_code = -1;
static int hf_cotp_parameter_length = -1;
static int hf_cotp_parameter_value = -1;
-static int hf_cotp_atn_extended_checksum = -1;
+static int hf_cotp_atn_extended_checksum16 = -1;
+static int hf_cotp_atn_extended_checksum32 = -1;
static int hf_cotp_ack_time = -1;
static int hf_cotp_res_error_rate_target_value = -1;
static int hf_cotp_res_error_rate_min_accept = -1;
@@ -440,10 +441,8 @@ static gboolean ositp_decode_var_part(tvbuff_t *tvb, int offset, int vp_length,
gint32 i = 0;
guint8 tmp_code = 0;
guint tmp_len = 0;
- cksum_status_t cksum_status;
- gboolean checksum_ok = FALSE;
guint32 pref_max_tpdu_size;
- proto_item *ti, *hidden_item;
+ proto_item *hidden_item;
while (vp_length != 0) {
code = tvb_get_guint8(tvb, offset);
@@ -462,6 +461,7 @@ static gboolean ositp_decode_var_part(tvbuff_t *tvb, int offset, int vp_length,
case VP_ATN_EC_16 : /* ATN */
if (cotp_decode_atn) {
+ guint16 sum;
/* if an alternate OSI checksum is present in the currently unprocessed
* VP section to the checksum algorithm has to know.
* this may be the case for backward compatible CR TPDU */
@@ -477,12 +477,11 @@ static gboolean ositp_decode_var_part(tvbuff_t *tvb, int offset, int vp_length,
i += tmp_len;
}
}
- checksum_ok = check_atn_ec_16(tvb, tpdu_len , offset,
+ sum = check_atn_ec_16(tvb, tpdu_len , offset,
offset_iso8073_checksum,
pinfo->dst.len, (const guint8 *)pinfo->dst.data,
pinfo->src.len, (const guint8 *)pinfo->src.data);
- ti = proto_tree_add_item(tree, hf_cotp_atn_extended_checksum, tvb, offset, 2, ENC_BIG_ENDIAN);
- proto_item_append_text(ti, checksum_ok ? " (correct)" : " (incorrect)");
+ proto_tree_add_checksum(tree, tvb, offset, hf_cotp_atn_extended_checksum16, -1, NULL, pinfo, sum, ENC_BIG_ENDIAN, PROTO_CHECKSUM_VERIFY|PROTO_CHECKSUM_ZERO);
} else {
proto_tree_add_bytes_format_value(tree, hf_cotp_parameter_value, tvb, offset, length, NULL, "<not shown>");
}
@@ -492,6 +491,7 @@ static gboolean ositp_decode_var_part(tvbuff_t *tvb, int offset, int vp_length,
case VP_ATN_EC_32 : /* ATN */
if (cotp_decode_atn) {
+ guint32 sum;
/* if an alternate OSI checksum is present in the currently unprocessed
* VP section the checksum algorithm has to know.
* this may be the case for backward compatible CR TPDU */
@@ -507,12 +507,11 @@ static gboolean ositp_decode_var_part(tvbuff_t *tvb, int offset, int vp_length,
i += tmp_len;
}
}
- checksum_ok = check_atn_ec_32(tvb, tpdu_len , offset,
+ sum = check_atn_ec_32(tvb, tpdu_len , offset,
offset_iso8073_checksum,
pinfo->dst.len, (const guint8 *)pinfo->dst.data,
pinfo->src.len, (const guint8 *)pinfo->src.data);
- ti = proto_tree_add_item(tree, hf_cotp_atn_extended_checksum, tvb, offset, 4, ENC_BIG_ENDIAN);
- proto_item_append_text(ti, checksum_ok ? " (correct)" : " (incorrect)");
+ proto_tree_add_checksum(tree, tvb, offset, hf_cotp_atn_extended_checksum32, -1, NULL, pinfo, sum, ENC_BIG_ENDIAN, PROTO_CHECKSUM_VERIFY|PROTO_CHECKSUM_ZERO);
} else {
proto_tree_add_bytes_format_value(tree, hf_cotp_parameter_value, tvb, offset, length, NULL, "<not shown>");
}
@@ -691,36 +690,21 @@ static gboolean ositp_decode_var_part(tvbuff_t *tvb, int offset, int vp_length,
case VP_CHECKSUM:
offset_iso8073_checksum = offset; /* save ISO 8073 checksum offset for ATN extended checksum calculation */
- cksum_status = calc_checksum(tvb, 0, tpdu_len,
- tvb_get_ntohs(tvb, offset));
- switch (cksum_status) {
- default:
- /*
- * No checksum present, or not enough of the packet present to
- * checksum it.
- */
- proto_tree_add_item(tree, hf_cotp_checksum, tvb, offset, 2, ENC_BIG_ENDIAN);
- break;
-
- case CKSUM_OK:
- /*
- * Checksum is correct.
- */
- s = tvb_get_ntohs(tvb, offset);
- proto_tree_add_uint_format_value(tree, hf_cotp_checksum, tvb, offset, 2,
- s, "0x%04x (correct)", s);
- break;
+ if (tvb_get_ntohs(tvb, offset) == 0) {
+ /* No checksum present */
+ proto_tree_add_checksum(tree, tvb, offset, hf_cotp_checksum, -1, NULL, pinfo, 0, ENC_BIG_ENDIAN, PROTO_CHECKSUM_NOT_PRESENT);
+ } else {
+ guint32 calc_c0 = 0, calc_c1 = 0;
- case CKSUM_NOT_OK:
- /*
- * Checksum is not correct.
- */
- s = tvb_get_ntohs(tvb, offset);
- proto_tree_add_uint_format_value(tree, hf_cotp_checksum, tvb, offset, 2,
- s, "0x%04x (incorrect)", s);
- break;
+ if (osi_calc_checksum(tvb, 0, length, &calc_c0, &calc_c1)) {
+ /* Successfully processed checksum, verify it */
+ proto_tree_add_checksum(tree, tvb, offset, hf_cotp_checksum, -1, NULL, pinfo, calc_c0 | calc_c1, ENC_BIG_ENDIAN, PROTO_CHECKSUM_VERIFY|PROTO_CHECKSUM_ZERO);
+ } else {
+ proto_tree_add_checksum(tree, tvb, offset, hf_cotp_checksum, -1, NULL, pinfo, 0, ENC_BIG_ENDIAN, PROTO_CHECKSUM_NO_FLAGS);
+ }
}
+
offset += length;
vp_length -= length;
break;
@@ -2338,7 +2322,8 @@ void proto_register_cotp(void)
{ &hf_cotp_parameter_code, { "Parameter code", "cotp.parameter_code", FT_UINT8, BASE_HEX, VALS(tp_vpart_type_vals), 0x0, NULL, HFILL }},
{ &hf_cotp_parameter_length, { "Parameter length", "cotp.parameter_length", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }},
{ &hf_cotp_parameter_value, { "Parameter value", "cotp.parameter_value", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }},
- { &hf_cotp_atn_extended_checksum, { "ATN extended checksum", "cotp.atn_extended_checksum", FT_UINT32, BASE_HEX, NULL, 0x0, NULL, HFILL }},
+ { &hf_cotp_atn_extended_checksum16, { "ATN extended checksum", "cotp.atn_extended_checksum", FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL }},
+ { &hf_cotp_atn_extended_checksum32, { "ATN extended checksum", "cotp.atn_extended_checksum", FT_UINT32, BASE_HEX, NULL, 0x0, NULL, HFILL }},
{ &hf_cotp_ack_time, { "Ack time (ms)", "cotp.ack_time", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }},
{ &hf_cotp_res_error_rate_target_value, { "Residual error rate, target value", "cotp.res_error_rate.target_value", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }},
{ &hf_cotp_res_error_rate_min_accept, { "Residual error rate, minimum acceptable", "cotp.res_error_rate.min_accept", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }},
diff --git a/epan/dissectors/packet-ospf.c b/epan/dissectors/packet-ospf.c
index 9130fa1978..18e2bef340 100644
--- a/epan/dissectors/packet-ospf.c
+++ b/epan/dissectors/packet-ospf.c
@@ -1470,7 +1470,7 @@ dissect_ospf_lls_data_block(tvbuff_t *tvb, packet_info *pinfo, int offset, proto
ospf_lls_data_block_tree = proto_tree_add_subtree(tree, tvb, offset, -1, ett_ospf_lls_data_block, NULL, "OSPF LLS Data Block");
/* TODO: verify checksum */
- proto_tree_add_item(ospf_lls_data_block_tree, hf_ospf_lls_checksum, tvb, offset, 2, ENC_BIG_ENDIAN);
+ proto_tree_add_checksum(ospf_lls_data_block_tree, tvb, offset, hf_ospf_lls_checksum, -1, NULL, pinfo, 0, ENC_BIG_ENDIAN, PROTO_CHECKSUM_NO_FLAGS);
proto_tree_add_uint_format_value(ospf_lls_data_block_tree, hf_ospf_lls_data_length, tvb, offset + 2, 2,
ospf_lls_len, "%d bytes", ospf_lls_len);
diff --git a/epan/dissectors/packet-pgm.c b/epan/dissectors/packet-pgm.c
index cfb4cabd56..d97d1fe31b 100644
--- a/epan/dissectors/packet-pgm.c
+++ b/epan/dissectors/packet-pgm.c
@@ -148,7 +148,7 @@ static int hf_pgm_main_opts_netsig = -1;
static int hf_pgm_main_opts_varlen = -1;
static int hf_pgm_main_opts_parity = -1;
static int hf_pgm_main_cksum = -1;
-static int hf_pgm_main_cksum_bad = -1;
+static int hf_pgm_main_cksum_status = -1;
static int hf_pgm_main_gsi = -1;
static int hf_pgm_main_tsdulen = -1;
static int hf_pgm_spm_sqn = -1;
@@ -910,30 +910,18 @@ dissect_pgm(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
if ((pgmhdr_type != PGM_RDATA_PCKT) && (pgmhdr_type != PGM_ODATA_PCKT) &&
(pgmhdr_cksum == 0))
{
- proto_tree_add_uint_format_value(pgm_tree, hf_pgm_main_cksum, tvb,
- ptvcursor_current_offset(cursor), 2, pgmhdr_cksum, "not available");
+ proto_tree_add_checksum(pgm_tree, tvb, ptvcursor_current_offset(cursor), hf_pgm_main_cksum, hf_pgm_main_cksum_status, NULL, pinfo, 0, ENC_BIG_ENDIAN, PROTO_CHECKSUM_NOT_PRESENT);
} else {
reportedlen = tvb_reported_length(tvb);
pgmlen = tvb_captured_length(tvb);
if (pgm_check_checksum && pgmlen >= reportedlen) {
vec_t cksum_vec[1];
- guint16 computed_cksum;
SET_CKSUM_VEC_TVB(cksum_vec[0], tvb, 0, pgmlen);
- computed_cksum = in_cksum(&cksum_vec[0], 1);
- if (computed_cksum == 0) {
- proto_tree_add_uint_format_value(pgm_tree, hf_pgm_main_cksum, tvb,
- ptvcursor_current_offset(cursor), 2, pgmhdr_cksum, "0x%04x [correct]", pgmhdr_cksum);
- } else {
- hidden_item = proto_tree_add_boolean(pgm_tree, hf_pgm_main_cksum_bad, tvb,
- ptvcursor_current_offset(cursor), 2, TRUE);
- PROTO_ITEM_SET_HIDDEN(hidden_item);
- proto_tree_add_uint_format_value(pgm_tree, hf_pgm_main_cksum, tvb,
- ptvcursor_current_offset(cursor), 2, pgmhdr_cksum, "0x%04x [incorrect, should be 0x%04x]",
- pgmhdr_cksum, in_cksum_shouldbe(pgmhdr_cksum, computed_cksum));
- }
+ proto_tree_add_checksum(pgm_tree, tvb, ptvcursor_current_offset(cursor), hf_pgm_main_cksum_status, -1, NULL, pinfo,
+ in_cksum(&cksum_vec[0], 1), ENC_BIG_ENDIAN, PROTO_CHECKSUM_VERIFY|PROTO_CHECKSUM_IN_CKSUM);
} else {
- ptvcursor_add_no_advance(cursor, hf_pgm_main_cksum, 2, ENC_BIG_ENDIAN);
+ proto_tree_add_checksum(pgm_tree, tvb, ptvcursor_current_offset(cursor), hf_pgm_main_cksum, hf_pgm_main_cksum_status, NULL, pinfo, 0, ENC_BIG_ENDIAN, PROTO_CHECKSUM_NO_FLAGS);
}
}
ptvcursor_advance(cursor, 2);
@@ -1120,9 +1108,9 @@ proto_register_pgm(void)
{ &hf_pgm_main_cksum,
{ "Checksum", "pgm.hdr.cksum", FT_UINT16, BASE_HEX,
NULL, 0x0, NULL, HFILL }},
- { &hf_pgm_main_cksum_bad,
- { "Bad Checksum", "pgm.hdr.cksum_bad", FT_BOOLEAN, BASE_NONE,
- NULL, 0x0, NULL, HFILL }},
+ { &hf_pgm_main_cksum_status,
+ { "Checksum Status", "pgm.hdr.cksum.status", FT_UINT8, BASE_NONE,
+ VALS(proto_checksum_vals), 0x0, NULL, HFILL }},
{ &hf_pgm_main_gsi,
{ "Global Source Identifier", "pgm.hdr.gsi", FT_BYTES, BASE_NONE,
NULL, 0x0, NULL, HFILL }},
diff --git a/epan/dissectors/packet-pim.c b/epan/dissectors/packet-pim.c
index f2257dc8c2..1f216e6f54 100644
--- a/epan/dissectors/packet-pim.c
+++ b/epan/dissectors/packet-pim.c
@@ -327,12 +327,10 @@ dissect_pimv1(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U
guint8 pim_type;
guint8 pim_ver;
guint length, pim_length;
- guint16 pim_cksum, computed_cksum;
vec_t cksum_vec[1];
proto_tree *pim_tree = NULL;
proto_item *ti;
proto_tree *pimopt_tree = NULL;
- proto_item *ticksum;
int offset = 0;
col_set_str(pinfo->cinfo, COL_PROTOCOL, "PIMv1");
@@ -353,10 +351,10 @@ dissect_pimv1(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U
proto_tree_add_uint(pim_tree, hf_pim_code, tvb, offset, 1, pim_type);
offset += 1;
- pim_cksum = tvb_get_ntohs(tvb, offset);
- ticksum = proto_tree_add_item(pim_tree, hf_pim_cksum, tvb, offset, 2, ENC_BIG_ENDIAN);
pim_ver = PIM_VER(tvb_get_guint8(tvb, offset + 2));
if (pim_ver != 1) {
+ proto_tree_add_checksum(pim_tree, tvb, offset, hf_pim_cksum, -1, NULL, pinfo, 0, ENC_BIG_ENDIAN, PROTO_CHECKSUM_NO_FLAGS);
+
/*
* Not PIMv1; should we bother dissecting the PIM drafts
* with a version number of 2 and with PIM running atop
@@ -403,12 +401,10 @@ dissect_pimv1(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U
* truncated, so we can checksum it.
*/
SET_CKSUM_VEC_TVB(cksum_vec[0], tvb, 0, pim_length);
- computed_cksum = in_cksum(&cksum_vec[0], 1);
- if (computed_cksum == 0) {
- proto_item_append_text(ticksum, " [correct]");
- } else {
- proto_item_append_text(ticksum, " [incorrect, should be 0x%04x]", in_cksum_shouldbe(pim_cksum, computed_cksum));
- }
+ proto_tree_add_checksum(pim_tree, tvb, offset, hf_pim_cksum, -1, NULL, pinfo, in_cksum(&cksum_vec[0], 1),
+ ENC_BIG_ENDIAN, PROTO_CHECKSUM_VERIFY|PROTO_CHECKSUM_IN_CKSUM);
+ } else {
+ proto_tree_add_checksum(pim_tree, tvb, offset, hf_pim_cksum, -1, NULL, pinfo, 0, ENC_BIG_ENDIAN, PROTO_CHECKSUM_NO_FLAGS);
}
offset += 2;
@@ -805,14 +801,13 @@ dissect_pim(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
guint8 pim_typever;
guint8 pim_bidir_subtype = 0;
guint length, pim_length;
- guint16 pim_cksum, computed_cksum;
vec_t cksum_vec[4];
guint32 phdr[2];
const char *typestr;
proto_tree *pim_tree = NULL;
proto_item *ti;
proto_tree *pimopt_tree = NULL;
- proto_item *tiopt, *ticksum;
+ proto_item *tiopt;
col_set_str(pinfo->cinfo, COL_PROTOCOL, "PIM");
col_clear(pinfo->cinfo, COL_INFO);
@@ -846,10 +841,9 @@ dissect_pim(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
else {
proto_tree_add_item(pim_tree, hf_pim_res_bytes, tvb, offset + 1, 1, ENC_NA);
}
- pim_cksum = tvb_get_ntohs(tvb, offset + 2);
- ticksum = proto_tree_add_item(pim_tree, hf_pim_cksum, tvb, offset + 2, 2, ENC_BIG_ENDIAN);
if (PIM_VER(pim_typever) != 2) {
+ proto_tree_add_checksum(pim_tree, tvb, offset+2, hf_pim_cksum, -1, NULL, pinfo, 0, ENC_BIG_ENDIAN, PROTO_CHECKSUM_NO_FLAGS);
/*
* We don't know this version, so we don't know how much of the
* packet the checksum covers.
@@ -891,7 +885,8 @@ dissect_pim(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
switch (pinfo->src.type) {
case AT_IPv4:
SET_CKSUM_VEC_TVB(cksum_vec[0], tvb, 0, pim_length);
- computed_cksum = in_cksum(&cksum_vec[0], 1);
+ proto_tree_add_checksum(pim_tree, tvb, offset+2, hf_pim_cksum, -1, NULL, pinfo, in_cksum(&cksum_vec[0], 1),
+ ENC_BIG_ENDIAN, PROTO_CHECKSUM_VERIFY|PROTO_CHECKSUM_IN_CKSUM);
break;
case AT_IPv6:
/* Set up the fields of the pseudo-header. */
@@ -901,20 +896,16 @@ dissect_pim(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
phdr[1] = g_htonl(IP_PROTO_PIM);
SET_CKSUM_VEC_PTR(cksum_vec[2], (const guint8 *)&phdr, 8);
SET_CKSUM_VEC_TVB(cksum_vec[3], tvb, 0, pim_length);
- computed_cksum = in_cksum(&cksum_vec[0], 4);
+ proto_tree_add_checksum(pim_tree, tvb, offset+2, hf_pim_cksum, -1, NULL, pinfo, in_cksum(&cksum_vec[0], 4),
+ ENC_BIG_ENDIAN, PROTO_CHECKSUM_VERIFY|PROTO_CHECKSUM_IN_CKSUM);
break;
default:
/* PIM is available for IPv4 and IPv6 right now */
DISSECTOR_ASSERT_NOT_REACHED();
break;
}
-
- if (computed_cksum == 0) {
- proto_item_append_text(ticksum, " [correct]");
-
- } else {
- proto_item_append_text(ticksum, " [incorrect, should be 0x%04x]", in_cksum_shouldbe(pim_cksum, computed_cksum));
- }
+ } else {
+ proto_tree_add_checksum(pim_tree, tvb, offset+2, hf_pim_cksum, -1, NULL, pinfo, 0, ENC_BIG_ENDIAN, PROTO_CHECKSUM_NO_FLAGS);
}
offset += 4;
diff --git a/epan/dissectors/packet-ppp.c b/epan/dissectors/packet-ppp.c
index 7a38f177ff..a3ca67883b 100644
--- a/epan/dissectors/packet-ppp.c
+++ b/epan/dissectors/packet-ppp.c
@@ -1829,9 +1829,6 @@ decode_fcs(tvbuff_t *tvb, proto_tree *fh_tree, int fcs_decode, int proto_offset)
{
tvbuff_t *next_tvb;
gint len, reported_len;
- int rx_fcs_offset;
- guint32 rx_fcs_exp;
- guint32 rx_fcs_got;
/*
* Remove the FCS, if any, from the packet data.
@@ -1880,17 +1877,8 @@ decode_fcs(tvbuff_t *tvb, proto_tree *fh_tree, int fcs_decode, int proto_offset)
/*
* Compute the FCS and put it into the tree.
*/
- rx_fcs_offset = proto_offset + len;
- rx_fcs_exp = fcs16(tvb);
- rx_fcs_got = tvb_get_letohs(tvb, rx_fcs_offset);
- if (rx_fcs_got != rx_fcs_exp) {
- proto_tree_add_uint_format_value(fh_tree, hf_ppp_fcs_16, tvb, rx_fcs_offset, 2,
- rx_fcs_got, "0x%04x [incorrect, should be 0x%04x]",
- rx_fcs_got, rx_fcs_exp);
- } else {
- proto_tree_add_uint_format_value(fh_tree, hf_ppp_fcs_16, tvb, rx_fcs_offset, 2,
- rx_fcs_got, "0x%04x [correct]", rx_fcs_got);
- }
+ proto_tree_add_checksum(fh_tree, tvb, proto_offset + len, hf_ppp_fcs_16, -1, NULL, NULL, fcs16(tvb),
+ ENC_LITTLE_ENDIAN, PROTO_CHECKSUM_VERIFY);
}
break;
@@ -1931,17 +1919,8 @@ decode_fcs(tvbuff_t *tvb, proto_tree *fh_tree, int fcs_decode, int proto_offset)
/*
* Compute the FCS and put it into the tree.
*/
- rx_fcs_offset = proto_offset + len;
- rx_fcs_exp = fcs32(tvb);
- rx_fcs_got = tvb_get_letohl(tvb, rx_fcs_offset);
- if (rx_fcs_got != rx_fcs_exp) {
- proto_tree_add_uint_format_value(fh_tree, hf_ppp_fcs_32, tvb, rx_fcs_offset, 4,
- rx_fcs_got, "0x%08x [incorrect, should be 0x%08x]",
- rx_fcs_got, rx_fcs_exp);
- } else {
- proto_tree_add_uint_format_value(fh_tree, hf_ppp_fcs_32, tvb, rx_fcs_offset, 4,
- rx_fcs_got, "0x%08x [correct]", rx_fcs_got);
- }
+ proto_tree_add_checksum(fh_tree, tvb, proto_offset + len, hf_ppp_fcs_32, -1, NULL, NULL, fcs32(tvb),
+ ENC_LITTLE_ENDIAN, PROTO_CHECKSUM_VERIFY);
}
break;
diff --git a/epan/dissectors/packet-quake2.c b/epan/dissectors/packet-quake2.c
index 10a0297f7e..5ca865a874 100644
--- a/epan/dissectors/packet-quake2.c
+++ b/epan/dissectors/packet-quake2.c
@@ -137,7 +137,6 @@ dissect_quake2_client_commands_move(tvbuff_t *tvb, packet_info *pinfo _U_,
#define BUTTON_USE 2
#define BUTTON_ANY 128
- guint8 chksum;
guint32 lastframe;
int i, offset = 0;
enum { Q_OFFSET, Q_VALUE, Q_SIZE };
@@ -151,7 +150,6 @@ dissect_quake2_client_commands_move(tvbuff_t *tvb, packet_info *pinfo _U_,
guint8 impulse[Q_SIZE];
} move[MOVES+1];
- chksum = tvb_get_guint8(tvb, offset);
offset++;
lastframe = tvb_get_letohl(tvb, offset);
offset += 4;
@@ -212,8 +210,7 @@ dissect_quake2_client_commands_move(tvbuff_t *tvb, packet_info *pinfo _U_,
if (!tree)
return offset;
- proto_tree_add_uint(tree, hf_quake2_game_client_command_move_chksum, tvb,
- 0, 1, chksum);
+ proto_tree_add_checksum(tree, tvb, 0, hf_quake2_game_client_command_move_chksum, -1, NULL, pinfo, 0, ENC_BIG_ENDIAN, PROTO_CHECKSUM_NO_FLAGS);
proto_tree_add_uint(tree, hf_quake2_game_client_command_move_lframe, tvb,
1, 4, lastframe);
diff --git a/epan/dissectors/packet-rdm.c b/epan/dissectors/packet-rdm.c
index 105379fc77..19b8ee5e9b 100644
--- a/epan/dissectors/packet-rdm.c
+++ b/epan/dissectors/packet-rdm.c
@@ -540,8 +540,7 @@ static int hf_rdm_parameter_data = -1;
static int hf_rdm_parameter_data_raw = -1;
static int hf_rdm_intron = -1;
static int hf_rdm_checksum = -1;
-static int hf_rdm_checksum_good = -1;
-static int hf_rdm_checksum_bad = -1;
+static int hf_rdm_checksum_status = -1;
static int hf_rdm_trailer = -1;
static int hf_rdm_pd_device_label = -1;
@@ -2051,9 +2050,7 @@ dissect_rdm(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
gint padding_size;
guint16 man_id;
guint32 dev_id;
- guint message_length, checksum, checksum_shouldbe, offset = 0;
- proto_item *item;
- proto_tree *checksum_tree;
+ guint message_length, offset = 0;
proto_tree *ti = proto_tree_add_item(tree, proto_rdm, tvb,
offset, -1, ENC_NA);
@@ -2096,32 +2093,8 @@ dissect_rdm(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
offset += padding_size;
}
- checksum_shouldbe = rdm_checksum(tvb, offset);
- checksum = tvb_get_ntohs(tvb, offset);
- item = proto_tree_add_item(rdm_tree, hf_rdm_checksum, tvb,
- offset, 2, ENC_BIG_ENDIAN);
- if (checksum == checksum_shouldbe) {
- proto_item_append_text(item, " [correct]");
-
- checksum_tree = proto_item_add_subtree(item, ett_rdm);
- item = proto_tree_add_boolean(checksum_tree, hf_rdm_checksum_good, tvb,
- offset, 2, TRUE);
- PROTO_ITEM_SET_GENERATED(item);
- item = proto_tree_add_boolean(checksum_tree, hf_rdm_checksum_bad, tvb,
- offset, 2, FALSE);
- PROTO_ITEM_SET_GENERATED(item);
- } else {
- proto_item_append_text(item, " [incorrect, should be 0x%04x]", checksum_shouldbe);
-
- checksum_tree = proto_item_add_subtree(item, ett_rdm);
- item = proto_tree_add_boolean(checksum_tree, hf_rdm_checksum_good, tvb,
- offset, 2, FALSE);
- PROTO_ITEM_SET_GENERATED(item);
- item = proto_tree_add_boolean(checksum_tree, hf_rdm_checksum_bad, tvb,
- offset, 2, TRUE);
- PROTO_ITEM_SET_GENERATED(item);
- }
-
+ proto_tree_add_checksum(rdm_tree, tvb, offset, hf_rdm_checksum, hf_rdm_checksum_status, NULL, pinfo, rdm_checksum(tvb, offset),
+ ENC_BIG_ENDIAN, PROTO_CHECKSUM_VERIFY);
offset += 2;
if (offset < tvb_reported_length(tvb))
@@ -2220,15 +2193,10 @@ proto_register_rdm(void)
FT_UINT16, BASE_HEX, NULL, 0x0,
NULL, HFILL }},
- { &hf_rdm_checksum_good,
- { "Good Checksum", "rdm.checksum_good",
- FT_BOOLEAN, BASE_NONE, NULL, 0x0,
- "True: checksum matches packet content; False: doesn't match content", HFILL }},
-
- { &hf_rdm_checksum_bad,
- { "Bad Checksum", "rdm.checksum_bad",
- FT_BOOLEAN, BASE_NONE, NULL, 0x0,
- "True: checksum doesn't match packet content; False: matches content", HFILL }},
+ { &hf_rdm_checksum_status,
+ { "Checksum Status", "rdm.checksum.status",
+ FT_UINT8, BASE_NONE, VALS(proto_checksum_vals), 0x0,
+ NULL, HFILL }},
{ &hf_rdm_trailer,
{ "Trailer", "rdm.trailer",
diff --git a/epan/dissectors/packet-rfid-pn532-hci.c b/epan/dissectors/packet-rfid-pn532-hci.c
index d85b3ed283..cbc3f2e475 100644
--- a/epan/dissectors/packet-rfid-pn532-hci.c
+++ b/epan/dissectors/packet-rfid-pn532-hci.c
@@ -137,15 +137,13 @@ dissect_pn532_hci(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *dat
call_dissector_with_data(pn532_handle, next_tvb, pinfo, tree, usb_conv_info);
offset += length;
- proto_tree_add_item(main_tree, hf_data_checksum, tvb, offset, 1, ENC_BIG_ENDIAN);
checksum = tvb_get_guint8(tvb, offset);
while (length) {
checksum += tvb_get_guint8(tvb, offset - length);
length -= 1;
}
- if (checksum != 0) {
- proto_tree_add_expert(main_tree, pinfo, &ei_invalid_data_checksum, tvb, offset, 1);
- }
+ proto_tree_add_checksum(main_tree, tvb, offset, hf_data_checksum, -1, &ei_invalid_data_checksum, pinfo, 0,
+ ENC_BIG_ENDIAN, PROTO_CHECKSUM_VERIFY|PROTO_CHECKSUM_ZERO);
offset += 1;
} else { /* Normal Information Frame */
col_set_str(pinfo->cinfo, COL_INFO, "Normal Information Frame");
diff --git a/epan/dissectors/packet-rgmp.c b/epan/dissectors/packet-rgmp.c
index 5cf1f361cc..dc0401d22b 100644
--- a/epan/dissectors/packet-rgmp.c
+++ b/epan/dissectors/packet-rgmp.c
@@ -39,7 +39,7 @@ static int proto_rgmp = -1;
static int hf_type = -1;
static int hf_reserved = -1;
static int hf_checksum = -1;
-static int hf_checksum_bad = -1;
+static int hf_checksum_status = -1;
static int hf_maddr = -1;
static int ett_rgmp = -1;
@@ -86,7 +86,7 @@ dissect_rgmp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, void* d
proto_tree_add_item(tree, hf_reserved, tvb, offset, 1, ENC_NA);
offset += 1;
- igmp_checksum(tree, tvb, hf_checksum, hf_checksum_bad, pinfo, 0);
+ igmp_checksum(tree, tvb, hf_checksum, hf_checksum_status, pinfo, 0);
offset += 2;
proto_tree_add_item(tree, hf_maddr, tvb, offset, 4, ENC_BIG_ENDIAN);
@@ -115,9 +115,9 @@ proto_register_rgmp(void)
NULL, 0, NULL, HFILL }
},
- { &hf_checksum_bad,
- { "Bad Checksum", "rgmp.checksum_bad", FT_BOOLEAN, BASE_NONE,
- NULL, 0x0, NULL, HFILL }
+ { &hf_checksum_status,
+ { "Checksum Status", "rgmp.checksum.status", FT_UINT8, BASE_NONE,
+ VALS(proto_checksum_vals), 0x0, NULL, HFILL }
},
{ &hf_maddr,
diff --git a/epan/dissectors/packet-rohc.c b/epan/dissectors/packet-rohc.c
index bcfcbc0434..5647fddb72 100644
--- a/epan/dissectors/packet-rohc.c
+++ b/epan/dissectors/packet-rohc.c
@@ -1461,7 +1461,7 @@ dissect_rohc_ir_rtp_profile_dynamic(tvbuff_t *tvb, packet_info *pinfo, proto_tre
dynamic_udp_tree = proto_item_add_subtree(root_ti, ett_rohc_dynamic_udp);
id = tvb_get_ntohs(tvb, offset);
rohc_cid_context->udp_checksum_present = id ? TRUE : FALSE;
- proto_tree_add_item(dynamic_udp_tree, hf_rohc_dynamic_udp_checksum, tvb, offset, 2, ENC_BIG_ENDIAN);
+ proto_tree_add_checksum(dynamic_udp_tree, tvb, offset, hf_rohc_dynamic_udp_checksum, -1, NULL, pinfo, 0, ENC_BIG_ENDIAN, PROTO_CHECKSUM_NO_FLAGS);
offset +=2;
proto_item_set_len(item, offset - start_offset);
}
@@ -2334,7 +2334,7 @@ start_over:
/* UDP Checksum */
if (rohc_cid_context->udp_checksum_present) {
- proto_tree_add_item(rohc_tree, hf_rohc_udp_checksum, tvb, offset, 2, ENC_BIG_ENDIAN);
+ proto_tree_add_checksum(rohc_tree, tvb, offset, hf_rohc_udp_checksum, -1, NULL, pinfo, 0, ENC_BIG_ENDIAN, PROTO_CHECKSUM_NO_FLAGS);
offset += 2;
}
diff --git a/epan/dissectors/packet-roofnet.c b/epan/dissectors/packet-roofnet.c
index 236f496075..23563f999b 100644
--- a/epan/dissectors/packet-roofnet.c
+++ b/epan/dissectors/packet-roofnet.c
@@ -116,7 +116,9 @@ static void dissect_roofnet_header(proto_tree *tree, tvbuff_t *tvb, guint *offse
ptvcursor_add(cursor, hf_roofnet_nlinks, 1, ENC_BIG_ENDIAN);
ptvcursor_add(cursor, hf_roofnet_next, 1, ENC_BIG_ENDIAN);
ptvcursor_add(cursor, hf_roofnet_ttl, 2, ENC_BIG_ENDIAN);
- ptvcursor_add(cursor, hf_roofnet_cksum, 2, ENC_BIG_ENDIAN);
+ proto_tree_add_checksum(ptvcursor_tree(cursor), ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor),
+ hf_roofnet_cksum, -1, NULL, NULL, 0, ENC_BIG_ENDIAN, PROTO_CHECKSUM_NO_FLAGS);
+ ptvcursor_advance(cursor, 2);
ptvcursor_add(cursor, hf_roofnet_flags, 2, ENC_BIG_ENDIAN);
ptvcursor_add(cursor, hf_roofnet_data_length, 2, ENC_BIG_ENDIAN);
ptvcursor_add(cursor, hf_roofnet_query_dst, 4, ENC_BIG_ENDIAN);
diff --git a/epan/dissectors/packet-rtp-midi.c b/epan/dissectors/packet-rtp-midi.c
index ace94643c8..5eb601506d 100644
--- a/epan/dissectors/packet-rtp-midi.c
+++ b/epan/dissectors/packet-rtp-midi.c
@@ -2528,7 +2528,7 @@ static int hf_rtp_midi_controller_value = -1;
static int hf_rtp_midi_program = -1;
static int hf_rtp_midi_channel_pressure = -1;
static int hf_rtp_midi_pitch_bend = -1;
-static int hf_rtp_midi_pitch_bend_truncated = -1;
+/* static int hf_rtp_midi_pitch_bend_truncated = -1; */
static int hf_rtp_midi_manu_short = -1;
static int hf_rtp_midi_manu_long = -1;
@@ -2733,7 +2733,7 @@ static int hf_rtp_midi_sj_chapter_x_invalid_data = -1;
static int hf_rtp_midi_quarter_frame_type = -1;
static int hf_rtp_midi_quarter_frame_value = -1;
-static int hf_rtp_midi_spp_truncated = -1;
+/* static int hf_rtp_midi_spp_truncated = -1; */
static int hf_rtp_midi_spp = -1;
static int hf_rtp_midi_song_select = -1;
static int hf_rtp_midi_manu_data = -1;
@@ -3515,7 +3515,7 @@ decode_sysex_common_nrt_fd( tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *t
offset += ( data_len - 1 );
}
- proto_tree_add_item( tree, hf_rtp_midi_sysex_common_nrt_fd_checksum, tvb, offset, 1, ENC_BIG_ENDIAN );
+ proto_tree_add_checksum(tree, tvb, offset, hf_rtp_midi_sysex_common_nrt_fd_checksum, -1, NULL, pinfo, 0, ENC_BIG_ENDIAN, PROTO_CHECKSUM_NO_FLAGS);
offset++;
} else if ( sub_id == RTP_MIDI_SYSEX_COMMON_NRT_FD_REQUEST ) {
@@ -3589,7 +3589,7 @@ decode_sysex_common_tuning( tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *t
}
/* checksum */
- proto_tree_add_item( tree, hf_rtp_midi_sysex_common_tune_checksum, tvb, offset, 1, ENC_BIG_ENDIAN );
+ proto_tree_add_checksum(tree, tvb, offset, hf_rtp_midi_sysex_common_tune_checksum, -1, NULL, pinfo, 0, ENC_BIG_ENDIAN, PROTO_CHECKSUM_NO_FLAGS);
offset++;
} else if ( sub_id == RTP_MIDI_SYSEX_COMMON_TUNING_NOTE_CHANGE ) {
@@ -6599,6 +6599,7 @@ proto_register_rtp_midi( void )
NULL, HFILL
}
},
+#if 0
{
&hf_rtp_midi_pitch_bend_truncated,
{
@@ -6611,6 +6612,7 @@ proto_register_rtp_midi( void )
NULL, HFILL
}
},
+#endif
{
&hf_rtp_midi_manu_short,
{
@@ -8939,6 +8941,7 @@ proto_register_rtp_midi( void )
NULL, HFILL
}
},
+#if 0
{
&hf_rtp_midi_spp_truncated,
{
@@ -8951,6 +8954,7 @@ proto_register_rtp_midi( void )
NULL, HFILL
}
},
+#endif
{
&hf_rtp_midi_song_select,
{
diff --git a/epan/dissectors/packet-rtps.c b/epan/dissectors/packet-rtps.c
index 8d6664fe8d..5869579db5 100644
--- a/epan/dissectors/packet-rtps.c
+++ b/epan/dissectors/packet-rtps.c
@@ -5477,8 +5477,8 @@ static gboolean dissect_parameter_sequence_v1(proto_tree *rtps_parameter_tree, p
case PID_TYPE_CHECKSUM:
ENSURE_LENGTH(4);
- proto_tree_add_item(rtps_parameter_tree, hf_rtps_type_checksum, tvb, offset, 4,
- little_endian ? ENC_LITTLE_ENDIAN : ENC_BIG_ENDIAN);
+ proto_tree_add_checksum(rtps_parameter_tree, tvb, offset, hf_rtps_type_checksum, -1, NULL, pinfo, 0,
+ little_endian ? ENC_LITTLE_ENDIAN : ENC_BIG_ENDIAN, PROTO_CHECKSUM_NO_FLAGS);
break;
case PID_EXPECTS_ACK:
diff --git a/epan/dissectors/packet-rudp.c b/epan/dissectors/packet-rudp.c
index 2f0b12109f..ea8d25f5ed 100644
--- a/epan/dissectors/packet-rudp.c
+++ b/epan/dissectors/packet-rudp.c
@@ -116,7 +116,7 @@ dissect_rudp(tvbuff_t *tvb, packet_info *pinfo _U_ , proto_tree *tree, void* dat
/* If the header is more than 4 bytes the next 2 bytes are the checksum */
if (hlen > 4) {
- proto_tree_add_item(rudp_tree, hf_rudp_cksum, tvb, 4, 2, ENC_BIG_ENDIAN);
+ proto_tree_add_checksum(rudp_tree, tvb, 4, hf_rudp_cksum, -1, NULL, pinfo, 0, ENC_BIG_ENDIAN, PROTO_CHECKSUM_NO_FLAGS);
}
/* If we have even more bytes their meaning is unknown - we have seen this
diff --git a/epan/dissectors/packet-s7comm.c b/epan/dissectors/packet-s7comm.c
index 2ab5e102a1..5b1dccbe17 100644
--- a/epan/dissectors/packet-s7comm.c
+++ b/epan/dissectors/packet-s7comm.c
@@ -4438,7 +4438,7 @@ s7comm_decode_ud_block_subfunc(tvbuff_t *tvb,
offset += 1;
proto_tree_add_item(data_tree, hf_s7comm_ud_blockinfo_res_unknown, tvb, offset, 1, ENC_NA);
offset += 1;
- proto_tree_add_item(data_tree, hf_s7comm_ud_blockinfo_checksum, tvb, offset, 2, ENC_BIG_ENDIAN);
+ proto_tree_add_checksum(data_tree, tvb, offset, hf_s7comm_ud_blockinfo_checksum, -1, NULL, pinfo, 0, ENC_BIG_ENDIAN, PROTO_CHECKSUM_NO_FLAGS);
offset += 2;
proto_tree_add_item(data_tree, hf_s7comm_ud_blockinfo_reserved1, tvb, offset, 4, ENC_BIG_ENDIAN);
offset += 4;
diff --git a/epan/dissectors/packet-sbus.c b/epan/dissectors/packet-sbus.c
index f5b947da17..f761eff181 100644
--- a/epan/dissectors/packet-sbus.c
+++ b/epan/dissectors/packet-sbus.c
@@ -240,7 +240,7 @@ static int hf_sbus_week_day = -1;
static int hf_sbus_date = -1;
static int hf_sbus_time = -1;
static int hf_sbus_crc = -1;
-static int hf_sbus_crc_bad = -1;
+static int hf_sbus_crc_status = -1;
static int hf_sbus_flags_accu = -1;
static int hf_sbus_flags_error = -1;
static int hf_sbus_flags_negative = -1;
@@ -650,7 +650,7 @@ dissect_sbus(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_
{
/* Set up structures needed to add the protocol subtree and manage it */
- proto_item *ti, *hi, *cs;
+ proto_item *ti, *hi;
proto_tree *sbus_tree, *ethsbus_tree, *sbusdata_tree;
gint i; /*for CRC calculation*/
@@ -1855,22 +1855,9 @@ dissect_sbus(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_
sbus_crc_calc = 0;
for (i = 0; i < sbus_eth_len - 2; i++)
sbus_crc_calc = crc_calc (sbus_crc_calc, tvb_get_guint8(tvb, i));
- /*Show CRC and add hidden item for wrong CRC*/
- sbus_helper = tvb_get_ntohs(tvb, offset);
- if (sbus_helper == sbus_crc_calc) {
- proto_tree_add_uint_format_value(sbus_tree,
- hf_sbus_crc, tvb, offset, 2, sbus_helper,
- "0x%04x (correct)", sbus_helper);
- } else {
- cs = proto_tree_add_uint_format_value(sbus_tree,
- hf_sbus_crc, tvb, offset, 2, sbus_helper,
- "0x%04x (NOT correct)", sbus_helper);
- expert_add_info(pinfo, cs, &ei_sbus_crc_bad);
- hi = proto_tree_add_boolean(sbus_tree,
- hf_sbus_crc_bad, tvb, offset, 2, TRUE);
- PROTO_ITEM_SET_HIDDEN(hi);
- PROTO_ITEM_SET_GENERATED(hi);
- }
+
+ proto_tree_add_checksum(sbus_tree, tvb, offset, hf_sbus_crc, hf_sbus_crc_status, &ei_sbus_crc_bad, pinfo, sbus_crc_calc,
+ ENC_BIG_ENDIAN, PROTO_CHECKSUM_VERIFY);
offset += 2; /*now at the end of the telegram*/
}
return offset;
@@ -2231,10 +2218,10 @@ proto_register_sbus(void)
"CRC 16", HFILL }
},
- { &hf_sbus_crc_bad,
- { "Bad Checksum", "sbus.crc_bad",
- FT_BOOLEAN, BASE_NONE, NULL, 0x0,
- "A bad checksum in the telegram", HFILL }},
+ { &hf_sbus_crc_status,
+ { "Checksum Status", "sbus.crc.status",
+ FT_UINT8, BASE_NONE, VALS(proto_checksum_vals), 0x0,
+ NULL, HFILL }},
{ &hf_sbus_flags_accu,
{ "ACCU", "sbus.flags.accu",
diff --git a/epan/dissectors/packet-sctp.c b/epan/dissectors/packet-sctp.c
index 106a1e954b..8c7a8ba36a 100644
--- a/epan/dissectors/packet-sctp.c
+++ b/epan/dissectors/packet-sctp.c
@@ -94,7 +94,9 @@ static int hf_source_port = -1;
static int hf_destination_port = -1;
static int hf_verification_tag = -1;
static int hf_checksum = -1;
-static int hf_checksum_bad = -1;
+static int hf_checksum_adler = -1;
+static int hf_checksum_crc32c = -1;
+static int hf_checksum_status = -1;
static int hf_chunk_type = -1;
static int hf_chunk_flags = -1;
@@ -272,7 +274,6 @@ static int exported_pdu_tap = -1;
/* Initialize the subtree pointers */
static gint ett_sctp = -1;
-static gint ett_sctp_checksum = -1;
static gint ett_sctp_chunk = -1;
static gint ett_sctp_chunk_parameter = -1;
static gint ett_sctp_chunk_cause = -1;
@@ -4573,8 +4574,8 @@ dissect_sctp_packet(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gboolea
guint16 source_port, destination_port;
guint captured_length, reported_length;
gboolean crc32c_correct = FALSE, adler32_correct = FALSE;
- proto_item *sctp_item, *hidden_item, *item;
- proto_tree *sctp_tree, *checksum_tree;
+ proto_item *sctp_item, *hidden_item;
+ proto_tree *sctp_tree;
guint32 vtag;
sctp_half_assoc_t *ha = NULL;
proto_item *pi, *vt = NULL;
@@ -4654,58 +4655,36 @@ dissect_sctp_packet(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gboolea
switch(sctp_checksum) {
case SCTP_CHECKSUM_NONE:
- proto_tree_add_uint_format_value(sctp_tree, hf_checksum, tvb, CHECKSUM_OFFSET, CHECKSUM_LENGTH, checksum, "0x%08x (not verified)", checksum);
+ proto_tree_add_checksum(sctp_tree, tvb, CHECKSUM_OFFSET, hf_checksum, hf_checksum_status, &ei_sctp_bad_sctp_checksum, pinfo, 0,
+ ENC_BIG_ENDIAN, PROTO_CHECKSUM_NO_FLAGS);
break;
case SCTP_CHECKSUM_ADLER32:
- if (adler32_correct)
- item = proto_tree_add_uint_format_value(sctp_tree, hf_checksum, tvb, CHECKSUM_OFFSET, CHECKSUM_LENGTH,
- checksum, "0x%08x [correct Adler32]", checksum);
- else {
- item = proto_tree_add_uint_format_value(sctp_tree, hf_checksum, tvb, CHECKSUM_OFFSET, CHECKSUM_LENGTH, checksum,
- "0x%08x [incorrect Adler32, should be 0x%08x]",
- checksum, calculated_adler32);
- expert_add_info(pinfo, item, &ei_sctp_bad_sctp_checksum);
- }
- checksum_tree = proto_item_add_subtree(item, ett_sctp_checksum);
- proto_tree_add_boolean(checksum_tree, hf_checksum_bad, tvb, CHECKSUM_OFFSET, CHECKSUM_LENGTH, !(adler32_correct));
+ proto_tree_add_checksum(sctp_tree, tvb, CHECKSUM_OFFSET, hf_checksum_adler, hf_checksum_status, &ei_sctp_bad_sctp_checksum, pinfo, calculated_adler32,
+ ENC_BIG_ENDIAN, PROTO_CHECKSUM_VERIFY);
break;
case SCTP_CHECKSUM_CRC32C:
- if (crc32c_correct)
- item = proto_tree_add_uint_format_value(sctp_tree, hf_checksum, tvb, CHECKSUM_OFFSET, CHECKSUM_LENGTH,
- checksum, "0x%08x [correct CRC32C]", checksum);
- else {
- item = proto_tree_add_uint_format_value(sctp_tree, hf_checksum, tvb, CHECKSUM_OFFSET, CHECKSUM_LENGTH, checksum,
- "0x%08x [incorrect CRC32C, should be 0x%08x]",
- checksum, calculated_crc32c);
- expert_add_info(pinfo, item, &ei_sctp_bad_sctp_checksum);
- }
- checksum_tree = proto_item_add_subtree(item, ett_sctp_checksum);
- proto_tree_add_boolean(checksum_tree, hf_checksum_bad, tvb, CHECKSUM_OFFSET, CHECKSUM_LENGTH, !(crc32c_correct));
+ proto_tree_add_checksum(sctp_tree, tvb, CHECKSUM_OFFSET, hf_checksum_crc32c, hf_checksum_status, &ei_sctp_bad_sctp_checksum, pinfo, calculated_crc32c,
+ ENC_BIG_ENDIAN, PROTO_CHECKSUM_VERIFY);
break;
case SCTP_CHECKSUM_AUTOMATIC:
if ((adler32_correct) && !(crc32c_correct))
- item = proto_tree_add_uint_format_value(sctp_tree, hf_checksum, tvb, CHECKSUM_OFFSET, CHECKSUM_LENGTH,
- checksum, "0x%08x [correct Adler32]", checksum);
+ proto_tree_add_checksum(sctp_tree, tvb, CHECKSUM_OFFSET, hf_checksum_adler, hf_checksum_status, &ei_sctp_bad_sctp_checksum, pinfo, calculated_adler32,
+ ENC_BIG_ENDIAN, PROTO_CHECKSUM_VERIFY);
else if ((!adler32_correct) && (crc32c_correct))
- item = proto_tree_add_uint_format_value(sctp_tree, hf_checksum, tvb, CHECKSUM_OFFSET, CHECKSUM_LENGTH,
- checksum, "0x%08x [correct CRC32C]", checksum);
- else if ((adler32_correct) && (crc32c_correct))
- item = proto_tree_add_uint_format_value(sctp_tree, hf_checksum, tvb, CHECKSUM_OFFSET, CHECKSUM_LENGTH,
- checksum, "0x%08x [correct Adler32 and CRC32C]", checksum);
+ proto_tree_add_checksum(sctp_tree, tvb, CHECKSUM_OFFSET, hf_checksum_crc32c, hf_checksum_status, &ei_sctp_bad_sctp_checksum, pinfo, calculated_crc32c,
+ ENC_BIG_ENDIAN, PROTO_CHECKSUM_VERIFY);
else {
- item = proto_tree_add_uint_format_value(sctp_tree, hf_checksum, tvb, CHECKSUM_OFFSET, CHECKSUM_LENGTH, checksum,
- "0x%08x [incorrect, should be 0x%08x (Adler32) or 0x%08x (CRC32C)]",
- checksum, calculated_adler32, calculated_crc32c);
- expert_add_info(pinfo, item, &ei_sctp_bad_sctp_checksum);
+ proto_tree_add_checksum(sctp_tree, tvb, CHECKSUM_OFFSET, hf_checksum_adler, hf_checksum_status, &ei_sctp_bad_sctp_checksum, pinfo, calculated_adler32,
+ ENC_BIG_ENDIAN, PROTO_CHECKSUM_VERIFY);
+ proto_tree_add_checksum(sctp_tree, tvb, CHECKSUM_OFFSET, hf_checksum_crc32c, hf_checksum_status, &ei_sctp_bad_sctp_checksum, pinfo, calculated_crc32c,
+ ENC_BIG_ENDIAN, PROTO_CHECKSUM_VERIFY);
}
- checksum_tree = proto_item_add_subtree(item, ett_sctp_checksum);
- proto_tree_add_boolean(checksum_tree, hf_checksum_bad, tvb, CHECKSUM_OFFSET, CHECKSUM_LENGTH, !(crc32c_correct || adler32_correct));
break;
}
} else {
/* We don't have the whole packet so we can't verify the checksum */
- proto_tree_add_uint_format_value(sctp_tree, hf_checksum, tvb, CHECKSUM_OFFSET, CHECKSUM_LENGTH,
- checksum, "0x%08x [unchecked, not all data available]", checksum);
+ proto_tree_add_checksum(sctp_tree, tvb, CHECKSUM_OFFSET, hf_checksum, hf_checksum_status, &ei_sctp_bad_sctp_checksum, pinfo, 0,
+ ENC_BIG_ENDIAN, PROTO_CHECKSUM_NO_FLAGS);
}
/* add all chunks of the sctp datagram to the protocol tree */
@@ -4789,7 +4768,9 @@ proto_register_sctp(void)
{ &hf_port, { "Port", "sctp.port", FT_UINT16, BASE_PT_SCTP, NULL, 0x0, NULL, HFILL } },
{ &hf_verification_tag, { "Verification tag", "sctp.verification_tag", FT_UINT32, BASE_HEX, NULL, 0x0, NULL, HFILL } },
{ &hf_checksum, { "Checksum", "sctp.checksum", FT_UINT32, BASE_HEX, NULL, 0x0, NULL, HFILL } },
- { &hf_checksum_bad, { "Bad checksum", "sctp.checksum_bad", FT_BOOLEAN, BASE_NONE, NULL, 0x0, NULL, HFILL } },
+ { &hf_checksum_adler, { "Checksum (Adler)", "sctp.checksum", FT_UINT32, BASE_HEX, NULL, 0x0, NULL, HFILL } },
+ { &hf_checksum_crc32c, { "Checksum (CRC32C)", "sctp.checksum", FT_UINT32, BASE_HEX, NULL, 0x0, NULL, HFILL } },
+ { &hf_checksum_status, { "Checksum Status", "sctp.checksum.status", FT_UINT8, BASE_NONE, VALS(proto_checksum_vals), 0x0, NULL, HFILL } },
{ &hf_chunk_type, { "Chunk type", "sctp.chunk_type", FT_UINT8, BASE_DEC, VALS(chunk_type_values), 0x0, NULL, HFILL } },
{ &hf_chunk_flags, { "Chunk flags", "sctp.chunk_flags", FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL } },
{ &hf_chunk_bit_1, { "Bit", "sctp.chunk_bit_1", FT_BOOLEAN, 8, TFS(&sctp_chunk_bit_1_value), SCTP_CHUNK_BIT_1, NULL, HFILL } },
@@ -4944,7 +4925,6 @@ proto_register_sctp(void)
/* Setup protocol subtree array */
static gint *ett[] = {
&ett_sctp,
- &ett_sctp_checksum,
&ett_sctp_chunk,
&ett_sctp_chunk_parameter,
&ett_sctp_chunk_cause,
diff --git a/epan/dissectors/packet-selfm.c b/epan/dissectors/packet-selfm.c
index d706c7ace9..4497736324 100644
--- a/epan/dissectors/packet-selfm.c
+++ b/epan/dissectors/packet-selfm.c
@@ -1103,10 +1103,9 @@ dissect_relaydef_frame(tvbuff_t *tvb, proto_tree *tree, int offset)
offset += 1;
}
- proto_tree_add_item(relaydef_tree, hf_selfm_checksum, tvb, offset, 1, ENC_BIG_ENDIAN);
+ proto_tree_add_checksum(relaydef_tree, tvb, offset, hf_selfm_checksum, -1, NULL, NULL, 0, ENC_BIG_ENDIAN, PROTO_CHECKSUM_NO_FLAGS);
return tvb_reported_length(tvb);
-
}
/******************************************************************************************************/
@@ -1208,7 +1207,7 @@ dissect_fmconfig_frame(tvbuff_t *tvb, proto_tree *tree, int offset)
offset += 1;
}
- proto_tree_add_item(fmconfig_tree, hf_selfm_checksum, tvb, offset, 1, ENC_BIG_ENDIAN);
+ proto_tree_add_checksum(fmconfig_tree, tvb, offset, hf_selfm_checksum, -1, NULL, NULL, 0, ENC_BIG_ENDIAN, PROTO_CHECKSUM_NO_FLAGS);
return tvb_reported_length(tvb);
@@ -1424,7 +1423,7 @@ dissect_fmdata_frame(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, int of
offset += 1;
}
- proto_tree_add_item(fmdata_tree, hf_selfm_checksum, tvb, offset, 1, ENC_BIG_ENDIAN);
+ proto_tree_add_checksum(fmdata_tree, tvb, offset, hf_selfm_checksum, -1, NULL, pinfo, 0, ENC_BIG_ENDIAN, PROTO_CHECKSUM_NO_FLAGS);
} /* matching config frame message was found */
@@ -1517,8 +1516,7 @@ dissect_foconfig_frame(tvbuff_t *tvb, proto_tree *tree, int offset)
offset += 1;
}
- proto_tree_add_item(foconfig_tree, hf_selfm_checksum, tvb, offset, 1, ENC_BIG_ENDIAN);
-
+ proto_tree_add_checksum(foconfig_tree, tvb, offset, hf_selfm_checksum, -1, NULL, NULL, 0, ENC_BIG_ENDIAN, PROTO_CHECKSUM_NO_FLAGS);
return tvb_reported_length(tvb);
@@ -1606,8 +1604,8 @@ dissect_fastop_frame(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, int of
proto_tree_add_item(fastop_tree, hf_selfm_fastop_valid, tvb, offset, 1, ENC_BIG_ENDIAN);
offset += 1;
- /* Add checksum */
- proto_tree_add_item(fastop_tree, hf_selfm_checksum, tvb, offset, 1, ENC_BIG_ENDIAN);
+ /* Add checksum */
+ proto_tree_add_checksum(fastop_tree, tvb, offset, hf_selfm_checksum, -1, NULL, pinfo, 0, ENC_BIG_ENDIAN, PROTO_CHECKSUM_NO_FLAGS);
return tvb_reported_length(tvb);
diff --git a/epan/dissectors/packet-shim6.c b/epan/dissectors/packet-shim6.c
index 6393f088b3..bb88dbdaf2 100644
--- a/epan/dissectors/packet-shim6.c
+++ b/epan/dissectors/packet-shim6.c
@@ -102,8 +102,7 @@ static int hf_shim6_ct = -1;
static int hf_shim6_type = -1;
static int hf_shim6_proto = -1;
static int hf_shim6_checksum = -1;
-static int hf_shim6_checksum_bad = -1;
-static int hf_shim6_checksum_good = -1;
+static int hf_shim6_checksum_status= -1;
static int hf_shim6_inonce = -1; /* also for request nonce */
static int hf_shim6_rnonce = -1;
static int hf_shim6_reserved = -1;
@@ -563,26 +562,6 @@ static const value_string shimctrlvals[] = {
{ 0, NULL }
};
-static void
-add_shim6_checksum_additional_info(tvbuff_t * tvb, packet_info * pinfo,
- proto_item * it_cksum, int offset, gboolean is_cksum_correct)
-{
- proto_tree *checksum_tree;
- proto_item *item;
-
- checksum_tree = proto_item_add_subtree(it_cksum, ett_shim6_cksum);
- item = proto_tree_add_boolean(checksum_tree, hf_shim6_checksum_good, tvb,
- offset, 2, is_cksum_correct);
- PROTO_ITEM_SET_GENERATED(item);
- item = proto_tree_add_boolean(checksum_tree, hf_shim6_checksum_bad, tvb,
- offset, 2, !is_cksum_correct);
- PROTO_ITEM_SET_GENERATED(item);
- if (!is_cksum_correct) {
- expert_add_info(pinfo, item, &ei_shim6_checksum_bad);
- col_append_str(pinfo->cinfo, COL_INFO, " [Shim6 CHECKSUM INCORRECT]");
- }
-}
-
static int
dissect_shim6(tvbuff_t *tvb, packet_info * pinfo, proto_tree *tree, void* data _U_)
{
@@ -656,17 +635,10 @@ dissect_shim6(tvbuff_t *tvb, packet_info * pinfo, proto_tree *tree, void* data _
/* Checksum */
csum = shim6_checksum(tvb, offset, len);
-
- if (csum == 0) {
- ti = proto_tree_add_uint_format_value(shim_tree, hf_shim6_checksum, tvb, p, 2,
- tvb_get_ntohs(tvb, p), "0x%04x [correct]", tvb_get_ntohs(tvb, p));
- add_shim6_checksum_additional_info(tvb, pinfo, ti, p, TRUE);
- } else {
- ti = proto_tree_add_uint_format_value(shim_tree, hf_shim6_checksum, tvb, p, 2,
- tvb_get_ntohs(tvb, p), "0x%04x [incorrect: should be 0x%04x]",
- tvb_get_ntohs(tvb, p), in_cksum_shouldbe(tvb_get_ntohs(tvb, p), csum));
- add_shim6_checksum_additional_info(tvb, pinfo, ti, p, FALSE);
- }
+ proto_tree_add_checksum(shim_tree, tvb, p, hf_shim6_checksum, hf_shim6_checksum_status, &ei_shim6_checksum_bad, pinfo, csum,
+ ENC_BIG_ENDIAN, PROTO_CHECKSUM_VERIFY|PROTO_CHECKSUM_IN_CKSUM);
+ if (csum != 0)
+ col_append_str(pinfo->cinfo, COL_INFO, " [Shim6 CHECKSUM INCORRECT]");
p += 2;
/* Type specific data */
@@ -726,14 +698,9 @@ proto_register_shim6(void)
FT_UINT16, BASE_HEX, NULL, 0x0,
"Shim6 Checksum", HFILL }
},
- { &hf_shim6_checksum_bad,
- { "Bad Checksum", "shim6.checksum_bad",
- FT_BOOLEAN, BASE_NONE, NULL, 0x0,
- "Shim6 Bad Checksum", HFILL }
- },
- { &hf_shim6_checksum_good,
- { "Good Checksum", "shim6.checksum_good",
- FT_BOOLEAN, BASE_NONE, NULL, 0x0,
+ { &hf_shim6_checksum_status,
+ { "Checksum Status", "shim6.checksum.status",
+ FT_UINT8, BASE_NONE, VALS(proto_checksum_vals), 0x0,
NULL, HFILL }
},
{ &hf_shim6_inonce,
diff --git a/epan/dissectors/packet-simple.c b/epan/dissectors/packet-simple.c
index 3ac7754a31..90f7ca1222 100644
--- a/epan/dissectors/packet-simple.c
+++ b/epan/dissectors/packet-simple.c
@@ -247,7 +247,7 @@ static gint hf_simple_status_link11_pu = -1;
static gint hf_simple_status_link11_dts_host_status = -1;
static gint hf_simple_status_spare_3 = -1;
static gint hf_simple_checksum = -1;
-static gint hf_simple_checksum_bad = -1;
+static gint hf_simple_checksum_status = -1;
static gint ett_simple = -1;
static gint ett_packet = -1;
@@ -409,10 +409,6 @@ static void dissect_simple_status(tvbuff_t *tvb, packet_info *pinfo, proto_tree
static void dissect_checksum(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gint offset)
{
- gint checksum = tvb_get_letohs(tvb, offset);
- proto_item *checksum_item = proto_tree_add_item(tree, hf_simple_checksum, tvb, offset, 2, ENC_BIG_ENDIAN);
- proto_item *hidden_item;
-
const guint8 * v = tvb_get_ptr(tvb, 0, offset);
guint16 expected_checksum = 0;
gint i;
@@ -420,17 +416,8 @@ static void dissect_checksum(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree
for (i = 0; i < offset; i++)
expected_checksum += v[i];
- if (checksum == expected_checksum) {
- hidden_item = proto_tree_add_boolean(tree, hf_simple_checksum_bad, tvb, offset, 2, FALSE);
- PROTO_ITEM_SET_HIDDEN(hidden_item);
- proto_item_append_text(checksum_item, " [correct]");
- } else {
- hidden_item = proto_tree_add_boolean(tree, hf_simple_checksum_bad, tvb, offset, 2, TRUE);
- PROTO_ITEM_SET_HIDDEN(hidden_item);
- proto_item_append_text(checksum_item, " [incorrect, should be 0x%04x]", expected_checksum);
- expert_add_info_format(pinfo, checksum_item, &ei_simple_checksum_bad,
- "SIMPLE Checksum Incorrect, should be 0x%04x", expected_checksum);
- }
+ proto_tree_add_checksum(tree, tvb, offset, hf_simple_checksum, hf_simple_checksum_status, &ei_simple_checksum_bad, pinfo, expected_checksum,
+ ENC_LITTLE_ENDIAN, PROTO_CHECKSUM_VERIFY);
}
static int dissect_simple(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_)
@@ -669,8 +656,8 @@ void proto_register_simple(void)
{ &hf_simple_checksum,
{ "Checksum", "simple.checksum", FT_UINT16, BASE_HEX, NULL, 0x0,
NULL, HFILL }},
- { &hf_simple_checksum_bad,
- { "Bad Checksum", "simple.checksum_bad", FT_BOOLEAN, BASE_NONE, NULL, 0x0,
+ { &hf_simple_checksum_status,
+ { "Checksum Status", "simple.checksum.status", FT_UINT8, BASE_NONE, VALS(proto_checksum_vals), 0x0,
NULL, HFILL }}
};
static gint *ett[] = {
diff --git a/epan/dissectors/packet-sml.c b/epan/dissectors/packet-sml.c
index 7d405519c7..6f4916e24f 100644
--- a/epan/dissectors/packet-sml.c
+++ b/epan/dissectors/packet-sml.c
@@ -93,6 +93,7 @@ static int hf_sml_datatype = -1;
static int hf_sml_abortOnError = -1;
static int hf_sml_MessageBody = -1;
static int hf_sml_crc16 = -1;
+static int hf_sml_crc16_status = -1;
static int hf_sml_endOfSmlMsg = -1;
static int hf_sml_end = -1;
static int hf_sml_codepage = -1;
@@ -2391,31 +2392,22 @@ static void dissect_sml_file(tvbuff_t *tvb, packet_info *pinfo, gint *offset, pr
proto_tree_add_item (crc16_tree, hf_sml_datatype, tvb, *offset, 1, ENC_BIG_ENDIAN);
*offset+=1;
- crc16 = proto_tree_add_item (crc16_tree, hf_sml_crc16, tvb, *offset, data, ENC_BIG_ENDIAN);
- *offset+=data;
-
if (sml_crc_enabled) {
- crc_msg_len = (*offset - crc_msg_len - data - 1);
- crc_check = crc16_ccitt_tvb_offset(tvb, (*offset - crc_msg_len - data - 1), crc_msg_len);
- crc_ref = tvb_get_letohs(tvb, *offset-2);
+ crc_msg_len = (*offset - crc_msg_len - 1);
+ crc_check = crc16_ccitt_tvb_offset(tvb, (*offset - crc_msg_len - 1), crc_msg_len);
if (data == 1){
crc_ref = crc_ref & 0xFF00;
}
- if (crc_check == crc_ref) {
- proto_item_append_text(crc16, " [CRC Okay]");
- }
- else {
- /*(little to big endian convert) to display in correct order*/
- crc_check = ((crc_check >> 8) & 0xFF) + ((crc_check << 8 & 0xFF00));
- proto_item_append_text(crc16, " [CRC Bad 0x%X]", crc_check);
- expert_add_info(pinfo, crc16, &ei_sml_crc_error);
- }
+ proto_tree_add_checksum(crc16_tree, tvb, *offset, hf_sml_crc16, hf_sml_crc16_status, &ei_sml_crc_error, pinfo, crc_check,
+ ENC_BIG_ENDIAN, PROTO_CHECKSUM_VERIFY);
}
else {
- proto_item_append_text(crc16, " [CRC validation disabled]");
+ proto_tree_add_checksum(crc16_tree, tvb, *offset, hf_sml_crc16, hf_sml_crc16_status, &ei_sml_crc_error, pinfo, 0,
+ ENC_BIG_ENDIAN, PROTO_CHECKSUM_NO_FLAGS);
}
+ *offset+=data;
/*Message END*/
if (tvb_get_guint8 (tvb, *offset) == 0){
@@ -2477,27 +2469,19 @@ static void dissect_sml_file(tvbuff_t *tvb, packet_info *pinfo, gint *offset, pr
*offset+=1;
proto_tree_add_item (msgend_tree, hf_sml_padding, tvb, *offset, 1, ENC_NA);
*offset+=1;
- crc16 = proto_tree_add_item (msgend_tree, hf_sml_crc16, tvb, *offset, 2, ENC_BIG_ENDIAN);
- *offset+=2;
if (sml_crc_enabled && sml_reassemble){
- crc_file_len = *offset - crc_file_len - 2;
- crc_check = crc16_ccitt_tvb_offset(tvb,*offset-crc_file_len-2, crc_file_len);
- crc_ref = tvb_get_letohs(tvb, *offset-2);
+ crc_file_len = *offset - crc_file_len;
+ crc_check = crc16_ccitt_tvb_offset(tvb,*offset-crc_file_len, crc_file_len);
- if (crc_check == crc_ref){
- proto_item_append_text(crc16, " [CRC Okay]");
- }
- else{
- /*(little to big endian convert) to display in correct order*/
- crc_check = ((crc_check >> 8) & 0xFF) + ((crc_check << 8) & 0xFF00);
- proto_item_append_text(crc16, " [CRC Bad 0x%X]", crc_check);
- expert_add_info_format(pinfo, msgend, &ei_sml_crc_error, "CRC error (messages not reassembled ?)");
- }
+ proto_tree_add_checksum(msgend_tree, tvb, *offset, hf_sml_crc16, hf_sml_crc16_status, &ei_sml_crc_error, pinfo, crc_check,
+ ENC_BIG_ENDIAN, PROTO_CHECKSUM_VERIFY);
}
else {
- proto_item_append_text(crc16, " [CRC validation disabled]");
+ proto_tree_add_checksum(msgend_tree, tvb, *offset, hf_sml_crc16, hf_sml_crc16_status, &ei_sml_crc_error, pinfo, crc_check,
+ ENC_BIG_ENDIAN, PROTO_CHECKSUM_NO_FLAGS);
}
+ *offset+=2;
available = tvb_reported_length_remaining(tvb, *offset);
if (available <= 0){
@@ -2556,6 +2540,8 @@ void proto_register_sml (void) {
{ "SML Version", "sml.version", FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL }},
{ &hf_sml_crc16,
{ "CRC16", "sml.crc", FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL }},
+ { &hf_sml_crc16_status,
+ { "CRC16 Status", "sml.crc.status", FT_UINT8, BASE_NONE, VALS(proto_checksum_vals), 0x0, NULL, HFILL }},
{ &hf_sml_endOfSmlMsg,
{ "End of SML Msg", "sml.end", FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL }},
{ &hf_sml_transactionId,
diff --git a/epan/dissectors/packet-stt.c b/epan/dissectors/packet-stt.c
index d4775826c6..a95cba8f1b 100644
--- a/epan/dissectors/packet-stt.c
+++ b/epan/dissectors/packet-stt.c
@@ -74,9 +74,7 @@ static int hf_stt_pkt_len = -1;
static int hf_stt_seg_off = -1;
static int hf_stt_pkt_id = -1;
static int hf_stt_checksum = -1;
-static int hf_stt_checksum_bad = -1;
-static int hf_stt_checksum_good = -1;
-static int hf_stt_checksum_calculated = -1;
+static int hf_stt_checksum_status = -1;
static int hf_stt_tcp_data = -1;
static int hf_stt_tcp_data_offset = -1;
static int hf_stt_tcp_flags = -1;
@@ -122,7 +120,6 @@ static int hf_reassembled_in = -1;
static int hf_reassembled_length = -1;
static int ett_stt = -1;
-static int ett_stt_checksum = -1;
static int ett_stt_tcp_data = -1;
static int ett_stt_tcp_flags = -1;
static int ett_stt_flgs = -1;
@@ -221,18 +218,7 @@ handle_segment(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
static void
dissect_stt_checksum(tvbuff_t *tvb, packet_info *pinfo, proto_tree *stt_tree)
{
- proto_tree *checksum_tree;
- proto_item *item;
- guint16 checksum = tvb_get_ntohs(tvb, 16);
- gboolean can_checksum;
- guint16 computed_cksum;
- gboolean checksum_good = FALSE, checksum_bad = FALSE;
-
- item = proto_tree_add_uint_format_value(stt_tree, hf_stt_checksum,
- tvb, 16, 2, checksum,
- "0x%04x", checksum);
-
- can_checksum = !pinfo->fragmented &&
+ gboolean can_checksum = !pinfo->fragmented &&
tvb_bytes_exist(tvb, 0, tvb_reported_length(tvb));
if (can_checksum && pref_check_checksum) {
@@ -262,41 +248,13 @@ dissect_stt_checksum(tvbuff_t *tvb, packet_info *pinfo, proto_tree *stt_tree)
break;
}
SET_CKSUM_VEC_TVB(cksum_vec[3], tvb, 0, tvb_reported_length(tvb));
- computed_cksum = in_cksum(cksum_vec, 4);
- checksum_good = (computed_cksum == 0);
- checksum_bad = !checksum_good;
-
- if (checksum_good) {
- proto_item_append_text(item, " [correct]");
- } else if (checksum_bad) {
- guint16 expected_cksum = in_cksum_shouldbe(checksum, computed_cksum);
-
- proto_item_append_text(item, " [incorrect, should be 0x%04x (maybe caused by \"TCP checksum offload\"?)]",
- expected_cksum);
-
- expert_add_info(pinfo, item, &ei_stt_checksum_bad);
- checksum = expected_cksum;
- }
- } else if (pref_check_checksum) {
- proto_item_append_text(item, " [unchecked, not all data available]");
+ proto_tree_add_checksum(stt_tree, tvb, 16, hf_stt_checksum, hf_stt_checksum_status, &ei_stt_checksum_bad, pinfo,
+ in_cksum(cksum_vec, 4), ENC_BIG_ENDIAN, PROTO_CHECKSUM_VERIFY);
} else {
- proto_item_append_text(item, " [validation disabled]");
- }
-
- checksum_tree = proto_item_add_subtree(item, ett_stt_checksum);
-
- if (checksum_good || checksum_bad) {
- item = proto_tree_add_uint(checksum_tree, hf_stt_checksum_calculated,
- tvb, 16, 2, checksum);
- PROTO_ITEM_SET_GENERATED(item);
+ proto_tree_add_checksum(stt_tree, tvb, 16, hf_stt_checksum, hf_stt_checksum_status, &ei_stt_checksum_bad, pinfo,
+ 0, ENC_BIG_ENDIAN, PROTO_CHECKSUM_NO_FLAGS);
}
- item = proto_tree_add_boolean(checksum_tree, hf_stt_checksum_good, tvb,
- 16, 2, checksum_good);
- PROTO_ITEM_SET_GENERATED(item);
- item = proto_tree_add_boolean(checksum_tree, hf_stt_checksum_bad, tvb,
- 16, 2, checksum_bad);
- PROTO_ITEM_SET_GENERATED(item);
}
static int
@@ -834,22 +792,10 @@ proto_register_stt(void)
"Details at: http://www.wireshark.org/docs/wsug_html_chunked/ChAdvChecksums.html", HFILL
},
},
- { &hf_stt_checksum_good,
- { "Good Checksum", "stt.checksum.good",
- FT_BOOLEAN, BASE_NONE, NULL, 0x0,
- "True: checksum matches packet content; False: doesn't match content or not checked", HFILL
- },
- },
- { &hf_stt_checksum_bad,
- { "Bad Checksum", "stt.checksum.bad",
- FT_BOOLEAN, BASE_NONE, NULL, 0x0,
- "True: checksum doesn't match packet content; False: matches content or not checked", HFILL
- },
- },
- { &hf_stt_checksum_calculated,
- { "Calculated Checksum", "stt.checksum.calculated",
- FT_UINT16, BASE_HEX, NULL, 0x0,
- "The expected STT checksum field as calculated from the STT segment", HFILL
+ { &hf_stt_checksum_status,
+ { "Checksum Status", "stt.checksum.status",
+ FT_UINT8, BASE_NONE, VALS(proto_checksum_vals), 0x0,
+ NULL, HFILL
},
},
@@ -923,7 +869,6 @@ proto_register_stt(void)
&ett_stt_tcp_flags,
&ett_stt_flgs,
&ett_stt_vlan,
- &ett_stt_checksum,
&ett_segment,
&ett_segments
};
diff --git a/epan/dissectors/packet-synphasor.c b/epan/dissectors/packet-synphasor.c
index d4b56d4423..47760b50ee 100644
--- a/epan/dissectors/packet-synphasor.c
+++ b/epan/dissectors/packet-synphasor.c
@@ -546,10 +546,10 @@ static int dissect_common(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, v
/* check CRC, call appropriate subdissector for the rest of the frame if CRC is correct*/
sub_item = proto_tree_add_item(synphasor_tree, hf_synphasor_data, tvb, offset, tvbsize - 16, ENC_NA);
crc_good = check_crc(tvb, &crc);
- temp_item = proto_tree_add_uint(synphasor_tree, hf_synphasor_checksum, tvb, tvbsize - 2, 2, crc);
+ proto_tree_add_checksum(synphasor_tree, tvb, tvbsize - 2, hf_synphasor_checksum, -1, NULL, pinfo, crc16_x25_ccitt_tvb(tvb, tvb_get_ntohs(tvb, 2) - 2),
+ ENC_BIG_ENDIAN, PROTO_CHECKSUM_VERIFY);
if (!crc_good) {
proto_item_append_text(sub_item, ", not dissected because of wrong checksum");
- proto_item_append_text(temp_item, " [incorrect]");
}
else {
/* create a new tvb to pass to the subdissector
diff --git a/epan/dissectors/packet-sysex.c b/epan/dissectors/packet-sysex.c
index f8d1a7414c..e5e827bdbb 100644
--- a/epan/dissectors/packet-sysex.c
+++ b/epan/dissectors/packet-sysex.c
@@ -1186,16 +1186,8 @@ dissect_sysex_command(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree
digitech_helper ^= *data_ptr++;
}
- item = proto_tree_add_item(tree, hf_digitech_checksum, tvb, offset, 1, ENC_BIG_ENDIAN);
- if (digitech_helper == 0)
- {
- proto_item_append_text(item, " (correct)");
- }
- else
- {
- proto_item_append_text(item, " (NOT correct)");
- expert_add_info(pinfo, item, &ei_digitech_checksum_bad);
- }
+ proto_tree_add_checksum(tree, tvb, offset, hf_digitech_checksum, -1, &ei_digitech_checksum_bad, pinfo, digitech_helper,
+ ENC_BIG_ENDIAN, PROTO_CHECKSUM_VERIFY|PROTO_CHECKSUM_ZERO);
offset++;
break;
}
diff --git a/epan/dissectors/packet-tcp.c b/epan/dissectors/packet-tcp.c
index 575ca1cb2a..d58ff69768 100644
--- a/epan/dissectors/packet-tcp.c
+++ b/epan/dissectors/packet-tcp.c
@@ -140,8 +140,7 @@ static int hf_tcp_window_size_value = -1;
static int hf_tcp_window_size = -1;
static int hf_tcp_window_size_scalefactor = -1;
static int hf_tcp_checksum = -1;
-static int hf_tcp_checksum_bad = -1;
-static int hf_tcp_checksum_good = -1;
+static int hf_tcp_checksum_status = -1;
static int hf_tcp_checksum_calculated = -1;
static int hf_tcp_len = -1;
static int hf_tcp_urgent_pointer = -1;
@@ -3872,8 +3871,7 @@ dissect_tcpopt_mptcp(const ip_tcp_opt *optp _U_, tvbuff_t *tvb,
if ((int)optlen >= offset-start_offset+4)
{
- proto_tree_add_item(mptcp_tree,
- hf_tcp_option_mptcp_checksum, tvb, offset, 2, ENC_BIG_ENDIAN);
+ proto_tree_add_checksum(mptcp_tree, tvb, offset, hf_tcp_option_mptcp_checksum, -1, NULL, pinfo, 0, ENC_BIG_ENDIAN, PROTO_CHECKSUM_NO_FLAGS);
}
}
break;
@@ -5286,7 +5284,6 @@ dissect_tcp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
vec_t cksum_vec[4];
guint32 phdr[2];
guint16 computed_cksum;
- guint16 expected_cksum;
guint16 real_window;
guint captured_length_remaining;
gboolean desegment_ok;
@@ -5753,11 +5750,9 @@ dissect_tcp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
item = proto_tree_add_uint(checksum_tree, hf_tcp_checksum_calculated, tvb,
offset + 16, 2, 0x0000);
PROTO_ITEM_SET_GENERATED(item);
- item = proto_tree_add_boolean(checksum_tree, hf_tcp_checksum_good, tvb,
- offset + 16, 2, FALSE);
- PROTO_ITEM_SET_GENERATED(item);
- item = proto_tree_add_boolean(checksum_tree, hf_tcp_checksum_bad, tvb,
- offset + 16, 2, FALSE);
+ /* XXX - What should this special status be? */
+ item = proto_tree_add_uint(checksum_tree, hf_tcp_checksum_status, tvb,
+ offset + 16, 0, 4);
PROTO_ITEM_SET_GENERATED(item);
expert_add_info(pinfo, item, &ei_tcp_checksum_ffff);
@@ -5765,60 +5760,30 @@ dissect_tcp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
/* Checksum is treated as valid on most systems, so we're willing to desegment it. */
desegment_ok = TRUE;
- } else if (computed_cksum == 0) {
- item = proto_tree_add_uint_format_value(tcp_tree, hf_tcp_checksum, tvb,
- offset + 16, 2, th_sum, "0x%04x [correct]", th_sum);
+ } else {
+ proto_item* calc_item;
+ item = proto_tree_add_checksum(tcp_tree, tvb, offset+16, hf_tcp_checksum, hf_tcp_checksum_status, &ei_tcp_checksum_bad, pinfo, computed_cksum,
+ ENC_BIG_ENDIAN, PROTO_CHECKSUM_VERIFY|PROTO_CHECKSUM_IN_CKSUM);
- checksum_tree = proto_item_add_subtree(item, ett_tcp_checksum);
- item = proto_tree_add_uint(checksum_tree, hf_tcp_checksum_calculated, tvb,
+ calc_item = proto_tree_add_uint(tcp_tree, hf_tcp_checksum_calculated, tvb,
offset + 16, 2, th_sum);
- PROTO_ITEM_SET_GENERATED(item);
- item = proto_tree_add_boolean(checksum_tree, hf_tcp_checksum_good, tvb,
- offset + 16, 2, TRUE);
- PROTO_ITEM_SET_GENERATED(item);
- item = proto_tree_add_boolean(checksum_tree, hf_tcp_checksum_bad, tvb,
- offset + 16, 2, FALSE);
- PROTO_ITEM_SET_GENERATED(item);
+ PROTO_ITEM_SET_GENERATED(calc_item);
/* Checksum is valid, so we're willing to desegment it. */
- desegment_ok = TRUE;
- } else {
- expected_cksum = in_cksum_shouldbe(th_sum, computed_cksum);
-
- item = proto_tree_add_uint_format_value(tcp_tree, hf_tcp_checksum, tvb,
- offset + 16, 2, th_sum,
- "0x%04x [incorrect, should be 0x%04x (maybe caused by \"TCP checksum offload\"?)]", th_sum,
- expected_cksum);
-
- checksum_tree = proto_item_add_subtree(item, ett_tcp_checksum);
- item = proto_tree_add_uint(checksum_tree, hf_tcp_checksum_calculated, tvb,
- offset + 16, 2, expected_cksum);
- PROTO_ITEM_SET_GENERATED(item);
- item = proto_tree_add_boolean(checksum_tree, hf_tcp_checksum_good, tvb,
- offset + 16, 2, FALSE);
- PROTO_ITEM_SET_GENERATED(item);
- item = proto_tree_add_boolean(checksum_tree, hf_tcp_checksum_bad, tvb,
- offset + 16, 2, TRUE);
- PROTO_ITEM_SET_GENERATED(item);
- expert_add_info(pinfo, item, &ei_tcp_checksum_bad);
-
- col_append_str(pinfo->cinfo, COL_INFO, " [TCP CHECKSUM INCORRECT]");
+ if (computed_cksum == 0) {
+ desegment_ok = TRUE;
+ } else {
+ proto_item_append_text(item, "(maybe caused by \"TCP checksum offload\"?)");
- /* Checksum is invalid, so we're not willing to desegment it. */
- desegment_ok = FALSE;
- pinfo->noreassembly_reason = " [incorrect TCP checksum]";
+ /* Checksum is invalid, so we're not willing to desegment it. */
+ desegment_ok = FALSE;
+ pinfo->noreassembly_reason = " [incorrect TCP checksum]";
+ col_append_str(pinfo->cinfo, COL_INFO, " [TCP CHECKSUM INCORRECT]");
+ }
}
} else {
- item = proto_tree_add_uint_format_value(tcp_tree, hf_tcp_checksum, tvb,
- offset + 16, 2, th_sum, "0x%04x [validation disabled]", th_sum);
-
- checksum_tree = proto_item_add_subtree(item, ett_tcp_checksum);
- item = proto_tree_add_boolean(checksum_tree, hf_tcp_checksum_good, tvb,
- offset + 16, 2, FALSE);
- PROTO_ITEM_SET_GENERATED(item);
- item = proto_tree_add_boolean(checksum_tree, hf_tcp_checksum_bad, tvb,
- offset + 16, 2, FALSE);
- PROTO_ITEM_SET_GENERATED(item);
+ proto_tree_add_checksum(tcp_tree, tvb, offset+16, hf_tcp_checksum, hf_tcp_checksum_status, &ei_tcp_checksum_bad, pinfo, 0,
+ ENC_BIG_ENDIAN, PROTO_CHECKSUM_NO_FLAGS);
/* We didn't check the checksum, and don't care if it's valid,
so we're willing to desegment it. */
@@ -5826,16 +5791,8 @@ dissect_tcp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
}
} else {
/* We don't have all the packet data, so we can't checksum it... */
- item = proto_tree_add_uint_format_value(tcp_tree, hf_tcp_checksum, tvb,
- offset + 16, 2, th_sum, "0x%04x [unchecked, not all data available]", th_sum);
-
- checksum_tree = proto_item_add_subtree(item, ett_tcp_checksum);
- item = proto_tree_add_boolean(checksum_tree, hf_tcp_checksum_good, tvb,
- offset + 16, 2, FALSE);
- PROTO_ITEM_SET_GENERATED(item);
- item = proto_tree_add_boolean(checksum_tree, hf_tcp_checksum_bad, tvb,
- offset + 16, 2, FALSE);
- PROTO_ITEM_SET_GENERATED(item);
+ proto_tree_add_checksum(tcp_tree, tvb, offset+16, hf_tcp_checksum, hf_tcp_checksum_status, &ei_tcp_checksum_bad, pinfo, 0,
+ ENC_BIG_ENDIAN, PROTO_CHECKSUM_NO_FLAGS);
/* ...and aren't willing to desegment it. */
desegment_ok = FALSE;
@@ -6201,13 +6158,9 @@ proto_register_tcp(void)
{ "Checksum", "tcp.checksum", FT_UINT16, BASE_HEX, NULL, 0x0,
"Details at: http://www.wireshark.org/docs/wsug_html_chunked/ChAdvChecksums.html", HFILL }},
- { &hf_tcp_checksum_good,
- { "Good Checksum", "tcp.checksum_good", FT_BOOLEAN, BASE_NONE, NULL, 0x0,
- "True: checksum matches packet content; False: doesn't match content or not checked", HFILL }},
-
- { &hf_tcp_checksum_bad,
- { "Bad Checksum", "tcp.checksum_bad", FT_BOOLEAN, BASE_NONE, NULL, 0x0,
- "True: checksum doesn't match packet content; False: matches content or not checked", HFILL }},
+ { &hf_tcp_checksum_status,
+ { "Checksum Status", "tcp.checksum.status", FT_UINT8, BASE_NONE, VALS(proto_checksum_vals), 0x0,
+ NULL, HFILL }},
{ &hf_tcp_checksum_calculated,
{ "Calculated Checksum", "tcp.checksum_calculated", FT_UINT16, BASE_HEX, NULL, 0x0,
diff --git a/epan/dissectors/packet-teamspeak2.c b/epan/dissectors/packet-teamspeak2.c
index 3febde13f3..388dd4dba1 100644
--- a/epan/dissectors/packet-teamspeak2.c
+++ b/epan/dissectors/packet-teamspeak2.c
@@ -304,7 +304,7 @@ typedef struct
static reassembly_table msg_reassembly_table;
/* forward reference */
-static gboolean ts2_add_checked_crc32(proto_tree *tree, int hf_item, tvbuff_t *tvb, guint16 offset, guint32 icrc32);
+static void ts2_add_checked_crc32(proto_tree *tree, int hf_item, tvbuff_t *tvb, guint16 offset);
static void ts2_parse_playerlist(tvbuff_t *tvb, proto_tree *ts2_tree);
static void ts2_parse_channellist(tvbuff_t *tvb, proto_tree *ts2_tree);
static void ts2_parse_newplayerjoined(tvbuff_t *tvb, proto_tree *ts2_tree);
@@ -421,7 +421,7 @@ static void ts2_standard_dissect(tvbuff_t *tvb, packet_info *pinfo, proto_tree *
proto_tree_add_item(ts2_tree, hf_ts2_resend_count, tvb, 16, 2, ENC_LITTLE_ENDIAN);
proto_tree_add_item(ts2_tree, hf_ts2_fragmentnumber, tvb, 18, 2, ENC_LITTLE_ENDIAN);
- ts2_add_checked_crc32(ts2_tree, hf_ts2_crc32, tvb, 20, tvb_get_letohl(tvb, 20));
+ ts2_add_checked_crc32(ts2_tree, hf_ts2_crc32, tvb, 20);
/* Reassemble the packet if it's fragmented */
new_tvb = NULL;
@@ -764,7 +764,7 @@ static int dissect_ts2(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void
{
case TS2C_CONNECTION:
proto_tree_add_item(ts2_tree, hf_ts2_seqnum, tvb, 12, 4, ENC_LITTLE_ENDIAN);
- ts2_add_checked_crc32(ts2_tree, hf_ts2_crc32, tvb, 16, tvb_get_letohl(tvb, 16));
+ ts2_add_checked_crc32(ts2_tree, hf_ts2_crc32, tvb, 16);
switch(type)
{
@@ -816,29 +816,20 @@ static int dissect_ts2(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void
/* Calculates a CRC32 checksum from the tvb zeroing out four bytes at the offset and checks it with the given crc32 and adds the result to the tree
* Returns true if the calculated CRC32 matches the passed CRC32.
* */
-static gboolean ts2_add_checked_crc32(proto_tree *tree, int hf_item, tvbuff_t *tvb, guint16 offset, guint32 icrc32 )
+static void ts2_add_checked_crc32(proto_tree *tree, int hf_item, tvbuff_t *tvb, guint16 offset)
{
- guint8 *zero;
- gint len;
+ guint32 zero = 0;
+ gint len = tvb_reported_length_remaining(tvb, offset+4);
guint32 ocrc32;
- zero = (guint8 *)wmem_alloc0(wmem_packet_scope(), 4);
- ocrc32 = crc32_ccitt_tvb(tvb, offset);
- ocrc32 = crc32_ccitt_seed(zero, 4, 0xffffffff-ocrc32);
- len = tvb_reported_length_remaining(tvb, offset+4);
if (len<0)
- return FALSE;
+ return;
+
+ ocrc32 = crc32_ccitt_tvb(tvb, offset);
+ ocrc32 = crc32_ccitt_seed((guint8*)&zero, 4, 0xffffffff-ocrc32);
ocrc32 = crc32_ccitt_tvb_offset_seed(tvb, offset+4, (guint)len, 0xffffffff-ocrc32);
- if(icrc32==ocrc32)
- {
- proto_tree_add_uint_format(tree, hf_item, tvb, offset, 4, tvb_get_letohl(tvb, 16), "crc32: 0x%04x [correct]", tvb_get_letohl(tvb, offset));
- return TRUE;
- }
- else
- {
- proto_tree_add_uint_format(tree, hf_item, tvb, offset, 4, tvb_get_letohl(tvb,16), "crc32: 0x%04x [incorrect, should be 0x%04x]", tvb_get_letohl(tvb, offset),ocrc32);
- return FALSE;
- }
+
+ proto_tree_add_checksum(tree, tvb, offset, hf_item, -1, NULL, NULL, ocrc32, ENC_LITTLE_ENDIAN, PROTO_CHECKSUM_VERIFY);
}
static void ts2_init(void)
diff --git a/epan/dissectors/packet-tnef.c b/epan/dissectors/packet-tnef.c
index b57a2627c9..0a83831dce 100644
--- a/epan/dissectors/packet-tnef.c
+++ b/epan/dissectors/packet-tnef.c
@@ -612,7 +612,7 @@ static int dissect_tnef(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, voi
offset += length;
}
- proto_tree_add_item(attr_tree, hf_tnef_attribute_checksum, tvb, offset, 2, ENC_LITTLE_ENDIAN);
+ proto_tree_add_checksum(attr_tree, tvb, offset, hf_tnef_attribute_checksum, -1, NULL, pinfo, 0, ENC_LITTLE_ENDIAN, PROTO_CHECKSUM_NO_FLAGS);
offset += 2;
proto_item_set_len(attr_item, offset - start_offset);
diff --git a/epan/dissectors/packet-tns.c b/epan/dissectors/packet-tns.c
index 0d3a82c404..137d4b71a1 100644
--- a/epan/dissectors/packet-tns.c
+++ b/epan/dissectors/packet-tns.c
@@ -816,11 +816,7 @@ dissect_tns_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data
}
offset += 2;
- if ( tree )
- {
- proto_tree_add_item(tns_tree, hf_tns_packet_checksum, tvb,
- offset, 2, ENC_BIG_ENDIAN);
- }
+ proto_tree_add_checksum(tns_tree, tvb, offset, hf_tns_packet_checksum, -1, NULL, pinfo, 0, ENC_BIG_ENDIAN, PROTO_CHECKSUM_NO_FLAGS);
offset += 2;
type = tvb_get_guint8(tvb, offset);
@@ -841,11 +837,7 @@ dissect_tns_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data
}
offset += 1;
- if ( tree )
- {
- proto_tree_add_item(tns_tree, hf_tns_header_checksum, tvb,
- offset, 2, ENC_BIG_ENDIAN);
- }
+ proto_tree_add_checksum(tns_tree, tvb, offset, hf_tns_header_checksum, -1, NULL, pinfo, 0, ENC_BIG_ENDIAN, PROTO_CHECKSUM_NO_FLAGS);
offset += 2;
switch (type)
diff --git a/epan/dissectors/packet-ua3g.c b/epan/dissectors/packet-ua3g.c
index e4b99e7365..c8acf15cbd 100644
--- a/epan/dissectors/packet-ua3g.c
+++ b/epan/dissectors/packet-ua3g.c
@@ -2796,7 +2796,7 @@ decode_ua_dwl_protocol(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo,
proto_tree_add_item(ua3g_body_tree, hf_ua3g_ua_dwl_protocol_packet_download_end_ack_ok_status, tvb, offset, 1, ENC_BIG_ENDIAN);
break;
case 0x06: /* Downloading Iso Checksum (MESSAGE FROM THE SYSTEM) */
- proto_tree_add_item(ua3g_body_tree, hf_ua3g_ua_dwl_protocol_checksum, tvb, offset, 4, ENC_BIG_ENDIAN);
+ proto_tree_add_checksum(ua3g_body_tree, tvb, offset, hf_ua3g_ua_dwl_protocol_checksum, -1, NULL, pinfo, 0, ENC_BIG_ENDIAN, PROTO_CHECKSUM_NO_FLAGS);
break;
case 0x07: /* Downloading ISO Checksum Acknowledge (MESSAGE FROM THE TERMINAL) */
proto_tree_add_item(ua3g_body_tree, hf_ua3g_ua_dwl_protocol_acknowledge, tvb, offset, 1, ENC_BIG_ENDIAN);
diff --git a/epan/dissectors/packet-udld.c b/epan/dissectors/packet-udld.c
index b694d0d3a6..b77d3ce6ee 100644
--- a/epan/dissectors/packet-udld.c
+++ b/epan/dissectors/packet-udld.c
@@ -125,7 +125,7 @@ dissect_udld(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_
proto_tree_add_item(flags_tree, hf_udld_flags_rt, tvb, offset, 1, ENC_BIG_ENDIAN);
proto_tree_add_item(flags_tree, hf_udld_flags_rsy, tvb, offset, 1, ENC_BIG_ENDIAN);
offset += 1;
- proto_tree_add_item(udld_tree, hf_udld_checksum, tvb, offset, 2, ENC_BIG_ENDIAN);
+ proto_tree_add_checksum(udld_tree, tvb, offset, hf_udld_checksum, -1, NULL, pinfo, 0, ENC_BIG_ENDIAN, PROTO_CHECKSUM_NO_FLAGS);
offset += 2;
} else {
offset += 4; /* The version/opcode/flags/checksum fields from above */
diff --git a/epan/dissectors/packet-udp.c b/epan/dissectors/packet-udp.c
index 1b170f817b..ce4ad54507 100644
--- a/epan/dissectors/packet-udp.c
+++ b/epan/dissectors/packet-udp.c
@@ -93,13 +93,9 @@ static header_field_info hfi_udp_checksum_calculated UDP_HFI_INIT =
{ "Calculated Checksum", "udp.checksum_calculated", FT_UINT16, BASE_HEX, NULL, 0x0,
"The expected UDP checksum field as calculated from the UDP packet", HFILL };
-static header_field_info hfi_udp_checksum_good UDP_HFI_INIT =
-{ "Good Checksum", "udp.checksum_good", FT_BOOLEAN, BASE_NONE, NULL, 0x0,
- "True: checksum matches packet content; False: doesn't match content or not checked", HFILL };
-
-static header_field_info hfi_udp_checksum_bad UDP_HFI_INIT =
-{ "Bad Checksum", "udp.checksum_bad", FT_BOOLEAN, BASE_NONE, NULL, 0x0,
- "True: checksum doesn't match packet content; False: matches content or not checked", HFILL };
+static header_field_info hfi_udp_checksum_status UDP_HFI_INIT =
+{ "Checksum Status", "udp.checksum.status", FT_UINT8, BASE_NONE, VALS(proto_checksum_vals), 0x0,
+ NULL, HFILL };
static header_field_info hfi_udp_proc_src_uid UDP_HFI_INIT =
{ "Source process user ID", "udp.proc.srcuid", FT_UINT32, BASE_DEC, NULL, 0x0,
@@ -777,14 +773,13 @@ static void
dissect(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint32 ip_proto)
{
proto_tree *udp_tree = NULL;
- proto_item *ti, *item, *hidden_item;
+ proto_item *ti, *item, *hidden_item, *calc_item;
proto_item *src_port_item, *dst_port_item, *len_cov_item;
guint len;
guint reported_len;
vec_t cksum_vec[4];
guint32 phdr[2];
guint16 computed_cksum;
- guint16 expected_cksum;
int offset = 0;
e_udphdr *udph;
proto_tree *checksum_tree;
@@ -890,28 +885,17 @@ dissect(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint32 ip_proto)
if (udph->uh_sum == 0) {
/* No checksum supplied in the packet. */
if (((ip_proto == IP_PROTO_UDP) && (pinfo->src.type == AT_IPv4)) || pinfo->flags.in_error_pkt) {
- item = proto_tree_add_uint_format_value(udp_tree, hfi_udp_checksum.id, tvb, offset + 6, 2, 0,
- "0x%04x (none)", 0);
-
- checksum_tree = proto_item_add_subtree(item, ett_udp_checksum);
- item = proto_tree_add_boolean(checksum_tree, &hfi_udp_checksum_good, tvb,
- offset + 6, 2, FALSE);
- PROTO_ITEM_SET_GENERATED(item);
- item = proto_tree_add_boolean(checksum_tree, &hfi_udp_checksum_bad, tvb,
- offset + 6, 2, FALSE);
- PROTO_ITEM_SET_GENERATED(item);
+ proto_tree_add_checksum(udp_tree, tvb, offset + 6, hfi_udp_checksum.id, hfi_udp_checksum_status.id, NULL, pinfo, 0, ENC_BIG_ENDIAN, PROTO_CHECKSUM_NOT_PRESENT);
} else {
- item = proto_tree_add_uint_format_value(udp_tree, hfi_udp_checksum.id, tvb, offset + 6, 2, 0,
- "0x%04x (Illegal)", 0);
+ item = proto_tree_add_uint_format_value(udp_tree, hfi_udp_checksum.id, tvb, offset + 6, 2, 0, "0 (Illegal)");
+ checksum_tree = proto_item_add_subtree(item, ett_udp_checksum);
+
expert_add_info(pinfo, item, &ei_udp_checksum_zero);
col_append_str(pinfo->cinfo, COL_INFO, " [ILLEGAL CHECKSUM (0)]");
- checksum_tree = proto_item_add_subtree(item, ett_udp_checksum);
- item = proto_tree_add_boolean(checksum_tree, &hfi_udp_checksum_good, tvb,
- offset + 6, 2, FALSE);
- PROTO_ITEM_SET_GENERATED(item);
- item = proto_tree_add_boolean(checksum_tree, &hfi_udp_checksum_bad, tvb,
- offset + 6, 2, TRUE);
+ /* XXX - What should this special status be? */
+ item = proto_tree_add_uint(checksum_tree, &hfi_udp_checksum_status, tvb,
+ offset + 6, 0, 4);
PROTO_ITEM_SET_GENERATED(item);
}
} else if (!pinfo->fragmented && (len >= reported_len) &&
@@ -953,63 +937,27 @@ dissect(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint32 ip_proto)
}
SET_CKSUM_VEC_TVB(cksum_vec[3], tvb, offset, udph->uh_sum_cov);
computed_cksum = in_cksum(&cksum_vec[0], 4);
- if (computed_cksum == 0) {
- item = proto_tree_add_uint_format_value(udp_tree, hfi_udp_checksum.id, tvb,
- offset + 6, 2, udph->uh_sum, "0x%04x [correct]", udph->uh_sum);
- checksum_tree = proto_item_add_subtree(item, ett_udp_checksum);
- item = proto_tree_add_uint(checksum_tree, &hfi_udp_checksum_calculated,
- tvb, offset + 6, 2, udph->uh_sum);
- PROTO_ITEM_SET_GENERATED(item);
- item = proto_tree_add_boolean(checksum_tree, &hfi_udp_checksum_good, tvb,
- offset + 6, 2, TRUE);
- PROTO_ITEM_SET_GENERATED(item);
- item = proto_tree_add_boolean(checksum_tree, &hfi_udp_checksum_bad, tvb,
- offset + 6, 2, FALSE);
- PROTO_ITEM_SET_GENERATED(item);
+ item = proto_tree_add_checksum(udp_tree, tvb, offset+6, hfi_udp_checksum.id, hfi_udp_checksum_status.id, &ei_udp_checksum_bad, pinfo, computed_cksum,
+ ENC_BIG_ENDIAN, PROTO_CHECKSUM_VERIFY|PROTO_CHECKSUM_IN_CKSUM);
+ checksum_tree = proto_item_add_subtree(item, ett_udp_checksum);
+
+ if (computed_cksum != 0) {
+ proto_item_append_text(item, "(maybe caused by \"UDP checksum offload\"?)");
+ col_append_str(pinfo->cinfo, COL_INFO, " [UDP CHECKSUM INCORRECT]");
+ calc_item = proto_tree_add_uint(checksum_tree, &hfi_udp_checksum_calculated,
+ tvb, offset + 6, 2, in_cksum_shouldbe(udph->uh_sum, computed_cksum));
} else {
- expected_cksum = in_cksum_shouldbe(udph->uh_sum, computed_cksum);
- item = proto_tree_add_uint_format_value(udp_tree, hfi_udp_checksum.id, tvb,
- offset + 6, 2, udph->uh_sum,
- "0x%04x [incorrect, should be 0x%04x (maybe caused by \"UDP checksum offload\"?)]", udph->uh_sum,
- expected_cksum);
-
- checksum_tree = proto_item_add_subtree(item, ett_udp_checksum);
- item = proto_tree_add_uint(checksum_tree, &hfi_udp_checksum_calculated,
- tvb, offset + 6, 2, expected_cksum);
- PROTO_ITEM_SET_GENERATED(item);
- item = proto_tree_add_boolean(checksum_tree, &hfi_udp_checksum_good, tvb,
- offset + 6, 2, FALSE);
- PROTO_ITEM_SET_GENERATED(item);
- item = proto_tree_add_boolean(checksum_tree, &hfi_udp_checksum_bad, tvb,
- offset + 6, 2, TRUE);
- PROTO_ITEM_SET_GENERATED(item);
- expert_add_info(pinfo, item, &ei_udp_checksum_bad);
-
- col_append_str(pinfo->cinfo, COL_INFO, " [UDP CHECKSUM INCORRECT]");
+ calc_item = proto_tree_add_uint(checksum_tree, &hfi_udp_checksum_calculated,
+ tvb, offset + 6, 2, udph->uh_sum);
}
+ PROTO_ITEM_SET_GENERATED(calc_item);
+
} else {
- item = proto_tree_add_uint_format_value(udp_tree, hfi_udp_checksum.id, tvb,
- offset + 6, 2, udph->uh_sum, "0x%04x [validation disabled]", udph->uh_sum);
- checksum_tree = proto_item_add_subtree(item, ett_udp_checksum);
- item = proto_tree_add_boolean(checksum_tree, &hfi_udp_checksum_good, tvb,
- offset + 6, 2, FALSE);
- PROTO_ITEM_SET_GENERATED(item);
- item = proto_tree_add_boolean(checksum_tree, &hfi_udp_checksum_bad, tvb,
- offset + 6, 2, FALSE);
- PROTO_ITEM_SET_GENERATED(item);
+ proto_tree_add_checksum(udp_tree, tvb, offset + 6, hfi_udp_checksum.id, hfi_udp_checksum_status.id, NULL, pinfo, 0, ENC_BIG_ENDIAN, PROTO_CHECKSUM_NO_FLAGS);
}
} else {
- item = proto_tree_add_uint_format_value(udp_tree, hfi_udp_checksum.id, tvb,
- offset + 6, 2, udph->uh_sum, "0x%04x [unchecked, not all data available]", udph->uh_sum);
-
- checksum_tree = proto_item_add_subtree(item, ett_udp_checksum);
- item = proto_tree_add_boolean(checksum_tree, &hfi_udp_checksum_good, tvb,
- offset + 6, 2, FALSE);
- PROTO_ITEM_SET_GENERATED(item);
- item = proto_tree_add_boolean(checksum_tree, &hfi_udp_checksum_bad, tvb,
- offset + 6, 2, FALSE);
- PROTO_ITEM_SET_GENERATED(item);
+ proto_tree_add_checksum(udp_tree, tvb, offset + 6, hfi_udp_checksum.id, hfi_udp_checksum_status.id, NULL, pinfo, 0, ENC_BIG_ENDIAN, PROTO_CHECKSUM_NO_FLAGS);
}
/* Skip over header */
@@ -1116,8 +1064,7 @@ proto_register_udp(void)
&hfi_udp_length,
&hfi_udp_checksum,
&hfi_udp_checksum_calculated,
- &hfi_udp_checksum_good,
- &hfi_udp_checksum_bad,
+ &hfi_udp_checksum_status,
&hfi_udp_proc_src_uid,
&hfi_udp_proc_src_pid,
&hfi_udp_proc_src_uname,
diff --git a/epan/dissectors/packet-v5dl.c b/epan/dissectors/packet-v5dl.c
index fd1f067105..1c4ed88e12 100644
--- a/epan/dissectors/packet-v5dl.c
+++ b/epan/dissectors/packet-v5dl.c
@@ -61,8 +61,7 @@ static int hf_v5dl_ftype_s_u = -1;
static int hf_v5dl_ftype_s_u_ext = -1;
#if 0
static int hf_v5dl_checksum = -1;
-static int hf_v5dl_checksum_good = -1;
-static int hf_v5dl_checksum_bad = -1;
+static int hf_v5dl_checksum_status = -1;
#endif
static gint ett_v5dl = -1;
static gint ett_v5dl_address = -1;
@@ -241,28 +240,11 @@ dissect_v5dl(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_
* packet.
*/
checksum_offset = reported_length - 2;
- checksum = tvb_get_ntohs(tvb, checksum_offset);
checksum_calculated = crc16_ccitt_tvb(tvb, checksum_offset);
checksum_calculated = g_htons(checksum_calculated); /* Note: g_htons() macro may eval arg multiple times */
- if (checksum == checksum_calculated) {
- checksum_ti = proto_tree_add_uint_format_value(v5dl_tree, hf_v5dl_checksum, tvb, checksum_offset,
- 2, 0,
- "0x%04x [correct]",
- checksum);
- checksum_tree = proto_item_add_subtree(checksum_ti, ett_v5dl_checksum);
- proto_tree_add_boolean(checksum_tree, hf_v5dl_checksum_good, tvb, checksum_offset, 2, TRUE);
- proto_tree_add_boolean(checksum_tree, hf_v5dl_checksum_bad, tvb, checksum_offset, 2, FALSE);
- } else {
- checksum_ti = proto_tree_add_uint_format_value(v5dl_tree, hf_v5dl_checksum, tvb, checksum_offset,
- 2, 0,
- "0x%04x [incorrect, should be 0x%04x]",
- checksum, checksum_calculated);
- checksum_tree = proto_item_add_subtree(checksum_ti, ett_v5dl_checksum);
- proto_tree_add_boolean(checksum_tree, hf_v5dl_checksum_good, tvb, checksum_offset, 2, FALSE);
- proto_tree_add_boolean(checksum_tree, hf_v5dl_checksum_bad, tvb, checksum_offset, 2, TRUE);
- }
-
+ proto_tree_add_checksum(v5dl_tree, tvb, checksum_offset, hf_v5dl_checksum, hf_v5dl_checksum_status, NULL, pinfo, checksum_calculated,
+ ENC_BIG_ENDIAN, PROTO_CHECKSUM_VERIFY);
/*
* Remove the V5DL header *and* the checksum.
*/
@@ -406,13 +388,9 @@ proto_register_v5dl(void)
{ "Checksum", "v5dl.checksum", FT_UINT16, BASE_HEX,
NULL, 0x0, "Details at: http://www.wireshark.org/docs/wsug_html_chunked/ChAdvChecksums.html", HFILL }},
- { &hf_v5dl_checksum_good,
- { "Good Checksum", "v5dl.checksum_good", FT_BOOLEAN, BASE_NONE,
- NULL, 0x0, "True: checksum matches packet content; False: doesn't match content or not checked", HFILL }},
-
- { &hf_v5dl_checksum_bad,
- { "Bad Checksum", "v5dl.checksum_bad", FT_BOOLEAN, BASE_NONE,
- NULL, 0x0, "True: checksum doesn't match packet content; False: matches content or not checked", HFILL }}
+ { &hf_v5dl_checksum_status,
+ { "Checksum Status", "v5dl.checksum.status", FT_UINT8, BASE_NONE,
+ VALS(proto_checksum_vals), 0x0, NULL, HFILL }},
#endif
};
diff --git a/epan/dissectors/packet-vines.c b/epan/dissectors/packet-vines.c
index 8df6bd96f2..e78db5c2be 100644
--- a/epan/dissectors/packet-vines.c
+++ b/epan/dissectors/packet-vines.c
@@ -578,7 +578,7 @@ dissect_vines_ip(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data
if (tree) {
ti = proto_tree_add_item(tree, proto_vines_ip, tvb, offset, vip_pktlen, ENC_NA);
vip_tree = proto_item_add_subtree(ti, ett_vines_ip);
- proto_tree_add_item(vip_tree, hf_vines_ip_checksum, tvb, offset, 2, ENC_BIG_ENDIAN);
+ proto_tree_add_checksum(vip_tree, tvb, offset, hf_vines_ip_checksum, -1, NULL, pinfo, 0, ENC_BIG_ENDIAN, PROTO_CHECKSUM_NO_FLAGS);
offset += 2;
proto_tree_add_item(vip_tree, hf_vines_ip_length, tvb, offset, 2, ENC_BIG_ENDIAN);
diff --git a/epan/dissectors/packet-vrrp.c b/epan/dissectors/packet-vrrp.c
index 00fa9cf9cd..e2819bd4c1 100644
--- a/epan/dissectors/packet-vrrp.c
+++ b/epan/dissectors/packet-vrrp.c
@@ -47,7 +47,7 @@ static gint hf_vrrp_virt_rtr_id = -1;
static gint hf_vrrp_prio = -1;
static gint hf_vrrp_addr_count = -1;
static gint hf_vrrp_checksum = -1;
-static gint hf_vrrp_checksum_bad = -1;
+static gint hf_vrrp_checksum_status = -1;
static gint hf_vrrp_auth_type = -1;
static gint hf_vrrp_adver_int = -1;
static gint hf_vrrp_reserved_mbz = -1;
@@ -101,10 +101,10 @@ dissect_vrrp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_
vec_t cksum_vec[4];
guint32 phdr[2];
gboolean is_ipv6;
- proto_item *ti, *tv, *hidden_item, *checksum_item;
+ proto_item *ti, *tv;
proto_tree *vrrp_tree, *ver_type_tree;
guint8 priority, addr_count = 0, auth_type = VRRP_AUTH_TYPE_NONE;
- guint16 cksum, computed_cksum;
+ guint16 computed_cksum;
is_ipv6 = (pinfo->src.type == AT_IPv6);
@@ -168,10 +168,6 @@ dissect_vrrp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_
offset += 6;
}
-
- checksum_item = proto_tree_add_item(vrrp_tree, hf_vrrp_checksum, tvb, offset, 2, ENC_BIG_ENDIAN);
-
- cksum = tvb_get_ntohs(tvb, offset);
vrrp_len = (gint)tvb_reported_length(tvb);
if (!pinfo->fragmented && (gint)tvb_captured_length(tvb) >= vrrp_len) {
/* The packet isn't part of a fragmented datagram
@@ -196,22 +192,11 @@ dissect_vrrp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_
break;
}
- if (computed_cksum == 0) {
- hidden_item = proto_tree_add_boolean(vrrp_tree, hf_vrrp_checksum_bad, tvb, offset, 2, FALSE);
- PROTO_ITEM_SET_HIDDEN(hidden_item);
- proto_item_append_text(checksum_item, " [correct]");
- } else {
- hidden_item = proto_tree_add_boolean(vrrp_tree, hf_vrrp_checksum_bad, tvb, offset, 2, TRUE);
- PROTO_ITEM_SET_HIDDEN(hidden_item);
- if(hi_nibble(ver_type)==3){
- proto_item_append_text(checksum_item, " [incorrect, should be 0x%04x(check preferences)]", in_cksum_shouldbe(cksum, computed_cksum));
- } else {
- proto_item_append_text(checksum_item, " [incorrect, should be 0x%04x]", in_cksum_shouldbe(cksum, computed_cksum));
- }
- expert_add_info_format(pinfo, checksum_item, &ei_vrrp_checksum,
- "VRRP Checksum Incorrect, should be 0x%04x", in_cksum_shouldbe(cksum, computed_cksum));
- }
-
+ proto_tree_add_checksum(vrrp_tree, tvb, offset, hf_vrrp_checksum, hf_vrrp_checksum_status, &ei_vrrp_checksum, pinfo, computed_cksum,
+ ENC_BIG_ENDIAN, PROTO_CHECKSUM_VERIFY|PROTO_CHECKSUM_IN_CKSUM);
+ } else {
+ proto_tree_add_checksum(vrrp_tree, tvb, offset, hf_vrrp_checksum, hf_vrrp_checksum_status, &ei_vrrp_checksum, pinfo, 0,
+ ENC_BIG_ENDIAN, PROTO_CHECKSUM_NO_FLAGS);
}
offset += 2;
@@ -273,9 +258,9 @@ void proto_register_vrrp(void)
FT_UINT16, BASE_HEX, NULL, 0x0,
"Used to detect data corruption in the VRRP message", HFILL }},
- { &hf_vrrp_checksum_bad,
- { "Bad Checksum", "vrrp.checksum_bad",
- FT_BOOLEAN, BASE_NONE, NULL, 0x0,
+ { &hf_vrrp_checksum_status,
+ { "Checksum Status", "vrrp.checksum.status",
+ FT_UINT8, BASE_NONE, VALS(proto_checksum_vals), 0x0,
NULL, HFILL }},
{ &hf_vrrp_auth_type,
diff --git a/epan/dissectors/packet-wcp.c b/epan/dissectors/packet-wcp.c
index f7ac337c28..45335fa9a8 100644
--- a/epan/dissectors/packet-wcp.c
+++ b/epan/dissectors/packet-wcp.c
@@ -383,8 +383,7 @@ static int dissect_wcp( tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, voi
}
/* add the check byte */
- proto_tree_add_item(wcp_tree, hf_wcp_chksum, tvb,
- tvb_reported_length( tvb)-1, 1, ENC_NA);
+ proto_tree_add_checksum(wcp_tree, tvb, tvb_reported_length( tvb)-1, hf_wcp_chksum, -1, NULL, pinfo, 0, ENC_NA, PROTO_CHECKSUM_NO_FLAGS);
call_dissector(fr_uncompressed_handle, next_tvb, pinfo, tree);
diff --git a/epan/dissectors/packet-xip-serval.c b/epan/dissectors/packet-xip-serval.c
index acf852c066..ae1219ff1d 100644
--- a/epan/dissectors/packet-xip-serval.c
+++ b/epan/dissectors/packet-xip-serval.c
@@ -179,12 +179,11 @@ static void
display_xip_serval(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
{
proto_tree *xip_serval_tree;
- proto_item *ti, *check_ti, *hl_ti;
+ proto_item *ti, *hl_ti;
tvbuff_t *next_tvb;
vec_t cksum_vec;
gint offset;
- guint16 packet_checksum, actual_checksum;
guint8 xsh_len, protocol, bytes_remaining;
/* Get XIP Serval header length, stored as number of 32-bit words. */
@@ -216,27 +215,9 @@ display_xip_serval(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
/* Compute checksum. */
SET_CKSUM_VEC_TVB(cksum_vec, tvb, 0, xsh_len);
- actual_checksum = in_cksum(&cksum_vec, 1);
- /* Get XIP Serval checksum. */
- packet_checksum = tvb_get_ntohs(tvb, XSRVL_CHK);
-
- if (actual_checksum == 0) {
- /* Add XIP Serval checksum as correct. */
- proto_tree_add_uint_format(xip_serval_tree,
- hf_xip_serval_check, tvb, XSRVL_CHK, 2, packet_checksum,
- "Header checksum: 0x%04x [correct]", packet_checksum);
- } else {
- /* Add XIP Serval checksum as incorrect. */
- check_ti = proto_tree_add_uint_format(xip_serval_tree,
- hf_xip_serval_check, tvb, XSRVL_CHK, 2, packet_checksum,
- "Header checksum: 0x%04x [incorrect, should be 0x%04x]",
- packet_checksum,
- in_cksum_shouldbe(packet_checksum, actual_checksum));
-
- expert_add_info_format(pinfo, check_ti,
- &ei_xip_serval_bad_checksum, "Bad checksum");
- }
+ proto_tree_add_checksum(xip_serval_tree, tvb, XSRVL_CHK, hf_xip_serval_check, -1, &ei_xip_serval_bad_checksum, pinfo, in_cksum(&cksum_vec, 1),
+ ENC_BIG_ENDIAN, PROTO_CHECKSUM_VERIFY|PROTO_CHECKSUM_IN_CKSUM);
offset = XSRVL_EXT;
/* If there's still more room, check for extension headers. */
diff --git a/epan/dissectors/packet-xtp.c b/epan/dissectors/packet-xtp.c
index 2eeea7a0de..7f36a1b304 100644
--- a/epan/dissectors/packet-xtp.c
+++ b/epan/dissectors/packet-xtp.c
@@ -887,7 +887,6 @@ dissect_xtp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_)
guint i, bpos;
guint cmd_options;
vec_t cksum_vec[1];
- guint16 computed_cksum;
gboolean have_btag;
static const int * cmd_options_flags[] = {
&hf_xtp_cmd_options_nocheck,
@@ -1018,20 +1017,12 @@ dissect_xtp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_)
if (!(xtph->cmd_options & XTP_CMD_OPTIONS_NOCHECK))
check_len += xtph->dlen;
SET_CKSUM_VEC_TVB(cksum_vec[0], tvb, 0, check_len);
- computed_cksum = in_cksum(cksum_vec, 1);
- if (computed_cksum == 0) {
- proto_tree_add_uint_format_value(xtp_tree, hf_xtp_checksum, tvb, offset, 2,
- xtph->check, "0x%04x [correct]", xtph->check);
- } else {
- proto_tree_add_uint_format_value(xtp_tree, hf_xtp_checksum, tvb, offset, 2,
- xtph->check, "0x%04x [incorrect, should be 0x%04x]",
- xtph->check,
- in_cksum_shouldbe(xtph->check, computed_cksum));
- }
+ proto_tree_add_checksum(xtp_tree, tvb, offset, hf_xtp_checksum, -1, NULL, pinfo, in_cksum(cksum_vec, 1),
+ ENC_BIG_ENDIAN, PROTO_CHECKSUM_VERIFY|PROTO_CHECKSUM_IN_CKSUM);
}
else {
- proto_tree_add_uint_format_value(xtp_tree, hf_xtp_checksum, tvb, offset, 2,
- xtph->check, "0x%04x", xtph->check);
+ proto_tree_add_checksum(xtp_tree, tvb, offset, hf_xtp_checksum, -1, NULL, pinfo, 0,
+ ENC_BIG_ENDIAN, PROTO_CHECKSUM_NO_FLAGS);
}
offset += 2;
/* sort(2) */
diff --git a/epan/dissectors/packet-zrtp.c b/epan/dissectors/packet-zrtp.c
index d34ea79b44..b73509193a 100644
--- a/epan/dissectors/packet-zrtp.c
+++ b/epan/dissectors/packet-zrtp.c
@@ -113,8 +113,7 @@ static int hf_zrtp_msg_ping_ssrc = -1;
Checksum Data
*/
static int hf_zrtp_checksum = -1;
-static int hf_zrtp_checksum_good = -1;
-static int hf_zrtp_checksum_bad = -1;
+static int hf_zrtp_checksum_status = -1;
/*
Sub-Tree
@@ -318,14 +317,13 @@ dissect_zrtp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_
proto_tree *zrtp_tree;
proto_tree *zrtp_msg_tree;
proto_tree *zrtp_msg_data_tree;
- proto_tree *checksum_tree;
proto_item *ti;
int linelen;
int checksum_offset;
unsigned char message_type[9];
unsigned int prime_offset = 0;
unsigned int msg_offset = 12;
- guint32 sent_crc, calc_crc;
+ guint32 calc_crc;
col_set_str(pinfo->cinfo, COL_PROTOCOL, "ZRTP");
@@ -416,27 +414,10 @@ dissect_zrtp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_
dissect_PingACK(tvb, pinfo, zrtp_msg_data_tree);
}
- sent_crc = tvb_get_ntohl(tvb, msg_offset+checksum_offset);
calc_crc = ~crc32c_tvb_offset_calculate(tvb, 0, msg_offset+checksum_offset, CRC32C_PRELOAD);
- if (sent_crc == calc_crc) {
- ti = proto_tree_add_uint_format_value(zrtp_tree, hf_zrtp_checksum, tvb, msg_offset+checksum_offset, 4, sent_crc,
- "0x%04x [correct]", sent_crc);
- checksum_tree = proto_item_add_subtree(ti, ett_zrtp_checksum);
- ti = proto_tree_add_boolean(checksum_tree, hf_zrtp_checksum_good, tvb, msg_offset+checksum_offset, 4, TRUE);
- PROTO_ITEM_SET_GENERATED(ti);
- ti = proto_tree_add_boolean(checksum_tree, hf_zrtp_checksum_bad, tvb, msg_offset+checksum_offset, 4, FALSE);
- PROTO_ITEM_SET_GENERATED(ti);
- } else {
- ti = proto_tree_add_uint_format_value(zrtp_tree, hf_zrtp_checksum, tvb, msg_offset+checksum_offset, 4, sent_crc,
- "0x%04x [incorrect, should be 0x%04x]", sent_crc, calc_crc);
- checksum_tree = proto_item_add_subtree(ti, ett_zrtp_checksum);
- ti = proto_tree_add_boolean(checksum_tree, hf_zrtp_checksum_good, tvb, msg_offset+checksum_offset, 4, FALSE);
- PROTO_ITEM_SET_GENERATED(ti);
- ti = proto_tree_add_boolean(checksum_tree, hf_zrtp_checksum_bad, tvb, msg_offset+checksum_offset, 4, TRUE);
- PROTO_ITEM_SET_GENERATED(ti);
- }
-
+ proto_tree_add_checksum(zrtp_tree, tvb, msg_offset+checksum_offset, hf_zrtp_checksum, hf_zrtp_checksum_status, NULL, pinfo, calc_crc,
+ ENC_BIG_ENDIAN, PROTO_CHECKSUM_VERIFY);
return tvb_captured_length(tvb);
}
@@ -1098,21 +1079,12 @@ proto_register_zrtp(void)
}
},
- {&hf_zrtp_checksum_good,
+ {&hf_zrtp_checksum_status,
{
- "Good", "zrtp.checksum_good",
- FT_BOOLEAN, BASE_NONE,
- NULL, 0x0,
- "True: checksum matches packet content; False: doesn't match content", HFILL
- }
- },
-
- {&hf_zrtp_checksum_bad,
- {
- "Bad", "zrtp.checksum_bad",
- FT_BOOLEAN, BASE_NONE,
- NULL, 0x0,
- "True: checksum doesn't match packet content; False: matches content", HFILL
+ "Checksum Status", "zrtp.checksum.status",
+ FT_UINT8, BASE_NONE,
+ VALS(proto_checksum_vals), 0x0,
+ NULL, HFILL
}
},
diff --git a/epan/proto.c b/epan/proto.c
index 268e443221..5298ba4c16 100644
--- a/epan/proto.c
+++ b/epan/proto.c
@@ -53,6 +53,7 @@
#include "osi-utils.h"
#include "expert.h"
#include "show_exception.h"
+#include "in_cksum.h"
#include <wsutil/plugins.h>
@@ -10012,6 +10013,133 @@ proto_tree_add_ascii_7bits_item(proto_tree *tree, const int hfindex, tvbuff_t *t
return pi;
}
+const value_string proto_checksum_vals[] = {
+ { PROTO_CHECKSUM_E_BAD, "Bad" },
+ { PROTO_CHECKSUM_E_GOOD, "Good" },
+ { PROTO_CHECKSUM_E_UNVERIFIED, "Unverified" },
+ { PROTO_CHECKSUM_E_NOT_PRESENT, "Not present" },
+
+ { 0, NULL }
+};
+
+proto_item *
+proto_tree_add_checksum(proto_tree *tree, tvbuff_t *tvb, const guint offset,
+ const int hf_checksum, const int hf_checksum_status, struct expert_field* bad_checksum_expert,
+ packet_info *pinfo, guint32 computed_checksum, const guint encoding, const guint flags)
+{
+ header_field_info *hfinfo = proto_registrar_get_nth(hf_checksum);
+ guint32 checksum;
+ guint32 len;
+ proto_item* ti = NULL;
+ proto_item* ti2;
+ gboolean incorrect_checksum = TRUE;
+
+ DISSECTOR_ASSERT_HINT(hfinfo != NULL, "Not passed hfi!");
+
+ if (flags & PROTO_CHECKSUM_NOT_PRESENT) {
+ ti = proto_tree_add_uint_format_value(tree, hf_checksum, tvb, offset, 0, 0, "[missing]");
+ PROTO_ITEM_SET_GENERATED(ti);
+ if (hf_checksum_status != -1) {
+ ti2 = proto_tree_add_uint(tree, hf_checksum_status, tvb, offset, 0, PROTO_CHECKSUM_E_NOT_PRESENT);
+ PROTO_ITEM_SET_GENERATED(ti2);
+ }
+ return ti;
+ }
+
+ switch (hfinfo->type){
+ case FT_UINT8:
+ len = 1;
+ break;
+ case FT_UINT16:
+ len = 2;
+ break;
+ case FT_UINT24:
+ len = 3;
+ break;
+ case FT_UINT32:
+ len = 4;
+ break;
+ default:
+ DISSECTOR_ASSERT_NOT_REACHED();
+ }
+
+ if (flags & PROTO_CHECKSUM_GENERATED) {
+ ti = proto_tree_add_uint(tree, hf_checksum, tvb, offset, 0, computed_checksum);
+ PROTO_ITEM_SET_GENERATED(ti);
+ } else {
+ ti = proto_tree_add_item_ret_uint(tree, hf_checksum, tvb, offset, len, encoding, &checksum);
+ if (flags & PROTO_CHECKSUM_VERIFY) {
+ if (flags & (PROTO_CHECKSUM_IN_CKSUM|PROTO_CHECKSUM_ZERO)) {
+ if (computed_checksum == 0) {
+ proto_item_append_text(ti, " [correct]");
+ if (hf_checksum_status != -1) {
+ ti2 = proto_tree_add_uint(tree, hf_checksum_status, tvb, offset, 0, PROTO_CHECKSUM_E_GOOD);
+ PROTO_ITEM_SET_GENERATED(ti2);
+ }
+ incorrect_checksum = FALSE;
+ } else if (flags & PROTO_CHECKSUM_IN_CKSUM) {
+ computed_checksum = in_cksum_shouldbe(checksum, computed_checksum);
+ }
+ } else {
+ if (checksum == computed_checksum) {
+ proto_item_append_text(ti, " [correct]");
+ if (hf_checksum_status != -1) {
+ ti2 = proto_tree_add_uint(tree, hf_checksum_status, tvb, offset, 0, PROTO_CHECKSUM_E_GOOD);
+ PROTO_ITEM_SET_GENERATED(ti2);
+ }
+ incorrect_checksum = FALSE;
+ }
+ }
+
+ if (incorrect_checksum) {
+ if (hf_checksum_status != -1) {
+ ti2 = proto_tree_add_uint(tree, hf_checksum_status, tvb, offset, 0, PROTO_CHECKSUM_E_BAD);
+ PROTO_ITEM_SET_GENERATED(ti2);
+ }
+ if (flags & PROTO_CHECKSUM_ZERO) {
+ proto_item_append_text(ti, " [incorrect]");
+ if (bad_checksum_expert != NULL)
+ expert_add_info_format(pinfo, ti, bad_checksum_expert, "Bad checksum");
+ } else {
+ switch(hfinfo->type)
+ {
+ case FT_UINT8:
+ proto_item_append_text(ti, " [incorrect, should be 0x%02x]", computed_checksum);
+ if (bad_checksum_expert != NULL)
+ expert_add_info_format(pinfo, ti, bad_checksum_expert, "Bad checksum [should be 0x%02x]", computed_checksum);
+ break;
+ case FT_UINT16:
+ proto_item_append_text(ti, " [incorrect, should be 0x%04x]", computed_checksum);
+ if (bad_checksum_expert != NULL)
+ expert_add_info_format(pinfo, ti, bad_checksum_expert, "Bad checksum [should be 0x%04x]", computed_checksum);
+ break;
+ case FT_UINT24:
+ proto_item_append_text(ti, " [incorrect, should be 0x%06x]", computed_checksum);
+ if (bad_checksum_expert != NULL)
+ expert_add_info_format(pinfo, ti, bad_checksum_expert, "Bad checksum [should be 0x%06x]", computed_checksum);
+ break;
+ case FT_UINT32:
+ proto_item_append_text(ti, " [incorrect, should be 0x%08x]", computed_checksum);
+ if (bad_checksum_expert != NULL)
+ expert_add_info_format(pinfo, ti, bad_checksum_expert, "Bad checksum [should be 0x%08x]", computed_checksum);
+ break;
+ default:
+ DISSECTOR_ASSERT_NOT_REACHED();
+ }
+ }
+ }
+ } else {
+ if (hf_checksum_status != -1) {
+ proto_item_append_text(ti, " [unverified]");
+ ti2 = proto_tree_add_uint(tree, hf_checksum_status, tvb, offset, 0, PROTO_CHECKSUM_E_UNVERIFIED);
+ PROTO_ITEM_SET_GENERATED(ti2);
+ }
+ }
+ }
+
+ return ti;
+}
+
guchar
proto_check_field_name(const gchar *field_name)
{
diff --git a/epan/proto.h b/epan/proto.h
index b48ecadeb7..de96b7cec7 100644
--- a/epan/proto.h
+++ b/epan/proto.h
@@ -45,6 +45,8 @@
#include "wsutil/nstime.h"
#include "time_fmt.h"
#include "tvbuff.h"
+#include "value_string.h"
+#include "packet_info.h"
#include "ftypes/ftypes.h"
#include "register.h"
#include "ws_symbol_export.h"
@@ -2847,6 +2849,47 @@ WS_DLL_PUBLIC proto_item *
proto_tree_add_ascii_7bits_item(proto_tree *tree, const int hfindex, tvbuff_t *tvb,
const guint bit_offset, const gint no_of_chars);
+/** Add a checksum filed to a proto_tree.
+ This standardizes the display of a checksum field as well as any
+ status and expert info supporting it.
+ @param tree the tree to append this item to
+ @param tvb the tv buffer of the current data
+ @param offset start of data in tvb
+ @param hf_checksum checksum field index
+ @param hf_checksum_status optional checksum status field index. If none
+ exists, just pass -1
+ @param bad_checksum_expert optional expert info for a bad checksum. If
+ none exists, just pass NULL
+ @pinfo Packet info used for optional expert info. If unused, NULL can
+ be passed
+ @param computed_checksum Checksum to verify against
+ @param encoding data encoding of checksum from tvb
+ @param flags bitmask field of PROTO_CHECKSUM_ options
+ @return the newly created item */
+WS_DLL_PUBLIC proto_item *
+proto_tree_add_checksum(proto_tree *tree, tvbuff_t *tvb, const guint offset,
+ const int hf_checksum, const int hf_checksum_status, struct expert_field* bad_checksum_expert,
+ packet_info *pinfo, guint32 computed_checksum, const guint encoding, const guint flags);
+
+typedef enum
+{
+ PROTO_CHECKSUM_E_BAD = 0,
+ PROTO_CHECKSUM_E_GOOD,
+ PROTO_CHECKSUM_E_UNVERIFIED,
+ PROTO_CHECKSUM_E_NOT_PRESENT
+
+} proto_checksum_enum_e;
+
+#define PROTO_CHECKSUM_NO_FLAGS 0x00 /**< Don't use any flags */
+#define PROTO_CHECKSUM_VERIFY 0x01 /**< Compare against computed checksum */
+#define PROTO_CHECKSUM_GENERATED 0x02 /**< Checksum is generated only */
+#define PROTO_CHECKSUM_IN_CKSUM 0x04 /**< Internet checksum routine used for computation */
+#define PROTO_CHECKSUM_ZERO 0x08 /**< Computed checksum must be zero (but correct checksum can't be calculated) */
+#define PROTO_CHECKSUM_NOT_PRESENT 0x10 /**< Checksum field is not present (Just populates status field) */
+
+WS_DLL_PUBLIC const value_string proto_checksum_vals[];
+
+
/** Check if given string is a valid field name
@param field_name the field name to check
@return 0 if valid, else first illegal character */
diff --git a/plugins/irda/packet-sir.c b/plugins/irda/packet-sir.c
index 98ee323390..11188a47bf 100644
--- a/plugins/irda/packet-sir.c
+++ b/plugins/irda/packet-sir.c
@@ -56,10 +56,20 @@ static int hf_sir_bof = -1;
/* static int hf_sir_ce = -1; */
static int hf_sir_eof = -1;
static int hf_sir_fcs = -1;
-static int hf_sir_fcs_bad = -1;
+static int hf_sir_fcs_status = -1;
static int hf_sir_length = -1;
static int hf_sir_preamble = -1;
+/* Copied and renamed from proto.c because global value_strings don't work for plugins */
+static const value_string plugin_proto_checksum_vals[] = {
+ { PROTO_CHECKSUM_E_BAD, "Bad" },
+ { PROTO_CHECKSUM_E_GOOD, "Good" },
+ { PROTO_CHECKSUM_E_UNVERIFIED, "Unverified" },
+ { PROTO_CHECKSUM_E_NOT_PRESENT, "Not present" },
+
+ { 0, NULL }
+};
+
/** Unescapes the data. */
static tvbuff_t *
@@ -94,29 +104,13 @@ unescape_data(tvbuff_t *tvb, packet_info *pinfo)
static tvbuff_t *
checksum_data(tvbuff_t *tvb, proto_tree *tree)
{
- proto_item *hidden_item;
int len = tvb_reported_length(tvb) - 2;
if (len < 0)
return tvb;
- if (tree) {
- guint16 actual_fcs = tvb_get_letohs(tvb, len);
- guint16 calculated_fcs = crc16_ccitt_tvb(tvb, len);
- if (calculated_fcs == actual_fcs) {
- proto_tree_add_uint_format(tree, hf_sir_fcs,
- tvb, len, 2, actual_fcs,
- "Frame check sequence: 0x%04x (correct)",
- actual_fcs);
- } else {
- hidden_item = proto_tree_add_boolean(tree,
- hf_sir_fcs_bad, tvb, len, 2, TRUE);
- PROTO_ITEM_SET_HIDDEN(hidden_item);
- proto_tree_add_uint_format(tree, hf_sir_fcs,
- tvb, len, 2, actual_fcs,
- "Frame check sequence: 0x%04x "
- "(incorrect, should be 0x%04x)",
- actual_fcs, calculated_fcs);
- }
- }
+
+ proto_tree_add_checksum(tree, tvb, len, hf_sir_fcs, hf_sir_fcs_status, NULL, NULL, crc16_ccitt_tvb(tvb, len),
+ ENC_LITTLE_ENDIAN, PROTO_CHECKSUM_VERIFY);
+
return tvb_new_subset_length(tvb, 0, len);
}
@@ -209,9 +203,9 @@ proto_register_irsir(void)
{ "Frame check sequence", "sir.fcs",
FT_UINT16, BASE_HEX, NULL, 0,
NULL, HFILL }},
- { &hf_sir_fcs_bad,
- { "Bad frame check sequence", "sir.fcs_bad",
- FT_BOOLEAN, BASE_NONE, NULL, 0x0,
+ { &hf_sir_fcs_status,
+ { "Frame check sequence Status", "sir.fcs.status",
+ FT_UINT8, BASE_NONE, VALS(plugin_proto_checksum_vals), 0x0,
NULL, HFILL }},
{ &hf_sir_length,
{ "Length", "sir.length",
diff --git a/plugins/profinet/packet-pn-rt.c b/plugins/profinet/packet-pn-rt.c
index 8757a1a9ff..885cd9fc68 100644
--- a/plugins/profinet/packet-pn-rt.c
+++ b/plugins/profinet/packet-pn-rt.c
@@ -58,8 +58,7 @@ static int hf_pn_rt_data_status_redundancy = -1;
static int hf_pn_rt_data_status_primary = -1;
static int hf_pn_rt_sf_crc16 = -1;
-static int hf_pn_rt_sf_crc16_ok = -1;
-static int hf_pn_rt_sf_crc16_null = -1;
+static int hf_pn_rt_sf_crc16_status = -1;
static int hf_pn_rt_sf = -1;
static int hf_pn_rt_sf_position = -1;
/* static int hf_pn_rt_sf_position_control = -1; */
@@ -124,6 +123,16 @@ static const value_string pn_rt_frag_status_more_follows[] = {
{ 0, NULL }
};
+/* Copied and renamed from proto.c because global value_strings don't work for plugins */
+static const value_string plugin_proto_checksum_vals[] = {
+ { PROTO_CHECKSUM_E_BAD, "Bad" },
+ { PROTO_CHECKSUM_E_GOOD, "Good" },
+ { PROTO_CHECKSUM_E_UNVERIFIED, "Unverified" },
+ { PROTO_CHECKSUM_E_NOT_PRESENT, "Not present" },
+
+ { 0, NULL }
+};
+
static void
dissect_DataStatus(tvbuff_t *tvb, int offset, proto_tree *tree, guint8 u8DataStatus)
{
@@ -246,7 +255,6 @@ dissect_CSF_SDU_heur(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *
guint32 u32SubStart;
proto_item *sub_item;
proto_tree *sub_tree;
- proto_item *item;
guint16 crc;
@@ -256,10 +264,16 @@ dissect_CSF_SDU_heur(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *
if (IsDFP_Frame(tvb, pinfo, tree, u16FrameID)) {
/* can't check this CRC, as the checked data bytes are not available */
u16SFCRC16 = tvb_get_letohs(tvb, offset);
- if (u16SFCRC16 != 0)
- proto_tree_add_uint(tree, hf_pn_rt_sf_crc16_ok, tvb, offset, 2, u16SFCRC16);
- else
- proto_tree_add_uint(tree, hf_pn_rt_sf_crc16_null, tvb, offset, 2, u16SFCRC16);
+ if (u16SFCRC16 != 0) {
+ /* Checksum verify will always succeed */
+ /* XXX - should we combine the two calls to always show "unverified"? */
+ proto_tree_add_checksum(tree, tvb, offset, hf_pn_rt_sf_crc16, hf_pn_rt_sf_crc16_status, &ei_pn_rt_sf_crc16, pinfo, u16SFCRC16,
+ ENC_LITTLE_ENDIAN, PROTO_CHECKSUM_VERIFY);
+ }
+ else {
+ proto_tree_add_checksum(tree, tvb, offset, hf_pn_rt_sf_crc16, hf_pn_rt_sf_crc16_status, &ei_pn_rt_sf_crc16, pinfo, 0,
+ ENC_LITTLE_ENDIAN, PROTO_CHECKSUM_NO_FLAGS);
+ }
offset += 2;
while (1) {
@@ -292,18 +306,14 @@ dissect_CSF_SDU_heur(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *
offset = dissect_pn_user_data(tvb, offset, pinfo, sub_tree, u8SFDataLength, "DataItem");
u16SFCRC16 = tvb_get_letohs(tvb, offset);
- item = proto_tree_add_uint(sub_tree, hf_pn_rt_sf_crc16, tvb, offset, 2, u16SFCRC16);
if (u16SFCRC16 != 0 /* "old check": u8SFPosition & 0x80 */) {
crc = crc16_plain_tvb_offset_seed(tvb, u32SubStart, offset-u32SubStart, 0);
- if (crc != u16SFCRC16) {
- proto_item_append_text(item, " [Preliminary check: incorrect, should be: %u]", crc);
- expert_add_info(pinfo, item, &ei_pn_rt_sf_crc16);
- } else {
- proto_item_append_text(item, " [Preliminary check: Correct]");
- }
+ proto_tree_add_checksum(tree, tvb, offset, hf_pn_rt_sf_crc16, hf_pn_rt_sf_crc16_status, &ei_pn_rt_sf_crc16, pinfo, crc,
+ ENC_LITTLE_ENDIAN, PROTO_CHECKSUM_VERIFY);
} else {
- proto_item_append_text(item, " [No check, supplied CRC == zero]");
+ proto_tree_add_checksum(tree, tvb, offset, hf_pn_rt_sf_crc16, hf_pn_rt_sf_crc16_status, &ei_pn_rt_sf_crc16, pinfo, 0,
+ ENC_LITTLE_ENDIAN, PROTO_CHECKSUM_NO_FLAGS);
}
offset += 2;
@@ -872,14 +882,9 @@ proto_register_pn_rt(void)
FT_UINT16, BASE_HEX, NULL, 0x0,
NULL, HFILL }},
- { &hf_pn_rt_sf_crc16_ok,
- { "SFCRC16 checked [ok]", "pn_rt.sf.crc16_ok",
- FT_UINT16, BASE_HEX, NULL, 0x0,
- NULL, HFILL }},
-
- { &hf_pn_rt_sf_crc16_null,
- { "SFCRC16 not checked but ok", "pn_rt.sf.crc16_null",
- FT_UINT16, BASE_HEX, NULL, 0x0,
+ { &hf_pn_rt_sf_crc16_status,
+ { "SFCRC16 status", "pn_rt.sf.crc16.status",
+ FT_UINT8, BASE_NONE, VALS(plugin_proto_checksum_vals), 0x0,
NULL, HFILL }},
{ &hf_pn_rt_sf_position,
diff --git a/plugins/wimax/mac_hd_generic_decoder.c b/plugins/wimax/mac_hd_generic_decoder.c
index b5fc149827..ad47a3915f 100644
--- a/plugins/wimax/mac_hd_generic_decoder.c
+++ b/plugins/wimax/mac_hd_generic_decoder.c
@@ -1218,16 +1218,12 @@ check_crc:
proto_item_append_text(parent_item, ", CRC");
/* check the length */
if (MIN(tvb_len, tvb_reported_length(tvb)) >= mac_len)
- { /* get the CRC */
- mac_crc = tvb_get_ntohl(tvb, mac_len - (int)sizeof(mac_crc));
- /* calculate the CRC */
+ {
+ /* calculate the CRC */
calculated_crc = wimax_mac_calc_crc32(tvb_get_ptr(tvb, 0, mac_len - (int)sizeof(mac_crc)), mac_len - (int)sizeof(mac_crc));
/* display the CRC */
- generic_item = proto_tree_add_item(tree, hf_mac_header_generic_crc, tvb, mac_len - (int)sizeof(mac_crc), (int)sizeof(mac_crc), ENC_BIG_ENDIAN);
- if (mac_crc != calculated_crc)
- {
- proto_item_append_text(generic_item, " - incorrect! (should be: 0x%x)", calculated_crc);
- }
+ proto_tree_add_checksum(tree, tvb, mac_len - (int)sizeof(mac_crc), hf_mac_header_generic_crc, -1, NULL, pinfo, calculated_crc,
+ ENC_BIG_ENDIAN, PROTO_CHECKSUM_VERIFY);
}
else
{ /* display error message */
diff --git a/plugins/wimax/msg_dlmap.c b/plugins/wimax/msg_dlmap.c
index 8a3ae02371..6f022cbdf4 100644
--- a/plugins/wimax/msg_dlmap.c
+++ b/plugins/wimax/msg_dlmap.c
@@ -822,9 +822,7 @@ static gint DL_HARQ_IR_CTC_sub_burst_IE(proto_tree *diuc_tree, gint offset, gint
{
/* offset of IE in nibbles, length is variable */
gint bit;
- guint data;
proto_tree *tree;
- proto_item *generic_item = NULL;
gint nsub, ddci, dur;
gint j;
guint32 calculated_crc;
@@ -867,14 +865,9 @@ static gint DL_HARQ_IR_CTC_sub_burst_IE(proto_tree *diuc_tree, gint offset, gint
if (include_cor2_changes)
{
/* CRC-16 is always appended */
- data = TVB_BIT_BITS(bit, tvb, 16);
- generic_item = proto_tree_add_uint(tree, hf_crc16, tvb, BITHI(bit,16), data);
- /* calculate the CRC */
calculated_crc = wimax_mac_calc_crc16(tvb_get_ptr(tvb, 0, BIT_TO_BYTE(bit)), BIT_TO_BYTE(bit));
- if (data != calculated_crc)
- {
- proto_item_append_text(generic_item, " - incorrect! (should be: 0x%x)", calculated_crc);
- }
+ proto_tree_add_checksum(tree, tvb, BIT_ADDR(bit), hf_crc16, -1, NULL, NULL, calculated_crc,
+ ENC_BIG_ENDIAN, PROTO_CHECKSUM_VERIFY);
bit += 16;
}
@@ -885,9 +878,7 @@ static gint DL_HARQ_IR_CC_sub_burst_IE(proto_tree *diuc_tree, gint offset, gint
{
/* offset of IE in nibbles, length is variable */
gint bit;
- gint data;
proto_tree *tree;
- proto_item *generic_item = NULL;
gint nsub, sbdi, ddci, dur;
gint j;
guint16 calculated_crc;
@@ -938,14 +929,9 @@ static gint DL_HARQ_IR_CC_sub_burst_IE(proto_tree *diuc_tree, gint offset, gint
if (include_cor2_changes)
{
/* CRC-16 is always appended */
- data = TVB_BIT_BITS(bit, tvb, 16);
- generic_item = proto_tree_add_uint(tree, hf_crc16, tvb, BITHI(bit,16), data);
- /* calculate the CRC */
calculated_crc = wimax_mac_calc_crc16(tvb_get_ptr(tvb, 0, BIT_TO_BYTE(bit)), BIT_TO_BYTE(bit));
- if (data != calculated_crc)
- {
- proto_item_append_text(generic_item, " - incorrect! (should be: 0x%x)", calculated_crc);
- }
+ proto_tree_add_checksum(tree, tvb, BIT_ADDR(bit), hf_crc16, -1, NULL, NULL, calculated_crc,
+ ENC_BIG_ENDIAN, PROTO_CHECKSUM_VERIFY);
bit += 16;
}
@@ -958,7 +944,6 @@ static gint MIMO_DL_Chase_HARQ_sub_burst_IE(proto_tree *diuc_tree, gint offset,
gint bit;
gint data;
proto_tree *tree;
- proto_item *generic_item = NULL;
gint nsub, mui, dci, akd;
gint i, j;
guint16 calculated_crc;
@@ -1005,14 +990,9 @@ static gint MIMO_DL_Chase_HARQ_sub_burst_IE(proto_tree *diuc_tree, gint offset,
if (include_cor2_changes)
{
/* CRC-16 is always appended */
- data = TVB_BIT_BITS(bit, tvb, 16);
- generic_item = proto_tree_add_uint(tree, hf_crc16, tvb, BITHI(bit,16), data);
- /* calculate the CRC */
calculated_crc = wimax_mac_calc_crc16(tvb_get_ptr(tvb, 0, BIT_TO_BYTE(bit)), BIT_TO_BYTE(bit));
- if (data != calculated_crc)
- {
- proto_item_append_text(generic_item, " - incorrect! (should be: 0x%x)", calculated_crc);
- }
+ proto_tree_add_checksum(tree, tvb, BIT_ADDR(bit), hf_crc16, -1, NULL, NULL, calculated_crc,
+ ENC_BIG_ENDIAN, PROTO_CHECKSUM_VERIFY);
bit += 16;
}
@@ -1023,9 +1003,7 @@ static gint MIMO_DL_IR_HARQ_sub_burst_IE(proto_tree *diuc_tree, gint offset, gin
{
/* offset of IE in nibbles, length is variable */
gint bit;
- gint data;
proto_tree *tree;
- proto_item *generic_item = NULL;
gint nsub, mui, dci, akd;
gint i, j;
guint16 calculated_crc;
@@ -1066,14 +1044,9 @@ static gint MIMO_DL_IR_HARQ_sub_burst_IE(proto_tree *diuc_tree, gint offset, gin
if (include_cor2_changes)
{
/* CRC-16 is always appended */
- data = TVB_BIT_BITS(bit, tvb, 16);
- generic_item = proto_tree_add_uint(tree, hf_crc16, tvb, BITHI(bit,16), data);
- /* calculate the CRC */
calculated_crc = wimax_mac_calc_crc16(tvb_get_ptr(tvb, 0, BIT_TO_BYTE(bit)), BIT_TO_BYTE(bit));
- if (data != calculated_crc)
- {
- proto_item_append_text(generic_item, " - incorrect! (should be: 0x%x)", calculated_crc);
- }
+ proto_tree_add_checksum(tree, tvb, BIT_ADDR(bit), hf_crc16, -1, NULL, NULL, calculated_crc,
+ ENC_BIG_ENDIAN, PROTO_CHECKSUM_VERIFY);
bit += 16;
}
@@ -1084,9 +1057,7 @@ static gint MIMO_DL_IR_HARQ_for_CC_sub_burst_IE(proto_tree *diuc_tree, gint offs
{
/* offset of IE in nibbles, length is variable */
gint bit;
- gint data;
proto_tree *tree;
- proto_item *generic_item = NULL;
gint nsub, mui, dci, akd;
gint i, j;
guint16 calculated_crc;
@@ -1128,14 +1099,9 @@ static gint MIMO_DL_IR_HARQ_for_CC_sub_burst_IE(proto_tree *diuc_tree, gint offs
if (include_cor2_changes)
{
/* CRC-16 is always appended */
- data = TVB_BIT_BITS(bit, tvb, 16);
- generic_item = proto_tree_add_uint(tree, hf_crc16, tvb, BITHI(bit,16), data);
- /* calculate the CRC */
calculated_crc = wimax_mac_calc_crc16(tvb_get_ptr(tvb, 0, BIT_TO_BYTE(bit)), BIT_TO_BYTE(bit));
- if (data != calculated_crc)
- {
- proto_item_append_text(generic_item, " - incorrect! (should be: 0x%x)", calculated_crc);
- }
+ proto_tree_add_checksum(tree, tvb, BIT_ADDR(bit), hf_crc16, -1, NULL, NULL, calculated_crc,
+ ENC_BIG_ENDIAN, PROTO_CHECKSUM_VERIFY);
bit += 16;
}
@@ -1146,9 +1112,7 @@ static gint MIMO_DL_STC_HARQ_sub_burst_IE(proto_tree *diuc_tree, gint offset, gi
{
/* offset of IE in nibbles, length is variable */
gint bit;
- gint data;
proto_tree *tree;
- proto_item *generic_item = NULL;
gint nsub, sbi, txc, akd, dmci;
gint j;
guint16 calculated_crc;
@@ -1188,14 +1152,9 @@ static gint MIMO_DL_STC_HARQ_sub_burst_IE(proto_tree *diuc_tree, gint offset, gi
if (include_cor2_changes)
{
/* CRC-16 is always appended */
- data = TVB_BIT_BITS(bit, tvb, 16);
- generic_item = proto_tree_add_uint(tree, hf_crc16, tvb, BITHI(bit,16), data);
- /* calculate the CRC */
calculated_crc = wimax_mac_calc_crc16(tvb_get_ptr(tvb, 0, BIT_TO_BYTE(bit)), BIT_TO_BYTE(bit));
- if (data != calculated_crc)
- {
- proto_item_append_text(generic_item, " - incorrect! (should be: 0x%x)", calculated_crc);
- }
+ proto_tree_add_checksum(tree, tvb, BIT_ADDR(bit), hf_crc16, -1, NULL, NULL, calculated_crc,
+ ENC_BIG_ENDIAN, PROTO_CHECKSUM_VERIFY);
bit += 16;
}
@@ -2341,7 +2300,6 @@ gint wimax_decode_dlmapc(tvbuff_t *tvb, packet_info *pinfo, proto_tree *base_tre
proto_item *ti = NULL;
proto_item *ti_phy = NULL;
proto_item *ti_dlmap_ies = NULL;
- proto_item *generic_item = NULL;
proto_tree *tree = NULL;
proto_tree *ie_tree = NULL;
proto_tree *phy_tree = NULL;
@@ -2424,16 +2382,11 @@ gint wimax_decode_dlmapc(tvbuff_t *tvb, packet_info *pinfo, proto_tree *base_tre
/* CRC is always appended */
/* check the length */
if (MIN(tvb_len, tvb_reported_length(tvb)) >= mac_len)
- { /* get the CRC */
- mac_crc = tvb_get_ntohl(tvb, mac_len - (int)sizeof(mac_crc));
+ {
/* calculate the CRC */
calculated_crc = wimax_mac_calc_crc32(tvb_get_ptr(tvb, 0, mac_len - (int)sizeof(mac_crc)), mac_len - (int)sizeof(mac_crc));
- /* display the CRC */
- generic_item = proto_tree_add_item(base_tree, hf_mac_header_compress_dlmap_crc, tvb, mac_len - (int)sizeof(mac_crc), (int)sizeof(mac_crc), ENC_BIG_ENDIAN);
- if (mac_crc != calculated_crc)
- {
- proto_item_append_text(generic_item, " - incorrect! (should be: 0x%x)", calculated_crc);
- }
+ proto_tree_add_checksum(base_tree, tvb, mac_len - (int)sizeof(mac_crc), hf_mac_header_compress_dlmap_crc, -1, NULL, pinfo, calculated_crc,
+ ENC_BIG_ENDIAN, PROTO_CHECKSUM_VERIFY);
}
else
{ /* display error message */
@@ -2510,14 +2463,9 @@ static gint wimax_decode_sub_dl_ul_map(tvbuff_t *tvb, packet_info *pinfo, proto_
}
/* CRC-16 is always appended */
- data = TVB_NIB_WORD(nib, tvb);
- generic_item = proto_tree_add_uint(tree, hf_crc16, tvb, NIBHI(nib,4), data);
- /* calculate the CRC */
calculated_crc = wimax_mac_calc_crc16(tvb_get_ptr(tvb, 0, NIB_TO_BYTE(nib)), NIB_TO_BYTE(nib));
- if (data != calculated_crc)
- {
- proto_item_append_text(generic_item, " - incorrect! (should be: 0x%x)", calculated_crc);
- }
+ proto_tree_add_checksum(tree, tvb, NIBHI(nib,4), hf_crc16, -1, NULL, pinfo, calculated_crc,
+ ENC_BIG_ENDIAN, PROTO_CHECKSUM_VERIFY);
/* nib += 4; */
sub_dl_ul_map = 0; /* clear flag */
@@ -2533,7 +2481,6 @@ gint wimax_decode_dlmap_reduced_aas(tvbuff_t *tvb, packet_info *pinfo _U_, proto
guint offset = 0;
proto_item *ti = NULL;
proto_tree *tree = NULL;
- proto_item *generic_item = NULL;
gint ulmap_appended;
gint length;
gint tvb_len = tvb_reported_length(tvb);
@@ -2636,14 +2583,9 @@ gint wimax_decode_dlmap_reduced_aas(tvbuff_t *tvb, packet_info *pinfo _U_, proto
}
/* CRC-16 is always appended */
- data = TVB_BIT_BITS(bit, tvb, 16);
- generic_item = proto_tree_add_uint(tree, hf_crc16, tvb, BITHI(bit,16), data);
- /* calculate the CRC */
calculated_crc = wimax_mac_calc_crc16(tvb_get_ptr(tvb, 0, BIT_TO_BYTE(bit)), BIT_TO_BYTE(bit));
- if (data != calculated_crc)
- {
- proto_item_append_text(generic_item, " - incorrect! (should be: 0x%x)", calculated_crc);
- }
+ proto_tree_add_checksum(tree, tvb, BIT_ADDR(bit), hf_crc16, -1, NULL, pinfo, calculated_crc,
+ ENC_BIG_ENDIAN, PROTO_CHECKSUM_VERIFY);
bit += 16;
return BIT_TO_BYTE(bit) - offset;
diff --git a/plugins/wimax/msg_ulmap.c b/plugins/wimax/msg_ulmap.c
index afce354898..dd19011bd8 100644
--- a/plugins/wimax/msg_ulmap.c
+++ b/plugins/wimax/msg_ulmap.c
@@ -634,16 +634,10 @@ static gint UL_HARQ_Chase_Sub_Burst_IE(proto_tree *uiuc_tree, gint offset, gint
#if 0
if (include_cor2_changes)
{
- /* CRC-16 is always appended */
- data = TVB_BIT_BITS(bit, tvb, 16);
- generic_item = proto_tree_add_uint(tree, hf_ulmap_crc16, tvb, BITHI(bit,16), data);
- /* calculate the CRC */
- calculated_crc = wimax_mac_calc_crc16((guint8 *)tvb_get_ptr(tvb, 0, BIT_TO_BYTE(bit)), BIT_TO_BYTE(bit));
- if (data != calculated_crc)
- {
- proto_item_append_text(generic_item, " - incorrect! (should be: 0x%x)", calculated_crc);
- }
- bit += 16;
+ calculated_crc = wimax_mac_calc_crc16((guint8 *)tvb_get_ptr(tvb, 0, BIT_TO_BYTE(bit)), BIT_TO_BYTE(bit));
+ proto_tree_add_checksum(tree, tvb, BITHI(bit,16), hf_ulmap_crc16, -1, NULL, pinfo, calculated_crc,
+ ENC_BIG_ENDIAN, PROTO_CHECKSUM_VERIFY);
+ bit += 16;
}
#endif
@@ -680,16 +674,11 @@ static gint UL_HARQ_IR_CTC_Sub_Burst_IE(proto_tree *uiuc_tree, gint offset, gint
#if 0
if (include_cor2_changes)
{
- /* CRC-16 is always appended */
- data = TVB_BIT_BITS(bit, tvb, 16);
- generic_item = proto_tree_add_uint(tree, hf_ulmap_crc16, tvb, BITHI(bit,16), data);
- /* calculate the CRC */
- calculated_crc = wimax_mac_calc_crc16((guint8 *)tvb_get_ptr(tvb, 0, BIT_TO_BYTE(bit)), BIT_TO_BYTE(bit));
- if (data != calculated_crc)
- {
- proto_item_append_text(generic_item, " - incorrect! (should be: 0x%x)", calculated_crc);
- }
- bit += 16;
+ /* CRC-16 is always appended */
+ calculated_crc = wimax_mac_calc_crc16((guint8 *)tvb_get_ptr(tvb, 0, BIT_TO_BYTE(bit)), BIT_TO_BYTE(bit));
+ proto_tree_add_checksum(tree, tvb, BITHI(bit,16), hf_ulmap_crc16, -1, NULL, pinfo, calculated_crc,
+ ENC_BIG_ENDIAN, PROTO_CHECKSUM_VERIFY);
+ bit += 16;
}
#endif
@@ -727,16 +716,12 @@ static gint UL_HARQ_IR_CC_Sub_Burst_IE(proto_tree *uiuc_tree, gint offset, gint
#if 0
if (include_cor2_changes)
{
- /* CRC-16 is always appended */
- data = TVB_BIT_BITS(bit, tvb, 16);
- generic_item = proto_tree_add_uint(tree, hf_ulmap_crc16, tvb, BITHI(bit,16), data);
- /* calculate the CRC */
- calculated_crc = wimax_mac_calc_crc16((guint8 *)tvb_get_ptr(tvb, 0, BIT_TO_BYTE(bit)), BIT_TO_BYTE(bit));
- if (data != calculated_crc)
- {
- proto_item_append_text(generic_item, " - incorrect! (should be: 0x%x)", calculated_crc);
- }
- bit += 16;
+ /* CRC-16 is always appended */
+ calculated_crc = wimax_mac_calc_crc16((guint8 *)tvb_get_ptr(tvb, 0, BIT_TO_BYTE(bit)), BIT_TO_BYTE(bit));
+ proto_tree_add_checksum(tree, tvb, BITHI(bit,16), hf_ulmap_crc16, -1, NULL, pinfo, calculated_crc,
+ ENC_BIG_ENDIAN, PROTO_CHECKSUM_VERIFY);
+
+ bit += 16;
}
#endif
@@ -784,16 +769,12 @@ static gint MIMO_UL_Chase_HARQ_Sub_Burst_IE(proto_tree *uiuc_tree, gint offset,
#if 0
if (include_cor2_changes)
{
- /* CRC-16 is always appended */
- data = TVB_BIT_BITS(bit, tvb, 16);
- generic_item = proto_tree_add_uint(tree, hf_ulmap_crc16, tvb, BITHI(bit,16), data);
- /* calculate the CRC */
- calculated_crc = wimax_mac_calc_crc16((guint8 *)tvb_get_ptr(tvb, 0, BIT_TO_BYTE(bit)), BIT_TO_BYTE(bit));
- if (data != calculated_crc)
- {
- proto_item_append_text(generic_item, " - incorrect! (should be: 0x%x)", calculated_crc);
- }
- bit += 16;
+ /* CRC-16 is always appended */
+ calculated_crc = wimax_mac_calc_crc16((guint8 *)tvb_get_ptr(tvb, 0, BIT_TO_BYTE(bit)), BIT_TO_BYTE(bit));
+ proto_tree_add_checksum(tree, tvb, BITHI(bit,16), hf_ulmap_crc16, -1, NULL, pinfo, calculated_crc,
+ ENC_BIG_ENDIAN, PROTO_CHECKSUM_VERIFY);
+
+ bit += 16;
}
#endif
@@ -841,16 +822,12 @@ static gint MIMO_UL_IR_HARQ__Sub_Burst_IE(proto_tree *uiuc_tree, gint offset, gi
#if 0
if (include_cor2_changes)
{
- /* CRC-16 is always appended */
- data = TVB_BIT_BITS(bit, tvb, 16);
- generic_item = proto_tree_add_uint(tree, hf_ulmap_crc16, tvb, BITHI(bit,16), data);
- /* calculate the CRC */
- calculated_crc = wimax_mac_calc_crc16((guint8 *)tvb_get_ptr(tvb, 0, BIT_TO_BYTE(bit)), BIT_TO_BYTE(bit));
- if (data != calculated_crc)
- {
- proto_item_append_text(generic_item, " - incorrect! (should be: 0x%x)", calculated_crc);
- }
- bit += 16;
+ /* CRC-16 is always appended */
+ calculated_crc = wimax_mac_calc_crc16((guint8 *)tvb_get_ptr(tvb, 0, BIT_TO_BYTE(bit)), BIT_TO_BYTE(bit));
+ proto_tree_add_checksum(tree, tvb, BITHI(bit,16), hf_ulmap_crc16, -1, NULL, pinfo, calculated_crc,
+ ENC_BIG_ENDIAN, PROTO_CHECKSUM_VERIFY);
+
+ bit += 16;
}
#endif
@@ -899,16 +876,12 @@ static gint MIMO_UL_IR_HARQ_for_CC_Sub_Burst_UIE(proto_tree *uiuc_tree, gint off
#if 0
if (include_cor2_changes)
{
- /* CRC-16 is always appended */
- data = TVB_BIT_BITS(bit, tvb, 16);
- generic_item = proto_tree_add_uint(tree, hf_ulmap_crc16, tvb, BITHI(bit,16), data);
- /* calculate the CRC */
- calculated_crc = wimax_mac_calc_crc16((guint8 *)tvb_get_ptr(tvb, 0, BIT_TO_BYTE(bit)), BIT_TO_BYTE(bit));
- if (data != calculated_crc)
- {
- proto_item_append_text(generic_item, " - incorrect! (should be: 0x%x)", calculated_crc);
- }
- bit += 16;
+ /* CRC-16 is always appended */
+ calculated_crc = wimax_mac_calc_crc16((guint8 *)tvb_get_ptr(tvb, 0, BIT_TO_BYTE(bit)), BIT_TO_BYTE(bit));
+ proto_tree_add_checksum(tree, tvb, BITHI(bit,16), hf_ulmap_crc16, -1, NULL, pinfo, calculated_crc,
+ ENC_BIG_ENDIAN, PROTO_CHECKSUM_VERIFY);
+
+ bit += 16;
}
#endif
@@ -949,16 +922,12 @@ static gint MIMO_UL_STC_HARQ_Sub_Burst_IE(proto_tree *uiuc_tree, gint offset, gi
#if 0
if (include_cor2_changes)
{
- /* CRC-16 is always appended */
- data = TVB_BIT_BITS(bit, tvb, 16);
- generic_item = proto_tree_add_uint(tree, hf_ulmap_crc16, tvb, BITHI(bit,16), data);
- /* calculate the CRC */
- calculated_crc = wimax_mac_calc_crc16((guint8 *)tvb_get_ptr(tvb, 0, BIT_TO_BYTE(bit)), BIT_TO_BYTE(bit));
- if (data != calculated_crc)
- {
- proto_item_append_text(generic_item, " - incorrect! (should be: 0x%x)", calculated_crc);
- }
- bit += 16;
+ /* CRC-16 is always appended */
+ calculated_crc = wimax_mac_calc_crc16((guint8 *)tvb_get_ptr(tvb, 0, BIT_TO_BYTE(bit)), BIT_TO_BYTE(bit));
+ proto_tree_add_checksum(tree, tvb, BITHI(bit,16), hf_ulmap_crc16, -1, NULL, pinfo, calculated_crc,
+ ENC_BIG_ENDIAN, PROTO_CHECKSUM_VERIFY);
+
+ bit += 16;
}
#endif
diff --git a/plugins/wimax/wimax_harq_map_decoder.c b/plugins/wimax/wimax_harq_map_decoder.c
index dd643ff37d..0666515160 100644
--- a/plugins/wimax/wimax_harq_map_decoder.c
+++ b/plugins/wimax/wimax_harq_map_decoder.c
@@ -71,7 +71,6 @@ static int dissector_wimax_harq_map_decoder(tvbuff_t *tvb, packet_info *pinfo, p
proto_tree *harq_map_tree = NULL;
guint nibble_offset;
proto_item *parent_item = NULL;
- proto_item *it = NULL;
guint ulmap_appended;
guint32 harq_map_msg_crc, calculated_crc;
guint32 first_24bits;
@@ -150,17 +149,10 @@ static int dissector_wimax_harq_map_decoder(tvbuff_t *tvb, packet_info *pinfo, p
}
/* add the CRC info */
proto_item_append_text(parent_item, ",CRC");
- /* get the CRC */
- harq_map_msg_crc = tvb_get_ntohl(tvb, length - (int)sizeof(harq_map_msg_crc));
/* calculate the HARQ MAM Message CRC */
calculated_crc = wimax_mac_calc_crc32(tvb_get_ptr(tvb, 0, length - (int)sizeof(harq_map_msg_crc)), length - (int)sizeof(harq_map_msg_crc));
- /* display the CRC */
- it = proto_tree_add_item(harq_map_tree, hf_harq_map_msg_crc, tvb, length - (int)sizeof(harq_map_msg_crc), (int)sizeof(harq_map_msg_crc), ENC_BIG_ENDIAN);
- /* verify the CRC */
- if (harq_map_msg_crc != calculated_crc)
- {
- proto_item_append_text(it, " - incorrect! (should be: 0x%x)", calculated_crc);
- }
+ proto_tree_add_checksum(tree, tvb, length - (int)sizeof(harq_map_msg_crc), hf_harq_map_msg_crc, -1, NULL, pinfo, calculated_crc,
+ ENC_BIG_ENDIAN, PROTO_CHECKSUM_VERIFY);
}
return tvb_captured_length(tvb);
}
diff --git a/profiles/Bluetooth/colorfilters b/profiles/Bluetooth/colorfilters
index 73b03f1b1f..ad5f5a81af 100644
--- a/profiles/Bluetooth/colorfilters
+++ b/profiles/Bluetooth/colorfilters
@@ -9,7 +9,7 @@
@TCP RST@tcp.flags.reset eq 1@[42148,0,0][65535,64764,40092]
@SCTP ABORT@sctp.chunk_type eq ABORT@[42148,0,0][65535,64764,40092]
@TTL low or unexpected@( ! ip.dst == 224.0.0.0/4 && ip.ttl < 5 && !pim) || (ip.dst == 224.0.0.0/24 && ip.dst != 224.0.0.251 && ip.ttl != 1 && !(vrrp || carp))@[42148,0,0][60652,61680,60395]
-@Checksum Errors@eth.fcs_bad==1 || ip.checksum_bad==1 || tcp.checksum_bad==1 || udp.checksum_bad==1 || sctp.checksum_bad==1 || mstp.checksum_bad==1 || cdp.checksum_bad==1 || edp.checksum_bad==1 || wlan.fcs_bad==1@[4718,10030,11796][63479,34695,34695]
+@Checksum Errors@eth.fcs.status=="Bad" || ip.checksum.status=="Bad" || tcp.checksum.status=="Bad" || udp.checksum.status=="Bad" || sctp.checksum.status=="Bad" || mstp.checksum.status=="Bad" || cdp.checksum.status=="Bad" || edp.checksum.status=="Bad" || wlan.fcs.status=="Bad"@[4718,10030,11796][63479,34695,34695]
@SMB@smb || nbss || nbns || nbipx || ipxsap || netbios@[65278,65535,53456][4718,10030,11796]
@HTTP@http || tcp.port == 80@[58596,65535,51143][4718,10030,11796]
@IPX@ipx || spx@[65534,58325,58808][4718,10030,11796]
diff --git a/profiles/Classic/colorfilters b/profiles/Classic/colorfilters
index 382f5be52a..5f8db510b8 100644
--- a/profiles/Classic/colorfilters
+++ b/profiles/Classic/colorfilters
@@ -9,7 +9,7 @@
@TCP RST@tcp.flags.reset eq 1@[37008,0,0][65535,63121,32911]
@SCTP ABORT@sctp.chunk_type eq ABORT@[37008,0,0][65535,63121,32911]
@TTL low or unexpected@( ! ip.dst == 224.0.0.0/4 && ip.ttl < 5 && !pim) || (ip.dst == 224.0.0.0/24 && ip.dst != 224.0.0.251 && ip.ttl != 1 && !(vrrp || carp))@[42148,0,0][60652,61680,60395]
-@Checksum Errors@cdp.checksum_bad==1 || edp.checksum_bad==1 || ip.checksum_bad==1 || tcp.checksum_bad==1 || udp.checksum_bad==1 || sctp.checksum_bad==1 || mstp.checksum_bad==1@[0,0,0][65535,24383,24383]
+@Checksum Errors@cdp.checksum.status=="Bad" || edp.checksum.status=="Bad" || ip.checksum.status=="Bad" || tcp.checksum.status=="Bad" || udp.checksum.status=="Bad"|| sctp.checksum.status=="Bad" || mstp.checksum.status=="Bad"@[0,0,0][65535,24383,24383]
@SMB@smb || nbss || nbns || nbipx || ipxsap || netbios@[65534,64008,39339][0,0,0]
@HTTP@http || tcp.port == 80@[36107,65535,32590][0,0,0]
@IPX@ipx || spx@[65534,58325,58808][0,0,0]
diff --git a/tools/checkAPIs.pl b/tools/checkAPIs.pl
index 36a2110f2d..f78ce92baa 100755
--- a/tools/checkAPIs.pl
+++ b/tools/checkAPIs.pl
@@ -1578,7 +1578,7 @@ sub check_proto_tree_add_XXX_encoding($$)
$args =~ s/\(.*\)//sg;
if ($args =~ /,\s*ENC_/xos) {
- if (!($func =~ /proto_tree_add_(time|item|bitmask|bits_item|bits_ret_val|item_ret_int|item_ret_uint|bytes_item)/xos)
+ if (!($func =~ /proto_tree_add_(time|item|bitmask|bits_item|bits_ret_val|item_ret_int|item_ret_uint|bytes_item|checksum)/xos)
) {
print STDERR "Error: ".$filename." uses $func with ENC_*.\n";
$errorCount++;