aboutsummaryrefslogtreecommitdiff
path: root/src/mesh/mesh.h
diff options
context:
space:
mode:
authorBart Polot <bart@net.in.tum.de>2011-04-07 14:51:15 +0000
committerBart Polot <bart@net.in.tum.de>2011-04-07 14:51:15 +0000
commitf43a092ddd82985e23d9277dbb5df400dc49491e (patch)
treed71c0626a8beaf65fdd0f99ed6438db13acb520a /src/mesh/mesh.h
parentfc6755b1900955f16b762a1964a58f69b0c76f85 (diff)
downloadgnunet-f43a092ddd82985e23d9277dbb5df400dc49491e.tar.gz
gnunet-f43a092ddd82985e23d9277dbb5df400dc49491e.zip
Adaped to new API, documented
Diffstat (limited to 'src/mesh/mesh.h')
-rw-r--r--src/mesh/mesh.h169
1 files changed, 108 insertions, 61 deletions
diff --git a/src/mesh/mesh.h b/src/mesh/mesh.h
index a29c63f88..32d9c4ee5 100644
--- a/src/mesh/mesh.h
+++ b/src/mesh/mesh.h
@@ -27,34 +27,60 @@
27#define MESH_H_ 27#define MESH_H_
28#include <stdint.h> 28#include <stdint.h>
29 29
30#include <gnunet_mesh_service.h> 30#include <gnunet_mesh_service_new.h>
31#include "gnunet_common.h" 31#include "gnunet_common.h"
32 32
33/******************************************************************************/ 33/******************************************************************************/
34/******************** MESH NETWORK MESSAGES **************************/ 34/******************** MESH LOCAL MESSAGES *************************/
35/******************************************************************************/ 35/******************************************************************************/
36/* API CALL MESSAGE USED 36/* Any API call should be documented in the folowing table under API CALL.
37 * -------- ------------ 37 * Also, any message type should be documented in the following table, with the
38 * connect GNUNET_MESH_Connect 38 * associated event.
39 * disconnect None (network level disconnect) 39 *
40 * API CALL (GNUNET_MESH_*) MESSAGE USED
41 * ------------------------ ------------
42 * connect GNUNET_MESH_Connect
43 * disconnect None (network level disconnect)
40 * 44 *
41 * tunnel_create GNUNET_MESH_TunnelMessage 45 * tunnel_create GNUNET_MESH_TunnelMessage
42 * tunnel_destroy GNUNET_MESH_TunnelMessage 46 * tunnel_destroy GNUNET_MESH_TunnelMessage
43 * 47 *
44 * peer_request_connect_add GNUNET_MESH_ConnectPeer 48 * peer_request_connect_add GNUNET_MESH_PeerControl
45 * peer_request_connect_del GNUNET_MESH_ConnectPeer 49 * peer_request_connect_del GNUNET_MESH_PeerControl
46 * peer_request_connect_by_type GNUNET_MESH_ConnectPeerByType 50 * peer_request_connect_by_type GNUNET_MESH_ConnectPeerByType
47 * 51 *
48 * notify_transmit_ready GNUNET_MESH_Control 52 * notify_transmit_ready GNUNET_MESH_RequestTransmitReady
49 * notify_transmit_ready_cancel None 53 * notify_transmit_ready_cancel None (clear of internal data structures)
54 *
55 *
56 *
57 * EVENT MESSAGE USED
58 * ----- ------------
59 * notify_transmit_ready reply GNUNET_MESH_NotifyTransmitReady
60 * notify_transmit_ready data GNUNET_MESH_Data or
61 * GNUNET_MESH_DataBroadcast
62 * new incoming tunnel GNUNET_MESH_PeerControl
63 * peer connects to a tunnel GNUNET_MESH_PeerControl
64 * peer disconnects from a tunnel GNUNET_MESH_PeerControl
50 */ 65 */
51 66
67/**
68 * Type for tunnel numbering.
69 * - Local tunnel numbers are >= 0x80000000
70 * - Global tunnel numbers are < 0x80000000
71 */
72typedef uint32_t MESH_TunnelID;
52 73
74
75/**
76 * Message for connecting to the msh service. Specifies the messages the client
77 * is interested in.
78 */
53struct GNUNET_MESH_Connect { 79struct GNUNET_MESH_Connect {
54 /** 80 /**
55 * Type: GNUNET_MESSAGE_TYPE_MESH_LOCAL_CONNECT 81 * Type: GNUNET_MESSAGE_TYPE_MESH_LOCAL_CONNECT
56 * 82 * Size: sizeof(struct GNUNET_MESH_Connect) +
57 * Size: sizeof(struct GNUNET_MESH_Connect) + messages_subscribed * sizeof (message_type) 83 * messages_subscribed * sizeof (message_type)
58 */ 84 */
59 struct GNUNET_MessageHeader header; 85 struct GNUNET_MessageHeader header;
60 86
@@ -63,7 +89,7 @@ struct GNUNET_MESH_Connect {
63 89
64 90
65/** 91/**
66 * 92 * Message for a client to create and destroy tunnels.
67 */ 93 */
68struct GNUNET_MESH_TunnelMessage { 94struct GNUNET_MESH_TunnelMessage {
69 /** 95 /**
@@ -71,37 +97,47 @@ struct GNUNET_MESH_TunnelMessage {
71 */ 97 */
72 struct GNUNET_MessageHeader header; 98 struct GNUNET_MessageHeader header;
73 99
74 /** 100 /**
75 * ID of a tunnel controlled by this client. 101 * ID of a tunnel controlled by this client.
76 */ 102 */
77 uint32_t tunnel_id GNUNET_PACKED; 103 MESH_TunnelID tunnel_id GNUNET_PACKED;
78}; 104};
79 105
80 106/**
107 * Message for:
108 * - request adding and deleting peers from a tunnel
109 * - notify the client that peers have connected:
110 * -- requested
111 * -- unrequested (new incoming tunnels)
112 * - notify the client that peers have disconnected
113 */
81struct GNUNET_MESH_PeerControl { 114struct GNUNET_MESH_PeerControl {
82 115
83 /** 116 /**
84 * Type: GNUNET_MESSAGE_TYPE_MESH_LOCAL_CONNECT_PEER_[ADD|DEL] (client to service, client created tunnel) 117 * Type: GNUNET_MESSAGE_TYPE_MESH_LOCAL_CONNECT_PEER_[ADD|DEL]
85 * Type: GNUNET_MESSAGE_TYPE_MESH_LOCAL_TUNNEL_NOTIFY[CONNECT|DISCONNECT] (service to client) 118 * (client to service, client created tunnel)
119 * GNUNET_MESSAGE_TYPE_MESH_LOCAL_TUNNEL_NOTIFY[CONNECT|DISCONNECT]
120 * (service to client)
86 * 121 *
87 * Size: sizeof(struct GNUNET_MESH_PeerControl) 122 * Size: sizeof(struct GNUNET_MESH_PeerControl)
88 */ 123 */
89 struct GNUNET_MessageHeader header; 124 struct GNUNET_MessageHeader header;
90 125
91 /** 126 /**
92 * ID of a tunnel controlled by this client. 127 * ID of a tunnel controlled by this client.
93 */ 128 */
94 uint32_t tunnel_id GNUNET_PACKED; 129 MESH_TunnelID tunnel_id GNUNET_PACKED;
95 130
96 /** 131 /**
97 * Peer to connect/disconnect. 132 * Peer to connect/disconnect.
98 */ 133 */
99 struct GNUNET_PeerIdentity peer; 134 struct GNUNET_PeerIdentity peer;
100}; 135};
101 136
102 137
103 138/**
104 139 * Message for connecting to peers offering a certain service.
140 */
105struct GNUNET_MESH_ConnectPeerByType { 141struct GNUNET_MESH_ConnectPeerByType {
106 /** 142 /**
107 * Type: GNUNET_MESSAGE_TYPE_MESH_LOCAL_CONNECT_PEER_BY_TYPE 143 * Type: GNUNET_MESSAGE_TYPE_MESH_LOCAL_CONNECT_PEER_BY_TYPE
@@ -111,84 +147,95 @@ struct GNUNET_MESH_ConnectPeerByType {
111 /** 147 /**
112 * ID of a tunnel controlled by this client. 148 * ID of a tunnel controlled by this client.
113 */ 149 */
114 uint32_t tunnel_id GNUNET_PACKED; 150 MESH_TunnelID tunnel_id GNUNET_PACKED;
115 151
116 /** 152 /**
117 * Type specification 153 * Type specification
118 */ 154 */
119 GNUNET_MESH_ApplicationType type; 155 GNUNET_MESH_ApplicationType type GNUNET_PACKED;
120}; 156};
121 157
122 158
159/**
160 * Message for notifying the service that the client wants to send data.
161 */
123struct GNUNET_MESH_RequestTransmitReady { 162struct GNUNET_MESH_RequestTransmitReady {
124 /** 163 /**
125 * Type: GNUNET_MESSAGE_TYPE_MESH_LOCAL_REQUEST_TRANSMIT_READY 164 * Type: GNUNET_MESSAGE_TYPE_MESH_LOCAL_REQUEST_TRANSMIT_READY
126 */ 165 */
127 struct GNUNET_MessageHeader header; 166 struct GNUNET_MessageHeader header;
128 167
129 /** 168 /**
130 * ID of a tunnel controlled by this client. 169 * ID of a tunnel controlled by this client.
131 */ 170 */
132 uint32_t tunnel_id GNUNET_PACKED; 171 MESH_TunnelID tunnel_id GNUNET_PACKED;
133 172
134 /** 173 /**
135 * Size of message we would like to transmit to this tunnel 174 * Size of message we would like to transmit to this tunnel
136 */ 175 */
137 uint32_t msg_size GNUNET_PACKED; 176 uint32_t msg_size GNUNET_PACKED;
138}; 177};
139 178
179
180/**
181 * Message for letting a client know that the service is ready to accept data
182 * for transmission.
183 */
140struct GNUNET_MESH_NotifyTransmitReady { 184struct GNUNET_MESH_NotifyTransmitReady {
141 /** 185 /**
142 * Type: GNUNET_MESSAGE_TYPE_MESH_LOCAL_NOTIFY_TRANSMIT_READY 186 * Type: GNUNET_MESSAGE_TYPE_MESH_LOCAL_NOTIFY_TRANSMIT_READY
143 */ 187 */
144 struct GNUNET_MessageHeader header; 188 struct GNUNET_MessageHeader header;
145 189
146 /** 190 /**
147 * ID of a tunnel controlled by this client. 191 * ID of a tunnel controlled by this client.
148 */ 192 */
149 uint32_t tunnel_id GNUNET_PACKED; 193 MESH_TunnelID tunnel_id GNUNET_PACKED;
150 194
151 /** 195 /**
152 * Size of message we can now transmit to this tunnel 196 * Size of message we can now transmit to this tunnel
153 */ 197 */
154 uint32_t msg_size GNUNET_PACKED; 198 uint32_t msg_size GNUNET_PACKED;
155}; 199};
156 200
157 201
202/**
203 * Message to encapsulate data transmitted to/from the service
204 */
158struct GNUNET_MESH_Data { 205struct GNUNET_MESH_Data {
159 /** 206 /**
160 * Type: GNUNET_MESSAGE_TYPE_MESH_LOCAL_DATA (client to service, or service to client) 207 * Type: GNUNET_MESSAGE_TYPE_MESH_LOCAL_DATA (client to service, or service to client)
161 *
162 * Size: sizeof(struct GNUNET_MESH_Data) + sizeof (data) 208 * Size: sizeof(struct GNUNET_MESH_Data) + sizeof (data)
163 */ 209 */
164 struct GNUNET_MessageHeader header; 210 struct GNUNET_MessageHeader header;
165 211
166 /** 212 /**
167 * ID of a tunnel controlled by this client. 213 * ID of a tunnel controlled by this client.
168 */ 214 */
169 uint32_t tunnel_id GNUNET_PACKED; 215 MESH_TunnelID tunnel_id GNUNET_PACKED;
170 216
171 /** 217 /**
172 * Source or destination of the message (depending on direction). 218 * Source or destination of the message (depending on direction).
173 */ 219 */
174 struct GNUNET_PeerIdentity destination; 220 struct GNUNET_PeerIdentity peer_id;
175 221
176 /* uint8_t data[] */ 222 /* uint8_t data[] */
177}; 223};
178 224
179 225/**
226 * Message to encapsulate broadcast data transmitted to the service
227 */
180struct GNUNET_MESH_DataBroadcast { 228struct GNUNET_MESH_DataBroadcast {
181 /** 229 /**
182 * Type: GNUNET_MESSAGE_TYPE_MESH_LOCAL_DATA_BROADCAST (client to service only, client created tunnel) 230 * Type: GNUNET_MESSAGE_TYPE_MESH_LOCAL_DATA_BROADCAST (client to service only, client created tunnel)
183 *
184 * Size: sizeof(struct GNUNET_MESH_DataBroadcast) + sizeof (data) 231 * Size: sizeof(struct GNUNET_MESH_DataBroadcast) + sizeof (data)
185 */ 232 */
186 struct GNUNET_MessageHeader header; 233 struct GNUNET_MessageHeader header;
187 234
188 /** 235 /**
189 * ID of a tunnel controlled by this client. 236 * ID of a tunnel controlled by this client.
190 */ 237 */
191 uint32_t tunnel_id GNUNET_PACKED; 238 MESH_TunnelID tunnel_id GNUNET_PACKED;
192 239
193 /* uint8_t data[] */ 240 /* uint8_t data[] */
194}; 241};