Subversion Repositories HelenOS

Rev

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

Rev 4197 Rev 4243
Line 45... Line 45...
45
#include "../../modules.h"
45
#include "../../modules.h"
46
 
46
 
47
#include "../../structures/measured_strings.h"
47
#include "../../structures/measured_strings.h"
48
#include "../../structures/packet/packet_client.h"
48
#include "../../structures/packet/packet_client.h"
49
 
49
 
-
 
50
#include "../../include/device.h"
-
 
51
 
50
#include "../netif.h"
52
#include "../netif.h"
51
#include "../netif_interface.h"
53
#include "../netif_interface.h"
52
 
54
 
53
#define DEFAULT_MTU 1500
55
#define DEFAULT_MTU 1500
54
 
56
 
Line 61... Line 63...
61
 
63
 
62
static struct lo_globals{
64
static struct lo_globals{
63
    int mtu;
65
    int mtu;
64
} lo_globals;
66
} lo_globals;
65
 
67
 
66
int change_state_message( device_id_t device_id, device_state_t state );
68
static int  change_state_message( device_id_t device_id, device_state_t state );
67
int create( device_id_t device_id, device_ref * device );
69
static int  create( device_id_t device_id, device_ref * device );
68
void    netif_print_name( void );
70
void    netif_print_name( void );
69
 
71
 
70
int specific_message( ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count ){
72
int netif_specific_message( ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count ){
-
 
73
    //TODO nil send message
71
    return ENOTSUP;
74
    return ENOTSUP;
72
}
75
}
73
 
76
 
74
int get_addr_message( device_id_t device_id, measured_string_ref address ){
77
int netif_get_addr_message( device_id_t device_id, measured_string_ref address ){
75
    if( ! address ) return EBADMEM;
78
    if( ! address ) return EBADMEM;
76
    address->value = DEFAULT_ADDR;
79
    address->value = DEFAULT_ADDR;
77
    address->length = DEFAULT_ADDR_LEN;
80
    address->length = DEFAULT_ADDR_LEN;
-
 
81
    return EOK;
78
}
82
}
79
 
83
 
80
int get_device_stats( device_id_t device_id, device_stats_ref stats ){
84
int netif_get_device_stats( device_id_t device_id, device_stats_ref stats ){
81
    ERROR_DECLARE;
85
    ERROR_DECLARE;
82
 
86
 
83
    device_ref  device;
87
    device_ref  device;
84
 
88
 
85
    if( ! stats ) return EBADMEM;
89
    if( ! stats ) return EBADMEM;
86
    ERROR_PROPAGATE( find_device( device_id, & device ));
90
    ERROR_PROPAGATE( find_device( device_id, & device ));
87
    memcpy( stats, ( device_stats_ref ) device->specific, sizeof( device_stats_t ));
91
    memcpy( stats, ( device_stats_ref ) device->specific, sizeof( device_stats_t ));
88
    return EOK;
92
    return EOK;
89
}
93
}
90
 
94
 
91
int change_state_message( device_id_t device_id, device_state_t state ){
95
static int change_state_message( device_id_t device_id, device_state_t state ){
92
    ERROR_DECLARE;
96
    ERROR_DECLARE;
93
 
97
 
94
    device_ref  device;
98
    device_ref  device;
95
 
99
 
96
    ERROR_PROPAGATE( find_device( device_id, & device ));
100
    ERROR_PROPAGATE( find_device( device_id, & device ));
Line 100... Line 104...
100
        printf( "\nState changed to %s", ( state == NETIF_ACTIVE ) ? "ACTIVE" : "STOPPED" );
104
        printf( "\nState changed to %s", ( state == NETIF_ACTIVE ) ? "ACTIVE" : "STOPPED" );
101
    }
105
    }
102
    return EOK;
106
    return EOK;
103
}
107
}
104
 
108
 
