Skip to content

Commit

Permalink
Merge pull request #18 from JulianSchmid/ci-fix
Browse files Browse the repository at this point in the history
Correct CI error
  • Loading branch information
JulianSchmid authored Sep 23, 2024
2 parents 320f8c2 + 65cf3f5 commit 7e472ce
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 8 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "someip_parse"
version = "0.6.1"
version = "0.6.2"
edition = "2021"
rust-version = "1.60"
authors = ["Julian Schmid <[email protected]>"]
Expand Down
2 changes: 1 addition & 1 deletion examples/count_messages_by_id.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ struct Stats {
}

#[derive(Debug)]
enum Error {
pub enum Error {
IoError(std::io::Error),
PcapError(rpcap::PcapError),
}
Expand Down
2 changes: 1 addition & 1 deletion examples/print_messages.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ fn main() -> Result<(), Error> {
}

#[derive(Debug)]
enum Error {
pub enum Error {
IoError(std::io::Error),
PcapError(rpcap::PcapError),
}
Expand Down
1 change: 1 addition & 0 deletions proptest-regressions/someip_header.txt
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
cc ba538a3dd744b011673fdb42ef76a3b4f53f5c21fc1f42d044f9ca7d53ec720b
cc 04f8332adeb3f83b7ad83f10f8e0da57af3ff865568e2bd7a61ed38b28616e2
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ pub const SOMEIP_LEN_OFFSET_TO_PAYLOAD: u32 = 4 * 2; // 2x 32bits

///Maximum payload length supported by some ip. This is NOT the maximum length that is supported when
///sending packets over UDP. This constant is based on the limitation of the length field data type (uint32).
pub const SOMEIP_MAX_PAYLOAD_LEN: u32 = std::u32::MAX - SOMEIP_LEN_OFFSET_TO_PAYLOAD;
pub const SOMEIP_MAX_PAYLOAD_LEN: u32 = u32::MAX - SOMEIP_LEN_OFFSET_TO_PAYLOAD;

/// The maximum payload size of an SOMEIP UDP message.
///
Expand Down
25 changes: 23 additions & 2 deletions src/sd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,10 @@ impl SdHeader {

#[inline]
#[cfg(any(target_pointer_width = "32", target_pointer_width = "64"))]
pub fn read_with_flag<T: Read + Seek>(reader: &mut T, discard_unknown_option: bool) -> Result<Self, SdReadError> {
pub fn read_with_flag<T: Read + Seek>(
reader: &mut T,
discard_unknown_option: bool,
) -> Result<Self, SdReadError> {
const HEADER_LENGTH: usize = 1 + 3 + 4; // flags + rev + entries length
let mut header_bytes: [u8; HEADER_LENGTH] = [0; HEADER_LENGTH];
reader.read_exact(&mut header_bytes)?;
Expand Down Expand Up @@ -958,7 +961,10 @@ impl SdOption {

/// Read the value from a [`std::io::Read`] source.
#[inline]
pub fn read_with_flag<T: Read + Seek>(reader: &mut T, discard_unknown_option: bool) -> Result<(u16, Self), SdReadError> {
pub fn read_with_flag<T: Read + Seek>(
reader: &mut T,
discard_unknown_option: bool,
) -> Result<(u16, Self), SdReadError> {
use self::sd_options::*;
use self::SdOption::*;
use SdReadError::*;
Expand Down Expand Up @@ -1602,6 +1608,21 @@ mod tests_sd_option {
let result = SdOption::read(&mut cursor);
assert_matches!(result, Err(SdReadError::UnknownSdOptionType(0xFF)));
}
// unknown option type (non discardable, discard option set)
{
let buffer = [0x00, 0x01, 0xff, 0x00];
let mut cursor = std::io::Cursor::new(buffer);
let (len, header) = SdOption::read_with_flag(&mut cursor, true).unwrap();
assert_eq!(
header,
UnknownDiscardableOption {
length: 1,
option_type: 0xff,
}
.into()
);
assert_eq!(4, len);
}
// unknown option type (discardable)
{
let buffer = [0x00, 0x01, 0xff, 0b1000_0000];
Expand Down
4 changes: 2 additions & 2 deletions src/someip_header.rs
Original file line number Diff line number Diff line change
Expand Up @@ -567,15 +567,15 @@ mod tests {
header.set_method_or_event_id(id);

assert_eq!(id, header.event_or_method_id());
assert_eq!(id > 0x8000, header.is_event());
assert_eq!(id >= 0x8000, header.is_event());

//serialize and check the slice methods
let mut buffer = Vec::new();
header.write_raw(&mut buffer).unwrap();
buffer.write(&packet.1[..]).unwrap();
let slice = SomeipMsgSlice::from_slice(&buffer[..]).unwrap();

assert_eq!(id > 0x8000, slice.is_event());
assert_eq!(id >= 0x8000, slice.is_event());
assert_eq!(id, slice.event_or_method_id());
}
}
Expand Down

0 comments on commit 7e472ce

Please sign in to comment.