/src/suricata7/rust/src/ftp/event.rs
Line | Count | Source |
1 | | /* Copyright (C) 2023 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 | | |
18 | | use crate::core::AppLayerEventType; |
19 | | use std::os::raw::{c_char, c_int}; |
20 | | |
21 | | #[derive(Debug, PartialEq, Eq, AppLayerEvent)] |
22 | | #[repr(C)] |
23 | | pub enum FtpEvent { |
24 | | #[name("request_command_too_long")] |
25 | | FtpEventRequestCommandTooLong, |
26 | | #[name("response_command_too_long")] |
27 | | FtpEventResponseCommandTooLong, |
28 | | } |
29 | | |
30 | | /// Wrapper around the Rust generic function for get_event_info. |
31 | | /// |
32 | | /// # Safety |
33 | | /// Unsafe as called from C. |
34 | | #[no_mangle] |
35 | 234 | pub unsafe extern "C" fn ftp_get_event_info( |
36 | 234 | event_name: *const c_char, event_id: *mut c_int, event_type: *mut AppLayerEventType, |
37 | 234 | ) -> c_int { |
38 | 234 | crate::applayer::get_event_info::<FtpEvent>(event_name, event_id, event_type) |
39 | 234 | } |
40 | | |
41 | | /// Wrapper around the Rust generic function for get_event_info_by_id. |
42 | | /// |
43 | | /// # Safety |
44 | | /// Unsafe as called from C. |
45 | | #[no_mangle] |
46 | 572 | pub unsafe extern "C" fn ftp_get_event_info_by_id( |
47 | 572 | event_id: c_int, event_name: *mut *const c_char, event_type: *mut AppLayerEventType, |
48 | 572 | ) -> c_int { |
49 | 572 | crate::applayer::get_event_info_by_id::<FtpEvent>(event_id, event_name, event_type) as c_int |
50 | 572 | } |