summaryrefslogtreecommitdiff
path: root/epan/address.h
diff options
context:
space:
mode:
authorJeff Morriss <jeff.morriss.ws@gmail.com>2012-12-02 04:49:13 +0000
committerJeff Morriss <jeff.morriss.ws@gmail.com>2012-12-02 04:49:13 +0000
commit49466f95bc1fe3cc139f3750fcc934ffc210faef (patch)
tree14c72b7db9d4fe0af875d373d6023c92bae0463a /epan/address.h
parentda4442d6384b15530fd740295080a8ad3a145ca6 (diff)
downloadwireshark-49466f95bc1fe3cc139f3750fcc934ffc210faef.tar.gz
Introduce, and start using, TVB_SET_ADDRESS() and TVB_SET_ADDRESS_HF(). They
are like the non-TVB versions except that they take a TVB and an offset instead of (frequently) a pointer into the TVB. Calling tvb_get_ptr() before modifying the rest of the fields should help fix https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=7960 (though I can't reproduce that problem). Replace a bunch of calls like: SET_ADDRESS(..., AT_XXX, length, tvb_get_ptr(tvb, offset, length)); with: TVB_SET_ADDRESS(..., AT_XXX, tvb, offset, length); svn path=/trunk/; revision=46324
Diffstat (limited to 'epan/address.h')
-rw-r--r--epan/address.h32
1 files changed, 30 insertions, 2 deletions
diff --git a/epan/address.h b/epan/address.h
index e650699647..cf20d3c48c 100644
--- a/epan/address.h
+++ b/epan/address.h
@@ -70,17 +70,45 @@ typedef struct _address {
} address;
#define SET_ADDRESS(addr, addr_type, addr_len, addr_data) { \
+ (addr)->data = (addr_data); \
+ (addr)->type = (addr_type); \
+ (addr)->hf = -1; \
+ (addr)->len = (addr_len); \
+ }
+
+/* Same as SET_ADDRESS but it takes a TVB and an offset instead of
+ * (frequently) a pointer into a TVB. This allow us to get the tvb_get_ptr()
+ * call out of the dissectors.
+ *
+ * Call tvb_get_ptr() first in case it throws an exception: then we won't
+ * modify the address at all.
+ */
+#define TVB_SET_ADDRESS(addr, addr_type, tvb, offset, addr_len) { \
+ (addr)->data = tvb_get_ptr(tvb, offset, addr_len); \
(addr)->type = (addr_type); \
(addr)->hf = -1; \
(addr)->len = (addr_len); \
- (addr)->data = (addr_data); \
}
#define SET_ADDRESS_HF(addr, addr_type, addr_len, addr_data, addr_hf) { \
+ (addr)->data = (addr_data); \
+ (addr)->type = (addr_type); \
+ (addr)->hf = (addr_hf); \
+ (addr)->len = (addr_len); \
+ }
+
+/* Same as SET_ADDRESS_HF but it takes a TVB and an offset instead of
+ * (frequently) a pointer into a TVB. This allow us to get the tvb_get_ptr()
+ * call out of the dissectors.
+ *
+ * Call tvb_get_ptr() first in case it throws an exception: then we won't
+ * modify the address at all.
+ */
+#define TVB_SET_ADDRESS_HF(addr, addr_type, tvb, offset, addr_len, addr_hf) { \
+ (addr)->data = tvb_get_ptr(tvb, offset, addr_len); \
(addr)->type = (addr_type); \
(addr)->hf = (addr_hf); \
(addr)->len = (addr_len); \
- (addr)->data = (addr_data); \
}
/*