Subversion Repositories HelenOS

Rev

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

Rev 3901 Rev 3912
Line 1... Line 1...
1
/*
1
/*
2
 * Copyright (c) 2008 Lukas Mejdrech
2
 * Copyright (c) 2009 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:
Line 24... Line 24...
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 net
29
/** @addtogroup ip
30
 * @{
30
 *  @{
31
 */
31
 */
32
 
32
 
33
/** @file
33
/** @file
34
 */
34
 */
35
 
35
 
Line 107... Line 107...
107
    ip_netif->device_id = device_id;
107
    ip_netif->device_id = device_id;
108
    // get configuration
108
    // get configuration
109
    // TODO mapping
109
    // TODO mapping
110
    message = async_send_2( ip_globals.networking_phone, NET_NET_GET_DEVICE_CONF, ip_netif->device_id, count, & answer );
110
    message = async_send_2( ip_globals.networking_phone, NET_NET_GET_DEVICE_CONF, ip_netif->device_id, count, & answer );
111
    // send names and get settings
111
    // send names and get settings
112
    if( ERROR_OCCURED( measured_strings_send( ip_globals.networking_phone, configuration, count ))
112
    if( ERROR_OCCURRED( measured_strings_send( ip_globals.networking_phone, configuration, count ))
113
    || ERROR_OCCURED( measured_strings_return( ip_globals.networking_phone, & settings, & data, count ))){
113
    || ERROR_OCCURRED( measured_strings_return( ip_globals.networking_phone, & settings, & data, count ))){
114
        async_wait_for( message, NULL );
114
        async_wait_for( message, NULL );
115
        return ERROR_CODE;
115
        return ERROR_CODE;
116
    }
116
    }
117
    if( settings ){
117
    if( settings ){
118
        if( settings[ 0 ].value ){
118
        if( settings[ 0 ].value ){
Line 124... Line 124...
124
        if( ip_netif->dhcp ){
124
        if( ip_netif->dhcp ){
125
            // TODO dhcp
125
            // TODO dhcp
126
            free( ip_netif );
126
            free( ip_netif );
127
            return ENOTSUP;
127
            return ENOTSUP;
128
        }else if( ip_netif->ipv == 4 ){
128
        }else if( ip_netif->ipv == 4 ){
129
            if( ERROR_OCCURED( inet_pton( AF_INET, settings[ 2 ].value, ( uint8_t * ) & ip_netif->address ))
129
            if( ERROR_OCCURRED( inet_pton( AF_INET, settings[ 2 ].value, ( uint8_t * ) & ip_netif->address ))
130
            || ERROR_OCCURED( inet_pton( AF_INET, settings[ 3 ].value, ( uint8_t * ) & ip_netif->netmask ))
130
            || ERROR_OCCURRED( inet_pton( AF_INET, settings[ 3 ].value, ( uint8_t * ) & ip_netif->netmask ))
131
            || ( inet_pton( AF_INET, settings[ 4 ].value, ( uint8_t * ) & ip_netif->gateway ) == EINVAL )
131
            || ( inet_pton( AF_INET, settings[ 4 ].value, ( uint8_t * ) & ip_netif->gateway ) == EINVAL )
132
            || ( inet_pton( AF_INET, settings[ 5 ].value, ( uint8_t * ) & ip_netif->broadcast ) == EINVAL )
132
            || ( inet_pton( AF_INET, settings[ 5 ].value, ( uint8_t * ) & ip_netif->broadcast ) == EINVAL )
133
            || ( inet_pton( AF_INET, settings[ 6 ].value, ( uint8_t * ) & ip_netif->dns1 ) == EINVAL )
133
            || ( inet_pton( AF_INET, settings[ 6 ].value, ( uint8_t * ) & ip_netif->dns1 ) == EINVAL )
134
            || ( inet_pton( AF_INET, settings[ 7 ].value, ( uint8_t * ) & ip_netif->dns2 ) == EINVAL )){
134
            || ( inet_pton( AF_INET, settings[ 7 ].value, ( uint8_t * ) & ip_netif->dns2 ) == EINVAL )){
135
                free( ip_netif );
135
                free( ip_netif );
Line 168... Line 168...
168
        printf( "\n -dns2 =\t%s", data );
168
        printf( "\n -dns2 =\t%s", data );
169
        free( data );
169
        free( data );
170
    }
170
    }
171
    // TODO mapping
171
    // TODO mapping
172
    ip_netif->phone = bind_service( service, ip_netif->device_id, SERVICE_IP, 0, ip_driver_receiver );
172
    ip_netif->phone = bind_service( service, ip_netif->device_id, SERVICE_IP, 0, ip_driver_receiver );
173
    if( ERROR_OCCURED( ip_netifs_add( & ip_globals.netifs, ip_netif->device_id, ip_netif ))){
173
    if( ERROR_OCCURRED( ip_netifs_add( & ip_globals.netifs, ip_netif->device_id, ip_netif ))){
174
        free( ip_netif );
174
        free( ip_netif );
175
        return ERROR_CODE;
175
        return ERROR_CODE;
176
    }
176
    }
177
    return EOK;
177
    return EOK;
178
}
178
}
Line 212... Line 212...
212
                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 ));
213
                ipc_answer_0( callid, result );
213
                ipc_answer_0( callid, result );
214
            // TODO packer received
214
            // TODO packer received
215
            case NET_IL_RECEIVED:
215
            case NET_IL_RECEIVED:
216
            case NET_NIL_RECEIVED:
216
            case NET_NIL_RECEIVED:
217
                if( ! ERROR_OCCURED( result = packet_translate( ip_globals.networking_phone, & packet, IPC_GET_PACKET( & call )))){
217
                if( ! ERROR_OCCURRED( result = packet_translate( ip_globals.networking_phone, & packet, IPC_GET_PACKET( & call )))){
218
                    //result = ip_receive_message( IPC_GET_DEVICE( call ), packet );
218
                    //result = ip_receive_message( IPC_GET_DEVICE( call ), packet );
219
                }
219
                }
220
                ipc_answer_0( callid, result );
220
                ipc_answer_0( callid, result );
221
        }
221
        }
