Changeset c028b22 in mainline for uspace/srv/net/tl/icmp/icmp.c


Ignore:
Timestamp:
2011-07-08T17:01:01Z (13 years ago)
Author:
Martin Sucha <sucha14@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
cc1a727
Parents:
4e36219 (diff), 026793d (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/tl/icmp/icmp.c

    r4e36219 rc028b22  
    118118
    119119/** Global data */
    120 static int phone_net = -1;
    121 static int phone_ip = -1;
     120static async_sess_t *net_sess = NULL;
     121static async_sess_t *ip_sess = NULL;
    122122static bool error_reporting = true;
    123123static bool echo_replying = true;
     
    173173static void icmp_release(packet_t *packet)
    174174{
    175         pq_release_remote(phone_net, packet_get_id(packet));
     175        pq_release_remote(net_sess, packet_get_id(packet));
    176176}
    177177
     
    225225        }
    226226       
    227         return ip_send_msg(phone_ip, -1, packet, SERVICE_ICMP, error);
     227        return ip_send_msg(ip_sess, -1, packet, SERVICE_ICMP, error);
    228228}
    229229
     
    297297        size_t length = (size_t) addrlen;
    298298       
    299         packet_t *packet = packet_get_4_remote(phone_net, size,
     299        packet_t *packet = packet_get_4_remote(net_sess, size,
    300300            icmp_dimension.addr_len, ICMP_HEADER_SIZE + icmp_dimension.prefix,
    301301            icmp_dimension.suffix);
     
    595595        case ICMP_SKIP:
    596596        case ICMP_PHOTURIS:
    597                 ip_received_error_msg(phone_ip, -1, packet,
     597                ip_received_error_msg(ip_sess, -1, packet,
    598598                    SERVICE_IP, SERVICE_ICMP);
    599599                return EOK;
     
    608608 * @param[in]     iid   Message identifier.
    609609 * @param[in,out] icall Message parameters.
    610  *
    611  */
    612 static void icmp_receiver(ipc_callid_t iid, ipc_call_t *icall)
    613 {
    614         bool loop = true;
     610 * @param[in]     arg   Local argument.
     611 *
     612 */
     613static void icmp_receiver(ipc_callid_t iid, ipc_call_t *icall, void *arg)
     614{
    615615        packet_t *packet;
    616616        int rc;
    617617       
    618         while (loop) {
     618        while (true) {
     619                if (!IPC_GET_IMETHOD(*icall))
     620                        break;
     621               
    619622                switch (IPC_GET_IMETHOD(*icall)) {
    620623                case NET_TL_RECEIVED:
    621                         rc = packet_translate_remote(phone_net, &packet,
     624                        rc = packet_translate_remote(net_sess, &packet,
    622625                            IPC_GET_PACKET(*icall));
    623626                        if (rc == EOK) {
     
    629632                        async_answer_0(iid, (sysarg_t) rc);
    630633                        break;
    631                 case IPC_M_PHONE_HUNGUP:
    632                         loop = false;
    633                         continue;
    634634                default:
    635635                        async_answer_0(iid, (sysarg_t) ENOTSUP);
     
    642642/** Initialize the ICMP module.
    643643 *
    644  * @param[in] net_phone Network module phone.
     644 * @param[in] sess Network module session.
    645645 *
    646646 * @return EOK on success.
     
    648648 *
    649649 */
    650 int tl_initialize(int net_phone)
     650int tl_initialize(async_sess_t *sess)
    651651{
    652652        measured_string_t names[] = {
     
    670670        atomic_set(&icmp_client, 0);
    671671       
    672         phone_net = net_phone;
    673         phone_ip = ip_bind_service(SERVICE_IP, IPPROTO_ICMP, SERVICE_ICMP,
     672        net_sess = sess;
     673        ip_sess = ip_bind_service(SERVICE_IP, IPPROTO_ICMP, SERVICE_ICMP,
    674674            icmp_receiver);
    675         if (phone_ip < 0)
    676                 return phone_ip;
    677        
    678         int rc = ip_packet_size_req(phone_ip, -1, &icmp_dimension);
     675        if (ip_sess == NULL)
     676                return ENOENT;
     677       
     678        int rc = ip_packet_size_req(ip_sess, -1, &icmp_dimension);
    679679        if (rc != EOK)
    680680                return rc;
     
    685685        /* Get configuration */
    686686        configuration = &names[0];
    687         rc = net_get_conf_req(phone_net, &configuration, count, &data);
     687        rc = net_get_conf_req(net_sess, &configuration, count, &data);
    688688        if (rc != EOK)
    689689                return rc;
     
    763763       
    764764        case NET_ICMP_DEST_UNREACH:
    765                 rc = packet_translate_remote(phone_net, &packet,
     765                rc = packet_translate_remote(net_sess, &packet,
    766766                    IPC_GET_PACKET(*call));
    767767                if (rc != EOK)
     
    772772       
    773773        case NET_ICMP_SOURCE_QUENCH:
    774                 rc = packet_translate_remote(phone_net, &packet,
     774                rc = packet_translate_remote(net_sess, &packet,
    775775                    IPC_GET_PACKET(*call));
    776776                if (rc != EOK)
     
    780780       
    781781        case NET_ICMP_TIME_EXCEEDED:
    782                 rc = packet_translate_remote(phone_net, &packet,
     782                rc = packet_translate_remote(net_sess, &packet,
    783783                    IPC_GET_PACKET(*call));
    784784                if (rc != EOK)
     
    788788       
    789789        case NET_ICMP_PARAMETERPROB:
    790                 rc = packet_translate_remote(phone_net, &packet,
     790                rc = packet_translate_remote(net_sess, &packet,
    791791                    IPC_GET_PACKET(*call));
    792792                if (rc != EOK)
Note: See TracChangeset for help on using the changeset viewer.