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
Diff: ip6/icmp/ndp/rs.c
- Revision:
- 61:aad055f1b0d1
- Parent:
- 47:73af5c0b0dc2
- Child:
- 103:9cf35a5b9d56
diff -r 1d8c7a1e7483 -r aad055f1b0d1 ip6/icmp/ndp/rs.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/ip6/icmp/ndp/rs.c Thu Jan 11 17:38:21 2018 +0000
@@ -0,0 +1,67 @@
+#include <stdint.h>
+#include <stdbool.h>
+
+#include "log.h"
+#include "net.h"
+#include "ndp.h"
+#include "ip6.h"
+#include "slaac.h"
+#include "clock.h"
+#include "action.h"
+#include "mac.h"
+
+bool RsTrace = false;
+
+bool RsSendSolicitation = false;
+
+__packed struct header
+{
+ uint32_t reserved;
+};
+
+static void logHeader(void* pPacket, int size)
+{
+ struct header* pHeader = (struct header*)pPacket;
+ char* pData = (char*)pHeader + sizeof(struct header);
+ int dataLength = size - sizeof(struct header);
+
+ if (NetTraceVerbose)
+ {
+ Log("RS header\r\n");
+ LogF(" Size %d\r\n", size);
+ NdpLogOptionsVerbose(pData, dataLength);
+ }
+ else
+ {
+ Log("RS header");
+ NdpLogOptionsQuiet(pData, dataLength);
+ Log("\r\n");
+ }
+}
+int RsGetWaitingSolicitation(void* pPacket, int* pSize, uint8_t* pType, uint8_t* pCode)
+{
+ if (!RsSendSolicitation) return DO_NOTHING;
+ RsSendSolicitation = false;
+
+ *pType = 133; //Router solicitation
+ *pCode = 0;
+
+ struct header* pHeader = (struct header*)pPacket;
+ pHeader->reserved = 0;
+
+ char* pData = (char*)pHeader + sizeof(struct header);
+ char* p = pData;
+ p += NdpAddOptionSourceMac(p, MacLocal);
+
+ *pSize = sizeof(struct header) + p - pData;
+
+ if (RsTrace)
+ {
+ if (NetTraceNewLine) Log("\r\n");
+ LogTime("NDP send router solicit\r\n");
+ logHeader(pPacket, *pSize);
+ }
+
+ return ActionMakeFromDestAndTrace(MULTICAST_ROUTER, RsTrace && NetTraceStack);
+
+}