about summary refs log tree commit diff
path: root/inet
diff options
context:
space:
mode:
authorArjun Shankar <arjun@redhat.com>2023-10-02 14:55:21 +0200
committerArjun Shankar <arjun@redhat.com>2023-10-24 12:30:59 +0200
commita7e8d0b90bc400b4d57afb01c1a54236a5c4754c (patch)
treedf1fff59376ea497ed6f95d6c2a86eae8cb693ec /inet
parent1c40266328babd3613d0fc7928449a7b53d87c73 (diff)
downloadglibc-a7e8d0b90bc400b4d57afb01c1a54236a5c4754c.tar.gz
glibc-a7e8d0b90bc400b4d57afb01c1a54236a5c4754c.tar.xz
glibc-a7e8d0b90bc400b4d57afb01c1a54236a5c4754c.zip
Move 'hosts' routines from 'inet' into 'nss'
The gethostby* and gethostent* routines are entry points for nss
functionality.  This commit moves them from the 'inet' subdirectory to
'nss'.
Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>
Diffstat (limited to 'inet')
-rw-r--r--inet/Makefile17
-rw-r--r--inet/Versions4
-rw-r--r--inet/gethstbyad.c29
-rw-r--r--inet/gethstbyad_r.c50
-rw-r--r--inet/gethstbynm.c36
-rw-r--r--inet/gethstbynm2.c37
-rw-r--r--inet/gethstbynm2_r.c44
-rw-r--r--inet/gethstbynm_r.c43
-rw-r--r--inet/gethstent.c26
-rw-r--r--inet/gethstent_r.c34
-rw-r--r--inet/tst-gethnm.c67
11 files changed, 1 insertions, 386 deletions
diff --git a/inet/Makefile b/inet/Makefile
index 4d053de748..d378542549 100644
--- a/inet/Makefile
+++ b/inet/Makefile
@@ -46,14 +46,6 @@ routines := \
   ether_line \
   ether_ntoa \
   ether_ntoa_r \
-  gethstbyad \
-  gethstbyad_r \
-  gethstbynm \
-  gethstbynm2 \
-  gethstbynm2_r \
-  gethstbynm_r \
-  gethstent \
-  gethstent_r \
   getipv4sourcefilter \
   getnameinfo \
   getnetbyad \
@@ -123,7 +115,6 @@ tests := \
   tst-checks-posix \
   tst-ether_aton \
   tst-ether_line \
-  tst-gethnm \
   tst-getni1 \
   tst-getni2 \
   tst-if_index-long \
@@ -154,14 +145,6 @@ include ../gen-locales.mk
 
 ifeq ($(have-thread-library),yes)
 
-CFLAGS-gethstbyad_r.c += -fexceptions
-CFLAGS-gethstbyad.c += -fexceptions
-CFLAGS-gethstbynm_r.c += -fexceptions
-CFLAGS-gethstbynm.c += -fexceptions
-CFLAGS-gethstbynm2_r.c += -fexceptions
-CFLAGS-gethstbynm2.c += -fexceptions
-CFLAGS-gethstent_r.c += -fexceptions
-CFLAGS-gethstent.c += -fexceptions
 CFLAGS-rcmd.c += -fexceptions
 CFLAGS-getnetbynm_r.c += -fexceptions
 CFLAGS-getnetbynm.c += -fexceptions
