Changes in uspace/srv/net/tl/icmp/icmp.c [14f1db0:19f857a] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/net/tl/icmp/icmp.c
r14f1db0 r19f857a 42 42 #include <stdint.h> 43 43 #include <str.h> 44 44 45 #include <ipc/ipc.h> 45 46 #include <ipc/services.h> 47 46 48 #include <sys/time.h> 47 49 #include <sys/types.h> 48 50 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" 74 74 75 75 #include "icmp.h" 76 #include "icmp_header.h" 77 #include "icmp_messages.h" 76 78 #include "icmp_module.h" 77 78 /** ICMP module name.79 */80 #define NAME "ICMP protocol"81 79 82 80 /** Default ICMP error reporting. … … 291 289 // TODO do not ask all the time 292 290 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); 294 292 if(! packet){ 295 293 return ENOMEM; … … 629 627 // compute the reply key 630 628 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)); 632 630 // lock the globals 633 631 fibril_rwlock_write_lock(&icmp_globals.lock); … … 644 642 } 645 643 646 int icmp_message _standalone(ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count){644 int icmp_message(ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count){ 647 645 ERROR_DECLARE; 648 646 … … 652 650 switch(IPC_GET_METHOD(*call)){ 653 651 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)))){ 655 653 ERROR_CODE = icmp_received_msg(IPC_GET_DEVICE(call), packet, SERVICE_ICMP, IPC_GET_ERROR(call)); 656 654 } … … 762 760 switch(IPC_GET_METHOD(*call)){ 763 761 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)))){ 765 763 ERROR_CODE = icmp_destination_unreachable_msg(0, ICMP_GET_CODE(call), ICMP_GET_MTU(call), packet); 766 764 } 767 765 return ERROR_CODE; 768 766 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)))){ 770 768 ERROR_CODE = icmp_source_quench_msg(0, packet); 771 769 } 772 770 return ERROR_CODE; 773 771 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)))){ 775 773 ERROR_CODE = icmp_time_exceeded_msg(0, ICMP_GET_CODE(call), packet); 776 774 } 777 775 return ERROR_CODE; 778 776 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)))){ 780 778 ERROR_CODE = icmp_parameter_problem_msg(0, ICMP_GET_CODE(call), ICMP_GET_POINTER(call), packet); 781 779 } … … 787 785 788 786 int 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)); 790 788 return result; 791 789 } … … 822 820 } 823 821 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 connection834 * - 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 882 822 /** @} 883 823 */
Note:
See TracChangeset
for help on using the changeset viewer.