⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sps.h

📁 由smsc公司改进的lwip2.1.1基于嵌入式系统的TCP/ip协议栈
💻 H
📖 第 1 页 / 共 5 页
字号:
	#endif

	#ifndef TCP_SEND_SPACE
	#define TCP_SEND_SPACE						(TCP_WINDOW_SIZE)	/* TCP sender buffer space (bytes) */
	#endif

	#ifndef TCP_SYNMAXRTX
	#define TCP_SYNMAXRTX						(4)			/* Maximum number of retransmissions of SYN segments */
	#endif

	#ifndef TCP_MAXRTX
	#define TCP_MAXRTX							(12)		/* Maximum number of retransmissions of data segments */
	#endif

	#ifndef TCP_CONTROL_BLOCK_COUNT
	#define TCP_CONTROL_BLOCK_COUNT				(5)
	#endif

	#ifndef TCP_SEGMENT_COUNT
	#define TCP_SEGMENT_COUNT					(100)
	#endif

	#ifndef TCP_LOCAL_PORT_RANGE_START
	#define TCP_LOCAL_PORT_RANGE_START 			(0x1000)
	#endif

	#ifndef TCP_LOCAL_PORT_RANGE_END
	#define TCP_LOCAL_PORT_RANGE_END			(0x7FFF)
	#endif


/* TCP sender buffer space (pbufs). This must be at least = 2 *
   TCP_SND_BUF/TCP_MSS for things to work. */
	/*#define TCP_SND_QUEUELEN					(4 * TCP_SND_BUF/TCP_MSS)*/

/* TCP writable space (bytes). This must be less than or equal
   to TCP_SND_BUF. It is the amount of space which must be
   available in the tcp snd_buf for select to return writable */
#ifndef TCP_SENDABLE_THRESHOLD
#define TCP_SENDABLE_THRESHOLD            (TCP_SEND_SPACE/2)
#endif


#ifndef DHCP_ENABLED
#define DHCP_ENABLED			(1)
#endif

	#ifndef DHCP_DOES_ARP_CHECK
	#define DHCP_DOES_ARP_CHECK		(1)
	#endif

	#ifndef DHCP_INTERFACE_COUNT
	#define DHCP_INTERFACE_COUNT	(1)
	#endif


/* SMSC_TRACE_ENABLED is used to enable messages intended for informational
   purposes only */
#ifndef SMSC_TRACE_ENABLED
#define SMSC_TRACE_ENABLED		1
#endif


/* SMSC_NOTICE_ENABLED is used to enable messages intended to alert the user
   about anticipated error conditions that are properly handled.
   (an example is packet drops) */
#ifndef SMSC_NOTICE_ENABLED
#define SMSC_NOTICE_ENABLED		1
#endif


/* SMSC_WARNING_ENABLED is used to enable messages intended to alert the user
   about unknown or unexpected conditions, which may cause errors that may 
   not be handled properly. 
   (an examples is unknown or unexpected values, common in the 
       'default' section of a switch statement)*/
#ifndef SMSC_WARNING_ENABLED
#define SMSC_WARNING_ENABLED	1
#endif


/* SMSC_ERROR_ENABLED is used to enable messages that alert the user that
   an unrecoverable error has been detected.
   (this includes violated assumptions encoded with SMSC_ASSERT) */
#ifndef SMSC_ERROR_ENABLED
#define SMSC_ERROR_ENABLED		1
#endif


/* Enable individual types of TRACE, and NOTICE messages*/
#ifndef PACKET_MANAGER_DEBUG
#define PACKET_MANAGER_DEBUG	DEBUG_WARNING_LEVEL
#endif

#ifndef ETHERNET_DEBUG
#define ETHERNET_DEBUG          DEBUG_WARNING_LEVEL
#endif

#ifndef IPV4_DEBUG
#define IPV4_DEBUG				DEBUG_WARNING_LEVEL
#endif

#ifndef IPV4_FILTER_DEBUG
#define IPV4_FILTER_DEBUG		DEBUG_WARNING_LEVEL
#endif

#ifndef ICMPV4_DEBUG
#define ICMPV4_DEBUG			DEBUG_WARNING_LEVEL
#endif

#ifndef LOOP_BACK_DEBUG
#define LOOP_BACK_DEBUG			DEBUG_WARNING_LEVEL
#endif

#ifndef SMSC911X_DEBUG
#define SMSC911X_DEBUG          DEBUG_WARNING_LEVEL
#endif

#ifndef UDP_DEBUG
#define UDP_DEBUG				DEBUG_WARNING_LEVEL
#endif

