diff options
| author | Joel Scherpelz <jscherpelz@google.com> | 2017-06-01 13:20:21 +0900 |
|---|---|---|
| committer | Joel Scherpelz <jscherpelz@google.com> | 2017-06-15 01:45:32 +0000 |
| commit | de9379641d5fc4b5912d6838075df9490518cca6 (patch) | |
| tree | cdd754135c4c04d6bc8ac3a7c602b73c8df7bc4a /libnetdutils/Socket.cpp | |
| parent | c60c6bd7bd12f5c9ccdaff7537d60da2d240fe22 (diff) | |
| download | platform_system_netd-de9379641d5fc4b5912d6838075df9490518cca6.tar.gz platform_system_netd-de9379641d5fc4b5912d6838075df9490518cca6.tar.bz2 platform_system_netd-de9379641d5fc4b5912d6838075df9490518cca6.zip | |
Enable RFC 7217 stable privacy addresses
... on kernels that support this feature. Android property server is
used in combination with SELinux policy to limit access to the
necessary stable secret.
This change also makes some small improvements and fixes to
libnetdutils.
ip -6 addr indicates stable_privacy addresses with "flags 800"
wlan0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 state UP qlen 3000
inet6 fdd5:6241:900d:0:d547:442:33d7:1982/64 scope global temporary dynamic
inet6 fdd5:6241:900d:0:9dbe:3875:1cab:eaf2/64 scope global mngtmpaddr dynamic flags 800
inet6 2401:fa00:4:ca0:d547:442:33d7:1982/64 scope global temporary dynamic
inet6 2401:fa00:4:ca0:6281:68a2:7124:6848/64 scope global mngtmpaddr dynamic flags 800
inet6 fe80::d5a7:18ed:4ea7:50d8/64 scope link flags 800
Test: as follows
- built
- flashed
- booted
- "runtest -x .../netd_unit_test.cpp" passes
Bug: 17613910
Change-Id: I0e0b6bbd15cb9d46368bed8aef5dac2f6183d32a
Diffstat (limited to 'libnetdutils/Socket.cpp')
| -rw-r--r-- | libnetdutils/Socket.cpp | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/libnetdutils/Socket.cpp b/libnetdutils/Socket.cpp new file mode 100644 index 000000000..e962b6e5d --- /dev/null +++ b/libnetdutils/Socket.cpp @@ -0,0 +1,35 @@ +/* + * Copyright (C) 2017 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 <arpa/inet.h> + +#include "netdutils/Slice.h" +#include "netdutils/Socket.h" + +namespace android { +namespace netdutils { + +StatusOr<std::string> toString(const in6_addr& addr) { + std::array<char, INET6_ADDRSTRLEN> out = {}; + auto* rv = inet_ntop(AF_INET6, &addr, out.data(), out.size()); + if (rv == nullptr) { + return statusFromErrno(errno, "inet_ntop() failed"); + } + return std::string(out.data()); +} + +} // namespace netdutils +} // namespace android |
