xref: /haiku/headers/private/net/net_device.h (revision f23596149e0d173463f70629581aa10cc305d32e)
1 /*
2  * Copyright 2006, Haiku, Inc. All Rights Reserved.
3  * Distributed under the terms of the MIT License.
4  */
5 #ifndef NET_DEVICE_H
6 #define NET_DEVICE_H
7 
8 
9 #include <module.h>
10 
11 #include <net/if.h>
12 
13 
14 struct net_hardware_address {
15 	uint8	data[64];
16 	uint8	length;
17 };
18 
19 struct net_device {
20 	struct net_device_module_info *module;
21 
22 	char	name[IF_NAMESIZE];
23 	uint32	index;
24 	uint32	flags;		// IFF_LOOPBACK, ...
25 	uint32	type;		// IFT_ETHER, ...
26 	size_t	mtu;
27 	uint32	media;
28 	size_t	header_length;
29 
30 	struct net_hardware_address address;
31 
32 	ifreq_stats stats;
33 };
34 
35 struct net_device_module_info {
36 	struct module_info info;
37 
38 	status_t	(*init_device)(const char *name, struct net_device **_device);
39 	status_t	(*uninit_device)(struct net_device *device);
40 
41 	status_t	(*up)(struct net_device *device);
42 	void		(*down)(struct net_device *device);
43 
44 	status_t	(*control)(struct net_device *device, int32 op,
45 					void *argument, size_t length);
46 
47 	status_t	(*send_data)(struct net_device *device, struct net_buffer *buffer);
48 	status_t	(*receive_data)(struct net_device *device, struct net_buffer **_buffer);
49 
50 	status_t	(*set_mtu)(struct net_device *device, size_t mtu);
51 	status_t	(*set_promiscuous)(struct net_device *device, bool promiscuous);
52 	status_t	(*set_media)(struct net_device *device, uint32 media);
53 
54 	status_t	(*get_multicast_addrs)(struct net_device *device,
55 					net_hardware_address **addressArray, uint32 count);
56 	status_t	(*set_multicast_addrs)(struct net_device *device,
57 					const net_hardware_address **addressArray, uint32 count);
58 };
59 
60 #endif	// NET_DEVICE_H
61