示例#1
0
isc_result_t omapi_auth_key_lookup (omapi_object_t **h,
				    omapi_object_t *id,
				    omapi_object_t *ref)
{
	isc_result_t status;
	omapi_value_t *name = (omapi_value_t *)0;
	omapi_value_t *algorithm = (omapi_value_t *)0;

	if (!auth_key_hash)
		return ISC_R_NOTFOUND;

	if (!ref)
		return ISC_R_NOKEYS;

	status = omapi_get_value_str (ref, id, "name", &name);
	if (status != ISC_R_SUCCESS)
		return status;

	if ((name -> value -> type != omapi_datatype_string) &&
	    (name -> value -> type != omapi_datatype_data)) {
		omapi_value_dereference (&name, MDL);
		return ISC_R_NOTFOUND;
	}

	status = omapi_get_value_str (ref, id, "algorithm", &algorithm);
	if (status != ISC_R_SUCCESS) {
		omapi_value_dereference (&name, MDL);
		return status;
	}

	if ((algorithm -> value -> type != omapi_datatype_string) &&
	    (algorithm -> value -> type != omapi_datatype_data)) {
		omapi_value_dereference (&name, MDL);
		omapi_value_dereference (&algorithm, MDL);
		return ISC_R_NOTFOUND;
	}


	if (!omapi_auth_key_hash_lookup ((omapi_auth_key_t **)h, auth_key_hash,
					 (const char *)
					 name -> value -> u.buffer.value,
					 name -> value -> u.buffer.len, MDL)) {
		omapi_value_dereference (&name, MDL);
		omapi_value_dereference (&algorithm, MDL);
		return ISC_R_NOTFOUND;
	}

	if (omapi_td_strcasecmp (algorithm -> value,
				 ((omapi_auth_key_t *)*h) -> algorithm) != 0) {
		omapi_value_dereference (&name, MDL);
		omapi_value_dereference (&algorithm, MDL);
		omapi_object_dereference (h, MDL);
		return ISC_R_NOTFOUND;
	}

	omapi_value_dereference (&name, MDL);
	omapi_value_dereference (&algorithm, MDL);

	return ISC_R_SUCCESS;
}
示例#2
0
isc_result_t omapi_make_handle_value (omapi_value_t **vp,
				      omapi_data_string_t *name,
				      omapi_object_t *value,
				      const char *file, int line)
{
	isc_result_t status;

	status = omapi_value_new (vp, file, line);
	if (status != ISC_R_SUCCESS)
		return status;

	status = omapi_data_string_reference (&(*vp) -> name,
					      name, file, line);
	if (status != ISC_R_SUCCESS) {
		omapi_value_dereference (vp, file, line);
		return status;
	}
	if (value) {
		status = omapi_typed_data_new (file, line, &(*vp) -> value,
					       omapi_datatype_int);
		if (status != ISC_R_SUCCESS) {
			omapi_value_dereference (vp, file, line);
			return status;
		}
		status = (omapi_object_handle
			  ((omapi_handle_t *)&(*vp) -> value -> u.integer,
			   value));
		if (status != ISC_R_SUCCESS) {
			omapi_value_dereference (vp, file, line);
			return status;
		}
	}
	return ISC_R_SUCCESS;
}
示例#3
0
isc_result_t omapi_make_string_value (omapi_value_t **vp,
				      omapi_data_string_t *name,
				      const char *value,
				      const char *file, int line)
{
	isc_result_t status;

	status = omapi_value_new (vp, file, line);
	if (status != ISC_R_SUCCESS)
		return status;

	status = omapi_data_string_reference (&(*vp) -> name,
					      name, file, line);
	if (status != ISC_R_SUCCESS) {
		omapi_value_dereference (vp, file, line);
		return status;
	}
	if (value) {
		status = omapi_typed_data_new (file, line, &(*vp) -> value,
					       omapi_datatype_string, value);
		if (status != ISC_R_SUCCESS) {
			omapi_value_dereference (vp, file, line);
			return status;
		}
	}
	return ISC_R_SUCCESS;
}
示例#4
0
isc_result_t omapi_make_const_value (omapi_value_t **vp,
				     omapi_data_string_t *name,
				     const unsigned char *value,
				     unsigned len,
				     const char *file, int line)
{
	isc_result_t status;

	status = omapi_value_new (vp, file, line);
	if (status != ISC_R_SUCCESS)
		return status;

	status = omapi_data_string_reference (&(*vp) -> name,
					      name, file, line);
	if (status != ISC_R_SUCCESS) {
		omapi_value_dereference (vp, file, line);
		return status;
	}
	if (value) {
		status = omapi_typed_data_new (file, line, &(*vp) -> value,
					       omapi_datatype_data, len);
		if (status != ISC_R_SUCCESS) {
			omapi_value_dereference (vp, file, line);
			return status;
		}
		memcpy ((*vp) -> value -> u.buffer.value, value, len);
	}
	return ISC_R_SUCCESS;
}
示例#5
0
isc_result_t omapi_auth_key_get_value (omapi_object_t *h,
				       omapi_object_t *id,
				       omapi_data_string_t *name,
				       omapi_value_t **value)
{
	omapi_auth_key_t *a;
	isc_result_t status;

	if (h -> type != omapi_type_auth_key)
		return ISC_R_UNEXPECTED;
	a = (omapi_auth_key_t *)h;

	if (omapi_ds_strcmp (name, "name") == 0) {
		if (a -> name)
			return omapi_make_string_value
				(value, name, a -> name, MDL);
		else
			return ISC_R_NOTFOUND;
	} else if (omapi_ds_strcmp (name, "key") == 0) {
		if (a -> key) {
			status = omapi_value_new (value, MDL);
			if (status != ISC_R_SUCCESS)
				return status;

			status = omapi_data_string_reference
				(&(*value) -> name, name, MDL);
			if (status != ISC_R_SUCCESS) {
				omapi_value_dereference (value, MDL);
				return status;
			}

			status = omapi_typed_data_new (MDL, &(*value) -> value,
						       omapi_datatype_data,
						       a -> key -> len);
			if (status != ISC_R_SUCCESS) {
				omapi_value_dereference (value, MDL);
				return status;
			}

			memcpy ((*value) -> value -> u.buffer.value,
				a -> key -> value, a -> key -> len);
			return ISC_R_SUCCESS;
		} else
			return ISC_R_NOTFOUND;
	} else if (omapi_ds_strcmp (name, "algorithm") == 0) {
		if (a -> algorithm)
			return omapi_make_string_value
				(value, name, a -> algorithm, MDL);
		else
			return ISC_R_NOTFOUND;
	}

	return ISC_R_SUCCESS;
}
示例#6
0
isc_result_t dhcp_control_lookup (omapi_object_t **lp,
				  omapi_object_t *id, omapi_object_t *ref)
{
	omapi_value_t *tv = (omapi_value_t *)0;
	isc_result_t status;
	dhcp_control_object_t *control;

	/* First see if we were sent a handle. */
	if (ref) {
		status = omapi_get_value_str (ref, id, "handle", &tv);
		if (status == ISC_R_SUCCESS) {
			status = omapi_handle_td_lookup (lp, tv -> value);
			
			omapi_value_dereference (&tv, MDL);
			if (status != ISC_R_SUCCESS)
				return status;
			
			/* Don't return the object if the type is wrong. */
			if ((*lp) -> type != dhcp_type_control) {
				omapi_object_dereference (lp, MDL);
				return ISC_R_INVALIDARG;
			}
		}
	}

	/* Otherwise, stop playing coy - there's only one control object,
	   so we can just return it. */
	dhcp_control_reference ((dhcp_control_object_t **)lp,
				dhcp_control_object, MDL);
	return ISC_R_SUCCESS;
}
示例#7
0
dhcpctl_status dhcpctl_get_value (dhcpctl_data_string *result,
				  dhcpctl_handle h, const char *value_name)
{
	isc_result_t status;
	omapi_value_t *tv = (omapi_value_t *)0;
	omapi_data_string_t *value = (omapi_data_string_t *)0;
	unsigned len;
	int ip;

	status = omapi_get_value_str (h, (omapi_object_t *)0, value_name, &tv);
	if (status != ISC_R_SUCCESS)
		return status;

	switch (tv -> value -> type) {
	      case omapi_datatype_int:
		len = sizeof (int);
		break;

	      case omapi_datatype_string:
	      case omapi_datatype_data:
		len = tv -> value -> u.buffer.len;
		break;

	      case omapi_datatype_object:
		len = sizeof (omapi_handle_t);
		break;

	      default:
		omapi_typed_data_dereference (&tv -> value, MDL);
		return ISC_R_UNEXPECTED;
	}

	status = omapi_data_string_new (result, len, MDL);
	if (status != ISC_R_SUCCESS) {
		omapi_typed_data_dereference (&tv -> value, MDL);
		return status;
	}

	switch (tv -> value -> type) {
	      case omapi_datatype_int:
		ip = htonl (tv -> value -> u.integer);
		memcpy ((*result) -> value, &ip, sizeof ip);
		break;

	      case omapi_datatype_string:
	      case omapi_datatype_data:
		memcpy ((*result) -> value,
			tv -> value -> u.buffer.value,
			tv -> value -> u.buffer.len);
		break;

	      case omapi_datatype_object:
		ip = htonl (tv -> value -> u.object -> handle);
		memcpy ((*result) -> value, &ip, sizeof ip);
		break;
	}

	omapi_value_dereference (&tv, MDL);
	return ISC_R_SUCCESS;
}
示例#8
0
isc_result_t dhcp_group_lookup (omapi_object_t **lp,
				omapi_object_t *id, omapi_object_t *ref)
{
	omapi_value_t *tv = (omapi_value_t *)0;
	isc_result_t status;
	struct group_object *group;

	if (!ref)
		return ISC_R_NOKEYS;

	/* First see if we were sent a handle. */
	status = omapi_get_value_str (ref, id, "handle", &tv);
	if (status == ISC_R_SUCCESS) {
		status = omapi_handle_td_lookup (lp, tv -> value);

		omapi_value_dereference (&tv, MDL);
		if (status != ISC_R_SUCCESS)
			return status;

		/* Don't return the object if the type is wrong. */
		if ((*lp) -> type != dhcp_type_group) {
			omapi_object_dereference (lp, MDL);
			return ISC_R_INVALIDARG;
		}
	}

	/* Now look for a name. */
	status = omapi_get_value_str (ref, id, "name", &tv);
	if (status == ISC_R_SUCCESS) {
		group = (struct group_object *)0;
		if (group_name_hash &&
		    group_hash_lookup (&group, group_name_hash,
				       (const char *)
				       tv -> value -> u.buffer.value,
				       tv -> value -> u.buffer.len, MDL)) {
			omapi_value_dereference (&tv, MDL);

			if (*lp && *lp != (omapi_object_t *)group) {
			    group_object_dereference (&group, MDL);
			    omapi_object_dereference (lp, MDL);
			    return ISC_R_KEYCONFLICT;
			} else if (!*lp) {
			    /* XXX fix so that hash lookup itself creates
			       XXX the reference. */
			    omapi_object_reference (lp,
						    (omapi_object_t *)group,
						    MDL);
			    group_object_dereference (&group, MDL);
			}
		} else if (!*lp)
			return ISC_R_NOTFOUND;
	}

	/* If we get to here without finding a group, no valid key was
	   specified. */
	if (!*lp)
		return ISC_R_NOKEYS;

	if (((struct group_object *)(*lp)) -> flags & GROUP_OBJECT_DELETED) {
		omapi_object_dereference (lp, MDL);
		return ISC_R_NOTFOUND;
	}
	return ISC_R_SUCCESS;
}
示例#9
0
isc_result_t omapi_one_dispatch (omapi_object_t *wo,
				 struct timeval *t)
{
	fd_set r, w, x, rr, ww, xx;
	int max = 0;
	int count;
	int desc;
	struct timeval now, to;
	omapi_io_object_t *io, *prev, *next;
	omapi_waiter_object_t *waiter;
	omapi_object_t *tmp = (omapi_object_t *)0;
	isc_result_t status;

