Skip to content

Commit 79aac69

Browse files
committed
SSADetector: Added transition functions to detection automaton
1 parent 913d32e commit 79aac69

File tree

2 files changed

+25
-2
lines changed

2 files changed

+25
-2
lines changed

process/ssadetector.cpp

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,25 @@ ProcessPlugin *SSADetectorPlugin::copy()
7878
return new SSADetectorPlugin(*this);
7979
}
8080

81-
int SSADetectorPlugin::pre_create(Packet &pkt)
81+
inline void transition_from_init(RecordExtSSADetector *record, uint16_t len,
82+
const timeval& ts, uint8_t dir)
8283
{
83-
return 0;
84+
record->syn_table.update_entry(len, dir, ts);
85+
}
86+
inline void transition_from_syn(RecordExtSSADetector *record, uint16_t len,
87+
const timeval& ts, uint8_t dir)
88+
{
89+
bool can_transit = record->syn_table.check_range_for_presence(len, 10, !dir, ts);
90+
if (can_transit) {
91+
record->syn_ack_table.update_entry(len, dir, ts);
92+
}
93+
}
94+
95+
inline bool transition_from_syn_ack(RecordExtSSADetector *record,
96+
uint16_t len, const timeval& ts, uint8_t dir)
97+
{
98+
return record->syn_table.check_range_for_presence(len, 12, !dir, ts);
99+
}
84100
}
85101

86102
int SSADetectorPlugin::post_create(Flow &rec, const Packet &pkt)

process/ssadetector.hpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,13 @@ class SSADetectorPlugin : public ProcessPlugin
184184
int pre_update(Flow &rec, Packet &pkt);
185185
int post_update(Flow &rec, const Packet &pkt);
186186
void pre_export(Flow &rec);
187+
static inline void transition_from_init(RecordExtSSADetector *record, uint16_t len,
188+
const timeval& ts, uint8_t dir);
189+
static inline void transition_from_syn(RecordExtSSADetector *record, uint16_t len,
190+
const timeval& ts, uint8_t dir);
191+
static inline bool transition_from_syn_ack(RecordExtSSADetector *record, uint16_t len,
192+
const timeval& ts, uint8_t dir);
193+
187194
};
188195

189196
}

0 commit comments

Comments
 (0)