Beispiel #1
0
/**
 * Add an IETF Installed Packages attribute to the send queue
 */
static void add_installed_packages(imc_state_t *state, imc_msg_t *msg)
{
	pa_tnc_attr_t *attr;
	ietf_attr_installed_packages_t *attr_cast;
	enumerator_t *enumerator;
	chunk_t name, version;

	enumerator = os->create_package_enumerator(os);
	if (!enumerator)
	{
		return;
	}
	attr = ietf_attr_installed_packages_create();

	while (enumerator->enumerate(enumerator, &name, &version))
	{
		DBG2(DBG_IMC, "package '%.*s' (%.*s)",
					   name.len, name.ptr, version.len, version.ptr);
		attr_cast = (ietf_attr_installed_packages_t*)attr;
		attr_cast->add(attr_cast, name, version);
	}
	enumerator->destroy(enumerator);

	msg->add_attribute(msg, attr);
}
/**
 * Add an IETF Installed Packages attribute to the send queue
 */
static void add_installed_packages(imc_msg_t *msg)
{
	pa_tnc_attr_t *attr;
	ietf_attr_installed_packages_t *attr_cast;
	chunk_t libc_name = { "libc-bin", 8 };
	chunk_t libc_version = { "2.15-0ubuntu10.2", 16 };
	chunk_t selinux_name =  { "selinux", 7 };
	chunk_t selinux_version = { "1:0.11", 6 };

	attr = ietf_attr_installed_packages_create();
	attr_cast = (ietf_attr_installed_packages_t*)attr;
	attr_cast->add(attr_cast, libc_name, libc_version);
	attr_cast->add(attr_cast, selinux_name, selinux_version);
	msg->add_attribute(msg, attr);
}
/**
 * Add an IETF Installed Packages attribute to the send queue
 */
static void add_installed_packages(linked_list_t *attr_list)
{
	pa_tnc_attr_t *attr;
	ietf_attr_installed_packages_t *attr_cast;
	chunk_t libc_name = { "libc-bin", 8 };
	chunk_t libc_version = { "2.15-0ubuntu10.2", 16 };
	chunk_t selinux_name =  { "selinux", 7 };
	chunk_t selinux_version = { "1:0.11", 6 };

	attr = ietf_attr_installed_packages_create();
	attr_cast = (ietf_attr_installed_packages_t*)attr;
	attr_cast->add(attr_cast, libc_name, libc_version);
	attr_cast->add(attr_cast, selinux_name, selinux_version);
	attr_list->insert_last(attr_list, attr);
}
Beispiel #4
0
/**
 * Add an IETF Installed Packages attribute to the send queue
 */
static void add_installed_packages(imc_state_t *state, imc_msg_t *msg)
{
	pa_tnc_attr_t *attr = NULL, *attr_angel;
	ietf_attr_installed_packages_t *attr_cast;
	enumerator_t *enumerator;
	chunk_t name, version;
	size_t max_attr_size, attr_size, entry_size;
	bool first = TRUE;

	/**
	 * Compute the maximum IETF Installed Packages attribute size
	 * leaving space for an additional ITA Angel attribute
	 */
	max_attr_size = state->get_max_msg_len(state) -
					PA_TNC_HEADER_SIZE - PA_TNC_ATTR_HEADER_SIZE;

	/* At least one IETF Installed Packages attribute is sent */
	attr = ietf_attr_installed_packages_create();
	attr_size = PA_TNC_ATTR_HEADER_SIZE + IETF_INSTALLED_PACKAGES_MIN_SIZE;

	enumerator = os->create_package_enumerator(os);
	if (enumerator)
	{
		while (enumerator->enumerate(enumerator, &name, &version))
		{
			DBG2(DBG_IMC, "package '%.*s' (%.*s)",
						   name.len, name.ptr, version.len, version.ptr);

			entry_size = 2 + name.len + version.len;
			if (attr_size + entry_size > max_attr_size)
			{
				if (first)
				{
					/**
					 * Send an ITA Start Angel attribute to the IMV signalling
					 * that multiple ITA Installed Package attributes follow.
					 */
					attr_angel = ita_attr_angel_create(TRUE);
					msg->add_attribute(msg, attr_angel);
					first = FALSE;
				}
				msg->add_attribute(msg, attr);

				/* create the next IETF Installed Packages attribute */
				attr = ietf_attr_installed_packages_create();
				attr_size = PA_TNC_ATTR_HEADER_SIZE +
							IETF_INSTALLED_PACKAGES_MIN_SIZE;
			}
			attr_cast = (ietf_attr_installed_packages_t*)attr;
			attr_cast->add(attr_cast, name, version);
			attr_size += entry_size;
		}
		enumerator->destroy(enumerator);
	}
	msg->add_attribute(msg, attr);

	if (!first)
	{
		/**
		 * If we sent an ITA Start Angel attribute in the first place,
		 * terminate by appending a matching ITA Stop Angel attribute.
		 */
		attr_angel = ita_attr_angel_create(FALSE);
		msg->add_attribute(msg, attr_angel);
	}
}