/*
* 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
*/
/*
*/
#include <stdio.h>
#include <fcntl.h>
#include <unistd.h>
#include <stdlib.h>
#include <strings.h>
#include <errno.h>
#include <sys/sysevent.h>
#include <libsysevent.h>
#include "libds.h"
static char vlds_device[] =
"/devices/virtual-devices@100/channel-devices@200/"
"virtual-domain-service@0:vlds";
typedef struct dslibentry {
char *dsl_service;
} dslibentry_t;
/* dsl_tflags */
static int ndslib;
/*
* Lock to protect the dslibtab table. We only need to protect this
* table for those functions which actually look at or modify the table:
* service registration (ds_svc_reg/ds_clnt_reg), service unregistration
* (ds_hdl_unreg) or during callbacks (ds_recv)
*/
/*
* Static functions internal to dslib.
*/
static dslibentry_t *ds_new_dslibentry(void);
static dslibentry_t *
{
int i;
return (dsp);
}
return (NULL);
}
static dslibentry_t *
ds_new_dslibentry(void)
{
int newndslib;
return (dsp);
/* double the size */
== NULL)
return (NULL);
return (dsp);
}
static uint_t
{
int i;
count++;
}
}
return (count);
}
static dslibentry_t *
{
int i;
return (dsp);
}
}
return (NULL);
}
static dslibentry_t *
{
return (dsp);
}
return (NULL);
}
/* use the original structure entry */
return (orig_dsp);
}
/*
* ds_new_dslibentry could cause orig_dsp to point to freed
* memory should we grow dslibtab, so save a copy of the
* table entry here and use it below.
*/
saved_orig = *orig_dsp;
/* allocate a new structure entry */
return (NULL);
*dsp = saved_orig;
return (dsp);
}
/*
* Want to leave an entry in the dslib table even though all the
* handles may have been unregistered for it.
*/
static void
{
/*
* Find out if we have 1 or 2 or more handles for the given
* service. Having one implies that we want to leave the entry
* intact but marked as not in use unless this is a ds_unreg_hdl
* (force_unreg is true).
*/
if (dsp->dsl_service) {
}
} else if (nhdls == 1) {
}
}
/*ARGSUSED*/
static int
{
char *subclass;
char *servicep;
return (0);
}
ds_domain_hdl_t) = NULL;
&servicep) == 0 &&
&is_client) == 0) {
(void) mutex_lock(&dslib_lock);
}
(void) mutex_unlock(&dslib_lock);
&dhdl) == 0 &&
dhdl);
}
}
(void) mutex_lock(&dslib_lock);
ds_free_dslibentry(dsp, 0);
}
(void) mutex_unlock(&dslib_lock);
}
(void) mutex_lock(&dslib_lock);
}
(void) mutex_unlock(&dslib_lock);
&buflen) == 0) {
}
}
}
return (0);
}
static void
{
dsp->vlds_strlen = 0;
} else {
}
}
static int
ds_init_sysev(void)
{
return (errno);
}
(void) sysevent_evc_unbind(ds_evchan);
return (errno);
}
return (0);
}
int
ds_init(void)
{
if (ds_fd >= 0)
return (0);
return (errno);
}
return (0);
}
static int
{
int i;
}
}
return (errno);
}
}
(void) mutex_lock(&dslib_lock);
(void) mutex_unlock(&dslib_lock);
}
/* Setup device driver capability structure. */
/* service string */
/* version array */
}
/*
* Format args for VLDS_SVC_REG ioctl.
*/
/* op flags */
/* returned handle */
(void) mutex_unlock(&dslib_lock);
return (errno);
}
/*
* Setup user callback sysevent channel.
*/
ds_init_sysev() != 0) {
(void) mutex_unlock(&dslib_lock);
return (errno);
}
/*
* Set entry values in dslibtab.
*/
dsp->dsl_tflags = 0;
(void) mutex_unlock(&dslib_lock);
return (0);
}
/*
* Registers a service provider. Kicks off the handshake with other
* domain(s) to announce servce. Callback events are as described above.
*/
int
{
}
/*
* Registers interest in a service from a specific domain. When that
* service is registered, the register callback is invoked. When that
* service is unregistered, the unregister callback is invoked. When
* data is received, the receive data callback is invoked.
*/
int
{
}
/*
* Given a service name and type, returns the existing handle(s), if
* one or more exist. This could be used to poll for the connection being
* registered or unregistered, rather than using the register/unregister
* callbacks.
*/
int
{
errno = 0;
if (ds_fd < 0) {
}
}
return (errno);
}
return (0);
}
/*
* Given a handle, return its associated domain.
*/
int
{
if (ds_fd < 0) {
}
return (errno);
}
if (dhdlp) {
}
return (0);
}
/*
* Unregisters either a service or an interest in that service
* indicated by the supplied handle.
*/
int
{
(void) mutex_lock(&dslib_lock);
}
(void) mutex_unlock(&dslib_lock);
if (ds_fd >= 0) {
}
return (0);
}
/*
* Send data to the appropriate service provider or client
* indicated by the provided handle. The sender will block
* until the message has been sent. There is no guarantee
* that multiple calls to ds_send_msg by the same thread
* will result in the data showing up at the receiver in
* the same order as sent. If multiple messages are required,
* it will be up to the sender and receiver to implement a
* protocol.
*/
int
{
if (ds_fd < 0) {
}
return (errno);
}
return (0);
}
/*
* Receive data from the appropriate service provider or client
* indicated by the provided handle. The sender will block
* until a message has been received.
*/
int
{
if (ds_fd < 0) {
}
*msglen = msglen_arg;
}
return (errno);
}
if (msglen) {
*msglen = msglen_arg;
}
return (0);
}
int
{
if (ds_fd < 0) {
}
return (errno);
}
*is_ready = (is_ready_arg != 0);
return (0);
}
/*
* Given a domain name, return its associated domain handle.
*/
int
{
if (ds_fd < 0) {
}
return (errno);
}
if (dhdlp) {
}
return (0);
}
/*
* Given a domain handle, return its associated domain name.
*/
int
{
if (ds_fd < 0) {
}
return (errno);
}
return (0);
}
void
{
nhdls == 1) {
(void) ds_unreg_hdl(hdl);
}
}
void
ds_fini(void)
{
int i;
if (ds_fd >= 0) {
ds_fd = -1;
}
if (ds_evchan) {
(void) sysevent_evc_unbind(ds_evchan);
}
if (ndslib > 0) {
(void) mutex_lock(&dslib_lock);
continue;
if (dsp->dsl_service) {
}
}
ndslib = 0;
(void) mutex_unlock(&dslib_lock);
(void) mutex_destroy(&dslib_lock);
}
}