Blame resolv/tst-inet_pton.c

Packit 6c4009
/* Test inet_pton functions.
Packit 6c4009
   Copyright (C) 2017-2018 Free Software Foundation, Inc.
Packit 6c4009
   This file is part of the GNU C Library.
Packit 6c4009
Packit 6c4009
   The GNU C Library is free software; you can redistribute it and/or
Packit 6c4009
   modify it under the terms of the GNU Lesser General Public
Packit 6c4009
   License as published by the Free Software Foundation; either
Packit 6c4009
   version 2.1 of the License, or (at your option) any later version.
Packit 6c4009
Packit 6c4009
   The GNU C Library is distributed in the hope that it will be useful,
Packit 6c4009
   but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit 6c4009
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Packit 6c4009
   Lesser General Public License for more details.
Packit 6c4009
Packit 6c4009
   You should have received a copy of the GNU Lesser General Public
Packit 6c4009
   License along with the GNU C Library; if not, see
Packit 6c4009
   <http://www.gnu.org/licenses/>.  */
Packit 6c4009
Packit 6c4009
#include <arpa/inet.h>
Packit 6c4009
#include <resolv/resolv-internal.h>
Packit 6c4009
#include <stdbool.h>
Packit 6c4009
#include <stdio.h>
Packit 6c4009
#include <string.h>
Packit 6c4009
#include <support/check.h>
Packit 6c4009
#include <support/next_to_fault.h>
Packit 6c4009
#include <support/xunistd.h>
Packit 6c4009
#include <unistd.h>
Packit 6c4009
Packit 6c4009
struct test_case
Packit 6c4009
{
Packit 6c4009
  /* The input data.  */
Packit 6c4009
  const char *input;
Packit 6c4009
Packit 6c4009
  /* True if AF_INET parses successfully.  */
Packit 6c4009
  bool ipv4_ok;
Packit 6c4009
Packit 6c4009
  /* True if AF_INET6 parses successfully.  */
Packit 6c4009
  bool ipv6_ok;
Packit 6c4009
Packit 6c4009
  /* Expected result for AF_INET.  */
Packit 6c4009
  unsigned char ipv4_expected[4];
Packit 6c4009
Packit 6c4009
  /* Expected result for AF_INET6.  */
Packit 6c4009
  unsigned char ipv6_expected[16];
Packit 6c4009
};
Packit 6c4009
Packit 6c4009
static void
Packit 6c4009
check_result (const char *what, const struct test_case *t, int family,
Packit 6c4009
              void *result_buffer, int inet_ret)
