/*
* 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 1999-2003 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
/*
* Subroutines that implement the bootparam services.
*/
#include <rpcsvc/bootparam_prot.h>
#include <netdb.h>
#include <nlist.h>
#include <stdio.h>
#include <ctype.h>
#include <stdlib.h>
#include <string.h>
#include <nsswitch.h>
#include "bootparam_private.h"
extern int getdomainname(char *, int);
extern int bootparams_getbyname(char *, char *, int);
static void getf_printres(bp_getfile_res *);
static void copydomain(char *, char *, int);
/*
* Whoami turns a client address into a client name
* and suggested route machine.
*/
/*ARGSUSED1*/
{
char *cp;
if (debug) {
msgout("Whoami failed: unknown address type %d",
}
return (NULL);
}
sizeof (clnt_addr));
if (debug) {
msgout("Whoami failed: gethostbyaddr for %s.",
}
return (NULL);
}
/*
* We only answer requests from clients listed in the database.
*/
sizeof (clnt_entry)) != __NSW_SUCCESS) &&
sizeof (clnt_entry)) != __NSW_SUCCESS))
return (NULL);
/*
* The algorithm for determining the client's domain name is:
* 1) look for "domain=" in the client's bootparams line.
* If found, use its value.
* 2) look for a "domain=" entry in the wildcard bootparams
* line (if any). If found, use its value. Otherwise,
* 3) return the domain name of the server answering the
* request.
*/
sizeof (domain));
} else {
/* "domain=" not found - try for wildcard */
sizeof (clnt_entry)) == __NSW_SUCCESS) &&
sizeof (domain));
} else {
}
}
if (debug) {
msgout("Whoami returning name = %s, router address = %s",
}
return (&res);
}
/*
* Getfile gets the client name and the key and returns its server
* and the pathname for that key.
*/
/*ARGSUSED1*/
{
char *cp;
char *server_hostname;
char *path_on_server;
int do_wildcard = 0;
/*
* The bootparams_getbyname() library function looks up a
* "client entry" using using the client's hostname as the
* key. A client entry consists of a string of "file entries"
* separated by white space. Each file entry is of the form:
*
* file_key=server_hostname:path_on_server
*
* In the getfile RPC call, the client gives us his hostname
* and a file_key. We lookup his client entry, then locate a
* file entry matching that file_key. We then parse out the
* server_hostname and path_on_server from the file entry, map
* the server_hostname to an IP address, and return both the
* IP address and path_on_server back to the client.
*/
/* make the client's file key int a string we can use for matching */
sizeof (clnt_entry)) == __NSW_SUCCESS) {
/* locate the file_key in the client's entry */
do_wildcard++;
} else
do_wildcard++;
if (do_wildcard) {
sizeof (clnt_entry)) != __NSW_SUCCESS)
return (NULL);
/* locate the file_key in the client's entry */
return (NULL);
}
/* locate the "data" part of file entry (r.h.s. of "=") */
return (NULL);
cp++;
if (*cp == '\0')
return (NULL);
/* null-terminate server_hostname and parse path_on_server */
return (NULL);
*cp = '\0';
cp++;
/* strtok() will null-terminate path_on_server */
if (path_on_server == NULL)
if (*res.server_name == 0) {
} else {
argp->client_name);
} else {
if (addr == INADDR_BROADCAST) {
if (debug) {
msgout("getfile_1: gethostbyname(%s) "
}
return (NULL);
}
}
}
if (debug) {
getf_printres(&res);
}
return (&res);
}
void
{
msgout("getfile_1: file is \"%s\" %s \"%s\"",
res->server_path);
}
/*
* Used when we've found a "domain=" key, this function copies characters
* from source to target until we come upon either a NULL or whitespace is
* found in the source string, or we run out of room in the target.
*
*/
void
{
int n; /* number of characters copies */;
len--; /* leave room for terminating '\0' */
if (source)
break;
else
*target = '\0';
}