diff options
-rw-r--r-- | epan/dissectors/packet-aruba-iap.c | 6 | ||||
-rw-r--r-- | epan/dissectors/packet-bencode.c | 153 | ||||
-rw-r--r-- | epan/dissectors/packet-hdmi.c | 21 | ||||
-rw-r--r-- | epan/dissectors/packet-hdmi.h | 3 | ||||
-rw-r--r-- | epan/dissectors/packet-logcat.c | 6 | ||||
-rw-r--r-- | epan/dissectors/packet-pathport.c | 19 | ||||
-rw-r--r-- | epan/dissectors/packet-vp8.c | 89 |
7 files changed, 154 insertions, 143 deletions
diff --git a/epan/dissectors/packet-aruba-iap.c b/epan/dissectors/packet-aruba-iap.c index ecc62b4e12..c5b877101b 100644 --- a/epan/dissectors/packet-aruba-iap.c +++ b/epan/dissectors/packet-aruba-iap.c @@ -68,7 +68,7 @@ dissect_aruba_iap(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* dat col_set_str(pinfo->cinfo, COL_PROTOCOL, "IAP"); col_clear(pinfo->cinfo, COL_INFO); - ti = proto_tree_add_item(tree, proto_aruba_iap, tvb, 0, 0, ENC_NA); + ti = proto_tree_add_item(tree, proto_aruba_iap, tvb, 0, -1, ENC_NA); aruba_iap_tree = proto_item_add_subtree(ti, ett_aruba_iap); proto_tree_add_item(aruba_iap_tree, hf_iap_magic, tvb, offset, 2, ENC_BIG_ENDIAN); @@ -94,9 +94,7 @@ dissect_aruba_iap(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* dat offset += 4; proto_tree_add_item(aruba_iap_tree, hf_iap_unknown_bytes, tvb, offset, -1, ENC_NA); - offset += tvb_reported_length(tvb); - - return offset; + return tvb_reported_length(tvb); } void diff --git a/epan/dissectors/packet-bencode.c b/epan/dissectors/packet-bencode.c index 7ce5855951..e85bb6dd31 100644 --- a/epan/dissectors/packet-bencode.c +++ b/epan/dissectors/packet-bencode.c @@ -26,8 +26,6 @@ #include "config.h" #include <glib.h> -#include <epan/prefs.h> -#include <epan/conversation.h> #include <epan/packet.h> #include <epan/expert.h> #include <epan/strutil.h> @@ -36,25 +34,25 @@ void proto_register_bencode(void); static int proto_bencode = -1; -static gint hf_bencode_str_length = -1; -static gint hf_bencode_str = -1; -static gint hf_bencode_int = -1; -static gint hf_bencode_dict = -1; -static gint hf_bencode_dict_entry = -1; -static gint hf_bencode_list = -1; +static gint hf_bencode_str_length = -1; +static gint hf_bencode_str = -1; +static gint hf_bencode_int = -1; +static gint hf_bencode_dict = -1; +static gint hf_bencode_dict_entry = -1; +static gint hf_bencode_list = -1; static gint hf_bencode_truncated_data = -1; static gint ett_bencode_dict = -1; static gint ett_bencode_dict_entry = -1; static gint ett_bencode_list = -1; -static expert_field ei_bencode_str = EI_INIT; +static expert_field ei_bencode_str = EI_INIT; static expert_field ei_bencode_str_length = EI_INIT; -static expert_field ei_bencode_int = EI_INIT; -static expert_field ei_bencode_nest = EI_INIT; -static expert_field ei_bencode_dict_key = EI_INIT; +static expert_field ei_bencode_int = EI_INIT; +static expert_field ei_bencode_nest = EI_INIT; +static expert_field ei_bencode_dict_key = EI_INIT; static expert_field ei_bencode_dict_value = EI_INIT; -static expert_field ei_bencode_invalid = EI_INIT; +static expert_field ei_bencode_invalid = EI_INIT; static int dissect_bencoding_str(tvbuff_t *tvb, packet_info *pinfo, int offset, int length, proto_tree *tree, proto_item *ti, int treeadd) @@ -64,44 +62,48 @@ static int dissect_bencoding_str(tvbuff_t *tvb, packet_info *pinfo, int used; int izero = 0; - if (length<2) { + if (length < 2) { proto_tree_add_expert(tree, pinfo, &ei_bencode_str, tvb, offset, length); return -1; } used = 0; - while (length>=1) { - ch = tvb_get_guint8(tvb, offset+used); + while (length >= 1) { + ch = tvb_get_guint8(tvb, offset + used); length--; used++; - if (ch==':' && used>1) { - if (stringlen>length || stringlen<0) { + if ((ch == ':') && (used > 1)) { + if ((stringlen > length) || (stringlen < 0)) { proto_tree_add_expert(tree, pinfo, &ei_bencode_str_length, tvb, offset, length); return -1; } if (tree) { proto_tree_add_uint(tree, hf_bencode_str_length, tvb, offset, used, stringlen); - proto_tree_add_item(tree, hf_bencode_str, tvb, offset+used, stringlen, ENC_ASCII|ENC_NA); + proto_tree_add_item(tree, hf_bencode_str, tvb, offset + used, stringlen, ENC_ASCII|ENC_NA); - if (treeadd==1) { - proto_item_append_text(ti, " Key: %s", format_text((guchar *)tvb_memdup(wmem_packet_scope(), tvb, offset+used, stringlen), stringlen)); + if (treeadd == 1) { + proto_item_append_text(ti, " Key: %s", + format_text((guchar *)tvb_memdup(wmem_packet_scope(), + tvb, offset + used, stringlen), stringlen)); } - if (treeadd==2) { - proto_item_append_text(ti, " Value: %s", format_text((guchar *)tvb_memdup(wmem_packet_scope(), tvb, offset+used, stringlen), stringlen)); + if (treeadd == 2) { + proto_item_append_text(ti, " Value: %s", + format_text((guchar *)tvb_memdup(wmem_packet_scope(), + tvb, offset + used, stringlen), stringlen)); } } - return used+stringlen; + return used + stringlen; } - if (!izero && ch>='0' && ch<='9') { - if (ch=='0' && used==1) { + if (!izero && (ch >= '0') && (ch <= '9')) { + if ((ch == '0') && (used == 1)) { izero = 1; } nextstringlen = (stringlen * 10) + (ch - '0'); - if (nextstringlen>=stringlen) { + if (nextstringlen >= stringlen) { stringlen = nextstringlen; continue; } @@ -118,10 +120,10 @@ static int dissect_bencoding_str(tvbuff_t *tvb, packet_info *pinfo, static int dissect_bencoding_int(tvbuff_t *tvb, packet_info *pinfo _U_, int offset, int length, proto_tree *tree, proto_item *ti, int treeadd) { - gint32 ival=0; - int neg = 0; - int izero = 0; - int used; + gint32 ival = 0; + int neg = 0; + int izero = 0; + int used; guint8 ch; if (length<3) { @@ -132,8 +134,8 @@ static int dissect_bencoding_int(tvbuff_t *tvb, packet_info *pinfo _U_, length--; used = 1; - while (length>=1) { - ch = tvb_get_guint8(tvb, offset+used); + while (length >= 1) { + ch = tvb_get_guint8(tvb, offset + used); length--; used++; @@ -142,26 +144,26 @@ static int dissect_bencoding_int(tvbuff_t *tvb, packet_info *pinfo _U_, if (tree) { if (neg) ival = -ival; proto_tree_add_int(tree, hf_bencode_int, tvb, offset, used, ival); - if (treeadd==2) { + if (treeadd == 2) { proto_item_append_text(ti, " Value: %d", ival); } } return used; case '-': - if (used==2) { + if (used == 2) { neg = 1; break; } /* Fall through */ default: - if (!(ch=='0' && used==3 && neg)) { /* -0 is invalid */ - if (ch=='0' && used==2) { /* as is 0[0-9]+ */ + if (!((ch == '0') && (used == 3) && neg)) { /* -0 is invalid */ + if ((ch == '0') && (used == 2)) { /* as is 0[0-9]+ */ izero = 1; break; } - if (!izero && ch>='0' && ch<='9') { + if (!izero && (ch >= '0') && (ch <= '9')) { ival = (ival * 10) + (ch - '0'); break; } @@ -186,18 +188,18 @@ static int dissect_bencoding_rec(tvbuff_t *tvb, packet_info *pinfo _U_, proto_item *ti = NULL, *td = NULL; proto_tree *itree = NULL, *dtree = NULL; - if (level>10) { + if (level > 10) { proto_tree_add_expert(tree, pinfo, &ei_bencode_nest, tvb, offset, -1); return -1; } - if (length<1) { + if (length < 1) { proto_tree_add_item(tree, hf_bencode_truncated_data, tvb, offset, -1, ENC_NA); return length; } op = tvb_get_guint8(tvb, offset); - oplen = dissect_bencoding_rec(tvb, pinfo, offset, length, NULL, level+1, NULL, 0); - if (oplen<0) + oplen = dissect_bencoding_rec(tvb, pinfo, offset, length, NULL, level + 1, NULL, 0); + if (oplen < 0) oplen = length; switch (op) { @@ -208,38 +210,38 @@ static int dissect_bencoding_rec(tvbuff_t *tvb, packet_info *pinfo _U_, used = 1; length--; - while (length>=1) { - op = tvb_get_guint8(tvb, offset+used); + while (length >= 1) { + op = tvb_get_guint8(tvb, offset + used); - if (op=='e') { - return used+1; + if (op == 'e') { + return used + 1; } - op1len = dissect_bencoding_str(tvb, pinfo, offset+used, length, NULL, NULL, 0); - if (op1len<0) { - proto_tree_add_expert(dtree, pinfo, &ei_bencode_dict_key, tvb, offset+used, -1); + op1len = dissect_bencoding_str(tvb, pinfo, offset + used, length, NULL, NULL, 0); + if (op1len < 0) { + proto_tree_add_expert(dtree, pinfo, &ei_bencode_dict_key, tvb, offset + used, -1); return op1len; } op2len = -1; - if (length-op1len>2) - op2len = dissect_bencoding_rec(tvb, pinfo, offset+used+op1len, length-op1len, NULL, level+1, NULL, 0); - if (op2len<0) { - proto_tree_add_expert(dtree, pinfo, &ei_bencode_dict_value, tvb, offset+used+op1len, -1); + if ((length - op1len) > 2) + op2len = dissect_bencoding_rec(tvb, pinfo, offset + used + op1len, length - op1len, NULL, level + 1, NULL, 0); + if (op2len < 0) { + proto_tree_add_expert(dtree, pinfo, &ei_bencode_dict_value, tvb, offset + used + op1len, -1); return op2len; } - ti = proto_tree_add_item(dtree, hf_bencode_dict_entry, tvb, offset+used, op1len+op2len, ENC_NA); + ti = proto_tree_add_item(dtree, hf_bencode_dict_entry, tvb, offset + used, op1len + op2len, ENC_NA); itree = proto_item_add_subtree(ti, ett_bencode_dict_entry); - dissect_bencoding_str(tvb, pinfo, offset+used, length, itree, ti, 1); - dissect_bencoding_rec(tvb, pinfo, offset+used+op1len, length-op1len, itree, level+1, ti, 2); + dissect_bencoding_str(tvb, pinfo, offset + used, length, itree, ti, 1); + dissect_bencoding_rec(tvb, pinfo, offset + used + op1len, length - op1len, itree, level + 1, ti, 2); - used += op1len+op2len; - length -= op1len+op2len; + used += op1len + op2len; + length -= op1len + op2len; } - proto_tree_add_item(dtree, hf_bencode_truncated_data, tvb, offset+used, -1, ENC_NA); + proto_tree_add_item(dtree, hf_bencode_truncated_data, tvb, offset + used, -1, ENC_NA); return -1; case 'l': @@ -249,28 +251,28 @@ static int dissect_bencoding_rec(tvbuff_t *tvb, packet_info *pinfo _U_, used = 1; length--; - while (length>=1) { - op = tvb_get_guint8(tvb, offset+used); + while (length >= 1) { + op = tvb_get_guint8(tvb, offset + used); - if (op=='e') { - return used+1; + if (op == 'e') { + return used + 1; } - oplen = dissect_bencoding_rec(tvb, pinfo, offset+used, length, itree, level+1, ti, 0); - if (oplen<1) return oplen; + oplen = dissect_bencoding_rec(tvb, pinfo, offset + used, length, itree, level + 1, ti, 0); + if (oplen < 1) return oplen; - used += oplen; + used += oplen; length -= oplen; } - proto_tree_add_item(itree, hf_bencode_truncated_data, tvb, offset+used, -1, ENC_NA); + proto_tree_add_item(itree, hf_bencode_truncated_data, tvb, offset + used, -1, ENC_NA); return -1; case 'i': return dissect_bencoding_int(tvb, pinfo, offset, length, tree, treei, treeadd); default: - if (op>='1' && op<='9') { + if ((op >= '1') && (op <= '9')) { return dissect_bencoding_str(tvb, pinfo, offset, length, tree, treei, treeadd); } @@ -282,7 +284,7 @@ static int dissect_bencoding_rec(tvbuff_t *tvb, packet_info *pinfo _U_, static void dissect_bencoding(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) { - dissect_bencoding_rec(tvb, pinfo, 0, tvb_length(tvb), tree, 0, NULL, 0); + dissect_bencoding_rec(tvb, pinfo, 0, tvb_reported_length(tvb), tree, 0, NULL, 0); } void @@ -337,3 +339,16 @@ proto_register_bencode(void) expert_bencode = expert_register_protocol(proto_bencode); expert_register_field_array(expert_bencode, ei, array_length(ei)); } + +/* + * Editor modelines - http://www.wireshark.org/tools/modelines.html + * + * Local variables: + * c-basic-offset: 3 + * tab-width: 8 + * indent-tabs-mode: nil + * End: + * + * vi: set shiftwidth=3 tabstop=8 expandtab: + * :indentSize=3:tabSize=8:noTabs=true: + */ diff --git a/epan/dissectors/packet-hdmi.c b/epan/dissectors/packet-hdmi.c index 9b1e21a705..d28782f0fa 100644 --- a/epan/dissectors/packet-hdmi.c +++ b/epan/dissectors/packet-hdmi.c @@ -31,8 +31,6 @@ #include <glib.h> #include <epan/packet.h> -#include <epan/expert.h> -#include <epan/wmem/wmem.h> #include "packet-hdmi.h" void proto_register_hdmi(void); @@ -66,7 +64,7 @@ static int hf_hdmi_edid_manf_year = -1; #define ADDR8_EDID_WRITE 0xA0 /* t->r */ #define ADDR8_EDID_READ 0xA1 /* r->t */ -#define HDCP_ADDR8(x) (x==ADDR8_HDCP_WRITE || x==ADDR8_HDCP_READ) +#define HDCP_ADDR8(x) (x == ADDR8_HDCP_WRITE || x == ADDR8_HDCP_READ) static const value_string hdmi_addr[] = { { ADDR8_HDCP_WRITE, "transmitter writes HDCP data for receiver" }, @@ -80,7 +78,7 @@ static const value_string hdmi_addr[] = { #define EDID_HDR_VALUE G_GUINT64_CONSTANT(0x00ffffffffffff00) /* grab 5 bits, from bit n to n+4, from a big-endian number x - map those bits to a capital letter such that A==1, B==2, ... */ + map those bits to a capital letter such that A == 1, B == 2, ... */ #define CAPITAL_LETTER(x, n) ('A'-1 + (((x) & (0x1F<<n)) >> n)) @@ -148,14 +146,14 @@ dissect_hdmi_edid(tvbuff_t *tvb, gint offset, packet_info *pinfo, proto_tree *tr week = tvb_get_guint8(tvb, offset); proto_tree_add_item(edid_tree, hf_hdmi_edid_manf_week, tvb, offset, 1, ENC_LITTLE_ENDIAN); - offset++; + offset += 1; - year_hf = week==255 ? hf_hdmi_edid_mod_year : hf_hdmi_edid_manf_year; + year_hf = week == 255 ? hf_hdmi_edid_mod_year : hf_hdmi_edid_manf_year; year = tvb_get_guint8(tvb, offset); yi = proto_tree_add_item(edid_tree, year_hf, tvb, offset, 1, ENC_LITTLE_ENDIAN); proto_item_append_text(yi, " (year %d)", 1990+year); - offset++; + offset += 1; edid_ver = tvb_get_guint8(tvb, offset); edid_rev = tvb_get_guint8(tvb, offset+1); @@ -187,8 +185,7 @@ dissect_hdmi(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_ col_set_str(pinfo->cinfo, COL_PROTOCOL, "HDMI"); col_clear(pinfo->cinfo, COL_INFO); - pi = proto_tree_add_protocol_format(tree, proto_hdmi, - tvb, 0, tvb_reported_length(tvb), "HDMI"); + pi = proto_tree_add_item(tree, proto_hdmi, tvb, 0, -1, ENC_NA); hdmi_tree = proto_item_add_subtree(pi, ett_hdmi); if (addr&0x01) { @@ -208,7 +205,7 @@ dissect_hdmi(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_ that are explicitly marked as little endian for the sake of simplicity, we use little endian everywhere */ proto_tree_add_item(hdmi_tree, hf_hdmi_addr, tvb, offset, 1, ENC_LITTLE_ENDIAN); - offset++; + offset += 1; if (HDCP_ADDR8(addr)) { tvbuff_t *hdcp_tvb; @@ -218,11 +215,11 @@ dissect_hdmi(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_ return call_dissector(hdcp_handle, hdcp_tvb, pinfo, hdmi_tree); } - if (addr==ADDR8_EDID_WRITE) { + if (addr == ADDR8_EDID_WRITE) { col_append_sep_str(pinfo->cinfo, COL_INFO, NULL, "EDID request"); proto_tree_add_item(hdmi_tree, hf_hdmi_edid_offset, tvb, offset, 1, ENC_LITTLE_ENDIAN); - offset++; + offset += 1; return offset; } diff --git a/epan/dissectors/packet-hdmi.h b/epan/dissectors/packet-hdmi.h index 7fa5fb8a5a..e4b5f608f6 100644 --- a/epan/dissectors/packet-hdmi.h +++ b/epan/dissectors/packet-hdmi.h @@ -24,9 +24,6 @@ #ifndef __PACKET_HDMI_H__ #define __PACKET_HDMI_H__ -#include <glib.h> -#include <epan/packet.h> - gboolean sub_check_hdmi(packet_info *pinfo _U_); #endif diff --git a/epan/dissectors/packet-logcat.c b/epan/dissectors/packet-logcat.c index e72c48862e..4a5141a907 100644 --- a/epan/dissectors/packet-logcat.c +++ b/epan/dissectors/packet-logcat.c @@ -77,7 +77,7 @@ static gint detect_version(tvbuff_t *tvb, gint offset) { guint16 payload_length; guint16 try_header_size; - payload_length = tvb_get_letohs(tvb, offset); + payload_length = tvb_get_letohs(tvb, offset); try_header_size = tvb_get_letohs(tvb, offset + 2); if (try_header_size == 0 || try_header_size != 24) @@ -106,6 +106,7 @@ dissect_logcat(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _ tvbuff_t *next_tvb; col_set_str(pinfo->cinfo, COL_PROTOCOL, "Logcat"); + col_clear(pinfo->cinfo, COL_INFO); mainitem = proto_tree_add_item(tree, proto_logcat, tvb, offset, -1, ENC_NA); maintree = proto_item_add_subtree(mainitem, ett_logcat); @@ -175,13 +176,12 @@ dissect_logcat(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _ next_tvb = tvb_new_subset_length(tvb, offset, string_length - 1); call_dissector(data_text_lines_handle, next_tvb, pinfo, subtree); - col_clear(pinfo->cinfo, COL_INFO); col_add_str(pinfo->cinfo, COL_INFO, log); offset += string_length; check_length += string_length; if (length != check_length) - proto_tree_add_expert(maintree, pinfo, &ei_invalid_payload_length, tvb, offset, tvb_length_remaining(tvb, offset)); + proto_tree_add_expert(maintree, pinfo, &ei_invalid_payload_length, tvb, offset, tvb_reported_length_remaining(tvb, offset)); if (have_tap_listener(exported_pdu_tap)) { exp_pdu_data_t *exp_pdu_data; diff --git a/epan/dissectors/packet-pathport.c b/epan/dissectors/packet-pathport.c index 173d6303fc..524c551e0e 100644 --- a/epan/dissectors/packet-pathport.c +++ b/epan/dissectors/packet-pathport.c @@ -455,13 +455,13 @@ dissect_data_payload(tvbuff_t *tvb, proto_item *tree, guint offset, guint len) static guint dissect_arp_reply(tvbuff_t *tvb, proto_tree *tree, guint offset, guint len) { - proto_tree_add_item(tree, hf_pp_arp_id, tvb, offset, 4, ENC_NA); + proto_tree_add_item(tree, hf_pp_arp_id, tvb, offset, 4, ENC_NA); offset += 4; - proto_tree_add_item(tree, hf_pp_arp_ip, tvb, offset, 4, ENC_NA); + proto_tree_add_item(tree, hf_pp_arp_ip, tvb, offset, 4, ENC_NA); offset += 4; - proto_tree_add_item(tree, hf_pp_arp_manuf, tvb, offset++, 1, ENC_NA); - proto_tree_add_item(tree, hf_pp_arp_class, tvb, offset++, 1, ENC_NA); - proto_tree_add_item(tree, hf_pp_arp_type, tvb, offset++, 1, ENC_NA); + proto_tree_add_item(tree, hf_pp_arp_manuf, tvb, offset++, 1, ENC_NA); + proto_tree_add_item(tree, hf_pp_arp_class, tvb, offset++, 1, ENC_NA); + proto_tree_add_item(tree, hf_pp_arp_type, tvb, offset++, 1, ENC_NA); proto_tree_add_item(tree, hf_pp_arp_numdmx, tvb, offset++, 1, ENC_NA); return len; } @@ -546,7 +546,7 @@ dissect_header(tvbuff_t *tvb, proto_tree *parent, guint offset) static gboolean packet_is_pathport(tvbuff_t *tvb) { - if(tvb_length(tvb) < PATHPORT_MIN_LENGTH) + if(tvb_captured_length(tvb) < PATHPORT_MIN_LENGTH) return FALSE; if(tvb_get_ntohs(tvb, 0) != PATHPORT_PROTO_MAGIC) @@ -583,7 +583,7 @@ static int dissect_pathport_common(tvbuff_t *tvb, packet_info *pinfo, proto_tree /* Set the info column to reflect the first PDU in the packet */ col_clear(pinfo->cinfo, COL_INFO); srcid = tvb_get_ntohl(tvb, PATHPORT_HEADER_SRCID_OFFSET); - type = tvb_get_ntohs(tvb, PATHPORT_HEADER_LENGTH); + type = tvb_get_ntohs(tvb, PATHPORT_HEADER_LENGTH); if(type == PP_ARP_REQUEST) { @@ -618,7 +618,7 @@ static int dissect_pathport_common(tvbuff_t *tvb, packet_info *pinfo, proto_tree pathport_tree = proto_item_add_subtree(ti, ett_pathport); offset = dissect_header(tvb, pathport_tree, PATHPORT_HEADER_OFFSET); - remaining_len = tvb_reported_length(tvb) - PATHPORT_HEADER_LENGTH; + remaining_len = tvb_reported_length_remaining(tvb, offset); offset = dissect_multiple_pdus(tvb, tree, offset, remaining_len); return offset; @@ -644,9 +644,6 @@ dissect_pathport_heur(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void } /* Register the protocol with Wireshark. - * - * This format is require because a script is used to build the C function that - * calls all the protocol registration. */ void proto_register_pathport(void) diff --git a/epan/dissectors/packet-vp8.c b/epan/dissectors/packet-vp8.c index 35ac6a3a50..06b91b2534 100644 --- a/epan/dissectors/packet-vp8.c +++ b/epan/dissectors/packet-vp8.c @@ -30,24 +30,25 @@ void proto_reg_handoff_vp8(void); void proto_register_vp8(void); -#define BIT_1_MASK 0x80 -#define BIT_2_MASK 0x40 -#define BIT_3_MASK 0x20 -#define BIT_4_MASK 0x10 -#define BIT_5_MASK 0x08 -#define BIT_6_MASK 0x04 -#define BIT_7_MASK 0x02 -#define BIT_8_MASK 0x01 -#define BIT_123_MASK 0xE0 -#define BIT_234_MASK 0x70 -#define BIT_5678_MASK 0x0F -#define BIT_567_MASK 0x0E -#define BIT_45678_MASK 0x1F -#define BIT_12_MASK 0xC0 -#define BIT_NO_MASK 0xFF -#define BIT_2BYTE_NO_MASK 0xFFFF -#define BIT_3BYTE_NO_MASK 0xFFFFFF -#define BIT_EXT_PICTURE_MASK 0x7FFF +#define BIT_1_MASK 0x80 +#define BIT_2_MASK 0x40 +#define BIT_3_MASK 0x20 +#define BIT_4_MASK 0x10 +#define BIT_5_MASK 0x08 +#define BIT_6_MASK 0x04 +#define BIT_7_MASK 0x02 +#define BIT_8_MASK 0x01 +#define BIT_123_MASK 0xE0 +#define BIT_234_MASK 0x70 +#define BIT_5678_MASK 0x0F +#define BIT_567_MASK 0x0E +#define BIT_45678_MASK 0x1F +#define BIT_12_MASK 0xC0 +#define BIT_NO_MASK 0xFF + +#define BIT_2BYTE_NO_MASK 0xFFFF +#define BIT_3BYTE_NO_MASK 0xFFFFFF +#define BIT_EXT_PICTURE_MASK 0x7FFF #define BIT_PARTITION_SIZE_MASK 0xE0FFFF static range_t *temp_dynamic_payload_type_range = NULL; @@ -170,16 +171,17 @@ dissect_vp8(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) { proto_item *item; - gint offset= 0, frametype = 0, partition1_size = -1; + gint offset = 0, frametype = 0, partition1_size = -1; proto_tree *vp8_tree; gboolean hasHeader = FALSE; col_set_str(pinfo->cinfo, COL_PROTOCOL, "VP8"); + col_clear(pinfo->cinfo, COL_INFO); item = proto_tree_add_item(tree, proto_vp8, tvb, 0, -1, ENC_NA); vp8_tree = proto_item_add_subtree(item, ett_vp8); - frametype=2;/*continuation, will get overridden if there is a payload header*/ + frametype = 2; /*continuation, will get overridden if there is a payload header*/ dissect_vp8_payload_descriptor(tvb, pinfo, vp8_tree, &offset, &hasHeader); if (hasHeader) @@ -218,18 +220,19 @@ The first octets after the RTP header are the VP8 payload descriptor, +-+-+-+-+-+-+-+-+ */ - vp8_payload_descriptor_tree = proto_tree_add_subtree(vp8_tree, tvb, *offset, -1, ett_vp8_payload_descriptor, &item_descriptor, "Payload descriptor"); + vp8_payload_descriptor_tree = proto_tree_add_subtree(vp8_tree, tvb, *offset, -1, ett_vp8_payload_descriptor, + &item_descriptor, "Payload descriptor"); - proto_tree_add_item(vp8_payload_descriptor_tree, hf_vp8_pld_x_bit, tvb, *offset, 1, ENC_BIG_ENDIAN); - proto_tree_add_item(vp8_payload_descriptor_tree, hf_vp8_pld_r_bit, tvb, *offset, 1, ENC_BIG_ENDIAN); - proto_tree_add_item(vp8_payload_descriptor_tree, hf_vp8_pld_n_bit, tvb, *offset, 1, ENC_BIG_ENDIAN); - proto_tree_add_item(vp8_payload_descriptor_tree, hf_vp8_pld_s_bit, tvb, *offset, 1, ENC_BIG_ENDIAN); + proto_tree_add_item(vp8_payload_descriptor_tree, hf_vp8_pld_x_bit, tvb, *offset, 1, ENC_BIG_ENDIAN); + proto_tree_add_item(vp8_payload_descriptor_tree, hf_vp8_pld_r_bit, tvb, *offset, 1, ENC_BIG_ENDIAN); + proto_tree_add_item(vp8_payload_descriptor_tree, hf_vp8_pld_n_bit, tvb, *offset, 1, ENC_BIG_ENDIAN); + proto_tree_add_item(vp8_payload_descriptor_tree, hf_vp8_pld_s_bit, tvb, *offset, 1, ENC_BIG_ENDIAN); proto_tree_add_item(vp8_payload_descriptor_tree, hf_vp8_pld_part_id, tvb, *offset, 1, ENC_BIG_ENDIAN); extended_bit = tvb_get_guint8(tvb, *offset) & BIT_1_MASK; - s_bit = tvb_get_guint8(tvb, *offset) & BIT_4_MASK; + s_bit = tvb_get_guint8(tvb, *offset) & BIT_4_MASK; partId = tvb_get_guint8(tvb, *offset) & BIT_5678_MASK; - if (s_bit>0 && partId==0) { + if ((s_bit > 0) && (partId == 0)) { *hasHeader=TRUE; } @@ -321,8 +324,8 @@ The first three octets of an encoded VP8 frame are referred to as an vp8_payload_header_tree = proto_tree_add_subtree(vp8_tree, tvb, *offset, 3, ett_vp8_payload_header, &item_header, "Payload header"); proto_tree_add_item(vp8_payload_header_tree, hf_vp8_hdr_frametype, tvb, *offset, 1, ENC_BIG_ENDIAN); - proto_tree_add_item(vp8_payload_header_tree, hf_vp8_hdr_version, tvb, *offset, 1, ENC_BIG_ENDIAN); - proto_tree_add_item(vp8_payload_header_tree, hf_vp8_hdr_show_bit, tvb, *offset, 1, ENC_BIG_ENDIAN); + proto_tree_add_item(vp8_payload_header_tree, hf_vp8_hdr_version, tvb, *offset, 1, ENC_BIG_ENDIAN); + proto_tree_add_item(vp8_payload_header_tree, hf_vp8_hdr_show_bit, tvb, *offset, 1, ENC_BIG_ENDIAN); *frametype = tvb_get_guint8(tvb, *offset) & BIT_8_MASK; @@ -345,7 +348,7 @@ dissect_vp8_payload(tvbuff_t *tvb, packet_info *pinfo, proto_tree *vp8_tree, gin vp8_payload_tree = proto_tree_add_subtree(vp8_tree, tvb, *offset, -1, ett_vp8_payload, NULL, "Payload"); - if (*frametype==0) + if (*frametype == 0) { guint16 width, height; gint start1, start2, start3, horizontal_scale, vertical_scale; @@ -359,7 +362,7 @@ dissect_vp8_payload(tvbuff_t *tvb, packet_info *pinfo, proto_tree *vp8_tree, gin start3 = tvb_get_guint8(tvb, *offset + 2); /* check start code is correct */ - if (start1!=0x9d||start2!=0x01||start3!=0x2a) + if ((start1 != 0x9d) || (start2 != 0x01) || (start3 != 0x2a)) { expert_add_info(pinfo, vp8_keyframe_tree, &ei_vp8_startcode); } @@ -384,7 +387,7 @@ dissect_vp8_payload(tvbuff_t *tvb, packet_info *pinfo, proto_tree *vp8_tree, gin } remainder = tvb_reported_length_remaining(tvb, (*offset)); - if ((*partition1_size)==-1) + if ((*partition1_size) == -1) { /*no header, continuation?*/ proto_tree_add_text(vp8_payload_tree, tvb, *offset, -1, "Continuation of partition fragment (%d bytes)", remainder); @@ -398,8 +401,10 @@ dissect_vp8_payload(tvbuff_t *tvb, packet_info *pinfo, proto_tree *vp8_tree, gin } else { - (*offset)= (*offset)+(*partition1_size); - proto_tree_add_text(vp8_payload_tree, tvb, *offset, -1, "This frame contains all of first partition (%d bytes) and also %d bytes from other partitions", *partition1_size, remainder); + (*offset)= (*offset) + (*partition1_size); + proto_tree_add_text(vp8_payload_tree, tvb, *offset, -1, + "This frame contains all of first partition (%d bytes) and also %d bytes from other partitions", + *partition1_size, remainder); } } expert_add_info(pinfo, vp8_payload_tree, &ei_vp8_undecoded); @@ -568,13 +573,15 @@ proto_register_vp8(void) register_dissector("vp8", dissect_vp8, proto_vp8); } -static void range_delete_vp8_rtp_pt_callback(guint32 rtp_pt) { - if (rtp_pt >= 96 && rtp_pt <= 127) +static void +range_delete_vp8_rtp_pt_callback(guint32 rtp_pt) { + if ((rtp_pt >= 96) && (rtp_pt <= 127)) dissector_delete_uint("rtp.pt", rtp_pt, vp8_handle); } -static void range_add_vp8_rtp_pt_callback(guint32 rtp_pt) { - if (rtp_pt >= 96 && rtp_pt <= 127) +static void +range_add_vp8_rtp_pt_callback(guint32 rtp_pt) { + if ((rtp_pt >= 96) && (rtp_pt <= 127)) dissector_add_uint("rtp.pt", rtp_pt, vp8_handle); } @@ -582,12 +589,12 @@ void proto_reg_handoff_vp8(void) { static range_t *dynamic_payload_type_range = NULL; - static gboolean vp8_prefs_initialized = FALSE; + static gboolean vp8_prefs_initialized = FALSE; if (!vp8_prefs_initialized) { vp8_handle = find_dissector("vp8"); - dissector_add_string("rtp_dyn_payload_type","VP8", vp8_handle); - + dissector_add_string("rtp_dyn_payload_type" , "VP8", vp8_handle); + vp8_prefs_initialized = TRUE; } else { range_foreach(dynamic_payload_type_range, range_delete_vp8_rtp_pt_callback); g_free(dynamic_payload_type_range); |