2 This file is part of GNUnet.
3 (C) 2010,2011 Christian Grothoff (and other contributing authors)
5 GNUnet is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published
7 by the Free Software Foundation; either version 3, or (at your
8 option) any later version.
10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with GNUnet; see the file COPYING. If not, write to the
17 Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA.
22 * @file transport/gnunet-service-transport_neighbours.h
23 * @brief neighbour management API
24 * @author Christian Grothoff
26 #ifndef GNUNET_SERVICE_TRANSPORT_NEIGHBOURS_H
27 #define GNUNET_SERVICE_TRANSPORT_NEIGHBOURS_H
29 #include "gnunet_statistics_service.h"
30 #include "gnunet_transport_service.h"
31 #include "gnunet_util_lib.h"
34 // - have a way to access the currently 'connected' session
35 // (for sending and to notice disconnect of it!)
36 // - have a way to access/update bandwidth/quota information per peer
37 // (for CostReport/TrafficReport callbacks)
42 * Initialize the neighbours subsystem.
44 * @param cls closure for callbacks
45 * @param connect_cb function to call if we connect to a peer
46 * @param disconnect_cb function to call if we disconnect from a peer
49 GST_neighbours_start (void *cls,
50 GNUNET_TRANSPORT_NotifyConnect connect_cb,
51 GNUNET_TRANSPORT_NotifyDisconnect disconnect_cb);
55 * Cleanup the neighbours subsystem.
58 GST_neighbours_stop (void);
62 * Try to create a connection to the given target (eventually).
64 * @param target peer to try to connect to
67 GST_neighbours_try_connect (const struct GNUNET_PeerIdentity *target);
71 * Test if we're connected to the given peer.
73 * @param target peer to test
74 * @return GNUNET_YES if we are connected, GNUNET_NO if not
77 GST_neighbours_test_connected (const struct GNUNET_PeerIdentity *target);
81 * If we have an active connection to the given target, it must be shutdown.
83 * @param target peer to disconnect from
86 GST_neighbours_force_disconnect (const struct GNUNET_PeerIdentity *target);
90 * Function called for each connected neighbour.
93 * @param neighbour identity of the neighbour
95 typedef void (*GST_NeighbourIterator)(void *cls,
96 const struct GNUNET_PeerIdentity *neighbour);
100 * Iterate over all connected neighbours.
102 * @param cb function to call
103 * @param cb_cls closure for cb
106 GST_neighbours_iterate (GST_NeighbourIterator cb,
111 * We have received a PONG. Update lifeness of the neighbour.
113 * @param sender peer sending the PONG
114 * @param hdr the PONG message (presumably)
115 * @param plugin_name name of transport that delivered the PONG
116 * @param sender_address address of the other peer, NULL if other peer
118 * @param sender_address_len number of bytes in sender_address
119 * @return GNUNET_OK if the message was well-formed, GNUNET_SYSERR if not
122 GST_neighbours_handle_pong (const struct GNUNET_PeerIdentity *sender,
123 const struct GNUNET_MessageHeader *hdr,
124 const char *plugin_name,
125 const void *sender_address,
126 size_t sender_address_len);
130 * We have received a CONNECT. Set the peer to connected.
132 * @param sender peer sending the PONG
133 * @param hdr the PONG message (presumably)
134 * @param plugin_name name of transport that delivered the PONG
135 * @param sender_address address of the other peer, NULL if other peer
137 * @param sender_address_len number of bytes in sender_address
138 * @return GNUNET_OK if the message was well-formed, GNUNET_SYSERR if not
141 GST_neighbours_handle_connect (const struct GNUNET_PeerIdentity *sender,
142 const struct GNUNET_MessageHeader *hdr,
143 const char *plugin_name,
144 const void *sender_address,
145 size_t sender_address_len);
149 * We have received a DISCONNECT. Set the peer to disconnected.
151 * @param sender peer sending the PONG
152 * @param hdr the PONG message (presumably)
153 * @param plugin_name name of transport that delivered the PONG
154 * @param sender_address address of the other peer, NULL if other peer
156 * @param sender_address_len number of bytes in sender_address
157 * @return GNUNET_OK if the message was well-formed, GNUNET_SYSERR if not
160 GST_neighbours_handle_disconnect (const struct GNUNET_PeerIdentity *sender,
161 const struct GNUNET_MessageHeader *hdr,
162 const char *plugin_name,
163 const void *sender_address,
164 size_t sender_address_len);
168 /* end of file gnunet-service-transport_neighbours.h */