code: private static String ipBytesToString(ByteBuf header, int addressLen) {
          StringBuilder sb = new StringBuilder();
          if (addressLen == 4) {
              sb.append(header.readByte() & 0xff);
              sb.append('.');
              sb.append(header.readByte() & 0xff);
              sb.append('.');
              sb.append(header.readByte() & 0xff);
              sb.append('.');
              sb.append(header.readByte() & 0xff);
          } else {
              sb.append(Integer.toHexString(header.readUnsignedShort()));
              sb.append(':');
              sb.append(Integer.toHexString(header.readUnsignedShort()));
              sb.append(':');
              sb.append(Integer.toHexString(header.readUnsignedShort()));
              sb.append(':');
              sb.append(Integer.toHexString(header.readUnsignedShort()));
              sb.append(':');
              sb.append(Integer.toHexString(header.readUnsignedShort()));
              sb.append(':');
              sb.append(Integer.toHexString(header.readUnsignedShort()));
              sb.append(':');
              sb.append(Integer.toHexString(header.readUnsignedShort()));
              sb.append(':');
              sb.append(Integer.toHexString(header.readUnsignedShort()));
          }
          return sb.toString();
      }
docs: Convert ip address bytes to string representation
  
  @param header     buffer containing ip address bytes
  @param addressLen number of bytes to read (4 bytes for IPv4, 16 bytes for IPv6)
  @return           string representation of the ip address