aboutsummaryrefslogtreecommitdiff
path: root/src/testbed/testbed_api_services.c
diff options
context:
space:
mode:
authorSree Harsha Totakura <totakura@in.tum.de>2012-08-27 09:10:37 +0000
committerSree Harsha Totakura <totakura@in.tum.de>2012-08-27 09:10:37 +0000
commita4d753e8d938081ec51efa816966a2d6153d29c4 (patch)
tree0ecd659a201e4175b653f0b7e5d1ee3cc1a1e3ee /src/testbed/testbed_api_services.c
parent7476213458c4d38472250031c50c667e765a67f7 (diff)
downloadgnunet-a4d753e8d938081ec51efa816966a2d6153d29c4.tar.gz
gnunet-a4d753e8d938081ec51efa816966a2d6153d29c4.zip
service connect checkpoint save
Diffstat (limited to 'src/testbed/testbed_api_services.c')
-rw-r--r--src/testbed/testbed_api_services.c95
1 files changed, 81 insertions, 14 deletions
diff --git a/src/testbed/testbed_api_services.c b/src/testbed/testbed_api_services.c
index 9fbb92797..09b94e196 100644
--- a/src/testbed/testbed_api_services.c
+++ b/src/testbed/testbed_api_services.c
@@ -55,6 +55,31 @@ struct ServiceConnectData
55 */ 55 */
56 void *op_cls; 56 void *op_cls;
57 57
58 /**
59 * The operation which created this structure
60 */
61 struct GNUNET_TESTBED_Operation *operation;
62
63 /**
64 * The operation context from GNUNET_TESTBED_forward_operation_msg_()
65 */
66 struct OperationContext *opc;
67
68 /**
69 * The peer handle
70 */
71 struct GNUNET_TESTBED_Peer *peer;
72
73 /**
74 * The acquired configuration of the peer
75 */
76 struct GNUNET_CONFIGURATION_Handle *cfg;
77
78 /**
79 * The op_result pointer from ConnectAdapter
80 */
81 void *op_result;
82
58}; 83};
59 84
60 85
@@ -67,6 +92,38 @@ struct SCFOContext
67}; 92};
68 93
69 94
95/**
96 * Type of a function to call when we receive a message
97 * from the service.
98 *
99 * @param cls ServiceConnectData
100 * @param msg message received, NULL on timeout or fatal error
101 */
102static void
103configuration_receiver (void *cls,
104 const struct GNUNET_MessageHeader *msg)
105{
106 struct ServiceConnectData *data = cls;
107 const struct GNUNET_TESTBED_PeerConfigurationInformationMessage *imsg;
108 struct GNUNET_TESTBED_Controller *c;
109 struct GNUNET_TESTBED_EventInformation info;
110
111 imsg = (const struct GNUNET_TESTBED_PeerConfigurationInformationMessage *)
112 msg;
113 data->cfg = GNUNET_TESTBED_get_config_from_peerinfo_msg_ (imsg);
114 data->op_result = data->ca (data->cada_cls, data->cfg);
115 info.type = GNUNET_TESTBED_ET_OPERATION_FINISHED;
116 info.details.operation_finished.operation = data->operation;
117 info.details.operation_finished.op_cls = data->op_cls;
118 info.details.operation_finished.emsg = NULL;
119 info.details.operation_finished.pit = GNUNET_TESTBED_PIT_GENERIC;
120 info.details.operation_finished.op_result.generic = data->op_result;
121 c = data->peer->controller;
122 if ((0 != (GNUNET_TESTBED_ET_OPERATION_FINISHED & c->event_mask))
123 && (NULL != c->cc))
124 c->cc (c->cc_cls, &info);
125}
126
70 127
71/** 128/**
72 * Function called when a service connect operation is ready 129 * Function called when a service connect operation is ready
@@ -76,7 +133,21 @@ struct SCFOContext
76static void 133static void
77opstart_service_connect (void *cls) 134opstart_service_connect (void *cls)
78{ 135{
79 GNUNET_break (0); 136 struct ServiceConnectData *data = cls;
137 struct GNUNET_TESTBED_PeerGetConfigurationMessage *msg;
138 struct GNUNET_TESTBED_Controller *c;
139 uint64_t op_id;
140
141 GNUNET_assert (NULL != data);
142 GNUNET_assert (NULL != data->peer);
143 c = data->peer->controller;
144 op_id = c->operation_counter++;
145 msg = GNUNET_TESTBED_generate_peergetconfig_msg_ (data->peer->unique_id,
146 op_id);
147 data->opc =
148 GNUNET_TESTBED_forward_operation_msg_ (c, op_id, &msg->header,
149 &configuration_receiver, data);
150
80} 151}
81 152
82 153
@@ -120,26 +191,22 @@ GNUNET_TESTBED_service_connect (void *op_cls,
120 GNUNET_TESTBED_DisconnectAdapter da, 191 GNUNET_TESTBED_DisconnectAdapter da,
121 void *cada_cls) 192 void *cada_cls)
122{ 193{
123 struct OperationContext *opc;
124 struct ServiceConnectData *data; 194 struct ServiceConnectData *data;
125 195
126 data = GNUNET_malloc (sizeof (struct ServiceConnectData)); 196 data = GNUNET_malloc (sizeof (struct ServiceConnectData));
127 data->ca = ca; 197 data->ca = ca;
128 data->da = da; 198 data->da = da;
129 data->cada_cls = cada_cls; 199 data->cada_cls = cada_cls;
130 data->op_cls = op_cls; 200 data->op_cls = op_cls;
131 opc = GNUNET_malloc (sizeof (struct OperationContext)); 201 data->peer = peer;
132 opc->data = data; 202 data->operation =
133 opc->c = peer->controller; 203 GNUNET_TESTBED_operation_create_ (data, &opstart_service_connect,
134 opc->id = peer->controller->operation_counter++; 204 &oprelease_service_connect);
135 opc->type = OP_SERVICE_CONNECT; 205 GNUNET_TESTBED_operation_queue_insert_
136 opc->op = GNUNET_TESTBED_operation_create_ (opc, &opstart_service_connect, 206 (peer->controller->opq_parallel_service_connections, data->operation);
137 &oprelease_service_connect);
138 GNUNET_TESTBED_operation_queue_insert_ 207 GNUNET_TESTBED_operation_queue_insert_
139 (opc->c->opq_parallel_service_connections, opc->op); 208 (peer->controller->opq_parallel_operations, data->operation);
140 GNUNET_TESTBED_operation_queue_insert_ (opc->c->opq_parallel_operations, 209 return data->operation;
141 opc->op);
142 return opc->op;
143} 210}
144 211
145/* end of testbed_api_services.c */ 212/* end of testbed_api_services.c */