Subversion Repositories HelenOS

Rev

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

Rev 4582 Rev 4695
Line 197... Line 197...
197
 *  @param phone The service phone. Input parameter.
197
 *  @param phone The service phone. Input parameter.
198
 *  @returns EOK on success.
198
 *  @returns EOK on success.
199
 *  @returns ENOENT if the service is not known.
199
 *  @returns ENOENT if the service is not known.
200
 *  @returns ENOMEM if there is not enough memory left.
200
 *  @returns ENOMEM if there is not enough memory left.
201
 */
201
 */
202
int nil_register_message( services_t service, int phone );
202
int eth_register_message( services_t service, int phone );
203
 
203
 
204
/** Returns the device packet dimensions for sending.
204
/** Returns the device packet dimensions for sending.
205
 *  @param device_id The device identifier. Input parameter.
205
 *  @param device_id The device identifier. Input parameter.
206
 *  @param addr_len The minimum reserved address length. Output parameter.
206
 *  @param addr_len The minimum reserved address length. Output parameter.
207
 *  @param prefix The minimum reserved prefix size. Output parameter.
207
 *  @param prefix The minimum reserved prefix size. Output parameter.
Line 304... Line 304...
304
    int             index;
304
    int             index;
305
    measured_string_t   names[ 2 ] = {{ "ETH_MODE", 8 }, { "ETH_DUMMY", 9 }};
305
    measured_string_t   names[ 2 ] = {{ "ETH_MODE", 8 }, { "ETH_DUMMY", 9 }};
306
    measured_string_ref configuration;
306
    measured_string_ref configuration;
307
    size_t              count = sizeof( names ) / sizeof( measured_string_t );
307
    size_t              count = sizeof( names ) / sizeof( measured_string_t );
308
    char *              data;
308
    char *              data;
-
 
309
    eth_proto_ref       proto;
309
 
310
 
310
    fibril_rwlock_write_lock( & eth_globals.devices_lock );
311
    fibril_rwlock_write_lock( & eth_globals.devices_lock );
311
    // an existing device?
312
    // an existing device?
312
    device = eth_devices_find( & eth_globals.devices, device_id );
313
    device = eth_devices_find( & eth_globals.devices, device_id );
313
    if( device ){
314
    if( device ){
Line 317... Line 318...
317
            return EEXIST;
318
            return EEXIST;
318
        }else{
319
        }else{
319
            // update mtu
320
            // update mtu
320
            device->mtu = mtu;
321
            device->mtu = mtu;
321
            printf( "Device %d already exists:\tMTU\t= %d\n", device->device_id, device->mtu );
322
            printf( "Device %d already exists:\tMTU\t= %d\n", device->device_id, device->mtu );
-
 
323
            fibril_rwlock_write_unlock( & eth_globals.devices_lock );
-
 
324
            // notify all upper layer modules
-
 
325
            fibril_rwlock_read_lock( & eth_globals.protos_lock );
-
 
326
            for( index = 0; index < eth_protos_count( & eth_globals.protos ); ++ index ){
-
 
327
                proto = eth_protos_get_index( & eth_globals.protos, index );
-
 
328
                if ( proto->phone ){
-
 
329
                    il_mtu_changed_msg( proto->phone, device->device_id, device->mtu, proto->service );
-
 
330
                }
-
 
331
            }
-
 
332
            fibril_rwlock_read_unlock( & eth_globals.protos_lock );
-
 
333
            return EOK;
322
        }
334
        }
323
    }else{
335
    }else{
324
        // create a new device
336
        // create a new device
325
        device = ( eth_device_ref ) malloc( sizeof( eth_device_t ));
337
        device = ( eth_device_ref ) malloc( sizeof( eth_device_t ));
326
        if( ! device ) return ENOMEM;
338
        if( ! device ) return ENOMEM;
Line 504... Line 516...
504
        fibril_rwlock_read_unlock( & eth_globals.devices_lock );
516
        fibril_rwlock_read_unlock( & eth_globals.devices_lock );
505
    }
517
    }
506
    return ( * address ) ? EOK : ENOENT;
518
    return ( * address ) ? EOK : ENOENT;
507
}
519
}
508
 
520
 
509
int nil_register_message( services_t service, int phone ){
521
int eth_register_message( services_t service, int phone ){
510
    eth_proto_ref   proto;
522
    eth_proto_ref   proto;
511
    int             protocol;
523
    int             protocol;
512
    int             index;
524
    int             index;
513
 
525
 
514
    protocol = protocol_map( SERVICE_ETHERNET, service );
526
    protocol = protocol_map( SERVICE_ETHERNET, service );
Line 646... Line 658...
646
    * answer_count = 0;
658
    * answer_count = 0;
647
    switch( IPC_GET_METHOD( * call )){
659
    switch( IPC_GET_METHOD( * call )){
648
        case IPC_M_PHONE_HUNGUP:
660
        case IPC_M_PHONE_HUNGUP:
649
            return EOK;
661
            return EOK;
650
        case NET_NIL_DEVICE:
662
        case NET_NIL_DEVICE:
651
            return eth_device_message( IPC_GET_DEVICE( call ), IPC_GET_SERVICE( call ), NIL_GET_MTU( call ));
663
            return eth_device_message( IPC_GET_DEVICE( call ), IPC_GET_SERVICE( call ), IPC_GET_MTU( call ));
652
        case NET_NIL_SEND:
664
        case NET_NIL_SEND:
653
            ERROR_PROPAGATE( packet_translate( eth_globals.net_phone, & packet, IPC_GET_PACKET( call )));
665
            ERROR_PROPAGATE( packet_translate( eth_globals.net_phone, & packet, IPC_GET_PACKET( call )));
654
            return eth_send_message( IPC_GET_DEVICE( call ), packet, IPC_GET_SERVICE( call ));
666
            return eth_send_message( IPC_GET_DEVICE( call ), packet, IPC_GET_SERVICE( call ));
655
        case NET_NIL_PACKET_SPACE:
667
        case NET_NIL_PACKET_SPACE:
656
            ERROR_PROPAGATE( eth_packet_space_message( IPC_GET_DEVICE( call ), IPC_SET_ADDR( answer ), IPC_SET_PREFIX( answer ), IPC_SET_CONTENT( answer ), IPC_SET_SUFFIX( answer )));
668
            ERROR_PROPAGATE( eth_packet_space_message( IPC_GET_DEVICE( call ), IPC_SET_ADDR( answer ), IPC_SET_PREFIX( answer ), IPC_SET_CONTENT( answer ), IPC_SET_SUFFIX( answer )));
Line 661... Line 673...
661
            return measured_strings_reply( address, 1 );
673
            return measured_strings_reply( address, 1 );
662
        case NET_NIL_BROADCAST_ADDR:
674
        case NET_NIL_BROADCAST_ADDR:
663
            ERROR_PROPAGATE( eth_addr_message( IPC_GET_DEVICE( call ), ETH_BROADCAST_ADDR, & address ));
675
            ERROR_PROPAGATE( eth_addr_message( IPC_GET_DEVICE( call ), ETH_BROADCAST_ADDR, & address ));
664
            return measured_strings_reply( address, 1 );
676
            return measured_strings_reply( address, 1 );
665
        case IPC_M_CONNECT_TO_ME:
677
        case IPC_M_CONNECT_TO_ME:
666
            return nil_register_message( NIL_GET_PROTO( call ), IPC_GET_PHONE( call ));
678
            return eth_register_message( NIL_GET_PROTO( call ), IPC_GET_PHONE( call ));
667
    }
679
    }
668
    return ENOTSUP;
680
    return ENOTSUP;
669
}
681
}
670
 
682
 
671
void eth_receiver( ipc_callid_t iid, ipc_call_t * icall ){
683
void eth_receiver( ipc_callid_t iid, ipc_call_t * icall ){