Added USE_INTERNAL_SERIAL compile time option to automatically read out the internal...
[pub/USBasp.git] / LUFA / Drivers / USB / Class / Device / RNDIS.h
1 /*
2 LUFA Library
3 Copyright (C) Dean Camera, 2009.
4
5 dean [at] fourwalledcubicle [dot] com
6 www.fourwalledcubicle.com
7 */
8
9 /*
10 Copyright 2009 Dean Camera (dean [at] fourwalledcubicle [dot] com)
11
12 Permission to use, copy, modify, and distribute this software
13 and its documentation for any purpose and without fee is hereby
14 granted, provided that the above copyright notice appear in all
15 copies and that both that the copyright notice and this
16 permission notice and warranty disclaimer appear in supporting
17 documentation, and that the name of the author not be used in
18 advertising or publicity pertaining to distribution of the
19 software without specific, written prior permission.
20
21 The author disclaim all warranties with regard to this
22 software, including all implied warranties of merchantability
23 and fitness. In no event shall the author be liable for any
24 special, indirect or consequential damages or any damages
25 whatsoever resulting from loss of use, data or profits, whether
26 in an action of contract, negligence or other tortious action,
27 arising out of or in connection with the use or performance of
28 this software.
29 */
30
31 /** \ingroup Group_USBClassRNDIS
32 * @defgroup Group_USBClassRNDISDevice RNDIS Class Device Mode Driver
33 *
34 * \section Module Description
35 * Device Mode USB Class driver framework interface, for the RNDIS USB Class driver.
36 *
37 * @{
38 */
39
40 #ifndef _RNDIS_CLASS_DEVICE_H_
41 #define _RNDIS_CLASS_DEVICE_H_
42
43 /* Includes: */
44 #include "../../USB.h"
45 #include "../Common/RNDIS.h"
46 #include "RNDISConstants.h"
47
48 #include <string.h>
49
50 /* Enable C linkage for C++ Compilers: */
51 #if defined(__cplusplus)
52 extern "C" {
53 #endif
54
55 /* Public Interface - May be used in end-application: */
56 /* Type Defines: */
57 /** Configuration information structure for \ref USB_ClassInfo_RNDIS_Device_t RNDIS device interface structures. */
58 typedef struct
59 {
60 uint8_t ControlInterfaceNumber; /**< Interface number of the CDC control interface within the device */
61
62 uint8_t DataINEndpointNumber; /**< Endpoint number of the CDC interface's IN data endpoint */
63 uint16_t DataINEndpointSize; /**< Size in bytes of the CDC interface's IN data endpoint */
64
65 uint8_t DataOUTEndpointNumber; /**< Endpoint number of the CDC interface's OUT data endpoint */
66 uint16_t DataOUTEndpointSize; /**< Size in bytes of the CDC interface's OUT data endpoint */
67
68 uint8_t NotificationEndpointNumber; /**< Endpoint number of the CDC interface's IN notification endpoint, if used */
69 uint16_t NotificationEndpointSize; /**< Size in bytes of the CDC interface's IN notification endpoint, if used */
70
71 char* AdapterVendorDescription; /**< String description of the adapter vendor */
72 MAC_Address_t AdapterMACAddress; /**< MAC address of the adapter */
73 } USB_ClassInfo_MS_Device_Config_t;
74
75 /** Current State information structure for \ref USB_ClassInfo_RNDIS_Device_t RNDIS device interface structures. */
76 typedef struct
77 {
78 uint8_t RNDISMessageBuffer[RNDIS_MESSAGE_BUFFER_SIZE]; /**< Buffer to hold RNDIS messages to and from the host,
79 * managed by the class driver
80 */
81 bool ResponseReady; /**< Internal flag indicating if a RNDIS message is waiting to be returned to the host */
82 uint8_t CurrRNDISState; /**< Current RNDIS state of the adapter, a value from the RNDIS_States_t enum */
83 uint32_t CurrPacketFilter; /**< Current packet filter mode, used internally by the class driver */
84 Ethernet_Frame_Info_t FrameIN; /**< Structure holding the last received Ethernet frame from the host, for user
85 * processing
86 */
87 Ethernet_Frame_Info_t FrameOUT; /**< Structure holding the next Ethernet frame to send to the host, populated by the
88 * user application
89 */
90 } USB_ClassInfo_MS_Device_State_t;
91
92 /** Class state structure. An instance of this structure should be made for each RNDIS interface
93 * within the user application, and passed to each of the RNDIS class driver functions as the
94 * RNDISInterfaceInfo parameter. This stores each RNDIS interface's configuration and state information.
95 */
96 typedef struct
97 {
98 const USB_ClassInfo_MS_Device_Config_t Config; /**< Config data for the USB class interface within
99 * the device. All elements in this section
100 * <b>must</b> be set or the interface will fail
101 * to enumerate and operate correctly.
102 */
103
104 USB_ClassInfo_MS_Device_State_t State; /**< State data for the USB class interface within
105 * the device. All elements in this section
106 * <b>may</b> be set to initial values, but may
107 * also be ignored to default to sane values when
108 * the interface is enumerated.
109 */
110 } USB_ClassInfo_RNDIS_Device_t;
111
112 /* Function Prototypes: */
113 /** Configures the endpoints of a given RNDIS interface, ready for use. This should be linked to the library
114 * \ref EVENT_USB_ConfigurationChanged() event so that the endpoints are configured when the configuration
115 * containing the given HID interface is selected.
116 *
117 * \param RNDISInterfaceInfo Pointer to a structure containing a RNDIS Class configuration and state.
118 *
119 * \return Boolean true if the endpoints were sucessfully configured, false otherwise
120 */
121 bool RNDIS_Device_ConfigureEndpoints(USB_ClassInfo_RNDIS_Device_t* RNDISInterfaceInfo);
122
123 /** Processes incomming control requests from the host, that are directed to the given RNDIS class interface. This should be
124 * linked to the library \ref EVENT_USB_UnhandledControlPacket() event.
125 *
126 * \param RNDISInterfaceInfo Pointer to a structure containing a RNDIS Class configuration and state.
127 */
128 void RNDIS_Device_ProcessControlPacket(USB_ClassInfo_RNDIS_Device_t* RNDISInterfaceInfo);
129
130 /** General management task for a given HID class interface, required for the correct operation of the interface. This should
131 * be called frequently in the main program loop, before the master USB management task \ref USB_USBTask().
132 *
133 * \param RNDISInterfaceInfo Pointer to a structure containing a RNDIS Class configuration and state.
134 */
135 void RNDIS_Device_USBTask(USB_ClassInfo_RNDIS_Device_t* RNDISInterfaceInfo);
136
137 /* Private Interface - For use in library only: */
138 #if !defined(__DOXYGEN__)
139 /* Function Prototypes: */
140 #if defined(INCLUDE_FROM_RNDIS_CLASS_DEVICE_C)
141 static void RNDIS_Device_ProcessRNDISControlMessage(USB_ClassInfo_RNDIS_Device_t* RNDISInterfaceInfo);
142 static bool RNDIS_Device_ProcessNDISQuery(USB_ClassInfo_RNDIS_Device_t* RNDISInterfaceInfo,
143 uint32_t OId, void* QueryData, uint16_t QuerySize,
144 void* ResponseData, uint16_t* ResponseSize);
145 static bool RNDIS_Device_ProcessNDISSet(USB_ClassInfo_RNDIS_Device_t* RNDISInterfaceInfo, uint32_t OId,
146 void* SetData, uint16_t SetSize);
147 #endif
148
149 #endif
150
151 /* Disable C linkage for C++ Compilers: */
152 #if defined(__cplusplus)
153 }
154 #endif
155
156 #endif
157
158 /** @} */