checkpoint
This commit is contained in:
@@ -15,7 +15,7 @@
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
/* $Id: connection.c,v 1.4 2000/01/06 03:36:27 tale Exp $ */
|
||||
/* $Id: connection.c,v 1.5 2000/01/06 23:52:58 tale Exp $ */
|
||||
|
||||
/* Principal Author: Ted Lemon */
|
||||
|
||||
@@ -239,15 +239,30 @@ send_done(isc_task_t *task, isc_event_t *event) {
|
||||
|
||||
ENSURE(socket == connection->socket && task == connection->task);
|
||||
|
||||
/*
|
||||
* XXXDCL I am assuming that partial writes are not done. I hope this
|
||||
* does not prove to be incorrect. But the assumption can be tested ...
|
||||
*/
|
||||
ENSURE(socketevent->n == connection->out_bytes &&
|
||||
socketevent->n ==
|
||||
isc_bufferlist_usedcount(&socketevent->bufferlist));
|
||||
|
||||
connection->events_pending--;
|
||||
|
||||
/*
|
||||
* Restore the bufferlist into the connection object.
|
||||
* Restore the head of bufferlist into the connection object, resetting
|
||||
* it to have zero used space, and free the remaining buffers.
|
||||
* This is done before the test of the socketevent's result so that
|
||||
* abandon_connection() can free the buffer, if it is called below.
|
||||
*/
|
||||
for (buffer = ISC_LIST_HEAD(socketevent->bufferlist);
|
||||
buffer != NULL;
|
||||
buffer = ISC_LIST_NEXT(buffer, link))
|
||||
ISC_LIST_APPEND(connection->output_buffers, buffer, link);
|
||||
buffer = ISC_LIST_HEAD(socketevent->bufferlist);
|
||||
ISC_LIST_APPEND(connection->output_buffers, buffer, link);
|
||||
isc_buffer_clear(buffer);
|
||||
|
||||
while ((buffer = ISC_LIST_NEXT(buffer, link)) != NULL) {
|
||||
ISC_LIST_UNLINK(socketevent->bufferlist, buffer, link);
|
||||
isc_buffer_free(&buffer);
|
||||
}
|
||||
|
||||
if (socketevent->result != ISC_R_SUCCESS) {
|
||||
abandon_connection(connection, event, socketevent->result);
|
||||
@@ -256,11 +271,6 @@ send_done(isc_task_t *task, isc_event_t *event) {
|
||||
|
||||
connection->out_bytes -= socketevent->n;
|
||||
|
||||
/*
|
||||
* If there is still data to be written, another send event is queued.
|
||||
*/
|
||||
connection_send(connection);
|
||||
|
||||
isc_event_free(&event);
|
||||
|
||||
return;
|
||||
@@ -390,28 +400,62 @@ omapi_connection_toserver(omapi_object_t *protocol, const char *server_name,
|
||||
* Put some bytes into the output buffer for a connection.
|
||||
*/
|
||||
isc_result_t
|
||||
omapi_connection_copyin(omapi_object_t *h, unsigned char *bufp,
|
||||
omapi_connection_copyin(omapi_object_t *generic, unsigned char *src,
|
||||
unsigned int len)
|
||||
{
|
||||
omapi_connection_object_t *connection;
|
||||
isc_buffer_t *buffer;
|
||||
isc_bufferlist_t bufferlist;
|
||||
isc_result_t result;
|
||||
unsigned int space_available;
|
||||
|
||||
REQUIRE(h != NULL && h->type == omapi_type_connection);
|
||||
REQUIRE(generic != NULL && generic->type == omapi_type_connection);
|
||||
|
||||
connection = (omapi_connection_object_t *)h;
|
||||
connection = (omapi_connection_object_t *)generic;
|
||||
|
||||
buffer = ISC_LIST_HEAD(connection->output_buffers);
|
||||
/*
|
||||
* Check for enough space in the output buffers.
|
||||
*/
|
||||
bufferlist = connection->output_buffers;
|
||||
space_available = isc_bufferlist_availablecount(&bufferlist);
|
||||
|
||||
if (ISC_BUFFER_AVAILABLECOUNT(buffer) < len)
|
||||
isc_buffer_compact(buffer);
|
||||
while (space_available < len) {
|
||||
/*
|
||||
* Add new buffers until there is sufficient space.
|
||||
*/
|
||||
buffer = NULL;
|
||||
result = isc_buffer_allocate(omapi_mctx, &buffer,
|
||||
OMAPI_BUFFER_SIZE,
|
||||
ISC_BUFFERTYPE_BINARY);
|
||||
if (result != ISC_R_SUCCESS)
|
||||
return (result);
|
||||
|
||||
/* XXXDCL allocate new buffers */
|
||||
ENSURE(ISC_BUFFER_AVAILABLECOUNT(buffer) >= len);
|
||||
|
||||
isc_buffer_putmem(buffer->base + buffer->used, bufp, len);
|
||||
space_available += OMAPI_BUFFER_SIZE;
|
||||
ISC_LIST_APPEND(bufferlist, buffer, link);
|
||||
}
|
||||
|
||||
/*
|
||||
* XXXDCL out_bytes hardly seems needed as it is easy to get a
|
||||
* total of how much data is in the output buffers.
|
||||
*/
|
||||
connection->out_bytes += len;
|
||||
|
||||
/*
|
||||
* Copy the data into the buffers, splitting across buffers as necessary.
|
||||
*/
|
||||
for (buffer = ISC_LIST_HEAD(bufferlist); len > 0;
|
||||
buffer = ISC_LIST_NEXT(buffer, link)) {
|
||||
|
||||
space_available = ISC_BUFFER_AVAILABLECOUNT(buffer);
|
||||
if (space_available > len)
|
||||
space_available = len;
|
||||
|
||||
isc_buffer_putmem(buffer, src, space_available);
|
||||
|
||||
src += space_available;
|
||||
len -= space_available;
|
||||
}
|
||||
|
||||
return (ISC_R_SUCCESS);
|
||||
}
|
||||
|
||||
@@ -420,11 +464,12 @@ omapi_connection_copyin(omapi_object_t *h, unsigned char *bufp,
|
||||
* pointer beyond the bytes copied out.
|
||||
*/
|
||||
isc_result_t
|
||||
omapi_connection_copyout(unsigned char *buffer, omapi_object_t *generic,
|
||||
omapi_connection_copyout(unsigned char *dst, omapi_object_t *generic,
|
||||
unsigned int size)
|
||||
{
|
||||
omapi_connection_object_t *connection;
|
||||
isc_buffer_t *ibuffer;
|
||||
isc_buffer_t *buffer;
|
||||
unsigned int copy_bytes;
|
||||
|
||||
REQUIRE(generic != NULL && generic->type == omapi_type_connection);
|
||||
|
||||
@@ -433,13 +478,26 @@ omapi_connection_copyout(unsigned char *buffer, omapi_object_t *generic,
|
||||
if (size > connection->in_bytes)
|
||||
return (ISC_R_NOMORE);
|
||||
|
||||
ibuffer = ISC_LIST_HEAD(connection->input_buffers);
|
||||
buffer = ISC_LIST_HEAD(connection->input_buffers);
|
||||
|
||||
(void)memcpy(buffer, ibuffer->base, size);
|
||||
isc_buffer_forward(ibuffer, size);
|
||||
isc_buffer_compact(ibuffer);
|
||||
|
||||
connection->in_bytes -= size;
|
||||
/*
|
||||
* The data could potentially be split across multiple buffers,
|
||||
* so rather than a simple memcpy, a loop is needed.
|
||||
*/
|
||||
while (size > 0) {
|
||||
copy_bytes = buffer->used - buffer->current;
|
||||
if (copy_bytes > size)
|
||||
copy_bytes = size;
|
||||
|
||||
(void)memcpy(dst, buffer->base + buffer->current, copy_bytes);
|
||||
|
||||
isc_buffer_forward(buffer, copy_bytes);
|
||||
|
||||
size -= copy_bytes;
|
||||
connection->in_bytes -= copy_bytes;
|
||||
|
||||
buffer = ISC_LIST_NEXT(buffer, link);
|
||||
}
|
||||
|
||||
return (ISC_R_SUCCESS);
|
||||
}
|
||||
@@ -451,7 +509,7 @@ omapi_connection_copyout(unsigned char *buffer, omapi_object_t *generic,
|
||||
*/
|
||||
|
||||
void
|
||||
omapi_disconnect(omapi_object_t *generic, isc_boolean_t force) {
|
||||
omapi_connection_disconnect(omapi_object_t *generic, isc_boolean_t force) {
|
||||
omapi_connection_object_t *connection;
|
||||
|
||||
REQUIRE(generic != NULL);
|
||||
@@ -494,7 +552,7 @@ omapi_disconnect(omapi_object_t *generic, isc_boolean_t force) {
|
||||
* Disconnect from I/O object, if any.
|
||||
*/
|
||||
if (connection->outer != NULL)
|
||||
OBJECT_DEREF(&connection->outer, "omapi_disconnect");
|
||||
OBJECT_DEREF(&connection->outer, "omapi_connection_disconnect");
|
||||
|
||||
/*
|
||||
* If whatever created us registered a signal handler, send it
|
||||
@@ -540,7 +598,7 @@ omapi_connection_require(omapi_object_t *generic, unsigned int bytes) {
|
||||
buffer = ISC_LIST_HEAD(bufferlist);
|
||||
|
||||
/*
|
||||
* Lop off any completelyu used buffers, except the last one.
|
||||
* Lop off any completely used buffers, except the last one.
|
||||
*/
|
||||
while (ISC_BUFFER_AVAILABLECOUNT(buffer) == 0 &&
|
||||
buffer != ISC_LIST_TAIL(bufferlist)) {
|
||||
@@ -588,96 +646,68 @@ omapi_connection_require(omapi_object_t *generic, unsigned int bytes) {
|
||||
return (OMAPI_R_NOTYET);
|
||||
}
|
||||
|
||||
/*
|
||||
* Reaper function for connection - if the connection is completely closed,
|
||||
* reap it. If it's in the disconnecting state, there were bytes left
|
||||
* to write when the user closed it, so if there are now no bytes left to
|
||||
* write, we can close it.
|
||||
*/
|
||||
isc_result_t
|
||||
omapi_connection_reaper(omapi_object_t *h) {
|
||||
omapi_connection_object_t *c;
|
||||
|
||||
REQUIRE(h != NULL && h->type == omapi_type_connection);
|
||||
|
||||
c = (omapi_connection_object_t *)h;
|
||||
if (c->state == omapi_connection_disconnecting && c->out_bytes == 0)
|
||||
omapi_disconnect(h, OMAPI_FORCE_DISCONNECT);
|
||||
if (c->state == omapi_connection_closed)
|
||||
return (ISC_R_NOTCONNECTED);
|
||||
return (ISC_R_SUCCESS);
|
||||
omapi_connection_setvalue(omapi_object_t *connection, omapi_object_t *id,
|
||||
omapi_data_string_t *name, omapi_typed_data_t *value)
|
||||
{
|
||||
REQUIRE(connection != NULL && connection->type == omapi_type_connection);
|
||||
|
||||
PASS_SETVALUE(connection);
|
||||
}
|
||||
|
||||
isc_result_t
|
||||
omapi_connection_set_value(omapi_object_t *h, omapi_object_t *id,
|
||||
omapi_data_string_t *name,
|
||||
omapi_typed_data_t *value)
|
||||
omapi_connection_getvalue(omapi_object_t *connection, omapi_object_t *id,
|
||||
omapi_data_string_t *name, omapi_value_t **value)
|
||||
{
|
||||
REQUIRE(h != NULL && h->type == omapi_type_connection);
|
||||
REQUIRE(connection != NULL && connection->type == omapi_type_connection);
|
||||
|
||||
if (h->inner != NULL && h->inner->type->set_value)
|
||||
return (*(h->inner->type->set_value))(h->inner, id,
|
||||
name, value);
|
||||
return (ISC_R_NOTFOUND);
|
||||
}
|
||||
|
||||
isc_result_t
|
||||
omapi_connection_get_value(omapi_object_t *h, omapi_object_t *id,
|
||||
omapi_data_string_t *name,
|
||||
omapi_value_t **value)
|
||||
{
|
||||
REQUIRE(h != NULL && h->type == omapi_type_connection);
|
||||
|
||||
if (h->inner != NULL && h->inner->type->get_value)
|
||||
return (*(h->inner->type->get_value))(h->inner, id,
|
||||
name, value);
|
||||
return (ISC_R_NOTFOUND);
|
||||
PASS_GETVALUE(connection);
|
||||
}
|
||||
|
||||
void
|
||||
omapi_connection_destroy(omapi_object_t *h, const char *name) {
|
||||
omapi_connection_object_t *c;
|
||||
omapi_connection_destroy(omapi_object_t *handle, const char *name) {
|
||||
omapi_connection_object_t *connection;
|
||||
|
||||
REQUIRE(h != NULL && h->type == omapi_type_connection);
|
||||
REQUIRE(handle != NULL && handle->type == omapi_type_connection);
|
||||
|
||||
c = (omapi_connection_object_t *)h;
|
||||
connection = (omapi_connection_object_t *)handle;
|
||||
|
||||
if (c->state == omapi_connection_connected)
|
||||
omapi_disconnect(h, OMAPI_FORCE_DISCONNECT);
|
||||
if (connection->state == omapi_connection_connected)
|
||||
omapi_connection_disconnect(handle, OMAPI_FORCE_DISCONNECT);
|
||||
|
||||
if (c->listener != NULL)
|
||||
OBJECT_DEREF(&c->listener, name);
|
||||
/*
|
||||
* XXXDCL why is the listener object is being referenced?
|
||||
* does it need to be in the connection structure at all?
|
||||
*/
|
||||
if (connection->listener != NULL)
|
||||
OBJECT_DEREF(&connection->listener, name);
|
||||
}
|
||||
|
||||
isc_result_t
|
||||
omapi_connection_signal_handler(omapi_object_t *h, const char *name,
|
||||
va_list ap)
|
||||
omapi_connection_signalhandler(omapi_object_t *connection, const char *name,
|
||||
va_list ap)
|
||||
{
|
||||
REQUIRE(h != NULL && h->type == omapi_type_connection);
|
||||
REQUIRE(connection != NULL && connection->type == omapi_type_connection);
|
||||
|
||||
if (h->inner != NULL && h->inner->type->signal_handler)
|
||||
return (*(h->inner->type->signal_handler))(h->inner, name, ap);
|
||||
|
||||
return (ISC_R_NOTFOUND);
|
||||
PASS_SIGNAL(connection);
|
||||
}
|
||||
|
||||
/*
|
||||
* Write all the published values associated with the object through the
|
||||
* specified connection.
|
||||
*/
|
||||
|
||||
isc_result_t
|
||||
omapi_connection_stuff_values(omapi_object_t *c, omapi_object_t *id,
|
||||
omapi_object_t *h)
|
||||
omapi_connection_stuffvalues(omapi_object_t *connection, omapi_object_t *id,
|
||||
omapi_object_t *handle)
|
||||
{
|
||||
REQUIRE(h != NULL && h->type == omapi_type_connection);
|
||||
REQUIRE(connection != NULL && connection->type == omapi_type_connection);
|
||||
|
||||
if (h->inner != NULL && h->inner->type->stuff_values)
|
||||
return ((*(h->inner->type->stuff_values))(c, id, h->inner));
|
||||
|
||||
return (ISC_R_SUCCESS);
|
||||
PASS_STUFFVALUES(handle);
|
||||
}
|
||||
|
||||
/*
|
||||
* XXXDCL These could potentially use the isc_buffer_* integer functions
|
||||
*/
|
||||
isc_result_t
|
||||
omapi_connection_getuint32(omapi_object_t *c, isc_uint32_t *value) {
|
||||
isc_uint32_t inbuf;
|
||||
@@ -712,7 +742,7 @@ omapi_connection_getuint16(omapi_object_t *c, isc_uint16_t *value) {
|
||||
if (result != ISC_R_SUCCESS)
|
||||
return (result);
|
||||
|
||||
*value = ntohs (inbuf);
|
||||
*value = ntohs(inbuf);
|
||||
return (ISC_R_SUCCESS);
|
||||
}
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
/* $Id: dispatch.c,v 1.4 2000/01/06 03:36:27 tale Exp $ */
|
||||
/* $Id: dispatch.c,v 1.5 2000/01/06 23:52:59 tale Exp $ */
|
||||
|
||||
/* Principal Author: Ted Lemon */
|
||||
|
||||
@@ -67,12 +67,10 @@ omapi_wait_for_completion(omapi_object_t *object, struct timeval *t) {
|
||||
omapi_object_t *inner;
|
||||
|
||||
if (object != NULL) {
|
||||
waiter = isc_mem_get(omapi_mctx, sizeof(*waiter));
|
||||
if (waiter == NULL)
|
||||
return (ISC_R_NOMEMORY);
|
||||
memset(waiter, 0, sizeof(*waiter));
|
||||
waiter->refcnt = 1;
|
||||
waiter->type = omapi_type_waiter;
|
||||
result = omapi_object_new((omapi_object_t **)&waiter,
|
||||
omapi_type_waiter, sizeof(*waiter));
|
||||
if (result != ISC_R_SUCCESS)
|
||||
return (result);
|
||||
|
||||
/*
|
||||
* Paste the waiter object onto the inner object we're
|
||||
@@ -277,57 +275,45 @@ omapi_one_dispatch(omapi_object_t *wo, struct timeval *t) {
|
||||
}
|
||||
|
||||
isc_result_t
|
||||
omapi_io_set_value(omapi_object_t *h, omapi_object_t *id,
|
||||
omapi_data_string_t *name, omapi_typed_data_t *value)
|
||||
omapi_io_setvalue(omapi_object_t *io, omapi_object_t *id,
|
||||
omapi_data_string_t *name, omapi_typed_data_t *value)
|
||||
{
|
||||
REQUIRE(h != NULL && h->type == omapi_type_io_object);
|
||||
REQUIRE(io != NULL && io->type == omapi_type_io_object);
|
||||
|
||||
if (h->inner != NULL && h->inner->type->set_value != NULL)
|
||||
return (*(h->inner->type->set_value))(h->inner, id,
|
||||
name, value);
|
||||
|
||||
return (ISC_R_NOTFOUND);
|
||||
PASS_SETVALUE(io);
|
||||
}
|
||||
|
||||
isc_result_t
|
||||
omapi_io_get_value(omapi_object_t *h, omapi_object_t *id,
|
||||
omapi_data_string_t *name, omapi_value_t **value)
|
||||
omapi_io_getvalue(omapi_object_t *io, omapi_object_t *id,
|
||||
omapi_data_string_t *name, omapi_value_t **value)
|
||||
{
|
||||
REQUIRE(h != NULL && h->type == omapi_type_io_object);
|
||||
REQUIRE(io != NULL && io->type == omapi_type_io_object);
|
||||
|
||||
if (h->inner != NULL && h->inner->type->get_value != NULL)
|
||||
return (*(h->inner->type->get_value))(h->inner, id,
|
||||
name, value);
|
||||
|
||||
return (ISC_R_NOTFOUND);
|
||||
PASS_GETVALUE(io);
|
||||
}
|
||||
|
||||
void
|
||||
omapi_io_destroy(omapi_object_t *h, const char *name) {
|
||||
REQUIRE(h != NULL && h->type == omapi_type_io_object);
|
||||
omapi_io_destroy(omapi_object_t *io, const char *name) {
|
||||
REQUIRE(io != NULL && io->type == omapi_type_io_object);
|
||||
|
||||
(void)name; /* Unused. */
|
||||
}
|
||||
|
||||
isc_result_t
|
||||
omapi_io_signal_handler(omapi_object_t *h, const char *name, va_list ap) {
|
||||
REQUIRE(h != NULL && h->type == omapi_type_io_object);
|
||||
omapi_io_signalhandler(omapi_object_t *io, const char *name, va_list ap)
|
||||
{
|
||||
REQUIRE(io != NULL && io->type == omapi_type_io_object);
|
||||
|
||||
if (h->inner != NULL && h->inner->type->signal_handler != NULL)
|
||||
return (*(h->inner->type->signal_handler))(h->inner, name, ap);
|
||||
|
||||
return (ISC_R_NOTFOUND);
|
||||
PASS_SIGNAL(io);
|
||||
}
|
||||
|
||||
isc_result_t
|
||||
omapi_io_stuff_values(omapi_object_t *c, omapi_object_t *id, omapi_object_t *h)
|
||||
omapi_io_stuffvalues(omapi_object_t *connection, omapi_object_t *id,
|
||||
omapi_object_t *io)
|
||||
{
|
||||
REQUIRE(h != NULL && h->type == omapi_type_io_object);
|
||||
REQUIRE(io != NULL && io->type == omapi_type_io_object);
|
||||
|
||||
if (h->inner != NULL && h->inner->type->stuff_values != NULL)
|
||||
return (*(h->inner->type->stuff_values))(c, id, h->inner);
|
||||
|
||||
return (ISC_R_SUCCESS);
|
||||
PASS_STUFFVALUES(io);
|
||||
}
|
||||
|
||||
isc_result_t
|
||||
@@ -342,9 +328,6 @@ omapi_waiter_signal_handler(omapi_object_t *h, const char *name, va_list ap) {
|
||||
return (ISC_R_SUCCESS);
|
||||
}
|
||||
|
||||
if (h->inner != NULL && h->inner->type->signal_handler != NULL)
|
||||
return ((*(h->inner->type->signal_handler))(h->inner, name,
|
||||
ap));
|
||||
return (ISC_R_NOTFOUND);
|
||||
PASS_SIGNAL(h);
|
||||
}
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
/* $Id: generic.c,v 1.4 2000/01/06 03:36:28 tale Exp $ */
|
||||
/* $Id: generic.c,v 1.5 2000/01/06 23:52:59 tale Exp $ */
|
||||
|
||||
/* Principal Author: Ted Lemon */
|
||||
|
||||
@@ -192,10 +192,7 @@ omapi_generic_get_value(omapi_object_t *h, omapi_object_t *id,
|
||||
}
|
||||
}
|
||||
|
||||
if (h->inner != NULL && h->inner->type->get_value != NULL)
|
||||
return (*(h->inner->type->get_value))(h->inner, id,
|
||||
name, value);
|
||||
return (ISC_R_NOTFOUND);
|
||||
PASS_GETVALUE(h);
|
||||
}
|
||||
|
||||
void
|
||||
@@ -225,9 +222,7 @@ omapi_generic_signal_handler(omapi_object_t *h, const char *name, va_list ap) {
|
||||
|
||||
REQUIRE(h != NULL && h->type == omapi_type_generic);
|
||||
|
||||
if (h->inner != NULL && h->inner->type->signal_handler != NULL)
|
||||
return (*(h->inner->type->signal_handler))(h->inner, name, ap);
|
||||
return (ISC_R_NOTFOUND);
|
||||
PASS_SIGNAL(h);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -236,7 +231,7 @@ omapi_generic_signal_handler(omapi_object_t *h, const char *name, va_list ap) {
|
||||
*/
|
||||
|
||||
isc_result_t
|
||||
omapi_generic_stuff_values(omapi_object_t *c, omapi_object_t *id,
|
||||
omapi_generic_stuff_values(omapi_object_t *connection, omapi_object_t *id,
|
||||
omapi_object_t *h)
|
||||
{
|
||||
omapi_generic_object_t *src;
|
||||
@@ -250,24 +245,22 @@ omapi_generic_stuff_values(omapi_object_t *c, omapi_object_t *id,
|
||||
for (i = 0; i < src->nvalues; i++) {
|
||||
if (src->values[i] != NULL &&
|
||||
src->values[i]->name->len != 0) {
|
||||
result = omapi_connection_putuint16(c,
|
||||
result = omapi_connection_putuint16(connection,
|
||||
src->values[i]->name->len);
|
||||
if (result != ISC_R_SUCCESS)
|
||||
return (result);
|
||||
result = omapi_connection_copyin(c,
|
||||
result = omapi_connection_copyin(connection,
|
||||
src->values[i]->name->value,
|
||||
src->values[i]->name->len);
|
||||
if (result != ISC_R_SUCCESS)
|
||||
return (result);
|
||||
|
||||
result = omapi_connection_puttypeddata(c,
|
||||
result = omapi_connection_puttypeddata(connection,
|
||||
src->values[i]->value);
|
||||
if (result != ISC_R_SUCCESS)
|
||||
return (result);
|
||||
}
|
||||
}
|
||||
|
||||
if (h->inner != NULL && h->inner->type->stuff_values != NULL)
|
||||
return (*(h->inner->type->stuff_values))(c, id, h->inner);
|
||||
return (ISC_R_SUCCESS);
|
||||
PASS_STUFFVALUES(h);
|
||||
}
|
||||
|
||||
@@ -159,7 +159,7 @@ struct omapi_object_type {
|
||||
#define OMAPI_PROTOCOL_PORT 7911
|
||||
|
||||
/*
|
||||
* For use with omapi_disconnect().
|
||||
* For use with omapi_connection_disconnect().
|
||||
*/
|
||||
#define OMAPI_FORCE_DISCONNECT ISC_TRUE
|
||||
#define OMAPI_CLEAN_DISCONNECT ISC_FALSE
|
||||
@@ -190,6 +190,9 @@ isc_result_t
|
||||
omapi_protocol_connect(omapi_object_t *object, const char *server, int port,
|
||||
omapi_object_t *authinfo);
|
||||
|
||||
void
|
||||
omapi_protocol_disconnect(omapi_object_t *handle, isc_boolean_t force);
|
||||
|
||||
isc_result_t
|
||||
omapi_protocol_listen(omapi_object_t *object, int port, int backlog);
|
||||
|
||||
@@ -262,7 +265,7 @@ omapi_connection_toserver(omapi_object_t *connection, const char *server,
|
||||
int port);
|
||||
|
||||
void
|
||||
omapi_disconnect(omapi_object_t *connection, isc_boolean_t force);
|
||||
omapi_connection_disconnect(omapi_object_t *connection, isc_boolean_t force);
|
||||
|
||||
int
|
||||
omapi_connection_readfd(omapi_object_t *connection);
|
||||
@@ -283,23 +286,23 @@ isc_result_t
|
||||
omapi_connection_reaper(omapi_object_t *connection);
|
||||
|
||||
isc_result_t
|
||||
omapi_connection_set_value(omapi_object_t *connection, omapi_object_t *id,
|
||||
omapi_connection_setvalue(omapi_object_t *connection, omapi_object_t *id,
|
||||
omapi_data_string_t *name,
|
||||
omapi_typed_data_t *value);
|
||||
|
||||
isc_result_t
|
||||
omapi_connection_get_value(omapi_object_t *connection, omapi_object_t *id,
|
||||
omapi_connection_getvalue(omapi_object_t *connection, omapi_object_t *id,
|
||||
omapi_data_string_t *name, omapi_value_t **value);
|
||||
|
||||
void
|
||||
omapi_connection_destroy(omapi_object_t *connection, const char *name);
|
||||
|
||||
isc_result_t
|
||||
omapi_connection_signal_handler(omapi_object_t *connection, const char *name,
|
||||
omapi_connection_signalhandler(omapi_object_t *connection, const char *name,
|
||||
va_list args);
|
||||
|
||||
isc_result_t
|
||||
omapi_connection_stuff_values(omapi_object_t *connection, omapi_object_t *id,
|
||||
omapi_connection_stuffvalues(omapi_object_t *connection, omapi_object_t *id,
|
||||
omapi_object_t *object);
|
||||
|
||||
isc_result_t
|
||||
@@ -385,21 +388,21 @@ isc_result_t
|
||||
omapi_one_dispatch(omapi_object_t *waiter, struct timeval *timeout);
|
||||
|
||||
isc_result_t
|
||||
omapi_io_set_value(omapi_object_t *io, omapi_object_t *id,
|
||||
omapi_io_setvalue(omapi_object_t *io, omapi_object_t *id,
|
||||
omapi_data_string_t *name, omapi_typed_data_t *value);
|
||||
|
||||
isc_result_t
|
||||
omapi_io_get_value(omapi_object_t *io, omapi_object_t *id,
|
||||
omapi_io_getvalue(omapi_object_t *io, omapi_object_t *id,
|
||||
omapi_data_string_t *name, omapi_value_t **value);
|
||||
|
||||
void
|
||||
omapi_io_destroy(omapi_object_t *io, const char *name);
|
||||
|
||||
isc_result_t
|
||||
omapi_io_signal_handler(omapi_object_t *io, const char *name, va_list args);
|
||||
omapi_io_signalhandler(omapi_object_t *io, const char *name, va_list args);
|
||||
|
||||
isc_result_t
|
||||
omapi_io_stuff_values(omapi_object_t *io, omapi_object_t *id,
|
||||
omapi_io_stuffvalues(omapi_object_t *io, omapi_object_t *id,
|
||||
omapi_object_t *object);
|
||||
isc_result_t
|
||||
omapi_waiter_signal_handler(omapi_object_t *waiter, const char *name,
|
||||
@@ -437,20 +440,20 @@ isc_result_t
|
||||
omapi_message_new(omapi_object_t **message, const char *name);
|
||||
|
||||
isc_result_t
|
||||
omapi_message_set_value(omapi_object_t *message, omapi_object_t *id,
|
||||
omapi_message_setvalue(omapi_object_t *message, omapi_object_t *id,
|
||||
omapi_data_string_t *name, omapi_typed_data_t *value);
|
||||
isc_result_t
|
||||
omapi_message_get_value(omapi_object_t *message, omapi_object_t *id,
|
||||
omapi_message_getvalue(omapi_object_t *message, omapi_object_t *id,
|
||||
omapi_data_string_t *name, omapi_value_t **value);
|
||||
void
|
||||
omapi_message_destroy(omapi_object_t *message, const char *name);
|
||||
|
||||
isc_result_t
|
||||
omapi_message_signal_handler(omapi_object_t *message, const char *name,
|
||||
omapi_message_signalhandler(omapi_object_t *message, const char *name,
|
||||
va_list args);
|
||||
|
||||
isc_result_t
|
||||
omapi_message_stuff_values(omapi_object_t *message, omapi_object_t *id,
|
||||
omapi_message_stuffvalues(omapi_object_t *message, omapi_object_t *id,
|
||||
omapi_object_t *object);
|
||||
isc_result_t
|
||||
omapi_message_register(omapi_object_t *message);
|
||||
|
||||
@@ -22,6 +22,8 @@
|
||||
#ifndef OMAPI_OMAPIP_P_H
|
||||
#define OMAPI_OMAPIP_P_H
|
||||
|
||||
#define ISC_MEM_DEBUG 1
|
||||
|
||||
#include <isc/lang.h>
|
||||
#include <isc/mem.h>
|
||||
#include <isc/net.h>
|
||||
|
||||
@@ -29,42 +29,38 @@ omapi_message_object_t *omapi_registered_messages;
|
||||
|
||||
isc_result_t
|
||||
omapi_message_new(omapi_object_t **o, const char *name) {
|
||||
omapi_message_object_t *m;
|
||||
omapi_message_object_t *message = NULL;
|
||||
omapi_object_t *g;
|
||||
isc_result_t result;
|
||||
|
||||
m = isc_mem_get(omapi_mctx, sizeof(*m));
|
||||
if (m == NULL)
|
||||
return (ISC_R_NOMEMORY);
|
||||
memset(m, 0, sizeof(*m));
|
||||
m->object_size = sizeof(*m);
|
||||
m->refcnt = 1;
|
||||
m->type = omapi_type_message;
|
||||
result = omapi_object_new((omapi_object_t **)&message,
|
||||
omapi_type_message, sizeof(*message));
|
||||
if (result != ISC_R_SUCCESS)
|
||||
return (result);
|
||||
|
||||
g = NULL;
|
||||
result = omapi_generic_new(&g, name);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
isc_mem_put(omapi_mctx, m, sizeof(*m));
|
||||
OBJECT_DEREF(&message, "omapi_message_new");
|
||||
return (result);
|
||||
}
|
||||
|
||||
OBJECT_REF(&m->inner, g, name);
|
||||
OBJECT_REF(&g->outer, m, name);
|
||||
OBJECT_REF(o, m, name);
|
||||
OBJECT_REF(&message->inner, g, name);
|
||||
OBJECT_REF(&g->outer, message, name);
|
||||
OBJECT_REF(o, message, name);
|
||||
|
||||
OBJECT_DEREF(&m, name);
|
||||
OBJECT_DEREF(&message, name);
|
||||
OBJECT_DEREF(&g, name);
|
||||
|
||||
return (result);
|
||||
}
|
||||
|
||||
isc_result_t
|
||||
omapi_message_set_value(omapi_object_t *h, omapi_object_t *id,
|
||||
omapi_message_setvalue(omapi_object_t *h, omapi_object_t *id,
|
||||
omapi_data_string_t *name,
|
||||
omapi_typed_data_t *value)
|
||||
{
|
||||
omapi_message_object_t *m;
|
||||
isc_result_t result;
|
||||
|
||||
REQUIRE(h != NULL && h->type == omapi_type_message);
|
||||
|
||||
@@ -153,18 +149,11 @@ omapi_message_set_value(omapi_object_t *h, omapi_object_t *id,
|
||||
/*
|
||||
* Try to find some inner object that can take the value.
|
||||
*/
|
||||
if (h->inner != NULL && h->inner->type->set_value != NULL) {
|
||||
result = ((*(h->inner->type->set_value))(h->inner, id,
|
||||
name, value));
|
||||
if (result == ISC_R_SUCCESS)
|
||||
return (result);
|
||||
}
|
||||
|
||||
return (ISC_R_NOTFOUND);
|
||||
PASS_SETVALUE(h);
|
||||
}
|
||||
|
||||
isc_result_t
|
||||
omapi_message_get_value(omapi_object_t *h, omapi_object_t *id,
|
||||
omapi_message_getvalue(omapi_object_t *h, omapi_object_t *id,
|
||||
omapi_data_string_t *name,
|
||||
omapi_value_t **value)
|
||||
{
|
||||
@@ -206,55 +195,52 @@ omapi_message_get_value(omapi_object_t *h, omapi_object_t *id,
|
||||
/*
|
||||
* See if there's an inner object that has the value.
|
||||
*/
|
||||
if (h->inner != NULL && h->inner->type->get_value != NULL)
|
||||
return (*(h->inner->type->get_value))(h->inner, id,
|
||||
name, value);
|
||||
return (ISC_R_NOTFOUND);
|
||||
PASS_GETVALUE(h);
|
||||
}
|
||||
|
||||
void
|
||||
omapi_message_destroy(omapi_object_t *h, const char *name) {
|
||||
omapi_message_object_t *m;
|
||||
omapi_message_destroy(omapi_object_t *handle, const char *name) {
|
||||
omapi_message_object_t *message;
|
||||
|
||||
REQUIRE(h != NULL && h->type == omapi_type_message);
|
||||
REQUIRE(handle != NULL && handle->type == omapi_type_message);
|
||||
|
||||
m = (omapi_message_object_t *)h;
|
||||
message = (omapi_message_object_t *)handle;
|
||||
|
||||
if (m->authenticator != NULL)
|
||||
omapi_data_dereference(&m->authenticator, name);
|
||||
if (message->authenticator != NULL)
|
||||
omapi_data_dereference(&message->authenticator, name);
|
||||
|
||||
if (m->prev == NULL && omapi_registered_messages != m)
|
||||
omapi_message_unregister(h);
|
||||
if (m->prev != NULL)
|
||||
OBJECT_DEREF(&m->prev, name);
|
||||
if (m->next != NULL)
|
||||
OBJECT_DEREF(&m->next, name);
|
||||
if (m->id_object != NULL)
|
||||
OBJECT_DEREF(&m->id_object, name);
|
||||
if (m->object != NULL)
|
||||
OBJECT_DEREF(&m->object, name);
|
||||
if (message->prev == NULL && omapi_registered_messages != message)
|
||||
omapi_message_unregister(handle);
|
||||
if (message->prev != NULL)
|
||||
OBJECT_DEREF(&message->prev, name);
|
||||
if (message->next != NULL)
|
||||
OBJECT_DEREF(&message->next, name);
|
||||
if (message->id_object != NULL)
|
||||
OBJECT_DEREF(&message->id_object, name);
|
||||
if (message->object != NULL)
|
||||
OBJECT_DEREF(&message->object, name);
|
||||
}
|
||||
|
||||
isc_result_t
|
||||
omapi_message_signal_handler(omapi_object_t *h, const char *name, va_list ap) {
|
||||
omapi_message_object_t *m;
|
||||
omapi_message_signalhandler(omapi_object_t *handle, const char *name,
|
||||
va_list ap) {
|
||||
omapi_message_object_t *message;
|
||||
|
||||
REQUIRE(h != NULL && h->type == omapi_type_message);
|
||||
REQUIRE(handle != NULL && handle->type == omapi_type_message);
|
||||
|
||||
m = (omapi_message_object_t *)h;
|
||||
message = (omapi_message_object_t *)handle;
|
||||
|
||||
if (strcmp(name, "status") == 0 &&
|
||||
(m->object != NULL || m->notify_object != NULL)) {
|
||||
if (m->object != NULL)
|
||||
return ((m->object->type->signal_handler))(m->object,
|
||||
name, ap);
|
||||
if (strcmp(name, "status") == 0 &&
|
||||
(message->object != NULL || message->notify_object != NULL)) {
|
||||
if (message->object != NULL)
|
||||
return ((message->object->type->signal_handler))
|
||||
(message->object, name, ap);
|
||||
else
|
||||
return ((m->notify_object->type->signal_handler))
|
||||
(m->notify_object, name, ap);
|
||||
return ((message->notify_object->type->signal_handler))
|
||||
(message->notify_object, name, ap);
|
||||
}
|
||||
if (h->inner != NULL && h->inner->type->signal_handler != NULL)
|
||||
return (*(h->inner->type->signal_handler))(h->inner, name, ap);
|
||||
return (ISC_R_NOTFOUND);
|
||||
|
||||
PASS_SIGNAL(handle);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -263,14 +249,12 @@ omapi_message_signal_handler(omapi_object_t *h, const char *name, va_list ap) {
|
||||
*/
|
||||
|
||||
isc_result_t
|
||||
omapi_message_stuff_values(omapi_object_t *c, omapi_object_t *id,
|
||||
omapi_object_t *h)
|
||||
omapi_message_stuffvalues(omapi_object_t *connection, omapi_object_t *id,
|
||||
omapi_object_t *message)
|
||||
{
|
||||
REQUIRE(h != NULL && h->type == omapi_type_message);
|
||||
REQUIRE(message != NULL && message->type == omapi_type_message);
|
||||
|
||||
if (h->inner != NULL && h->inner->type->stuff_values != NULL)
|
||||
return (*(h->inner->type->stuff_values))(c, id, h->inner);
|
||||
return (ISC_R_SUCCESS);
|
||||
PASS_STUFFVALUES(message);
|
||||
}
|
||||
|
||||
isc_result_t
|
||||
@@ -380,7 +364,7 @@ omapi_message_process(omapi_object_t *mo, omapi_object_t *po) {
|
||||
case OMAPI_OP_OPEN:
|
||||
if (m != NULL) {
|
||||
return (omapi_protocol_send_status(po, NULL,
|
||||
ISC_R_INVALIDARG,
|
||||
OMAPI_R_INVALIDARG,
|
||||
message->id,
|
||||
"OPEN can't be "
|
||||
"a response"));
|
||||
@@ -460,7 +444,7 @@ omapi_message_process(omapi_object_t *mo, omapi_object_t *po) {
|
||||
if (type == NULL) {
|
||||
if (create != 0) {
|
||||
return (omapi_protocol_send_status(po, NULL,
|
||||
ISC_R_INVALIDARG, message->id,
|
||||
OMAPI_R_INVALIDARG, message->id,
|
||||
"type required on create"));
|
||||
}
|
||||
goto refresh;
|
||||
@@ -485,7 +469,7 @@ omapi_message_process(omapi_object_t *mo, omapi_object_t *po) {
|
||||
|
||||
if (result != ISC_R_SUCCESS &&
|
||||
result != ISC_R_NOTFOUND &&
|
||||
result != ISC_R_NOKEYS) {
|
||||
result != OMAPI_R_NOKEYS) {
|
||||
return (omapi_protocol_send_status(po, NULL,
|
||||
result, message->id,
|
||||
"object lookup failed"));
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
/* $Id: object.c,v 1.2 2000/01/06 03:36:29 tale Exp $ */
|
||||
/* $Id: object.c,v 1.3 2000/01/06 23:53:00 tale Exp $ */
|
||||
|
||||
/* Principal Author: Ted Lemon */
|
||||
|
||||
@@ -30,8 +30,7 @@
|
||||
#include <omapi/private.h>
|
||||
|
||||
isc_result_t
|
||||
omapi_object_new(omapi_object_t **object, omapi_object_type_t *type,
|
||||
size_t size)
|
||||
omapi_object_new(omapi_object_t **object, omapi_object_type_t *type, size_t size)
|
||||
{
|
||||
omapi_object_t *new;
|
||||
|
||||
|
||||
@@ -53,7 +53,7 @@ typedef struct {
|
||||
/*
|
||||
* True when reading message-specific values.
|
||||
*/
|
||||
int reading_message_values;
|
||||
isc_boolean_t reading_message_values;
|
||||
omapi_message_object_t * message; /* Incoming message. */
|
||||
omapi_data_string_t * name; /* Incoming name. */
|
||||
omapi_typed_data_t * value; /* Incoming value. */
|
||||
@@ -112,6 +112,24 @@ omapi_protocol_connect(omapi_object_t *h, const char *server_name,
|
||||
return (ISC_R_SUCCESS);
|
||||
}
|
||||
|
||||
void
|
||||
omapi_protocol_disconnect(omapi_object_t *handle, isc_boolean_t force) {
|
||||
omapi_protocol_object_t *protocol;
|
||||
omapi_connection_object_t *connection;
|
||||
|
||||
REQUIRE(handle != NULL);
|
||||
|
||||
protocol = (omapi_protocol_object_t *)handle->outer;
|
||||
|
||||
ENSURE(protocol != NULL && protocol->type == omapi_type_protocol);
|
||||
|
||||
connection = (omapi_connection_object_t *)protocol->outer;
|
||||
|
||||
ENSURE(connection != NULL && connection->type == omapi_type_connection);
|
||||
|
||||
omapi_connection_disconnect((omapi_object_t *)connection, force);
|
||||
}
|
||||
|
||||
/*
|
||||
* Send the protocol introduction message.
|
||||
*/
|
||||
@@ -120,7 +138,6 @@ omapi_protocol_send_intro(omapi_object_t *h, unsigned int ver,
|
||||
unsigned int hsize)
|
||||
{
|
||||
isc_result_t result;
|
||||
isc_task_t *task;
|
||||
omapi_protocol_object_t *p;
|
||||
omapi_connection_object_t *connection;
|
||||
|
||||
@@ -130,7 +147,7 @@ omapi_protocol_send_intro(omapi_object_t *h, unsigned int ver,
|
||||
connection = (omapi_connection_object_t *)h->outer;
|
||||
|
||||
if (h->outer == NULL || h->outer->type != omapi_type_connection)
|
||||
return (ISC_R_NOTCONNECTED);
|
||||
return (OMAPI_R_NOTCONNECTED);
|
||||
|
||||
result = omapi_connection_putuint32((omapi_object_t *)connection,
|
||||
ver);
|
||||
@@ -171,7 +188,6 @@ omapi_protocol_send_message(omapi_object_t *po, omapi_object_t *id,
|
||||
omapi_object_t *c;
|
||||
omapi_message_object_t *m;
|
||||
omapi_message_object_t *om;
|
||||
isc_task_t *task;
|
||||
isc_result_t result;
|
||||
|
||||
REQUIRE(po != NULL && po->type == omapi_type_protocol &&
|
||||
@@ -192,7 +208,7 @@ omapi_protocol_send_message(omapi_object_t *po, omapi_object_t *id,
|
||||
/* XXXTL Write the ID of the authentication key we're using. */
|
||||
result = omapi_connection_putuint32(c, 0);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
omapi_disconnect(c, OMAPI_FORCE_DISCONNECT);
|
||||
omapi_connection_disconnect(c, OMAPI_FORCE_DISCONNECT);
|
||||
return (result);
|
||||
}
|
||||
|
||||
@@ -201,7 +217,7 @@ omapi_protocol_send_message(omapi_object_t *po, omapi_object_t *id,
|
||||
*/
|
||||
result = omapi_connection_putuint32(c, m->op);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
omapi_disconnect(c, OMAPI_FORCE_DISCONNECT);
|
||||
omapi_connection_disconnect(c, OMAPI_FORCE_DISCONNECT);
|
||||
return (result);
|
||||
}
|
||||
|
||||
@@ -216,7 +232,7 @@ omapi_protocol_send_message(omapi_object_t *po, omapi_object_t *id,
|
||||
m->object->handle
|
||||
: 0)));
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
omapi_disconnect(c, OMAPI_FORCE_DISCONNECT);
|
||||
omapi_connection_disconnect(c, OMAPI_FORCE_DISCONNECT);
|
||||
return (result);
|
||||
}
|
||||
|
||||
@@ -226,7 +242,7 @@ omapi_protocol_send_message(omapi_object_t *po, omapi_object_t *id,
|
||||
m->id = p->next_xid++;
|
||||
result = omapi_connection_putuint32(c, m->id);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
omapi_disconnect(c, OMAPI_FORCE_DISCONNECT);
|
||||
omapi_connection_disconnect(c, OMAPI_FORCE_DISCONNECT);
|
||||
return (result);
|
||||
}
|
||||
|
||||
@@ -236,7 +252,7 @@ omapi_protocol_send_message(omapi_object_t *po, omapi_object_t *id,
|
||||
*/
|
||||
result = omapi_connection_putuint32(c, om ? om->id : m->rid);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
omapi_disconnect(c, OMAPI_FORCE_DISCONNECT);
|
||||
omapi_connection_disconnect(c, OMAPI_FORCE_DISCONNECT);
|
||||
return (result);
|
||||
}
|
||||
|
||||
@@ -245,7 +261,7 @@ omapi_protocol_send_message(omapi_object_t *po, omapi_object_t *id,
|
||||
*/
|
||||
result = omapi_stuff_values(c, id, (omapi_object_t *)m);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
omapi_disconnect(c, OMAPI_FORCE_DISCONNECT);
|
||||
omapi_connection_disconnect(c, OMAPI_FORCE_DISCONNECT);
|
||||
return (result);
|
||||
}
|
||||
|
||||
@@ -255,7 +271,7 @@ omapi_protocol_send_message(omapi_object_t *po, omapi_object_t *id,
|
||||
*/
|
||||
result = omapi_connection_putuint16(c, 0);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
omapi_disconnect(c, OMAPI_FORCE_DISCONNECT);
|
||||
omapi_connection_disconnect(c, OMAPI_FORCE_DISCONNECT);
|
||||
return (result);
|
||||
}
|
||||
|
||||
@@ -266,7 +282,7 @@ omapi_protocol_send_message(omapi_object_t *po, omapi_object_t *id,
|
||||
if (m->object != NULL) {
|
||||
result = omapi_stuff_values(c, id, m->object);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
omapi_disconnect(c, OMAPI_FORCE_DISCONNECT);
|
||||
omapi_connection_disconnect(c, OMAPI_FORCE_DISCONNECT);
|
||||
return (result);
|
||||
}
|
||||
}
|
||||
@@ -277,7 +293,7 @@ omapi_protocol_send_message(omapi_object_t *po, omapi_object_t *id,
|
||||
*/
|
||||
result = omapi_connection_putuint16(c, 0);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
omapi_disconnect(c, OMAPI_FORCE_DISCONNECT);
|
||||
omapi_connection_disconnect(c, OMAPI_FORCE_DISCONNECT);
|
||||
return (result);
|
||||
}
|
||||
|
||||
@@ -333,13 +349,15 @@ omapi_protocol_signal_handler(omapi_object_t *h, const char *name, va_list ap)
|
||||
* We currently only support the current protocol version.
|
||||
*/
|
||||
if (p->protocol_version != OMAPI_PROTOCOL_VERSION) {
|
||||
omapi_disconnect(connection, OMAPI_FORCE_DISCONNECT);
|
||||
return (ISC_R_VERSIONMISMATCH);
|
||||
omapi_connection_disconnect(connection,
|
||||
OMAPI_FORCE_DISCONNECT);
|
||||
return (OMAPI_R_VERSIONMISMATCH);
|
||||
}
|
||||
|
||||
if (p->header_size < sizeof(omapi_protocol_header_t)) {
|
||||
omapi_disconnect(connection, OMAPI_FORCE_DISCONNECT);
|
||||
return (ISC_R_PROTOCOLERROR);
|
||||
omapi_connection_disconnect(connection,
|
||||
OMAPI_FORCE_DISCONNECT);
|
||||
return (OMAPI_R_PROTOCOLERROR);
|
||||
}
|
||||
|
||||
result = omapi_signal_in(h->inner, "ready");
|
||||
@@ -369,7 +387,8 @@ omapi_protocol_signal_handler(omapi_object_t *h, const char *name, va_list ap)
|
||||
result = omapi_message_new((omapi_object_t **)&p->message,
|
||||
"omapi_protocol_signal_handler");
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
omapi_disconnect(connection, OMAPI_FORCE_DISCONNECT);
|
||||
omapi_connection_disconnect(connection,
|
||||
OMAPI_FORCE_DISCONNECT);
|
||||
return (result);
|
||||
}
|
||||
|
||||
@@ -410,7 +429,7 @@ omapi_protocol_signal_handler(omapi_object_t *h, const char *name, va_list ap)
|
||||
* First we read in message-specific values, then object
|
||||
* values.
|
||||
*/
|
||||
p->reading_message_values = 1;
|
||||
p->reading_message_values = ISC_TRUE;
|
||||
|
||||
need_name_length:
|
||||
/*
|
||||
@@ -431,7 +450,8 @@ omapi_protocol_signal_handler(omapi_object_t *h, const char *name, va_list ap)
|
||||
case omapi_protocol_name_length_wait:
|
||||
result = omapi_connection_getuint16(connection, &nlen);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
omapi_disconnect(connection, OMAPI_FORCE_DISCONNECT);
|
||||
omapi_connection_disconnect(connection,
|
||||
OMAPI_FORCE_DISCONNECT);
|
||||
return (result);
|
||||
}
|
||||
|
||||
@@ -448,7 +468,7 @@ omapi_protocol_signal_handler(omapi_object_t *h, const char *name, va_list ap)
|
||||
* object.
|
||||
*/
|
||||
if (p->reading_message_values) {
|
||||
p->reading_message_values = 0;
|
||||
p->reading_message_values = ISC_FALSE;
|
||||
goto need_name_length;
|
||||
}
|
||||
|
||||
@@ -484,7 +504,8 @@ omapi_protocol_signal_handler(omapi_object_t *h, const char *name, va_list ap)
|
||||
result = omapi_data_newstring(&p->name, nlen,
|
||||
"omapi_protocol_signal_handler");
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
omapi_disconnect(connection, OMAPI_FORCE_DISCONNECT);
|
||||
omapi_connection_disconnect(connection,
|
||||
OMAPI_FORCE_DISCONNECT);
|
||||
return (result);
|
||||
}
|
||||
p->state = omapi_protocol_name_wait;
|
||||
@@ -500,7 +521,8 @@ omapi_protocol_signal_handler(omapi_object_t *h, const char *name, va_list ap)
|
||||
result = omapi_connection_copyout(p->name->value, connection,
|
||||
p->name->len);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
omapi_disconnect(connection, OMAPI_FORCE_DISCONNECT);
|
||||
omapi_connection_disconnect(connection,
|
||||
OMAPI_FORCE_DISCONNECT);
|
||||
return (result);
|
||||
}
|
||||
|
||||
@@ -530,7 +552,8 @@ omapi_protocol_signal_handler(omapi_object_t *h, const char *name, va_list ap)
|
||||
omapi_datatype_data, vlen,
|
||||
"omapi_protocol_signal_handler");
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
omapi_disconnect(connection, OMAPI_FORCE_DISCONNECT);
|
||||
omapi_connection_disconnect(connection,
|
||||
OMAPI_FORCE_DISCONNECT);
|
||||
return (result);
|
||||
}
|
||||
|
||||
@@ -546,12 +569,13 @@ omapi_protocol_signal_handler(omapi_object_t *h, const char *name, va_list ap)
|
||||
connection,
|
||||
p->value->u.buffer.len);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
omapi_disconnect(connection, OMAPI_FORCE_DISCONNECT);
|
||||
omapi_connection_disconnect(connection,
|
||||
OMAPI_FORCE_DISCONNECT);
|
||||
return (result);
|
||||
}
|
||||
|
||||
insert_new_value:
|
||||
if (p->reading_message_values != 0) {
|
||||
if (p->reading_message_values) {
|
||||
result = omapi_set_value((omapi_object_t *)p->message,
|
||||
p->message->id_object,
|
||||
p->name, p->value);
|
||||
@@ -564,7 +588,7 @@ omapi_protocol_signal_handler(omapi_object_t *h, const char *name, va_list ap)
|
||||
result = omapi_generic_new(&p->message->object,
|
||||
"omapi_protocol_signal_handler");
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
omapi_disconnect(connection,
|
||||
omapi_connection_disconnect(connection,
|
||||
OMAPI_FORCE_DISCONNECT);
|
||||
return (result);
|
||||
}
|
||||
@@ -575,7 +599,8 @@ omapi_protocol_signal_handler(omapi_object_t *h, const char *name, va_list ap)
|
||||
p->name, p->value));
|
||||
}
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
omapi_disconnect(connection, OMAPI_FORCE_DISCONNECT);
|
||||
omapi_connection_disconnect(connection,
|
||||
OMAPI_FORCE_DISCONNECT);
|
||||
return (result);
|
||||
}
|
||||
omapi_data_stringdereference(&p->name,
|
||||
@@ -591,14 +616,16 @@ omapi_protocol_signal_handler(omapi_object_t *h, const char *name, va_list ap)
|
||||
p->message->authlen);
|
||||
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
omapi_disconnect(connection, OMAPI_FORCE_DISCONNECT);
|
||||
omapi_connection_disconnect(connection,
|
||||
OMAPI_FORCE_DISCONNECT);
|
||||
return (result);
|
||||
}
|
||||
result = (omapi_connection_copyout
|
||||
(p->message->authenticator->u.buffer.value,
|
||||
connection, p->message->authlen));
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
omapi_disconnect(connection, OMAPI_FORCE_DISCONNECT);
|
||||
omapi_connection_disconnect(connection,
|
||||
OMAPI_FORCE_DISCONNECT);
|
||||
return (result);
|
||||
}
|
||||
|
||||
@@ -611,7 +638,8 @@ omapi_protocol_signal_handler(omapi_object_t *h, const char *name, va_list ap)
|
||||
result = omapi_message_process((omapi_object_t *)p->message,
|
||||
h);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
omapi_disconnect(connection, OMAPI_FORCE_DISCONNECT);
|
||||
omapi_connection_disconnect(connection,
|
||||
OMAPI_FORCE_DISCONNECT);
|
||||
return (result);
|
||||
}
|
||||
|
||||
@@ -641,10 +669,7 @@ omapi_protocol_set_value(omapi_object_t *h, omapi_object_t *id,
|
||||
{
|
||||
REQUIRE(h != NULL && h->type == omapi_type_protocol);
|
||||
|
||||
if (h->inner != NULL && h->inner->type->set_value != NULL)
|
||||
return (*(h->inner->type->set_value))(h->inner, id,
|
||||
name, value);
|
||||
return (ISC_R_NOTFOUND);
|
||||
PASS_SETVALUE(h);
|
||||
}
|
||||
|
||||
isc_result_t
|
||||
@@ -654,10 +679,7 @@ omapi_protocol_get_value(omapi_object_t *h, omapi_object_t *id,
|
||||
{
|
||||
REQUIRE(h != NULL && h->type == omapi_type_protocol);
|
||||
|
||||
if (h->inner != NULL && h->inner->type->get_value != NULL)
|
||||
return (*(h->inner->type->get_value))(h->inner, id,
|
||||
name, value);
|
||||
return (ISC_R_NOTFOUND);
|
||||
PASS_GETVALUE(h);
|
||||
}
|
||||
|
||||
void
|
||||
@@ -681,14 +703,12 @@ omapi_protocol_destroy(omapi_object_t *h, const char *name) {
|
||||
*/
|
||||
|
||||
isc_result_t
|
||||
omapi_protocol_stuff_values(omapi_object_t *c, omapi_object_t *id,
|
||||
omapi_protocol_stuff_values(omapi_object_t *connection, omapi_object_t *id,
|
||||
omapi_object_t *h)
|
||||
{
|
||||
REQUIRE(h != NULL && h->type == omapi_type_protocol);
|
||||
|
||||
if (h->inner != NULL && h->inner->type->stuff_values != NULL)
|
||||
return (*(h->inner->type->stuff_values))(c, id, h->inner);
|
||||
return (ISC_R_SUCCESS);
|
||||
PASS_STUFFVALUES(h);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -739,10 +759,7 @@ omapi_protocol_listener_signal(omapi_object_t *h, const char *name, va_list ap)
|
||||
* Not a signal we recognize?
|
||||
*/
|
||||
if (strcmp(name, "connect") != 0) {
|
||||
if (p->inner != NULL && p->inner->type->signal_handler != NULL)
|
||||
return (*(p->inner->type->signal_handler))(p->inner,
|
||||
name, ap);
|
||||
return (ISC_R_NOTFOUND);
|
||||
PASS_SIGNAL(h);
|
||||
}
|
||||
|
||||
c = va_arg(ap, omapi_object_t *);
|
||||
@@ -768,7 +785,7 @@ omapi_protocol_listener_signal(omapi_object_t *h, const char *name, va_list ap)
|
||||
sizeof(omapi_protocol_header_t));
|
||||
|
||||
if (result != ISC_R_SUCCESS)
|
||||
omapi_disconnect(c, OMAPI_FORCE_DISCONNECT);
|
||||
omapi_connection_disconnect(c, OMAPI_FORCE_DISCONNECT);
|
||||
|
||||
OBJECT_DEREF(&obj, "omapi_protocol_accept");
|
||||
return (result);
|
||||
@@ -781,10 +798,7 @@ omapi_protocol_listener_set_value(omapi_object_t *h, omapi_object_t *id,
|
||||
{
|
||||
REQUIRE(h != NULL && h->type == omapi_type_protocol_listener);
|
||||
|
||||
if (h->inner != NULL && h->inner->type->set_value != NULL)
|
||||
return (*(h->inner->type->set_value))(h->inner, id,
|
||||
name, value);
|
||||
return (ISC_R_NOTFOUND);
|
||||
PASS_SETVALUE(h);
|
||||
}
|
||||
|
||||
isc_result_t
|
||||
@@ -794,10 +808,7 @@ omapi_protocol_listener_get_value(omapi_object_t *h, omapi_object_t *id,
|
||||
{
|
||||
REQUIRE(h != NULL && h->type == omapi_type_protocol_listener);
|
||||
|
||||
if (h->inner != NULL && h->inner->type->get_value != NULL)
|
||||
return (*(h->inner->type->get_value))(h->inner, id,
|
||||
name, value);
|
||||
return (ISC_R_NOTFOUND);
|
||||
PASS_GETVALUE(h);
|
||||
}
|
||||
|
||||
void
|
||||
@@ -813,15 +824,13 @@ omapi_protocol_listener_destroy(omapi_object_t *h, const char *name) {
|
||||
*/
|
||||
|
||||
isc_result_t
|
||||
omapi_protocol_listener_stuff(omapi_object_t *c, omapi_object_t *id,
|
||||
omapi_protocol_listener_stuff(omapi_object_t *connection, omapi_object_t *id,
|
||||
omapi_object_t *h)
|
||||
{
|
||||
|
||||
REQUIRE(h != NULL && h->type == omapi_type_protocol_listener);
|
||||
|
||||
if (h->inner != NULL && h->inner->type->stuff_values != NULL)
|
||||
return (*(h->inner->type->stuff_values)) (c, id, h->inner);
|
||||
return (ISC_R_SUCCESS);
|
||||
PASS_STUFFVALUES(h);
|
||||
}
|
||||
|
||||
isc_result_t
|
||||
|
||||
@@ -89,11 +89,11 @@ omapi_init(isc_mem_t *mctx) {
|
||||
*/
|
||||
result = omapi_object_type_register(&omapi_type_connection,
|
||||
"connection",
|
||||
omapi_connection_set_value,
|
||||
omapi_connection_get_value,
|
||||
omapi_connection_setvalue,
|
||||
omapi_connection_getvalue,
|
||||
omapi_connection_destroy,
|
||||
omapi_connection_signal_handler,
|
||||
omapi_connection_stuff_values,
|
||||
omapi_connection_signalhandler,
|
||||
omapi_connection_stuffvalues,
|
||||
0, 0, 0);
|
||||
if (result != ISC_R_SUCCESS)
|
||||
return (result);
|
||||
@@ -111,11 +111,11 @@ omapi_init(isc_mem_t *mctx) {
|
||||
|
||||
result = omapi_object_type_register(&omapi_type_io_object,
|
||||
"io",
|
||||
omapi_io_set_value,
|
||||
omapi_io_get_value,
|
||||
omapi_io_setvalue,
|
||||
omapi_io_getvalue,
|
||||
omapi_io_destroy,
|
||||
omapi_io_signal_handler,
|
||||
omapi_io_stuff_values,
|
||||
omapi_io_signalhandler,
|
||||
omapi_io_stuffvalues,
|
||||
0, 0, 0);
|
||||
if (result != ISC_R_SUCCESS)
|
||||
return (result);
|
||||
@@ -155,11 +155,11 @@ omapi_init(isc_mem_t *mctx) {
|
||||
|
||||
result = omapi_object_type_register(&omapi_type_message,
|
||||
"message",
|
||||
omapi_message_set_value,
|
||||
omapi_message_get_value,
|
||||
omapi_message_setvalue,
|
||||
omapi_message_getvalue,
|
||||
omapi_message_destroy,
|
||||
omapi_message_signal_handler,
|
||||
omapi_message_stuff_values,
|
||||
omapi_message_signalhandler,
|
||||
omapi_message_stuffvalues,
|
||||
0, 0, 0);
|
||||
if (result != ISC_R_SUCCESS)
|
||||
return (result);
|
||||
|
||||
Reference in New Issue
Block a user