|
38 | 38 | #include "flowifc.hpp" |
39 | 39 |
|
40 | 40 | namespace ipxp { |
41 | | - |
42 | | -/** |
43 | | - * \brief Tell storage plugin to flush (immediately export) current flow. |
44 | | - * Behavior when called from post_create, pre_update and post_update: flush current Flow and erase FlowRecord. |
45 | | - */ |
46 | | -#define FLOW_FLUSH 0x1 |
47 | | - |
48 | | -/** |
49 | | - * \brief Tell storage plugin to flush (immediately export) current flow. |
50 | | - * Behavior when called from post_create: flush current Flow and erase FlowRecord. |
51 | | - * Behavior when called from pre_update and post_update: flush current Flow, erase FlowRecord and call post_create on packet. |
52 | | - */ |
53 | | -#define FLOW_FLUSH_WITH_REINSERT 0x3 |
54 | | - |
55 | 41 | /** |
56 | 42 | * \brief Class template for flow cache plugins. |
57 | 43 | */ |
58 | 44 | class ProcessPlugin : public Plugin |
59 | 45 | { |
60 | 46 | public: |
61 | | - ProcessPlugin() {} |
62 | | - virtual ~ProcessPlugin() {} |
63 | | - virtual ProcessPlugin *copy() = 0; |
| 47 | + enum FlowAction : int { |
| 48 | + /** |
| 49 | + * \brief Tell storage plugin that process plugin requires all incoming data for given flow. |
| 50 | + */ |
| 51 | + GET_ALL_DATA = 0, |
| 52 | + /** |
| 53 | + * \brief Tell storage plugin that process plugin requires only metadata. |
| 54 | + * Used to offload the cache when all process plugin return GET_METADATA. |
| 55 | + */ |
| 56 | + GET_METADATA = 0x2, |
| 57 | + /** |
| 58 | + * \brief Tell storage plugin that process plugin has ended up its work and doesn't require |
| 59 | + * any new data. Used to offload the cache when all process plugin return NO_PROCESS. |
| 60 | + */ |
| 61 | + NO_PROCESS = 0x4, |
| 62 | + /** |
| 63 | + * \brief Tell storage plugin to flush (immediately export) current flow. |
| 64 | + * Behavior when called from post_create, pre_update and post_update: flush current Flow and |
| 65 | + * erase FlowRecord. |
| 66 | + */ |
| 67 | + FLUSH = 0x1, |
| 68 | + |
| 69 | + /** |
| 70 | + * \brief Tell storage plugin to flush (immediately export) current flow. |
| 71 | + * Behavior when called from post_create: flush current Flow and erase FlowRecord. |
| 72 | + * Behavior when called from pre_update and post_update: flush current Flow, erase |
| 73 | + * FlowRecord and call post_create on packet. |
| 74 | + */ |
| 75 | + FLUSH_WITH_REINSERT = 0x7 |
| 76 | + }; |
| 77 | + |
| 78 | + ProcessPlugin() {} |
| 79 | + virtual ~ProcessPlugin() {} |
| 80 | + virtual ProcessPlugin* copy() = 0; |
| 81 | + |
| 82 | + virtual RecordExt *get_ext() const |
| 83 | + { |
| 84 | + return nullptr; |
| 85 | + } |
64 | 86 |
|
65 | | - virtual RecordExt *get_ext() const |
66 | | - { |
67 | | - return nullptr; |
68 | | - } |
| 87 | + /** |
| 88 | + * \brief Called before a new flow record is created. |
| 89 | + * \param [in] pkt Parsed packet. |
| 90 | + * \return 0 on success or FLOW_FLUSH option. |
| 91 | + */ |
| 92 | + virtual FlowAction pre_create(Packet& pkt) |
| 93 | + { |
| 94 | + return FlowAction::GET_ALL_DATA; |
| 95 | + } |
69 | 96 |
|
70 | | - /** |
71 | | - * \brief Called before a new flow record is created. |
72 | | - * \param [in] pkt Parsed packet. |
73 | | - * \return 0 on success or FLOW_FLUSH option. |
74 | | - */ |
75 | | - virtual int pre_create(Packet &pkt) |
76 | | - { |
77 | | - return 0; |
78 | | - } |
| 97 | + /** |
| 98 | + * \brief Called after a new flow record is created. |
| 99 | + * \param [in,out] rec Reference to flow record. |
| 100 | + * \param [in] pkt Parsed packet. |
| 101 | + * \return 0 on success or FLOW_FLUSH option. |
| 102 | + */ |
| 103 | + virtual FlowAction post_create(Flow& rec, const Packet& pkt) |
| 104 | + { |
| 105 | + return FlowAction::GET_ALL_DATA; |
| 106 | + } |
79 | 107 |
|
80 | | - /** |
81 | | - * \brief Called after a new flow record is created. |
82 | | - * \param [in,out] rec Reference to flow record. |
83 | | - * \param [in] pkt Parsed packet. |
84 | | - * \return 0 on success or FLOW_FLUSH option. |
85 | | - */ |
86 | | - virtual int post_create(Flow &rec, const Packet &pkt) |
87 | | - { |
88 | | - return 0; |
89 | | - } |
| 108 | + /** |
| 109 | + * \brief Called before an existing record is update. |
| 110 | + * \param [in,out] rec Reference to flow record. |
| 111 | + * \param [in,out] pkt Parsed packet. |
| 112 | + * \return 0 on success or FLOW_FLUSH option. |
| 113 | + */ |
| 114 | + virtual FlowAction pre_update(Flow& rec, Packet& pkt) |
| 115 | + { |
| 116 | + return FlowAction::GET_ALL_DATA; |
| 117 | + } |
90 | 118 |
|
91 | | - /** |
92 | | - * \brief Called before an existing record is update. |
93 | | - * \param [in,out] rec Reference to flow record. |
94 | | - * \param [in,out] pkt Parsed packet. |
95 | | - * \return 0 on success or FLOW_FLUSH option. |
96 | | - */ |
97 | | - virtual int pre_update(Flow &rec, Packet &pkt) |
98 | | - { |
99 | | - return 0; |
100 | | - } |
| 119 | + /** |
| 120 | + * \brief Called after an existing record is updated. |
| 121 | + * \param [in,out] rec Reference to flow record. |
| 122 | + * \param [in,out] pkt Parsed packet. |
| 123 | + * \return 0 on success or FLOW_FLUSH option. |
| 124 | + */ |
| 125 | + virtual FlowAction post_update(Flow& rec, const Packet& pkt) |
| 126 | + { |
| 127 | + return FlowAction::GET_ALL_DATA; |
| 128 | + } |
101 | 129 |
|
102 | | - /** |
103 | | - * \brief Called after an existing record is updated. |
104 | | - * \param [in,out] rec Reference to flow record. |
105 | | - * \param [in,out] pkt Parsed packet. |
106 | | - * \return 0 on success or FLOW_FLUSH option. |
107 | | - */ |
108 | | - virtual int post_update(Flow &rec, const Packet &pkt) |
109 | | - { |
110 | | - return 0; |
111 | | - } |
| 130 | + /** |
| 131 | + * \brief Called before a flow record is exported from the cache. |
| 132 | + * \param [in,out] rec Reference to flow record. |
| 133 | + */ |
| 134 | + virtual void pre_export(Flow& rec) |
| 135 | + { |
112 | 136 |
|
113 | | - /** |
114 | | - * \brief Called before a flow record is exported from the cache. |
115 | | - * \param [in,out] rec Reference to flow record. |
116 | | - */ |
117 | | - virtual void pre_export(Flow &rec) |
118 | | - { |
119 | | - } |
| 137 | + } |
120 | 138 | }; |
121 | 139 |
|
122 | 140 | } |
|
0 commit comments