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 .......
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.
Copy (part of) the contents of a packet buffer to an application supplied buffer.
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.
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.
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.
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()
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()).
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.
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.
Add a DHCP message trailer Adds the END option to the DHCP message, and if necessary, up to three padding bytes.
Copy the contents of one packet buffer into another.
Get one byte from the specified position in a pbuf
Send an ethernet packet on the network using netif->linkoutput(). The ethernet header is filled in before sending. @see LWIP_HOOK_VLAN_SET
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.
Increment the reference count of the pbuf.
Same as udp_sendto_if, but with source address
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.
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().
Get one byte from the specified position in a pbuf WARNING: returns zero for offset >= p->tot_len
Send an ICMPv6 packet in response to an incoming packet. The packet is sent *to* ip_current_src_addr() on ip_current_netif().
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.
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
Copy part or all of one packet buffer into another, to a specified offset.
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().
Pass a received packet to tcpip_thread for input processing
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 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
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.
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.
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 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.
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()).
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.
Create a TCP segment with prefilled header. Called by tcp_write, tcp_enqueue_flags and tcp_split_unsent_seg
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.
Send an icmp packet in response to an incoming packet.
Send an ICMPv6 packet (with srd/dst address and netif given).
Helper function to pass a pbuf to all ports marked in 'dstports'
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.
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.
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)
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()
Process an incoming neighbor discovery message
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.
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()
Receive data (in form of a pbuf) from a TCP netconn
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()
Called from ip_input() if a new IGMP packet is received.
Receive input function for DNS response packets arriving for the dns UDP pcb.
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
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'.
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.
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.
Queue a packet for a neighbor.
Send a pbuf doing the necessary SLIP encapsulation Uses the serial layer's sio_send()
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.
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!
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.
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.
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 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
UDP recv callback for the sntp pcb
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.
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.
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()
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
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.
Input function for port netifs used to synchronize into tcpip_thread.
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.