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