#ifndef TCP_DEBUG
#define TCP_DEBUG				DEBUG_WARNING_LEVEL
#endif

#ifndef DHCP_DEBUG
#define DHCP_DEBUG				DEBUG_WARNING_LEVEL
#endif


#define IP_ADDRESS IPV4_ADDRESS
#define PIP_ADDRESS PIPV4_ADDRESS


#define IP_ADDRESS_STRING_SIZE	IPV4_ADDRESS_STRING_SIZE


#define IP_ADDRESS_ANY											IPV4_ADDRESS_ANY
#define IP_ADDRESS_TO_STRING(stringDataSpace,pIpAddress)		IPV4_ADDRESS_TO_STRING(stringDataSpace,*(pIpAddress))
#define IP_ADDRESS_IS_ANY(pIpAddress)							IPV4_ADDRESS_IS_ANY(pIpAddress)
#define IP_ADDRESS_IS_BROADCAST(pIpAddress,pNetworkInterface)	IPV4_ADDRESS_IS_BROADCAST(*((PIPV4_ADDRESS)(pIpAddress)),pNetworkInterface)
#define IP_ADDRESS_COMPARE(pIpAddress1,pIpAddress2)				IPV4_ADDRESS_COMPARE(*(pIpAddress1),*(pIpAddress2))
#define IP_ADDRESS_NETWORK_COMPARE								IPV4_ADDRESS_NETWORK_COMPARE
#define IP_ADDRESS_IS_MULTICAST(pIpAddress)						IPV4_ADDRESS_IS_MULTICAST(*((PIPV4_ADDRESS)(pIpAddress)))
#define IP_ADDRESS_COPY(pIpAddressDestination,pIpAddressSource)	\
	(*(pIpAddressDestination))=(*(pIpAddressSource))


#define IP_ADDRESS_GET_TYPE(pIpAddress)	IP_ADDRESS_TYPE_IPV4
#define IP_ADDRESS_IS_IPV4(pIpAddress)	(1)
#define IP_ADDRESS_IS_IPV6(pIpAddress)	(0)
#define IP_ADDRESS_SET_IPV4(pIpAddress,byte1,byte2,byte3,byte4)	\
	IPV4_ADDRESS_SET(*(pIpAddress),byte1,byte2,byte3,byte4)
#define IP_ADDRESS_COPY_FROM_IPV4_ADDRESS(pIpAddress,pIpv4Address)	\
	(*(pIpAddress))=(*(pIpv4Address))
#define IPV4_ADDRESS_COPY_FROM_IP_ADDRESS(pIpv4Address,pIpAddress)	\
	(*(pIpv4Address))=(*(pIpAddress))


struct NETWORK_INTERFACE;


struct TASK;


struct PACKET_QUEUE;


struct PACKET_BUFFER;


typedef s8_t err_t;

/*****************************************************************************
* The following define some error codes used in the SMSC network stack.
*****************************************************************************/
#define ERR_OK    (0)      /* No error, everything OK. */
#define ERR_MEM  (-1)      /* Out of memory error.     */
#define ERR_BUF  (-2)      /* Buffer error.            */
#define ERR_ABRT (-3)      /* Connection aborted.      */
#define ERR_RST  (-4)      /* Connection reset.        */
#define ERR_CLSD (-5)      /* Connection closed.       */
#define ERR_CONN (-6)      /* Not connected.           */
#define ERR_VAL  (-7)      /* Illegal value.           */
#define ERR_ARG  (-8)      /* Illegal argument.        */
#define ERR_RTE  (-9)      /* Routing problem.         */
#define ERR_USE  (-10)     /* Address in use.          */
#define ERR_IF   (-11)     /* Low-level netif error    */
#define ERR_ISCONN (-12)   /* Already connected.       */


typedef u32_t IPV4_ADDRESS, * PIPV4_ADDRESS;


/*****************************************************************************
* FUNCTION TYPE: TASK_FUNCTION
* PURPOSE: This is the type of function called by the task manager
*****************************************************************************/
typedef void (*TASK_FUNCTION)(void * param);


struct TCP_CONTROL_BLOCK;


struct UDP_CONTROL_BLOCK;


typedef void (*ICMPV4_ECHO_REPLY_CALLBACK)(void * param,struct PACKET_BUFFER * packetBuffer);


struct PACKET_BUFFER * Icmpv4_AllocatePacket(
	PIPV4_ADDRESS destinationAddress,u32_t size);


err_t Icmpv4_SendEchoRequest(
	IPV4_ADDRESS destination,struct PACKET_BUFFER * packet,
	ICMPV4_ECHO_REPLY_CALLBACK callback,void * callBackParam,
	u8_t timeOut);/* timeOut is in units of seconds */


