1// Copyright 2022 The Fuchsia Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
45use crate::prelude_internal::*;
67/// Methods from the "Platform Infrastructure Interface" group [1]
8///
9/// [1] https://openthread.io/reference/group/plat-infra-if
10pub trait InfraInterface {
11/// The infra interface driver calls this method to notify OpenThread of
12 /// the interface state changes.
13fn plat_infra_if_on_state_changed(&self, id: u32, is_running: bool);
1415/// The infra interface driver calls this method to notify OpenThread that
16 /// the discovery of NAT64 prefix is done.
17fn plat_infra_if_discover_nat64_prefix_done(&self, infra_if_idx: u32, ip6_prefix: Ip6Prefix);
18}
1920impl<T: InfraInterface + ot::Boxable> InfraInterface for ot::Box<T> {
21fn plat_infra_if_on_state_changed(&self, id: u32, is_running: bool) {
22self.as_ref().plat_infra_if_on_state_changed(id, is_running);
23 }
2425fn plat_infra_if_discover_nat64_prefix_done(&self, infra_if_idx: u32, ip6_prefix: Ip6Prefix) {
26self.as_ref().plat_infra_if_discover_nat64_prefix_done(infra_if_idx, ip6_prefix);
27 }
28}
2930impl InfraInterface for Instance {
31fn plat_infra_if_on_state_changed(&self, id: u32, is_running: bool) {
32unsafe {
33 otPlatInfraIfStateChanged(self.as_ot_ptr(), id, is_running);
34 }
35 }
3637fn plat_infra_if_discover_nat64_prefix_done(&self, infra_if_idx: u32, ip6_prefix: Ip6Prefix) {
38unsafe {
39 otPlatInfraIfDiscoverNat64PrefixDone(self.as_ot_ptr(), infra_if_idx, &ip6_prefix.into())
40 }
41 }
42}