Minimal version of the LTE downgrade analyzer

This also renames the lte_parser crate to telcom_parser, since it'll
handle any 2G or 3G parsing going forward.
This commit is contained in:
Will Greenberg
2024-02-08 15:38:36 -08:00
parent d570ad3cb1
commit 5d7caba1a6
19 changed files with 150 additions and 52 deletions

18
telcom-parser/src/lib.rs Normal file
View File

@@ -0,0 +1,18 @@
use asn1_codecs::{uper::UperCodec, PerCodecData, PerCodecError};
use thiserror::Error;
#[allow(unreachable_patterns, non_camel_case_types)]
pub mod lte_rrc;
#[derive(Error, Debug)]
pub enum ParsingError {
#[error("Failed to decode UPER data: {0}")]
UperDecodeError(PerCodecError),
}
pub fn decode<T>(data: &[u8]) -> Result<T, ParsingError>
where T: UperCodec<Output = T>
{
let mut asn_data = PerCodecData::from_slice_uper(data);
T::uper_decode(&mut asn_data)
.map_err(|e| ParsingError::UperDecodeError(e))
}