/*****************************************************************************
* FUNCTION TYPE: UDP_RECEIVE_FUNCTION
* DESCRIPTION:
*    This is the function template for passing received UDP packets to
*    the application.
* PARAMETERS:
*    param, this is an application specific parameter provided in the call
*           to Udp_SetReceiverCallBack
*    udpControlBlock, This is the control block that received the packet.
*    packetBuffer, this is the received packet buffer list.
*    sourceAddress, this is the address the packet came from.
*    sourcePort, this is the port the packet came from.
*****************************************************************************/
typedef void (*UDP_RECEIVE_FUNCTION)(
	void * param, struct UDP_CONTROL_BLOCK * udpControlBlock,
	struct PACKET_BUFFER * packetBuffer,
	PIP_ADDRESS sourceAddress,
	u16_t sourcePort);


/* Function to be called when more send buffer space is available. */
typedef err_t (*TCP_SENT_CALLBACK)(void *arg, struct TCP_CONTROL_BLOCK * tcpControlBlock, u16_t space);


/* Function to be called when (in-sequence) data has arrived. */
typedef err_t (*TCP_RECEIVE_CALLBACK)(void *arg, struct TCP_CONTROL_BLOCK * tcpControlBlock, struct PACKET_BUFFER * packet, err_t err);


/* Function to be called when a connection has been set up. */
typedef err_t (*TCP_CONNECTED_CALLBACK)(void *arg, struct TCP_CONTROL_BLOCK * tcpControlBlock, err_t err);


/* Function to call when a listener has been connected. */
typedef err_t (*TCP_ACCEPT_CALLBACK)(void *arg, struct TCP_CONTROL_BLOCK * newControlBlock, err_t err);


/* Function to be called whenever a fatal error occurs. */
typedef void (*TCP_ERROR_CALLBACK)(void *arg, err_t err);


/*****************************************************************************
* FUNCTION: Tcp_GetRemoteAddress
* DESCRIPTION:
*    Gets the remote address from this tcpControlBlock
*****************************************************************************/
PIP_ADDRESS Tcp_GetRemoteAddress(struct TCP_CONTROL_BLOCK * tcpControlBlock);


/*****************************************************************************
* FUNCTION: Tcp_GetRemotePort
* DESCRIPTION:
*    Gets the remote port from this tcpControlBlock
*****************************************************************************/
u16_t Tcp_GetRemotePort(struct TCP_CONTROL_BLOCK * tcpControlBlock);


/*****************************************************************************
* FUNCTION: Tcp_GetAvailableSendSpace
* DESCRIPTION:
*    Gets the available send space
*****************************************************************************/
u16_t Tcp_GetAvailableSendSpace(struct TCP_CONTROL_BLOCK * tcpControlBlock);


/*****************************************************************************
* FUNCTION: Tcp_NewControlBlock
* DESCRIPTION:
*    Allocates a new TCP control block
*****************************************************************************/
struct TCP_CONTROL_BLOCK * Tcp_NewControlBlock(void);


/*****************************************************************************
* FUNCTION: Tcp_AllocateControlBlock
* DESCRIPTION:
*    Allocates a new TCP control block and assigns a priority to it.
*****************************************************************************/
struct TCP_CONTROL_BLOCK * Tcp_AllocateControlBlock(u8_t priority);


/*****************************************************************************
* FUNCTION: Tcp_FreeControlBlock
* DESCRIPTION:
*    Frees a TCP control block
*****************************************************************************/
void Tcp_FreeControlBlock(struct TCP_CONTROL_BLOCK * tcpControlBlock);


/*****************************************************************************
* FUNCTION: Tcp_SetCallBackArgument
* DESCRIPTION:
*    Sets the call back argument for a tcpControlBlock
*****************************************************************************/
void Tcp_SetCallBackArgument(struct TCP_CONTROL_BLOCK * tcpControlBlock, void * argument);


/*****************************************************************************
* FUNCTION: Tcp_GetCallBackArgument
* DESCRIPTION:
*    Gets the call back argument from a tcpControlBlock
*****************************************************************************/
void * Tcp_GetCallBackArgument(struct TCP_CONTROL_BLOCK * tcpControlBlock);


/*****************************************************************************
* FUNCTION: Tcp_SetErrorCallBack
* DESCRIPTION:
*    Sets the error call back function for a tcpControlBlock
*****************************************************************************/
void Tcp_SetErrorCallBack(struct TCP_CONTROL_BLOCK * tcpControlBlock, TCP_ERROR_CALLBACK callback);


/*****************************************************************************

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -