2 * Copyright 2006-2017, Haiku, Inc. All Rights Reserved.
3 * Distributed under the terms of the MIT License.
6 * Axel Dörfler, axeld@pinc-software.de
8 #ifndef DEVICE_INTERFACES_H
9 #define DEVICE_INTERFACES_H
12 #include <net_datalink.h>
13 #include <net_stack.h>
15 #include <util/DoublyLinkedList.h>
18 struct net_device_handler
: DoublyLinkedListLinkImpl
<net_device_handler
> {
19 net_receive_func func
;
24 typedef DoublyLinkedList
<net_device_handler
> DeviceHandlerList
;
26 typedef DoublyLinkedList
<net_device_monitor
,
27 DoublyLinkedListCLink
<net_device_monitor
> > DeviceMonitorList
;
29 struct net_device_interface
: DoublyLinkedListLinkImpl
<net_device_interface
> {
30 struct net_device
* device
;
31 thread_id reader_thread
;
33 // a device can be brought up by more than one interface
37 net_deframe_func deframe_func
;
38 int32 deframe_ref_count
;
41 recursive_lock monitor_lock
;
42 DeviceMonitorList monitor_funcs
;
44 DeviceHandlerList receive_funcs
;
45 recursive_lock receive_lock
;
47 thread_id consumer_thread
;
48 net_fifo receive_queue
;
51 typedef DoublyLinkedList
<net_device_interface
> DeviceInterfaceList
;
55 net_device_interface
* acquire_device_interface(net_device_interface
* interface
);
56 void get_device_interface_address(net_device_interface
* interface
,
58 uint32
count_device_interfaces();
59 status_t
list_device_interfaces(void* buffer
, size_t* _bufferSize
);
60 void put_device_interface(struct net_device_interface
* interface
);
61 struct net_device_interface
* get_device_interface(uint32 index
);
62 struct net_device_interface
* get_device_interface(const char* name
,
64 void device_interface_monitor_receive(net_device_interface
* interface
,
66 status_t
up_device_interface(net_device_interface
* interface
);
67 void down_device_interface(net_device_interface
* interface
);
70 status_t
unregister_device_deframer(net_device
* device
);
71 status_t
register_device_deframer(net_device
* device
,
72 net_deframe_func deframeFunc
);
73 status_t
register_domain_device_handler(struct net_device
* device
, int32 type
,
74 struct net_domain
* domain
);
75 status_t
register_device_handler(struct net_device
* device
, int32 type
,
76 net_receive_func receiveFunc
, void* cookie
);
77 status_t
unregister_device_handler(struct net_device
* device
, int32 type
);
78 status_t
register_device_monitor(struct net_device
* device
,
79 struct net_device_monitor
* monitor
);
80 status_t
unregister_device_monitor(struct net_device
* device
,
81 struct net_device_monitor
* monitor
);
82 status_t
device_link_changed(net_device
* device
);
83 status_t
device_removed(net_device
* device
);
84 status_t
device_enqueue_buffer(net_device
* device
, net_buffer
* buffer
);
86 status_t
init_device_interfaces();
87 status_t
uninit_device_interfaces();
90 #endif // DEVICE_INTERFACES_H