Skip to content

Commit

Permalink
Made AID optional.
Browse files Browse the repository at this point in the history
  • Loading branch information
Frostie314159 committed Jan 18, 2025
1 parent ed5055b commit 800f5e4
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 10 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 21 additions & 9 deletions src/frames/mgmt_frame/body/assoc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ impl<ElementContainer: TryIntoCtx<Error = scroll::Error>> TryIntoCtx
pub struct AssociationResponseBody<'a, ElementContainer = ReadElements<'a>> {
pub capabilities_info: CapabilitiesInformation,
pub status_code: IEEE80211StatusCode,
pub association_id: AssociationID,
pub association_id: Option<AssociationID>,
pub elements: ElementContainer,
pub _phantom: PhantomData<&'a ()>,
}
Expand All @@ -96,13 +96,19 @@ impl<'a> TryFromCtx<'a> for AssociationResponseBody<'a> {
CapabilitiesInformation::from_bits(from.gread_with(&mut offset, Endian::Little)?);
let status_code =
IEEE80211StatusCode::from_bits(from.gread_with(&mut offset, Endian::Little)?);
let association_id = AssociationID::new_checked(
from.gread_with(&mut offset, Endian::Little)?,
)
.ok_or(scroll::Error::BadInput {
size: offset,
msg: "Association ID is out of bounds.",
})?;
let association_id = from.gread_with::<u16>(&mut offset, Endian::Little)?;
let association_id = if association_id == 0 {
None
} else {
Some(
AssociationID::new_checked(from.gread_with(&mut offset, Endian::Little)?).ok_or(
scroll::Error::BadInput {
size: offset,
msg: "Association ID is out of bounds.",
},
)?,
)
};
let elements = from.gread(&mut offset)?;

Ok((
Expand Down Expand Up @@ -137,7 +143,13 @@ impl<ElementContainer: TryIntoCtx<Error = scroll::Error>> TryIntoCtx
Endian::Little,
)?;
buf.gwrite_with(self.status_code.into_bits(), &mut offset, Endian::Little)?;
buf.gwrite_with(self.association_id.into_bits(), &mut offset, Endian::Little)?;
buf.gwrite_with(
self.association_id
.map(AssociationID::into_bits)
.unwrap_or_default(),
&mut offset,
Endian::Little,
)?;
buf.gwrite(self.elements, &mut offset)?;

Ok(offset)
Expand Down

0 comments on commit 800f5e4

Please sign in to comment.