libnm: export reload flags

Flags to the manager Reload() method are stable API but not exposed in
a public header. Export them.
This commit is contained in:
Beniamino Galvani 2019-09-05 14:54:22 +02:00
parent a2e6e7f2a9
commit c1c970f1b1
5 changed files with 34 additions and 24 deletions

View file

@ -1122,4 +1122,32 @@ typedef enum {
NM_TERNARY_TRUE = 1,
} NMTernary;
/**
* NMManagerReloadFlags:
* @NM_MANAGER_RELOAD_FLAG_NONE: an alias for numeric zero, no flags set. This
* reloads everything that is supported and is identical to a SIGHUP.
* @NM_MANAGER_RELOAD_FLAG_CONF: reload the NetworkManager.conf configuration
* from disk. Note that this does not include connections, which can be
* reloaded via Setting's ReloadConnections().
* @NM_MANAGER_RELOAD_FLAG_DNS_RC: update DNS configuration, which usually
* involves writing /etc/resolv.conf anew.
* @NM_MANAGER_RELOAD_FLAG_DNS_FULL: means to restart the DNS plugin. This
* is for example useful when using dnsmasq plugin, which uses additional
* configuration in /etc/NetworkManager/dnsmasq.d. If you edit those files,
* you can restart the DNS plugin. This action shortly interrupts name
* resolution.
* @NM_MANAGER_RELOAD_FLAG_ALL: all flags.
*
* Flags for the manager Reload() call.
*
* Since: 1.22
*/
typedef enum { /*< flags >*/
NM_MANAGER_RELOAD_FLAG_NONE = 0, /*< skip >*/
NM_MANAGER_RELOAD_FLAG_CONF = 0x1,
NM_MANAGER_RELOAD_FLAG_DNS_RC = 0x2,
NM_MANAGER_RELOAD_FLAG_DNS_FULL = 0x4,
NM_MANAGER_RELOAD_FLAG_ALL = 0x7, /*< skip >*/
} NMManagerReloadFlags;
#endif /* __NM_DBUS_INTERFACE_H__ */

View file

@ -1631,5 +1631,6 @@ global:
libnm_1_22_0 {
global:
nm_manager_reload_flags_get_type;
nm_setting_gsm_get_auto_config;
} libnm_1_20_0;

View file

@ -89,7 +89,7 @@ _init_nm_debug (NMConfig *config)
debug = nm_config_data_get_value (nm_config_get_data_orig (config),
NM_CONFIG_KEYFILE_GROUP_MAIN,
NM_CONFIG_KEYFILE_KEY_MAIN_DEBUG,
NM_MANAGER_RELOAD_FLAGS_NONE);
NM_CONFIG_GET_VALUE_NONE);
flags = nm_utils_parse_debug_string (env, keys, G_N_ELEMENTS (keys));
flags |= nm_utils_parse_debug_string (debug, keys, G_N_ELEMENTS (keys));

View file

@ -25,25 +25,6 @@
#define NM_CONFIG_DATA_NO_AUTO_DEFAULT "no-auto-default"
#define NM_CONFIG_DATA_DNS_MODE "dns"
/* The flags for Reload. Currently these are internal defines,
* only their numeric value matters and must be stable as
* they are public API! Also, the enum must fit in uint32. */
enum { /*< skip >*/
NM_MANAGER_RELOAD_FLAGS_NONE = 0,
/* reload the configuration from disk */
NM_MANAGER_RELOAD_FLAGS_CONF = (1LL << 0),
/* write DNS configuration to resolv.conf */
NM_MANAGER_RELOAD_FLAGS_DNS_RC = (1LL << 1),
/* restart the DNS plugin (includes DNS_RC) */
NM_MANAGER_RELOAD_FLAGS_DNS_FULL = (1LL << 2),
_NM_MANAGER_RELOAD_FLAGS_ALL,
NM_MANAGER_RELOAD_FLAGS_ALL = ((_NM_MANAGER_RELOAD_FLAGS_ALL - 1) << 1) - 1,
};
typedef enum { /*< flags >*/
NM_CONFIG_GET_VALUE_NONE = 0,

View file

@ -1155,16 +1155,16 @@ _reload_auth_cb (NMAuthChain *chain,
NM_MANAGER_ERROR_PERMISSION_DENIED,
"Not authorized to reload configuration");
} else {
if (NM_FLAGS_ANY (flags, ~NM_MANAGER_RELOAD_FLAGS_ALL)) {
if (NM_FLAGS_ANY (flags, ~NM_MANAGER_RELOAD_FLAG_ALL)) {
/* invalid flags */
} else if (flags == 0)
reload_type = NM_CONFIG_CHANGE_CAUSE_SIGHUP;
else {
if (NM_FLAGS_HAS (flags, NM_MANAGER_RELOAD_FLAGS_CONF))
if (NM_FLAGS_HAS (flags, NM_MANAGER_RELOAD_FLAG_CONF))
reload_type |= NM_CONFIG_CHANGE_CAUSE_CONF;
if (NM_FLAGS_HAS (flags, NM_MANAGER_RELOAD_FLAGS_DNS_RC))
if (NM_FLAGS_HAS (flags, NM_MANAGER_RELOAD_FLAG_DNS_RC))
reload_type |= NM_CONFIG_CHANGE_CAUSE_DNS_RC;
if (NM_FLAGS_HAS (flags, NM_MANAGER_RELOAD_FLAGS_DNS_FULL))
if (NM_FLAGS_HAS (flags, NM_MANAGER_RELOAD_FLAG_DNS_FULL))
reload_type |= NM_CONFIG_CHANGE_CAUSE_DNS_FULL;
}