/*
* 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 (c) 1999 by Sun Microsystems, Inc.
* All rights reserved.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include <stdio.h>
#include <stdlib.h>
#include <syslog.h>
#include <unistd.h>
#include <netdb.h>
#include <nss_dbdefs.h>
#include <slp-internal.h>
#include <slp_net_utils.h>
typedef struct slp_ifinfo {
short flags;
} slp_ifinfo_t;
typedef struct slp_handle_ifinfo {
int numifs;
/*
* Obtains the broadcast addresses for all local interfaces given in
* addrs.
*
* hp IN / OUT holds cached-per-handle if info
* given_ifs IN an array of local interfaces
* num_givenifs IN number of addresses in given_ifs
* bc_addrs OUT an array of broadcast addresses for local interfaces
* num_addrs OUT number of addrs returned in bc_addrs
*
* Returns SLP_OK if at least one broadcast address was found; if none
* were found, returns err != SLP_OK and *bc_addrs = NULL;
* Caller must free *bc_addrs when done.
*/
int num_givenifs,
struct sockaddr_in *bc_addrs[],
int *num_addrs) {
int i, j;
int numifs;
"out of memory");
return (SLP_MEMORY_ALLOC_FAILED);
}
return (err);
}
}
/* allocate memory for reply */
return (SLP_MEMORY_ALLOC_FAILED);
}
/* copy bc addrs for all desired interfaces which are bc-enabled */
*num_addrs = 0;
for (j = 0; j < num_givenifs; j++) {
for (i = 0; i < numifs; i++) {
continue;
}
/* got it, so copy it to bc_addrs */
(void) memcpy(
(*num_addrs)++;
break;
}
}
}
if (*num_addrs == 0) {
/* none found */
return (SLP_INTERNAL_SYSTEM_ERROR);
}
return (SLP_OK);
}
/*
* Returns true if addr is on a subnet local to the local host.
*/
int i;
int numifs;
"out of memory");
return (SLP_FALSE);
}
return (SLP_FALSE);
}
}
for (i = 0; i < numifs; i++) {
/* get netmask */
/* get network address */
/* apply netmask to input addr */
return (SLP_TRUE);
}
}
return (SLP_FALSE);
}
/*
* Returns true if any local interface if configured with addr.
*/
int i;
int numifs;
"out of memory");
return (SLP_FALSE);
}
return (SLP_FALSE);
}
}
for (i = 0; i < numifs; i++) {
sizeof (addr)) == 0) {
return (SLP_TRUE);
}
}
return (SLP_FALSE);
}
}
/*
* Populates all_ifs.
*/
int i, n, s = 0;
int numifs;
/* create a socket with which to get interface info */
goto cleanup;
}
/* how many interfaces are configured? */
goto cleanup;
}
/* allocate memory for ifinfo_t array */
goto cleanup;
}
/* allocate memory for interface info */
goto cleanup;
}
/* get if info */
goto cleanup;
}
i = 0;
/* ignore if interface is not up */
continue;
}
continue;
}
/* get the interface's address */
continue;
}
/* get the interface's broadcast address */
} else {
}
/* get the interface's subnet mask */
} else {
}
i++;
}
/* i contains the number we actually got info on */
if (i == 0) {
}
if (s) (void) close(s);
return (err);
}
/*
* Converts a SLPSrvURL to a network address. 'sa' must have been
* allocated by the caller.
* Assumes that addresses are given as specified in the protocol spec,
* i.e. as IP addresses and not host names.
*/
return (SLP_PARAMETER_BAD);
/* port number */
return (SLP_OK);
}
/*
* A wrapper around gethostbyaddr_r. This checks the useGetXXXbyYYY
* property first to determine whether a name service lookup should
* be used. If not, it converts the address in 'addr' to a string
* and just returns that.
*
* The core functionality herein will be replaced with getaddrinfo
* when it becomes available.
*/
const char *use_xbyy;
int herrno;
/* default: copy in the IP address */
return (NULL);
}
return (cname);
}
&herrno))) {
switch (herrno) {
case NO_RECOVERY:
case NO_DATA:
return (cname);
case TRY_AGAIN:
continue;
default:
return (cname); /* IP address */
}
}
return (NULL);
}
return (cname);
}
/* @@@ currently getting these from libresolv2 -> change? */
/*
* Converts the address pointed to by 'addr' to a string. Currently
* just calls inet_ntoa, but is structured to be a wrapper to
* inet_ntop. Returns NULL on failure.
*
* This wrapper allows callers to be protocol agnostic. Right now it
* only handles IPv4.
*/
/*ARGSUSED*/
}
/*
* convert from presentation format (which usually means ASCII printable)
* to network format (which is usually some kind of binary format).
* return:
* 1 if the address was valid for the specified address family
* 0 if the address wasn't valid (`dst' is untouched in this case)
* -1 if some other error occurred (`dst' is untouched in this case, too)
*
* This wrapper allows callers to be protocol agnostic. Right now it
* only handles IPv4.
*/
}