Ignore:
File:
1 edited

Legend:

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

    r84c20da re526f08  
    2727 */
    2828
    29 /** @addtogroup libnet
    30  * @{
     29/** @addtogroup net_tl
     30 *  @{
    3131 */
    3232
    3333/** @file
    34  * Transport layer common functions implementation.
    35  * @see tl_common.h
    36  */
    37 
    38 #include <tl_common.h>
     34 *  Transport layer common functions implementation.
     35 *  @see tl_common.h
     36 */
     37
     38#include <net/socket_codes.h>
     39#include <net/in.h>
     40#include <net/in6.h>
     41#include <net/inet.h>
     42#include <async.h>
     43#include <ipc/services.h>
     44#include <errno.h>
     45#include <err.h>
     46
     47#include <net/packet.h>
    3948#include <packet_client.h>
    4049#include <packet_remote.h>
     50#include <net/device.h>
    4151#include <icmp_interface.h>
    4252#include <ip_remote.h>
    4353#include <ip_interface.h>
    4454#include <tl_interface.h>
    45 
    46 #include <net/socket_codes.h>
    47 #include <net/in.h>
    48 #include <net/in6.h>
    49 #include <net/inet.h>
    50 #include <net/device.h>
    51 #include <net/packet.h>
    52 
    53 #include <async.h>
    54 #include <ipc/services.h>
    55 #include <errno.h>
    56 #include <err.h>
     55#include <tl_common.h>
    5756
    5857DEVICE_MAP_IMPLEMENT(packet_dimensions, packet_dimension_t);
    5958
    60 /** Gets the address port.
    61  *
    62  * Supports AF_INET and AF_INET6 address families.
    63  *
    64  * @param[in,out] addr  The address to be updated.
    65  * @param[in] addrlen   The address length.
    66  * @param[out] port     The set port.
    67  * @returns             EOK on success.
    68  * @returns             EINVAL if the address length does not match the address
    69  *                      family.
    70  * @returns             EAFNOSUPPORT if the address family is not supported.
    71  */
    7259int
    7360tl_get_address_port(const struct sockaddr *addr, int addrlen, uint16_t *port)
     
    8774                *port = ntohs(address_in->sin_port);
    8875                break;
    89        
    9076        case AF_INET6:
    9177                if (addrlen != sizeof(struct sockaddr_in6))
    92                         return EINVAL;
     78                                return EINVAL;
    9379
    9480                address_in6 = (struct sockaddr_in6 *) addr;
    9581                *port = ntohs(address_in6->sin6_port);
    9682                break;
    97        
    9883        default:
    9984                return EAFNOSUPPORT;
     
    10893 * The reply is cached then.
    10994 *
    110  * @param[in] ip_phone  The IP moduel phone for (semi)remote calls.
    111  * @param[in] packet_dimensions The packet dimensions cache.
    112  * @param[in] device_id The device identifier.
    113  * @param[out] packet_dimension The IP packet dimensions.
    114  * @return              EOK on success.
    115  * @return              EBADMEM if the packet_dimension parameter is NULL.
    116  * @return              ENOMEM if there is not enough memory left.
    117  * @return              EINVAL if the packet_dimensions cache is not valid.
    118  * @return              Other codes as defined for the ip_packet_size_req()
    119  *                      function.
    120  */
    121 int
    122 tl_get_ip_packet_dimension(int ip_phone,
     95 * @param[in]  ip_phone          The IP moduel phone for (semi)remote calls.
     96 * @param[in]  packet_dimensions The packet dimensions cache.
     97 * @param[in]  device_id         The device identifier.
     98 * @param[out] packet_dimension  The IP packet dimensions.
     99 *
     100 * @return EOK on success.
     101 * @return EBADMEM if the packet_dimension parameter is NULL.
     102 * @return ENOMEM if there is not enough memory left.
     103 * @return EINVAL if the packet_dimensions cache is not valid.
     104 * @return Other codes as defined for the ip_packet_size_req() function.
     105 *
     106 */
     107int tl_get_ip_packet_dimension(int ip_phone,
    123108    packet_dimensions_ref packet_dimensions, device_id_t device_id,
    124109    packet_dimension_ref *packet_dimension)
     
    154139}
    155140
    156 /** Updates IP device packet dimensions cache.
    157  *
    158  * @param[in,out] packet_dimensions The packet dimensions cache.
    159  * @param[in] device_id The device identifier.
    160  * @param[in] content   The new maximum content size.
    161  * @returns             EOK on success.
    162  * @return              ENOENT if the packet dimension is not cached.
    163  */
    164141int
    165142tl_update_ip_packet_dimension(packet_dimensions_ref packet_dimensions,
     
    171148        if (!packet_dimension)
    172149                return ENOENT;
    173 
    174150        packet_dimension->content = content;
    175151
     
    184160                                packet_dimensions_exclude(packet_dimensions,
    185161                                    DEVICE_INVALID_ID);
     162
    186163                }
    187164        }
     
    190167}
    191168
    192 /** Sets the address port.
    193  *
    194  * Supports AF_INET and AF_INET6 address families.
    195  *
    196  * @param[in,out] addr  The address to be updated.
    197  * @param[in] addrlen   The address length.
    198  * @param[in] port      The port to be set.
    199  * @returns             EOK on success.
    200  * @returns             EINVAL if the address length does not match the address
    201  *                      family.
    202  * @returns             EAFNOSUPPORT if the address family is not supported.
    203  */
    204169int tl_set_address_port(struct sockaddr * addr, int addrlen, uint16_t port)
    205170{
     
    222187                address_in->sin_port = htons(port);
    223188                return EOK;
    224        
    225189        case AF_INET6:
    226190                if (length != sizeof(struct sockaddr_in6))
     
    229193                address_in6->sin6_port = htons(port);
    230194                return EOK;
    231        
    232195        default:
    233196                return EAFNOSUPPORT;
     
    235198}
    236199
    237 /** Prepares the packet for ICMP error notification.
    238  *
    239  * Keeps the first packet and releases all the others.
    240  * Releases all the packets on error.
    241  *
    242  * @param[in] packet_phone The packet server module phone.
    243  * @param[in] icmp_phone The ICMP module phone.
    244  * @param[in] packet    The packet to be send.
    245  * @param[in] error     The packet error reporting service. Prefixes the
    246  *                      received packet.
    247  * @returns             EOK on success.
    248  * @returns             ENOENT if no packet may be sent.
    249  */
    250200int
    251201tl_prepare_icmp_packet(int packet_phone, int icmp_phone, packet_t packet,
     
    273223}
    274224
    275 /** Receives data from the socket into a packet.
    276  *
    277  * @param[in] packet_phone The packet server module phone.
    278  * @param[out] packet   The new created packet.
    279  * @param[in] prefix    Reserved packet data prefix length.
    280  * @param[in] dimension The packet dimension.
    281  * @param[in] addr      The destination address.
    282  * @param[in] addrlen   The address length.
    283  * @returns             Number of bytes received.
    284  * @returns             EINVAL if the client does not send data.
    285  * @returns             ENOMEM if there is not enough memory left.
    286  * @returns             Other error codes as defined for the
    287  *                      async_data_read_finalize() function.
    288  */
    289225int
    290226tl_socket_read_packet_data(int packet_phone, packet_ref packet, size_t prefix,
Note: See TracChangeset for help on using the changeset viewer.