xref: /illumos-gate/usr/src/lib/nsswitch/nis/common/netmasks.c (revision 89b2a9fbeabf42fa54594df0e5927bcc50a07cc9)
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, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  *	nis/netmasks.c -- "nis" backend for nsswitch "netmasks" database
24  *
25  *	Copyright (c) 1996 Sun Microsystems Inc
26  *	All Rights Reserved.
27  */
28 
29 #pragma ident	"%Z%%M%	%I%	%E% SMI"
30 
31 /*
32  * All routines necessary to deal with the netmasks NIS maps.  The maps
33  * contain mapping between 32 bit network internet addresses and their
34  * corresponding 32 bit network mask internet address. The addresses are in
35  * dotted internet address form.
36  */
37 
38 #include <sys/types.h>
39 #include <sys/socket.h>
40 #include <net/if.h>
41 #include <netinet/in.h>
42 #include <net/if_arp.h>
43 #include <nss_dbdefs.h>
44 #include "nis_common.h"
45 
46 static nss_status_t
47 getbynet(be, a)
48 	nis_backend_ptr_t	be;
49 	void			*a;
50 {
51 	nss_XbyY_args_t		*argp = (nss_XbyY_args_t *) a;
52 	return (_nss_nis_lookup(be, argp, 0, "netmasks.byaddr",
53 	    argp->key.name, 0));
54 }
55 
56 static nis_backend_op_t netmasks_ops[] = {
57 	_nss_nis_destr,
58 	getbynet
59 };
60 
61 /*ARGSUSED*/
62 nss_backend_t *
63 _nss_nis_netmasks_constr(dummy1, dummy2, dummy3)
64 	const char	*dummy1, *dummy2, *dummy3;
65 {
66 	return (_nss_nis_constr(netmasks_ops,
67 			sizeof (netmasks_ops) / sizeof (netmasks_ops[0]),
68 			"netmasks.byaddr"));
69 }
70