network_types/
sctp.rs

1use core::mem;
2
3#[repr(C)]
4#[derive(Debug, Copy, Clone)]
5#[cfg_attr(feature = "serde", derive(::serde::Serialize, ::serde::Deserialize))]
6pub struct SctpHdr {
7    /// Source port in network byte order (big-endian)
8    pub src: [u8; 2],
9
10    /// Destination port in network byte order (big-endian)
11    pub dst: [u8; 2],
12
13    /// Verification tag
14    pub verification_tag: [u8; 4],
15
16    /// Checksum
17    pub checksum: [u8; 4],
18}
19
20impl SctpHdr {
21    /// The size of the Sctp header in bytes (12 bytes).
22    pub const LEN: usize = mem::size_of::<SctpHdr>();
23}
24
25#[cfg(test)]
26mod test {
27    use super::SctpHdr;
28    use core::mem;
29
30    #[test]
31    fn test_sctp_hdr_size() {
32        // SctpHdr should be exactly 12 bytes
33        assert_eq!(SctpHdr::LEN, 12);
34        assert_eq!(SctpHdr::LEN, mem::size_of::<SctpHdr>());
35    }
36}