You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nifi.apache.org by al...@apache.org on 2017/11/14 01:48:37 UTC

[23/25] nifi-minifi-cpp git commit: MINIFICPP-250: Initial implementation fo CapturePacket Processor that uses lipcap.

http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/blob/c0a788b3/thirdparty/pcap++/3rdParty/LightPcapNg/LightPcapNg/src/light_pcapng_ext.c
----------------------------------------------------------------------
diff --git a/thirdparty/pcap++/3rdParty/LightPcapNg/LightPcapNg/src/light_pcapng_ext.c b/thirdparty/pcap++/3rdParty/LightPcapNg/LightPcapNg/src/light_pcapng_ext.c
new file mode 100644
index 0000000..7b4bb92
--- /dev/null
+++ b/thirdparty/pcap++/3rdParty/LightPcapNg/LightPcapNg/src/light_pcapng_ext.c
@@ -0,0 +1,528 @@
+// light_pcapng_ext.c
+// Created on: Nov 14, 2016
+
+// Copyright (c) 2016
+
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included in all
+// copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+// SOFTWARE.
+
+#include "light_pcapng_ext.h"
+#include "light_pcapng.h"
+#include "light_platform.h"
+#include "light_debug.h"
+#include "light_util.h"
+
+#include <stdlib.h>
+#include <string.h>
+
+
+struct _light_pcapng_t
+{
+	light_pcapng pcapng;
+	light_pcapng_file_info *file_info;
+	light_pcapng pcapng_iter;
+	__fd_t file;
+};
+
+static light_pcapng_file_info *__create_file_info(light_pcapng pcapng_head)
+{
+	uint32_t type = LIGHT_UNKNOWN_DATA_BLOCK;
+
+	if (pcapng_head == NULL)
+		return NULL;
+
+	light_pcapng iter = pcapng_head;
+
+	light_get_block_info(iter, LIGHT_INFO_TYPE, &type, NULL);
+
+	if (type != LIGHT_SECTION_HEADER_BLOCK)
+		return NULL;
+
+	light_pcapng_file_info *file_info = calloc(1, sizeof(light_pcapng_file_info));
+
+	struct _light_section_header* section_header;
+
+	light_get_block_info(iter, LIGHT_INFO_BODY, &section_header, NULL);
+	file_info->major_version = section_header->major_version;
+	file_info->minor_version = section_header->minor_version;
+
+	light_option opt = light_get_option(iter, LIGHT_OPTION_SHB_HARDWARE);
+	if (opt != NULL)
+	{
+		file_info->hardware_desc_size = light_get_option_length(opt);
+		file_info->hardware_desc = calloc(file_info->hardware_desc_size+1, sizeof(char));
+		memcpy(file_info->hardware_desc, (char*)light_get_option_data(opt), file_info->hardware_desc_size);
+		file_info->hardware_desc[file_info->hardware_desc_size] = '\0';
+	}
+	else
+	{
+		file_info->hardware_desc_size = 0;
+		file_info->hardware_desc = NULL;
+	}
+
+	opt = light_get_option(iter, LIGHT_OPTION_SHB_OS);
+	if (opt != NULL)
+	{
+		file_info->os_desc_size = light_get_option_length(opt);
+		file_info->os_desc = calloc(file_info->os_desc_size+1, sizeof(char));
+		memcpy(file_info->os_desc, (char*)light_get_option_data(opt), file_info->os_desc_size);
+		file_info->os_desc[file_info->os_desc_size] = '\0';
+	}
+	else
+	{
+		file_info->os_desc_size = 0;
+		file_info->os_desc = NULL;
+	}
+
+	opt = light_get_option(iter, LIGHT_OPTION_SHB_USERAPPL);
+	if (opt != NULL)
+	{
+		file_info->user_app_desc_size = light_get_option_length(opt);
+		file_info->user_app_desc = calloc(file_info->user_app_desc_size+1, sizeof(char));
+		memcpy(file_info->user_app_desc, (char*)light_get_option_data(opt), file_info->user_app_desc_size);
+		file_info->user_app_desc[file_info->user_app_desc_size] = '\0';
+	}
+	else
+	{
+		file_info->user_app_desc_size = 0;
+		file_info->user_app_desc = NULL;
+	}
+
+	opt = light_get_option(iter, LIGHT_OPTION_COMMENT);
+	if (opt != NULL)
+	{
+		file_info->file_comment_size = light_get_option_length(opt);
+		file_info->file_comment = calloc(file_info->file_comment_size+1, sizeof(char));
+		memcpy(file_info->file_comment, (char*)light_get_option_data(opt), file_info->file_comment_size);
+		file_info->file_comment[file_info->file_comment_size] = '\0';
+	}
+	else
+	{
+		file_info->file_comment_size = 0;
+		file_info->file_comment = NULL;
+	}
+
+	file_info->interface_block_count = 0;
+
+	return file_info;
+}
+
+static double __power_of(int x, int y)
+{
+	int i;
+	double res = 1;
+
+	if (y < 0)
+		return 1 / __power_of(x, -y);
+
+	for (i = 0; i < y; i++)
+		res *= x;
+
+	return res;
+}
+
+static void __append_interface_block_to_file_info(const light_pcapng interface_block, light_pcapng_file_info* info)
+{
+	struct _light_interface_description_block* interface_desc_block;
+	light_option ts_resolution_option = NULL;
+
+	if (info->interface_block_count > MAX_SUPPORTED_INTERFACE_BLOCKS)
+		return;
+
+	light_get_block_info(interface_block, LIGHT_INFO_BODY, &interface_desc_block, NULL);
+
+	ts_resolution_option = light_get_option(interface_block, LIGHT_OPTION_IF_TSRESOL);
+	if (ts_resolution_option == NULL)
+	{
+		info->timestamp_resolution[info->interface_block_count] = __power_of(10,-6);
+	}
+	else
+	{
+		uint8_t* raw_ts_data = (uint8_t*)light_get_option_data(ts_resolution_option);
+		if (*raw_ts_data < 128)
+			info->timestamp_resolution[info->interface_block_count] = __power_of(10, (-1)*(*raw_ts_data));
+		else
+			info->timestamp_resolution[info->interface_block_count] = __power_of(2, (-1)*((*raw_ts_data)-128));
+	}
+
+	info->link_types[info->interface_block_count++] = interface_desc_block->link_type;
+}
+
+static light_boolean __is_open_for_write(const struct _light_pcapng_t* pcapng)
+{
+	if (pcapng->file != NULL)
+		return LIGHT_TRUE;
+
+	return LIGHT_FALSE;
+}
+
+light_pcapng_t *light_pcapng_open_read(const char* file_path, light_boolean read_all_interfaces)
+{
+	DCHECK_NULLP(file_path, return NULL);
+
+	light_pcapng_t *pcapng = calloc(1, sizeof(struct _light_pcapng_t));
+	pcapng->pcapng = light_read_from_path(file_path);
+	pcapng->pcapng_iter = pcapng->pcapng;
+	pcapng->file_info = __create_file_info(pcapng->pcapng);
+	pcapng->file = NULL;
+
+	if (read_all_interfaces)
+	{
+		light_pcapng iter = pcapng->pcapng;
+		while (iter != NULL)
+		{
+			uint32_t type = LIGHT_UNKNOWN_DATA_BLOCK;
+			light_get_block_info(iter, LIGHT_INFO_TYPE, &type, NULL);
+			if (type == LIGHT_INTERFACE_BLOCK)
+				__append_interface_block_to_file_info(iter, pcapng->file_info);
+			iter = light_next_block(iter);
+		}
+
+	}
+
+	return pcapng;
+}
+
+light_pcapng_t *light_pcapng_open_write(const char* file_path, light_pcapng_file_info *file_info)
+{
+	DCHECK_NULLP(file_info, return NULL);
+	DCHECK_NULLP(file_path, return NULL);
+
+	light_pcapng_t *pcapng = calloc(1, sizeof(struct _light_pcapng_t));
+	pcapng->file = light_open(file_path, LIGHT_OWRITE);
+	pcapng->file_info = file_info;
+
+	struct _light_section_header section_header;
+	section_header.byteorder_magic = BYTE_ORDER_MAGIC;
+	section_header.major_version = file_info->major_version;
+	section_header.minor_version = file_info->minor_version;
+	section_header.section_length = 0xFFFFFFFFFFFFFFFFULL;
+	pcapng->pcapng = light_alloc_block(LIGHT_SECTION_HEADER_BLOCK, (const uint32_t*)&section_header, sizeof(section_header)+3*sizeof(uint32_t));
+
+	if (file_info->file_comment_size > 0)
+	{
+		light_option new_opt = light_create_option(LIGHT_OPTION_COMMENT, file_info->file_comment_size, file_info->file_comment);
+		light_add_option(pcapng->pcapng, pcapng->pcapng, new_opt, LIGHT_FALSE);
+	}
+
+	if (file_info->hardware_desc_size > 0)
+	{
+		light_option new_opt = light_create_option(LIGHT_OPTION_SHB_HARDWARE, file_info->hardware_desc_size, file_info->hardware_desc);
+		light_add_option(pcapng->pcapng, pcapng->pcapng, new_opt, LIGHT_FALSE);
+	}
+
+	if (file_info->os_desc_size > 0)
+	{
+		light_option new_opt = light_create_option(LIGHT_OPTION_SHB_OS, file_info->os_desc_size, file_info->os_desc);
+		light_add_option(pcapng->pcapng, pcapng->pcapng, new_opt, LIGHT_FALSE);
+	}
+
+	if (file_info->user_app_desc_size > 0)
+	{
+		light_option new_opt = light_create_option(LIGHT_OPTION_SHB_USERAPPL, file_info->user_app_desc_size, file_info->user_app_desc);
+		light_add_option(pcapng->pcapng, pcapng->pcapng, new_opt, LIGHT_FALSE);
+	}
+
+	pcapng->pcapng_iter = pcapng->pcapng;
+	int i = 0;
+	for (i = 0; i < file_info->interface_block_count; i++)
+	{
+		struct _light_interface_description_block interface_block;
+		interface_block.link_type = file_info->link_types[i];
+		interface_block.reserved = 0;
+		interface_block.snapshot_length = 0;
+
+		light_pcapng iface_block_pcapng = light_alloc_block(LIGHT_INTERFACE_BLOCK, (const uint32_t*)&interface_block, sizeof(struct _light_interface_description_block)+3*sizeof(uint32_t));
+		light_add_block(pcapng->pcapng_iter, iface_block_pcapng);
+		pcapng->pcapng_iter = iface_block_pcapng;
+	}
+
+	size_t section_memory_size = 0;
+	uint32_t *file_memory = light_pcapng_to_memory(pcapng->pcapng, &section_memory_size);
+	light_write(pcapng->file, file_memory, section_memory_size);
+	free(file_memory);
+
+	return pcapng;
+}
+
+light_pcapng_t *light_pcapng_open_append(const char* file_path)
+{
+	DCHECK_NULLP(file_path, return NULL);
+
+	light_pcapng_t *pcapng = light_pcapng_open_read(file_path, LIGHT_TRUE);
+	DCHECK_NULLP(pcapng, return NULL);
+
+	light_pcapng iter = pcapng->pcapng;
+	while (iter != NULL)
+	{
+		pcapng->pcapng_iter = iter;
+		iter = light_next_block(iter);
+	}
+
+	pcapng->file = light_open(file_path, LIGHT_OAPPEND);
+
+	return pcapng;
+}
+
+light_pcapng_file_info *light_create_default_file_info()
+{
+	light_pcapng_file_info *default_file_info = calloc(1, sizeof(light_pcapng_file_info));
+	memset(default_file_info, 0, sizeof(light_pcapng_file_info));
+	default_file_info->major_version = 1;
+	return default_file_info;
+}
+
+light_pcapng_file_info *light_create_file_info(const char *os_desc, const char *hardware_desc, const char *user_app_desc, const char *file_comment)
+{
+	light_pcapng_file_info *info = light_create_default_file_info();
+
+	if (os_desc != NULL && strlen(os_desc) > 0)
+	{
+		size_t os_len = strlen(os_desc);
+		info->os_desc = calloc(os_len, sizeof(char));
+		memcpy(info->os_desc, os_desc, os_len);
+		info->os_desc_size = os_len;
+	}
+
+	if (hardware_desc != NULL && strlen(hardware_desc) > 0)
+	{
+		size_t hw_len = strlen(hardware_desc);
+		info->hardware_desc = calloc(hw_len, sizeof(char));
+		memcpy(info->hardware_desc, hardware_desc, hw_len);
+		info->hardware_desc_size = hw_len;
+	}
+
+	if (user_app_desc != NULL && strlen(user_app_desc) > 0)
+	{
+		size_t app_len = strlen(user_app_desc);
+		info->user_app_desc = calloc(app_len, sizeof(char));
+		memcpy(info->user_app_desc, user_app_desc, app_len);
+		info->user_app_desc_size = app_len;
+	}
+
+	if (file_comment != NULL && strlen(file_comment) > 0)
+	{
+		size_t comment_len = strlen(file_comment);
+		info->file_comment = calloc(comment_len, sizeof(char));
+		memcpy(info->file_comment, file_comment, comment_len);
+		info->file_comment_size = comment_len;
+	}
+
+	return info;
+}
+
+void light_free_file_info(light_pcapng_file_info *info)
+{
+	if (info->user_app_desc != NULL)
+		free(info->user_app_desc);
+
+	if (info->file_comment != NULL)
+		free(info->file_comment);
+
+	if (info->hardware_desc != NULL)
+		free(info->hardware_desc);
+
+	if (info->os_desc != NULL)
+		free(info->os_desc);
+
+	free(info);
+}
+
+light_pcapng_file_info *light_pcang_get_file_info(light_pcapng_t *pcapng)
+{
+	DCHECK_NULLP(pcapng, return NULL);
+	return pcapng->file_info;
+}
+
+int light_get_next_packet(light_pcapng_t *pcapng, light_packet_header *packet_header, const uint8_t **packet_data)
+{
+	uint32_t type = LIGHT_UNKNOWN_DATA_BLOCK;
+
+	if (pcapng->pcapng_iter == NULL)
+		return 0;
+
+	light_get_block_info(pcapng->pcapng_iter, LIGHT_INFO_TYPE, &type, NULL);
+
+	while (pcapng->pcapng_iter != NULL && type != LIGHT_ENHANCED_PACKET_BLOCK && type != LIGHT_SIMPLE_PACKET_BLOCK)
+	{
+		if (type == LIGHT_INTERFACE_BLOCK)
+			__append_interface_block_to_file_info(pcapng->pcapng_iter, pcapng->file_info);
+
+		pcapng->pcapng_iter = light_next_block(pcapng->pcapng_iter);
+		if (pcapng->pcapng_iter == NULL)
+			break;
+		light_get_block_info(pcapng->pcapng_iter, LIGHT_INFO_TYPE, &type, NULL);
+	}
+
+	*packet_data = NULL;
+
+	if (pcapng->pcapng_iter == NULL)
+		return 0;
+
+	if (type == LIGHT_ENHANCED_PACKET_BLOCK)
+	{
+		struct _light_enhanced_packet_block *epb = NULL;
+
+		light_get_block_info(pcapng->pcapng_iter, LIGHT_INFO_BODY, &epb, NULL);
+
+		packet_header->interface_id = epb->interface_id;
+		packet_header->captured_length = epb->capture_packet_length;
+		packet_header->original_length = epb->original_capture_length;
+		uint64_t timestamp = epb->timestamp_high;
+		timestamp = timestamp << 32;
+		timestamp += epb->timestamp_low;
+		double timestamp_res = pcapng->file_info->timestamp_resolution[epb->interface_id];
+		packet_header->timestamp.tv_sec = timestamp * timestamp_res;
+		packet_header->timestamp.tv_usec = (timestamp - (packet_header->timestamp.tv_sec / timestamp_res))*timestamp_res*1000000;
+		if (epb->interface_id < pcapng->file_info->interface_block_count)
+			packet_header->data_link = pcapng->file_info->link_types[epb->interface_id];
+
+		*packet_data = (uint8_t*)epb->packet_data;
+	}
+
+	else if (type == LIGHT_SIMPLE_PACKET_BLOCK)
+	{
+		struct _light_simple_packet_block *spb = NULL;
+
+		light_get_block_info(pcapng->pcapng_iter, LIGHT_INFO_BODY, &spb, NULL);
+
+		packet_header->interface_id = 0;
+		packet_header->captured_length = spb->original_packet_length;
+		packet_header->original_length = spb->original_packet_length;
+		packet_header->timestamp.tv_sec = 0;
+		packet_header->timestamp.tv_usec = 0;
+		if (pcapng->file_info->interface_block_count > 0)
+			packet_header->data_link = pcapng->file_info->link_types[0];
+
+		*packet_data = (uint8_t*)spb->packet_data;
+	}
+
+	packet_header->comment = NULL;
+	packet_header->comment_length = 0;
+
+	light_option option = light_get_option(pcapng->pcapng_iter, 1); // get comment
+	if (option != NULL)
+	{
+		packet_header->comment_length = light_get_option_length(option);
+		packet_header->comment = (char*)light_get_option_data(option);
+	}
+
+	pcapng->pcapng_iter = light_next_block(pcapng->pcapng_iter);
+
+	return 1;
+}
+
+void light_write_packet(light_pcapng_t *pcapng, const light_packet_header *packet_header, const uint8_t *packet_data)
+{
+	DCHECK_NULLP(pcapng, return);
+	DCHECK_NULLP(packet_header, return);
+	DCHECK_NULLP(packet_data, return);
+	DCHECK_ASSERT_EXP(__is_open_for_write(pcapng) == LIGHT_TRUE, "file not open for writing", return);
+
+	size_t iface_id = 0;
+	for (iface_id = 0; iface_id < pcapng->file_info->interface_block_count; iface_id++)
+	{
+		if (pcapng->file_info->link_types[iface_id] == packet_header->data_link)
+			break;
+	}
+
+	light_pcapng blocks_to_write = NULL;
+
+	if (iface_id >= pcapng->file_info->interface_block_count)
+	{
+		struct _light_interface_description_block interface_block;
+		interface_block.link_type = packet_header->data_link;
+		interface_block.reserved = 0;
+		interface_block.snapshot_length = 0;
+
+		light_pcapng iface_block_pcapng = light_alloc_block(LIGHT_INTERFACE_BLOCK, (const uint32_t*)&interface_block, sizeof(struct _light_interface_description_block)+3*sizeof(uint32_t));
+		light_add_block(pcapng->pcapng_iter, iface_block_pcapng);
+		pcapng->pcapng_iter = iface_block_pcapng;
+
+		blocks_to_write = iface_block_pcapng;
+		__append_interface_block_to_file_info(iface_block_pcapng, pcapng->file_info);
+	}
+
+	size_t option_size = sizeof(struct _light_enhanced_packet_block) + packet_header->captured_length;
+	PADD32(option_size, &option_size);
+	uint8_t *epb_memory = calloc(1, option_size);
+	memset(epb_memory, 0, option_size);
+	struct _light_enhanced_packet_block *epb = (struct _light_enhanced_packet_block *)epb_memory;
+	epb->interface_id = iface_id;
+	uint64_t timestamp_usec = (uint64_t)packet_header->timestamp.tv_sec * (uint64_t)1000000 + (uint64_t)packet_header->timestamp.tv_usec;
+	epb->timestamp_high = timestamp_usec >> 32;
+	epb->timestamp_low = timestamp_usec & 0xFFFFFFFF;
+	epb->capture_packet_length = packet_header->captured_length;
+	epb->original_capture_length = packet_header->original_length;
+
+	memcpy(epb->packet_data, packet_data, packet_header->captured_length);
+
+//	int i = 0;
+//
+//	for (i = 0; i < packet_header->captured_length; i++)
+//	{
+//		if (i % 4 == 0)
+//			printf("  ");
+//
+//		printf("0x%X ", packet_data[i]);
+//	}
+//
+//	printf("\n\n\n");
+//
+//	for (i = 0; i < sizeof(struct _light_enhanced_packet_block) + packet_header->captured_length; i++)
+//	{
+//		if (i % 4 == 0)
+//			printf("  ");
+//
+//		printf("0x%X ", epb_memory[i]);
+//	}
+
+
+	light_pcapng packet_block_pcapng = light_alloc_block(LIGHT_ENHANCED_PACKET_BLOCK, (const uint32_t*)epb_memory, option_size+3*sizeof(uint32_t));
+	light_add_block(pcapng->pcapng_iter, packet_block_pcapng);
+	free(epb_memory);
+
+	if (packet_header->comment_length > 0)
+	{
+		light_option packet_comment_opt = light_create_option(LIGHT_OPTION_COMMENT, packet_header->comment_length, packet_header->comment);
+		light_add_option(NULL, packet_block_pcapng, packet_comment_opt, LIGHT_FALSE);
+	}
+
+	pcapng->pcapng_iter = packet_block_pcapng;
+
+	if (blocks_to_write == NULL)
+		blocks_to_write = packet_block_pcapng;
+
+	size_t blocks_memory_size = 0;
+	uint32_t *file_memory = light_pcapng_to_memory(blocks_to_write, &blocks_memory_size);
+	light_write(pcapng->file, file_memory, blocks_memory_size);
+	free(file_memory);
+}
+
+void light_pcapng_close(light_pcapng_t *pcapng)
+{
+	DCHECK_NULLP(pcapng, return);
+	light_pcapng_release(pcapng->pcapng);
+	if (pcapng->file != NULL)
+	{
+		light_flush(pcapng->file);
+		light_close(pcapng->file);
+	}
+	light_free_file_info(pcapng->file_info);
+	free(pcapng);
+}

