diff options
author | Sree Harsha Totakura <totakura@in.tum.de> | 2012-08-10 15:33:26 +0000 |
---|---|---|
committer | Sree Harsha Totakura <totakura@in.tum.de> | 2012-08-10 15:33:26 +0000 |
commit | 4693fb2d1f0c831dfc1621ab76e85e0ba233e3d7 (patch) | |
tree | b71343462b72429fb749f463026174e34f7d79c3 /src/testbed/gnunet-service-testbed.c | |
parent | 8c15f0c9f77a5014f0331f80e2a60914873f93b5 (diff) | |
download | gnunet-4693fb2d1f0c831dfc1621ab76e85e0ba233e3d7.tar.gz gnunet-4693fb2d1f0c831dfc1621ab76e85e0ba233e3d7.zip |
controller hostname in init
Diffstat (limited to 'src/testbed/gnunet-service-testbed.c')
-rw-r--r-- | src/testbed/gnunet-service-testbed.c | 44 |
1 files changed, 20 insertions, 24 deletions
diff --git a/src/testbed/gnunet-service-testbed.c b/src/testbed/gnunet-service-testbed.c index ff19250aa..c9781ba4e 100644 --- a/src/testbed/gnunet-service-testbed.c +++ b/src/testbed/gnunet-service-testbed.c | |||
@@ -935,8 +935,8 @@ handle_init (void *cls, | |||
935 | { | 935 | { |
936 | const struct GNUNET_TESTBED_InitMessage *msg; | 936 | const struct GNUNET_TESTBED_InitMessage *msg; |
937 | struct GNUNET_TESTBED_Host *host; | 937 | struct GNUNET_TESTBED_Host *host; |
938 | void *addr; | 938 | const char *controller_hostname; |
939 | size_t addrlen; | 939 | uint16_t msize; |
940 | 940 | ||
941 | if (NULL != master_context) | 941 | if (NULL != master_context) |
942 | { | 942 | { |
@@ -944,29 +944,26 @@ handle_init (void *cls, | |||
944 | GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); | 944 | GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); |
945 | return; | 945 | return; |
946 | } | 946 | } |
947 | msg = (const struct GNUNET_TESTBED_InitMessage *) message; | 947 | msg = (const struct GNUNET_TESTBED_InitMessage *) message; |
948 | msize = ntohs (message->size); | ||
949 | if (msize <= sizeof (struct GNUNET_TESTBED_InitMessage)) | ||
950 | { | ||
951 | GNUNET_break (0); | ||
952 | GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); | ||
953 | return; | ||
954 | } | ||
955 | msize -= sizeof (struct GNUNET_TESTBED_InitMessage); | ||
956 | controller_hostname = (const char *) &msg[1]; | ||
957 | if ('\0' != controller_hostname[msize - 1]) | ||
958 | { | ||
959 | GNUNET_break (0); | ||
960 | GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); | ||
961 | return; | ||
962 | } | ||
948 | master_context = GNUNET_malloc (sizeof (struct Context)); | 963 | master_context = GNUNET_malloc (sizeof (struct Context)); |
949 | master_context->client = client; | 964 | master_context->client = client; |
950 | master_context->host_id = ntohl (msg->host_id); | 965 | master_context->host_id = ntohl (msg->host_id); |
951 | GNUNET_assert (GNUNET_OK == | 966 | master_context->master_ip = GNUNET_strdup (controller_hostname); |
952 | GNUNET_SERVER_client_get_address (client, &addr, &addrlen)); | ||
953 | master_context->master_ip = GNUNET_malloc (NI_MAXHOST); | ||
954 | if (0 != getnameinfo (addr, addrlen, master_context->master_ip, NI_MAXHOST, | ||
955 | NULL, 0, NI_NUMERICHOST)) | ||
956 | { | ||
957 | LOG (GNUNET_ERROR_TYPE_WARNING, | ||
958 | "Cannot determine the ip of master controller: %s\n", STRERROR (errno)); | ||
959 | GNUNET_free (addr); | ||
960 | GNUNET_free (master_context->master_ip); | ||
961 | GNUNET_assert (0); | ||
962 | } | ||
963 | GNUNET_free (addr); | ||
964 | if (0 == strcasecmp (master_context->master_ip, "localhost")) | ||
965 | { /* Hack for connections via unix sockets */ | ||
966 | LOG_DEBUG ("May be using local sockets - assuming loopback for master ip\n"); | ||
967 | GNUNET_free (master_context->master_ip); | ||
968 | master_context->master_ip = strdup ("127.0.0.1"); | ||
969 | } | ||
970 | LOG_DEBUG ("Master Controller IP: %s\n", master_context->master_ip); | 967 | LOG_DEBUG ("Master Controller IP: %s\n", master_context->master_ip); |
971 | master_context->system = | 968 | master_context->system = |
972 | GNUNET_TESTING_system_create ("testbed", master_context->master_ip); | 969 | GNUNET_TESTING_system_create ("testbed", master_context->master_ip); |
@@ -2031,8 +2028,7 @@ testbed_run (void *cls, | |||
2031 | { | 2028 | { |
2032 | static const struct GNUNET_SERVER_MessageHandler message_handlers[] = | 2029 | static const struct GNUNET_SERVER_MessageHandler message_handlers[] = |
2033 | { | 2030 | { |
2034 | {&handle_init, NULL, GNUNET_MESSAGE_TYPE_TESTBED_INIT, | 2031 | {&handle_init, NULL, GNUNET_MESSAGE_TYPE_TESTBED_INIT, 0}, |
2035 | sizeof (struct GNUNET_TESTBED_InitMessage)}, | ||
2036 | {&handle_add_host, NULL, GNUNET_MESSAGE_TYPE_TESTBED_ADDHOST, 0}, | 2032 | {&handle_add_host, NULL, GNUNET_MESSAGE_TYPE_TESTBED_ADDHOST, 0}, |
2037 | {&handle_configure_shared_service, NULL, | 2033 | {&handle_configure_shared_service, NULL, |
2038 | GNUNET_MESSAGE_TYPE_TESTBED_SERVICESHARE, 0}, | 2034 | GNUNET_MESSAGE_TYPE_TESTBED_SERVICESHARE, 0}, |