xref: /titanic_44/usr/src/lib/nsswitch/mdns/common/mdns_common.h (revision a38ddfee9c8c6b6c5a2947ff52fd2338362a4444)
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 #pragma ident	"%Z%%M%	%I%	%E% SMI"
28 
29 #ifndef _MDNS_COMMON_H
30 #define	_MDNS_COMMON_H
31 
32 #include <stdio.h>
33 #include <ctype.h>
34 #include <sys/types.h>
35 #include <sys/socket.h>
36 #include <netdb.h>
37 #include <strings.h>
38 #include <syslog.h>
39 #include <sys/time.h>
40 #include <sys/select.h>
41 #include <netinet/in.h>
42 #include <arpa/inet.h>
43 #include <arpa/nameser.h>
44 #include <nsswitch.h>
45 #include <nss_common.h>
46 #include <nss_dbdefs.h>
47 #include <stdlib.h>
48 #include <signal.h>
49 #include <libscf.h>
50 #include <dns_sd.h>
51 
52 #ifdef	__cplusplus
53 extern "C" {
54 #endif
55 
56 #define	NSSMDNS_MAXQRYTMO	1
57 #define	NSSMDNS_MAXSRCHDMNS	6
58 #define	NSSMDNS_MAXVALIDDMNS	10
59 
60 #define	SMF_MDNS_FMRI "svc:/network/dns/multicast:default"
61 #define	SMF_NSSMDNSCFG_PROPGRP "nss_mdns_config"
62 #define	SMF_NSSMDNSCFG_SRCHPROP "search"
63 #define	SMF_NSSMDNSCFG_DMNPROP "domain"
64 
65 typedef struct mdns_backend *mdns_backend_ptr_t;
66 typedef nss_status_t (*mdns_backend_op_t)(mdns_backend_ptr_t, void *);
67 
68 struct mdns_backend {
69 	mdns_backend_op_t	*ops;
70 	nss_dbop_t		n_ops;
71 	char *dmnsrchlist[NSSMDNS_MAXSRCHDMNS];
72 	char *validdmnlist[NSSMDNS_MAXVALIDDMNS];
73 	struct timeval conftimestamp;
74 };
75 
76 struct mdns_querydata {
77 	nss_XbyY_args_t *argp;
78 	char *buffer;
79 	int buflen;
80 	int ttl;
81 	boolean_t qrydone;
82 	int status;
83 	int af;
84 	char paddrbuf[INET6_ADDRSTRLEN + 1];
85 	int withttlbsize;
86 	char *withttlbuffer;
87 };
88 
89 nss_backend_t *_nss_mdns_constr(mdns_backend_op_t *, int);
90 void _nss_mdns_destr(mdns_backend_ptr_t);
91 int _nss_mdns_querybyname(mdns_backend_ptr_t, char *name,
92 		int af, struct mdns_querydata *data);
93 int _nss_mdns_querybyaddr(mdns_backend_ptr_t, char *name,
94 		int af, struct mdns_querydata *data);
95 void _nss_mdns_updatecfg(mdns_backend_ptr_t);
96 
97 nss_status_t _nss_mdns_gethost_withttl(void *buf, size_t bufsize, int ipnode);
98 nss_status_t _nss_get_mdns_hosts_name(mdns_backend_ptr_t *be,
99 		void **bufp, size_t *sizep);
100 nss_status_t _nss_get_mdns_ipnodes_name(mdns_backend_ptr_t *be,
101 		void **bufp, size_t *sizep);
102 
103 #ifdef	__cplusplus
104 }
105 #endif
106 
107 #endif /* _MDNS_COMMON_H */
108