1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
//! SCTP protocol implementation.
//!
//! SCTP layers compose with the same packet builder surface as other transports:
//! `Ipv4 / Sctp / ...`, `compile()`, direct L3 decode, `summary()`, and typed
//! layer inspection all stay offline until a caller chooses an explicit live
//! wire path.
//!
//! ```rust
//! use crafter::prelude::*;
//! use std::net::Ipv4Addr;
//!
//! # fn main() -> crafter::Result<()> {
//! let packet = Ipv4::new()
//! .src(Ipv4Addr::new(192, 0, 2, 94))
//! .dst(Ipv4Addr::new(198, 51, 100, 94))
//! / Sctp::data(
//! 0x0102_0394,
//! 1,
//! 1,
//! SCTP_PPID_WEBRTC_STRING,
//! b"hello-sctp".to_vec(),
//! )
//! .sport(21_094)
//! .dport(21_095)
//! .vtag(0x1122_3394);
//!
//! let compiled = packet.compile()?;
//! let decoded = Packet::decode_from_l3(NetworkLayer::Ipv4, compiled.as_bytes())?;
//! let sctp = decoded.layer::<Sctp>().expect("SCTP layer");
//!
//! assert_eq!(sctp.checksum_status(), SctpChecksumStatus::Valid);
//! assert_eq!(sctp.chunk_count(), 1);
//! assert!(decoded.summary().contains("Ipv4("));
//! assert!(decoded.summary().contains("Sctp("));
//! assert!(decoded.summary().contains("chunks=1[DATA]"));
//! # Ok(())
//! # }
//! ```
//!
//! Explicit field overrides survive compilation, including intentionally wrong
//! SCTP checksums for negative testing.
//!
//! ```rust
//! use crafter::prelude::*;
//! use std::net::Ipv4Addr;
//!
//! # fn main() -> crafter::Result<()> {
//! let packet = Ipv4::new()
//! .src(Ipv4Addr::new(192, 0, 2, 95))
//! .dst(Ipv4Addr::new(198, 51, 100, 95))
//! / Sctp::data(0x0102_0395, 2, 1, SCTP_PPID_WEBRTC_STRING, b"override".to_vec())
//! .sport(21_096)
//! .dport(21_097)
//! .vtag(0x1122_3395)
//! .checksum(0x0102_0304);
//!
//! let compiled = packet.compile()?;
//! let decoded = Packet::decode_from_l3(NetworkLayer::Ipv4, compiled.as_bytes())?;
//! let sctp = decoded.layer::<Sctp>().expect("SCTP layer");
//!
//! assert_eq!(sctp.checksum_value(), Some(0x0102_0304));
//! assert_eq!(sctp.checksum_status(), SctpChecksumStatus::Invalid);
//! assert!(decoded.summary().contains("checksum=0x01020304"));
//! assert!(decoded.summary().contains("checksum_status=invalid"));
//! # Ok(())
//! # }
//! ```
pub use *;
pub use SctpChecksumStatus;
pub use ;
pub use *;
pub use *;
pub use append_sctp_packet_with_registry;
pub use ;
pub use ;
pub use *;