Ignore:
Timestamp:
2011-07-13T22:39:18Z (13 years ago)
Author:
Jiří Zárevúcky <zarevucky.jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
e6910c8
Parents:
5974661 (diff), 8ecef91 (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 libposix.

File:
1 edited

Legend:

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

    r5974661 re4f8c77  
    3737
    3838#include <async.h>
    39 #include <async_obsolete.h>
    4039#include <errno.h>
    4140#include <ipc/packet.h>
     
    5251 * Create the local packet mapping as well.
    5352 *
    54  * @param[in]  phone     The packet server module phone.
    55  * @param[out] packet    The packet reference pointer to store the received
     53 * @param[in]  sess      Packet server module session.
     54 * @param[out] packet    Packet reference pointer to store the received
    5655 *                       packet reference.
    57  * @param[in]  packet_id The packet identifier.
    58  * @param[in]  size      The packet total size in bytes.
     56 * @param[in]  packet_id Packet identifier.
     57 * @param[in]  size      Packet total size in bytes.
    5958 *
    6059 * @return EOK on success.
    6160 * @return Other error codes as defined for the pm_add() function.
    62  * @return Other error codes as defined for the async_obsolete_share_in_start() function.
    63  *
    64  */
    65 static int
    66 packet_return(int phone, packet_t **packet, packet_id_t packet_id, size_t size)
    67 {
     61 * @return Other error codes as defined for the async_share_in_start()
     62 *         function.
     63 *
     64 */
     65static int packet_return(async_sess_t *sess, packet_t **packet,
     66    packet_id_t packet_id, size_t size)
     67{
     68        *packet = (packet_t *) as_get_mappable_page(size);
     69       
     70        async_exch_t *exch = async_exchange_begin(sess);
    6871        ipc_call_t answer;
    69         aid_t message;
    70         int rc;
    71        
    72         message = async_obsolete_send_1(phone, NET_PACKET_GET, packet_id, &answer);
    73 
    74         *packet = (packet_t *) as_get_mappable_page(size);
    75         rc = async_obsolete_share_in_start_0_0(phone, *packet, size);
     72        aid_t message = async_send_1(exch, NET_PACKET_GET, packet_id, &answer);
     73        int rc = async_share_in_start_0_0(exch, *packet, size);
     74        async_exchange_end(exch);
     75       
     76        sysarg_t result;
     77        async_wait_for(message, &result);
     78       
    7679        if (rc != EOK) {
    7780                munmap(*packet, size);
    78                 async_wait_for(message, NULL);
    7981                return rc;
    8082        }
     83       
    8184        rc = pm_add(*packet);
    8285        if (rc != EOK) {
    8386                munmap(*packet, size);
    84                 async_wait_for(message, NULL);
    8587                return rc;
    8688        }
    8789       
    88         sysarg_t result;
    89         async_wait_for(message, &result);
    90        
    9190        return result;
    9291}
    9392
    94 /** Translates the packet identifier to the packet reference.
    95  *
    96  * Tries to find mapping first.
    97  * Contacts the packet server to share the packet if the mapping is not present.
    98  *
    99  * @param[in] phone     The packet server module phone.
    100  * @param[out] packet   The packet reference.
    101  * @param[in] packet_id The packet identifier.
    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
    105  *                      message.
    106  * @return              Other error codes as defined for the packet_return()
    107  *                      function.
    108  */
    109 int packet_translate_remote(int phone, packet_t **packet, packet_id_t packet_id)
    110 {
    111         int rc;
    112        
     93/** Translate the packet identifier to the packet reference.
     94 *
     95 * Try to find mapping first. The packet server is asked to share
     96 * the packet if the mapping is not present.
     97 *
     98 * @param[in]  sess      Packet server module session.
     99 * @param[out] packet    Packet reference.
     100 * @param[in]  packet_id Packet identifier.
     101 *
     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
     105 *         message.
     106 * @return Other error codes as defined for the packet_return()
     107 *         function.
     108 *
     109 */
     110int packet_translate_remote(async_sess_t *sess, packet_t **packet,
     111    packet_id_t packet_id)
     112{
    113113        if (!packet)
    114114                return EINVAL;
     
    116116        *packet = pm_find(packet_id);
    117117        if (!*packet) {
     118                async_exch_t *exch = async_exchange_begin(sess);
    118119                sysarg_t size;
     120                int rc = async_req_1_1(exch, NET_PACKET_GET_SIZE, packet_id,
     121                    &size);
     122                async_exchange_end(exch);
    119123               
    120                 rc = async_obsolete_req_1_1(phone, NET_PACKET_GET_SIZE, packet_id,
    121                     &size);
    122124                if (rc != EOK)
    123125                        return rc;
    124                 rc = packet_return(phone, packet, packet_id, size);
     126               
     127                rc = packet_return(sess, packet, packet_id, size);
    125128                if (rc != EOK)
    126129                        return rc;
    127130        }
     131       
    128132        if ((*packet)->next) {
    129133                packet_t *next;
    130                
    131                 return packet_translate_remote(phone, &next, (*packet)->next);
     134                return packet_translate_remote(sess, &next, (*packet)->next);
    132135        }
    133136       
     
    135138}
    136139
    137 /** Obtains the packet of the given dimensions.
    138  *
    139  * Contacts the packet server to return the appropriate packet.
    140  *
    141  * @param[in] phone     The packet server module phone.
    142  * @param[in] addr_len  The source and destination addresses maximal length in
    143  *                      bytes.
    144  * @param[in] max_prefix The maximal prefix length in bytes.
    145  * @param[in] max_content The maximal content length in bytes.
    146  * @param[in] max_suffix The maximal suffix length in bytes.
    147  * @return              The packet reference.
    148  * @return              NULL on error.
    149  */
    150 packet_t *packet_get_4_remote(int phone, size_t max_content, size_t addr_len,
    151     size_t max_prefix, size_t max_suffix)
    152 {
     140/** Obtain the packet of given dimensions.
     141 *
     142 * Contact the packet server to return the appropriate packet.
     143 *
     144 * @param[in] sess        Packet server module session.
     145 * @param[in] addr_len    Source and destination addresses maximal length
     146 *                        in bytes.
     147 * @param[in] max_prefix  Maximal prefix length in bytes.
     148 * @param[in] max_content Maximal content length in bytes.
     149 * @param[in] max_suffix  Maximal suffix length in bytes.
     150 *
     151 * @return The packet reference.
     152 * @return NULL on error.
     153 *
     154 */
     155packet_t *packet_get_4_remote(async_sess_t *sess, size_t max_content,
     156    size_t addr_len, size_t max_prefix, size_t max_suffix)
     157{
     158        async_exch_t *exch = async_exchange_begin(sess);
    153159        sysarg_t packet_id;
    154160        sysarg_t size;
    155         int rc;
    156        
    157         rc = async_obsolete_req_4_2(phone, NET_PACKET_CREATE_4, max_content, addr_len,
     161        int rc = async_req_4_2(exch, NET_PACKET_CREATE_4, max_content, addr_len,
    158162            max_prefix, max_suffix, &packet_id, &size);
     163        async_exchange_end(exch);
     164       
    159165        if (rc != EOK)
    160166                return NULL;
    161167       
    162        
    163168        packet_t *packet = pm_find(packet_id);
    164169        if (!packet) {
    165                 rc = packet_return(phone, &packet, packet_id, size);
     170                rc = packet_return(sess, &packet, packet_id, size);
    166171                if (rc != EOK)
    167172                        return NULL;
     
    171176}
    172177
    173 /** Obtains the packet of the given content size.
    174  *
    175  * Contacts the packet server to return the appropriate packet.
    176  *
    177  * @param[in] phone     The packet server module phone.
    178  * @param[in] content   The maximal content length in bytes.
    179  * @return              The packet reference.
    180  * @return              NULL on error.
    181  */
    182 packet_t *packet_get_1_remote(int phone, size_t content)
    183 {
     178/** Obtain the packet of given content size.
     179 *
     180 * Contact the packet server to return the appropriate packet.
     181 *
     182 * @param[in] sess    Packet server module session.
     183 * @param[in] content Maximal content length in bytes.
     184 *
     185 * @return The packet reference.
     186 * @return NULL on error.
     187 *
     188 */
     189packet_t *packet_get_1_remote(async_sess_t *sess, size_t content)
     190{
     191        async_exch_t *exch = async_exchange_begin(sess);
    184192        sysarg_t packet_id;
    185193        sysarg_t size;
    186         int rc;
    187        
    188         rc = async_obsolete_req_1_2(phone, NET_PACKET_CREATE_1, content, &packet_id,
     194        int rc = async_req_1_2(exch, NET_PACKET_CREATE_1, content, &packet_id,
    189195            &size);
     196        async_exchange_end(exch);
     197       
    190198        if (rc != EOK)
    191199                return NULL;
     
    193201        packet_t *packet = pm_find(packet_id);
    194202        if (!packet) {
    195                 rc = packet_return(phone, &packet, packet_id, size);
     203                rc = packet_return(sess, &packet, packet_id, size);
    196204                if (rc != EOK)
    197205                        return NULL;
     
    201209}
    202210
    203 /** Releases the packet queue.
     211/** Release the packet queue.
    204212 *
    205213 * All packets in the queue are marked as free for use.
     
    208216 * received or obtained again.
    209217 *
    210  * @param[in] phone     The packet server module phone.
    211  * @param[in] packet_id The packet identifier.
    212  */
    213 void pq_release_remote(int phone, packet_id_t packet_id)
    214 {
    215         async_obsolete_msg_1(phone, NET_PACKET_RELEASE, packet_id);
     218 * @param[in] sess      Packet server module session.
     219 * @param[in] packet_id Packet identifier.
     220 *
     221 */
     222void pq_release_remote(async_sess_t *sess, packet_id_t packet_id)
     223{
     224        async_exch_t *exch = async_exchange_begin(sess);
     225        async_msg_1(exch, NET_PACKET_RELEASE, packet_id);
     226        async_exchange_end(exch);
    216227}
    217228
Note: See TracChangeset for help on using the changeset viewer.