If a Message isn't convertable to GSMTAP, don't try

This also removes the pseudo GSMTAP packets added for measurement
results, since they add a ton of noise to PCAPs. Eventually, we should
keep track of the latest signal for a given PCI, and annotate actual
packets with that value.
This commit is contained in:
Will Greenberg
2026-06-25 07:36:23 -07:00
parent 956b719e12
commit 7831c5085e
2 changed files with 19 additions and 12 deletions
+14
View File
@@ -156,6 +156,20 @@ impl Message {
Err(err) => Err(DiagParsingError::HdlcDecapsulationError(err, data.to_vec())),
}
}
/// Returns whether this message should be parsed into a GSMTAP packet for
/// display in pcap files
pub fn is_gsmtap_message(&self) -> bool {
let Message::Log { body, .. } = self else {
return false;
};
match body {
LogBody::LteRrcOtaMessage { .. } => true,
LogBody::LteMacRachResponse { .. } => true,
LogBody::Nas4GMessage { .. } => true,
_ => false
}
}
}
#[derive(Debug, Clone, PartialEq, DekuRead, DekuWrite)]
+5 -12
View File
@@ -17,6 +17,9 @@ pub enum GsmtapParserError {
}
pub fn parse(msg: Message) -> Result<Option<(Timestamp, GsmtapMessage)>, GsmtapParserError> {
if !msg.is_gsmtap_message() {
return Ok(None);
}
if let Message::Log {
timestamp, body, ..
} = msg
@@ -31,6 +34,8 @@ pub fn parse(msg: Message) -> Result<Option<(Timestamp, GsmtapMessage)>, GsmtapP
}
fn log_to_gsmtap(value: LogBody) -> Result<Option<GsmtapMessage>, GsmtapParserError> {
// Note: if support for another LogBody variant is added here, it should
// also be added to Message::is_gsmtap_message
match value {
LogBody::LteRrcOtaMessage {
ext_header_version,
@@ -156,18 +161,6 @@ fn log_to_gsmtap(value: LogBody) -> Result<Option<GsmtapMessage>, GsmtapParserEr
payload: msg,
}))
}
LogBody::LteMl1ServingCellMeasurementAndEvaluation { data, .. } => {
// frame_number reused for PCI (normally SFN in RRC frames) so all three
// serving-cell fields are accessible in Wireshark as gsmtap.* columns.
let mut header = GsmtapHeader::new(GsmtapType::QcDiag);
header.signal_dbm = data.get_meas_rsrp() as i8;
header.arfcn = data.get_earfcn().try_into().unwrap_or(0);
header.frame_number = data.get_pci() as u32;
Ok(Some(GsmtapMessage {
header,
payload: vec![],
}))
}
LogBody::LteMacRachResponse { packet } => {
if packet.subpackets.len() > 1 {
warn!(