Skip to content

Commit

Permalink
lib: set uplink flag for NAS
Browse files Browse the repository at this point in the history
  • Loading branch information
wgreenberg authored and cooperq committed Jan 30, 2025
1 parent 3619df3 commit 5a084f1
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
4 changes: 2 additions & 2 deletions lib/src/diag.rs
Original file line number Diff line number Diff line change
Expand Up @@ -221,9 +221,9 @@ pub enum Nas4GMessageDirection {
// * 0xb0ec: plain EMM NAS message (incoming)
// * 0xb0ed: plain EMM NAS message (outgoing)
#[deku(id_pat = "0xb0e2 | 0xb0ec")]
Inbound,
Downlink,
#[deku(id_pat = "0xb0e3 | 0xb0ed")]
Outbound,
Uplink,
}

#[derive(Debug, Clone, PartialEq, DekuRead, DekuWrite)]
Expand Down
9 changes: 8 additions & 1 deletion lib/src/gsmtap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ pub enum GsmtapType {
UmtsRlcMac,
UmtsRrc(UmtsRrcSubtype),
LteRrc(LteRrcSubtype), /* LTE interface */
LteMac, /* LTE MAC interface */
LteMac, /* LTE MAC interface */
LteMacFramed, /* LTE MAC with context hdr */
OsmocoreLog, /* libosmocore logging */
QcDiag, /* Qualcomm DIAG frame */
Expand Down Expand Up @@ -200,6 +200,11 @@ pub struct GsmtapHeader {
#[deku(update = "self.gsmtap_type.get_type()")]
pub packet_type: u8,
pub timeslot: u8,
#[deku(bits = 1)]
pub pcs_band_indicator: bool,
#[deku(bits = 1)]
pub uplink: bool,
#[deku(bits = 14)]
pub arfcn: u16,
pub signal_dbm: i8,
pub signal_noise_ratio_db: u8,
Expand All @@ -222,6 +227,8 @@ impl GsmtapHeader {
header_len: 4,
packet_type: gsmtap_type.get_type(),
timeslot: 0,
pcs_band_indicator: false,
uplink: false,
arfcn: 0,
signal_dbm: 0,
signal_noise_ratio_db: 0,
Expand Down
6 changes: 3 additions & 3 deletions lib/src/gsmtap_parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@ fn log_to_gsmtap(value: LogBody) -> Result<Option<GsmtapMessage>, GsmtapParserEr
_ => return Err(GsmtapParserError::InvalidLteRrcOtaExtHeaderVersion(ext_header_version)),
};
let mut header = GsmtapHeader::new(gsmtap_type);
// Wireshark GSMTAP only accepts 14 bits of ARFCN
header.arfcn = packet.get_earfcn().try_into().unwrap_or(0);
header.frame_number = packet.get_sfn();
header.subslot = packet.get_subfn();
Expand All @@ -108,9 +107,10 @@ fn log_to_gsmtap(value: LogBody) -> Result<Option<GsmtapMessage>, GsmtapParserEr
payload: packet.take_payload(),
}))
},
LogBody::Nas4GMessage { msg, .. } => {
LogBody::Nas4GMessage { msg, direction, .. } => {
// currently we only handle "plain" (i.e. non-secure) NAS messages
let header = GsmtapHeader::new(GsmtapType::LteNas(LteNasSubtype::Plain));
let mut header = GsmtapHeader::new(GsmtapType::LteNas(LteNasSubtype::Plain));
header.uplink = matches!(direction, Nas4GMessageDirection::Uplink);
Ok(Some(GsmtapMessage {
header,
payload: msg,
Expand Down

0 comments on commit 5a084f1

Please sign in to comment.