Changeset 973ef9fc in mainline for uspace/srv/net/tl/tcp/tcp.c
- Timestamp:
- 2010-12-25T21:20:28Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 631ee0c
- Parents:
- 1bfd3d3 (diff), 09178b7f (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
r1bfd3d3 r973ef9fc 160 160 }; 161 161 162 static int tcp_release_and_return(packet_t , int);162 static int tcp_release_and_return(packet_t *, int); 163 163 static void tcp_prepare_operation_header(socket_core_t *, tcp_socket_data_t *, 164 164 tcp_header_t *, int synchronize, int); … … 171 171 static int tcp_release_after_timeout(void *); 172 172 173 static int tcp_process_packet(device_id_t, packet_t , services_t);173 static int tcp_process_packet(device_id_t, packet_t *, services_t); 174 174 static int tcp_connect_core(socket_core_t *, socket_cores_t *, 175 175 struct sockaddr *, socklen_t); 176 176 static int tcp_queue_prepare_packet(socket_core_t *, tcp_socket_data_t *, 177 packet_t , size_t);178 static int tcp_queue_packet(socket_core_t *, tcp_socket_data_t *, packet_t ,177 packet_t *, size_t); 178 static int tcp_queue_packet(socket_core_t *, tcp_socket_data_t *, packet_t *, 179 179 size_t); 180 static packet_t tcp_get_packets_to_send(socket_core_t *, tcp_socket_data_t *);181 static void tcp_send_packets(device_id_t, packet_t );180 static packet_t *tcp_get_packets_to_send(socket_core_t *, tcp_socket_data_t *); 181 static void tcp_send_packets(device_id_t, packet_t *); 182 182 183 183 static void tcp_process_acknowledgement(socket_core_t *, tcp_socket_data_t *, 184 184 tcp_header_t *); 185 static packet_t tcp_send_prepare_packet(socket_core_t *, tcp_socket_data_t *,186 packet_t , size_t, size_t);187 static packet_t tcp_prepare_copy(socket_core_t *, tcp_socket_data_t *, packet_t,188 size_t, size_t);185 static packet_t *tcp_send_prepare_packet(socket_core_t *, tcp_socket_data_t *, 186 packet_t *, size_t, size_t); 187 static packet_t *tcp_prepare_copy(socket_core_t *, tcp_socket_data_t *, 188 packet_t *, size_t, size_t); 189 189 /* static */ void tcp_retransmit_packet(socket_core_t *, tcp_socket_data_t *, 190 190 size_t); 191 static int tcp_create_notification_packet(packet_t * , socket_core_t *,191 static int tcp_create_notification_packet(packet_t **, socket_core_t *, 192 192 tcp_socket_data_t *, int, int); 193 193 static void tcp_refresh_socket_data(tcp_socket_data_t *); … … 196 196 197 197 static int tcp_process_listen(socket_core_t *, tcp_socket_data_t *, 198 tcp_header_t *, packet_t , struct sockaddr *, struct sockaddr *, size_t);198 tcp_header_t *, packet_t *, struct sockaddr *, struct sockaddr *, size_t); 199 199 static int tcp_process_syn_sent(socket_core_t *, tcp_socket_data_t *, 200 tcp_header_t *, packet_t );200 tcp_header_t *, packet_t *); 201 201 static int tcp_process_syn_received(socket_core_t *, tcp_socket_data_t *, 202 tcp_header_t *, packet_t );202 tcp_header_t *, packet_t *); 203 203 static int tcp_process_established(socket_core_t *, tcp_socket_data_t *, 204 tcp_header_t *, packet_t , int, size_t);204 tcp_header_t *, packet_t *, int, size_t); 205 205 static int tcp_queue_received_packet(socket_core_t *, tcp_socket_data_t *, 206 packet_t , int, size_t);207 208 static int tcp_received_msg(device_id_t, packet_t , services_t, services_t);206 packet_t *, int, size_t); 207 208 static int tcp_received_msg(device_id_t, packet_t *, services_t, services_t); 209 209 static int tcp_process_client_messages(ipc_callid_t, ipc_call_t); 210 210 … … 262 262 } 263 263 264 int tcp_received_msg(device_id_t device_id, packet_t packet,264 int tcp_received_msg(device_id_t device_id, packet_t *packet, 265 265 services_t receiver, services_t error) 266 266 { … … 280 280 } 281 281 282 int tcp_process_packet(device_id_t device_id, packet_t packet, services_t error)282 int tcp_process_packet(device_id_t device_id, packet_t *packet, services_t error) 283 283 { 284 284 size_t length; … … 288 288 socket_core_t *socket; 289 289 tcp_socket_data_t *socket_data; 290 packet_t next_packet;290 packet_t *next_packet; 291 291 size_t total_length; 292 292 uint32_t checksum; … … 453 453 454 454 has_error_service: 455 fibril_rwlock_ read_unlock(&tcp_globals.lock);455 fibril_rwlock_write_unlock(&tcp_globals.lock); 456 456 457 457 /* TODO error reporting/handling */ … … 493 493 494 494 int tcp_process_established(socket_core_t *socket, tcp_socket_data_t * 495 socket_data, tcp_header_t *header, packet_t packet, int fragments,495 socket_data, tcp_header_t *header, packet_t *packet, int fragments, 496 496 size_t total_length) 497 497 { 498 packet_t next_packet;499 packet_t tmp_packet;498 packet_t *next_packet; 499 packet_t *tmp_packet; 500 500 uint32_t old_incoming; 501 501 size_t order; … … 801 801 802 802 int tcp_queue_received_packet(socket_core_t *socket, 803 tcp_socket_data_t *socket_data, packet_t packet, int fragments,803 tcp_socket_data_t *socket_data, packet_t *packet, int fragments, 804 804 size_t total_length) 805 805 { … … 829 829 /* Notify the destination socket */ 830 830 async_msg_5(socket->phone, NET_SOCKET_RECEIVED, 831 ( ipcarg_t) socket->socket_id,831 (sysarg_t) socket->socket_id, 832 832 ((packet_dimension->content < socket_data->data_fragment_size) ? 833 833 packet_dimension->content : socket_data->data_fragment_size), 0, 0, 834 ( ipcarg_t) fragments);834 (sysarg_t) fragments); 835 835 836 836 return EOK; … … 838 838 839 839 int tcp_process_syn_sent(socket_core_t *socket, tcp_socket_data_t * 840 socket_data, tcp_header_t *header, packet_t packet)841 { 842 packet_t next_packet;840 socket_data, tcp_header_t *header, packet_t *packet) 841 { 842 packet_t *next_packet; 843 843 int rc; 844 844 … … 897 897 int tcp_process_listen(socket_core_t *listening_socket, 898 898 tcp_socket_data_t *listening_socket_data, tcp_header_t *header, 899 packet_t packet, struct sockaddr *src, struct sockaddr *dest,899 packet_t *packet, struct sockaddr *src, struct sockaddr *dest, 900 900 size_t addrlen) 901 901 { 902 packet_t next_packet;902 packet_t *next_packet; 903 903 socket_core_t *socket; 904 904 tcp_socket_data_t *socket_data; … … 1056 1056 1057 1057 int tcp_process_syn_received(socket_core_t *socket, 1058 tcp_socket_data_t *socket_data, tcp_header_t *header, packet_t packet)1058 tcp_socket_data_t *socket_data, tcp_header_t *header, packet_t *packet) 1059 1059 { 1060 1060 socket_core_t *listening_socket; … … 1090 1090 /* Notify the destination socket */ 1091 1091 async_msg_5(socket->phone, NET_SOCKET_ACCEPTED, 1092 ( ipcarg_t) listening_socket->socket_id,1092 (sysarg_t) listening_socket->socket_id, 1093 1093 socket_data->data_fragment_size, TCP_HEADER_SIZE, 1094 0, ( ipcarg_t) socket->socket_id);1094 0, (sysarg_t) socket->socket_id); 1095 1095 1096 1096 fibril_rwlock_write_unlock(socket_data->local_lock); … … 1127 1127 size_t number; 1128 1128 size_t length; 1129 packet_t packet;1130 packet_t next;1131 packet_t acknowledged = NULL;1129 packet_t *packet; 1130 packet_t *next; 1131 packet_t *acknowledged = NULL; 1132 1132 uint32_t old; 1133 1133 … … 1232 1232 ipc_call_t *answer, int *answer_count) 1233 1233 { 1234 packet_t packet;1234 packet_t *packet; 1235 1235 int rc; 1236 1236 … … 1240 1240 1241 1241 *answer_count = 0; 1242 switch (IPC_GET_ METHOD(*call)) {1242 switch (IPC_GET_IMETHOD(*call)) { 1243 1243 case NET_TL_RECEIVED: 1244 1244 // fibril_rwlock_read_lock(&tcp_globals.lock); … … 1323 1323 1324 1324 /* Process the call */ 1325 switch (IPC_GET_ METHOD(call)) {1325 switch (IPC_GET_IMETHOD(call)) { 1326 1326 case IPC_M_PHONE_HUNGUP: 1327 1327 keep_on_going = false; … … 1365 1365 1366 1366 case NET_SOCKET_BIND: 1367 res = data_receive((void **) &addr, &addrlen); 1367 res = async_data_write_accept((void **) &addr, false, 1368 0, 0, 0, &addrlen); 1368 1369 if (res != EOK) 1369 1370 break; … … 1402 1403 1403 1404 case NET_SOCKET_CONNECT: 1404 res = data_receive((void **) &addr, &addrlen); 1405 res = async_data_write_accept((void **) &addr, false, 1406 0, 0, 0, &addrlen); 1405 1407 if (res != EOK) 1406 1408 break; … … 1453 1455 1454 1456 case NET_SOCKET_SENDTO: 1455 res = data_receive((void **) &addr, &addrlen); 1457 res = async_data_write_accept((void **) &addr, false, 1458 0, 0, 0, &addrlen); 1456 1459 if (res != EOK) 1457 1460 break; … … 1654 1657 socket_data, size_t sequence_number) 1655 1658 { 1656 packet_t packet;1657 packet_t copy;1659 packet_t *packet; 1660 packet_t *copy; 1658 1661 size_t data_length; 1659 1662 … … 1736 1739 { 1737 1740 tcp_socket_data_t *socket_data; 1738 packet_t packet;1741 packet_t *packet; 1739 1742 int rc; 1740 1743 … … 1800 1803 fibril_rwlock_write_unlock(socket_data->local_lock); 1801 1804 1805 socket_data->state = TCP_SOCKET_SYN_SENT; 1806 1802 1807 /* Send the packet */ 1803 1808 printf("connecting %d\n", packet_get_id(packet)); … … 1824 1829 1825 1830 int tcp_queue_prepare_packet(socket_core_t *socket, 1826 tcp_socket_data_t *socket_data, packet_t packet, size_t data_length)1831 tcp_socket_data_t *socket_data, packet_t *packet, size_t data_length) 1827 1832 { 1828 1833 tcp_header_t *header; … … 1855 1860 1856 1861 int tcp_queue_packet(socket_core_t *socket, tcp_socket_data_t *socket_data, 1857 packet_t packet, size_t data_length)1862 packet_t *packet, size_t data_length) 1858 1863 { 1859 1864 int rc; … … 1876 1881 } 1877 1882 1878 packet_t tcp_get_packets_to_send(socket_core_t *socket, tcp_socket_data_t *1883 packet_t *tcp_get_packets_to_send(socket_core_t *socket, tcp_socket_data_t * 1879 1884 socket_data) 1880 1885 { 1881 packet_t packet;1882 packet_t copy;1883 packet_t sending = NULL;1884 packet_t previous = NULL;1886 packet_t *packet; 1887 packet_t *copy; 1888 packet_t *sending = NULL; 1889 packet_t *previous = NULL; 1885 1890 size_t data_length; 1886 1891 int rc; … … 1936 1941 } 1937 1942 1938 packet_t tcp_send_prepare_packet(socket_core_t *socket, tcp_socket_data_t *1939 socket_data, packet_t packet, size_t data_length, size_t sequence_number)1943 packet_t *tcp_send_prepare_packet(socket_core_t *socket, tcp_socket_data_t * 1944 socket_data, packet_t *packet, size_t data_length, size_t sequence_number) 1940 1945 { 1941 1946 tcp_header_t *header; … … 1997 2002 } 1998 2003 1999 packet_t tcp_prepare_copy(socket_core_t *socket, tcp_socket_data_t *2000 socket_data, packet_t packet, size_t data_length, size_t sequence_number)2001 { 2002 packet_t copy;2004 packet_t *tcp_prepare_copy(socket_core_t *socket, tcp_socket_data_t * 2005 socket_data, packet_t *packet, size_t data_length, size_t sequence_number) 2006 { 2007 packet_t *copy; 2003 2008 2004 2009 assert(socket); … … 2015 2020 } 2016 2021 2017 void tcp_send_packets(device_id_t device_id, packet_t packet)2018 { 2019 packet_t next;2022 void tcp_send_packets(device_id_t device_id, packet_t *packet) 2023 { 2024 packet_t *next; 2020 2025 2021 2026 while (packet) { … … 2082 2087 if (!fibril) { 2083 2088 free(operation_timeout); 2084 return EPARTY; /* FIXME: use another EC */ 2085 } 2089 return ENOMEM; 2090 } 2091 2086 2092 // fibril_mutex_lock(&socket_data->operation.mutex); 2087 2093 /* Start the timeout fibril */ … … 2097 2103 tcp_socket_data_t *socket_data; 2098 2104 int packet_id; 2099 packet_t packet;2105 packet_t *packet; 2100 2106 size_t length; 2101 2107 int rc; … … 2155 2161 tcp_socket_data_t *socket_data; 2156 2162 packet_dimension_t *packet_dimension; 2157 packet_t packet;2163 packet_t *packet; 2158 2164 size_t total_length; 2159 2165 tcp_header_t *header; … … 2229 2235 socket_core_t *socket; 2230 2236 tcp_socket_data_t *socket_data; 2231 packet_t packet;2237 packet_t *packet; 2232 2238 int rc; 2233 2239 … … 2293 2299 } 2294 2300 2295 int tcp_create_notification_packet(packet_t * packet, socket_core_t *socket,2301 int tcp_create_notification_packet(packet_t **packet, socket_core_t *socket, 2296 2302 tcp_socket_data_t *socket_data, int synchronize, int finalize) 2297 2303 { … … 2442 2448 * @return The result parameter. 2443 2449 */ 2444 int tcp_release_and_return(packet_t packet, int result)2450 int tcp_release_and_return(packet_t *packet, int result) 2445 2451 { 2446 2452 pq_release_remote(tcp_globals.net_phone, packet_get_id(packet)); … … 2481 2487 * result. 2482 2488 */ 2483 if ((IPC_GET_ METHOD(call) == IPC_M_PHONE_HUNGUP) ||2489 if ((IPC_GET_IMETHOD(call) == IPC_M_PHONE_HUNGUP) || 2484 2490 (res == EHANGUP)) 2485 2491 return;
Note:
See TracChangeset
for help on using the changeset viewer.