2 This file is part of GNUnet.
3 Copyright (C) 2013, 2016 GNUnet e.V.
5 GNUnet is free software: you can redistribute it and/or modify it
6 under the terms of the GNU Affero General Public License as published
7 by the Free Software Foundation, either version 3 of the License,
8 or (at your 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 Affero General Public License for more details.
15 You should have received a copy of the GNU Affero General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
20 * @author Christian Grothoff
23 * DV service API (should only be used by the DV plugin)
25 * @defgroup dv DV service
26 * Distance Vector routing
28 * The DV service API should only be used by the DV plugin.
31 #ifndef GNUNET_SERVICE_DV_H
32 #define GNUNET_SERVICE_DV_H
34 #include "gnunet_util_lib.h"
35 #include "gnunet_ats_service.h"
38 * Signature of a function to be called if DV
39 * starts to be able to talk to a peer.
42 * @param peer newly connected peer
43 * @param distance distance to the peer
44 * @param network the peer is located in
47 (*GNUNET_DV_ConnectCallback)(void *cls,
48 const struct GNUNET_PeerIdentity *peer,
50 enum GNUNET_ATS_Network_Type network);
54 * Signature of a function to be called if DV
55 * distance to a peer is changed.
58 * @param peer connected peer
59 * @param distance new distance to the peer
60 * @param network this network will be used to reach the next hop
63 (*GNUNET_DV_DistanceChangedCallback)(void *cls,
64 const struct GNUNET_PeerIdentity *peer,
66 enum GNUNET_ATS_Network_Type network);
70 * Signature of a function to be called if DV
71 * is no longer able to talk to a peer.
74 * @param peer peer that disconnected
77 (*GNUNET_DV_DisconnectCallback)(void *cls,
78 const struct GNUNET_PeerIdentity *peer);
82 * Signature of a function to be called if DV
83 * receives a message for this peer.
86 * @param sender sender of the message
87 * @param distance how far did the message travel
88 * @param msg actual message payload
91 (*GNUNET_DV_MessageReceivedCallback)(void *cls,
92 const struct GNUNET_PeerIdentity *sender,
94 const struct GNUNET_MessageHeader *msg);
98 * Signature of a function called once the delivery of a
99 * message has been successful.
104 (*GNUNET_DV_MessageSentCallback)(void *cls);
108 * Handle to the DV service.
110 struct GNUNET_DV_ServiceHandle;
114 * Connect to the DV service.
116 * @param cfg configuration
117 * @param cls closure for callbacks
118 * @param connect_cb function to call on connects
119 * @param distance_cb function to call if distances change
120 * @param disconnect_cb function to call on disconnects
121 * @param message_cb function to call if we receive messages
122 * @return handle to access the service
124 struct GNUNET_DV_ServiceHandle *
125 GNUNET_DV_service_connect (const struct GNUNET_CONFIGURATION_Handle *cfg,
127 GNUNET_DV_ConnectCallback connect_cb,
128 GNUNET_DV_DistanceChangedCallback distance_cb,
129 GNUNET_DV_DisconnectCallback disconnect_cb,
130 GNUNET_DV_MessageReceivedCallback message_cb);
134 * Disconnect from DV service.
136 * @param sh service handle
139 GNUNET_DV_service_disconnect (struct GNUNET_DV_ServiceHandle *sh);
143 * Handle for a send operation.
145 struct GNUNET_DV_TransmitHandle;
149 * Send a message via DV service.
151 * @param sh service handle
152 * @param target intended recpient
153 * @param msg message payload
154 * @return handle to cancel the operation
157 GNUNET_DV_send (struct GNUNET_DV_ServiceHandle *sh,
158 const struct GNUNET_PeerIdentity *target,
159 const struct GNUNET_MessageHeader *msg);
164 /** @} */ /* end of group */