Clean up excessive whitespace at the end of each line using the wspurify tool made by Laszlo Monda
This commit is contained in:
parent
a8871c7fba
commit
5a4def7478
760 changed files with 12883 additions and 12164 deletions
|
@ -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,9 +30,9 @@
|
|||
|
||||
/** \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"
|
||||
|
@ -57,22 +57,22 @@
|
|||
USB_Descriptor_Device_t PROGMEM DeviceDescriptor =
|
||||
{
|
||||
.Header = {.Size = sizeof(USB_Descriptor_Device_t), .Type = DTYPE_Device},
|
||||
|
||||
|
||||
.USBSpecification = VERSION_BCD(01.10),
|
||||
.Class = 0x00,
|
||||
.SubClass = 0x00,
|
||||
.Protocol = 0x00,
|
||||
|
||||
|
||||
.Endpoint0Size = FIXED_CONTROL_ENDPOINT_SIZE,
|
||||
|
||||
|
||||
.VendorID = 0x03EB,
|
||||
.ProductID = 0x2045,
|
||||
.ReleaseNumber = VERSION_BCD(00.01),
|
||||
|
||||
|
||||
.ManufacturerStrIndex = 0x01,
|
||||
.ProductStrIndex = 0x02,
|
||||
.SerialNumStrIndex = USE_INTERNAL_SERIAL,
|
||||
|
||||
|
||||
.NumberOfConfigurations = FIXED_NUM_CONFIGURATIONS
|
||||
};
|
||||
|
||||
|
@ -83,38 +83,38 @@ 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 = 1,
|
||||
|
||||
|
||||
.ConfigurationNumber = 1,
|
||||
.ConfigurationStrIndex = NO_DESCRIPTOR,
|
||||
|
||||
|
||||
.ConfigAttributes = USB_CONFIG_ATTR_BUSPOWERED,
|
||||
|
||||
|
||||
.MaxPowerConsumption = USB_CONFIG_POWER_MA(100)
|
||||
},
|
||||
|
||||
.MS_Interface =
|
||||
|
||||
.MS_Interface =
|
||||
{
|
||||
.Header = {.Size = sizeof(USB_Descriptor_Interface_t), .Type = DTYPE_Interface},
|
||||
|
||||
.InterfaceNumber = 0,
|
||||
.AlternateSetting = 0,
|
||||
|
||||
|
||||
.TotalEndpoints = 2,
|
||||
|
||||
|
||||
.Class = 0x08,
|
||||
.SubClass = 0x06,
|
||||
.Protocol = 0x50,
|
||||
|
||||
|
||||
.InterfaceStrIndex = NO_DESCRIPTOR
|
||||
},
|
||||
|
||||
.MS_DataInEndpoint =
|
||||
.MS_DataInEndpoint =
|
||||
{
|
||||
.Header = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint},
|
||||
|
||||
|
@ -124,7 +124,7 @@ USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor =
|
|||
.PollingIntervalMS = 0x00
|
||||
},
|
||||
|
||||
.MS_DataOutEndpoint =
|
||||
.MS_DataOutEndpoint =
|
||||
{
|
||||
.Header = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint},
|
||||
|
||||
|
@ -142,7 +142,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}
|
||||
};
|
||||
|
||||
|
@ -153,7 +153,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"
|
||||
};
|
||||
|
||||
|
@ -164,7 +164,7 @@ USB_Descriptor_String_t PROGMEM ManufacturerString =
|
|||
USB_Descriptor_String_t PROGMEM ProductString =
|
||||
{
|
||||
.Header = {.Size = USB_STRING_LEN(14), .Type = DTYPE_String},
|
||||
|
||||
|
||||
.UnicodeString = L"LUFA Webserver"
|
||||
};
|
||||
|
||||
|
@ -186,34 +186,35 @@ uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue,
|
|||
|
||||
switch (DescriptorType)
|
||||
{
|
||||
case DTYPE_Device:
|
||||
case DTYPE_Device:
|
||||
Address = &DeviceDescriptor;
|
||||
Size = sizeof(USB_Descriptor_Device_t);
|
||||
break;
|
||||
case DTYPE_Configuration:
|
||||
case DTYPE_Configuration:
|
||||
Address = &ConfigurationDescriptor;
|
||||
Size = sizeof(USB_Descriptor_Configuration_t);
|
||||
break;
|
||||
case DTYPE_String:
|
||||
case DTYPE_String:
|
||||
switch (DescriptorNumber)
|
||||
{
|
||||
case 0x00:
|
||||
case 0x00:
|
||||
Address = &LanguageString;
|
||||
Size = pgm_read_byte(&LanguageString.Header.Size);
|
||||
break;
|
||||
case 0x01:
|
||||
case 0x01:
|
||||
Address = &ManufacturerString;
|
||||
Size = pgm_read_byte(&ManufacturerString.Header.Size);
|
||||
break;
|
||||
case 0x02:
|
||||
case 0x02:
|
||||
Address = &ProductString;
|
||||
Size = pgm_read_byte(&ProductString.Header.Size);
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
*DescriptorAddress = Address;
|
||||
return Size;
|
||||
}
|
||||
|
||||
|
|
|
@ -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 Descriptors.c.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef _DESCRIPTORS_H_
|
||||
#define _DESCRIPTORS_H_
|
||||
|
||||
|
@ -44,15 +44,15 @@
|
|||
|
||||
/* Macros: */
|
||||
/** Endpoint number of the Mass Storage device-to-host data IN endpoint. */
|
||||
#define MASS_STORAGE_IN_EPNUM 3
|
||||
#define MASS_STORAGE_IN_EPNUM 3
|
||||
|
||||
/** Endpoint number of the Mass Storage host-to-device data OUT endpoint. */
|
||||
#define MASS_STORAGE_OUT_EPNUM 4
|
||||
#define MASS_STORAGE_OUT_EPNUM 4
|
||||
|
||||
/** Size in bytes of the Mass Storage data endpoints. */
|
||||
#define MASS_STORAGE_IO_EPSIZE 64
|
||||
|
||||
/* Type Defines: */
|
||||
|
||||
/* Type Defines: */
|
||||
/** Type define for the device configuration descriptor structure. This must be defined in the
|
||||
* application code, as the configuration descriptor contains several sub-descriptors which
|
||||
* vary between devices, and which describe the device's usage to the host.
|
||||
|
@ -64,7 +64,7 @@
|
|||
USB_Descriptor_Endpoint_t MS_DataInEndpoint;
|
||||
USB_Descriptor_Endpoint_t MS_DataOutEndpoint;
|
||||
} USB_Descriptor_Configuration_t;
|
||||
|
||||
|
||||
/* Function Prototypes: */
|
||||
uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue,
|
||||
const uint8_t wIndex,
|
||||
|
@ -72,3 +72,4 @@
|
|||
ATTR_WARN_UNUSED_RESULT ATTR_NON_NULL_PTR_ARG(3);
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -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
|
||||
|
@ -44,13 +44,13 @@ void DHCPClientApp_Init(void)
|
|||
{
|
||||
/* Create a new UDP connection to the DHCP server port for the DHCP solicitation */
|
||||
struct uip_udp_conn* Connection = uip_udp_new(&uip_broadcast_addr, HTONS(DHCPC_SERVER_PORT));
|
||||
|
||||
|
||||
/* If the connection was successfully created, bind it to the local DHCP client port */
|
||||
if (Connection != NULL)
|
||||
{
|
||||
uip_udp_appstate_t* const AppState = &Connection->appstate;
|
||||
uip_udp_bind(Connection, HTONS(DHCPC_CLIENT_PORT));
|
||||
|
||||
|
||||
/* Set the initial client state */
|
||||
AppState->DHCPClient.CurrentState = DHCP_STATE_SendDiscover;
|
||||
|
||||
|
@ -58,8 +58,8 @@ void DHCPClientApp_Init(void)
|
|||
timer_set(&AppState->DHCPClient.Timeout, CLOCK_SECOND / 2);
|
||||
}
|
||||
}
|
||||
|
||||
/** uIP stack application callback for the DHCP client. This function must be called each time the TCP/IP stack
|
||||
|
||||
/** uIP stack application callback for the DHCP client. This function must be called each time the TCP/IP stack
|
||||
* needs a UDP packet to be processed.
|
||||
*/
|
||||
void DHCPClientApp_Callback(void)
|
||||
|
@ -67,7 +67,7 @@ void DHCPClientApp_Callback(void)
|
|||
uip_udp_appstate_t* const AppState = &uip_udp_conn->appstate;
|
||||
DHCP_Header_t* const AppData = (DHCP_Header_t*)uip_appdata;
|
||||
uint16_t AppDataSize = 0;
|
||||
|
||||
|
||||
switch (AppState->DHCPClient.CurrentState)
|
||||
{
|
||||
case DHCP_STATE_SendDiscover:
|
||||
|
@ -77,19 +77,19 @@ void DHCPClientApp_Callback(void)
|
|||
|
||||
/* Fill out the DHCP response header */
|
||||
AppDataSize += DHCPClientApp_FillDHCPHeader(AppData, DHCP_DISCOVER, AppState);
|
||||
|
||||
|
||||
/* Add the required DHCP options list to the packet */
|
||||
uint8_t RequiredOptionList[] = {DHCP_OPTION_SUBNET_MASK, DHCP_OPTION_ROUTER, DHCP_OPTION_DNS_SERVER};
|
||||
AppDataSize += DHCPClientApp_SetOption(AppData->Options, DHCP_OPTION_REQ_LIST, sizeof(RequiredOptionList),
|
||||
RequiredOptionList);
|
||||
|
||||
RequiredOptionList);
|
||||
|
||||
/* Send the DHCP DISCOVER packet */
|
||||
uip_udp_send(AppDataSize);
|
||||
|
||||
/* Reset the timeout timer, progress to next state */
|
||||
timer_reset(&AppState->DHCPClient.Timeout);
|
||||
AppState->DHCPClient.CurrentState = DHCP_STATE_WaitForOffer;
|
||||
|
||||
AppState->DHCPClient.CurrentState = DHCP_STATE_WaitForOffer;
|
||||
|
||||
break;
|
||||
case DHCP_STATE_WaitForOffer:
|
||||
if (!(uip_newdata()))
|
||||
|
@ -97,10 +97,10 @@ void DHCPClientApp_Callback(void)
|
|||
/* Check if the DHCP timeout period has expired while waiting for a response */
|
||||
if (timer_expired(&AppState->DHCPClient.Timeout))
|
||||
AppState->DHCPClient.CurrentState = DHCP_STATE_SendDiscover;
|
||||
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
uint8_t OfferResponse_MessageType;
|
||||
if ((AppData->TransactionID == DHCP_TRANSACTION_ID) &&
|
||||
DHCPClientApp_GetOption(AppData->Options, DHCP_OPTION_MSG_TYPE, &OfferResponse_MessageType) &&
|
||||
|
@ -111,7 +111,7 @@ void DHCPClientApp_Callback(void)
|
|||
DHCPClientApp_GetOption(AppData->Options, DHCP_OPTION_SUBNET_MASK, &AppState->DHCPClient.DHCPOffer_Data.Netmask);
|
||||
DHCPClientApp_GetOption(AppData->Options, DHCP_OPTION_ROUTER, &AppState->DHCPClient.DHCPOffer_Data.GatewayIP);
|
||||
DHCPClientApp_GetOption(AppData->Options, DHCP_OPTION_SERVER_ID, &AppState->DHCPClient.DHCPOffer_Data.ServerIP);
|
||||
|
||||
|
||||
timer_reset(&AppState->DHCPClient.Timeout);
|
||||
AppState->DHCPClient.CurrentState = DHCP_STATE_SendRequest;
|
||||
}
|
||||
|
@ -131,7 +131,7 @@ void DHCPClientApp_Callback(void)
|
|||
|
||||
/* Send the DHCP REQUEST packet */
|
||||
uip_udp_send(AppDataSize);
|
||||
|
||||
|
||||
/* Reset the timeout timer, progress to next state */
|
||||
timer_reset(&AppState->DHCPClient.Timeout);
|
||||
AppState->DHCPClient.CurrentState = DHCP_STATE_WaitForACK;
|
||||
|
@ -143,10 +143,10 @@ void DHCPClientApp_Callback(void)
|
|||
/* Check if the DHCP timeout period has expired while waiting for a response */
|
||||
if (timer_expired(&AppState->DHCPClient.Timeout))
|
||||
AppState->DHCPClient.CurrentState = DHCP_STATE_SendDiscover;
|
||||
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
uint8_t RequestResponse_MessageType;
|
||||
if ((AppData->TransactionID == DHCP_TRANSACTION_ID) &&
|
||||
DHCPClientApp_GetOption(AppData->Options, DHCP_OPTION_MSG_TYPE, &RequestResponse_MessageType) &&
|
||||
|
@ -156,13 +156,13 @@ void DHCPClientApp_Callback(void)
|
|||
uip_sethostaddr((uip_ipaddr_t*)&AppState->DHCPClient.DHCPOffer_Data.AllocatedIP);
|
||||
uip_setnetmask((uip_ipaddr_t*)&AppState->DHCPClient.DHCPOffer_Data.Netmask);
|
||||
uip_setdraddr((uip_ipaddr_t*)&AppState->DHCPClient.DHCPOffer_Data.GatewayIP);
|
||||
|
||||
|
||||
/* Indicate to the user that we now have a valid IP configuration */
|
||||
HaveIPConfiguration = true;
|
||||
|
||||
AppState->DHCPClient.CurrentState = DHCP_STATE_AddressLeased;
|
||||
AppState->DHCPClient.CurrentState = DHCP_STATE_AddressLeased;
|
||||
}
|
||||
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -196,13 +196,13 @@ static uint16_t DHCPClientApp_FillDHCPHeader(DHCP_Header_t* const DHCPHeader,
|
|||
memcpy(&DHCPHeader->NextServerIP, &AppState->DHCPClient.DHCPOffer_Data.ServerIP, sizeof(uip_ipaddr_t));
|
||||
memcpy(&DHCPHeader->ClientHardwareAddress, &MACAddress, sizeof(struct uip_eth_addr));
|
||||
DHCPHeader->Cookie = DHCP_MAGIC_COOKIE;
|
||||
|
||||
|
||||
/* Add a DHCP message type and terminator options to the start of the DHCP options field */
|
||||
DHCPHeader->Options[0] = DHCP_OPTION_MSG_TYPE;
|
||||
DHCPHeader->Options[1] = 1;
|
||||
DHCPHeader->Options[2] = DHCPMessageType;
|
||||
DHCPHeader->Options[3] = DHCP_OPTION_END;
|
||||
|
||||
|
||||
/* Calculate the total number of bytes added to the outgoing packet */
|
||||
return (sizeof(DHCP_Header_t) + 4);
|
||||
}
|
||||
|
@ -231,7 +231,7 @@ static uint8_t DHCPClientApp_SetOption(uint8_t* DHCPOptionList,
|
|||
DHCPOptionList[1] = DataLen;
|
||||
memcpy(&DHCPOptionList[2], OptionData, DataLen);
|
||||
DHCPOptionList[2 + DataLen] = DHCP_OPTION_END;
|
||||
|
||||
|
||||
/* Calculate the total number of bytes added to the outgoing packet */
|
||||
return (2 + DataLen);
|
||||
}
|
||||
|
@ -256,16 +256,17 @@ static bool DHCPClientApp_GetOption(const uint8_t* DHCPOptionList,
|
|||
{
|
||||
/* Copy request option's data to the destination buffer */
|
||||
memcpy(Destination, &DHCPOptionList[2], DHCPOptionList[1]);
|
||||
|
||||
|
||||
/* Indicate that the requested option data was successfully retrieved */
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/* Skip to next DHCP option in the options list */
|
||||
DHCPOptionList += (DHCPOptionList[1] + 2);
|
||||
}
|
||||
|
||||
|
||||
/* Requested option not found in the incoming packet's DHCP options list */
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
@ -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,11 +38,11 @@
|
|||
|
||||
/* Includes: */
|
||||
#include <stdio.h>
|
||||
|
||||
|
||||
#include <uip.h>
|
||||
|
||||
|
||||
#include "../Webserver.h"
|
||||
|
||||
|
||||
/* Macros: */
|
||||
/** UDP listen port for a BOOTP server. */
|
||||
#define DHCPC_SERVER_PORT 67
|
||||
|
@ -58,10 +58,10 @@
|
|||
|
||||
/** BOOTP flag for a BOOTP broadcast message. */
|
||||
#define BOOTP_BROADCAST 0x8000
|
||||
|
||||
|
||||
/** Magic DHCP cookie for a BOOTP message to identify it as a DHCP message. */
|
||||
#define DHCP_MAGIC_COOKIE 0x63538263
|
||||
|
||||
|
||||
/** Unique transaction ID used to identify DHCP responses to the client. */
|
||||
#define DHCP_TRANSACTION_ID 0x13245466
|
||||
|
||||
|
@ -106,8 +106,8 @@
|
|||
|
||||
/** DHCP message option for the DHCP message type. */
|
||||
#define DHCP_OPTION_MSG_TYPE 53
|
||||
|
||||
/** DHCP message option for the DHCP server IP. */
|
||||
|
||||
/** DHCP message option for the DHCP server IP. */
|
||||
#define DHCP_OPTION_SERVER_ID 54
|
||||
|
||||
/** DHCP message option for the list of required options from the server. */
|
||||
|
@ -129,18 +129,18 @@
|
|||
|
||||
uint16_t ElapsedSeconds; /**< Elapsed seconds since the request was made */
|
||||
uint16_t Flags; /**< BOOTP packet flags */
|
||||
|
||||
|
||||
uip_ipaddr_t ClientIP; /**< Client IP address, if already leased an IP */
|
||||
uip_ipaddr_t YourIP; /**< Client IP address */
|
||||
uip_ipaddr_t NextServerIP; /**< Legacy BOOTP protocol field, unused for DHCP */
|
||||
uip_ipaddr_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 */
|
||||
|
||||
|
||||
uint8_t Options[]; /**< DHCP message options */
|
||||
} DHCP_Header_t;
|
||||
|
||||
|
@ -158,7 +158,7 @@
|
|||
/* Function Prototypes: */
|
||||
void DHCPClientApp_Init(void);
|
||||
void DHCPClientApp_Callback(void);
|
||||
|
||||
|
||||
#if defined(INCLUDE_FROM_DHCPCLIENTAPP_C)
|
||||
static uint16_t DHCPClientApp_FillDHCPHeader(DHCP_Header_t* const DHCPHeader,
|
||||
const uint8_t DHCPMessageType,
|
||||
|
@ -172,3 +172,4 @@
|
|||
void* const Destination);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
|
|
@ -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
|
||||
|
@ -77,7 +77,7 @@ void DataflashManager_WriteBlocks(USB_ClassInfo_MS_Device_t* const MSInterfaceIn
|
|||
while (TotalBlocks)
|
||||
{
|
||||
uint8_t BytesInBlockDiv16 = 0;
|
||||
|
||||
|
||||
/* Write an endpoint packet sized data block to the Dataflash */
|
||||
while (BytesInBlockDiv16 < (VIRTUAL_MEMORY_BLOCK_SIZE >> 4))
|
||||
{
|
||||
|
@ -86,7 +86,7 @@ void DataflashManager_WriteBlocks(USB_ClassInfo_MS_Device_t* const MSInterfaceIn
|
|||
{
|
||||
/* Clear the current endpoint bank */
|
||||
Endpoint_ClearOUT();
|
||||
|
||||
|
||||
/* Wait until the host has sent another packet */
|
||||
if (Endpoint_WaitUntilReady())
|
||||
return;
|
||||
|
@ -125,7 +125,7 @@ void DataflashManager_WriteBlocks(USB_ClassInfo_MS_Device_t* const MSInterfaceIn
|
|||
|
||||
/* Send the Dataflash buffer write command */
|
||||
Dataflash_SendByte(UsingSecondBuffer ? DF_CMD_BUFF2WRITE : DF_CMD_BUFF1WRITE);
|
||||
Dataflash_SendAddressBytes(0, 0);
|
||||
Dataflash_SendAddressBytes(0, 0);
|
||||
}
|
||||
|
||||
/* Write one 16-byte chunk of data to the Dataflash */
|
||||
|
@ -145,7 +145,7 @@ void DataflashManager_WriteBlocks(USB_ClassInfo_MS_Device_t* const MSInterfaceIn
|
|||
Dataflash_SendByte(Endpoint_Read_Byte());
|
||||
Dataflash_SendByte(Endpoint_Read_Byte());
|
||||
Dataflash_SendByte(Endpoint_Read_Byte());
|
||||
|
||||
|
||||
/* Increment the Dataflash page 16 byte block counter */
|
||||
CurrDFPageByteDiv16++;
|
||||
|
||||
|
@ -154,9 +154,9 @@ void DataflashManager_WriteBlocks(USB_ClassInfo_MS_Device_t* const MSInterfaceIn
|
|||
|
||||
/* Check if the current command is being aborted by the host */
|
||||
if (MSInterfaceInfo->State.IsMassStoreReset)
|
||||
return;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
/* Decrement the blocks remaining counter and reset the sub block counter */
|
||||
TotalBlocks--;
|
||||
}
|
||||
|
@ -201,15 +201,15 @@ void DataflashManager_ReadBlocks(USB_ClassInfo_MS_Device_t* const MSInterfaceInf
|
|||
Dataflash_SendByte(0x00);
|
||||
Dataflash_SendByte(0x00);
|
||||
Dataflash_SendByte(0x00);
|
||||
|
||||
|
||||
/* Wait until endpoint is ready before continuing */
|
||||
if (Endpoint_WaitUntilReady())
|
||||
return;
|
||||
|
||||
|
||||
while (TotalBlocks)
|
||||
{
|
||||
uint8_t BytesInBlockDiv16 = 0;
|
||||
|
||||
|
||||
/* Write an endpoint packet sized data block to the Dataflash */
|
||||
while (BytesInBlockDiv16 < (VIRTUAL_MEMORY_BLOCK_SIZE >> 4))
|
||||
{
|
||||
|
@ -218,12 +218,12 @@ void DataflashManager_ReadBlocks(USB_ClassInfo_MS_Device_t* const MSInterfaceInf
|
|||
{
|
||||
/* Clear the endpoint bank to send its contents to the host */
|
||||
Endpoint_ClearIN();
|
||||
|
||||
|
||||
/* Wait until the endpoint is ready for more data */
|
||||
if (Endpoint_WaitUntilReady())
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
/* Check if end of Dataflash page reached */
|
||||
if (CurrDFPageByteDiv16 == (DATAFLASH_PAGE_SIZE >> 4))
|
||||
{
|
||||
|
@ -233,7 +233,7 @@ void DataflashManager_ReadBlocks(USB_ClassInfo_MS_Device_t* const MSInterfaceInf
|
|||
|
||||
/* Select the next Dataflash chip based on the new Dataflash page index */
|
||||
Dataflash_SelectChipFromPage(CurrDFPage);
|
||||
|
||||
|
||||
/* Send the Dataflash main memory page read command */
|
||||
Dataflash_SendByte(DF_CMD_MAINMEMPAGEREAD);
|
||||
Dataflash_SendAddressBytes(CurrDFPage, 0);
|
||||
|
@ -241,7 +241,7 @@ void DataflashManager_ReadBlocks(USB_ClassInfo_MS_Device_t* const MSInterfaceInf
|
|||
Dataflash_SendByte(0x00);
|
||||
Dataflash_SendByte(0x00);
|
||||
Dataflash_SendByte(0x00);
|
||||
}
|
||||
}
|
||||
|
||||
/* Read one 16-byte chunk of data from the Dataflash */
|
||||
Endpoint_Write_Byte(Dataflash_ReceiveByte());
|
||||
|
@ -260,10 +260,10 @@ void DataflashManager_ReadBlocks(USB_ClassInfo_MS_Device_t* const MSInterfaceInf
|
|||
Endpoint_Write_Byte(Dataflash_ReceiveByte());
|
||||
Endpoint_Write_Byte(Dataflash_ReceiveByte());
|
||||
Endpoint_Write_Byte(Dataflash_ReceiveByte());
|
||||
|
||||
|
||||
/* Increment the Dataflash page 16 byte block counter */
|
||||
CurrDFPageByteDiv16++;
|
||||
|
||||
|
||||
/* Increment the block 16 byte block counter */
|
||||
BytesInBlockDiv16++;
|
||||
|
||||
|
@ -271,11 +271,11 @@ void DataflashManager_ReadBlocks(USB_ClassInfo_MS_Device_t* const MSInterfaceInf
|
|||
if (MSInterfaceInfo->State.IsMassStoreReset)
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
/* Decrement the blocks remaining counter */
|
||||
TotalBlocks--;
|
||||
}
|
||||
|
||||
|
||||
/* If the endpoint is full, send its contents to the host */
|
||||
if (!(Endpoint_IsReadWriteAllowed()))
|
||||
Endpoint_ClearIN();
|
||||
|
@ -315,11 +315,11 @@ void DataflashManager_WriteBlocks_RAM(const uint32_t BlockAddress,
|
|||
/* Send the Dataflash buffer write command */
|
||||
Dataflash_SendByte(DF_CMD_BUFF1WRITE);
|
||||
Dataflash_SendAddressBytes(0, CurrDFPageByte);
|
||||
|
||||
|
||||
while (TotalBlocks)
|
||||
{
|
||||
uint8_t BytesInBlockDiv16 = 0;
|
||||
|
||||
|
||||
/* Write an endpoint packet sized data block to the Dataflash */
|
||||
while (BytesInBlockDiv16 < (VIRTUAL_MEMORY_BLOCK_SIZE >> 4))
|
||||
{
|
||||
|
@ -359,18 +359,18 @@ void DataflashManager_WriteBlocks_RAM(const uint32_t BlockAddress,
|
|||
Dataflash_SendByte(DF_CMD_BUFF1WRITE);
|
||||
Dataflash_SendAddressBytes(0, 0);
|
||||
}
|
||||
|
||||
|
||||
/* Write one 16-byte chunk of data to the Dataflash */
|
||||
for (uint8_t ByteNum = 0; ByteNum < 16; ByteNum++)
|
||||
Dataflash_SendByte(*(BufferPtr++));
|
||||
|
||||
|
||||
/* Increment the Dataflash page 16 byte block counter */
|
||||
CurrDFPageByteDiv16++;
|
||||
|
||||
/* Increment the block 16 byte block counter */
|
||||
BytesInBlockDiv16++;
|
||||
BytesInBlockDiv16++;
|
||||
}
|
||||
|
||||
|
||||
/* Decrement the blocks remaining counter and reset the sub block counter */
|
||||
TotalBlocks--;
|
||||
}
|
||||
|
@ -416,7 +416,7 @@ void DataflashManager_ReadBlocks_RAM(const uint32_t BlockAddress,
|
|||
while (TotalBlocks)
|
||||
{
|
||||
uint8_t BytesInBlockDiv16 = 0;
|
||||
|
||||
|
||||
/* Write an endpoint packet sized data block to the Dataflash */
|
||||
while (BytesInBlockDiv16 < (VIRTUAL_MEMORY_BLOCK_SIZE >> 4))
|
||||
{
|
||||
|
@ -429,7 +429,7 @@ void DataflashManager_ReadBlocks_RAM(const uint32_t BlockAddress,
|
|||
|
||||
/* Select the next Dataflash chip based on the new Dataflash page index */
|
||||
Dataflash_SelectChipFromPage(CurrDFPage);
|
||||
|
||||
|
||||
/* Send the Dataflash main memory page read command */
|
||||
Dataflash_SendByte(DF_CMD_MAINMEMPAGEREAD);
|
||||
Dataflash_SendAddressBytes(CurrDFPage, 0);
|
||||
|
@ -437,19 +437,19 @@ void DataflashManager_ReadBlocks_RAM(const uint32_t BlockAddress,
|
|||
Dataflash_SendByte(0x00);
|
||||
Dataflash_SendByte(0x00);
|
||||
Dataflash_SendByte(0x00);
|
||||
}
|
||||
}
|
||||
|
||||
/* Read one 16-byte chunk of data from the Dataflash */
|
||||
for (uint8_t ByteNum = 0; ByteNum < 16; ByteNum++)
|
||||
*(BufferPtr++) = Dataflash_ReceiveByte();
|
||||
|
||||
|
||||
/* Increment the Dataflash page 16 byte block counter */
|
||||
CurrDFPageByteDiv16++;
|
||||
|
||||
|
||||
/* Increment the block 16 byte block counter */
|
||||
BytesInBlockDiv16++;
|
||||
}
|
||||
|
||||
|
||||
/* Decrement the blocks remaining counter */
|
||||
TotalBlocks--;
|
||||
}
|
||||
|
@ -464,7 +464,7 @@ void DataflashManager_ResetDataflashProtections(void)
|
|||
/* Select first Dataflash chip, send the read status register command */
|
||||
Dataflash_SelectChip(DATAFLASH_CHIP1);
|
||||
Dataflash_SendByte(DF_CMD_GETSTATUS);
|
||||
|
||||
|
||||
/* Check if sector protection is enabled */
|
||||
if (Dataflash_ReceiveByte() & DF_STATUS_SECTORPROTECTION_ON)
|
||||
{
|
||||
|
@ -476,12 +476,12 @@ void DataflashManager_ResetDataflashProtections(void)
|
|||
Dataflash_SendByte(DF_CMD_SECTORPROTECTIONOFF[2]);
|
||||
Dataflash_SendByte(DF_CMD_SECTORPROTECTIONOFF[3]);
|
||||
}
|
||||
|
||||
|
||||
/* Select second Dataflash chip (if present on selected board), send read status register command */
|
||||
#if (DATAFLASH_TOTALCHIPS == 2)
|
||||
Dataflash_SelectChip(DATAFLASH_CHIP2);
|
||||
Dataflash_SendByte(DF_CMD_GETSTATUS);
|
||||
|
||||
|
||||
/* Check if sector protection is enabled */
|
||||
if (Dataflash_ReceiveByte() & DF_STATUS_SECTORPROTECTION_ON)
|
||||
{
|
||||
|
@ -494,7 +494,7 @@ void DataflashManager_ResetDataflashProtections(void)
|
|||
Dataflash_SendByte(DF_CMD_SECTORPROTECTIONOFF[3]);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/* Deselect current Dataflash chip */
|
||||
Dataflash_DeselectChip();
|
||||
}
|
||||
|
@ -528,6 +528,7 @@ bool DataflashManager_CheckDataflashOperation(void)
|
|||
if (ReturnByte != DF_MANUFACTURER_ATMEL)
|
||||
return false;
|
||||
#endif
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -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,13 +32,13 @@
|
|||
*
|
||||
* Header file for DataflashManager.c.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef _DATAFLASH_MANAGER_H_
|
||||
#define _DATAFLASH_MANAGER_H_
|
||||
|
||||
/* Includes: */
|
||||
#include <avr/io.h>
|
||||
|
||||
|
||||
#include "Descriptors.h"
|
||||
|
||||
#include <LUFA/Common/Common.h>
|
||||
|
@ -59,12 +59,12 @@
|
|||
* storage media (Dataflash) using a different native block size. Do not change this value.
|
||||
*/
|
||||
#define VIRTUAL_MEMORY_BLOCK_SIZE 512
|
||||
|
||||
|
||||
/** Total number of blocks of the virtual memory for reporting to the host as the device's total capacity. Do not
|
||||
* change this value; change VIRTUAL_MEMORY_BYTES instead to alter the media size.
|
||||
*/
|
||||
#define VIRTUAL_MEMORY_BLOCKS (VIRTUAL_MEMORY_BYTES / VIRTUAL_MEMORY_BLOCK_SIZE)
|
||||
|
||||
|
||||
/* Function Prototypes: */
|
||||
void DataflashManager_WriteBlocks(USB_ClassInfo_MS_Device_t* const MSInterfaceInfo,
|
||||
const uint32_t BlockAddress,
|
||||
|
@ -80,5 +80,6 @@
|
|||
uint8_t* BufferPtr) ATTR_NON_NULL_PTR_ARG(3);
|
||||
void DataflashManager_ResetDataflashProtections(void);
|
||||
bool DataflashManager_CheckDataflashOperation(void);
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -115,3 +115,4 @@ REVISION HISTORY
|
|||
Changed some types on the API, XCHAR->TCHAR.
|
||||
Changed fname member in the FILINFO structure on Unicode cfg.
|
||||
String functions support UTF-8 encoding files on Unicode cfg.
|
||||
|
||||
|
|
|
@ -62,3 +62,4 @@ DRESULT disk_write (
|
|||
return RES_OK;
|
||||
}
|
||||
#endif /* _READONLY */
|
||||
|
||||
|
|
|
@ -70,3 +70,4 @@ DRESULT disk_ioctl (BYTE, BYTE, void*);
|
|||
|
||||
#define _DISKIO
|
||||
#endif
|
||||
|
||||
|
|
|
@ -2289,7 +2289,7 @@ FRESULT f_close (
|
|||
#if _FS_REENTRANT
|
||||
res = validate(fp->fs, fp->id);
|
||||
if (res == FR_OK) {
|
||||
res = dec_lock(fp->fs, fp->lockid);
|
||||
res = dec_lock(fp->fs, fp->lockid);
|
||||
unlock_fs(fp->fs, FR_OK);
|
||||
}
|
||||
#else
|
||||
|
@ -3539,7 +3539,7 @@ int f_printf (
|
|||
res++;
|
||||
}
|
||||
do {
|
||||
cc = f_putc(s[--i], fil);
|
||||
cc = f_putc(s[--i], fil);
|
||||
res++;
|
||||
} while (i && cc != EOF);
|
||||
if (cc != EOF) cc = 0;
|
||||
|
@ -3551,3 +3551,4 @@ int f_printf (
|
|||
|
||||
#endif /* !_FS_READONLY */
|
||||
#endif /* _USE_STRFUNC */
|
||||
|
||||
|
|
|
@ -611,3 +611,4 @@ void ff_rel_grant (_SYNC_t); /* Unlock sync object */
|
|||
#endif
|
||||
|
||||
#endif /* _FATFS */
|
||||
|
||||
|
|
|
@ -179,3 +179,4 @@
|
|||
|
||||
|
||||
#endif /* _FFCONFIG */
|
||||
|
||||
|
|
|
@ -37,3 +37,4 @@ typedef unsigned char BOOL;
|
|||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -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 @@
|
|||
* Simple HTTP Webserver Application. When connected to the uIP stack,
|
||||
* this will serve out files to HTTP clients on port 80.
|
||||
*/
|
||||
|
||||
|
||||
#define INCLUDE_FROM_HTTPSERVERAPP_C
|
||||
#include "HTTPServerApp.h"
|
||||
|
||||
|
@ -86,7 +86,7 @@ void HTTPServerApp_Init(void)
|
|||
{
|
||||
/* Listen on port 80 for HTTP connections from hosts */
|
||||
uip_listen(HTONS(HTTP_SERVER_PORT));
|
||||
|
||||
|
||||
/* Mount the Dataflash disk via FatFS */
|
||||
f_mount(0, &DiskFATState);
|
||||
}
|
||||
|
@ -127,7 +127,7 @@ void HTTPServerApp_Callback(void)
|
|||
if (uip_rexmit())
|
||||
{
|
||||
/* Return file pointer to the last ACKed position */
|
||||
f_lseek(&AppState->HTTPServer.FileHandle, AppState->HTTPServer.ACKedFilePos);
|
||||
f_lseek(&AppState->HTTPServer.FileHandle, AppState->HTTPServer.ACKedFilePos);
|
||||
}
|
||||
|
||||
if (uip_rexmit() || uip_acked() || uip_newdata() || uip_connected() || uip_poll())
|
||||
|
@ -147,15 +147,15 @@ void HTTPServerApp_Callback(void)
|
|||
/* Connection is being terminated for some reason - close file handle */
|
||||
f_close(&AppState->HTTPServer.FileHandle);
|
||||
AppState->HTTPServer.FileOpen = false;
|
||||
|
||||
|
||||
/* If connection is not already closed, close it */
|
||||
uip_close();
|
||||
|
||||
|
||||
AppState->HTTPServer.CurrentState = WEBSERVER_STATE_Closed;
|
||||
AppState->HTTPServer.NextState = WEBSERVER_STATE_Closed;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** HTTP Server State handler for the Request Process state. This state manages the processing of incoming HTTP
|
||||
|
@ -165,27 +165,27 @@ static void HTTPServerApp_OpenRequestedFile(void)
|
|||
{
|
||||
uip_tcp_appstate_t* const AppState = &uip_conn->appstate;
|
||||
char* const AppData = (char*)uip_appdata;
|
||||
|
||||
|
||||
/* No HTTP header received from the client, abort processing */
|
||||
if (!(uip_newdata()))
|
||||
return;
|
||||
|
||||
|
||||
char* RequestToken = strtok(AppData, " ");
|
||||
char* RequestedFileName = strtok(NULL, " ");
|
||||
|
||||
|
||||
/* Must be a GET request, abort otherwise */
|
||||
if (strcmp_P(RequestToken, PSTR("GET")) != 0)
|
||||
{
|
||||
uip_abort();
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
/* Copy over the requested filename */
|
||||
strncpy(AppState->HTTPServer.FileName, &RequestedFileName[1], (sizeof(AppState->HTTPServer.FileName) - 1));
|
||||
|
||||
|
||||
/* Ensure filename is null-terminated */
|
||||
AppState->HTTPServer.FileName[sizeof(AppState->HTTPServer.FileName) - 1] = 0x00;
|
||||
|
||||
|
||||
/* Determine the length of the URI so that it can be checked to see if it is a directory */
|
||||
uint8_t FileNameLen = strlen(AppState->HTTPServer.FileName);
|
||||
|
||||
|
@ -198,7 +198,7 @@ static void HTTPServerApp_OpenRequestedFile(void)
|
|||
/* Ensure altered filename is still null-terminated */
|
||||
AppState->HTTPServer.FileName[sizeof(AppState->HTTPServer.FileName) - 1] = 0x00;
|
||||
}
|
||||
|
||||
|
||||
/* Try to open the file from the Dataflash disk */
|
||||
AppState->HTTPServer.FileOpen = (f_open(&AppState->HTTPServer.FileHandle, AppState->HTTPServer.FileName,
|
||||
(FA_OPEN_EXISTING | FA_READ)) == FR_OK);
|
||||
|
@ -224,13 +224,13 @@ static void HTTPServerApp_SendResponseHeader(void)
|
|||
{
|
||||
/* Copy over the HTTP 404 response header and send it to the receiving client */
|
||||
strcpy_P(AppData, HTTP404Header);
|
||||
strcpy(&AppData[strlen(AppData)], AppState->HTTPServer.FileName);
|
||||
strcpy(&AppData[strlen(AppData)], AppState->HTTPServer.FileName);
|
||||
uip_send(AppData, strlen(AppData));
|
||||
|
||||
|
||||
AppState->HTTPServer.NextState = WEBSERVER_STATE_Closing;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
/* Copy over the HTTP 200 response header and send it to the receiving client */
|
||||
strcpy_P(AppData, HTTP200Header);
|
||||
|
||||
|
@ -242,11 +242,11 @@ static void HTTPServerApp_SendResponseHeader(void)
|
|||
{
|
||||
if (strcmp(&Extension[1], MIMETypes[i].Extension) == 0)
|
||||
{
|
||||
strcpy(&AppData[strlen(AppData)], MIMETypes[i].MIMEType);
|
||||
strcpy(&AppData[strlen(AppData)], MIMETypes[i].MIMEType);
|
||||
FoundMIMEType = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Check if a MIME type was found and copied to the output buffer */
|
||||
|
@ -255,13 +255,13 @@ static void HTTPServerApp_SendResponseHeader(void)
|
|||
/* MIME type not found - copy over the default MIME type */
|
||||
strcpy_P(&AppData[strlen(AppData)], DefaultMIMEType);
|
||||
}
|
||||
|
||||
|
||||
/* Add the end-of-line terminator and end-of-headers terminator after the MIME type */
|
||||
strcpy_P(&AppData[strlen(AppData)], PSTR("\r\n\r\n"));
|
||||
|
||||
|
||||
/* Send the MIME header to the receiving client */
|
||||
uip_send(AppData, strlen(AppData));
|
||||
|
||||
|
||||
/* When the MIME header is ACKed, progress to the data send stage */
|
||||
AppState->HTTPServer.NextState = WEBSERVER_STATE_SendData;
|
||||
}
|
||||
|
@ -279,11 +279,12 @@ static void HTTPServerApp_SendData(void)
|
|||
|
||||
/* Read the next chunk of data from the open file */
|
||||
f_read(&AppState->HTTPServer.FileHandle, AppData, MaxChunkSize, &AppState->HTTPServer.SentChunkSize);
|
||||
|
||||
|
||||
/* Send the next file chunk to the receiving client */
|
||||
uip_send(AppData, AppState->HTTPServer.SentChunkSize);
|
||||
|
||||
|
||||
/* Check if we are at the last chunk of the file, if so next ACK should close the connection */
|
||||
if (MaxChunkSize != AppState->HTTPServer.SentChunkSize)
|
||||
AppState->HTTPServer.NextState = WEBSERVER_STATE_Closing;
|
||||
}
|
||||
|
||||
|
|
|
@ -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,12 +39,12 @@
|
|||
/* Includes: */
|
||||
#include <avr/pgmspace.h>
|
||||
#include <string.h>
|
||||
|
||||
|
||||
#include <LUFA/Version.h>
|
||||
|
||||
#include <uip.h>
|
||||
#include <ff.h>
|
||||
|
||||
|
||||
/* Enums: */
|
||||
/** States for each HTTP connection to the webserver. */
|
||||
enum Webserver_States_t
|
||||
|
@ -55,7 +55,7 @@
|
|||
WEBSERVER_STATE_Closing, /**< Ready to close the connection to the client */
|
||||
WEBSERVER_STATE_Closed, /**< Connection closed after all data sent */
|
||||
};
|
||||
|
||||
|
||||
/* Type Defines: */
|
||||
/** Type define for a MIME type handler. */
|
||||
typedef struct
|
||||
|
@ -63,7 +63,7 @@
|
|||
char* Extension; /**< File extension (no leading '.' character) */
|
||||
char* MIMEType; /**< Appropriate MIME type to send when the extension is encountered */
|
||||
} MIME_Type_t;
|
||||
|
||||
|
||||
/* Macros: */
|
||||
/** TCP listen port for incoming HTTP traffic. */
|
||||
#define HTTP_SERVER_PORT 80
|
||||
|
@ -71,11 +71,12 @@
|
|||
/* Function Prototypes: */
|
||||
void HTTPServerApp_Init(void);
|
||||
void HTTPServerApp_Callback(void);
|
||||
|
||||
|
||||
#if defined(INCLUDE_FROM_HTTPSERVERAPP_C)
|
||||
static void HTTPServerApp_OpenRequestedFile(void);
|
||||
static void HTTPServerApp_SendResponseHeader(void);
|
||||
static void HTTPServerApp_SendData(void);
|
||||
#endif
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -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,29 +34,29 @@
|
|||
* devices use a thin "Bulk-Only Transport" protocol for issuing commands and status information,
|
||||
* which wrap around standard SCSI device commands for controlling the actual storage medium.
|
||||
*/
|
||||
|
||||
|
||||
#define INCLUDE_FROM_SCSI_C
|
||||
#include "SCSI.h"
|
||||
|
||||
/** Structure to hold the SCSI response data to a SCSI INQUIRY command. This gives information about the device's
|
||||
* features and capabilities.
|
||||
*/
|
||||
SCSI_Inquiry_Response_t InquiryData =
|
||||
SCSI_Inquiry_Response_t InquiryData =
|
||||
{
|
||||
.DeviceType = DEVICE_TYPE_BLOCK,
|
||||
.PeripheralQualifier = 0,
|
||||
|
||||
|
||||
.Removable = true,
|
||||
|
||||
|
||||
.Version = 0,
|
||||
|
||||
|
||||
.ResponseDataFormat = 2,
|
||||
.NormACA = false,
|
||||
.TrmTsk = false,
|
||||
.AERC = false,
|
||||
|
||||
.AdditionalLength = 0x1F,
|
||||
|
||||
|
||||
.SoftReset = false,
|
||||
.CmdQue = false,
|
||||
.Linked = false,
|
||||
|
@ -64,7 +64,7 @@ SCSI_Inquiry_Response_t InquiryData =
|
|||
.WideBus16Bit = false,
|
||||
.WideBus32Bit = false,
|
||||
.RelAddr = false,
|
||||
|
||||
|
||||
.VendorID = "LUFA",
|
||||
.ProductID = "Dataflash Disk",
|
||||
.RevisionID = {'0','.','0','0'},
|
||||
|
@ -96,13 +96,13 @@ bool SCSI_DecodeSCSICommand(USB_ClassInfo_MS_Device_t* const MSInterfaceInfo)
|
|||
switch (MSInterfaceInfo->State.CommandBlock.SCSICommandData[0])
|
||||
{
|
||||
case SCSI_CMD_INQUIRY:
|
||||
CommandSuccess = SCSI_Command_Inquiry(MSInterfaceInfo);
|
||||
CommandSuccess = SCSI_Command_Inquiry(MSInterfaceInfo);
|
||||
break;
|
||||
case SCSI_CMD_REQUEST_SENSE:
|
||||
CommandSuccess = SCSI_Command_Request_Sense(MSInterfaceInfo);
|
||||
break;
|
||||
case SCSI_CMD_READ_CAPACITY_10:
|
||||
CommandSuccess = SCSI_Command_Read_Capacity_10(MSInterfaceInfo);
|
||||
CommandSuccess = SCSI_Command_Read_Capacity_10(MSInterfaceInfo);
|
||||
break;
|
||||
case SCSI_CMD_SEND_DIAGNOSTIC:
|
||||
CommandSuccess = SCSI_Command_Send_Diagnostic(MSInterfaceInfo);
|
||||
|
@ -134,7 +134,7 @@ bool SCSI_DecodeSCSICommand(USB_ClassInfo_MS_Device_t* const MSInterfaceInfo)
|
|||
SCSI_SET_SENSE(SCSI_SENSE_KEY_GOOD,
|
||||
SCSI_ASENSE_NO_ADDITIONAL_INFORMATION,
|
||||
SCSI_ASENSEQ_NO_QUALIFIER);
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -165,11 +165,11 @@ static bool SCSI_Command_Inquiry(USB_ClassInfo_MS_Device_t* const MSInterfaceInf
|
|||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
Endpoint_Write_Stream_LE(&InquiryData, BytesTransferred, NO_STREAM_CALLBACK);
|
||||
|
||||
uint8_t PadBytes[AllocationLength - BytesTransferred];
|
||||
|
||||
|
||||
/* Pad out remaining bytes with 0x00 */
|
||||
Endpoint_Write_Stream_LE(&PadBytes, sizeof(PadBytes), NO_STREAM_CALLBACK);
|
||||
|
||||
|
@ -178,7 +178,7 @@ static bool SCSI_Command_Inquiry(USB_ClassInfo_MS_Device_t* const MSInterfaceInf
|
|||
|
||||
/* Succeed the command and update the bytes transferred counter */
|
||||
MSInterfaceInfo->State.CommandBlock.DataTransferLength -= BytesTransferred;
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -193,7 +193,7 @@ static bool SCSI_Command_Request_Sense(USB_ClassInfo_MS_Device_t* const MSInterf
|
|||
{
|
||||
uint8_t AllocationLength = MSInterfaceInfo->State.CommandBlock.SCSICommandData[4];
|
||||
uint8_t BytesTransferred = (AllocationLength < sizeof(SenseData))? AllocationLength : sizeof(SenseData);
|
||||
|
||||
|
||||
uint8_t PadBytes[AllocationLength - BytesTransferred];
|
||||
|
||||
Endpoint_Write_Stream_LE(&SenseData, BytesTransferred, NO_STREAM_CALLBACK);
|
||||
|
@ -221,10 +221,10 @@ static bool SCSI_Command_Read_Capacity_10(USB_ClassInfo_MS_Device_t* const MSInt
|
|||
Endpoint_Write_Stream_BE(&LastBlockAddressInLUN, sizeof(LastBlockAddressInLUN), NO_STREAM_CALLBACK);
|
||||
Endpoint_Write_Stream_BE(&MediaBlockSize, sizeof(MediaBlockSize), NO_STREAM_CALLBACK);
|
||||
Endpoint_ClearIN();
|
||||
|
||||
|
||||
/* Succeed the command and update the bytes transferred counter */
|
||||
MSInterfaceInfo->State.CommandBlock.DataTransferLength -= 8;
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -248,21 +248,21 @@ static bool SCSI_Command_Send_Diagnostic(USB_ClassInfo_MS_Device_t* const MSInte
|
|||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/* Check to see if all attached Dataflash ICs are functional */
|
||||
if (!(DataflashManager_CheckDataflashOperation()))
|
||||
{
|
||||
/* Update SENSE key with a hardware error condition and return command fail */
|
||||
SCSI_SET_SENSE(SCSI_SENSE_KEY_HARDWARE_ERROR,
|
||||
SCSI_ASENSE_NO_ADDITIONAL_INFORMATION,
|
||||
SCSI_ASENSEQ_NO_QUALIFIER);
|
||||
|
||||
SCSI_ASENSEQ_NO_QUALIFIER);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/* Succeed the command and update the bytes transferred counter */
|
||||
MSInterfaceInfo->State.CommandBlock.DataTransferLength = 0;
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -280,13 +280,13 @@ static bool SCSI_Command_ReadWrite_10(USB_ClassInfo_MS_Device_t* const MSInterfa
|
|||
{
|
||||
uint32_t BlockAddress;
|
||||
uint16_t TotalBlocks;
|
||||
|
||||
|
||||
/* Load in the 32-bit block address (SCSI uses big-endian, so have to reverse the byte order) */
|
||||
BlockAddress = SwapEndian_32(*(uint32_t*)&MSInterfaceInfo->State.CommandBlock.SCSICommandData[2]);
|
||||
|
||||
/* Load in the 16-bit total blocks (SCSI uses big-endian, so have to reverse the byte order) */
|
||||
TotalBlocks = SwapEndian_16(*(uint16_t*)&MSInterfaceInfo->State.CommandBlock.SCSICommandData[7]);
|
||||
|
||||
|
||||
/* Check if the block address is outside the maximum allowable value for the LUN */
|
||||
if (BlockAddress >= VIRTUAL_MEMORY_BLOCKS)
|
||||
{
|
||||
|
@ -297,7 +297,7 @@ static bool SCSI_Command_ReadWrite_10(USB_ClassInfo_MS_Device_t* const MSInterfa
|
|||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/* Determine if the packet is a READ (10) or WRITE (10) command, call appropriate function */
|
||||
if (IsDataRead == DATA_READ)
|
||||
DataflashManager_ReadBlocks(MSInterfaceInfo, BlockAddress, TotalBlocks);
|
||||
|
@ -306,6 +306,7 @@ static bool SCSI_Command_ReadWrite_10(USB_ClassInfo_MS_Device_t* const MSInterfa
|
|||
|
||||
/* Update the bytes transferred counter and succeed the command */
|
||||
MSInterfaceInfo->State.CommandBlock.DataTransferLength -= ((uint32_t)TotalBlocks * VIRTUAL_MEMORY_BLOCK_SIZE);
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -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 SCSI.c.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef _SCSI_H_
|
||||
#define _SCSI_H_
|
||||
|
||||
|
@ -45,7 +45,7 @@
|
|||
|
||||
#include "../Descriptors.h"
|
||||
#include "DataflashManager.h"
|
||||
|
||||
|
||||
/* Macros: */
|
||||
/** Macro to set the current SCSI sense data to the given key, additional sense code and additional sense qualifier. This
|
||||
* is for convenience, as it allows for all three sense values (returned upon request to the host to give information about
|
||||
|
@ -67,13 +67,13 @@
|
|||
|
||||
/** Value for the DeviceType entry in the SCSI_Inquiry_Response_t enum, indicating a Block Media device. */
|
||||
#define DEVICE_TYPE_BLOCK 0x00
|
||||
|
||||
|
||||
/** Value for the DeviceType entry in the SCSI_Inquiry_Response_t enum, indicating a CD-ROM device. */
|
||||
#define DEVICE_TYPE_CDROM 0x05
|
||||
|
||||
|
||||
/* Function Prototypes: */
|
||||
bool SCSI_DecodeSCSICommand(USB_ClassInfo_MS_Device_t* const MSInterfaceInfo);
|
||||
|
||||
|
||||
#if defined(INCLUDE_FROM_SCSI_C)
|
||||
static bool SCSI_Command_Inquiry(USB_ClassInfo_MS_Device_t* const MSInterfaceInfo);
|
||||
static bool SCSI_Command_Request_Sense(USB_ClassInfo_MS_Device_t* const MSInterfaceInfo);
|
||||
|
@ -82,5 +82,6 @@
|
|||
static bool SCSI_Command_ReadWrite_10(USB_ClassInfo_MS_Device_t* const MSInterfaceInfo,
|
||||
const bool IsDataRead);
|
||||
#endif
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -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
|
||||
|
@ -35,7 +35,7 @@
|
|||
* TELNET Webserver Application. When connected to the uIP stack,
|
||||
* this will serve out raw TELNET to the client on port 23.
|
||||
*/
|
||||
|
||||
|
||||
#define INCLUDE_FROM_TELNETSERVERAPP_C
|
||||
#include "TELNETServerApp.h"
|
||||
|
||||
|
@ -50,7 +50,7 @@ const char PROGMEM TELNETMenu[] = "\r\n"
|
|||
" c) List Active TCP Connections\r\n"
|
||||
" =========================\r\n"
|
||||
"\r\n>";
|
||||
|
||||
|
||||
/** Header to print before the current connections are printed to the client */
|
||||
const char PROGMEM CurrentConnectionsHeader[] = "\r\n* Current TCP Connections: *\r\n";
|
||||
|
||||
|
@ -78,7 +78,7 @@ void TELNETServerApp_Callback(void)
|
|||
if (uip_acked())
|
||||
{
|
||||
/* Progress to the next state once the current state's data has been ACKed */
|
||||
AppState->TELNETServer.CurrentState = AppState->TELNETServer.NextState;
|
||||
AppState->TELNETServer.CurrentState = AppState->TELNETServer.NextState;
|
||||
}
|
||||
|
||||
if (uip_rexmit() || uip_acked() || uip_newdata() || uip_connected() || uip_poll())
|
||||
|
@ -89,14 +89,14 @@ void TELNETServerApp_Callback(void)
|
|||
/* Copy over and send the TELNET welcome message upon first connection */
|
||||
strcpy_P(AppData, WelcomeHeader);
|
||||
uip_send(AppData, strlen(AppData));
|
||||
|
||||
|
||||
AppState->TELNETServer.NextState = TELNET_STATE_SendMenu;
|
||||
break;
|
||||
case TELNET_STATE_SendMenu:
|
||||
/* Copy over and send the TELNET menu to the client */
|
||||
strcpy_P(AppData, TELNETMenu);
|
||||
uip_send(AppData, strlen(AppData));
|
||||
|
||||
|
||||
AppState->TELNETServer.NextState = TELNET_STATE_GetCommand;
|
||||
break;
|
||||
case TELNET_STATE_GetCommand:
|
||||
|
@ -105,7 +105,7 @@ void TELNETServerApp_Callback(void)
|
|||
|
||||
/* Save the issued command for later processing */
|
||||
AppState->TELNETServer.IssuedCommand = AppData[0];
|
||||
|
||||
|
||||
AppState->TELNETServer.CurrentState = TELNET_STATE_SendResponse;
|
||||
break;
|
||||
case TELNET_STATE_SendResponse:
|
||||
|
@ -124,7 +124,7 @@ void TELNETServerApp_Callback(void)
|
|||
AppState->TELNETServer.NextState = TELNET_STATE_SendMenu;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** Sends a list of active TCP connections to the TELNET client. */
|
||||
|
@ -133,7 +133,7 @@ static void TELNETServerApp_DisplayTCPConnections(void)
|
|||
char* const AppData = (char*)uip_appdata;
|
||||
|
||||
strcpy_P(AppData, CurrentConnectionsHeader);
|
||||
|
||||
|
||||
uint16_t ResponseLen = strlen(AppData);
|
||||
uint8_t ActiveConnCount = 0;
|
||||
|
||||
|
@ -141,7 +141,7 @@ static void TELNETServerApp_DisplayTCPConnections(void)
|
|||
for (uint8_t i = 0; i < UIP_CONNS; i++)
|
||||
{
|
||||
struct uip_conn* CurrConnection = &uip_conns[i];
|
||||
|
||||
|
||||
/* If the connection is not closed, it is active and must be added to the out buffer */
|
||||
if (CurrConnection->tcpstateflags != UIP_CLOSED)
|
||||
{
|
||||
|
@ -160,3 +160,4 @@ static void TELNETServerApp_DisplayTCPConnections(void)
|
|||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -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/pgmspace.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
|
||||
|
||||
#include <uip.h>
|
||||
|
||||
|
||||
/* Macros: */
|
||||
/** TCP listen port for incoming TELNET traffic. */
|
||||
#define TELNET_SERVER_PORT 23
|
||||
|
||||
|
||||
/* Enums: */
|
||||
/** States for each TELNET connection to the server. */
|
||||
enum TELNET_States_t
|
||||
|
@ -55,14 +55,15 @@
|
|||
TELNET_STATE_SendMenu, /**< Currently sending the command list menu to the client */
|
||||
TELNET_STATE_GetCommand, /**< Currently waiting for a command from the client */
|
||||
TELNET_STATE_SendResponse, /**< Processing the issued command and sending a response */
|
||||
};
|
||||
};
|
||||
|
||||
/* Function Prototypes: */
|
||||
void TELNETServerApp_Init(void);
|
||||
void TELNETServerApp_Callback(void);
|
||||
|
||||
|
||||
#if defined(INCLUDE_FROM_TELNETSERVERAPP_C)
|
||||
static void TELNETServerApp_DisplayTCPConnections(void);
|
||||
#endif
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -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 @@ void uIPManagement_Init(void)
|
|||
/* uIP Timing Initialization */
|
||||
clock_init();
|
||||
timer_set(&ConnectionTimer, CLOCK_SECOND / 2);
|
||||
timer_set(&ARPTimer, CLOCK_SECOND * 10);
|
||||
timer_set(&ARPTimer, CLOCK_SECOND * 10);
|
||||
|
||||
/* uIP Stack Initialization */
|
||||
uip_init();
|
||||
|
@ -75,10 +75,10 @@ void uIPManagement_Init(void)
|
|||
uip_setnetmask(&Netmask);
|
||||
uip_setdraddr(&GatewayIPAddress);
|
||||
#endif
|
||||
|
||||
|
||||
/* HTTP Webserver Initialization */
|
||||
HTTPServerApp_Init();
|
||||
|
||||
|
||||
/* TELNET Server Initialization */
|
||||
#if defined(ENABLE_TELNET_SERVER)
|
||||
TELNETServerApp_Init();
|
||||
|
@ -136,7 +136,7 @@ static void uIPManagement_ProcessIncomingPacket(void)
|
|||
/* If no packet received, exit processing routine */
|
||||
if (!(RNDIS_Host_IsPacketReceived(&Ethernet_RNDIS_Interface)))
|
||||
return;
|
||||
|
||||
|
||||
LEDs_SetAllLEDs(LEDMASK_USB_BUSY);
|
||||
|
||||
/* Read the Incoming packet straight into the UIP packet buffer */
|
||||
|
@ -162,16 +162,16 @@ static void uIPManagement_ProcessIncomingPacket(void)
|
|||
|
||||
uip_split_output();
|
||||
}
|
||||
|
||||
|
||||
break;
|
||||
case HTONS(UIP_ETHTYPE_ARP):
|
||||
/* Process ARP packet */
|
||||
uip_arp_arpin();
|
||||
|
||||
|
||||
/* If a response was generated, send it */
|
||||
if (uip_len > 0)
|
||||
uip_split_output();
|
||||
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -204,7 +204,7 @@ static void uIPManagement_ManageConnections(void)
|
|||
timer_reset(&ConnectionTimer);
|
||||
|
||||
LEDs_SetAllLEDs(LEDMASK_USB_BUSY);
|
||||
|
||||
|
||||
for (uint8_t i = 0; i < UIP_CONNS; i++)
|
||||
{
|
||||
/* Run periodic connection management for each TCP connection */
|
||||
|
@ -220,7 +220,7 @@ static void uIPManagement_ManageConnections(void)
|
|||
uip_split_output();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#if defined(ENABLE_DHCP_CLIENT)
|
||||
for (uint8_t i = 0; i < UIP_UDP_CONNS; i++)
|
||||
{
|
||||
|
@ -249,3 +249,4 @@ static void uIPManagement_ManageConnections(void)
|
|||
uip_arp_timer();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
|
@ -43,18 +43,18 @@
|
|||
#include <uip_arp.h>
|
||||
#include <uip-split.h>
|
||||
#include <timer.h>
|
||||
|
||||
|
||||
#include "Lib/DHCPClientApp.h"
|
||||
#include "Lib/HTTPServerApp.h"
|
||||
#include "Lib/TELNETServerApp.h"
|
||||
|
||||
|
||||
/* Macros: */
|
||||
/** IP address that the webserver should use once connected to a RNDIS device (when DHCP is disabled). */
|
||||
#define DEVICE_IP_ADDRESS (uint8_t[]){192, 168, 1, 10}
|
||||
|
||||
|
||||
/** Netmask that the webserver should once connected to a RNDIS device (when DHCP is disabled). */
|
||||
#define DEVICE_NETMASK (uint8_t[]){255, 255, 255, 0}
|
||||
|
||||
|
||||
/** IP address of the default gateway the webserver should use when routing outside the local subnet
|
||||
* (when DHCP is disabled).
|
||||
*/
|
||||
|
@ -62,18 +62,19 @@
|
|||
|
||||
/* External Variables: */
|
||||
extern struct uip_eth_addr MACAddress;
|
||||
|
||||
|
||||
extern bool HaveIPConfiguration;
|
||||
|
||||
|
||||
/* Function Prototypes: */
|
||||
void uIPManagement_Init(void);
|
||||
void uIPManagement_ManageNetwork(void);
|
||||
void uIPManagement_TCPCallback(void);
|
||||
void uIPManagement_UDPCallback(void);
|
||||
|
||||
|
||||
#if defined(INCLUDE_FROM_UIPMANAGEMENT_C)
|
||||
static void uIPManagement_ProcessIncomingPacket(void);
|
||||
static void uIPManagement_ManageConnections(void);
|
||||
#endif
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -36,3 +36,4 @@ clock_time_t clock_time()
|
|||
|
||||
return time;
|
||||
}
|
||||
|
||||
|
|
|
@ -10,3 +10,4 @@ void clock_init(void);
|
|||
clock_time_t clock_time(void);
|
||||
|
||||
#endif /* __CLOCK_ARCH_H__ */
|
||||
|
||||
|
|
|
@ -125,3 +125,4 @@ timer_expired(struct timer *t)
|
|||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
/** @} */
|
||||
|
||||
|
|
|
@ -84,3 +84,4 @@ int timer_expired(struct timer *t);
|
|||
#endif /* __TIMER_H__ */
|
||||
|
||||
/** @} */
|
||||
|
||||
|
|
|
@ -47,7 +47,7 @@ uip_split_output(void)
|
|||
|
||||
/* We only try to split maximum sized TCP segments. */
|
||||
if(BUF->proto == UIP_PROTO_TCP && uip_len == UIP_BUFSIZE) {
|
||||
|
||||
|
||||
tcplen = uip_len - UIP_TCPIP_HLEN - UIP_LLH_LEN;
|
||||
/* Split the segment in two. If the original packet length was
|
||||
odd, we make the second packet one byte larger. */
|
||||
|
@ -68,7 +68,7 @@ uip_split_output(void)
|
|||
BUF->len[0] = (uip_len - UIP_LLH_LEN) >> 8;
|
||||
BUF->len[1] = (uip_len - UIP_LLH_LEN) & 0xff;
|
||||
#endif /* UIP_CONF_IPV6 */
|
||||
|
||||
|
||||
/* Recalculate the TCP checksum. */
|
||||
BUF->tcpchksum = 0;
|
||||
BUF->tcpchksum = ~(uip_tcpchksum());
|
||||
|
@ -78,14 +78,14 @@ uip_split_output(void)
|
|||
BUF->ipchksum = 0;
|
||||
BUF->ipchksum = ~(uip_ipchksum());
|
||||
#endif /* UIP_CONF_IPV6 */
|
||||
|
||||
|
||||
/* Transmit the first packet. */
|
||||
#if UIP_CONF_IPV6
|
||||
tcpip_ipv6_output();
|
||||
#else
|
||||
RNDIS_Host_SendPacket(&Ethernet_RNDIS_Interface, uip_buf, uip_len);
|
||||
#endif /* UIP_CONF_IPV6 */
|
||||
|
||||
|
||||
/* Now, create the second packet. To do this, it is not enough to
|
||||
just alter the length field, but we must also update the TCP
|
||||
sequence number and point the uip_appdata to a new place in
|
||||
|
@ -101,7 +101,7 @@ uip_split_output(void)
|
|||
BUF->len[0] = (uip_len - UIP_LLH_LEN) >> 8;
|
||||
BUF->len[1] = (uip_len - UIP_LLH_LEN) & 0xff;
|
||||
#endif /* UIP_CONF_IPV6 */
|
||||
|
||||
|
||||
memcpy(uip_appdata, (u8_t *)uip_appdata + len1, len2);
|
||||
|
||||
uip_add32(BUF->seqno, len1);
|
||||
|
@ -109,7 +109,7 @@ uip_split_output(void)
|
|||
BUF->seqno[1] = uip_acc32[1];
|
||||
BUF->seqno[2] = uip_acc32[2];
|
||||
BUF->seqno[3] = uip_acc32[3];
|
||||
|
||||
|
||||
/* Recalculate the TCP checksum. */
|
||||
BUF->tcpchksum = 0;
|
||||
BUF->tcpchksum = ~(uip_tcpchksum());
|
||||
|
@ -139,3 +139,4 @@ uip_split_output(void)
|
|||
}
|
||||
|
||||
/*-----------------------------------------------------------------------------*/
|
||||
|
||||
|
|
|
@ -1,33 +1,33 @@
|
|||
/*
|
||||
* Copyright (c) 2004, Swedish Institute of Computer Science.
|
||||
* All rights reserved.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the Institute nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the Institute nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* This file is part of the Contiki operating system.
|
||||
*
|
||||
*
|
||||
* Author: Adam Dunkels <adam@sics.se>
|
||||
*
|
||||
* $Id: uip-split.h,v 1.1 2006/06/17 22:41:19 adamdunkels Exp $
|
||||
|
@ -63,7 +63,7 @@
|
|||
/**
|
||||
* \file
|
||||
* Module for splitting outbound TCP segments in two to avoid the
|
||||
* delayed ACK throughput degradation.
|
||||
* delayed ACK throughput degradation.
|
||||
* \author
|
||||
* Adam Dunkels <adam@sics.se>
|
||||
*
|
||||
|
@ -101,3 +101,4 @@ void uip_add32(u8_t *op32, u16_t op16);
|
|||
|
||||
/** @} */
|
||||
/** @} */
|
||||
|
||||
|
|
|
@ -245,15 +245,15 @@ uip_add32(u8_t *op32, u16_t op16)
|
|||
uip_acc32[2] = op32[2] + (op16 >> 8);
|
||||
uip_acc32[1] = op32[1];
|
||||
uip_acc32[0] = op32[0];
|
||||
|
||||
|
||||
if(uip_acc32[2] < (op16 >> 8)) {
|
||||
++uip_acc32[1];
|
||||
if(uip_acc32[1] == 0) {
|
||||
++uip_acc32[0];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
if(uip_acc32[3] < (op16 & 0xff)) {
|
||||
++uip_acc32[2];
|
||||
if(uip_acc32[2] == 0) {
|
||||
|
@ -278,7 +278,7 @@ chksum(u16_t sum, const u8_t *data, u16_t len)
|
|||
|
||||
dataptr = data;
|
||||
last_byte = data + len - 1;
|
||||
|
||||
|
||||
while(dataptr < last_byte) { /* At least two more bytes */
|
||||
t = (dataptr[0] << 8) + dataptr[1];
|
||||
sum += t;
|
||||
|
@ -287,7 +287,7 @@ chksum(u16_t sum, const u8_t *data, u16_t len)
|
|||
}
|
||||
dataptr += 2;
|
||||
}
|
||||
|
||||
|
||||
if(dataptr == last_byte) {
|
||||
t = (dataptr[0] << 8) + 0;
|
||||
sum += t;
|
||||
|
@ -323,15 +323,15 @@ upper_layer_chksum(u8_t proto)
|
|||
{
|
||||
u16_t upper_layer_len;
|
||||
u16_t sum;
|
||||
|
||||
|
||||
#if UIP_CONF_IPV6
|
||||
upper_layer_len = (((u16_t)(BUF->len[0]) << 8) + BUF->len[1]);
|
||||
#else /* UIP_CONF_IPV6 */
|
||||
upper_layer_len = (((u16_t)(BUF->len[0]) << 8) + BUF->len[1]) - UIP_IPH_LEN;
|
||||
#endif /* UIP_CONF_IPV6 */
|
||||
|
||||
|
||||
/* First sum pseudoheader. */
|
||||
|
||||
|
||||
/* IP protocol and length fields. This addition cannot carry. */
|
||||
sum = upper_layer_len + proto;
|
||||
/* Sum IP source and destination addresses. */
|
||||
|
@ -340,7 +340,7 @@ upper_layer_chksum(u8_t proto)
|
|||
/* Sum TCP header and data. */
|
||||
sum = chksum(sum, &uip_buf[UIP_IPH_LEN + UIP_LLH_LEN],
|
||||
upper_layer_len);
|
||||
|
||||
|
||||
return (sum == 0) ? 0xffff : htons(sum);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
@ -349,7 +349,7 @@ u16_t
|
|||
uip_icmp6chksum(void)
|
||||
{
|
||||
return upper_layer_chksum(UIP_PROTO_ICMP6);
|
||||
|
||||
|
||||
}
|
||||
#endif /* UIP_CONF_IPV6 */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
@ -386,7 +386,7 @@ uip_init(void)
|
|||
uip_udp_conns[c].lport = 0;
|
||||
}
|
||||
#endif /* UIP_UDP */
|
||||
|
||||
|
||||
|
||||
/* IPv4 initialization. */
|
||||
#if UIP_FIXEDADDR == 0
|
||||
|
@ -400,7 +400,7 @@ struct uip_conn *
|
|||
uip_connect(uip_ipaddr_t *ripaddr, u16_t rport)
|
||||
{
|
||||
register struct uip_conn *conn, *cconn;
|
||||
|
||||
|
||||
/* Find an unused local port. */
|
||||
again:
|
||||
++lastport;
|
||||
|
@ -437,7 +437,7 @@ uip_connect(uip_ipaddr_t *ripaddr, u16_t rport)
|
|||
if(conn == 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
conn->tcpstateflags = UIP_SYN_SENT;
|
||||
|
||||
conn->snd_nxt[0] = iss[0];
|
||||
|
@ -446,7 +446,7 @@ uip_connect(uip_ipaddr_t *ripaddr, u16_t rport)
|
|||
conn->snd_nxt[3] = iss[3];
|
||||
|
||||
conn->initialmss = conn->mss = UIP_TCP_MSS;
|
||||
|
||||
|
||||
conn->len = 1; /* TCP length of the SYN is one. */
|
||||
conn->nrtx = 0;
|
||||
conn->timer = 1; /* Send the SYN next time around. */
|
||||
|
@ -456,7 +456,7 @@ uip_connect(uip_ipaddr_t *ripaddr, u16_t rport)
|
|||
conn->lport = htons(lastport);
|
||||
conn->rport = rport;
|
||||
uip_ipaddr_copy(&conn->ripaddr, ripaddr);
|
||||
|
||||
|
||||
return conn;
|
||||
}
|
||||
#endif /* UIP_ACTIVE_OPEN */
|
||||
|
@ -466,7 +466,7 @@ struct uip_udp_conn *
|
|||
uip_udp_new(const uip_ipaddr_t *ripaddr, u16_t rport)
|
||||
{
|
||||
register struct uip_udp_conn *conn;
|
||||
|
||||
|
||||
/* Find an unused local port. */
|
||||
again:
|
||||
++lastport;
|
||||
|
@ -474,7 +474,7 @@ uip_udp_new(const uip_ipaddr_t *ripaddr, u16_t rport)
|
|||
if(lastport >= 32000) {
|
||||
lastport = 4096;
|
||||
}
|
||||
|
||||
|
||||
for(c = 0; c < UIP_UDP_CONNS; ++c) {
|
||||
if(uip_udp_conns[c].lport == htons(lastport)) {
|
||||
goto again;
|
||||
|
@ -493,7 +493,7 @@ uip_udp_new(const uip_ipaddr_t *ripaddr, u16_t rport)
|
|||
if(conn == 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
conn->lport = HTONS(lastport);
|
||||
conn->rport = rport;
|
||||
if(ripaddr == NULL) {
|
||||
|
@ -502,7 +502,7 @@ uip_udp_new(const uip_ipaddr_t *ripaddr, u16_t rport)
|
|||
uip_ipaddr_copy(&conn->ripaddr, ripaddr);
|
||||
}
|
||||
conn->ttl = UIP_TTL;
|
||||
|
||||
|
||||
return conn;
|
||||
}
|
||||
#endif /* UIP_UDP */
|
||||
|
@ -587,12 +587,12 @@ uip_reass(void)
|
|||
memcpy(&uip_reassbuf[UIP_IPH_LEN + offset],
|
||||
(char *)BUF + (int)((BUF->vhl & 0x0f) * 4),
|
||||
len);
|
||||
|
||||
|
||||
/* Update the bitmap. */
|
||||
if(offset / (8 * 8) == (offset + len) / (8 * 8)) {
|
||||
/* If the two endpoints are in the same byte, we only update
|
||||
that byte. */
|
||||
|
||||
|
||||
uip_reassbitmap[offset / (8 * 8)] |=
|
||||
bitmap_bits[(offset / 8 ) & 7] &
|
||||
~bitmap_bits[((offset + len) / 8 ) & 7];
|
||||
|
@ -608,7 +608,7 @@ uip_reass(void)
|
|||
uip_reassbitmap[(offset + len) / (8 * 8)] |=
|
||||
~bitmap_bits[((offset + len) / 8 ) & 7];
|
||||
}
|
||||
|
||||
|
||||
/* If this fragment has the More Fragments flag set to zero, we
|
||||
know that this is the last fragment, so we can calculate the
|
||||
size of the entire packet. We also set the
|
||||
|
@ -619,7 +619,7 @@ uip_reass(void)
|
|||
uip_reassflags |= UIP_REASS_FLAG_LASTFRAG;
|
||||
uip_reasslen = offset + len;
|
||||
}
|
||||
|
||||
|
||||
/* Finally, we check if we have a full packet in the buffer. We do
|
||||
this by checking if we have the last fragment and if all bits
|
||||
in the bitmap are set. */
|
||||
|
@ -681,7 +681,7 @@ uip_process(u8_t flag)
|
|||
goto udp_send;
|
||||
}
|
||||
#endif /* UIP_UDP */
|
||||
|
||||
|
||||
uip_sappdata = uip_appdata = &uip_buf[UIP_IPTCPH_LEN + UIP_LLH_LEN];
|
||||
|
||||
/* Check if we were invoked because of a poll request for a
|
||||
|
@ -695,7 +695,7 @@ uip_process(u8_t flag)
|
|||
goto appsend;
|
||||
}
|
||||
goto drop;
|
||||
|
||||
|
||||
/* Check if we were invoked because of the periodic timer firing. */
|
||||
} else if(flag == UIP_TIMER) {
|
||||
#if UIP_REASSEMBLY
|
||||
|
@ -754,7 +754,7 @@ uip_process(u8_t flag)
|
|||
4:
|
||||
uip_connr->nrtx);
|
||||
++(uip_connr->nrtx);
|
||||
|
||||
|
||||
/* Ok, so we need to retransmit. We do this differently
|
||||
depending on which state we are in. In ESTABLISHED, we
|
||||
call upon the application so that it may prepare the
|
||||
|
@ -767,14 +767,14 @@ uip_process(u8_t flag)
|
|||
/* In the SYN_RCVD state, we should retransmit our
|
||||
SYNACK. */
|
||||
goto tcp_send_synack;
|
||||
|
||||
|
||||
#if UIP_ACTIVE_OPEN
|
||||
case UIP_SYN_SENT:
|
||||
/* In the SYN_SENT state, we retransmit out SYN. */
|
||||
BUF->flags = 0;
|
||||
goto tcp_send_syn;
|
||||
#endif /* UIP_ACTIVE_OPEN */
|
||||
|
||||
|
||||
case UIP_ESTABLISHED:
|
||||
/* In the ESTABLISHED state, we call upon the application
|
||||
to do the actual retransmit after which we jump into
|
||||
|
@ -783,19 +783,19 @@ uip_process(u8_t flag)
|
|||
uip_flags = UIP_REXMIT;
|
||||
UIP_APPCALL();
|
||||
goto apprexmit;
|
||||
|
||||
|
||||
case UIP_FIN_WAIT_1:
|
||||
case UIP_CLOSING:
|
||||
case UIP_LAST_ACK:
|
||||
/* In all these states we should retransmit a FINACK. */
|
||||
goto tcp_send_finack;
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
} else if((uip_connr->tcpstateflags & UIP_TS_MASK) == UIP_ESTABLISHED) {
|
||||
/* If there was no need for a retransmission, we poll the
|
||||
application for new data. */
|
||||
uip_len = uip_slen = 0;
|
||||
uip_len = uip_slen = 0;
|
||||
uip_flags = UIP_POLL;
|
||||
UIP_APPCALL();
|
||||
goto appsend;
|
||||
|
@ -822,7 +822,7 @@ uip_process(u8_t flag)
|
|||
UIP_STAT(++uip_stat.ip.recv);
|
||||
|
||||
/* Start of IP input header processing code. */
|
||||
|
||||
|
||||
#if UIP_CONF_IPV6
|
||||
/* Check validity of the IP header. */
|
||||
if((BUF->vtc & 0xf0) != 0x60) { /* IP version and header length. */
|
||||
|
@ -840,7 +840,7 @@ uip_process(u8_t flag)
|
|||
goto drop;
|
||||
}
|
||||
#endif /* UIP_CONF_IPV6 */
|
||||
|
||||
|
||||
/* Check the size of the packet. If the size reported to us in
|
||||
uip_len is smaller the size reported in the IP header, we assume
|
||||
that the packet has been corrupted in transit. If the size of
|
||||
|
@ -910,7 +910,7 @@ uip_process(u8_t flag)
|
|||
goto udp_input;
|
||||
}
|
||||
#endif /* UIP_BROADCAST */
|
||||
|
||||
|
||||
/* Check if the packet is destined for our IP address. */
|
||||
#if !UIP_CONF_IPV6
|
||||
if(!uip_ipaddr_cmp(&BUF->destipaddr, &uip_hostaddr)) {
|
||||
|
@ -1028,14 +1028,14 @@ uip_process(u8_t flag)
|
|||
/* Save the sender's address in our neighbor list. */
|
||||
uip_neighbor_add(&ICMPBUF->srcipaddr, &(ICMPBUF->options[2]));
|
||||
}
|
||||
|
||||
|
||||
/* We should now send a neighbor advertisement back to where the
|
||||
neighbor solicitation came from. */
|
||||
ICMPBUF->type = ICMP6_NEIGHBOR_ADVERTISEMENT;
|
||||
ICMPBUF->flags = ICMP6_FLAG_S; /* Solicited flag. */
|
||||
|
||||
|
||||
ICMPBUF->reserved1 = ICMPBUF->reserved2 = ICMPBUF->reserved3 = 0;
|
||||
|
||||
|
||||
uip_ipaddr_copy(&ICMPBUF->destipaddr, &ICMPBUF->srcipaddr);
|
||||
uip_ipaddr_copy(&ICMPBUF->srcipaddr, &uip_hostaddr);
|
||||
ICMPBUF->options[0] = ICMP6_OPTION_TARGET_LINK_ADDRESS;
|
||||
|
@ -1043,9 +1043,9 @@ uip_process(u8_t flag)
|
|||
memcpy(&(ICMPBUF->options[2]), &uip_ethaddr, sizeof(uip_ethaddr));
|
||||
ICMPBUF->icmpchksum = 0;
|
||||
ICMPBUF->icmpchksum = ~uip_icmp6chksum();
|
||||
|
||||
|
||||
goto send;
|
||||
|
||||
|
||||
}
|
||||
goto drop;
|
||||
} else if(ICMPBUF->type == ICMP6_ECHO) {
|
||||
|
@ -1054,12 +1054,12 @@ uip_process(u8_t flag)
|
|||
ICMP checksum before we return the packet. */
|
||||
|
||||
ICMPBUF->type = ICMP6_ECHO_REPLY;
|
||||
|
||||
|
||||
uip_ipaddr_copy(&BUF->destipaddr, &BUF->srcipaddr);
|
||||
uip_ipaddr_copy(&BUF->srcipaddr, &uip_hostaddr);
|
||||
ICMPBUF->icmpchksum = 0;
|
||||
ICMPBUF->icmpchksum = ~uip_icmp6chksum();
|
||||
|
||||
|
||||
UIP_STAT(++uip_stat.icmp.sent);
|
||||
goto send;
|
||||
} else {
|
||||
|
@ -1071,7 +1071,7 @@ uip_process(u8_t flag)
|
|||
}
|
||||
|
||||
/* End of IPv6 ICMP processing. */
|
||||
|
||||
|
||||
#endif /* !UIP_CONF_IPV6 */
|
||||
|
||||
#if UIP_UDP
|
||||
|
@ -1147,7 +1147,7 @@ uip_process(u8_t flag)
|
|||
#else /* UIP_CONF_ICMP_DEST_UNREACH */
|
||||
goto drop;
|
||||
#endif /* UIP_CONF_ICMP_DEST_UNREACH */
|
||||
|
||||
|
||||
udp_found:
|
||||
uip_conn = NULL;
|
||||
uip_flags = UIP_NEWDATA;
|
||||
|
@ -1182,7 +1182,7 @@ uip_process(u8_t flag)
|
|||
|
||||
uip_ipaddr_copy(&BUF->srcipaddr, &uip_hostaddr);
|
||||
uip_ipaddr_copy(&BUF->destipaddr, &uip_udp_conn->ripaddr);
|
||||
|
||||
|
||||
uip_appdata = &uip_buf[UIP_LLH_LEN + UIP_IPTCPH_LEN];
|
||||
|
||||
#if UIP_UDP_CHECKSUMS
|
||||
|
@ -1192,16 +1192,16 @@ uip_process(u8_t flag)
|
|||
UDPBUF->udpchksum = 0xffff;
|
||||
}
|
||||
#endif /* UIP_UDP_CHECKSUMS */
|
||||
|
||||
|
||||
goto ip_send_nolen;
|
||||
#endif /* UIP_UDP */
|
||||
|
||||
|
||||
/* TCP input processing. */
|
||||
tcp_input:
|
||||
UIP_STAT(++uip_stat.tcp.recv);
|
||||
|
||||
/* Start of TCP input header processing code. */
|
||||
|
||||
|
||||
if(uip_tcpchksum() != 0xffff) { /* Compute and check the TCP
|
||||
checksum. */
|
||||
UIP_STAT(++uip_stat.tcp.drop);
|
||||
|
@ -1209,7 +1209,7 @@ uip_process(u8_t flag)
|
|||
UIP_LOG("tcp: bad checksum.");
|
||||
goto drop;
|
||||
}
|
||||
|
||||
|
||||
/* Demultiplex this segment. */
|
||||
/* First check any active connections. */
|
||||
for(uip_connr = &uip_conns[0]; uip_connr <= &uip_conns[UIP_CONNS - 1];
|
||||
|
@ -1229,7 +1229,7 @@ uip_process(u8_t flag)
|
|||
if((BUF->flags & TCP_CTL) != TCP_SYN) {
|
||||
goto reset;
|
||||
}
|
||||
|
||||
|
||||
tmp16 = BUF->destport;
|
||||
/* Next, check listening connections. */
|
||||
for(c = 0; c < UIP_LISTENPORTS; ++c) {
|
||||
|
@ -1237,7 +1237,7 @@ uip_process(u8_t flag)
|
|||
goto found_listen;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* No matching connection found, so we send a RST packet. */
|
||||
UIP_STAT(++uip_stat.tcp.synrst);
|
||||
|
||||
|
@ -1248,7 +1248,7 @@ uip_process(u8_t flag)
|
|||
}
|
||||
|
||||
UIP_STAT(++uip_stat.tcp.rst);
|
||||
|
||||
|
||||
BUF->flags = TCP_RST | TCP_ACK;
|
||||
uip_len = UIP_IPTCPH_LEN;
|
||||
BUF->tcpoffset = 5 << 4;
|
||||
|
@ -1257,15 +1257,15 @@ uip_process(u8_t flag)
|
|||
c = BUF->seqno[3];
|
||||
BUF->seqno[3] = BUF->ackno[3];
|
||||
BUF->ackno[3] = c;
|
||||
|
||||
|
||||
c = BUF->seqno[2];
|
||||
BUF->seqno[2] = BUF->ackno[2];
|
||||
BUF->ackno[2] = c;
|
||||
|
||||
|
||||
c = BUF->seqno[1];
|
||||
BUF->seqno[1] = BUF->ackno[1];
|
||||
BUF->ackno[1] = c;
|
||||
|
||||
|
||||
c = BUF->seqno[0];
|
||||
BUF->seqno[0] = BUF->ackno[0];
|
||||
BUF->ackno[0] = c;
|
||||
|
@ -1280,16 +1280,16 @@ uip_process(u8_t flag)
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Swap port numbers. */
|
||||
tmp16 = BUF->srcport;
|
||||
BUF->srcport = BUF->destport;
|
||||
BUF->destport = tmp16;
|
||||
|
||||
|
||||
/* Swap IP addresses. */
|
||||
uip_ipaddr_copy(&BUF->destipaddr, &BUF->srcipaddr);
|
||||
uip_ipaddr_copy(&BUF->srcipaddr, &uip_hostaddr);
|
||||
|
||||
|
||||
/* And send out the RST packet! */
|
||||
goto tcp_send_noconn;
|
||||
|
||||
|
@ -1326,7 +1326,7 @@ uip_process(u8_t flag)
|
|||
goto drop;
|
||||
}
|
||||
uip_conn = uip_connr;
|
||||
|
||||
|
||||
/* Fill in the necessary fields for the new connection. */
|
||||
uip_connr->rto = uip_connr->timer = UIP_RTO;
|
||||
uip_connr->sa = 0;
|
||||
|
@ -1367,7 +1367,7 @@ uip_process(u8_t flag)
|
|||
(u16_t)uip_buf[UIP_IPTCPH_LEN + UIP_LLH_LEN + 3 + c];
|
||||
uip_connr->initialmss = uip_connr->mss =
|
||||
tmp16 > UIP_TCP_MSS? UIP_TCP_MSS: tmp16;
|
||||
|
||||
|
||||
/* And we are done processing options. */
|
||||
break;
|
||||
} else {
|
||||
|
@ -1382,19 +1382,19 @@ uip_process(u8_t flag)
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Our response will be a SYNACK. */
|
||||
#if UIP_ACTIVE_OPEN
|
||||
tcp_send_synack:
|
||||
BUF->flags = TCP_ACK;
|
||||
|
||||
|
||||
tcp_send_syn:
|
||||
BUF->flags |= TCP_SYN;
|
||||
#else /* UIP_ACTIVE_OPEN */
|
||||
tcp_send_synack:
|
||||
BUF->flags = TCP_SYN | TCP_ACK;
|
||||
#endif /* UIP_ACTIVE_OPEN */
|
||||
|
||||
|
||||
/* We send out the TCP Maximum Segment Size option with our
|
||||
SYNACK. */
|
||||
BUF->optdata[0] = TCP_OPT_MSS;
|
||||
|
@ -1458,7 +1458,7 @@ uip_process(u8_t flag)
|
|||
uip_connr->snd_nxt[1] = uip_acc32[1];
|
||||
uip_connr->snd_nxt[2] = uip_acc32[2];
|
||||
uip_connr->snd_nxt[3] = uip_acc32[3];
|
||||
|
||||
|
||||
/* Do RTT estimation, unless we have done retransmissions. */
|
||||
if(uip_connr->nrtx == 0) {
|
||||
signed char m;
|
||||
|
@ -1482,7 +1482,7 @@ uip_process(u8_t flag)
|
|||
/* Reset length of outstanding data. */
|
||||
uip_connr->len = 0;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/* Do different things depending on in what state the connection is. */
|
||||
|
@ -1570,7 +1570,7 @@ uip_process(u8_t flag)
|
|||
uip_conn->tcpstateflags = UIP_CLOSED;
|
||||
goto reset;
|
||||
#endif /* UIP_ACTIVE_OPEN */
|
||||
|
||||
|
||||
case UIP_ESTABLISHED:
|
||||
/* In the ESTABLISHED state, we call upon the application to feed
|
||||
data into the uip_buf. If the UIP_ACKDATA flag is set, the
|
||||
|
@ -1672,7 +1672,7 @@ uip_process(u8_t flag)
|
|||
UIP_APPCALL();
|
||||
|
||||
appsend:
|
||||
|
||||
|
||||
if(uip_flags & UIP_ABORT) {
|
||||
uip_slen = 0;
|
||||
uip_connr->tcpstateflags = UIP_CLOSED;
|
||||
|
@ -1724,7 +1724,7 @@ uip_process(u8_t flag)
|
|||
uip_connr->nrtx = 0;
|
||||
apprexmit:
|
||||
uip_appdata = uip_sappdata;
|
||||
|
||||
|
||||
/* If the application has data to be sent, or if the incoming
|
||||
packet had new data in it, we must send out a packet. */
|
||||
if(uip_slen > 0 && uip_connr->len > 0) {
|
||||
|
@ -1753,7 +1753,7 @@ uip_process(u8_t flag)
|
|||
UIP_APPCALL();
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
case UIP_FIN_WAIT_1:
|
||||
/* The application has closed the connection, but the remote host
|
||||
hasn't closed its end yet. Thus we do nothing but wait for a
|
||||
|
@ -1782,7 +1782,7 @@ uip_process(u8_t flag)
|
|||
goto tcp_send_ack;
|
||||
}
|
||||
goto drop;
|
||||
|
||||
|
||||
case UIP_FIN_WAIT_2:
|
||||
if(uip_len > 0) {
|
||||
uip_add_rcv_nxt(uip_len);
|
||||
|
@ -1802,7 +1802,7 @@ uip_process(u8_t flag)
|
|||
|
||||
case UIP_TIME_WAIT:
|
||||
goto tcp_send_ack;
|
||||
|
||||
|
||||
case UIP_CLOSING:
|
||||
if(uip_flags & UIP_ACKDATA) {
|
||||
uip_connr->tcpstateflags = UIP_TIME_WAIT;
|
||||
|
@ -1810,7 +1810,7 @@ uip_process(u8_t flag)
|
|||
}
|
||||
}
|
||||
goto drop;
|
||||
|
||||
|
||||
/* We jump here when we are ready to send the packet, and just want
|
||||
to set the appropriate TCP sequence numbers in the TCP header. */
|
||||
tcp_send_ack:
|
||||
|
@ -1831,14 +1831,14 @@ uip_process(u8_t flag)
|
|||
BUF->ackno[1] = uip_connr->rcv_nxt[1];
|
||||
BUF->ackno[2] = uip_connr->rcv_nxt[2];
|
||||
BUF->ackno[3] = uip_connr->rcv_nxt[3];
|
||||
|
||||
|
||||
BUF->seqno[0] = uip_connr->snd_nxt[0];
|
||||
BUF->seqno[1] = uip_connr->snd_nxt[1];
|
||||
BUF->seqno[2] = uip_connr->snd_nxt[2];
|
||||
BUF->seqno[3] = uip_connr->snd_nxt[3];
|
||||
|
||||
BUF->proto = UIP_PROTO_TCP;
|
||||
|
||||
|
||||
BUF->srcport = uip_connr->lport;
|
||||
BUF->destport = uip_connr->rport;
|
||||
|
||||
|
@ -1867,7 +1867,7 @@ uip_process(u8_t flag)
|
|||
#endif /* UIP_CONF_IPV6 */
|
||||
|
||||
BUF->urgp[0] = BUF->urgp[1] = 0;
|
||||
|
||||
|
||||
/* Calculate TCP checksum. */
|
||||
BUF->tcpchksum = 0;
|
||||
BUF->tcpchksum = ~(uip_tcpchksum());
|
||||
|
@ -1888,14 +1888,14 @@ uip_process(u8_t flag)
|
|||
BUF->ipchksum = 0;
|
||||
BUF->ipchksum = ~(uip_ipchksum());
|
||||
DEBUG_PRINTF("uip ip_send_nolen: chkecum 0x%04x\n", uip_ipchksum());
|
||||
#endif /* UIP_CONF_IPV6 */
|
||||
#endif /* UIP_CONF_IPV6 */
|
||||
UIP_STAT(++uip_stat.tcp.sent);
|
||||
#if UIP_CONF_IPV6
|
||||
send:
|
||||
#endif /* UIP_CONF_IPV6 */
|
||||
DEBUG_PRINTF("Sending packet with length %d (%d)\n", uip_len,
|
||||
(BUF->len[0] << 8) | BUF->len[1]);
|
||||
|
||||
|
||||
UIP_STAT(++uip_stat.ip.sent);
|
||||
/* Return and let the caller do the actual transmission. */
|
||||
uip_flags = 0;
|
||||
|
@ -1936,3 +1936,4 @@ uip_send(const void *data, int len)
|
|||
/*---------------------------------------------------------------------------*/
|
||||
/** @} */
|
||||
#endif /* UIP_CONF_IPV6 */
|
||||
|
||||
|
|
|
@ -145,7 +145,7 @@ typedef struct uip_eth_addr uip_lladdr_t;
|
|||
|
||||
uip_ipaddr(&addr, 192,168,1,2);
|
||||
uip_sethostaddr(&addr);
|
||||
|
||||
|
||||
\endcode
|
||||
* \param addr A pointer to an IP address of type uip_ipaddr_t;
|
||||
*
|
||||
|
@ -805,7 +805,7 @@ void uip_send(const void *data, int len);
|
|||
\code
|
||||
uip_ipaddr_t addr;
|
||||
struct uip_udp_conn *c;
|
||||
|
||||
|
||||
uip_ipaddr(&addr, 192,168,2,1);
|
||||
c = uip_udp_new(&addr, HTONS(12345));
|
||||
if(c != NULL) {
|
||||
|
@ -866,7 +866,7 @@ struct uip_udp_conn *uip_udp_new(const uip_ipaddr_t *ripaddr, u16_t rport);
|
|||
* These functions can be used for converting between different data
|
||||
* formats used by uIP.
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Convert an IP address to four bytes separated by commas.
|
||||
*
|
||||
|
@ -892,7 +892,7 @@ struct uip_udp_conn *uip_udp_new(const uip_ipaddr_t *ripaddr, u16_t rport);
|
|||
\code
|
||||
uip_ipaddr_t ipaddr;
|
||||
struct uip_conn *c;
|
||||
|
||||
|
||||
uip_ipaddr(&ipaddr, 192,168,1,2);
|
||||
c = uip_connect(&ipaddr, HTONS(80));
|
||||
\endcode
|
||||
|
@ -1281,11 +1281,11 @@ extern u16_t uip_urglen, uip_surglen;
|
|||
*/
|
||||
struct uip_conn {
|
||||
uip_ipaddr_t ripaddr; /**< The IP address of the remote host. */
|
||||
|
||||
|
||||
u16_t lport; /**< The local TCP port, in network byte order. */
|
||||
u16_t rport; /**< The local remote TCP port, in network byte
|
||||
order. */
|
||||
|
||||
|
||||
u8_t rcv_nxt[4]; /**< The sequence number that we expect to
|
||||
receive next. */
|
||||
u8_t snd_nxt[4]; /**< The sequence number that was last sent by
|
||||
|
@ -1398,7 +1398,7 @@ struct uip_stats {
|
|||
layer. */
|
||||
uip_stats_t sent; /**< Number of sent packets at the IP
|
||||
layer. */
|
||||
uip_stats_t forwarded;/**< Number of forwarded packets at the IP
|
||||
uip_stats_t forwarded;/**< Number of forwarded packets at the IP
|
||||
layer. */
|
||||
uip_stats_t drop; /**< Number of dropped packets at the IP
|
||||
layer. */
|
||||
|
@ -1527,14 +1527,14 @@ uip_ext_hdr_options_process(); */
|
|||
* The actual uIP function which does all the work.
|
||||
*/
|
||||
void uip_process(u8_t flag);
|
||||
|
||||
|
||||
/* The following flags are passed as an argument to the uip_process()
|
||||
function. They are used to distinguish between the two cases where
|
||||
uip_process() is called. It can be called either because we have
|
||||
incoming data that should be processed, or because the periodic
|
||||
timer has fired. These values are never used directly, but only in
|
||||
the macros defined in this file. */
|
||||
|
||||
|
||||
#define UIP_DATA 1 /* Tells uIP that there is incoming
|
||||
data in the uip_buf buffer. The
|
||||
length of the data is stored in the
|
||||
|
@ -1561,7 +1561,7 @@ void uip_process(u8_t flag);
|
|||
#define UIP_TIME_WAIT 7
|
||||
#define UIP_LAST_ACK 8
|
||||
#define UIP_TS_MASK 15
|
||||
|
||||
|
||||
#define UIP_STOPPED 16
|
||||
|
||||
/* The TCP and IP headers. */
|
||||
|
@ -1586,7 +1586,7 @@ struct uip_tcpip_hdr {
|
|||
u16_t ipchksum;
|
||||
uip_ipaddr_t srcipaddr, destipaddr;
|
||||
#endif /* UIP_CONF_IPV6 */
|
||||
|
||||
|
||||
/* TCP header. */
|
||||
u16_t srcport,
|
||||
destport;
|
||||
|
@ -1622,7 +1622,7 @@ struct uip_icmpip_hdr {
|
|||
u16_t ipchksum;
|
||||
uip_ipaddr_t srcipaddr, destipaddr;
|
||||
#endif /* UIP_CONF_IPV6 */
|
||||
|
||||
|
||||
/* ICMP header. */
|
||||
u8_t type, icode;
|
||||
u16_t icmpchksum;
|
||||
|
@ -1655,7 +1655,7 @@ struct uip_udpip_hdr {
|
|||
u16_t ipchksum;
|
||||
uip_ipaddr_t srcipaddr, destipaddr;
|
||||
#endif /* UIP_CONF_IPV6 */
|
||||
|
||||
|
||||
/* UDP header. */
|
||||
u16_t srcport,
|
||||
destport;
|
||||
|
@ -2023,7 +2023,7 @@ extern uip_lladdr_t uip_lladdr;
|
|||
(((a)->u8[13]) == (m)->addr[3]) && \
|
||||
(((a)->u8[14]) == (m)->addr[4]) && \
|
||||
(((a)->u8[15]) == (m)->addr[5]))
|
||||
|
||||
|
||||
#endif /*UIP_CONF_LL_802154*/
|
||||
|
||||
/**
|
||||
|
@ -2127,3 +2127,4 @@ u16_t uip_icmp6chksum(void);
|
|||
|
||||
|
||||
/** @} */
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
*
|
||||
* \note This ARP implementation only supports Ethernet.
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* \file
|
||||
* Implementation of the ARP Address Resolution Protocol.
|
||||
|
@ -150,7 +150,7 @@ void
|
|||
uip_arp_timer(void)
|
||||
{
|
||||
struct arp_entry *tabptr = NULL;
|
||||
|
||||
|
||||
++arptime;
|
||||
for(i = 0; i < UIP_ARPTAB_SIZE; ++i) {
|
||||
tabptr = &arp_table[i];
|
||||
|
@ -178,7 +178,7 @@ uip_arp_update(uip_ipaddr_t *ipaddr, struct uip_eth_addr *ethaddr)
|
|||
/* Check if the source IP address of the incoming packet matches
|
||||
the IP address in this ARP table entry. */
|
||||
if(uip_ipaddr_cmp(ipaddr, &tabptr->ipaddr)) {
|
||||
|
||||
|
||||
/* An old entry found, update this and return. */
|
||||
memcpy(tabptr->ethaddr.addr, ethaddr->addr, 6);
|
||||
tabptr->time = arptime;
|
||||
|
@ -240,7 +240,7 @@ void
|
|||
uip_arp_ipin(void)
|
||||
{
|
||||
uip_len -= sizeof(struct uip_eth_hdr);
|
||||
|
||||
|
||||
/* Only insert/update an entry if the source IP address of the
|
||||
incoming IP packet comes from a host on the local network. */
|
||||
if((IPBUF->srcipaddr[0] & uip_netmask[0]) !=
|
||||
|
@ -252,7 +252,7 @@ uip_arp_ipin(void)
|
|||
return;
|
||||
}
|
||||
uip_arp_update(IPBUF->srcipaddr, &(IPBUF->ethhdr.src));
|
||||
|
||||
|
||||
return;
|
||||
}
|
||||
#endif /* 0 */
|
||||
|
@ -287,7 +287,7 @@ uip_arp_arpin(void)
|
|||
return;
|
||||
}
|
||||
uip_len = 0;
|
||||
|
||||
|
||||
switch(BUF->opcode) {
|
||||
case HTONS(ARP_REQUEST):
|
||||
/* ARP request. If it asked for our address, we send out a
|
||||
|
@ -304,14 +304,14 @@ uip_arp_arpin(void)
|
|||
table, since it is likely that we will do more communication
|
||||
with this host in the future. */
|
||||
uip_arp_update(&BUF->sipaddr, &BUF->shwaddr);
|
||||
|
||||
|
||||
BUF->opcode = HTONS(ARP_REPLY);
|
||||
|
||||
memcpy(BUF->dhwaddr.addr, BUF->shwaddr.addr, 6);
|
||||
memcpy(BUF->shwaddr.addr, uip_ethaddr.addr, 6);
|
||||
memcpy(BUF->ethhdr.src.addr, uip_ethaddr.addr, 6);
|
||||
memcpy(BUF->ethhdr.dest.addr, BUF->dhwaddr.addr, 6);
|
||||
|
||||
|
||||
uip_ipaddr_copy(&BUF->dipaddr, &BUF->sipaddr);
|
||||
uip_ipaddr_copy(&BUF->sipaddr, &uip_hostaddr);
|
||||
|
||||
|
@ -362,7 +362,7 @@ void
|
|||
uip_arp_out(void)
|
||||
{
|
||||
struct arp_entry *tabptr = NULL;
|
||||
|
||||
|
||||
/* Find the destination IP address in the ARP table and construct
|
||||
the Ethernet header. If the destination IP address isn't on the
|
||||
local network, we use the default router's IP address instead.
|
||||
|
@ -384,7 +384,7 @@ uip_arp_out(void)
|
|||
/* Else, we use the destination IP address. */
|
||||
uip_ipaddr_copy(&ipaddr, &IPBUF->destipaddr);
|
||||
}
|
||||
|
||||
|
||||
for(i = 0; i < UIP_ARPTAB_SIZE; ++i) {
|
||||
tabptr = &arp_table[i];
|
||||
if(uip_ipaddr_cmp(&ipaddr, &tabptr->ipaddr)) {
|
||||
|
@ -400,7 +400,7 @@ uip_arp_out(void)
|
|||
memset(BUF->dhwaddr.addr, 0x00, 6);
|
||||
memcpy(BUF->ethhdr.src.addr, uip_ethaddr.addr, 6);
|
||||
memcpy(BUF->shwaddr.addr, uip_ethaddr.addr, 6);
|
||||
|
||||
|
||||
uip_ipaddr_copy(&BUF->dipaddr, &ipaddr);
|
||||
uip_ipaddr_copy(&BUF->sipaddr, &uip_hostaddr);
|
||||
BUF->opcode = HTONS(ARP_REQUEST); /* ARP request. */
|
||||
|
@ -411,7 +411,7 @@ uip_arp_out(void)
|
|||
BUF->ethhdr.type = HTONS(UIP_ETHTYPE_ARP);
|
||||
|
||||
uip_appdata = &uip_buf[UIP_TCPIP_HLEN + UIP_LLH_LEN];
|
||||
|
||||
|
||||
uip_len = sizeof(struct arp_hdr);
|
||||
return;
|
||||
}
|
||||
|
@ -420,7 +420,7 @@ uip_arp_out(void)
|
|||
memcpy(IPBUF->ethhdr.dest.addr, tabptr->ethaddr.addr, 6);
|
||||
}
|
||||
memcpy(IPBUF->ethhdr.src.addr, uip_ethaddr.addr, 6);
|
||||
|
||||
|
||||
IPBUF->ethhdr.type = HTONS(UIP_ETHTYPE_IP);
|
||||
|
||||
uip_len += sizeof(struct uip_eth_hdr);
|
||||
|
@ -429,3 +429,4 @@ uip_arp_out(void)
|
|||
|
||||
/** @} */
|
||||
/** @} */
|
||||
|
||||
|
|
|
@ -7,13 +7,13 @@
|
|||
* \addtogroup uiparp
|
||||
* @{
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* \file
|
||||
* Macros and definitions for the ARP module.
|
||||
* \author Adam Dunkels <adam@dunkels.com>
|
||||
*/
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Copyright (c) 2001-2003, Adam Dunkels.
|
||||
|
@ -143,3 +143,4 @@ void uip_arp_timer(void);
|
|||
|
||||
#endif /* __UIP_ARP_H__ */
|
||||
/** @} */
|
||||
|
||||
|
|
|
@ -189,12 +189,12 @@
|
|||
#define UIP_CONF_IPV6_QUEUE_PKT 0
|
||||
#endif
|
||||
|
||||
#ifndef UIP_CONF_IPV6_CHECKS
|
||||
#ifndef UIP_CONF_IPV6_CHECKS
|
||||
/** Do we do IPv6 consistency checks (highly recommended, default: yes) */
|
||||
#define UIP_CONF_IPV6_CHECKS 1
|
||||
#endif
|
||||
|
||||
#ifndef UIP_CONF_IPV6_REASSEMBLY
|
||||
#ifndef UIP_CONF_IPV6_REASSEMBLY
|
||||
/** Do we do IPv6 fragmentation (default: no) */
|
||||
#define UIP_CONF_IPV6_REASSEMBLY 0
|
||||
#endif
|
||||
|
@ -204,14 +204,14 @@
|
|||
#define UIP_CONF_NETIF_MAX_ADDRESSES 3
|
||||
#endif
|
||||
|
||||
#ifndef UIP_CONF_ND6_MAX_PREFIXES
|
||||
#ifndef UIP_CONF_ND6_MAX_PREFIXES
|
||||
/** Default number of IPv6 prefixes associated to the node's interface */
|
||||
#define UIP_CONF_ND6_MAX_PREFIXES 3
|
||||
#endif
|
||||
|
||||
#ifndef UIP_CONF_ND6_MAX_NEIGHBORS
|
||||
#ifndef UIP_CONF_ND6_MAX_NEIGHBORS
|
||||
/** Default number of neighbors that can be stored in the %neighbor cache */
|
||||
#define UIP_CONF_ND6_MAX_NEIGHBORS 4
|
||||
#define UIP_CONF_ND6_MAX_NEIGHBORS 4
|
||||
#endif
|
||||
|
||||
#ifndef UIP_CONF_ND6_MAX_DEFROUTERS
|
||||
|
@ -485,14 +485,14 @@
|
|||
/**
|
||||
* If we use IPHC compression, how many address contexts do we support
|
||||
*/
|
||||
#ifndef SICSLOWPAN_CONF_MAX_ADDR_CONTEXTS
|
||||
#ifndef SICSLOWPAN_CONF_MAX_ADDR_CONTEXTS
|
||||
#define SICSLOWPAN_CONF_MAX_ADDR_CONTEXTS 1
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Do we support 6lowpan fragmentation
|
||||
*/
|
||||
#ifndef SICSLOWPAN_CONF_FRAG
|
||||
#ifndef SICSLOWPAN_CONF_FRAG
|
||||
#define SICSLOWPAN_CONF_FRAG 0
|
||||
#endif
|
||||
|
||||
|
@ -690,19 +690,19 @@ typedef union
|
|||
{
|
||||
uint8_t CurrentState;
|
||||
uint8_t NextState;
|
||||
|
||||
|
||||
char FileName[MAX_URI_LENGTH];
|
||||
FIL FileHandle;
|
||||
bool FileOpen;
|
||||
uint32_t ACKedFilePos;
|
||||
uint16_t SentChunkSize;
|
||||
} HTTPServer;
|
||||
|
||||
|
||||
struct
|
||||
{
|
||||
uint8_t CurrentState;
|
||||
uint8_t NextState;
|
||||
|
||||
|
||||
uint8_t IssuedCommand;
|
||||
} TELNETServer;
|
||||
} uip_tcp_appstate_t;
|
||||
|
@ -720,7 +720,7 @@ typedef union
|
|||
{
|
||||
uint8_t CurrentState;
|
||||
struct timer Timeout;
|
||||
|
||||
|
||||
struct
|
||||
{
|
||||
uint8_t AllocatedIP[4];
|
||||
|
@ -735,3 +735,4 @@ typedef union
|
|||
#endif /* __UIPOPT_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
|
||||
|
@ -33,7 +33,7 @@
|
|||
* USB Device Mode management functions and variables. This file contains the LUFA code required to
|
||||
* manage the USB Mass Storage device mode.
|
||||
*/
|
||||
|
||||
|
||||
#include "USBDeviceMode.h"
|
||||
|
||||
/** LUFA Mass Storage Class driver interface configuration and state information. This structure is
|
||||
|
@ -105,10 +105,11 @@ void EVENT_USB_Device_UnhandledControlRequest(void)
|
|||
bool CALLBACK_MS_Device_SCSICommandReceived(USB_ClassInfo_MS_Device_t* const MSInterfaceInfo)
|
||||
{
|
||||
bool CommandSuccess;
|
||||
|
||||
|
||||
LEDs_SetAllLEDs(LEDMASK_USB_BUSY);
|
||||
CommandSuccess = SCSI_DecodeSCSICommand(MSInterfaceInfo);
|
||||
LEDs_SetAllLEDs(LEDMASK_USB_READY);
|
||||
|
||||
|
||||
return CommandSuccess;
|
||||
}
|
||||
|
||||
|
|
|
@ -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/MassStorage.h>
|
||||
|
||||
|
||||
#include "Webserver.h"
|
||||
#include "Descriptors.h"
|
||||
#include "Lib/SCSI.h"
|
||||
|
@ -53,5 +53,6 @@
|
|||
void EVENT_USB_Device_UnhandledControlRequest(void);
|
||||
|
||||
bool CALLBACK_MS_Device_SCSICommandReceived(USB_ClassInfo_MS_Device_t* const MSInterfaceInfo);
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -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 @@
|
|||
* USB Host Mode management functions and variables. This file contains the LUFA code required to
|
||||
* manage the USB RNDIS host mode.
|
||||
*/
|
||||
|
||||
|
||||
#include "USBHostMode.h"
|
||||
|
||||
/** LUFA RNDIS Class driver interface configuration and state information. This structure is
|
||||
|
@ -52,7 +52,7 @@ USB_ClassInfo_RNDIS_Host_t Ethernet_RNDIS_Interface =
|
|||
|
||||
.NotificationPipeNumber = 3,
|
||||
.NotificationPipeDoubleBank = false,
|
||||
|
||||
|
||||
.HostMaxPacketSize = UIP_CONF_BUFFER_SIZE,
|
||||
},
|
||||
};
|
||||
|
@ -70,7 +70,7 @@ void USBHostMode_USBTask(void)
|
|||
{
|
||||
case HOST_STATE_Addressed:
|
||||
LEDs_SetAllLEDs(LEDMASK_USB_ENUMERATING);
|
||||
|
||||
|
||||
uint16_t ConfigDescriptorSize;
|
||||
uint8_t ConfigDescriptorData[512];
|
||||
|
||||
|
@ -89,21 +89,21 @@ void USBHostMode_USBTask(void)
|
|||
USB_HostState = HOST_STATE_WaitForDeviceRemoval;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
if (USB_Host_SetDeviceConfiguration(1) != HOST_SENDCONTROL_Successful)
|
||||
{
|
||||
LEDs_SetAllLEDs(LEDMASK_USB_ERROR);
|
||||
USB_HostState = HOST_STATE_WaitForDeviceRemoval;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
if (RNDIS_Host_InitializeDevice(&Ethernet_RNDIS_Interface) != HOST_SENDCONTROL_Successful)
|
||||
{
|
||||
LEDs_SetAllLEDs(LEDMASK_USB_ERROR);
|
||||
USB_HostState = HOST_STATE_WaitForDeviceRemoval;
|
||||
break;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
uint32_t PacketFilter = (REMOTE_NDIS_PACKET_DIRECTED | REMOTE_NDIS_PACKET_BROADCAST);
|
||||
if (RNDIS_Host_SetRNDISProperty(&Ethernet_RNDIS_Interface, OID_GEN_CURRENT_PACKET_FILTER,
|
||||
&PacketFilter, sizeof(PacketFilter)) != HOST_SENDCONTROL_Successful)
|
||||
|
@ -112,7 +112,7 @@ void USBHostMode_USBTask(void)
|
|||
USB_HostState = HOST_STATE_WaitForDeviceRemoval;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
if (RNDIS_Host_QueryRNDISProperty(&Ethernet_RNDIS_Interface, OID_802_3_CURRENT_ADDRESS,
|
||||
&MACAddress, sizeof(MACAddress)) != HOST_SENDCONTROL_Successful)
|
||||
{
|
||||
|
@ -120,16 +120,16 @@ void USBHostMode_USBTask(void)
|
|||
USB_HostState = HOST_STATE_WaitForDeviceRemoval;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
/* Initialize uIP stack */
|
||||
uIPManagement_Init();
|
||||
|
||||
|
||||
LEDs_SetAllLEDs(LEDMASK_USB_READY);
|
||||
USB_HostState = HOST_STATE_Configured;
|
||||
break;
|
||||
case HOST_STATE_Configured:
|
||||
uIPManagement_ManageNetwork();
|
||||
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -176,3 +176,4 @@ void EVENT_USB_Host_DeviceEnumerationFailed(const uint8_t ErrorCode, const uint8
|
|||
{
|
||||
LEDs_SetAllLEDs(LEDMASK_USB_ERROR);
|
||||
}
|
||||
|
||||
|
|
|
@ -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,21 +39,22 @@
|
|||
/* Includes: */
|
||||
#include <LUFA/Drivers/USB/USB.h>
|
||||
#include <LUFA/Drivers/USB/Class/RNDIS.h>
|
||||
|
||||
|
||||
#include "Webserver.h"
|
||||
#include "Lib/uIPManagement.h"
|
||||
|
||||
|
||||
/* External Variables: */
|
||||
extern USB_ClassInfo_RNDIS_Host_t Ethernet_RNDIS_Interface;
|
||||
|
||||
/* Function Prototypes: */
|
||||
void USBHostMode_USBTask(void);
|
||||
|
||||
|
||||
void EVENT_USB_Host_HostError(const uint8_t ErrorCode);
|
||||
void EVENT_USB_Host_DeviceAttached(void);
|
||||
void EVENT_USB_Host_DeviceUnattached(void);
|
||||
void EVENT_USB_Host_DeviceEnumerationFailed(const uint8_t ErrorCode,
|
||||
const uint8_t SubErrorCode);
|
||||
void EVENT_USB_Host_DeviceEnumerationComplete(void);
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -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 @@
|
|||
* Main source file for the Webserver project. This file contains the main tasks of
|
||||
* the project and is responsible for the initial application hardware configuration.
|
||||
*/
|
||||
|
||||
|
||||
#include "Webserver.h"
|
||||
|
||||
/** Main program entry point. This routine configures the hardware required by the application, then
|
||||
|
@ -73,3 +73,4 @@ void SetupHardware(void)
|
|||
LEDs_Init();
|
||||
USB_Init(USB_MODE_UID);
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
|
@ -48,10 +48,10 @@
|
|||
#include <LUFA/Drivers/Board/Dataflash.h>
|
||||
#include <LUFA/Drivers/Peripheral/SPI.h>
|
||||
#include <LUFA/Drivers/USB/USB.h>
|
||||
|
||||
|
||||
#include "USBDeviceMode.h"
|
||||
#include "USBHostMode.h"
|
||||
|
||||
|
||||
/* Macros: */
|
||||
/** LED mask for the library LED driver, to indicate that the USB interface is not ready. */
|
||||
#define LEDMASK_USB_NOTREADY LEDS_LED1
|
||||
|
@ -64,7 +64,7 @@
|
|||
|
||||
/** LED mask for the library LED driver, to indicate that an error has occurred in the USB interface. */
|
||||
#define LEDMASK_USB_ERROR (LEDS_LED1 | LEDS_LED3)
|
||||
|
||||
|
||||
/** LED mask for the library LED driver, to indicate that the USB interface is busy. */
|
||||
#define LEDMASK_USB_BUSY (LEDS_LED1 | LEDS_LED3 | LEDS_LED4)
|
||||
|
||||
|
@ -76,5 +76,6 @@
|
|||
|
||||
/* Function Prototypes: */
|
||||
void SetupHardware(void);
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -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 uIP Powered Webserver Project
|
||||
*
|
||||
* \section SSec_Compat Project Compatibility:
|
||||
|
@ -26,7 +26,7 @@
|
|||
* <td>Communications Device Class (CDC) \n
|
||||
* Mass Storage Device</td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <tr>
|
||||
* <td><b>USB Subclass:</b></td>
|
||||
* <td>Remote NDIS (Microsoft Proprietary CDC Class Networking Standard) \n
|
||||
* Bulk-Only Transport</td>
|
||||
|
@ -45,7 +45,7 @@
|
|||
* </tr>
|
||||
* </table>
|
||||
*
|
||||
* \section SSec_Description Project Description:
|
||||
* \section SSec_Description Project Description:
|
||||
*
|
||||
* Simple HTTP webserver project. This project combines the LUFA library with the uIP TCP/IP full network stack and FatFS
|
||||
* library to create a RNDIS host capable of serving out HTTP web pages to multiple hosts simultaneously. This project
|
||||
|
@ -111,3 +111,4 @@
|
|||
* </tr>
|
||||
* </table>
|
||||
*/
|
||||
|
||||
|
|
|
@ -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
|
||||
|
@ -131,9 +131,9 @@ LUFA_OPTS += -D UIP_CONF_TCP=1
|
|||
LUFA_OPTS += -D UIP_CONF_UDP_CONNS=1
|
||||
LUFA_OPTS += -D UIP_CONF_MAX_CONNECTIONS=3
|
||||
LUFA_OPTS += -D UIP_CONF_MAX_LISTENPORTS=5
|
||||
LUFA_OPTS += -D UIP_URGDATA=0
|
||||
LUFA_OPTS += -D UIP_URGDATA=0
|
||||
LUFA_OPTS += -D UIP_CONF_BUFFER_SIZE=1514
|
||||
LUFA_OPTS += -D UIP_ARCH_CHKSUM=0
|
||||
LUFA_OPTS += -D UIP_ARCH_CHKSUM=0
|
||||
LUFA_OPTS += -D UIP_CONF_LL_802154=0
|
||||
LUFA_OPTS += -D UIP_CONF_LL_80211=0
|
||||
LUFA_OPTS += -D UIP_CONF_ROUTER=0
|
||||
|
@ -170,7 +170,7 @@ SRC = $(TARGET).c \
|
|||
|
||||
|
||||
# List C++ source files here. (C dependencies are automatically generated.)
|
||||
CPPSRC =
|
||||
CPPSRC =
|
||||
|
||||
|
||||
# List Assembler source files here.
|
||||
|
@ -183,7 +183,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
|
||||
|
@ -297,7 +297,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
|
||||
|
||||
|
@ -310,7 +310,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)
|
||||
|
||||
|
@ -322,7 +322,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)
|
||||
|
||||
|
@ -334,7 +334,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 =
|
||||
|
||||
|
||||
|
||||
|
@ -357,7 +357,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))
|
||||
|
@ -391,7 +391,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
|
||||
|
||||
|
@ -425,7 +425,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
|
||||
|
||||
|
@ -454,7 +454,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:
|
||||
|
@ -473,10 +473,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.
|
||||
|
@ -541,11 +541,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)
|
||||
|
||||
|
@ -572,9 +572,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)
|
||||
|
@ -672,14 +672,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.
|
||||
|
@ -701,7 +701,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.
|
||||
|
@ -745,3 +745,4 @@ $(shell mkdir $(OBJDIR) 2>/dev/null)
|
|||
build elf hex eep lss sym coff extcoff doxygen clean \
|
||||
clean_list clean_doxygen program dfu flip flip-ee dfu-ee \
|
||||
debug gdb-config
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue