summaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorsbyx <steven@midlink.org>2014-08-12 15:10:27 +0200
committersbyx <steven@midlink.org>2014-08-12 15:10:27 +0200
commit479cd9f6a5b6c68285004aa30bacfb284121ac8e (patch)
treea062368823c468b22684439b2aa47b1b95153f76 /src
parentaa5659eb06a386ddf2bc80ad078891820f12c410 (diff)
parent85e370673ef76fa1ce461a4ac3d995f376522fd1 (diff)
Merge pull request #22 from mehlis/log-dhcp4-events
dhcpv4: log requests and replies to syslog
Diffstat (limited to 'src')
-rw-r--r--src/dhcpv4.c33
1 files changed, 33 insertions, 0 deletions
diff --git a/src/dhcpv4.c b/src/dhcpv4.c
index d978da8..9b9b528 100644
--- a/src/dhcpv4.c
+++ b/src/dhcpv4.c
@@ -45,6 +45,29 @@ int init_dhcpv4(void)
return 0;
}
+char *dhcpv4_msg_to_string(uint8_t reqmsg)
+{
+ switch (reqmsg) {
+ case (DHCPV4_MSG_DISCOVER):
+ return "DHCPV4_MSG_DISCOVER";
+ case (DHCPV4_MSG_OFFER):
+ return "DHCPV4_MSG_OFFER";
+ case (DHCPV4_MSG_REQUEST):
+ return "DHCPV4_MSG_REQUEST";
+ case (DHCPV4_MSG_DECLINE):
+ return "DHCPV4_MSG_DECLINE";
+ case (DHCPV4_MSG_ACK):
+ return "DHCPV4_MSG_ACK";
+ case (DHCPV4_MSG_NAK):
+ return "DHCPV4_MSG_NAK";
+ case (DHCPV4_MSG_RELEASE):
+ return "DHCPV4_MSG_RELEASE";
+ case (DHCPV4_MSG_INFORM):
+ return "DHCPV4_MSG_INFORM";
+ default:
+ return "UNKNOWN";
+ }
+}
int setup_dhcpv4_interface(struct interface *iface, bool enable)
{
@@ -346,6 +369,11 @@ static void handle_dhcpv4(void *addr, void *data, size_t len,
*/
}
+ syslog(LOG_WARNING, "received %s from %x:%x:%x:%x:%x:%x",
+ dhcpv4_msg_to_string(reqmsg),
+ req->chaddr[0],req->chaddr[1],req->chaddr[2],
+ req->chaddr[3],req->chaddr[4],req->chaddr[5]);
+
if (reqmsg == DHCPV4_MSG_DECLINE || reqmsg == DHCPV4_MSG_RELEASE)
return;
@@ -431,6 +459,11 @@ static void handle_dhcpv4(void *addr, void *data, size_t len,
ioctl(sock, SIOCSARP, &arp);
}
+ syslog(LOG_WARNING, "sending %s to %x:%x:%x:%x:%x:%x",
+ dhcpv4_msg_to_string(msg),
+ req->chaddr[0],req->chaddr[1],req->chaddr[2],
+ req->chaddr[3],req->chaddr[4],req->chaddr[5]);
+
sendto(sock, &reply, sizeof(reply), MSG_DONTWAIT,
(struct sockaddr*)&dest, sizeof(dest));
}