Changeset 14f1db0 in mainline for uspace/lib/net/tl/tl_common.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/lib/net/tl/tl_common.c

    r24ab58b3 r14f1db0  
    4242#include <packet/packet.h>
    4343#include <packet/packet_client.h>
     44#include <packet_remote.h>
    4445#include <net_device.h>
    4546#include <icmp_interface.h>
     
    4748#include <in6.h>
    4849#include <inet.h>
    49 #include <ip_interface.h>
     50#include <ip_local.h>
     51#include <ip_remote.h>
    5052#include <socket_codes.h>
    5153#include <socket_errno.h>
     54#include <ip_interface.h>
     55#include <tl_interface.h>
    5256#include <tl_common.h>
    5357
     
    8286}
    8387
    84 int tl_get_ip_packet_dimension(int ip_phone, packet_dimensions_ref packet_dimensions, device_id_t device_id, packet_dimension_ref * packet_dimension){
     88/** Get IP packet dimensions.
     89 *
     90 * Try to search a cache and query the IP module if not found.
     91 * The reply is cached then.
     92 *
     93 * @param[in]  ip_phone          The IP moduel phone for (semi)remote calls.
     94 * @param[in]  packet_dimensions The packet dimensions cache.
     95 * @param[in]  device_id         The device identifier.
     96 * @param[out] packet_dimension  The IP packet dimensions.
     97 *
     98 * @return EOK on success.
     99 * @return EBADMEM if the packet_dimension parameter is NULL.
     100 * @return ENOMEM if there is not enough memory left.
     101 * @return EINVAL if the packet_dimensions cache is not valid.
     102 * @return Other codes as defined for the ip_packet_size_req() function.
     103 *
     104 */
     105int tl_get_ip_packet_dimension(int ip_phone,
     106    packet_dimensions_ref packet_dimensions, device_id_t device_id,
     107    packet_dimension_ref *packet_dimension)
     108{
    85109        ERROR_DECLARE;
    86 
    87         if(! packet_dimension){
     110       
     111        if (!packet_dimension)
    88112                return EBADMEM;
    89         }
    90 
     113       
    91114        *packet_dimension = packet_dimensions_find(packet_dimensions, device_id);
    92         if(! * packet_dimension){
    93                 // ask for and remember them if not found
    94                 *packet_dimension = malloc(sizeof(** packet_dimension));
    95                 if(! * packet_dimension){
     115        if (!*packet_dimension) {
     116                /* Ask for and remember them if not found */
     117                *packet_dimension = malloc(sizeof(**packet_dimension));
     118                if(!*packet_dimension)
    96119                        return ENOMEM;
    97                 }
    98                 if(ERROR_OCCURRED(ip_packet_size_req(ip_phone, device_id, * packet_dimension))){
     120               
     121                if (ERROR_OCCURRED(ip_packet_size_req(ip_phone, device_id,
     122                    *packet_dimension))) {
    99123                        free(*packet_dimension);
    100124                        return ERROR_CODE;
    101125                }
    102                 ERROR_CODE = packet_dimensions_add(packet_dimensions, device_id, * packet_dimension);
    103                 if(ERROR_CODE < 0){
     126               
     127                ERROR_CODE = packet_dimensions_add(packet_dimensions, device_id,
     128                    *packet_dimension);
     129                if (ERROR_CODE < 0) {
    104130                        free(*packet_dimension);
    105131                        return ERROR_CODE;
    106132                }
    107133        }
     134       
    108135        return EOK;
    109136}
     
    169196        // detach the first packet and release the others
    170197        next = pq_detach(packet);
    171         if(next){
    172                 pq_release(packet_phone, packet_get_id(next));
    173         }
     198        if (next)
     199                pq_release_remote(packet_phone, packet_get_id(next));
     200       
    174201        length = packet_get_addr(packet, &src, NULL);
    175202        if((length > 0)
     
    180207                return EOK;
    181208        }else{
    182                 pq_release(packet_phone, packet_get_id(packet));
     209                pq_release_remote(packet_phone, packet_get_id(packet));
    183210        }
    184211        return ENOENT;
     
    200227        }
    201228        // get a new packet
    202         *packet = packet_get_4(packet_phone, length, dimension->addr_len, prefix + dimension->prefix, dimension->suffix);
     229        *packet = packet_get_4_remote(packet_phone, length, dimension->addr_len, prefix + dimension->prefix, dimension->suffix);
    203230        if(! packet){
    204231                return ENOMEM;
     
    207234        data = packet_suffix(*packet, length);
    208235        if(! data){
    209                 pq_release(packet_phone, packet_get_id(*packet));
     236                pq_release_remote(packet_phone, packet_get_id(*packet));
    210237                return ENOMEM;
    211238        }
     
    214241        // set the packet destination address
    215242                || ERROR_OCCURRED(packet_set_addr(*packet, NULL, (uint8_t *) addr, addrlen))){
    216                 pq_release(packet_phone, packet_get_id(*packet));
     243                pq_release_remote(packet_phone, packet_get_id(*packet));
    217244                return ERROR_CODE;
    218245        }
Note: See TracChangeset for help on using the changeset viewer.