Functions | |
void | handle_error_status (int status, const char *message) |
void | ntpl_multicall (const std::vector< std::string > &ntpls) |
uint64_t | flow_hash (const NtFlow_t *flow) |
void | rx_task (std::atomic< int > *ready, std::atomic< bool > *end_task, uint32_t stream_id, std::function< void(const NtNetBuf_t &)> handle) |
void | flow_program_task (std::atomic< int > *ready, std::atomic< bool > *end_task) |
void | handle_stream_unhandled (const NtNetBuf_t &) |
void | handle_stream_miss (const NtNetBuf_t &net_buffer) |
void | handle_stream_blacklist_hit (const NtNetBuf_t &) |
void | handle_stream_whitelist_hit (const NtNetBuf_t &) |
Variables | |
uint64_t | counter_unhandled = 0 |
uint64_t | counter_miss = 0 |
uint64_t | counter_blacklist_hit = 0 |
uint64_t | counter_whitelist_hit = 0 |
NtFlowStream_t | flow_stream |
std::unordered_multimap< uint64_t, std::unique_ptr< NtFlow_t > > | flow_map |
std::atomic< uint64_t > | flow_learn_queue_read_index {0} |
std::atomic< uint64_t > | flow_learn_queue_write_index {0} |
std::array< NtFlow_t *, 0x100000 > | flow_learn_queue |
constexpr uint64_t | flow_learn_queue_index_mask = 0xfffff |
Function Documentation
void anonymous_namespace{flow_learn_span_example.cpp}::handle_error_status | ( | int | status, |
const char * | message | ||
) |
Handle errors by printing an error and exit the application.
- Examples:
- flow/flow_learn_span/flow_learn_span_example.cpp, net/checksum/checksum_example.cpp, and net/transmit_segment_dyn_descr/transmit_segment_dyn_descr_example.cpp.
Definition at line 109 of file flow_learn_span_example.cpp.
Referenced by flow_program_task(), main(), ntpl_multicall(), and rx_task().
void anonymous_namespace{flow_learn_span_example.cpp}::ntpl_multicall | ( | const std::vector< std::string > & | ntpls | ) |
Opens a config stream and programs the input NTPL. When the NTPL has been programmed, the config stream is closed again.
Definition at line 123 of file flow_learn_span_example.cpp.
Referenced by main().
uint64_t anonymous_namespace{flow_learn_span_example.cpp}::flow_hash | ( | const NtFlow_t * | flow | ) |
Quick and dirty hashing function for some fields in NtFlow_t. The hash uniqueness in this function is not great, but since std::unordered_multimap is used to store the flows, the application is able to handle duplicate hashes.
Definition at line 146 of file flow_learn_span_example.cpp.
Referenced by handle_stream_miss().
void anonymous_namespace{flow_learn_span_example.cpp}::rx_task | ( | std::atomic< int > * | ready, |
std::atomic< bool > * | end_task, | ||
uint32_t | stream_id, | ||
std::function< void(const NtNetBuf_t &)> | handle | ||
) |
Opens a RX stream and received packets until an end-task signal is received.
Definition at line 167 of file flow_learn_span_example.cpp.
Referenced by main().
void anonymous_namespace{flow_learn_span_example.cpp}::flow_program_task | ( | std::atomic< int > * | ready, |
std::atomic< bool > * | end_task | ||
) |
Separate task to program flows
Definition at line 223 of file flow_learn_span_example.cpp.
Referenced by main().
void anonymous_namespace{flow_learn_span_example.cpp}::handle_stream_unhandled | ( | const NtNetBuf_t & | ) |
Handle used for the unhandled packets RX thread.
In this example, unhandled packets are only counted.
Definition at line 251 of file flow_learn_span_example.cpp.
Referenced by main().
void anonymous_namespace{flow_learn_span_example.cpp}::handle_stream_miss | ( | const NtNetBuf_t & | net_buffer | ) |
Handle used for the missed packets RX thread.
Whenever a missed packet is received, the function calculates the flow learn data, and checks if it is a new flow, or a previously known flow. If the flow is new, then the flow is programmed.
Definition at line 263 of file flow_learn_span_example.cpp.
Referenced by main().
void anonymous_namespace{flow_learn_span_example.cpp}::handle_stream_blacklist_hit | ( | const NtNetBuf_t & | ) |
Handle used for the blacklist packets RX thread.
In this example, packets that hit a programmed flow are only counted.
Definition at line 343 of file flow_learn_span_example.cpp.
Referenced by main().
void anonymous_namespace{flow_learn_span_example.cpp}::handle_stream_whitelist_hit | ( | const NtNetBuf_t & | ) |
Handle used for the whitelist packets RX thread.
In this example, packets that hit a programmed flow are only counted.
Definition at line 353 of file flow_learn_span_example.cpp.
Referenced by main().
Variable Documentation
uint64_t anonymous_namespace{flow_learn_span_example.cpp}::counter_unhandled = 0 |
Definition at line 203 of file flow_learn_span_example.cpp.
Referenced by main().
uint64_t anonymous_namespace{flow_learn_span_example.cpp}::counter_miss = 0 |
Definition at line 204 of file flow_learn_span_example.cpp.
Referenced by main().
uint64_t anonymous_namespace{flow_learn_span_example.cpp}::counter_blacklist_hit = 0 |
Definition at line 205 of file flow_learn_span_example.cpp.
Referenced by main().
uint64_t anonymous_namespace{flow_learn_span_example.cpp}::counter_whitelist_hit = 0 |
Definition at line 206 of file flow_learn_span_example.cpp.
Referenced by main().
NtFlowStream_t anonymous_namespace{flow_learn_span_example.cpp}::flow_stream |
Definition at line 208 of file flow_learn_span_example.cpp.
Referenced by main().
std::unordered_multimap<uint64_t, std::unique_ptr<NtFlow_t> > anonymous_namespace{flow_learn_span_example.cpp}::flow_map |
Definition at line 209 of file flow_learn_span_example.cpp.
Referenced by main().
std::atomic<uint64_t> anonymous_namespace{flow_learn_span_example.cpp}::flow_learn_queue_read_index {0} |
Definition at line 211 of file flow_learn_span_example.cpp.
Referenced by flow_program_task().
std::atomic<uint64_t> anonymous_namespace{flow_learn_span_example.cpp}::flow_learn_queue_write_index {0} |
Definition at line 212 of file flow_learn_span_example.cpp.
Referenced by flow_program_task(), and handle_stream_miss().
std::array<NtFlow_t*, 0x100000> anonymous_namespace{flow_learn_span_example.cpp}::flow_learn_queue |
Definition at line 213 of file flow_learn_span_example.cpp.
constexpr uint64_t anonymous_namespace{flow_learn_span_example.cpp}::flow_learn_queue_index_mask = 0xfffff |
Definition at line 214 of file flow_learn_span_example.cpp.