diff mbox series

[02/17] wispr: Add and leverage 'is_wispr_supported'.

Message ID 20231116010259.628527-3-gerickson@nuovations.com (mailing list archive)
State Superseded
Headers show
Series Address Redundant IPv4 Reachability Checks | expand

Commit Message

Grant Erickson Nov. 16, 2023, 1:02 a.m. UTC
This factors out from '__connman_wispr_start', adds, and leverages
as an independent, file-scoped function 'is_wispr_supported'. It
determines and returns Boolean status whether WISPr requests /
HTTP-based Internet reachability check are supported for the
specified network service based on its associated technology
type.
---
 src/wispr.c | 35 ++++++++++++++++++++++-------------
 1 file changed, 22 insertions(+), 13 deletions(-)
diff mbox series

Patch

diff --git a/src/wispr.c b/src/wispr.c
index 79cb713449bc..9c99402c8c6d 100644
--- a/src/wispr.c
+++ b/src/wispr.c
@@ -1072,6 +1072,27 @@  done:
 	return err;
 }
 
+static bool is_wispr_supported(const struct connman_service *service)
+{
+	if (!service)
+		return false;
+
+	switch (connman_service_get_type(service)) {
+	case CONNMAN_SERVICE_TYPE_ETHERNET:
+	case CONNMAN_SERVICE_TYPE_WIFI:
+	case CONNMAN_SERVICE_TYPE_BLUETOOTH:
+	case CONNMAN_SERVICE_TYPE_CELLULAR:
+	case CONNMAN_SERVICE_TYPE_GADGET:
+		return true;
+	case CONNMAN_SERVICE_TYPE_UNKNOWN:
+	case CONNMAN_SERVICE_TYPE_SYSTEM:
+	case CONNMAN_SERVICE_TYPE_GPS:
+	case CONNMAN_SERVICE_TYPE_VPN:
+	case CONNMAN_SERVICE_TYPE_P2P:
+		return false;
+	}
+}
+
 /**
  *  @brief
  *    Start a HTTP-based Internet reachability check for the specified
@@ -1132,20 +1153,8 @@  int __connman_wispr_start(struct connman_service *service,
 	if (!wispr_portal_hash || !callback)
 		return -EINVAL;
 
-	switch (connman_service_get_type(service)) {
-	case CONNMAN_SERVICE_TYPE_ETHERNET:
-	case CONNMAN_SERVICE_TYPE_WIFI:
-	case CONNMAN_SERVICE_TYPE_BLUETOOTH:
-	case CONNMAN_SERVICE_TYPE_CELLULAR:
-	case CONNMAN_SERVICE_TYPE_GADGET:
-		break;
-	case CONNMAN_SERVICE_TYPE_UNKNOWN:
-	case CONNMAN_SERVICE_TYPE_SYSTEM:
-	case CONNMAN_SERVICE_TYPE_GPS:
-	case CONNMAN_SERVICE_TYPE_VPN:
-	case CONNMAN_SERVICE_TYPE_P2P:
+	if (!is_wispr_supported(service))
 		return -EOPNOTSUPP;
-	}
 
 	index = __connman_service_get_index(service);
 	if (index < 0)