📄 sps.h
字号:
* FUNCTION: Tcp_SetReceiveCallBack
* DESCRIPTION:
* Sets the Receive call back function for a tcpControlBlock
*****************************************************************************/
void Tcp_SetReceiveCallBack(struct TCP_CONTROL_BLOCK * tcpControlBlock, TCP_RECEIVE_CALLBACK callback);
/*****************************************************************************
* FUNCTION: Tcp_SetSentCallBack
* DESCRIPTION:
* Sets the Sent call back function for a tcpControlBlock
*****************************************************************************/
void Tcp_SetSentCallBack(struct TCP_CONTROL_BLOCK * tcpControlBlock, TCP_SENT_CALLBACK callback);
/*****************************************************************************
* FUNCTION: Tcp_SetAcceptCallBack
* DESCRIPTION:
* Sets the Accept call back function for a tcpControlBlock
*****************************************************************************/
void Tcp_SetAcceptCallBack(struct TCP_CONTROL_BLOCK * tcpControlBlock, TCP_ACCEPT_CALLBACK callback);
/*****************************************************************************
* FUNCTION: Tcp_Bind
* DESCRIPTION:
* Binds a tcpControlBlock to an ipAddress and port
*****************************************************************************/
err_t Tcp_Bind(struct TCP_CONTROL_BLOCK * tcpControlBlock, PIP_ADDRESS ipAddress, u16_t port);
/*****************************************************************************
* FUNCTION: Tcp_Connect
* DESCRIPTION:
* Initiates a connection request to an ipAddress and port. The callback
* will be called on completion.
*****************************************************************************/
err_t Tcp_Connect(struct TCP_CONTROL_BLOCK * tcpControlBlock, PIP_ADDRESS ipAddress, u16_t port,
TCP_CONNECTED_CALLBACK callback);
/*****************************************************************************
* FUNCTION: Tcp_Listen
* DESCRIPTION:
* Puts a tcpControlBlock into the listening state. Should have previously
* called Tcp_Bind
*****************************************************************************/
void Tcp_Listen(struct TCP_CONTROL_BLOCK * tcpControlBlock);
/*****************************************************************************
* FUNCTION: Tcp_AcknowledgeReceivedData
* DESCRIPTION:
* This function is called by the application to acknowledge that the data
* was received. This increases the receiver window size.
*****************************************************************************/
void Tcp_AcknowledgeReceivedData(struct TCP_CONTROL_BLOCK * tcpControlBlock, u32_t len);
/*****************************************************************************
* FUNCTION: Tcp_Close
* DESCRIPTION:
* Closes a connected tcpControlBlock
*****************************************************************************/
err_t Tcp_Close(struct TCP_CONTROL_BLOCK * tcpControlBlock);
/*****************************************************************************
* FUNCTION: Tcp_GetMaximumSegmentSize
* DESCRIPTION:
* Gets the maximum segment size. This is useful information because the
* application can use this to allocate data buffers that are a multiple
* of this maximum segment size, to allow for more efficient transfers.
*****************************************************************************/
u16_t Tcp_GetMaximumSegmentSize(struct TCP_CONTROL_BLOCK * tcpControlBlock);
/*****************************************************************************
* FUNCTION: Tcp_AllocateDataBuffers
* DESCRIPTION:
* Allocates Packet buffers that the application can use to fill in and then
* queue them with Tcp_QueueData.
*****************************************************************************/
struct PACKET_BUFFER * Tcp_AllocateDataBuffers(struct TCP_CONTROL_BLOCK * tcpControlBlock, u32_t size);
/*****************************************************************************
* FUNCTION: Tcp_QueueData
* DESCRIPTION:
* Queues data to be sent on this tcp connection. Any packet buffers that
* can not be queue will be returned.
*****************************************************************************/
struct PACKET_BUFFER * Tcp_QueueData(struct TCP_CONTROL_BLOCK * tcpControlBlock,struct PACKET_BUFFER * packet);
/*****************************************************************************
* FUNCTION: Tcp_SendQueuedData
* DESCRIPTION:
* Sends the data that was previously queued with Tcp_QueueData
*****************************************************************************/
err_t Tcp_SendQueuedData(struct TCP_CONTROL_BLOCK * tcpControlBlock);
/*****************************************************************************
* FUNCTION: Udp_GetFlags
* DESCRIPTION:
* Gets the Flags of this udpControlBlock.
*****************************************************************************/
u16_t Udp_GetFlags(struct UDP_CONTROL_BLOCK * udpControlBlock);
#define UDP_FLAGS_UDPLITE (0x02)
#define UDP_FLAGS_CONNECTED (0x04)
/*****************************************************************************
* FUNCTION: Udp_SetFlags
* DESCRIPTION:
* Sets the flags by bit wise ORing with the current flags
*****************************************************************************/
void Udp_SetFlags(struct UDP_CONTROL_BLOCK * udpControlBlock, u16_t flags);
/*****************************************************************************
* FUNCTION: Udp_GetRemoteAddress
* DESCRIPTION:
* Gets the remote address for this udpControlBlock.
*****************************************************************************/
PIP_ADDRESS Udp_GetRemoteAddress(struct UDP_CONTROL_BLOCK * udpControlBlock);
/*****************************************************************************
* FUNCTION: Udp_GetRemotePort
* DESCRIPTION:
* Gets the remote port setting for this udpControlBlock.
*****************************************************************************/
u16_t Udp_GetRemotePort(struct UDP_CONTROL_BLOCK * udpControlBlock);
/*****************************************************************************
* FUNCTION: Udp_CreateControlBlock
* DESCRIPTION: Allocates and initializes a UDP_CONTROL_BLOCK
*****************************************************************************/
struct UDP_CONTROL_BLOCK * Udp_CreateControlBlock(void);
/*****************************************************************************
* FUNCTION: Udp_FreeControlBlock
* DESCRIPTION: Deallocates a UDP_CONTROL_BLOCK,
* the UDP_CONTROL_BLOCK should not be binded, or connected when this is
* called.
*****************************************************************************/
void Udp_FreeControlBlock(struct UDP_CONTROL_BLOCK * udpControlBlock);
/*****************************************************************************
* FUNCTION: Udp_Bind
* DESCRIPTION:
* Binds the UDP_CONTROL_BLOCK to a local IP address and port
*****************************************************************************/
err_t Udp_Bind(struct UDP_CONTROL_BLOCK * udpControlBlock,
PIP_ADDRESS localAddress,u16_t localPort);
/*****************************************************************************
* FUNCTION: Udp_UnBind
* DESCRIPTION:
* Unbinds the UDP_CONTROL_BLOCK.
*****************************************************************************/
void Udp_UnBind(struct UDP_CONTROL_BLOCK * udpControlBlock);
/*****************************************************************************
* FUNCTION: Udp_SetReceiverCallBack
* DESCRIPTION: Sets the receiver callback function and parameter
*****************************************************************************/
void Udp_SetReceiverCallBack(
struct UDP_CONTROL_BLOCK * udpControlBlock,
UDP_RECEIVE_FUNCTION receiverFunction,void * receiverParam);
/*****************************************************************************
* FUNCTION: Udp_Connect
* DESCRIPTION: Associates a remote address and port with a UDP_CONTROL_BLOCK,
* While in connected state, Udp_Send will send all packets to the
* associated remote address and port. Also only packets arriving from
* the remote address and port will be passed to the application.
*****************************************************************************/
err_t Udp_Connect(struct UDP_CONTROL_BLOCK * udpControlBlock,
PIP_ADDRESS remoteAddress,u16_t remotePort);
/*****************************************************************************
* FUNCTION: Udp_Disconnect
* DESCRIPTION: De-associates a UDP_CONTROL_BLOCK from a remote address and port
*****************************************************************************/
void Udp_Disconnect(struct UDP_CONTROL_BLOCK * udpControlBlock);
/*****************************************************************************
* FUNCTION: Udp_AllocatePacket
* DESCRIPTION:
* Allocates a packet buffer list
* PARAMETERS:
* destinationAddress, This is the destination address where the packet
* will be send to. This information is necessary
* to make sure the packet buffer list has enough
* header space in each packet buffer, and to make sure
* no packet buffer will exceed the MTU of the interface
* that the packet will be sent on.
* size, This is the size of payload space requested.
*****************************************************************************/
struct PACKET_BUFFER * Udp_AllocatePacket(PIP_ADDRESS destinationAddress,u32_t size);
/*****************************************************************************
* FUNCTION: Udp_SendTo
* DESCRIPTION:
* Sends a packet to a specified destination address and port
*****************************************************************************/
void Udp_SendTo(
struct UDP_CONTROL_BLOCK * udpControlBlock,struct PACKET_BUFFER * packet,
PIP_ADDRESS destinationAddress, u16_t destinationPort);
/*****************************************************************************
* FUNCTION: Udp_Send
* DESCRIPTION:
* Sends a packet to a the destination specified in a previous call to
* Udp_Connect
*****************************************************************************/
void Udp_Send(
struct UDP_CONTROL_BLOCK * udpControlBlock,struct PACKET_BUFFER * packet);
/*****************************************************************************
* FUNCTION: Sps_Initialize
* PURPOSE: Initializes network stack protocols and utilities, according
* to what was enabled in smsc_environment.h
*****************************************************************************/
void Sps_Initialize(void);
/*****************************************************************************
* FUNCTION: Sps_StartDhcp
* DESCRIPTION:
* Initializes and attaches a DHCP_DATA structure to a network interface,
* Then immediately tries to obtain an ip address.
* returns 0 on failure, 1 on success
*****************************************************************************/
int Sps_StartDhcp(const char * interfaceName);
/*****************************************************************************
* FUNCTION: Sps_DhcpRelease(const char * interfaceName)
* DESCRIPTION:
* Releases a DHCP lease, usually called before Sps_DhcpStop
* Returns 0 on failure, 1 on success.
*****************************************************************************/
int Sps_DhcpRelease(const char * interfaceName);
/*****************************************************************************
* FUNCTION: Sps_DhcpInform(const char * interfaceName)
* DESCRIPTION:
* Informs the DHCP server of our manual assigned IP address
* Returns 0 on failure, 1 on success.
*****************************************************************************/
int Sps_DhcpInform(const char * interfaceName);
/*****************************************************************************
* FUNCTION: Sps_DhcpRenew(const char * interfaceName)
* DESCRIPTION:
* Begin an early lease renewal. This is not needed normally
* Returns 0 on failure, 1 on success.
*****************************************************************************/
int Sps_DhcpRenew(const char * interfaceName);
/*****************************************************************************
* FUNCTION: Sps_DhcpStop(const char * interfaceName)
* DESCRIPTION:
* Stops a DHCP client
* Returns 0 on failure, 1 on success.
*****************************************************************************/
int Sps_DhcpStop(const char * interfaceName);
/*****************************************************************************
* FUNCTION: Sps_SetIpv4Addresses
* DESCRIPTION:
* Sets the IPV4 addresses for the named interface.
* This function should not be used if DHCP will be used instead.
* returns 0 on failure, 1 on success
*****************************************************************************/
int Sps_SetIpv4Addresses(
const char * interfaceName,
IPV4_ADDRESS ipAddress,
IPV4_ADDRESS netMask,
IPV4_ADDRESS gateway);
/*****************************************************************************
* FUNCTION: Sps_GetIpv4Addresses
* DESCRIPTION:
* Gets the IPV4 addresses for the named interface.
* Returns 0 on failure, 1 on success.
*****************************************************************************/
int Sps_GetIpv4Addresses(
const char * interfaceName,
PIPV4_ADDRESS ipAddress,
PIPV4_ADDRESS netMask,
PIPV4_ADDRESS gateway);
/*****************************************************************************
* FUNCTION: Sps_EnableInterface
* DESCRIPTION:
* Enables the named interface. After initialization interfaces are disabled.
* This function should not be used if DHCP is used.
* returns 0 on failure, 1 on success
*****************************************************************************/
int Sps_EnableInterface(const char * interfaceName);
/*****************************************************************************
* FUNCTION: Sps_DisableInterface
* DESCRIPTION:
* Disables the named interface.
* This function should not be used if DHCP is used.
* returns 0 on failure, 1 on success
*****************************************************************************/
int Sps_DisableInterface(const char * interfaceName);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -