Skip to content

Commit

Permalink
service: Add EnableOnlineCheck config option
Browse files Browse the repository at this point in the history
Global config option, which allows to enable/disable (enabled by default)
use of http get in wispr to transition a default service from READY to
ONLINE state.
  • Loading branch information
Lukasz Nowak authored and igaw committed Mar 14, 2017
1 parent 815a0b2 commit 4de35cd
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 7 deletions.
9 changes: 9 additions & 0 deletions doc/connman.conf.5.in
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,15 @@ See RFC6343. Default value is false (as recommended by RFC6343 section 4.1).
Set DHCP option 60 (Vendor Class ID) to the given string. This option can
be used by DHCP servers to identify specific clients without having to
rely on MAC address ranges, etc
.TP
.BI EnableOnlineCheck=true\ \fR|\fB\ false
Enable or disable use of http get as on online status check.
When a service is in a READY state, and is selected as default,
ConnMan will issue an HTTP GET request to verify that end-to-end
connectivity is successful. Only then the service will be
transitioned to ONLINE state.
If this setting is false, the default service will remain in READY state.
Default value is true.
.SH "EXAMPLE"
The following example configuration disables hostname updates and enables
ethernet tethering.
Expand Down
17 changes: 17 additions & 0 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ static struct {
bool persistent_tethering_mode;
bool enable_6to4;
char *vendor_class_id;
bool enable_online_check;
} connman_settings = {
.bg_scan = true,
.pref_timeservers = NULL,
Expand All @@ -94,6 +95,7 @@ static struct {
.persistent_tethering_mode = false,
.enable_6to4 = false,
.vendor_class_id = NULL,
.enable_online_check = true,
};

#define CONF_BG_SCAN "BackgroundScanning"
Expand All @@ -111,6 +113,7 @@ static struct {
#define CONF_PERSISTENT_TETHERING_MODE "PersistentTetheringMode"
#define CONF_ENABLE_6TO4 "Enable6to4"
#define CONF_VENDOR_CLASS_ID "VendorClassID"
#define CONF_ENABLE_ONLINE_CHECK "EnableOnlineCheck"

static const char *supported_options[] = {
CONF_BG_SCAN,
Expand All @@ -128,6 +131,7 @@ static const char *supported_options[] = {
CONF_PERSISTENT_TETHERING_MODE,
CONF_ENABLE_6TO4,
CONF_VENDOR_CLASS_ID,
CONF_ENABLE_ONLINE_CHECK,
NULL
};

Expand Down Expand Up @@ -394,6 +398,16 @@ static void parse_config(GKeyFile *config)
connman_settings.vendor_class_id = vendor_class_id;

g_clear_error(&error);

boolean = __connman_config_get_bool(config, "General",
CONF_ENABLE_ONLINE_CHECK, &error);
if (!error) {
connman_settings.enable_online_check = boolean;
if (!boolean)
connman_info("Online check disabled by main config.");
}

g_clear_error(&error);
}

static int config_init(const char *file)
Expand Down Expand Up @@ -589,6 +603,9 @@ bool connman_setting_get_bool(const char *key)
if (g_str_equal(key, CONF_ENABLE_6TO4))
return connman_settings.enable_6to4;

if (g_str_equal(key, CONF_ENABLE_ONLINE_CHECK))
return connman_settings.enable_online_check;

return false;
}

Expand Down
9 changes: 9 additions & 0 deletions src/main.conf
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,15 @@
# section 4.1).
# Enable6to4 = false

# Enable use of http get as on online status check.
# When a service is in a READY state, and is selected as default,
# ConnMan will issue an HTTP GET request to verify that end-to-end
# connectivity is successful. Only then the service will be
# transitioned to ONLINE state.
# If this setting is false, the default service will remain in READY state.
# Default value is true.
# EnableOnlineCheck = false

# List of technologies with AutoConnect = true which are always connected
# regardless of PreferredTechnologies setting. Default value is empty and
# will connect a technology only if it is at a higher preference than any
Expand Down
18 changes: 11 additions & 7 deletions src/service.c
Original file line number Diff line number Diff line change
Expand Up @@ -5981,13 +5981,17 @@ int __connman_service_ipconfig_indicate_state(struct connman_service *service,
case CONNMAN_SERVICE_STATE_CONFIGURATION:
break;
case CONNMAN_SERVICE_STATE_READY:
if (type == CONNMAN_IPCONFIG_TYPE_IPV4) {
check_proxy_setup(service);
service_rp_filter(service, true);
} else {
service->online_check_count = 1;
__connman_wispr_start(service, type);
}
if (connman_setting_get_bool("EnableOnlineCheck"))
if (type == CONNMAN_IPCONFIG_TYPE_IPV4) {
check_proxy_setup(service);
service_rp_filter(service, true);
} else {
service->online_check_count = 1;
__connman_wispr_start(service, type);
}
else
connman_info("Online check disabled. "
"Default service remains in READY state.");
break;
case CONNMAN_SERVICE_STATE_ONLINE:
break;
Expand Down

0 comments on commit 4de35cd

Please sign in to comment.