mirror of
https://github.com/chirpstack/chirpstack.git
synced 2024-12-19 05:07:54 +00:00
Do not fail on corrupted mac-commands.
This will print a warn log in case of a corrupted mac-command that can not be decoded instead of failing on the uplink.
This commit is contained in:
parent
eccb09cb1b
commit
fc3a94521f
@ -9,7 +9,7 @@ use redis::streams::StreamReadReply;
|
|||||||
use serde_json::json;
|
use serde_json::json;
|
||||||
use tokio::sync::mpsc;
|
use tokio::sync::mpsc;
|
||||||
use tokio::task;
|
use tokio::task;
|
||||||
use tracing::{debug, error, trace};
|
use tracing::{debug, error, trace, warn};
|
||||||
|
|
||||||
use lrwn::EUI64;
|
use lrwn::EUI64;
|
||||||
|
|
||||||
@ -278,10 +278,14 @@ pub async fn get_frame_logs(
|
|||||||
let pl = api::UplinkFrameLog::decode(&mut Cursor::new(b))?;
|
let pl = api::UplinkFrameLog::decode(&mut Cursor::new(b))?;
|
||||||
let mut phy = lrwn::PhyPayload::from_slice(&pl.phy_payload)?;
|
let mut phy = lrwn::PhyPayload::from_slice(&pl.phy_payload)?;
|
||||||
if pl.plaintext_f_opts {
|
if pl.plaintext_f_opts {
|
||||||
phy.decode_f_opts_to_mac_commands()?;
|
if let Err(e) = phy.decode_f_opts_to_mac_commands() {
|
||||||
|
warn!(error = %e, "Decode f_opts to mac-commands error");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if pl.plaintext_frm_payload {
|
if pl.plaintext_frm_payload {
|
||||||
phy.decode_frm_payload()?;
|
if let Err(e) = phy.decode_frm_payload() {
|
||||||
|
warn!(error = %e, "Decode frm_payload error");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let pl = api::LogItem {
|
let pl = api::LogItem {
|
||||||
@ -312,10 +316,14 @@ pub async fn get_frame_logs(
|
|||||||
let pl = api::DownlinkFrameLog::decode(&mut Cursor::new(b))?;
|
let pl = api::DownlinkFrameLog::decode(&mut Cursor::new(b))?;
|
||||||
let mut phy = lrwn::PhyPayload::from_slice(&pl.phy_payload)?;
|
let mut phy = lrwn::PhyPayload::from_slice(&pl.phy_payload)?;
|
||||||
if pl.plaintext_f_opts {
|
if pl.plaintext_f_opts {
|
||||||
phy.decode_f_opts_to_mac_commands()?;
|
if let Err(e) = phy.decode_f_opts_to_mac_commands() {
|
||||||
|
warn!(error = %e, "Decode f_opts to mac-commands error");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if pl.plaintext_frm_payload {
|
if pl.plaintext_frm_payload {
|
||||||
phy.decode_frm_payload()?;
|
if let Err(e) = phy.decode_frm_payload() {
|
||||||
|
warn!(error = %e, "Decode frm_payload error");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let pl = api::LogItem {
|
let pl = api::LogItem {
|
||||||
|
@ -611,14 +611,16 @@ impl Data {
|
|||||||
trace!("Decrypting mac-commands");
|
trace!("Decrypting mac-commands");
|
||||||
let ds = self.device_session.as_ref().unwrap();
|
let ds = self.device_session.as_ref().unwrap();
|
||||||
if ds.mac_version().to_string().starts_with("1.0") {
|
if ds.mac_version().to_string().starts_with("1.0") {
|
||||||
self.phy_payload
|
if let Err(e) = self.phy_payload.decode_f_opts_to_mac_commands() {
|
||||||
.decode_f_opts_to_mac_commands()
|
// This avoids failing in case of a corrupted mac-command in the frm_payload.
|
||||||
.context("Decode mac-commands")?;
|
warn!(error = %e, "Decoding f_opts mac-commands failed");
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
let nwk_s_enc_key = AES128Key::from_slice(&ds.nwk_s_enc_key)?;
|
let nwk_s_enc_key = AES128Key::from_slice(&ds.nwk_s_enc_key)?;
|
||||||
self.phy_payload
|
if let Err(e) = self.phy_payload.decrypt_f_opts(&nwk_s_enc_key) {
|
||||||
.decrypt_f_opts(&nwk_s_enc_key)
|
// This avoids failing in case of a corrupted mac-command in the frm_payload.
|
||||||
.context("Decrypt f_opts")?;
|
warn!(error = %e, "Decrypting f_opts mac-commands failed");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
@ -636,7 +638,10 @@ impl Data {
|
|||||||
// Mac-commands (f_port=0) or Relay payload (f_port=226).
|
// Mac-commands (f_port=0) or Relay payload (f_port=226).
|
||||||
if f_port == 0 || f_port == lrwn::LA_FPORT_RELAY {
|
if f_port == 0 || f_port == lrwn::LA_FPORT_RELAY {
|
||||||
let nwk_s_enc_key = AES128Key::from_slice(&ds.nwk_s_enc_key)?;
|
let nwk_s_enc_key = AES128Key::from_slice(&ds.nwk_s_enc_key)?;
|
||||||
self.phy_payload.decrypt_frm_payload(&nwk_s_enc_key)?;
|
if let Err(e) = self.phy_payload.decrypt_frm_payload(&nwk_s_enc_key) {
|
||||||
|
// This avoids failing in case of a corrupted mac-command in the frm_payload.
|
||||||
|
warn!(error = %e, "Decrypting frm_payload failed");
|
||||||
|
}
|
||||||
} else if !self._is_end_to_end_encrypted() {
|
} else if !self._is_end_to_end_encrypted() {
|
||||||
if let Some(app_s_key) = &ds.app_s_key {
|
if let Some(app_s_key) = &ds.app_s_key {
|
||||||
let app_s_key = AES128Key::from_slice(&app_s_key.aes_key)?;
|
let app_s_key = AES128Key::from_slice(&app_s_key.aes_key)?;
|
||||||
|
Loading…
Reference in New Issue
Block a user