ipv6_misc.h
Go to the documentation of this file.
1 /**
2  * @file ipv6_misc.h
3  * @brief Helper functions for IPv6
4  *
5  * @section License
6  *
7  * SPDX-License-Identifier: GPL-2.0-or-later
8  *
9  * Copyright (C) 2010-2025 Oryx Embedded SARL. All rights reserved.
10  *
11  * This file is part of CycloneTCP Open.
12  *
13  * This program is free software; you can redistribute it and/or
14  * modify it under the terms of the GNU General Public License
15  * as published by the Free Software Foundation; either version 2
16  * of the License, or (at your option) any later version.
17  *
18  * This program is distributed in the hope that it will be useful,
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21  * GNU General Public License for more details.
22  *
23  * You should have received a copy of the GNU General Public License
24  * along with this program; if not, write to the Free Software Foundation,
25  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
26  *
27  * @author Oryx Embedded SARL (www.oryx-embedded.com)
28  * @version 2.5.2
29  **/
30 
31 #ifndef _IPV6_MISC_H
32 #define _IPV6_MISC_H
33 
34 //Dependencies
35 #include "core/net.h"
36 #include "ipv6/ipv6.h"
37 
38 //C++ guard
39 #ifdef __cplusplus
40 extern "C" {
41 #endif
42 
43 //IPv6 related functions
44 void ipv6ChangeAddrState(Ipv6AddrEntry *entry, Ipv6AddrState newState);
46 
47 error_t ipv6SetAddr(NetInterface *interface, uint_t index,
50 
51 void ipv6AddAddr(NetInterface *interface, const Ipv6Addr *addr,
52  uint32_t validLifetime, uint32_t preferredLifetime);
53 
54 void ipv6RemoveAddr(NetInterface *interface, const Ipv6Addr *addr);
55 
56 void ipv6AddPrefix(NetInterface *interface, const Ipv6Addr *prefix,
57  uint_t length, bool_t onLinkFlag, bool_t autonomousFlag,
58  uint32_t validLifetime, uint32_t preferredLifetime);
59 
60 void ipv6RemovePrefix(NetInterface *interface, const Ipv6Addr *prefix,
61  uint_t length);
62 
63 void ipv6AddDefaultRouter(NetInterface *interface, const Ipv6Addr *addr,
64  uint16_t lifetime, uint8_t preference);
65 
66 void ipv6RemoveDefaultRouter(NetInterface *interface, const Ipv6Addr *addr);
67 
68 void ipv6FlushAddrList(NetInterface *interface);
69 void ipv6FlushPrefixList(NetInterface *interface);
71 void ipv6FlushDnsServerList(NetInterface *interface);
72 
75 
78 
79 bool_t ipv6IsOnLink(NetInterface *interface, const Ipv6Addr *ipAddr);
83 
84 bool_t ipv6CompPrefix(const Ipv6Addr *ipAddr1, const Ipv6Addr *ipAddr2,
85  size_t length);
86 
89 
91  const Ipv6Addr *ipAddr2);
92 
94  Ipv6Addr *solicitedNodeAddr);
95 
97 
98 void ipv6UpdateInStats(NetInterface *interface, const Ipv6Addr *destIpAddr,
99  size_t length);
100 
101 void ipv6UpdateOutStats(NetInterface *interface, const Ipv6Addr *destIpAddr,
102  size_t length);
103 
104 //C++ guard
105 #ifdef __cplusplus
106 }
107 #endif
108 
109 #endif
IPv6 (Internet Protocol Version 6)
int bool_t
Definition: compiler_port.h:61
Ipv4Addr destAddr
Definition: ipv4.h:330
void ipv6AddAddr(NetInterface *interface, const Ipv6Addr *addr, uint32_t validLifetime, uint32_t preferredLifetime)
Add a new entry to the list of IPv6 addresses.
Definition: ipv6_misc.c:242
Eui64
Definition: ethernet.h:212
bool_t ipv6IsLocalHostAddr(const Ipv6Addr *ipAddr)
Check whether the specified IPv6 is assigned to the host.
Definition: ipv6_misc.c:1157
uint32_t preferredLifetime
void ipv6AddDefaultRouter(NetInterface *interface, const Ipv6Addr *addr, uint16_t lifetime, uint8_t preference)
Add a new entry to the Default Router List.
Definition: ipv6_misc.c:561
bool_t ipv6IsAnycastAddr(NetInterface *interface, const Ipv6Addr *ipAddr)
Check whether an IPv6 address is an anycast address.
Definition: ipv6_misc.c:1085
Ipv6Addr
Definition: ipv6.h:260
error_t ipv6SelectSourceAddr(NetInterface **interface, const Ipv6Addr *destAddr, Ipv6Addr *srcAddr)
IPv6 source address selection.
Definition: ipv6_misc.c:891
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.
Definition: ipv6_misc.c:117
uint_t ipv6GetAddrScope(const Ipv6Addr *ipAddr)
Retrieve the scope of an IPv6 address.
Definition: ipv6_misc.c:1262
uint32_t lifetime
Definition: ndp.h:480
Ipv6Addr prefix
Ipv6AddrState
IPv6 address state.
Definition: ipv6.h:172
error_t
Error codes.
Definition: error.h:43
error_t ipv6ComputeSolicitedNodeAddr(const Ipv6Addr *ipAddr, Ipv6Addr *solicitedNodeAddr)
Form a solicited-node address from an IPv6 address.
Definition: ipv6_misc.c:1386
uint32_t validLifetime
bool_t ipv6IsTentativeAddr(NetInterface *interface, const Ipv6Addr *ipAddr)
Check whether an IPv6 address is a tentative address.
Definition: ipv6_misc.c:1121
#define NetInterface
Definition: net.h:36
uint_t ipv6GetMulticastAddrScope(const Ipv6Addr *ipAddr)
Retrieve the scope of an IPv6 multicast address.
Definition: ipv6_misc.c:1309
void ipv6UpdateOutStats(NetInterface *interface, const Ipv6Addr *destIpAddr, size_t length)
Update IPv6 output statistics.
Definition: ipv6_misc.c:1473
bool_t ipv6IsOnLink(NetInterface *interface, const Ipv6Addr *ipAddr)
Check whether an IPv6 address is on-link.
Definition: ipv6_misc.c:1041
void ipv6UpdateInStats(NetInterface *interface, const Ipv6Addr *destIpAddr, size_t length)
Update IPv6 input statistics.
Definition: ipv6_misc.c:1445
Eui64 interfaceId
Definition: ipv6cp.h:71
uint8_t length
Definition: tcp.h:375
uint32_t systime_t
System time.
void ipv6FlushPrefixList(NetInterface *interface)
Flush the Prefix List.
Definition: ipv6_misc.c:713
IPv6 address entry.
Definition: ipv6.h:420
void ipv6RemoveAddr(NetInterface *interface, const Ipv6Addr *addr)
Remove an entry from the list of IPv6 addresses.
Definition: ipv6_misc.c:360
void ipv6GenerateLinkLocalAddr(const Eui64 *interfaceId, Ipv6Addr *ipAddr)
Generate a IPv6 link-local address from an interface identifier.
Definition: ipv6_misc.c:1423
bool_t ipv6CompPrefix(const Ipv6Addr *ipAddr1, const Ipv6Addr *ipAddr2, size_t length)
Compare IPv6 address prefixes.
Definition: ipv6_misc.c:1217
void ipv6FlushDefaultRouterList(NetInterface *interface)
Flush the Default Router List.
Definition: ipv6_misc.c:745
void ipv6FlushAddrList(NetInterface *interface)
Flush the list of IPv6 addresses.
Definition: ipv6_misc.c:682
error_t ipv6CheckSourceAddr(NetInterface *interface, const Ipv6Addr *ipAddr)
Source IPv6 address filtering.
Definition: ipv6_misc.c:792
void ipv6FlushDnsServerList(NetInterface *interface)
Flush the list of DNS servers.
Definition: ipv6_misc.c:777
MacAddr srcAddr
Definition: ethernet.h:222
Ipv4Addr ipAddr
Definition: ipcp.h:105
Ipv4Addr addr
Definition: nbns_common.h:123
error_t ipv6CheckDestAddr(NetInterface *interface, const Ipv6Addr *ipAddr)
Destination IPv6 address filtering.
Definition: ipv6_misc.c:815
unsigned int uint_t
Definition: compiler_port.h:57
TCP/IP stack core.
void ipv6ChangeAddrState(Ipv6AddrEntry *entry, Ipv6AddrState newState)
Update IPv6 address state.
Definition: ipv6_misc.c:55
Ipv6AddrState ipv6GetAddrState(NetInterface *interface, const Ipv6Addr *addr)
Get the state of the specified IPv6 address.
Definition: ipv6_misc.c:77
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.
Definition: ipv6_misc.c:401
uint_t ipv6GetCommonPrefixLength(const Ipv6Addr *ipAddr1, const Ipv6Addr *ipAddr2)
Compute the length of the longest common prefix.
Definition: ipv6_misc.c:1336
void ipv6RemovePrefix(NetInterface *interface, const Ipv6Addr *prefix, uint_t length)
Remove an entry from the Prefix List.
Definition: ipv6_misc.c:516
void ipv6RemoveDefaultRouter(NetInterface *interface, const Ipv6Addr *addr)
Remove an entry from the Default Router List.
Definition: ipv6_misc.c:628
Ipv4Addr destIpAddr
Definition: ipcp.h:80