transport-testing.c | transport-testing.c | |||
---|---|---|---|---|
skipping to change at line 107 | skipping to change at line 107 | |||
/* Find PeerContext */ | /* Find PeerContext */ | |||
GNUNET_assert (p != 0); | GNUNET_assert (p != 0); | |||
GNUNET_assert (p->tth != NULL); | GNUNET_assert (p->tth != NULL); | |||
struct PeerContext *p2 = find_peer_context (p->tth, peer); | struct PeerContext *p2 = find_peer_context (p->tth, peer); | |||
if (p == NULL) | if (p == NULL) | |||
return; | return; | |||
if (p->nc != NULL) | if (p->nc != NULL) | |||
p->nc (p->cb_cls, peer, ats, ats_count); | p->nc (p->cb_cls, peer, ats, ats_count); | |||
#if VERBOSE | ||||
char *p2_s; | char *p2_s; | |||
if (p2 != NULL) | if (p2 != NULL) | |||
GNUNET_asprintf (&p2_s, "%u (`%s')", p2->no, GNUNET_i2s (&p2->id)); | GNUNET_asprintf (&p2_s, "%u (`%s')", p2->no, GNUNET_i2s (&p2->id)); | |||
else | else | |||
GNUNET_asprintf (&p2_s, "`%s'", GNUNET_i2s (peer)); | GNUNET_asprintf (&p2_s, "`%s'", GNUNET_i2s (peer)); | |||
GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "transport-testing", | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "transport-testing", | |||
"Peers %s connected to peer %u (`%s')\n", p2_s, p->no, | "Peers %s connected to peer %u (`%s')\n", p2_s, p->no, | |||
GNUNET_i2s (&p->id)); | GNUNET_i2s (&p->id)); | |||
GNUNET_free (p2_s); | GNUNET_free (p2_s); | |||
#endif | ||||
/* Find ConnectingContext */ | /* Find ConnectingContext */ | |||
struct ConnectingContext *cc = find_connecting_context (p->tth, p, p2); | struct ConnectingContext *cc = find_connecting_context (p->tth, p, p2); | |||
if (cc == NULL) | if (cc == NULL) | |||
return; | return; | |||
if (p == cc->p1) | if (p == cc->p1) | |||
cc->p1_c = GNUNET_YES; | cc->p1_c = GNUNET_YES; | |||
skipping to change at line 194 | skipping to change at line 192 | |||
static void | static void | |||
get_hello (void *cb_cls, const struct GNUNET_MessageHeader *message) | get_hello (void *cb_cls, const struct GNUNET_MessageHeader *message) | |||
{ | { | |||
struct PeerContext *p = cb_cls; | struct PeerContext *p = cb_cls; | |||
GNUNET_assert (message != NULL); | GNUNET_assert (message != NULL); | |||
GNUNET_assert (GNUNET_OK == | GNUNET_assert (GNUNET_OK == | |||
GNUNET_HELLO_get_id ((const struct GNUNET_HELLO_Message *) | GNUNET_HELLO_get_id ((const struct GNUNET_HELLO_Message *) | |||
message, &p->id)); | message, &p->id)); | |||
#if VERBOSE | ||||
size_t size = | ||||
GNUNET_HELLO_size ((const struct GNUNET_HELLO_Message *) message); | ||||
#endif | ||||
GNUNET_free_non_null (p->hello); | GNUNET_free_non_null (p->hello); | |||
p->hello = (struct GNUNET_HELLO_Message *) GNUNET_copy_message (message); | p->hello = (struct GNUNET_HELLO_Message *) GNUNET_copy_message (message); | |||
#if VERBOSE | ||||
GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "transport-testing", | ||||
"New HELLO for peer %u (`%s') with size %u\n", p->no, | ||||
GNUNET_i2s (&p->id), size); | ||||
#endif | ||||
if (p->start_cb != NULL) | if (p->start_cb != NULL) | |||
{ | { | |||
#if VERBOSE | ||||
GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "transport-testing", | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "transport-testing", | |||
"Peer %u (`%s') successfully started\n", p->no, | "Peer %u (`%s') successfully started\n", p->no, | |||
GNUNET_i2s (&p->id)); | GNUNET_i2s (&p->id)); | |||
#endif | ||||
p->start_cb (p, p->cb_cls); | p->start_cb (p, p->cb_cls); | |||
p->start_cb = NULL; | p->start_cb = NULL; | |||
} | } | |||
} | } | |||
static void | static void | |||
try_connect (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | try_connect (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
{ | { | |||
struct ConnectingContext *cc = cls; | struct ConnectingContext *cc = cls; | |||
struct PeerContext *p1 = cc->p1; | struct PeerContext *p1 = cc->p1; | |||
skipping to change at line 318 | skipping to change at line 305 | |||
GNUNET_DISK_PERM_USER_WRITE); | GNUNET_DISK_PERM_USER_WRITE); | |||
GNUNET_assert (fn != NULL); | GNUNET_assert (fn != NULL); | |||
GNUNET_assert (HOSTKEYFILESIZE == | GNUNET_assert (HOSTKEYFILESIZE == | |||
GNUNET_DISK_file_write (fn, hostkey, HOSTKEYFILESIZE)); | GNUNET_DISK_file_write (fn, hostkey, HOSTKEYFILESIZE)); | |||
GNUNET_assert (GNUNET_OK == GNUNET_DISK_file_close (fn)); | GNUNET_assert (GNUNET_OK == GNUNET_DISK_file_close (fn)); | |||
GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "transport-testing", | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "transport-testing", | |||
"Wrote hostkey to file: `%s' \n", p->hostkeyfile); | "Wrote hostkey to file: `%s' \n", p->hostkeyfile); | |||
} | } | |||
p->arm_proc = | p->arm_proc = | |||
GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm", | GNUNET_OS_start_process (GNUNET_YES, | |||
NULL, NULL, "gnunet-service-arm", | ||||
"gnunet-service-arm", "-c", cfgname, | "gnunet-service-arm", "-c", cfgname, | |||
#if VERBOSE_PEERS | #if VERBOSE_PEERS | |||
"-L", "DEBUG", | "-L", "DEBUG", | |||
#else | #else | |||
"-L", "ERROR", | "-L", "ERROR", | |||
#endif | #endif | |||
NULL); | NULL); | |||
p->no = peer_id; | p->no = peer_id; | |||
p->tth = tth; | p->tth = tth; | |||
skipping to change at line 347 | skipping to change at line 335 | |||
p->th = | p->th = | |||
GNUNET_TRANSPORT_connect (p->cfg, NULL, p, ¬ify_receive, | GNUNET_TRANSPORT_connect (p->cfg, NULL, p, ¬ify_receive, | |||
¬ify_connect, ¬ify_disconnect); | ¬ify_connect, ¬ify_disconnect); | |||
GNUNET_assert (p->th != NULL); | GNUNET_assert (p->th != NULL); | |||
p->ghh = GNUNET_TRANSPORT_get_hello (p->th, &get_hello, p); | p->ghh = GNUNET_TRANSPORT_get_hello (p->th, &get_hello, p); | |||
GNUNET_assert (p->ghh != NULL); | GNUNET_assert (p->ghh != NULL); | |||
GNUNET_CONTAINER_DLL_insert (tth->p_head, tth->p_tail, p); | GNUNET_CONTAINER_DLL_insert (tth->p_head, tth->p_tail, p); | |||
return p; | return p; | |||
} | } | |||
/** | /** | |||
* Restart the given peer | * Restart the given peer | |||
* @param tth testing handle | * @param tth testing handle | |||
* @param p the peer | * @param p the peer | |||
* @param cfgname the cfg file used to restart | * @param cfgname the cfg file used to restart | |||
* @param restart_cb callback to call when restarted | * @param restart_cb callback to call when restarted | |||
* @param cb_cls callback closure | * @param cb_cls callback closure | |||
skipping to change at line 434 | skipping to change at line 421 | |||
GNUNET_DISK_OPEN_READWRITE | | GNUNET_DISK_OPEN_READWRITE | | |||
GNUNET_DISK_OPEN_CREATE, | GNUNET_DISK_OPEN_CREATE, | |||
GNUNET_DISK_PERM_USER_READ | | GNUNET_DISK_PERM_USER_READ | | |||
GNUNET_DISK_PERM_USER_WRITE); | GNUNET_DISK_PERM_USER_WRITE); | |||
if (fn == NULL) | if (fn == NULL) | |||
goto fail; | goto fail; | |||
if (GNUNET_OK != GNUNET_DISK_file_close (fn)) | if (GNUNET_OK != GNUNET_DISK_file_close (fn)) | |||
goto fail; | goto fail; | |||
p->arm_proc = | p->arm_proc = | |||
GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm", | GNUNET_OS_start_process (GNUNET_YES, | |||
NULL, NULL, "gnunet-service-arm", | ||||
"gnunet-service-arm", "-c", cfgname, | "gnunet-service-arm", "-c", cfgname, | |||
#if VERBOSE_PEERS | #if VERBOSE_PEERS | |||
"-L", "DEBUG", | "-L", "DEBUG", | |||
#else | #else | |||
"-L", "ERROR", | "-L", "ERROR", | |||
#endif | #endif | |||
NULL); | NULL); | |||
p->th = | p->th = | |||
GNUNET_TRANSPORT_connect (p->cfg, NULL, p, ¬ify_receive, | GNUNET_TRANSPORT_connect (p->cfg, NULL, p, ¬ify_receive, | |||
skipping to change at line 512 | skipping to change at line 500 | |||
if (p->hello != NULL) | if (p->hello != NULL) | |||
GNUNET_free (p->hello); | GNUNET_free (p->hello); | |||
p->hello = NULL; | p->hello = NULL; | |||
if (p->cfg != NULL) | if (p->cfg != NULL) | |||
GNUNET_CONFIGURATION_destroy (p->cfg); | GNUNET_CONFIGURATION_destroy (p->cfg); | |||
p->cfg = NULL; | p->cfg = NULL; | |||
GNUNET_CONTAINER_DLL_remove (tth->p_head, tth->p_tail, p); | GNUNET_CONTAINER_DLL_remove (tth->p_head, tth->p_tail, p); | |||
GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "transport-testing", | ||||
"Peer %u (`%s') stopped \n", p->no, | ||||
GNUNET_i2s (&p->id)); | ||||
GNUNET_free (p); | GNUNET_free (p); | |||
p = NULL; | p = NULL; | |||
} | } | |||
/** | /** | |||
* Initiate peer p1 to connect to peer p2 | * Connect the given peers and call the callback when both peers report the | |||
* Get peer p2's HELLO and offer it to p1 | * inbound connection. Remarks: start_peer's notify_connect callback can be | |||
* p1 then tries to connect to p2 | called | |||
* before. | ||||
* | ||||
* @param tth transport testing handle | ||||
* @param p1 peer 1 | * @param p1 peer 1 | |||
* @param p2 peer 2 | * @param p2 peer 2 | |||
* @param cb the callback to call when both peers notified that they are co nnected | * @param cb the callback to call when both peers notified that they are co nnected | |||
* @param cb_cls callback cls (or a pointer to the | * @param cls callback cls | |||
* GNUNET_TRANSPORT_TESTING_ConnectRequest itself if null) | * @return a connect request handle | |||
* @return connect context | ||||
*/ | */ | |||
GNUNET_TRANSPORT_TESTING_ConnectRequest | GNUNET_TRANSPORT_TESTING_ConnectRequest | |||
GNUNET_TRANSPORT_TESTING_connect_peers (struct GNUNET_TRANSPORT_TESTING_han | GNUNET_TRANSPORT_TESTING_connect_peers (struct GNUNET_TRANSPORT_TESTING_han | |||
dle | dle *tth, | |||
*tth, struct PeerContext *p1, | struct PeerContext *p1, | |||
struct PeerContext *p2, | struct PeerContext *p2, | |||
GNUNET_TRANSPORT_TESTING_connect_cb cb, | GNUNET_TRANSPORT_TESTING_connect_cb cb, | |||
void *cb_cls) | void *cls) | |||
{ | { | |||
GNUNET_assert (tth != NULL); | GNUNET_assert (tth != NULL); | |||
struct ConnectingContext *cc = | struct ConnectingContext *cc = | |||
GNUNET_malloc (sizeof (struct ConnectingContext)); | GNUNET_malloc (sizeof (struct ConnectingContext)); | |||
GNUNET_assert (p1 != NULL); | GNUNET_assert (p1 != NULL); | |||
GNUNET_assert (p2 != NULL); | GNUNET_assert (p2 != NULL); | |||
cc->p1 = p1; | cc->p1 = p1; | |||
cc->p2 = p2; | cc->p2 = p2; | |||
cc->cb = cb; | cc->cb = cb; | |||
if (cb_cls != NULL) | if (cls != NULL) | |||
cc->cb_cls = cb_cls; | cc->cb_cls = cls; | |||
else | else | |||
cc->cb_cls = cc; | cc->cb_cls = cc; | |||
cc->th_p1 = p1->th; | cc->th_p1 = p1->th; | |||
cc->th_p2 = p2->th; | cc->th_p2 = p2->th; | |||
GNUNET_assert (cc->th_p1 != NULL); | GNUNET_assert (cc->th_p1 != NULL); | |||
GNUNET_assert (cc->th_p2 != NULL); | GNUNET_assert (cc->th_p2 != NULL); | |||
GNUNET_CONTAINER_DLL_insert (tth->cc_head, tth->cc_tail, cc); | GNUNET_CONTAINER_DLL_insert (tth->cc_head, tth->cc_tail, cc); | |||
End of changes. 15 change blocks. | ||||
29 lines changed or deleted | 23 lines changed or added | |||
This html diff was produced by rfcdiff 1.41. The latest version is available from http://tools.ietf.org/tools/rfcdiff/ |