http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/blob/c0a788b3/thirdparty/pcap++/3rdParty/LightPcapNg/LightPcapNg/src/light_platform.c
----------------------------------------------------------------------
diff --git a/thirdparty/pcap++/3rdParty/LightPcapNg/LightPcapNg/src/light_platform.c b/thirdparty/pcap++/3rdParty/LightPcapNg/LightPcapNg/src/light_platform.c
new file mode 100644
index 0000000..ae07c65
--- /dev/null
+++ b/thirdparty/pcap++/3rdParty/LightPcapNg/LightPcapNg/src/light_platform.c
@@ -0,0 +1,89 @@
+// light_platform.c
+// Created on: Jul 23, 2016
+
+// Copyright (c) 2016 Radu Velea
+
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included in all
+// copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+// SOFTWARE.
+
+#include "light_platform.h"
+
+#include "light_internal.h"
+
+#include <stdio.h>
+
+#ifdef UNIVERSAL
+
+__fd_t light_open(const char *file_name, const __read_mode_t mode)
+{
+	__fd_t fd = (__fd_t)INVALID_FILE;
+
+	switch (mode) {
+	case LIGHT_OREAD:
+		fd = fopen(file_name, "rb");
+		break;
+	case LIGHT_OWRITE:
+		fd = fopen(file_name, "wb");
+		break;
+	case LIGHT_OAPPEND:
+		fd = fopen(file_name, "ab");
+		break;
+	}
+
+	return fd;
+}
+
+int light_read(__fd_t fd, void *buf, size_t count)
+{
+	size_t bytes_read = fread(buf, 1, count, fd);
+	return  bytes_read != count ? -1 : bytes_read;
+}
+
+int light_write(__fd_t fd, const void *buf, size_t count)
+{
+	size_t bytes_written = fwrite(buf, 1, count, fd);
+	return  bytes_written != count ? -1 : bytes_written;
+}
+
+size_t light_size(__fd_t fd)
+{
+	size_t size = 0;
+	size_t current = ftell(fd);
+
+	fseek(fd, 0, SEEK_END);
+	size = ftell(fd);
+	fseek(fd, current, SEEK_SET);
+
+	return size;
+}
+
+int light_close(__fd_t fd)
+{
+	return fclose(fd);
+}
+
+int light_flush(__fd_t fd)
+{
+	return fflush(fd);
+}
+
+#else
+
+#error UNIMPLEMENRTED
+
+#endif

