diff options
Diffstat (limited to 'Demos/Device/ClassDriver/RNDISEthernet')
25 files changed, 423 insertions, 399 deletions
diff --git a/Demos/Device/ClassDriver/RNDISEthernet/Descriptors.c b/Demos/Device/ClassDriver/RNDISEthernet/Descriptors.c index 2eaa1eb5b..33f1dfe93 100644 --- a/Demos/Device/ClassDriver/RNDISEthernet/Descriptors.c +++ b/Demos/Device/ClassDriver/RNDISEthernet/Descriptors.c @@ -1,7 +1,7 @@ /* LUFA Library Copyright (C) Dean Camera, 2010. - + dean [at] fourwalledcubicle [dot] com www.fourwalledcubicle.com */ @@ -9,13 +9,13 @@ /* Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com) - Permission to use, copy, modify, distribute, and sell this + Permission to use, copy, modify, distribute, and sell this software and its documentation for any purpose is hereby granted - without fee, provided that the above copyright notice appear in + without fee, 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 + 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 @@ -30,11 +30,11 @@ /** \file * - * USB Device Descriptors, for library use when in USB device mode. Descriptors are special + * USB Device Descriptors, for library use when in USB device mode. Descriptors are special * computer-readable structures which the host requests upon device enumeration, to determine - * the device's capabilities and functions. + * the device's capabilities and functions. */ - + #include "Descriptors.h" /** Device descriptor structure. This descriptor, located in FLASH memory, describes the overall @@ -45,22 +45,22 @@ USB_Descriptor_Device_t PROGMEM DeviceDescriptor = { .Header = {.Size = sizeof(USB_Descriptor_Device_t), .Type = DTYPE_Device}, - + .USBSpecification = VERSION_BCD(01.10), .Class = 0x02, .SubClass = 0x00, .Protocol = 0x00, - + .Endpoint0Size = FIXED_CONTROL_ENDPOINT_SIZE, - + .VendorID = 0x03EB, .ProductID = 0x204C, .ReleaseNumber = VERSION_BCD(00.01), - + .ManufacturerStrIndex = 0x01, .ProductStrIndex = 0x02, .SerialNumStrIndex = NO_DESCRIPTOR, - + .NumberOfConfigurations = FIXED_NUM_CONFIGURATIONS }; @@ -71,102 +71,102 @@ USB_Descriptor_Device_t PROGMEM DeviceDescriptor = */ USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor = { - .Config = + .Config = { .Header = {.Size = sizeof(USB_Descriptor_Configuration_Header_t), .Type = DTYPE_Configuration}, .TotalConfigurationSize = sizeof(USB_Descriptor_Configuration_t), .TotalInterfaces = 2, - + .ConfigurationNumber = 1, .ConfigurationStrIndex = NO_DESCRIPTOR, - + .ConfigAttributes = (USB_CONFIG_ATTR_BUSPOWERED | USB_CONFIG_ATTR_SELFPOWERED), - + .MaxPowerConsumption = USB_CONFIG_POWER_MA(100) }, - - .CDC_CCI_Interface = + + .CDC_CCI_Interface = { .Header = {.Size = sizeof(USB_Descriptor_Interface_t), .Type = DTYPE_Interface}, .InterfaceNumber = 0, .AlternateSetting = 0, - + .TotalEndpoints = 1, - + .Class = 0x02, .SubClass = 0x02, .Protocol = 0xFF, - + .InterfaceStrIndex = NO_DESCRIPTOR }, - .CDC_Functional_Header = + .CDC_Functional_Header = { .Header = {.Size = sizeof(USB_CDC_Descriptor_FunctionalHeader_t), .Type = DTYPE_CSInterface}, .Subtype = CDC_DSUBTYPE_CSInterface_Header, - + .CDCSpecification = VERSION_BCD(01.10), }, - .CDC_Functional_ACM = + .CDC_Functional_ACM = { .Header = {.Size = sizeof(USB_CDC_Descriptor_FunctionalACM_t), .Type = DTYPE_CSInterface}, .Subtype = CDC_DSUBTYPE_CSInterface_ACM, - + .Capabilities = 0x00, }, - - .CDC_Functional_Union = + + .CDC_Functional_Union = { .Header = {.Size = sizeof(USB_CDC_Descriptor_FunctionalUnion_t), .Type = DTYPE_CSInterface}, .Subtype = CDC_DSUBTYPE_CSInterface_Union, - + .MasterInterfaceNumber = 0, .SlaveInterfaceNumber = 1, }, - .CDC_NotificationEndpoint = + .CDC_NotificationEndpoint = { .Header = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint}, - + .EndpointAddress = (ENDPOINT_DESCRIPTOR_DIR_IN | CDC_NOTIFICATION_EPNUM), .Attributes = (EP_TYPE_INTERRUPT | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA), .EndpointSize = CDC_NOTIFICATION_EPSIZE, .PollingIntervalMS = 0x02 }, - .CDC_DCI_Interface = + .CDC_DCI_Interface = { .Header = {.Size = sizeof(USB_Descriptor_Interface_t), .Type = DTYPE_Interface}, .InterfaceNumber = 1, .AlternateSetting = 0, - + .TotalEndpoints = 2, - + .Class = 0x0A, .SubClass = 0x00, .Protocol = 0x00, - + .InterfaceStrIndex = NO_DESCRIPTOR }, - .RNDIS_DataOutEndpoint = + .RNDIS_DataOutEndpoint = { .Header = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint}, - + .EndpointAddress = (ENDPOINT_DESCRIPTOR_DIR_OUT | CDC_RX_EPNUM), .Attributes = (EP_TYPE_BULK | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA), .EndpointSize = CDC_TXRX_EPSIZE, .PollingIntervalMS = 0x00 }, - - .RNDIS_DataInEndpoint = + + .RNDIS_DataInEndpoint = { .Header = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint}, - + .EndpointAddress = (ENDPOINT_DESCRIPTOR_DIR_IN | CDC_TX_EPNUM), .Attributes = (EP_TYPE_BULK | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA), .EndpointSize = CDC_TXRX_EPSIZE, @@ -181,7 +181,7 @@ USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor = USB_Descriptor_String_t PROGMEM LanguageString = { .Header = {.Size = USB_STRING_LEN(1), .Type = DTYPE_String}, - + .UnicodeString = {LANGUAGE_ID_ENG} }; @@ -192,7 +192,7 @@ USB_Descriptor_String_t PROGMEM LanguageString = USB_Descriptor_String_t PROGMEM ManufacturerString = { .Header = {.Size = USB_STRING_LEN(11), .Type = DTYPE_String}, - + .UnicodeString = L"Dean Camera" }; @@ -203,7 +203,7 @@ USB_Descriptor_String_t PROGMEM ManufacturerString = USB_Descriptor_String_t PROGMEM ProductString = { .Header = {.Size = USB_STRING_LEN(19), .Type = DTYPE_String}, - + .UnicodeString = L"LUFA RNDIS CDC Demo" }; @@ -229,7 +229,7 @@ uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue, Address = &DeviceDescriptor; Size = sizeof(USB_Descriptor_Device_t); break; - case DTYPE_Configuration: + case DTYPE_Configuration: Address = &ConfigurationDescriptor; Size = sizeof(USB_Descriptor_Configuration_t); break; @@ -249,10 +249,11 @@ uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue, Size = pgm_read_byte(&ProductString.Header.Size); break; } - + break; } - + *DescriptorAddress = Address; return Size; } + diff --git a/Demos/Device/ClassDriver/RNDISEthernet/Descriptors.h b/Demos/Device/ClassDriver/RNDISEthernet/Descriptors.h index 26bd57127..7f67bc09b 100644 --- a/Demos/Device/ClassDriver/RNDISEthernet/Descriptors.h +++ b/Demos/Device/ClassDriver/RNDISEthernet/Descriptors.h @@ -1,7 +1,7 @@ /* LUFA Library Copyright (C) Dean Camera, 2010. - + dean [at] fourwalledcubicle [dot] com www.fourwalledcubicle.com */ @@ -9,13 +9,13 @@ /* Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com) - Permission to use, copy, modify, distribute, and sell this + Permission to use, copy, modify, distribute, and sell this software and its documentation for any purpose is hereby granted - without fee, provided that the above copyright notice appear in + without fee, 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 + 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 @@ -39,7 +39,7 @@ /* Includes: */ #include <LUFA/Drivers/USB/USB.h> #include <LUFA/Drivers/USB/Class/RNDIS.h> - + #include <avr/pgmspace.h> /* Macros: */ @@ -47,10 +47,10 @@ #define CDC_NOTIFICATION_EPNUM 3 /** Endpoint number of the CDC device-to-host data IN endpoint. */ - #define CDC_TX_EPNUM 1 + #define CDC_TX_EPNUM 1 /** Endpoint number of the CDC host-to-device data OUT endpoint. */ - #define CDC_RX_EPNUM 2 + #define CDC_RX_EPNUM 2 /** Size in bytes of the CDC device-to-host notification IN endpoint. */ #define CDC_NOTIFICATION_EPSIZE 8 @@ -83,3 +83,4 @@ ATTR_WARN_UNUSED_RESULT ATTR_NON_NULL_PTR_ARG(3); #endif + diff --git a/Demos/Device/ClassDriver/RNDISEthernet/Lib/ARP.c b/Demos/Device/ClassDriver/RNDISEthernet/Lib/ARP.c index 18da19cdb..fe6c5bef2 100644 --- a/Demos/Device/ClassDriver/RNDISEthernet/Lib/ARP.c +++ b/Demos/Device/ClassDriver/RNDISEthernet/Lib/ARP.c @@ -1,7 +1,7 @@ /* LUFA Library Copyright (C) Dean Camera, 2010. - + dean [at] fourwalledcubicle [dot] com www.fourwalledcubicle.com */ @@ -9,13 +9,13 @@ /* Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com) - Permission to use, copy, modify, distribute, and sell this + Permission to use, copy, modify, distribute, and sell this software and its documentation for any purpose is hereby granted - without fee, provided that the above copyright notice appear in + without fee, 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 + 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 @@ -34,7 +34,7 @@ * conversion of physical MAC addresses to protocol IP addresses between the host and the * device. */ - + #include "ARP.h" /** Processes an ARP packet inside an Ethernet frame, and writes the appropriate response @@ -59,7 +59,7 @@ int16_t ARP_ProcessARPPacket(void* InDataStart, (SwapEndian_16(ARPHeaderIN->Operation) == ARP_OPERATION_REQUEST)) { /* If the ARP packet is requesting the MAC or IP of the virtual webserver, return the response */ - if (IP_COMPARE(&ARPHeaderIN->TPA, &ServerIPAddress) || + if (IP_COMPARE(&ARPHeaderIN->TPA, &ServerIPAddress) || MAC_COMPARE(&ARPHeaderIN->THA, &ServerMACAddress)) { /* Fill out the ARP response header */ @@ -81,6 +81,7 @@ int16_t ARP_ProcessARPPacket(void* InDataStart, return sizeof(ARP_Header_t); } } - + return NO_RESPONSE; } + diff --git a/Demos/Device/ClassDriver/RNDISEthernet/Lib/ARP.h b/Demos/Device/ClassDriver/RNDISEthernet/Lib/ARP.h index 8de76f3b6..d97761539 100644 --- a/Demos/Device/ClassDriver/RNDISEthernet/Lib/ARP.h +++ b/Demos/Device/ClassDriver/RNDISEthernet/Lib/ARP.h @@ -1,7 +1,7 @@ /* LUFA Library Copyright (C) Dean Camera, 2010. - + dean [at] fourwalledcubicle [dot] com www.fourwalledcubicle.com */ @@ -9,13 +9,13 @@ /* Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com) - Permission to use, copy, modify, distribute, and sell this + Permission to use, copy, modify, distribute, and sell this software and its documentation for any purpose is hereby granted - without fee, provided that the above copyright notice appear in + without fee, 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 + 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 @@ -32,18 +32,18 @@ * * Header file for ARP.c. */ - + #ifndef _ARP_H_ #define _ARP_H_ /* Includes: */ #include <avr/io.h> #include <string.h> - + #include "EthernetProtocols.h" #include "Ethernet.h" #include "ProtocolDecoders.h" - + /* Macros: */ /** ARP header operation constant, indicating a request from a host for an address translation. */ #define ARP_OPERATION_REQUEST 1 @@ -57,19 +57,20 @@ { uint16_t HardwareType; /**< Hardware type constant, indicating the hardware used */ uint16_t ProtocolType; /**< Protocol being resolved, usually ETHERTYPE_IPV4 */ - + uint8_t HLEN; /**< Length in bytes of the source/destination hardware addresses */ uint8_t PLEN; /**< Length in bytes of the source/destination protocol addresses */ uint16_t Operation; /**< Type of operation, either ARP_OPERATION_REQUEST or ARP_OPERATION_REPLY */ - + MAC_Address_t SHA; /**< Sender's hardware address */ IP_Address_t SPA; /**< Sender's protocol address */ MAC_Address_t THA; /**< Target's hardware address */ IP_Address_t TPA; /**< Target's protocol address */ } ARP_Header_t; - + /* Function Prototypes: */ int16_t ARP_ProcessARPPacket(void* InDataStart, void* OutDataStart); #endif + diff --git a/Demos/Device/ClassDriver/RNDISEthernet/Lib/DHCP.c b/Demos/Device/ClassDriver/RNDISEthernet/Lib/DHCP.c index f694f2c81..18ad6a5e9 100644 --- a/Demos/Device/ClassDriver/RNDISEthernet/Lib/DHCP.c +++ b/Demos/Device/ClassDriver/RNDISEthernet/Lib/DHCP.c @@ -1,7 +1,7 @@ /* LUFA Library Copyright (C) Dean Camera, 2010. - + dean [at] fourwalledcubicle [dot] com www.fourwalledcubicle.com */ @@ -9,13 +9,13 @@ /* Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com) - Permission to use, copy, modify, distribute, and sell this + Permission to use, copy, modify, distribute, and sell this software and its documentation for any purpose is hereby granted - without fee, provided that the above copyright notice appear in + without fee, 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 + 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 @@ -34,7 +34,7 @@ * handles the automatic IP negotiation to the host, so that the host will use the provided * IP address given to it by the device. */ - + #include "DHCP.h" /** Processes a DHCP packet inside an Ethernet frame, and writes the appropriate response @@ -53,7 +53,7 @@ int16_t DHCP_ProcessDHCPPacket(void* IPHeaderInStart, IP_Header_t* IPHeaderIN = (IP_Header_t*)IPHeaderInStart; DHCP_Header_t* DHCPHeaderIN = (DHCP_Header_t*)DHCPHeaderInStart; DHCP_Header_t* DHCPHeaderOUT = (DHCP_Header_t*)DHCPHeaderOutStart; - + uint8_t* DHCPOptionsINStart = (uint8_t*)(DHCPHeaderInStart + sizeof(DHCP_Header_t)); uint8_t* DHCPOptionsOUTStart = (uint8_t*)(DHCPHeaderOutStart + sizeof(DHCP_Header_t)); @@ -73,7 +73,7 @@ int16_t DHCP_ProcessDHCPPacket(void* IPHeaderInStart, DHCPHeaderOUT->YourIP = ClientIPAddress; memmove(&DHCPHeaderOUT->ClientHardwareAddress, &DHCPHeaderIN->ClientHardwareAddress, sizeof(MAC_Address_t)); DHCPHeaderOUT->Cookie = SwapEndian_32(DHCP_MAGIC_COOKIE); - + /* Alter the incoming IP packet header so that the corrected IP source and destinations are used - this means that when the response IP header is generated, it will use the corrected addresses and not the null/broatcast addresses */ IPHeaderIN->SourceAddress = ClientIPAddress; @@ -81,7 +81,7 @@ int16_t DHCP_ProcessDHCPPacket(void* IPHeaderInStart, /* Process the incoming DHCP packet options */ while (DHCPOptionsINStart[0] != DHCP_OPTION_END) - { + { /* Find the Message Type DHCP option, to determine the type of DHCP packet */ if (DHCPOptionsINStart[0] == DHCP_OPTION_MESSAGETYPE) { @@ -107,14 +107,15 @@ int16_t DHCP_ProcessDHCPPacket(void* IPHeaderInStart, DHCPOptionsOUTStart += sizeof(IP_Address_t); *(DHCPOptionsOUTStart++) = DHCP_OPTION_END; - + return (sizeof(DHCP_Header_t) + 12 + sizeof(IP_Address_t)); } } - + /* Go to the next DHCP option - skip one byte if option is a padding byte, else skip the complete option's size */ DHCPOptionsINStart += ((DHCPOptionsINStart[0] == DHCP_OPTION_PAD) ? 1 : (DHCPOptionsINStart[1] + 2)); } - + return NO_RESPONSE; } + diff --git a/Demos/Device/ClassDriver/RNDISEthernet/Lib/DHCP.h b/Demos/Device/ClassDriver/RNDISEthernet/Lib/DHCP.h index 3bfdb29be..a4dc00dbb 100644 --- a/Demos/Device/ClassDriver/RNDISEthernet/Lib/DHCP.h +++ b/Demos/Device/ClassDriver/RNDISEthernet/Lib/DHCP.h @@ -1,7 +1,7 @@ /* LUFA Library Copyright (C) Dean Camera, 2010. - + dean [at] fourwalledcubicle [dot] com www.fourwalledcubicle.com */ @@ -9,13 +9,13 @@ /* Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com) - Permission to use, copy, modify, distribute, and sell this + Permission to use, copy, modify, distribute, and sell this software and its documentation for any purpose is hereby granted - without fee, provided that the above copyright notice appear in + without fee, 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 + 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 @@ -32,14 +32,14 @@ * * Header file for DHCP.c. */ - + #ifndef _DHCP_H_ #define _DHCP_H_ /* Includes: */ #include <avr/io.h> #include <string.h> - + #include "EthernetProtocols.h" #include "Ethernet.h" #include "ProtocolDecoders.h" @@ -50,13 +50,13 @@ /** DHCP operation constant, indicating a reply from a DHCP server to a host. */ #define DHCP_OP_BOOTREPLY 0x02 - + /** Hardware type constant, indicating Ethernet as a carrier. */ #define DHCP_HTYPE_ETHERNET 0x01 - + /** Magic boot protocol "cookie", inserted into all BOOTP packets (BOOTP is the carrier of DHCP). */ #define DHCP_MAGIC_COOKIE 0x63825363 - + /** DHCP option list entry header, indicating that a subnet mask will follow. */ #define DHCP_OPTION_SUBNETMASK 1 @@ -71,7 +71,7 @@ /** DHCP option list entry header, indicating the end of option data. */ #define DHCP_OPTION_END 255 - + /** Message type constant, used in the DHCP option data field, requesting that a DHCP server offer an IP address. */ #define DHCP_MESSAGETYPE_DISCOVER 1 @@ -106,16 +106,16 @@ uint16_t ElapsedSeconds; /**< Elapsed seconds since the request was made */ uint16_t Flags; /**< BOOTP packet flags */ - + IP_Address_t ClientIP; /**< Client IP address, if already leased an IP */ IP_Address_t YourIP; /**< Client IP address */ IP_Address_t NextServerIP; /**< Legacy BOOTP protocol field, unused for DHCP */ IP_Address_t RelayAgentIP; /**< Legacy BOOTP protocol field, unused for DHCP */ - + uint8_t ClientHardwareAddress[16]; /**< Hardware (MAC) address of the client making a request to the DHCP server */ uint8_t ServerHostnameString[64]; /**< Legacy BOOTP protocol field, unused for DHCP */ uint8_t BootFileName[128]; /**< Legacy BOOTP protocol field, unused for DHCP */ - + uint32_t Cookie; /**< Magic BOOTP protocol cookie to indicate a valid packet */ } DHCP_Header_t; @@ -125,3 +125,4 @@ void* DHCPHeaderOutStart); #endif + diff --git a/Demos/Device/ClassDriver/RNDISEthernet/Lib/Ethernet.c b/Demos/Device/ClassDriver/RNDISEthernet/Lib/Ethernet.c index 899b81f7e..687efe0c1 100644 --- a/Demos/Device/ClassDriver/RNDISEthernet/Lib/Ethernet.c +++ b/Demos/Device/ClassDriver/RNDISEthernet/Lib/Ethernet.c @@ -1,7 +1,7 @@ /* LUFA Library Copyright (C) Dean Camera, 2010. - + dean [at] fourwalledcubicle [dot] com www.fourwalledcubicle.com */ @@ -9,13 +9,13 @@ /* Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com) - Permission to use, copy, modify, distribute, and sell this + Permission to use, copy, modify, distribute, and sell this software and its documentation for any purpose is hereby granted - without fee, provided that the above copyright notice appear in + without fee, 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 + 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 @@ -34,7 +34,7 @@ * frames sent and received, deferring the processing of sub-packet protocols to the appropriate * protocol handlers, such as DHCP or ARP. */ - + #include "Ethernet.h" /** Constant for convenience when checking against or setting a MAC address to the virtual server MAC address. */ @@ -64,9 +64,9 @@ void Ethernet_ProcessPacket(Ethernet_Frame_Info_t* const FrameIN, /* Cast the incoming Ethernet frame to the Ethernet header type */ Ethernet_Frame_Header_t* FrameINHeader = (Ethernet_Frame_Header_t*)&FrameIN->FrameData; Ethernet_Frame_Header_t* FrameOUTHeader = (Ethernet_Frame_Header_t*)&FrameOUT->FrameData; - + int16_t RetSize = NO_RESPONSE; - + /* Ensure frame is addressed to either all (broadcast) or the virtual webserver, and is a type II frame */ if ((MAC_COMPARE(&FrameINHeader->Destination, &ServerMACAddress) || MAC_COMPARE(&FrameINHeader->Destination, &BroadcastMACAddress)) && @@ -78,14 +78,14 @@ void Ethernet_ProcessPacket(Ethernet_Frame_Info_t* const FrameIN, case ETHERTYPE_ARP: RetSize = ARP_ProcessARPPacket(&FrameIN->FrameData[sizeof(Ethernet_Frame_Header_t)], &FrameOUT->FrameData[sizeof(Ethernet_Frame_Header_t)]); - break; + break; case ETHERTYPE_IPV4: RetSize = IP_ProcessIPPacket(FrameIN, &FrameIN->FrameData[sizeof(Ethernet_Frame_Header_t)], &FrameOUT->FrameData[sizeof(Ethernet_Frame_Header_t)]); break; } - + /* Protocol processing routine has filled a response, complete the ethernet frame header */ if (RetSize > 0) { @@ -93,7 +93,7 @@ void Ethernet_ProcessPacket(Ethernet_Frame_Info_t* const FrameIN, FrameOUTHeader->Source = ServerMACAddress; FrameOUTHeader->Destination = FrameINHeader->Source; FrameOUTHeader->EtherType = FrameINHeader->EtherType; - + /* Set the response length in the buffer and indicate that a response is ready to be sent */ FrameOUT->FrameLength = (sizeof(Ethernet_Frame_Header_t) + RetSize); FrameOUT->FrameInBuffer = true; @@ -124,9 +124,10 @@ uint16_t Ethernet_Checksum16(void* Data, for (uint16_t CurrWord = 0; CurrWord < (Bytes >> 1); CurrWord++) Checksum += Words[CurrWord]; - + while (Checksum & 0xFFFF0000) Checksum = ((Checksum & 0xFFFF) + (Checksum >> 16)); - + return ~Checksum; } + diff --git a/Demos/Device/ClassDriver/RNDISEthernet/Lib/Ethernet.h b/Demos/Device/ClassDriver/RNDISEthernet/Lib/Ethernet.h index 233f48d1b..cd2cd8b4d 100644 --- a/Demos/Device/ClassDriver/RNDISEthernet/Lib/Ethernet.h +++ b/Demos/Device/ClassDriver/RNDISEthernet/Lib/Ethernet.h @@ -1,7 +1,7 @@ /* LUFA Library Copyright (C) Dean Camera, 2010. - + dean [at] fourwalledcubicle [dot] com www.fourwalledcubicle.com */ @@ -9,13 +9,13 @@ /* Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com) - Permission to use, copy, modify, distribute, and sell this + Permission to use, copy, modify, distribute, and sell this software and its documentation for any purpose is hereby granted - without fee, provided that the above copyright notice appear in + without fee, 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 + 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 @@ -32,14 +32,14 @@ * * Header file for Ethernet.c. */ - + #ifndef _ETHERNET_H_ #define _ETHERNET_H_ /* Includes: */ #include <avr/io.h> #include <string.h> - + #include <LUFA/Drivers/USB/Class/RNDIS.h> #include "EthernetProtocols.h" @@ -50,31 +50,31 @@ #include "DHCP.h" #include "ARP.h" #include "IP.h" - + /* Macros: */ /** Physical MAC address of the USB RNDIS network adapter. */ #define ADAPTER_MAC_ADDRESS {0x02, 0x00, 0x02, 0x00, 0x02, 0x00} /** Physical MAC address of the virtual server on the network. */ - #define SERVER_MAC_ADDRESS {0x00, 0x01, 0x00, 0x01, 0x00, 0x01} + #define SERVER_MAC_ADDRESS {0x00, 0x01, 0x00, 0x01, 0x00, 0x01} /** Physical MAC address of the network broadcast address. */ #define BROADCAST_MAC_ADDRESS {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF} - + /** Performs a comparison between two MAC addresses, indicating if they are identical. - * + * * \param[in] MAC1 First MAC address * \param[in] MAC2 Second MAC address * * \return True if the addresses match, false otherwise */ #define MAC_COMPARE(MAC1, MAC2) (memcmp(MAC1, MAC2, sizeof(MAC_Address_t)) == 0) - + /** Minimum size of an Ethernet packet in bytes, to conform to the Ethernet V2 packet standard. */ #define ETHERNET_VER2_MINSIZE 0x0600 /** Return value for all sub protocol handling routines, indicating that no response packet has been generated. */ - #define NO_RESPONSE 0 + #define NO_RESPONSE 0 /** Return value for all sub protocol handling routines, indicating that the packet has not yet been handled. */ #define NO_PROCESS -1 @@ -87,18 +87,19 @@ MAC_Address_t Source; /**< Physics MAC address of the packet source */ uint16_t EtherType; /**< Ethernet packet sub-protocol type, for Ethernet V2 packets */ } Ethernet_Frame_Header_t; - + /* External Variables: */ extern const MAC_Address_t ServerMACAddress; extern const IP_Address_t ServerIPAddress; extern const MAC_Address_t BroadcastMACAddress; extern const IP_Address_t BroadcastIPAddress; extern const IP_Address_t ClientIPAddress; - + /* Function Prototypes: */ void Ethernet_ProcessPacket(Ethernet_Frame_Info_t* const FrameIN, Ethernet_Frame_Info_t* const FrameOUT); uint16_t Ethernet_Checksum16(void* Data, uint16_t Bytes); - + #endif + diff --git a/Demos/Device/ClassDriver/RNDISEthernet/Lib/EthernetProtocols.h b/Demos/Device/ClassDriver/RNDISEthernet/Lib/EthernetProtocols.h index d5c93c695..2b0a71d01 100644 --- a/Demos/Device/ClassDriver/RNDISEthernet/Lib/EthernetProtocols.h +++ b/Demos/Device/ClassDriver/RNDISEthernet/Lib/EthernetProtocols.h @@ -1,7 +1,7 @@ /* LUFA Library Copyright (C) Dean Camera, 2010. - + dean [at] fourwalledcubicle [dot] com www.fourwalledcubicle.com */ @@ -9,13 +9,13 @@ /* Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com) - Permission to use, copy, modify, distribute, and sell this + Permission to use, copy, modify, distribute, and sell this software and its documentation for any purpose is hereby granted - without fee, provided that the above copyright notice appear in + without fee, 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 + 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 @@ -63,7 +63,7 @@ #define ETHERTYPE_FIBRECHANNEL 0x8906 #define ETHERTYPE_QINQ 0x9100 #define ETHERTYPE_VLLT 0xCAFE - + #define PROTOCOL_ICMP 1 #define PROTOCOL_IGMP 2 #define PROTOCOL_TCP 6 @@ -71,7 +71,7 @@ #define PROTOCOL_OSPF 89 #define PROTOCOL_SCTP 132 - /* Type Defines: */ + /* Type Defines: */ /** Type define for a protocol IP address of a device on a network. */ typedef struct { @@ -79,3 +79,4 @@ } IP_Address_t; #endif + diff --git a/Demos/Device/ClassDriver/RNDISEthernet/Lib/ICMP.c b/Demos/Device/ClassDriver/RNDISEthernet/Lib/ICMP.c index fec74b37b..11a09afb9 100644 --- a/Demos/Device/ClassDriver/RNDISEthernet/Lib/ICMP.c +++ b/Demos/Device/ClassDriver/RNDISEthernet/Lib/ICMP.c @@ -1,7 +1,7 @@ /* LUFA Library Copyright (C) Dean Camera, 2010. - + dean [at] fourwalledcubicle [dot] com www.fourwalledcubicle.com */ @@ -9,13 +9,13 @@ /* Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com) - Permission to use, copy, modify, distribute, and sell this + Permission to use, copy, modify, distribute, and sell this software and its documentation for any purpose is hereby granted - without fee, provided that the above copyright notice appear in + without fee, 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 + 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 @@ -34,7 +34,7 @@ * Echo requests from the host, to indicate a successful network connection between the host * and the virtual server. */ - + #include "ICMP.h" /** Processes an ICMP packet inside an Ethernet frame, and writes the appropriate response @@ -64,9 +64,9 @@ int16_t ICMP_ProcessICMPPacket(Ethernet_Frame_Info_t* const FrameIN, ICMPHeaderOUT->Checksum = 0; ICMPHeaderOUT->Id = ICMPHeaderIN->Id; ICMPHeaderOUT->Sequence = ICMPHeaderIN->Sequence; - + intptr_t DataSize = FrameIN->FrameLength - ((((intptr_t)InDataStart + sizeof(ICMP_Header_t)) - (intptr_t)FrameIN->FrameData)); - + /* Copy the remaining payload to the response - echo requests should echo back any sent data */ memmove(&((uint8_t*)OutDataStart)[sizeof(ICMP_Header_t)], &((uint8_t*)InDataStart)[sizeof(ICMP_Header_t)], @@ -77,6 +77,7 @@ int16_t ICMP_ProcessICMPPacket(Ethernet_Frame_Info_t* const FrameIN, /* Return the size of the response so far */ return (DataSize + sizeof(ICMP_Header_t)); } - + return NO_RESPONSE; } + diff --git a/Demos/Device/ClassDriver/RNDISEthernet/Lib/ICMP.h b/Demos/Device/ClassDriver/RNDISEthernet/Lib/ICMP.h index 9982560b1..26cd7cd1c 100644 --- a/Demos/Device/ClassDriver/RNDISEthernet/Lib/ICMP.h +++ b/Demos/Device/ClassDriver/RNDISEthernet/Lib/ICMP.h @@ -1,7 +1,7 @@ /* LUFA Library Copyright (C) Dean Camera, 2010. - + dean [at] fourwalledcubicle [dot] com www.fourwalledcubicle.com */ @@ -9,13 +9,13 @@ /* Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com) - Permission to use, copy, modify, distribute, and sell this + Permission to use, copy, modify, distribute, and sell this software and its documentation for any purpose is hereby granted - without fee, provided that the above copyright notice appear in + without fee, 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 + 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 @@ -39,18 +39,18 @@ /* Includes: */ #include <avr/io.h> #include <string.h> - + #include "EthernetProtocols.h" #include "Ethernet.h" #include "ProtocolDecoders.h" - + /* Macros: */ /** ICMP message type constant, indicating an ICMP ECHO Reply message. */ #define ICMP_TYPE_ECHOREPLY 0 /** ICMP message type constant, indicating a packet destination is unreachable. */ #define ICMP_TYPE_DESTINATIONUNREACHABLE 3 - + /** ICMP message type constant, indicating an ICMP Source Quench message. */ #define ICMP_TYPE_SOURCEQUENCH 4 @@ -62,7 +62,7 @@ /** ICMP message type constant, indicating an ICMP Time Exceeded message. */ #define ICMP_TYPE_TIMEEXCEEDED 11 - + /* Type Defines: */ /** Type define for an ICMP message header. */ typedef struct @@ -73,10 +73,11 @@ uint16_t Id; /**< Id of the ICMP message */ uint16_t Sequence; /**< Sequence number of the ICMP message, to link together message responses */ } ICMP_Header_t; - + /* Function Prototypes: */ int16_t ICMP_ProcessICMPPacket(Ethernet_Frame_Info_t* const FrameIN, void* InDataStart, void* OutDataStart); #endif + diff --git a/Demos/Device/ClassDriver/RNDISEthernet/Lib/IP.c b/Demos/Device/ClassDriver/RNDISEthernet/Lib/IP.c index 6f49eac88..5a2285c6d 100644 --- a/Demos/Device/ClassDriver/RNDISEthernet/Lib/IP.c +++ b/Demos/Device/ClassDriver/RNDISEthernet/Lib/IP.c @@ -1,7 +1,7 @@ /* LUFA Library Copyright (C) Dean Camera, 2010. - + dean [at] fourwalledcubicle [dot] com www.fourwalledcubicle.com */ @@ -9,13 +9,13 @@ /* Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com) - Permission to use, copy, modify, distribute, and sell this + Permission to use, copy, modify, distribute, and sell this software and its documentation for any purpose is hereby granted - without fee, provided that the above copyright notice appear in + without fee, 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 + 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 @@ -33,7 +33,7 @@ * Internet Protocol (IP) packet handling routines. This protocol handles IP packets from the * host which typically encapsulate other protocols such as ICMP, UDP and TCP. */ - + #include "IP.h" /** Processes an IP packet inside an Ethernet frame, and writes the appropriate response @@ -67,7 +67,7 @@ int16_t IP_ProcessIPPacket(Ethernet_Frame_Info_t* const FrameIN, { return NO_RESPONSE; } - + /* Pass off the IP payload to the appropriate protocol processing routine */ switch (IPHeaderIN->Protocol) { @@ -79,15 +79,15 @@ int16_t IP_ProcessIPPacket(Ethernet_Frame_Info_t* const FrameIN, case PROTOCOL_TCP: RetSize = TCP_ProcessTCPPacket(InDataStart, &((uint8_t*)InDataStart)[HeaderLengthBytes], - &((uint8_t*)OutDataStart)[sizeof(IP_Header_t)]); + &((uint8_t*)OutDataStart)[sizeof(IP_Header_t)]); break; case PROTOCOL_UDP: RetSize = UDP_ProcessUDPPacket(InDataStart, &((uint8_t*)InDataStart)[HeaderLengthBytes], - &((uint8_t*)OutDataStart)[sizeof(IP_Header_t)]); + &((uint8_t*)OutDataStart)[sizeof(IP_Header_t)]); break; } - + /* Check to see if the protocol processing routine has filled out a response */ if (RetSize > 0) { @@ -104,12 +104,13 @@ int16_t IP_ProcessIPPacket(Ethernet_Frame_Info_t* const FrameIN, IPHeaderOUT->TTL = DEFAULT_TTL; IPHeaderOUT->SourceAddress = IPHeaderIN->DestinationAddress; IPHeaderOUT->DestinationAddress = IPHeaderIN->SourceAddress; - + IPHeaderOUT->HeaderChecksum = Ethernet_Checksum16(IPHeaderOUT, sizeof(IP_Header_t)); - + /* Return the size of the response so far */ return (sizeof(IP_Header_t) + RetSize); } - + return RetSize; } + diff --git a/Demos/Device/ClassDriver/RNDISEthernet/Lib/IP.h b/Demos/Device/ClassDriver/RNDISEthernet/Lib/IP.h index 215695756..da9dc1549 100644 --- a/Demos/Device/ClassDriver/RNDISEthernet/Lib/IP.h +++ b/Demos/Device/ClassDriver/RNDISEthernet/Lib/IP.h @@ -1,7 +1,7 @@ /* LUFA Library Copyright (C) Dean Camera, 2010. - + dean [at] fourwalledcubicle [dot] com www.fourwalledcubicle.com */ @@ -9,13 +9,13 @@ /* Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com) - Permission to use, copy, modify, distribute, and sell this + Permission to use, copy, modify, distribute, and sell this software and its documentation for any purpose is hereby granted - without fee, provided that the above copyright notice appear in + without fee, 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 + 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 @@ -32,18 +32,18 @@ * * Header file for IP.c. */ - + #ifndef _IP_H_ #define _IP_H_ /* Includes: */ #include <avr/io.h> #include <string.h> - + #include "EthernetProtocols.h" #include "Ethernet.h" #include "ProtocolDecoders.h" - + /* Macros: */ /** Protocol IP address of the host (client) machine, once assigned by DHCP. */ #define CLIENT_IP_ADDRESS { 10, 0, 0, 1} @@ -58,16 +58,16 @@ * is reached. */ #define DEFAULT_TTL 128 - + /** Performs a comparison between two IP addresses, indicating if they are identical. - * + * * \param[in] IP1 First IP address * \param[in] IP2 Second IP address * * \return True if the addresses match, false otherwise */ #define IP_COMPARE(IP1, IP2) (memcmp(IP1, IP2, sizeof(IP_Address_t)) == 0) - + /* Type Defines: */ /** Type define of an IP packet header. */ typedef struct @@ -84,14 +84,15 @@ uint8_t TTL; /**< Maximum allowable number of hops to reach the packet destination */ uint8_t Protocol; /**< Encapsulated protocol type */ uint16_t HeaderChecksum; /**< Ethernet checksum of the IP header */ - + IP_Address_t SourceAddress; /**< Source protocol IP address of the packet */ IP_Address_t DestinationAddress; /**< Destination protocol IP address of the packet */ } IP_Header_t; - + /* Function Prototypes: */ int16_t IP_ProcessIPPacket(Ethernet_Frame_Info_t* const FrameIN, void* InDataStart, void* OutDataStart); #endif + diff --git a/Demos/Device/ClassDriver/RNDISEthernet/Lib/ProtocolDecoders.c b/Demos/Device/ClassDriver/RNDISEthernet/Lib/ProtocolDecoders.c index 676bf7a94..99e3ab46b 100644 --- a/Demos/Device/ClassDriver/RNDISEthernet/Lib/ProtocolDecoders.c +++ b/Demos/Device/ClassDriver/RNDISEthernet/Lib/ProtocolDecoders.c @@ -1,7 +1,7 @@ /* LUFA Library Copyright (C) Dean Camera, 2010. - + dean [at] fourwalledcubicle [dot] com www.fourwalledcubicle.com */ @@ -9,13 +9,13 @@ /* Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com) - Permission to use, copy, modify, distribute, and sell this + Permission to use, copy, modify, distribute, and sell this software and its documentation for any purpose is hereby granted - without fee, provided that the above copyright notice appear in + without fee, 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 + 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 @@ -31,7 +31,7 @@ /* Protocol decoders for Ethernet, TCP, IP, ICMP and ARP. Each of these routines accepts a header to the appropriate protocol and prints out pertinent information on the packet through the serial port. - + To disable printing of a specific protocol, define the token NO_DECODE_{Protocol} in the project makefile, and pass it to the compiler using the -D switch. */ @@ -46,7 +46,7 @@ * Packet decoding routines can be disabled by defining NO_DECODE_{Protocol Name} in the project makefile * and passing it to the compiler via the -D switch. */ - + #include "ProtocolDecoders.h" /** Decodes an Ethernet frame header and prints its contents to through the USART in a human readable format. @@ -57,9 +57,9 @@ void DecodeEthernetFrameHeader(Ethernet_Frame_Info_t* const FrameINData) { #if !defined(NO_DECODE_ETHERNET) Ethernet_Frame_Header_t* FrameHeader = (Ethernet_Frame_Header_t*)FrameINData->FrameData; - + printf_P(PSTR("\r\n")); - + printf_P(PSTR(" ETHERNET\r\n")); printf_P(PSTR(" + Frame Size: %u\r\n"), FrameINData->FrameLength); @@ -98,7 +98,7 @@ void DecodeEthernetFrameHeader(Ethernet_Frame_Info_t* const FrameINData) void DecodeARPHeader(void* InDataStart) { #if !defined(NO_DECODE_ARP) - ARP_Header_t* ARPHeader = (ARP_Header_t*)InDataStart; + ARP_Header_t* ARPHeader = (ARP_Header_t*)InDataStart; printf_P(PSTR(" \\\r\n ARP\r\n")); @@ -106,12 +106,12 @@ void DecodeARPHeader(void* InDataStart) !(MAC_COMPARE(&ARPHeader->THA, &ServerMACAddress))) { printf_P(PSTR(" + NOT ADDRESSED TO DEVICE\r\n")); - return; + return; } printf_P(PSTR(" + Protocol: %x\r\n"), SwapEndian_16(ARPHeader->ProtocolType)); printf_P(PSTR(" + Operation: %u\r\n"), SwapEndian_16(ARPHeader->Operation)); - + if (SwapEndian_16(ARPHeader->ProtocolType) == ETHERTYPE_IPV4) { printf_P(PSTR(" + SHA MAC: %02X:%02X:%02X:%02X:%02X:%02X\r\n"), ARPHeader->SHA.Octets[0], @@ -163,14 +163,14 @@ void DecodeIPHeader(void* InDataStart) printf_P(PSTR(" + Header Length: %u Bytes\r\n"), HeaderLengthBytes); printf_P(PSTR(" + Packet Version: %u\r\n"), IPHeader->Version); printf_P(PSTR(" + Total Length: %u\r\n"), SwapEndian_16(IPHeader->TotalLength)); - + printf_P(PSTR(" + Protocol: %u\r\n"), IPHeader->Protocol); printf_P(PSTR(" + TTL: %u\r\n"), IPHeader->TTL); - + printf_P(PSTR(" + IP Src: %u.%u.%u.%u\r\n"), IPHeader->SourceAddress.Octets[0], IPHeader->SourceAddress.Octets[1], IPHeader->SourceAddress.Octets[2], - IPHeader->SourceAddress.Octets[3]); + IPHeader->SourceAddress.Octets[3]); printf_P(PSTR(" + IP Dst: %u.%u.%u.%u\r\n"), IPHeader->DestinationAddress.Octets[0], IPHeader->DestinationAddress.Octets[1], @@ -215,9 +215,9 @@ void DecodeTCPHeader(void* InDataStart) printf_P(PSTR(" + Sequence Number: %lu\r\n"), SwapEndian_32(TCPHeader->SequenceNumber)); printf_P(PSTR(" + Acknowledgment Number: %lu\r\n"), SwapEndian_32(TCPHeader->AcknowledgmentNumber)); - + printf_P(PSTR(" + Flags: 0x%02X\r\n"), TCPHeader->Flags); - + if (TCP_GetPortState(TCPHeader->DestinationPort) == TCP_Port_Closed) printf_P(PSTR(" + NOT LISTENING ON DESTINATION PORT\r\n")); #endif @@ -272,9 +272,10 @@ void DecodeDHCPHeader(void* InDataStart) break; } } - + DHCPOptions += ((DHCPOptions[0] == DHCP_OPTION_PAD) ? 1 : (DHCPOptions[1] + 2)); } #endif } + diff --git a/Demos/Device/ClassDriver/RNDISEthernet/Lib/ProtocolDecoders.h b/Demos/Device/ClassDriver/RNDISEthernet/Lib/ProtocolDecoders.h index c1d3b395d..572fdeb82 100644 --- a/Demos/Device/ClassDriver/RNDISEthernet/Lib/ProtocolDecoders.h +++ b/Demos/Device/ClassDriver/RNDISEthernet/Lib/ProtocolDecoders.h @@ -1,7 +1,7 @@ /* LUFA Library Copyright (C) Dean Camera, 2010. - + dean [at] fourwalledcubicle [dot] com www.fourwalledcubicle.com */ @@ -9,13 +9,13 @@ /* Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com) - Permission to use, copy, modify, distribute, and sell this + Permission to use, copy, modify, distribute, and sell this software and its documentation for any purpose is hereby granted - without fee, provided that the above copyright notice appear in + without fee, 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 + 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 @@ -40,13 +40,13 @@ #include <avr/io.h> #include <avr/pgmspace.h> #include <stdio.h> - + #include <LUFA/Drivers/USB/Class/RNDIS.h> #include <LUFA/Drivers/Peripheral/SerialStream.h> - + #include "EthernetProtocols.h" #include "Ethernet.h" - + /* Function Prototypes: */ void DecodeEthernetFrameHeader(Ethernet_Frame_Info_t* const FrameINData); void DecodeARPHeader(void* InDataStart); @@ -57,3 +57,4 @@ void DecodeDHCPHeader(void* InDataStart); #endif + diff --git a/Demos/Device/ClassDriver/RNDISEthernet/Lib/TCP.c b/Demos/Device/ClassDriver/RNDISEthernet/Lib/TCP.c index 5889c45b3..dda9883ea 100644 --- a/Demos/Device/ClassDriver/RNDISEthernet/Lib/TCP.c +++ b/Demos/Device/ClassDriver/RNDISEthernet/Lib/TCP.c @@ -1,7 +1,7 @@ /* LUFA Library Copyright (C) Dean Camera, 2010. - + dean [at] fourwalledcubicle [dot] com www.fourwalledcubicle.com */ @@ -9,13 +9,13 @@ /* Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com) - Permission to use, copy, modify, distribute, and sell this + Permission to use, copy, modify, distribute, and sell this software and its documentation for any purpose is hereby granted - without fee, provided that the above copyright notice appear in + without fee, 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 + 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 @@ -34,7 +34,7 @@ * and reception of packets to and from devices on a network, to "ports" on the device. It is used in situations where data * delivery must be reliable and correct, e.g. HTTP, TELNET and most other non-streaming protocols. */ - + #define INCLUDE_FROM_TCP_C #include "TCP.h" @@ -64,7 +64,7 @@ void TCP_TCPTask(USB_ClassInfo_RNDIS_Device_t* const RNDISInterfaceInfo) for (uint8_t PTableEntry = 0; PTableEntry < MAX_OPEN_TCP_PORTS; PTableEntry++) { /* Run the application handler for the port */ - if ((PortStateTable[PTableEntry].Port == ConnectionStateTable[CSTableEntry].Port) && + if ((PortStateTable[PTableEntry].Port == ConnectionStateTable[CSTableEntry].Port) && (PortStateTable[PTableEntry].State == TCP_Port_Open)) { PortStateTable[PTableEntry].ApplicationHandler(&ConnectionStateTable[CSTableEntry], @@ -72,14 +72,14 @@ void TCP_TCPTask(USB_ClassInfo_RNDIS_Device_t* const RNDISInterfaceInfo) } } } - + /* Get pointer to the output frame info struct for convenience */ Ethernet_Frame_Info_t* FrameOUT = &RNDISInterfaceInfo->State.FrameOUT; - + /* Bail out early if there is already a frame waiting to be sent in the Ethernet OUT buffer */ if (FrameOUT->FrameInBuffer) return; - + /* Send response packets from each application as the TCP packet buffers are filled by the applications */ for (uint8_t CSTableEntry = 0; CSTableEntry < MAX_TCP_CONNECTIONS; CSTableEntry++) { @@ -111,7 +111,7 @@ void TCP_TCPTask(USB_ClassInfo_RNDIS_Device_t* const RNDISInterfaceInfo) TCPHeaderOUT->Reserved = 0; memcpy(TCPDataOUT, ConnectionStateTable[CSTableEntry].Info.Buffer.Data, PacketSize); - + ConnectionStateTable[CSTableEntry].Info.SequenceNumberOut += PacketSize; TCPHeaderOUT->Checksum = TCP_Checksum16(TCPHeaderOUT, ServerIPAddress, @@ -133,11 +133,11 @@ void TCP_TCPTask(USB_ClassInfo_RNDIS_Device_t* const RNDISInterfaceInfo) IPHeaderOUT->TTL = DEFAULT_TTL; IPHeaderOUT->SourceAddress = ServerIPAddress; IPHeaderOUT->DestinationAddress = ConnectionStateTable[CSTableEntry].RemoteAddress; - + IPHeaderOUT->HeaderChecksum = Ethernet_Checksum16(IPHeaderOUT, sizeof(IP_Header_t)); - + PacketSize += sizeof(IP_Header_t); - + /* Fill out the response Ethernet frame header */ FrameOUTHeader->Source = ServerMACAddress; FrameOUTHeader->Destination = (MAC_Address_t){{0x02, 0x00, 0x02, 0x00, 0x02, 0x00}}; @@ -148,9 +148,9 @@ void TCP_TCPTask(USB_ClassInfo_RNDIS_Device_t* const RNDISInterfaceInfo) /* Set the response length in the buffer and indicate that a response is ready to be sent */ FrameOUT->FrameLength = PacketSize; FrameOUT->FrameInBuffer = true; - + ConnectionStateTable[CSTableEntry].Info.Buffer.Ready = false; - + break; } } @@ -210,7 +210,7 @@ bool TCP_SetPortState(const uint16_t Port, return true; } } - + /* Port not in table and no room to add it, return failure */ return false; } @@ -237,7 +237,7 @@ uint8_t TCP_GetPortState(const uint16_t Port) if (PortStateTable[PTableEntry].Port == Port) return PortStateTable[PTableEntry].State; } - + /* Port not in table, assume closed */ return TCP_Port_Closed; } @@ -270,20 +270,20 @@ bool TCP_SetConnectionState(const uint16_t Port, return true; } } - + for (uint8_t CSTableEntry = 0; CSTableEntry < MAX_TCP_CONNECTIONS; CSTableEntry++) { /* Find empty entry in the table */ if (ConnectionStateTable[CSTableEntry].State == TCP_Connection_Closed) { ConnectionStateTable[CSTableEntry].Port = Port; - ConnectionStateTable[CSTableEntry].RemoteAddress = RemoteAddress; + ConnectionStateTable[CSTableEntry].RemoteAddress = RemoteAddress; ConnectionStateTable[CSTableEntry].RemotePort = RemotePort; ConnectionStateTable[CSTableEntry].State = State; return true; } } - + return false; } @@ -307,12 +307,12 @@ uint8_t TCP_GetConnectionState(const uint16_t Port, if ((ConnectionStateTable[CSTableEntry].Port == Port) && IP_COMPARE(&ConnectionStateTable[CSTableEntry].RemoteAddress, &RemoteAddress) && ConnectionStateTable[CSTableEntry].RemotePort == RemotePort) - + { return ConnectionStateTable[CSTableEntry].State; } } - + return TCP_Connection_Closed; } @@ -340,7 +340,7 @@ TCP_ConnectionInfo_t* TCP_GetConnectionInfo(const uint16_t Port, return &ConnectionStateTable[CSTableEntry].Info; } } - + return NULL; } @@ -364,11 +364,11 @@ int16_t TCP_ProcessTCPPacket(void* IPHeaderInStart, TCP_Header_t* TCPHeaderOUT = (TCP_Header_t*)TCPHeaderOutStart; TCP_ConnectionInfo_t* ConnectionInfo; - + DecodeTCPHeader(TCPHeaderInStart); bool PacketResponse = false; - + /* Check if the destination port is open and allows incoming connections */ if (TCP_GetPortState(TCPHeaderIN->DestinationPort) == TCP_Port_Open) { @@ -382,8 +382,8 @@ int16_t TCP_ProcessTCPPacket(void* IPHeaderInStart, if (TCP_SetConnectionState(TCPHeaderIN->DestinationPort, IPHeaderIN->SourceAddress, TCPHeaderIN->SourcePort, TCP_Connection_Closed)) { - TCPHeaderOUT->Flags = (TCP_FLAG_RST | TCP_FLAG_ACK); - PacketResponse = true; + TCPHeaderOUT->Flags = (TCP_FLAG_RST | TCP_FLAG_ACK); + PacketResponse = true; } } else @@ -398,7 +398,7 @@ int16_t TCP_ProcessTCPPacket(void* IPHeaderInStart, if (TCP_SetConnectionState(TCPHeaderIN->DestinationPort, IPHeaderIN->SourceAddress, TCPHeaderIN->SourcePort, TCP_Connection_SYNReceived)) { - TCPHeaderOUT->Flags = (TCP_FLAG_SYN | TCP_FLAG_ACK); + TCPHeaderOUT->Flags = (TCP_FLAG_SYN | TCP_FLAG_ACK); ConnectionInfo = TCP_GetConnectionInfo(TCPHeaderIN->DestinationPort, IPHeaderIN->SourceAddress, TCPHeaderIN->SourcePort); @@ -410,10 +410,10 @@ int16_t TCP_ProcessTCPPacket(void* IPHeaderInStart, { TCPHeaderOUT->Flags = TCP_FLAG_RST; } - + PacketResponse = true; } - + break; case TCP_Connection_SYNReceived: if (TCPHeaderIN->Flags == TCP_FLAG_ACK) @@ -425,19 +425,19 @@ int16_t TCP_ProcessTCPPacket(void* IPHeaderInStart, ConnectionInfo = TCP_GetConnectionInfo(TCPHeaderIN->DestinationPort, IPHeaderIN->SourceAddress, TCPHeaderIN->SourcePort); - + ConnectionInfo->SequenceNumberOut++; } - + break; case TCP_Connection_Established: if (TCPHeaderIN->Flags == (TCP_FLAG_FIN | TCP_FLAG_ACK)) { /* FIN ACK when connected to a peer starts the finalization process */ - - TCPHeaderOUT->Flags = (TCP_FLAG_FIN | TCP_FLAG_ACK); + + TCPHeaderOUT->Flags = (TCP_FLAG_FIN | TCP_FLAG_ACK); PacketResponse = true; - + TCP_SetConnectionState(TCPHeaderIN->DestinationPort, IPHeaderIN->SourceAddress, TCPHeaderIN->SourcePort, TCP_Connection_CloseWait); @@ -452,14 +452,14 @@ int16_t TCP_ProcessTCPPacket(void* IPHeaderInStart, ConnectionInfo = TCP_GetConnectionInfo(TCPHeaderIN->DestinationPort, IPHeaderIN->SourceAddress, TCPHeaderIN->SourcePort); - /* Check if the buffer is currently in use either by a buffered data to send, or receive */ + /* Check if the buffer is currently in use either by a buffered data to send, or receive */ if ((ConnectionInfo->Buffer.InUse == false) && (ConnectionInfo->Buffer.Ready == false)) - { + { ConnectionInfo->Buffer.Direction = TCP_PACKETDIR_IN; ConnectionInfo->Buffer.InUse = true; ConnectionInfo->Buffer.Length = 0; } - + /* Check if the buffer has been claimed by us to read in data from the peer */ if ((ConnectionInfo->Buffer.Direction == TCP_PACKETDIR_IN) && (ConnectionInfo->Buffer.Length != TCP_WINDOW_SIZE)) @@ -475,7 +475,7 @@ int16_t TCP_ProcessTCPPacket(void* IPHeaderInStart, ConnectionInfo->SequenceNumberIn += DataLength; ConnectionInfo->Buffer.Length += DataLength; - + /* Check if the buffer is full or if the PSH flag is set, if so indicate buffer ready */ if ((!(TCP_WINDOW_SIZE - ConnectionInfo->Buffer.Length)) || (TCPHeaderIN->Flags & TCP_FLAG_PSH)) { @@ -492,7 +492,7 @@ int16_t TCP_ProcessTCPPacket(void* IPHeaderInStart, return NO_PROCESS; } } - + break; case TCP_Connection_Closing: ConnectionInfo = TCP_GetConnectionInfo(TCPHeaderIN->DestinationPort, IPHeaderIN->SourceAddress, @@ -500,9 +500,9 @@ int16_t TCP_ProcessTCPPacket(void* IPHeaderInStart, TCPHeaderOUT->Flags = (TCP_FLAG_ACK | TCP_FLAG_FIN); PacketResponse = true; - + ConnectionInfo->Buffer.InUse = false; - + TCP_SetConnectionState(TCPHeaderIN->DestinationPort, IPHeaderIN->SourceAddress, TCPHeaderIN->SourcePort, TCP_Connection_FINWait1); @@ -518,7 +518,7 @@ int16_t TCP_ProcessTCPPacket(void* IPHeaderInStart, ConnectionInfo->SequenceNumberIn++; ConnectionInfo->SequenceNumberOut++; - + TCP_SetConnectionState(TCPHeaderIN->DestinationPort, IPHeaderIN->SourceAddress, TCPHeaderIN->SourcePort, TCP_Connection_Closed); } @@ -527,7 +527,7 @@ int16_t TCP_ProcessTCPPacket(void* IPHeaderInStart, TCP_SetConnectionState(TCPHeaderIN->DestinationPort, IPHeaderIN->SourceAddress, TCPHeaderIN->SourcePort, TCP_Connection_FINWait2); } - + break; case TCP_Connection_FINWait2: if (TCPHeaderIN->Flags == (TCP_FLAG_FIN | TCP_FLAG_ACK)) @@ -540,11 +540,11 @@ int16_t TCP_ProcessTCPPacket(void* IPHeaderInStart, ConnectionInfo->SequenceNumberIn++; ConnectionInfo->SequenceNumberOut++; - + TCP_SetConnectionState(TCPHeaderIN->DestinationPort, IPHeaderIN->SourceAddress, TCPHeaderIN->SourcePort, TCP_Connection_Closed); } - + break; case TCP_Connection_CloseWait: if (TCPHeaderIN->Flags == TCP_FLAG_ACK) @@ -552,7 +552,7 @@ int16_t TCP_ProcessTCPPacket(void* IPHeaderInStart, TCP_SetConnectionState(TCPHeaderIN->DestinationPort, IPHeaderIN->SourceAddress, TCPHeaderIN->SourcePort, TCP_Connection_Closed); } - + break; } } @@ -560,10 +560,10 @@ int16_t TCP_ProcessTCPPacket(void* IPHeaderInStart, else { /* Port is not open, indicate via a RST/ACK response to the sender */ - TCPHeaderOUT->Flags = (TCP_FLAG_RST | TCP_FLAG_ACK); + TCPHeaderOUT->Flags = (TCP_FLAG_RST | TCP_FLAG_ACK); PacketResponse = true; } - + /* Check if we need to respond to the sent packet */ if (PacketResponse) { @@ -575,7 +575,7 @@ int16_t TCP_ProcessTCPPacket(void* IPHeaderInStart, TCPHeaderOUT->SequenceNumber = SwapEndian_32(ConnectionInfo->SequenceNumberOut); TCPHeaderOUT->AcknowledgmentNumber = SwapEndian_32(ConnectionInfo->SequenceNumberIn); TCPHeaderOUT->DataOffset = (sizeof(TCP_Header_t) / sizeof(uint32_t)); - + if (!(ConnectionInfo->Buffer.InUse)) TCPHeaderOUT->WindowSize = SwapEndian_16(TCP_WINDOW_SIZE); else @@ -584,11 +584,11 @@ int16_t TCP_ProcessTCPPacket(void* IPHeaderInStart, TCPHeaderOUT->UrgentPointer = 0; TCPHeaderOUT->Checksum = 0; TCPHeaderOUT->Reserved = 0; - + TCPHeaderOUT->Checksum = TCP_Checksum16(TCPHeaderOUT, IPHeaderIN->DestinationAddress, - IPHeaderIN->SourceAddress, sizeof(TCP_Header_t)); + IPHeaderIN->SourceAddress, sizeof(TCP_Header_t)); - return sizeof(TCP_Header_t); + return sizeof(TCP_Header_t); } return NO_RESPONSE; @@ -610,10 +610,10 @@ static uint16_t TCP_Checksum16(void* TCPHeaderOutStart, const uint16_t TCPOutSize) { uint32_t Checksum = 0; - + /* TCP/IP checksums are the addition of the one's compliment of each word including the IP pseudo-header, complimented */ - + Checksum += ((uint16_t*)&SourceAddress)[0]; Checksum += ((uint16_t*)&SourceAddress)[1]; Checksum += ((uint16_t*)&DestinationAddress)[0]; @@ -623,12 +623,13 @@ static uint16_t TCP_Checksum16(void* TCPHeaderOutStart, for (uint16_t CurrWord = 0; CurrWord < (TCPOutSize >> 1); CurrWord++) Checksum += ((uint16_t*)TCPHeaderOutStart)[CurrWord]; - + if (TCPOutSize & 0x01) Checksum += (((uint16_t*)TCPHeaderOutStart)[TCPOutSize >> 1] & 0x00FF); - + while (Checksum & 0xFFFF0000) Checksum = ((Checksum & 0xFFFF) + (Checksum >> 16)); - + return ~Checksum; } + diff --git a/Demos/Device/ClassDriver/RNDISEthernet/Lib/TCP.h b/Demos/Device/ClassDriver/RNDISEthernet/Lib/TCP.h index d412647eb..721657e4a 100644 --- a/Demos/Device/ClassDriver/RNDISEthernet/Lib/TCP.h +++ b/Demos/Device/ClassDriver/RNDISEthernet/Lib/TCP.h @@ -1,7 +1,7 @@ /* LUFA Library Copyright (C) Dean Camera, 2010. - + dean [at] fourwalledcubicle [dot] com www.fourwalledcubicle.com */ @@ -9,13 +9,13 @@ /* Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com) - Permission to use, copy, modify, distribute, and sell this + Permission to use, copy, modify, distribute, and sell this software and its documentation for any purpose is hereby granted - without fee, provided that the above copyright notice appear in + without fee, 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 + 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 @@ -39,11 +39,11 @@ /* Includes: */ #include <avr/io.h> #include <stdbool.h> - + #include "EthernetProtocols.h" #include "Ethernet.h" #include "ProtocolDecoders.h" - + /* Macros: */ /** Maximum number of TCP ports which can be open at the one time. */ #define MAX_OPEN_TCP_PORTS 1 @@ -53,16 +53,16 @@ /** TCP window size, giving the maximum number of bytes which can be buffered at the one time. */ #define TCP_WINDOW_SIZE 512 - + /** Port number for HTTP transmissions. */ #define TCP_PORT_HTTP SwapEndian_16(80) - + /** Data direction indicator for a TCP application buffer, indicating data from host-to-device. */ #define TCP_PACKETDIR_IN false /** Data direction indicator for a TCP application buffer, indicating data from device-to-host. */ #define TCP_PACKETDIR_OUT true - + /** Congestion Window Reduced TCP flag mask. */ #define TCP_FLAG_CWR (1 << 7) @@ -86,7 +86,7 @@ /** Connection Finalize TCP flag mask. */ #define TCP_FLAG_FIN (1 << 0) - + /** Application macro: Determines if the given application buffer contains a packet received from the host * * \param[in] Buffer Application buffer to check @@ -138,7 +138,7 @@ * \param[in] Buffer Application buffer to clear */ #define TCP_APP_CLEAR_BUFFER(Buffer) MACROS{ Buffer->Ready = false; Buffer->Length = 0; }MACROE - + /** Application macro: Closes an open connection to a host. * * \param[in] Connection Open TCP connection to close @@ -152,7 +152,7 @@ TCP_Port_Closed = 0, /**< TCP port closed, no connections to a host may be made on this port. */ TCP_Port_Open = 1, /**< TCP port open, connections to a host may be made on this port. */ }; - + /** Enum for possible TCP connection states. */ enum TCP_ConnectionStates_t { @@ -166,9 +166,9 @@ TCP_Connection_Closing = 7, /**< Unused */ TCP_Connection_LastACK = 8, /**< Unused */ TCP_Connection_TimeWait = 9, /**< Unused */ - TCP_Connection_Closed = 10, /**< Connection closed in both directions */ + TCP_Connection_Closed = 10, /**< Connection closed in both directions */ }; - + /* Type Defines: */ /** Type define for a TCP connection buffer structure, including size, data and direction. */ typedef struct @@ -185,7 +185,7 @@ /** Type define for a TCP connection information structure. */ typedef struct { - uint32_t SequenceNumberIn; /**< Current TCP sequence number for host-to-device */ + uint32_t SequenceNumberIn; /**< Current TCP sequence number for host-to-device */ uint32_t SequenceNumberOut; /**< Current TCP sequence number for device-to-host */ TCP_ConnectionBuffer_t Buffer; /**< Connection application data buffer */ } TCP_ConnectionInfo_t; @@ -214,19 +214,19 @@ { uint16_t SourcePort; /**< Source port of the TCP packet */ uint16_t DestinationPort; /**< Destination port of the TCP packet */ - + uint32_t SequenceNumber; /**< Data sequence number of the packet */ uint32_t AcknowledgmentNumber; /**< Data acknowledgment number of the packet */ - + unsigned char Reserved : 4; /**< Reserved, must be all 0 */ unsigned char DataOffset : 4; /**< Offset of the data from the start of the header, in 4 byte chunks */ uint8_t Flags; /**< TCP packet flags */ uint16_t WindowSize; /**< Current data window size (bytes remaining in reception buffer) */ - + uint16_t Checksum; /**< TCP checksum */ uint16_t UrgentPointer; /**< Urgent data pointer */ } TCP_Header_t; - + /* Function Prototypes: */ void TCP_TCPTask(USB_ClassInfo_RNDIS_Device_t* const RNDISInterfaceInfo); void TCP_Init(void); @@ -256,3 +256,4 @@ #endif #endif + diff --git a/Demos/Device/ClassDriver/RNDISEthernet/Lib/UDP.c b/Demos/Device/ClassDriver/RNDISEthernet/Lib/UDP.c index 15b065656..9637bebcb 100644 --- a/Demos/Device/ClassDriver/RNDISEthernet/Lib/UDP.c +++ b/Demos/Device/ClassDriver/RNDISEthernet/Lib/UDP.c @@ -1,7 +1,7 @@ /* LUFA Library Copyright (C) Dean Camera, 2010. - + dean [at] fourwalledcubicle [dot] com www.fourwalledcubicle.com */ @@ -9,13 +9,13 @@ /* Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com) - Permission to use, copy, modify, distribute, and sell this + Permission to use, copy, modify, distribute, and sell this software and its documentation for any purpose is hereby granted - without fee, provided that the above copyright notice appear in + without fee, 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 + 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 @@ -33,7 +33,7 @@ * User Datagram Protocol (UDP) packet handling routines. This protocol handles high throughput, low * reliability packets which are typically used to encapsulate streaming data. */ - + #define INCLUDE_FROM_UDP_C #include "UDP.h" @@ -52,11 +52,11 @@ int16_t UDP_ProcessUDPPacket(void* IPHeaderInStart, { UDP_Header_t* UDPHeaderIN = (UDP_Header_t*)UDPHeaderInStart; UDP_Header_t* UDPHeaderOUT = (UDP_Header_t*)UDPHeaderOutStart; - + int16_t RetSize = NO_RESPONSE; - + DecodeUDPHeader(UDPHeaderInStart); - + switch (SwapEndian_16(UDPHeaderIN->DestinationPort)) { case UDP_PORT_DHCP_REQUEST: @@ -65,7 +65,7 @@ int16_t UDP_ProcessUDPPacket(void* IPHeaderInStart, &((uint8_t*)UDPHeaderOutStart)[sizeof(UDP_Header_t)]); break; } - + /* Check to see if the protocol processing routine has filled out a response */ if (RetSize > 0) { @@ -78,6 +78,7 @@ int16_t UDP_ProcessUDPPacket(void* IPHeaderInStart, /* Return the size of the response so far */ return (sizeof(UDP_Header_t) + RetSize); } - + return NO_RESPONSE; } + diff --git a/Demos/Device/ClassDriver/RNDISEthernet/Lib/UDP.h b/Demos/Device/ClassDriver/RNDISEthernet/Lib/UDP.h index 57abd0dc7..425bbe30d 100644 --- a/Demos/Device/ClassDriver/RNDISEthernet/Lib/UDP.h +++ b/Demos/Device/ClassDriver/RNDISEthernet/Lib/UDP.h @@ -1,7 +1,7 @@ /* LUFA Library Copyright (C) Dean Camera, 2010. - + dean [at] fourwalledcubicle [dot] com www.fourwalledcubicle.com */ @@ -9,13 +9,13 @@ /* Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com) - Permission to use, copy, modify, distribute, and sell this + Permission to use, copy, modify, distribute, and sell this software and its documentation for any purpose is hereby granted - without fee, provided that the above copyright notice appear in + without fee, 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 + 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 @@ -38,12 +38,12 @@ /* Includes: */ #include <avr/io.h> - + #include "EthernetProtocols.h" #include "Ethernet.h" #include "ProtocolDecoders.h" #include "DHCP.h" - + /* Macros: */ /** Source UDP port for a DHCP request. */ #define UDP_PORT_DHCP_REQUEST 67 @@ -60,10 +60,11 @@ uint16_t Length; /**< Total packet length, in bytes */ uint16_t Checksum; /**< Optional UDP packet checksum */ } UDP_Header_t; - + /* Function Prototypes: */ int16_t UDP_ProcessUDPPacket(void* IPHeaderInStart, void* UDPHeaderInStart, void* UDPHeaderOutStart); #endif + diff --git a/Demos/Device/ClassDriver/RNDISEthernet/Lib/Webserver.c b/Demos/Device/ClassDriver/RNDISEthernet/Lib/Webserver.c index 4fab86cfb..08ab0687b 100644 --- a/Demos/Device/ClassDriver/RNDISEthernet/Lib/Webserver.c +++ b/Demos/Device/ClassDriver/RNDISEthernet/Lib/Webserver.c @@ -1,7 +1,7 @@ /* LUFA Library Copyright (C) Dean Camera, 2010. - + dean [at] fourwalledcubicle [dot] com www.fourwalledcubicle.com */ @@ -9,13 +9,13 @@ /* Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com) - Permission to use, copy, modify, distribute, and sell this + Permission to use, copy, modify, distribute, and sell this software and its documentation for any purpose is hereby granted - without fee, provided that the above copyright notice appear in + without fee, 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 + 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 @@ -54,7 +54,7 @@ char PROGMEM HTTP404Header[] = "HTTP/1.1 404 Not Found\r\n" /** HTTP page to serve to the host when a HTTP request is made. This page is too long for a single response, thus it is automatically * broken up into smaller blocks and sent as a series of packets each time the webserver application callback is run. */ -char PROGMEM HTTPPage[] = +char PROGMEM HTTPPage[] = "<html>" " <head>" " <title>" @@ -108,7 +108,7 @@ void Webserver_ApplicationCallback(TCP_ConnectionState_t* const ConnectionState, { char* BufferDataStr = (char*)Buffer->Data; static uint8_t PageBlock = 0; - + /* Check to see if a packet has been received on the HTTP port from a remote host */ if (TCP_APP_HAS_RECEIVED_PACKET(Buffer)) { @@ -120,7 +120,7 @@ void Webserver_ApplicationCallback(TCP_ConnectionState_t* const ConnectionState, /* Copy the HTTP 200 response header into the packet buffer */ strcpy_P(BufferDataStr, HTTP200Header); - + /* Send the buffer contents to the host */ TCP_APP_SEND_BUFFER(Buffer, strlen(BufferDataStr)); @@ -131,10 +131,10 @@ void Webserver_ApplicationCallback(TCP_ConnectionState_t* const ConnectionState, { /* Copy the HTTP 404 response header into the packet buffer */ strcpy_P(BufferDataStr, HTTP404Header); - + /* Send the buffer contents to the host */ TCP_APP_SEND_BUFFER(Buffer, strlen(BufferDataStr)); - + /* All data sent, close the connection */ TCP_APP_CLOSECONNECTION(ConnectionState); } @@ -155,9 +155,9 @@ void Webserver_ApplicationCallback(TCP_ConnectionState_t* const ConnectionState, strcpy_P(BufferDataStr, HTTP404Header); /* Send the buffer contents to the host */ - TCP_APP_SEND_BUFFER(Buffer, strlen(BufferDataStr)); + TCP_APP_SEND_BUFFER(Buffer, strlen(BufferDataStr)); } - + /* All data sent, close the connection */ TCP_APP_CLOSECONNECTION(ConnectionState); } @@ -165,7 +165,7 @@ void Webserver_ApplicationCallback(TCP_ConnectionState_t* const ConnectionState, { /* Echo the host's query back to the host */ TCP_APP_SEND_BUFFER(Buffer, Buffer->Length); - + /* All data sent, close the connection */ TCP_APP_CLOSECONNECTION(ConnectionState); } @@ -179,13 +179,13 @@ void Webserver_ApplicationCallback(TCP_ConnectionState_t* const ConnectionState, { uint16_t RemLength = strlen_P(&HTTPPage[PageBlock * HTTP_REPLY_BLOCK_SIZE]); uint16_t Length; - + /* Determine the length of the loaded block */ Length = ((RemLength > HTTP_REPLY_BLOCK_SIZE) ? HTTP_REPLY_BLOCK_SIZE : RemLength); /* Copy the next buffer sized block of the page to the packet buffer */ strncpy_P(BufferDataStr, &HTTPPage[PageBlock * HTTP_REPLY_BLOCK_SIZE], Length); - + /* Send the buffer contents to the host */ TCP_APP_SEND_BUFFER(Buffer, Length); @@ -194,9 +194,10 @@ void Webserver_ApplicationCallback(TCP_ConnectionState_t* const ConnectionState, { /* Unlock the buffer so that the host can fill it with future packets */ TCP_APP_RELEASE_BUFFER(Buffer); - + /* Close the connection to the host */ TCP_APP_CLOSECONNECTION(ConnectionState); } } } + diff --git a/Demos/Device/ClassDriver/RNDISEthernet/Lib/Webserver.h b/Demos/Device/ClassDriver/RNDISEthernet/Lib/Webserver.h index 87fe1c91d..7abd6adc9 100644 --- a/Demos/Device/ClassDriver/RNDISEthernet/Lib/Webserver.h +++ b/Demos/Device/ClassDriver/RNDISEthernet/Lib/Webserver.h @@ -1,7 +1,7 @@ /* LUFA Library Copyright (C) Dean Camera, 2010. - + dean [at] fourwalledcubicle [dot] com www.fourwalledcubicle.com */ @@ -9,13 +9,13 @@ /* Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com) - Permission to use, copy, modify, distribute, and sell this + Permission to use, copy, modify, distribute, and sell this software and its documentation for any purpose is hereby granted - without fee, provided that the above copyright notice appear in + without fee, 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 + 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 @@ -32,25 +32,26 @@ * * Header file for Webserver.c. */ - + #ifndef _WEBSERVER_H_ #define _WEBSERVER_H_ /* Includes: */ #include <avr/io.h> #include <avr/pgmspace.h> - + #include <LUFA/Version.h> - + #include "TCP.h" - + /* Macros: */ /** Maximum size of a HTTP response per transmission */ #define HTTP_REPLY_BLOCK_SIZE 128 - + /* Function Prototypes: */ void Webserver_Init(void); void Webserver_ApplicationCallback(TCP_ConnectionState_t* const ConnectionState, TCP_ConnectionBuffer_t* const Buffer); #endif + diff --git a/Demos/Device/ClassDriver/RNDISEthernet/RNDISEthernet.c b/Demos/Device/ClassDriver/RNDISEthernet/RNDISEthernet.c index d332b206a..1dbd7db5a 100644 --- a/Demos/Device/ClassDriver/RNDISEthernet/RNDISEthernet.c +++ b/Demos/Device/ClassDriver/RNDISEthernet/RNDISEthernet.c @@ -1,7 +1,7 @@ /* LUFA Library Copyright (C) Dean Camera, 2010. - + dean [at] fourwalledcubicle [dot] com www.fourwalledcubicle.com */ @@ -9,13 +9,13 @@ /* Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com) - Permission to use, copy, modify, distribute, and sell this + Permission to use, copy, modify, distribute, and sell this software and its documentation for any purpose is hereby granted - without fee, provided that the above copyright notice appear in + without fee, 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 + 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 @@ -57,7 +57,7 @@ USB_ClassInfo_RNDIS_Device_t Ethernet_RNDIS_Interface = .NotificationEndpointNumber = CDC_NOTIFICATION_EPNUM, .NotificationEndpointSize = CDC_NOTIFICATION_EPSIZE, .NotificationEndpointDoubleBank = false, - + .AdapterVendorDescription = "LUFA RNDIS Demo Adapter", .AdapterMACAddress = {ADAPTER_MAC_ADDRESS}, }, @@ -135,3 +135,4 @@ void EVENT_USB_Device_UnhandledControlRequest(void) { RNDIS_Device_ProcessControlRequest(&Ethernet_RNDIS_Interface); } + diff --git a/Demos/Device/ClassDriver/RNDISEthernet/RNDISEthernet.h b/Demos/Device/ClassDriver/RNDISEthernet/RNDISEthernet.h index a689ee819..2cbdb3104 100644 --- a/Demos/Device/ClassDriver/RNDISEthernet/RNDISEthernet.h +++ b/Demos/Device/ClassDriver/RNDISEthernet/RNDISEthernet.h @@ -1,7 +1,7 @@ /* LUFA Library Copyright (C) Dean Camera, 2010. - + dean [at] fourwalledcubicle [dot] com www.fourwalledcubicle.com */ @@ -9,13 +9,13 @@ /* Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com) - Permission to use, copy, modify, distribute, and sell this + Permission to use, copy, modify, distribute, and sell this software and its documentation for any purpose is hereby granted - without fee, provided that the above copyright notice appear in + without fee, 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 + 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 @@ -32,7 +32,7 @@ * * Header file for RNDISEthernet.c. */ - + #ifndef _RNDISETHERNET_H_ #define _RNDISETHERNET_H_ @@ -71,7 +71,7 @@ /** LED mask for the library LED driver, to indicate that the USB interface is busy. */ #define LEDMASK_USB_BUSY LEDS_LED2 - + /* Function Prototypes: */ void SetupHardware(void); @@ -79,5 +79,6 @@ void EVENT_USB_Device_Disconnect(void); void EVENT_USB_Device_ConfigurationChanged(void); void EVENT_USB_Device_UnhandledControlRequest(void); - + #endif + diff --git a/Demos/Device/ClassDriver/RNDISEthernet/RNDISEthernet.txt b/Demos/Device/ClassDriver/RNDISEthernet/RNDISEthernet.txt index f9cd651d0..906ea0101 100644 --- a/Demos/Device/ClassDriver/RNDISEthernet/RNDISEthernet.txt +++ b/Demos/Device/ClassDriver/RNDISEthernet/RNDISEthernet.txt @@ -3,7 +3,7 @@ * This file contains special DoxyGen information for the generation of the main page and other special * documentation pages. It is not a project source file. */ - + /** \mainpage RNDIS Class Ethernet Demo (with Webserver/Telnet) * * \section SSec_Compat Demo Compatibility: @@ -26,7 +26,7 @@ * <td><b>USB Class:</b></td> * <td>Communications Device Class (CDC)</td> * </tr> - * <tr> + * <tr> * <td><b>USB Subclass:</b></td> * <td>Remote NDIS (Microsoft Proprietary CDC Class Networking Standard)</td> * </tr> @@ -40,7 +40,7 @@ * </tr> * </table> * - * \section SSec_Description Project Description: + * \section SSec_Description Project Description: * * Remote Network Driver Interface demonstration application. * This gives a simple reference application for implementing @@ -49,7 +49,7 @@ * standard; this demo will only work on Windows 2000 (manually * patched with the Microsoft RNDIS hotfix) and above (with no * manual patches), or on the latest Linux kernels. - * + * * Before running, you will need to install the INF file that * is located in the RNDISEthernet project directory. This will * enable Windows to use its inbuilt RNDIS drivers, negating the @@ -58,7 +58,7 @@ * Windows 2000 is used, the Microsoft INF file in the hotfix * will need to be altered to use the VID/PID of the demo and * then chosen instead of the LUFA RNDIS INF file when prompted. - * + * * When enumerated, this demo will install as a new network * adapter which ethernet packets can be sent to and received * from. Running on top of the adapter is a very simple TCP/IP @@ -66,10 +66,10 @@ * accessed through a web browser at IP address 10.0.0.2:80 or * through a TELNET client at 10.0.0.2:25. This device also supports * ping echos via the ICMP protocol. - * + * * \note The TCP/IP stack in this demo has a number of limitations * and should serve as an example only - it is not fully featured nor - * compliant to the TCP/IP specification. For complete projects, it is + * compliant to the TCP/IP specification. For complete projects, it is * recommended that it be replaced with an external open source TCP/IP * stack that is feature complete, such as the uIP stack. * @@ -120,3 +120,4 @@ * </tr> * </table> */ + diff --git a/Demos/Device/ClassDriver/RNDISEthernet/makefile b/Demos/Device/ClassDriver/RNDISEthernet/makefile index 2d0a6ef40..2d3e5d541 100644 --- a/Demos/Device/ClassDriver/RNDISEthernet/makefile +++ b/Demos/Device/ClassDriver/RNDISEthernet/makefile @@ -47,7 +47,7 @@ # make doxygen = Generate DoxyGen documentation for the project (must have # DoxyGen installed) # -# make debug = Start either simulavr or avarice as specified for debugging, +# make debug = Start either simulavr or avarice as specified for debugging, # with avr-gdb or avr-insight as the front end for debugging. # # make filename.s = Just compile filename.c into the assembler code only. @@ -64,14 +64,14 @@ MCU = at90usb1287 # Target board (see library "Board Types" documentation, NONE for projects not requiring -# LUFA board drivers). If USER is selected, put custom board drivers in a directory called +# LUFA board drivers). If USER is selected, put custom board drivers in a directory called # "Board" inside the application directory. BOARD = USBKEY # Processor frequency. -# This will define a symbol, F_CPU, in all source code files equal to the -# processor frequency in Hz. You can then use this symbol in your source code to +# This will define a symbol, F_CPU, in all source code files equal to the +# processor frequency in Hz. You can then use this symbol in your source code to # calculate timings. Do NOT tack on a 'UL' at the end, this will be done # automatically to create a 32-bit value in your source code. # @@ -84,7 +84,7 @@ F_CPU = 8000000 # Input clock frequency. -# This will define a symbol, F_CLOCK, in all source code files equal to the +# This will define a symbol, F_CLOCK, in all source code files equal to the # input clock frequency (before any prescaling is performed) in Hz. This value may # differ from F_CPU if prescaling is used on the latter, and is required as the # raw input clock is fed directly to the PLL sections of the AVR for high speed @@ -154,7 +154,7 @@ SRC = $(TARGET).c \ # List C++ source files here. (C dependencies are automatically generated.) -CPPSRC = +CPPSRC = # List Assembler source files here. @@ -167,7 +167,7 @@ CPPSRC = ASRC = -# Optimization level, can be [0, 1, 2, 3, s]. +# Optimization level, can be [0, 1, 2, 3, s]. # 0 = turn off optimization. s = optimize for size. # (Note: 3 is not always the best optimization level. See avr-libc FAQ.) OPT = s @@ -281,7 +281,7 @@ CPPFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS)) # for use in COFF files, additional information about filenames # and function names needs to be present in the assembler source # files -- see avr-libc docs [FIXME: not yet described there] -# -listing-cont-lines: Sets the maximum number of continuation lines of hex +# -listing-cont-lines: Sets the maximum number of continuation lines of hex # dump that will be displayed for a given single line of source input. ASFLAGS = $(ADEFS) -Wa,-adhlns=$(<:%.S=$(OBJDIR)/%.lst),-gstabs,--listing-cont-lines=100 @@ -294,7 +294,7 @@ PRINTF_LIB_MIN = -Wl,-u,vfprintf -lprintf_min PRINTF_LIB_FLOAT = -Wl,-u,vfprintf -lprintf_flt # If this is left blank, then it will use the Standard printf version. -PRINTF_LIB = +PRINTF_LIB = #PRINTF_LIB = $(PRINTF_LIB_MIN) #PRINTF_LIB = $(PRINTF_LIB_FLOAT) @@ -306,7 +306,7 @@ SCANF_LIB_MIN = -Wl,-u,vfscanf -lscanf_min SCANF_LIB_FLOAT = -Wl,-u,vfscanf -lscanf_flt # If this is left blank, then it will use the Standard scanf version. -SCANF_LIB = +SCANF_LIB = #SCANF_LIB = $(SCANF_LIB_MIN) #SCANF_LIB = $(SCANF_LIB_FLOAT) @@ -318,7 +318,7 @@ MATH_LIB = -lm # Each directory must be seperated by a space. # Use forward slashes for directory separators. # For a directory that has spaces, enclose it in quotes. -EXTRALIBDIRS = +EXTRALIBDIRS = @@ -341,7 +341,7 @@ EXTMEMOPTS = # -Map: create map file # --cref: add cross reference to map file LDFLAGS = -Wl,-Map=$(TARGET).map,--cref -LDFLAGS += -Wl,--relax +LDFLAGS += -Wl,--relax LDFLAGS += -Wl,--gc-sections LDFLAGS += $(EXTMEMOPTS) LDFLAGS += $(patsubst %,-L%,$(EXTRALIBDIRS)) @@ -375,7 +375,7 @@ AVRDUDE_WRITE_FLASH = -U flash:w:$(TARGET).hex #AVRDUDE_NO_VERIFY = -V # Increase verbosity level. Please use this when submitting bug -# reports about avrdude. See <http://savannah.nongnu.org/projects/avrdude> +# reports about avrdude. See <http://savannah.nongnu.org/projects/avrdude> # to submit bug reports. #AVRDUDE_VERBOSE = -v -v @@ -409,7 +409,7 @@ JTAG_DEV = /dev/com1 DEBUG_PORT = 4242 # Debugging host used to communicate between GDB / avarice / simulavr, normally -# just set to localhost unless doing some sort of crazy debugging when +# just set to localhost unless doing some sort of crazy debugging when # avarice is running on a different computer. DEBUG_HOST = localhost @@ -438,7 +438,7 @@ WINSHELL = cmd MSG_ERRORS_NONE = Errors: none MSG_BEGIN = -------- begin -------- MSG_END = -------- end -------- -MSG_SIZE_BEFORE = Size before: +MSG_SIZE_BEFORE = Size before: MSG_SIZE_AFTER = Size after: MSG_COFF = Converting to AVR COFF: MSG_EXTENDED_COFF = Converting to AVR Extended COFF: @@ -457,10 +457,10 @@ MSG_CREATING_LIBRARY = Creating library: # Define all object files. -OBJ = $(SRC:%.c=$(OBJDIR)/%.o) $(CPPSRC:%.cpp=$(OBJDIR)/%.o) $(ASRC:%.S=$(OBJDIR)/%.o) +OBJ = $(SRC:%.c=$(OBJDIR)/%.o) $(CPPSRC:%.cpp=$(OBJDIR)/%.o) $(ASRC:%.S=$(OBJDIR)/%.o) # Define all listing files. -LST = $(SRC:%.c=$(OBJDIR)/%.lst) $(CPPSRC:%.cpp=$(OBJDIR)/%.lst) $(ASRC:%.S=$(OBJDIR)/%.lst) +LST = $(SRC:%.c=$(OBJDIR)/%.lst) $(CPPSRC:%.cpp=$(OBJDIR)/%.lst) $(ASRC:%.S=$(OBJDIR)/%.lst) # Compiler flags to generate dependency files. @@ -525,11 +525,11 @@ sizeafter: # Display compiler version information. -gccversion : +gccversion : @$(CC) --version -# Program the device. +# Program the device. program: $(TARGET).hex $(TARGET).eep $(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH) $(AVRDUDE_WRITE_EEPROM) @@ -556,9 +556,9 @@ dfu-ee: $(TARGET).hex $(TARGET).eep # Generate avr-gdb config/init file which does the following: -# define the reset signal, load the target file, connect to target, and set +# define the reset signal, load the target file, connect to target, and set # a breakpoint at main(). -gdb-config: +gdb-config: @$(REMOVE) $(GDBINIT_FILE) @echo define reset >> $(GDBINIT_FILE) @echo SIGNAL SIGHUP >> $(GDBINIT_FILE) @@ -656,14 +656,14 @@ extcoff: $(TARGET).elf $(OBJDIR)/%.o : %.c @echo @echo $(MSG_COMPILING) $< - $(CC) -c $(ALL_CFLAGS) $< -o $@ + $(CC) -c $(ALL_CFLAGS) $< -o $@ # Compile: create object files from C++ source files. $(OBJDIR)/%.o : %.cpp @echo @echo $(MSG_COMPILING_CPP) $< - $(CC) -c $(ALL_CPPFLAGS) $< -o $@ + $(CC) -c $(ALL_CPPFLAGS) $< -o $@ # Compile: create assembler files from C source files. @@ -685,7 +685,7 @@ $(OBJDIR)/%.o : %.S # Create preprocessed source for use in sending a bug report. %.i : %.c - $(CC) -E -mmcu=$(MCU) -I. $(CFLAGS) $< -o $@ + $(CC) -E -mmcu=$(MCU) -I. $(CFLAGS) $< -o $@ # Target: clean project. @@ -728,4 +728,4 @@ $(shell mkdir $(OBJDIR) 2>/dev/null) .PHONY : all begin finish end sizebefore sizeafter gccversion \ build elf hex eep lss sym coff extcoff doxygen clean \ clean_list clean_doxygen program dfu flip flip-ee dfu-ee \ -debug gdb-config
\ No newline at end of file +debug gdb-config |