From a2b7543b87ed47d5cc2ab82595b0addc97b09fbb Mon Sep 17 00:00:00 2001 From: Oleksandr Mazur Date: Fri, 20 Sep 2024 14:25:06 +0300 Subject: [PATCH] AP Parser: fetch serial both from state:params:serial and state:serial Signed-off-by: Oleksandr Mazur --- src/cgw_tls.rs | 14 +++++++++----- src/cgw_ucentral_ap_parser.rs | 25 ++++++++++++++++++++----- 2 files changed, 29 insertions(+), 10 deletions(-) diff --git a/src/cgw_tls.rs b/src/cgw_tls.rs index 7aa3457..19b9f15 100644 --- a/src/cgw_tls.rs +++ b/src/cgw_tls.rs @@ -37,8 +37,10 @@ pub async fn cgw_tls_read_certs(cert_file: &str) -> Result Result info!("err {e}"), - Ok(_) => () + Ok(_) => (), } if let Ok(d) = BASE64_STANDARD.decode(buffer.clone()) { - info!("Private key file {} is base64 encoded, trying to use decoded.", - private_key_file); + info!( + "Private key file {} is base64 encoded, trying to use decoded.", + private_key_file + ); d } else { buffer diff --git a/src/cgw_ucentral_ap_parser.rs b/src/cgw_ucentral_ap_parser.rs index 4d64d8a..7c65a68 100644 --- a/src/cgw_ucentral_ap_parser.rs +++ b/src/cgw_ucentral_ap_parser.rs @@ -448,11 +448,26 @@ fn parse_state_event_data( "Parsed, decompressed state message but failed to find state object", )); } else if let Value::Object(state_map) = ¶ms["state"] { - let serial = MacAddress::from_str( - params["serial"] - .as_str() - .ok_or_else(|| Error::UCentralParser("Failed to parse mac address"))?, - )?; + let serial = { + if let Value::String(_) = ¶ms["serial"] { + MacAddress::from_str( + params["serial"] + .as_str() + .ok_or_else(|| Error::UCentralParser("Failed to parse mac address"))?, + )? + } else if let Value::String(_) = &state_map["serial"] { + MacAddress::from_str( + state_map["serial"] + .as_str() + .ok_or_else(|| Error::UCentralParser("Failed to parse mac address"))?, + )? + } else { + return Err(Error::UCentralParser( + "Failed to parse state: mac address is missing", + )); + } + }; + let mut lldp_links: HashMap> = HashMap::new(); let mut clients_links: HashMap<