aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2012-05-10 21:26:09 +0000
committerChristian Grothoff <christian@grothoff.org>2012-05-10 21:26:09 +0000
commit7f96c0370dfa90c1c6c64ae63e69c8ec3ae8b47f (patch)
treee915c2b168a4fff3ae35e172020bbae99898a470 /src
parentaba401676da7c4725ffcc7ff45e1f5874623b4ba (diff)
downloadgnunet-7f96c0370dfa90c1c6c64ae63e69c8ec3ae8b47f.tar.gz
gnunet-7f96c0370dfa90c1c6c64ae63e69c8ec3ae8b47f.zip
-fixing misc issues in stream, including compilation errors on bots, but more
Diffstat (limited to 'src')
-rw-r--r--src/stream/stream_api.c204
1 files changed, 60 insertions, 144 deletions
diff --git a/src/stream/stream_api.c b/src/stream/stream_api.c
index ff4e49dad..3bf3c7863 100644
--- a/src/stream/stream_api.c
+++ b/src/stream/stream_api.c
@@ -298,11 +298,6 @@ struct GNUNET_STREAM_Socket
298 GNUNET_PEER_Id other_peer; 298 GNUNET_PEER_Id other_peer;
299 299
300 /** 300 /**
301 * Our Peer Identity (for debugging)
302 */
303 GNUNET_PEER_Id our_id;
304
305 /**
306 * The application port number (type: uint32_t) 301 * The application port number (type: uint32_t)
307 */ 302 */
308 GNUNET_MESH_ApplicationType app_port; 303 GNUNET_MESH_ApplicationType app_port;
@@ -377,11 +372,6 @@ struct GNUNET_STREAM_ListenSocket
377 void *listen_cb_cls; 372 void *listen_cb_cls;
378 373
379 /** 374 /**
380 * Our interned Peer's identity
381 */
382 GNUNET_PEER_Id our_id;
383
384 /**
385 * The service port 375 * The service port
386 * FIXME: Remove if not required! 376 * FIXME: Remove if not required!
387 */ 377 */
@@ -575,8 +565,7 @@ queue_message (struct GNUNET_STREAM_Socket *socket,
575 && (ntohs (message->header.type) <= GNUNET_MESSAGE_TYPE_STREAM_CLOSE_ACK)); 565 && (ntohs (message->header.type) <= GNUNET_MESSAGE_TYPE_STREAM_CLOSE_ACK));
576 566
577 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 567 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
578 "%x: Queueing message of type %d and size %d\n", 568 "Queueing message of type %d and size %d\n",
579 socket->our_id,
580 ntohs (message->header.type), 569 ntohs (message->header.type),
581 ntohs (message->header.size)); 570 ntohs (message->header.size));
582 GNUNET_assert (NULL != message); 571 GNUNET_assert (NULL != message);
@@ -685,7 +674,7 @@ retransmission_timeout_task (void *cls,
685 return; 674 return;
686 675
687 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 676 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
688 "%x: Retransmitting DATA...\n", socket->our_id); 677 "Retransmitting DATA...\n");
689 socket->retransmission_timeout_task_id = GNUNET_SCHEDULER_NO_TASK; 678 socket->retransmission_timeout_task_id = GNUNET_SCHEDULER_NO_TASK;
690 write_data (socket); 679 write_data (socket);
691} 680}
@@ -847,8 +836,7 @@ write_data (struct GNUNET_STREAM_Socket *socket)
847 packet)) 836 packet))
848 { 837 {
849 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 838 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
850 "%x: Placing DATA message with sequence %u in send queue\n", 839 "Placing DATA message with sequence %u in send queue\n",
851 socket->our_id,
852 ntohl (io_handle->messages[packet]->sequence_number)); 840 ntohl (io_handle->messages[packet]->sequence_number));
853 841
854 copy_and_queue_message (socket, 842 copy_and_queue_message (socket,
@@ -866,8 +854,7 @@ write_data (struct GNUNET_STREAM_Socket *socket)
866 socket->receiver_window_available -= 854 socket->receiver_window_available -=
867 ntohs (io_handle->messages[packet]->header.header.size); 855 ntohs (io_handle->messages[packet]->header.header.size);
868 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 856 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
869 "%x: Placing DATA message with sequence %u in send queue\n", 857 "Placing DATA message with sequence %u in send queue\n",
870 socket->our_id,
871 ntohl (io_handle->messages[packet]->sequence_number)); 858 ntohl (io_handle->messages[packet]->sequence_number));
872 copy_and_queue_message (socket, 859 copy_and_queue_message (socket,
873 &io_handle->messages[packet]->header, 860 &io_handle->messages[packet]->header,
@@ -933,20 +920,17 @@ call_read_processor (void *cls,
933 920
934 /* Call the data processor */ 921 /* Call the data processor */
935 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 922 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
936 "%x: Calling read processor\n", 923 "Calling read processor\n");
937 socket->our_id);
938 read_size = 924 read_size =
939 socket->read_handle->proc (socket->read_handle->proc_cls, 925 socket->read_handle->proc (socket->read_handle->proc_cls,
940 socket->status, 926 socket->status,
941 socket->receive_buffer + socket->copy_offset, 927 socket->receive_buffer + socket->copy_offset,
942 valid_read_size); 928 valid_read_size);
943 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 929 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
944 "%x: Read processor read %d bytes\n", 930 "Read processor read %d bytes\n",
945 socket->our_id,
946 read_size); 931 read_size);
947 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 932 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
948 "%x: Read processor completed successfully\n", 933 "Read processor completed successfully\n");
949 socket->our_id);
950 934
951 /* Free the read handle */ 935 /* Free the read handle */
952 GNUNET_free (socket->read_handle); 936 GNUNET_free (socket->read_handle);
@@ -969,8 +953,7 @@ call_read_processor (void *cls,
969 953
970 sequence_increase = packet; 954 sequence_increase = packet;
971 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 955 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
972 "%x: Sequence increase after read processor completion: %u\n", 956 "Sequence increase after read processor completion: %u\n",
973 socket->our_id,
974 sequence_increase); 957 sequence_increase);
975 958
976 /* Shift the data in the receive buffer */ 959 /* Shift the data in the receive buffer */
@@ -1027,8 +1010,7 @@ read_io_timeout (void *cls,
1027 if (socket->read_task_id != GNUNET_SCHEDULER_NO_TASK) 1010 if (socket->read_task_id != GNUNET_SCHEDULER_NO_TASK)
1028 { 1011 {
1029 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1012 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1030 "%x: Read task timedout - Cancelling it\n", 1013 "Read task timedout - Cancelling it\n");
1031 socket->our_id);
1032 GNUNET_SCHEDULER_cancel (socket->read_task_id); 1014 GNUNET_SCHEDULER_cancel (socket->read_task_id);
1033 socket->read_task_id = GNUNET_SCHEDULER_NO_TASK; 1015 socket->read_task_id = GNUNET_SCHEDULER_NO_TASK;
1034 } 1016 }
@@ -1080,8 +1062,7 @@ handle_data (struct GNUNET_STREAM_Socket *socket,
1080 if (GNUNET_PEER_search (sender) != socket->other_peer) 1062 if (GNUNET_PEER_search (sender) != socket->other_peer)
1081 { 1063 {
1082 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1064 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1083 "%x: Received DATA from non-confirming peer\n", 1065 "Received DATA from non-confirming peer\n");
1084 socket->our_id);
1085 return GNUNET_YES; 1066 return GNUNET_YES;
1086 } 1067 }
1087 1068
@@ -1098,8 +1079,7 @@ handle_data (struct GNUNET_STREAM_Socket *socket,
1098 if ( relative_sequence_number > GNUNET_STREAM_ACK_BITMAP_BIT_LENGTH) 1079 if ( relative_sequence_number > GNUNET_STREAM_ACK_BITMAP_BIT_LENGTH)
1099 { 1080 {
1100 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1081 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1101 "%x: Ignoring received message with sequence number %u\n", 1082 "Ignoring received message with sequence number %u\n",
1102 socket->our_id,
1103 ntohl (msg->sequence_number)); 1083 ntohl (msg->sequence_number));
1104 /* Start ACK sending task if one is not already present */ 1084 /* Start ACK sending task if one is not already present */
1105 if (GNUNET_SCHEDULER_NO_TASK == socket->ack_task_id) 1085 if (GNUNET_SCHEDULER_NO_TASK == socket->ack_task_id)
@@ -1118,9 +1098,8 @@ handle_data (struct GNUNET_STREAM_Socket *socket,
1118 relative_sequence_number)) 1098 relative_sequence_number))
1119 { 1099 {
1120 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1100 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1121 "%x: Ignoring already received message with sequence " 1101 "Ignoring already received message with sequence "
1122 "number %u\n", 1102 "number %u\n",
1123 socket->our_id,
1124 ntohl (msg->sequence_number)); 1103 ntohl (msg->sequence_number));
1125 /* Start ACK sending task if one is not already present */ 1104 /* Start ACK sending task if one is not already present */
1126 if (GNUNET_SCHEDULER_NO_TASK == socket->ack_task_id) 1105 if (GNUNET_SCHEDULER_NO_TASK == socket->ack_task_id)
@@ -1135,9 +1114,7 @@ handle_data (struct GNUNET_STREAM_Socket *socket,
1135 } 1114 }
1136 1115
1137 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1116 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1138 "%x: Receiving DATA with sequence number: %u and size: %d " 1117 "Receiving DATA with sequence number: %u and size: %d from %x\n",
1139 "from %x\n",
1140 socket->our_id,
1141 ntohl (msg->sequence_number), 1118 ntohl (msg->sequence_number),
1142 ntohs (msg->header.header.size), 1119 ntohs (msg->header.header.size),
1143 socket->other_peer); 1120 socket->other_peer);
@@ -1157,9 +1134,7 @@ handle_data (struct GNUNET_STREAM_Socket *socket,
1157 else 1134 else
1158 { 1135 {
1159 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1136 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1160 "%x: Cannot accommodate packet %d as buffer is", 1137 "Cannot accommodate packet %d as buffer is full\n",
1161 "full\n",
1162 socket->our_id,
1163 ntohl (msg->sequence_number)); 1138 ntohl (msg->sequence_number));
1164 return GNUNET_YES; 1139 return GNUNET_YES;
1165 } 1140 }
@@ -1197,8 +1172,7 @@ handle_data (struct GNUNET_STREAM_Socket *socket,
1197 0))) 1172 0)))
1198 { 1173 {
1199 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1174 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1200 "%x: Scheduling read processor\n", 1175 "Scheduling read processor\n");
1201 socket->our_id);
1202 1176
1203 socket->read_task_id = 1177 socket->read_task_id =
1204 GNUNET_SCHEDULER_add_now (&call_read_processor, 1178 GNUNET_SCHEDULER_add_now (&call_read_processor,
@@ -1209,8 +1183,7 @@ handle_data (struct GNUNET_STREAM_Socket *socket,
1209 1183
1210 default: 1184 default:
1211 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1185 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1212 "%x: Received data message when it cannot be handled\n", 1186 "Received data message when it cannot be handled\n");
1213 socket->our_id);
1214 break; 1187 break;
1215 } 1188 }
1216 return GNUNET_YES; 1189 return GNUNET_YES;
@@ -1260,8 +1233,7 @@ set_state_established (void *cls,
1260 struct GNUNET_PeerIdentity initiator_pid; 1233 struct GNUNET_PeerIdentity initiator_pid;
1261 1234
1262 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1235 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1263 "%x: Attaining ESTABLISHED state\n", 1236 "Attaining ESTABLISHED state\n");
1264 socket->our_id);
1265 socket->write_offset = 0; 1237 socket->write_offset = 0;
1266 socket->read_offset = 0; 1238 socket->read_offset = 0;
1267 socket->state = STATE_ESTABLISHED; 1239 socket->state = STATE_ESTABLISHED;
@@ -1270,8 +1242,7 @@ set_state_established (void *cls,
1270 { 1242 {
1271 GNUNET_PEER_resolve (socket->other_peer, &initiator_pid); 1243 GNUNET_PEER_resolve (socket->other_peer, &initiator_pid);
1272 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1244 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1273 "%x: Calling listen callback\n", 1245 "Calling listen callback\n");
1274 socket->our_id);
1275 if (GNUNET_SYSERR == 1246 if (GNUNET_SYSERR ==
1276 socket->lsocket->listen_cb (socket->lsocket->listen_cb_cls, 1247 socket->lsocket->listen_cb (socket->lsocket->listen_cb_cls,
1277 socket, 1248 socket,
@@ -1300,8 +1271,7 @@ set_state_hello_wait (void *cls,
1300{ 1271{
1301 GNUNET_assert (STATE_INIT == socket->state); 1272 GNUNET_assert (STATE_INIT == socket->state);
1302 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1273 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1303 "%x: Attaining HELLO_WAIT state\n", 1274 "Attaining HELLO_WAIT state\n");
1304 socket->our_id);
1305 socket->state = STATE_HELLO_WAIT; 1275 socket->state = STATE_HELLO_WAIT;
1306} 1276}
1307 1277
@@ -1317,8 +1287,7 @@ set_state_close_wait (void *cls,
1317 struct GNUNET_STREAM_Socket *socket) 1287 struct GNUNET_STREAM_Socket *socket)
1318{ 1288{
1319 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1289 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1320 "%x: Attaing CLOSE_WAIT state\n", 1290 "Attaing CLOSE_WAIT state\n");
1321 socket->our_id);
1322 socket->state = STATE_CLOSE_WAIT; 1291 socket->state = STATE_CLOSE_WAIT;
1323 GNUNET_free_non_null (socket->receive_buffer); /* Free the receive buffer */ 1292 GNUNET_free_non_null (socket->receive_buffer); /* Free the receive buffer */
1324 socket->receive_buffer = NULL; 1293 socket->receive_buffer = NULL;
@@ -1337,8 +1306,7 @@ set_state_receive_close_wait (void *cls,
1337 struct GNUNET_STREAM_Socket *socket) 1306 struct GNUNET_STREAM_Socket *socket)
1338{ 1307{
1339 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1308 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1340 "%x: Attaing RECEIVE_CLOSE_WAIT state\n", 1309 "Attaing RECEIVE_CLOSE_WAIT state\n");
1341 socket->our_id);
1342 socket->state = STATE_RECEIVE_CLOSE_WAIT; 1310 socket->state = STATE_RECEIVE_CLOSE_WAIT;
1343 GNUNET_free_non_null (socket->receive_buffer); /* Free the receive buffer */ 1311 GNUNET_free_non_null (socket->receive_buffer); /* Free the receive buffer */
1344 socket->receive_buffer = NULL; 1312 socket->receive_buffer = NULL;
@@ -1357,8 +1325,7 @@ set_state_transmit_close_wait (void *cls,
1357 struct GNUNET_STREAM_Socket *socket) 1325 struct GNUNET_STREAM_Socket *socket)
1358{ 1326{
1359 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1327 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1360 "%x: Attaing TRANSMIT_CLOSE_WAIT state\n", 1328 "Attaining TRANSMIT_CLOSE_WAIT state\n");
1361 socket->our_id);
1362 socket->state = STATE_TRANSMIT_CLOSE_WAIT; 1329 socket->state = STATE_TRANSMIT_CLOSE_WAIT;
1363} 1330}
1364 1331
@@ -1392,8 +1359,7 @@ generate_hello_ack_msg (struct GNUNET_STREAM_Socket *socket)
1392 socket->write_sequence_number = 1359 socket->write_sequence_number =
1393 GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_NONCE, UINT32_MAX); 1360 GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_NONCE, UINT32_MAX);
1394 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1361 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1395 "%x: Generated write sequence number %u\n", 1362 "Generated write sequence number %u\n",
1396 socket->our_id,
1397 (unsigned int) socket->write_sequence_number); 1363 (unsigned int) socket->write_sequence_number);
1398 1364
1399 msg = GNUNET_malloc (sizeof (struct GNUNET_STREAM_HelloAckMessage)); 1365 msg = GNUNET_malloc (sizeof (struct GNUNET_STREAM_HelloAckMessage));
@@ -1434,14 +1400,12 @@ client_handle_hello_ack (void *cls,
1434 if (GNUNET_PEER_search (sender) != socket->other_peer) 1400 if (GNUNET_PEER_search (sender) != socket->other_peer)
1435 { 1401 {
1436 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1402 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1437 "%x: Received HELLO_ACK from non-confirming peer\n", 1403 "Received HELLO_ACK from non-confirming peer\n");
1438 socket->our_id);
1439 return GNUNET_YES; 1404 return GNUNET_YES;
1440 } 1405 }
1441 ack_msg = (const struct GNUNET_STREAM_HelloAckMessage *) message; 1406 ack_msg = (const struct GNUNET_STREAM_HelloAckMessage *) message;
1442 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1407 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1443 "%x: Received HELLO_ACK from %x\n", 1408 "Received HELLO_ACK from %x\n",
1444 socket->our_id,
1445 socket->other_peer); 1409 socket->other_peer);
1446 1410
1447 GNUNET_assert (socket->tunnel == tunnel); 1411 GNUNET_assert (socket->tunnel == tunnel);
@@ -1450,8 +1414,7 @@ client_handle_hello_ack (void *cls,
1450 case STATE_HELLO_WAIT: 1414 case STATE_HELLO_WAIT:
1451 socket->read_sequence_number = ntohl (ack_msg->sequence_number); 1415 socket->read_sequence_number = ntohl (ack_msg->sequence_number);
1452 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1416 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1453 "%x: Read sequence number %u\n", 1417 "Read sequence number %u\n",
1454 socket->our_id,
1455 (unsigned int) socket->read_sequence_number); 1418 (unsigned int) socket->read_sequence_number);
1456 socket->receiver_window_available = ntohl (ack_msg->receiver_window_size); 1419 socket->receiver_window_available = ntohl (ack_msg->receiver_window_size);
1457 reply = generate_hello_ack_msg (socket); 1420 reply = generate_hello_ack_msg (socket);
@@ -1467,8 +1430,7 @@ client_handle_hello_ack (void *cls,
1467 case STATE_INIT: 1430 case STATE_INIT:
1468 default: 1431 default:
1469 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1432 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1470 "%x: Server %x sent HELLO_ACK when in state %d\n", 1433 "Server %x sent HELLO_ACK when in state %d\n",
1471 socket->our_id,
1472 socket->other_peer, 1434 socket->other_peer,
1473 socket->state); 1435 socket->state);
1474 socket->state = STATE_CLOSED; // introduce STATE_ERROR? 1436 socket->state = STATE_CLOSED; // introduce STATE_ERROR?
@@ -1601,8 +1563,7 @@ handle_generic_close_ack (struct GNUNET_STREAM_Socket *socket,
1601 if (NULL == shutdown_handle) 1563 if (NULL == shutdown_handle)
1602 { 1564 {
1603 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1565 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1604 "%x: Received *CLOSE_ACK when shutdown handle is NULL\n", 1566 "Received *CLOSE_ACK when shutdown handle is NULL\n");
1605 socket->our_id);
1606 return GNUNET_OK; 1567 return GNUNET_OK;
1607 } 1568 }
1608 1569
@@ -1615,22 +1576,18 @@ handle_generic_close_ack (struct GNUNET_STREAM_Socket *socket,
1615 if (SHUT_RDWR != shutdown_handle->operation) 1576 if (SHUT_RDWR != shutdown_handle->operation)
1616 { 1577 {
1617 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1578 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1618 "%x: Received CLOSE_ACK when shutdown handle " 1579 "Received CLOSE_ACK when shutdown handle is not for SHUT_RDWR\n");
1619 "is not for SHUT_RDWR\n",
1620 socket->our_id);
1621 return GNUNET_OK; 1580 return GNUNET_OK;
1622 } 1581 }
1623 1582
1624 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1583 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1625 "%x: Received CLOSE_ACK from %x\n", 1584 "Received CLOSE_ACK from %x\n",
1626 socket->our_id,
1627 socket->other_peer); 1585 socket->other_peer);
1628 socket->state = STATE_CLOSED; 1586 socket->state = STATE_CLOSED;
1629 break; 1587 break;
1630 default: 1588 default:
1631 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1589 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1632 "%x: Received CLOSE_ACK when in it not expected\n", 1590 "Received CLOSE_ACK when in it not expected\n");
1633 socket->our_id);
1634 return GNUNET_OK; 1591 return GNUNET_OK;
1635 } 1592 }
1636 break; 1593 break;
@@ -1642,22 +1599,18 @@ handle_generic_close_ack (struct GNUNET_STREAM_Socket *socket,
1642 if (SHUT_RD != shutdown_handle->operation) 1599 if (SHUT_RD != shutdown_handle->operation)
1643 { 1600 {
1644 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1601 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1645 "%x: Received RECEIVE_CLOSE_ACK when shutdown handle " 1602 "Received RECEIVE_CLOSE_ACK when shutdown handle is not for SHUT_RD\n");
1646 "is not for SHUT_RD\n",
1647 socket->our_id);
1648 return GNUNET_OK; 1603 return GNUNET_OK;
1649 } 1604 }
1650 1605
1651 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1606 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1652 "%x: Received RECEIVE_CLOSE_ACK from %x\n", 1607 "Received RECEIVE_CLOSE_ACK from %x\n",
1653 socket->our_id,
1654 socket->other_peer); 1608 socket->other_peer);
1655 socket->state = STATE_RECEIVE_CLOSED; 1609 socket->state = STATE_RECEIVE_CLOSED;
1656 break; 1610 break;
1657 default: 1611 default:
1658 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1612 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1659 "%x: Received RECEIVE_CLOSE_ACK when in it not expected\n", 1613 "Received RECEIVE_CLOSE_ACK when in it not expected\n");
1660 socket->our_id);
1661 return GNUNET_OK; 1614 return GNUNET_OK;
1662 } 1615 }
1663 1616
@@ -1669,22 +1622,18 @@ handle_generic_close_ack (struct GNUNET_STREAM_Socket *socket,
1669 if (SHUT_WR != shutdown_handle->operation) 1622 if (SHUT_WR != shutdown_handle->operation)
1670 { 1623 {
1671 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1624 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1672 "%x: Received TRANSMIT_CLOSE_ACK when shutdown handle " 1625 "Received TRANSMIT_CLOSE_ACK when shutdown handle is not for SHUT_WR\n");
1673 "is not for SHUT_WR\n",
1674 socket->our_id);
1675 return GNUNET_OK; 1626 return GNUNET_OK;
1676 } 1627 }
1677 1628
1678 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1629 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1679 "%x: Received TRANSMIT_CLOSE_ACK from %x\n", 1630 "Received TRANSMIT_CLOSE_ACK from %x\n",
1680 socket->our_id,
1681 socket->other_peer); 1631 socket->other_peer);
1682 socket->state = STATE_TRANSMIT_CLOSED; 1632 socket->state = STATE_TRANSMIT_CLOSED;
1683 break; 1633 break;
1684 default: 1634 default:
1685 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1635 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1686 "%x: Received TRANSMIT_CLOSE_ACK when in it not expected\n", 1636 "Received TRANSMIT_CLOSE_ACK when in it not expected\n");
1687 socket->our_id);
1688 1637
1689 return GNUNET_OK; 1638 return GNUNET_OK;
1690 } 1639 }
@@ -1768,16 +1717,14 @@ handle_receive_close (struct GNUNET_STREAM_Socket *socket,
1768 case STATE_LISTEN: 1717 case STATE_LISTEN:
1769 case STATE_HELLO_WAIT: 1718 case STATE_HELLO_WAIT:
1770 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1719 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1771 "%x: Ignoring RECEIVE_CLOSE as it cannot be handled now\n", 1720 "Ignoring RECEIVE_CLOSE as it cannot be handled now\n");
1772 socket->our_id);
1773 return GNUNET_OK; 1721 return GNUNET_OK;
1774 default: 1722 default:
1775 break; 1723 break;
1776 } 1724 }
1777 1725
1778 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1726 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1779 "%x: Received RECEIVE_CLOSE from %x\n", 1727 "Received RECEIVE_CLOSE from %x\n",
1780 socket->our_id,
1781 socket->other_peer); 1728 socket->other_peer);
1782 receive_close_ack = 1729 receive_close_ack =
1783 GNUNET_malloc (sizeof (struct GNUNET_STREAM_MessageHeader)); 1730 GNUNET_malloc (sizeof (struct GNUNET_STREAM_MessageHeader));
@@ -1886,16 +1833,14 @@ handle_close (struct GNUNET_STREAM_Socket *socket,
1886 case STATE_LISTEN: 1833 case STATE_LISTEN:
1887 case STATE_HELLO_WAIT: 1834 case STATE_HELLO_WAIT:
1888 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1835 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1889 "%x: Ignoring RECEIVE_CLOSE as it cannot be handled now\n", 1836 "Ignoring RECEIVE_CLOSE as it cannot be handled now\n");
1890 socket->our_id);
1891 return GNUNET_OK; 1837 return GNUNET_OK;
1892 default: 1838 default:
1893 break; 1839 break;
1894 } 1840 }
1895 1841
1896 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1842 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1897 "%x: Received CLOSE from %x\n", 1843 "Received CLOSE from %x\n",
1898 socket->our_id,
1899 socket->other_peer); 1844 socket->other_peer);
1900 close_ack = GNUNET_malloc (sizeof (struct GNUNET_STREAM_MessageHeader)); 1845 close_ack = GNUNET_malloc (sizeof (struct GNUNET_STREAM_MessageHeader));
1901 close_ack->header.size = htons (sizeof (struct GNUNET_STREAM_MessageHeader)); 1846 close_ack->header.size = htons (sizeof (struct GNUNET_STREAM_MessageHeader));
@@ -2035,8 +1980,7 @@ server_handle_hello (void *cls,
2035 if (GNUNET_PEER_search (sender) != socket->other_peer) 1980 if (GNUNET_PEER_search (sender) != socket->other_peer)
2036 { 1981 {
2037 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1982 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2038 "%x: Received HELLO from non-confirming peer\n", 1983 "Received HELLO from non-confirming peer\n");
2039 socket->our_id);
2040 return GNUNET_YES; 1984 return GNUNET_YES;
2041 } 1985 }
2042 1986
@@ -2044,8 +1988,7 @@ server_handle_hello (void *cls,
2044 ntohs (message->type)); 1988 ntohs (message->type));
2045 GNUNET_assert (socket->tunnel == tunnel); 1989 GNUNET_assert (socket->tunnel == tunnel);
2046 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1990 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2047 "%x: Received HELLO from %x\n", 1991 "Received HELLO from %x\n",
2048 socket->our_id,
2049 socket->other_peer); 1992 socket->other_peer);
2050 1993
2051 if (STATE_INIT == socket->state) 1994 if (STATE_INIT == socket->state)
@@ -2097,13 +2040,11 @@ server_handle_hello_ack (void *cls,
2097 if (STATE_HELLO_WAIT == socket->state) 2040 if (STATE_HELLO_WAIT == socket->state)
2098 { 2041 {
2099 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 2042 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2100 "%x: Received HELLO_ACK from %x\n", 2043 "Received HELLO_ACK from %x\n",
2101 socket->our_id,
2102 socket->other_peer); 2044 socket->other_peer);
2103 socket->read_sequence_number = ntohl (ack_message->sequence_number); 2045 socket->read_sequence_number = ntohl (ack_message->sequence_number);
2104 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 2046 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2105 "%x: Read sequence number %u\n", 2047 "Read sequence number %u\n",
2106 socket->our_id,
2107 (unsigned int) socket->read_sequence_number); 2048 (unsigned int) socket->read_sequence_number);
2108 socket->receiver_window_available = 2049 socket->receiver_window_available =
2109 ntohl (ack_message->receiver_window_size); 2050 ntohl (ack_message->receiver_window_size);
@@ -2360,8 +2301,7 @@ handle_ack (struct GNUNET_STREAM_Socket *socket,
2360 if (GNUNET_PEER_search (sender) != socket->other_peer) 2301 if (GNUNET_PEER_search (sender) != socket->other_peer)
2361 { 2302 {
2362 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 2303 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2363 "%x: Received ACK from non-confirming peer\n", 2304 "Received ACK from non-confirming peer\n");
2364 socket->our_id);
2365 return GNUNET_YES; 2305 return GNUNET_YES;
2366 } 2306 }
2367 2307
@@ -2373,8 +2313,7 @@ handle_ack (struct GNUNET_STREAM_Socket *socket,
2373 if (NULL == socket->write_handle) 2313 if (NULL == socket->write_handle)
2374 { 2314 {
2375 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 2315 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2376 "%x: Received DATA_ACK when write_handle is NULL\n", 2316 "Received DATA_ACK when write_handle is NULL\n");
2377 socket->our_id);
2378 return GNUNET_OK; 2317 return GNUNET_OK;
2379 } 2318 }
2380 /* FIXME: increment in the base sequence number is breaking current flow 2319 /* FIXME: increment in the base sequence number is breaking current flow
@@ -2383,12 +2322,9 @@ handle_ack (struct GNUNET_STREAM_Socket *socket,
2383 - ntohl (ack->base_sequence_number)) < GNUNET_STREAM_ACK_BITMAP_BIT_LENGTH)) 2322 - ntohl (ack->base_sequence_number)) < GNUNET_STREAM_ACK_BITMAP_BIT_LENGTH))
2384 { 2323 {
2385 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 2324 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2386 "%x: Received DATA_ACK with unexpected base sequence " 2325 "Received DATA_ACK with unexpected base sequence number\n");
2387 "number\n",
2388 socket->our_id);
2389 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 2326 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2390 "%x: Current write sequence: %u; Ack's base sequence: %u\n", 2327 "Current write sequence: %u; Ack's base sequence: %u\n",
2391 socket->our_id,
2392 socket->write_sequence_number, 2328 socket->write_sequence_number,
2393 ntohl (ack->base_sequence_number)); 2329 ntohl (ack->base_sequence_number));
2394 return GNUNET_OK; 2330 return GNUNET_OK;
@@ -2397,8 +2333,7 @@ handle_ack (struct GNUNET_STREAM_Socket *socket,
2397 acks */ 2333 acks */
2398 2334
2399 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 2335 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2400 "%x: Received DATA_ACK from %x\n", 2336 "Received DATA_ACK from %x\n",
2401 socket->our_id,
2402 socket->other_peer); 2337 socket->other_peer);
2403 2338
2404 /* Cancel the retransmission task */ 2339 /* Cancel the retransmission task */
@@ -2462,8 +2397,7 @@ handle_ack (struct GNUNET_STREAM_Socket *socket,
2462 socket->status, 2397 socket->status,
2463 socket->write_handle->size); 2398 socket->write_handle->size);
2464 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 2399 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2465 "%x: Write completion callback completed\n", 2400 "Write completion callback completed\n");
2466 socket->our_id);
2467 /* We are done with the write handle - Freeing it */ 2401 /* We are done with the write handle - Freeing it */
2468 GNUNET_free (socket->write_handle); 2402 GNUNET_free (socket->write_handle);
2469 socket->write_handle = NULL; 2403 socket->write_handle = NULL;
@@ -2609,15 +2543,12 @@ mesh_peer_connect_callback (void *cls,
2609 if (connected_peer != socket->other_peer) 2543 if (connected_peer != socket->other_peer)
2610 { 2544 {
2611 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 2545 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2612 "%x: A peer which is not our target has connected", 2546 "A peer which is not our target has connected to our tunnel\n");
2613 "to our tunnel\n",
2614 socket->our_id);
2615 return; 2547 return;
2616 } 2548 }
2617 2549
2618 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 2550 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2619 "%x: Target peer %x connected\n", 2551 "Target peer %x connected\n",
2620 socket->our_id,
2621 connected_peer); 2552 connected_peer);
2622 2553
2623 /* Set state to INIT */ 2554 /* Set state to INIT */
@@ -2655,8 +2586,7 @@ mesh_peer_disconnect_callback (void *cls,
2655 2586
2656 /* If the state is SHUTDOWN its ok; else set the state of the socket to SYSERR */ 2587 /* If the state is SHUTDOWN its ok; else set the state of the socket to SYSERR */
2657 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 2588 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2658 "%x: Other peer %x disconnected \n", 2589 "Other peer %x disconnected\n",
2659 socket->our_id,
2660 socket->other_peer); 2590 socket->other_peer);
2661} 2591}
2662 2592
@@ -2688,12 +2618,9 @@ new_tunnel_notify (void *cls,
2688 socket->tunnel = tunnel; 2618 socket->tunnel = tunnel;
2689 socket->session_id = 0; /* FIXME */ 2619 socket->session_id = 0; /* FIXME */
2690 socket->state = STATE_INIT; 2620 socket->state = STATE_INIT;
2691 socket->lsocket = lsocket; 2621 socket->lsocket = lsocket;
2692 socket->our_id = lsocket->our_id;
2693
2694 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 2622 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2695 "%x: Peer %x initiated tunnel to us\n", 2623 "Peer %x initiated tunnel to us\n",
2696 socket->our_id,
2697 socket->other_peer); 2624 socket->other_peer);
2698 2625
2699 /* FIXME: Copy MESH handle from lsocket to socket */ 2626 /* FIXME: Copy MESH handle from lsocket to socket */
@@ -2726,8 +2653,7 @@ tunnel_cleaner (void *cls,
2726 2653
2727 GNUNET_break_op(0); 2654 GNUNET_break_op(0);
2728 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 2655 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2729 "%x: Peer %x has terminated connection abruptly\n", 2656 "Peer %x has terminated connection abruptly\n",
2730 socket->our_id,
2731 socket->other_peer); 2657 socket->other_peer);
2732 2658
2733 socket->status = GNUNET_STREAM_SHUTDOWN; 2659 socket->status = GNUNET_STREAM_SHUTDOWN;
@@ -2788,7 +2714,6 @@ GNUNET_STREAM_open (const struct GNUNET_CONFIGURATION_Handle *cfg,
2788 ...) 2714 ...)
2789{ 2715{
2790 struct GNUNET_STREAM_Socket *socket; 2716 struct GNUNET_STREAM_Socket *socket;
2791 struct GNUNET_PeerIdentity own_peer_id;
2792 enum GNUNET_STREAM_Option option; 2717 enum GNUNET_STREAM_Option option;
2793 GNUNET_MESH_ApplicationType ports[] = {app_port, 0}; 2718 GNUNET_MESH_ApplicationType ports[] = {app_port, 0};
2794 va_list vargs; /* Variable arguments */ 2719 va_list vargs; /* Variable arguments */
@@ -2800,9 +2725,6 @@ GNUNET_STREAM_open (const struct GNUNET_CONFIGURATION_Handle *cfg,
2800 socket->other_peer = GNUNET_PEER_intern (target); 2725 socket->other_peer = GNUNET_PEER_intern (target);
2801 socket->open_cb = open_cb; 2726 socket->open_cb = open_cb;
2802 socket->open_cls = open_cb_cls; 2727 socket->open_cls = open_cb_cls;
2803 GNUNET_TESTING_get_peer_identity (cfg, &own_peer_id);
2804 socket->our_id = GNUNET_PEER_intern (&own_peer_id);
2805
2806 /* Set defaults */ 2728 /* Set defaults */
2807 socket->retransmit_timeout = 2729 socket->retransmit_timeout =
2808 GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, default_timeout); 2730 GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, default_timeout);
@@ -3049,14 +2971,11 @@ GNUNET_STREAM_listen (const struct GNUNET_CONFIGURATION_Handle *cfg,
3049 /* FIXME: Add variable args for passing configration options? */ 2971 /* FIXME: Add variable args for passing configration options? */
3050 struct GNUNET_STREAM_ListenSocket *lsocket; 2972 struct GNUNET_STREAM_ListenSocket *lsocket;
3051 GNUNET_MESH_ApplicationType ports[] = {app_port, 0}; 2973 GNUNET_MESH_ApplicationType ports[] = {app_port, 0};
3052 struct GNUNET_PeerIdentity our_peer_id;
3053 2974
3054 lsocket = GNUNET_malloc (sizeof (struct GNUNET_STREAM_ListenSocket)); 2975 lsocket = GNUNET_malloc (sizeof (struct GNUNET_STREAM_ListenSocket));
3055 lsocket->port = app_port; 2976 lsocket->port = app_port;
3056 lsocket->listen_cb = listen_cb; 2977 lsocket->listen_cb = listen_cb;
3057 lsocket->listen_cb_cls = listen_cb_cls; 2978 lsocket->listen_cb_cls = listen_cb_cls;
3058 GNUNET_TESTING_get_peer_identity (cfg, &our_peer_id);
3059 lsocket->our_id = GNUNET_PEER_intern (&our_peer_id);
3060 lsocket->mesh = GNUNET_MESH_connect (cfg, 2979 lsocket->mesh = GNUNET_MESH_connect (cfg,
3061 10, /* FIXME: QUEUE size as parameter? */ 2980 10, /* FIXME: QUEUE size as parameter? */
3062 lsocket, /* Closure */ 2981 lsocket, /* Closure */
@@ -3234,8 +3153,7 @@ GNUNET_STREAM_read (struct GNUNET_STREAM_Socket *socket,
3234 struct GNUNET_STREAM_IOReadHandle *read_handle; 3153 struct GNUNET_STREAM_IOReadHandle *read_handle;
3235 3154
3236 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 3155 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
3237 "%x: %s()\n", 3156 "%s()\n",
3238 socket->our_id,
3239 __func__); 3157 __func__);
3240 3158
3241 /* Return NULL if there is already a read handle; the user has to cancel that 3159 /* Return NULL if there is already a read handle; the user has to cancel that
@@ -3252,8 +3170,7 @@ GNUNET_STREAM_read (struct GNUNET_STREAM_Socket *socket,
3252 case STATE_CLOSE_WAIT: 3170 case STATE_CLOSE_WAIT:
3253 proc (proc_cls, GNUNET_STREAM_SHUTDOWN, NULL, 0); 3171 proc (proc_cls, GNUNET_STREAM_SHUTDOWN, NULL, 0);
3254 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 3172 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
3255 "%x: %s() END\n", 3173 "%s() END\n",
3256 socket->our_id,
3257 __func__); 3174 __func__);
3258 return NULL; 3175 return NULL;
3259 default: 3176 default:
@@ -3280,8 +3197,7 @@ GNUNET_STREAM_read (struct GNUNET_STREAM_Socket *socket,
3280 &read_io_timeout, 3197 &read_io_timeout,
3281 socket); 3198 socket);
3282 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 3199 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
3283 "%x: %s() END\n", 3200 "%s() END\n",
3284 socket->our_id,
3285 __func__); 3201 __func__);
3286 return read_handle; 3202 return read_handle;
3287} 3203}