File
Blob: firmware/vendor/sctp-proto/src/param/param_forward_tsn_supported.rs
| 1 | use super::{param_header::*, param_type::*, *}; |
| 2 | |
| 3 | /// At the initialization of the association, the sender of the INIT or |
| 4 | /// INIT ACK chunk MAY include this OPTIONAL parameter to inform its peer |
| 5 | /// that it is able to support the Forward TSN chunk |
| 6 | /// |
| 7 | /// 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 |
| 8 | ///+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
| 9 | ///| Parameter Type = 49152 | Parameter Length = 4 | |
| 10 | ///+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
| 11 | #[derive(Default, Debug, Clone, PartialEq)] |
| 12 | pub(crate) struct ParamForwardTsnSupported; |
| 13 | |
| 14 | impl fmt::Display for ParamForwardTsnSupported { |
| 15 | fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { |
| 16 | write!(f, "{}", self.header()) |
| 17 | } |
| 18 | } |
| 19 | |
| 20 | impl Param for ParamForwardTsnSupported { |
| 21 | fn header(&self) -> ParamHeader { |
| 22 | ParamHeader { |
| 23 | typ: ParamType::ForwardTsnSupp, |
| 24 | value_length: self.value_length() as u16, |
| 25 | } |
| 26 | } |
| 27 | |
| 28 | fn unmarshal(raw: &Bytes) -> Result<Self> { |
| 29 | let _ = ParamHeader::unmarshal(raw)?; |
| 30 | Ok(ParamForwardTsnSupported {}) |
| 31 | } |
| 32 | |
| 33 | fn marshal_to(&self, buf: &mut BytesMut) -> Result<usize> { |
| 34 | self.header().marshal_to(buf)?; |
| 35 | Ok(buf.len()) |
| 36 | } |
| 37 | |
| 38 | fn value_length(&self) -> usize { |
| 39 | 0 |
| 40 | } |
| 41 | |
| 42 | fn clone_to(&self) -> Box<dyn Param + Send + Sync> { |
| 43 | Box::new(self.clone()) |
| 44 | } |
| 45 | |
| 46 | fn as_any(&self) -> &(dyn Any + Send + Sync) { |
| 47 | self |
| 48 | } |
| 49 | } |