Skip to content

Commit

Permalink
Replace local vars with nl80211 protocol state.
Browse files Browse the repository at this point in the history
  • Loading branch information
abeltrano committed Jan 11, 2024
1 parent 37883f7 commit 2ba29af
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -95,29 +95,8 @@ AccessPointDiscoveryAgentOperationsNetlink::Start(AccessPointPresenceEventCallba
return;
}

// Lookup the nl80211 netlink id if not already done.
int nl80211NetlinkId = m_nl80211NetlinkId;
if (nl80211NetlinkId == -1) {
nl80211NetlinkId = genl_ctrl_resolve(netlinkSocket, NL80211_GENL_NAME);
if (nl80211NetlinkId < 0) {
LOG_ERROR << std::format("Failed to resolve nl80211 netlink id with error {} ({})", nl80211NetlinkId, nl_geterror(nl80211NetlinkId));
return;
}
m_nl80211NetlinkId = nl80211NetlinkId;
}

// Lookup the membership id for the "config" multicast group if not already done.
int nl80211MulticastGroupIdConfig = m_nl80211MulticastGroupIdConfig;
if (nl80211MulticastGroupIdConfig == -1) {
nl80211MulticastGroupIdConfig = genl_ctrl_resolve_grp(netlinkSocket, NL80211_GENL_NAME, NL80211_MULTICAST_GROUP_CONFIG);
if (nl80211MulticastGroupIdConfig < 0) {
LOG_ERROR << std::format("Failed to resolve nl80211 multicast group id for config with error {} ({})", nl80211MulticastGroupIdConfig, nl_geterror(nl80211MulticastGroupIdConfig));
return;
}
m_nl80211MulticastGroupIdConfig = nl80211MulticastGroupIdConfig;
}

// Subscribe to configuration messages.
int nl80211MulticastGroupIdConfig = m_netlink80211ProtocolState.MulticastGroupId[Nl80211MulticastGroup::Configuration];
ret = nl_socket_add_membership(netlinkSocket, nl80211MulticastGroupIdConfig);
if (ret < 0) {
const auto err = errno;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,6 @@ private:
// Cookie used to invalidate the callback context.
static constexpr uint32_t CookieInvalid{ 0xDEADBEEFu };

int m_nl80211NetlinkId{ -1 };
int m_nl80211MulticastGroupIdConfig{ -1 };

uint32_t m_cookie{ CookieInvalid };
AccessPointPresenceEventCallback m_accessPointPresenceCallback{ nullptr };

Expand All @@ -106,7 +103,7 @@ private:
};

std::unordered_map<int, WifiInterfaceInfo> m_interfaceInfo;
Microsoft::Net::Netlink::Nl80211::Nl80211ProtocolState& m_netlink80211ProtocolState;
Microsoft::Net::Netlink::Nl80211::Nl80211ProtocolState &m_netlink80211ProtocolState;
};
} // namespace Microsoft::Net::Wifi

Expand Down

0 comments on commit 2ba29af

Please sign in to comment.