A stack which works with or without an Mbed os library. Provides IPv4 or IPv6 with a full 1500 byte buffer.
Dependents: oldheating gps motorhome heating
ip6/slaac.cpp@37:793b39683406, 2017-10-04 (annotated)
- Committer:
- andrewboyson
- Date:
- Wed Oct 04 07:51:02 2017 +0000
- Revision:
- 37:793b39683406
- Parent:
- 35:93c39d260a83
- Child:
- 44:83ce5ace337b
Added trace back and trace forward to log messages
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
andrewboyson | 15:6ca6778168b1 | 1 | #include "mbed.h" |
andrewboyson | 15:6ca6778168b1 | 2 | #include "mac.h" |
andrewboyson | 35:93c39d260a83 | 3 | #include "ip6.h" |
andrewboyson | 7:b794780e33b4 | 4 | |
andrewboyson | 7:b794780e33b4 | 5 | char SlaacLinkLocalIp[16]; |
andrewboyson | 15:6ca6778168b1 | 6 | char SlaacGlobalIp[16]; |
andrewboyson | 7:b794780e33b4 | 7 | |
andrewboyson | 35:93c39d260a83 | 8 | bool SlaacIsMe(char* ip) |
andrewboyson | 35:93c39d260a83 | 9 | { |
andrewboyson | 35:93c39d260a83 | 10 | return Ip6IsSame(ip, SlaacLinkLocalIp) || Ip6IsSame(ip, SlaacGlobalIp); |
andrewboyson | 35:93c39d260a83 | 11 | } |
andrewboyson | 35:93c39d260a83 | 12 | |
andrewboyson | 15:6ca6778168b1 | 13 | void SlaacMakeGlobal(char* pPrefix) |
andrewboyson | 15:6ca6778168b1 | 14 | { |
andrewboyson | 15:6ca6778168b1 | 15 | memcpy(SlaacGlobalIp, pPrefix, 8); |
andrewboyson | 15:6ca6778168b1 | 16 | char* p = SlaacGlobalIp + 8; |
andrewboyson | 15:6ca6778168b1 | 17 | *p++ = MacLocal[0] | 0x02; //Modified EUI-64 |
andrewboyson | 15:6ca6778168b1 | 18 | *p++ = MacLocal[1]; |
andrewboyson | 15:6ca6778168b1 | 19 | *p++ = MacLocal[2]; |
andrewboyson | 15:6ca6778168b1 | 20 | *p++ = 0xFF; |
andrewboyson | 15:6ca6778168b1 | 21 | *p++ = 0xFE; |
andrewboyson | 15:6ca6778168b1 | 22 | *p++ = MacLocal[3]; |
andrewboyson | 15:6ca6778168b1 | 23 | *p++ = MacLocal[4]; |
andrewboyson | 15:6ca6778168b1 | 24 | *p++ = MacLocal[5]; |
andrewboyson | 15:6ca6778168b1 | 25 | |
andrewboyson | 15:6ca6778168b1 | 26 | } |
andrewboyson | 7:b794780e33b4 | 27 | void SlaacInit() |
andrewboyson | 7:b794780e33b4 | 28 | { |
andrewboyson | 37:793b39683406 | 29 | char* p = SlaacLinkLocalIp; //fe80::::202:f7ff:fef2:7d27 |
andrewboyson | 7:b794780e33b4 | 30 | *p++ = 0xFE; |
andrewboyson | 7:b794780e33b4 | 31 | *p++ = 0x80; |
andrewboyson | 7:b794780e33b4 | 32 | *p++ = 0x00; |
andrewboyson | 7:b794780e33b4 | 33 | *p++ = 0x00; |
andrewboyson | 7:b794780e33b4 | 34 | *p++ = 0x00; |
andrewboyson | 7:b794780e33b4 | 35 | *p++ = 0x00; |
andrewboyson | 7:b794780e33b4 | 36 | *p++ = 0x00; |
andrewboyson | 7:b794780e33b4 | 37 | *p++ = 0x00; |
andrewboyson | 13:9cd54f7db57a | 38 | *p++ = MacLocal[0] | 0x02; //Modified EUI-64 |
andrewboyson | 13:9cd54f7db57a | 39 | *p++ = MacLocal[1]; |
andrewboyson | 13:9cd54f7db57a | 40 | *p++ = MacLocal[2]; |
andrewboyson | 7:b794780e33b4 | 41 | *p++ = 0xFF; |
andrewboyson | 7:b794780e33b4 | 42 | *p++ = 0xFE; |
andrewboyson | 13:9cd54f7db57a | 43 | *p++ = MacLocal[3]; |
andrewboyson | 13:9cd54f7db57a | 44 | *p++ = MacLocal[4]; |
andrewboyson | 13:9cd54f7db57a | 45 | *p++ = MacLocal[5]; |
andrewboyson | 7:b794780e33b4 | 46 | } |