-improve indentation, reduce duplication of PIDs in core's neighbour map
[oweals/gnunet.git] / src / transport / plugin_transport_udp.c
index c638b6668203e527d8ed4e7cdec393669c5218f6..d031e600838d82fffb2dcd028b974d0206d11b32 100644 (file)
@@ -14,8 +14,8 @@
 
  You should have received a copy of the GNU General Public License
  along with GNUnet; see the file COPYING.  If not, write to the
- Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- Boston, MA 02111-1307, USA.
+ Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
  */
 
 /**
@@ -1901,7 +1901,7 @@ udp_plugin_send (void *cls,
                               GNUNET_NO);
     GNUNET_STATISTICS_update (plugin->env->stats,
                               "# UDP, unfragmented bytes payload queued total",
-                              udpw->payload_size,
+                              msgbuf_size,
                               GNUNET_NO);
   }
   else
@@ -2854,6 +2854,13 @@ udp_select_read (struct Plugin *plugin,
     /* Connection failure or something. Not a protocol violation. */
     return;
   }
+
+
+  /* PROCESS STUN PACKET */
+  if(GNUNET_NAT_try_decode_stun_packet(plugin->nat,(uint8_t *)buf, size ))
+    return;
+
+
   if (size < sizeof(struct GNUNET_MessageHeader))
   {
     LOG (GNUNET_ERROR_TYPE_WARNING,
@@ -2866,6 +2873,10 @@ udp_select_read (struct Plugin *plugin,
     GNUNET_break_op (0);
     return;
   }
+
+
+
+
   msg = (const struct GNUNET_MessageHeader *) buf;
   LOG (GNUNET_ERROR_TYPE_DEBUG,
        "UDP received %u-byte message from `%s' type %u\n",
@@ -3255,8 +3266,9 @@ udp_plugin_select_v4 (void *cls,
   plugin->select_task_v4 = NULL;
   if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN))
     return;
+  if (NULL == plugin->sockv4)
+    return;
   if ((0 != (tc->reason & GNUNET_SCHEDULER_REASON_READ_READY)) &&
-      (NULL != plugin->sockv4) &&
       (GNUNET_NETWORK_fdset_isset (tc->read_ready,
                                    plugin->sockv4)))
     udp_select_read (plugin,
@@ -3284,12 +3296,14 @@ udp_plugin_select_v6 (void *cls,
   plugin->select_task_v6 = NULL;
   if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN))
     return;
+  if (NULL == plugin->sockv6)
+    return;
   if ( (0 != (tc->reason & GNUNET_SCHEDULER_REASON_READ_READY)) &&
-       (NULL != plugin->sockv6) &&
        (GNUNET_NETWORK_fdset_isset (tc->read_ready,
                                     plugin->sockv6)) )
     udp_select_read (plugin,
                      plugin->sockv6);
+
   udp_select_send (plugin,
                    plugin->sockv6);
   schedule_select_v6 (plugin);
@@ -3530,7 +3544,8 @@ setup_sockets (struct Plugin *plugin,
                                      addrlens,
                                      &udp_nat_port_map_callback,
                                      NULL,
-                                     plugin);
+                                     plugin,
+                                     plugin->sockv4);
   return sockets_created;
 }