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 .......
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.
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.\n 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
Increment the reference count of the pbuf.
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.
Count number of pbufs in a chain
Copy (part of) the contents of a packet buffer to an application supplied buffer.
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().
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()
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()
Add a DHCP message trailer Adds the END option to the DHCP message, and if necessary, up to three padding bytes.
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()
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()
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.
Get one byte from the specified position in a pbuf
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.
Send an ethernet packet on the network using netif->linkoutput(). The ethernet header is filled in before sending. @see LWIP_HOOK_VLAN_SET
Same as udp_sendto_if, but with source address
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.
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.
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.
Default receive callback that is called if the user didn't register a recv callback for the pcb.
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.
Same as ip_output_if() but 'src' address is not replaced by netif address when it is 'any'.
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.
Create PBUF_RAM copies of pbufs. Used to queue packets on behalf of the lwIP stack, such as ARP based queueing.
Same as pbuf_take() but puts data at an offset
Skip a number of bytes at the start of a pbuf
Allocates a new pbuf of same length (via pbuf_alloc()) and copies the source pbuf into this new pbuf (using pbuf_copy()).
Put one byte to the specified position in a pbuf WARNING: silently ignores offset >= p->tot_len
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.
Pass a received packet to tcpip_thread for input processing
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.
Adjusts the payload pointer to reveal headers in the payload. @see pbuf_add_header.
Create a TCP segment with prefilled header. Called by tcp_write, tcp_enqueue_flags and tcp_split_unsent_seg
Send an icmp packet in response to an incoming packet.
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.
Similar to pbuf_header(-size) but de-refs header pbufs for (size >= p->len)
Get one byte from the specified position in a pbuf WARNING: returns zero for offset >= p->tot_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.
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()
Receive data (in form of a pbuf) from a TCP netconn
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()).
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.
Calculate a checksum over a chain of pbufs (without pseudo-header, much like inet_chksum only pbufs are used).
Reassembles incoming IP fragments into an IP datagram.
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.
Dummy IPv4 output function for netifs not supporting IPv4
If an incoming DHCP message is in response to us, then trigger the state machine
Just a small helper function that sends a pbuf to an ethernet address in the arp_table specified by the index 'arp_idx'.
Receive input function for DNS response packets arriving for the dns UDP pcb.
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!
Simple interface to ip_output_if. It finds the outgoing network interface and calls upon ip_output_if to do the actual work.
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.
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.
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!
A simple wrapper function that allows you to free a pbuf from interrupt context.
Receive data (in form of a pbuf) from a TCP netconn
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
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
Parts of the pseudo checksum which are common to IPv4 and IPv6
Parts of the pseudo checksum which are common to IPv4 and IPv6
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.
Chain a new pbuf into the pbuf list that composes the datagram. The pbuf list will grow over time as new pbufs are rx. Also checks that the datagram passes basic continuity checks (if the last fragment was received at least once).
Free-callback function to free a 'struct pbuf_custom_ref', called by pbuf_free.
When data has been received in the correct state, try to parse it as a HTTP request.
Data has been received on this pcb. For HTTP 1.0, this should normally only happen once (if the request fits in one packet).
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.
Walk through a compact encoded DNS name and return the end of the name.