extending bandwidth tracker api to support notifications
[oweals/gnunet.git] / src / include / gnunet_mesh_service.h
index b99c724b95cdc15a8e8e1d15caae9c50d1782aa3..21a51b7b22b1e4e199bb7cd5a9b0caae2a85a507 100644 (file)
@@ -362,44 +362,65 @@ GNUNET_MESH_receive_done (struct GNUNET_MESH_Channel *channel);
 /* normal mesh applications.                                                  */
 /******************************************************************************/
 
+
 /**
- * Method called to retrieve information about each channel the mesh peer
- * is aware of.
+ * Method called to retrieve information about a specific channel the mesh peer
+ * is aware of, including all transit nodes.
  *
  * @param cls Closure.
- * @param channel_number Channel number.
- * @param origin that started the channel (owner).
- * @param target other endpoint of the channel
+ * @param root Root of the channel.
+ * @param dest Destination of the channel.
+ * @param port Destination port of the channel.
+ * @param root_channel_number Local number for root, if known.
+ * @param dest_channel_number Local number for dest, if known.
+ * @param public_channel_numbe Number for P2P, always known.
  */
-typedef void (*GNUNET_MESH_ChannelsCB) (void *cls,
-                                        uint32_t root_channel_number,
-                                        uint32_t dest_channel_number,
-                                        uint32_t public_channel_number,
-                                        const struct GNUNET_PeerIdentity *origin,
-                                        const struct GNUNET_PeerIdentity *target);
-
+typedef void (*GNUNET_MESH_ChannelCB) (void *cls,
+                                       const struct GNUNET_PeerIdentity *root,
+                                       const struct GNUNET_PeerIdentity *dest,
+                                       uint32_t port,
+                                       uint32_t root_channel_number,
+                                       uint32_t dest_channel_number,
+                                       uint32_t public_channel_number);
 
 /**
- * Method called to retrieve information about a specific channel the mesh peer
- * is aware of, including all transit nodes.
+ * Method called to retrieve information about all peers in MESH, called
+ * once per peer.
+ *
+ * After last peer has been reported, an additional call with NULL is done.
  *
  * @param cls Closure.
- * @param peer Peer in the channel's tree.
- * @param parent Parent of the current peer. All 0 when peer is root.
+ * @param peer Peer, or NULL on "EOF".
+ * @param tunnel Do we have a tunnel towards this peer?
+ * @param n_paths Number of known paths towards this peer.
+ * @param best_path How long is the best path?
+ *                  (0 = unknown, 1 = ourselves, 2 = neighbor)
  */
-typedef void (*GNUNET_MESH_ChannelCB) (void *cls,
-                                      const struct GNUNET_PeerIdentity *peer,
-                                      const struct GNUNET_PeerIdentity *parent);
+typedef void (*GNUNET_MESH_PeersCB) (void *cls,
+                                     const struct GNUNET_PeerIdentity *peer,
+                                     int tunnel, unsigned int n_paths,
+                                     unsigned int best_path);
 
 
 /**
- * Method called to retrieve information about all tunnels in MESH.
+ * Method called to retrieve information about all tunnels in MESH, called
+ * once per tunnel.
+ *
+ * After last tunnel has been reported, an additional call with NULL is done.
  *
  * @param cls Closure.
- * @param peer Peer in the channel's tree.
+ * @param peer Destination peer, or NULL on "EOF".
+ * @param channels Number of channels.
+ * @param connections Number of connections.
+ * @param estate Encryption state.
+ * @param cstate Connectivity state.
  */
 typedef void (*GNUNET_MESH_TunnelsCB) (void *cls,
-                                       const struct GNUNET_PeerIdentity *peer);
+                                       const struct GNUNET_PeerIdentity *peer,
+                                       unsigned int channels,
+                                       unsigned int connections,
+                                       uint16_t estate,
+                                       uint16_t cstate);
 
 
 
