/*
* 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
*/
/*
*/
/*
* Public utilities and convenience calls (from the API spec):
* SLPFindScopes (queries for all known scopes)
* SLPEscape / Unescape
* SLPFree
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <syslog.h>
#include <netdb.h>
#include <unistd.h>
#include <libintl.h>
#include <slp-internal.h>
struct scopes_tree {
void *scopes;
int len;
};
static void collect_scopes(void *, VISIT, int, void *);
SLPScopeCallback, void *,
void **, int *);
/*
* Finds scopes according the the user administrative model.
*/
return (SLP_PARAMETER_BAD);
}
/* first try administratively configured scopes */
!= SLP_OK) {
return (err);
}
if (*ppcScopes) {
/* got scopes */
return (SLP_OK);
}
/* DAs from active and passive discovery */
err != SLP_NETWORK_ERROR)
return (err);
/* Unpack the reply */
if (reply) {
/* tag call as internal */
(void) slp_unpackSrvReply(
/* invoke last call */
(void) slp_unpackSrvReply(
/* revert internal call tag */
}
/* Finally, if no results yet, try SA discovery */
if (!stree) {
}
if (!stree) {
/* found none, so just return "default" */
return (SLP_MEMORY_ALLOC_FAILED);
}
return (SLP_OK);
}
/* we now have a btree, each leaf of which is a unique scope */
/* unescape scopes list */
== SLP_OK) {
*ppcScopes = unesc_reply;
} else {
}
return (err);
}
/*
* Finds scopes according to the adminstrative scoping model. A
* comma-separated list of scopes is returned in *ppcScopes; the
* caller must free *ppcScopes.
* If the return_default parameter is true, and no scopes are found,
* *ppcScopes will be set to 'default', otherwise, *ppcScopes will
* be NULL. This helps simplify internal memory management.
*/
const char *useScopes;
/* @@@ first try DHCP */
/* next try the useScopes property */
return (SLP_MEMORY_ALLOC_FAILED);
}
return (SLP_OK);
}
/* found none, so just return "default" */
return (SLP_MEMORY_ALLOC_FAILED);
}
return (SLP_OK);
}
/*
* This function operates on the same btree as the collate_scopes().
* The difference is that this one is called for each
* SAAdvert recieved.
*/
/* ARGSUSED */
char *s, *tstate;
return (SLP_TRUE);
}
for (
s;
"out of memory");
return (SLP_TRUE);
}
srch = slp_tsearch(
(int (*)(const void *, const void *)) slp_strcasecmp);
/* scope is already in there, so just free ascope */
}
return (SLP_TRUE);
}
/*
* Generates an SAAdvert solicitation, and returns any scopes found
* from all recieved SAAdverts in stree. stree must be a btree
* structure.
*/
char *predicate;
const char *type_hint;
/* get type hint, if set */
*type_hint != 0) {
/* check bounds */
return (SLP_PARAMETER_BAD);
}
"out of memory");
return (SLP_MEMORY_ALLOC_FAILED);
}
} else {
predicate = "";
}
/* No callback for SLPFindScopes, so force synchronous mode only */
return (err);
if (type_hint) {
}
/* restore sync state */
return (err);
}
/*
* Unpack an SAAdvert and pass each set of scopes into cb.
*/
/* ARGSUSED */
void **collator, int *numResults) {
if (!reply) {
return (SLP_FALSE);
}
/* tag call as internal; gets all scopes, regardless of maxResults */
return (SLP_TRUE);
}
/* revert internal_call tag */
return (cont);
}
/*
* Creates a service request for finding DAs or SAs (based on 'filter'),
* and sends it to slpd, returning the reply in 'reply'.
*/
/* Try the cache first */
return (SLP_OK);
}
/*
* create a find scopes message:
* this is a SrvRqst for the type directory-agent.sun.
*/
/* use the local host's name for the scope */
}
/* Add the reply to the cache */
}
return (err);
}
/*
* This is called for each URL entry in the DA service reply (sun private).
* Contained within the cookie is a btree, to which it adds new
* scopes from the URL entry. The scopes are retrieved from the btree
* by traversing the tree in SLPFindScopes().
* SLPHandle h is NULL, so don't touch it!
*/
/*ARGSUSED*/
unsigned short lifetime,
return (SLP_TRUE);
/* dup url so as not to corrupt da cache */
return (SLP_FALSE);
}
/* parse url into a SLPSrvURL struct */
return (SLP_TRUE); /* bad URL; skip it */
/* collate the scopes using the btree stree->scopes: */
/* skip the 'scopes=' part */
return (SLP_TRUE); /* bad URL; skip it */
}
p++;
for (
s;
"out of memory");
return (SLP_TRUE);
}
srch = slp_tsearch(
(int (*)(const void *, const void *)) slp_strcasecmp);
/* scope is already in there, so just free ascope */
}
return (SLP_TRUE);
}
/*
* Each time we visit a node for the last time, copy that scope into
* the scope collection and free the scope string and the node.
*/
/*ARGSUSED*/
char *s = *(char **)node;
free(s);
}
}
if (pvMem)
}
/*
* Escape / Unescape
*/
(c) == '\n' || (c) == '\t' || (c) == '\r')
(c) == ',' || (c) == '\\' || (c) == '!' || \
(c) == '<' || (c) == '=' || (c) == '>' || \
(c) == '~')
return (SLP_PARAMETER_BAD);
return (SLP_MEMORY_ALLOC_FAILED);
}
int len;
/* If char is start of multibyte char, just copy it in */
int i;
continue;
}
/* check for bad tag */
return (SLP_PARSE_ERROR);
if (isReserved(*pin)) {
if (isTag)
return (SLP_PARSE_ERROR);
pout += 3;
pin++;
} else {
}
}
*pout = 0;
return (SLP_OK);
}
return (SLP_PARAMETER_BAD);
}
/*
* The actual unescaping routine; allows for different escape chars.
*/
return (SLP_MEMORY_ALLOC_FAILED);
}
conv[2] = 0;
int len;
/* If char is start of multibyte char, just copy it in */
int i;
continue;
}
return (SLP_PARSE_ERROR);
pin++;
return (SLP_PARSE_ERROR);
} else {
}
}
*pout = 0;
return (SLP_OK);
}
/*
* Properties
*
* All properties are stored in a global tree (prop_table). This
* tree is created and accessed by slp_tsearch and slp_tfind.
*/
struct prop_entry {
};
/* Global properties table */
static void setDefaults();
static int compare_props(const void *a, const void *b) {
return (strcmp(
((slp_prop_entry_t *)a)->key,
((slp_prop_entry_t *)b)->key));
}
if (!slp_props) setDefaults();
return;
}
return;
}
/* place the strings under library ownership */
return;
}
return;
}
/* is pcName already set? */
(void) mutex_lock(&prop_table_lock);
/* this prop is already set; overwrite the old value */
}
(void) mutex_unlock(&prop_table_lock);
}
if (!slp_props) setDefaults();
if (!pcName) {
return (NULL);
}
(void) mutex_lock(&prop_table_lock);
(void) mutex_unlock(&prop_table_lock);
if (ans)
return (NULL);
}
static void setDefaults() {
(void) mutex_lock(&lock);
if (slp_props) {
(void) mutex_unlock(&lock);
return;
}
(void) mutex_unlock(&lock);
}
static const char *error_strings[] = {
"OK", /* 0 */
"Language not supported", /* -1 */
"Parse error", /* -2 */
"Invalid registration", /* -3 */
"Scope not supported", /* -4 */
"Invalid error number", /* -5 */
"Authentication absent", /* -6 */
"Authentication failed", /* -7 */
"Invalid error number", /* -8 */
"Invalid error number", /* -9 */
"Invalid error number", /* -10 */
"Invalid error number", /* -11 */
"Invalid error number", /* -12 */
"Invalid update", /* -13 */
"Invalid error number", /* -14 */
"Invalid error number", /* -15 */
"Invalid error number", /* -16 */
"Not implemented", /* -17 */
"Buffer overflow", /* -18 */
"Network timed out", /* -19 */
"Network init failed", /* -20 */
"Memory alloc failed", /* -21 */
"Parameter bad", /* -22 */
"Network error", /* -23 */
"Internal system error", /* -24 */
"Handle in use", /* -25 */
"Type error" /* -26 */
};
int abserr;
const char *str;
if (err == SLP_LAST_CALL) {
str = "Last call";
} else if (err == SLP_SECURITY_UNAVAILABLE) {
str = "Security Implementation Unavailable";
} else {
if (abserr > SLP_MAX_ERR_CNT) {
str = "Invalid error number";
} else {
}
}
}