//********************************************************************* //-------------------- UDP Configuration -------------------- //********************************************************************* //When defined, the code will be compiled for optimal speed. If not defined, code is defined for smallest size. #define UDP_SPEED_OPTIMIZE
#include "net\ip.h"
#include "net\mac.h"
|
|
|
|
|
|
|
|
Returns the maximum size the UDP data is allowed to be. This value should never be execeed when writting data to the UDP transmit buffer before calling UDPFlush(). For slip: = MAC_TX_BUFFER_SIZE - sizeof(IP_HEADER) - sizeof(UDP_HEADER) = MAC_TX_BUFFER_SIZE - 20 - 8 = MAC_TX_BUFFER_SIZE - 28 For RTL MAC = MAC_TX_BUFFER_SIZE - SIZEOF_MAC_HEADER - sizeof(IP_HEADER) - sizeof(UDP_HEADER) = MAC_TX_BUFFER_SIZE - 14 - 20 - 8 = MAC_TX_BUFFER_SIZE - 42 |
|
|
|
|
|
Sets the receive buffer access point to given offset in UDP Data. For example, if UDP data is a HTTP message, an offset of 0 will set access to first byte of HTTP message (UDP data). Layers that use UDP services (HTTP) should call this macro to set the access pointer for the current buffer.
|
|
|
UDP Packet header |
|
|
Handle to a UDP socket
|
|
|
UDP Socket - is 22 bytes long |
|
|
Given socket is marked as available for future new communcations. This function does not affect previous active UDP socket designation.
|
|
|
This function discards an active UDP socket content.
|
|
|
This function transmit all data from an active UDP socket.
|
|
|
Get a byte of data. Note: This function fetches data from the currently active UDP socket. The active UDP socket is set by the UDPIsGetReady() call.
|
|
||||||||||||
|
Read the requested number of bytes from the active UDP socket into the given buffer. Note: This function fetches data from an active UDP socket as set by UDPIsGetReady() call.
|
|
|
Get's the MAC and IP address of the currently active UDP socket. This data is assigned the MAC and IP address of the remote node after a UDP message has been received. So, the MAC and IP address returned by this function will only be valid if a UDP message has already been received on this socket! The active socket is set by the UDPIsGetReady() call.
|
|
|
Initializes internal variables.
|
|
|
Check if given socket contains any data that is ready to be read, and that the given socket is valid (not equal to INVALID_UDP_SOCKET for example). It also sets the given socket as the active UDP socket.
Side Effects: Given socket is set as the active UDP Socket. Note: This function automatically sets supplied socket as the active socket. All subsequent calls will us this socket as the active socket.
|
|
|
Checks if there is a transmit buffer ready for accepting data, and that the given socket is valid (not equal to INVALID_UDP_SOCKET for example).
Side Effects: Given socket is set as the active UDP Socket. Note: This function automatically sets supplied socket as the active socket. All subsequent calls will us this socket as the active socket.
|
|
||||||||||||||||
|
A UDP packet header is assembled and loaded into UDP transmit buffer. A localPort value of '0' is considered nonexistent port. This call must always have nonzero localPort value. This function sets returned socket as an active UDP socket.
|
|
||||||||||||||||
|
Performs UDP related tasks. Must continuesly be called.
|
|
|
Given data byte is put into the UDP transmit buffer and active UDP socket buffer length is incremented. The data is NOT sent yet, and the UDPFlush() function must be called to send all data contained in the transmit buffer. If the transmit buffer filled up, the contents of the transmit buffer will be sent, and this function will return FALSE. In this case, it is VERY IMPORTANT to call the UDPIsPutReady() function again before calling the UDPPut() or UDPPutArray() functions! Note: This function loads data into an active UDP socket as determined by previous call to UDPIsPutReady().
|
|
||||||||||||
|
Given number of data bytes from the given array are put into the UDP transmit buffer and active UDP socket buffer length is incremented by number of bytes. The data is NOT sent yet, and the UDPFlush() function must be called to send all data contained in the transmit buffer. If there is not enough space in the transmit buffer for all the data, the contents of the transmit buffer will be sent, and this function will return the actual amount of bytes that were sent. In this case, it is VERY IMPORTANT to call the UDPIsPutReady() function again before calling the UDPPut() or UDPPutArray() functions! This will however only happen if the transmit buffer fills up. The transmit buffer for UDP data is = (MAC_TX_BUFFER_SIZE - 42), which is usually 982 bytes. If writing less then this to the transmit buffer before calling UDPFlush(), then this function will always return the requested number of bytes! Note: This function loads data into an active UDP socket as determined by previous call to UDPIsPutReady().
|
|
|
|
|
|
|
1.4.5