@@ -408,69 +429,121 @@ typedef void (*GNUNET_MESH_TunnelsCB) (void *cls,
  * has established, o`r is trying to establish.
  *
  * @param cls Closure.
- * @param peer Peer in the channel's tree.
+ * @param peer Peer towards whom the tunnel is directed.
+ * @param n_channels Number of channels.
+ * @param n_connections Number of connections.
+ * @param channels Channels.
+ * @param connections Connections.
+ * @param estate Encryption state.
+ * @param cstate Connectivity state.
  */
 typedef void (*GNUNET_MESH_TunnelCB) (void *cls,
                                       const struct GNUNET_PeerIdentity *peer,
-                                      unsigned int channels,
-                                      unsigned int connections,
-                                      unsigned int estatus,
-                                      unsigned int cstatus
-                                     );
-
+                                      unsigned int n_channels,
+                                      unsigned int n_connections,
+                                      uint32_t *channels,
+                                      struct GNUNET_HashCode *connections,
+                                      unsigned int estate,
+                                      unsigned int cstate);
 
 /**
- * Request information about the running mesh peer.
- * The callback will be called for every channel known to the service,
- * listing all active peers that belong to the channel.
- *
- * If called again on the same handle, it will overwrite the previous
- * callback and cls. To retrieve the cls, monitor_cancel must be
- * called first.
+ * Request information about a specific channel of the running mesh peer.
  *
  * WARNING: unstable API, likely to change in the future!
  *
  * @param h Handle to the mesh peer.
+ * @param peer ID of the other end of the channel.
+ * @param channel_number Channel number.
  * @param callback Function to call with the requested data.
  * @param callback_cls Closure for @c callback.
  */
 void
-GNUNET_MESH_get_channels (struct GNUNET_MESH_Handle *h,
-                         GNUNET_MESH_ChannelsCB callback,
+GNUNET_MESH_get_channel (struct GNUNET_MESH_Handle *h,
+                         struct GNUNET_PeerIdentity *peer,
+                         uint32_t channel_number,
+                         GNUNET_MESH_ChannelCB callback,
                          void *callback_cls);
 
 
 /**
- * Request information about a specific channel of the running mesh peer.
+ * Request information about peers known to the running mesh service.
+ * The callback will be called for every peer known to the service.
+ * Only one info request (of any kind) can be active at once.
+ *
  *
  * WARNING: unstable API, likely to change in the future!
  *
  * @param h Handle to the mesh peer.
- * @param initiator ID of the owner of the channel.
- * @param channel_number Channel number.
  * @param callback Function to call with the requested data.
  * @param callback_cls Closure for @c callback.
+ *
+ * @return #GNUNET_OK / #GNUNET_SYSERR
  */
-void
-GNUNET_MESH_show_channel (struct GNUNET_MESH_Handle *h,
-                         struct GNUNET_PeerIdentity *initiator,
-                         uint32_t channel_number,
-                         GNUNET_MESH_ChannelCB callback,
-                         void *callback_cls);
+int
+GNUNET_MESH_get_peers (struct GNUNET_MESH_Handle *h,
+                       GNUNET_MESH_PeersCB callback,
+                       void *callback_cls);
 
+/**
+ * Cancel a peer info request. The callback will not be called (anymore).
+ *
+ * WARNING: unstable API, likely to change in the future!
+ *
+ * @param h Mesh handle.
+ *
+ * @return Closure given to GNUNET_MESH_get_peers.
+ */
+void *
+GNUNET_MESH_get_peers_cancel (struct GNUNET_MESH_Handle *h);
 
 /**
- * Cancel a monitor request. The monitor callback will not be called.
+ * Request information about tunnels of the running mesh peer.
+ * The callback will be called for every tunnel of the service.
+ * Only one info request (of any kind) can be active at once.
  *
  * WARNING: unstable API, likely to change in the future!
  *
+ * @param h Handle to the mesh peer.
+ * @param callback Function to call with the requested data.
+ * @param callback_cls Closure for @c callback.
+ *
+ * @return #GNUNET_OK / #GNUNET_SYSERR
+ */
+int
+GNUNET_MESH_get_tunnels (struct GNUNET_MESH_Handle *h,
+                         GNUNET_MESH_TunnelsCB callback,
+                         void *callback_cls);
+
+/**
+ * Cancel a monitor request. The monitor callback will not be called.
+ *
  * @param h Mesh handle.
  *
  * @return Closure given to GNUNET_MESH_monitor, if any.
  */
 void *
-GNUNET_MESH_get_channels_cancel (struct GNUNET_MESH_Handle *h);
+GNUNET_MESH_get_tunnels_cancel (struct GNUNET_MESH_Handle *h);
+
 
+/**
+ * Request information about a tunnel of the running mesh peer.
+ * The callback will be called for the tunnel once.
+ * Only one info request (of any kind) can be active at once.
+ *
+ * WARNING: unstable API, likely to change in the future!
+ *
+ * @param h Handle to the mesh peer.
+ * @param id Peer whose tunnel to examine.
+ * @param callback Function to call with the requested data.
+ * @param callback_cls Closure for @c callback.
+ *
+ * @return #GNUNET_OK / #GNUNET_SYSERR
+ */
+int
+GNUNET_MESH_get_tunnel (struct GNUNET_MESH_Handle *h,
+                        const struct GNUNET_PeerIdentity *id,
+                        GNUNET_MESH_TunnelCB callback,
+                        void *callback_cls);
 
 /**
  * Create a message queue for a mesh channel.