Rev 4742 | Rev 4756 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 4742 | Rev 4750 | ||
---|---|---|---|
Line 170... | Line 170... | ||
170 | * @param result The result to be returned. Input parameter. |
170 | * @param result The result to be returned. Input parameter. |
171 | * @return The result parameter. |
171 | * @return The result parameter. |
172 | */ |
172 | */ |
173 | int tcp_release_and_return( packet_t packet, int result ); |
173 | int tcp_release_and_return( packet_t packet, int result ); |
174 | 174 | ||
175 | int tcp_get_packet_dimension( device_id_t device_id, packet_dimension_ref * packet_dimension ); |
- | |
176 | void tcp_prepare_operation_header( socket_core_ref socket, tcp_socket_data_ref socket_data, tcp_header_ref header, int synchronize, int finalize ); |
175 | void tcp_prepare_operation_header( socket_core_ref socket, tcp_socket_data_ref socket_data, tcp_header_ref header, int synchronize, int finalize ); |
177 | int tcp_prepare_timeout( int ( * timeout_function )( void * tcp_timeout_t ), socket_core_ref socket, tcp_socket_data_ref socket_data, size_t sequence_number, tcp_socket_state_t state, suseconds_t timeout, int globals_read_only ); |
176 | int tcp_prepare_timeout( int ( * timeout_function )( void * tcp_timeout_t ), socket_core_ref socket, tcp_socket_data_ref socket_data, size_t sequence_number, tcp_socket_state_t state, suseconds_t timeout, int globals_read_only ); |
178 | void tcp_free_socket_data( socket_core_ref socket ); |
177 | void tcp_free_socket_data( socket_core_ref socket ); |
179 | int tcp_timeout( void * data ); |
178 | int tcp_timeout( void * data ); |
180 | int tcp_release_after_timeout( void * data ); |
179 | int tcp_release_after_timeout( void * data ); |
Line 204... | Line 203... | ||
204 | int tcp_recvfrom_message( socket_cores_ref local_sockets, int socket_id, int flags, size_t * addrlen ); |
203 | int tcp_recvfrom_message( socket_cores_ref local_sockets, int socket_id, int flags, size_t * addrlen ); |
205 | int tcp_send_message( socket_cores_ref local_sockets, int socket_id, int fragments, size_t data_fragment_size, int flags ); |
204 | int tcp_send_message( socket_cores_ref local_sockets, int socket_id, int fragments, size_t data_fragment_size, int flags ); |
206 | int tcp_accept_message( socket_cores_ref local_sockets, int socket_id, size_t * addrlen ); |
205 | int tcp_accept_message( socket_cores_ref local_sockets, int socket_id, size_t * addrlen ); |
207 | int tcp_close_message( socket_cores_ref local_sockets, int socket_id ); |
206 | int tcp_close_message( socket_cores_ref local_sockets, int socket_id ); |
208 | 207 | ||
209 | DEVICE_MAP_IMPLEMENT( packet_dimensions, packet_dimension_t ); |
- | |
210 | - | ||
211 | /** TCP global data. |
208 | /** TCP global data. |
212 | */ |
209 | */ |
213 | tcp_globals_t tcp_globals; |
210 | tcp_globals_t tcp_globals; |
214 | 211 | ||
215 | /** Initializes the module. |
212 | /** Initializes the module. |
Line 1630... | Line 1627... | ||
1630 | ip_send_msg( tcp_globals.ip_phone, device_id, packet, SERVICE_TCP, 0 ); |
1627 | ip_send_msg( tcp_globals.ip_phone, device_id, packet, SERVICE_TCP, 0 ); |
1631 | packet = next; |
1628 | packet = next; |
1632 | } |
1629 | } |
1633 | } |
1630 | } |
1634 | 1631 | ||
1635 | int tcp_get_packet_dimension( device_id_t device_id, packet_dimension_ref * packet_dimension ){ |
- | |
1636 | ERROR_DECLARE; |
- | |
1637 | - | ||
1638 | assert( packet_dimension ); |
- | |
1639 | - | ||
1640 | * packet_dimension = packet_dimensions_find( & tcp_globals.dimensions, device_id ); |
- | |
1641 | if( ! * packet_dimension ){ |
- | |
1642 | // ask for and remember them if not found |
- | |
1643 | * packet_dimension = malloc( sizeof( ** packet_dimension )); |
- | |
1644 | if( ! * packet_dimension ) return ENOMEM; |
- | |
1645 | if( ERROR_OCCURRED( ip_packet_size_req( tcp_globals.ip_phone, device_id, & ( ** packet_dimension ).addr_len, & ( ** packet_dimension ).prefix, & ( ** packet_dimension ).content, & ( ** packet_dimension ).suffix ))){ |
- | |
1646 | free( * packet_dimension ); |
- | |
1647 | return ERROR_CODE; |
- | |
1648 | } |
- | |
1649 | ERROR_CODE = packet_dimensions_add( & tcp_globals.dimensions, device_id, * packet_dimension ); |
- | |
1650 | if( ERROR_CODE < 0 ){ |
- | |
1651 | free( * packet_dimension ); |
- | |
1652 | return ERROR_CODE; |
- | |
1653 | } |
- | |
1654 | } |
- | |
1655 | return EOK; |
- | |
1656 | } |
- | |
1657 | - | ||
1658 | void tcp_prepare_operation_header( socket_core_ref socket, tcp_socket_data_ref socket_data, tcp_header_ref header, int synchronize, int finalize ){ |
1632 | void tcp_prepare_operation_header( socket_core_ref socket, tcp_socket_data_ref socket_data, tcp_header_ref header, int synchronize, int finalize ){ |
1659 | assert( socket ); |
1633 | assert( socket ); |
1660 | assert( socket_data ); |
1634 | assert( socket_data ); |
1661 | assert( socket->specific_data == socket_data ); |
1635 | assert( socket->specific_data == socket_data ); |
1662 | assert( header ); |
1636 | assert( header ); |
Line 1776... | Line 1750... | ||
1776 | // check state |
1750 | // check state |
1777 | if(( socket_data->state != TCP_SOCKET_ESTABLISHED ) && ( socket_data->state != TCP_SOCKET_CLOSE_WAIT )){ |
1751 | if(( socket_data->state != TCP_SOCKET_ESTABLISHED ) && ( socket_data->state != TCP_SOCKET_CLOSE_WAIT )){ |
1778 | return ENOTCONN; |
1752 | return ENOTCONN; |
1779 | } |
1753 | } |
1780 | 1754 | ||
1781 | ERROR_PROPAGATE( tcp_get_packet_dimension( socket_data->device_id, & packet_dimension )); |
1755 | ERROR_PROPAGATE( tl_get_ip_packet_dimension( tcp_globals.ip_phone, & tcp_globals.dimensions, socket_data->device_id, & packet_dimension )); |
1782 | 1756 | ||
1783 | // TODO return the device_id + data_fragment_size if different - the client should send it again |
1757 | // TODO return the device_id + data_fragment_size if different - the client should send it again |
1784 | // ( two messages are better than ip fragmentation ) |
1758 | // ( two messages are better than ip fragmentation ) |
1785 | 1759 | ||
1786 | for( index = 0; index < fragments; ++ index ){ |
1760 | for( index = 0; index < fragments; ++ index ){ |
Line 1867... | Line 1841... | ||
1867 | tcp_header_ref header; |
1841 | tcp_header_ref header; |
1868 | 1842 | ||
1869 | assert( packet ); |
1843 | assert( packet ); |
1870 | 1844 | ||
1871 | // get the device packet dimension |
1845 | // get the device packet dimension |
1872 | ERROR_PROPAGATE( tcp_get_packet_dimension( socket_data->device_id, & packet_dimension )); |
1846 | ERROR_PROPAGATE( tl_get_ip_packet_dimension( tcp_globals.ip_phone, & tcp_globals.dimensions, socket_data->device_id, & packet_dimension )); |
1873 | // get a new packet |
1847 | // get a new packet |
1874 | * packet = packet_get_4( tcp_globals.net_phone, sizeof( tcp_header_t ), packet_dimension->addr_len, packet_dimension->prefix, packet_dimension->suffix ); |
1848 | * packet = packet_get_4( tcp_globals.net_phone, sizeof( tcp_header_t ), packet_dimension->addr_len, packet_dimension->prefix, packet_dimension->suffix ); |
1875 | if( ! * packet ) return ENOMEM; |
1849 | if( ! * packet ) return ENOMEM; |
1876 | // allocate space in the packet |
1850 | // allocate space in the packet |
1877 | header = PACKET_SUFFIX( * packet, tcp_header_t ); |
1851 | header = PACKET_SUFFIX( * packet, tcp_header_t ); |