aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSree Harsha Totakura <totakura@in.tum.de>2012-09-09 14:20:50 +0000
committerSree Harsha Totakura <totakura@in.tum.de>2012-09-09 14:20:50 +0000
commit7666505af72b1ca0b568f1c8a053a506dda64d95 (patch)
tree229314c99af16e5dd7686beaa53e11ef5593d1bc
parent58d35329939062c00b165a973ad236490678eca3 (diff)
downloadgnunet-7666505af72b1ca0b568f1c8a053a506dda64d95.tar.gz
gnunet-7666505af72b1ca0b568f1c8a053a506dda64d95.zip
error reporting in service_connect
-rw-r--r--src/testbed/gnunet-service-testbed.c2
-rw-r--r--src/testbed/testbed_api.c29
-rw-r--r--src/testbed/testbed_api.h13
-rw-r--r--src/testbed/testbed_api_services.c26
4 files changed, 62 insertions, 8 deletions
diff --git a/src/testbed/gnunet-service-testbed.c b/src/testbed/gnunet-service-testbed.c
index 3438d6794..1bc1683c8 100644
--- a/src/testbed/gnunet-service-testbed.c
+++ b/src/testbed/gnunet-service-testbed.c
@@ -930,7 +930,7 @@ lcf_proc_cc (void *cls, const char *emsg)
930 } 930 }
931 return; 931 return;
932 932
933registration_error: 933 registration_error:
934 LOG (GNUNET_ERROR_TYPE_WARNING, "Host registration failed with message: %s\n", 934 LOG (GNUNET_ERROR_TYPE_WARNING, "Host registration failed with message: %s\n",
935 emsg); 935 emsg);
936 lcf->state = FINISHED; 936 lcf->state = FINISHED;
diff --git a/src/testbed/testbed_api.c b/src/testbed/testbed_api.c
index 9171ce947..fcbff7004 100644
--- a/src/testbed/testbed_api.c
+++ b/src/testbed/testbed_api.c
@@ -1758,4 +1758,33 @@ GNUNET_TESTBED_get_config_from_peerinfo_msg_ (const struct
1758 return cfg; 1758 return cfg;
1759} 1759}
1760 1760
1761
1762/**
1763 * Checks the integrity of the OpeationFailureEventMessage and if good returns
1764 * the error message it contains.
1765 *
1766 * @param msg the OperationFailureEventMessage
1767 * @return the error message
1768 */
1769const char *
1770GNUNET_TESTBED_parse_error_string_ (const struct
1771 GNUNET_TESTBED_OperationFailureEventMessage
1772 *msg)
1773{
1774 uint16_t msize;
1775 const char *emsg;
1776
1777 msize = ntohs (msg->header.size);
1778 if (sizeof (struct GNUNET_TESTBED_OperationFailureEventMessage) == msize)
1779 return NULL;
1780 msize -= sizeof (struct GNUNET_TESTBED_OperationFailureEventMessage);
1781 emsg = (const char *) &msg[1];
1782 if ('\0' != emsg[msize])
1783 {
1784 GNUNET_break (0);
1785 return NULL;
1786 }
1787 return emsg;
1788}
1789
1761/* end of testbed_api.c */ 1790/* end of testbed_api.c */
diff --git a/src/testbed/testbed_api.h b/src/testbed/testbed_api.h
index 06ab6d504..a021e2130 100644
--- a/src/testbed/testbed_api.h
+++ b/src/testbed/testbed_api.h
@@ -398,5 +398,18 @@ GNUNET_TESTBED_get_config_from_peerinfo_msg_ (const struct
398 GNUNET_TESTBED_PeerConfigurationInformationMessage 398 GNUNET_TESTBED_PeerConfigurationInformationMessage
399 *msg); 399 *msg);
400 400
401
402/**
403 * Checks the integrity of the OpeationFailureEventMessage and if good returns
404 * the error message it contains.
405 *
406 * @param msg the OperationFailureEventMessage
407 * @return the error message
408 */
409const char *
410GNUNET_TESTBED_parse_error_string_ (const struct
411 GNUNET_TESTBED_OperationFailureEventMessage
412 *msg);
413
401#endif 414#endif
402/* end of testbed_api.h */ 415/* end of testbed_api.h */
diff --git a/src/testbed/testbed_api_services.c b/src/testbed/testbed_api_services.c
index c3375a9c7..62bafb724 100644
--- a/src/testbed/testbed_api_services.c
+++ b/src/testbed/testbed_api_services.c
@@ -138,30 +138,42 @@ configuration_receiver (void *cls, const struct GNUNET_MessageHeader *msg)
138 struct ServiceConnectData *data = cls; 138 struct ServiceConnectData *data = cls;
139 const struct GNUNET_TESTBED_PeerConfigurationInformationMessage *imsg; 139 const struct GNUNET_TESTBED_PeerConfigurationInformationMessage *imsg;
140 struct GNUNET_TESTBED_Controller *c; 140 struct GNUNET_TESTBED_Controller *c;
141 const char *emsg;
141 struct GNUNET_TESTBED_EventInformation info; 142 struct GNUNET_TESTBED_EventInformation info;
142 uint16_t mtype; 143 uint16_t mtype;
143 144
144 mtype = ntohs (msg->type); 145 mtype = ntohs (msg->type);
146 emsg = NULL;
147 info.type = GNUNET_TESTBED_ET_OPERATION_FINISHED;
148 info.details.operation_finished.operation = data->operation;
149 info.details.operation_finished.op_cls = data->op_cls;
145 if (GNUNET_MESSAGE_TYPE_TESTBED_OPERATIONFAILEVENT == mtype) 150 if (GNUNET_MESSAGE_TYPE_TESTBED_OPERATIONFAILEVENT == mtype)
146 { 151 {
147 GNUNET_assert (0); /* FIXME: Add notification for failure */ 152 emsg = GNUNET_TESTBED_parse_error_string_ ((const struct
148 } 153 GNUNET_TESTBED_OperationFailureEventMessage
154 *) msg);
155 if (NULL == emsg)
156 emsg = "Unknown error";
157 info.details.operation_finished.emsg = emsg;
158 info.details.operation_finished.generic = NULL;
159 goto call_cb;
160 }
149 imsg = 161 imsg =
150 (const struct GNUNET_TESTBED_PeerConfigurationInformationMessage *) msg; 162 (const struct GNUNET_TESTBED_PeerConfigurationInformationMessage *) msg;
151 data->cfg = GNUNET_TESTBED_get_config_from_peerinfo_msg_ (imsg); 163 data->cfg = GNUNET_TESTBED_get_config_from_peerinfo_msg_ (imsg);
152 data->op_result = data->ca (data->cada_cls, data->cfg); 164 GNUNET_assert (NULL == data->op_result);
153 info.type = GNUNET_TESTBED_ET_OPERATION_FINISHED; 165 data->op_result = data->ca (data->cada_cls, data->cfg);
154 info.details.operation_finished.operation = data->operation;
155 info.details.operation_finished.op_cls = data->op_cls;
156 info.details.operation_finished.emsg = NULL; 166 info.details.operation_finished.emsg = NULL;
157 info.details.operation_finished.generic = data->op_result; 167 info.details.operation_finished.generic = data->op_result;
158 c = data->peer->controller; 168 c = data->peer->controller;
159 data->state = SERVICE_CONNECTED; 169 data->state = SERVICE_CONNECTED;
170
171 call_cb:
160 if ((0 != (GNUNET_TESTBED_ET_OPERATION_FINISHED & c->event_mask)) && 172 if ((0 != (GNUNET_TESTBED_ET_OPERATION_FINISHED & c->event_mask)) &&
161 (NULL != c->cc)) 173 (NULL != c->cc))
162 c->cc (c->cc_cls, &info); 174 c->cc (c->cc_cls, &info);
163 if (NULL != data->cb) 175 if (NULL != data->cb)
164 data->cb (data->cb_cls, data->operation, data->op_result, NULL); 176 data->cb (data->cb_cls, data->operation, data->op_result, emsg);
165} 177}
166 178
167 179