aboutsummaryrefslogtreecommitdiffstats
path: root/Demos/Device/ClassDriver/RNDISEthernet/Lib
diff options
context:
space:
mode:
Diffstat (limited to 'Demos/Device/ClassDriver/RNDISEthernet/Lib')
-rw-r--r--Demos/Device/ClassDriver/RNDISEthernet/Lib/ARP.c19
-rw-r--r--Demos/Device/ClassDriver/RNDISEthernet/Lib/ARP.h25
-rw-r--r--Demos/Device/ClassDriver/RNDISEthernet/Lib/DHCP.c27
-rw-r--r--Demos/Device/ClassDriver/RNDISEthernet/Lib/DHCP.h31
-rw-r--r--Demos/Device/ClassDriver/RNDISEthernet/Lib/Ethernet.c29
-rw-r--r--Demos/Device/ClassDriver/RNDISEthernet/Lib/Ethernet.h35
-rw-r--r--Demos/Device/ClassDriver/RNDISEthernet/Lib/EthernetProtocols.h17
-rw-r--r--Demos/Device/ClassDriver/RNDISEthernet/Lib/ICMP.c21
-rw-r--r--Demos/Device/ClassDriver/RNDISEthernet/Lib/ICMP.h23
-rw-r--r--Demos/Device/ClassDriver/RNDISEthernet/Lib/IP.c29
-rw-r--r--Demos/Device/ClassDriver/RNDISEthernet/Lib/IP.h29
-rw-r--r--Demos/Device/ClassDriver/RNDISEthernet/Lib/ProtocolDecoders.c39
-rw-r--r--Demos/Device/ClassDriver/RNDISEthernet/Lib/ProtocolDecoders.h19
-rw-r--r--Demos/Device/ClassDriver/RNDISEthernet/Lib/TCP.c121
-rw-r--r--Demos/Device/ClassDriver/RNDISEthernet/Lib/TCP.h43
-rw-r--r--Demos/Device/ClassDriver/RNDISEthernet/Lib/UDP.c25
-rw-r--r--Demos/Device/ClassDriver/RNDISEthernet/Lib/UDP.h19
-rw-r--r--Demos/Device/ClassDriver/RNDISEthernet/Lib/Webserver.c35
-rw-r--r--Demos/Device/ClassDriver/RNDISEthernet/Lib/Webserver.h23
19 files changed, 314 insertions, 295 deletions
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
+