ndp.c File Reference

NDP (Neighbor Discovery Protocol) More...

#include <limits.h>
#include <string.h>
#include "core/net.h"
#include "ipv6/ipv6.h"
#include "ipv6/ipv6_misc.h"
#include "ipv6/icmpv6.h"
#include "ipv6/ndp.h"
#include "ipv6/ndp_cache.h"
#include "ipv6/ndp_misc.h"
#include "ipv6/slaac.h"
#include "mibs/ip_mib_module.h"
#include "debug.h"

Go to the source code of this file.

Macros

#define TRACE_LEVEL   NDP_TRACE_LEVEL
 

Functions

error_t ndpInit (NetInterface *interface)
 Neighbor cache initialization. More...
 
error_t ndpResolve (NetInterface *interface, const Ipv6Addr *ipAddr, MacAddr *macAddr)
 Address resolution using Neighbor Discovery protocol. More...
 
error_t ndpEnqueuePacket (NetInterface *srcInterface, NetInterface *destInterface, const Ipv6Addr *ipAddr, NetBuffer *buffer, size_t offset)
 Enqueue an IPv6 packet waiting for address resolution. More...
 
void ndpTick (NetInterface *interface)
 NDP timer handler. More...
 
void ndpLinkChangeEvent (NetInterface *interface)
 Callback function for link change event. More...
 
void ndpProcessRouterAdv (NetInterface *interface, Ipv6PseudoHeader *pseudoHeader, const NetBuffer *buffer, size_t offset, uint8_t hopLimit)
 Router Advertisement message processing. More...
 
void ndpProcessNeighborSol (NetInterface *interface, Ipv6PseudoHeader *pseudoHeader, const NetBuffer *buffer, size_t offset, uint8_t hopLimit)
 Neighbor Solicitation message processing. More...
 
void ndpProcessNeighborAdv (NetInterface *interface, Ipv6PseudoHeader *pseudoHeader, const NetBuffer *buffer, size_t offset, uint8_t hopLimit)
 Neighbor Advertisement message processing. More...
 
void ndpProcessRedirect (NetInterface *interface, Ipv6PseudoHeader *pseudoHeader, const NetBuffer *buffer, size_t offset, uint8_t hopLimit)
 Redirect message processing. More...
 
error_t ndpSendRouterSol (NetInterface *interface)
 Send a Router Solicitation message. More...
 
error_t ndpSendNeighborSol (NetInterface *interface, const Ipv6Addr *targetIpAddr, bool_t multicast)
 Send a Neighbor Solicitation message. More...
 
error_t ndpSendNeighborAdv (NetInterface *interface, const Ipv6Addr *targetIpAddr, const Ipv6Addr *destIpAddr)
 Send a Neighbor Advertisement message. More...
 
error_t ndpSendRedirect (NetInterface *interface, const Ipv6Addr *targetAddr, const NetBuffer *ipPacket, size_t ipPacketOffset)
 Send a Redirect message. More...
 
void ndpDumpRouterSolMessage (const NdpRouterSolMessage *message)
 Dump Router Solicitation message for debugging purpose. More...
 
void ndpDumpRouterAdvMessage (const NdpRouterAdvMessage *message)
 Dump Router Advertisement message for debugging purpose. More...
 
void ndpDumpNeighborSolMessage (const NdpNeighborSolMessage *message)
 Dump Neighbor Solicitation message for debugging purpose. More...
 
void ndpDumpNeighborAdvMessage (const NdpNeighborAdvMessage *message)
 Dump Neighbor Advertisement message for debugging purpose. More...
 
void ndpDumpRedirectMessage (const NdpRedirectMessage *message)
 Dump Redirect message for debugging purpose. More...
 

Variables

systime_t ndpTickCounter
 

Detailed Description

NDP (Neighbor Discovery Protocol)

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.

Description

