Subversion Repositories HelenOS

Rev

Rev 3886 | Rev 3991 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 3886 Rev 3901
Line 47... Line 47...
47
 
47
 
48
#include "../../include/sockaddr.h"
48
#include "../../include/sockaddr.h"
49
#include "../../include/socket.h"
49
#include "../../include/socket.h"
50
#include "../../netif/device.h"
50
#include "../../netif/device.h"
51
#include "../../structures/measured_strings.h"
51
#include "../../structures/measured_strings.h"
52
#include "../../structures/packet/packet.h"
52
#include "../../structures/packet/packet_client.h"
53
 
53
 
54
#include "ip.h"
54
#include "ip.h"
55
#include "ip_messages.h"
55
#include "ip_messages.h"
56
#include "ip_module.h"
56
#include "ip_module.h"
57
 
57
 
58
#define DEFAULT_IPV     4
58
#define DEFAULT_IPV     4
59
 
59
 
60
#define IPC_GET_DEVICE( call )      ( device_id_t ) IPC_GET_ARG1( * call )
60
#define IPC_GET_DEVICE( call )      ( device_id_t ) IPC_GET_ARG1( * call )
-
 
61
#define IPC_GET_PACKET( call )      ( packet_id_t ) IPC_GET_ARG1( * call )
61
#define IPC_GET_PROTO( call )       ( int ) IPC_GET_ARG1( * call )
62
#define IPC_GET_PROTO( call )       ( int ) IPC_GET_ARG1( * call )
62
#define IPC_GET_SERVICE( call )     ( services_t ) IPC_GET_ARG2( * call )
63
#define IPC_GET_SERVICE( call )     ( services_t ) IPC_GET_ARG2( * call )
63
#define IPC_GET_STATE( call )       ( device_state_t ) IPC_GET_ARG2( * call )
64
#define IPC_GET_STATE( call )       ( device_state_t ) IPC_GET_ARG2( * call )
64
#define IPC_GET_PHONE( call )       ( int ) IPC_GET_ARG5( * call )
65
#define IPC_GET_PHONE( call )       ( int ) IPC_GET_ARG5( * call )
65
 
66
 
Line 211... Line 212...
211
                result = ip_state_message( IPC_GET_DEVICE( & call ), IPC_GET_STATE( & call ));
212
                result = ip_state_message( IPC_GET_DEVICE( & call ), IPC_GET_STATE( & call ));
212
                ipc_answer_0( callid, result );
213
                ipc_answer_0( callid, result );
213
            // TODO packer received
214
            // TODO packer received
214
            case NET_IL_RECEIVED:
215
            case NET_IL_RECEIVED:
215
            case NET_NIL_RECEIVED:
216
            case NET_NIL_RECEIVED:
216
                if( ERROR_OCCURED( result = packet_receive( & packet ))){
217
                if( ! ERROR_OCCURED( result = packet_translate( ip_globals.networking_phone, & packet, IPC_GET_PACKET( & call )))){
217
                    ipc_answer_0( callid, ERROR_CODE );
218
                    //result = ip_receive_message( IPC_GET_DEVICE( call ), packet );
218
                    continue;
-
 
219
                }
219
                }
220
                //result = ip_receive_message( IPC_GET_DEVICE( call ), packet );
-
 
221
                packet_destroy( packet );
-
 
222
                ipc_answer_0( callid, result );
220
                ipc_answer_0( callid, result );
223
        }
221
        }
224
    }
222
    }
225
}
223
}
226
 
224
 
Line 247... Line 245...
247
}
245
}
248
 
246
 
249
int ip_send_message( device_id_t device_id, packet_t packet ){
247
int ip_send_message( device_id_t device_id, packet_t packet ){
250
    // TODO send packet
248
    // TODO send packet
251
    printf( "Packet to send via %d: %s", device_id, packet_get_data( packet ));
249
    printf( "Packet to send via %d: %s", device_id, packet_get_data( packet ));
-
 
250
    packet_release( ip_globals.networking_phone, packet_get_id( packet ));
252
    return EOK;
251
    return EOK;
253
}
252
}
254
 
253
 
255
int ip_message( ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count ){
254
int ip_message( ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count ){
256
    ERROR_DECLARE;
255
    ERROR_DECLARE;
Line 267... Line 266...
267
        case NET_IL_DEVICE:
266
        case NET_IL_DEVICE:
268
            return ip_device_message( IPC_GET_DEVICE( call ), IPC_GET_SERVICE( call ));
267
            return ip_device_message( IPC_GET_DEVICE( call ), IPC_GET_SERVICE( call ));
269
        case IPC_M_CONNECT_TO_ME:
268
        case IPC_M_CONNECT_TO_ME:
270
            return ip_register_message( IPC_GET_PROTO( call ), IPC_GET_PHONE( call ));
269
            return ip_register_message( IPC_GET_PROTO( call ), IPC_GET_PHONE( call ));
271
        case NET_IP_SEND:
270
        case NET_IP_SEND:
-
 
271
            if( ERROR_OCCURED( packet_translate( ip_globals.networking_phone, & packet, IPC_GET_PACKET( call )))){
272
            ERROR_PROPAGATE( packet_receive( & packet ));
272
                printf( "\nIP send E %d", ERROR_CODE );
-
 
273
                return ERROR_CODE;
-
 
274
            }
273
            return ip_send_message( IPC_GET_DEVICE( call ), packet );
275
            return ip_send_message( IPC_GET_DEVICE( call ), packet );
274
    }
276
    }
275
    return ENOTSUP;
277
    return ENOTSUP;
276
}
278
}
277
 
279