summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDylan Van Assche <me@dylanvanassche.be>2022-07-28 19:55:32 +0200
committerThomas Haller <thaller@redhat.com>2022-08-01 09:37:42 +0200
commit0f3eb6fabbbb93730d1ce6e704dba8076ea900cb (patch)
treeb52a825dca31b0b6f97584b7c5a05dc2ed1249db
parent05825b0348ae9bf18456c7f3778da4a84b817852 (diff)
downloadNetworkManager-0f3eb6fabbbb93730d1ce6e704dba8076ea900cb.tar.gz
nm-device-bt: allow Bluetooth NAP type for complete-connection
Bluetooth NAP is besides Bluetooth PAN and DUN also supported by NetworkManager. Add NAP to the supported Bluetooth types of nm-device-bt.c https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/issues/1058 https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1320
-rw-r--r--src/core/devices/bluetooth/nm-device-bt.c25
1 files changed, 24 insertions, 1 deletions
diff --git a/src/core/devices/bluetooth/nm-device-bt.c b/src/core/devices/bluetooth/nm-device-bt.c
index 39b5c4eccc..a8258123f9 100644
--- a/src/core/devices/bluetooth/nm-device-bt.c
+++ b/src/core/devices/bluetooth/nm-device-bt.c
@@ -262,6 +262,7 @@ complete_connection(NMDevice *device,
const char *ctype;
gboolean is_dun = FALSE;
gboolean is_pan = FALSE;
+ gboolean is_nap = FALSE;
NMSettingGsm *s_gsm;
NMSettingCdma *s_cdma;
NMSettingSerial *s_serial;
@@ -281,6 +282,8 @@ complete_connection(NMDevice *device,
is_dun = TRUE;
else if (!strcmp(ctype, NM_SETTING_BLUETOOTH_TYPE_PANU))
is_pan = TRUE;
+ else if (!strcmp(ctype, NM_SETTING_BLUETOOTH_TYPE_NAP))
+ is_nap = TRUE;
} else {
if (s_gsm || s_cdma)
is_dun = TRUE;
@@ -288,7 +291,27 @@ complete_connection(NMDevice *device,
is_pan = TRUE;
}
- if (is_pan) {
+ if (is_nap) {
+ /* Make sure the device supports NAP */
+ if (!(priv->capabilities & NM_BT_CAPABILITY_NAP)) {
+ g_set_error_literal(error,
+ NM_CONNECTION_ERROR,
+ NM_CONNECTION_ERROR_INVALID_PROPERTY,
+ _("NAP requested, but Bluetooth device does not support NAP"));
+ g_prefix_error(error,
+ "%s.%s: ",
+ NM_SETTING_BLUETOOTH_SETTING_NAME,
+ NM_SETTING_BLUETOOTH_TYPE);
+ return FALSE;
+ }
+
+ g_object_set(G_OBJECT(s_bt),
+ NM_SETTING_BLUETOOTH_TYPE,
+ NM_SETTING_BLUETOOTH_TYPE_NAP,
+ NULL);
+
+ fallback_prefix = _("NAP connection");
+ } else if (is_pan) {
/* Make sure the device supports PAN */
if (!(priv->capabilities & NM_BT_CAPABILITY_NAP)) {
g_set_error_literal(error,