Subversion Repositories HelenOS

Rev

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

Rev 3991 Rev 4163
Line 196... Line 196...
196
    rwlock_write_lock( & arp_globals.lock );
196
    rwlock_write_lock( & arp_globals.lock );
197
    // an existing device?
197
    // an existing device?
198
    device = arp_cache_find( & arp_globals.cache, device_id );
198
    device = arp_cache_find( & arp_globals.cache, device_id );
199
    if( device ){
199
    if( device ){
200
        if( device->service != service ){
200
        if( device->service != service ){
-
 
201
            printf( "\nDevice %d already exists", device->device_id );
201
            rwlock_write_unlock( & arp_globals.lock );
202
            rwlock_write_unlock( & arp_globals.lock );
202
            return EEXIST;
203
            return EEXIST;
203
        }
204
        }
204
        proto = arp_protos_find( & device->protos, protocol );
205
        proto = arp_protos_find( & device->protos, protocol );
205
        if( proto ){
206
        if( proto ){
Line 216... Line 217...
216
                rwlock_write_unlock( & arp_globals.lock );
217
                rwlock_write_unlock( & arp_globals.lock );
217
                free( proto );
218
                free( proto );
218
                return ERROR_CODE;
219
                return ERROR_CODE;
219
            }
220
            }
220
        }
221
        }
221
        return EOK;
222
        printf( "\nCache of the existing device %d cleaned", device->device_id );
222
    }else{
223
    }else{
223
        // create a new device
224
        // create a new device
224
        device = ( arp_device_ref ) malloc( sizeof( arp_device_t ));
225
        device = ( arp_device_ref ) malloc( sizeof( arp_device_t ));
225
        if( ! device ){
226
        if( ! device ){
226
            rwlock_write_unlock( & arp_globals.lock );
227
            rwlock_write_unlock( & arp_globals.lock );
Line 289... Line 290...
289
            free( device->broadcast_data );
290
            free( device->broadcast_data );
290
            arp_protos_destroy( & device->protos );
291
            arp_protos_destroy( & device->protos );
291
            free( device );
292
            free( device );
292
            return ERROR_CODE;
293
            return ERROR_CODE;
293
        }
294
        }
-
 
295
        printf( "\nNew device registered:\n\tid\t= %d\n\ttype\t= %x\n\tservice\t= %d", device->device_id, device->hardware, device->service );
294
    }
296
    }
295
    rwlock_write_unlock( & arp_globals.lock );
297
    rwlock_write_unlock( & arp_globals.lock );
296
    return EOK;
298
    return EOK;
297
}
299
}
298
 
300
 
Line 440... Line 442...
440
    if( ! device ){
442
    if( ! device ){
441
        rwlock_write_unlock( & arp_globals.lock );
443
        rwlock_write_unlock( & arp_globals.lock );
442
        return ENOENT;
444
        return ENOENT;
443
    }
445
    }
444
    clear_device( device );
446
    clear_device( device );
-
 
447
    printf( "\nDevice %d cleared", device_id );
445
    rwlock_write_unlock( & arp_globals.lock );
448
    rwlock_write_unlock( & arp_globals.lock );
446
    return EOK;
449
    return EOK;
447
}
450
}
448
 
451
 
449
void clear_device( arp_device_ref device ){
452
void clear_device( arp_device_ref device ){
Line 474... Line 477...
474
            if( device->addr_data ) free( device->addr_data );
477
            if( device->addr_data ) free( device->addr_data );
475
            if( device->broadcast_data ) free( device->broadcast_data );
478
            if( device->broadcast_data ) free( device->broadcast_data );
476
        }
479
        }
477
    }
480
    }
478
    arp_cache_clear( & arp_globals.cache );
481
    arp_cache_clear( & arp_globals.cache );
479
    rwlock_write_lock( & arp_globals.lock );
482
    rwlock_write_unlock( & arp_globals.lock );
-
 
483
    printf( "\nCache cleaned" );
480
    return EOK;
484
    return EOK;
481
}
485
}
482
 
486
 
483
int arp_message( ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count ){
487
int arp_message( ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count ){
484
    ERROR_DECLARE;
488
    ERROR_DECLARE;