aboutsummaryrefslogtreecommitdiff
path: root/src/cadet/cadet_common.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/cadet/cadet_common.c')
-rw-r--r--src/cadet/cadet_common.c61
1 files changed, 24 insertions, 37 deletions
diff --git a/src/cadet/cadet_common.c b/src/cadet/cadet_common.c
index a9d9a35be..95a3144e4 100644
--- a/src/cadet/cadet_common.c
+++ b/src/cadet/cadet_common.c
@@ -51,11 +51,20 @@ GC_f2s (int fwd)
51 } 51 }
52} 52}
53 53
54
55/**
56 * Test if @a bigger is larger than @a smaller.
57 * Considers the case that @a bigger just overflowed
58 * and is thus tiny while @a smaller is still below
59 * `UINT32_MAX`.
60 */
54int 61int
55GC_is_pid_bigger (uint32_t bigger, uint32_t smaller) 62GC_is_pid_bigger (uint32_t bigger,
63 uint32_t smaller)
56{ 64{
57 return (GNUNET_YES == PID_OVERFLOW (smaller, bigger) || 65 return (PID_OVERFLOW (smaller, bigger) ||
58 (bigger > smaller && GNUNET_NO == PID_OVERFLOW (bigger, smaller))); 66 ( (bigger > smaller) &&
67 (! PID_OVERFLOW (bigger, smaller))) );
59} 68}
60 69
61 70
@@ -77,28 +86,6 @@ GC_min_pid (uint32_t a, uint32_t b)
77} 86}
78 87
79 88
80const struct GNUNET_HashCode *
81GC_h2hc (const struct GNUNET_CADET_Hash *id)
82{
83 static struct GNUNET_HashCode hc;
84 GNUNET_memcpy (&hc, id, sizeof (*id));
85
86 return &hc;
87}
88
89
90const char *
91GC_h2s (const struct GNUNET_CADET_Hash *id)
92{
93 static char s[53];
94
95 GNUNET_memcpy (s, GNUNET_h2s_full (GC_h2hc (id)), 52);
96 s[52] = '\0';
97
98 return s;
99}
100
101
102/** 89/**
103 * Allocate a string with a hexdump of any binary data. 90 * Allocate a string with a hexdump of any binary data.
104 * 91 *
@@ -159,7 +146,7 @@ GC_m2s (uint16_t m)
159 /** 146 /**
160 * Request the modification of an existing path 147 * Request the modification of an existing path
161 */ 148 */
162 case GNUNET_MESSAGE_TYPE_CADET_CONNECTION_ACK: 149 case GNUNET_MESSAGE_TYPE_CADET_CONNECTION_CREATE_ACK:
163 s = "CONN_ACK"; 150 s = "CONN_ACK";
164 break; 151 break;
165 152
@@ -173,35 +160,35 @@ GC_m2s (uint16_t m)
173 /** 160 /**
174 * At some point, the route will spontaneously change 161 * At some point, the route will spontaneously change
175 */ 162 */
176 case GNUNET_MESSAGE_TYPE_CADET_PATH_CHANGED: 163 case GNUNET_MESSAGE_TYPE_CADET_CONNECTION_PATH_CHANGED_UNIMPLEMENTED:
177 s = "PATH_CHNGD"; 164 s = "PATH_CHNGD";
178 break; 165 break;
179 166
180 /** 167 /**
181 * Transport payload data. 168 * Transport payload data.
182 */ 169 */
183 case GNUNET_MESSAGE_TYPE_CADET_DATA: 170 case GNUNET_MESSAGE_TYPE_CADET_CHANNEL_APP_DATA:
184 s = "DATA"; 171 s = "DATA";
185 break; 172 break;
186 173
187 /** 174 /**
188 * Confirm receipt of payload data. 175 * Confirm receipt of payload data.
189 */ 176 */
190 case GNUNET_MESSAGE_TYPE_CADET_DATA_ACK: 177 case GNUNET_MESSAGE_TYPE_CADET_CHANNEL_APP_DATA_ACK:
191 s = "DATA_ACK"; 178 s = "DATA_ACK";
192 break; 179 break;
193 180
194 /** 181 /**
195 * Key exchange message. 182 * Key exchange message.
196 */ 183 */
197 case GNUNET_MESSAGE_TYPE_CADET_KX: 184 case GNUNET_MESSAGE_TYPE_CADET_TUNNEL_KX:
198 s = "KX"; 185 s = "KX";
199 break; 186 break;
200 187
201 /** 188 /**
202 * Encrypted. 189 * Encrypted.
203 */ 190 */
204 case GNUNET_MESSAGE_TYPE_CADET_ENCRYPTED: 191 case GNUNET_MESSAGE_TYPE_CADET_TUNNEL_ENCRYPTED:
205 s = "ENCRYPTED"; 192 s = "ENCRYPTED";
206 break; 193 break;
207 194
@@ -215,21 +202,21 @@ GC_m2s (uint16_t m)
215 /** 202 /**
216 * ACK for a data packet. 203 * ACK for a data packet.
217 */ 204 */
218 case GNUNET_MESSAGE_TYPE_CADET_ACK: 205 case GNUNET_MESSAGE_TYPE_CADET_CONNECTION_HOP_BY_HOP_ENCRYPTED_ACK:
219 s = "ACK"; 206 s = "ACK";
220 break; 207 break;
221 208
222 /** 209 /**
223 * POLL for ACK. 210 * POLL for ACK.
224 */ 211 */
225 case GNUNET_MESSAGE_TYPE_CADET_POLL: 212 case GNUNET_MESSAGE_TYPE_CADET_TUNNEL_ENCRYPTED_POLL:
226 s = "POLL"; 213 s = "POLL";
227 break; 214 break;
228 215
229 /** 216 /**
230 * Announce origin is still alive. 217 * Announce origin is still alive.
231 */ 218 */
232 case GNUNET_MESSAGE_TYPE_CADET_KEEPALIVE: 219 case GNUNET_MESSAGE_TYPE_CADET_CHANNEL_KEEPALIVE:
233 s = "KEEPALIVE"; 220 s = "KEEPALIVE";
234 break; 221 break;
235 222
@@ -250,7 +237,7 @@ GC_m2s (uint16_t m)
250 /** 237 /**
251 * Ask the cadet service to create a new tunnel 238 * Ask the cadet service to create a new tunnel
252 */ 239 */
253 case GNUNET_MESSAGE_TYPE_CADET_CHANNEL_CREATE: 240 case GNUNET_MESSAGE_TYPE_CADET_CHANNEL_OPEN:
254 s = "CHAN_CREAT"; 241 s = "CHAN_CREAT";
255 break; 242 break;
256 243
@@ -264,14 +251,14 @@ GC_m2s (uint16_t m)
264 /** 251 /**
265 * Confirm the creation of a channel. 252 * Confirm the creation of a channel.
266 */ 253 */
267 case GNUNET_MESSAGE_TYPE_CADET_CHANNEL_ACK: 254 case GNUNET_MESSAGE_TYPE_CADET_CHANNEL_OPEN_ACK:
268 s = "CHAN_ACK"; 255 s = "CHAN_ACK";
269 break; 256 break;
270 257
271 /** 258 /**
272 * Confirm the creation of a channel. 259 * Confirm the creation of a channel.
273 */ 260 */
274 case GNUNET_MESSAGE_TYPE_CADET_CHANNEL_NACK: 261 case GNUNET_MESSAGE_TYPE_CADET_CHANNEL_OPEN_NACK_DEPRECATED:
275 s = "CHAN_NACK"; 262 s = "CHAN_NACK";
276 break; 263 break;
277 264