Subversion Repositories HelenOS

Rev

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

Rev 4351 Rev 4500
Line 301... Line 301...
301
 
301
 
302
    eth_device_ref  device;
302
    eth_device_ref  device;
303
    int             index;
303
    int             index;
304
    measured_string_t   names[ 2 ] = {{ "ETH_MODE", 8 }, { "ETH_DUMMY", 9 }};
304
    measured_string_t   names[ 2 ] = {{ "ETH_MODE", 8 }, { "ETH_DUMMY", 9 }};
305
    measured_string_ref configuration;
305
    measured_string_ref configuration;
306
    int                 count = 2;
306
    size_t              count = sizeof( names ) / sizeof( measured_string_t );
307
    char *              data;
307
    char *              data;
308
 
308
 
309
    rwlock_write_lock( & eth_globals.devices_lock );
309
    rwlock_write_lock( & eth_globals.devices_lock );
310
    // an existing device?
310
    // an existing device?
311
    device = eth_devices_find( & eth_globals.devices, device_id );
311
    device = eth_devices_find( & eth_globals.devices, device_id );
Line 563... Line 563...
563
        preamble->sfd = ETH_SFD;
563
        preamble->sfd = ETH_SFD;
564
    }
564
    }
565
    // TODO LSAP only device
565
    // TODO LSAP only device
566
    if( IS_DIX( flags ) || IS_8023_2_LSAP( flags )){
566
    if( IS_DIX( flags ) || IS_8023_2_LSAP( flags )){
567
        header_dix = PACKET_PREFIX( packet, eth_header_t );
567
        header_dix = PACKET_PREFIX( packet, eth_header_t );
-
 
568
        if( ! header_dix ) return ENOMEM;
568
        header_dix->ethertype = ( uint16_t ) ethertype;
569
        header_dix->ethertype = ( uint16_t ) ethertype;
569
        memcpy( header_dix->src, src_addr, ETH_ADDR );
570
        memcpy( header_dix->src, src_addr, ETH_ADDR );
570
        memcpy( header_dix->dest, dest, ETH_ADDR );
571
        memcpy( header_dix->dest, dest, ETH_ADDR );
571
        src = & header_dix->dest[ 0 ];
572
        src = & header_dix->dest[ 0 ];
572
    }else if( IS_8023_2_SNAP( flags )){
573
    }else if( IS_8023_2_SNAP( flags )){
Line 613... Line 614...
613
    next = packet;
614
    next = packet;
614
    do{
615
    do{
615
        if( ERROR_OCCURRED( eth_prepare_packet( device->flags, next, ( uint8_t * ) device->addr->value, ethertype, device->mtu ))){
616
        if( ERROR_OCCURRED( eth_prepare_packet( device->flags, next, ( uint8_t * ) device->addr->value, ethertype, device->mtu ))){
616
            // release invalid packet
617
            // release invalid packet
617
            tmp = pq_detach( next );
618
            tmp = pq_detach( next );
-
 
619
            if( next == packet ) packet = tmp;
618
            pq_release( eth_globals.net_phone, packet_get_id( next ));
620
            pq_release( eth_globals.net_phone, packet_get_id( next ));
619
            next = tmp;
621
            next = tmp;
620
        }else{
622
        }else{
621
            next = pq_next( next );
623
            next = pq_next( next );
622
        }
624
        }
623
    }while( next );
625
    }while( next );
624
    // send packet queue
626
    // send packet queue
-
 
627
    if( packet ){
625
    netif_send_msg( device->phone, device_id, packet, SERVICE_ETHERNET );
628
        netif_send_msg( device->phone, device_id, packet, SERVICE_ETHERNET );
-
 
629
    }
626
    rwlock_read_unlock( & eth_globals.devices_lock );
630
    rwlock_read_unlock( & eth_globals.devices_lock );
627
    return EOK;
631
    return EOK;
628
}
632
}
629
 
633
 
630
int nil_message( ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count ){
634
int nil_message( ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count ){
Line 643... Line 647...
643
        case NET_NIL_SEND:
647
        case NET_NIL_SEND:
644
            ERROR_PROPAGATE( packet_translate( eth_globals.net_phone, & packet, IPC_GET_PACKET( call )));
648
            ERROR_PROPAGATE( packet_translate( eth_globals.net_phone, & packet, IPC_GET_PACKET( call )));
645
            return eth_send_message( IPC_GET_DEVICE( call ), packet, IPC_GET_SERVICE( call ));
649
            return eth_send_message( IPC_GET_DEVICE( call ), packet, IPC_GET_SERVICE( call ));
646
        case NET_NIL_PACKET_SPACE:
650
        case NET_NIL_PACKET_SPACE:
647
            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 )));
651
            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 )));
648
            * answer_count = 3;
652
            * answer_count = 4;
649
            return EOK;
653
            return EOK;
650
        case NET_NIL_ADDR:
654
        case NET_NIL_ADDR:
651
            ERROR_PROPAGATE( eth_addr_message( IPC_GET_DEVICE( call ), ETH_LOCAL_ADDR, & address ));
655
            ERROR_PROPAGATE( eth_addr_message( IPC_GET_DEVICE( call ), ETH_LOCAL_ADDR, & address ));
652
            return measured_strings_reply( address, 1 );
656
            return measured_strings_reply( address, 1 );
653
        case NET_NIL_BROADCAST_ADDR:
657
        case NET_NIL_BROADCAST_ADDR: