Changeset eb522e8 in mainline for uspace/lib/net/tl/tl_common.c


Ignore:
Timestamp:
2011-06-01T08:43:42Z (14 years ago)
Author:
Lubos Slovak <lubos.slovak@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
8d6c1f1
Parents:
9e2e715 (diff), e51a514 (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.
Message:

Huuuuuge merge from development - all the work actually :)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/net/tl/tl_common.c

    r9e2e715 reb522e8  
    2727 */
    2828
    29 /** @addtogroup libnet 
     29/** @addtogroup libnet
    3030 * @{
    3131 */
     
    3939#include <packet_client.h>
    4040#include <packet_remote.h>
    41 #include <icmp_interface.h>
     41#include <icmp_remote.h>
    4242#include <ip_remote.h>
    4343#include <ip_interface.h>
    44 #include <tl_interface.h>
     44#include <tl_remote.h>
    4545
    4646#include <net/socket_codes.h>
     
    6464 * @param[in] addrlen   The address length.
    6565 * @param[out] port     The set port.
    66  * @returns             EOK on success.
    67  * @returns             EINVAL if the address length does not match the address
     66 * @return              EOK on success.
     67 * @return              EINVAL if the address length does not match the address
    6868 *                      family.
    69  * @returns             EAFNOSUPPORT if the address family is not supported.
     69 * @return              EAFNOSUPPORT if the address family is not supported.
    7070 */
    7171int
     
    120120int
    121121tl_get_ip_packet_dimension(int ip_phone,
    122     packet_dimensions_ref packet_dimensions, device_id_t device_id,
    123     packet_dimension_ref *packet_dimension)
     122    packet_dimensions_t *packet_dimensions, device_id_t device_id,
     123    packet_dimension_t **packet_dimension)
    124124{
    125125        int rc;
     
    158158 * @param[in] device_id The device identifier.
    159159 * @param[in] content   The new maximum content size.
    160  * @returns             EOK on success.
     160 * @return              EOK on success.
    161161 * @return              ENOENT if the packet dimension is not cached.
    162162 */
    163163int
    164 tl_update_ip_packet_dimension(packet_dimensions_ref packet_dimensions,
     164tl_update_ip_packet_dimension(packet_dimensions_t *packet_dimensions,
    165165    device_id_t device_id, size_t content)
    166166{
    167         packet_dimension_ref packet_dimension;
     167        packet_dimension_t *packet_dimension;
    168168
    169169        packet_dimension = packet_dimensions_find(packet_dimensions, device_id);
     
    182182                        else
    183183                                packet_dimensions_exclude(packet_dimensions,
    184                                     DEVICE_INVALID_ID);
     184                                    DEVICE_INVALID_ID, free);
    185185                }
    186186        }
     
    196196 * @param[in] addrlen   The address length.
    197197 * @param[in] port      The port to be set.
    198  * @returns             EOK on success.
    199  * @returns             EINVAL if the address length does not match the address
     198 * @return              EOK on success.
     199 * @return              EINVAL if the address length does not match the address
    200200 *                      family.
    201  * @returns             EAFNOSUPPORT if the address family is not supported.
     201 * @return              EAFNOSUPPORT if the address family is not supported.
    202202 */
    203203int tl_set_address_port(struct sockaddr * addr, int addrlen, uint16_t port)
     
    244244 * @param[in] error     The packet error reporting service. Prefixes the
    245245 *                      received packet.
    246  * @returns             EOK on success.
    247  * @returns             ENOENT if no packet may be sent.
    248  */
    249 int
    250 tl_prepare_icmp_packet(int packet_phone, int icmp_phone, packet_t packet,
     246 * @return              EOK on success.
     247 * @return              ENOENT if no packet may be sent.
     248 */
     249int
     250tl_prepare_icmp_packet(int packet_phone, int icmp_phone, packet_t *packet,
    251251    services_t error)
    252252{
    253         packet_t next;
     253        packet_t *next;
    254254        uint8_t *src;
    255255        int length;
    256256
    257         // detach the first packet and release the others
     257        /* Detach the first packet and release the others */
    258258        next = pq_detach(packet);
    259259        if (next)
     
    262262        length = packet_get_addr(packet, &src, NULL);
    263263        if ((length > 0) && (!error) && (icmp_phone >= 0) &&
    264             // set both addresses to the source one (avoids the source address
    265             // deletion before setting the destination one)
     264            /*
     265             * Set both addresses to the source one (avoids the source address
     266             * deletion before setting the destination one)
     267             */
    266268            (packet_set_addr(packet, src, src, (size_t) length) == EOK)) {
    267269                return EOK;
     
    280282 * @param[in] addr      The destination address.
    281283 * @param[in] addrlen   The address length.
    282  * @returns             Number of bytes received.
    283  * @returns             EINVAL if the client does not send data.
    284  * @returns             ENOMEM if there is not enough memory left.
    285  * @returns             Other error codes as defined for the
     284 * @return              Number of bytes received.
     285 * @return              EINVAL if the client does not send data.
     286 * @return              ENOMEM if there is not enough memory left.
     287 * @return              Other error codes as defined for the
    286288 *                      async_data_read_finalize() function.
    287289 */
    288290int
    289 tl_socket_read_packet_data(int packet_phone, packet_ref packet, size_t prefix,
    290     const packet_dimension_ref dimension, const struct sockaddr *addr,
     291tl_socket_read_packet_data(int packet_phone, packet_t **packet, size_t prefix,
     292    const packet_dimension_t *dimension, const struct sockaddr *addr,
    291293    socklen_t addrlen)
    292294{
     
    299301                return EINVAL;
    300302
    301         // get the data length
     303        /* Get the data length */
    302304        if (!async_data_write_receive(&callid, &length))
    303305                return EINVAL;
    304306
    305         // get a new packet
     307        /* Get a new packet */
    306308        *packet = packet_get_4_remote(packet_phone, length, dimension->addr_len,
    307309            prefix + dimension->prefix, dimension->suffix);
     
    309311                return ENOMEM;
    310312
    311         // allocate space in the packet
     313        /* Allocate space in the packet */
    312314        data = packet_suffix(*packet, length);
    313315        if (!data) {
     
    316318        }
    317319
    318         // read the data into the packet
     320        /* Read the data into the packet */
    319321        rc = async_data_write_finalize(callid, data, length);
    320322        if (rc != EOK) {
     
    323325        }
    324326       
    325         // set the packet destination address
     327        /* Set the packet destination address */
    326328        rc = packet_set_addr(*packet, NULL, (uint8_t *) addr, addrlen);
    327329        if (rc != EOK) {
Note: See TracChangeset for help on using the changeset viewer.