Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/net/generic/packet_client.c

    rb69ceea r514ee46  
    2727 */
    2828
    29 /** @addtogroup libnet
    30  * @{
     29/** @addtogroup packet
     30 *  @{
    3131 */
    3232
    3333/** @file
    34  * Packet client implementation.
     34 *  Packet client implementation.
    3535 */
    3636
     
    3838#include <mem.h>
    3939#include <unistd.h>
     40
    4041#include <sys/mman.h>
    4142
    4243#include <packet_client.h>
    43 #include <packet_remote.h>
    4444
    4545#include <net/packet.h>
    4646#include <net/packet_header.h>
    4747
    48 /** Copies the specified data to the beginning of the actual packet content.
    49  *
    50  * Pushes the content end if needed.
    51  *
    52  * @param[in] packet    The packet to be filled.
    53  * @param[in] data      The data to be copied.
    54  * @param[in] length    The length of the copied data.
    55  * @returns             EOK on success.
    56  * @returns             EINVAL if the packet is not valid.
    57  * @returns             ENOMEM if there is not enough memory left.
    58  */
    59 int packet_copy_data(packet_t packet, const void *data, size_t length)
     48int packet_copy_data(packet_t packet, const void * data, size_t length)
    6049{
    6150        if (!packet_is_valid(packet))
     
    7261}
    7362
    74 /** Allocates the specified space right before the actual packet content and
    75  * returns its pointer.
    76  *
    77  * @param[in] packet    The packet to be used.
    78  * @param[in] length    The space length to be allocated at the beginning of the
    79  *                      packet content.
    80  * @returns             The pointer to the allocated memory.
    81  * @returns             NULL if there is not enough memory left.
    82  */
    8363void *packet_prefix(packet_t packet, size_t length)
    8464{
     
    9373}
    9474
    95 /** Allocates the specified space right after the actual packet content and
    96  * returns its pointer.
    97  *
    98  * @param[in] packet    The packet to be used.
    99  * @param[in] length    The space length to be allocated at the end of the
    100  *                       packet content.
    101  * @returns             The pointer to the allocated memory.
    102  * @returns             NULL if there is not enough memory left.
    103  */
    10475void *packet_suffix(packet_t packet, size_t length)
    10576{
     
    11384}
    11485
    115 /** Trims the actual packet content by the specified prefix and suffix lengths.
    116  *
    117  * @param[in] packet    The packet to be trimmed.
    118  * @param[in] prefix    The prefix length to be removed from the beginning of
    119  *                      the packet content.
    120  * @param[in] suffix    The suffix length to be removed from the end of the
    121  *                      packet content.
    122  * @returns             EOK on success.
    123  * @returns             EINVAL if the packet is not valid.
    124  * @returns             ENOMEM if there is not enough memory left.
    125  */
    12686int packet_trim(packet_t packet, size_t prefix, size_t suffix)
    12787{
     
    13797}
    13898
    139 /** Returns the packet identifier.
    140  *
    141  * @param[in] packet    The packet.
    142  * @returns             The packet identifier.
    143  * @returns             Zero if the packet is not valid.
    144  */
    14599packet_id_t packet_get_id(const packet_t packet)
    146100{
     
    148102}
    149103
    150 /** Returns the stored packet addresses and their length.
    151  *
    152  * @param[in] packet    The packet.
    153  * @param[out] src      The source address. May be NULL if not desired.
    154  * @param[out] dest     The destination address. May be NULL if not desired.
    155  * @returns             The stored addresses length.
    156  * @returns             Zero if the addresses are not present.
    157  * @returns             EINVAL if the packet is not valid.
    158  */
    159 int packet_get_addr(const packet_t packet, uint8_t **src, uint8_t **dest)
     104int packet_get_addr(const packet_t packet, uint8_t ** src, uint8_t ** dest)
    160105{
    161106        if (!packet_is_valid(packet))
     
    171116}
    172117
    173 /** Returns the packet content length.
    174  *
    175  * @param[in] packet    The packet.
    176  * @returns             The packet content length in bytes.
    177  * @returns             Zero if the packet is not valid.
    178  */
    179118size_t packet_get_data_length(const packet_t packet)
    180119{
     
    185124}
    186125
    187 /** Returns the pointer to the beginning of the packet content.
    188  *
    189  * @param[in] packet    The packet.
    190  * @returns             The pointer to the beginning of the packet content.
    191  * @returns             NULL if the packet is not valid.
    192  */
    193126void *packet_get_data(const packet_t packet)
    194127{
     
    199132}
    200133
    201 /** Sets the packet addresses.
    202  *
    203  * @param[in] packet    The packet.
    204  * @param[in] src       The new source address. May be NULL.
    205  * @param[in] dest      The new destination address. May be NULL.
    206  * @param[in] addr_len  The addresses length.
    207  * @returns             EOK on success.
    208  * @returns             EINVAL if the packet is not valid.
    209  * @returns             ENOMEM if there is not enough memory left.
    210  */
    211134int
    212 packet_set_addr(packet_t packet, const uint8_t *src, const uint8_t *dest,
     135packet_set_addr(packet_t packet, const uint8_t * src, const uint8_t * dest,
    213136    size_t addr_len)
    214137{
     
    247170}
    248171
    249 /** Returns the packet copy.
    250  *
    251  * Copies the addresses, data, order and metric values.
    252  * Does not copy the queue placement.
    253  *
    254  * @param[in] phone     The packet server module phone.
    255  * @param[in] packet    The original packet.
    256  * @returns             The packet copy.
    257  * @returns             NULL on error.
    258  */
    259172packet_t packet_get_copy(int phone, packet_t packet)
    260173{
Note: See TracChangeset for help on using the changeset viewer.