convert int to option

This commit is contained in:
Cooper Quintin
2026-02-02 16:33:35 -08:00
committed by Will Greenberg
parent b453c92d6a
commit 6e4cbac4b1
2 changed files with 38 additions and 33 deletions
+1 -1
View File
@@ -385,7 +385,7 @@ impl Harness {
"in packet {}, failed to convert gsmtap message to IE: {err:?}", "in packet {}, failed to convert gsmtap message to IE: {err:?}",
self.packet_num self.packet_num
); );
debug!(&msg); debug!("{msg}");
row.skipped_message_reason = Some(msg); row.skipped_message_reason = Some(msg);
return row; return row;
} }
+37 -32
View File
@@ -11,8 +11,8 @@ use telcom_parser::lte_rrc::{
/// Based on heuristic T7 from Shinjo Park's "Why We Cannot Win". /// Based on heuristic T7 from Shinjo Park's "Why We Cannot Win".
pub struct LteSib6And7DowngradeAnalyzer { pub struct LteSib6And7DowngradeAnalyzer {
lte_priority: i16, lte_priority: Option<u8>,
legacy_priority: i16, legacy_priority: Option<u8>,
} }
impl Default for LteSib6And7DowngradeAnalyzer { impl Default for LteSib6And7DowngradeAnalyzer {
fn default() -> Self { fn default() -> Self {
@@ -23,8 +23,8 @@ impl Default for LteSib6And7DowngradeAnalyzer {
impl LteSib6And7DowngradeAnalyzer { impl LteSib6And7DowngradeAnalyzer {
pub fn new() -> Self { pub fn new() -> Self {
Self { Self {
lte_priority: 0, lte_priority: None,
legacy_priority: 0, legacy_priority: None,
} }
} }
@@ -76,14 +76,14 @@ impl Analyzer for LteSib6And7DowngradeAnalyzer {
Some(Event { Some(Event {
event_type: EventType::High, event_type: EventType::High,
message: message:
format!("LTE cell advertised a 3G cell for priority {} reselection over LTE neighbors at priority {}", self.legacy_priority, self.lte_priority) format!("LTE cell advertised a 3G cell for priority {} reselection over LTE neighbors at priority {}", self.legacy_priority?, self.lte_priority?)
.to_string(), .to_string(),
}) })
} else { } else {
None None
}; };
self.lte_priority = 0; self.lte_priority = None;
self.legacy_priority = -1; self.legacy_priority = None;
debug!("reset priority to 0 due to new sib1 at {_packet_num}"); debug!("reset priority to 0 due to new sib1 at {_packet_num}");
return flag; return flag;
} }
@@ -92,16 +92,15 @@ impl Analyzer for LteSib6And7DowngradeAnalyzer {
for sib in sibs { for sib in sibs {
match sib { match sib {
SystemInformation_r8_IEsSib_TypeAndInfo_Entry::Sib3(sib3) => { SystemInformation_r8_IEsSib_TypeAndInfo_Entry::Sib3(sib3) => {
let res_p: i16 = sib3 let res_p: u8 = sib3
.cell_reselection_serving_freq_info .cell_reselection_serving_freq_info
.cell_reselection_priority .cell_reselection_priority
.0 .0;
.into(); if Some(res_p) > self.lte_priority {
if res_p > self.lte_priority { self.lte_priority = Some(res_p);
self.lte_priority = res_p;
debug!( debug!(
"set priority {} due to sib3 (frame {})", "set priority {} due to sib3 (frame {})",
self.lte_priority, _packet_num res_p, _packet_num
); );
} }
} }
@@ -109,12 +108,12 @@ impl Analyzer for LteSib6And7DowngradeAnalyzer {
let carrier_freq_list = &sib5.inter_freq_carrier_freq_list; let carrier_freq_list = &sib5.inter_freq_carrier_freq_list;
for carrier_freq in &carrier_freq_list.0 { for carrier_freq in &carrier_freq_list.0 {
if let Some(res_p) = &carrier_freq.cell_reselection_priority { if let Some(res_p) = &carrier_freq.cell_reselection_priority {
let pri: i16 = res_p.0.into(); let pri: u8 = res_p.0;
if pri > self.lte_priority { if Some(pri) > self.lte_priority {
self.lte_priority = pri; self.lte_priority = Some(pri);
debug!( debug!(
"set priority {} due to sib5 (frame {})", "set priority {} due to sib5 (frame {})",
self.lte_priority, _packet_num pri, _packet_num
); );
} }
} }
@@ -126,11 +125,13 @@ impl Analyzer for LteSib6And7DowngradeAnalyzer {
if let Some(CellReselectionPriority(p)) = if let Some(CellReselectionPriority(p)) =
carrier_info.cell_reselection_priority carrier_info.cell_reselection_priority
{ {
self.legacy_priority = p.into(); if Some(p) > self.legacy_priority {
debug!( self.legacy_priority = Some(p.into());
"set legacy priority {} due to sib6 (frame {})", debug!(
self.lte_priority, _packet_num "set legacy priority {} due to sib6 (frame {})",
); p, _packet_num
);
}
} }
} }
} }
@@ -139,11 +140,13 @@ impl Analyzer for LteSib6And7DowngradeAnalyzer {
if let Some(CellReselectionPriority(p)) = if let Some(CellReselectionPriority(p)) =
carrier_info.cell_reselection_priority carrier_info.cell_reselection_priority
{ {
self.legacy_priority = p.into(); if Some(p) > self.legacy_priority {
debug!( self.legacy_priority = Some(p);
"set legacy priority {} due to sib6 (frame {})", debug!(
self.lte_priority, _packet_num "set legacy priority {} due to sib6 (frame {})",
); p, _packet_num
);
}
} }
} }
} }
@@ -158,11 +161,13 @@ impl Analyzer for LteSib6And7DowngradeAnalyzer {
if let Some(CellReselectionPriority(p)) = if let Some(CellReselectionPriority(p)) =
carrier_info.common_info.cell_reselection_priority carrier_info.common_info.cell_reselection_priority
{ {
self.legacy_priority = p.into(); if Some(p) > self.legacy_priority {
debug!( self.legacy_priority = p.into();
"set legacy priority {} due to sib7 (frame {})", debug!(
self.lte_priority, _packet_num "set legacy priority {} due to sib7 (frame {})",
); p, _packet_num
);
}
} }
} }
} }