Wireshark-dev: [Wireshark-dev] ip6_to_str equivalent/alternative with variable length for ipv6

From: ivan jr sy <ivan_jr@xxxxxxxxx>
Date: Mon, 10 Aug 2009 19:03:09 -0700 (PDT)
Hi all:

I need some advise on getting an IPv6 address to str with variable number of bytes.

Example:

/* the hex part is */
20 01 db 08 ff ff 00 02 20 86 20 03 de ad be ef

addr_len = 6;	/* variable */

/* if I do this: */
addr = tvb_get_ptr(tvb, cur_offset, addr_len);
 .... ip6_to_str((const struct e_in6_addr *)addr);

this will result to:
2001:db8:ffff:2:2086:2003:dead:beef

but what i wanted was:
/* the hex part is */
20 01 db 08 ff ff

so it will result to "2001:db8:ffff" (the network portion) coz the "00 02 20 86 20 03 de ad be ef" is for a different purpose.. then I also need to append "::" to the last part of the str to make it "2001:db8:ffff::"

-----------

I've also tried to use:

bytes_to_str_punct(addr, addr_len, ':')


but this will result to "20:01:db:08:ff:ff"



what is my best approach?

Thanks!
- Ivan