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
//! ULE — Unidirectional Lightweight Encapsulation (RFC 4326) + Extension
//! Headers (RFC 5163): IP over MPEG-2 Transport Streams.
//!
//! ULE encapsulates a network-layer PDU (an IP datagram, Ethernet frame, etc.)
//! into a **SubNetwork Data Unit** ([`Sndu`]) and maps it into the payload of
//! MPEG-2 TS packets on a single PID (RFC 4326 §3, §4).
//!
//! This crate implements:
//!
//! - [`Sndu`] — the SNDU wire structure (RFC 4326 §4, Figure 1): the `D` bit +
//! 15-bit `Length` + 16-bit `Type`, an optional 6-byte Destination NPA
//! address (present iff `D = 0`), the PDU, and the 4-byte CRC-32 trailer.
//! `Length` and the CRC are **recomputed on serialize** from the typed
//! fields — there is no raw passthrough.
//! - [`TypeField`] — the §4.4 split at `0x0600`: a Next-Header (`H-LEN`/
//! `H-Type`) below, an EtherType at or above.
//! - [`ExtensionHeader`] / [`PayloadChain`] — the chained extension-header
//! model (RFC 4326 §5, RFC 5163 §3): Optional headers (`H-LEN = 1..=5`,
//! total `2·H-LEN` bytes) and a terminating EtherType or Mandatory header
//! (Test-SNDU 0x00, Bridged-Frame 0x01, TS-Concat 0x02, PDU-Concat 0x03).
//! - [`UleReceiver`] — TS-packet de-fragmentation/reassembly (RFC 4326 §6, §7):
//! PUSI + 1-byte Payload Pointer handling, fragmentation across packets,
//! packing of multiple SNDUs per packet, and End-Indicator / 0xFF padding.
//!
//! The CRC-32 is the MPEG-2 / DSM-CC CRC (poly `0x04C11DB7`, init
//! `0xFFFFFFFF`, MSB-first, no reflection, no final XOR — RFC 4326 §4.6),
//! reused from [`dvb_common::crc32_mpeg2`]; this is verified byte-exact against
//! RFC 4326 Appendix B's worked example in the crate's fixture test.
//!
//! `#![no_std]` + `alloc`; depends only on `dvb-common`.
//!
//! # Examples
//!
//! Build an IPv4 SNDU (L2 filtering, `D = 0`) from typed fields and round-trip
//! it:
//!
//! ```
//! use dvb_ule::{Sndu, TypeField};
//!
//! let pdu = [0x45u8, 0x00, 0x00, 0x14]; // start of an IPv4 header
//! let sndu = Sndu::new(
//! TypeField::EtherType(0x0800),
//! Some([0x00, 0x01, 0x02, 0x03, 0x04, 0x05]),
//! &pdu,
//! );
//! let mut buf = vec![0u8; sndu.serialized_len()];
//! sndu.serialize_into(&mut buf).unwrap();
//! assert_eq!(Sndu::parse(&buf).unwrap(), sndu);
//! ```
// Runnable examples, embedded so they render on docs.rs and stay in sync with
// the actual `examples/*.rs` files (shown, not compiled).
extern crate alloc;
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;