mirror of
https://github.com/EFForg/rayhunter.git
synced 2026-06-29 21:52:06 -07:00
wip
This commit is contained in:
+12
-7
@@ -2,10 +2,7 @@ use clap::Parser;
|
||||
use log::{debug, error, info, warn};
|
||||
use pcap_file_tokio::pcapng::{Block, PcapNgReader};
|
||||
use rayhunter::{
|
||||
analysis::analyzer::{AnalysisRow, AnalyzerConfig, EventType, Harness},
|
||||
gsmtap::parser as gsmtap_parser,
|
||||
pcap::GsmtapPcapWriter,
|
||||
qmdl::QmdlMessageReader,
|
||||
analysis::analyzer::{AnalysisRow, AnalyzerConfig, EventType, Harness}, diag::Message, gsmtap::parser as gsmtap_parser, pcap::GsmtapPcapWriter, qmdl::QmdlMessageReader,
|
||||
};
|
||||
use std::{collections::HashMap, path::PathBuf};
|
||||
use tokio::fs::File;
|
||||
@@ -115,12 +112,20 @@ async fn analyze_qmdl(qmdl_path: &str, show_skipped: bool) {
|
||||
.await
|
||||
.expect("failed to open QmdlReader");
|
||||
let mut report = Report::new(qmdl_path);
|
||||
while let Some(maybe_message) = qmdl_reader
|
||||
.get_next_message()
|
||||
let mut stats = HashMap::new();
|
||||
while let Some(buf) = qmdl_reader
|
||||
.get_next_buf()
|
||||
.await
|
||||
.expect("failed to get message")
|
||||
{
|
||||
report.process_row(harness.analyze_qmdl_message(maybe_message));
|
||||
let log_type = u16::from_le_bytes([buf[6], buf[7]]);
|
||||
stats.entry(log_type)
|
||||
.and_modify(|total| *total += buf.len())
|
||||
.or_insert(buf.len());
|
||||
report.process_row(harness.analyze_qmdl_message(Message::from_hdlc(&buf)));
|
||||
}
|
||||
for (id, size) in stats {
|
||||
println!("{id:04x}: {size}");
|
||||
}
|
||||
report.print_summary(show_skipped);
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ use serde::{Deserialize, Serialize};
|
||||
use std::borrow::Cow;
|
||||
|
||||
use crate::analysis::diagnostic::DiagnosticAnalyzer;
|
||||
use crate::diag::diaglog::LogBody;
|
||||
use crate::diag::{DiagParsingError, Message, MessagesContainer};
|
||||
use crate::gsmtap::{GsmtapHeader, GsmtapMessage, GsmtapType, parser as gsmtap_parser};
|
||||
use crate::util::RuntimeMetadata;
|
||||
@@ -430,6 +431,21 @@ impl Harness {
|
||||
return row;
|
||||
}
|
||||
};
|
||||
if let Message::Log { body, .. } = &qmdl_message {
|
||||
match body {
|
||||
LogBody::LteLl1ServingCellTiming { data } => {
|
||||
for t in &data.timing_adjustment {
|
||||
if t.timing_advance != 0 {
|
||||
println!("ta {}", t.timing_advance);
|
||||
}
|
||||
}
|
||||
}
|
||||
LogBody::LteMl1ServingCellMeasurementAndEvaluation { data } => {
|
||||
// println!("serving cell pci {}, earfcn {}", data.get_pci(), data.get_earfcn());
|
||||
}
|
||||
_ => {},
|
||||
}
|
||||
}
|
||||
let (timestamp, gsmtap_msg) = match gsmtap_parser::parse(qmdl_message) {
|
||||
Ok(Some(msg)) => msg,
|
||||
Ok(None) => return row,
|
||||
|
||||
@@ -199,6 +199,22 @@ where
|
||||
|
||||
Ok(Some(Message::from_hdlc(&buf)))
|
||||
}
|
||||
|
||||
pub async fn get_next_buf(
|
||||
&mut self,
|
||||
) -> Result<Option<Vec<u8>>, std::io::Error> {
|
||||
let mut buf = vec![];
|
||||
if self
|
||||
.buf_reader
|
||||
.read_until(MESSAGE_TERMINATOR, &mut buf)
|
||||
.await?
|
||||
== 0
|
||||
{
|
||||
return Ok(None);
|
||||
}
|
||||
|
||||
Ok(Some(buf))
|
||||
}
|
||||
}
|
||||
|
||||
impl<T> AsyncRead for QmdlMessageReader<T>
|
||||
|
||||
Reference in New Issue
Block a user