xref: /haiku/headers/private/net/net_device.h (revision 893988af824e65e49e55f517b157db8386e8002b)
1 /*
2  * Copyright 2006-2007, 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 	uint64	link_speed;
29 	uint32	link_quality;
30 	size_t	header_length;
31 
32 	struct net_hardware_address address;
33 
34 	struct ifreq_stats stats;
35 };
36 
37 struct net_device_module_info {
38 	struct module_info info;
39 
40 	status_t	(*init_device)(const char *name, struct net_device **_device);
41 	status_t	(*uninit_device)(struct net_device *device);
42 
43 	status_t	(*up)(struct net_device *device);
44 	void		(*down)(struct net_device *device);
45 
46 	status_t	(*control)(struct net_device *device, int32 op,
47 					void *argument, size_t length);
48 
49 	status_t	(*send_data)(struct net_device *device,
50 					struct net_buffer *buffer);
51 	status_t	(*receive_data)(struct net_device *device,
52 					struct net_buffer **_buffer);
53 
54 	status_t	(*set_mtu)(struct net_device *device, size_t mtu);
55 	status_t	(*set_promiscuous)(struct net_device *device, bool promiscuous);
56 	status_t	(*set_media)(struct net_device *device, uint32 media);
57 
58 	status_t	(*add_multicast)(struct net_device *device,
59 					const struct sockaddr *address);
60 	status_t	(*remove_multicast)(struct net_device *device,
61 					const struct sockaddr *address);
62 };
63 
64 #endif	// NET_DEVICE_H
65