The Neighbor Discovery Protocol is responsible for address autoconfiguration of nodes, discovery of the link-layer addresses of other nodes, duplicate address detection, finding available routers and address prefix discovery. Refer to RFC 4861 for more details

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

Definition in file ndp.c.

Macro Definition Documentation

◆ TRACE_LEVEL

#define TRACE_LEVEL   NDP_TRACE_LEVEL

Definition at line 37 of file ndp.c.

Function Documentation

◆ ndpDumpNeighborAdvMessage()

void ndpDumpNeighborAdvMessage ( const NdpNeighborAdvMessage message)

Dump Neighbor Advertisement message for debugging purpose.

Parameters
[in]messageNeighbor Advertisement message

Definition at line 1941 of file ndp.c.

◆ ndpDumpNeighborSolMessage()

void ndpDumpNeighborSolMessage ( const NdpNeighborSolMessage message)

Dump Neighbor Solicitation message for debugging purpose.

Parameters
[in]messageNeighbor Solicitation message

Definition at line 1926 of file ndp.c.

◆ ndpDumpRedirectMessage()

void ndpDumpRedirectMessage ( const NdpRedirectMessage message)

Dump Redirect message for debugging purpose.

Parameters
[in]messageRedirect message

Definition at line 1959 of file ndp.c.

◆ ndpDumpRouterAdvMessage()

void ndpDumpRouterAdvMessage ( const NdpRouterAdvMessage message)

Dump Router Advertisement message for debugging purpose.

Parameters
[in]messageRouter Advertisement message

Definition at line 1906 of file ndp.c.

◆ ndpDumpRouterSolMessage()

void ndpDumpRouterSolMessage ( const NdpRouterSolMessage message)

Dump Router Solicitation message for debugging purpose.

Parameters
[in]messageRouter Solicitation message

Definition at line 1892 of file ndp.c.

◆ ndpEnqueuePacket()

error_t ndpEnqueuePacket ( NetInterface srcInterface,
NetInterface destInterface,
const Ipv6Addr ipAddr,
NetBuffer buffer,
size_t  offset 
)

Enqueue an IPv6 packet waiting for address resolution.

Parameters
[in]srcInterfaceInterface from which the packet has been received
[in]destInterfaceInterface on which the packet should be sent
[in]ipAddrIPv6 address of the destination host
[in]bufferMulti-part buffer containing the packet to be enqueued
[in]offsetOffset to the first byte of the packet
Returns
Error code

Definition at line 190 of file ndp.c.

◆ ndpInit()

error_t ndpInit ( NetInterface interface)

Neighbor cache initialization.

Parameters
[in]interfaceUnderlying network interface
Returns
Error code

Definition at line 66 of file ndp.c.

◆ ndpLinkChangeEvent()

void ndpLinkChangeEvent ( NetInterface interface)

Callback function for link change event.

Parameters
[in]interfaceUnderlying network interface

Definition at line 364 of file ndp.c.

◆ ndpProcessNeighborAdv()

void ndpProcessNeighborAdv ( NetInterface interface,
Ipv6PseudoHeader pseudoHeader,
const NetBuffer buffer,
size_t  offset,
uint8_t  hopLimit 
)

Neighbor Advertisement message processing.

Parameters
[in]interfaceUnderlying network interface
[in]pseudoHeaderIPv6 pseudo header
[in]bufferMulti-part buffer containing the Neighbor Advertisement message
[in]offsetOffset to the first byte of the message
[in]hopLimitHop Limit field from IPv6 header

Definition at line 917 of file ndp.c.

◆ ndpProcessNeighborSol()

void ndpProcessNeighborSol ( NetInterface interface,
Ipv6PseudoHeader pseudoHeader,
const NetBuffer buffer,
size_t  offset,
uint8_t  hopLimit 
)

Neighbor Solicitation message processing.

