Changeset 6b82009 in mainline for uspace/lib


Ignore:
Timestamp:
2011-06-22T20:41:41Z (14 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
ef09a7a
Parents:
55091847
Message:

networking stack: convert to the new async framework

Location:
uspace/lib
Files:
48 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/c/generic/adt/measured_strings.c

    r55091847 r6b82009  
    4242#include <errno.h>
    4343#include <async.h>
    44 #include <async_obsolete.h>
    4544
    4645/** Creates a new measured string bundled with a copy of the given string
     
    298297 * size has to be negotiated in advance.
    299298 *
    300  * @param[in] phone     The other module phone.
     299 * @param[in] exch      Exchange.
    301300 * @param[out] strings  The returned measured strings array.
    302301 * @param[out] data     The measured strings data. This memory block stores the
     
    305304 * @return              EOK on success.
    306305 * @return              EINVAL if the strings or data parameter is NULL.
    307  * @return              EINVAL if the phone or count parameter is not positive.
     306 * @return              EINVAL if the exch or count parameter is invalid.
    308307 * @return              EINVAL if the sent array differs in size.
    309308 * @return              ENOMEM if there is not enough memory left.
     
    311310 *                      async_data_read_start() function.
    312311 */
    313 int
    314 measured_strings_return(int phone, measured_string_t **strings, uint8_t **data,
    315     size_t count)
     312int measured_strings_return(async_exch_t *exch, measured_string_t **strings,
     313    uint8_t **data, size_t count)
    316314{
    317315        size_t *lengths;
     
    320318        int rc;
    321319
    322         if ((phone < 0) || (!strings) || (!data) || (count <= 0))
     320        if ((exch == NULL) || (!strings) || (!data) || (count <= 0))
    323321                return EINVAL;
    324322
     
    327325                return ENOMEM;
    328326
    329         rc = async_obsolete_data_read_start(phone, lengths,
     327        rc = async_data_read_start(exch, lengths,
    330328            sizeof(size_t) * (count + 1));
    331329        if (rc != EOK) {
     
    352350                (*strings)[index].length = lengths[index];
    353351                if (lengths[index] > 0) {
    354                         rc = async_obsolete_data_read_start(phone, next, lengths[index]);
     352                        rc = async_data_read_start(exch, next, lengths[index]);
    355353                        if (rc != EOK) {
    356354                                free(lengths);
     
    376374 * size has to be negotiated in advance.
    377375 *
    378  * @param[in] phone     The other module phone.
     376 * @param[in] exch      Exchange.
    379377 * @param[in] strings   The measured strings array to be transferred.
    380378 * @param[in] count     The measured strings array size.
    381379 * @return              EOK on success.
    382380 * @return              EINVAL if the strings parameter is NULL.
    383  * @return              EINVAL if the phone or count parameter is not positive.
     381 * @return              EINVAL if the exch or count parameter is invalid.
    384382 * @return              Other error codes as defined for the
    385383 *                      async_data_write_start() function.
    386384 */
    387 int
    388 measured_strings_send(int phone, const measured_string_t *strings,
     385int measured_strings_send(async_exch_t *exch, const measured_string_t *strings,
    389386    size_t count)
    390387{
     
    393390        int rc;
    394391
    395         if ((phone < 0) || (!strings) || (count <= 0))
     392        if ((exch == NULL) || (!strings) || (count <= 0))
    396393                return EINVAL;
    397394
     
    400397                return ENOMEM;
    401398
    402         rc = async_obsolete_data_write_start(phone, lengths,
     399        rc = async_data_write_start(exch, lengths,
    403400            sizeof(size_t) * (count + 1));
    404401        if (rc != EOK) {
     
    411408        for (index = 0; index < count; index++) {
    412409                if (strings[index].length > 0) {
    413                         rc = async_obsolete_data_write_start(phone, strings[index].value,
     410                        rc = async_data_write_start(exch, strings[index].value,
    414411                            strings[index].length);
    415412                        if (rc != EOK)
     
    423420/** @}
    424421 */
    425 
  • uspace/lib/c/generic/net/icmp_api.c

    r55091847 r6b82009  
    4242#include <net/ip_codes.h>
    4343#include <async.h>
    44 #include <async_obsolete.h>
    4544#include <sys/types.h>
    4645#include <sys/time.h>
     
    5554 * timeout occurs.
    5655 *
    57  * @param[in] icmp_phone The ICMP module phone used for (semi)remote calls.
     56 * @param[in] sess The ICMP session.
    5857 * @param[in] size      The message data length in bytes.
    5958 * @param[in] timeout   The timeout in milliseconds.
     
    7473 */
    7574int
    76 icmp_echo_msg(int icmp_phone, size_t size, mseconds_t timeout, ip_ttl_t ttl,
     75icmp_echo_msg(async_sess_t *sess, size_t size, mseconds_t timeout, ip_ttl_t ttl,
    7776    ip_tos_t tos, int dont_fragment, const struct sockaddr *addr,
    7877    socklen_t addrlen)
     
    8382        if (addrlen <= 0)
    8483                return EINVAL;
    85 
    86         message_id = async_obsolete_send_5(icmp_phone, NET_ICMP_ECHO, size, timeout, ttl,
     84       
     85        async_exch_t *exch = async_exchange_begin(sess);
     86       
     87        message_id = async_send_5(exch, NET_ICMP_ECHO, size, timeout, ttl,
    8788            tos, (sysarg_t) dont_fragment, NULL);
    88 
     89       
    8990        /* Send the address */
    90         async_obsolete_data_write_start(icmp_phone, addr, (size_t) addrlen);
     91        async_data_write_start(exch, addr, (size_t) addrlen);
     92       
     93        async_exchange_end(exch);
    9194
    9295        async_wait_for(message_id, &result);
  • uspace/lib/c/generic/net/icmp_common.c

    r55091847 r6b82009  
    4545/** Connect to the ICMP module.
    4646 *
    47  * @return ICMP module phone on success.
     47 * @return ICMP module session.
    4848 *
    4949 */
    50 int icmp_connect_module(void)
     50async_sess_t *icmp_connect_module(void)
    5151{
    5252        return connect_to_service(SERVICE_ICMP);
  • uspace/lib/c/generic/net/modules.c

    r55091847 r6b82009  
    4040
    4141#include <async.h>
    42 #include <async_obsolete.h>
    4342#include <malloc.h>
    4443#include <errno.h>
     
    4746#include <net/modules.h>
    4847#include <ns.h>
    49 #include <ns_obsolete.h>
    50 
    51 /** The time between connect requests in microseconds. */
    52 #define MODULE_WAIT_TIME  (10 * 1000)
    5348
    5449/** Answer a call.
     
    9893}
    9994
    100 /** Create bidirectional connection with the needed module service and registers
     95/** Create bidirectional connection with the needed module service and register
    10196 * the message receiver.
    10297 *
    103  * @param[in] need      The needed module service.
    104  * @param[in] arg1      The first parameter.
    105  * @param[in] arg2      The second parameter.
    106  * @param[in] arg3      The third parameter.
    107  * @param[in] client_receiver The message receiver.
    108  *
    109  * @return              The phone of the needed service.
    110  * @return              Other error codes as defined for the ipc_connect_to_me()
    111  *                      function.
    112  */
    113 int bind_service(services_t need, sysarg_t arg1, sysarg_t arg2, sysarg_t arg3,
    114     async_client_conn_t client_receiver)
     98 * @param[in] need            Needed module service.
     99 * @param[in] arg1            First parameter.
     100 * @param[in] arg2            Second parameter.
     101 * @param[in] arg3            Third parameter.
     102 * @param[in] client_receiver Message receiver.
     103 *
     104 * @return Session to the needed service.
     105 * @return Other error codes as defined for the async_connect_to_me()
     106 *         function.
     107 *
     108 */
     109async_sess_t *bind_service(services_t need, sysarg_t arg1, sysarg_t arg2,
     110    sysarg_t arg3, async_client_conn_t client_receiver)
    115111{
    116112        /* Connect to the needed service */
    117         int phone = connect_to_service(need);
    118         if (phone >= 0) {
     113        async_sess_t *sess = connect_to_service(need);
     114        if (sess != NULL) {
    119115                /* Request the bidirectional connection */
    120                 int rc = async_obsolete_connect_to_me(phone, arg1, arg2, arg3,
     116                async_exch_t *exch = async_exchange_begin(sess);
     117                int rc = async_connect_to_me(exch, arg1, arg2, arg3,
    121118                    client_receiver, NULL);
     119                async_exchange_end(exch);
     120               
    122121                if (rc != EOK) {
    123                         async_obsolete_hangup(phone);
    124                         return rc;
     122                        async_hangup(sess);
     123                        errno = rc;
     124                        return NULL;
    125125                }
    126126        }
    127127       
    128         return phone;
    129 }
    130 
    131 /** Connects to the needed module.
    132  *
    133  * @param[in] need      The needed module service.
    134  * @return              The phone of the needed service.
    135  */
    136 int connect_to_service(services_t need)
    137 {
    138         return service_obsolete_connect_blocking(need, 0, 0);
    139 }
    140 
    141 /** Replies the data to the other party.
    142  *
    143  * @param[in] data      The data buffer to be sent.
     128        return sess;
     129}
     130
     131/** Connect to the needed module.
     132 *
     133 * @param[in] need Needed module service.
     134 *
     135 * @return Session to the needed service.
     136 * @return NULL if the connection timeouted.
     137 *
     138 */
     139async_sess_t *connect_to_service(services_t need)
     140{
     141        return service_connect_blocking(EXCHANGE_SERIALIZE, need, 0, 0);
     142}
     143
     144/** Reply the data to the other party.
     145 *
     146 * @param[in] data        The data buffer to be sent.
    144147 * @param[in] data_length The buffer length.
    145  * @return              EOK on success.
    146  * @return              EINVAL if the client does not expect the data.
    147  * @return              EOVERFLOW if the client does not expect all the data.
    148  *                      Only partial data are transfered.
    149  * @return              Other error codes as defined for the
    150  *                      async_data_read_finalize() function.
     148 *
     149 * @return EOK on success.
     150 * @return EINVAL if the client does not expect the data.
     151 * @return EOVERFLOW if the client does not expect all the data.
     152 *         Only partial data are transfered.
     153 * @return Other error codes as defined for the
     154 *         async_data_read_finalize() function.
     155 *
    151156 */
    152157int data_reply(void *data, size_t data_length)
     
    154159        size_t length;
    155160        ipc_callid_t callid;
    156 
     161       
    157162        /* Fetch the request */
    158163        if (!async_data_read_receive(&callid, &length))
    159164                return EINVAL;
    160 
     165       
    161166        /* Check the requested data size */
    162167        if (length < data_length) {
     
    164169                return EOVERFLOW;
    165170        }
    166 
     171       
    167172        /* Send the data */
    168173        return async_data_read_finalize(callid, data, data_length);
  • uspace/lib/c/generic/net/socket_client.c

    r55091847 r6b82009  
    3939#include <assert.h>
    4040#include <async.h>
    41 #include <async_obsolete.h>
    4241#include <fibril_synch.h>
    4342#include <stdint.h>
     
    8483        /** Socket identifier. */
    8584        int socket_id;
    86         /** Parent module phone. */
    87         int phone;
     85        /** Parent module session. */
     86        async_sess_t *sess;
    8887        /** Parent module service. */
    8988        services_t service;
     
    144143/** Socket client library global data. */
    145144static struct socket_client_globals {
    146         /** TCP module phone. */
    147         int tcp_phone;
    148         /** UDP module phone. */
    149         int udp_phone;
    150 
    151 //      /** The last socket identifier.
    152 //       */
    153 //      int last_id;
     145        /** TCP module session. */
     146        async_sess_t *tcp_sess;
     147        /** UDP module session. */
     148        async_sess_t *udp_sess;
    154149
    155150        /** Active sockets. */
     
    164159        fibril_rwlock_t lock;
    165160} socket_globals = {
    166         .tcp_phone = -1,
    167         .udp_phone = -1,
    168 //      .last_id = 0,
     161        .tcp_sess = NULL,
     162        .udp_sess = NULL,
    169163        .sockets = NULL,
    170164        .lock = FIBRIL_RWLOCK_INITIALIZER(socket_globals.lock)
     
    280274}
    281275
    282 /** Returns the TCP module phone.
    283  *
    284  * Connects to the TCP module if necessary.
    285  *
    286  * @return              The TCP module phone.
    287  * @return              Other error codes as defined for the
    288  *                      bind_service() function.
    289  */
    290 static int socket_get_tcp_phone(void)
    291 {
    292         if (socket_globals.tcp_phone < 0) {
    293                 socket_globals.tcp_phone = bind_service(SERVICE_TCP,
     276/** Return the TCP module session.
     277 *
     278 * Connect to the TCP module if necessary.
     279 *
     280 * @return The TCP module session.
     281 *
     282 */
     283static async_sess_t *socket_get_tcp_sess(void)
     284{
     285        if (socket_globals.tcp_sess == NULL) {
     286                socket_globals.tcp_sess = bind_service(SERVICE_TCP,
    294287                    0, 0, SERVICE_TCP, socket_connection);
    295288        }
    296289
    297         return socket_globals.tcp_phone;
    298 }
    299 
    300 /** Returns the UDP module phone.
    301  *
    302  * Connects to the UDP module if necessary.
    303  *
    304  * @return              The UDP module phone.
    305  * @return              Other error codes as defined for the
    306  *                      bind_service() function.
    307  */
    308 static int socket_get_udp_phone(void)
    309 {
    310         if (socket_globals.udp_phone < 0) {
    311                 socket_globals.udp_phone = bind_service(SERVICE_UDP,
     290        return socket_globals.tcp_sess;
     291}
     292
     293/** Return the UDP module session.
     294 *
     295 * Connect to the UDP module if necessary.
     296 *
     297 * @return The UDP module session.
     298 *
     299 */
     300static async_sess_t *socket_get_udp_sess(void)
     301{
     302        if (socket_globals.udp_sess == NULL) {
     303                socket_globals.udp_sess = bind_service(SERVICE_UDP,
    312304                    0, 0, SERVICE_UDP, socket_connection);
    313305        }
    314306
    315         return socket_globals.udp_phone;
     307        return socket_globals.udp_sess;
    316308}
    317309
     
    329321        sockets = socket_get_sockets();
    330322        count = 0;
    331 //      socket_id = socket_globals.last_id;
    332323
    333324        do {
     
    342333                        if (socket_id < INT_MAX) {
    343334                                ++socket_id;
    344 /*                      } else if(socket_globals.last_id) {
    345  *                              socket_globals.last_id = 0;
    346  *                              socket_id = 1;
    347  */                     } else {
     335                        } else {
    348336                                return ELIMIT;
    349337                        }
    350338                }
    351339        } while (sockets_find(sockets, socket_id));
    352 
    353 //      last_id = socket_id
     340       
    354341        return socket_id;
    355342}
     
    358345 *
    359346 * @param[in,out] socket The socket to be initialized.
    360  * @param[in] socket_id The new socket identifier.
    361  * @param[in] phone     The parent module phone.
    362  * @param[in] service   The parent module service.
    363  */
    364 static void
    365 socket_initialize(socket_t *socket, int socket_id, int phone,
    366     services_t service)
     347 * @param[in] socket_id  The new socket identifier.
     348 * @param[in] sess       The parent module session.
     349 * @param[in] service    The parent module service.
     350 */
     351static void socket_initialize(socket_t *socket, int socket_id,
     352    async_sess_t *sess, services_t service)
    367353{
    368354        socket->socket_id = socket_id;
    369         socket->phone = phone;
     355        socket->sess = sess;
    370356        socket->service = service;
    371357        dyn_fifo_initialize(&socket->received, SOCKET_INITIAL_RECEIVED_SIZE);
     
    397383{
    398384        socket_t *socket;
    399         int phone;
     385        async_sess_t *sess;
    400386        int socket_id;
    401387        services_t service;
     
    414400                        switch (protocol) {
    415401                        case IPPROTO_TCP:
    416                                 phone = socket_get_tcp_phone();
     402                                sess = socket_get_tcp_sess();
    417403                                service = SERVICE_TCP;
    418404                                break;
     
    429415                        switch (protocol) {
    430416                        case IPPROTO_UDP:
    431                                 phone = socket_get_udp_phone();
     417                                sess = socket_get_udp_sess();
    432418                                service = SERVICE_UDP;
    433419                                break;
     
    450436        }
    451437
    452         if (phone < 0)
    453                 return phone;
     438        if (sess == NULL)
     439                return ENOENT;
    454440
    455441        /* Create a new socket structure */
     
    468454                return socket_id;
    469455        }
    470 
    471         rc = (int) async_obsolete_req_3_3(phone, NET_SOCKET, socket_id, 0, service, NULL,
     456       
     457        async_exch_t *exch = async_exchange_begin(sess);
     458        rc = (int) async_req_3_3(exch, NET_SOCKET, socket_id, 0, service, NULL,
    472459            &fragment_size, &header_size);
     460        async_exchange_end(exch);
     461       
    473462        if (rc != EOK) {
    474463                fibril_rwlock_write_unlock(&socket_globals.lock);
     
    481470
    482471        /* Finish the new socket initialization */
    483         socket_initialize(socket, socket_id, phone, service);
     472        socket_initialize(socket, socket_id, sess, service);
    484473        /* Store the new socket */
    485474        rc = sockets_add(socket_get_sockets(), socket_id, socket);
     
    490479                dyn_fifo_destroy(&socket->accepted);
    491480                free(socket);
    492                 async_obsolete_msg_3(phone, NET_SOCKET_CLOSE, (sysarg_t) socket_id, 0,
     481               
     482                exch = async_exchange_begin(sess);
     483                async_msg_3(exch, NET_SOCKET_CLOSE, (sysarg_t) socket_id, 0,
    493484                    service);
     485                async_exchange_end(exch);
     486               
    494487                return rc;
    495488        }
     
    535528
    536529        /* Request the message */
    537         message_id = async_obsolete_send_3(socket->phone, message,
     530        async_exch_t *exch = async_exchange_begin(socket->sess);
     531        message_id = async_send_3(exch, message,
    538532            (sysarg_t) socket->socket_id, arg2, socket->service, NULL);
    539533        /* Send the address */
    540         async_obsolete_data_write_start(socket->phone, data, datalength);
     534        async_data_write_start(exch, data, datalength);
     535        async_exchange_end(exch);
    541536
    542537        fibril_rwlock_read_unlock(&socket_globals.lock);
     
    595590
    596591        /* Request listen backlog change */
    597         result = (int) async_obsolete_req_3_0(socket->phone, NET_SOCKET_LISTEN,
     592        async_exch_t *exch = async_exchange_begin(socket->sess);
     593        result = (int) async_req_3_0(exch, NET_SOCKET_LISTEN,
    598594            (sysarg_t) socket->socket_id, (sysarg_t) backlog, socket->service);
     595        async_exchange_end(exch);
    599596
    600597        fibril_rwlock_read_unlock(&socket_globals.lock);
     
    666663                return socket_id;
    667664        }
    668         socket_initialize(new_socket, socket_id, socket->phone,
     665        socket_initialize(new_socket, socket_id, socket->sess,
    669666            socket->service);
    670667        result = sockets_add(socket_get_sockets(), new_socket->socket_id,
     
    678675
    679676        /* Request accept */
    680         message_id = async_obsolete_send_5(socket->phone, NET_SOCKET_ACCEPT,
     677        async_exch_t *exch = async_exchange_begin(socket->sess);
     678        message_id = async_send_5(exch, NET_SOCKET_ACCEPT,
    681679            (sysarg_t) socket->socket_id, 0, socket->service, 0,
    682680            new_socket->socket_id, &answer);
    683681
    684682        /* Read address */
    685         async_obsolete_data_read_start(socket->phone, cliaddr, *addrlen);
     683        async_data_read_start(exch, cliaddr, *addrlen);
     684        async_exchange_end(exch);
     685       
    686686        fibril_rwlock_write_unlock(&socket_globals.lock);
    687687        async_wait_for(message_id, &ipc_result);
     
    777777
    778778        /* Request close */
    779         rc = (int) async_obsolete_req_3_0(socket->phone, NET_SOCKET_CLOSE,
     779        async_exch_t *exch = async_exchange_begin(socket->sess);
     780        rc = (int) async_req_3_0(exch, NET_SOCKET_CLOSE,
    780781            (sysarg_t) socket->socket_id, 0, socket->service);
     782        async_exchange_end(exch);
     783       
    781784        if (rc != EOK) {
    782785                fibril_rwlock_write_unlock(&socket_globals.lock);
     
    850853
    851854        /* Request send */
    852         message_id = async_obsolete_send_5(socket->phone, message,
     855        async_exch_t *exch = async_exchange_begin(socket->sess);
     856       
     857        message_id = async_send_5(exch, message,
    853858            (sysarg_t) socket->socket_id,
    854859            (fragments == 1 ? datalength : socket->data_fragment_size),
     
    857862        /* Send the address if given */
    858863        if (!toaddr ||
    859             (async_obsolete_data_write_start(socket->phone, toaddr, addrlen) == EOK)) {
     864            (async_data_write_start(exch, toaddr, addrlen) == EOK)) {
    860865                if (fragments == 1) {
    861866                        /* Send all if only one fragment */
    862                         async_obsolete_data_write_start(socket->phone, data, datalength);
     867                        async_data_write_start(exch, data, datalength);
    863868                } else {
    864869                        /* Send the first fragment */
    865                         async_obsolete_data_write_start(socket->phone, data,
     870                        async_data_write_start(exch, data,
    866871                            socket->data_fragment_size - socket->header_size);
    867872                        data = ((const uint8_t *) data) +
     
    870875                        /* Send the middle fragments */
    871876                        while (--fragments > 1) {
    872                                 async_obsolete_data_write_start(socket->phone, data,
     877                                async_data_write_start(exch, data,
    873878                                    socket->data_fragment_size);
    874879                                data = ((const uint8_t *) data) +
     
    877882
    878883                        /* Send the last fragment */
    879                         async_obsolete_data_write_start(socket->phone, data,
     884                        async_data_write_start(exch, data,
    880885                            (datalength + socket->header_size) %
    881886                            socket->data_fragment_size);
    882887                }
    883888        }
     889       
     890        async_exchange_end(exch);
    884891
    885892        async_wait_for(message_id, &result);
     
    10231030                return 0;
    10241031        }
     1032       
     1033        async_exch_t *exch = async_exchange_begin(socket->sess);
    10251034
    10261035        /* Prepare lengths if more fragments */
     
    10351044
    10361045                /* Request packet data */
    1037                 message_id = async_obsolete_send_4(socket->phone, message,
     1046                message_id = async_send_4(exch, message,
    10381047                    (sysarg_t) socket->socket_id, 0, socket->service,
    10391048                    (sysarg_t) flags, &answer);
     
    10411050                /* Read the address if desired */
    10421051                if(!fromaddr ||
    1043                     (async_obsolete_data_read_start(socket->phone, fromaddr,
     1052                    (async_data_read_start(exch, fromaddr,
    10441053                    *addrlen) == EOK)) {
    10451054                        /* Read the fragment lengths */
    1046                         if (async_obsolete_data_read_start(socket->phone, lengths,
     1055                        if (async_data_read_start(exch, lengths,
    10471056                            sizeof(int) * (fragments + 1)) == EOK) {
    10481057                                if (lengths[fragments] <= datalength) {
     
    10511060                                        for (index = 0; index < fragments;
    10521061                                            ++index) {
    1053                                                 async_obsolete_data_read_start(
    1054                                                     socket->phone, data,
     1062                                                async_data_read_start(exch, data,
    10551063                                                    lengths[index]);
    10561064                                                data = ((uint8_t *) data) +
     
    10641072        } else { /* fragments == 1 */
    10651073                /* Request packet data */
    1066                 message_id = async_obsolete_send_4(socket->phone, message,
     1074                message_id = async_send_4(exch, message,
    10671075                    (sysarg_t) socket->socket_id, 0, socket->service,
    10681076                    (sysarg_t) flags, &answer);
     
    10701078                /* Read the address if desired */
    10711079                if (!fromaddr ||
    1072                     (async_obsolete_data_read_start(socket->phone, fromaddr,
    1073                         *addrlen) == EOK)) {
     1080                    (async_data_read_start(exch, fromaddr, *addrlen) == EOK)) {
    10741081                        /* Read all if only one fragment */
    1075                         async_obsolete_data_read_start(socket->phone, data, datalength);
     1082                        async_data_read_start(exch, data, datalength);
    10761083                }
    10771084        }
     1085       
     1086        async_exchange_end(exch);
    10781087
    10791088        async_wait_for(message_id, &ipc_result);
     
    11871196
    11881197        /* Request option value */
    1189         message_id = async_obsolete_send_3(socket->phone, NET_SOCKET_GETSOCKOPT,
     1198        async_exch_t *exch = async_exchange_begin(socket->sess);
     1199       
     1200        message_id = async_send_3(exch, NET_SOCKET_GETSOCKOPT,
    11901201            (sysarg_t) socket->socket_id, (sysarg_t) optname, socket->service,
    11911202            NULL);
    11921203
    11931204        /* Read the length */
    1194         if (async_obsolete_data_read_start(socket->phone, optlen,
     1205        if (async_data_read_start(exch, optlen,
    11951206            sizeof(*optlen)) == EOK) {
    11961207                /* Read the value */
    1197                 async_obsolete_data_read_start(socket->phone, value, *optlen);
    1198         }
     1208                async_data_read_start(exch, value, *optlen);
     1209        }
     1210       
     1211        async_exchange_end(exch);
    11991212
    12001213        fibril_rwlock_read_unlock(&socket_globals.lock);
  • uspace/lib/c/include/adt/measured_strings.h

    r55091847 r6b82009  
    4141
    4242#include <sys/types.h>
     43#include <async.h>
    4344
    4445/** Type definition of the character string with measured length.
     
    6465extern int measured_strings_receive(measured_string_t **, uint8_t **, size_t);
    6566extern int measured_strings_reply(const measured_string_t *, size_t);
    66 extern int measured_strings_return(int, measured_string_t **, uint8_t **, size_t);
    67 extern int measured_strings_send(int, const measured_string_t *, size_t);
     67
     68extern int measured_strings_return(async_exch_t *, measured_string_t **,
     69    uint8_t **, size_t);
     70extern int measured_strings_send(async_exch_t *, const measured_string_t *,
     71    size_t);
    6872
    6973#endif
  • uspace/lib/c/include/ipc/net.h

    r55091847 r6b82009  
    335335#define IPC_GET_ERROR(call)  ((services_t) IPC_GET_ARG4(call))
    336336
    337 /** Return the phone message argument.
    338  *
    339  * @param[in] call Message call structure.
    340  *
    341  */
    342 #define IPC_GET_PHONE(call)  ((int) IPC_GET_ARG5(call))
    343 
    344337/** Set the device identifier in the message answer.
    345338 *
  • uspace/lib/c/include/net/icmp_api.h

    r55091847 r6b82009  
    4242#include <sys/types.h>
    4343#include <sys/time.h>
    44 
    4544#include <adt/measured_strings.h>
    4645#include <net/ip_codes.h>
    4746#include <net/icmp_codes.h>
    4847#include <net/icmp_common.h>
     48#include <async.h>
    4949
    5050/** @name ICMP module application interface
     
    5353/*@{*/
    5454
    55 extern int icmp_echo_msg(int, size_t, mseconds_t, ip_ttl_t, ip_tos_t, int,
    56     const struct sockaddr *, socklen_t);
     55extern int icmp_echo_msg(async_sess_t *, size_t, mseconds_t, ip_ttl_t, ip_tos_t,
     56    int, const struct sockaddr *, socklen_t);
    5757
    5858/*@}*/
  • uspace/lib/c/include/net/icmp_common.h

    r55091847 r6b82009  
    4040#include <ipc/services.h>
    4141#include <sys/time.h>
     42#include <async.h>
    4243
    43 extern int icmp_connect_module(void);
     44extern async_sess_t *icmp_connect_module(void);
    4445
    4546#endif
  • uspace/lib/c/include/net/modules.h

    r55091847 r6b82009  
    4646#include <sys/time.h>
    4747
    48 /** Connect to the needed module function type definition.
     48/** Connect to module function type definition.
    4949 *
    50  * @param[in] need The needed module service.
    51  *
    52  * @return The phone of the needed service.
     50 * @return Session to the service.
    5351 *
    5452 */
    55 typedef int connect_module_t(services_t need);
     53typedef async_sess_t *connect_module_t(services_t);
    5654
    5755extern void answer_call(ipc_callid_t, int, ipc_call_t *, size_t);
    58 extern int bind_service(services_t, sysarg_t, sysarg_t, sysarg_t,
     56extern async_sess_t *bind_service(services_t, sysarg_t, sysarg_t, sysarg_t,
    5957    async_client_conn_t);
    60 extern int connect_to_service(services_t);
     58extern async_sess_t *connect_to_service(services_t);
    6159extern int data_reply(void *, size_t);
    6260extern void refresh_answer(ipc_call_t *, size_t *);
  • uspace/lib/net/adt/module_map.c

    r55091847 r6b82009  
    3939#include <unistd.h>
    4040#include <errno.h>
    41 
    42 #include <ipc/services.h>
    43 
    4441#include <net/modules.h>
    45 
    4642#include <adt/generic_char_map.h>
    4743#include <adt/module_map.h>
     
    4945GENERIC_CHAR_MAP_IMPLEMENT(modules, module_t)
    5046
    51 /** Adds module to the module map.
     47/** Add module to the module map.
    5248 *
    53  * @param[out] module   The module structure added.
    54  * @param[in] modules   The module map.
    55  * @param[in] name      The module name.
    56  * @param[in] filename  The full path filename.
    57  * @param[in] service   The module service.
    58  * @param[in] task_id   The module current task identifier. Zero means not
    59  *                      running.
    60  * @param[in] connect_module The module connecting function.
    61  * @return              EOK on success.
    62  * @return              ENOMEM if there is not enough memory left.
     49 * @param[out] module         Module structure added.
     50 * @param[in]  modules        Module map.
     51 * @param[in]  name           Module name.
     52 * @param[in]  filename       Full path filename.
     53 * @param[in]  service        Module service.
     54 * @param[in]  task_id        Module current task identifier.
     55 *                            Zero means not running.
     56 * @param[in]  connect_module Module connecting function.
     57 *
     58 * @return EOK on success.
     59 * @return ENOMEM if there is not enough memory left.
     60 *
    6361 */
    64 int
    65 add_module(module_t **module, modules_t *modules, const uint8_t *name,
     62int add_module(module_t **module, modules_t *modules, const uint8_t *name,
    6663    const uint8_t *filename, services_t service, task_id_t task_id,
    6764    connect_module_t connect_module)
     
    6966        module_t *tmp_module;
    7067        int rc;
    71 
     68       
    7269        tmp_module = (module_t *) malloc(sizeof(module_t));
    7370        if (!tmp_module)
    7471                return ENOMEM;
    75 
     72       
    7673        tmp_module->task_id = task_id;
    77         tmp_module->phone = 0;
     74        tmp_module->sess = NULL;
    7875        tmp_module->usage = 0;
    7976        tmp_module->name = name;
     
    8178        tmp_module->service = service;
    8279        tmp_module->connect_module = connect_module;
    83 
     80       
    8481        rc = modules_add(modules, tmp_module->name, 0, tmp_module);
    8582        if (rc != EOK) {
     
    8784                return rc;
    8885        }
     86       
    8987        if (module)
    9088                *module = tmp_module;
    91 
     89       
    9290        return EOK;
    9391}
    9492
    95 /** Searches and returns the specified module.
     93/** Search and return the specified module.
    9694 *
    9795 * If the module is not running, the module filaname is spawned.
    9896 * If the module is not connected, the connect_function is called.
    9997 *
    100  * @param[in] modules   The module map.
    101  * @param[in] name      The module name.
    102  * @return              The running module found. It does not have to be
    103  *                      connected.
    104  * @return              NULL if there is no such module.
     98 * @param[in] modules Module map.
     99 * @param[in] name    Module name.
     100 *
     101 * @return The running module found. It does not have to be
     102 *         connected.
     103 * @return NULL if there is no such module.
     104 *
    105105 */
    106106module_t *get_running_module(modules_t *modules, uint8_t *name)
    107107{
    108         module_t *module;
    109 
    110         module = modules_find(modules, name, 0);
     108        module_t *module = modules_find(modules, name, 0);
    111109        if (!module)
    112110                return NULL;
    113 
     111       
    114112        if (!module->task_id) {
    115113                module->task_id = net_spawn(module->filename);
     
    117115                        return NULL;
    118116        }
    119         if (!module->phone)
    120                 module->phone = module->connect_module(module->service);
    121 
     117       
     118        if (!module->sess)
     119                module->sess = module->connect_module(module->service);
     120       
    122121        return module;
    123122}
  • uspace/lib/net/generic/generic.c

    r55091847 r6b82009  
    3737#include <generic.h>
    3838#include <async.h>
    39 #include <async_obsolete.h>
    4039#include <ipc/services.h>
    4140#include <net/device.h>
     
    4544/** Notify the module about the device state change.
    4645 *
    47  * @param[in] phone     The service module phone.
    48  * @param[in] message   The service specific message.
    49  * @param[in] device_id The device identifier.
    50  * @param[in] state     The new device state.
    51  * @param[in] target    The target module service.
    52  * @return              EOK on success.
    53  *
    54  */
    55 int
    56 generic_device_state_msg_remote(int phone, int message, device_id_t device_id,
    57     int state, services_t target)
    58 {
    59         async_obsolete_msg_3(phone, (sysarg_t) message, (sysarg_t) device_id,
    60             (sysarg_t) state, target);
     46 * @param[in] sess      Service module session.
     47 * @param[in] message   Service specific message.
     48 * @param[in] device_id Device identifier.
     49 * @param[in] state     New device state.
     50 * @param[in] target    Target module service.
     51 *
     52 * @return EOK on success.
     53 *
     54 */
     55int generic_device_state_msg_remote(async_sess_t *sess, sysarg_t message,
     56    device_id_t device_id, sysarg_t state, services_t target)
     57{
     58        async_exch_t *exch = async_exchange_begin(sess);
     59        async_msg_3(exch, message, (sysarg_t) device_id, state, target);
     60        async_exchange_end(exch);
    6161       
    6262        return EOK;
     
    6565/** Notify a module about the device.
    6666 *
    67  * @param[in] phone     The service module phone.
    68  * @param[in] message   The service specific message.
    69  * @param[in] device_id The device identifier.
    70  * @param[in] arg2      The second argument of the message.
    71  * @param[in] service   The device module service.
    72  * @return              EOK on success.
    73  * @return              Other error codes as defined for the specific service
    74  *                       message.
    75  *
    76  */
    77 int
    78 generic_device_req_remote(int phone, int message, device_id_t device_id,
    79     int arg2, services_t service)
    80 {
    81         return (int) async_obsolete_req_3_0(phone, (sysarg_t) message,
    82             (sysarg_t) device_id, (sysarg_t) arg2, (sysarg_t) service);
     67 * @param[in] sess      Service module session.
     68 * @param[in] message   Service specific message.
     69 * @param[in] device_id Device identifier.
     70 * @param[in] arg2      Second argument of the message.
     71 * @param[in] service   Device module service.
     72 *
     73 * @return EOK on success.
     74 * @return Other error codes as defined for the specific service
     75 *         message.
     76 *
     77 */
     78int generic_device_req_remote(async_sess_t *sess, sysarg_t message,
     79    device_id_t device_id, sysarg_t arg2, services_t service)
     80{
     81        async_exch_t *exch = async_exchange_begin(sess);
     82        int rc = async_req_3_0(exch, message, (sysarg_t) device_id,
     83            arg2, (sysarg_t) service);
     84        async_exchange_end(exch);
     85       
     86        return rc;
    8387}
    8488
    8589/** Returns the address.
    8690 *
    87  * @param[in] phone     The service module phone.
    88  * @param[in] message   The service specific message.
    89  * @param[in] device_id The device identifier.
    90  * @param[out] address  The desired address.
    91  * @param[out] data     The address data container.
    92  * @return              EOK on success.
    93  * @return              EBADMEM if the address parameter and/or the data
    94  *                      parameter is NULL.
    95  * @return              Other error codes as defined for the specific service
    96  *                      message.
    97  */
    98 int
    99 generic_get_addr_req(int phone, int message, device_id_t device_id,
    100     measured_string_t **address, uint8_t **data)
    101 {
    102         aid_t message_id;
     91 * @param[in] sess      Service module session.
     92 * @param[in] message   Service specific message.
     93 * @param[in] device_id Device identifier.
     94 * @param[out] address  Desired address.
     95 * @param[out] data     Address data container.
     96 *
     97 * @return EOK on success.
     98 * @return EBADMEM if the address parameter and/or the data
     99 *         parameter is NULL.
     100 * @return Other error codes as defined for the specific service
     101 *         message.
     102 *
     103 */
     104int generic_get_addr_req(async_sess_t *sess, sysarg_t message,
     105    device_id_t device_id, measured_string_t **address, uint8_t **data)
     106{
     107        if ((!address) || (!data))
     108                return EBADMEM;
     109       
     110        /* Request the address */
     111        async_exch_t *exch = async_exchange_begin(sess);
     112        aid_t message_id = async_send_1(exch, message, (sysarg_t) device_id,
     113            NULL);
     114        int rc = measured_strings_return(exch, address, data, 1);
     115        async_exchange_end(exch);
     116       
    103117        sysarg_t result;
    104         int string;
    105 
    106         if (!address || !data)
    107                 return EBADMEM;
    108 
    109         /* Request the address */
    110         message_id = async_obsolete_send_1(phone, (sysarg_t) message,
    111             (sysarg_t) device_id, NULL);
    112         string = measured_strings_return(phone, address, data, 1);
    113118        async_wait_for(message_id, &result);
    114 
     119       
    115120        /* If not successful */
    116         if ((string == EOK) && (result != EOK)) {
     121        if ((rc == EOK) && (result != EOK)) {
    117122                /* Clear the data */
    118123                free(*address);
     
    125130/** Return the device packet dimension for sending.
    126131 *
    127  * @param[in] phone     The service module phone.
    128  * @param[in] message   The service specific message.
    129  * @param[in] device_id The device identifier.
    130  * @param[out] packet_dimension The packet dimension.
    131  * @return              EOK on success.
    132  * @return              EBADMEM if the packet_dimension parameter is NULL.
    133  * @return              Other error codes as defined for the specific service
    134  *                      message.
    135  */
    136 int
    137 generic_packet_size_req_remote(int phone, int message, device_id_t device_id,
    138     packet_dimension_t *packet_dimension)
     132 * @param[in] sess              Service module session.
     133 * @param[in] message           Service specific message.
     134 * @param[in] device_id         Device identifier.
     135 * @param[out] packet_dimension Packet dimension.
     136 *
     137 * @return EOK on success.
     138 * @return EBADMEM if the packet_dimension parameter is NULL.
     139 * @return Other error codes as defined for the specific service
     140 *         message.
     141 *
     142 */
     143int generic_packet_size_req_remote(async_sess_t *sess, sysarg_t message,
     144    device_id_t device_id, packet_dimension_t *packet_dimension)
    139145{
    140146        if (!packet_dimension)
     
    146152        sysarg_t suffix;
    147153       
    148         sysarg_t result = async_obsolete_req_1_4(phone, (sysarg_t) message,
    149             (sysarg_t) device_id, &addr_len, &prefix, &content, &suffix);
     154        async_exch_t *exch = async_exchange_begin(sess);
     155        sysarg_t result = async_req_1_4(exch, message, (sysarg_t) device_id,
     156            &addr_len, &prefix, &content, &suffix);
     157        async_exchange_end(exch);
    150158       
    151159        packet_dimension->prefix = (size_t) prefix;
     
    159167/** Pass the packet queue to the module.
    160168 *
    161  * @param[in] phone     The service module phone.
    162  * @param[in] message   The service specific message.
    163  * @param[in] device_id The device identifier.
    164  * @param[in] packet_id The received packet or the received packet queue
    165  *                      identifier.
    166  * @param[in] target    The target module service.
    167  * @param[in] error     The error module service.
    168  * @return              EOK on success.
    169  */
    170 int
    171 generic_received_msg_remote(int phone, int message, device_id_t device_id,
    172     packet_id_t packet_id, services_t target, services_t error)
    173 {
     169 * @param[in] sess      Service module session.
     170 * @param[in] message   Service specific message.
     171 * @param[in] device_id Device identifier.
     172 * @param[in] packet_id Received packet or the received packet queue
     173 *                      identifier.
     174 * @param[in] target    Target module service.
     175 * @param[in] error     Error module service.
     176 *
     177 * @return EOK on success.
     178 *
     179 */
     180int generic_received_msg_remote(async_sess_t *sess, sysarg_t message,
     181    device_id_t device_id, packet_id_t packet_id, services_t target,
     182    services_t error)
     183{
     184        async_exch_t *exch = async_exchange_begin(sess);
     185       
    174186        if (error) {
    175                 async_obsolete_msg_4(phone, (sysarg_t) message, (sysarg_t) device_id,
     187                async_msg_4(exch, message, (sysarg_t) device_id,
    176188                    (sysarg_t) packet_id, (sysarg_t) target, (sysarg_t) error);
    177189        } else {
    178                 async_obsolete_msg_3(phone, (sysarg_t) message, (sysarg_t) device_id,
     190                async_msg_3(exch, message, (sysarg_t) device_id,
    179191                    (sysarg_t) packet_id, (sysarg_t) target);
    180192        }
    181193       
     194        async_exchange_end(exch);
     195       
    182196        return EOK;
    183197}
     
    185199/** Send the packet queue.
    186200 *
    187  * @param[in] phone     The service module phone.
    188  * @param[in] message   The service specific message.
    189  * @param[in] device_id The device identifier.
    190  * @param[in] packet_id The packet or the packet queue identifier.
    191  * @param[in] sender    The sending module service.
    192  * @param[in] error     The error module service.
    193  * @return              EOK on success.
    194  *
    195  */
    196 int
    197 generic_send_msg_remote(int phone, int message, device_id_t device_id,
    198     packet_id_t packet_id, services_t sender, services_t error)
    199 {
     201 * @param[in] sess      Service module session.
     202 * @param[in] message   Service specific message.
     203 * @param[in] device_id Device identifier.
     204 * @param[in] packet_id Packet or the packet queue identifier.
     205 * @param[in] sender    Sending module service.
     206 * @param[in] error     Error module service.
     207 *
     208 * @return EOK on success.
     209 *
     210 */
     211int generic_send_msg_remote(async_sess_t *sess, sysarg_t message,
     212    device_id_t device_id, packet_id_t packet_id, services_t sender,
     213    services_t error)
     214{
     215        async_exch_t *exch = async_exchange_begin(sess);
     216       
    200217        if (error) {
    201                 async_obsolete_msg_4(phone, (sysarg_t) message, (sysarg_t) device_id,
     218                async_msg_4(exch, message, (sysarg_t) device_id,
    202219                    (sysarg_t) packet_id, (sysarg_t) sender, (sysarg_t) error);
    203220        } else {
    204                 async_obsolete_msg_3(phone, (sysarg_t) message, (sysarg_t) device_id,
     221                async_msg_3(exch, message, (sysarg_t) device_id,
    205222                    (sysarg_t) packet_id, (sysarg_t) sender);
    206223        }
    207224       
     225        async_exchange_end(exch);
     226       
    208227        return EOK;
    209228}
     
    213232 * Allocates and returns the needed memory block as the data parameter.
    214233 *
    215  * @param[in] phone     The service module phone.
    216  * @param[in] message   The service specific message.
    217  * @param[in] device_id The device identifier.
    218  * @param[in] service   The module service.
    219  * @param[in] configuration The key strings.
    220  * @param[in] count     The number of configuration keys.
    221  * @param[out] translation The translated values.
    222  * @param[out] data     The translation data container.
    223  * @return              EOK on success.
    224  * @return              EINVAL if the configuration parameter is NULL.
    225  * @return              EINVAL if the count parameter is zero.
    226  * @return              EBADMEM if the translation or the data parameters are
    227  *                      NULL.
    228  * @return              Other error codes as defined for the specific service
    229  *                      message.
    230  */
    231 int
    232 generic_translate_req(int phone, int message, device_id_t device_id,
    233     services_t service, measured_string_t *configuration, size_t count,
     234 * @param[in] sess          Service module session.
     235 * @param[in] message       Service specific message.
     236 * @param[in] device_id     Device identifier.
     237 * @param[in] service       Module service.
     238 * @param[in] configuration Key strings.
     239 * @param[in] count         Number of configuration keys.
     240 * @param[out] translation  Translated values.
     241 * @param[out] data         Translation data container.
     242 *
     243 * @return EOK on success.
     244 * @return EINVAL if the configuration parameter is NULL.
     245 * @return EINVAL if the count parameter is zero.
     246 * @return EBADMEM if the translation or the data parameters are
     247 *         NULL.
     248 * @return Other error codes as defined for the specific service
     249 *         message.
     250 *
     251 */
     252int generic_translate_req(async_sess_t *sess, sysarg_t message,
     253    device_id_t device_id, services_t service,
     254    measured_string_t *configuration, size_t count,
    234255    measured_string_t **translation, uint8_t **data)
    235256{
    236         aid_t message_id;
     257        if ((!configuration) || (count == 0))
     258                return EINVAL;
     259       
     260        if ((!translation) || (!data))
     261                return EBADMEM;
     262       
     263        /* Request the translation */
     264        async_exch_t *exch = async_exchange_begin(sess);
     265        aid_t message_id = async_send_3(exch, message, (sysarg_t) device_id,
     266            (sysarg_t) count, (sysarg_t) service, NULL);
     267        measured_strings_send(exch, configuration, count);
     268        int rc = measured_strings_return(exch, translation, data, count);
     269        async_exchange_end(exch);
     270       
    237271        sysarg_t result;
    238         int string;
    239 
    240         if (!configuration || (count == 0))
    241                 return EINVAL;
    242         if (!translation || !data)
    243                 return EBADMEM;
    244 
    245         /* Request the translation */
    246         message_id = async_obsolete_send_3(phone, (sysarg_t) message,
    247             (sysarg_t) device_id, (sysarg_t) count, (sysarg_t) service, NULL);
    248         measured_strings_send(phone, configuration, count);
    249         string = measured_strings_return(phone, translation, data, count);
    250272        async_wait_for(message_id, &result);
    251 
     273       
    252274        /* If not successful */
    253         if ((string == EOK) && (result != EOK)) {
     275        if ((rc == EOK) && (result != EOK)) {
    254276                /* Clear the data */
    255277                free(*translation);
    256278                free(*data);
    257279        }
    258 
     280       
    259281        return (int) result;
    260282}
  • uspace/lib/net/generic/net_remote.c

    r55091847 r6b82009  
    4747#include <adt/measured_strings.h>
    4848
    49 /** Connects to the networking module.
     49/** Connect to the networking module.
    5050 *
    51  * @return              The networking module phone on success.
     51 * @return Networking module session on success.
     52 *
    5253 */
    53 int net_connect_module(void)
     54async_sess_t *net_connect_module(void)
    5455{
    5556        return connect_to_service(SERVICE_NETWORKING);
    5657}
    5758
    58 /** Frees the received settings.
     59/** Free the received settings.
    5960 *
    60  * @param[in] settings  The received settings.
    61  * @param[in] data      The received settings data.
    62  * @see net_get_device_conf_req()
     61 * @param[in] settings Received settings.
     62 * @param[in] data     Received settings data.
     63 *
     64 * @see net_get_device_conf_req()
    6365 * @see net_get_conf_req()
     66 *
    6467 */
    6568void net_free_settings(measured_string_t *settings, uint8_t *data)
     
    7174}
    7275
    73 /** Returns the global configuration.
     76/** Return the global configuration.
    7477 *
    7578 * The configuration names are read and the appropriate settings are set
     
    7780 * configuration.
    7881 *
    79  * @param[in] net_phone The networking module phone.
    80  * @param[in,out] configuration The requested configuration. The names are read
    81  * and the appropriate settings are set instead.
     82 * @param[in]     sess          Networking module session.
     83 * @param[in,out] configuration Requested configuration. The names are
     84 *                              read and the appropriate settings are set
     85 *                              instead.
    8286 *
    83  * @param[in] count     The configuration entries count.
    84  * @param[in,out] data  The configuration and settings data.
    85  * @return              EOK on success.
    86  * @return              EINVAL if the configuration is NULL.
    87  * @return              EINVAL if the count is zero.
    88  * @return              Other error codes as defined for the
    89  *                      generic_translate_req() function.
     87 * @param[in]     count         Configuration entries count.
     88 * @param[in,out] data          Configuration and settings data.
     89 *
     90 * @return EOK on success.
     91 * @return EINVAL if the configuration is NULL.
     92 * @return EINVAL if the count is zero.
     93 * @return Other error codes as defined for the
     94 *         generic_translate_req() function.
     95 *
    9096 */
    91 int
    92 net_get_conf_req(int net_phone, measured_string_t **configuration,
     97int net_get_conf_req(async_sess_t *sess, measured_string_t **configuration,
    9398    size_t count, uint8_t **data)
    9499{
    95         return generic_translate_req(net_phone, NET_NET_GET_DEVICE_CONF, 0, 0,
     100        return generic_translate_req(sess, NET_NET_GET_DEVICE_CONF, 0, 0,
    96101            *configuration, count, configuration, data);
    97102}
    98103
    99 /** Returns the device specific configuration.
     104/** Return the device specific configuration.
    100105 *
    101  * Returns the global configuration if the device specific is not found.
     106 * Return the global configuration if the device specific is not found.
    102107 * The configuration names are read and the appropriate settings are set
    103108 * instead. Call net_free_settings() function to release the returned
    104109 * configuration.
    105110 *
    106  * @param[in] net_phone The networking module phone.
    107  * @param[in] device_id The device identifier.
    108  * @param[in,out] configuration The requested device configuration. The names
    109  *                      are read and the appropriate settings are set instead.
    110  * @param[in] count     The configuration entries count.
    111  * @param[in,out] data  The configuration and settings data.
    112  * @return              EOK on success.
    113  * @return              EINVAL if the configuration is NULL.
    114  * @return              EINVAL if the count is zero.
    115  * @return              Other error codes as defined for the
    116  *                      generic_translate_req() function.
     111 * @param[in]     sess          The networking module session.
     112 * @param[in]     device_id     Device identifier.
     113 * @param[in,out] configuration Requested device configuration. The names
     114 *                              are read and the appropriate settings are
     115 *                              set instead.
     116 * @param[in]     count         Configuration entries count.
     117 * @param[in,out] data          Configuration and settings data.
     118 *
     119 * @return EOK on success.
     120 * @return EINVAL if the configuration is NULL.
     121 * @return EINVAL if the count is zero.
     122 * @return Other error codes as defined for the
     123 *         generic_translate_req() function.
     124 *
    117125 */
    118 int
    119 net_get_device_conf_req(int net_phone, device_id_t device_id,
     126int net_get_device_conf_req(async_sess_t *sess, device_id_t device_id,
    120127    measured_string_t **configuration, size_t count, uint8_t **data)
    121128{
    122         return generic_translate_req(net_phone, NET_NET_GET_DEVICE_CONF,
     129        return generic_translate_req(sess, NET_NET_GET_DEVICE_CONF,
    123130            device_id, 0, *configuration, count, configuration, data);
    124131}
  • uspace/lib/net/generic/packet_client.c

    r55091847 r6b82009  
    247247}
    248248
    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  * @return              The packet copy.
    257  * @return              NULL on error.
    258  */
    259 packet_t *packet_get_copy(int phone, packet_t *packet)
    260 {
    261         packet_t *copy;
    262         uint8_t * src = NULL;
    263         uint8_t * dest = NULL;
    264         size_t addrlen;
    265 
    266         if (!packet_is_valid(packet))
    267                 return NULL;
    268 
     249/** Return the packet copy.
     250 *
     251 * Copy the addresses, data, order and metric values.
     252 * Queue placement is not copied.
     253 *
     254 * @param[in] sess   Packet server module session.
     255 * @param[in] packet Original packet.
     256 *
     257 * @return Packet copy.
     258 * @return NULL on error.
     259 *
     260 */
     261packet_t *packet_get_copy(async_sess_t *sess, packet_t *packet)
     262{
     263        if (!packet_is_valid(packet))
     264                return NULL;
     265       
    269266        /* Get a new packet */
    270         copy = packet_get_4_remote(phone, PACKET_DATA_LENGTH(packet),
     267        packet_t *copy = packet_get_4_remote(sess, PACKET_DATA_LENGTH(packet),
    271268            PACKET_MAX_ADDRESS_LENGTH(packet), packet->max_prefix,
    272269            PACKET_MIN_SUFFIX(packet));
     270       
    273271        if (!copy)
    274272                return NULL;
    275 
     273       
    276274        /* Get addresses */
    277         addrlen = packet_get_addr(packet, &src, &dest);
     275        uint8_t *src = NULL;
     276        uint8_t *dest = NULL;
     277        size_t addrlen = packet_get_addr(packet, &src, &dest);
     278       
    278279        /* Copy data */
    279280        if ((packet_copy_data(copy, packet_get_data(packet),
     
    286287                return copy;
    287288        } else {
    288                 pq_release_remote(phone, copy->packet_id);
     289                pq_release_remote(sess, copy->packet_id);
    289290                return NULL;
    290291        }
  • uspace/lib/net/generic/packet_remote.c

    r55091847 r6b82009  
    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
  • uspace/lib/net/il/arp_remote.c

    r55091847 r6b82009  
    3838#include <arp_interface.h>
    3939#include <generic.h>
    40 
    41 #include <async.h>
    42 #include <async_obsolete.h>
    43 #include <errno.h>
    4440#include <ipc/services.h>
    4541#include <ipc/arp.h>
    46 
    4742#include <net/modules.h>
    4843#include <net/device.h>
    4944#include <adt/measured_strings.h>
     45#include <async.h>
     46#include <errno.h>
    5047
    51 /** Connects to the ARP module.
     48/** Connect to the ARP module.
    5249 *
    53  * @param service       The ARP module service. Ignored parameter.
    54  * @return              The ARP module phone on success.
     50 * @return ARP module session on success.
     51 *
    5552 */
    56 int arp_connect_module(services_t service)
     53async_sess_t *arp_connect_module(services_t service)
    5754{
    58         if (service != SERVICE_ARP)
    59                 return EINVAL;
    60 
     55        // FIXME: Get rid of the useless argument
    6156        return connect_to_service(SERVICE_ARP);
    6257}
     
    6459/** Cleans the cache.
    6560 *
    66  * @param[in] arp_phone The ARP module phone used for (semi)remote calls.
    67  * @return              EOK on success.
     61 * @param[in] sess ARP module session.
     62 *
     63 * @return EOK on success.
     64 *
    6865 */
    69 int arp_clean_cache_req(int arp_phone)
     66int arp_clean_cache_req(async_sess_t *sess)
    7067{
    71         return (int) async_obsolete_req_0_0(arp_phone, NET_ARP_CLEAN_CACHE);
     68        async_exch_t *exch = async_exchange_begin(sess);
     69        int rc = async_req_0_0(exch, NET_ARP_CLEAN_CACHE);
     70        async_exchange_end(exch);
     71       
     72        return rc;
    7273}
    7374
    74 /** Clears the given protocol address from the cache.
     75/** Clear the given protocol address from the cache.
    7576 *
    76  * @param[in] arp_phone The ARP module phone used for (semi)remote calls.
    77  * @param[in] device_id The device identifier.
    78  * @param[in] protocol  The requesting protocol service.
    79  * @param[in] address   The protocol address to be cleared.
    80  * @return              EOK on success.
    81  * @return              ENOENT if the mapping is not found.
     77 * @param[in] sess      ARP module session.
     78 * @param[in] device_id Device identifier.
     79 * @param[in] protocol  Requesting protocol service.
     80 * @param[in] address   Protocol address to be cleared.
     81 *
     82 * @return EOK on success.
     83 * @return ENOENT if the mapping is not found.
     84 *
    8285 */
    83 int
    84 arp_clear_address_req(int arp_phone, device_id_t device_id, services_t protocol,
    85     measured_string_t *address)
     86int arp_clear_address_req(async_sess_t *sess, device_id_t device_id,
     87    services_t protocol, measured_string_t *address)
    8688{
    87         aid_t message_id;
     89        async_exch_t *exch = async_exchange_begin(sess);
     90        aid_t message_id = async_send_2(exch, NET_ARP_CLEAR_ADDRESS,
     91            (sysarg_t) device_id, protocol, NULL);
     92        measured_strings_send(exch, address, 1);
     93        async_exchange_end(exch);
     94       
    8895        sysarg_t result;
     96        async_wait_for(message_id, &result);
     97       
     98        return (int) result;
     99}
    89100
    90         message_id = async_obsolete_send_2(arp_phone, NET_ARP_CLEAR_ADDRESS,
    91             (sysarg_t) device_id, protocol, NULL);
    92         measured_strings_send(arp_phone, address, 1);
     101/** Clear the device cache.
     102 *
     103 * @param[in] sess      ARP module session.
     104 * @param[in] device_id Device identifier.
     105 *
     106 * @return EOK on success.
     107 * @return ENOENT if the device is not found.
     108 *
     109 */
     110int arp_clear_device_req(async_sess_t *sess, device_id_t device_id)
     111{
     112        async_exch_t *exch = async_exchange_begin(sess);
     113        int rc = async_req_1_0(exch, NET_ARP_CLEAR_DEVICE,
     114            (sysarg_t) device_id);
     115        async_exchange_end(exch);
     116       
     117        return rc;
     118}
     119
     120/** Register new device and the requesting protocol service.
     121 *
     122 * Connect to the network interface layer service.
     123 * Determine the device broadcast address, its address lengths and packet size.
     124 *
     125 * @param[in] sess      ARP module session.
     126 * @param[in] device_id New device identifier.
     127 * @param[in] protocol  Requesting protocol service.
     128 * @param[in] netif     Underlying device network interface layer service.
     129 * @param[in] address   Local requesting protocol address of the device.
     130 *
     131 * @return EOK on success.
     132 * @return EEXIST if the device is already used.
     133 * @return ENOMEM if there is not enough memory left.
     134 * @return ENOENT if the network interface service is not known.
     135 * @return EREFUSED if the network interface service is not
     136 *         responding.
     137 * @return Other error codes as defined for the
     138 *         nil_packet_get_size() function.
     139 * @return Other error codes as defined for the nil_get_addr()
     140 *         function.
     141 * @return Other error codes as defined for the
     142 *         nil_get_broadcast_addr() function.
     143 *
     144 */
     145int arp_device_req(async_sess_t *sess, device_id_t device_id,
     146    services_t protocol, services_t netif, measured_string_t *address)
     147{
     148        async_exch_t *exch = async_exchange_begin(sess);
     149        aid_t message_id = async_send_3(exch, NET_ARP_DEVICE,
     150            (sysarg_t) device_id, protocol, netif, NULL);
     151        measured_strings_send(exch, address, 1);
     152        async_exchange_end(exch);
     153       
     154        sysarg_t result;
    93155        async_wait_for(message_id, &result);
    94156
     
    96158}
    97159
    98 /** Clears the device cache.
     160/** Translate the given protocol address to the network interface address.
    99161 *
    100  * @param[in] arp_phone The ARP module phone used for (semi)remote calls.
    101  * @param[in] device_id The device identifier.
    102  * @return              EOK on success.
    103  * @return              ENOENT if the device is not found.
     162 * Broadcast the ARP request if the mapping is not found.
     163 * Allocate and returns the needed memory block as the data parameter.
     164 *
     165 * @param[in]  sess        ARP module session.
     166 * @param[in]  device_id   Device identifier.
     167 * @param[in]  protocol    Requesting protocol service.
     168 * @param[in]  address     Local requesting protocol address.
     169 * @param[out] translation Translation of the local protocol address.
     170 * @param[out] data        Allocated raw translation data container.
     171 *
     172 * @return EOK on success.
     173 * @return EINVAL if the address parameter is NULL.
     174 * @return EBADMEM if the translation or the data parameters are
     175 *         NULL.
     176 * @return ENOENT if the mapping is not found.
     177 *
    104178 */
    105 int arp_clear_device_req(int arp_phone, device_id_t device_id)
     179int arp_translate_req(async_sess_t *sess, device_id_t device_id,
     180    services_t protocol, measured_string_t *address,
     181    measured_string_t **translation, uint8_t **data)
    106182{
    107         return (int) async_obsolete_req_1_0(arp_phone, NET_ARP_CLEAR_DEVICE,
    108             (sysarg_t) device_id);
    109 }
    110 
    111 /** Registers the new device and the requesting protocol service.
    112  *
    113  * Connects to the network interface layer service.
    114  * Determines the device broadcast address, its address lengths and packet size.
    115  *
    116  * @param[in] arp_phone The ARP module phone used for (semi)remote calls.
    117  * @param[in] device_id The new device identifier.
    118  * @param[in] protocol  The requesting protocol service.
    119  * @param[in] netif     The underlying device network interface layer service.
    120  * @param[in] address   The local requesting protocol address of the device.
    121  * @return              EOK on success.
    122  * @return              EEXIST if the device is already used.
    123  * @return              ENOMEM if there is not enough memory left.
    124  * @return              ENOENT if the network interface service is not known.
    125  * @return              EREFUSED if the network interface service is not
    126  *                      responding.
    127  * @return              Other error codes as defined for the
    128  *                      nil_packet_get_size() function.
    129  * @return              Other error codes as defined for the nil_get_addr()
    130  *                      function.
    131  * @return              Other error codes as defined for the
    132  *                      nil_get_broadcast_addr() function.
    133  */
    134 int arp_device_req(int arp_phone, device_id_t device_id, services_t protocol,
    135     services_t netif, measured_string_t *address)
    136 {
    137         aid_t message_id;
    138         sysarg_t result;
    139 
    140         message_id = async_obsolete_send_3(arp_phone, NET_ARP_DEVICE,
    141             (sysarg_t) device_id, protocol, netif, NULL);
    142         measured_strings_send(arp_phone, address, 1);
    143         async_wait_for(message_id, &result);
    144 
    145         return (int) result;
    146 }
    147 
    148 /** Translates the given protocol address to the network interface address.
    149  *
    150  * Broadcasts the ARP request if the mapping is not found.
    151  * Allocates and returns the needed memory block as the data parameter.
    152  *
    153  * @param[in] arp_phone The ARP module phone used for (semi)remote calls.
    154  * @param[in] device_id The device identifier.
    155  * @param[in] protocol  The requesting protocol service.
    156  * @param[in] address   The local requesting protocol address.
    157  * @param[out] translation The translation of the local protocol address.
    158  * @param[out] data     The allocated raw translation data container.
    159  * @return              EOK on success.
    160  * @return              EINVAL if the address parameter is NULL.
    161  * @return              EBADMEM if the translation or the data parameters are
    162  *                      NULL.
    163  * @return              ENOENT if the mapping is not found.
    164  */
    165 int
    166 arp_translate_req(int arp_phone, device_id_t device_id, services_t protocol,
    167     measured_string_t *address, measured_string_t **translation, uint8_t **data)
    168 {
    169         return generic_translate_req(arp_phone, NET_ARP_TRANSLATE, device_id,
     183        return generic_translate_req(sess, NET_ARP_TRANSLATE, device_id,
    170184            protocol, address, 1, translation, data);
    171185}
  • uspace/lib/net/il/il_remote.c

    r55091847 r6b82009  
    3939#include <generic.h>
    4040#include <packet_client.h>
    41 
    4241#include <ipc/services.h>
    4342#include <ipc/il.h>
    44 
    4543#include <net/device.h>
    4644#include <net/packet.h>
     
    4846/** Notify the internetwork layer modules about the device state change.
    4947 *
    50  * @param[in] il_phone  The internetwork layer module phone used for
    51  *                      (semi)remote calls.
    52  * @param[in] device_id The device identifier.
    53  * @param[in] state     The new device state.
    54  * @param[in] target    The target internetwork module service to be
     48 * @param[in] sess      Internetwork layer module session.
     49 * @param[in] device_id Device identifier.
     50 * @param[in] state     New device state.
     51 * @param[in] target    Target internetwork module service to be
    5552 *                      delivered to.
    5653 *
     
    5855 *
    5956 */
    60 int il_device_state_msg(int il_phone, device_id_t device_id,
     57int il_device_state_msg(async_sess_t *sess, device_id_t device_id,
    6158    device_state_t state, services_t target)
    6259{
    63         return generic_device_state_msg_remote(il_phone, NET_IL_DEVICE_STATE,
     60        return generic_device_state_msg_remote(sess, NET_IL_DEVICE_STATE,
    6461            device_id, state, target);
    6562}
     
    6764/** Notify the internetwork layer modules about the received packet/s.
    6865 *
    69  * @param[in] il_phone  The internetwork layer module phone used for
    70  *                      (semi)remote calls.
    71  * @param[in] device_id The device identifier.
    72  * @param[in] packet    The received packet or the received packet queue.
    73  * @param[in] target    The target internetwork module service to be
     66 * @param[in] sess      Internetwork layer module session.
     67 * @param[in] device_id Device identifier.
     68 * @param[in] packet    Received packet or the received packet queue.
     69 * @param[in] target    Target internetwork module service to be
    7470 *                      delivered to.
    7571 *
     
    7773 *
    7874 */
    79 int il_received_msg(int il_phone, device_id_t device_id, packet_t *packet,
     75int il_received_msg(async_sess_t *sess, device_id_t device_id, packet_t *packet,
    8076    services_t target)
    8177{
    82         return generic_received_msg_remote(il_phone, NET_IL_RECEIVED, device_id,
     78        return generic_received_msg_remote(sess, NET_IL_RECEIVED, device_id,
    8379            packet_get_id(packet), target, 0);
    8480}
     
    8682/** Notify the internetwork layer modules about the mtu change.
    8783 *
    88  * @param[in] il_phone  The internetwork layer module phone used for
    89  *                      (semi)remote calls.
    90  * @param[in] device_id The device identifier.
    91  * @param[in] mtu       The new mtu value.
    92  * @param[in] target    The target internetwork module service to be
     84 * @param[in] sess      Internetwork layer module session.
     85 * @param[in] device_id Device identifier.
     86 * @param[in] mtu       New MTU value.
     87 * @param[in] target    Target internetwork module service to be
    9388 *                      delivered to.
    9489 *
     
    9691 *
    9792 */
    98 int il_mtu_changed_msg(int il_phone, device_id_t device_id, size_t mtu,
     93int il_mtu_changed_msg(async_sess_t *sess, device_id_t device_id, size_t mtu,
    9994    services_t target)
    10095{
    101         return generic_device_state_msg_remote(il_phone, NET_IL_MTU_CHANGED,
    102             device_id, (int) mtu, target);
     96        return generic_device_state_msg_remote(sess, NET_IL_MTU_CHANGED,
     97            device_id, mtu, target);
    10398}
    10499
  • uspace/lib/net/il/il_skel.c

    r55091847 r6b82009  
    3838#include <bool.h>
    3939#include <errno.h>
     40#include <ns.h>
    4041#include <il_skel.h>
    4142#include <net_interface.h>
    4243#include <net/modules.h>
    43 #include <async_obsolete.h>
    44 
    45 // FIXME: remove this header
    46 #include <kernel/ipc/ipc_methods.h>
    4744
    4845/** Default thread for new connections.
     
    10097 * @return Other error codes as defined for the il_initialize()
    10198 *         function.
    102  * @return Other error codes as defined for the REGISTER_ME() macro
    103  *         function.
    10499 *
    105100 */
    106 int il_module_start(int service)
     101int il_module_start(sysarg_t service)
    107102{
    108103        async_set_client_connection(il_client_connection);
    109         int net_phone = net_connect_module();
    110         if (net_phone < 0)
    111                 return net_phone;
     104        async_sess_t *sess = net_connect_module();
     105        if (!sess)
     106                return ENOENT;
    112107       
    113108        int rc = pm_init();
     
    115110                return rc;
    116111       
    117         rc = il_initialize(net_phone);
     112        rc = il_initialize(sess);
    118113        if (rc != EOK)
    119114                goto out;
    120115       
    121         rc = async_obsolete_connect_to_me(PHONE_NS, service, 0, 0, NULL, NULL);
     116        rc = service_register(service);
    122117        if (rc != EOK)
    123118                goto out;
  • uspace/lib/net/il/ip_remote.c

    r55091847 r6b82009  
    4444#include <packet_client.h>
    4545#include <generic.h>
    46 #include <async_obsolete.h>
    4746#include <ipc/services.h>
    4847#include <ipc/il.h>
    4948#include <ipc/ip.h>
    50 
    5149#include <net/modules.h>
    5250#include <net/device.h>
     
    5755 * The target network is routed using this device.
    5856 *
    59  * @param[in] ip_phone  The IP module phone used for (semi)remote calls.
    60  * @param[in] device_id The device identifier.
    61  * @param[in] address   The target network address.
    62  * @param[in] netmask   The target network mask.
    63  * @param[in] gateway   The target network gateway. Not used if zero.
    64  */
    65 int ip_add_route_req_remote(int ip_phone, device_id_t device_id,
     57 * @param[in] sess      IP module sessions.
     58 * @param[in] device_id Device identifier.
     59 * @param[in] address   Target network address.
     60 * @param[in] netmask   Target network mask.
     61 * @param[in] gateway   Target network gateway. Not used if zero.
     62 *
     63 */
     64int ip_add_route_req_remote(async_sess_t *sess, device_id_t device_id,
    6665    in_addr_t address, in_addr_t netmask, in_addr_t gateway)
    6766{
    68         return (int) async_obsolete_req_4_0(ip_phone, NET_IP_ADD_ROUTE,
     67        async_exch_t *exch = async_exchange_begin(sess);
     68        int rc = async_req_4_0(exch, NET_IP_ADD_ROUTE,
    6969            (sysarg_t) device_id, (sysarg_t) gateway.s_addr,
    7070            (sysarg_t) address.s_addr, (sysarg_t) netmask.s_addr);
    71 }
    72 
    73 /** Creates bidirectional connection with the ip module service and registers
     71        async_exchange_end(exch);
     72       
     73        return rc;
     74}
     75
     76/** Create bidirectional connection with the ip module service and register
    7477 * the message receiver.
    7578 *
    76  * @param[in] service   The IP module service.
    77  * @param[in] protocol  The transport layer protocol.
    78  * @param[in] me        The requesting module service.
    79  * @param[in] receiver  The message receiver. Used for remote connection.
    80  * @return              The phone of the needed service.
    81  * @return              EOK on success.
    82  * @return              Other error codes as defined for the bind_service()
    83  *                      function.
    84  */
    85 int ip_bind_service(services_t service, int protocol, services_t me,
     79 * @param[in] service  IP module service.
     80 * @param[in] protocol Transport layer protocol.
     81 * @param[in] me       Rquesting module service.
     82 * @param[in] receiver Message receiver. Used for remote connection.
     83 *
     84 * @return Session to the needed service.
     85 * @return NULL on failure.
     86 *
     87 */
     88async_sess_t *ip_bind_service(services_t service, int protocol, services_t me,
    8689    async_client_conn_t receiver)
    8790{
    88         return (int) bind_service(service, (sysarg_t) protocol, me, service,
     91        return bind_service(service, (sysarg_t) protocol, me, service,
    8992            receiver);
    9093}
    9194
    92 /** Connects to the IP module.
    93  *
    94  * @param service       The IP module service. Ignored parameter.
    95  * @return              The IP module phone on success.
    96  */
    97 int ip_connect_module(services_t service)
    98 {
     95/** Connect to the IP module.
     96 *
     97 * @return The IP module session.
     98 *
     99 */
     100async_sess_t *ip_connect_module(services_t service)
     101{
     102        // FIXME: Get rid of the useless argument
    99103        return connect_to_service(SERVICE_IP);
    100104}
     
    105109 * If the device uses ARP registers also the new ARP device.
    106110 *
    107  * @param[in] ip_phone  The IP module phone used for (semi)remote calls.
    108  * @param[in] device_id The new device identifier.
    109  * @param[in] netif     The underlying device network interface layer service.
    110  * @return              EOK on success.
    111  * @return              ENOMEM if there is not enough memory left.
    112  * @return              EINVAL if the device configuration is invalid.
    113  * @return              ENOTSUP if the device uses IPv6.
    114  * @return              ENOTSUP if the device uses DHCP.
    115  * @return              Other error codes as defined for the
    116  *                      net_get_device_conf_req() function.
    117  * @return              Other error codes as defined for the arp_device_req()
    118  *                      function.
    119  */
    120 int ip_device_req_remote(int ip_phone, device_id_t device_id,
    121     services_t service)
    122 {
    123         return generic_device_req_remote(ip_phone, NET_IP_DEVICE, device_id, 0,
    124             service);
     111 * @param[in] sess      IP module session.
     112 * @param[in] device_id New device identifier.
     113 *
     114 * @return EOK on success.
     115 * @return ENOMEM if there is not enough memory left.
     116 * @return EINVAL if the device configuration is invalid.
     117 * @return ENOTSUP if the device uses IPv6.
     118 * @return ENOTSUP if the device uses DHCP.
     119 * @return Other error codes as defined for the
     120 *         net_get_device_conf_req() function.
     121 * @return Other error codes as defined for the arp_device_req()
     122 *         function.
     123 *
     124 */
     125int ip_device_req_remote(async_sess_t *sess, device_id_t device_id)
     126{
     127        return generic_device_req_remote(sess, NET_IP_DEVICE, device_id, 0, 0);
    125128}
    126129
     
    128131 * destination address.
    129132 *
    130  * @param[in] ip_phone  The IP module phone used for (semi)remote calls.
    131  * @param[in] protocol  The transport protocol.
    132  * @param[in] destination The destination address.
    133  * @param[in] addrlen   The destination address length.
    134  * @param[out] device_id The device identifier.
    135  * @param[out] header   The constructed IP pseudo header.
    136  * @param[out] headerlen The IP pseudo header length.
    137  *
    138  */
    139 int ip_get_route_req_remote(int ip_phone, ip_protocol_t protocol,
     133 * @param[in] sess        IP module session.
     134 * @param[in] protocol    Transport protocol.
     135 * @param[in] destination Destination address.
     136 * @param[in] addrlen     Destination address length.
     137 * @param[out] device_id  Device identifier.
     138 * @param[out] header     Constructed IP pseudo header.
     139 * @param[out] headerlen IP pseudo header length.
     140 *
     141 */
     142int ip_get_route_req_remote(async_sess_t *sess, ip_protocol_t protocol,
    140143    const struct sockaddr *destination, socklen_t addrlen,
    141144    device_id_t *device_id, void **header, size_t *headerlen)
    142145{
    143         if (!destination || (addrlen == 0))
     146        if ((!destination) || (addrlen == 0))
    144147                return EINVAL;
    145148       
    146         if (!device_id || !header || !headerlen)
     149        if ((!device_id) || (!header) || (!headerlen))
    147150                return EBADMEM;
    148151       
    149152        *header = NULL;
    150153       
     154        async_exch_t *exch = async_exchange_begin(sess);
     155       
    151156        ipc_call_t answer;
    152         aid_t message_id = async_obsolete_send_1(ip_phone, NET_IP_GET_ROUTE,
     157        aid_t message_id = async_send_1(exch, NET_IP_GET_ROUTE,
    153158            (sysarg_t) protocol, &answer);
    154159       
    155         if ((async_obsolete_data_write_start(ip_phone, destination, addrlen) == EOK) &&
    156             (async_obsolete_data_read_start(ip_phone, headerlen,
    157             sizeof(*headerlen)) == EOK) && (*headerlen > 0)) {
     160        if ((async_data_write_start(exch, destination, addrlen) == EOK) &&
     161            (async_data_read_start(exch, headerlen, sizeof(*headerlen)) == EOK) &&
     162            (*headerlen > 0)) {
    158163                *header = malloc(*headerlen);
    159164                if (*header) {
    160                         if (async_obsolete_data_read_start(ip_phone, *header,
     165                        if (async_data_read_start(exch, *header,
    161166                            *headerlen) != EOK)
    162167                                free(*header);
     
    164169        }
    165170       
     171        async_exchange_end(exch);
     172       
    166173        sysarg_t result;
    167174        async_wait_for(message_id, &result);
     
    177184/** Return the device packet dimension for sending.
    178185 *
    179  * @param[in] ip_phone  The IP module phone used for (semi)remote calls.
    180  * @param[in] device_id The device identifier.
    181  * @param[out] packet_dimension The packet dimension.
    182  * @return              EOK on success.
    183  * @return              ENOENT if there is no such device.
    184  * @return              Other error codes as defined for the
    185  *                      generic_packet_size_req_remote() function.
    186  */
    187 int ip_packet_size_req_remote(int ip_phone, device_id_t device_id,
     186 * @param[in] sess              IP module session.
     187 * @param[in] device_id         Device identifier.
     188 * @param[out] packet_dimension Packet dimension.
     189 *
     190 * @return EOK on success.
     191 * @return ENOENT if there is no such device.
     192 * @return Other error codes as defined for the
     193 *         generic_packet_size_req_remote() function.
     194 *
     195 */
     196int ip_packet_size_req_remote(async_sess_t *sess, device_id_t device_id,
    188197    packet_dimension_t *packet_dimension)
    189198{
    190         return generic_packet_size_req_remote(ip_phone, NET_IP_PACKET_SPACE,
     199        return generic_packet_size_req_remote(sess, NET_IP_PACKET_SPACE,
    191200            device_id, packet_dimension);
    192201}
     
    194203/** Notify the IP module about the received error notification packet.
    195204 *
    196  * @param[in] ip_phone  The IP module phone used for (semi)remote calls.
    197  * @param[in] device_id The device identifier.
    198  * @param[in] packet    The received packet or the received packet queue.
    199  * @param[in] target    The target internetwork module service to be
    200  *                      delivered to.
    201  * @param[in] error     The packet error reporting service. Prefixes the
    202  *                      received packet.
    203  * @return              EOK on success.
    204  */
    205 int ip_received_error_msg_remote(int ip_phone, device_id_t device_id,
     205 * @param[in] sess      IP module session.
     206 * @param[in] device_id Device identifier.
     207 * @param[in] packet    Received packet or the received packet queue.
     208 * @param[in] target    Target internetwork module service to be
     209 *                      delivered to.
     210 * @param[in] error     Packet error reporting service. Prefixes the
     211 *                      received packet.
     212 *
     213 * @return EOK on success.
     214 *
     215 */
     216int ip_received_error_msg_remote(async_sess_t *sess, device_id_t device_id,
    206217    packet_t *packet, services_t target, services_t error)
    207218{
    208         return generic_received_msg_remote(ip_phone, NET_IP_RECEIVED_ERROR,
     219        return generic_received_msg_remote(sess, NET_IP_RECEIVED_ERROR,
    209220            device_id, packet_get_id(packet), target, error);
    210221}
     
    214225 * The packets may get fragmented if needed.
    215226 *
    216  * @param[in] ip_phone  The IP module phone used for (semi)remote calls.
    217  * @param[in] device_id The device identifier.
    218  * @param[in] packet    The packet fragments as a packet queue. All the
    219  *                      packets have to have the same destination address.
    220  * @param[in] sender    The sending module service.
    221  * @param[in] error     The packet error reporting service. Prefixes the
    222  *                      received packet.
    223  * @return              EOK on success.
    224  * @return              Other error codes as defined for the generic_send_msg()
    225  *                      function.
    226  */
    227 int ip_send_msg_remote(int ip_phone, device_id_t device_id, packet_t *packet,
    228     services_t sender, services_t error)
    229 {
    230         return generic_send_msg_remote(ip_phone, NET_IP_SEND, device_id,
     227 * @param[in] sess      IP module session.
     228 * @param[in] device_id Device identifier.
     229 * @param[in] packet    Packet fragments as a packet queue. All the
     230 *                      packets have to have the same destination address.
     231 * @param[in] sender    Sending module service.
     232 * @param[in] error     Packet error reporting service. Prefixes the
     233 *                      received packet.
     234 *
     235 * @return EOK on success.
     236 * @return Other error codes as defined for the generic_send_msg()
     237 *         function.
     238 *
     239 */
     240int ip_send_msg_remote(async_sess_t *sess, device_id_t device_id,
     241    packet_t *packet, services_t sender, services_t error)
     242{
     243        return generic_send_msg_remote(sess, NET_IP_SEND, device_id,
    231244            packet_get_id(packet), sender, error);
    232245}
     
    236249 * This gateway is used if no other route is found.
    237250 *
    238  * @param[in] ip_phone  The IP module phone used for (semi)remote calls.
    239  * @param[in] device_id The device identifier.
    240  * @param[in] gateway   The default gateway.
    241  */
    242 int ip_set_gateway_req_remote(int ip_phone, device_id_t device_id,
     251 * @param[in] sess      IP module session.
     252 * @param[in] device_id Device identifier.
     253 * @param[in] gateway   Default gateway.
     254 *
     255 */
     256int ip_set_gateway_req_remote(async_sess_t *sess, device_id_t device_id,
    243257    in_addr_t gateway)
    244258{
    245         return (int) async_obsolete_req_2_0(ip_phone, NET_IP_SET_GATEWAY,
     259        async_exch_t *exch = async_exchange_begin(sess);
     260        int rc = async_req_2_0(exch, NET_IP_SET_GATEWAY,
    246261            (sysarg_t) device_id, (sysarg_t) gateway.s_addr);
     262        async_exchange_end(exch);
     263       
     264        return rc;
    247265}
    248266
  • uspace/lib/net/include/adt/module_map.h

    r55091847 r6b82009  
    3939
    4040#include <task.h>
    41 #include <ipc/services.h>
     41#include <async.h>
    4242#include <net/modules.h>
    4343#include <adt/generic_char_map.h>
     
    6060        /** Module service identifier. */
    6161        services_t service;
    62         /** Module phone if running and connected. */
    63         int phone;
     62        /** Module session if running and connected. */
     63        async_sess_t *sess;
    6464        /** Usage counter. */
    6565        int usage;
  • uspace/lib/net/include/arp_interface.h

    r55091847 r6b82009  
    3636#include <adt/measured_strings.h>
    3737#include <task.h>
    38 
    3938#include <ipc/services.h>
    40 
    4139#include <net/device.h>
    4240#include <net/socket.h>
     41#include <async.h>
    4342
    4443/** @name ARP module interface
     
    4746/*@{*/
    4847
    49 extern int arp_device_req(int, device_id_t, services_t, services_t,
     48extern int arp_device_req(async_sess_t *, device_id_t, services_t, services_t,
    5049    measured_string_t *);
    51 extern int arp_translate_req(int, device_id_t, services_t, measured_string_t *,
    52     measured_string_t **, uint8_t **);
    53 extern int arp_clear_device_req(int, device_id_t);
    54 extern int arp_clear_address_req(int, device_id_t, services_t,
     50extern int arp_translate_req(async_sess_t *, device_id_t, services_t,
     51    measured_string_t *, measured_string_t **, uint8_t **);
     52extern int arp_clear_device_req(async_sess_t *, device_id_t);
     53extern int arp_clear_address_req(async_sess_t *, device_id_t, services_t,
    5554    measured_string_t *);
    56 extern int arp_clean_cache_req(int);
    57 extern int arp_connect_module(services_t);
     55extern int arp_clean_cache_req(async_sess_t *);
     56extern async_sess_t *arp_connect_module(services_t);
    5857
    5958/*@}*/
  • uspace/lib/net/include/generic.h

    r55091847 r6b82009  
    3838#define LIBNET_GENERIC_H_
    3939
    40 #include <async.h>
    4140#include <ipc/services.h>
    42 
    4341#include <net/device.h>
    4442#include <adt/measured_strings.h>
    4543#include <net/packet.h>
     44#include <async.h>
    4645
    47 extern int generic_device_state_msg_remote(int, int, device_id_t, int,
    48     services_t);
    49 extern int generic_device_req_remote(int, int, device_id_t, int, services_t);
    50 extern int generic_get_addr_req(int, int, device_id_t, measured_string_t **,
    51     uint8_t **);
    52 extern int generic_packet_size_req_remote(int, int, device_id_t,
     46extern int generic_device_state_msg_remote(async_sess_t *, sysarg_t,
     47    device_id_t, sysarg_t, services_t);
     48extern int generic_device_req_remote(async_sess_t *, sysarg_t, device_id_t,
     49    sysarg_t, services_t);
     50extern int generic_get_addr_req(async_sess_t *, sysarg_t, device_id_t,
     51    measured_string_t **, uint8_t **);
     52extern int generic_packet_size_req_remote(async_sess_t *, sysarg_t, device_id_t,
    5353    packet_dimension_t *);
    54 extern int generic_received_msg_remote(int, int, device_id_t, packet_id_t,
    55     services_t, services_t);
    56 extern int generic_send_msg_remote(int, int, device_id_t, packet_id_t,
    57     services_t, services_t);
    58 extern int generic_translate_req(int, int, device_id_t, services_t,
    59     measured_string_t *, size_t, measured_string_t **, uint8_t **);
     54extern int generic_received_msg_remote(async_sess_t *, sysarg_t, device_id_t,
     55    packet_id_t, services_t, services_t);
     56extern int generic_send_msg_remote(async_sess_t *, sysarg_t, device_id_t,
     57    packet_id_t, services_t, services_t);
     58extern int generic_translate_req(async_sess_t *, sysarg_t, device_id_t,
     59    services_t, measured_string_t *, size_t, measured_string_t **, uint8_t **);
    6060
    6161#endif
  • uspace/lib/net/include/icmp_remote.h

    r55091847 r6b82009  
    3636#include <net/socket_codes.h>
    3737#include <sys/types.h>
    38 
    3938#include <net/device.h>
    4039#include <adt/measured_strings.h>
     
    4443#include <net/icmp_codes.h>
    4544#include <net/icmp_common.h>
     45#include <async.h>
    4646
    4747/** @name ICMP module interface
     
    5050/*@{*/
    5151
    52 extern int icmp_destination_unreachable_msg(int, icmp_code_t, icmp_param_t,
    53     packet_t *);
    54 extern int icmp_source_quench_msg(int, packet_t *);
    55 extern int icmp_time_exceeded_msg(int, icmp_code_t, packet_t *);
    56 extern int icmp_parameter_problem_msg(int, icmp_code_t, icmp_param_t,
     52extern int icmp_destination_unreachable_msg(async_sess_t *, icmp_code_t,
     53    icmp_param_t, packet_t *);
     54extern int icmp_source_quench_msg(async_sess_t *, packet_t *);
     55extern int icmp_time_exceeded_msg(async_sess_t *, icmp_code_t, packet_t *);
     56extern int icmp_parameter_problem_msg(async_sess_t *, icmp_code_t, icmp_param_t,
    5757    packet_t *);
    5858
  • uspace/lib/net/include/il_remote.h

    r55091847 r6b82009  
    4141#include <ipc/services.h>
    4242#include <sys/types.h>
    43 
    4443#include <net/device.h>
    4544#include <net/packet.h>
     45#include <async.h>
    4646
    4747/** @name Internetwork layer module interface
     
    5050/*@{*/
    5151
    52 extern int il_device_state_msg(int, device_id_t, device_state_t, services_t);
    53 extern int il_received_msg(int, device_id_t, packet_t *, services_t);
    54 extern int il_mtu_changed_msg(int, device_id_t, size_t, services_t);
     52extern int il_device_state_msg(async_sess_t *, device_id_t, device_state_t,
     53    services_t);
     54extern int il_received_msg(async_sess_t *, device_id_t, packet_t *, services_t);
     55extern int il_mtu_changed_msg(async_sess_t *, device_id_t, size_t, services_t);
    5556
    5657/*@}*/
  • uspace/lib/net/include/il_skel.h

    r55091847 r6b82009  
    3939 */
    4040
    41 #include <async.h>
    42 #include <fibril_synch.h>
    4341#include <ipc/services.h>
    44 
    4542#include <adt/measured_strings.h>
    4643#include <net/device.h>
    4744#include <net/packet.h>
     45#include <async.h>
    4846
    4947/** Module initialization.
     
    5149 * This has to be implemented in user code.
    5250 *
    53  * @param[in] net_phone Networking module phone.
     51 * @param[in] sess Networking module session.
    5452 *
    5553 * @return EOK on success.
     
    5856 *
    5957 */
    60 extern int il_initialize(int net_phone);
     58extern int il_initialize(async_sess_t *sess);
    6159
    6260/** Process the internetwork layer module message.
     
    7674    ipc_call_t *answer, size_t *answer_count);
    7775
    78 extern int il_module_start(int);
     76extern int il_module_start(sysarg_t);
    7977
    8078#endif
  • uspace/lib/net/include/ip_interface.h

    r55091847 r6b82009  
    3535
    3636#include <net/socket_codes.h>
    37 #include <async.h>
    3837#include <ipc/services.h>
    39 
    4038#include <net/device.h>
    4139#include <net/packet.h>
    42 
    4340#include <net/in.h>
    4441#include <net/ip_codes.h>
    45 
    4642#include <ip_remote.h>
     43#include <async.h>
    4744
    4845#define ip_received_error_msg  ip_received_error_msg_remote
     
    6158/** The transport layer notification function type definition.
    6259 *
    63  * Notifies the transport layer modules about the received packet/s.
     60 * Notify the transport layer modules about the received packet/s.
    6461 *
    65  * @param[in] device_id The device identifier.
    66  * @param[in] packet    The received packet or the received packet queue.
    67  * @param[in] receiver  The receiving module service.
    68  * @param[in] error     The packet error reporting service. Prefixes the
    69  *                      received packet.
    70  * @return              EOK on success.
     62 * @param[in] device_id Device identifier.
     63 * @param[in] packet    Received packet or the received packet queue.
     64 * @param[in] receiver  Receiving module service.
     65 * @param[in] error     Packet error reporting service. Prefixes the
     66 *                      received packet.
     67 *
     68 * @return EOK on success.
     69 *
    7170 */
    7271typedef int (*tl_received_msg_t)(device_id_t device_id, packet_t *packet,
    7372    services_t receiver, services_t error);
    7473
    75 extern int ip_bind_service(services_t, int, services_t, async_client_conn_t);
    76 extern int ip_connect_module(services_t);
     74extern async_sess_t *ip_bind_service(services_t, int, services_t, async_client_conn_t);
     75extern async_sess_t *ip_connect_module(services_t);
    7776
    7877/*@}*/
  • uspace/lib/net/include/ip_remote.h

    r55091847 r6b82009  
    3535
    3636#include <ipc/services.h>
    37 
    3837#include <net/ip_codes.h>
    3938#include <net/inet.h>
     
    4241#include <net/device.h>
    4342#include <net/socket.h>
     43#include <async.h>
    4444
    45 extern int ip_set_gateway_req_remote(int, device_id_t, in_addr_t);
    46 extern int ip_packet_size_req_remote(int, device_id_t, packet_dimension_t *);
    47 extern int ip_received_error_msg_remote(int, device_id_t, packet_t *, services_t,
    48     services_t);
    49 extern int ip_device_req_remote(int, device_id_t, services_t);
    50 extern int ip_add_route_req_remote(int, device_id_t, in_addr_t, in_addr_t,
    51     in_addr_t);
    52 extern int ip_send_msg_remote(int, device_id_t, packet_t *, services_t,
    53     services_t);
    54 extern int ip_get_route_req_remote(int, ip_protocol_t, const struct sockaddr *,
    55     socklen_t, device_id_t *, void **, size_t *);
     45extern int ip_set_gateway_req_remote(async_sess_t *, device_id_t, in_addr_t);
     46extern int ip_packet_size_req_remote(async_sess_t *, device_id_t,
     47    packet_dimension_t *);
     48extern int ip_received_error_msg_remote(async_sess_t *, device_id_t, packet_t *,
     49    services_t, services_t);
     50extern int ip_device_req_remote(async_sess_t *, device_id_t);
     51extern int ip_add_route_req_remote(async_sess_t *, device_id_t, in_addr_t,
     52    in_addr_t, in_addr_t);
     53extern int ip_send_msg_remote(async_sess_t *, device_id_t, packet_t *,
     54    services_t, services_t);
     55extern int ip_get_route_req_remote(async_sess_t *, ip_protocol_t,
     56    const struct sockaddr *, socklen_t, device_id_t *, void **, size_t *);
    5657
    5758#endif
  • uspace/lib/net/include/net_interface.h

    r55091847 r6b82009  
    3838#include <net/device.h>
    3939#include <adt/measured_strings.h>
     40#include <async.h>
    4041
    4142/** @name Networking module interface
     
    4445/*@{*/
    4546
    46 extern int net_get_device_conf_req(int, device_id_t, measured_string_t **,
    47     size_t, uint8_t **);
    48 extern int net_get_conf_req(int, measured_string_t **, size_t, uint8_t **);
     47extern int net_get_device_conf_req(async_sess_t *, device_id_t,
     48    measured_string_t **, size_t, uint8_t **);
     49extern int net_get_conf_req(async_sess_t *, measured_string_t **, size_t,
     50    uint8_t **);
    4951extern void net_free_settings(measured_string_t *, uint8_t *);
    50 extern int net_connect_module(void);
     52extern async_sess_t *net_connect_module(void);
    5153
    5254/*@}*/
  • uspace/lib/net/include/netif_remote.h

    r55091847 r6b82009  
    3434#define LIBNET_NETIF_REMOTE_H_
    3535
    36 #include <async.h>
    3736#include <ipc/services.h>
    3837#include <adt/measured_strings.h>
    39 
    4038#include <net/device.h>
    4139#include <net/packet.h>
     40#include <async.h>
    4241
    43 extern int netif_get_addr_req(int, device_id_t, measured_string_t **,
     42extern int netif_get_addr_req(async_sess_t *, device_id_t, measured_string_t **,
    4443    uint8_t **);
    45 extern int netif_probe_req(int, device_id_t, int, void *);
    46 extern int netif_send_msg(int, device_id_t, packet_t *, services_t);
    47 extern int netif_start_req(int, device_id_t);
    48 extern int netif_stop_req(int, device_id_t);
    49 extern int netif_stats_req(int, device_id_t, device_stats_t *);
    50 extern int netif_bind_service(services_t, device_id_t, services_t,
     44extern int netif_probe_req(async_sess_t *, device_id_t, int, void *);
     45extern int netif_send_msg(async_sess_t *, device_id_t, packet_t *, services_t);
     46extern int netif_start_req(async_sess_t *, device_id_t);
     47extern int netif_stop_req(async_sess_t *, device_id_t);
     48extern int netif_stats_req(async_sess_t *, device_id_t, device_stats_t *);
     49extern async_sess_t *netif_bind_service(services_t, device_id_t, services_t,
    5150    async_client_conn_t);
    5251
  • uspace/lib/net/include/netif_skel.h

    r55091847 r6b82009  
    3939#define NET_NETIF_SKEL_H_
    4040
    41 #include <async.h>
    4241#include <fibril_synch.h>
    4342#include <ipc/services.h>
    44 
    4543#include <adt/measured_strings.h>
    4644#include <net/device.h>
    4745#include <net/packet.h>
     46#include <async.h>
    4847
    4948/** Network interface device specific data. */
    5049typedef struct {
    51         device_id_t device_id;  /**< Device identifier. */
    52         int nil_phone;          /**< Receiving network interface layer phone. */
    53         device_state_t state;   /**< Actual device state. */
    54         void *specific;         /**< Driver specific data. */
     50        device_id_t device_id;   /**< Device identifier. */
     51        device_state_t state;    /**< Actual device state. */
     52        void *specific;          /**< Driver specific data. */
    5553} netif_device_t;
    5654
     
    6563/** Network interface module skeleton global data. */
    6664typedef struct {
    67         int net_phone;                  /**< Networking module phone. */
     65        async_sess_t *sess;             /**< Networking module session. */
     66        async_sess_t *nil_sess;         /**< Network interface layer session. */
    6867        netif_device_map_t device_map;  /**< Device map. */
    6968        fibril_rwlock_t lock;           /**< Safety lock. */
     
    127126 * @return Other error codes as defined for the specific module
    128127 *         message implementation.
    129  
    130128 *
    131129 */
     
    207205extern packet_t *netif_packet_get_1(size_t);
    208206
    209 extern int netif_module_start(void);
     207extern int netif_module_start(sysarg_t);
    210208
    211209#endif
  • uspace/lib/net/include/nil_remote.h

    r55091847 r6b82009  
    3838#include <net/packet.h>
    3939#include <generic.h>
     40#include <async.h>
    4041
    4142#define nil_bind_service(service, device_id, me, receiver) \
    4243        bind_service(service, device_id, me, 0, receiver)
    4344
    44 #define nil_packet_size_req(nil_phone, device_id, packet_dimension) \
    45         generic_packet_size_req_remote(nil_phone, NET_NIL_PACKET_SPACE, \
     45#define nil_packet_size_req(sess, device_id, packet_dimension) \
     46        generic_packet_size_req_remote(sess, NET_NIL_PACKET_SPACE, \
    4647            device_id, packet_dimension)
    4748
    48 #define nil_get_addr_req(nil_phone, device_id, address, data) \
    49         generic_get_addr_req(nil_phone, NET_NIL_ADDR, device_id, address, data)
     49#define nil_get_addr_req(sess, device_id, address, data) \
     50        generic_get_addr_req(sess, NET_NIL_ADDR, device_id, address, data)
    5051
    51 #define nil_get_broadcast_addr_req(nil_phone, device_id, address, data) \
    52         generic_get_addr_req(nil_phone, NET_NIL_BROADCAST_ADDR, device_id, \
     52#define nil_get_broadcast_addr_req(sess, device_id, address, data) \
     53        generic_get_addr_req(sess, NET_NIL_BROADCAST_ADDR, device_id, \
    5354            address, data)
    5455
    55 #define nil_send_msg(nil_phone, device_id, packet, sender) \
    56         generic_send_msg_remote(nil_phone, NET_NIL_SEND, device_id, \
     56#define nil_send_msg(sess, device_id, packet, sender) \
     57        generic_send_msg_remote(sess, NET_NIL_SEND, device_id, \
    5758            packet_get_id(packet), sender, 0)
    5859
    59 #define nil_device_req(nil_phone, device_id, mtu, netif_service) \
    60         generic_device_req_remote(nil_phone, NET_NIL_DEVICE, device_id, mtu, \
    61             netif_service)
     60#define nil_device_req(sess, device_id, mtu) \
     61        generic_device_req_remote(sess, NET_NIL_DEVICE, device_id, mtu, 0)\
    6262
    63 extern int nil_device_state_msg(int, device_id_t, int);
    64 extern int nil_received_msg(int, device_id_t, packet_t *, services_t);
     63extern int nil_device_state_msg(async_sess_t *, device_id_t, sysarg_t);
     64extern int nil_received_msg(async_sess_t *, device_id_t, packet_t *,
     65    services_t);
    6566
    6667#endif
  • uspace/lib/net/include/nil_skel.h

    r55091847 r6b82009  
    3939#define LIBNET_NIL_SKEL_H_
    4040
    41 #include <async.h>
    42 #include <fibril_synch.h>
    4341#include <ipc/services.h>
    44 
    4542#include <adt/measured_strings.h>
    4643#include <net/device.h>
    4744#include <net/packet.h>
     45#include <async.h>
    4846
    4947/** Module initialization.
     
    5149 * This has to be implemented in user code.
    5250 *
    53  * @param[in] net_phone Networking module phone.
     51 * @param[in] sess Networking module session.
    5452 *
    5553 * @return EOK on success.
     
    5856 *
    5957 */
    60 extern int nil_initialize(int net_phone);
     58extern int nil_initialize(async_sess_t *sess);
    6159
    6260/** Notify the network interface layer about the device state change.
     
    6462 * This has to be implemented in user code.
    6563 *
    66  * @param[in] nil_phone Network interface layer phone.
    6764 * @param[in] device_id Device identifier.
    6865 * @param[in] state     New device state.
     
    7370 *
    7471 */
    75 extern int nil_device_state_msg_local(int, device_id_t, int);
     72extern int nil_device_state_msg_local(device_id_t device_id, sysarg_t state);
    7673
    7774/** Pass the packet queue to the network interface layer.
     
    8279 * This has to be implemented in user code.
    8380 *
    84  * @param[in] nil_phone Network interface layer phone.
    8581 * @param[in] device_id Source device identifier.
    8682 * @param[in] packet    Received packet or the received packet queue.
     
    9288 *
    9389 */
    94 extern int nil_received_msg_local(int, device_id_t, packet_t *, services_t);
     90extern int nil_received_msg_local(device_id_t device_id, packet_t *packet,
     91    services_t target);
    9592
    9693/** Message processing function.
     
    9895 * This has to be implemented in user code.
    9996 *
    100  * @param[in]  name   Module name.
    10197 * @param[in]  callid Message identifier.
    10298 * @param[in]  call   Message parameters.
     
    112108 *
    113109 */
    114 extern int nil_module_message(ipc_callid_t, ipc_call_t *, ipc_call_t *,
    115     size_t *);
     110extern int nil_module_message(ipc_callid_t callid, ipc_call_t *call,
     111    ipc_call_t *answer, size_t *count);
    116112
    117 extern int nil_module_start(int);
     113extern int nil_module_start(sysarg_t);
    118114
    119115#endif
  • uspace/lib/net/include/packet_client.h

    r55091847 r6b82009  
    4949
    5050#include <net/packet.h>
     51#include <async.h>
    5152
    5253/** @name Packet client interface */
     
    108109extern int packet_get_addr(const packet_t *, uint8_t **, uint8_t **);
    109110extern int packet_set_addr(packet_t *, const uint8_t *, const uint8_t *, size_t);
    110 extern packet_t *packet_get_copy(int, packet_t *);
     111extern packet_t *packet_get_copy(async_sess_t *, packet_t *);
    111112
    112113/*@}*/
  • uspace/lib/net/include/packet_remote.h

    r55091847 r6b82009  
    3636#include <net/packet.h>
    3737#include <sys/types.h>
     38#include <async.h>
    3839
    39 extern int packet_translate_remote(int, packet_t **, packet_id_t);
    40 extern packet_t *packet_get_4_remote(int, size_t, size_t, size_t, size_t);
    41 extern packet_t *packet_get_1_remote(int, size_t);
    42 extern void pq_release_remote(int, packet_id_t);
     40extern int packet_translate_remote(async_sess_t *, packet_t **, packet_id_t);
     41extern packet_t *packet_get_4_remote(async_sess_t *, size_t, size_t, size_t,
     42    size_t);
     43extern packet_t *packet_get_1_remote(async_sess_t *, size_t);
     44extern void pq_release_remote(async_sess_t *, packet_id_t);
    4345
    4446#endif
  • uspace/lib/net/include/socket_core.h

    r55091847 r6b82009  
    2727 */
    2828
    29 /** @addtogroup libnet 
     29/** @addtogroup libnet
    3030 *  @{
    3131 */
     
    4545#include <net/device.h>
    4646#include <net/packet.h>
     47#include <async.h>
    4748
    4849/** Initial size of the received packet queue. */
    49 #define SOCKET_INITIAL_RECEIVED_SIZE    4
     50#define SOCKET_INITIAL_RECEIVED_SIZE  4
    5051
    5152/** Maximum size of the received packet queue. */
    52 #define SOCKET_MAX_RECEIVED_SIZE        0
     53#define SOCKET_MAX_RECEIVED_SIZE  0
    5354
    5455/** Initial size of the sockets for acceptance queue. */
    55 #define SOCKET_INITIAL_ACCEPTED_SIZE    1
     56#define SOCKET_INITIAL_ACCEPTED_SIZE  1
    5657
    5758/** Maximum size of the sockets for acceptance queue. */
    58 #define SOCKET_MAX_ACCEPTEDED_SIZE      0
     59#define SOCKET_MAX_ACCEPTEDED_SIZE  0
    5960
    6061/** Listening sockets' port map key. */
    61 #define SOCKET_MAP_KEY_LISTENING        "L"
     62#define SOCKET_MAP_KEY_LISTENING  "L"
    6263
    6364/** Type definition of the socket core.
     
    7576        /** Socket identifier. */
    7677        int socket_id;
    77         /** Client application phone. */
    78         int phone;
     78        /** Client application session. */
     79        async_sess_t *sess;
    7980        /** Bound port. */
    8081        int port;
     
    108109INT_MAP_DECLARE(socket_ports, socket_port_t);
    109110
    110 extern void socket_cores_release(int, socket_cores_t *, socket_ports_t *,
    111     void (*)(socket_core_t *));
     111extern void socket_cores_release(async_sess_t *, socket_cores_t *,
     112    socket_ports_t *, void (*)(socket_core_t *));
    112113extern int socket_bind(socket_cores_t *, socket_ports_t *, int, void *, size_t,
    113114    int, int, int);
    114115extern int socket_bind_free_port(socket_ports_t *, socket_core_t *, int, int,
    115116    int);
    116 extern int socket_create(socket_cores_t *, int, void *, int *);
    117 extern int socket_destroy(int, int, socket_cores_t *, socket_ports_t *,
    118     void (*)(socket_core_t *));
     117extern int socket_create(socket_cores_t *, async_sess_t *, void *, int *);
     118extern int socket_destroy(async_sess_t *, int, socket_cores_t *,
     119    socket_ports_t *, void (*)(socket_core_t *));
    119120extern int socket_reply_packets(packet_t *, size_t *);
    120121extern socket_core_t *socket_port_find(socket_ports_t *, int, const uint8_t *,
  • uspace/lib/net/include/tl_common.h

    r55091847 r6b82009  
    2727 */
    2828
    29 /** @addtogroup libnet 
     29/** @addtogroup libnet
    3030 * @{
    3131 */
     
    3939
    4040#include <ipc/services.h>
    41 
    4241#include <net/socket_codes.h>
    4342#include <net/packet.h>
    4443#include <net/device.h>
    4544#include <net/inet.h>
     45#include <async.h>
    4646
    4747/** Device packet dimensions.
     
    5151DEVICE_MAP_DECLARE(packet_dimensions, packet_dimension_t);
    5252
    53 extern int tl_get_ip_packet_dimension(int, packet_dimensions_t *,
     53extern int tl_get_ip_packet_dimension(async_sess_t *, packet_dimensions_t *,
    5454    device_id_t, packet_dimension_t **);
    5555extern int tl_get_address_port(const struct sockaddr *, int, uint16_t *);
     
    5757    size_t);
    5858extern int tl_set_address_port(struct sockaddr *, int, uint16_t);
    59 extern int tl_prepare_icmp_packet(int, int, packet_t *, services_t);
    60 extern int tl_socket_read_packet_data(int, packet_t **, size_t,
     59extern int tl_prepare_icmp_packet(async_sess_t *, async_sess_t *, packet_t *,
     60    services_t);
     61extern int tl_socket_read_packet_data(async_sess_t *, packet_t **, size_t,
    6162    const packet_dimension_t *, const struct sockaddr *, socklen_t);
    6263
     
    6566/** @}
    6667 */
    67 
  • uspace/lib/net/include/tl_remote.h

    r55091847 r6b82009  
    3838#define LIBNET_TL_REMOTE_H_
    3939
    40 #include <async.h>
    4140#include <ipc/services.h>
    4241#include <ipc/tl.h>
    43 
    4442#include <generic.h>
    4543#include <net/device.h>
    4644#include <net/packet.h>
    4745#include <packet_client.h>
     46#include <async.h>
    4847
    4948/** @name Transport layer module interface
     
    5251/*@{*/
    5352
    54 extern int tl_received_msg(int, device_id_t, packet_t *, services_t,
     53extern int tl_received_msg(async_sess_t *, device_id_t, packet_t *, services_t,
    5554    services_t);
    5655
  • uspace/lib/net/include/tl_skel.h

    r55091847 r6b82009  
    3939 */
    4040
    41 #include <async.h>
    4241#include <fibril_synch.h>
    4342#include <ipc/services.h>
    44 
    4543#include <adt/measured_strings.h>
    4644#include <net/device.h>
    4745#include <net/packet.h>
     46#include <async.h>
    4847
    4948/** Module initialization.
     
    5150 * This has to be implemented in user code.
    5251 *
    53  * @param[in] net_phone Networking module phone.
     52 * @param[in] sess Networking module session.
    5453 *
    5554 * @return EOK on success.
     
    5857 *
    5958 */
    60 extern int tl_initialize(int net_phone);
     59extern int tl_initialize(async_sess_t *sess);
    6160
    6261/** Per-connection module initialization.
     
    8382    ipc_call_t *, size_t *);
    8483
    85 extern int tl_module_start(int);
     84extern int tl_module_start(sysarg_t);
    8685
    8786#endif
  • uspace/lib/net/netif/netif_remote.c

    r55091847 r6b82009  
    3838#include <packet_client.h>
    3939#include <generic.h>
    40 #include <async_obsolete.h>
    4140#include <ipc/services.h>
    4241#include <ipc/netif.h>
    43 
    4442#include <net/modules.h>
    4543#include <adt/measured_strings.h>
     
    4947/** Return the device local hardware address.
    5048 *
    51  * @param[in]  netif_phone Network interface phone.
    52  * @param[in]  device_id   Device identifier.
    53  * @param[out] address     Device local hardware address.
    54  * @param[out] data        Address data.
     49 * @param[in]  sess      Network interface session.
     50 * @param[in]  device_id Device identifier.
     51 * @param[out] address   Device local hardware address.
     52 * @param[out] data      Address data.
    5553 *
    5654 * @return EOK on success.
     
    6159 *
    6260 */
    63 int netif_get_addr_req(int netif_phone, device_id_t device_id,
     61int netif_get_addr_req(async_sess_t *sess, device_id_t device_id,
    6462    measured_string_t **address, uint8_t **data)
    6563{
    66         return generic_get_addr_req(netif_phone, NET_NETIF_GET_ADDR, device_id,
     64        return generic_get_addr_req(sess, NET_NETIF_GET_ADDR, device_id,
    6765            address, data);
    6866}
     
    7068/** Probe the existence of the device.
    7169 *
    72  * @param[in] netif_phone Network interface phone.
    73  * @param[in] device_id   Device identifier.
    74  * @param[in] irq         Device interrupt number.
    75  * @param[in] io          Device input/output address.
     70 * @param[in] sess      Network interface session.
     71 * @param[in] device_id Device identifier.
     72 * @param[in] irq       Device interrupt number.
     73 * @param[in] io        Device input/output address.
    7674 *
    7775 * @return EOK on success.
     
    8078 *
    8179 */
    82 int netif_probe_req(int netif_phone, device_id_t device_id, int irq, void *io)
     80int netif_probe_req(async_sess_t *sess, device_id_t device_id, int irq, void *io)
    8381{
    84         return async_obsolete_req_3_0(netif_phone, NET_NETIF_PROBE, device_id, irq,
     82        async_exch_t *exch = async_exchange_begin(sess);
     83        int rc = async_req_3_0(exch, NET_NETIF_PROBE, device_id, (sysarg_t) irq,
    8584            (sysarg_t) io);
     85        async_exchange_end(exch);
     86       
     87        return rc;
    8688}
    8789
    8890/** Send the packet queue.
    8991 *
    90  * @param[in] netif_phone Network interface phone.
    91  * @param[in] device_id   Device identifier.
    92  * @param[in] packet      Packet queue.
    93  * @param[in] sender      Sending module service.
     92 * @param[in] sess      Network interface session.
     93 * @param[in] device_id Device identifier.
     94 * @param[in] packet    Packet queue.
     95 * @param[in] sender    Sending module service.
    9496 *
    9597 * @return EOK on success.
     
    98100 *
    99101 */
    100 int netif_send_msg(int netif_phone, device_id_t device_id, packet_t *packet,
     102int netif_send_msg(async_sess_t *sess, device_id_t device_id, packet_t *packet,
    101103    services_t sender)
    102104{
    103         return generic_send_msg_remote(netif_phone, NET_NETIF_SEND, device_id,
     105        return generic_send_msg_remote(sess, NET_NETIF_SEND, device_id,
    104106            packet_get_id(packet), sender, 0);
    105107}
     
    107109/** Start the device.
    108110 *
    109  * @param[in] netif_phone Network interface phone.
    110  * @param[in] device_id   Device identifier.
     111 * @param[in] sess      Network interface session.
     112 * @param[in] device_id Device identifier.
    111113 *
    112114 * @return EOK on success.
     
    117119 *
    118120 */
    119 int netif_start_req(int netif_phone, device_id_t device_id)
     121int netif_start_req(async_sess_t *sess, device_id_t device_id)
    120122{
    121         return async_obsolete_req_1_0(netif_phone, NET_NETIF_START, device_id);
     123        async_exch_t *exch = async_exchange_begin(sess);
     124        int rc = async_req_1_0(exch, NET_NETIF_START, device_id);
     125        async_exchange_end(exch);
     126       
     127        return rc;
    122128}
    123129
    124130/** Stop the device.
    125131 *
    126  * @param[in] netif_phone Network interface phone.
    127  * @param[in] device_id   Device identifier.
     132 * @param[in] sess      Network interface session.
     133 * @param[in] device_id Device identifier.
    128134 *
    129135 * @return EOK on success.
     
    134140 *
    135141 */
    136 int netif_stop_req(int netif_phone, device_id_t device_id)
     142int netif_stop_req(async_sess_t *sess, device_id_t device_id)
    137143{
    138         return async_obsolete_req_1_0(netif_phone, NET_NETIF_STOP, device_id);
     144        async_exch_t *exch = async_exchange_begin(sess);
     145        int rc = async_req_1_0(exch, NET_NETIF_STOP, device_id);
     146        async_exchange_end(exch);
     147       
     148        return rc;
    139149}
    140150
    141151/** Return the device usage statistics.
    142152 *
    143  * @param[in] netif_phone Network interface phone.
    144  * @param[in] device_id  Device identifier.
    145  * @param[out] stats      Device usage statistics.
     153 * @param[in]  sess      Network interface session.
     154 * @param[in]  device_id Device identifier.
     155 * @param[out] stats     Device usage statistics.
    146156 *
    147157 * @return EOK on success.
    148158 *
    149159 */
    150 int netif_stats_req(int netif_phone, device_id_t device_id,
     160int netif_stats_req(async_sess_t *sess, device_id_t device_id,
    151161    device_stats_t *stats)
    152162{
     
    154164                return EBADMEM;
    155165       
    156         aid_t message_id = async_obsolete_send_1(netif_phone, NET_NETIF_STATS,
     166        async_exch_t *exch = async_exchange_begin(sess);
     167        aid_t message_id = async_send_1(exch, NET_NETIF_STATS,
    157168            (sysarg_t) device_id, NULL);
    158         async_obsolete_data_read_start(netif_phone, stats, sizeof(*stats));
     169        async_data_read_start(exch, stats, sizeof(*stats));
     170        async_exchange_end(exch);
    159171       
    160172        sysarg_t result;
     
    169181 * register the message receiver.
    170182 *
    171  * @param[in] service   The network interface module service.
    172  * @param[in] device_id The device identifier.
    173  * @param[in] me        The requesting module service.
    174  * @param[in] receiver  The message receiver.
     183 * @param[in] service   Network interface module service.
     184 * @param[in] device_id Device identifier.
     185 * @param[in] me        Requesting module service.
     186 * @param[in] receiver  Message receiver.
    175187 *
    176  * @return The phone of the needed service.
    177  * @return EOK on success.
    178  * @return Other error codes as defined for the bind_service()
    179  *         function.
     188 * @return Session to the needed service.
     189 * @return NULL on failure.
    180190 *
    181191 */
    182 int netif_bind_service(services_t service, device_id_t device_id,
     192async_sess_t *netif_bind_service(services_t service, device_id_t device_id,
    183193    services_t me, async_client_conn_t receiver)
    184194{
  • uspace/lib/net/netif/netif_skel.c

    r55091847 r6b82009  
    5454#include <nil_remote.h>
    5555
    56 // FIXME: remove this header
    57 #include <kernel/ipc/ipc_methods.h>
    58 
    5956DEVICE_MAP_IMPLEMENT(netif_device_map, netif_device_t);
    6057
     
    6461/** Probe the existence of the device.
    6562 *
    66  * @param[in] netif_phone Network interface phone.
    6763 * @param[in] device_id   Device identifier.
    6864 * @param[in] irq         Device interrupt number.
     
    7470 *
    7571 */
    76 static int netif_probe_req_local(int netif_phone, device_id_t device_id,
    77     int irq, void *io)
     72static int netif_probe_req_local(device_id_t device_id, int irq, void *io)
    7873{
    7974        fibril_rwlock_write_lock(&netif_globals.lock);
     
    8681/** Send the packet queue.
    8782 *
    88  * @param[in] netif_phone Network interface phone.
    8983 * @param[in] device_id   Device identifier.
    9084 * @param[in] packet      Packet queue.
     
    9690 *
    9791 */
    98 static int netif_send_msg_local(int netif_phone, device_id_t device_id,
    99     packet_t *packet, services_t sender)
     92static int netif_send_msg_local(device_id_t device_id, packet_t *packet,
     93    services_t sender)
    10094{
    10195        fibril_rwlock_write_lock(&netif_globals.lock);
     
    108102/** Start the device.
    109103 *
    110  * @param[in] netif_phone Network interface phone.
    111104 * @param[in] device_id   Device identifier.
    112105 *
     
    118111 *
    119112 */
    120 static int netif_start_req_local(int netif_phone, device_id_t device_id)
     113static int netif_start_req_local(device_id_t device_id)
    121114{
    122115        fibril_rwlock_write_lock(&netif_globals.lock);
     
    131124        int result = netif_start_message(device);
    132125        if (result > NETIF_NULL) {
    133                 int phone = device->nil_phone;
    134                 nil_device_state_msg(phone, device_id, result);
     126                nil_device_state_msg(netif_globals.nil_sess, device_id, result);
    135127                fibril_rwlock_write_unlock(&netif_globals.lock);
    136128                return EOK;
     
    144136/** Stop the device.
    145137 *
    146  * @param[in] netif_phone Network interface phone.
    147138 * @param[in] device_id   Device identifier.
    148139 *
     
    154145 *
    155146 */
    156 static int netif_stop_req_local(int netif_phone, device_id_t device_id)
     147static int netif_stop_req_local(device_id_t device_id)
    157148{
    158149        fibril_rwlock_write_lock(&netif_globals.lock);
     
    167158        int result = netif_stop_message(device);
    168159        if (result > NETIF_NULL) {
    169                 int phone = device->nil_phone;
    170                 nil_device_state_msg(phone, device_id, result);
     160                nil_device_state_msg(netif_globals.nil_sess, device_id, result);
    171161                fibril_rwlock_write_unlock(&netif_globals.lock);
    172162                return EOK;
     
    222212void netif_pq_release(packet_id_t packet_id)
    223213{
    224         pq_release_remote(netif_globals.net_phone, packet_id);
     214        pq_release_remote(netif_globals.sess, packet_id);
    225215}
    226216
     
    235225packet_t *netif_packet_get_1(size_t content)
    236226{
    237         return packet_get_1_remote(netif_globals.net_phone, content);
    238 }
    239 
    240 /** Register the device notification receiver,
    241  *
    242  * Register a  network interface layer module as the device
    243  * notification receiver.
    244  *
    245  * @param[in] device_id Device identifier.
    246  * @param[in] phone     Network interface layer module phone.
    247  *
    248  * @return EOK on success.
    249  * @return ENOENT if there is no such device.
    250  * @return ELIMIT if there is another module registered.
    251  *
    252  */
    253 static int register_message(device_id_t device_id, int phone)
    254 {
    255         netif_device_t *device;
    256         int rc = find_device(device_id, &device);
    257         if (rc != EOK)
    258                 return rc;
    259        
    260         if (device->nil_phone >= 0)
    261                 return ELIMIT;
    262        
    263         device->nil_phone = phone;
    264         return EOK;
     227        return packet_get_1_remote(netif_globals.sess, content);
    265228}
    266229
     
    296259        switch (IPC_GET_IMETHOD(*call)) {
    297260        case NET_NETIF_PROBE:
    298                 return netif_probe_req_local(0, IPC_GET_DEVICE(*call),
     261                return netif_probe_req_local(IPC_GET_DEVICE(*call),
    299262                    NETIF_GET_IRQ(*call), NETIF_GET_IO(*call));
    300263       
    301         case IPC_M_CONNECT_TO_ME:
    302                 fibril_rwlock_write_lock(&netif_globals.lock);
    303                
    304                 rc = register_message(IPC_GET_DEVICE(*call), IPC_GET_PHONE(*call));
    305                
    306                 fibril_rwlock_write_unlock(&netif_globals.lock);
    307                 return rc;
    308        
    309264        case NET_NETIF_SEND:
    310                 rc = packet_translate_remote(netif_globals.net_phone, &packet,
     265                rc = packet_translate_remote(netif_globals.sess, &packet,
    311266                    IPC_GET_PACKET(*call));
    312267                if (rc != EOK)
    313268                        return rc;
    314269               
    315                 return netif_send_msg_local(0, IPC_GET_DEVICE(*call), packet,
     270                return netif_send_msg_local(IPC_GET_DEVICE(*call), packet,
    316271                    IPC_GET_SENDER(*call));
    317272       
    318273        case NET_NETIF_START:
    319                 return netif_start_req_local(0, IPC_GET_DEVICE(*call));
     274                return netif_start_req_local(IPC_GET_DEVICE(*call));
    320275       
    321276        case NET_NETIF_STATS:
     
    343298       
    344299        case NET_NETIF_STOP:
    345                 return netif_stop_req_local(0, IPC_GET_DEVICE(*call));
     300                return netif_stop_req_local(IPC_GET_DEVICE(*call));
    346301       
    347302        case NET_NETIF_GET_ADDR:
     
    403358 * messages in an infinite loop.
    404359 *
     360 * @param[in] nil_service Network interface layer service.
     361 *
    405362 * @return EOK on success.
    406363 * @return Other error codes as defined for each specific module
     
    408365 *
    409366 */
    410 int netif_module_start(void)
     367int netif_module_start(sysarg_t nil_service)
    411368{
    412369        async_set_client_connection(netif_client_connection);
    413370       
    414         netif_globals.net_phone = connect_to_service(SERVICE_NETWORKING);
     371        netif_globals.sess = connect_to_service(SERVICE_NETWORKING);
     372        netif_globals.nil_sess = connect_to_service(nil_service);
    415373        netif_device_map_initialize(&netif_globals.device_map);
    416374       
  • uspace/lib/net/nil/nil_remote.c

    r55091847 r6b82009  
    4545/** Notify the network interface layer about the device state change.
    4646 *
    47  * @param[in] nil_phone Network interface layer phone.
     47 * @param[in] sess      Network interface layer session.
    4848 * @param[in] device_id Device identifier.
    4949 * @param[in] state     New device state.
     
    5454 *
    5555 */
    56 int nil_device_state_msg(int nil_phone, device_id_t device_id, int state)
     56int nil_device_state_msg(async_sess_t *sess, device_id_t device_id,
     57    sysarg_t state)
    5758{
    58         return generic_device_state_msg_remote(nil_phone, NET_NIL_DEVICE_STATE,
     59        return generic_device_state_msg_remote(sess, NET_NIL_DEVICE_STATE,
    5960            device_id, state, 0);
    6061}
     
    6566 * upper layers.
    6667 *
    67  * @param[in] nil_phone Network interface layer phone.
     68 * @param[in] sess      Network interface layer session.
    6869 * @param[in] device_id Source device identifier.
    6970 * @param[in] packet    Received packet or the received packet queue.
     
    7576 *
    7677 */
    77 int nil_received_msg(int nil_phone, device_id_t device_id,
     78int nil_received_msg(async_sess_t *sess, device_id_t device_id,
    7879    packet_t *packet, services_t target)
    7980{
    80         return generic_received_msg_remote(nil_phone, NET_NIL_RECEIVED,
     81        return generic_received_msg_remote(sess, NET_NIL_RECEIVED,
    8182            device_id, packet_get_id(packet), target, 0);
    8283}
  • uspace/lib/net/nil/nil_skel.c

    r55091847 r6b82009  
    3838#include <bool.h>
    3939#include <errno.h>
     40#include <ns.h>
    4041#include <nil_skel.h>
    4142#include <net_interface.h>
    4243#include <net/modules.h>
    43 #include <async_obsolete.h>
    44 
    45 // FIXME: remove this header
    46 #include <kernel/ipc/ipc_methods.h>
    4744
    4845/** Default thread for new connections.
     
    10097 * @return Other error codes as defined for the nil_initialize()
    10198 *         function.
    102  * @return Other error codes as defined for the REGISTER_ME() macro
    103  *         function.
    10499 *
    105100 */
    106 int nil_module_start(int service)
     101int nil_module_start(sysarg_t service)
    107102{
    108103        async_set_client_connection(nil_client_connection);
    109         int net_phone = net_connect_module();
    110         if (net_phone < 0)
    111                 return net_phone;
     104        async_sess_t *sess = net_connect_module();
     105        if (!sess)
     106                return ENOENT;
    112107       
    113108        int rc = pm_init();
     
    115110                return rc;
    116111       
    117         rc = nil_initialize(net_phone);
     112        rc = nil_initialize(sess);
    118113        if (rc != EOK)
    119114                goto out;
    120115       
    121         rc = async_obsolete_connect_to_me(PHONE_NS, service, 0, 0, NULL, NULL);
     116        rc = service_register(service);
    122117        if (rc != EOK)
    123118                goto out;
  • uspace/lib/net/tl/icmp_remote.c

    r55091847 r6b82009  
    3939#include <net/modules.h>
    4040#include <packet_client.h>
    41 
    42 #include <async.h>
    43 #include <async_obsolete.h>
    44 #include <errno.h>
    4541#include <ipc/services.h>
    4642#include <ipc/icmp.h>
    4743#include <sys/types.h>
     44#include <async.h>
     45#include <errno.h>
    4846
    49 /** Sends the Destination Unreachable error notification packet.
     47/** Send the Destination Unreachable error notification packet.
    5048 *
    5149 * Beginning of the packet is sent as the notification packet data.
     
    5351 * packet.
    5452 *
    55  * @param[in] icmp_phone The ICMP module phone used for (semi)remote calls.
    56  * @param[in] code      The error specific code.
    57  * @param[in] mtu       The error MTU value.
    58  * @param[in] packet    The original packet.
    59  * @return              EOK on success.
    60  * @return              EPERM if the ICMP error notifications are disabled.
    61  * @return              ENOMEM if there is not enough memory left.
     53 * @param[in] sess   ICMP module session.
     54 * @param[in] code   Error specific code.
     55 * @param[in] mtu    Error MTU value.
     56 * @param[in] packet Original packet.
     57 *
     58 * @return EOK on success.
     59 * @return EPERM if the ICMP error notifications are disabled.
     60 * @return ENOMEM if there is not enough memory left.
     61 *
    6262 */
    63 int
    64 icmp_destination_unreachable_msg(int icmp_phone, icmp_code_t code,
     63int icmp_destination_unreachable_msg(async_sess_t *sess, icmp_code_t code,
    6564    icmp_param_t mtu, packet_t *packet)
    6665{
    67         async_obsolete_msg_3(icmp_phone, NET_ICMP_DEST_UNREACH, (sysarg_t) code,
     66        async_exch_t *exch = async_exchange_begin(sess);
     67        async_msg_3(exch, NET_ICMP_DEST_UNREACH, (sysarg_t) code,
    6868            (sysarg_t) packet_get_id(packet), (sysarg_t) mtu);
     69        async_exchange_end(exch);
     70       
    6971        return EOK;
    7072}
    7173
    72 /** Sends the Source Quench error notification packet.
     74/** Send the Source Quench error notification packet.
    7375 *
    7476 * Beginning of the packet is sent as the notification packet data.
     
    7678 * packet.
    7779 *
    78  * @param[in] icmp_phone The ICMP module phone used for (semi)remote calls.
    79  * @param[in] packet    The original packet.
    80  * @return              EOK on success.
    81  * @return              EPERM if the ICMP error notifications are disabled.
    82  * @return              ENOMEM if there is not enough memory left.
     80 * @param[in] sess   ICMP module session.
     81 * @param[in] packet Original packet.
     82 *
     83 * @return EOK on success.
     84 * @return EPERM if the ICMP error notifications are disabled.
     85 * @return ENOMEM if there is not enough memory left.
     86 *
    8387 */
    84 int icmp_source_quench_msg(int icmp_phone, packet_t *packet)
     88int icmp_source_quench_msg(async_sess_t *sess, packet_t *packet)
    8589{
    86         async_obsolete_msg_2(icmp_phone, NET_ICMP_SOURCE_QUENCH, 0,
     90        async_exch_t *exch = async_exchange_begin(sess);
     91        async_msg_2(exch, NET_ICMP_SOURCE_QUENCH, 0,
    8792            (sysarg_t) packet_get_id(packet));
     93        async_exchange_end(exch);
     94       
    8895        return EOK;
    8996}
    9097
    91 /** Sends the Time Exceeded error notification packet.
     98/** Send the Time Exceeded error notification packet.
    9299 *
    93100 * Beginning of the packet is sent as the notification packet data.
     
    95102 * packet.
    96103 *
    97  * @param[in] icmp_phone The ICMP module phone used for (semi)remote calls.
    98  * @param[in] code      The error specific code.
    99  * @param[in] packet    The original packet.
    100  * @return              EOK on success.
    101  * @return              EPERM if the ICMP error notifications are disabled.
    102  * @return              ENOMEM if there is not enough memory left.
     104 * @param[in] sess   ICMP module session.
     105 * @param[in] code   Error specific code.
     106 * @param[in] packet Original packet.
     107 *
     108 * @return EOK on success.
     109 * @return EPERM if the ICMP error notifications are disabled.
     110 * @return ENOMEM if there is not enough memory left.
     111 *
    103112 */
    104 int icmp_time_exceeded_msg(int icmp_phone, icmp_code_t code, packet_t *packet)
     113int icmp_time_exceeded_msg(async_sess_t *sess, icmp_code_t code,
     114    packet_t *packet)
    105115{
    106         async_obsolete_msg_2(icmp_phone, NET_ICMP_TIME_EXCEEDED, (sysarg_t) code,
     116        async_exch_t *exch = async_exchange_begin(sess);
     117        async_msg_2(exch, NET_ICMP_TIME_EXCEEDED, (sysarg_t) code,
    107118            (sysarg_t) packet_get_id(packet));
     119        async_exchange_end(exch);
     120       
    108121        return EOK;
    109122}
    110123
    111 /** Sends the Parameter Problem error notification packet.
     124/** Send the Parameter Problem error notification packet.
    112125 *
    113126 * Beginning of the packet is sent as the notification packet data.
     
    115128 * packet.
    116129 *
    117  * @param[in] icmp_phone The ICMP module phone used for (semi)remote calls.
    118  * @param[in] code      The error specific code.
    119  * @param[in] pointer   The problematic parameter offset.
    120  * @param[in] packet    The original packet.
    121  * @return              EOK on success.
    122  * @return              EPERM if the ICMP error notifications are disabled.
    123  * @return              ENOMEM if there is not enough memory left.
     130 * @param[in] sess    ICMP module session.
     131 * @param[in] code    Error specific code.
     132 * @param[in] pointer Problematic parameter offset.
     133 * @param[in] packet  Original packet.
     134 *
     135 * @return EOK on success.
     136 * @return EPERM if the ICMP error notifications are disabled.
     137 * @return ENOMEM if there is not enough memory left.
     138 *
    124139 */
    125 int icmp_parameter_problem_msg(int icmp_phone, icmp_code_t code,
     140int icmp_parameter_problem_msg(async_sess_t *sess, icmp_code_t code,
    126141    icmp_param_t pointer, packet_t *packet)
    127142{
    128         async_obsolete_msg_3(icmp_phone, NET_ICMP_PARAMETERPROB, (sysarg_t) code,
     143        async_exch_t *exch = async_exchange_begin(sess);
     144        async_msg_3(exch, NET_ICMP_PARAMETERPROB, (sysarg_t) code,
    129145            (sysarg_t) packet_get_id(packet), (sysarg_t) pointer);
     146        async_exchange_end(exch);
     147       
    130148        return EOK;
    131149}
     
    133151/** @}
    134152 */
    135 
  • uspace/lib/net/tl/socket_core.c

    r55091847 r6b82009  
    3838#include <packet_client.h>
    3939#include <packet_remote.h>
    40 
    4140#include <net/socket_codes.h>
    4241#include <net/in.h>
     
    4443#include <net/packet.h>
    4544#include <net/modules.h>
    46 
    4745#include <stdint.h>
    4846#include <stdlib.h>
    4947#include <errno.h>
    50 
    5148#include <adt/dynamic_fifo.h>
    5249#include <adt/int_map.h>
     
    5653 * switching to the sequence.
    5754 */
    58 #define SOCKET_ID_TRIES 100
     55#define SOCKET_ID_TRIES  100
    5956
    6057/** Bound port sockets.*/
     
    7269INT_MAP_IMPLEMENT(socket_ports, socket_port_t);
    7370
    74 /** Destroys the socket.
     71/** Destroy the socket.
    7572 *
    7673 * If the socket is bound, the port is released.
    77  * Releases all buffered packets, calls the release function and removes the
     74 * Release all buffered packets, call the release function and remove the
    7875 * socket from the local sockets.
    7976 *
    80  * @param[in] packet_phone The packet server phone to release buffered packets.
    81  * @param[in] socket    The socket to be destroyed.
    82  * @param[in,out] local_sockets The local sockets to be updated.
    83  * @param[in,out] global_sockets The global sockets to be updated.
    84  * @param[in] socket_release The client release callback function.
    85  */
    86 static void
    87 socket_destroy_core(int packet_phone, socket_core_t *socket,
     77 * @param[in]     sess           Packet server session.
     78 * @param[in]     socket         Socket to be destroyed.
     79 * @param[in,out] local_sockets  Local sockets to be updated.
     80 * @param[in,out] global_sockets Global sockets to be updated.
     81 * @param[in]     socket_release Client release callback function.
     82 *
     83 */
     84static void socket_destroy_core(async_sess_t *sess, socket_core_t *socket,
    8885    socket_cores_t *local_sockets, socket_ports_t *global_sockets,
    8986    void (* socket_release)(socket_core_t *socket))
    9087{
    91         int packet_id;
    92 
    9388        /* If bound */
    9489        if (socket->port) {
     
    9893       
    9994        /* Release all received packets */
     95        int packet_id;
    10096        while ((packet_id = dyn_fifo_pop(&socket->received)) >= 0)
    101                 pq_release_remote(packet_phone, packet_id);
    102 
     97                pq_release_remote(sess, packet_id);
     98       
    10399        dyn_fifo_destroy(&socket->received);
    104100        dyn_fifo_destroy(&socket->accepted);
    105 
     101       
    106102        if (socket_release)
    107103                socket_release(socket);
    108 
     104       
    109105        socket_cores_exclude(local_sockets, socket->socket_id, free);
    110106}
    111107
    112 /** Destroys local sockets.
    113  *
    114  * Releases all buffered packets and calls the release function for each of the
     108/** Destroy local sockets.
     109 *
     110 * Release all buffered packets and call the release function for each of the
    115111 * sockets.
    116112 *
    117  * @param[in] packet_phone The packet server phone to release buffered packets.
    118  * @param[in] local_sockets The local sockets to be destroyed.
    119  * @param[in,out] global_sockets The global sockets to be updated.
    120  * @param[in] socket_release The client release callback function.
    121  */
    122 void
    123 socket_cores_release(int packet_phone, socket_cores_t *local_sockets,
     113 * @param[in]     sess           Packet server session.
     114 * @param[in]     local_sockets  Local sockets to be destroyed.
     115 * @param[in,out] global_sockets Global sockets to be updated.
     116 * @param[in]     socket_release Client release callback function.
     117 *
     118 */
     119void socket_cores_release(async_sess_t *sess, socket_cores_t *local_sockets,
    124120    socket_ports_t *global_sockets,
    125121    void (* socket_release)(socket_core_t *socket))
    126122{
    127         int index;
    128 
    129123        if (!socket_cores_is_valid(local_sockets))
    130124                return;
    131 
     125       
    132126        local_sockets->magic = 0;
    133 
     127       
     128        int index;
    134129        for (index = 0; index < local_sockets->next; ++index) {
    135130                if (socket_cores_item_is_valid(&local_sockets->items[index])) {
    136131                        local_sockets->items[index].magic = 0;
    137 
     132                       
    138133                        if (local_sockets->items[index].value) {
    139                                 socket_destroy_core(packet_phone,
     134                                socket_destroy_core(sess,
    140135                                    local_sockets->items[index].value,
    141136                                    local_sockets, global_sockets,
     
    146141                }
    147142        }
    148 
     143       
    149144        free(local_sockets->items);
    150145}
     
    406401}
    407402
    408 /** Creates a new socket.
    409  *
    410  * @param[in,out] local_sockets The local sockets to be updated.
    411  * @param[in] app_phone The application phone.
    412  * @param[in] specific_data The socket specific data.
    413  * @param[in,out] socket_id The new socket identifier. A new identifier is
    414  *                      chosen if set to zero or negative. A negative identifier
    415  *                      is chosen if set to negative.
    416  * @return              EOK on success.
    417  * @return              EINVAL if the socket_id parameter is NULL.
    418  * @return              ENOMEM if there is not enough memory left.
    419  */
    420 int
    421 socket_create(socket_cores_t *local_sockets, int app_phone,
     403/** Create a new socket.
     404 *
     405 * @param[in,out] local_sockets Local sockets to be updated.
     406 * @param[in]     sess          Application session.
     407 * @param[in]     specific_data Socket specific data.
     408 * @param[in,out] socket_id     New socket identifier. A new identifier
     409 *                              is chosen if set to zero or negative.
     410 *                              A negative identifier is chosen if set
     411 *                              to negative.
     412 *
     413 * @return EOK on success.
     414 * @return EINVAL if the socket_id parameter is NULL.
     415 * @return ENOMEM if there is not enough memory left.
     416 *
     417 */
     418int socket_create(socket_cores_t *local_sockets, async_sess_t* sess,
    422419    void *specific_data, int *socket_id)
    423420{
     
    446443       
    447444        /* Initialize */
    448         socket->phone = app_phone;
     445        socket->sess = sess;
    449446        socket->port = -1;
    450447        socket->key = NULL;
     
    475472}
    476473
    477 /** Destroys the socket.
     474/** Destroy the socket.
    478475 *
    479476 * If the socket is bound, the port is released.
    480  * Releases all buffered packets, calls the release function and removes the
     477 * Release all buffered packets, call the release function and remove the
    481478 * socket from the local sockets.
    482479 *
    483  * @param[in] packet_phone The packet server phone to release buffered packets.
    484  * @param[in] socket_id The socket identifier.
    485  * @param[in,out] local_sockets The local sockets to be updated.
    486  * @param[in,out] global_sockets The global sockets to be updated.
    487  * @param[in] socket_release The client release callback function.
    488  * @return              EOK on success.
    489  * @return              ENOTSOCK if the socket is not found.
     480 * @param[in]     sess           Packet server session.
     481 * @param[in]     socket_id      Socket identifier.
     482 * @param[in,out] local_sockets  Local sockets to be updated.
     483 * @param[in,out] global_sockets Global sockets to be updated.
     484 * @param[in]     socket_release Client release callback function.
     485 *
     486 * @return EOK on success.
     487 * @return ENOTSOCK if the socket is not found.
     488 *
    490489 */
    491490int
    492 socket_destroy(int packet_phone, int socket_id, socket_cores_t *local_sockets,
     491socket_destroy(async_sess_t *sess, int socket_id, socket_cores_t *local_sockets,
    493492    socket_ports_t *global_sockets,
    494493    void (*socket_release)(socket_core_t *socket))
    495494{
    496         socket_core_t *socket;
    497         int accepted_id;
    498 
    499495        /* Find the socket */
    500         socket = socket_cores_find(local_sockets, socket_id);
     496        socket_core_t *socket = socket_cores_find(local_sockets, socket_id);
    501497        if (!socket)
    502498                return ENOTSOCK;
    503499       
    504500        /* Destroy all accepted sockets */
     501        int accepted_id;
    505502        while ((accepted_id = dyn_fifo_pop(&socket->accepted)) >= 0)
    506                 socket_destroy(packet_phone, accepted_id, local_sockets,
     503                socket_destroy(sess, accepted_id, local_sockets,
    507504                    global_sockets, socket_release);
    508505       
    509         socket_destroy_core(packet_phone, socket, local_sockets, global_sockets,
     506        socket_destroy_core(sess, socket, local_sockets, global_sockets,
    510507            socket_release);
    511508       
  • uspace/lib/net/tl/tl_common.c

    r55091847 r6b82009  
    4343#include <ip_interface.h>
    4444#include <tl_remote.h>
    45 
    4645#include <net/socket_codes.h>
    4746#include <net/in.h>
     
    5049#include <net/device.h>
    5150#include <net/packet.h>
    52 
    5351#include <async.h>
    5452#include <ipc/services.h>
     
    107105 * The reply is cached then.
    108106 *
    109  * @param[in] ip_phone  The IP moduel phone for (semi)remote calls.
    110  * @param[in] packet_dimensions The packet dimensions cache.
    111  * @param[in] device_id The device identifier.
    112  * @param[out] packet_dimension The IP packet dimensions.
    113  * @return              EOK on success.
    114  * @return              EBADMEM if the packet_dimension parameter is NULL.
    115  * @return              ENOMEM if there is not enough memory left.
    116  * @return              EINVAL if the packet_dimensions cache is not valid.
    117  * @return              Other codes as defined for the ip_packet_size_req()
    118  *                      function.
    119  */
    120 int
    121 tl_get_ip_packet_dimension(int ip_phone,
     107 * @param[in]  sess              IP module session.
     108 * @param[in]  packet_dimensions Packet dimensions cache.
     109 * @param[in]  device_id         Device identifier.
     110 * @param[out] packet_dimension  IP packet dimensions.
     111 *
     112 * @return EOK on success.
     113 * @return EBADMEM if the packet_dimension parameter is NULL.
     114 * @return ENOMEM if there is not enough memory left.
     115 * @return EINVAL if the packet_dimensions cache is not valid.
     116 * @return Other codes as defined for the ip_packet_size_req()
     117 *         function.
     118 *
     119 */
     120int tl_get_ip_packet_dimension(async_sess_t *sess,
    122121    packet_dimensions_t *packet_dimensions, device_id_t device_id,
    123122    packet_dimension_t **packet_dimension)
    124123{
    125         int rc;
    126        
    127124        if (!packet_dimension)
    128125                return EBADMEM;
     
    133130                /* Ask for and remember them if not found */
    134131                *packet_dimension = malloc(sizeof(**packet_dimension));
    135                 if(!*packet_dimension)
     132                if (!*packet_dimension)
    136133                        return ENOMEM;
    137134               
    138                 rc = ip_packet_size_req(ip_phone, device_id, *packet_dimension);
     135                int rc = ip_packet_size_req(sess, device_id, *packet_dimension);
    139136                if (rc != EOK) {
    140137                        free(*packet_dimension);
     
    236233/** Prepares the packet for ICMP error notification.
    237234 *
    238  * Keeps the first packet and releases all the others.
    239  * Releases all the packets on error.
    240  *
    241  * @param[in] packet_phone The packet server module phone.
    242  * @param[in] icmp_phone The ICMP module phone.
    243  * @param[in] packet    The packet to be send.
    244  * @param[in] error     The packet error reporting service. Prefixes the
    245  *                      received packet.
    246  * @return              EOK on success.
    247  * @return              ENOENT if no packet may be sent.
    248  */
    249 int
    250 tl_prepare_icmp_packet(int packet_phone, int icmp_phone, packet_t *packet,
    251     services_t error)
    252 {
    253         packet_t *next;
     235 * Keep the first packet and release all the others.
     236 * Release all the packets on error.
     237 *
     238 * @param[in] packet_sess Packet server module session.
     239 * @param[in] icmp_sess   ICMP module phone.
     240 * @param[in] packet      Packet to be send.
     241 * @param[in] error       Packet error reporting service. Prefixes the
     242 *                        received packet.
     243 *
     244 * @return EOK on success.
     245 * @return ENOENT if no packet may be sent.
     246 *
     247 */
     248int tl_prepare_icmp_packet(async_sess_t *packet_sess, async_sess_t *icmp_sess,
     249    packet_t *packet, services_t error)
     250{
     251        /* Detach the first packet and release the others */
     252        packet_t *next = pq_detach(packet);
     253        if (next)
     254                pq_release_remote(packet_sess, packet_get_id(next));
     255       
    254256        uint8_t *src;
    255         int length;
    256 
    257         /* Detach the first packet and release the others */
    258         next = pq_detach(packet);
    259         if (next)
    260                 pq_release_remote(packet_phone, packet_get_id(next));
    261        
    262         length = packet_get_addr(packet, &src, NULL);
    263         if ((length > 0) && (!error) && (icmp_phone >= 0) &&
     257        int length = packet_get_addr(packet, &src, NULL);
     258        if ((length > 0) && (!error) && (icmp_sess) &&
    264259            /*
    265260             * Set both addresses to the source one (avoids the source address
     
    269264                return EOK;
    270265        } else
    271                 pq_release_remote(packet_phone, packet_get_id(packet));
    272 
     266                pq_release_remote(packet_sess, packet_get_id(packet));
     267       
    273268        return ENOENT;
    274269}
     
    276271/** Receives data from the socket into a packet.
    277272 *
    278  * @param[in] packet_phone The packet server module phone.
    279  * @param[out] packet   The new created packet.
    280  * @param[in] prefix    Reserved packet data prefix length.
    281  * @param[in] dimension The packet dimension.
    282  * @param[in] addr      The destination address.
    283  * @param[in] addrlen   The address length.
    284  * @return              Number of bytes received.
    285  * @return              EINVAL if the client does not send data.
    286  * @return              ENOMEM if there is not enough memory left.
    287  * @return              Other error codes as defined for the
    288  *                      async_data_read_finalize() function.
    289  */
    290 int
    291 tl_socket_read_packet_data(int packet_phone, packet_t **packet, size_t prefix,
    292     const packet_dimension_t *dimension, const struct sockaddr *addr,
    293     socklen_t addrlen)
     273 * @param[in]  sess      Packet server module session.
     274 * @param[out] packet    New created packet.
     275 * @param[in]  prefix    Reserved packet data prefix length.
     276 * @param[in]  dimension Packet dimension.
     277 * @param[in]  addr      Destination address.
     278 * @param[in]  addrlen   Address length.
     279 *
     280 * @return Number of bytes received.
     281 * @return EINVAL if the client does not send data.
     282 * @return ENOMEM if there is not enough memory left.
     283 * @return Other error codes as defined for the
     284 *         async_data_read_finalize() function.
     285 *
     286 */
     287int tl_socket_read_packet_data(async_sess_t *sess, packet_t **packet,
     288    size_t prefix, const packet_dimension_t *dimension,
     289    const struct sockaddr *addr, socklen_t addrlen)
    294290{
    295291        ipc_callid_t callid;
     
    306302
    307303        /* Get a new packet */
    308         *packet = packet_get_4_remote(packet_phone, length, dimension->addr_len,
     304        *packet = packet_get_4_remote(sess, length, dimension->addr_len,
    309305            prefix + dimension->prefix, dimension->suffix);
    310306        if (!packet)
     
    314310        data = packet_suffix(*packet, length);
    315311        if (!data) {
    316                 pq_release_remote(packet_phone, packet_get_id(*packet));
     312                pq_release_remote(sess, packet_get_id(*packet));
    317313                return ENOMEM;
    318314        }
     
    321317        rc = async_data_write_finalize(callid, data, length);
    322318        if (rc != EOK) {
    323                 pq_release_remote(packet_phone, packet_get_id(*packet));
     319                pq_release_remote(sess, packet_get_id(*packet));
    324320                return rc;
    325321        }
     
    328324        rc = packet_set_addr(*packet, NULL, (uint8_t *) addr, addrlen);
    329325        if (rc != EOK) {
    330                 pq_release_remote(packet_phone, packet_get_id(*packet));
     326                pq_release_remote(sess, packet_get_id(*packet));
    331327                return rc;
    332328        }
  • uspace/lib/net/tl/tl_remote.c

    r55091847 r6b82009  
    3434#include <generic.h>
    3535#include <packet_client.h>
    36 
    3736#include <ipc/services.h>
    3837#include <ipc/tl.h>
    39 
    4038#include <net/device.h>
    4139#include <net/packet.h>
     40#include <async.h>
    4241
    4342/** Notify the remote transport layer modules about the received packet/s.
    4443 *
    45  * @param[in] tl_phone  The transport layer module phone used for remote calls.
    46  * @param[in] device_id The device identifier.
    47  * @param[in] packet    The received packet or the received packet queue.
     44 * @param[in] sess      Transport layer module session.
     45 * @param[in] device_id Device identifier.
     46 * @param[in] packet    Received packet or the received packet queue.
    4847 *                      The packet queue is used to carry a fragmented
    4948 *                      datagram. The first packet contains the headers,
    5049 *                      the others contain only data.
    51  * @param[in] target    The target transport layer module service to be
     50 * @param[in] target    Target transport layer module service to be
    5251 *                      delivered to.
    53  * @param[in] error     The packet error reporting service. Prefixes the
     52 * @param[in] error     Packet error reporting service. Prefixes the
    5453 *                      received packet.
    5554 *
     
    5756 *
    5857 */
    59 int tl_received_msg(int tl_phone, device_id_t device_id, packet_t *packet,
     58int tl_received_msg(async_sess_t *sess, device_id_t device_id, packet_t *packet,
    6059    services_t target, services_t error)
    6160{
    62         return generic_received_msg_remote(tl_phone, NET_TL_RECEIVED, device_id,
     61        return generic_received_msg_remote(sess, NET_TL_RECEIVED, device_id,
    6362            packet_get_id(packet), target, error);
    6463}
  • uspace/lib/net/tl/tl_skel.c

    r55091847 r6b82009  
    3838#include <bool.h>
    3939#include <errno.h>
     40#include <ns.h>
    4041#include <tl_skel.h>
    4142#include <net_interface.h>
    4243#include <net/modules.h>
    43 #include <async_obsolete.h>
    44 
    45 // FIXME: remove this header
    46 #include <kernel/ipc/ipc_methods.h>
    4744
    4845/** Default thread for new connections.
    4946 *
    50  * @param[in] iid       The initial message identifier.
    51  * @param[in] icall     The initial message call structure.
    52  * @param[in] arg       Local argument.
     47 * @param[in] iid   The initial message identifier.
     48 * @param[in] icall The initial message call structure.
     49 * @param[in] arg   Local argument.
    5350 *
    5451 */
     
    107104 *
    108105 */
    109 int tl_module_start(int service)
     106int tl_module_start(sysarg_t service)
    110107{
    111108        async_set_client_connection(tl_client_connection);
    112         int net_phone = net_connect_module();
    113         if (net_phone < 0)
    114                 return net_phone;
     109        async_sess_t *sess = net_connect_module();
     110        if (!sess)
     111                return ENOENT;
    115112       
    116113        int rc = pm_init();
     
    118115                return rc;
    119116       
    120         rc = tl_initialize(net_phone);
     117        rc = tl_initialize(sess);
    121118        if (rc != EOK)
    122119                goto out;
    123120       
    124         rc = async_obsolete_connect_to_me(PHONE_NS, service, 0, 0, NULL, NULL);
     121        rc = service_register(service);
    125122        if (rc != EOK)
    126123                goto out;
  • uspace/lib/packet/generic/packet_server.c

    r55091847 r6b82009  
    3636
    3737#include <packet_server.h>
    38 
    3938#include <align.h>
    4039#include <assert.h>
     
    317316 *                      packet_release_wrapper() function.
    318317 */
    319 int
    320 packet_server_message(ipc_callid_t callid, ipc_call_t *call, ipc_call_t *answer,
     318int packet_server_message(ipc_callid_t callid, ipc_call_t *call, ipc_call_t *answer,
    321319    size_t *answer_count)
    322320{
    323321        packet_t *packet;
    324 
    325         *answer_count = 0;
    326322       
    327323        if (!IPC_GET_IMETHOD(*call))
    328324                return EOK;
    329325       
     326        *answer_count = 0;
    330327        switch (IPC_GET_IMETHOD(*call)) {
    331328        case NET_PACKET_CREATE_1:
Note: See TracChangeset for help on using the changeset viewer.