diff options
author | Bart Polot <bart@net.in.tum.de> | 2013-08-01 23:33:45 +0000 |
---|---|---|
committer | Bart Polot <bart@net.in.tum.de> | 2013-08-01 23:33:45 +0000 |
commit | f9a24fe44a52c45198211c283d33aeda6601c352 (patch) | |
tree | e152927a6628cba80542fb30fc245e8e7ed5cfe2 /src | |
parent | b20f6248dd60dfb02539cdff90e2c37b6cf03d6b (diff) | |
download | gnunet-f9a24fe44a52c45198211c283d33aeda6601c352.tar.gz gnunet-f9a24fe44a52c45198211c283d33aeda6601c352.zip |
- encapsulate channel traffic in tunnel message
Diffstat (limited to 'src')
-rw-r--r-- | src/mesh/gnunet-service-mesh-enc.c | 154 | ||||
-rw-r--r-- | src/mesh/mesh_protocol_enc.h | 110 |
2 files changed, 190 insertions, 74 deletions
diff --git a/src/mesh/gnunet-service-mesh-enc.c b/src/mesh/gnunet-service-mesh-enc.c index ce8cde724..8f4baf459 100644 --- a/src/mesh/gnunet-service-mesh-enc.c +++ b/src/mesh/gnunet-service-mesh-enc.c | |||
@@ -541,11 +541,16 @@ struct MeshConnection | |||
541 | struct MeshTunnel2 | 541 | struct MeshTunnel2 |
542 | { | 542 | { |
543 | /** | 543 | /** |
544 | * Tunnel ID (owner, destination) | 544 | * Endpoint of the tunnel. |
545 | */ | 545 | */ |
546 | struct MeshPeer *peer; | 546 | struct MeshPeer *peer; |
547 | 547 | ||
548 | /** | 548 | /** |
549 | * ID of the tunnel. | ||
550 | */ | ||
551 | struct GNUNET_HashCode id; | ||
552 | |||
553 | /** | ||
549 | * State of the tunnel. | 554 | * State of the tunnel. |
550 | */ | 555 | */ |
551 | enum MeshTunnelState state; | 556 | enum MeshTunnelState state; |
@@ -1385,10 +1390,51 @@ tunnel_get_connection (struct MeshTunnel2 *t, int fwd) | |||
1385 | 1390 | ||
1386 | 1391 | ||
1387 | /** | 1392 | /** |
1393 | * FIXME FIXME FIXME FIXME FIXME FIXME FIXME FIXME FIXME FIXME FIXME | ||
1394 | * Encrypt data with the tunnel key. | ||
1395 | * | ||
1396 | * @param t Tunnel whose key to use. | ||
1397 | * @param dst Destination for the encrypted data. | ||
1398 | * @param src Source of the plaintext. | ||
1399 | * @param size Size of the plaintext. | ||
1400 | * @param iv Initialization Vector to use. | ||
1401 | * @param fwd Is this a fwd message? | ||
1402 | */ | ||
1403 | static void | ||
1404 | tunnel_encrypt (struct MeshTunnel2 *t, | ||
1405 | void *dst, const void *src, | ||
1406 | size_t size, uint64_t iv, int fwd) | ||
1407 | { | ||
1408 | memcpy (dst, src, size); | ||
1409 | } | ||
1410 | |||
1411 | |||
1412 | /** | ||
1413 | * FIXME FIXME FIXME FIXME FIXME FIXME FIXME FIXME FIXME FIXME FIXME | ||
1414 | * Decrypt data with the tunnel key. | ||
1415 | * | ||
1416 | * @param t Tunnel whose key to use. | ||
1417 | * @param dst Destination for the plaintext. | ||
1418 | * @param src Source of the encrypted data. | ||
1419 | * @param size Size of the encrypted data. | ||
1420 | * @param iv Initialization Vector to use. | ||
1421 | * @param fwd Is this a fwd message? | ||
1422 | */ | ||
1423 | static void | ||
1424 | tunnel_decrypt (struct MeshTunnel2 *t, | ||
1425 | void *dst, const void *src, | ||
1426 | size_t size, uint64_t iv, int fwd) | ||
1427 | { | ||
1428 | memcpy (dst, src, size); | ||
1429 | } | ||
1430 | |||
1431 | |||
1432 | /** | ||
1388 | * Sends an already built message on a tunnel, properly registering | 1433 | * Sends an already built message on a tunnel, properly registering |
1389 | * all used resources. | 1434 | * all used resources. |
1390 | * | 1435 | * |
1391 | * @param message Message to send. Function makes a copy of it. | 1436 | * @param message Message to send. Function makes a copy of it. |
1437 | * If message is not hop-by-hop, decrements TTL of copy. | ||
1392 | * @param c Connection on which this message is transmitted. | 1438 | * @param c Connection on which this message is transmitted. |
1393 | * @param ch Channel on which this message is transmitted. | 1439 | * @param ch Channel on which this message is transmitted. |
1394 | * @param fwd Is this a fwd message? | 1440 | * @param fwd Is this a fwd message? |
@@ -1415,13 +1461,21 @@ send_prebuilt_message_connection (const struct GNUNET_MessageHeader *message, | |||
1415 | data = GNUNET_malloc (size); | 1461 | data = GNUNET_malloc (size); |
1416 | memcpy (data, message, size); | 1462 | memcpy (data, message, size); |
1417 | type = ntohs(message->type); | 1463 | type = ntohs(message->type); |
1418 | if (GNUNET_MESSAGE_TYPE_MESH_UNICAST == type || | 1464 | |
1419 | GNUNET_MESSAGE_TYPE_MESH_TO_ORIGIN == type) | 1465 | if (GNUNET_MESSAGE_TYPE_MESH_FWD == type || |
1466 | GNUNET_MESSAGE_TYPE_MESH_BCK == type) | ||
1420 | { | 1467 | { |
1421 | struct GNUNET_MESH_Data *u; | 1468 | struct GNUNET_MESH_Encrypted *msg; |
1469 | uint32_t ttl; | ||
1422 | 1470 | ||
1423 | u = (struct GNUNET_MESH_Data *) data; | 1471 | msg = (struct GNUNET_MESH_Encrypted *) data; |
1424 | u->ttl = htonl (ntohl (u->ttl) - 1); | 1472 | ttl = ntohl (msg->ttl); |
1473 | if (0 == ttl) | ||
1474 | { | ||
1475 | GNUNET_break_op (0); | ||
1476 | return; | ||
1477 | } | ||
1478 | msg->ttl = htonl (ttl - 1); | ||
1425 | } | 1479 | } |
1426 | 1480 | ||
1427 | queue_add (data, | 1481 | queue_add (data, |
@@ -1434,21 +1488,21 @@ send_prebuilt_message_connection (const struct GNUNET_MessageHeader *message, | |||
1434 | 1488 | ||
1435 | 1489 | ||
1436 | /** | 1490 | /** |
1437 | * Sends an already built message on a tunnel, properly registering | 1491 | * Sends an already built message on a tunnel, choosing the best connection. |
1438 | * all used resources. | ||
1439 | * | 1492 | * |
1440 | * @param message Message to send. Function makes a copy of it. | 1493 | * @param message Message to send. Function modifies it. |
1441 | * @param t Tunnel on which this message is transmitted. | 1494 | * @param t Tunnel on which this message is transmitted. |
1442 | * @param ch Channel on which this message is transmitted. | 1495 | * @param ch Channel on which this message is transmitted. |
1443 | * @param fwd Is this a fwd message? | 1496 | * @param fwd Is this a fwd message? |
1444 | */ | 1497 | */ |
1445 | static void | 1498 | static void |
1446 | send_prebuilt_message_tunnel (const struct GNUNET_MessageHeader *message, | 1499 | send_prebuilt_message_tunnel (struct GNUNET_MESH_Encrypted *msg, |
1447 | struct MeshTunnel2 *t, | 1500 | struct MeshTunnel2 *t, |
1448 | struct MeshChannel *ch, | 1501 | struct MeshChannel *ch, |
1449 | int fwd) | 1502 | int fwd) |
1450 | { | 1503 | { |
1451 | struct MeshConnection *c; | 1504 | struct MeshConnection *c; |
1505 | uint16_t type; | ||
1452 | 1506 | ||
1453 | c = tunnel_get_connection (t, fwd); | 1507 | c = tunnel_get_connection (t, fwd); |
1454 | if (NULL == c) | 1508 | if (NULL == c) |
@@ -1456,14 +1510,26 @@ send_prebuilt_message_tunnel (const struct GNUNET_MessageHeader *message, | |||
1456 | GNUNET_break (0); | 1510 | GNUNET_break (0); |
1457 | return; | 1511 | return; |
1458 | } | 1512 | } |
1513 | type = ntohs (msg->header.size); | ||
1514 | switch (type) | ||
1515 | { | ||
1516 | case GNUNET_MESSAGE_TYPE_MESH_FWD: | ||
1517 | case GNUNET_MESSAGE_TYPE_MESH_BCK: | ||
1518 | msg->cid = htonl (c->id); | ||
1519 | msg->tid = t->id; | ||
1520 | msg->ttl = default_ttl; | ||
1521 | break; | ||
1522 | default: | ||
1523 | GNUNET_break (0); | ||
1524 | } | ||
1459 | 1525 | ||
1460 | send_prebuilt_message_connection (message, c, ch, fwd); | 1526 | send_prebuilt_message_connection (&msg->header, c, ch, fwd); |
1461 | } | 1527 | } |
1462 | 1528 | ||
1463 | 1529 | ||
1464 | /** | 1530 | /** |
1465 | * Sends an already built message on a channel, properly registering | 1531 | * Sends an already built message on a channel, properly registering |
1466 | * all used resources. | 1532 | * all used resources and encrypting the message with the tunnel's key. |
1467 | * | 1533 | * |
1468 | * @param message Message to send. Function makes a copy of it. | 1534 | * @param message Message to send. Function makes a copy of it. |
1469 | * @param ch Channel on which this message is transmitted. | 1535 | * @param ch Channel on which this message is transmitted. |
@@ -1474,7 +1540,22 @@ send_prebuilt_message_channel (const struct GNUNET_MessageHeader *message, | |||
1474 | struct MeshChannel *ch, | 1540 | struct MeshChannel *ch, |
1475 | int fwd) | 1541 | int fwd) |
1476 | { | 1542 | { |
1477 | send_prebuilt_message_tunnel (message, ch->t, ch, fwd); | 1543 | struct GNUNET_MESH_Encrypted *msg; |
1544 | size_t size = ntohs (message->size); | ||
1545 | char *cbuf[size + sizeof (struct GNUNET_MESH_Encrypted)]; | ||
1546 | uint16_t type; | ||
1547 | uint64_t iv; | ||
1548 | |||
1549 | type = fwd ? GNUNET_MESSAGE_TYPE_MESH_FWD : GNUNET_MESSAGE_TYPE_MESH_BCK; | ||
1550 | iv = GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_WEAK, UINT64_MAX); | ||
1551 | |||
1552 | msg = (struct GNUNET_MESH_Encrypted *) cbuf; | ||
1553 | msg->header.type = htons (type); | ||
1554 | msg->header.size = htons (size); | ||
1555 | msg->iv = GNUNET_htonll (iv); | ||
1556 | tunnel_encrypt (ch->t, &msg[1], message, size, iv, fwd); | ||
1557 | |||
1558 | send_prebuilt_message_tunnel (msg, ch->t, ch, fwd); | ||
1478 | } | 1559 | } |
1479 | 1560 | ||
1480 | 1561 | ||
@@ -1741,7 +1822,7 @@ send_core_connection_ack (void *cls, size_t size, void *buf) | |||
1741 | msg->header.type = htons (GNUNET_MESSAGE_TYPE_MESH_CONNECTION_ACK); | 1822 | msg->header.type = htons (GNUNET_MESSAGE_TYPE_MESH_CONNECTION_ACK); |
1742 | GNUNET_CRYPTO_hash_xor (&GNUNET_PEER_resolve2 (t->peer->id)->hashPubKey, | 1823 | GNUNET_CRYPTO_hash_xor (&GNUNET_PEER_resolve2 (t->peer->id)->hashPubKey, |
1743 | &my_full_id.hashPubKey, | 1824 | &my_full_id.hashPubKey, |
1744 | &msg->tid.hashPubKey); | 1825 | &msg->tid); |
1745 | msg->cid = htonl (c->id); | 1826 | msg->cid = htonl (c->id); |
1746 | 1827 | ||
1747 | /* TODO add signature */ | 1828 | /* TODO add signature */ |
@@ -2629,7 +2710,7 @@ channel_send_data_ack (struct MeshChannel *ch, int fwd) | |||
2629 | msg.header.type = htons (fwd ? GNUNET_MESSAGE_TYPE_MESH_UNICAST_ACK : | 2710 | msg.header.type = htons (fwd ? GNUNET_MESSAGE_TYPE_MESH_UNICAST_ACK : |
2630 | GNUNET_MESSAGE_TYPE_MESH_TO_ORIG_ACK); | 2711 | GNUNET_MESSAGE_TYPE_MESH_TO_ORIG_ACK); |
2631 | msg.header.size = htons (sizeof (msg)); | 2712 | msg.header.size = htons (sizeof (msg)); |
2632 | msg.id = htonl (ch->id); | 2713 | msg.chid = htonl (ch->id); |
2633 | msg.mid = htonl (rel->mid_recv - 1); | 2714 | msg.mid = htonl (rel->mid_recv - 1); |
2634 | msg.futures = 0; | 2715 | msg.futures = 0; |
2635 | for (copy = rel->head_recv; NULL != copy; copy = copy->next) | 2716 | for (copy = rel->head_recv; NULL != copy; copy = copy->next) |
@@ -3125,14 +3206,23 @@ channel_retransmit_message (void *cls, | |||
3125 | return; | 3206 | return; |
3126 | } | 3207 | } |
3127 | 3208 | ||
3128 | /* Search the message to be retransmitted in the outgoing queue */ | 3209 | /* Search the message to be retransmitted in the outgoing queue. |
3210 | * Check only the queue for the connection that is going to be used, | ||
3211 | * if the message is stuck in some other connection's queue we shouldn't | ||
3212 | * act upon it: | ||
3213 | * - cancelling it and sending the new one doesn't guarantee it's delivery, | ||
3214 | * the old connection could be temporary stalled or the queue happened to | ||
3215 | * be long at time of insertion. | ||
3216 | * - not sending the new one could cause terrible delays the old connection | ||
3217 | * is stalled. | ||
3218 | */ | ||
3129 | payload = (struct GNUNET_MESH_Data *) ©[1]; | 3219 | payload = (struct GNUNET_MESH_Data *) ©[1]; |
3130 | fwd = (rel == ch->fwd_rel); | 3220 | fwd = (rel == ch->fwd_rel); |
3131 | c = tunnel_get_connection(ch->t, fwd); | 3221 | c = tunnel_get_connection(ch->t, fwd); |
3132 | pi = connection_get_next_hop (c); | 3222 | pi = connection_get_next_hop (c); |
3133 | for (q = pi->fc->queue_head; NULL != q; q = q->next) | 3223 | for (q = pi->fc->queue_head; NULL != q; q = q->next) |
3134 | { | 3224 | { |
3135 | if (ntohs (payload->header.type) == q->type) | 3225 | if (ntohs (payload->header.type) == q->type && ch == q->ch) |
3136 | { | 3226 | { |
3137 | struct GNUNET_MESH_Data *queued_data = q->cls; | 3227 | struct GNUNET_MESH_Data *queued_data = q->cls; |
3138 | 3228 | ||
@@ -3141,31 +3231,28 @@ channel_retransmit_message (void *cls, | |||
3141 | } | 3231 | } |
3142 | } | 3232 | } |
3143 | 3233 | ||
3144 | /* Message not found in the queue */ | 3234 | /* Message not found in the queue that we are going to use. */ |
3145 | if (NULL == q) | 3235 | if (NULL == q) |
3146 | { | 3236 | { |
3147 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "!!! RETRANSMIT %u\n", copy->mid); | 3237 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "!!! RETRANSMIT %u\n", copy->mid); |
3148 | 3238 | ||
3149 | fc->last_ack_sent++; | 3239 | send_prebuilt_message_channel (&payload->header, ch, ch->fwd_rel == rel); |
3150 | fc->last_pid_recv++; | ||
3151 | payload->pid = htonl (fc->last_pid_recv); | ||
3152 | send_prebuilt_message_channel (&payload->header, hop, t); | ||
3153 | GNUNET_STATISTICS_update (stats, "# data retransmitted", 1, GNUNET_NO); | 3240 | GNUNET_STATISTICS_update (stats, "# data retransmitted", 1, GNUNET_NO); |
3154 | } | 3241 | } |
3155 | else | 3242 | else |
3156 | { | 3243 | { |
3157 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "!!! STILL IN QUEUE %u\n", copy->mid); | 3244 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "!!! ALREADY IN QUEUE %u\n", copy->mid); |
3158 | } | 3245 | } |
3159 | 3246 | ||
3160 | rel->retry_timer = GNUNET_TIME_STD_BACKOFF (rel->retry_timer); | 3247 | rel->retry_timer = GNUNET_TIME_STD_BACKOFF (rel->retry_timer); |
3161 | rel->retry_task = GNUNET_SCHEDULER_add_delayed (rel->retry_timer, | 3248 | rel->retry_task = GNUNET_SCHEDULER_add_delayed (rel->retry_timer, |
3162 | &tunnel_retransmit_message, | 3249 | &channel_retransmit_message, |
3163 | cls); | 3250 | cls); |
3164 | } | 3251 | } |
3165 | 3252 | ||
3166 | 3253 | ||
3167 | /** | 3254 | /** |
3168 | * Send keepalive packets for a tunnel. | 3255 | * Send keepalive packets for a connection. |
3169 | * | 3256 | * |
3170 | * @param c Connection to keep alive.. | 3257 | * @param c Connection to keep alive.. |
3171 | * @param fwd Is this a FWD keepalive? (owner -> dest). | 3258 | * @param fwd Is this a FWD keepalive? (owner -> dest). |
@@ -3176,23 +3263,24 @@ connection_keepalive (struct MeshConnection *c, int fwd) | |||
3176 | struct GNUNET_MESH_ConnectionKeepAlive *msg; | 3263 | struct GNUNET_MESH_ConnectionKeepAlive *msg; |
3177 | size_t size = sizeof (struct GNUNET_MESH_TunnelKeepAlive); | 3264 | size_t size = sizeof (struct GNUNET_MESH_TunnelKeepAlive); |
3178 | char cbuf[size]; | 3265 | char cbuf[size]; |
3179 | GNUNET_PEER_Id hop; | ||
3180 | uint16_t type; | 3266 | uint16_t type; |
3181 | 3267 | ||
3182 | type = fwd ? GNUNET_MESSAGE_TYPE_MESH_FWD_KEEPALIVE : | 3268 | type = fwd ? GNUNET_MESSAGE_TYPE_MESH_FWD_KEEPALIVE : |
3183 | GNUNET_MESSAGE_TYPE_MESH_BCK_KEEPALIVE; | 3269 | GNUNET_MESSAGE_TYPE_MESH_BCK_KEEPALIVE; |
3184 | hop = fwd ? connection_get_next_hop (c) : connection_get_prev_hop (c); | ||
3185 | 3270 | ||
3186 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 3271 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
3187 | "sending %s keepalive for connection %d\n", | 3272 | "sending %s keepalive for connection %s[%d]\n", |
3188 | fwd ? "FWD" : "BCK", c->id); | 3273 | fwd ? "FWD" : "BCK", |
3274 | GNUNET_i2s (GNUNET_PEER_resolve2 (c->t->peer->id)), | ||
3275 | c->id); | ||
3189 | 3276 | ||
3190 | msg = (struct GNUNET_MESH_TunnelKeepAlive *) cbuf; | 3277 | msg = (struct GNUNET_MESH_TunnelKeepAlive *) cbuf; |
3191 | msg->header.size = htons (size); | 3278 | msg->header.size = htons (size); |
3192 | msg->header.type = htons (type); | 3279 | msg->header.type = htons (type); |
3193 | msg->oid = *(GNUNET_PEER_resolve2 (c->t->id.oid)); | 3280 | msg->cid = htonl (c->id); |
3194 | msg->tid = htonl (c->t->id.tid); | 3281 | msg->tid = c->t->id; |
3195 | send_prebuilt_message (&msg->header, hop, c->t); | 3282 | |
3283 | send_prebuilt_message_connection (&msg->header, c, NULL, fwd); | ||
3196 | } | 3284 | } |
3197 | 3285 | ||
3198 | 3286 | ||
diff --git a/src/mesh/mesh_protocol_enc.h b/src/mesh/mesh_protocol_enc.h index 547ae89fc..9a49cea4a 100644 --- a/src/mesh/mesh_protocol_enc.h +++ b/src/mesh/mesh_protocol_enc.h | |||
@@ -26,7 +26,12 @@ | |||
26 | #ifndef MESH_PROTOCOL_ENC_H_ | 26 | #ifndef MESH_PROTOCOL_ENC_H_ |
27 | #define MESH_PROTOCOL_ENC_H_ | 27 | #define MESH_PROTOCOL_ENC_H_ |
28 | 28 | ||
29 | #include "platform.h" | ||
30 | #include "gnunet_util_lib.h" | ||
31 | |||
29 | #ifdef __cplusplus | 32 | #ifdef __cplusplus |
33 | |||
34 | struct GNUNET_MESH_TunnelMessage; | ||
30 | extern "C" | 35 | extern "C" |
31 | { | 36 | { |
32 | #if 0 | 37 | #if 0 |
@@ -61,6 +66,11 @@ struct GNUNET_MESH_ConnectionCreate | |||
61 | uint32_t cid GNUNET_PACKED; | 66 | uint32_t cid GNUNET_PACKED; |
62 | 67 | ||
63 | /** | 68 | /** |
69 | * ID of the tunnel | ||
70 | */ | ||
71 | struct GNUNET_HashCode tid; | ||
72 | |||
73 | /** | ||
64 | * path_length structs defining the *whole* path from the origin [0] to the | 74 | * path_length structs defining the *whole* path from the origin [0] to the |
65 | * final destination [path_length-1]. | 75 | * final destination [path_length-1]. |
66 | */ | 76 | */ |
@@ -78,18 +88,57 @@ struct GNUNET_MESH_ConnectionACK | |||
78 | struct GNUNET_MessageHeader header; | 88 | struct GNUNET_MessageHeader header; |
79 | 89 | ||
80 | /** | 90 | /** |
81 | * CID of the connection | 91 | * ID of the connection |
82 | */ | 92 | */ |
83 | uint32_t cid GNUNET_PACKED; | 93 | uint32_t cid GNUNET_PACKED; |
84 | 94 | ||
85 | /** | 95 | /** |
86 | * TID of the tunnel | 96 | * ID of the tunnel |
87 | */ | 97 | */ |
88 | struct GNUNET_PeerIdentity tid; | 98 | struct GNUNET_HashCode tid; |
89 | 99 | ||
90 | /* TODO: signature */ | 100 | /* TODO: signature */ |
91 | }; | 101 | }; |
92 | 102 | ||
103 | /** | ||
104 | * Tunnel(ed) message. | ||
105 | */ | ||
106 | struct GNUNET_MESH_Encrypted | ||
107 | { | ||
108 | /** | ||
109 | * Type: GNUNET_MESSAGE_TYPE_MESH_{FWD,BCK} | ||
110 | */ | ||
111 | struct GNUNET_MessageHeader header; | ||
112 | |||
113 | /** | ||
114 | * ID of the connection. | ||
115 | */ | ||
116 | uint32_t cid GNUNET_PACKED; | ||
117 | |||
118 | /** | ||
119 | * ID of the tunnel. | ||
120 | */ | ||
121 | struct GNUNET_HashCode tid; | ||
122 | |||
123 | /** | ||
124 | * ID of the packet (hop by hop). | ||
125 | */ | ||
126 | uint32_t pid GNUNET_PACKED; | ||
127 | |||
128 | /** | ||
129 | * Number of hops to live. | ||
130 | */ | ||
131 | uint32_t ttl GNUNET_PACKED; | ||
132 | |||
133 | /** | ||
134 | * Initialization Vector for payload encryption. | ||
135 | */ | ||
136 | uint64_t iv; | ||
137 | |||
138 | /** | ||
139 | * Encrypted content follows. | ||
140 | */ | ||
141 | }; | ||
93 | 142 | ||
94 | /** | 143 | /** |
95 | * Message for mesh data traffic. | 144 | * Message for mesh data traffic. |
@@ -103,29 +152,14 @@ struct GNUNET_MESH_Data | |||
103 | struct GNUNET_MessageHeader header; | 152 | struct GNUNET_MessageHeader header; |
104 | 153 | ||
105 | /** | 154 | /** |
106 | * TID of the tunnel | 155 | * Unique ID of the payload message |
107 | */ | 156 | */ |
108 | uint32_t tid GNUNET_PACKED; | 157 | uint32_t mid GNUNET_PACKED; |
109 | |||
110 | /** | ||
111 | * Number of hops to live | ||
112 | */ | ||
113 | uint32_t ttl GNUNET_PACKED; | ||
114 | 158 | ||
115 | /** | 159 | /** |
116 | * ID of the packet | 160 | * ID of the channel |
117 | */ | 161 | */ |
118 | uint32_t pid GNUNET_PACKED; | 162 | uint32_t chid GNUNET_PACKED; |
119 | |||
120 | /** | ||
121 | * OID of the tunnel | ||
122 | */ | ||
123 | struct GNUNET_PeerIdentity oid; | ||
124 | |||
125 | /** | ||
126 | * Unique ID of the payload message | ||
127 | */ | ||
128 | uint32_t mid GNUNET_PACKED; | ||
129 | 163 | ||
130 | /** | 164 | /** |
131 | * Payload follows | 165 | * Payload follows |
@@ -146,7 +180,7 @@ struct GNUNET_MESH_DataACK | |||
146 | /** | 180 | /** |
147 | * ID of the channel | 181 | * ID of the channel |
148 | */ | 182 | */ |
149 | uint32_t id GNUNET_PACKED; | 183 | uint32_t chid GNUNET_PACKED; |
150 | 184 | ||
151 | /** | 185 | /** |
152 | * Bitfield of already-received newer messages | 186 | * Bitfield of already-received newer messages |
@@ -176,12 +210,6 @@ struct GNUNET_MESH_ACK | |||
176 | * Maximum packet ID authorized. | 210 | * Maximum packet ID authorized. |
177 | */ | 211 | */ |
178 | uint32_t ack GNUNET_PACKED; | 212 | uint32_t ack GNUNET_PACKED; |
179 | |||
180 | /** | ||
181 | * OID of the tunnel | ||
182 | */ | ||
183 | struct GNUNET_PeerIdentity oid; | ||
184 | |||
185 | }; | 213 | }; |
186 | 214 | ||
187 | 215 | ||
@@ -213,14 +241,14 @@ struct GNUNET_MESH_ConnectionBroken | |||
213 | struct GNUNET_MessageHeader header; | 241 | struct GNUNET_MessageHeader header; |
214 | 242 | ||
215 | /** | 243 | /** |
216 | * TID of the tunnel | 244 | * ID of the connection. |
217 | */ | 245 | */ |
218 | uint32_t tid GNUNET_PACKED; | 246 | uint32_t cid GNUNET_PACKED; |
219 | 247 | ||
220 | /** | 248 | /** |
221 | * OID of the tunnel | 249 | * ID of the tunnel |
222 | */ | 250 | */ |
223 | struct GNUNET_PeerIdentity oid; | 251 | struct GNUNET_HashCode tid; |
224 | 252 | ||
225 | /** | 253 | /** |
226 | * ID of the endpoint | 254 | * ID of the endpoint |
@@ -237,7 +265,7 @@ struct GNUNET_MESH_ConnectionBroken | |||
237 | 265 | ||
238 | 266 | ||
239 | /** | 267 | /** |
240 | * Message to destroy a tunnel | 268 | * Message to destroy a connection. |
241 | */ | 269 | */ |
242 | struct GNUNET_MESH_ConnectionDestroy | 270 | struct GNUNET_MESH_ConnectionDestroy |
243 | { | 271 | { |
@@ -247,21 +275,21 @@ struct GNUNET_MESH_ConnectionDestroy | |||
247 | struct GNUNET_MessageHeader header; | 275 | struct GNUNET_MessageHeader header; |
248 | 276 | ||
249 | /** | 277 | /** |
250 | * TID of the tunnel | 278 | * ID of the connection. |
251 | */ | 279 | */ |
252 | uint32_t tid GNUNET_PACKED; | 280 | uint32_t cid GNUNET_PACKED; |
253 | 281 | ||
254 | /** | 282 | /** |
255 | * OID of the tunnel | 283 | * ID of the tunnel |
256 | */ | 284 | */ |
257 | struct GNUNET_PeerIdentity oid; | 285 | struct GNUNET_HashCode tid; |
258 | 286 | ||
259 | /* TODO: signature */ | 287 | /* TODO: signature */ |
260 | }; | 288 | }; |
261 | 289 | ||
262 | 290 | ||
263 | /** | 291 | /** |
264 | * Message to destroy a tunnel | 292 | * Message to keep a connection alive. |
265 | */ | 293 | */ |
266 | struct GNUNET_MESH_ConnectionKeepAlive | 294 | struct GNUNET_MESH_ConnectionKeepAlive |
267 | { | 295 | { |
@@ -269,12 +297,12 @@ struct GNUNET_MESH_ConnectionKeepAlive | |||
269 | * Type: GNUNET_MESSAGE_TYPE_MESH_(FWD|BCK)_KEEPALIVE | 297 | * Type: GNUNET_MESSAGE_TYPE_MESH_(FWD|BCK)_KEEPALIVE |
270 | */ | 298 | */ |
271 | struct GNUNET_MessageHeader header; | 299 | struct GNUNET_MessageHeader header; |
272 | 300 | ||
273 | /** | 301 | /** |
274 | * ID of the connection | 302 | * ID of the connection |
275 | */ | 303 | */ |
276 | uint32_t cid GNUNET_PACKED; | 304 | uint32_t cid GNUNET_PACKED; |
277 | 305 | ||
278 | /** | 306 | /** |
279 | * ID of the tunnel | 307 | * ID of the tunnel |
280 | */ | 308 | */ |