2 * Copyright 2006-2010, 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
36 net_deframe_func deframe_func
;
37 int32 deframe_ref_count
;
40 recursive_lock monitor_lock
;
41 DeviceMonitorList monitor_funcs
;
43 DeviceHandlerList receive_funcs
;
44 recursive_lock receive_lock
;
46 thread_id consumer_thread
;
47 net_fifo receive_queue
;
50 typedef DoublyLinkedList
<net_device_interface
> DeviceInterfaceList
;
54 net_device_interface
* acquire_device_interface(net_device_interface
* interface
);
55 void get_device_interface_address(net_device_interface
* interface
,
57 uint32
count_device_interfaces();
58 status_t
list_device_interfaces(void* buffer
, size_t* _bufferSize
);
59 void put_device_interface(struct net_device_interface
* interface
);
60 struct net_device_interface
* get_device_interface(uint32 index
);
61 struct net_device_interface
* get_device_interface(const char* name
,
63 void device_interface_monitor_receive(net_device_interface
* interface
,
65 status_t
up_device_interface(net_device_interface
* interface
);
66 void down_device_interface(net_device_interface
* interface
);
69 status_t
unregister_device_deframer(net_device
* device
);
70 status_t
register_device_deframer(net_device
* device
,
71 net_deframe_func deframeFunc
);
72 status_t
register_domain_device_handler(struct net_device
* device
, int32 type
,
73 struct net_domain
* domain
);
74 status_t
register_device_handler(struct net_device
* device
, int32 type
,
75 net_receive_func receiveFunc
, void* cookie
);
76 status_t
unregister_device_handler(struct net_device
* device
, int32 type
);
77 status_t
register_device_monitor(struct net_device
* device
,
78 struct net_device_monitor
* monitor
);
79 status_t
unregister_device_monitor(struct net_device
* device
,
80 struct net_device_monitor
* monitor
);
81 status_t
device_link_changed(net_device
* device
);
82 status_t
device_removed(net_device
* device
);
83 status_t
device_enqueue_buffer(net_device
* device
, net_buffer
* buffer
);
85 status_t
init_device_interfaces();
86 status_t
uninit_device_interfaces();
89 #endif // DEVICE_INTERFACES_H