From 33ed089d4b59bd79ae35f626ea6fc3da20c2edb9 Mon Sep 17 00:00:00 2001 From: Yevhen Mykhno Date: Thu, 9 Feb 2023 20:25:11 +0200 Subject: [GP-1597] mPower R.6.3.X: Cellular Provider Profiles - LTE Authentication --- include/mts/MTS_IO_CellularRadio.h | 167 ++++++++++++++++++++++++++++++++++++ include/mts/MTS_IO_ICellularRadio.h | 51 ++++++++--- include/mts/MTS_IO_QuectelRadio.h | 6 ++ include/mts/MTS_IO_SequansRadio.h | 5 ++ include/mts/MTS_IO_TelitRadio.h | 5 ++ 5 files changed, 224 insertions(+), 10 deletions(-) (limited to 'include') diff --git a/include/mts/MTS_IO_CellularRadio.h b/include/mts/MTS_IO_CellularRadio.h index 68c1394..991dc47 100644 --- a/include/mts/MTS_IO_CellularRadio.h +++ b/include/mts/MTS_IO_CellularRadio.h @@ -269,6 +269,7 @@ namespace MTS { virtual CODE sendData(const char* pData, size_t nBytes); virtual CODE sendBasicQuery(const std::string& sCmd, const std::string& sLabel, std::string& sResult, int32_t timeoutMillis = 100, const char& ESC = ICellularRadio::CR); + virtual CODE isCommandSupported(const std::string& sCmd, bool& bIsSupported); /** * @brief getDiagCommands - returns the list of Cellular Diagnostics commands for this radio. * @@ -278,6 +279,172 @@ namespace MTS { */ virtual const std::vector& getDiagCommands(bool bIsSimReady = true) = 0; + struct PdpContextInfo { + std::string sId; + std::string sIpMode; + std::string sApn; + std::string sAuthType; + std::string sUsername; + std::string sPassword; + }; + + virtual std::vector getSupportedPdpContextAuthTypes() const = 0; + static CODE convertPdpContextAuthTypeToString(PDP_CONTEXT_AUTH_TYPE eAuthType, std::string& sAuthType); + static CODE convertStringToPdpContextAuthType(const std::string& sAuthType, PDP_CONTEXT_AUTH_TYPE& eAuthType); + + /** + * @brief checks if PDP context authentication is supported by the modem. + * + * @param isSupported - sets to "true" if PDP context authentication is supported, "false" otherwise. + * + * @return CODE::SUCCESS when the response from the radio is received + * CODE::NO_RESPONSE when the modem doesn't respond, + * CODE::FAILURE otherwise. + */ + virtual CODE isPdpContextAuthSupported(bool& isSupported) = 0; + + /** + * @brief Get the list of PDP contexts with the base info about them from the radio. + * + * @param jData - a JSON object to be filled with data. + * { + * "context_number : STRING": { + * "apn" : "apn_value: STRING", + * "ipMode" : "ip_mode_value: STRING", + * } + * } + * + * @return CODE::SUCCESS when fetched successfully, + * CODE::NO_RESPONSE when the modem doesn't respond, + * CODE::ERROR when the radio returns "ERROR", + * CODE::FAILURE otherwise (unexpected response). + */ + virtual CODE getPdpContextsBase(Json::Value& jData); + + /** + * @brief fills jData with the information about PDP context authentication + * + * @param jData - a JSON object that is pre-filled with the list of PDP contexts: + * { + * "context_number : STRING": { + * "apn" : "apn_value: STRING", + * "ipMode" : "ip_mode_value: STRING", + * } + * } + * On success the method will complement jData with the PDP context authentication fields: + * { + * "context_number : STRING": { + * "apn" : "apn_value: STRING", + * "authType" : "auth_type_value: STRING", + * "ipMode" : "ip_mode_value: STRING", + * "password" : "password_value (optional): STRING", + * "username" : "username_value (optional): STRING" + * } + * } + * + * @return CODE::SUCCESS when fetched successfully, + * CODE::NO_RESPONSE when the modem doesn't respond, + * CODE::ERROR when the radio returns "ERROR", + * CODE::FAILURE otherwise (unexpected response). + */ + virtual CODE fillPdpContextAuthFields(Json::Value& jData) = 0; + + /** + * @brief merges the current configuration of the PDP context with the one requested by user + * + * @param sId - ID of the PDP context to change. + * @param jCurrentContext - a JSON object filled with current configuration data + * { + * "apn" : "apn_value (optional): STRING", + * "authType" : "auth_type_value: STRING", + * "ipMode" : "ip_mode_value: STRING", + * "password" : "password_value (optional): STRING", + * "username" : "username_value (optional): STRING" + * } + * @param jChanges - a JSON object filled with new configuration data + * { + * "apn" : "apn_value (optional): STRING", + * "authType" : "auth_type_value (optional): STRING", + * "ipMode" : "ip_mode_value (optional): STRING", + * "password" : "password_value (optional): STRING", + * "username" : "username_value (optional): STRING" + * } + * @param jResult - a JSON object to be filled with merged data + * { + * "apn" : "apn_value (optional): STRING", + * "authType" : "auth_type_value (optional): STRING", + * "id" : "ctx_id (optional): STRING", + * "ipMode" : "ip_mode_value (optional): STRING", + * "password" : "password_value (optional): STRING", + * "username" : "username_value (optional): STRING" + * } + * @return CODE::SUCCESS. + */ + virtual CODE mergePdpContexts(const std::string& sId, const Json::Value& jCurrentContext, const Json::Value& jChanges, Json::Value& jResult); + + /** + * @brief fills a PdpContextInfo instance with the data from JSON + * @param jData - a JSON object that contains: + * { + * "apn" : "apn_value: STRING", + * "authType" : "auth_type_value: STRING", + * "id" : "ctx_id: STRING", + * "ipMode" : "ip_mode_value: STRING", + * "password" : "password_value: STRING", + * "username" : "username_value: STRING" + * } + * @param pdpContextResult - PdpContextInfo object to be filled with parameters. + * @return CODE::SUCCESS if validated successfully, + * CODE::INVALID_ARGS if validation failed. + */ + virtual CODE initPdpContextInfo(const Json::Value& jConfig, PdpContextInfo& pdpContextResult); + + /** + * @brief checks if PDP context authentication should be configured + * @param jData - a JSON object that contains: + * { + * "apn" : "apn_value (optional): STRING", + * "authType" : "auth_type_value: STRING", + * "ipMode" : "ip_mode_value: STRING", + * "password" : "password_value (optional): STRING", + * "username" : "username_value (optional): STRING" + * } + * @param bIsAuthEditRequired - sets to "false" if there are no authType, username, and password fields in the json, otherwise sets to "true". + * @return CODE::SUCCESS. + */ + static CODE isPdpContextAuthEditRequired(const Json::Value& jConfig, bool& bIsAuthEditRequired); + + /** + * @brief Sets the base PDP context parameters: IP Mode and APN + * @param pdpContext - The new PDP context configuration + * @return CODE::SUCCESS when set successfully, + * CODE::NO_RESPONSE when the modem doesn't respond, + * CODE::ERROR when the radio returns "ERROR", + * CODE::FAILURE otherwise (unexpected response). + */ + virtual CODE setPdpContextBase(const PdpContextInfo& pdpContext); + + /** + * @brief Sets the Cellular Authentication parameters for this PDP context: Authentication Type, Username and Password. + * NOTE: Some implementations (Quectel) override the current IP Mode and APN in addition to the authentication fields. + * @param pdpContext - The new PDP context configuration + * @return CODE::SUCCESS when set successfully, + * CODE::NO_RESPONSE when the modem doesn't respond, + * CODE::ERROR when the radio returns "ERROR", + * CODE::FAILURE otherwise (unexpected response). + */ + virtual CODE setPdpContextAuth(const PdpContextInfo& pdpContext) = 0; + + /** + * @brief Delete the PDP context by its ID. + * @param sId - PDP context ID + * @return CODE::SUCCESS when delete successfully, + * CODE::NO_RESPONSE when the modem doesn't respond, + * CODE::ERROR when the radio returns "ERROR", + * CODE::FAILURE otherwise (unexpected response). + */ + virtual CODE deletePdpContext(const std::string& sId); + class RadioBandMap : public MTS::NonCopyable { public: RadioBandMap() diff --git a/include/mts/MTS_IO_ICellularRadio.h b/include/mts/MTS_IO_ICellularRadio.h index 0523236..a698647 100644 --- a/include/mts/MTS_IO_ICellularRadio.h +++ b/include/mts/MTS_IO_ICellularRadio.h @@ -78,6 +78,13 @@ namespace MTS { CS_MODE2 // only non-EPS services are allowed, the usage is "data centric" }; + enum PDP_CONTEXT_AUTH_TYPE : uint8_t { + NONE = 0, + PAP, + CHAP, + PAP_CHAP + }; + static CODE convertModelToType(const std::string& sModel, std::string& sType); static CODE convertModelToMtsShortCode(const std::string& sModel, std::string& sCode, ICellularRadio *radioObj = NULL); static CODE convertServiceDomainToString(SERVICEDOMAIN eSd, std::string& sSd); @@ -206,8 +213,19 @@ namespace MTS { static const char *KEY_ATTEMPTS_PUK; //!< The number of attempts left to unlock the SIM card using PUK code //PDP Context + static const char *KEY_PDP_CONTEXT_ID; static const char *KEY_PDP_CONTEXT_APN; static const char *KEY_PDP_CONTEXT_IPMODE; + static const char *KEY_PDP_CONTEXT_AUTH_TYPE; + static const char *KEY_PDP_CONTEXT_AUTH_USERNAME; + static const char *KEY_PDP_CONTEXT_AUTH_PASSWORD; + static const char *VALUE_PDP_CONTEXT_IP_MODE_IP; + static const char *VALUE_PDP_CONTEXT_IP_MODE_IPV6; + static const char *VALUE_PDP_CONTEXT_IP_MODE_IPV4V6; + static const char *VALUE_PDP_CONTEXT_AUTH_TYPE_NONE; + static const char *VALUE_PDP_CONTEXT_AUTH_TYPE_PAP; + static const char *VALUE_PDP_CONTEXT_AUTH_TYPE_CHAP; + static const char *VALUE_PDP_CONTEXT_AUTH_TYPE_PAP_CHAP; //Values - Type static const char *VALUE_TYPE_LTE; @@ -662,12 +680,18 @@ namespace MTS { /** * @brief Get the list of PDP contexts from the radio + * NOTE: authType, password and username are only present if the radio supports Cellular Authentication on + * the PDP Context Level. “password” and “username” are only present if the current authentication type is + * other than NONE. The “password” field is omitted on radios that do not allow reading the current password (i.e. on Telit LE910Cx). * * @param jData - an object to be filled with data. * { - * "": { - * "apn": "", - * "ipMode": "" + * "context_number : STRING": { + * "apn" : "apn_value: STRING", + * "authType" : "auth_type_value: STRING", + * "ipMode" : "ip_mode_value: STRING", + * "password" : "password_value (optional): STRING", + * "username" : "username_value (optional): STRING" * } * } * @@ -679,20 +703,27 @@ namespace MTS { virtual CODE getPdpContexts(Json::Value& jData) = 0; /** - * @brief Set the PDP context to the radio + * @brief Set the PDP context to the radio. If any of the fields are omitted, + * the system re-uses the current configuration for such fields. + * If all fields are omitted - the system deletes the context. + * "username" and "password" are mandatory if "ipMode" is PAP, CHAP or PAP-CHAP. + * "username", "password" and "authType" shall be omitted on radios that do NOT + * support Cellular Authentication on the PDP Context Level. * - * @param sId - a string value that contains an ID of the PDP context to change. - * @param jConfig - a JSON-object that contains: - * an IP mode for the specified PDP context, - * an APN for the specified PDP context. + * @param sId - ID of the PDP context that should be edited. + * @param jConfig - a JSON object that contains: * { - * "apn": "", - * "ipMode": "" + * "apn" : "apn_value (optional): STRING", + * "authType" : "auth_type_value (optional): STRING", + * "ipMode" : "ip_mode_value (optional): STRING", + * "password" : "password_value (optional): STRING", + * "username" : "username_value (optional): STRING" * } * * @return CODE::SUCCESS when fetched successfully, * CODE::NO_RESPONSE when the modem doesn't respond, * CODE::ERROR when the radio returns "ERROR", + * CODE::INVALID_ARGS when one of the JSON object values is incorrect OR not supported by the current radio, * CODE::FAILURE otherwise (unexpected response). */ virtual CODE setPdpContext(const std::string& sId, const Json::Value& jConfig) = 0; diff --git a/include/mts/MTS_IO_QuectelRadio.h b/include/mts/MTS_IO_QuectelRadio.h index 4315cb3..b3881cb 100644 --- a/include/mts/MTS_IO_QuectelRadio.h +++ b/include/mts/MTS_IO_QuectelRadio.h @@ -85,6 +85,12 @@ namespace MTS { CODE setRxDiversity(const Json::Value& jArgs) override; + std::vector getSupportedPdpContextAuthTypes() const override; + static CODE convertStringToPdpContextType(const std::string& sStringType, std::string& sIntType); + CODE isPdpContextAuthSupported(bool& isSupported) override; + CODE fillPdpContextAuthFields(Json::Value& jData) override; + CODE setPdpContextAuth(const PdpContextInfo& pdpContext) override; + const std::vector& getDiagCommands(bool bIsSimReady = true) override; private: diff --git a/include/mts/MTS_IO_SequansRadio.h b/include/mts/MTS_IO_SequansRadio.h index 11f2c91..b5a3a38 100644 --- a/include/mts/MTS_IO_SequansRadio.h +++ b/include/mts/MTS_IO_SequansRadio.h @@ -56,6 +56,11 @@ namespace MTS { CODE getIsSimInserted(bool& bData) override; CODE getSimLockAttempts(int& iAttemptsPin, int& iAttemptsPuk) override; + std::vector getSupportedPdpContextAuthTypes() const override; + CODE isPdpContextAuthSupported(bool& isSupported) override; + CODE fillPdpContextAuthFields(Json::Value& jData) override; + CODE setPdpContextAuth(const PdpContextInfo& pdpContext) override; + const std::vector& getDiagCommands(bool bIsSimReady = true) override; private: diff --git a/include/mts/MTS_IO_TelitRadio.h b/include/mts/MTS_IO_TelitRadio.h index d198969..dc02755 100644 --- a/include/mts/MTS_IO_TelitRadio.h +++ b/include/mts/MTS_IO_TelitRadio.h @@ -73,6 +73,11 @@ namespace MTS { virtual CODE fumoWriteGroupsABD(int fd, UpdateCb& stepCb); //virtual CODE fumoWriteGroupC(int fd, UpdateCb& stepCb); + std::vector getSupportedPdpContextAuthTypes() const override; + CODE isPdpContextAuthSupported(bool& isSupported) override; + CODE fillPdpContextAuthFields(Json::Value &jData) override; + CODE setPdpContextAuth(const PdpContextInfo& pdpContext) override; + const std::vector& getDiagCommands(bool bIsSimReady = true) override; static bool isContainsSignChar(const std::string& str); -- cgit v1.2.3