[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r6628 - in GNUnet/src/applications: chat testing topology_d
From: |
gnunet |
Subject: |
[GNUnet-SVN] r6628 - in GNUnet/src/applications: chat testing topology_default |
Date: |
Wed, 26 Mar 2008 18:20:18 -0600 (MDT) |
Author: nevans
Date: 2008-03-26 18:20:18 -0600 (Wed, 26 Mar 2008)
New Revision: 6628
Modified:
GNUnet/src/applications/chat/clientapi.c
GNUnet/src/applications/testing/remote.c
GNUnet/src/applications/testing/remote.h
GNUnet/src/applications/testing/remotetest.c
GNUnet/src/applications/testing/remotetopologies.c
GNUnet/src/applications/topology_default/topology.c
Log:
Modified: GNUnet/src/applications/chat/clientapi.c
===================================================================
--- GNUnet/src/applications/chat/clientapi.c 2008-03-26 23:49:22 UTC (rev
6627)
+++ GNUnet/src/applications/chat/clientapi.c 2008-03-27 00:20:18 UTC (rev
6628)
@@ -58,7 +58,7 @@
ret = GNUNET_OK;
while ((ret == GNUNET_OK) && (room->shutdown_flag != GNUNET_YES))
{
-
+
if (disconnected)
{
GNUNET_thread_sleep (15 * GNUNET_CRON_SECONDS);
@@ -73,14 +73,14 @@
else
break;
}
-
+
reply = NULL;
if (GNUNET_OK != GNUNET_client_connection_read (room->sock, &reply))
{
disconnected = GNUNET_YES;
continue;
}
-
+
if (((reply->size < ntohs (sizeof (CS_chat_MESSAGE)))
|| (reply->type != ntohs (GNUNET_CS_PROTO_CHAT_MSG)))
&& ((reply->size < ntohs (sizeof (CS_chat_ROOM_MEMBER_MESSAGE)))
@@ -301,7 +301,7 @@
void
GNUNET_CHAT_leave_room (struct GNUNET_CHAT_Room *chat_room)
{
- GNUNET_mutex_lock(chatMutex);
+ GNUNET_mutex_lock (chatMutex);
void *unused;
chat_room->shutdown_flag = GNUNET_YES;
GNUNET_client_connection_close_forever (chat_room->sock);
@@ -312,7 +312,7 @@
GNUNET_free (chat_room->memberInfo);
GNUNET_client_connection_destroy (chat_room->sock);
GNUNET_free (chat_room);
- GNUNET_mutex_unlock(chatMutex);
+ GNUNET_mutex_unlock (chatMutex);
}
/**
Modified: GNUnet/src/applications/testing/remote.c
===================================================================
--- GNUnet/src/applications/testing/remote.c 2008-03-26 23:49:22 UTC (rev
6627)
+++ GNUnet/src/applications/testing/remote.c 2008-03-27 00:20:18 UTC (rev
6628)
@@ -36,10 +36,9 @@
const unsigned long long MIN_NUMBER_DAEMONS = 1;
const unsigned long long MAX_NUMBER_DAEMONS = -1;
-static struct GNUNET_REMOTE_daemon_list *head;
-static struct GNUNET_REMOTE_daemon_list **list_as_array;
+static struct GNUNET_REMOTE_host_list *head;
+static struct GNUNET_REMOTE_host_list **list_as_array;
-
/**
* Starts a single gnunet daemon on a remote machine
*
@@ -54,7 +53,7 @@
GNUNET_REMOTE_start_daemon (char *gnunetd_home,
char *localConfigPath, char *configFileName,
char *remote_config_path, char *hostname,
- char *username)
+ char *username,char *remote_friend_file_path)
{
char *cmd;
int length;
@@ -71,6 +70,19 @@
GNUNET_free (cmd);
length =
+ snprintf (NULL, 0, "ssh address@hidden touch %s", username, hostname,
+ remote_friend_file_path);
+ cmd = GNUNET_malloc (length + 1);
+ snprintf (cmd, length + 1, "ssh address@hidden touch %s", username, hostname,
+ remote_friend_file_path);
+
+ fprintf (stderr, "ssh command is : %s \n", cmd);
+
+ system (cmd);
+
+ GNUNET_free (cmd);
+
+ length =
snprintf (NULL, 0, "ssh address@hidden %sgnunetd -c %s%s", username,
hostname,
gnunetd_home, remote_config_path, configFileName);
cmd = GNUNET_malloc (length + 1);
@@ -82,16 +94,18 @@
system (cmd);
GNUNET_free (cmd);
+
+
return GNUNET_OK;
}
int
GNUNET_REMOTE_start_daemons (struct GNUNET_GC_Configuration *newcfg,
- unsigned int number_of_daemons)
+ unsigned long long number_of_daemons,
GNUNET_REMOTE_TOPOLOGIES type_of_topology)
{
struct GNUNET_GC_Configuration *basecfg;
- struct GNUNET_REMOTE_daemon_list *array_of_pointers[number_of_daemons];
- struct GNUNET_REMOTE_daemon_list *temp_pos;
+ struct GNUNET_REMOTE_host_list *array_of_pointers[number_of_daemons];
+ struct GNUNET_REMOTE_host_list *temp_pos;
list_as_array = &array_of_pointers[0];
char *ssh_username;
@@ -122,6 +136,7 @@
unsigned int j;
unsigned int pos;
int temp_remote_config_path_length;
+ int friend_location_length;
int ret;
char *ipk_dir;
@@ -239,8 +254,6 @@
"GNUNETD_HOME",
temp_remote_config_path);
- GNUNET_free (temp_remote_config_path);
-
GNUNET_GC_set_configuration_value_number (basecfg, NULL, "NETWORK",
"PORT",
starting_port +
@@ -280,13 +293,22 @@
temp = GNUNET_malloc (32);
if (1 == sscanf (temp_path, "/tmp/%s", temp))
{
- GNUNET_REMOTE_start_daemon (remote_gnunetd_path, "/tmp/",
- temp, remote_config_path,
- curr_host, ssh_username);
temp_pos =
- GNUNET_malloc (sizeof (struct GNUNET_REMOTE_daemon_list));
+ GNUNET_malloc (sizeof (struct GNUNET_REMOTE_host_list));
temp_pos->hostname = GNUNET_malloc (strlen (curr_host));
strcpy (temp_pos->hostname, curr_host);
+
+ temp_pos->username = GNUNET_malloc(strlen(ssh_username));
+ strcpy (temp_pos->username,ssh_username);
+
+ friend_location_length =
snprintf(NULL,0,"%s/friends",temp_remote_config_path);
+ temp_pos->remote_friend_file_path =
GNUNET_malloc(friend_location_length + 1);
+
snprintf(temp_pos->remote_friend_file_path,friend_location_length +
1,"%s/friends",temp_remote_config_path);
+
+ GNUNET_REMOTE_start_daemon (remote_gnunetd_path, "/tmp/",
+ temp, remote_config_path,
+ curr_host,
ssh_username,temp_pos->remote_friend_file_path);
+
GNUNET_GC_get_configuration_value_number (basecfg,
"NETWORK",
"PORT",
@@ -297,6 +319,8 @@
array_of_pointers[count_started] = temp_pos;
count_started++;
}
+
+ GNUNET_free (temp_remote_config_path);
GNUNET_free (temp);
UNLINK (temp_path);
GNUNET_free (temp_path);
@@ -314,7 +338,21 @@
"PIDFILE",
temp_pid_file);
GNUNET_free (temp_pid_file);
+
+ temp_remote_config_path_length =
+ snprintf (NULL, 0, "%s%d", remote_config_path, j);
+ temp_remote_config_path =
+ GNUNET_malloc (temp_remote_config_path_length + 1);
+ snprintf (temp_remote_config_path,
+ temp_remote_config_path_length + 1, "%s%d",
+ remote_config_path, j);
+ GNUNET_GC_set_configuration_value_string (basecfg,
NULL, "PATHS",
+ "GNUNETD_HOME",
+ temp_remote_config_path);
+
+
+
GNUNET_GC_set_configuration_value_number (basecfg, NULL,
"NETWORK", "PORT",
starting_port +
@@ -362,14 +400,22 @@
temp = GNUNET_malloc (32);
if (1 == sscanf (temp_path, "/tmp/%s", temp))
{
- GNUNET_REMOTE_start_daemon (remote_gnunetd_path,
- "/tmp/", temp,
- remote_config_path,
- curr_host, ssh_username);
temp_pos =
- GNUNET_malloc (sizeof (struct GNUNET_REMOTE_daemon_list));
+ GNUNET_malloc (sizeof (struct GNUNET_REMOTE_host_list));
temp_pos->hostname = GNUNET_malloc (strlen (curr_host));
strcpy (temp_pos->hostname, curr_host);
+
+ temp_pos->username =
GNUNET_malloc(strlen(ssh_username));
+ strcpy (temp_pos->username,ssh_username);
+
+ friend_location_length =
snprintf(NULL,0,"%s/friends",temp_remote_config_path);
+ temp_pos->remote_friend_file_path =
GNUNET_malloc(friend_location_length + 1);
+
snprintf(temp_pos->remote_friend_file_path,friend_location_length +
1,"%s/friends",temp_remote_config_path);
+
+ GNUNET_REMOTE_start_daemon (remote_gnunetd_path, "/tmp/",
+ temp, remote_config_path,
+ curr_host,
ssh_username,temp_pos->remote_friend_file_path);
+
GNUNET_GC_get_configuration_value_number (basecfg,
"NETWORK",
"PORT",
@@ -380,6 +426,7 @@
array_of_pointers[count_started] = temp_pos;
count_started++;
}
+ GNUNET_free (temp_remote_config_path);
UNLINK (temp_path);
GNUNET_free (temp_path);
GNUNET_free (temp);
@@ -390,7 +437,8 @@
++i;
}
ret =
- GNUNET_REMOTE_create_topology (GNUNET_REMOTE_CLIQUE, number_of_daemons);
+ GNUNET_REMOTE_create_topology (type_of_topology, number_of_daemons);
+
GNUNET_free (base_config);
GNUNET_free (remote_pid_path);
GNUNET_free (data_dir);
@@ -407,8 +455,14 @@
GNUNET_REMOTE_create_topology (GNUNET_REMOTE_TOPOLOGIES t,
int number_of_daemons)
{
+ FILE *temp_friend_handle;
int ret;
-
+ struct GNUNET_REMOTE_host_list *pos;
+ struct GNUNET_REMOTE_friends_list *friend_pos;
+
+ char *cmd;
+ int length;
+
ret = GNUNET_OK;
switch (t)
{
@@ -416,16 +470,51 @@
ret = GNUNET_REMOTE_connect_clique (head);
break;
case GNUNET_REMOTE_SMALL_WORLD:
+ ret = GNUNET_SYSERR;
break;
case GNUNET_REMOTE_RING:
+ ret = GNUNET_SYSERR;
break;
case GNUNET_REMOTE_2D_TORUS:
ret = GNUNET_REMOTE_connect_2d_torus (number_of_daemons, list_as_array);
break;
default:
+ ret = GNUNET_SYSERR;
break;
}
+
+ if(ret == GNUNET_OK)
+ {
+ pos = head;
+ while(pos != NULL)
+ {
+ fprintf(stderr,"Friend list of
%s:%lld\n",pos->hostname,pos->port);
+ temp_friend_handle = fopen ("friend.temp", "wt");
+ friend_pos = pos->friend_entries;
+ while(friend_pos != NULL)
+ {
+ fprintf(stderr,"\t%s\n",(const char
*)friend_pos->nodeid);
+ fprintf(temp_friend_handle,"%s\n",(const char
*)friend_pos->nodeid);
+ friend_pos = friend_pos->next;
+ }
+
+ fclose(temp_friend_handle);
+ length = snprintf (NULL, 0, "scp %s address@hidden:%s",
"friend.temp", pos->username, pos->hostname, pos->remote_friend_file_path);
+ cmd = GNUNET_malloc (length + 1);
+ snprintf (cmd, length + 1, "scp %s address@hidden:%s",
"friend.temp", pos->username, pos->hostname, pos->remote_friend_file_path);
+ fprintf (stderr, "scp command for friend file copy is :
%s \n", cmd);
+ system (cmd);
+
+ pos = pos->next;
+ }
+
+ system("rm friend.temp");
+ }
+ else
+ {
+ fprintf(stderr,"connect didn't return well!\n");
+ }
return ret;
}
Modified: GNUnet/src/applications/testing/remote.h
===================================================================
--- GNUnet/src/applications/testing/remote.h 2008-03-26 23:49:22 UTC (rev
6627)
+++ GNUnet/src/applications/testing/remote.h 2008-03-27 00:20:18 UTC (rev
6628)
@@ -31,28 +31,9 @@
#include "gnunet_protocols.h"
#include "gnunet_identity_lib.h"
#include "gnunet_util.h"
-#include "gnunet_testing_lib.h"
+#include "gnunet_remote_lib.h"
-typedef enum
-{
- GNUNET_REMOTE_CLIQUE = 0,
- GNUNET_REMOTE_SMALL_WORLD = 1,
- GNUNET_REMOTE_RING = 2,
- GNUNET_REMOTE_2D_TORUS,
-} GNUNET_REMOTE_TOPOLOGIES;
-
-struct GNUNET_REMOTE_daemon_list
-{
- struct GNUNET_REMOTE_daemon_list *next;
- char *hostname;
- unsigned long long port;
-
-};
-
-
-
-
/**
* Establish a connection between two GNUnet daemons
*
@@ -65,6 +46,10 @@
int
GNUNET_REMOTE_connect_daemons (char *ip1, unsigned short port1, char *ip2,
unsigned short port2);
+
+int
+GNUNET_REMOTE_get_daemons_information (char *hostname1, unsigned short port1,
+ char *hostname2, unsigned short port2,
GNUNET_EncName **host1entry, GNUNET_EncName **host2entry);
/**
* Create a topology (connect the running gnunetd's) that corresponds
Modified: GNUnet/src/applications/testing/remotetest.c
===================================================================
--- GNUnet/src/applications/testing/remotetest.c 2008-03-26 23:49:22 UTC
(rev 6627)
+++ GNUnet/src/applications/testing/remotetest.c 2008-03-27 00:20:18 UTC
(rev 6628)
@@ -28,6 +28,7 @@
#include "gnunet_protocols.h"
#include "gnunet_remote_lib.h"
#include "gnunet_directories.h"
+#include "remote.h"
static char *configFile = GNUNET_DEFAULT_DAEMON_CONFIG_FILE;
static unsigned long long number_of_daemons;
@@ -77,7 +78,7 @@
return -1;
}
- GNUNET_REMOTE_start_daemons (hostConfig, number_of_daemons);
+ GNUNET_REMOTE_start_daemons (hostConfig, number_of_daemons,
GNUNET_REMOTE_CLIQUE);
GNUNET_GC_free (hostConfig);
GNUNET_fini (ectx, cfg);
Modified: GNUnet/src/applications/testing/remotetopologies.c
===================================================================
--- GNUnet/src/applications/testing/remotetopologies.c 2008-03-26 23:49:22 UTC
(rev 6627)
+++ GNUnet/src/applications/testing/remotetopologies.c 2008-03-27 00:20:18 UTC
(rev 6628)
@@ -23,6 +23,7 @@
* @brief helper to set up topologies for testing
* @author Nathan Evans
*/
+#include "remote.h"
static int
printInfo (void *data,
@@ -41,29 +42,57 @@
}
int
-GNUNET_REMOTE_connect_clique (struct GNUNET_REMOTE_daemon_list *main_list)
+GNUNET_REMOTE_connect_clique (struct GNUNET_REMOTE_host_list *main_list)
{
- struct GNUNET_REMOTE_daemon_list *pos = main_list;
- struct GNUNET_REMOTE_daemon_list *iter_pos = main_list;
+ struct GNUNET_REMOTE_host_list *pos = main_list;
+ struct GNUNET_REMOTE_host_list *iter_pos = main_list;
+ GNUNET_EncName *node1;
+ GNUNET_EncName *node2;
+ struct GNUNET_REMOTE_friends_list *node1temp;
+ struct GNUNET_REMOTE_friends_list *node2temp;
+ node1 = GNUNET_malloc(sizeof(GNUNET_EncName));
+ node2 = GNUNET_malloc(sizeof(GNUNET_EncName));
+
while ((pos != NULL) && (pos->next != NULL))
{
iter_pos = pos->next;
while (iter_pos != NULL)
{
- GNUNET_REMOTE_connect_daemons (pos->hostname, pos->port,
- iter_pos->hostname, iter_pos->port);
+
+ fprintf(stderr,"connecting %s:%lld to
%s:%lld\n",pos->hostname,pos->port,iter_pos->hostname,iter_pos->port);
+ if(GNUNET_OK == GNUNET_REMOTE_get_daemons_information
(pos->hostname, pos->port,
+ iter_pos->hostname,
iter_pos->port,&node1,&node2))
+ {
+ node1temp = GNUNET_malloc(sizeof(struct
GNUNET_REMOTE_friends_list));
+ node2temp = GNUNET_malloc(sizeof(struct
GNUNET_REMOTE_friends_list));
+
+ node1temp->nodeid =
GNUNET_malloc(sizeof(GNUNET_EncName));
+ node2temp->nodeid =
GNUNET_malloc(sizeof(GNUNET_EncName));
+
+ memcpy(node1temp->nodeid,node2,sizeof(GNUNET_EncName));
+ memcpy(node2temp->nodeid,node1,sizeof(GNUNET_EncName));
+
+ node1temp->next = pos->friend_entries;
+ node2temp->next = iter_pos->friend_entries;
+
+ pos->friend_entries = node1temp;
+ iter_pos->friend_entries = node2temp;
+ }
iter_pos = iter_pos->next;
}
pos = pos->next;
}
-
+
+ GNUNET_free(node1);
+ GNUNET_free(node2);
+
return GNUNET_OK;
}
int
GNUNET_REMOTE_connect_2d_torus (int number_of_daemons,
- struct GNUNET_REMOTE_daemon_list
+ struct GNUNET_REMOTE_host_list
**list_as_array)
{
@@ -90,6 +119,12 @@
struct GNUNET_ClientServerConnection *sock1;
struct GNUNET_ClientServerConnection *sock2;
int ret;
+
+ GNUNET_EncName *host1entry;
+ GNUNET_EncName *host2entry;
+ host1entry = GNUNET_malloc(sizeof(GNUNET_EncName));
+ host2entry = GNUNET_malloc(sizeof(GNUNET_EncName));
+
GNUNET_MessageHello *h1;
GNUNET_MessageHello *h2;
@@ -97,11 +132,11 @@
GNUNET_snprintf (host, 128, "%s:%u", hostname1, port1);
GNUNET_GC_set_configuration_value_string (cfg1, NULL, "NETWORK", "HOST",
host);
- fprintf (stderr, "host1 is %s\n", host);
+
GNUNET_snprintf (host, 128, "%s:%u", hostname2, port2);
GNUNET_GC_set_configuration_value_string (cfg2, NULL, "NETWORK", "HOST",
host);
- fprintf (stderr, "host2 is %s\n", host);
+
if ((GNUNET_OK ==
GNUNET_wait_for_daemon_running (NULL, cfg1, 300 * GNUNET_CRON_SECONDS))
&& (GNUNET_OK ==
@@ -148,19 +183,18 @@
GNUNET_free_non_null (h1);
GNUNET_free_non_null (h2);
}
+
+ GNUNET_hash_to_enc (&h1->senderIdentity.hashPubKey, host1entry);
+ GNUNET_hash_to_enc (&h2->senderIdentity.hashPubKey, host2entry);
+
if (ret != GNUNET_OK)
{
-
- GNUNET_EncName e1;
- GNUNET_EncName e2;
- GNUNET_hash_to_enc (&h1->senderIdentity.hashPubKey, &e1);
- GNUNET_hash_to_enc (&h2->senderIdentity.hashPubKey, &e2);
fprintf (stderr,
"\nFailed to connect `%s' and `%s'\n",
- (const char *) &e1, (const char *) &e2);
- fprintf (stderr, "Connections of `%s':\n", (const char *) &e1);
+ (const char *) &host1entry, (const char *) &host2entry);
+ fprintf (stderr, "Connections of `%s':\n", (const char *)
&host1entry);
GNUNET_IDENTITY_request_peer_infos (sock1, &printInfo, NULL);
- fprintf (stderr, "Connections of `%s':\n", (const char *) &e2);
+ fprintf (stderr, "Connections of `%s':\n", (const char *)
&host2entry);
GNUNET_IDENTITY_request_peer_infos (sock2, &printInfo, NULL);
}
@@ -177,4 +211,65 @@
return ret;
}
+int
+GNUNET_REMOTE_get_daemons_information (char *hostname1, unsigned short port1,
+ char *hostname2, unsigned short port2,
GNUNET_EncName **host1entry, GNUNET_EncName **host2entry)
+{
+ char host[128];
+ struct GNUNET_GC_Configuration *cfg1 = GNUNET_GC_create ();
+ struct GNUNET_GC_Configuration *cfg2 = GNUNET_GC_create ();
+ struct GNUNET_ClientServerConnection *sock1;
+ struct GNUNET_ClientServerConnection *sock2;
+ int ret;
+ GNUNET_MessageHello *h1;
+ GNUNET_MessageHello *h2;
+
+ ret = GNUNET_SYSERR;
+ GNUNET_snprintf (host, 128, "%s:%u", hostname1, port1);
+ GNUNET_GC_set_configuration_value_string (cfg1, NULL, "NETWORK", "HOST",
+ host);
+
+ GNUNET_snprintf (host, 128, "%s:%u", hostname2, port2);
+ GNUNET_GC_set_configuration_value_string (cfg2, NULL, "NETWORK", "HOST",
+ host);
+
+ if ((GNUNET_OK ==
+ GNUNET_wait_for_daemon_running (NULL, cfg1, 300 * GNUNET_CRON_SECONDS))
+ && (GNUNET_OK ==
+ GNUNET_wait_for_daemon_running (NULL, cfg2,
+ 300 * GNUNET_CRON_SECONDS)))
+ {
+ sock1 = GNUNET_client_connection_create (NULL, cfg1);
+ sock2 = GNUNET_client_connection_create (NULL, cfg2);
+ ret = -20;
+ fprintf (stderr, _("Waiting for peers to connect"));
+ while ((ret++ < -1) && (GNUNET_shutdown_test () == GNUNET_NO))
+ {
+ h1 = NULL;
+ h2 = NULL;
+ GNUNET_IDENTITY_get_self (sock1,&h1);
+ GNUNET_IDENTITY_get_self (sock2,&h2);
+
+ GNUNET_thread_sleep (100 * GNUNET_CRON_MILLISECONDS);
+ }
+
+ GNUNET_hash_to_enc (&h1->senderIdentity.hashPubKey, *host1entry);
+ GNUNET_hash_to_enc (&h2->senderIdentity.hashPubKey, *host2entry);
+
+ GNUNET_free_non_null (h1);
+ GNUNET_free_non_null (h2);
+
+ fprintf (stderr, "%s\n", ret == GNUNET_OK ? "Connected nodes." : "?");
+ GNUNET_client_connection_destroy (sock1);
+ GNUNET_client_connection_destroy (sock2);
+ }
+ else
+ {
+ fprintf (stderr, "Failed to establish connection with peers.\n");
+ }
+ GNUNET_GC_free (cfg1);
+ GNUNET_GC_free (cfg2);
+ return ret;
+}
+
/* end of remotetopologies.c */
Modified: GNUnet/src/applications/topology_default/topology.c
===================================================================
--- GNUnet/src/applications/topology_default/topology.c 2008-03-26 23:49:22 UTC
(rev 6627)
+++ GNUnet/src/applications/topology_default/topology.c 2008-03-27 00:20:18 UTC
(rev 6628)
@@ -523,6 +523,11 @@
"FRIENDS",
GNUNET_DEFAULT_DAEMON_VAR_DIRECTORY
"/friends", &fn);
+ /**Nate change, don't beat me up if it's not pretty!*/
+ if(GNUNET_OK != GNUNET_disk_file_test (ectx, fn))
+ {
+ GNUNET_disk_file_write (ectx,fn,NULL, 0,"600");
+ }
if ((0 == GNUNET_disk_file_test (ectx, fn))
|| (GNUNET_OK != GNUNET_disk_file_size (ectx, fn, &size, GNUNET_YES)))
{
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r6628 - in GNUnet/src/applications: chat testing topology_default,
gnunet <=