Specifies the callback function that should be called when data has successfully been received (i.e., acknowledged) by the remote host. The len argument passed to the callback function gives the amount bytes that was acknowledged by the last acknowledgment.
This function should be called by the application when it has processed the data. The purpose is to advertise a larger window when the data has been processed.
Sets the callback function that will be called when new data arrives. The callback function will be passed a NULL pbuf to indicate that the remote host has closed the connection. If the callback function returns ERR_OK or ERR_ABRT it must have freed the pbuf, otherwise it must not have freed it.
Specifies the polling interval and the callback function that should be called to poll the application. The interval is specified in number of TCP coarse grained timer shots, which typically occurs twice a second. An interval of 10 means that the application would be polled every 5 seconds. When a connection is idle (i.e., no data is either transmitted or received), lwIP will repeatedly poll the application by calling a specified callback function. This can be used either as a watchdog timer for killing connections that have stayed idle for too long, or as a method of waiting for memory to become available. For instance, if a call to tcp_write() has failed because memory wasn't available, the application may use the polling functionality to call tcp_write() again when the connection has been idle for a while.
Specifies the program specific state that should be passed to all other callback functions. The "pcb" argument is the current TCP connection control block, and the "arg" argument is the argument that will be passed to the callbacks.
Aborts the connection by sending a RST (reset) segment to the remote host. The pcb is deallocated. This function never fails. ATTENTION: When calling this from one of the TCP callbacks, make sure you always return ERR_ABRT (and never return ERR_ABRT otherwise or you will risk accessing deallocated memory or memory leaks!
Find out what we can send and send it
Used to specify the function that should be called when a fatal error has occurred on the connection. If a connection is aborted because of an error, the application is alerted of this event by the err callback. Errors that might abort a connection are when there is a shortage of memory. The callback function to be called is set using the tcp_err() function.
Closes the connection held by the PCB. Listening pcbs are freed and may not be referenced any more. Connection pcbs are freed if not yet connected and may not be referenced any more. If a connection is established (at least SYN received or in a closing state), the connection is closed, and put in a closing state. The pcb is then automatically freed in tcp_slowtmr(). It is therefore unsafe to reference it (unless an error is returned). The function may return ERR_MEM if no memory was available for closing the connection. If so, the application should wait and try again either by using the acknowledgment callback or the polling functionality. If the close succeeds, the function returns ERR_OK.
Write data for sending (but does not send it immediately). It waits in the expectation of more data being sent soon (as it can send them more efficiently by combining them together). To prompt the system to send data now, call tcp_output() after calling tcp_write(). This function enqueues the data pointed to by the argument dataptr. The length of the data is passed as the len parameter. The apiflags can be one or more of: - TCP_WRITE_FLAG_COPY: indicates whether the new memory should be allocated for the data to be copied into. If this flag is not given, no new memory should be allocated and the data should only be referenced by pointer. This also means that the memory behind dataptr must not change until the data is ACKed by the remote host - TCP_WRITE_FLAG_MORE: indicates that more data follows. If this is omitted, the PSH flag is set in the last segment created by this call to tcp_write. If this flag is given, the PSH flag is not set. The tcp_write() function will fail and return ERR_MEM if the length of the data exceeds the current send buffer size or if the length of the queue of outgoing segment is larger than the upper limit defined in lwipopts.h. The number of bytes available in the output queue can be retrieved with the tcp_sndbuf() function. The proper way to use this function is to call the function with at most tcp_sndbuf() bytes of data. If the function returns ERR_MEM, the application should wait until some of the currently enqueued data has been successfully received by the other host and try again.
Used for specifying the function that should be called when a LISTENing connection has been connected to another host.
Send a TCP RESET packet (empty segment with RST flag set) either to abort a connection or to show that there is no matching local connection for a received segment. Called by tcp_abort() (to abort a local connection), tcp_input() (if no matching local pcb was found), tcp_listen_input() (if incoming segment has ACK flag set) and tcp_process() (received segment in the wrong state) Since a RST segment is in most cases not sent for an active connection, tcp_rst() has a number of arguments that are taken from a tcp_pcb for most other segment output functions.
Binds the connection to a local port number and IP address. If the IP address is not given (i.e., ipaddr == IP_ANY_TYPE), the connection is bound to all local IP addresses. If another connection is bound to the same port, the function will return ERR_USE, otherwise ERR_OK is returned.
Purges a TCP PCB. Removes any buffered data and frees the buffer memory (pcb->ooseq, pcb->unsent and pcb->unacked are freed).
Purges the PCB and removes it from a PCB list. Any delayed ACKs are sent first.
Set the state of the connection to be LISTEN, which means that it is able to accept incoming connections. The protocol control block is reallocated in order to consume less memory. Setting the connection to LISTEN is an irreversible process. When an incoming connection is accepted, the function specified with the tcp_accept() function will be called. The pcb has to be bound to a local port with the tcp_bind() function. The tcp_listen() function returns a new connection identifier, and the one passed as an argument to the function will be deallocated. The reason for this behavior is that less memory is needed for a connection that is listening, so tcp_listen() will reclaim the memory needed for the original connection and allocate a new smaller memory block for the listening connection. tcp_listen() may return NULL if no memory was available for the listening connection. If so, the memory associated with the pcb passed as an argument to tcp_listen() will not be deallocated. The backlog limits the number of outstanding connections in the listen queue to the value specified by the backlog argument. To use it, your need to set TCP_LISTEN_BACKLOG=1 in your lwipopts.h.
Send an ACK without data.
Called by tcp_process. Checks if the given segment is an ACK for outstanding data, and if so frees the memory of the buffered data. Next, it places the segment on any of the receive queues (pcb->recved or pcb->ooseq). If the segment is buffered, the pbuf is referenced by pbuf_ref so that it will not be freed until it has been removed from the buffer. If the incoming segment constitutes an ACK for a segment that was used for RTT estimation, the RTT is estimated here as well. Called from tcp_process().
Sets the priority of a connection.
Call tcp_write() in a loop trying smaller and smaller length
The connection shall be actively closed. Reset the sent- and recv-callbacks.
Connects to another host. The function given as the "connected" argument will be called when the connection has been established. Sets up the pcb to connect to the remote host and sends the initial SYN segment which opens the connection. The tcp_connect() function returns immediately; it does not wait for the connection to be properly setup. Instead, it will call the function specified as the fourth argument (the "connected" argument) when the connection is established. If the connection could not be properly established, either because the other host refused the connection or because the other host didn't answer, the "err" callback function of this pcb (registered with tcp_err, see below) will be called. The tcp_connect() function can return ERR_MEM if no memory is available for enqueueing the SYN segment. If the SYN indeed was enqueued successfully, the tcp_connect() function returns ERR_OK.
Called by tcp_close() to send a segment including FIN flag but not data. This FIN may be added to an existing segment or a new, otherwise empty segment is enqueued.
Enqueue SYN or FIN for transmission. Called by tcp_connect, tcp_listen_input, and tcp_close (via tcp_send_fin)
Default receive callback that is called if the user didn't register a recv callback for the pcb.
Abandons a connection and optionally sends a RST to the remote host. Deletes the local protocol control block. This is done when a connection is killed because of shortage of memory.
Output a control segment pbuf to IP. Called from tcp_rst, tcp_send_empty_ack, tcp_keepalive and tcp_zero_window_probe, this function combines selecting a netif for transmission, generating the tcp header checksum and calling ip_output_if while handling netif hints and stats.
Calculates a new initial sequence number for new connections.
Binds the connection to a netif and IP address. After calling this function, all packets received via this PCB are guaranteed to have come in via the specified netif, and all outgoing packets will go out via the specified netif.
Set the state of the connection to be LISTEN, which means that it is able to accept incoming connections. The protocol control block is reallocated in order to consume less memory. Setting the connection to LISTEN is an irreversible process.
Requeue the first unacked segment for retransmission Called by tcp_receive() for fast retransmit.
Requeue all unacked segments for retransmission Called by tcp_slowtmr() for slow retransmission.
Requeue all unacked segments for retransmission Called by tcp_slowtmr() for slow retransmission.
Update the state that tracks the available window space to advertise. Returns how much extra window would be advertised if we sent an update now.
Pass pcb->refused_data to the recv callback
Closes the TX side of a connection held by the PCB. For tcp_close(), a RST is sent if the application didn't receive all data (tcp_recved() not called for all data passed to recv callback). Listening pcbs are freed and may not be referenced any more. Connection pcbs are freed if not yet connected and may not be referenced any more. If a connection is established (at least SYN received or in a closing state), the connection is closed, and put in a closing state. The pcb is then automatically freed in tcp_slowtmr(). It is therefore unsafe to reference it.
Called from tcp_input to check for TF_CLOSED flag. This results in closing and deallocating a pcb at the correct place to ensure noone references it any more.
Parses the options contained in the incoming segment. Called from tcp_listen_input() and tcp_process(). Currently, only the MSS option is supported!
Create a TCP segment with prefilled header. Called by tcp_write, tcp_enqueue_flags and tcp_split_unsent_seg
Allocate a pbuf and create a tcphdr at p->payload, used for output functions other than the default tcp_output -> tcp_output_segment (e.g. tcp_send_empty_ack, etc.)
End of file: either close the connection (Connection: close) or close the file (Connection: keep-alive)
Try to send more data on this pcb.
The poll function is called every 2nd second. If there has been no data sent (which resets the retries) in 8 seconds, close. If the last portion of a file has not been sent in 2 seconds, close. This could be increased, but we don't want to waste resources for bad connections.
Send keepalive packets to keep a connection active although no data is sent over it. Called by tcp_slowtmr()
Split segment on the head of the unsent queue. If return is not ERR_OK, existing head remains intact The split is accomplished by creating a new TCP segment and pbuf which holds the remainder payload after the split. The original pbuf is trimmed to new length. This allows splitting of read-only pbufs
Send persist timer zero-window probes to keep a connection active when a window update is lost. Called by tcp_slowtmr()
Requeue all unacked segments for retransmission Called by tcp_process() only, tcp_slowtmr() needs to do some things between "prepare" and "commit".
Handle retransmission after three dupacks received
Causes all or part of a full-duplex connection of this PCB to be shut down. This doesn't deallocate the PCB unless shutting down both sides! Shutting down both sides is the same as calling tcp_close, so if it succeds (i.e. returns ER_OK), the PCB must not be referenced any more!
Sent callback function for TCP netconns. Signals the conn->sem and calls API_EVENT. netconn_write waits for conn->sem if send buffer is low. @see tcp.h (struct tcp_pcb.sent) for parameters and return value
Poll callback function for TCP netconns. Wakes up an application thread that waits for a connection to close or data to be sent. The application thread then takes the appropriate action to go on. Signals the conn->sem. netconn_close waits for conn->sem if closing failed. @see tcp.h (struct tcp_pcb.poll) for parameters and return value
Helper function for tcp_netif_ip_addr_changed() that iterates a pcb list
Called by tcp_input() when a segment arrives for a connection in TIME_WAIT.
Implements the TCP state machine. Called by tcp_input. In some states tcp_receive() is called to receive data. The tcp_seg argument will be freed by the caller (tcp_input()) unless the recv_data pointer in the pcb is set.
Remove segments from a list if the incoming ACK acknowledges them
Allocate a PBUF_RAM pbuf, perhaps with extra space at the end. This function is like pbuf_alloc(layer, length, PBUF_RAM) except there may be extra bytes available at the end. Called by tcp_write
Called by tcp_output() to actually send a TCP segment over IP.
The connection shall be actively closed (using RST to close from fault states). Reset the sent- and recv-callbacks.
Sub-function of http_send(): end-of-file (or block) is reached, either close the file or read the next block (if supported). @returns: 0 if the file is finished or no data has been read 1 if the file is not finished and data has been read
TCP callback function if a connection (opened by tcp_connect/lwip_netconn_do_connect) has been established (or reset by the remote host). @see tcp.h (struct tcp_pcb.connected) for parameters and return values
Receive callback function for TCP netconns. Posts the packet to conn->recvmbox, but doesn't delete it on errors. @see tcp.h (struct tcp_pcb.recv) for parameters and return value
Accept callback function for TCP netconns. Allocates a new netconn and posts that to conn->acceptmbox. @see tcp.h (struct tcp_pcb_listen.accept) for parameters and return value
Called when a listen pcb is closed. Iterates all pcb lists and removes the closed listener pcb from pcb->listener if matching.
Default accept callback if no accept callback is specified by the user.
Checks if tcp_write is allowed or not (checks state, snd_buf and snd_queuelen).
When data has been received in the correct state, try to parse it as a HTTP request.
Sub-function of http_send(): This is the normal send-routine for non-ssi files @returns: - 1: data has been written (so call tcp_ouput) - 0: no data has been written (no need to call tcp_output)
Data has been sent and acknowledged by the remote host. This means that more data can be sent.
Data has been received on this pcb. For HTTP 1.0, this should normally only happen once (if the request fits in one packet).
A new incoming connection has been accepted.
Sub-function of http_send(): This is the send-routine for ssi files @returns: - 1: data has been written (so call tcp_ouput) - 0: no data has been written (no need to call tcp_output)