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

Wireshark-dev: [Wireshark-dev] ipv6 address help

From: Brian Oleksa <oleksab@xxxxxxxxxxxxxxxxxxxxxx>
Date: Tue, 26 Jan 2010 14:57:45 -0500

Wiresharkers

I was able to successfully dissect my ipv4 address by using the built in routines.
                       guint32 addr;
                       addr = tvb_get_ipv4(tvb,offset);
proto_tree_add_ipv4_format_value(helen_sub_tree, hf_helen_ipv4, tvb, offset, 4, addr, "Address: %d.%d.%d.%d", addr & 0xff, (addr >> 8) & 0xff, (addr >> 16) & 0xff, addr >> 24);

I am now trying to do the same for ipv6 addresses (unfortunately.. I do not have a way to test it)....but I would like to get the code in place.

I have found the code in the wireshark developers readme file.... but not sure what to do with "struct e_in6_addr *addr" in the void tvb_get_ipv6 function.

void tvb_get_ipv6(tvbuff_t*, gint offset, struct e_in6_addr *addr); proto_tree_add_ipv6_format_value... I have created a hf_helen_ipv6 routine

here is what I have put together....but would like to use the built in wireshark routines:

                        guint32 addr1, addr2, addr3, addr4;

                       if (swap) {

                           addr1 = swap32(addr1);

                           addr2 = swap32(addr2);

                           addr3 = swap32(addr3);

                           addr4 = swap32(addr4);

                       }

proto_tree_add_uint_format(helen_sub_tree, hf_helen_length, tvb, offset, 16, 0,

"Address: %d.%d.%d.%d.%d.%d.%d.%d.%d.%d.%d.%d.%d.%d.%d.%d",

addr1 >> 24, (addr1 >> 16) & 0xff, (addr1 >> 8) & 0xff, addr1 & 0xff,

addr2 >> 24, (addr2 >> 16) & 0xff, (addr2 >> 8) & 0xff, addr2 & 0xff,

addr3 >> 24, (addr3 >> 16) & 0xff, (addr3 >> 8) & 0xff, addr3 & 0xff,

addr4 >> 24, (addr4 >> 16) & 0xff, (addr4 >> 8) & 0xff, addr4 & 0xff

                               );

                       offset += 16;


Any help is greatly appreciated.

Thanks,
Brian