forked from osmocom/wireshark
Add tvb_get_[n|le]toh[40|48|56]() accessors. Addresses bug 5082.
svn path=/trunk/; revision=35538
This commit is contained in:
parent
f37c04357b
commit
116d67e164
|
@ -160,21 +160,9 @@ static const value_string mpeg_pes_TrickModeFrequencyTruncation_vals[] = {
|
|||
{ 0, NULL }
|
||||
};
|
||||
|
||||
static guint64 tvb_get_ntoh40(tvbuff_t *tvb, unsigned offset)
|
||||
{
|
||||
return (guint64)tvb_get_guint8(tvb, offset) << 32
|
||||
| tvb_get_ntohl(tvb, offset + 1);
|
||||
}
|
||||
|
||||
static guint64 tvb_get_ntoh48(tvbuff_t *tvb, unsigned offset)
|
||||
{
|
||||
return (guint64)tvb_get_ntohs(tvb, offset) << 32
|
||||
| tvb_get_ntohl(tvb, offset + 2);
|
||||
}
|
||||
|
||||
#define TSHZ 90000
|
||||
|
||||
static guint64 decode_time_stamp(tvbuff_t *tvb, unsigned offset, nstime_t *nst)
|
||||
static guint64 decode_time_stamp(tvbuff_t *tvb, gint offset, nstime_t *nst)
|
||||
{
|
||||
guint64 bytes = tvb_get_ntoh40(tvb, offset);
|
||||
guint64 ts =
|
||||
|
@ -189,7 +177,7 @@ static guint64 decode_time_stamp(tvbuff_t *tvb, unsigned offset, nstime_t *nst)
|
|||
|
||||
#define SCRHZ 27000000
|
||||
|
||||
static guint64 decode_clock_reference(tvbuff_t *tvb, unsigned offset,
|
||||
static guint64 decode_clock_reference(tvbuff_t *tvb, gint offset,
|
||||
nstime_t *nst)
|
||||
{
|
||||
guint64 bytes = tvb_get_ntoh48(tvb, offset);
|
||||
|
@ -213,7 +201,7 @@ dissect_mpeg_pes_header_data(tvbuff_t *tvb, packet_info *pinfo,
|
|||
0, -1, FALSE);
|
||||
proto_tree *tree = proto_item_add_subtree(item, ett_mpeg_pes_header_data);
|
||||
|
||||
unsigned offset = 0;
|
||||
gint offset = 0;
|
||||
if (flags & PTS_FLAG) {
|
||||
nstime_t nst;
|
||||
decode_time_stamp(tvb, offset, &nst);
|
||||
|
@ -357,8 +345,8 @@ dissect_mpeg_pes_header_data(tvbuff_t *tvb, packet_info *pinfo,
|
|||
}
|
||||
}
|
||||
|
||||
static unsigned
|
||||
dissect_mpeg_pes_pack_header(tvbuff_t *tvb, unsigned offset,
|
||||
static gint
|
||||
dissect_mpeg_pes_pack_header(tvbuff_t *tvb, gint offset,
|
||||
packet_info *pinfo, proto_tree *root)
|
||||
{
|
||||
unsigned program_mux_rate, stuffing_length;
|
||||
|
@ -405,7 +393,7 @@ dissect_mpeg_pes(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
|
|||
int prefix;
|
||||
int stream;
|
||||
asn1_ctx_t asn1_ctx;
|
||||
unsigned offset = 0;
|
||||
gint offset = 0;
|
||||
|
||||
if (!tvb_bytes_exist(tvb, 0, 3))
|
||||
return FALSE; /* not enough bytes for a PES prefix */
|
||||
|
|
|
@ -1198,6 +1198,9 @@ integers, 32-bit integers (guint32), and 64-bit integers (guint64):
|
|||
guint16 tvb_get_ntohs(tvbuff_t*, gint offset);
|
||||
guint32 tvb_get_ntoh24(tvbuff_t*, gint offset);
|
||||
guint32 tvb_get_ntohl(tvbuff_t*, gint offset);
|
||||
guint64 tvb_get_ntoh40(tvbuff_t*, gint offset);
|
||||
guint64 tvb_get_ntoh48(tvbuff_t*, gint offset);
|
||||
guint64 tvb_get_ntoh56(tvbuff_t*, gint offset);
|
||||
guint64 tvb_get_ntoh64(tvbuff_t*, gint offset);
|
||||
|
||||
Network-to-host-order accessors for single-precision and
|
||||
|
@ -1213,6 +1216,9 @@ Little-Endian-to-host-order accessors for 16-bit integers (guint16),
|
|||
guint16 tvb_get_letohs(tvbuff_t*, gint offset);
|
||||
guint32 tvb_get_letoh24(tvbuff_t*, gint offset);
|
||||
guint32 tvb_get_letohl(tvbuff_t*, gint offset);
|
||||
guint64 tvb_get_letoh40(tvbuff_t*, gint offset);
|
||||
guint64 tvb_get_letoh48(tvbuff_t*, gint offset);
|
||||
guint64 tvb_get_letoh56(tvbuff_t*, gint offset);
|
||||
guint64 tvb_get_letoh64(tvbuff_t*, gint offset);
|
||||
|
||||
Little-Endian-to-host-order accessors for single-precision and
|
||||
|
|
|
@ -601,21 +601,9 @@ static const value_string mpeg_pes_TrickModeFrequencyTruncation_vals[] = {
|
|||
{ 0, NULL }
|
||||
};
|
||||
|
||||
static guint64 tvb_get_ntoh40(tvbuff_t *tvb, unsigned offset)
|
||||
{
|
||||
return (guint64)tvb_get_guint8(tvb, offset) << 32
|
||||
| tvb_get_ntohl(tvb, offset + 1);
|
||||
}
|
||||
|
||||
static guint64 tvb_get_ntoh48(tvbuff_t *tvb, unsigned offset)
|
||||
{
|
||||
return (guint64)tvb_get_ntohs(tvb, offset) << 32
|
||||
| tvb_get_ntohl(tvb, offset + 2);
|
||||
}
|
||||
|
||||
#define TSHZ 90000
|
||||
|
||||
static guint64 decode_time_stamp(tvbuff_t *tvb, unsigned offset, nstime_t *nst)
|
||||
static guint64 decode_time_stamp(tvbuff_t *tvb, gint offset, nstime_t *nst)
|
||||
{
|
||||
guint64 bytes = tvb_get_ntoh40(tvb, offset);
|
||||
guint64 ts =
|
||||
|
@ -630,7 +618,7 @@ static guint64 decode_time_stamp(tvbuff_t *tvb, unsigned offset, nstime_t *nst)
|
|||
|
||||
#define SCRHZ 27000000
|
||||
|
||||
static guint64 decode_clock_reference(tvbuff_t *tvb, unsigned offset,
|
||||
static guint64 decode_clock_reference(tvbuff_t *tvb, gint offset,
|
||||
nstime_t *nst)
|
||||
{
|
||||
guint64 bytes = tvb_get_ntoh48(tvb, offset);
|
||||
|
@ -654,7 +642,7 @@ dissect_mpeg_pes_header_data(tvbuff_t *tvb, packet_info *pinfo,
|
|||
0, -1, FALSE);
|
||||
proto_tree *tree = proto_item_add_subtree(item, ett_mpeg_pes_header_data);
|
||||
|
||||
unsigned offset = 0;
|
||||
gint offset = 0;
|
||||
if (flags & PTS_FLAG) {
|
||||
nstime_t nst;
|
||||
decode_time_stamp(tvb, offset, &nst);
|
||||
|
@ -798,8 +786,8 @@ dissect_mpeg_pes_header_data(tvbuff_t *tvb, packet_info *pinfo,
|
|||
}
|
||||
}
|
||||
|
||||
static unsigned
|
||||
dissect_mpeg_pes_pack_header(tvbuff_t *tvb, unsigned offset,
|
||||
static gint
|
||||
dissect_mpeg_pes_pack_header(tvbuff_t *tvb, gint offset,
|
||||
packet_info *pinfo, proto_tree *root)
|
||||
{
|
||||
unsigned program_mux_rate, stuffing_length;
|
||||
|
@ -846,7 +834,7 @@ dissect_mpeg_pes(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
|
|||
int prefix;
|
||||
int stream;
|
||||
asn1_ctx_t asn1_ctx;
|
||||
unsigned offset = 0;
|
||||
gint offset = 0;
|
||||
|
||||
if (!tvb_bytes_exist(tvb, 0, 3))
|
||||
return FALSE; /* not enough bytes for a PES prefix */
|
||||
|
@ -1224,7 +1212,7 @@ proto_register_mpeg_pes(void)
|
|||
"BIT_STRING_SIZE_16", HFILL }},
|
||||
|
||||
/*--- End of included file: packet-mpeg-pes-hfarr.c ---*/
|
||||
#line 582 "packet-mpeg-pes-template.c"
|
||||
#line 570 "packet-mpeg-pes-template.c"
|
||||
{ &hf_mpeg_pes_pack_header,
|
||||
{ "Pack header", "mpeg-pes.pack",
|
||||
FT_NONE, BASE_NONE, NULL, 0, NULL, HFILL }},
|
||||
|
@ -1342,7 +1330,7 @@ proto_register_mpeg_pes(void)
|
|||
&ett_mpeg_pes_Picture,
|
||||
|
||||
/*--- End of included file: packet-mpeg-pes-ettarr.c ---*/
|
||||
#line 689 "packet-mpeg-pes-template.c"
|
||||
#line 677 "packet-mpeg-pes-template.c"
|
||||
&ett_mpeg_pes_pack_header,
|
||||
&ett_mpeg_pes_header_data,
|
||||
&ett_mpeg_pes_trick_mode
|
||||
|
|
|
@ -1053,6 +1053,9 @@ tvb_get_guint8
|
|||
tvb_get_ipv4
|
||||
tvb_get_ipv6
|
||||
tvb_get_letoh24
|
||||
tvb_get_letoh40
|
||||
tvb_get_letoh48
|
||||
tvb_get_letoh56
|
||||
tvb_get_letoh64
|
||||
tvb_get_letohguid
|
||||
tvb_get_letohieee_double
|
||||
|
@ -1062,6 +1065,9 @@ tvb_get_letohs
|
|||
tvb_get_nstringz
|
||||
tvb_get_nstringz0
|
||||
tvb_get_ntoh24
|
||||
tvb_get_ntoh40
|
||||
tvb_get_ntoh48
|
||||
tvb_get_ntoh56
|
||||
tvb_get_ntoh64
|
||||
tvb_get_ntohguid
|
||||
tvb_get_ntohieee_double
|
||||
|
|
48
epan/pint.h
48
epan/pint.h
|
@ -39,13 +39,35 @@
|
|||
(guint16)*((const guint8 *)(p)+1)<<0))
|
||||
|
||||
#define pntoh24(p) ((guint32)*((const guint8 *)(p)+0)<<16| \
|
||||
(guint32)*((const guint8 *)(p)+1)<<8| \
|
||||
(guint32)*((const guint8 *)(p)+1)<<8| \
|
||||
(guint32)*((const guint8 *)(p)+2)<<0)
|
||||
|
||||
#define pntohl(p) ((guint32)*((const guint8 *)(p)+0)<<24| \
|
||||
(guint32)*((const guint8 *)(p)+1)<<16| \
|
||||
(guint32)*((const guint8 *)(p)+2)<<8| \
|
||||
(guint32)*((const guint8 *)(p)+3)<<0)
|
||||
|
||||
#define pntoh40(p) ((guint64)*((const guint8 *)(p)+0)<<32| \
|
||||
(guint64)*((const guint8 *)(p)+1)<<24| \
|
||||
(guint64)*((const guint8 *)(p)+2)<<16| \
|
||||
(guint64)*((const guint8 *)(p)+3)<<8| \
|
||||
(guint64)*((const guint8 *)(p)+4)<<0)
|
||||
|
||||
#define pntoh48(p) ((guint64)*((const guint8 *)(p)+0)<<40| \
|
||||
(guint64)*((const guint8 *)(p)+1)<<32| \
|
||||
(guint64)*((const guint8 *)(p)+2)<<24| \
|
||||
(guint64)*((const guint8 *)(p)+3)<<16| \
|
||||
(guint64)*((const guint8 *)(p)+4)<<8| \
|
||||
(guint64)*((const guint8 *)(p)+5)<<0)
|
||||
|
||||
#define pntoh56(p) ((guint64)*((const guint8 *)(p)+0)<<48| \
|
||||
(guint64)*((const guint8 *)(p)+1)<<40| \
|
||||
(guint64)*((const guint8 *)(p)+2)<<32| \
|
||||
(guint64)*((const guint8 *)(p)+3)<<24| \
|
||||
(guint64)*((const guint8 *)(p)+4)<<16| \
|
||||
(guint64)*((const guint8 *)(p)+5)<<8| \
|
||||
(guint64)*((const guint8 *)(p)+6)<<0)
|
||||
|
||||
#define pntoh64(p) ((guint64)*((const guint8 *)(p)+0)<<56| \
|
||||
(guint64)*((const guint8 *)(p)+1)<<48| \
|
||||
(guint64)*((const guint8 *)(p)+2)<<40| \
|
||||
|
@ -61,13 +83,35 @@
|
|||
(guint16)*((const guint8 *)(p)+0)<<0))
|
||||
|
||||
#define pletoh24(p) ((guint32)*((const guint8 *)(p)+2)<<16| \
|
||||
(guint32)*((const guint8 *)(p)+1)<<8| \
|
||||
(guint32)*((const guint8 *)(p)+1)<<8| \
|
||||
(guint32)*((const guint8 *)(p)+0)<<0)
|
||||
|
||||
#define pletohl(p) ((guint32)*((const guint8 *)(p)+3)<<24| \
|
||||
(guint32)*((const guint8 *)(p)+2)<<16| \
|
||||
(guint32)*((const guint8 *)(p)+1)<<8| \
|
||||
(guint32)*((const guint8 *)(p)+0)<<0)
|
||||
|
||||
#define pletoh40(p) ((guint64)*((const guint8 *)(p)+4)<<32| \
|
||||
(guint64)*((const guint8 *)(p)+3)<<24| \
|
||||
(guint64)*((const guint8 *)(p)+2)<<16| \
|
||||
(guint64)*((const guint8 *)(p)+1)<<8| \
|
||||
(guint64)*((const guint8 *)(p)+0)<<0)
|
||||
|
||||
#define pletoh48(p) ((guint64)*((const guint8 *)(p)+5)<<40| \
|
||||
(guint64)*((const guint8 *)(p)+4)<<32| \
|
||||
(guint64)*((const guint8 *)(p)+3)<<24| \
|
||||
(guint64)*((const guint8 *)(p)+2)<<16| \
|
||||
(guint64)*((const guint8 *)(p)+1)<<8| \
|
||||
(guint64)*((const guint8 *)(p)+0)<<0)
|
||||
|
||||
#define pletoh56(p) ((guint64)*((const guint8 *)(p)+6)<<48| \
|
||||
(guint64)*((const guint8 *)(p)+5)<<40| \
|
||||
(guint64)*((const guint8 *)(p)+4)<<32| \
|
||||
(guint64)*((const guint8 *)(p)+3)<<24| \
|
||||
(guint64)*((const guint8 *)(p)+2)<<16| \
|
||||
(guint64)*((const guint8 *)(p)+1)<<8| \
|
||||
(guint64)*((const guint8 *)(p)+0)<<0)
|
||||
|
||||
#define pletoh64(p) ((guint64)*((const guint8 *)(p)+7)<<56| \
|
||||
(guint64)*((const guint8 *)(p)+6)<<48| \
|
||||
(guint64)*((const guint8 *)(p)+5)<<40| \
|
||||
|
|
|
@ -1180,6 +1180,33 @@ tvb_get_ntohl(tvbuff_t *tvb, const gint offset)
|
|||
return pntohl(ptr);
|
||||
}
|
||||
|
||||
guint64
|
||||
tvb_get_ntoh40(tvbuff_t *tvb, const gint offset)
|
||||
{
|
||||
const guint8* ptr;
|
||||
|
||||
ptr = fast_ensure_contiguous(tvb, offset, 5);
|
||||
return pntoh40(ptr);
|
||||
}
|
||||
|
||||
guint64
|
||||
tvb_get_ntoh48(tvbuff_t *tvb, const gint offset)
|
||||
{
|
||||
const guint8* ptr;
|
||||
|
||||
ptr = fast_ensure_contiguous(tvb, offset, 6);
|
||||
return pntoh48(ptr);
|
||||
}
|
||||
|
||||
guint64
|
||||
tvb_get_ntoh56(tvbuff_t *tvb, const gint offset)
|
||||
{
|
||||
const guint8* ptr;
|
||||
|
||||
ptr = fast_ensure_contiguous(tvb, offset, 7);
|
||||
return pntoh56(ptr);
|
||||
}
|
||||
|
||||
guint64
|
||||
tvb_get_ntoh64(tvbuff_t *tvb, const gint offset)
|
||||
{
|
||||
|
@ -1419,6 +1446,33 @@ tvb_get_letohl(tvbuff_t *tvb, const gint offset)
|
|||
return pletohl(ptr);
|
||||
}
|
||||
|
||||
guint64
|
||||
tvb_get_letoh40(tvbuff_t *tvb, const gint offset)
|
||||
{
|
||||
const guint8* ptr;
|
||||
|
||||
ptr = fast_ensure_contiguous(tvb, offset, 5);
|
||||
return pletoh40(ptr);
|
||||
}
|
||||
|
||||
guint64
|
||||
tvb_get_letoh48(tvbuff_t *tvb, const gint offset)
|
||||
{
|
||||
const guint8* ptr;
|
||||
|
||||
ptr = fast_ensure_contiguous(tvb, offset, 6);
|
||||
return pletoh48(ptr);
|
||||
}
|
||||
|
||||
guint64
|
||||
tvb_get_letoh56(tvbuff_t *tvb, const gint offset)
|
||||
{
|
||||
const guint8* ptr;
|
||||
|
||||
ptr = fast_ensure_contiguous(tvb, offset, 7);
|
||||
return pletoh56(ptr);
|
||||
}
|
||||
|
||||
guint64
|
||||
tvb_get_letoh64(tvbuff_t *tvb, const gint offset)
|
||||
{
|
||||
|
|
|
@ -319,6 +319,9 @@ extern guint8 tvb_get_guint8(tvbuff_t*, const gint offset);
|
|||
extern guint16 tvb_get_ntohs(tvbuff_t*, const gint offset);
|
||||
extern guint32 tvb_get_ntoh24(tvbuff_t*, const gint offset);
|
||||
extern guint32 tvb_get_ntohl(tvbuff_t*, const gint offset);
|
||||
extern guint64 tvb_get_ntoh40(tvbuff_t*, const gint offset);
|
||||
extern guint64 tvb_get_ntoh48(tvbuff_t*, const gint offset);
|
||||
extern guint64 tvb_get_ntoh56(tvbuff_t*, const gint offset);
|
||||
extern guint64 tvb_get_ntoh64(tvbuff_t*, const gint offset);
|
||||
extern gfloat tvb_get_ntohieee_float(tvbuff_t*, const gint offset);
|
||||
extern gdouble tvb_get_ntohieee_double(tvbuff_t*, const gint offset);
|
||||
|
@ -326,6 +329,9 @@ extern gdouble tvb_get_ntohieee_double(tvbuff_t*, const gint offset);
|
|||
extern guint16 tvb_get_letohs(tvbuff_t*, const gint offset);
|
||||
extern guint32 tvb_get_letoh24(tvbuff_t*, const gint offset);
|
||||
extern guint32 tvb_get_letohl(tvbuff_t*, const gint offset);
|
||||
extern guint64 tvb_get_letoh40(tvbuff_t*, const gint offset);
|
||||
extern guint64 tvb_get_letoh48(tvbuff_t*, const gint offset);
|
||||
extern guint64 tvb_get_letoh56(tvbuff_t*, const gint offset);
|
||||
extern guint64 tvb_get_letoh64(tvbuff_t*, const gint offset);
|
||||
extern gfloat tvb_get_letohieee_float(tvbuff_t*, const gint offset);
|
||||
extern gdouble tvb_get_letohieee_double(tvbuff_t*, const gint offset);
|
||||
|
|
Loading…
Reference in New Issue