summaryrefslogtreecommitdiff
path: root/src/drivers/net/network.c
blob: fe7ecc11457d48cae551249b0b723ec1a9945846 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#include "network.h"

#include "string.h"
#include "kernel.h"

#undef DEBUG

static network_vtable_t const network_vtable = {
	{
	network_activate,
	network_deactivate,
	network_deinit,
	network_print_info
	}
};

void network_init( network_t *network, interrupt_t *interrupt, void *context )
{
	memset( network, 0, sizeof( network_t ) );

	driver_init( (driver_t *)network, DRIVER_TYPE_NETWORK, interrupt, context );

	((driver_t *)network)->vtable = (driver_vtable_t *)&network_vtable;
}

void network_activate( void *obj )
{
	kernel_panic( "Calling abstract method in file %s at line %d.", __FILE__, __LINE__ ); 
}

void network_deactivate( void *obj )
{
	kernel_panic( "Calling abstract method in file %s at line %d.", __FILE__, __LINE__ ); 
}

void network_deinit( void *obj )
{
	// nothing to be done
}

void network_print_info( void *obj )
{
	kernel_panic( "Calling abstract method in file %s at line %d.", __FILE__, __LINE__ ); 
}

char *network_mac_to_string( network_mac_address_t mac, char *buf, size_t buflen )
{
	snprintf( buf, buflen, "%X:%X:%X:%X:%X:%X",
		mac.byte[0], mac.byte[1], mac.byte[2],
		mac.byte[3], mac.byte[4], mac.byte[5] );

	return buf;
}