105
int create( device_id_t device_id, device_ref * device ){
109
static int create( device_id_t device_id, device_ref * device ){
106
    int index;
110
    int index;
107
 
111
 
108
    if( device_map_count( & netif_globals.device_map ) > 0 ){
112
    if( device_map_count( & netif_globals.device_map ) > 0 ){
109
        return EXDEV;
113
        return EXDEV;
110
    }else{
114
    }else{
Line 128... Line 132...
128
        }
132
        }
129
    }
133
    }
130
    return EOK;
134
    return EOK;
131
}
135
}
132
 
136
 
133
int initialize( void ){
137
int netif_initialize( void ){
134
    ipcarg_t    phonehash;
138
    ipcarg_t    phonehash;
135
 
139
 
136
    return REGISTER_ME( SERVICE_LO, & phonehash );
140
    return REGISTER_ME( SERVICE_LO, & phonehash );
137
}
141
}
138
 
142
 
139
void netif_print_name( void ){
143
void netif_print_name( void ){
140
    printf( "%s", NAME );
144
    printf( "%s", NAME );
141
}
145
}
142
 
146
 
143
int probe_auto_message( void ){
147
int netif_probe_auto_message( void ){
144
/*  ERROR_DECLARE;
148
/*  ERROR_DECLARE;
145
 
149
 
146
    device_ref  device;
150
    device_ref  device;
147
 
151
 
148
    ERROR_PROPAGATE( create( arg1, & device ));
152
    ERROR_PROPAGATE( create( arg1, & device ));
149
    ipc_call_sync_3_3( netif_globals.networking_phone, NET_NET_DEVICE, device->device_id, NULL, NULL, NULL, NULL, NULL );
153
    ipc_call_sync_3_3( netif_globals.networking_phone, NET_NET_DEVICE, device->device_id, NULL, NULL, NULL, NULL, NULL );
150
*/  return ENOTSUP;
154
*/  return ENOTSUP;
151
}
155
}
152
 
156
 
153
int probe_message( device_id_t device_id, int irq, int io ){
157
int netif_probe_message( device_id_t device_id, int irq, int io ){
154
    ERROR_DECLARE;
158
    ERROR_DECLARE;
155
 
159
 
156
    device_ref      device;
160
    device_ref      device;
157
    aid_t           message;
161
    aid_t           message;
158
    ipc_call_t      answer;
162
    ipc_call_t      answer;
Line 192... Line 196...
192
    // print the settings
196
    // print the settings
193
    printf("\nNew device registered:\n\tid\t= %d\n\tMTU\t= %d", device->device_id, lo_globals.mtu );
197
    printf("\nNew device registered:\n\tid\t= %d\n\tMTU\t= %d", device->device_id, lo_globals.mtu );
194
    return EOK;
198
    return EOK;
195
}
199
}
196
 
200
 
197
int send_message( device_id_t device_id, packet_t packet ){
201
int netif_send_message( device_id_t device_id, packet_t packet ){
198
    ERROR_DECLARE;
202
    ERROR_DECLARE;
199
 
203
 
200
    device_ref  device;
204
    device_ref  device;
201
    size_t      length;
205
    size_t      length;
202
    packet_t    next;
206
    packet_t    next;
Line 214... Line 218...
214
    }while( next );
218
    }while( next );
215
    nil_message( device, NET_NIL_RECEIVED, packet_get_id( packet ), PACKET_SELF );
219
    nil_message( device, NET_NIL_RECEIVED, packet_get_id( packet ), PACKET_SELF );
216
    return EOK;
220
    return EOK;
217
}
221
}
218
 
222
 
219
int start_message( device_id_t device_id ){
223
int netif_start_message( device_id_t device_id ){
220
    return change_state_message( device_id, NETIF_ACTIVE );
224
    return change_state_message( device_id, NETIF_ACTIVE );
221
}
225
}
222
 
226
 
223
int stop_message( device_id_t device_id ){
227
int netif_stop_message( device_id_t device_id ){
224
    return change_state_message( device_id, NETIF_STOPPED );
228
    return change_state_message( device_id, NETIF_STOPPED );
225
}
229
}
226
 
230
 
227
/** @}
231
/** @}
228
 */
232
 */