http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/blob/c0a788b3/thirdparty/pcap++/3rdParty/LightPcapNg/LightPcapNg/src/tests/features/Makefile
----------------------------------------------------------------------
diff --git a/thirdparty/pcap++/3rdParty/LightPcapNg/LightPcapNg/src/tests/features/Makefile b/thirdparty/pcap++/3rdParty/LightPcapNg/LightPcapNg/src/tests/features/Makefile
new file mode 100644
index 0000000..8f19ae3
--- /dev/null
+++ b/thirdparty/pcap++/3rdParty/LightPcapNg/LightPcapNg/src/tests/features/Makefile
@@ -0,0 +1,10 @@
+all: libfeatures.so features_cluster
+
+libfeatures.so: *.c
+	gcc -Wall -O2 -g -shared $^ -o $@ -Iinclude -fPIC -L. -llight_pcapng
+
+features_cluster: features_cluster.cc cluster.cc
+	g++ -std=c++11 -Wall -O2 -g $^ -o $@
+
+clean:
+	rm -rf libfeatures.so features_cluster
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/blob/c0a788b3/thirdparty/pcap++/3rdParty/LightPcapNg/LightPcapNg/src/tests/features/cluster.cc
----------------------------------------------------------------------
diff --git a/thirdparty/pcap++/3rdParty/LightPcapNg/LightPcapNg/src/tests/features/cluster.cc b/thirdparty/pcap++/3rdParty/LightPcapNg/LightPcapNg/src/tests/features/cluster.cc
new file mode 100644
index 0000000..b5ffdd7
--- /dev/null
+++ b/thirdparty/pcap++/3rdParty/LightPcapNg/LightPcapNg/src/tests/features/cluster.cc
@@ -0,0 +1,173 @@
+/*
+ * cluster.cc
+ *
+ *  Created on: Nov 4, 2016
+ *      Author: rvelea
+ */
+
+#include "cluster.h"
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <time.h>
+
+#define EPSILON 0.00000001
+
+double Cluster::distance(const vector<double> &x)
+{
+	double distance = 0;
+	for (unsigned i = 0; i < x.size(); ++i) {
+		double diff = x[i] - center[i];
+		distance += diff * diff;
+	}
+
+	return distance;
+}
+
+double Cluster::recompute_center()
+{
+	if (members.size() == 0) {
+		return 0;
+	}
+
+	double center_diff = 0.0;
+
+	for (unsigned i = 0; i < center.size(); ++i) {
+		double sum = 0.0;
+		for (auto it : members) {
+			vector <double> &vals = it->entries;
+			sum += vals[i];
+		}
+
+		sum /= members.size();
+		center_diff += (center[i] - sum) * (center[i] - sum);
+		center[i] = sum;
+	}
+
+	return center_diff;
+}
+
+Galaxy::Galaxy(int sz, vector<csv_entry_t *> &elements, int iter) : size(sz), stars(elements), iterations(iter)
+{
+	srand(time(NULL));
+}
+
+void Galaxy::compute_clusters()
+{
+	int world_size = stars.size();
+
+	error = 1000000.0;
+
+	for (auto iteration = 0; iteration < iterations; ++iteration) {
+		vector<Cluster *> current_clusters;
+
+		int failures = 0;
+
+		// printf("Start reinitialization!\n");
+
+		// Randomly initialize clusters.
+		for (auto i = 0; i < size; ++i) {
+			int random = rand() % world_size;
+			bool valid = true;
+
+			for (auto c : current_clusters) {
+				if (c->id() == random || c->distance(stars[random]->entries) <= EPSILON) {
+					if (failures >= world_size / size) {
+						// printf("Failed to find enough entropy for %d centers!\n", size);
+
+						// Some clean-up.
+						while (!current_clusters.empty()) {
+							Cluster *tmp = current_clusters.back();
+							current_clusters.pop_back();
+							delete tmp;
+						}
+
+						return;
+					}
+
+					valid = false;
+					break;
+				}
+			}
+
+			if (valid == true) {
+				Cluster *new_cluster = new Cluster(stars[random]->entries, random);
+				current_clusters.push_back(new_cluster);
+			}
+			else {
+				failures++;
+				i--;
+			}
+		}
+
+		// printf("Successfully initialized centers!\n");
+
+		double convergence_error = 1000000.0;
+
+		while (convergence_error * convergence_error > EPSILON) {
+			convergence_error = 0.0;
+
+			for (auto i = 0; i < size; ++i) {
+				current_clusters[i]->reset();
+			}
+
+			for (auto i = 0; i < world_size; ++i) {
+				csv_entry_t *current_element = stars[i];
+				double min_distance = 1000000.0;
+				int index = -1;
+				for (auto j = 0; j < size; ++j) {
+					double d = current_clusters[j]->distance(current_element->entries);
+					if (d < min_distance) {
+						min_distance = d;
+						index = j;
+					}
+				}
+				current_clusters[index]->add_member(current_element, min_distance);
+			}
+
+			for (auto i = 0; i < size; ++i) {
+				convergence_error += current_clusters[i]->recompute_center();
+			}
+		}
+
+		// printf("Total error computed for %d iteration = %.12lf\n", iteration, convergence_error);
+
+		double current_error = 0.0;
+		for (auto c : current_clusters) {
+			current_error += c->get_error();
+		}
+
+		if (error > current_error) {
+			is_valid = true;
+
+			while (!clusters.empty()) {
+				Cluster *tmp = clusters.back();
+				clusters.pop_back();
+				delete tmp;
+			}
+
+			clusters = current_clusters;
+			error = current_error;
+		}
+		else {
+			while (!current_clusters.empty()) {
+				Cluster *tmp = current_clusters.back();
+				current_clusters.pop_back();
+				delete tmp;
+			}
+		}
+	}
+}
+
+void Galaxy::print() const
+{
+	printf("Current \"Galaxy\" has %d clusters and a total population of %lu:\n", size, stars.size());
+	for (auto i : clusters) {
+		printf("\t(");
+		for (unsigned j = 0; j < i->get_center().size(); ++j) {
+			printf("%.8lf, ", i->get_center().at(j));
+		}
+		printf(") has %u elements\n", i->get_size());
+	}
+	printf("\n\n");
+}

