netstack3_ip/
uninstantiable.rs

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
// Copyright 2024 The Fuchsia Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

use explicit::UnreachableExt as _;
use net_types::SpecifiedAddr;
use netstack3_base::socket::SocketIpAddr;
use netstack3_base::{
    AnyDevice, DeviceIdContext, EitherDeviceId, IpDeviceAddr, IpExt, Mms, UninstantiableWrapper,
};
use netstack3_filter::Tuple;

use crate::internal::base::{BaseTransportIpContext, HopLimits, IpLayerIpExt};
use crate::internal::socket::{
    DeviceIpSocketHandler, IpSock, IpSockCreationError, IpSockSendError, IpSocketHandler, MmsError,
    RouteResolutionOptions,
};

impl<I: IpExt, C, P: DeviceIdContext<AnyDevice>> BaseTransportIpContext<I, C>
    for UninstantiableWrapper<P>
{
    type DevicesWithAddrIter<'s> = UninstantiableWrapper<core::iter::Empty<P::DeviceId>>;
    fn with_devices_with_assigned_addr<O, F: FnOnce(Self::DevicesWithAddrIter<'_>) -> O>(
        &mut self,
        _addr: SpecifiedAddr<I::Addr>,
        _cb: F,
    ) -> O {
        self.uninstantiable_unreachable()
    }
    fn get_default_hop_limits(&mut self, _device: Option<&Self::DeviceId>) -> HopLimits {
        self.uninstantiable_unreachable()
    }
    fn get_original_destination(&mut self, _tuple: &Tuple<I>) -> Option<(I::Addr, u16)> {
        self.uninstantiable_unreachable()
    }
}

impl<I: IpExt, C, P: DeviceIdContext<AnyDevice>> IpSocketHandler<I, C>
    for UninstantiableWrapper<P>
{
    fn new_ip_socket<O>(
        &mut self,
        _ctx: &mut C,
        _device: Option<EitherDeviceId<&Self::DeviceId, &Self::WeakDeviceId>>,
        _local_ip: Option<IpDeviceAddr<I::Addr>>,
        _remote_ip: SocketIpAddr<I::Addr>,
        _proto: I::Proto,
        _options: &O,
    ) -> Result<IpSock<I, Self::WeakDeviceId>, IpSockCreationError> {
        self.uninstantiable_unreachable()
    }

    fn send_ip_packet<S, O>(
        &mut self,
        _ctx: &mut C,
        _socket: &IpSock<I, Self::WeakDeviceId>,
        _body: S,
        _options: &O,
    ) -> Result<(), IpSockSendError> {
        self.uninstantiable_unreachable()
    }

    fn confirm_reachable<O>(
        &mut self,
        _bindings_ctx: &mut C,
        _socket: &IpSock<I, Self::WeakDeviceId>,
        _options: &O,
    ) {
        self.uninstantiable_unreachable()
    }
}

impl<I: IpLayerIpExt, C, P: DeviceIpSocketHandler<I, C>> DeviceIpSocketHandler<I, C>
    for UninstantiableWrapper<P>
{
    fn get_mms<O: RouteResolutionOptions<I>>(
        &mut self,
        _bindings_ctx: &mut C,
        _ip_sock: &IpSock<I, Self::WeakDeviceId>,
        _options: &O,
    ) -> Result<Mms, MmsError> {
        self.uninstantiable_unreachable()
    }
}