use crate::jsonbuilder::{JsonBuilder, JsonError};
use crate::tftp::tftp::TFTPTransaction;
fn tftp_log_request(tx: &TFTPTransaction, jb: &mut JsonBuilder) -> Result<(), JsonError> {
jb.open_object("tftp")?;
match tx.opcode {
1 => jb.set_string("packet", "read")?,
2 => jb.set_string("packet", "write")?,
_ => jb.set_string("packet", "error")?,
};
jb.set_string("file", tx.filename.as_str())?;
jb.set_string("mode", tx.mode.as_str())?;
jb.close()?;
Ok(())
}
#[no_mangle]
pub extern "C" fn SCTftpLogJsonRequest(tx: &TFTPTransaction, jb: &mut JsonBuilder) -> bool {
tftp_log_request(tx, jb).is_ok()
}