222
    }
222
    }
Line 235... Line 235...
235
 
235
 
236
    proto = ( ip_proto_ref ) malloc( sizeof( ip_protos_t ));
236
    proto = ( ip_proto_ref ) malloc( sizeof( ip_protos_t ));
237
    if( ! proto ) return ENOMEM;
237
    if( ! proto ) return ENOMEM;
238
    proto->protocol = protocol;
238
    proto->protocol = protocol;
239
    proto->phone = phone;
239
    proto->phone = phone;
240
    if( ERROR_OCCURED( ip_protos_add( & ip_globals.protos, proto->protocol, proto ))){
240
    if( ERROR_OCCURRED( ip_protos_add( & ip_globals.protos, proto->protocol, proto ))){
241
        free( proto );
241
        free( proto );
242
        return ERROR_CODE;
242
        return ERROR_CODE;
243
    }
243
    }
244
    return EOK;
244
    return EOK;
245
}
245
}
Line 266... Line 266...
266
        case NET_IL_DEVICE:
266
        case NET_IL_DEVICE:
267
            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 ));
268
        case IPC_M_CONNECT_TO_ME:
268
        case IPC_M_CONNECT_TO_ME:
269
            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 ));
270
        case NET_IP_SEND:
270
        case NET_IP_SEND:
271
            if( ERROR_OCCURED( packet_translate( ip_globals.networking_phone, & packet, IPC_GET_PACKET( call )))){
271
            if( ERROR_OCCURRED( packet_translate( ip_globals.networking_phone, & packet, IPC_GET_PACKET( call )))){
272
                printf( "\nIP send E %d", ERROR_CODE );
272
                printf( "\nIP send E %d", ERROR_CODE );
273
                return ERROR_CODE;
273
                return ERROR_CODE;
274
            }
274
            }
275
            return ip_send_message( IPC_GET_DEVICE( call ), packet );
275
            return ip_send_message( IPC_GET_DEVICE( call ), packet );
276
    }
276
    }