Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/net/tl/icmp/icmp.c

    r49bd793b rffa2c8ef  
    118118
    119119/** Global data */
    120 static async_sess_t *net_sess = NULL;
    121 static async_sess_t *ip_sess = NULL;
     120static int phone_net = -1;
     121static int phone_ip = -1;
    122122static bool error_reporting = true;
    123123static bool echo_replying = true;
     
    173173static void icmp_release(packet_t *packet)
    174174{
    175         pq_release_remote(net_sess, packet_get_id(packet));
     175        pq_release_remote(phone_net, packet_get_id(packet));
    176176}
    177177
     
    225225        }
    226226       
    227         return ip_send_msg(ip_sess, -1, packet, SERVICE_ICMP, error);
     227        return ip_send_msg(phone_ip, -1, packet, SERVICE_ICMP, error);
    228228}
    229229
     
    297297        size_t length = (size_t) addrlen;
    298298       
    299         packet_t *packet = packet_get_4_remote(net_sess, size,
     299        packet_t *packet = packet_get_4_remote(phone_net, 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(ip_sess, -1, packet,
     597                ip_received_error_msg(phone_ip, -1, packet,
    598598                    SERVICE_IP, SERVICE_ICMP);
    599599                return EOK;
     
    608608 * @param[in]     iid   Message identifier.
    609609 * @param[in,out] icall Message parameters.
    610  * @param[in]     arg   Local argument.
    611  *
    612  */
    613 static void icmp_receiver(ipc_callid_t iid, ipc_call_t *icall, void *arg)
    614 {
     610 *
     611 */
     612static void icmp_receiver(ipc_callid_t iid, ipc_call_t *icall)
     613{
     614        bool loop = true;
    615615        packet_t *packet;
    616616        int rc;
    617617       
    618         while (true) {
    619                 if (!IPC_GET_IMETHOD(*icall))
    620                         break;
    621                
     618        while (loop) {
    622619                switch (IPC_GET_IMETHOD(*icall)) {
    623620                case NET_TL_RECEIVED:
    624                         rc = packet_translate_remote(net_sess, &packet,
     621                        rc = packet_translate_remote(phone_net, &packet,
    625622                            IPC_GET_PACKET(*icall));
    626623                        if (rc == EOK) {
     
    632629                        async_answer_0(iid, (sysarg_t) rc);
    633630                        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] sess Network module session.
     644 * @param[in] net_phone Network module phone.
    645645 *
    646646 * @return EOK on success.
     
    648648 *
    649649 */
    650 int tl_initialize(async_sess_t *sess)
     650int tl_initialize(int net_phone)
    651651{
    652652        measured_string_t names[] = {
     
    670670        atomic_set(&icmp_client, 0);
    671671       
    672         net_sess = sess;
    673         ip_sess = ip_bind_service(SERVICE_IP, IPPROTO_ICMP, SERVICE_ICMP,
     672        phone_net = net_phone;
     673        phone_ip = ip_bind_service(SERVICE_IP, IPPROTO_ICMP, SERVICE_ICMP,
    674674            icmp_receiver);
    675         if (ip_sess == NULL)
    676                 return ENOENT;
    677        
    678         int rc = ip_packet_size_req(ip_sess, -1, &icmp_dimension);
     675        if (phone_ip < 0)
     676                return phone_ip;
     677       
     678        int rc = ip_packet_size_req(phone_ip, -1, &icmp_dimension);
    679679        if (rc != EOK)
    680680                return rc;
     
    685685        /* Get configuration */
    686686        configuration = &names[0];
    687         rc = net_get_conf_req(net_sess, &configuration, count, &data);
     687        rc = net_get_conf_req(phone_net, &configuration, count, &data);
    688688        if (rc != EOK)
    689689                return rc;
     
    753753                        return rc;
    754754               
    755                 rc = icmp_echo(icmp_id, icmp_seq, ICMP_GET_SIZE(*call),
     755                rc = icmp_echo(icmp_id, icmp_seq, ICMP_GET_SIZE(*call), 
    756756                    ICMP_GET_TIMEOUT(*call), ICMP_GET_TTL(*call),
    757757                    ICMP_GET_TOS(*call), ICMP_GET_DONT_FRAGMENT(*call),
     
    763763       
    764764        case NET_ICMP_DEST_UNREACH:
    765                 rc = packet_translate_remote(net_sess, &packet,
     765                rc = packet_translate_remote(phone_net, &packet,
    766766                    IPC_GET_PACKET(*call));
    767767                if (rc != EOK)
     
    772772       
    773773        case NET_ICMP_SOURCE_QUENCH:
    774                 rc = packet_translate_remote(net_sess, &packet,
     774                rc = packet_translate_remote(phone_net, &packet,
    775775                    IPC_GET_PACKET(*call));
    776776                if (rc != EOK)
     
    780780       
    781781        case NET_ICMP_TIME_EXCEEDED:
    782                 rc = packet_translate_remote(net_sess, &packet,
     782                rc = packet_translate_remote(phone_net, &packet,
    783783                    IPC_GET_PACKET(*call));
    784784                if (rc != EOK)
     
    788788       
    789789        case NET_ICMP_PARAMETERPROB:
    790                 rc = packet_translate_remote(net_sess, &packet,
     790                rc = packet_translate_remote(phone_net, &packet,
    791791                    IPC_GET_PACKET(*call));
    792792                if (rc != EOK)
Note: See TracChangeset for help on using the changeset viewer.