|
| 1 | +/** |
| 2 | +* \file |
| 3 | + * \author Damir Zainullin <[email protected]> |
| 4 | + * \brief FlowRecord declaration. |
| 5 | + */ |
| 6 | +/* |
| 7 | + * Copyright (C) 2023 CESNET |
| 8 | + * |
| 9 | + * LICENSE TERMS |
| 10 | + * |
| 11 | + * Redistribution and use in source and binary forms, with or without |
| 12 | + * modification, are permitted provided that the following conditions |
| 13 | + * are met: |
| 14 | + * 1. Redistributions of source code must retain the above copyright |
| 15 | + * notice, this list of conditions and the following disclaimer. |
| 16 | + * 2. Redistributions in binary form must reproduce the above copyright |
| 17 | + * notice, this list of conditions and the following disclaimer in |
| 18 | + * the documentation and/or other materials provided with the |
| 19 | + * distribution. |
| 20 | + * 3. Neither the name of the Company nor the names of its contributors |
| 21 | + * may be used to endorse or promote products derived from this |
| 22 | + * software without specific prior written permission. |
| 23 | + */ |
| 24 | + |
| 25 | +#pragma once |
| 26 | + |
| 27 | +#include <ipfixprobe/packet.hpp> |
| 28 | +#include <ipfixprobe/flowifc.hpp> |
| 29 | +#include <cstdint> |
| 30 | +#include <optional> |
| 31 | +#include <ipfixprobe/cttmeta.hpp> |
| 32 | + |
| 33 | +#include "../../cache/src/flowRecord.hpp" |
| 34 | + |
| 35 | +namespace ipxp { |
| 36 | + |
| 37 | +struct alignas(64) FlowRecordCtt : public FlowRecord |
| 38 | +{ |
| 39 | + bool can_be_offloaded; /**< No flow collision in CTT */ |
| 40 | + std::optional<timeval> last_request_time; /**< Time point when the last not processed request was sent to CTT. */ |
| 41 | + std::optional<feta::OffloadMode> offload_mode; /**< Offload mode of the flow. Nullopt if not offloaded*/ |
| 42 | + |
| 43 | + void erase() override; |
| 44 | + |
| 45 | + void create(const Packet &pkt, uint64_t pkt_hash) override; |
| 46 | + |
| 47 | + __attribute__((always_inline)) bool is_in_ctt() const noexcept |
| 48 | + { |
| 49 | + return offload_mode.has_value(); |
| 50 | + } |
| 51 | + |
| 52 | + __attribute__((always_inline)) bool is_waiting_ctt_response() const noexcept |
| 53 | + { |
| 54 | + return is_in_ctt() && last_request_time.has_value(); |
| 55 | + } |
| 56 | + |
| 57 | +}; |
| 58 | + |
| 59 | +} // ipxp |
0 commit comments