	if (!wo || wo -> type != omapi_type_waiter)
		waiter = (omapi_waiter_object_t *)0;
	else
		waiter = (omapi_waiter_object_t *)wo;

	FD_ZERO (&x);

	/* First, see if the timeout has expired, and if so return. */
	if (t) {
		gettimeofday (&now, (struct timezone *)0);
		cur_tv.tv_sec = now.tv_sec;
		cur_tv.tv_usec = now.tv_usec;
		if (now.tv_sec > t -> tv_sec ||
		    (now.tv_sec == t -> tv_sec && now.tv_usec >= t -> tv_usec))
			return ISC_R_TIMEDOUT;
			
		/* We didn't time out, so figure out how long until
		   we do. */
		to.tv_sec = t -> tv_sec - now.tv_sec;
		to.tv_usec = t -> tv_usec - now.tv_usec;
		if (to.tv_usec < 0) {
			to.tv_usec += 1000000;
			to.tv_sec--;
		}

		/* It is possible for the timeout to get set larger than
		   the largest time select() is willing to accept.
		   Restricting the timeout to a maximum of one day should
		   work around this.  -DPN.  (Ref: Bug #416) */
		if (to.tv_sec > (60 * 60 * 24))
			to.tv_sec = 60 * 60 * 24;
	}
	
