Helper functions for IPv6. More...
#include "core/net.h"#include "ipv6/ipv6.h"#include "ipv6/ipv6_multicast.h"#include "ipv6/ipv6_misc.h"#include "ipv6/ndp.h"#include "ipv6/ndp_cache.h"#include "mdns/mdns_responder.h"#include "mibs/ip_mib_module.h"#include "debug.h"Go to the source code of this file.
| Macros | |
| #define | TRACE_LEVEL IPV6_TRACE_LEVEL | 
| Functions | |
| void | ipv6ChangeAddrState (Ipv6AddrEntry *entry, Ipv6AddrState newState) | 
| Update IPv6 address state.  More... | |
| Ipv6AddrState | ipv6GetAddrState (NetInterface *interface, const Ipv6Addr *addr) | 
| Get the state of the specified IPv6 address.  More... | |
| error_t | ipv6SetAddr (NetInterface *interface, uint_t index, const Ipv6Addr *addr, Ipv6AddrState state, systime_t validLifetime, systime_t preferredLifetime, bool_t permanent) | 
| Set IPv6 address and address state.  More... | |
| void | ipv6AddAddr (NetInterface *interface, const Ipv6Addr *addr, uint32_t validLifetime, uint32_t preferredLifetime) | 
| Add a new entry to the list of IPv6 addresses.  More... | |
| void | ipv6RemoveAddr (NetInterface *interface, const Ipv6Addr *addr) | 
| Remove an entry from the list of IPv6 addresses.  More... | |
| void | ipv6AddPrefix (NetInterface *interface, const Ipv6Addr *prefix, uint_t length, bool_t onLinkFlag, bool_t autonomousFlag, uint32_t validLifetime, uint32_t preferredLifetime) | 
| Add a new entry to the Prefix List.  More... | |
| void | ipv6RemovePrefix (NetInterface *interface, const Ipv6Addr *prefix, uint_t length) | 
| Remove an entry from the Prefix List.  More... | |
| void | ipv6AddDefaultRouter (NetInterface *interface, const Ipv6Addr *addr, uint16_t lifetime, uint8_t preference) | 
| Add a new entry to the Default Router List.  More... | |
| void | ipv6RemoveDefaultRouter (NetInterface *interface, const Ipv6Addr *addr) | 
| Remove an entry from the Default Router List.  More... | |
| void | ipv6FlushAddrList (NetInterface *interface) | 
| Flush the list of IPv6 addresses.  More... | |
| void | ipv6FlushPrefixList (NetInterface *interface) | 
| Flush the Prefix List.  More... | |
| void | ipv6FlushDefaultRouterList (NetInterface *interface) | 
| Flush the Default Router List.  More... | |
| void | ipv6FlushDnsServerList (NetInterface *interface) | 
| Flush the list of DNS servers.  More... | |
| error_t | ipv6CheckSourceAddr (NetInterface *interface, const Ipv6Addr *ipAddr) | 
| Source IPv6 address filtering.  More... | |
| error_t | ipv6CheckDestAddr (NetInterface *interface, const Ipv6Addr *ipAddr) | 
| Destination IPv6 address filtering.  More... | |
| error_t | ipv6SelectSourceAddr (NetInterface **interface, const Ipv6Addr *destAddr, Ipv6Addr *srcAddr) | 
| IPv6 source address selection.  More... | |
| bool_t | ipv6IsOnLink (NetInterface *interface, const Ipv6Addr *ipAddr) | 
| Check whether an IPv6 address is on-link.  More... | |
| bool_t | ipv6IsAnycastAddr (NetInterface *interface, const Ipv6Addr *ipAddr) | 
| Check whether an IPv6 address is an anycast address.  More... | |
| bool_t | ipv6IsTentativeAddr (NetInterface *interface, const Ipv6Addr *ipAddr) | 
| Check whether an IPv6 address is a tentative address.  More... | |
| bool_t | ipv6IsLocalHostAddr (const Ipv6Addr *ipAddr) | 
| Check whether the specified IPv6 is assigned to the host.  More... | |
| bool_t | ipv6CompPrefix (const Ipv6Addr *ipAddr1, const Ipv6Addr *ipAddr2, size_t length) | 
| Compare IPv6 address prefixes.  More... | |
| uint_t | ipv6GetAddrScope (const Ipv6Addr *ipAddr) | 
| Retrieve the scope of an IPv6 address.  More... | |
| uint_t | ipv6GetMulticastAddrScope (const Ipv6Addr *ipAddr) | 
| Retrieve the scope of an IPv6 multicast address.  More... | |
| uint_t | ipv6GetCommonPrefixLength (const Ipv6Addr *ipAddr1, const Ipv6Addr *ipAddr2) | 
| Compute the length of the longest common prefix.  More... | |
| error_t | ipv6ComputeSolicitedNodeAddr (const Ipv6Addr *ipAddr, Ipv6Addr *solicitedNodeAddr) | 
| Form a solicited-node address from an IPv6 address.  More... | |
| void | ipv6GenerateLinkLocalAddr (const Eui64 *interfaceId, Ipv6Addr *ipAddr) | 
| Generate a IPv6 link-local address from an interface identifier.  More... | |
| void | ipv6UpdateInStats (NetInterface *interface, const Ipv6Addr *destIpAddr, size_t length) | 
| Update IPv6 input statistics.  More... | |
| void | ipv6UpdateOutStats (NetInterface *interface, const Ipv6Addr *destIpAddr, size_t length) | 
| Update IPv6 output statistics.  More... | |
Detailed Description
Helper functions for IPv6.
License
SPDX-License-Identifier: GPL-2.0-or-later
Copyright (C) 2010-2025 Oryx Embedded SARL. All rights reserved.
This file is part of CycloneTCP Open.
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- Version
- 2.5.4
Definition in file ipv6_misc.c.
Macro Definition Documentation
◆ TRACE_LEVEL
| #define TRACE_LEVEL IPV6_TRACE_LEVEL | 
Definition at line 32 of file ipv6_misc.c.
Function Documentation
◆ ipv6AddAddr()
| void ipv6AddAddr | ( | NetInterface * | interface, | 
| const Ipv6Addr * | addr, | ||
| uint32_t | validLifetime, | ||
| uint32_t | preferredLifetime | ||
| ) | 
Add a new entry to the list of IPv6 addresses.
- Parameters
- 
  [in] interface Underlying network interface [in] addr IPv6 address [in] validLifetime Valid lifetime, in seconds [in] preferredLifetime Preferred lifetime, in seconds 
