/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (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 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
/* All Rights Reserved */
#pragma ident "%Z%%M% %I% %E% SMI"
#include <ctype.h>
#include <stdio.h>
#include <tiuser.h>
#include <netdir.h>
#include <netconfig.h>
#include <string.h>
#include <stdlib.h>
#include <synch.h>
/*
* The generic name to address mappings for any transport that
* has strings for address (e.g., ISO Starlan).
*
* Address in ISO Starlan consist of arbitrary strings of
* characters. Because of this, the following routines
* create an "address" based on two strings, one gotten
* from a "host" file and one gotten from a "services" file.
* The two strings are catenated together (with a "." between
* contain lines of the form:
*
* arbitrary_string machname
*
* To make things simple, the "arbitrary string" should be the
* machine name.
*
* of the form:
*
* service_name arbitrary_string
*
* Again, to make things easer, the "arbitrary name" should be the
* service name.
*/
static int searchhost(struct netconfig *, char *, int, char *);
static int searchserv(struct netconfig *, char *, int, char *);
static const char *nodename(void);
/*
* _netdir_getbyname() returns all of the addresses for
* a specified host and service.
*/
struct nd_addrlist *
struct nd_hostserv *nd_hostservp)
{
/*
* HOST_BROADCAST is not supported.
*/
return (NULL);
}
fulladdr) == 0) {
return (NULL);
}
/*
* Now simply fill in the address by forming strings of the
* form "string_from_hosts.string_from_services"
*/
if (nd_hostservp->h_serv &&
} else {
/*
* Get the address from the services file
*/
return (NULL);
}
}
}
return (NULL);
}
/*
* We do not worry about multiple addresses here. Loopbacks
* have only one interface.
*/
return (NULL);
}
/*
* Don't include the terminating NULL character in the
* length.
*/
return (NULL);
}
return (retp);
}
/*
* _netdir_getbyaddr() takes an address (hopefully obtained from
* someone doing a _netdir_getbyname()) and returns all hosts with
* that address.
*/
struct nd_hostservlist *
{
/*
* Separate the two parts of the address string.
*/
return (NULL);
}
/*
* Search for all the hosts associated with the
* first part of the address string.
*/
if (nhost == 0) {
return (NULL);
}
/*
* Search for the service associated with the second
* path of the address string.
*/
return (NULL);
}
servbuf[0] = '\0';
while (*serv != '.')
serv++;
}
/*
* Allocate space to hold the return structure, set the number
* of hosts, and allocate space to hold them.
*/
return (NULL);
}
return (NULL);
}
/*
* Loop through the host structues and fill them in with
* each host name (and service name).
*/
return (NULL);
}
nd_hostservp++;
}
return (retp);
}
/*
* _taddr2uaddr() translates a address into a "universal" address.
* Since the address is a string, simply return the string as the
* universal address (but replace all non-printable characters with
* the \ddd form, where ddd is three octal digits). The '\n' character
* is also replace by \ddd and the '\' character is placed as two
* '\' characters.
*/
/* ARGSUSED */
char *
{
int i; /* indexes through the given string */
/*
* BUFSIZ is perhaps too big for this one and there is a better
* way to optimize it, but for now we will just assume BUFSIZ
*/
return (NULL);
}
if (*from == '\\') {
*to++ = '\\';
*to++ = '\\';
} else {
to += 4;
} else {
}
}
from++;
}
*to = '\0';
return (retp);
}
/*
* _uaddr2taddr() translates a universal address back into a
* netaddr structure. Since the universal address is a string,
* put that into the TLI buffer (making sure to change all \ddd
* characters back and strip off the trailing \0 character).
*/
/* ARGSUSED */
struct netbuf *
{
return (NULL);
}
while (*from) {
if (*from == '\\') {
*to = '\\';
from += 2;
} else {
from += 4;
}
} else {
}
to++;
}
*to = '\0';
return (NULL);
}
return (retp);
}
/*
* _netdir_options() is a "catch-all" routine that does
* transport specific things. The only thing that these
* routines have to worry about is ND_MERGEADDR.
*/
/* ARGSUSED */
int
{
switch (option) {
case ND_MERGEADDR:
/*
* Translate the universal address into something that
* makes sense to the caller. This is a no-op in
* loopback's case, so just return the universal address.
*/
default:
return (-1);
}
}
/*
* searchhost() looks for the specified token in the host file.
* The "field" parameter signifies which field to compare the token
* on, and returns all comma separated values associated with the token.
*/
static int
{
/*
* that will use straddr.so is loopback. In this case, we
* always return our nodename if that's what we were passed,
* or we fail (note that we'd like to return a constant like
* "localhost" so that changes to the machine name won't cause
* problems, but things like autofs actually assume that we're
* using our nodename).
*/
return (0);
return (1);
}
return (0);
/*
* We only get here if an administrator has modified
* loopback (which is questionable but something we'll need to
* EOL at a later point in time). In this case, we fallback to
* searching for the associated key in the appropriate hosts
* file (based on nc_netid).
*/
return (0);
/*
* Loop through the file looking for the tokens and creating
* the list of strings to be returned.
*/
/*
* Ignore comments and bad lines.
*/
continue;
continue;
/*
* determine which to compare the token to, then
* compare it, and if they match, add the return
* string to the list.
*/
nelements++;
/*
* called by _netdir_getbyname
*/
break;
}
if (nelements > 1) {
/*
* Assuming that "," will never be a part
* of any host name.
*/
}
}
}
return (nelements);
}
/*
* searchserv() looks for the specified token in the service file.
* The "field" parameter signifies which field to compare the token
* on, and returns the string associated with the token in servname.
*/
static int
{
return (0);
/*
* Loop through the services file looking for the token.
*/
/*
* If comment or bad line, continue.
*/
continue;
continue;
return (1);
}
}
return (0);
}
static const char *
nodename(void)
{
static const char *myname;
(void) mutex_lock(&nodename_lock);
(void) mutex_unlock(&nodename_lock);
return (myname);
}
(void) mutex_unlock(&nodename_lock);
return (NULL);
}
(void) mutex_unlock(&nodename_lock);
return (myname);
}