mirror of
https://github.com/EFForg/rayhunter.git
synced 2026-04-27 16:09:58 -07:00
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:
18
telcom-parser/src/lib.rs
Normal file
18
telcom-parser/src/lib.rs
Normal 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))
|
||||
}
|
||||
Reference in New Issue
Block a user