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
//! Binary IPFIX wire encoder per RFC 7011 / 7012.
//!
//! Gated by the `ipfix-export` Cargo feature. Turns the
//! typed [`crate::FlowRecord`] into RFC 7011 Message bytes
//! suitable for transport over UDP, SCTP, or a file. The
//! transport layer itself (socket I/O, template
//! retransmission timer, sequence-number bookkeeping across
//! reconnects) is **out of scope** for this module — it
//! produces complete Message byte buffers and trusts the
//! caller to push them on the wire.
//!
//! # Why this is in flowscope
//!
//! flowscope already owns the typed `FlowRecord` and every
//! emitter that produces it. Adding the binary IPFIX
//! emitter here keeps the "every emitter is a view over
//! FlowRecord" invariant intact and avoids inverting the
//! flowscope/netring dependency direction. Pure byte
//! serialization, no runtime requirement.
//!
//! # Quick start
//!
//! ```rust,ignore
//! use flowscope::FlowRecord;
//! use flowscope::ipfix::wire::{
//! MessageBuilder, TemplateRegistry,
//! FLOWSCOPE_TEMPLATE_FLOW_IPV4,
//! };
//!
//! let mut reg = TemplateRegistry::new(0xDEAD_BEEF);
//! reg.register(FLOWSCOPE_TEMPLATE_FLOW_IPV4.clone());
//!
//! // Round 1: emit the template definition.
//! let mut msg = MessageBuilder::new(®, 1, 1700000000);
//! msg.add_template_set(&[FLOWSCOPE_TEMPLATE_FLOW_IPV4.template_id])?;
//! let bytes = msg.finalize();
//! // Send `bytes` over UDP/SCTP.
//!
//! // Round 2: emit data records under the template.
//! let mut msg = MessageBuilder::new(®, 2, 1700000001);
//! msg.add_data_record(&rec, FLOWSCOPE_TEMPLATE_FLOW_IPV4.template_id)?;
//! let bytes = msg.finalize();
//! ```
//!
//! # Limits
//!
//! - Only the most-common abstract types (unsigned8/16/32/64,
//! ipv4Address, ipv6Address, dateTimeMilliseconds) are
//! emitted. The exotic IE 351 (`layer2SegmentId`,
//! 8 bytes) plus variable-length string types
//! (`applicationName`) ship in the default templates'
//! field list but skip emission with a zero-length
//! placeholder when absent from the record.
//! - No fixed-MTU truncation logic. Callers building large
//! messages must check `MessageBuilder::current_length()`
//! and split themselves.
//! - No Options Templates (Template Set type 3) yet.
pub use ;
pub use ;
pub use ;