doxy
[oweals/gnunet.git] / src / include / gnunet_mesh_service.h
index 0497cee2fe63787ed7b53ec3a51498571142159e..b674e5d7637cab50fee76f33fb6fbda5aa764a6d 100644 (file)
@@ -74,9 +74,8 @@ typedef int (*GNUNET_MESH_MessageCallback) (void *cls,
                                             sender,
                                             const struct GNUNET_MessageHeader *
                                             message,
-                                            const struct
-                                            GNUNET_ATS_Information *
-                                            atsi);
+                                            const struct GNUNET_ATS_Information
+                                            * atsi);
 
 
 /**
@@ -130,7 +129,10 @@ typedef void *(GNUNET_MESH_InboundTunnelNotificationHandler) (void *cls,
 
 /**
  * Function called whenever an inbound tunnel is destroyed.  Should clean up
- * any associated state.
+ * any associated state.  This function is NOT called if the client has
+ * explicitly asked for the tunnel to be destroyed using
+ * GNUNET_MESH_tunnel_destroy. It must NOT call GNUNET_MESH_tunnel_destroy on
+ * the tunnel.
  *
  * @param cls closure (set from GNUNET_MESH_connect)
  * @param tunnel connection to the other end (henceforth invalid)
@@ -152,13 +154,12 @@ typedef uint32_t GNUNET_MESH_ApplicationType;
  * Connect to the mesh service.
  *
  * @param cfg configuration to use
- * @param queue_size size of the data message queue, shared among all tunnels
- *                   (each tunnel is guaranteed to accept at least one message,
- *                    no matter what is the status of other tunnels)
  * @param cls closure for the various callbacks that follow
  *            (including handlers in the handlers array)
  * @param new_tunnel function called when an *inbound* tunnel is created
- * @param cleaner function called when an *inbound* tunnel is destroyed
+ * @param cleaner function called when an *inbound* tunnel is destroyed by the
+ *                remote peer, it is *not* called if GNUNET_MESH_tunnel_destroy
+ *                is called on the tunnel
  * @param handlers callbacks for messages we care about, NULL-terminated
  *                note that the mesh is allowed to drop notifications about
  *                inbound messages if the client does not process them fast
@@ -168,8 +169,7 @@ typedef uint32_t GNUNET_MESH_ApplicationType;
  *         (in this case, init is never called)
  */
 struct GNUNET_MESH_Handle *