Parameters
[in]interfaceUnderlying network interface
[in]pseudoHeaderIPv6 pseudo header
[in]bufferMulti-part buffer containing the Neighbor Solicitation message
[in]offsetOffset to the first byte of the message
[in]hopLimitHop Limit field from IPv6 header

Definition at line 683 of file ndp.c.

◆ ndpProcessRedirect()

void ndpProcessRedirect ( NetInterface interface,
Ipv6PseudoHeader pseudoHeader,
const NetBuffer buffer,
size_t  offset,
uint8_t  hopLimit 
)

Redirect message processing.

Parameters
[in]interfaceUnderlying network interface
[in]pseudoHeaderIPv6 pseudo header
[in]bufferMulti-part buffer containing the Redirect message
[in]offsetOffset to the first byte of the message
[in]hopLimitHop Limit field from IPv6 header

Definition at line 1164 of file ndp.c.

◆ ndpProcessRouterAdv()

void ndpProcessRouterAdv ( NetInterface interface,
Ipv6PseudoHeader pseudoHeader,
const NetBuffer buffer,
size_t  offset,
uint8_t  hopLimit 
)

Router Advertisement message processing.

Parameters
[in]interfaceUnderlying network interface
[in]pseudoHeaderIPv6 pseudo header
[in]bufferMulti-part buffer containing the Router Advertisement message
[in]offsetOffset to the first byte of the message
[in]hopLimitHop Limit field from IPv6 header

Definition at line 401 of file ndp.c.

◆ ndpResolve()

error_t ndpResolve ( NetInterface interface,
const Ipv6Addr ipAddr,
MacAddr macAddr 
)

Address resolution using Neighbor Discovery protocol.

Parameters
[in]interfaceUnderlying network interface
[in]ipAddrIPv6 address
[in]macAddrPhysical address matching the specified IPv6 address
Returns
Error code

Definition at line 98 of file ndp.c.

◆ ndpSendNeighborAdv()

error_t ndpSendNeighborAdv ( NetInterface interface,
const Ipv6Addr targetIpAddr,
const Ipv6Addr destIpAddr 
)

Send a Neighbor Advertisement message.

Parameters
[in]interfaceUnderlying network interface
[in]targetIpAddrTarget IPv6 address
[in]destIpAddrDestination IPv6 address
Returns
Error code

Definition at line 1591 of file ndp.c.

◆ ndpSendNeighborSol()

error_t ndpSendNeighborSol ( NetInterface interface,
const Ipv6Addr targetIpAddr,
bool_t  multicast 
)

Send a Neighbor Solicitation message.

Parameters
[in]interfaceUnderlying network interface
[in]targetIpAddrTarget IPv6 address
[in]multicastUnicast or unicast Neighbor Solicitation message
Returns
Error code

Definition at line 1471 of file ndp.c.

◆ ndpSendRedirect()

error_t ndpSendRedirect ( NetInterface interface,
const Ipv6Addr targetAddr,
const NetBuffer ipPacket,
size_t  ipPacketOffset 
)

Send a Redirect message.

Parameters
[in]interfaceUnderlying network interface
[in]targetAddrIPv6 address that is a better first hop to use for the destination address
[in]ipPacketMulti-part buffer that holds the IPv6 packet that triggered the sending of the Redirect
[in]ipPacketOffsetOffset to the first byte of the IPv6 packet
Returns
Error code

Definition at line 1733 of file ndp.c.

◆ ndpSendRouterSol()

error_t ndpSendRouterSol ( NetInterface interface)

Send a Router Solicitation message.

Parameters
[in]interfaceUnderlying network interface
Returns
Error code

Definition at line 1364 of file ndp.c.

◆ ndpTick()

void ndpTick ( NetInterface interface)

NDP timer handler.

Parameters
[in]interfaceUnderlying network interface

Definition at line 274 of file ndp.c.

Variable Documentation

◆ ndpTickCounter

systime_t ndpTickCounter

Definition at line 57 of file ndp.c.