Esempio n. 1
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;
}
Esempio n. 2
0
isc_result_t dhcp_control_get_value (omapi_object_t *h, omapi_object_t *id,
				   omapi_data_string_t *name,
				   omapi_value_t **value)
{
	dhcp_control_object_t *control;
	isc_result_t status;
	struct data_string ip_addrs;

	if (h -> type != dhcp_type_control)
		return ISC_R_INVALIDARG;
	control = (dhcp_control_object_t *)h;

	if (!omapi_ds_strcmp (name, "state"))
		return omapi_make_int_value (value,
					     name, (int)control -> state, MDL);

	/* Try to find some inner object that can take the value. */
	if (h -> inner && h -> inner -> type -> get_value) {
		status = ((*(h -> inner -> type -> get_value))
			  (h -> inner, id, name, value));
		if (status == ISC_R_SUCCESS)
			return status;
	}
	return ISC_R_NOTFOUND;
}
Esempio n. 3
0
isc_result_t dhcp_control_set_value  (omapi_object_t *h,
				      omapi_object_t *id,
				      omapi_data_string_t *name,
				      omapi_typed_data_t *value)
{
	dhcp_control_object_t *control;
	isc_result_t status;
	int foo;
	unsigned long newstate;

	if (h -> type != dhcp_type_control)
		return ISC_R_INVALIDARG;
	control = (dhcp_control_object_t *)h;

	if (!omapi_ds_strcmp (name, "state")) {
		status = omapi_get_int_value (&newstate, value);
		if (status != ISC_R_SUCCESS)
			return status;
		status = dhcp_set_control_state (control -> state, newstate);
		if (status == ISC_R_SUCCESS)
			control -> state = value -> u.integer;
		return status;
	}

	/* Try to find some inner object that can take the value. */
	if (h -> inner && h -> inner -> type -> set_value) {
		status = ((*(h -> inner -> type -> set_value))
			  (h -> inner, id, name, value));
		if (status == ISC_R_SUCCESS || status == ISC_R_UNCHANGED)
			return status;
	}
			  
	return ISC_R_NOTFOUND;
}
Esempio n. 4
0
isc_result_t dhcp_group_get_value (omapi_object_t *h, omapi_object_t *id,
				   omapi_data_string_t *name,
				   omapi_value_t **value)
{
	struct group_object *group;
	isc_result_t status;
	struct data_string ip_addrs;

	if (h -> type != dhcp_type_group)
		return ISC_R_INVALIDARG;
	group = (struct group_object *)h;

	if (!omapi_ds_strcmp (name, "name"))
		return omapi_make_string_value (value,
						name, group -> name, MDL);

	/* Try to find some inner object that can take the value. */
	if (h -> inner && h -> inner -> type -> get_value) {
		status = ((*(h -> inner -> type -> get_value))
			  (h -> inner, id, name, value));
		if (status == ISC_R_SUCCESS)
			return status;
	}
	return ISC_R_NOTFOUND;
}
Esempio n. 5
0
isc_result_t dhcpctl_remote_set_value (omapi_object_t *h,
				       omapi_object_t *id,
				       omapi_data_string_t *name,
				       omapi_typed_data_t *value)
{
	dhcpctl_remote_object_t *ro;
	unsigned long rh;
	isc_result_t status;

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

	if (!omapi_ds_strcmp (name, "remote-handle")) {
		status = omapi_get_int_value (&rh, value);
		if (status == ISC_R_SUCCESS)
			ro -> remote_handle = rh;
		return status;
	}

	if (h -> inner && h -> inner -> type -> set_value)
		return (*(h -> inner -> type -> set_value))
			(h -> inner, id, name, value);
	return ISC_R_NOTFOUND;
}
Esempio n. 6
0
isc_result_t omapi_protocol_set_value (omapi_object_t *h,
				       omapi_object_t *id,
				       omapi_data_string_t *name,
				       omapi_typed_data_t *value)
{
	omapi_protocol_object_t *p;
	omapi_remote_auth_t *r;

	if (h -> type != omapi_type_protocol)
		return ISC_R_INVALIDARG;
	p = (omapi_protocol_object_t *)h;

	if (omapi_ds_strcmp (name, "default-authenticator") == 0) {
		if (value -> type != omapi_datatype_object)
			return ISC_R_INVALIDARG;

		if (!value || !value -> u.object) {
			p -> default_auth = (omapi_remote_auth_t *)0;
		} else {
			for (r = p -> remote_auth_list; r; r = r -> next)
				if (r -> a == value -> u.object)
					break;

			if (!r)
				return ISC_R_KEY_UNKNOWN;

			p -> default_auth = r;
		}

		return ISC_R_SUCCESS;
	}

	if (h -> inner && h -> inner -> type -> set_value)
		return (*(h -> inner -> type -> set_value))
			(h -> inner, id, name, value);
	return ISC_R_NOTFOUND;
}
Esempio n. 7
0
isc_result_t omapi_message_get_value (omapi_object_t *h,
				      omapi_object_t *id,
				      omapi_data_string_t *name,
				      omapi_value_t **value)
{
	omapi_message_object_t *m;
	if (h -> type != omapi_type_message)
		return DHCP_R_INVALIDARG;
	m = (omapi_message_object_t *)h;

	/* Look for values that are in the message data structure. */
	if (!omapi_ds_strcmp (name, "authlen"))
		return omapi_make_int_value (value, name, (int)m -> authlen,
					     MDL);
	else if (!omapi_ds_strcmp (name, "authenticator")) {
		if (m -> authenticator)
			return omapi_make_value (value, name,
						 m -> authenticator, MDL);
		else
			return ISC_R_NOTFOUND;
	} else if (!omapi_ds_strcmp (name, "authid")) {
		return omapi_make_int_value (value,
					     name, (int)m -> authid, MDL);
	} else if (!omapi_ds_strcmp (name, "op")) {
		return omapi_make_int_value (value, name, (int)m -> op, MDL);
	} else if (!omapi_ds_strcmp (name, "handle")) {
		return omapi_make_int_value (value, name, (int)m -> h, MDL);
	} else if (!omapi_ds_strcmp (name, "id")) {
		return omapi_make_int_value (value, name, (int)m -> id, MDL);
	} else if (!omapi_ds_strcmp (name, "rid")) {
		return omapi_make_int_value (value, name, (int)m -> rid, MDL);
	}

	/* See if there's an inner object that has the value. */
	if (h -> inner && h -> inner -> type -> get_value)
		return (*(h -> inner -> type -> get_value))
			(h -> inner, id, name, value);
	return ISC_R_NOTFOUND;
}
Esempio n. 8
0
isc_result_t omapi_protocol_get_value (omapi_object_t *h,
				       omapi_object_t *id,
				       omapi_data_string_t *name,
				       omapi_value_t **value)
{
	omapi_protocol_object_t *p;

	if (h -> type != omapi_type_protocol)
		return ISC_R_INVALIDARG;
	p = (omapi_protocol_object_t *)h;

	if (omapi_ds_strcmp (name, "default-authenticator") == 0) {
		if (!p -> default_auth)
			return ISC_R_NOTFOUND;

		return omapi_make_object_value (value, name,
						p -> default_auth -> a, MDL);
	}
	
	if (h -> inner && h -> inner -> type -> get_value)
		return (*(h -> inner -> type -> get_value))
			(h -> inner, id, name, value);
	return ISC_R_NOTFOUND;
}
Esempio n. 9
0
isc_result_t dhcp_group_set_value  (omapi_object_t *h,
				    omapi_object_t *id,
				    omapi_data_string_t *name,
				    omapi_typed_data_t *value)
{
	struct group_object *group;
	isc_result_t status;
	int foo;

	if (h -> type != dhcp_type_group)
		return ISC_R_INVALIDARG;
	group = (struct group_object *)h;

	/* XXX For now, we can only set these values on new group objects. 
	   XXX Soon, we need to be able to update group objects. */
	if (!omapi_ds_strcmp (name, "name")) {
		if (group -> name)
			return ISC_R_EXISTS;
		if (value -> type == omapi_datatype_data ||
		    value -> type == omapi_datatype_string) {
			group -> name = dmalloc (value -> u.buffer.len + 1,
						 MDL);
			if (!group -> name)
				return ISC_R_NOMEMORY;
			memcpy (group -> name,
				value -> u.buffer.value,
				value -> u.buffer.len);
			group -> name [value -> u.buffer.len] = 0;
		} else
			return ISC_R_INVALIDARG;
		return ISC_R_SUCCESS;
	}

	if (!omapi_ds_strcmp (name, "statements")) {
		if (group -> group && group -> group -> statements)
			return ISC_R_EXISTS;
		if (!group -> group) {
			if (!clone_group (&group -> group, root_group, MDL))
				return ISC_R_NOMEMORY;
		}
		if (value -> type == omapi_datatype_data ||
		    value -> type == omapi_datatype_string) {
			struct parse *parse;
			int lose = 0;
			parse = (struct parse *)0;
			status = new_parse (&parse, -1,
					    (char *)value -> u.buffer.value,
					    value -> u.buffer.len,
					    "network client", 0);
			if (status != ISC_R_SUCCESS)
				return status;
			if (!(parse_executable_statements
			      (&group -> group -> statements, parse, &lose,
			       context_any))) {
				end_parse (&parse);
				return ISC_R_BADPARSE;
			}
			end_parse (&parse);
			return ISC_R_SUCCESS;
		} else
			return ISC_R_INVALIDARG;
	}

	/* Try to find some inner object that can take the value. */
	if (h -> inner && h -> inner -> type -> set_value) {
		status = ((*(h -> inner -> type -> set_value))
			  (h -> inner, id, name, value));
		if (status == ISC_R_SUCCESS || status == ISC_R_UNCHANGED)
			return status;
	}
			  
	return ISC_R_NOTFOUND;
}
Esempio n. 10
0
isc_result_t omapi_message_set_value (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 status;

	if (h -> type != omapi_type_message)
		return DHCP_R_INVALIDARG;
	m = (omapi_message_object_t *)h;

	/* Can't set authlen. */

	/* Can set authenticator, but the value must be typed data. */
	if (!omapi_ds_strcmp (name, "authenticator")) {
		if (m -> authenticator)
			omapi_typed_data_dereference (&m -> authenticator,
						      MDL);
		omapi_typed_data_reference (&m -> authenticator, value, MDL);
		return ISC_R_SUCCESS;

	} else if (!omapi_ds_strcmp (name, "object")) {
		if (value -> type != omapi_datatype_object)
			return DHCP_R_INVALIDARG;
		if (m -> object)
			omapi_object_dereference (&m -> object, MDL);
		omapi_object_reference (&m -> object, value -> u.object, MDL);
		return ISC_R_SUCCESS;

	} else if (!omapi_ds_strcmp (name, "notify-object")) {
		if (value -> type != omapi_datatype_object)
			return DHCP_R_INVALIDARG;
		if (m -> notify_object)
			omapi_object_dereference (&m -> notify_object, MDL);
		omapi_object_reference (&m -> notify_object,
					value -> u.object, MDL);
		return ISC_R_SUCCESS;

	/* Can set authid, but it has to be an integer. */
	} else if (!omapi_ds_strcmp (name, "authid")) {
		if (value -> type != omapi_datatype_int)
			return DHCP_R_INVALIDARG;
		m -> authid = value -> u.integer;
		return ISC_R_SUCCESS;

	/* Can set op, but it has to be an integer. */
	} else if (!omapi_ds_strcmp (name, "op")) {
		if (value -> type != omapi_datatype_int)
			return DHCP_R_INVALIDARG;
		m -> op = value -> u.integer;
		return ISC_R_SUCCESS;

	/* Handle also has to be an integer. */
	} else if (!omapi_ds_strcmp (name, "handle")) {
		if (value -> type != omapi_datatype_int)
			return DHCP_R_INVALIDARG;
		m -> h = value -> u.integer;
		return ISC_R_SUCCESS;

	/* Transaction ID has to be an integer. */
	} else if (!omapi_ds_strcmp (name, "id")) {
		if (value -> type != omapi_datatype_int)
			return DHCP_R_INVALIDARG;
		m -> id = value -> u.integer;
		return ISC_R_SUCCESS;

	/* Remote transaction ID has to be an integer. */
	} else if (!omapi_ds_strcmp (name, "rid")) {
		if (value -> type != omapi_datatype_int)
			return DHCP_R_INVALIDARG;
		m -> rid = value -> u.integer;
		return ISC_R_SUCCESS;
	}

	/* Try to find some inner object that can take the value. */
	if (h -> inner && h -> inner -> type -> set_value) {
		status = ((*(h -> inner -> type -> set_value))
			  (h -> inner, id, name, value));
		if (status == ISC_R_SUCCESS)
			return status;
	}
			  
	return ISC_R_NOTFOUND;
}
Esempio n. 11
0
isc_result_t omapi_connection_get_value (omapi_object_t *h,
					 omapi_object_t *id,
					 omapi_data_string_t *name,
					 omapi_value_t **value)
{
	omapi_connection_object_t *c;
	omapi_typed_data_t *td = (omapi_typed_data_t *)0;
	isc_result_t status;
	unsigned int sigsize;

	if (h -> type != omapi_type_connection)
		return DHCP_R_INVALIDARG;
	c = (omapi_connection_object_t *)h;

	if (omapi_ds_strcmp (name, "input-signature") == 0) {
//ScenSim-Port//		if (!c -> in_key || !c -> in_context)
//ScenSim-Port//			return ISC_R_NOTFOUND;

//ScenSim-Port//		status = omapi_connection_sign_data (SIG_MODE_FINAL,
//ScenSim-Port//						     c -> in_key,
//ScenSim-Port//						     &c -> in_context,
//ScenSim-Port//						     0, 0, &td);
//ScenSim-Port//		if (status != ISC_R_SUCCESS)
//ScenSim-Port//			return status;

		status = omapi_make_value (value, name, td, MDL);
		omapi_typed_data_dereference (&td, MDL);
		return status;

	} else if (omapi_ds_strcmp (name, "input-signature-size") == 0) {
//ScenSim-Port//		if (c->in_key == NULL)
//ScenSim-Port//			return ISC_R_NOTFOUND;

//ScenSim-Port//		status = dst_key_sigsize(c->in_key, &sigsize);
//ScenSim-Port//		if (status != ISC_R_SUCCESS) {
//ScenSim-Port//			return(status);
//ScenSim-Port//		}		

		return omapi_make_int_value(value, name, sigsize, MDL);

	} else if (omapi_ds_strcmp (name, "output-signature") == 0) {
//ScenSim-Port//		if (!c -> out_key || !c -> out_context)
//ScenSim-Port//			return ISC_R_NOTFOUND;

//ScenSim-Port//		status = omapi_connection_sign_data (SIG_MODE_FINAL,
//ScenSim-Port//						     c -> out_key,
//ScenSim-Port//						     &c -> out_context,
//ScenSim-Port//						     0, 0, &td);
//ScenSim-Port//		if (status != ISC_R_SUCCESS)
//ScenSim-Port//			return status;

		status = omapi_make_value (value, name, td, MDL);
		omapi_typed_data_dereference (&td, MDL);
		return status;

	} else if (omapi_ds_strcmp (name, "output-signature-size") == 0) {
//ScenSim-Port//		if (c->out_key == NULL)
//ScenSim-Port//			return ISC_R_NOTFOUND;


//ScenSim-Port//		status = dst_key_sigsize(c->out_key, &sigsize);
//ScenSim-Port//		if (status != ISC_R_SUCCESS) {
//ScenSim-Port//			return(status);
//ScenSim-Port//		}		

		return omapi_make_int_value(value, name, sigsize, MDL);
	}
	
	if (h -> inner && h -> inner -> type -> get_value)
		return (*(h -> inner -> type -> get_value))
			(h -> inner, id, name, value);
	return ISC_R_NOTFOUND;
}
Esempio n. 12
0
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_object_t *c;
	isc_result_t status;

	if (h -> type != omapi_type_connection)
		return DHCP_R_INVALIDARG;
	c = (omapi_connection_object_t *)h;

	if (omapi_ds_strcmp (name, "input-authenticator") == 0) {
		if (value && value -> type != omapi_datatype_object)
			return DHCP_R_INVALIDARG;

//ScenSim-Port//		if (c -> in_context) {
//ScenSim-Port//			omapi_connection_sign_data (SIG_MODE_FINAL,
//ScenSim-Port//						    c -> in_key,
//ScenSim-Port//						    &c -> in_context,
//ScenSim-Port//						    0, 0,
//ScenSim-Port//						    (omapi_typed_data_t **) 0);
//ScenSim-Port//		}

//ScenSim-Port//		if (c->in_key != NULL) {
//ScenSim-Port//			dst_key_free(&c->in_key);
//ScenSim-Port//		}

//ScenSim-Port//		if (value) {
//ScenSim-Port//			status = make_dst_key (&c -> in_key,
//ScenSim-Port//					       value -> u.object);
//ScenSim-Port//			if (status != ISC_R_SUCCESS)
//ScenSim-Port//				return status;
//ScenSim-Port//		}

		return ISC_R_SUCCESS;
	}
	else if (omapi_ds_strcmp (name, "output-authenticator") == 0) {
		if (value && value -> type != omapi_datatype_object)
			return DHCP_R_INVALIDARG;

//ScenSim-Port//		if (c -> out_context) {
//ScenSim-Port//			omapi_connection_sign_data (SIG_MODE_FINAL,
//ScenSim-Port//						    c -> out_key,
//ScenSim-Port//						    &c -> out_context,
//ScenSim-Port//						    0, 0,
//ScenSim-Port//						    (omapi_typed_data_t **) 0);
//ScenSim-Port//		}

//ScenSim-Port//		if (c->out_key != NULL) {
//ScenSim-Port//			dst_key_free(&c->out_key);
//ScenSim-Port//		}

//ScenSim-Port//		if (value) {
//ScenSim-Port//			status = make_dst_key (&c -> out_key,
//ScenSim-Port//					       value -> u.object);
//ScenSim-Port//			if (status != ISC_R_SUCCESS)
//ScenSim-Port//				return status;
//ScenSim-Port//		}

		return ISC_R_SUCCESS;
	}
	
	if (h -> inner && h -> inner -> type -> set_value)
		return (*(h -> inner -> type -> set_value))
			(h -> inner, id, name, value);
	return ISC_R_NOTFOUND;
}