[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r23200 - gnunet/src/testbed
From: |
gnunet |
Subject: |
[GNUnet-SVN] r23200 - gnunet/src/testbed |
Date: |
Sat, 11 Aug 2012 14:46:05 +0200 |
Author: harsha
Date: 2012-08-11 14:46:05 +0200 (Sat, 11 Aug 2012)
New Revision: 23200
Modified:
gnunet/src/testbed/gnunet-service-testbed.c
gnunet/src/testbed/testbed.h
gnunet/src/testbed/testbed_api.c
gnunet/src/testbed/testbed_api.h
Log:
api forward operation message
Modified: gnunet/src/testbed/gnunet-service-testbed.c
===================================================================
--- gnunet/src/testbed/gnunet-service-testbed.c 2012-08-11 10:38:52 UTC (rev
23199)
+++ gnunet/src/testbed/gnunet-service-testbed.c 2012-08-11 12:46:05 UTC (rev
23200)
@@ -428,25 +428,19 @@
/**
- * Context data to be used when forwarding peer create messages
+ * Context information for operations forward to subcontrollers
*/
-struct PeerCreateContext
+struct ForwardedOperationContext
{
/**
- * The operation handle to peer create
+ * Task ID for the timeout task
*/
- struct GNUNET_TESTBED_operation *operation;
+ GNUNET_SCHEDULER_TaskIdentifier timeout_task;
/**
- * The ID of the operation which created this context
+ * The ID of the operation that is forwarded
*/
uint64_t operation_id;
-
- /**
- * The peer create timeout task id
- */
- GNUNET_SCHEDULER_TaskIdentifier timeout_task;
-
};
@@ -1396,10 +1390,12 @@
const struct GNUNET_MessageHeader *message)
{
const struct GNUNET_TESTBED_PeerCreateMessage *msg;
+ struct GNUNET_TESTBED_PeerCreateMessage *dup_msg;
struct GNUNET_TESTBED_PeerCreateSuccessEventMessage *reply;
struct GNUNET_CONFIGURATION_Handle *cfg;
- struct PeerCreateContext *pc_ctxt;
+ struct ForwardedOperationContext *fo_ctxt;
struct Route *route;
+ struct Peer *peer;
char *config;
size_t dest_size;
int ret;
@@ -1419,7 +1415,6 @@
host_id = ntohl (msg->host_id);
if (host_id == master_context->host_id)
{
- struct Peer *peer;
char *emsg;
/* We are responsible for this peer */
@@ -1489,9 +1484,13 @@
GNUNET_SERVER_receive_done (client, GNUNET_OK);
return;
}
- pc_ctxt = GNUNET_malloc (sizeof (struct PeerCreateContext));
- pc_ctxt->operation_id = GNUNET_ntohll (msg->operation_id);
- /* To be continued .. :) */
+ fo_ctxt = GNUNET_malloc (sizeof (struct ForwardedOperationContext));
+ fo_ctxt->operation_id = GNUNET_ntohll (msg->operation_id);
+ dup_msg = GNUNET_malloc (msize);
+ (void) memcpy (dup_msg, msg, msize);
+ GNUNET_TESTBED_queue_message_ (slave_list[route->dest]->controller,
+ &dup_msg->header);
+ GNUNET_SERVER_receive_done (client, GNUNET_OK);
}
Modified: gnunet/src/testbed/testbed.h
===================================================================
--- gnunet/src/testbed/testbed.h 2012-08-11 10:38:52 UTC (rev 23199)
+++ gnunet/src/testbed/testbed.h 2012-08-11 12:46:05 UTC (rev 23200)
@@ -606,4 +606,5 @@
};
+
#endif
Modified: gnunet/src/testbed/testbed_api.c
===================================================================
--- gnunet/src/testbed/testbed_api.c 2012-08-11 10:38:52 UTC (rev 23199)
+++ gnunet/src/testbed/testbed_api.c 2012-08-11 12:46:05 UTC (rev 23200)
@@ -156,6 +156,25 @@
/**
+ * Context data for forwarded Operation
+ */
+struct ForwardedOperationData
+{
+
+ /**
+ * The callback to call when reply is available
+ */
+ GNUNET_CLIENT_MessageHandler cc;
+
+ /**
+ * The closure for the above callback
+ */
+ void *cc_cls;
+
+};
+
+
+/**
* Returns the operation context with the given id if found in the Operation
* context queues of the controller
*
@@ -326,6 +345,18 @@
LOG_DEBUG ("Operation context for PeerCreateSuccessEvent not found\n");
return GNUNET_YES;
}
+ if (OP_FORWARDED == opc->type)
+ {
+ struct ForwardedOperationData *fo_data;
+
+ fo_data = opc->data;
+ if (NULL != fo_data->cc)
+ fo_data->cc (fo_data->cc_cls, (const struct GNUNET_MessageHeader *) msg);
+ GNUNET_CONTAINER_DLL_remove (c->ocq_head, c->ocq_tail, opc);
+ GNUNET_free (fo_data);
+ GNUNET_free (opc);
+ return GNUNET_YES;
+ }
GNUNET_assert (OP_PEER_CREATE == opc->type);
GNUNET_assert (NULL != opc->data);
data = opc->data;
@@ -719,6 +750,48 @@
/**
+ * Sends the given message as an operation. The given callback is called when a
+ * reply for the operation is available
+ *
+ * @param controller the controller to which the message has to be sent
+ * @param operation_id the operation id of the message
+ * @param msg the message to send
+ * @param cc the callback to call when reply is available
+ * @param cc_cls the closure for the above callback
+ * @return the operation context which can be used to cancel the forwarded
+ * operation
+ */
+struct OperationContext *
+GNUNET_TESTBED_forward_operation_msg_ (struct GNUNET_TESTBED_Controller
+ * controller,
+ uint64_t operation_id,
+ const struct GNUNET_MessageHeader *msg,
+ GNUNET_CLIENT_MessageHandler cc,
+ void *cc_cls)
+{
+ struct OperationContext *opc;
+ struct ForwardedOperationData *data;
+ struct GNUNET_MessageHeader *dup_msg;
+ uint16_t msize;
+
+ data = GNUNET_malloc (sizeof (struct ForwardedOperationData));
+ data->cc = cc;
+ data->cc_cls = cc_cls;
+ opc = GNUNET_malloc (sizeof (struct OperationContext));
+ opc->type = OP_FORWARDED;
+ opc->data = data;
+ opc->id = operation_id;
+ msize = ntohs (msg->size);
+ dup_msg = GNUNET_malloc (msize);
+ (void) memcpy (dup_msg, msg, msize);
+ GNUNET_TESTBED_queue_message_ (opc->c, dup_msg);
+ GNUNET_CONTAINER_DLL_insert_tail (controller->ocq_head,
+ controller->ocq_tail, opc);
+ return opc;
+}
+
+
+/**
* Handle for controller process
*/
struct GNUNET_TESTBED_ControllerProc
@@ -1434,5 +1507,4 @@
}
}
-
/* end of testbed_api.c */
Modified: gnunet/src/testbed/testbed_api.h
===================================================================
--- gnunet/src/testbed/testbed_api.h 2012-08-11 10:38:52 UTC (rev 23199)
+++ gnunet/src/testbed/testbed_api.h 2012-08-11 12:46:05 UTC (rev 23200)
@@ -63,6 +63,11 @@
*/
OP_OVERLAY_CONNECT,
+ /**
+ * Forwarded operation
+ */
+ OP_FORWARDED
+
};
@@ -349,4 +354,25 @@
GNUNET_CONFIGURATION_Handle *cfg);
+/**
+ * Sends the given message as an operation. The given callback is called when a
+ * reply for the operation is available
+ *
+ * @param controller the controller to which the message has to be sent
+ * @param operation_id the operation id of the message
+ * @param msg the message to send
+ * @param cc the callback to call when reply is available
+ * @param cc_cls the closure for the above callback
+ * @return the operation context which can be used to cancel the forwarded
+ * operation
+ */
+struct OperationContext *
+GNUNET_TESTBED_forward_operation_msg_ (struct GNUNET_TESTBED_Controller
+ * controller,
+ uint64_t operation_id,
+ const struct GNUNET_MessageHeader *msg,
+ GNUNET_CLIENT_MessageHandler cc,
+ void *cc_cls);
+
#endif
+/* end of testbed_api.h */
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r23200 - gnunet/src/testbed,
gnunet <=