File
Blob: firmware/vendor/sctp-proto/src/chunk/chunk_cookie_ack.rs
| 1 | use super::{chunk_header::*, chunk_type::*, *}; |
| 2 | |
| 3 | /// chunkCookieAck represents an SCTP Chunk of type chunkCookieAck |
| 4 | /// |
| 5 | /// 0 1 2 3 |
| 6 | /// 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 |
| 7 | /// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
| 8 | /// | Type = 11 |Chunk Flags | Length = 4 | |
| 9 | /// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
| 10 | #[derive(Debug, Clone)] |
| 11 | pub(crate) struct ChunkCookieAck; |
| 12 | |
| 13 | /// makes ChunkCookieAck printable |
| 14 | impl fmt::Display for ChunkCookieAck { |
| 15 | fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { |
| 16 | write!(f, "{}", self.header()) |
| 17 | } |
| 18 | } |
| 19 | |
| 20 | impl Chunk for ChunkCookieAck { |
| 21 | fn header(&self) -> ChunkHeader { |
| 22 | ChunkHeader { |
| 23 | typ: CT_COOKIE_ACK, |
| 24 | flags: 0, |
| 25 | value_length: self.value_length() as u16, |
| 26 | } |
| 27 | } |
| 28 | |
| 29 | fn unmarshal(raw: &Bytes) -> Result<Self> { |
| 30 | let header = ChunkHeader::unmarshal(raw)?; |
| 31 | |
| 32 | if header.typ != CT_COOKIE_ACK { |
| 33 | return Err(Error::ErrChunkTypeNotCookieAck); |
| 34 | } |
| 35 | |
| 36 | Ok(ChunkCookieAck {}) |
| 37 | } |
| 38 | |
| 39 | fn marshal_to(&self, buf: &mut BytesMut) -> Result<usize> { |
| 40 | self.header().marshal_to(buf)?; |
| 41 | Ok(buf.len()) |
| 42 | } |
| 43 | |
| 44 | fn check(&self) -> Result<()> { |
| 45 | Ok(()) |
| 46 | } |
| 47 | |
| 48 | fn value_length(&self) -> usize { |
| 49 | 0 |
| 50 | } |
| 51 | |
| 52 | fn as_any(&self) -> &(dyn Any + Send + Sync) { |
| 53 | self |
| 54 | } |
| 55 | } |