Huge thanks to our Platinum Members Endace and LiveAction,
and our Silver Member Veeam, for supporting the Wireshark Foundation and project.

Wireshark-dev: Re: [Wireshark-dev] Decoding an incoming message into an array

From: "Abhik Sarkar" <sarkar.abhik@xxxxxxxxx>
Date: Wed, 23 Jul 2008 10:27:59 +0400
Hi Sachin,

I don't think there is any function to fetch an array from the tvb.
_In theory_, if you knew that there are exactly 10 integers in param2
you could do a memcpy from the tvb... but that would be just wrong
because the byte-order might get messed up on different platforms. So,
it is probably best to loop 10 times and get an integer in the
host-order one at a time.

As far as displaying it in the decoded tree goes, you can create a
sub-tree called param2 and add the integers under that tree. You can
find any example in packet-smpp.c, function smpp_handle_dlist().

HTH
Abhik.

On Tue, Jul 22, 2008 at 10:41 AM, Sachin Kumar Verma
<sachin.verma@xxxxxxxxxxx> wrote:
> Hi All,
>
> Can anyone please provide me a sample code to dissect an incoming message
> into a structure that also contains an array? For e.g. if the target
> structure is:
>
>
>
> struct sample_struct {
>
>             int param1;
>
>             int param2[10];
>
> };
>
>
>
> Then please suggest me the appropriate way to dissect an incoming packet
> into this structure and displaying its decoded tree properly. Would
> appreciate if you can also suggest me the way to take care of possible
> padding bytes that may be inserted by the sending entity.
>
>
>
> Thanks a ton in advance.
>
>
>
> T & R
>
> Sachin Verma
>
> Software Engineer
>
> ________________________________
> "DISCLAIMER: This message is proprietary to Aricent and is intended solely
> for the use of the individual to whom it is addressed. It may contain
> privileged or confidential information and should not be circulated or used
> for any purpose other than for what it is intended. If you have received
> this message in error,please notify the originator immediately. If you are
> not the intended recipient, you are notified that you are strictly
> prohibited from using, copying, altering, or disclosing the contents of this
> message. Aricent accepts no responsibility forloss or damage arising from
> the use of the information transmitted by this email including damage from
> virus."
>
> _______________________________________________
> Wireshark-dev mailing list
> Wireshark-dev@xxxxxxxxxxxxx
> https://wireshark.org/mailman/listinfo/wireshark-dev
>
>