Subversion Repositories HelenOS

Rev

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

Rev 4307 Rev 4350
Line 29... Line 29...
29
/** @addtogroup lo
29
/** @addtogroup lo
30
 *  @{
30
 *  @{
31
 */
31
 */
32
 
32
 
33
/** @file
33
/** @file
-
 
34
 *  Loopback network interface implementation.
34
 */
35
 */
35
 
36
 
36
#include <async.h>
37
#include <async.h>
37
#include <errno.h>
38
#include <errno.h>
38
#include <stdio.h>
39
#include <stdio.h>
Line 52... Line 53...
52
#include "../../include/net_interface.h"
53
#include "../../include/net_interface.h"
53
 
54
 
54
#include "../netif.h"
55
#include "../netif.h"
55
#include "../netif_module.h"
56
#include "../netif_module.h"
56
 
57
 
-
 
58
/** Default maximum transmission unit.
-
 
59
 */
57
#define DEFAULT_MTU 1500
60
#define DEFAULT_MTU 1500
58
 
61
 
-
 
62
/** Default hardware address.
-
 
63
 */
59
#define DEFAULT_ADDR        "\0\0\0\0\0\0"
64
#define DEFAULT_ADDR        "\0\0\0\0\0\0"
-
 
65
 
-
 
66
/** Default address length.
-
 
67
 */
60
#define DEFAULT_ADDR_LEN    ( sizeof( DEFAULT_ADDR ) / sizeof( char ))
68
#define DEFAULT_ADDR_LEN    ( sizeof( DEFAULT_ADDR ) / sizeof( char ))
61
 
69
 
-
 
70
/** Loopback module name.
-
 
71
 */
62
#define NAME    "lo - loopback interface"
72
#define NAME    "lo - loopback interface"
63
 
73
 
-
 
74
/** Network interface global data.
-
 
75
 */
64
netif_globals_t netif_globals;
76
netif_globals_t netif_globals;
65
 
77
 
-
 
78
/** Loopback module global data.
-
 
79
 */
66
static struct lo_globals{
80
static struct lo_globals{
67
    unsigned int mtu;
81
    unsigned int mtu;
68
} lo_globals;
82
} lo_globals;
69
 
83
 
-
 
84
/** Changes the loopback state.
-
 
85
 *  @param device The device structure. Input parameter.
-
 
86
 *  @param state The new device state. Input parameter.
-
 
87
 *  @returns The new state if changed.
-
 
88
 *  @returns EOK otherwise.
-
 
89
 */
70
static int  change_state_message( device_ref device, device_state_t state );
90
int change_state_message( device_ref device, device_state_t state );
-
 
91
 
-
 
92
/** Creates and returns the loopback network interface structure.
-
 
93
 *  @param device_id The new devce identifier. Input parameter.
-
 
94
 *  @param device The device structure. Output parameter.
-
 
95
 *  @returns EOK on success.
-
 
96
 *  @returns EXDEV if one loopback network interface already exists.
-
 
97
 *  @returns ENOMEM if there is not enough memory left.
-
 
98
 */
71
static int  create( device_id_t device_id, device_ref * device );
99
int create( device_id_t device_id, device_ref * device );
-
 
100
 
-
 
101
/** Prints the module name.
-
 
102
 *  @see NAME
-
 
103
 */
72
void    module_print_name( void );
104
void    module_print_name( void );
73
 
105
 
74
int netif_specific_message( ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count ){
106
int netif_specific_message( ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count ){
75
    //TODO nil send message
107
    //TODO nil send message
76
    return ENOTSUP;
108
    return ENOTSUP;
Line 92... Line 124...
92
    ERROR_PROPAGATE( find_device( device_id, & device ));
124
    ERROR_PROPAGATE( find_device( device_id, & device ));
93
    memcpy( stats, ( device_stats_ref ) device->specific, sizeof( device_stats_t ));
125
    memcpy( stats, ( device_stats_ref ) device->specific, sizeof( device_stats_t ));
94
    return EOK;
126
    return EOK;
95
}
127
}
96
 
128
 
97
static int change_state_message( device_ref device, device_state_t state ){
129
int change_state_message( device_ref device, device_state_t state ){
98
    if( device->state != state ){
130
    if( device->state != state ){
99
        device->state = state;
131
        device->state = state;
100
        printf( "State changed to %s\n", ( state == NETIF_ACTIVE ) ? "ACTIVE" : "STOPPED" );
132
        printf( "State changed to %s\n", ( state == NETIF_ACTIVE ) ? "ACTIVE" : "STOPPED" );
101
        return state;
133
        return state;
102
    }
134
    }
103
    return EOK;
135
    return EOK;
104
}
136
}
105
 
137
 
106
static int create( device_id_t device_id, device_ref * device ){
138
int create( device_id_t device_id, device_ref * device ){
107
    int index;
139
    int index;
108
 
140
 
109
    if( device_map_count( & netif_globals.device_map ) > 0 ){
141
    if( device_map_count( & netif_globals.device_map ) > 0 ){
110
        return EXDEV;
142
        return EXDEV;
111
    }else{
143
    }else{