Blame inet/check_pf.c

Packit 6c4009
/* Determine protocol families for which interfaces exist.  Generic version.
Packit 6c4009
   Copyright (C) 2003-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 <ifaddrs.h>
Packit 6c4009
#include <netdb.h>
Packit 6c4009
#include <stdint.h>
Packit 6c4009
Packit 6c4009
void
Packit 6c4009
attribute_hidden
Packit 6c4009
__check_pf (bool *seen_ipv4, bool *seen_ipv6,
Packit 6c4009
	    struct in6addrinfo **in6ai, size_t *in6ailen)
Packit 6c4009
{
Packit 6c4009
  /* By default we have no way to determine information about
Packit 6c4009
     deprecated and temporary addresses.  */
Packit 6c4009
  *in6ai = NULL;
Packit 6c4009
  *in6ailen = 0;
Packit 6c4009
Packit 6c4009
  /* Get the interface list via getifaddrs.  */
Packit 6c4009
  struct ifaddrs *ifa = NULL;
Packit 6c4009
  if (__getifaddrs (&ifa) != 0)
Packit 6c4009
    {
Packit 6c4009
      /* We cannot determine what interfaces are available.  Be
Packit 6c4009
	 pessimistic.  */
Packit 6c4009
      *seen_ipv4 = true;
Packit 6c4009
      *seen_ipv6 = true;
Packit 6c4009
      return;
Packit 6c4009
    }
Packit 6c4009
Packit 6c4009
  *seen_ipv4 = false;
Packit 6c4009
  *seen_ipv6 = false;
Packit 6c4009
Packit 6c4009
  struct ifaddrs *runp;
Packit 6c4009
  for (runp = ifa; runp != NULL; runp = runp->ifa_next)
Packit 6c4009
    if (runp->ifa_addr->sa_family == PF_INET)
Packit 6c4009
      *seen_ipv4 = true;
Packit 6c4009
    else if (runp->ifa_addr->sa_family == PF_INET6)
Packit 6c4009
      *seen_ipv6 = true;
Packit 6c4009
Packit 6c4009
  (void) __freeifaddrs (ifa);
Packit 6c4009
}
Packit 6c4009
Packit 6c4009
Packit 6c4009
void
Packit 6c4009
__free_in6ai (struct in6addrinfo *in6ai)
Packit 6c4009
{
Packit 6c4009
  /* Nothing to do.  */
Packit 6c4009
}
Packit 6c4009
Packit 6c4009
Packit 6c4009
#if IS_IN (nscd)
Packit 6c4009
uint32_t
Packit 6c4009
__bump_nl_timestamp (void)
Packit 6c4009
{
Packit 6c4009
  return 0;
Packit 6c4009
}
Packit 6c4009
#endif