core gives a buf of NULL to indicate errors
authorPhilipp Tölke <toelke@in.tum.de>
Wed, 5 Oct 2011 09:41:31 +0000 (09:41 +0000)
committerPhilipp Tölke <toelke@in.tum.de>
Wed, 5 Oct 2011 09:41:31 +0000 (09:41 +0000)
src/mesh/mesh_api.c
src/vpn/gnunet-daemon-vpn.c

index 4b6731d3fa6467f4b5a4c3a07ec82b5a82bafa92..5bb7d140390f7114e783b7ec8c871955e77cb03c 100644 (file)
@@ -675,6 +675,9 @@ core_notify (void *cls, size_t size, void *buf)
   struct notify_cls *ncls = cls;
   struct GNUNET_MESH_Tunnel *tunnel = ncls->tunnel;
 
+  if (NULL == buf)
+    return ncls->notify (ncls->notify_cls, 0, NULL);
+
   tunnel->notify_handle = NULL;
   struct tunnel_message *message = buf;
   void *cbuf = (void *) &message[1];
index 9c944ebef1699c1b982c4ec0d45fdb4d37a24870..fbbffc9a125bd9512b4970d5779e8a9e16c22297 100644 (file)
@@ -283,15 +283,21 @@ send_pkt_to_peer_notify_callback (void *cls, size_t size, void *buf)
   struct GNUNET_MESH_Tunnel **tunnel = cls;
 
   GNUNET_MESH_tunnel_set_data (*tunnel, NULL);
-  struct GNUNET_MessageHeader *hdr =
-      (struct GNUNET_MessageHeader *) (tunnel + 1);
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-              "send_pkt_to_peer_notify_callback: buf = %x; size = %u;\n", buf,
-              size);
-  GNUNET_assert (size >= ntohs (hdr->size));
-  memcpy (buf, hdr, ntohs (hdr->size));
-  size = ntohs (hdr->size);
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sent!\n");
+
+  if (NULL != buf)
+    {
+      struct GNUNET_MessageHeader *hdr =
+        (struct GNUNET_MessageHeader *) (tunnel + 1);
+      GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                  "send_pkt_to_peer_notify_callback: buf = %x; size = %u;\n", buf,
+                  size);
+      GNUNET_assert (size >= ntohs (hdr->size));
+      memcpy (buf, hdr, ntohs (hdr->size));
+      size = ntohs (hdr->size);
+      GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sent!\n");
+    }
+  else
+    size = 0;
 
   if (NULL != GNUNET_MESH_tunnel_get_head (*tunnel))
   {