-{
- unsigned long raw = GAddress_INET_GetHostAddress(m_address);
- return wxString::Format(
- _T("%u.%u.%u.%u"),
- (unsigned char)((raw>>24) & 0xff),
- (unsigned char)((raw>>16) & 0xff),
- (unsigned char)((raw>>8) & 0xff),
- (unsigned char)(raw & 0xff)
- );
+{
+ unsigned char addr[16];
+ GAddress_INET6_GetHostAddress(m_address,(in6_addr*)addr);
+
+ wxUint16 words[8];
+ int i,
+ prefix_zero_count = 0;
+ for ( i = 0; i < 8; ++i )
+ {
+ words[i] = addr[i*2];
+ words[i] <<= 8;
+ words[i] |= addr[i*2+1];
+ if ( i == prefix_zero_count && words[i] == 0 )
+ ++prefix_zero_count;
+ }
+
+ wxString result;
+ if ( prefix_zero_count == 8 )
+ {
+ result = wxT( "::" );
+ }
+ else if ( prefix_zero_count == 6 && words[5] == 0xFFFF )
+ {
+ // IPv4 mapped
+ result.Printf("::ffff:%d.%d.%d.%d",
+ addr[12], addr[13], addr[14], addr[15]);
+ }
+ else // general case
+ {
+ result = ":";
+ for ( i = prefix_zero_count; i < 8; ++i )
+ {
+ result += wxString::Format(":%x", words[i]);
+ }
+ }
+
+ return result;