Definition at line 242 of file ipv6_misc.c.
◆ ipv6AddDefaultRouter()
| void ipv6AddDefaultRouter | ( | NetInterface * | interface, | 
| const Ipv6Addr * | addr, | ||
| uint16_t | lifetime, | ||
| uint8_t | preference | ||
| ) | 
Add a new entry to the Default Router List.
- Parameters
- 
  [in] interface Underlying network interface [in] addr IPv6 address of the router [in] lifetime Router lifetime, in seconds [in] preference Preference value 
Definition at line 561 of file ipv6_misc.c.
◆ ipv6AddPrefix()
| void ipv6AddPrefix | ( | NetInterface * | interface, | 
| const Ipv6Addr * | prefix, | ||
| uint_t | length, | ||
| bool_t | onLinkFlag, | ||
| bool_t | autonomousFlag, | ||
| uint32_t | validLifetime, | ||
| uint32_t | preferredLifetime | ||
| ) | 
Add a new entry to the Prefix List.
- Parameters
- 
  [in] interface Underlying network interface [in] prefix IPv6 prefix [in] length The number of leading bits in the prefix that are valid [in] onLinkFlag On-link flag [in] autonomousFlag Autonomous flag [in] validLifetime Valid lifetime, in seconds [in] preferredLifetime Preferred lifetime, in seconds 
Definition at line 401 of file ipv6_misc.c.
◆ ipv6ChangeAddrState()
| void ipv6ChangeAddrState | ( | Ipv6AddrEntry * | entry, | 
| Ipv6AddrState | newState | ||
| ) | 
Update IPv6 address state.
- Parameters
- 
  [in] entry Pointer to an IPv6 address entry [in] newState New state to switch to 
Definition at line 55 of file ipv6_misc.c.
◆ ipv6CheckDestAddr()
| error_t ipv6CheckDestAddr | ( | NetInterface * | interface, | 
| const Ipv6Addr * | ipAddr | ||
| ) | 
Destination IPv6 address filtering.
- Parameters
- 
  [in] interface Underlying network interface [in] ipAddr Destination IPv6 address to be checked 
- Returns
- Error code
Definition at line 815 of file ipv6_misc.c.
◆ ipv6CheckSourceAddr()
| error_t ipv6CheckSourceAddr | ( | NetInterface * | interface, | 
| const Ipv6Addr * | ipAddr | ||
| ) | 
Source IPv6 address filtering.
- Parameters
- 
  [in] interface Underlying network interface [in] ipAddr Source IPv6 address to be checked 
