]> git.ipfire.org Git - thirdparty/systemd.git/blame - src/shared/nss-util.h
Merge pull request #531 from dvdhrm/boot-buildid
[thirdparty/systemd.git] / src / shared / nss-util.h
CommitLineData
c9fdc26e
LP
1/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
2
3#pragma once
4
5/***
6 This file is part of systemd.
7
8 Copyright 2014 Lennart Poettering
9
10 systemd is free software; you can redistribute it and/or modify it
11 under the terms of the GNU Lesser General Public License as published by
12 the Free Software Foundation; either version 2.1 of the License, or
13 (at your option) any later version.
14
15 systemd is distributed in the hope that it will be useful, but
16 WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 Lesser General Public License for more details.
19
20 You should have received a copy of the GNU Lesser General Public License
21 along with systemd; If not, see <http://www.gnu.org/licenses/>.
22***/
23
24#include <nss.h>
25#include <netdb.h>
ea30eb86 26#include <resolv.h>
c9fdc26e
LP
27
28#define NSS_GETHOSTBYNAME_PROTOTYPES(module) \
29enum nss_status _nss_##module##_gethostbyname4_r( \
30 const char *name, \
31 struct gaih_addrtuple **pat, \
32 char *buffer, size_t buflen, \
33 int *errnop, int *h_errnop, \
34 int32_t *ttlp) _public_; \
35enum nss_status _nss_##module##_gethostbyname3_r( \
36 const char *name, \
37 int af, \
38 struct hostent *host, \
39 char *buffer, size_t buflen, \
40 int *errnop, int *h_errnop, \
41 int32_t *ttlp, \
42 char **canonp) _public_; \
43enum nss_status _nss_##module##_gethostbyname2_r( \
44 const char *name, \
45 int af, \
46 struct hostent *host, \
47 char *buffer, size_t buflen, \
48 int *errnop, int *h_errnop) _public_; \
49enum nss_status _nss_##module##_gethostbyname_r( \
50 const char *name, \
51 struct hostent *host, \
52 char *buffer, size_t buflen, \
53 int *errnop, int *h_errnop) _public_
54
55#define NSS_GETHOSTBYADDR_PROTOTYPES(module) \
56enum nss_status _nss_##module##_gethostbyaddr2_r( \
57 const void* addr, socklen_t len, \
58 int af, \
59 struct hostent *host, \
60 char *buffer, size_t buflen, \
61 int *errnop, int *h_errnop, \
62 int32_t *ttlp) _public_; \
63enum nss_status _nss_##module##_gethostbyaddr_r( \
64 const void* addr, socklen_t len, \
65 int af, \
66 struct hostent *host, \
67 char *buffer, size_t buflen, \
68 int *errnop, int *h_errnop) _public_
69
70#define NSS_GETHOSTBYNAME_FALLBACKS(module) \
71enum nss_status _nss_##module##_gethostbyname2_r( \
72 const char *name, \
73 int af, \
74 struct hostent *host, \
75 char *buffer, size_t buflen, \
76 int *errnop, int *h_errnop) { \
77 return _nss_##module##_gethostbyname3_r( \
78 name, \
79 af, \
80 host, \
81 buffer, buflen, \
82 errnop, h_errnop, \
83 NULL, \
84 NULL); \
85} \
86enum nss_status _nss_##module##_gethostbyname_r( \
87 const char *name, \
88 struct hostent *host, \
89 char *buffer, size_t buflen, \
90 int *errnop, int *h_errnop) { \
ea30eb86
LP
91 enum nss_status ret = NSS_STATUS_NOTFOUND; \
92 \
93 if (_res.options & RES_USE_INET6) \
94 ret = _nss_##module##_gethostbyname3_r( \
95 name, \
96 AF_INET6, \
97 host, \
98 buffer, buflen, \
99 errnop, h_errnop, \
100 NULL, \
101 NULL); \
102 if (ret == NSS_STATUS_NOTFOUND) \
103 ret = _nss_##module##_gethostbyname3_r( \
c9fdc26e 104 name, \
ea30eb86 105 AF_INET, \
c9fdc26e
LP
106 host, \
107 buffer, buflen, \
108 errnop, h_errnop, \
109 NULL, \
110 NULL); \
ea30eb86 111 return ret; \
c9fdc26e
LP
112}
113
114#define NSS_GETHOSTBYADDR_FALLBACKS(module) \
115enum nss_status _nss_##module##_gethostbyaddr_r( \
116 const void* addr, socklen_t len, \
117 int af, \
118 struct hostent *host, \
119 char *buffer, size_t buflen, \
120 int *errnop, int *h_errnop) { \
121 return _nss_##module##_gethostbyaddr2_r( \
122 addr, len, \
123 af, \
124 host, \
125 buffer, buflen, \
126 errnop, h_errnop, \
127 NULL); \
128}