From 5003654fe0bb1bc5f96f288795d4953b8f853ff8 Mon Sep 17 00:00:00 2001 From: Bill Meier Date: Sun, 25 Jan 2015 09:53:25 -0500 Subject: Cleanup: Including: Remove dead initializers; Remove boilerplate comments; Localize some variables; tvb_length...() ==> tvb_reported_length...(); Use TRUE/FALSE when assigning a value to a gboolean; whitespace/indentaion. Change-Id: I09e1f15611011bbe393d23e1cb54568ddd3cebc6 Reviewed-on: https://code.wireshark.org/review/6771 Reviewed-by: Bill Meier --- epan/dissectors/packet-extreme.c | 4 +- epan/dissectors/packet-ismacryp.c | 259 +++++++++++++++++------------------ epan/dissectors/packet-kdp.c | 230 +++++++++++++++---------------- epan/dissectors/packet-mgcp.c | 192 +++++++++++++------------- epan/dissectors/packet-netflow.c | 2 +- epan/dissectors/packet-tivoconnect.c | 59 +++----- 6 files changed, 360 insertions(+), 386 deletions(-) (limited to 'epan/dissectors') diff --git a/epan/dissectors/packet-extreme.c b/epan/dissectors/packet-extreme.c index ad127db779..b3dd7f56db 100644 --- a/epan/dissectors/packet-extreme.c +++ b/epan/dissectors/packet-extreme.c @@ -952,7 +952,7 @@ static void dissect_edp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) { proto_item *ti; - proto_tree *edp_tree = NULL; + proto_tree *edp_tree; proto_item *checksum_item; proto_tree *checksum_tree; guint32 offset = 0; @@ -1059,7 +1059,7 @@ dissect_edp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) switch (tlv_type) { case EDP_TYPE_NULL: /* Last TLV */ dissect_null_tlv(tvb, pinfo, offset, tlv_length, edp_tree); - last = 1; + last = TRUE; break; case EDP_TYPE_DISPLAY: /* MIB II display string */ dissect_display_tlv(tvb, pinfo, offset, tlv_length, edp_tree); diff --git a/epan/dissectors/packet-ismacryp.c b/epan/dissectors/packet-ismacryp.c index 9e3d52a15a..aa9dd41c90 100644 --- a/epan/dissectors/packet-ismacryp.c +++ b/epan/dissectors/packet-ismacryp.c @@ -247,7 +247,7 @@ static void dissect_ismacryp_common(tvbuff_t *tvb, packet_info *pinfo, proto_tre proto_tree *ismacryp_message_tree; /* select and display ISMACryp version */ - if ((ismacryp_version!=version_type) && override_flag){ + if ((ismacryp_version != version_type) && override_flag) { /* override -> use manual preference setting */ col_append_str(pinfo->cinfo, COL_INFO, " Manual version"); set_version = version_type; /* set to preference value */ @@ -256,24 +256,24 @@ static void dissect_ismacryp_common(tvbuff_t *tvb, packet_info *pinfo, proto_tre set_version = ismacryp_version; } - if (set_version == V11){ + if (set_version == V11) { col_set_str(pinfo->cinfo, COL_PROTOCOL, PROTO_TAG_ISMACRYP_11); /* display mode */ - if (pref_user_mode == FALSE){ - col_append_fstr(pinfo->cinfo, COL_INFO, ", %s",val_to_str_const(mode, modetypenames, "user mode")); + if (pref_user_mode == FALSE) { + col_append_fstr(pinfo->cinfo, COL_INFO, ", %s", val_to_str_const(mode, modetypenames, "user mode")); } else { col_append_str(pinfo->cinfo, COL_INFO, ", user mode"); } user_mode = pref_user_mode; } - if (set_version == V20){ + if (set_version == V20) { col_set_str(pinfo->cinfo, COL_PROTOCOL, PROTO_TAG_ISMACRYP_20); user_mode = TRUE; /* display mode */ col_append_str(pinfo->cinfo, COL_INFO, ", user mode"); } /* select correct AU values depending on version & selected mode in preferences menu if not in user_mode */ - if (user_mode == TRUE){ /* use values set in preference menu */ + if (user_mode == TRUE) { /* use values set in preference menu */ au_size_length = pref_au_size_length; au_index_length = pref_au_index_length; au_index_delta_length = pref_au_index_delta_length; @@ -282,8 +282,8 @@ static void dissect_ismacryp_common(tvbuff_t *tvb, packet_info *pinfo, proto_tre random_access_indication = pref_random_access_indication; stream_state_indication = pref_stream_state_indication; } /* end if user_mode == TRUE */ - if (user_mode == FALSE){ - switch (mode){ + if (user_mode == FALSE) { + switch (mode) { case AAC_HBR_MODE: au_size_length = 13; au_index_length = 3; @@ -318,18 +318,15 @@ static void dissect_ismacryp_common(tvbuff_t *tvb, packet_info *pinfo, proto_tre } /* end if user_mode == FALSE */ /* navigate through buffer */ - /* if (tree) */ { - guint16 au_headers_length = 0; /* total length of AU headers */ - guint16 totalbits =0; /* keeps track of total number of AU header bits treated (used to determine end of AU headers) */ - int deltabits = -1; /* keeps track of extra bits per AU header treated (used to determine end of AU heafers ) */ - guint16 totalbit_offset = 0; /* total offset in bits*/ - int nbpadding_bits = 0; /* number of padding bits*/ + guint16 au_headers_length; /* total length of AU headers */ + guint16 totalbits; /* keeps track of total number of AU header bits treated (used to determine end of AU headers) */ + int deltabits; /* keeps track of extra bits per AU header treated (used to determine end of AU heafers ) */ offset_struct s_offset; offset_struct* poffset; - guint16 nbmessage_bytes = 0; /*nb of message data bytes */ + guint16 nbmessage_bytes; /*nb of message data bytes */ s_offset.offset_bytes = 0; /* initialise byte offset */ - s_offset.offset_bits = 0; /* initialise bit offset */ + s_offset.offset_bits = 0; /* initialise bit offset */ poffset = &s_offset; ismacryp_item = proto_tree_add_item(tree, proto_ismacryp, tvb, 0, -1, ENC_NA); @@ -337,41 +334,43 @@ static void dissect_ismacryp_common(tvbuff_t *tvb, packet_info *pinfo, proto_tre proto_item_append_text(tree, ", %s", "ismacryp packet"); /* add text to tree */ /* ismacryp_tree analysis */ - /* we are being asked for details */ /* get total length of AU headers (first 2 bytes) */ ismacryp_item = proto_tree_add_item(ismacryp_tree, hf_ismacryp_au_headers_length, tvb, poffset->offset_bytes, AU_HEADERS_LENGTH_SIZE, ENC_BIG_ENDIAN ); proto_item_append_text(ismacryp_item, " (bits)"); /* add text to AU Header tree indicating length */ - au_headers_length=tvb_get_ntohs(tvb,poffset->offset_bytes); /* 2 byte au headers length */ - poffset->offset_bytes+=AU_HEADERS_LENGTH_SIZE; + au_headers_length = tvb_get_ntohs(tvb, poffset->offset_bytes); /* 2 byte au headers length */ + poffset->offset_bytes += AU_HEADERS_LENGTH_SIZE; /* ADD HEADER(S) BRANCH */ /* AU Header loop */ - totalbits=(poffset->offset_bytes*8)+poffset->offset_bits; - while( ((totalbits-8*AU_HEADERS_LENGTH_SIZE)offset_bytes*8) + poffset->offset_bits; + deltabits = 1; + while( ((totalbits - 8*AU_HEADERS_LENGTH_SIZE)offset_bytes*8)+poffset->offset_bits - totalbits; /* if zero this means no actual AU header so exit while loop */ - totalbits+=deltabits; + poffset = dissect_auheader( tvb, poffset, pinfo, ismacryp_tree, set_version); + deltabits = (poffset->offset_bytes*8) + poffset->offset_bits - totalbits; /* if zero this means no actual AU header so exit while loop */ + totalbits += deltabits; } /* reached end of AU Header(s) */ /* sanity check if actual total AU headers length in bits i.e. totalbits is */ /* the same as expected AU headers length from 2 bytes at start of buffer */ - if ( (totalbits-8*AU_HEADERS_LENGTH_SIZE) != au_headers_length) /* something wrong */ + if ( (totalbits - 8*AU_HEADERS_LENGTH_SIZE) != au_headers_length) /* something wrong */ { proto_item_append_text(ismacryp_item, " Error - expected total AU headers size (%d bits) " "does not match calculated size (%d bits) - check parameters!", - au_headers_length,(totalbits-8*AU_HEADERS_LENGTH_SIZE)); + au_headers_length, (totalbits - 8*AU_HEADERS_LENGTH_SIZE)); } /* add padding if need to byte align */ - if (poffset->offset_bits!=0) + if (poffset->offset_bits != 0) { - totalbit_offset = (poffset->offset_bytes)*8+poffset->offset_bits; /* offset in bits */ - nbpadding_bits = (8-poffset->offset_bits); /* number of padding bits for byte alignment */ + guint16 totalbit_offset; /* total offset in bits*/ + int nbpadding_bits; /* number of padding bits*/ + totalbit_offset = (poffset->offset_bytes)*8 + poffset->offset_bits; /* offset in bits */ + nbpadding_bits = (8 - poffset->offset_bits); /* number of padding bits for byte alignment */ ismacryp_item = proto_tree_add_bits_item(ismacryp_tree, hf_ismacryp_padding, tvb, totalbit_offset, nbpadding_bits , ENC_BIG_ENDIAN); /* padding bits */ - proto_item_append_text(ismacryp_item, ": Length=%d bits",nbpadding_bits); /* add padding info */ + proto_item_append_text(ismacryp_item, ": Length=%d bits", nbpadding_bits); /* add padding info */ add_bits(poffset, nbpadding_bits); } /* ADD MESSAGE BRANCH */ @@ -384,11 +383,10 @@ static void dissect_ismacryp_common(tvbuff_t *tvb, packet_info *pinfo, proto_tre /* ismacryp message tree analysis (encrypted AUs) */ if (ismacryp_message_tree) - { /* we are being asked for details */ - poffset->offset_bytes+= nbmessage_bytes; /* */ - } /* end message details */ - /* end ismacryp tree details */ - } /* end if tree */ + { + poffset->offset_bytes += nbmessage_bytes; /* */ + } + } } /* AU Header dissection */ static offset_struct* dissect_auheader( tvbuff_t *tvb, offset_struct *poffset, packet_info *pinfo, proto_tree *ismacryp_tree, guint set_version ) @@ -401,7 +399,7 @@ static offset_struct* dissect_auheader( tvbuff_t *tvb, offset_struct *poffset, p gint header_len = 0; /* length of AU headers in bits */ gint cts_flag =0; gint dts_flag =0; - gboolean first_au_flag=FALSE; + gboolean first_au_flag = FALSE; gint bit_offset = 0; /*first determine total AU header length */ @@ -409,59 +407,59 @@ static offset_struct* dissect_auheader( tvbuff_t *tvb, offset_struct *poffset, p switch (set_version) { case V11: if (selective_encryption) - header_len+=8; /* add one byte to header length */ + header_len += 8; /* add one byte to header length */ break; case V20: if (selective_encryption || slice_indication || padding_indication) - header_len+=8; /* add one byte to header length */ + header_len += 8; /* add one byte to header length */ break; default: DISSECTOR_ASSERT_NOT_REACHED(); break; } /* end switch */ - header_len+=au_size_length; /* add au size length */ + header_len += au_size_length; /* add au size length */ - if (poffset->offset_bytes==AU_HEADERS_LENGTH_SIZE){ /*first AU */ - header_len+=8*(iv_length); /* add IV length */ - header_len+=8*key_indicator_length; /* add key indicator length */ - header_len+=au_index_length; /* add AU index length */ + if (poffset->offset_bytes == AU_HEADERS_LENGTH_SIZE) { /*first AU */ + header_len += 8*(iv_length); /* add IV length */ + header_len += 8*key_indicator_length; /* add key indicator length */ + header_len += au_index_length; /* add AU index length */ first_au_flag = TRUE; } else { /* not the first AU */ if (key_indicator_per_au_flag == TRUE) - header_len+=8*key_indicator_length; /* add key indicator length */ - header_len+=8*(delta_iv_length); /* add delta IV length */ - header_len+=au_index_delta_length; /* add AU delta index length */ + header_len += 8*key_indicator_length; /* add key indicator length */ + header_len += 8*(delta_iv_length); /* add delta IV length */ + header_len += au_index_delta_length; /* add AU delta index length */ } /* CTS flag is present? */ - if (cts_delta_length != 0){ /* need to test whether cts_delta_flag is TRUE or FALSE */ - cts_flag=tvb_get_bits8(tvb, AU_HEADERS_LENGTH_SIZE*8+header_len, 1); /*fetch 1 bit CTS flag */ - header_len+=1; /* add CTS flag bit */ - if (cts_flag==1) - header_len+=cts_delta_length; /* add CTS delta length bits if CTS flag SET */ + if (cts_delta_length != 0) { /* need to test whether cts_delta_flag is TRUE or FALSE */ + cts_flag = tvb_get_bits8(tvb, AU_HEADERS_LENGTH_SIZE*8 + header_len, 1); /*fetch 1 bit CTS flag */ + header_len += 1; /* add CTS flag bit */ + if (cts_flag == 1) + header_len += cts_delta_length; /* add CTS delta length bits if CTS flag SET */ } /* DTS flag is present? */ - if (dts_delta_length != 0){ /* need to test whether dts_delta_flag is TRUE or FALSE */ - dts_flag=tvb_get_bits8(tvb, AU_HEADERS_LENGTH_SIZE*8+header_len, 1); /*fetch 1 bit DTS flag */ - header_len+=1; /* add DTS flag bit */ - if (dts_flag==1) - header_len+=dts_delta_length; /* add DTS delta length bits if DTS flag SET */ + if (dts_delta_length != 0) { /* need to test whether dts_delta_flag is TRUE or FALSE */ + dts_flag = tvb_get_bits8(tvb, AU_HEADERS_LENGTH_SIZE*8 + header_len, 1); /*fetch 1 bit DTS flag */ + header_len += 1; /* add DTS flag bit */ + if (dts_flag == 1) + header_len += dts_delta_length; /* add DTS delta length bits if DTS flag SET */ } /* RAP flag present? */ if (random_access_indication != FALSE) - header_len+=1; /* add 1 bit RAP flag */ + header_len += 1; /* add 1 bit RAP flag */ /* stream state indication present */ if (stream_state_indication !=0) - header_len+=stream_state_indication; /* add stream state indication bits */ + header_len += stream_state_indication; /* add stream state indication bits */ /* convert header_len to bytes (rounded up) */ - if (header_len% 8!=0) + if (header_len% 8 != 0) { - header_len_bytes=((header_len)/8)+1; /*add 1 */ + header_len_bytes = ((header_len)/8) + 1; /*add 1 */ } else - header_len_bytes=((header_len)/8); + header_len_bytes = ((header_len)/8); /* add AU header tree */ ismacryp_item = proto_tree_add_item(ismacryp_tree, hf_ismacryp_header, tvb, poffset->offset_bytes, header_len_bytes, ENC_NA ); @@ -474,12 +472,11 @@ static offset_struct* dissect_auheader( tvbuff_t *tvb, offset_struct *poffset, p ismacryp_header_tree = proto_item_add_subtree(ismacryp_item, ett_ismacryp_header); /* ismacryp header analysis */ - /* we are being asked for details */ /* Extra 1 Byte Header? */ - if ((set_version==V20 && (selective_encryption || slice_indication || padding_indication)) - || (set_version==V11 && selective_encryption)){ + if ((set_version == V20 && (selective_encryption || slice_indication || padding_indication)) + || (set_version == V11 && selective_encryption)) { /* add header byte tree */ ismacryp_item = proto_tree_add_item(ismacryp_header_tree, hf_ismacryp_header_byte, @@ -488,12 +485,11 @@ static offset_struct* dissect_auheader( tvbuff_t *tvb, offset_struct *poffset, p ismacryp_header_byte_tree = proto_item_add_subtree(ismacryp_item, ett_ismacryp_header_byte); /*ismacryp_header_byte_tree */ - /* we are being asked for details */ /* tvb is network order, so get MSB bits first, so shift 8 bits and work "backwards" */ - add_bits(poffset,7); /*shift 7 bits to get correct bit */ + add_bits(poffset, 7); /*shift 7 bits to get correct bit */ /* AU_is_encrypted bit */ - bit_offset = (poffset->offset_bytes)*8+poffset->offset_bits; /* offset in bits */ - if (selective_encryption){ /* bit used */ + bit_offset = (poffset->offset_bytes)*8 + poffset->offset_bits; /* offset in bits */ + if (selective_encryption) { /* bit used */ proto_tree_add_bits_item(ismacryp_header_byte_tree, hf_ismacryp_au_is_encrypted, tvb, bit_offset, 1, ENC_BIG_ENDIAN); /*fetch 1 bit AU_is_encrypted */ } @@ -501,20 +497,20 @@ static offset_struct* dissect_auheader( tvbuff_t *tvb, offset_struct *poffset, p proto_tree_add_bits_item(ismacryp_header_byte_tree, hf_ismacryp_unused_bits, tvb, bit_offset, 1, ENC_BIG_ENDIAN); /*fetch 1 bit unused */ } - switch (set_version){ /* ISMACryp version? */ + switch (set_version) { /* ISMACryp version? */ case V11: /* Reserved bits */ add_bits(poffset, -7); /* move back 7 bits for reserved bits */ - bit_offset = (poffset->offset_bytes)*8+poffset->offset_bits; /* offset in bits */ + bit_offset = (poffset->offset_bytes)*8 + poffset->offset_bits; /* offset in bits */ proto_tree_add_bits_item(ismacryp_header_byte_tree, hf_ismacryp_reserved_bits, tvb, bit_offset, 7, ENC_BIG_ENDIAN); /*fetch 7 bits reserved */ - add_bits(poffset,8); /* offset to next byte */ + add_bits(poffset, 8); /* offset to next byte */ break; case V20: /* Slice_start bit */ add_bits(poffset, -1); /* move back 1 bit for slice_start */ - bit_offset = (poffset->offset_bytes)*8+poffset->offset_bits; /* offset in bits */ - if (slice_indication){ + bit_offset = (poffset->offset_bytes)*8 + poffset->offset_bits; /* offset in bits */ + if (slice_indication) { proto_tree_add_bits_item(ismacryp_header_byte_tree, hf_ismacryp_slice_start, tvb, bit_offset, 1, ENC_BIG_ENDIAN); /*fetch 1 bit slice_start */ } @@ -525,8 +521,8 @@ static offset_struct* dissect_auheader( tvbuff_t *tvb, offset_struct *poffset, p add_bits(poffset, -1); /* move back 1 bit for slice_end */ /* Slice_end bit */ - bit_offset = (poffset->offset_bytes)*8+poffset->offset_bits; /* offset in bits */ - if (slice_indication){ + bit_offset = (poffset->offset_bytes)*8 + poffset->offset_bits; /* offset in bits */ + if (slice_indication) { proto_tree_add_bits_item(ismacryp_header_byte_tree, hf_ismacryp_slice_end, tvb, bit_offset, 1, ENC_BIG_ENDIAN); /*fetch 1 bit Slice_end */ } @@ -537,8 +533,8 @@ static offset_struct* dissect_auheader( tvbuff_t *tvb, offset_struct *poffset, p add_bits(poffset, -3); /* move back 3 bits for padding_bitcount */ /* Padding_bitcount bits */ - bit_offset = (poffset->offset_bytes)*8+poffset->offset_bits; /* offset in bits */ - if (padding_indication){ + bit_offset = (poffset->offset_bytes)*8 + poffset->offset_bits; /* offset in bits */ + if (padding_indication) { proto_tree_add_bits_item(ismacryp_header_byte_tree, hf_ismacryp_padding_bitcount, tvb, bit_offset, 3, ENC_BIG_ENDIAN); /*fetch 3 bits padding_bitcount */ } @@ -549,10 +545,10 @@ static offset_struct* dissect_auheader( tvbuff_t *tvb, offset_struct *poffset, p add_bits(poffset, -2); /* move back 2 bits for reserved bits */ /* Reserved bits */ - bit_offset = (poffset->offset_bytes)*8+poffset->offset_bits; /* offset in bits */ + bit_offset = (poffset->offset_bytes)*8 + poffset->offset_bits; /* offset in bits */ proto_tree_add_bits_item(ismacryp_header_byte_tree, hf_ismacryp_reserved_bits, tvb, bit_offset, 2, ENC_BIG_ENDIAN); /*fetch 2 bits reserved */ - add_bits(poffset,8); /* offset to next byte */ + add_bits(poffset, 8); /* offset to next byte */ break; default: DISSECTOR_ASSERT_NOT_REACHED(); @@ -563,21 +559,21 @@ static offset_struct* dissect_auheader( tvbuff_t *tvb, offset_struct *poffset, p if (first_au_flag == TRUE && iv_length != 0) { ismacryp_item = proto_tree_add_item(ismacryp_header_tree, hf_ismacryp_iv, tvb, poffset->offset_bytes, iv_length, ENC_NA); - proto_item_append_text(ismacryp_item, ": Length=%d bytes",iv_length); /* add IV info */ + proto_item_append_text(ismacryp_item, ": Length=%d bytes", iv_length); /* add IV info */ col_append_fstr( pinfo->cinfo, COL_INFO, - ", IV=0x%s", tvb_bytes_to_str_punct(wmem_packet_scope(), tvb, poffset->offset_bytes, iv_length,' ')); + ", IV=0x%s", tvb_bytes_to_str_punct(wmem_packet_scope(), tvb, poffset->offset_bytes, iv_length, ' ')); - poffset->offset_bytes+=iv_length; /* add IV length to offset_bytes */ + poffset->offset_bytes += iv_length; /* add IV length to offset_bytes */ } /*Delta IV */ if (first_au_flag == FALSE && delta_iv_length != 0) { ismacryp_item = proto_tree_add_item(ismacryp_header_tree, hf_ismacryp_delta_iv, tvb, poffset->offset_bytes, delta_iv_length, ENC_NA); - proto_item_append_text(ismacryp_item, ": Length=%d bytes",delta_iv_length); /* add delta IV info */ + proto_item_append_text(ismacryp_item, ": Length=%d bytes", delta_iv_length); /* add delta IV info */ col_append_fstr( pinfo->cinfo, COL_INFO, - ", Delta IV=0x%s", tvb_bytes_to_str_punct(wmem_packet_scope(), tvb, poffset->offset_bytes, delta_iv_length,' ')); - poffset->offset_bytes+=delta_iv_length; /* add IV length to offset_bytes */ + ", Delta IV=0x%s", tvb_bytes_to_str_punct(wmem_packet_scope(), tvb, poffset->offset_bytes, delta_iv_length, ' ')); + poffset->offset_bytes += delta_iv_length; /* add IV length to offset_bytes */ } /* Key Indicator */ if ( key_indicator_length != 0 && ( first_au_flag == TRUE || key_indicator_per_au_flag == TRUE) ) @@ -585,62 +581,62 @@ static offset_struct* dissect_auheader( tvbuff_t *tvb, offset_struct *poffset, p /* (first AU or KI for each AU) and non-zero KeyIndicator size */ ismacryp_item = proto_tree_add_item(ismacryp_header_tree, hf_ismacryp_key_indicator, tvb, poffset->offset_bytes, key_indicator_length, ENC_NA); - proto_item_append_text(ismacryp_item,": Length=%d bytes",key_indicator_length); /* add KI info */ + proto_item_append_text(ismacryp_item, ": Length=%d bytes", key_indicator_length); /* add KI info */ col_append_fstr( pinfo->cinfo, COL_INFO, - ", KI=0x%s", tvb_bytes_to_str_punct(wmem_packet_scope(), tvb, poffset->offset_bytes, key_indicator_length,' ')); - poffset->offset_bytes+=key_indicator_length; /* add KI length to offset_bytes */ + ", KI=0x%s", tvb_bytes_to_str_punct(wmem_packet_scope(), tvb, poffset->offset_bytes, key_indicator_length, ' ')); + poffset->offset_bytes += key_indicator_length; /* add KI length to offset_bytes */ } /* AU size */ if (au_size_length != 0) /* in bits */ { - bit_offset = (poffset->offset_bytes)*8+poffset->offset_bits; /* offset in bits */ - ismacryp_item = proto_tree_add_bits_item(ismacryp_header_tree,hf_ismacryp_au_size, + bit_offset = (poffset->offset_bytes)*8 + poffset->offset_bits; /* offset in bits */ + ismacryp_item = proto_tree_add_bits_item(ismacryp_header_tree, hf_ismacryp_au_size, tvb, bit_offset, au_size_length, ENC_BIG_ENDIAN); - proto_item_append_text(ismacryp_item, " bytes: Length=%d bits",au_size_length); /* add AU size info */ - /*bit_offset+=au_size_length;*/ + proto_item_append_text(ismacryp_item, " bytes: Length=%d bits", au_size_length); /* add AU size info */ + /*bit_offset += au_size_length;*/ add_bits(poffset, au_size_length); } /* AU Index */ if (first_au_flag == TRUE && au_index_length != 0) /* first AU and non-zero AU size */ { - bit_offset = (poffset->offset_bytes)*8+poffset->offset_bits; /* offset in bits */ - ismacryp_item = proto_tree_add_bits_item(ismacryp_header_tree,hf_ismacryp_au_index, + bit_offset = (poffset->offset_bytes)*8 + poffset->offset_bits; /* offset in bits */ + ismacryp_item = proto_tree_add_bits_item(ismacryp_header_tree, hf_ismacryp_au_index, tvb, bit_offset, au_index_length, ENC_BIG_ENDIAN); - proto_item_append_text(ismacryp_item, " bits: Length=%d bits",au_index_length); /* add AU index info */ - /*bit_offset+=au_index_length;*/ + proto_item_append_text(ismacryp_item, " bits: Length=%d bits", au_index_length); /* add AU index info */ + /*bit_offset += au_index_length;*/ add_bits(poffset, au_index_length); } /* AU index delta */ if (first_au_flag == FALSE && au_index_delta_length != 0) /* not first AU and non-zero AU delta size */ { - bit_offset = (poffset->offset_bytes)*8+poffset->offset_bits; /* offset in bits */ - ismacryp_item = proto_tree_add_bits_item(ismacryp_header_tree,hf_ismacryp_au_index_delta, + bit_offset = (poffset->offset_bytes)*8 + poffset->offset_bits; /* offset in bits */ + ismacryp_item = proto_tree_add_bits_item(ismacryp_header_tree, hf_ismacryp_au_index_delta, tvb, bit_offset, au_index_delta_length, ENC_BIG_ENDIAN); proto_item_append_text(ismacryp_item, ": Length=%d bits", au_index_delta_length); /* add AU index info */ - /*bit_offset+=au_index_delta_length;*/ + /*bit_offset += au_index_delta_length;*/ add_bits(poffset, au_index_delta_length); } /* CTS delta value */ if (cts_delta_length != 0) { - bit_offset = (poffset->offset_bytes)*8+poffset->offset_bits; /* offset in bits */ + bit_offset = (poffset->offset_bytes)*8 + poffset->offset_bits; /* offset in bits */ proto_tree_add_bits_item(ismacryp_header_tree, hf_ismacryp_cts_flag, tvb, bit_offset, 1, ENC_BIG_ENDIAN); /* read CTS flag */ add_bits(poffset, 1); - if (cts_flag==1) + if (cts_flag == 1) { /* now fetch CTS delta value (remember offset 1 bit due to CTS flag) */ - bit_offset = (poffset->offset_bytes)*8+poffset->offset_bits; /* offset in bits */ + bit_offset = (poffset->offset_bytes)*8 + poffset->offset_bits; /* offset in bits */ ismacryp_item = proto_tree_add_bits_item(ismacryp_header_tree, hf_ismacryp_cts_delta, tvb, bit_offset, cts_delta_length, ENC_BIG_ENDIAN); /* read CTS delta value */ - proto_item_append_text(ismacryp_item, ": Length=%d bits",cts_delta_length); /* add CTS delta info */ + proto_item_append_text(ismacryp_item, ": Length=%d bits", cts_delta_length); /* add CTS delta info */ add_bits(poffset, cts_delta_length); } } /* DTS delta value */ if (dts_delta_length != 0) { - bit_offset = (poffset->offset_bytes)*8+poffset->offset_bits; /* offset in bits */ + bit_offset = (poffset->offset_bytes)*8 + poffset->offset_bits; /* offset in bits */ proto_tree_add_bits_item(ismacryp_header_tree, hf_ismacryp_dts_flag, tvb, bit_offset, 1, ENC_BIG_ENDIAN); /* read DTS flag */ add_bits(poffset, 1); @@ -648,17 +644,17 @@ static offset_struct* dissect_auheader( tvbuff_t *tvb, offset_struct *poffset, p /* now fetch DTS delta value (remember offset x bits due to DTS flag) */ if (dts_flag ==1) { - bit_offset = (poffset->offset_bytes)*8+poffset->offset_bits; /* offset in bits */ + bit_offset = (poffset->offset_bytes)*8 + poffset->offset_bits; /* offset in bits */ ismacryp_item = proto_tree_add_bits_item(ismacryp_header_tree, hf_ismacryp_dts_delta, tvb, bit_offset, dts_delta_length, ENC_BIG_ENDIAN); /* read DTS delta value */ - proto_item_append_text(ismacryp_item, ": Length=%d bits",dts_delta_length); /* add DTS delta info */ + proto_item_append_text(ismacryp_item, ": Length=%d bits", dts_delta_length); /* add DTS delta info */ add_bits(poffset, dts_delta_length); } } /* RAP */ if (random_access_indication != FALSE) { - bit_offset = (poffset->offset_bytes)*8+poffset->offset_bits; /* offset in bits */ + bit_offset = (poffset->offset_bytes)*8 + poffset->offset_bits; /* offset in bits */ proto_tree_add_bits_item(ismacryp_header_tree, hf_ismacryp_rap_flag, tvb, bit_offset, 1, ENC_BIG_ENDIAN); /* read RAP flag */ add_bits(poffset, 1); @@ -666,23 +662,22 @@ static offset_struct* dissect_auheader( tvbuff_t *tvb, offset_struct *poffset, p /*STREAM STATE */ if (stream_state_indication != 0) { - bit_offset = (poffset->offset_bytes)*8+poffset->offset_bits; /* offset in bits */ + bit_offset = (poffset->offset_bytes)*8 + poffset->offset_bits; /* offset in bits */ proto_tree_add_bits_item(ismacryp_header_tree, hf_ismacryp_stream_state, tvb, bit_offset, stream_state_indication, ENC_BIG_ENDIAN); /* read stream state */ add_bits(poffset, stream_state_indication); } - /* end header details */ return poffset; } /* add len_bits to offset bits and bytes, handling bits overflow */ static void add_bits(offset_struct* poffset, gint len_bits) { - gint nbbitstotal=0; - nbbitstotal=poffset->offset_bytes*8+(poffset->offset_bits)+len_bits; /* total offset in bits */ + gint nbbitstotal; + nbbitstotal = poffset->offset_bytes*8 + (poffset->offset_bits) + len_bits; /* total offset in bits */ /* now calculate bytes and bit offsets */ - poffset->offset_bytes=(nbbitstotal / 8); /* add integer no. of bytes */ - poffset->offset_bits=(nbbitstotal % 8); /* add remaining bits */ + poffset->offset_bytes = (nbbitstotal / 8); /* add integer no. of bytes */ + poffset->offset_bits = (nbbitstotal % 8); /* add remaining bits */ } void proto_register_ismacryp (void) @@ -884,7 +879,7 @@ void proto_register_ismacryp (void) " and to override the version if detected from RTP payload type:"); prefs_register_bool_preference(ismacryp_module, - "override_rtp_pt","Override RTP payload type for version", + "override_rtp_pt", "Override RTP payload type for version", "Indicates whether or not the ISMACryp version deduced" " from RTP payload type, if present, is used or whether the" " version above is used", @@ -897,27 +892,27 @@ void proto_register_ismacryp (void) "ISMACryp v1.1 parameters declared in SDP"); prefs_register_uint_preference(ismacryp_module, - "iv_length","ISMACrypIVLength (bytes)", + "iv_length", "ISMACrypIVLength (bytes)", "Set the length of the IV in the ISMACryp AU Header in bytes", 10, &iv_length); prefs_register_uint_preference(ismacryp_module, - "delta_iv_length","ISMACrypDeltaIVLength (bytes)", + "delta_iv_length", "ISMACrypDeltaIVLength (bytes)", "Set the length of the Delta IV in the ISMACryp AU Header in bytes", 10, &delta_iv_length); prefs_register_uint_preference(ismacryp_module, - "key_indicator_length","ISMACrypKeyIndicatorLength (bytes)", + "key_indicator_length", "ISMACrypKeyIndicatorLength (bytes)", "Set the length of the Key Indicator in the ISMACryp AU Header in bytes", 10, &key_indicator_length); prefs_register_bool_preference(ismacryp_module, - "key_indicator_per_au_flag","ISMACrypKeyIndicatorPerAU (T/F)", + "key_indicator_per_au_flag", "ISMACrypKeyIndicatorPerAU (T/F)", "Indicates whether or not the Key Indicator is present in all AU Headers (T/F)", &key_indicator_per_au_flag); prefs_register_bool_preference(ismacryp_module, - "selective_encryption","ISMACrypSelectiveEncryption (T/F)", + "selective_encryption", "ISMACrypSelectiveEncryption (T/F)", "Indicates whether or not selective encryption is enabled (T/F)", &selective_encryption); @@ -928,12 +923,12 @@ void proto_register_ismacryp (void) "ISMACryp v2.0 parameters declared in SDP"); prefs_register_bool_preference(ismacryp_module, - "slice_indication","ISMACrypSliceIndication (T/F)", + "slice_indication", "ISMACrypSliceIndication (T/F)", "Indicates whether or not slice start / end is present (T/F)", &slice_indication); prefs_register_bool_preference(ismacryp_module, - "padding_indication","ISMACrypPaddingIndication (T/F)", + "padding_indication", "ISMACrypPaddingIndication (T/F)", "Indicates whether or not padding information is present (T/F)", &padding_indication); @@ -951,7 +946,7 @@ void proto_register_ismacryp (void) /* User defined mode */ prefs_register_bool_preference(ismacryp_module, - "user_mode","User mode (T/F)", + "user_mode", "User mode (T/F)", "Indicates use of user mode instead of RFC3640 modes (T/F)", &pref_user_mode); @@ -963,37 +958,37 @@ void proto_register_ismacryp (void) /* ideally would grey this out or disable this if in user mode */ prefs_register_uint_preference(ismacryp_module, - "au_size_length","User mode: SizeLength (bits)", + "au_size_length", "User mode: SizeLength (bits)", "Set the length of the AU size in the AU Header in bits", 10, &pref_au_size_length); prefs_register_uint_preference(ismacryp_module, - "au_index_length","User mode: IndexLength (bits)", + "au_index_length", "User mode: IndexLength (bits)", "Set the length of the AU index in the AU Header in bits", 10, &pref_au_index_length); prefs_register_uint_preference(ismacryp_module, - "au_index_delta_length","User mode: IndexDeltaLength (bits)", + "au_index_delta_length", "User mode: IndexDeltaLength (bits)", "Set the length of the AU delta index in the AU Header in bits", 10, &pref_au_index_delta_length); prefs_register_uint_preference(ismacryp_module, - "cts_delta_length","User mode: CTSDeltaLength (bits)", + "cts_delta_length", "User mode: CTSDeltaLength (bits)", "Set the length of the CTS delta field in the AU Header in bits", 10, &pref_cts_delta_length); prefs_register_uint_preference(ismacryp_module, - "dts_delta_length","User mode: DTSDeltaLength (bits)", + "dts_delta_length", "User mode: DTSDeltaLength (bits)", "Set the length of the DTS delta field in the AU Header in bits", 10, &pref_dts_delta_length); prefs_register_bool_preference(ismacryp_module, - "random_access_indication","User mode: RandomAccessIndication (T/F)", + "random_access_indication", "User mode: RandomAccessIndication (T/F)", "Indicates whether or not the RAP field is present in the AU Header (T/F)", &pref_random_access_indication); prefs_register_uint_preference(ismacryp_module, - "stream_state_indication","User mode: StreamStateIndication (number of bits)", + "stream_state_indication", "User mode: StreamStateIndication (number of bits)", "Indicates the number of bits on which the stream state field is encoded" " in the AU Header (bits)", 10, &pref_stream_state_indication); @@ -1002,7 +997,7 @@ void proto_register_ismacryp (void) void proto_reg_handoff_ismacryp(void) { - static gboolean ismacryp_prefs_initialized=FALSE; + static gboolean ismacryp_prefs_initialized = FALSE; static dissector_handle_t ismacryp_handle; static guint dynamic_payload_type; @@ -1019,13 +1014,13 @@ void proto_reg_handoff_ismacryp(void) } else { /* ismacryp_prefs_initialized = TRUE */ /* delete existing association of ismacryp with payload_type */ - if ( dynamic_payload_type > 95 ){ + if ( dynamic_payload_type > 95 ) { dissector_delete_uint("rtp.pt", dynamic_payload_type, ismacryp_handle); } } /* always do the following */ dynamic_payload_type = pref_dynamic_payload_type; /*update payload_type to new value */ - if ( dynamic_payload_type > 95 ){ + if ( dynamic_payload_type > 95 ) { dissector_add_uint("rtp.pt", dynamic_payload_type, ismacryp_handle); } diff --git a/epan/dissectors/packet-kdp.c b/epan/dissectors/packet-kdp.c index e346775289..394950d005 100644 --- a/epan/dissectors/packet-kdp.c +++ b/epan/dissectors/packet-kdp.c @@ -78,152 +78,148 @@ static int hf_kdp_dup_flag = -1; static void dissect_kdp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) { + proto_item *ti; + proto_tree *kdp_tree; guint body_len; - guint8 version = 0; + guint8 version; guint8 header_len = 0; guint8 packet_flags = 0; guint8 packet_errors = 0; guint32 sequence_number = G_MAXUINT32; guint32 ack_number = G_MAXUINT32; guint32 src_flowid = G_MAXUINT32; - int offset; col_set_str(pinfo->cinfo, COL_PROTOCOL, "KDP"); col_clear(pinfo->cinfo, COL_INFO); - /* if (tree) */ { - proto_item *ti; - proto_tree *kdp_tree, *flags_tree; - ti = NULL; - kdp_tree = NULL; - flags_tree = NULL; - ti = proto_tree_add_item(tree, proto_kdp, tvb, 0, -1, ENC_NA); - kdp_tree = proto_item_add_subtree(ti, ett_kdp); + ti = proto_tree_add_item(tree, proto_kdp, tvb, 0, -1, ENC_NA); + kdp_tree = proto_item_add_subtree(ti, ett_kdp); - version = tvb_get_guint8(tvb, 0); - if (version != 2) { - /* Version other than 2 is really SDDP in UDP */ - proto_tree_add_item(kdp_tree, hf_kdp_version, tvb, 0, 1, ENC_BIG_ENDIAN); - proto_tree_add_item(kdp_tree, hf_kdp_xml_body, tvb, 0, -1, ENC_ASCII|ENC_NA); + version = tvb_get_guint8(tvb, 0); + if (version != 2) { + /* Version other than 2 is really SDDP in UDP */ + proto_tree_add_item(kdp_tree, hf_kdp_version, tvb, 0, 1, ENC_BIG_ENDIAN); + proto_tree_add_item(kdp_tree, hf_kdp_xml_body, tvb, 0, -1, ENC_ASCII|ENC_NA); + } else { + proto_tree *flags_tree; + header_len = tvb_get_guint8(tvb, 1) * 4; + body_len = tvb_reported_length(tvb); + if (header_len > body_len) { + body_len = 0; /* malformed packet */ } else { - header_len = tvb_get_guint8(tvb, 1) * 4; - body_len = tvb_reported_length(tvb); - if (header_len > body_len) { - body_len = 0; /* malformed packet */ - } else { - body_len = body_len - header_len; - } - packet_flags = tvb_get_guint8(tvb, 2); - packet_errors = tvb_get_guint8(tvb, 3); - proto_tree_add_item(kdp_tree, hf_kdp_version, tvb, 0, 1, ENC_BIG_ENDIAN); - proto_tree_add_item(kdp_tree, hf_kdp_headerlen, tvb, 1, 1, ENC_BIG_ENDIAN); - ti = proto_tree_add_item(kdp_tree, hf_kdp_flags, tvb, 2, 1, ENC_BIG_ENDIAN); - flags_tree = proto_item_add_subtree(ti, ett_kdp_flags); - - proto_tree_add_item(flags_tree, hf_kdp_drop_flag, tvb, 2, 1, ENC_BIG_ENDIAN); - proto_tree_add_item(flags_tree, hf_kdp_syn_flag, tvb, 2, 1, ENC_BIG_ENDIAN); - proto_tree_add_item(flags_tree, hf_kdp_ack_flag, tvb, 2, 1, ENC_BIG_ENDIAN); - proto_tree_add_item(flags_tree, hf_kdp_rst_flag, tvb, 2, 1, ENC_BIG_ENDIAN); - proto_tree_add_item(flags_tree, hf_kdp_bcst_flag, tvb, 2, 1, ENC_BIG_ENDIAN); - proto_tree_add_item(flags_tree, hf_kdp_dup_flag, tvb, 2, 1, ENC_BIG_ENDIAN); + body_len = body_len - header_len; + } + packet_flags = tvb_get_guint8(tvb, 2); + packet_errors = tvb_get_guint8(tvb, 3); + proto_tree_add_item(kdp_tree, hf_kdp_version, tvb, 0, 1, ENC_BIG_ENDIAN); + proto_tree_add_item(kdp_tree, hf_kdp_headerlen, tvb, 1, 1, ENC_BIG_ENDIAN); + ti = proto_tree_add_item(kdp_tree, hf_kdp_flags, tvb, 2, 1, ENC_BIG_ENDIAN); + flags_tree = proto_item_add_subtree(ti, ett_kdp_flags); - proto_tree_add_item(kdp_tree, hf_kdp_errors, tvb, 3, 1, ENC_BIG_ENDIAN); + proto_tree_add_item(flags_tree, hf_kdp_drop_flag, tvb, 2, 1, ENC_BIG_ENDIAN); + proto_tree_add_item(flags_tree, hf_kdp_syn_flag, tvb, 2, 1, ENC_BIG_ENDIAN); + proto_tree_add_item(flags_tree, hf_kdp_ack_flag, tvb, 2, 1, ENC_BIG_ENDIAN); + proto_tree_add_item(flags_tree, hf_kdp_rst_flag, tvb, 2, 1, ENC_BIG_ENDIAN); + proto_tree_add_item(flags_tree, hf_kdp_bcst_flag, tvb, 2, 1, ENC_BIG_ENDIAN); + proto_tree_add_item(flags_tree, hf_kdp_dup_flag, tvb, 2, 1, ENC_BIG_ENDIAN); - if (header_len > 4) { - offset = 4; - if (packet_flags & KDP_ACK_FLAG) { - proto_tree_add_item(kdp_tree, hf_kdp_destflowid, tvb, offset, 4, ENC_BIG_ENDIAN); - offset = offset + 4; - } + proto_tree_add_item(kdp_tree, hf_kdp_errors, tvb, 3, 1, ENC_BIG_ENDIAN); - if (packet_flags & (KDP_SYN_FLAG | KDP_BCST_FLAG)) { - proto_tree_add_item(kdp_tree, hf_kdp_srcflowid, tvb, offset, 4, ENC_BIG_ENDIAN); - src_flowid = tvb_get_ntohl(tvb, offset); - offset = offset + 4; - } + if (header_len > 4) { + int offset; + offset = 4; + if (packet_flags & KDP_ACK_FLAG) { + proto_tree_add_item(kdp_tree, hf_kdp_destflowid, tvb, offset, 4, ENC_BIG_ENDIAN); + offset = offset + 4; + } - proto_tree_add_item(kdp_tree, hf_kdp_sequence, tvb, offset, 4, ENC_BIG_ENDIAN); - sequence_number = tvb_get_ntohl(tvb, offset); + if (packet_flags & (KDP_SYN_FLAG | KDP_BCST_FLAG)) { + proto_tree_add_item(kdp_tree, hf_kdp_srcflowid, tvb, offset, 4, ENC_BIG_ENDIAN); + src_flowid = tvb_get_ntohl(tvb, offset); offset = offset + 4; + } - if (packet_flags & KDP_ACK_FLAG) { - proto_tree_add_item(kdp_tree, hf_kdp_ack, tvb, offset, 4, ENC_BIG_ENDIAN); - ack_number = tvb_get_ntohl(tvb, offset); - offset = offset + 4; - } - if (packet_flags & KDP_SYN_FLAG) { - proto_tree_add_item(kdp_tree, hf_kdp_maxsegmentsize, tvb, offset, 4, ENC_BIG_ENDIAN); - offset = offset + 4; - } + proto_tree_add_item(kdp_tree, hf_kdp_sequence, tvb, offset, 4, ENC_BIG_ENDIAN); + sequence_number = tvb_get_ntohl(tvb, offset); + offset = offset + 4; - while (offset < ((body_len > 0) ? header_len - 4 : header_len)) { - guint8 option_number; - guint8 option_len = 0; + if (packet_flags & KDP_ACK_FLAG) { + proto_tree_add_item(kdp_tree, hf_kdp_ack, tvb, offset, 4, ENC_BIG_ENDIAN); + ack_number = tvb_get_ntohl(tvb, offset); + offset = offset + 4; + } + if (packet_flags & KDP_SYN_FLAG) { + proto_tree_add_item(kdp_tree, hf_kdp_maxsegmentsize, tvb, offset, 4, ENC_BIG_ENDIAN); + offset = offset + 4; + } - option_number = tvb_get_guint8(tvb, offset); + while (offset < ((body_len > 0) ? header_len - 4 : header_len)) { + guint8 option_number; + guint8 option_len = 0; - proto_tree_add_item(kdp_tree, hf_kdp_optionnumber, tvb, offset, 1, ENC_BIG_ENDIAN); - offset = offset + 1; - if (option_number > 0) { - option_len = tvb_get_guint8(tvb, offset); - proto_tree_add_item(kdp_tree, hf_kdp_optionlen, tvb, offset, 1, ENC_BIG_ENDIAN); - offset = offset + 1; - } + option_number = tvb_get_guint8(tvb, offset); - switch (option_number) { - case 0: - break; - case 1: - proto_tree_add_item(kdp_tree, hf_kdp_option1, tvb, offset, 2, ENC_BIG_ENDIAN); - offset = offset + 2; - break; - case 2: - proto_tree_add_item(kdp_tree, hf_kdp_option2, tvb, offset, 2, ENC_BIG_ENDIAN); - offset = offset + 2; - break; - case 3: - proto_tree_add_item(kdp_tree, hf_kdp_option3, tvb, offset, 2, ENC_BIG_ENDIAN); - offset = offset + 2; - break; - case 4: - proto_tree_add_item(kdp_tree, hf_kdp_option4, tvb, offset, 0, ENC_NA); - break; - case 5: - proto_tree_add_item(kdp_tree, hf_kdp_option5, tvb, offset, 0, ENC_NA); - break; - case 6: - proto_tree_add_item(kdp_tree, hf_kdp_option6, tvb, offset, option_len - 2, ENC_NA); - offset = offset + option_len - 2; - break; - case 7: - proto_tree_add_item(kdp_tree, hf_kdp_option7, tvb, offset, 2, ENC_BIG_ENDIAN); - offset = offset + 2; - break; - case 8: - proto_tree_add_item(kdp_tree, hf_kdp_option8, tvb, offset, 2, ENC_BIG_ENDIAN); - offset = offset + 2; - break; - case 9: - proto_tree_add_item(kdp_tree, hf_kdp_option9, tvb, offset, 2, ENC_BIG_ENDIAN); - offset = offset + 2; - break; - default: - proto_tree_add_item(kdp_tree, hf_kdp_option_unknown, tvb, offset, option_len - 2, ENC_NA); - offset = offset + option_len - 2; - break; - } + proto_tree_add_item(kdp_tree, hf_kdp_optionnumber, tvb, offset, 1, ENC_BIG_ENDIAN); + offset = offset + 1; + if (option_number > 0) { + option_len = tvb_get_guint8(tvb, offset); + proto_tree_add_item(kdp_tree, hf_kdp_optionlen, tvb, offset, 1, ENC_BIG_ENDIAN); + offset = offset + 1; } - if (body_len > 0) { - proto_tree_add_item(kdp_tree, hf_kdp_fragment, tvb, offset, 2, ENC_BIG_ENDIAN); + switch (option_number) { + case 0: + break; + case 1: + proto_tree_add_item(kdp_tree, hf_kdp_option1, tvb, offset, 2, ENC_BIG_ENDIAN); offset = offset + 2; - - proto_tree_add_item(kdp_tree, hf_kdp_fragtotal, tvb, offset, 2, ENC_BIG_ENDIAN); + break; + case 2: + proto_tree_add_item(kdp_tree, hf_kdp_option2, tvb, offset, 2, ENC_BIG_ENDIAN); offset = offset + 2; - - proto_tree_add_item(kdp_tree, hf_kdp_body, tvb, offset, -1, ENC_NA); + break; + case 3: + proto_tree_add_item(kdp_tree, hf_kdp_option3, tvb, offset, 2, ENC_BIG_ENDIAN); + offset = offset + 2; + break; + case 4: + proto_tree_add_item(kdp_tree, hf_kdp_option4, tvb, offset, 0, ENC_NA); + break; + case 5: + proto_tree_add_item(kdp_tree, hf_kdp_option5, tvb, offset, 0, ENC_NA); + break; + case 6: + proto_tree_add_item(kdp_tree, hf_kdp_option6, tvb, offset, option_len - 2, ENC_NA); + offset = offset + option_len - 2; + break; + case 7: + proto_tree_add_item(kdp_tree, hf_kdp_option7, tvb, offset, 2, ENC_BIG_ENDIAN); + offset = offset + 2; + break; + case 8: + proto_tree_add_item(kdp_tree, hf_kdp_option8, tvb, offset, 2, ENC_BIG_ENDIAN); + offset = offset + 2; + break; + case 9: + proto_tree_add_item(kdp_tree, hf_kdp_option9, tvb, offset, 2, ENC_BIG_ENDIAN); + offset = offset + 2; + break; + default: + proto_tree_add_item(kdp_tree, hf_kdp_option_unknown, tvb, offset, option_len - 2, ENC_NA); + offset = offset + option_len - 2; + break; } } + + if (body_len > 0) { + proto_tree_add_item(kdp_tree, hf_kdp_fragment, tvb, offset, 2, ENC_BIG_ENDIAN); + offset = offset + 2; + + proto_tree_add_item(kdp_tree, hf_kdp_fragtotal, tvb, offset, 2, ENC_BIG_ENDIAN); + offset = offset + 2; + + proto_tree_add_item(kdp_tree, hf_kdp_body, tvb, offset, -1, ENC_NA); + } } } /* Now that we know sequence number and optional ack number, we can diff --git a/epan/dissectors/packet-mgcp.c b/epan/dissectors/packet-mgcp.c index cc6a913d5e..797f929d7c 100644 --- a/epan/dissectors/packet-mgcp.c +++ b/epan/dissectors/packet-mgcp.c @@ -332,7 +332,7 @@ static int dissect_mgcp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, voi { gint sectionlen; guint32 num_messages; - gint tvb_sectionend,tvb_sectionbegin, tvb_len; + gint tvb_sectionend, tvb_sectionbegin, tvb_len; proto_tree *mgcp_tree, *ti; const gchar *verb_name = ""; @@ -349,7 +349,7 @@ static int dissect_mgcp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, voi * for a valid MGCP verb or response code. This isn't infallible, * but it's cheap and it's better than nothing. */ - if (is_mgcp_verb(tvb,0,tvb_len, &verb_name) || is_mgcp_rspcode(tvb,0,tvb_len)) + if (is_mgcp_verb(tvb, 0, tvb_len, &verb_name) || is_mgcp_rspcode(tvb, 0, tvb_len)) { /* * Set the columns now, so that they'll be set correctly if we throw @@ -368,7 +368,7 @@ static int dissect_mgcp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, voi if (tree) { /* Create our mgcp subtree */ - ti = proto_tree_add_item(tree,proto_mgcp,tvb,0,0, ENC_NA); + ti = proto_tree_add_item(tree, proto_mgcp, tvb, 0, 0, ENC_NA); mgcp_tree = proto_item_add_subtree(ti, ett_mgcp); } @@ -377,7 +377,7 @@ static int dissect_mgcp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, voi { dissect_mgcp_message(tvb_new_subset(tvb, tvb_sectionbegin, sectionlen, sectionlen), - pinfo, tree, mgcp_tree,ti); + pinfo, tree, mgcp_tree, ti); tvb_sectionbegin = tvb_sectionend; } else @@ -389,7 +389,7 @@ static int dissect_mgcp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, voi if (mgcp_tree) { proto_item *tii = proto_tree_add_uint(mgcp_tree, hf_mgcp_messagecount, tvb, - 0 ,0 , num_messages); + 0 , 0 , num_messages); PROTO_ITEM_SET_HIDDEN(tii); } @@ -403,16 +403,16 @@ static int dissect_mgcp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, voi { if (num_messages > 1) { - col_add_fstr(pinfo->cinfo, COL_PROTOCOL, "MGCP (%i messages)",num_messages); + col_add_fstr(pinfo->cinfo, COL_PROTOCOL, "MGCP (%i messages)", num_messages); } else { - col_add_fstr(pinfo->cinfo, COL_PROTOCOL, "MGCP (%i message)",num_messages); + col_add_fstr(pinfo->cinfo, COL_PROTOCOL, "MGCP (%i message)", num_messages); } } - sectionlen = tvb_find_line_end(tvb, tvb_sectionbegin,-1, - &tvb_sectionend,FALSE); + sectionlen = tvb_find_line_end(tvb, tvb_sectionbegin, -1, + &tvb_sectionend, FALSE); col_prepend_fstr(pinfo->cinfo, COL_INFO, "%s", tvb_format_text(tvb, tvb_sectionbegin, sectionlen)); @@ -465,7 +465,7 @@ static void dissect_mgcp_message(tvbuff_t *tvb, packet_info *pinfo, proto_tree * { /* Declare variables */ gint sectionlen; - gint tvb_sectionend,tvb_sectionbegin, tvb_len; + gint tvb_sectionend, tvb_sectionbegin, tvb_len; tvbuff_t *next_tvb; const gchar *verb_name = ""; @@ -501,12 +501,12 @@ static void dissect_mgcp_message(tvbuff_t *tvb, packet_info *pinfo, proto_tree * * for a valid MGCP verb or response code. This isn't infallible, * but it's cheap and it's better than nothing. */ - if (is_mgcp_verb(tvb,0,tvb_len,&verb_name) || is_mgcp_rspcode(tvb,0,tvb_len)) + if (is_mgcp_verb(tvb, 0, tvb_len, &verb_name) || is_mgcp_rspcode(tvb, 0, tvb_len)) { /* dissect first line */ tvb_sectionbegin = 0; tvb_sectionend = tvb_sectionbegin; - sectionlen = tvb_find_line_end(tvb,0,-1,&tvb_sectionend,FALSE); + sectionlen = tvb_find_line_end(tvb, 0, -1, &tvb_sectionend, FALSE); if (sectionlen > 0) { dissect_mgcp_firstline(tvb_new_subset(tvb, tvb_sectionbegin, @@ -530,7 +530,7 @@ static void dissect_mgcp_message(tvbuff_t *tvb, packet_info *pinfo, proto_tree * /* Set the mgcp payload length correctly so we don't include any encapsulated SDP */ sectionlen = tvb_sectionend; - proto_item_set_len(ti,sectionlen); + proto_item_set_len(ti, sectionlen); /* Display the raw text of the mgcp message if desired */ @@ -557,14 +557,14 @@ static void dissect_mgcp_message(tvbuff_t *tvb, packet_info *pinfo, proto_tree * */ static void mgcp_raw_text_add(tvbuff_t *tvb, proto_tree *tree) { - gint tvb_linebegin,tvb_lineend,tvb_len,linelen; + gint tvb_linebegin, tvb_lineend, tvb_len, linelen; tvb_linebegin = 0; tvb_len = tvb_reported_length(tvb); do { - tvb_find_line_end(tvb,tvb_linebegin,-1,&tvb_lineend,FALSE); + tvb_find_line_end(tvb, tvb_linebegin, -1, &tvb_lineend, FALSE); linelen = tvb_lineend - tvb_linebegin; proto_tree_add_format_text(tree, tvb, tvb_linebegin, linelen); tvb_linebegin = tvb_lineend; @@ -599,7 +599,7 @@ static void mgcp_init_protocol(void) */ static gboolean is_mgcp_verb(tvbuff_t *tvb, gint offset, gint maxlength, const gchar **verb_name) { - int returnvalue = FALSE; + gboolean returnvalue = FALSE; gchar word[5]; /* Read the string into 'word' and see if it looks like the start of a verb */ @@ -625,7 +625,7 @@ static gboolean is_mgcp_verb(tvbuff_t *tvb, gint offset, gint maxlength, const g /* May be whitespace after verb code - anything else is an error.. */ if (returnvalue && maxlength >= 5) { - char next = tvb_get_guint8(tvb,4); + char next = tvb_get_guint8(tvb, 4); if ((next != ' ') && (next != '\t')) { returnvalue = FALSE; @@ -651,7 +651,7 @@ static gboolean is_mgcp_verb(tvbuff_t *tvb, gint offset, gint maxlength, const g */ static gboolean is_mgcp_rspcode(tvbuff_t *tvb, gint offset, gint maxlength) { - int returnvalue = FALSE; + gboolean returnvalue = FALSE; guint8 word[4]; /* Do 1st 3 characters look like digits? */ @@ -712,22 +712,22 @@ static gboolean is_rfc2234_alpha(guint8 c) */ static gint tvb_parse_param(tvbuff_t* tvb, gint offset, gint len, int** hf) { - gint returnvalue = -1, tvb_current_offset,counter; + gint returnvalue = -1, tvb_current_offset, counter; guint8 tempchar, plus_minus; gchar **buf; tvb_current_offset = offset; *hf = NULL; - buf=NULL; + buf = NULL; if (len > 0) { - tempchar = tvb_get_guint8(tvb,tvb_current_offset); + tempchar = tvb_get_guint8(tvb, tvb_current_offset); switch (tempchar) { case 'K': - if (tvb_get_guint8(tvb,tvb_current_offset+1) != ':') + if (tvb_get_guint8(tvb, tvb_current_offset+1) != ':') { *hf = &hf_mgcp_param_invalid; break; @@ -735,7 +735,7 @@ static gint tvb_parse_param(tvbuff_t* tvb, gint offset, gint len, int** hf) *hf = &hf_mgcp_param_rspack; break; case 'B': - if (tvb_get_guint8(tvb,tvb_current_offset+1) != ':') + if (tvb_get_guint8(tvb, tvb_current_offset+1) != ':') { *hf = &hf_mgcp_param_invalid; break; @@ -743,7 +743,7 @@ static gint tvb_parse_param(tvbuff_t* tvb, gint offset, gint len, int** hf) *hf = &hf_mgcp_param_bearerinfo; break; case 'C': - if (tvb_get_guint8(tvb,tvb_current_offset+1) != ':') + if (tvb_get_guint8(tvb, tvb_current_offset+1) != ':') { *hf = &hf_mgcp_param_invalid; break; @@ -753,7 +753,7 @@ static gint tvb_parse_param(tvbuff_t* tvb, gint offset, gint len, int** hf) case 'I': tvb_current_offset++; if (len > (tvb_current_offset - offset) && - (tempchar = tvb_get_guint8(tvb,tvb_current_offset)) == ':') + (tempchar = tvb_get_guint8(tvb, tvb_current_offset)) == ':') { *hf = &hf_mgcp_param_connectionid; tvb_current_offset--; @@ -765,7 +765,7 @@ static gint tvb_parse_param(tvbuff_t* tvb, gint offset, gint len, int** hf) } break; case 'N': - if (tvb_get_guint8(tvb,tvb_current_offset+1) != ':') + if (tvb_get_guint8(tvb, tvb_current_offset+1) != ':') { *hf = &hf_mgcp_param_invalid; break; @@ -778,7 +778,7 @@ static gint tvb_parse_param(tvbuff_t* tvb, gint offset, gint len, int** hf) /* X: is RequestIdentifier */ if (len > (tvb_current_offset - offset) && - (tempchar = tvb_get_guint8(tvb,tvb_current_offset)) == ':') + (tempchar = tvb_get_guint8(tvb, tvb_current_offset)) == ':') { *hf = &hf_mgcp_param_requestid; tvb_current_offset--; @@ -787,7 +787,7 @@ static gint tvb_parse_param(tvbuff_t* tvb, gint offset, gint len, int** hf) /* X+...: or X-....: are vendor extension parameters */ else if (len > (tvb_current_offset - offset) && - ((plus_minus = tvb_get_guint8(tvb,tvb_current_offset)) == '-' || + ((plus_minus = tvb_get_guint8(tvb, tvb_current_offset)) == '-' || (plus_minus == '+'))) { /* Move past + or - */ @@ -817,7 +817,7 @@ static gint tvb_parse_param(tvbuff_t* tvb, gint offset, gint len, int** hf) } break; case 'L': - if (tvb_get_guint8(tvb,tvb_current_offset+1) != ':') + if (tvb_get_guint8(tvb, tvb_current_offset+1) != ':') { *hf = &hf_mgcp_param_invalid; break; @@ -827,7 +827,7 @@ static gint tvb_parse_param(tvbuff_t* tvb, gint offset, gint len, int** hf) case 'M': tvb_current_offset++; if (len > (tvb_current_offset - offset) && - (tempchar = tvb_get_guint8(tvb,tvb_current_offset)) == ':') + (tempchar = tvb_get_guint8(tvb, tvb_current_offset)) == ':') { *hf = &hf_mgcp_param_connectionmode; tvb_current_offset--; @@ -841,7 +841,7 @@ static gint tvb_parse_param(tvbuff_t* tvb, gint offset, gint len, int** hf) case 'R': tvb_current_offset++; if (len > (tvb_current_offset - offset) && - (tempchar = tvb_get_guint8(tvb,tvb_current_offset)) == ':') + (tempchar = tvb_get_guint8(tvb, tvb_current_offset)) == ':') { *hf = &hf_mgcp_param_reqevents; tvb_current_offset--; @@ -858,7 +858,7 @@ static gint tvb_parse_param(tvbuff_t* tvb, gint offset, gint len, int** hf) } break; case 'S': - if (tvb_get_guint8(tvb,tvb_current_offset+1) != ':') + if (tvb_get_guint8(tvb, tvb_current_offset+1) != ':') { *hf = &hf_mgcp_param_invalid; break; @@ -867,7 +867,7 @@ static gint tvb_parse_param(tvbuff_t* tvb, gint offset, gint len, int** hf) buf = &(mi->signalReq); break; case 'D': - if (tvb_get_guint8(tvb,tvb_current_offset+1) != ':') + if (tvb_get_guint8(tvb, tvb_current_offset+1) != ':') { *hf = &hf_mgcp_param_invalid; break; @@ -876,7 +876,7 @@ static gint tvb_parse_param(tvbuff_t* tvb, gint offset, gint len, int** hf) mi->hasDigitMap = TRUE; break; case 'O': - if (tvb_get_guint8(tvb,tvb_current_offset+1) != ':') + if (tvb_get_guint8(tvb, tvb_current_offset+1) != ':') { *hf = &hf_mgcp_param_invalid; break; @@ -887,7 +887,7 @@ static gint tvb_parse_param(tvbuff_t* tvb, gint offset, gint len, int** hf) case 'P': tvb_current_offset++; if (len > (tvb_current_offset - offset) && - (tempchar = tvb_get_guint8(tvb,tvb_current_offset)) == ':') + (tempchar = tvb_get_guint8(tvb, tvb_current_offset)) == ':') { *hf = &hf_mgcp_param_connectionparam; tvb_current_offset--; @@ -901,7 +901,7 @@ static gint tvb_parse_param(tvbuff_t* tvb, gint offset, gint len, int** hf) case 'E': tvb_current_offset++; if (len > (tvb_current_offset - offset) && - (tempchar = tvb_get_guint8(tvb,tvb_current_offset)) == ':') + (tempchar = tvb_get_guint8(tvb, tvb_current_offset)) == ':') { *hf = &hf_mgcp_param_reasoncode; tvb_current_offset--; @@ -915,7 +915,7 @@ static gint tvb_parse_param(tvbuff_t* tvb, gint offset, gint len, int** hf) case 'Z': tvb_current_offset++; if (len > (tvb_current_offset - offset) && - (tempchar = tvb_get_guint8(tvb,tvb_current_offset)) == ':') + (tempchar = tvb_get_guint8(tvb, tvb_current_offset)) == ':') { *hf = &hf_mgcp_param_specificendpoint; tvb_current_offset--; @@ -927,7 +927,7 @@ static gint tvb_parse_param(tvbuff_t* tvb, gint offset, gint len, int** hf) } break; case 'F': - if (tvb_get_guint8(tvb,tvb_current_offset+1) != ':') + if (tvb_get_guint8(tvb, tvb_current_offset+1) != ':') { *hf = &hf_mgcp_param_invalid; break; @@ -935,7 +935,7 @@ static gint tvb_parse_param(tvbuff_t* tvb, gint offset, gint len, int** hf) *hf = &hf_mgcp_param_reqinfo; break; case 'Q': - if (tvb_get_guint8(tvb,tvb_current_offset+1) != ':') + if (tvb_get_guint8(tvb, tvb_current_offset+1) != ':') { *hf = &hf_mgcp_param_invalid; break; @@ -943,7 +943,7 @@ static gint tvb_parse_param(tvbuff_t* tvb, gint offset, gint len, int** hf) *hf = &hf_mgcp_param_quarantinehandling; break; case 'T': - if (tvb_get_guint8(tvb,tvb_current_offset+1) != ':') + if (tvb_get_guint8(tvb, tvb_current_offset+1) != ':') { *hf = &hf_mgcp_param_invalid; break; @@ -951,7 +951,7 @@ static gint tvb_parse_param(tvbuff_t* tvb, gint offset, gint len, int** hf) *hf = &hf_mgcp_param_detectedevents; break; case 'A': - if (tvb_get_guint8(tvb,tvb_current_offset+1) != ':') + if (tvb_get_guint8(tvb, tvb_current_offset+1) != ':') { *hf = &hf_mgcp_param_invalid; break; @@ -969,10 +969,10 @@ static gint tvb_parse_param(tvbuff_t* tvb, gint offset, gint len, int** hf) /* Add a recognised parameter type if we have one */ if (*hf != NULL && len > (tvb_current_offset - offset) && - tvb_get_guint8(tvb,tvb_current_offset) == ':') + tvb_get_guint8(tvb, tvb_current_offset) == ':') { tvb_current_offset++; - tvb_current_offset = tvb_skip_wsp(tvb,tvb_current_offset, (len - tvb_current_offset + offset)); + tvb_current_offset = tvb_skip_wsp(tvb, tvb_current_offset, (len - tvb_current_offset + offset)); returnvalue = tvb_current_offset; /* set the observedEvents or signalReq used in Voip Calls analysis */ @@ -1016,7 +1016,7 @@ static gint tvb_parse_param(tvbuff_t* tvb, gint offset, gint len, int** hf) */ static void dissect_mgcp_firstline(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) { - gint tvb_current_offset,tvb_previous_offset,tvb_len,tvb_current_len; + gint tvb_current_offset, tvb_previous_offset, tvb_len, tvb_current_len; gint tokennum, tokenlen; proto_item* hidden_item; char *transid = NULL; @@ -1045,7 +1045,7 @@ static void dissect_mgcp_firstline(tvbuff_t *tvb, packet_info *pinfo, proto_tree do { - tvb_current_len = tvb_reported_length_remaining(tvb,tvb_previous_offset); + tvb_current_len = tvb_reported_length_remaining(tvb, tvb_previous_offset); tvb_current_offset = tvb_find_guint8(tvb, tvb_previous_offset, tvb_current_len, ' '); if (tvb_current_offset == -1) { @@ -1060,9 +1060,9 @@ static void dissect_mgcp_firstline(tvbuff_t *tvb, packet_info *pinfo, proto_tree { if (tokenlen > 4) THROW(ReportedBoundsError); - code = tvb_format_text(tvb,tvb_previous_offset,tokenlen); - g_strlcpy(mi->code,code,5); - if (is_mgcp_verb(tvb,tvb_previous_offset,tvb_current_len,&verb_description)) + code = tvb_format_text(tvb, tvb_previous_offset, tokenlen); + g_strlcpy(mi->code, code, 5); + if (is_mgcp_verb(tvb, tvb_previous_offset, tvb_current_len, &verb_description)) { mgcp_type = MGCP_REQUEST; if (verb_description != NULL) @@ -1077,12 +1077,12 @@ static void dissect_mgcp_firstline(tvbuff_t *tvb, packet_info *pinfo, proto_tree strlen(code_with_verb) ? code_with_verb : code); } else - if (is_mgcp_rspcode(tvb,tvb_previous_offset,tvb_current_len)) + if (is_mgcp_rspcode(tvb, tvb_previous_offset, tvb_current_len)) { mgcp_type = MGCP_RESPONSE; rspcode = atoi(code); mi->rspcode = rspcode; - proto_tree_add_uint(tree,hf_mgcp_rsp_rspcode, tvb, + proto_tree_add_uint(tree, hf_mgcp_rsp_rspcode, tvb, tvb_previous_offset, tokenlen, rspcode); } else @@ -1092,7 +1092,7 @@ static void dissect_mgcp_firstline(tvbuff_t *tvb, packet_info *pinfo, proto_tree } if (tokennum == 1) { - transid = tvb_format_text(tvb,tvb_previous_offset,tokenlen); + transid = tvb_format_text(tvb, tvb_previous_offset, tokenlen); /* XXX - what if this isn't a valid text string? */ mi->transid = (guint32)strtoul(transid, NULL, 10); proto_tree_add_string(tree, hf_mgcp_transid, tvb, @@ -1102,9 +1102,9 @@ static void dissect_mgcp_firstline(tvbuff_t *tvb, packet_info *pinfo, proto_tree { if (mgcp_type == MGCP_REQUEST) { - endpointId = tvb_format_text(tvb, tvb_previous_offset,tokenlen); + endpointId = tvb_format_text(tvb, tvb_previous_offset, tokenlen); mi->endpointId = wmem_strdup(wmem_packet_scope(), endpointId); - proto_tree_add_string(tree,hf_mgcp_req_endpoint, tvb, + proto_tree_add_string(tree, hf_mgcp_req_endpoint, tvb, tvb_previous_offset, tokenlen, endpointId); } else @@ -1132,15 +1132,15 @@ static void dissect_mgcp_firstline(tvbuff_t *tvb, packet_info *pinfo, proto_tree if (tvb_current_offset < tvb_len ) { tokenlen = tvb_find_line_end(tvb, tvb_previous_offset, - -1, &tvb_current_offset,FALSE); + -1, &tvb_current_offset, FALSE); } else { tokenlen = tvb_current_len; } - proto_tree_add_string(tree,hf_mgcp_version, tvb, + proto_tree_add_string(tree, hf_mgcp_version, tvb, tvb_previous_offset, tokenlen, - tvb_format_text(tvb,tvb_previous_offset, + tvb_format_text(tvb, tvb_previous_offset, tokenlen)); break; } @@ -1207,7 +1207,7 @@ static void dissect_mgcp_firstline(tvbuff_t *tvb, packet_info *pinfo, proto_tree mi->request_available = TRUE; mgcp_call->responded = TRUE; mi->req_num = mgcp_call->req_num; - g_strlcpy(mi->code,mgcp_call->code,5); + g_strlcpy(mi->code, mgcp_call->code, 5); item = proto_tree_add_uint_format(tree, hf_mgcp_req_frame, tvb, 0, 0, mgcp_call->req_num, "This is a response to a request in frame %u", @@ -1241,7 +1241,7 @@ static void dissect_mgcp_firstline(tvbuff_t *tvb, packet_info *pinfo, proto_tree if (tree) { proto_item* item; - item = proto_tree_add_uint(tree, hf_mgcp_dup, tvb, 0,0, mi->transid); + item = proto_tree_add_uint(tree, hf_mgcp_dup, tvb, 0, 0, mi->transid); PROTO_ITEM_SET_HIDDEN(item); item = proto_tree_add_uint(tree, hf_mgcp_rsp_dup, tvb, 0, 0, mi->transid); @@ -1334,11 +1334,11 @@ static void dissect_mgcp_firstline(tvbuff_t *tvb, packet_info *pinfo, proto_tree if (tree) { proto_item* item; - item = proto_tree_add_uint(tree, hf_mgcp_dup, tvb, 0,0, mi->transid); + item = proto_tree_add_uint(tree, hf_mgcp_dup, tvb, 0, 0, mi->transid); PROTO_ITEM_SET_HIDDEN(item); - item = proto_tree_add_uint(tree, hf_mgcp_req_dup, tvb, 0,0, mi->transid); + item = proto_tree_add_uint(tree, hf_mgcp_req_dup, tvb, 0, 0, mi->transid); PROTO_ITEM_SET_GENERATED(item); - item = proto_tree_add_uint(tree, hf_mgcp_req_dup_frame, tvb, 0,0, mi->req_num); + item = proto_tree_add_uint(tree, hf_mgcp_req_dup_frame, tvb, 0, 0, mi->req_num); PROTO_ITEM_SET_GENERATED(item); } } @@ -1358,7 +1358,7 @@ static void dissect_mgcp_firstline(tvbuff_t *tvb, packet_info *pinfo, proto_tree mgcp_call->transid = mi->transid; mgcp_call->responded = FALSE; mgcp_call->req_time=pinfo->fd->abs_ts; - g_strlcpy(mgcp_call->code,mi->code,5); + g_strlcpy(mgcp_call->code, mi->code, 5); /* Store it */ g_hash_table_insert(mgcp_calls, new_mgcp_call_key, mgcp_call); @@ -1422,30 +1422,30 @@ static void dissect_mgcp_params(tvbuff_t *tvb, proto_tree *tree) while (tvb_lineend < tvb_len) { old_lineend = tvb_lineend; - linelen = tvb_find_line_end(tvb, tvb_linebegin, -1,&tvb_lineend,FALSE); + linelen = tvb_find_line_end(tvb, tvb_linebegin, -1, &tvb_lineend, FALSE); tvb_tokenbegin = tvb_parse_param(tvb, tvb_linebegin, linelen, &my_param); if (my_param) { if (*my_param == hf_mgcp_param_connectionparam) { - tokenlen = tvb_find_line_end(tvb,tvb_tokenbegin,-1,&tvb_lineend,FALSE); + tokenlen = tvb_find_line_end(tvb, tvb_tokenbegin, -1, &tvb_lineend, FALSE); dissect_mgcp_connectionparams(mgcp_param_tree, tvb, tvb_linebegin, tvb_tokenbegin - tvb_linebegin, tokenlen); } else if (*my_param == hf_mgcp_param_localconnoptions) { - tokenlen = tvb_find_line_end(tvb,tvb_tokenbegin,-1,&tvb_lineend,FALSE); + tokenlen = tvb_find_line_end(tvb, tvb_tokenbegin, -1, &tvb_lineend, FALSE); dissect_mgcp_localconnectionoptions(mgcp_param_tree, tvb, tvb_linebegin, tvb_tokenbegin - tvb_linebegin, tokenlen); } else { - tokenlen = tvb_find_line_end(tvb,tvb_tokenbegin,-1,&tvb_lineend,FALSE); - proto_tree_add_string(mgcp_param_tree,*my_param, tvb, + tokenlen = tvb_find_line_end(tvb, tvb_tokenbegin, -1, &tvb_lineend, FALSE); + proto_tree_add_string(mgcp_param_tree, *my_param, tvb, tvb_linebegin, linelen, - tvb_format_text(tvb,tvb_tokenbegin, tokenlen)); + tvb_format_text(tvb, tvb_tokenbegin, tokenlen)); } } @@ -1464,18 +1464,14 @@ static void dissect_mgcp_connectionparams(proto_tree *parent_tree, tvbuff_t *tvb, gint offset, gint param_type_len, gint param_val_len) { proto_tree *tree = parent_tree; - proto_item *item = NULL; - gchar *tokenline = NULL; - gchar **tokens = NULL; - gchar **typval = NULL; - guint i = 0; - guint tokenlen = 0; - int hf_uint = -1; - int hf_string = -1; + gchar *tokenline; + gchar **tokens; + guint i; if (parent_tree) { + proto_item *item; item = proto_tree_add_item(parent_tree, hf_mgcp_param_connectionparam, tvb, offset, param_type_len+param_val_len, ENC_ASCII|ENC_NA); tree = proto_item_add_subtree(item, ett_mgcp_param_connectionparam); } @@ -1489,6 +1485,11 @@ dissect_mgcp_connectionparams(proto_tree *parent_tree, tvbuff_t *tvb, gint offse for (i = 0; tokens[i] != NULL; i++) { + gchar **typval; + guint tokenlen; + int hf_uint = -1; + int hf_string = -1; + tokenlen = (int)strlen(tokens[i]); typval = wmem_strsplit(wmem_packet_scope(), tokens[i], "=", 2); if ((typval[0] != NULL) && (typval[1] != NULL)) @@ -1576,18 +1577,14 @@ static void dissect_mgcp_localconnectionoptions(proto_tree *parent_tree, tvbuff_t *tvb, gint offset, gint param_type_len, gint param_val_len) { proto_tree *tree = parent_tree; - proto_item *item = NULL; - gchar *tokenline = NULL; - gchar **tokens = NULL; - gchar **typval = NULL; - guint i = 0; - guint tokenlen = 0; - int hf_uint = -1; - int hf_string = -1; + gchar *tokenline; + gchar **tokens; + guint i; if (parent_tree) { + proto_item *item; item = proto_tree_add_item(parent_tree, hf_mgcp_param_localconnoptions, tvb, offset, param_type_len+param_val_len, ENC_ASCII|ENC_NA); tree = proto_item_add_subtree(item, ett_mgcp_param_localconnectionoptions); } @@ -1600,6 +1597,11 @@ dissect_mgcp_localconnectionoptions(proto_tree *parent_tree, tvbuff_t *tvb, gint tokens = wmem_strsplit(wmem_packet_scope(), tokenline, ",", -1); for (i = 0; tokens[i] != NULL; i++) { + gchar **typval; + guint tokenlen; + int hf_uint; + int hf_string; + hf_uint = -1; hf_string = -1; @@ -1762,7 +1764,7 @@ dissect_mgcp_localconnectionoptions(proto_tree *parent_tree, tvbuff_t *tvb, gint */ static gint tvb_find_null_line(tvbuff_t* tvb, gint offset, gint len, gint* next_offset) { - gint tvb_lineend,tvb_current_len,tvb_linebegin,maxoffset; + gint tvb_lineend, tvb_current_len, tvb_linebegin, maxoffset; guint tempchar; tvb_linebegin = offset; @@ -1775,7 +1777,7 @@ static gint tvb_find_null_line(tvbuff_t* tvb, gint offset, gint len, gint* next_ } else { - tvb_current_len = tvb_reported_length_remaining(tvb,offset); + tvb_current_len = tvb_reported_length_remaining(tvb, offset); } maxoffset = (tvb_current_len - 1) + offset; @@ -1785,9 +1787,9 @@ static gint tvb_find_null_line(tvbuff_t* tvb, gint offset, gint len, gint* next_ do { tvb_linebegin = tvb_lineend; - tvb_current_len = tvb_reported_length_remaining(tvb,tvb_linebegin); - tvb_find_line_end(tvb, tvb_linebegin, tvb_current_len, &tvb_lineend,FALSE); - tempchar = tvb_get_guint8(tvb,tvb_linebegin); + tvb_current_len = tvb_reported_length_remaining(tvb, tvb_linebegin); + tvb_find_line_end(tvb, tvb_linebegin, tvb_current_len, &tvb_lineend, FALSE); + tempchar = tvb_get_guint8(tvb, tvb_linebegin); } while (tempchar != '\r' && tempchar != '\n' && tvb_lineend <= maxoffset); @@ -1799,7 +1801,7 @@ static gint tvb_find_null_line(tvbuff_t* tvb, gint offset, gint len, gint* next_ } else { - tvb_current_len = tvb_reported_length_remaining(tvb,offset); + tvb_current_len = tvb_reported_length_remaining(tvb, offset); } return tvb_current_len; @@ -1828,7 +1830,7 @@ static gint tvb_find_null_line(tvbuff_t* tvb, gint offset, gint len, gint* next_ */ static gint tvb_find_dot_line(tvbuff_t* tvb, gint offset, gint len, gint* next_offset) { - gint tvb_current_offset, tvb_current_len, maxoffset,tvb_len; + gint tvb_current_offset, tvb_current_len, maxoffset, tvb_len; guint8 tempchar; tvb_current_len = len; tvb_len = tvb_reported_length(tvb); @@ -1858,7 +1860,7 @@ static gint tvb_find_dot_line(tvbuff_t* tvb, gint offset, gint len, gint* next_o /* Do we have and characters following the . ? */ if (tvb_current_offset < maxoffset) { - tempchar = tvb_get_guint8(tvb,tvb_current_offset+1); + tempchar = tvb_get_guint8(tvb, tvb_current_offset+1); /* Are the characters that follow the dot a newline or carriage return ? */ if (tempchar == '\r' || tempchar == '\n') { @@ -1869,7 +1871,7 @@ static gint tvb_find_dot_line(tvbuff_t* tvb, gint offset, gint len, gint* next_o } else { - tempchar = tvb_get_guint8(tvb,tvb_current_offset-1); + tempchar = tvb_get_guint8(tvb, tvb_current_offset-1); /* Are the characters that follow the dot a newline or a carriage return ? */ @@ -1889,7 +1891,7 @@ static gint tvb_find_dot_line(tvbuff_t* tvb, gint offset, gint len, gint* next_o } else { - tempchar = tvb_get_guint8(tvb,tvb_current_offset-1); + tempchar = tvb_get_guint8(tvb, tvb_current_offset-1); if (tempchar == '\r' || tempchar == '\n') { break; @@ -1910,7 +1912,7 @@ static gint tvb_find_dot_line(tvbuff_t* tvb, gint offset, gint len, gint* next_o } else { - tvb_find_line_end(tvb,tvb_current_offset,tvb_current_len,next_offset,FALSE); + tvb_find_line_end(tvb, tvb_current_offset, tvb_current_len, next_offset, FALSE); } if (tvb_current_offset == offset) diff --git a/epan/dissectors/packet-netflow.c b/epan/dissectors/packet-netflow.c index 68f8a3a888..9e42ebe093 100644 --- a/epan/dissectors/packet-netflow.c +++ b/epan/dissectors/packet-netflow.c @@ -6625,7 +6625,7 @@ getprefix(const guint32 *addr, int prefix) static void netflow_init(void) { - /* keys & values are "se allocated"; se memory is freed as part of the init sequence */ + /* keys & values are allocated using 'wmem_file_scope()' as thus freed as part of the init sequence */ if (v9_v10_tmplt_table != NULL) { g_hash_table_destroy(v9_v10_tmplt_table); } diff --git a/epan/dissectors/packet-tivoconnect.c b/epan/dissectors/packet-tivoconnect.c index 0c52accb20..345c3541ab 100644 --- a/epan/dissectors/packet-tivoconnect.c +++ b/epan/dissectors/packet-tivoconnect.c @@ -11,8 +11,6 @@ * By Gerald Combs * Copyright 1998 Gerald Combs * - * Copied from README.developer - * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 @@ -37,14 +35,11 @@ #include "config.h" - #include -/* Forward declaration we need below */ void proto_reg_handoff_tivoconnect(void); void proto_register_tivoconnect(void); -/* Initialize the protocol and registered fields */ static int proto_tivoconnect = -1; static int hf_tivoconnect_flavor = -1; static int hf_tivoconnect_method = -1; @@ -54,18 +49,16 @@ static int hf_tivoconnect_identity = -1; static int hf_tivoconnect_services = -1; static int hf_tivoconnect_version = -1; -/* Initialize the subtree pointers */ static gint ett_tivoconnect = -1; -/* Code to actually dissect the packets */ static int dissect_tivoconnect(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gboolean is_tcp) { /* parsing variables */ - gchar * string = NULL; - gint length = -1; + gchar * string; + gint length; /* value strings */ - const gchar * proto_name = NULL; + const gchar * proto_name; gchar * packet_identity = NULL; gchar * packet_machine = NULL; @@ -87,12 +80,12 @@ dissect_tivoconnect(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gboolea /* if (tree) */ { /* Set up structures needed to add the protocol subtree and manage it */ - proto_item *ti = NULL; - proto_tree *tivoconnect_tree = NULL; + proto_item *ti; + proto_tree *tivoconnect_tree; /* parsing variables */ guint offset = 0; - gchar * field = NULL; + gchar * field; /* create display subtree for the protocol */ ti = proto_tree_add_item(tree, proto_tivoconnect, tvb, 0, -1, ENC_NA); @@ -100,54 +93,54 @@ dissect_tivoconnect(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gboolea tivoconnect_tree = proto_item_add_subtree(ti, ett_tivoconnect); /* process the packet */ - for ( field = strtok(string,"\n"); + for ( field = strtok(string, "\n"); field; - offset+=length, field = strtok(NULL,"\n") ) { - gchar * value = NULL; + offset += length, field = strtok(NULL, "\n") ) { + gchar * value; gint fieldlen; length = (int)strlen(field) + 1; - if ( !(value=strchr(field, '=')) ) { + if ( !(value = strchr(field, '=')) ) { /* bad packet: missing the field separator */ continue; } - *value++='\0'; - fieldlen=(int)strlen(field)+1; + *value++ = '\0'; + fieldlen = (int)strlen(field) + 1; - if ( g_ascii_strcasecmp(field,"tivoconnect") == 0 ) { + if ( g_ascii_strcasecmp(field, "tivoconnect") == 0 ) { proto_tree_add_item(tivoconnect_tree, hf_tivoconnect_flavor, tvb, offset+fieldlen, length-fieldlen-1, ENC_ASCII|ENC_NA); } - else if ( g_ascii_strcasecmp(field,"method") == 0 ) { + else if ( g_ascii_strcasecmp(field, "method") == 0 ) { proto_tree_add_item(tivoconnect_tree, hf_tivoconnect_method, tvb, offset+fieldlen, length-fieldlen-1, ENC_ASCII|ENC_NA); } - else if ( g_ascii_strcasecmp(field,"platform") == 0 ) { + else if ( g_ascii_strcasecmp(field, "platform") == 0 ) { proto_tree_add_item(tivoconnect_tree, hf_tivoconnect_platform, tvb, offset+fieldlen, length-fieldlen-1, ENC_ASCII|ENC_NA); } - else if ( g_ascii_strcasecmp(field,"machine") == 0 ) { + else if ( g_ascii_strcasecmp(field, "machine") == 0 ) { proto_tree_add_item(tivoconnect_tree, hf_tivoconnect_machine, tvb, offset+fieldlen, length-fieldlen-1, ENC_ASCII|ENC_NA); packet_machine = value; } - else if ( g_ascii_strcasecmp(field,"identity") == 0 ) { + else if ( g_ascii_strcasecmp(field, "identity") == 0 ) { proto_tree_add_item(tivoconnect_tree, hf_tivoconnect_identity, tvb, offset+fieldlen, length-fieldlen-1, ENC_ASCII|ENC_NA); packet_identity = value; } - else if ( g_ascii_strcasecmp(field,"services") == 0 ) { + else if ( g_ascii_strcasecmp(field, "services") == 0 ) { proto_tree_add_item(tivoconnect_tree, hf_tivoconnect_services, tvb, offset+fieldlen, length-fieldlen-1, ENC_ASCII|ENC_NA); } - else if ( g_ascii_strcasecmp(field,"swversion") == 0 ) { + else if ( g_ascii_strcasecmp(field, "swversion") == 0 ) { proto_tree_add_item(tivoconnect_tree, hf_tivoconnect_version, tvb, offset+fieldlen, length-fieldlen-1, ENC_ASCII|ENC_NA); @@ -179,9 +172,7 @@ dissect_tivoconnect(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gboolea } - /* If this protocol has a sub-dissector call it here, see section 1.8 */ - - return tvb_length(tvb); + return tvb_reported_length(tvb); } static int @@ -196,16 +187,9 @@ dissect_tivoconnect_udp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, voi return dissect_tivoconnect(tvb, pinfo, tree, FALSE); } -/* 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_tivoconnect(void) { - /* Setup list of header fields See Section 1.6.1 for details*/ static hf_register_info hf[] = { { &hf_tivoconnect_flavor, { "Flavor", "tivoconnect.flavor", @@ -237,16 +221,13 @@ proto_register_tivoconnect(void) "System software version", HFILL }}, }; - /* Setup protocol subtree array */ static gint *ett[] = { &ett_tivoconnect, }; - /* Register the protocol name and description */ proto_tivoconnect = proto_register_protocol("TiVoConnect Discovery Protocol", "TiVoConnect", "tivoconnect"); - /* Required function calls to register the header fields and subtrees used */ proto_register_field_array(proto_tivoconnect, hf, array_length(hf)); proto_register_subtree_array(ett, array_length(ett)); } -- cgit v1.2.3