http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/blob/c0a788b3/thirdparty/pcap++/3rdParty/LightPcapNg/LightPcapNg/src/tests/features/cluster.h
----------------------------------------------------------------------
diff --git a/thirdparty/pcap++/3rdParty/LightPcapNg/LightPcapNg/src/tests/features/cluster.h b/thirdparty/pcap++/3rdParty/LightPcapNg/LightPcapNg/src/tests/features/cluster.h
new file mode 100644
index 0000000..0f640f2
--- /dev/null
+++ b/thirdparty/pcap++/3rdParty/LightPcapNg/LightPcapNg/src/tests/features/cluster.h
@@ -0,0 +1,63 @@
+/*
+ * cluster.h
+ *
+ *  Created on: Nov 4, 2016
+ *      Author: rvelea
+ */
+
+#ifndef SRC_TESTS_FEATURES_CLUSTER_H_
+#define SRC_TESTS_FEATURES_CLUSTER_H_
+
+#include <string>
+#include <vector>
+
+using namespace std;
+
+typedef struct csv_entry {
+	int count;
+	string addr1, addr2;
+	vector<double> entries;
+	vector<unsigned long long> original_values;
+} csv_entry_t;
+
+class Cluster {
+public:
+	Cluster(const vector<double> values, int id = 0) : center(values), identifier(id) {}
+
+	double distance(const vector<double> &x);
+	void add_member(csv_entry_t *e, double dist) { members.push_back(e); error += dist; }
+	void reset() { error = 0; members.clear(); }
+	double recompute_center();
+	int id() { return identifier; }
+	int get_size() { return members.size(); }
+	vector <double> &get_center() { return center; }
+	double get_error() { return error; }
+
+	virtual ~Cluster() {}
+
+private:
+	double error = 0;
+	vector<double> center;
+	vector<csv_entry_t *> members;
+	int identifier;
+};
+
+class Galaxy {
+public:
+	Galaxy(int sz, vector<csv_entry_t *> &elements, int iter);
+	void compute_clusters();
+	double get_error() { return error; }
+	bool valid() { return is_valid; }
+	void print() const;
+	virtual ~Galaxy() {}
+
+private:
+	double error = 0;
+	int size;
+	vector<Cluster *> clusters;
+	vector<csv_entry_t *> &stars;
+	int iterations;
+	bool is_valid = false;
+};
+
+#endif /* SRC_TESTS_FEATURES_CLUSTER_H_ */

http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/blob/c0a788b3/thirdparty/pcap++/3rdParty/LightPcapNg/LightPcapNg/src/tests/features/feature_list.txt
----------------------------------------------------------------------
diff --git a/thirdparty/pcap++/3rdParty/LightPcapNg/LightPcapNg/src/tests/features/feature_list.txt b/thirdparty/pcap++/3rdParty/LightPcapNg/LightPcapNg/src/tests/features/feature_list.txt
new file mode 100644
index 0000000..f09a62d
--- /dev/null
+++ b/thirdparty/pcap++/3rdParty/LightPcapNg/LightPcapNg/src/tests/features/feature_list.txt
@@ -0,0 +1,2 @@
+_f_data_transfered
+_f_trace_duration

http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/blob/c0a788b3/thirdparty/pcap++/3rdParty/LightPcapNg/LightPcapNg/src/tests/features/features.h
----------------------------------------------------------------------
diff --git a/thirdparty/pcap++/3rdParty/LightPcapNg/LightPcapNg/src/tests/features/features.h b/thirdparty/pcap++/3rdParty/LightPcapNg/LightPcapNg/src/tests/features/features.h
new file mode 100644
index 0000000..6a12eea
--- /dev/null
+++ b/thirdparty/pcap++/3rdParty/LightPcapNg/LightPcapNg/src/tests/features/features.h
@@ -0,0 +1,15 @@
+/*
+ * features.h
+ *
+ *  Created on: Nov 1, 2016
+ *      Author: rvelea
+ */
+
+#ifndef SRC_TESTS_FEATURES_FEATURES_H_
+#define SRC_TESTS_FEATURES_FEATURES_H_
+
+#include <stdint.h>
+
+typedef uint64_t feature_type_t;
+
+#endif /* SRC_TESTS_FEATURES_FEATURES_H_ */

http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/blob/c0a788b3/thirdparty/pcap++/3rdParty/LightPcapNg/LightPcapNg/src/tests/features/features_cluster.cc
----------------------------------------------------------------------
diff --git a/thirdparty/pcap++/3rdParty/LightPcapNg/LightPcapNg/src/tests/features/features_cluster.cc b/thirdparty/pcap++/3rdParty/LightPcapNg/LightPcapNg/src/tests/features/features_cluster.cc
new file mode 100644
index 0000000..13e0bb1
--- /dev/null
+++ b/thirdparty/pcap++/3rdParty/LightPcapNg/LightPcapNg/src/tests/features/features_cluster.cc
@@ -0,0 +1,166 @@
+/*
+ * features_cluster.cc
+ *
+ *  Created on: Nov 3, 2016
+ *      Author: rvelea
+ */
+
+#include "cluster.h"
+
+#include <stdint.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+#include <fstream>
+#include <iostream>
+#include <regex>
+#include <vector>
+
+using namespace std;
+
+static int number_of_entries = 0;
+static vector<string> csv_labels;
+
+static int zero_count(const csv_entry *e)
+{
+	int zeros = 0;
+	for (auto i : e->entries) {
+		if (i == 0.0) {
+			zeros++;
+		}
+	}
+
+	return zeros;
+}
+
+static csv_entry_t *make_csv_entry(const char *csv_line)
+{
+	string line(csv_line);
+	regex re("[\\s,]+");
+	sregex_token_iterator it(line.begin(), line.end(), re, -1);
+	sregex_token_iterator reg_end;
+
+	csv_entry *e = new csv_entry;
+
+	// Skip keys/description.
+	e->addr1 = it->str();
+	it++;
+	e->addr2 = it->str();
+	it++;
+
+	e->count = 0;
+
+	for (; it != reg_end; it++) {
+		unsigned long long value = atoll(it->str().c_str());
+		e->entries.push_back(value);
+		e->original_values.push_back(value);
+		e->count++;
+	}
+
+	return e;
+}
+
+static bool read_csv_file(const char *csv_file_path, vector<csv_entry_t *> &entries)
+{
+	ifstream csv(csv_file_path, ifstream::in);
+	char header[256] = {0,};
+
+	csv.getline(header, sizeof(header));
+
+	string s(header);
+	regex re("[\\s,]+");
+	sregex_token_iterator it(s.begin(), s.end(), re, -1);
+	sregex_token_iterator reg_end;
+
+	for (; it != reg_end; it++) {
+		csv_labels.push_back(it->str());
+	}
+
+	while (!csv.eof()) {
+		char line[256] = {0,};
+		csv.getline(line, sizeof(line));
+		if (strlen(line) <= 1) {
+			continue;
+		}
+
+		csv_entry_t *e = make_csv_entry(line);
+		if (zero_count(e) == 0) {
+			entries.push_back(e);
+			number_of_entries++;
+		}
+		else {
+			delete e;
+		}
+	}
+
+	csv.close();
+
+	return true;
+}
+
+static double rescale(const double &v, const double &min, const double &max)
+{
+	return (v - min) / (max - min);
+}
+
+static void scale_features(vector<csv_entry_t *> &entries)
+{
+	vector<double> min, max;
+	csv_entry_t *reference = entries[0];
+
+	for (auto d : reference->entries) {
+		min.push_back(d);
+		max.push_back(d);
+	}
+
+	for (auto it : entries) {
+		csv_entry_t *current = it;
+		for (unsigned i = 0; i < current->entries.size(); ++i) {
+			if (min[i] > current->entries[i]) {
+				min[i] = current->entries[i];
+			}
+			if (max[i] < current->entries[i]) {
+				max[i] = current->entries[i];
+			}
+		}
+	}
+
+	for (auto it : entries) {
+		csv_entry_t *current = it;
+		for (unsigned i = 0; i < current->entries.size(); ++i) {
+			current->entries[i] = rescale(current->entries[i], min[i], max[i]);
+		}
+	}
+}
+
+static void cluster_data(vector<csv_entry_t *> &data)
+{
+	for (auto i = 2; i < 8; ++i) {
+		Galaxy g(i, data, data.size());
+		g.compute_clusters();
+		if (g.valid()) {
+			printf("K-means algorithm for %d clusters has %.12lf total error.\n", i, g.get_error());
+			g.print();
+		}
+	}
+}
+
+int main(int argc, const char **args) {
+
+	if (argc < 2) {
+		fprintf(stderr, "Please provide path to CSV in cmdline!\n");
+		return 0;
+	}
+
+	vector<csv_entry_t *> entries;
+	if (read_csv_file(args[1], entries) == false) {
+		fprintf(stderr, "Unable to read input file %s\n", args[1]);
+	}
+
+	scale_features(entries);
+	// Now we only have to deal with [0..1] values.
+
+	cluster_data(entries);
+
+	return 0;
+}

