forked from osmocom/wireshark
Change calls to g_ntohs, g_ntohl, g_htons, and g_htonl to their
epan/pint.h equivalents. Add warnings about trying to operate on tvb data directly. svn path=/trunk/; revision=23787
This commit is contained in:
parent
4783f12c08
commit
2a67c4d472
|
@ -2454,6 +2454,7 @@ void dissect_mac_mgmt_msg_dlmap_decoder(tvbuff_t *tvb, packet_info *pinfo, proto
|
|||
proto_tree *ie_tree = NULL;
|
||||
proto_tree *phy_tree = NULL;
|
||||
gint tvb_len = tvb_reported_length(tvb);
|
||||
/* XXX This should be removed, and regular tvb accessors should be used instead. */
|
||||
const guint8 *bufptr = tvb_get_ptr(tvb, offset, tvb_len);
|
||||
|
||||
UNREFERENCED_PARAMETER(pinfo);
|
||||
|
@ -2515,6 +2516,7 @@ gint wimax_decode_dlmapc(tvbuff_t *tvb, packet_info *pinfo, proto_tree *base_tre
|
|||
guint length, lennib, pad;
|
||||
guint mac_len, dl_ie_count;
|
||||
guint tvb_len = tvb_reported_length(tvb);
|
||||
/* XXX This should be removed, and regular tvb accessors should be used instead. */
|
||||
const guint8 * bufptr = tvb_get_ptr(tvb, offset, tvb_len);
|
||||
guint nib = 0;
|
||||
guint32 mac_crc, calculated_crc;
|
||||
|
@ -2616,6 +2618,7 @@ gint wimax_decode_sub_dl_ul_map(tvbuff_t *tvb, packet_info *pinfo, proto_tree *b
|
|||
guint16 calculated_crc;
|
||||
|
||||
gint length = tvb_reported_length(tvb);
|
||||
/* XXX This should be removed, and regular tvb accessors should be used instead. */
|
||||
const guint8 * bufptr = tvb_get_ptr(tvb, offset, length);
|
||||
gint nib = 0;
|
||||
gint lennib = BYTE_TO_NIB(length);
|
||||
|
@ -2704,6 +2707,7 @@ gint wimax_decode_dlmap_reduced_aas(tvbuff_t *tvb, packet_info *pinfo, proto_tre
|
|||
gint ulmap_appended;
|
||||
gint length;
|
||||
gint tvb_len = tvb_reported_length(tvb);
|
||||
/* XXX This should be removed, and regular tvb accessors should be used instead. */
|
||||
const guint8 * bufptr = tvb_get_ptr(tvb, offset, tvb_len);
|
||||
gint bit = 0;
|
||||
guint data, pad, mult;
|
||||
|
|
|
@ -2270,6 +2270,7 @@ void dissect_mac_mgmt_msg_ulmap_decoder(tvbuff_t *tvb, packet_info *pinfo, proto
|
|||
const guint8 *bufptr;
|
||||
|
||||
tvb_len = tvb_reported_length(tvb);
|
||||
/* XXX This should be removed, and regular tvb accessors should be used instead. */
|
||||
bufptr = tvb_get_ptr(tvb, offset, tvb_len);
|
||||
|
||||
UNREFERENCED_PARAMETER(pinfo);
|
||||
|
|
|
@ -33,9 +33,6 @@
|
|||
* Functions for working with nibbles and bits
|
||||
*/
|
||||
|
||||
#define AS16(x) g_htons(*((guint16*)(x)))
|
||||
#define AS32(x) g_htonl(*((guint32*)(x)))
|
||||
|
||||
/* SWAR functions */
|
||||
#define _BITS(n,hi,lo) (((n)>>(lo))&((1<<(((hi)-(lo))+1))-1))
|
||||
#define _ADD_SWAP(x,y) { (x) = (x) + (y); (y) = (x) - (y); (x) = (x) - (y); }
|
||||
|
@ -60,37 +57,34 @@
|
|||
/* extract the byte at the given nibble address 'n' of buffer 'b' */
|
||||
#define NIB_BYTE(n,b) \
|
||||
(n) & 1 \
|
||||
? (g_ntohs( *(guint16 *)((b)+(n)/2) ) >> 4) & BYTE_MASK \
|
||||
? (pntohs( (b)+(n)/2 ) >> 4) & BYTE_MASK \
|
||||
: (b)[(n)/2]
|
||||
/*
|
||||
? (AS16((b)+(n)/2) >> 4) & BYTE_MASK \
|
||||
? (pletohs((b)+(n)/2) >> 4) & BYTE_MASK \
|
||||
*/
|
||||
|
||||
/* extract 12 bits at the given nibble address */
|
||||
#define NIB_BITS12(n,b) \
|
||||
(NIB_NIBBLE(n,b+1) | (NIB_BYTE(n,b) << 4))
|
||||
|
||||
#define AS16(x) g_htons(*((guint16*)(x)))
|
||||
#define AS32(x) g_htonl(*((guint32*)(x)))
|
||||
|
||||
/* extract the word at the given nibble address 'n' of buffer 'b' */
|
||||
#define NIB_WORD(n,b) \
|
||||
(n) & 1 \
|
||||
? (gint)((g_ntohl(*(guint32 *)((b) + (n)/2)) >> 12) & 0x0000FFFF) \
|
||||
: g_ntohs(*(guint16 *)((b) + (n)/2))
|
||||
? (gint)((pntohl(((b) + (n)/2)) >> 12) & 0x0000FFFF) \
|
||||
: pntohs((b) + (n)/2)
|
||||
/*
|
||||
: AS16((b) + (n)/2)
|
||||
? (AS32((b)+(n)/2) >> 12) & 0x0000FFFF \
|
||||
: pletohs((b) + (n)/2)
|
||||
? (pletohl((b)+(n)/2) >> 12) & 0x0000FFFF \
|
||||
*/
|
||||
|
||||
/* extract the word at the given nibble address 'n' of buffer 'b' */
|
||||
#define NIB_LONG(n,b) \
|
||||
(n) & 1 \
|
||||
? (g_ntohl(*(guint32 *)((b) + (n)/2)) << 4) | (((b)[(n)/2 + 4] >> 4) & NIBBLE_MASK) \
|
||||
: g_ntohl(*(guint32 *)((b) + (n)/2))
|
||||
? (pntohl(((b) + (n)/2)) << 4) | (((b)[(n)/2 + 4] >> 4) & NIBBLE_MASK) \
|
||||
: pntohl((b) + (n)/2)
|
||||
/*
|
||||
? (AS32((b) + (n)/2) << 4) | (((b)[(n)/2 + 4] >> 4) & NIBBLE_MASK) \
|
||||
: AS32((b) + (n)/2)
|
||||
? (pletohl((b) + (n)/2) << 4) | (((b)[(n)/2 + 4] >> 4) & NIBBLE_MASK) \
|
||||
: pletohl((b) + (n)/2)
|
||||
*/
|
||||
|
||||
/* Only currently used with nib == 1 or 2 */
|
||||
|
@ -160,7 +154,7 @@
|
|||
* num ... length of bitfield
|
||||
*/
|
||||
#define BIT_BITS16(bit, buf, num) \
|
||||
(( AS16(buf+ADDR16(bit)) >> SHIFT16(bit,num) ) & MASK16(num))
|
||||
(( pletohs(buf+ADDR16(bit)) >> SHIFT16(bit,num) ) & MASK16(num))
|
||||
|
||||
/* extract bitfield up to 24 bits
|
||||
* bit ... bit address
|
||||
|
@ -169,14 +163,14 @@
|
|||
*/
|
||||
|
||||
#define BIT_BITS32(bit, buf, num) \
|
||||
((AS32(buf+ADDR32(bit)) >> SHIFT32(bit,num) ) & MASK32(num))
|
||||
((pletohl(buf+ADDR32(bit)) >> SHIFT32(bit,num) ) & MASK32(num))
|
||||
|
||||
/* bitfield up to 32 bits */
|
||||
#define BIT_BITS64a(bit, buf, num) \
|
||||
((AS32(buf+ADDR32(bit)) & MASK64a(bit)) << SHIFT64a(bit,num))
|
||||
((pletohl(buf+ADDR32(bit)) & MASK64a(bit)) << SHIFT64a(bit,num))
|
||||
|
||||
#define BIT_BITS64b(bit, buf, num) \
|
||||
((AS32(buf+ADDR32(bit)+4) >> SHIFT64b(bit,num) ) & MASK64b(bit,num))
|
||||
((pletohl(buf+ADDR32(bit)+4) >> SHIFT64b(bit,num) ) & MASK64b(bit,num))
|
||||
|
||||
#define BIT_BITS64(bit, buf, num) \
|
||||
( (OFFSET32(bit)+(num)) <= 32 \
|
||||
|
|
Loading…
Reference in New Issue