@@ -45,42 +45,52 @@ static FieldSchema createBasicPlusSchema()
4545 " IP_TTL" ,
4646 FieldDirection::Forward,
4747 offsetof (BasicPlusExport, ipTtl.values [Direction::Forward]));
48+
4849 schema.addScalarField <uint8_t >(
4950 " IP_TTL_REV" ,
5051 FieldDirection::Reverse,
5152 offsetof (BasicPlusExport, ipTtl.values [Direction::Reverse]));
53+
5254 schema.addScalarField <uint8_t >(
5355 " IP_FLG" ,
5456 FieldDirection::Forward,
5557 offsetof (BasicPlusExport, ipFlag.values [Direction::Forward]));
58+
5659 schema.addScalarField <uint8_t >(
5760 " IP_FLG_REV" ,
5861 FieldDirection::Reverse,
5962 offsetof (BasicPlusExport, ipFlag.values [Direction::Reverse]));
63+
6064 schema.addScalarField <uint16_t >(
6165 " TCP_WIN" ,
6266 FieldDirection::Forward,
6367 offsetof (BasicPlusExport, tcpWindow.values [Direction::Forward]));
68+
6469 schema.addScalarField <uint16_t >(
6570 " TCP_WIN_REV" ,
6671 FieldDirection::Reverse,
6772 offsetof (BasicPlusExport, tcpWindow.values [Direction::Reverse]));
73+
6874 schema.addScalarField <uint64_t >(
6975 " TCP_OPT" ,
7076 FieldDirection::Forward,
7177 offsetof (BasicPlusExport, tcpOption.values [Direction::Forward]));
78+
7279 schema.addScalarField <uint64_t >(
7380 " TCP_OPT_REV" ,
7481 FieldDirection::Reverse,
7582 offsetof (BasicPlusExport, tcpOption.values [Direction::Reverse]));
83+
7684 schema.addScalarField <uint32_t >(
7785 " TCP_MSS" ,
7886 FieldDirection::Forward,
7987 offsetof (BasicPlusExport, tcpMss.values [Direction::Forward]));
88+
8089 schema.addScalarField <uint32_t >(
8190 " TCP_MSS_REV" ,
8291 FieldDirection::Reverse,
8392 offsetof (BasicPlusExport, tcpMss.values [Direction::Reverse]));
93+
8494 schema.addScalarField <uint16_t >(
8595 " TCP_SYN_SIZE" ,
8696 FieldDirection::DirectionalIndifferent,
@@ -100,7 +110,6 @@ BasicPlusPlugin::BasicPlusPlugin([[maybe_unused]]const std::string& params, Fiel
100110 const FieldSchema schema = createBasicPlusSchema ();
101111 const FieldSchemaHandler schemaHandler = manager.registerSchema (schema);
102112
103-
104113 m_fieldHandlers[BasicPlusFields::IP_TTL] = schemaHandler.getFieldHandler (" IP_TTL" );
105114 m_fieldHandlers[BasicPlusFields::IP_TTL_REV] = schemaHandler.getFieldHandler (" IP_TTL_REV" );
106115 m_fieldHandlers[BasicPlusFields::IP_FLG] = schemaHandler.getFieldHandler (" IP_FLG" );
@@ -123,55 +132,62 @@ FlowAction BasicPlusPlugin::onFlowCreate(FlowRecord& flowRecord, const Packet& p
123132 m_exportData.ipFlag [Direction::Forward] = packet.ipFlags ;
124133 m_fieldHandlers[BasicPlusFields::IP_FLG].setAsAvailable (flowRecord);
125134
126- m_exportData.tcpWindow[Direction::Forward] = packet.tcpWindow;
135+ if (!packet.tcpData .has_value ()) {
136+ return FlowAction::RequestTrimmedData;
137+ }
138+
139+ m_exportData.tcpWindow [Direction::Forward] = packet.tcpData ->window ;
127140 m_fieldHandlers[BasicPlusFields::TCP_WIN].setAsAvailable (flowRecord);
128141
129- m_exportData.tcpOption[Direction::Forward] = packet.tcpOptions ;
142+ m_exportData.tcpOption [Direction::Forward] = packet.tcpData -> options ;
130143 m_fieldHandlers[BasicPlusFields::TCP_OPT].setAsAvailable (flowRecord);
131144
132- m_exportData.tcpMss[Direction::Forward] = packet.tcpMss ;
145+ m_exportData.tcpMss [Direction::Forward] = packet.tcpData -> mss ;
133146 m_fieldHandlers[BasicPlusFields::TCP_MSS].setAsAvailable (flowRecord);
134147
135- if (packet.tcpFlags. flags.synchronize) { // check if SYN packet
148+ if (packet.tcpData -> flags . bitfields .synchronize ) { // check if SYN packet
136149 m_exportData.tcpSynSize = packet.ipLength ;
137150 m_fieldHandlers[BasicPlusFields::TCP_SYN_SIZE].setAsAvailable (flowRecord);
138151 }
139152
140153 return FlowAction::RequestTrimmedData;
141154}
142155
143- FlowAction BasicPlusPlugin::onFlowUpdate(FlowRecord& flowRecord,
144- const Packet& packet, const PacketOfFlowData& data)
156+ FlowAction BasicPlusPlugin::onFlowUpdate (FlowRecord& flowRecord, const Packet& packet)
145157{
146- m_exportData.ipTtl[Direction::Forward]
147- = std::min(m_exportData.ipTtl[Direction::Forward], packet.ipTtl);
158+ m_exportData.ipTtl [packet.direction ]
159+ = std::min (m_exportData.ipTtl [packet.direction ], packet.ipTtl );
160+
161+ if (!packet.tcpData .has_value ()) {
162+ return FlowAction::RequestTrimmedData;
163+ }
148164
149- if (data.packetDirection == Direction::Reverse) {
150- m_exportData.ipTtl[Direction::Reverse] = packet.ipTtl;
151- m_fieldHandlers[BasicPlusFields::IP_TTL_REV].setAsAvailable(flowRecord);
152-
153- m_exportData.ipFlag[Direction::Reverse] = packet.ipFlags;
154- m_fieldHandlers[BasicPlusFields::IP_FLG_REV].setAsAvailable(flowRecord);
155-
156- m_exportData.tcpWindow[Direction::Reverse] = packet.tcpWindow;
157- m_fieldHandlers[BasicPlusFields::TCP_WIN_REV].setAsAvailable(flowRecord);
158-
159- m_exportData.tcpOption[Direction::Reverse] = packet.tcpOptions;
160- m_fieldHandlers[BasicPlusFields::TCP_OPT_REV].setAsAvailable(flowRecord);
161-
162- m_exportData.tcpMss[Direction::Reverse] = packet.tcpMss;
163- m_fieldHandlers[BasicPlusFields::TCP_MSS_REV].setAsAvailable(flowRecord);
164-
165- m_exportData.processingState.destinationFilled = true;
165+ m_exportData.tcpOption [packet.direction ] |= packet.tcpData ->options ;
166+
167+ if (packet.direction == Direction::Forward) {
168+ return FlowAction::RequestTrimmedData;
166169 }
167170
168- m_exportData.tcpOption[data.packetDirection] |= packet.tcpOptions;
171+ m_exportData.ipTtl [Direction::Reverse] = packet.ipTtl ;
172+ m_fieldHandlers[BasicPlusFields::IP_TTL_REV].setAsAvailable (flowRecord);
173+
174+ m_exportData.ipFlag [Direction::Reverse] = packet.ipFlags ;
175+ m_fieldHandlers[BasicPlusFields::IP_FLG_REV].setAsAvailable (flowRecord);
176+
177+ m_exportData.tcpWindow [Direction::Reverse] = packet.tcpData ->window ;
178+ m_fieldHandlers[BasicPlusFields::TCP_WIN_REV].setAsAvailable (flowRecord);
179+
180+ m_exportData.tcpOption [Direction::Reverse] = packet.tcpData ->options ;
181+ m_fieldHandlers[BasicPlusFields::TCP_OPT_REV].setAsAvailable (flowRecord);
182+
183+ m_exportData.tcpMss [Direction::Reverse] = packet.tcpData ->mss ;
184+ m_fieldHandlers[BasicPlusFields::TCP_MSS_REV].setAsAvailable (flowRecord);
185+
186+ m_exportData.processingState .destinationFilled = true ;
169187
170188 return FlowAction::RequestTrimmedData;
171189}
172190
173- void BasicPlusPlugin::onFlowExport() {}
174-
175191ProcessPlugin* BasicPlusPlugin::clone (std::byte* constructAtAddress) const
176192{
177193 return std::construct_at (reinterpret_cast <BasicPlusPlugin*>(constructAtAddress), *this );
0 commit comments