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

function tvb_get_ntohs

0

hi everyone,

What is the exact role of function "tvb_get_ntohs" , if we write :

ch1 = tvb_get_ntohs(tvb, 0); ch2 = tvb_get_ntohs(tvb, 2);

what does it mean exactly , i know that the tvb is buffer where our data is recorded, but the second element is an offset , What's that? and what does it mean this offset.

Thank you.

asked 04 Jul '13, 10:07

cruz's gravatar image

cruz
11446
accept rate: 0%


One Answer:

2

The offset parameter is the offset into the buffer to get the value from, counting from 0.

In your example, ch1 is set to the 16 bit value at offset 0 in the buffer and ch2 is set to the 16 bit value at offset 2 in the buffer.

The ntohs part specifies that the data value in the buffer is in network order (big-endian) and it will be converted to the correct order for the host that the software is running on.

answered 04 Jul '13, 13:41

grahamb's gravatar image

grahamb ♦
19.8k330206
accept rate: 22%

edited 04 Jul '13, 13:43