summaryrefslogtreecommitdiff
path: root/src/test/test-local-addresses.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2021-03-26 18:06:26 +0100
committerLennart Poettering <lennart@poettering.net>2021-04-23 12:01:41 +0200
commit54e6f97bc9931679aa9b895546621b15e0f464a4 (patch)
tree2ebb6e370a084956daefa2f66ecb178fd7c7be54 /src/test/test-local-addresses.c
parentce0cedacc4dbfc465797b039b3d3af0cd13b6bd5 (diff)
downloadsystemd-54e6f97bc9931679aa9b895546621b15e0f464a4.tar.gz
local-addresses: add helper for determining local "outbound" IP addresses
This adds a small helper, similar in style to local_addresses() and local_gateways() that determines the local "outbound" addresses. What's an "outbound" address supposed to be? The local IP addresses that are the most likely used for outbound communication. It's determined by using connect() towards the default gws on an UDP socket, and then reading the address of the socket this caused it to be bound to. This is not the "public" or "external" IP address of the local system, and is not supposed to be. It's just the local IP addresses that are likely the ones going to be used by the local IP stack for communication with other hosts.
Diffstat (limited to 'src/test/test-local-addresses.c')
-rw-r--r--src/test/test-local-addresses.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/test/test-local-addresses.c b/src/test/test-local-addresses.c
index 7eeddd28f4..7b75132e18 100644
--- a/src/test/test-local-addresses.c
+++ b/src/test/test-local-addresses.c
@@ -40,5 +40,12 @@ int main(int argc, char *argv[]) {
print_local_addresses(a, (unsigned) n);
free(a);
+ n = local_outbounds(NULL, 0, AF_UNSPEC, &a);
+ assert_se(n >= 0);
+
+ printf("Local Outbounds:\n");
+ print_local_addresses(a, (unsigned) n);
+ free(a);
+
return 0;
}