summaryrefslogtreecommitdiffhomepage
path: root/test/syscalls/linux/ip_socket_test_util.cc
diff options
context:
space:
mode:
authorTamir Duberstein <tamird@google.com>2020-01-08 13:52:56 -0800
committergVisor bot <gvisor-bot@google.com>2020-01-08 13:54:19 -0800
commitd01240d871c8737989b1af27c137f6ae40bc6d37 (patch)
tree11d58038add06d2499174c102aa704db874e9f33 /test/syscalls/linux/ip_socket_test_util.cc
parentbb96f525769b0929bdcce7f933ead70af1b85e6d (diff)
Take addresses as const
PiperOrigin-RevId: 288767927
Diffstat (limited to 'test/syscalls/linux/ip_socket_test_util.cc')
-rw-r--r--test/syscalls/linux/ip_socket_test_util.cc10
1 files changed, 5 insertions, 5 deletions
diff --git a/test/syscalls/linux/ip_socket_test_util.cc b/test/syscalls/linux/ip_socket_test_util.cc
index 8398fc95f..6b472eb2f 100644
--- a/test/syscalls/linux/ip_socket_test_util.cc
+++ b/test/syscalls/linux/ip_socket_test_util.cc
@@ -187,24 +187,24 @@ PosixErrorOr<int> IfAddrHelper::GetIndex(std::string name) {
return InterfaceIndex(name);
}
-std::string GetAddr4Str(in_addr* a) {
+std::string GetAddr4Str(const in_addr* a) {
char str[INET_ADDRSTRLEN];
inet_ntop(AF_INET, a, str, sizeof(str));
return std::string(str);
}
-std::string GetAddr6Str(in6_addr* a) {
+std::string GetAddr6Str(const in6_addr* a) {
char str[INET6_ADDRSTRLEN];
inet_ntop(AF_INET6, a, str, sizeof(str));
return std::string(str);
}
-std::string GetAddrStr(sockaddr* a) {
+std::string GetAddrStr(const sockaddr* a) {
if (a->sa_family == AF_INET) {
- auto src = &(reinterpret_cast<sockaddr_in*>(a)->sin_addr);
+ auto src = &(reinterpret_cast<const sockaddr_in*>(a)->sin_addr);
return GetAddr4Str(src);
} else if (a->sa_family == AF_INET6) {
- auto src = &(reinterpret_cast<sockaddr_in6*>(a)->sin6_addr);
+ auto src = &(reinterpret_cast<const sockaddr_in6*>(a)->sin6_addr);
return GetAddr6Str(src);
}
return std::string("<invalid>");