/*
* 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.
*/
/*
* l_misc.c :
* This file contains the miscelleneous routines for libsm.so
*/
#include <fcntl.h>
#include <dirent.h>
#include <dlfcn.h>
#include <stdlib.h>
#include <strings.h>
#include "l_defines.h"
#include "smed.h"
#include <smserver.h>
#include <utmpx.h>
#include <limits.h>
#ifdef _LP64
#ifdef __sparc
#else
#endif
#else
#endif
static void
{
int error_no;
if (errno == 0)
return;
perror("");
}
static int
{
int ret_val;
int door_fd;
/*
* We will assume that we are running at level 2 or greater
* and attempt to contact the server using RPC mecahnisms.
* If that fails then we will attempt to contact the server
* using non-rpc mechanism. This will enable the libsmedia
* to be used in SINGLE user mode when inetd is not running.
* We expect the server to have been started manually by user.
*
* Note that "localhost" is used (vs hostname (eg, "uname -n")),
* as this minimizes interference with common IPSec rules.
*/
"circuit_v");
/*
* The failure could be that we are running at level 1
*/
if (door_fd < 0) {
DPRINTF1("Error in opening %s\n",
return (0);
}
if (ret_val < 0) {
return (0);
}
DPRINTF3("rsize = %d data_size = %d data_ptr = %p \n",
retping = (smedia_retping_t *)(
DPRINTF1("*** door call failed *** cnum "
return (0);
}
return (1);
}
if (server_info == NULL) {
if (clnt)
return (0);
}
if (server_info->status != 0) {
if (clnt)
DPRINTF1("get server_info call failed. "
return (0);
}
if (clnt)
DPRINTF2("version expected = %d version "
"returned = %d\n", SMSERVERVERS,
return (0);
}
if (door_fd < 0) {
return (0);
}
if (ret_val < 0) {
return (0);
}
DPRINTF3("rsize = %d data_size = %d data_ptr = %p \n",
DPRINTF1("*** door call failed *** cnum returned "
return (0);
}
return (1);
}
static void *
{
void *handle;
char *pathname;
PERROR("DKIOCINFO failed");
return (NULL);
}
PERROR("malloc failed");
return (NULL);
}
return (NULL);
}
continue;
}
continue;
}
PERROR("Error opening library file");
continue;
}
"_m_device_type");
DPRINTF("Could not find _m_device_type\n");
continue;
}
if (ret_val == 0) {
"_m_version_no");
DPRINTF("Could not find _m_version_no\n");
continue;
}
if ((ret_val >= 0) &&
(ret_val >= SM_PLUGIN_VERSION)) {
if (old_handle != NULL)
(void) dlclose(old_handle);
old_handle = handle;
continue;
} else {
}
} else {
}
}
return (old_handle);
}
{
void *lib_handle;
DPRINTF("Handle is NULL\n");
return (-1);
}
DPRINTF2("call_function:signature expected=0x%x, found=0x%x\n",
return (-1);
}
return (-1);
}
return (ret_val);
}
{
DPRINTF("Handle is NULL\n");
return (-1);
}
}
handle->sm_signature = 0;
return (0);
}
{
void *lib_handle;
int ret_val;
DPRINTF("smedia_get_handle called\n");
DPRINTF("Could not allocate memory for handle\n");
return (NULL);
}
handle->sm_bufsize = 0;
PERROR("DKIOCINFO failed");
return (NULL);
}
if (lib_handle == NULL) {
DPRINTF("lib_Handle is NULL\n");
return (NULL);
}
DPRINTF("Handle initialised successfully.\n");
/* Initialise the handle elements */
if (ret_val == 0) {
return (NULL);
}
if (door_fd < 0) {
return (NULL);
}
if (ret_val < 0) {
PERROR("door_call");
return (NULL);
}
DPRINTF3("rsize = %d data_size = %d data_ptr = %p \n",
return (NULL);
}
/*
* 2 door descriptors are returned after the above door call.
* The first door descriptor is the one that will be used
* in subsequent smedia calls. A dedicated thread is
* associated with this door to handle client calls.
* The second door descriptor is needed to signal unexpected
* death of the client to the server. This will help the server
* to do the necessary cleanup.
*/
DPRINTF("Num of door descriptors returned by "
"server is not 2");
return (NULL);
}
/* Check if the descriptor returned is S_IFDOOR */
PERROR("fstat");
return (NULL);
}
"Descriptor returned by door_call is not of type DOOR\n");
return (NULL);
}
DPRINTF("door call succeeded.\n");
return ((smedia_handle_t)handle);
} else {
return ((smedia_handle_t)handle);
}
}