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/>.
18 SPDX-License-Identifier: AGPL3.0-or-later
22 * @author Christian Grothoff
25 * DV service API (should only be used by the DV plugin)
27 * @defgroup dv DV service
28 * Distance Vector routing
30 * The DV service API should only be used by the DV plugin.
33 #ifndef GNUNET_SERVICE_DV_H
34 #define GNUNET_SERVICE_DV_H
36 #include "gnunet_util_lib.h"
37 #include "gnunet_ats_service.h"
40 * Signature of a function to be called if DV
41 * starts to be able to talk to a peer.
44 * @param peer newly connected peer
45 * @param distance distance to the peer
46 * @param network the peer is located in
49 (*GNUNET_DV_ConnectCallback)(void *cls,
50 const struct GNUNET_PeerIdentity *peer,
52 enum GNUNET_NetworkType network);
56 * Signature of a function to be called if DV
57 * distance to a peer is changed.
60 * @param peer connected peer
61 * @param distance new distance to the peer
62 * @param network this network will be used to reach the next hop
65 (*GNUNET_DV_DistanceChangedCallback)(void *cls,
66 const struct GNUNET_PeerIdentity *peer,
68 enum GNUNET_NetworkType network);
72 * Signature of a function to be called if DV
73 * is no longer able to talk to a peer.
76 * @param peer peer that disconnected
79 (*GNUNET_DV_DisconnectCallback)(void *cls,
80 const struct GNUNET_PeerIdentity *peer);
84 * Signature of a function to be called if DV
85 * receives a message for this peer.
88 * @param sender sender of the message
89 * @param distance how far did the message travel
90 * @param msg actual message payload
93 (*GNUNET_DV_MessageReceivedCallback)(void *cls,
94 const struct GNUNET_PeerIdentity *sender,
96 const struct GNUNET_MessageHeader *msg);
100 * Signature of a function called once the delivery of a
101 * message has been successful.
106 (*GNUNET_DV_MessageSentCallback)(void *cls);
110 * Handle to the DV service.
112 struct GNUNET_DV_ServiceHandle;
116 * Connect to the DV service.
118 * @param cfg configuration
119 * @param cls closure for callbacks
120 * @param connect_cb function to call on connects
121 * @param distance_cb function to call if distances change
122 * @param disconnect_cb function to call on disconnects
123 * @param message_cb function to call if we receive messages
124 * @return handle to access the service
126 struct GNUNET_DV_ServiceHandle *
127 GNUNET_DV_service_connect (const struct GNUNET_CONFIGURATION_Handle *cfg,
129 GNUNET_DV_ConnectCallback connect_cb,
130 GNUNET_DV_DistanceChangedCallback distance_cb,
131 GNUNET_DV_DisconnectCallback disconnect_cb,
132 GNUNET_DV_MessageReceivedCallback message_cb);
136 * Disconnect from DV service.
138 * @param sh service handle
141 GNUNET_DV_service_disconnect (struct GNUNET_DV_ServiceHandle *sh);
145 * Handle for a send operation.
147 struct GNUNET_DV_TransmitHandle;
151 * Send a message via DV service.
153 * @param sh service handle
154 * @param target intended recpient
155 * @param msg message payload
156 * @return handle to cancel the operation
159 GNUNET_DV_send (struct GNUNET_DV_ServiceHandle *sh,
160 const struct GNUNET_PeerIdentity *target,
161 const struct GNUNET_MessageHeader *msg);
166 /** @} */ /* end of group */