Dereference a pbuf chain or queue and deallocate any no-longer-used pbufs at the head of this chain or queue. Decrements the pbuf reference count. If it reaches zero, the pbuf is deallocated. For a pbuf chain, this is repeated for each pbuf in the chain, up to the first pbuf which has a non-zero reference count after decrementing. So, when all reference counts are one, the whole chain is free'd. @internal examples: Assuming existing chains a->b->c with the following reference counts, calling pbuf_free(a) results in: 1->2->3 becomes ...1->3 3->3->3 becomes 2->3->3 1->1->2 becomes ......1 2->1->1 becomes 1->1->1 1->1->1 becomes .......
Convert an u16_t from host- to network byte order.
Convert an u32_t from host- to network byte order.
Check whether "cp" is a valid ascii representation of an IPv6 address and convert to a binary address. Returns 1 if the address is valid, 0 if not.
Unprotect critical region
Get runtime profile of ping session
Allocates a pbuf of the given type (possibly a chain for PBUF_POOL type). The actual memory allocated for the pbuf is determined by the layer at which the pbuf is allocated and the requested size (from the size parameter). - PBUF_RAM: buffer memory for pbuf is allocated as one large chunk. This includes protocol headers as well. - PBUF_ROM: no buffer memory is allocated for the pbuf, even for protocol headers. Additional headers must be prepended by allocating another pbuf and chain in to the front of the ROM pbuf. It is assumed that the memory used is really similar to ROM in that it is immutable and will not be changed. Memory which is dynamic should generally not be attached to PBUF_ROM pbufs. Use PBUF_REF instead. - PBUF_REF: no buffer memory is allocated for the pbuf, even for protocol headers. It is assumed that the pbuf is only being used in a single thread. If the pbuf gets queued, then pbuf_take should be called to copy the buffer. - PBUF_POOL: the pbuf is allocated as a pbuf chain, with pbufs from the pbuf pool that is allocated during pbuf_init().
Same as ipaddr_ntoa, but reentrant since a user-supplied buffer is used.
Put an element back into its pool.
Get an element from a specific pool.
Convert numeric IPv6 address into ASCII representation. returns ptr to static buffer; not reentrant!
Same as ip4addr_ntoa, but reentrant since a user-supplied buffer is used.
Adjusts the payload pointer to hide headers in the payload. Adjusts the ->payload pointer so that space for a header disappears in the pbuf payload. The ->payload, ->tot_len and ->len fields are adjusted.
Map a externally used socket index to the internal socket representation.
Go through timeout list (for this task only) and remove the first matching entry (subsequent entries remain untouched), even though the timeout has not triggered yet.
Removes and deallocates the pcb. @see udp_new()
Synchronously calls function in TCPIP thread and waits for its completion. It is recommended to use LWIP_TCPIP_CORE_LOCKING (preferred) or LWIP_NETCONN_SEM_PER_THREAD. If not, a semaphore is created and destroyed on every call which is usually an expensive/slow operation.
Convert numeric IP address into decimal dotted ASCII representation. returns ptr to static buffer; not reentrant!
Set a receive callback for a UDP PCB. This callback will be called when receiving a datagram for the pcb.
Copy (part of) the contents of a packet buffer to an application supplied buffer.
Get current time, in milliseconds
Bind an UDP PCB. ipaddr & port are expected to be in the same byte order as in the pcb. @see udp_disconnect()
Check whether "cp" is a valid ascii representation of an Internet address and convert to a binary address. Returns 1 if the address is valid, 0 if not. This replaces inet_addr, the return value from which cannot distinguish between failure and a local broadcast address.
Finds the appropriate network interface for a given IPv6 address. It tries to select a netif following a sequence of heuristics: 1) if there is only 1 netif, return it 2) if the destination is a zoned address, match its zone to a netif 3) if the either the source or destination address is a scoped address, match the source address's zone (if set) or address (if not) to a netif 4) tries to match the destination subnet to a configured address 5) tries to find a router-announced route 6) tries to match the (unscoped) source address to the netif 7) returns the default netif, if configured Note that each of the two given addresses may or may not be properly zoned.
Join a group on a network interface.
Leave a group on a network interface.
Ascii internet address interpretation routine. The value returned is in network order.
Find out what we can send and send it
Call the lower part of a netconn_* function This function is then running in the thread context of tcpip_thread and has exclusive access to lwIP core code.
Return the interface for the netif index
Adjusts the payload pointer to reveal headers in the payload. Adjusts the ->payload pointer so that space for a header appears in the pbuf payload. The ->payload, ->tot_len and ->len fields are adjusted. PBUF_ROM and PBUF_REF type buffers cannot have their sizes increased, so the call will fail. A check is made that the increase in header size does not move the payload pointer in front of the start of the buffer.
Try to post a message to mailbox
Change the state of an IPv6 address of a network interface (INVALID, TEMPTATIVE, PREFERRED, DEPRECATED, where TEMPTATIVE includes the number of checks done, see ip6_addr.h)
Send data to a specified address using UDP. The netif used for sending can be specified. This function exists mainly for DHCP, to be able to send UDP packets on a netif that is still down. dst_ip & dst_port are expected to be in the same byte order as in the pcb. @see udp_disconnect() udp_send()
Shrink a pbuf chain to a desired length. Depending on the desired length, the first few pbufs in a chain might be skipped and left unchanged. The new last pbuf in the chain will be resized, and any remaining pbufs will be freed.
Invoke extended netif status event
Call a specific function in the thread context of tcpip_thread for easy access synchronization. A function called in that way may access lwIP core code without fearing concurrent access. Blocks until the request is posted. Must not be called from interrupt context! @see tcpip_try_callback
Determine if an address is a broadcast address on a network interface
Sends an IPv6 packet on a network interface. This function constructs the IPv6 header. If the source IPv6 address is NULL, the IPv6 "ANY" address is used as source (usually during network startup). If the source IPv6 address it IP6_ADDR_ANY, the most appropriate IPv6 address of the outgoing network interface is filled in as source address. If the destination IPv6 address is LWIP_IP_HDRINCL, p is assumed to already include an IPv6 header and p->payload points to it instead of the data.
Wait for a semaphore to be signaled
Creates a new UDP pcb which can be used for UDP communication. The pcb is not active until it has either been bound to a local address or connected to a remote address. @see MEMP_NUM_UDP_PCB @see udp_remove()
Source based IPv4 routing must be fully implemented in LWIP_HOOK_IP4_ROUTE_SRC(). This function only provides the parameters.
Deallocates a list of TCP segments (tcp_seg structures).
Send out an sntp request.
Send data to a specified address using UDP. dst_ip & dst_port are expected to be in the same byte order as in the pcb. If the PCB already has a remote address association, it will be restored after the data is sent. @see udp_disconnect() udp_send()
Put memory back on the heap
Send an icmpv6 'parameter problem' packet. This function must be used only in direct response to a packet that is being received right now. Otherwise, address zones would be lost and the calculated offset would be wrong (calculated against ip6_current_header()).
Frees a TCP segment (tcp_seg structure).
Calculates the checksum with IPv6 pseudo header used by TCP and UDP for a pbuf chain. IPv6 addresses are expected to be in network byte order.
Will free any resources associated with a neighbor cache entry, and will mark it as unused.
Count number of pbufs in a chain
Sends an IP packet on a network interface. This function constructs the IP header and calculates the IP header checksum. If the source IP address is NULL, the IP address of the outgoing network interface is filled in as source address. If the destination IP address is LWIP_IP_HDRINCL, p is assumed to already include an IP header and p->payload points to it instead of the data.
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!
Retry: send a new request (and increase retry timeout).
Create a DHCP request, fill in common headers
Add a DHCP message trailer Adds the END option to the DHCP message, and if necessary, up to three padding bytes.
Change IP address configuration for a network interface (including netmask and default gateway).
Remove the remote end of the pcb. This function does not generate any network traffic, but only removes the remote address of the pcb.
Join a group on one network interface.
Leave a group on one network interface.
Get one byte from the specified position in a pbuf
Select the best IPv6 source address for a given destination IPv6 address. This implementation follows RFC 6724 Sec. 5 to the following extent: - Rules 1, 2, 3: fully implemented - Rules 4, 5, 5.5: not applicable - Rule 6: not implemented - Rule 7: not applicable - Rule 8: limited to "prefer /64 subnet match over non-match" For Rule 2, we deliberately deviate from RFC 6724 Sec. 3.1 by considering ULAs to be of smaller scope than global addresses, to avoid that a preferred ULA is picked over a deprecated global address when given a global address as destination, as that would likely result in broken two-way communication. As long as temporary addresses are not supported (as used in Rule 7), a proper implementation of Rule 8 would obviate the need to implement Rule 6.
Send an ethernet packet on the network using netif->linkoutput(). The ethernet header is filled in before sending. @see LWIP_HOOK_VLAN_SET
Get and reset pending error on a netconn
Purges a TCP PCB. Removes any buffered data and frees the buffer memory (pcb->ooseq, pcb->unsent and pcb->unacked are freed).
Called from TCP_REG when registering a new PCB: the reason is to have the TCP timer only running when there are active (or time-wait) PCBs.
Search for a neighbor cache entry
If Kiss-of-Death is received (or another packet parsing error), try the next server or retry the current server and increase the retry timeout if only one server is available. (implicitly, SNTP_MAX_SERVERS > 1)
Allocate a block of memory with a minimum of 'size' bytes. Note that the returned value must always be aligned (as defined by MEM_ALIGNMENT).
Copy the contents of one packet buffer into another.
Convert numeric IP address (both versions) into ASCII representation. returns ptr to static buffer; not reentrant!
Concatenate two pbufs (each may be a pbuf chain) and take over the caller's reference of the tail pbuf. This function explicitly does not check for tot_len overflow to prevent failing to queue too long pbufs. This can produce invalid pbufs, so handle with care! @see pbuf_chain()
Allocates a new pbuf of same length (via pbuf_alloc()) and copies the source pbuf into this new pbuf (using pbuf_copy()).
Send an IP packet to be received on the same netif (loopif-like). The pbuf is copied and added to an internal queue which is fed to netif->input by netif_poll(). In multithreaded mode, the call to netif_poll() is queued to be done on the TCP/IP thread. In callback mode, the user has the responsibility to call netif_poll() in the main loop of their application.
Send an icmp 'destination unreachable' packet, called from ip_input() if the transport layer protocol is unknown and from udp_input() if the local port is not bound.
Send an ACK without data.
Purges the PCB and removes it from a PCB list. Any delayed ACKs are sent first.
Send a TCP RESET packet (empty segment with RST flag set) to abort a connection. Called by tcp_abort() (to abort a local connection), tcp_closen() (if not all data has been received by the application), tcp_timewait_input() (if a SYN is received) 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.
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().
Sends a single character to the serial device.
Checks if a specific local address is present on the netif and returns its index. Depending on its state, it may or may not be assigned to the interface (as per RFC terminology). The given address may or may not be zoned (i.e., have a zone index other than IP6_NO_ZONE). If the address is zoned, it must have the correct zone for the given netif, or no match will be found.
Convert IP address string (both versions) to numeric. The version is auto-detected from the string.
This function is called by the network interface device driver when an IPv6 packet is received. The function does the basic checks of the IP header such as packet size being at least larger than the header size etc. If the packet was not destined for us, the packet is forwarded (using ip6_forward). Finally, the packet is sent to the upper layer protocol input function.
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.
A delayed-accept a connection is accepted (or closed/aborted): decreases the number of outstanding connections after calling tcp_backlog_delayed(). ATTENTION: the caller is responsible for calling tcp_backlog_accepted() or else the backlog feature will get out of sync!
Release a DHCP lease and stop DHCP statemachine (and AUTOIP if LWIP_DHCP_AUTOIP_COOP).
Search for a group that is joined on a netif
Deallocate a netbuf allocated by netbuf_new().
Search for a group in the netif's igmp group list
Returns a copy of the given TCP segment. The pbuf and data are not copied, only the pointers
dns_call_found() - call the found callback and check if there are duplicate entries for the given hostname. If there are any, their found callback will be called and they will be removed.
Send ARP/IGMP/MLD/RS events, e.g. on link-up/netif-up or addr-change
Start the DHCP process, discover a DHCP server.
Search for a destination cache entry
Increment the reference count of the pbuf.
Same as udp_sendto_if, but with source address
lwIP default implementation for strnicmp() non-standard function. This can be \#defined to strnicmp() depending on your platform port.
Add a network interface to the list of lwIP netifs.
Initialize one of the DNS servers.
Get one byte from the specified position in a pbuf WARNING: returns zero for offset >= p->tot_len
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.
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.
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.
Add a new static entry to the ARP table. If an entry exists for the specified IP address, this entry is overwritten. If packets are queued for the specified IP address, they are sent out.
Fetch message from mailbox
try to fetch message from mailbox
Call a specific function in the thread context of tcpip_thread for easy access synchronization. A function called in that way may access lwIP core code without fearing concurrent access. Does NOT block when the request cannot be posted because the tcpip_mbox is full, but returns ERR_MEM instead. Can be called from interrupt context. @see tcpip_callback
Create a UDP PCB for specific IP type. The pcb is not active until it has either been bound to a local address or connected to a remote address. @see MEMP_NUM_UDP_PCB @see udp_remove()
Calculates the effective send mss that can be used for a specific IP address by calculating the minimum of TCP_MSS and the mtu (if set) of the target netif (if not NULL).
Internal helper function to close a TCP netconn: since this sometimes doesn't work at the first attempt, this function is called from multiple places.
Send a raw ARP packet (opcode and all addresses can be modified)
Send an ICMPv6 packet in response to an incoming packet. The packet is sent *to* ip_current_src_addr() on ip_current_netif().
Schedule a delayed membership report for a group
Send a neighbor solicitation message for a specific neighbor cache entry
Create a new neighbor cache entry. If no unused entry is found, will try to recycle an old entry according to ad-hoc "age" heuristic.
Send an ARP request packet asking for ipaddr.
Sends a message to TCPIP thread to call a function. Caller thread blocks on on a provided semaphore, which ist NOT automatically signalled by TCPIP thread, this has to be done by the user. It is recommended to use LWIP_TCPIP_CORE_LOCKING since this is the way with least runtime overhead.
Bind an UDP PCB to a specific netif. 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. @see udp_disconnect()
Pass a received packet to tcpip_thread for input processing with ethernet_input or ip_input. Don't call directly, pass to netif_add() and call netif->input().
Initialize this module. Send out request instantly or after SNTP_STARTUP_DELAY(_FUNC).
Bring an interface down, disabling any traffic processing.
Called by a driver when its link goes up
Copy part or all of one packet buffer into another, to a specified offset.
Find a network interface by searching for its name
Get PING function result action
Finds the appropriate network interface for a given IP address. It searches the list of network interfaces linearly. A match is found if the masked IP address of the network interface equals the masked IP address given to the function.
If both IP versions are enabled, this function can dispatch packets to the correct one. Don't call directly, pass to netif_add() and call netif->input().
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.
Used for specifying the function that should be called when a LISTENing connection has been connected to another host. @see MEMP_NUM_TCP_PCB_LISTEN and MEMP_NUM_TCP_PCB
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.
Remove a static entry from the ARP table previously added with a call to etharp_add_static_entry.
Get the Path MTU for a destination.
Netif was added, set up, or reconnected (link up)
Pass a received packet to tcpip_thread for input processing
Close or shutdown a TCP netconn (doesn't delete it).
Execute a DNS query, only one IP address is returned
Send data over a UDP or RAW netconn (that is already connected).
Create a new netconn (of a specific type) that has a callback function. The corresponding pcb is also created.
Close a netconn 'connection' and free its resources. UDP and RAW connection are completely closed, TCP pcbs might still be in a waitstate after this returns.
Get the local or remote IP address and port of a netconn. For RAW netconns, this returns the protocol instead of a port!
Receive data: actual implementation that doesn't care whether pbuf or netbuf is received (this is internal, it's just here for describing common errors)
Free the packet buffer included in a netbuf
Delete a netconn and all its resources. The pcb is NOT freed (since we might not be in the right thread context do this).
Allocate a new tcp_pcb structure.
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.
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.
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.
See if more data needs to be written from a previous call to netconn_write. Called initially from lwip_netconn_do_write. If the first call can't send all data (because of low memory or empty send-buffer), this function is called again from sent_tcp() or poll_tcp() to send more data. If all data is sent, the blocking application thread (waiting in netconn_write) is released.
Setup a tcp_pcb with the correct callback function pointers and their arguments.
Callback registered in the netconn layer for each socket-netconn. Processes recvevent (data available) and wakes up tasks waiting for select.
dns_check_entry() - see if entry has not yet been queried and, if so, sends out a query. Check an entry in the dns_table: - send out query for new entries - retry old pending entries on timeout (also with different servers) - remove completed entries from the table if their TTL has expired
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.
Check if a segment's pbufs are used by someone else than TCP. This can happen on retransmission if the pbuf of this segment is still referenced by the netif driver due to deferred transmission. This is the case (only!) if someone down the TX call path called pbuf_ref() on one of the pbufs! @arg seg the tcp segment to check
Timer callback function that calls cyclic->handler() and reschedules itself.
Bind the interface to the offered IP address.
Search the ARP table for a matching or new entry. If an IP address is given, return a pending or stable ARP entry that matches the address. If no match is found, create a new entry with this address set, but in state ETHARP_EMPTY. The caller must check and possibly change the state of the returned entry. If ipaddr is NULL, return a initialized new entry in state ETHARP_EMPTY. In all cases, attempt to create new entries from an empty entry. If no empty entries are available and ETHARP_FLAG_TRY_HARD flag is set, recycle old entries. Heuristic choose the least important entry for recycling.
Clean up ARP table entries
Delaying membership report for a group if necessary
Send an igmp packet to a specific group.
Send a MLD message (report or done). An IPv6 hop-by-hop options header with a router alert option is prepended.
Send a neighbor advertisement message
FunctionName : node_delete_from_list Description : remove the node from list Parameters : phead -- the head node of the list pdelete -- the remove node of the list Returns : none
FunctionName : dhcps_coarse_tmr Description : the lease time count Parameters : none Returns : none
Kills the oldest connection that is in specific state. Called from tcp_alloc() for LAST_ACK and CLOSING if no more connections are available.
Start DHCP negotiation for a network interface. If no DHCP client instance was attached to this interface, a new client is created first. If a DHCP client instance was already present, it restarts negotiation.
Sets the remote end of the pcb. This function does not generate any network traffic, but only sets the remote address of the pcb. ipaddr & port are expected to be in the same byte order as in the pcb. The udp pcb is bound to a random local port if not already bound. @see udp_disconnect()
Like dns_gethostbyname, but returned address type can be controlled:
Bring an interface up, available for processing traffic.
Resolve and fill-in Ethernet address header for outgoing IP packet. For IP multicast and broadcast, corresponding Ethernet addresses are selected and the packet is transmitted on the link. For unicast addresses, the packet is submitted to etharp_query(). In case the IP address is outside the local network, the IP address of the gateway is used.
Initialize one of the NTP servers by name
Resolve and fill-in Ethernet address header for outgoing IPv6 packet. For IPv6 multicast, corresponding Ethernet addresses are selected and the packet is transmitted on the link. For unicast addresses, ask the ND6 module what to do. It will either let us send the the packet right away, or queue the packet for later itself, unless an error occurs. @todo anycast addresses
This function calls dhcp_release_and_stop() internally. @deprecated Use dhcp_release_and_stop() instead.
Sets the DHCP server option info
Enable/Disable NAPT for a specified interface.
Get the sync interval of SNTP operation
Same as pbuf_header but does not check if 'header_size > 0' is allowed. This is used internally only, to allow PBUF_REF for RX.
Same as pbuf_add_header but does not check if 'header_size > 0' is allowed. This is used internally only, to allow PBUF_REF for RX.
Chain two pbufs (or pbuf chains) together. The caller MUST call pbuf_free(t) once it has stopped using it. Use pbuf_cat() instead if you no longer use t. The ->tot_len fields of all pbufs of the head chain are adjusted. The ->next field of the last pbuf of the head chain is adjusted. The ->ref field of the first pbuf of the tail chain is adjusted.
Copy application supplied data into a pbuf. This function can only be used to copy the equivalent of buf->tot_len data.
Same as pbuf_take() but puts data at an offset
Skip a number of bytes at the start of a pbuf
Put one byte to the specified position in a pbuf WARNING: silently ignores offset >= p->tot_len
Frees one or more addrinfo structures returned by getaddrinfo(), along with any additional storage associated with those structures. If the ai_next field of the structure is not null, the entire list of structures is freed.
This function is called by the network interface device driver when an IP packet is received. The function does the basic checks of the IP header such as packet size being at least larger than the header size etc. If the packet was not destined for us, the packet is forwarded (using ip_forward). The IP checksum is always checked. Finally, the packet is sent to the upper layer protocol input function.
Same as ip_output_if() but with the possibility to include IP options: @ param ip_options pointer to the IP options, copied into the IP header @ param optlen length of ip_options
Same as ip_output_if_opt() but 'src' address is not replaced by netif address when it is 'any'.
Same as ip6_output_if() but 'src' address is not replaced by netif address when it is 'any'.
Send an icmpv6 'destination unreachable' packet. This function must be used only in direct response to a packet that is being received right now. Otherwise, address zones would be lost.
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.
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.
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 succeeds (i.e. returns ER_OK), the PCB must not be referenced any more!
Source based IPv4 routing hook function.
Send an ARP request for the given IP address and/or queue a packet. If the IP address was not yet in the cache, a pending ARP cache entry is added and an ARP request is sent for the given address. The packet is queued on this entry. If the IP address was already pending in the cache, a new ARP request is sent for the given address. The packet is queued on this entry. If the IP address was already stable in the cache, and a packet is given, it is directly sent and no ARP request is sent out. If the IP address was already stable in the cache, and no packet is given, an ARP request is sent out.
Provide the Neighbor discovery process with a hint that a destination is reachable. Called by tcp_receive when ACKs are received or sent (as per RFC). This is useful to avoid sending NS messages every 30 seconds.
Handle timeouts for NO_SYS==1 (i.e. without using tcpip_thread/sys_timeouts_mbox_fetch(). Uses sys_now() to call timeout handler functions when timeouts expire. Must be called periodically from your main loop.
Process an incoming UDP datagram. Given an incoming UDP datagram (as a chain of pbufs) this function finds a corresponding UDP PCB and hands over the pbuf to the pcbs recv function. If no pcb is found or the datagram is incorrect, the pbuf is freed.
Process received ethernet frames. Using this function instead of directly calling ip_input and passing ARP frames through etharp in ethernetif_input, the ARP cache is protected from concurrent access. Don't call directly, pass to netif_add() and call netif->input(). @see LWIP_HOOK_UNKNOWN_ETH_PROTOCOL @see ETHARP_SUPPORT_VLAN @see LWIP_HOOK_VLAN_CHECK
Send vectorized data atomically over a TCP netconn.
Close a netconn 'connection' and free all its resources but not the netconn itself. UDP and RAW connection are completely closed, TCP pcbs might still be in a waitstate after this returns.
Allocate memory for a packet buffer for a given netbuf.
Send the raw IP packet to the given address. An IP header will be prepended to the packet, unless the RAW_FLAGS_HDRINCL flag is set on the PCB. In that case, the packet must include an IP header, which will then be sent as is.
Bind an RAW PCB to a specific netif. 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. @see raw_disconnect()
Join a group on one network interface.
Leave a group on one network interface.
Execute a DNS query Called from netconn_gethostbyname
Create a new netconn (of a specific type) that has a callback function. The corresponding pcb is NOT created!
Called periodically to dispatch TCP timers.
The initial input processing of TCP. It verifies the TCP header, demultiplexes the segment between the PCBs and passes it on to tcp_process(), which implements the TCP finite state machine. This function is called by the IP layer (in ip_input()).
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.
Pass pcb->refused_data to the recv callback
Send a TCP RESET packet (empty segment with RST flag set) to show that there is no matching local connection for a received segment. Called by tcp_input() (if no matching local pcb was found) and tcp_listen_input() (if incoming segment has ACK flag set). 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.
Calculates a new initial sequence number for new connections.
Translate an error to a unique void* passed via an mbox
Delete rcvmbox and acceptmbox of a netconn and free the left-over data in these mboxes
Same as get_socket but doesn't set errno
Free a socket (under lock)
Free a socket's leftover members.
Go through the readset and writeset lists and see which socket of the sockets set in the sets has events. On return, readset, writeset and exceptset have the sockets enabled that had events.
Update revents in each struct pollfd. Optionally update select_waiting in struct lwip_sock.
Wrapper function with matching prototype which calls the actual callback
Fragment an IP datagram if too large for the netif. Chop the datagram in MTU sized chunks and send them in order by pointing PBUF_REFs into p.
Determine if in incoming IP packet is covered by a RAW PCB and if so, pass it to a user-provided receive callback function. Given an incoming IP datagram (as a chain of pbufs) this function finds a corresponding RAW PCB and calls the corresponding receive callback function.
Adjusts the payload pointer to reveal headers in the payload. @see pbuf_add_header.
Parses the options contained in the incoming segment. Called from tcp_listen_input() and tcp_process(). Currently, only the MSS option is supported!
Called from tcp_input to check for TF_CLOSED flag. This results in closing and deallocating a pcb at the correct place to ensure no one references it any more.
Insert segment into the list (segments covered with new one will be deleted) Called from tcp_receive()
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.)
Output a control segment pbuf to IP. Called instead of tcp_output_control_segment when we don't have a pcb but we do know the interface to send to.
Free DHCP PCB if the last netif stops using it
Select a DHCP server offer out of all offers. Simply select the first offer received.
Enter REBOOTING state to verify an existing lease
Send an ARP request packet asking for ipaddr to a specific eth address. Used to send unicast request to refresh the ARP table just before an entry times out
Send an icmp packet in response to an incoming packet.
Search for a specific igmp group and create a new one if not found-
Wrapper function with matching prototype which calls the actual callback
Start a timer for an igmp group
Send an ICMPv6 packet (with srd/dst address and netif given).
Wrapper function with matching prototype which calls the actual callback
Send a neighbor solicitation message
Free a complete queue of nd6 q entries
Send queued packets for a neighbor
Select a default router for a destination. This function is used both for routing and for finding a next-hop target for a packet. In the former case, the given netif is NULL, and the returned router entry must be for a netif suitable for sending packets (up, link up). In the latter case, the given netif is not NULL and restricts router choice.
Send a router solicitation message
FunctionName : add_end Description : add end option of DHCP message Parameters : optptr -- the addr of DHCP message option Returns : the addr of DHCP message option
FunctionName : create_msg Description : create response message Parameters : m -- DHCP message info Returns : none
FunctionName : add_msg_type Description : add TYPE option of DHCP message Parameters : optptr -- the addr of DHCP message option Returns : the addr of DHCP message option
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.
Allocate a new local TCP port.
Deallocates the NAPT tables.
Allocates and initializes the NAPT tables.
Get the forwarding port(s) (as bit mask) for the specified destination mac address
Helper function to pass a pbuf to all ports marked in 'dstports'
Set a network interface as the default network interface (used to output all packets for which no specific route is found)
Return the interface name for the netif matching index or NULL if not found/on error
Report MLD memberships for this interface
Gets the server reachability shift register as described in RFC 5905.
Allocate an index to store data in client_data member of struct netif. Returned value is an index in mentioned array. @see LWIP_NUM_NETIF_CLIENT_DATA
Removes a struct dhcp from a netif. ATTENTION: Only use this when not using dhcp_set_struct() to allocate the struct dhcp since the memory is passed back to the heap.
Sets callback on assigning an IP to the connected client
Starts the DHCP server on the specified network interface
Stops the DHCP server on the specified netif
Get status of time sync After the update is completed, the status will be returned as SNTP_SYNC_STATUS_COMPLETED. After that, the status will be reset to SNTP_SYNC_STATUS_RESET. If the update operation is not completed yet, the status will be SNTP_SYNC_STATUS_RESET. If a smooth mode was chosen and the synchronization is still continuing (adjtime works), then it will be SNTP_SYNC_STATUS_IN_PROGRESS.
Set a callback function for time synchronization notification
system time setter used in the sntp module
lwIP default implementation for itoa() non-standard function. This can be \#defined to itoa() or snprintf(result, bufsize, "%d", number) depending on your platform port.
Allocates a pbuf for referenced data. Referenced data can be volatile (PBUF_REF) or long-lived (PBUF_ROM). The actual memory allocated for the pbuf is determined by the layer at which the pbuf is allocated and the requested size (from the size parameter). - PBUF_ROM: It is assumed that the memory used is really similar to ROM in that it is immutable and will not be changed. Memory which is dynamic should generally not be attached to PBUF_ROM pbufs. Use PBUF_REF instead. - PBUF_REF: It is assumed that the pbuf is only being used in a single thread. If the pbuf gets queued, then pbuf_take should be called to copy the buffer.
Similar to pbuf_header(-size) but de-refs header pbufs for (size >= p->len)
Compare pbuf contents at specified offset with memory s2, both of length n
Find occurrence of mem (with length mem_len) in pbuf p, starting at offset start_offset.
mem_init is not used when using pools instead of a heap or using C library malloc().
mem_trim is not used when using pools instead of a heap or using C library malloc(): we can't free part of a pool element and the stack support mem_trim() to return a different pointer
Initialize custom memory pool. Related functions: memp_malloc_pool, memp_free_pool
Initializes lwIP built-in pools. Related functions: memp_malloc, memp_free Carves out memp_memory into linked lists for each pool-type.
Call netif_poll() in the main loop of your application. This is to prevent reentering non-reentrant functions like tcp_input(). Packets passed to netif_loop_output() are put on a list that is passed to netif->input() by netif_poll().
Set a socket into listen mode. The socket may not have been used for another connection previously.
A minimal implementation of fcntl. Currently only the commands F_GETFL and F_SETFL are implemented. The flag O_NONBLOCK and access modes are supported for F_GETFL, only the flag O_NONBLOCK is implemented for F_SETFL.
Close one end of a full-duplex connection.
Returns an entry containing addresses of address family AF_INET for the host with name name. dns_gethostbyname can return as many address as configured in DNS_MAX_HOST_IP.
Thread-safe variant of lwip_gethostbyname: instead of using a static buffer, this function takes buffer and errno pointers as arguments and uses these for the result.
Translates the name of a service location (for example, a host name) and/or a service name and returns a set of socket addresses and associated information to be used in creating a socket with which to address the specified service. Memory for the result is allocated internally and must be freed by calling lwip_freeaddrinfo()! dns_gethostbyname can return as many address as configured in DNS_MAX_HOST_IP. Also, service names are not supported (only port numbers)! @todo: implement AI_V4MAPPED, AI_ADDRCONFIG
Same as ip_output_if() but 'src' address is not replaced by netif address when it is 'any'.
Add a hop-by-hop options header with a router alert option and padding. Used by MLD when sending a Multicast listener report/done message.
Send an icmpv6 'packet too big' packet. This function must be used only in direct response to a packet that is being received right now. Otherwise, address zones would be lost.
Send an icmpv6 'time exceeded' packet. This function must be used only in direct response to a packet that is being received right now. Otherwise, address zones would be lost.
Processes ICMP input packets, called from ip_input(). Currently only processes icmp echo requests and sends out the echo response.
Send a 'time exceeded' packet, called from ip_forward() if TTL is 0.
Process an input ICMPv6 message. Called by ip6_input. Will generate a reply for echo requests. Other messages are forwarded to nd6_input, or mld6_input.
Creates a new TCP protocol control block but doesn't place it on any of the TCP PCB lists. The pcb is not put on any list until binding using tcp_bind(). @see MEMP_NUM_TCP_PCB_LISTEN and MEMP_NUM_TCP_PCB
Delay accepting a connection in respect to the listen backlog: the number of outstanding connections is increased until tcp_backlog_accepted() is called. ATTENTION: the caller is responsible for calling tcp_backlog_accepted() or else the backlog feature will get out of sync!
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. @see MEMP_NUM_TCP_PCB_LISTEN and MEMP_NUM_TCP_PCB
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.
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.
Hook to generate an Initial Sequence Number (ISN) for a new TCP connection.
The default IPv6 input hook checks if we already have an IPv6 address (netif->ip6_addr[0] is link local), so we drop all incoming IPv6 packets if the input netif has no LL address. LWIP accepts IPv6 multicast packets even if the ip6_addr[] for the given address wasn't set, this may cause trouble if we enable IPv6 SLAAC (LWIP_IPV6_AUTOCONFIG), but have not created any LL address. If the router sends a packet to all nodes 0xff01::1 with RDNSS servers, it would be accepted and rewrite DNS server info with IPv6 values (which won't be routable without any IPv6 address assigned)
Remove all ARP table entries of the specified netif.
Responds to ARP requests to us. Upon ARP replies to us, add entry to cache send out queued IP packets. Updates cache with snooped address pairs. Should be called for incoming ARP packets. The pbuf in the argument is freed by this function. @see pbuf_free()
Renew an existing DHCP lease at the involved DHCP server.
Handle a possible change in the network configuration. This enters the REBOOTING state to verify that the currently bound address is still valid.
check if DHCP supplied netif->ip_addr
The DHCP timer that checks for lease renewal/rebind timeouts. Must be called once a minute (see ).
DHCP transaction timeout handling (this function must be called every 500ms, see ). A DHCP server is expected to respond within a short period of time. This timer checks whether an outstanding DHCP request is timed out.
Stop MLD processing on interface
Periodic timer for mld processing. Must be called every MLD6_TMR_INTERVAL milliseconds (100). When a delaying member expires, a membership report is sent.
Process an input MLD message. Called by icmp6_input.
Join a group on one or all network interfaces. If the group is to be joined on all interfaces, the given group address must not have a zone set (i.e., it must have its zone index set to IP6_NO_ZONE). If the group is to be joined on one particular interface, the given group address may or may not have a zone set.
Leave a group on a network interface. Zoning of address follows the same rules as mld6_joingroup.
Periodic timer for Neighbor discovery functions: - Update neighbor reachability states - Update destination cache entries age - Update invalidation timers of default routers and on-link prefixes - Update lifetimes of our addresses - Perform duplicate address detection (DAD) for our addresses - Send router solicitations
Process an incoming neighbor discovery message
Clear the destination cache. This operation may be necessary for consistency in the light of changing local addresses and/or use of the gateway hook.
Find a router-announced route to the given destination. This route may be based on an on-link prefix or a default router. If a suitable route is found, the returned netif is guaranteed to be in a suitable state (up, link up) to be used for packet transmission.
A packet is to be transmitted to a specific IPv6 destination on a specific interface. Check if we can find the hardware address of the next hop to use for the packet. If so, give the hardware address to the caller, which should use it to send the packet right away. Otherwise, enqueue the packet for later transmission while looking up the hardware address, if possible. As such, this function returns one of three different possible results: - ERR_OK with a non-NULL 'hwaddrp': the caller should send the packet now. - ERR_OK with a NULL 'hwaddrp': the packet has been enqueued for later. - not ERR_OK: something went wrong; forward the error upward in the stack.
Remove all prefix, neighbor_cache and router entries of the specified netif.
The state of a local IPv6 address entry is about to change. If needed, join or leave the solicited-node multicast group for the address.
Initialize the resolver: set up the UDP pcb and configure the default server (if DNS_SERVER_ADDRESS is set).
The DNS resolver client timer - handle retries and timeouts and should be called every DNS_TMR_INTERVAL milliseconds (every second by default).
Resolve a hostname (string) into an IP address. NON-BLOCKING callback version for use with raw API!!! Returns immediately with one of err_t return codes: - ERR_OK if hostname is a valid IP address string or the host name is already in the local names table. - ERR_INPROGRESS enqueue a request to be sent to the DNS server for resolution if no errors are present. - ERR_ARG: dns client not initialized or invalid hostname
Initialize the sys_arch layer
Try to post a message to mailbox from ISR
Return the time left before the next timeout is due. If no timeouts are enqueued, returns 0xffffffff
Sends the pbuf p using UDP. The pbuf is not deallocated. The datagram will be sent to the current remote_ip & remote_port stored in pcb. If the pcb is not bound to a port, it will automatically be bound to a random port. @see udp_disconnect() udp_sendto()
This function is called from netif.c when address is changed
Clears expired entries in the ARP table. This function should be called every ARP_TMR_INTERVAL milliseconds (1 second), in order to expire entries in the ARP table.
This function updates the system time. This is a weak-linked function. It is possible to replace all SNTP update functionality by placing a sntp_sync_time() function in the app firmware source. If the default implementation is used, calling sntp_set_sync_mode() allows the time synchronization mode to be changed to instant or smooth. If a callback function is registered via sntp_set_time_sync_notification_cb(), it will be called following time synchronization.
Sets SNTP operating mode. The mode has to be set before init.
Init and start SNTP service
Gets the server reachability shift register as described in RFC 5905.
Get the configured operating mode
Initialize one of the NTP servers by IP address
Obtain one of the currently configured by IP address (or DHCP) NTP servers
Obtain one of the currently configured by name NTP servers.
Send data over a TCP netconn.
Shut down one or both sides of a TCP netconn (doesn't delete it).
Join multicast groups for UDP netconns.
Join multicast groups for UDP netconns.
Receive data (in form of a pbuf) from a TCP netconn
Receive data (in form of a netbuf) from a UDP or RAW netconn
Accept a new connection on a TCP listening netconn.
Bind a netconn to a specific local IP address and port. Binding one netconn twice might not always be checked correctly!
Connect a netconn to a specific remote IP address and port.
Disconnect a netconn from its current peer (only valid for UDP netconns).
Set a TCP netconn into listen mode
Send the raw IP packet to the given address, using a particular outgoing netif and source IP address. An IP header will be prepended to the packet, unless the RAW_FLAGS_HDRINCL flag is set on the PCB. In that case, the packet must include an IP header, which will then be sent as is.
Send the raw IP packet to the address given by raw_connect()
Set the callback function for received packets that match the raw PCB's protocol and binding. The callback function MUST either - eat the packet by calling pbuf_free() and returning non-zero. The packet will not be passed to other raw PCBs or other protocol layers. - not free the packet, and return zero. The packet will be matched against further PCBs and/or forwarded to another protocol layers.
Create a RAW PCB. @see raw_remove()
Create a RAW PCB for specific IP type. @see raw_remove()
Remove an RAW PCB. @see raw_new()
Bind a RAW PCB. @see raw_disconnect()
Connect an RAW PCB. This function is required by upper layers of lwip. Using the raw api you could use raw_sendto() instead This will associate the RAW PCB with the remote address. @see raw_disconnect() and raw_sendto()
Initialize the IGMP module
Start IGMP processing on interface
Stop IGMP processing on interface
Report IGMP memberships for this interface
Called from ip_input() if a new IGMP packet is received.
The igmp timer function (both for NO_SYS=1 and =0) Should be called every IGMP_TMR_INTERVAL milliseconds (100 ms is default).
Send some data on a RAW or UDP pcb contained in a netconn Called from netconn_send
Indicate data has been received from a TCP pcb contained in a netconn Called from netconn_recv
Indicate that a TCP pcb has been accepted Called from netconn_accept
Send some data on a TCP pcb contained in a netconn Called from netconn_write
Return a connection's local or remote address Called from netconn_getaddr
Close or half-shutdown a TCP pcb contained in a netconn Called from netconn_close In contrast to closing sockets, the netconn is not deallocated.
Join multicast groups for UDP netconns. Called from netconn_join_leave_group
Join multicast groups for UDP netconns. Called from netconn_join_leave_group_netif
Create a new pcb of a specific type inside a netconn. Called from netconn_new_with_proto_and_callback.
Delete the pcb inside a netconn. Called from netconn_delete.
Bind a pcb contained in a netconn Called from netconn_bind.
Bind a pcb contained in a netconn to an interface Called from netconn_bind_if.
Connect a pcb contained inside a netconn Called from netconn_connect.
Disconnect a pcb contained inside a netconn Only used for UDP netconns. Called from netconn_disconnect.
Set a TCP pcb contained in a netconn into listen mode Called from netconn_listen.
Called every 500 ms and implements the retransmission timer and the timer that removes PCBs that have been in TIME-WAIT for enough time. It also increments various timers such as the inactivity timer in each PCB. Automatically called from tcp_tmr().
Is called every TCP_FAST_INTERVAL (250 ms) and process data previously "refused" by upper layer (application) and sends delayed ACKs or pending FINs. Automatically called from tcp_tmr().
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
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()
This function is called from netif.c when address is changed or netif is removed
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
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
Error callback function for TCP netconns. Signals conn->sem, posts to all conn mboxes and calls API_EVENT. The application thread has then to decide what to do. @see tcp.h (struct tcp_pcb.err) for parameters
Creates a new address information (addrinfo) structure based on the provided parameters.
Allocate a new socket for a given netconn.
Free a socket. The socket's netconn must have been delete before!
Unregister a previously registered membership. This prevents dropping the membership on socket close. ATTENTION: this function is called from tcpip_thread (or under CORE_LOCK).
Drop all memberships of a socket that were not dropped explicitly via setsockopt. ATTENTION: this function is NOT called from tcpip_thread (or under CORE_LOCK).
Register a new MLD6 membership. On socket close, the membership is dropped automatically. ATTENTION: this function is called from tcpip_thread (or under CORE_LOCK).
Unregister a previously registered MLD6 membership. This prevents dropping the membership on socket close. ATTENTION: this function is called from tcpip_thread (or under CORE_LOCK).
Drop all MLD6 memberships of a socket that were not dropped explicitly via setsockopt. ATTENTION: this function is NOT called from tcpip_thread (or under CORE_LOCK).
Check if any select waiters are waiting on this socket and its events
lwip_getsockopt_callback: only used without CORE_LOCKING to get into the tcpip_thread
lwip_getsockopt_impl: the actual implementation of getsockopt: same argument as lwip_getsockopt, either called directly or through callback
lwip_setsockopt_callback: only used without CORE_LOCKING to get into the tcpip_thread
lwip_setsockopt_impl: the actual implementation of setsockopt: same argument as lwip_setsockopt, either called directly or through callback
Register a new IGMP membership. On socket close, the membership is dropped automatically. ATTENTION: this function is called from tcpip_thread (or under CORE_LOCK).
Initialize all modules. Use this in NO_SYS mode. Use tcpip_init() otherwise.
Actually send an sntp request to a server.
Receive input function for DNS response packets arriving for the dns UDP pcb.
Look up a hostname in the array of known hostnames.
Check whether there are other backup DNS servers available to try
Call dns_check_entry for each entry in dns_table - check all entries.
Parts of the pseudo checksum which are common to IPv4 and IPv6
Parts of the pseudo checksum which are common to IPv4 and IPv6
Calculates the checksum with IPv6 pseudo header used by TCP and UDP for a pbuf chain. IPv6 addresses are expected to be in network byte order. Will only compute for a portion of the payload.
Calculate a checksum over a chain of pbufs (without pseudo-header, much like inet_chksum only pbufs are used).
Fragment an IPv6 datagram if too large for the netif or path MTU. Chop the datagram in MTU sized chunks and send them in order by pointing PBUF_REFs into p
Dummy IPv6 output function for netifs not supporting IPv6
Dummy IPv4 output function for netifs not supporting IPv4
This function is called from netif.c when address is changed
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.
Called by tcp_input() when a segment arrives for a listening connection (from tcp_input()).
Remove segments from a list if the incoming ACK acknowledges them
Called by tcp_output() to actually send a TCP segment over IP.
Timer callback function that calls tcp_tmr() and reschedules itself.
Common code to see if the current input packet matches the pcb (current input packet is accessed via ip(4/6)_current_* macros)
Ensure DHCP PCB is allocated and bound
A DHCP negotiation transaction, or ARP request, has timed out. The timer that was started with the DHCP or ARP request has timed out, indicating no response was received in time.
The renewal period has timed out.
The rebind period has timed out.
If an incoming DHCP message is in response to us, then trigger the state machine
Decline an offered lease. Tell the DHCP server we do not accept the offered address. One reason to decline the lease is when we find out the address is already in use by another host (through ARP).
Rebind with a DHCP server for an existing DHCP lease.
Update (or insert) a IP/MAC address pair in the ARP cache. If a pending entry is resolved, any queued packets will be sent at this point. @see pbuf_free()
Just a small helper function that sends a pbuf to an ethernet address in the arp_table specified by the index 'arp_idx'.
Remove a group from netif's igmp group list, but don't free it yet
Called if a timeout for one group is reached. Sends a report for this group.
Sends an IP packet on a network interface. This function constructs the IP header and calculates the IP header checksum. If the source IP address is NULL, the IP address of the outgoing network interface is filled in as source address.
Return true if the current input packet should be accepted on this netif
Send an ICMPv6 packet in response to an incoming packet. Call this function if the packet is NOT sent as a direct response to an incoming packet, but rather sometime later (e.g. for a fragment reassembly timeout). The caller must provide the zoned source and destination addresses from the original packet with the src_addr and dest_addr parameters. The reason for this approach is that while the addresses themselves are part of the original packet, their zone information is not, thus possibly resulting in a link-local response being sent over the wrong link.
Return true if the current input packet should be accepted on this netif
Remove a group from the mld_group_list, but do not free it yet
A local address has been determined to be a duplicate. Take the appropriate action(s) on the address and the interface as a whole.
Queue a packet for a neighbor.
Create a new destination cache entry. If no unused entry is found, will recycle oldest entry.
Determine whether an address matches an on-link prefix or the subnet of a statically assigned address.
Find an entry for a default router.
Create a new entry for a default router.
Find the cached entry for an on-link prefix.
Creates a new entry for an on-link prefix.
Determine the next hop for a destination. Will determine if the destination is on-link, else a suitable on-link router is selected. The last entry index is cached for fast entry search.
A real simple and slow implementation of an auto-learning forwarding database that remembers known src mac addresses to know which port to send frames destined for that mac address. ATTENTION: This is meant as an example only, in real-world use, you should provide a better implementation :-)
Walk our list of auto-learnt fdb entries and return a port to forward or BR_FLOOD if unknown
Timer callback for fdb aging, called once per second
Send a pbuf doing the necessary SLIP encapsulation Uses the serial layer's sio_send()
Like slipif_rxbyte, but passes completed packets to netif->input
This function is implemented only in FreeRTOS port (ingroup sys_sem) and has no official API counterpart in lwip's sys.h declarations Signals a semaphore from ISR
FunctionName : add_offer_options Description : add OFFER option of DHCP message Parameters : optptr -- the addr of DHCP message option Returns : the addr of DHCP message option
FunctionName : dhcps_response_ip_set Description : set the ip address for sending to the DHCP client Parameters : m -- DHCP message info ip4_out -- ip address for sending Returns : none
Helper function for tcp_netif_ip_addr_changed() that iterates a pcb list
NAPT for a forwarded packet. It checks weather we need NAPT and modify the packet source address and port if needed.
NAPT for an input packet. It checks weather the destination is on NAPT table and modify the packet destination address and port if needed.
Initialize a custom pbuf (already allocated). Example of custom pbuf usage: zerocopyrx
Remove a network interface from the list of lwIP netifs.
Called by a driver when its link goes down
Change an IPv6 address of a network interface
Create a link-local IPv6 address on a netif (stored in slot 0)
This function allows for the easy addition of a new IPv6 address to an interface. It takes care of finding an empty slot and then sets the address tentative (to make sure that all the subsequent processing happens).
Add extended netif events listener
Remove extended netif events listener
Initialize the TCP ISN module, with the boot time and a secret.
This function calls dhcp_release_and_stop() internally. @deprecated Use dhcp_release_and_stop() instead.
Obtain one of the currently configured DNS server.
Gets DNS server associated with this DHCP server
Creates new DHCP server object
Deletes supplied DHPC server object @warning This may not delete the handle immediately if the server wasn't stopped properly, but mark for deleting once the timer callback occurs
Gets the DHCP server option info
Tries to find IP address corresponding to the supplied MAC
Sets DNS server address for the DHCP server
Initialize this module: - initialize all sub modules - start the tcpip_thread
Set the sync mode Modes allowed: SNTP_SYNC_MODE_IMMED and SNTP_SYNC_MODE_SMOOTH.
Initialization function passed to netif_add(). ATTENTION: A pointer to a must be passed as 'state' to netif_add when adding the bridge. I supplies MAC address and controls memory allocation (number of ports, FDB size).
Add a static entry to the forwarding database. A static entry marks where frames to a specific eth address (unicast or group address) are forwarded. bits [0..(BRIDGEIF_MAX_PORTS-1)]: hw ports bit [BRIDGEIF_MAX_PORTS]: cpu port 0: drop
Remove a static entry from the forwarding database
Same as ipaddr_ntoa, but reentrant since a user-supplied buffer is used.
Set netbios name. ATTENTION: the hostname must be less than 15 characters! the NetBIOS name spec says the name MUST be upper case, so incoming name is forced into uppercase :-)
Enable/Disable NAPT for a specified interface.
system time getter used in the sntp module
lwIP default implementation for stricmp() non-standard function. This can be \#defined to stricmp() depending on your platform port.
lwIP default implementation for strnstr() non-standard function. This can be \#defined to strnstr() depending on your platform port.
lwIP default implementation for strnistr() non-standard function. This can be \#defined to strnistr() depending on your platform port.
Checks if a netmask is valid (starting with ones, then only zeros)
Adjusts the payload pointer to hide or reveal headers in the payload. Adjusts the ->payload pointer so that space for a header (dis)appears in the pbuf payload. The ->payload, ->tot_len and ->len fields are adjusted. PBUF_ROM and PBUF_REF type buffers cannot have their sizes increased, so the call will fail. A check is made that the increase in header size does not move the payload pointer in front of the start of the buffer.
Dechains the first pbuf from its succeeding pbufs in the chain. Makes p->tot_len field equal to p->len.
Get part of a pbuf's payload as contiguous memory. The returned memory is either a pointer into the pbuf's payload or, if split over multiple pbufs, a copy into the user-supplied buffer.
Creates a single pbuf out of a queue of pbufs. @remark: Either the source pbuf 'p' is freed by this function or the original pbuf 'p' is returned, therefore the caller has to check the result!
Find occurrence of substr with length substr_len in pbuf p, start at offset start_offset WARNING: in contrast to strstr(), this one does not stop at the first \0 in the pbuf/source string!
Get an element from a custom pool.
Put a custom pool element back into its pool.
Add a network interface to the list of lwIP netifs. Same as netif_add but without IPv4 addresses
Change the IP address of a network interface
Change the netmask of a network interface
Change the default gateway for a network interface
Forwards a received packet for input processing with ethernet_input() or ip_input() depending on netif flags. Don't call directly, pass to netif_add() and call netif->input(). Only works if the netif driver correctly sets NETIF_FLAG_ETHARP and/or NETIF_FLAG_ETHERNET flag!
Return the interface index for the netif with name or NETIF_NO_INDEX if not found/on error
LWIP_NETCONN_SEM_PER_THREAD==1: initialize thread-local semaphore
LWIP_NETCONN_SEM_PER_THREAD==1: destroy thread-local semaphore
Maps an interface index to its corresponding name.
Returns the interface index corresponding to name ifname.
Simple interface to ip_output_if. It finds the outgoing network interface and calls upon ip_output_if to do the actual work.
Set a default netif for IPv4 multicast.
Simple interface to ip6_output_if. It finds the outgoing network interface and calls upon ip6_output_if to do the actual work.
Send an icmpv6 'time exceeded' packet, with explicit source and destination addresses. This function may be used to send a response sometime after receiving the packet for which this response is meant. The provided source and destination addresses are used primarily to retain their zone information.
Creates a new TCP protocol control block but doesn't place it on any of the TCP PCB lists. The pcb is not put on any list until binding using tcp_bind(). If memory is not available for creating the new pcb, NULL is returned. @see MEMP_NUM_TCP_PCB_LISTEN and MEMP_NUM_TCP_PCB @internal: Maybe there should be a idle TCP PCB list where these PCBs are put on. Port reservation using tcp_bind() is implemented but allocated pcbs that are not bound can't be killed automatically if wanting to allocate a pcb with higher prio (@see tcp_kill_prio())
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.
Sets the priority of a connection.
Send an ARP request packet probing for an ipaddr. Used to send probe messages for address conflict detection.
Send an ARP request packet announcing an ipaddr. Used to send announce messages for address conflict detection.
Set a statically allocated struct dhcp to work with. Using this prevents dhcp_start to allocate it using mem_malloc.
Inform a DHCP server of our manual configuration. This informs DHCP servers of our fixed IP address configuration by sending an INFORM message. It does not involve DHCP address configuration, it is just here to be nice to the network.
Rebase the timeout times to the current time. This is necessary if sys_check_timeouts() hasn't been called for a long time (e.g. while saving energy) to prevent all timer functions of that period being called.
Sends a message to TCPIP thread to call a function. Caller thread blocks until the function returns. It is recommended to use LWIP_TCPIP_CORE_LOCKING (preferred) or LWIP_NETCONN_SEM_PER_THREAD. If not, a semaphore is created and destroyed on every call which is usually an expensive/slow operation.
Allocate a structure for a static callback message and initialize it. The message has a special type such that lwIP never frees it. This is intended to be used to send "static" messages from interrupt context, e.g. the message is allocated once and posted several times from an IRQ using tcpip_callbackmsg_trycallback(). Example usage: Trigger execution of an ethernet IRQ DPC routine in lwIP thread context. @see tcpip_callbackmsg_trycallback() @see tcpip_callbackmsg_delete()
Free a callback message allocated by tcpip_callbackmsg_new(). @see tcpip_callbackmsg_new()
Try to post a callback-message to the tcpip_thread tcpip_mbox. @see tcpip_callbackmsg_new()
Try to post a callback-message to the tcpip_thread mbox. Same as tcpip_callbackmsg_trycallback but calls sys_mbox_trypost_fromisr(), mainly to help FreeRTOS, where calls differ between task level and ISR level. @see tcpip_callbackmsg_new()
A simple wrapper function that allows you to free a pbuf from interrupt context.
A simple wrapper function that allows you to free heap memory from interrupt context.
Finds (stable) ethernet/IP address pair from ARP table using interface and IP address index.
Possibility to iterate over stable ARP table entries
Set the sync interval of SNTP operation Note: SNTPv4 RFC 4330 enforces a minimum sync interval of 15 seconds. This sync interval will be used in the next attempt update time throught SNTP. To apply the new sync interval call the sntp_restart() function, otherwise, it will be applied after the last interval expired.
Checks if sntp is enabled
Check if a Kiss-of-Death has been received from this server (only valid for SNTP_MAX_SERVERS > 1).
Close a TCP netconn (doesn't delete it).
Receive data (in form of a pbuf) from a TCP netconn
Receive data (in form of a netbuf) from a UDP or RAW netconn
Receive data (in form of a netbuf containing a packet buffer) from a netconn
Send data (in form of a netbuf) to a specific remote IP address and port. Only to be used for UDP and RAW netconns (not TCP).
Bind a netconn to a specific interface and port. Binding one netconn twice might not always be checked correctly!
Create (allocate) and initialize a new netbuf. The netbuf doesn't yet contain a packet buffer!
Let a netbuf reference existing (non-volatile) data.
Chain one netbuf to another (@see pbuf_chain)
Get the data pointer and length of the data inside a netbuf.
Move the current data pointer of a packet buffer contained in a netbuf to the next part. The packet buffer itself is not modified.
Move the current data pointer of a packet buffer contained in a netbuf to the beginning of the packet. The packet buffer itself is not modified.
Call tcp_output for all active pcbs that have TF_NAGLEMEMERR set
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
Create a new pcb of a specific type. Called from lwip_netconn_do_newconn().
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
Callback function that is called when DNS name is resolved (or on timeout). A waiting application thread is waked up by signaling the semaphore.
Receive callback function for UDP netconns. Posts the packet to conn->recvmbox or deletes it on memory error. @see udp.h (struct udp_pcb.recv) for parameters
Receive callback function for RAW netconns. Doesn't 'eat' the packet, only copies it and sends it to conn->recvmbox @see raw.h (struct raw_pcb.recv) for parameters and return value
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
Check whether event_callback should wake up a thread waiting in lwip_poll.
Wait (forever) for a message to arrive in an mbox. While waiting, timeouts are processed.
The main lwIP thread. This thread has exclusive access to lwIP core functions (unless access to them is not locked). Other threads communicate with this thread using message boxes. It also starts all the timers to make sure they are running in the right thread context.
Simple callback function used with tcpip_callback to free a pbuf (pbuf_free has a wrong signature for tcpip_callback)
SNTP processing of received timestamp
Initialize request struct to be sent to server.
DNS found callback when using DNS names as server address.
UDP recv callback for the sntp pcb
Decode a NetBIOS name (from packet to string)
NetBIOS Name service recv callback
Walk through a compact encoded DNS name and return the end of the name.
Compare the "dotted" name "query" with the encoded name "response" to make sure an answer from the DNS server matches the current dns_table entry (otherwise, answers might arrive late for hostname not on the list any more). For now, this function compares case-insensitive to cope with all kinds of servers. This also means that "dns 0x20 bit encoding" must be checked externally, if we want to implement it. Currently, the request is sent exactly as passed in by he user request.
dns_alloc_pcb() - allocates a new pcb (or reuses an existing one) to be used for sending a request
Call dns_call_found for correct response.
Queues a new hostname to resolve and sends out a DNS query for that hostname
Initialize a lwip network interface structure for a loopback interface
Attempt to reclaim some memory from queued out-of-sequence TCP segments if we run out of pool pbufs. It's better to give priority to new packets if we're running out. This must be done in the correct thread context therefore this function can only be used with NO_SYS=0 and through tcpip_callback.
Just a callback function for tcpip_callback() that calls pbuf_free_ooseq().
Queue a call to pbuf_free_ooseq if not already queued.
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
Checks if tcp_write is allowed or not (checks state, snd_buf and snd_queuelen).
Allocate a new local UDP port.
Checks if the offered IP address is already in use. It does this according to the address conflict detection method described in RFC5227.
Remember the configuration offered by a DHCP server.
Back-off the DHCP client (because of a received NAK response). Back-off the DHCP client because of a received NAK. Receiving a NAK means the client asked for something non-sensible, for example when it tries to renew a lease obtained on another network. We clear any existing set IP address and restart DHCP negotiation afresh (as per RFC2131 3.2.3).
Handle conflict information from ACD module
Extract the DHCP message and the DHCP options. Extract the DHCP message and the DHCP options, each into a contiguous piece of memory. As a DHCP message is variable sized by its options, and also allows overriding some fields for options, the easy approach is to first unfold the options into a contiguous piece of memory, and use that further on.
Free a complete queue of etharp entries
We received a router advertisement that contains a prefix with the autoconfiguration flag set. Add or update an associated autogenerated address.
Aging implementation of our simple fdb
Send a pbuf doing the necessary SLIP encapsulation Uses the serial layer's sio_send()
Send a pbuf doing the necessary SLIP encapsulation Uses the serial layer's sio_send()
Handle the incoming SLIP stream character by character
The SLIP input thread. Feed the IP layer with incoming packets
SLIP netif initialization Call the arch specific sio_open and remember the opened device in the state field of the netif.
Polls the serial device and feeds the IP layer with incoming packets.
Opens a serial device for communication.
Reads from the serial device.
Tries to read from the serial device. Same as sio_read but returns immediately if no data is available and never blocks.
Re-implement ping_init and ping_deinit with the APIs from ping_sock.h for back-ward compatibility sake. It's highly recommended that users should use the new APIs from ping_sock.h. ToDo: ping.h and esp_ping.h are deprecated now and should be removed in idf v5.x.
FunctionName : node_insert_to_list Description : insert the node to the list Parameters : phead -- the head node of the list pinsert -- the insert node of the list Returns : none
FunctionName : handle_dhcp Description : If an incoming DHCP message is in response to us, then trigger the state machine Parameters : arg -- arg user supplied argument (udp_pcb.recv_arg) pcb -- the udp_pcb which received data p -- the packet buffer that was received addr -- the remote IP address from which the packet was received port -- the remote port from which the packet was received Returns : none
FunctionName : dhcps_poll_set Description : set ip poll from start to end for station Parameters : ip -- The current ip addr Returns : none
FunctionName : kill_oldest_dhcps_pool Description : remove the oldest node from list Parameters : none Returns : none
FunctionName : send_offer Description : DHCP message OFFER Response Parameters : m -- DHCP message info Returns : none
FunctionName : send_ack Description : DHCP message ACK Response Parameters : m -- DHCP message info Returns : none
FunctionName : send_nak Description : DHCP message NACK Response Parameters : m -- DHCP message info Returns : none
FunctionName : parse_options Description : parse DHCP message options Parameters : optptr -- DHCP message option info len -- DHCP message option length Returns : none
FunctionName : parse_msg Description : parse DHCP message from netif Parameters : m -- DHCP message info len -- DHCP message length Returns : DHCP message type
Called when a listen pcb is closed. Iterates one pcb list and removes the closed listener pcb from pcb->listener if matching.
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.
Kills the oldest active connection that has a lower priority than 'prio'.
Kills the oldest connection that is in TIME_WAIT state. Called from tcp_alloc() if no more connections are available.
Enable/Disable NAPT for a specified interface.
Register port mapping on the external interface to internal interface. When the same port mapping is registered again, the old mapping is overwritten. In this implementation, only 1 unique port mapping can be defined for each target address/port.
Unregister port mapping on the external interface to internal interface.
Determine whether an IP address is in a reserved set of addresses that may not be forwarded, or whether datagrams to that destination may be forwarded.
Forwards an IP packet. It finds an appropriate route for the packet, decrements the TTL value of the packet, adjusts the checksum and outputs the packet on the appropriate interface.
Output function of the application port of the bridge (the one with an ip address). The forwarding port(s) where this pbuf is sent on is/are automatically selected from the FDB.
The actual bridge input function. Port netif's input is changed to call here. This function decides where the frame is forwarded.
Helper function to see if a destination mac belongs to the bridge (bridge netif or one of the port netifs), in which case the frame is sent to the cpu only.
Input function for port netifs used to synchronize into tcpip_thread.
Set callback to be called when interface is brought up/down or address is changed while up
Forwards an IPv6 packet. It finds an appropriate route for the packet, decrements the HL value of the packet, and outputs the packet on the appropriate interface.
Receives a single character from the serial device.
Writes to the serial device.
Aborts a blocking sio_read() call.
if not build within lwip, provide translating inlines, that will warn about thread safety