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/rs.c@103:9cf35a5b9d56, 2019-01-08 (annotated)
- Committer:
- andrewboyson
- Date:
- Tue Jan 08 20:43:21 2019 +0000
- Revision:
- 103:9cf35a5b9d56
- Parent:
- 61:aad055f1b0d1
- Child:
- 119:8e1a7805b801
Updated clock library
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
andrewboyson | 61:aad055f1b0d1 | 1 | #include <stdint.h> |
andrewboyson | 61:aad055f1b0d1 | 2 | #include <stdbool.h> |
andrewboyson | 61:aad055f1b0d1 | 3 | |
andrewboyson | 46:40d33e9037e4 | 4 | #include "log.h" |
andrewboyson | 46:40d33e9037e4 | 5 | #include "net.h" |
andrewboyson | 46:40d33e9037e4 | 6 | #include "ndp.h" |
andrewboyson | 46:40d33e9037e4 | 7 | #include "ip6.h" |
andrewboyson | 46:40d33e9037e4 | 8 | #include "slaac.h" |
andrewboyson | 46:40d33e9037e4 | 9 | #include "action.h" |
andrewboyson | 46:40d33e9037e4 | 10 | #include "mac.h" |
andrewboyson | 46:40d33e9037e4 | 11 | |
andrewboyson | 46:40d33e9037e4 | 12 | bool RsTrace = false; |
andrewboyson | 46:40d33e9037e4 | 13 | |
andrewboyson | 47:73af5c0b0dc2 | 14 | bool RsSendSolicitation = false; |
andrewboyson | 47:73af5c0b0dc2 | 15 | |
andrewboyson | 47:73af5c0b0dc2 | 16 | __packed struct header |
andrewboyson | 47:73af5c0b0dc2 | 17 | { |
andrewboyson | 47:73af5c0b0dc2 | 18 | uint32_t reserved; |
andrewboyson | 47:73af5c0b0dc2 | 19 | }; |
andrewboyson | 46:40d33e9037e4 | 20 | |
andrewboyson | 47:73af5c0b0dc2 | 21 | static void logHeader(void* pPacket, int size) |
andrewboyson | 47:73af5c0b0dc2 | 22 | { |
andrewboyson | 61:aad055f1b0d1 | 23 | struct header* pHeader = (struct header*)pPacket; |
andrewboyson | 47:73af5c0b0dc2 | 24 | char* pData = (char*)pHeader + sizeof(struct header); |
andrewboyson | 47:73af5c0b0dc2 | 25 | int dataLength = size - sizeof(struct header); |
andrewboyson | 47:73af5c0b0dc2 | 26 | |
andrewboyson | 47:73af5c0b0dc2 | 27 | if (NetTraceVerbose) |
andrewboyson | 47:73af5c0b0dc2 | 28 | { |
andrewboyson | 47:73af5c0b0dc2 | 29 | Log("RS header\r\n"); |
andrewboyson | 47:73af5c0b0dc2 | 30 | LogF(" Size %d\r\n", size); |
andrewboyson | 47:73af5c0b0dc2 | 31 | NdpLogOptionsVerbose(pData, dataLength); |
andrewboyson | 47:73af5c0b0dc2 | 32 | } |
andrewboyson | 47:73af5c0b0dc2 | 33 | else |
andrewboyson | 47:73af5c0b0dc2 | 34 | { |
andrewboyson | 47:73af5c0b0dc2 | 35 | Log("RS header"); |
andrewboyson | 47:73af5c0b0dc2 | 36 | NdpLogOptionsQuiet(pData, dataLength); |
andrewboyson | 47:73af5c0b0dc2 | 37 | Log("\r\n"); |
andrewboyson | 47:73af5c0b0dc2 | 38 | } |
andrewboyson | 47:73af5c0b0dc2 | 39 | } |
andrewboyson | 46:40d33e9037e4 | 40 | int RsGetWaitingSolicitation(void* pPacket, int* pSize, uint8_t* pType, uint8_t* pCode) |
andrewboyson | 46:40d33e9037e4 | 41 | { |
andrewboyson | 47:73af5c0b0dc2 | 42 | if (!RsSendSolicitation) return DO_NOTHING; |
andrewboyson | 47:73af5c0b0dc2 | 43 | RsSendSolicitation = false; |
andrewboyson | 46:40d33e9037e4 | 44 | |
andrewboyson | 46:40d33e9037e4 | 45 | *pType = 133; //Router solicitation |
andrewboyson | 46:40d33e9037e4 | 46 | *pCode = 0; |
andrewboyson | 46:40d33e9037e4 | 47 | |
andrewboyson | 61:aad055f1b0d1 | 48 | struct header* pHeader = (struct header*)pPacket; |
andrewboyson | 47:73af5c0b0dc2 | 49 | pHeader->reserved = 0; |
andrewboyson | 47:73af5c0b0dc2 | 50 | |
andrewboyson | 46:40d33e9037e4 | 51 | char* pData = (char*)pHeader + sizeof(struct header); |
andrewboyson | 46:40d33e9037e4 | 52 | char* p = pData; |
andrewboyson | 46:40d33e9037e4 | 53 | p += NdpAddOptionSourceMac(p, MacLocal); |
andrewboyson | 46:40d33e9037e4 | 54 | |
andrewboyson | 46:40d33e9037e4 | 55 | *pSize = sizeof(struct header) + p - pData; |
andrewboyson | 46:40d33e9037e4 | 56 | |
andrewboyson | 46:40d33e9037e4 | 57 | if (RsTrace) |
andrewboyson | 46:40d33e9037e4 | 58 | { |
andrewboyson | 46:40d33e9037e4 | 59 | if (NetTraceNewLine) Log("\r\n"); |
andrewboyson | 46:40d33e9037e4 | 60 | LogTime("NDP send router solicit\r\n"); |
andrewboyson | 47:73af5c0b0dc2 | 61 | logHeader(pPacket, *pSize); |
andrewboyson | 46:40d33e9037e4 | 62 | } |
andrewboyson | 46:40d33e9037e4 | 63 | |
andrewboyson | 46:40d33e9037e4 | 64 | return ActionMakeFromDestAndTrace(MULTICAST_ROUTER, RsTrace && NetTraceStack); |
andrewboyson | 46:40d33e9037e4 | 65 | |
andrewboyson | 46:40d33e9037e4 | 66 | } |