Embedded Web Server for the CR16
National Semiconductor
Jeff Wright
14
2.
The successful passing of a segment to IP for transmission as indicated by the IPSEND
flag in that same Cmd field.
typedef struct tcpapi_t{
UWORD LocPort; /* Our (local) Port number */
UWORD ForPort;
/* Foreign (peers) Port number
*/
QUADB_T ForIP; /* Peers IP address */
UWORD Cmd; /* Command from Application layer */
UWORD Status;
/* Status of the TCP layer */
UWORD Tout; /* Timeout for various TCP states */
UBYTE *RxBuf; /* Pointer to Applications Rx buffer */
UWORD RxCount; /* Number of bytes recd */
UWORD RxBufLen; /* Applications Rx buffer length */
UBYTE *TxBuf; /* Pointer to RAM data to send */
UWORD TxCount; /* Number of RAM bytes to send */
const UBYTE *html; /* Pointer to ROM-based data to send */
UWORD HtmLen; /* Number of ROM bytes to send */
CRSOCK_T *Socket; /* Pointer to Transmission Control */
/* Block for specified connection name */
} TCPAPI_T;
Figure 6. TCPs API data structure
Commands are issued by the overlying Application layer via flags in the Cmd field of the
TCPAPI_T data structure. TCP recognizes the following commands (although not all are
currently supported):
#define TCP_OPEN
BIT0
/* OPEN a connection
*/
#define TCP_RECV BIT1 /* Data has been received
*/
#define TCP_CLOSE BIT2
/* CLOSE this connection
*/
#define TCP_STATUS BIT3
/* Not implemented
*/
#define TCP_ABORT BIT4
/* ABORT this connection
*/
#define TCP_SEND BIT5 /* SEND specified buffer(s)
*/
#define TCP_SENDACK BIT6 /* SEND an ACK only
*/
#define TCP_ACTIVE BIT8 /* Used in conjunction w/ OPEN */
#define TCP_MORE BIT9 /* Indicates whether the application*/
/* is finished sending all data
*/
Figure 7. TCPs command definition
2.
The TCP Socket.
Upon receiving the TCP_OPEN command, TCP will create a TCP Control Block (if one is
available) and provide the application with a pointer to this structure. Thereafter, this
pointer is used by the application(s) as a handle to uniquely identify itself from among the
other (if there are others) applications requesting service from TCP. As illustrated in
Figure 8, TCP Control Blocks are linked together with any others that may have been
created, forming a list of active sockets. (*Note that, due to the RAM requirements of the
HTTP layer, only one such socket may be created on the Cannonball.)