/*
LUFA Library
- Copyright (C) Dean Camera, 2010.
+ Copyright (C) Dean Camera, 2015.
dean [at] fourwalledcubicle [dot] com
www.lufa-lib.org
*/
/*
- Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com)
+ Copyright 2015 Dean Camera (dean [at] fourwalledcubicle [dot] com)
Permission to use, copy, modify, distribute, and sell this
software and its documentation for any purpose is hereby granted
advertising or publicity pertaining to distribution of the
software without specific, written prior permission.
- The author disclaim all warranties with regard to this
+ The author disclaims all warranties with regard to this
software, including all implied warranties of merchantability
and fitness. In no event shall the author be liable for any
special, indirect or consequential damages or any damages
*
* \param[in] Buffer Application buffer to check
*
- * \return Boolean true if the buffer contains a packet from the host, false otherwise
+ * \return Boolean \c true if the buffer contains a packet from the host, \c false otherwise
*/
#define TCP_APP_HAS_RECEIVED_PACKET(Buffer) (Buffer->Ready && (Buffer->Direction == TCP_PACKETDIR_IN))
*
* \param[in] Buffer Application buffer to check
*
- * \return Boolean true if the buffer has been captured by the application for device-to-host transmissions, false otherwise
+ * \return Boolean \c true if the buffer has been captured by the application for device-to-host transmissions, \c false otherwise
*/
#define TCP_APP_HAVE_CAPTURED_BUFFER(Buffer) (!(Buffer->Ready) && Buffer->InUse && (Buffer->Direction == TCP_PACKETDIR_OUT))
*
* \param[in] Buffer Application buffer to check
*
- * \return Boolean true if the buffer may be captured by the application for device-to-host transmissions, false otherwise
+ * \return Boolean \c true if the buffer may be captured by the application for device-to-host transmissions, \c false otherwise
*/
#define TCP_APP_CAN_CAPTURE_BUFFER(Buffer) Buffer->InUse
*
* \param[in] Buffer Application buffer to lock
*/
- #define TCP_APP_CAPTURE_BUFFER(Buffer) MACROS{ Buffer->Direction = TCP_PACKETDIR_OUT; Buffer->InUse = true; }MACROE
+ #define TCP_APP_CAPTURE_BUFFER(Buffer) do { Buffer->Direction = TCP_PACKETDIR_OUT; Buffer->InUse = true; } while (0)
/** Application macro: Releases a captured application buffer, allowing for host-to-device packets to be received.
*
* \param[in] Buffer Application buffer to release
*/
- #define TCP_APP_RELEASE_BUFFER(Buffer) MACROS{ Buffer->InUse = false; }MACROE
+ #define TCP_APP_RELEASE_BUFFER(Buffer) do { Buffer->InUse = false; } while (0)
/** Application macro: Sends the contents of the given application buffer to the host.
*
* \param[in] Buffer Application buffer to send
* \param[in] Len Length of data contained in the buffer
*/
- #define TCP_APP_SEND_BUFFER(Buffer, Len) MACROS{ Buffer->Direction = TCP_PACKETDIR_OUT; Buffer->Length = Len; Buffer->Ready = true; }MACROE
+ #define TCP_APP_SEND_BUFFER(Buffer, Len) do { Buffer->Direction = TCP_PACKETDIR_OUT; Buffer->Length = Len; Buffer->Ready = true; } while (0)
/** Application macro: Clears the application buffer, ready for a packet to be written to it.
*
* \param[in] Buffer Application buffer to clear
*/
- #define TCP_APP_CLEAR_BUFFER(Buffer) MACROS{ Buffer->Ready = false; Buffer->Length = 0; }MACROE
+ #define TCP_APP_CLEAR_BUFFER(Buffer) do { Buffer->Ready = false; Buffer->Length = 0; } while (0)
/** Application macro: Closes an open connection to a host.
*
* \param[in] Connection Open TCP connection to close
*/
- #define TCP_APP_CLOSECONNECTION(Connection) MACROS{ Connection->State = TCP_Connection_Closing; }MACROE
+ #define TCP_APP_CLOSECONNECTION(Connection) do { Connection->State = TCP_Connection_Closing; } while (0)
/* Enums: */
/** Enum for possible TCP port states. */
uint16_t RemotePort; /**< Connection port number on the host */
IP_Address_t RemoteAddress; /**< Connection protocol IP address of the host */
TCP_ConnectionInfo_t Info; /**< Connection information, including application buffer */
- uint8_t State; /**< Current connection state, a value from the TCP_ConnectionStates_t enum */
+ uint8_t State; /**< Current connection state, a value from the \ref TCP_ConnectionStates_t enum */
} TCP_ConnectionState_t;
/** Type define for a TCP port state. */
typedef struct
{
uint16_t Port; /**< TCP port number on the device */
- uint8_t State; /**< Current port state, a value from the TCP_PortStates_t enum */
+ uint8_t State; /**< Current port state, a value from the \ref TCP_PortStates_t enum */
void (*ApplicationHandler) (TCP_ConnectionState_t* ConnectionState,
TCP_ConnectionBuffer_t* Buffer); /**< Port application handler */
} TCP_PortState_t;
uint32_t SequenceNumber; /**< Data sequence number of the packet */
uint32_t AcknowledgmentNumber; /**< Data acknowledgment number of the packet */
- unsigned char Reserved : 4; /**< Reserved, must be all 0 */
- unsigned char DataOffset : 4; /**< Offset of the data from the start of the header, in 4 byte chunks */
+ unsigned Reserved : 4; /**< Reserved, must be all 0 */
+ unsigned DataOffset : 4; /**< Offset of the data from the start of the header, in 4 byte chunks */
uint8_t Flags; /**< TCP packet flags */
uint16_t WindowSize; /**< Current data window size (bytes remaining in reception buffer) */
} TCP_Header_t;
/* Function Prototypes: */
- void TCP_TCPTask(USB_ClassInfo_RNDIS_Device_t* const RNDISInterfaceInfo);
+ void TCP_TCPTask(USB_ClassInfo_RNDIS_Device_t* const RNDISInterfaceInfo,
+ Ethernet_Frame_Info_t* const FrameOUT);
void TCP_Init(void);
bool TCP_SetPortState(const uint16_t Port,
const uint8_t State,
void (*Handler)(TCP_ConnectionState_t*, TCP_ConnectionBuffer_t*));
uint8_t TCP_GetPortState(const uint16_t Port);
bool TCP_SetConnectionState(const uint16_t Port,
- const IP_Address_t RemoteAddress,
+ const IP_Address_t* RemoteAddress,
const uint16_t RemotePort,
const uint8_t State);
uint8_t TCP_GetConnectionState(const uint16_t Port,
- const IP_Address_t RemoteAddress,
+ const IP_Address_t* RemoteAddress,
const uint16_t RemotePort);
TCP_ConnectionInfo_t* TCP_GetConnectionInfo(const uint16_t Port,
- const IP_Address_t RemoteAddress,
+ const IP_Address_t* RemoteAddress,
const uint16_t RemotePort);
int16_t TCP_ProcessTCPPacket(void* IPHeaderInStart,
void* TCPHeaderInStart,
#if defined(INCLUDE_FROM_TCP_C)
static uint16_t TCP_Checksum16(void* TCPHeaderOutStart,
- const IP_Address_t SourceAddress,
- const IP_Address_t DestinationAddress,
+ const IP_Address_t* SourceAddress,
+ const IP_Address_t* DestinationAddress,
uint16_t TCPOutSize);
#endif