Skip to main content

network_types/
sctp.rs

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