-}
-
-
-
-void
-GAS_handle_monitor (void *cls,
- struct GNUNET_SERVER_Client *client,
- const struct GNUNET_MessageHeader *message)
-{
- struct PerformanceClient *pc;
- struct PerformanceMonitorClient *res;
- struct MonitorMessage *mm = (struct MonitorMessage *) message;
- size_t msg_size;
- uint32_t id;
- uint32_t op;
-
- pc = find_client (client);
- if (NULL == pc)
- {
- GNUNET_break (0);
- return;
- }
-
- msg_size = ntohs (message->size);
- if (msg_size < sizeof (struct MonitorMessage))
- {
- GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
- return;
- }
-
- id = ntohl (mm->id);
- op = ntohl (mm->op);
-
- for (res = pc->pm_head; NULL != res; res = res->next)
- if ((res->id == id) && (client == res->client))
- break;
-
- if (GNUNET_YES == op)
- {
- /* Start monitoring */
- if (NULL != res)
- {
- GNUNET_break (0);
- GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
- return; /* Duplicate*/
- }
- res = GNUNET_malloc (sizeof (struct PerformanceMonitorClient));
- res->client = client;
- res->id = id;
- GNUNET_CONTAINER_DLL_insert (pc->pm_head, pc->pm_tail, res);
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Added performance monitoring client %p id %u\n",
- client, id);
- }
- else if (GNUNET_NO == op)
- {
- /* Stop monitoring */
- if (NULL == res)
- {
- GNUNET_break (0);
- GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
- return; /* Not existing */
- }
- GNUNET_CONTAINER_DLL_remove (pc->pm_head, pc->pm_tail, res);
- GNUNET_free (res);
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Removed performance monitoring client %p id %u\n",
- client, id);
- }
- else
- {
- GNUNET_break (0);
- GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
- return;
- }
- GNUNET_SERVER_receive_done (client, GNUNET_OK);