	/* If the object we're waiting on has reached completion,
	   return now. */
	if (waiter && waiter -> ready)
		return ISC_R_SUCCESS;
	
      again:
	/* If we have no I/O state, we can't proceed. */
	if (!(io = omapi_io_states.next))
		return ISC_R_NOMORE;

	/* Set up the read and write masks. */
	FD_ZERO (&r);
	FD_ZERO (&w);

	for (; io; io = io -> next) {
		/* Check for a read socket.   If we shouldn't be
		   trying to read for this I/O object, either there
		   won't be a readfd function, or it'll return -1. */
		if (io -> readfd && io -> inner &&
		    (desc = (*(io -> readfd)) (io -> inner)) >= 0) {
			FD_SET (desc, &r);
			if (desc > max)
				max = desc;
		}
		
		/* Same deal for write fdets. */
		if (io -> writefd && io -> inner &&
		    (desc = (*(io -> writefd)) (io -> inner)) >= 0) {
			FD_SET (desc, &w);
			if (desc > max)
				max = desc;
		}
	}

	/* poll if all reader are dry */ 
	now.tv_sec = 0;
	now.tv_usec = 0;
	rr=r; 
	ww=w; 
	xx=x;

	/* poll once */
	count = select(max + 1, &r, &w, &x, &now);
	if (!count) {  
		/* We are dry now */ 
		trigger_event(&rw_queue_empty);
		/* Wait for a packet or a timeout... XXX */
		r = rr;
		w = ww;
		x = xx;
		count = select(max + 1, &r, &w, &x, t ? &to : NULL);
	}

	/* Get the current time... */
	gettimeofday (&cur_tv, (struct timezone *)0);

	/* We probably have a bad file descriptor.   Figure out which one.
	   When we find it, call the reaper function on it, which will
	   maybe make it go away, and then try again. */
	if (count < 0) {
		struct timeval t0;
		omapi_io_object_t *prev = (omapi_io_object_t *)0;
		io = (omapi_io_object_t *)0;
		if (omapi_io_states.next)
			omapi_io_reference (&io, omapi_io_states.next, MDL);

		while (io) {
			omapi_object_t *obj;
			FD_ZERO (&r);
			FD_ZERO (&w);
			t0.tv_sec = t0.tv_usec = 0;

			if (io -> readfd && io -> inner &&
			    (desc = (*(io -> readfd)) (io -> inner)) >= 0) {
			    FD_SET (desc, &r);
			    count = select (desc + 1, &r, &w, &x, &t0);
			   bogon:
			    if (count < 0) {
				log_error ("Bad descriptor %d.", desc);
				for (obj = (omapi_object_t *)io;
				     obj -> outer;
				     obj = obj -> outer)
					;
				for (; obj; obj = obj -> inner) {
				    omapi_value_t *ov;
				    int len;
				    const char *s;
				    ov = (omapi_value_t *)0;
				   status = omapi_get_value_str (obj,
							 (omapi_object_t *)0,
							 "name", &ov);
				   if(status!=ISC_R_SUCCESS){
						log_error("omapi_get_value_str failed!\n");
				   }
				    if (ov && ov -> value &&
					(ov -> value -> type ==
					 omapi_datatype_string)) {
					s = (char *)
						ov -> value -> u.buffer.value;
					len = ov -> value -> u.buffer.len;
				    } else {
					s = "";
					len = 0;
				    }
				    log_error ("Object %lx %s%s%.*s",
					       (unsigned long)obj,
					       obj -> type -> name,
					       len ? " " : "",
					       len, s);
				    if (len)
					omapi_value_dereference (&ov, MDL);
				}
				(*(io -> reaper)) (io -> inner);
				if (prev) {
				    omapi_io_dereference (&prev -> next, MDL);
				    if (io -> next)
					omapi_io_reference (&prev -> next,
							    io -> next, MDL);
				} else {
				    omapi_io_dereference
					    (&omapi_io_states.next, MDL);
				    if (io -> next)
					omapi_io_reference
						(&omapi_io_states.next,
						 io -> next, MDL);
				}
				omapi_io_dereference (&io, MDL);
				goto again;
			    }
			}
			
			FD_ZERO (&r);
			FD_ZERO (&w);
			t0.tv_sec = t0.tv_usec = 0;

			/* Same deal for write fdets. */
			if (io -> writefd && io -> inner &&
			    (desc = (*(io -> writefd)) (io -> inner)) >= 0) {
				FD_SET (desc, &w);
				count = select (desc + 1, &r, &w, &x, &t0);
				if (count < 0)
					goto bogon;
			}
			if (prev)
				omapi_io_dereference (&prev, MDL);
			omapi_io_reference (&prev, io, MDL);
			omapi_io_dereference (&io, MDL);
			if (prev -> next)
			    omapi_io_reference (&io, prev -> next, MDL);
		}
		if (prev)
			omapi_io_dereference (&prev, MDL);
		
	}

	for (io = omapi_io_states.next; io; io = io -> next) {
		if (!io -> inner)
			continue;
		omapi_object_reference (&tmp, io -> inner, MDL);
		/* Check for a read descriptor, and if there is one,
		   see if we got input on that socket. */
		if (io -> readfd &&
		    (desc = (*(io -> readfd)) (tmp)) >= 0) {
			if (FD_ISSET (desc, &r))
				((*(io -> reader)) (tmp));
		}
		
		/* Same deal for write descriptors. */
		if (io -> writefd &&
		    (desc = (*(io -> writefd)) (tmp)) >= 0)
		{
			if (FD_ISSET (desc, &w))
				((*(io -> writer)) (tmp));
		}
		omapi_object_dereference (&tmp, MDL);
	}

	/* Now check for I/O handles that are no longer valid,
	   and remove them from the list. */
	prev = NULL;
	io = NULL;
	if (omapi_io_states.next != NULL) {
		omapi_io_reference(&io, omapi_io_states.next, MDL);
	}
	while (io != NULL) {
		if ((io->inner == NULL) || 
		    ((io->reaper != NULL) && 
		     ((io->reaper)(io->inner) != ISC_R_SUCCESS))) 
		{

			omapi_io_object_t *tmp = NULL;
			/* Save a reference to the next
			   pointer, if there is one. */
			if (io->next != NULL) {
				omapi_io_reference(&tmp, io->next, MDL);
				omapi_io_dereference(&io->next, MDL);
			}
			if (prev != NULL) {
				omapi_io_dereference(&prev->next, MDL);
				if (tmp != NULL)
					omapi_io_reference(&prev->next,
							   tmp, MDL);
			} else {
				omapi_io_dereference(&omapi_io_states.next, 
						     MDL);
				if (tmp != NULL)
					omapi_io_reference
					    (&omapi_io_states.next,
					     tmp, MDL);
				else
					omapi_signal_in(
							(omapi_object_t *)
						 	&omapi_io_states,
							"ready");
			}
			if (tmp != NULL)
				omapi_io_dereference(&tmp, MDL);

		} else {

			if (prev != NULL) {
				omapi_io_dereference(&prev, MDL);
			}
			omapi_io_reference(&prev, io, MDL);

		}

		/*
		 * Equivalent to:
		 *   io = io->next
		 * But using our reference counting voodoo.
		 */
		next = NULL;
		if (io->next != NULL) {
			omapi_io_reference(&next, io->next, MDL);
		}
		omapi_io_dereference(&io, MDL);
		if (next != NULL) {
			omapi_io_reference(&io, next, MDL);
			omapi_io_dereference(&next, MDL);
		}
	}
	if (prev != NULL) {
		omapi_io_dereference(&prev, MDL);
	}

