- "Processing message of type %u and size %u from arm service\n",
- ntohs (msg->type), msize);
- if (msize < sizeof (struct GNUNET_ARM_Message))
- {
- GNUNET_break (0);
- reconnect_arm_later (h);
- return;
- }
- arm_msg = (const struct GNUNET_ARM_Message *) msg;
- id = GNUNET_ntohll (arm_msg->request_id);
- cm = find_cm_by_id (h, id);
- if (NULL == cm)
- {
- LOG (GNUNET_ERROR_TYPE_DEBUG, "Message with unknown id %llu\n", id);
- return;
- }
-
- fail = GNUNET_NO;
- switch (ntohs (msg->type))
- {
- case GNUNET_MESSAGE_TYPE_ARM_RESULT:
- if (msize < sizeof (struct GNUNET_ARM_ResultMessage))
- {
- GNUNET_assert (0);
- fail = GNUNET_YES;
- break;
- }
- res = (const struct GNUNET_ARM_ResultMessage *) msg;
- LOG (GNUNET_ERROR_TYPE_DEBUG,
- "Received response from ARM for service `%s': %u\n",
- (const char *) &cm->msg[1], ntohs (msg->type));
- result = (enum GNUNET_ARM_Result) ntohl (res->result);
- if (NULL != cm->result_cont)
- cm->result_cont (cm->cont_cls, h, GNUNET_ARM_REQUEST_SENT_OK, (const char *) &cm->msg[1], result);
- break;
- case GNUNET_MESSAGE_TYPE_ARM_LIST_RESULT:
- if (msize < sizeof (struct GNUNET_ARM_ListResultMessage))
- {
- GNUNET_break (0);
- fail = GNUNET_YES;
- return;
- }
- else
- {
- size_check = 0;
- lres = (const struct GNUNET_ARM_ListResultMessage *) msg;
- rcount = ntohs (lres->count);
- {
- const char *list[rcount];
- unsigned int i;
-
- pos = (const char *)&lres[1];
- for (i = 0; i < rcount; i++)
- {
- const char *end = memchr (pos, 0, msize - size_check);
- if (NULL == end)
- {
- GNUNET_break (0);
- fail = GNUNET_YES;
- break;
- }
- list[i] = pos;
- size_check += (end - pos) + 1;
- pos = end + 1;
- }
- if (GNUNET_YES == fail)
- break;
- if (NULL != cm->list_cont)
- cm->list_cont (cm->cont_cls, h, GNUNET_ARM_REQUEST_SENT_OK, rcount, list);
- }
- }
- break;
- default:
- fail = GNUNET_YES;
- return;
- }
-
- GNUNET_assert (GNUNET_SCHEDULER_NO_TASK != cm->timeout_task_id);
- GNUNET_SCHEDULER_cancel (cm->timeout_task_id);
- GNUNET_CONTAINER_DLL_remove (h->control_sent_head,
- h->control_sent_tail, cm);
- GNUNET_free (cm->msg);
- GNUNET_free (cm);
-
- if (GNUNET_YES == fail)
- reconnect_arm_later (h);
- else
- GNUNET_CLIENT_receive (h->client, &client_notify_handler, h,
- GNUNET_TIME_UNIT_FOREVER_REL);
+ "Requesting LIST from ARM service\n");
+ if (0 == h->request_id_counter)
+ h->request_id_counter++;
+ op = GNUNET_new (struct GNUNET_ARM_Operation);
+ op->h = h;
+ op->list_cont = cont;
+ op->cont_cls = cont_cls;
+ op->id = h->request_id_counter++;
+ GNUNET_CONTAINER_DLL_insert_tail (h->operation_pending_head,
+ h->operation_pending_tail,
+ op);
+ env = GNUNET_MQ_msg (msg,
+ GNUNET_MESSAGE_TYPE_ARM_LIST);
+ msg->reserved = htonl (0);
+ msg->request_id = GNUNET_htonll (op->id);
+ GNUNET_MQ_send (h->mq,
+ env);
+ return op;