Changes in uspace/srv/net/tl/tcp/tcp.c [49bd793b:28a3e74] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/net/tl/tcp/tcp.c
r49bd793b r28a3e74 169 169 static int tcp_release_after_timeout(void *); 170 170 171 static int tcp_process_packet( nic_device_id_t, packet_t *, services_t);171 static int tcp_process_packet(device_id_t, packet_t *, services_t); 172 172 static int tcp_connect_core(socket_core_t *, socket_cores_t *, 173 173 struct sockaddr *, socklen_t); … … 177 177 size_t); 178 178 static packet_t *tcp_get_packets_to_send(socket_core_t *, tcp_socket_data_t *); 179 static void tcp_send_packets( nic_device_id_t, packet_t *);179 static void tcp_send_packets(device_id_t, packet_t *); 180 180 181 181 static void tcp_process_acknowledgement(socket_core_t *, tcp_socket_data_t *, … … 205 205 static void tcp_queue_received_end_of_data(socket_core_t *socket); 206 206 207 static int tcp_received_msg(nic_device_id_t, packet_t *, services_t, services_t); 208 static int tcp_process_client_messages(async_sess_t *, ipc_callid_t, 209 ipc_call_t); 207 static int tcp_received_msg(device_id_t, packet_t *, services_t, services_t); 208 static int tcp_process_client_messages(ipc_callid_t, ipc_call_t); 210 209 211 210 static int tcp_listen_message(socket_cores_t *, int, int); … … 220 219 tcp_globals_t tcp_globals; 221 220 222 int tcp_received_msg( nic_device_id_t device_id, packet_t *packet,221 int tcp_received_msg(device_id_t device_id, packet_t *packet, 223 222 services_t receiver, services_t error) 224 223 { … … 238 237 } 239 238 240 int tcp_process_packet( nic_device_id_t device_id, packet_t *packet, services_t error)239 int tcp_process_packet(device_id_t device_id, packet_t *packet, services_t error) 241 240 { 242 241 size_t length; … … 325 324 326 325 if (!socket) { 327 if (tl_prepare_icmp_packet(tcp_globals.net_ sess,328 tcp_globals.icmp_ sess, packet, error) == EOK) {329 icmp_destination_unreachable_msg(tcp_globals.icmp_ sess,326 if (tl_prepare_icmp_packet(tcp_globals.net_phone, 327 tcp_globals.icmp_phone, packet, error) == EOK) { 328 icmp_destination_unreachable_msg(tcp_globals.icmp_phone, 330 329 ICMP_PORT_UNREACH, 0, packet); 331 330 } … … 398 397 fibril_rwlock_write_unlock(socket_data->local_lock); 399 398 400 rc = tl_prepare_icmp_packet(tcp_globals.net_ sess,401 tcp_globals.icmp_ sess, packet, error);399 rc = tl_prepare_icmp_packet(tcp_globals.net_phone, 400 tcp_globals.icmp_phone, packet, error); 402 401 if (rc == EOK) { 403 402 /* Checksum error ICMP */ 404 icmp_parameter_problem_msg(tcp_globals.icmp_ sess,403 icmp_parameter_problem_msg(tcp_globals.icmp_phone, 405 404 ICMP_PARAM_POINTER, 406 405 ((size_t) ((void *) &header->checksum)) - … … 440 439 break; 441 440 default: 442 pq_release_remote(tcp_globals.net_ sess, packet_get_id(packet));441 pq_release_remote(tcp_globals.net_phone, packet_get_id(packet)); 443 442 } 444 443 … … 477 476 old_incoming = socket_data->next_incoming; 478 477 479 if ( GET_TCP_HEADER_FINALIZE(header)) {478 if (header->finalize) { 480 479 socket_data->fin_incoming = new_sequence_number + 481 480 total_length - TCP_HEADER_LENGTH(header); … … 503 502 /* Release the acknowledged packets */ 504 503 next_packet = pq_next(packet); 505 pq_release_remote(tcp_globals.net_ sess,504 pq_release_remote(tcp_globals.net_phone, 506 505 packet_get_id(packet)); 507 506 packet = next_packet; … … 562 561 next_packet = pq_next(next_packet); 563 562 pq_insert_after(tmp_packet, next_packet); 564 pq_release_remote(tcp_globals.net_ sess,563 pq_release_remote(tcp_globals.net_phone, 565 564 packet_get_id(tmp_packet)); 566 565 } … … 599 598 if (packet == socket_data->incoming) 600 599 socket_data->incoming = next_packet; 601 pq_release_remote(tcp_globals.net_ sess,600 pq_release_remote(tcp_globals.net_phone, 602 601 packet_get_id(packet)); 603 602 packet = next_packet; … … 622 621 if (length <= 0) { 623 622 /* Remove the empty packet */ 624 pq_release_remote(tcp_globals.net_ sess,623 pq_release_remote(tcp_globals.net_phone, 625 624 packet_get_id(packet)); 626 625 packet = next_packet; … … 669 668 } 670 669 /* Remove the duplicit or corrupted packet */ 671 pq_release_remote(tcp_globals.net_ sess,670 pq_release_remote(tcp_globals.net_phone, 672 671 packet_get_id(packet)); 673 672 packet = next_packet; … … 696 695 if (rc != EOK) { 697 696 /* Remove the corrupted packets */ 698 pq_release_remote(tcp_globals.net_ sess,697 pq_release_remote(tcp_globals.net_phone, 699 698 packet_get_id(packet)); 700 pq_release_remote(tcp_globals.net_ sess,699 pq_release_remote(tcp_globals.net_phone, 701 700 packet_get_id(next_packet)); 702 701 } else { … … 709 708 new_sequence_number, length); 710 709 if (rc != EOK) { 711 pq_release_remote(tcp_globals.net_ sess,710 pq_release_remote(tcp_globals.net_phone, 712 711 packet_get_id(next_packet)); 713 712 } 714 713 rc = pq_insert_after(packet, next_packet); 715 714 if (rc != EOK) { 716 pq_release_remote(tcp_globals.net_ sess,715 pq_release_remote(tcp_globals.net_phone, 717 716 packet_get_id(next_packet)); 718 717 } … … 723 722 printf("unexpected\n"); 724 723 /* Release duplicite or restricted */ 725 pq_release_remote(tcp_globals.net_ sess, packet_get_id(packet));724 pq_release_remote(tcp_globals.net_phone, packet_get_id(packet)); 726 725 forced_ack = true; 727 726 } … … 791 790 if (rc != EOK) 792 791 return tcp_release_and_return(packet, rc); 793 rc = tl_get_ip_packet_dimension(tcp_globals.ip_ sess,792 rc = tl_get_ip_packet_dimension(tcp_globals.ip_phone, 794 793 &tcp_globals.dimensions, socket_data->device_id, &packet_dimension); 795 794 if (rc != EOK) … … 800 799 801 800 /* Notify the destination socket */ 802 async_ exch_t *exch = async_exchange_begin(socket->sess);803 async_msg_5(exch, NET_SOCKET_RECEIVED,(sysarg_t) socket->socket_id,801 async_msg_5(socket->phone, NET_SOCKET_RECEIVED, 802 (sysarg_t) socket->socket_id, 804 803 ((packet_dimension->content < socket_data->data_fragment_size) ? 805 804 packet_dimension->content : socket_data->data_fragment_size), 0, 0, 806 805 (sysarg_t) fragments); 807 async_exchange_end(exch);808 806 809 807 return EOK; … … 822 820 823 821 /* Notify the destination socket */ 824 async_ exch_t *exch = async_exchange_begin(socket->sess);825 async_msg_5(exch, NET_SOCKET_RECEIVED,(sysarg_t) socket->socket_id,826 0, 0, 0, (sysarg_t) 0 /* 0 fragments == no more data */);827 async_exchange_end(exch);822 async_msg_5(socket->phone, NET_SOCKET_RECEIVED, 823 (sysarg_t) socket->socket_id, 824 0, 0, 0, 825 (sysarg_t) 0 /* 0 fragments == no more data */); 828 826 } 829 827 … … 840 838 assert(packet); 841 839 842 if (! GET_TCP_HEADER_SYNCHRONIZE(header))840 if (!header->synchronize) 843 841 return tcp_release_and_return(packet, EINVAL); 844 842 … … 851 849 next_packet = pq_detach(packet); 852 850 if (next_packet) { 853 pq_release_remote(tcp_globals.net_ sess,851 pq_release_remote(tcp_globals.net_phone, 854 852 packet_get_id(next_packet)); 855 853 } … … 905 903 assert(packet); 906 904 907 if (! GET_TCP_HEADER_SYNCHRONIZE(header))905 if (!header->synchronize) 908 906 return tcp_release_and_return(packet, EINVAL); 909 907 … … 938 936 /* Create a socket */ 939 937 socket_id = -1; 940 rc = socket_create(socket_data->local_sockets, listening_socket-> sess,938 rc = socket_create(socket_data->local_sockets, listening_socket->phone, 941 939 socket_data, &socket_id); 942 940 if (rc != EOK) { … … 991 989 fibril_rwlock_write_unlock(&tcp_globals.lock); 992 990 if (rc != EOK) { 993 socket_destroy(tcp_globals.net_ sess, socket->socket_id,991 socket_destroy(tcp_globals.net_phone, socket->socket_id, 994 992 socket_data->local_sockets, &tcp_globals.sockets, 995 993 tcp_free_socket_data); … … 1003 1001 next_packet = pq_detach(packet); 1004 1002 if (next_packet) { 1005 pq_release_remote(tcp_globals.net_ sess,1003 pq_release_remote(tcp_globals.net_phone, 1006 1004 packet_get_id(next_packet)); 1007 1005 } … … 1012 1010 packet_get_data_length(packet) - sizeof(*header)); 1013 1011 if (rc != EOK) { 1014 socket_destroy(tcp_globals.net_ sess, socket->socket_id,1012 socket_destroy(tcp_globals.net_phone, socket->socket_id, 1015 1013 socket_data->local_sockets, &tcp_globals.sockets, 1016 1014 tcp_free_socket_data); … … 1023 1021 rc = tcp_queue_packet(socket, socket_data, packet, 1); 1024 1022 if (rc != EOK) { 1025 socket_destroy(tcp_globals.net_ sess, socket->socket_id,1023 socket_destroy(tcp_globals.net_phone, socket->socket_id, 1026 1024 socket_data->local_sockets, &tcp_globals.sockets, 1027 1025 tcp_free_socket_data); … … 1031 1029 packet = tcp_get_packets_to_send(socket, socket_data); 1032 1030 if (!packet) { 1033 socket_destroy(tcp_globals.net_ sess, socket->socket_id,1031 socket_destroy(tcp_globals.net_phone, socket->socket_id, 1034 1032 socket_data->local_sockets, &tcp_globals.sockets, 1035 1033 tcp_free_socket_data); … … 1059 1057 assert(packet); 1060 1058 1061 if (! GET_TCP_HEADER_ACKNOWLEDGE(header))1059 if (!header->acknowledge) 1062 1060 return tcp_release_and_return(packet, EINVAL); 1063 1061 … … 1066 1064 1067 1065 socket_data->next_incoming = ntohl(header->sequence_number); /* + 1; */ 1068 pq_release_remote(tcp_globals.net_ sess, packet_get_id(packet));1066 pq_release_remote(tcp_globals.net_phone, packet_get_id(packet)); 1069 1067 socket_data->state = TCP_SOCKET_ESTABLISHED; 1070 1068 listening_socket = socket_cores_find(socket_data->local_sockets, … … 1080 1078 if (rc == EOK) { 1081 1079 /* Notify the destination socket */ 1082 async_exch_t *exch = async_exchange_begin(socket->sess); 1083 async_msg_5(exch, NET_SOCKET_ACCEPTED, 1080 async_msg_5(socket->phone, NET_SOCKET_ACCEPTED, 1084 1081 (sysarg_t) listening_socket->socket_id, 1085 1082 socket_data->data_fragment_size, TCP_HEADER_SIZE, 1086 1083 0, (sysarg_t) socket->socket_id); 1087 async_exchange_end(exch);1088 1084 1089 1085 fibril_rwlock_write_unlock(socket_data->local_lock); … … 1130 1126 assert(header); 1131 1127 1132 if (! GET_TCP_HEADER_ACKNOWLEDGE(header))1128 if (!header->acknowledge) 1133 1129 return; 1134 1130 … … 1181 1177 /* Add to acknowledged or release */ 1182 1178 if (pq_add(&acknowledged, packet, 0, 0) != EOK) 1183 pq_release_remote(tcp_globals.net_ sess,1179 pq_release_remote(tcp_globals.net_phone, 1184 1180 packet_get_id(packet)); 1185 1181 packet = next; … … 1190 1186 /* Release acknowledged */ 1191 1187 if (acknowledged) { 1192 pq_release_remote(tcp_globals.net_ sess,1188 pq_release_remote(tcp_globals.net_phone, 1193 1189 packet_get_id(acknowledged)); 1194 1190 } … … 1234 1230 assert(answer); 1235 1231 assert(answer_count); 1236 1232 1237 1233 *answer_count = 0; 1238 1239 async_sess_t *callback = 1240 async_callback_receive_start(EXCHANGE_SERIALIZE, call); 1241 if (callback) 1242 return tcp_process_client_messages(callback, callid, *call); 1243 1234 switch (IPC_GET_IMETHOD(*call)) { 1235 case IPC_M_CONNECT_TO_ME: 1236 return tcp_process_client_messages(callid, *call); 1237 } 1238 1244 1239 return ENOTSUP; 1245 1240 } … … 1251 1246 bzero(socket_data, sizeof(*socket_data)); 1252 1247 socket_data->state = TCP_SOCKET_INITIAL; 1253 socket_data->device_id = NIC_DEVICE_INVALID_ID;1248 socket_data->device_id = DEVICE_INVALID_ID; 1254 1249 socket_data->window = NET_DEFAULT_TCP_WINDOW; 1255 1250 socket_data->treshold = socket_data->window; … … 1271 1266 } 1272 1267 1273 int tcp_process_client_messages(async_sess_t *sess, ipc_callid_t callid, 1274 ipc_call_t call) 1268 int tcp_process_client_messages(ipc_callid_t callid, ipc_call_t call) 1275 1269 { 1276 1270 int res; 1271 bool keep_on_going = true; 1277 1272 socket_cores_t local_sockets; 1273 int app_phone = IPC_GET_PHONE(call); 1278 1274 struct sockaddr *addr; 1279 1275 int socket_id; … … 1297 1293 fibril_rwlock_initialize(&lock); 1298 1294 1299 while ( true) {1295 while (keep_on_going) { 1300 1296 1301 1297 /* Answer the call */ … … 1305 1301 /* Get the next call */ 1306 1302 callid = async_get_call(&call); 1307 1308 if (!IPC_GET_IMETHOD(call)) { 1303 1304 /* Process the call */ 1305 switch (IPC_GET_IMETHOD(call)) { 1306 case IPC_M_PHONE_HUNGUP: 1307 keep_on_going = false; 1309 1308 res = EHANGUP; 1310 1309 break; 1311 } 1312 1313 /* Process the call */ 1314 switch (IPC_GET_IMETHOD(call)) { 1310 1315 1311 case NET_SOCKET: 1316 1312 socket_data = … … 1326 1322 fibril_rwlock_write_lock(&lock); 1327 1323 socket_id = SOCKET_GET_SOCKET_ID(call); 1328 res = socket_create(&local_sockets, sess,1324 res = socket_create(&local_sockets, app_phone, 1329 1325 socket_data, &socket_id); 1330 1326 SOCKET_SET_SOCKET_ID(answer, socket_id); … … 1334 1330 break; 1335 1331 } 1336 if (tl_get_ip_packet_dimension(tcp_globals.ip_ sess,1337 &tcp_globals.dimensions, NIC_DEVICE_INVALID_ID,1332 if (tl_get_ip_packet_dimension(tcp_globals.ip_phone, 1333 &tcp_globals.dimensions, DEVICE_INVALID_ID, 1338 1334 &packet_dimension) == EOK) { 1339 1335 SOCKET_SET_DATA_FRAGMENT_SIZE(answer, … … 1509 1505 } 1510 1506 1511 /* Release the application session*/1512 async_hangup( sess);1507 /* Release the application phone */ 1508 async_hangup(app_phone); 1513 1509 1514 1510 printf("release\n"); 1515 1511 /* Release all local sockets */ 1516 socket_cores_release(tcp_globals.net_ sess, &local_sockets,1512 socket_cores_release(tcp_globals.net_phone, &local_sockets, 1517 1513 &tcp_globals.sockets, tcp_free_socket_data); 1518 1514 … … 1622 1618 local_lock = socket_data->local_lock; 1623 1619 fibril_rwlock_write_lock(local_lock); 1624 socket_destroy(tcp_globals.net_ sess,1620 socket_destroy(tcp_globals.net_phone, 1625 1621 timeout->socket_id, timeout->local_sockets, 1626 1622 &tcp_globals.sockets, tcp_free_socket_data); … … 1651 1647 /* Sent packet? */ 1652 1648 packet = pq_find(socket_data->outgoing, sequence_number); 1649 printf("retransmit %d\n", packet_get_id(packet)); 1653 1650 if (packet) { 1654 1651 pq_get_order(packet, NULL, &data_length); … … 1754 1751 } 1755 1752 1756 rc = ip_get_route_req(tcp_globals.ip_ sess, IPPROTO_TCP,1753 rc = ip_get_route_req(tcp_globals.ip_phone, IPPROTO_TCP, 1757 1754 addr, addrlen, &socket_data->device_id, 1758 1755 &socket_data->pseudo_header, &socket_data->headerlen); … … 1789 1786 1790 1787 /* Send the packet */ 1788 printf("connecting %d\n", packet_get_id(packet)); 1791 1789 tcp_send_packets(socket_data->device_id, packet); 1792 1790 … … 1835 1833 1836 1834 /* Remember the outgoing FIN */ 1837 if ( GET_TCP_HEADER_FINALIZE(header))1835 if (header->finalize) 1838 1836 socket_data->fin_outgoing = socket_data->next_outgoing; 1839 1837 … … 1901 1899 rc = pq_insert_after(previous, copy); 1902 1900 if (rc != EOK) { 1903 pq_release_remote(tcp_globals.net_ sess,1901 pq_release_remote(tcp_globals.net_phone, 1904 1902 packet_get_id(copy)); 1905 1903 return sending; … … 1938 1936 socket_data->headerlen, packet_get_data_length(packet)); 1939 1937 if (rc != EOK) { 1940 pq_release_remote(tcp_globals.net_ sess, packet_get_id(packet));1938 pq_release_remote(tcp_globals.net_phone, packet_get_id(packet)); 1941 1939 return NULL; 1942 1940 } … … 1945 1943 header = (tcp_header_t *) packet_get_data(packet); 1946 1944 if (!header) { 1947 pq_release_remote(tcp_globals.net_ sess, packet_get_id(packet));1945 pq_release_remote(tcp_globals.net_phone, packet_get_id(packet)); 1948 1946 return NULL; 1949 1947 } … … 1954 1952 header->acknowledgement_number = 1955 1953 htonl(socket_data->next_incoming); 1956 SET_TCP_HEADER_ACKNOWLEDGE(header, 1);1954 header->acknowledge = 1; 1957 1955 } 1958 1956 header->window = htons(socket_data->window); … … 1970 1968 rc = ip_client_prepare_packet(packet, IPPROTO_TCP, 0, 0, 0, 0); 1971 1969 if (rc != EOK) { 1972 pq_release_remote(tcp_globals.net_ sess, packet_get_id(packet));1970 pq_release_remote(tcp_globals.net_phone, packet_get_id(packet)); 1973 1971 return NULL; 1974 1972 } … … 1977 1975 sequence_number, socket_data->state, socket_data->timeout, true); 1978 1976 if (rc != EOK) { 1979 pq_release_remote(tcp_globals.net_ sess, packet_get_id(packet));1977 pq_release_remote(tcp_globals.net_phone, packet_get_id(packet)); 1980 1978 return NULL; 1981 1979 } … … 1994 1992 1995 1993 /* Make a copy of the packet */ 1996 copy = packet_get_copy(tcp_globals.net_ sess, packet);1994 copy = packet_get_copy(tcp_globals.net_phone, packet); 1997 1995 if (!copy) 1998 1996 return NULL; … … 2002 2000 } 2003 2001 2004 void tcp_send_packets( nic_device_id_t device_id, packet_t *packet)2002 void tcp_send_packets(device_id_t device_id, packet_t *packet) 2005 2003 { 2006 2004 packet_t *next; … … 2008 2006 while (packet) { 2009 2007 next = pq_detach(packet); 2010 ip_send_msg(tcp_globals.ip_ sess, device_id, packet,2008 ip_send_msg(tcp_globals.ip_phone, device_id, packet, 2011 2009 SERVICE_TCP, 0); 2012 2010 packet = next; … … 2026 2024 header->source_port = htons(socket->port); 2027 2025 header->source_port = htons(socket_data->dest_port); 2028 SET_TCP_HEADER_LENGTH(header, 2029 TCP_COMPUTE_HEADER_LENGTH(sizeof(*header))); 2030 SET_TCP_HEADER_SYNCHRONIZE(header, synchronize); 2031 SET_TCP_HEADER_FINALIZE(header, finalize); 2026 header->header_length = TCP_COMPUTE_HEADER_LENGTH(sizeof(*header)); 2027 header->synchronize = synchronize; 2028 header->finalize = finalize; 2032 2029 } 2033 2030 … … 2121 2118 return NO_DATA; 2122 2119 2123 rc = packet_translate_remote(tcp_globals.net_ sess, &packet, packet_id);2120 rc = packet_translate_remote(tcp_globals.net_phone, &packet, packet_id); 2124 2121 if (rc != EOK) 2125 2122 return rc; … … 2132 2129 /* Release the packet */ 2133 2130 dyn_fifo_pop(&socket->received); 2134 pq_release_remote(tcp_globals.net_ sess, packet_get_id(packet));2131 pq_release_remote(tcp_globals.net_phone, packet_get_id(packet)); 2135 2132 2136 2133 /* Return the total length */ … … 2170 2167 return ENOTCONN; 2171 2168 2172 rc = tl_get_ip_packet_dimension(tcp_globals.ip_ sess,2169 rc = tl_get_ip_packet_dimension(tcp_globals.ip_phone, 2173 2170 &tcp_globals.dimensions, socket_data->device_id, &packet_dimension); 2174 2171 if (rc != EOK) … … 2181 2178 for (index = 0; index < fragments; index++) { 2182 2179 /* Read the data fragment */ 2183 result = tl_socket_read_packet_data(tcp_globals.net_ sess,2180 result = tl_socket_read_packet_data(tcp_globals.net_phone, 2184 2181 &packet, TCP_HEADER_SIZE, packet_dimension, 2185 2182 socket_data->addr, socket_data->addrlen); … … 2244 2241 default: 2245 2242 /* Just destroy */ 2246 rc = socket_destroy(tcp_globals.net_ sess, socket_id,2243 rc = socket_destroy(tcp_globals.net_phone, socket_id, 2247 2244 local_sockets, &tcp_globals.sockets, 2248 2245 tcp_free_socket_data); … … 2292 2289 2293 2290 /* Get the device packet dimension */ 2294 rc = tl_get_ip_packet_dimension(tcp_globals.ip_ sess,2291 rc = tl_get_ip_packet_dimension(tcp_globals.ip_phone, 2295 2292 &tcp_globals.dimensions, socket_data->device_id, &packet_dimension); 2296 2293 if (rc != EOK) … … 2298 2295 2299 2296 /* Get a new packet */ 2300 *packet = packet_get_4_remote(tcp_globals.net_ sess, TCP_HEADER_SIZE,2297 *packet = packet_get_4_remote(tcp_globals.net_phone, TCP_HEADER_SIZE, 2301 2298 packet_dimension->addr_len, packet_dimension->prefix, 2302 2299 packet_dimension->suffix); … … 2361 2358 if (rc != EOK) 2362 2359 return rc; 2363 rc = tl_get_ip_packet_dimension(tcp_globals.ip_ sess,2360 rc = tl_get_ip_packet_dimension(tcp_globals.ip_phone, 2364 2361 &tcp_globals.dimensions, socket_data->device_id, 2365 2362 &packet_dimension); … … 2433 2430 int tcp_release_and_return(packet_t *packet, int result) 2434 2431 { 2435 pq_release_remote(tcp_globals.net_ sess, packet_get_id(packet));2432 pq_release_remote(tcp_globals.net_phone, packet_get_id(packet)); 2436 2433 return result; 2437 2434 } … … 2441 2438 * @param[in] iid Message identifier. 2442 2439 * @param[in,out] icall Message parameters. 2443 * @param[in] arg Local argument.2444 2440 * 2445 2441 */ 2446 static void tcp_receiver(ipc_callid_t iid, ipc_call_t *icall , void *arg)2442 static void tcp_receiver(ipc_callid_t iid, ipc_call_t *icall) 2447 2443 { 2448 2444 packet_t *packet; … … 2452 2448 switch (IPC_GET_IMETHOD(*icall)) { 2453 2449 case NET_TL_RECEIVED: 2454 rc = packet_translate_remote(tcp_globals.net_ sess, &packet,2450 rc = packet_translate_remote(tcp_globals.net_phone, &packet, 2455 2451 IPC_GET_PACKET(*icall)); 2456 2452 if (rc == EOK) … … 2470 2466 /** Initialize the TCP module. 2471 2467 * 2472 * @param[in] sess Network module session.2468 * @param[in] net_phone Network module phone. 2473 2469 * 2474 2470 * @return EOK on success. … … 2476 2472 * 2477 2473 */ 2478 int tl_initialize( async_sess_t *sess)2474 int tl_initialize(int net_phone) 2479 2475 { 2480 2476 fibril_rwlock_initialize(&tcp_globals.lock); 2481 2477 fibril_rwlock_write_lock(&tcp_globals.lock); 2482 2478 2483 tcp_globals.net_ sess = sess;2479 tcp_globals.net_phone = net_phone; 2484 2480 2485 tcp_globals.icmp_ sess = icmp_connect_module();2486 tcp_globals.ip_ sess= ip_bind_service(SERVICE_IP, IPPROTO_TCP,2481 tcp_globals.icmp_phone = icmp_connect_module(ICMP_CONNECT_TIMEOUT); 2482 tcp_globals.ip_phone = ip_bind_service(SERVICE_IP, IPPROTO_TCP, 2487 2483 SERVICE_TCP, tcp_receiver); 2488 if (tcp_globals.ip_ sess == NULL) {2484 if (tcp_globals.ip_phone < 0) { 2489 2485 fibril_rwlock_write_unlock(&tcp_globals.lock); 2490 return ENOENT;2486 return tcp_globals.ip_phone; 2491 2487 } 2492 2488
Note:
See TracChangeset
for help on using the changeset viewer.