Rev 3886 | Rev 3912 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
| Rev 3886 | Rev 3901 | ||
|---|---|---|---|
| Line 43... | Line 43... | ||
| 43 | #include "../../err.h" |
43 | #include "../../err.h" |
| 44 | #include "../../messages.h" |
44 | #include "../../messages.h" |
| 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.h" |
48 | #include "../../structures/packet/packet_client.h" |
| 49 | 49 | ||
| 50 | #include "../netif.h" |
50 | #include "../netif.h" |
| 51 | 51 | ||
| 52 | #define DEFAULT_MTU 1500 |
52 | #define DEFAULT_MTU 1500 |
| 53 | 53 | ||
| Line 161... | Line 161... | ||
| 161 | int send_message( device_id_t device_id, packet_t packet ){ |
161 | int send_message( device_id_t device_id, packet_t packet ){ |
| 162 | ERROR_DECLARE; |
162 | ERROR_DECLARE; |
| 163 | 163 | ||
| 164 | device_ref device; |
164 | device_ref device; |
| 165 | size_t length; |
165 | size_t length; |
| 166 | aid_t message; |
- | |
| 167 | ipc_call_t answer; |
- | |
| 168 | ipcarg_t result; |
- | |
| 169 | packet_t received; |
166 | packet_t received; |
| 170 | 167 | ||
| 171 | ERROR_PROPAGATE( find_device( device_id, & device )); |
168 | ERROR_PROPAGATE( find_device( device_id, & device )); |
| 172 | if( device->state != NETIF_ACTIVE ) return EPERM; |
169 | if( device->state != NETIF_ACTIVE ) return EPERM; |
| 173 | ++ device->stats.tx_packets; |
170 | ++ device->stats.tx_packets; |
| 174 | ++ device->stats.rx_packets; |
171 | ++ device->stats.rx_packets; |
| 175 | length = packet_get_data_length( packet ); |
172 | length = packet_get_data_length( packet ); |
| 176 | device->stats.tx_bytes += length; |
173 | device->stats.tx_bytes += length; |
| 177 | device->stats.rx_bytes += length; |
174 | device->stats.rx_bytes += length; |
| 178 | received = packet_copy( packet ); |
175 | received = packet_copy( netif_globals.networking_phone, SERVICE_LO, packet ); |
| 179 | packet_destroy( packet ); |
176 | packet_release( netif_globals.networking_phone, packet_get_id( packet )); |
| 180 | if( ! received ){ |
177 | if( ! received ){ |
| 181 | ++ device->stats.rx_dropped; |
178 | ++ device->stats.rx_dropped; |
| 182 | return EOK; |
179 | return EOK; |
| 183 | } |
180 | } |
| - | 181 | async_msg_2( device->nil_phone, NET_NIL_RECEIVED, device_id, packet_get_id( received )); |
|
| 184 | 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 ); |
| 185 | if( ERROR_OCCURED( packet_send( received, device->nil_phone ))){ |
183 | // if( ERROR_OCCURED( packet_send( received, device->nil_phone ))){ |
| 186 | ++ device->stats.rx_dropped; |
184 | // ++ device->stats.rx_dropped; |
| 187 | } |
185 | // } |
| 188 | async_wait_for( message, & result ); |
- | |
| 189 | if( result != EOK ) ++ device->stats.rx_dropped; |
186 | // if( result != EOK ) ++ device->stats.rx_dropped; |
| 190 | return EOK; |
187 | return EOK; |
| 191 | } |
188 | } |
| 192 | 189 | ||
| 193 | int start_message( device_id_t device_id ){ |
190 | int start_message( device_id_t device_id ){ |
| 194 | return change_state_message( device_id, NETIF_ACTIVE ); |
191 | return change_state_message( device_id, NETIF_ACTIVE ); |