summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2015-03-13 19:59:32 +0100
committerThomas Haller <thaller@redhat.com>2015-03-20 11:43:29 +0100
commit1fc5aba42a175c0eca0b6d8804d6ee9088c1dfe5 (patch)
tree53663a9a93f5e140a78792b041287e6a8d7e8640
parentb5ca5bd7b7e8894450786c0874a47620e777d3bb (diff)
downloadNetworkManager-1fc5aba42a175c0eca0b6d8804d6ee9088c1dfe5.tar.gz
main: move option variables to static variable
Move the variables to a static struct so that we can factor out some of the initialization code. Also it's nice to have all options placed together in one struct so that is is obvious which static variables are part of the command line options, and which have other use.
-rw-r--r--src/main.c75
-rw-r--r--src/nm-iface-helper.c162
2 files changed, 129 insertions, 108 deletions
diff --git a/src/main.c b/src/main.c
index 0e9e923dcd..a1747f2e59 100644
--- a/src/main.c
+++ b/src/main.c
@@ -67,6 +67,20 @@
static GMainLoop *main_loop = NULL;
static gboolean configure_and_quit = FALSE;
+static struct {
+ gboolean show_version;
+ gboolean become_daemon;
+ gboolean debug;
+ gboolean g_fatal_warnings;
+ gboolean run_from_build_dir;
+ char *opt_log_level;
+ char *opt_log_domains;
+ char *pidfile;
+ char *state_file;
+} global_opt = {
+ .become_daemon = TRUE,
+};
+
static gboolean
parse_state_file (const char *filename,
gboolean *net_enabled,
@@ -204,15 +218,8 @@ manager_configure_quit (NMManager *manager, gpointer user_data)
int
main (int argc, char *argv[])
{
- char *opt_log_level = NULL;
- char *opt_log_domains = NULL;
- gboolean become_daemon = TRUE, run_from_build_dir = FALSE;
- gboolean debug = FALSE;
- gboolean g_fatal_warnings = FALSE;
- gs_free char *pidfile = NULL;
- gs_free char *state_file = NULL;
gboolean wifi_enabled = TRUE, net_enabled = TRUE, wwan_enabled = TRUE, wimax_enabled = TRUE;
- gboolean success, show_version = FALSE;
+ gboolean success;
NMManager *manager = NULL;
gs_unref_object NMSettings *settings = NULL;
NMConfig *config;
@@ -222,17 +229,17 @@ main (int argc, char *argv[])
NMConfigCmdLineOptions *config_cli;
GOptionEntry options[] = {
- { "version", 'V', 0, G_OPTION_ARG_NONE, &show_version, N_("Print NetworkManager version and exit"), NULL },
- { "no-daemon", 'n', G_OPTION_FLAG_REVERSE, G_OPTION_ARG_NONE, &become_daemon, N_("Don't become a daemon"), NULL },
- { "debug", 'd', 0, G_OPTION_ARG_NONE, &debug, N_("Don't become a daemon, and log to stderr"), NULL },
- { "log-level", 0, 0, G_OPTION_ARG_STRING, &opt_log_level, N_("Log level: one of [%s]"), "INFO" },
- { "log-domains", 0, 0, G_OPTION_ARG_STRING, &opt_log_domains,
+ { "version", 'V', 0, G_OPTION_ARG_NONE, &global_opt.show_version, N_("Print NetworkManager version and exit"), NULL },
+ { "no-daemon", 'n', G_OPTION_FLAG_REVERSE, G_OPTION_ARG_NONE, &global_opt.become_daemon, N_("Don't become a daemon"), NULL },
+ { "debug", 'd', 0, G_OPTION_ARG_NONE, &global_opt.debug, N_("Don't become a daemon, and log to stderr"), NULL },
+ { "log-level", 0, 0, G_OPTION_ARG_STRING, &global_opt.opt_log_level, N_("Log level: one of [%s]"), "INFO" },
+ { "log-domains", 0, 0, G_OPTION_ARG_STRING, &global_opt.opt_log_domains,
N_("Log domains separated by ',': any combination of [%s]"),
"PLATFORM,RFKILL,WIFI" },
- { "g-fatal-warnings", 0, 0, G_OPTION_ARG_NONE, &g_fatal_warnings, N_("Make all warnings fatal"), NULL },
- { "pid-file", 'p', 0, G_OPTION_ARG_FILENAME, &pidfile, N_("Specify the location of a PID file"), N_("filename") },
- { "state-file", 0, 0, G_OPTION_ARG_FILENAME, &state_file, N_("State file location"), N_("/path/to/state.file") },
- { "run-from-build-dir", 0, 0, G_OPTION_ARG_NONE, &run_from_build_dir, "Run from build directory", NULL },
+ { "g-fatal-warnings", 0, 0, G_OPTION_ARG_NONE, &global_opt.g_fatal_warnings, N_("Make all warnings fatal"), NULL },
+ { "pid-file", 'p', 0, G_OPTION_ARG_FILENAME, &global_opt.pidfile, N_("Specify the location of a PID file"), N_("filename") },
+ { "state-file", 0, 0, G_OPTION_ARG_FILENAME, &global_opt.state_file, N_("State file location"), N_("/path/to/state.file") },
+ { "run-from-build-dir", 0, 0, G_OPTION_ARG_NONE, &global_opt.run_from_build_dir, "Run from build directory", NULL },
{NULL}
};
@@ -250,13 +257,13 @@ main (int argc, char *argv[])
_("NetworkManager monitors all network connections and automatically\nchooses the best connection to use. It also allows the user to\nspecify wireless access points which wireless cards in the computer\nshould associate with.")))
exit (1);
- if (show_version) {
+ if (global_opt.show_version) {
fprintf (stdout, NM_DIST_VERSION "\n");
exit (0);
}
- if (!nm_logging_setup (opt_log_level,
- opt_log_domains,
+ if (!nm_logging_setup (global_opt.opt_log_level,
+ global_opt.opt_log_domains,
&bad_domains,
&error)) {
fprintf (stderr,
@@ -272,7 +279,7 @@ main (int argc, char *argv[])
/* When running from the build directory, determine our build directory
* base and set helper paths in the build tree */
- if (run_from_build_dir) {
+ if (global_opt.run_from_build_dir) {
char *path, *slash;
int g;
@@ -300,11 +307,11 @@ main (int argc, char *argv[])
exit (1);
}
- pidfile = pidfile ? pidfile : g_strdup (NM_DEFAULT_PID_FILE);
- state_file = state_file ? state_file : g_strdup (NM_DEFAULT_SYSTEM_STATE_FILE);
+ global_opt.pidfile = global_opt.pidfile ? global_opt.pidfile : g_strdup (NM_DEFAULT_PID_FILE);
+ global_opt.state_file = global_opt.state_file ? global_opt.state_file : g_strdup (NM_DEFAULT_SYSTEM_STATE_FILE);
/* check pid file */
- if (nm_main_utils_check_pidfile (pidfile, "NetworkManager"))
+ if (nm_main_utils_check_pidfile (global_opt.pidfile, "NetworkManager"))
exit (1);
/* Read the config file and CLI overrides */
@@ -321,7 +328,7 @@ main (int argc, char *argv[])
/* Initialize logging from config file *only* if not explicitly
* specified by commandline.
*/
- if (opt_log_level == NULL && opt_log_domains == NULL) {
+ if (global_opt.opt_log_level == NULL && global_opt.opt_log_domains == NULL) {
if (!nm_logging_setup (nm_config_get_log_level (config),
nm_config_get_log_domains (config),
&bad_domains,
@@ -338,16 +345,16 @@ main (int argc, char *argv[])
}
/* Parse the state file */
- if (!parse_state_file (state_file, &net_enabled, &wifi_enabled, &wwan_enabled, &wimax_enabled, &error)) {
+ if (!parse_state_file (global_opt.state_file, &net_enabled, &wifi_enabled, &wwan_enabled, &wimax_enabled, &error)) {
fprintf (stderr, _("State file %s parsing failed: (%d) %s\n"),
- state_file,
+ global_opt.state_file,
error ? error->code : -1,
(error && error->message) ? error->message : _("unknown"));
/* Not a hard failure */
}
g_clear_error (&error);
- if (become_daemon && !debug) {
+ if (global_opt.become_daemon && !global_opt.debug) {
if (daemon (0, 0) < 0) {
int saved_errno;
@@ -357,7 +364,7 @@ main (int argc, char *argv[])
saved_errno);
exit (1);
}
- wrote_pidfile = nm_main_utils_write_pidfile (pidfile);
+ wrote_pidfile = nm_main_utils_write_pidfile (global_opt.pidfile);
}
_init_nm_debug (nm_config_get_debug (config));
@@ -365,7 +372,7 @@ main (int argc, char *argv[])
/* Set up unix signal handling - before creating threads, but after daemonizing! */
nm_main_utils_setup_signals (main_loop);
- if (g_fatal_warnings) {
+ if (global_opt.g_fatal_warnings) {
GLogLevelFlags fatal_mask;
fatal_mask = g_log_set_always_fatal (G_LOG_FATAL_MASK);
@@ -373,7 +380,7 @@ main (int argc, char *argv[])
g_log_set_always_fatal (fatal_mask);
}
- nm_logging_syslog_openlog (debug);
+ nm_logging_syslog_openlog (global_opt.debug);
#if !GLIB_CHECK_VERSION (2, 35, 0)
g_type_init ();
@@ -413,7 +420,7 @@ main (int argc, char *argv[])
}
manager = nm_manager_new (settings,
- state_file,
+ global_opt.state_file,
net_enabled,
wifi_enabled,
wwan_enabled,
@@ -469,8 +476,8 @@ done:
nm_logging_syslog_closelog ();
- if (pidfile && wrote_pidfile)
- unlink (pidfile);
+ if (global_opt.pidfile && wrote_pidfile)
+ unlink (global_opt.pidfile);
nm_log_info (LOGD_CORE, "exiting (%s)", success ? "success" : "error");
exit (success ? 0 : 1);
diff --git a/src/nm-iface-helper.c b/src/nm-iface-helper.c
index 09054c0237..eb376b5e6d 100644
--- a/src/nm-iface-helper.c
+++ b/src/nm-iface-helper.c
@@ -51,14 +51,35 @@
#define NMIH_PID_FILE_FMT NMRUNDIR "/nm-iface-helper-%d.pid"
static GMainLoop *main_loop = NULL;
-static char *ifname = NULL;
static int ifindex = -1;
-static gboolean slaac_required = FALSE;
-static gboolean dhcp4_required = FALSE;
-static int tempaddr = NM_SETTING_IP6_CONFIG_PRIVACY_UNKNOWN;
static guint32 priority_v4 = NM_PLATFORM_ROUTE_METRIC_DEFAULT_IP4;
static guint32 priority_v6 = NM_PLATFORM_ROUTE_METRIC_DEFAULT_IP6;
+static struct {
+ gboolean slaac;
+ gboolean show_version;
+ gboolean become_daemon;
+ gboolean debug;
+ gboolean g_fatal_warnings;
+ gboolean slaac_required;
+ gboolean dhcp4_required;
+ int tempaddr;
+ char *ifname;
+ char *uuid;
+ char *dhcp4_address;
+ char *dhcp4_clientid;
+ char *dhcp4_hostname;
+ char *iid_str;
+ char *opt_log_level;
+ char *opt_log_domains;
+ gint64 priority64_v4;
+ gint64 priority64_v6;
+} global_opt = {
+ .tempaddr = NM_SETTING_IP6_CONFIG_PRIVACY_UNKNOWN,
+ .priority64_v4 = -1,
+ .priority64_v6 = -1,
+};
+
static void
dhcp4_state_changed (NMDhcpClient *client,
NMDhcpState state,
@@ -71,7 +92,7 @@ dhcp4_state_changed (NMDhcpClient *client,
g_return_if_fail (!ip4_config || NM_IS_IP4_CONFIG (ip4_config));
- nm_log_dbg (LOGD_DHCP4, "(%s): new DHCPv4 client state %d", ifname, state);
+ nm_log_dbg (LOGD_DHCP4, "(%s): new DHCPv4 client state %d", global_opt.ifname, state);
switch (state) {
case NM_DHCP_STATE_BOUND:
@@ -82,7 +103,7 @@ dhcp4_state_changed (NMDhcpClient *client,
nm_ip4_config_merge (existing, ip4_config);
if (!nm_ip4_config_commit (existing, ifindex, priority_v4))
- nm_log_warn (LOGD_DHCP4, "(%s): failed to apply DHCPv4 config", ifname);
+ nm_log_warn (LOGD_DHCP4, "(%s): failed to apply DHCPv4 config", global_opt.ifname);
if (last_config) {
g_object_unref (last_config);
@@ -93,11 +114,11 @@ dhcp4_state_changed (NMDhcpClient *client,
case NM_DHCP_STATE_TIMEOUT:
case NM_DHCP_STATE_DONE:
case NM_DHCP_STATE_FAIL:
- if (dhcp4_required) {
- nm_log_warn (LOGD_DHCP4, "(%s): DHCPv4 timed out or failed, quitting...", ifname);
+ if (global_opt.dhcp4_required) {
+ nm_log_warn (LOGD_DHCP4, "(%s): DHCPv4 timed out or failed, quitting...", global_opt.ifname);
g_main_loop_quit (main_loop);
} else
- nm_log_warn (LOGD_DHCP4, "(%s): DHCPv4 timed out or failed", ifname);
+ nm_log_warn (LOGD_DHCP4, "(%s): DHCPv4 timed out or failed", global_opt.ifname);
break;
default:
break;
@@ -128,8 +149,8 @@ rdisc_config_changed (NMRDisc *rdisc, NMRDiscConfigMap changed, gpointer user_da
if (system_support)
ifa_flags = IFA_F_NOPREFIXROUTE;
- if (tempaddr == NM_SETTING_IP6_CONFIG_PRIVACY_PREFER_TEMP_ADDR
- || tempaddr == NM_SETTING_IP6_CONFIG_PRIVACY_PREFER_PUBLIC_ADDR)
+ if (global_opt.tempaddr == NM_SETTING_IP6_CONFIG_PRIVACY_PREFER_TEMP_ADDR
+ || global_opt.tempaddr == NM_SETTING_IP6_CONFIG_PRIVACY_PREFER_PUBLIC_ADDR)
{
/* without system_support, this flag will be ignored. Still set it, doesn't seem to do any harm. */
ifa_flags |= IFA_F_MANAGETEMPADDR;
@@ -210,23 +231,23 @@ rdisc_config_changed (NMRDisc *rdisc, NMRDiscConfigMap changed, gpointer user_da
char val[16];
g_snprintf (val, sizeof (val), "%d", rdisc->hop_limit);
- nm_platform_sysctl_set (nm_utils_ip6_property_path (ifname, "hop_limit"), val);
+ nm_platform_sysctl_set (nm_utils_ip6_property_path (global_opt.ifname, "hop_limit"), val);
}
if (changed & NM_RDISC_CONFIG_MTU) {
char val[16];
g_snprintf (val, sizeof (val), "%d", rdisc->mtu);
- nm_platform_sysctl_set (nm_utils_ip6_property_path (ifname, "mtu"), val);
+ nm_platform_sysctl_set (nm_utils_ip6_property_path (global_opt.ifname, "mtu"), val);
}
- existing = nm_ip6_config_capture (ifindex, FALSE, tempaddr);
+ existing = nm_ip6_config_capture (ifindex, FALSE, global_opt.tempaddr);
if (last_config)
nm_ip6_config_subtract (existing, last_config);
nm_ip6_config_merge (existing, ip6_config);
if (!nm_ip6_config_commit (existing, ifindex))
- nm_log_warn (LOGD_IP6, "(%s): failed to apply IPv6 config", ifname);
+ nm_log_warn (LOGD_IP6, "(%s): failed to apply IPv6 config", global_opt.ifname);
if (last_config) {
g_object_unref (last_config);
@@ -238,11 +259,11 @@ rdisc_config_changed (NMRDisc *rdisc, NMRDiscConfigMap changed, gpointer user_da
static void
rdisc_ra_timeout (NMRDisc *rdisc, gpointer user_data)
{
- if (slaac_required) {
- nm_log_warn (LOGD_IP6, "(%s): IPv6 timed out or failed, quitting...", ifname);
+ if (global_opt.slaac_required) {
+ nm_log_warn (LOGD_IP6, "(%s): IPv6 timed out or failed, quitting...", global_opt.ifname);
g_main_loop_quit (main_loop);
} else
- nm_log_warn (LOGD_IP6, "(%s): IPv6 timed out or failed", ifname);
+ nm_log_warn (LOGD_IP6, "(%s): IPv6 timed out or failed", global_opt.ifname);
}
static gboolean
@@ -263,12 +284,7 @@ setup_signals (void)
int
main (int argc, char *argv[])
{
- char *opt_log_level = NULL;
- char *opt_log_domains = NULL;
- gboolean debug = FALSE, g_fatal_warnings = FALSE, become_daemon = FALSE;
- gboolean show_version = FALSE, slaac = FALSE;
- char *bad_domains = NULL, *dhcp4_hostname = NULL, *uuid = NULL;
- char *iid_str = NULL, *dhcp4_clientid = NULL, *dhcp4_address = NULL;
+ char *bad_domains = NULL;
GError *error = NULL;
gboolean wrote_pidfile = FALSE;
gs_free char *pidfile = NULL;
@@ -278,33 +294,31 @@ main (int argc, char *argv[])
size_t hwaddr_len = 0;
gconstpointer tmp;
gs_free NMUtilsIPv6IfaceId *iid = NULL;
- gint64 priority64_v4 = -1;
- gint64 priority64_v6 = -1;
GOptionEntry options[] = {
/* Interface/IP config */
- { "ifname", 'i', 0, G_OPTION_ARG_STRING, &ifname, N_("The interface to manage"), N_("eth0") },
- { "uuid", 'u', 0, G_OPTION_ARG_STRING, &uuid, N_("Connection UUID"), N_("661e8cd0-b618-46b8-9dc9-31a52baaa16b") },
- { "slaac", 's', 0, G_OPTION_ARG_NONE, &slaac, N_("Whether to manage IPv6 SLAAC"), NULL },
- { "slaac-required", '6', 0, G_OPTION_ARG_NONE, &slaac_required, N_("Whether SLAAC must be successful"), NULL },
- { "slaac-tempaddr", 't', 0, G_OPTION_ARG_INT, &tempaddr, N_("Use an IPv6 temporary privacy address"), NULL },
- { "dhcp4", 'd', 0, G_OPTION_ARG_STRING, &dhcp4_address, N_("Current DHCPv4 address"), NULL },
- { "dhcp4-required", '4', 0, G_OPTION_ARG_NONE, &dhcp4_required, N_("Whether DHCPv4 must be successful"), NULL },
- { "dhcp4-clientid", 'c', 0, G_OPTION_ARG_STRING, &dhcp4_clientid, N_("Hex-encoded DHCPv4 client ID"), NULL },
- { "dhcp4-hostname", 'h', 0, G_OPTION_ARG_STRING, &dhcp4_hostname, N_("Hostname to send to DHCP server"), N_("barbar") },
- { "priority4", '\0', 0, G_OPTION_ARG_INT64, &priority64_v4, N_("Route priority for IPv4"), N_("0") },
- { "priority6", '\0', 0, G_OPTION_ARG_INT64, &priority64_v6, N_("Route priority for IPv6"), N_("1024") },
- { "iid", 'e', 0, G_OPTION_ARG_STRING, &iid_str, N_("Hex-encoded Interface Identifier"), N_("") },
+ { "ifname", 'i', 0, G_OPTION_ARG_STRING, &global_opt.ifname, N_("The interface to manage"), N_("eth0") },
+ { "uuid", 'u', 0, G_OPTION_ARG_STRING, &global_opt.uuid, N_("Connection UUID"), N_("661e8cd0-b618-46b8-9dc9-31a52baaa16b") },
+ { "slaac", 's', 0, G_OPTION_ARG_NONE, &global_opt.slaac, N_("Whether to manage IPv6 SLAAC"), NULL },
+ { "slaac-required", '6', 0, G_OPTION_ARG_NONE, &global_opt.slaac_required, N_("Whether SLAAC must be successful"), NULL },
+ { "slaac-tempaddr", 't', 0, G_OPTION_ARG_INT, &global_opt.tempaddr, N_("Use an IPv6 temporary privacy address"), NULL },
+ { "dhcp4", 'd', 0, G_OPTION_ARG_STRING, &global_opt.dhcp4_address, N_("Current DHCPv4 address"), NULL },
+ { "dhcp4-required", '4', 0, G_OPTION_ARG_NONE, &global_opt.dhcp4_required, N_("Whether DHCPv4 must be successful"), NULL },
+ { "dhcp4-clientid", 'c', 0, G_OPTION_ARG_STRING, &global_opt.dhcp4_clientid, N_("Hex-encoded DHCPv4 client ID"), NULL },
+ { "dhcp4-hostname", 'h', 0, G_OPTION_ARG_STRING, &global_opt.dhcp4_hostname, N_("Hostname to send to DHCP server"), N_("barbar") },
+ { "priority4", '\0', 0, G_OPTION_ARG_INT64, &global_opt.priority64_v4, N_("Route priority for IPv4"), N_("0") },
+ { "priority6", '\0', 0, G_OPTION_ARG_INT64, &global_opt.priority64_v6, N_("Route priority for IPv6"), N_("1024") },
+ { "iid", 'e', 0, G_OPTION_ARG_STRING, &global_opt.iid_str, N_("Hex-encoded Interface Identifier"), N_("") },
/* Logging/debugging */
- { "version", 'V', 0, G_OPTION_ARG_NONE, &show_version, N_("Print NetworkManager version and exit"), NULL },
- { "no-daemon", 'n', G_OPTION_FLAG_REVERSE, G_OPTION_ARG_NONE, &become_daemon, N_("Don't become a daemon"), NULL },
- { "debug", 'b', 0, G_OPTION_ARG_NONE, &debug, N_("Don't become a daemon, and log to stderr"), NULL },
- { "log-level", 0, 0, G_OPTION_ARG_STRING, &opt_log_level, N_("Log level: one of [%s]"), "INFO" },
- { "log-domains", 0, 0, G_OPTION_ARG_STRING, &opt_log_domains,
+ { "version", 'V', 0, G_OPTION_ARG_NONE, &global_opt.show_version, N_("Print NetworkManager version and exit"), NULL },
+ { "no-daemon", 'n', G_OPTION_FLAG_REVERSE, G_OPTION_ARG_NONE, &global_opt.become_daemon, N_("Don't become a daemon"), NULL },
+ { "debug", 'b', 0, G_OPTION_ARG_NONE, &global_opt.debug, N_("Don't become a daemon, and log to stderr"), NULL },
+ { "log-level", 0, 0, G_OPTION_ARG_STRING, &global_opt.opt_log_level, N_("Log level: one of [%s]"), "INFO" },
+ { "log-domains", 0, 0, G_OPTION_ARG_STRING, &global_opt.opt_log_domains,
N_("Log domains separated by ',': any combination of [%s]"),
"PLATFORM,RFKILL,WIFI" },
- { "g-fatal-warnings", 0, 0, G_OPTION_ARG_NONE, &g_fatal_warnings, N_("Make all warnings fatal"), NULL },
+ { "g-fatal-warnings", 0, 0, G_OPTION_ARG_NONE, &global_opt.g_fatal_warnings, N_("Make all warnings fatal"), NULL },
{NULL}
};
@@ -319,18 +333,18 @@ main (int argc, char *argv[])
_("nm-iface-helper is a small, standalone process that manages a single network interface.")))
exit (1);
- if (show_version) {
+ if (global_opt.show_version) {
fprintf (stdout, NM_DIST_VERSION "\n");
exit (0);
}
- if (!ifname || !uuid) {
+ if (!global_opt.ifname || !global_opt.uuid) {
fprintf (stderr, _("An interface name and UUID are required\n"));
exit (1);
}
- if (!nm_logging_setup (opt_log_level,
- opt_log_domains,
+ if (!nm_logging_setup (global_opt.opt_log_level,
+ global_opt.opt_log_domains,
&bad_domains,
&error)) {
fprintf (stderr,
@@ -351,7 +365,7 @@ main (int argc, char *argv[])
if (nm_main_utils_check_pidfile (pidfile, "nm-iface-helper"))
exit (1);
- if (become_daemon && !debug) {
+ if (global_opt.become_daemon && !global_opt.debug) {
if (daemon (0, 0) < 0) {
int saved_errno;
@@ -369,7 +383,7 @@ main (int argc, char *argv[])
main_loop = g_main_loop_new (NULL, FALSE);
setup_signals ();
- if (g_fatal_warnings) {
+ if (global_opt.g_fatal_warnings) {
GLogLevelFlags fatal_mask;
fatal_mask = g_log_set_always_fatal (G_LOG_FATAL_MASK);
@@ -377,7 +391,7 @@ main (int argc, char *argv[])
g_log_set_always_fatal (fatal_mask);
}
- nm_logging_syslog_openlog (debug);
+ nm_logging_syslog_openlog (global_opt.debug);
#if !GLIB_CHECK_VERSION (2, 35, 0)
g_type_init ();
@@ -388,9 +402,9 @@ main (int argc, char *argv[])
/* Set up platform interaction layer */
nm_linux_platform_setup ();
- ifindex = nm_platform_link_get_ifindex (ifname);
+ ifindex = nm_platform_link_get_ifindex (global_opt.ifname);
if (ifindex <= 0) {
- fprintf (stderr, _("Failed to find interface index for %s\n"), ifname);
+ fprintf (stderr, _("Failed to find interface index for %s\n"), global_opt.ifname);
exit (1);
}
@@ -400,39 +414,39 @@ main (int argc, char *argv[])
g_byte_array_append (hwaddr, tmp, hwaddr_len);
}
- if (iid_str) {
+ if (global_opt.iid_str) {
GBytes *bytes;
gsize ignored = 0;
- bytes = nm_utils_hexstr2bin (iid_str);
+ bytes = nm_utils_hexstr2bin (global_opt.iid_str);
if (!bytes || g_bytes_get_size (bytes) != sizeof (*iid)) {
- fprintf (stderr, _("(%s): Invalid IID %s\n"), ifname, iid_str);
+ fprintf (stderr, _("(%s): Invalid IID %s\n"), global_opt.ifname, global_opt.iid_str);
exit (1);
}
iid = g_bytes_unref_to_data (bytes, &ignored);
}
- if (priority64_v4 >= 0 && priority64_v4 <= G_MAXUINT32)
- priority_v4 = (guint32) priority64_v4;
+ if (global_opt.priority64_v4 >= 0 && global_opt.priority64_v4 <= G_MAXUINT32)
+ priority_v4 = (guint32) global_opt.priority64_v4;
- if (priority64_v6 >= 0 && priority64_v6 <= G_MAXUINT32)
- priority_v6 = (guint32) priority64_v6;
+ if (global_opt.priority64_v6 >= 0 && global_opt.priority64_v6 <= G_MAXUINT32)
+ priority_v6 = (guint32) global_opt.priority64_v6;
- if (dhcp4_address) {
- nm_platform_sysctl_set (nm_utils_ip4_property_path (ifname, "promote_secondaries"), "1");
+ if (global_opt.dhcp4_address) {
+ nm_platform_sysctl_set (nm_utils_ip4_property_path (global_opt.ifname, "promote_secondaries"), "1");
dhcp4_client = nm_dhcp_manager_start_ip4 (nm_dhcp_manager_get (),
- ifname,
+ global_opt.ifname,
ifindex,
hwaddr,
- uuid,
+ global_opt.uuid,
priority_v4,
- !!dhcp4_hostname,
- dhcp4_hostname,
- dhcp4_clientid,
+ !!global_opt.dhcp4_hostname,
+ global_opt.dhcp4_hostname,
+ global_opt.dhcp4_clientid,
45,
NULL,
- dhcp4_address);
+ global_opt.dhcp4_address);
g_assert (dhcp4_client);
g_signal_connect (dhcp4_client,
NM_DHCP_CLIENT_SIGNAL_STATE_CHANGED,
@@ -440,19 +454,19 @@ main (int argc, char *argv[])
NULL);
}
- if (slaac) {
+ if (global_opt.slaac) {
nm_platform_link_set_user_ipv6ll_enabled (ifindex, TRUE);
- rdisc = nm_lndp_rdisc_new (ifindex, ifname);
+ rdisc = nm_lndp_rdisc_new (ifindex, global_opt.ifname);
g_assert (rdisc);
if (iid)
nm_rdisc_set_iid (rdisc, *iid);
- nm_platform_sysctl_set (nm_utils_ip6_property_path (ifname, "accept_ra"), "1");
- nm_platform_sysctl_set (nm_utils_ip6_property_path (ifname, "accept_ra_defrtr"), "0");
- nm_platform_sysctl_set (nm_utils_ip6_property_path (ifname, "accept_ra_pinfo"), "0");
- nm_platform_sysctl_set (nm_utils_ip6_property_path (ifname, "accept_ra_rtr_pref"), "0");
+ nm_platform_sysctl_set (nm_utils_ip6_property_path (global_opt.ifname, "accept_ra"), "1");
+ nm_platform_sysctl_set (nm_utils_ip6_property_path (global_opt.ifname, "accept_ra_defrtr"), "0");
+ nm_platform_sysctl_set (nm_utils_ip6_property_path (global_opt.ifname, "accept_ra_pinfo"), "0");
+ nm_platform_sysctl_set (nm_utils_ip6_property_path (global_opt.ifname, "accept_ra_rtr_pref"), "0");
g_signal_connect (rdisc,
NM_RDISC_CONFIG_CHANGED,