diff options
author | Bart Polot <bart@net.in.tum.de> | 2013-10-17 13:05:52 +0000 |
---|---|---|
committer | Bart Polot <bart@net.in.tum.de> | 2013-10-17 13:05:52 +0000 |
commit | 76e897b90794cd1cde6b0a2f79c70104ca6c98f5 (patch) | |
tree | 1781b059c46d2d3400cc62e2daccca67c2fe7ef7 /src/mesh | |
parent | 8f488ae652e52af47d5662666c016755132a72d7 (diff) | |
download | gnunet-76e897b90794cd1cde6b0a2f79c70104ca6c98f5.tar.gz gnunet-76e897b90794cd1cde6b0a2f79c70104ca6c98f5.zip |
- multiple fixes
Diffstat (limited to 'src/mesh')
-rw-r--r-- | src/mesh/Makefile.am | 8 | ||||
-rw-r--r-- | src/mesh/gnunet-service-mesh_connection.c | 64 | ||||
-rw-r--r-- | src/mesh/gnunet-service-mesh_connection.h | 21 | ||||
-rw-r--r-- | src/mesh/gnunet-service-mesh_peer.c | 9 | ||||
-rw-r--r-- | src/mesh/gnunet-service-mesh_tunnel.c | 4 | ||||
-rw-r--r-- | src/mesh/mesh_common.c | 11 | ||||
-rw-r--r-- | src/mesh/test_mesh.conf | 8 |
7 files changed, 50 insertions, 75 deletions
diff --git a/src/mesh/Makefile.am b/src/mesh/Makefile.am index df1c74c87..3c71f4792 100644 --- a/src/mesh/Makefile.am +++ b/src/mesh/Makefile.am | |||
@@ -102,15 +102,15 @@ if LINUX | |||
102 | endif | 102 | endif |
103 | 103 | ||
104 | gnunet_service_mesh_enc_SOURCES = \ | 104 | gnunet_service_mesh_enc_SOURCES = \ |
105 | gnunet-service-mesh-enc.c \ | ||
106 | gnunet-service-mesh_tunnel.c \ | 105 | gnunet-service-mesh_tunnel.c \ |
107 | gnunet-service-mesh_channel.c \ | ||
108 | gnunet-service-mesh_connection.c \ | 106 | gnunet-service-mesh_connection.c \ |
107 | gnunet-service-mesh_channel.c \ | ||
108 | gnunet-service-mesh_local.c \ | ||
109 | gnunet-service-mesh_peer.c \ | 109 | gnunet-service-mesh_peer.c \ |
110 | gnunet-service-mesh_dht.c \ | 110 | gnunet-service-mesh_dht.c \ |
111 | gnunet-service-mesh_local.c \ | ||
112 | mesh_path.c \ | 111 | mesh_path.c \ |
113 | mesh_common.c | 112 | mesh_common.c \ |
113 | gnunet-service-mesh-enc.c | ||
114 | gnunet_service_mesh_enc_CFLAGS = $(AM_CFLAGS) | 114 | gnunet_service_mesh_enc_CFLAGS = $(AM_CFLAGS) |
115 | gnunet_service_mesh_enc_LDADD = \ | 115 | gnunet_service_mesh_enc_LDADD = \ |
116 | $(top_builddir)/src/util/libgnunetutil.la \ | 116 | $(top_builddir)/src/util/libgnunetutil.la \ |
diff --git a/src/mesh/gnunet-service-mesh_connection.c b/src/mesh/gnunet-service-mesh_connection.c index 5ca287cb1..3197255ef 100644 --- a/src/mesh/gnunet-service-mesh_connection.c +++ b/src/mesh/gnunet-service-mesh_connection.c | |||
@@ -409,8 +409,7 @@ message_sent (void *cls, | |||
409 | /* Send ACK if needed, after accounting for sent ID in fc->queue_n */ | 409 | /* Send ACK if needed, after accounting for sent ID in fc->queue_n */ |
410 | switch (type) | 410 | switch (type) |
411 | { | 411 | { |
412 | case GNUNET_MESSAGE_TYPE_MESH_FWD: | 412 | case GNUNET_MESSAGE_TYPE_MESH_ENCRYPTED: |
413 | case GNUNET_MESSAGE_TYPE_MESH_BCK: | ||
414 | fc->last_pid_sent++; | 413 | fc->last_pid_sent++; |
415 | LOG (GNUNET_ERROR_TYPE_DEBUG, "! accounting pid %u\n", fc->last_pid_sent); | 414 | LOG (GNUNET_ERROR_TYPE_DEBUG, "! accounting pid %u\n", fc->last_pid_sent); |
416 | // send_ack (c, ch, fwd); | 415 | // send_ack (c, ch, fwd); |
@@ -1309,23 +1308,23 @@ GMC_handle_destroy (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
1309 | * | 1308 | * |
1310 | * @param peer Peer identity this notification is about. | 1309 | * @param peer Peer identity this notification is about. |
1311 | * @param message Encrypted message. | 1310 | * @param message Encrypted message. |
1312 | * @param fwd Is this FWD traffic? GNUNET_YES : GNUNET_NO; | ||
1313 | * | 1311 | * |
1314 | * @return GNUNET_OK to keep the connection open, | 1312 | * @return GNUNET_OK to keep the connection open, |
1315 | * GNUNET_SYSERR to close it (signal serious error) | 1313 | * GNUNET_SYSERR to close it (signal serious error) |
1316 | */ | 1314 | */ |
1317 | static int | 1315 | static int |
1318 | handle_mesh_encrypted (const struct GNUNET_PeerIdentity *peer, | 1316 | handle_mesh_encrypted (const struct GNUNET_PeerIdentity *peer, |
1319 | const struct GNUNET_MESH_Encrypted *msg, | 1317 | const struct GNUNET_MESH_Encrypted *msg) |
1320 | int fwd) | ||
1321 | { | 1318 | { |
1322 | struct MeshConnection *c; | 1319 | struct MeshConnection *c; |
1323 | struct MeshPeer *neighbor; | 1320 | struct MeshPeer *neighbor; |
1324 | struct MeshFlowControl *fc; | 1321 | struct MeshFlowControl *fc; |
1322 | GNUNET_PEER_Id peer_id; | ||
1325 | uint32_t pid; | 1323 | uint32_t pid; |
1326 | uint32_t ttl; | 1324 | uint32_t ttl; |
1327 | uint16_t type; | 1325 | uint16_t type; |
1328 | size_t size; | 1326 | size_t size; |
1327 | int fwd; | ||
1329 | 1328 | ||
1330 | /* Check size */ | 1329 | /* Check size */ |
1331 | size = ntohs (msg->header.size); | 1330 | size = ntohs (msg->header.size); |
@@ -1350,15 +1349,27 @@ handle_mesh_encrypted (const struct GNUNET_PeerIdentity *peer, | |||
1350 | return GNUNET_OK; | 1349 | return GNUNET_OK; |
1351 | } | 1350 | } |
1352 | 1351 | ||
1353 | fc = fwd ? &c->bck_fc : &c->fwd_fc; | ||
1354 | |||
1355 | /* Check if origin is as expected */ | 1352 | /* Check if origin is as expected */ |
1356 | neighbor = get_hop (c, !fwd); | 1353 | neighbor = get_prev_hop (c); |
1357 | if (GNUNET_PEER_search (peer) != GMP_get_short_id (neighbor)) | 1354 | peer_id = GNUNET_PEER_search (peer); |
1355 | if (peer_id == GMP_get_short_id (neighbor)) | ||
1358 | { | 1356 | { |
1359 | GNUNET_break_op (0); | 1357 | fwd = GNUNET_YES; |
1360 | return GNUNET_OK; | 1358 | } |
1359 | else | ||
1360 | { | ||
1361 | neighbor = get_next_hop (c); | ||
1362 | if (peer_id == GMP_get_short_id (neighbor)) | ||
1363 | { | ||
1364 | fwd = GNUNET_NO; | ||
1365 | } | ||
1366 | else | ||
1367 | { | ||
1368 | GNUNET_break_op (0); | ||
1369 | return GNUNET_OK; | ||
1370 | } | ||
1361 | } | 1371 | } |
1372 | fc = fwd ? &c->bck_fc : &c->fwd_fc; | ||
1362 | 1373 | ||
1363 | /* Check PID */ | 1374 | /* Check PID */ |
1364 | pid = ntohl (msg->pid); | 1375 | pid = ntohl (msg->pid); |
@@ -1421,7 +1432,7 @@ handle_mesh_encrypted (const struct GNUNET_PeerIdentity *peer, | |||
1421 | 1432 | ||
1422 | 1433 | ||
1423 | /** | 1434 | /** |
1424 | * Core handler for mesh network traffic going orig->dest. | 1435 | * Core handler for encrypted mesh network traffic (channel mgmt, data). |
1425 | * | 1436 | * |
1426 | * @param cls Closure (unused). | 1437 | * @param cls Closure (unused). |
1427 | * @param message Message received. | 1438 | * @param message Message received. |
@@ -1431,31 +1442,11 @@ handle_mesh_encrypted (const struct GNUNET_PeerIdentity *peer, | |||
1431 | * GNUNET_SYSERR to close it (signal serious error) | 1442 | * GNUNET_SYSERR to close it (signal serious error) |
1432 | */ | 1443 | */ |
1433 | int | 1444 | int |
1434 | GMC_handle_fwd (void *cls, const struct GNUNET_PeerIdentity *peer, | 1445 | GMC_handle_encrypted (void *cls, const struct GNUNET_PeerIdentity *peer, |
1435 | const struct GNUNET_MessageHeader *message) | 1446 | const struct GNUNET_MessageHeader *message) |
1436 | { | ||
1437 | return handle_mesh_encrypted (peer, | ||
1438 | (struct GNUNET_MESH_Encrypted *)message, | ||
1439 | GNUNET_YES); | ||
1440 | } | ||
1441 | |||
1442 | /** | ||
1443 | * Core handler for mesh network traffic going dest->orig. | ||
1444 | * | ||
1445 | * @param cls Closure (unused). | ||
1446 | * @param message Message received. | ||
1447 | * @param peer Peer who sent the message. | ||
1448 | * | ||
1449 | * @return GNUNET_OK to keep the connection open, | ||
1450 | * GNUNET_SYSERR to close it (signal serious error) | ||
1451 | */ | ||
1452 | int | ||
1453 | GMC_handle_bck (void *cls, const struct GNUNET_PeerIdentity *peer, | ||
1454 | const struct GNUNET_MessageHeader *message) | ||
1455 | { | 1447 | { |
1456 | return handle_mesh_encrypted (peer, | 1448 | return handle_mesh_encrypted (peer, |
1457 | (struct GNUNET_MESH_Encrypted *)message, | 1449 | (struct GNUNET_MESH_Encrypted *)message); |
1458 | GNUNET_NO); | ||
1459 | } | 1450 | } |
1460 | 1451 | ||
1461 | 1452 | ||
@@ -2118,8 +2109,7 @@ GMC_send_prebuilt_message (const struct GNUNET_MessageHeader *message, | |||
2118 | struct GNUNET_MESH_ConnectionBroken *bmsg; | 2109 | struct GNUNET_MESH_ConnectionBroken *bmsg; |
2119 | uint32_t ttl; | 2110 | uint32_t ttl; |
2120 | 2111 | ||
2121 | case GNUNET_MESSAGE_TYPE_MESH_FWD: | 2112 | case GNUNET_MESSAGE_TYPE_MESH_ENCRYPTED: |
2122 | case GNUNET_MESSAGE_TYPE_MESH_BCK: | ||
2123 | emsg = (struct GNUNET_MESH_Encrypted *) data; | 2113 | emsg = (struct GNUNET_MESH_Encrypted *) data; |
2124 | ttl = ntohl (emsg->ttl); | 2114 | ttl = ntohl (emsg->ttl); |
2125 | if (0 == ttl) | 2115 | if (0 == ttl) |
diff --git a/src/mesh/gnunet-service-mesh_connection.h b/src/mesh/gnunet-service-mesh_connection.h index bdfaaf988..3fecf3b63 100644 --- a/src/mesh/gnunet-service-mesh_connection.h +++ b/src/mesh/gnunet-service-mesh_connection.h | |||
@@ -136,7 +136,7 @@ GMC_handle_destroy (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
136 | const struct GNUNET_MessageHeader *message); | 136 | const struct GNUNET_MessageHeader *message); |
137 | 137 | ||
138 | /** | 138 | /** |
139 | * Core handler for mesh network traffic going orig->dest. | 139 | * Core handler for encrypted mesh network traffic (channel mgmt, data). |
140 | * | 140 | * |
141 | * @param cls Closure (unused). | 141 | * @param cls Closure (unused). |
142 | * @param message Message received. | 142 | * @param message Message received. |
@@ -146,23 +146,8 @@ GMC_handle_destroy (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
146 | * GNUNET_SYSERR to close it (signal serious error) | 146 | * GNUNET_SYSERR to close it (signal serious error) |
147 | */ | 147 | */ |
148 | int | 148 | int |
149 | GMC_handle_fwd (void *cls, const struct GNUNET_PeerIdentity *peer, | 149 | GMC_handle_encrypted (void *cls, const struct GNUNET_PeerIdentity *peer, |
150 | const struct GNUNET_MessageHeader *message); | 150 | const struct GNUNET_MessageHeader *message); |
151 | |||
152 | |||
153 | /** | ||
154 | * Core handler for mesh network traffic going dest->orig. | ||
155 | * | ||
156 | * @param cls Closure (unused). | ||
157 | * @param message Message received. | ||
158 | * @param peer Peer who sent the message. | ||
159 | * | ||
160 | * @return GNUNET_OK to keep the connection open, | ||
161 | * GNUNET_SYSERR to close it (signal serious error) | ||
162 | */ | ||
163 | int | ||
164 | GMC_handle_bck (void *cls, const struct GNUNET_PeerIdentity *peer, | ||
165 | const struct GNUNET_MessageHeader *message); | ||
166 | 151 | ||
167 | /** | 152 | /** |
168 | * Core handler for mesh network traffic point-to-point acks. | 153 | * Core handler for mesh network traffic point-to-point acks. |
diff --git a/src/mesh/gnunet-service-mesh_peer.c b/src/mesh/gnunet-service-mesh_peer.c index ff0d43813..515c4b4f0 100644 --- a/src/mesh/gnunet-service-mesh_peer.c +++ b/src/mesh/gnunet-service-mesh_peer.c | |||
@@ -332,8 +332,7 @@ static struct GNUNET_CORE_MessageHandler core_handlers[] = { | |||
332 | sizeof (struct GNUNET_MESH_ACK)}, | 332 | sizeof (struct GNUNET_MESH_ACK)}, |
333 | {&GMC_handle_poll, GNUNET_MESSAGE_TYPE_MESH_POLL, | 333 | {&GMC_handle_poll, GNUNET_MESSAGE_TYPE_MESH_POLL, |
334 | sizeof (struct GNUNET_MESH_Poll)}, | 334 | sizeof (struct GNUNET_MESH_Poll)}, |
335 | {&GMC_handle_fwd, GNUNET_MESSAGE_TYPE_MESH_FWD, 0}, | 335 | {&GMC_handle_encrypted, GNUNET_MESSAGE_TYPE_MESH_ENCRYPTED, 0}, |
336 | {&GMC_handle_bck, GNUNET_MESSAGE_TYPE_MESH_BCK, 0}, | ||
337 | {NULL, 0, 0} | 336 | {NULL, 0, 0} |
338 | }; | 337 | }; |
339 | 338 | ||
@@ -774,8 +773,7 @@ queue_destroy (struct MeshPeerQueue *queue, int clear_cls) | |||
774 | case GNUNET_MESSAGE_TYPE_MESH_TUNNEL_DESTROY: | 773 | case GNUNET_MESSAGE_TYPE_MESH_TUNNEL_DESTROY: |
775 | LOG (GNUNET_ERROR_TYPE_INFO, "destroying a DESTROY message\n"); | 774 | LOG (GNUNET_ERROR_TYPE_INFO, "destroying a DESTROY message\n"); |
776 | /* fall through */ | 775 | /* fall through */ |
777 | case GNUNET_MESSAGE_TYPE_MESH_FWD: | 776 | case GNUNET_MESSAGE_TYPE_MESH_ENCRYPTED: |
778 | case GNUNET_MESSAGE_TYPE_MESH_BCK: | ||
779 | case GNUNET_MESSAGE_TYPE_MESH_ACK: | 777 | case GNUNET_MESSAGE_TYPE_MESH_ACK: |
780 | case GNUNET_MESSAGE_TYPE_MESH_POLL: | 778 | case GNUNET_MESSAGE_TYPE_MESH_POLL: |
781 | case GNUNET_MESSAGE_TYPE_MESH_CONNECTION_ACK: | 779 | case GNUNET_MESSAGE_TYPE_MESH_CONNECTION_ACK: |
@@ -872,8 +870,7 @@ queue_send (void *cls, size_t size, void *buf) | |||
872 | case GNUNET_MESSAGE_TYPE_MESH_TUNNEL_DESTROY: | 870 | case GNUNET_MESSAGE_TYPE_MESH_TUNNEL_DESTROY: |
873 | case GNUNET_MESSAGE_TYPE_MESH_CONNECTION_DESTROY: | 871 | case GNUNET_MESSAGE_TYPE_MESH_CONNECTION_DESTROY: |
874 | case GNUNET_MESSAGE_TYPE_MESH_CONNECTION_BROKEN: | 872 | case GNUNET_MESSAGE_TYPE_MESH_CONNECTION_BROKEN: |
875 | case GNUNET_MESSAGE_TYPE_MESH_FWD: | 873 | case GNUNET_MESSAGE_TYPE_MESH_ENCRYPTED: |
876 | case GNUNET_MESSAGE_TYPE_MESH_BCK: | ||
877 | case GNUNET_MESSAGE_TYPE_MESH_ACK: | 874 | case GNUNET_MESSAGE_TYPE_MESH_ACK: |
878 | case GNUNET_MESSAGE_TYPE_MESH_POLL: | 875 | case GNUNET_MESSAGE_TYPE_MESH_POLL: |
879 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 876 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
diff --git a/src/mesh/gnunet-service-mesh_tunnel.c b/src/mesh/gnunet-service-mesh_tunnel.c index a5220a04f..e2cf7db17 100644 --- a/src/mesh/gnunet-service-mesh_tunnel.c +++ b/src/mesh/gnunet-service-mesh_tunnel.c | |||
@@ -1199,10 +1199,10 @@ GMT_send_prebuilt_message (const struct GNUNET_MessageHeader *message, | |||
1199 | type = ntohs (message->type); | 1199 | type = ntohs (message->type); |
1200 | switch (type) | 1200 | switch (type) |
1201 | { | 1201 | { |
1202 | case GNUNET_MESSAGE_TYPE_MESH_FWD: | 1202 | case GNUNET_MESSAGE_TYPE_MESH_ENCRYPTED: |
1203 | case GNUNET_MESSAGE_TYPE_MESH_BCK: | ||
1204 | case GNUNET_MESSAGE_TYPE_MESH_CHANNEL_CREATE: | 1203 | case GNUNET_MESSAGE_TYPE_MESH_CHANNEL_CREATE: |
1205 | case GNUNET_MESSAGE_TYPE_MESH_CHANNEL_DESTROY: | 1204 | case GNUNET_MESSAGE_TYPE_MESH_CHANNEL_DESTROY: |
1205 | case GNUNET_MESSAGE_TYPE_MESH_CHANNEL_ACK: | ||
1206 | msg->cid = *GMC_get_id (c); | 1206 | msg->cid = *GMC_get_id (c); |
1207 | msg->ttl = htonl (default_ttl); | 1207 | msg->ttl = htonl (default_ttl); |
1208 | break; | 1208 | break; |
diff --git a/src/mesh/mesh_common.c b/src/mesh/mesh_common.c index 1089e8edc..90f2e5299 100644 --- a/src/mesh/mesh_common.c +++ b/src/mesh/mesh_common.c | |||
@@ -146,19 +146,14 @@ GNUNET_MESH_DEBUG_M2S (uint16_t m) | |||
146 | case 274: return "GNUNET_MESSAGE_TYPE_MESH_CHANNEL_DESTROY"; | 146 | case 274: return "GNUNET_MESSAGE_TYPE_MESH_CHANNEL_DESTROY"; |
147 | 147 | ||
148 | /** | 148 | /** |
149 | * Confirm the creation of a channel | 149 | * Confirm the creation of a channel. |
150 | */ | 150 | */ |
151 | case 275: return "GNUNET_MESSAGE_TYPE_MESH_CHANNEL_ACK"; | 151 | case 275: return "GNUNET_MESSAGE_TYPE_MESH_CHANNEL_ACK"; |
152 | 152 | ||
153 | /** | 153 | /** |
154 | * Ask the mesh service to create a new tunnel | 154 | * Encrypted payload. |
155 | */ | ||
156 | case 280: return "GNUNET_MESSAGE_TYPE_MESH_FWD"; | ||
157 | |||
158 | /** | ||
159 | * Ask the mesh service to destroy a tunnel | ||
160 | */ | 155 | */ |
161 | case 281: return "GNUNET_MESSAGE_TYPE_MESH_BCK"; | 156 | case 280: return "GNUNET_MESSAGE_TYPE_MESH_ENCRYPTED"; |
162 | 157 | ||
163 | /** | 158 | /** |
164 | * Local payload traffic | 159 | * Local payload traffic |
diff --git a/src/mesh/test_mesh.conf b/src/mesh/test_mesh.conf index 7d04cd97d..e7d265bea 100644 --- a/src/mesh/test_mesh.conf +++ b/src/mesh/test_mesh.conf | |||
@@ -79,3 +79,11 @@ AUTOSTART = NO | |||
79 | 79 | ||
80 | [consensus] | 80 | [consensus] |
81 | AUTOSTART = NO | 81 | AUTOSTART = NO |
82 | |||
83 | [nat] | ||
84 | # Allow running on systems with only loopback? | ||
85 | RETURN_LOCAL_ADDRESSES = YES | ||
86 | # Disable redundant addresses... | ||
87 | DISABLEV6 = YES | ||
88 | USE_LOCALADDR = YES | ||
89 | |||