return NULL;
}
+
static struct PeerContext *
find_peer_context (struct GNUNET_TRANSPORT_TESTING_handle *tth,
const struct GNUNET_PeerIdentity *peer)
return t;
}
-struct ConnectingContext *
+
+static struct ConnectingContext *
find_connecting_context (struct GNUNET_TRANSPORT_TESTING_handle *tth,
struct PeerContext *p1, struct PeerContext *p2)
{
return cc;
}
+
static void
notify_connect (void *cls, const struct GNUNET_PeerIdentity *peer,
const struct GNUNET_ATS_Information *ats, uint32_t ats_count)
}
}
+
static void
notify_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer)
{
p->nd (p->cb_cls, peer);
}
+
static void
notify_receive (void *cls, const struct GNUNET_PeerIdentity *peer,
const struct GNUNET_MessageHeader *message,
p->rec (p->cb_cls, peer, message, ats, ats_count);
}
+
static void
get_hello (void *cb_cls, const struct GNUNET_MessageHeader *message)
{
GNUNET_OS_start_process (GNUNET_YES,
NULL, NULL, "gnunet-service-arm",
"gnunet-service-arm", "-c", cfgname,
-#if VERBOSE_PEERS
- "-L", "DEBUG",
-#else
"-L", "ERROR",
-#endif
NULL);
p->no = peer_id;
GNUNET_assert (p->servicehome != NULL);
/* shutdown */
-#if VERBOSE
GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "transport-testing",
"Stopping peer %u (`%s')\n", p->no, GNUNET_i2s (&p->id));
-#endif
if (p->ghh != NULL)
GNUNET_TRANSPORT_get_hello_cancel (p->ghh);
p->ghh = NULL;
/* start */
-#if VERBOSE
GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "transport-testing",
"Restarting peer %u (`%s')\n", p->no, GNUNET_i2s (&p->id));
-#endif
-
sleep (5); // YUCK!
if (GNUNET_DISK_file_test (cfgname) == GNUNET_NO)
GNUNET_OS_start_process (GNUNET_YES,
NULL, NULL, "gnunet-service-arm",
"gnunet-service-arm", "-c", cfgname,
-#if VERBOSE_PEERS
- "-L", "DEBUG",
-#else
"-L", "ERROR",
-#endif
NULL);
p->th =
return GNUNET_SYSERR;
}
+
/**
* shutdown the given peer
* @param tth testing handle
p = NULL;
}
+
/**
* Connect the given peers and call the callback when both peers report the
* inbound connection. Remarks: start_peer's notify_connect callback can be called
return cc;
}
+
/**
* Cancel the request to connect two peers
* Tou MUST cancel the request if you stop the peers before the peers connected succesfully
tth = NULL;
}
+
/**
* Initialize the transport testing
* @return transport testing handle
return res;
}
+
/**
* Extracts the test filename from an absolute file name and removes the extension
* @param file absolute file name
/**
- * Extracts the plugin anme from an absolute file name and the test name
+ * Extracts the plugin name from an absolute file name and the test name
+ *
* @param file absolute file name
* @param test test name
* @param dest where to store result
GNUNET_TRANSPORT_TESTING_get_test_plugin_name (const char *file,
const char *test, char **dest)
{
+ char *filename;
+ char *dotexe;
char *e = extract_filename (file);
char *t = extract_filename (test);
- char *filename = NULL;
- char *dotexe;
-
- if (e == NULL)
+ if (NULL == e)
goto fail;
-
/* remove "lt-" */
filename = strstr (e, "tes");
- if (filename == NULL)
+ if (NULL == filename)
goto fail;
-
/* remove ".exe" */
if (NULL != (dotexe = strstr (filename, ".exe")))
dotexe[0] = '\0';
/* find last _ */
filename = strstr (filename, t);
- if (filename == NULL)
+ if (NULL == filename)
goto fail;
-
/* copy plugin */
filename += strlen (t);
- filename++;
+ if ('\0' != *filename)
+ filename++;
GNUNET_asprintf (dest, "%s", filename);
goto suc;
-
fail:
(*dest) = NULL;
suc:
GNUNET_free (t);
GNUNET_free (e);
-
}
+
/**
* This function takes the filename (e.g. argv[0), removes a "lt-"-prefix and
* if existing ".exe"-prefix and adds the peer-number
char *backup = filename;
char *dotexe;
- if (filename == NULL)
+ if (NULL == filename)
goto fail;
-
/* remove "lt-" */
filename = strstr (filename, "tes");
- if (filename == NULL)
+ if (NULL == filename)
goto fail;
-
/* remove ".exe" */
if (NULL != (dotexe = strstr (filename, ".exe")))
dotexe[0] = '\0';
-
- goto suc;
-
+ GNUNET_asprintf (dest, "%s_peer%u.conf", filename, count);
+ GNUNET_free (backup);
+ return;
fail:
(*dest) = NULL;
- return;
-
-suc:
- /* create cfg filename */
- GNUNET_asprintf (dest, "%s_peer%u.conf", filename, count);
GNUNET_free (backup);
}
-/* end of transport_testing.h */
+/* end of transport-testing.c */