- fix warnings
[oweals/gnunet.git] / src / identity-provider / identity_provider_api.c
index f0e91a7399f69ca43d5e5fec5a9c6f3f6d5facca..f3280cb18a8ae393f03c9cfdb63e76dfcb01542c 100644 (file)
@@ -1,6 +1,6 @@
 /*
      This file is part of GNUnet.
-     Copyright (C) 2016 Christian Grothoff (and other contributing authors)
+     Copyright (C) 2016 GNUnet e.V.
 
      GNUnet is free software; you can redistribute it and/or modify
      it under the terms of the GNU General Public Liceidentity as published
@@ -138,11 +138,9 @@ struct GNUNET_IDENTITY_PROVIDER_Handle
  * Try again to connect to the service.
  *
  * @param cls handle to the service.
- * @param tc scheduler context
  */
 static void
-reconnect (void *cls,
-          const struct GNUNET_SCHEDULER_TaskContext *tc);
+reconnect (void *cls);
 
 
 /**
@@ -193,7 +191,11 @@ message_handler (void *cls,
   const struct GNUNET_IDENTITY_PROVIDER_IssueResultMessage *irm;
   const struct GNUNET_IDENTITY_PROVIDER_ExchangeResultMessage *erm;
   char *str;
+  char *ticket_str;
+  char *token_str;
+  char *label_str;
   uint16_t size;
+  uint64_t ticket_nonce;
 
   if (NULL == msg)
   {
@@ -214,26 +216,56 @@ message_handler (void *cls,
       return;
     }
     irm = (const struct GNUNET_IDENTITY_PROVIDER_IssueResultMessage *) msg;
-    str = (char *) &irm[1];
+    str = GNUNET_strdup ((char *) &irm[1]);
     if ( (size > sizeof (struct GNUNET_IDENTITY_PROVIDER_IssueResultMessage)) &&
         ('\0' != str[size - sizeof (struct GNUNET_IDENTITY_PROVIDER_IssueResultMessage) - 1]) )
     {
+      GNUNET_free (str);
       GNUNET_break (0);
       reschedule_connect (h);
       return;
     }
     if (size == sizeof (struct GNUNET_IDENTITY_PROVIDER_IssueResultMessage))
+    {
+      GNUNET_free (str);
       str = NULL;
+    }
+    label_str = strtok (str, ",");
 
+    if (NULL == label_str)
+    {
+      GNUNET_free (str);
+      GNUNET_break (0);
+      reschedule_connect (h);
+      return;
+    }
+    ticket_str = strtok (NULL, ",");
+    if (NULL == ticket_str)
+    {
+      GNUNET_free (str);
+      GNUNET_break (0);
+      reschedule_connect (h);
+      return;
+    }
+    token_str = strtok (NULL, ",");
+    if (NULL == token_str)
+    {
+      GNUNET_free (str);
+      GNUNET_break (0);
+      reschedule_connect (h);
+      return;
+    }
     op = h->op_head;
     GNUNET_CONTAINER_DLL_remove (h->op_head,
                                 h->op_tail,
                                 op);
     GNUNET_CLIENT_receive (h->client, &message_handler, h,
                           GNUNET_TIME_UNIT_FOREVER_REL);
-    ticket.data = str;
+    ticket.data = ticket_str;
+    token.data = token_str;
     if (NULL != op->iss_cb)
-      op->iss_cb (op->cls, &ticket);
+      op->iss_cb (op->cls, label_str, &ticket, &token);
+    GNUNET_free (str);
     GNUNET_free (op);
     break;
    case GNUNET_MESSAGE_TYPE_IDENTITY_PROVIDER_EXCHANGE_RESULT:
@@ -262,11 +294,12 @@ message_handler (void *cls,
     GNUNET_CLIENT_receive (h->client, &message_handler, h,
                           GNUNET_TIME_UNIT_FOREVER_REL);
     token.data = str;
+    ticket_nonce = ntohl (erm->ticket_nonce);
     if (NULL != op->ex_cb)
-      op->ex_cb (op->cls, &token);
+      op->ex_cb (op->cls, &token, ticket_nonce);
     GNUNET_free (op);
     break;
-  
+
   default:
     GNUNET_break (0);
     reschedule_connect (h);
@@ -362,10 +395,9 @@ transmit_next (struct GNUNET_IDENTITY_PROVIDER_Handle *h)
  * Try again to connect to the service.
  *
  * @param cls handle to the identity provider service.
- * @param tc scheduler context
  */
 static void
-reconnect (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
+reconnect (void *cls)
 {
   struct GNUNET_IDENTITY_PROVIDER_Handle *h = cls;