diff options
author | Denis Kenzior <denkenz@gmail.com> | 2024-04-26 16:52:22 -0500 |
---|---|---|
committer | Denis Kenzior <denkenz@gmail.com> | 2024-04-29 14:04:25 -0500 |
commit | e1756a883d8a80ca8b514807f34fc589d018609b (patch) | |
tree | 5cf2763e765f330dd25da98ca1b88ed650d397e0 | |
parent | 758a6ea7faedb2c12965a0d2cec8411cf4c93e34 (diff) | |
download | ofono-e1756a883d8a80ca8b514807f34fc589d018609b.tar.gz |
qmi: wds: Move enum conversion into wds.c
Introduce a new wds.c file which will house various utilities, such as
enumeration conversion, that could be shared between multiple QMI based
atom drivers. Move ofono_gprs_auth_method conversion here.
-rw-r--r-- | Makefile.am | 1 | ||||
-rw-r--r-- | drivers/qmimodem/gprs-context.c | 17 | ||||
-rw-r--r-- | drivers/qmimodem/wds.c | 25 | ||||
-rw-r--r-- | drivers/qmimodem/wds.h | 2 |
4 files changed, 29 insertions, 16 deletions
diff --git a/Makefile.am b/Makefile.am index a4880036e..36319d985 100644 --- a/Makefile.am +++ b/Makefile.am @@ -362,6 +362,7 @@ qmi_sources = drivers/qmimodem/qmi.h drivers/qmimodem/qmi.c \ drivers/qmimodem/pds.h \ drivers/qmimodem/common.h \ drivers/qmimodem/wda.h \ + drivers/qmimodem/wds.c \ drivers/qmimodem/voice.h builtin_sources += $(qmi_sources) \ diff --git a/drivers/qmimodem/gprs-context.c b/drivers/qmimodem/gprs-context.c index 4004876ba..9ac57c893 100644 --- a/drivers/qmimodem/gprs-context.c +++ b/drivers/qmimodem/gprs-context.c @@ -239,21 +239,6 @@ static void qmi_gprs_read_settings(struct ofono_gprs_context* gc, l_free(cbd); } -static uint8_t auth_method_to_qmi_auth(enum ofono_gprs_auth_method method) -{ - /* QMI uses a bitmap */ - switch (method) { - case OFONO_GPRS_AUTH_METHOD_CHAP: - return QMI_WDS_AUTHENTICATION_CHAP; - case OFONO_GPRS_AUTH_METHOD_PAP: - return QMI_WDS_AUTHENTICATION_PAP; - case OFONO_GPRS_AUTH_METHOD_NONE: - return 0; - } - - return 0; -} - static void qmi_activate_primary(struct ofono_gprs_context *gc, const struct ofono_gprs_primary_context *ctx, ofono_gprs_context_cb_t cb, void *user_data) @@ -288,7 +273,7 @@ static void qmi_activate_primary(struct ofono_gprs_context *gc, qmi_param_append_uint8(param, QMI_WDS_PARAM_IP_FAMILY, ip_family); - auth = auth_method_to_qmi_auth(ctx->auth_method); + auth = qmi_wds_auth_from_ofono(ctx->auth_method); qmi_param_append_uint8(param, QMI_WDS_PARAM_AUTHENTICATION_PREFERENCE, auth); diff --git a/drivers/qmimodem/wds.c b/drivers/qmimodem/wds.c new file mode 100644 index 000000000..748ad867c --- /dev/null +++ b/drivers/qmimodem/wds.c @@ -0,0 +1,25 @@ +/* + * oFono - Open Source Telephony + * Copyright (C) 2024 Cruise, LLC + * + * SPDX-License-Identifier: LGPL-2.1-or-later + */ + +#include "src/common.h" + +#include "wds.h" + +int qmi_wds_auth_from_ofono(enum ofono_gprs_auth_method method) +{ + /* QMI uses a bitmap */ + switch (method) { + case OFONO_GPRS_AUTH_METHOD_CHAP: + return QMI_WDS_AUTHENTICATION_CHAP; + case OFONO_GPRS_AUTH_METHOD_PAP: + return QMI_WDS_AUTHENTICATION_PAP; + case OFONO_GPRS_AUTH_METHOD_NONE: + return 0; + } + + return -ENOENT; +} diff --git a/drivers/qmimodem/wds.h b/drivers/qmimodem/wds.h index 6d7071fe2..c8aeefe43 100644 --- a/drivers/qmimodem/wds.h +++ b/drivers/qmimodem/wds.h @@ -108,3 +108,5 @@ enum qmi_wds_command { QMI_WDS_CONFIGURE_PROFILE_EVENT_LIST = 0xA7, QMI_WDS_PROFILE_CHANGED = 0xA8, }; + +int qmi_wds_auth_from_ofono(enum ofono_gprs_auth_method method); |