DHCP tweaks

This commit is contained in:
Wiesner András 2024-10-20 10:52:02 +02:00
parent 22c260e9dc
commit c3f8e53006
2 changed files with 10 additions and 2 deletions

View File

@ -275,9 +275,9 @@ void ethinf_print_info(const EthInterface * intf) {
if (intf->dhcp != NULL) { if (intf->dhcp != NULL) {
bool on = dhcp_get_fsm_state(intf->dhcp) != DHCP_STOPPED; bool on = dhcp_get_fsm_state(intf->dhcp) != DHCP_STOPPED;
MSG("DHCP is %s" ANSI_COLOR_RESET "%s.", on ? (ANSI_COLOR_BGREEN "ON") : (ANSI_COLOR_BRED "OFF"), intf->manageDhcp ? "[automanaged]" : ""); MSG("DHCP is %s" ANSI_COLOR_RESET " %s.", on ? (ANSI_COLOR_BGREEN "RUNNING") : (ANSI_COLOR_BRED "STOPPED"), intf->manageDhcp ? "[automanaged]" : "");
} else { } else {
MSG ("DHCP is " ANSI_COLOR_RED "absent" ANSI_COLOR_RESET "."); MSG ("DHCP is " ANSI_COLOR_RED "ABSENT" ANSI_COLOR_RESET ".");
} }
MSG("\n"); MSG("\n");

View File

@ -368,6 +368,14 @@ static int dhcp_resp_cb(const Pckt *pckt, PcktSieveLayerTag tag) {
void dhcp_start(DhcpState *s) { void dhcp_start(DhcpState *s) {
//MSG("DHCP start!\n"); //MSG("DHCP start!\n");
// clear addresses
s->intf->ip = IPv4_IF_ADDR;
s->intf->router = IPv4_IF_ADDR;
s->intf->netmask = IPv4_ANY_ADDR;
s->intf->dns = IPv4_IF_ADDR;
// start the DHCP state machine
s->enabled = true; s->enabled = true;
s->state = DHCP_INIT; s->state = DHCP_INIT;
dhcp_process(s, NULL, NULL); dhcp_process(s, NULL, NULL);