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

getting PDUs length

1
1

I want to get the PDUs length, I think it is found here:

tvbuff_t *tvb -> length

or

packet_info *pinfo -> gssapi_decrypted_tvb -> length

But when I compile, I get an error from the compiler:

error C2037: left of 'length' specifies undefined struct/union 'tvbuff'

Does someone know what it is?

member "length" exists. you can see it here.

Thanks

asked 03 Jul '13, 06:27

hudac's gravatar image

hudac
61111317
accept rate: 50%


2 Answers:

2

The length member is "private", to get the length use the function tvb_length() on a tvb pointer. Careful though, the tvb may not contain all the data expected for a PDU, e.g. because the capture was made with a small snaplen.

Also note the correct reference for Wireshark source code would be the actual Wireshark repository which can be found here.

answered 03 Jul '13, 06:41

grahamb's gravatar image

grahamb ♦
19.8k330206
accept rate: 22%

1

I want to get the PDUs length, I think it is found here:

tvbuff_t *tvb -> length

Remember, many capture programs, including Wireshark/TShark/dumpcap, tcpdump, and a number of other sniffers, let you limit the number of bytes captured and saved, so that if the snapshot length is N, and the packet is M bytes long, where M > N, only the first N bytes of the packet will be captured.

So if you want the actual packet length, rather than the number of bytes of the packet that happen to have been captured, you want reported_length, and you get that by calling tvb_reported_length().

answered 03 Jul '13, 11:43

Guy%20Harris's gravatar image

Guy Harris ♦♦
17.4k335196
accept rate: 19%