usb_ecm: Use the current configuration instead of a fixed one.
[haiku.git] / src / add-ons / kernel / drivers / network / usb_ecm / ECMDevice.h
blobbfbd4e4b35901d0d038199051a0ecd069f7ae956
1 /*
2 Driver for USB Ethernet Control Model devices
3 Copyright (C) 2008 Michael Lotz <mmlr@mlotz.ch>
4 Distributed under the terms of the MIT license.
5 */
6 #ifndef _USB_ECM_DEVICE_H_
7 #define _USB_ECM_DEVICE_H_
9 #include "Driver.h"
11 class ECMDevice {
12 public:
13 ECMDevice(usb_device device);
14 ~ECMDevice();
16 status_t InitCheck() { return fStatus; };
18 status_t Open();
19 bool IsOpen() { return fOpen; };
21 status_t Close();
22 status_t Free();
24 status_t Read(uint8 *buffer, size_t *numBytes);
25 status_t Write(const uint8 *buffer, size_t *numBytes);
26 status_t Control(uint32 op, void *buffer, size_t length);
28 void Removed();
29 bool IsRemoved() { return fRemoved; };
31 status_t CompareAndReattach(usb_device device);
33 private:
34 static void _ReadCallback(void *cookie, int32 status,
35 void *data, size_t actualLength);
36 static void _WriteCallback(void *cookie, int32 status,
37 void *data, size_t actualLength);
38 static void _NotifyCallback(void *cookie, int32 status,
39 void *data, size_t actualLength);
41 status_t _SetupDevice();
42 status_t _ReadMACAddress(usb_device device, uint8 *buffer);
44 // state tracking
45 status_t fStatus;
46 bool fOpen;
47 bool fRemoved;
48 int32 fInsideNotify;
49 usb_device fDevice;
50 uint16 fVendorID;
51 uint16 fProductID;
53 // interface and device infos
54 uint8 fControlInterfaceIndex;
55 uint8 fDataInterfaceIndex;
56 uint8 fMACAddressIndex;
57 uint16 fMaxSegmentSize;
59 // pipes for notifications and data io
60 usb_pipe fNotifyEndpoint;
61 usb_pipe fReadEndpoint;
62 usb_pipe fWriteEndpoint;
64 // data stores for async usb transfers
65 uint32 fActualLengthRead;
66 uint32 fActualLengthWrite;
67 int32 fStatusRead;
68 int32 fStatusWrite;
69 sem_id fNotifyReadSem;
70 sem_id fNotifyWriteSem;
72 uint8 * fNotifyBuffer;
73 uint32 fNotifyBufferLength;
75 // connection data
76 sem_id fLinkStateChangeSem;
77 uint8 fMACAddress[6];
78 bool fHasConnection;
79 uint32 fDownstreamSpeed;
80 uint32 fUpstreamSpeed;
83 #endif //_USB_ECM_DEVICE_H_