Packit 6c4009
{
Packit 6c4009
  TEST_VERIFY_EXIT (inet_ret >= -1);
Packit 6c4009
  TEST_VERIFY_EXIT (inet_ret <= 1);
Packit 6c4009
Packit 6c4009
  int ok;
Packit 6c4009
  const unsigned char *expected;
Packit 6c4009
  size_t result_size;
Packit 6c4009
  switch (family)
Packit 6c4009
    {
Packit 6c4009
    case AF_INET:
Packit 6c4009
      ok = t->ipv4_ok;
Packit 6c4009
      expected = t->ipv4_expected;
Packit 6c4009
      result_size = 4;
Packit 6c4009
      break;
Packit 6c4009
    case AF_INET6:
Packit 6c4009
      ok = t->ipv6_ok;
Packit 6c4009
      expected = t->ipv6_expected;
Packit 6c4009
      result_size = 16;
Packit 6c4009
      break;
Packit 6c4009
    default:
Packit 6c4009
      FAIL_EXIT1 ("invalid address family %d", family);
Packit 6c4009
    }
Packit 6c4009
Packit 6c4009
  if (inet_ret != ok)
Packit 6c4009
    {
Packit 6c4009
      support_record_failure ();
Packit 6c4009
      printf ("error: %s return value mismatch for [[%s]], family %d\n"
Packit 6c4009
              "  expected: %d\n"
Packit 6c4009
              "  actual: %d\n",
Packit 6c4009
              what, t->input, family, ok, inet_ret);
Packit 6c4009
      return;
Packit 6c4009
    }
Packit 6c4009
  if (memcmp (result_buffer, expected, result_size) != 0)
Packit 6c4009
    {
Packit 6c4009
      support_record_failure ();
Packit 6c4009
      printf ("error: %s result mismatch for [[%s]], family %d\n",
Packit 6c4009
              what, t->input, family);
Packit 6c4009
    }
Packit 6c4009
}
Packit 6c4009
Packit 6c4009
static void
Packit 6c4009
run_one_test (const struct test_case *t)
Packit 6c4009
{
Packit 6c4009
  size_t test_len = strlen (t->input);
Packit 6c4009
Packit 6c4009
  struct support_next_to_fault ntf_out4 = support_next_to_fault_allocate (4);
Packit 6c4009
  struct support_next_to_fault ntf_out6 = support_next_to_fault_allocate (16);
Packit 6c4009
Packit 6c4009
  /* inet_pton requires NUL termination.  */
Packit 6c4009
  {
Packit 6c4009
    struct support_next_to_fault ntf_in
Packit 6c4009
      = support_next_to_fault_allocate (test_len + 1);
Packit 6c4009
    memcpy (ntf_in.buffer, t->input, test_len + 1);
Packit 6c4009
    memset (ntf_out4.buffer, 0, 4);
Packit 6c4009
    check_result ("inet_pton", t, AF_INET, ntf_out4.buffer,
Packit 6c4009
                  inet_pton (AF_INET, ntf_in.buffer, ntf_out4.buffer));
Packit 6c4009
    memset (ntf_out6.buffer, 0, 16);
Packit 6c4009
    check_result ("inet_pton", t, AF_INET6, ntf_out6.buffer,
Packit 6c4009
                  inet_pton (AF_INET6, ntf_in.buffer, ntf_out6.buffer));
Packit 6c4009
    support_next_to_fault_free (&ntf_in);
Packit 6c4009
  }
Packit 6c4009
Packit 6c4009
  /* __inet_pton_length does not require NUL termination.  */
Packit 6c4009
  {
Packit 6c4009
    struct support_next_to_fault ntf_in
Packit 6c4009
      = support_next_to_fault_allocate (test_len);
Packit 6c4009
    memcpy (ntf_in.buffer, t->input, test_len);
Packit 6c4009
    memset (ntf_out4.buffer, 0, 4);
Packit 6c4009
    check_result ("__inet_pton_length", t, AF_INET, ntf_out4.buffer,
Packit 6c4009
                  __inet_pton_length (AF_INET, ntf_in.buffer, ntf_in.length,
Packit 6c4009
                                      ntf_out4.buffer));
Packit 6c4009
    memset (ntf_out6.buffer, 0, 16);
Packit 6c4009
    check_result ("__inet_pton_length", t, AF_INET6, ntf_out6.buffer,
Packit 6c4009
                  __inet_pton_length (AF_INET6, ntf_in.buffer, ntf_in.length,
Packit 6c4009
                                      ntf_out6.buffer));
Packit 6c4009
    support_next_to_fault_free (&ntf_in);
Packit 6c4009
  }
Packit 6c4009
Packit 6c4009
  support_next_to_fault_free (&ntf_out4);
Packit 6c4009
  support_next_to_fault_free (&ntf_out6);
Packit 6c4009
}
Packit 6c4009
Packit 6c4009
/* The test cases were manually crafted and the set enhanced with
Packit 6c4009
   American Fuzzy Lop.  */
