Merge changes from topic "libnl++"
* changes:
Change libnl++ namespace to android::nl
Split out libnl++ from libnetdevice
diff --git a/automotive/can/1.0/default/Android.bp b/automotive/can/1.0/default/Android.bp
index f5cf425..0ba066e 100644
--- a/automotive/can/1.0/default/Android.bp
+++ b/automotive/can/1.0/default/Android.bp
@@ -52,5 +52,6 @@
static_libs: [
"android.hardware.automotive.can@libnetdevice",
"android.hardware.automotive@libc++fs",
+ "libnl++",
],
}
diff --git a/automotive/can/1.0/default/libnetdevice/Android.bp b/automotive/can/1.0/default/libnetdevice/Android.bp
index d49b9ab..2605f88 100644
--- a/automotive/can/1.0/default/libnetdevice/Android.bp
+++ b/automotive/can/1.0/default/libnetdevice/Android.bp
@@ -18,29 +18,16 @@
name: "android.hardware.automotive.can@libnetdevice",
defaults: ["android.hardware.automotive.can@defaults"],
vendor_available: true,
- relative_install_path: "hw",
srcs: [
- "protocols/common/Empty.cpp",
- "protocols/common/Error.cpp",
- "protocols/generic/Ctrl.cpp",
- "protocols/generic/Generic.cpp",
- "protocols/generic/GenericMessageBase.cpp",
- "protocols/generic/Unknown.cpp",
- "protocols/route/Link.cpp",
- "protocols/route/Route.cpp",
- "protocols/route/structs.cpp",
- "protocols/MessageDefinition.cpp",
- "protocols/NetlinkProtocol.cpp",
- "protocols/all.cpp",
- "NetlinkRequest.cpp",
- "NetlinkSocket.cpp",
"can.cpp",
"common.cpp",
"ethtool.cpp",
"ifreqs.cpp",
"libnetdevice.cpp",
- "printer.cpp",
"vlan.cpp",
],
export_include_dirs: ["include"],
+ static_libs: [
+ "libnl++",
+ ],
}
diff --git a/automotive/can/1.0/default/libnetdevice/can.cpp b/automotive/can/1.0/default/libnetdevice/can.cpp
index b0a2432..0aa5afe 100644
--- a/automotive/can/1.0/default/libnetdevice/can.cpp
+++ b/automotive/can/1.0/default/libnetdevice/can.cpp
@@ -20,8 +20,8 @@
#include <android-base/logging.h>
#include <android-base/unique_fd.h>
-#include <libnetdevice/NetlinkRequest.h>
-#include <libnetdevice/NetlinkSocket.h>
+#include <libnl++/NetlinkRequest.h>
+#include <libnl++/NetlinkSocket.h>
#include <linux/can.h>
#include <linux/can/error.h>
@@ -69,7 +69,7 @@
struct can_bittiming bt = {};
bt.bitrate = bitrate;
- NetlinkRequest<struct ifinfomsg> req(RTM_NEWLINK, NLM_F_REQUEST);
+ nl::NetlinkRequest<struct ifinfomsg> req(RTM_NEWLINK, NLM_F_REQUEST);
const auto ifidx = nametoindex(ifname);
if (ifidx == 0) {
@@ -89,7 +89,7 @@
}
}
- NetlinkSocket sock(NETLINK_ROUTE);
+ nl::NetlinkSocket sock(NETLINK_ROUTE);
return sock.send(req) && sock.receiveAck();
}
diff --git a/automotive/can/1.0/default/libnetdevice/common.cpp b/automotive/can/1.0/default/libnetdevice/common.cpp
index f2968fc..28e50af 100644
--- a/automotive/can/1.0/default/libnetdevice/common.cpp
+++ b/automotive/can/1.0/default/libnetdevice/common.cpp
@@ -32,27 +32,4 @@
return 0;
}
-std::string sanitize(std::string str) {
- str.erase(std::find(str.begin(), str.end(), '\0'), str.end());
-
- const auto isInvalid = [](char c) { return !isprint(c); };
- std::replace_if(str.begin(), str.end(), isInvalid, '?');
-
- return str;
-}
-
-uint16_t crc16(const nlbuf<uint8_t> data, uint16_t crc) {
- for (const auto byte : data.getRaw()) {
- crc ^= byte;
- for (unsigned i = 0; i < 8; i++) {
- if (crc & 1) {
- crc = (crc >> 1) ^ 0xA001;
- } else {
- crc >>= 1;
- }
- }
- }
- return crc;
-}
-
} // namespace android::netdevice
diff --git a/automotive/can/1.0/default/libnetdevice/common.h b/automotive/can/1.0/default/libnetdevice/common.h
index 1e0d5b7..201909f 100644
--- a/automotive/can/1.0/default/libnetdevice/common.h
+++ b/automotive/can/1.0/default/libnetdevice/common.h
@@ -16,7 +16,7 @@
#pragma once
-#include <libnetdevice/nlbuf.h>
+#include <libnl++/nlbuf.h>
#include <linux/can.h>
#include <net/if.h>
@@ -36,24 +36,4 @@
*/
unsigned int nametoindex(const std::string& ifname);
-/**
- * Sanitize a string of unknown contents.
- *
- * Trims the string to the first '\0' character and replaces all non-printable characters with '?'.
- */
-std::string sanitize(std::string str);
-
-/**
- * Calculates a (optionally running) CRC16 checksum.
- *
- * CRC16 isn't a strong checksum, but is good for quick comparison purposes.
- * One benefit (and also a drawback too) is that all-zero payloads with any length will
- * always have a checksum of 0x0000.
- *
- * \param data Buffer to calculate checksum for
- * \param crc Previous CRC16 value to continue calculating running checksum
- * \return CRC16 checksum
- */
-uint16_t crc16(const nlbuf<uint8_t> data, uint16_t crc = 0);
-
} // namespace android::netdevice
diff --git a/automotive/can/1.0/default/libnetdevice/libnetdevice.cpp b/automotive/can/1.0/default/libnetdevice/libnetdevice.cpp
index 4293cad..04381f2 100644
--- a/automotive/can/1.0/default/libnetdevice/libnetdevice.cpp
+++ b/automotive/can/1.0/default/libnetdevice/libnetdevice.cpp
@@ -20,8 +20,8 @@
#include "ifreqs.h"
#include <android-base/logging.h>
-#include <libnetdevice/NetlinkRequest.h>
-#include <libnetdevice/NetlinkSocket.h>
+#include <libnl++/NetlinkRequest.h>
+#include <libnl++/NetlinkSocket.h>
#include <linux/can.h>
#include <net/if.h>
@@ -61,7 +61,8 @@
}
bool add(std::string dev, std::string type) {
- NetlinkRequest<struct ifinfomsg> req(RTM_NEWLINK, NLM_F_REQUEST | NLM_F_CREATE | NLM_F_EXCL);
+ nl::NetlinkRequest<struct ifinfomsg> req(RTM_NEWLINK,
+ NLM_F_REQUEST | NLM_F_CREATE | NLM_F_EXCL);
req.addattr(IFLA_IFNAME, dev);
{
@@ -69,15 +70,15 @@
req.addattr(IFLA_INFO_KIND, type);
}
- NetlinkSocket sock(NETLINK_ROUTE);
+ nl::NetlinkSocket sock(NETLINK_ROUTE);
return sock.send(req) && sock.receiveAck();
}
bool del(std::string dev) {
- NetlinkRequest<struct ifinfomsg> req(RTM_DELLINK, NLM_F_REQUEST);
+ nl::NetlinkRequest<struct ifinfomsg> req(RTM_DELLINK, NLM_F_REQUEST);
req.addattr(IFLA_IFNAME, dev);
- NetlinkSocket sock(NETLINK_ROUTE);
+ nl::NetlinkSocket sock(NETLINK_ROUTE);
return sock.send(req) && sock.receiveAck();
}
diff --git a/automotive/can/1.0/default/libnetdevice/vlan.cpp b/automotive/can/1.0/default/libnetdevice/vlan.cpp
index f0caacd..bcc9345 100644
--- a/automotive/can/1.0/default/libnetdevice/vlan.cpp
+++ b/automotive/can/1.0/default/libnetdevice/vlan.cpp
@@ -19,8 +19,8 @@
#include "common.h"
#include <android-base/logging.h>
-#include <libnetdevice/NetlinkRequest.h>
-#include <libnetdevice/NetlinkSocket.h>
+#include <libnl++/NetlinkRequest.h>
+#include <libnl++/NetlinkSocket.h>
namespace android::netdevice::vlan {
@@ -31,7 +31,8 @@
return false;
}
- NetlinkRequest<struct ifinfomsg> req(RTM_NEWLINK, NLM_F_REQUEST | NLM_F_CREATE | NLM_F_EXCL);
+ nl::NetlinkRequest<struct ifinfomsg> req(RTM_NEWLINK,
+ NLM_F_REQUEST | NLM_F_CREATE | NLM_F_EXCL);
req.addattr(IFLA_IFNAME, vlan);
req.addattr<uint32_t>(IFLA_LINK, ethidx);
@@ -45,7 +46,7 @@
}
}
- NetlinkSocket sock(NETLINK_ROUTE);
+ nl::NetlinkSocket sock(NETLINK_ROUTE);
return sock.send(req) && sock.receiveAck();
}
diff --git a/automotive/can/1.0/default/libnl++/Android.bp b/automotive/can/1.0/default/libnl++/Android.bp
new file mode 100644
index 0000000..cffefe7
--- /dev/null
+++ b/automotive/can/1.0/default/libnl++/Android.bp
@@ -0,0 +1,40 @@
+//
+// Copyright (C) 2019 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.
+//
+
+cc_library_static {
+ name: "libnl++",
+ defaults: ["android.hardware.automotive.can@defaults"],
+ vendor_available: true,
+ srcs: [
+ "protocols/common/Empty.cpp",
+ "protocols/common/Error.cpp",
+ "protocols/generic/Ctrl.cpp",
+ "protocols/generic/Generic.cpp",
+ "protocols/generic/GenericMessageBase.cpp",
+ "protocols/generic/Unknown.cpp",
+ "protocols/route/Link.cpp",
+ "protocols/route/Route.cpp",
+ "protocols/route/structs.cpp",
+ "protocols/MessageDefinition.cpp",
+ "protocols/NetlinkProtocol.cpp",
+ "protocols/all.cpp",
+ "NetlinkRequest.cpp",
+ "NetlinkSocket.cpp",
+ "common.cpp",
+ "printer.cpp",
+ ],
+ export_include_dirs: ["include"],
+}
diff --git a/automotive/can/1.0/default/libnetdevice/NetlinkRequest.cpp b/automotive/can/1.0/default/libnl++/NetlinkRequest.cpp
similarity index 93%
rename from automotive/can/1.0/default/libnetdevice/NetlinkRequest.cpp
rename to automotive/can/1.0/default/libnl++/NetlinkRequest.cpp
index 4c06f7c..e9463d1 100644
--- a/automotive/can/1.0/default/libnetdevice/NetlinkRequest.cpp
+++ b/automotive/can/1.0/default/libnl++/NetlinkRequest.cpp
@@ -14,11 +14,11 @@
* limitations under the License.
*/
-#include <libnetdevice/NetlinkRequest.h>
+#include <libnl++/NetlinkRequest.h>
#include <android-base/logging.h>
-namespace android::netdevice::impl {
+namespace android::nl::impl {
static struct rtattr* nlmsg_tail(struct nlmsghdr* n) {
return reinterpret_cast<struct rtattr*>( //
@@ -51,4 +51,4 @@
nest->rta_len = nestLen;
}
-} // namespace android::netdevice::impl
+} // namespace android::nl::impl
diff --git a/automotive/can/1.0/default/libnetdevice/NetlinkSocket.cpp b/automotive/can/1.0/default/libnl++/NetlinkSocket.cpp
similarity index 97%
rename from automotive/can/1.0/default/libnetdevice/NetlinkSocket.cpp
rename to automotive/can/1.0/default/libnl++/NetlinkSocket.cpp
index 91149c0..6f0f0c2 100644
--- a/automotive/can/1.0/default/libnetdevice/NetlinkSocket.cpp
+++ b/automotive/can/1.0/default/libnl++/NetlinkSocket.cpp
@@ -14,13 +14,13 @@
* limitations under the License.
*/
-#include <libnetdevice/NetlinkSocket.h>
+#include <libnl++/NetlinkSocket.h>
-#include <libnetdevice/printer.h>
+#include <libnl++/printer.h>
#include <android-base/logging.h>
-namespace android::netdevice {
+namespace android::nl {
/**
* Print all outbound/inbound Netlink messages.
@@ -190,4 +190,4 @@
return sa.nl_pid;
}
-} // namespace android::netdevice
+} // namespace android::nl
diff --git a/automotive/can/1.0/default/libnl++/common.cpp b/automotive/can/1.0/default/libnl++/common.cpp
new file mode 100644
index 0000000..7848646
--- /dev/null
+++ b/automotive/can/1.0/default/libnl++/common.cpp
@@ -0,0 +1,58 @@
+/*
+ * Copyright (C) 2019 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.
+ */
+
+#include "common.h"
+
+#include <android-base/logging.h>
+
+#include <net/if.h>
+
+namespace android::nl {
+
+unsigned int nametoindex(const std::string& ifname) {
+ const auto ifidx = if_nametoindex(ifname.c_str());
+ if (ifidx != 0) return ifidx;
+
+ if (errno != ENODEV) {
+ PLOG(ERROR) << "if_nametoindex(" << ifname << ") failed";
+ }
+ return 0;
+}
+
+std::string sanitize(std::string str) {
+ str.erase(std::find(str.begin(), str.end(), '\0'), str.end());
+
+ const auto isInvalid = [](char c) { return !isprint(c); };
+ std::replace_if(str.begin(), str.end(), isInvalid, '?');
+
+ return str;
+}
+
+uint16_t crc16(const nlbuf<uint8_t> data, uint16_t crc) {
+ for (const auto byte : data.getRaw()) {
+ crc ^= byte;
+ for (unsigned i = 0; i < 8; i++) {
+ if (crc & 1) {
+ crc = (crc >> 1) ^ 0xA001;
+ } else {
+ crc >>= 1;
+ }
+ }
+ }
+ return crc;
+}
+
+} // namespace android::nl
diff --git a/automotive/can/1.0/default/libnl++/common.h b/automotive/can/1.0/default/libnl++/common.h
new file mode 100644
index 0000000..dc5777c
--- /dev/null
+++ b/automotive/can/1.0/default/libnl++/common.h
@@ -0,0 +1,59 @@
+/*
+ * Copyright (C) 2019 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.
+ */
+
+#pragma once
+
+#include <libnl++/nlbuf.h>
+
+#include <linux/can.h>
+#include <net/if.h>
+
+#include <string>
+
+namespace android::nl {
+
+/**
+ * Returns the index of a given network interface.
+ *
+ * If the syscall to check the index fails with other error than ENODEV, it gets logged and the
+ * return value indicates the interface doesn't exists.
+ *
+ * \param ifname Interface to check
+ * \return Interface index, or 0 if the interface doesn't exist
+ */
+unsigned int nametoindex(const std::string& ifname);
+
+/**
+ * Sanitize a string of unknown contents.
+ *
+ * Trims the string to the first '\0' character and replaces all non-printable characters with '?'.
+ */
+std::string sanitize(std::string str);
+
+/**
+ * Calculates a (optionally running) CRC16 checksum.
+ *
+ * CRC16 isn't a strong checksum, but is good for quick comparison purposes.
+ * One benefit (and also a drawback too) is that all-zero payloads with any length will
+ * always have a checksum of 0x0000.
+ *
+ * \param data Buffer to calculate checksum for
+ * \param crc Previous CRC16 value to continue calculating running checksum
+ * \return CRC16 checksum
+ */
+uint16_t crc16(const nlbuf<uint8_t> data, uint16_t crc = 0);
+
+} // namespace android::nl
diff --git a/automotive/can/1.0/default/libnetdevice/include/libnetdevice/NetlinkRequest.h b/automotive/can/1.0/default/libnl++/include/libnl++/NetlinkRequest.h
similarity index 97%
rename from automotive/can/1.0/default/libnetdevice/include/libnetdevice/NetlinkRequest.h
rename to automotive/can/1.0/default/libnl++/include/libnl++/NetlinkRequest.h
index c19d04d..3b30a2a 100644
--- a/automotive/can/1.0/default/libnetdevice/include/libnetdevice/NetlinkRequest.h
+++ b/automotive/can/1.0/default/libnl++/include/libnl++/NetlinkRequest.h
@@ -17,13 +17,13 @@
#pragma once
#include <android-base/macros.h>
-#include <libnetdevice/types.h>
+#include <libnl++/types.h>
#include <linux/rtnetlink.h>
#include <string>
-namespace android::netdevice {
+namespace android::nl {
/** Implementation details, do not use outside NetlinkRequest template. */
namespace impl {
@@ -154,4 +154,4 @@
}
};
-} // namespace android::netdevice
+} // namespace android::nl
diff --git a/automotive/can/1.0/default/libnetdevice/include/libnetdevice/NetlinkSocket.h b/automotive/can/1.0/default/libnl++/include/libnl++/NetlinkSocket.h
similarity index 95%
rename from automotive/can/1.0/default/libnetdevice/include/libnetdevice/NetlinkSocket.h
rename to automotive/can/1.0/default/libnl++/include/libnl++/NetlinkSocket.h
index 826b6b8..f2a38fb 100644
--- a/automotive/can/1.0/default/libnetdevice/include/libnetdevice/NetlinkSocket.h
+++ b/automotive/can/1.0/default/libnl++/include/libnl++/NetlinkSocket.h
@@ -18,14 +18,14 @@
#include <android-base/macros.h>
#include <android-base/unique_fd.h>
-#include <libnetdevice/NetlinkRequest.h>
-#include <libnetdevice/nlbuf.h>
+#include <libnl++/NetlinkRequest.h>
+#include <libnl++/nlbuf.h>
#include <linux/netlink.h>
#include <optional>
-namespace android::netdevice {
+namespace android::nl {
/**
* A wrapper around AF_NETLINK sockets.
@@ -113,4 +113,4 @@
DISALLOW_COPY_AND_ASSIGN(NetlinkSocket);
};
-} // namespace android::netdevice
+} // namespace android::nl
diff --git a/automotive/can/1.0/default/libnetdevice/include/libnetdevice/nlbuf.h b/automotive/can/1.0/default/libnl++/include/libnl++/nlbuf.h
similarity index 98%
rename from automotive/can/1.0/default/libnetdevice/include/libnetdevice/nlbuf.h
rename to automotive/can/1.0/default/libnl++/include/libnl++/nlbuf.h
index 601ab94..4c0e581 100644
--- a/automotive/can/1.0/default/libnetdevice/include/libnetdevice/nlbuf.h
+++ b/automotive/can/1.0/default/libnl++/include/libnl++/nlbuf.h
@@ -22,7 +22,7 @@
#include <optional>
-namespace android::netdevice {
+namespace android::nl {
/**
* Buffer containing netlink structure (e.g. struct nlmsghdr, struct nlattr).
@@ -199,4 +199,4 @@
return mData->nla_len;
}
-} // namespace android::netdevice
+} // namespace android::nl
diff --git a/automotive/can/1.0/default/libnetdevice/include/libnetdevice/printer.h b/automotive/can/1.0/default/libnl++/include/libnl++/printer.h
similarity index 91%
rename from automotive/can/1.0/default/libnetdevice/include/libnetdevice/printer.h
rename to automotive/can/1.0/default/libnl++/include/libnl++/printer.h
index 071fa63..7167965 100644
--- a/automotive/can/1.0/default/libnetdevice/include/libnetdevice/printer.h
+++ b/automotive/can/1.0/default/libnl++/include/libnl++/printer.h
@@ -16,13 +16,13 @@
#pragma once
-#include <libnetdevice/nlbuf.h>
+#include <libnl++/nlbuf.h>
#include <linux/netlink.h>
#include <string>
-namespace android::netdevice {
+namespace android::nl {
/**
* Stringify a Netlink message.
@@ -34,4 +34,4 @@
*/
std::string toString(const nlbuf<nlmsghdr> hdr, int protocol, bool printPayload = false);
-} // namespace android::netdevice
+} // namespace android::nl
diff --git a/automotive/can/1.0/default/libnetdevice/include/libnetdevice/types.h b/automotive/can/1.0/default/libnl++/include/libnl++/types.h
similarity index 92%
rename from automotive/can/1.0/default/libnetdevice/include/libnetdevice/types.h
rename to automotive/can/1.0/default/libnl++/include/libnl++/types.h
index 9d90c8a..d2f10ff 100644
--- a/automotive/can/1.0/default/libnetdevice/include/libnetdevice/types.h
+++ b/automotive/can/1.0/default/libnl++/include/libnl++/types.h
@@ -18,10 +18,10 @@
#include <linux/types.h>
-namespace android::netdevice {
+namespace android::nl {
typedef __u16 nlmsgtype_t; // nlmsghdr::nlmsg_type
typedef __u16 nlattrtype_t; // nlattr::nla_type
typedef unsigned short rtattrtype_t; // rtattr::rta_type
-} // namespace android::netdevice
+} // namespace android::nl
diff --git a/automotive/can/1.0/default/libnetdevice/printer.cpp b/automotive/can/1.0/default/libnl++/printer.cpp
similarity index 97%
rename from automotive/can/1.0/default/libnetdevice/printer.cpp
rename to automotive/can/1.0/default/libnl++/printer.cpp
index 179d501..c32afb3 100644
--- a/automotive/can/1.0/default/libnetdevice/printer.cpp
+++ b/automotive/can/1.0/default/libnl++/printer.cpp
@@ -14,19 +14,19 @@
* limitations under the License.
*/
-#include <libnetdevice/printer.h>
+#include <libnl++/printer.h>
#include "common.h"
#include "protocols/all.h"
#include <android-base/logging.h>
-#include <libnetdevice/nlbuf.h>
+#include <libnl++/nlbuf.h>
#include <algorithm>
#include <iomanip>
#include <sstream>
-namespace android::netdevice {
+namespace android::nl {
static void flagsToStream(std::stringstream& ss, __u16 nlmsg_flags) {
bool first = true;
@@ -174,4 +174,4 @@
return ss.str();
}
-} // namespace android::netdevice
+} // namespace android::nl
diff --git a/automotive/can/1.0/default/libnetdevice/protocols/MessageDefinition.cpp b/automotive/can/1.0/default/libnl++/protocols/MessageDefinition.cpp
similarity index 95%
rename from automotive/can/1.0/default/libnetdevice/protocols/MessageDefinition.cpp
rename to automotive/can/1.0/default/libnl++/protocols/MessageDefinition.cpp
index cb42896..dc56643 100644
--- a/automotive/can/1.0/default/libnetdevice/protocols/MessageDefinition.cpp
+++ b/automotive/can/1.0/default/libnl++/protocols/MessageDefinition.cpp
@@ -16,7 +16,7 @@
#include "MessageDefinition.h"
-namespace android::netdevice::protocols {
+namespace android::nl::protocols {
AttributeMap::AttributeMap(const std::initializer_list<value_type> attrTypes)
: std::map<std::optional<nlattrtype_t>, AttributeDefinition>(attrTypes) {}
@@ -59,4 +59,4 @@
return it->second;
}
-} // namespace android::netdevice::protocols
+} // namespace android::nl::protocols
diff --git a/automotive/can/1.0/default/libnetdevice/protocols/MessageDefinition.h b/automotive/can/1.0/default/libnl++/protocols/MessageDefinition.h
similarity index 95%
rename from automotive/can/1.0/default/libnetdevice/protocols/MessageDefinition.h
rename to automotive/can/1.0/default/libnl++/protocols/MessageDefinition.h
index 3a8b2b5..046ef47 100644
--- a/automotive/can/1.0/default/libnetdevice/protocols/MessageDefinition.h
+++ b/automotive/can/1.0/default/libnl++/protocols/MessageDefinition.h
@@ -16,14 +16,14 @@
#pragma once
-#include <libnetdevice/nlbuf.h>
-#include <libnetdevice/types.h>
+#include <libnl++/nlbuf.h>
+#include <libnl++/types.h>
#include <map>
#include <sstream>
#include <variant>
-namespace android::netdevice::protocols {
+namespace android::nl::protocols {
struct AttributeDefinition;
@@ -123,4 +123,4 @@
virtual void toStream(std::stringstream& ss, const T& data) const = 0;
};
-} // namespace android::netdevice::protocols
+} // namespace android::nl::protocols
diff --git a/automotive/can/1.0/default/libnetdevice/protocols/NetlinkProtocol.cpp b/automotive/can/1.0/default/libnl++/protocols/NetlinkProtocol.cpp
similarity index 95%
rename from automotive/can/1.0/default/libnetdevice/protocols/NetlinkProtocol.cpp
rename to automotive/can/1.0/default/libnl++/protocols/NetlinkProtocol.cpp
index 4b6cefb..4b795d9 100644
--- a/automotive/can/1.0/default/libnetdevice/protocols/NetlinkProtocol.cpp
+++ b/automotive/can/1.0/default/libnl++/protocols/NetlinkProtocol.cpp
@@ -16,7 +16,7 @@
#include "NetlinkProtocol.h"
-namespace android::netdevice::protocols {
+namespace android::nl::protocols {
NetlinkProtocol::NetlinkProtocol(int protocol, const std::string name,
const MessageDescriptorList&& messageDescrs)
@@ -61,4 +61,4 @@
return map;
}
-} // namespace android::netdevice::protocols
+} // namespace android::nl::protocols
diff --git a/automotive/can/1.0/default/libnetdevice/protocols/NetlinkProtocol.h b/automotive/can/1.0/default/libnl++/protocols/NetlinkProtocol.h
similarity index 93%
rename from automotive/can/1.0/default/libnetdevice/protocols/NetlinkProtocol.h
rename to automotive/can/1.0/default/libnl++/protocols/NetlinkProtocol.h
index 7b12efa..81a0a65 100644
--- a/automotive/can/1.0/default/libnetdevice/protocols/NetlinkProtocol.h
+++ b/automotive/can/1.0/default/libnl++/protocols/NetlinkProtocol.h
@@ -20,12 +20,12 @@
#include "common/Empty.h"
#include "common/Error.h"
-#include <libnetdevice/types.h>
+#include <libnl++/types.h>
#include <string>
#include <vector>
-namespace android::netdevice::protocols {
+namespace android::nl::protocols {
/**
* Netlink-based protocol definition.
@@ -59,4 +59,4 @@
static MessageDescriptorMap toMap(const MessageDescriptorList& descrs, int protocol);
};
-} // namespace android::netdevice::protocols
+} // namespace android::nl::protocols
diff --git a/automotive/can/1.0/default/libnetdevice/protocols/README b/automotive/can/1.0/default/libnl++/protocols/README
similarity index 100%
rename from automotive/can/1.0/default/libnetdevice/protocols/README
rename to automotive/can/1.0/default/libnl++/protocols/README
diff --git a/automotive/can/1.0/default/libnetdevice/protocols/all.cpp b/automotive/can/1.0/default/libnl++/protocols/all.cpp
similarity index 93%
rename from automotive/can/1.0/default/libnetdevice/protocols/all.cpp
rename to automotive/can/1.0/default/libnl++/protocols/all.cpp
index 980e3d0..a398dc8 100644
--- a/automotive/can/1.0/default/libnetdevice/protocols/all.cpp
+++ b/automotive/can/1.0/default/libnl++/protocols/all.cpp
@@ -21,7 +21,7 @@
#include <map>
-namespace android::netdevice::protocols {
+namespace android::nl::protocols {
// This should be a map of unique_ptr, but it's not trivial to uniformly initialize such a map
static std::map<int, std::shared_ptr<NetlinkProtocol>> toMap(
@@ -43,4 +43,4 @@
return *all.find(protocol)->second.get();
}
-} // namespace android::netdevice::protocols
+} // namespace android::nl::protocols
diff --git a/automotive/can/1.0/default/libnetdevice/protocols/all.h b/automotive/can/1.0/default/libnl++/protocols/all.h
similarity index 90%
rename from automotive/can/1.0/default/libnetdevice/protocols/all.h
rename to automotive/can/1.0/default/libnl++/protocols/all.h
index 2180ebb..6d6ec1e 100644
--- a/automotive/can/1.0/default/libnetdevice/protocols/all.h
+++ b/automotive/can/1.0/default/libnl++/protocols/all.h
@@ -18,7 +18,7 @@
#include "NetlinkProtocol.h"
-namespace android::netdevice::protocols {
+namespace android::nl::protocols {
/**
* Protocol definition lookup.
@@ -28,4 +28,4 @@
*/
std::optional<std::reference_wrapper<NetlinkProtocol>> get(int protocol);
-} // namespace android::netdevice::protocols
+} // namespace android::nl::protocols
diff --git a/automotive/can/1.0/default/libnetdevice/protocols/common/Empty.cpp b/automotive/can/1.0/default/libnl++/protocols/common/Empty.cpp
similarity index 89%
rename from automotive/can/1.0/default/libnetdevice/protocols/common/Empty.cpp
rename to automotive/can/1.0/default/libnl++/protocols/common/Empty.cpp
index 9f25203..dbf10d4 100644
--- a/automotive/can/1.0/default/libnetdevice/protocols/common/Empty.cpp
+++ b/automotive/can/1.0/default/libnl++/protocols/common/Empty.cpp
@@ -16,7 +16,7 @@
#include "Empty.h"
-namespace android::netdevice::protocols::base {
+namespace android::nl::protocols::base {
// clang-format off
Empty::Empty() : MessageDefinition<char>("nlmsg", {
@@ -28,4 +28,4 @@
void Empty::toStream(std::stringstream&, const char&) const {}
-} // namespace android::netdevice::protocols::base
+} // namespace android::nl::protocols::base
diff --git a/automotive/can/1.0/default/libnetdevice/protocols/common/Empty.h b/automotive/can/1.0/default/libnl++/protocols/common/Empty.h
similarity index 86%
rename from automotive/can/1.0/default/libnetdevice/protocols/common/Empty.h
rename to automotive/can/1.0/default/libnl++/protocols/common/Empty.h
index b5b317f..79a0f46 100644
--- a/automotive/can/1.0/default/libnetdevice/protocols/common/Empty.h
+++ b/automotive/can/1.0/default/libnl++/protocols/common/Empty.h
@@ -18,9 +18,9 @@
#include "../MessageDefinition.h"
-#include <libnetdevice/printer.h>
+#include <libnl++/printer.h>
-namespace android::netdevice::protocols::base {
+namespace android::nl::protocols::base {
// no-payload (like NLMSG_NOOP) messages can't be defined with T=void, so let's use char
class Empty : public MessageDefinition<char> {
@@ -29,4 +29,4 @@
void toStream(std::stringstream&, const char&) const override;
};
-} // namespace android::netdevice::protocols::base
+} // namespace android::nl::protocols::base
diff --git a/automotive/can/1.0/default/libnetdevice/protocols/common/Error.cpp b/automotive/can/1.0/default/libnl++/protocols/common/Error.cpp
similarity index 88%
rename from automotive/can/1.0/default/libnetdevice/protocols/common/Error.cpp
rename to automotive/can/1.0/default/libnl++/protocols/common/Error.cpp
index 25ae680..1d6bd1c 100644
--- a/automotive/can/1.0/default/libnetdevice/protocols/common/Error.cpp
+++ b/automotive/can/1.0/default/libnl++/protocols/common/Error.cpp
@@ -18,9 +18,9 @@
#include "../MessageDefinition.h"
-#include <libnetdevice/printer.h>
+#include <libnl++/printer.h>
-namespace android::netdevice::protocols::base {
+namespace android::nl::protocols::base {
// clang-format off
Error::Error(int protocol) : MessageDefinition<nlmsgerr>("nlmsg", {
@@ -33,4 +33,4 @@
<< ", msg=" << toString({&data.msg, sizeof(data.msg)}, mProtocol) << "}";
}
-} // namespace android::netdevice::protocols::base
+} // namespace android::nl::protocols::base
diff --git a/automotive/can/1.0/default/libnetdevice/protocols/common/Error.h b/automotive/can/1.0/default/libnl++/protocols/common/Error.h
similarity index 89%
rename from automotive/can/1.0/default/libnetdevice/protocols/common/Error.h
rename to automotive/can/1.0/default/libnl++/protocols/common/Error.h
index 1f3c1dd..782986b 100644
--- a/automotive/can/1.0/default/libnetdevice/protocols/common/Error.h
+++ b/automotive/can/1.0/default/libnl++/protocols/common/Error.h
@@ -18,7 +18,7 @@
#include "../MessageDefinition.h"
-namespace android::netdevice::protocols::base {
+namespace android::nl::protocols::base {
class Error : public MessageDefinition<nlmsgerr> {
public:
@@ -29,4 +29,4 @@
const int mProtocol;
};
-} // namespace android::netdevice::protocols::base
+} // namespace android::nl::protocols::base
diff --git a/automotive/can/1.0/default/libnetdevice/protocols/generic/Ctrl.cpp b/automotive/can/1.0/default/libnl++/protocols/generic/Ctrl.cpp
similarity index 94%
rename from automotive/can/1.0/default/libnetdevice/protocols/generic/Ctrl.cpp
rename to automotive/can/1.0/default/libnl++/protocols/generic/Ctrl.cpp
index 4120008..a3c6736 100644
--- a/automotive/can/1.0/default/libnetdevice/protocols/generic/Ctrl.cpp
+++ b/automotive/can/1.0/default/libnl++/protocols/generic/Ctrl.cpp
@@ -16,7 +16,7 @@
#include "Ctrl.h"
-namespace android::netdevice::protocols::generic {
+namespace android::nl::protocols::generic {
using DataType = AttributeDefinition::DataType;
@@ -52,4 +52,4 @@
}) {}
// clang-format on
-} // namespace android::netdevice::protocols::generic
+} // namespace android::nl::protocols::generic
diff --git a/automotive/can/1.0/default/libnetdevice/protocols/generic/Ctrl.h b/automotive/can/1.0/default/libnl++/protocols/generic/Ctrl.h
similarity index 87%
rename from automotive/can/1.0/default/libnetdevice/protocols/generic/Ctrl.h
rename to automotive/can/1.0/default/libnl++/protocols/generic/Ctrl.h
index 804ed2c..6af87a8 100644
--- a/automotive/can/1.0/default/libnetdevice/protocols/generic/Ctrl.h
+++ b/automotive/can/1.0/default/libnl++/protocols/generic/Ctrl.h
@@ -18,11 +18,11 @@
#include "GenericMessageBase.h"
-namespace android::netdevice::protocols::generic {
+namespace android::nl::protocols::generic {
class Ctrl : public GenericMessageBase {
public:
Ctrl();
};
-} // namespace android::netdevice::protocols::generic
+} // namespace android::nl::protocols::generic
diff --git a/automotive/can/1.0/default/libnetdevice/protocols/generic/Generic.cpp b/automotive/can/1.0/default/libnl++/protocols/generic/Generic.cpp
similarity index 91%
rename from automotive/can/1.0/default/libnetdevice/protocols/generic/Generic.cpp
rename to automotive/can/1.0/default/libnl++/protocols/generic/Generic.cpp
index 633ef3c..1a24914 100644
--- a/automotive/can/1.0/default/libnetdevice/protocols/generic/Generic.cpp
+++ b/automotive/can/1.0/default/libnl++/protocols/generic/Generic.cpp
@@ -19,7 +19,7 @@
#include "Ctrl.h"
#include "Unknown.h"
-namespace android::netdevice::protocols::generic {
+namespace android::nl::protocols::generic {
Generic::Generic() : NetlinkProtocol(NETLINK_GENERIC, "GENERIC", {std::make_shared<Ctrl>()}) {}
@@ -33,4 +33,4 @@
return *(mFamilyRegister[nlmsg_type] = std::make_shared<Unknown>(nlmsg_type));
}
-} // namespace android::netdevice::protocols::generic
+} // namespace android::nl::protocols::generic
diff --git a/automotive/can/1.0/default/libnetdevice/protocols/generic/Generic.h b/automotive/can/1.0/default/libnl++/protocols/generic/Generic.h
similarity index 90%
rename from automotive/can/1.0/default/libnetdevice/protocols/generic/Generic.h
rename to automotive/can/1.0/default/libnl++/protocols/generic/Generic.h
index b4352f6..593c92d 100644
--- a/automotive/can/1.0/default/libnetdevice/protocols/generic/Generic.h
+++ b/automotive/can/1.0/default/libnl++/protocols/generic/Generic.h
@@ -18,7 +18,7 @@
#include "../NetlinkProtocol.h"
-namespace android::netdevice::protocols::generic {
+namespace android::nl::protocols::generic {
/**
* Definition of NETLINK_GENERIC protocol.
@@ -34,4 +34,4 @@
std::map<nlmsgtype_t, std::shared_ptr<const MessageDescriptor>> mFamilyRegister;
};
-} // namespace android::netdevice::protocols::generic
+} // namespace android::nl::protocols::generic
diff --git a/automotive/can/1.0/default/libnetdevice/protocols/generic/GenericMessageBase.cpp b/automotive/can/1.0/default/libnl++/protocols/generic/GenericMessageBase.cpp
similarity index 92%
rename from automotive/can/1.0/default/libnetdevice/protocols/generic/GenericMessageBase.cpp
rename to automotive/can/1.0/default/libnl++/protocols/generic/GenericMessageBase.cpp
index c9f0813..5203368 100644
--- a/automotive/can/1.0/default/libnetdevice/protocols/generic/GenericMessageBase.cpp
+++ b/automotive/can/1.0/default/libnl++/protocols/generic/GenericMessageBase.cpp
@@ -16,7 +16,7 @@
#include "GenericMessageBase.h"
-namespace android::netdevice::protocols::generic {
+namespace android::nl::protocols::generic {
GenericMessageBase::GenericMessageBase(
nlmsgtype_t msgtype, std::string msgname,
@@ -37,4 +37,4 @@
ss << "}";
}
-} // namespace android::netdevice::protocols::generic
+} // namespace android::nl::protocols::generic
diff --git a/automotive/can/1.0/default/libnetdevice/protocols/generic/GenericMessageBase.h b/automotive/can/1.0/default/libnl++/protocols/generic/GenericMessageBase.h
similarity index 92%
rename from automotive/can/1.0/default/libnetdevice/protocols/generic/GenericMessageBase.h
rename to automotive/can/1.0/default/libnl++/protocols/generic/GenericMessageBase.h
index 2a19034..f3b0b31 100644
--- a/automotive/can/1.0/default/libnetdevice/protocols/generic/GenericMessageBase.h
+++ b/automotive/can/1.0/default/libnl++/protocols/generic/GenericMessageBase.h
@@ -20,7 +20,7 @@
#include <linux/genetlink.h>
-namespace android::netdevice::protocols::generic {
+namespace android::nl::protocols::generic {
class GenericMessageBase : public MessageDefinition<struct genlmsghdr> {
public:
@@ -37,4 +37,4 @@
const GenericCommandNameMap mCommandNames;
};
-} // namespace android::netdevice::protocols::generic
+} // namespace android::nl::protocols::generic
diff --git a/automotive/can/1.0/default/libnetdevice/protocols/generic/Unknown.cpp b/automotive/can/1.0/default/libnl++/protocols/generic/Unknown.cpp
similarity index 87%
rename from automotive/can/1.0/default/libnetdevice/protocols/generic/Unknown.cpp
rename to automotive/can/1.0/default/libnl++/protocols/generic/Unknown.cpp
index 9a71d89..17367f0 100644
--- a/automotive/can/1.0/default/libnetdevice/protocols/generic/Unknown.cpp
+++ b/automotive/can/1.0/default/libnl++/protocols/generic/Unknown.cpp
@@ -16,9 +16,9 @@
#include "Unknown.h"
-namespace android::netdevice::protocols::generic {
+namespace android::nl::protocols::generic {
Unknown::Unknown(nlmsgtype_t msgtype)
: GenericMessageBase(msgtype, "Unknown(" + std::to_string(msgtype) + ")") {}
-} // namespace android::netdevice::protocols::generic
+} // namespace android::nl::protocols::generic
diff --git a/automotive/can/1.0/default/libnetdevice/protocols/generic/Unknown.h b/automotive/can/1.0/default/libnl++/protocols/generic/Unknown.h
similarity index 87%
rename from automotive/can/1.0/default/libnetdevice/protocols/generic/Unknown.h
rename to automotive/can/1.0/default/libnl++/protocols/generic/Unknown.h
index 82a5501..62ae19d 100644
--- a/automotive/can/1.0/default/libnetdevice/protocols/generic/Unknown.h
+++ b/automotive/can/1.0/default/libnl++/protocols/generic/Unknown.h
@@ -18,11 +18,11 @@
#include "GenericMessageBase.h"
-namespace android::netdevice::protocols::generic {
+namespace android::nl::protocols::generic {
class Unknown : public GenericMessageBase {
public:
Unknown(nlmsgtype_t msgtype);
};
-} // namespace android::netdevice::protocols::generic
+} // namespace android::nl::protocols::generic
diff --git a/automotive/can/1.0/default/libnetdevice/protocols/route/Link.cpp b/automotive/can/1.0/default/libnl++/protocols/route/Link.cpp
similarity index 97%
rename from automotive/can/1.0/default/libnetdevice/protocols/route/Link.cpp
rename to automotive/can/1.0/default/libnl++/protocols/route/Link.cpp
index 53e1700..26d3e3e 100644
--- a/automotive/can/1.0/default/libnetdevice/protocols/route/Link.cpp
+++ b/automotive/can/1.0/default/libnl++/protocols/route/Link.cpp
@@ -20,7 +20,7 @@
#include <net/if.h>
-namespace android::netdevice::protocols::route {
+namespace android::nl::protocols::route {
using DataType = AttributeDefinition::DataType;
@@ -114,4 +114,4 @@
<< ", change=" << data.ifi_change << "}";
}
-} // namespace android::netdevice::protocols::route
+} // namespace android::nl::protocols::route
diff --git a/automotive/can/1.0/default/libnetdevice/protocols/route/Link.h b/automotive/can/1.0/default/libnl++/protocols/route/Link.h
similarity index 89%
rename from automotive/can/1.0/default/libnetdevice/protocols/route/Link.h
rename to automotive/can/1.0/default/libnl++/protocols/route/Link.h
index bcfce19..4ea3eba 100644
--- a/automotive/can/1.0/default/libnetdevice/protocols/route/Link.h
+++ b/automotive/can/1.0/default/libnl++/protocols/route/Link.h
@@ -20,7 +20,7 @@
#include <linux/rtnetlink.h>
-namespace android::netdevice::protocols::route {
+namespace android::nl::protocols::route {
class Link : public MessageDefinition<struct ifinfomsg> {
public:
@@ -28,4 +28,4 @@
void toStream(std::stringstream& ss, const struct ifinfomsg& data) const override;
};
-} // namespace android::netdevice::protocols::route
+} // namespace android::nl::protocols::route
diff --git a/automotive/can/1.0/default/libnetdevice/protocols/route/Route.cpp b/automotive/can/1.0/default/libnl++/protocols/route/Route.cpp
similarity index 87%
rename from automotive/can/1.0/default/libnetdevice/protocols/route/Route.cpp
rename to automotive/can/1.0/default/libnl++/protocols/route/Route.cpp
index 456072b..c134911 100644
--- a/automotive/can/1.0/default/libnetdevice/protocols/route/Route.cpp
+++ b/automotive/can/1.0/default/libnl++/protocols/route/Route.cpp
@@ -18,8 +18,8 @@
#include "Link.h"
-namespace android::netdevice::protocols::route {
+namespace android::nl::protocols::route {
Route::Route() : NetlinkProtocol(NETLINK_ROUTE, "ROUTE", {std::make_shared<Link>()}) {}
-} // namespace android::netdevice::protocols::route
+} // namespace android::nl::protocols::route
diff --git a/automotive/can/1.0/default/libnetdevice/protocols/route/Route.h b/automotive/can/1.0/default/libnl++/protocols/route/Route.h
similarity index 88%
rename from automotive/can/1.0/default/libnetdevice/protocols/route/Route.h
rename to automotive/can/1.0/default/libnl++/protocols/route/Route.h
index 3051cf9..433e610 100644
--- a/automotive/can/1.0/default/libnetdevice/protocols/route/Route.h
+++ b/automotive/can/1.0/default/libnl++/protocols/route/Route.h
@@ -18,7 +18,7 @@
#include "../NetlinkProtocol.h"
-namespace android::netdevice::protocols::route {
+namespace android::nl::protocols::route {
/**
* Definition of NETLINK_ROUTE protocol.
@@ -28,4 +28,4 @@
Route();
};
-} // namespace android::netdevice::protocols::route
+} // namespace android::nl::protocols::route
diff --git a/automotive/can/1.0/default/libnetdevice/protocols/route/structs.cpp b/automotive/can/1.0/default/libnl++/protocols/route/structs.cpp
similarity index 93%
rename from automotive/can/1.0/default/libnetdevice/protocols/route/structs.cpp
rename to automotive/can/1.0/default/libnl++/protocols/route/structs.cpp
index 48d64f0..ea923bb 100644
--- a/automotive/can/1.0/default/libnetdevice/protocols/route/structs.cpp
+++ b/automotive/can/1.0/default/libnl++/protocols/route/structs.cpp
@@ -16,7 +16,7 @@
#include "structs.h"
-namespace android::netdevice::protocols::route {
+namespace android::nl::protocols::route {
void mapToStream(std::stringstream& ss, const nlbuf<nlattr> attr) {
const auto& [ok, data] = attr.data<rtnl_link_ifmap>().getFirst();
@@ -46,4 +46,4 @@
<< data.retrans_time << '}';
}
-} // namespace android::netdevice::protocols::route
+} // namespace android::nl::protocols::route
diff --git a/automotive/can/1.0/default/libnetdevice/protocols/route/structs.h b/automotive/can/1.0/default/libnl++/protocols/route/structs.h
similarity index 94%
rename from automotive/can/1.0/default/libnetdevice/protocols/route/structs.h
rename to automotive/can/1.0/default/libnl++/protocols/route/structs.h
index e532704..38776fa 100644
--- a/automotive/can/1.0/default/libnetdevice/protocols/route/structs.h
+++ b/automotive/can/1.0/default/libnl++/protocols/route/structs.h
@@ -16,13 +16,13 @@
#pragma once
-#include <libnetdevice/nlbuf.h>
+#include <libnl++/nlbuf.h>
#include <linux/rtnetlink.h>
#include <sstream>
-namespace android::netdevice::protocols::route {
+namespace android::nl::protocols::route {
// rtnl_link_ifmap
void mapToStream(std::stringstream& ss, const nlbuf<nlattr> attr);
@@ -75,4 +75,4 @@
<< data.rx_nohandler << '}';
}
-} // namespace android::netdevice::protocols::route
+} // namespace android::nl::protocols::route