-GNUNET_MESH_connect (const struct GNUNET_CONFIGURATION_Handle *cfg,
-                     unsigned int queue_size, void *cls,
+GNUNET_MESH_connect (const struct GNUNET_CONFIGURATION_Handle *cfg, void *cls,
                      GNUNET_MESH_InboundTunnelNotificationHandler new_tunnel,
                      GNUNET_MESH_TunnelEndHandler cleaner,
                      const struct GNUNET_MESH_MessageHandler *handlers,
@@ -177,7 +177,10 @@ GNUNET_MESH_connect (const struct GNUNET_CONFIGURATION_Handle *cfg,
 
 
 /**
- * Disconnect from the mesh service.
+ * Disconnect from the mesh service. All tunnels will be destroyed. All tunnel
+ * disconnect callbacks will be called on any still connected peers, notifying
+ * about their disconnection. The registered inbound tunnel cleaner will be
+ * called should any inbound tunnels still exist.
  *
  * @param handle connection to mesh to disconnect
  */
@@ -187,6 +190,10 @@ GNUNET_MESH_disconnect (struct GNUNET_MESH_Handle *handle);
 
 /**
  * Method called whenever a peer has disconnected from the tunnel.
+ * Implementations of this callback must NOT call
+ * GNUNET_MESH_tunnel_destroy immediately, but instead schedule those
+ * to run in some other task later.  However, calling 
+ * "GNUNET_MESH_notify_transmit_ready_cancel" is allowed.
  *
  * @param cls closure
  * @param peer peer identity the tunnel stopped working with
@@ -198,19 +205,34 @@ typedef void (*GNUNET_MESH_PeerDisconnectHandler) (void *cls,
 
 /**
  * Method called whenever a peer has connected to the tunnel.
- * TODO: change to typedef int? to let client allow the new peer or not
  *
  * @param cls closure
  * @param peer peer identity the tunnel was created to, NULL on timeout
  * @param atsi performance data for the connection
+ *
+ * TODO: change to return int to let client allow the new peer or not?
  */
 typedef void (*GNUNET_MESH_PeerConnectHandler) (void *cls,
                                                 const struct GNUNET_PeerIdentity
                                                 * peer,
                                                 const struct
-                                                GNUNET_ATS_Information
-                                                * atsi);
+                                                GNUNET_ATS_Information * atsi);
+
 
+/**
+ * Announce to ther peer the availability of services described by the regex,
+ * in order to be reachable to other peers via connect_by_string.
+ * 
+ * Note that the first 8 characters are considered to be part of a prefix,
+ * (for instance 'gnunet://'). If you put a variable part in there (*, +. ()),
+ * all matching strings will be stored in the DHT.
+ *
+ * @param h handle to mesh.
+ * @param regex string with the regular expression describing local services.
+ */
+void
+GNUNET_MESH_announce_regex (struct GNUNET_MESH_Handle *h,
+                            const char *regex);
 
 
 /**
@@ -230,7 +252,8 @@ GNUNET_MESH_tunnel_create (struct GNUNET_MESH_Handle *h, void *tunnel_ctx,
                            void *handler_cls);
 
 /**
- * Destroy an existing tunnel.
+ * Destroy an existing tunnel. The existing callback for the tunnel will NOT
+ * be called.
  *
  * @param tunnel tunnel handle
  */
@@ -238,6 +261,37 @@ void
 GNUNET_MESH_tunnel_destroy (struct GNUNET_MESH_Tunnel *tunnel);
 
 
+/**
+ * Request that the tunnel data rate is limited to the speed of the slowest
+ * receiver.
+ * 
+ * @param tunnel Tunnel affected.
+ */
+void
+GNUNET_MESH_tunnel_speed_min (struct GNUNET_MESH_Tunnel *tunnel);
+
+
+/**
+ * Request that the tunnel data rate is limited to the speed of the fastest
+ * receiver. This is the default behavior.
+ * 
+ * @param tunnel Tunnel affected.
+ */
+void
+GNUNET_MESH_tunnel_speed_max (struct GNUNET_MESH_Tunnel *tunnel);
+
+
+/**
+ * Turn on/off the buffering status of the tunnel.
+ * 
+ * @param tunnel Tunnel affected.
+ * @param buffer GNUNET_YES to turn buffering on (default),
+ *               GNUNET_NO otherwise.
+ */
+void
+GNUNET_MESH_tunnel_buffer (struct GNUNET_MESH_Tunnel *tunnel, int buffer);
+
+
 /**
  * Request that a peer should be added to the tunnel.  The connect handler
  * will be called when the peer connects
@@ -275,6 +329,45 @@ GNUNET_MESH_peer_request_connect_by_type (struct GNUNET_MESH_Tunnel *tunnel,
                                           GNUNET_MESH_ApplicationType app_type);
 
 
+/**
+ * Request that the mesh should try to connect to a peer matching the
+ * description given in the service string.
+ *
+ * @param tunnel handle to existing tunnel
+ * @param description string describing the destination node requirements
+ */
+void
+GNUNET_MESH_peer_request_connect_by_string (struct GNUNET_MESH_Tunnel *tunnel,
+                                            const char *description);
+
+
+/**
+ * Request that the given peer isn't added to this tunnel in calls to
+ * connect_by_* calls, (due to misbehaviour, bad performance, ...).
+ *
+ * @param tunnel handle to existing tunnel.
+ * @param peer peer identity of the peer which should be blacklisted
+ *                  for the tunnel.
+ */
+void
+GNUNET_MESH_peer_blacklist (struct GNUNET_MESH_Tunnel *tunnel,
+                            const struct GNUNET_PeerIdentity *peer);
+
+
+/**
+ * Request that the given peer isn't blacklisted anymore from this tunnel,
+ * and therefore can be added in future calls to connect_by_*.
+ * The peer must have been previously blacklisted for this tunnel.
+ *
+ * @param tunnel handle to existing tunnel.
+ * @param peer peer identity of the peer which shouldn't be blacklisted
+ *                  for the tunnel anymore.
+ */
+void
+GNUNET_MESH_peer_unblacklist (struct GNUNET_MESH_Tunnel *tunnel,
+                              const struct GNUNET_PeerIdentity *peer);
+
+
 /**
  * Handle for a transmission request.
  */
@@ -284,10 +377,11 @@ struct GNUNET_MESH_TransmitHandle;
 /**
  * Ask the mesh to call "notify" once it is ready to transmit the
  * given number of bytes to the specified tunnel or target.
+ * Only one call can be active at any time, to issue another request,
+ * wait for the callback or cancel the current request.
  *
  * @param tunnel tunnel to use for transmission
  * @param cork is corking allowed for this transmission?
- * @param priority how important is the message?
  * @param maxdelay how long can the message wait?
  * @param target destination for the message
  *               NULL for multicast to all tunnel targets
@@ -303,7 +397,6 @@ struct GNUNET_MESH_TransmitHandle;
  */
 struct GNUNET_MESH_TransmitHandle *
 GNUNET_MESH_notify_transmit_ready (struct GNUNET_MESH_Tunnel *tunnel, int cork,
-                                   uint32_t priority,
                                    struct GNUNET_TIME_Relative maxdelay,
                                    const struct GNUNET_PeerIdentity *target,
                                    size_t notify_size,
@@ -323,12 +416,16 @@ GNUNET_MESH_notify_transmit_ready_cancel (struct GNUNET_MESH_TransmitHandle
 
 /**
  * Transition API for tunnel ctx management
+ * 
+ * FIXME deprecated
  */
 void
 GNUNET_MESH_tunnel_set_data (struct GNUNET_MESH_Tunnel *tunnel, void *data);
 
 /**
  * Transition API for tunnel ctx management
+ * 
+ * FIXME deprecated
  */
 void *
 GNUNET_MESH_tunnel_get_data (struct GNUNET_MESH_Tunnel *tunnel);