Back to index

glibc  2.9
Defines | Functions | Variables
tst-rfc3484.c File Reference
#include <stdbool.h>
#include <stdio.h>
#include <ifaddrs.h>
#include "../sysdeps/posix/getaddrinfo.c"
#include "../test-skeleton.c"

Go to the source code of this file.

Defines

#define __getservbyname_r   getservbyname_r
#define __socket   socket
#define __getsockname   getsockname
#define __inet_aton   inet_aton
#define __gethostbyaddr_r   gethostbyaddr_r
#define __gethostbyname2_r   gethostbyname2_r
#define h(n)   n
#define naddrs   (sizeof (addrs) / sizeof (addrs[0]))
#define TEST_FUNCTION   do_test ()

Functions

void attribute_hidden __check_pf (bool *p1, bool *p2, struct in6addrinfo **in6ai, size_t *in6ailen)
void attribute_hidden __check_native (uint32_t a1_index, int *a1_native, uint32_t a2_index, int *a2_native)
int attribute_hidden __idna_to_ascii_lz (const char *input, char **output, int flags)
int attribute_hidden __idna_to_unicode_lzlz (const char *input, char **output, int flags)
void attribute_hidden _res_hconf_init (void)
ssize_t __getline (char **lineptr, size_t *n, FILE *s)
static int do_test (void)

Variables

service_user *__nss_hosts_database attribute_hidden
static struct addrinfo [naddrs]
static struct sort_result [naddrs]
static size_t order [naddrs]
static int expected [naddrs]

Define Documentation

#define __gethostbyaddr_r   gethostbyaddr_r

Definition at line 10 of file tst-rfc3484.c.

#define __gethostbyname2_r   gethostbyname2_r

Definition at line 11 of file tst-rfc3484.c.

#define __getservbyname_r   getservbyname_r

Definition at line 6 of file tst-rfc3484.c.

#define __getsockname   getsockname

Definition at line 8 of file tst-rfc3484.c.

#define __inet_aton   inet_aton

Definition at line 9 of file tst-rfc3484.c.

#define __socket   socket

Definition at line 7 of file tst-rfc3484.c.

#define h (   n)    n

Definition at line 60 of file tst-rfc3484.c.

#define naddrs   (sizeof (addrs) / sizeof (addrs[0]))

Definition at line 75 of file tst-rfc3484.c.

#define TEST_FUNCTION   do_test ()

Definition at line 138 of file tst-rfc3484.c.


Function Documentation

void attribute_hidden __check_native ( uint32_t  a1_index,
int a1_native,
uint32_t  a2_index,
int a2_native 
)

Definition at line 24 of file tst-rfc3484.c.

{
}
void attribute_hidden __check_pf ( bool *  p1,
bool *  p2,
struct in6addrinfo **  in6ai,
size_t in6ailen 
)

Definition at line 15 of file tst-rfc3484.c.

{
  *p1 = *p2 = true;
  *in6ai = NULL;
  *in6ailen = 0;
}
ssize_t __getline ( char **  lineptr,
size_t n,
FILE s 
)

Definition at line 87 of file tst-rfc3484.c.

{
  *lineptr = NULL;
  *n = 0;
  return 0;
}
int attribute_hidden __idna_to_ascii_lz ( const char *  input,
char **  output,
int  flags 
)

Definition at line 31 of file tst-rfc3484.c.

{
  return 0;
}
int attribute_hidden __idna_to_unicode_lzlz ( const char *  input,
char **  output,
int  flags 
)

Definition at line 38 of file tst-rfc3484.c.

{
  *output = NULL;
  return 0;
}

Definition at line 46 of file tst-rfc3484.c.

{
}
static int do_test ( void  ) [static]

Definition at line 96 of file tst-rfc3484.c.

{
  labels = default_labels;
  precedence = default_precedence;
  scopes= default_scopes;

  struct sockaddr_in so;
  so.sin_family = AF_INET;
  so.sin_addr.s_addr = h (0xc0a85f19);

  for (int i = 0; i < naddrs; ++i)
    {
      ais[i].ai_family = AF_INET;
      ais[i].ai_addr = (struct sockaddr *) &addrs[i];
      results[i].dest_addr = &ais[i];
      results[i].got_source_addr = true;
      memcpy(&results[i].source_addr, &so, sizeof (so));
      results[i].source_addr_len = sizeof (so);
      results[i].source_addr_flags = 0;
      results[i].prefixlen = 8;
      results[i].index = 0;

      order[i] = i;
    }

  struct sort_result_combo combo = { .results = results, .nresults = naddrs };
  qsort_r (order, naddrs, sizeof (order[0]), rfc3484_sort, &combo);

  int result = 0;
  for (int i = 0; i < naddrs; ++i)
    {
      struct in_addr addr = ((struct sockaddr_in *) (results[order[i]].dest_addr->ai_addr))->sin_addr;

      int here = memcmp (&addr, &addrs[expected[i]].sin_addr,
                      sizeof (struct in_addr));
      printf ("[%d] = %s: %s\n", i, inet_ntoa (addr), here ? "FAIL" : "OK");
      result |= here;
    }

  return result;
}

Here is the call graph for this function:


Variable Documentation

struct addrinfo[naddrs] [static]

Definition at line 76 of file tst-rfc3484.c.

Definition at line 52 of file tst-rfc3484.c.

int expected[naddrs] [static]
Initial value:
  {
    6, 1, 0, 3, 2, 4, 5
  }

Definition at line 80 of file tst-rfc3484.c.

size_t order[naddrs] [static]

Definition at line 78 of file tst-rfc3484.c.

struct sort_result[naddrs] [static]

Definition at line 77 of file tst-rfc3484.c.