2 This file is part of GNUnet.
3 (C) 2012 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 * @file mesh/mesh_common.c
23 * @brief MESH helper functions
24 * @author Bartlomiej Polot
30 * @brief Translate a fwd variable into a string representation, for logging.
32 * @param fwd Is FWD? (#GNUNET_YES or #GNUNET_NO)
34 * @return String representing FWD or BCK.
39 if (GNUNET_YES == fwd)
43 else if (GNUNET_NO == fwd)
55 GM_is_pid_bigger (uint32_t bigger, uint32_t smaller)
57 return (GNUNET_YES == PID_OVERFLOW (smaller, bigger) ||
58 (bigger > smaller && GNUNET_NO == PID_OVERFLOW (bigger, smaller)));
63 GM_max_pid (uint32_t a, uint32_t b)
65 if (GM_is_pid_bigger(a, b))
72 GM_min_pid (uint32_t a, uint32_t b)
74 if (GM_is_pid_bigger(a, b))
80 const struct GNUNET_HashCode *
81 GM_h2hc (const struct GNUNET_MeshHash *id)
83 static struct GNUNET_HashCode hc;
84 memcpy (&hc, id, sizeof (*id));
90 #if !defined(GNUNET_CULL_LOGGING)
100 * Request the creation of a path
102 case GNUNET_MESSAGE_TYPE_MESH_CONNECTION_CREATE:
103 t = "CONNECTION_CREATE";
107 * Request the modification of an existing path
109 case GNUNET_MESSAGE_TYPE_MESH_CONNECTION_ACK:
110 t = "CONNECTION_ACK";
114 * Notify that a connection of a path is no longer valid
116 case GNUNET_MESSAGE_TYPE_MESH_CONNECTION_BROKEN:
117 t = "CONNECTION_BROKEN";
121 * At some point, the route will spontaneously change
123 case GNUNET_MESSAGE_TYPE_MESH_PATH_CHANGED:
128 * Transport payload data.
130 case GNUNET_MESSAGE_TYPE_MESH_DATA:
135 * Confirm receipt of payload data.
137 case GNUNET_MESSAGE_TYPE_MESH_DATA_ACK:
142 * Key exchange encapsulation.
144 case GNUNET_MESSAGE_TYPE_MESH_KX:
151 case GNUNET_MESSAGE_TYPE_MESH_KX_EPHEMERAL:
156 * Challenge to test peer's session key.
158 case GNUNET_MESSAGE_TYPE_MESH_KX_PING:
163 * Answer to session key challenge.
165 case GNUNET_MESSAGE_TYPE_MESH_KX_PONG:
170 * Request the destuction of a path
172 case GNUNET_MESSAGE_TYPE_MESH_CONNECTION_DESTROY:
173 t = "CONNECTION_DESTROY";
177 * ACK for a data packet.
179 case GNUNET_MESSAGE_TYPE_MESH_ACK:
186 case GNUNET_MESSAGE_TYPE_MESH_POLL:
191 * Announce origin is still alive.
193 case GNUNET_MESSAGE_TYPE_MESH_KEEPALIVE:
198 * Connect to the mesh service, specifying subscriptions
200 case GNUNET_MESSAGE_TYPE_MESH_LOCAL_CONNECT:
205 * Ask the mesh service to create a new tunnel
207 case GNUNET_MESSAGE_TYPE_MESH_CHANNEL_CREATE:
208 t = "CHANNEL_CREATE";
212 * Ask the mesh service to destroy a tunnel
214 case GNUNET_MESSAGE_TYPE_MESH_CHANNEL_DESTROY:
215 t = "CHANNEL_DESTROY";
219 * Confirm the creation of a channel.
221 case GNUNET_MESSAGE_TYPE_MESH_CHANNEL_ACK:
226 * Confirm the creation of a channel.
228 case GNUNET_MESSAGE_TYPE_MESH_CHANNEL_NACK:
235 case GNUNET_MESSAGE_TYPE_MESH_ENCRYPTED:
240 * Local payload traffic
242 case GNUNET_MESSAGE_TYPE_MESH_LOCAL_DATA:
247 * Local ACK for data.
249 case GNUNET_MESSAGE_TYPE_MESH_LOCAL_ACK:
254 * Local monitoring of channels.
256 case GNUNET_MESSAGE_TYPE_MESH_LOCAL_INFO_CHANNELS:
257 t = "LOCAL_INFO_CHANNELS";
261 * Local monitoring of a channel.
263 case GNUNET_MESSAGE_TYPE_MESH_LOCAL_INFO_CHANNEL:
264 t = "LOCAL_INFO_CHANNEL";
268 * Local monitoring of service.
270 case GNUNET_MESSAGE_TYPE_MESH_LOCAL_INFO_TUNNELS:
271 t = "LOCAL_INFO_TUNNELS";
275 * Local monitoring of service.
277 case GNUNET_MESSAGE_TYPE_MESH_LOCAL_INFO_TUNNEL:
278 t = "LOCAL_INFO_TUNNEL";
282 * Local information about all connections of service.
284 case GNUNET_MESSAGE_TYPE_MESH_LOCAL_INFO_CONNECTIONS:
285 t = "LOCAL_INFO_CONNECTIONS";
289 * Local information of service about a specific connection.
291 case GNUNET_MESSAGE_TYPE_MESH_LOCAL_INFO_CONNECTION:
292 t = "LOCAL_INFO_CONNECTION";
296 * Local information about all peers known to the service.
298 case GNUNET_MESSAGE_TYPE_MESH_LOCAL_INFO_PEERS:
299 t = "LOCAL_INFO_PEERS";
303 * Local information of service about a specific peer.
305 case GNUNET_MESSAGE_TYPE_MESH_LOCAL_INFO_PEER:
306 t = "LOCAL_INFO_PEER";
310 * Traffic (net-cat style) used by the Command Line Interface.
312 case GNUNET_MESSAGE_TYPE_MESH_CLI:
317 * 640kb should be enough for everybody
324 sprintf(buf, "%u (UNKNOWN TYPE)", m);
327 sprintf(buf, "{%22s}", t);