aboutsummaryrefslogtreecommitdiffstats
path: root/Demos/Host/Incomplete/RNDISEthernetHost/Lib
diff options
context:
space:
mode:
Diffstat (limited to 'Demos/Host/Incomplete/RNDISEthernetHost/Lib')
-rw-r--r--Demos/Host/Incomplete/RNDISEthernetHost/Lib/RNDISCommands.c234
-rw-r--r--Demos/Host/Incomplete/RNDISEthernetHost/Lib/RNDISCommands.h212
-rw-r--r--Demos/Host/Incomplete/RNDISEthernetHost/Lib/RNDISConstants.h112
3 files changed, 0 insertions, 558 deletions
diff --git a/Demos/Host/Incomplete/RNDISEthernetHost/Lib/RNDISCommands.c b/Demos/Host/Incomplete/RNDISEthernetHost/Lib/RNDISCommands.c
deleted file mode 100644
index b1966142a..000000000
--- a/Demos/Host/Incomplete/RNDISEthernetHost/Lib/RNDISCommands.c
+++ /dev/null
@@ -1,234 +0,0 @@
-/*
- LUFA Library
- Copyright (C) Dean Camera, 2009.
-
- dean [at] fourwalledcubicle [dot] com
- www.fourwalledcubicle.com
-*/
-
-/*
- Copyright 2009 Dean Camera (dean [at] fourwalledcubicle [dot] com)
-
- Permission to use, copy, modify, and distribute this software
- and its documentation for any purpose and without fee is hereby
- granted, provided that the above copyright notice appear in all
- copies and that both that the copyright notice and this
- permission notice and warranty disclaimer appear in supporting
- documentation, and that the name of the author not be used in
- advertising or publicity pertaining to distribution of the
- software without specific, written prior permission.
-
- The author disclaim all warranties with regard to this
- software, including all implied warranties of merchantability
- and fitness. In no event shall the author be liable for any
- special, indirect or consequential damages or any damages
- whatsoever resulting from loss of use, data or profits, whether
- in an action of contract, negligence or other tortious action,
- arising out of or in connection with the use or performance of
- this software.
-*/
-
-/** \file
- *
- * RNDOS Device commands, to issue RNDIS commands to the device for
- * the control and data transfer between the host and RNDIS device.
- */
-
-#include "RNDISCommands.h"
-
-uint32_t RequestID = 0;
-
-uint8_t RNDIS_SendEncapsulatedCommand(void* Buffer, uint16_t Length)
-{
- USB_ControlRequest = (USB_Request_Header_t)
- {
- .bmRequestType = (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE),
- .bRequest = REQ_SendEncapsulatedCommand,
- .wValue = 0,
- .wIndex = 0,
- .wLength = Length,
- };
-
- /* Select the control pipe for the request transfer */
- Pipe_SelectPipe(PIPE_CONTROLPIPE);
-
- return USB_Host_SendControlRequest(Buffer);
-}
-
-uint8_t RNDIS_GetEncapsulatedResponse(void* Buffer, uint16_t Length)
-{
- USB_ControlRequest = (USB_Request_Header_t)
- {
- .bmRequestType = (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_INTERFACE),
- .bRequest = REQ_GetEncapsulatedResponse,
- .wValue = 0,
- .wIndex = 0,
- .wLength = Length,
- };
-
- /* Select the control pipe for the request transfer */
- Pipe_SelectPipe(PIPE_CONTROLPIPE);
-
- return USB_Host_SendControlRequest(Buffer);
-}
-
-uint8_t RNDIS_SendKeepAlive(void)
-{
- uint8_t ErrorCode;
-
- RNDIS_KeepAlive_Message_t KeepAliveMessage;
- RNDIS_KeepAlive_Complete_t KeepAliveMessageResponse;
-
- KeepAliveMessage.MessageType = REMOTE_NDIS_KEEPALIVE_MSG;
- KeepAliveMessage.MessageLength = sizeof(RNDIS_KeepAlive_Message_t);
- KeepAliveMessage.RequestId = RequestID++;
-
- if ((ErrorCode = RNDIS_SendEncapsulatedCommand(&KeepAliveMessage,
- sizeof(RNDIS_KeepAlive_Message_t))) != HOST_SENDCONTROL_Successful)
- {
- return ErrorCode;
- }
-
- if ((ErrorCode = RNDIS_GetEncapsulatedResponse(&KeepAliveMessageResponse,
- sizeof(RNDIS_KeepAlive_Complete_t))) != HOST_SENDCONTROL_Successful)
- {
- return ErrorCode;
- }
-
- return HOST_SENDCONTROL_Successful;
-}
-
-uint8_t RNDIS_InitializeDevice(uint16_t HostMaxPacketSize, uint16_t* DeviceMaxPacketSize)
-{
- uint8_t ErrorCode;
-
- RNDIS_Initialize_Message_t InitMessage;
- RNDIS_Initialize_Complete_t InitMessageResponse;
-
- InitMessage.MessageType = REMOTE_NDIS_INITIALIZE_MSG;
- InitMessage.MessageLength = sizeof(RNDIS_Initialize_Message_t);
- InitMessage.RequestId = RequestID++;
-
- InitMessage.MajorVersion = REMOTE_NDIS_VERSION_MAJOR;
- InitMessage.MinorVersion = REMOTE_NDIS_VERSION_MINOR;
- InitMessage.MaxTransferSize = HostMaxPacketSize;
-
- if ((ErrorCode = RNDIS_SendEncapsulatedCommand(&InitMessage,
- sizeof(RNDIS_Initialize_Message_t))) != HOST_SENDCONTROL_Successful)
- {
- return ErrorCode;
- }
-
- if ((ErrorCode = RNDIS_GetEncapsulatedResponse(&InitMessageResponse,
- sizeof(RNDIS_Initialize_Complete_t))) != HOST_SENDCONTROL_Successful)
- {
- return ErrorCode;
- }
-
- if (InitMessageResponse.Status != REMOTE_NDIS_STATUS_SUCCESS)
- return RNDIS_COMMAND_FAILED;
-
- *DeviceMaxPacketSize = InitMessageResponse.MaxTransferSize;
-
- return HOST_SENDCONTROL_Successful;
-}
-
-uint8_t RNDIS_SetRNDISProperty(uint32_t Oid, void* Buffer, uint16_t Length)
-{
- uint8_t ErrorCode;
-
- struct
- {
- RNDIS_Set_Message_t SetMessage;
- uint8_t ContigiousBuffer[Length];
- } SetMessageData;
-
- RNDIS_Set_Complete_t SetMessageResponse;
-
- SetMessageData.SetMessage.MessageType = REMOTE_NDIS_SET_MSG;
- SetMessageData.SetMessage.MessageLength = sizeof(RNDIS_Set_Message_t) + Length;
- SetMessageData.SetMessage.RequestId = RequestID++;
-
- SetMessageData.SetMessage.Oid = Oid;
- SetMessageData.SetMessage.InformationBufferLength = Length;
- SetMessageData.SetMessage.InformationBufferOffset = (sizeof(RNDIS_Set_Message_t) - sizeof(RNDIS_Message_Header_t));
- SetMessageData.SetMessage.DeviceVcHandle = 0;
-
- memcpy(&SetMessageData.ContigiousBuffer, Buffer, Length);
-
- if ((ErrorCode = RNDIS_SendEncapsulatedCommand(&SetMessageData,
- SetMessageData.SetMessage.MessageLength)) != HOST_SENDCONTROL_Successful)
- {
- return ErrorCode;
- }
-
- if ((ErrorCode = RNDIS_GetEncapsulatedResponse(&SetMessageResponse,
- sizeof(RNDIS_Set_Complete_t))) != HOST_SENDCONTROL_Successful)
- {
- return ErrorCode;
- }
-
- if (SetMessageResponse.Status != REMOTE_NDIS_STATUS_SUCCESS)
- return RNDIS_COMMAND_FAILED;
-
- return HOST_SENDCONTROL_Successful;
-}
-
-uint8_t RNDIS_QueryRNDISProperty(uint32_t Oid, void* Buffer, uint16_t MaxLength)
-{
- uint8_t ErrorCode;
-
- RNDIS_Query_Message_t QueryMessage;
-
- struct
- {
- RNDIS_Query_Complete_t QueryMessageResponse;
- uint8_t ContigiousBuffer[MaxLength];
- } QueryMessageResponseData;
-
- QueryMessage.MessageType = REMOTE_NDIS_QUERY_MSG;
- QueryMessage.MessageLength = sizeof(RNDIS_Query_Message_t);
- QueryMessage.RequestId = RequestID++;
-
- QueryMessage.Oid = Oid;
- QueryMessage.InformationBufferLength = 0;
- QueryMessage.InformationBufferOffset = 0;
- QueryMessage.DeviceVcHandle = 0;
-
- if ((ErrorCode = RNDIS_SendEncapsulatedCommand(&QueryMessage,
- sizeof(RNDIS_Query_Message_t))) != HOST_SENDCONTROL_Successful)
- {
- return ErrorCode;
- }
-
- if ((ErrorCode = RNDIS_GetEncapsulatedResponse(&QueryMessageResponseData,
- sizeof(QueryMessageResponseData))) != HOST_SENDCONTROL_Successful)
- {
- return ErrorCode;
- }
-
- if (QueryMessageResponseData.QueryMessageResponse.Status != REMOTE_NDIS_STATUS_SUCCESS)
- return RNDIS_COMMAND_FAILED;
-
- memcpy(Buffer, &QueryMessageResponseData.ContigiousBuffer, MaxLength);
-
- return HOST_SENDCONTROL_Successful;
-}
-
-uint8_t RNDIS_GetPacketLength(uint16_t* PacketLength)
-{
- uint8_t ErrorCode;
-
- RNDIS_Packet_Message_t DeviceMessage;
-
- if ((ErrorCode = Pipe_Read_Stream_LE(&DeviceMessage, sizeof(RNDIS_Packet_Message_t))) != PIPE_RWSTREAM_NoError)
- {
- return ErrorCode;
- }
-
- *PacketLength = (uint16_t)DeviceMessage.DataLength;
-
- Pipe_Discard_Stream(DeviceMessage.DataOffset - (sizeof(RNDIS_Packet_Message_t) - sizeof(RNDIS_Message_Header_t)));
-
- return PIPE_RWSTREAM_NoError;
-}
diff --git a/Demos/Host/Incomplete/RNDISEthernetHost/Lib/RNDISCommands.h b/Demos/Host/Incomplete/RNDISEthernetHost/Lib/RNDISCommands.h
deleted file mode 100644
index 429b4c535..000000000
--- a/Demos/Host/Incomplete/RNDISEthernetHost/Lib/RNDISCommands.h
+++ /dev/null
@@ -1,212 +0,0 @@
-/*
- LUFA Library
- Copyright (C) Dean Camera, 2009.
-
- dean [at] fourwalledcubicle [dot] com
- www.fourwalledcubicle.com
-*/
-
-/*
- Copyright 2009 Dean Camera (dean [at] fourwalledcubicle [dot] com)
-
- Permission to use, copy, modify, and distribute this software
- and its documentation for any purpose and without fee is hereby
- granted, provided that the above copyright notice appear in all
- copies and that both that the copyright notice and this
- permission notice and warranty disclaimer appear in supporting
- documentation, and that the name of the author not be used in
- advertising or publicity pertaining to distribution of the
- software without specific, written prior permission.
-
- The author disclaim all warranties with regard to this
- software, including all implied warranties of merchantability
- and fitness. In no event shall the author be liable for any
- special, indirect or consequential damages or any damages
- whatsoever resulting from loss of use, data or profits, whether
- in an action of contract, negligence or other tortious action,
- arising out of or in connection with the use or performance of
- this software.
-*/
-
-/** \file
- *
- * Header file for RNDISCommands.c.
- */
-
-#ifndef _RNDIS_COMMANDS_H_
-#define _RNDIS_COMMANDS_H_
-
- /* Includes: */
- #include <avr/io.h>
- #include <stdio.h>
- #include <string.h>
-
- #include <LUFA/Drivers/USB/USB.h>
-
- #include "RNDISConstants.h"
-
- /* Type Defines: */
- /** Type define for a RNDIS message header, sent before RNDIS messages */
- typedef struct
- {
- uint32_t MessageType; /**< RNDIS message type, a REMOTE_NDIS_*_MSG constant */
- uint32_t MessageLength; /**< Total length of the RNDIS message, in bytes */
- } RNDIS_Message_Header_t;
-
- /** Type define for a RNDIS packet message, used to encapsulate Ethernet packets sent to and from the adapter */
- typedef struct
- {
- uint32_t MessageType;
- uint32_t MessageLength;
- uint32_t DataOffset;
- uint32_t DataLength;
- uint32_t OOBDataOffset;
- uint32_t OOBDataLength;
- uint32_t NumOOBDataElements;
- uint32_t PerPacketInfoOffset;
- uint32_t PerPacketInfoLength;
- uint32_t VcHandle;
- uint32_t Reserved;
- } RNDIS_Packet_Message_t;
-
- /** Type define for a RNDIS Initialize command message */
- typedef struct
- {
- uint32_t MessageType;
- uint32_t MessageLength;
- uint32_t RequestId;
-
- uint32_t MajorVersion;
- uint32_t MinorVersion;
- uint32_t MaxTransferSize;
- } RNDIS_Initialize_Message_t;
-
- /** Type define for a RNDIS Initialize complete response message */
- typedef struct
- {
- uint32_t MessageType;
- uint32_t MessageLength;
- uint32_t RequestId;
- uint32_t Status;
-
- uint32_t MajorVersion;
- uint32_t MinorVersion;
- uint32_t DeviceFlags;
- uint32_t Medium;
- uint32_t MaxPacketsPerTransfer;
- uint32_t MaxTransferSize;
- uint32_t PacketAlignmentFactor;
- uint32_t AFListOffset;
- uint32_t AFListSize;
- } RNDIS_Initialize_Complete_t;
-
- /** Type define for a RNDIS Keepalive command message */
- typedef struct
- {
- uint32_t MessageType;
- uint32_t MessageLength;
- uint32_t RequestId;
- } RNDIS_KeepAlive_Message_t;
-
- /** Type define for a RNDIS Keepalive complete message */
- typedef struct
- {
- uint32_t MessageType;
- uint32_t MessageLength;
- uint32_t RequestId;
- uint32_t Status;
- } RNDIS_KeepAlive_Complete_t;
-
- /** Type define for a RNDIS Reset complete message */
- typedef struct
- {
- uint32_t MessageType;
- uint32_t MessageLength;
- uint32_t Status;
-
- uint32_t AddressingReset;
- } RNDIS_Reset_Complete_t;
-
- /** Type define for a RNDIS Set command message */
- typedef struct
- {
- uint32_t MessageType;
- uint32_t MessageLength;
- uint32_t RequestId;
-
- uint32_t Oid;
- uint32_t InformationBufferLength;
- uint32_t InformationBufferOffset;
- uint32_t DeviceVcHandle;
- } RNDIS_Set_Message_t;
-
- /** Type define for a RNDIS Set complete response message */
- typedef struct
- {
- uint32_t MessageType;
- uint32_t MessageLength;
- uint32_t RequestId;
- uint32_t Status;
- } RNDIS_Set_Complete_t;
-
- /** Type define for a RNDIS Query command message */
- typedef struct
- {
- uint32_t MessageType;
- uint32_t MessageLength;
- uint32_t RequestId;
-
- uint32_t Oid;
- uint32_t InformationBufferLength;
- uint32_t InformationBufferOffset;
- uint32_t DeviceVcHandle;
- } RNDIS_Query_Message_t;
-
- /** Type define for a RNDIS Query complete response message */
- typedef struct
- {
- uint32_t MessageType;
- uint32_t MessageLength;
- uint32_t RequestId;
- uint32_t Status;
-
- uint32_t InformationBufferLength;
- uint32_t InformationBufferOffset;
- } RNDIS_Query_Complete_t;
-
- /* Macros: */
- /** RNDIS request to issue a host-to-device NDIS command */
- #define REQ_SendEncapsulatedCommand 0x00
-
- /** RNDIS request to issue a device-to-host NDIS response */
- #define REQ_GetEncapsulatedResponse 0x01
-
- /** Implemented RNDIS Version Major */
- #define REMOTE_NDIS_VERSION_MAJOR 0x01
-
- /** Implemented RNDIS Version Minor */
- #define REMOTE_NDIS_VERSION_MINOR 0x00
-
- /** Pipe number for the RNDIS data IN pipe */
- #define RNDIS_DATAPIPE_IN 1
-
- /** Pipe number for the RNDIS data OUT pipe */
- #define RNDIS_DATAPIPE_OUT 2
-
- /** Pipe number for the RNDIS notification pipe */
- #define RNDIS_NOTIFICATIONPIPE 3
-
- /** Additional error code for RNDIS functions when a device returns a logical command failure */
- #define RNDIS_COMMAND_FAILED 0xC0
-
- /* Function Prototypes: */
- uint8_t RNDIS_SendEncapsulatedCommand(void* Buffer, uint16_t Length);
- uint8_t RNDIS_GetEncapsulatedResponse(void* Buffer, uint16_t Length);
-
- uint8_t RNDIS_SendKeepAlive(void);
- uint8_t RNDIS_InitializeDevice(uint16_t HostMaxPacketSize, uint16_t* DeviceMaxPacketSize);
- uint8_t RNDIS_SetRNDISProperty(uint32_t Oid, void* Buffer, uint16_t Length);
- uint8_t RNDIS_QueryRNDISProperty(uint32_t Oid, void* Buffer, uint16_t MaxLength);
- uint8_t RNDIS_GetPacketLength(uint16_t* PacketLength);
-
-#endif
diff --git a/Demos/Host/Incomplete/RNDISEthernetHost/Lib/RNDISConstants.h b/Demos/Host/Incomplete/RNDISEthernetHost/Lib/RNDISConstants.h
deleted file mode 100644
index f65a66cbf..000000000
--- a/Demos/Host/Incomplete/RNDISEthernetHost/Lib/RNDISConstants.h
+++ /dev/null
@@ -1,112 +0,0 @@
-/*
- LUFA Library
- Copyright (C) Dean Camera, 2009.
-
- dean [at] fourwalledcubicle [dot] com
- www.fourwalledcubicle.com
-*/
-
-/*
- Copyright 2009 Dean Camera (dean [at] fourwalledcubicle [dot] com)
-
- Permission to use, copy, modify, and distribute this software
- and its documentation for any purpose and without fee is hereby
- granted, provided that the above copyright notice appear in all
- copies and that both that the copyright notice and this
- permission notice and warranty disclaimer appear in supporting
- documentation, and that the name of the author not be used in
- advertising or publicity pertaining to distribution of the
- software without specific, written prior permission.
-
- The author disclaim all warranties with regard to this
- software, including all implied warranties of merchantability
- and fitness. In no event shall the author be liable for any
- special, indirect or consequential damages or any damages
- whatsoever resulting from loss of use, data or profits, whether
- in an action of contract, negligence or other tortious action,
- arising out of or in connection with the use or performance of
- this software.
-*/
-
-/** \file
- *
- * RNDIS specification related constants. For more information on these
- * constants, please refer to the Microsoft RNDIS specification.
- */
-
-#ifndef _RNDIS_CONSTANTS_H_
-#define _RNDIS_CONSTANTS_H_
-
- /* Macros: */
- #define REMOTE_NDIS_PACKET_MSG 0x00000001UL
- #define REMOTE_NDIS_INITIALIZE_MSG 0x00000002UL
- #define REMOTE_NDIS_HALT_MSG 0x00000003UL
- #define REMOTE_NDIS_QUERY_MSG 0x00000004UL
- #define REMOTE_NDIS_SET_MSG 0x00000005UL
- #define REMOTE_NDIS_RESET_MSG 0x00000006UL
- #define REMOTE_NDIS_INDICATE_STATUS_MSG 0x00000007UL
- #define REMOTE_NDIS_KEEPALIVE_MSG 0x00000008UL
-
- #define REMOTE_NDIS_INITIALIZE_CMPLT 0x80000002UL
- #define REMOTE_NDIS_QUERY_CMPLT 0x80000004UL
- #define REMOTE_NDIS_SET_CMPLT 0x80000005UL
- #define REMOTE_NDIS_RESET_CMPLT 0x80000006UL
- #define REMOTE_NDIS_KEEPALIVE_CMPLT 0x80000008UL
-
- #define REMOTE_NDIS_STATUS_SUCCESS 0x00000000UL
- #define REMOTE_NDIS_STATUS_FAILURE 0xC0000001UL
- #define REMOTE_NDIS_STATUS_INVALID_DATA 0xC0010015UL
- #define REMOTE_NDIS_STATUS_NOT_SUPPORTED 0xC00000BBUL
- #define REMOTE_NDIS_STATUS_MEDIA_CONNECT 0x4001000BUL
- #define REMOTE_NDIS_STATUS_MEDIA_DISCONNECT 0x4001000CUL
-
- #define REMOTE_NDIS_MEDIA_STATE_CONNECTED 0x00000000UL
- #define REMOTE_NDIS_MEDIA_STATE_DISCONNECTED 0x00000001UL
-
- #define REMOTE_NDIS_MEDIUM_802_3 0x00000000UL
-
- #define REMOTE_NDIS_DF_CONNECTIONLESS 0x00000001UL
- #define REMOTE_NDIS_DF_CONNECTION_ORIENTED 0x00000002UL
-
- #define OID_GEN_SUPPORTED_LIST 0x00010101UL
- #define OID_GEN_HARDWARE_STATUS 0x00010102UL
- #define OID_GEN_MEDIA_SUPPORTED 0x00010103UL
- #define OID_GEN_MEDIA_IN_USE 0x00010104UL
- #define OID_GEN_MAXIMUM_FRAME_SIZE 0x00010106UL
- #define OID_GEN_MAXIMUM_TOTAL_SIZE 0x00010111UL
- #define OID_GEN_LINK_SPEED 0x00010107UL
- #define OID_GEN_TRANSMIT_BLOCK_SIZE 0x0001010AUL
- #define OID_GEN_RECEIVE_BLOCK_SIZE 0x0001010BUL
- #define OID_GEN_VENDOR_ID 0x0001010CUL
- #define OID_GEN_VENDOR_DESCRIPTION 0x0001010DUL
- #define OID_GEN_CURRENT_PACKET_FILTER 0x0001010EUL
- #define OID_GEN_MAXIMUM_TOTAL_SIZE 0x00010111UL
- #define OID_GEN_MEDIA_CONNECT_STATUS 0x00010114UL
- #define OID_GEN_PHYSICAL_MEDIUM 0x00010202UL
- #define OID_GEN_XMIT_OK 0x00020101UL
- #define OID_GEN_RCV_OK 0x00020102UL
- #define OID_GEN_XMIT_ERROR 0x00020103UL
- #define OID_GEN_RCV_ERROR 0x00020104UL
- #define OID_GEN_RCV_NO_BUFFER 0x00020105UL
- #define OID_802_3_PERMANENT_ADDRESS 0x01010101UL
- #define OID_802_3_CURRENT_ADDRESS 0x01010102UL
- #define OID_802_3_MULTICAST_LIST 0x01010103UL
- #define OID_802_3_MAXIMUM_LIST_SIZE 0x01010104UL
- #define OID_802_3_RCV_ERROR_ALIGNMENT 0x01020101UL
- #define OID_802_3_XMIT_ONE_COLLISION 0x01020102UL
- #define OID_802_3_XMIT_MORE_COLLISIONS 0x01020103UL
-
- #define RNDIS_PACKET_TYPE_DIRECTED 0x00000001UL
- #define RNDIS_PACKET_TYPE_MULTICAST 0x00000002UL
- #define RNDIS_PACKET_TYPE_ALL_MULTICAST 0x00000004UL
- #define RNDIS_PACKET_TYPE_BROADCAST 0x00000008UL
- #define RNDIS_PACKET_TYPE_SOURCE_ROUTING 0x00000010UL
- #define RNDIS_PACKET_TYPE_PROMISCUOUS 0x00000020UL
- #define RNDIS_PACKET_TYPE_SMT 0x00000040UL
- #define RNDIS_PACKET_TYPE_ALL_LOCAL 0x00000080UL
- #define RNDIS_PACKET_TYPE_GROUP 0x00001000UL
- #define RNDIS_PACKET_TYPE_ALL_FUNCTIONAL 0x00002000UL
- #define RNDIS_PACKET_TYPE_FUNCTIONAL 0x00004000UL
- #define RNDIS_PACKET_TYPE_MAC_FRAME 0x00008000UL
-
-#endif