more nat code
authorChristian Grothoff <christian@grothoff.org>
Fri, 1 Jul 2011 17:59:57 +0000 (17:59 +0000)
committerChristian Grothoff <christian@grothoff.org>
Fri, 1 Jul 2011 17:59:57 +0000 (17:59 +0000)
src/nat/nat_test.c

index 4b502ec60fd814d7cb2a91f1c57bb51616aab0d3..dc8255a8e40977edb2c5b72d286f9e58a4d70490 100644 (file)
@@ -169,16 +169,30 @@ do_read (void *cls,
 {
   struct NatActivity *na = cls;
   struct GNUNET_NAT_Test *tst;
+  uint16_t data;
 
   na->rtask = GNUNET_SCHEDULER_NO_TASK;
   tst = na->h;
   GNUNET_CONTAINER_DLL_remove (tst->head,
                               tst->tail,
                               na);
-  if (1)
+  if ( (NULL != tc->write_ready) &&
+       (GNUNET_NETWORK_fdset_isset (tc->read_ready, 
+                                   na->sock)) &&
+       (sizeof (data) ==
+       GNUNET_NETWORK_socket_recv (na->sock,
+                                   &data,
+                                   sizeof (data))) )
     {
-      // fimxe: read from socket...
+      if (data == tst->data)
+       tst->report (tst->report_cls, GNUNET_OK);
+      else
+       GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                   "Received data mismatches expected value\n");
     }
+  else
+    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+               "Failed to receive data from inbound connection\n");
   GNUNET_NETWORK_socket_close (na->sock);
   GNUNET_free (na);
 }
@@ -208,7 +222,12 @@ do_accept (void *cls,
                                              tst);
   s = GNUNET_NETWORK_socket_accept (tst->lsock, NULL, NULL);
   if (NULL == s)
-    return; /* odd error */
+    {
+      GNUNET_log_strerror (GNUNET_ERROR_TYPE_INFO, "accept");
+      return; /* odd error */
+    }
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+             "Got an inbound connection, waiting for data\n");
   wl = GNUNET_malloc (sizeof (struct NatActivity));
   wl->sock = s;
   wl->h = tst;