http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/blob/c0a788b3/thirdparty/pcap++/3rdParty/LightPcapNg/LightPcapNg/src/tests/features/features_impl.c
----------------------------------------------------------------------
diff --git a/thirdparty/pcap++/3rdParty/LightPcapNg/LightPcapNg/src/tests/features/features_impl.c b/thirdparty/pcap++/3rdParty/LightPcapNg/LightPcapNg/src/tests/features/features_impl.c
new file mode 100644
index 0000000..7379d55
--- /dev/null
+++ b/thirdparty/pcap++/3rdParty/LightPcapNg/LightPcapNg/src/tests/features/features_impl.c
@@ -0,0 +1,106 @@
+/*
+ * feature_impl.c
+ *
+ *  Created on: Nov 1, 2016
+ *      Author: rvelea
+ */
+
+#include "features.h"
+
+#include <light_pcapng.h>
+
+#include <stdio.h>
+
+static uint64_t my_pow(uint32_t base, uint32_t exponent)
+{
+	uint64_t result = 1;
+
+	while (exponent-- > 0) {
+		result = result * base;
+	}
+
+	return result;
+}
+
+feature_type_t _f_data_transfered(const light_pcapng pcapng)
+{
+	feature_type_t bytes = 0;
+	uint32_t block_type;
+	light_pcapng iterator = pcapng;
+
+	while (iterator != NULL) {
+		light_get_block_info(iterator, LIGHT_INFO_TYPE, &block_type, NULL);
+		if (block_type == LIGHT_ENHANCED_PACKET_BLOCK) {
+			struct _light_enhanced_packet_block *epb;
+			light_get_block_info(iterator, LIGHT_INFO_BODY, &epb, NULL);
+			bytes += epb->original_capture_length;
+		}
+		else if (block_type == LIGHT_SIMPLE_PACKET_BLOCK) {
+			struct _light_simple_packet_block *spb;
+			light_get_block_info(iterator, LIGHT_INFO_BODY, &spb, NULL);
+			bytes += spb->original_packet_length;
+		}
+
+		iterator = light_next_block(iterator);
+	}
+
+	return bytes;
+}
+
+feature_type_t _f_trace_duration(const light_pcapng pcapng)
+{
+	feature_type_t duration;
+	uint64_t resolution = 1000; // Microsecond resolution.
+	int first_block = 1;
+	uint64_t first_timestamp = 0;
+	uint64_t current_timestamp = 0;
+	uint32_t block_type;
+	light_pcapng iterator = pcapng;
+
+	while (iterator != NULL) {
+		light_get_block_info(iterator, LIGHT_INFO_TYPE, &block_type, NULL);
+		if (block_type == LIGHT_INTERFACE_BLOCK) {
+			light_option timestamp_resolution = light_get_option(iterator, LIGHT_OPTION_IF_TSRESOL);
+			if (timestamp_resolution != NULL) {
+				uint8_t *interface_resolution = (uint8_t *)light_get_option_data(timestamp_resolution);
+				uint8_t value = *interface_resolution & 0x7F;
+
+				if ((*interface_resolution & 0x80) == 0) { // Resolution is negative power of 10.
+					resolution = 1000000000 / my_pow(10, value);
+				}
+				else { // Resolution is negative power of 2.
+					resolution = 1000000000 / my_pow(2, value);
+				}
+
+				if (resolution == 0) {
+					fprintf(stderr, "Invalid resolution: %u\n", value);
+					resolution = 1000;
+				}
+			}
+		}
+		else if (block_type == LIGHT_ENHANCED_PACKET_BLOCK) {
+			struct _light_enhanced_packet_block *epb;
+			light_get_block_info(iterator, LIGHT_INFO_BODY, &epb, NULL);
+			current_timestamp = ((uint64_t)epb->timestamp_high << 32) + epb->timestamp_low;
+			if (first_block == 1) {
+				first_timestamp = current_timestamp;
+				first_block = 0;
+			}
+			else if (first_timestamp > current_timestamp) {
+				fprintf(stderr, "We are going back in time!\n");
+				first_timestamp = current_timestamp;
+			}
+		}
+		/*
+		else if (pcapng->block_type == LIGHT_SIMPLE_PACKET_BLOCK) {
+			struct _light_simple_packet_block *spb = (struct _light_simple_packet_block *)pcapng->block_body;
+		}
+		*/
+
+		iterator = light_next_block(iterator);
+	}
+
+	// Returning the duration in nanoseconds.
+	duration = (current_timestamp - first_timestamp) * resolution;
+	return duration;
+}

http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/blob/c0a788b3/thirdparty/pcap++/3rdParty/LightPcapNg/LightPcapNg/src/tests/test_feature.c
----------------------------------------------------------------------
diff --git a/thirdparty/pcap++/3rdParty/LightPcapNg/LightPcapNg/src/tests/test_feature.c b/thirdparty/pcap++/3rdParty/LightPcapNg/LightPcapNg/src/tests/test_feature.c
new file mode 100644
index 0000000..1725d8b
--- /dev/null
+++ b/thirdparty/pcap++/3rdParty/LightPcapNg/LightPcapNg/src/tests/test_feature.c
@@ -0,0 +1,176 @@
+// test_feature.c
+// Created on: Oct 12, 2016
+
+// Copyright (c) 2016 Radu Velea
+
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included in all
+// copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+// SOFTWARE.
+
+#include "light_pcapng.h"
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#include <arpa/inet.h>
+
+enum feature_description {
+	FEATURE_PROTOCOL = 0,
+	FEATURE_LENGTH = 1,
+};
+
+static void print_interface(const struct _light_interface_description_block *idb)
+{
+	printf("Interface link type = 0x%X\n", idb->link_type);
+	printf("Interface snapshot length = %u\n", idb->snapshot_length);
+}
+
+static void __handle_tcp(uint8_t *packet_data)
+{
+	uint16_t source_port = ntohs(((uint16_t *)packet_data)[0]);
+	uint16_t destination_port = ntohs(((uint16_t *)packet_data)[1]);
+	printf("TCP source: %u, destination: %u\n", source_port, destination_port);
+}
+
+static void __handle_ipv4(uint8_t *packet_data, uint8_t header_len)
+{
+	uint16_t total_length = ntohs(((uint16_t *)packet_data)[1]);
+	uint8_t protocol = packet_data[9];
+	int i = 12;
+
+	printf("Packet total length = %u, protocol = %u\n", total_length, protocol);
+
+	printf("Source address: ");
+	for (; i < 16; ++i) {
+		printf("%u.", packet_data[i]);
+	}
+	printf("\n");
+
+	printf("Destination address: ");
+	for (; i < 20; ++i) {
+		printf("%u.", packet_data[i]);
+	}
+	printf("\n");
+
+	if (protocol == 6) {
+		__handle_tcp(packet_data + header_len * 4);
+	}
+}
+
+static int extractor(const light_pcapng packet, void *data, size_t feature_count)
+{
+	float *features = (float *)data;
+	uint32_t *body = NULL;
+	size_t body_size = 0;
+	uint32_t type = LIGHT_UNKNOWN_DATA_BLOCK;
+	uint8_t protocol_version;
+	uint8_t ip_header_length;
+	uint16_t ethernet_type;
+	struct _light_enhanced_packet_block *epb;
+	uint8_t *octets;
+	int i;
+
+	light_get_block_info(packet, LIGHT_INFO_BODY, &body, &body_size);
+	light_get_block_info(packet, LIGHT_INFO_TYPE, &type, NULL);
+
+	if (type == LIGHT_INTERFACE_BLOCK) {
+		struct _light_interface_description_block *idb = (struct _light_interface_description_block *)body;
+		print_interface(idb);
+		return 0;
+	}
+	else if (type != LIGHT_ENHANCED_PACKET_BLOCK /*&& type != LIGHT_SIMPLE_PACKET_BLOCK*/) {
+		return 0;
+	}
+
+	epb = (struct _light_enhanced_packet_block *)body;
+	octets = (uint8_t *)epb->packet_data;
+
+	printf("HWaddr0: "); // Print destination address.
+	for (i = 0; i < 6; ++i) {
+		uint8_t byte = *octets++;
+		printf("%x:", byte);
+	}
+	printf("\n");
+
+	printf("HWaddr1: "); // Print host address.
+	for (i = 0; i < 6; ++i) {
+		uint8_t byte = *octets++;
+		printf("%x:", byte);
+	}
+	printf("\n");
+
+	ethernet_type = ntohs(*(uint16_t*)(octets));
+	octets += 2; // Skip rest of Ethernet header.
+
+	switch (ethernet_type) {
+	case 0x0800: // Internet Protocol v4
+	case 0x86DD: // Internet Protocol v6
+		break;
+	case 0x8100: // 802.1Q Virtual LAN
+		octets += 4;
+		break;
+	case 0x9100: // 802.1Q DoubleTag
+		octets += 6;
+		break;
+	default:
+		printf("Unhandled Ethernet type(len) 0x%X\n", ethernet_type);
+		return 0;
+	}
+
+	ip_header_length = (*octets) & 0b1111;
+	protocol_version = (*octets >> 4) & 0b1111;
+
+	if (protocol_version == 4) {
+		__handle_ipv4(octets, ip_header_length);
+		features[FEATURE_PROTOCOL] = 1.0;
+	}
+	else {
+		// TODO;
+		printf("Protocol version = %u\n", protocol_version);
+	}
+
+	printf("\n");
+	return 0;
+}
+
+int main(int argc, const char **args) {
+	int i;
+
+	for (i = 1; i < argc; ++i) {
+		const char *file = args[i];
+		light_pcapng pcapng = light_read_from_path(file);
+		if (pcapng != NULL) {
+			float *features = NULL;
+			int ret = light_section_feature_extraction(pcapng, extractor, (void **)&features, FEATURE_LENGTH, LIGHT_FEATURE_FLOAT);
+
+			if (ret != LIGHT_SUCCESS) {
+				fprintf(stderr, "Error while extracting features for %s\n", file);
+				goto release;
+			}
+
+			// TODO: Print or handle features.
+release:
+			light_pcapng_release(pcapng);
+			free(features);
+		}
+		else {
+			fprintf(stderr, "Unable to read pcapng: %s\n", file);
+		}
+	}
+
+	return 0;
+}

