netaddrs.c revision fcf3ce441efd61da9bb2884968af01cb7c1452cc
/*
* 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 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#include <locale.h>
#include <stdio.h>
#include <string.h>
#include <memory.h>
#include <varargs.h>
#include <unistd.h>
#include <ctype.h>
#include <stdlib.h>
#include <signal.h>
#include <errno.h>
#include <netdb.h>
#include <sys/pathconf.h>
#include <netdir.h>
#include <netconfig.h>
#include <syslog.h>
#include <strings.h>
#include <nsctl.h>
#include "librdc.h"
#define MAXIFS 32
/* number of transports to try */
#define MNT_PREF_LISTLEN 2
#define FIRST_TRY 1
#define SECOND_TRY 2
int
Is_ipv6present(void)
{
#ifdef AF_INET6
int sock;
if (sock < 0)
return (0);
lifn.lifn_flags = 0;
return (0);
}
if (lifn.lifn_count == 0)
return (0);
return (1);
#else
return (0);
#endif
}
/*
* The following is stolen from autod_nfs.c
*/
static void
{
int sock;
int numifs;
char *buf;
int family;
#ifdef AF_INET6
#else
#endif
#ifdef DEBUG
perror("getmyaddrs(): socket");
#endif
return;
}
#ifdef DEBUG
perror("getmyaddrs(): SIOCGIFNUM");
#endif
}
#ifdef DEBUG
#endif
return;
}
#ifdef DEBUG
perror("getmyaddrs(): SIOCGIFCONF");
#else
;
/*EMPTY*/
#endif
}
}
int
self_check(char *hostname)
{
int n;
struct nd_hostserv hs;
struct nd_addrlist *retaddrs;
int retval;
return (0);
/*
* Get the IP address for hostname
*/
#ifdef DEBUG
#endif
retval = 0;
goto out;
}
retval = 0;
goto out;
}
/* LINTED pointer alignment */
/*
* Now compare it against the list of
* addresses for the interfaces on this
* host.
*/
for (; n > 0; n--, ifr++) {
continue;
/* LINTED pointer alignment */
retval = 1;
goto out; /* it's me */
}
}
retval = 0;
out:
return (retval);
}
int
{
return (-1);
}
#ifdef DEBUG_ADDR
#endif
return (0);
}
struct hostent *
gethost_byname(const char *name)
{
int errnum;
#ifdef AF_INET6
#else /* !AF_INET6 */
return (gethostbyname(name));
#endif /* AF_INET6 */
}
int
char *fromnetaddr, char *tonetaddr)
{
int j;
int errnum;
#ifdef AF_INET6
#ifdef DEBUG
"Could not find host %s"), fromhost);
#endif
return (-1);
}
#else /* !AF_INET6 */
#ifdef DEBUG
"Could not find host %s"), fromhost);
#endif
return (-1);
}
#ifdef DEBUG
#endif
return (-1);
}
#endif /* AF_INET6 */
#ifdef AF_INET6
#ifdef DEBUG
"Could not find host %s"), tohost);
#endif
return (-1);
}
#else /* !AF_INET6 */
#ifdef DEBUG
"Could not find host %s"), tohost);
#endif
return (-1);
}
#ifdef DEBUG
#endif
return (-1);
}
#endif /* AF_INET6 */
return (0);
}
/*
* Get the network address on "hostname" for program "prog"
* with version "vers" by using the nconf configuration data
* passed in.
*
* If the address of a netconfig pointer is null then
* information is not sufficient and no netbuf will be returned.
*
* Finally, ping the null procedure of that service.
*
*/
static struct netbuf *
int portmap)
{
int fd = -1;
return (NULL);
goto done;
/* LINTED pointer alignment */
goto done;
if (portmap) { /* contact rpcbind */
goto done;
}
if (port) {
/* LINTED pointer alignment */
= port;
#ifdef NC_INET6
/* LINTED pointer alignment */
= port;
#endif
}
/* Simon -- we never use the client we create?! */
goto done;
ah = authsys_create_default();
} else { /* create our own address and skip rpcbind */
int j;
int errnum;
unsigned short family;
#ifdef AF_INET6
} else {
}
#ifdef DEBUG_ADDR
"Could not find host %s\n"), hostname);
#endif
goto done;
}
goto done;
}
/* LINTED pointer alignment */
/* LINTED pointer alignment */
} else {
/* LINTED pointer alignment */
/* LINTED pointer alignment */
}
#else
#ifdef DEBUG
"Could not find host %s"), hostname);
#endif
goto done;
}
goto done;
}
}
#endif
}
/*
* Make a copy of the netbuf to return
*/
goto done;
}
goto done;
}
done:
if (cl) {
}
}
if (tbind) {
}
if (fd >= 0)
return (nb);
}
/*
* Get a network address on "hostname" for program "prog"
* with version "vers". If the port number is specified (non zero)
* resulting IP address.
*
* If the address of a netconfig pointer was passed and
* if it's not null, use it as the netconfig otherwise
* assign the address of the netconfig that was used to
* establish contact with the service.
* If portmap is false, we return a similiar address and we do not
* contact rpcbind
*
*/
struct netbuf *
{
/*
* First lets get the requested port
*/
goto done;
/*
* No nconf passed in.
*
* the NETPATH environment variable.
* First search for COTS, second for CLTS unless proto
* is specified. When we retry, we reset the
* netconfig list so that we would search the whole list
* all over again.
*/
goto done;
/*
* If proto is specified, then only search for the match,
* otherwise try COTS first, if failed, try CLTS.
*/
if (proto) {
/*
*/
if (port == 0)
break;
#ifdef NC_INET6
/* CSTYLED */
#endif
/* CSTYLED */
) &&
break;
else {
break;
}
}
}
goto done;
goto done;
}
} else {
if (port == 0)
break;
NC_INET) == 0
#ifdef NC_INET6
/* CSTYLED */
NC_INET6) == 0
#endif
/* CSTYLED */
) &&
break;
}
}
}
} /* while */
if (++nthtry <= MNT_PREF_LISTLEN) {
endnetpath(nc);
goto done;
goto retry;
} else
goto done;
} else {
/*
* Continue the same search path in the
* netconfig db until no more matched
* nconf (nconf == NULL).
*/
goto retry;
}
#ifdef AF_INET6
/*
* We have a mismatch in the netconfig retry
*/
goto retry;
}
#endif
}
}
/*
* Got nconf and nb. Now dup the netconfig structure (nconf)
* and return it thru nconfp.
*/
}
done:
if (nc)
endnetpath(nc);
return (nb);
}
/* return values as for nsc_check_release() */
int
rdc_check_release(char **reqd)
{
/* librdc.so must be built on the runtime OS release */
}