	return ISC_R_SUCCESS;
}
示例#10
0
isc_result_t omapi_protocol_signal_handler (omapi_object_t *h,
					    const char *name, va_list ap)
{
	isc_result_t status;
	omapi_protocol_object_t *p;
	omapi_object_t *c;
	omapi_message_object_t *m;
	omapi_value_t *signature;
	u_int16_t nlen;
	u_int32_t vlen;
	u_int32_t th;
#if defined (DEBUG_MEMORY_LEAKAGE)
	unsigned long previous_outstanding = 0xDEADBEEF;
	unsigned long connect_outstanding = 0xDEADBEEF;
#endif

	if (h -> type != omapi_type_protocol) {
		/* XXX shouldn't happen.   Put an assert here? */
		return ISC_R_UNEXPECTED;
	}
	p = (omapi_protocol_object_t *)h;

	if (!strcmp (name, "connect")) {
#if defined (DEBUG_MEMORY_LEAKAGE)
		connect_outstanding = dmalloc_outstanding;
#endif
		/* Send the introductory message. */
		status = omapi_protocol_send_intro
			(h, OMAPI_PROTOCOL_VERSION,
			 sizeof (omapi_protocol_header_t));
		if (status != ISC_R_SUCCESS) {
			omapi_disconnect (p -> outer, 1);
			return status;
		}
		return ISC_R_SUCCESS;
	}

	/* Should only receive these when opening the initial authenticator. */
	if (!strcmp (name, "status")) {
		status = va_arg (ap, isc_result_t);
		if (status != ISC_R_SUCCESS) {
			omapi_signal_in (h -> inner, "status", status,
					 (omapi_object_t *)0);
			omapi_disconnect (p -> outer, 1);
			return status;
		} else {
			return omapi_signal_in (h -> inner, "ready");
		}
	}

	/* If we get a disconnect, dump memory usage. */
	if (!strcmp (name, "disconnect")) {
#if defined (DEBUG_MEMORY_LEAKAGE)
	    if (connect_outstanding != 0xDEADBEEF) {
		log_info ("generation %ld: %ld new, %ld outstanding, %ld%s",
			  dmalloc_generation,
			  dmalloc_outstanding - previous_outstanding,
			  dmalloc_outstanding, dmalloc_longterm, " long-term");
	    }
#endif
#if defined (DEBUG_MEMORY_LEAKAGE)
	    dmalloc_dump_outstanding ();
#endif
#if defined (DEBUG_RC_HISTORY_EXHAUSTIVELY)
	    dump_rc_history ();
#endif
	    for (m = omapi_registered_messages; m; m = m -> next) {
		if (m -> protocol_object == p) {
		    if (m -> object)
			omapi_signal (m -> object, "disconnect");
		}
	    }
	}

	/* Not a signal we recognize? */
	if (strcmp (name, "ready")) {
		if (p -> inner && p -> inner -> type -> signal_handler)
			return (*(p -> inner -> type -> signal_handler)) (h,
									  name,
									  ap);
		return ISC_R_NOTFOUND;
	}

	if (!p -> outer || p -> outer -> type != omapi_type_connection)
		return ISC_R_INVALIDARG;
	c = p -> outer;

	/* We get here because we requested that we be woken up after
           some number of bytes were read, and that number of bytes
           has in fact been read. */
	switch (p -> state) {
	      case omapi_protocol_intro_wait:
		/* Get protocol version and header size in network
		   byte order. */
		omapi_connection_get_uint32 (c, &p -> protocol_version);
		omapi_connection_get_uint32 (c, &p -> header_size);
	
		/* We currently only support the current protocol version. */
		if (p -> protocol_version != OMAPI_PROTOCOL_VERSION) {
			omapi_disconnect (c, 1);
			return ISC_R_VERSIONMISMATCH;
		}

		if (p -> header_size < sizeof (omapi_protocol_header_t)) {
			omapi_disconnect (c, 1);
			return ISC_R_PROTOCOLERROR;
		}

		if (p -> default_auth) {
			status = omapi_protocol_send_open
				(h, (omapi_object_t *)0, "authenticator",
				 p -> default_auth -> a,
				 OMAPI_NOTIFY_PROTOCOL);
			if (status != ISC_R_SUCCESS) {
				omapi_disconnect (c, 1);
				return status;
			}
		} else {
			status = omapi_signal_in (h -> inner, "ready");
		}

	      to_header_wait:
		/* The next thing we're expecting is a message header. */
		p -> state = omapi_protocol_header_wait;

		/* Register a need for the number of bytes in a
		   header, and if we already have that many, process
		   them immediately. */
		if ((omapi_connection_require (c, p -> header_size)) !=
		    ISC_R_SUCCESS)
			break;
		/* If we already have the data, fall through. */

	      case omapi_protocol_header_wait:
#if defined (DEBUG_MEMORY_LEAKAGE)
		if (previous_outstanding != 0xDEADBEEF) {
			log_info ("%s %ld: %ld new, %ld outstanding, %ld%s",
				  "generation", dmalloc_generation,
				  dmalloc_outstanding - previous_outstanding,
				  dmalloc_outstanding, dmalloc_longterm,
				  " long-term");
#endif
#if (defined (DEBUG_MEMORY_LEAKAGE) || defined (DEBUG_MALLOC_POOL))
			dmalloc_dump_outstanding ();
#endif
#if defined (DEBUG_RC_HISTORY_EXHAUSTIVELY)
			dump_rc_history ();
#endif
#if defined (DEBUG_MEMORY_LEAKAGE)
		}
		previous_outstanding = dmalloc_outstanding;
#endif
		status = omapi_message_new ((omapi_object_t **)&p -> message,
					    MDL);
		if (status != ISC_R_SUCCESS) {
			omapi_disconnect (c, 1);
			return status;
		}

		p -> verify_result = ISC_R_SUCCESS;

		/* Swap in the header... */
		omapi_connection_get_uint32 (c, &p -> message -> authid);

		/* Bind the authenticator to the message object. */
		if (p -> message -> authid) {
			status = (omapi_protocol_lookup_auth
				  (&p -> message -> id_object, h,
				   p -> message -> authid));
			if (status != ISC_R_SUCCESS)
				p -> verify_result = status;

			/* Activate the authentication key. */
			status = omapi_set_object_value
				(c, (omapi_object_t *)0, "input-authenticator",
				 p -> message -> id_object);
			if (status != ISC_R_SUCCESS) {
				omapi_disconnect (c, 1);
				return status;
			}
		}

		omapi_connection_get_uint32 (c, &p -> message -> authlen);
		omapi_connection_get_uint32 (c, &p -> message -> op);
		omapi_connection_get_uint32 (c, &th);
		p -> message -> h = th;
		omapi_connection_get_uint32 (c, &p -> message -> id);
		omapi_connection_get_uint32 (c, &p -> message -> rid);

		/* If there was any extra header data, skip over it. */
		if (p -> header_size > sizeof (omapi_protocol_header_t)) {
			omapi_connection_copyout
				(0, c, (p -> header_size -
					sizeof (omapi_protocol_header_t)));
		}
						     
		/* XXX must compute partial signature across the
                   XXX preceding bytes.    Also, if authenticator
		   specifies encryption as well as signing, we may
		   have to decrypt the data on the way in. */

		/* First we read in message-specific values, then object
		   values. */
		p -> reading_message_values = 1;

	      need_name_length:
		/* The next thing we're expecting is length of the
		   first name. */
		p -> state = omapi_protocol_name_length_wait;

		/* Wait for a 16-bit length. */
		if ((omapi_connection_require (c, 2)) != ISC_R_SUCCESS)
			break;
		/* If it's already here, fall through. */

	      case omapi_protocol_name_length_wait:
		omapi_connection_get_uint16 (c, &nlen);
		/* A zero-length name means that we're done reading name+value
		   pairs. */
		if (nlen == 0) {
			/* If we've already read in the object, we are
			   done reading the message, but if we've just
			   finished reading in the values associated
			   with the message, we need to read the
			   object. */
			if (p -> reading_message_values) {
				p -> reading_message_values = 0;
				goto need_name_length;
			}

			/* If the authenticator length is zero, there's no
			   signature to read in, so go straight to processing
			   the message. */
			if (p -> message -> authlen == 0)
				goto message_done;

			/* The next thing we're expecting is the
                           message signature. */
			p -> state = omapi_protocol_signature_wait;

			/* Wait for the number of bytes specified for
			   the authenticator.  If we already have it,
			   go read it in. */
			if (omapi_connection_require
			    (c, p -> message -> authlen) == ISC_R_SUCCESS)
				goto signature_wait;
			break;
		}

		/* Allocate a buffer for the name. */
		status = (omapi_data_string_new (&p -> name, nlen, MDL));
		if (status != ISC_R_SUCCESS) {
			omapi_disconnect (c, 1);
			return ISC_R_NOMEMORY;
		}
		p -> state = omapi_protocol_name_wait;
		if (omapi_connection_require (c, nlen) != ISC_R_SUCCESS)
			break;
		/* If it's already here, fall through. */
					     
	      case omapi_protocol_name_wait:
		omapi_connection_copyout (p -> name -> value, c,
					  p -> name -> len);
		/* Wait for a 32-bit length. */
		p -> state = omapi_protocol_value_length_wait;
		if ((omapi_connection_require (c, 4)) != ISC_R_SUCCESS)
			break;
		/* If it's already here, fall through. */

	      case omapi_protocol_value_length_wait:
		omapi_connection_get_uint32 (c, &vlen);

		/* Zero-length values are allowed - if we get one, we
		   don't have to read any data for the value - just
		   get the next one, if there is a next one. */
		if (!vlen)
			goto insert_new_value;

		status = omapi_typed_data_new (MDL, &p -> value,
					       omapi_datatype_data,
					       vlen);
		if (status != ISC_R_SUCCESS) {
			omapi_disconnect (c, 1);
			return ISC_R_NOMEMORY;
		}

		p -> state = omapi_protocol_value_wait;
		if (omapi_connection_require (c, vlen) != ISC_R_SUCCESS)
			break;
		/* If it's already here, fall through. */
					     
	      case omapi_protocol_value_wait:
		omapi_connection_copyout (p -> value -> u.buffer.value, c,
					  p -> value -> u.buffer.len);

	      insert_new_value:
		if (p -> reading_message_values) {
			status = (omapi_set_value
				  ((omapi_object_t *)p -> message,
				   p -> message -> id_object,
				   p -> name, p -> value));
		} else {
			if (!p -> message -> object) {
				/* We need a generic object to hang off of the
				   incoming message. */
				status = (omapi_generic_new
					  (&p -> message -> object, MDL));
				if (status != ISC_R_SUCCESS) {
					omapi_disconnect (c, 1);
					return status;
				}
			}
			status = (omapi_set_value
				  ((omapi_object_t *)p -> message -> object,
				   p -> message -> id_object,
				   p -> name, p -> value));
		}
		if (status != ISC_R_SUCCESS) {
			omapi_disconnect (c, 1);
			return status;
		}
		omapi_data_string_dereference (&p -> name, MDL);
		if (p -> value)
			omapi_typed_data_dereference (&p -> value, MDL);
		goto need_name_length;

	      signature_wait:
	      case omapi_protocol_signature_wait:
		if (p -> message -> id_object) {
			/* Compute the signature of the message. */
			signature = (omapi_value_t *)0;
			status = omapi_get_value_str (c, (omapi_object_t *)0,
						      "input-signature",
						      &signature);
			if (status != ISC_R_SUCCESS) {
				omapi_disconnect (c, 1);
				return status;
			}

			/* Disable the authentication key on the connection. */
			status = omapi_set_value_str (c, (omapi_object_t *)0,
						      "input-authenticator",
						      (omapi_typed_data_t *)0);
			if (status != ISC_R_SUCCESS) {
				omapi_value_dereference (&signature, MDL);
				omapi_disconnect (c, 1);
				return status;
			}
		}

		/* Read the authenticator. */
		status = omapi_typed_data_new (MDL,
					       &p -> message -> authenticator,
					       omapi_datatype_data,
					       p -> message -> authlen);
			
		if (status != ISC_R_SUCCESS) {
			omapi_value_dereference (&signature, MDL);
			omapi_disconnect (c, 1);
			return ISC_R_NOMEMORY;
		}
		omapi_connection_copyout
			(p -> message -> authenticator -> u.buffer.value, c,
			 p -> message -> authlen);

		/* Verify the signature. */
		if (p -> message -> id_object &&
		    ((signature -> value -> u.buffer.len !=
		      p -> message -> authlen) ||
		     (memcmp (signature -> value -> u.buffer.value,
			      p -> message -> authenticator -> u.buffer.value,
			      p -> message -> authlen) != 0))) {
			/* Invalid signature. */
			p -> verify_result = ISC_R_INVALIDKEY;
		}

		omapi_value_dereference (&signature, MDL);

		/* Process the message. */
	      message_done:
		if (p -> verify_result != ISC_R_SUCCESS) {
			status = omapi_protocol_send_status
				(h, (omapi_object_t *)0, p -> verify_result,
				 p -> message -> id, (char *)0);
		} else {
			status = omapi_message_process
				((omapi_object_t *)p -> message, h);
		}
		if (status != ISC_R_SUCCESS) {
			omapi_disconnect (c, 1);
			return ISC_R_NOMEMORY;
		}

		omapi_message_dereference (&p -> message, MDL);
#if defined (DEBUG_MEMORY_LEAKAGE)
		log_info ("generation %ld: %ld new, %ld outstanding, %ld%s",
			  dmalloc_generation,
			  dmalloc_outstanding - previous_outstanding,
			  dmalloc_outstanding, dmalloc_longterm, " long-term");
#endif
#if (defined (DEBUG_MEMORY_LEAKAGE) || defined (DEBUG_MALLOC_POOL))
		dmalloc_dump_outstanding ();
#endif
#if defined (DEBUG_RC_HISTORY_EXHAUSTIVELY)
		dump_rc_history ();
#endif
#if defined (DEBUG_MEMORY_LEAKAGE)
		previous_outstanding = 0xDEADBEEF;
#endif
		/* Now wait for the next message. */
		goto to_header_wait;		

	      default:
		/* XXX should never get here.   Assertion? */
		break;
	}
	return ISC_R_SUCCESS;
}
示例#11
0
isc_result_t omapi_protocol_send_message (omapi_object_t *po,
					  omapi_object_t *id,
					  omapi_object_t *mo,
					  omapi_object_t *omo)
{
	omapi_protocol_object_t *p;
	omapi_object_t *c;
	omapi_message_object_t *m, *om;
	omapi_remote_auth_t *ra;
	omapi_value_t *signature;
	isc_result_t status;
	u_int32_t foo;
	unsigned auth_len;

	if (po -> type != omapi_type_protocol ||
	    !po -> outer || po -> outer -> type != omapi_type_connection ||
	    mo -> type != omapi_type_message)
		return ISC_R_INVALIDARG;
	if (omo && omo -> type != omapi_type_message)
		return ISC_R_INVALIDARG;
	p = (omapi_protocol_object_t *)po;
	c = (omapi_object_t *)(po -> outer);
	m = (omapi_message_object_t *)mo;
	om = (omapi_message_object_t *)omo;

#ifdef DEBUG_PROTOCOL
	log_debug ("omapi_protocol_send_message()"
		   "op=%ld  handle=%#lx  id=%#lx  rid=%#lx",
		   (long)m -> op,
		   (long)(m -> object ? m -> object -> handle : m -> handle),
		   (long)p -> next_xid, (long)m -> rid);
#endif

	/* Find the authid to use for this message. */
	if (id) {
		for (ra = p -> remote_auth_list; ra; ra = ra -> next) {
			if (ra -> a == id) {
				break;
			}
		}

		if (!ra)
			return ISC_R_KEY_UNKNOWN;
	} else if (p -> remote_auth_list) {
		ra = p -> default_auth;
	} else {
		ra = (omapi_remote_auth_t *)0;
	}

	if (ra) {
		m -> authid = ra -> remote_handle;
		status = omapi_object_reference (&m -> id_object,
						 ra -> a, MDL);
		if (status != ISC_R_SUCCESS)
			return status;
	}

	/* Write the ID of the authentication key we're using. */
	status = omapi_connection_put_uint32 (c, ra ? ra -> remote_handle : 0);
	if (status != ISC_R_SUCCESS) {
		omapi_disconnect (c, 1);
		return status;
	}

	/* Activate the authentication key on the connection. */
	auth_len = 0;
	if (ra) {
		status = omapi_set_object_value (c, (omapi_object_t *)0,
						 "output-authenticator",
						 ra -> a);
		if (status != ISC_R_SUCCESS) {
			omapi_disconnect (c, 1);
			return status;
		}

		status = omapi_connection_output_auth_length (c, &auth_len);
		if (status != ISC_R_SUCCESS) {
			omapi_disconnect (c, 1);
			return status;
		}
	}

	/* Write the authenticator length */
	status = omapi_connection_put_uint32 (c, auth_len);
	if (status != ISC_R_SUCCESS) {
		omapi_disconnect (c, 1);
		return status;
	}

	/* Write the opcode. */
	status = omapi_connection_put_uint32 (c, m -> op);
	if (status != ISC_R_SUCCESS) {
		omapi_disconnect (c, 1);
		return status;
	}

	/* Write the handle.  If we've been given an explicit handle, use
	   that.   Otherwise, use the handle of the object we're sending.
	   The caller is responsible for arranging for one of these handles
	   to be set (or not). */
	status = omapi_connection_put_uint32 (c, (m -> h
						  ? m -> h
						  : (m -> object
						     ? m -> object -> handle
						     : 0)));
	if (status != ISC_R_SUCCESS) {
		omapi_disconnect (c, 1);
		return status;
	}

	/* Set and write the transaction ID. */
	m -> id = p -> next_xid++;
	status = omapi_connection_put_uint32 (c, m -> id);
	if (status != ISC_R_SUCCESS) {
		omapi_disconnect (c, 1);
		return status;
	}

	/* Write the transaction ID of the message to which this is a
	   response, if there is such a message. */
	status = omapi_connection_put_uint32 (c, om ? om -> id : m -> rid);
	if (status != ISC_R_SUCCESS) {
		omapi_disconnect (c, 1);
		return status;
	}

	/* Stuff out the name/value pairs specific to this message. */
	status = omapi_stuff_values (c, id, (omapi_object_t *)m);
	if (status != ISC_R_SUCCESS) {
		omapi_disconnect (c, 1);
		return status;
	}

	/* Write the zero-length name that terminates the list of name/value
	   pairs specific to the message. */
	status = omapi_connection_put_uint16 (c, 0);
	if (status != ISC_R_SUCCESS) {
		omapi_disconnect (c, 1);
		return status;
	}

	/* Stuff out all the published name/value pairs in the object that's
	   being sent in the message, if there is one. */
	if (m -> object) {
		status = omapi_stuff_values (c, id, m -> object);
		if (status != ISC_R_SUCCESS) {
			omapi_disconnect (c, 1);
			return status;
		}
	}

	/* Write the zero-length name that terminates the list of name/value
	   pairs for the associated object. */
	status = omapi_connection_put_uint16 (c, 0);
	if (status != ISC_R_SUCCESS) {
		omapi_disconnect (c, 1);
		return status;
	}

	if (ra) {
		/* Calculate the message signature. */
		signature = (omapi_value_t *)0;
		status = omapi_get_value_str (c, (omapi_object_t *)0,
					      "output-signature", &signature);
		if (status != ISC_R_SUCCESS) {
			omapi_disconnect (c, 1);
			return status;
		}

		/* Write the authenticator... */
		status = (omapi_connection_copyin
			  (c, signature -> value -> u.buffer.value,
			   signature -> value -> u.buffer.len));
		omapi_value_dereference (&signature, MDL);
		if (status != ISC_R_SUCCESS) {
			omapi_disconnect (c, 1);
			return status;
		}

		/* Dectivate the authentication key on the connection. */
		status = omapi_set_value_str (c, (omapi_object_t *)0,
						 "output-authenticator",
						 (omapi_typed_data_t *)0);
		if (status != ISC_R_SUCCESS) {
			omapi_disconnect (c, 1);
			return status;
		}
	}

	if (!omo) {
		omapi_protocol_reference (&m -> protocol_object, p, MDL);
	}
	return ISC_R_SUCCESS;
}
示例#12
0
static isc_result_t
omapi_message_process_internal (omapi_object_t *mo, omapi_object_t *po)
{
	omapi_message_object_t *message, *m;
	omapi_object_t *object = (omapi_object_t *)0;
	omapi_value_t *tv = (omapi_value_t *)0;
	unsigned long create, update, exclusive;
	unsigned long wsi;
	isc_result_t status, waitstatus;
	omapi_object_type_t *type;

	if (mo -> type != omapi_type_message)
		return DHCP_R_INVALIDARG;
	message = (omapi_message_object_t *)mo;

#ifdef DEBUG_PROTOCOL
	log_debug ("omapi_message_process(): "
		   "op=%s  handle=%#x  id=%#x  rid=%#x",
		   omapi_message_op_name (message -> op),
		   message -> h, message -> id, message -> rid);
#endif

	if (message -> rid) {
		for (m = omapi_registered_messages; m; m = m -> next)
			if (m -> id == message -> rid)
				break;
		/* If we don't have a real message corresponding to
		   the message ID to which this message claims it is a
		   response, something's fishy. */
		if (!m)
			return ISC_R_NOTFOUND;
		/* The authenticator on responses must match the initial
		   message. */
		if (message -> authid != m -> authid)
			return ISC_R_NOTFOUND;
	} else {
		m = (omapi_message_object_t *)0;

		/* All messages must have an authenticator, with the exception
		   of messages that are opening a new authenticator. */
		if (omapi_protocol_authenticated(po) &&
		    !message->id_object &&
		    message->op != OMAPI_OP_OPEN) {
			return omapi_protocol_send_status
				(po, message->id_object, DHCP_R_NOKEYS,
				 message->id, "No authenticator on message");
		}
	}

	switch (message -> op) {
	      case OMAPI_OP_OPEN:
		if (m) {
			return omapi_protocol_send_status
				(po, message->id_object, DHCP_R_INVALIDARG,
				 message->id, "OPEN can't be a response");
		}

		/* Get the type of the requested object, if one was
		   specified. */
		status = omapi_get_value_str (mo, message -> id_object,
					      "type", &tv);
		if (status == ISC_R_SUCCESS &&
		    (tv -> value -> type == omapi_datatype_data ||
		     tv -> value -> type == omapi_datatype_string)) {
			for (type = omapi_object_types;
			     type; type = type -> next)
				if (!omapi_td_strcmp (tv -> value,
						      type -> name))
					break;
		} else
			type = (omapi_object_type_t *)0;
		if (tv)
			omapi_value_dereference (&tv, MDL);

		/* If this object had no authenticator, the requested object
		   must be an authenticator object. */
		if (omapi_protocol_authenticated(po) &&
		    !message->id_object &&
		    type != omapi_type_auth_key) {
			return omapi_protocol_send_status
				(po, message->id_object, DHCP_R_NOKEYS,
				 message->id, "No authenticator on message");
		}

		/* Get the create flag. */
		status = omapi_get_value_str (mo, message -> id_object,
					      "create", &tv);
		if (status == ISC_R_SUCCESS) {
			status = omapi_get_int_value (&create, tv -> value);
			omapi_value_dereference (&tv, MDL);
			if (status != ISC_R_SUCCESS) {
				return omapi_protocol_send_status
					(po, message -> id_object,
					 status, message -> id,
					 "invalid create flag value");
			}
		} else
			create = 0;

		/* Get the update flag. */
		status = omapi_get_value_str (mo, message -> id_object,
					      "update", &tv);
		if (status == ISC_R_SUCCESS) {
			status = omapi_get_int_value (&update, tv -> value);
			omapi_value_dereference (&tv, MDL);
			if (status != ISC_R_SUCCESS) {
				return omapi_protocol_send_status
					(po, message -> id_object,
					 status, message -> id,
					 "invalid update flag value");
			}
		} else
			update = 0;

		/* Get the exclusive flag. */
		status = omapi_get_value_str (mo, message -> id_object,
					      "exclusive", &tv);
		if (status == ISC_R_SUCCESS) {
			status = omapi_get_int_value (&exclusive, tv -> value);
			omapi_value_dereference (&tv, MDL);
			if (status != ISC_R_SUCCESS) {
				return omapi_protocol_send_status
					(po, message -> id_object,
					 status, message -> id,
					 "invalid exclusive flag value");
			}
		} else
			exclusive = 0;

		/* If we weren't given a type, look the object up with
                   the handle. */
		if (!type) {
			if (create) {
				return omapi_protocol_send_status
					(po, message->id_object,
					 DHCP_R_INVALIDARG,
					 message->id,
					 "type required on create");
			}
			goto refresh;
		}

		/* If the type doesn't provide a lookup method, we can't
		   look up the object. */
		if (!type -> lookup) {
			return omapi_protocol_send_status
				(po, message -> id_object,
				 ISC_R_NOTIMPLEMENTED, message -> id,
				 "unsearchable object type");
		}

		status = (*(type -> lookup)) (&object, message -> id_object,
					      message -> object);

		if (status != ISC_R_SUCCESS &&
		    status != ISC_R_NOTFOUND &&
		    status != DHCP_R_NOKEYS) {
			return omapi_protocol_send_status
				(po, message -> id_object,
				 status, message -> id,
				 "object lookup failed");
		}

		/* If we didn't find the object and we aren't supposed to
		   create it, return an error. */
		if (status == ISC_R_NOTFOUND && !create) {
			return omapi_protocol_send_status
				(po, message -> id_object,
				 ISC_R_NOTFOUND, message -> id,
				 "no object matches specification");
		}			

		/* If we found an object, we're supposed to be creating an
		   object, and we're not supposed to have found an object,
		   return an error. */
		if (status == ISC_R_SUCCESS && create && exclusive) {
			omapi_object_dereference (&object, MDL);
			return omapi_protocol_send_status
				(po, message -> id_object,
				 ISC_R_EXISTS, message -> id,
				 "specified object already exists");
		}

		/* If we're creating the object, do it now. */
		if (!object) {
			status = omapi_object_create (&object,
						      message -> id_object,
						      type);
			if (status != ISC_R_SUCCESS) {
				return omapi_protocol_send_status
					(po, message -> id_object,
					 status, message -> id,
					 "can't create new object");
			}
		}

		/* If we're updating it, do so now. */
		if (create || update) {
			/* This check does not belong here. */
			if (object -> type == omapi_type_auth_key) {
				omapi_object_dereference (&object, MDL);
				return omapi_protocol_send_status
					(po, message -> id_object,
					 status, message -> id,
					 "can't update object");
			}

			status = omapi_object_update (object,
						      message -> id_object,
						      message -> object,
						      message -> h);
			if (status != ISC_R_SUCCESS) {
				omapi_object_dereference (&object, MDL);
				return omapi_protocol_send_status
					(po, message -> id_object,
					 status, message -> id,
					 "can't update object");
			}
		}

		/* If this is an authenticator object, add it to the active
		   set for the connection. */
		if (object -> type == omapi_type_auth_key) {
			omapi_handle_t handle;
			status = omapi_object_handle (&handle, object);
			if (status != ISC_R_SUCCESS) {
				omapi_object_dereference (&object, MDL);
				return omapi_protocol_send_status
					(po, message -> id_object,
					 status, message -> id,
					 "can't select authenticator");
			}

			status = omapi_protocol_add_auth (po, object, handle);
			if (status != ISC_R_SUCCESS) {
				omapi_object_dereference (&object, MDL);
				return omapi_protocol_send_status
					(po, message -> id_object,
					 status, message -> id,
					 "can't select authenticator");
			}
		}
		
		/* Now send the new contents of the object back in
		   response. */
		goto send;

	      case OMAPI_OP_REFRESH:
	      refresh:
		status = omapi_handle_lookup (&object, message -> h);
		if (status != ISC_R_SUCCESS) {
			return omapi_protocol_send_status
				(po, message -> id_object,
				 status, message -> id,
				 "no matching handle");
		}
	      send:		
		status = omapi_protocol_send_update (po, message -> id_object,
						     message -> id, object);
		omapi_object_dereference (&object, MDL);
		return status;

	      case OMAPI_OP_UPDATE:
		if (m && m -> object) {
			status = omapi_object_reference (&object, m -> object,
									MDL);
		} else {
			status = omapi_handle_lookup (&object, message -> h);
			if (status != ISC_R_SUCCESS) {
				return omapi_protocol_send_status
					(po, message -> id_object,
					 status, message -> id,
					 "no matching handle");
			}
		}

		if (object -> type == omapi_type_auth_key ||
		    (object -> inner &&
		     object -> inner -> type == omapi_type_auth_key)) {
			if (!m) {
				omapi_object_dereference (&object, MDL);
				return omapi_protocol_send_status
					(po, message -> id_object,
					 status, message -> id,
					 "cannot update authenticator");
			}
			
			status = omapi_protocol_add_auth (po, object,
							  message -> h);
		} else {
			status = omapi_object_update (object,
						      message -> id_object,
						      message -> object,
						      message -> h);
		}
		if (status != ISC_R_SUCCESS) {
			omapi_object_dereference (&object, MDL);
			if (!message -> rid)
				return omapi_protocol_send_status
					(po, message -> id_object,
					 status, message -> id,
					 "can't update object");
			if (m)
				omapi_signal ((omapi_object_t *)m,
					      "status", status,
					      (omapi_typed_data_t *)0);
			return ISC_R_SUCCESS;
		}
		if (!message -> rid)
			status = omapi_protocol_send_status
				(po, message -> id_object, ISC_R_SUCCESS,
				 message -> id, (char *)0);
		if (m) {
			omapi_signal ((omapi_object_t *)m,
				      "status", ISC_R_SUCCESS,
				      (omapi_typed_data_t *)0);
			omapi_message_unregister ((omapi_object_t *)m);
		}

		omapi_object_dereference (&object, MDL);

		return status;

	      case OMAPI_OP_NOTIFY:
		return omapi_protocol_send_status
			(po, message -> id_object, ISC_R_NOTIMPLEMENTED,
			 message -> id, "notify not implemented yet");

	      case OMAPI_OP_STATUS:
		/* The return status of a request. */
		if (!m)
			return ISC_R_UNEXPECTED;

		/* Get the wait status. */
		status = omapi_get_value_str (mo, message -> id_object,
					      "result", &tv);
		if (status == ISC_R_SUCCESS) {
			status = omapi_get_int_value (&wsi, tv -> value);
			waitstatus = wsi;
			omapi_value_dereference (&tv, MDL);
			if (status != ISC_R_SUCCESS)
				waitstatus = ISC_R_UNEXPECTED;
		} else
			waitstatus = ISC_R_UNEXPECTED;

		status = omapi_get_value_str (mo, message -> id_object,
					      "message", &tv);
		omapi_signal ((omapi_object_t *)m, "status", waitstatus, tv);
		if (status == ISC_R_SUCCESS)
			omapi_value_dereference (&tv, MDL);

		omapi_message_unregister((omapi_object_t *)m);

		return ISC_R_SUCCESS;

	      case OMAPI_OP_DELETE:
		status = omapi_handle_lookup (&object, message -> h);
		if (status != ISC_R_SUCCESS) {
			return omapi_protocol_send_status
				(po, message -> id_object,
				 status, message -> id,
				 "no matching handle");
		}

		if (!object -> type -> remove)
			return omapi_protocol_send_status
				(po, message -> id_object,
				 ISC_R_NOTIMPLEMENTED, message -> id,
				 "no remove method for object");

		status = (*(object -> type -> remove)) (object,
							message -> id_object);
		omapi_object_dereference (&object, MDL);

		return omapi_protocol_send_status (po, message -> id_object,
						   status, message -> id,
						   (char *)0);
	}
	return ISC_R_NOTIMPLEMENTED;
}