odhcpd: Replace strerror(errno) with %m format
[project/odhcpd.git] / src / dhcpv4.c
index 166582e..db5f138 100644 (file)
@@ -86,8 +86,7 @@ int dhcpv4_setup_interface(struct interface *iface, bool enable)
 
                int sock = socket(AF_INET, SOCK_DGRAM | SOCK_CLOEXEC, IPPROTO_UDP);
                if (sock < 0) {
-                       syslog(LOG_ERR, "Failed to create DHCPv4 server socket: %s",
-                                       strerror(errno));
+                       syslog(LOG_ERR, "Failed to create DHCPv4 server socket: %m");
                        return -1;
                }
 
@@ -110,8 +109,7 @@ int dhcpv4_setup_interface(struct interface *iface, bool enable)
                                        {INADDR_ANY}, {0}};
 
                if (bind(sock, (struct sockaddr*)&bind_addr, sizeof(bind_addr))) {
-                       syslog(LOG_ERR, "Failed to open DHCPv4 server socket: %s",
-                                       strerror(errno));
+                       syslog(LOG_ERR, "Failed to open DHCPv4 server socket: %m");
                        return -1;
                }
 
@@ -723,6 +721,11 @@ static void handle_dhcpv4(void *addr, void *data, size_t len,
                        req->chaddr[0],req->chaddr[1],req->chaddr[2],
                        req->chaddr[3],req->chaddr[4],req->chaddr[5]);
 
+#ifdef WITH_UBUS
+       if (reqmsg == DHCPV4_MSG_RELEASE)
+               ubus_bcast_dhcp_event("dhcp.release", req->chaddr, req->hlen,
+                                       &req->ciaddr, hostname, iface->ifname);
+#endif
        if (reqmsg == DHCPV4_MSG_DECLINE || reqmsg == DHCPV4_MSG_RELEASE)
                return;
 
@@ -872,6 +875,12 @@ static void handle_dhcpv4(void *addr, void *data, size_t len,
 
        sendto(sock, &reply, sizeof(reply), MSG_DONTWAIT,
                        (struct sockaddr*)&dest, sizeof(dest));
+
+#ifdef WITH_UBUS
+       if (msg == DHCPV4_MSG_ACK)
+               ubus_bcast_dhcp_event("dhcp.ack", req->chaddr, req->hlen, &reply.yiaddr,
+                                       hostname, iface->ifname);
+#endif
 }
 
 static bool dhcpv4_assign(struct interface *iface,