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 lo
30
 * @{
30
 *  @{
31
 */
31
 */
32
 
32
 
33
/** @file
33
/** @file
34
 */
34
 */
35
 
35
 
Line 71... Line 71...
71
    device_ref  device;
71
    device_ref  device;
72
 
72
 
73
    ERROR_PROPAGATE( find_device( device_id, & device ));
73
    ERROR_PROPAGATE( find_device( device_id, & device ));
74
    if( device->state != state ){
74
    if( device->state != state ){
75
        device->state = state;
75
        device->state = state;
76
        nil_message( device, NET_NIL_DEVICE_STATE, device->state, NULL, NULL, NULL, NULL );
76
        nil_message( device, NET_NIL_DEVICE_STATE, device->state, NULL );
77
    }
77
    }
78
    return EOK;
78
    return EOK;
79
}
79
}
80
 
80
 
81
int create( device_id_t device_id, device_ref * device ){
81
int create( device_id_t device_id, device_ref * device ){
Line 91... Line 91...
91
        ( ** device ).specific = NULL;
91
        ( ** device ).specific = NULL;
92
        null_device_stats( &(( ** device ).stats ));
92
        null_device_stats( &(( ** device ).stats ));
93
        ( ** device ).state = NETIF_STOPPED;
93
        ( ** device ).state = NETIF_STOPPED;
94
        ( ** device ).flags = NULL;
94
        ( ** device ).flags = NULL;
95
        ( ** device ).mtu = DEFAULT_MTU;
95
        ( ** device ).mtu = DEFAULT_MTU;
96
        if( ERROR_OCCURED( device_map_add( & netif_globals.device_map, ( ** device ).device_id, * device ))){
96
        if( ERROR_OCCURRED( device_map_add( & netif_globals.device_map, ( ** device ).device_id, * device ))){
97
            free( * device );
97
            free( * device );
98
            * device = NULL;
98
            * device = NULL;
99
            return ERROR_CODE;
99
            return ERROR_CODE;
100
        }
100
        }
101
    }
101
    }
Line 136... Line 136...
136
    // create a new device
136
    // create a new device
137
    ERROR_PROPAGATE( create( device_id, & device ));
137
    ERROR_PROPAGATE( create( device_id, & device ));
138
    // get configuration
138
    // get configuration
139
    message = async_send_2( netif_globals.networking_phone, NET_NET_GET_DEVICE_CONF, device->device_id, count, & answer );
139
    message = async_send_2( netif_globals.networking_phone, NET_NET_GET_DEVICE_CONF, device->device_id, count, & answer );
140
    // send names and get settings
140
    // send names and get settings
141
    if( ERROR_OCCURED( measured_strings_send( netif_globals.networking_phone, configuration, count ))
141
    if( ERROR_OCCURRED( measured_strings_send( netif_globals.networking_phone, configuration, count ))
142
    || ERROR_OCCURED( measured_strings_return( netif_globals.networking_phone, & settings, & data, count ))){
142
    || ERROR_OCCURRED( measured_strings_return( netif_globals.networking_phone, & settings, & data, count ))){
143
        async_wait_for( message, NULL );
143
        async_wait_for( message, NULL );
144
        return ERROR_CODE;
144
        return ERROR_CODE;
145
    }
145
    }
146
    // MTU is the first one
146
    // MTU is the first one
147
    if( settings && ( settings[ 0 ].value )){
147
    if( settings && ( settings[ 0 ].value )){
Line 176... Line 176...
176
    packet_release( netif_globals.networking_phone, packet_get_id( packet ));
176
    packet_release( netif_globals.networking_phone, packet_get_id( packet ));
177
    if( ! received ){
177
    if( ! received ){
178
        ++ device->stats.rx_dropped;
178
        ++ device->stats.rx_dropped;
179
        return EOK;
179
        return EOK;
180
    }
180
    }
181
    async_msg_2( device->nil_phone, NET_NIL_RECEIVED, device_id, packet_get_id( received ));
181
    nil_message( device, NET_NIL_RECEIVED, packet_get_id( received ), NULL );
182
//  message = async_send_1( device->nil_phone, NET_NIL_RECEIVED, ( device_id ), & answer );
182
//  message = async_send_1( device->nil_phone, NET_NIL_RECEIVED, ( device_id ), & answer );
183
//  if( ERROR_OCCURED( packet_send( received, device->nil_phone ))){
183
//  if( ERROR_OCCURRED( packet_send( received, device->nil_phone ))){
184
//      ++ device->stats.rx_dropped;
184
//      ++ device->stats.rx_dropped;
185
//  }
185
//  }
186
//  if( result != EOK ) ++ device->stats.rx_dropped;
186
//  if( result != EOK ) ++ device->stats.rx_dropped;
187
    return EOK;
187
    return EOK;
188
}
188
}