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