Changeset 14f1db0 in mainline for uspace/lib/net/il/ip_remote.c


Ignore:
Timestamp:
2010-04-09T12:54:57Z (14 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
a1caa3c2
Parents:
24ab58b3
Message:

networking overhaul:

  • separation of conserns
  • removal of (almost all) overlaping symbols, libnetif is not needed anymore
  • again, it is possible to build the networking in multiple architecture configurations (however, currently only the bundling netif and nil layers is supported, more to come)
  • code style updates and fixes (still a huge amount of work to do)
File:
1 edited

Legend:

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

    r24ab58b3 r14f1db0  
    3333/** @file
    3434 *
    35  * IP interface implementation for standalone remote modules.
     35 * IP interface implementation for remote modules.
    3636 *
    3737 * @see ip_interface.h
     
    5050#include <il_messages.h>
    5151#include <ip_messages.h>
    52 
    53 int ip_add_route_req(int ip_phone, device_id_t device_id, in_addr_t address,
    54     in_addr_t netmask, in_addr_t gateway)
     52#include <ip_remote.h>
     53
     54/** Add a route to the device routing table.
     55 *
     56 * The target network is routed using this device.
     57 *
     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 *
     64 */
     65int ip_add_route_req_remote(int ip_phone, device_id_t device_id,
     66    in_addr_t address, in_addr_t netmask, in_addr_t gateway)
    5567{
    5668        return (int) async_req_4_0(ip_phone, NET_IP_ADD_ROUTE,
     
    7183}
    7284
    73 int ip_device_req(int ip_phone, device_id_t device_id, services_t service)
    74 {
    75         return generic_device_req(ip_phone, NET_IL_DEVICE, device_id, 0, service);
    76 }
    77 
    78 int ip_get_route_req(int ip_phone, ip_protocol_t protocol,
     85/** Register the new device.
     86 *
     87 * Register itself as the ip packet receiver.
     88 * If the device uses ARP registers also the new ARP device.
     89 *
     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 *
     103 */
     104int ip_device_req_remote(int ip_phone, device_id_t device_id,
     105    services_t service)
     106{
     107        return generic_device_req_remote(ip_phone, NET_IL_DEVICE, device_id, 0,
     108            service);
     109}
     110
     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.
     120 *
     121 */
     122int ip_get_route_req_remote(int ip_phone, ip_protocol_t protocol,
    79123    const struct sockaddr *destination, socklen_t addrlen,
    80     device_id_t *device_id, ip_pseudo_header_ref *header, size_t *headerlen)
     124    device_id_t *device_id, void **header, size_t *headerlen)
    81125{
    82126        if ((!destination) || (addrlen == 0))
     
    95139            && (async_data_read_start(ip_phone, headerlen, sizeof(*headerlen)) == EOK)
    96140            && (*headerlen > 0)) {
    97                 *header = (ip_pseudo_header_ref) malloc(*headerlen);
     141                *header = malloc(*headerlen);
    98142                if (*header) {
    99143                        if (async_data_read_start(ip_phone, *header, *headerlen) != EOK)
     
    113157}
    114158
    115 int ip_packet_size_req(int ip_phone, device_id_t device_id,
     159/** Return the device packet dimension for sending.
     160 *
     161 * @param[in]  ip_phone         The IP module phone used for (semi)remote calls.
     162 * @param[in]  device_id        The device identifier.
     163 * @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 *
     170 */
     171int ip_packet_size_req_remote(int ip_phone, device_id_t device_id,
    116172    packet_dimension_ref packet_dimension)
    117173{
    118         return generic_packet_size_req(ip_phone, NET_IL_PACKET_SPACE, device_id,
     174        return generic_packet_size_req_remote(ip_phone, NET_IL_PACKET_SPACE, device_id,
    119175            packet_dimension);
    120176}
    121177
    122 int ip_received_error_msg(int ip_phone, device_id_t device_id,
     178/** Notify the IP module about the received error notification packet.
     179 *
     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 *
     190 */
     191int ip_received_error_msg_remote(int ip_phone, device_id_t device_id,
    123192    packet_t packet, services_t target, services_t error)
    124193{
    125         return generic_received_msg(ip_phone, NET_IP_RECEIVED_ERROR, device_id,
    126             packet_get_id(packet), target, error);
    127 }
    128 
    129 int ip_send_msg(int ip_phone, device_id_t device_id, packet_t packet,
     194        return generic_received_msg_remote(ip_phone, NET_IP_RECEIVED_ERROR,
     195            device_id, packet_get_id(packet), target, error);
     196}
     197
     198/** Send the packet queue.
     199 *
     200 * The packets may get fragmented if needed.
     201 *
     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 */
     214int ip_send_msg_remote(int ip_phone, device_id_t device_id, packet_t packet,
    130215    services_t sender, services_t error)
    131216{
    132         return generic_send_msg(ip_phone, NET_IL_SEND, device_id,
     217        return generic_send_msg_remote(ip_phone, NET_IL_SEND, device_id,
    133218            packet_get_id(packet), sender, error);
    134219}
    135220
    136 int ip_set_gateway_req(int ip_phone, device_id_t device_id, in_addr_t gateway)
     221/** Set the default gateway.
     222 *
     223 * This gateway is used if no other route is found.
     224 *
     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 *
     229 */
     230int ip_set_gateway_req_remote(int ip_phone, device_id_t device_id,
     231    in_addr_t gateway)
    137232{
    138233        return (int) async_req_2_0(ip_phone, NET_IP_SET_GATEWAY,
Note: See TracChangeset for help on using the changeset viewer.