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