odhcpd: document the ubus interface
authorDavid Härdeman <[email protected]>
Tue, 7 Oct 2025 12:41:44 +0000 (14:41 +0200)
committerÁlvaro Fernández Rojas <[email protected]>
Thu, 9 Oct 2025 06:49:09 +0000 (08:49 +0200)
I guess this might be subject to change (for example, we probably want to
also broadcast events for DHCPv6 leases in the future, and I guess the
ack/release/expire events that are currently broadcast might benefit from
being renamed to something that makes it clearer that they are DHCPv4
specific events), but this is the current ubus interface.

Signed-off-by: David Härdeman <[email protected]>
Link: https://github.com/openwrt/odhcpd/pull/270
Signed-off-by: Álvaro Fernández Rojas <[email protected]>
README.md

index 47ffd634d30b20bd28321b53a643d7e8296c17dc..b710b93603392d799ffd4f6c3a6831874c105fc8 100644 (file)
--- a/README.md
+++ b/README.md
@@ -42,6 +42,7 @@ prefix delegation and can be used to relay RA, DHCPv6 and NDP between routed
 
 5. IPv6 PxE Support
 
+
 ## Compiling
 
 odhcpd uses cmake:
@@ -135,3 +136,28 @@ and may also receive information from ubus
 | :------------ | :---- | :----        | :---------- |
 | url          |string | yes   | e.g. `tftp://[fd11::1]/pxe.efi` |
 | arch         |integer| no    | the arch code. `07` is EFI. If not present, this boot6 will be the default. |
+
+
+## ubus Interface
+
+odhcpd currently exposes the following methods under the `dhcp` object path:
+
+| Method       | Arguments     | Description |
+| :------------ | :------------ | :---------- |
+| `ipv4leases`  | `none`       | Lists all currently active DHCPv4 leases per interface |
+| `ipv6leases` | `none`        | Lists all currently active DHCPv6 leases per interface |
+| `ipv6ra`     | `none`        | Lists announced IPv6 prefixes per interface |
+| `add_lease`  | options as in the cfg `host` section | Creates a new static lease, the arguments need to be formatted as a valid JSON string |
+
+These can be called by running e.g. `ubus call dhcp ipv6leases` on your OpenWrt
+device.
+
+odhcpd currently broadcasts the following events via ubus:
+
+| Name         | Parameters                    | Description   |
+| :------------ | :----------------------------        | :------------ |
+| `dhcp.ack`   | `mac,ip,name,interface`       | A new DHCPv4 lease has been created |
+| `dhcp.release`| `mac,ip,name,interface`      | A DHCPv4 lease has been released by a client |
+| `dhcp.expire`        | `mac,ip,name,interface`       | A DHCPv4 lease has expired |
+
+These can be observed by running e.g. `ubus listen dhcp` on your OpenWrt device.