Exemplo n.º 1
0
/**
 * see section 3.8.3 of TCG TNC IF-IMC Specification 1.3
 */
TNC_Result TNC_IMC_BeginHandshake(TNC_IMCID imc_id,
								  TNC_ConnectionID connection_id)
{
	imc_state_t *state;
	imc_msg_t *out_msg;
	TNC_Result result = TNC_RESULT_SUCCESS;

	if (!imc_os)
	{
		DBG1(DBG_IMC, "IMC \"%s\" has not been initialized", imc_name);
		return TNC_RESULT_NOT_INITIALIZED;
	}
	if (!imc_os->get_state(imc_os, connection_id, &state))
	{
		return TNC_RESULT_FATAL;
	}
	if (lib->settings->get_bool(lib->settings,
								"libimcv.plugins.imc-os.send_info", TRUE))
	{
		out_msg = imc_msg_create(imc_os, state, connection_id, imc_id,
								 TNC_IMVID_ANY, msg_types[0]);
		add_product_info(out_msg);
		add_string_version(out_msg);
		add_op_status(out_msg);
		add_fwd_enabled(out_msg);
		add_default_pwd_enabled(out_msg);

		/* send PA-TNC message with the excl flag not set */
		result = out_msg->send(out_msg, FALSE);
		out_msg->destroy(out_msg);
	}

	return result;
}
Exemplo n.º 2
0
static TNC_Result receive_message(imc_msg_t *in_msg)
{
	imc_msg_t *out_msg;
	enumerator_t *enumerator;
	pa_tnc_attr_t *attr;
	pen_type_t attr_type;
	TNC_Result result;
	bool fatal_error = FALSE;

	/* parse received PA-TNC message and handle local and remote errors */
	result = in_msg->receive(in_msg, &fatal_error);
	if (result != TNC_RESULT_SUCCESS)
	{
		return result;
	}
	out_msg = imc_msg_create_as_reply(in_msg);

	/* analyze PA-TNC attributes */
	enumerator = in_msg->create_attribute_enumerator(in_msg);
	while (enumerator->enumerate(enumerator, &attr))
	{
		attr_type = attr->get_type(attr);

		if (attr_type.vendor_id != PEN_IETF)
		{
			continue;
		}
		if (attr_type.type == IETF_ATTR_ATTRIBUTE_REQUEST)
		{
			ietf_attr_attr_request_t *attr_cast;
			pen_type_t *entry;
			enumerator_t *e;

			attr_cast = (ietf_attr_attr_request_t*)attr;

			e = attr_cast->create_enumerator(attr_cast);
			while (e->enumerate(e, &entry))
			{
				if (entry->vendor_id != PEN_IETF)
				{
					continue;
				}
				switch (entry->type)
				{
					case IETF_ATTR_PRODUCT_INFORMATION:
						add_product_info(out_msg);
						break;
					case IETF_ATTR_STRING_VERSION:
						add_string_version(out_msg);
						break;
					case IETF_ATTR_OPERATIONAL_STATUS:
						add_op_status(out_msg);
						break;
					case IETF_ATTR_FORWARDING_ENABLED:
						add_fwd_enabled(out_msg);
						break;
					case IETF_ATTR_FACTORY_DEFAULT_PWD_ENABLED:
						add_default_pwd_enabled(out_msg);
						break;
					case IETF_ATTR_INSTALLED_PACKAGES:
						add_installed_packages(out_msg);
						break;
					default:
						break;
				}
			}
			e->destroy(e); 
		}
	}
	enumerator->destroy(enumerator);

	if (fatal_error)
	{
		result = TNC_RESULT_FATAL;
	}
	else
	{
		result = out_msg->send(out_msg, TRUE);
	}
	out_msg->destroy(out_msg);

	return result;
}
Exemplo n.º 3
0
static TNC_Result receive_message(imc_state_t *state, imc_msg_t *in_msg)
{
	imc_msg_t *out_msg;
	enumerator_t *enumerator;
	pa_tnc_attr_t *attr;
	pen_type_t type;
	TNC_Result result;
	bool fatal_error = FALSE;

	/* generate an outgoing PA-TNC message - we might need it */
	out_msg = imc_msg_create_as_reply(in_msg);

	/* parse received PA-TNC message and handle local and remote errors */
	result = in_msg->receive(in_msg, out_msg, &fatal_error);
	if (result != TNC_RESULT_SUCCESS)
	{
		out_msg->destroy(out_msg);
		return result;
	}

	/* analyze PA-TNC attributes */
	enumerator = in_msg->create_attribute_enumerator(in_msg);
	while (enumerator->enumerate(enumerator, &attr))
	{
		type = attr->get_type(attr);

		if (type.vendor_id == PEN_IETF)
		{
			if (type.type == IETF_ATTR_ATTRIBUTE_REQUEST)
			{
				ietf_attr_attr_request_t *attr_cast;
				pen_type_t *entry;
				enumerator_t *e;

				attr_cast = (ietf_attr_attr_request_t*)attr;

				e = attr_cast->create_enumerator(attr_cast);
				while (e->enumerate(e, &entry))
				{
					if (entry->vendor_id == PEN_IETF)
					{
						switch (entry->type)
						{
							case IETF_ATTR_PRODUCT_INFORMATION:
								add_product_info(out_msg);
								break;
							case IETF_ATTR_STRING_VERSION:
								add_string_version(out_msg);
								break;
							case IETF_ATTR_NUMERIC_VERSION:
								add_numeric_version(out_msg);
								break;
							case IETF_ATTR_OPERATIONAL_STATUS:
								add_op_status(out_msg);
								break;
							case IETF_ATTR_FORWARDING_ENABLED:
								add_fwd_enabled(out_msg);
								break;
							case IETF_ATTR_FACTORY_DEFAULT_PWD_ENABLED:
								add_default_pwd_enabled(out_msg);
								break;
							case IETF_ATTR_INSTALLED_PACKAGES:
								add_installed_packages(state, out_msg);
								break;
							default:
								break;
						}
					}
					else if (entry->vendor_id == PEN_ITA)
					{
						switch (entry->type)
						{
							case ITA_ATTR_DEVICE_ID:
								add_device_id(out_msg);
								break;
							default:
								break;
						}
					}
				}
				e->destroy(e);
			}
		}
		else if (type.vendor_id == PEN_ITA && type.type == ITA_ATTR_GET_SETTINGS)
		{
			ita_attr_get_settings_t *attr_cast;
			enumerator_t *e;

			attr_cast = (ita_attr_get_settings_t*)attr;

			e = attr_cast->create_enumerator(attr_cast);
			add_settings(e, out_msg);
			e->destroy(e);
		}
	}
	enumerator->destroy(enumerator);

	if (fatal_error)
	{
		result = TNC_RESULT_FATAL;
	}
	else
	{
		/* send PA-TNC message with the EXCL flag set */
		result = out_msg->send(out_msg, TRUE);
	}
	out_msg->destroy(out_msg);

	return result;
}