diff options
author | Luiz Augusto von Dentz <luiz.dentz@openbossa.org> | 2007-09-28 13:29:59 +0000 |
---|---|---|
committer | Luiz Augusto von Dentz <luiz.dentz@openbossa.org> | 2007-09-28 13:29:59 +0000 |
commit | 684fe2781c46ccfb30a4e653fad126286bddcdcb (patch) | |
tree | e5b1c103cbbc1db86d7e29e7ed901e861d6ec7d3 | |
parent | 7b4212920e58f58b15c69146a109f02d365e2286 (diff) |
Fix default configuration when config file is missing.
-rw-r--r-- | network/main.c | 42 | ||||
-rw-r--r-- | network/network.conf | 24 |
2 files changed, 33 insertions, 33 deletions
diff --git a/network/main.c b/network/main.c index 6225ff4e..8c9bdc54 100644 --- a/network/main.c +++ b/network/main.c @@ -42,9 +42,8 @@ #include "hal.h" #define IFACE_PREFIX "bnep%d" -#define PANU_IFACE "pan0" -#define GN_IFACE "pan1" -#define NAP_IFACE "pan2" +#define GN_IFACE "pan0" +#define NAP_IFACE "pan1" static GMainLoop *main_loop; @@ -76,8 +75,7 @@ static void read_config(const char *file) if (!g_key_file_load_from_file(keyfile, file, 0, &err)) { error("Parsing %s failed: %s", file, err->message); g_error_free(err); - g_key_file_free(keyfile); - return; + goto done; } disabled = g_key_file_get_string(keyfile, "General", @@ -93,16 +91,6 @@ static void read_config(const char *file) conf.server_enabled = FALSE; } - conf.iface_prefix = g_key_file_get_string(keyfile, "General", - "InterfacePrefix", &err); - if (!conf.iface_prefix) - conf.iface_prefix = g_strdup(IFACE_PREFIX); - if (err) { - debug("%s: %s", file, err->message); - g_error_free(err); - err = NULL; - } - conf.security = !g_key_file_get_boolean(keyfile, "General", "DisableSecurity", &err); if (err) { @@ -135,10 +123,16 @@ static void read_config(const char *file) err = NULL; } + conf.iface_prefix = g_key_file_get_string(keyfile, "PANU Role", + "Interface", &err); + if (err) { + debug("%s: %s", file, err->message); + g_error_free(err); + err = NULL; + } + conf.gn_iface = g_key_file_get_string(keyfile, "GN Role", "Interface", &err); - if (!conf.gn_iface) - conf.gn_iface = g_strdup(GN_IFACE); if (err) { debug("%s: %s", file, err->message); g_error_free(err); @@ -147,22 +141,28 @@ static void read_config(const char *file) conf.nap_iface = g_key_file_get_string(keyfile, "NAP Role", "Interface", &err); - if (!conf.nap_iface) - conf.nap_iface = g_strdup(NAP_IFACE); if (err) { debug("%s: %s", file, err->message); g_error_free(err); err = NULL; } +done: + g_key_file_free(keyfile); + + if (!conf.iface_prefix) + conf.iface_prefix = g_strdup(IFACE_PREFIX); + if (!conf.gn_iface) + conf.gn_iface = g_strdup(GN_IFACE); + if (!conf.nap_iface) + conf.nap_iface = g_strdup(NAP_IFACE); + debug("Config options: InterfacePrefix=%s, PANU_Script=%s, " "GN_Script=%s, NAP_Script=%s, GN_Interface=%s, " "NAP_Interface=%s, Security=%s", conf.iface_prefix, conf.panu_script, conf.gn_script, conf.nap_script, conf.gn_iface, conf.nap_iface, conf.security ? "true" : "false"); - - g_key_file_free(keyfile); } int main(int argc, char *argv[]) diff --git a/network/network.conf b/network/network.conf index 98524bfc..51a873e7 100644 --- a/network/network.conf +++ b/network/network.conf @@ -8,30 +8,30 @@ # Defaults to supporting all implemented services #Disable=Connection,Server -# Network interface name prefix for connections. default:bnep%d -# (up to 16 characters) -InterfacePrefix=bnep%d - # Disable link encryption: default=false -DisableSecurity=false +#DisableSecurity=true [PANU Role] +# Network interface name for PANU for connections. default:bnep%d +# (up to 16 characters) +#Interface= + # PAN user connection interface up script. default:none -Script=avahi-autoipd +#Script=avahi-autoipd [GN Role] -# Network Interface name for Group Network server. default:pan1 -Interface=pan0 +# Network Interface name for Group Network server. default:pan0 +#Interface= # Group Network connection interface up script. default:none -Script=avahi-autoipd +#Script=avahi-autoipd [NAP Role] -# Network Interface name for Network Access Point server. default:pan2 -Interface=pan1 +# Network Interface name for Network Access Point server. default:pan1 +#Interface= # Network Access Point connection interface up script. default:none -Script=dhclient +#Script=dhclient |