Rev 4582 | Rev 4703 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
| Rev 4582 | Rev 4696 | ||
|---|---|---|---|
| Line 56... | Line 56... | ||
| 56 | #include "../../nil/nil_messages.h" |
56 | #include "../../nil/nil_messages.h" |
| 57 | 57 | ||
| 58 | #include "../netif.h" |
58 | #include "../netif.h" |
| 59 | #include "../netif_module.h" |
59 | #include "../netif_module.h" |
| 60 | 60 | ||
| 61 | /** Default maximum transmission unit. |
- | |
| 62 | */ |
- | |
| 63 | #define DEFAULT_MTU 1500 |
- | |
| 64 | - | ||
| 65 | /** Default hardware address. |
61 | /** Default hardware address. |
| 66 | */ |
62 | */ |
| 67 | #define DEFAULT_ADDR "\0\0\0\0\0\0" |
63 | #define DEFAULT_ADDR "\0\0\0\0\0\0" |
| 68 | 64 | ||
| 69 | /** Default address length. |
65 | /** Default address length. |
| Line 76... | Line 72... | ||
| 76 | 72 | ||
| 77 | /** Network interface global data. |
73 | /** Network interface global data. |
| 78 | */ |
74 | */ |
| 79 | netif_globals_t netif_globals; |
75 | netif_globals_t netif_globals; |
| 80 | 76 | ||
| 81 | /** Loopback module global data. |
- | |
| 82 | */ |
- | |
| 83 | static struct lo_globals{ |
- | |
| 84 | unsigned int mtu; |
- | |
| 85 | } lo_globals; |
- | |
| 86 | - | ||
| 87 | /** Changes the loopback state. |
77 | /** Changes the loopback state. |
| 88 | * @param device The device structure. Input parameter. |
78 | * @param device The device structure. Input parameter. |
| 89 | * @param state The new device state. Input parameter. |
79 | * @param state The new device state. Input parameter. |
| 90 | * @returns The new state if changed. |
80 | * @returns The new state if changed. |
| 91 | * @returns EOK otherwise. |
81 | * @returns EOK otherwise. |
| Line 105... | Line 95... | ||
| 105 | * @see NAME |
95 | * @see NAME |
| 106 | */ |
96 | */ |
| 107 | void module_print_name( void ); |
97 | void module_print_name( void ); |
| 108 | 98 | ||
| 109 | int netif_specific_message( ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count ){ |
99 | int netif_specific_message( ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count ){ |
| 110 | switch( IPC_GET_METHOD( * call )){ |
- | |
| 111 | case NET_NIL_PACKET_SPACE: |
- | |
| 112 | * IPC_SET_ADDR( answer ) = 0; |
- | |
| 113 | * IPC_SET_PREFIX( answer ) = 0; |
- | |
| 114 | * IPC_SET_CONTENT( answer ) = lo_globals.mtu; |
- | |
| 115 | * IPC_SET_SUFFIX( answer ) = 0; |
- | |
| 116 | * answer_count = 4; |
- | |
| 117 | return EOK; |
- | |
| 118 | default: |
- | |
| 119 | return ENOTSUP; |
100 | return ENOTSUP; |
| 120 | } |
- | |
| 121 | } |
101 | } |
| 122 | 102 | ||
| 123 | int netif_get_addr_message( device_id_t device_id, measured_string_ref address ){ |
103 | int netif_get_addr_message( device_id_t device_id, measured_string_ref address ){ |
| 124 | if( ! address ) return EBADMEM; |
104 | if( ! address ) return EBADMEM; |
| 125 | address->value = DEFAULT_ADDR; |
105 | address->value = DEFAULT_ADDR; |
| Line 197... | Line 177... | ||
| 197 | 177 | ||
| 198 | int netif_probe_message( device_id_t device_id, int irq, int io ){ |
178 | int netif_probe_message( device_id_t device_id, int irq, int io ){ |
| 199 | ERROR_DECLARE; |
179 | ERROR_DECLARE; |
| 200 | 180 | ||
| 201 | device_ref device; |
181 | device_ref device; |
| 202 | measured_string_t names[ 1 ] = {{ "MTU", 3 }}; |
- | |
| 203 | measured_string_ref configuration; |
- | |
| 204 | size_t count = sizeof( names ) / sizeof( measured_string_t ); |
- | |
| 205 | char * data; |
- | |
| 206 | 182 | ||
| 207 | configuration = & names[ 0 ]; |
- | |
| 208 | // create a new device |
183 | // create a new device |
| 209 | ERROR_PROPAGATE( create( device_id, & device )); |
184 | ERROR_PROPAGATE( create( device_id, & device )); |
| 210 | // get configuration |
- | |
| 211 | ERROR_PROPAGATE( net_get_device_conf_req( netif_globals.net_phone, device->device_id, & configuration, count, & data )); |
- | |
| 212 | // MTU is the first one |
- | |
| 213 | if( configuration && configuration[ 0 ].value ){ |
- | |
| 214 | lo_globals.mtu = strtoul( configuration[ 0 ].value, NULL, 0 ); |
- | |
| 215 | net_free_settings( configuration, data ); |
- | |
| 216 | }else{ |
- | |
| 217 | lo_globals.mtu = DEFAULT_MTU; |
- | |
| 218 | } |
- | |
| 219 | // print the settings |
185 | // print the settings |
| 220 | printf("New device registered:\n\tid\t= %d\n\tMTU\t= %d\n", device->device_id, lo_globals.mtu ); |
186 | printf("New device created:\n\tid\t= %d\n", device->device_id ); |
| 221 | return EOK; |
187 | return EOK; |
| 222 | } |
188 | } |
| 223 | 189 | ||
| 224 | int netif_send_message( device_id_t device_id, packet_t packet, services_t sender ){ |
190 | int netif_send_message( device_id_t device_id, packet_t packet, services_t sender ){ |
| 225 | ERROR_DECLARE; |
191 | ERROR_DECLARE; |