summaryrefslogtreecommitdiff
path: root/src/transport/transport-testing-send.c
diff options
context:
space:
mode:
authorng0 <ng0@n0.is>2019-09-08 12:33:09 +0000
committerng0 <ng0@n0.is>2019-09-08 12:33:09 +0000
commitd41ed82a4ea0cc8e1674b6d5d2c49fd6462610bb (patch)
tree9efd18ea7d425652085ed0bd5e8e45604bc5f6b9 /src/transport/transport-testing-send.c
parenta0fce305c565c0937d917a92712f15e9c5736260 (diff)
uncrustify as demanded.
Diffstat (limited to 'src/transport/transport-testing-send.c')
-rw-r--r--src/transport/transport-testing-send.c206
1 files changed, 103 insertions, 103 deletions
diff --git a/src/transport/transport-testing-send.c b/src/transport/transport-testing-send.c
index cb4be57de..42735e4c1 100644
--- a/src/transport/transport-testing-send.c
+++ b/src/transport/transport-testing-send.c
@@ -11,12 +11,12 @@
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Affero General Public License for more details.
-
+
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
SPDX-License-Identifier: AGPL3.0-or-later
-*/
+ */
/**
* @file transport-testing-send.c
* @brief convenience transmission function for tests
@@ -27,15 +27,15 @@
/**
* Acceptable transmission delay.
*/
-#define TIMEOUT_TRANSMIT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 30)
+#define TIMEOUT_TRANSMIT GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 30)
/**
* Return @a cx in @a cls.
*/
static void
-find_cr (void *cls,
- struct GNUNET_TRANSPORT_TESTING_ConnectRequest *cx)
+find_cr(void *cls,
+ struct GNUNET_TRANSPORT_TESTING_ConnectRequest *cx)
{
struct GNUNET_TRANSPORT_TESTING_ConnectRequest **cr = cls;
@@ -62,72 +62,72 @@ find_cr (void *cls,
* #GNUNET_SYSERR if @a msize is illegal
*/
int
-GNUNET_TRANSPORT_TESTING_send (struct GNUNET_TRANSPORT_TESTING_PeerContext *sender,
- struct GNUNET_TRANSPORT_TESTING_PeerContext *receiver,
- uint16_t mtype,
- uint16_t msize,
- uint32_t num,
- GNUNET_SCHEDULER_TaskCallback cont,
- void *cont_cls)
+GNUNET_TRANSPORT_TESTING_send(struct GNUNET_TRANSPORT_TESTING_PeerContext *sender,
+ struct GNUNET_TRANSPORT_TESTING_PeerContext *receiver,
+ uint16_t mtype,
+ uint16_t msize,
+ uint32_t num,
+ GNUNET_SCHEDULER_TaskCallback cont,
+ void *cont_cls)
{
struct GNUNET_TRANSPORT_TESTING_ConnectRequest *cr;
struct GNUNET_MQ_Envelope *env;
struct GNUNET_TRANSPORT_TESTING_TestMessage *test;
-
- if (msize < sizeof (struct GNUNET_TRANSPORT_TESTING_TestMessage))
- {
- GNUNET_break (0);
- return GNUNET_SYSERR;
- }
+
+ if (msize < sizeof(struct GNUNET_TRANSPORT_TESTING_TestMessage))
+ {
+ GNUNET_break(0);
+ return GNUNET_SYSERR;
+ }
cr = NULL;
- GNUNET_TRANSPORT_TESTING_find_connecting_context (sender,
- receiver,
- &find_cr,
- &cr);
+ GNUNET_TRANSPORT_TESTING_find_connecting_context(sender,
+ receiver,
+ &find_cr,
+ &cr);
if (NULL == cr)
- GNUNET_TRANSPORT_TESTING_find_connecting_context (receiver,
- sender,
- &find_cr,
- &cr);
+ GNUNET_TRANSPORT_TESTING_find_connecting_context(receiver,
+ sender,
+ &find_cr,
+ &cr);
if (NULL == cr)
+ {
+ GNUNET_break(0);
+ return GNUNET_NO;
+ }
+ if (NULL == cr->mq)
+ {
+ GNUNET_break(0);
+ return GNUNET_NO;
+ }
{
- GNUNET_break (0);
- return GNUNET_NO;
+ char *receiver_s = GNUNET_strdup(GNUNET_i2s(&receiver->id));
+
+ GNUNET_log(GNUNET_ERROR_TYPE_INFO,
+ "Sending message from peer %u (`%s') -> peer %u (`%s') !\n",
+ sender->no,
+ GNUNET_i2s(&sender->id),
+ receiver->no,
+ receiver_s);
+ GNUNET_free(receiver_s);
}
- if (NULL == cr->mq)
- {
- GNUNET_break (0);
- return GNUNET_NO;
- }
- {
- char *receiver_s = GNUNET_strdup (GNUNET_i2s (&receiver->id));
-
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "Sending message from peer %u (`%s') -> peer %u (`%s') !\n",
- sender->no,
- GNUNET_i2s (&sender->id),
- receiver->no,
- receiver_s);
- GNUNET_free (receiver_s);
- }
- env = GNUNET_MQ_msg_extra (test,
- msize - sizeof (*test),
- mtype);
- test->num = htonl (num);
- memset (&test[1],
- num,
- msize - sizeof (*test));
- GNUNET_MQ_notify_sent (env,
- cont,
- cont_cls);
- GNUNET_MQ_send (cr->mq,
- env);
+ env = GNUNET_MQ_msg_extra(test,
+ msize - sizeof(*test),
+ mtype);
+ test->num = htonl(num);
+ memset(&test[1],
+ num,
+ msize - sizeof(*test));
+ GNUNET_MQ_notify_sent(env,
+ cont,
+ cont_cls);
+ GNUNET_MQ_send(cr->mq,
+ env);
return GNUNET_OK;
}
/**
- * Task that sends a test message from the
+ * Task that sends a test message from the
* first peer to the second peer.
*
* @param ccc context which should contain at least two peers, the
@@ -137,33 +137,33 @@ GNUNET_TRANSPORT_TESTING_send (struct GNUNET_TRANSPORT_TESTING_PeerContext *send
* @param cont_cls closure for @a cont
*/
static void
-do_send (struct GNUNET_TRANSPORT_TESTING_ConnectCheckContext *ccc,
- uint16_t size,
- GNUNET_SCHEDULER_TaskCallback cont,
- void *cont_cls)
+do_send(struct GNUNET_TRANSPORT_TESTING_ConnectCheckContext *ccc,
+ uint16_t size,
+ GNUNET_SCHEDULER_TaskCallback cont,
+ void *cont_cls)
{
int ret;
ccc->global_ret = GNUNET_SYSERR;
- ret = GNUNET_TRANSPORT_TESTING_send (ccc->p[0],
- ccc->p[1],
- GNUNET_TRANSPORT_TESTING_SIMPLE_MTYPE,
- size,
- ccc->send_num_gen++,
- cont,
- cont_cls);
- GNUNET_assert (GNUNET_SYSERR != ret);
+ ret = GNUNET_TRANSPORT_TESTING_send(ccc->p[0],
+ ccc->p[1],
+ GNUNET_TRANSPORT_TESTING_SIMPLE_MTYPE,
+ size,
+ ccc->send_num_gen++,
+ cont,
+ cont_cls);
+ GNUNET_assert(GNUNET_SYSERR != ret);
if (GNUNET_NO == ret)
- {
- GNUNET_break (0);
- ccc->global_ret = GNUNET_SYSERR;
- GNUNET_SCHEDULER_shutdown ();
- }
+ {
+ GNUNET_break(0);
+ ccc->global_ret = GNUNET_SYSERR;
+ GNUNET_SCHEDULER_shutdown();
+ }
}
/**
- * Task that sends a minimalistic test message from the
+ * Task that sends a minimalistic test message from the
* first peer to the second peer.
*
* @param cls the `struct GNUNET_TRANSPORT_TESTING_ConnectCheckContext`
@@ -171,35 +171,35 @@ do_send (struct GNUNET_TRANSPORT_TESTING_ConnectCheckContext *ccc,
* of which should be currently connected
*/
void
-GNUNET_TRANSPORT_TESTING_simple_send (void *cls)
+GNUNET_TRANSPORT_TESTING_simple_send(void *cls)
{
struct GNUNET_TRANSPORT_TESTING_SendClosure *sc = cls;
int done;
size_t msize;
if (0 < sc->num_messages)
- {
- sc->num_messages--;
- done = (0 == sc->num_messages);
- }
+ {
+ sc->num_messages--;
+ done = (0 == sc->num_messages);
+ }
else
- {
- done = 0; /* infinite loop */
- }
- msize = sizeof (struct GNUNET_TRANSPORT_TESTING_TestMessage);
+ {
+ done = 0; /* infinite loop */
+ }
+ msize = sizeof(struct GNUNET_TRANSPORT_TESTING_TestMessage);
if (NULL != sc->get_size_cb)
- msize = sc->get_size_cb (sc->num_messages);
+ msize = sc->get_size_cb(sc->num_messages);
/* if this was the last message, call the continuation,
otherwise call this function again */
- do_send (sc->ccc,
- msize,
- done ? sc->cont : &GNUNET_TRANSPORT_TESTING_simple_send,
- done ? sc->cont_cls : sc);
+ do_send(sc->ccc,
+ msize,
+ done ? sc->cont : &GNUNET_TRANSPORT_TESTING_simple_send,
+ done ? sc->cont_cls : sc);
}
/**
- * Task that sends a large test message from the
+ * Task that sends a large test message from the
* first peer to the second peer.
*
* @param cls the `struct GNUNET_TRANSPORT_TESTING_ConnectCheckContext`
@@ -207,30 +207,30 @@ GNUNET_TRANSPORT_TESTING_simple_send (void *cls)
* of which should be currently connected
*/
void
-GNUNET_TRANSPORT_TESTING_large_send (void *cls)
+GNUNET_TRANSPORT_TESTING_large_send(void *cls)
{
struct GNUNET_TRANSPORT_TESTING_SendClosure *sc = cls;
int done;
size_t msize;
if (0 < sc->num_messages)
- {
- sc->num_messages--;
- done = (0 == sc->num_messages);
- }
+ {
+ sc->num_messages--;
+ done = (0 == sc->num_messages);
+ }
else
- {
- done = 0; /* infinite loop */
- }
+ {
+ done = 0; /* infinite loop */
+ }
msize = 2600;
if (NULL != sc->get_size_cb)
- msize = sc->get_size_cb (sc->num_messages);
+ msize = sc->get_size_cb(sc->num_messages);
/* if this was the last message, call the continuation,
otherwise call this function again */
- do_send (sc->ccc,
- msize,
- done ? sc->cont : &GNUNET_TRANSPORT_TESTING_large_send,
- done ? sc->cont_cls : sc);
+ do_send(sc->ccc,
+ msize,
+ done ? sc->cont : &GNUNET_TRANSPORT_TESTING_large_send,
+ done ? sc->cont_cls : sc);
}
/* end of transport-testing-send.c */