Ignore:
File:
1 edited

Legend:

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

    r14f1db0 r849ed54  
    3232
    3333/** @file
    34  *  Packet client interface implementation for remote modules.
     34 *  Packet client interface implementation for standalone remote modules.
    3535 *  @see packet_client.h
    3636 */
     
    4747#include <packet/packet_header.h>
    4848#include <packet/packet_messages.h>
    49 #include <packet_remote.h>
    5049
    51 /** Obtain the packet from the packet server as the shared memory block.
    52  *
    53  * Create the local packet mapping as well.
    54  *
    55  * @param[in]  phone     The packet server module phone.
    56  * @param[out] packet    The packet reference pointer to store the received
    57  *                       packet reference.
    58  * @param[in]  packet_id The packet identifier.
    59  * @param[in]  size      The packet total size in bytes.
    60  *
    61  * @return EOK on success.
    62  * @return Other error codes as defined for the pm_add() function.
    63  * @return Other error codes as defined for the async_share_in_start() function.
    64  *
     50/** Obtains the packet from the packet server as the shared memory block.
     51 *  Creates the local packet mapping as well.
     52 *  @param[in] phone The packet server module phone.
     53 *  @param[out] packet The packet reference pointer to store the received packet reference.
     54 *  @param[in] packet_id The packet identifier.
     55 *  @param[in] size The packet total size in bytes.
     56 *  @returns EOK on success.
     57 *  @returns Other error codes as defined for the pm_add() function.
     58 *  @returns Other error codes as defined for the async_share_in_start() function.
    6559 */
    66 static int packet_return(int phone, packet_ref packet, packet_id_t packet_id, size_t size){
     60int packet_return(int phone, packet_ref packet, packet_id_t packet_id, size_t size);
     61
     62int packet_translate(int phone, packet_ref packet, packet_id_t packet_id){
    6763        ERROR_DECLARE;
    68        
     64
     65        ipcarg_t size;
     66        packet_t next;
     67
     68        if(! packet){
     69                return EINVAL;
     70        }
     71        *packet = pm_find(packet_id);
     72        if(!(*packet)){
     73                ERROR_PROPAGATE(async_req_1_1(phone, NET_PACKET_GET_SIZE, packet_id, &size));
     74                ERROR_PROPAGATE(packet_return(phone, packet, packet_id, size));
     75        }
     76        if((** packet).next){
     77                return packet_translate(phone, &next, (** packet).next);
     78        }else return EOK;
     79}
     80
     81int packet_return(int phone, packet_ref packet, packet_id_t packet_id, size_t size){
     82        ERROR_DECLARE;
     83
     84        aid_t message;
    6985        ipc_call_t answer;
    70         aid_t message = async_send_1(phone, NET_PACKET_GET, packet_id, &answer);
     86        ipcarg_t result;
     87
     88        message = async_send_1(phone, NET_PACKET_GET, packet_id, &answer);
    7189        *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))) {
     90        if(ERROR_OCCURRED(async_share_in_start_0_0(phone, * packet, size))
     91                || ERROR_OCCURRED(pm_add(*packet))){
    7492                munmap(*packet, size);
    7593                async_wait_for(message, NULL);
    7694                return ERROR_CODE;
    7795        }
    78        
    79         ipcarg_t result;
    8096        async_wait_for(message, &result);
    81        
    8297        return result;
    8398}
    8499
    85 int packet_translate_remote(int phone, packet_ref packet, packet_id_t packet_id)
    86 {
     100packet_t packet_get_4(int phone, size_t max_content, size_t addr_len, size_t max_prefix, size_t max_suffix){
    87101        ERROR_DECLARE;
    88        
    89         if (!packet)
    90                 return EINVAL;
    91        
    92         *packet = pm_find(packet_id);
    93         if (!(*packet)) {
    94                 ipcarg_t size;
    95                
    96                 ERROR_PROPAGATE(async_req_1_1(phone, NET_PACKET_GET_SIZE, packet_id, &size));
    97                 ERROR_PROPAGATE(packet_return(phone, packet, packet_id, size));
    98         }
    99         if ((** packet).next) {
    100                 packet_t next;
    101                
    102                 return packet_translate_remote(phone, &next, (** packet).next);
    103         }
    104        
    105         return EOK;
    106 }
    107102
    108 packet_t packet_get_4_remote(int phone, size_t max_content, size_t addr_len,
    109     size_t max_prefix, size_t max_suffix)
    110 {
    111         ERROR_DECLARE;
    112        
    113103        ipcarg_t packet_id;
    114104        ipcarg_t size;
    115        
    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)))
     105        packet_t packet;
     106
     107        if(ERROR_OCCURRED(async_req_4_2(phone, NET_PACKET_CREATE_4, max_content, addr_len, max_prefix, max_suffix, &packet_id, &size))){
    118108                return NULL;
    119        
    120        
    121         packet_t packet = pm_find(packet_id);
    122         if (!packet) {
    123                 if (ERROR_OCCURRED(packet_return(phone, &packet, packet_id, size)))
     109        }
     110        packet = pm_find(packet_id);
     111        if(! packet){
     112                if(ERROR_OCCURRED(packet_return(phone, &packet, packet_id, size))){
    124113                        return NULL;
     114                }
    125115        }
    126        
    127116        return packet;
    128117}
    129118
    130 packet_t packet_get_1_remote(int phone, size_t content)
    131 {
     119packet_t packet_get_1(int phone, size_t content){
    132120        ERROR_DECLARE;
    133        
     121
    134122        ipcarg_t packet_id;
    135123        ipcarg_t size;
    136        
    137         if (ERROR_OCCURRED(async_req_1_2(phone, NET_PACKET_CREATE_1, content,
    138             &packet_id, &size)))
     124        packet_t packet;
     125
     126        if(ERROR_OCCURRED(async_req_1_2(phone, NET_PACKET_CREATE_1, content, &packet_id, &size))){
    139127                return NULL;
    140        
    141         packet_t packet = pm_find(packet_id);
    142         if (!packet) {
    143                 if (ERROR_OCCURRED(packet_return(phone, &packet, packet_id, size)))
     128        }
     129        packet = pm_find(packet_id);
     130        if(! packet){
     131                if(ERROR_OCCURRED(packet_return(phone, &packet, packet_id, size))){
    144132                        return NULL;
     133                }
    145134        }
    146        
    147135        return packet;
    148136}
    149137
    150 void pq_release_remote(int phone, packet_id_t packet_id)
    151 {
     138void pq_release(int phone, packet_id_t packet_id){
    152139        async_msg_1(phone, NET_PACKET_RELEASE, packet_id);
    153140}
Note: See TracChangeset for help on using the changeset viewer.