getnode.c revision 7c478bd95313f5f23a4c958a745db2134aa03244
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2003 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
/*
* Routines to handle getipnode* calls in nscd. Note that the
* getnodeby* APIs were renamed getipnodeby*. The interfaces
* related to them in the nscd will remain as getnode*.
*/
#include <assert.h>
#include <errno.h>
#include <memory.h>
#include <signal.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <strings.h>
#include <thread.h>
#include <unistd.h>
#include <ucred.h>
#include <nss_common.h>
#include "getxby_door.h"
#include "server_door.h"
#include "nscd.h"
static void getnode_invalidate_unlocked(void);
int callnumber);
/*
* Create a combined key
* combined key =
* name + ":" + af_family(in %d format) + ":" + flags(in %d format)
* name = foo, af_family = 26, flags = 3, addrconfig = 1
* key = "foo:26:3"
* The string is allocated and caller has to free it.
*
* Insert ":" in between to ensure the uniqueness of the key.
*
* af_family: [2 | 26] ([AF_INET | AF_INET6])
* flags: 0 - strict
* 1 - AI_V4MAPPED
* 3 - (AI_V4MAPPED | AI_ALL)
* 4 - AI_ADDRCONFIG
* 5 - AI_DEFAULT (AI_V4MAPPED | AI_ADDRCONFIG)
* 7 - (AI_V4MAPPED | AI_ALL | AI_ADDRCONFIG)
*/
static char *
int len;
char *key;
/* name + ":" + af_str + ":" + flags_str + 1 */
return (NULL);
return (key);
}
/*
* Parse key and copy the values to out
*/
static void
/* copy name */
/* Copy af_family */
/* Copy flags */
}
}
}
}
static void
{
/*
* Called only for logging purposes...
* this should never happen in the nscd... but
* just in case we'll make sure we have a
* plausible error message.
*/
}
}
void
getnode_init(void)
{
}
static void
{
/* leave pending calls alone */
}
}
static void
{
/*
* be careful with ptr - it may be -1 or NULL.
*/
/* leave pending calls alone */
if (tmp != (char *)-1)
}
}
static void
{
/* leave pending calls alone */
if (tmp != (char *)-1)
}
}
void
getnode_revalidate(void)
{
for (;;) {
int slp;
int interval;
int count;
if (slp < 60)
slp = 60;
} else {
}
}
}
static void
{
int *table;
union {
} u;
int i;
if (!keep)
return;
(void) mutex_lock(&node_lock);
(void) mutex_unlock(&node_lock);
for (i = 1; i <= keep; i++) {
char *tmp;
continue; /* unused slot in table */
}
for (i = 1; i <= keep; i++) {
char *tmp;
}
}
static void
{
int *table;
union {
} u;
int i;
if (!keep)
return;
(void) mutex_lock(&node_lock);
(void) mutex_unlock(&node_lock);
for (i = 1; i <= keep; i++) {
char *tmp;
char addr[IPV6_ADDR_LEN];
continue; /* enused slot in table */
1)
continue; /* illegal address - skip it */
else {
}
}
for (i = 1; i <= keep; i++) {
char *tmp;
}
}
/*
* This routine marks all entries as invalid
*
*/
void
getnode_invalidate(void)
{
(void) mutex_lock(&node_lock);
(void) mutex_unlock(&node_lock);
}
static void
{
}
/*
* Mark only the ipnodebyname cache entries as invalid
*/
void
getnode_name_invalidate(void)
{
(void) mutex_lock(&node_lock);
(void) mutex_unlock(&node_lock);
}
void
{
int out_of_date;
return;
}
(void) mutex_lock(&node_lock);
/*EMPTY*/;
} else if (lastmod == 0) {
}
}
char addr[INET6_ADDRSTRLEN];
sizeof (addr));
} else {
logit("getnode_lookup: looking for nodename %s:%d:%d\n",
}
}
for (;;) {
char addr[INET6_ADDRSTRLEN];
goto getout;
}
} else { /* bounce excessively long requests */
if (door_ucred(&uc) != 0) {
logit("getnode_lookup: Name too long, "
"but no user credential: %s\n",
} else {
logit("getnode_lookup: Name too long "
"from pid %d uid %d\n",
ucred_getruid(uc));
ucred_free(uc);
}
goto getout;
}
goto getout;
}
}
/* no threads available */
/* cannot process now */
goto getout;
}
continue; /* go back and relookup hash bucket */
}
break;
}
/*
* check for no name_service mode
*/
/* time has expired */
int saved_errno;
int saved_hits = 0;
struct hostent *p;
/* no threads available */
/* cannot process now */
goto getout;
}
}
/*
* block any threads accessing this bucket if data is
* non-existent or out of date
*/
(nsc_bucket_t *)-1,
in->nsc_callnumber);
} else {
/*
* if still not -1 bucket we are doing update... mark to
* prevent pileups of threads if the name service is hanging...
*/
/* cleared by deletion of old data */
}
(void) mutex_unlock(&node_lock);
&saved_errno);
} else {
&saved_errno);
}
(void) mutex_lock(&node_lock);
if (p == NULL) { /* data not found */
char addr[INET6_ADDRSTRLEN];
logit("getnode_lookup: nscd COULDN'T "\
"FIND address %s\n", addr);
} else {
logit("getnode_lookup: nscd COULDN'T "\
"FIND node name %s:%d:%d\n",
}
}
sizeof (nsc_return_t);
in->nsc_callnumber);
goto getout;
}
else {
char addr[INET6_ADDRSTRLEN];
logit("getnode_lookup: nscd FOUND "\
"addr %s\n", addr);
} else {
logit("getnode_lookup: nscd FOUND "\
"node name %s:%d:%d\n",
}
}
in->nsc_callnumber);
if (saved_hits)
}
} else { /* found entry in cache */
char addr[INET6_ADDRSTRLEN];
logit("getnode_lookup: found address "\
"%s in cache\n", addr);
} else {
logit("getnode_lookup: found node "\
"name %s:%d:%d in cache\n",
}
}
} else {
char addr[INET6_ADDRSTRLEN];
logit("getnode_lookup: %s marked as "\
"NOT FOUND in cache.\n", addr);
} else {
logit("getnode_lookup: %s:%d:%d marked"\
" as NOT FOUND in cache.\n",
}
}
}
logit("launch update since time = %d\n",
/* cleared by deletion of old data */
}
}
(void) mutex_unlock(&node_lock);
}
/*ARGSUSED*/
static void
{
}
/*
* we can do this before reseting *old since we're holding the lock
*/
}
/* real data, not just update pending or invalidate */
new->nsc_status = 0;
} else {
}
}
}
/* Allocate a bucket to fit the data(nsc_return_t *in size) */
/* copy the data into the bucket and return the bucket */
/*ARGSUSED*/
static nsc_bucket_t *
{
char *dest;
char ** aliaseslist;
char ** addrlist;
int offset;
int strs;
int i;
int numaliases;
int numaddrs;
/* find out the size of the data block we're going to need */
/* allocate it and copy it in code doesn't assume packing */
/* order in original buffer */
return (NULL);
}
/* allocat the h_aliases list and the h_addr_list first to align 'em. */
aliaseslist = (char **)dest;
/* fill out the h_aliases list */
for (i = 0; i < numaliases; i++) {
}
aliaseslist[i] = 0; /* null term ptr chain */
/* fill out the h_addr list */
for (i = 0; i < numaddrs; i++) {
}
addrlist[i] = 0; /* null term ptr chain */
return (retb);
}
void
{
}
void
{
}