Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: mbed-os-example-blinky-gr-lychee GR-Boads_Camera_sample GR-Boards_Audio_Recoder GR-Boads_Camera_DisplayApp ... more
lwip_nd6.c File Reference
Neighbor discovery and stateless address autoconfiguration for IPv6. More...
Go to the source code of this file.
Functions | |
| static s8_t | nd6_find_neighbor_cache_entry (const ip6_addr_t *ip6addr) |
| Search for a neighbor cache entry. | |
| static s8_t | nd6_new_neighbor_cache_entry (void) |
| Create a new neighbor cache entry. | |
| static void | nd6_free_neighbor_cache_entry (s8_t i) |
| Will free any resources associated with a neighbor cache entry, and will mark it as unused. | |
| static s8_t | nd6_find_destination_cache_entry (const ip6_addr_t *ip6addr) |
| Search for a destination cache entry. | |
| static s8_t | nd6_new_destination_cache_entry (void) |
| Create a new destination cache entry. | |
| static s8_t | nd6_is_prefix_in_netif (const ip6_addr_t *ip6addr, struct netif *netif) |
| Determine whether an address matches an on-link prefix. | |
| static s8_t | nd6_select_router (const ip6_addr_t *ip6addr, struct netif *netif) |
| Select a default router for a destination. | |
| static s8_t | nd6_get_router (const ip6_addr_t *router_addr, struct netif *netif) |
| Find an entry for a default router. | |
| static s8_t | nd6_new_router (const ip6_addr_t *router_addr, struct netif *netif) |
| Create a new entry for a default router. | |
| static s8_t | nd6_get_onlink_prefix (ip6_addr_t *prefix, struct netif *netif) |
| Find the cached entry for an on-link prefix. | |
| static s8_t | nd6_new_onlink_prefix (ip6_addr_t *prefix, struct netif *netif) |
| Creates a new entry for an on-link prefix. | |
| static s8_t | nd6_get_next_hop_entry (const ip6_addr_t *ip6addr, struct netif *netif) |
| Determine the next hop for a destination. | |
| static err_t | nd6_queue_packet (s8_t neighbor_index, struct pbuf *q) |
| Queue a packet for a neighbor. | |
| static void | nd6_send_ns (struct netif *netif, const ip6_addr_t *target_addr, u8_t flags) |
| Send a neighbor solicitation message. | |
| static void | nd6_send_na (struct netif *netif, const ip6_addr_t *target_addr, u8_t flags) |
| Send a neighbor advertisement message. | |
| static void | nd6_send_neighbor_cache_probe (struct nd6_neighbor_cache_entry *entry, u8_t flags) |
| Send a neighbor solicitation message for a specific neighbor cache entry. | |
| static err_t | nd6_send_rs (struct netif *netif) |
| Send a router solicitation message. | |
| static void | nd6_free_q (struct nd6_q_entry *q) |
| Free a complete queue of nd6 q entries. | |
| static void | nd6_send_q (s8_t i) |
| Send queued packets for a neighbor. | |
| void | nd6_input (struct pbuf *p, struct netif *inp) |
| Process an incoming neighbor discovery message. | |
| void | nd6_tmr (void) |
| Periodic timer for Neighbor discovery functions: | |
| void | nd6_clear_destination_cache (void) |
| Clear the destination cache. | |
| struct netif * | nd6_find_route (const ip6_addr_t *ip6addr) |
| Find a router-announced route to the given destination. | |
| err_t | nd6_get_next_hop_addr_or_queue (struct netif *netif, struct pbuf *q, const ip6_addr_t *ip6addr, const u8_t **hwaddrp) |
| A packet is to be transmitted to a specific IPv6 destination on a specific interface. | |
| u16_t | nd6_get_destination_mtu (const ip6_addr_t *ip6addr, struct netif *netif) |
| Get the Path MTU for a destination. | |
| void | nd6_reachability_hint (const ip6_addr_t *ip6addr) |
| Provide the Neighbor discovery process with a hint that a destination is reachable. | |
| void | nd6_cleanup_netif (struct netif *netif) |
| Remove all prefix, neighbor_cache and router entries of the specified netif. | |
| void | nd6_adjust_mld_membership (struct netif *netif, s8_t addr_idx, u8_t new_state) |
| The state of a local IPv6 address entry is about to change. | |
Detailed Description
Neighbor discovery and stateless address autoconfiguration for IPv6.
Aims to be compliant with RFC 4861 (Neighbor discovery) and RFC 4862 (Address autoconfiguration).
Definition in file lwip_nd6.c.
Function Documentation
| void nd6_adjust_mld_membership | ( | struct netif * | netif, |
| s8_t | addr_idx, | ||
| u8_t | new_state | ||
| ) |
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.
- Parameters:
-
netif The netif that owns the address. addr_idx The index of the address. new_state The new (IP6_ADDR_) state for the address.
Definition at line 2074 of file lwip_nd6.c.
| void nd6_cleanup_netif | ( | struct netif * | netif ) |
Remove all prefix, neighbor_cache and router entries of the specified netif.
- Parameters:
-
netif points to a network interface
Definition at line 2040 of file lwip_nd6.c.
| void nd6_clear_destination_cache | ( | void | ) |
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.
Definition at line 1332 of file lwip_nd6.c.
| static s8_t nd6_find_destination_cache_entry | ( | const ip6_addr_t * | ip6addr ) | [static] |
Search for a destination cache entry.
- Parameters:
-
ip6addr the IPv6 address of the destination
- Returns:
- The destination cache entry index that matched, -1 if no entry is found
Definition at line 1282 of file lwip_nd6.c.
| static s8_t nd6_find_neighbor_cache_entry | ( | const ip6_addr_t * | ip6addr ) | [static] |
Search for a neighbor cache entry.
- Parameters:
-
ip6addr the IPv6 address of the neighbor
- Returns:
- The neighbor cache entry index that matched, -1 if no entry is found
Definition at line 1123 of file lwip_nd6.c.
| struct netif* nd6_find_route | ( | const ip6_addr_t * | ip6addr ) | [read] |
Find a router-announced route to the given destination.
The caller is responsible for checking whether the returned netif, if any, is in a suitable state (up, link up) to be used for packet transmission.
- Parameters:
-
ip6addr the destination IPv6 address
- Returns:
- the netif to use for the destination, or NULL if none found
Definition at line 1438 of file lwip_nd6.c.
| static void nd6_free_neighbor_cache_entry | ( | s8_t | i ) | [static] |
Will free any resources associated with a neighbor cache entry, and will mark it as unused.
- Parameters:
-
i the neighbor cache entry index to free
Definition at line 1251 of file lwip_nd6.c.
| static void nd6_free_q | ( | struct nd6_q_entry * | q ) | [static] |
Free a complete queue of nd6 q entries.
- Parameters:
-
q a queue of nd6_q_entry to free
Definition at line 1838 of file lwip_nd6.c.
| u16_t nd6_get_destination_mtu | ( | const ip6_addr_t * | ip6addr, |
| struct netif * | netif | ||
| ) |
Get the Path MTU for a destination.
- Parameters:
-
ip6addr the destination address netif the netif on which the packet will be sent
- Returns:
- the Path MTU, if known, or the netif default MTU
Definition at line 1967 of file lwip_nd6.c.
| err_t nd6_get_next_hop_addr_or_queue | ( | struct netif * | netif, |
| struct pbuf * | q, | ||
| const ip6_addr_t * | ip6addr, | ||
| const u8_t ** | hwaddrp | ||
| ) |
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.
- Parameters:
-
netif The lwIP network interface on which the IP packet will be sent. q The pbuf(s) containing the IP packet to be sent. ip6addr The destination IPv6 address of the packet. hwaddrp On success, filled with a pointer to a HW address or NULL (meaning the packet has been queued).
- Returns:
- ERR_OK on success, ERR_RTE if no route was found for the packet, or ERR_MEM if low memory conditions prohibit sending the packet at all.
Definition at line 1926 of file lwip_nd6.c.
| static s8_t nd6_get_next_hop_entry | ( | const ip6_addr_t * | ip6addr, |
| struct netif * | netif | ||
| ) | [static] |
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.
- Parameters:
-
ip6addr the destination address netif the netif on which the packet will be sent
- Returns:
- the neighbor cache entry for the next hop, ERR_RTE if no suitable next hop was found, ERR_MEM if no cache entry could be created
Definition at line 1605 of file lwip_nd6.c.
| static s8_t nd6_get_onlink_prefix | ( | ip6_addr_t * | prefix, |
| struct netif * | netif | ||
| ) | [static] |
Find the cached entry for an on-link prefix.
- Parameters:
-
prefix the IPv6 prefix that is on-link netif the netif on which the prefix is on-link
- Returns:
- the index on the prefix table, or -1 if not found
Definition at line 1546 of file lwip_nd6.c.
| static s8_t nd6_get_router | ( | const ip6_addr_t * | router_addr, |
| struct netif * | netif | ||
| ) | [static] |
Find an entry for a default router.
- Parameters:
-
router_addr the IPv6 address of the router netif the netif on which the router is found, if known
- Returns:
- the index of the router entry, or -1 if not found
Definition at line 1460 of file lwip_nd6.c.
Process an incoming neighbor discovery message.
- Parameters:
-
p the nd packet, p->payload pointing to the icmpv6 header inp the netif on which this packet was received
Definition at line 130 of file lwip_nd6.c.
| static s8_t nd6_is_prefix_in_netif | ( | const ip6_addr_t * | ip6addr, |
| struct netif * | netif | ||
| ) | [static] |
Determine whether an address matches an on-link prefix.
- Parameters:
-
ip6addr the IPv6 address to match
- Returns:
- 1 if the address is on-link, 0 otherwise
Definition at line 1348 of file lwip_nd6.c.
| static s8_t nd6_new_destination_cache_entry | ( | void | ) | [static] |
Create a new destination cache entry.
If no unused entry is found, will recycle oldest entry.
- Returns:
- The destination cache entry index that was created, -1 if no entry was created
Definition at line 1301 of file lwip_nd6.c.
| static s8_t nd6_new_neighbor_cache_entry | ( | void | ) | [static] |
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.
- Returns:
- The neighbor cache entry index that was created, -1 if no entry could be created
Definition at line 1144 of file lwip_nd6.c.
| static s8_t nd6_new_onlink_prefix | ( | ip6_addr_t * | prefix, |
| struct netif * | netif | ||
| ) | [static] |
Creates a new entry for an on-link prefix.
- Parameters:
-
prefix the IPv6 prefix that is on-link netif the netif on which the prefix is on-link
- Returns:
- the index on the prefix table, or -1 if not created
Definition at line 1570 of file lwip_nd6.c.
| static s8_t nd6_new_router | ( | const ip6_addr_t * | router_addr, |
| struct netif * | netif | ||
| ) | [static] |
Create a new entry for a default router.
- Parameters:
-
router_addr the IPv6 address of the router netif the netif on which the router is connected, if known
- Returns:
- the index on the router table, or -1 if could not be created
Definition at line 1485 of file lwip_nd6.c.
Queue a packet for a neighbor.
- Parameters:
-
neighbor_index the index in the neighbor cache table q packet to be queued
- Returns:
- ERR_OK if succeeded, ERR_MEM if out of memory
Definition at line 1727 of file lwip_nd6.c.
| void nd6_reachability_hint | ( | const ip6_addr_t * | ip6addr ) |
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.
- Parameters:
-
ip6addr the destination address which is know to be reachable by an upper layer protocol (TCP)
Definition at line 1997 of file lwip_nd6.c.
| static s8_t nd6_select_router | ( | const ip6_addr_t * | ip6addr, |
| struct netif * | netif | ||
| ) | [static] |
Select a default router for a destination.
- Parameters:
-
ip6addr the destination address netif the netif for the outgoing packet, if known
- Returns:
- the default router entry index, or -1 if no suitable router is found
Definition at line 1377 of file lwip_nd6.c.
| static void nd6_send_na | ( | struct netif * | netif, |
| const ip6_addr_t * | target_addr, | ||
| u8_t | flags | ||
| ) | [static] |
Send a neighbor advertisement message.
- Parameters:
-
netif the netif on which to send the message target_addr the IPv6 target address for the ND message flags one of ND6_SEND_FLAG_*
Definition at line 981 of file lwip_nd6.c.
| static void nd6_send_neighbor_cache_probe | ( | struct nd6_neighbor_cache_entry * | entry, |
| u8_t | flags | ||
| ) | [static] |
Send a neighbor solicitation message for a specific neighbor cache entry.
- Parameters:
-
entry the neightbor cache entry for wich to send the message flags one of ND6_SEND_FLAG_*
Definition at line 899 of file lwip_nd6.c.
| static void nd6_send_ns | ( | struct netif * | netif, |
| const ip6_addr_t * | target_addr, | ||
| u8_t | flags | ||
| ) | [static] |
Send a neighbor solicitation message.
- Parameters:
-
netif the netif on which to send the message target_addr the IPv6 target address for the ND message flags one of ND6_SEND_FLAG_*
Definition at line 912 of file lwip_nd6.c.
| static void nd6_send_q | ( | s8_t | i ) | [static] |
Send queued packets for a neighbor.
- Parameters:
-
i the neighbor to send packets to
Definition at line 1859 of file lwip_nd6.c.
Send a router solicitation message.
- Parameters:
-
netif the netif on which to send the message
Definition at line 1052 of file lwip_nd6.c.
| void nd6_tmr | ( | void | ) |
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
- Perform duplicate address detection (DAD) for our addresses
- Send router solicitations
Definition at line 712 of file lwip_nd6.c.
Generated on Tue Jul 12 2022 11:02:36 by
1.7.2