2016-02-13 08:27:50 +00:00
|
|
|
/*
|
|
|
|
* libvirt_nss: Name Service Switch plugin
|
|
|
|
*
|
|
|
|
* The aim is to enable users and applications to translate
|
|
|
|
* domain names into IP addresses. However, this is currently
|
|
|
|
* available only for those domains which gets their IP addresses
|
|
|
|
* from a libvirt managed network.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2016 Red Hat, Inc.
|
|
|
|
*
|
|
|
|
* This 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.
|
|
|
|
*
|
|
|
|
* This 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 this library. If not, see
|
|
|
|
* <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2019-06-18 16:13:15 +00:00
|
|
|
#pragma once
|
2016-02-13 08:27:50 +00:00
|
|
|
|
2019-06-18 16:13:15 +00:00
|
|
|
#include <nss.h>
|
2019-08-08 14:14:03 +00:00
|
|
|
#include <sys/socket.h>
|
|
|
|
#include <netinet/in.h>
|
2019-06-18 16:13:15 +00:00
|
|
|
#include <netdb.h>
|
2016-02-13 08:27:50 +00:00
|
|
|
|
2019-07-31 09:40:39 +00:00
|
|
|
|
|
|
|
#if 0
|
2019-07-31 13:35:34 +00:00
|
|
|
# include <errno.h>
|
2019-08-09 08:32:15 +00:00
|
|
|
# include <stdio.h>
|
|
|
|
# define NULLSTR(s) ((s) ? (s) : "<null>")
|
2019-07-31 09:40:39 +00:00
|
|
|
# define ERROR(...) \
|
|
|
|
do { \
|
2024-04-18 07:25:07 +00:00
|
|
|
char ebuf[512]; \
|
|
|
|
const char *errmsg = strerror_r(errno, ebuf, sizeof(ebuf)); \
|
2019-07-31 09:40:39 +00:00
|
|
|
fprintf(stderr, "ERROR %s:%d : ", __FUNCTION__, __LINE__); \
|
|
|
|
fprintf(stderr, __VA_ARGS__); \
|
2024-04-18 07:25:07 +00:00
|
|
|
fprintf(stderr, " : %s\n", errmsg); \
|
2019-07-31 09:40:39 +00:00
|
|
|
fprintf(stderr, "\n"); \
|
|
|
|
} while (0)
|
|
|
|
|
|
|
|
# define DEBUG(...) \
|
|
|
|
do { \
|
|
|
|
fprintf(stderr, "DEBUG %s:%d : ", __FUNCTION__, __LINE__); \
|
|
|
|
fprintf(stderr, __VA_ARGS__); \
|
|
|
|
fprintf(stderr, "\n"); \
|
|
|
|
} while (0)
|
|
|
|
#else
|
|
|
|
# define ERROR(...) do { } while (0)
|
|
|
|
# define DEBUG(...) do { } while (0)
|
|
|
|
#endif
|
|
|
|
|
2019-06-18 16:13:15 +00:00
|
|
|
#if !defined(LIBVIRT_NSS_GUEST)
|
|
|
|
# define NSS_NAME(s) _nss_libvirt_##s##_r
|
|
|
|
#else
|
|
|
|
# define NSS_NAME(s) _nss_libvirt_guest_##s##_r
|
|
|
|
#endif
|
2016-12-04 10:56:44 +00:00
|
|
|
|
2016-02-14 10:38:37 +00:00
|
|
|
enum nss_status
|
2016-12-04 10:56:44 +00:00
|
|
|
NSS_NAME(gethostbyname)(const char *name, struct hostent *result,
|
|
|
|
char *buffer, size_t buflen, int *errnop,
|
|
|
|
int *herrnop);
|
2016-02-14 10:38:37 +00:00
|
|
|
|
|
|
|
enum nss_status
|
2016-12-04 10:56:44 +00:00
|
|
|
NSS_NAME(gethostbyname2)(const char *name, int af, struct hostent *result,
|
|
|
|
char *buffer, size_t buflen, int *errnop,
|
|
|
|
int *herrnop);
|
2019-07-16 10:05:27 +00:00
|
|
|
|
2016-02-14 10:38:37 +00:00
|
|
|
enum nss_status
|
2016-12-04 10:56:44 +00:00
|
|
|
NSS_NAME(gethostbyname3)(const char *name, int af, struct hostent *result,
|
|
|
|
char *buffer, size_t buflen, int *errnop,
|
|
|
|
int *herrnop, int32_t *ttlp, char **canonp);
|
2019-07-16 10:05:27 +00:00
|
|
|
|
2020-09-01 11:27:44 +00:00
|
|
|
#ifdef WITH_STRUCT_GAIH_ADDRTUPLE
|
2016-02-14 07:13:54 +00:00
|
|
|
enum nss_status
|
2016-12-04 10:56:44 +00:00
|
|
|
NSS_NAME(gethostbyname4)(const char *name, struct gaih_addrtuple **pat,
|
|
|
|
char *buffer, size_t buflen, int *errnop,
|
|
|
|
int *herrnop, int32_t *ttlp);
|
2020-09-01 11:27:44 +00:00
|
|
|
#endif /* WITH_STRUCT_GAIH_ADDRTUPLE */
|
2016-03-27 18:07:10 +00:00
|
|
|
|
2020-09-01 09:19:26 +00:00
|
|
|
#if defined(WITH_BSD_NSS)
|
2016-03-27 18:07:10 +00:00
|
|
|
ns_mtab*
|
|
|
|
nss_module_register(const char *name, unsigned int *size,
|
|
|
|
nss_module_unregister_fn *unregister);
|
2020-09-01 09:19:26 +00:00
|
|
|
#endif /* WITH_BSD_NSS */
|