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.
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.
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]
22 * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
26 #pragma ident "%Z%%M% %I% %E% SMI"
29 * Routines to handle tsol_getrhbyaddr calls in nscd
34 #include <sys/types.h>
38 #define tsol_rh_db ctx->nsc_db[0]
40 #define NSC_NAME_TSOL_RH_BYADDR "tsol_getrhbyaddr"
42 static int tsol_rh_compar(const void *, const void *);
43 static uint_t
tsol_rh_gethash(nss_XbyY_key_t
*, int);
44 static void tsol_rh_getlogstr(char *, char *, size_t, nss_XbyY_args_t
*);
47 tnrhdb_init_ctx(nsc_ctx_t
*ctx
) {
48 ctx
->dbname
= NSS_DBNAM_TSOL_RH
;
50 ctx
->file_name
= TNRHDB_PATH
;
52 tsol_rh_db
= make_cache(nsc_key_other
,
53 NSS_DBOP_TSOL_RH_BYADDR
,
54 NSC_NAME_TSOL_RH_BYADDR
,
57 tsol_rh_gethash
, nsc_ht_default
, -1);
61 tsol_rh_getlogstr(char *name
, char *whoami
, size_t len
,
62 nss_XbyY_args_t
*argp
) {
64 (void) snprintf(whoami
, len
, "%s [key=%s, len=%d, addrtype=%d]",
65 name
, argp
->key
.hostaddr
.addr
, argp
->key
.hostaddr
.len
,
66 argp
->key
.hostaddr
.type
);
70 tsol_rh_compar(const void *n1
, const void *n2
) {
74 e1
= (nsc_entry_t
*)n1
;
75 e2
= (nsc_entry_t
*)n2
;
77 if (e1
->key
.hostaddr
.type
> e2
->key
.hostaddr
.type
)
79 else if (e1
->key
.hostaddr
.type
< e2
->key
.hostaddr
.type
)
82 l1
= strlen(e1
->key
.hostaddr
.addr
);
83 l2
= strlen(e2
->key
.hostaddr
.addr
);
84 res
= strncasecmp(e1
->key
.hostaddr
.addr
, e2
->key
.hostaddr
.addr
,
86 return (_NSC_INT_KEY_CMP(res
, 0));
90 tsol_rh_gethash(nss_XbyY_key_t
*key
, int htsize
) {
91 return (db_gethash(key
->hostaddr
.addr
,
92 strlen(key
->hostaddr
.addr
), htsize
));