Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: oldheating gps motorhome heating
ip6/icmp/ndp/ra.c
- Committer:
- andrewboyson
- Date:
- 2019-01-29
- Revision:
- 119:8e1a7805b801
- Parent:
- 101:a677d8aee6dd
- Child:
- 137:cf6e7db0e985
File content as of revision 119:8e1a7805b801:
#include <stdint.h>
#include <stdbool.h>
#include "log.h"
#include "clk.h"
#include "net.h"
#include "action.h"
#include "ip6.h"
#include "mac.h"
#include "slaac.h"
#include "ndp.h"
bool RaTrace = false;
__packed struct header
{
uint8_t hop;
uint8_t mo;
uint16_t lifetime;
uint32_t reachable;
uint32_t retrans;
};
void logHeader(struct header* pHeader, char* pData, int dataLength)
{
if (NetTraceVerbose)
{
Log("RA header\r\n");
LogF(" Hop limit %d\r\n", pHeader->hop);
LogF(" M O %x\r\n", pHeader->mo);
LogF(" Lifetime %d\r\n", NetToHost16(pHeader->lifetime));
LogF(" Reachable %d\r\n", NetToHost32(pHeader->reachable));
LogF(" Retrans %d\r\n", NetToHost32(pHeader->retrans));
NdpLogOptionsVerbose(pData, dataLength);
}
else
{
Log("RA header");
NdpLogOptionsQuiet(pData, dataLength);
Log("\r\n");
}
}
int RaHandleReceivedAdvertisement(void (*traceback)(void), void* pPacket, int* pSize)
{
struct header* pHeader = (struct header*)pPacket;
char* pData = (char*)pHeader + sizeof(struct header);
int dataLength = *pSize - sizeof(struct header);
NdpHopLimit = pHeader->hop;
NdpManagedConfiguration = pHeader->mo & 0x80;
NdpOtherConfiguration = pHeader->mo & 0x40;
NdpSetLease (NetToHost16(pHeader->lifetime)); //This resets the NdpElapsedTimer
if (RaTrace)
{
if (NetTraceNewLine) Log("\r\n");
LogTimeF("NDP received router advertise\r\n");
if (NetTraceStack) traceback();
logHeader(pHeader, pData, dataLength);
}
NdpDecodeOptions(pData, dataLength, NdpRouterMac, NULL);
return DO_NOTHING;
}