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


Ignore:
Timestamp:
2011-07-20T15:26:21Z (14 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
efcebe1
Parents:
25bef0ff (diff), a701812 (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/srv/net/il/ip/ip.c

    r25bef0ff r6a44ee4  
    120120GENERIC_FIELD_IMPLEMENT(ip_routes, ip_route_t);
    121121
    122 static void ip_receiver(ipc_callid_t, ipc_call_t *);
    123 
    124 /** Releases the packet and returns the result.
    125  *
    126  * @param[in] packet    The packet queue to be released.
    127  * @param[in] result    The result to be returned.
    128  * @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 *
    129131 */
    130132static int ip_release_and_return(packet_t *packet, int result)
    131133{
    132         pq_release_remote(ip_globals.net_phone, packet_get_id(packet));
     134        pq_release_remote(ip_globals.net_sess, packet_get_id(packet));
    133135        return result;
    134136}
    135137
    136 /** Returns the ICMP phone.
    137  *
    138  * Searches the registered protocols.
    139  *
    140  * @return              The found ICMP phone.
    141  * @return              ENOENT if the ICMP is not registered.
    142  */
    143 static int ip_get_icmp_phone(void)
    144 {
    145         ip_proto_t *proto;
    146         int phone;
    147 
     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{
    148148        fibril_rwlock_read_lock(&ip_globals.protos_lock);
    149         proto = ip_protos_find(&ip_globals.protos, IPPROTO_ICMP);
    150         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;
    151151        fibril_rwlock_read_unlock(&ip_globals.protos_lock);
    152         return phone;
     152       
     153        return sess;
    153154}
    154155
     
    179180        next = pq_detach(packet);
    180181        if (next)
    181                 pq_release_remote(ip_globals.net_phone, packet_get_id(next));
     182                pq_release_remote(ip_globals.net_sess, packet_get_id(next));
    182183
    183184        if (!header) {
     
    218219}
    219220
    220 /** Prepares the ICMP notification packet.
    221  *
    222  * 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.
    223224 * All packets are released on error.
    224225 *
    225  * @param[in] error     The packet error service.
    226  * @param[in] packet    The packet or the packet queue to be reported as faulty.
    227  * @param[in] header    The first packet IP header. May be NULL.
    228  * @return              The found ICMP phone.
    229  * @return              EINVAL if the error parameter is set.
    230  * @return              EINVAL if the ICMP phone is not found.
    231  * @return              EINVAL if the ip_prepare_icmp() fails.
    232  */
    233 static int
    234 ip_prepare_icmp_and_get_phone(services_t error, packet_t *packet,
    235     ip_header_t *header)
    236 {
    237         int phone;
    238 
    239         phone = ip_get_icmp_phone();
    240         if (error || (phone < 0) || ip_prepare_icmp(packet, header))
    241                 return ip_release_and_return(packet, EINVAL);
    242         return phone;
    243 }
    244 
    245 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)
    246250{
    247251        fibril_rwlock_initialize(&ip_globals.lock);
     
    250254        fibril_rwlock_initialize(&ip_globals.netifs_lock);
    251255       
    252         ip_globals.net_phone = net_phone;
     256        ip_globals.net_sess = net_sess;
    253257        ip_globals.packet_counter = 0;
    254258        ip_globals.gateway.address.s_addr = 0;
     
    352356
    353357        /* Get configuration */
    354         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,
    355359            &configuration, count, &data);
    356360        if (rc != EOK)
     
    420424
    421425        /* Bind netif service which also initializes the device */
    422         ip_netif->phone = nil_bind_service(ip_netif->service,
     426        ip_netif->sess = nil_bind_service(ip_netif->service,
    423427            (sysarg_t) ip_netif->device_id, SERVICE_IP,
    424428            ip_receiver);
    425         if (ip_netif->phone < 0) {
     429        if (ip_netif->sess == NULL) {
    426430                printf("Failed to contact the nil service %d\n",
    427431                    ip_netif->service);
    428                 return ip_netif->phone;
     432                return ENOENT;
    429433        }
    430434
     
    435439                        address.length = sizeof(in_addr_t);
    436440                       
    437                         rc = arp_device_req(ip_netif->arp->phone,
     441                        rc = arp_device_req(ip_netif->arp->sess,
    438442                            ip_netif->device_id, SERVICE_IP, ip_netif->service,
    439443                            &address);
     
    446450
    447451        /* Get packet dimensions */
    448         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,
    449453            &ip_netif->packet_dimension);
    450454        if (rc != EOK)
     
    478482}
    479483
    480 static int ip_device_req_local(int il_phone, device_id_t device_id,
    481     services_t netif)
     484static int ip_device_req_local(device_id_t device_id, services_t netif)
    482485{
    483486        ip_netif_t *ip_netif;
     
    513516
    514517        /* Print the settings */
    515         printf("%s: Device registered (id: %d, phone: %d, ipv: %d, conf: %s)\n",
    516             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,
    517520            ip_netif->dhcp ? "dhcp" : "static");
    518521       
     
    929932
    930933        /* Create the last fragment */
    931         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,
    932935            suffix, ((addrlen > addr_len) ? addrlen : addr_len));
    933936        if (!new_packet)
     
    966969        /* Create middle fragments */
    967970        while (IP_TOTAL_LENGTH(header) > length) {
    968                 new_packet = packet_get_4_remote(ip_globals.net_phone, prefix,
     971                new_packet = packet_get_4_remote(ip_globals.net_sess, prefix,
    969972                    length, suffix,
    970973                    ((addrlen >= addr_len) ? addrlen : addr_len));
     
    991994}
    992995
    993 /** Checks the packet queue lengths and fragments the packets if needed.
     996/** Check the packet queue lengths and fragments the packets if needed.
    994997 *
    995998 * The ICMP_FRAG_NEEDED error notification may be sent if the packet needs to
    996999 * be fragmented and the fragmentation is not allowed.
    9971000 *
    998  * @param[in,out] packet The packet or the packet queue to be checked.
    999  * @param[in] prefix    The minimum prefix size.
    1000  * @param[in] content   The maximum content size.
    1001  * @param[in] suffix    The minimum suffix size.
    1002  * @param[in] addr_len  The minimum address length.
    1003  * @param[in] error     The error module service.
    1004  * @return              The packet or the packet queue of the allowed length.
    1005  * @return              NULL if there are no packets left.
    1006  */
    1007 static packet_t *
    1008 ip_split_packet(packet_t *packet, size_t prefix, size_t content, size_t suffix,
    1009     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)
    10101014{
    10111015        size_t length;
     
    10131017        packet_t *new_packet;
    10141018        int result;
    1015         int phone;
    1016 
     1019        async_sess_t *sess;
     1020       
    10171021        next = packet;
    10181022        /* Check all packets */
     
    10361040                        /* Fragmentation needed? */
    10371041                        if (result == EPERM) {
    1038                                 phone = ip_prepare_icmp_and_get_phone(
    1039                                     error, next, NULL);
    1040                                 if (phone >= 0) {
     1042                                sess = ip_prepare_icmp_and_get_session(error, next, NULL);
     1043                                if (sess) {
    10411044                                        /* Fragmentation necessary ICMP */
    1042                                         icmp_destination_unreachable_msg(phone,
     1045                                        icmp_destination_unreachable_msg(sess,
    10431046                                            ICMP_FRAG_NEEDED, content, next);
    10441047                                }
    10451048                        } else {
    1046                                 pq_release_remote(ip_globals.net_phone,
     1049                                pq_release_remote(ip_globals.net_sess,
    10471050                                    packet_get_id(next));
    10481051                        }
     
    10581061}
    10591062
    1060 /** Sends the packet or the packet queue via the specified route.
     1063/** Send the packet or the packet queue via the specified route.
    10611064 *
    10621065 * The ICMP_HOST_UNREACH error notification may be sent if route hardware
    10631066 * destination address is found.
    10641067 *
    1065  * @param[in,out] packet The packet to be sent.
    1066  * @param[in] netif     The target network interface.
    1067  * @param[in] route     The target route.
    1068  * @param[in] src       The source address.
    1069  * @param[in] dest      The destination address.
    1070  * @param[in] error     The error module service.
    1071  * @return              EOK on success.
    1072  * @return              Other error codes as defined for the arp_translate_req()
    1073  *                      function.
    1074  * @return              Other error codes as defined for the ip_prepare_packet()
    1075  *                      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 *
    10761079 */
    10771080static int ip_send_route(packet_t *packet, ip_netif_t *netif,
     
    10811084        measured_string_t *translation;
    10821085        uint8_t *data;
    1083         int phone;
     1086        async_sess_t *sess;
    10841087        int rc;
    10851088
     
    10901093                destination.length = sizeof(dest.s_addr);
    10911094
    1092                 rc = arp_translate_req(netif->arp->phone, netif->device_id,
     1095                rc = arp_translate_req(netif->arp->sess, netif->device_id,
    10931096                    SERVICE_IP, &destination, &translation, &data);
    10941097                if (rc != EOK) {
    1095                         pq_release_remote(ip_globals.net_phone,
     1098                        pq_release_remote(ip_globals.net_sess,
    10961099                            packet_get_id(packet));
    10971100                        return rc;
     
    11031106                                free(data);
    11041107                        }
    1105                         phone = ip_prepare_icmp_and_get_phone(error, packet,
     1108                        sess = ip_prepare_icmp_and_get_session(error, packet,
    11061109                            NULL);
    1107                         if (phone >= 0) {
     1110                        if (sess) {
    11081111                                /* Unreachable ICMP if no routing */
    1109                                 icmp_destination_unreachable_msg(phone,
     1112                                icmp_destination_unreachable_msg(sess,
    11101113                                    ICMP_HOST_UNREACH, 0, packet);
    11111114                        }
     
    11191122        rc = ip_prepare_packet(src, dest, packet, translation);
    11201123        if (rc != EOK) {
    1121                 pq_release_remote(ip_globals.net_phone, packet_get_id(packet));
     1124                pq_release_remote(ip_globals.net_sess, packet_get_id(packet));
    11221125        } else {
    11231126                packet = ip_split_packet(packet, netif->packet_dimension.prefix,
     
    11261129                    netif->packet_dimension.addr_len, error);
    11271130                if (packet) {
    1128                         nil_send_msg(netif->phone, netif->device_id, packet,
     1131                        nil_send_msg(netif->sess, netif->device_id, packet,
    11291132                            SERVICE_IP);
    11301133                }
     
    11391142}
    11401143
    1141 static int ip_send_msg_local(int il_phone, device_id_t device_id,
    1142     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)
    11431146{
    11441147        int addrlen;
     
    11491152        in_addr_t *dest;
    11501153        in_addr_t *src;
    1151         int phone;
     1154        async_sess_t *sess;
    11521155        int rc;
    11531156
     
    11941197        if (!netif || !route) {
    11951198                fibril_rwlock_read_unlock(&ip_globals.netifs_lock);
    1196                 phone = ip_prepare_icmp_and_get_phone(error, packet, NULL);
    1197                 if (phone >= 0) {
     1199                sess = ip_prepare_icmp_and_get_session(error, packet, NULL);
     1200                if (sess) {
    11981201                        /* Unreachable ICMP if no routing */
    1199                         icmp_destination_unreachable_msg(phone,
     1202                        icmp_destination_unreachable_msg(sess,
    12001203                            ICMP_NET_UNREACH, 0, packet);
    12011204                }
     
    12251228                if (!netif || !route) {
    12261229                        fibril_rwlock_read_unlock(&ip_globals.netifs_lock);
    1227                         phone = ip_prepare_icmp_and_get_phone(error, packet,
     1230                        sess = ip_prepare_icmp_and_get_session(error, packet,
    12281231                            NULL);
    1229                         if (phone >= 0) {
     1232                        if (sess) {
    12301233                                /* Unreachable ICMP if no routing */
    1231                                 icmp_destination_unreachable_msg(phone,
     1234                                icmp_destination_unreachable_msg(sess,
    12321235                                    ICMP_HOST_UNREACH, 0, packet);
    12331236                        }
     
    13131316{
    13141317        ip_proto_t *proto;
    1315         int phone;
     1318        async_sess_t *sess;
    13161319        services_t service;
    13171320        tl_received_msg_t received_msg;
     
    13661369        if (!proto) {
    13671370                fibril_rwlock_read_unlock(&ip_globals.protos_lock);
    1368                 phone = ip_prepare_icmp_and_get_phone(error, packet, header);
    1369                 if (phone >= 0) {
     1371                sess = ip_prepare_icmp_and_get_session(error, packet, header);
     1372                if (sess) {
    13701373                        /* Unreachable ICMP */
    1371                         icmp_destination_unreachable_msg(phone,
     1374                        icmp_destination_unreachable_msg(sess,
    13721375                            ICMP_PROT_UNREACH, 0, packet);
    13731376                }
     
    13811384                rc = received_msg(device_id, packet, service, error);
    13821385        } else {
    1383                 rc = tl_received_msg(proto->phone, device_id, packet,
     1386                rc = tl_received_msg(proto->sess, device_id, packet,
    13841387                    proto->service, error);
    13851388                fibril_rwlock_read_unlock(&ip_globals.protos_lock);
     
    14151418        in_addr_t dest;
    14161419        ip_route_t *route;
    1417         int phone;
     1420        async_sess_t *sess;
    14181421        struct sockaddr *addr;
    14191422        struct sockaddr_in addr_in;
     
    14281431        if ((header->header_checksum) &&
    14291432            (IP_HEADER_CHECKSUM(header) != IP_CHECKSUM_ZERO)) {
    1430                 phone = ip_prepare_icmp_and_get_phone(0, packet, header);
    1431                 if (phone >= 0) {
     1433                sess = ip_prepare_icmp_and_get_session(0, packet, header);
     1434                if (sess) {
    14321435                        /* Checksum error ICMP */
    1433                         icmp_parameter_problem_msg(phone, ICMP_PARAM_POINTER,
     1436                        icmp_parameter_problem_msg(sess, ICMP_PARAM_POINTER,
    14341437                            ((size_t) ((void *) &header->header_checksum)) -
    14351438                            ((size_t) ((void *) header)), packet);
     
    14391442
    14401443        if (header->ttl <= 1) {
    1441                 phone = ip_prepare_icmp_and_get_phone(0, packet, header);
    1442                 if (phone >= 0) {
     1444                sess = ip_prepare_icmp_and_get_session(0, packet, header);
     1445                if (sess) {
    14431446                        /* TTL exceeded ICMP */
    1444                         icmp_time_exceeded_msg(phone, ICMP_EXC_TTL, packet);
     1447                        icmp_time_exceeded_msg(sess, ICMP_EXC_TTL, packet);
    14451448                }
    14461449                return EINVAL;
     
    14701473        route = ip_find_route(dest);
    14711474        if (!route) {
    1472                 phone = ip_prepare_icmp_and_get_phone(0, packet, header);
    1473                 if (phone >= 0) {
     1475                sess = ip_prepare_icmp_and_get_session(0, packet, header);
     1476                if (sess) {
    14741477                        /* Unreachable ICMP */
    1475                         icmp_destination_unreachable_msg(phone,
     1478                        icmp_destination_unreachable_msg(sess,
    14761479                            ICMP_HOST_UNREACH, 0, packet);
    14771480                }
     
    14901493        }
    14911494
    1492         phone = ip_prepare_icmp_and_get_phone(0, packet, header);
    1493         if (phone >= 0) {
     1495        sess = ip_prepare_icmp_and_get_session(0, packet, header);
     1496        if (sess) {
    14941497                /* Unreachable ICMP if no routing */
    1495                 icmp_destination_unreachable_msg(phone, ICMP_HOST_UNREACH, 0,
     1498                icmp_destination_unreachable_msg(sess, ICMP_HOST_UNREACH, 0,
    14961499                    packet);
    14971500        }
     
    15001503}
    15011504
    1502 /** Returns the device packet dimensions for sending.
    1503  *
    1504  * @param[in] phone     The service module phone.
    1505  * @param[in] message   The service specific message.
    1506  * @param[in] device_id The device identifier.
    1507  * @param[out] addr_len The minimum reserved address length.
    1508  * @param[out] prefix   The minimum reserved prefix size.
    1509  * @param[out] content  The maximum content size.
    1510  * @param[out] suffix   The minimum reserved suffix size.
    1511  * @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 *
    15121515 */
    15131516static int ip_packet_size_message(device_id_t device_id, size_t *addr_len,
     
    15911594 * @param[in]     iid   Message identifier.
    15921595 * @param[in,out] icall Message parameters.
    1593  *
    1594  */
    1595 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)
    15961600{
    15971601        packet_t *packet;
     
    16071611               
    16081612                case NET_IL_RECEIVED:
    1609                         rc = packet_translate_remote(ip_globals.net_phone, &packet,
     1613                        rc = packet_translate_remote(ip_globals.net_sess, &packet,
    16101614                            IPC_GET_PACKET(*icall));
    16111615                        if (rc == EOK) {
     
    16341638}
    16351639
    1636 /** Registers the transport layer protocol.
     1640/** Register the transport layer protocol.
    16371641 *
    16381642 * The traffic of this protocol will be supplied using either the receive
    16391643 * function or IPC message.
    16401644 *
    1641  * @param[in] protocol  The transport layer module protocol.
    1642  * @param[in] service   The transport layer module service.
    1643  * @param[in] phone     The transport layer module phone.
    1644  * @param[in] received_msg The receiving function.
    1645  * @return              EOK on success.
    1646  * @return              EINVAL if the protocol parameter and/or the service
    1647  *                      parameter is zero.
    1648  * @return              EINVAL if the phone parameter is not a positive number
    1649  *                      and the tl_receive_msg is NULL.
    1650  * @return              ENOMEM if there is not enough memory left.
    1651  */
    1652 static int
    1653 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,
    16541659    tl_received_msg_t received_msg)
    16551660{
     
    16571662        int index;
    16581663
    1659         if (!protocol || !service || ((phone < 0) && !received_msg))
     1664        if ((!protocol) || (!service) || ((!sess) && (!received_msg)))
    16601665                return EINVAL;
    1661 
     1666       
    16621667        proto = (ip_proto_t *) malloc(sizeof(ip_protos_t));
    16631668        if (!proto)
     
    16661671        proto->protocol = protocol;
    16671672        proto->service = service;
    1668         proto->phone = phone;
     1673        proto->sess = sess;
    16691674        proto->received_msg = received_msg;
    16701675
     
    16781683        fibril_rwlock_write_unlock(&ip_globals.protos_lock);
    16791684
    1680         printf("%s: Protocol registered (protocol: %d, phone: %d)\n",
    1681             NAME, proto->protocol, proto->phone);
     1685        printf("%s: Protocol registered (protocol: %d)\n",
     1686            NAME, proto->protocol);
    16821687
    16831688        return EOK;
    16841689}
    16851690
    1686 
    1687 static int
    1688 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,
    16891692    in_addr_t netmask, in_addr_t gateway)
    16901693{
     
    17201723}
    17211724
    1722 static int
    1723 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)
    17241726{
    17251727        ip_netif_t *netif;
     
    17451747/** Notify the IP module about the received error notification packet.
    17461748 *
    1747  * @param[in] ip_phone  The IP module phone used for (semi)remote calls.
    1748  * @param[in] device_id The device identifier.
    1749  * @param[in] packet    The received packet or the received packet queue.
    1750  * @param[in] target    The target internetwork module service to be
    1751  *                      delivered to.
    1752  * @param[in] error     The packet error reporting service. Prefixes the
    1753  *                      received packet.
    1754  * @return              EOK on success.
    1755  *
    1756  */
    1757 static int
    1758 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,
    17591760    packet_t *packet, services_t target, services_t error)
    17601761{
     
    18011802                        address.value = (uint8_t *) &header->destination_address;
    18021803                        address.length = sizeof(header->destination_address);
    1803                         arp_clear_address_req(netif->arp->phone,
     1804                        arp_clear_address_req(netif->arp->sess,
    18041805                            netif->device_id, SERVICE_IP, &address);
    18051806                }
     
    18151816}
    18161817
    1817 static int
    1818 ip_get_route_req_local(int ip_phone, ip_protocol_t protocol,
     1818static int ip_get_route_req_local(ip_protocol_t protocol,
    18191819    const struct sockaddr *destination, socklen_t addrlen,
    18201820    device_id_t *device_id, void **header, size_t *headerlen)
     
    19131913       
    19141914        *answer_count = 0;
     1915       
     1916        if (!IPC_GET_IMETHOD(*call))
     1917                return EOK;
     1918       
     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       
    19151925        switch (IPC_GET_IMETHOD(*call)) {
    1916         case IPC_M_PHONE_HUNGUP:
    1917                 return EOK;
    1918        
    1919         case IPC_M_CONNECT_TO_ME:
    1920                 return ip_register(IL_GET_PROTO(*call), IL_GET_SERVICE(*call),
    1921                     IPC_GET_PHONE(*call), NULL);
    1922        
    19231926        case NET_IP_DEVICE:
    1924                 return ip_device_req_local(0, IPC_GET_DEVICE(*call),
     1927                return ip_device_req_local(IPC_GET_DEVICE(*call),
    19251928                    IPC_GET_SERVICE(*call));
    19261929       
    19271930        case NET_IP_RECEIVED_ERROR:
    1928                 rc = packet_translate_remote(ip_globals.net_phone, &packet,
     1931                rc = packet_translate_remote(ip_globals.net_sess, &packet,
    19291932                    IPC_GET_PACKET(*call));
    19301933                if (rc != EOK)
    19311934                        return rc;
    1932                 return ip_received_error_msg_local(0, IPC_GET_DEVICE(*call),
     1935                return ip_received_error_msg_local(IPC_GET_DEVICE(*call),
    19331936                    packet, IPC_GET_TARGET(*call), IPC_GET_ERROR(*call));
    19341937       
    19351938        case NET_IP_ADD_ROUTE:
    1936                 return ip_add_route_req_local(0, IPC_GET_DEVICE(*call),
     1939                return ip_add_route_req_local(IPC_GET_DEVICE(*call),
    19371940                    IP_GET_ADDRESS(*call), IP_GET_NETMASK(*call),
    19381941                    IP_GET_GATEWAY(*call));
    19391942
    19401943        case NET_IP_SET_GATEWAY:
    1941                 return ip_set_gateway_req_local(0, IPC_GET_DEVICE(*call),
     1944                return ip_set_gateway_req_local(IPC_GET_DEVICE(*call),
    19421945                    IP_GET_GATEWAY(*call));
    19431946
     
    19481951                        return rc;
    19491952               
    1950                 rc = ip_get_route_req_local(0, IP_GET_PROTOCOL(*call), addr,
     1953                rc = ip_get_route_req_local(IP_GET_PROTOCOL(*call), addr,
    19511954                    (socklen_t) addrlen, &device_id, &header, &headerlen);
    19521955                if (rc != EOK)
     
    19791982       
    19801983        case NET_IP_SEND:
    1981                 rc = packet_translate_remote(ip_globals.net_phone, &packet,
     1984                rc = packet_translate_remote(ip_globals.net_sess, &packet,
    19821985                    IPC_GET_PACKET(*call));
    19831986                if (rc != EOK)
    19841987                        return rc;
    19851988               
    1986                 return ip_send_msg_local(0, IPC_GET_DEVICE(*call), packet, 0,
     1989                return ip_send_msg_local(IPC_GET_DEVICE(*call), packet, 0,
    19871990                    IPC_GET_ERROR(*call));
    19881991        }
Note: See TracChangeset for help on using the changeset viewer.