xref: /illumos-gate/usr/src/lib/nsswitch/nis/common/netmasks.c (revision 533affcbc7fc4d0c8132976ea454aaa715fe2307)
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 /*
30  * All routines necessary to deal with the netmasks NIS maps.  The maps
31  * contain mapping between 32 bit network internet addresses and their
32  * corresponding 32 bit network mask internet address. The addresses are in
33  * dotted internet address form.
34  */
35 
36 #include <sys/types.h>
37 #include <sys/socket.h>
38 #include <net/if.h>
39 #include <netinet/in.h>
40 #include <net/if_arp.h>
41 #include <nss_dbdefs.h>
42 #include "nis_common.h"
43 
44 static nss_status_t
45 getbynet(be, a)
46 	nis_backend_ptr_t	be;
47 	void			*a;
48 {
49 	nss_XbyY_args_t		*argp = (nss_XbyY_args_t *) a;
50 	return (_nss_nis_lookup(be, argp, 0, "netmasks.byaddr",
51 	    argp->key.name, 0));
52 }
53 
54 static nis_backend_op_t netmasks_ops[] = {
55 	_nss_nis_destr,
56 	getbynet
57 };
58 
59 /*ARGSUSED*/
60 nss_backend_t *
61 _nss_nis_netmasks_constr(dummy1, dummy2, dummy3)
62 	const char	*dummy1, *dummy2, *dummy3;
63 {
64 	return (_nss_nis_constr(netmasks_ops,
65 			sizeof (netmasks_ops) / sizeof (netmasks_ops[0]),
66 			"netmasks.byaddr"));
67 }
68