Coverage Report

Created: 2026-09-28 07:39

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/suricata8/rust/src/sip/log.rs
Line
Count
Source
1
/* Copyright (C) 2019 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 Giuseppe Longo <giuseppe@glongo.it>
19
20
use crate::jsonbuilder::{JsonBuilder, JsonError};
21
use crate::sdp::logger::sdp_log;
22
use crate::sip::sip::SIPTransaction;
23
24
0
fn log(tx: &SIPTransaction, js: &mut JsonBuilder) -> Result<(), JsonError> {
25
0
    js.open_object("sip")?;
26
27
0
    if let Some(req) = &tx.request {
28
0
        js.set_string("method", &req.method)?
29
0
            .set_string("uri", &req.path)?
30
0
            .set_string("version", &req.version)?;
31
32
0
        if let Some(sdp_body) = &req.body {
33
0
            sdp_log(sdp_body, js)?;
34
0
        }
35
0
    }
36
37
0
    if let Some(req_line) = &tx.request_line {
38
0
        js.set_string("request_line", req_line)?;
39
0
    }
40
41
0
    if let Some(resp) = &tx.response {
42
0
        js.set_string("version", &resp.version)?
43
0
            .set_string("code", &resp.code)?
44
0
            .set_string("reason", &resp.reason)?;
45
0
        if let Some(sdp_body) = &resp.body {
46
0
            sdp_log(sdp_body, js)?;
47
0
        }
48
0
    }
49
50
0
    if let Some(resp_line) = &tx.response_line {
51
0
        js.set_string("response_line", resp_line)?;
52
0
    }
53
54
0
    js.close()?;
55
56
0
    Ok(())
57
0
}
58
59
#[no_mangle]
60
pub extern "C" fn SCSipLogJson(tx: &SIPTransaction, js: &mut JsonBuilder) -> bool {
61
    log(tx, js).is_ok()
62
}