diff --git a/asn-compiler/src/parser/asn/structs/types/base.rs b/asn-compiler/src/parser/asn/structs/types/base.rs index c924c49..b530bc8 100644 --- a/asn-compiler/src/parser/asn/structs/types/base.rs +++ b/asn-compiler/src/parser/asn/structs/types/base.rs @@ -3,6 +3,7 @@ #[derive(Debug, Clone)] pub(crate) enum NamedValue { Number(String), + #[allow(dead_code)] ValueRef(String), } diff --git a/codecs/src/per/mod.rs b/codecs/src/per/mod.rs index 44d30bc..a8a5c62 100644 --- a/codecs/src/per/mod.rs +++ b/codecs/src/per/mod.rs @@ -78,14 +78,24 @@ impl PerCodecData { .iter() .all(|b| b == false) { - Err(PerCodecError::new( + // Issue 117: Sometimes the sender doesn't send the bits correctly. + // Accept it but log. + log::warn!( + "{} Padding bits {} at Offset {} not all '0'", + remaining, + &self.bits[self.decode_offset..self.decode_offset + remaining], + self.decode_offset + ); + self.decode_offset += remaining; + Ok(()) + /* Err(PerCodecError::new( PerCodecErrorCause::InvalidAlignment, format!( "{} Padding bits at Offset {} not all '0'.", remaining, self.decode_offset, ) .as_str(), - )) + )) */ } else { self.decode_offset += remaining; Ok(()) diff --git a/examples/tests/13-ngap.rs b/examples/tests/13-ngap.rs index b3123d5..dcd5ca7 100644 --- a/examples/tests/13-ngap.rs +++ b/examples/tests/13-ngap.rs @@ -35,4 +35,15 @@ fn main() { let mut codec_data = PerCodecData::from_slice_aper(&response_data); let ngap_pdu = ngap::NGAP_PDU::aper_decode(&mut codec_data); eprintln!("ngap_pdu: {:?}", ngap_pdu); + + let issue_117_data: [u8; 57] = [ + 0x00, 0x15, 0x00, 0x35, 0x00, 0x00, 0x04, 0x00, 0x1b, 0x00, 0x08, 0x00, 0x02, 0xf8, 0x39, + 0x03, 0x80, 0x00, 0x04, 0x00, 0x52, 0x40, 0x09, 0x03, 0x00, 0x4e, 0x65, 0x72, 0x76, 0x69, + 0x6f, 0x6e, 0x00, 0x66, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x02, 0xf8, 0x39, + 0x00, 0x00, 0x10, 0x08, 0x00, 0x00, 0x01, 0x00, 0x15, 0x40, 0x01, 0x40, + ]; + + let mut codec_data = PerCodecData::from_slice_aper(&issue_117_data); + let ngap_pdu = ngap::NGAP_PDU::aper_decode(&mut codec_data).expect("Error decoding NGAP PDU"); + eprintln!("Decoded NGAP PDU: {:#?}", ngap_pdu); }