http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/blob/c0a788b3/thirdparty/pcap++/3rdParty/LightPcapNg/LightPcapNg/src/tests/test_feature_advanced.c
----------------------------------------------------------------------
diff --git a/thirdparty/pcap++/3rdParty/LightPcapNg/LightPcapNg/src/tests/test_feature_advanced.c b/thirdparty/pcap++/3rdParty/LightPcapNg/LightPcapNg/src/tests/test_feature_advanced.c
new file mode 100644
index 0000000..26fe3c3
--- /dev/null
+++ b/thirdparty/pcap++/3rdParty/LightPcapNg/LightPcapNg/src/tests/test_feature_advanced.c
@@ -0,0 +1,171 @@
+// test_feature_advanced.c
+// Created on: Nov 1, 2016
+
+// Copyright (c) 2016 Radu Velea
+
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included in all
+// copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+// SOFTWARE.
+
+#include "light_pcapng.h"
+
+#include <dlfcn.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include <arpa/inet.h>
+
+#define MAX_FEATURES 64
+
+typedef uint64_t (*extractor_fn)(const light_pcapng);
+static extractor_fn features[MAX_FEATURES] = {0,};
+static char *feature_names[MAX_FEATURES] = {0,};
+static int feature_count = 0;
+static void *feature_lib_handle = NULL;
+
+static int compile_features()
+{
+	int ret = system("make -C features");
+	return ret;
+}
+
+static int extract_features()
+{
+	feature_lib_handle = dlopen("./features/libfeatures.so", RTLD_LAZY);
+	if (!feature_lib_handle) {
+		fprintf(stderr, "dlerror: %s\n", dlerror());
+		return -1;
+	}
+
+	FILE *feature_list = fopen("features/feature_list.txt", "r");
+	if (!feature_list) {
+		perror("Unable to open feature_list.txt");
+		return -1;
+	}
+
+	char line[256] = {0,};
+	while (fgets(line, sizeof(line), feature_list) != NULL) {
+		if (line[strlen(line) - 1] == '\n') {
+			line[strlen(line) - 1] = 0;
+		}
+
+		extractor_fn function = (extractor_fn)dlsym(feature_lib_handle, line);
+		if (!function) {
+			fprintf(stderr, "Unable to find symbol %s\n", line);
+		}
+		else {
+			features[feature_count] = function;
+			feature_names[feature_count] = strdup(line);
+			feature_count++;
+		}
+		memset(line, 0, sizeof(line));
+	}
+
+	fclose(feature_list);
+
+	return 0;
+}
+
+static void cleanup()
+{
+	int i;
+
+	for (i = 0; i < feature_count; ++i) {
+		free(feature_names[i]);
+	}
+
+	dlclose(feature_lib_handle);
+	feature_lib_handle = NULL;
+}
+
+int main(int argc, const char **args) {
+	int i, j;
+	FILE *features_csv = fopen("features/unscaled.csv", "w");
+
+	if (compile_features() != 0) {
+		fprintf(stderr, "Unable to compile features!\n");
+		return EXIT_FAILURE;
+	}
+
+	if (extract_features() != 0) {
+		fprintf(stderr, "Unable to extract function pointers!\n");
+		return EXIT_FAILURE;
+	}
+
+	fprintf(features_csv, "address1, address2");
+	for (i = 0; i < feature_count; ++i) {
+		fprintf(features_csv, ", %s", feature_names[i]);
+	}
+	fprintf(features_csv, "\n");
+
+	printf("Running feature extraction with %d functions and %d traces\n", feature_count, argc - 1);
+
+	for (i = 1; i < argc; ++i) {
+		const char *file = args[i];
+		light_pcapng pcapng = light_read_from_path(file);
+		if (pcapng != NULL) {
+			uint64_t feature_values[MAX_FEATURES];
+			light_option feature_option;
+			light_option address_option;
+
+			address_option = light_get_option(pcapng, LIGHT_CUSTOM_OPTION_ADDRESS_INFO);
+			if (address_option != NULL) {
+				uint8_t *label = (uint8_t *)light_get_option_data(address_option);
+				if (*label == 4) {
+					uint8_t source[4], destination[4];
+					memcpy(source, label + 1, sizeof(uint32_t));
+					memcpy(destination, label + 5, sizeof(uint32_t));
+					fprintf(features_csv, "%u.%u.%u.%u, %u.%u.%u.%u",
+							source[0], source[1], source[2], source[3],
+							destination[0], destination[1], destination[2], destination[3]);
+				}
+				else {
+					fprintf(features_csv, "unknown, unknown");
+				}
+			}
+			else {
+				fprintf(features_csv, "unknown, unknown");
+			}
+
+			printf("Extract features for %s\n", file);
+
+			// Write output to file.
+			for (j = 0; j < feature_count; ++j) {
+				feature_values[j] = features[j](pcapng);
+				fprintf(features_csv, ", %lu", feature_values[j]);
+			}
+			fprintf(features_csv, "\n");
+
+			// Update .pcapng traces with computed metrics.
+			feature_option = light_create_option(LIGHT_CUSTOM_OPTION_FEATURE_U64, feature_count * sizeof(uint64_t), feature_values);
+			light_update_option(pcapng, pcapng, feature_option);
+			light_pcapng_to_file(file, pcapng);
+
+			light_free_option(feature_option);
+			light_pcapng_release(pcapng);
+		}
+		else {
+			fprintf(stderr, "Unable to read pcapng: %s\n", file);
+		}
+	}
+
+	fclose(features_csv);
+	cleanup();
+
+	return EXIT_SUCCESS;
+}

http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/blob/c0a788b3/thirdparty/pcap++/3rdParty/LightPcapNg/LightPcapNg/src/tests/test_flow.c
----------------------------------------------------------------------
diff --git a/thirdparty/pcap++/3rdParty/LightPcapNg/LightPcapNg/src/tests/test_flow.c b/thirdparty/pcap++/3rdParty/LightPcapNg/LightPcapNg/src/tests/test_flow.c
new file mode 100644
index 0000000..2828c10
--- /dev/null
+++ b/thirdparty/pcap++/3rdParty/LightPcapNg/LightPcapNg/src/tests/test_flow.c
@@ -0,0 +1,123 @@
+// test_flow.c
+// Created on: Oct 23, 2016
+
+// Copyright (c) 2016 Radu Velea
+
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included in all
+// copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+// SOFTWARE.
+
+#include "light_pcapng.h"
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+int main(int argc, const char **args) {
+	int i;
+
+	for (i = 1; i < argc; ++i) {
+		const char *file = args[i];
+		char *core_file_name = strdup(file);
+		char *dot = strrchr(core_file_name, '.');
+		light_pcapng pcapng = light_read_from_path(file);
+		light_pcapng current_section = pcapng;
+		int flow_index = 0;
+
+		if (dot != NULL) {
+			*dot = 0;
+		}
+
+		while (current_section != NULL) {
+			light_pcapng *flows = NULL;
+			size_t flow_count = 0;
+			size_t dropped = 0;
+			size_t i;
+			int ret = light_ip_flow(&current_section, &flows, &flow_count, &dropped);
+
+			if (ret != LIGHT_SUCCESS) {
+				fprintf(stderr, "Error while computing for %s\n", file);
+				break;
+			}
+
+			printf("Found %zu flows, dropped %zu packages for %s\n", flow_count, dropped, file);
+			for (i = 0; i < flow_count; ++i) {
+				light_pcapng current_flow = flows[i];
+				size_t block_count = light_get_block_count(current_flow);
+				uint32_t type = LIGHT_UNKNOWN_DATA_BLOCK;
+				char flow_file_name[256] = {0,};
+				light_option options = NULL;
+
+				light_get_block_info(pcapng, LIGHT_INFO_TYPE, &type, NULL);
+#if 0
+				printf("Write flow %zu out of %zu, with block count = %zu and type = 0x%X\n",
+						i, flow_count, block_count, type);
+#else
+				(void)block_count;
+#endif
+
+				light_get_block_info(current_flow, LIGHT_INFO_OPTIONS, &options, NULL);
+				while (options != NULL) {
+					if (light_get_option_code(options) == LIGHT_CUSTOM_OPTION_ADDRESS_INFO) {
+						break;
+					}
+					options = light_get_next_option(options);
+				}
+
+				if (options != NULL) {
+					uint8_t *label = (uint8_t *)light_get_option_data(options);
+					if (*label == 4) {
+						uint8_t source[4], destination[4];
+						memcpy(source, label + 1, sizeof(uint32_t));
+						memcpy(destination, label + 5, sizeof(uint32_t));
+						sprintf(flow_file_name, "%s_flow_[%d]_%u.%u.%u.%u-%u.%u.%u.%u.pcapng",
+								core_file_name, flow_index,
+								source[0], source[1], source[2], source[3],
+								destination[0], destination[1], destination[2], destination[3]);
+					}
+					else {
+						// TODO: handle IPv6 info.
+						printf("Protocol type = %u\n", *label);
+						sprintf(flow_file_name, "%s_flow_%d.pcapng", core_file_name, flow_index);
+					}
+				}
+				else {
+					sprintf(flow_file_name, "%s_flow_%d.pcapng", core_file_name, flow_index);
+				}
+
+				if (light_pcapng_to_file(flow_file_name, current_flow) != LIGHT_SUCCESS) {
+					fprintf(stderr, "Failed to write flow %d for %s\n", flow_index, file);
+				}
+				light_pcapng_release(current_flow);
+				flow_index++;
+			}
+
+			free(flows);
+		}
+
+		if (pcapng != NULL) {
+			light_pcapng_release(pcapng);
+		}
+		else {
+			fprintf(stderr, "Unable to read pcapng: %s\n", file);
+		}
+
+		free(core_file_name);
+	}
+
+	return 0;
+}

http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/blob/c0a788b3/thirdparty/pcap++/3rdParty/LightPcapNg/LightPcapNg/src/tests/test_histogram.c
----------------------------------------------------------------------
diff --git a/thirdparty/pcap++/3rdParty/LightPcapNg/LightPcapNg/src/tests/test_histogram.c b/thirdparty/pcap++/3rdParty/LightPcapNg/LightPcapNg/src/tests/test_histogram.c
new file mode 100644
index 0000000..9652745
--- /dev/null
+++ b/thirdparty/pcap++/3rdParty/LightPcapNg/LightPcapNg/src/tests/test_histogram.c
@@ -0,0 +1,64 @@
+// test_histogram.c
+// Created on: Sep 30, 2016
+
+// Copyright (c) 2016 Radu Velea
+
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included in all
+// copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+// SOFTWARE.
+
+#include "light_pcapng.h"
+
+#include <stdio.h>
+#include <stdlib.h>
+
+static uint32_t key_master(const light_pcapng pcapng)
+{
+	uint32_t type = LIGHT_UNKNOWN_DATA_BLOCK;
+	light_get_block_info(pcapng, LIGHT_INFO_TYPE, &type, NULL);
+	return type;
+}
+
+int main(int argc, const char **args) {
+	int i;
+
+	for (i = 1; i < argc; ++i) {
+		const char *file = args[i];
+		light_pcapng pcapng = light_read_from_path(file);
+		if (pcapng != NULL) {
+			light_pair *histogram;
+			size_t length = 0;
+			size_t uncounted = 0;
+			size_t i;
+			light_pcapng_historgram(pcapng, key_master, &histogram, &length, &uncounted);
+
+			printf("Histogram for %s: %zu classes, %zu items rejected. See <key, value> bellow:\n", file, length, uncounted);
+			for (i = 0; i < length; ++i) {
+				printf("<0x%8X, %12u>\n", histogram[i].key, histogram[i].val);
+			}
+			printf("\n");
+
+			free(histogram);
+			light_pcapng_release(pcapng);
+		}
+		else {
+			fprintf(stderr, "Unable to read pcapng: %s\n", file);
+		}
+	}
+
+	return 0;
+}

