]>
Commit | Line | Data |
---|---|---|
75d7c9d6 VJ |
1 | /* Copyright (C) 2018 Open Information Security Foundation |
2 | * | |
3 | * You can copy, redistribute or modify this Program under the terms of | |
4 | * the GNU General Public License version 2 as published by the Free | |
5 | * Software Foundation. | |
6 | * | |
7 | * This program is distributed in the hope that it will be useful, | |
8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
10 | * GNU General Public License for more details. | |
11 | * | |
12 | * You should have received a copy of the GNU General Public License | |
13 | * version 2 along with this program; if not, write to the Free Software | |
14 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA | |
15 | * 02110-1301, USA. | |
16 | */ | |
17 | ||
42e5065a | 18 | use crate::smb::smb::*; |
75d7c9d6 | 19 | |
b9f10ba2 | 20 | #[derive(AppLayerEvent)] |
75d7c9d6 | 21 | pub enum SMBEvent { |
b9f10ba2 JI |
22 | InternalError, |
23 | MalformedData, | |
24 | RecordOverflow, | |
25 | MalformedNtlmsspRequest, | |
26 | MalformedNtlmsspResponse, | |
27 | DuplicateNegotiate, | |
28 | NegotiateMalformedDialects, | |
29 | FileOverlap, | |
75d7c9d6 VJ |
30 | } |
31 | ||
32 | impl SMBTransaction { | |
33 | /// Set event. | |
34 | pub fn set_event(&mut self, e: SMBEvent) { | |
7732efbe | 35 | self.tx_data.set_event(e as u8); |
75d7c9d6 VJ |
36 | } |
37 | ||
38 | /// Set events from vector of events. | |
39 | pub fn set_events(&mut self, events: Vec<SMBEvent>) { | |
40 | for e in events { | |
7732efbe | 41 | self.tx_data.set_event(e as u8); |
75d7c9d6 VJ |
42 | } |
43 | } | |
44 | } | |
45 | ||
46 | impl SMBState { | |
47 | /// Set an event. The event is set on the most recent transaction. | |
48 | pub fn set_event(&mut self, event: SMBEvent) { | |
49 | let len = self.transactions.len(); | |
50 | if len == 0 { | |
51 | return; | |
52 | } | |
53 | ||
54 | let tx = &mut self.transactions[len - 1]; | |
55 | tx.set_event(event); | |
75d7c9d6 VJ |
56 | } |
57 | } |