mirror of
https://git.rwth-aachen.de/acs/public/villas/node/
synced 2025-03-09 00:00:00 +01:00
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
This commit is contained in:
parent
2df4865e02
commit
6a5418a851
1 changed files with 9 additions and 3 deletions
|
@ -15,6 +15,7 @@
|
|||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <netdb.h>
|
||||
|
||||
#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");
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue