From 6a5418a851020b5bc30c0f35b5f6bb6ca3c889b1 Mon Sep 17 00:00:00 2001 From: Steffen Vogel Date: Tue, 9 Sep 2014 13:26:54 +0000 Subject: [PATCH] fixed address resolution for 'send' tool git-svn-id: https://zerberus.eonerc.rwth-aachen.de:8443/svn/s2ss/trunk@232 8ec27952-4edc-4aab-86aa-e87bb2611832 --- server/src/send.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/server/src/send.c b/server/src/send.c index d4b1a12b7..4fa1aa576 100644 --- a/server/src/send.c +++ b/server/src/send.c @@ -15,6 +15,7 @@ #include #include #include +#include #include "config.h" #include "utils.h" @@ -57,14 +58,19 @@ int main(int argc, char *argv[]) if (resolve_addr(argv[1], &n.remote, 0)) error("Failed to resolve remote address: %s", argv[1]); - if (argc == 3 && resolve_addr(argv[2], &n.local, 0)) - error("Failed to resolve local address: %s", argv[2]); + if (argc == 3) { + if (resolve_addr(argv[2], &n.local, AI_PASSIVE)) + error("Failed to resolve local address: %s", argv[2]); + } else { n.local.sin_family = AF_INET; n.local.sin_addr.s_addr = INADDR_ANY; - n.local.sin_port = 0; + n.local.sin_port = 0; /* random port */ } + debug(1, "We listen at %s:%u", inet_ntoa(n.local.sin_addr), ntohs(n.local.sin_port)); + debug(1, "We sent to %s:%u", inet_ntoa(n.remote.sin_addr), ntohs(n.remote.sin_port)); + if (node_connect(&n)) error("Failed to connect node");