stackforge_core/layer/tcp/mod.rs
1//! TCP (Transmission Control Protocol) layer module.
2//!
3//! This module implements the TCP protocol (RFC 793), providing packet parsing (via `TcpLayer`),
4//! construction (via `TcpBuilder`), options handling, and checksum verification.
5//!
6//! # Features
7//!
8//! - Zero-copy parsing with lazy field access
9//! - Complete TCP options support (MSS, Window Scale, SACK, Timestamps, etc.)
10//! - TCP-AO (Authentication Option) support per RFC 5925
11//! - Checksum calculation with IPv4/IPv6 pseudo-header
12//! - Service name resolution for well-known ports
13//! - Builder pattern for packet construction
14//!
15//! # Example
16//!
17//! ```rust
18//! use stackforge_core::layer::tcp::{TcpBuilder, TcpFlags};
19//!
20//! // Build a SYN packet
21//! let packet = TcpBuilder::new()
22//! .src_port(12345)
23//! .dst_port(80)
24//! .seq(1000)
25//! .syn()
26//! .window(65535)
27//! .mss(1460)
28//! .build();
29//! ```
30
31// Submodules
32pub mod builder;
33pub mod checksum;
34pub mod flags;
35pub mod header;
36pub mod options;
37pub mod services;
38
39// Re-export primary types for easier access
40pub use builder::TcpBuilder;
41pub use checksum::{tcp_checksum, tcp_checksum_ipv4, verify_tcp_checksum};
42pub use flags::TcpFlags;
43pub use header::{
44 FIELDS as TCP_FIELDS, TCP_MAX_HEADER_LEN, TCP_MIN_HEADER_LEN, TcpLayer, offsets as tcp_offsets,
45};
46pub use options::{
47 TcpAoValue, TcpOption, TcpOptionKind, TcpOptions, TcpOptionsBuilder, TcpSackBlock, TcpTimestamp,
48};
49pub use services::{TCP_SERVICES, service_name, service_port};