Skip to content

Commit b2069ec

Browse files
committed
ndpi: use flow access functions
To prevent direct access to the flow structure and be subject to changes in its size. Ticket: OISF#8632
1 parent 6b2addf commit b2069ec

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

plugins/ndpi/ndpi.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424

2525
#include "detect-engine-helper.h"
2626
#include "detect-parse.h"
27+
#include "flow-bindgen.h"
2728
#include "flow-callbacks.h"
2829
#include "flow-storage.h"
2930
#include "output-eve.h"
@@ -129,9 +130,11 @@ static void OnFlowInit(ThreadVars *tv, Flow *f, const Packet *p, void *_data)
129130

130131
static void OnFlowUpdate(ThreadVars *tv, Flow *f, Packet *p, void *_data)
131132
{
133+
const uint8_t flow_proto = SCFlowGetIPProtocol(f);
134+
132135
/* Ignore packets that have a different protocol than the
133136
* flow. This can happen with ICMP unreachable packets. */
134-
if (p->proto != f->proto) {
137+
if (p->proto != flow_proto) {
135138
return;
136139
}
137140

@@ -169,9 +172,10 @@ static void OnFlowUpdate(ThreadVars *tv, Flow *f, Packet *p, void *_data)
169172
flowctx->detection_completed = true;
170173
}
171174
} else {
172-
uint16_t max_num_pkts = (f->proto == IPPROTO_UDP) ? 8 : 24;
175+
uint16_t max_num_pkts = (flow_proto == IPPROTO_UDP) ? 8 : 24;
173176

174-
if ((f->todstpktcnt + f->tosrcpktcnt) > max_num_pkts) {
177+
if ((SCFlowGetToServerPacketCount(f) + SCFlowGetToClientPacketCount(f)) >
178+
max_num_pkts) {
175179
uint8_t proto_guessed;
176180

177181
flowctx->detected_l7_protocol =

0 commit comments

Comments
 (0)