diff options
author | Gerald Combs <gerald@wireshark.org> | 2007-12-06 18:53:58 +0000 |
---|---|---|
committer | Gerald Combs <gerald@wireshark.org> | 2007-12-06 18:53:58 +0000 |
commit | 2a67c4d472c4f806b2b7640b3fa721c45320635e (patch) | |
tree | aa044121f215edbe77ca6f864356cfcd954e7082 /plugins | |
parent | 4783f12c08140054591b66160ee8e3e2d45525c4 (diff) | |
download | wireshark-2a67c4d472c4f806b2b7640b3fa721c45320635e.tar.gz |
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
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/wimax/msg_dlmap.c | 4 | ||||
-rw-r--r-- | plugins/wimax/msg_ulmap.c | 99 | ||||
-rw-r--r-- | plugins/wimax/wimax_bits.h | 36 |
3 files changed, 69 insertions, 70 deletions
diff --git a/plugins/wimax/msg_dlmap.c b/plugins/wimax/msg_dlmap.c index c7d202739a..98f3d4914f 100644 --- a/plugins/wimax/msg_dlmap.c +++ b/plugins/wimax/msg_dlmap.c @@ -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; diff --git a/plugins/wimax/msg_ulmap.c b/plugins/wimax/msg_ulmap.c index 8db77105b3..53700bce5b 100644 --- a/plugins/wimax/msg_ulmap.c +++ b/plugins/wimax/msg_ulmap.c @@ -315,7 +315,7 @@ static hf_register_info hf[] = { &hf_ulmap_message_type, { - "MAC Management Message Type", "wmx.macmgtmsgtype.ulmap", + "MAC Management Message Type", "wmx.macmgtmsgtype.ulmap", FT_UINT8, BASE_DEC, NULL, 0x0, "", HFILL } }, @@ -323,294 +323,294 @@ static hf_register_info hf[] = &hf_ulmap_fch_expected, { "FCH Expected", "wmx.ulmap.fch.expected", - FT_UINT16, BASE_DEC, NULL, 0x0, "", HFILL + FT_UINT16, BASE_DEC, NULL, 0x0, "", HFILL } }, { &hf_ulmap_ie, { "UL-MAP IE", "wmx.ulmap.ie", - FT_UINT8, BASE_DEC, NULL, 0x0, "", HFILL + FT_UINT8, BASE_DEC, NULL, 0x0, "", HFILL } }, { &hf_ulmap_ie_cid, { "CID", "wmx.ulmap.ie.cid", - FT_UINT32, BASE_DEC, NULL, 0x0, "", HFILL + FT_UINT32, BASE_DEC, NULL, 0x0, "", HFILL } }, { &hf_ulmap_ie_uiuc, { "UIUC", "wmx.ulmap.ie.uiuc", - FT_UINT8, BASE_DEC, NULL, 0x0, "", HFILL + FT_UINT8, BASE_DEC, NULL, 0x0, "", HFILL } }, { &hf_ulmap_ofdma_sym, { "Num OFDMA Symbols", "wmx.ulmap.ofdma.sym", - FT_UINT8, BASE_DEC, NULL, 0x0, "", HFILL + FT_UINT8, BASE_DEC, NULL, 0x0, "", HFILL } }, { &hf_ulmap_reserved, { "Reserved", "wmx.ulmap.rsv", - FT_UINT8, BASE_DEC, NULL, 0x0, "", HFILL + FT_UINT8, BASE_DEC, NULL, 0x0, "", HFILL } }, { &hf_ulmap_alloc_start_time, { "Uplink Channel ID", "wmx.ulmap.start", - FT_UINT32, BASE_DEC, NULL, 0x0, "", HFILL + FT_UINT32, BASE_DEC, NULL, 0x0, "", HFILL } }, { &hf_ulmap_ucd_count, { "UCD Count", "wmx.ulmap.ucd", - FT_UINT8, BASE_DEC, NULL, 0x0, "", HFILL + FT_UINT8, BASE_DEC, NULL, 0x0, "", HFILL } }, { &hf_ulmap_uiuc0_numsub, { "No. subchannels", "wmx.ulmap.uiuc0.numsub", - FT_UINT32, BASE_DEC, NULL, 0x000003f8, "", HFILL + FT_UINT32, BASE_DEC, NULL, 0x000003f8, "", HFILL } }, { &hf_ulmap_uiuc0_numsym, { "No. OFDMA symbols", "wmx.ulmap.uiuc0.numsym", - FT_UINT32, BASE_DEC, NULL, 0x0001fc00, "", HFILL + FT_UINT32, BASE_DEC, NULL, 0x0001fc00, "", HFILL } }, { &hf_ulmap_uiuc0_rsv, { "Reserved", "wmx.ulmap.uiuc0.rsv", - FT_UINT32, BASE_DEC, NULL, 0x00000007, "", HFILL + FT_UINT32, BASE_DEC, NULL, 0x00000007, "", HFILL } }, { &hf_ulmap_uiuc0_subofs, { "Subchannel offset", "wmx.ulmap.uiuc0.subofs", - FT_UINT32, BASE_DEC, NULL, 0x00fe0000, "", HFILL + FT_UINT32, BASE_DEC, NULL, 0x00fe0000, "", HFILL } }, { &hf_ulmap_uiuc0_symofs, { "OFDMA symbol offset", "wmx.ulmap.uiuc0.symofs", - FT_UINT32, BASE_DEC, NULL, 0xff000000, "", HFILL + FT_UINT32, BASE_DEC, NULL, 0xff000000, "", HFILL } }, { &hf_ulmap_uiuc11_data, { "Data", "wmx.ulmap.uiuc11.data", - FT_BYTES, BASE_HEX, NULL, 0x0, "", HFILL + FT_BYTES, BASE_HEX, NULL, 0x0, "", HFILL } }, { &hf_ulmap_uiuc11_ext, { "Extended 2 UIUC", "wmx.ulmap.uiuc11.ext", - FT_UINT8, BASE_DEC, NULL, 0x0, "", HFILL + FT_UINT8, BASE_DEC, NULL, 0x0, "", HFILL } }, { &hf_ulmap_uiuc11_len, { "Length", "wmx.ulmap.uiuc11.len", - FT_UINT8, BASE_DEC, NULL, 0x0, "", HFILL + FT_UINT8, BASE_DEC, NULL, 0x0, "", HFILL } }, { &hf_ulmap_uiuc12_dri, { "Dedicated ranging indicator", "wmx.ulmap.uiuc12.dri", - FT_UINT32, BASE_DEC, NULL, 0x00000001, "", HFILL + FT_UINT32, BASE_DEC, NULL, 0x00000001, "", HFILL } }, { &hf_ulmap_uiuc10_dur, { "Duration", "wmx.ulmap.uiuc12.dur", - FT_UINT16, BASE_DEC, NULL, 0xFFc0, "", HFILL + FT_UINT16, BASE_DEC, NULL, 0xFFc0, "", HFILL } }, { &hf_ulmap_uiuc12_method, { "Ranging Method", "wmx.ulmap.uiuc12.method", - FT_UINT32, BASE_DEC, NULL, 0x00000006, "", HFILL + FT_UINT32, BASE_DEC, NULL, 0x00000006, "", HFILL } }, { &hf_ulmap_uiuc12_numsub, { "No. Subchannels", "wmx.ulmap.uiuc12.numsub", - FT_UINT32, BASE_DEC, NULL, 0x000003F8, "", HFILL + FT_UINT32, BASE_DEC, NULL, 0x000003F8, "", HFILL } }, { &hf_ulmap_uiuc12_numsym, { "No. OFDMA Symbols", "wmx.ulmap.uiuc12.numsym", - FT_UINT32, BASE_DEC, NULL, 0x0001Fc00, "", HFILL + FT_UINT32, BASE_DEC, NULL, 0x0001Fc00, "", HFILL } }, { &hf_ulmap_uiuc10_rep, { "Repetition Coding indication", "wmx.ulmap.uiuc12.rep", - FT_UINT16, BASE_DEC, NULL, 0x0030, "", HFILL + FT_UINT16, BASE_DEC, NULL, 0x0030, "", HFILL } }, { &hf_ulmap_uiuc12_subofs, { "Subchannel Offset", "wmx.ulmap.uiuc12.subofs", - FT_UINT32, BASE_DEC, NULL, 0x00Fe0000, "", HFILL + FT_UINT32, BASE_DEC, NULL, 0x00Fe0000, "", HFILL } }, { &hf_ulmap_uiuc12_symofs, { "OFDMA Symbol Offset", "wmx.ulmap.uiuc12.symofs", - FT_UINT32, BASE_DEC, NULL, 0xFF000000, "", HFILL + FT_UINT32, BASE_DEC, NULL, 0xFF000000, "", HFILL } }, { &hf_ulmap_uiuc13_numsub, { "No. Subchannels/SZ Shift Value", "wmx.ulmap.uiuc13.numsub", - FT_UINT32, BASE_DEC, NULL, 0x000003f8, "", HFILL + FT_UINT32, BASE_DEC, NULL, 0x000003f8, "", HFILL } }, { &hf_ulmap_uiuc13_numsym, { "No. OFDMA symbols", "wmx.ulmap.uiuc13.numsym", - FT_UINT32, BASE_DEC, NULL, 0x0001fc00, "", HFILL + FT_UINT32, BASE_DEC, NULL, 0x0001fc00, "", HFILL } }, { - &hf_ulmap_uiuc13_papr, + &hf_ulmap_uiuc13_papr, { "PAPR Reduction/Safety Zone", "wmx.ulmap.uiuc13.papr", - FT_UINT32, BASE_DEC, NULL, 0x00000004, "", HFILL + FT_UINT32, BASE_DEC, NULL, 0x00000004, "", HFILL } }, { - &hf_ulmap_uiuc13_rsv, + &hf_ulmap_uiuc13_rsv, { "Reserved", "wmx.ulmap.uiuc13.rsv", - FT_UINT32, BASE_DEC, NULL, 0x00000001, "", HFILL + FT_UINT32, BASE_DEC, NULL, 0x00000001, "", HFILL } }, { &hf_ulmap_uiuc13_subofs, { "Subchannel offset", "wmx.ulmap.uiuc13.subofs", - FT_UINT32, BASE_DEC, NULL, 0x00fe0000, "", HFILL + FT_UINT32, BASE_DEC, NULL, 0x00fe0000, "", HFILL } }, { &hf_ulmap_uiuc13_symofs, { "OFDMA symbol offset", "wmx.ulmap.uiuc13.symofs", - FT_UINT32, BASE_DEC, NULL, 0xff000000, "", HFILL + FT_UINT32, BASE_DEC, NULL, 0xff000000, "", HFILL } }, { - &hf_ulmap_uiuc13_zone, + &hf_ulmap_uiuc13_zone, { "Sounding Zone", "wmx.ulmap.uiuc13.zone", - FT_UINT32, BASE_DEC, NULL, 0x00000002, "", HFILL + FT_UINT32, BASE_DEC, NULL, 0x00000002, "", HFILL } }, { &hf_ulmap_uiuc14_bwr, { "BW request mandatory", "wmx.ulmap.uiuc14.bwr", - FT_UINT8, BASE_DEC, NULL, 0x01, "", HFILL + FT_UINT8, BASE_DEC, NULL, 0x01, "", HFILL } }, { &hf_ulmap_uiuc14_code, { "Ranging code", "wmx.ulmap.uiuc14.code", - FT_UINT8, BASE_DEC, NULL, 0x0, "", HFILL + FT_UINT8, BASE_DEC, NULL, 0x0, "", HFILL } }, { &hf_ulmap_uiuc14_dur, { "Duration", "wmx.ulmap.uiuc14.dur", - FT_UINT16, BASE_DEC, NULL, 0xfc00, "", HFILL + FT_UINT16, BASE_DEC, NULL, 0xfc00, "", HFILL } }, { &hf_ulmap_uiuc14_idx, { "Frame Number Index", "wmx.ulmap.uiuc14.idx", - FT_UINT16, BASE_DEC, NULL, 0x000F, "", HFILL + FT_UINT16, BASE_DEC, NULL, 0x000F, "", HFILL } }, { &hf_ulmap_uiuc14_rep, { "Repetition Coding Indication", "wmx.ulmap.uiuc14.rep", - FT_UINT16, BASE_DEC, NULL, 0x0030, "", HFILL + FT_UINT16, BASE_DEC, NULL, 0x0030, "", HFILL } }, { &hf_ulmap_uiuc14_sub, { "Ranging subchannel", "wmx.ulmap.uiuc14.sub", - FT_UINT8, BASE_DEC, NULL, 0xfe, "", HFILL + FT_UINT8, BASE_DEC, NULL, 0xfe, "", HFILL } }, { &hf_ulmap_uiuc14_sym, { "Ranging symbol", "wmx.ulmap.uiuc14.sym", - FT_UINT8, BASE_DEC, NULL, 0x0, "", HFILL + FT_UINT8, BASE_DEC, NULL, 0x0, "", HFILL } }, { &hf_ulmap_uiuc14_uiuc, { "UIUC", "wmx.ulmap.uiuc14.uiuc", - FT_UINT16, BASE_DEC, NULL, 0x03c0, "", HFILL + FT_UINT16, BASE_DEC, NULL, 0x03c0, "", HFILL } }, { &hf_ulmap_uiuc15_data, { "Data", "wmx.ulmap.uiuc15.data", - FT_BYTES, BASE_HEX, NULL, 0x0, "", HFILL + FT_BYTES, BASE_HEX, NULL, 0x0, "", HFILL } }, { &hf_ulmap_uiuc15_ext, { "Extended UIUC", "wmx.ulmap.uiuc15.ext", - FT_UINT8, BASE_DEC, NULL, 0x0, "", HFILL + FT_UINT8, BASE_DEC, NULL, 0x0, "", HFILL } }, { &hf_ulmap_uiuc15_len, { "Length", "wmx.ulmap.uiuc15.len", - FT_UINT8, BASE_DEC, NULL, 0x0, "", HFILL + FT_UINT8, BASE_DEC, NULL, 0x0, "", HFILL } } }; @@ -640,7 +640,7 @@ gint Dedicated_UL_Control_IE(proto_tree *uiuc_tree, const guint8 *bufptr, gint o proto_item *ti = NULL; proto_item *tree = NULL; gint sdma; - + bit = offset; ti = proto_tree_add_text(uiuc_tree, tvb, NIBHI(offset, length), "Dedicated_UL_Control_IE"); @@ -1856,7 +1856,7 @@ gint AAS_SDMA_UL_IE(proto_tree *uiuc_tree, const guint8 *bufptr, gint offset, gi } if (padj) { XBIT(data, 8, "Power Adjustment"); - + } } } @@ -2128,7 +2128,7 @@ gint dissect_ulmap_ie( proto_tree *ie_tree, const guint8 *bufptr, gint offset, g nibble += 1; data = NIB_WORD(nibble, bufptr); - proto_tree_add_uint(tree, hf_ulmap_uiuc14_dur, tvb, NIBHI(nibble,2), data); + proto_tree_add_uint(tree, hf_ulmap_uiuc14_dur, tvb, NIBHI(nibble,2), data); proto_tree_add_uint(tree, hf_ulmap_uiuc14_uiuc, tvb, NIBHI(nibble+1,2), data); proto_tree_add_uint(tree, hf_ulmap_uiuc14_rep, tvb, NIBHI(nibble+2,1), data); proto_tree_add_uint(tree, hf_ulmap_uiuc14_idx, tvb, NIBHI(nibble+3,1), data); @@ -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); diff --git a/plugins/wimax/wimax_bits.h b/plugins/wimax/wimax_bits.h index e5c2835855..8da7da8c3e 100644 --- a/plugins/wimax/wimax_bits.h +++ b/plugins/wimax/wimax_bits.h @@ -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,15 +163,15 @@ */ #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 \ ? BIT_BITS32(bit,buf,num) \ |