isc_result_t omapi_protocol_send_open (omapi_object_t *po,
				       omapi_object_t *id,
				       const char *type,
				       omapi_object_t *object,
				       unsigned flags)
{
	isc_result_t status;
	omapi_message_object_t *message = (omapi_message_object_t *)0;
	omapi_object_t *mo;

	if (po -> type != omapi_type_protocol)
		return ISC_R_INVALIDARG;

	status = omapi_message_new ((omapi_object_t **)&message, MDL);
	mo = (omapi_object_t *)message;

	if (status == ISC_R_SUCCESS)
		status = omapi_set_int_value (mo, (omapi_object_t *)0,
					      "op", OMAPI_OP_OPEN);

	if (status == ISC_R_SUCCESS)
		status = omapi_set_object_value (mo, (omapi_object_t *)0,
						 "object", object);

	if ((flags & OMAPI_CREATE) && (status == ISC_R_SUCCESS))
		status = omapi_set_boolean_value (mo, (omapi_object_t *)0,
						  "create", 1);

	if ((flags & OMAPI_UPDATE) && (status == ISC_R_SUCCESS))
		status = omapi_set_boolean_value (mo, (omapi_object_t *)0,
						  "update", 1);

	if ((flags & OMAPI_EXCL) && (status == ISC_R_SUCCESS))
		status = omapi_set_boolean_value (mo, (omapi_object_t *)0,
						  "exclusive", 1);

	if ((flags & OMAPI_NOTIFY_PROTOCOL) && (status == ISC_R_SUCCESS))
		status = omapi_set_object_value (mo, (omapi_object_t *)0,
						 "notify-object", po);

	if (type && (status == ISC_R_SUCCESS))
		status = omapi_set_string_value (mo, (omapi_object_t *)0,
						 "type", type);

	if (status == ISC_R_SUCCESS)
		status = omapi_message_register (mo);

	if (status == ISC_R_SUCCESS) {
		status = omapi_protocol_send_message (po, id, mo,
						      (omapi_object_t *)0);
		if (status != ISC_R_SUCCESS)
			omapi_message_unregister (mo);
	}

	if (message)
		omapi_message_dereference (&message, MDL);

	return status;
}
isc_result_t omapi_protocol_send_update (omapi_object_t *po,
					 omapi_object_t *id,
					 unsigned rid,
					 omapi_object_t *object)
{
	isc_result_t status;
	omapi_message_object_t *message = (omapi_message_object_t *)0;
	omapi_object_t *mo;

	if (po -> type != omapi_type_protocol)
		return ISC_R_INVALIDARG;

	status = omapi_message_new ((omapi_object_t **)&message, MDL);
	if (status != ISC_R_SUCCESS)
		return status;
	mo = (omapi_object_t *)message;

	status = omapi_set_int_value (mo, (omapi_object_t *)0,
				      "op", OMAPI_OP_UPDATE);
	if (status != ISC_R_SUCCESS) {
		omapi_message_dereference (&message, MDL);
		return status;
	}

	if (rid) {
		omapi_handle_t handle;
		status = omapi_set_int_value (mo, (omapi_object_t *)0,
					      "rid", (int)rid);
		if (status != ISC_R_SUCCESS) {
			omapi_message_dereference (&message, MDL);
			return status;
		}

		status = omapi_object_handle (&handle, object);
		if (status != ISC_R_SUCCESS) {
			omapi_message_dereference (&message, MDL);
			return status;
		}
		status = omapi_set_int_value (mo, (omapi_object_t *)0,
					      "handle", (int)handle);
		if (status != ISC_R_SUCCESS) {
			omapi_message_dereference (&message, MDL);
			return status;
		}
	}		
		
	status = omapi_set_object_value (mo, (omapi_object_t *)0,
					 "object", object);
	if (status != ISC_R_SUCCESS) {
		omapi_message_dereference (&message, MDL);
		return status;
	}

	status = omapi_protocol_send_message (po, id, mo, (omapi_object_t *)0);
	omapi_message_dereference (&message, MDL);
	return status;
}
isc_result_t omapi_protocol_send_status (omapi_object_t *po,
					 omapi_object_t *id,
					 isc_result_t waitstatus,
					 unsigned rid, const char *msg)
{
	isc_result_t status;
	omapi_message_object_t *message = (omapi_message_object_t *)0;
	omapi_object_t *mo;

	if (po -> type != omapi_type_protocol)
		return ISC_R_INVALIDARG;

	status = omapi_message_new ((omapi_object_t **)&message, MDL);
	if (status != ISC_R_SUCCESS)
		return status;
	mo = (omapi_object_t *)message;

	status = omapi_set_int_value (mo, (omapi_object_t *)0,
				      "op", OMAPI_OP_STATUS);
	if (status != ISC_R_SUCCESS) {
		omapi_message_dereference (&message, MDL);
		return status;
	}

	status = omapi_set_int_value (mo, (omapi_object_t *)0,
				      "rid", (int)rid);
	if (status != ISC_R_SUCCESS) {
		omapi_message_dereference (&message, MDL);
		return status;
	}

	status = omapi_set_int_value (mo, (omapi_object_t *)0,
				      "result", (int)waitstatus);
	if (status != ISC_R_SUCCESS) {
		omapi_message_dereference (&message, MDL);
		return status;
	}

	/* If a message has been provided, send it. */
	if (msg) {
		status = omapi_set_string_value (mo, (omapi_object_t *)0,
						 "message", msg);
		if (status != ISC_R_SUCCESS) {
			omapi_message_dereference (&message, MDL);
			return status;
		}
	}

	status = omapi_protocol_send_message (po, id, mo, (omapi_object_t *)0);
	omapi_message_dereference (&message, MDL);
	return status;
}
Exemple #4
0
dhcpctl_status dhcpctl_object_refresh (dhcpctl_handle connection,
				       dhcpctl_handle h)
{
	isc_result_t status;
	omapi_object_t *message = (omapi_object_t *)0;
	dhcpctl_remote_object_t *ro;

	if (h -> type != dhcpctl_remote_type)
		return DHCP_R_INVALIDARG;
	ro = (dhcpctl_remote_object_t *)h;

	status = omapi_message_new (&message, MDL);
	if (status != ISC_R_SUCCESS) {
		omapi_object_dereference (&message, MDL);
		return status;
	}
	status = omapi_set_int_value (message, (omapi_object_t *)0,
				      "op", OMAPI_OP_REFRESH);
	if (status != ISC_R_SUCCESS) {
		omapi_object_dereference (&message, MDL);
		return status;
	}
	status = omapi_set_int_value (message, (omapi_object_t *)0,
				      "handle", (int)(ro -> remote_handle));
	if (status != ISC_R_SUCCESS) {
		omapi_object_dereference (&message, MDL);
		return status;
	}

	omapi_message_register (message);
	status = omapi_protocol_send_message (connection -> outer,
					      (omapi_object_t *)0,
					      message, (omapi_object_t *)0);

	/* We don't want to send the contents of the object down the
	   wire, but we do need to reference it so that we know what
	   to do with the update. */
	status = omapi_set_object_value (message, (omapi_object_t *)0,
					 "object", h);
	if (status != ISC_R_SUCCESS) {
		omapi_object_dereference (&message, MDL);
		return status;
	}

	omapi_object_dereference (&message, MDL);
	return status;
}
Exemple #5
0
dhcpctl_status dhcpctl_object_remove (dhcpctl_handle connection,
				      dhcpctl_handle h)
{
	isc_result_t status;
	omapi_object_t *message = (omapi_object_t *)0;
	dhcpctl_remote_object_t *ro;

	if (h -> type != dhcpctl_remote_type)
		return DHCP_R_INVALIDARG;
	ro = (dhcpctl_remote_object_t *)h;

	status = omapi_message_new (&message, MDL);
	if (status != ISC_R_SUCCESS) {
		omapi_object_dereference (&message, MDL);
		return status;
	}
	status = omapi_set_int_value (message, (omapi_object_t *)0,
				      "op", OMAPI_OP_DELETE);
	if (status != ISC_R_SUCCESS) {
		omapi_object_dereference (&message, MDL);
		return status;
	}

	status = omapi_set_int_value (message, (omapi_object_t *)0, "handle",
				      (int)(ro -> remote_handle));
	if (status != ISC_R_SUCCESS) {
		omapi_object_dereference (&message, MDL);
		return status;
	}

	status = omapi_set_object_value (message, (omapi_object_t *)0,
					 "notify-object", h);
	if (status != ISC_R_SUCCESS) {
		omapi_object_dereference (&message, MDL);
		return status;
	}

	omapi_message_register (message);
	status = omapi_protocol_send_message (connection -> outer,
					      (omapi_object_t *)0,
					      message, (omapi_object_t *)0);
	omapi_object_dereference (&message, MDL);
	return status;
}
Exemple #6
0
dhcpctl_status dhcpctl_open_object (dhcpctl_handle h,
				    dhcpctl_handle connection,
				    int flags)
{
	isc_result_t status;
	omapi_object_t *message = (omapi_object_t *)0;
	dhcpctl_remote_object_t *remote;

	if (h -> type != dhcpctl_remote_type)
		return DHCP_R_INVALIDARG;
	remote = (dhcpctl_remote_object_t *)h;

	status = omapi_message_new (&message, MDL);
	if (status != ISC_R_SUCCESS)
		return status;
	status = omapi_set_int_value (message, (omapi_object_t *)0,
				      "op", OMAPI_OP_OPEN);
	if (status != ISC_R_SUCCESS) {
		omapi_object_dereference (&message, MDL);
		return status;
	}
	status = omapi_set_object_value (message, (omapi_object_t *)0,
					 "object", h);
	if (status != ISC_R_SUCCESS) {
		omapi_object_dereference (&message, MDL);
		return status;
	}
	if (flags & DHCPCTL_CREATE) {
		status = omapi_set_boolean_value (message, (omapi_object_t *)0,
						  "create", 1);
		if (status != ISC_R_SUCCESS) {
			omapi_object_dereference (&message, MDL);
			return status;
		}
	}
	if (flags & DHCPCTL_UPDATE) {
		status = omapi_set_boolean_value (message, (omapi_object_t *)0,
						  "update", 1);
		if (status != ISC_R_SUCCESS) {
			omapi_object_dereference (&message, MDL);
			return status;
		}
	}
	if (flags & DHCPCTL_EXCL) {
		status = omapi_set_boolean_value (message, (omapi_object_t *)0,
						  "exclusive", 1);
		if (status != ISC_R_SUCCESS) {
			omapi_object_dereference (&message, MDL);
			return status;
		}
	}

	if (remote -> rtype) {
		status = omapi_set_value_str (message, (omapi_object_t *)0,
					      "type", remote -> rtype);
		if (status != ISC_R_SUCCESS) {
			omapi_object_dereference (&message, MDL);
			return status;
		}
	}

	status = omapi_message_register (message);
	if (status != ISC_R_SUCCESS) {
		omapi_object_dereference (&message, MDL);
		return status;
	}

	status = omapi_protocol_send_message (connection -> outer,
					    (omapi_object_t *)0,
					    message, (omapi_object_t *)0);

	if (status != ISC_R_SUCCESS)
		omapi_message_unregister (message);

	omapi_object_dereference (&message, MDL);
	return status;
}