ipv6: constexpr compile-time SLAAC settings
This commit is contained in:
parent
3d206c0d23
commit
42e70e9c20
@ -14,6 +14,8 @@ int udp_server(char* output_buffer, const char* input_buffer, int len) {
|
|||||||
void setup() {
|
void setup() {
|
||||||
pinMode(13, OUTPUT);
|
pinMode(13, OUTPUT);
|
||||||
|
|
||||||
|
/* Customize coppino library configuration settings by editing settings.h */
|
||||||
|
|
||||||
/* setup serial for Internet connectivity
|
/* setup serial for Internet connectivity
|
||||||
* attach a SLIP daemon on the other endpoint; a good one is `tunslip6` by Contiki
|
* attach a SLIP daemon on the other endpoint; a good one is `tunslip6` by Contiki
|
||||||
* $ tunslip6 -s /dev/ttyUSB0 -L -v5 -B 19200 2001:db8:1324::1/64
|
* $ tunslip6 -s /dev/ttyUSB0 -L -v5 -B 19200 2001:db8:1324::1/64
|
||||||
@ -26,8 +28,6 @@ void setup() {
|
|||||||
* Note: pay attention to enter exactly 64 bits / 8 bytes
|
* Note: pay attention to enter exactly 64 bits / 8 bytes
|
||||||
*/
|
*/
|
||||||
ipv6::setEUI("\xde\xad\xbe\xef\x12\x34\x56\x78");
|
ipv6::setEUI("\xde\xad\xbe\xef\x12\x34\x56\x78");
|
||||||
/* enable or disable IPv6 Stateless Auto-Configuration (SLAAC) */
|
|
||||||
ipv6::SLAAC(false);
|
|
||||||
/* set global address -- will be overwritten if SLAAC is enabled and a Router Advertisement is received */
|
/* set global address -- will be overwritten if SLAAC is enabled and a Router Advertisement is received */
|
||||||
ipv6::setGlobalAddress("\x20\x01\x04\x70\xc8\x44\x00\x31\x00\x00\x00\x00\x00\x00\xca\xfe");
|
ipv6::setGlobalAddress("\x20\x01\x04\x70\xc8\x44\x00\x31\x00\x00\x00\x00\x00\x00\xca\xfe");
|
||||||
|
|
||||||
|
@ -10,7 +10,6 @@ namespace ipv6
|
|||||||
uint8_t HOP_LIMIT = 64;
|
uint8_t HOP_LIMIT = 64;
|
||||||
IPv6Addr LINK_LOCAL_ADDRESS;
|
IPv6Addr LINK_LOCAL_ADDRESS;
|
||||||
IPv6Addr GLOBAL_ADDRESS;
|
IPv6Addr GLOBAL_ADDRESS;
|
||||||
bool slaac_enable;
|
|
||||||
|
|
||||||
/******** buffers ********/
|
/******** buffers ********/
|
||||||
IPv6Packet packetin;
|
IPv6Packet packetin;
|
||||||
@ -23,10 +22,6 @@ namespace ipv6
|
|||||||
memcpy(&LINK_LOCAL_ADDRESS, "\xfe\x80", 2);
|
memcpy(&LINK_LOCAL_ADDRESS, "\xfe\x80", 2);
|
||||||
memcpy(((char *)&LINK_LOCAL_ADDRESS) + 8, eui, 8);
|
memcpy(((char *)&LINK_LOCAL_ADDRESS) + 8, eui, 8);
|
||||||
}
|
}
|
||||||
void SLAAC(bool enable)
|
|
||||||
{
|
|
||||||
slaac_enable = enable;
|
|
||||||
}
|
|
||||||
void setGlobalAddress(const char *address)
|
void setGlobalAddress(const char *address)
|
||||||
{
|
{
|
||||||
memcpy(&GLOBAL_ADDRESS, address, 16);
|
memcpy(&GLOBAL_ADDRESS, address, 16);
|
||||||
@ -242,7 +237,7 @@ namespace ipv6
|
|||||||
memcpy(output_buffer + 2, &checksum, 2);
|
memcpy(output_buffer + 2, &checksum, 2);
|
||||||
return len;
|
return len;
|
||||||
}
|
}
|
||||||
else if (type == ICMP_RADV_TYPE && slaac_enable)
|
else if (type == ICMP_RADV_TYPE && ENABLE_SLAAC)
|
||||||
{ /* if it is IVMPc6 Router Advertisement, then... */
|
{ /* if it is IVMPc6 Router Advertisement, then... */
|
||||||
ICMPv6_RADV *radv = (ICMPv6_RADV *)input_buffer;
|
ICMPv6_RADV *radv = (ICMPv6_RADV *)input_buffer;
|
||||||
HOP_LIMIT = (radv->cur_hop_limit != 0) ? radv->cur_hop_limit : 64;
|
HOP_LIMIT = (radv->cur_hop_limit != 0) ? radv->cur_hop_limit : 64;
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
#ifndef COPPINO_IPV6_H
|
#ifndef COPPINO_IPV6_H
|
||||||
#define COPPINO_IPV6_H
|
#define COPPINO_IPV6_H
|
||||||
|
|
||||||
|
#include "settings.h"
|
||||||
#include "Arduino.h"
|
#include "Arduino.h"
|
||||||
#include "slip.h"
|
#include "slip.h"
|
||||||
|
|
||||||
@ -102,7 +103,6 @@ namespace ipv6
|
|||||||
/* RFC 4861 -- end */
|
/* RFC 4861 -- end */
|
||||||
|
|
||||||
void setEUI(const char *eui); /* 64bit Extended Unique Identifier */
|
void setEUI(const char *eui); /* 64bit Extended Unique Identifier */
|
||||||
void SLAAC(bool enable); /* enable IPv6 automatic prefix configuration (listens for RADV) */
|
|
||||||
void setGlobalAddress(const char *address); /* global IPv6 address, manually configured */
|
void setGlobalAddress(const char *address); /* global IPv6 address, manually configured */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
8
src/settings.h
Normal file
8
src/settings.h
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
#ifndef __COPPINO_SETTINGS_
|
||||||
|
#define __COPPINO_SETTINGS_
|
||||||
|
|
||||||
|
/* coppino configuration settings */
|
||||||
|
// Enable IPv6 automatic prefix configuration (listens for RADV)
|
||||||
|
constexpr bool ENABLE_SLAAC = false;
|
||||||
|
|
||||||
|
#endif
|
Loading…
Reference in New Issue
Block a user