aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--epan/address.h53
-rw-r--r--epan/address_to_str.c6
-rw-r--r--epan/address_types.c10
-rw-r--r--epan/address_types.h8
-rw-r--r--epan/column-utils.c12
-rw-r--r--epan/dissectors/packet-dvbci.c4
-rw-r--r--epan/dissectors/packet-ieee80211.c34
-rw-r--r--epan/dissectors/packet-lbtrm.c2
-rw-r--r--epan/dissectors/packet-lbtru.c2
-rw-r--r--epan/dissectors/packet-lbttcp.c2
-rw-r--r--epan/dissectors/packet-maccontrol.c2
-rw-r--r--epan/dissectors/packet-mgcp.c2
-rw-r--r--epan/dissectors/packet-mp2t.c8
-rw-r--r--epan/dissectors/packet-radius.c2
-rw-r--r--epan/dissectors/packet-rpc.c6
-rw-r--r--plugins/wimax/packet-wmx.c2
16 files changed, 66 insertions, 89 deletions
diff --git a/epan/address.h b/epan/address.h
index 0d433ece8a..841b9c6345 100644
--- a/epan/address.h
+++ b/epan/address.h
@@ -30,7 +30,13 @@
extern "C" {
#endif /* __cplusplus */
-/* Types of addresses Wireshark knows about. */
+/* Types of "global" addresses Wireshark knows about. */
+/* Address types can be added here if there are many dissectors that use them or just
+ * within a specific dissector.
+ * If an address type is added here, it must be "registered" within address_types.c
+ * For dissector address types, just use the address_type_dissector_register function
+ * from address_types.h
+ */
/* If a new address type is added here, a string representation procedure should also be */
/* included in address_to_str_buf defined in address_to_str.c, for presentation purposes */
@@ -56,7 +62,6 @@ typedef enum {
typedef struct _address {
int type; /* type of address */
- int hf; /* the specific field that this addr is */
int len; /* length of address, in bytes */
const void *data; /* pointer to address data */
} address;
@@ -73,7 +78,6 @@ static inline void
set_address(address *addr, int addr_type, int addr_len, const void * addr_data) {
addr->data = addr_data;
addr->type = addr_type;
- addr->hf = -1;
addr->len = addr_len;
}
#define SET_ADDRESS(addr, addr_type, addr_len, addr_data) \
@@ -100,47 +104,6 @@ set_address(address *addr, int addr_type, int addr_len, const void * addr_data)
set_address((addr), (addr_type), (addr_len), TVB_SET_ADDRESS_data); \
} while (0)
-/** Initialize an address with the given values including an associated field.
- *
- * @param addr [in,out] The address to initialize.
- * @param addr_type [in] Address type.
- * @param addr_len [in] The length in bytes of the address data. For example, 4 for
- * AT_IPv4 or sizeof(struct e_in6_addr) for AT_IPv6.
- * @param addr_data [in] Pointer to the address data.
- * @param addr_hf [in] The header field index to associate with the address.
- */
-static inline void
-set_address_hf(address *addr, address_type addr_type, int addr_len, const void * addr_data, int addr_hf) {
- addr->data = addr_data;
- addr->type = addr_type;
- addr->hf = addr_hf;
- addr->len = addr_len;
-}
-#define SET_ADDRESS_HF(addr, addr_type, addr_len, addr_data, addr_hf) \
- set_address_hf((addr), (addr_type), (addr_len), (addr_data), (addr_hf))
-
-/** Initialize an address from TVB data including an associated field.
- *
- * Same as SET_ADDRESS_HF but it takes a TVB and an offset. This is preferred
- * over passing the return value of tvb_get_ptr() to set_address().
- *
- * This calls tvb_get_ptr() (including throwing any exceptions) before
- * modifying the address.
- *
- * @param addr [in,out] The address to initialize.
- * @param addr_type [in] Address type.
- * @param tvb [in] Pointer to the TVB.
- * @param offset [in] Offset within the TVB.
- * @param addr_len [in] The length in bytes of the address data. For example, 4 for
- * AT_IPv4 or sizeof(struct e_in6_addr) for AT_IPv6.
- * @param addr_hf [in] The header field index to associate with the address.
- */
-#define TVB_SET_ADDRESS_HF(addr, addr_type, tvb, offset, addr_len, addr_hf) \
- do { \
- const void *TVB_SET_ADDRESS_data = (const void *) tvb_get_ptr(tvb, offset, addr_len); \
- set_address_hf((addr), (addr_type), (addr_len), TVB_SET_ADDRESS_data, (addr_hf)); \
- } while (0)
-
/** Compare two addresses.
*
* @param addr1 [in] The first address to compare.
@@ -194,7 +157,6 @@ copy_address(address *to, const address *from) {
to->type = from->type;
to->len = from->len;
- to->hf = from->hf;
to_data = (guint8 *)g_malloc(from->len);
memcpy(to_data, from->data, from->len);
to->data = to_data;
@@ -213,7 +175,6 @@ copy_address_shallow(address *to, const address *from) {
/*
to->type = from->type;
to->len = from->len;
- to->hf = from->hf;
to->data = from->data;
*/
}
diff --git a/epan/address_to_str.c b/epan/address_to_str.c
index 228133a58c..74154e58b7 100644
--- a/epan/address_to_str.c
+++ b/epan/address_to_str.c
@@ -246,7 +246,6 @@ tvb_address_to_str(wmem_allocator_t *scope, tvbuff_t *tvb, address_type type, co
address addr;
addr.type = type;
- addr.hf = -1;
switch(type)
{
@@ -325,11 +324,6 @@ gchar* tvb_address_var_to_str(wmem_allocator_t *scope, tvbuff_t *tvb, address_ty
a table of routines to do operations such as address-to-name translation,
address-to-string translation, and the like, and have this call them,
and also have an address-to-string-with-a-name routine */
-/* XXX - use this, and that future address-to-string-with-a-name routine,
- in "col_set_addr()"; it might also be useful to have address types
- export the names of the source and destination address fields, so
- that "col_set_addr()" need know nothing whatsoever about particular
- address types */
/* convert an address struct into a printable string */
gchar*
diff --git a/epan/address_types.c b/epan/address_types.c
index 7c7c9783a2..48b0e26b74 100644
--- a/epan/address_types.c
+++ b/epan/address_types.c
@@ -57,7 +57,7 @@ struct _address_type_t {
/* XXX - Include functions for name resolution? ***/
};
-#define MAX_DISSECTOR_ADDR_TYPE 15
+#define MAX_DISSECTOR_ADDR_TYPE 20
#define MAX_ADDR_TYPE_VALUE (AT_END_OF_LIST+MAX_DISSECTOR_ADDR_TYPE)
static int num_dissector_addr_type;
@@ -119,13 +119,13 @@ int address_type_dissector_register(const char* name, const char* pretty_name,
/******************************************************************************
* AT_NONE
******************************************************************************/
-static gboolean none_addr_to_str(const address* addr _U_, gchar *buf, int buf_len _U_)
+gboolean none_addr_to_str(const address* addr _U_, gchar *buf, int buf_len _U_)
{
buf[0] = '\0';
return TRUE;
}
-static int none_addr_str_len(const address* addr _U_)
+int none_addr_str_len(const address* addr _U_)
{
return 1; /* NULL character for empty string */
}
@@ -133,14 +133,14 @@ static int none_addr_str_len(const address* addr _U_)
/******************************************************************************
* AT_ETHER
******************************************************************************/
-static gboolean ether_to_str(const address* addr, gchar *buf, int buf_len _U_)
+gboolean ether_to_str(const address* addr, gchar *buf, int buf_len _U_)
{
bytes_to_hexstr_punct(buf, (const guint8*)addr->data, 6, ':');
buf[17] = '\0';
return TRUE;
}
-static int ether_str_len(const address* addr _U_)
+int ether_str_len(const address* addr _U_)
{
return 18;
}
diff --git a/epan/address_types.h b/epan/address_types.h
index 1146b493f3..ae699c86eb 100644
--- a/epan/address_types.h
+++ b/epan/address_types.h
@@ -41,6 +41,14 @@ int address_type_dissector_register(const char* name, const char* pretty_name,
void address_types_initialize(void);
+/* Address type functions used by multiple (dissector) address types */
+gboolean none_addr_to_str(const address* addr, gchar *buf, int buf_len);
+int none_addr_str_len(const address* addr);
+gboolean ether_to_str(const address* addr, gchar *buf, int buf_len);
+int ether_str_len(const address* addr);
+
+
+
/* XXX - Temporary? Here at least until all of the address type handling is finalized
* Otherwise should be folded into address_types.c or just be handled with function pointers
*/
diff --git a/epan/column-utils.c b/epan/column-utils.c
index 06e8fbee23..581f5e6078 100644
--- a/epan/column-utils.c
+++ b/epan/column-utils.c
@@ -1855,18 +1855,6 @@ col_set_addr(packet_info *pinfo, const int col, const address *addr, const gbool
/* For address types that have a filter, create a string */
if (strlen(pinfo->cinfo->col_expr.col_expr[col]) > 0)
address_to_str_buf(addr, pinfo->cinfo->col_expr.col_expr_val[col], COL_MAX_LEN);
-
- /* Some addresses (e.g. ieee80211) use a standard format like AT_ETHER but
- * don't use the same hf_ value (and thus don't use the same filter string).
- * Such address can use the SET_ADDRESS_HF macro to pass in the specific hf_
- * value they use. If they did so, we overwrite the default filter string
- * with their specific one here. See bug #7728 for further discussion.
- * https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=7728 */
- /* XXX - can the new address types fix this and prevent the need for this logic? */
- if (addr->hf != -1) {
- pinfo->cinfo->col_expr.col_expr[col] = proto_registrar_get_nth(addr->hf)->abbrev;
- }
-
}
/* ------------------------ */
diff --git a/epan/dissectors/packet-dvbci.c b/epan/dissectors/packet-dvbci.c
index 42517ae9cc..0105f073a3 100644
--- a/epan/dissectors/packet-dvbci.c
+++ b/epan/dissectors/packet-dvbci.c
@@ -1638,8 +1638,8 @@ guint8
dvbci_get_evt_from_addrs(packet_info *pinfo)
{
/* this should be working from C89 on */
- static const address a_cam = { AT_STRINGZ, -1, sizeof(ADDR_CAM), ADDR_CAM };
- static const address a_host = { AT_STRINGZ, -1, sizeof(ADDR_HOST), ADDR_HOST };
+ static const address a_cam = { AT_STRINGZ, sizeof(ADDR_CAM), ADDR_CAM };
+ static const address a_host = { AT_STRINGZ, sizeof(ADDR_HOST), ADDR_HOST };
if ( ADDRESSES_EQUAL(&(pinfo->src), &a_cam) &&
ADDRESSES_EQUAL(&(pinfo->dst), &a_host) ) {
diff --git a/epan/dissectors/packet-ieee80211.c b/epan/dissectors/packet-ieee80211.c
index 307d674420..a66e03ec5c 100644
--- a/epan/dissectors/packet-ieee80211.c
+++ b/epan/dissectors/packet-ieee80211.c
@@ -84,6 +84,7 @@
#include <epan/exceptions.h>
#include <wsutil/pint.h>
#include <epan/addr_resolv.h>
+#include <epan/address_types.h>
#include <epan/strutil.h>
#include <epan/prefs.h>
#include <epan/reassemble.h>
@@ -5228,6 +5229,9 @@ static const enum_val_t wlan_ignore_wep_options[] = {
{ NULL, NULL, 0 }
};
+static int wlan_address_type = -1;
+static int wlan_bssid_address_type = -1;
+
static dissector_handle_t ieee80211_handle;
static dissector_handle_t llc_handle;
static dissector_handle_t ipx_handle;
@@ -5368,6 +5372,21 @@ wlan_hostlist_packet(void *pit, packet_info *pinfo, epan_dissect_t *edt _U_, con
return 1;
}
+
+const char* wlan_col_filter_str(const address* addr _U_, gboolean is_src)
+{
+ if (is_src)
+ return "wlan.sa";
+
+ return "wlan.da";
+}
+
+const char* wlan_bssid_col_filter_str(const address* addr _U_, gboolean is_src _U_)
+{
+ return "wlan.bssid";
+}
+
+
static void
beacon_interval_base_custom(gchar *result, guint32 beacon_interval)
{
@@ -16313,13 +16332,13 @@ dissect_ieee80211_common (tvbuff_t *tvb, packet_info *pinfo,
/*
* All management frame types have the same header.
*/
- TVB_SET_ADDRESS_HF(&pinfo->dl_src, AT_ETHER, tvb, 10, 6, hf_ieee80211_addr_sa);
+ TVB_SET_ADDRESS(&pinfo->dl_src, wlan_address_type, tvb, 10, 6);
COPY_ADDRESS_SHALLOW(&pinfo->src, &pinfo->dl_src);
- TVB_SET_ADDRESS_HF(&pinfo->dl_dst, AT_ETHER, tvb, 4, 6, hf_ieee80211_addr_da);
+ TVB_SET_ADDRESS(&pinfo->dl_dst, wlan_address_type, tvb, 4, 6);
COPY_ADDRESS_SHALLOW(&pinfo->dst, &pinfo->dl_dst);
/* for tap */
- TVB_SET_ADDRESS_HF(&whdr->bssid, AT_ETHER, tvb, 16, 6, hf_ieee80211_addr_bssid);
+ TVB_SET_ADDRESS(&whdr->bssid, wlan_bssid_address_type, tvb, 16, 6);
COPY_ADDRESS_SHALLOW(&whdr->src, &pinfo->dl_src);
COPY_ADDRESS_SHALLOW(&whdr->dst, &pinfo->dl_dst);
whdr->type = frame_type_subtype;
@@ -16956,14 +16975,14 @@ dissect_ieee80211_common (tvbuff_t *tvb, packet_info *pinfo,
dst = tvb_get_ptr(tvb, dst_offset, 6);
bssid = tvb_get_ptr(tvb, bssid_offset, 6);
- SET_ADDRESS_HF(&pinfo->dl_src, AT_ETHER, 6, src, hf_ieee80211_addr_sa);
+ SET_ADDRESS(&pinfo->dl_src, wlan_address_type, 6, src);
COPY_ADDRESS_SHALLOW(&pinfo->src, &pinfo->dl_src);
- SET_ADDRESS_HF(&pinfo->dl_dst, AT_ETHER, 6, dst, hf_ieee80211_addr_da);
+ SET_ADDRESS(&pinfo->dl_dst, wlan_address_type, 6, dst);
COPY_ADDRESS_SHALLOW(&pinfo->dst, &pinfo->dl_dst);
/* for tap */
- SET_ADDRESS_HF(&whdr->bssid, AT_ETHER, 6, bssid, hf_ieee80211_addr_bssid);
+ SET_ADDRESS(&whdr->bssid, wlan_bssid_address_type, 6, bssid);
COPY_ADDRESS_SHALLOW(&whdr->src, &pinfo->dl_src);
COPY_ADDRESS_SHALLOW(&whdr->dst, &pinfo->dl_dst);
whdr->type = frame_type_subtype;
@@ -26534,6 +26553,9 @@ proto_register_ieee80211 (void)
wlan_tap = register_tap("wlan");
register_conversation_table(proto_wlan, TRUE, wlan_conversation_packet, wlan_hostlist_packet);
+ wlan_address_type = address_type_dissector_register("AT_ETHER_WLAN", "WLAN Address", ether_to_str, ether_str_len, wlan_col_filter_str);
+ wlan_bssid_address_type = address_type_dissector_register("AT_ETHER_BSSID", "WLAN BSSID Address", ether_to_str, ether_str_len, wlan_bssid_col_filter_str);
+
/* Register configuration options */
wlan_module = prefs_register_protocol(proto_wlan, init_wepkeys);
prefs_register_bool_preference(wlan_module, "defragment",
diff --git a/epan/dissectors/packet-lbtrm.c b/epan/dissectors/packet-lbtrm.c
index f5765941c8..a8c73b576e 100644
--- a/epan/dissectors/packet-lbtrm.c
+++ b/epan/dissectors/packet-lbtrm.c
@@ -59,7 +59,7 @@ static int lbtrm_tap_handle = -1;
/* LBT-RM transport management. */
/*----------------------------------------------------------------------------*/
-static const address lbtrm_null_address = { AT_NONE, -1, 0, NULL };
+static const address lbtrm_null_address = { AT_NONE, 0, NULL };
static lbtrm_transport_t * lbtrm_transport_unicast_find(const address * source_address, guint16 source_port, guint32 session_id, guint32 frame)
{
diff --git a/epan/dissectors/packet-lbtru.c b/epan/dissectors/packet-lbtru.c
index 5def0cbc1f..4051ed2814 100644
--- a/epan/dissectors/packet-lbtru.c
+++ b/epan/dissectors/packet-lbtru.c
@@ -49,7 +49,7 @@ static int lbtru_tap_handle = -1;
/* LBT-RU transport management. */
/*----------------------------------------------------------------------------*/
-static const address lbtru_null_address = { AT_NONE, -1, 0, NULL };
+static const address lbtru_null_address = { AT_NONE, 0, NULL };
static lbtru_transport_t * lbtru_transport_find(const address * source_address, guint16 source_port, guint32 session_id, guint32 frame)
{
diff --git a/epan/dissectors/packet-lbttcp.c b/epan/dissectors/packet-lbttcp.c
index c118942711..bae06e9acb 100644
--- a/epan/dissectors/packet-lbttcp.c
+++ b/epan/dissectors/packet-lbttcp.c
@@ -51,7 +51,7 @@ typedef struct
wmem_tree_t * session_tree;
} lbttcp_transport_conv_data_t;
-static const address lbttcp_null_address = { AT_NONE, -1, 0, NULL };
+static const address lbttcp_null_address = { AT_NONE, 0, NULL };
lbttcp_transport_t * lbttcp_transport_find(const address * source_address, guint16 source_port, guint32 session_id, guint32 frame)
{
diff --git a/epan/dissectors/packet-maccontrol.c b/epan/dissectors/packet-maccontrol.c
index 9adb05fdc2..7f03b50c8b 100644
--- a/epan/dissectors/packet-maccontrol.c
+++ b/epan/dissectors/packet-maccontrol.c
@@ -127,7 +127,7 @@ static const value_string reg_flags_vals[] = {
};
static const guint8 dst_addr[] = {0x01, 0x80, 0xC2, 0x00, 0x00, 0x01};
-static const address macctrl_dst_address = { AT_ETHER, -1, 6, dst_addr};
+static const address macctrl_dst_address = { AT_ETHER, 6, dst_addr};
static void
dissect_macctrl(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
diff --git a/epan/dissectors/packet-mgcp.c b/epan/dissectors/packet-mgcp.c
index 797f929d7c..7a7fc7cd44 100644
--- a/epan/dissectors/packet-mgcp.c
+++ b/epan/dissectors/packet-mgcp.c
@@ -1032,7 +1032,7 @@ static void dissect_mgcp_firstline(tvbuff_t *tvb, packet_info *pinfo, proto_tree
const gchar *verb_description = "";
char code_with_verb[64] = ""; /* To fit "<4-letter-code> (<longest-verb>)" */
- static address null_address = { AT_NONE, -1, 0, NULL };
+ static address null_address = { AT_NONE, 0, NULL };
tvb_previous_offset = 0;
tvb_len = tvb_reported_length(tvb);
tvb_current_offset = tvb_previous_offset;
diff --git a/epan/dissectors/packet-mp2t.c b/epan/dissectors/packet-mp2t.c
index 272144e489..677a839bc1 100644
--- a/epan/dissectors/packet-mp2t.c
+++ b/epan/dissectors/packet-mp2t.c
@@ -34,6 +34,7 @@
#include <epan/conversation.h>
#include <epan/expert.h>
#include <epan/reassemble.h>
+#include <epan/address_types.h>
#include <epan/tvbuff-int.h> /* XXX, for tvb_new_proxy() */
@@ -163,6 +164,7 @@ static int hf_mp2t_af_e_m_3 = -1;
static int hf_mp2t_stuff_bytes = -1;
static int hf_mp2t_pointer = -1;
+static int mp2t_no_address_type = -1;
static const value_string mp2t_sync_byte_vals[] = {
{ MP2T_SYNC_BYTE, "Correct" },
@@ -529,8 +531,8 @@ mp2t_fragment_handle(tvbuff_t *tvb, guint offset, packet_info *pinfo,
/* It's possible that a fragment in the same packet set an address already
* This will change the hash value, we need to make sure it's NULL */
- SET_ADDRESS_HF(&pinfo->src, AT_NONE, 0, NULL, 0);
- SET_ADDRESS_HF(&pinfo->dst, AT_NONE, 0, NULL, 0);
+ SET_ADDRESS(&pinfo->src, mp2t_no_address_type, 0, NULL);
+ SET_ADDRESS(&pinfo->dst, mp2t_no_address_type, 0, NULL);
/* check length; send frame for reassembly */
frag_msg = fragment_add_check(&mp2t_reassembly_table,
@@ -1511,6 +1513,8 @@ proto_register_mp2t(void)
expert_mp2t = expert_register_protocol(proto_mp2t);
expert_register_field_array(expert_mp2t, ei, array_length(ei));
+ mp2t_no_address_type = address_type_dissector_register("AT_MP2T_NONE", "No MP2T Address", none_addr_to_str, none_addr_str_len, NULL);
+
heur_subdissector_list = register_heur_dissector_list("mp2t.pid");
/* Register init of processing of fragmented DEPI packets */
register_init_routine(mp2t_init);
diff --git a/epan/dissectors/packet-radius.c b/epan/dissectors/packet-radius.c
index 8a3d6b38b1..e29a44b615 100644
--- a/epan/dissectors/packet-radius.c
+++ b/epan/dissectors/packet-radius.c
@@ -1387,7 +1387,7 @@ dissect_radius(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _
radius_call_info_key radius_call_key;
radius_call_info_key *new_radius_call_key;
radius_call_t *radius_call = NULL;
- static address null_address = { AT_NONE, -1, 0, NULL };
+ static address null_address = { AT_NONE, 0, NULL };
/* does this look like radius ? */
if(!is_radius(tvb)){
diff --git a/epan/dissectors/packet-rpc.c b/epan/dissectors/packet-rpc.c
index 11fbfba531..b42ec089f7 100644
--- a/epan/dissectors/packet-rpc.c
+++ b/epan/dissectors/packet-rpc.c
@@ -1504,7 +1504,7 @@ dissect_rpc_indir_call(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
int offset, int args_id, guint32 prog, guint32 vers, guint32 proc)
{
conversation_t* conversation;
- static address null_address = { AT_NONE, -1, 0, NULL };
+ static address null_address = { AT_NONE, 0, NULL };
rpc_proc_info_key key;
rpc_proc_info_value *value;
rpc_call_info_value *rpc_call;
@@ -1652,7 +1652,7 @@ dissect_rpc_indir_reply(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
int offset, int result_id, int prog_id, int vers_id, int proc_id)
{
conversation_t* conversation;
- static address null_address = { AT_NONE, -1, 0, NULL };
+ static address null_address = { AT_NONE, 0, NULL };
rpc_call_info_value *rpc_call;
const char *procname=NULL;
dissect_function_t *dissect_function = NULL;
@@ -1879,7 +1879,7 @@ dissect_rpc_message(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
rpc_proc_info_key key;
rpc_proc_info_value *value = NULL;
conversation_t* conversation;
- static address null_address = { AT_NONE, -1, 0, NULL };
+ static address null_address = { AT_NONE, 0, NULL };
nstime_t ns;
dissect_function_t *dissect_function = NULL;
diff --git a/plugins/wimax/packet-wmx.c b/plugins/wimax/packet-wmx.c
index e06d33131a..8e474f1b0a 100644
--- a/plugins/wimax/packet-wmx.c
+++ b/plugins/wimax/packet-wmx.c
@@ -46,7 +46,7 @@ gint mac_sdu_length = 49; /* default SDU size is 49 bytes (11.13.16) */
extern guint global_cid_max_basic;
extern gboolean include_cor2_changes;
-address bs_address = {AT_NONE, -1, 0, NULL};
+address bs_address = {AT_NONE, 0, NULL};
static int hf_tlv_type = -1;