Go to the documentation of this file.
32 #define TRACE_LEVEL NDP_TRACE_LEVEL
48 #if (IPV6_SUPPORT == ENABLED && NDP_ROUTER_ADV_SUPPORT == ENABLED)
70 interface = context->settings.interface;
78 if(interface->linkState && context->
running)
97 settings->maxRtrAdvInterval);
130 interface = context->settings.interface;
167 const NetBuffer *buffer,
size_t offset, uint8_t hopLimit)
180 context = interface->ndpRouterAdvContext;
232 if(option != NULL && option->length == 1)
256 entry->
ipAddr = pseudoHeader->srcAddr;
257 entry->
macAddr = option->linkLayerAddr;
276 entry->
macAddr = option->linkLayerAddr;
303 entry->
macAddr = option->linkLayerAddr;
362 #if (ETH_SUPPORT == ENABLED)
367 interface = context->settings.interface;
377 &pseudoHeader.srcAddr);
407 message->curHopLimit = settings->curHopLimit;
408 message->m = settings->managedFlag;
409 message->o = settings->otherConfigFlag;
410 message->h = settings->homeAgentFlag;
411 message->prf = settings->preference;
412 message->p = settings->proxyFlag;
415 message->reachableTime =
htonl(settings->reachableTime);
426 #if (ETH_SUPPORT == ENABLED)
435 &logicalInterface->macAddr,
sizeof(
MacAddr));
440 if(settings->linkMtu > 0)
445 mtuOption.reserved = 0;
446 mtuOption.mtu =
htonl(settings->linkMtu);
450 (uint8_t *) &mtuOption +
sizeof(
NdpOption),
455 for(i = 0; i < settings->prefixListLength; i++)
461 prefixInfoOption.prefixLength = settings->prefixList[i].length;
462 prefixInfoOption.l = settings->prefixList[i].onLinkFlag;
463 prefixInfoOption.a = settings->prefixList[i].autonomousFlag;
464 prefixInfoOption.r = 0;
465 prefixInfoOption.reserved1 = 0;
466 prefixInfoOption.validLifetime =
htonl(settings->prefixList[i].validLifetime);
467 prefixInfoOption.preferredLifetime =
htonl(settings->prefixList[i].preferredLifetime);
468 prefixInfoOption.reserved2 = 0;
469 prefixInfoOption.prefix = settings->prefixList[i].prefix;
473 (uint8_t *) &prefixInfoOption +
sizeof(
NdpOption),
478 for(i = 0; i < settings->routeListLength; i++)
484 routeInfoOption.prefixLength = settings->routeList[i].length;
485 routeInfoOption.reserved1 = 0;
486 routeInfoOption.prf = settings->routeList[i].preference;
487 routeInfoOption.reserved2 = 0;
488 routeInfoOption.routeLifetime =
htonl(settings->routeList[i].routeLifetime);
489 routeInfoOption.prefix = settings->routeList[i].prefix;
493 (uint8_t *) &routeInfoOption +
sizeof(
NdpOption),
498 for(i = 0; i < settings->contextListLength; i++)
504 contextOption.contextLength = settings->contextList[i].length;
505 contextOption.reserved1 = 0;
506 contextOption.c = settings->contextList[i].compression;
507 contextOption.cid = settings->contextList[i].cid;
508 contextOption.reserved2 = 0;
509 contextOption.validLifetime =
htons(settings->contextList[i].validLifetime);
510 contextOption.contextPrefix = settings->contextList[i].prefix;
525 pseudoHeader.reserved[0] = 0;
526 pseudoHeader.reserved[1] = 0;
527 pseudoHeader.reserved[2] = 0;
NdpNeighborCacheEntry * ndpFindNeighborCacheEntry(NetInterface *interface, const Ipv6Addr *ipAddr)
Search the Neighbor cache for a given IPv6 address.
IPv6 (Internet Protocol Version 6)
#define NDP_MIN_DELAY_BETWEEN_RAS
error_t ndpSendRouterAdv(NdpRouterAdvContext *context, uint16_t routerLifetime)
Send a Router Advertisement message.
NetBuffer * ipAllocBuffer(size_t length, size_t *offset)
Allocate a buffer to hold an IP packet.
@ NDP_ROUTER_SEL_PREFERENCE_MEDIUM
const NetTxAncillary NET_DEFAULT_TX_ANCILLARY
__start_packed struct @6 NdpLinkLayerAddrOption
Source/Target Link-Layer Address option.
Helper functions for NDP (Neighbor Discovery Protocol)
NdpRouterAdvSettings settings
RA service settings.
#define IP_MIB_INC_COUNTER32(name, value)
void ndpDumpRouterSolMessage(const NdpRouterSolMessage *message)
Dump Router Solicitation message for debugging purpose.
__start_packed struct @9 NdpMtuOption
MTU option.
Structure describing a buffer that spans multiple chunks.
systime_t timestamp
Timestamp to manage retransmissions.
void ndpAddOption(void *message, size_t *messageLen, uint8_t type, const void *value, size_t length)
Append an option to a NDP message.
@ NDP_OPT_SOURCE_LINK_LAYER_ADDR
bool_t running
This flag tells whether the RA service is running.
void ndpRouterAdvTick(NdpRouterAdvContext *context)
RA service timer handler.
uint_t routerAdvCount
Router Advertisement message counter.
#define ipv6CompAddr(ipAddr1, ipAddr2)
#define timeCompare(t1, t2)
__start_packed struct @13 NdpContextOption
6LoWPAN Context option (6CO)
#define NDP_DELAY_FIRST_PROBE_TIME
Router advertisement service.
systime_t timestamp
Timestamp to manage entry lifetime.
__start_packed struct @0 MacAddr
MAC address.
ICMPv6 (Internet Control Message Protocol Version 6)
uint32_t netGenerateRandRange(uint32_t min, uint32_t max)
Generate a random value in the specified range.
MacAddr macAddr
Link layer address associated with the IPv6 address.
__start_packed struct @10 NdpRouteInfoOption
Route Information option (RIO)
__start_packed struct @0 NdpRouterSolMessage
Router Solicitation message.
error_t ipv6SelectSourceAddr(NetInterface **interface, const Ipv6Addr *destAddr, Ipv6Addr *srcAddr)
IPv6 source address selection.
void * netBufferAt(const NetBuffer *buffer, size_t offset)
Returns a pointer to the data at the specified position.
@ ERROR_FAILURE
Generic error code.
char_t * macAddrToString(const MacAddr *macAddr, char_t *str)
Convert a MAC address to a dash delimited string.
NdpNeighborCacheEntry * ndpCreateNeighborCacheEntry(NetInterface *interface)
Create a new entry in the Neighbor cache.
const Ipv6Addr IPV6_LINK_LOCAL_ALL_NODES_ADDR
#define NDP_MAX_INITIAL_RTR_ADVERTISEMENTS
void netBufferFree(NetBuffer *buffer)
Dispose a multi-part buffer.
uint_t ndpSendQueuedPackets(NetInterface *interface, NdpNeighborCacheEntry *entry)
Send packets that are waiting for address resolution.
Helper functions for IPv6.
const Ipv6Addr IPV6_UNSPECIFIED_ADDR
#define NDP_MAX_RA_DELAY_TIME
__start_packed struct @7 NdpPrefixInfoOption
Prefix Information option (PIO)
size_t netBufferGetLength(const NetBuffer *buffer)
Get the actual length of a multi-part buffer.
Neighbor and destination cache management.
NDP (Neighbor Discovery Protocol)
#define NDP_MAX_INITIAL_RTR_ADVERT_INTERVAL
uint32_t systime_t
System time.
uint16_t ipCalcUpperLayerChecksumEx(const void *pseudoHeader, size_t pseudoHeaderLen, const NetBuffer *buffer, size_t offset, size_t length)
Calculate IP upper-layer checksum over a multi-part buffer.
Ipv6Addr ipAddr
Unicast IPv6 address.
systime_t ndpRouterAdvTickCounter
void ndpProcessRouterSol(NetInterface *interface, Ipv6PseudoHeader *pseudoHeader, const NetBuffer *buffer, size_t offset, uint8_t hopLimit)
Router Solicitation message processing.
@ NDP_OPT_ROUTE_INFORMATION
NdpState state
Reachability state.
Ipv6AddrState ipv6GetLinkLocalAddrState(NetInterface *interface)
Get the state of the link-local address.
void * ndpGetOption(uint8_t *options, size_t length, uint8_t type)
Search a NDP message for a given option.
@ NDP_OPT_PREFIX_INFORMATION
error_t netBufferSetLength(NetBuffer *buffer, size_t length)
Adjust the length of a multi-part buffer.
#define macCompAddr(macAddr1, macAddr2)
error_t ndpCheckOptions(const uint8_t *options, size_t length)
Check NDP message options.
__start_packed struct @5 NdpOption
Neighbor Discovery option general format.
systime_t timeout
Timeout value.
void ndpDumpRouterAdvMessage(const NdpRouterAdvMessage *message)
Dump Router Advertisement message for debugging purpose.
error_t ipv6SendDatagram(NetInterface *interface, Ipv6PseudoHeader *pseudoHeader, NetBuffer *buffer, size_t offset, NetTxAncillary *ancillary)
Send an IPv6 datagram.
void ndpRouterAdvLinkChangeEvent(NdpRouterAdvContext *context)
Callback function for link change event.
@ IPV6_ADDR_STATE_PREFERRED
An address assigned to an interface whose use is unrestricted.
Helper functions for router advertisement service.
NetInterface * nicGetLogicalInterface(NetInterface *interface)
Retrieve logical interface.
__start_packed struct @1 NdpRouterAdvMessage
Router Advertisement message.
__start_packed struct @0 Ipv6Addr
IPv6 network address.
@ NDP_OPT_6LOWPAN_CONTEXT
const MacAddr MAC_UNSPECIFIED_ADDR
systime_t timeout
Timeout value.
bool_t isRouter
A flag indicating whether the neighbor is a router or a host.
systime_t osGetSystemTime(void)
Retrieve system time.