2 This file is part of GNUnet.
3 (C) 2001 - 2011 Christian Grothoff (and other contributing authors)
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.
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.
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.
22 * @author Bartlomiej Polot
32 #if 0 /* keep Emacsens' auto-indent happy */
39 #define MESH_DEBUG GNUNET_YES
42 #include "gnunet_util_lib.h"
43 #include "gnunet_peer_lib.h"
44 #include "gnunet_core_service.h"
45 #include "gnunet_protocols.h"
46 #include <gnunet_mesh_service.h>
48 /******************************************************************************/
49 /************************** CONSTANTS ******************************/
50 /******************************************************************************/
52 #define GNUNET_MESH_LOCAL_CHANNEL_ID_CLI 0x80000000
53 #define GNUNET_MESH_LOCAL_CHANNEL_ID_SERV 0xB0000000
55 #define HIGH_PID 0xFFFF0000
56 #define LOW_PID 0x0000FFFF
58 #define PID_OVERFLOW(pid, max) (pid > HIGH_PID && max < LOW_PID)
60 /******************************************************************************/
61 /************************** MESSAGES ******************************/
62 /******************************************************************************/
64 GNUNET_NETWORK_STRUCT_BEGIN
67 * Message for a client to register to the service
69 struct GNUNET_MESH_ClientConnect
72 * Type: GNUNET_MESSAGE_TYPE_MESH_LOCAL_CONNECT
74 * Size: sizeof(struct GNUNET_MESH_ClientConnect) +
75 * sizeof(MESH_ApplicationType) * applications +
76 * sizeof(uint16_t) * types
78 struct GNUNET_MessageHeader header;
79 /* uint32_t list_ports[] */
84 * Type for channel numbering.
85 * - Local channel numbers given by the service (incoming) are >= 0xB0000000
86 * - Local channel numbers given by the client (created) are >= 0x80000000
87 * - Global channel numbers are < 0x80000000
89 typedef uint32_t MESH_ChannelNumber;
93 * Message for a client to create and destroy channels.
95 struct GNUNET_MESH_ChannelMessage
98 * Type: GNUNET_MESSAGE_TYPE_MESH_LOCAL_TUNNEL_[CREATE|DESTROY]
100 * Size: sizeof(struct GNUNET_MESH_ChannelMessage)
102 struct GNUNET_MessageHeader header;
105 * ID of a channel controlled by this client.
107 MESH_ChannelNumber channel_id GNUNET_PACKED;
112 struct GNUNET_PeerIdentity peer;
115 * Port of the channel.
117 uint32_t port GNUNET_PACKED;
122 uint32_t opt GNUNET_PACKED;
127 * Message for mesh data traffic.
129 struct GNUNET_MESH_LocalData
132 * Type: GNUNET_MESSAGE_TYPE_MESH_LOCAL_DATA
134 struct GNUNET_MessageHeader header;
139 uint32_t id GNUNET_PACKED;
148 * Message to allow the client send more data to the service
149 * (always service -> client).
151 struct GNUNET_MESH_LocalAck
154 * Type: GNUNET_MESSAGE_TYPE_MESH_LOCAL_ACK
156 struct GNUNET_MessageHeader header;
159 * ID of the channel allowed to send more data.
161 MESH_ChannelNumber channel_id GNUNET_PACKED;
167 * Message to inform the client about channels in the service.
169 struct GNUNET_MESH_LocalInfo
172 * Type: GNUNET_MESSAGE_TYPE_MESH_LOCAL_INFO[_TUNNEL]
174 struct GNUNET_MessageHeader header;
177 * ID of the channel allowed to send more data.
179 MESH_ChannelNumber channel_id GNUNET_PACKED;
184 uint32_t reserved GNUNET_PACKED;
187 * ID of the owner of the channel (can be local peer).
189 struct GNUNET_PeerIdentity owner;
192 * ID of the destination of the channel (can be local peer).
194 struct GNUNET_PeerIdentity destination;
198 GNUNET_NETWORK_STRUCT_END
203 * @brief Translate a fwd variable into a string representation, for logging.
205 * @param fwd Is FWD? (#GNUNET_YES or #GNUNET_NO)
207 * @return String representing FWD or BCK.
214 * Check if one pid is bigger than other, accounting for overflow.
216 * @param bigger Argument that should be bigger.
217 * @param smaller Argument that should be smaller.
219 * @return True if bigger (arg1) has a higher value than smaller (arg 2).
222 GM_is_pid_bigger (uint32_t bigger, uint32_t smaller);
226 * Get the higher ACK value out of two values, taking in account overflow.
228 * @param a First ACK value.
229 * @param b Second ACK value.
231 * @return Highest ACK value from the two.
234 GM_max_pid (uint32_t a, uint32_t b);
238 * Get the lower ACK value out of two values, taking in account overflow.
240 * @param a First ACK value.
241 * @param b Second ACK value.
243 * @return Lowest ACK value from the two.
246 GM_min_pid (uint32_t a, uint32_t b);
250 * Convert a message type into a string to help debug
252 * FIND: "#define ([^ ]+)[ ]*([0-9]+)"
253 * REPLACE: " case \2: return "\1"; break;"
255 * @param m Message type.
257 * @return Human readable string description.
262 #if 0 /* keep Emacsens' auto-indent happy */