networkd: add DHCPServer PoolSize and PoolOffset DBus properties
Closes https://github.com/systemd/systemd/issues/30011
This commit is contained in:
@@ -458,6 +458,10 @@ node /org/freedesktop/network1/link/_1 {
|
||||
interface org.freedesktop.network1.DHCPServer {
|
||||
properties:
|
||||
readonly a(uayayayayt) Leases = [...];
|
||||
@org.freedesktop.DBus.Property.EmitsChangedSignal("const")
|
||||
readonly u PoolSize = ...;
|
||||
@org.freedesktop.DBus.Property.EmitsChangedSignal("const")
|
||||
readonly u PoolOffset = ...;
|
||||
};
|
||||
interface org.freedesktop.DBus.Peer { ... };
|
||||
interface org.freedesktop.DBus.Introspectable { ... };
|
||||
@@ -466,8 +470,6 @@ node /org/freedesktop/network1/link/_1 {
|
||||
};
|
||||
</programlisting>
|
||||
|
||||
<!--property Leases is not documented!-->
|
||||
|
||||
<!--Autogenerated cross-references for systemd.directives, do not edit-->
|
||||
|
||||
<variablelist class="dbus-interface" generated="True" extra-ref="org.freedesktop.network1.Link"/>
|
||||
@@ -480,10 +482,23 @@ node /org/freedesktop/network1/link/_1 {
|
||||
|
||||
<variablelist class="dbus-property" generated="True" extra-ref="Leases"/>
|
||||
|
||||
<variablelist class="dbus-property" generated="True" extra-ref="PoolSize"/>
|
||||
|
||||
<variablelist class="dbus-property" generated="True" extra-ref="PoolOffset"/>
|
||||
|
||||
<!--End of Autogenerated section-->
|
||||
|
||||
<para>
|
||||
Provides information about leases.
|
||||
Provides information about the DHCP server. The <varname>Leases</varname> property contains
|
||||
the currently active leases. The <varname>PoolSize</varname> property contains the total number
|
||||
of addresses in the dynamic address pool. The <varname>PoolOffset</varname> property contains
|
||||
the offset from the subnet base address where the pool starts. These correspond to the
|
||||
<varname>PoolSize=</varname> and <varname>PoolOffset=</varname> settings in
|
||||
<citerefentry><refentrytitle>systemd.network</refentrytitle><manvolnum>5</manvolnum></citerefentry>.
|
||||
<constant>UINT32_MAX</constant> is used as a sentinel value for <varname>PoolSize</varname>
|
||||
and <varname>PoolOffset</varname> to indicate that the information is unavailable (i.e. no
|
||||
DHCP server is configured or the link is in relay mode), rather than a valid pool size or
|
||||
offset.
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
@@ -589,6 +604,10 @@ $ gdbus introspect --system \
|
||||
|
||||
<refsect1>
|
||||
<title>History</title>
|
||||
<refsect2>
|
||||
<title>DHCP Server Object</title>
|
||||
<para><varname>PoolSize</varname> and <varname>PoolOffset</varname> were added in version 261.</para>
|
||||
</refsect2>
|
||||
<refsect2>
|
||||
<title>DHCPv4 Client Object</title>
|
||||
<para><varname>State</varname> was added in version 255.</para>
|
||||
|
||||
@@ -74,6 +74,46 @@ static int property_get_leases(
|
||||
return sd_bus_message_close_container(reply);
|
||||
}
|
||||
|
||||
static int property_get_pool_size(
|
||||
sd_bus *bus,
|
||||
const char *path,
|
||||
const char *interface,
|
||||
const char *property,
|
||||
sd_bus_message *reply,
|
||||
void *userdata,
|
||||
sd_bus_error *error) {
|
||||
Link *l = ASSERT_PTR(userdata);
|
||||
sd_dhcp_server *s;
|
||||
uint32_t v;
|
||||
|
||||
assert(reply);
|
||||
|
||||
s = l->dhcp_server;
|
||||
v = s && !sd_dhcp_server_is_in_relay_mode(s) ? s->pool_size : UINT32_MAX;
|
||||
|
||||
return sd_bus_message_append_basic(reply, 'u', &v);
|
||||
}
|
||||
|
||||
static int property_get_pool_offset(
|
||||
sd_bus *bus,
|
||||
const char *path,
|
||||
const char *interface,
|
||||
const char *property,
|
||||
sd_bus_message *reply,
|
||||
void *userdata,
|
||||
sd_bus_error *error) {
|
||||
Link *l = ASSERT_PTR(userdata);
|
||||
sd_dhcp_server *s;
|
||||
uint32_t v;
|
||||
|
||||
assert(reply);
|
||||
|
||||
s = l->dhcp_server;
|
||||
v = s && !sd_dhcp_server_is_in_relay_mode(s) ? s->pool_offset : UINT32_MAX;
|
||||
|
||||
return sd_bus_message_append_basic(reply, 'u', &v);
|
||||
}
|
||||
|
||||
static int dhcp_server_emit_changed_strv(Link *link, char **properties) {
|
||||
_cleanup_free_ char *path = NULL;
|
||||
|
||||
@@ -104,6 +144,8 @@ static const sd_bus_vtable dhcp_server_vtable[] = {
|
||||
SD_BUS_VTABLE_START(0),
|
||||
|
||||
SD_BUS_PROPERTY("Leases", "a(uayayayayt)", property_get_leases, 0, SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE),
|
||||
SD_BUS_PROPERTY("PoolSize", "u", property_get_pool_size, 0, SD_BUS_VTABLE_PROPERTY_CONST),
|
||||
SD_BUS_PROPERTY("PoolOffset", "u", property_get_pool_offset, 0, SD_BUS_VTABLE_PROPERTY_CONST),
|
||||
|
||||
SD_BUS_VTABLE_END
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user