Changeset 89c57b6 in mainline for uspace/lib/net/il/ip_remote.c


Ignore:
Timestamp:
2011-04-13T14:45:41Z (14 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
88634420
Parents:
cefb126 (diff), 17279ead (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge mainline changes.

File:
1 edited

Legend:

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

    rcefb126 r89c57b6  
    2727 */
    2828
    29 /** @addtogroup ip
     29/** @addtogroup libnet
    3030 * @{
    3131 */
     
    3636 *
    3737 * @see ip_interface.h
    38  * @see il_interface.h
    39  *
    40  */
     38 * @see il_remote.h
     39 *
     40 */
     41
     42#include <ip_remote.h>
     43#include <ip_interface.h>
     44#include <packet_client.h>
     45#include <generic.h>
    4146
    4247#include <ipc/services.h>
    43 
    44 #include <net_messages.h>
    45 #include <net_modules.h>
    46 #include <net_device.h>
    47 #include <inet.h>
    48 #include <ip_interface.h>
    49 #include <packet/packet_client.h>
    50 #include <il_messages.h>
    51 #include <ip_messages.h>
    52 #include <ip_remote.h>
     48#include <ipc/il.h>
     49#include <ipc/ip.h>
     50
     51#include <net/modules.h>
     52#include <net/device.h>
     53#include <net/inet.h>
    5354
    5455/** Add a route to the device routing table.
     
    5657 * The target network is routed using this device.
    5758 *
    58  * @param[in] ip_phone  The IP module phone used for (semi)remote calls.
    59  * @param[in] device_id The device identifier.
    60  * @param[in] address   The target network address.
    61  * @param[in] netmask   The target network mask.
    62  * @param[in] gateway   The target network gateway. Not used if zero.
    63  *
     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.
    6464 */
    6565int ip_add_route_req_remote(int ip_phone, device_id_t device_id,
     
    6767{
    6868        return (int) async_req_4_0(ip_phone, NET_IP_ADD_ROUTE,
    69             (ipcarg_t) device_id, (ipcarg_t) gateway.s_addr,
    70             (ipcarg_t) address.s_addr, (ipcarg_t) netmask.s_addr);
    71 }
    72 
     69            (sysarg_t) device_id, (sysarg_t) gateway.s_addr,
     70            (sysarg_t) address.s_addr, (sysarg_t) netmask.s_addr);
     71}
     72
     73/** Creates bidirectional connection with the ip module service and registers
     74 * the message receiver.
     75 *
     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 */
    7385int ip_bind_service(services_t service, int protocol, services_t me,
    74     async_client_conn_t receiver, tl_received_msg_t tl_received_msg)
    75 {
    76         return (int) bind_service(service, (ipcarg_t) protocol, me, service,
     86    async_client_conn_t receiver)
     87{
     88        return (int) bind_service(service, (sysarg_t) protocol, me, service,
    7789            receiver);
    7890}
    7991
     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 */
    8097int ip_connect_module(services_t service)
    8198{
     
    88105 * If the device uses ARP registers also the new ARP device.
    89106 *
    90  * @param[in] ip_phone  The IP module phone used for (semi)remote calls.
    91  * @param[in] device_id The new device identifier.
    92  * @param[in] netif     The underlying device network interface layer service.
    93  *
    94  * @return EOK on success.
    95  * @return ENOMEM if there is not enough memory left.
    96  * @return EINVAL if the device configuration is invalid.
    97  * @return ENOTSUP if the device uses IPv6.
    98  * @return ENOTSUP if the device uses DHCP.
    99  * @return Other error codes as defined for the net_get_device_conf_req()
    100  *         function.
    101  * @return Other error codes as defined for the arp_device_req() function.
    102  *
     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.
    103119 */
    104120int ip_device_req_remote(int ip_phone, device_id_t device_id,
    105121    services_t service)
    106122{
    107         return generic_device_req_remote(ip_phone, NET_IL_DEVICE, device_id, 0,
     123        return generic_device_req_remote(ip_phone, NET_IP_DEVICE, device_id, 0,
    108124            service);
    109125}
    110126
    111 /** Return the device identifier and the IP pseudo header based on the destination address.
    112  *
    113  * @param[in]  ip_phone    The IP module phone used for (semi)remote calls.
    114  * @param[in]  protocol    The transport protocol.
    115  * @param[in]  destination The destination address.
    116  * @param[in]  addrlen     The destination address length.
    117  * @param[out] device_id   The device identifier.
    118  * @param[out] header      The constructed IP pseudo header.
    119  * @param[out] headerlen   The IP pseudo header length.
     127/** Return the device identifier and the IP pseudo header based on the
     128 * destination address.
     129 *
     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.
    120137 *
    121138 */
     
    124141    device_id_t *device_id, void **header, size_t *headerlen)
    125142{
    126         if ((!destination) || (addrlen == 0))
     143        if (!destination || (addrlen == 0))
    127144                return EINVAL;
    128145       
    129         if ((!device_id) || (header) || (headerlen))
     146        if (!device_id || !header || !headerlen)
    130147                return EBADMEM;
    131148       
     
    134151        ipc_call_t answer;
    135152        aid_t message_id = async_send_1(ip_phone, NET_IP_GET_ROUTE,
    136             (ipcarg_t) protocol, &answer);
    137        
    138         if ((async_data_write_start(ip_phone, destination, addrlen) == EOK)
    139             && (async_data_read_start(ip_phone, headerlen, sizeof(*headerlen)) == EOK)
    140             && (*headerlen > 0)) {
     153            (sysarg_t) protocol, &answer);
     154       
     155        if ((async_data_write_start(ip_phone, destination, addrlen) == EOK) &&
     156            (async_data_read_start(ip_phone, headerlen,
     157            sizeof(*headerlen)) == EOK) && (*headerlen > 0)) {
    141158                *header = malloc(*headerlen);
    142159                if (*header) {
    143                         if (async_data_read_start(ip_phone, *header, *headerlen) != EOK)
     160                        if (async_data_read_start(ip_phone, *header,
     161                            *headerlen) != EOK)
    144162                                free(*header);
    145163                }
    146164        }
    147165       
    148         ipcarg_t result;
     166        sysarg_t result;
    149167        async_wait_for(message_id, &result);
    150168       
    151         if ((result != EOK) && (*header))
     169        if ((result != EOK) && *header)
    152170                free(*header);
    153171        else
    154                 *device_id = IPC_GET_DEVICE(&answer);
     172                *device_id = IPC_GET_DEVICE(answer);
    155173       
    156174        return (int) result;
     
    159177/** Return the device packet dimension for sending.
    160178 *
    161  * @param[in]  ip_phone         The IP module phone used for (semi)remote calls.
    162  * @param[in]  device_id        The device identifier.
     179 * @param[in] ip_phone  The IP module phone used for (semi)remote calls.
     180 * @param[in] device_id The device identifier.
    163181 * @param[out] packet_dimension The packet dimension.
    164  *
    165  * @return EOK on success.
    166  * @return ENOENT if there is no such device.
    167  * @return Other error codes as defined for the
    168  *         generic_packet_size_req_remote() function.
    169  *
     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.
    170186 */
    171187int ip_packet_size_req_remote(int ip_phone, device_id_t device_id,
    172     packet_dimension_ref packet_dimension)
    173 {
    174         return generic_packet_size_req_remote(ip_phone, NET_IL_PACKET_SPACE, device_id,
    175             packet_dimension);
     188    packet_dimension_t *packet_dimension)
     189{
     190        return generic_packet_size_req_remote(ip_phone, NET_IP_PACKET_SPACE,
     191            device_id, packet_dimension);
    176192}
    177193
    178194/** Notify the IP module about the received error notification packet.
    179195 *
    180  * @param[in] ip_phone  The IP module phone used for (semi)remote calls.
    181  * @param[in] device_id The device identifier.
    182  * @param[in] packet    The received packet or the received packet queue.
    183  * @param[in] target    The target internetwork module service to be
    184  *                      delivered to.
    185  * @param[in] error     The packet error reporting service. Prefixes the
    186  *                      received packet.
    187  *
    188  * @return EOK on success.
    189  *
     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.
    190204 */
    191205int ip_received_error_msg_remote(int ip_phone, device_id_t device_id,
    192     packet_t packet, services_t target, services_t error)
     206    packet_t *packet, services_t target, services_t error)
    193207{
    194208        return generic_received_msg_remote(ip_phone, NET_IP_RECEIVED_ERROR,
     
    200214 * The packets may get fragmented if needed.
    201215 *
    202  * @param[in] ip_phone  The IP module phone used for (semi)remote calls.
    203  * @param[in] device_id The device identifier.
    204  * @param[in] packet    The packet fragments as a packet queue. All the
    205  *                      packets have to have the same destination address.
    206  * @param[in] sender    The sending module service.
    207  * @param[in] error     The packet error reporting service. Prefixes the
    208  *                      received packet.
    209  *
    210  * @return EOK on success.
    211  * @return Other error codes as defined for the generic_send_msg() function.
    212  *
    213  */
    214 int ip_send_msg_remote(int ip_phone, device_id_t device_id, packet_t packet,
     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 */
     227int ip_send_msg_remote(int ip_phone, device_id_t device_id, packet_t *packet,
    215228    services_t sender, services_t error)
    216229{
    217         return generic_send_msg_remote(ip_phone, NET_IL_SEND, device_id,
     230        return generic_send_msg_remote(ip_phone, NET_IP_SEND, device_id,
    218231            packet_get_id(packet), sender, error);
    219232}
     
    223236 * This gateway is used if no other route is found.
    224237 *
    225  * @param[in] ip_phone  The IP module phone used for (semi)remote calls.
    226  * @param[in] device_id The device identifier.
    227  * @param[in] gateway   The default gateway.
    228  *
     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.
    229241 */
    230242int ip_set_gateway_req_remote(int ip_phone, device_id_t device_id,
     
    232244{
    233245        return (int) async_req_2_0(ip_phone, NET_IP_SET_GATEWAY,
    234             (ipcarg_t) device_id, (ipcarg_t) gateway.s_addr);
     246            (sysarg_t) device_id, (sysarg_t) gateway.s_addr);
    235247}
    236248
Note: See TracChangeset for help on using the changeset viewer.