diff options
26 files changed, 108 insertions, 28 deletions
diff --git a/epan/dissectors/packet-2dparityfec.c b/epan/dissectors/packet-2dparityfec.c index 53315d315b..85221e7f92 100644 --- a/epan/dissectors/packet-2dparityfec.c +++ b/epan/dissectors/packet-2dparityfec.c @@ -295,6 +295,7 @@ void proto_register_2dparityfec(void) { module_t *module_2dparityfec; +#ifndef HAVE_HFI_SECTION_INIT /* Payload type definitions */ static header_field_info *hfi[] = { &hfi_2dparityfec_snbase_low, @@ -312,6 +313,7 @@ void proto_register_2dparityfec(void) &hfi_2dparityfec_snbase_ext, &hfi_2dparityfec_payload, }; +#endif /* Setup protocol subtree array */ static gint *ett[] = { diff --git a/epan/dissectors/packet-acap.c b/epan/dissectors/packet-acap.c index 1dd9f4db18..20b7904dfb 100644 --- a/epan/dissectors/packet-acap.c +++ b/epan/dissectors/packet-acap.c @@ -174,10 +174,12 @@ dissect_acap(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) void proto_register_acap(void) { +#ifndef HAVE_HFI_SECTION_INIT static header_field_info *hfi[] = { &hfi_acap_response, &hfi_acap_request, }; +#endif static gint *ett[] = { &ett_acap, diff --git a/epan/dissectors/packet-bitcoin.c b/epan/dissectors/packet-bitcoin.c index 89be74a698..337503459d 100644 --- a/epan/dissectors/packet-bitcoin.c +++ b/epan/dissectors/packet-bitcoin.c @@ -1120,6 +1120,7 @@ dissect_bitcoin_heur(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void * void proto_register_bitcoin(void) { +#ifndef HAVE_HFI_SECTION_INIT static header_field_info *hfi[] = { &hfi_bitcoin_magic, &hfi_bitcoin_command, @@ -1248,6 +1249,7 @@ proto_register_bitcoin(void) &hfi_string_varint_count32, &hfi_string_varint_count64, }; +#endif static gint *ett[] = { &ett_bitcoin, diff --git a/epan/dissectors/packet-data.c b/epan/dissectors/packet-data.c index 13c5950a98..e6a2830c92 100644 --- a/epan/dissectors/packet-data.c +++ b/epan/dissectors/packet-data.c @@ -119,12 +119,14 @@ dissect_data(tvbuff_t *tvb, packet_info *pinfo _U_ , proto_tree *tree) void proto_register_data(void) { +#ifndef HAVE_HFI_SECTION_INIT static header_field_info *hfi[] = { &hfi_data_data, &hfi_data_text, &hfi_data_md5_hash, &hfi_data_len, }; +#endif static gint *ett[] = { &ett_data diff --git a/epan/dissectors/packet-daytime.c b/epan/dissectors/packet-daytime.c index 926beb1ec2..0eacced3af 100644 --- a/epan/dissectors/packet-daytime.c +++ b/epan/dissectors/packet-daytime.c @@ -77,9 +77,11 @@ dissect_daytime(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) void proto_register_daytime(void) { +#ifndef HAVE_HFI_SECTION_INIT static header_field_info *hfi[] = { &hfi_daytime_string, }; +#endif static gint *ett[] = { &ett_daytime, diff --git a/epan/dissectors/packet-dbus.c b/epan/dissectors/packet-dbus.c index 6cbb27015b..8d48724c94 100644 --- a/epan/dissectors/packet-dbus.c +++ b/epan/dissectors/packet-dbus.c @@ -629,6 +629,7 @@ dissect_dbus_tcp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data void proto_register_dbus(void) { +#ifndef HAVE_HFI_SECTION_INIT static header_field_info *hfi[] = { /* Header */ &hfi_dbus_hdr, @@ -651,6 +652,7 @@ proto_register_dbus(void) &hfi_dbus_value_str, &hfi_dbus_value_double, }; +#endif static gint *ett[] = { &ett_dbus, diff --git a/epan/dissectors/packet-fcdns.c b/epan/dissectors/packet-fcdns.c index f92fa3c1f6..500f8f5123 100644 --- a/epan/dissectors/packet-fcdns.c +++ b/epan/dissectors/packet-fcdns.c @@ -1860,7 +1860,7 @@ dissect_fcdns (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) void proto_register_fcdns (void) { - +#ifndef HAVE_HFI_SECTION_INIT static header_field_info *hfi[] = { /* &hfi_fcdns_gssubtype */ &hfi_fcdns_opcode, @@ -1927,6 +1927,7 @@ proto_register_fcdns (void) &hfi_fcdns_fc4features_i, &hfi_fcdns_fc4features_t, }; +#endif static gint *ett[] = { &ett_fcdns, diff --git a/epan/dissectors/packet-gadu-gadu.c b/epan/dissectors/packet-gadu-gadu.c index 313f3d4db7..000ef179ed 100644 --- a/epan/dissectors/packet-gadu-gadu.c +++ b/epan/dissectors/packet-gadu-gadu.c @@ -2038,6 +2038,7 @@ dissect_gadu_gadu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *dat void proto_register_gadu_gadu(void) { +#ifndef HAVE_HFI_SECTION_INIT static header_field_info *hfi[] = { /* Header */ &hfi_gadu_gadu_header_type_recv, @@ -2114,6 +2115,7 @@ proto_register_gadu_gadu(void) /* Not dissected data */ &hfi_gadu_gadu_data, }; +#endif /* HAVE_HFI_SECTION_INIT */ static gint *ett[] = { &ett_gadu_gadu, diff --git a/epan/dissectors/packet-hpext.c b/epan/dissectors/packet-hpext.c index d946a661c8..2a23d26456 100644 --- a/epan/dissectors/packet-hpext.c +++ b/epan/dissectors/packet-hpext.c @@ -104,10 +104,12 @@ dissect_hpext(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) void proto_register_hpext(void) { +#ifndef HAVE_HFI_SECTION_INIT static header_field_info *hfi[] = { &hfi_hpext_dxsap, &hfi_hpext_sxsap, }; +#endif static gint *ett[] = { &ett_hpext diff --git a/epan/dissectors/packet-http-urlencoded.c b/epan/dissectors/packet-http-urlencoded.c index 4e89e43ca2..38951e0f8c 100644 --- a/epan/dissectors/packet-http-urlencoded.c +++ b/epan/dissectors/packet-http-urlencoded.c @@ -203,11 +203,13 @@ dissect_form_urlencoded(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, voi void proto_register_http_urlencoded(void) { +#ifndef HAVE_HFI_SECTION_INIT static header_field_info *hfi[] = { &hfi_form_keyvalue, &hfi_form_key, &hfi_form_value, }; +#endif static gint *ett[] = { &ett_form_urlencoded, diff --git a/epan/dissectors/packet-image-gif.c b/epan/dissectors/packet-image-gif.c index 44de462d78..42c9eb33e3 100644 --- a/epan/dissectors/packet-image-gif.c +++ b/epan/dissectors/packet-image-gif.c @@ -610,6 +610,7 @@ dissect_gif_heur(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data void proto_register_gif(void) { +#ifndef HAVE_HFI_SECTION_INIT /* * Setup list of header fields. */ @@ -661,6 +662,7 @@ proto_register_gif(void) */ &hfi_trailer, }; +#endif /* Setup protocol subtree array */ static gint *ett[] = { diff --git a/epan/dissectors/packet-image-png.c b/epan/dissectors/packet-image-png.c index b9599cdbcf..7c37164ddd 100644 --- a/epan/dissectors/packet-image-png.c +++ b/epan/dissectors/packet-image-png.c @@ -406,6 +406,7 @@ dissect_png(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, void *da void proto_register_png(void) { +#ifndef HAVE_HFI_SECTION_INIT static header_field_info *hfi[] = { &hfi_png_signature, @@ -440,6 +441,7 @@ proto_register_png(void) &hfi_png_bkgd_green, &hfi_png_bkgd_blue, }; +#endif static gint *ett[] = { diff --git a/epan/dissectors/packet-jpeg.c b/epan/dissectors/packet-jpeg.c index b8f639f4dd..be87693edb 100644 --- a/epan/dissectors/packet-jpeg.c +++ b/epan/dissectors/packet-jpeg.c @@ -259,7 +259,7 @@ dissect_jpeg( tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree ) void proto_register_jpeg(void) { - +#ifndef HAVE_HFI_SECTION_INIT static header_field_info *hfi[] = { &hfi_rtp_jpeg_main_hdr, @@ -281,6 +281,7 @@ proto_register_jpeg(void) &hfi_rtp_jpeg_qtable_hdr_data, &hfi_rtp_jpeg_payload, }; +#endif static gint *ett[] = { diff --git a/epan/dissectors/packet-json.c b/epan/dissectors/packet-json.c index 4355e002d6..246440f9f2 100644 --- a/epan/dissectors/packet-json.c +++ b/epan/dissectors/packet-json.c @@ -566,6 +566,7 @@ proto_register_json(void) { &ett_json_member }; +#ifndef HAVE_HFI_SECTION_INIT static header_field_info *hfi[] = { &hfi_json_array, &hfi_json_object, @@ -577,6 +578,7 @@ proto_register_json(void) { &hfi_json_value_null, &hfi_json_value_true, }; +#endif int proto_json; diff --git a/epan/dissectors/packet-mint.c b/epan/dissectors/packet-mint.c index d7c4bfe995..ea8466bcd7 100644 --- a/epan/dissectors/packet-mint.c +++ b/epan/dissectors/packet-mint.c @@ -674,6 +674,7 @@ dissect_mint_ethshim_static(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void proto_register_mint(void) { +#ifndef HAVE_HFI_SECTION_INIT static header_field_info *hfi[] = { /* MiNT Eth Shim */ @@ -722,6 +723,8 @@ proto_register_mint(void) &hfi_mint_control_0x22_length, &hfi_mint_control_0x22_value, }; +#endif + static gint *ett[] = { &ett_mint_ethshim, &ett_mint, diff --git a/epan/dissectors/packet-nflog.c b/epan/dissectors/packet-nflog.c index 3f1fe286ab..a0beebc393 100644 --- a/epan/dissectors/packet-nflog.c +++ b/epan/dissectors/packet-nflog.c @@ -354,6 +354,7 @@ dissect_nflog(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) void proto_register_nflog(void) { +#ifndef HAVE_HFI_SECTION_INIT static header_field_info *hfi[] = { /* Header */ &hfi_nflog_family, @@ -371,6 +372,7 @@ proto_register_nflog(void) &hfi_nflog_tlv_timestamp, &hfi_nflog_tlv_unknown, }; +#endif static gint *ett[] = { &ett_nflog, diff --git a/epan/dissectors/packet-redback.c b/epan/dissectors/packet-redback.c index 30232fef71..f5b9a1c8d8 100644 --- a/epan/dissectors/packet-redback.c +++ b/epan/dissectors/packet-redback.c @@ -186,6 +186,7 @@ dissect_redback(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) void proto_register_redback(void) { +#ifndef HAVE_HFI_SECTION_INIT static header_field_info *hfi[] = { &hfi_redback_context, &hfi_redback_flags, @@ -197,6 +198,7 @@ proto_register_redback(void) &hfi_redback_padding, &hfi_redback_unknown, }; +#endif static gint *ett[] = { &ett_redback diff --git a/epan/dissectors/packet-rsync.c b/epan/dissectors/packet-rsync.c index 5f649a871c..bf57b937f6 100644 --- a/epan/dissectors/packet-rsync.c +++ b/epan/dissectors/packet-rsync.c @@ -308,6 +308,7 @@ void proto_reg_handoff_rsync(void); void proto_register_rsync(void) { +#ifndef HAVE_HFI_SECTION_INIT static header_field_info *hfi[] = { &hfi_rsync_hdr_magic, &hfi_rsync_hdr_version, @@ -318,6 +319,7 @@ proto_register_rsync(void) &hfi_rsync_command_string, &hfi_rsync_data, }; +#endif static gint *ett[] = { &ett_rsync, diff --git a/epan/dissectors/packet-rwall.c b/epan/dissectors/packet-rwall.c index d9496ae519..a5dc305503 100644 --- a/epan/dissectors/packet-rwall.c +++ b/epan/dissectors/packet-rwall.c @@ -63,10 +63,12 @@ static const vsff rwall1_proc[] = { void proto_register_rwall(void) { +#ifndef HAVE_HFI_SECTION_INIT static header_field_info *hfi[] = { &hfi_rwall_procedure_v1, &hfi_rwall_message, }; +#endif static gint *ett[] = { &ett_rwall, diff --git a/epan/dissectors/packet-stat.c b/epan/dissectors/packet-stat.c index e9843476d4..72c2644938 100644 --- a/epan/dissectors/packet-stat.c +++ b/epan/dissectors/packet-stat.c @@ -326,6 +326,7 @@ static const vsff stat1_proc[] = { void proto_register_stat(void) { +#ifndef HAVE_HFI_SECTION_INIT static header_field_info *hfi[] = { &hfi_stat_procedure_v1, &hfi_stat_mon_name, @@ -343,6 +344,7 @@ proto_register_stat(void) &hfi_stat_state, &hfi_stat_stat_chge, }; +#endif static gint *ett[] = { &ett_stat, diff --git a/epan/dissectors/packet-tali.c b/epan/dissectors/packet-tali.c index 6bb04efad7..a18b2971b3 100644 --- a/epan/dissectors/packet-tali.c +++ b/epan/dissectors/packet-tali.c @@ -180,11 +180,13 @@ dissect_tali_heur(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *dat void proto_register_tali(void) { +#ifndef HAVE_HFI_SECTION_INIT static header_field_info *hfi[] = { &hfi_tali_sync_indicator, &hfi_tali_opcode_indicator, &hfi_tali_length_indicator }; +#endif /* Setup protocol subtree array */ static gint *ett[] = { diff --git a/epan/dissectors/packet-udp.c b/epan/dissectors/packet-udp.c index 38541d09de..b6f4dc6111 100644 --- a/epan/dissectors/packet-udp.c +++ b/epan/dissectors/packet-udp.c @@ -716,6 +716,7 @@ proto_register_udp(void) module_t *udplite_module; expert_module_t* expert_udp; +#ifndef HAVE_HFI_SECTION_INIT static header_field_info *hfi[] = { &hfi_udp_srcport, &hfi_udp_dstport, @@ -738,6 +739,7 @@ proto_register_udp(void) &hfi_udplite_checksum_coverage_bad, &hfi_udplite_checksum_coverage, }; +#endif static gint *ett[] = { &ett_udp, diff --git a/epan/dissectors/packet-xcsl.c b/epan/dissectors/packet-xcsl.c index 136e2a4155..dc5054a42c 100644 --- a/epan/dissectors/packet-xcsl.c +++ b/epan/dissectors/packet-xcsl.c @@ -323,7 +323,7 @@ static gboolean dissect_xcsl_tcp_heur(tvbuff_t *tvb, packet_info *pinfo, proto_t /* register the various xcsl protocol filters */ void proto_register_xcsl(void) { - +#ifndef HAVE_HFI_SECTION_INIT static header_field_info *hfi[] = { &hfi_xcsl_protocol_version, &hfi_xcsl_transaction_id, @@ -332,6 +332,7 @@ void proto_register_xcsl(void) { &hfi_xcsl_parameter, &hfi_xcsl_information, }; +#endif /* Setup protocol subtree array */ static gint *ett[] = { diff --git a/epan/dissectors/packet-yami.c b/epan/dissectors/packet-yami.c index 02f7294cc8..1e5576ac51 100644 --- a/epan/dissectors/packet-yami.c +++ b/epan/dissectors/packet-yami.c @@ -547,6 +547,7 @@ dissect_yami(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_ void proto_register_yami(void) { +#ifndef HAVE_HFI_SECTION_INIT static header_field_info *hfi[] = { /* Header */ &hfi_yami_message_id, @@ -568,6 +569,7 @@ proto_register_yami(void) &hfi_yami_params_count, &hfi_yami_items_count, }; +#endif static gint *ett[] = { &ett_yami, diff --git a/epan/proto.c b/epan/proto.c index 8bef0f6bae..bd81825512 100644 --- a/epan/proto.c +++ b/epan/proto.c @@ -4580,14 +4580,30 @@ proto_set_cant_toggle(const int proto_id) protocol->can_toggle = FALSE; } +static int +proto_register_field_common(protocol_t *proto, header_field_info *hfi, const int parent) +{ + if (proto != NULL) { + if (proto->fields == NULL) { + proto->fields = g_slist_append(NULL, hfi); + proto->last_field = proto->fields; + } else { + proto->last_field = + g_slist_append(proto->last_field, hfi)->next; + } + } + + return proto_register_field_init(hfi, parent); +} + /* for use with static arrays only, since we don't allocate our own copies of the header_field_info struct contained within the hf_register_info struct */ void proto_register_field_array(const int parent, hf_register_info *hf, const int num_records) { - int field_id, i; hf_register_info *ptr = hf; protocol_t *proto; + int i; proto = find_protocol_by_id(parent); for (i = 0; i < num_records; i++, ptr++) { @@ -4606,22 +4622,34 @@ proto_register_field_array(const int parent, hf_register_info *hf, const int num return; } - if (proto != NULL) { - if (proto->fields == NULL) { - proto->fields = g_slist_append(NULL, &ptr->hfinfo); - proto->last_field = proto->fields; - } else { - proto->last_field = - g_slist_append(proto->last_field, &ptr->hfinfo)->next; - } + *ptr->p_id = proto_register_field_common(proto, &ptr->hfinfo, parent); + } +} + +void +proto_register_fields_section(const int parent, header_field_info *hfi, const int num_records) +{ + int i; + protocol_t *proto; + + proto = find_protocol_by_id(parent); + for (i = 0; i < num_records; i++) { + /* + * Make sure we haven't registered this yet. + */ + if (hfi[i].id != -1) { + fprintf(stderr, + "Duplicate field detected in call to proto_register_fields: %s is already registered\n", + hfi[i].abbrev); + return; } - field_id = proto_register_field_init(&ptr->hfinfo, parent); - *ptr->p_id = field_id; + + proto_register_field_common(proto, &hfi[i], parent); } } void -proto_register_fields(const int parent, header_field_info **hfi, const int num_records) +proto_register_fields_manual(const int parent, header_field_info **hfi, const int num_records) { int i; protocol_t *proto; @@ -4633,21 +4661,12 @@ proto_register_fields(const int parent, header_field_info **hfi, const int num_r */ if (hfi[i]->id != -1) { fprintf(stderr, - "Duplicate field detected in call to proto_register_field_array: %s is already registered\n", + "Duplicate field detected in call to proto_register_fields: %s is already registered\n", hfi[i]->abbrev); return; } - if (proto != NULL) { - if (proto->fields == NULL) { - proto->fields = g_slist_append(NULL, hfi[i]); - proto->last_field = proto->fields; - } else { - proto->last_field = - g_slist_append(proto->last_field, hfi[i])->next; - } - } - proto_register_field_init(hfi[i], parent); + proto_register_field_common(proto, hfi[i], parent); } } diff --git a/epan/proto.h b/epan/proto.h index e0b54fb83e..f8584d7fbd 100644 --- a/epan/proto.h +++ b/epan/proto.h @@ -1675,7 +1675,8 @@ proto_register_prefix(const char *prefix, prefix_initializer_t initializer); /** Initialize every remaining uninitialized prefix. */ WS_DLL_PUBLIC void proto_initialize_all_prefixes(void); -WS_DLL_PUBLIC void proto_register_fields(const int parent, header_field_info **hfi, const int num_records); +WS_DLL_PUBLIC void proto_register_fields_manual(const int parent, header_field_info **hfi, const int num_records); +WS_DLL_PUBLIC void proto_register_fields_section(const int parent, header_field_info *hfi, const int num_records); /** Register a header_field array. @param parent the protocol handle from proto_register_protocol() @@ -2118,7 +2119,21 @@ proto_custom_set(proto_tree* tree, const int field_id, gchar *result, gchar *expr, const int size ); -#define HFI_INIT(proto) +/* #define HAVE_HFI_SECTION_INIT */ + +#ifdef HAVE_HFI_SECTION_INIT + #define HFI_INIT(proto) __attribute__((section( "_data_" G_STRINGIFY(proto) ))) + + #define proto_register_fields(proto, hfi, count) \ + extern header_field_info __start__data_ ##proto[]; \ + extern header_field_info __stop__data_ ##proto[]; \ +\ + proto_register_fields_section(proto, __start__data_ ##proto, (int) (__stop__data_ ##proto - __start__data_ ##proto)) +#else + #define HFI_INIT(proto) + #define proto_register_fields(proto, hfi, count) \ + proto_register_fields_manual(proto, hfi, count) +#endif #ifdef NEW_PROTO_TREE_API #define proto_tree_add_item(tree, hfinfo, tvb, start, length, encoding) \ |