Update Stellar export header and add stellar_get_current_thread_index() function
This commit is contained in:
@@ -1,12 +1,12 @@
|
|||||||
#ifndef _PACKET_H
|
#ifndef _PACKET_PUB_H
|
||||||
#define _PACKET_H
|
#define _PACKET_PUB_H
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C"
|
extern "C"
|
||||||
{
|
{
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "tuple.h"
|
#include "stellar/tuple.h"
|
||||||
|
|
||||||
enum layer_type
|
enum layer_type
|
||||||
{
|
{
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
#ifndef _SESSION_H
|
#ifndef _SESSION_PUB_H
|
||||||
#define _SESSION_H
|
#define _SESSION_PUB_H
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C"
|
extern "C"
|
||||||
@@ -8,7 +8,7 @@ extern "C"
|
|||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
#include "packet.h"
|
#include "stellar/packet.h"
|
||||||
|
|
||||||
enum session_state
|
enum session_state
|
||||||
{
|
{
|
||||||
17
include/stellar/stellar.h
Normal file
17
include/stellar/stellar.h
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
#ifndef _STELLAR_PUB_H
|
||||||
|
#define _STELLAR_PUB_H
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C"
|
||||||
|
{
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
uint8_t stellar_get_current_thread_index();
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
#ifndef _TUPLE_H
|
#ifndef _TUPLE_PUB_H
|
||||||
#define _TUPLE_H
|
#define _TUPLE_PUB_H
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C"
|
extern "C"
|
||||||
@@ -4,6 +4,7 @@ add_subdirectory(timestamp)
|
|||||||
add_subdirectory(tuple)
|
add_subdirectory(tuple)
|
||||||
add_subdirectory(packet)
|
add_subdirectory(packet)
|
||||||
add_subdirectory(packet_io)
|
add_subdirectory(packet_io)
|
||||||
|
add_subdirectory(thread_idx)
|
||||||
add_subdirectory(id_generator)
|
add_subdirectory(id_generator)
|
||||||
add_subdirectory(ip_reassembly)
|
add_subdirectory(ip_reassembly)
|
||||||
add_subdirectory(tcp_reassembly)
|
add_subdirectory(tcp_reassembly)
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ extern "C"
|
|||||||
// Duplicated Packet Filter for IPv4 Packet
|
// Duplicated Packet Filter for IPv4 Packet
|
||||||
|
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
#include "packet.h"
|
#include "packet_priv.h"
|
||||||
|
|
||||||
#define DUPLICATED_PACKET_FILTER_LOG_ERROR(format, ...) LOG_ERROR("duplicated packet filter", format, ##__VA_ARGS__)
|
#define DUPLICATED_PACKET_FILTER_LOG_ERROR(format, ...) LOG_ERROR("duplicated packet filter", format, ##__VA_ARGS__)
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#include <gtest/gtest.h>
|
#include <gtest/gtest.h>
|
||||||
|
|
||||||
#include "duplicated_packet_filter.h"
|
#include "duplicated_packet_filter.h"
|
||||||
#include "packet_private.h"
|
#include "packet_priv.h"
|
||||||
|
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
* [Protocols in frame: eth:ethertype:ip:ipv6:tcp]
|
* [Protocols in frame: eth:ethertype:ip:ipv6:tcp]
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ extern "C"
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
#include "tuple.h"
|
#include "stellar/tuple.h"
|
||||||
|
|
||||||
#define EVICTED_SESSION_FILTER_LOG_ERROR(format, ...) LOG_ERROR("evicted session filter", format, ##__VA_ARGS__)
|
#define EVICTED_SESSION_FILTER_LOG_ERROR(format, ...) LOG_ERROR("evicted session filter", format, ##__VA_ARGS__)
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
add_library(id_generator id_generator.cpp)
|
add_library(id_generator id_generator.cpp)
|
||||||
target_include_directories(id_generator PUBLIC ${CMAKE_CURRENT_LIST_DIR})
|
target_include_directories(id_generator PUBLIC ${CMAKE_CURRENT_LIST_DIR})
|
||||||
target_include_directories(id_generator PUBLIC ${CMAKE_SOURCE_DIR}/src/stellar)
|
target_include_directories(id_generator PUBLIC ${CMAKE_SOURCE_DIR}/src/stellar)
|
||||||
target_link_libraries(id_generator log)
|
target_link_libraries(id_generator log thread_idx)
|
||||||
@@ -1,8 +1,9 @@
|
|||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
#include "macro.h"
|
||||||
|
#include "thread_idx.h"
|
||||||
#include "id_generator.h"
|
#include "id_generator.h"
|
||||||
#include "stellar.h"
|
|
||||||
|
|
||||||
struct id_generator
|
struct id_generator
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
#include <sys/queue.h>
|
#include <sys/queue.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
||||||
#include "packet_private.h"
|
#include "packet_priv.h"
|
||||||
#include "crc32_hash.h"
|
#include "crc32_hash.h"
|
||||||
#include "checksum.h"
|
#include "checksum.h"
|
||||||
#include "ipv4_utils.h"
|
#include "ipv4_utils.h"
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ extern "C"
|
|||||||
{
|
{
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "packet.h"
|
#include "packet_priv.h"
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
|
|
||||||
#define IP_REASSEMBLE_DEBUG(format, ...) LOG_DEBUG("ip_reassembly", format, ##__VA_ARGS__)
|
#define IP_REASSEMBLE_DEBUG(format, ...) LOG_DEBUG("ip_reassembly", format, ##__VA_ARGS__)
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ extern "C"
|
|||||||
#include "ipv4_utils.h"
|
#include "ipv4_utils.h"
|
||||||
#include "ipv6_utils.h"
|
#include "ipv6_utils.h"
|
||||||
#include "ip_reassembly.h"
|
#include "ip_reassembly.h"
|
||||||
#include "packet_private.h"
|
#include "packet_priv.h"
|
||||||
|
|
||||||
static inline void packet_set_ipv4_src_addr(struct packet *pkt, uint32_t saddr)
|
static inline void packet_set_ipv4_src_addr(struct packet *pkt, uint32_t saddr)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -11,7 +11,7 @@
|
|||||||
#include <linux/ppp_defs.h>
|
#include <linux/ppp_defs.h>
|
||||||
|
|
||||||
#include "uthash.h"
|
#include "uthash.h"
|
||||||
#include "packet_private.h"
|
#include "packet_priv.h"
|
||||||
#include "udp_utils.h"
|
#include "udp_utils.h"
|
||||||
#include "tcp_utils.h"
|
#include "tcp_utils.h"
|
||||||
#include "ipv4_utils.h"
|
#include "ipv4_utils.h"
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
#ifndef _PACKET_PRIVATE_H
|
#ifndef _PACKET_PRIV_H
|
||||||
#define _PACKET_PRIVATE_H
|
#define _PACKET_PRIV_H
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C"
|
extern "C"
|
||||||
@@ -10,8 +10,8 @@ extern "C"
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
#include "tuple.h"
|
#include "stellar/tuple.h"
|
||||||
#include "packet.h"
|
#include "stellar/packet.h"
|
||||||
|
|
||||||
#define PACKET_MAX_LAYERS 32
|
#define PACKET_MAX_LAYERS 32
|
||||||
#define PACKET_LOG_ERROR(format, ...) LOG_ERROR("packet", format, ##__VA_ARGS__)
|
#define PACKET_LOG_ERROR(format, ...) LOG_ERROR("packet", format, ##__VA_ARGS__)
|
||||||
@@ -2,7 +2,7 @@
|
|||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include "packet_private.h"
|
#include "packet_priv.h"
|
||||||
#include "marsio.h"
|
#include "marsio.h"
|
||||||
|
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#include <gtest/gtest.h>
|
#include <gtest/gtest.h>
|
||||||
#include <arpa/inet.h>
|
#include <arpa/inet.h>
|
||||||
|
|
||||||
#include "packet_private.h"
|
#include "packet_priv.h"
|
||||||
|
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
* Pcap file: 1-ETH_VLAN_VLAN_IP4_IP4_UDP.pcap
|
* Pcap file: 1-ETH_VLAN_VLAN_IP4_IP4_UDP.pcap
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
#include <gtest/gtest.h>
|
#include <gtest/gtest.h>
|
||||||
|
|
||||||
#include "packet_private.h"
|
#include "packet_priv.h"
|
||||||
|
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
* [Protocols in frame: eth:ethertype:ip:data]
|
* [Protocols in frame: eth:ethertype:ip:data]
|
||||||
|
|||||||
@@ -5,9 +5,9 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
||||||
#include "stellar.h"
|
#include "macro.h"
|
||||||
|
#include "packet_priv.h"
|
||||||
#include "file_scan.h"
|
#include "file_scan.h"
|
||||||
#include "packet_private.h"
|
|
||||||
#include "lock_free_queue.h"
|
#include "lock_free_queue.h"
|
||||||
#include "dumpfile_io.h"
|
#include "dumpfile_io.h"
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,9 @@
|
|||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
#include "stellar.h"
|
#include "macro.h"
|
||||||
#include "lock_free_queue.h"
|
#include "lock_free_queue.h"
|
||||||
|
|
||||||
struct lock_free_queue
|
struct lock_free_queue
|
||||||
|
|||||||
@@ -4,9 +4,9 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <netinet/ether.h>
|
#include <netinet/ether.h>
|
||||||
|
|
||||||
#include "stellar.h"
|
#include "macro.h"
|
||||||
#include "marsio.h"
|
#include "marsio.h"
|
||||||
#include "packet_private.h"
|
#include "packet_priv.h"
|
||||||
#include "marsio_io.h"
|
#include "marsio_io.h"
|
||||||
|
|
||||||
struct marsio_io
|
struct marsio_io
|
||||||
|
|||||||
@@ -7,8 +7,8 @@ extern "C"
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
#include "packet.h"
|
#include "macro.h"
|
||||||
#include "stellar.h"
|
#include "packet_priv.h"
|
||||||
|
|
||||||
#define PACKET_IO_LOG_STATE(format, ...) LOG_STATE("packet_io", format, ##__VA_ARGS__)
|
#define PACKET_IO_LOG_STATE(format, ...) LOG_STATE("packet_io", format, ##__VA_ARGS__)
|
||||||
#define PACKET_IO_LOG_ERROR(format, ...) LOG_ERROR("packet_io", format, ##__VA_ARGS__)
|
#define PACKET_IO_LOG_ERROR(format, ...) LOG_ERROR("packet_io", format, ##__VA_ARGS__)
|
||||||
|
|||||||
@@ -1,3 +1,3 @@
|
|||||||
add_library(plugin_manager plugin_manager.cpp)
|
add_library(plugin_manager plugin_manager.cpp)
|
||||||
target_include_directories(plugin_manager PUBLIC ${CMAKE_CURRENT_LIST_DIR})
|
target_include_directories(plugin_manager PUBLIC ${CMAKE_CURRENT_LIST_DIR})
|
||||||
target_link_libraries(plugin_manager session_manager)
|
target_link_libraries(plugin_manager session_manager thread_idx)
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include "plugin_manager.h"
|
#include "plugin_manager.h"
|
||||||
#include "session_private.h"
|
#include "session_priv.h"
|
||||||
|
#include "thread_idx.h"
|
||||||
|
|
||||||
struct plugin_manager
|
struct plugin_manager
|
||||||
{
|
{
|
||||||
@@ -42,7 +43,7 @@ void plugin_manager_dispatch_session(struct plugin_manager *mgr, struct session
|
|||||||
struct tcp_segment *seg;
|
struct tcp_segment *seg;
|
||||||
enum session_state state = session_get_state(sess);
|
enum session_state state = session_get_state(sess);
|
||||||
enum session_type type = session_get_type(sess);
|
enum session_type type = session_get_type(sess);
|
||||||
PLUGIN_MANAGER_LOG_DEBUG("=> plugin dispatch session: %u %s %s %s", session_get_id(sess), session_get_tuple_str(sess), session_type_to_str(type), session_state_to_str(state));
|
PLUGIN_MANAGER_LOG_DEBUG("=> thread [%d] plugin dispatch session: %u %s %s %s", stellar_get_current_thread_index(), session_get_id(sess), session_get_tuple_str(sess), session_type_to_str(type), session_state_to_str(state));
|
||||||
// session_print(sess);
|
// session_print(sess);
|
||||||
|
|
||||||
if (packet_is_ctrl(pkt))
|
if (packet_is_ctrl(pkt))
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ extern "C"
|
|||||||
{
|
{
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "session.h"
|
#include "session_priv.h"
|
||||||
|
|
||||||
#define PLUGIN_MANAGER_LOG_ERROR(format, ...) LOG_ERROR("plugin manager", format, ##__VA_ARGS__)
|
#define PLUGIN_MANAGER_LOG_ERROR(format, ...) LOG_ERROR("plugin manager", format, ##__VA_ARGS__)
|
||||||
#define PLUGIN_MANAGER_LOG_DEBUG(format, ...) LOG_DEBUG("plugin manager", format, ##__VA_ARGS__)
|
#define PLUGIN_MANAGER_LOG_DEBUG(format, ...) LOG_DEBUG("plugin manager", format, ##__VA_ARGS__)
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
||||||
#include "session_private.h"
|
#include "session_priv.h"
|
||||||
#include "tcp_utils.h"
|
#include "tcp_utils.h"
|
||||||
#include "tcp_reassembly.h"
|
#include "tcp_reassembly.h"
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
||||||
#include "stellar.h"
|
#include "macro.h"
|
||||||
#include "tcp_utils.h"
|
#include "tcp_utils.h"
|
||||||
#include "udp_utils.h"
|
#include "udp_utils.h"
|
||||||
#include "id_generator.h"
|
#include "id_generator.h"
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ extern "C"
|
|||||||
{
|
{
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "session_private.h"
|
#include "session_priv.h"
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
|
|
||||||
#define SESSION_LOG_ERROR(format, ...) LOG_ERROR("session", format, ##__VA_ARGS__)
|
#define SESSION_LOG_ERROR(format, ...) LOG_ERROR("session", format, ##__VA_ARGS__)
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ extern "C"
|
|||||||
{
|
{
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "session_private.h"
|
#include "session_priv.h"
|
||||||
|
|
||||||
struct session_pool;
|
struct session_pool;
|
||||||
struct session_pool *session_pool_new(uint64_t count);
|
struct session_pool *session_pool_new(uint64_t count);
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
#ifndef _SESSION_PRIVATE_H
|
#ifndef _SESSION_PRIV_H
|
||||||
#define _SESSION_PRIVATE_H
|
#define _SESSION_PRIV_H
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C"
|
extern "C"
|
||||||
@@ -7,11 +7,11 @@ extern "C"
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "list.h"
|
#include "list.h"
|
||||||
#include "tuple.h"
|
#include "packet_priv.h"
|
||||||
#include "packet_private.h"
|
|
||||||
#include "timeout.h"
|
#include "timeout.h"
|
||||||
#include "uthash.h"
|
#include "uthash.h"
|
||||||
#include "session.h"
|
#include "stellar/tuple.h"
|
||||||
|
#include "stellar/session.h"
|
||||||
#include "tcp_reassembly.h"
|
#include "tcp_reassembly.h"
|
||||||
#include "session_manager.h"
|
#include "session_manager.h"
|
||||||
|
|
||||||
@@ -6,7 +6,7 @@ extern "C"
|
|||||||
{
|
{
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "session_private.h"
|
#include "session_priv.h"
|
||||||
|
|
||||||
struct session_table;
|
struct session_table;
|
||||||
struct session_table *session_table_new();
|
struct session_table *session_table_new();
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ extern "C"
|
|||||||
{
|
{
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "session_private.h"
|
#include "session_priv.h"
|
||||||
|
|
||||||
struct session_timer;
|
struct session_timer;
|
||||||
struct session_timer *session_timer_new(uint64_t now);
|
struct session_timer *session_timer_new(uint64_t now);
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ extern "C"
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
#include "session_private.h"
|
#include "session_priv.h"
|
||||||
|
|
||||||
#define SESSION_TRANSITION_LOG_INFO(format, ...) LOG_INFO("session transition", format, ##__VA_ARGS__)
|
#define SESSION_TRANSITION_LOG_INFO(format, ...) LOG_INFO("session transition", format, ##__VA_ARGS__)
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
#include <gtest/gtest.h>
|
#include <gtest/gtest.h>
|
||||||
|
|
||||||
#include "session_private.h"
|
#include "session_priv.h"
|
||||||
#include "session_manager.h"
|
#include "session_manager.h"
|
||||||
|
|
||||||
#include "ipv4_utils.h"
|
#include "ipv4_utils.h"
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
#include <gtest/gtest.h>
|
#include <gtest/gtest.h>
|
||||||
|
|
||||||
#include "session_private.h"
|
#include "session_priv.h"
|
||||||
#include "session_manager.h"
|
#include "session_manager.h"
|
||||||
|
|
||||||
#include "stellar.h"
|
#include "macro.h"
|
||||||
#include "ipv4_utils.h"
|
#include "ipv4_utils.h"
|
||||||
#include "test_packets.h"
|
#include "test_packets.h"
|
||||||
|
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
#include <gtest/gtest.h>
|
#include <gtest/gtest.h>
|
||||||
|
|
||||||
#include "session_private.h"
|
#include "session_priv.h"
|
||||||
#include "session_manager.h"
|
#include "session_manager.h"
|
||||||
|
|
||||||
#include "stellar.h"
|
#include "macro.h"
|
||||||
#include "ipv4_utils.h"
|
#include "ipv4_utils.h"
|
||||||
#include "test_packets.h"
|
#include "test_packets.h"
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
#include <gtest/gtest.h>
|
#include <gtest/gtest.h>
|
||||||
|
|
||||||
#include "session_private.h"
|
#include "session_priv.h"
|
||||||
#include "session_manager.h"
|
#include "session_manager.h"
|
||||||
|
|
||||||
#include "ipv4_utils.h"
|
#include "ipv4_utils.h"
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
#include <gtest/gtest.h>
|
#include <gtest/gtest.h>
|
||||||
|
|
||||||
#include "session_private.h"
|
#include "session_priv.h"
|
||||||
|
|
||||||
#define SESSION_KEY_IPV4_TCP(name) \
|
#define SESSION_KEY_IPV4_TCP(name) \
|
||||||
struct tuple6 name; \
|
struct tuple6 name; \
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
// TCP state machine test: active -> closing
|
// TCP state machine test: active -> closing
|
||||||
#include <gtest/gtest.h>
|
#include <gtest/gtest.h>
|
||||||
|
|
||||||
#include "session_private.h"
|
#include "session_priv.h"
|
||||||
#include "session_manager.h"
|
#include "session_manager.h"
|
||||||
|
|
||||||
#include "tcp_utils.h"
|
#include "tcp_utils.h"
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
// TCP state machine test: init -> opening
|
// TCP state machine test: init -> opening
|
||||||
#include <gtest/gtest.h>
|
#include <gtest/gtest.h>
|
||||||
|
|
||||||
#include "session_private.h"
|
#include "session_priv.h"
|
||||||
#include "session_manager.h"
|
#include "session_manager.h"
|
||||||
|
|
||||||
#include "ipv4_utils.h"
|
#include "ipv4_utils.h"
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
// TCP state machine test: init -> opening -> active -> closing -> closed
|
// TCP state machine test: init -> opening -> active -> closing -> closed
|
||||||
#include <gtest/gtest.h>
|
#include <gtest/gtest.h>
|
||||||
|
|
||||||
#include "session_private.h"
|
#include "session_priv.h"
|
||||||
#include "session_manager.h"
|
#include "session_manager.h"
|
||||||
|
|
||||||
#include "test_packets.h"
|
#include "test_packets.h"
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
// TCP state machine test: opening -> active
|
// TCP state machine test: opening -> active
|
||||||
#include <gtest/gtest.h>
|
#include <gtest/gtest.h>
|
||||||
|
|
||||||
#include "session_private.h"
|
#include "session_priv.h"
|
||||||
#include "session_manager.h"
|
#include "session_manager.h"
|
||||||
|
|
||||||
#include "test_packets.h"
|
#include "test_packets.h"
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
// TCP state machine test: opening -> closing
|
// TCP state machine test: opening -> closing
|
||||||
#include <gtest/gtest.h>
|
#include <gtest/gtest.h>
|
||||||
|
|
||||||
#include "session_private.h"
|
#include "session_priv.h"
|
||||||
#include "session_manager.h"
|
#include "session_manager.h"
|
||||||
|
|
||||||
#include "tcp_utils.h"
|
#include "tcp_utils.h"
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
// UDP state machine test: init -> opening -> active -> closing
|
// UDP state machine test: init -> opening -> active -> closing
|
||||||
#include <gtest/gtest.h>
|
#include <gtest/gtest.h>
|
||||||
|
|
||||||
#include "session_private.h"
|
#include "session_priv.h"
|
||||||
#include "session_manager.h"
|
#include "session_manager.h"
|
||||||
|
|
||||||
#include "test_packets.h"
|
#include "test_packets.h"
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
// UDP state machine test: init -> opening -> closing
|
// UDP state machine test: init -> opening -> closing
|
||||||
#include <gtest/gtest.h>
|
#include <gtest/gtest.h>
|
||||||
|
|
||||||
#include "session_private.h"
|
#include "session_priv.h"
|
||||||
#include "session_manager.h"
|
#include "session_manager.h"
|
||||||
|
|
||||||
#include "test_packets.h"
|
#include "test_packets.h"
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
#include <gtest/gtest.h>
|
#include <gtest/gtest.h>
|
||||||
|
|
||||||
#include "session_private.h"
|
#include "session_priv.h"
|
||||||
#include "session_manager.h"
|
#include "session_manager.h"
|
||||||
|
|
||||||
#include "test_packets.h"
|
#include "test_packets.h"
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
#include <gtest/gtest.h>
|
#include <gtest/gtest.h>
|
||||||
|
|
||||||
#include "session_private.h"
|
#include "session_priv.h"
|
||||||
#include "session_manager.h"
|
#include "session_manager.h"
|
||||||
|
|
||||||
#include "ipv4_utils.h"
|
#include "ipv4_utils.h"
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
#include <gtest/gtest.h>
|
#include <gtest/gtest.h>
|
||||||
|
|
||||||
#include "session_private.h"
|
#include "session_priv.h"
|
||||||
#include "session_manager.h"
|
#include "session_manager.h"
|
||||||
|
|
||||||
#include "ipv4_utils.h"
|
#include "ipv4_utils.h"
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
#include <gtest/gtest.h>
|
#include <gtest/gtest.h>
|
||||||
|
|
||||||
#include "session_private.h"
|
#include "session_priv.h"
|
||||||
#include "session_manager.h"
|
#include "session_manager.h"
|
||||||
|
|
||||||
#include "test_packets.h"
|
#include "test_packets.h"
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
add_executable(stellar config.cpp stat.cpp stellar.cpp)
|
add_executable(stellar config.cpp stat.cpp stellar.cpp)
|
||||||
target_link_libraries(stellar timestamp plugin_manager session_manager ip_reassembly packet_io)
|
target_link_libraries(stellar timestamp plugin_manager session_manager ip_reassembly packet_io thread_idx)
|
||||||
target_link_libraries(stellar pthread fieldstat4 toml)
|
target_link_libraries(stellar pthread fieldstat4 toml)
|
||||||
|
|
||||||
install(TARGETS stellar RUNTIME DESTINATION bin COMPONENT Program)
|
install(TARGETS stellar RUNTIME DESTINATION bin COMPONENT Program)
|
||||||
@@ -1,15 +1,13 @@
|
|||||||
#ifndef _STELLAR_H
|
#ifndef _MACRO_H
|
||||||
#define _STELLAR_H
|
#define _MACRO_H
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C"
|
extern "C"
|
||||||
{
|
{
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <stdint.h>
|
|
||||||
|
|
||||||
#define MAX_THREAD_NUM 256
|
|
||||||
#define RX_BURST_MAX 32
|
#define RX_BURST_MAX 32
|
||||||
|
#define MAX_THREAD_NUM 256 // limit by id_generator
|
||||||
|
|
||||||
#define ATOMIC_INC(x) __atomic_fetch_add(x, 1, __ATOMIC_RELAXED)
|
#define ATOMIC_INC(x) __atomic_fetch_add(x, 1, __ATOMIC_RELAXED)
|
||||||
#define ATOMIC_DEC(x) __atomic_fetch_sub(x, 1, __ATOMIC_RELAXED)
|
#define ATOMIC_DEC(x) __atomic_fetch_sub(x, 1, __ATOMIC_RELAXED)
|
||||||
@@ -23,16 +21,11 @@ extern "C"
|
|||||||
#define unlikely(expr) __builtin_expect((expr), 0)
|
#define unlikely(expr) __builtin_expect((expr), 0)
|
||||||
|
|
||||||
#ifdef STELLAR_GIT_VERSION
|
#ifdef STELLAR_GIT_VERSION
|
||||||
static __attribute__((__used__)) const char *__stellar_version = STELLAR_GIT_VERSION;
|
static __attribute__((__used__)) const char *__stellar_version = STELLAR_GIT_VERSION;
|
||||||
#else
|
#else
|
||||||
static __attribute__((__used__)) const char *__stellar_version = "Unknown";
|
static __attribute__((__used__)) const char *__stellar_version = "Unknown";
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static inline uint8_t stellar_get_current_thread_index()
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@@ -10,11 +10,11 @@
|
|||||||
|
|
||||||
#include "logo.h"
|
#include "logo.h"
|
||||||
#include "stat.h"
|
#include "stat.h"
|
||||||
#include "stellar.h"
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "packet_private.h"
|
#include "packet_priv.h"
|
||||||
#include "packet_io.h"
|
#include "packet_io.h"
|
||||||
#include "timestamp.h"
|
#include "timestamp.h"
|
||||||
|
#include "thread_idx.h"
|
||||||
#include "id_generator.h"
|
#include "id_generator.h"
|
||||||
#include "ip_reassembly.h"
|
#include "ip_reassembly.h"
|
||||||
#include "session_manager.h"
|
#include "session_manager.h"
|
||||||
@@ -159,7 +159,6 @@ static void *work_thread(void *arg)
|
|||||||
{
|
{
|
||||||
int nr_recv;
|
int nr_recv;
|
||||||
uint64_t now = 0;
|
uint64_t now = 0;
|
||||||
uint16_t thr_idx = 0;
|
|
||||||
char thd_name[16] = {0};
|
char thd_name[16] = {0};
|
||||||
void *plugin_ctx = NULL;
|
void *plugin_ctx = NULL;
|
||||||
struct packet *pkt = NULL;
|
struct packet *pkt = NULL;
|
||||||
@@ -170,7 +169,8 @@ static void *work_thread(void *arg)
|
|||||||
struct stellar_thread *thread = (struct stellar_thread *)arg;
|
struct stellar_thread *thread = (struct stellar_thread *)arg;
|
||||||
struct ip_reassembly *ip_reass = thread->ip_mgr;
|
struct ip_reassembly *ip_reass = thread->ip_mgr;
|
||||||
struct session_manager *sess_mgr = thread->sess_mgr;
|
struct session_manager *sess_mgr = thread->sess_mgr;
|
||||||
thr_idx = thread->idx;
|
uint16_t thr_idx = thread->idx;
|
||||||
|
stellar_set_current_thread_index(thr_idx);
|
||||||
|
|
||||||
snprintf(thd_name, sizeof(thd_name), "stellar:%d", thr_idx);
|
snprintf(thd_name, sizeof(thd_name), "stellar:%d", thr_idx);
|
||||||
prctl(PR_SET_NAME, (unsigned long long)thd_name, NULL, NULL, NULL);
|
prctl(PR_SET_NAME, (unsigned long long)thd_name, NULL, NULL, NULL);
|
||||||
|
|||||||
4
src/thread_idx/CMakeLists.txt
Normal file
4
src/thread_idx/CMakeLists.txt
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
add_library(thread_idx thread_idx.cpp)
|
||||||
|
target_include_directories(thread_idx PUBLIC ${CMAKE_CURRENT_LIST_DIR})
|
||||||
|
target_include_directories(thread_idx PUBLIC ${CMAKE_SOURCE_DIR}/include)
|
||||||
|
target_link_libraries(thread_idx)
|
||||||
13
src/thread_idx/thread_idx.cpp
Normal file
13
src/thread_idx/thread_idx.cpp
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
#include "thread_idx.h"
|
||||||
|
|
||||||
|
static thread_local uint8_t __thread_id = 0;
|
||||||
|
|
||||||
|
uint8_t stellar_get_current_thread_index()
|
||||||
|
{
|
||||||
|
return __thread_id;
|
||||||
|
}
|
||||||
|
|
||||||
|
void stellar_set_current_thread_index(uint8_t idx)
|
||||||
|
{
|
||||||
|
__thread_id = idx;
|
||||||
|
}
|
||||||
17
src/thread_idx/thread_idx.h
Normal file
17
src/thread_idx/thread_idx.h
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
#ifndef _THREAD_IDX_H
|
||||||
|
#define _THREAD_IDX_H
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C"
|
||||||
|
{
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "stellar/stellar.h"
|
||||||
|
|
||||||
|
void stellar_set_current_thread_index(uint8_t idx);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
add_library(timestamp timestamp.cpp)
|
add_library(timestamp timestamp.cpp)
|
||||||
target_include_directories(timestamp PUBLIC ${CMAKE_CURRENT_LIST_DIR})
|
target_include_directories(timestamp PUBLIC ${CMAKE_CURRENT_LIST_DIR})
|
||||||
|
target_include_directories(timestamp PUBLIC ${CMAKE_SOURCE_DIR}/src/stellar)
|
||||||
target_link_libraries(timestamp)
|
target_link_libraries(timestamp)
|
||||||
|
|
||||||
add_subdirectory(test)
|
add_subdirectory(test)
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
|
||||||
|
#include "macro.h"
|
||||||
#include "timestamp.h"
|
#include "timestamp.h"
|
||||||
|
|
||||||
// 1 s = 1000 ms
|
// 1 s = 1000 ms
|
||||||
@@ -23,9 +24,6 @@ struct timestamp
|
|||||||
uint64_t ts_in_sec;
|
uint64_t ts_in_sec;
|
||||||
} g_timestamp;
|
} g_timestamp;
|
||||||
|
|
||||||
#define ATOMIC_SET(x, y) __atomic_store_n(x, y, __ATOMIC_RELAXED)
|
|
||||||
#define ATOMIC_READ(x) __atomic_load_n(x, __ATOMIC_RELAXED)
|
|
||||||
|
|
||||||
void timestamp_update()
|
void timestamp_update()
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
#include <gtest/gtest.h>
|
#include <gtest/gtest.h>
|
||||||
|
|
||||||
#include "tuple.h"
|
#include "stellar/tuple.h"
|
||||||
|
|
||||||
TEST(TUPLE, TUPLE2)
|
TEST(TUPLE, TUPLE2)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
#include "tuple.h"
|
#include "stellar/tuple.h"
|
||||||
#include "crc32_hash.h"
|
#include "crc32_hash.h"
|
||||||
|
|
||||||
uint32_t tuple2_hash(const struct tuple2 *tuple)
|
uint32_t tuple2_hash(const struct tuple2 *tuple)
|
||||||
|
|||||||
Reference in New Issue
Block a user