From c3f8e53006fd3bc135fb47cd108c5b39252630b9 Mon Sep 17 00:00:00 2001 From: Epagris Date: Sun, 20 Oct 2024 10:52:02 +0200 Subject: [PATCH] DHCP tweaks --- eth_interface.c | 4 ++-- prefab/packet_parsers/dhcp.c | 8 ++++++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/eth_interface.c b/eth_interface.c index ea2e585..a6dcf3f 100644 --- a/eth_interface.c +++ b/eth_interface.c @@ -275,9 +275,9 @@ void ethinf_print_info(const EthInterface * intf) { if (intf->dhcp != NULL) { 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 { - MSG ("DHCP is " ANSI_COLOR_RED "absent" ANSI_COLOR_RESET "."); + MSG ("DHCP is " ANSI_COLOR_RED "ABSENT" ANSI_COLOR_RESET "."); } MSG("\n"); diff --git a/prefab/packet_parsers/dhcp.c b/prefab/packet_parsers/dhcp.c index dc9b594..77e364d 100644 --- a/prefab/packet_parsers/dhcp.c +++ b/prefab/packet_parsers/dhcp.c @@ -368,6 +368,14 @@ static int dhcp_resp_cb(const Pckt *pckt, PcktSieveLayerTag tag) { void dhcp_start(DhcpState *s) { //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->state = DHCP_INIT; dhcp_process(s, NULL, NULL);