This is a static archive of our old Q&A Site. Please post any new questions and answers at ask.wireshark.org.

Can tvb_get_ntoh24 , tvb_get_guint8 take negative offset ?

0

I may sound pretty novice but i just want to avoid any silly mistakes. Do these two functions work properly with negative offset ?

tvb_get_ntoh24 , tvb_get_guint8

Thanks in advance!!

asked 13 Aug '12, 04:13

yogeshg's gravatar image

yogeshg
41222326
accept rate: 0%


One Answer:

0

I believe so, both those functions, and most of the other tvb accessors, take a gint for offset where a negative value indicates bytes from the end of the buffer to start at.

answered 13 Aug '12, 04:45

grahamb's gravatar image

grahamb ♦
19.8k330206
accept rate: 22%

Okay , so if (tvb,0) points to chunk of address from 10 to 20 then (tvb,-1) will point to 19 rather than 9. Am i getting it correct ?

(13 Aug '12, 04:58) yogeshg

Say your tvb has 20 bytes in it, then (tvb, -1) will point to offset 19. You can't "step back" into data before the start of the tvb, that will be held in a different tvb owned by the preceding dissector.

(13 Aug '12, 06:44) grahamb ♦