ipv6_misc.c File Reference

Helper functions for IPv6. More...

#include "core/net.h"
#include "ipv6/ipv6.h"
#include "ipv6/ipv6_misc.h"
#include "ipv6/ndp.h"
#include "ipv6/ndp_cache.h"
#include "mdns/mdns_responder.h"
#include "debug.h"

Go to the source code of this file.

Macros

#define TRACE_LEVEL   IPV6_TRACE_LEVEL
 

Functions

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 ipv6IsTentativeAddr (NetInterface *interface, const Ipv6Addr *ipAddr)
 Check whether an IPv6 address is a tentative address. More...
 
bool_t ipv6IsAnycastAddr (NetInterface *interface, const Ipv6Addr *ipAddr)
 Check whether an IPv6 address is an anycast address. 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...
 
error_t ipv6MapMulticastAddrToMac (const Ipv6Addr *ipAddr, MacAddr *macAddr)
 Map an IPv6 multicast address to a MAC-layer multicast address. More...
 
void ipv6GenerateLinkLocalAddr (const Eui64 *interfaceId, Ipv6Addr *ipAddr)
 Generate a IPv6 link-local address from an interface identifier. More...
 

Detailed Description

Helper functions for IPv6.

License

Copyright (C) 2010-2018 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.

Author
Oryx Embedded SARL (www.oryx-embedded.com)
Version
1.9.0

Definition in file ipv6_misc.c.

Macro Definition Documentation

◆ TRACE_LEVEL

#define TRACE_LEVEL   IPV6_TRACE_LEVEL

Definition at line 30 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]interfaceUnderlying network interface
[in]addrIPv6 address
[in]validLifetimeValid lifetime, in seconds
[in]preferredLifetimePreferred lifetime, in seconds

Definition at line 221 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]interfaceUnderlying network interface
[in]addrIPv6 address of the router
[in]lifetimeRouter lifetime, in seconds
[in]preferencePreference value

Definition at line 521 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]interfaceUnderlying network interface
[in]prefixIPv6 prefix
[in]lengthThe number of leading bits in the prefix that are valid
[in]onLinkFlagOn-link flag
[in]autonomousFlagAutonomous flag
[in]validLifetimeValid lifetime, in seconds
[in]preferredLifetimePreferred lifetime, in seconds

Definition at line 372 of file ipv6_misc.c.

◆ ipv6CheckDestAddr()

error_t ipv6CheckDestAddr ( NetInterface interface,
const Ipv6Addr ipAddr 
)

Destination IPv6 address filtering.

Parameters
[in]interfaceUnderlying network interface
[in]ipAddrDestination IPv6 address to be checked
Returns
Error code

Definition at line 773 of file ipv6_misc.c.

◆ ipv6CheckSourceAddr()

error_t ipv6CheckSourceAddr ( NetInterface interface,
const Ipv6Addr ipAddr 
)

Source IPv6 address filtering.

Parameters
[in]interfaceUnderlying network interface
[in]ipAddrSource IPv6 address to be checked
Returns
Error code

Definition at line 750 of file ipv6_misc.c.

◆ ipv6CompPrefix()

bool_t ipv6CompPrefix ( const Ipv6Addr ipAddr1,
const Ipv6Addr ipAddr2,
size_t  length 
)

Compare IPv6 address prefixes.

Parameters
[in]ipAddr1Pointer to the first IPv6 address
[in]ipAddr2Pointer to the second IPv6 address
[in]lengthPrefix length
Returns
TRUE if the prefixes match each other, else FALSE

Definition at line 1140 of file ipv6_misc.c.

◆ ipv6ComputeSolicitedNodeAddr()

error_t ipv6ComputeSolicitedNodeAddr ( const Ipv6Addr ipAddr,
Ipv6Addr solicitedNodeAddr 
)

Form a solicited-node address from an IPv6 address.

Parameters
[in]ipAddrUnicast or anycast address
[out]solicitedNodeAddrCorresponding solicited-node address
Returns
Error code

Definition at line 1298 of file ipv6_misc.c.

◆ ipv6FlushAddrList()

void ipv6FlushAddrList ( NetInterface interface)

Flush the list of IPv6 addresses.

Parameters
[in]interfaceUnderlying network interface

Definition at line 640 of file ipv6_misc.c.

◆ ipv6FlushDefaultRouterList()

void ipv6FlushDefaultRouterList ( NetInterface interface)

Flush the Default Router List.

Parameters
[in]interfaceUnderlying network interface

Definition at line 703 of file ipv6_misc.c.

◆ ipv6FlushDnsServerList()

void ipv6FlushDnsServerList ( NetInterface interface)

Flush the list of DNS servers.

Parameters
[in]interfaceUnderlying network interface

