aboutsummaryrefslogtreecommitdiff
path: root/src/mesh/mesh_enc.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/mesh/mesh_enc.h')
-rw-r--r--src/mesh/mesh_enc.h259
1 files changed, 0 insertions, 259 deletions
diff --git a/src/mesh/mesh_enc.h b/src/mesh/mesh_enc.h
deleted file mode 100644
index 93a3a2e9e..000000000
--- a/src/mesh/mesh_enc.h
+++ /dev/null
@@ -1,259 +0,0 @@
1/*
2 This file is part of GNUnet.
3 (C) 2001 - 2011 Christian Grothoff (and other contributing authors)
4
5 GNUnet is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published
7 by the Free Software Foundation; either version 3, or (at your
8 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 General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with GNUnet; see the file COPYING. If not, write to the
17 Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA.
19*/
20
21/**
22 * @author Bartlomiej Polot
23 * @file mesh/mesh_enc.h
24 */
25
26#ifndef MESH_H_
27#define MESH_H_
28
29#ifdef __cplusplus
30extern "C"
31{
32#if 0 /* keep Emacsens' auto-indent happy */
33}
34#endif
35#endif
36
37#include <stdint.h>
38
39#define MESH_DEBUG GNUNET_YES
40
41#include "platform.h"
42#include "gnunet_common.h"
43#include "gnunet_util_lib.h"
44#include "gnunet_peer_lib.h"
45#include "gnunet_core_service.h"
46#include "gnunet_protocols.h"
47#include <gnunet_mesh_service.h>
48
49/******************************************************************************/
50/************************** CONSTANTS ******************************/
51/******************************************************************************/
52
53#define GNUNET_MESH_LOCAL_CHANNEL_ID_CLI 0x80000000
54#define GNUNET_MESH_LOCAL_CHANNEL_ID_SERV 0xB0000000
55
56#define HIGH_PID 0xFFFF0000
57#define LOW_PID 0x0000FFFF
58
59#define PID_OVERFLOW(pid, max) (pid > HIGH_PID && max < LOW_PID)
60
61/******************************************************************************/
62/************************** MESSAGES ******************************/
63/******************************************************************************/
64
65GNUNET_NETWORK_STRUCT_BEGIN
66
67/**
68 * Message for a client to register to the service
69 */
70struct GNUNET_MESH_ClientConnect
71{
72 /**
73 * Type: GNUNET_MESSAGE_TYPE_MESH_LOCAL_CONNECT
74 *
75 * Size: sizeof(struct GNUNET_MESH_ClientConnect) +
76 * sizeof(MESH_ApplicationType) * applications +
77 * sizeof(uint16_t) * types
78 */
79 struct GNUNET_MessageHeader header;
80 /* uint32_t list_ports[] */
81};
82
83
84/**
85 * Type for channel numbering.
86 * - Local channel numbers given by the service (incoming) are >= 0xB0000000
87 * - Local channel numbers given by the client (created) are >= 0x80000000
88 * - Global channel numbers are < 0x80000000
89 */
90typedef uint32_t MESH_ChannelNumber;
91
92
93/**
94 * Message for a client to create and destroy channels.
95 */
96struct GNUNET_MESH_ChannelMessage
97{
98 /**
99 * Type: GNUNET_MESSAGE_TYPE_MESH_LOCAL_TUNNEL_[CREATE|DESTROY]
100 *
101 * Size: sizeof(struct GNUNET_MESH_ChannelMessage)
102 */
103 struct GNUNET_MessageHeader header;
104
105 /**
106 * ID of a channel controlled by this client.
107 */
108 MESH_ChannelNumber channel_id GNUNET_PACKED;
109
110 /**
111 * Channel's peer
112 */
113 struct GNUNET_PeerIdentity peer;
114
115 /**
116 * Port of the channel.
117 */
118 uint32_t port GNUNET_PACKED;
119
120 /**
121 * Options.
122 */
123 uint32_t opt GNUNET_PACKED;
124};
125
126
127/**
128 * Message for mesh data traffic.
129 */
130struct GNUNET_MESH_LocalData
131{
132 /**
133 * Type: GNUNET_MESSAGE_TYPE_MESH_LOCAL_DATA
134 */
135 struct GNUNET_MessageHeader header;
136
137 /**
138 * ID of the channel
139 */
140 uint32_t id GNUNET_PACKED;
141
142 /**
143 * Payload follows
144 */
145};
146
147
148/**
149 * Message to allow the client send more data to the service
150 * (always service -> client).
151 */
152struct GNUNET_MESH_LocalAck
153{
154 /**
155 * Type: GNUNET_MESSAGE_TYPE_MESH_LOCAL_ACK
156 */
157 struct GNUNET_MessageHeader header;
158
159 /**
160 * ID of the channel allowed to send more data.
161 */
162 MESH_ChannelNumber channel_id GNUNET_PACKED;
163
164};
165
166
167/**
168 * Message to inform the client about channels in the service.
169 */
170struct GNUNET_MESH_LocalMonitor
171{
172 /**
173 * Type: GNUNET_MESSAGE_TYPE_MESH_LOCAL_MONITOR[_TUNNEL]
174 */
175 struct GNUNET_MessageHeader header;
176
177 /**
178 * ID of the channel allowed to send more data.
179 */
180 MESH_ChannelNumber channel_id GNUNET_PACKED;
181
182 /**
183 * Alignment.
184 */
185 uint32_t reserved GNUNET_PACKED;
186
187 /**
188 * ID of the owner of the channel (can be local peer).
189 */
190 struct GNUNET_PeerIdentity owner;
191
192 /**
193 * ID of the destination of the channel (can be local peer).
194 */
195 struct GNUNET_PeerIdentity destination;
196};
197
198
199GNUNET_NETWORK_STRUCT_END
200
201
202
203/**
204 * Check if one pid is bigger than other, accounting for overflow.
205 *
206 * @param bigger Argument that should be bigger.
207 * @param smaller Argument that should be smaller.
208 *
209 * @return True if bigger (arg1) has a higher value than smaller (arg 2).
210 */
211int
212GMC_is_pid_bigger (uint32_t bigger, uint32_t smaller);
213
214
215/**
216 * Get the higher ACK value out of two values, taking in account overflow.
217 *
218 * @param a First ACK value.
219 * @param b Second ACK value.
220 *
221 * @return Highest ACK value from the two.
222 */
223uint32_t
224GMC_max_pid (uint32_t a, uint32_t b);
225
226
227/**
228 * Get the lower ACK value out of two values, taking in account overflow.
229 *
230 * @param a First ACK value.
231 * @param b Second ACK value.
232 *
233 * @return Lowest ACK value from the two.
234 */
235uint32_t
236GMC_min_pid (uint32_t a, uint32_t b);
237
238
239/**
240 * Convert a message type into a string to help debug
241 * Generated with:
242 * FIND: "#define ([^ ]+)[ ]*([0-9]+)"
243 * REPLACE: " case \2: return "\1"; break;"
244 *
245 * @param m Message type.
246 *
247 * @return Human readable string description.
248 */
249const char *
250GNUNET_MESH_DEBUG_M2S (uint16_t m);
251
252#if 0 /* keep Emacsens' auto-indent happy */
253{
254#endif
255#ifdef __cplusplus
256}
257#endif
258
259#endif