f54a77a7ebe2f087f79df529254acb699759f3b2
[oweals/gnunet.git] / src / dv / dv.h
1 /*
2      This file is part of GNUnet.
3      Copyright (C) 2013 GNUnet e.V.
4
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.
9
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.
14     
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/>.
17 */
18
19 /**
20  * @author Christian Grothoff
21  * @file dv/dv.h
22  * @brief IPC messages between DV service and DV plugin
23  */
24 #ifndef DV_H
25 #define DV_H
26
27 #include "gnunet_common.h"
28
29 GNUNET_NETWORK_STRUCT_BEGIN
30
31 /**
32  * DV service tells plugin about a DV-connection being
33  * now available.
34  */
35 struct GNUNET_DV_ConnectMessage
36 {
37   /**
38    * Type: #GNUNET_MESSAGE_TYPE_DV_CONNECT
39    */
40   struct GNUNET_MessageHeader header;
41
42   /**
43    * The distance to the peer that we are now connected to
44    */
45   uint32_t distance GNUNET_PACKED;
46
47   /**
48    * The other peer (at the given distance).
49    */
50   struct GNUNET_PeerIdentity peer;
51
52   /**
53    * The network the peer is in
54    */
55   uint32_t network GNUNET_PACKED;
56
57 };
58
59
60 /**
61  * DV service tells plugin about a DV-connection being
62  * no longer available.
63  *
64  * Sender address is copied to the end of this struct,
65  * followed by the actual message received.
66  */
67 struct GNUNET_DV_DisconnectMessage
68 {
69   /**
70    * Type: #GNUNET_MESSAGE_TYPE_DV_DISCONNECT
71    */
72   struct GNUNET_MessageHeader header;
73
74   /**
75    * Always zero.
76    */
77   uint32_t reserved GNUNET_PACKED;
78
79   /**
80    * The peer that is no longer available.
81    */
82   struct GNUNET_PeerIdentity peer;
83
84 };
85
86
87 /**
88  * DV Message, contains a message that was received via DV for this
89  * peer.  Send from the DV service to the DV plugin.
90  *
91  * Sender address is copied to the end of this struct,
92  * followed by the actual message received.
93  */
94 struct GNUNET_DV_ReceivedMessage
95 {
96   /**
97    * Type: #GNUNET_MESSAGE_TYPE_DV_RECV
98    */
99   struct GNUNET_MessageHeader header;
100
101   /**
102    * The distance to the peer that we received the message from
103    */
104   uint32_t distance GNUNET_PACKED;
105
106   /**
107    * The (actual) sender of the message
108    */
109   struct GNUNET_PeerIdentity sender;
110
111   /* payload follows */
112 };
113
114
115 /**
116  * Message from plugin to DV service, requesting a
117  * message to be routed.
118  */
119 struct GNUNET_DV_SendMessage
120 {
121   /**
122    * Type: #GNUNET_MESSAGE_TYPE_DV_SEND
123    */
124   struct GNUNET_MessageHeader header;
125
126   /**
127    * Reserved for alignment. 0.
128    */
129   uint32_t reserved GNUNET_PACKED;
130
131   /**
132    * The (actual) target of the message
133    */
134   struct GNUNET_PeerIdentity target;
135
136 };
137
138
139 /**
140  * Message from service to DV plugin, saying that our
141  * distance to another peer changed.
142  */
143 struct GNUNET_DV_DistanceUpdateMessage
144 {
145   /**
146    * Type: #GNUNET_MESSAGE_TYPE_DV_DISTANCE_CHANGED.
147    */
148   struct GNUNET_MessageHeader header;
149
150   /**
151    * What is the new distance?
152    */
153   uint32_t distance GNUNET_PACKED;
154
155   /**
156    * The peer for which the distance changed.
157    */
158   struct GNUNET_PeerIdentity peer;
159
160   /**
161    * The network the peer is in
162    */
163   uint32_t network GNUNET_PACKED;
164
165 };
166
167
168 GNUNET_NETWORK_STRUCT_END
169
170 #endif