Ignore:
File:
1 edited

Legend:

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

    r14f1db0 r19f857a  
    4242#include <stdint.h>
    4343#include <str.h>
     44
    4445#include <ipc/ipc.h>
    4546#include <ipc/services.h>
     47
    4648#include <sys/time.h>
    4749#include <sys/types.h>
    4850
    49 #include <net_err.h>
    50 #include <net_messages.h>
    51 #include <net_modules.h>
    52 #include <packet/packet_client.h>
    53 #include <packet_remote.h>
    54 #include <net_byteorder.h>
    55 #include <net_checksum.h>
    56 #include <icmp_api.h>
    57 #include <icmp_client.h>
    58 #include <icmp_codes.h>
    59 #include <icmp_common.h>
    60 #include <icmp_interface.h>
    61 #include <il_interface.h>
    62 #include <inet.h>
    63 #include <ip_client.h>
    64 #include <ip_interface.h>
    65 #include <ip_protocols.h>
    66 #include <net_interface.h>
    67 #include <socket_codes.h>
    68 #include <socket_errno.h>
    69 #include <tl_messages.h>
    70 #include <tl_interface.h>
    71 #include <tl_local.h>
    72 #include <icmp_messages.h>
    73 #include <icmp_header.h>
     51#include "../../err.h"
     52#include "../../messages.h"
     53#include "../../modules.h"
     54
     55#include "../../structures/packet/packet_client.h"
     56
     57#include "../../include/byteorder.h"
     58#include "../../include/checksum.h"
     59#include "../../include/icmp_api.h"
     60#include "../../include/icmp_client.h"
     61#include "../../include/icmp_codes.h"
     62#include "../../include/icmp_common.h"
     63#include "../../include/icmp_interface.h"
     64#include "../../include/il_interface.h"
     65#include "../../include/inet.h"
     66#include "../../include/ip_client.h"
     67#include "../../include/ip_interface.h"
     68#include "../../include/ip_protocols.h"
     69#include "../../include/net_interface.h"
     70#include "../../include/socket_codes.h"
     71#include "../../include/socket_errno.h"
     72
     73#include "../../tl/tl_messages.h"
    7474
    7575#include "icmp.h"
     76#include "icmp_header.h"
     77#include "icmp_messages.h"
    7678#include "icmp_module.h"
    77 
    78 /** ICMP module name.
    79  */
    80 #define NAME    "ICMP protocol"
    8179
    8280/** Default ICMP error reporting.
     
    291289        // TODO do not ask all the time
    292290        ERROR_PROPAGATE(ip_packet_size_req(icmp_globals.ip_phone, -1, &icmp_globals.packet_dimension));
    293         packet = packet_get_4_remote(icmp_globals.net_phone, size, icmp_globals.packet_dimension.addr_len, ICMP_HEADER_SIZE + icmp_globals.packet_dimension.prefix, icmp_globals.packet_dimension.suffix);
     291        packet = packet_get_4(icmp_globals.net_phone, size, icmp_globals.packet_dimension.addr_len, ICMP_HEADER_SIZE + icmp_globals.packet_dimension.prefix, icmp_globals.packet_dimension.suffix);
    294292        if(! packet){
    295293                return ENOMEM;
     
    629627        // compute the reply key
    630628        reply_key = ICMP_GET_REPLY_KEY(header->un.echo.identifier, header->un.echo.sequence_number);
    631         pq_release_remote(icmp_globals.net_phone, packet_get_id(packet));
     629        pq_release(icmp_globals.net_phone, packet_get_id(packet));
    632630        // lock the globals
    633631        fibril_rwlock_write_lock(&icmp_globals.lock);
     
    644642}
    645643
    646 int icmp_message_standalone(ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count){
     644int icmp_message(ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count){
    647645        ERROR_DECLARE;
    648646
     
    652650        switch(IPC_GET_METHOD(*call)){
    653651                case NET_TL_RECEIVED:
    654                         if(! ERROR_OCCURRED(packet_translate_remote(icmp_globals.net_phone, &packet, IPC_GET_PACKET(call)))){
     652                        if(! ERROR_OCCURRED(packet_translate(icmp_globals.net_phone, &packet, IPC_GET_PACKET(call)))){
    655653                                ERROR_CODE = icmp_received_msg(IPC_GET_DEVICE(call), packet, SERVICE_ICMP, IPC_GET_ERROR(call));
    656654                        }
     
    762760        switch(IPC_GET_METHOD(*call)){
    763761                case NET_ICMP_DEST_UNREACH:
    764                         if(! ERROR_OCCURRED(packet_translate_remote(icmp_globals.net_phone, &packet, IPC_GET_PACKET(call)))){
     762                        if(! ERROR_OCCURRED(packet_translate(icmp_globals.net_phone, &packet, IPC_GET_PACKET(call)))){
    765763                                ERROR_CODE = icmp_destination_unreachable_msg(0, ICMP_GET_CODE(call), ICMP_GET_MTU(call), packet);
    766764                        }
    767765                        return ERROR_CODE;
    768766                case NET_ICMP_SOURCE_QUENCH:
    769                         if(! ERROR_OCCURRED(packet_translate_remote(icmp_globals.net_phone, &packet, IPC_GET_PACKET(call)))){
     767                        if(! ERROR_OCCURRED(packet_translate(icmp_globals.net_phone, &packet, IPC_GET_PACKET(call)))){
    770768                                ERROR_CODE = icmp_source_quench_msg(0, packet);
    771769                        }
    772770                        return ERROR_CODE;
    773771                case NET_ICMP_TIME_EXCEEDED:
    774                         if(! ERROR_OCCURRED(packet_translate_remote(icmp_globals.net_phone, &packet, IPC_GET_PACKET(call)))){
     772                        if(! ERROR_OCCURRED(packet_translate(icmp_globals.net_phone, &packet, IPC_GET_PACKET(call)))){
    775773                                ERROR_CODE = icmp_time_exceeded_msg(0, ICMP_GET_CODE(call), packet);
    776774                        }
    777775                        return ERROR_CODE;
    778776                case NET_ICMP_PARAMETERPROB:
    779                         if(! ERROR_OCCURRED(packet_translate_remote(icmp_globals.net_phone, &packet, IPC_GET_PACKET(call)))){
     777                        if(! ERROR_OCCURRED(packet_translate(icmp_globals.net_phone, &packet, IPC_GET_PACKET(call)))){
    780778                                ERROR_CODE = icmp_parameter_problem_msg(0, ICMP_GET_CODE(call), ICMP_GET_POINTER(call), packet);
    781779                        }
     
    787785
    788786int icmp_release_and_return(packet_t packet, int result){
    789         pq_release_remote(icmp_globals.net_phone, packet_get_id(packet));
     787        pq_release(icmp_globals.net_phone, packet_get_id(packet));
    790788        return result;
    791789}
     
    822820}
    823821
    824 /** Default thread for new connections.
    825  *
    826  *  @param[in] iid The initial message identifier.
    827  *  @param[in] icall The initial message call structure.
    828  *
    829  */
    830 static void tl_client_connection(ipc_callid_t iid, ipc_call_t * icall)
    831 {
    832         /*
    833          * Accept the connection
    834          *  - Answer the first IPC_M_CONNECT_ME_TO call.
    835          */
    836         ipc_answer_0(iid, EOK);
    837        
    838         while(true) {
    839                 ipc_call_t answer;
    840                 int answer_count;
    841                
    842                 /* Clear the answer structure */
    843                 refresh_answer(&answer, &answer_count);
    844                
    845                 /* Fetch the next message */
    846                 ipc_call_t call;
    847                 ipc_callid_t callid = async_get_call(&call);
    848                
    849                 /* Process the message */
    850                 int res = tl_module_message_standalone(callid, &call, &answer,
    851                     &answer_count);
    852                
    853                 /* End if said to either by the message or the processing result */
    854                 if ((IPC_GET_METHOD(call) == IPC_M_PHONE_HUNGUP) || (res == EHANGUP))
    855                         return;
    856                
    857                 /* Answer the message */
    858                 answer_call(callid, res, &answer, answer_count);
    859         }
    860 }
    861 
    862 /** Starts the module.
    863  *
    864  *  @param argc The count of the command line arguments. Ignored parameter.
    865  *  @param argv The command line parameters. Ignored parameter.
    866  *
    867  *  @returns EOK on success.
    868  *  @returns Other error codes as defined for each specific module start function.
    869  *
    870  */
    871 int main(int argc, char *argv[])
    872 {
    873         ERROR_DECLARE;
    874        
    875         /* Start the module */
    876         if (ERROR_OCCURRED(tl_module_start_standalone(tl_client_connection)))
    877                 return ERROR_CODE;
    878        
    879         return EOK;
    880 }
    881 
    882822/** @}
    883823 */
Note: See TracChangeset for help on using the changeset viewer.