Changeset e4f8c77 in mainline for uspace/srv/net/il/ip/ip.c


Ignore:
Timestamp:
2011-07-13T22:39:18Z (13 years ago)
Author:
Jiří Zárevúcky <zarevucky.jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
e6910c8
Parents:
5974661 (diff), 8ecef91 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge libposix.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/net/il/ip/ip.c

    r5974661 re4f8c77  
    7777#include <il_skel.h>
    7878
    79 // FIXME: remove this header
    80 #include <kernel/ipc/ipc_methods.h>
    81 
    8279/** IP module name. */
    8380#define NAME                    "ip"
     
    123120GENERIC_FIELD_IMPLEMENT(ip_routes, ip_route_t);
    124121
    125 static void ip_receiver(ipc_callid_t, ipc_call_t *);
    126 
    127 /** Releases the packet and returns the result.
    128  *
    129  * @param[in] packet    The packet queue to be released.
    130  * @param[in] result    The result to be returned.
    131  * @return              The result parameter.
     122static void ip_receiver(ipc_callid_t, ipc_call_t *, void *);
     123
     124/** Release the packet and returns the result.
     125 *
     126 * @param[in] packet Packet queue to be released.
     127 * @param[in] result Result to be returned.
     128 *
     129 * @return Result parameter.
     130 *
    132131 */
    133132static int ip_release_and_return(packet_t *packet, int result)
    134133{
    135         pq_release_remote(ip_globals.net_phone, packet_get_id(packet));
     134        pq_release_remote(ip_globals.net_sess, packet_get_id(packet));
    136135        return result;
    137136}
    138137
    139 /** Returns the ICMP phone.
    140  *
    141  * Searches the registered protocols.
    142  *
    143  * @return              The found ICMP phone.
    144  * @return              ENOENT if the ICMP is not registered.
    145  */
    146 static int ip_get_icmp_phone(void)
    147 {
    148         ip_proto_t *proto;
    149         int phone;
    150 
     138/** Return the ICMP session.
     139 *
     140 * Search the registered protocols.
     141 *
     142 * @return Found ICMP session.
     143 * @return NULL if the ICMP is not registered.
     144 *
     145 */
     146static async_sess_t *ip_get_icmp_session(void)
     147{
    151148        fibril_rwlock_read_lock(&ip_globals.protos_lock);
    152         proto = ip_protos_find(&ip_globals.protos, IPPROTO_ICMP);
    153         phone = proto ? proto->phone : ENOENT;
     149        ip_proto_t *proto = ip_protos_find(&ip_globals.protos, IPPROTO_ICMP);
     150        async_sess_t *sess = proto ? proto->sess : NULL;
    154151        fibril_rwlock_read_unlock(&ip_globals.protos_lock);
    155         return phone;
     152       
     153        return sess;
    156154}
    157155
     
    182180        next = pq_detach(packet);
    183181        if (next)
    184                 pq_release_remote(ip_globals.net_phone, packet_get_id(next));
     182                pq_release_remote(ip_globals.net_sess, packet_get_id(next));
    185183
    186184        if (!header) {
     
    221219}
    222220
    223 /** Prepares the ICMP notification packet.
    224  *
    225  * Releases additional packets and keeps only the first one.
     221/** Prepare the ICMP notification packet.
     222 *
     223 * Release additional packets and keep only the first one.
    226224 * All packets are released on error.
    227225 *
    228  * @param[in] error     The packet error service.
    229  * @param[in] packet    The packet or the packet queue to be reported as faulty.
    230  * @param[in] header    The first packet IP header. May be NULL.
    231  * @return              The found ICMP phone.
    232  * @return              EINVAL if the error parameter is set.
    233  * @return              EINVAL if the ICMP phone is not found.
    234  * @return              EINVAL if the ip_prepare_icmp() fails.
    235  */
    236 static int
    237 ip_prepare_icmp_and_get_phone(services_t error, packet_t *packet,
    238     ip_header_t *header)
    239 {
    240         int phone;
    241 
    242         phone = ip_get_icmp_phone();
    243         if (error || (phone < 0) || ip_prepare_icmp(packet, header))
    244                 return ip_release_and_return(packet, EINVAL);
    245         return phone;
    246 }
    247 
    248 int il_initialize(int net_phone)
     226 * @param[in] error  Packet error service.
     227 * @param[in] packet Packet or the packet queue to be reported as faulty.
     228 * @param[in] header First packet IP header. May be NULL.
     229 *
     230 * @return Found ICMP session.
     231 * @return NULL if the error parameter is set.
     232 * @return NULL if the ICMP session is not found.
     233 * @return NULL if the ip_prepare_icmp() fails.
     234 *
     235 */
     236static async_sess_t *ip_prepare_icmp_and_get_session(services_t error,
     237    packet_t *packet, ip_header_t *header)
     238{
     239        async_sess_t *sess = ip_get_icmp_session();
     240       
     241        if ((error) || (!sess) || (ip_prepare_icmp(packet, header))) {
     242                pq_release_remote(ip_globals.net_sess, packet_get_id(packet));
     243                return NULL;
     244        }
     245       
     246        return sess;
     247}
     248
     249int il_initialize(async_sess_t *net_sess)
    249250{
    250251        fibril_rwlock_initialize(&ip_globals.lock);
     
    253254        fibril_rwlock_initialize(&ip_globals.netifs_lock);
    254255       
    255         ip_globals.net_phone = net_phone;
     256        ip_globals.net_sess = net_sess;
    256257        ip_globals.packet_counter = 0;
    257258        ip_globals.gateway.address.s_addr = 0;
     
    355356
    356357        /* Get configuration */
    357         rc = net_get_device_conf_req(ip_globals.net_phone, ip_netif->device_id,
     358        rc = net_get_device_conf_req(ip_globals.net_sess, ip_netif->device_id,
    358359            &configuration, count, &data);
    359360        if (rc != EOK)
     
    423424
    424425        /* Bind netif service which also initializes the device */
    425         ip_netif->phone = nil_bind_service(ip_netif->service,
     426        ip_netif->sess = nil_bind_service(ip_netif->service,
    426427            (sysarg_t) ip_netif->device_id, SERVICE_IP,
    427428            ip_receiver);
    428         if (ip_netif->phone < 0) {
     429        if (ip_netif->sess == NULL) {
    429430                printf("Failed to contact the nil service %d\n",
    430431                    ip_netif->service);
    431                 return ip_netif->phone;
     432                return ENOENT;
    432433        }
    433434
     
    438439                        address.length = sizeof(in_addr_t);
    439440                       
    440                         rc = arp_device_req(ip_netif->arp->phone,
     441                        rc = arp_device_req(ip_netif->arp->sess,
    441442                            ip_netif->device_id, SERVICE_IP, ip_netif->service,
    442443                            &address);
     
    449450
    450451        /* Get packet dimensions */
    451         rc = nil_packet_size_req(ip_netif->phone, ip_netif->device_id,
     452        rc = nil_packet_size_req(ip_netif->sess, ip_netif->device_id,
    452453            &ip_netif->packet_dimension);
    453454        if (rc != EOK)
     
    481482}
    482483
    483 static int ip_device_req_local(int il_phone, device_id_t device_id,
    484     services_t netif)
     484static int ip_device_req_local(device_id_t device_id, services_t netif)
    485485{
    486486        ip_netif_t *ip_netif;
     
    516516
    517517        /* Print the settings */
    518         printf("%s: Device registered (id: %d, phone: %d, ipv: %d, conf: %s)\n",
    519             NAME, ip_netif->device_id, ip_netif->phone, ip_netif->ipv,
     518        printf("%s: Device registered (id: %d, ipv: %d, conf: %s)\n",
     519            NAME, ip_netif->device_id, ip_netif->ipv,
    520520            ip_netif->dhcp ? "dhcp" : "static");
    521521       
     
    932932
    933933        /* Create the last fragment */
    934         new_packet = packet_get_4_remote(ip_globals.net_phone, prefix, length,
     934        new_packet = packet_get_4_remote(ip_globals.net_sess, prefix, length,
    935935            suffix, ((addrlen > addr_len) ? addrlen : addr_len));
    936936        if (!new_packet)
     
    969969        /* Create middle fragments */
    970970        while (IP_TOTAL_LENGTH(header) > length) {
    971                 new_packet = packet_get_4_remote(ip_globals.net_phone, prefix,
     971                new_packet = packet_get_4_remote(ip_globals.net_sess, prefix,
    972972                    length, suffix,
    973973                    ((addrlen >= addr_len) ? addrlen : addr_len));
     
    994994}
    995995
    996 /** Checks the packet queue lengths and fragments the packets if needed.
     996/** Check the packet queue lengths and fragments the packets if needed.
    997997 *
    998998 * The ICMP_FRAG_NEEDED error notification may be sent if the packet needs to
    999999 * be fragmented and the fragmentation is not allowed.
    10001000 *
    1001  * @param[in,out] packet The packet or the packet queue to be checked.
    1002  * @param[in] prefix    The minimum prefix size.
    1003  * @param[in] content   The maximum content size.
    1004  * @param[in] suffix    The minimum suffix size.
    1005  * @param[in] addr_len  The minimum address length.
    1006  * @param[in] error     The error module service.
    1007  * @return              The packet or the packet queue of the allowed length.
    1008  * @return              NULL if there are no packets left.
    1009  */
    1010 static packet_t *
    1011 ip_split_packet(packet_t *packet, size_t prefix, size_t content, size_t suffix,
    1012     socklen_t addr_len, services_t error)
     1001 * @param[in,out] packet   Packet or the packet queue to be checked.
     1002 * @param[in]     prefix   Minimum prefix size.
     1003 * @param[in]     content  Maximum content size.
     1004 * @param[in]     suffix   Minimum suffix size.
     1005 * @param[in]     addr_len Minimum address length.
     1006 * @param[in]     error    Error module service.
     1007 *
     1008 * @return The packet or the packet queue of the allowed length.
     1009 * @return NULL if there are no packets left.
     1010 *
     1011 */
     1012static packet_t *ip_split_packet(packet_t *packet, size_t prefix, size_t content,
     1013    size_t suffix, socklen_t addr_len, services_t error)
    10131014{
    10141015        size_t length;
     
    10161017        packet_t *new_packet;
    10171018        int result;
    1018         int phone;
    1019 
     1019        async_sess_t *sess;
     1020       
    10201021        next = packet;
    10211022        /* Check all packets */
     
    10391040                        /* Fragmentation needed? */
    10401041                        if (result == EPERM) {
    1041                                 phone = ip_prepare_icmp_and_get_phone(
    1042                                     error, next, NULL);
    1043                                 if (phone >= 0) {
     1042                                sess = ip_prepare_icmp_and_get_session(error, next, NULL);
     1043                                if (sess) {
    10441044                                        /* Fragmentation necessary ICMP */
    1045                                         icmp_destination_unreachable_msg(phone,
     1045                                        icmp_destination_unreachable_msg(sess,
    10461046                                            ICMP_FRAG_NEEDED, content, next);
    10471047                                }
    10481048                        } else {
    1049                                 pq_release_remote(ip_globals.net_phone,
     1049                                pq_release_remote(ip_globals.net_sess,
    10501050                                    packet_get_id(next));
    10511051                        }
     
    10611061}
    10621062
    1063 /** Sends the packet or the packet queue via the specified route.
     1063/** Send the packet or the packet queue via the specified route.
    10641064 *
    10651065 * The ICMP_HOST_UNREACH error notification may be sent if route hardware
    10661066 * destination address is found.
    10671067 *
    1068  * @param[in,out] packet The packet to be sent.
    1069  * @param[in] netif     The target network interface.
    1070  * @param[in] route     The target route.
    1071  * @param[in] src       The source address.
    1072  * @param[in] dest      The destination address.
    1073  * @param[in] error     The error module service.
    1074  * @return              EOK on success.
    1075  * @return              Other error codes as defined for the arp_translate_req()
    1076  *                      function.
    1077  * @return              Other error codes as defined for the ip_prepare_packet()
    1078  *                      function.
     1068 * @param[in,out] packet Packet to be sent.
     1069 * @param[in]     netif  Target network interface.
     1070 * @param[in]     route  Target route.
     1071 * @param[in]     src    Source address.
     1072 * @param[in]     dest   Destination address.
     1073 * @param[in]     error  Error module service.
     1074 *
     1075 * @return EOK on success.
     1076 * @return Other error codes as defined for arp_translate_req().
     1077 * @return Other error codes as defined for ip_prepare_packet().
     1078 *
    10791079 */
    10801080static int ip_send_route(packet_t *packet, ip_netif_t *netif,
     
    10841084        measured_string_t *translation;
    10851085        uint8_t *data;
    1086         int phone;
     1086        async_sess_t *sess;
    10871087        int rc;
    10881088
     
    10931093                destination.length = sizeof(dest.s_addr);
    10941094
    1095                 rc = arp_translate_req(netif->arp->phone, netif->device_id,
     1095                rc = arp_translate_req(netif->arp->sess, netif->device_id,
    10961096                    SERVICE_IP, &destination, &translation, &data);
    10971097                if (rc != EOK) {
    1098                         pq_release_remote(ip_globals.net_phone,
     1098                        pq_release_remote(ip_globals.net_sess,
    10991099                            packet_get_id(packet));
    11001100                        return rc;
     
    11061106                                free(data);
    11071107                        }
    1108                         phone = ip_prepare_icmp_and_get_phone(error, packet,
     1108                        sess = ip_prepare_icmp_and_get_session(error, packet,
    11091109                            NULL);
    1110                         if (phone >= 0) {
     1110                        if (sess) {
    11111111                                /* Unreachable ICMP if no routing */
    1112                                 icmp_destination_unreachable_msg(phone,
     1112                                icmp_destination_unreachable_msg(sess,
    11131113                                    ICMP_HOST_UNREACH, 0, packet);
    11141114                        }
     
    11221122        rc = ip_prepare_packet(src, dest, packet, translation);
    11231123        if (rc != EOK) {
    1124                 pq_release_remote(ip_globals.net_phone, packet_get_id(packet));
     1124                pq_release_remote(ip_globals.net_sess, packet_get_id(packet));
    11251125        } else {
    11261126                packet = ip_split_packet(packet, netif->packet_dimension.prefix,
     
    11291129                    netif->packet_dimension.addr_len, error);
    11301130                if (packet) {
    1131                         nil_send_msg(netif->phone, netif->device_id, packet,
     1131                        nil_send_msg(netif->sess, netif->device_id, packet,
    11321132                            SERVICE_IP);
    11331133                }
     
    11421142}
    11431143
    1144 static int ip_send_msg_local(int il_phone, device_id_t device_id,
    1145     packet_t *packet, services_t sender, services_t error)
     1144static int ip_send_msg_local(device_id_t device_id, packet_t *packet,
     1145    services_t sender, services_t error)
    11461146{
    11471147        int addrlen;
     
    11521152        in_addr_t *dest;
    11531153        in_addr_t *src;
    1154         int phone;
     1154        async_sess_t *sess;
    11551155        int rc;
    11561156
     
    11971197        if (!netif || !route) {
    11981198                fibril_rwlock_read_unlock(&ip_globals.netifs_lock);
    1199                 phone = ip_prepare_icmp_and_get_phone(error, packet, NULL);
    1200                 if (phone >= 0) {
     1199                sess = ip_prepare_icmp_and_get_session(error, packet, NULL);
     1200                if (sess) {
    12011201                        /* Unreachable ICMP if no routing */
    1202                         icmp_destination_unreachable_msg(phone,
     1202                        icmp_destination_unreachable_msg(sess,
    12031203                            ICMP_NET_UNREACH, 0, packet);
    12041204                }
     
    12281228                if (!netif || !route) {
    12291229                        fibril_rwlock_read_unlock(&ip_globals.netifs_lock);
    1230                         phone = ip_prepare_icmp_and_get_phone(error, packet,
     1230                        sess = ip_prepare_icmp_and_get_session(error, packet,
    12311231                            NULL);
    1232                         if (phone >= 0) {
     1232                        if (sess) {
    12331233                                /* Unreachable ICMP if no routing */
    1234                                 icmp_destination_unreachable_msg(phone,
     1234                                icmp_destination_unreachable_msg(sess,
    12351235                                    ICMP_HOST_UNREACH, 0, packet);
    12361236                        }
     
    13161316{
    13171317        ip_proto_t *proto;
    1318         int phone;
     1318        async_sess_t *sess;
    13191319        services_t service;
    13201320        tl_received_msg_t received_msg;
     
    13691369        if (!proto) {
    13701370                fibril_rwlock_read_unlock(&ip_globals.protos_lock);
    1371                 phone = ip_prepare_icmp_and_get_phone(error, packet, header);
    1372                 if (phone >= 0) {
     1371                sess = ip_prepare_icmp_and_get_session(error, packet, header);
     1372                if (sess) {
    13731373                        /* Unreachable ICMP */
    1374                         icmp_destination_unreachable_msg(phone,
     1374                        icmp_destination_unreachable_msg(sess,
    13751375                            ICMP_PROT_UNREACH, 0, packet);
    13761376                }
     
    13841384                rc = received_msg(device_id, packet, service, error);
    13851385        } else {
    1386                 rc = tl_received_msg(proto->phone, device_id, packet,
     1386                rc = tl_received_msg(proto->sess, device_id, packet,
    13871387                    proto->service, error);
    13881388                fibril_rwlock_read_unlock(&ip_globals.protos_lock);
     
    14181418        in_addr_t dest;
    14191419        ip_route_t *route;
    1420         int phone;
     1420        async_sess_t *sess;
    14211421        struct sockaddr *addr;
    14221422        struct sockaddr_in addr_in;
     
    14311431        if ((header->header_checksum) &&
    14321432            (IP_HEADER_CHECKSUM(header) != IP_CHECKSUM_ZERO)) {
    1433                 phone = ip_prepare_icmp_and_get_phone(0, packet, header);
    1434                 if (phone >= 0) {
     1433                sess = ip_prepare_icmp_and_get_session(0, packet, header);
     1434                if (sess) {
    14351435                        /* Checksum error ICMP */
    1436                         icmp_parameter_problem_msg(phone, ICMP_PARAM_POINTER,
     1436                        icmp_parameter_problem_msg(sess, ICMP_PARAM_POINTER,
    14371437                            ((size_t) ((void *) &header->header_checksum)) -
    14381438                            ((size_t) ((void *) header)), packet);
     
    14421442
    14431443        if (header->ttl <= 1) {
    1444                 phone = ip_prepare_icmp_and_get_phone(0, packet, header);
    1445                 if (phone >= 0) {
     1444                sess = ip_prepare_icmp_and_get_session(0, packet, header);
     1445                if (sess) {
    14461446                        /* TTL exceeded ICMP */
    1447                         icmp_time_exceeded_msg(phone, ICMP_EXC_TTL, packet);
     1447                        icmp_time_exceeded_msg(sess, ICMP_EXC_TTL, packet);
    14481448                }
    14491449                return EINVAL;
     
    14731473        route = ip_find_route(dest);
    14741474        if (!route) {
    1475                 phone = ip_prepare_icmp_and_get_phone(0, packet, header);
    1476                 if (phone >= 0) {
     1475                sess = ip_prepare_icmp_and_get_session(0, packet, header);
     1476                if (sess) {
    14771477                        /* Unreachable ICMP */
    1478                         icmp_destination_unreachable_msg(phone,
     1478                        icmp_destination_unreachable_msg(sess,
    14791479                            ICMP_HOST_UNREACH, 0, packet);
    14801480                }
     
    14931493        }
    14941494
    1495         phone = ip_prepare_icmp_and_get_phone(0, packet, header);
    1496         if (phone >= 0) {
     1495        sess = ip_prepare_icmp_and_get_session(0, packet, header);
     1496        if (sess) {
    14971497                /* Unreachable ICMP if no routing */
    1498                 icmp_destination_unreachable_msg(phone, ICMP_HOST_UNREACH, 0,
     1498                icmp_destination_unreachable_msg(sess, ICMP_HOST_UNREACH, 0,
    14991499                    packet);
    15001500        }
     
    15031503}
    15041504
    1505 /** Returns the device packet dimensions for sending.
    1506  *
    1507  * @param[in] phone     The service module phone.
    1508  * @param[in] message   The service specific message.
    1509  * @param[in] device_id The device identifier.
    1510  * @param[out] addr_len The minimum reserved address length.
    1511  * @param[out] prefix   The minimum reserved prefix size.
    1512  * @param[out] content  The maximum content size.
    1513  * @param[out] suffix   The minimum reserved suffix size.
    1514  * @return              EOK on success.
     1505/** Return the device packet dimensions for sending.
     1506 *
     1507 * @param[in]  device_id Device identifier.
     1508 * @param[out] addr_len  Minimum reserved address length.
     1509 * @param[out] prefix    Minimum reserved prefix size.
     1510 * @param[out] content   Maximum content size.
     1511 * @param[out] suffix    Minimum reserved suffix size.
     1512 *
     1513 * @return EOK on success.
     1514 *
    15151515 */
    15161516static int ip_packet_size_message(device_id_t device_id, size_t *addr_len,
     
    15941594 * @param[in]     iid   Message identifier.
    15951595 * @param[in,out] icall Message parameters.
    1596  *
    1597  */
    1598 static void ip_receiver(ipc_callid_t iid, ipc_call_t *icall)
     1596 * @param[in]     arg   Local argument.
     1597 *
     1598 */
     1599static void ip_receiver(ipc_callid_t iid, ipc_call_t *icall, void *arg)
    15991600{
    16001601        packet_t *packet;
     
    16101611               
    16111612                case NET_IL_RECEIVED:
    1612                         rc = packet_translate_remote(ip_globals.net_phone, &packet,
     1613                        rc = packet_translate_remote(ip_globals.net_sess, &packet,
    16131614                            IPC_GET_PACKET(*icall));
    16141615                        if (rc == EOK) {
     
    16371638}
    16381639
    1639 /** Registers the transport layer protocol.
     1640/** Register the transport layer protocol.
    16401641 *
    16411642 * The traffic of this protocol will be supplied using either the receive
    16421643 * function or IPC message.
    16431644 *
    1644  * @param[in] protocol  The transport layer module protocol.
    1645  * @param[in] service   The transport layer module service.
    1646  * @param[in] phone     The transport layer module phone.
    1647  * @param[in] received_msg The receiving function.
    1648  * @return              EOK on success.
    1649  * @return              EINVAL if the protocol parameter and/or the service
    1650  *                      parameter is zero.
    1651  * @return              EINVAL if the phone parameter is not a positive number
    1652  *                      and the tl_receive_msg is NULL.
    1653  * @return              ENOMEM if there is not enough memory left.
    1654  */
    1655 static int
    1656 ip_register(int protocol, services_t service, int phone,
     1645 * @param[in] protocol     Transport layer module protocol.
     1646 * @param[in] service      Transport layer module service.
     1647 * @param[in] sess         Transport layer module session.
     1648 * @param[in] received_msg Receiving function.
     1649 *
     1650 * @return EOK on success.
     1651 * @return EINVAL if the protocol parameter and/or the service
     1652 *         parameter is zero.
     1653 * @return EINVAL if the phone parameter is not a positive number
     1654 *         and the tl_receive_msg is NULL.
     1655 * @return ENOMEM if there is not enough memory left.
     1656 *
     1657 */
     1658static int ip_register(int protocol, services_t service, async_sess_t *sess,
    16571659    tl_received_msg_t received_msg)
    16581660{
     
    16601662        int index;
    16611663
    1662         if (!protocol || !service || ((phone < 0) && !received_msg))
     1664        if ((!protocol) || (!service) || ((!sess) && (!received_msg)))
    16631665                return EINVAL;
    1664 
     1666       
    16651667        proto = (ip_proto_t *) malloc(sizeof(ip_protos_t));
    16661668        if (!proto)
     
    16691671        proto->protocol = protocol;
    16701672        proto->service = service;
    1671         proto->phone = phone;
     1673        proto->sess = sess;
    16721674        proto->received_msg = received_msg;
    16731675
     
    16811683        fibril_rwlock_write_unlock(&ip_globals.protos_lock);
    16821684
    1683         printf("%s: Protocol registered (protocol: %d, phone: %d)\n",
    1684             NAME, proto->protocol, proto->phone);
     1685        printf("%s: Protocol registered (protocol: %d)\n",
     1686            NAME, proto->protocol);
    16851687
    16861688        return EOK;
    16871689}
    16881690
    1689 
    1690 static int
    1691 ip_add_route_req_local(int ip_phone, device_id_t device_id, in_addr_t address,
     1691static int ip_add_route_req_local(device_id_t device_id, in_addr_t address,
    16921692    in_addr_t netmask, in_addr_t gateway)
    16931693{
     
    17231723}
    17241724
    1725 static int
    1726 ip_set_gateway_req_local(int ip_phone, device_id_t device_id, in_addr_t gateway)
     1725static int ip_set_gateway_req_local(device_id_t device_id, in_addr_t gateway)
    17271726{
    17281727        ip_netif_t *netif;
     
    17481747/** Notify the IP module about the received error notification packet.
    17491748 *
    1750  * @param[in] ip_phone  The IP module phone used for (semi)remote calls.
    1751  * @param[in] device_id The device identifier.
    1752  * @param[in] packet    The received packet or the received packet queue.
    1753  * @param[in] target    The target internetwork module service to be
    1754  *                      delivered to.
    1755  * @param[in] error     The packet error reporting service. Prefixes the
    1756  *                      received packet.
    1757  * @return              EOK on success.
    1758  *
    1759  */
    1760 static int
    1761 ip_received_error_msg_local(int ip_phone, device_id_t device_id,
     1749 * @param[in] device_id Device identifier.
     1750 * @param[in] packet    Received packet or the received packet queue.
     1751 * @param[in] target    Target internetwork module service to be
     1752 *                      delivered to.
     1753 * @param[in] error     Packet error reporting service. Prefixes the
     1754 *                      received packet.
     1755 *
     1756 * @return EOK on success.
     1757 *
     1758 */
     1759static int ip_received_error_msg_local(device_id_t device_id,
    17621760    packet_t *packet, services_t target, services_t error)
    17631761{
     
    18041802                        address.value = (uint8_t *) &header->destination_address;
    18051803                        address.length = sizeof(header->destination_address);
    1806                         arp_clear_address_req(netif->arp->phone,
     1804                        arp_clear_address_req(netif->arp->sess,
    18071805                            netif->device_id, SERVICE_IP, &address);
    18081806                }
     
    18181816}
    18191817
    1820 static int
    1821 ip_get_route_req_local(int ip_phone, ip_protocol_t protocol,
     1818static int ip_get_route_req_local(ip_protocol_t protocol,
    18221819    const struct sockaddr *destination, socklen_t addrlen,
    18231820    device_id_t *device_id, void **header, size_t *headerlen)
     
    19201917                return EOK;
    19211918       
     1919        async_sess_t *callback =
     1920            async_callback_receive_start(EXCHANGE_SERIALIZE, call);
     1921        if (callback)
     1922                return ip_register(IL_GET_PROTO(*call), IL_GET_SERVICE(*call),
     1923                    callback, NULL);
     1924       
    19221925        switch (IPC_GET_IMETHOD(*call)) {
    1923         case IPC_M_CONNECT_TO_ME:
    1924                 return ip_register(IL_GET_PROTO(*call), IL_GET_SERVICE(*call),
    1925                     IPC_GET_PHONE(*call), NULL);
    1926        
    19271926        case NET_IP_DEVICE:
    1928                 return ip_device_req_local(0, IPC_GET_DEVICE(*call),
     1927                return ip_device_req_local(IPC_GET_DEVICE(*call),
    19291928                    IPC_GET_SERVICE(*call));
    19301929       
    19311930        case NET_IP_RECEIVED_ERROR:
    1932                 rc = packet_translate_remote(ip_globals.net_phone, &packet,
     1931                rc = packet_translate_remote(ip_globals.net_sess, &packet,
    19331932                    IPC_GET_PACKET(*call));
    19341933                if (rc != EOK)
    19351934                        return rc;
    1936                 return ip_received_error_msg_local(0, IPC_GET_DEVICE(*call),
     1935                return ip_received_error_msg_local(IPC_GET_DEVICE(*call),
    19371936                    packet, IPC_GET_TARGET(*call), IPC_GET_ERROR(*call));
    19381937       
    19391938        case NET_IP_ADD_ROUTE:
    1940                 return ip_add_route_req_local(0, IPC_GET_DEVICE(*call),
     1939                return ip_add_route_req_local(IPC_GET_DEVICE(*call),
    19411940                    IP_GET_ADDRESS(*call), IP_GET_NETMASK(*call),
    19421941                    IP_GET_GATEWAY(*call));
    19431942
    19441943        case NET_IP_SET_GATEWAY:
    1945                 return ip_set_gateway_req_local(0, IPC_GET_DEVICE(*call),
     1944                return ip_set_gateway_req_local(IPC_GET_DEVICE(*call),
    19461945                    IP_GET_GATEWAY(*call));
    19471946
     
    19521951                        return rc;
    19531952               
    1954                 rc = ip_get_route_req_local(0, IP_GET_PROTOCOL(*call), addr,
     1953                rc = ip_get_route_req_local(IP_GET_PROTOCOL(*call), addr,
    19551954                    (socklen_t) addrlen, &device_id, &header, &headerlen);
    19561955                if (rc != EOK)
     
    19831982       
    19841983        case NET_IP_SEND:
    1985                 rc = packet_translate_remote(ip_globals.net_phone, &packet,
     1984                rc = packet_translate_remote(ip_globals.net_sess, &packet,
    19861985                    IPC_GET_PACKET(*call));
    19871986                if (rc != EOK)
    19881987                        return rc;
    19891988               
    1990                 return ip_send_msg_local(0, IPC_GET_DEVICE(*call), packet, 0,
     1989                return ip_send_msg_local(IPC_GET_DEVICE(*call), packet, 0,
    19911990                    IPC_GET_ERROR(*call));
    19921991        }
Note: See TracChangeset for help on using the changeset viewer.