mirror of
https://github.com/openwrt/luci.git
synced 2025-12-21 14:54:36 +04:00
rpcd-mod-luci: report the interface for leases
This adds support to rpcd-mod-luci's ubus interface to report also which interface a given lease corresponds to, which will make it possible to expose that information in LuCI. Signed-off-by: David Härdeman <david@hardeman.nu>
This commit is contained in:
committed by
Paul Donald
parent
338b379d4d
commit
570b4bfe6f
@@ -353,6 +353,7 @@ struct lease_entry {
|
|||||||
char buf[512];
|
char buf[512];
|
||||||
int32_t expire;
|
int32_t expire;
|
||||||
struct ether_addr mac;
|
struct ether_addr mac;
|
||||||
|
char *iface;
|
||||||
char *hostname;
|
char *hostname;
|
||||||
char *duid;
|
char *duid;
|
||||||
char *iaid;
|
char *iaid;
|
||||||
@@ -486,8 +487,13 @@ lease_next(void)
|
|||||||
ea = NULL;
|
ea = NULL;
|
||||||
|
|
||||||
if (lease_state.files[lease_state.off].odhcpd) {
|
if (lease_state.files[lease_state.off].odhcpd) {
|
||||||
strtok(e.buf, " \t\n"); /* # */
|
p = strtok(e.buf, " \t\n"); /* # */
|
||||||
strtok(NULL, " \t\n"); /* iface */
|
if (!p || strcmp(p, "#"))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
e.iface = strtok(NULL, " \t\n"); /* iface */
|
||||||
|
if (!e.iface)
|
||||||
|
continue;
|
||||||
|
|
||||||
e.duid = strtok(NULL, " \t\n"); /* duid or MAC */
|
e.duid = strtok(NULL, " \t\n"); /* duid or MAC */
|
||||||
if (!e.duid)
|
if (!e.duid)
|
||||||
@@ -1859,6 +1865,9 @@ rpc_luci_get_duid_hints(struct ubus_context *ctx, struct ubus_object *obj,
|
|||||||
|
|
||||||
o = blobmsg_open_table(&blob, key);
|
o = blobmsg_open_table(&blob, key);
|
||||||
|
|
||||||
|
if (lease->iface)
|
||||||
|
blobmsg_add_string(&blob, "interface", lease->iface);
|
||||||
|
|
||||||
blobmsg_add_string(&blob, "duid", lease->duid);
|
blobmsg_add_string(&blob, "duid", lease->duid);
|
||||||
|
|
||||||
if (lease->iaid)
|
if (lease->iaid)
|
||||||
@@ -1972,6 +1981,9 @@ rpc_luci_get_dhcp_leases(struct ubus_context *ctx, struct ubus_object *obj,
|
|||||||
else
|
else
|
||||||
blobmsg_add_u32(&blob, "expires", lease->expire);
|
blobmsg_add_u32(&blob, "expires", lease->expire);
|
||||||
|
|
||||||
|
if (lease->iface)
|
||||||
|
blobmsg_add_string(&blob, "interface", lease->iface);
|
||||||
|
|
||||||
if (lease->hostname)
|
if (lease->hostname)
|
||||||
blobmsg_add_string(&blob, "hostname", lease->hostname);
|
blobmsg_add_string(&blob, "hostname", lease->hostname);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user