Пример #1
0
/**
 * \brief Store metadata information
 */
void Storage::storeMetadata(metadata* mdata)
{
	std::stringstream ss;
	
	/* Geolocation info */
	ss << "\"srcAS\": \"" << mdata->srcAS << "\", ";
	ss << "\"dstAS\": \"" << mdata->dstAS << "\", ";
	ss << "\"srcCountry\": \"" << mdata->srcCountry << "\", ";
	ss << "\"dstCountry\": \"" << mdata->dstCountry << "\", ";
	ss << "\"srcName\": \"" << mdata->srcName << "\", ";
	ss << "\"dstName\": \"" << mdata->dstName << "\", ";

	record += ss.str();

	
	/* Profiles */
	if (mdata->channels) {
		record += "\"profiles\": [";

		for (int i = 0; mdata->channels[i] != 0; ++i) {
			if (i > 0) {
				record += ", ";
			}

			record += "{\"profile\": \"";
			record += channel_get_name(mdata->channels[i]);
			record += "\", \"channel\": \"";
			record += profile_get_name(channel_get_profile(mdata->channels[i]));
			record += "\"}";
		}

		record += "]";
	}
}
Пример #2
0
/**
 * \brief Store metadata information
 */
void Storage::storeMetadata(metadata* mdata)
{
	std::stringstream ss;
	
	/* Geolocation info */
	ss << "\"srcAS\": \"" << mdata->srcAS << "\", ";
	ss << "\"dstAS\": \"" << mdata->dstAS << "\", ";
	ss << "\"srcCountry\": \"" << mdata->srcCountry << "\", ";
	ss << "\"dstCountry\": \"" << mdata->dstCountry << "\", ";
	ss << "\"srcName\": \"" << mdata->srcName << "\", ";
	ss << "\"dstName\": \"" << mdata->dstName << "\", ";

	record += ss.str();

	
	/* Profiles */
	STR_APPEND(record, "\"profiles\": [");
	if (mdata->channels) {
		// Get name of root profile
		void *profile_ptr = NULL;
		void *prev_profile_ptr = NULL;
		const char *root_profile_name;

		profile_ptr = channel_get_profile(mdata->channels[0]);
		while (profile_ptr != NULL) {
			prev_profile_ptr = profile_ptr;
			profile_ptr = profile_get_parent(profile_ptr);
		}
		root_profile_name = profile_get_name(prev_profile_ptr);

		// Process all channels
		for (int i = 0; mdata->channels[i] != 0; ++i) {
			if (i > 0) {
				STR_APPEND(record, ", ");
			}

			STR_APPEND(record, "{\"profile\": \"");
			record += root_profile_name;
			STR_APPEND(record, "/");
			record += profile_get_path(channel_get_profile(mdata->channels[i]));

			STR_APPEND(record, "\", \"channel\": \"");
			record += channel_get_name(mdata->channels[i]);
			STR_APPEND(record, "\"}");
		}
	}
	record += ']';
}