Changeset a676574 in mainline for uspace/srv/net/tl/tcp/tcp.c
- Timestamp:
- 2011-01-09T12:18:00Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 54de5ebd
- Parents:
- a3eeef45 (diff), 9d12059 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/net/tl/tcp/tcp.c
ra3eeef45 ra676574 154 154 155 155 /** Port map key. */ 156 char*key;156 uint8_t *key; 157 157 158 158 /** Port map key length. */ … … 205 205 static int tcp_queue_received_packet(socket_core_t *, tcp_socket_data_t *, 206 206 packet_t *, int, size_t); 207 static void tcp_queue_received_end_of_data(socket_core_t *socket); 207 208 208 209 static int tcp_received_msg(device_id_t, packet_t *, services_t, services_t); … … 357 358 /* Find the destination socket */ 358 359 socket = socket_port_find(&tcp_globals.sockets, 359 ntohs(header->destination_port), ( const char*) src, addrlen);360 ntohs(header->destination_port), (uint8_t *) src, addrlen); 360 361 if (!socket) { 361 362 /* Find the listening destination socket */ 362 363 socket = socket_port_find(&tcp_globals.sockets, 363 ntohs(header->destination_port), SOCKET_MAP_KEY_LISTENING,364 0);364 ntohs(header->destination_port), 365 (uint8_t *) SOCKET_MAP_KEY_LISTENING, 0); 365 366 } 366 367 … … 453 454 454 455 has_error_service: 455 fibril_rwlock_ read_unlock(&tcp_globals.lock);456 fibril_rwlock_write_unlock(&tcp_globals.lock); 456 457 457 458 /* TODO error reporting/handling */ … … 504 505 size_t offset; 505 506 uint32_t new_sequence_number; 507 bool forced_ack; 506 508 int rc; 507 509 … … 512 514 assert(packet); 513 515 516 forced_ack = false; 517 514 518 new_sequence_number = ntohl(header->sequence_number); 515 519 old_incoming = socket_data->next_incoming; 516 520 517 if (header->finalize) 518 socket_data->fin_incoming = new_sequence_number; 521 if (header->finalize) { 522 socket_data->fin_incoming = new_sequence_number + 523 total_length - TCP_HEADER_LENGTH(header); 524 } 519 525 520 526 /* Trim begining if containing expected data */ … … 760 766 /* Release duplicite or restricted */ 761 767 pq_release_remote(tcp_globals.net_phone, packet_get_id(packet)); 762 } 763 764 /* Change state according to the acknowledging incoming fin */ 765 if (IS_IN_INTERVAL_OVERFLOW(old_incoming, socket_data->fin_incoming, 766 socket_data->next_incoming)) { 768 forced_ack = true; 769 } 770 771 /* If next in sequence is an incoming FIN */ 772 if (socket_data->next_incoming == socket_data->fin_incoming) { 773 /* Advance sequence number */ 774 socket_data->next_incoming += 1; 775 776 /* Handle FIN */ 767 777 switch (socket_data->state) { 768 778 case TCP_SOCKET_FIN_WAIT_1: … … 771 781 socket_data->state = TCP_SOCKET_CLOSING; 772 782 break; 773 /*case TCP_ESTABLISHED:*/ 783 case TCP_SOCKET_ESTABLISHED: 784 /* Queue end-of-data marker on the socket. */ 785 tcp_queue_received_end_of_data(socket); 786 socket_data->state = TCP_SOCKET_CLOSE_WAIT; 787 break; 774 788 default: 775 789 socket_data->state = TCP_SOCKET_CLOSE_WAIT; … … 779 793 780 794 packet = tcp_get_packets_to_send(socket, socket_data); 781 if (!packet ) {795 if (!packet && (socket_data->next_incoming != old_incoming || forced_ack)) { 782 796 /* Create the notification packet */ 783 797 rc = tcp_create_notification_packet(&packet, socket, … … 835 849 836 850 return EOK; 851 } 852 853 /** Queue end-of-data marker on the socket. 854 * 855 * Next element in the sequence space is FIN. Queue end-of-data marker 856 * on the socket. 857 * 858 * @param socket Socket 859 */ 860 static void tcp_queue_received_end_of_data(socket_core_t *socket) 861 { 862 assert(socket != NULL); 863 864 /* Notify the destination socket */ 865 async_msg_5(socket->phone, NET_SOCKET_RECEIVED, 866 (sysarg_t) socket->socket_id, 867 0, 0, 0, 868 (sysarg_t) 0 /* 0 fragments == no more data */); 837 869 } 838 870 … … 966 998 /* Find the destination socket */ 967 999 listening_socket = socket_port_find(&tcp_globals.sockets, 968 listening_port, SOCKET_MAP_KEY_LISTENING, 0);1000 listening_port, (uint8_t *) SOCKET_MAP_KEY_LISTENING, 0); 969 1001 if (!listening_socket || 970 1002 (listening_socket->socket_id != listening_socket_id)) { … … 990 1022 991 1023 rc = socket_port_add(&tcp_globals.sockets, listening_port, socket, 992 ( const char*) socket_data->addr, socket_data->addrlen);1024 (uint8_t *) socket_data->addr, socket_data->addrlen); 993 1025 assert(socket == socket_port_find(&tcp_globals.sockets, listening_port, 994 ( const char*) socket_data->addr, socket_data->addrlen));1026 (uint8_t *) socket_data->addr, socket_data->addrlen)); 995 1027 996 1028 // rc = socket_bind_free_port(&tcp_globals.sockets, socket, … … 1803 1835 fibril_rwlock_write_unlock(socket_data->local_lock); 1804 1836 1837 socket_data->state = TCP_SOCKET_SYN_SENT; 1838 1805 1839 /* Send the packet */ 1806 1840 printf("connecting %d\n", packet_get_id(packet)); … … 2075 2109 2076 2110 /* Copy the key */ 2077 operation_timeout->key = (( char*) operation_timeout) +2111 operation_timeout->key = ((uint8_t *) operation_timeout) + 2078 2112 sizeof(*operation_timeout); 2079 2113 operation_timeout->key_length = socket->key_length; … … 2085 2119 if (!fibril) { 2086 2120 free(operation_timeout); 2087 return EPARTY; /* FIXME: use another EC */ 2088 } 2121 return ENOMEM; 2122 } 2123 2089 2124 // fibril_mutex_lock(&socket_data->operation.mutex); 2090 2125 /* Start the timeout fibril */ … … 2209 2244 2210 2245 tcp_prepare_operation_header(socket, socket_data, header, 0, 0); 2211 rc = tcp_queue_packet(socket, socket_data, packet, 0);2246 rc = tcp_queue_packet(socket, socket_data, packet, total_length); 2212 2247 if (rc != EOK) 2213 2248 return rc;
Note:
See TracChangeset
for help on using the changeset viewer.