Loading automotive/can/1.0/default/libnl++/Android.bp +2 −0 Original line number Diff line number Diff line Loading @@ -26,6 +26,7 @@ cc_library_static { "protocols/generic/Generic.cpp", "protocols/generic/GenericMessageBase.cpp", "protocols/generic/Unknown.cpp", "protocols/generic/families/Mac80211hwsim.cpp", "protocols/generic/families/Nl80211.cpp", "protocols/route/Link.cpp", "protocols/route/Route.cpp", Loading @@ -33,6 +34,7 @@ cc_library_static { "protocols/MessageDefinition.cpp", "protocols/NetlinkProtocol.cpp", "protocols/all.cpp", "protocols/structs.cpp", "Attributes.cpp", "MessageFactory.cpp", "MessageMutator.cpp", Loading automotive/can/1.0/default/libnl++/include/libnl++/Message.h +5 −4 Original line number Diff line number Diff line Loading @@ -34,7 +34,7 @@ namespace android::nl { * a single instance can only be used by a single thread - the one owning the underlying buffer). */ template <typename T> class Message { class Message : public Buffer<nlmsghdr> { public: /** * Validate buffer contents as a message carrying T data and create instance of parsed message. Loading @@ -51,7 +51,7 @@ class Message { const auto attributes = buf.data<nlattr>(sizeof(T)); return Message<T>(nlHeader, dataHeader, attributes); return Message<T>(buf, nlHeader, dataHeader, attributes); } /** Loading Loading @@ -94,8 +94,9 @@ class Message { const T* operator->() const { return &data; } private: Message(const nlmsghdr& nlHeader, const T& dataHeader, Attributes attributes) : header(nlHeader), data(dataHeader), attributes(attributes) {} Message(Buffer<nlmsghdr> buffer, const nlmsghdr& nlHeader, const T& dataHeader, Attributes attributes) : Buffer<nlmsghdr>(buffer), header(nlHeader), data(dataHeader), attributes(attributes) {} }; } // namespace android::nl automotive/can/1.0/default/libnl++/include/libnl++/generic/families/mac80211_hwsim.h 0 → 100644 +73 −0 Original line number Diff line number Diff line /* * Copyright (C) 2021 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ // API definitions from kernel drivers/net/wireless/mac80211_hwsim.h #define BIT(n) (1 << (n)) enum hwsim_tx_control_flags { HWSIM_TX_CTL_REQ_TX_STATUS = BIT(0), HWSIM_TX_CTL_NO_ACK = BIT(1), HWSIM_TX_STAT_ACK = BIT(2), }; enum { HWSIM_CMD_UNSPEC, HWSIM_CMD_REGISTER, HWSIM_CMD_FRAME, HWSIM_CMD_TX_INFO_FRAME, HWSIM_CMD_NEW_RADIO, HWSIM_CMD_DEL_RADIO, HWSIM_CMD_GET_RADIO, HWSIM_CMD_ADD_MAC_ADDR, HWSIM_CMD_DEL_MAC_ADDR, }; enum { HWSIM_ATTR_UNSPEC, HWSIM_ATTR_ADDR_RECEIVER, HWSIM_ATTR_ADDR_TRANSMITTER, HWSIM_ATTR_FRAME, HWSIM_ATTR_FLAGS, HWSIM_ATTR_RX_RATE, HWSIM_ATTR_SIGNAL, HWSIM_ATTR_TX_INFO, HWSIM_ATTR_COOKIE, HWSIM_ATTR_CHANNELS, HWSIM_ATTR_RADIO_ID, HWSIM_ATTR_REG_HINT_ALPHA2, HWSIM_ATTR_REG_CUSTOM_REG, HWSIM_ATTR_REG_STRICT_REG, HWSIM_ATTR_SUPPORT_P2P_DEVICE, HWSIM_ATTR_USE_CHANCTX, HWSIM_ATTR_DESTROY_RADIO_ON_CLOSE, HWSIM_ATTR_RADIO_NAME, HWSIM_ATTR_NO_VIF, HWSIM_ATTR_FREQ, HWSIM_ATTR_PAD, HWSIM_ATTR_TX_INFO_FLAGS, HWSIM_ATTR_PERM_ADDR, HWSIM_ATTR_IFTYPE_SUPPORT, HWSIM_ATTR_CIPHER_SUPPORT, }; struct hwsim_tx_rate { int8_t idx; uint8_t count; } __packed; static_assert(sizeof(hwsim_tx_rate) == 2); #undef BIT automotive/can/1.0/default/libnl++/protocols/generic/Ctrl.cpp +5 −1 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ #include "Ctrl.h" #include "families/Mac80211hwsim.h" #include "families/Nl80211.h" #include <libnl++/Message.h> Loading Loading @@ -68,12 +69,15 @@ void Ctrl::track(const Buffer<nlmsghdr> hdr) { const auto familyId = msg.attributes.get<uint16_t>(CTRL_ATTR_FAMILY_ID); const auto familyName = msg.attributes.get<std::string>(CTRL_ATTR_FAMILY_NAME); /* For now, we support just a single family. But if you add more, please define proper /* For now, we support just two families. But if you add more, please define proper * abstraction and not hardcode every name and class here. */ if (familyName == "nl80211") { mFamilyRegister[familyId] = std::make_shared<families::Nl80211>(familyId); } if (familyName == "MAC80211_HWSIM") { mFamilyRegister[familyId] = std::make_shared<families::Mac80211hwsim>(familyId); } } } // namespace android::nl::protocols::generic automotive/can/1.0/default/libnl++/protocols/generic/GenericMessageBase.cpp +2 −2 Original line number Diff line number Diff line Loading @@ -40,9 +40,9 @@ void GenericMessageBase::toStream(std::stringstream& ss, const genlmsghdr& data) ss << "genlmsghdr{"; if (commandName.has_value()) { ss << "cmd=" << unsigned(data.cmd); } else { ss << "cmd=" << *commandName; } else { ss << "cmd=" << unsigned(data.cmd); } ss << ", version=" << unsigned(data.version); if (data.reserved != 0) ss << ", reserved=" << data.reserved; Loading Loading
automotive/can/1.0/default/libnl++/Android.bp +2 −0 Original line number Diff line number Diff line Loading @@ -26,6 +26,7 @@ cc_library_static { "protocols/generic/Generic.cpp", "protocols/generic/GenericMessageBase.cpp", "protocols/generic/Unknown.cpp", "protocols/generic/families/Mac80211hwsim.cpp", "protocols/generic/families/Nl80211.cpp", "protocols/route/Link.cpp", "protocols/route/Route.cpp", Loading @@ -33,6 +34,7 @@ cc_library_static { "protocols/MessageDefinition.cpp", "protocols/NetlinkProtocol.cpp", "protocols/all.cpp", "protocols/structs.cpp", "Attributes.cpp", "MessageFactory.cpp", "MessageMutator.cpp", Loading
automotive/can/1.0/default/libnl++/include/libnl++/Message.h +5 −4 Original line number Diff line number Diff line Loading @@ -34,7 +34,7 @@ namespace android::nl { * a single instance can only be used by a single thread - the one owning the underlying buffer). */ template <typename T> class Message { class Message : public Buffer<nlmsghdr> { public: /** * Validate buffer contents as a message carrying T data and create instance of parsed message. Loading @@ -51,7 +51,7 @@ class Message { const auto attributes = buf.data<nlattr>(sizeof(T)); return Message<T>(nlHeader, dataHeader, attributes); return Message<T>(buf, nlHeader, dataHeader, attributes); } /** Loading Loading @@ -94,8 +94,9 @@ class Message { const T* operator->() const { return &data; } private: Message(const nlmsghdr& nlHeader, const T& dataHeader, Attributes attributes) : header(nlHeader), data(dataHeader), attributes(attributes) {} Message(Buffer<nlmsghdr> buffer, const nlmsghdr& nlHeader, const T& dataHeader, Attributes attributes) : Buffer<nlmsghdr>(buffer), header(nlHeader), data(dataHeader), attributes(attributes) {} }; } // namespace android::nl
automotive/can/1.0/default/libnl++/include/libnl++/generic/families/mac80211_hwsim.h 0 → 100644 +73 −0 Original line number Diff line number Diff line /* * Copyright (C) 2021 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ // API definitions from kernel drivers/net/wireless/mac80211_hwsim.h #define BIT(n) (1 << (n)) enum hwsim_tx_control_flags { HWSIM_TX_CTL_REQ_TX_STATUS = BIT(0), HWSIM_TX_CTL_NO_ACK = BIT(1), HWSIM_TX_STAT_ACK = BIT(2), }; enum { HWSIM_CMD_UNSPEC, HWSIM_CMD_REGISTER, HWSIM_CMD_FRAME, HWSIM_CMD_TX_INFO_FRAME, HWSIM_CMD_NEW_RADIO, HWSIM_CMD_DEL_RADIO, HWSIM_CMD_GET_RADIO, HWSIM_CMD_ADD_MAC_ADDR, HWSIM_CMD_DEL_MAC_ADDR, }; enum { HWSIM_ATTR_UNSPEC, HWSIM_ATTR_ADDR_RECEIVER, HWSIM_ATTR_ADDR_TRANSMITTER, HWSIM_ATTR_FRAME, HWSIM_ATTR_FLAGS, HWSIM_ATTR_RX_RATE, HWSIM_ATTR_SIGNAL, HWSIM_ATTR_TX_INFO, HWSIM_ATTR_COOKIE, HWSIM_ATTR_CHANNELS, HWSIM_ATTR_RADIO_ID, HWSIM_ATTR_REG_HINT_ALPHA2, HWSIM_ATTR_REG_CUSTOM_REG, HWSIM_ATTR_REG_STRICT_REG, HWSIM_ATTR_SUPPORT_P2P_DEVICE, HWSIM_ATTR_USE_CHANCTX, HWSIM_ATTR_DESTROY_RADIO_ON_CLOSE, HWSIM_ATTR_RADIO_NAME, HWSIM_ATTR_NO_VIF, HWSIM_ATTR_FREQ, HWSIM_ATTR_PAD, HWSIM_ATTR_TX_INFO_FLAGS, HWSIM_ATTR_PERM_ADDR, HWSIM_ATTR_IFTYPE_SUPPORT, HWSIM_ATTR_CIPHER_SUPPORT, }; struct hwsim_tx_rate { int8_t idx; uint8_t count; } __packed; static_assert(sizeof(hwsim_tx_rate) == 2); #undef BIT
automotive/can/1.0/default/libnl++/protocols/generic/Ctrl.cpp +5 −1 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ #include "Ctrl.h" #include "families/Mac80211hwsim.h" #include "families/Nl80211.h" #include <libnl++/Message.h> Loading Loading @@ -68,12 +69,15 @@ void Ctrl::track(const Buffer<nlmsghdr> hdr) { const auto familyId = msg.attributes.get<uint16_t>(CTRL_ATTR_FAMILY_ID); const auto familyName = msg.attributes.get<std::string>(CTRL_ATTR_FAMILY_NAME); /* For now, we support just a single family. But if you add more, please define proper /* For now, we support just two families. But if you add more, please define proper * abstraction and not hardcode every name and class here. */ if (familyName == "nl80211") { mFamilyRegister[familyId] = std::make_shared<families::Nl80211>(familyId); } if (familyName == "MAC80211_HWSIM") { mFamilyRegister[familyId] = std::make_shared<families::Mac80211hwsim>(familyId); } } } // namespace android::nl::protocols::generic
automotive/can/1.0/default/libnl++/protocols/generic/GenericMessageBase.cpp +2 −2 Original line number Diff line number Diff line Loading @@ -40,9 +40,9 @@ void GenericMessageBase::toStream(std::stringstream& ss, const genlmsghdr& data) ss << "genlmsghdr{"; if (commandName.has_value()) { ss << "cmd=" << unsigned(data.cmd); } else { ss << "cmd=" << *commandName; } else { ss << "cmd=" << unsigned(data.cmd); } ss << ", version=" << unsigned(data.version); if (data.reserved != 0) ss << ", reserved=" << data.reserved; Loading