Blame resolv/resolv_conf.h

Packit 6c4009
/* Extended resolver state separate from struct __res_state.
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
#ifndef RESOLV_STATE_H
Packit 6c4009
#define RESOLV_STATE_H
Packit 6c4009
Packit 6c4009
#include <netinet/in.h>
Packit 6c4009
#include <stdbool.h>
Packit 6c4009
#include <stddef.h>
Packit 6c4009
Packit 6c4009
/* This type corresponds to members of the _res.sort_list array.  */
Packit 6c4009
struct resolv_sortlist_entry
Packit 6c4009
{
Packit 6c4009
  struct in_addr addr;
Packit 6c4009
  uint32_t mask;
Packit 6c4009
};
Packit 6c4009
Packit 6c4009
/* Extended resolver state associated with res_state objects.  Client
Packit 6c4009
   code can reach this state through a struct resolv_context
Packit 6c4009
   object.  */
Packit 6c4009
struct resolv_conf
Packit 6c4009
{
Packit 6c4009
  /* Reference counter.  The object is deallocated once it reaches
Packit 6c4009
     zero.  For internal use within resolv_conf only.  */
Packit 6c4009
  size_t __refcount;
Packit 6c4009
Packit 6c4009
  /* List of IPv4 and IPv6 name server addresses.  */
Packit 6c4009
  const struct sockaddr **nameserver_list;
Packit 6c4009
  size_t nameserver_list_size;
Packit 6c4009
Packit 6c4009
  /* The domain names forming the search list.  */
Packit 6c4009
  const char *const *search_list;
Packit 6c4009
  size_t search_list_size;
Packit 6c4009
Packit 6c4009
  /* IPv4 address preference rules.  */
Packit 6c4009
  const struct resolv_sortlist_entry *sort_list;
Packit 6c4009
  size_t sort_list_size;
Packit 6c4009
Packit 6c4009
  /* _res.options has type unsigned long, but we can only use 32 bits
Packit 6c4009
     for portability across all architectures.  */
Packit 6c4009
  unsigned int options;
Packit 6c4009
  unsigned int retrans;         /* Timeout.  */
Packit 6c4009
  unsigned int retry;           /* Number of times to retry.  */
Packit 6c4009
  unsigned int ndots; /* Dots needed for initial non-search query.  */
Packit 6c4009
};
Packit 6c4009
Packit 6c4009
/* The functions below are for use by the res_init resolv.conf parser
Packit 6c4009
   and the struct resolv_context facility.  */
Packit 6c4009
Packit 6c4009
struct __res_state;
Packit Service 70b2a5
struct file_change_detection;
Packit 6c4009
Packit 6c4009
/* Read /etc/resolv.conf and return a configuration object, or NULL if
Packit 6c4009
   /etc/resolv.conf cannot be read due to memory allocation errors.
Packit Service 70b2a5
   If PREINIT is not NULL, some configuration values are taken from
Packit Service 70b2a5
   the struct __res_state object.  If CHANGE is not null, file change
Packit Service 70b2a5
   detection data is written to *CHANGE, based on the state of the
Packit Service 70b2a5
   file after reading it.  */
Packit Service 70b2a5
struct resolv_conf *__resolv_conf_load (struct __res_state *preinit,
Packit Service 70b2a5
                                        struct file_change_detection *change)
Packit 6c4009
  attribute_hidden __attribute__ ((warn_unused_result));
Packit 6c4009
Packit 6c4009
/* Return a configuration object for the current /etc/resolv.conf
Packit 6c4009
   settings, or NULL on failure.  The object is cached.  */
Packit 6c4009
struct resolv_conf *__resolv_conf_get_current (void)
Packit 6c4009
  attribute_hidden __attribute__ ((warn_unused_result));
Packit 6c4009
Packit 6c4009
/* Return the extended resolver state for *RESP, or NULL if it cannot
Packit 6c4009
   be determined.  A call to this function must be paired with a call
Packit 6c4009
   to __resolv_conf_put.  */
Packit 6c4009
struct resolv_conf *__resolv_conf_get (struct __res_state *) attribute_hidden;
Packit 6c4009
Packit 6c4009
/* Converse of __resolv_conf_get.  */
Packit 6c4009
void __resolv_conf_put (struct resolv_conf *) attribute_hidden;
Packit 6c4009
Packit 6c4009
/* Allocate a new struct resolv_conf object and copy the
Packit 6c4009
   pre-configured values from *INIT.  Return NULL on allocation
Packit 6c4009
   failure.  The object must be deallocated using
Packit 6c4009
   __resolv_conf_put.  */
Packit 6c4009
struct resolv_conf *__resolv_conf_allocate (const struct resolv_conf *init)
Packit 6c4009
  attribute_hidden __attribute__ ((nonnull (1), warn_unused_result));
Packit 6c4009
Packit 6c4009
/* Associate an existing extended resolver state with *RESP.  Return
Packit 6c4009
   false on allocation failure.  In addition, update *RESP with the
Packit 6c4009
   overlapping non-extended resolver state.  */
Packit 6c4009
bool __resolv_conf_attach (struct __res_state *, struct resolv_conf *)
Packit 6c4009
  attribute_hidden;
Packit 6c4009
Packit 6c4009
/* Detach the extended resolver state from *RESP.  */
Packit 6c4009
void __resolv_conf_detach (struct __res_state *resp) attribute_hidden;
Packit 6c4009
Packit 6c4009
#endif /* RESOLV_STATE_H */