+ struct GNUNET_MessageHeader * msg;
+ unsigned int size;
+
+ if (phase==0)
+ {
+ char * host_str = NULL;
+ /* resetting buffers */
+ buffer_in.size = HTTP_BUFFER_SIZE;
+ buffer_in.pos = 0;
+ buffer_in.len = 0;
+
+ buffer_out.size = HTTP_BUFFER_SIZE;
+ buffer_out.pos = 0;
+ buffer_out.len = 0;
+
+ if (test_no_ident.test_executed == GNUNET_NO)
+ {
+ /* Connecting to peer without identification */
+ char * ident = "";
+ GNUNET_asprintf (&host_str, "http://%s/%s",test_addr,ident);
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO, _("Connecting to peer without any peer identification.\n"));
+ test_no_ident.test_executed = GNUNET_YES;
+ send_data ( &test_no_ident, host_str);
+ GNUNET_free (host_str);
+ return;
+ }
+ if (test_too_short_ident.test_executed == GNUNET_NO)
+ {
+ char * ident = "AAAAAAAAAA";
+ /* Connecting to peer with too short identification */
+ GNUNET_asprintf (&host_str, "http://%s/%s",test_addr,ident);
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO, _("Connecting to peer with too short peer identification.\n"));
+ test_too_short_ident.test_executed = GNUNET_YES;
+ send_data ( &test_too_short_ident, host_str);
+ GNUNET_free (host_str);
+ return;
+ }
+
+ if (test_too_long_ident.test_executed == GNUNET_NO)
+ {
+ char * ident = "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA";
+
+ /* Connecting to peer with too long identification */
+ GNUNET_asprintf (&host_str, "http://%s/%s",test_addr,ident);
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO, _("Connecting to peer with too long peer identification.\n"));
+ test_too_long_ident.test_executed = GNUNET_YES;
+ send_data ( &test_too_long_ident, host_str);
+ GNUNET_free (host_str);
+ return;
+ }
+ if (test_valid_ident.test_executed == GNUNET_NO)
+ {
+ struct GNUNET_CRYPTO_HashAsciiEncoded ident;
+ GNUNET_CRYPTO_hash_to_enc(&my_identity.hashPubKey,&ident);
+ GNUNET_asprintf (&host_str, "http://%s/%s%s",test_addr,(char *) &ident,";0");
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO, _("Connecting to peer with valid peer identification.\n"));
+ test_valid_ident.test_executed = GNUNET_YES;
+ send_data ( &test_valid_ident, host_str);
+ GNUNET_free (host_str);
+ return;
+ }
+ }
+ if (phase==1)
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO, _("\nPhase 1: transmit data to all suggested addresses\n\n"));
+ /* Using one of the addresses the plugin proposed */
+ GNUNET_assert (addr_head->addr != NULL);
+
+ struct Plugin_Address * tmp_addr;
+ struct GNUNET_MessageHeader msg;
+ char * tmp = GNUNET_malloc(sizeof(struct GNUNET_MessageHeader));
+ char address[INET6_ADDRSTRLEN];
+ unsigned int port;
+ unsigned int type = 10;
+
+ msg.size=htons(sizeof(struct GNUNET_MessageHeader));
+ tmp_addr = addr_head;
+ /* send a message to all addresses advertised by plugin */
+
+ int count = 0;
+ while (tmp_addr != NULL)
+ {
+ if (tmp_addr->addrlen == (sizeof (struct IPv4HttpAddress)))
+ {
+ inet_ntop(AF_INET, (struct in_addr *) tmp_addr->addr,address,INET_ADDRSTRLEN);
+ port = ntohs(((struct IPv4HttpAddress *) tmp_addr->addr)->u_port);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"Sending message to addres no. %u: `%s':%u\n", count,address, port);
+ }
+ if (tmp_addr->addrlen == (sizeof (struct IPv6HttpAddress)))
+ {
+ inet_ntop(AF_INET6, (struct in6_addr *) tmp_addr->addr,address,INET6_ADDRSTRLEN);
+ port = ntohs(((struct IPv6HttpAddress *) tmp_addr->addr)->u6_port);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"Sending message to addres no. %u: `%s':%u\n", count,address,port);
+ }
+ msg.type=htons(type);
+ memcpy(tmp,&msg,sizeof(struct GNUNET_MessageHeader));
+ api->send(api->cls, &my_identity, tmp, sizeof(struct GNUNET_MessageHeader), 0, TIMEOUT, NULL,tmp_addr->addr, tmp_addr->addrlen, GNUNET_YES, &task_send_cont, &fail_msgs_transmited_to_local_addrs);
+ tmp_addr = tmp_addr->next;
+
+ count ++;
+ type ++;
+ }