Subversion Repositories HelenOS

Rev

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

Rev 4582 Rev 4695
Line 125... Line 125...
125
/** Clears the device specific data.
125
/** Clears the device specific data.
126
 *  @param device The device specific data.
126
 *  @param device The device specific data.
127
 */
127
 */
128
void    clear_device( arp_device_ref device );
128
void    clear_device( arp_device_ref device );
129
 
129
 
-
 
130
/** Updates the device content length according to the new MTU value.
-
 
131
 *  @param device_id The device identifier. Input parameter.
-
 
132
 *  @param mtu The new mtu value. Input parameter.
-
 
133
 *  @returns EOK on success.
-
 
134
 */
-
 
135
int arp_mtu_changed_msg( device_id_t device_id, size_t mtu );
-
 
136
 
130
DEVICE_MAP_IMPLEMENT( arp_cache, arp_device_t )
137
DEVICE_MAP_IMPLEMENT( arp_cache, arp_device_t )
131
 
138
 
132
INT_MAP_IMPLEMENT( arp_protos, arp_proto_t )
139
INT_MAP_IMPLEMENT( arp_protos, arp_proto_t )
133
 
140
 
134
GENERIC_CHAR_MAP_IMPLEMENT( arp_addr, measured_string_t )
141
GENERIC_CHAR_MAP_IMPLEMENT( arp_addr, measured_string_t )
Line 150... Line 157...
150
    printf( "Device %d cleared\n", device_id );
157
    printf( "Device %d cleared\n", device_id );
151
    fibril_rwlock_write_unlock( & arp_globals.lock );
158
    fibril_rwlock_write_unlock( & arp_globals.lock );
152
    return EOK;
159
    return EOK;
153
}
160
}
154
 
161
 
-
 
162
int arp_clear_address_req( int arp_phone, device_id_t device_id, services_t protocol, measured_string_ref address ){
-
 
163
    arp_device_ref  device;
-
 
164
    arp_proto_ref   proto;
-
 
165
 
-
 
166
    fibril_rwlock_write_lock( & arp_globals.lock );
-
 
167
    device = arp_cache_find( & arp_globals.cache, device_id );
-
 
168
    if( ! device ){
-
 
169
        fibril_rwlock_write_unlock( & arp_globals.lock );
-
 
170
        return ENOENT;
-
 
171
    }
-
 
172
    proto = arp_protos_find( & device->protos, protocol );
-
 
173
    if( ! proto ){
-
 
174
        fibril_rwlock_write_unlock( & arp_globals.lock );
-
 
175
        return ENOENT;
-
 
176
    }
-
 
177
    arp_addr_exclude( & proto->addresses, address->value, address->length );
-
 
178
    fibril_rwlock_write_unlock( & arp_globals.lock );
-
 
179
    return EOK;
-
 
180
}
-
 
181
 
155
int arp_clean_cache_req( int arp_phone ){
182
int arp_clean_cache_req( int arp_phone ){
156
    int             count;
183
    int             count;
157
    arp_device_ref  device;
184
    arp_device_ref  device;
158
 
185
 
159
    fibril_rwlock_write_lock( & arp_globals.lock );
186
    fibril_rwlock_write_lock( & arp_globals.lock );
Line 463... Line 490...
463
 
490
 
464
int arp_connect_module( services_t service ){
491
int arp_connect_module( services_t service ){
465
    return EOK;
492
    return EOK;
466
}
493
}
467
 
494
 
-
 
495
int arp_mtu_changed_msg( device_id_t device_id, size_t mtu ){
-
 
496
    arp_device_ref  device;
-
 
497
 
-
 
498
    fibril_rwlock_write_lock( & arp_globals.lock );
-
 
499
    device = arp_cache_find( & arp_globals.cache, device_id );
-
 
500
    if( ! device ){
-
 
501
        fibril_rwlock_write_unlock( & arp_globals.lock );
-
 
502
        return ENOENT;
-
 
503
    }
-
 
504
    device->content = mtu;
-
 
505
    printf( "arp - device %d changed mtu to %d\n\n", device_id, mtu );
-
 
506
    fibril_rwlock_write_unlock( & arp_globals.lock );
-
 
507
    return EOK;
-
 
508
}
-
 
509
 
468
int arp_message( ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count ){
510
int arp_message( ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count ){
469
    ERROR_DECLARE;
511
    ERROR_DECLARE;
470
 
512
 
471
    measured_string_ref address;
513
    measured_string_ref address;
472
    measured_string_ref translation;
514
    measured_string_ref translation;
Line 499... Line 541...
499
            ERROR_CODE = measured_strings_reply( translation, 1 );
541
            ERROR_CODE = measured_strings_reply( translation, 1 );
500
            fibril_rwlock_read_unlock( & arp_globals.lock );
542
            fibril_rwlock_read_unlock( & arp_globals.lock );
501
            return ERROR_CODE;
543
            return ERROR_CODE;
502
        case NET_ARP_CLEAR_DEVICE:
544
        case NET_ARP_CLEAR_DEVICE:
503
            return arp_clear_device_req( 0, IPC_GET_DEVICE( call ));
545
            return arp_clear_device_req( 0, IPC_GET_DEVICE( call ));
-
 
546
        case NET_ARP_CLEAR_ADDRESS:
-
 
547
            ERROR_PROPAGATE( measured_strings_receive( & address, & data, 1 ));
-
 
548
            arp_clear_address_req( 0, IPC_GET_DEVICE( call ), IPC_GET_SERVICE( call ), address );
-
 
549
            free( address );
-
 
550
            free( data );
-
 
551
            return EOK;
504
        case NET_ARP_CLEAN_CACHE:
552
        case NET_ARP_CLEAN_CACHE:
505
            return arp_clean_cache_req( 0 );
553
            return arp_clean_cache_req( 0 );
506
        case NET_IL_DEVICE_STATE:
554
        case NET_IL_DEVICE_STATE:
507
            // do nothing - keep the cache
555
            // do nothing - keep the cache
508
            return EOK;
556
            return EOK;
Line 516... Line 564...
516
                    packet = next;
564
                    packet = next;
517
                }while( packet );
565
                }while( packet );
518
                fibril_rwlock_read_unlock( & arp_globals.lock );
566
                fibril_rwlock_read_unlock( & arp_globals.lock );
519
            }
567
            }
520
            return ERROR_CODE;
568
            return ERROR_CODE;
-
 
569
        case NET_IL_MTU_CHANGED:
-
 
570
            return arp_mtu_changed_msg( IPC_GET_DEVICE( call ), IPC_GET_MTU( call ));
521
    }
571
    }
522
    return ENOTSUP;
572
    return ENOTSUP;
523
}
573
}
524
 
574
 
525
/** @}
575
/** @}