From cc286bad25a9b9fcce696b0bf0bcdef2196481f2 Mon Sep 17 00:00:00 2001 From: Bill Meier Date: Wed, 10 Sep 2014 12:07:04 -0400 Subject: [PATCH] Various minor changes: - Create/use some extended value_strings - Remove unneeded #includes; - Do whitespace changes; - Add editor modelines. Change-Id: I2e1ea37dddfd5e8656c90c0d45a6596c4912bb2c Reviewed-on: https://code.wireshark.org/review/4065 Reviewed-by: Bill Meier --- epan/dissectors/packet-3g-a11.c | 44 +- epan/dissectors/packet-artnet.c | 90 +- epan/dissectors/packet-epl.c | 188 +- epan/dissectors/packet-gsm_a_common.h | 45 +- epan/dissectors/packet-gsm_a_gm.c | 140 +- epan/dissectors/packet-igmp.c | 6 +- epan/dissectors/packet-megaco.c | 68 +- epan/dissectors/packet-mux27010.c | 12 + epan/dissectors/packet-nfs.c | 18 +- epan/dissectors/packet-opensafety.c | 35 +- epan/dissectors/packet-rdm.c | 12 + epan/dissectors/packet-zbee-zcl-general.c | 13 + epan/gcp.c | 73 +- epan/gcp.h | 16 +- epan/wslua/wslua_proto.c | 25 +- wiretap/file_wrappers.c | 1927 +++++++++++---------- 16 files changed, 1430 insertions(+), 1282 deletions(-) diff --git a/epan/dissectors/packet-3g-a11.c b/epan/dissectors/packet-3g-a11.c index 193bef7fff..393115fe19 100644 --- a/epan/dissectors/packet-3g-a11.c +++ b/epan/dissectors/packet-3g-a11.c @@ -260,6 +260,7 @@ static const value_string a11_types[] = { {0, NULL}, }; +static value_string_ext a11_types_ext = VALUE_STRING_EXT_INIT(a11_types); static const value_string a11_ses_ptype_vals[] = { {0x8881, "Unstructured Byte Stream"}, @@ -312,7 +313,7 @@ static const value_string a11_reply_codes[]= { {142, "Registration Denied - nonexistent A10 or IP flow"}, {0, NULL}, }; - +static value_string_ext a11_reply_codes_ext = VALUE_STRING_EXT_INIT(a11_reply_codes); static const value_string a11_ack_status[]= { {0x00, "Update Accepted"}, @@ -328,6 +329,7 @@ static const value_string a11_ack_status[]= { {0xff, "Update Denied - handoff in progress"}, {0, NULL}, }; +static value_string_ext a11_ack_status_ext = VALUE_STRING_EXT_INIT(a11_ack_status); typedef enum { MH_AUTH_EXT = 32, @@ -357,11 +359,12 @@ static const value_string a11_ext_types[]= { {RU_AUTH_EXT, "Registration Update Authentication Extension"}, {MN_NAI_EXT, "Mobile Node NAI Extension"}, {MF_CHALLENGE_EXT, "MN-FA Challenge Extension"}, - {NVSE_EXT, "Normal Vendor/Organization Specific Extension"}, {OLD_NVSE_EXT, "Normal Vendor/Organization Specific Extension (OLD)"}, + {NVSE_EXT, "Normal Vendor/Organization Specific Extension"}, {BCMCS_EXT, "BCMCS Session Extension"}, {0, NULL}, }; +static value_string_ext a11_ext_types_ext = VALUE_STRING_EXT_INIT(a11_ext_types); static const value_string a11_ext_stypes[]= { {1, "MN AAA Extension"}, @@ -462,6 +465,7 @@ static const value_string a11_ext_app[]= { {0xB001, "System Identifiers (BSID / HRPD Subnet)"}, {0, NULL}, }; +static value_string_ext a11_ext_app_ext = VALUE_STRING_EXT_INIT(a11_ext_app); #if 0 static const value_string a11_airlink_types[]= { @@ -497,7 +501,6 @@ static const value_string a11_rohc_profile_vals[] = { 0x0003, "ROHC ESP" }, /*RFC 3095*/ { 0x0004, "ROHC IP" }, /*RFC 3843*/ { 0x0005, "ROHC LLA" }, /*RFC 3242*/ - { 0x0105, "ROHC LLA with R-mode" }, /*RFC 3408*/ { 0x0006, "ROHC TCP" }, /*RFC 4996*/ { 0x0007, "ROHC RTP/UDP-Lite" }, /*RFC 4019*/ { 0x0008, "ROHC UDP-Lite" }, /*RFC 4019*/ @@ -505,10 +508,12 @@ static const value_string a11_rohc_profile_vals[] = { 0x0102, "ROHCv2 UDP" }, /*RFC 5225*/ { 0x0103, "ROHCv2 ESP" }, /*RFC 5225*/ { 0x0104, "ROHCv2 IP" }, /*RFC 5225*/ + { 0x0105, "ROHC LLA with R-mode" }, /*RFC 3408*/ { 0x0107, "ROHCv2 RTP/UDP-Lite" }, /*RFC 5225*/ { 0x0108, "ROHCv2 UDP-Lite" }, /*RFC 5225*/ { 0, NULL }, }; +static value_string_ext a11_rohc_profile_vals_ext = VALUE_STRING_EXT_INIT(a11_rohc_profile_vals); #define NUM_ATTR (sizeof(attrs)/sizeof(struct radius_attribute)) @@ -1331,7 +1336,7 @@ dissect_a11_extensions( tvbuff_t *tvb, packet_info *pinfo, int offset, proto_tre ext_tree = proto_tree_add_subtree_format(exts_tree, tvb, offset, ext_len + hdrLen, ett_a11_ext, NULL, "Extension: %s", - val_to_str(ext_type, a11_ext_types, + val_to_str_ext(ext_type, &a11_ext_types_ext, "Unknown Extension %u")); proto_tree_add_uint(ext_tree, hf_a11_ext_type, tvb, offset, 1, ext_type); @@ -1551,7 +1556,7 @@ dissect_a11( tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_ return 0; /* not enough data to check message type */ type = tvb_get_guint8(tvb, offset); - if (try_val_to_str(type, a11_types) == NULL) + if (try_val_to_str_ext(type, &a11_types_ext) == NULL) return 0; /* not a known message type */ /* Make entries in Protocol column and Info column on summary display */ @@ -2072,7 +2077,7 @@ proto_register_a11(void) static hf_register_info hf[] = { { &hf_a11_type, { "Message Type", "a11.type", - FT_UINT8, BASE_DEC, VALS(a11_types), 0, + FT_UINT8, BASE_DEC | BASE_EXT_STRING, &a11_types_ext, 0, "A11 Message Type", HFILL } }, { &hf_a11_flags, @@ -2117,12 +2122,12 @@ proto_register_a11(void) }, { &hf_a11_code, { "Reply Code", "a11.code", - FT_UINT8, BASE_DEC, VALS(a11_reply_codes), 0, + FT_UINT8, BASE_DEC | BASE_EXT_STRING, &a11_reply_codes_ext, 0, "A11 Registration Reply code", HFILL } }, { &hf_a11_status, { "Reply Status", "a11.ackstat", - FT_UINT8, BASE_DEC, VALS(a11_ack_status), 0, + FT_UINT8, BASE_DEC | BASE_EXT_STRING, &a11_ack_status_ext, 0, "A11 Registration Ack Status", HFILL } }, { &hf_a11_life, @@ -2153,7 +2158,7 @@ proto_register_a11(void) }, { &hf_a11_ext_type, { "Extension Type", "a11.ext.type", - FT_UINT8, BASE_DEC, VALS(a11_ext_types), 0, + FT_UINT8, BASE_DEC | BASE_EXT_STRING, &a11_ext_types_ext, 0, "Mobile IP Extension Type", HFILL } }, { &hf_a11_ext_stype, @@ -2228,7 +2233,7 @@ proto_register_a11(void) }, { &hf_a11_vse_apptype, { "Application Type", "a11.ext.apptype", - FT_UINT8, BASE_HEX, VALS(a11_ext_app), 0, + FT_UINT8, BASE_HEX | BASE_EXT_STRING, &a11_ext_app_ext, 0, NULL, HFILL } }, { &hf_a11_vse_ppaddr, @@ -2263,7 +2268,7 @@ proto_register_a11(void) }, { &hf_a11_vse_code, { "Reply Code", "a11.ext.code", - FT_UINT8, BASE_DEC, VALS(a11_reply_codes), 0, + FT_UINT8, BASE_DEC | BASE_EXT_STRING, &a11_reply_codes_ext, 0, NULL, HFILL } }, /* XXX: Is this the correct filter name ?? */ @@ -2596,7 +2601,7 @@ proto_register_a11(void) { &hf_a11_ase_forward_profile, { "Forward Profile", "a11.ext.ase.forwardprofile", - FT_UINT16, BASE_DEC, VALS(a11_rohc_profile_vals), 0, + FT_UINT16, BASE_DEC | BASE_EXT_STRING, &a11_rohc_profile_vals_ext, 0, NULL, HFILL } }, @@ -2633,7 +2638,7 @@ proto_register_a11(void) { &hf_a11_ase_reverse_profile, { "Reverse Profile", "a11.ext.ase.reverseprofile", - FT_UINT16, BASE_DEC, VALS(a11_rohc_profile_vals), 0, + FT_UINT16, BASE_DEC | BASE_EXT_STRING, &a11_rohc_profile_vals_ext, 0, NULL, HFILL } }, { &hf_a11_aut_flow_prof_sub_type, @@ -2753,3 +2758,16 @@ proto_reg_handoff_a11(void) /* 3GPP2-Authorized-Flow-Profile-IDs(131) */ radius_register_avp_dissector(VENDOR_THE3GPP2, 131, dissect_3gpp2_radius_aut_flow_profile_ids); } + +/* + * Editor modelines - http://www.wireshark.org/tools/modelines.html + * + * Local variables: + * c-basic-offset: 4 + * tab-width: 8 + * indent-tabs-mode: nil + * End: + * + * vi: set shiftwidth=4 tabstop=8 expandtab: + * :indentSize=4:tabSize=8:noTabs=true: + */ diff --git a/epan/dissectors/packet-artnet.c b/epan/dissectors/packet-artnet.c index 938e45e9ef..7a5a392414 100644 --- a/epan/dissectors/packet-artnet.c +++ b/epan/dissectors/packet-artnet.c @@ -31,7 +31,7 @@ /* * See * - * http://www.artisticlicence.com/WebSiteMaster/User%20Guides/art-net.pdf + * http://www.artisticlicence.com/WebSiteMaster/User%20Guides/art-net.pdf */ void proto_register_artnet(void); @@ -143,6 +143,7 @@ static const value_string artnet_opcode_vals[] = { { ARTNET_OP_IP_PROG_REPLY, "ArtIpProgReply" }, { 0, NULL } }; +static value_string_ext artnet_opcode_vals_ext = VALUE_STRING_EXT_INIT(artnet_opcode_vals); static const value_string artnet_oem_code_vals[] = { { 0x0000, "Artistic Licence:DMX-Hub:4x DMX in,4x DMX out" }, @@ -1919,15 +1920,15 @@ dissect_artnet_tod_request(tvbuff_t *tvb, guint offset, proto_tree *tree) guint8 ad_count; proto_tree_add_item(tree, hf_artnet_filler, tvb, - offset, 2, ENC_NA); + offset, 2, ENC_NA); offset += 2; proto_tree_add_item(tree, hf_artnet_spare, tvb, - offset, 8, ENC_NA); + offset, 8, ENC_NA); offset += 8; proto_tree_add_item(tree, hf_artnet_tod_request_command, tvb, - offset, 1, ENC_BIG_ENDIAN); + offset, 1, ENC_BIG_ENDIAN); offset += 1; ad_count = tvb_get_guint8(tvb, offset); @@ -1936,7 +1937,7 @@ dissect_artnet_tod_request(tvbuff_t *tvb, guint offset, proto_tree *tree) offset += 1; proto_tree_add_item(tree, hf_artnet_tod_request_address, tvb, - offset, ad_count, ENC_NA); + offset, ad_count, ENC_NA); offset += ad_count; return offset; @@ -1948,31 +1949,31 @@ dissect_artnet_tod_data(tvbuff_t *tvb, guint offset, proto_tree *tree) guint8 i, uid_count; proto_tree_add_item(tree, hf_artnet_filler, tvb, - offset, 1, ENC_NA); + offset, 1, ENC_NA); offset += 1; proto_tree_add_item(tree, hf_artnet_tod_data_port, tvb, - offset, 1, ENC_BIG_ENDIAN); + offset, 1, ENC_BIG_ENDIAN); offset += 1; proto_tree_add_item(tree, hf_artnet_spare, tvb, - offset, 8, ENC_NA); + offset, 8, ENC_NA); offset += 8; proto_tree_add_item(tree, hf_artnet_tod_data_command_response, tvb, - offset, 1, ENC_BIG_ENDIAN); + offset, 1, ENC_BIG_ENDIAN); offset += 1; proto_tree_add_item(tree, hf_artnet_tod_data_address, tvb, - offset, 1, ENC_BIG_ENDIAN); + offset, 1, ENC_BIG_ENDIAN); offset += 1; proto_tree_add_item(tree, hf_artnet_tod_data_uid_total, tvb, - offset, 2, ENC_BIG_ENDIAN); + offset, 2, ENC_BIG_ENDIAN); offset += 2; proto_tree_add_item(tree, hf_artnet_tod_data_block_count, tvb, - offset, 1, ENC_BIG_ENDIAN); + offset, 1, ENC_BIG_ENDIAN); offset += 1; uid_count = tvb_get_guint8(tvb, offset); @@ -1994,19 +1995,19 @@ static guint dissect_artnet_tod_control(tvbuff_t *tvb, guint offset, proto_tree *tree) { proto_tree_add_item(tree, hf_artnet_filler, tvb, - offset, 2, ENC_NA); + offset, 2, ENC_NA); offset += 2; proto_tree_add_item(tree, hf_artnet_spare, tvb, - offset, 8, ENC_NA); + offset, 8, ENC_NA); offset += 8; proto_tree_add_item(tree, hf_artnet_tod_control_command, tvb, - offset, 1, ENC_BIG_ENDIAN); + offset, 1, ENC_BIG_ENDIAN); offset += 1; proto_tree_add_item(tree, hf_artnet_tod_control_address, tvb, - offset, 1, ENC_BIG_ENDIAN); + offset, 1, ENC_BIG_ENDIAN); offset += 1; return offset; @@ -2024,11 +2025,11 @@ dissect_artnet_rdm(tvbuff_t *tvb, guint offset, proto_tree *tree, packet_info * rdmver = tvb_get_guint8(tvb, offset); if (rdmver == 0x00) { proto_tree_add_item(tree, hf_artnet_filler, tvb, - offset, 2, ENC_NA); + offset, 2, ENC_NA); offset += 2; proto_tree_add_item(tree, hf_artnet_spare, tvb, - offset, 8, ENC_NA); + offset, 8, ENC_NA); offset += 8; } else { proto_tree_add_item(tree, hf_artnet_rdm_rdmver, tvb, @@ -2049,11 +2050,11 @@ dissect_artnet_rdm(tvbuff_t *tvb, guint offset, proto_tree *tree, packet_info * } proto_tree_add_item(tree, hf_artnet_rdm_command, tvb, - offset, 1, ENC_BIG_ENDIAN); + offset, 1, ENC_BIG_ENDIAN); offset += 1; proto_tree_add_item(tree, hf_artnet_rdm_address, tvb, - offset, 1, ENC_BIG_ENDIAN); + offset, 1, ENC_BIG_ENDIAN); offset += 1; /* check for old version that included the 0xCC startcode @@ -2063,7 +2064,7 @@ dissect_artnet_rdm(tvbuff_t *tvb, guint offset, proto_tree *tree, packet_info * if (sc == 0xCC) { proto_tree_add_item(tree, hf_artnet_rdm_sc, tvb, - offset, 1, ENC_BIG_ENDIAN); + offset, 1, ENC_BIG_ENDIAN); offset += 1; } @@ -2151,11 +2152,11 @@ dissect_artnet_ip_prog(tvbuff_t *tvb, guint offset, proto_tree *tree) { proto_tree *flags_tree, *flags_item; proto_tree_add_item(tree, hf_artnet_filler, tvb, - offset, 2, ENC_NA); + offset, 2, ENC_NA); offset += 2; flags_item = proto_tree_add_item(tree, hf_artnet_ip_prog_command, tvb, - offset, 1, ENC_BIG_ENDIAN); + offset, 1, ENC_BIG_ENDIAN); flags_tree = proto_item_add_subtree(flags_item, ett_artnet); proto_tree_add_item(flags_tree, hf_artnet_ip_prog_command_prog_port, tvb, offset, 1, ENC_BIG_ENDIAN); @@ -2168,23 +2169,23 @@ dissect_artnet_ip_prog(tvbuff_t *tvb, guint offset, proto_tree *tree) { offset += 1; proto_tree_add_item(tree, hf_artnet_filler, tvb, - offset, 1, ENC_NA); + offset, 1, ENC_NA); offset += 1; proto_tree_add_item(tree, hf_artnet_ip_prog_ip, tvb, - offset, 4, ENC_BIG_ENDIAN); + offset, 4, ENC_BIG_ENDIAN); offset += 4; proto_tree_add_item(tree, hf_artnet_ip_prog_sm, tvb, - offset, 4, ENC_BIG_ENDIAN); + offset, 4, ENC_BIG_ENDIAN); offset += 4; proto_tree_add_item(tree, hf_artnet_ip_prog_port, tvb, - offset, 2, ENC_BIG_ENDIAN); + offset, 2, ENC_BIG_ENDIAN); offset += 2; proto_tree_add_item(tree, hf_artnet_spare, tvb, - offset, 8, ENC_NA); + offset, 8, ENC_NA); offset += 8; return offset; @@ -2202,15 +2203,15 @@ dissect_artnet_ip_prog_reply(tvbuff_t *tvb, guint offset, proto_tree *tree) offset += 4; proto_tree_add_item(tree, hf_artnet_ip_prog_reply_sm, tvb, - offset, 4, ENC_BIG_ENDIAN); + offset, 4, ENC_BIG_ENDIAN); offset += 4; proto_tree_add_item(tree, hf_artnet_ip_prog_reply_port, tvb, - offset, 2, ENC_BIG_ENDIAN); + offset, 2, ENC_BIG_ENDIAN); offset += 2; proto_tree_add_item(tree, hf_artnet_spare, tvb, - offset, 8, ENC_NA); + offset, 8, ENC_NA); offset += 8; return offset; @@ -2241,10 +2242,10 @@ dissect_artnet_diag_data(tvbuff_t *tvb, guint offset, proto_tree *tree) offset, 2, ENC_NA); offset += 2; - length = tvb_get_ntohs(tvb, offset); - proto_tree_add_item(tree, hf_artnet_diag_data_length, tvb, - offset, 2, ENC_NA); - offset+=2; + length = tvb_get_ntohs(tvb, offset); + proto_tree_add_item(tree, hf_artnet_diag_data_length, tvb, + offset, 2, ENC_NA); + offset+=2; proto_tree_add_item(tree, hf_artnet_diag_data_data, tvb, offset, length, ENC_ASCII|ENC_NA); @@ -2465,13 +2466,13 @@ dissect_artnet(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) { opcode = tvb_get_letohs(tvb, offset); col_add_fstr(pinfo->cinfo, COL_INFO, "%s (0x%04x)", - val_to_str_const(opcode, artnet_opcode_vals, "Unknown"), opcode); + val_to_str_ext_const(opcode, &artnet_opcode_vals_ext, "Unknown"), opcode); if (tree) { proto_tree_add_uint(artnet_header_tree, hf_artnet_header_opcode, tvb, offset, 2, opcode); - proto_item_append_text(ti, ", Opcode: %s (0x%04x)", val_to_str_const(opcode, artnet_opcode_vals, "Unknown"), opcode); + proto_item_append_text(ti, ", Opcode: %s (0x%04x)", val_to_str_ext_const(opcode, &artnet_opcode_vals_ext, "Unknown"), opcode); } offset += 2; @@ -3193,7 +3194,7 @@ proto_register_artnet(void) { { &hf_artnet_header_opcode, { "Opcode", "artnet.header.opcode", - FT_UINT16, BASE_HEX, VALS(artnet_opcode_vals), 0x0, + FT_UINT16, BASE_HEX | BASE_EXT_STRING, &artnet_opcode_vals_ext, 0x0, "Art-Net message type", HFILL }}, { &hf_artnet_header_protver, @@ -4336,3 +4337,16 @@ proto_reg_handoff_artnet(void) { heur_dissector_add("udp", dissect_artnet_heur, proto_artnet); } + +/* + * Editor modelines + * + * Local Variables: + * c-basic-offset: 2 + * tab-width: 8 + * indent-tabs-mode: nil + * End: + * + * ex: set shiftwidth=2 tabstop=8 expandtab: + * :indentSize=2:tabSize=8:noTabs=true: + */ diff --git a/epan/dissectors/packet-epl.c b/epan/dissectors/packet-epl.c index 0fb89a9c72..1dbf6ab773 100644 --- a/epan/dissectors/packet-epl.c +++ b/epan/dissectors/packet-epl.c @@ -67,7 +67,7 @@ static heur_dissector_list_t heur_epl_data_subdissector_list; #if 0 /* Container for tapping relevant data */ typedef struct _epl_info_t { - unsigned char epl_mtyp; + unsigned char epl_mtyp; } epl_info_t; #endif @@ -79,21 +79,21 @@ typedef struct _epl_info_t { #define EPL_BROADCAST_NODEID 255 static const value_string addr_str_vals[] = { - {EPL_INVALID_NODEID, " (invalid)" }, - {EPL_MN_NODEID, " (Managing Node)" }, - {EPL_DIAGNOSTIC_DEVICE_NODEID, " (Diagnostic Device)" }, - {EPL_TO_LEGACY_ETHERNET_ROUTER_NODEID, " (EPL to legacy Ethernet Router)" }, - {EPL_BROADCAST_NODEID, " (broadcast)" }, - {0,NULL} + {EPL_INVALID_NODEID, " (invalid)" }, + {EPL_MN_NODEID, " (Managing Node)" }, + {EPL_DIAGNOSTIC_DEVICE_NODEID, " (Diagnostic Device)" }, + {EPL_TO_LEGACY_ETHERNET_ROUTER_NODEID, " (EPL to legacy Ethernet Router)" }, + {EPL_BROADCAST_NODEID, " (broadcast)" }, + {0,NULL} }; static const value_string addr_str_abbr_vals[] _U_ = { - {EPL_INVALID_NODEID, " (inv.)" }, - {EPL_MN_NODEID, " (MN)" }, - {EPL_DIAGNOSTIC_DEVICE_NODEID, " (diag.)" }, - {EPL_TO_LEGACY_ETHERNET_ROUTER_NODEID, " (router)" }, - {EPL_BROADCAST_NODEID, " (bc)" }, - {0,NULL} + {EPL_INVALID_NODEID, " (inv.)" }, + {EPL_MN_NODEID, " (MN)" }, + {EPL_DIAGNOSTIC_DEVICE_NODEID, " (diag.)" }, + {EPL_TO_LEGACY_ETHERNET_ROUTER_NODEID, " (router)" }, + {EPL_BROADCAST_NODEID, " (bc)" }, + {0,NULL} }; /* static const gchar* addr_str_abbr_cn = " (CN)"; @@ -132,13 +132,13 @@ static const gchar* addr_str_abbr_res = " (res.)"; #define EPL_AINV 0x0D static const value_string mtyp_vals[] = { - {EPL_SOC, "Start of Cycle (SoC)" }, - {EPL_PREQ, "PollRequest (PReq)" }, - {EPL_PRES, "PollResponse (PRes)" }, - {EPL_SOA, "Start of Asynchronous (SoA)" }, - {EPL_ASND, "Asynchronous Send (ASnd)" }, - {EPL_AINV, "Asynchronous Invite (AInv)" }, - {0,NULL} + {EPL_SOC, "Start of Cycle (SoC)" }, + {EPL_PREQ, "PollRequest (PReq)" }, + {EPL_PRES, "PollResponse (PRes)" }, + {EPL_SOA, "Start of Asynchronous (SoA)" }, + {EPL_ASND, "Asynchronous Send (ASnd)" }, + {EPL_AINV, "Asynchronous Invite (AInv)" }, + {0,NULL} }; #define EPL_SOC_MC_MASK 0x80 @@ -154,13 +154,13 @@ static const value_string mtyp_vals[] = { #define EPL_SOA_UNSPECIFIEDINVITE 255 static const value_string soa_svid_vals[] = { - {EPL_SOA_NOSERVICE, "NoService" }, - {EPL_SOA_IDENTREQUEST, "IdentRequest" }, - {EPL_SOA_STATUSREQUEST, "StatusRequest" }, - {EPL_SOA_NMTREQUESTINVITE, "NMTRequestInvite" }, - {EPL_SOA_SYNCREQUEST, "SyncRequest" }, - {EPL_SOA_UNSPECIFIEDINVITE, "UnspecifiedInvite"}, - {0,NULL} + {EPL_SOA_NOSERVICE, "NoService" }, + {EPL_SOA_IDENTREQUEST, "IdentRequest" }, + {EPL_SOA_STATUSREQUEST, "StatusRequest" }, + {EPL_SOA_NMTREQUESTINVITE, "NMTRequestInvite" }, + {EPL_SOA_SYNCREQUEST, "SyncRequest" }, + {EPL_SOA_UNSPECIFIEDINVITE, "UnspecifiedInvite"}, + {0,NULL} }; /* ServiceID values for EPL message type "ASnd" */ @@ -172,13 +172,13 @@ static const value_string soa_svid_vals[] = { #define EPL_ASND_SYNCRESPONSE 6 static const value_string asnd_svid_vals[] = { - {EPL_ASND_IDENTRESPONSE, "IdentResponse" }, - {EPL_ASND_STATUSRESPONSE, "StatusResponse"}, - {EPL_ASND_NMTREQUEST, "NMTRequest" }, - {EPL_ASND_NMTCOMMAND, "NMTCommand" }, - {EPL_ASND_SDO, "SDO" }, - {EPL_ASND_SYNCRESPONSE, "SyncResponse" }, - {0,NULL} + {EPL_ASND_IDENTRESPONSE, "IdentResponse" }, + {EPL_ASND_STATUSRESPONSE, "StatusResponse"}, + {EPL_ASND_NMTREQUEST, "NMTRequest" }, + {EPL_ASND_NMTCOMMAND, "NMTCommand" }, + {EPL_ASND_SDO, "SDO" }, + {EPL_ASND_SYNCRESPONSE, "SyncResponse" }, + {0,NULL} }; /* NMTCommand values for EPL message type "ASnd" */ @@ -214,39 +214,39 @@ static const value_string asnd_svid_vals[] = { #define EPL_ASND_NMTCOMMAND_NMTINVALIDSERVICE 0xFF static const value_string asnd_cid_vals[] = { - /* "special" values to cover all possibilities of CommandID in NMTRequests */ - {EPL_ASND_IDENTRESPONSE, "IdentResponse" }, - {EPL_ASND_STATUSRESPONSE, "StatusResponse" }, - /* ... */ - {EPL_ASND_NMTCOMMAND_NMTSTARTNODE, "NMTStartNode" }, - {EPL_ASND_NMTCOMMAND_NMTSTOPNODE, "NMTStopNode" }, - {EPL_ASND_NMTCOMMAND_NMTENTERPREOPERATIONAL2, "NMTEnterPreOperational2" }, - {EPL_ASND_NMTCOMMAND_NMTENABLEREADYTOOPERATE, "NMTEnableReadyToOperate" }, - {EPL_ASND_NMTCOMMAND_NMTRESETNODE, "NMTResetNode" }, - {EPL_ASND_NMTCOMMAND_NMTRESETCOMMUNICATION, "NMTResetCommunication" }, - {EPL_ASND_NMTCOMMAND_NMTRESETCONFIGURATION, "NMTResetConfiguration" }, - {EPL_ASND_NMTCOMMAND_NMTSWRESET, "NMTSwReset" }, - {EPL_ASND_NMTCOMMAND_NMTSTARTNODEEX, "NMTStartNodeEx" }, - {EPL_ASND_NMTCOMMAND_NMTSTOPNODEEX, "NMTStopNodeEx" }, - {EPL_ASND_NMTCOMMAND_NMTENTERPREOPERATIONAL2EX, "NMTEnterPreOperational2Ex" }, - {EPL_ASND_NMTCOMMAND_NMTENABLEREADYTOOPERATEEX, "NMTEnableReadyToOperateEx" }, - {EPL_ASND_NMTCOMMAND_NMTRESETNODEEX, "NMTResetNodeEx" }, - {EPL_ASND_NMTCOMMAND_NMTRESETCOMMUNICATIONEX, "NMTCommunicationEx" }, - {EPL_ASND_NMTCOMMAND_NMTRESETCONFIGURATIONEX, "NMTResetConfigurationEx" }, - {EPL_ASND_NMTCOMMAND_NMTSWRESETEX, "NMTSwResetEx" }, - {EPL_ASND_NMTCOMMAND_NMTNETHOSTNAMESET, "NMTNetHostNameSet" }, - {EPL_ASND_NMTCOMMAND_NMTFLUSHARPENTRY, "NMTFlushArpEntry" }, - {EPL_ASND_NMTCOMMAND_NMTPUBLISHCONFIGUREDNODES, "NMTPublishConfiguredNodes" }, - {EPL_ASND_NMTCOMMAND_NMTPUBLISHACTIVENODES, "NMTPublishActiveNodes" }, - {EPL_ASND_NMTCOMMAND_NMTPUBLISHPREOPERATIONAL1, "NMTPublishPreOperational1" }, - {EPL_ASND_NMTCOMMAND_NMTPUBLISHPREOPERATIONAL2, "NMTPublishPreOperational2" }, - {EPL_ASND_NMTCOMMAND_NMTPUBLISHREADYTOOPERATE, "NMTPublishReadyToOperate" }, - {EPL_ASND_NMTCOMMAND_NMTPUBLISHOPERATIONAL, "NMTPublishOperational" }, - {EPL_ASND_NMTCOMMAND_NMTPUBLISHSTOPPED, "NMTPublishStopped" }, - {EPL_ASND_NMTCOMMAND_NMTPUBLISHEMERGENCYNEW, "NMTPublishEmergencyNew" }, - {EPL_ASND_NMTCOMMAND_NMTPUBLISHTIME, "NMTPublishTime" }, - {EPL_ASND_NMTCOMMAND_NMTINVALIDSERVICE, "NMTInvalidService" }, - {0,NULL} + /* "special" values to cover all possibilities of CommandID in NMTRequests */ + {EPL_ASND_IDENTRESPONSE, "IdentResponse" }, + {EPL_ASND_STATUSRESPONSE, "StatusResponse" }, + /* ... */ + {EPL_ASND_NMTCOMMAND_NMTSTARTNODE, "NMTStartNode" }, + {EPL_ASND_NMTCOMMAND_NMTSTOPNODE, "NMTStopNode" }, + {EPL_ASND_NMTCOMMAND_NMTENTERPREOPERATIONAL2, "NMTEnterPreOperational2" }, + {EPL_ASND_NMTCOMMAND_NMTENABLEREADYTOOPERATE, "NMTEnableReadyToOperate" }, + {EPL_ASND_NMTCOMMAND_NMTRESETNODE, "NMTResetNode" }, + {EPL_ASND_NMTCOMMAND_NMTRESETCOMMUNICATION, "NMTResetCommunication" }, + {EPL_ASND_NMTCOMMAND_NMTRESETCONFIGURATION, "NMTResetConfiguration" }, + {EPL_ASND_NMTCOMMAND_NMTSWRESET, "NMTSwReset" }, + {EPL_ASND_NMTCOMMAND_NMTSTARTNODEEX, "NMTStartNodeEx" }, + {EPL_ASND_NMTCOMMAND_NMTSTOPNODEEX, "NMTStopNodeEx" }, + {EPL_ASND_NMTCOMMAND_NMTENTERPREOPERATIONAL2EX, "NMTEnterPreOperational2Ex" }, + {EPL_ASND_NMTCOMMAND_NMTENABLEREADYTOOPERATEEX, "NMTEnableReadyToOperateEx" }, + {EPL_ASND_NMTCOMMAND_NMTRESETNODEEX, "NMTResetNodeEx" }, + {EPL_ASND_NMTCOMMAND_NMTRESETCOMMUNICATIONEX, "NMTCommunicationEx" }, + {EPL_ASND_NMTCOMMAND_NMTRESETCONFIGURATIONEX, "NMTResetConfigurationEx" }, + {EPL_ASND_NMTCOMMAND_NMTSWRESETEX, "NMTSwResetEx" }, + {EPL_ASND_NMTCOMMAND_NMTNETHOSTNAMESET, "NMTNetHostNameSet" }, + {EPL_ASND_NMTCOMMAND_NMTFLUSHARPENTRY, "NMTFlushArpEntry" }, + {EPL_ASND_NMTCOMMAND_NMTPUBLISHCONFIGUREDNODES, "NMTPublishConfiguredNodes" }, + {EPL_ASND_NMTCOMMAND_NMTPUBLISHACTIVENODES, "NMTPublishActiveNodes" }, + {EPL_ASND_NMTCOMMAND_NMTPUBLISHPREOPERATIONAL1, "NMTPublishPreOperational1" }, + {EPL_ASND_NMTCOMMAND_NMTPUBLISHPREOPERATIONAL2, "NMTPublishPreOperational2" }, + {EPL_ASND_NMTCOMMAND_NMTPUBLISHREADYTOOPERATE, "NMTPublishReadyToOperate" }, + {EPL_ASND_NMTCOMMAND_NMTPUBLISHOPERATIONAL, "NMTPublishOperational" }, + {EPL_ASND_NMTCOMMAND_NMTPUBLISHSTOPPED, "NMTPublishStopped" }, + {EPL_ASND_NMTCOMMAND_NMTPUBLISHEMERGENCYNEW, "NMTPublishEmergencyNew" }, + {EPL_ASND_NMTCOMMAND_NMTPUBLISHTIME, "NMTPublishTime" }, + {EPL_ASND_NMTCOMMAND_NMTINVALIDSERVICE, "NMTInvalidService" }, + {0,NULL} }; static value_string_ext asnd_cid_vals_ext = VALUE_STRING_EXT_INIT(asnd_cid_vals); @@ -294,15 +294,15 @@ static epl_sdo_reassembly epl_asnd_sdo_reassembly_read; #define EPL_PR_NMTREQUEST 0x07 static const value_string epl_pr_vals[] = { - {0, "lowest"}, - {1, "lower"}, - {2, "below generic"}, - {EPL_PR_GENERICREQUEST, "GenericRequest"}, - {4, "above generic"}, - {5, "higher"}, - {6, "below NMTRequest"}, - {EPL_PR_NMTREQUEST, "NMTRequest"}, - {0,NULL} + {0, "lowest"}, + {1, "lower"}, + {2, "below generic"}, + {EPL_PR_GENERICREQUEST, "GenericRequest"}, + {4, "above generic"}, + {5, "higher"}, + {6, "below NMTRequest"}, + {EPL_PR_NMTREQUEST, "NMTRequest"}, + {0,NULL} }; /* NMT State values (for CN)*/ @@ -319,18 +319,18 @@ static const value_string epl_pr_vals[] = { #define EPL_NMT_CS_BASIC_ETHERNET 0x1E static const value_string epl_nmt_cs_vals[] = { - {EPL_NMT_GS_OFF, "NMT_GS_OFF" }, - {EPL_NMT_GS_INITIALIZING, "NMT_GS_INITIALIZING" }, - {EPL_NMT_GS_RESET_APPLICATION, "NMT_GS_RESET_APPLICATION" }, - {EPL_NMT_GS_RESET_COMMUNICATION, "NMT_GS_RESET_COMMUNICATION"}, - {EPL_NMT_CS_NOT_ACTIVE, "NMT_CS_NOT_ACTIVE" }, - {EPL_NMT_CS_PRE_OPERATIONAL_1, "NMT_CS_PRE_OPERATIONAL_1" }, - {EPL_NMT_CS_PRE_OPERATIONAL_2, "NMT_CS_PRE_OPERATIONAL_2" }, - {EPL_NMT_CS_READY_TO_OPERATE, "NMT_CS_READY_TO_OPERATE" }, - {EPL_NMT_CS_OPERATIONAL, "NMT_CS_OPERATIONAL" }, - {EPL_NMT_CS_STOPPED, "NMT_CS_STOPPED" }, - {EPL_NMT_CS_BASIC_ETHERNET, "NMT_CS_BASIC_ETHERNET" }, - {0,NULL} + {EPL_NMT_GS_OFF, "NMT_GS_OFF" }, + {EPL_NMT_GS_INITIALIZING, "NMT_GS_INITIALIZING" }, + {EPL_NMT_GS_RESET_APPLICATION, "NMT_GS_RESET_APPLICATION" }, + {EPL_NMT_GS_RESET_COMMUNICATION, "NMT_GS_RESET_COMMUNICATION"}, + {EPL_NMT_CS_NOT_ACTIVE, "NMT_CS_NOT_ACTIVE" }, + {EPL_NMT_CS_PRE_OPERATIONAL_1, "NMT_CS_PRE_OPERATIONAL_1" }, + {EPL_NMT_CS_PRE_OPERATIONAL_2, "NMT_CS_PRE_OPERATIONAL_2" }, + {EPL_NMT_CS_READY_TO_OPERATE, "NMT_CS_READY_TO_OPERATE" }, + {EPL_NMT_CS_OPERATIONAL, "NMT_CS_OPERATIONAL" }, + {EPL_NMT_CS_STOPPED, "NMT_CS_STOPPED" }, + {EPL_NMT_CS_BASIC_ETHERNET, "NMT_CS_BASIC_ETHERNET" }, + {0,NULL} }; /* NMT State values (for MN)*/ @@ -1500,13 +1500,13 @@ dissect_eplpdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gboolean udp static int dissect_epl(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_) { - return dissect_eplpdu(tvb, pinfo, tree, FALSE); + return dissect_eplpdu(tvb, pinfo, tree, FALSE); } static int dissect_epludp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_) { - return dissect_eplpdu(tvb, pinfo, tree, TRUE); + return dissect_eplpdu(tvb, pinfo, tree, TRUE); } @@ -2671,7 +2671,7 @@ dissect_epl_sdo_command_write_by_index(proto_tree *epl_tree, tvbuff_t *tvb, pack } /* add the frame to reassembly_table */ frag_msg = fragment_add_seq_check(&epl_reassembly_table, tvb, offset, pinfo, - fragmentId, NULL, ct, payload_length, end_segment ? FALSE : TRUE ); + fragmentId, NULL, ct, payload_length, end_segment ? FALSE : TRUE ); /* if the reassembly_table is not Null and the frame stored is the same as the current frame */ if(frag_msg != NULL && (epl_asnd_sdo_reassembly_write.frame[epl_segmentation.recv][epl_segmentation.send] == frame)) @@ -2685,7 +2685,7 @@ dissect_epl_sdo_command_write_by_index(proto_tree *epl_tree, tvbuff_t *tvb, pack /* add the reassembley fields */ process_reassembled_data(tvb, 0, pinfo, "Reassembled Message", frag_msg, &epl_frag_items, NULL, payload_tree ); proto_tree_add_uint_format_value(payload_tree, hf_epl_asnd_sdo_cmd_reassembled, tvb, 0, 0, - payload_length, "%d bytes (over all fragments)", frag_msg->len); + payload_length, "%d bytes (over all fragments)", frag_msg->len); col_append_str(pinfo->cinfo, COL_INFO, " (Message Reassembled)" ); /* reset memory */ memset(&epl_asnd_sdo_reassembly_write,0,sizeof(epl_sdo_reassembly)); @@ -3006,7 +3006,7 @@ dissect_epl_sdo_command_read_by_index(proto_tree *epl_tree, tvbuff_t *tvb, packe } /* add the frame to reassembly_table */ frag_msg = fragment_add_seq_check(&epl_reassembly_table, tvb, offset, pinfo, - fragmentId, NULL, count, payload_length, end_segment ? FALSE : TRUE ); + fragmentId, NULL, count, payload_length, end_segment ? FALSE : TRUE ); /* if the reassembly_table is not Null and the frame stored is the same as the current frame */ if(frag_msg != NULL && (epl_asnd_sdo_reassembly_read.frame[epl_segmentation.recv][epl_segmentation.send] == frame)) @@ -3019,7 +3019,7 @@ dissect_epl_sdo_command_read_by_index(proto_tree *epl_tree, tvbuff_t *tvb, packe /* add the reassembley fields */ process_reassembled_data(tvb, 0, pinfo, "Reassembled Message", frag_msg, &epl_frag_items, NULL, payload_tree ); proto_tree_add_uint_format_value(payload_tree, hf_epl_asnd_sdo_cmd_reassembled, tvb, 0, 0, - payload_length, "%d bytes (over all fragments)", frag_msg->len); + payload_length, "%d bytes (over all fragments)", frag_msg->len); col_append_str(pinfo->cinfo, COL_INFO, " (Message Reassembled)" ); /* reset memory */ memset(&epl_asnd_sdo_reassembly_read,0,sizeof(epl_sdo_reassembly)); diff --git a/epan/dissectors/packet-gsm_a_common.h b/epan/dissectors/packet-gsm_a_common.h index 7f5db63db4..bb31373513 100644 --- a/epan/dissectors/packet-gsm_a_common.h +++ b/epan/dissectors/packet-gsm_a_common.h @@ -931,24 +931,24 @@ typedef enum BE_UDEF_130, /* Undefined */ BE_KC128, /* Kc128 */ BE_CSG_ID, /* CSG Identifier */ - BE_REDIR_ATT_FLG, /* Redirect Attempt Flag 3.2.2.111 */ - BE_REROUTE_REJ_CAUSE, /* Reroute Reject Cause 3.2.2.112 */ - BE_SEND_SEQN, /* Send Sequence Number 3.2.2.113 */ - BE_REROUTE_OUTCOME, /* Reroute complete outcome 3.2.2.114 */ - BE_GLOBAL_CALL_REF, /* Global Call Reference 3.2.2.115 */ - BE_LCLS_CONF, /* LCLS-Configuration 3.2.2.116 */ - BE_LCLS_CON_STATUS_CONTROL, /* LCLS-Connection-Status-Control 3.2.2.117 */ - BE_LCLS_CORR_NOT_NEEDED, /* LCLS-Correlation-Not-Needed 3.2.2.118 */ - BE_LCLS_BSS_STATUS, /* LCLS-BSS-Status 3.2.2.119 */ - BE_LCLS_BREAK_REQ, /* LCLS-Break-Request 3.2.2.120 */ - BE_CSFB_IND, /* CSFB Indication 3.2.2.121 */ + BE_REDIR_ATT_FLG, /* Redirect Attempt Flag 3.2.2.111 */ + BE_REROUTE_REJ_CAUSE, /* Reroute Reject Cause 3.2.2.112 */ + BE_SEND_SEQN, /* Send Sequence Number 3.2.2.113 */ + BE_REROUTE_OUTCOME, /* Reroute complete outcome 3.2.2.114 */ + BE_GLOBAL_CALL_REF, /* Global Call Reference 3.2.2.115 */ + BE_LCLS_CONF, /* LCLS-Configuration 3.2.2.116 */ + BE_LCLS_CON_STATUS_CONTROL, /* LCLS-Connection-Status-Control 3.2.2.117 */ + BE_LCLS_CORR_NOT_NEEDED, /* LCLS-Correlation-Not-Needed 3.2.2.118 */ + BE_LCLS_BSS_STATUS, /* LCLS-BSS-Status 3.2.2.119 */ + BE_LCLS_BREAK_REQ, /* LCLS-Break-Request 3.2.2.120 */ + BE_CSFB_IND, /* CSFB Indication 3.2.2.121 */ #if 0 - BE_CS_TO_PS_SRVCC, /* CS to PS SRVCC 3.2.2.122 */ - BE_SRC_ENB_2_TGT_ENB_TRANSP_INF, /* Source eNB to target eNB transparent information (E-UTRAN)" 3.2.2.123 */ - BE_CS_TO_PS_SRVCC_IND, /* CS to PS SRVCC Indication 3.2.2.124 */ - BE_CN_TO_MS_TRANSP, /* CN to MS transparent information 3.2.2.125 */ + BE_CS_TO_PS_SRVCC, /* CS to PS SRVCC 3.2.2.122 */ + BE_SRC_ENB_2_TGT_ENB_TRANSP_INF, /* Source eNB to target eNB transparent information (E-UTRAN)" 3.2.2.123 */ + BE_CS_TO_PS_SRVCC_IND, /* CS to PS SRVCC Indication 3.2.2.124 */ + BE_CN_TO_MS_TRANSP, /* CN to MS transparent information 3.2.2.125 */ #endif - BE_SELECTED_PLMN_ID, /* Selected PLMN ID 3.2.2.126 */ + BE_SELECTED_PLMN_ID, /* Selected PLMN ID 3.2.2.126 */ BE_NONE /* NONE */ } bssmap_elem_idx_t; @@ -1440,3 +1440,16 @@ typedef enum sgsap_elem_idx_t; #endif /* __PACKET_GSM_A_COMMON_H__ */ + +/* + * Editor modelines - http://www.wireshark.org/tools/modelines.html + * + * Local variables: + * c-basic-offset: 4 + * tab-width: 8 + * indent-tabs-mode: nil + * End: + * + * vi: set shiftwidth=4 tabstop=8 expandtab: + * :indentSize=4:tabSize=8:noTabs=true: + */ diff --git a/epan/dissectors/packet-gsm_a_gm.c b/epan/dissectors/packet-gsm_a_gm.c index deb8481a5c..0057c0c531 100644 --- a/epan/dissectors/packet-gsm_a_gm.c +++ b/epan/dissectors/packet-gsm_a_gm.c @@ -110,13 +110,15 @@ const value_string gsm_a_dtap_msg_gmm_strings[] = { { 0x12, "Authentication and Ciphering Req" }, { 0x13, "Authentication and Ciphering Resp" }, { 0x14, "Authentication and Ciphering Rej" }, - { 0x1c, "Authentication and Ciphering Failure" }, { 0x15, "Identity Request" }, { 0x16, "Identity Response" }, + { 0x1c, "Authentication and Ciphering Failure" }, { 0x20, "GMM Status" }, { 0x21, "GMM Information" }, { 0, NULL } }; +static value_string_ext gsm_a_dtap_msg_gmm_strings_ext = VALUE_STRING_EXT_INIT(gsm_a_dtap_msg_gmm_strings); + const value_string gsm_a_dtap_msg_sm_strings[] = { { 0x41, "Activate PDP Context Request" }, @@ -150,75 +152,77 @@ const value_string gsm_a_dtap_msg_sm_strings[] = { { 0x5d, "Notification" }, { 0, NULL } }; +static value_string_ext gsm_a_dtap_msg_sm_strings_ext = VALUE_STRING_EXT_INIT(gsm_a_dtap_msg_sm_strings); + static const value_string gsm_gm_elem_strings[] = { /* GPRS Mobility Management Information Elements 10.5.5 */ - { DE_ADD_UPD_TYPE, "Additional Update Type" }, - { DE_ATTACH_RES, "Attach Result" }, - { DE_ATTACH_TYPE, "Attach Type" }, - { DE_CIPH_ALG, "Cipher Algorithm" }, - { DE_TMSI_STAT, "TMSI Status" }, - { DE_DETACH_TYPE, "Detach Type" }, - { DE_DRX_PARAM, "DRX Parameter" }, - { DE_FORCE_TO_STAND, "Force to Standby" }, - { DE_FORCE_TO_STAND_H, "Force to Standby" }, - { DE_P_TMSI_SIG, "P-TMSI Signature" }, - { DE_P_TMSI_SIG_2, "P-TMSI Signature 2" }, - { DE_ID_TYPE_2, "Identity Type 2" }, - { DE_IMEISV_REQ, "IMEISV Request" }, - { DE_REC_N_PDU_NUM_LIST, "Receive N-PDU Numbers List" }, - { DE_MS_NET_CAP, "MS Network Capability" }, - { DE_MS_RAD_ACC_CAP, "MS Radio Access Capability" }, - { DE_GMM_CAUSE, "GMM Cause" }, - { DE_RAI, "Routing Area Identification" }, - { DE_RAI_2, "Routing Area Identification 2" }, - { DE_UPD_RES, "Update Result" }, - { DE_UPD_TYPE, "Update Type" }, - { DE_AC_REF_NUM, "A&C Reference Number" }, - { DE_AC_REF_NUM_H, "A&C Reference Number" }, - { DE_SRVC_TYPE, "Service Type" }, - { DE_CELL_NOT, "Cell Notification" }, - { DE_PS_LCS_CAP, "PS LCS Capability" }, - { DE_NET_FEAT_SUP, "Network Feature Support" }, - { DE_ADD_NET_FEAT_SUP, "Additional Network Feature Support" }, - { DE_RAT_INFO_CONTAINER, "Inter RAT information container" }, - { DE_REQ_MS_INFO, "Requested MS information" }, - { DE_UE_NETWORK_CAP, "UE network capability" }, + { DE_ADD_UPD_TYPE, "Additional Update Type" }, + { DE_ATTACH_RES, "Attach Result" }, + { DE_ATTACH_TYPE, "Attach Type" }, + { DE_CIPH_ALG, "Cipher Algorithm" }, + { DE_TMSI_STAT, "TMSI Status" }, + { DE_DETACH_TYPE, "Detach Type" }, + { DE_DRX_PARAM, "DRX Parameter" }, + { DE_FORCE_TO_STAND, "Force to Standby" }, + { DE_FORCE_TO_STAND_H, "Force to Standby" }, + { DE_P_TMSI_SIG, "P-TMSI Signature" }, + { DE_P_TMSI_SIG_2, "P-TMSI Signature 2" }, + { DE_ID_TYPE_2, "Identity Type 2" }, + { DE_IMEISV_REQ, "IMEISV Request" }, + { DE_REC_N_PDU_NUM_LIST, "Receive N-PDU Numbers List" }, + { DE_MS_NET_CAP, "MS Network Capability" }, + { DE_MS_RAD_ACC_CAP, "MS Radio Access Capability" }, + { DE_GMM_CAUSE, "GMM Cause" }, + { DE_RAI, "Routing Area Identification" }, + { DE_RAI_2, "Routing Area Identification 2" }, + { DE_UPD_RES, "Update Result" }, + { DE_UPD_TYPE, "Update Type" }, + { DE_AC_REF_NUM, "A&C Reference Number" }, + { DE_AC_REF_NUM_H, "A&C Reference Number" }, + { DE_SRVC_TYPE, "Service Type" }, + { DE_CELL_NOT, "Cell Notification" }, + { DE_PS_LCS_CAP, "PS LCS Capability" }, + { DE_NET_FEAT_SUP, "Network Feature Support" }, + { DE_ADD_NET_FEAT_SUP, "Additional Network Feature Support" }, + { DE_RAT_INFO_CONTAINER, "Inter RAT information container" }, + { DE_REQ_MS_INFO, "Requested MS information" }, + { DE_UE_NETWORK_CAP, "UE network capability" }, { DE_EUTRAN_IRAT_INFO_CONTAINER, "E-UTRAN inter RAT information container" }, - { DE_VOICE_DOMAIN_PREF, "Voice domain preference and UE's usage setting" }, - { DE_PTMSI_TYPE, "P-TMSI type" }, - { DE_LAI_2, "Location Area Identification 2" }, - { DE_NET_RES_ID_CONT, "Network resource identifier container" }, + { DE_VOICE_DOMAIN_PREF, "Voice domain preference and UE's usage setting" }, + { DE_PTMSI_TYPE, "P-TMSI type" }, + { DE_LAI_2, "Location Area Identification 2" }, + { DE_NET_RES_ID_CONT, "Network resource identifier container" }, /* Session Management Information Elements 10.5.6 */ - { DE_ACC_POINT_NAME, "Access Point Name" }, - { DE_NET_SAPI, "Network Service Access Point Identifier" }, - { DE_PRO_CONF_OPT, "Protocol Configuration Options" }, - { DE_PD_PRO_ADDR, "Packet Data Protocol Address" }, - { DE_QOS, "Quality Of Service" }, - { DE_SM_CAUSE, "SM Cause" }, - { DE_SM_CAUSE_2, "SM Cause 2" }, - { DE_LINKED_TI, "Linked TI" }, - { DE_LLC_SAPI, "LLC Service Access Point Identifier" }, - { DE_TEAR_DOWN_IND, "Tear Down Indicator" }, - { DE_PACKET_FLOW_ID, "Packet Flow Identifier" }, - { DE_TRAFFIC_FLOW_TEMPLATE, "Traffic Flow Template" }, - { DE_TMGI, "Temporary Mobile Group Identity (TMGI)" }, - { DE_MBMS_BEARER_CAP, "MBMS bearer capabilities" }, - { DE_MBMS_PROT_CONF_OPT, "MBMS protocol configuration options" }, - { DE_ENH_NSAPI, "Enhanced network service access point identifier" }, - { DE_REQ_TYPE, "Request type" }, - { DE_SM_NOTIF_IND, "Notification indicator" }, - { DE_SM_CONNECTIVITY_TYPE, "Connectivity type" }, + { DE_ACC_POINT_NAME, "Access Point Name" }, + { DE_NET_SAPI, "Network Service Access Point Identifier" }, + { DE_PRO_CONF_OPT, "Protocol Configuration Options" }, + { DE_PD_PRO_ADDR, "Packet Data Protocol Address" }, + { DE_QOS, "Quality Of Service" }, + { DE_SM_CAUSE, "SM Cause" }, + { DE_SM_CAUSE_2, "SM Cause 2" }, + { DE_LINKED_TI, "Linked TI" }, + { DE_LLC_SAPI, "LLC Service Access Point Identifier" }, + { DE_TEAR_DOWN_IND, "Tear Down Indicator" }, + { DE_PACKET_FLOW_ID, "Packet Flow Identifier" }, + { DE_TRAFFIC_FLOW_TEMPLATE, "Traffic Flow Template" }, + { DE_TMGI, "Temporary Mobile Group Identity (TMGI)" }, + { DE_MBMS_BEARER_CAP, "MBMS bearer capabilities" }, + { DE_MBMS_PROT_CONF_OPT, "MBMS protocol configuration options" }, + { DE_ENH_NSAPI, "Enhanced network service access point identifier" }, + { DE_REQ_TYPE, "Request type" }, + { DE_SM_NOTIF_IND, "Notification indicator" }, + { DE_SM_CONNECTIVITY_TYPE, "Connectivity type" }, /* GPRS Common Information Elements 10.5.7 */ - { DE_PDP_CONTEXT_STAT, "PDP Context Status" }, - { DE_RAD_PRIO, "Radio Priority" }, - { DE_GPRS_TIMER, "GPRS Timer" }, - { DE_GPRS_TIMER_2, "GPRS Timer 2" }, - { DE_GPRS_TIMER_3, "GPRS Timer 3" }, - { DE_RAD_PRIO_2, "Radio Priority 2"}, - { DE_MBMS_CTX_STATUS, "MBMS context status"}, - { DE_UPLINK_DATA_STATUS, "Uplink data status"}, - { DE_DEVICE_PROPERTIES, "Device properties"}, + { DE_PDP_CONTEXT_STAT, "PDP Context Status" }, + { DE_RAD_PRIO, "Radio Priority" }, + { DE_GPRS_TIMER, "GPRS Timer" }, + { DE_GPRS_TIMER_2, "GPRS Timer 2" }, + { DE_GPRS_TIMER_3, "GPRS Timer 3" }, + { DE_RAD_PRIO_2, "Radio Priority 2"}, + { DE_MBMS_CTX_STATUS, "MBMS context status"}, + { DE_UPLINK_DATA_STATUS, "Uplink data status"}, + { DE_DEVICE_PROPERTIES, "Device properties"}, { 0, NULL } }; value_string_ext gsm_gm_elem_strings_ext = VALUE_STRING_EXT_INIT(gsm_gm_elem_strings); @@ -7074,7 +7078,7 @@ get_gmm_msg_params(guint8 oct, const gchar **msg_str, int *ett_tree, int *hf_idx { gint idx; - *msg_str = try_val_to_str_idx((guint32) (oct & DTAP_GMM_IEI_MASK), gsm_a_dtap_msg_gmm_strings, &idx); + *msg_str = try_val_to_str_idx_ext((guint32) (oct & DTAP_GMM_IEI_MASK), &gsm_a_dtap_msg_gmm_strings_ext, &idx); *hf_idx = hf_gsm_a_dtap_msg_gmm_type; if (*msg_str != NULL) { *ett_tree = ett_gsm_dtap_msg_gmm[idx]; @@ -7089,7 +7093,7 @@ get_sm_msg_params(guint8 oct, const gchar **msg_str, int *ett_tree, int *hf_idx, { gint idx; - *msg_str = try_val_to_str_idx((guint32) (oct & DTAP_SM_IEI_MASK), gsm_a_dtap_msg_sm_strings, &idx); + *msg_str = try_val_to_str_idx_ext((guint32) (oct & DTAP_SM_IEI_MASK), &gsm_a_dtap_msg_sm_strings_ext, &idx); *hf_idx = hf_gsm_a_dtap_msg_sm_type; if (*msg_str != NULL) { *ett_tree = ett_gsm_dtap_msg_sm[idx]; @@ -7111,12 +7115,12 @@ proto_register_gsm_a_gm(void) static hf_register_info hf[] = { { &hf_gsm_a_dtap_msg_gmm_type, { "DTAP GPRS Mobility Management Message Type", "gsm_a.dtap.msg_gmm_type", - FT_UINT8, BASE_HEX, VALS(gsm_a_dtap_msg_gmm_strings), 0x0, + FT_UINT8, BASE_HEX | BASE_EXT_STRING, &gsm_a_dtap_msg_gmm_strings_ext, 0x0, NULL, HFILL } }, { &hf_gsm_a_dtap_msg_sm_type, { "DTAP GPRS Session Management Message Type", "gsm_a.dtap.msg_sm_type", - FT_UINT8, BASE_HEX, VALS(gsm_a_dtap_msg_sm_strings), 0x0, + FT_UINT8, BASE_HEX | BASE_EXT_STRING, &gsm_a_dtap_msg_sm_strings_ext, 0x0, NULL, HFILL } }, { &hf_gsm_a_gm_elem_id, diff --git a/epan/dissectors/packet-igmp.c b/epan/dissectors/packet-igmp.c index 33e4a81907..97cdd36939 100644 --- a/epan/dissectors/packet-igmp.c +++ b/epan/dissectors/packet-igmp.c @@ -1203,12 +1203,12 @@ proto_reg_handoff_igmp(void) * Editor modelines - http://www.wireshark.org/tools/modelines.html * * Local variables: - * c-basic-offset: 4 + * c-basic-offset: 8 * tab-width: 8 * indent-tabs-mode: t * End: * - * vi: set shiftwidth=4 tabstop=8 noexpandtab: - * :indentSize=4:tabSize=8:noTabs=false: + * vi: set shiftwidth=8 tabstop=8 noexpandtab: + * :indentSize=8:tabSize=8:noTabs=false: */ diff --git a/epan/dissectors/packet-megaco.c b/epan/dissectors/packet-megaco.c index 31c713aec1..7a6632ea68 100644 --- a/epan/dissectors/packet-megaco.c +++ b/epan/dissectors/packet-megaco.c @@ -176,8 +176,8 @@ static gboolean global_megaco_raw_text = TRUE; static gboolean global_megaco_dissect_tree = TRUE; /* Some basic utility functions that are specific to this dissector */ -static gint megaco_tvb_skip_wsp(tvbuff_t* tvb, gint offset); -static gint megaco_tvb_skip_wsp_return(tvbuff_t* tvb, gint offset); +static gint megaco_tvb_skip_wsp(tvbuff_t *tvb, gint offset); +static gint megaco_tvb_skip_wsp_return(tvbuff_t *tvb, gint offset); /* * The various functions that either dissect some * subpart of MEGACO. These aren't really proto dissectors but they @@ -223,7 +223,7 @@ tvb_raw_text_add(tvbuff_t *tvb, proto_tree *tree); static void dissect_megaco_text(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree); static gint -megaco_tvb_find_token(tvbuff_t* tvb, gint offset, gint maxlength); +megaco_tvb_find_token(tvbuff_t *tvb, gint offset, gint maxlength); static dissector_handle_t data_handle; static dissector_handle_t sdp_handle; static dissector_handle_t h245_handle; @@ -335,17 +335,17 @@ dissect_megaco_text(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) guchar needle; guint8 first; - gcp_msg_t* msg = NULL; - gcp_trx_t* trx = NULL; - gcp_ctx_t* ctx = NULL; - gcp_cmd_t* cmd = NULL; - gcp_term_t* term = NULL; - gcp_trx_type_t trx_type = GCP_TRX_NONE; - guint32 trx_id = 0; - guint32 ctx_id = 0; - gcp_cmd_type_t cmd_type = GCP_CMD_NONE; - gcp_wildcard_t wild_term = GCP_WILDCARD_NONE; - proto_item *hidden_item; + gcp_msg_t *msg = NULL; + gcp_trx_t *trx = NULL; + gcp_ctx_t *ctx = NULL; + gcp_cmd_t *cmd = NULL; + gcp_term_t *term = NULL; + gcp_trx_type_t trx_type = GCP_TRX_NONE; + guint32 trx_id = 0; + guint32 ctx_id = 0; + gcp_cmd_type_t cmd_type = GCP_CMD_NONE; + gcp_wildcard_t wild_term = GCP_WILDCARD_NONE; + proto_item *hidden_item; top_tree=tree; /* Initialize variables */ @@ -882,10 +882,10 @@ nextcontext: tvb_next_offset = tvb_command_start_offset + tokenlen; /* Try to dissect Topology Descriptor before the command */ - tempchar = tvb_get_guint8(tvb, tvb_command_start_offset); - if ( (tempchar >= 'a')&& (tempchar <= 'z')){ + tempchar = tvb_get_guint8(tvb, tvb_command_start_offset); + if ( (tempchar >= 'a')&& (tempchar <= 'z')){ tempchar = tempchar - 0x20; - } + } if ( tempchar == 'T') { tempchar = tvb_get_guint8(tvb, tvb_command_start_offset+1); @@ -959,7 +959,7 @@ nextcontext: if ( tempchar != 'E' ){ - /* Short form used */ + /* Short form used */ if ( tvb_get_guint8(tvb, 0 ) == '!'){ switch ( tempchar ){ @@ -1138,17 +1138,17 @@ nextcontext: break; default: - { - proto_item *item; + { + proto_item *item; - tokenlen = (tvb_RBRKT+1) - tvb_previous_offset; - tvb_ensure_bytes_exist(tvb, tvb_previous_offset, tokenlen); - item = proto_tree_add_string(megaco_tree, hf_megaco_error_Frame, tvb, - tvb_previous_offset, tokenlen, - "No Command detectable !"); - proto_item_append_text(item,"[ tempchar 0x%x ]", tempchar); - return; - } + tokenlen = (tvb_RBRKT+1) - tvb_previous_offset; + tvb_ensure_bytes_exist(tvb, tvb_previous_offset, tokenlen); + item = proto_tree_add_string(megaco_tree, hf_megaco_error_Frame, tvb, + tvb_previous_offset, tokenlen, + "No Command detectable !"); + proto_item_append_text(item,"[ tempchar 0x%x ]", tempchar); + return; + } } } else{ @@ -3631,3 +3631,15 @@ proto_reg_handoff_megaco(void) } +/* + * Editor modelines - http://www.wireshark.org/tools/modelines.html + * + * Local variables: + * c-basic-offset: 4 + * tab-width: 8 + * indent-tabs-mode: nil + * End: + * + * vi: set shiftwidth=4 tabstop=8 expandtab: + * :indentSize=4:tabSize=8:noTabs=true: + */ diff --git a/epan/dissectors/packet-mux27010.c b/epan/dissectors/packet-mux27010.c index 9c717e9128..71240fad60 100644 --- a/epan/dissectors/packet-mux27010.c +++ b/epan/dissectors/packet-mux27010.c @@ -1432,3 +1432,15 @@ proto_reg_handoff_mux27010(void) } +/* + * Editor modelines - http://www.wireshark.org/tools/modelines.html + * + * Local variables: + * c-basic-offset: 4 + * tab-width: 8 + * indent-tabs-mode: nil + * End: + * + * vi: set shiftwidth=4 tabstop=8 expandtab: + * :indentSize=4:tabSize=8:noTabs=true: + */ diff --git a/epan/dissectors/packet-nfs.c b/epan/dissectors/packet-nfs.c index 27f662f0a4..20664108ce 100644 --- a/epan/dissectors/packet-nfs.c +++ b/epan/dissectors/packet-nfs.c @@ -7561,11 +7561,11 @@ dissect_nfs4_cb_client4(tvbuff_t *tvb, int offset, proto_tree *tree) cbprog = tvb_get_ntohl(tvb, offset); reg_callback(cbprog); offset = dissect_rpc_uint32(tvb, tree, hf_nfs4_cb_program, offset); - old_offset = offset; + old_offset = offset; cb_location = proto_tree_add_subtree(tree, tvb, offset, 0, ett_nfs4_clientaddr, &fitem, "cb_location"); offset = dissect_nfs4_clientaddr(tvb, offset, cb_location); - proto_item_set_len(fitem, offset - old_offset); + proto_item_set_len(fitem, offset - old_offset); return offset; } @@ -7801,7 +7801,7 @@ dissect_nfs4_change_info(tvbuff_t *tvb, int offset, offset = dissect_rpc_bool( tvb, newftree, hf_nfs4_change_info_atomic, offset); offset = dissect_rpc_uint64(tvb, newftree, hf_nfs4_changeid_before, offset); offset = dissect_rpc_uint64(tvb, newftree, hf_nfs4_changeid_after, offset); - proto_item_set_len(fitem, offset - old_offset); + proto_item_set_len(fitem, offset - old_offset); return offset; } @@ -7888,7 +7888,7 @@ dissect_nfs4_stateid(tvbuff_t *tvb, int offset, proto_tree *tree, guint16 *hash) if (hash) *hash = sid_hash; - proto_item_set_len(fitem, offset - old_offset); + proto_item_set_len(fitem, offset - old_offset); return offset; } @@ -12459,12 +12459,12 @@ proto_register_nfs(void) &ett_nfs4_want_notify_flags }; - static ei_register_info ei[] = { - { &ei_nfs_too_many_ops, { "nfs.too_many_ops", PI_PROTOCOL, PI_NOTE, "Too many operations", EXPFILL }}, - { &ei_nfs_not_vnx_file, { "nfs.not_vnx_file", PI_UNDECODED, PI_WARN, "Not a Celerra|VNX file handle", EXPFILL }}, - }; + static ei_register_info ei[] = { + { &ei_nfs_too_many_ops, { "nfs.too_many_ops", PI_PROTOCOL, PI_NOTE, "Too many operations", EXPFILL }}, + { &ei_nfs_not_vnx_file, { "nfs.not_vnx_file", PI_UNDECODED, PI_WARN, "Not a Celerra|VNX file handle", EXPFILL }}, + }; - module_t *nfs_module; + module_t *nfs_module; expert_module_t* expert_nfs; proto_nfs = proto_register_protocol("Network File System", "NFS", "nfs"); diff --git a/epan/dissectors/packet-opensafety.c b/epan/dissectors/packet-opensafety.c index 3efccb168a..155366b98c 100644 --- a/epan/dissectors/packet-opensafety.c +++ b/epan/dissectors/packet-opensafety.c @@ -55,7 +55,6 @@ #include #include -#include #include @@ -361,6 +360,7 @@ static const value_string sod_idx_names[] = { { 0, NULL } }; +static value_string_ext sod_idx_names_ext = VALUE_STRING_EXT_INIT(sod_idx_names); static const value_string abort_codes[] = { @@ -405,6 +405,7 @@ static const value_string abort_codes[] = { { 0, NULL } }; +static value_string_ext abort_codes_ext = VALUE_STRING_EXT_INIT(abort_codes); static const true_false_string opensafety_message_direction = { "Request", "Response" }; #define OPENSAFETY_REQUEST TRUE @@ -1068,15 +1069,15 @@ static void dissect_ssdo_payload ( packet_info *pinfo, tvbuff_t *new_tvb, proto_ item = proto_tree_add_uint_format_value(ssdo_payload, hf_oss_ssdo_sod_index, new_tvb, 0, 0, 0x1018, "0x%04X (%s)", 0x1018, - val_to_str_const( ((guint32) (0x1018 << 16) ), - sod_idx_names, "Unknown") ); + val_to_str_ext_const( ((guint32) (0x1018 << 16) ), + &sod_idx_names_ext, "Unknown") ); sod_tree = proto_item_add_subtree(item, ett_opensafety_ssdo_sodentry); PROTO_ITEM_SET_GENERATED(item); item = proto_tree_add_uint_format_value(sod_tree, hf_oss_ssdo_sod_subindex, new_tvb, 0, 0, - 0x06, "0x%02X (%s)", 0x06, - val_to_str_const(((guint32) (0x1018 << 16) + 0x06), - sod_idx_names, "Unknown") ); + 0x06, "0x%02X (%s)", 0x06, + val_to_str_ext_const(((guint32) (0x1018 << 16) + 0x06), + &sod_idx_names_ext, "Unknown") ); PROTO_ITEM_SET_GENERATED(item); entry = tvb_get_letohl ( new_tvb, 0 ); @@ -1114,8 +1115,8 @@ static void dissect_ssdo_payload ( packet_info *pinfo, tvbuff_t *new_tvb, proto_ item = proto_tree_add_uint_format_value(ssdo_payload, hf_oss_ssdo_sod_index, new_tvb, ctr, 2, ssdoIndex, "0x%04X (%s)", ssdoIndex, - val_to_str_const( ((guint32) (dispSSDOIndex << 16) ), - sod_idx_names, "Unknown") ); + val_to_str_ext_const( ((guint32) (dispSSDOIndex << 16) ), + &sod_idx_names_ext, "Unknown") ); if ( ssdoIndex != dispSSDOIndex ) PROTO_ITEM_SET_GENERATED ( item ); @@ -1127,9 +1128,9 @@ static void dissect_ssdo_payload ( packet_info *pinfo, tvbuff_t *new_tvb, proto_ if ( ssdoSubIndex != 0 ) { proto_tree_add_uint_format_value(sod_tree, hf_oss_ssdo_sod_subindex, new_tvb, ctr + 2, 1, - ssdoSubIndex, "0x%02X (%s)", ssdoSubIndex, - val_to_str_const(((guint32) (ssdoIndex << 16) + ssdoSubIndex), - sod_idx_names, "Unknown") ); + ssdoSubIndex, "0x%02X (%s)", ssdoSubIndex, + val_to_str_ext_const(((guint32) (ssdoIndex << 16) + ssdoSubIndex), + &sod_idx_names_ext, "Unknown") ); } else proto_tree_add_uint_format_value(sod_tree, hf_oss_ssdo_sod_subindex, new_tvb, ctr + 2, 1, @@ -1349,17 +1350,17 @@ dissect_opensafety_ssdo_message(tvbuff_t *message_tvb, packet_info *pinfo, proto proto_tree_add_uint_format_value(ssdo_tree, hf_oss_ssdo_sod_index, message_tvb, db0Offset + 1, 2, ssdoIndex, "0x%04X (%s)", ssdoIndex, - val_to_str_const(((guint32) (ssdoIndex << 16)), sod_idx_names, "Unknown") ); - col_append_fstr(pinfo->cinfo, COL_INFO, " [%s", val_to_str_const(((guint32) (ssdoIndex << 16)), sod_idx_names, "Unknown")); + val_to_str_ext_const(((guint32) (ssdoIndex << 16)), &sod_idx_names_ext, "Unknown") ); + col_append_fstr(pinfo->cinfo, COL_INFO, " [%s", val_to_str_ext_const(((guint32) (ssdoIndex << 16)), &sod_idx_names_ext, "Unknown")); /* Some SOD downloads (0x101A for instance) don't have sub-indeces */ if ( ssdoSubIndex != 0x0 ) { proto_tree_add_uint_format_value(ssdo_tree, hf_oss_ssdo_sod_subindex, message_tvb, db0Offset + 3, 1, ssdoSubIndex, "0x%02X (%s)", ssdoSubIndex, - val_to_str_const(((guint32) (ssdoIndex << 16) + ssdoSubIndex), sod_idx_names, "Unknown") ); + val_to_str_ext_const(((guint32) (ssdoIndex << 16) + ssdoSubIndex), &sod_idx_names_ext, "Unknown") ); col_append_fstr(pinfo->cinfo, COL_INFO, " - %s", - val_to_str_const(((guint32) (ssdoIndex << 16) + ssdoSubIndex), sod_idx_names, "Unknown")); + val_to_str_ext_const(((guint32) (ssdoIndex << 16) + ssdoSubIndex), &sod_idx_names_ext, "Unknown")); } col_append_fstr(pinfo->cinfo, COL_INFO, "%s", "]" ); payloadOffset += 3; @@ -1371,8 +1372,8 @@ dissect_opensafety_ssdo_message(tvbuff_t *message_tvb, packet_info *pinfo, proto proto_tree_add_uint_format_value(ssdo_tree, hf_oss_ssdo_abort_code, message_tvb, frameStart1 + OSS_FRAME_POS_DATA + 4, 4, abortcode, "0x%04X %04X - %s", (guint16)(abortcode >> 16), (guint16)(abortcode), - val_to_str_const(abortcode, abort_codes, "Unknown")); - col_append_fstr(pinfo->cinfo, COL_INFO, " - %s", val_to_str_const(abortcode, abort_codes, "Unknown")); + val_to_str_ext_const(abortcode, &abort_codes_ext, "Unknown")); + col_append_fstr(pinfo->cinfo, COL_INFO, " - %s", val_to_str_ext_const(abortcode, &abort_codes_ext, "Unknown")); } else { diff --git a/epan/dissectors/packet-rdm.c b/epan/dissectors/packet-rdm.c index 3cc3f9f1da..2de91eab57 100644 --- a/epan/dissectors/packet-rdm.c +++ b/epan/dissectors/packet-rdm.c @@ -2780,3 +2780,15 @@ proto_register_rdm(void) register_dissector("rdm", dissect_rdm, proto_rdm); } +/* + * Editor modelines - http://www.wireshark.org/tools/modelines.html + * + * Local variables: + * c-basic-offset: 8 + * tab-width: 8 + * indent-tabs-mode: t + * End: + * + * vi: set shiftwidth=8 tabstop=8 noexpandtab: + * :indentSize=8:tabSize=8:noTabs=false: + */ diff --git a/epan/dissectors/packet-zbee-zcl-general.c b/epan/dissectors/packet-zbee-zcl-general.c index b86fb12e26..c6d6c44ff9 100644 --- a/epan/dissectors/packet-zbee-zcl-general.c +++ b/epan/dissectors/packet-zbee-zcl-general.c @@ -4814,3 +4814,16 @@ proto_reg_handoff_zbee_zcl_appl_ctrl(void) (zbee_zcl_fn_cmd_id)dissect_zcl_appl_ctrl_cmd_id ); } /*proto_reg_handoff_zbee_zcl_appl_ctrl*/ + +/* + * Editor modelines - http://www.wireshark.org/tools/modelines.html + * + * Local variables: + * c-basic-offset: 4 + * tab-width: 8 + * indent-tabs-mode: nil + * End: + * + * vi: set shiftwidth=4 tabstop=8 expandtab: + * :indentSize=4:tabSize=8:noTabs=true: + */ diff --git a/epan/gcp.c b/epan/gcp.c index 7689469659..4f5287f3c1 100644 --- a/epan/gcp.c +++ b/epan/gcp.c @@ -39,35 +39,35 @@ static wmem_tree_t* ctxs_by_trx = NULL; static wmem_tree_t* ctxs = NULL; const value_string gcp_cmd_type[] = { - { GCP_CMD_NONE, "NoCommand"}, - { GCP_CMD_ADD_REQ, "addReq"}, - { GCP_CMD_MOVE_REQ, "moveReq"}, - { GCP_CMD_MOD_REQ, "modReq"}, - { GCP_CMD_SUB_REQ, "subtractReq"}, - { GCP_CMD_AUDITCAP_REQ, "auditCapRequest"}, - { GCP_CMD_AUDITVAL_REQ, "auditValueRequest"}, - { GCP_CMD_NOTIFY_REQ, "notifyReq"}, - { GCP_CMD_SVCCHG_REQ, "serviceChangeReq"}, - { GCP_CMD_TOPOLOGY_REQ, "topologyReq"}, + { GCP_CMD_NONE, "NoCommand"}, + { GCP_CMD_ADD_REQ, "addReq"}, + { GCP_CMD_MOVE_REQ, "moveReq"}, + { GCP_CMD_MOD_REQ, "modReq"}, + { GCP_CMD_SUB_REQ, "subtractReq"}, + { GCP_CMD_AUDITCAP_REQ, "auditCapRequest"}, + { GCP_CMD_AUDITVAL_REQ, "auditValueRequest"}, + { GCP_CMD_NOTIFY_REQ, "notifyReq"}, + { GCP_CMD_SVCCHG_REQ, "serviceChangeReq"}, + { GCP_CMD_TOPOLOGY_REQ, "topologyReq"}, { GCP_CMD_CTX_ATTR_AUDIT_REQ, "ctxAttrAuditReq"}, - { GCP_CMD_ADD_REPLY, "addReply"}, - { GCP_CMD_MOVE_REPLY, "moveReply"}, - { GCP_CMD_MOD_REPLY, "modReply"}, - { GCP_CMD_SUB_REPLY, "subtractReply"}, - { GCP_CMD_AUDITCAP_REPLY, "auditCapReply"}, - { GCP_CMD_AUDITVAL_REPLY, "auditValReply"}, - { GCP_CMD_NOTIFY_REPLY, "notifyReply"}, - { GCP_CMD_SVCCHG_REPLY, "serviceChangeReply"}, - { GCP_CMD_TOPOLOGY_REPLY, "topologyReply"}, + { GCP_CMD_ADD_REPLY, "addReply"}, + { GCP_CMD_MOVE_REPLY, "moveReply"}, + { GCP_CMD_MOD_REPLY, "modReply"}, + { GCP_CMD_SUB_REPLY, "subtractReply"}, + { GCP_CMD_AUDITCAP_REPLY, "auditCapReply"}, + { GCP_CMD_AUDITVAL_REPLY, "auditValReply"}, + { GCP_CMD_NOTIFY_REPLY, "notifyReply"}, + { GCP_CMD_SVCCHG_REPLY, "serviceChangeReply"}, + { GCP_CMD_TOPOLOGY_REPLY, "topologyReply"}, { 0, NULL } }; const value_string gcp_term_types[] = { - { GCP_TERM_TYPE_AAL1, "aal1" }, - { GCP_TERM_TYPE_AAL2, "aal2" }, + { GCP_TERM_TYPE_AAL1, "aal1" }, + { GCP_TERM_TYPE_AAL2, "aal2" }, { GCP_TERM_TYPE_AAL1_STRUCT, "aal1struct" }, - { GCP_TERM_TYPE_IP_RTP, "ipRtp" }, - { GCP_TERM_TYPE_TDM, "tdm" }, + { GCP_TERM_TYPE_IP_RTP, "ipRtp" }, + { GCP_TERM_TYPE_TDM, "tdm" }, { 0, NULL } }; @@ -95,14 +95,14 @@ gcp_msg_t* gcp_msg(packet_info* pinfo, int o, gboolean keep_persistent_data) { address* hi_addr; if (keep_persistent_data) { - wmem_tree_key_t key[3]; + wmem_tree_key_t key[3]; - key[0].length = 1; - key[0].key = &(framenum); - key[1].length = 1; - key[1].key = &offset; - key[2].length = 0; - key[2].key =NULL; + key[0].length = 1; + key[0].key = &(framenum); + key[1].length = 1; + key[1].key = &offset; + key[2].length = 0; + key[2].key =NULL; if (( m = (gcp_msg_t *)wmem_tree_lookup32_array(msgs,key) )) { m->committed = TRUE; @@ -768,3 +768,16 @@ void gcp_analyze_msg(proto_tree* gcp_tree, packet_info* pinfo, tvbuff_t* gcp_tvb } } } + +/* + * Editor modelines - http://www.wireshark.org/tools/modelines.html + * + * Local variables: + * c-basic-offset: 4 + * tab-width: 8 + * indent-tabs-mode: nil + * End: + * + * vi: set shiftwidth=4 tabstop=8 expandtab: + * :indentSize=4:tabSize=8:noTabs=true: + */ diff --git a/epan/gcp.h b/epan/gcp.h index 4f341cb042..42f03da4a5 100644 --- a/epan/gcp.h +++ b/epan/gcp.h @@ -31,9 +31,6 @@ #include #include -#include -#include - #include #include #include @@ -212,3 +209,16 @@ extern const gchar* gcp_msg_to_str(gcp_msg_t* m, gboolean persistent); { &(gi.hf.ctx_cmd), { "Command in Frame", n ".ctx.cmd", FT_FRAMENUM, BASE_NONE, NULL, 0, NULL, HFILL }} #endif + +/* + * Editor modelines - http://www.wireshark.org/tools/modelines.html + * + * Local variables: + * c-basic-offset: 4 + * tab-width: 8 + * indent-tabs-mode: nil + * End: + * + * vi: set shiftwidth=4 tabstop=8 expandtab: + * :indentSize=4:tabSize=8:noTabs=true: + */ diff --git a/epan/wslua/wslua_proto.c b/epan/wslua/wslua_proto.c index 977492caf6..b025cd8926 100644 --- a/epan/wslua/wslua_proto.c +++ b/epan/wslua/wslua_proto.c @@ -915,16 +915,16 @@ static int ProtoField_integer(lua_State* L, enum ftenum type) { } if (type == FT_FRAMENUM) { - if (base != BASE_NONE) - luaL_argerror(L, 3, "ftypes.FRAMENUMs must use base.NONE"); - else if (mask) - luaL_argerror(L, 3, "ftypes.FRAMENUMs can not have a bitmask"); + if (base != BASE_NONE) + luaL_argerror(L, 3, "ftypes.FRAMENUMs must use base.NONE"); + else if (mask) + luaL_argerror(L, 3, "ftypes.FRAMENUMs can not have a bitmask"); } else if (base < BASE_DEC || base > BASE_HEX_DEC) { luaL_argerror(L, 3, "Base must be either base.DEC, base.HEX, base.OCT," " base.DEC_HEX, base.DEC_HEX or base.HEX_DEC"); return 0; } else if ((base == BASE_HEX || base == BASE_OCT) && - (type == FT_INT8 || type == FT_INT16 || type == FT_INT24 || type == FT_INT32 || type == FT_INT64)) { + (type == FT_INT8 || type == FT_INT16 || type == FT_INT24 || type == FT_INT32 || type == FT_INT64)) { luaL_argerror(L, 3, "This type does not display as hexadecimal"); return 0; } @@ -2174,7 +2174,7 @@ WSLUA_CONSTRUCTOR DissectorTable_new (lua_State *L) { switch(type) { case FT_STRING: base = BASE_NONE; - /* fallthrough */ + /* fallthrough */ case FT_UINT8: case FT_UINT16: case FT_UINT24: @@ -2645,3 +2645,16 @@ int DissectorTable_register(lua_State* L) { WSLUA_REGISTER_CLASS(DissectorTable); return 0; } + +/* + * Editor modelines - http://www.wireshark.org/tools/modelines.html + * + * Local variables: + * c-basic-offset: 4 + * tab-width: 8 + * indent-tabs-mode: nil + * End: + * + * vi: set shiftwidth=4 tabstop=8 expandtab: + * :indentSize=4:tabSize=8:noTabs=true: + */ diff --git a/wiretap/file_wrappers.c b/wiretap/file_wrappers.c index b121ddd9ac..65c35d1e6c 100644 --- a/wiretap/file_wrappers.c +++ b/wiretap/file_wrappers.c @@ -37,7 +37,7 @@ * 2. Altered source versions must be plainly marked as such, and must not be * misrepresented as being the original software. * 3. This notice may not be removed or altered from any source distribution. -*/ + */ #include "config.h" @@ -64,9 +64,9 @@ * * Some other compressed file formats we might want to support: * - * XZ format: http://tukaani.org/xz/ + * XZ format: http://tukaani.org/xz/ * - * Bzip2 format: http://bzip.org/ + * Bzip2 format: http://bzip.org/ */ /* @@ -77,9 +77,9 @@ */ static const char *compressed_file_extensions[] = { #ifdef HAVE_LIBZ - "gz", + "gz", #endif - NULL + NULL }; /* @@ -90,14 +90,14 @@ static const char *compressed_file_extensions[] = { GSList * wtap_get_compressed_file_extensions(void) { - const char **extension; - GSList *extensions; + const char **extension; + GSList *extensions; - extensions = NULL; - for (extension = &compressed_file_extensions[0]; *extension != NULL; - extension++) - extensions = g_slist_append(extensions, (gpointer)(*extension)); - return extensions; + extensions = NULL; + for (extension = &compressed_file_extensions[0]; *extension != NULL; + extension++) + extensions = g_slist_append(extensions, (gpointer)(*extension)); + return extensions; } /* #define GZBUFSIZE 8192 */ @@ -105,166 +105,166 @@ wtap_get_compressed_file_extensions(void) /* values for wtap_reader compression */ typedef enum { - UNKNOWN, /* unknown - look for a gzip header */ - UNCOMPRESSED, /* uncompressed - copy input directly */ + UNKNOWN, /* unknown - look for a gzip header */ + UNCOMPRESSED, /* uncompressed - copy input directly */ #ifdef HAVE_LIBZ - ZLIB, /* decompress a zlib stream */ - GZIP_AFTER_HEADER + ZLIB, /* decompress a zlib stream */ + GZIP_AFTER_HEADER #endif } compression_t; struct wtap_reader { - int fd; /* file descriptor */ - gint64 raw_pos; /* current position in file (just to not call lseek()) */ - gint64 pos; /* current position in uncompressed data */ - guint size; /* buffer size */ - unsigned char *in; /* input buffer */ - unsigned char *out; /* output buffer (double-sized when reading) */ - unsigned char *next; /* next output data to deliver or write */ + int fd; /* file descriptor */ + gint64 raw_pos; /* current position in file (just to not call lseek()) */ + gint64 pos; /* current position in uncompressed data */ + guint size; /* buffer size */ + unsigned char *in; /* input buffer */ + unsigned char *out; /* output buffer (double-sized when reading) */ + unsigned char *next; /* next output data to deliver or write */ - guint have; /* amount of output data unused at next */ - gboolean eof; /* TRUE if end of input file reached */ - gint64 start; /* where the gzip data started, for rewinding */ - gint64 raw; /* where the raw data started, for seeking */ - compression_t compression; /* type of compression, if any */ - gboolean is_compressed; /* FALSE if completely uncompressed, TRUE otherwise */ - /* seek request */ - gint64 skip; /* amount to skip (already rewound if backwards) */ - gboolean seek_pending; /* TRUE if seek request pending */ - /* error information */ - int err; /* error code */ - const char *err_info; /* additional error information string for some errors */ + guint have; /* amount of output data unused at next */ + gboolean eof; /* TRUE if end of input file reached */ + gint64 start; /* where the gzip data started, for rewinding */ + gint64 raw; /* where the raw data started, for seeking */ + compression_t compression; /* type of compression, if any */ + gboolean is_compressed; /* FALSE if completely uncompressed, TRUE otherwise */ + /* seek request */ + gint64 skip; /* amount to skip (already rewound if backwards) */ + gboolean seek_pending; /* TRUE if seek request pending */ + /* error information */ + int err; /* error code */ + const char *err_info; /* additional error information string for some errors */ - guint avail_in; /* number of bytes available at next_in */ - unsigned char *next_in; /* next input byte */ + guint avail_in; /* number of bytes available at next_in */ + unsigned char *next_in; /* next input byte */ #ifdef HAVE_LIBZ - /* zlib inflate stream */ - z_stream strm; /* stream structure in-place (not a pointer) */ - gboolean dont_check_crc; /* TRUE if we aren't supposed to check the CRC */ + /* zlib inflate stream */ + z_stream strm; /* stream structure in-place (not a pointer) */ + gboolean dont_check_crc; /* TRUE if we aren't supposed to check the CRC */ #endif - /* fast seeking */ - GPtrArray *fast_seek; - void *fast_seek_cur; + /* fast seeking */ + GPtrArray *fast_seek; + void *fast_seek_cur; }; -static int /* gz_load */ +static int /* gz_load */ raw_read(FILE_T state, unsigned char *buf, unsigned int count, guint *have) { - ssize_t ret; + ssize_t ret; - *have = 0; - do { - ret = read(state->fd, buf + *have, count - *have); - if (ret <= 0) - break; - *have += (unsigned)ret; - state->raw_pos += ret; - } while (*have < count); - if (ret < 0) { - state->err = errno; - state->err_info = NULL; - return -1; - } - if (ret == 0) - state->eof = TRUE; - return 0; + *have = 0; + do { + ret = read(state->fd, buf + *have, count - *have); + if (ret <= 0) + break; + *have += (unsigned)ret; + state->raw_pos += ret; + } while (*have < count); + if (ret < 0) { + state->err = errno; + state->err_info = NULL; + return -1; + } + if (ret == 0) + state->eof = TRUE; + return 0; } static int /* gz_avail */ fill_in_buffer(FILE_T state) { - if (state->err) - return -1; - if (state->eof == 0) { - if (raw_read(state, state->in, state->size, &(state->avail_in)) == -1) - return -1; - state->next_in = state->in; - } - return 0; + if (state->err) + return -1; + if (state->eof == 0) { + if (raw_read(state, state->in, state->size, &(state->avail_in)) == -1) + return -1; + state->next_in = state->in; + } + return 0; } #define ZLIB_WINSIZE 32768 struct fast_seek_point { - gint64 out; /* corresponding offset in uncompressed data */ - gint64 in; /* offset in input file of first full byte */ + gint64 out; /* corresponding offset in uncompressed data */ + gint64 in; /* offset in input file of first full byte */ - compression_t compression; - union { - struct { + compression_t compression; + union { + struct { #ifdef HAVE_INFLATEPRIME - int bits; /* number of bits (1-7) from byte at in - 1, or 0 */ + int bits; /* number of bits (1-7) from byte at in - 1, or 0 */ #endif - unsigned char window[ZLIB_WINSIZE]; /* preceding 32K of uncompressed data */ + unsigned char window[ZLIB_WINSIZE]; /* preceding 32K of uncompressed data */ - /* be gentle with Z_STREAM_END, 8 bytes more... Another solution would be to comment checks out */ - guint32 adler; - guint32 total_out; - } zlib; - } data; + /* be gentle with Z_STREAM_END, 8 bytes more... Another solution would be to comment checks out */ + guint32 adler; + guint32 total_out; + } zlib; + } data; }; struct zlib_cur_seek_point { - unsigned char window[ZLIB_WINSIZE]; /* preceding 32K of uncompressed data */ - unsigned int pos; - unsigned int have; + unsigned char window[ZLIB_WINSIZE]; /* preceding 32K of uncompressed data */ + unsigned int pos; + unsigned int have; }; #define SPAN G_GINT64_CONSTANT(1048576) static struct fast_seek_point * fast_seek_find(FILE_T file, gint64 pos) { - struct fast_seek_point *smallest = NULL; - struct fast_seek_point *item; - guint low, i, max; + struct fast_seek_point *smallest = NULL; + struct fast_seek_point *item; + guint low, i, max; - if (!file->fast_seek) - return NULL; + if (!file->fast_seek) + return NULL; - for (low = 0, max = file->fast_seek->len; low < max; ) { - i = (low + max) / 2; - item = (struct fast_seek_point *)file->fast_seek->pdata[i]; + for (low = 0, max = file->fast_seek->len; low < max; ) { + i = (low + max) / 2; + item = (struct fast_seek_point *)file->fast_seek->pdata[i]; - if (pos < item->out) - max = i; - else if (pos > item->out) { - smallest = item; - low = i + 1; - } else { - return item; - } - } - return smallest; + if (pos < item->out) + max = i; + else if (pos > item->out) { + smallest = item; + low = i + 1; + } else { + return item; + } + } + return smallest; } static void fast_seek_header(FILE_T file, gint64 in_pos, gint64 out_pos, - compression_t compression) + compression_t compression) { - struct fast_seek_point *item = NULL; + struct fast_seek_point *item = NULL; - if (file->fast_seek->len != 0) - item = (struct fast_seek_point *)file->fast_seek->pdata[file->fast_seek->len - 1]; + if (file->fast_seek->len != 0) + item = (struct fast_seek_point *)file->fast_seek->pdata[file->fast_seek->len - 1]; - if (!item || item->out < out_pos) { - struct fast_seek_point *val = g_new(struct fast_seek_point,1); - val->in = in_pos; - val->out = out_pos; - val->compression = compression; + if (!item || item->out < out_pos) { + struct fast_seek_point *val = g_new(struct fast_seek_point,1); + val->in = in_pos; + val->out = out_pos; + val->compression = compression; - g_ptr_array_add(file->fast_seek, val); - } + g_ptr_array_add(file->fast_seek, val); + } } static void fast_seek_reset(FILE_T state _U_) { #ifdef HAVE_LIBZ - if (state->compression == ZLIB && state->fast_seek_cur) { - struct zlib_cur_seek_point *cur = (struct zlib_cur_seek_point *) state->fast_seek_cur; + if (state->compression == ZLIB && state->fast_seek_cur) { + struct zlib_cur_seek_point *cur = (struct zlib_cur_seek_point *) state->fast_seek_cur; - cur->have = 0; - } + cur->have = 0; + } #endif } @@ -274,36 +274,36 @@ fast_seek_reset(FILE_T state _U_) * * Note: * - * 1) errors from raw_read(), and thus from fill_in_buffer(), are - * "sticky", and fill_in_buffer() won't do any reading if there's - * an error; + * 1) errors from raw_read(), and thus from fill_in_buffer(), are + * "sticky", and fill_in_buffer() won't do any reading if there's + * an error; * - * 2) GZ_GETC() returns -1 on an EOF; + * 2) GZ_GETC() returns -1 on an EOF; * * so it's safe to make multiple GZ_GETC() calls and only check the * last one for an error. */ #define GZ_GETC() ((state->avail_in == 0 && fill_in_buffer(state) == -1) ? -1 : \ - (state->avail_in == 0 ? -1 : \ - (state->avail_in--, *(state->next_in)++))) + (state->avail_in == 0 ? -1 : \ + (state->avail_in--, *(state->next_in)++))) /* Get a one-byte integer and return 0 on success and the value in *ret. Otherwise -1 is returned, state->err is set, and *ret is not modified. */ static int gz_next1(FILE_T state, guint8 *ret) { - int ch; + int ch; - ch = GZ_GETC(); - if (ch == -1) { - if (state->err == 0) { - /* EOF */ - state->err = WTAP_ERR_SHORT_READ; - state->err_info = NULL; - } - return -1; - } - *ret = ch; - return 0; + ch = GZ_GETC(); + if (ch == -1) { + if (state->err == 0) { + /* EOF */ + state->err = WTAP_ERR_SHORT_READ; + state->err_info = NULL; + } + return -1; + } + *ret = ch; + return 0; } /* Get a two-byte little-endian integer and return 0 on success and the value @@ -312,22 +312,22 @@ gz_next1(FILE_T state, guint8 *ret) static int gz_next2(FILE_T state, guint16 *ret) { - guint16 val; - int ch; + guint16 val; + int ch; - val = GZ_GETC(); - ch = GZ_GETC(); - if (ch == -1) { - if (state->err == 0) { - /* EOF */ - state->err = WTAP_ERR_SHORT_READ; - state->err_info = NULL; - } - return -1; - } - val += (guint16)ch << 8; - *ret = val; - return 0; + val = GZ_GETC(); + ch = GZ_GETC(); + if (ch == -1) { + if (state->err == 0) { + /* EOF */ + state->err = WTAP_ERR_SHORT_READ; + state->err_info = NULL; + } + return -1; + } + val += (guint16)ch << 8; + *ret = val; + return 0; } /* Get a four-byte little-endian integer and return 0 on success and the value @@ -336,24 +336,24 @@ gz_next2(FILE_T state, guint16 *ret) static int gz_next4(FILE_T state, guint32 *ret) { - guint32 val; - int ch; + guint32 val; + int ch; - val = GZ_GETC(); - val += (unsigned)GZ_GETC() << 8; - val += (guint32)GZ_GETC() << 16; - ch = GZ_GETC(); - if (ch == -1) { - if (state->err == 0) { - /* EOF */ - state->err = WTAP_ERR_SHORT_READ; - state->err_info = NULL; - } - return -1; - } - val += (guint32)ch << 24; - *ret = val; - return 0; + val = GZ_GETC(); + val += (unsigned)GZ_GETC() << 8; + val += (guint32)GZ_GETC() << 16; + ch = GZ_GETC(); + if (ch == -1) { + if (state->err == 0) { + /* EOF */ + state->err = WTAP_ERR_SHORT_READ; + state->err_info = NULL; + } + return -1; + } + val += (guint32)ch << 24; + *ret = val; + return 0; } /* Skip the specified number of bytes and return 0 on success. Otherwise -1 @@ -361,18 +361,18 @@ gz_next4(FILE_T state, guint32 *ret) static int gz_skipn(FILE_T state, size_t n) { - while (n != 0) { - if (GZ_GETC() == -1) { - if (state->err == 0) { - /* EOF */ - state->err = WTAP_ERR_SHORT_READ; - state->err_info = NULL; - } - return -1; - } - n--; - } - return 0; + while (n != 0) { + if (GZ_GETC() == -1) { + if (state->err == 0) { + /* EOF */ + state->err = WTAP_ERR_SHORT_READ; + state->err_info = NULL; + } + return -1; + } + n--; + } + return 0; } /* Skip a null-terminated string and return 0 on success. Otherwise -1 @@ -380,728 +380,728 @@ gz_skipn(FILE_T state, size_t n) static int gz_skipzstr(FILE_T state) { - int ch; + int ch; - /* It's null-terminated, so scan until we read a byte with - the value 0 or get an error. */ - while ((ch = GZ_GETC()) > 0) - ; - if (ch == -1) { - if (state->err == 0) { - /* EOF */ - state->err = WTAP_ERR_SHORT_READ; - state->err_info = NULL; - } - return -1; - } - return 0; + /* It's null-terminated, so scan until we read a byte with + the value 0 or get an error. */ + while ((ch = GZ_GETC()) > 0) + ; + if (ch == -1) { + if (state->err == 0) { + /* EOF */ + state->err = WTAP_ERR_SHORT_READ; + state->err_info = NULL; + } + return -1; + } + return 0; } static void zlib_fast_seek_add(FILE_T file, struct zlib_cur_seek_point *point, int bits, gint64 in_pos, gint64 out_pos) { - /* it's for sure after gzip header, so file->fast_seek->len != 0 */ - struct fast_seek_point *item = (struct fast_seek_point *)file->fast_seek->pdata[file->fast_seek->len - 1]; + /* it's for sure after gzip header, so file->fast_seek->len != 0 */ + struct fast_seek_point *item = (struct fast_seek_point *)file->fast_seek->pdata[file->fast_seek->len - 1]; #ifndef HAVE_INFLATEPRIME - if (bits) - return; + if (bits) + return; #endif - /* Glib has got Balanced Binary Trees (GTree) but I couldn't find a way to do quick search for nearest (and smaller) value to seek (It's what fast_seek_find() do) - * Inserting value in middle of sorted array is expensive, so we want to add only in the end. - * It's not big deal, cause first-read don't usually invoke seeking - */ - if (item->out + SPAN < out_pos) { - struct fast_seek_point *val = g_new(struct fast_seek_point,1); - val->in = in_pos; - val->out = out_pos; - val->compression = ZLIB; + /* Glib has got Balanced Binary Trees (GTree) but I couldn't find a way to do quick search for nearest (and smaller) value to seek (It's what fast_seek_find() do) + * Inserting value in middle of sorted array is expensive, so we want to add only in the end. + * It's not big deal, cause first-read don't usually invoke seeking + */ + if (item->out + SPAN < out_pos) { + struct fast_seek_point *val = g_new(struct fast_seek_point,1); + val->in = in_pos; + val->out = out_pos; + val->compression = ZLIB; #ifdef HAVE_INFLATEPRIME - val->data.zlib.bits = bits; + val->data.zlib.bits = bits; #endif - if (point->pos != 0) { - unsigned int left = ZLIB_WINSIZE - point->pos; + if (point->pos != 0) { + unsigned int left = ZLIB_WINSIZE - point->pos; - memcpy(val->data.zlib.window, point->window + point->pos, left); - memcpy(val->data.zlib.window + left, point->window, point->pos); - } else - memcpy(val->data.zlib.window, point->window, ZLIB_WINSIZE); + memcpy(val->data.zlib.window, point->window + point->pos, left); + memcpy(val->data.zlib.window + left, point->window, point->pos); + } else + memcpy(val->data.zlib.window, point->window, ZLIB_WINSIZE); - /* - * XXX - strm.adler is a uLong in at least some versions - * of zlib, and uLong is an unsigned long in at least - * some of those versions, which means it's 64-bit - * on LP64 platforms, even though the checksum is - * 32-bit. We assume the actual Adler checksum - * is in the lower 32 bits of strm.adler; as the - * checksum in the file is only 32 bits, we save only - * those lower 32 bits, and cast away any additional - * bits to squelch warnings. - * - * The same applies to strm.total_out. - */ - val->data.zlib.adler = (guint32) file->strm.adler; - val->data.zlib.total_out = (guint32) file->strm.total_out; - g_ptr_array_add(file->fast_seek, val); - } + /* + * XXX - strm.adler is a uLong in at least some versions + * of zlib, and uLong is an unsigned long in at least + * some of those versions, which means it's 64-bit + * on LP64 platforms, even though the checksum is + * 32-bit. We assume the actual Adler checksum + * is in the lower 32 bits of strm.adler; as the + * checksum in the file is only 32 bits, we save only + * those lower 32 bits, and cast away any additional + * bits to squelch warnings. + * + * The same applies to strm.total_out. + */ + val->data.zlib.adler = (guint32) file->strm.adler; + val->data.zlib.total_out = (guint32) file->strm.total_out; + g_ptr_array_add(file->fast_seek, val); + } } static void /* gz_decomp */ zlib_read(FILE_T state, unsigned char *buf, unsigned int count) { - int ret = 0; /* XXX */ - guint32 crc, len; - z_streamp strm = &(state->strm); + int ret = 0; /* XXX */ + guint32 crc, len; + z_streamp strm = &(state->strm); - unsigned char *buf2 = buf; - unsigned int count2 = count; + unsigned char *buf2 = buf; + unsigned int count2 = count; - strm->avail_out = count; - strm->next_out = buf; + strm->avail_out = count; + strm->next_out = buf; - /* fill output buffer up to end of deflate stream or error */ - do { - /* get more input for inflate() */ - if (state->avail_in == 0 && fill_in_buffer(state) == -1) - break; - if (state->avail_in == 0) { - /* EOF */ - state->err = WTAP_ERR_SHORT_READ; - state->err_info = NULL; - break; - } + /* fill output buffer up to end of deflate stream or error */ + do { + /* get more input for inflate() */ + if (state->avail_in == 0 && fill_in_buffer(state) == -1) + break; + if (state->avail_in == 0) { + /* EOF */ + state->err = WTAP_ERR_SHORT_READ; + state->err_info = NULL; + break; + } - strm->avail_in = state->avail_in; - strm->next_in = state->next_in; - /* decompress and handle errors */ + strm->avail_in = state->avail_in; + strm->next_in = state->next_in; + /* decompress and handle errors */ #ifdef Z_BLOCK - ret = inflate(strm, Z_BLOCK); + ret = inflate(strm, Z_BLOCK); #else - ret = inflate(strm, Z_NO_FLUSH); + ret = inflate(strm, Z_NO_FLUSH); #endif - state->avail_in = strm->avail_in; - state->next_in = strm->next_in; - if (ret == Z_STREAM_ERROR) { - state->err = WTAP_ERR_DECOMPRESS; - state->err_info = strm->msg; - break; - } - if (ret == Z_NEED_DICT) { - state->err = WTAP_ERR_DECOMPRESS; - state->err_info = "preset dictionary needed"; - break; - } - if (ret == Z_MEM_ERROR) { - /* This means "not enough memory". */ - state->err = ENOMEM; - state->err_info = NULL; - break; - } - if (ret == Z_DATA_ERROR) { /* deflate stream invalid */ - state->err = WTAP_ERR_DECOMPRESS; - state->err_info = strm->msg; - break; - } - /* - * XXX - Z_BUF_ERROR? - */ + state->avail_in = strm->avail_in; + state->next_in = strm->next_in; + if (ret == Z_STREAM_ERROR) { + state->err = WTAP_ERR_DECOMPRESS; + state->err_info = strm->msg; + break; + } + if (ret == Z_NEED_DICT) { + state->err = WTAP_ERR_DECOMPRESS; + state->err_info = "preset dictionary needed"; + break; + } + if (ret == Z_MEM_ERROR) { + /* This means "not enough memory". */ + state->err = ENOMEM; + state->err_info = NULL; + break; + } + if (ret == Z_DATA_ERROR) { /* deflate stream invalid */ + state->err = WTAP_ERR_DECOMPRESS; + state->err_info = strm->msg; + break; + } + /* + * XXX - Z_BUF_ERROR? + */ - strm->adler = crc32(strm->adler, buf2, count2 - strm->avail_out); + strm->adler = crc32(strm->adler, buf2, count2 - strm->avail_out); #ifdef Z_BLOCK - if (state->fast_seek_cur) { - struct zlib_cur_seek_point *cur = (struct zlib_cur_seek_point *) state->fast_seek_cur; - unsigned int ready = count2 - strm->avail_out; + if (state->fast_seek_cur) { + struct zlib_cur_seek_point *cur = (struct zlib_cur_seek_point *) state->fast_seek_cur; + unsigned int ready = count2 - strm->avail_out; - if (ready < ZLIB_WINSIZE) { - guint left = ZLIB_WINSIZE - cur->pos; + if (ready < ZLIB_WINSIZE) { + guint left = ZLIB_WINSIZE - cur->pos; - if (ready >= left) { - memcpy(cur->window + cur->pos, buf2, left); - if (ready != left) - memcpy(cur->window, buf2 + left, ready - left); + if (ready >= left) { + memcpy(cur->window + cur->pos, buf2, left); + if (ready != left) + memcpy(cur->window, buf2 + left, ready - left); - cur->pos = ready - left; - cur->have += ready; - } else { - memcpy(cur->window + cur->pos, buf2, ready); - cur->pos += ready; - cur->have += ready; - } + cur->pos = ready - left; + cur->have += ready; + } else { + memcpy(cur->window + cur->pos, buf2, ready); + cur->pos += ready; + cur->have += ready; + } - if (cur->have >= ZLIB_WINSIZE) - cur->have = ZLIB_WINSIZE; + if (cur->have >= ZLIB_WINSIZE) + cur->have = ZLIB_WINSIZE; - } else { - memcpy(cur->window, buf2 + (ready - ZLIB_WINSIZE), ZLIB_WINSIZE); - cur->pos = 0; - cur->have = ZLIB_WINSIZE; - } + } else { + memcpy(cur->window, buf2 + (ready - ZLIB_WINSIZE), ZLIB_WINSIZE); + cur->pos = 0; + cur->have = ZLIB_WINSIZE; + } - if (cur->have >= ZLIB_WINSIZE && ret != Z_STREAM_END && (strm->data_type & 128) && !(strm->data_type & 64)) - zlib_fast_seek_add(state, cur, (strm->data_type & 7), state->raw_pos - strm->avail_in, state->pos + (count - strm->avail_out)); - } + if (cur->have >= ZLIB_WINSIZE && ret != Z_STREAM_END && (strm->data_type & 128) && !(strm->data_type & 64)) + zlib_fast_seek_add(state, cur, (strm->data_type & 7), state->raw_pos - strm->avail_in, state->pos + (count - strm->avail_out)); + } #endif - buf2 = (buf2 + count2 - strm->avail_out); - count2 = strm->avail_out; + buf2 = (buf2 + count2 - strm->avail_out); + count2 = strm->avail_out; - } while (strm->avail_out && ret != Z_STREAM_END); + } while (strm->avail_out && ret != Z_STREAM_END); - /* update available output and crc check value */ - state->next = buf; - state->have = count - strm->avail_out; + /* update available output and crc check value */ + state->next = buf; + state->have = count - strm->avail_out; - /* Check gzip trailer if at end of deflate stream. - We don't fail immediately here, we just set an error - indication, so that we try to process what data we - got before the error. The next attempt to read - something past that data will get the error. */ - if (ret == Z_STREAM_END) { - if (gz_next4(state, &crc) != -1 && - gz_next4(state, &len) != -1) { - if (crc != strm->adler && !state->dont_check_crc) { - state->err = WTAP_ERR_DECOMPRESS; - state->err_info = "bad CRC"; - } else if (len != (strm->total_out & 0xffffffffL)) { - state->err = WTAP_ERR_DECOMPRESS; - state->err_info = "length field wrong"; - } - } - state->compression = UNKNOWN; /* ready for next stream, once have is 0 */ - g_free(state->fast_seek_cur); - state->fast_seek_cur = NULL; - } + /* Check gzip trailer if at end of deflate stream. + We don't fail immediately here, we just set an error + indication, so that we try to process what data we + got before the error. The next attempt to read + something past that data will get the error. */ + if (ret == Z_STREAM_END) { + if (gz_next4(state, &crc) != -1 && + gz_next4(state, &len) != -1) { + if (crc != strm->adler && !state->dont_check_crc) { + state->err = WTAP_ERR_DECOMPRESS; + state->err_info = "bad CRC"; + } else if (len != (strm->total_out & 0xffffffffL)) { + state->err = WTAP_ERR_DECOMPRESS; + state->err_info = "length field wrong"; + } + } + state->compression = UNKNOWN; /* ready for next stream, once have is 0 */ + g_free(state->fast_seek_cur); + state->fast_seek_cur = NULL; + } } #endif static int gz_head(FILE_T state) { - /* get some data in the input buffer */ - if (state->avail_in == 0) { - if (fill_in_buffer(state) == -1) - return -1; - if (state->avail_in == 0) - return 0; - } + /* get some data in the input buffer */ + if (state->avail_in == 0) { + if (fill_in_buffer(state) == -1) + return -1; + if (state->avail_in == 0) + return 0; + } - /* look for the gzip magic header bytes 31 and 139 */ + /* look for the gzip magic header bytes 31 and 139 */ #ifdef HAVE_LIBZ - if (state->next_in[0] == 31) { - state->avail_in--; - state->next_in++; - if (state->avail_in == 0 && fill_in_buffer(state) == -1) - return -1; - if (state->avail_in && state->next_in[0] == 139) { - guint8 cm; - guint8 flags; - guint16 len; - guint16 hcrc; + if (state->next_in[0] == 31) { + state->avail_in--; + state->next_in++; + if (state->avail_in == 0 && fill_in_buffer(state) == -1) + return -1; + if (state->avail_in && state->next_in[0] == 139) { + guint8 cm; + guint8 flags; + guint16 len; + guint16 hcrc; - /* we have a gzip header, woo hoo! */ - state->avail_in--; - state->next_in++; + /* we have a gzip header, woo hoo! */ + state->avail_in--; + state->next_in++; - /* read rest of header */ + /* read rest of header */ - /* compression method (CM) */ - if (gz_next1(state, &cm) == -1) - return -1; - if (cm != 8) { - state->err = WTAP_ERR_DECOMPRESS; - state->err_info = "unknown compression method"; - return -1; - } + /* compression method (CM) */ + if (gz_next1(state, &cm) == -1) + return -1; + if (cm != 8) { + state->err = WTAP_ERR_DECOMPRESS; + state->err_info = "unknown compression method"; + return -1; + } - /* flags (FLG) */ - if (gz_next1(state, &flags) == -1) - return -1; - if (flags & 0xe0) { /* reserved flag bits */ - state->err = WTAP_ERR_DECOMPRESS; - state->err_info = "reserved flag bits set"; - return -1; - } + /* flags (FLG) */ + if (gz_next1(state, &flags) == -1) + return -1; + if (flags & 0xe0) { /* reserved flag bits */ + state->err = WTAP_ERR_DECOMPRESS; + state->err_info = "reserved flag bits set"; + return -1; + } - /* modification time (MTIME) */ - if (gz_skipn(state, 4) == -1) - return -1; + /* modification time (MTIME) */ + if (gz_skipn(state, 4) == -1) + return -1; - /* extra flags (XFL) */ - if (gz_skipn(state, 1) == -1) - return -1; + /* extra flags (XFL) */ + if (gz_skipn(state, 1) == -1) + return -1; - /* operating system (OS) */ - if (gz_skipn(state, 1) == -1) - return -1; + /* operating system (OS) */ + if (gz_skipn(state, 1) == -1) + return -1; - if (flags & 4) { - /* extra field - get XLEN */ - if (gz_next2(state, &len) == -1) - return -1; + if (flags & 4) { + /* extra field - get XLEN */ + if (gz_next2(state, &len) == -1) + return -1; - /* skip the extra field */ - if (gz_skipn(state, len) == -1) - return -1; - } - if (flags & 8) { - /* file name */ - if (gz_skipzstr(state) == -1) - return -1; - } - if (flags & 16) { - /* comment */ - if (gz_skipzstr(state) == -1) - return -1; - } - if (flags & 2) { - /* header crc */ - if (gz_next2(state, &hcrc) == -1) - return -1; - /* XXX - check the CRC? */ - } + /* skip the extra field */ + if (gz_skipn(state, len) == -1) + return -1; + } + if (flags & 8) { + /* file name */ + if (gz_skipzstr(state) == -1) + return -1; + } + if (flags & 16) { + /* comment */ + if (gz_skipzstr(state) == -1) + return -1; + } + if (flags & 2) { + /* header crc */ + if (gz_next2(state, &hcrc) == -1) + return -1; + /* XXX - check the CRC? */ + } - /* set up for decompression */ - inflateReset(&(state->strm)); - state->strm.adler = crc32(0L, Z_NULL, 0); - state->compression = ZLIB; - state->is_compressed = TRUE; + /* set up for decompression */ + inflateReset(&(state->strm)); + state->strm.adler = crc32(0L, Z_NULL, 0); + state->compression = ZLIB; + state->is_compressed = TRUE; #ifdef Z_BLOCK - if (state->fast_seek) { - struct zlib_cur_seek_point *cur = g_new(struct zlib_cur_seek_point,1); + if (state->fast_seek) { + struct zlib_cur_seek_point *cur = g_new(struct zlib_cur_seek_point,1); - cur->pos = cur->have = 0; - g_free(state->fast_seek_cur); - state->fast_seek_cur = cur; - fast_seek_header(state, state->raw_pos - state->avail_in, state->pos, GZIP_AFTER_HEADER); - } + cur->pos = cur->have = 0; + g_free(state->fast_seek_cur); + state->fast_seek_cur = cur; + fast_seek_header(state, state->raw_pos - state->avail_in, state->pos, GZIP_AFTER_HEADER); + } #endif - return 0; - } - else { - /* not a gzip file -- save first byte (31) and fall to raw i/o */ - state->out[0] = 31; - state->have = 1; - } - } + return 0; + } + else { + /* not a gzip file -- save first byte (31) and fall to raw i/o */ + state->out[0] = 31; + state->have = 1; + } + } #endif #ifdef HAVE_LIBXZ - /* { 0xFD, '7', 'z', 'X', 'Z', 0x00 } */ - /* FD 37 7A 58 5A 00 */ + /* { 0xFD, '7', 'z', 'X', 'Z', 0x00 } */ + /* FD 37 7A 58 5A 00 */ #endif - if (state->fast_seek) - fast_seek_header(state, state->raw_pos - state->avail_in - state->have, state->pos, UNCOMPRESSED); + if (state->fast_seek) + fast_seek_header(state, state->raw_pos - state->avail_in - state->have, state->pos, UNCOMPRESSED); - /* doing raw i/o, save start of raw data for seeking, copy any leftover - input to output -- this assumes that the output buffer is larger than - the input buffer, which also assures space for gzungetc() */ - state->raw = state->pos; - state->next = state->out; - if (state->avail_in) { - memcpy(state->next + state->have, state->next_in, state->avail_in); - state->have += state->avail_in; - state->avail_in = 0; - } - state->compression = UNCOMPRESSED; - return 0; + /* doing raw i/o, save start of raw data for seeking, copy any leftover + input to output -- this assumes that the output buffer is larger than + the input buffer, which also assures space for gzungetc() */ + state->raw = state->pos; + state->next = state->out; + if (state->avail_in) { + memcpy(state->next + state->have, state->next_in, state->avail_in); + state->have += state->avail_in; + state->avail_in = 0; + } + state->compression = UNCOMPRESSED; + return 0; } static int /* gz_make */ fill_out_buffer(FILE_T state) { - if (state->compression == UNKNOWN) { /* look for gzip header */ - if (gz_head(state) == -1) - return -1; - if (state->have) /* got some data from gz_head() */ - return 0; - } - if (state->compression == UNCOMPRESSED) { /* straight copy */ - if (raw_read(state, state->out, state->size /* << 1 */, &(state->have)) == -1) - return -1; - state->next = state->out; - } + if (state->compression == UNKNOWN) { /* look for gzip header */ + if (gz_head(state) == -1) + return -1; + if (state->have) /* got some data from gz_head() */ + return 0; + } + if (state->compression == UNCOMPRESSED) { /* straight copy */ + if (raw_read(state, state->out, state->size /* << 1 */, &(state->have)) == -1) + return -1; + state->next = state->out; + } #ifdef HAVE_LIBZ - else if (state->compression == ZLIB) { /* decompress */ - zlib_read(state, state->out, state->size << 1); - } + else if (state->compression == ZLIB) { /* decompress */ + zlib_read(state, state->out, state->size << 1); + } #endif - return 0; + return 0; } static int gz_skip(FILE_T state, gint64 len) { - guint n; + guint n; - /* skip over len bytes or reach end-of-file, whichever comes first */ - while (len) - if (state->have) { - /* We have stuff in the output buffer; skip over - it. */ - n = (gint64)state->have > len ? (unsigned)len : state->have; - state->have -= n; - state->next += n; - state->pos += n; - len -= n; - } else if (state->err) { - /* We have nothing in the output buffer, and - we have an error that may not have been - reported yet; that means we can't generate - any more data into the output buffer, so - return an error indication. */ - return -1; - } else if (state->eof && state->avail_in == 0) { - /* We have nothing in the output buffer, and - we're at the end of the input; just return. */ - break; - } else { - /* We have nothing in the output buffer, and - we can generate more data; get more output, - looking for header if required. */ - if (fill_out_buffer(state) == -1) - return -1; - } - return 0; + /* skip over len bytes or reach end-of-file, whichever comes first */ + while (len) + if (state->have) { + /* We have stuff in the output buffer; skip over + it. */ + n = (gint64)state->have > len ? (unsigned)len : state->have; + state->have -= n; + state->next += n; + state->pos += n; + len -= n; + } else if (state->err) { + /* We have nothing in the output buffer, and + we have an error that may not have been + reported yet; that means we can't generate + any more data into the output buffer, so + return an error indication. */ + return -1; + } else if (state->eof && state->avail_in == 0) { + /* We have nothing in the output buffer, and + we're at the end of the input; just return. */ + break; + } else { + /* We have nothing in the output buffer, and + we can generate more data; get more output, + looking for header if required. */ + if (fill_out_buffer(state) == -1) + return -1; + } + return 0; } static void gz_reset(FILE_T state) { - state->have = 0; /* no output data available */ - state->eof = FALSE; /* not at end of file */ - state->compression = UNKNOWN; /* look for gzip header */ + state->have = 0; /* no output data available */ + state->eof = FALSE; /* not at end of file */ + state->compression = UNKNOWN; /* look for gzip header */ - state->seek_pending = FALSE; /* no seek request pending */ - state->err = 0; /* clear error */ - state->err_info = NULL; - state->pos = 0; /* no uncompressed data yet */ - state->avail_in = 0; /* no input data yet */ + state->seek_pending = FALSE; /* no seek request pending */ + state->err = 0; /* clear error */ + state->err_info = NULL; + state->pos = 0; /* no uncompressed data yet */ + state->avail_in = 0; /* no input data yet */ } FILE_T file_fdopen(int fd) { -#ifdef _STATBUF_ST_BLKSIZE /* XXX, _STATBUF_ST_BLKSIZE portable? */ - ws_statb64 st; +#ifdef _STATBUF_ST_BLKSIZE /* XXX, _STATBUF_ST_BLKSIZE portable? */ + ws_statb64 st; #endif - int want = GZBUFSIZE; - FILE_T state; + int want = GZBUFSIZE; + FILE_T state; - if (fd == -1) - return NULL; + if (fd == -1) + return NULL; - /* allocate FILE_T structure to return */ - state = (FILE_T)g_try_malloc(sizeof *state); - if (state == NULL) - return NULL; + /* allocate FILE_T structure to return */ + state = (FILE_T)g_try_malloc(sizeof *state); + if (state == NULL) + return NULL; - state->fast_seek_cur = NULL; - state->fast_seek = NULL; + state->fast_seek_cur = NULL; + state->fast_seek = NULL; - /* open the file with the appropriate mode (or just use fd) */ - state->fd = fd; + /* open the file with the appropriate mode (or just use fd) */ + state->fd = fd; - /* we don't yet know whether it's compressed */ - state->is_compressed = FALSE; + /* we don't yet know whether it's compressed */ + state->is_compressed = FALSE; - /* save the current position for rewinding (only if reading) */ - state->start = ws_lseek64(state->fd, 0, SEEK_CUR); - if (state->start == -1) state->start = 0; - state->raw_pos = state->start; + /* save the current position for rewinding (only if reading) */ + state->start = ws_lseek64(state->fd, 0, SEEK_CUR); + if (state->start == -1) state->start = 0; + state->raw_pos = state->start; - /* initialize stream */ - gz_reset(state); + /* initialize stream */ + gz_reset(state); #ifdef _STATBUF_ST_BLKSIZE - if (ws_fstat64(fd, &st) >= 0) { - /* - * Yes, st_blksize can be bigger than an int; apparently, - * it's a long on LP64 Linux, for example. - * - * If the value is too big to fit into an int, just - * use the default. - */ - if (st.st_blksize <= G_MAXINT) - want = (int)st.st_blksize; - /* XXX, verify result? */ - } + if (ws_fstat64(fd, &st) >= 0) { + /* + * Yes, st_blksize can be bigger than an int; apparently, + * it's a long on LP64 Linux, for example. + * + * If the value is too big to fit into an int, just + * use the default. + */ + if (st.st_blksize <= G_MAXINT) + want = (int)st.st_blksize; + /* XXX, verify result? */ + } #endif - /* allocate buffers */ - state->in = (unsigned char *)g_try_malloc(want); - state->out = (unsigned char *)g_try_malloc(want << 1); - state->size = want; - if (state->in == NULL || state->out == NULL) { - g_free(state->out); - g_free(state->in); - g_free(state); - errno = ENOMEM; - return NULL; - } + /* allocate buffers */ + state->in = (unsigned char *)g_try_malloc(want); + state->out = (unsigned char *)g_try_malloc(want << 1); + state->size = want; + if (state->in == NULL || state->out == NULL) { + g_free(state->out); + g_free(state->in); + g_free(state); + errno = ENOMEM; + return NULL; + } #ifdef HAVE_LIBZ - /* allocate inflate memory */ - state->strm.zalloc = Z_NULL; - state->strm.zfree = Z_NULL; - state->strm.opaque = Z_NULL; - state->strm.avail_in = 0; - state->strm.next_in = Z_NULL; - if (inflateInit2(&(state->strm), -15) != Z_OK) { /* raw inflate */ - g_free(state->out); - g_free(state->in); - g_free(state); - errno = ENOMEM; - return NULL; - } + /* allocate inflate memory */ + state->strm.zalloc = Z_NULL; + state->strm.zfree = Z_NULL; + state->strm.opaque = Z_NULL; + state->strm.avail_in = 0; + state->strm.next_in = Z_NULL; + if (inflateInit2(&(state->strm), -15) != Z_OK) { /* raw inflate */ + g_free(state->out); + g_free(state->in); + g_free(state); + errno = ENOMEM; + return NULL; + } - /* for now, assume we should check the crc */ - state->dont_check_crc = FALSE; + /* for now, assume we should check the crc */ + state->dont_check_crc = FALSE; #endif - /* return stream */ - return state; + /* return stream */ + return state; } FILE_T file_open(const char *path) { - int fd; - FILE_T ft; + int fd; + FILE_T ft; #ifdef HAVE_LIBZ - const char *suffixp; + const char *suffixp; #endif - /* open file and do correct filename conversions. + /* open file and do correct filename conversions. - XXX - do we need O_LARGEFILE? On UN*X, if we need to do - something special to get large file support, the configure - script should have set us up with the appropriate #defines, - so we should be getting a large-file-enabled file descriptor - here. Pre-Large File Summit UN*Xes, and possibly even some - post-LFS UN*Xes, might require O_LARGEFILE here, though. - If so, we should probably handle that in ws_open(). */ - if ((fd = ws_open(path, O_RDONLY|O_BINARY, 0000)) == -1) - return NULL; + XXX - do we need O_LARGEFILE? On UN*X, if we need to do + something special to get large file support, the configure + script should have set us up with the appropriate #defines, + so we should be getting a large-file-enabled file descriptor + here. Pre-Large File Summit UN*Xes, and possibly even some + post-LFS UN*Xes, might require O_LARGEFILE here, though. + If so, we should probably handle that in ws_open(). */ + if ((fd = ws_open(path, O_RDONLY|O_BINARY, 0000)) == -1) + return NULL; - /* open file handle */ - ft = file_fdopen(fd); - if (ft == NULL) { - ws_close(fd); - return NULL; - } + /* open file handle */ + ft = file_fdopen(fd); + if (ft == NULL) { + ws_close(fd); + return NULL; + } #ifdef HAVE_LIBZ - /* - * If this file's name ends in ".caz", it's probably a compressed - * Windows Sniffer file. The compression is gzip, but if we - * process the CRC as specified by RFC 1952, the computed CRC - * doesn't match the stored CRC. - * - * Compressed Windows Sniffer files don't all have the same CRC - * value; is it just random crap, or are they running the CRC on - * a different set of data than you're supposed to (e.g., not - * CRCing some of the data), or something such as that? - * - * For now, we just set a flag to ignore CRC errors. - */ - suffixp = strrchr(path, '.'); - if (suffixp != NULL) { - if (g_ascii_strcasecmp(suffixp, ".caz") == 0) - ft->dont_check_crc = TRUE; - } + /* + * If this file's name ends in ".caz", it's probably a compressed + * Windows Sniffer file. The compression is gzip, but if we + * process the CRC as specified by RFC 1952, the computed CRC + * doesn't match the stored CRC. + * + * Compressed Windows Sniffer files don't all have the same CRC + * value; is it just random crap, or are they running the CRC on + * a different set of data than you're supposed to (e.g., not + * CRCing some of the data), or something such as that? + * + * For now, we just set a flag to ignore CRC errors. + */ + suffixp = strrchr(path, '.'); + if (suffixp != NULL) { + if (g_ascii_strcasecmp(suffixp, ".caz") == 0) + ft->dont_check_crc = TRUE; + } #endif - return ft; + return ft; } void file_set_random_access(FILE_T stream, gboolean random_flag _U_, GPtrArray *seek) { - stream->fast_seek = seek; + stream->fast_seek = seek; } gint64 file_seek(FILE_T file, gint64 offset, int whence, int *err) { - struct fast_seek_point *here; - guint n; + struct fast_seek_point *here; + guint n; - /* can only seek from start or relative to current position */ - if (whence != SEEK_SET && whence != SEEK_CUR) { - g_assert_not_reached(); + /* can only seek from start or relative to current position */ + if (whence != SEEK_SET && whence != SEEK_CUR) { + g_assert_not_reached(); /* - *err = EINVAL; - return -1; - */ - } + *err = EINVAL; + return -1; +*/ + } - /* normalize offset to a SEEK_CUR specification */ - if (whence == SEEK_SET) - offset -= file->pos; - else if (file->seek_pending) - offset += file->skip; - file->seek_pending = FALSE; + /* normalize offset to a SEEK_CUR specification */ + if (whence == SEEK_SET) + offset -= file->pos; + else if (file->seek_pending) + offset += file->skip; + file->seek_pending = FALSE; - if (offset < 0 && file->next) { - /* - * This is guaranteed to fit in an unsigned int. - * To squelch compiler warnings, we cast the - * result. - */ - guint had = (unsigned)(file->next - file->out); - if (-offset <= had) { - /* - * Offset is negative, so -offset is - * non-negative, and -offset is - * <= an unsigned and thus fits in an - * unsigned. Get that value and - * adjust appropriately. - * - * (Casting offset to unsigned makes - * it positive, which is not what we - * would want, so we cast -offset - * instead.) - */ - guint adjustment = (unsigned)(-offset); - file->have += adjustment; - file->next -= adjustment; - file->pos -= adjustment; - return file->pos; - } - } + if (offset < 0 && file->next) { + /* + * This is guaranteed to fit in an unsigned int. + * To squelch compiler warnings, we cast the + * result. + */ + guint had = (unsigned)(file->next - file->out); + if (-offset <= had) { + /* + * Offset is negative, so -offset is + * non-negative, and -offset is + * <= an unsigned and thus fits in an + * unsigned. Get that value and + * adjust appropriately. + * + * (Casting offset to unsigned makes + * it positive, which is not what we + * would want, so we cast -offset + * instead.) + */ + guint adjustment = (unsigned)(-offset); + file->have += adjustment; + file->next -= adjustment; + file->pos -= adjustment; + return file->pos; + } + } - /* XXX, profile */ - if ((here = fast_seek_find(file, file->pos + offset)) && (offset < 0 || offset > SPAN || here->compression == UNCOMPRESSED)) { - gint64 off, off2; + /* XXX, profile */ + if ((here = fast_seek_find(file, file->pos + offset)) && (offset < 0 || offset > SPAN || here->compression == UNCOMPRESSED)) { + gint64 off, off2; #ifdef HAVE_LIBZ - if (here->compression == ZLIB) { + if (here->compression == ZLIB) { #ifdef HAVE_INFLATEPRIME - off = here->in - (here->data.zlib.bits ? 1 : 0); + off = here->in - (here->data.zlib.bits ? 1 : 0); #else - off = here->in; + off = here->in; #endif - off2 = here->out; - } else if (here->compression == GZIP_AFTER_HEADER) { - off = here->in; - off2 = here->out; - } else + off2 = here->out; + } else if (here->compression == GZIP_AFTER_HEADER) { + off = here->in; + off2 = here->out; + } else #endif - { - off2 = (file->pos + offset); - off = here->in + (off2 - here->out); - } + { + off2 = (file->pos + offset); + off = here->in + (off2 - here->out); + } - if (ws_lseek64(file->fd, off, SEEK_SET) == -1) { - *err = errno; - return -1; - } - fast_seek_reset(file); + if (ws_lseek64(file->fd, off, SEEK_SET) == -1) { + *err = errno; + return -1; + } + fast_seek_reset(file); - file->raw_pos = off; - file->have = 0; - file->eof = FALSE; - file->seek_pending = FALSE; - file->err = 0; - file->err_info = NULL; - file->avail_in = 0; + file->raw_pos = off; + file->have = 0; + file->eof = FALSE; + file->seek_pending = FALSE; + file->err = 0; + file->err_info = NULL; + file->avail_in = 0; #ifdef HAVE_LIBZ - if (here->compression == ZLIB) { - z_stream *strm = &file->strm; + if (here->compression == ZLIB) { + z_stream *strm = &file->strm; - inflateReset(strm); - strm->adler = here->data.zlib.adler; - strm->total_out = here->data.zlib.total_out; + inflateReset(strm); + strm->adler = here->data.zlib.adler; + strm->total_out = here->data.zlib.total_out; #ifdef HAVE_INFLATEPRIME - if (here->data.zlib.bits) { - FILE_T state = file; - int ret = GZ_GETC(); + if (here->data.zlib.bits) { + FILE_T state = file; + int ret = GZ_GETC(); - if (ret == -1) { - if (state->err == 0) { - /* EOF */ - *err = WTAP_ERR_SHORT_READ; - } else - *err = state->err; - return -1; - } - (void)inflatePrime(strm, here->data.zlib.bits, ret >> (8 - here->data.zlib.bits)); - } + if (ret == -1) { + if (state->err == 0) { + /* EOF */ + *err = WTAP_ERR_SHORT_READ; + } else + *err = state->err; + return -1; + } + (void)inflatePrime(strm, here->data.zlib.bits, ret >> (8 - here->data.zlib.bits)); + } #endif - (void)inflateSetDictionary(strm, here->data.zlib.window, ZLIB_WINSIZE); - file->compression = ZLIB; - } else if (here->compression == GZIP_AFTER_HEADER) { - z_stream *strm = &file->strm; + (void)inflateSetDictionary(strm, here->data.zlib.window, ZLIB_WINSIZE); + file->compression = ZLIB; + } else if (here->compression == GZIP_AFTER_HEADER) { + z_stream *strm = &file->strm; - inflateReset(strm); - strm->adler = crc32(0L, Z_NULL, 0); - file->compression = ZLIB; - } else + inflateReset(strm); + strm->adler = crc32(0L, Z_NULL, 0); + file->compression = ZLIB; + } else #endif - file->compression = here->compression; + file->compression = here->compression; - offset = (file->pos + offset) - off2; - file->pos = off2; - /* g_print("OK! %ld\n", offset); */ + offset = (file->pos + offset) - off2; + file->pos = off2; + /* g_print("OK! %ld\n", offset); */ - if (offset) { - file->seek_pending = TRUE; - file->skip = offset; - } - return file->pos + offset; - } + if (offset) { + file->seek_pending = TRUE; + file->skip = offset; + } + return file->pos + offset; + } - /* if within raw area while reading, just go there */ - if (file->compression == UNCOMPRESSED && file->pos + offset >= file->raw - && (offset < 0 || offset >= file->have) /* seek only when we don't have that offset in buffer */ - && (file->fast_seek) /* seek only when random access is supported */) - { - if (ws_lseek64(file->fd, offset - file->have, SEEK_CUR) == -1) { - *err = errno; - return -1; - } - file->raw_pos += (offset - file->have); - file->have = 0; - file->eof = FALSE; - file->seek_pending = FALSE; - file->err = 0; - file->err_info = NULL; - file->avail_in = 0; - file->pos += offset; - return file->pos; - } + /* if within raw area while reading, just go there */ + if (file->compression == UNCOMPRESSED && file->pos + offset >= file->raw + && (offset < 0 || offset >= file->have) /* seek only when we don't have that offset in buffer */ + && (file->fast_seek) /* seek only when random access is supported */) + { + if (ws_lseek64(file->fd, offset - file->have, SEEK_CUR) == -1) { + *err = errno; + return -1; + } + file->raw_pos += (offset - file->have); + file->have = 0; + file->eof = FALSE; + file->seek_pending = FALSE; + file->err = 0; + file->err_info = NULL; + file->avail_in = 0; + file->pos += offset; + return file->pos; + } - /* calculate skip amount, rewinding if needed for back seek when reading */ - if (offset < 0) { - offset += file->pos; - if (offset < 0) { /* before start of file! */ - *err = EINVAL; - return -1; - } - /* rewind, then skip to offset */ + /* calculate skip amount, rewinding if needed for back seek when reading */ + if (offset < 0) { + offset += file->pos; + if (offset < 0) { /* before start of file! */ + *err = EINVAL; + return -1; + } + /* rewind, then skip to offset */ - /* back up and start over */ - if (ws_lseek64(file->fd, file->start, SEEK_SET) == -1) { - *err = errno; - return -1; - } - fast_seek_reset(file); - file->raw_pos = file->start; - gz_reset(file); - } + /* back up and start over */ + if (ws_lseek64(file->fd, file->start, SEEK_SET) == -1) { + *err = errno; + return -1; + } + fast_seek_reset(file); + file->raw_pos = file->start; + gz_reset(file); + } - /* skip what's in output buffer (one less gzgetc() check) */ - n = (gint64)file->have > offset ? (unsigned)offset : file->have; - file->have -= n; - file->next += n; - file->pos += n; - offset -= n; + /* skip what's in output buffer (one less gzgetc() check) */ + n = (gint64)file->have > offset ? (unsigned)offset : file->have; + file->have -= n; + file->next += n; + file->pos += n; + offset -= n; - /* request skip (if not zero) */ - if (offset) { - file->seek_pending = TRUE; - file->skip = offset; - } - return file->pos + offset; + /* request skip (if not zero) */ + if (offset) { + file->seek_pending = TRUE; + file->skip = offset; + } + return file->pos + offset; } /* @@ -1114,97 +1114,97 @@ file_seek(FILE_T file, gint64 offset, int whence, int *err) gboolean file_skip(FILE_T file, gint64 delta, int *err) { - if (file_seek(file, delta, SEEK_CUR, err) == -1) - return FALSE; - return TRUE; + if (file_seek(file, delta, SEEK_CUR, err) == -1) + return FALSE; + return TRUE; } gint64 file_tell(FILE_T stream) { - /* return position */ - return stream->pos + (stream->seek_pending ? stream->skip : 0); + /* return position */ + return stream->pos + (stream->seek_pending ? stream->skip : 0); } gint64 file_tell_raw(FILE_T stream) { - return stream->raw_pos; + return stream->raw_pos; } int file_fstat(FILE_T stream, ws_statb64 *statb, int *err) { - if (ws_fstat64(stream->fd, statb) == -1) { - if (err != NULL) - *err = errno; - return -1; - } - return 0; + if (ws_fstat64(stream->fd, statb) == -1) { + if (err != NULL) + *err = errno; + return -1; + } + return 0; } gboolean file_iscompressed(FILE_T stream) { - return stream->is_compressed; + return stream->is_compressed; } int file_read(void *buf, unsigned int len, FILE_T file) { - guint got, n; + guint got, n; - /* if len is zero, avoid unnecessary operations */ - if (len == 0) - return 0; + /* if len is zero, avoid unnecessary operations */ + if (len == 0) + return 0; - /* process a skip request */ - if (file->seek_pending) { - file->seek_pending = FALSE; - if (gz_skip(file, file->skip) == -1) - return -1; - } + /* process a skip request */ + if (file->seek_pending) { + file->seek_pending = FALSE; + if (gz_skip(file, file->skip) == -1) + return -1; + } - /* get len bytes to buf, or less than len if at the end */ - got = 0; - do { - if (file->have) { - /* We have stuff in the output buffer; copy - what we have. */ - n = file->have > len ? len : file->have; - memcpy(buf, file->next, n); - file->next += n; - file->have -= n; - } else if (file->err) { - /* We have nothing in the output buffer, and - we have an error that may not have been - reported yet; that means we can't generate - any more data into the output buffer, so - return an error indication. */ - return -1; - } else if (file->eof && file->avail_in == 0) { - /* We have nothing in the output buffer, and - we're at the end of the input; just return - with what we've gotten so far. */ - break; - } else { - /* We have nothing in the output buffer, and - we can generate more data; get more output, - looking for header if required, and - keep looping to process the new stuff - in the output buffer. */ - if (fill_out_buffer(file) == -1) - return -1; - continue; /* no progress yet -- go back to memcpy() above */ - } - /* update progress */ - len -= n; - buf = (char *)buf + n; - got += n; - file->pos += n; - } while (len); + /* get len bytes to buf, or less than len if at the end */ + got = 0; + do { + if (file->have) { + /* We have stuff in the output buffer; copy + what we have. */ + n = file->have > len ? len : file->have; + memcpy(buf, file->next, n); + file->next += n; + file->have -= n; + } else if (file->err) { + /* We have nothing in the output buffer, and + we have an error that may not have been + reported yet; that means we can't generate + any more data into the output buffer, so + return an error indication. */ + return -1; + } else if (file->eof && file->avail_in == 0) { + /* We have nothing in the output buffer, and + we're at the end of the input; just return + with what we've gotten so far. */ + break; + } else { + /* We have nothing in the output buffer, and + we can generate more data; get more output, + looking for header if required, and + keep looping to process the new stuff + in the output buffer. */ + if (fill_out_buffer(file) == -1) + return -1; + continue; /* no progress yet -- go back to memcpy() above */ + } + /* update progress */ + len -= n; + buf = (char *)buf + n; + got += n; + file->pos += n; + } while (len); - return (int)got; + return (int)got; } /* @@ -1213,45 +1213,45 @@ file_read(void *buf, unsigned int len, FILE_T file) int file_peekc(FILE_T file) { - int ret = 0; + int ret = 0; - /* check that we're reading and that there's no error */ - if (file->err) - return -1; + /* check that we're reading and that there's no error */ + if (file->err) + return -1; - /* try output buffer (no need to check for skip request) */ - if (file->have) { - return *(file->next); - } + /* try output buffer (no need to check for skip request) */ + if (file->have) { + return *(file->next); + } - /* process a skip request */ - if (file->seek_pending) { - file->seek_pending = FALSE; - if (gz_skip(file, file->skip) == -1) - return -1; - } - /* if we processed a skip request, there may be data in the buffer, - * or an error could have occurred; likewise if we didn't do seek but - * now call fill_out_buffer, the errors can occur. So we do this while - * loop to check before and after - this is basically the logic from - * file_read() but only for peeking not consuming a byte - */ - while (1) { - if (file->have) { - return *(file->next); - } - else if (file->err) { - return -1; - } - else if (file->eof && file->avail_in == 0) { - return -1; - } - else if (fill_out_buffer(file) == -1) { - return -1; - } - } - /* it's actually impossible to get here */ - return ret; + /* process a skip request */ + if (file->seek_pending) { + file->seek_pending = FALSE; + if (gz_skip(file, file->skip) == -1) + return -1; + } + /* if we processed a skip request, there may be data in the buffer, + * or an error could have occurred; likewise if we didn't do seek but + * now call fill_out_buffer, the errors can occur. So we do this while + * loop to check before and after - this is basically the logic from + * file_read() but only for peeking not consuming a byte + */ + while (1) { + if (file->have) { + return *(file->next); + } + else if (file->err) { + return -1; + } + else if (file->eof && file->avail_in == 0) { + return -1; + } + else if (fill_out_buffer(file) == -1) { + return -1; + } + } + /* it's actually impossible to get here */ + return ret; } /* @@ -1260,97 +1260,97 @@ file_peekc(FILE_T file) int file_getc(FILE_T file) { - unsigned char buf[1]; - int ret; + unsigned char buf[1]; + int ret; - /* check that we're reading and that there's no error */ - if (file->err) - return -1; + /* check that we're reading and that there's no error */ + if (file->err) + return -1; - /* try output buffer (no need to check for skip request) */ - if (file->have) { - file->have--; - file->pos++; - return *(file->next)++; - } + /* try output buffer (no need to check for skip request) */ + if (file->have) { + file->have--; + file->pos++; + return *(file->next)++; + } - ret = file_read(buf, 1, file); - return ret < 1 ? -1 : buf[0]; + ret = file_read(buf, 1, file); + return ret < 1 ? -1 : buf[0]; } char * file_gets(char *buf, int len, FILE_T file) { - guint left, n; - char *str; - unsigned char *eol; + guint left, n; + char *str; + unsigned char *eol; - /* check parameters */ - if (buf == NULL || len < 1) - return NULL; + /* check parameters */ + if (buf == NULL || len < 1) + return NULL; - /* check that there's no error */ - if (file->err) - return NULL; + /* check that there's no error */ + if (file->err) + return NULL; - /* process a skip request */ - if (file->seek_pending) { - file->seek_pending = FALSE; - if (gz_skip(file, file->skip) == -1) - return NULL; - } + /* process a skip request */ + if (file->seek_pending) { + file->seek_pending = FALSE; + if (gz_skip(file, file->skip) == -1) + return NULL; + } - /* copy output bytes up to new line or len - 1, whichever comes first -- - append a terminating zero to the string (we don't check for a zero in - the contents, let the user worry about that) */ - str = buf; - left = (unsigned)len - 1; - if (left) do { - /* assure that something is in the output buffer */ - if (file->have == 0) { - /* We have nothing in the output buffer. */ - if (file->err) { - /* We have an error that may not have - been reported yet; that means we - can't generate any more data into - the output buffer, so return an - error indication. */ - return NULL; - } - if (fill_out_buffer(file) == -1) - return NULL; /* error */ - if (file->have == 0) { /* end of file */ - if (buf == str) /* got bupkus */ - return NULL; - break; /* got something -- return it */ - } - } + /* copy output bytes up to new line or len - 1, whichever comes first -- + append a terminating zero to the string (we don't check for a zero in + the contents, let the user worry about that) */ + str = buf; + left = (unsigned)len - 1; + if (left) do { + /* assure that something is in the output buffer */ + if (file->have == 0) { + /* We have nothing in the output buffer. */ + if (file->err) { + /* We have an error that may not have + been reported yet; that means we + can't generate any more data into + the output buffer, so return an + error indication. */ + return NULL; + } + if (fill_out_buffer(file) == -1) + return NULL; /* error */ + if (file->have == 0) { /* end of file */ + if (buf == str) /* got bupkus */ + return NULL; + break; /* got something -- return it */ + } + } - /* look for end-of-line in current output buffer */ - n = file->have > left ? left : file->have; - eol = (unsigned char *)memchr(file->next, '\n', n); - if (eol != NULL) - n = (unsigned)(eol - file->next) + 1; + /* look for end-of-line in current output buffer */ + n = file->have > left ? left : file->have; + eol = (unsigned char *)memchr(file->next, '\n', n); + if (eol != NULL) + n = (unsigned)(eol - file->next) + 1; - /* copy through end-of-line, or remainder if not found */ - memcpy(buf, file->next, n); - file->have -= n; - file->next += n; - file->pos += n; - left -= n; - buf += n; - } while (left && eol == NULL); + /* copy through end-of-line, or remainder if not found */ + memcpy(buf, file->next, n); + file->have -= n; + file->next += n; + file->pos += n; + left -= n; + buf += n; + } while (left && eol == NULL); - /* found end-of-line or out of space -- terminate string and return it */ - buf[0] = 0; - return str; + /* found end-of-line or out of space -- terminate string and return it */ + buf[0] = 0; + return str; } int file_eof(FILE_T file) { - /* return end-of-file state */ - return (file->eof && file->avail_in == 0 && file->have == 0); + /* return end-of-file state */ + return (file->eof && file->avail_in == 0 && file->have == 0); } /* @@ -1361,64 +1361,64 @@ file_eof(FILE_T file) int file_error(FILE_T fh, gchar **err_info) { - if (fh->err!=0 && err_info) { - /* g_strdup() returns NULL for NULL argument */ - *err_info = g_strdup(fh->err_info); - } - return fh->err; + if (fh->err!=0 && err_info) { + /* g_strdup() returns NULL for NULL argument */ + *err_info = g_strdup(fh->err_info); + } + return fh->err; } void file_clearerr(FILE_T stream) { - /* clear error and end-of-file */ - stream->err = 0; - stream->err_info = NULL; - stream->eof = FALSE; + /* clear error and end-of-file */ + stream->err = 0; + stream->err_info = NULL; + stream->eof = FALSE; } void file_fdclose(FILE_T file) { - ws_close(file->fd); - file->fd = -1; + ws_close(file->fd); + file->fd = -1; } gboolean file_fdreopen(FILE_T file, const char *path) { - int fd; + int fd; - if ((fd = ws_open(path, O_RDONLY|O_BINARY, 0000)) == -1) - return FALSE; - file->fd = fd; - return TRUE; + if ((fd = ws_open(path, O_RDONLY|O_BINARY, 0000)) == -1) + return FALSE; + file->fd = fd; + return TRUE; } void file_close(FILE_T file) { - int fd = file->fd; + int fd = file->fd; - /* free memory and close file */ - if (file->size) { + /* free memory and close file */ + if (file->size) { #ifdef HAVE_LIBZ - inflateEnd(&(file->strm)); + inflateEnd(&(file->strm)); #endif - g_free(file->out); - g_free(file->in); - } - g_free(file->fast_seek_cur); - file->err = 0; - file->err_info = NULL; - g_free(file); - /* - * If fd is -1, somebody's done a file_closefd() on us, so - * we don't need to close the FD itself, and shouldn't do - * so. - */ - if (fd != -1) - ws_close(fd); + g_free(file->out); + g_free(file->in); + } + g_free(file->fast_seek_cur); + file->err = 0; + file->err_info = NULL; + g_free(file); + /* + * If fd is -1, somebody's done a file_closefd() on us, so + * we don't need to close the FD itself, and shouldn't do + * so. + */ + if (fd != -1) + ws_close(fd); } #ifdef HAVE_LIBZ @@ -1434,7 +1434,7 @@ struct wtap_writer { int level; /* compression level */ int strategy; /* compression strategy */ int err; /* error code */ - /* zlib deflate stream */ + /* zlib deflate stream */ z_stream strm; /* stream structure in-place (not a pointer) */ }; @@ -1511,11 +1511,11 @@ gz_init(GZWFILE_T state) g_free(state->out); g_free(state->in); if (ret == Z_MEM_ERROR) { - /* This means "not enough memory". */ - state->err = ENOMEM; + /* This means "not enough memory". */ + state->err = ENOMEM; } else { - /* This "shouldn't happen". */ - state->err = WTAP_ERR_INTERNAL; + /* This "shouldn't happen". */ + state->err = WTAP_ERR_INTERNAL; } return -1; } @@ -1553,11 +1553,11 @@ gz_comp(GZWFILE_T state, int flush) /* write out current buffer contents if full, or if flushing, but if doing Z_FINISH then don't write until we get to Z_STREAM_END */ if (strm->avail_out == 0 || (flush != Z_NO_FLUSH && - (flush != Z_FINISH || ret == Z_STREAM_END))) { + (flush != Z_FINISH || ret == Z_STREAM_END))) { have = strm->next_out - state->next; if (have) { - got = write(state->fd, state->next, (unsigned int)have); - if (got < 0) { + got = write(state->fd, state->next, (unsigned int)have); + if (got < 0) { state->err = errno; return -1; } @@ -1693,3 +1693,16 @@ gzwfile_geterr(GZWFILE_T state) return state->err; } #endif + +/* + * Editor modelines - http://www.wireshark.org/tools/modelines.html + * + * Local variables: + * c-basic-offset: 4 + * tab-width: 8 + * indent-tabs-mode: nil + * End: + * + * vi: set shiftwidth=4 tabstop=8 expandtab: + * :indentSize=4:tabSize=8:noTabs=true: + */