http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/blob/c0a788b3/thirdparty/pcap++/3rdParty/LightPcapNg/LightPcapNg/src/tests/test_mem.c
----------------------------------------------------------------------
diff --git a/thirdparty/pcap++/3rdParty/LightPcapNg/LightPcapNg/src/tests/test_mem.c b/thirdparty/pcap++/3rdParty/LightPcapNg/LightPcapNg/src/tests/test_mem.c
new file mode 100644
index 0000000..06634b9
--- /dev/null
+++ b/thirdparty/pcap++/3rdParty/LightPcapNg/LightPcapNg/src/tests/test_mem.c
@@ -0,0 +1,86 @@
+// test_mem.c
+// Created on: Jul 23, 2016
+
+// Copyright (c) 2016 Radu Velea
+
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included in all
+// copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+// SOFTWARE.
+
+#include "light_pcapng.h"
+
+#include <stdio.h>
+#include <stdint.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <unistd.h>
+
+struct _light_pcapng_mem;
+extern int light_pcapng_validate(light_pcapng p0, uint32_t *p1);
+extern struct _light_pcapng_mem *light_no_copy_from_memory(uint32_t *memory, size_t size, int is_owner);
+extern void light_pcapng_mem_release(struct _light_pcapng_mem *pcapng);
+
+int read_file(const char *file, uint8_t **data, size_t *size)
+{
+	size_t tmp;
+	struct stat info;
+	FILE *f;
+
+	f = fopen(file, "rb");
+	stat(file, &info);
+	*data = calloc(info.st_size, 1);
+	tmp = fread(*data, 1, info.st_size, f);
+	if (tmp != info.st_size) {
+		free(*data);
+		return -1;
+	}
+
+	fclose(f);
+	*size = info.st_size;
+	return 0;
+}
+
+int main(int argc, const char **args) {
+	int i;
+
+	for (i = 1; i < argc; ++i) {
+		const char *file = args[i];
+		uint8_t *data;
+		size_t size;
+		if (read_file(file, &data, &size) == 0) {
+			light_pcapng pcapng0 = light_read_from_memory((uint32_t *)data, size);
+			struct _light_pcapng_mem *pcapng1 = light_no_copy_from_memory((uint32_t *)data, size, 1);
+			int status = light_pcapng_validate(pcapng0, *(uint32_t **)pcapng1);
+			uint32_t **sec = (uint32_t **)(((uint32_t **)pcapng1)[1]);
+
+			status &= light_pcapng_validate(pcapng0, sec[0]);
+
+			printf("Internal structure comparison returned %d\n", status);
+
+			light_pcapng_release(pcapng0);
+			light_pcapng_mem_release(pcapng1);
+		}
+		else {
+			fprintf(stderr, "Unable to read pcapng: %s\n", file);
+		}
+	}
+
+	return 0;
+}
+

http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/blob/c0a788b3/thirdparty/pcap++/3rdParty/LightPcapNg/LightPcapNg/src/tests/test_read.c
----------------------------------------------------------------------
diff --git a/thirdparty/pcap++/3rdParty/LightPcapNg/LightPcapNg/src/tests/test_read.c b/thirdparty/pcap++/3rdParty/LightPcapNg/LightPcapNg/src/tests/test_read.c
new file mode 100644
index 0000000..d8aa733
--- /dev/null
+++ b/thirdparty/pcap++/3rdParty/LightPcapNg/LightPcapNg/src/tests/test_read.c
@@ -0,0 +1,47 @@
+// test_read.c
+// Created on: Jul 23, 2016
+
+// Copyright (c) 2016 Radu Velea
+
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included in all
+// copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+// SOFTWARE.
+
+#include "light_pcapng.h"
+
+#include <stdio.h>
+#include <stdlib.h>
+
+int main(int argc, const char **args) {
+	int i;
+
+	for (i = 1; i < argc; ++i) {
+		const char *file = args[i];
+		light_pcapng pcapng = light_read_from_path(file);
+		if (pcapng != NULL) {
+			char *data = light_pcapng_to_string(pcapng);
+			printf("Data for %s\n%s\n", file, data);
+			light_pcapng_release(pcapng);
+			free(data);
+		}
+		else {
+			fprintf(stderr, "Unable to read pcapng: %s\n", file);
+		}
+	}
+
+	return 0;
+}

http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/blob/c0a788b3/thirdparty/pcap++/3rdParty/LightPcapNg/LightPcapNg/src/tests/test_read_packets.c
----------------------------------------------------------------------
diff --git a/thirdparty/pcap++/3rdParty/LightPcapNg/LightPcapNg/src/tests/test_read_packets.c b/thirdparty/pcap++/3rdParty/LightPcapNg/LightPcapNg/src/tests/test_read_packets.c
new file mode 100644
index 0000000..1103358
--- /dev/null
+++ b/thirdparty/pcap++/3rdParty/LightPcapNg/LightPcapNg/src/tests/test_read_packets.c
@@ -0,0 +1,86 @@
+// test_read_packets.c
+// Created on: Nov 14, 2016
+
+// Copyright (c) 2016
+
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included in all
+// copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+// SOFTWARE.
+
+#include "light_pcapng_ext.h"
+
+#include <stdio.h>
+#include <stdlib.h>
+
+int main(int argc, const char **args) {
+	int i;
+
+	for (i = 1; i < argc; ++i) {
+		const char *file = args[i];
+		light_pcapng_t *pcapng = light_pcapng_open_read(file, LIGHT_FALSE);
+		if (pcapng != NULL) {
+			light_pcapng_file_info *info = light_pcang_get_file_info(pcapng);
+			printf("file version is %d.%d\n", info->major_version, info->minor_version);
+			if (info->file_comment != NULL)
+				printf("file comment is: %s\n", info->file_comment);
+			if (info->os_desc != NULL)
+				printf("os is: %s\n", info->os_desc);
+			if (info->hardware_desc != NULL)
+				printf("hardware description is: %s\n", info->hardware_desc);
+			if (info->user_app_desc != NULL)
+				printf("user app is: %s\n", info->user_app_desc);
+
+			int index = 1;
+
+			while (1) {
+				light_packet_header pkt_header;
+				const uint8_t *pkt_data = NULL;
+				int res = 0;
+
+				res = light_get_next_packet(pcapng, &pkt_header, &pkt_data);
+				if (!res)
+					break;
+
+				if (pkt_data != NULL) {
+					printf("packet #%d: orig_len=%d, cap_len=%d, iface_id=%d, data_link=%d, timestamp=%d.%06d",
+							index,
+							pkt_header.original_length,
+							pkt_header.captured_length,
+							pkt_header.interface_id,
+							pkt_header.data_link,
+							(int)pkt_header.timestamp.tv_sec,
+							(int)pkt_header.timestamp.tv_usec);
+					if (pkt_header.comment_length > 0)
+						printf(", comment=\"%s\"\n", pkt_header.comment);
+					else
+						printf("\n");
+
+					index++;
+				}
+			}
+
+			printf("interface count in file: %d\n", info->interface_block_count);
+
+			light_pcapng_close(pcapng);
+		}
+		else {
+			fprintf(stderr, "Unable to read pcapng: %s\n", file);
+		}
+	}
+
+	return 0;
+}

http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/blob/c0a788b3/thirdparty/pcap++/3rdParty/LightPcapNg/LightPcapNg/src/tests/test_read_write.c
----------------------------------------------------------------------
diff --git a/thirdparty/pcap++/3rdParty/LightPcapNg/LightPcapNg/src/tests/test_read_write.c b/thirdparty/pcap++/3rdParty/LightPcapNg/LightPcapNg/src/tests/test_read_write.c
new file mode 100644
index 0000000..6aecc04
--- /dev/null
+++ b/thirdparty/pcap++/3rdParty/LightPcapNg/LightPcapNg/src/tests/test_read_write.c
@@ -0,0 +1,90 @@
+// test_read_write.c
+// Created on: Jul 23, 2016
+
+// Copyright (c) 2016 Radu Velea
+
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included in all
+// copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+// SOFTWARE.
+
+#include "light_pcapng.h"
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <unistd.h>
+
+#define TMP_FILE	"/tmp/pcapng.tmp"
+
+int main(int argc, const char **args) {
+	int i;
+
+	for (i = 1; i < argc; ++i) {
+		const char *file = args[i];
+		light_pcapng pcapng = light_read_from_path(file);
+		if (pcapng != NULL) {
+			FILE *tmp = fopen(TMP_FILE, "wb");
+			size_t size;
+			uint32_t *data = light_pcapng_to_memory(pcapng, &size);
+			struct stat f_info;
+			FILE *f_check = fopen(file, "rb");
+			uint8_t *data_check;
+			int status = 0;
+
+			stat(file, &f_info);
+			if (size != f_info.st_size) {
+				fprintf(stderr, "Memory size mismatch %zu != %zu\n", size, f_info.st_size);
+				goto EARLY_FAILURE;
+			}
+			printf("Data for %s: %zu bytes\n", file, size);
+
+			data_check = calloc(size, 1);
+			if (fread(data_check, 1, size, f_check) != size) {
+				fprintf(stderr, "Error reading %s!\n", file);
+				free(data_check);
+				goto EARLY_FAILURE;
+			}
+
+			status = memcmp(data, data_check, size);
+
+			if (status == 0) {
+				printf("SUCCESS for %s\n\n", file);
+			}
+			else {
+				fprintf(stderr, "FAILURE for %s\n\n", file);
+			}
+
+			fwrite(data, size, 1, tmp);
+
+			free(data_check);
+EARLY_FAILURE:
+			fclose(f_check);
+			fclose(tmp);
+			free(data);
+			light_pcapng_release(pcapng);
+		}
+		else {
+			fprintf(stderr, "Unable to read pcapng: %s\n", file);
+		}
+	}
+
+	// unlink(TMP_FILE);
+
+	return EXIT_SUCCESS;
+}

