/src/suricata8/rust/src/tftp/log.rs
Line | Count | Source |
1 | | /* Copyright (C) 2017-2020 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 | | // written by Clément Galland <clement.galland@epita.fr> |
19 | | |
20 | | use crate::jsonbuilder::{JsonBuilder, JsonError}; |
21 | | use crate::tftp::tftp::TFTPTransaction; |
22 | | |
23 | 0 | fn tftp_log_request(tx: &TFTPTransaction, jb: &mut JsonBuilder) -> Result<(), JsonError> { |
24 | 0 | jb.open_object("tftp")?; |
25 | 0 | match tx.opcode { |
26 | 0 | 1 => jb.set_string("packet", "read")?, |
27 | 0 | 2 => jb.set_string("packet", "write")?, |
28 | 0 | _ => jb.set_string("packet", "error")?, |
29 | | }; |
30 | 0 | jb.set_string("file", tx.filename.as_str())?; |
31 | 0 | jb.set_string("mode", tx.mode.as_str())?; |
32 | 0 | jb.close()?; |
33 | 0 | Ok(()) |
34 | 0 | } |
35 | | |
36 | | #[no_mangle] |
37 | 0 | pub extern "C" fn SCTftpLogJsonRequest(tx: &TFTPTransaction, jb: &mut JsonBuilder) -> bool { |
38 | 0 | tftp_log_request(tx, jb).is_ok() |
39 | 0 | } |