- Returns
- Error code
Definition at line 792 of file ipv6_misc.c.
◆ ipv6CompPrefix()
Compare IPv6 address prefixes.
- Parameters
- 
  [in] ipAddr1 Pointer to the first IPv6 address [in] ipAddr2 Pointer to the second IPv6 address [in] length Prefix length 
- Returns
- TRUE if the prefixes match each other, else FALSE
Definition at line 1217 of file ipv6_misc.c.
◆ ipv6ComputeSolicitedNodeAddr()
Form a solicited-node address from an IPv6 address.
- Parameters
- 
  [in] ipAddr Unicast or anycast address [out] solicitedNodeAddr Corresponding solicited-node address 
- Returns
- Error code
Definition at line 1386 of file ipv6_misc.c.
◆ ipv6FlushAddrList()
| void ipv6FlushAddrList | ( | NetInterface * | interface | ) | 
Flush the list of IPv6 addresses.
- Parameters
- 
  [in] interface Underlying network interface 
Definition at line 682 of file ipv6_misc.c.
◆ ipv6FlushDefaultRouterList()
| void ipv6FlushDefaultRouterList | ( | NetInterface * | interface | ) | 
Flush the Default Router List.
- Parameters
- 
  [in] interface Underlying network interface 
Definition at line 745 of file ipv6_misc.c.
◆ ipv6FlushDnsServerList()
| void ipv6FlushDnsServerList | ( | NetInterface * | interface | ) | 
Flush the list of DNS servers.
- Parameters
- 
  [in] interface Underlying network interface 
Definition at line 777 of file ipv6_misc.c.
◆ ipv6FlushPrefixList()
| void ipv6FlushPrefixList | ( | NetInterface * | interface | ) | 
Flush the Prefix List.
- Parameters
- 
  [in] interface Underlying network interface 
Definition at line 713 of file ipv6_misc.c.
◆ ipv6GenerateLinkLocalAddr()
Generate a IPv6 link-local address from an interface identifier.
- Parameters
- 
  [in] interfaceId Interface identifier [out] ipAddr Corresponding IPv6 link-local address 
Definition at line 1423 of file ipv6_misc.c.
◆ ipv6GetAddrScope()
Retrieve the scope of an IPv6 address.
- Parameters
- 
  [in] ipAddr Pointer to an IPv6 address 
- Returns
- IPv6 address scope
Definition at line 1262 of file ipv6_misc.c.
◆ ipv6GetAddrState()
| Ipv6AddrState ipv6GetAddrState | ( | NetInterface * | interface, | 
| const Ipv6Addr * | addr | ||
| ) | 
Get the state of the specified IPv6 address.
- Parameters
- 
  [in] interface Underlying network interface [in] addr IPv6 address 
- Returns
- Address state
Definition at line 77 of file ipv6_misc.c.
◆ ipv6GetCommonPrefixLength()
Compute the length of the longest common prefix.
- Parameters
- 
  [in] ipAddr1 Pointer to the first IPv6 address [in] ipAddr2 Pointer to the second IPv6 address 
- Returns
- The length of the longest common prefix, in bits
Definition at line 1336 of file ipv6_misc.c.
◆ ipv6GetMulticastAddrScope()
Retrieve the scope of an IPv6 multicast address.
- Parameters
- 
  [in] ipAddr Pointer to an IPv6 multicast address 
- Returns
- IPv6 address scope
Definition at line 1309 of file ipv6_misc.c.
◆ ipv6IsAnycastAddr()
| bool_t ipv6IsAnycastAddr | ( | NetInterface * | interface, | 
| const Ipv6Addr * | ipAddr | ||
| ) | 
Check whether an IPv6 address is an anycast address.
- Parameters
- 
  [in] interface Underlying network interface [in] ipAddr IPv6 address to be checked 
- Returns
- TRUE if the IPv6 address is an anycast address, else FALSE
Definition at line 1085 of file ipv6_misc.c.
◆ ipv6IsLocalHostAddr()
Check whether the specified IPv6 is assigned to the host.
- Parameters
- 
  [in] ipAddr IPv6 address to be checked 
