34 #ifndef INFRA_LINK_SELECTOR_HPP_
35 #define INFRA_LINK_SELECTOR_HPP_
44 #include <openthread/backbone_router_ftd.h>
51 #if OTBR_ENABLE_VENDOR_INFRA_LINK_SELECT
59 extern "C" const char *otbrVendorInfraLinkSelect(
void);
69 class InfraLinkSelector :
public MainloopProcessor,
private NonCopyable
78 explicit InfraLinkSelector(std::vector<const char *> aInfraLinkNames);
84 ~InfraLinkSelector(
void);
101 const char *Select(
void);
108 enum LinkState : uint8_t
119 LinkState mState = kInvalid;
120 Clock::time_point mLastRunningTime;
121 bool mWasUpAndRunning =
false;
123 bool Update(LinkState aState);
126 static constexpr
const char *kDefaultInfraLinkName =
"";
127 static constexpr
auto kInfraLinkSelectionDelay = Milliseconds(10000);
129 const char *SelectGeneric(
void);
131 static const char *LinkStateToString(LinkState aState);
132 static LinkState QueryInfraLinkState(
const char *aInfraLinkName);
133 void Update(MainloopContext &aMainloop)
override;
134 void Process(
const MainloopContext &aMainloop)
override;
135 void ReceiveNetLinkMessage(
void);
136 void HandleInfraLinkStateChange(uint32_t aInfraLinkIndex);
138 std::vector<const char *> mInfraLinkNames;
139 std::map<const char *, LinkInfo> mInfraLinkInfos;
140 int mNetlinkSocket = -1;
141 const char * mCurrentInfraLink =
nullptr;
142 TaskRunner mTaskRunner;
143 bool mRequireReselect =
true;
151 #endif // INFRA_LINK_SELECTOR_HPP_