* Copyright (c) 1993, 1994, 1995, 1996 Rick Sladkey <jrs@world.std.com>
* Copyright (c) 1996-2000 Wichert Akkerman <wichert@cistron.nl>
* Copyright (c) 2005-2016 Dmitry V. Levin <ldv@altlinux.org>
+ * Copyright (c) 2016-2017 The strace developers.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
return false;
}
+bool
+decode_inet_addr(struct tcb *const tcp,
+ const kernel_ulong_t addr,
+ const unsigned int len,
+ const int family,
+ const char *const var_name)
+{
+ union {
+ struct in_addr a4;
+ struct in6_addr a6;
+ } addrbuf;
+ size_t size = 0;
+
+ switch (family) {
+ case AF_INET:
+ size = sizeof(addrbuf.a4);
+ break;
+ case AF_INET6:
+ size = sizeof(addrbuf.a6);
+ break;
+ }
+
+ if (!size || len < size) {
+ if (var_name)
+ tprintf("%s=", var_name);
+ printstr_ex(tcp, addr, len, QUOTE_FORCE_HEX);
+ return false;
+ }
+
+ if (umoven(tcp, addr, size, &addrbuf) < 0) {
+ if (var_name)
+ tprintf("%s=", var_name);
+ printaddr(addr);
+ return false;
+ }
+
+ return print_inet_addr(family, &addrbuf, size, var_name);
+}
+
static void
print_sockaddr_data_in(const void *const buf, const int addrlen)
{