Changeset 14f1db0 in mainline for uspace/srv/net/tl/tcp/tcp.c


Ignore:
Timestamp:
2010-04-09T12:54:57Z (14 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
a1caa3c2
Parents:
24ab58b3
Message:

networking overhaul:

  • separation of conserns
  • removal of (almost all) overlaping symbols, libnetif is not needed anymore
  • again, it is possible to build the networking in multiple architecture configurations (however, currently only the bundling netif and nil layers is supported, more to come)
  • code style updates and fixes (still a huge amount of work to do)
File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/net/tl/tcp/tcp.c

    r24ab58b3 r14f1db0  
    5151#include <adt/dynamic_fifo.h>
    5252#include <packet/packet_client.h>
     53#include <packet_remote.h>
    5354#include <net_checksum.h>
    5455#include <in.h>
     
    6869#include <tl_common.h>
    6970#include <tl_messages.h>
     71#include <tl_local.h>
     72#include <tl_interface.h>
    7073
    7174#include "tcp.h"
     
    421424                        break;
    422425                default:
    423                         pq_release(tcp_globals.net_phone, packet_get_id(packet));
     426                        pq_release_remote(tcp_globals.net_phone, packet_get_id(packet));
    424427        }
    425428
     
    473476                        // release the acknowledged packets
    474477                        next_packet = pq_next(packet);
    475                         pq_release(tcp_globals.net_phone, packet_get_id(packet));
     478                        pq_release_remote(tcp_globals.net_phone, packet_get_id(packet));
    476479                        packet = next_packet;
    477480                        offset -= length;
     
    517520                        next_packet = pq_next(next_packet);
    518521                        pq_insert_after(tmp_packet, next_packet);
    519                         pq_release(tcp_globals.net_phone, packet_get_id(tmp_packet));
     522                        pq_release_remote(tcp_globals.net_phone, packet_get_id(tmp_packet));
    520523                }
    521524                assert(new_sequence_number + total_length == socket_data->next_incoming + socket_data->window);
     
    548551                                        socket_data->incoming = next_packet;
    549552                                }
    550                                 pq_release(tcp_globals.net_phone, packet_get_id(packet));
     553                                pq_release_remote(tcp_globals.net_phone, packet_get_id(packet));
    551554                                packet = next_packet;
    552555                                continue;
     
    568571                                if(length <= 0){
    569572                                        // remove the empty packet
    570                                         pq_release(tcp_globals.net_phone, packet_get_id(packet));
     573                                        pq_release_remote(tcp_globals.net_phone, packet_get_id(packet));
    571574                                        packet = next_packet;
    572575                                        continue;
     
    595598                                }
    596599                                // remove the duplicit or corrupted packet
    597                                 pq_release(tcp_globals.net_phone, packet_get_id(packet));
     600                                pq_release_remote(tcp_globals.net_phone, packet_get_id(packet));
    598601                                packet = next_packet;
    599602                                continue;
     
    617620                if(ERROR_OCCURRED(pq_add(&socket_data->incoming, packet, new_sequence_number, length))){
    618621                        // remove the corrupted packets
    619                         pq_release(tcp_globals.net_phone, packet_get_id(packet));
    620                         pq_release(tcp_globals.net_phone, packet_get_id(next_packet));
     622                        pq_release_remote(tcp_globals.net_phone, packet_get_id(packet));
     623                        pq_release_remote(tcp_globals.net_phone, packet_get_id(next_packet));
    621624                }else{
    622625                        while(next_packet){
     
    626629                                if(ERROR_OCCURRED(pq_set_order(next_packet, new_sequence_number, length))
    627630                                        || ERROR_OCCURRED(pq_insert_after(packet, next_packet))){
    628                                         pq_release(tcp_globals.net_phone, packet_get_id(next_packet));
     631                                        pq_release_remote(tcp_globals.net_phone, packet_get_id(next_packet));
    629632                                }
    630633                                next_packet = tmp_packet;
     
    634637                printf("unexpected\n");
    635638                // release duplicite or restricted
    636                 pq_release(tcp_globals.net_phone, packet_get_id(packet));
     639                pq_release_remote(tcp_globals.net_phone, packet_get_id(packet));
    637640        }
    638641
     
    679682        // queue the received packet
    680683        if(ERROR_OCCURRED(dyn_fifo_push(&socket->received, packet_get_id(packet), SOCKET_MAX_RECEIVED_SIZE))
    681                 || ERROR_OCCURRED(tl_get_ip_packet_dimension(tcp_globals.ip_phone, &tcp_globals.dimensions, socket_data->device_id, &packet_dimension))){
     684            || ERROR_OCCURRED(tl_get_ip_packet_dimension(tcp_globals.ip_phone, &tcp_globals.dimensions, socket_data->device_id, &packet_dimension))){
    682685                return tcp_release_and_return(packet, ERROR_CODE);
    683686        }
     
    710713                next_packet = pq_detach(packet);
    711714                if(next_packet){
    712                         pq_release(tcp_globals.net_phone, packet_get_id(next_packet));
     715                        pq_release_remote(tcp_globals.net_phone, packet_get_id(next_packet));
    713716                }
    714717                // trim if longer than the header
     
    780783                                free(socket_data->addr);
    781784                                free(socket_data);
    782                                 pq_release(tcp_globals.net_phone, packet_get_id(packet));
     785                                pq_release_remote(tcp_globals.net_phone, packet_get_id(packet));
    783786                                return ERROR_CODE;
    784787                        }
     
    846849                        next_packet = pq_detach(packet);
    847850                        if(next_packet){
    848                                 pq_release(tcp_globals.net_phone, packet_get_id(next_packet));
     851                                pq_release_remote(tcp_globals.net_phone, packet_get_id(next_packet));
    849852                        }
    850853                        // trim if longer than the header
     
    895898
    896899                socket_data->next_incoming = ntohl(header->sequence_number);// + 1;
    897                 pq_release(tcp_globals.net_phone, packet_get_id(packet));
     900                pq_release_remote(tcp_globals.net_phone, packet_get_id(packet));
    898901                socket_data->state = TCP_SOCKET_ESTABLISHED;
    899902                listening_socket = socket_cores_find(socket_data->local_sockets, socket_data->listening_socket_id);
     
    981984                                        // add to acknowledged or release
    982985                                        if(pq_add(&acknowledged, packet, 0, 0) != EOK){
    983                                                 pq_release(tcp_globals.net_phone, packet_get_id(packet));
     986                                                pq_release_remote(tcp_globals.net_phone, packet_get_id(packet));
    984987                                        }
    985988                                        packet = next;
     
    990993                        // release acknowledged
    991994                        if(acknowledged){
    992                                 pq_release(tcp_globals.net_phone, packet_get_id(acknowledged));
     995                                pq_release_remote(tcp_globals.net_phone, packet_get_id(acknowledged));
    993996                        }
    994997                        return;
     
    10061009}
    10071010
    1008 int tcp_message(ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count){
     1011int tcp_message_standalone(ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count){
    10091012        ERROR_DECLARE;
    10101013
     
    10191022                case NET_TL_RECEIVED:
    10201023                        //fibril_rwlock_read_lock(&tcp_globals.lock);
    1021                         if(! ERROR_OCCURRED(packet_translate(tcp_globals.net_phone, &packet, IPC_GET_PACKET(call)))){
     1024                        if(! ERROR_OCCURRED(packet_translate_remote(tcp_globals.net_phone, &packet, IPC_GET_PACKET(call)))){
    10221025                                ERROR_CODE = tcp_received_msg(IPC_GET_DEVICE(call), packet, SERVICE_TCP, IPC_GET_ERROR(call));
    10231026                        }
     
    11111114                                        fibril_rwlock_write_unlock(&lock);
    11121115                                        if(res == EOK){
    1113                                                 if(tl_get_ip_packet_dimension(tcp_globals.ip_phone, &tcp_globals.dimensions, DEVICE_INVALID_ID, &packet_dimension) == EOK){
     1116                                                if (tl_get_ip_packet_dimension(tcp_globals.ip_phone, &tcp_globals.dimensions, DEVICE_INVALID_ID, &packet_dimension) == EOK){
    11141117                                                        SOCKET_SET_DATA_FRAGMENT_SIZE(answer, ((packet_dimension->content < socket_data->data_fragment_size) ? packet_dimension->content : socket_data->data_fragment_size));
    11151118                                                }
     
    15651568                        }else{
    15661569                                if(ERROR_OCCURRED(pq_insert_after(previous, copy))){
    1567                                         pq_release(tcp_globals.net_phone, packet_get_id(copy));
     1570                                        pq_release_remote(tcp_globals.net_phone, packet_get_id(copy));
    15681571                                        return sending;
    15691572                                }
     
    15971600        // adjust the pseudo header
    15981601        if(ERROR_OCCURRED(ip_client_set_pseudo_header_data_length(socket_data->pseudo_header, socket_data->headerlen, packet_get_data_length(packet)))){
    1599                 pq_release(tcp_globals.net_phone, packet_get_id(packet));
     1602                pq_release_remote(tcp_globals.net_phone, packet_get_id(packet));
    16001603                return NULL;
    16011604        }
     
    16041607        header = (tcp_header_ref) packet_get_data(packet);
    16051608        if(! header){
    1606                 pq_release(tcp_globals.net_phone, packet_get_id(packet));
     1609                pq_release_remote(tcp_globals.net_phone, packet_get_id(packet));
    16071610                return NULL;
    16081611        }
     
    16251628        // prepare the timeout
    16261629                || ERROR_OCCURRED(tcp_prepare_timeout(tcp_timeout, socket, socket_data, sequence_number, socket_data->state, socket_data->timeout, true))){
    1627                 pq_release(tcp_globals.net_phone, packet_get_id(packet));
     1630                pq_release_remote(tcp_globals.net_phone, packet_get_id(packet));
    16281631                return NULL;
    16291632        }
     
    17501753                return NO_DATA;
    17511754        }
    1752         ERROR_PROPAGATE(packet_translate(tcp_globals.net_phone, &packet, packet_id));
     1755        ERROR_PROPAGATE(packet_translate_remote(tcp_globals.net_phone, &packet, packet_id));
    17531756
    17541757        // reply the packets
     
    17571760        // release the packet
    17581761        dyn_fifo_pop(&socket->received);
    1759         pq_release(tcp_globals.net_phone, packet_get_id(packet));
     1762        pq_release_remote(tcp_globals.net_phone, packet_get_id(packet));
    17601763        // return the total length
    17611764        return (int) length;
     
    18891892        ERROR_PROPAGATE(tl_get_ip_packet_dimension(tcp_globals.ip_phone, &tcp_globals.dimensions, socket_data->device_id, &packet_dimension));
    18901893        // get a new packet
    1891         *packet = packet_get_4(tcp_globals.net_phone, TCP_HEADER_SIZE, packet_dimension->addr_len, packet_dimension->prefix, packet_dimension->suffix);
     1894        *packet = packet_get_4_remote(tcp_globals.net_phone, TCP_HEADER_SIZE, packet_dimension->addr_len, packet_dimension->prefix, packet_dimension->suffix);
    18921895        if(! * packet){
    18931896                return ENOMEM;
     
    19931996
    19941997int tcp_release_and_return(packet_t packet, int result){
    1995         pq_release(tcp_globals.net_phone, packet_get_id(packet));
     1998        pq_release_remote(tcp_globals.net_phone, packet_get_id(packet));
    19961999        return result;
    19972000}
    1998 
    1999 #ifdef CONFIG_NETWORKING_modular
    2000 
    2001 #include <tl_standalone.h>
    20022001
    20032002/** Default thread for new connections.
     
    20272026               
    20282027                /* Process the message */
    2029                 int res = tl_module_message(callid, &call, &answer, &answer_count);
     2028                int res = tl_module_message_standalone(callid, &call, &answer,
     2029                    &answer_count);
    20302030               
    20312031                /* End if said to either by the message or the processing result */
     
    20522052       
    20532053        /* Start the module */
    2054         if (ERROR_OCCURRED(tl_module_start(tl_client_connection)))
     2054        if (ERROR_OCCURRED(tl_module_start_standalone(tl_client_connection)))
    20552055                return ERROR_CODE;
    20562056       
     
    20582058}
    20592059
    2060 #endif /* CONFIG_NETWORKING_modular */
    2061 
    20622060/** @}
    20632061 */
Note: See TracChangeset for help on using the changeset viewer.