2006-08-08 17:07:07 +04:00
|
|
|
/*
|
2010-08-03 15:23:03 +04:00
|
|
|
* Copyright 2006-2010, Haiku, Inc. All Rights Reserved.
|
2006-08-08 17:07:07 +04:00
|
|
|
* Distributed under the terms of the MIT License.
|
|
|
|
*/
|
|
|
|
#ifndef NET_DEVICE_H
|
|
|
|
#define NET_DEVICE_H
|
|
|
|
|
|
|
|
|
2010-08-03 15:23:03 +04:00
|
|
|
#include <net/if.h>
|
|
|
|
|
2006-08-08 17:07:07 +04:00
|
|
|
#include <module.h>
|
|
|
|
|
2010-08-03 15:23:03 +04:00
|
|
|
|
|
|
|
typedef struct net_buffer net_buffer;
|
2006-08-08 17:07:07 +04:00
|
|
|
|
|
|
|
|
|
|
|
struct net_hardware_address {
|
|
|
|
uint8 data[64];
|
|
|
|
uint8 length;
|
|
|
|
};
|
|
|
|
|
2010-08-03 15:23:03 +04:00
|
|
|
typedef struct net_device {
|
|
|
|
struct net_device_module_info* module;
|
2006-08-08 17:07:07 +04:00
|
|
|
|
|
|
|
char name[IF_NAMESIZE];
|
|
|
|
uint32 index;
|
|
|
|
uint32 flags; // IFF_LOOPBACK, ...
|
|
|
|
uint32 type; // IFT_ETHER, ...
|
|
|
|
size_t mtu;
|
|
|
|
uint32 media;
|
2007-04-04 13:41:04 +04:00
|
|
|
uint64 link_speed;
|
|
|
|
uint32 link_quality;
|
2006-08-08 17:07:07 +04:00
|
|
|
size_t header_length;
|
|
|
|
|
|
|
|
struct net_hardware_address address;
|
|
|
|
|
2008-07-14 22:47:02 +04:00
|
|
|
struct ifreq_stats stats;
|
2010-08-03 15:23:03 +04:00
|
|
|
} net_device;
|
|
|
|
|
2006-08-08 17:07:07 +04:00
|
|
|
|
|
|
|
struct net_device_module_info {
|
|
|
|
struct module_info info;
|
|
|
|
|
2010-08-03 15:23:03 +04:00
|
|
|
status_t (*init_device)(const char* name, net_device** _device);
|
|
|
|
status_t (*uninit_device)(net_device* device);
|
2006-08-08 17:07:07 +04:00
|
|
|
|
2010-08-03 15:23:03 +04:00
|
|
|
status_t (*up)(net_device* device);
|
|
|
|
void (*down)(net_device* device);
|
2006-08-08 17:07:07 +04:00
|
|
|
|
2010-08-03 15:23:03 +04:00
|
|
|
status_t (*control)(net_device* device, int32 op, void* argument,
|
|
|
|
size_t length);
|
2006-08-08 17:07:07 +04:00
|
|
|
|
2010-08-03 15:23:03 +04:00
|
|
|
status_t (*send_data)(net_device* device, net_buffer* buffer);
|
|
|
|
status_t (*receive_data)(net_device* device, net_buffer** _buffer);
|
2006-08-08 17:07:07 +04:00
|
|
|
|
2010-08-03 15:23:03 +04:00
|
|
|
status_t (*set_mtu)(net_device* device, size_t mtu);
|
|
|
|
status_t (*set_promiscuous)(net_device* device, bool promiscuous);
|
|
|
|
status_t (*set_media)(net_device* device, uint32 media);
|
2006-08-08 17:07:07 +04:00
|
|
|
|
2010-08-03 15:23:03 +04:00
|
|
|
status_t (*add_multicast)(net_device* device,
|
|
|
|
const struct sockaddr* address);
|
|
|
|
status_t (*remove_multicast)(net_device* device,
|
|
|
|
const struct sockaddr* address);
|
2006-08-08 17:07:07 +04:00
|
|
|
};
|
|
|
|
|
2010-08-03 15:23:03 +04:00
|
|
|
|
2006-08-08 17:07:07 +04:00
|
|
|
#endif // NET_DEVICE_H
|