use enum GNUNET_ATS_Network_Type instead of uint32_t where appropriate
[oweals/gnunet.git] / src / include / gnunet_transport_service.h
index 6396127b8007f4fd4d940e26cbb06a5017d46d51..4b0735b10261b772bf8cd1c9c256b2df31e312bb 100644 (file)
@@ -58,10 +58,7 @@ typedef void (*GNUNET_TRANSPORT_ReceiveCallback) (void *cls,
                                                   GNUNET_PeerIdentity * peer,
                                                   const struct
                                                   GNUNET_MessageHeader *
-                                                  message,
-                                                  const struct
-                                                  GNUNET_ATS_Information * ats,
-                                                  uint32_t ats_count);
+                                                  message);
 
 
 /**
@@ -81,10 +78,7 @@ struct GNUNET_TRANSPORT_Handle;
  */
 typedef void (*GNUNET_TRANSPORT_NotifyConnect) (void *cls,
                                                 const struct GNUNET_PeerIdentity
-                                                * peer,
-                                                const struct
-                                                GNUNET_ATS_Information * ats,
-                                                uint32_t ats_count);
+                                                * peer);
 
 /**
  * Function called to notify transport users that another
@@ -148,9 +142,9 @@ typedef void (*GNUNET_TRANSPORT_PeerIterateCallback) (void *cls,
  * @param self our own identity (API should check that it matches
  *             the identity found by transport), or NULL (no check)
  * @param cls closure for the callbacks
- * @param rec receive function to call
- * @param nc function to call on connect events
- * @param nd function to call on disconnect events
+ * @param rec receive function to call, or NULL
+ * @param nc function to call on connect events, or NULL
+ * @param nd function to call on disconnect events, or NULL
  * @return NULL on error
  */
 struct GNUNET_TRANSPORT_Handle *
@@ -184,6 +178,7 @@ struct GNUNET_TRANSPORT_TryConnectHandle;
  * @param target who we should try to connect to
  * @param cb callback to be called when request was transmitted to transport
  *         service
+ * @param cb_cls closure for the callback
  * @return a GNUNET_TRANSPORT_TryConnectHandle handle or
  *         NULL on failure (cb will not be called)
  */
@@ -203,6 +198,7 @@ GNUNET_TRANSPORT_try_connect (struct GNUNET_TRANSPORT_Handle *handle,
 void
 GNUNET_TRANSPORT_try_connect_cancel (struct GNUNET_TRANSPORT_TryConnectHandle *tch);
 
+
 /**
  * Opaque handle for a transmission-ready request.
  */
@@ -269,7 +265,55 @@ struct GNUNET_TRANSPORT_GetHelloHandle;
 
 
 /**
- * Obtain updates on changes to the HELLO message for this peer.
+ * Checks if a given peer is connected to us
+ *
+ * @param handle connection to transport service
+ * @param peer the peer to check
+ * @return #GNUNET_YES (connected) or #GNUNET_NO (disconnected)
+ */
+int
+GNUNET_TRANSPORT_check_peer_connected (struct GNUNET_TRANSPORT_Handle *handle,
+                                            const struct GNUNET_PeerIdentity *peer);
+
+
+/**
+ * Set transport metrics for a peer and a direction
+ *
+ * @param handle transport handle
+ * @param peer the peer to set the metric for
+ * @param inbound set inbound direction (GNUNET_YES or GNUNET_NO)
+ * @param outbound set outbound direction (GNUNET_YES or GNUNET_NO)
+ * @param ats the metric as ATS information
+ * @param ats_count the number of metrics
+ *
+ * Supported ATS values:
+ * GNUNET_ATS_QUALITY_NET_DELAY  (value in ms)
+ * GNUNET_ATS_QUALITY_NET_DISTANCE (value in count(hops))
+ *
+ * Example
+ * To enforce a delay of 10 ms for peer p1 in sending direction use:
+ *
+ * struct GNUNET_ATS_Information ats;
+ * ats.type = ntohl (GNUNET_ATS_QUALITY_NET_DELAY);
+ * ats.value = ntohl (10);
+ * GNUNET_TRANSPORT_set_traffic_metric (th, p1, TM_SEND, &ats, 1);
+ *
+ * Note:
+ * Delay restrictions in receiving direction will be enforced with
+ * 1 message delay.
+ */
+void
+GNUNET_TRANSPORT_set_traffic_metric (struct GNUNET_TRANSPORT_Handle *handle,
+                                    const struct GNUNET_PeerIdentity *peer,
+                                    int inbound,
+                                    int outbound,
+                                    const struct GNUNET_ATS_Information *ats,
+                                    size_t ats_count);
+
+
+/**
+ * Obtain updates on changes to the HELLO message for this peer. The callback
+ * given in this function is never called synchronously.
  *
  * @param handle connection to transport service
  * @param rec function to call with the HELLO
@@ -320,6 +364,7 @@ GNUNET_TRANSPORT_offer_hello (struct GNUNET_TRANSPORT_Handle *handle,
 void
 GNUNET_TRANSPORT_offer_hello_cancel (struct GNUNET_TRANSPORT_OfferHelloHandle *ohh);
 
+
 /**
  * Handle to cancel a pending address lookup.
  */