/*
* 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 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#include <stdlib.h>
#include <strings.h>
#include <unistd.h>
#include <stddef.h>
#include <assert.h>
#include <thread.h>
#include <synch.h>
#include <libilb_impl.h>
#include <libilb.h>
/* Assertion: the calling thread has a hold on the handle */
static void
{
if (h == ILB_INVALID_HANDLE)
return;
}
{
int s = -1;
int sobufsz;
return (ILB_STATUS_EINVAL);
return (ILB_STATUS_ENOMEM);
goto out;
}
!= 0) {
goto out;
}
== -1) {
goto out;
}
/* The socket buffer must be at least the max size of a message */
sizeof (sobufsz)) != 0) {
(void) close(s);
goto out;
}
sizeof (sobufsz)) != 0) {
(void) close(s);
goto out;
}
out:
(void) close(s);
if (rc == ILB_STATUS_OK) {
} else {
*hp = ILB_INVALID_HANDLE;
}
return (rc);
}
{
if (h == ILB_INVALID_HANDLE)
return (ILB_STATUS_EINVAL);
return (ILB_STATUS_INTERNAL);
/* Somebody has done a close, no need to do anything. */
return (ILB_STATUS_OK);
} else {
}
/* Wait until there is nobody waiting. */
return (ILB_STATUS_INTERNAL);
}
}
/* No one is waiting, proceed to free the handle. */
return (ILB_STATUS_OK);
}
/*
* Unified routine to communicate with ilbd.
*
* If ic is non-NULL, it means that the caller wants to send something
* to ilbd and expects a reply. If ic is NULL, it means that the caller
* only expects to receive from ilbd.
*
* The rbuf is the buffer supplied by the caller for receiving. If it
* is NULL, it means that there is no reply expected.
*
* This function will not close() the socket to kernel unless there is
* an error. If the transaction only consists of one exchange, the caller
* can use i_ilb_close_comm() to close() the socket when done.
*/
{
int r, s;
if (h == ILB_INVALID_HANDLE)
return (ILB_STATUS_EINVAL);
return (ILB_STATUS_INTERNAL);
return (ILB_STATUS_INTERNAL);
}
}
}
if (r < ic_sz) {
goto socket_error;
}
rc = ILB_STATUS_OK;
} else {
*rbufsz = r;
goto out;
}
i_ilb_socket_set_err(h, rc);
out:
return (rc);
}
void
{
(void) ilb_close(h);
}