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 #if !defined(GNUNET_CULL_LOGGING)
90 * Request the creation of a path
92 case GNUNET_MESSAGE_TYPE_MESH_CONNECTION_CREATE:
93 t = "CONNECTION_CREATE";
97 * Request the modification of an existing path
99 case GNUNET_MESSAGE_TYPE_MESH_CONNECTION_ACK:
100 t = "CONNECTION_ACK";
104 * Notify that a connection of a path is no longer valid
106 case GNUNET_MESSAGE_TYPE_MESH_CONNECTION_BROKEN:
107 t = "CONNECTION_BROKEN";
111 * At some point, the route will spontaneously change
113 case GNUNET_MESSAGE_TYPE_MESH_PATH_CHANGED:
118 * Transport payload data.
120 case GNUNET_MESSAGE_TYPE_MESH_DATA:
125 * Confirm receipt of payload data.
127 case GNUNET_MESSAGE_TYPE_MESH_DATA_ACK:
132 * Key exchange encapsulation.
134 case GNUNET_MESSAGE_TYPE_MESH_KX:
141 case GNUNET_MESSAGE_TYPE_MESH_KX_EPHEMERAL:
146 * Challenge to test peer's session key.
148 case GNUNET_MESSAGE_TYPE_MESH_KX_PING:
153 * Answer to session key challenge.
155 case GNUNET_MESSAGE_TYPE_MESH_KX_PONG:
160 * Request the destuction of a path
162 case GNUNET_MESSAGE_TYPE_MESH_CONNECTION_DESTROY:
163 t = "CONNECTION_DESTROY";
167 * ACK for a data packet.
169 case GNUNET_MESSAGE_TYPE_MESH_ACK:
176 case GNUNET_MESSAGE_TYPE_MESH_POLL:
181 * Announce origin is still alive.
183 case GNUNET_MESSAGE_TYPE_MESH_KEEPALIVE:
188 * Connect to the mesh service, specifying subscriptions
190 case GNUNET_MESSAGE_TYPE_MESH_LOCAL_CONNECT:
195 * Ask the mesh service to create a new tunnel
197 case GNUNET_MESSAGE_TYPE_MESH_CHANNEL_CREATE:
198 t = "CHANNEL_CREATE";
202 * Ask the mesh service to destroy a tunnel
204 case GNUNET_MESSAGE_TYPE_MESH_CHANNEL_DESTROY:
205 t = "CHANNEL_DESTROY";
209 * Confirm the creation of a channel.
211 case GNUNET_MESSAGE_TYPE_MESH_CHANNEL_ACK:
216 * Confirm the creation of a channel.
218 case GNUNET_MESSAGE_TYPE_MESH_CHANNEL_NACK:
225 case GNUNET_MESSAGE_TYPE_MESH_ENCRYPTED:
230 * Local payload traffic
232 case GNUNET_MESSAGE_TYPE_MESH_LOCAL_DATA:
237 * Local ACK for data.
239 case GNUNET_MESSAGE_TYPE_MESH_LOCAL_ACK:
244 * Local monitoring of channels.
246 case GNUNET_MESSAGE_TYPE_MESH_LOCAL_INFO_CHANNELS:
247 t = "LOCAL_INFO_CHANNELS";
251 * Local monitoring of a channel.
253 case GNUNET_MESSAGE_TYPE_MESH_LOCAL_INFO_CHANNEL:
254 t = "LOCAL_INFO_CHANNEL";
258 * Local monitoring of service.
260 case GNUNET_MESSAGE_TYPE_MESH_LOCAL_INFO_TUNNELS:
261 t = "LOCAL_INFO_TUNNELS";
265 * Local monitoring of service.
267 case GNUNET_MESSAGE_TYPE_MESH_LOCAL_INFO_TUNNEL:
268 t = "LOCAL_INFO_TUNNEL";
272 * Local information about all connections of service.
274 case GNUNET_MESSAGE_TYPE_MESH_LOCAL_INFO_CONNECTIONS:
275 t = "LOCAL_INFO_CONNECTIONS";
279 * Local information of service about a specific connection.
281 case GNUNET_MESSAGE_TYPE_MESH_LOCAL_INFO_CONNECTION:
282 t = "LOCAL_INFO_CONNECTION";
286 * Local information about all peers known to the service.
288 case GNUNET_MESSAGE_TYPE_MESH_LOCAL_INFO_PEERS:
289 t = "LOCAL_INFO_PEERS";
293 * Local information of service about a specific peer.
295 case GNUNET_MESSAGE_TYPE_MESH_LOCAL_INFO_PEER:
296 t = "LOCAL_INFO_PEER";
300 * Traffic (net-cat style) used by the Command Line Interface.
302 case GNUNET_MESSAGE_TYPE_MESH_CLI:
307 * 640kb should be enough for everybody
314 sprintf(buf, "%u (UNKNOWN TYPE)", m);
317 sprintf(buf, "%31s", t);