Skip to content

added weak fnc add_custom_offer_options #8451

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 4 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions cores/esp8266/LwipDhcpServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,21 @@ 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
Expand Down Expand Up @@ -475,6 +490,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
Expand Down