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
31 * Check if one pid is bigger than other, accounting for overflow.
33 * @param bigger Argument that should be bigger.
34 * @param smaller Argument that should be smaller.
36 * @return True if bigger (arg1) has a higher value than smaller (arg 2).
39 GMC_is_pid_bigger (uint32_t bigger, uint32_t smaller)
41 return (GNUNET_YES == PID_OVERFLOW(smaller, bigger) ||
42 (bigger > smaller && GNUNET_NO == PID_OVERFLOW(bigger, smaller)));
46 * Get the higher ACK value out of two values, taking in account overflow.
48 * @param a First ACK value.
49 * @param b Second ACK value.
51 * @return Highest ACK value from the two.
54 GMC_max_pid (uint32_t a, uint32_t b)
56 if (GMC_is_pid_bigger(a, b))
63 * Get the lower ACK value out of two values, taking in account overflow.
65 * @param a First ACK value.
66 * @param b Second ACK value.
68 * @return Lowest ACK value from the two.
71 GMC_min_pid (uint32_t a, uint32_t b)
73 if (GMC_is_pid_bigger(a, b))
79 #if !defined(GNUNET_CULL_LOGGING)
81 GNUNET_MESH_DEBUG_M2S (uint16_t m)
87 * Request the creation of a path
89 case 256: return "GNUNET_MESSAGE_TYPE_MESH_PATH_CREATE";
92 * Request the modification of an existing path
94 case 257: return "GNUNET_MESSAGE_TYPE_MESH_PATH_CHANGE";
97 * Notify that a connection of a path is no longer valid
99 case 258: return "GNUNET_MESSAGE_TYPE_MESH_PATH_BROKEN";
102 * At some point, the route will spontaneously change
104 case 259: return "GNUNET_MESSAGE_TYPE_MESH_PATH_CHANGED";
107 * Transport data in the mesh (origin->end) unicast
109 case 260: return "GNUNET_MESSAGE_TYPE_MESH_UNICAST";
112 * Transport data to all peers in a tunnel
114 case 261: return "GNUNET_MESSAGE_TYPE_MESH_MULTICAST";
117 * Transport data back in the mesh (end->origin)
119 case 262: return "GNUNET_MESSAGE_TYPE_MESH_TO_ORIGIN";
122 * Send origin an ACK that the path is complete
124 case 263: return "GNUNET_MESSAGE_TYPE_MESH_PATH_ACK";
127 * Avoid path timeouts
129 case 264: return "GNUNET_MESSAGE_TYPE_MESH_PATH_KEEPALIVE";
132 * Request the destuction of a path
134 case 265: return "GNUNET_MESSAGE_TYPE_MESH_PATH_DESTROY";
137 * Request the destruction of a whole tunnel
139 case 266: return "GNUNET_MESSAGE_TYPE_MESH_TUNNEL_DESTROY";
142 * ACK for a data packet.
144 case 267: return "GNUNET_MESSAGE_TYPE_MESH_ACK";
149 case 268: return "GNUNET_MESSAGE_TYPE_MESH_POLL";
152 * Connect to the mesh service, specifying subscriptions
154 case 272: return "GNUNET_MESSAGE_TYPE_MESH_LOCAL_CONNECT";
157 * Ask the mesh service to create a new tunnel
159 case 273: return "GNUNET_MESSAGE_TYPE_MESH_LOCAL_TUNNEL_CREATE";
162 * Ask the mesh service to destroy a tunnel
164 case 274: return "GNUNET_MESSAGE_TYPE_MESH_LOCAL_TUNNEL_DESTROY";
167 * Ask the mesh service to add a peer to an existing tunnel
169 case 275: return "GNUNET_MESSAGE_TYPE_MESH_LOCAL_PEER_ADD";
172 * Ask the mesh service to remove a peer from a tunnel
174 case 276: return "GNUNET_MESSAGE_TYPE_MESH_LOCAL_PEER_DEL";
177 * Ask the mesh service to add a peer offering a service to an existing tunnel
179 case 277: return "GNUNET_MESSAGE_TYPE_MESH_LOCAL_PEER_ADD_BY_TYPE";
182 * Ask the mesh service to add a peer described by a service string
184 case 278: return "GNUNET_MESSAGE_TYPE_MESH_LOCAL_ANNOUNCE_REGEX";
187 * Ask the mesh service to add a peer described by a service string
189 case 279: return "GNUNET_MESSAGE_TYPE_MESH_LOCAL_PEER_ADD_BY_STRING";
192 * Ask the mesh service to add a peer to the blacklist of an existing tunnel
194 case 280: return "GNUNET_MESSAGE_TYPE_MESH_LOCAL_PEER_BLACKLIST";
197 * Ask the mesh service to remove a peer from the blacklist of a tunnel
199 case 281: return "GNUNET_MESSAGE_TYPE_MESH_LOCAL_PEER_UNBLACKLIST";
202 * Set tunnel speed to slowest peer
204 case 282: return "GNUNET_MESSAGE_TYPE_MESH_LOCAL_TUNNEL_MIN";
207 * Set tunnel speed to fastest peer
209 case 283: return "GNUNET_MESSAGE_TYPE_MESH_LOCAL_TUNNEL_MAX";
212 * Set tunnel buffering on.
214 case 284: return "GNUNET_MESSAGE_TYPE_MESH_LOCAL_TUNNEL_BUFFER";
217 * Set tunnel buffering off.
219 case 285: return "GNUNET_MESSAGE_TYPE_MESH_LOCAL_TUNNEL_NOBUFFER";
222 * Local ACK for data.
224 case 286: return "GNUNET_MESSAGE_TYPE_MESH_LOCAL_ACK";
227 * Local monitoring of service.
229 case 287: return "GNUNET_MESSAGE_TYPE_MESH_LOCAL_MONITOR";
232 * Local monitoring of service of a specific tunnel.
234 case 288: return "GNUNET_MESSAGE_TYPE_MESH_LOCAL_MONITOR_TUNNEL";
237 * 640kb should be enough for everybody
239 case 299: return "GNUNET_MESSAGE_TYPE_MESH_RESERVE_END";
241 sprintf(buf, "%u (UNKNOWN TYPE)", m);
246 GNUNET_MESH_DEBUG_M2S (uint16_t m)