This question should be fixed to accept proper v6 addresses


  • 2
    B

    This problem is terrible it accepts some version of ipv6 that's not correct it should be changed to accept valid ipv4 addresses and valid ipv6 addresses as according to man 3 inet_pton.

    AF_INET
                  src points to a character string containing an IPv4 network
                  address in dotted-decimal format, "ddd.ddd.ddd.ddd", where ddd
                  is a decimal number of up to three digits in the range 0 to
                  255.  The address is converted to a struct in_addr and copied
                  to dst, which must be sizeof(struct in_addr) (4) bytes (32
                  bits) long.
    
           AF_INET6
                  src points to a character string containing an IPv6 network
                  address.  The address is converted to a struct in6_addr and
                  copied to dst, which must be sizeof(struct in6_addr) (16)
                  bytes (128 bits) long.  The allowed formats for IPv6 addresses
                  follow these rules:
    
                  1. The preferred format is x:x:x:x:x:x:x:x.  This form
                     consists of eight hexadecimal numbers, each of which
                     expresses a 16-bit value (i.e., each x can be up to 4 hex
                     digits).
    
                  2. A series of contiguous zero values in the preferred format
                     can be abbreviated to ::.  Only one instance of :: can
                     occur in an address.  For example, the loopback address
                     0:0:0:0:0:0:0:1 can be abbreviated as ::1.  The wildcard
                     address, consisting of all zeros, can be written as ::.
    
                  3. An alternate format is useful for expressing IPv4-mapped
                     IPv6 addresses.  This form is written as
                     x:x:x:x:x:x:d.d.d.d, where the six leading xs are
                     hexadecimal values that define the six most-significant
                     16-bit pieces of the address (i.e., 96 bits), and the ds
                     express a value in dotted-decimal notation that defines the
                     least significant 32 bits of the address.  An example of
                     such an address is ::FFFF:204.152.189.116.
    
                  See RFC 2373 for further details on the representation of IPv6
                  addresses.
    

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.