Rev 4350 | Rev 4505 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 4350 | Rev 4351 | ||
---|---|---|---|
Line 73... | Line 73... | ||
73 | 73 | ||
74 | DEVICE_MAP_IMPLEMENT( ip_netifs, ip_netif_t ) |
74 | DEVICE_MAP_IMPLEMENT( ip_netifs, ip_netif_t ) |
75 | 75 | ||
76 | INT_MAP_IMPLEMENT( ip_protos, ip_proto_t ) |
76 | INT_MAP_IMPLEMENT( ip_protos, ip_proto_t ) |
77 | 77 | ||
78 | void ip_driver_receiver( ipc_callid_t iid, ipc_call_t * icall ); |
- | |
79 | int ip_device_state_msg( int il_phone, device_id_t device_id, device_state_t state ); |
78 | int ip_device_state_msg( int il_phone, device_id_t device_id, device_state_t state ); |
80 | int ip_register( int il_phone, int protocol, int phone ); |
79 | int ip_register( int il_phone, int protocol, int phone ); |
81 | 80 | ||
82 | /** Initializes the module. |
81 | /** Initializes the module. |
83 | */ |
82 | */ |
84 | int ip_initialize( void ){ |
83 | int ip_initialize( async_client_conn_t client_connection ){ |
85 | ERROR_DECLARE; |
84 | ERROR_DECLARE; |
86 | 85 | ||
87 | ERROR_PROPAGATE( ip_netifs_initialize( & ip_globals.netifs )); |
86 | ERROR_PROPAGATE( ip_netifs_initialize( & ip_globals.netifs )); |
88 | ERROR_PROPAGATE( ip_protos_initialize( & ip_globals.protos )); |
87 | ERROR_PROPAGATE( ip_protos_initialize( & ip_globals.protos )); |
- | 88 | ip_globals.client_connection = client_connection; |
|
89 | ERROR_PROPAGATE( modules_initialize( & ip_globals.modules )); |
89 | ERROR_PROPAGATE( modules_initialize( & ip_globals.modules )); |
90 | ERROR_PROPAGATE( add_module( NULL, & ip_globals.modules, ARP_NAME, ARP_FILENAME, SERVICE_ARP, arp_task_get_id(), arp_connect_module )); |
90 | ERROR_PROPAGATE( add_module( NULL, & ip_globals.modules, ARP_NAME, ARP_FILENAME, SERVICE_ARP, arp_task_get_id(), arp_connect_module )); |
91 | return EOK; |
91 | return EOK; |
92 | } |
92 | } |
93 | 93 | ||
Line 147... | Line 147... | ||
147 | }else{ |
147 | }else{ |
148 | ip_netif->arp = NULL; |
148 | ip_netif->arp = NULL; |
149 | } |
149 | } |
150 | net_free_settings( configuration, data ); |
150 | net_free_settings( configuration, data ); |
151 | } |
151 | } |
152 | ip_netif->phone = bind_service( netif, ip_netif->device_id, SERVICE_IP, 0, ip_driver_receiver ); |
152 | ip_netif->phone = bind_service( netif, ip_netif->device_id, SERVICE_IP, 0, ip_globals.client_connection ); |
153 | if( ip_netif->phone < 0 ){ |
153 | if( ip_netif->phone < 0 ){ |
154 | printf( "Failed to contact the nil service %d\n", netif ); |
154 | printf( "Failed to contact the nil service %d\n", netif ); |
155 | free( ip_netif ); |
155 | free( ip_netif ); |
156 | return ip_netif->phone; |
156 | return ip_netif->phone; |
157 | } |
157 | } |
Line 190... | Line 190... | ||
190 | free( data ); |
190 | free( data ); |
191 | } |
191 | } |
192 | return EOK; |
192 | return EOK; |
193 | } |
193 | } |
194 | 194 | ||
195 | void ip_driver_receiver( ipc_callid_t iid, ipc_call_t * icall ){ |
- | |
196 | ERROR_DECLARE; |
- | |
197 | - | ||
198 | ipc_callid_t callid; |
- | |
199 | ipc_call_t call; |
- | |
200 | // ipc_call_t answer; |
- | |
201 | // int count; |
- | |
202 | int result; |
- | |
203 | packet_t packet; |
- | |
204 | - | ||
205 | /* |
- | |
206 | * Accept the connection |
- | |
207 | * - Answer the first IPC_M_CONNECT_ME_TO call. |
- | |
208 | */ |
- | |
209 | ipc_answer_0( iid, EOK ); |
- | |
210 | - | ||
211 | while( true ){ |
- | |
212 | /* // refresh data |
- | |
213 | count = 0; |
- | |
214 | IPC_SET_RETVAL( answer, 0 ); |
- | |
215 | // just to be precize |
- | |
216 | IPC_SET_RETVAL( answer, 0 ); |
- | |
217 | IPC_SET_ARG1( answer, 0 ); |
- | |
218 | IPC_SET_ARG2( answer, 0 ); |
- | |
219 | IPC_SET_ARG3( answer, 0 ); |
- | |
220 | IPC_SET_ARG4( answer, 0 ); |
- | |
221 | IPC_SET_ARG5( answer, 0 ); |
- | |
222 | */ |
- | |
223 | callid = async_get_call( & call ); |
- | |
224 | switch( IPC_GET_METHOD( call )){ |
- | |
225 | case NET_IL_DEVICE_STATE: |
- | |
226 | case NET_NIL_DEVICE_STATE: |
- | |
227 | result = ip_device_state_msg( 0, IPC_GET_DEVICE( & call ), IPC_GET_STATE( & call )); |
- | |
228 | ipc_answer_0( callid, result ); |
- | |
229 | break; |
- | |
230 | // TODO packer received |
- | |
231 | case NET_IL_RECEIVED: |
- | |
232 | case NET_NIL_RECEIVED: |
- | |
233 | if( ! ERROR_OCCURRED( result = packet_translate( ip_globals.net_phone, & packet, IPC_GET_PACKET( & call )))){ |
- | |
234 | //result = il_receive_msg( 0, IPC_GET_DEVICE( call ), packet ); |
- | |
235 | } |
- | |
236 | ipc_answer_0( callid, result ); |
- | |
237 | break; |
- | |
238 | } |
- | |
239 | } |
- | |
240 | } |
- | |
241 | - | ||
242 | int ip_device_state_msg( int il_phone, device_id_t device_id, device_state_t state ){ |
195 | int ip_device_state_msg( int il_phone, device_id_t device_id, device_state_t state ){ |
243 | // ERROR_DECLARE; |
196 | // ERROR_DECLARE; |
244 | 197 | ||
245 | ip_netif_ref netif; |
198 | ip_netif_ref netif; |
246 | 199 | ||
Line 313... | Line 266... | ||
313 | case IPC_M_CONNECT_TO_ME: |
266 | case IPC_M_CONNECT_TO_ME: |
314 | return ip_register( 0, IL_GET_PROTO( call ), IPC_GET_PHONE( call )); |
267 | return ip_register( 0, IL_GET_PROTO( call ), IPC_GET_PHONE( call )); |
315 | case NET_IL_SEND: |
268 | case NET_IL_SEND: |
316 | ERROR_PROPAGATE( packet_translate( ip_globals.net_phone, & packet, IPC_GET_PACKET( call ))); |
269 | ERROR_PROPAGATE( packet_translate( ip_globals.net_phone, & packet, IPC_GET_PACKET( call ))); |
317 | return ip_send_msg( 0, IPC_GET_DEVICE( call ), packet, 0 ); |
270 | return ip_send_msg( 0, IPC_GET_DEVICE( call ), packet, 0 ); |
- | 271 | case NET_IL_DEVICE_STATE: |
|
- | 272 | case NET_NIL_DEVICE_STATE: |
|
- | 273 | return ip_device_state_msg( 0, IPC_GET_DEVICE( call ), IPC_GET_STATE( call )); |
|
- | 274 | // TODO packet received |
|
- | 275 | case NET_IL_RECEIVED: |
|
- | 276 | case NET_NIL_RECEIVED: |
|
- | 277 | ERROR_PROPAGATE( packet_translate( ip_globals.net_phone, & packet, IPC_GET_PACKET( call ))); |
|
- | 278 | //return il_receive_msg( 0, IPC_GET_DEVICE( call ), packet ); |
|
318 | } |
279 | } |
319 | return ENOTSUP; |
280 | return ENOTSUP; |
320 | } |
281 | } |
321 | 282 | ||
322 | /** @} |
283 | /** @} |