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:38 UTC
[24/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/README
----------------------------------------------------------------------
diff --git a/thirdparty/pcap++/3rdParty/LightPcapNg/LightPcapNg/README b/thirdparty/pcap++/3rdParty/LightPcapNg/LightPcapNg/README
new file mode 100644
index 0000000..09615b2
--- /dev/null
+++ b/thirdparty/pcap++/3rdParty/LightPcapNg/LightPcapNg/README
@@ -0,0 +1,8 @@
+LightPcapNg
+
+Library for general-purpose tracing based on PcapNg[1] file format.
+The current project represents work in progress to provide an API
+that can read, write and manipulate PcapNg files (possibly outside
+normal contexts).
+
+[1] https://github.com/pcapng/pcapng
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/blob/c0a788b3/thirdparty/pcap++/3rdParty/LightPcapNg/LightPcapNg/include/light_debug.h
----------------------------------------------------------------------
diff --git a/thirdparty/pcap++/3rdParty/LightPcapNg/LightPcapNg/include/light_debug.h b/thirdparty/pcap++/3rdParty/LightPcapNg/LightPcapNg/include/light_debug.h
new file mode 100644
index 0000000..8f24dc8
--- /dev/null
+++ b/thirdparty/pcap++/3rdParty/LightPcapNg/LightPcapNg/include/light_debug.h
@@ -0,0 +1,96 @@
+// light_debug.h
+// 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.
+
+#ifndef INCLUDE_LIGHT_DEBUG_H_
+#define INCLUDE_LIGHT_DEBUG_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <stdio.h>
+
+#ifdef _LIGHT_DEBUG_MODE
+#define light_stop getchar()
+#define DPRINT_HERE(symbol) fprintf(stderr, "%s::%s::%d, %s\n", __FILE__, __FUNCTION__, __LINE__, #symbol)
+#else
+#define light_stop (void)0
+#define DPRINT_HERE(symbol) (void)#symbol
+#endif
+
+// XXX: Warning: I should not use these macros with functions!!! Undefined for Release.
+
+#define DCHECK_INT(x, y, other) do { \
+ int x_ret = (int)(x); \
+ int y_ret = (int)(y); \
+ if (x_ret <= y_ret) { \
+ fprintf(stderr, "ERROR at %s::%s::%d: %d <= %d\n", \
+ __FILE__, __FUNCTION__, __LINE__, x_ret, y_ret); \
+ other; \
+ } \
+ } while (0)
+
+#define DCHECK_ASSERT(x, y, other) do { \
+ int x_ret = (int)(x); \
+ int y_ret = (int)(y); \
+ if (x_ret != y_ret) { \
+ fprintf(stderr, "ERROR at %s::%s::%d: %d != %d\n", \
+ __FILE__, __FUNCTION__, __LINE__, x_ret, y_ret); \
+ other; \
+ } \
+ } while (0)
+
+#define DCHECK_ASSERT_EXP(expression, err_message, other) do { \
+ if (!(expression)) {\
+ fprintf(stderr, "ERROR at %s::%s::%d: %s\n", \
+ __FILE__, __FUNCTION__, __LINE__, err_message); \
+ other; \
+ } \
+ } while (0)
+
+#define DCHECK_NULLP(x, other) do { \
+ void *x_ret = (void *)(x); \
+ if (x_ret == NULL) { \
+ fprintf(stderr, "NULL pointer ERROR at %s::%s::%d\n", \
+ __FILE__, __FUNCTION__, __LINE__); \
+ other; \
+ } \
+ } while (0)
+
+#define PCAPNG_WARNING(symbol) fprintf(stderr, "Warning at: %s::%s::%d, %s\n", __FILE__, __FUNCTION__, __LINE__, #symbol)
+#define PCAPNG_ERROR(symbol) fprintf(stderr, "Error at: %s::%s::%d, %s\n", __FILE__, __FUNCTION__, __LINE__, #symbol)
+
+#ifdef _MSC_VER
+#define __attribute__(x)
+#endif // _MSC_VER
+
+#define PCAPNG_ATTRIBUTE_SLOW __attribute__((warning ("slow for large traces")))
+#define PCAPNG_ATTRIBUTE_DEPRECATED __attribute__((warning ("deprecated function")))
+#define PCAPNG_ATTRIBUTE_UNTESTED __attribute__((warning ("unit test required")))
+#define PCAPNG_ATTRIBUTE_REFACTOR __attribute__((warning ("should be refactored")))
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* INCLUDE_LIGHT_DEBUGs_H_ */
http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/blob/c0a788b3/thirdparty/pcap++/3rdParty/LightPcapNg/LightPcapNg/include/light_internal.h
----------------------------------------------------------------------
diff --git a/thirdparty/pcap++/3rdParty/LightPcapNg/LightPcapNg/include/light_internal.h b/thirdparty/pcap++/3rdParty/LightPcapNg/LightPcapNg/include/light_internal.h
new file mode 100644
index 0000000..6d86b55
--- /dev/null
+++ b/thirdparty/pcap++/3rdParty/LightPcapNg/LightPcapNg/include/light_internal.h
@@ -0,0 +1,64 @@
+// light_internal.h
+// 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.
+
+#ifndef INCLUDE_LIGHT_INTERNAL_H_
+#define INCLUDE_LIGHT_INTERNAL_H_
+
+#include "light_types.h"
+
+#include <stddef.h>
+#include <stdint.h>
+
+struct _light_pcapng {
+ uint32_t block_type;
+ uint32_t block_total_lenght;
+ uint32_t *block_body;
+ struct _light_option *options;
+ struct _light_pcapng *next_block;
+};
+
+struct _light_option {
+ uint16_t custom_option_code;
+ uint16_t option_length;
+ // uint32_t PEN;
+ uint32_t *data;
+ struct _light_option *next_option;
+};
+
+struct _light_pcapng_mem {
+ uint32_t *mem;
+ uint32_t **mem_blocks;
+ size_t mem_size;
+ size_t block_count;
+ int owner;
+};
+
+// Private Functions
+struct _light_pcapng *__copy_block(const struct _light_pcapng *pcapng, const light_boolean recursive);
+struct _light_option *__copy_option(const struct _light_option *option);
+size_t __get_option_total_size(const struct _light_option *option);
+uint32_t *__get_option_size(const struct _light_option *option, size_t *size);
+light_boolean __is_section_header(const struct _light_pcapng *section);
+int __validate_section(struct _light_pcapng *section);
+
+#endif /* INCLUDE_LIGHT_INTERNAL_H_ */
http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/blob/c0a788b3/thirdparty/pcap++/3rdParty/LightPcapNg/LightPcapNg/include/light_pcapng.h
----------------------------------------------------------------------
diff --git a/thirdparty/pcap++/3rdParty/LightPcapNg/LightPcapNg/include/light_pcapng.h b/thirdparty/pcap++/3rdParty/LightPcapNg/LightPcapNg/include/light_pcapng.h
new file mode 100644
index 0000000..8fe5b65
--- /dev/null
+++ b/thirdparty/pcap++/3rdParty/LightPcapNg/LightPcapNg/include/light_pcapng.h
@@ -0,0 +1,136 @@
+// light_pcapng.h
+// 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.
+
+#ifndef LIGHT_PCAPNG_H_
+#define LIGHT_PCAPNG_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include "light_special.h"
+#include "light_types.h"
+
+#define LIGHT_SECTION_HEADER_BLOCK 0x0A0D0D0A
+#define LIGHT_INTERFACE_BLOCK 0x00000001
+#define LIGHT_ENHANCED_PACKET_BLOCK 0x00000006
+#define LIGHT_SIMPLE_PACKET_BLOCK 0x00000003
+
+#define LIGHT_CUSTOM_DATA_BLOCK 0xB16B00B5
+#define LIGHT_UNKNOWN_DATA_BLOCK 0xDEADBEEF
+
+// "Official" option codes
+#define LIGHT_OPTION_IF_TSRESOL 0x0009
+#define LIGHT_OPTION_COMMENT 0x0001
+#define LIGHT_OPTION_SHB_HARDWARE 0x0002
+#define LIGHT_OPTION_SHB_OS 0x0003
+#define LIGHT_OPTION_SHB_USERAPPL 0x0004
+#define LIGHT_OPTION_IF_TSRESOL 0x0009
+
+// Custom option codes
+#define LIGHT_CUSTOM_OPTION_ADDRESS_INFO 0xADD4
+#define LIGHT_CUSTOM_OPTION_FEATURE_U64 0x0064
+
+#define BYTE_ORDER_MAGIC 0x1A2B3C4D
+
+#define LIGHT_KEY_REJECTED 0xFFFFFFFF
+
+/////////////////////////////// /////////// ERROR CODES //////////////////////////////////////////////
+
+#define LIGHT_SUCCESS 0
+#define LIGHT_INVALID_SECTION -1
+#define LIGHT_OUT_OF_MEMORY -2
+#define LIGHT_INVALID_ARGUMENT -3
+#define LIGHT_NOT_FOUND -4
+
+/////////////////////////////// STANDARD PCAPNG STRUCTURES & FUNCTIONS ///////////////////////////////
+
+typedef struct _light_pcapng *light_pcapng;
+typedef struct _light_option *light_option;
+
+typedef struct _light_pair {
+ uint32_t key;
+ uint32_t val;
+} light_pair;
+
+// Read/Write Functions
+light_pcapng light_read_from_path(const char *file_name);
+light_pcapng light_read_from_memory(const uint32_t *memory, size_t size);
+uint32_t *light_pcapng_to_memory(const light_pcapng pcapng, size_t *size);
+int light_pcapng_to_file(const char *file_name, const light_pcapng pcapng);
+void light_pcapng_release(light_pcapng pcapng);
+
+// For Debugging Purposes
+char *light_pcapng_to_string(light_pcapng pcapng);
+uint32_t light_get_block_count(const light_pcapng pcapng);
+light_pcapng light_get_block(const light_pcapng pcapng, uint32_t index);
+light_pcapng light_next_block(const light_pcapng pcapng);
+size_t light_get_size(const light_pcapng pcapng);
+void light_pcapng_historgram(const light_pcapng pcapng, uint32_t (*key_master)(const light_pcapng),
+ light_pair **hist, size_t *size, size_t *rejected);
+int light_get_block_info(const light_pcapng pcapng, light_info info_flag, void *info_data, size_t *data_size);
+light_option light_get_option(const light_pcapng pcapng, uint16_t option_code);
+uint16_t light_get_option_code(const light_option option);
+const light_option light_get_next_option(const light_option option);
+uint32_t *light_get_option_data(const light_option option);
+uint16_t light_get_option_length(const light_option option);
+
+// Manipulation Functions
+light_option light_create_option(const uint16_t option_code, const uint16_t option_length, void *option_value);
+int light_add_option(light_pcapng section, light_pcapng pcapng, light_option option, light_boolean copy);
+int light_update_option(light_pcapng section, light_pcapng pcapng, light_option option);
+int light_add_block(light_pcapng block, light_pcapng next_block);
+int light_subcapture(const light_pcapng section, light_boolean (*predicate)(const light_pcapng), light_pcapng *subcapture);
+int light_iterate(const light_pcapng pcapng, light_boolean (*stop_fn)(const light_pcapng, void *), void *args);
+int light_ip_flow(light_pcapng *sectionp, light_pcapng **flows, size_t *flow_count, size_t *dropped);
+
+// Allocation and free functions
+light_option light_alloc_option(uint16_t option_length);
+light_pcapng light_alloc_block(uint32_t block_type, const uint32_t *block_body, uint32_t block_body_length);
+void light_free_option(light_option option);
+void light_free_block(light_pcapng pcapng);
+
+// Advanced Interaction
+typedef enum {
+ LIGHT_FEATURE_BITMASK = 0,
+ LIGHT_FEATURE_BYTE = 1,
+ LIGHT_FEATURE_SHORT = 2,
+ LIGHT_FEATURE_FLOAT = 4,
+ LIGHT_FEATURE_DOUBLE = 5,
+} light_feature_t;
+int light_section_feature_extraction(const light_pcapng section, int (*extractor)(const light_pcapng, void *, size_t),
+ void **feature_vector, const size_t feature_vector_size, const light_feature_t type);
+
+/////////////////////////////// CONTINUOUS MEMORY BLOCK STRUCTURES & FUNCTIONS ///////////////////////////////
+
+typedef struct _light_pcapng_mem *light_pcapng_mem;
+
+// Continuous Memory Functions
+struct _light_pcapng_mem *light_no_copy_from_memory(uint32_t *memory, size_t size, int is_owner);
+void light_pcapng_mem_release(struct _light_pcapng_mem *pcapng);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* LIGHT_PCAPNG_H_ */
http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/blob/c0a788b3/thirdparty/pcap++/3rdParty/LightPcapNg/LightPcapNg/include/light_pcapng_ext.h
----------------------------------------------------------------------
diff --git a/thirdparty/pcap++/3rdParty/LightPcapNg/LightPcapNg/include/light_pcapng_ext.h b/thirdparty/pcap++/3rdParty/LightPcapNg/LightPcapNg/include/light_pcapng_ext.h
new file mode 100644
index 0000000..e8cdc66
--- /dev/null
+++ b/thirdparty/pcap++/3rdParty/LightPcapNg/LightPcapNg/include/light_pcapng_ext.h
@@ -0,0 +1,102 @@
+// light_pcapng_ext.h
+// 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.
+
+#ifndef LIGHT_PCAPNG_EXT_H_
+#define LIGHT_PCAPNG_EXT_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include "light_types.h"
+
+#include <stddef.h>
+#include <stdint.h>
+#ifdef _MSC_VER
+#include <Winsock2.h>
+#else
+#include <sys/time.h>
+#endif
+
+#ifndef NULL
+#define NULL ((void *) 0)
+#endif
+
+#define MAX_SUPPORTED_INTERFACE_BLOCKS 32
+
+struct _light_pcapng_t;
+typedef struct _light_pcapng_t light_pcapng_t;
+
+typedef struct _light_packet_header {
+ uint32_t interface_id;
+ struct timeval timestamp;
+ uint32_t captured_length;
+ uint32_t original_length;
+ uint16_t data_link;
+ char* comment;
+ uint16_t comment_length;
+} light_packet_header;
+
+typedef struct _light_pcapng_file_info {
+ uint16_t major_version;
+ uint16_t minor_version;
+ char *file_comment;
+ size_t file_comment_size;
+ char *hardware_desc;
+ size_t hardware_desc_size;
+ char *os_desc;
+ size_t os_desc_size;
+ char *user_app_desc;
+ size_t user_app_desc_size;
+ size_t interface_block_count;
+ uint16_t link_types[MAX_SUPPORTED_INTERFACE_BLOCKS];
+ double timestamp_resolution[MAX_SUPPORTED_INTERFACE_BLOCKS];
+
+} light_pcapng_file_info;
+
+
+light_pcapng_t *light_pcapng_open_read(const char* file_path, light_boolean read_all_interfaces);
+
+light_pcapng_t *light_pcapng_open_write(const char* file_path, light_pcapng_file_info *file_info);
+
+light_pcapng_t *light_pcapng_open_append(const char* file_path);
+
+light_pcapng_file_info *light_create_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);
+
+void light_free_file_info(light_pcapng_file_info *info);
+
+light_pcapng_file_info *light_pcang_get_file_info(light_pcapng_t *pcapng);
+
+int light_get_next_packet(light_pcapng_t *pcapng, light_packet_header *packet_header, const uint8_t **packet_data);
+
+void light_write_packet(light_pcapng_t *pcapng, const light_packet_header *packet_header, const uint8_t *packet_data);
+
+void light_pcapng_close(light_pcapng_t *pcapng);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* LIGHT_PCAPNG_EXT_H_ */
http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/blob/c0a788b3/thirdparty/pcap++/3rdParty/LightPcapNg/LightPcapNg/include/light_platform.h
----------------------------------------------------------------------
diff --git a/thirdparty/pcap++/3rdParty/LightPcapNg/LightPcapNg/include/light_platform.h b/thirdparty/pcap++/3rdParty/LightPcapNg/LightPcapNg/include/light_platform.h
new file mode 100644
index 0000000..f06baa3
--- /dev/null
+++ b/thirdparty/pcap++/3rdParty/LightPcapNg/LightPcapNg/include/light_platform.h
@@ -0,0 +1,59 @@
+// light_platform.h
+// 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.
+
+#ifndef INCLUDE_LIGHT_PLATFORM_H_
+#define INCLUDE_LIGHT_PLATFORM_H_
+
+#ifndef UNIVERSAL
+#define UNIVERSAL
+#endif // UNIVERSAL
+
+#include <stddef.h>
+
+typedef enum {
+ LIGHT_OREAD,
+ LIGHT_OWRITE,
+ LIGHT_OAPPEND,
+} __read_mode_t;
+
+#ifdef UNIVERSAL
+
+#include <stdio.h>
+
+typedef FILE* __fd_t;
+#define INVALID_FILE NULL
+
+#else
+
+#error UNIMPLEMENRTED
+
+#endif
+
+__fd_t light_open(const char *file_name, const __read_mode_t mode);
+int light_read(__fd_t fd, void *buf, size_t count);
+int light_write(__fd_t fd, const void *buf, size_t count);
+size_t light_size(__fd_t fd);
+int light_close(__fd_t fd);
+int light_flush(__fd_t fd);
+
+#endif /* INCLUDE_LIGHT_PLATFORM_H_ */
http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/blob/c0a788b3/thirdparty/pcap++/3rdParty/LightPcapNg/LightPcapNg/include/light_special.h
----------------------------------------------------------------------
diff --git a/thirdparty/pcap++/3rdParty/LightPcapNg/LightPcapNg/include/light_special.h b/thirdparty/pcap++/3rdParty/LightPcapNg/LightPcapNg/include/light_special.h
new file mode 100644
index 0000000..158ce02
--- /dev/null
+++ b/thirdparty/pcap++/3rdParty/LightPcapNg/LightPcapNg/include/light_special.h
@@ -0,0 +1,74 @@
+// light_special.h
+// 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.
+
+#ifndef INCLUDE_LIGHT_SPECIAL_H_
+#define INCLUDE_LIGHT_SPECIAL_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <stddef.h>
+#include <stdint.h>
+
+#ifndef NULL
+#define NULL ((void *) 0)
+#endif
+
+struct _light_section_header {
+ uint32_t byteorder_magic;
+ uint16_t major_version;
+ uint16_t minor_version;
+ uint64_t section_length;
+};
+
+struct _light_interface_description_block {
+ uint16_t link_type;
+ uint16_t reserved;
+ uint32_t snapshot_length;
+};
+
+struct _light_enhanced_packet_block {
+ uint32_t interface_id;
+ uint32_t timestamp_high, timestamp_low;
+ uint32_t capture_packet_length;
+ uint32_t original_capture_length;
+ uint32_t packet_data[0];
+};
+
+struct _light_simple_packet_block {
+ uint32_t original_packet_length;
+ uint32_t packet_data[0];
+};
+
+struct _light_custom_nonstandard_block {
+ uint32_t data_length;
+ uint32_t reserved0, reserved1;
+ uint32_t packet_data[0];
+};
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* INCLUDE_LIGHT_SPECIAL_H_ */
http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/blob/c0a788b3/thirdparty/pcap++/3rdParty/LightPcapNg/LightPcapNg/include/light_types.h
----------------------------------------------------------------------
diff --git a/thirdparty/pcap++/3rdParty/LightPcapNg/LightPcapNg/include/light_types.h b/thirdparty/pcap++/3rdParty/LightPcapNg/LightPcapNg/include/light_types.h
new file mode 100644
index 0000000..dd35a27
--- /dev/null
+++ b/thirdparty/pcap++/3rdParty/LightPcapNg/LightPcapNg/include/light_types.h
@@ -0,0 +1,41 @@
+// light_types.h
+// 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.
+
+#ifndef INCLUDE_LIGHT_TYPES_H_
+#define INCLUDE_LIGHT_TYPES_H_
+
+typedef enum {
+ LIGHT_FALSE = 0,
+ LIGHT_TRUE = 1,
+// LIGHT_MAYBE = 2,
+} light_boolean;
+
+typedef enum {
+ LIGHT_INFO_TYPE = 0,
+ LIGHT_INFO_LENGTH = 1,
+ LIGHT_INFO_BODY = 2,
+ LIGHT_INFO_OPTIONS = 3,
+ LIGHT_INFO_MAX = 4,
+} light_info;
+
+#endif /* INCLUDE_LIGHT_TYPES_H_ */
http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/blob/c0a788b3/thirdparty/pcap++/3rdParty/LightPcapNg/LightPcapNg/include/light_util.h
----------------------------------------------------------------------
diff --git a/thirdparty/pcap++/3rdParty/LightPcapNg/LightPcapNg/include/light_util.h b/thirdparty/pcap++/3rdParty/LightPcapNg/LightPcapNg/include/light_util.h
new file mode 100644
index 0000000..deeba96
--- /dev/null
+++ b/thirdparty/pcap++/3rdParty/LightPcapNg/LightPcapNg/include/light_util.h
@@ -0,0 +1,32 @@
+// light_util.h
+// 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.
+
+#ifndef INCLUDE_LIGHT_UTIL_H_
+#define INCLUDE_LIGHT_UTIL_H_
+
+#define PADD32(val, aligned_val_p) do { \
+ *aligned_val_p = (val % sizeof(uint32_t)) == 0 ? val : (val / sizeof(uint32_t) + 1) * sizeof(uint32_t); \
+} while (0)
+
+
+#endif /* INCLUDE_LIGHT_UTIL_H_ */
http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/blob/c0a788b3/thirdparty/pcap++/3rdParty/LightPcapNg/LightPcapNg/src/Makefile
----------------------------------------------------------------------
diff --git a/thirdparty/pcap++/3rdParty/LightPcapNg/LightPcapNg/src/Makefile b/thirdparty/pcap++/3rdParty/LightPcapNg/LightPcapNg/src/Makefile
new file mode 100644
index 0000000..def3373
--- /dev/null
+++ b/thirdparty/pcap++/3rdParty/LightPcapNg/LightPcapNg/src/Makefile
@@ -0,0 +1,36 @@
+ROOT_DIR = ..
+INCLUDE = $(ROOT_DIR)/include
+HEADERS = $(INCLUDE)/light_pcapng.h $(INCLUDE)/light_special.h $(INCLUDE)/light_debug.h \
+ $(INCLUDE)/light_platform.h $(INCLUDE)/light_internal.h $(INCLUDE)/light_util.h $(INCLUDE)/light_types.h
+SOURCES = light_io.c light_pcapng.c light_pcapng_cont.c light_platform.c light_manipulate.c light_internal.c light_alloc.c \
+ light_advanced.c light_option.c
+OBJECTS = $(SOURCES:.c=.o)
+PRECOMPILED = $(HEADERS:.h=.gch)
+
+TESTS = tests/test_read.c tests/test_read_write.c tests/test_mem.c tests/test_histogram.c tests/test_subcapture.c \
+ tests/test_feature.c tests/test_flow.c tests/test_feature_advanced.c
+TESTE = $(TESTS:.c=.test)
+
+LDFLAGS = -ldl
+INCLUDES = -I$(ROOT_DIR)/include
+DEBUG = -g -p -ggdb -D_DEBUG
+CFLAGS = -Wall -O2 -fPIC -DUNIVERSAL -g
+# CFLAGS += $(DEBUG)
+# LDFLAGS += $(DEBUG)
+
+all: liblight_pcapng.so liblight_pcapng.a $(TESTE)
+
+%.o: %.c $(HEADERS)
+ $(CC) $^ -c $(CFLAGS) $(INCLUDES)
+
+tests/%.test: tests/%.c liblight_pcapng.a
+ $(CC) $^ -o $@ $(CFLAGS) $(INCLUDES) $(LDFLAGS)
+
+liblight_pcapng.so: $(OBJECTS)
+ $(CC) $^ -shared -o $@ $(LDFLAGS)
+
+liblight_pcapng.a: $(OBJECTS)
+ $(AR) rc $@ $^
+
+clean:
+ rm -rf $(TESTE) $(OBJECTS) $(PRECOMPILED) liblight_pcapng.a liblight_pcapng.so
http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/blob/c0a788b3/thirdparty/pcap++/3rdParty/LightPcapNg/LightPcapNg/src/light_advanced.c
----------------------------------------------------------------------
diff --git a/thirdparty/pcap++/3rdParty/LightPcapNg/LightPcapNg/src/light_advanced.c b/thirdparty/pcap++/3rdParty/LightPcapNg/LightPcapNg/src/light_advanced.c
new file mode 100644
index 0000000..715ab6e
--- /dev/null
+++ b/thirdparty/pcap++/3rdParty/LightPcapNg/LightPcapNg/src/light_advanced.c
@@ -0,0 +1,68 @@
+// light_advanced.c
+// Created on: Aug 19, 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_internal.h"
+#include "light_pcapng.h"
+
+#include <stdlib.h>
+
+int light_section_feature_extraction(const light_pcapng section, int (*extractor)(const light_pcapng, void *, size_t),
+ void **feature_vector, const size_t feature_vector_size, const light_feature_t type)
+{
+ light_pcapng iterator;
+
+ if (__is_section_header(section) != LIGHT_TRUE) {
+ return LIGHT_INVALID_SECTION;
+ }
+
+ switch(type) {
+ case LIGHT_FEATURE_BITMASK:
+ *feature_vector = calloc(1, sizeof(uint64_t));
+ break;
+ case LIGHT_FEATURE_BYTE:
+ *feature_vector = calloc(feature_vector_size, sizeof(uint8_t));
+ break;
+ case LIGHT_FEATURE_SHORT:
+ *feature_vector = calloc(feature_vector_size, sizeof(uint16_t));
+ break;
+ case LIGHT_FEATURE_FLOAT:
+ *feature_vector = calloc(feature_vector_size, sizeof(float));
+ break;
+ case LIGHT_FEATURE_DOUBLE:
+ *feature_vector = calloc(feature_vector_size, sizeof(double));
+ break;
+ }
+
+ if (*feature_vector == NULL) {
+ return LIGHT_OUT_OF_MEMORY;
+ }
+
+ extractor(section, *feature_vector, feature_vector_size);
+ iterator = section->next_block;
+ while (iterator != NULL && __is_section_header(iterator) != LIGHT_TRUE) {
+ extractor(iterator, *feature_vector, feature_vector_size);
+ iterator = iterator->next_block;
+ }
+
+ return LIGHT_SUCCESS;
+}
http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/blob/c0a788b3/thirdparty/pcap++/3rdParty/LightPcapNg/LightPcapNg/src/light_alloc.c
----------------------------------------------------------------------
diff --git a/thirdparty/pcap++/3rdParty/LightPcapNg/LightPcapNg/src/light_alloc.c b/thirdparty/pcap++/3rdParty/LightPcapNg/LightPcapNg/src/light_alloc.c
new file mode 100644
index 0000000..ed02af4
--- /dev/null
+++ b/thirdparty/pcap++/3rdParty/LightPcapNg/LightPcapNg/src/light_alloc.c
@@ -0,0 +1,83 @@
+// light_alloc.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 "light_internal.h"
+#include "light_util.h"
+
+#include <stdlib.h>
+#include <string.h>
+
+light_option light_alloc_option(uint16_t option_length)
+{
+ struct _light_option *option = calloc(1, sizeof(struct _light_option));
+ uint16_t actual_size = 0;
+
+ option->option_length = option_length;
+
+ PADD32(option_length, &actual_size);
+ if (actual_size != 0) {
+ option->data = calloc(1, actual_size);
+ }
+
+ return option;
+}
+
+light_pcapng light_alloc_block(uint32_t block_type, const uint32_t *block_body, uint32_t block_body_length)
+{
+ struct _light_pcapng *pcapng_block = calloc(1, sizeof(struct _light_pcapng));
+ uint32_t actual_size = 0;
+ int32_t block_body_size;
+
+ pcapng_block->block_type = block_type;
+
+ PADD32(block_body_length, &actual_size);
+
+ pcapng_block->block_total_lenght = actual_size; // This value MUST be a multiple of 4.
+ block_body_size = actual_size - 2 * sizeof(pcapng_block->block_total_lenght) - sizeof(pcapng_block->block_type);
+
+ if (block_body_size > 0) {
+ pcapng_block->block_body = calloc(1, block_body_size);
+ memcpy(pcapng_block->block_body, block_body, block_body_size);
+ }
+
+ pcapng_block->next_block = NULL;
+ pcapng_block->options = NULL;
+
+ return pcapng_block;
+}
+
+void light_free_option(light_option option)
+{
+ free(option->data);
+ free(option);
+}
+
+void light_free_block(light_pcapng pcapng)
+{
+ free(pcapng);
+ free(pcapng->block_body);
+}
+
+
http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/blob/c0a788b3/thirdparty/pcap++/3rdParty/LightPcapNg/LightPcapNg/src/light_internal.c
----------------------------------------------------------------------
diff --git a/thirdparty/pcap++/3rdParty/LightPcapNg/LightPcapNg/src/light_internal.c b/thirdparty/pcap++/3rdParty/LightPcapNg/LightPcapNg/src/light_internal.c
new file mode 100644
index 0000000..89ba01c
--- /dev/null
+++ b/thirdparty/pcap++/3rdParty/LightPcapNg/LightPcapNg/src/light_internal.c
@@ -0,0 +1,161 @@
+// light_internal.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_internal.h"
+
+#include "light_debug.h"
+#include "light_pcapng.h"
+#include "light_util.h"
+
+#include <stdlib.h>
+#include <string.h>
+
+struct _light_option *__copy_option(const struct _light_option *option)
+{
+ if (option == NULL) {
+ return NULL;
+ }
+
+ size_t current_size = 0;
+ struct _light_option *copy = calloc(1, sizeof(struct _light_option));
+
+ PADD32(option->option_length, ¤t_size);
+
+ copy->custom_option_code = option->custom_option_code;
+ copy->option_length = option->option_length;
+ copy->data = calloc(1, current_size);
+ memcpy(copy->data, option->data, option->option_length);
+
+ copy->next_option = __copy_option(option->next_option);
+
+ return copy;
+}
+
+struct _light_pcapng *__copy_block(const struct _light_pcapng *pcapng, const light_boolean recursive)
+{
+ if (pcapng == NULL) {
+ return NULL;
+ }
+
+ size_t body_length = pcapng->block_total_lenght - 2 * sizeof(pcapng->block_total_lenght) - sizeof(pcapng->block_type);
+ struct _light_pcapng *pcopy = calloc(1, sizeof(struct _light_pcapng));
+ size_t option_length = 0;
+
+ pcopy->block_type = pcapng->block_type;
+ pcopy->block_total_lenght = pcapng->block_total_lenght;
+ pcopy->options = __copy_option(pcapng->options);
+ option_length = __get_option_total_size(pcopy->options);
+ body_length -= option_length;
+
+ pcopy->block_body = calloc(body_length, 1);
+ memcpy(pcopy->block_body, pcapng->block_body, body_length);
+
+ if (recursive == LIGHT_TRUE) {
+ pcopy->next_block = __copy_block(pcapng->next_block, recursive);
+ }
+ else {
+ pcopy->next_block = NULL;
+ }
+
+ return pcopy;
+}
+
+size_t __get_option_total_size(const struct _light_option *option)
+{
+ size_t size = 0;
+
+ while (option != NULL) {
+ uint16_t actual_length;
+ PADD32(option->option_length, &actual_length);
+ size += 4 + actual_length;
+ option = option->next_option;
+ }
+
+ return size;
+}
+
+uint32_t *__get_option_size(const struct _light_option *option, size_t *size)
+{
+ if (option == NULL) {
+ *size = 0;
+ return NULL;
+ }
+
+ size_t next_size;
+ uint32_t *next_option = __get_option_size(option->next_option, &next_size);
+ uint32_t *current_mem;
+ size_t current_size = 0;
+
+ PADD32(option->option_length, ¤t_size);
+
+ current_mem = calloc(sizeof(uint32_t) + current_size + next_size, 1);
+ current_mem[0] = option->custom_option_code | (option->option_length << 16);
+ memcpy(¤t_mem[1], option->data, current_size);
+ memcpy(¤t_mem[1 + current_size / 4], next_option, next_size);
+
+ current_size += sizeof(option->custom_option_code) + sizeof(option->option_length) + next_size;
+ *size = current_size;
+
+ free(next_option);
+
+ return current_mem;
+}
+
+light_boolean __is_section_header(const struct _light_pcapng * section)
+{
+ if (section != NULL) {
+ if (section->block_type != LIGHT_SECTION_HEADER_BLOCK) {
+ return LIGHT_FALSE;
+ }
+ else {
+ return LIGHT_TRUE;
+ }
+ }
+
+ return LIGHT_FALSE;
+}
+
+int __validate_section(struct _light_pcapng *section)
+{
+ if (__is_section_header(section) != LIGHT_TRUE) {
+ return LIGHT_INVALID_SECTION;
+ }
+
+ struct _light_section_header *shb = (struct _light_section_header *)section->block_body;
+ uint64_t size = section->block_total_lenght;
+ struct _light_pcapng *next_block = section->next_block;
+
+ while (next_block != NULL) {
+ if (__is_section_header(next_block) == LIGHT_TRUE) {
+ shb->section_length = size;
+ return __validate_section(next_block);
+ }
+ else {
+ size += next_block->block_total_lenght;
+ next_block = next_block->next_block;
+ }
+ }
+
+ shb->section_length = size;
+ return LIGHT_SUCCESS;
+}
http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/blob/c0a788b3/thirdparty/pcap++/3rdParty/LightPcapNg/LightPcapNg/src/light_io.c
----------------------------------------------------------------------
diff --git a/thirdparty/pcap++/3rdParty/LightPcapNg/LightPcapNg/src/light_io.c b/thirdparty/pcap++/3rdParty/LightPcapNg/LightPcapNg/src/light_io.c
new file mode 100644
index 0000000..3fb707d
--- /dev/null
+++ b/thirdparty/pcap++/3rdParty/LightPcapNg/LightPcapNg/src/light_io.c
@@ -0,0 +1,65 @@
+// light_io.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_debug.h"
+#include "light_internal.h"
+#include "light_pcapng.h"
+#include "light_platform.h"
+
+#include <stdio.h>
+#include <stdlib.h>
+
+light_pcapng light_read_from_path(const char *file_name)
+{
+ light_pcapng head;
+ uint32_t *memory;
+ size_t size = 0;
+ __fd_t fd = light_open(file_name, LIGHT_OREAD);
+ DCHECK_ASSERT_EXP(fd != NULL, "could not open file", return NULL);
+
+ size = light_size(fd);
+ DCHECK_INT(size, 0, light_stop);
+
+ memory = calloc(size, 1);
+
+ DCHECK_INT(light_read(fd, memory, size), size - 1, light_stop);
+
+ head = light_read_from_memory(memory, size);
+
+ light_close(fd);
+ free(memory);
+
+ return head;
+}
+
+int light_pcapng_to_file(const char *file_name, const light_pcapng pcapng)
+{
+ size_t size;
+ uint32_t *data = light_pcapng_to_memory(pcapng, &size);
+ __fd_t fd = light_open(file_name, LIGHT_OWRITE);
+
+ light_write(fd, data, size);
+ light_close(fd);
+ free(data);
+ return LIGHT_SUCCESS;
+}
http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/blob/c0a788b3/thirdparty/pcap++/3rdParty/LightPcapNg/LightPcapNg/src/light_manipulate.c
----------------------------------------------------------------------
diff --git a/thirdparty/pcap++/3rdParty/LightPcapNg/LightPcapNg/src/light_manipulate.c b/thirdparty/pcap++/3rdParty/LightPcapNg/LightPcapNg/src/light_manipulate.c
new file mode 100644
index 0000000..e995d2a
--- /dev/null
+++ b/thirdparty/pcap++/3rdParty/LightPcapNg/LightPcapNg/src/light_manipulate.c
@@ -0,0 +1,504 @@
+// light_manipulate.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 "light_debug.h"
+#include "light_internal.h"
+#include "light_util.h"
+
+#include <stdlib.h>
+#include <string.h>
+
+
+#if BYTE_ORDER == BIG_ENDIAN
+
+#define LIGHT_HTONS(n) (n)
+#define LIGHT_NTOHS(n) (n)
+#define LIGHT_HTONL(n) (n)
+#define LIGHT_NTOHL(n) (n)
+
+#elif BYTE_ORDER == LITTLE_ENDIAN
+
+#define LIGHT_HTONS(n) (((((unsigned short)(n) & 0xFF)) << 8) | (((unsigned short)(n) & 0xFF00) >> 8))
+#define LIGHT_NTOHS(n) (((((unsigned short)(n) & 0xFF)) << 8) | (((unsigned short)(n) & 0xFF00) >> 8))
+
+#define LIGHT_HTONL(n) (((((unsigned long)(n) & 0xFF)) << 24) | \
+ ((((unsigned long)(n) & 0xFF00)) << 8) | \
+ ((((unsigned long)(n) & 0xFF0000)) >> 8) | \
+ ((((unsigned long)(n) & 0xFF000000)) >> 24))
+
+#define LIGHT_NTOHL(n) (((((unsigned long)(n) & 0xFF)) << 24) | \
+ ((((unsigned long)(n) & 0xFF00)) << 8) | \
+ ((((unsigned long)(n) & 0xFF0000)) >> 8) | \
+ ((((unsigned long)(n) & 0xFF000000)) >> 24))
+#else
+#error "Both BIG_ENDIAN or LITTLE_ENDIAN are not #defined"
+#endif
+
+
+light_option light_create_option(const uint16_t option_code, uint16_t option_length, void *option_value)
+{
+ uint16_t size = 0;
+ light_option option = calloc(1, sizeof(struct _light_option));
+
+ PADD32(option_length, &size);
+ option->custom_option_code = option_code;
+ option->option_length = option_length;
+
+ option->data = calloc(size, sizeof(uint8_t));
+ memcpy(option->data, option_value, option_length);
+
+ return option;
+}
+
+int light_add_option(light_pcapng section, light_pcapng pcapng, light_option option, light_boolean copy)
+{
+ size_t option_size = 0;
+ light_option option_list = NULL;
+
+ if (option == NULL) {
+ return LIGHT_INVALID_ARGUMENT;
+ }
+
+ if (copy == LIGHT_TRUE) {
+ option_list = __copy_option(option);
+ }
+ else {
+ option_list = option;
+ }
+
+ option_size = __get_option_total_size(option_list);
+
+ if (pcapng->options == NULL) {
+ light_option iterator = option_list;
+ while (iterator->next_option != NULL) {
+ iterator = iterator->next_option;
+ }
+
+ if (iterator->custom_option_code != 0) {
+ // Add terminator option.
+ iterator->next_option = calloc(1, sizeof(struct _light_option));
+ option_size += 4;
+ }
+ pcapng->options = option_list;
+ }
+ else {
+ light_option current = pcapng->options;
+ while (current->next_option && current->next_option->custom_option_code != 0) {
+ current = current->next_option;
+ }
+
+ light_option opt_endofopt = current->next_option;
+ current->next_option = option_list;
+ option_list->next_option = opt_endofopt;
+ }
+
+ pcapng->block_total_lenght += option_size;
+
+ if (__is_section_header(section) == 1) {
+ struct _light_section_header *shb = (struct _light_section_header *)section->block_body;
+ shb->section_length += option_size;
+ }
+ else if (section != NULL) {
+ PCAPNG_WARNING("PCAPNG block is not section header!");
+ }
+
+ return LIGHT_SUCCESS;
+}
+
+int light_update_option(light_pcapng section, light_pcapng pcapng, light_option option)
+{
+ light_option iterator = pcapng->options;
+ uint16_t old_data_size, new_data_size;
+
+ while (iterator != NULL) {
+ if (iterator->custom_option_code == option->custom_option_code) {
+ break;
+ }
+ iterator = iterator->next_option;
+ }
+
+ if (iterator == NULL) {
+ return light_add_option(section, pcapng, option, LIGHT_TRUE);
+ }
+
+ if (iterator->option_length != option->option_length) {
+ PADD32(option->option_length, &new_data_size);
+ PADD32(iterator->option_length, &old_data_size);
+
+ int data_size_diff = (int)new_data_size - (int)old_data_size;
+ pcapng->block_total_lenght += data_size_diff;
+
+ if (__is_section_header(section) == 1) {
+ struct _light_section_header *shb = (struct _light_section_header *)section->block_body;
+ shb->section_length += data_size_diff;
+ }
+ else {
+ PCAPNG_WARNING("PCAPNG block is not section header!");
+ }
+
+ iterator->option_length = option->option_length;
+ free(iterator->data);
+ iterator->data = calloc(new_data_size, sizeof(uint8_t));
+ }
+
+ memcpy(iterator->data, option->data, iterator->option_length);
+
+ return LIGHT_SUCCESS;
+}
+
+int light_add_block(light_pcapng block, light_pcapng next_block)
+{
+ block->next_block = next_block;
+ return LIGHT_SUCCESS;
+}
+
+int light_subcapture(const light_pcapng section, light_boolean (*predicate)(const light_pcapng), light_pcapng *subcapture)
+{
+ if (__is_section_header(section) == 0) {
+ PCAPNG_ERROR("Invalid section header");
+ return LIGHT_INVALID_SECTION;
+ }
+
+ // Root section header is automatically included into the subcapture.
+ light_pcapng root = __copy_block(section, LIGHT_FALSE);
+ light_pcapng iterator = root;
+ light_pcapng next_block = section->next_block;
+
+ while (next_block != NULL) {
+ // Predicate functions applies to all block types, including section header blocks.
+ if (!!predicate(next_block) == LIGHT_TRUE) {
+ iterator->next_block = __copy_block(next_block, LIGHT_FALSE);
+ iterator = iterator->next_block;
+ }
+ next_block = next_block->next_block;
+ }
+
+ *subcapture = root;
+ return __validate_section(*subcapture);
+
+}
+
+typedef union {
+ union {
+ uint32_t raw;
+ uint8_t bytes[4];
+ } ipv4;
+ union {
+ uint64_t raw[2];
+ uint16_t words[8];
+ } ipv6;
+} address_t;
+
+typedef struct _flow_address {
+ address_t source;
+ address_t destination;
+} flow_address_t;
+
+typedef struct _flow_information {
+ uint8_t version;
+ flow_address_t address;
+ light_pcapng section; // Deep copy.
+ light_pcapng interface; // Deep copy.
+ light_pcapng last_block;
+ struct _flow_information *next;
+} flow_information_t;
+
+static void __extract_ipv4_address(const uint8_t *payload, flow_address_t *address)
+{
+ const uint8_t *address_offest = payload + 12;
+ int i;
+
+ for (i = 0; i < 4; ++i) {
+ address->source.ipv4.bytes[i] = address_offest[i];
+ }
+
+ address_offest += 4;
+ for (i = 0; i < 4; ++i) {
+ address->destination.ipv4.bytes[i] = address_offest[i];
+ }
+}
+
+static void __extract_ipv6_address(const uint8_t *payload, flow_address_t *address)
+{
+ const uint8_t *address_offest = payload + 8;
+ int i;
+
+ for (i = 0; i < 16; i += 2) {
+ address->source.ipv6.words[i / 2] = LIGHT_NTOHS(*(uint16_t*)(&address_offest[i]));
+ }
+
+ address_offest += 16;
+ for (i = 0; i < 16; i += 2) {
+ address->destination.ipv6.words[i / 2] = LIGHT_NTOHS(*(uint16_t*)(&address_offest[i]));
+ }
+}
+
+static light_boolean __get_ip_address(const uint8_t *payload, flow_address_t *address, uint8_t *protocol_version)
+{
+ uint16_t ethernet_type = LIGHT_NTOHS(*(uint16_t*)(payload + 12));
+ payload += 14; // MAC address is 6 bytes long. ==> 2 x 6 + 2
+
+ switch (ethernet_type) {
+ case 0x0800: // Internet Protocol v4
+ case 0x86DD: // Internet Protocol v6
+ break;
+ case 0x8100: // 802.1Q Virtual LAN
+ payload += 4;
+ break;
+ case 0x9100: // 802.1Q DoubleTag
+ payload += 6;
+ break;
+ default:
+ // PCAPNG_WARNING("Unhandled Ethernet type(len)");
+ return LIGHT_FALSE;
+ }
+
+ *protocol_version = (*payload >> 4) & 0b1111;
+
+ if (*protocol_version == 4) {
+ __extract_ipv4_address(payload, address);
+ }
+ else if (*protocol_version == 6) {
+ __extract_ipv6_address(payload, address);
+ }
+ else {
+ // PCAPNG_WARNING("Unknown protocol version");
+ // fprintf(stderr, "Unknown protocol version %u for ether type 0x%X\n", *protocol_version, ethernet_type);
+ return LIGHT_FALSE;
+ }
+
+ return LIGHT_TRUE;
+}
+
+static light_boolean __get_address(const light_pcapng pcapng, flow_address_t *address, uint8_t *protocol_version)
+{
+ uint32_t type = pcapng->block_type;
+
+ if (type == LIGHT_ENHANCED_PACKET_BLOCK) {
+ struct _light_enhanced_packet_block *epb = (struct _light_enhanced_packet_block *)pcapng->block_body;
+ uint8_t *bytes = (uint8_t *)epb->packet_data;
+ return __get_ip_address(bytes, address, protocol_version);
+ }
+ else if (type == LIGHT_SIMPLE_PACKET_BLOCK) {
+ struct _light_simple_packet_block *epb = (struct _light_simple_packet_block *)pcapng->block_body;
+ uint8_t *bytes = (uint8_t *)epb->packet_data;
+ return __get_ip_address(bytes, address, protocol_version);
+ }
+
+ return LIGHT_FALSE;
+}
+
+static flow_information_t *__create_flow(const light_pcapng section, const light_pcapng interface, const flow_address_t *key, const uint8_t protocol_version)
+{
+ flow_information_t *flow = calloc(1, sizeof(flow_information_t));
+
+ flow->version = protocol_version;
+ memcpy(&flow->address, key, sizeof(flow->address));
+ flow->section = __copy_block(section, LIGHT_FALSE);
+ flow->interface = __copy_block(interface, LIGHT_FALSE);;
+ flow->last_block = flow->interface;
+
+ flow->section->next_block = flow->interface;
+
+ return flow;
+}
+
+// Could be better.
+static flow_information_t *__find_flow(flow_information_t *start, const flow_address_t *key, const uint8_t protocol_version)
+{
+ while (start != NULL) {
+ if (start->version == protocol_version) {
+ if (start->address.source.ipv6.raw[0] == key->source.ipv6.raw[0] && start->address.source.ipv6.raw[1] == key->source.ipv6.raw[1] &&
+ start->address.destination.ipv6.raw[0] == key->destination.ipv6.raw[0] && start->address.destination.ipv6.raw[1] == key->destination.ipv6.raw[1]) {
+ return start;
+ }
+
+ if (start->address.source.ipv6.raw[0] == key->destination.ipv6.raw[0] && start->address.source.ipv6.raw[1] == key->destination.ipv6.raw[1] &&
+ start->address.destination.ipv6.raw[0] == key->source.ipv6.raw[0] && start->address.destination.ipv6.raw[1] == key->source.ipv6.raw[1]) {
+ return start;
+ }
+ }
+ start = start->next;
+ }
+
+ return NULL;
+}
+
+static void __append_address_information(light_pcapng section, const flow_information_t *info)
+{
+ light_option flow_option;
+ uint8_t *option_data;
+ uint16_t option_length = 1;
+
+ if (info->version == 4) {
+ option_length += 2 * sizeof(info->address.source.ipv4);
+ }
+ else if (info->version == 6) {
+ option_length += 2 * sizeof(info->address.source.ipv6);
+ }
+
+ // Maybe I could use light_create_option instead of light_alloc_option.
+ flow_option = light_alloc_option(option_length);
+ flow_option->custom_option_code = LIGHT_CUSTOM_OPTION_ADDRESS_INFO;
+ option_data = (uint8_t *)flow_option->data;
+
+ memcpy(option_data, &info->version, sizeof(info->version));
+ option_data += sizeof(info->version);
+ if (info->version == 4) {
+ memcpy(option_data, &info->address.source.ipv4, sizeof(info->address.source.ipv4));
+ option_data += sizeof(info->address.source.ipv4);
+ memcpy(option_data, &info->address.destination.ipv4, sizeof(info->address.destination.ipv4));
+ }
+ else if (info->version == 6) {
+ memcpy(option_data, &info->address.source.ipv6, sizeof(info->address.source.ipv6));
+ option_data += sizeof(info->address.source.ipv6);
+ memcpy(option_data, &info->address.destination.ipv6, sizeof(info->address.destination.ipv6));
+ }
+ light_add_option(section, info->section, flow_option, LIGHT_FALSE);
+}
+
+int light_ip_flow(light_pcapng *sectionp, light_pcapng **flows, size_t *flow_count, size_t *dropped)
+{
+ light_pcapng section = *sectionp;
+ size_t progress = 0;
+ size_t limit = light_get_block_count(*sectionp);
+ size_t skipped = 0;
+
+ if (__is_section_header(section) == 0) {
+ PCAPNG_ERROR("Invalid section header");
+ return LIGHT_INVALID_SECTION;
+ }
+
+ light_pcapng current_section = section;
+ light_pcapng current_interface = NULL;
+ light_pcapng *interface_list = NULL;
+ uint32_t interface_list_size = 0;
+
+ flow_information_t *current_flow = NULL;
+ flow_information_t *last_flow = NULL;
+ light_pcapng current_block = section->next_block;
+
+ *flow_count = 0;
+
+ while (current_block != NULL) {
+ uint32_t type = current_block->block_type;
+ if (type == LIGHT_SECTION_HEADER_BLOCK) {
+ // current_section = current_block;
+ *sectionp = current_block;
+ break;
+ }
+ else if (type == LIGHT_INTERFACE_BLOCK) {
+ current_interface = current_block;
+ interface_list = realloc(interface_list, (interface_list_size + 1) * sizeof(light_pcapng));
+ interface_list[interface_list_size] = current_interface;
+ interface_list_size++;
+ }
+ else if (type == LIGHT_ENHANCED_PACKET_BLOCK || type == LIGHT_SIMPLE_PACKET_BLOCK) {
+ flow_address_t flow_key = {0};
+ uint8_t protocol_version;
+ flow_information_t *match = NULL;
+
+ if (__get_address(current_block, &flow_key, &protocol_version) == LIGHT_FALSE) {
+ skipped++;
+ goto iterate;
+ }
+
+ if (current_flow == NULL) { // Beginning of the trace.
+ if (type == LIGHT_SIMPLE_PACKET_BLOCK) {
+ current_flow = __create_flow(current_section, current_interface, &flow_key, protocol_version);
+ }
+ else {
+ struct _light_enhanced_packet_block *epb = (struct _light_enhanced_packet_block *)current_block->block_body;
+ current_flow = __create_flow(current_section, interface_list[epb->interface_id], &flow_key, protocol_version);
+ }
+ match = current_flow;
+ last_flow = current_flow;
+ *flow_count = 1;
+ }
+ else {
+ match = __find_flow(current_flow, &flow_key, protocol_version);
+ }
+
+ if (match == NULL) {
+ if (type == LIGHT_SIMPLE_PACKET_BLOCK) {
+ match = __create_flow(current_section, current_interface, &flow_key, protocol_version);
+ }
+ else {
+ struct _light_enhanced_packet_block *epb = (struct _light_enhanced_packet_block *)current_block->block_body;
+ match = __create_flow(current_section, interface_list[epb->interface_id], &flow_key, protocol_version);
+ }
+
+ last_flow->next = match;
+ last_flow = match;
+ *flow_count += 1;
+ }
+ else {
+ match->last_block->next_block = __copy_block(current_block, LIGHT_FALSE);
+ match->last_block = match->last_block->next_block;
+ }
+ }
+ else {
+ // TODO: Append other blocks to all flows accordingly.
+ }
+
+iterate:
+ progress++;
+ if (progress % 10000 == 0) {
+ printf("Flow extraction progress: %.2lf [%d / %d]\n", (double)progress / limit * 100.0, (int)progress, (int)limit);
+ }
+ current_block = current_block->next_block;
+ }
+
+ if (dropped != NULL) {
+ *dropped = skipped;
+ }
+
+ // End of trace.
+ if (current_block == NULL) {
+ *sectionp = NULL;
+ }
+
+ *flows = calloc(*flow_count, sizeof(light_pcapng));
+ uint32_t index = 0;
+ flow_information_t *iterator = current_flow;
+
+ while (iterator != NULL) {
+ (*flows)[index] = iterator->section;
+ __validate_section((*flows)[index]);
+ __append_address_information(iterator->section, iterator);
+ index++;
+ iterator = iterator->next;
+ }
+
+ while (current_flow != NULL) {
+ flow_information_t *to_be_deleted = current_flow;
+ current_flow = current_flow->next;
+ free(to_be_deleted);
+ }
+
+ free(interface_list);
+
+ return LIGHT_SUCCESS;
+}
http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/blob/c0a788b3/thirdparty/pcap++/3rdParty/LightPcapNg/LightPcapNg/src/light_option.c
----------------------------------------------------------------------
diff --git a/thirdparty/pcap++/3rdParty/LightPcapNg/LightPcapNg/src/light_option.c b/thirdparty/pcap++/3rdParty/LightPcapNg/LightPcapNg/src/light_option.c
new file mode 100644
index 0000000..c1aa095
--- /dev/null
+++ b/thirdparty/pcap++/3rdParty/LightPcapNg/LightPcapNg/src/light_option.c
@@ -0,0 +1,66 @@
+// light_option.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 "light_debug.h"
+#include "light_internal.h"
+
+light_option light_get_option(const light_pcapng pcapng, uint16_t option_code)
+{
+ if (pcapng == NULL) {
+ return NULL;
+ }
+
+ light_option iterator = pcapng->options;
+
+ while (iterator != NULL) {
+ if (iterator->custom_option_code == option_code) {
+ break;
+ }
+ iterator = iterator->next_option;
+ }
+
+ return iterator;
+}
+
+uint16_t light_get_option_code(const light_option option)
+{
+ return option->custom_option_code;
+}
+
+const light_option light_get_next_option(const light_option option)
+{
+ return option->next_option;
+}
+
+uint32_t *light_get_option_data(const light_option option)
+{
+ return option->data;
+}
+
+uint16_t light_get_option_length(const light_option option)
+{
+ return option->option_length;
+}
+
http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/blob/c0a788b3/thirdparty/pcap++/3rdParty/LightPcapNg/LightPcapNg/src/light_pcapng.c
----------------------------------------------------------------------
diff --git a/thirdparty/pcap++/3rdParty/LightPcapNg/LightPcapNg/src/light_pcapng.c b/thirdparty/pcap++/3rdParty/LightPcapNg/LightPcapNg/src/light_pcapng.c
new file mode 100644
index 0000000..7192950
--- /dev/null
+++ b/thirdparty/pcap++/3rdParty/LightPcapNg/LightPcapNg/src/light_pcapng.c
@@ -0,0 +1,551 @@
+// light_pcapng.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 "light_debug.h"
+#include "light_internal.h"
+#include "light_util.h"
+
+#include <stdlib.h>
+#include <string.h>
+
+// Documentation from: https://github.com/pcapng/pcapng
+
+static struct _light_option *__parse_options(uint32_t **memory, const int32_t max_len)
+{
+ if (max_len <= 0) {
+ return NULL;
+ }
+ else {
+ struct _light_option *opt = calloc(1, sizeof(struct _light_option));
+ uint16_t actual_length;
+ uint16_t allignment = sizeof(uint32_t);
+
+ uint16_t *local_memory = (uint16_t*)*memory;
+ uint16_t remaining_size;
+
+ opt->custom_option_code = *local_memory++;
+ opt->option_length = *local_memory++;
+
+ actual_length = (opt->option_length % allignment) == 0 ?
+ opt->option_length :
+ (opt->option_length / allignment + 1) * allignment;
+
+ if (actual_length > 0) {
+ opt->data = calloc(1, actual_length);
+ memcpy(opt->data, local_memory, actual_length);
+ local_memory += (sizeof(**memory) / sizeof(*local_memory)) * (actual_length / allignment);
+ }
+
+ *memory = (uint32_t*)local_memory;
+ remaining_size = max_len - actual_length - 2 * sizeof(*local_memory);
+
+ if (opt->custom_option_code == 0) {
+ DCHECK_ASSERT(opt->option_length, 0, light_stop);
+ DCHECK_ASSERT(remaining_size, 0, light_stop);
+
+ if (remaining_size) {
+ // XXX: Treat the remaining data as garbage and discard it form the trace.
+ *memory += remaining_size / sizeof(uint32_t);
+ }
+ }
+ else {
+ opt->next_option = __parse_options(memory, remaining_size);
+ }
+
+ return opt;
+ }
+}
+
+// Parse memory and allocate _light_pcapng array.
+static size_t __parse_mem_copy(struct _light_pcapng **iter, const uint32_t *memory, const size_t size)
+{
+ struct _light_pcapng *current = NULL;
+ size_t bytes_read = 0;
+ size_t remaining = size;
+ size_t block_count = 0;
+
+ *iter = NULL;
+
+ while (remaining > 12) {
+ const uint32_t *local_data = (const uint32_t *)(memory);
+
+ if (current == NULL) {
+ current = calloc(1, sizeof(struct _light_pcapng));
+ DCHECK_NULLP(current, return block_count);
+
+ if (*iter == NULL) {
+ *iter = current;
+ }
+ }
+ else {
+ current->next_block = calloc(1, sizeof(struct _light_pcapng));
+ DCHECK_NULLP(current->next_block, return block_count);
+
+ current = current->next_block;
+ }
+
+ current->block_type = *local_data++;
+ current->block_total_lenght = *local_data++;
+ DCHECK_INT(((current->block_total_lenght % 4) == 0), 0, light_stop);
+
+ switch (current->block_type)
+ {
+ case LIGHT_SECTION_HEADER_BLOCK:
+ {
+ DPRINT_HERE(LIGHT_SECTION_HEADER_BLOCK);
+ struct _light_section_header *shb = calloc(1, sizeof(struct _light_section_header));
+ struct _light_option *opt = NULL;
+ uint32_t version;
+ int32_t local_offset;
+
+ shb->byteorder_magic = *local_data++;
+ // TODO check byte order.
+ version = *local_data++;
+ shb->major_version = version & 0xFFFF;
+ shb->minor_version = (version >> 16) & 0xFFFF;
+ shb->section_length = *((uint64_t*)local_data);
+ local_data += 2;
+
+ current->block_body = (uint32_t*)shb;
+ local_offset = (size_t)local_data - (size_t)memory;
+ opt = __parse_options((uint32_t **)&local_data, current->block_total_lenght - local_offset - sizeof(current->block_total_lenght));
+ current->options = opt;
+ }
+ break;
+
+ case LIGHT_INTERFACE_BLOCK:
+ {
+ DPRINT_HERE(LIGHT_INTERFACE_BLOCK);
+ struct _light_interface_description_block *idb = calloc(1, sizeof(struct _light_interface_description_block));
+ struct _light_option *opt = NULL;
+ uint32_t link_reserved = *local_data++;
+ int32_t local_offset;
+
+ idb->link_type = link_reserved & 0xFFFF;
+ idb->reserved = (link_reserved >> 16) & 0xFFFF;
+ idb->snapshot_length = *local_data++;
+ current->block_body = (uint32_t*)idb;
+ local_offset = (size_t)local_data - (size_t)memory;
+ opt = __parse_options((uint32_t **)&local_data, current->block_total_lenght - local_offset - sizeof(current->block_total_lenght));
+ current->options = opt;
+ }
+ break;
+
+ case LIGHT_ENHANCED_PACKET_BLOCK:
+ {
+ DPRINT_HERE(LIGHT_ENHANCED_PACKET_BLOCK);
+ struct _light_enhanced_packet_block *epb = NULL;
+ struct _light_option *opt = NULL;
+ uint32_t interface_id = *local_data++;
+ uint32_t timestamp_high = *local_data++;
+ uint32_t timestamp_low = *local_data++;
+ uint32_t captured_packet_length = *local_data++;
+ uint32_t original_packet_length = *local_data++;
+ int32_t local_offset;
+ uint32_t actual_len = 0;
+
+ PADD32(captured_packet_length, &actual_len);
+
+ epb = calloc(1, sizeof(struct _light_enhanced_packet_block) + actual_len);
+ epb->interface_id = interface_id;
+ epb->timestamp_high = timestamp_high;
+ epb->timestamp_low = timestamp_low;
+ epb->capture_packet_length = captured_packet_length;
+ epb->original_capture_length = original_packet_length;
+
+ memcpy(epb->packet_data, local_data, captured_packet_length); // Maybe actual_len?
+ local_data += actual_len / sizeof(uint32_t);
+ current->block_body = (uint32_t*)epb;
+ local_offset = (size_t)local_data - (size_t)memory;
+ opt = __parse_options((uint32_t **)&local_data, current->block_total_lenght - local_offset - sizeof(current->block_total_lenght));
+ current->options = opt;
+ }
+ break;
+
+ case LIGHT_SIMPLE_PACKET_BLOCK:
+ {
+ DPRINT_HERE(LIGHT_SIMPLE_PACKET_BLOCK);
+ struct _light_simple_packet_block *spb = NULL;
+ uint32_t original_packet_length = *local_data++;
+ uint32_t actual_len = current->block_total_lenght - 2 * sizeof(current->block_total_lenght) - sizeof(current->block_type) - sizeof(original_packet_length);
+
+ spb = calloc(1, sizeof(struct _light_enhanced_packet_block) + actual_len);
+ spb->original_packet_length = original_packet_length;
+
+ memcpy(spb->packet_data, local_data, actual_len);
+ local_data += actual_len / sizeof(uint32_t);
+ current->block_body = (uint32_t*)spb;
+ current->options = NULL; // No options defined by the standard for this block type.
+ }
+ break;
+
+ case LIGHT_CUSTOM_DATA_BLOCK:
+ {
+ DPRINT_HERE(LIGHT_CUSTOM_DATA_BLOCK);
+ struct _light_custom_nonstandard_block *cnb = NULL;
+ struct _light_option *opt = NULL;
+ uint32_t len = *local_data++;
+ uint32_t reserved0 = *local_data++;
+ uint32_t reserved1 = *local_data++;
+ int32_t local_offset;
+ uint32_t actual_len = 0;
+
+ PADD32(len, &actual_len);
+ cnb = calloc(1, sizeof(struct _light_custom_nonstandard_block) + actual_len);
+ cnb->data_length = len;
+ cnb->reserved0 = reserved0;
+ cnb->reserved1 = reserved1;
+
+ memcpy(cnb->packet_data, local_data, len); // Maybe actual_len?
+ local_data += actual_len / sizeof(uint32_t);
+ current->block_body = (uint32_t*)cnb;
+ local_offset = (size_t)local_data - (size_t)memory;
+ opt = __parse_options((uint32_t **)&local_data, current->block_total_lenght - local_offset - sizeof(current->block_total_lenght));
+ current->options = opt;
+ }
+ break;
+
+ default: // Could not find registered block type. Copying data as RAW.
+ {
+ DPRINT_HERE(default);
+ uint32_t raw_size = current->block_total_lenght - 2 * sizeof(current->block_total_lenght) - sizeof(current->block_type);
+ if (raw_size > 0) {
+ current->block_body = calloc(raw_size, 1);
+ memcpy(current->block_body, local_data, raw_size);
+ local_data += raw_size / (sizeof(*local_data));
+ }
+ else {
+ current->block_body = NULL;
+ }
+ }
+ break;
+ }
+
+ // Compute offset and return new link.
+ // Block total length.
+ DCHECK_ASSERT((bytes_read = *local_data++), current->block_total_lenght, light_stop);
+
+ bytes_read = current->block_total_lenght;
+ remaining -= bytes_read;
+ memory += bytes_read / sizeof(*memory);
+ block_count++;
+ }
+
+ return block_count;
+}
+
+light_pcapng light_read_from_memory(const uint32_t *memory, size_t size)
+{
+ struct _light_pcapng *head = NULL;
+ __parse_mem_copy(&head, memory, size);
+ return head;
+}
+
+static void __free_option(struct _light_option *option)
+{
+ if (option == NULL)
+ return;
+
+ __free_option(option->next_option);
+
+ option->next_option = NULL;
+ free(option->data);
+ free(option);
+}
+
+void light_pcapng_release(light_pcapng pcapng)
+{
+ light_pcapng iter = pcapng;
+ uint32_t block_count = light_get_block_count(pcapng);
+ light_pcapng *block_pointers = calloc(block_count, sizeof(light_pcapng));
+ uint32_t i = 0;
+
+ while (iter != NULL) {
+ block_pointers[i] = iter;
+ i++;
+ iter = iter->next_block;
+ }
+
+ for (i = 0; i < block_count; ++i) {
+ __free_option(block_pointers[i]->options);
+ free(block_pointers[i]->block_body);
+ free(block_pointers[i]);
+ }
+
+ free(block_pointers);
+}
+
+static int __option_count(struct _light_option *option)
+{
+ if (option == NULL)
+ return 0;
+
+ return 1 + __option_count(option->next_option);
+}
+
+char *light_pcapng_to_string(light_pcapng pcapng)
+{
+ if (pcapng == NULL)
+ return NULL;
+
+ light_pcapng iter = pcapng;
+ uint32_t block_count = light_get_block_count(pcapng);
+ size_t buffer_size = 128 * block_count;
+ char *string = calloc(buffer_size, sizeof(char));
+ char *offset = string;
+ DCHECK_NULLP(offset, return NULL);
+
+ while (iter != NULL) {
+ char *next = calloc(128, 1);
+
+ sprintf(next, "---\nType = 0x%X\nLength = %u\nData Pointer = %p\nOption count = %d\n---\n",
+ iter->block_type, iter->block_total_lenght, (void*)iter->block_body, __option_count(iter->options));
+
+ memcpy(offset, next, strlen(next));
+ offset += strlen(next);
+ free(next);
+ iter = iter->next_block;
+ }
+
+ return string;
+}
+
+uint32_t *light_pcapng_to_memory(const light_pcapng pcapng, size_t *size)
+{
+ light_pcapng iterator = pcapng;
+ size_t bytes = light_get_size(pcapng);
+ uint32_t *block_mem = calloc(bytes, 1);
+ uint32_t *block_offset = block_mem;
+ DCHECK_NULLP(block_offset, return NULL);
+
+ *size = 0;
+ while (iterator != NULL && bytes > 0) {
+ size_t body_length = iterator->block_total_lenght - 2 * sizeof(iterator->block_total_lenght) - sizeof(iterator->block_type);
+ size_t option_length;
+ uint32_t *option_mem = __get_option_size(iterator->options, &option_length);
+ body_length -= option_length;
+
+ block_offset[0] = iterator->block_type;
+ block_offset[1] = iterator->block_total_lenght;
+ memcpy(&block_offset[2], iterator->block_body, body_length);
+ memcpy(&block_offset[2 + body_length / 4], option_mem, option_length);
+ block_offset[iterator->block_total_lenght / 4 - 1] = iterator->block_total_lenght;
+
+ DCHECK_ASSERT(iterator->block_total_lenght, body_length + option_length + 3 * sizeof(uint32_t), light_stop);
+ block_offset += iterator->block_total_lenght / 4;
+ bytes -= iterator->block_total_lenght;
+ *size += iterator->block_total_lenght;
+
+ free(option_mem);
+ iterator = iterator->next_block;
+ }
+
+ return block_mem;
+}
+
+int light_pcapng_validate(light_pcapng p0, uint32_t *p1)
+{
+ light_pcapng iterator0 = p0;
+ uint32_t *iterator1 = p1;
+ int block_count = 0;
+
+ while (iterator0 != NULL && iterator1 != NULL) { // XXX find a better stop condition.
+ if (iterator0->block_type != iterator1[0] ||
+ iterator0->block_total_lenght != iterator1[1]) {
+ fprintf(stderr, "Block type or length mismatch at block %d!\n", block_count);
+ fprintf(stderr, "Expected type: 0x%X == 0x%X and expected length: %u == %u\n",
+ iterator0->block_type, iterator1[0], iterator0->block_total_lenght, iterator1[1]);
+ return 0;
+ }
+ size_t size = 0;
+ light_pcapng next_block = iterator0->next_block;
+ iterator0->next_block = NULL; // This might be quite intrusive.
+ uint32_t *mem = light_pcapng_to_memory(iterator0, &size);
+ if (memcmp(mem, iterator1, size) != 0) {
+ iterator0->next_block = next_block;
+ free(mem);
+ fprintf(stderr, "Block contents mismatch!\n");
+ return 0;
+ }
+
+ free(mem);
+ iterator0->next_block = next_block;
+ iterator0 = iterator0->next_block;
+
+ iterator1 += iterator1[1] / sizeof(uint32_t);
+ block_count++;
+ }
+
+ return 1;
+}
+
+uint32_t light_get_block_count(const light_pcapng pcapng)
+{
+ uint32_t count = 0;
+ light_pcapng iterator = pcapng;
+
+ while (iterator != NULL) {
+ count++;
+ iterator = iterator->next_block;
+ }
+
+ return count;
+}
+
+light_pcapng light_get_block(const light_pcapng pcapng, uint32_t index)
+{
+ light_pcapng iterator = pcapng;
+ while (iterator != NULL && index != 0) {
+ index--;
+ iterator = iterator->next_block;
+ }
+
+ return iterator;
+}
+
+light_pcapng light_next_block(const light_pcapng pcapng)
+{
+ return pcapng == NULL ? NULL : pcapng->next_block;
+}
+
+void light_pcapng_historgram(const light_pcapng pcapng, uint32_t (*key_master)(const light_pcapng),
+ light_pair **hist, size_t *size, size_t *rejected)
+{
+ light_pcapng iterator = pcapng;
+ size_t dropped = 0;
+ size_t sz = 0;
+ size_t i;
+
+ *hist = NULL;
+
+ while (iterator != NULL) {
+ uint32_t key = key_master(iterator);
+ if (key != LIGHT_KEY_REJECTED) {
+ int found = 0;
+ for (i = 0; i < sz; ++i) {
+ if ((*hist)[i].key == key) {
+ found = 1;
+ (*hist)[i].val++;
+ break;
+ }
+ }
+
+ if (found == 0) {
+ *hist = realloc(*hist, (sz + 1) * sizeof(light_pair));
+ (*hist)[sz].key = key;
+ (*hist)[sz].val = 1;
+ sz++;
+ }
+ }
+ else {
+ dropped++;
+ }
+ iterator = iterator->next_block;
+ }
+
+ *size = sz;
+
+ if (rejected != NULL)
+ *rejected = dropped;
+}
+
+size_t light_get_size(const light_pcapng pcapng)
+{
+ light_pcapng iterator = pcapng;
+ size_t size = 0;
+
+ while (iterator != NULL) {
+ size += iterator->block_total_lenght;
+ iterator = iterator->next_block;
+ }
+
+ return size;
+}
+
+int light_iterate(const light_pcapng pcapng, light_boolean (*stop_fn)(const light_pcapng, void *), void *args)
+{
+ int iterations = 0;
+ light_pcapng iterator = pcapng;
+
+ while (iterator != NULL) {
+ if (stop_fn(iterator, args) == LIGHT_FALSE) {
+ break;
+ }
+ iterations++;
+ iterator = iterator->next_block;
+ }
+
+ return iterations;
+}
+
+int light_get_block_info(const light_pcapng pcapng, light_info info_flag, void *info_data, size_t *data_size)
+{
+ if (pcapng == NULL || info_flag < 0 || info_flag > LIGHT_INFO_MAX) {
+ return LIGHT_INVALID_ARGUMENT;
+ }
+
+ switch (info_flag) {
+ case LIGHT_INFO_TYPE:
+ {
+ uint32_t *type = (uint32_t *)info_data;
+ if (type)
+ *type = pcapng->block_type;
+ if (data_size)
+ *data_size = sizeof(*type);
+ break;
+ }
+ case LIGHT_INFO_LENGTH:
+ {
+ uint32_t *length = (uint32_t *)info_data;
+ if (length)
+ *length = pcapng->block_total_lenght;
+ if (data_size)
+ *data_size = sizeof(*length);
+ break;
+ }
+ case LIGHT_INFO_BODY:
+ {
+ uint32_t **body = (uint32_t **)info_data;
+ if (body)
+ *body = pcapng->block_body;
+ if (data_size)
+ *data_size = sizeof(*body);
+ break;
+ }
+ case LIGHT_INFO_OPTIONS:
+ {
+ light_option *body = (light_option *)info_data;
+ if (body)
+ *body = pcapng->options;
+ if (data_size)
+ *data_size = sizeof(*body);
+ break;
+ }
+ default:
+ break;
+ }
+
+ return LIGHT_SUCCESS;
+}
http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/blob/c0a788b3/thirdparty/pcap++/3rdParty/LightPcapNg/LightPcapNg/src/light_pcapng_cont.c
----------------------------------------------------------------------
diff --git a/thirdparty/pcap++/3rdParty/LightPcapNg/LightPcapNg/src/light_pcapng_cont.c b/thirdparty/pcap++/3rdParty/LightPcapNg/LightPcapNg/src/light_pcapng_cont.c
new file mode 100644
index 0000000..1e741d3
--- /dev/null
+++ b/thirdparty/pcap++/3rdParty/LightPcapNg/LightPcapNg/src/light_pcapng_cont.c
@@ -0,0 +1,77 @@
+// light_pcapng_cont.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 "light_debug.h"
+#include "light_internal.h"
+
+#include <stdlib.h>
+#include <string.h>
+
+static void __parse_mem_inplace(struct _light_pcapng_mem *head, uint32_t *memory, size_t size, int is_owner)
+{
+ uint32_t tmp_block_len;
+ size_t tmp_size = size;
+ uint32_t *iterator = memory;;
+ size_t i;
+
+ head->mem = memory;
+ head->mem_size = size;
+ head->owner = is_owner;
+
+ head->block_count = 0;
+ while (tmp_size > 0) {
+ head->block_count++;
+ tmp_block_len = iterator[1];
+ tmp_size -= tmp_block_len;
+ iterator += tmp_block_len / sizeof(iterator[0]);
+ }
+
+ head->mem_blocks = calloc(head->block_count, sizeof(uint32_t *));
+ iterator = memory;
+ for (i = 0; i < head->block_count; ++i) {
+ head->mem_blocks[i] = iterator;
+ iterator += iterator[1] / sizeof(iterator[0]);
+ }
+}
+
+struct _light_pcapng_mem *light_no_copy_from_memory(uint32_t *memory, size_t size, int is_owner)
+{
+ struct _light_pcapng_mem *head = NULL;
+ head = calloc(1, sizeof(struct _light_pcapng_mem));
+ __parse_mem_inplace(head, memory, size, is_owner);
+ return head;
+}
+
+void light_pcapng_mem_release(struct _light_pcapng_mem *pcapng)
+{
+ if (pcapng != NULL) {
+ free(pcapng->mem_blocks);
+
+ if (pcapng->owner != 0)
+ free(pcapng->mem);
+
+ free(pcapng);
+ }
+}