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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
//! # RuVix Network Stack
//!
//! This crate provides a minimal networking stack for the RuVix Cognition Kernel
//! as specified in ADR-087 Phase E. It is designed to be `no_std` compatible with
//! optional alloc support for dynamic allocation.
//!
//! ## Network Layers
//!
//! | Layer | Module | Purpose |
//! |-------|--------|---------|
//! | **Link** | `ethernet` | Ethernet II frame handling |
//! | **Network** | `arp`, `ipv4`, `icmp` | Address resolution and IP routing |
//! | **Transport** | `udp` | Connectionless datagram transport |
//!
//! ## Architecture
//!
//! ```text
//! +------------------+
//! | Application |
//! +------------------+
//! |
//! +------------------+
//! | UDP |
//! +------------------+
//! |
//! +------------------+
//! | IPv4 + ICMP |
//! +------------------+
//! |
//! +------------------+
//! | ARP Resolution |
//! +------------------+
//! |
//! +------------------+
//! | Ethernet |
//! +------------------+
//! |
//! +------------------+
//! | NetworkDevice | <-- Hardware abstraction
//! +------------------+
//! ```
//!
//! ## Features
//!
//! - `std`: Enable standard library support
//! - `alloc`: Enable alloc crate support for heap allocation
//!
//! ## Example
//!
//! ```no_run
//! use ruvix_net::{MacAddress, Ipv4Addr, UdpSocket, NetworkStack};
//!
//! // Create a network stack with device
//! // let stack = NetworkStack::new(device, mac, ip);
//!
//! // Send UDP datagram
//! // let socket = stack.udp_bind(8080).unwrap();
//! // socket.send_to(&data, dest_addr, dest_port);
//! ```
extern crate alloc;
extern crate std;
// Re-exports for convenience
pub use ;
pub use NetworkDevice;
pub use NetError;
pub use ;
pub use ;
pub use ;
pub use NetworkStack;
pub use ;
/// Maximum Transmission Unit (standard Ethernet).
pub const MTU: usize = 1500;
/// Ethernet header size in bytes.
pub const ETHERNET_HEADER_SIZE: usize = 14;
/// IPv4 header minimum size in bytes.
pub const IPV4_HEADER_MIN_SIZE: usize = 20;
/// UDP header size in bytes.
pub const UDP_HEADER_SIZE: usize = 8;
/// ICMP header size in bytes.
pub const ICMP_HEADER_SIZE: usize = 8;
/// ARP packet size in bytes (for Ethernet/IPv4).
pub const ARP_PACKET_SIZE: usize = 28;
/// Maximum UDP payload size for standard Ethernet.
pub const MAX_UDP_PAYLOAD: usize = MTU - IPV4_HEADER_MIN_SIZE - UDP_HEADER_SIZE;