Rev 4707 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 4707 | Rev 4708 | ||
---|---|---|---|
1 | /* |
1 | /* |
2 | * Copyright (c) 2008 Lukas Mejdrech |
2 | * Copyright (c) 2008 Lukas Mejdrech |
3 | * All rights reserved. |
3 | * All rights reserved. |
4 | * |
4 | * |
5 | * Redistribution and use in source and binary forms, with or without |
5 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions |
6 | * modification, are permitted provided that the following conditions |
7 | * are met: |
7 | * are met: |
8 | * |
8 | * |
9 | * - Redistributions of source code must retain the above copyright |
9 | * - Redistributions of source code must retain the above copyright |
10 | * notice, this list of conditions and the following disclaimer. |
10 | * notice, this list of conditions and the following disclaimer. |
11 | * - Redistributions in binary form must reproduce the above copyright |
11 | * - Redistributions in binary form must reproduce the above copyright |
12 | * notice, this list of conditions and the following disclaimer in the |
12 | * notice, this list of conditions and the following disclaimer in the |
13 | * documentation and/or other materials provided with the distribution. |
13 | * documentation and/or other materials provided with the distribution. |
14 | * - The name of the author may not be used to endorse or promote products |
14 | * - The name of the author may not be used to endorse or promote products |
15 | * derived from this software without specific prior written permission. |
15 | * derived from this software without specific prior written permission. |
16 | * |
16 | * |
17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
18 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
18 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
19 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
19 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
20 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
20 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
21 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
21 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
22 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
22 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
23 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
23 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
24 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
24 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
26 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
27 | */ |
27 | */ |
28 | 28 | ||
29 | /** @addtogroup icmp |
29 | /** @addtogroup icmp |
30 | * @{ |
30 | * @{ |
31 | */ |
31 | */ |
32 | 32 | ||
33 | /** @file |
33 | /** @file |
34 | * ICMP module implementation. |
34 | * ICMP module implementation. |
35 | * @see icmp.h |
35 | * @see icmp.h |
36 | */ |
36 | */ |
37 | 37 | ||
38 | #include <async.h> |
38 | #include <async.h> |
39 | #include <fibril_sync.h> |
39 | #include <fibril_sync.h> |
40 | 40 | ||
41 | #include <ipc/ipc.h> |
41 | #include <ipc/ipc.h> |
42 | #include <ipc/services.h> |
42 | #include <ipc/services.h> |
43 | 43 | ||
44 | #include "../../err.h" |
44 | #include "../../err.h" |
45 | #include "../../messages.h" |
45 | #include "../../messages.h" |
46 | #include "../../modules.h" |
46 | #include "../../modules.h" |
47 | 47 | ||
48 | #include "../../structures/packet/packet_client.h" |
48 | #include "../../structures/packet/packet_client.h" |
49 | 49 | ||
50 | #include "../../include/crc.h" |
50 | #include "../../include/crc.h" |
51 | #include "../../include/icmp_codes.h" |
51 | #include "../../include/icmp_codes.h" |
52 | #include "../../include/icmp_client.h" |
52 | #include "../../include/icmp_client.h" |
53 | #include "../../include/icmp_interface.h" |
53 | #include "../../include/icmp_interface.h" |
54 | #include "../../include/ip_client.h" |
54 | #include "../../include/ip_client.h" |
55 | #include "../../include/ip_interface.h" |
55 | #include "../../include/ip_interface.h" |
56 | #include "../../include/il_interface.h" |
56 | #include "../../include/il_interface.h" |
57 | #include "../../include/ip_protocols.h" |
57 | #include "../../include/ip_protocols.h" |
58 | 58 | ||
59 | #include "../../tl/tl_messages.h" |
59 | #include "../../tl/tl_messages.h" |
60 | 60 | ||
61 | #include "icmp.h" |
61 | #include "icmp.h" |
62 | #include "icmp_header.h" |
62 | #include "icmp_header.h" |
63 | #include "icmp_messages.h" |
63 | #include "icmp_messages.h" |
64 | #include "icmp_module.h" |
64 | #include "icmp_module.h" |
65 | 65 | ||
66 | #define ICMP_KEEP_LENGTH 8 |
66 | #define ICMP_KEEP_LENGTH 8 |
67 | 67 | ||
68 | #define ICMP_HEADER_CHECKSUM( header ) compact_checksum(compute_checksum( 0, ( uint8_t * ) header, sizeof( icmp_header_t ))) |
68 | #define ICMP_HEADER_CHECKSUM( header ) compact_checksum(compute_checksum( 0, ( uint8_t * ) header, sizeof( icmp_header_t ))) |
69 | 69 | ||
70 | /** Processes the received ICMP packet. |
70 | /** Processes the received ICMP packet. |
71 | * Is used as an entry point from the underlying IP module. |
71 | * Is used as an entry point from the underlying IP module. |
72 | * Releases the packet on error. |
72 | * Releases the packet on error. |
73 | * @param device_id The device identifier. Ignored parameter. |
73 | * @param device_id The device identifier. Ignored parameter. |
74 | * @param packet The received packet. Input/output parameter. |
74 | * @param packet The received packet. Input/output parameter. |
75 | * @param receiver The target service. Ignored parameter. |
75 | * @param receiver The target service. Ignored parameter. |
76 | * @param error The packet error reporting service. Prefixes the received packet. Input parameter. |
76 | * @param error The packet error reporting service. Prefixes the received packet. Input parameter. |
77 | * @returns EOK on success. |
77 | * @returns EOK on success. |
78 | * @returns Other error codes as defined for the icmp_process_packet() function. |
78 | * @returns Other error codes as defined for the icmp_process_packet() function. |
79 | */ |
79 | */ |
80 | int icmp_received_msg( device_id_t device_id, packet_t packet, services_t receiver, services_t error ); |
80 | int icmp_received_msg( device_id_t device_id, packet_t packet, services_t receiver, services_t error ); |
81 | 81 | ||
82 | /** Processes the received ICMP packet. |
82 | /** Processes the received ICMP packet. |
83 | * Notifies the destination socket application. |
83 | * Notifies the destination socket application. |
84 | * @param packet The received packet. Input/output parameter. |
84 | * @param packet The received packet. Input/output parameter. |
85 | * @returns EOK on success. |
85 | * @returns EOK on success. |
86 | * @returns EINVAL if the packet is not valid. |
86 | * @returns EINVAL if the packet is not valid. |
87 | * @returns EINVAL if the stored packet address is not the an_addr_t. |
87 | * @returns EINVAL if the stored packet address is not the an_addr_t. |
88 | * @returns EINVAL if the packet does not contain any data. |
88 | * @returns EINVAL if the packet does not contain any data. |
89 | * @returns NO_DATA if the packet content is shorter than the user datagram header. |
89 | * @returns NO_DATA if the packet content is shorter than the user datagram header. |
90 | * @returns ENOMEM if there is not enough memory left. |
90 | * @returns ENOMEM if there is not enough memory left. |
91 | * @returns EADDRNOTAVAIL if the destination socket does not exist. |
91 | * @returns EADDRNOTAVAIL if the destination socket does not exist. |
92 | * @returns Other error codes as defined for the ip_client_process_packet() function. |
92 | * @returns Other error codes as defined for the ip_client_process_packet() function. |
93 | */ |
93 | */ |
94 | int icmp_process_packet( packet_t packet ); |
94 | int icmp_process_packet( packet_t packet ); |
95 | 95 | ||
96 | icmp_header_ref icmp_prepare_packet( packet_t packet ); |
96 | icmp_header_ref icmp_prepare_packet( packet_t packet ); |
97 | int icmp_send_packet( icmp_type_t type, icmp_code_t code, packet_t packet, icmp_header_ref header ); |
97 | int icmp_send_packet( icmp_type_t type, icmp_code_t code, packet_t packet, icmp_header_ref header ); |
98 | 98 | ||
99 | /** ICMP global data. |
99 | /** ICMP global data. |
100 | */ |
100 | */ |
101 | icmp_globals_t icmp_globals; |
101 | icmp_globals_t icmp_globals; |
102 | 102 | ||
103 | int icmp_echo_msg( int icmp_phone, icmp_param_t identifier, icmp_param_t sequence_number, const void * data, size_t length ){ |
103 | int icmp_echo_msg( int icmp_phone, icmp_param_t identifier, icmp_param_t sequence_number, const void * data, size_t length ){ |
104 | // TODO echo - with timeout |
104 | // TODO echo - with timeout |
105 | // waits for the reply up to the timeout |
105 | // waits for the reply up to the timeout |
106 | return ENOTSUP; |
106 | return ENOTSUP; |
107 | } |
107 | } |
108 | 108 | ||
109 | int icmp_destination_unreachable_msg( int icmp_phone, icmp_code_t code, icmp_param_t mtu, packet_t packet ){ |
109 | int icmp_destination_unreachable_msg( int icmp_phone, icmp_code_t code, icmp_param_t mtu, packet_t packet ){ |
110 | icmp_header_ref header; |
110 | icmp_header_ref header; |
111 | 111 | ||
112 | header = icmp_prepare_packet( packet ); |
112 | header = icmp_prepare_packet( packet ); |
113 | if( ! header ) return ENOMEM; |
113 | if( ! header ) return ENOMEM; |
114 | if( mtu ){ |
114 | if( mtu ){ |
115 | header->un.frag.mtu = mtu; |
115 | header->un.frag.mtu = mtu; |
116 | } |
116 | } |
117 | return icmp_send_packet( ICMP_DEST_UNREACH, code, packet, header ); |
117 | return icmp_send_packet( ICMP_DEST_UNREACH, code, packet, header ); |
118 | } |
118 | } |
119 | 119 | ||
120 | int icmp_source_quench_msg( int icmp_phone, packet_t packet ){ |
120 | int icmp_source_quench_msg( int icmp_phone, packet_t packet ){ |
121 | icmp_header_ref header; |
121 | icmp_header_ref header; |
122 | 122 | ||
123 | header = icmp_prepare_packet( packet ); |
123 | header = icmp_prepare_packet( packet ); |
124 | if( ! header ) return ENOMEM; |
124 | if( ! header ) return ENOMEM; |
125 | return icmp_send_packet( ICMP_SOURCE_QUENCH, ICMP_SOURCE_QUENCH, packet, header ); |
125 | return icmp_send_packet( ICMP_SOURCE_QUENCH, ICMP_SOURCE_QUENCH, packet, header ); |
126 | } |
126 | } |
127 | 127 | ||
128 | int icmp_time_exceeded_msg( int icmp_phone, icmp_code_t code, packet_t packet ){ |
128 | int icmp_time_exceeded_msg( int icmp_phone, icmp_code_t code, packet_t packet ){ |
129 | icmp_header_ref header; |
129 | icmp_header_ref header; |
130 | 130 | ||
131 | header = icmp_prepare_packet( packet ); |
131 | header = icmp_prepare_packet( packet ); |
132 | if( ! header ) return ENOMEM; |
132 | if( ! header ) return ENOMEM; |
133 | return icmp_send_packet( ICMP_TIME_EXCEEDED, code, packet, header ); |
133 | return icmp_send_packet( ICMP_TIME_EXCEEDED, code, packet, header ); |
134 | } |
134 | } |
135 | 135 | ||
136 | int icmp_parameter_problem_msg( int icmp_phone, icmp_code_t code, icmp_param_t pointer, packet_t packet ){ |
136 | int icmp_parameter_problem_msg( int icmp_phone, icmp_code_t code, icmp_param_t pointer, packet_t packet ){ |
137 | icmp_header_ref header; |
137 | icmp_header_ref header; |
138 | 138 | ||
139 | header = icmp_prepare_packet( packet ); |
139 | header = icmp_prepare_packet( packet ); |
140 | if( ! header ) return ENOMEM; |
140 | if( ! header ) return ENOMEM; |
141 | header->un.param.pointer = pointer; |
141 | header->un.param.pointer = pointer; |
142 | return icmp_send_packet( ICMP_PARAMETERPROB, code, packet, header ); |
142 | return icmp_send_packet( ICMP_PARAMETERPROB, code, packet, header ); |
143 | } |
143 | } |
144 | 144 | ||
145 | icmp_header_ref icmp_prepare_packet( packet_t packet ){ |
145 | icmp_header_ref icmp_prepare_packet( packet_t packet ){ |
146 | icmp_header_ref header; |
146 | icmp_header_ref header; |
147 | int header_length; |
147 | int header_length; |
148 | size_t total_length; |
148 | size_t total_length; |
149 | 149 | ||
150 | total_length = packet_get_data_length( packet ); |
150 | total_length = packet_get_data_length( packet ); |
151 | if( total_length <= 0 ) return NULL; |
151 | if( total_length <= 0 ) return NULL; |
152 | header_length = ip_client_header_length( packet ); |
152 | header_length = ip_client_header_length( packet ); |
153 | if( header_length <= 0 ) return NULL; |
153 | if( header_length <= 0 ) return NULL; |
154 | // truncate if longer than 64 bits (without the IP header) |
154 | // truncate if longer than 64 bits (without the IP header) |
155 | if( total_length - header_length > ICMP_KEEP_LENGTH ){ |
155 | if( total_length - header_length > ICMP_KEEP_LENGTH ){ |
156 | if( packet_trim( packet, 0, total_length - header_length - ICMP_KEEP_LENGTH ) != EOK ) return NULL; |
156 | if( packet_trim( packet, 0, total_length - header_length - ICMP_KEEP_LENGTH ) != EOK ) return NULL; |
157 | } |
157 | } |
158 | header = PACKET_PREFIX( packet, icmp_header_t ); |
158 | header = PACKET_PREFIX( packet, icmp_header_t ); |
159 | if( ! header ){ |
159 | if( ! header ){ |
160 | pq_release( icmp_globals.net_phone, packet_get_id( packet )); |
160 | pq_release( icmp_globals.net_phone, packet_get_id( packet )); |
161 | return NULL; |
161 | return NULL; |
162 | } |
162 | } |
163 | bzero( header, sizeof( * header )); |
163 | bzero( header, sizeof( * header )); |
164 | return header; |
164 | return header; |
165 | } |
165 | } |
166 | 166 | ||
167 | int icmp_send_packet( icmp_type_t type, icmp_code_t code, packet_t packet, icmp_header_ref header ){ |
167 | int icmp_send_packet( icmp_type_t type, icmp_code_t code, packet_t packet, icmp_header_ref header ){ |
168 | ERROR_DECLARE; |
168 | ERROR_DECLARE; |
169 | 169 | ||
170 | header->type = type; |
170 | header->type = type; |
171 | header->code = code; |
171 | header->code = code; |
172 | header->checksum = 0; |
172 | header->checksum = 0; |
173 | header->checksum = ICMP_HEADER_CHECKSUM( header ); |
173 | header->checksum = ICMP_HEADER_CHECKSUM( header ); |
174 | if( ERROR_OCCURRED( ip_client_prepare_packet( packet, IPPROTO_ICMP, 0, 0, 0, 0 ))){ |
174 | if( ERROR_OCCURRED( ip_client_prepare_packet( packet, IPPROTO_ICMP, 0, 0, 0, 0 ))){ |
175 | pq_release( icmp_globals.net_phone, packet_get_id( packet )); |
175 | pq_release( icmp_globals.net_phone, packet_get_id( packet )); |
176 | return ERROR_CODE; |
176 | return ERROR_CODE; |
177 | } |
177 | } |
178 | return ip_send_msg( icmp_globals.ip_phone, -1, packet, SERVICE_ICMP, SERVICE_ICMP ); |
178 | return ip_send_msg( icmp_globals.ip_phone, -1, packet, SERVICE_ICMP, SERVICE_ICMP ); |
179 | } |
179 | } |
180 | 180 | ||
181 | int icmp_connect_module( services_t service ){ |
181 | int icmp_connect_module( services_t service ){ |
182 | return EOK; |
182 | return EOK; |
183 | } |
183 | } |
184 | 184 | ||
185 | int icmp_initialize( async_client_conn_t client_connection ){ |
185 | int icmp_initialize( async_client_conn_t client_connection ){ |
186 | ERROR_DECLARE; |
186 | ERROR_DECLARE; |
187 | 187 | ||
188 | fibril_rwlock_initialize( & icmp_globals.lock ); |
188 | fibril_rwlock_initialize( & icmp_globals.lock ); |
189 | fibril_rwlock_write_lock( & icmp_globals.lock ); |
189 | fibril_rwlock_write_lock( & icmp_globals.lock ); |
190 | icmp_globals.ip_phone = ip_bind_service( SERVICE_IP, IPPROTO_ICMP, SERVICE_ICMP, client_connection, icmp_received_msg ); |
190 | icmp_globals.ip_phone = ip_bind_service( SERVICE_IP, IPPROTO_ICMP, SERVICE_ICMP, client_connection, icmp_received_msg ); |
191 | if( icmp_globals.ip_phone < 0 ){ |
191 | if( icmp_globals.ip_phone < 0 ){ |
192 | return icmp_globals.ip_phone; |
192 | return icmp_globals.ip_phone; |
193 | } |
193 | } |
194 | ERROR_PROPAGATE( ip_packet_size_req( icmp_globals.ip_phone, -1, & icmp_globals.addr_len, & icmp_globals.prefix, & icmp_globals.content, & icmp_globals.suffix )); |
194 | ERROR_PROPAGATE( ip_packet_size_req( icmp_globals.ip_phone, -1, & icmp_globals.addr_len, & icmp_globals.prefix, & icmp_globals.content, & icmp_globals.suffix )); |
195 | icmp_globals.prefix += sizeof( icmp_header_t ); |
195 | icmp_globals.prefix += sizeof( icmp_header_t ); |
196 | icmp_globals.content -= sizeof( icmp_header_t ); |
196 | icmp_globals.content -= sizeof( icmp_header_t ); |
197 | fibril_rwlock_write_unlock( & icmp_globals.lock ); |
197 | fibril_rwlock_write_unlock( & icmp_globals.lock ); |
198 | return EOK; |
198 | return EOK; |
199 | } |
199 | } |
200 | 200 | ||
201 | int icmp_received_msg( device_id_t device_id, packet_t packet, services_t receiver, services_t error ){ |
201 | int icmp_received_msg( device_id_t device_id, packet_t packet, services_t receiver, services_t error ){ |
202 | ERROR_DECLARE; |
202 | ERROR_DECLARE; |
203 | 203 | ||
204 | if( error ){ |
204 | if( error ){ |
205 | pq_release( icmp_globals.net_phone, packet_get_id( packet )); |
205 | pq_release( icmp_globals.net_phone, packet_get_id( packet )); |
206 | return EINVAL; |
206 | return EINVAL; |
207 | } |
207 | } |
208 | if( ERROR_OCCURRED( icmp_process_packet( packet ))){ |
208 | if( ERROR_OCCURRED( icmp_process_packet( packet ))){ |
209 | pq_release( icmp_globals.net_phone, packet_get_id( packet )); |
209 | pq_release( icmp_globals.net_phone, packet_get_id( packet )); |
210 | return ERROR_CODE; |
210 | return ERROR_CODE; |
211 | } |
211 | } |
212 | 212 | ||
213 | return EOK; |
213 | return EOK; |
214 | } |
214 | } |
215 | 215 | ||
216 | int icmp_process_packet( packet_t packet ){ |
216 | int icmp_process_packet( packet_t packet ){ |
217 | int length; |
217 | size_t length; |
- | 218 | int result; |
|
218 | void * data; |
219 | void * data; |
219 | icmp_header_ref header; |
220 | icmp_header_ref header; |
220 | 221 | ||
221 | // get rid of the ip header |
222 | // get rid of the ip header |
222 | length = ip_client_process_packet( packet, NULL, NULL, NULL, NULL, NULL ); |
223 | result = ip_client_process_packet( packet, NULL, NULL, NULL, NULL, NULL ); |
223 | if( length < 0 ) return length; |
224 | if( result < 0 ) return result; |
224 | packet_trim( packet, length, 0 ); |
225 | packet_trim( packet, ( size_t ) result, 0 ); |
225 | 226 | ||
226 | length = packet_get_data_length( packet ); |
227 | length = packet_get_data_length( packet ); |
227 | if( length <= 0 ) return EINVAL; |
228 | if( length <= 0 ) return EINVAL; |
228 | if( length < sizeof( icmp_header_t )) return EINVAL; |
229 | if( length < sizeof( icmp_header_t )) return EINVAL; |
229 | data = packet_get_data( packet ); |
230 | data = packet_get_data( packet ); |
230 | if( ! data ) return EINVAL; |
231 | if( ! data ) return EINVAL; |
231 | // get icmp header |
232 | // get icmp header |
232 | header = ( icmp_header_ref ) data; |
233 | header = ( icmp_header_ref ) data; |
233 | // checksum |
234 | // checksum |
234 | if(( header->checksum ) && ( ICMP_HEADER_CHECKSUM( header ))){ |
235 | if(( header->checksum ) && ( ICMP_HEADER_CHECKSUM( header ))){ |
235 | return EINVAL; |
236 | return EINVAL; |
236 | } |
237 | } |
237 | // TODO process requests and replies |
238 | // TODO process requests and replies |
238 | ip_received_error_msg( icmp_globals.ip_phone, -1, packet, SERVICE_IP, SERVICE_ICMP ); |
239 | ip_received_error_msg( icmp_globals.ip_phone, -1, packet, SERVICE_IP, SERVICE_ICMP ); |
239 | return EOK; |
240 | return EOK; |
240 | } |
241 | } |
241 | 242 | ||
242 | int icmp_message( ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count ){ |
243 | int icmp_message( ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count ){ |
243 | ERROR_DECLARE; |
244 | ERROR_DECLARE; |
244 | 245 | ||
245 | packet_t packet; |
246 | packet_t packet; |
246 | 247 | ||
247 | * answer_count = 0; |
248 | * answer_count = 0; |
248 | switch( IPC_GET_METHOD( * call )){ |
249 | switch( IPC_GET_METHOD( * call )){ |
249 | case NET_TL_RECEIVED: |
250 | case NET_TL_RECEIVED: |
250 | fibril_rwlock_read_lock( & icmp_globals.lock ); |
251 | fibril_rwlock_read_lock( & icmp_globals.lock ); |
251 | if( ! ERROR_OCCURRED( packet_translate( icmp_globals.net_phone, & packet, IPC_GET_PACKET( call )))){ |
252 | if( ! ERROR_OCCURRED( packet_translate( icmp_globals.net_phone, & packet, IPC_GET_PACKET( call )))){ |
252 | ERROR_CODE = icmp_received_msg( IPC_GET_DEVICE( call ), packet, SERVICE_ICMP, IPC_GET_ERROR( call )); |
253 | ERROR_CODE = icmp_received_msg( IPC_GET_DEVICE( call ), packet, SERVICE_ICMP, IPC_GET_ERROR( call )); |
253 | } |
254 | } |
254 | fibril_rwlock_read_unlock( & icmp_globals.lock ); |
255 | fibril_rwlock_read_unlock( & icmp_globals.lock ); |
255 | return ERROR_CODE; |
256 | return ERROR_CODE; |
256 | case NET_ICMP_DEST_UNREACH: |
257 | case NET_ICMP_DEST_UNREACH: |
257 | ERROR_PROPAGATE( packet_translate( icmp_globals.net_phone, & packet, IPC_GET_PACKET( call ))); |
258 | ERROR_PROPAGATE( packet_translate( icmp_globals.net_phone, & packet, IPC_GET_PACKET( call ))); |
258 | return icmp_destination_unreachable_msg( 0, ICMP_GET_CODE( call ), ICMP_GET_MTU( call ), packet ); |
259 | return icmp_destination_unreachable_msg( 0, ICMP_GET_CODE( call ), ICMP_GET_MTU( call ), packet ); |
259 | case NET_ICMP_SOURCE_QUENCH: |
260 | case NET_ICMP_SOURCE_QUENCH: |
260 | ERROR_PROPAGATE( packet_translate( icmp_globals.net_phone, & packet, IPC_GET_PACKET( call ))); |
261 | ERROR_PROPAGATE( packet_translate( icmp_globals.net_phone, & packet, IPC_GET_PACKET( call ))); |
261 | return icmp_source_quench_msg( 0, packet ); |
262 | return icmp_source_quench_msg( 0, packet ); |
262 | case NET_ICMP_TIME_EXCEEDED: |
263 | case NET_ICMP_TIME_EXCEEDED: |
263 | ERROR_PROPAGATE( packet_translate( icmp_globals.net_phone, & packet, IPC_GET_PACKET( call ))); |
264 | ERROR_PROPAGATE( packet_translate( icmp_globals.net_phone, & packet, IPC_GET_PACKET( call ))); |
264 | return icmp_time_exceeded_msg( 0, ICMP_GET_CODE( call ), packet ); |
265 | return icmp_time_exceeded_msg( 0, ICMP_GET_CODE( call ), packet ); |
265 | case NET_ICMP_PARAMETERPROB: |
266 | case NET_ICMP_PARAMETERPROB: |
266 | ERROR_PROPAGATE( packet_translate( icmp_globals.net_phone, & packet, IPC_GET_PACKET( call ))); |
267 | ERROR_PROPAGATE( packet_translate( icmp_globals.net_phone, & packet, IPC_GET_PACKET( call ))); |
267 | return icmp_parameter_problem_msg( 0, ICMP_GET_CODE( call ), ICMP_GET_POINTER( call ), packet ); |
268 | return icmp_parameter_problem_msg( 0, ICMP_GET_CODE( call ), ICMP_GET_POINTER( call ), packet ); |
268 | } |
269 | } |
269 | return ENOTSUP; |
270 | return ENOTSUP; |
270 | } |
271 | } |
271 | 272 | ||
272 | /** @} |
273 | /** @} |
273 | */ |
274 | */ |
274 | 275 |