diff --git a/inet/Versions b/inet/Versions
index a7c1a0fb6f..d937e9835c 100644
--- a/inet/Versions
+++ b/inet/Versions
@@ -14,9 +14,7 @@ libc {
     ether_ntoa_r;
 
     # g*
-    getdomainname; gethostbyaddr; gethostbyaddr_r; gethostbyname;
-    gethostbyname2; gethostbyname2_r; gethostbyname_r; gethostent;
-    gethostent_r; getnetbyaddr; getnetbyaddr_r; getnetbyname;
+    getdomainname; getnetbyaddr; getnetbyaddr_r; getnetbyname;
     getnetbyname_r; getnetent; getnetent_r; getnetgrent; getnetgrent_r;
     getprotobyname; getprotobyname_r; getprotobynumber;
     getprotobynumber_r; getprotoent; getprotoent_r;
diff --git a/inet/gethstbyad.c b/inet/gethstbyad.c
deleted file mode 100644
index 1b0fc982e4..0000000000
--- a/inet/gethstbyad.c
+++ /dev/null
@@ -1,29 +0,0 @@
-/* Copyright (C) 1996-2023 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/>.  */
-
-#include <netdb.h>
-
-
-#define LOOKUP_TYPE	struct hostent
-#define FUNCTION_NAME	gethostbyaddr
-#define DATABASE_NAME	hosts
-#define ADD_PARAMS	const void *addr, socklen_t len, int type
-#define ADD_VARIABLES	addr, len, type
-#define BUFLEN		1024
-#define NEED_H_ERRNO	1
-
-#include "../nss/getXXbyYY.c"
diff --git a/inet/gethstbyad_r.c b/inet/gethstbyad_r.c
deleted file mode 100644
index ee1b1d12ee..0000000000
--- a/inet/gethstbyad_r.c
+++ /dev/null
@@ -1,50 +0,0 @@
-/* Copyright (C) 1996-2023 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/>.  */
-
-#include <netdb.h>
-#include <string.h>
-#include <resolv/res_hconf.h>
-
-#define LOOKUP_TYPE	struct hostent
-#define FUNCTION_NAME	gethostbyaddr
-#define DATABASE_NAME	hosts
-#define ADD_PARAMS	const void *addr, socklen_t len, int type
-#define ADD_VARIABLES	addr, len, type
-#define NEED_H_ERRNO	1
-#define NEED__RES	1
-/* If the addr parameter is the IPv6 unspecified address no query must
-   be performed.  */
-#define PREPROCESS \
-  if (len == sizeof (struct in6_addr)					      \
-      && __builtin_expect (memcmp (&__in6addr_any, addr,		      \
-				   sizeof (struct in6_addr)), 1) == 0)	      \
-    {									      \
-      *h_errnop = HOST_NOT_FOUND;					      \
-      *result = NULL;							      \
-      return ENOENT;							      \
-    }
-#define POSTPROCESS \
-  if (status == NSS_STATUS_SUCCESS)					      \
-    {									      \
-      _res_hconf_reorder_addrs (resbuf);				      \
-      _res_hconf_trim_domains (resbuf);					      \
-    }
-
-/* Special name for the lookup function.  */
-#define DB_LOOKUP_FCT __nss_hosts_lookup2
-
-#include "../nss/getXXbyYY_r.c"
diff --git a/inet/gethstbynm.c b/inet/gethstbynm.c
deleted file mode 100644
index 6134dec455..0000000000
--- a/inet/gethstbynm.c
+++ /dev/null
@@ -1,36 +0,0 @@
-/* Copyright (C) 1996-2023 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/>.  */
-
-#include <ctype.h>
-#include <errno.h>
-#include <netdb.h>
-#include <string.h>
-#include <arpa/inet.h>
-#include <netinet/in.h>
-
-
-#define LOOKUP_TYPE	struct hostent
-#define FUNCTION_NAME	gethostbyname
-#define DATABASE_NAME	hosts
-#define ADD_PARAMS	const char *name
-#define ADD_VARIABLES	name
-#define BUFLEN		1024
-#define NEED_H_ERRNO	1
-
-#define HANDLE_DIGITS_DOTS	1
-
-#include <nss/getXXbyYY.c>
diff --git a/inet/gethstbynm2.c b/inet/gethstbynm2.c
deleted file mode 100644
index 6d1421b06a..0000000000
--- a/inet/gethstbynm2.c
+++ /dev/null
@@ -1,37 +0,0 @@
-/* Copyright (C) 1996-2023 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/>.  */
-
-#include <ctype.h>
-#include <errno.h>
-#include <netdb.h>
-#include <string.h>
-#include <arpa/inet.h>
-#include <netinet/in.h>
-
-
-#define LOOKUP_TYPE	struct hostent
-#define FUNCTION_NAME	gethostbyname2
-#define DATABASE_NAME	hosts
-#define ADD_PARAMS	const char *name, int af
-#define ADD_VARIABLES	name, af
-#define BUFLEN		1024
-#define NEED_H_ERRNO	1
-
-#define HANDLE_DIGITS_DOTS	1
-#define HAVE_AF			1
-
-#include "../nss/getXXbyYY.c"
diff --git a/inet/gethstbynm2_r.c b/inet/gethstbynm2_r.c
deleted file mode 100644
index e0c373513d..0000000000
--- a/inet/gethstbynm2_r.c
+++ /dev/null
@@ -1,44 +0,0 @@
-/* Copyright (C) 1996-2023 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/>.  */
-
-#include <ctype.h>
-#include <errno.h>
-#include <netdb.h>
-#include <string.h>
-#include <arpa/inet.h>
-#include <netinet/in.h>
-#include <resolv/res_hconf.h>
-
-#define LOOKUP_TYPE	struct hostent
-#define FUNCTION_NAME	gethostbyname2
-#define DATABASE_NAME	hosts
-#define ADD_PARAMS	const char *name, int af
-#define ADD_VARIABLES	name, af
-#define NEED_H_ERRNO	1
-#define NEED__RES	1
-#define POSTPROCESS \
-  if (status == NSS_STATUS_SUCCESS)					      \
-    _res_hconf_reorder_addrs (resbuf);
-
-#define HANDLE_DIGITS_DOTS	1
-#define HAVE_LOOKUP_BUFFER	1
-#define HAVE_AF			1
-
-/* Special name for the lookup function.  */
-#define DB_LOOKUP_FCT __nss_hosts_lookup2
-
-#include "../nss/getXXbyYY_r.c"
diff --git a/inet/gethstbynm_r.c b/inet/gethstbynm_r.c
deleted file mode 100644
index c224673544..0000000000
--- a/inet/gethstbynm_r.c
+++ /dev/null
@@ -1,43 +0,0 @@
-/* Copyright (C) 1996-2023 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/>.  */
-
-#include <ctype.h>
-#include <errno.h>
-#include <netdb.h>
-#include <string.h>
-#include <arpa/inet.h>
-#include <netinet/in.h>
-#include <resolv/res_hconf.h>
-
-#define LOOKUP_TYPE	struct hostent
-#define FUNCTION_NAME	gethostbyname
-#define DATABASE_NAME	hosts
-#define ADD_PARAMS	const char *name
-#define ADD_VARIABLES	name
-#define NEED_H_ERRNO	1
-#define NEED__RES	1
-#define POSTPROCESS \
-  if (status == NSS_STATUS_SUCCESS)					      \
-    _res_hconf_reorder_addrs (resbuf);
-
-#define HANDLE_DIGITS_DOTS	1
-#define HAVE_LOOKUP_BUFFER	1
-
-/* Special name for the lookup function.  */
-#define DB_LOOKUP_FCT __nss_hosts_lookup2
-
-#include "../nss/getXXbyYY_r.c"
diff --git a/inet/gethstent.c b/inet/gethstent.c
deleted file mode 100644
index 2bfe27443d..0000000000
--- a/inet/gethstent.c
+++ /dev/null
@@ -1,26 +0,0 @@
-/* Copyright (C) 1996-2023 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/>.  */
-
-#include <netdb.h>
-
-
-#define LOOKUP_TYPE	struct hostent
-#define	GETFUNC_NAME	gethostent
-#define BUFLEN		1024
-#define NEED_H_ERRNO	1
-
-#include "../nss/getXXent.c"
diff --git a/inet/gethstent_r.c b/inet/gethstent_r.c
deleted file mode 100644
index 00957fc1c1..0000000000
--- a/inet/gethstent_r.c
+++ /dev/null
@@ -1,34 +0,0 @@
-/* Copyright (C) 1996-2023 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/>.  */
-
-#include <netdb.h>
-
-
-#define LOOKUP_TYPE	struct hostent
-#define SETFUNC_NAME	sethostent
-#define	GETFUNC_NAME	gethostent
-#define	ENDFUNC_NAME	endhostent
-#define DATABASE_NAME	hosts
-#define STAYOPEN	int stayopen
-#define STAYOPEN_VAR	stayopen
-#define NEED_H_ERRNO	1
-#define NEED__RES	1
-
-/* Special name for the lookup function.  */
-#define DB_LOOKUP_FCT __nss_hosts_lookup2
-
-#include "../nss/getXXent_r.c"
diff --git a/inet/tst-gethnm.c b/inet/tst-gethnm.c
deleted file mode 100644
index dd3a547811..0000000000
--- a/inet/tst-gethnm.c
+++ /dev/null
@@ -1,67 +0,0 @@
-/* Based on a test case by grd@algonet.se.  */
-
-#include <netdb.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-#include <unistd.h>
-#include <sys/param.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
-
-static int
-do_test (void)
-{
-  struct hostent *ent;
-  struct in_addr hostaddr;
-  int result = 0;
-
-  inet_aton ("127.0.0.1", (struct in_addr *) &hostaddr.s_addr);
-  ent = gethostbyaddr (&hostaddr, sizeof (hostaddr), AF_INET);
-  if (ent == NULL)
-    puts ("gethostbyaddr (...) == NULL");
-  else
-    {
-      puts ("Using gethostbyaddr(..):");
-      printf ("h_name: %s\n", ent->h_name);
-
-      if (ent->h_aliases == NULL)
-	puts ("ent->h_aliases == NULL");
-      else
-	printf ("h_aliases[0]: %s\n", ent->h_aliases[0]);
-    }
-
-  ent = gethostbyname ("127.0.0.1");
-  if (ent == NULL)
-    {
-      puts ("gethostbyname (\"127.0.0.1\") == NULL");
-      result = 1;
-    }
-  else
-    {
-      printf ("\nNow using gethostbyname(..):\n");
-      printf ("h_name: %s\n", ent->h_name);
-      if (strcmp (ent->h_name, "127.0.0.1") != 0)
-	{
-	  puts ("ent->h_name != \"127.0.0.1\"");
-	  result = 1;
-	}
-
-      if (ent->h_aliases == NULL)
-	{
-	  puts ("ent->h_aliases == NULL");
-	  result = 1;
-	}
-      else
-	{
-	  printf ("h_aliases[0]: %s\n", ent->h_aliases[0]);
-	  result |= ent->h_aliases[0] != NULL;
-	}
-    }
-
-  return result;
-}
-
-#define TEST_FUNCTION do_test ()
-#include "../test-skeleton.c"