Changeset 1916d1f in mainline for uspace/lib/net/il/ip_remote.c


Ignore:
Timestamp:
2011-07-12T13:41:26Z (13 years ago)
Author:
Petr Koupy <petr.koupy@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
50fc490
Parents:
11809eab (diff), 6817eba (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge libposix changes.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/net/il/ip_remote.c

    r11809eab r1916d1f  
    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,
     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,
    121126    services_t service)
    122127{
    123         return generic_device_req_remote(ip_phone, NET_IP_DEVICE, device_id, 0,
     128        return generic_device_req_remote(sess, NET_IP_DEVICE, device_id, 0,
    124129            service);
    125130}
     
    128133 * destination address.
    129134 *
    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,
     135 * @param[in] sess        IP module session.
     136 * @param[in] protocol    Transport protocol.
     137 * @param[in] destination Destination address.
     138 * @param[in] addrlen     Destination address length.
     139 * @param[out] device_id  Device identifier.
     140 * @param[out] header     Constructed IP pseudo header.
     141 * @param[out] headerlen IP pseudo header length.
     142 *
     143 */
     144int ip_get_route_req_remote(async_sess_t *sess, ip_protocol_t protocol,
    140145    const struct sockaddr *destination, socklen_t addrlen,
    141146    device_id_t *device_id, void **header, size_t *headerlen)
    142147{
    143         if (!destination || (addrlen == 0))
     148        if ((!destination) || (addrlen == 0))
    144149                return EINVAL;
    145150       
    146         if (!device_id || !header || !headerlen)
     151        if ((!device_id) || (!header) || (!headerlen))
    147152                return EBADMEM;
    148153       
    149154        *header = NULL;
    150155       
     156        async_exch_t *exch = async_exchange_begin(sess);
     157       
    151158        ipc_call_t answer;
    152         aid_t message_id = async_obsolete_send_1(ip_phone, NET_IP_GET_ROUTE,
     159        aid_t message_id = async_send_1(exch, NET_IP_GET_ROUTE,
    153160            (sysarg_t) protocol, &answer);
    154161       
    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)) {
     162        if ((async_data_write_start(exch, destination, addrlen) == EOK) &&
     163            (async_data_read_start(exch, headerlen, sizeof(*headerlen)) == EOK) &&
     164            (*headerlen > 0)) {
    158165                *header = malloc(*headerlen);
    159166                if (*header) {
    160                         if (async_obsolete_data_read_start(ip_phone, *header,
     167                        if (async_data_read_start(exch, *header,
    161168                            *headerlen) != EOK)
    162169                                free(*header);
     
    164171        }
    165172       
     173        async_exchange_end(exch);
     174       
    166175        sysarg_t result;
    167176        async_wait_for(message_id, &result);
     
    177186/** Return the device packet dimension for sending.
    178187 *
    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,
     188 * @param[in] sess              IP module session.
     189 * @param[in] device_id         Device identifier.
     190 * @param[out] packet_dimension Packet dimension.
     191 *
     192 * @return EOK on success.
     193 * @return ENOENT if there is no such device.
     194 * @return Other error codes as defined for the
     195 *         generic_packet_size_req_remote() function.
     196 *
     197 */
     198int ip_packet_size_req_remote(async_sess_t *sess, device_id_t device_id,
    188199    packet_dimension_t *packet_dimension)
    189200{
    190         return generic_packet_size_req_remote(ip_phone, NET_IP_PACKET_SPACE,
     201        return generic_packet_size_req_remote(sess, NET_IP_PACKET_SPACE,
    191202            device_id, packet_dimension);
    192203}
     
    194205/** Notify the IP module about the received error notification packet.
    195206 *
    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,
     207 * @param[in] sess      IP module session.
     208 * @param[in] device_id Device identifier.
     209 * @param[in] packet    Received packet or the received packet queue.
     210 * @param[in] target    Target internetwork module service to be
     211 *                      delivered to.
     212 * @param[in] error     Packet error reporting service. Prefixes the
     213 *                      received packet.
     214 *
     215 * @return EOK on success.
     216 *
     217 */
     218int ip_received_error_msg_remote(async_sess_t *sess, device_id_t device_id,
    206219    packet_t *packet, services_t target, services_t error)
    207220{
    208         return generic_received_msg_remote(ip_phone, NET_IP_RECEIVED_ERROR,
     221        return generic_received_msg_remote(sess, NET_IP_RECEIVED_ERROR,
    209222            device_id, packet_get_id(packet), target, error);
    210223}
     
    214227 * The packets may get fragmented if needed.
    215228 *
    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,
     229 * @param[in] sess      IP module session.
     230 * @param[in] device_id Device identifier.
     231 * @param[in] packet    Packet fragments as a packet queue. All the
     232 *                      packets have to have the same destination address.
     233 * @param[in] sender    Sending module service.
     234 * @param[in] error     Packet error reporting service. Prefixes the
     235 *                      received packet.
     236 *
     237 * @return EOK on success.
     238 * @return Other error codes as defined for the generic_send_msg()
     239 *         function.
     240 *
     241 */
     242int ip_send_msg_remote(async_sess_t *sess, device_id_t device_id,
     243    packet_t *packet, services_t sender, services_t error)
     244{
     245        return generic_send_msg_remote(sess, NET_IP_SEND, device_id,
    231246            packet_get_id(packet), sender, error);
    232247}
     
    236251 * This gateway is used if no other route is found.
    237252 *
    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,
     253 * @param[in] sess      IP module session.
     254 * @param[in] device_id Device identifier.
     255 * @param[in] gateway   Default gateway.
     256 *
     257 */
     258int ip_set_gateway_req_remote(async_sess_t *sess, device_id_t device_id,
    243259    in_addr_t gateway)
    244260{
    245         return (int) async_obsolete_req_2_0(ip_phone, NET_IP_SET_GATEWAY,
     261        async_exch_t *exch = async_exchange_begin(sess);
     262        int rc = async_req_2_0(exch, NET_IP_SET_GATEWAY,
    246263            (sysarg_t) device_id, (sysarg_t) gateway.s_addr);
     264        async_exchange_end(exch);
     265       
     266        return rc;
    247267}
    248268
Note: See TracChangeset for help on using the changeset viewer.