Ignore:
Timestamp:
2010-11-02T18:29:01Z (14 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
4f35b9ff
Parents:
76e1121f (diff), 28f4adb (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:

Merge mainline changes.

File:
1 edited

Legend:

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

    r76e1121f r4687a26c  
    2727 */
    2828
    29 /** @addtogroup packet
    30  *  @{
     29/** @addtogroup libnet
     30 * @{
    3131 */
    3232
    3333/** @file
    34  *  Packet client interface implementation for remote modules.
    35  *  @see packet_client.h
     34 * Packet client interface implementation for remote modules.
     35 * @see packet_client.h
    3636 */
    3737
    3838#include <async.h>
    3939#include <errno.h>
     40#include <err.h>
    4041#include <ipc/ipc.h>
     42#include <ipc/packet.h>
    4143#include <sys/mman.h>
    4244
    43 #include <net_err.h>
    44 #include <net_messages.h>
    45 #include <packet/packet.h>
    46 #include <packet/packet_client.h>
    47 #include <packet/packet_header.h>
    48 #include <packet/packet_messages.h>
     45#include <packet_client.h>
    4946#include <packet_remote.h>
     47
     48#include <net/packet.h>
     49#include <net/packet_header.h>
    5050
    5151/** Obtain the packet from the packet server as the shared memory block.
     
    6464 *
    6565 */
    66 static int packet_return(int phone, packet_ref packet, packet_id_t packet_id, size_t size){
     66static int
     67packet_return(int phone, packet_ref packet, packet_id_t packet_id, size_t size)
     68{
    6769        ERROR_DECLARE;
    6870       
    6971        ipc_call_t answer;
    7072        aid_t message = async_send_1(phone, NET_PACKET_GET, packet_id, &answer);
     73
    7174        *packet = (packet_t) as_get_mappable_page(size);
    72         if (ERROR_OCCURRED(async_share_in_start_0_0(phone, *packet, size))
    73             || ERROR_OCCURRED(pm_add(*packet))) {
     75        if (ERROR_OCCURRED(async_share_in_start_0_0(phone, *packet, size)) ||
     76            ERROR_OCCURRED(pm_add(*packet))) {
    7477                munmap(*packet, size);
    7578                async_wait_for(message, NULL);
     
    8386}
    8487
     88/** Translates the packet identifier to the packet reference.
     89 *
     90 * Tries to find mapping first.
     91 * Contacts the packet server to share the packet if the mapping is not present.
     92 *
     93 * @param[in] phone     The packet server module phone.
     94 * @param[out] packet   The packet reference.
     95 * @param[in] packet_id The packet identifier.
     96 * @returns             EOK on success.
     97 * @returns             EINVAL if the packet parameter is NULL.
     98 * @returns             Other error codes as defined for the NET_PACKET_GET_SIZE
     99 *                      message.
     100 * @returns             Other error codes as defined for the packet_return()
     101 *                      function.
     102 */
    85103int packet_translate_remote(int phone, packet_ref packet, packet_id_t packet_id)
    86104{
     
    91109       
    92110        *packet = pm_find(packet_id);
    93         if (!(*packet)) {
     111        if (!*packet) {
    94112                ipcarg_t size;
    95113               
    96                 ERROR_PROPAGATE(async_req_1_1(phone, NET_PACKET_GET_SIZE, packet_id, &size));
     114                ERROR_PROPAGATE(async_req_1_1(phone, NET_PACKET_GET_SIZE,
     115                    packet_id, &size));
    97116                ERROR_PROPAGATE(packet_return(phone, packet, packet_id, size));
    98117        }
    99         if ((** packet).next) {
     118        if ((*packet)->next) {
    100119                packet_t next;
    101120               
    102                 return packet_translate_remote(phone, &next, (** packet).next);
     121                return packet_translate_remote(phone, &next, (*packet)->next);
    103122        }
    104123       
     
    106125}
    107126
     127/** Obtains the packet of the given dimensions.
     128 *
     129 * Contacts the packet server to return the appropriate packet.
     130 *
     131 * @param[in] phone     The packet server module phone.
     132 * @param[in] addr_len  The source and destination addresses maximal length in
     133 *                      bytes.
     134 * @param[in] max_prefix The maximal prefix length in bytes.
     135 * @param[in] max_content The maximal content length in bytes.
     136 * @param[in] max_suffix The maximal suffix length in bytes.
     137 * @returns             The packet reference.
     138 * @returns             NULL on error.
     139 */
    108140packet_t packet_get_4_remote(int phone, size_t max_content, size_t addr_len,
    109141    size_t max_prefix, size_t max_suffix)
     
    114146        ipcarg_t size;
    115147       
    116         if (ERROR_OCCURRED(async_req_4_2(phone, NET_PACKET_CREATE_4, max_content,
    117             addr_len, max_prefix, max_suffix, &packet_id, &size)))
     148        if (ERROR_OCCURRED(async_req_4_2(phone, NET_PACKET_CREATE_4,
     149            max_content, addr_len, max_prefix, max_suffix, &packet_id, &size)))
    118150                return NULL;
    119151       
     
    121153        packet_t packet = pm_find(packet_id);
    122154        if (!packet) {
    123                 if (ERROR_OCCURRED(packet_return(phone, &packet, packet_id, size)))
     155                if (ERROR_OCCURRED(packet_return(phone, &packet, packet_id,
     156                    size)))
    124157                        return NULL;
    125158        }
     
    128161}
    129162
     163/** Obtains the packet of the given content size.
     164 *
     165 * Contacts the packet server to return the appropriate packet.
     166 *
     167 * @param[in] phone     The packet server module phone.
     168 * @param[in] content   The maximal content length in bytes.
     169 * @returns             The packet reference.
     170 * @returns             NULL on error.
     171 */
    130172packet_t packet_get_1_remote(int phone, size_t content)
    131173{
     
    141183        packet_t packet = pm_find(packet_id);
    142184        if (!packet) {
    143                 if (ERROR_OCCURRED(packet_return(phone, &packet, packet_id, size)))
     185                if (ERROR_OCCURRED(packet_return(phone, &packet, packet_id,
     186                    size)))
    144187                        return NULL;
    145188        }
     
    148191}
    149192
     193/** Releases the packet queue.
     194 *
     195 * All packets in the queue are marked as free for use.
     196 * The packet queue may be one packet only.
     197 * The module should not use the packets after this point until they are
     198 * received or obtained again.
     199 *
     200 * @param[in] phone     The packet server module phone.
     201 * @param[in] packet_id The packet identifier.
     202 */
    150203void pq_release_remote(int phone, packet_id_t packet_id)
    151204{
Note: See TracChangeset for help on using the changeset viewer.