lib: serialize MAC RACH attempts to GSMTAP

This also refactors the gsmtap code into a neater module, and adds MAC
UL & DL logs to our diag capture.
This commit is contained in:
Will Greenberg
2026-06-18 13:45:59 -07:00
committed by Will Greenberg
parent 64c59d5e08
commit 30f663be2f
11 changed files with 266 additions and 33 deletions
+16 -2
View File
@@ -1,8 +1,9 @@
use crate::diag::Message;
use crate::diag::diaglog::{LogBody, Nas4GMessageDirection, Timestamp};
use crate::gsmtap::mac::mac_subpacket_to_gsmtap;
use crate::gsmtap::{GsmtapHeader, GsmtapMessage, GsmtapType, LteNasSubtype, LteRrcSubtype};
use log::debug;
use log::{debug, warn};
use thiserror::Error;
#[derive(Debug, Error)]
@@ -11,6 +12,8 @@ pub enum GsmtapParserError {
InvalidLteRrcOtaExtHeaderVersion(u8),
#[error("Invalid LteRrcOtaMessage header/PDU number combination: {0}/{1}")]
InvalidLteRrcOtaHeaderPduNum(u8, u8),
#[error("Invalid LteMacRachResponse packet: {0}")]
InvalidLteMacRachResponse(String),
}
pub fn parse(msg: Message) -> Result<Option<(Timestamp, GsmtapMessage)>, GsmtapParserError> {
@@ -165,7 +168,18 @@ fn log_to_gsmtap(value: LogBody) -> Result<Option<GsmtapMessage>, GsmtapParserEr
payload: vec![],
}))
}
LogBody::LteMacRachResponse { payload } => Ok(parse_rach_response(&payload)),
LogBody::LteMacRachResponse { packet } => {
if packet.subpackets.len() > 1 {
warn!("expected 1 MAC subpacket for LogBody::LteMacRachResponse, but got {}! ignoring all but the first", packet.subpackets.len());
}
let Some(subpacket) = packet.subpackets.get(0) else {
return Err(GsmtapParserError::InvalidLteMacRachResponse(format!("no subpackets")));
};
mac_subpacket_to_gsmtap(&subpacket.body)
.map_err(|err| {
GsmtapParserError::InvalidLteMacRachResponse(format!("unable to serialize GSMTAP payload: {err:?}"))
})
},
_ => {
debug!("gsmtap_sink: ignoring unhandled log type: {value:?}");
Ok(None)