summaryrefslogtreecommitdiff
path: root/usr/src/head/nss_netdir.h
blob: 9ab072fe2a7e61ad3a3608e6d2e34482e31029f7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License (the "License").
 * You may not use this file except in compliance with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */
/*
 * Copyright 2014 Garrett D'Amore <garrett@damore.org>
 *
 * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
 * Use is subject to license terms.
 */

/*
 * nss_netdir.h
 *
 * Defines structures that are shared between the OSNET-private
 * _get_hostserv_inetnetdir_byYY() interfaces and the public
 * interfaces gethostbyYY()/getservbyYY() and netdir_getbyYY().
 * Ideally, this header file should never be visible to developers
 * outside of the OSNET build.
 */

#ifndef _NSS_NETDIR_H
#define	_NSS_NETDIR_H

#ifdef	__cplusplus
extern "C" {
#endif

typedef enum {
	NSS_HOST,
	NSS_SERV,
	NETDIR_BY,
	NETDIR_BY_NOSRV,		/* bypass service lookup */
	NETDIR_BY6,
	NETDIR_BY_NOSRV6,		/* bypass service lookup */
	NSS_HOST6
} nss_netdir_op_t;

struct nss_netdirbyname_in {
	nss_netdir_op_t	op_t;
	union {
		struct nd_hostserv *nd_hs;
		union {
			struct {
				const char	*name;
				char	*buf;
				int	buflen;
			} host;
			struct {
				const char	*name;
				char	*buf;
				int	buflen;
				int	af_family;	/* for ipnode */
				int	flags;		/* for ipnode */
			} host6;
			struct {
				const char	*name;
				const char	*proto;
				char	*buf;
				int	buflen;
			} serv;
		} nss;
	} arg;
};

union nss_netdirbyname_out {
	struct nd_addrlist **nd_alist;
	union {
		struct {
			struct hostent *hent;
			int	*herrno_p;
		} host;
		struct servent *serv;
	} nss;
};

struct nss_netdirbyaddr_in {
	nss_netdir_op_t	op_t;
	union {
		struct netbuf *nd_nbuf;
		union {
			struct {
				const char	*addr;
				int	len;
				int	type;
				char	*buf;
				int	buflen;
			} host;
			struct {
				int	port;
				const char	*proto;
				char	*buf;
				int	buflen;
			} serv;
		} nss;
	} arg;
};

union nss_netdirbyaddr_out {
	struct nd_hostservlist **nd_hslist;
	union {
		struct {
			struct hostent *hent;
			int	*herrno_p;
		} host;
		struct servent *serv;
	} nss;
};

int __classic_netdir_getbyname(struct netconfig *,
		struct nd_hostserv *, struct nd_addrlist **);
int __classic_netdir_getbyaddr(struct netconfig *,
		struct nd_hostservlist **, struct netbuf *);
int _get_hostserv_inetnetdir_byname(struct netconfig *,
		struct nss_netdirbyname_in *, union nss_netdirbyname_out *);
int _get_hostserv_inetnetdir_byaddr(struct netconfig *,
		struct nss_netdirbyaddr_in *, union nss_netdirbyaddr_out *);
int __inet_netdir_options(struct netconfig *,
		int option, int fd, char *par);
struct netbuf *__inet_uaddr2taddr(struct netconfig *, char *);
char *__inet_taddr2uaddr(struct netconfig *, struct netbuf *);

#ifdef	__cplusplus
}
#endif

#endif /* _NSS_NETDIR_H */