diff --git a/epan/dissectors/packet-babel.c b/epan/dissectors/packet-babel.c index cb2507bdc6..deff931901 100644 --- a/epan/dissectors/packet-babel.c +++ b/epan/dissectors/packet-babel.c @@ -105,9 +105,9 @@ static const unsigned char v4prefix[16] = static const char * format_address(const unsigned char *prefix) { - if(prefix == NULL) + if (prefix == NULL) return "corrupt"; - else if(memcmp(prefix, v4prefix, 12) == 0) + else if (memcmp(prefix, v4prefix, 12) == 0) return ip_to_str(prefix + 12); else return ip6_to_str((const struct e_in6_addr*)prefix); @@ -127,14 +127,14 @@ network_prefix(int ae, int plen, unsigned int omitted, unsigned pb; unsigned char prefix[16]; - if(plen >= 0) + if (plen >= 0) pb = (plen + 7) / 8; - else if(ae == 1) + else if (ae == 1) pb = 4; else pb = 16; - if(pb > 16) + if (pb > 16) return -1; memset(prefix, 0, 16); @@ -142,29 +142,29 @@ network_prefix(int ae, int plen, unsigned int omitted, switch(ae) { case 0: break; case 1: - if(omitted > 4 || pb > 4 || (pb > omitted && len < pb - omitted)) + if (omitted > 4 || pb > 4 || (pb > omitted && len < pb - omitted)) return -1; memcpy(prefix, v4prefix, 12); - if(omitted) { + if (omitted) { if (dp == NULL) return -1; memcpy(prefix, dp, 12 + omitted); } - if(pb > omitted) memcpy(prefix + 12 + omitted, p, pb - omitted); + if (pb > omitted) memcpy(prefix + 12 + omitted, p, pb - omitted); break; case 2: - if(omitted > 16 || (pb > omitted && len < pb - omitted)) + if (omitted > 16 || (pb > omitted && len < pb - omitted)) return -1; - if(omitted) { + if (omitted) { if (dp == NULL) return -1; memcpy(prefix, dp, omitted); } - if(pb > omitted) memcpy(prefix + omitted, p, pb - omitted); + if (pb > omitted) memcpy(prefix + omitted, p, pb - omitted); break; case 3: - if(pb > 8 && len < pb - 8) return -1; + if (pb > 8 && len < pb - 8) return -1; prefix[0] = 0xfe; prefix[1] = 0x80; - if(pb > 8) memcpy(prefix + 8, p, pb - 8); + if (pb > 8) memcpy(prefix + 8, p, pb - 8); break; default: return -1; @@ -184,29 +184,29 @@ network_address(int ae, const unsigned char *a, unsigned int len, static int dissect_babel(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_) { - proto_item *ti; - unsigned char v4_prefix[16] = {0}, v6_prefix[16] = {0}; - int i = 0; - proto_tree *babel_tree = NULL; - guint8 version; - guint16 bodylen; + proto_item *ti; + unsigned char v4_prefix[16] = {0}, v6_prefix[16] = {0}; + int i; + proto_tree *babel_tree = NULL; + guint8 version; + guint16 bodylen; - if(tvb_length(tvb) < 4) + if (tvb_length(tvb) < 4) return 0; - if(tvb_get_guint8(tvb, 0) != 42) + if (tvb_get_guint8(tvb, 0) != 42) return 0; version = tvb_get_guint8(tvb, 1); col_set_str(pinfo->cinfo, COL_PROTOCOL, "Babel"); col_set_str(pinfo->cinfo, COL_INFO, "Babel"); - if(version != 2) { + if (version != 2) { col_add_fstr(pinfo->cinfo, COL_INFO, "Version %u", version); return 2; } - if(tree) { + if (tree) { ti = proto_tree_add_item(tree, proto_babel, tvb, 0, -1, ENC_NA); babel_tree = proto_item_add_subtree(ti, ett_babel); @@ -219,13 +219,13 @@ dissect_babel(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U bodylen = tvb_get_ntohs(tvb, 2); i = 0; - while(i < bodylen) { - guint8 type, len = 0, total_length; + while (i < bodylen) { + guint8 type, len = 0, total_length; proto_tree *message_tree = NULL; - int message = 4 + i; + int message = 4 + i; type = tvb_get_guint8(tvb, message); - if(type == MESSAGE_PAD1) + if (type == MESSAGE_PAD1) total_length = 1; else { len = tvb_get_guint8(tvb, message + 1); @@ -241,43 +241,43 @@ dissect_babel(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U val_to_str_const(type, messages, "unknown"), type); - if(tree) { + if (tree) { message_tree = proto_item_add_subtree(ti, ett_message); proto_tree_add_item(message_tree, hf_babel_message_type, tvb, message, 1, ENC_NA); } - if(type == MESSAGE_PAD1) { + if (type == MESSAGE_PAD1) { i++; continue; } - if(tree) { + if (tree) { proto_tree_add_item(message_tree, hf_babel_message_length, tvb, message + 1, 1, ENC_BIG_ENDIAN); - if(type == MESSAGE_PADN) { - } else if(type == MESSAGE_ACK_REQ) { + if (type == MESSAGE_PADN) { + } else if (type == MESSAGE_ACK_REQ) { proto_tree_add_item(message_tree, hf_babel_message_nonce, tvb, message + 4, 2, ENC_BIG_ENDIAN); proto_tree_add_item(message_tree, hf_babel_message_interval, tvb, message + 6, 2, ENC_BIG_ENDIAN); - } else if(type == MESSAGE_ACK) { + } else if (type == MESSAGE_ACK) { proto_tree_add_item(message_tree, hf_babel_message_nonce, tvb, message + 2, 2, ENC_BIG_ENDIAN); - } else if(type == MESSAGE_HELLO) { + } else if (type == MESSAGE_HELLO) { proto_tree_add_item(message_tree, hf_babel_message_seqno, tvb, message + 4, 2, ENC_BIG_ENDIAN); proto_tree_add_item(message_tree, hf_babel_message_interval, tvb, message + 6, 2, ENC_BIG_ENDIAN); - } else if(type == MESSAGE_IHU) { + } else if (type == MESSAGE_IHU) { proto_tree *subtree; - unsigned char address[16]; + unsigned char addr_str[16]; int rc = network_address(tvb_get_guint8(tvb, message + 2), tvb_get_ptr(tvb, message + 8, len - 6), len - 6, - address); + addr_str); proto_tree_add_item(message_tree, hf_babel_message_rxcost, tvb, message + 4, 2, ENC_BIG_ENDIAN); proto_tree_add_item(message_tree, hf_babel_message_interval, @@ -286,16 +286,16 @@ dissect_babel(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U tvb, message + 4, len - 2, "Address: %s", format_address(rc < 0 ? - NULL : address)); + NULL : addr_str)); subtree = proto_item_add_subtree(ti, ett_subtree); proto_tree_add_item(subtree, hf_babel_message_ae, tvb, message + 2, 1, ENC_NA); proto_tree_add_item(subtree, hf_babel_message_prefix, tvb, message + 4, len - 2, ENC_NA); - } else if(type == MESSAGE_ROUTER_ID) { + } else if (type == MESSAGE_ROUTER_ID) { proto_tree_add_item(message_tree, hf_babel_message_routerid, tvb, message + 4, 8, ENC_NA); - } else if(type == MESSAGE_NH) { + } else if (type == MESSAGE_NH) { proto_tree *subtree; unsigned char nh[16]; int rc = @@ -312,7 +312,7 @@ dissect_babel(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U tvb, message + 2, 1, ENC_NA); proto_tree_add_item(subtree, hf_babel_message_prefix, tvb, message + 4, len - 2, ENC_NA); - } else if(type == MESSAGE_UPDATE) { + } else if (type == MESSAGE_UPDATE) { proto_tree *subtree; unsigned char p[16]; @@ -325,8 +325,8 @@ dissect_babel(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U tvb_get_ptr(tvb, message + 12, len - 10), ae == 1 ? v4_prefix : v6_prefix, len - 10, p); - if(rc >= 0 && (flags & 0x80)) { - if(ae == 1) + if (rc >= 0 && (flags & 0x80)) { + if (ae == 1) memcpy(v4_prefix, p, 16); else memcpy(v6_prefix, p, 16); @@ -354,7 +354,7 @@ dissect_babel(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U tvb, message + 5, 1, ENC_NA); proto_tree_add_item(subtree, hf_babel_message_prefix, tvb, message + 12, len - 10, ENC_NA); - } else if(type == MESSAGE_REQUEST) { + } else if (type == MESSAGE_REQUEST) { proto_tree *subtree; unsigned char p[16]; guint8 plen = tvb_get_guint8(tvb, message + 3); @@ -376,7 +376,7 @@ dissect_babel(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U tvb, message + 3, 1, ENC_NA); proto_tree_add_item(subtree, hf_babel_message_prefix, tvb, message + 4, len - 2, ENC_NA); - } else if(type == MESSAGE_MH_REQUEST) { + } else if (type == MESSAGE_MH_REQUEST) { proto_tree *subtree; unsigned char p[16]; guint8 plen = tvb_get_guint8(tvb, message + 3); diff --git a/epan/dissectors/packet-bootp.c b/epan/dissectors/packet-bootp.c index 2450069503..d0905b4174 100644 --- a/epan/dissectors/packet-bootp.c +++ b/epan/dissectors/packet-bootp.c @@ -1,5 +1,6 @@ /* packet-bootp.c * Routines for BOOTP/DHCP packet disassembly + * * Copyright 1998, Gilbert Ramirez * Copyright 2004, Thomas Anders * @@ -12,6 +13,8 @@ * RFC 3396 - Encoding Long Options in the Dynamic Host Configuration Protocol (DHCPv4) * Improved opt 120 : Add support of RFC 3396 - Encoding Long Options in the Dynamic Host Configuration Protocol (DHCPv4) * Add support compression according to the encoding in Section 4.1.4 of RFC 1035 - DOMAIN NAMES - IMPLEMENTATION AND SPECIFICATION + * + * * Copyright 2012, Jerome LAFORGE * * $Id$ @@ -1865,7 +1868,7 @@ bootp_option(tvbuff_t *tvb, packet_info *pinfo, proto_tree *bp_tree, int voff, break; case 77: { /* User Class Information RFC 3004 */ guchar user_class_instance_index; - proto_item *vti; + proto_item *vtix; proto_tree *o77_v_tree; if (optlen < 2) { expert_add_info_format(pinfo, v_tree, PI_PROTOCOL, PI_ERROR, "length isn't >= 2 (length = %i)", optlen); @@ -1874,21 +1877,21 @@ bootp_option(tvbuff_t *tvb, packet_info *pinfo, proto_tree *bp_tree, int voff, optleft = optlen; for (user_class_instance_index = 0, i = 0, byte = tvb_get_guint8(tvb, optoff); i < optlen; byte = tvb_get_guint8(tvb, optoff + i), user_class_instance_index++) { /* Create subtree for instance of User Class. */ - vti = proto_tree_add_uint_format_value(v_tree, hf_bootp_option77_user_class, + vtix = proto_tree_add_uint_format_value(v_tree, hf_bootp_option77_user_class, tvb, optoff + i, byte + 1, user_class_instance_index, "[%d]", user_class_instance_index); - o77_v_tree = proto_item_add_subtree(vti, ett_bootp_option77_instance); + o77_v_tree = proto_item_add_subtree(vtix, ett_bootp_option77_instance); /* Add length for instance of User Class. */ proto_tree_add_item(o77_v_tree, hf_bootp_option77_user_class_length, tvb, optoff + i, 1, ENC_BIG_ENDIAN); if (byte == 0) { - expert_add_info_format(pinfo, vti, PI_PROTOCOL, PI_ERROR, "UC_Len_%u isn't >= 1 (UC_Len_%u = 0)", user_class_instance_index, user_class_instance_index); + expert_add_info_format(pinfo, vtix, PI_PROTOCOL, PI_ERROR, "UC_Len_%u isn't >= 1 (UC_Len_%u = 0)", user_class_instance_index, user_class_instance_index); break; } optleft -= byte + 1; if (optleft < 0) { - expert_add_info_format(pinfo, vti, PI_PROTOCOL, PI_ERROR, "User Class Information: malformed option"); + expert_add_info_format(pinfo, vtix, PI_PROTOCOL, PI_ERROR, "User Class Information: malformed option"); break; } @@ -2227,21 +2230,21 @@ bootp_option(tvbuff_t *tvb, packet_info *pinfo, proto_tree *bp_tree, int voff, if (rfc3396_dns_domain_search_list.index_current_block == rfc3396_dns_domain_search_list.total_number_of_block) { /* Here, we are into the last (or unique) option 119. */ /* We will display the information about fqdn */ - unsigned int consumed = 0; + unsigned int consumedx = 0; unsigned int offset = 0; tvb_composite_finalize(rfc3396_dns_domain_search_list.tvb_composite); while (offset < tvb_length(rfc3396_dns_domain_search_list.tvb_composite)) { /* use the get_dns_name method that manages all techniques of RFC 1035 (compression pointer and so on) */ - consumed = get_dns_name(rfc3396_dns_domain_search_list.tvb_composite, offset, tvb_length(rfc3396_dns_domain_search_list.tvb_composite), 0, &dns_name); + consumedx = get_dns_name(rfc3396_dns_domain_search_list.tvb_composite, offset, tvb_length(rfc3396_dns_domain_search_list.tvb_composite), 0, &dns_name); if (rfc3396_dns_domain_search_list.total_number_of_block == 1) { /* RFC 3396 is not used, so we can easily link the fqdn with v_tree. */ - proto_tree_add_string(v_tree, hf_bootp_option_dhcp_dns_domain_search_list_fqdn, tvb, optoff + offset, consumed, dns_name); + proto_tree_add_string(v_tree, hf_bootp_option_dhcp_dns_domain_search_list_fqdn, tvb, optoff + offset, consumedx, dns_name); } else { /* RFC 3396 is used, so the option is split into several option 119. We don't link fqdn with v_tree. */ proto_tree_add_string(v_tree, hf_bootp_option_dhcp_dns_domain_search_list_fqdn, tvb, 0, 0, dns_name); } - offset += consumed; + offset += consumedx; } rfc3396_dns_domain_search_list.tvb_composite = NULL; } @@ -2287,7 +2290,7 @@ bootp_option(tvbuff_t *tvb, packet_info *pinfo, proto_tree *bp_tree, int voff, switch (enc) { case RFC_3361_ENC_FQDN: { - unsigned int consumed = 0; + unsigned int consumedx = 0; if (tvb_length(rfc3396_sip_server.tvb_composite) < 3) { expert_add_info_format(pinfo, vti, PI_PROTOCOL, PI_ERROR, "length isn't >= 3 (len = %u)", tvb_length(rfc3396_sip_server.tvb_composite)); break; @@ -2295,16 +2298,16 @@ bootp_option(tvbuff_t *tvb, packet_info *pinfo, proto_tree *bp_tree, int voff, while (offset < tvb_length(rfc3396_sip_server.tvb_composite)) { /* use the get_dns_name method that manages all techniques of RFC 1035 (compression pointer and so on) */ - consumed = get_dns_name(rfc3396_sip_server.tvb_composite, offset, tvb_length(rfc3396_sip_server.tvb_composite), 1 /* ignore enc */, &dns_name); + consumedx = get_dns_name(rfc3396_sip_server.tvb_composite, offset, tvb_length(rfc3396_sip_server.tvb_composite), 1 /* ignore enc */, &dns_name); if (rfc3396_sip_server.total_number_of_block == 1) { /* RFC 3396 is not used, so we can easily link the fqdn with v_tree. */ - proto_tree_add_string(v_tree, hf_bootp_option_sip_server_name, tvb, optoff + offset, consumed, dns_name); + proto_tree_add_string(v_tree, hf_bootp_option_sip_server_name, tvb, optoff + offset, consumedx, dns_name); } else { /* RFC 3396 is used, so the option is split into several option 120. We don't link fqdn with v_tree. */ proto_tree_add_string(v_tree, hf_bootp_option_sip_server_name, tvb, 0, 0, dns_name); } - offset += consumed; + offset += consumedx; } rfc3396_sip_server.tvb_composite = NULL; break; diff --git a/epan/dissectors/packet-bssgp.c b/epan/dissectors/packet-bssgp.c index f6321db4cf..ed2cada036 100644 --- a/epan/dissectors/packet-bssgp.c +++ b/epan/dissectors/packet-bssgp.c @@ -6222,14 +6222,14 @@ static void (*bssgp_msg_fcn[])(tvbuff_t *tvb, proto_tree *tree, packet_info *pin NULL, /* NONE */ }; -void get_bssgp_msg_params(guint8 oct, const gchar **msg_str, int *ett_tree, int *hf_idx, msg_fcn *msg_fcn) +void get_bssgp_msg_params(guint8 oct, const gchar **msg_str, int *ett_tree, int *hf_idx, msg_fcn *msg_fcn_p) { gint idx; *msg_str = match_strval_idx_ext((guint32) (oct & 0xff), &bssgp_msg_strings_ext, &idx); *ett_tree = ett_bssgp_msg[idx]; *hf_idx = hf_bssgp_msg_type; - *msg_fcn = bssgp_msg_fcn[idx]; + *msg_fcn_p = bssgp_msg_fcn[idx]; return; } @@ -6238,14 +6238,14 @@ static void dissect_bssgp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) { - proto_item *ti; - proto_tree *bssgp_tree = NULL; - int offset = 0; - guint32 len; - const gchar *msg_str = NULL; - gint ett_tree; - int hf_idx; - void (*msg_fcn)(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, guint32 offset, guint len); + proto_item *ti; + proto_tree *bssgp_tree = NULL; + int offset = 0; + guint32 len; + const gchar *msg_str = NULL; + gint ett_tree; + int hf_idx; + void (*msg_fcn_p)(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, guint32 offset, guint len); /* Save pinfo */ gpinfo = pinfo; @@ -6265,12 +6265,12 @@ dissect_bssgp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) } /* Messge type IE*/ - msg_fcn = NULL; + msg_fcn_p = NULL; ett_tree = -1; hf_idx = -1; msg_str = NULL; - get_bssgp_msg_params(g_pdu_type, &msg_str, &ett_tree, &hf_idx, &msg_fcn); + get_bssgp_msg_params(g_pdu_type, &msg_str, &ett_tree, &hf_idx, &msg_fcn_p); if(msg_str){ col_add_fstr(pinfo->cinfo, COL_INFO, "%s", msg_str); @@ -6289,13 +6289,13 @@ dissect_bssgp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) /* * decode elements */ - if (msg_fcn == NULL) + if (msg_fcn_p == NULL) { proto_tree_add_text(bssgp_tree, tvb, offset, len - offset, "Message Elements"); } else { - (*msg_fcn)(tvb, bssgp_tree, pinfo, offset, len - offset); + (*msg_fcn_p)(tvb, bssgp_tree, pinfo, offset, len - offset); } }