--- /dev/null
+/* Internal routines for nss_dns.
+ Copyright (C) 2021 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <https://www.gnu.org/licenses/>. */
+
+#ifndef _NSS_DNS_H
+#define _NSS_DNS_H
+
+#include <nss.h>
+
+NSS_DECLARE_MODULE_FUNCTIONS (dns)
+
+libc_hidden_proto (_nss_dns_getcanonname_r)
+libc_hidden_proto (_nss_dns_gethostbyname3_r)
+libc_hidden_proto (_nss_dns_gethostbyname2_r)
+libc_hidden_proto (_nss_dns_gethostbyname_r)
+libc_hidden_proto (_nss_dns_gethostbyname4_r)
+libc_hidden_proto (_nss_dns_gethostbyaddr2_r)
+libc_hidden_proto (_nss_dns_gethostbyaddr_r)
+libc_hidden_proto (_nss_dns_getnetbyname_r)
+libc_hidden_proto (_nss_dns_getnetbyaddr_r)
+
+#endif
__resolv_context_get_preinit;
__resolv_context_put;
__resp;
+ _nss_dns_getcanonname_r;
+ _nss_dns_gethostbyaddr2_r;
+ _nss_dns_gethostbyaddr_r;
+ _nss_dns_gethostbyname2_r;
+ _nss_dns_gethostbyname3_r;
+ _nss_dns_gethostbyname4_r;
+ _nss_dns_gethostbyname_r;
+ _nss_dns_getnetbyaddr_r;
+ _nss_dns_getnetbyname_r;
}
}
libnss_dns {
GLIBC_PRIVATE {
- _nss_dns_getcanonname_r;
- _nss_dns_gethostbyaddr2_r;
- _nss_dns_gethostbyaddr_r;
- _nss_dns_gethostbyname2_r;
- _nss_dns_gethostbyname3_r;
- _nss_dns_gethostbyname4_r;
- _nss_dns_gethostbyname_r;
- _nss_dns_getnetbyaddr_r;
- _nss_dns_getnetbyname_r;
+ # Keep a version node (with a synthesized local: * directive) so that
+ # __bss_* symbols are hidden on targets that need it.
+ __libnss_dns_version_placeholder;
}
}
#include "nsswitch.h"
#include <arpa/nameser.h>
+#include <nss_dns.h>
#include <resolv/resolv-internal.h>
#include <resolv/resolv_context.h>
#include <resolv/mapv4v6addr.h>
#include <resolv/mapv4v6hostent.h>
-NSS_DECLARE_MODULE_FUNCTIONS (dns)
-
#define RESOLVSORT
#if PACKETSZ > 65536
__resolv_context_put (ctx);
return status;
}
+libc_hidden_def (_nss_dns_gethostbyname3_r)
static enum nss_status
gethostbyname3_context (struct resolv_context *ctx,
static enum nss_status
check_name (const char *name, int *h_errnop)
{
- if (res_hnok (name))
+ if (__libc_res_hnok (name))
return NSS_STATUS_SUCCESS;
*h_errnop = HOST_NOT_FOUND;
return NSS_STATUS_NOTFOUND;
return _nss_dns_gethostbyname3_r (name, af, result, buffer, buflen, errnop,
h_errnop, NULL, NULL);
}
-
+libc_hidden_def (_nss_dns_gethostbyname2_r)
enum nss_status
_nss_dns_gethostbyname_r (const char *name, struct hostent *result,
__resolv_context_put (ctx);
return status;
}
-
+libc_hidden_def (_nss_dns_gethostbyname_r)
enum nss_status
_nss_dns_gethostbyname4_r (const char *name, struct gaih_addrtuple **pat,
__resolv_context_put (ctx);
return status;
}
-
-
-extern enum nss_status _nss_dns_gethostbyaddr2_r (const void *addr,
- socklen_t len, int af,
- struct hostent *result,
- char *buffer, size_t buflen,
- int *errnop, int *h_errnop,
- int32_t *ttlp);
-hidden_proto (_nss_dns_gethostbyaddr2_r)
+libc_hidden_def (_nss_dns_gethostbyname4_r)
enum nss_status
_nss_dns_gethostbyaddr2_r (const void *addr, socklen_t len, int af,
__resolv_context_put (ctx);
return NSS_STATUS_SUCCESS;
}
-hidden_def (_nss_dns_gethostbyaddr2_r)
+libc_hidden_def (_nss_dns_gethostbyaddr2_r)
enum nss_status
return _nss_dns_gethostbyaddr2_r (addr, len, af, result, buffer, buflen,
errnop, h_errnop, NULL);
}
+libc_hidden_def (_nss_dns_gethostbyaddr_r)
static void
addrsort (struct resolv_context *ctx, char **ap, int num)
{
case T_A:
case T_AAAA:
- name_ok = res_hnok;
+ name_ok = __libc_res_hnok;
break;
case T_PTR:
- name_ok = res_dnok;
+ name_ok = __libc_res_dnok;
break;
default:
*errnop = ENOENT;
if (ap >= &host_data->aliases[MAX_NR_ALIASES - 1])
continue;
- n = dn_expand (answer->buf, end_of_message, cp, tbuf, sizeof tbuf);
+ n = __libc_dn_expand (answer->buf, end_of_message, cp,
+ tbuf, sizeof tbuf);
if (__glibc_unlikely (n < 0 || (*name_ok) (tbuf) == 0))
{
++had_error;
if (ttlp != NULL && ttl < *ttlp)
*ttlp = ttl;
- n = dn_expand (answer->buf, end_of_message, cp, tbuf, sizeof tbuf);
- if (__glibc_unlikely (n < 0 || res_dnok (tbuf) == 0))
+ n = __libc_dn_expand (answer->buf, end_of_message, cp,
+ tbuf, sizeof tbuf);
+ if (__glibc_unlikely (n < 0 || __libc_res_dnok (tbuf) == 0))
{
++had_error;
continue;
switch (type)
{
case T_PTR:
- if (__glibc_unlikely (strcasecmp (tname, bp) != 0))
+ if (__glibc_unlikely (__strcasecmp (tname, bp) != 0))
{
cp += n;
continue; /* XXX - had_error++ ? */
n = -1;
}
- if (__glibc_unlikely (n < 0 || res_hnok (bp) == 0))
+ if (__glibc_unlikely (n < 0 || __libc_res_hnok (bp) == 0))
{
++had_error;
break;
return NSS_STATUS_SUCCESS;
case T_A:
case T_AAAA:
- if (__glibc_unlikely (strcasecmp (result->h_name, bp) != 0))
+ if (__glibc_unlikely (__strcasecmp (result->h_name, bp) != 0))
{
cp += n;
continue; /* XXX - had_error++ ? */
*h_errnop = NO_RECOVERY;
return NSS_STATUS_UNAVAIL;
}
- if (__glibc_unlikely (res_hnok (buffer) == 0))
+ if (__glibc_unlikely (__libc_res_hnok (buffer) == 0))
{
errno = EBADMSG;
*errnop = EBADMSG;
n = -1;
}
- if (__glibc_unlikely (n < 0 || res_hnok (buffer) == 0))
+ if (__glibc_unlikely (n < 0 || __libc_res_hnok (buffer) == 0))
{
++had_error;
continue;
if (ttlp != NULL && ttl < *ttlp)
*ttlp = ttl;
- n = dn_expand (answer->buf, end_of_message, cp, tbuf, sizeof tbuf);
- if (__glibc_unlikely (n < 0 || res_hnok (tbuf) == 0))
+ n = __libc_dn_expand (answer->buf, end_of_message, cp,
+ tbuf, sizeof tbuf);
+ if (__glibc_unlikely (n < 0 || __libc_res_hnok (tbuf) == 0))
{
++had_error;
continue;
#include "nsswitch.h"
#include <arpa/inet.h>
#include <arpa/nameser.h>
+#include <nss_dns.h>
#include <resolv/resolv-internal.h>
#include <resolv/resolv_context.h>
-NSS_DECLARE_MODULE_FUNCTIONS (dns)
-
/* Maximum number of aliases we allow. */
#define MAX_NR_ALIASES 48
__resolv_context_put (ctx);
return status;
}
-
+libc_hidden_def (_nss_dns_getnetbyname_r)
enum nss_status
_nss_dns_getnetbyaddr_r (uint32_t net, int type, struct netent *result,
__resolv_context_put (ctx);
return status;
}
-
+libc_hidden_def (_nss_dns_getnetbyaddr_r)
static enum nss_status
getanswer_r (const querybuf *answer, int anslen, struct netent *result,
n = -1;
}
- if (n < 0 || res_dnok (bp) == 0)
+ if (n < 0 || __libc_res_dnok (bp) == 0)
break;
cp += n;
n = -1;
}
- if (n < 0 || !res_hnok (bp))
+ if (n < 0 || !__libc_res_hnok (bp))
{
/* XXX What does this mean? The original form from bind
returns NULL. Incrementing cp has no effect in any case.
/* If we are out of digits now, there are two cases:
1. We are done with digits and now see "in-addr.arpa".
2. This is not the droid we are looking for. */
- if (!isdigit (*p) && !strcasecmp (p, "in-addr.arpa"))
+ if (!isdigit (*p) && !__strcasecmp (p, "in-addr.arpa"))
{
result->n_net = val;
return NSS_STATUS_SUCCESS;