Definition at line 735 of file ipv6_misc.c.

◆ ipv6FlushPrefixList()

void ipv6FlushPrefixList ( NetInterface interface)

Flush the Prefix List.

Parameters
[in]interfaceUnderlying network interface

Definition at line 671 of file ipv6_misc.c.

◆ ipv6GenerateLinkLocalAddr()

void ipv6GenerateLinkLocalAddr ( const Eui64 interfaceId,
Ipv6Addr ipAddr 
)

Generate a IPv6 link-local address from an interface identifier.

Parameters
[in]interfaceIdInterface identifier
[out]ipAddrCorresponding IPv6 link-local address

Definition at line 1356 of file ipv6_misc.c.

◆ ipv6GetAddrScope()

uint_t ipv6GetAddrScope ( const Ipv6Addr ipAddr)

Retrieve the scope of an IPv6 address.

Parameters
[in]ipAddrPointer to an IPv6 address
Returns
IPv6 address scope

Definition at line 1184 of file ipv6_misc.c.

◆ ipv6GetAddrState()

Ipv6AddrState ipv6GetAddrState ( NetInterface interface,
const Ipv6Addr addr 
)

Get the state of the specified IPv6 address.

Parameters
[in]interfaceUnderlying network interface
[in]addrIPv6 address
Returns
Address state

Definition at line 52 of file ipv6_misc.c.

◆ ipv6GetCommonPrefixLength()

uint_t ipv6GetCommonPrefixLength ( const Ipv6Addr ipAddr1,
const Ipv6Addr ipAddr2 
)

Compute the length of the longest common prefix.

Parameters
[in]ipAddr1Pointer to the first IPv6 address
[in]ipAddr2Pointer to the second IPv6 address
Returns
The length of the longest common prefix, in bits

Definition at line 1255 of file ipv6_misc.c.

◆ ipv6GetMulticastAddrScope()

uint_t ipv6GetMulticastAddrScope ( const Ipv6Addr ipAddr)

Retrieve the scope of an IPv6 multicast address.

Parameters
[in]ipAddrPointer to an IPv6 multicast address
Returns
IPv6 address scope

Definition at line 1230 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]interfaceUnderlying network interface
[in]ipAddrIPv6 address to be checked
Returns
TRUE if the IPv6 address is an anycast address, else FALSE

Definition at line 1103 of file ipv6_misc.c.

◆ ipv6IsOnLink()

bool_t ipv6IsOnLink ( NetInterface interface,
const Ipv6Addr ipAddr 
)

Check whether an IPv6 address is on-link.

Parameters
[in]interfaceUnderlying network interface
[in]ipAddrIPv6 address to be checked
Returns
TRUE if the IPv6 address is on-link, else FALSE

Definition at line 1023 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]interfaceUnderlying network interface
[in]ipAddrIPv6 address to be checked
Returns
TRUE if the IPv6 address is a tentative address, else FALSE

Definition at line 1067 of file ipv6_misc.c.

◆ ipv6MapMulticastAddrToMac()

error_t ipv6MapMulticastAddrToMac ( const Ipv6Addr ipAddr,
MacAddr macAddr 
)

Map an IPv6 multicast address to a MAC-layer multicast address.

Parameters
[in]ipAddrIPv6 multicast address
[out]macAddrCorresponding MAC-layer multicast address
Returns
Error code

Definition at line 1326 of file ipv6_misc.c.

◆ ipv6RemoveAddr()

void ipv6RemoveAddr ( NetInterface interface,
const Ipv6Addr addr 
)

Remove an entry from the list of IPv6 addresses.

Parameters
[in]interfaceUnderlying network interface
[in]addrIPv6 address

Definition at line 331 of file ipv6_misc.c.

◆ ipv6RemoveDefaultRouter()

void ipv6RemoveDefaultRouter ( NetInterface interface,
const Ipv6Addr addr 
)

Remove an entry from the Default Router List.

Parameters
[in]interfaceUnderlying network interface
[in]addrIPv6 address of the router to be removed from the list

Definition at line 586 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]interfaceUnderlying network interface
[in]prefixIPv6 prefix
[in]lengthThe number of leading bits in the prefix that are valid

Definition at line 477 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]interfaceA pointer to a valid network interface may be provided as a hint. The function returns a pointer identifying the interface to be used
[in]destAddrDestination IPv6 address
[out]srcAddrLocal IPv6 address to be used
Returns
Error code

Definition at line 879 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]interfacePointer to the desired network interface
[in]indexZero-based index
[in]addrIPv6 address
[in]stateState of the IPv6 address
[in]validLifetimeValid lifetime
[in]preferredLifetimePreferred lifetime
[in]permanentPermanently assigned address
Returns
Error code

Definition at line 92 of file ipv6_misc.c.