vfs: check userland buffers before reading them.
[haiku.git] / headers / private / net / net_device.h
blob64e119501ac298ad503a9892763b3e61fc33594b
1 /*
2 * Copyright 2006-2010, 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
9 #include <net/if.h>
11 #include <module.h>
14 typedef struct net_buffer net_buffer;
17 struct net_hardware_address {
18 uint8 data[64];
19 uint8 length;
22 typedef struct net_device {
23 struct net_device_module_info* module;
25 char name[IF_NAMESIZE];
26 uint32 index;
27 uint32 flags; // IFF_LOOPBACK, ...
28 uint32 type; // IFT_ETHER, ...
29 size_t mtu;
30 uint32 media;
31 uint64 link_speed;
32 uint32 link_quality;
33 size_t header_length;
35 struct net_hardware_address address;
37 struct ifreq_stats stats;
38 } net_device;
41 struct net_device_module_info {
42 struct module_info info;
44 status_t (*init_device)(const char* name, net_device** _device);
45 status_t (*uninit_device)(net_device* device);
47 status_t (*up)(net_device* device);
48 void (*down)(net_device* device);
50 status_t (*control)(net_device* device, int32 op, void* argument,
51 size_t length);
53 status_t (*send_data)(net_device* device, net_buffer* buffer);
54 status_t (*receive_data)(net_device* device, net_buffer** _buffer);
56 status_t (*set_mtu)(net_device* device, size_t mtu);
57 status_t (*set_promiscuous)(net_device* device, bool promiscuous);
58 status_t (*set_media)(net_device* device, uint32 media);
60 status_t (*add_multicast)(net_device* device,
61 const struct sockaddr* address);
62 status_t (*remove_multicast)(net_device* device,
63 const struct sockaddr* address);
67 #endif // NET_DEVICE_H