1#![no_std]
11#![warn(
12 missing_docs,
13 unreachable_patterns,
14 clippy::useless_conversion,
15 clippy::redundant_clone,
16 clippy::precedence
17)]
18
19extern crate alloc;
20
21mod context;
22mod convert;
23mod counters;
24mod data_structures;
25mod device;
26mod error;
27mod event;
28mod frame;
29mod inspect;
30mod ip;
31mod map_deref;
32mod matchers;
33mod num;
34mod port_alloc;
35mod resource_references;
36mod rng;
37mod settings;
38mod tcp;
39mod test_only;
40mod time;
41mod uninstantiable;
42mod work_queue;
43
44pub use context::{BuildableCoreContext, ContextPair, ContextProvider, CtxPair};
45pub use convert::{BidirectionalConverter, OwnedOrRefsBidirectionalConverter};
46pub use counters::{
47 Counter, CounterCollection, CounterCollectionSpec, CounterContext, CounterRepr,
48 ResourceCounterContext,
49};
50pub use data_structures::token_bucket::TokenBucket;
51pub use device::address::{
52 AssignedAddrIpExt, IpAddressId, IpDeviceAddr, IpDeviceAddressIdContext, Ipv4DeviceAddr,
53 Ipv6DeviceAddr, WeakIpAddressId,
54};
55pub use device::link::{LinkAddress, LinkDevice, LinkUnicastAddress};
56pub use device::{
57 AnyDevice, Device, DeviceIdAnyCompatContext, DeviceIdContext, DeviceIdentifier, EitherDeviceId,
58 StrongDeviceIdentifier, WeakDeviceIdentifier,
59};
60pub use error::{
61 AddressResolutionFailed, ErrorAndSerializer, ExistsError, LocalAddressError, NotFoundError,
62 NotSupportedError, RemoteAddressError, SocketError, ZonedAddressError,
63};
64pub use event::EventContext;
65pub use frame::{
66 CoreTxMetadataContext, FrameDestination, ReceivableFrameMeta, RecvFrameContext,
67 RecvIpFrameMeta, SendFrameContext, SendFrameError, SendFrameErrorReason, SendableFrameMeta,
68 TxMetadata, TxMetadataBindingsTypes,
69};
70pub use inspect::{Inspectable, InspectableValue, Inspector, InspectorDeviceExt, InspectorExt};
71pub use ip::{
72 BroadcastIpExt, IcmpErrorCode, IcmpIpExt, Icmpv4ErrorCode, Icmpv6ErrorCode, IpExt,
73 IpTypesIpExt, Mark, MarkDomain, MarkStorage, Marks, Mms, WrapBroadcastMarker,
74};
75pub use map_deref::{MapDeref, MapDerefExt};
76pub use matchers::{
77 AddressMatcher, AddressMatcherEither, AddressMatcherType, BoundInterfaceMatcher,
78 InterfaceMatcher, InterfaceProperties, IpSocketMatcher, IpSocketProperties,
79 IpSocketPropertiesMatcher, MarkInDomainMatcher, MarkMatcher, MarkMatchers, Matcher,
80 MatcherBindingsTypes, MaybeSocketTransportProperties, PortMatcher, SocketCookieMatcher,
81 SocketTransportProtocolMatcher, SubnetMatcher, TcpSocketMatcher, TcpSocketProperties,
82 TcpSocketState, TcpStateMatcher, UdpSocketMatcher, UdpSocketProperties, UdpSocketState,
83 UdpStateMatcher,
84};
85pub use num::PositiveIsize;
86pub use port_alloc::{EphemeralPort, PortAllocImpl, simple_randomized_port_alloc};
87pub use resource_references::{
88 DeferredResourceRemovalContext, ReferenceNotifiers, ReferenceNotifiersExt,
89 RemoveResourceResult, RemoveResourceResultWithContext,
90};
91pub use rng::RngContext;
92pub use settings::{BufferSizeSettings, SettingsContext};
93pub use tcp::base::{Control, EffectiveMss, FragmentedPayload, Mss, MssSizeLimiters};
94pub use tcp::segment::{
95 HandshakeOptions, Options, Payload, PayloadLen, ResetOptions, SackBlock, SackBlocks, Segment,
96 SegmentHeader, SegmentOptions, VerifiedTcpSegment,
97};
98pub use tcp::seqnum::{SeqNum, UnscaledWindowSize, WindowScale, WindowSize};
99pub use tcp::timestamp::{
100 Milliseconds, RxTimestampOption, Timestamp, TimestampOption, TxTimestampOption, Unitless,
101};
102pub use test_only::TestOnlyPartialEq;
103pub use time::local_timer_heap::LocalTimerHeap;
104pub use time::{
105 AtomicInstant, CoreTimerContext, HandleableTimer, Instant, InstantBindingsTypes,
106 InstantContext, IntoCoreTimerCtx, NestedIntoCoreTimerCtx, TimerBindingsTypes, TimerContext,
107 TimerHandler,
108};
109pub use uninstantiable::{Uninstantiable, UninstantiableWrapper};
110pub use work_queue::WorkQueueReport;
111
112pub mod ref_counted_hash_map {
114 pub use crate::data_structures::ref_counted_hash_map::{
115 InsertResult, RefCountedHashMap, RefCountedHashSet, RemoveResult,
116 };
117}
118
119pub mod rcu {
121 pub use crate::data_structures::rcu::{ReadGuard, SynchronizedWriterRcu, WriteGuard};
122}
123
124pub mod socket {
126 mod address;
127 mod base;
128 mod cookie;
129 pub(crate) mod sndbuf;
130
131 pub use address::{
132 AddrIsMappedError, AddrVecIter, ConnAddr, ConnInfoAddr, ConnIpAddr, DualStackConnIpAddr,
133 DualStackListenerIpAddr, DualStackLocalIp, DualStackRemoteIp, ListenerAddr, ListenerIpAddr,
134 SocketIpAddr, StrictlyZonedAddr,
135 };
136 pub use base::{
137 AddrEntry, AddrVec, Bound, BoundSocketMap, DualStackIpExt, DualStackTuple, EitherStack,
138 FoundSockets, IncompatibleError, InsertError, Inserter, Listener, ListenerAddrInfo,
139 MaybeDualStack, NotDualStackCapableError, RemoveResult, ReusePortOption,
140 SetDualStackEnabledError, SharingDomain, Shutdown, ShutdownType, SocketAddrType,
141 SocketDeviceUpdate, SocketDeviceUpdateNotAllowedError, SocketIpAddrExt, SocketIpExt,
142 SocketMapAddrSpec, SocketMapAddrStateSpec, SocketMapAddrStateUpdateSharingSpec,
143 SocketMapConflictPolicy, SocketMapStateSpec, SocketMapUpdateSharingPolicy,
144 SocketStateEntry, SocketZonedAddrExt, UpdateSharingError,
145 };
146 pub use cookie::SocketCookie;
147 pub use sndbuf::{
148 SendBufferFullError, SendBufferSpace, SendBufferTracking, SocketWritableListener,
149 };
150}
151
152pub mod socketmap {
155 pub use crate::data_structures::socketmap::{
156 Entry, IterShadows, OccupiedEntry, SocketMap, Tagged, VacantEntry,
157 };
158}
159
160pub mod sync {
162 pub use netstack3_sync::rc::{
167 DebugReferences, DynDebugReferences, MapNotifier as MapRcNotifier, Notifier as RcNotifier,
168 Primary as PrimaryRc, ResourceToken, ResourceTokenValue, Strong as StrongRc,
169 Weak as WeakRc,
170 };
171 pub use netstack3_sync::{LockGuard, Mutex, RwLock, RwLockReadGuard, RwLockWriteGuard};
172}
173
174#[cfg(any(test, feature = "testutils"))]
176pub mod testutil {
177 mod addr;
178 mod benchmarks;
179 mod fake_bindings;
180 mod fake_core;
181 mod fake_network;
182 mod misc;
183 mod monotonic_id;
184
185 pub use crate::device::address::testutil::FakeWeakAddressId;
186 pub use crate::device::link::testutil::{FakeLinkAddress, FakeLinkDevice, FakeLinkDeviceId};
187 pub use crate::device::testutil::{
188 FakeDeviceClass, FakeDeviceId, FakeReferencyDeviceId, FakeStrongDeviceId, FakeWeakDeviceId,
189 MultipleDevicesId, MultipleDevicesIdState,
190 };
191 pub use crate::event::testutil::FakeEventCtx;
192 pub use crate::frame::testutil::{FakeFrameCtx, FakeTxMetadata, WithFakeFrameContext};
193 pub use crate::matchers::testutil::FakeMatcherDeviceId;
194 pub use crate::rng::testutil::{FakeCryptoRng, new_rng, run_with_many_seeds};
195 pub use crate::settings::testutil::AlwaysDefaultsSettingsContext;
196 pub use crate::socket::sndbuf::testutil::FakeSocketWritableListener;
197 pub use crate::time::testutil::{
198 FakeAtomicInstant, FakeInstant, FakeInstantCtx, FakeTimerCtx, FakeTimerCtxExt, FakeTimerId,
199 InstantAndData, WithFakeTimerContext,
200 };
201 pub use addr::{TEST_ADDRS_V4, TEST_ADDRS_V6, TestAddrs, TestDualStackIpExt, TestIpExt};
202 pub use benchmarks::{Bencher, RealBencher, TestBencher};
203 pub use fake_bindings::FakeBindingsCtx;
204 pub use fake_core::FakeCoreCtx;
205 pub use fake_network::{
206 FakeNetwork, FakeNetworkLinks, FakeNetworkSpec, PendingFrame, PendingFrameData, StepResult,
207 };
208 pub use misc::{assert_empty, set_logger_for_test};
209 pub use monotonic_id::MonotonicIdentifier;
210}
211
212#[cfg(benchmark)]
214pub mod benchmarks {
215 pub fn add_benches(b: criterion::Benchmark) -> criterion::Benchmark {
217 crate::data_structures::token_bucket::benchmarks::add_benches(b)
218 }
219}