diff --git a/examples/simple-udp-server/simple-udp-server.ino b/examples/simple-udp-server/simple-udp-server.ino index b719db1..2f3280a 100644 --- a/examples/simple-udp-server/simple-udp-server.ino +++ b/examples/simple-udp-server/simple-udp-server.ino @@ -14,6 +14,8 @@ int udp_server(char* output_buffer, const char* input_buffer, int len) { void setup() { pinMode(13, OUTPUT); + /* Customize coppino library configuration settings by editing settings.h */ + /* setup serial for Internet connectivity * 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 @@ -26,8 +28,6 @@ void setup() { * Note: pay attention to enter exactly 64 bits / 8 bytes */ 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 */ ipv6::setGlobalAddress("\x20\x01\x04\x70\xc8\x44\x00\x31\x00\x00\x00\x00\x00\x00\xca\xfe"); diff --git a/src/ipv6.cpp b/src/ipv6.cpp index f3f03dc..88a4b9a 100644 --- a/src/ipv6.cpp +++ b/src/ipv6.cpp @@ -10,7 +10,6 @@ namespace ipv6 uint8_t HOP_LIMIT = 64; IPv6Addr LINK_LOCAL_ADDRESS; IPv6Addr GLOBAL_ADDRESS; - bool slaac_enable; /******** buffers ********/ IPv6Packet packetin; @@ -23,10 +22,6 @@ namespace ipv6 memcpy(&LINK_LOCAL_ADDRESS, "\xfe\x80", 2); memcpy(((char *)&LINK_LOCAL_ADDRESS) + 8, eui, 8); } - void SLAAC(bool enable) - { - slaac_enable = enable; - } void setGlobalAddress(const char *address) { memcpy(&GLOBAL_ADDRESS, address, 16); @@ -242,7 +237,7 @@ namespace ipv6 memcpy(output_buffer + 2, &checksum, 2); 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... */ ICMPv6_RADV *radv = (ICMPv6_RADV *)input_buffer; HOP_LIMIT = (radv->cur_hop_limit != 0) ? radv->cur_hop_limit : 64; diff --git a/src/ipv6.h b/src/ipv6.h index f697d14..6ec047c 100644 --- a/src/ipv6.h +++ b/src/ipv6.h @@ -1,6 +1,7 @@ #ifndef COPPINO_IPV6_H #define COPPINO_IPV6_H +#include "settings.h" #include "Arduino.h" #include "slip.h" @@ -102,7 +103,6 @@ namespace ipv6 /* RFC 4861 -- end */ 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 */ } diff --git a/src/settings.h b/src/settings.h new file mode 100644 index 0000000..7d2b0e7 --- /dev/null +++ b/src/settings.h @@ -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