Ignore:
Timestamp:
2010-11-25T13:42:50Z (13 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
8df8415
Parents:
a93d79a (diff), eb667613 (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

    ra93d79a r8fb1bf82  
    3838#include <async.h>
    3939#include <errno.h>
    40 #include <err.h>
    4140#include <ipc/ipc.h>
    4241#include <ipc/packet.h>
     
    6564 */
    6665static int
    67 packet_return(int phone, packet_ref packet, packet_id_t packet_id, size_t size)
    68 {
    69         ERROR_DECLARE;
    70        
     66packet_return(int phone, packet_t **packet, packet_id_t packet_id, size_t size)
     67{
    7168        ipc_call_t answer;
    72         aid_t message = async_send_1(phone, NET_PACKET_GET, packet_id, &answer);
    73 
    74         *packet = (packet_t) as_get_mappable_page(size);
    75         if (ERROR_OCCURRED(async_share_in_start_0_0(phone, *packet, size)) ||
    76             ERROR_OCCURRED(pm_add(*packet))) {
     69        aid_t message;
     70        int rc;
     71       
     72        message = async_send_1(phone, NET_PACKET_GET, packet_id, &answer);
     73
     74        *packet = (packet_t *) as_get_mappable_page(size);
     75        rc = async_share_in_start_0_0(phone, *packet, size);
     76        if (rc != EOK) {
    7777                munmap(*packet, size);
    7878                async_wait_for(message, NULL);
    79                 return ERROR_CODE;
     79                return rc;
     80        }
     81        rc = pm_add(*packet);
     82        if (rc != EOK) {
     83                munmap(*packet, size);
     84                async_wait_for(message, NULL);
     85                return rc;
    8086        }
    8187       
     
    94100 * @param[out] packet   The packet reference.
    95101 * @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
     102 * @return              EOK on success.
     103 * @return              EINVAL if the packet parameter is NULL.
     104 * @return              Other error codes as defined for the NET_PACKET_GET_SIZE
    99105 *                      message.
    100  * @returns             Other error codes as defined for the packet_return()
     106 * @return              Other error codes as defined for the packet_return()
    101107 *                      function.
    102108 */
    103 int packet_translate_remote(int phone, packet_ref packet, packet_id_t packet_id)
    104 {
    105         ERROR_DECLARE;
     109int packet_translate_remote(int phone, packet_t **packet, packet_id_t packet_id)
     110{
     111        int rc;
    106112       
    107113        if (!packet)
     
    112118                ipcarg_t size;
    113119               
    114                 ERROR_PROPAGATE(async_req_1_1(phone, NET_PACKET_GET_SIZE,
    115                     packet_id, &size));
    116                 ERROR_PROPAGATE(packet_return(phone, packet, packet_id, size));
     120                rc = async_req_1_1(phone, NET_PACKET_GET_SIZE, packet_id,
     121                    &size);
     122                if (rc != EOK)
     123                        return rc;
     124                rc = packet_return(phone, packet, packet_id, size);
     125                if (rc != EOK)
     126                        return rc;
    117127        }
    118128        if ((*packet)->next) {
    119                 packet_t next;
     129                packet_t *next;
    120130               
    121131                return packet_translate_remote(phone, &next, (*packet)->next);
     
    135145 * @param[in] max_content The maximal content length in bytes.
    136146 * @param[in] max_suffix The maximal suffix length in bytes.
    137  * @returns             The packet reference.
    138  * @returns             NULL on error.
    139  */
    140 packet_t packet_get_4_remote(int phone, size_t max_content, size_t addr_len,
     147 * @return              The packet reference.
     148 * @return              NULL on error.
     149 */
     150packet_t *packet_get_4_remote(int phone, size_t max_content, size_t addr_len,
    141151    size_t max_prefix, size_t max_suffix)
    142152{
    143         ERROR_DECLARE;
    144        
    145153        ipcarg_t packet_id;
    146154        ipcarg_t size;
    147        
    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)))
     155        int rc;
     156       
     157        rc = async_req_4_2(phone, NET_PACKET_CREATE_4, max_content, addr_len,
     158            max_prefix, max_suffix, &packet_id, &size);
     159        if (rc != EOK)
    150160                return NULL;
    151161       
    152162       
    153         packet_t packet = pm_find(packet_id);
     163        packet_t *packet = pm_find(packet_id);
    154164        if (!packet) {
    155                 if (ERROR_OCCURRED(packet_return(phone, &packet, packet_id,
    156                     size)))
     165                rc = packet_return(phone, &packet, packet_id, size);
     166                if (rc != EOK)
    157167                        return NULL;
    158168        }
     
    167177 * @param[in] phone     The packet server module phone.
    168178 * @param[in] content   The maximal content length in bytes.
    169  * @returns             The packet reference.
    170  * @returns             NULL on error.
    171  */
    172 packet_t packet_get_1_remote(int phone, size_t content)
    173 {
    174         ERROR_DECLARE;
    175        
     179 * @return              The packet reference.
     180 * @return              NULL on error.
     181 */
     182packet_t *packet_get_1_remote(int phone, size_t content)
     183{
    176184        ipcarg_t packet_id;
    177185        ipcarg_t size;
    178        
    179         if (ERROR_OCCURRED(async_req_1_2(phone, NET_PACKET_CREATE_1, content,
    180             &packet_id, &size)))
     186        int rc;
     187       
     188        rc = async_req_1_2(phone, NET_PACKET_CREATE_1, content, &packet_id,
     189            &size);
     190        if (rc != EOK)
    181191                return NULL;
    182192       
    183         packet_t packet = pm_find(packet_id);
     193        packet_t *packet = pm_find(packet_id);
    184194        if (!packet) {
    185                 if (ERROR_OCCURRED(packet_return(phone, &packet, packet_id,
    186                     size)))
     195                rc = packet_return(phone, &packet, packet_id, size);
     196                if (rc != EOK)
    187197                        return NULL;
    188198        }
Note: See TracChangeset for help on using the changeset viewer.