- Returns
- TRUE if the IPv6 address matches any address assigned to the host, else FALSE
Definition at line 1157 of file ipv6_misc.c.
◆ ipv6IsOnLink()
| bool_t ipv6IsOnLink | ( | NetInterface * | interface, | 
| const Ipv6Addr * | ipAddr | ||
| ) | 
Check whether an IPv6 address is on-link.
- Parameters
- 
  [in] interface Underlying network interface [in] ipAddr IPv6 address to be checked 
- Returns
- TRUE if the IPv6 address is on-link, else FALSE
Definition at line 1041 of file ipv6_misc.c.
◆ ipv6IsTentativeAddr()
| bool_t ipv6IsTentativeAddr | ( | NetInterface * | interface, | 
| const Ipv6Addr * | ipAddr | ||
| ) | 
Check whether an IPv6 address is a tentative address.
- Parameters
- 
  [in] interface Underlying network interface [in] ipAddr IPv6 address to be checked 
- Returns
- TRUE if the IPv6 address is a tentative address, else FALSE
Definition at line 1121 of file ipv6_misc.c.
◆ ipv6RemoveAddr()
| void ipv6RemoveAddr | ( | NetInterface * | interface, | 
| const Ipv6Addr * | addr | ||
| ) | 
Remove an entry from the list of IPv6 addresses.
- Parameters
- 
  [in] interface Underlying network interface [in] addr IPv6 address 
Definition at line 360 of file ipv6_misc.c.
◆ ipv6RemoveDefaultRouter()
| void ipv6RemoveDefaultRouter | ( | NetInterface * | interface, | 
| const Ipv6Addr * | addr | ||
| ) | 
Remove an entry from the Default Router List.
- Parameters
- 
  [in] interface Underlying network interface [in] addr IPv6 address of the router to be removed from the list 
Definition at line 628 of file ipv6_misc.c.
◆ ipv6RemovePrefix()
| void ipv6RemovePrefix | ( | NetInterface * | interface, | 
| const Ipv6Addr * | prefix, | ||
| uint_t | length | ||
| ) | 
Remove an entry from the Prefix List.
- Parameters
- 
  [in] interface Underlying network interface [in] prefix IPv6 prefix [in] length The number of leading bits in the prefix that are valid 
Definition at line 516 of file ipv6_misc.c.
◆ ipv6SelectSourceAddr()
| error_t ipv6SelectSourceAddr | ( | NetInterface ** | interface, | 
| const Ipv6Addr * | destAddr, | ||
| Ipv6Addr * | srcAddr | ||
| ) | 
IPv6 source address selection.
This function selects the source address and the relevant network interface to be used in order to join the specified destination address
- Parameters
- 
  [in,out] interface A pointer to a valid network interface may be provided as a hint. The function returns a pointer identifying the interface to be used [in] destAddr Destination IPv6 address [out] srcAddr Local IPv6 address to be used 
- Returns
- Error code
Definition at line 891 of file ipv6_misc.c.
◆ ipv6SetAddr()
| error_t ipv6SetAddr | ( | NetInterface * | interface, | 
| uint_t | index, | ||
| const Ipv6Addr * | addr, | ||
| Ipv6AddrState | state, | ||
| systime_t | validLifetime, | ||
| systime_t | preferredLifetime, | ||
| bool_t | permanent | ||
| ) | 
Set IPv6 address and address state.
- Parameters
- 
  [in] interface Pointer to the desired network interface [in] index Zero-based index [in] addr IPv6 address [in] state State of the IPv6 address [in] validLifetime Valid lifetime [in] preferredLifetime Preferred lifetime [in] permanent Permanently assigned address 
- Returns
- Error code
Definition at line 117 of file ipv6_misc.c.
◆ ipv6UpdateInStats()
| void ipv6UpdateInStats | ( | NetInterface * | interface, | 
| const Ipv6Addr * | destIpAddr, | ||
| size_t | length | ||
| ) | 
Update IPv6 input statistics.
- Parameters
- 
  [in] interface Underlying network interface [in] destIpAddr Destination IP address [in] length Length of the incoming IP packet 
Definition at line 1445 of file ipv6_misc.c.
◆ ipv6UpdateOutStats()
| void ipv6UpdateOutStats | ( | NetInterface * | interface, | 
| const Ipv6Addr * | destIpAddr, | ||
| size_t | length | ||
| ) | 
Update IPv6 output statistics.
- Parameters
- 
  [in] interface Underlying network interface [in] destIpAddr Destination IP address [in] length Length of the outgoing IP packet 
Definition at line 1473 of file ipv6_misc.c.