Packit 6c4009
const struct test_case test_cases[] =
Packit 6c4009
  {
Packit 6c4009
    {.input = ".:", },
Packit 6c4009
    {.input = "0.0.0.0",
Packit 6c4009
     .ipv4_ok = true,
Packit 6c4009
     .ipv4_expected = {0, 0, 0, 0},
Packit 6c4009
    },
Packit 6c4009
    {.input = "0.:", },
Packit 6c4009
    {.input = "00", },
Packit 6c4009
    {.input = "0000000", },
Packit 6c4009
    {.input = "00000000000000000", },
Packit 6c4009
    {.input = "092.", },
Packit 6c4009
    {.input = "10.0.301.2", },
Packit 6c4009
    {.input = "127.0.0.1",
Packit 6c4009
     .ipv4_ok = true,
Packit 6c4009
     .ipv4_expected = {127, 0, 0, 1},
Packit 6c4009
    },
Packit 6c4009
    {.input = "19..", },
Packit 6c4009
    {.input = "192.0.2.-1", },
Packit 6c4009
    {.input = "192.0.2.01", },
Packit 6c4009
    {.input = "192.0.2.1.", },
Packit 6c4009
    {.input = "192.0.2.1192.", },
Packit 6c4009
    {.input = "192.0.2.192.\377..", },
Packit 6c4009
    {.input = "192.0.2.256", },
Packit 6c4009
    {.input = "192.0.2.27",
Packit 6c4009
     .ipv4_ok = true,
Packit 6c4009
     .ipv4_expected = {192, 0, 2, 27},
Packit 6c4009
    },
Packit 6c4009
    {.input = "192.0.201.", },
Packit 6c4009
    {.input = "192.0.261.", },
Packit 6c4009
    {.input = "192.0.2\256", },
Packit 6c4009
    {.input = "192.0.\262.", },
Packit 6c4009
    {.input = "192.062.", },
Packit 6c4009
    {.input = "192.092.\256", },
Packit 6c4009
    {.input = "192.0\2562.", },
Packit 6c4009
    {.input = "192.192.0.2661\031", },
Packit 6c4009
    {.input = "192.192.00n2.1.", },
Packit 6c4009
    {.input = "192.192.2.190.", },
Packit 6c4009
    {.input = "192.255.255.2555", },
Packit 6c4009
    {.input = "192.92.219\023.", },
Packit 6c4009
    {.input = "192.\260.2.", },
Packit 6c4009
    {.input = "1:1::1:1",
Packit 6c4009
     .ipv6_ok = true,
Packit 6c4009
     .ipv6_expected = {
Packit 6c4009
       0x0, 0x1, 0x0, 0x1, 0x0, 0x0, 0x0, 0x0,
Packit 6c4009
       0x0, 0x0, 0x0, 0x0, 0x0, 0x1, 0x0, 0x1
Packit 6c4009
     },
Packit 6c4009
    },
Packit 6c4009
    {.input = "2", },
Packit 6c4009
    {.input = "2.", },
Packit 6c4009
    {.input = "2001:db8:00001::f", },
Packit 6c4009
    {.input = "2001:db8:10000::f", },
Packit 6c4009
    {.input = "2001:db8:1234:5678:abcd:ef01:2345:67",
Packit 6c4009
     .ipv6_ok = true,
Packit 6c4009
     .ipv6_expected = {
Packit 6c4009
       0x20, 0x1, 0xd, 0xb8, 0x12, 0x34, 0x56, 0x78,
Packit 6c4009
       0xab, 0xcd, 0xef, 0x1, 0x23, 0x45, 0x0, 0x67
Packit 6c4009
     },
Packit 6c4009
    },
Packit 6c4009
    {.input = "2001:db8:1234:5678:abcd:ef01:2345:6789:1", },
Packit 6c4009
    {.input = "2001:db8:1234:5678:abcd:ef01:2345::6789", },
Packit 6c4009
    {.input = "2001:db8::0",
Packit 6c4009
     .ipv6_ok = true,
Packit 6c4009
     .ipv6_expected = {
Packit 6c4009
       0x20, 0x1, 0xd, 0xb8, 0x0, 0x0, 0x0, 0x0,
Packit 6c4009
       0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0
Packit 6c4009
     },
Packit 6c4009
    },
Packit 6c4009
    {.input = "2001:db8::00",
Packit 6c4009
     .ipv6_ok = true,
Packit 6c4009
     .ipv6_expected = {
Packit 6c4009
       0x20, 0x1, 0xd, 0xb8, 0x0, 0x0, 0x0, 0x0,
Packit 6c4009
       0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0
Packit 6c4009
     },
Packit 6c4009
    },
Packit 6c4009
    {.input = "2001:db8::1",
Packit 6c4009
     .ipv6_ok = true,
Packit 6c4009
     .ipv6_expected = {
Packit 6c4009
       0x20, 0x1, 0xd, 0xb8, 0x0, 0x0, 0x0, 0x0,
Packit 6c4009
       0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1
Packit 6c4009
     },
Packit 6c4009
    },
Packit 6c4009
    {.input = "2001:db8::10",
Packit 6c4009
     .ipv6_ok = true,
Packit 6c4009
     .ipv6_expected = {
Packit 6c4009
       0x20, 0x1, 0xd, 0xb8, 0x0, 0x0, 0x0, 0x0,
Packit 6c4009
       0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x10
Packit 6c4009
     },
Packit 6c4009
    },
Packit 6c4009
    {.input = "2001:db8::19",
Packit 6c4009
     .ipv6_ok = true,
Packit 6c4009
     .ipv6_expected = {
Packit 6c4009
       0x20, 0x1, 0xd, 0xb8, 0x0, 0x0, 0x0, 0x0,
Packit 6c4009
       0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x19
Packit 6c4009
     },
Packit 6c4009
    },
Packit 6c4009
    {.input = "2001:db8::1::\012", },
Packit 6c4009
    {.input = "2001:db8::1::2\012", },
Packit 6c4009
    {.input = "2001:db8::2",
Packit 6c4009
     .ipv6_ok = true,
Packit 6c4009
     .ipv6_expected = {
Packit 6c4009
       0x20, 0x1, 0xd, 0xb8, 0x0, 0x0, 0x0, 0x0,
Packit 6c4009
       0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x2
Packit 6c4009
     },
Packit 6c4009
    },
Packit 6c4009
    {.input = "2001:db8::3",
Packit 6c4009
     .ipv6_ok = true,
Packit 6c4009
     .ipv6_expected = {
Packit 6c4009
       0x20, 0x1, 0xd, 0xb8, 0x0, 0x0, 0x0, 0x0,
Packit 6c4009
       0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x3
Packit 6c4009
     },
Packit 6c4009
    },
Packit 6c4009
    {.input = "2001:db8::4",
Packit 6c4009
     .ipv6_ok = true,
Packit 6c4009
     .ipv6_expected = {
Packit 6c4009
       0x20, 0x1, 0xd, 0xb8, 0x0, 0x0, 0x0, 0x0,
Packit 6c4009
       0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x4
Packit 6c4009
     },
Packit 6c4009
    },
Packit 6c4009
    {.input = "2001:db8::5",
Packit 6c4009
     .ipv6_ok = true,
Packit 6c4009
     .ipv6_expected = {
Packit 6c4009
       0x20, 0x1, 0xd, 0xb8, 0x0, 0x0, 0x0, 0x0,
Packit 6c4009
       0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x5
Packit 6c4009
     },
Packit 6c4009
    },
Packit 6c4009
    {.input = "2001:db8::6",
Packit 6c4009
     .ipv6_ok = true,
Packit 6c4009
     .ipv6_expected = {
Packit 6c4009
       0x20, 0x1, 0xd, 0xb8, 0x0, 0x0, 0x0, 0x0,
Packit 6c4009
       0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x6
Packit 6c4009
     },
Packit 6c4009
    },
Packit 6c4009
    {.input = "2001:db8::7",
Packit 6c4009
     .ipv6_ok = true,
Packit 6c4009
     .ipv6_expected = {
Packit 6c4009
       0x20, 0x1, 0xd, 0xb8, 0x0, 0x0, 0x0, 0x0,
Packit 6c4009
       0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x7
Packit 6c4009
     },
Packit 6c4009
    },
Packit 6c4009
    {.input = "2001:db8::8",
Packit 6c4009
     .ipv6_ok = true,
Packit 6c4009
     .ipv6_expected = {
Packit 6c4009
       0x20, 0x1, 0xd, 0xb8, 0x0, 0x0, 0x0, 0x0,
Packit 6c4009
       0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x8
Packit 6c4009
     },
Packit 6c4009
    },
Packit 6c4009
    {.input = "2001:db8::9",
Packit 6c4009
     .ipv6_ok = true,
Packit 6c4009
     .ipv6_expected = {
Packit 6c4009
       0x20, 0x1, 0xd, 0xb8, 0x0, 0x0, 0x0, 0x0,
Packit 6c4009
       0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x9
Packit 6c4009
     },
Packit 6c4009
    },
Packit 6c4009
    {.input = "2001:db8::A",
Packit 6c4009
     .ipv6_ok = true,
Packit 6c4009
     .ipv6_expected = {
Packit 6c4009
       0x20, 0x1, 0xd, 0xb8, 0x0, 0x0, 0x0, 0x0,
Packit 6c4009
       0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xa
Packit 6c4009
     },
Packit 6c4009
    },
Packit 6c4009
    {.input = "2001:db8::B",
Packit 6c4009
     .ipv6_ok = true,
Packit 6c4009
     .ipv6_expected = {
Packit 6c4009
       0x20, 0x1, 0xd, 0xb8, 0x0, 0x0, 0x0, 0x0,
Packit 6c4009
       0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xb
Packit 6c4009
     },
Packit 6c4009
    },
Packit 6c4009
    {.input = "2001:db8::C",
Packit 6c4009
     .ipv6_ok = true,
Packit 6c4009
     .ipv6_expected = {
Packit 6c4009
       0x20, 0x1, 0xd, 0xb8, 0x0, 0x0, 0x0, 0x0,
Packit 6c4009
       0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xc
Packit 6c4009
     },
Packit 6c4009
    },
Packit 6c4009
    {.input = "2001:db8::D",
Packit 6c4009
     .ipv6_ok = true,
Packit 6c4009
     .ipv6_expected = {
Packit 6c4009
       0x20, 0x1, 0xd, 0xb8, 0x0, 0x0, 0x0, 0x0,
Packit 6c4009
       0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xd
Packit 6c4009
     },
Packit 6c4009
    },
Packit 6c4009
    {.input = "2001:db8::E",
Packit 6c4009
     .ipv6_ok = true,
Packit 6c4009
     .ipv6_expected = {
Packit 6c4009
       0x20, 0x1, 0xd, 0xb8, 0x0, 0x0, 0x0, 0x0,
Packit 6c4009
       0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xe
Packit 6c4009
     },
Packit 6c4009
    },
Packit 6c4009
    {.input = "2001:db8::F",
Packit 6c4009
     .ipv6_ok = true,
Packit 6c4009
     .ipv6_expected = {
Packit 6c4009
       0x20, 0x1, 0xd, 0xb8, 0x0, 0x0, 0x0, 0x0,
Packit 6c4009
       0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xf
Packit 6c4009
     },
Packit 6c4009
    },
Packit 6c4009
    {.input = "2001:db8::a",
Packit 6c4009
     .ipv6_ok = true,
Packit 6c4009
     .ipv6_expected = {
Packit 6c4009
       0x20, 0x1, 0xd, 0xb8, 0x0, 0x0, 0x0, 0x0,
Packit 6c4009
       0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xa
Packit 6c4009
     },
Packit 6c4009
    },
Packit 6c4009
    {.input = "2001:db8::b",
Packit 6c4009
     .ipv6_ok = true,
Packit 6c4009
     .ipv6_expected = {
Packit 6c4009
       0x20, 0x1, 0xd, 0xb8, 0x0, 0x0, 0x0, 0x0,
Packit 6c4009
       0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xb
Packit 6c4009
     },
Packit 6c4009
    },
Packit 6c4009
    {.input = "2001:db8::c",
Packit 6c4009
     .ipv6_ok = true,
Packit 6c4009
     .ipv6_expected = {
Packit 6c4009
       0x20, 0x1, 0xd, 0xb8, 0x0, 0x0, 0x0, 0x0,
Packit 6c4009
       0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xc
Packit 6c4009
     },
Packit 6c4009
    },
Packit 6c4009
    {.input = "2001:db8::d",
Packit 6c4009
     .ipv6_ok = true,
Packit 6c4009
     .ipv6_expected = {
Packit 6c4009
       0x20, 0x1, 0xd, 0xb8, 0x0, 0x0, 0x0, 0x0,
Packit 6c4009
       0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xd
Packit 6c4009
     },
Packit 6c4009
    },
Packit 6c4009
    {.input = "2001:db8::e",
Packit 6c4009
     .ipv6_ok = true,
Packit 6c4009
     .ipv6_expected = {
Packit 6c4009
       0x20, 0x1, 0xd, 0xb8, 0x0, 0x0, 0x0, 0x0,
Packit 6c4009
       0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xe
Packit 6c4009
     },
Packit 6c4009
    },
Packit 6c4009
    {.input = "2001:db8::f",
Packit 6c4009
     .ipv6_ok = true,
Packit 6c4009
     .ipv6_expected = {
Packit 6c4009
       0x20, 0x1, 0xd, 0xb8, 0x0, 0x0, 0x0, 0x0,
Packit 6c4009
       0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xf
Packit 6c4009
     },
Packit 6c4009
    },
Packit 6c4009
    {.input = "2001:db8::ff",
Packit 6c4009
     .ipv6_ok = true,
Packit 6c4009
     .ipv6_expected = {
Packit 6c4009
       0x20, 0x1, 0xd, 0xb8, 0x0, 0x0, 0x0, 0x0,
Packit 6c4009
       0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xff
Packit 6c4009
     },
Packit 6c4009
    },
Packit 6c4009
    {.input = "2001:db8::ffff:2\012", },
Packit 6c4009
    {.input = "22", },
Packit 6c4009
    {.input = "2222@", },
Packit 6c4009
    {.input = "255.255.255.255",
Packit 6c4009
     .ipv4_ok = true,
Packit 6c4009
     .ipv4_expected = {255, 255, 255, 255},
Packit 6c4009
    },
Packit 6c4009
    {.input = "255.255.255.255\001", },
Packit 6c4009
    {.input = "255.255.255.25555", },
Packit 6c4009
    {.input = "2:", },
Packit 6c4009
    {.input = "2:a:8:EEEE::EEEE:F:EEE8:EEEE\034*:", },
Packit 6c4009
    {.input = "2:ff:1:1:7:ff:1:1:7.", },
Packit 6c4009
    {.input = "2f:0000000000000000000000000000000000000000000000000000000000"
Packit 6c4009
     "0000000000000000000000000000000000000000000000000000000000000000000000"
Packit 6c4009
     "0G01",
Packit 6c4009
    },
Packit 6c4009
    {.input = "429495", },
Packit 6c4009
    {.input = "5::5::", },
Packit 6c4009
    {.input = "6.6.", },
Packit 6c4009
    {.input = "992.", },
Packit 6c4009
    {.input = "::",
Packit 6c4009
     .ipv6_ok = true,
Packit 6c4009
     .ipv6_expected = {
Packit 6c4009
       0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
Packit 6c4009
       0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0
Packit 6c4009
     },
Packit 6c4009
    },
Packit 6c4009
    {.input = "::00001", },
Packit 6c4009
    {.input = "::1",
Packit 6c4009
     .ipv6_ok = true,
Packit 6c4009
     .ipv6_expected = {
Packit 6c4009
       0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
Packit 6c4009
       0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1
Packit 6c4009
     },
Packit 6c4009
    },
Packit 6c4009
    {.input = "::10000", },
Packit 6c4009
    {.input = "::1:1",
Packit 6c4009
     .ipv6_ok = true,
Packit 6c4009
     .ipv6_expected = {
Packit 6c4009
       0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
Packit 6c4009
       0x0, 0x0, 0x0, 0x0, 0x0, 0x1, 0x0, 0x1
Packit 6c4009
     },
Packit 6c4009
    },
Packit 6c4009
    {.input = "::ff:1:1:7.0.0.1",
Packit 6c4009
     .ipv6_ok = true,
Packit 6c4009
     .ipv6_expected = {
Packit 6c4009
       0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xff,
Packit 6c4009
       0x0, 0x1, 0x0, 0x1, 0x7, 0x0, 0x0, 0x1
Packit 6c4009
     },
Packit 6c4009
    },
Packit 6c4009
    {.input = "::ff:1:1:7:ff:1:1:7.", },
Packit 6c4009
    {.input = "::ff:1:1:7ff:1:8:7.0.0.1", },
Packit 6c4009
    {.input = "::ff:1:1:7ff:1:8f:1:1:71", },
Packit 6c4009
    {.input = "::ffff:02fff:127.0.S1", },
Packit 6c4009
    {.input = "::ffff:127.0.0.1",
Packit 6c4009
     .ipv6_ok = true,
Packit 6c4009
     .ipv6_expected = {
Packit 6c4009
       0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
Packit 6c4009
       0x0, 0x0, 0xff, 0xff, 0x7f, 0x0, 0x0, 0x1
Packit 6c4009
     },
Packit 6c4009
    },
Packit 6c4009
    {.input = "::ffff:1:7.0.0.1",
Packit 6c4009
     .ipv6_ok = true,
Packit 6c4009
     .ipv6_expected = {
Packit 6c4009
       0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
Packit 6c4009
       0xff, 0xff, 0x0, 0x1, 0x7, 0x0, 0x0, 0x1
Packit 6c4009
     },
Packit 6c4009
    },
Packit 6c4009
    {.input = ":\272", },
Packit 6c4009
    {.input = "A:f:ff:1:1:D:ff:1:1::7.", },
Packit 6c4009
    {.input = "AAAAA.", },
Packit 6c4009
    {.input = "D:::", },
Packit 6c4009
    {.input = "DF8F", },
Packit 6c4009
    {.input = "F::",
Packit 6c4009
     .ipv6_ok = true,
Packit 6c4009
     .ipv6_expected = {
Packit 6c4009
       0x0, 0xf, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
Packit 6c4009
       0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0
Packit 6c4009
     },
Packit 6c4009
    },
Packit 6c4009
    {.input = "F:A:8:EEEE:8:EEEE\034*:", },
Packit 6c4009
    {.input = "F:a:8:EEEE:8:EEEE\034*:", },
Packit 6c4009
    {.input = "F:ff:100:7ff:1:8:7.0.10.1",
Packit 6c4009
     .ipv6_ok = true,
Packit 6c4009
     .ipv6_expected = {
Packit 6c4009
       0x0, 0xf, 0x0, 0xff, 0x1, 0x0, 0x7, 0xff,
Packit 6c4009
       0x0, 0x1, 0x0, 0x8, 0x7, 0x0, 0xa, 0x1
Packit 6c4009
     },
Packit 6c4009
    },
Packit 6c4009
    {.input = "d92.", },
Packit 6c4009
    {.input = "ff:00000000000000000000000000000000000000000000000000000000000"
Packit 6c4009
     "00000000000000000000000000000000000000000000000000000000000000000001",
Packit 6c4009
    },
Packit 6c4009
    {.input = "fff2:2::ff2:2:f7",
Packit 6c4009
     .ipv6_ok = true,
Packit 6c4009
     .ipv6_expected = {
Packit 6c4009
       0xff, 0xf2, 0x0, 0x2, 0x0, 0x0, 0x0, 0x0,
Packit 6c4009
       0x0, 0x0, 0xf, 0xf2, 0x0, 0x2, 0x0, 0xf7
Packit 6c4009
     },
Packit 6c4009
    },
Packit 6c4009
    {.input = "ffff:ff:ff:fff:ff:ff:ff:", },
Packit 6c4009
    {.input = "\272:", },
Packit 6c4009
    {NULL}
Packit 6c4009
  };
Packit 6c4009
Packit 6c4009
static int
Packit 6c4009
do_test (void)
Packit 6c4009
{
Packit 6c4009
  for (size_t i = 0; test_cases[i].input != NULL; ++i)
Packit 6c4009
    run_one_test (test_cases + i);
Packit 6c4009
  return 0;
Packit 6c4009
}
Packit 6c4009
Packit 6c4009
#include <support/test-driver.c>