Hi,
I am trying to dissect a byte field for protocol with following byte structure.
=============
|T|S|TSG|RES|
=============
|1|1| 3 | 3 |
=============
T bit 1 bit
S bit 1 bit
TSG 3 bit
RES 3 bit
I was trying to get 1 byte unsigned int, AND with the MASKs for the bits and right shift operation.
(tvb_get_guint8(tvb,stlv_offset+46)) && 0x80) >> 7
(tvb_get_guint8(tvb,stlv_offset+46)) && 0x40) >> 6
(tvb_get_guint8(tvb,stlv_offset+46)) && 0x38) >> 3
I am using above functions as an argument to add_text like:
proto_tree_add_text(stlv_tree, tvb, stlv_offset+46, 1, "Termination Capable: %d",
((tvb_get_guint8(tvb,stlv_offset+46)) && 0x80)>>7));
But this is giving me all 0 values, and messes my further dissecting.
I am fairly new to Wireshark development, but I was thinking I could just get int, bitwise and, then right shift to get the correct bits.
Is there a better way to do this?
I have a C program wherein I receive a byte array and I do the same thing, extracting bytes and using masks to get the correct bit values, which works. The same logic is not working in Wireshark code.
asked
30 May '12, 11:36
prafulla
1●1●1●1
accept rate:
0%