xref: /illumos-gate/usr/src/lib/nsswitch/mdns/common/mdns_common.h (revision 201ceb75ab95f9bf1f42ea1dc9ab363b43ba47cf)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 
22 /*
23  * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #ifndef _MDNS_COMMON_H
28 #define	_MDNS_COMMON_H
29 
30 #include <stdio.h>
31 #include <ctype.h>
32 #include <sys/types.h>
33 #include <sys/socket.h>
34 #include <netdb.h>
35 #include <strings.h>
36 #include <syslog.h>
37 #include <sys/time.h>
38 #include <sys/select.h>
39 #include <netinet/in.h>
40 #include <arpa/inet.h>
41 #include <arpa/nameser.h>
42 #include <nsswitch.h>
43 #include <nss_common.h>
44 #include <nss_dbdefs.h>
45 #include <stdlib.h>
46 #include <signal.h>
47 #include <libscf.h>
48 #include <dns_sd.h>
49 
50 #ifdef	__cplusplus
51 extern "C" {
52 #endif
53 
54 #define	NSSMDNS_MAXQRYTMO	1
55 #define	NSSMDNS_MAXSRCHDMNS	6
56 #define	NSSMDNS_MAXVALIDDMNS	10
57 
58 #define	SMF_MDNS_FMRI "svc:/network/dns/multicast:default"
59 #define	SMF_NSSMDNSCFG_PROPGRP "nss_mdns_config"
60 #define	SMF_NSSMDNSCFG_SRCHPROP "search"
61 #define	SMF_NSSMDNSCFG_DMNPROP "domain"
62 
63 typedef struct mdns_backend *mdns_backend_ptr_t;
64 typedef nss_status_t (*mdns_backend_op_t)(mdns_backend_ptr_t, void *);
65 
66 struct mdns_backend {
67 	mdns_backend_op_t	*ops;
68 	nss_dbop_t		n_ops;
69 	char *dmnsrchlist[NSSMDNS_MAXSRCHDMNS];
70 	char *validdmnlist[NSSMDNS_MAXVALIDDMNS];
71 	struct timeval conftimestamp;
72 };
73 
74 struct mdns_querydata {
75 	nss_XbyY_args_t *argp;
76 	char *buffer;
77 	int buflen;
78 	int ttl;
79 	boolean_t qrydone;
80 	int status;
81 	int af;
82 	char paddrbuf[INET6_ADDRSTRLEN + 1];
83 	int withttlbsize;
84 	char *withttlbuffer;
85 };
86 
87 nss_backend_t *_nss_mdns_constr(mdns_backend_op_t *, int);
88 void _nss_mdns_destr(mdns_backend_ptr_t);
89 int _nss_mdns_querybyname(mdns_backend_ptr_t, char *name,
90 		int af, struct mdns_querydata *data);
91 int _nss_mdns_querybyaddr(mdns_backend_ptr_t, char *name,
92 		int af, struct mdns_querydata *data);
93 void _nss_mdns_updatecfg(mdns_backend_ptr_t);
94 
95 nss_status_t _nss_mdns_gethost_withttl(void *buf, size_t bufsize, int ipnode);
96 nss_status_t _nss_get_mdns_hosts_name(mdns_backend_ptr_t *be,
97 		void **bufp, size_t *sizep);
98 nss_status_t _nss_get_mdns_ipnodes_name(mdns_backend_ptr_t *be,
99 		void **bufp, size_t *sizep);
100 
101 #ifdef	__cplusplus
102 }
103 #endif
104 
105 #endif /* _MDNS_COMMON_H */
106