17#ifndef IPV6_INTERFACE_H
18#define IPV6_INTERFACE_H
20#include <basictypes.h>
22#include <ipv6/dhcpv6_internal.h>
24#include <ipv6/ipv6_frames.h>
36#define ADDR_ALL_NODES_LINK_LOCAL IPADDR6::AsciiToIp6("FF02::1")
37#define ADDR_ALL_ROUTERS_LINK_LOCAL IPADDR6::AsciiToIp6("FF02::2")
38#define ADDR_ALL_NB_LINK_LOCAL IPADDR6::AsciiToIp6("FF02::4e42")
39#define ADDR_UNICAST_LINK_LOCAL_PREFIX IPADDR6::AsciiToIp6("FE80::")
40#define ADDR_MLDV2_REPORTS IPADDR6::AsciiToIp6("FF02::16")
42#define IPV6_MULTICAST_NODE_LOCAL 0xFF01
43#define IPV6_MULTICAST_LINK_LOCAL 0xFF02
44#define IPV6_MULTICAST_REALM_LOCAL 0xFF03
45#define IPV6_MULTICAST_ADMIN_LOCAL 0xFF04
46#define IPV6_MULTICAST_SITE_LOCAL 0xFF05
47#define IPV6_MULTICAST_ORG_LOCAL 0xFF08
48#define IPV6_MULTICAST_GLOBAL 0xFF0E
52struct ICMP6_ND_ADVERT;
176class TcpCarrierPacket;
178typedef socket_struct SOCKET;
179typedef SOCKET *PSOCKET;
633inline bool ThisCheck(
void * p) {
return p!=0; }
892 uint32_t m_LastFragCheckSec;
893 uint32_t m_LastRouterSolSec;
894 uint32_t m_RouterSolCount;
895 uint32_t m_LastMLDRepSec;
896 bool m_solicitSendLinkLayer;
897 NB::V6::DHCPv6::DHCPClient *m_pDhcpClient;
907 volatile PoolPtr m_pp_FragmentParts;
908 virtual void TimeElementEvent();
928 if (prefix == NULL) { prefix = FirstPrefix(); }
936 uint16_t CurHopLimit;
937 uint32_t BaseReachableTime_Ticks;
938 uint32_t ReachableTime_Ticks;
939 uint32_t ND_RetranmistTimer_Ticks;
941 uint32_t CalcRandomReachable();
946 uint16_t m_MultiCastMtu;
948 uint8_t m_DefHopCount;
949 volatile bool bHadLink;
950 volatile int m_bStill_Need_To_Process_DupDiscovery_Ticks;
951 volatile bool m_bNeighborTicks;
956 static IPADDR6 NetBurnerMultiCast;
964 void SendTimeExceeded(
PoolPtr pp);
983 void AddDefAddress(
const IPADDR6 &ip);
984 void AddPrefix(
const IPADDR6 &ip,
int len,
int expire);
986 void SendRouterSolicit(
bool sendLinkLayer);
987 void SendDUP_Discover(
const IPADDR6 &ip);
1003 friend class NB::V6::DHCPv6::DHCPClient;
1004 friend void RetransmitV6Packet(
PoolPtr pp, PSOCKET ps);
1005 friend void TcpSendwSum6(PSOCKET ps,
const IPADDR &IPto, TcpCarrierPacket &pkt, BOOL keep, uint32_t data_sum);
1006 friend void TcpSendwSumFrom6(
const IPADDR &IPto,
const IPADDR &IPfrom, TcpCarrierPacket &pkt, BOOL keep, uint32_t data_sum);
1008 friend int Ping6(
const IPADDR6 &to, uint16_t
id, uint16_t seq, uint16_t maxwaitticks,
int size);
1011 static void RootProcessV6(
PoolPtr pp);
1015 void JoinMulticastGroup(
const IPADDR6 &addr);
1016 void LeaveMulticastGroup(
const IPADDR6 &addr);
1018 void LinkLocalIsNowValid();
1019 void ClearDHCPDInfo(
IPV6_DHCPD *pDhcpd = NULL);
1190 inline void StartDHCP_Solicit() { NB::V6::DHCPv6::DHCPClient::ProcessDHCPAvail(
this, (uint8_t)RA_FLAG_MANAGED_IP); }
1195 inline void StartDHCP_InfoReq() { NB::V6::DHCPv6::DHCPClient::ProcessDHCPAvail(
this, (uint8_t)RA_FLAG_OTHER_AVAIL); }
1288 int ping(
const IPADDR6 &ip, uint16_t
id, uint16_t seq, uint16_t wait,
int siz);
Used to hold and manipulate IPv4 and IPv6 addresses in dual stack mode.
Definition ipv6_addr.h:41
bool IsLinkLocal() const
Check if the IP address is the link-local address for the interface.
Definition ipv6_addr.h:175
static IPADDR6 NullIP()
Static function to return a null IPADDR6 object.
Main IPv6 interface management class.
Definition ipv6_interface.h:889
bool RemoveDefaultGateway(const IPADDR6 &ip)
Remove default gateway from interface.
bool IsMyAddress(const IPADDR6 &ip6, bool bMustBePrefered)
Check if IPv6 address belongs to this interface.
void NotifyUnreachable(const IPADDR6 &ip)
Notify that neighbor is unreachable.
void StartDHCP_Solicit()
Start DHCPv6 solicitation process.
Definition ipv6_interface.h:1190
IPADDR6 MySourceAddress(const IPADDR6 &ip)
Determine best source address for communicating with destination.
bool RemoveStaticDNS(const IPADDR6 &ip)
Remove static DNS server from interface.
IPADDR6 MyDNSAddress()
Get DNS server address for this interface.
IPADDR6 GetMyFirstAddress()
Get first configured IPv6 address.
Definition ipv6_interface.h:1247
static IPv6Interface * GetFirst_IP6_Interface()
Get first IPv6 interface in the system.
bool HadLink()
Check if interface has had link connectivity.
Definition ipv6_interface.h:1117
bool OnLink(const IPADDR6 &ip6)
Check if IPv6 address is on-link for this interface.
int SendMLDRegistration(const IPADDR ®Addr, bool joinNotLeave=true)
Send MLD registration message.
IPADDR6 GetMyNextAddress(const IPADDR6 &ip)
Get next IPv6 address after specified address.
Definition ipv6_interface.h:1260
void SetStaticDNS(IPADDR6 dns)
Set static DNS server address.
Definition ipv6_interface.h:1185
void ShowInfo()
Display IPv6 information for this interface.
uint16_t GetDestinationMTU(const IPADDR &ip)
Get destination MTU for specified address.
IPv6Interface(int ifnum)
Constructor for IPv6 interface.
bool RemoveStaticAddress(const IPADDR6 &ip)
Remove static IPv6 address from interface.
IPv6Interface * GetNext_IP6_Interface()
Get next IPv6 interface in the list.
void NotifyReachable(const IPADDR6 &ip6)
Notify that neighbor is reachable.
IPV6_ROUTER * AddDefaultGateway(const IPADDR6 &ip)
Add default gateway to interface.
IPADDR6 m_StaticDNS
Static DNS server address.
Definition ipv6_interface.h:1032
static IPv6Interface * GetInterfaceN(int n)
Get IPv6 interface by interface number.
friend int Ping6(const IPADDR6 &to, uint16_t id, uint16_t seq, uint16_t maxwaitticks, int size)
Send an IPv6 "ping" packet and wait the specified timeout for a response.
IPV6_DNS * AddStaticDNS(const IPADDR6 &ip)
Add static DNS server to interface.
IPV6_PREFIX * AddStaticAddress(const IPADDR6 &ip, int PrefixLen)
Add static IPv6 address to interface.
static IPv6Interface * GetInterfaceForSource(const IPADDR6 &ip)
Find interface that should be used as source for specified destination.
bool HasRoute(const IPADDR6 &ip6)
Check if there is a route to the specified IPv6 address.
void StartDHCP_InfoReq()
Start DHCPv6 information request process.
Definition ipv6_interface.h:1195
friend void InitIPv6(int ifnum)
int ping(const IPADDR6 &ip, uint16_t id, uint16_t seq, uint16_t wait, int siz)
Send IPv6 ping to specified address.
IPV6_PREFIX * m_pMyLinkLocal
Link-local address for this interface.
Definition ipv6_interface.h:1031
static IPv6Interface * GetInterfaceForDestination(const IPADDR6 &ip)
Find interface that can reach the specified destination.
int GetInterfaceNumber()
Get interface number.
Definition ipv6_interface.h:1103
static void ShowAllInfo()
Display IPv6 information for all interfaces.
Used to store and manipulate MAC addresses.
Definition nettypes.h:69
UDP Packet Class.
Definition udp.h:81
int Ping6ViaInterface(const IPADDR &to, uint16_t id, uint16_t seq, uint16_t wait, int interface, int size=32)
Send an IPv6 "ping" packet via a specific network interface.
void ShowIP6Counters()
Display IPv6 counters and statistics.
IPV6_ROOT_EL_TYPE
IPv6 root element types enumeration.
Definition ipv6_interface.h:195
@ IPV6_ROOT_TYPE_DHCPD
DHCPv6 server element.
Definition ipv6_interface.h:199
@ IPV6_ROOT_TYPE_EL_CONTAINER
Element container.
Definition ipv6_interface.h:197
@ IPV6_ROOT_TYPE_DNS
DNS server element.
Definition ipv6_interface.h:201
@ IPV6_ROOT_TYPE_DEST
Destination cache element.
Definition ipv6_interface.h:203
@ IPV6_ROOT_TYPE_PREFIX
Address prefix element.
Definition ipv6_interface.h:200
@ IPV6_ROOT_TYPE_EL
Base root element.
Definition ipv6_interface.h:196
@ IPV6_ROOT_TYPE_ROUTER
Router element.
Definition ipv6_interface.h:198
@ IPV6_ROOT_TYPE_NEIGHBOR
Neighbor cache element.
Definition ipv6_interface.h:202
eMY_NEIGHBOR_STATE
IPv6 neighbor states enumeration.
Definition ipv6_interface.h:749
@ eStale
More than ReachableTime since reachability was confirmed.
Definition ipv6_interface.h:752
@ eProbe
Actively probing neighbor reachability.
Definition ipv6_interface.h:754
@ eDelay
More than ReachableTime, packet sent, waiting for upper layer.
Definition ipv6_interface.h:753
@ eIncomplete
Address resolution in progress.
Definition ipv6_interface.h:750
@ eReachable
Reachability confirmed within ReachableTime.
Definition ipv6_interface.h:751
eMY_ADDR_STATE
IPv6 address states enumeration.
Definition ipv6_interface.h:466
ePrefixSource
IPv6 prefix source enumeration.
Definition ipv6_interface.h:479
eRouteOutResult
Route output result enumeration.
Definition ipv6_interface.h:627
@ eInvalid
Address is invalid.
Definition ipv6_interface.h:470
@ eValid_Depricated
Address is valid but deprecated.
Definition ipv6_interface.h:469
@ eTenative
Address is tentative (duplicate address detection in progress)
Definition ipv6_interface.h:467
@ eValid_Preferred
Address is valid and preferred.
Definition ipv6_interface.h:468
@ eRouter
From router advertisement.
Definition ipv6_interface.h:481
@ eDHCP
From DHCPv6.
Definition ipv6_interface.h:482
@ eStatic
Statically configured.
Definition ipv6_interface.h:483
@ eLinkLocal
Link-local address.
Definition ipv6_interface.h:480
@ eUnknown
Unknown source.
Definition ipv6_interface.h:484
@ eSent
Packet was sent successfully.
Definition ipv6_interface.h:628
@ eDoingND
Performing neighbor discovery.
Definition ipv6_interface.h:629
@ eNoRoute
No route available.
Definition ipv6_interface.h:630
NetBurner IPADDR4 Class. See the IPADDR4 Class page for complete documentation.
IPv6 destination cache element.
Definition ipv6_interface.h:643
uint16_t m_PathMTU
Path MTU to this destination.
Definition ipv6_interface.h:645
virtual bool AgeStillValidTest()
Check if destination is still valid.
virtual void ShowItem()
Display destination information.
bool m_bStaticRoute
True if this is a static route.
Definition ipv6_interface.h:648
int m_nLockCount
Reference count to prevent destruction.
Definition ipv6_interface.h:647
uint32_t m_nSecsLastUsed
Last time this destination was used.
Definition ipv6_interface.h:646
IPV6_DEST * GetNext()
Get next destination in list.
Definition ipv6_interface.h:655
void free_element()
Free resources for this destination.
IPV6_NEIGHBOR * m_pNeighbor
Associated neighbor entry.
Definition ipv6_interface.h:644
DHCPv6 server information element.
Definition ipv6_interface.h:327
virtual void ShowItem()
Display DHCP server information.
uint32_t GetDhcpRebindTime()
Get DHCP rebind time.
Definition ipv6_interface.h:370
void free_element()
Free resources for this DHCP server element.
uint32_t GetDhcpRenewTime()
Get DHCP renew time.
Definition ipv6_interface.h:363
IPV6_PREFIX * FindIA_Addr(IPV6_PREFIX *start)
Find associated IA address starting from given prefix.
uint32_t m_IAID
Identity Association Identifier.
Definition ipv6_interface.h:329
uint32_t m_renewTick
Tick when lease should be renewed.
Definition ipv6_interface.h:330
virtual bool AgeStillValidTest()
Check if DHCP lease is still valid.
uint8_t m_ServerID[CLIENT_LONG_SERVID]
Space to contain the ServerID of the leasing server.
Definition ipv6_interface.h:328
uint32_t m_rebindTick
Tick when lease should be rebound.
Definition ipv6_interface.h:331
IPv6 DNS server information element.
Definition ipv6_interface.h:696
virtual bool AgeStillValidTest()
Check if DNS server is still valid.
IPV6_DNS * GetNext()
Get next DNS server in list.
Definition ipv6_interface.h:706
IPV6_DHCPD * pDHCPD
DHCP server that provided this DNS server.
Definition ipv6_interface.h:699
virtual void ShowItem()
Display DNS server information.
uint32_t m_nSecsToBeValid
Seconds until this DNS entry expires.
Definition ipv6_interface.h:697
void CleanUpAndRemove()
Clean up and remove DNS server from lists.
IPV6_ROUTER * pRouter
Router that provided this DNS server.
Definition ipv6_interface.h:698
void free_element()
Free resources for this DNS server.
DHCPv6 Identity Association address element.
Definition ipv6_interface.h:377
void free_element()
Free resources for this IA address.
virtual void ShowItem()
Display IA address information.
virtual bool AgeStillValidTest()
Check if IA address is still valid.
IPv6 neighbor cache element.
Definition ipv6_interface.h:764
uint8_t m_SentNDCount
Number of neighbor solicitations sent.
Definition ipv6_interface.h:767
uint32_t m_TickTimeOfNextAction
When next action should be taken.
Definition ipv6_interface.h:768
IPV6_NEIGHBOR * GetNext()
Get next neighbor in list.
Definition ipv6_interface.h:785
void Send_ND_Solicit(bool multicast)
Send neighbor solicitation message.
void CoreSendPend(PoolPtr pp)
Queue packet for transmission when neighbor becomes reachable.
virtual bool AgeStillValidTest()
Check if neighbor is still valid.
eRouteOutResult Send(IPv6FrameProcessingStruct &p6proc, uint16_t mtu)
Attempt to send packet via this neighbor.
virtual void ShowItem()
Display neighbor information.
IPV6_ROUTER * m_pRouter
Associated router entry.
Definition ipv6_interface.h:771
PoolPtr m_pOutBound1
First pending outbound packet.
Definition ipv6_interface.h:772
void ProcessTick()
Process timer tick for neighbor discovery.
bool SendPending()
Send any pending packets.
eMY_NEIGHBOR_STATE GetState()
Get current neighbor state.
Definition ipv6_interface.h:859
bool ProcessAdvert(IPv6FrameProcessingStruct &p6proc, ICMP6_ND_ADVERT *pRsp)
Process neighbor advertisement message.
void free_element()
Free resources for this neighbor.
MACADR m_Macaddr
MAC address of this neighbor.
Definition ipv6_interface.h:765
bool StillValidToSend()
Check if neighbor is still valid for sending.
bool m_bActiveTimer
Whether timer processing is active.
Definition ipv6_interface.h:769
void Discard()
Discard pending packets and clean up.
PoolPtr m_pOutBound2
Second pending outbound packet.
Definition ipv6_interface.h:773
IPV6_NEIGHBOR()
Default constructor.
eMY_NEIGHBOR_STATE m_NeighborState
Current neighbor discovery state.
Definition ipv6_interface.h:766
void SetState(eMY_NEIGHBOR_STATE s)
Set neighbor discovery state.
IPv6 prefix and address management element.
Definition ipv6_interface.h:493
eMY_ADDR_STATE GetState()
Get current state of this address.
Definition ipv6_interface.h:550
uint8_t PrefixLen
Prefix length in bits.
Definition ipv6_interface.h:501
void CleanUpAndRemove()
Clean up and remove prefix from lists.
IPV6_ROUTER * pRouter
Router that established this prefix.
Definition ipv6_interface.h:499
bool bOnLink
On-link flag.
Definition ipv6_interface.h:503
virtual void ShowItem()
Display prefix information.
uint32_t GetRemainingDhcpLeaseTime()
Get remaining DHCP lease time.
Definition ipv6_interface.h:589
bool AgeStillPreferred()
Check if prefix is still preferred based on aging.
eMY_ADDR_STATE m_state
Current state of this address.
Definition ipv6_interface.h:494
bool OnLink(const IPADDR6 &ip)
Check if given IP address is on-link for this prefix.
uint32_t GetRemainingDhcpLeasePreferredTime()
Get remaining DHCP preferred time.
Definition ipv6_interface.h:596
void free_element()
Free resources for this prefix.
virtual bool AgeStillValidTest()
Check if prefix is still valid based on aging.
uint32_t time_to_lose_prefered_in_secs_from_establish
Preferred lifetime from establishment.
Definition ipv6_interface.h:495
void CheckTenative()
Check tentative state and perform duplicate address detection.
bool bValidForInterface
Valid for this interface.
Definition ipv6_interface.h:502
uint32_t RemainingValidTime()
Get remaining valid time for this prefix.
Definition ipv6_interface.h:576
uint32_t time_to_lose_valid_in_secs_from_establish
Valid lifetime from establishment.
Definition ipv6_interface.h:496
bool Prefered()
Check if this prefix is preferred.
IPV6_DHCPD * pDHCPD
DHCP server that established this prefix.
Definition ipv6_interface.h:500
IPV6_PREFIX * GetNext()
Get next prefix in list.
Definition ipv6_interface.h:510
ePrefixSource Source()
Get the source of this prefix.
Definition ipv6_interface.h:562
IPV6_PREFIX()
Default constructor.
uint32_t max_valid_time_seen
Maximum valid time seen (for IOL cleanup)
Definition ipv6_interface.h:498
uint32_t time_established_in_secs
When this prefix was established.
Definition ipv6_interface.h:497
Container for managing collections of IPv6 root elements.
Definition ipv6_interface.h:249
void Show()
Display all elements in container.
void Remove(IPV6_ROOT_EL *pEl)
Remove element from container.
void Attach(IPv6Interface &Interface, const char *name)
Attach container to an interface.
IPV6_ROOT_EL * Find(const IPADDR6 &ip, bool age)
Find element by IPv6 address.
void InsertBack(IPV6_ROOT_EL *pEl)
Insert element at the tail of the list.
IPv6Interface * m_pInterface
Interface that owns this container.
Definition ipv6_interface.h:253
void MoveToTop(IPV6_ROOT_EL *pEl)
Move element to top of list.
IPV6_ROOT_EL * m_pHead
Head of element list.
Definition ipv6_interface.h:251
IPV6_ROOT_EL * First()
Get first element in container.
void Insert(IPV6_ROOT_EL *pEl)
Insert element at the head of the list.
IPV6_ROOT_EL_CONTAINER()
Default constructor.
int m_nElements
Number of elements in container.
Definition ipv6_interface.h:254
IPV6_ROOT_EL * m_pTail
Tail of element list.
Definition ipv6_interface.h:252
const char * m_name
Name of this container.
Definition ipv6_interface.h:250
Base class for all IPv6 interface elements.
Definition ipv6_interface.h:213
virtual void free_element()
Free resources associated with this element.
IPV6_ROOT_EL * m_pNext
Next element in list.
Definition ipv6_interface.h:214
IPV6_ROOT_EL_CONTAINER * m_pContainer
Container that owns this element.
Definition ipv6_interface.h:216
IPV6_ROOT_EL * m_pPrev
Previous element in list.
Definition ipv6_interface.h:215
virtual ~IPV6_ROOT_EL()
Virtual destructor.
virtual void ShowItem()
Display information about this element.
IPADDR6 m_IPAddress
IPv6 address associated with this element.
Definition ipv6_interface.h:217
virtual bool AgeStillValidTest()
Test if this element is still valid based on aging.
IPv6 router information element.
Definition ipv6_interface.h:411
IPV6_ROUTER * GetNextValid()
Get next valid router in list.
uint16_t m_PathMTU
Path MTU for this router.
Definition ipv6_interface.h:416
void RemoveFromDefault()
Remove router from default router list.
IPV6_NEIGHBOR * m_pNeighbor
Associated neighbor entry.
Definition ipv6_interface.h:414
IPV6_ROUTER * GetNext()
Get next router in list.
void CleanUpAndRemove()
Clean up and remove router from lists.
virtual void ShowItem()
Display router information.
void free_element()
Free resources for this router.
uint32_t m_SecsLastAdvertise
Seconds since last router advertisement.
Definition ipv6_interface.h:413
virtual bool AgeStillValidTest()
Check if router is still valid.
uint32_t m_Life_In_Secs
Router lifetime in seconds.
Definition ipv6_interface.h:415
uint16_t m_CheckSumCache
Cached checksum value.
Definition ipv6_interface.h:412
IPv6 frame processing structure for packet analysis and header walking.
Definition ipv6_interface.h:69
puint8_t GetDataPointer()
Get pointer to frame data.
Definition ipv6_interface.h:145
bool RouterHeaderParseHasError(puint8_t pData, int *pError_offset)
Check routing header for errors.
EFRAME * GetEframe()
Get pointer to Ethernet frame.
Definition ipv6_interface.h:157
uint8_t WalkNextHeader(int *pError_offset=NULL)
Walk through IPv6 extension headers to the next header.
IPv6FrameProcessingStruct()
Default constructor.
Definition ipv6_interface.h:131
uint8_t * pData
Pointer to current data location.
Definition ipv6_interface.h:72
uint8_t * pLargeData
Used for fragments larger than 1500 bytes.
Definition ipv6_interface.h:74
void release()
Release buffer pool resources.
uint16_t nDataLen
Length of current data segment.
Definition ipv6_interface.h:73
void free_proc_struct()
Free the processing structure and associated resources.
bool HopByHopParseHasError(puint8_t pData, int *pError_offset)
Check hop-by-hop options header for errors.
bool DestOptHasError(puint8_t pData, int *pError_offset)
Check destination options header for errors.
IP6FRAME * pIPf
Pointer to IPv6 frame header.
Definition ipv6_interface.h:71
PoolPtr root_pp
Root buffer pool pointer.
Definition ipv6_interface.h:70
IPv6FrameProcessingStruct(PoolPtr pp)
Constructor with buffer pool.
An OS_CRIT object is used to establish critical sections of code that can only be run by one task at ...
Definition nbrtos.h:1110
Main buffer structure for network and serial communication.
Definition buffers.h:90
uint8_t pData[ETHER_BUFFER_SIZE]
Buffer data payload (1548 bytes)
Definition buffers.h:104