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 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.
17 * @author Christian Grothoff
20 * DV service API (should only be used by the DV plugin)
22 * @defgroup dv DV service
23 * Distance Vector routing
25 * The DV service API should only be used by the DV plugin.
28 #ifndef GNUNET_SERVICE_DV_H
29 #define GNUNET_SERVICE_DV_H
31 #include "gnunet_util_lib.h"
32 #include "gnunet_ats_service.h"
35 * Signature of a function to be called if DV
36 * starts to be able to talk to a peer.
39 * @param peer newly connected peer
40 * @param distance distance to the peer
41 * @param network the peer is located in
44 (*GNUNET_DV_ConnectCallback)(void *cls,
45 const struct GNUNET_PeerIdentity *peer,
47 enum GNUNET_ATS_Network_Type network);
51 * Signature of a function to be called if DV
52 * distance to a peer is changed.
55 * @param peer connected peer
56 * @param distance new distance to the peer
57 * @param network this network will be used to reach the next hop
60 (*GNUNET_DV_DistanceChangedCallback)(void *cls,
61 const struct GNUNET_PeerIdentity *peer,
63 enum GNUNET_ATS_Network_Type network);
67 * Signature of a function to be called if DV
68 * is no longer able to talk to a peer.
71 * @param peer peer that disconnected
74 (*GNUNET_DV_DisconnectCallback)(void *cls,
75 const struct GNUNET_PeerIdentity *peer);
79 * Signature of a function to be called if DV
80 * receives a message for this peer.
83 * @param sender sender of the message
84 * @param distance how far did the message travel
85 * @param msg actual message payload
88 (*GNUNET_DV_MessageReceivedCallback)(void *cls,
89 const struct GNUNET_PeerIdentity *sender,
91 const struct GNUNET_MessageHeader *msg);
95 * Signature of a function called once the delivery of a
96 * message has been successful.
101 (*GNUNET_DV_MessageSentCallback)(void *cls);
105 * Handle to the DV service.
107 struct GNUNET_DV_ServiceHandle;
111 * Connect to the DV service.
113 * @param cfg configuration
114 * @param cls closure for callbacks
115 * @param connect_cb function to call on connects
116 * @param distance_cb function to call if distances change
117 * @param disconnect_cb function to call on disconnects
118 * @param message_cb function to call if we receive messages
119 * @return handle to access the service
121 struct GNUNET_DV_ServiceHandle *
122 GNUNET_DV_service_connect (const struct GNUNET_CONFIGURATION_Handle *cfg,
124 GNUNET_DV_ConnectCallback connect_cb,
125 GNUNET_DV_DistanceChangedCallback distance_cb,
126 GNUNET_DV_DisconnectCallback disconnect_cb,
127 GNUNET_DV_MessageReceivedCallback message_cb);
131 * Disconnect from DV service.
133 * @param sh service handle
136 GNUNET_DV_service_disconnect (struct GNUNET_DV_ServiceHandle *sh);
140 * Handle for a send operation.
142 struct GNUNET_DV_TransmitHandle;
146 * Send a message via DV service.
148 * @param sh service handle
149 * @param target intended recpient
150 * @param msg message payload
151 * @return handle to cancel the operation
154 GNUNET_DV_send (struct GNUNET_DV_ServiceHandle *sh,
155 const struct GNUNET_PeerIdentity *target,
156 const struct GNUNET_MessageHeader *msg);
161 /** @} */ /* end of group */