http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/blob/c0a788b3/thirdparty/pcap++/3rdParty/LightPcapNg/LightPcapNg/src/tests/test_read_write_packets.c
----------------------------------------------------------------------
diff --git a/thirdparty/pcap++/3rdParty/LightPcapNg/LightPcapNg/src/tests/test_read_write_packets.c b/thirdparty/pcap++/3rdParty/LightPcapNg/LightPcapNg/src/tests/test_read_write_packets.c
new file mode 100644
index 0000000..e29ba09
--- /dev/null
+++ b/thirdparty/pcap++/3rdParty/LightPcapNg/LightPcapNg/src/tests/test_read_write_packets.c
@@ -0,0 +1,131 @@
+// test_read_write_packets.c
+// Created on: Nov 14, 2016
+
+// Copyright (c) 2016
+
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included in all
+// copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+// SOFTWARE.
+
+#include "light_pcapng_ext.h"
+
+#include <stdio.h>
+#include <stdlib.h>
+
+void copy_file(const char *src_path, const char *dst_path) {
+	FILE *src_fd = fopen(src_path, "rb");
+	FILE *dst_fd = fopen(dst_path, "wb");
+	size_t n, m;
+	unsigned char buff[8192];
+	do {
+	    n = fread(buff, 1, 8192, src_fd);
+	    if (n)
+	    	m = fwrite(buff, 1, n, dst_fd);
+	    else
+	    	m = 0;
+	} while ((n > 0) && (n == m));
+
+	fflush(dst_fd);
+    fclose(src_fd);
+    fclose(dst_fd);
+}
+
+int main(int argc, const char **args) {
+	int i;
+
+	for (i = 1; i < argc; ++i) {
+		const char *file = args[i];
+		light_pcapng_t *pcapng_read = light_pcapng_open_read(file, LIGHT_FALSE);
+		if (pcapng_read != NULL) {
+			const char* file_append = "output_append.pcapng";
+			copy_file(file, file_append);
+
+			light_pcapng_file_info *info = light_pcang_get_file_info(pcapng_read);
+			printf("file version is %d.%d\n", info->major_version, info->minor_version);
+			if (info->file_comment != NULL)
+				printf("file comment is: %s\n", info->file_comment);
+			if (info->os_desc != NULL)
+				printf("os is: %s\n", info->os_desc);
+			if (info->hardware_desc != NULL)
+				printf("hardware description is: %s\n", info->hardware_desc);
+			if (info->user_app_desc != NULL)
+				printf("user app is: %s\n", info->user_app_desc);
+
+			const char *file_write = "output.pcapng";
+			light_pcapng_t *pcapng_write = light_pcapng_open_write(file_write, light_create_default_file_info());
+
+			light_pcapng_t *pcapng_append = light_pcapng_open_append(file_append);
+			//light_pcapng_t *pcapng_write = light_pcapng_open_write(file_write, info);
+			if (pcapng_write == NULL)
+			{
+				printf("Error occurred in opening write file\n");
+				exit(1);
+			}
+
+			if (pcapng_append == NULL)
+			{
+				printf("Error occurred in opening append file\n");
+				exit(1);
+			}
+
+			int index = 1;
+
+			while (1) {
+				light_packet_header pkt_header;
+				const uint8_t *pkt_data = NULL;
+				int res = 0;
+
+				res = light_get_next_packet(pcapng_read, &pkt_header, &pkt_data);
+				if (!res)
+					break;
+
+				if (pkt_data != NULL) {
+					printf("packet #%d: orig_len=%d, cap_len=%d, iface_id=%d, data_link=%d, timestamp=%d.%06d\n",
+							index,
+							pkt_header.original_length,
+							pkt_header.captured_length,
+							pkt_header.interface_id,
+							pkt_header.data_link,
+							(int)pkt_header.timestamp.tv_sec,
+							(int)pkt_header.timestamp.tv_usec);
+
+					uint16_t comment_len = 15;
+					char comment[comment_len];
+					sprintf(comment, "Packet #%d", index);
+					pkt_header.comment = comment;
+					pkt_header.comment_length = comment_len;
+
+					light_write_packet(pcapng_write, &pkt_header, pkt_data);
+					light_write_packet(pcapng_append, &pkt_header, pkt_data);
+
+					index++;
+				}
+			}
+
+			printf("interface count in file: %d\n", info->interface_block_count);
+
+			light_pcapng_close(pcapng_read);
+			light_pcapng_close(pcapng_write);
+			light_pcapng_close(pcapng_append);
+		}
+		else {
+			fprintf(stderr, "Unable to read pcapng: %s\n", file);
+		}
+	}
+
+	return 0;
+}

http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/blob/c0a788b3/thirdparty/pcap++/3rdParty/LightPcapNg/LightPcapNg/src/tests/test_subcapture.c
----------------------------------------------------------------------
diff --git a/thirdparty/pcap++/3rdParty/LightPcapNg/LightPcapNg/src/tests/test_subcapture.c b/thirdparty/pcap++/3rdParty/LightPcapNg/LightPcapNg/src/tests/test_subcapture.c
new file mode 100644
index 0000000..02a59e5
--- /dev/null
+++ b/thirdparty/pcap++/3rdParty/LightPcapNg/LightPcapNg/src/tests/test_subcapture.c
@@ -0,0 +1,83 @@
+// test_subcapture.c
+// Created on: Sep 30, 2016
+
+// Copyright (c) 2016 Radu Velea
+
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included in all
+// copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+// SOFTWARE.
+
+#include "light_pcapng.h"
+
+#include <limits.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+static light_boolean subcapture_predicate(const light_pcapng pcapng)
+{
+	uint32_t type = LIGHT_UNKNOWN_DATA_BLOCK;
+	uint32_t length = 0;
+
+	light_get_block_info(pcapng, LIGHT_INFO_TYPE, &type, NULL);
+	light_get_block_info(pcapng, LIGHT_INFO_LENGTH, &length, NULL);
+
+	return (type != LIGHT_ENHANCED_PACKET_BLOCK) || (length > 512);
+}
+
+int main(int argc, const char **args) {
+	int i;
+	char comment[] = "This pcapng file was created using LightPcapNg subcapture functionality.";
+	light_option option = light_create_option(0xB00B, strlen(comment), comment);
+
+	for (i = 1; i < argc; ++i) {
+		const char *file = args[i];
+		light_pcapng pcapng = light_read_from_path(file);
+		if (pcapng != NULL) {
+			light_pcapng subcapture = NULL;
+			uint32_t *subcapture_mem;
+			size_t subcapture_size;
+			FILE *subcapture_file;
+			char subcapture_name[PATH_MAX] = {0,};
+			const char *file_name = file;
+			char *offset;
+
+			while ((offset = strstr(file_name, "/")) != NULL)
+				file_name = offset + 1;
+
+			light_subcapture(pcapng, subcapture_predicate, &subcapture);
+			light_add_option(subcapture, subcapture, option, LIGHT_TRUE);
+			subcapture_mem = light_pcapng_to_memory(subcapture, &subcapture_size);
+
+			sprintf(subcapture_name, "subcapture_%s", file_name);
+			printf("Write subcapture to %s\n", subcapture_name);
+			subcapture_file = fopen(subcapture_name, "wb");
+			fwrite(subcapture_mem, 1, subcapture_size, subcapture_file);
+			fclose(subcapture_file);
+
+			free(subcapture_mem);
+			light_pcapng_release(subcapture);
+			light_pcapng_release(pcapng);
+		}
+		else {
+			fprintf(stderr, "Unable to read pcapng: %s\n", file);
+		}
+	}
+
+	light_free_option(option);
+	return 0;
+}

http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/blob/c0a788b3/thirdparty/pcap++/3rdParty/LightPcapNg/Makefile
----------------------------------------------------------------------
diff --git a/thirdparty/pcap++/3rdParty/LightPcapNg/Makefile b/thirdparty/pcap++/3rdParty/LightPcapNg/Makefile
new file mode 100644
index 0000000..22e5502
--- /dev/null
+++ b/thirdparty/pcap++/3rdParty/LightPcapNg/Makefile
@@ -0,0 +1,42 @@
+ifeq ($(wildcard ../../mk/platform.mk),)
+  $(error platform.mk not found! Please run configure script first)
+endif
+
+include ../../mk/platform.mk
+
+SOURCES := $(wildcard LightPcapNg/src/*.c)
+OBJS_FILENAMES := $(patsubst LightPcapNg/src/%.c,Obj/%.o,$(SOURCES))
+
+INCLUDES := -I"LightPcapNg/include"
+			
+Obj/%.o: LightPcapNg/src/%.c
+	@echo 'Building file: $<'
+	@$(GCC) $(INCLUDES) -Wall -O2 -DUNIVERSAL -g -c -o "$@" "$<"
+
+CUR_TARGET := $(notdir $(shell pwd))
+
+.SILENT:
+
+create_light_pcapng_directories:
+	@$(MKDIR) -p Obj
+	@$(MKDIR) -p Lib
+
+start:
+	@echo '==> Building target: $(CUR_TARGET)'
+
+# Sources only
+light_pcapng_sources: create_light_pcapng_directories $(OBJS_FILENAMES)
+
+# Sources and static lib
+light_pcapng_all: start light_pcapng_sources
+	@$(AR) -r  "Lib/light_pcapng.a" $(OBJS_FILENAMES)
+	@echo 'Finished successfully building: $(CUR_TARGET)'
+	@echo ' '
+
+light_pcapng_clean:
+	@$(RM) -rf ./Obj/*
+	@$(RM) -rf ./Lib/*
+	@echo 'Clean finished: $(CUR_TARGET)'
+
+# Clean target
+clean: light_pcapng_clean

http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/blob/c0a788b3/thirdparty/pcap++/3rdParty/LightPcapNg/current_commit.git
----------------------------------------------------------------------
diff --git a/thirdparty/pcap++/3rdParty/LightPcapNg/current_commit.git b/thirdparty/pcap++/3rdParty/LightPcapNg/current_commit.git
new file mode 100644
index 0000000..10ec769
--- /dev/null
+++ b/thirdparty/pcap++/3rdParty/LightPcapNg/current_commit.git
@@ -0,0 +1 @@
+1a0a0ee5caea03c9d9762c066d0489e10dff6252

http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/blob/c0a788b3/thirdparty/pcap++/3rdParty/debug-new/Makefile
----------------------------------------------------------------------
diff --git a/thirdparty/pcap++/3rdParty/debug-new/Makefile b/thirdparty/pcap++/3rdParty/debug-new/Makefile
new file mode 100644
index 0000000..2e137ae
--- /dev/null
+++ b/thirdparty/pcap++/3rdParty/debug-new/Makefile
@@ -0,0 +1,29 @@
+ifeq ($(wildcard ../../mk/platform.mk),)
+  $(error platform.mk not found! Please run configure script first)
+endif
+
+include ../../mk/platform.mk
+
+SOURCES := $(wildcard *.cpp)
+OBJS_FILENAMES := $(patsubst %.cpp,%.o,$(SOURCES))
+
+%.o: %.cpp
+	@echo 'Building debug-new file: $<'
+	@$(GCC) -Wall -O2 -g -c -o "$@" "$<"
+
+CUR_TARGET := $(notdir $(shell pwd))
+
+.SILENT:
+
+all: start debug_new_sources
+	@echo 'Finished successfully building: $(CUR_TARGET)'
+	@echo ' '
+
+start:
+	@echo '==> Building target: $(CUR_TARGET)'
+
+debug_new_sources: $(OBJS_FILENAMES)
+
+clean:
+	@$(RM) -rf *.o
+	@echo 'Clean finished: $(CUR_TARGET)'