Check that you are not present in trail twice
[oweals/gnunet.git] / src / transport / plugin_transport_udp.h
index 46cea2d5be5c1d37bdd7e6a08d5213b5f1519d9d..3770b3b70584392b361e85b3429130f9bdbb52ad 100644 (file)
@@ -1,6 +1,6 @@
 /*
      This file is part of GNUnet
-     (C) 2010, 2011 Christian Grothoff (and other contributing authors)
+     (C) 2010-2014 Christian Grothoff (and other contributing authors)
 
      GNUnet is free software; you can redistribute it and/or modify
      it under the terms of the GNU General Public License as published
@@ -25,6 +25,9 @@
  * @author Nathan Evans
  * @author Matthias Wachs
  */
+#ifndef PLUGIN_TRANSPORT_UDP_H
+#define PLUGIN_TRANSPORT_UDP_H
+
 #include "platform.h"
 #include "gnunet_hello_lib.h"
 #include "gnunet_util_lib.h"
 
 #define LOG(kind,...) GNUNET_log_from (kind, "transport-udp", __VA_ARGS__)
 
+#define PLUGIN_NAME "udp"
+
 #define DEBUG_UDP GNUNET_NO
+
 #define DEBUG_UDP_BROADCASTING GNUNET_NO
 
 /**
@@ -57,10 +63,10 @@ GNUNET_NETWORK_STRUCT_BEGIN
  */
 struct IPv4UdpAddress
 {
-       /**
-        * Optional options and flags for this address
-        */
-       uint32_t options GNUNET_PACKED;
+  /**
+   * Optional options and flags for this address
+   */
+  uint32_t options GNUNET_PACKED;
 
   /**
    * IPv4 address, in network byte order.
@@ -79,10 +85,10 @@ struct IPv4UdpAddress
  */
 struct IPv6UdpAddress
 {
-       /**
-        * Optional options and flags for this address
-        */
-       uint32_t options GNUNET_PACKED;
+  /**
+   * Optional options and flags for this address
+   */
+  uint32_t options GNUNET_PACKED;
 
   /**
    * IPv6 address.
@@ -119,6 +125,10 @@ struct UDPMessage
 
 };
 
+struct UDP_MessageWrapper;
+
+struct PrettyPrinterContext;
+
 
 /**
  * Encapsulation of all of the state of the plugin.
@@ -133,7 +143,7 @@ struct Plugin
 
   /**
    * Session of peers with whom we are currently connected,
-   * map of peer identity to 'struct PeerSession'.
+   * map of peer identity to `struct Session *`.
    */
   struct GNUNET_CONTAINER_MultiPeerMap *sessions;
 
@@ -143,9 +153,13 @@ struct Plugin
   struct GNUNET_CONTAINER_Heap *defrag_ctxs;
 
   /**
-   * ID of select task
+   * ID of select task for IPv4
    */
   GNUNET_SCHEDULER_TaskIdentifier select_task;
+
+  /**
+   * ID of select task for IPv6
+   */
   GNUNET_SCHEDULER_TaskIdentifier select_task_v6;
 
   /**
@@ -168,12 +182,6 @@ struct Plugin
    */
   char *bind6_address;
 
-
-  /**
-   * Bytes currently in buffer
-   */
-  int64_t bytes_in_buffer;
-
   /**
    * Handle to NAT traversal support.
    */
@@ -189,13 +197,11 @@ struct Plugin
    */
   struct GNUNET_NETWORK_FDSet *ws_v4;
 
-
   /**
    * The read socket for IPv4
    */
   struct GNUNET_NETWORK_Handle *sockv4;
 
-
   /**
    * FD Read set
    */
@@ -212,41 +218,64 @@ struct Plugin
   struct GNUNET_NETWORK_Handle *sockv6;
 
   /**
-   * Beacon broadcasting
-   * -------------------
+   * Tokenizer for inbound IPv6 messages.
    */
+  struct GNUNET_SERVER_MessageStreamTokenizer *broadcast_ipv6_mst;
 
   /**
-   * Broadcast interval
+   * Tokenizer for inbound IPv4 messages.
    */
-  struct GNUNET_TIME_Relative broadcast_interval;
+  struct GNUNET_SERVER_MessageStreamTokenizer *broadcast_ipv4_mst;
 
   /**
-   * Broadcast with IPv4
+   * Head of DLL of broadcast addresses
    */
-  int broadcast_ipv4;
+  struct BroadcastAddress *broadcast_tail;
 
   /**
-   * Broadcast with IPv6
+   * Tail of DLL of broadcast addresses
    */
-  int broadcast_ipv6;
+  struct BroadcastAddress *broadcast_head;
 
+  /**
+   * Head of messages in IPv4 queue.
+   */
+  struct UDP_MessageWrapper *ipv4_queue_head;
 
   /**
-   * Tokenizer for inbound messages.
+   * Tail of messages in IPv4 queue.
    */
-  struct GNUNET_SERVER_MessageStreamTokenizer *broadcast_ipv6_mst;
-  struct GNUNET_SERVER_MessageStreamTokenizer *broadcast_ipv4_mst;
+  struct UDP_MessageWrapper *ipv4_queue_tail;
+
+  /**
+   * Head of messages in IPv6 queue.
+   */
+  struct UDP_MessageWrapper *ipv6_queue_head;
+
+  /**
+   * Tail of messages in IPv6 queue.
+   */
+  struct UDP_MessageWrapper *ipv6_queue_tail;
+
+  /**
+   * Running pretty printers: head
+   */
+  struct PrettyPrinterContext *ppc_dll_head;
 
   /**
-   * ID of select broadcast task
+   * Running pretty printers: tail
    */
-  GNUNET_SCHEDULER_TaskIdentifier send_ipv4_broadcast_task;
+  struct PrettyPrinterContext *ppc_dll_tail;
 
   /**
-   * ID of select broadcast task
+   * Function to call about session status changes.
    */
-  GNUNET_SCHEDULER_TaskIdentifier send_ipv6_broadcast_task;
+  GNUNET_TRANSPORT_SessionInfoCallback sic;
+
+  /**
+   * Closure for @e sic.
+   */
+  void *sic_cls;
 
   /**
    * IPv6 multicast address
@@ -254,21 +283,40 @@ struct Plugin
   struct sockaddr_in6 ipv6_multicast_address;
 
   /**
-   * DLL of IPv4 broadcast addresses
+   * Broadcast interval
    */
-  struct BroadcastAddress *ipv4_broadcast_tail;
-  struct BroadcastAddress *ipv4_broadcast_head;
+  struct GNUNET_TIME_Relative broadcast_interval;
 
   /**
-   * Is IPv6 enabled: GNUNET_YES or GNUNET_NO
+   * Bytes currently in buffer
+   */
+  int64_t bytes_in_buffer;
+
+  /**
+   * Address options
+   */
+  uint32_t myoptions;
+
+  /**
+   * Is IPv6 enabled: #GNUNET_YES or #GNUNET_NO
    */
   int enable_ipv6;
 
   /**
-   * Is IPv4 enabled: GNUNET_YES or GNUNET_NO
+   * Is IPv4 enabled: #GNUNET_YES or #GNUNET_NO
    */
   int enable_ipv4;
 
+  /**
+   * Is broadcasting enabled: #GNUNET_YES or #GNUNET_NO
+   */
+  int enable_broadcasting;
+
+  /**
+   * Is receiving broadcasts enabled: #GNUNET_YES or #GNUNET_NO
+   */
+  int enable_broadcasting_receiving;
+
   /**
    * Port we broadcasting on.
    */
@@ -284,11 +332,6 @@ struct Plugin
    */
   uint16_t aport;
 
-  struct UDP_MessageWrapper *ipv4_queue_head;
-  struct UDP_MessageWrapper *ipv4_queue_tail;
-
-  struct UDP_MessageWrapper *ipv6_queue_head;
-  struct UDP_MessageWrapper *ipv6_queue_tail;
 };
 
 
@@ -296,12 +339,20 @@ const char *
 udp_address_to_string (void *cls, const void *addr, size_t addrlen);
 
 void
-udp_broadcast_receive ();
+udp_broadcast_receive (struct Plugin *plugin,
+                       const char * buf,
+                       ssize_t size,
+                       const struct sockaddr *addr,
+                       size_t addrlen);
 
 void
-setup_broadcast (struct Plugin *plugin, struct sockaddr_in6 *server_addrv6, struct sockaddr_in *server_addrv4);
+setup_broadcast (struct Plugin *plugin,
+                 struct sockaddr_in6 *server_addrv6,
+                 struct sockaddr_in *server_addrv4);
 
 void
 stop_broadcast (struct Plugin *plugin);
 
+/*#ifndef PLUGIN_TRANSPORT_UDP_H*/
+#endif
 /* end of plugin_transport_udp.h */