From 5e130d6e22aa8607a8ac623633c9535d8ec4e61a Mon Sep 17 00:00:00 2001 From: Byron Johnson Date: Mon, 17 Jan 2022 11:51:11 -0500 Subject: [PATCH 1/2] added weak fnc add_custom_offer_options --- cores/esp8266/LwipDhcpServer.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/cores/esp8266/LwipDhcpServer.cpp b/cores/esp8266/LwipDhcpServer.cpp index 86f8849a91..920d394a48 100644 --- a/cores/esp8266/LwipDhcpServer.cpp +++ b/cores/esp8266/LwipDhcpServer.cpp @@ -367,6 +367,20 @@ uint8_t* DhcpServer::add_msg_type(uint8_t *optptr, uint8_t type) *optptr++ = type; return optptr; } + +extern "C" uint8_t* __add_custom_offer_options(uint8_t *optptr){ + /* Example showing how to add Captive Portal Option to DHCP Server + *optptr++ = 114; + *optptr++ = 19; + char captive_uri[] = "http://192.168.4.1/"; + for(int i = 0; i<19; i++){ + *optptr++ = captive_uri[i]; + } + */ + return optptr; //do nothing by default. Libraries can then redefine this weak function in order to hook into DHCP server options +} +extern "C" uint8_t* add_custom_offer_options(uint8_t *optptr) __attribute__ ((weak, alias("__add_custom_offer_options"))); + /////////////////////////////////////////////////////////////////////////////////// /* DHCP msg offer @@ -469,6 +483,8 @@ uint8_t* DhcpServer::add_offer_options(uint8_t *optptr) *optptr++ = 2; #endif + optptr = add_custom_offer_options(optptr); //this allows external code to redefine this weak function and hook into DHCP Offer. + return optptr; #undef ipadd From 56c208ca447871035fb54a79b7c2e8dda50d24b8 Mon Sep 17 00:00:00 2001 From: Byron Date: Mon, 17 Jan 2022 23:52:56 -0500 Subject: [PATCH 2/2] formatted with restyle.sh --- cores/esp8266/LwipDhcpServer.cpp | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/cores/esp8266/LwipDhcpServer.cpp b/cores/esp8266/LwipDhcpServer.cpp index 920d394a48..a7b91f2f1c 100644 --- a/cores/esp8266/LwipDhcpServer.cpp +++ b/cores/esp8266/LwipDhcpServer.cpp @@ -368,18 +368,19 @@ uint8_t* DhcpServer::add_msg_type(uint8_t *optptr, uint8_t type) return optptr; } -extern "C" uint8_t* __add_custom_offer_options(uint8_t *optptr){ - /* Example showing how to add Captive Portal Option to DHCP Server - *optptr++ = 114; - *optptr++ = 19; - char captive_uri[] = "http://192.168.4.1/"; - for(int i = 0; i<19; i++){ - *optptr++ = captive_uri[i]; - } - */ +extern "C" uint8_t* __add_custom_offer_options(uint8_t *optptr) +{ + // Example showing how to add Captive Portal Option to DHCP Server + // *optptr++ = 114; + // *optptr++ = 19; + // char captive_uri[] = "http://192.168.4.1/"; + // for(int i = 0; i<19; i++){ + // *optptr++ = captive_uri[i]; + // } + return optptr; //do nothing by default. Libraries can then redefine this weak function in order to hook into DHCP server options } -extern "C" uint8_t* add_custom_offer_options(uint8_t *optptr) __attribute__ ((weak, alias("__add_custom_offer_options"))); +extern "C" uint8_t* add_custom_offer_options(uint8_t *optptr) __attribute__((weak, alias("__add_custom_offer_options"))); /////////////////////////////////////////////////////////////////////////////////// /* @@ -484,7 +485,7 @@ uint8_t* DhcpServer::add_offer_options(uint8_t *optptr) #endif optptr = add_custom_offer_options(optptr); //this allows external code to redefine this weak function and hook into DHCP Offer. - + return optptr; #undef ipadd