nm_rs/auto/setting_ip4_config.rs
1// This file was generated by gir (https://github.com/gtk-rs/gir)
2// from gir
3// from gtk-girs (https://github.com/gtk-rs/gir-files)
4// DO NOT EDIT
5
6#[cfg(feature = "v1_52")]
7#[cfg_attr(docsrs, doc(cfg(feature = "v1_52")))]
8use crate::SettingIP4DhcpIpv6OnlyPreferred;
9use crate::{IPAddress, IPRoute, Setting, SettingIPConfig, ffi};
10#[cfg(feature = "v1_42")]
11#[cfg_attr(docsrs, doc(cfg(feature = "v1_42")))]
12use crate::{SettingIP4LinkLocal, Ternary};
13use glib::{
14 prelude::*,
15 signal::{SignalHandlerId, connect_raw},
16 translate::*,
17};
18use std::boxed::Box as Box_;
19
20glib::wrapper! {
21 /// IPv4 Settings
22 ///
23 /// ## Properties
24 ///
25 ///
26 /// #### `dhcp-client-id`
27 /// A string sent to the DHCP server to identify the local machine which the
28 /// DHCP server may use to customize the DHCP lease and options.
29 /// When the property is a hex string ('aa:bb:cc') it is interpreted as a
30 /// binary client ID, in which case the first byte is assumed to be the
31 /// 'type' field as per RFC 2132 section 9.14 and the remaining bytes may be
32 /// an hardware address (e.g. '01:xx:xx:xx:xx:xx:xx' where 1 is the Ethernet
33 /// ARP type and the rest is a MAC address).
34 /// If the property is not a hex string it is considered as a
35 /// non-hardware-address client ID and the 'type' field is set to 0.
36 ///
37 /// The special values "mac" and "perm-mac" are supported, which use the
38 /// current or permanent MAC address of the device to generate a client identifier
39 /// with type ethernet (01). Currently, these options only work for ethernet
40 /// type of links.
41 ///
42 /// The special value "ipv6-duid" uses the DUID from "ipv6.dhcp-duid" property as
43 /// an RFC4361-compliant client identifier. As IAID it uses "ipv4.dhcp-iaid"
44 /// and falls back to "ipv6.dhcp-iaid" if unset.
45 ///
46 /// The special value "duid" generates a RFC4361-compliant client identifier based
47 /// on "ipv4.dhcp-iaid" and uses a DUID generated by hashing /etc/machine-id.
48 ///
49 /// The special value "stable" is supported to generate a type 0 client identifier based
50 /// on the stable-id (see connection.stable-id) and a per-host key. If you set the
51 /// stable-id, you may want to include the "${DEVICE}" or "${MAC}" specifier to get a
52 /// per-device key.
53 ///
54 /// The special value "none" prevents any client identifier from being sent. Note that
55 /// this is normally not recommended.
56 ///
57 /// If unset, a globally configured default from NetworkManager.conf is
58 /// used. If still unset, the default depends on the DHCP plugin. The
59 /// internal dhcp client will default to "mac" and the dhclient plugin will
60 /// try to use one from its config file if present, or won't sent any
61 /// client-id otherwise.
62 ///
63 /// Readable | Writeable
64 ///
65 ///
66 /// #### `dhcp-fqdn`
67 /// If the #NMSettingIPConfig:dhcp-send-hostname property is [`true`], then the
68 /// specified FQDN will be sent to the DHCP server when acquiring a lease. This
69 /// property and #NMSettingIPConfig:dhcp-hostname are mutually exclusive and
70 /// cannot be set at the same time.
71 ///
72 /// Readable | Writeable
73 ///
74 ///
75 /// #### `dhcp-ipv6-only-preferred`
76 /// Controls the "IPv6-Only Preferred" DHCPv4 option (RFC 8925).
77 ///
78 /// When set to [`SettingIP4DhcpIpv6OnlyPreferred::Yes`][crate::SettingIP4DhcpIpv6OnlyPreferred::Yes], the host adds the
79 /// option to the parameter request list; if the DHCP server sends the option back,
80 /// the host stops the DHCP client for the time interval specified in the option.
81 ///
82 /// Enable this feature if the host supports an IPv6-only mode, i.e. either all
83 /// applications are IPv6-only capable or there is a form of 464XLAT deployed.
84 ///
85 /// When set to [`SettingIP4DhcpIpv6OnlyPreferred::Default`][crate::SettingIP4DhcpIpv6OnlyPreferred::Default], the actual value
86 /// is looked up in the global configuration; if not specified, it defaults to
87 /// [`SettingIP4DhcpIpv6OnlyPreferred::No`][crate::SettingIP4DhcpIpv6OnlyPreferred::No].
88 ///
89 /// If the connection has IPv6 method set to "disabled", this property does not
90 /// have effect and the "IPv6-Only Preferred" option is always disabled.
91 ///
92 /// Readable | Writeable
93 ///
94 ///
95 /// #### `dhcp-vendor-class-identifier`
96 /// The Vendor Class Identifier DHCP option (60).
97 /// Special characters in the data string may be escaped using C-style escapes,
98 /// nevertheless this property cannot contain nul bytes.
99 /// If the per-profile value is unspecified (the default),
100 /// a global connection default gets consulted.
101 /// If still unspecified, the DHCP option is not sent to the server.
102 ///
103 /// Readable | Writeable
104 ///
105 ///
106 /// #### `link-local`
107 /// Enable and disable the IPv4 link-local configuration independently of the
108 /// ipv4.method configuration. This allows a link-local address (169.254.x.y/16)
109 /// to be obtained in addition to other addresses, such as those manually
110 /// configured or obtained from a DHCP server.
111 ///
112 /// When set to "auto", the value is dependent on "ipv4.method".
113 /// When set to "default", it honors the global connection default, before
114 /// falling back to "auto". Note that if "ipv4.method" is "disabled", then
115 /// link local addressing is always disabled too. The default is "default".
116 /// Since 1.52, when set to "fallback", a link-local address is obtained
117 /// if no other IPv4 address is set.
118 ///
119 /// Readable | Writeable
120 /// <details><summary><h4>SettingIPConfig</h4></summary>
121 ///
122 ///
123 /// #### `addresses`
124 /// Array of IP addresses.
125 ///
126 /// Readable | Writeable
127 ///
128 ///
129 /// #### `auto-route-ext-gw`
130 /// VPN connections will default to add the route automatically unless this
131 /// setting is set to [`false`].
132 ///
133 /// For other connection types, adding such an automatic route is currently
134 /// not supported and setting this to [`true`] has no effect.
135 ///
136 /// Readable | Writeable
137 ///
138 ///
139 /// #### `dad-timeout`
140 /// Maximum timeout in milliseconds used to check for the presence of duplicate
141 /// IP addresses on the network. If an address conflict is detected, the
142 /// activation will fail. The property is currently implemented only for IPv4.
143 ///
144 /// A zero value means that no duplicate address detection is performed, -1 means
145 /// the default value (either the value configured globally in NetworkManger.conf
146 /// or 200ms). A value greater than zero is a timeout in milliseconds. Note that
147 /// the time intervals are subject to randomization as per RFC 5227 and so the
148 /// actual duration can be between half and the full time specified in this
149 /// property.
150 ///
151 /// Readable | Writeable
152 ///
153 ///
154 /// #### `dhcp-dscp`
155 /// Specifies the value for the DSCP field (traffic class) of the IP header. When
156 /// empty, the global default value is used; if no global default is specified, it is
157 /// assumed to be "CS0". Allowed values are: "CS0", "CS4" and "CS6".
158 ///
159 /// The property is currently valid only for IPv4, and it is supported only by the
160 /// "internal" DHCP plugin.
161 ///
162 /// Readable | Writeable
163 ///
164 ///
165 /// #### `dhcp-hostname`
166 /// If the #NMSettingIPConfig:dhcp-send-hostname property is [`true`], then the
167 /// specified name will be sent to the DHCP server when acquiring a lease.
168 /// This property and #NMSettingIP4Config:dhcp-fqdn are mutually exclusive and
169 /// cannot be set at the same time.
170 ///
171 /// Readable | Writeable
172 ///
173 ///
174 /// #### `dhcp-hostname-flags`
175 /// Flags for the DHCP hostname and FQDN.
176 ///
177 /// Currently, this property only includes flags to control the FQDN flags
178 /// set in the DHCP FQDN option. Supported FQDN flags are
179 /// [`DhcpHostnameFlags::FQDN_SERV_UPDATE`][crate::DhcpHostnameFlags::FQDN_SERV_UPDATE],
180 /// [`DhcpHostnameFlags::FQDN_ENCODED`][crate::DhcpHostnameFlags::FQDN_ENCODED] and
181 /// [`DhcpHostnameFlags::FQDN_NO_UPDATE`][crate::DhcpHostnameFlags::FQDN_NO_UPDATE]. When no FQDN flag is set and
182 /// [`DhcpHostnameFlags::FQDN_CLEAR_FLAGS`][crate::DhcpHostnameFlags::FQDN_CLEAR_FLAGS] is set, the DHCP FQDN option will
183 /// contain no flag. Otherwise, if no FQDN flag is set and
184 /// [`DhcpHostnameFlags::FQDN_CLEAR_FLAGS`][crate::DhcpHostnameFlags::FQDN_CLEAR_FLAGS] is not set, the standard FQDN flags
185 /// are set in the request:
186 /// [`DhcpHostnameFlags::FQDN_SERV_UPDATE`][crate::DhcpHostnameFlags::FQDN_SERV_UPDATE],
187 /// [`DhcpHostnameFlags::FQDN_ENCODED`][crate::DhcpHostnameFlags::FQDN_ENCODED] for IPv4 and
188 /// [`DhcpHostnameFlags::FQDN_SERV_UPDATE`][crate::DhcpHostnameFlags::FQDN_SERV_UPDATE] for IPv6.
189 ///
190 /// When this property is set to the default value [`DhcpHostnameFlags::NONE`][crate::DhcpHostnameFlags::NONE],
191 /// a global default is looked up in NetworkManager configuration. If that value
192 /// is unset or also [`DhcpHostnameFlags::NONE`][crate::DhcpHostnameFlags::NONE], then the standard FQDN flags
193 /// described above are sent in the DHCP requests.
194 ///
195 /// Readable | Writeable
196 ///
197 ///
198 /// #### `dhcp-iaid`
199 /// A string containing the "Identity Association Identifier" (IAID) used by
200 /// the DHCP client. The string can be a 32-bit number (either decimal,
201 /// hexadecimal or as colon separated hexadecimal numbers). Alternatively
202 /// it can be set to the special values "mac", "perm-mac", "ifname" or
203 /// "stable". When set to "mac" (or "perm-mac"), the last 4 bytes of the
204 /// current (or permanent) MAC address are used as IAID. When set to
205 /// "ifname", the IAID is computed by hashing the interface name. The
206 /// special value "stable" can be used to generate an IAID based on the
207 /// stable-id (see connection.stable-id), a per-host key and the interface
208 /// name. When the property is unset, the value from global configuration is
209 /// used; if no global default is set then the IAID is assumed to be
210 /// "ifname".
211 ///
212 /// For DHCPv4, the IAID is only used with "ipv4.dhcp-client-id"
213 /// values "duid" and "ipv6-duid" to generate the client-id.
214 ///
215 /// For DHCPv6, note that at the moment this property is
216 /// only supported by the "internal" DHCPv6 plugin. The "dhclient" DHCPv6
217 /// plugin always derives the IAID from the MAC address.
218 ///
219 /// The actually used DHCPv6 IAID for a currently activated interface is
220 /// exposed in the lease information of the device.
221 ///
222 /// Readable | Writeable
223 ///
224 ///
225 /// #### `dhcp-reject-servers`
226 /// Array of servers from which DHCP offers must be rejected. This property
227 /// is useful to avoid getting a lease from misconfigured or rogue servers.
228 ///
229 /// For DHCPv4, each element must be an IPv4 address, optionally
230 /// followed by a slash and a prefix length (e.g. "192.168.122.0/24").
231 ///
232 /// This property is currently not implemented for DHCPv6.
233 ///
234 /// Readable | Writeable
235 ///
236 ///
237 /// #### `dhcp-send-hostname`
238 /// Since 1.52 this property is deprecated and is only used as fallback value
239 /// for #NMSettingIPConfig:dhcp-send-hostname-v2 if it's set to 'default'.
240 /// This is only done to avoid breaking existing configurations, the new
241 /// property should be used from now on.
242 ///
243 /// Readable | Writeable
244 ///
245 ///
246 /// #### `dhcp-send-hostname-v2`
247 /// If [`true`], a hostname is sent to the DHCP server when acquiring a lease.
248 /// Some DHCP servers use this hostname to update DNS databases, essentially
249 /// providing a static hostname for the computer. If the
250 /// #NMSettingIPConfig:dhcp-hostname property is [`None`] and this property is
251 /// [`true`], the current persistent hostname of the computer is sent.
252 ///
253 /// The default value is [`Ternary::Default`][crate::Ternary::Default]. In this case the global value
254 /// from NetworkManager configuration is looked up. If it's not set, the value
255 /// from #NMSettingIPConfig:dhcp-send-hostname, which defaults to [`true`], is
256 /// used for backwards compatibility. In the future this will change and, in
257 /// absence of a global default, it will always fallback to [`true`].
258 ///
259 /// Readable | Writeable
260 ///
261 ///
262 /// #### `dhcp-send-release`
263 /// Whether the DHCP client will send RELEASE message when
264 /// bringing the connection down. The default value is [`Ternary::Default`][crate::Ternary::Default].
265 /// When the default value is specified, then the global value from NetworkManager
266 /// configuration is looked up, if not set, it is considered as [`false`].
267 ///
268 /// Readable | Writeable
269 ///
270 ///
271 /// #### `dhcp-timeout`
272 /// A timeout for a DHCP transaction in seconds. If zero (the default), a
273 /// globally configured default is used. If still unspecified, a device specific
274 /// timeout is used (usually 45 seconds).
275 ///
276 /// Set to 2147483647 (MAXINT32) for infinity.
277 ///
278 /// Readable | Writeable
279 ///
280 ///
281 /// #### `dns`
282 /// Array of DNS servers.
283 ///
284 /// Each server can be specified either as a plain IP address (optionally followed
285 /// by a "#" and the SNI server name for DNS over TLS) or with a URI syntax.
286 ///
287 /// When it is specified as an URI, the following forms are supported:
288 /// dns+udp://ADDRESS[:PORT], dns+tls://ADDRESS[:PORT][#SERVERNAME] .
289 ///
290 /// When using the URI syntax, IPv6 addresses must be enclosed in square
291 /// brackets ('[', ']').
292 ///
293 /// Readable | Writeable
294 ///
295 ///
296 /// #### `dns-options`
297 /// Array of DNS options to be added to resolv.conf.
298 ///
299 /// [`None`] means that the options are unset and left at the default.
300 /// In this case NetworkManager will use default options. This is
301 /// distinct from an empty list of properties.
302 ///
303 /// The following options are directly added to resolv.conf: "attempts",
304 /// "debug", "edns0",
305 /// "inet6", "ip6-bytestring", "ip6-dotint", "ndots", "no-aaaa",
306 /// "no-check-names", "no-ip6-dotint", "no-reload", "no-tld-query",
307 /// "rotate", "single-request", "single-request-reopen", "timeout",
308 /// "trust-ad", "use-vc". See the resolv.conf(5) man page for a
309 /// detailed description of these options.
310 ///
311 /// In addition, NetworkManager supports the special options "_no-add-edns0"
312 /// and "_no-add-trust-ad". They are not added to resolv.conf, and can be
313 /// used to prevent the automatic addition of options "edns0" and "trust-ad"
314 /// when using caching DNS plugins (see below).
315 ///
316 /// The "trust-ad" setting is only honored if the profile contributes
317 /// name servers to resolv.conf, and if all contributing profiles have
318 /// "trust-ad" enabled.
319 ///
320 /// When using a caching DNS plugin (dnsmasq or systemd-resolved in
321 /// NetworkManager.conf) then "edns0" and "trust-ad" are automatically
322 /// added, unless "_no-add-edns0" and "_no-add-trust-ad" are present.
323 ///
324 /// Readable | Writeable
325 ///
326 ///
327 /// #### `dns-priority`
328 /// DNS servers priority.
329 ///
330 /// The relative priority for DNS servers specified by this setting. A lower
331 /// numerical value is better (higher priority).
332 ///
333 /// Negative values have the special effect of excluding other configurations
334 /// with a greater numerical priority value; so in presence of at least one negative
335 /// priority, only DNS servers from connections with the lowest priority value will be used.
336 /// To avoid all DNS leaks, set the priority of the profile that should be used
337 /// to the most negative value of all active connections profiles.
338 ///
339 /// Zero selects a globally configured default value. If the latter is missing
340 /// or zero too, it defaults to 50 for VPNs (including WireGuard) and 100 for
341 /// other connections.
342 ///
343 /// Note that the priority is to order DNS settings for multiple active
344 /// connections. It does not disambiguate multiple DNS servers within the
345 /// same connection profile.
346 ///
347 /// When multiple devices have configurations with the same priority, VPNs will be
348 /// considered first, then devices with the best (lowest metric) default
349 /// route and then all other devices.
350 ///
351 /// When using dns=default, servers with higher priority will be on top of
352 /// resolv.conf. To prioritize a given server over another one within the
353 /// same connection, just specify them in the desired order.
354 /// Note that commonly the resolver tries name servers in /etc/resolv.conf
355 /// in the order listed, proceeding with the next server in the list
356 /// on failure. See for example the "rotate" option of the dns-options setting.
357 /// If there are any negative DNS priorities, then only name servers from
358 /// the devices with that lowest priority will be considered.
359 ///
360 /// When using a DNS resolver that supports Conditional Forwarding or
361 /// Split DNS (with dns=dnsmasq or dns=systemd-resolved settings), each connection
362 /// is used to query domains in its search list. The search domains determine which
363 /// name servers to ask, and the DNS priority is used to prioritize
364 /// name servers based on the domain. Queries for domains not present in any
365 /// search list are routed through connections having the '~.' special wildcard
366 /// domain, which is added automatically to connections with the default route
367 /// (or can be added manually). When multiple connections specify the same domain, the
368 /// one with the best priority (lowest numerical value) wins. If a sub domain
369 /// is configured on another interface it will be accepted regardless the priority,
370 /// unless parent domain on the other interface has a negative priority, which causes
371 /// the sub domain to be shadowed.
372 /// With Split DNS one can avoid undesired DNS leaks by properly configuring
373 /// DNS priorities and the search domains, so that only name servers of the desired
374 /// interface are configured.
375 ///
376 /// Readable | Writeable
377 ///
378 ///
379 /// #### `dns-search`
380 /// List of DNS search domains. Domains starting with a tilde ('~')
381 /// are considered 'routing' domains and are used only to decide the
382 /// interface over which a query must be forwarded; they are not used
383 /// to complete unqualified host names.
384 ///
385 /// When using a DNS plugin that supports Conditional Forwarding or
386 /// Split DNS, then the search domains specify which name servers to
387 /// query. This makes the behavior different from running with plain
388 /// /etc/resolv.conf. For more information see also the dns-priority setting.
389 ///
390 /// When set on a profile that also enabled DHCP, the DNS search list
391 /// received automatically (option 119 for DHCPv4 and option 24 for DHCPv6)
392 /// gets merged with the manual list. This can be prevented by setting
393 /// "ignore-auto-dns". Note that if no DNS searches are configured, the
394 /// fallback will be derived from the domain from DHCP (option 15).
395 ///
396 /// Readable | Writeable
397 ///
398 ///
399 /// #### `forwarding`
400 /// Whether to configure sysctl interface-specific forwarding. When enabled, the interface
401 /// will act as a router to forward the packet from one interface to another. When set to
402 /// [`SettingIPConfigForwarding::Default`][crate::SettingIPConfigForwarding::Default], the value from global configuration is used;
403 /// if no global default is defined, [`SettingIPConfigForwarding::Auto`][crate::SettingIPConfigForwarding::Auto] will be used.
404 /// The #NMSettingIPConfig:forwarding property is ignored when #NMSettingIPConfig:method
405 /// is set to "shared", because forwarding is always enabled in this case.
406 /// The accepted values are:
407 /// [`SettingIPConfigForwarding::Default`][crate::SettingIPConfigForwarding::Default]: use global default.
408 /// [`SettingIPConfigForwarding::No`][crate::SettingIPConfigForwarding::No]: disabled.
409 /// [`SettingIPConfigForwarding::Yes`][crate::SettingIPConfigForwarding::Yes]: enabled.
410 /// [`SettingIPConfigForwarding::Auto`][crate::SettingIPConfigForwarding::Auto]: enable if any shared connection is active,
411 /// use kernel default otherwise.
412 ///
413 /// Readable | Writeable
414 ///
415 ///
416 /// #### `gateway`
417 /// The gateway associated with this configuration. This is only meaningful
418 /// if #NMSettingIPConfig:addresses is also set.
419 ///
420 /// Setting the gateway causes NetworkManager to configure a standard default route
421 /// with the gateway as next hop. This is ignored if #NMSettingIPConfig:never-default
422 /// is set. An alternative is to configure the default route explicitly with a manual
423 /// route and /0 as prefix length.
424 ///
425 /// Note that the gateway usually conflicts with routing that NetworkManager configures
426 /// for WireGuard interfaces, so usually it should not be set in that case. See
427 /// #NMSettingWireGuard:ip4-auto-default-route.
428 ///
429 /// Readable | Writeable
430 ///
431 ///
432 /// #### `ignore-auto-dns`
433 /// When #NMSettingIPConfig:method is set to "auto" and this property to
434 /// [`true`], automatically configured name servers and search domains are
435 /// ignored and only name servers and search domains specified in the
436 /// #NMSettingIPConfig:dns and #NMSettingIPConfig:dns-search properties, if
437 /// any, are used.
438 ///
439 /// Readable | Writeable
440 ///
441 ///
442 /// #### `ignore-auto-routes`
443 /// When #NMSettingIPConfig:method is set to "auto" and this property to
444 /// [`true`], automatically configured routes are ignored and only routes
445 /// specified in the #NMSettingIPConfig:routes property, if any, are used.
446 ///
447 /// Readable | Writeable
448 ///
449 ///
450 /// #### `may-fail`
451 /// If [`true`], allow overall network configuration to proceed even if the
452 /// configuration specified by this property times out. Note that at least
453 /// one IP configuration must succeed or overall network configuration will
454 /// still fail. For example, in IPv6-only networks, setting this property to
455 /// [`true`] on the #NMSettingIP4Config allows the overall network configuration
456 /// to succeed if IPv4 configuration fails but IPv6 configuration completes
457 /// successfully.
458 ///
459 /// Readable | Writeable
460 ///
461 ///
462 /// #### `method`
463 /// IP configuration method.
464 ///
465 /// #NMSettingIP4Config and #NMSettingIP6Config both support "disabled",
466 /// "auto", "manual", and "link-local". See the subclass-specific
467 /// documentation for other values.
468 ///
469 /// In general, for the "auto" method, properties such as
470 /// #NMSettingIPConfig:dns and #NMSettingIPConfig:routes specify information
471 /// that is added on to the information returned from automatic
472 /// configuration. The #NMSettingIPConfig:ignore-auto-routes and
473 /// #NMSettingIPConfig:ignore-auto-dns properties modify this behavior.
474 ///
475 /// For methods that imply no upstream network, such as "shared" or
476 /// "link-local", these properties must be empty.
477 ///
478 /// For IPv4 method "shared", the IP subnet can be configured by adding one
479 /// manual IPv4 address or otherwise 10.42.x.0/24 is chosen. Note that the
480 /// shared method must be configured on the interface which shares the internet
481 /// to a subnet, not on the uplink which is shared.
482 ///
483 /// Readable | Writeable
484 ///
485 ///
486 /// #### `never-default`
487 /// If [`true`], this connection will never be the default connection for this
488 /// IP type, meaning it will never be assigned the default route by
489 /// NetworkManager.
490 ///
491 /// Readable | Writeable
492 ///
493 ///
494 /// #### `replace-local-rule`
495 /// Connections will default to keep the autogenerated priority 0 local rule
496 /// unless this setting is set to [`true`].
497 ///
498 /// Readable | Writeable
499 ///
500 ///
501 /// #### `required-timeout`
502 /// The minimum time interval in milliseconds for which dynamic IP configuration
503 /// should be tried before the connection succeeds.
504 ///
505 /// This property is useful for example if both IPv4 and IPv6 are enabled and
506 /// are allowed to fail. Normally the connection succeeds as soon as one of
507 /// the two address families completes; by setting a required timeout for
508 /// e.g. IPv4, one can ensure that even if IP6 succeeds earlier than IPv4,
509 /// NetworkManager waits some time for IPv4 before the connection becomes
510 /// active.
511 ///
512 /// Note that if #NMSettingIPConfig:may-fail is FALSE for the same address
513 /// family, this property has no effect as NetworkManager needs to wait for
514 /// the full DHCP timeout.
515 ///
516 /// A zero value means that no required timeout is present, -1 means the
517 /// default value (either configuration ipvx.required-timeout override or
518 /// zero).
519 ///
520 /// Readable | Writeable
521 ///
522 ///
523 /// #### `route-metric`
524 /// The default metric for routes that don't explicitly specify a metric.
525 /// The default value -1 means that the metric is chosen automatically
526 /// based on the device type.
527 /// The metric applies to dynamic routes, manual (static) routes that
528 /// don't have an explicit metric setting, address prefix routes, and
529 /// the default route.
530 /// Note that for IPv6, the kernel accepts zero (0) but coerces it to
531 /// 1024 (user default). Hence, setting this property to zero effectively
532 /// mean setting it to 1024.
533 /// For IPv4, zero is a regular value for the metric.
534 ///
535 /// Readable | Writeable
536 ///
537 ///
538 /// #### `route-table`
539 /// Enable policy routing (source routing) and set the routing table used when adding routes.
540 ///
541 /// This affects all routes, including device-routes, IPv4LL, DHCP, SLAAC, default-routes
542 /// and static routes. But note that static routes can individually overwrite the setting
543 /// by explicitly specifying a non-zero routing table.
544 ///
545 /// If the table setting is left at zero, it is eligible to be overwritten via global
546 /// configuration. If the property is zero even after applying the global configuration
547 /// value, policy routing is disabled for the address family of this connection.
548 ///
549 /// Policy routing disabled means that NetworkManager will add all routes to the main
550 /// table (except static routes that explicitly configure a different table). Additionally,
551 /// NetworkManager will not delete any extraneous routes from tables except the main table.
552 /// This is to preserve backward compatibility for users who manage routing tables outside
553 /// of NetworkManager.
554 ///
555 /// Readable | Writeable
556 ///
557 ///
558 /// #### `routed-dns`
559 /// Whether to add routes for DNS servers. When enabled, NetworkManager adds a route
560 /// for each DNS server that is associated with this connection either statically
561 /// (defined in the connection profile) or dynamically (for example, retrieved via
562 /// DHCP). The route guarantees that the DNS server is reached via this interface. When
563 /// set to [`SettingIPConfigRoutedDns::Default`][crate::SettingIPConfigRoutedDns::Default], the value from global
564 /// configuration is used; if no global default is defined, this feature is disabled.
565 ///
566 /// Readable | Writeable
567 ///
568 ///
569 /// #### `routes`
570 /// Array of IP routes.
571 ///
572 /// Readable | Writeable
573 ///
574 ///
575 /// #### `shared-dhcp-lease-time`
576 /// This option allows you to specify a custom DHCP lease time for the shared connection
577 /// method in seconds. The value should be either a number between 120 and 31536000 (one year)
578 /// If this option is not specified, 3600 (one hour) is used.
579 ///
580 /// Special values are 0 for default value of 1 hour and 2147483647 (MAXINT32) for infinite lease time.
581 ///
582 /// Readable | Writeable
583 ///
584 ///
585 /// #### `shared-dhcp-range`
586 /// This option allows you to specify a custom DHCP range for the shared connection
587 /// method. The value is expected to be in `<START_ADDRESS>,<END_ADDRESS>` format.
588 /// The range should be part of network set by ipv4.address option and it should
589 /// not contain network address or broadcast address. If this option is not specified,
590 /// the DHCP range will be automatically determined based on the interface address.
591 /// The range will be selected to be adjacent to the interface address, either before
592 /// or after it, with the larger possible range being preferred. The range will be
593 /// adjusted to fill the available address space, except for networks with a prefix
594 /// length greater than 24, which will be treated as if they have a prefix length of 24.
595 ///
596 /// Readable | Writeable
597 /// </details>
598 /// <details><summary><h4>Setting</h4></summary>
599 ///
600 ///
601 /// #### `name`
602 /// The setting's name, which uniquely identifies the setting within the
603 /// connection. Each setting type has a name unique to that type, for
604 /// example "ppp" or "802-11-wireless" or "802-3-ethernet".
605 ///
606 /// Readable
607 /// </details>
608 ///
609 /// # Implements
610 ///
611 /// [`SettingIPConfigExt`][trait@crate::prelude::SettingIPConfigExt], [`SettingExt`][trait@crate::prelude::SettingExt]
612 #[doc(alias = "NMSettingIP4Config")]
613 pub struct SettingIP4Config(Object<ffi::NMSettingIP4Config, ffi::NMSettingIP4ConfigClass>) @extends SettingIPConfig, Setting;
614
615 match fn {
616 type_ => || ffi::nm_setting_ip4_config_get_type(),
617 }
618}
619
620impl SettingIP4Config {
621 /// Creates a new #NMSettingIP4Config object with default values.
622 ///
623 /// # Returns
624 ///
625 /// the new empty #NMSettingIP4Config object
626 #[doc(alias = "nm_setting_ip4_config_new")]
627 pub fn new() -> SettingIP4Config {
628 assert_initialized_main_thread!();
629 unsafe { Setting::from_glib_full(ffi::nm_setting_ip4_config_new()).unsafe_cast() }
630 }
631
632 // rustdoc-stripper-ignore-next
633 /// Creates a new builder-pattern struct instance to construct [`SettingIP4Config`] objects.
634 ///
635 /// This method returns an instance of [`SettingIP4ConfigBuilder`](crate::builders::SettingIP4ConfigBuilder) which can be used to create [`SettingIP4Config`] objects.
636 pub fn builder() -> SettingIP4ConfigBuilder {
637 SettingIP4ConfigBuilder::new()
638 }
639
640 /// Returns the value contained in the #NMSettingIP4Config:dhcp-client-id
641 /// property.
642 ///
643 /// # Returns
644 ///
645 /// the configured Client ID to send to the DHCP server when requesting
646 /// addresses via DHCP.
647 #[doc(alias = "nm_setting_ip4_config_get_dhcp_client_id")]
648 #[doc(alias = "get_dhcp_client_id")]
649 #[doc(alias = "dhcp-client-id")]
650 pub fn dhcp_client_id(&self) -> glib::GString {
651 unsafe {
652 from_glib_none(ffi::nm_setting_ip4_config_get_dhcp_client_id(
653 self.to_glib_none().0,
654 ))
655 }
656 }
657
658 /// Returns the value contained in the #NMSettingIP4Config:dhcp-fqdn
659 /// property.
660 ///
661 /// # Returns
662 ///
663 /// the configured FQDN to send to the DHCP server
664 #[cfg(feature = "v1_2")]
665 #[cfg_attr(docsrs, doc(cfg(feature = "v1_2")))]
666 #[doc(alias = "nm_setting_ip4_config_get_dhcp_fqdn")]
667 #[doc(alias = "get_dhcp_fqdn")]
668 #[doc(alias = "dhcp-fqdn")]
669 pub fn dhcp_fqdn(&self) -> glib::GString {
670 unsafe {
671 from_glib_none(ffi::nm_setting_ip4_config_get_dhcp_fqdn(
672 self.to_glib_none().0,
673 ))
674 }
675 }
676
677 /// Returns the value in the #NMSettingIP4Config:dhcp-ipv6-only-preferred
678 /// property.
679 ///
680 /// # Returns
681 ///
682 /// the DHCP IPv6-only preferred property value
683 #[cfg(feature = "v1_52")]
684 #[cfg_attr(docsrs, doc(cfg(feature = "v1_52")))]
685 #[doc(alias = "nm_setting_ip4_config_get_dhcp_ipv6_only_preferred")]
686 #[doc(alias = "get_dhcp_ipv6_only_preferred")]
687 #[doc(alias = "dhcp-ipv6-only-preferred")]
688 pub fn dhcp_ipv6_only_preferred(&self) -> SettingIP4DhcpIpv6OnlyPreferred {
689 unsafe {
690 from_glib(ffi::nm_setting_ip4_config_get_dhcp_ipv6_only_preferred(
691 self.to_glib_none().0,
692 ))
693 }
694 }
695
696 /// Returns the value contained in the #NMSettingIP4Config:dhcp_vendor_class_identifier
697 /// property.
698 ///
699 /// # Returns
700 ///
701 /// the vendor class identifier option to send to the DHCP server
702 #[cfg(feature = "v1_28")]
703 #[cfg_attr(docsrs, doc(cfg(feature = "v1_28")))]
704 #[doc(alias = "nm_setting_ip4_config_get_dhcp_vendor_class_identifier")]
705 #[doc(alias = "get_dhcp_vendor_class_identifier")]
706 #[doc(alias = "dhcp-vendor-class-identifier")]
707 pub fn dhcp_vendor_class_identifier(&self) -> glib::GString {
708 unsafe {
709 from_glib_none(ffi::nm_setting_ip4_config_get_dhcp_vendor_class_identifier(
710 self.to_glib_none().0,
711 ))
712 }
713 }
714
715 /// Returns the value contained in the #NMSettingIP4Config:link_local
716 /// property.
717 ///
718 /// # Returns
719 ///
720 /// the link-local configuration
721 #[cfg(feature = "v1_42")]
722 #[cfg_attr(docsrs, doc(cfg(feature = "v1_42")))]
723 #[doc(alias = "nm_setting_ip4_config_get_link_local")]
724 #[doc(alias = "get_link_local")]
725 #[doc(alias = "link-local")]
726 pub fn link_local(&self) -> SettingIP4LinkLocal {
727 unsafe {
728 from_glib(ffi::nm_setting_ip4_config_get_link_local(
729 self.to_glib_none().0,
730 ))
731 }
732 }
733
734 /// A string sent to the DHCP server to identify the local machine which the
735 /// DHCP server may use to customize the DHCP lease and options.
736 /// When the property is a hex string ('aa:bb:cc') it is interpreted as a
737 /// binary client ID, in which case the first byte is assumed to be the
738 /// 'type' field as per RFC 2132 section 9.14 and the remaining bytes may be
739 /// an hardware address (e.g. '01:xx:xx:xx:xx:xx:xx' where 1 is the Ethernet
740 /// ARP type and the rest is a MAC address).
741 /// If the property is not a hex string it is considered as a
742 /// non-hardware-address client ID and the 'type' field is set to 0.
743 ///
744 /// The special values "mac" and "perm-mac" are supported, which use the
745 /// current or permanent MAC address of the device to generate a client identifier
746 /// with type ethernet (01). Currently, these options only work for ethernet
747 /// type of links.
748 ///
749 /// The special value "ipv6-duid" uses the DUID from "ipv6.dhcp-duid" property as
750 /// an RFC4361-compliant client identifier. As IAID it uses "ipv4.dhcp-iaid"
751 /// and falls back to "ipv6.dhcp-iaid" if unset.
752 ///
753 /// The special value "duid" generates a RFC4361-compliant client identifier based
754 /// on "ipv4.dhcp-iaid" and uses a DUID generated by hashing /etc/machine-id.
755 ///
756 /// The special value "stable" is supported to generate a type 0 client identifier based
757 /// on the stable-id (see connection.stable-id) and a per-host key. If you set the
758 /// stable-id, you may want to include the "${DEVICE}" or "${MAC}" specifier to get a
759 /// per-device key.
760 ///
761 /// The special value "none" prevents any client identifier from being sent. Note that
762 /// this is normally not recommended.
763 ///
764 /// If unset, a globally configured default from NetworkManager.conf is
765 /// used. If still unset, the default depends on the DHCP plugin. The
766 /// internal dhcp client will default to "mac" and the dhclient plugin will
767 /// try to use one from its config file if present, or won't sent any
768 /// client-id otherwise.
769 #[doc(alias = "dhcp-client-id")]
770 pub fn set_dhcp_client_id(&self, dhcp_client_id: Option<&str>) {
771 ObjectExt::set_property(self, "dhcp-client-id", dhcp_client_id)
772 }
773
774 /// If the #NMSettingIPConfig:dhcp-send-hostname property is [`true`], then the
775 /// specified FQDN will be sent to the DHCP server when acquiring a lease. This
776 /// property and #NMSettingIPConfig:dhcp-hostname are mutually exclusive and
777 /// cannot be set at the same time.
778 #[cfg(feature = "v1_2")]
779 #[cfg_attr(docsrs, doc(cfg(feature = "v1_2")))]
780 #[doc(alias = "dhcp-fqdn")]
781 pub fn set_dhcp_fqdn(&self, dhcp_fqdn: Option<&str>) {
782 ObjectExt::set_property(self, "dhcp-fqdn", dhcp_fqdn)
783 }
784
785 /// Controls the "IPv6-Only Preferred" DHCPv4 option (RFC 8925).
786 ///
787 /// When set to [`SettingIP4DhcpIpv6OnlyPreferred::Yes`][crate::SettingIP4DhcpIpv6OnlyPreferred::Yes], the host adds the
788 /// option to the parameter request list; if the DHCP server sends the option back,
789 /// the host stops the DHCP client for the time interval specified in the option.
790 ///
791 /// Enable this feature if the host supports an IPv6-only mode, i.e. either all
792 /// applications are IPv6-only capable or there is a form of 464XLAT deployed.
793 ///
794 /// When set to [`SettingIP4DhcpIpv6OnlyPreferred::Default`][crate::SettingIP4DhcpIpv6OnlyPreferred::Default], the actual value
795 /// is looked up in the global configuration; if not specified, it defaults to
796 /// [`SettingIP4DhcpIpv6OnlyPreferred::No`][crate::SettingIP4DhcpIpv6OnlyPreferred::No].
797 ///
798 /// If the connection has IPv6 method set to "disabled", this property does not
799 /// have effect and the "IPv6-Only Preferred" option is always disabled.
800 #[cfg(feature = "v1_52")]
801 #[cfg_attr(docsrs, doc(cfg(feature = "v1_52")))]
802 #[doc(alias = "dhcp-ipv6-only-preferred")]
803 pub fn set_dhcp_ipv6_only_preferred(&self, dhcp_ipv6_only_preferred: i32) {
804 ObjectExt::set_property(self, "dhcp-ipv6-only-preferred", dhcp_ipv6_only_preferred)
805 }
806
807 /// The Vendor Class Identifier DHCP option (60).
808 /// Special characters in the data string may be escaped using C-style escapes,
809 /// nevertheless this property cannot contain nul bytes.
810 /// If the per-profile value is unspecified (the default),
811 /// a global connection default gets consulted.
812 /// If still unspecified, the DHCP option is not sent to the server.
813 #[cfg(feature = "v1_28")]
814 #[cfg_attr(docsrs, doc(cfg(feature = "v1_28")))]
815 #[doc(alias = "dhcp-vendor-class-identifier")]
816 pub fn set_dhcp_vendor_class_identifier(&self, dhcp_vendor_class_identifier: Option<&str>) {
817 ObjectExt::set_property(
818 self,
819 "dhcp-vendor-class-identifier",
820 dhcp_vendor_class_identifier,
821 )
822 }
823
824 #[cfg(not(feature = "v1_42"))]
825 #[cfg_attr(docsrs, doc(cfg(not(feature = "v1_42"))))]
826 #[doc(alias = "link-local")]
827 pub fn link_local(&self) -> i32 {
828 ObjectExt::property(self, "link-local")
829 }
830
831 /// Enable and disable the IPv4 link-local configuration independently of the
832 /// ipv4.method configuration. This allows a link-local address (169.254.x.y/16)
833 /// to be obtained in addition to other addresses, such as those manually
834 /// configured or obtained from a DHCP server.
835 ///
836 /// When set to "auto", the value is dependent on "ipv4.method".
837 /// When set to "default", it honors the global connection default, before
838 /// falling back to "auto". Note that if "ipv4.method" is "disabled", then
839 /// link local addressing is always disabled too. The default is "default".
840 /// Since 1.52, when set to "fallback", a link-local address is obtained
841 /// if no other IPv4 address is set.
842 #[cfg(feature = "v1_40")]
843 #[cfg_attr(docsrs, doc(cfg(feature = "v1_40")))]
844 #[doc(alias = "link-local")]
845 pub fn set_link_local(&self, link_local: i32) {
846 ObjectExt::set_property(self, "link-local", link_local)
847 }
848
849 #[doc(alias = "dhcp-client-id")]
850 pub fn connect_dhcp_client_id_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
851 unsafe extern "C" fn notify_dhcp_client_id_trampoline<
852 F: Fn(&SettingIP4Config) + 'static,
853 >(
854 this: *mut ffi::NMSettingIP4Config,
855 _param_spec: glib::ffi::gpointer,
856 f: glib::ffi::gpointer,
857 ) {
858 let f: &F = &*(f as *const F);
859 f(&from_glib_borrow(this))
860 }
861 unsafe {
862 let f: Box_<F> = Box_::new(f);
863 connect_raw(
864 self.as_ptr() as *mut _,
865 c"notify::dhcp-client-id".as_ptr() as *const _,
866 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
867 notify_dhcp_client_id_trampoline::<F> as *const (),
868 )),
869 Box_::into_raw(f),
870 )
871 }
872 }
873
874 #[cfg(feature = "v1_2")]
875 #[cfg_attr(docsrs, doc(cfg(feature = "v1_2")))]
876 #[doc(alias = "dhcp-fqdn")]
877 pub fn connect_dhcp_fqdn_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
878 unsafe extern "C" fn notify_dhcp_fqdn_trampoline<F: Fn(&SettingIP4Config) + 'static>(
879 this: *mut ffi::NMSettingIP4Config,
880 _param_spec: glib::ffi::gpointer,
881 f: glib::ffi::gpointer,
882 ) {
883 let f: &F = &*(f as *const F);
884 f(&from_glib_borrow(this))
885 }
886 unsafe {
887 let f: Box_<F> = Box_::new(f);
888 connect_raw(
889 self.as_ptr() as *mut _,
890 c"notify::dhcp-fqdn".as_ptr() as *const _,
891 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
892 notify_dhcp_fqdn_trampoline::<F> as *const (),
893 )),
894 Box_::into_raw(f),
895 )
896 }
897 }
898
899 #[cfg(feature = "v1_52")]
900 #[cfg_attr(docsrs, doc(cfg(feature = "v1_52")))]
901 #[doc(alias = "dhcp-ipv6-only-preferred")]
902 pub fn connect_dhcp_ipv6_only_preferred_notify<F: Fn(&Self) + 'static>(
903 &self,
904 f: F,
905 ) -> SignalHandlerId {
906 unsafe extern "C" fn notify_dhcp_ipv6_only_preferred_trampoline<
907 F: Fn(&SettingIP4Config) + 'static,
908 >(
909 this: *mut ffi::NMSettingIP4Config,
910 _param_spec: glib::ffi::gpointer,
911 f: glib::ffi::gpointer,
912 ) {
913 let f: &F = &*(f as *const F);
914 f(&from_glib_borrow(this))
915 }
916 unsafe {
917 let f: Box_<F> = Box_::new(f);
918 connect_raw(
919 self.as_ptr() as *mut _,
920 c"notify::dhcp-ipv6-only-preferred".as_ptr() as *const _,
921 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
922 notify_dhcp_ipv6_only_preferred_trampoline::<F> as *const (),
923 )),
924 Box_::into_raw(f),
925 )
926 }
927 }
928
929 #[cfg(feature = "v1_28")]
930 #[cfg_attr(docsrs, doc(cfg(feature = "v1_28")))]
931 #[doc(alias = "dhcp-vendor-class-identifier")]
932 pub fn connect_dhcp_vendor_class_identifier_notify<F: Fn(&Self) + 'static>(
933 &self,
934 f: F,
935 ) -> SignalHandlerId {
936 unsafe extern "C" fn notify_dhcp_vendor_class_identifier_trampoline<
937 F: Fn(&SettingIP4Config) + 'static,
938 >(
939 this: *mut ffi::NMSettingIP4Config,
940 _param_spec: glib::ffi::gpointer,
941 f: glib::ffi::gpointer,
942 ) {
943 let f: &F = &*(f as *const F);
944 f(&from_glib_borrow(this))
945 }
946 unsafe {
947 let f: Box_<F> = Box_::new(f);
948 connect_raw(
949 self.as_ptr() as *mut _,
950 c"notify::dhcp-vendor-class-identifier".as_ptr() as *const _,
951 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
952 notify_dhcp_vendor_class_identifier_trampoline::<F> as *const (),
953 )),
954 Box_::into_raw(f),
955 )
956 }
957 }
958
959 #[cfg(feature = "v1_40")]
960 #[cfg_attr(docsrs, doc(cfg(feature = "v1_40")))]
961 #[doc(alias = "link-local")]
962 pub fn connect_link_local_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
963 unsafe extern "C" fn notify_link_local_trampoline<F: Fn(&SettingIP4Config) + 'static>(
964 this: *mut ffi::NMSettingIP4Config,
965 _param_spec: glib::ffi::gpointer,
966 f: glib::ffi::gpointer,
967 ) {
968 let f: &F = &*(f as *const F);
969 f(&from_glib_borrow(this))
970 }
971 unsafe {
972 let f: Box_<F> = Box_::new(f);
973 connect_raw(
974 self.as_ptr() as *mut _,
975 c"notify::link-local".as_ptr() as *const _,
976 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
977 notify_link_local_trampoline::<F> as *const (),
978 )),
979 Box_::into_raw(f),
980 )
981 }
982 }
983}
984
985impl Default for SettingIP4Config {
986 fn default() -> Self {
987 Self::new()
988 }
989}
990
991// rustdoc-stripper-ignore-next
992/// A [builder-pattern] type to construct [`SettingIP4Config`] objects.
993///
994/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
995#[must_use = "The builder must be built to be used"]
996pub struct SettingIP4ConfigBuilder {
997 builder: glib::object::ObjectBuilder<'static, SettingIP4Config>,
998}
999
1000impl SettingIP4ConfigBuilder {
1001 fn new() -> Self {
1002 Self {
1003 builder: glib::object::Object::builder(),
1004 }
1005 }
1006
1007 /// A string sent to the DHCP server to identify the local machine which the
1008 /// DHCP server may use to customize the DHCP lease and options.
1009 /// When the property is a hex string ('aa:bb:cc') it is interpreted as a
1010 /// binary client ID, in which case the first byte is assumed to be the
1011 /// 'type' field as per RFC 2132 section 9.14 and the remaining bytes may be
1012 /// an hardware address (e.g. '01:xx:xx:xx:xx:xx:xx' where 1 is the Ethernet
1013 /// ARP type and the rest is a MAC address).
1014 /// If the property is not a hex string it is considered as a
1015 /// non-hardware-address client ID and the 'type' field is set to 0.
1016 ///
1017 /// The special values "mac" and "perm-mac" are supported, which use the
1018 /// current or permanent MAC address of the device to generate a client identifier
1019 /// with type ethernet (01). Currently, these options only work for ethernet
1020 /// type of links.
1021 ///
1022 /// The special value "ipv6-duid" uses the DUID from "ipv6.dhcp-duid" property as
1023 /// an RFC4361-compliant client identifier. As IAID it uses "ipv4.dhcp-iaid"
1024 /// and falls back to "ipv6.dhcp-iaid" if unset.
1025 ///
1026 /// The special value "duid" generates a RFC4361-compliant client identifier based
1027 /// on "ipv4.dhcp-iaid" and uses a DUID generated by hashing /etc/machine-id.
1028 ///
1029 /// The special value "stable" is supported to generate a type 0 client identifier based
1030 /// on the stable-id (see connection.stable-id) and a per-host key. If you set the
1031 /// stable-id, you may want to include the "${DEVICE}" or "${MAC}" specifier to get a
1032 /// per-device key.
1033 ///
1034 /// The special value "none" prevents any client identifier from being sent. Note that
1035 /// this is normally not recommended.
1036 ///
1037 /// If unset, a globally configured default from NetworkManager.conf is
1038 /// used. If still unset, the default depends on the DHCP plugin. The
1039 /// internal dhcp client will default to "mac" and the dhclient plugin will
1040 /// try to use one from its config file if present, or won't sent any
1041 /// client-id otherwise.
1042 pub fn dhcp_client_id(self, dhcp_client_id: impl Into<glib::GString>) -> Self {
1043 Self {
1044 builder: self
1045 .builder
1046 .property("dhcp-client-id", dhcp_client_id.into()),
1047 }
1048 }
1049
1050 /// If the #NMSettingIPConfig:dhcp-send-hostname property is [`true`], then the
1051 /// specified FQDN will be sent to the DHCP server when acquiring a lease. This
1052 /// property and #NMSettingIPConfig:dhcp-hostname are mutually exclusive and
1053 /// cannot be set at the same time.
1054 #[cfg(feature = "v1_2")]
1055 #[cfg_attr(docsrs, doc(cfg(feature = "v1_2")))]
1056 pub fn dhcp_fqdn(self, dhcp_fqdn: impl Into<glib::GString>) -> Self {
1057 Self {
1058 builder: self.builder.property("dhcp-fqdn", dhcp_fqdn.into()),
1059 }
1060 }
1061
1062 /// Controls the "IPv6-Only Preferred" DHCPv4 option (RFC 8925).
1063 ///
1064 /// When set to [`SettingIP4DhcpIpv6OnlyPreferred::Yes`][crate::SettingIP4DhcpIpv6OnlyPreferred::Yes], the host adds the
1065 /// option to the parameter request list; if the DHCP server sends the option back,
1066 /// the host stops the DHCP client for the time interval specified in the option.
1067 ///
1068 /// Enable this feature if the host supports an IPv6-only mode, i.e. either all
1069 /// applications are IPv6-only capable or there is a form of 464XLAT deployed.
1070 ///
1071 /// When set to [`SettingIP4DhcpIpv6OnlyPreferred::Default`][crate::SettingIP4DhcpIpv6OnlyPreferred::Default], the actual value
1072 /// is looked up in the global configuration; if not specified, it defaults to
1073 /// [`SettingIP4DhcpIpv6OnlyPreferred::No`][crate::SettingIP4DhcpIpv6OnlyPreferred::No].
1074 ///
1075 /// If the connection has IPv6 method set to "disabled", this property does not
1076 /// have effect and the "IPv6-Only Preferred" option is always disabled.
1077 #[cfg(feature = "v1_52")]
1078 #[cfg_attr(docsrs, doc(cfg(feature = "v1_52")))]
1079 pub fn dhcp_ipv6_only_preferred(self, dhcp_ipv6_only_preferred: i32) -> Self {
1080 Self {
1081 builder: self
1082 .builder
1083 .property("dhcp-ipv6-only-preferred", dhcp_ipv6_only_preferred),
1084 }
1085 }
1086
1087 /// The Vendor Class Identifier DHCP option (60).
1088 /// Special characters in the data string may be escaped using C-style escapes,
1089 /// nevertheless this property cannot contain nul bytes.
1090 /// If the per-profile value is unspecified (the default),
1091 /// a global connection default gets consulted.
1092 /// If still unspecified, the DHCP option is not sent to the server.
1093 #[cfg(feature = "v1_28")]
1094 #[cfg_attr(docsrs, doc(cfg(feature = "v1_28")))]
1095 pub fn dhcp_vendor_class_identifier(
1096 self,
1097 dhcp_vendor_class_identifier: impl Into<glib::GString>,
1098 ) -> Self {
1099 Self {
1100 builder: self.builder.property(
1101 "dhcp-vendor-class-identifier",
1102 dhcp_vendor_class_identifier.into(),
1103 ),
1104 }
1105 }
1106
1107 /// Enable and disable the IPv4 link-local configuration independently of the
1108 /// ipv4.method configuration. This allows a link-local address (169.254.x.y/16)
1109 /// to be obtained in addition to other addresses, such as those manually
1110 /// configured or obtained from a DHCP server.
1111 ///
1112 /// When set to "auto", the value is dependent on "ipv4.method".
1113 /// When set to "default", it honors the global connection default, before
1114 /// falling back to "auto". Note that if "ipv4.method" is "disabled", then
1115 /// link local addressing is always disabled too. The default is "default".
1116 /// Since 1.52, when set to "fallback", a link-local address is obtained
1117 /// if no other IPv4 address is set.
1118 #[cfg(feature = "v1_40")]
1119 #[cfg_attr(docsrs, doc(cfg(feature = "v1_40")))]
1120 pub fn link_local(self, link_local: i32) -> Self {
1121 Self {
1122 builder: self.builder.property("link-local", link_local),
1123 }
1124 }
1125
1126 /// Array of IP addresses.
1127 pub fn addresses(self, addresses: &[&IPAddress]) -> Self {
1128 Self {
1129 builder: self.builder.property(
1130 "addresses",
1131 addresses
1132 .iter()
1133 .map(|address| address.to_value())
1134 .collect::<glib::ValueArray>(),
1135 ),
1136 }
1137 }
1138
1139 /// VPN connections will default to add the route automatically unless this
1140 /// setting is set to [`false`].
1141 ///
1142 /// For other connection types, adding such an automatic route is currently
1143 /// not supported and setting this to [`true`] has no effect.
1144 #[cfg(feature = "v1_42")]
1145 #[cfg_attr(docsrs, doc(cfg(feature = "v1_42")))]
1146 pub fn auto_route_ext_gw(self, auto_route_ext_gw: Ternary) -> Self {
1147 Self {
1148 builder: self
1149 .builder
1150 .property("auto-route-ext-gw", auto_route_ext_gw),
1151 }
1152 }
1153
1154 /// Maximum timeout in milliseconds used to check for the presence of duplicate
1155 /// IP addresses on the network. If an address conflict is detected, the
1156 /// activation will fail. The property is currently implemented only for IPv4.
1157 ///
1158 /// A zero value means that no duplicate address detection is performed, -1 means
1159 /// the default value (either the value configured globally in NetworkManger.conf
1160 /// or 200ms). A value greater than zero is a timeout in milliseconds. Note that
1161 /// the time intervals are subject to randomization as per RFC 5227 and so the
1162 /// actual duration can be between half and the full time specified in this
1163 /// property.
1164 #[cfg(feature = "v1_2")]
1165 #[cfg_attr(docsrs, doc(cfg(feature = "v1_2")))]
1166 pub fn dad_timeout(self, dad_timeout: i32) -> Self {
1167 Self {
1168 builder: self.builder.property("dad-timeout", dad_timeout),
1169 }
1170 }
1171
1172 /// Specifies the value for the DSCP field (traffic class) of the IP header. When
1173 /// empty, the global default value is used; if no global default is specified, it is
1174 /// assumed to be "CS0". Allowed values are: "CS0", "CS4" and "CS6".
1175 ///
1176 /// The property is currently valid only for IPv4, and it is supported only by the
1177 /// "internal" DHCP plugin.
1178 #[cfg(feature = "v1_46")]
1179 #[cfg_attr(docsrs, doc(cfg(feature = "v1_46")))]
1180 pub fn dhcp_dscp(self, dhcp_dscp: impl Into<glib::GString>) -> Self {
1181 Self {
1182 builder: self.builder.property("dhcp-dscp", dhcp_dscp.into()),
1183 }
1184 }
1185
1186 /// If the #NMSettingIPConfig:dhcp-send-hostname property is [`true`], then the
1187 /// specified name will be sent to the DHCP server when acquiring a lease.
1188 /// This property and #NMSettingIP4Config:dhcp-fqdn are mutually exclusive and
1189 /// cannot be set at the same time.
1190 pub fn dhcp_hostname(self, dhcp_hostname: impl Into<glib::GString>) -> Self {
1191 Self {
1192 builder: self.builder.property("dhcp-hostname", dhcp_hostname.into()),
1193 }
1194 }
1195
1196 /// Flags for the DHCP hostname and FQDN.
1197 ///
1198 /// Currently, this property only includes flags to control the FQDN flags
1199 /// set in the DHCP FQDN option. Supported FQDN flags are
1200 /// [`DhcpHostnameFlags::FQDN_SERV_UPDATE`][crate::DhcpHostnameFlags::FQDN_SERV_UPDATE],
1201 /// [`DhcpHostnameFlags::FQDN_ENCODED`][crate::DhcpHostnameFlags::FQDN_ENCODED] and
1202 /// [`DhcpHostnameFlags::FQDN_NO_UPDATE`][crate::DhcpHostnameFlags::FQDN_NO_UPDATE]. When no FQDN flag is set and
1203 /// [`DhcpHostnameFlags::FQDN_CLEAR_FLAGS`][crate::DhcpHostnameFlags::FQDN_CLEAR_FLAGS] is set, the DHCP FQDN option will
1204 /// contain no flag. Otherwise, if no FQDN flag is set and
1205 /// [`DhcpHostnameFlags::FQDN_CLEAR_FLAGS`][crate::DhcpHostnameFlags::FQDN_CLEAR_FLAGS] is not set, the standard FQDN flags
1206 /// are set in the request:
1207 /// [`DhcpHostnameFlags::FQDN_SERV_UPDATE`][crate::DhcpHostnameFlags::FQDN_SERV_UPDATE],
1208 /// [`DhcpHostnameFlags::FQDN_ENCODED`][crate::DhcpHostnameFlags::FQDN_ENCODED] for IPv4 and
1209 /// [`DhcpHostnameFlags::FQDN_SERV_UPDATE`][crate::DhcpHostnameFlags::FQDN_SERV_UPDATE] for IPv6.
1210 ///
1211 /// When this property is set to the default value [`DhcpHostnameFlags::NONE`][crate::DhcpHostnameFlags::NONE],
1212 /// a global default is looked up in NetworkManager configuration. If that value
1213 /// is unset or also [`DhcpHostnameFlags::NONE`][crate::DhcpHostnameFlags::NONE], then the standard FQDN flags
1214 /// described above are sent in the DHCP requests.
1215 #[cfg(feature = "v1_22")]
1216 #[cfg_attr(docsrs, doc(cfg(feature = "v1_22")))]
1217 pub fn dhcp_hostname_flags(self, dhcp_hostname_flags: u32) -> Self {
1218 Self {
1219 builder: self
1220 .builder
1221 .property("dhcp-hostname-flags", dhcp_hostname_flags),
1222 }
1223 }
1224
1225 /// A string containing the "Identity Association Identifier" (IAID) used by
1226 /// the DHCP client. The string can be a 32-bit number (either decimal,
1227 /// hexadecimal or as colon separated hexadecimal numbers). Alternatively
1228 /// it can be set to the special values "mac", "perm-mac", "ifname" or
1229 /// "stable". When set to "mac" (or "perm-mac"), the last 4 bytes of the
1230 /// current (or permanent) MAC address are used as IAID. When set to
1231 /// "ifname", the IAID is computed by hashing the interface name. The
1232 /// special value "stable" can be used to generate an IAID based on the
1233 /// stable-id (see connection.stable-id), a per-host key and the interface
1234 /// name. When the property is unset, the value from global configuration is
1235 /// used; if no global default is set then the IAID is assumed to be
1236 /// "ifname".
1237 ///
1238 /// For DHCPv4, the IAID is only used with "ipv4.dhcp-client-id"
1239 /// values "duid" and "ipv6-duid" to generate the client-id.
1240 ///
1241 /// For DHCPv6, note that at the moment this property is
1242 /// only supported by the "internal" DHCPv6 plugin. The "dhclient" DHCPv6
1243 /// plugin always derives the IAID from the MAC address.
1244 ///
1245 /// The actually used DHCPv6 IAID for a currently activated interface is
1246 /// exposed in the lease information of the device.
1247 #[cfg(feature = "v1_22")]
1248 #[cfg_attr(docsrs, doc(cfg(feature = "v1_22")))]
1249 pub fn dhcp_iaid(self, dhcp_iaid: impl Into<glib::GString>) -> Self {
1250 Self {
1251 builder: self.builder.property("dhcp-iaid", dhcp_iaid.into()),
1252 }
1253 }
1254
1255 /// Array of servers from which DHCP offers must be rejected. This property
1256 /// is useful to avoid getting a lease from misconfigured or rogue servers.
1257 ///
1258 /// For DHCPv4, each element must be an IPv4 address, optionally
1259 /// followed by a slash and a prefix length (e.g. "192.168.122.0/24").
1260 ///
1261 /// This property is currently not implemented for DHCPv6.
1262 #[cfg(feature = "v1_28")]
1263 #[cfg_attr(docsrs, doc(cfg(feature = "v1_28")))]
1264 pub fn dhcp_reject_servers(self, dhcp_reject_servers: impl Into<glib::StrV>) -> Self {
1265 Self {
1266 builder: self
1267 .builder
1268 .property("dhcp-reject-servers", dhcp_reject_servers.into()),
1269 }
1270 }
1271
1272 /// Since 1.52 this property is deprecated and is only used as fallback value
1273 /// for #NMSettingIPConfig:dhcp-send-hostname-v2 if it's set to 'default'.
1274 /// This is only done to avoid breaking existing configurations, the new
1275 /// property should be used from now on.
1276 /// use the new version of dhcp-send-hostname instead.
1277 #[cfg_attr(feature = "v1_52", deprecated = "Since 1.52")]
1278 pub fn dhcp_send_hostname(self, dhcp_send_hostname: bool) -> Self {
1279 Self {
1280 builder: self
1281 .builder
1282 .property("dhcp-send-hostname", dhcp_send_hostname),
1283 }
1284 }
1285
1286 /// If [`true`], a hostname is sent to the DHCP server when acquiring a lease.
1287 /// Some DHCP servers use this hostname to update DNS databases, essentially
1288 /// providing a static hostname for the computer. If the
1289 /// #NMSettingIPConfig:dhcp-hostname property is [`None`] and this property is
1290 /// [`true`], the current persistent hostname of the computer is sent.
1291 ///
1292 /// The default value is [`Ternary::Default`][crate::Ternary::Default]. In this case the global value
1293 /// from NetworkManager configuration is looked up. If it's not set, the value
1294 /// from #NMSettingIPConfig:dhcp-send-hostname, which defaults to [`true`], is
1295 /// used for backwards compatibility. In the future this will change and, in
1296 /// absence of a global default, it will always fallback to [`true`].
1297 #[cfg(feature = "v1_52")]
1298 #[cfg_attr(docsrs, doc(cfg(feature = "v1_52")))]
1299 pub fn dhcp_send_hostname_v2(self, dhcp_send_hostname_v2: i32) -> Self {
1300 Self {
1301 builder: self
1302 .builder
1303 .property("dhcp-send-hostname-v2", dhcp_send_hostname_v2),
1304 }
1305 }
1306
1307 /// Whether the DHCP client will send RELEASE message when
1308 /// bringing the connection down. The default value is [`Ternary::Default`][crate::Ternary::Default].
1309 /// When the default value is specified, then the global value from NetworkManager
1310 /// configuration is looked up, if not set, it is considered as [`false`].
1311 #[cfg(feature = "v1_48")]
1312 #[cfg_attr(docsrs, doc(cfg(feature = "v1_48")))]
1313 pub fn dhcp_send_release(self, dhcp_send_release: Ternary) -> Self {
1314 Self {
1315 builder: self
1316 .builder
1317 .property("dhcp-send-release", dhcp_send_release),
1318 }
1319 }
1320
1321 /// A timeout for a DHCP transaction in seconds. If zero (the default), a
1322 /// globally configured default is used. If still unspecified, a device specific
1323 /// timeout is used (usually 45 seconds).
1324 ///
1325 /// Set to 2147483647 (MAXINT32) for infinity.
1326 pub fn dhcp_timeout(self, dhcp_timeout: i32) -> Self {
1327 Self {
1328 builder: self.builder.property("dhcp-timeout", dhcp_timeout),
1329 }
1330 }
1331
1332 /// Array of DNS servers.
1333 ///
1334 /// Each server can be specified either as a plain IP address (optionally followed
1335 /// by a "#" and the SNI server name for DNS over TLS) or with a URI syntax.
1336 ///
1337 /// When it is specified as an URI, the following forms are supported:
1338 /// dns+udp://ADDRESS[:PORT], dns+tls://ADDRESS[:PORT][#SERVERNAME] .
1339 ///
1340 /// When using the URI syntax, IPv6 addresses must be enclosed in square
1341 /// brackets ('[', ']').
1342 pub fn dns(self, dns: impl Into<glib::StrV>) -> Self {
1343 Self {
1344 builder: self.builder.property("dns", dns.into()),
1345 }
1346 }
1347
1348 /// Array of DNS options to be added to resolv.conf.
1349 ///
1350 /// [`None`] means that the options are unset and left at the default.
1351 /// In this case NetworkManager will use default options. This is
1352 /// distinct from an empty list of properties.
1353 ///
1354 /// The following options are directly added to resolv.conf: "attempts",
1355 /// "debug", "edns0",
1356 /// "inet6", "ip6-bytestring", "ip6-dotint", "ndots", "no-aaaa",
1357 /// "no-check-names", "no-ip6-dotint", "no-reload", "no-tld-query",
1358 /// "rotate", "single-request", "single-request-reopen", "timeout",
1359 /// "trust-ad", "use-vc". See the resolv.conf(5) man page for a
1360 /// detailed description of these options.
1361 ///
1362 /// In addition, NetworkManager supports the special options "_no-add-edns0"
1363 /// and "_no-add-trust-ad". They are not added to resolv.conf, and can be
1364 /// used to prevent the automatic addition of options "edns0" and "trust-ad"
1365 /// when using caching DNS plugins (see below).
1366 ///
1367 /// The "trust-ad" setting is only honored if the profile contributes
1368 /// name servers to resolv.conf, and if all contributing profiles have
1369 /// "trust-ad" enabled.
1370 ///
1371 /// When using a caching DNS plugin (dnsmasq or systemd-resolved in
1372 /// NetworkManager.conf) then "edns0" and "trust-ad" are automatically
1373 /// added, unless "_no-add-edns0" and "_no-add-trust-ad" are present.
1374 #[cfg(feature = "v1_2")]
1375 #[cfg_attr(docsrs, doc(cfg(feature = "v1_2")))]
1376 pub fn dns_options(self, dns_options: impl Into<glib::StrV>) -> Self {
1377 Self {
1378 builder: self.builder.property("dns-options", dns_options.into()),
1379 }
1380 }
1381
1382 /// DNS servers priority.
1383 ///
1384 /// The relative priority for DNS servers specified by this setting. A lower
1385 /// numerical value is better (higher priority).
1386 ///
1387 /// Negative values have the special effect of excluding other configurations
1388 /// with a greater numerical priority value; so in presence of at least one negative
1389 /// priority, only DNS servers from connections with the lowest priority value will be used.
1390 /// To avoid all DNS leaks, set the priority of the profile that should be used
1391 /// to the most negative value of all active connections profiles.
1392 ///
1393 /// Zero selects a globally configured default value. If the latter is missing
1394 /// or zero too, it defaults to 50 for VPNs (including WireGuard) and 100 for
1395 /// other connections.
1396 ///
1397 /// Note that the priority is to order DNS settings for multiple active
1398 /// connections. It does not disambiguate multiple DNS servers within the
1399 /// same connection profile.
1400 ///
1401 /// When multiple devices have configurations with the same priority, VPNs will be
1402 /// considered first, then devices with the best (lowest metric) default
1403 /// route and then all other devices.
1404 ///
1405 /// When using dns=default, servers with higher priority will be on top of
1406 /// resolv.conf. To prioritize a given server over another one within the
1407 /// same connection, just specify them in the desired order.
1408 /// Note that commonly the resolver tries name servers in /etc/resolv.conf
1409 /// in the order listed, proceeding with the next server in the list
1410 /// on failure. See for example the "rotate" option of the dns-options setting.
1411 /// If there are any negative DNS priorities, then only name servers from
1412 /// the devices with that lowest priority will be considered.
1413 ///
1414 /// When using a DNS resolver that supports Conditional Forwarding or
1415 /// Split DNS (with dns=dnsmasq or dns=systemd-resolved settings), each connection
1416 /// is used to query domains in its search list. The search domains determine which
1417 /// name servers to ask, and the DNS priority is used to prioritize
1418 /// name servers based on the domain. Queries for domains not present in any
1419 /// search list are routed through connections having the '~.' special wildcard
1420 /// domain, which is added automatically to connections with the default route
1421 /// (or can be added manually). When multiple connections specify the same domain, the
1422 /// one with the best priority (lowest numerical value) wins. If a sub domain
1423 /// is configured on another interface it will be accepted regardless the priority,
1424 /// unless parent domain on the other interface has a negative priority, which causes
1425 /// the sub domain to be shadowed.
1426 /// With Split DNS one can avoid undesired DNS leaks by properly configuring
1427 /// DNS priorities and the search domains, so that only name servers of the desired
1428 /// interface are configured.
1429 #[cfg(feature = "v1_4")]
1430 #[cfg_attr(docsrs, doc(cfg(feature = "v1_4")))]
1431 pub fn dns_priority(self, dns_priority: i32) -> Self {
1432 Self {
1433 builder: self.builder.property("dns-priority", dns_priority),
1434 }
1435 }
1436
1437 /// List of DNS search domains. Domains starting with a tilde ('~')
1438 /// are considered 'routing' domains and are used only to decide the
1439 /// interface over which a query must be forwarded; they are not used
1440 /// to complete unqualified host names.
1441 ///
1442 /// When using a DNS plugin that supports Conditional Forwarding or
1443 /// Split DNS, then the search domains specify which name servers to
1444 /// query. This makes the behavior different from running with plain
1445 /// /etc/resolv.conf. For more information see also the dns-priority setting.
1446 ///
1447 /// When set on a profile that also enabled DHCP, the DNS search list
1448 /// received automatically (option 119 for DHCPv4 and option 24 for DHCPv6)
1449 /// gets merged with the manual list. This can be prevented by setting
1450 /// "ignore-auto-dns". Note that if no DNS searches are configured, the
1451 /// fallback will be derived from the domain from DHCP (option 15).
1452 pub fn dns_search(self, dns_search: impl Into<glib::StrV>) -> Self {
1453 Self {
1454 builder: self.builder.property("dns-search", dns_search.into()),
1455 }
1456 }
1457
1458 /// Whether to configure sysctl interface-specific forwarding. When enabled, the interface
1459 /// will act as a router to forward the packet from one interface to another. When set to
1460 /// [`SettingIPConfigForwarding::Default`][crate::SettingIPConfigForwarding::Default], the value from global configuration is used;
1461 /// if no global default is defined, [`SettingIPConfigForwarding::Auto`][crate::SettingIPConfigForwarding::Auto] will be used.
1462 /// The #NMSettingIPConfig:forwarding property is ignored when #NMSettingIPConfig:method
1463 /// is set to "shared", because forwarding is always enabled in this case.
1464 /// The accepted values are:
1465 /// [`SettingIPConfigForwarding::Default`][crate::SettingIPConfigForwarding::Default]: use global default.
1466 /// [`SettingIPConfigForwarding::No`][crate::SettingIPConfigForwarding::No]: disabled.
1467 /// [`SettingIPConfigForwarding::Yes`][crate::SettingIPConfigForwarding::Yes]: enabled.
1468 /// [`SettingIPConfigForwarding::Auto`][crate::SettingIPConfigForwarding::Auto]: enable if any shared connection is active,
1469 /// use kernel default otherwise.
1470 #[cfg(feature = "v1_54")]
1471 #[cfg_attr(docsrs, doc(cfg(feature = "v1_54")))]
1472 pub fn forwarding(self, forwarding: i32) -> Self {
1473 Self {
1474 builder: self.builder.property("forwarding", forwarding),
1475 }
1476 }
1477
1478 /// The gateway associated with this configuration. This is only meaningful
1479 /// if #NMSettingIPConfig:addresses is also set.
1480 ///
1481 /// Setting the gateway causes NetworkManager to configure a standard default route
1482 /// with the gateway as next hop. This is ignored if #NMSettingIPConfig:never-default
1483 /// is set. An alternative is to configure the default route explicitly with a manual
1484 /// route and /0 as prefix length.
1485 ///
1486 /// Note that the gateway usually conflicts with routing that NetworkManager configures
1487 /// for WireGuard interfaces, so usually it should not be set in that case. See
1488 /// #NMSettingWireGuard:ip4-auto-default-route.
1489 pub fn gateway(self, gateway: impl Into<glib::GString>) -> Self {
1490 Self {
1491 builder: self.builder.property("gateway", gateway.into()),
1492 }
1493 }
1494
1495 /// When #NMSettingIPConfig:method is set to "auto" and this property to
1496 /// [`true`], automatically configured name servers and search domains are
1497 /// ignored and only name servers and search domains specified in the
1498 /// #NMSettingIPConfig:dns and #NMSettingIPConfig:dns-search properties, if
1499 /// any, are used.
1500 pub fn ignore_auto_dns(self, ignore_auto_dns: bool) -> Self {
1501 Self {
1502 builder: self.builder.property("ignore-auto-dns", ignore_auto_dns),
1503 }
1504 }
1505
1506 /// When #NMSettingIPConfig:method is set to "auto" and this property to
1507 /// [`true`], automatically configured routes are ignored and only routes
1508 /// specified in the #NMSettingIPConfig:routes property, if any, are used.
1509 pub fn ignore_auto_routes(self, ignore_auto_routes: bool) -> Self {
1510 Self {
1511 builder: self
1512 .builder
1513 .property("ignore-auto-routes", ignore_auto_routes),
1514 }
1515 }
1516
1517 /// If [`true`], allow overall network configuration to proceed even if the
1518 /// configuration specified by this property times out. Note that at least
1519 /// one IP configuration must succeed or overall network configuration will
1520 /// still fail. For example, in IPv6-only networks, setting this property to
1521 /// [`true`] on the #NMSettingIP4Config allows the overall network configuration
1522 /// to succeed if IPv4 configuration fails but IPv6 configuration completes
1523 /// successfully.
1524 pub fn may_fail(self, may_fail: bool) -> Self {
1525 Self {
1526 builder: self.builder.property("may-fail", may_fail),
1527 }
1528 }
1529
1530 /// IP configuration method.
1531 ///
1532 /// #NMSettingIP4Config and #NMSettingIP6Config both support "disabled",
1533 /// "auto", "manual", and "link-local". See the subclass-specific
1534 /// documentation for other values.
1535 ///
1536 /// In general, for the "auto" method, properties such as
1537 /// #NMSettingIPConfig:dns and #NMSettingIPConfig:routes specify information
1538 /// that is added on to the information returned from automatic
1539 /// configuration. The #NMSettingIPConfig:ignore-auto-routes and
1540 /// #NMSettingIPConfig:ignore-auto-dns properties modify this behavior.
1541 ///
1542 /// For methods that imply no upstream network, such as "shared" or
1543 /// "link-local", these properties must be empty.
1544 ///
1545 /// For IPv4 method "shared", the IP subnet can be configured by adding one
1546 /// manual IPv4 address or otherwise 10.42.x.0/24 is chosen. Note that the
1547 /// shared method must be configured on the interface which shares the internet
1548 /// to a subnet, not on the uplink which is shared.
1549 pub fn method(self, method: impl Into<glib::GString>) -> Self {
1550 Self {
1551 builder: self.builder.property("method", method.into()),
1552 }
1553 }
1554
1555 /// If [`true`], this connection will never be the default connection for this
1556 /// IP type, meaning it will never be assigned the default route by
1557 /// NetworkManager.
1558 pub fn never_default(self, never_default: bool) -> Self {
1559 Self {
1560 builder: self.builder.property("never-default", never_default),
1561 }
1562 }
1563
1564 /// Connections will default to keep the autogenerated priority 0 local rule
1565 /// unless this setting is set to [`true`].
1566 #[cfg(feature = "v1_44")]
1567 #[cfg_attr(docsrs, doc(cfg(feature = "v1_44")))]
1568 pub fn replace_local_rule(self, replace_local_rule: Ternary) -> Self {
1569 Self {
1570 builder: self
1571 .builder
1572 .property("replace-local-rule", replace_local_rule),
1573 }
1574 }
1575
1576 /// The minimum time interval in milliseconds for which dynamic IP configuration
1577 /// should be tried before the connection succeeds.
1578 ///
1579 /// This property is useful for example if both IPv4 and IPv6 are enabled and
1580 /// are allowed to fail. Normally the connection succeeds as soon as one of
1581 /// the two address families completes; by setting a required timeout for
1582 /// e.g. IPv4, one can ensure that even if IP6 succeeds earlier than IPv4,
1583 /// NetworkManager waits some time for IPv4 before the connection becomes
1584 /// active.
1585 ///
1586 /// Note that if #NMSettingIPConfig:may-fail is FALSE for the same address
1587 /// family, this property has no effect as NetworkManager needs to wait for
1588 /// the full DHCP timeout.
1589 ///
1590 /// A zero value means that no required timeout is present, -1 means the
1591 /// default value (either configuration ipvx.required-timeout override or
1592 /// zero).
1593 #[cfg(feature = "v1_34")]
1594 #[cfg_attr(docsrs, doc(cfg(feature = "v1_34")))]
1595 pub fn required_timeout(self, required_timeout: i32) -> Self {
1596 Self {
1597 builder: self.builder.property("required-timeout", required_timeout),
1598 }
1599 }
1600
1601 /// The default metric for routes that don't explicitly specify a metric.
1602 /// The default value -1 means that the metric is chosen automatically
1603 /// based on the device type.
1604 /// The metric applies to dynamic routes, manual (static) routes that
1605 /// don't have an explicit metric setting, address prefix routes, and
1606 /// the default route.
1607 /// Note that for IPv6, the kernel accepts zero (0) but coerces it to
1608 /// 1024 (user default). Hence, setting this property to zero effectively
1609 /// mean setting it to 1024.
1610 /// For IPv4, zero is a regular value for the metric.
1611 pub fn route_metric(self, route_metric: i64) -> Self {
1612 Self {
1613 builder: self.builder.property("route-metric", route_metric),
1614 }
1615 }
1616
1617 /// Enable policy routing (source routing) and set the routing table used when adding routes.
1618 ///
1619 /// This affects all routes, including device-routes, IPv4LL, DHCP, SLAAC, default-routes
1620 /// and static routes. But note that static routes can individually overwrite the setting
1621 /// by explicitly specifying a non-zero routing table.
1622 ///
1623 /// If the table setting is left at zero, it is eligible to be overwritten via global
1624 /// configuration. If the property is zero even after applying the global configuration
1625 /// value, policy routing is disabled for the address family of this connection.
1626 ///
1627 /// Policy routing disabled means that NetworkManager will add all routes to the main
1628 /// table (except static routes that explicitly configure a different table). Additionally,
1629 /// NetworkManager will not delete any extraneous routes from tables except the main table.
1630 /// This is to preserve backward compatibility for users who manage routing tables outside
1631 /// of NetworkManager.
1632 #[cfg(feature = "v1_10")]
1633 #[cfg_attr(docsrs, doc(cfg(feature = "v1_10")))]
1634 pub fn route_table(self, route_table: u32) -> Self {
1635 Self {
1636 builder: self.builder.property("route-table", route_table),
1637 }
1638 }
1639
1640 /// Whether to add routes for DNS servers. When enabled, NetworkManager adds a route
1641 /// for each DNS server that is associated with this connection either statically
1642 /// (defined in the connection profile) or dynamically (for example, retrieved via
1643 /// DHCP). The route guarantees that the DNS server is reached via this interface. When
1644 /// set to [`SettingIPConfigRoutedDns::Default`][crate::SettingIPConfigRoutedDns::Default], the value from global
1645 /// configuration is used; if no global default is defined, this feature is disabled.
1646 #[cfg(feature = "v1_52")]
1647 #[cfg_attr(docsrs, doc(cfg(feature = "v1_52")))]
1648 pub fn routed_dns(self, routed_dns: i32) -> Self {
1649 Self {
1650 builder: self.builder.property("routed-dns", routed_dns),
1651 }
1652 }
1653
1654 /// Array of IP routes.
1655 pub fn routes(self, routes: &[&IPRoute]) -> Self {
1656 Self {
1657 builder: self.builder.property(
1658 "routes",
1659 routes
1660 .iter()
1661 .map(|route| route.to_value())
1662 .collect::<glib::ValueArray>(),
1663 ),
1664 }
1665 }
1666
1667 /// This option allows you to specify a custom DHCP lease time for the shared connection
1668 /// method in seconds. The value should be either a number between 120 and 31536000 (one year)
1669 /// If this option is not specified, 3600 (one hour) is used.
1670 ///
1671 /// Special values are 0 for default value of 1 hour and 2147483647 (MAXINT32) for infinite lease time.
1672 #[cfg(feature = "v1_52")]
1673 #[cfg_attr(docsrs, doc(cfg(feature = "v1_52")))]
1674 pub fn shared_dhcp_lease_time(self, shared_dhcp_lease_time: i32) -> Self {
1675 Self {
1676 builder: self
1677 .builder
1678 .property("shared-dhcp-lease-time", shared_dhcp_lease_time),
1679 }
1680 }
1681
1682 /// This option allows you to specify a custom DHCP range for the shared connection
1683 /// method. The value is expected to be in `<START_ADDRESS>,<END_ADDRESS>` format.
1684 /// The range should be part of network set by ipv4.address option and it should
1685 /// not contain network address or broadcast address. If this option is not specified,
1686 /// the DHCP range will be automatically determined based on the interface address.
1687 /// The range will be selected to be adjacent to the interface address, either before
1688 /// or after it, with the larger possible range being preferred. The range will be
1689 /// adjusted to fill the available address space, except for networks with a prefix
1690 /// length greater than 24, which will be treated as if they have a prefix length of 24.
1691 #[cfg(feature = "v1_52")]
1692 #[cfg_attr(docsrs, doc(cfg(feature = "v1_52")))]
1693 pub fn shared_dhcp_range(self, shared_dhcp_range: impl Into<glib::GString>) -> Self {
1694 Self {
1695 builder: self
1696 .builder
1697 .property("shared-dhcp-range", shared_dhcp_range.into()),
1698 }
1699 }
1700
1701 // rustdoc-stripper-ignore-next
1702 /// Build the [`SettingIP4Config`].
1703 #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
1704 pub fn build(self) -> SettingIP4Config {
1705 assert_initialized_main_thread!();
1706 self.builder.build()
1707 }
1708}