jolly has uploaded this change for review. ( https://gerrit.osmocom.org/c/onomondo-ipa/+/43054?usp=email )
Change subject: V1.2: Add function ES10b.GetConnectivityParameters ......................................................................
V1.2: Add function ES10b.GetConnectivityParameters
Add new library function to get connectivity parameters from IoT eUICC. Also add an option to the command line interface to call the library function.
The function cannot be emulated with non-IoT eUICC.
Reference: SGP.32 Section 5.9.24
Related: SYS#8101 Change-Id: I075590e095dbbe05fa6cdb0a96d5b38c7a17ff78 --- M asn1/SGP32Definitions.asn M include/onomondo/ipa/ipad.h M src/ipa/libasn/CMakeLists.txt A src/ipa/libasn/ConnectivityParameters.c A src/ipa/libasn/ConnectivityParameters.h A src/ipa/libasn/ConnectivityParametersError.c A src/ipa/libasn/ConnectivityParametersError.h A src/ipa/libasn/GetConnectivityParametersRequest.c A src/ipa/libasn/GetConnectivityParametersRequest.h A src/ipa/libasn/GetConnectivityParametersResponse.c A src/ipa/libasn/GetConnectivityParametersResponse.h M src/ipa/libipa/CMakeLists.txt A src/ipa/libipa/es10b_get_conn_params.c A src/ipa/libipa/es10b_get_conn_params.h M src/ipa/libipa/ipad.c M src/ipa/main.c 16 files changed, 564 insertions(+), 0 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/onomondo-ipa refs/changes/54/43054/1
diff --git a/asn1/SGP32Definitions.asn b/asn1/SGP32Definitions.asn index 09fda46..1f0edb7 100644 --- a/asn1/SGP32Definitions.asn +++ b/asn1/SGP32Definitions.asn @@ -723,6 +723,25 @@ } -- ASN1STOP
+-- Section 5.9.24 +-- ASN1START +GetConnectivityParametersRequest ::= [95] SEQUENCE { -- Tag 'BF5F' +} +-- ASN1STOP +-- ASN1START +GetConnectivityParametersResponse ::= [95] CHOICE { -- Tag 'BF5F' + connectivityParameters ConnectivityParameters, + connectivityParametersError ConnectivityParametersError +} +ConnectivityParameters ::= SEQUENCE { + httpParams [1] OCTET STRING OPTIONAL -- Also used for CoAP +} +ConnectivityParametersError ::= INTEGER { + parametersNotAvailable(1), + undefinedError(127) +} +-- ASN1STOP + -- Section 5.9.25 -- ASN1START SGP32-SetDefaultDpAddressRequest ::= [101] SEQUENCE { -- Tag 'BF65' diff --git a/include/onomondo/ipa/ipad.h b/include/onomondo/ipa/ipad.h index defa530..ff3bd68 100644 --- a/include/onomondo/ipa/ipad.h +++ b/include/onomondo/ipa/ipad.h @@ -98,6 +98,7 @@ int ipa_return_from_fallback(struct ipa_context *ctx, bool refresh_flag); int ipa_enable_emergency_profile(struct ipa_context *ctx, bool refresh_flag); int ipa_disable_emergency_profile(struct ipa_context *ctx, bool refresh_flag); +int ipa_get_connnectivity_parameters(struct ipa_context *ctx, struct ipa_buf **http_params); int ipa_poll(struct ipa_context *ctx); void ipa_close(struct ipa_context *ctx); struct ipa_buf *ipa_free_ctx(struct ipa_context *ctx); diff --git a/src/ipa/libasn/CMakeLists.txt b/src/ipa/libasn/CMakeLists.txt index 82328de..b1f9d8a 100644 --- a/src/ipa/libasn/CMakeLists.txt +++ b/src/ipa/libasn/CMakeLists.txt @@ -194,6 +194,10 @@ ConfigureImmediateProfileEnablingResponse.h ConfigureISDPRequest.c ConfigureISDPRequest.h +ConnectivityParameters.c +ConnectivityParametersError.c +ConnectivityParametersError.h +ConnectivityParameters.h constraints.c constraints.h constr_CHOICE.c @@ -411,6 +415,10 @@ GetCertsRequest.h GetCertsResponse.c GetCertsResponse.h +GetConnectivityParametersRequest.c +GetConnectivityParametersRequest.h +GetConnectivityParametersResponse.c +GetConnectivityParametersResponse.h GetEimConfigurationDataRequest.c GetEimConfigurationDataRequest.h GetEimConfigurationDataResponse.c diff --git a/src/ipa/libasn/ConnectivityParameters.c b/src/ipa/libasn/ConnectivityParameters.c new file mode 100644 index 0000000..37c2e43 --- /dev/null +++ b/src/ipa/libasn/ConnectivityParameters.c @@ -0,0 +1,52 @@ +/* + * Generated by asn1c-0.9.29 (http://lionet.info/asn1c) + * From ASN.1 module "SGP32Definitions" + * found in "../../../asn1/SGP32Definitions.asn" + * `asn1c -fcompound-names -no-gen-example` + */ + +#include "ConnectivityParameters.h" + +asn_TYPE_member_t asn_MBR_ConnectivityParameters_1[] = { + { ATF_POINTER, 1, offsetof(struct ConnectivityParameters, httpParams), + (ASN_TAG_CLASS_CONTEXT | (1 << 2)), + -1, /* IMPLICIT tag at current level */ + &asn_DEF_OCTET_STRING, + 0, + { 0, 0, 0 }, + 0, 0, /* No default value */ + "httpParams" + }, +}; +static const int asn_MAP_ConnectivityParameters_oms_1[] = { 0 }; +static const ber_tlv_tag_t asn_DEF_ConnectivityParameters_tags_1[] = { + (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) +}; +static const asn_TYPE_tag2member_t asn_MAP_ConnectivityParameters_tag2el_1[] = { + { (ASN_TAG_CLASS_CONTEXT | (1 << 2)), 0, 0, 0 } /* httpParams */ +}; +asn_SEQUENCE_specifics_t asn_SPC_ConnectivityParameters_specs_1 = { + sizeof(struct ConnectivityParameters), + offsetof(struct ConnectivityParameters, _asn_ctx), + asn_MAP_ConnectivityParameters_tag2el_1, + 1, /* Count of tags in the map */ + asn_MAP_ConnectivityParameters_oms_1, /* Optional members */ + 1, 0, /* Root/Additions */ + 1, /* First extension addition */ +}; +asn_TYPE_descriptor_t asn_DEF_ConnectivityParameters = { + "ConnectivityParameters", + "ConnectivityParameters", + &asn_OP_SEQUENCE, + asn_DEF_ConnectivityParameters_tags_1, + sizeof(asn_DEF_ConnectivityParameters_tags_1) + /sizeof(asn_DEF_ConnectivityParameters_tags_1[0]), /* 1 */ + asn_DEF_ConnectivityParameters_tags_1, /* Same as above */ + sizeof(asn_DEF_ConnectivityParameters_tags_1) + /sizeof(asn_DEF_ConnectivityParameters_tags_1[0]), /* 1 */ + { 0, 0, SEQUENCE_constraint }, + asn_MBR_ConnectivityParameters_1, + 1, /* Elements count */ + &asn_SPC_ConnectivityParameters_specs_1 /* Additional specs */ +}; + diff --git a/src/ipa/libasn/ConnectivityParameters.h b/src/ipa/libasn/ConnectivityParameters.h new file mode 100644 index 0000000..7174cea --- /dev/null +++ b/src/ipa/libasn/ConnectivityParameters.h @@ -0,0 +1,44 @@ +/* + * Generated by asn1c-0.9.29 (http://lionet.info/asn1c) + * From ASN.1 module "SGP32Definitions" + * found in "../../../asn1/SGP32Definitions.asn" + * `asn1c -fcompound-names -no-gen-example` + */ + +#ifndef _ConnectivityParameters_H_ +#define _ConnectivityParameters_H_ + + +#include <asn_application.h> + +/* Including external dependencies */ +#include <OCTET_STRING.h> +#include <constr_SEQUENCE.h> + +#ifdef __cplusplus +extern "C" { +#endif + +/* ConnectivityParameters */ +typedef struct ConnectivityParameters { + OCTET_STRING_t *httpParams /* OPTIONAL */; + /* + * This type is extensible, + * possible extensions are below. + */ + + /* Context for parsing across buffer boundaries */ + asn_struct_ctx_t _asn_ctx; +} ConnectivityParameters_t; + +/* Implementation */ +extern asn_TYPE_descriptor_t asn_DEF_ConnectivityParameters; +extern asn_SEQUENCE_specifics_t asn_SPC_ConnectivityParameters_specs_1; +extern asn_TYPE_member_t asn_MBR_ConnectivityParameters_1[1]; + +#ifdef __cplusplus +} +#endif + +#endif /* _ConnectivityParameters_H_ */ +#include <asn_internal.h> diff --git a/src/ipa/libasn/ConnectivityParametersError.c b/src/ipa/libasn/ConnectivityParametersError.c new file mode 100644 index 0000000..c42280c --- /dev/null +++ b/src/ipa/libasn/ConnectivityParametersError.c @@ -0,0 +1,31 @@ +/* + * Generated by asn1c-0.9.29 (http://lionet.info/asn1c) + * From ASN.1 module "SGP32Definitions" + * found in "../../../asn1/SGP32Definitions.asn" + * `asn1c -fcompound-names -no-gen-example` + */ + +#include "ConnectivityParametersError.h" + +/* + * This type is implemented using NativeInteger, + * so here we adjust the DEF accordingly. + */ +static const ber_tlv_tag_t asn_DEF_ConnectivityParametersError_tags_1[] = { + (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)) +}; +asn_TYPE_descriptor_t asn_DEF_ConnectivityParametersError = { + "ConnectivityParametersError", + "ConnectivityParametersError", + &asn_OP_NativeInteger, + asn_DEF_ConnectivityParametersError_tags_1, + sizeof(asn_DEF_ConnectivityParametersError_tags_1) + /sizeof(asn_DEF_ConnectivityParametersError_tags_1[0]), /* 1 */ + asn_DEF_ConnectivityParametersError_tags_1, /* Same as above */ + sizeof(asn_DEF_ConnectivityParametersError_tags_1) + /sizeof(asn_DEF_ConnectivityParametersError_tags_1[0]), /* 1 */ + { 0, 0, NativeInteger_constraint }, + 0, 0, /* Defined elsewhere */ + 0 /* No specifics */ +}; + diff --git a/src/ipa/libasn/ConnectivityParametersError.h b/src/ipa/libasn/ConnectivityParametersError.h new file mode 100644 index 0000000..92f24b5 --- /dev/null +++ b/src/ipa/libasn/ConnectivityParametersError.h @@ -0,0 +1,49 @@ +/* + * Generated by asn1c-0.9.29 (http://lionet.info/asn1c) + * From ASN.1 module "SGP32Definitions" + * found in "../../../asn1/SGP32Definitions.asn" + * `asn1c -fcompound-names -no-gen-example` + */ + +#ifndef _ConnectivityParametersError_H_ +#define _ConnectivityParametersError_H_ + + +#include <asn_application.h> + +/* Including external dependencies */ +#include <NativeInteger.h> + +#ifdef __cplusplus +extern "C" { +#endif + +/* Dependencies */ +typedef enum ConnectivityParametersError { + ConnectivityParametersError_parametersNotAvailable = 1, + ConnectivityParametersError_undefinedError = 127 +} e_ConnectivityParametersError; + +/* ConnectivityParametersError */ +typedef long ConnectivityParametersError_t; + +/* Implementation */ +extern asn_TYPE_descriptor_t asn_DEF_ConnectivityParametersError; +asn_struct_free_f ConnectivityParametersError_free; +asn_struct_print_f ConnectivityParametersError_print; +asn_constr_check_f ConnectivityParametersError_constraint; +ber_type_decoder_f ConnectivityParametersError_decode_ber; +der_type_encoder_f ConnectivityParametersError_encode_der; +xer_type_decoder_f ConnectivityParametersError_decode_xer; +xer_type_encoder_f ConnectivityParametersError_encode_xer; +oer_type_decoder_f ConnectivityParametersError_decode_oer; +oer_type_encoder_f ConnectivityParametersError_encode_oer; +per_type_decoder_f ConnectivityParametersError_decode_uper; +per_type_encoder_f ConnectivityParametersError_encode_uper; + +#ifdef __cplusplus +} +#endif + +#endif /* _ConnectivityParametersError_H_ */ +#include <asn_internal.h> diff --git a/src/ipa/libasn/GetConnectivityParametersRequest.c b/src/ipa/libasn/GetConnectivityParametersRequest.c new file mode 100644 index 0000000..2abebd7 --- /dev/null +++ b/src/ipa/libasn/GetConnectivityParametersRequest.c @@ -0,0 +1,36 @@ +/* + * Generated by asn1c-0.9.29 (http://lionet.info/asn1c) + * From ASN.1 module "SGP32Definitions" + * found in "../../../asn1/SGP32Definitions.asn" + * `asn1c -fcompound-names -no-gen-example` + */ + +#include "GetConnectivityParametersRequest.h" + +static const ber_tlv_tag_t asn_DEF_GetConnectivityParametersRequest_tags_1[] = { + (ASN_TAG_CLASS_CONTEXT | (95 << 2)), + (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) +}; +static asn_SEQUENCE_specifics_t asn_SPC_GetConnectivityParametersRequest_specs_1 = { + sizeof(struct GetConnectivityParametersRequest), + offsetof(struct GetConnectivityParametersRequest, _asn_ctx), + 0, /* No top level tags */ + 0, /* No tags in the map */ + 0, 0, 0, /* Optional elements (not needed) */ + -1, /* First extension addition */ +}; +asn_TYPE_descriptor_t asn_DEF_GetConnectivityParametersRequest = { + "GetConnectivityParametersRequest", + "GetConnectivityParametersRequest", + &asn_OP_SEQUENCE, + asn_DEF_GetConnectivityParametersRequest_tags_1, + sizeof(asn_DEF_GetConnectivityParametersRequest_tags_1) + /sizeof(asn_DEF_GetConnectivityParametersRequest_tags_1[0]) - 1, /* 1 */ + asn_DEF_GetConnectivityParametersRequest_tags_1, /* Same as above */ + sizeof(asn_DEF_GetConnectivityParametersRequest_tags_1) + /sizeof(asn_DEF_GetConnectivityParametersRequest_tags_1[0]), /* 2 */ + { 0, 0, SEQUENCE_constraint }, + 0, 0, /* No members */ + &asn_SPC_GetConnectivityParametersRequest_specs_1 /* Additional specs */ +}; + diff --git a/src/ipa/libasn/GetConnectivityParametersRequest.h b/src/ipa/libasn/GetConnectivityParametersRequest.h new file mode 100644 index 0000000..70c4c8f --- /dev/null +++ b/src/ipa/libasn/GetConnectivityParametersRequest.h @@ -0,0 +1,40 @@ +/* + * Generated by asn1c-0.9.29 (http://lionet.info/asn1c) + * From ASN.1 module "SGP32Definitions" + * found in "../../../asn1/SGP32Definitions.asn" + * `asn1c -fcompound-names -no-gen-example` + */ + +#ifndef _GetConnectivityParametersRequest_H_ +#define _GetConnectivityParametersRequest_H_ + + +#include <asn_application.h> + +/* Including external dependencies */ +#include <constr_SEQUENCE.h> + +#ifdef __cplusplus +extern "C" { +#endif + +/* GetConnectivityParametersRequest */ +typedef struct GetConnectivityParametersRequest { + /* + * This type is extensible, + * possible extensions are below. + */ + + /* Context for parsing across buffer boundaries */ + asn_struct_ctx_t _asn_ctx; +} GetConnectivityParametersRequest_t; + +/* Implementation */ +extern asn_TYPE_descriptor_t asn_DEF_GetConnectivityParametersRequest; + +#ifdef __cplusplus +} +#endif + +#endif /* _GetConnectivityParametersRequest_H_ */ +#include <asn_internal.h> diff --git a/src/ipa/libasn/GetConnectivityParametersResponse.c b/src/ipa/libasn/GetConnectivityParametersResponse.c new file mode 100644 index 0000000..a7b547a --- /dev/null +++ b/src/ipa/libasn/GetConnectivityParametersResponse.c @@ -0,0 +1,70 @@ +/* + * Generated by asn1c-0.9.29 (http://lionet.info/asn1c) + * From ASN.1 module "SGP32Definitions" + * found in "../../../asn1/SGP32Definitions.asn" + * `asn1c -fcompound-names -no-gen-example` + */ + +#include "GetConnectivityParametersResponse.h" + +static asn_oer_constraints_t asn_OER_type_GetConnectivityParametersResponse_constr_1 CC_NOTUSED = { + { 0, 0 }, + -1}; +static asn_per_constraints_t asn_PER_type_GetConnectivityParametersResponse_constr_1 CC_NOTUSED = { + { APC_CONSTRAINED | APC_EXTENSIBLE, 1, 1, 0, 1 } /* (0..1,...) */, + { APC_UNCONSTRAINED, -1, -1, 0, 0 }, + 0, 0 /* No PER value map */ +}; +static asn_TYPE_member_t asn_MBR_GetConnectivityParametersResponse_1[] = { + { ATF_NOFLAGS, 0, offsetof(struct GetConnectivityParametersResponse, choice.connectivityParameters), + (ASN_TAG_CLASS_CONTEXT | (0 << 2)), + -1, /* IMPLICIT tag at current level */ + &asn_DEF_ConnectivityParameters, + 0, + { 0, 0, 0 }, + 0, 0, /* No default value */ + "connectivityParameters" + }, + { ATF_NOFLAGS, 0, offsetof(struct GetConnectivityParametersResponse, choice.connectivityParametersError), + (ASN_TAG_CLASS_CONTEXT | (1 << 2)), + -1, /* IMPLICIT tag at current level */ + &asn_DEF_ConnectivityParametersError, + 0, + { 0, 0, 0 }, + 0, 0, /* No default value */ + "connectivityParametersError" + }, +}; +static const ber_tlv_tag_t asn_DEF_GetConnectivityParametersResponse_tags_1[] = { + (ASN_TAG_CLASS_CONTEXT | (95 << 2)) +}; +static const asn_TYPE_tag2member_t asn_MAP_GetConnectivityParametersResponse_tag2el_1[] = { + { (ASN_TAG_CLASS_CONTEXT | (0 << 2)), 0, 0, 0 }, /* connectivityParameters */ + { (ASN_TAG_CLASS_CONTEXT | (1 << 2)), 1, 0, 0 } /* connectivityParametersError */ +}; +static asn_CHOICE_specifics_t asn_SPC_GetConnectivityParametersResponse_specs_1 = { + sizeof(struct GetConnectivityParametersResponse), + offsetof(struct GetConnectivityParametersResponse, _asn_ctx), + offsetof(struct GetConnectivityParametersResponse, present), + sizeof(((struct GetConnectivityParametersResponse *)0)->present), + asn_MAP_GetConnectivityParametersResponse_tag2el_1, + 2, /* Count of tags in the map */ + 0, 0, + 2 /* Extensions start */ +}; +asn_TYPE_descriptor_t asn_DEF_GetConnectivityParametersResponse = { + "GetConnectivityParametersResponse", + "GetConnectivityParametersResponse", + &asn_OP_CHOICE, + asn_DEF_GetConnectivityParametersResponse_tags_1, + sizeof(asn_DEF_GetConnectivityParametersResponse_tags_1) + /sizeof(asn_DEF_GetConnectivityParametersResponse_tags_1[0]), /* 1 */ + asn_DEF_GetConnectivityParametersResponse_tags_1, /* Same as above */ + sizeof(asn_DEF_GetConnectivityParametersResponse_tags_1) + /sizeof(asn_DEF_GetConnectivityParametersResponse_tags_1[0]), /* 1 */ + { &asn_OER_type_GetConnectivityParametersResponse_constr_1, &asn_PER_type_GetConnectivityParametersResponse_constr_1, CHOICE_constraint }, + asn_MBR_GetConnectivityParametersResponse_1, + 2, /* Elements count */ + &asn_SPC_GetConnectivityParametersResponse_specs_1 /* Additional specs */ +}; + diff --git a/src/ipa/libasn/GetConnectivityParametersResponse.h b/src/ipa/libasn/GetConnectivityParametersResponse.h new file mode 100644 index 0000000..940a2bc --- /dev/null +++ b/src/ipa/libasn/GetConnectivityParametersResponse.h @@ -0,0 +1,56 @@ +/* + * Generated by asn1c-0.9.29 (http://lionet.info/asn1c) + * From ASN.1 module "SGP32Definitions" + * found in "../../../asn1/SGP32Definitions.asn" + * `asn1c -fcompound-names -no-gen-example` + */ + +#ifndef _GetConnectivityParametersResponse_H_ +#define _GetConnectivityParametersResponse_H_ + + +#include <asn_application.h> + +/* Including external dependencies */ +#include "ConnectivityParameters.h" +#include "ConnectivityParametersError.h" +#include <constr_CHOICE.h> + +#ifdef __cplusplus +extern "C" { +#endif + +/* Dependencies */ +typedef enum GetConnectivityParametersResponse_PR { + GetConnectivityParametersResponse_PR_NOTHING, /* No components present */ + GetConnectivityParametersResponse_PR_connectivityParameters, + GetConnectivityParametersResponse_PR_connectivityParametersError + /* Extensions may appear below */ + +} GetConnectivityParametersResponse_PR; + +/* GetConnectivityParametersResponse */ +typedef struct GetConnectivityParametersResponse { + GetConnectivityParametersResponse_PR present; + union GetConnectivityParametersResponse_u { + ConnectivityParameters_t connectivityParameters; + ConnectivityParametersError_t connectivityParametersError; + /* + * This type is extensible, + * possible extensions are below. + */ + } choice; + + /* Context for parsing across buffer boundaries */ + asn_struct_ctx_t _asn_ctx; +} GetConnectivityParametersResponse_t; + +/* Implementation */ +extern asn_TYPE_descriptor_t asn_DEF_GetConnectivityParametersResponse; + +#ifdef __cplusplus +} +#endif + +#endif /* _GetConnectivityParametersResponse_H_ */ +#include <asn_internal.h> diff --git a/src/ipa/libipa/CMakeLists.txt b/src/ipa/libipa/CMakeLists.txt index d25b35b..e85d128 100644 --- a/src/ipa/libipa/CMakeLists.txt +++ b/src/ipa/libipa/CMakeLists.txt @@ -24,6 +24,7 @@ es10b_ret_from_fallback.c es10b_en_emerg_prfle.c es10b_dis_emerg_prfle.c + es10b_get_conn_params.c es10c_delete_prfle.c es10c_disable_prfle.c es10c_enable_prfle.c diff --git a/src/ipa/libipa/es10b_get_conn_params.c b/src/ipa/libipa/es10b_get_conn_params.c new file mode 100644 index 0000000..074c8b4 --- /dev/null +++ b/src/ipa/libipa/es10b_get_conn_params.c @@ -0,0 +1,95 @@ +/* + * Copyright (c) 2026 sysmocom - s.f.m.c. GmbH. All rights reserved. + * + * SPDX-License-Identifier: AGPL-3.0-only + * + * Author: Philipp Maier pmaier@sysmocom.de / sysmocom - s.f.m.c. GmbH + * Andreas Eversberg aeversberg@sysmocom.de / sysmocom - s.f.m.c. GmbH + * + * See also: GSMA SGP.22, 5.9.20: Function (ES10b): ExecuteFallbackMechanism + */ + +#include <stdio.h> +#include <assert.h> +#include <onomondo/ipa/utils.h> +#include "context.h" +#include "utils.h" +#include "euicc.h" +#include "es10x.h" +#include "es10b_get_conn_params.h" +#include <GetConnectivityParametersRequest.h> + +static const struct num_str_map error_code_strings[] = { + { ConnectivityParametersError_parametersNotAvailable, "parametersNotAvailable" }, + { ConnectivityParametersError_undefinedError, "undefinedError" }, + { 0, NULL } +}; + +static int dec_get_conn_params_res(struct ipa_es10b_get_conn_params_res *res, const struct ipa_buf *es10b_res) +{ + struct GetConnectivityParametersResponse *asn = NULL; + + asn = ipa_es10x_res_dec(&asn_DEF_GetConnectivityParametersResponse, es10b_res, "GetConnectivityParameters"); + if (!asn) + return -EINVAL; + + switch (asn->present) { + case GetConnectivityParametersResponse_PR_connectivityParameters: + IPA_LOGP_ES10X("GetConnectivityParametersResponse", LERROR, "function succeeded!\n"); + break; + case GetConnectivityParametersResponse_PR_connectivityParametersError: + IPA_LOGP_ES10X("GetConnectivityParametersResponse", LERROR, "function failed with error code %ld=%s!\n", + asn->choice.connectivityParametersError, + ipa_str_from_num(error_code_strings, asn->choice.connectivityParametersError, "(unknown)")); + break; + default: + break; + } + + res->res = asn; + return 0; +} + +/*! Function (Es10b): GetConnectivityParameters. + * \param[inout] ctx pointer to ipa_context. + * \returns pointer newly allocated struct with function result, NULL on error. */ +struct ipa_es10b_get_conn_params_res *ipa_es10b_get_conn_params(struct ipa_context *ctx) +{ + struct ipa_buf *es10b_req = NULL; + struct ipa_buf *es10b_res = NULL; + struct GetConnectivityParametersRequest req = { 0 }; + struct ipa_es10b_get_conn_params_res *res = IPA_ALLOC_ZERO(struct ipa_es10b_get_conn_params_res); + int rc; + + es10b_req = ipa_es10x_req_enc(&asn_DEF_GetConnectivityParametersRequest, &req, "GetConnectivityParameters"); + if (!es10b_req) { + IPA_LOGP_ES10X("GetConnectivityParametersRequest", LERROR, "unable to encode Es10b request\n"); + goto error; + } + + es10b_res = ipa_euicc_transceive_es10x(ctx, es10b_req); + if (!es10b_res) { + IPA_LOGP_ES10X("GetConnectivityParametersRequest", LERROR, "no Es10b response\n"); + goto error; + } + + rc = dec_get_conn_params_res(res, es10b_res); + if (rc < 0) + goto error; + + IPA_FREE(es10b_req); + IPA_FREE(es10b_res); + return res; +error: + IPA_FREE(es10b_req); + IPA_FREE(es10b_res); + ipa_es10b_get_conn_params_res_free(res); + return NULL; +} + +/*! Free results of function (Es10b): GetConnectivityParameters. + * \param[in] res pointer to function result. */ +void ipa_es10b_get_conn_params_res_free(struct ipa_es10b_get_conn_params_res *res) +{ + IPA_ES10X_RES_FREE(asn_DEF_GetConnectivityParametersResponse, res); +} diff --git a/src/ipa/libipa/es10b_get_conn_params.h b/src/ipa/libipa/es10b_get_conn_params.h new file mode 100644 index 0000000..75feeca --- /dev/null +++ b/src/ipa/libipa/es10b_get_conn_params.h @@ -0,0 +1,17 @@ +/* + * Copyright (c) 2026 sysmocom - s.f.m.c. GmbH. All rights reserved. + * + * SPDX-License-Identifier: AGPL-3.0-only + */ + +#pragma once + +#include <GetConnectivityParametersResponse.h> +struct ipa_context; + +struct ipa_es10b_get_conn_params_res { + struct GetConnectivityParametersResponse *res; +}; + +struct ipa_es10b_get_conn_params_res *ipa_es10b_get_conn_params(struct ipa_context *ctx); +void ipa_es10b_get_conn_params_res_free(struct ipa_es10b_get_conn_params_res *res); diff --git a/src/ipa/libipa/ipad.c b/src/ipa/libipa/ipad.c index 00ab37d..83e94a1 100644 --- a/src/ipa/libipa/ipad.c +++ b/src/ipa/libipa/ipad.c @@ -29,6 +29,7 @@ #include "es10b_ret_from_fallback.h" #include "es10b_en_emerg_prfle.h" #include "es10b_dis_emerg_prfle.h" +#include "es10b_get_conn_params.h" #include "proc_euicc_pkg_dwnld_exec.h" #include "proc_notif_delivery.h"
@@ -373,6 +374,35 @@ return rc; }
+/*! Get connectivity parameters from active profile. + * \param[inout] ctx pointer to ipa_context. + * \param[out] http_params pointer to the HTTP parameters pointer to be returned. + * \returns 0 on success, negative on error. */ +int ipa_get_connnectivity_parameters(struct ipa_context *ctx, struct ipa_buf **http_params) +{ + struct ipa_es10b_get_conn_params_res *res; + + *http_params = NULL; + + if (ctx->cfg->iot_euicc_emu_enabled) { + IPA_LOGP(SIPA, LERROR, "Unable to emulate retrieval of connectivity patameters.\n"); + return -ENOTSUP; + } + + res = ipa_es10b_get_conn_params(ctx); + if (!res) + return -EIO; + if (res->res->present == GetConnectivityParametersResponse_PR_connectivityParameters) { + if (res->res->choice.connectivityParameters.httpParams) { + ipa_buf_alloc_data(res->res->choice.connectivityParameters.httpParams->size, + res->res->choice.connectivityParameters.httpParams->buf); + } + } + ipa_es10b_get_conn_params_res_free(res); + + return 0; +} + static int check_canaries(struct ipa_context *ctx) { if (ctx->check_http) diff --git a/src/ipa/main.c b/src/ipa/main.c index 4352ee6..3e7b7a7 100644 --- a/src/ipa/main.c +++ b/src/ipa/main.c @@ -54,6 +54,7 @@ printf(" --enable-emergency-profile.. Trigger enabling of emergency profile\n"); printf(" --disable-emergency-profile. Trigger return from emergency profile to previous profile\n"); printf(" --refresh-flag.............. Make eUICC send a CAT refresh after switchting profile with the triggers above.\n"); + printf(" --getopt-get-conn-params.... Get connectivity parameters from acurrently active profile\n"); printf(" -n PATH .................... path to nvstate file (default: %s)\n", DEFAULT_NVSTATE_PATH); printf(" -y NUM ..................... number of retries for ESipa requests (default: %u)\n", DEFAULT_ESIPA_REQ_RETRIES); @@ -152,6 +153,7 @@ bool getopt_enable_emergency_profile = false; bool getopt_disable_emergency_profile = false; bool getopt_refresh_flag = false; + bool getopt_get_connectivity_params = false; char *getopt_nvstate_path = DEFAULT_NVSTATE_PATH; struct ipa_buf *nvstate_load = NULL; struct ipa_buf *nvstate_save = NULL; @@ -174,6 +176,7 @@ OPT_ENABLEEMGERGENCY, OPT_DISABLEEMGERGENCY, OPT_REFRESHFLAG, + OPT_GETCONNPARAMS, };
struct option long_options[] = { @@ -182,6 +185,7 @@ { "enable-emergency-profile", no_argument, NULL, OPT_ENABLEEMGERGENCY}, { "disable-emergency-profile", no_argument, NULL, OPT_DISABLEEMGERGENCY}, { "refresh-flag", no_argument, NULL, OPT_REFRESHFLAG}, + { "get-conn-params", no_argument, NULL, OPT_GETCONNPARAMS}, { NULL, 0, NULL, 0} };
@@ -229,6 +233,9 @@ case OPT_REFRESHFLAG: getopt_refresh_flag = true; break; + case OPT_GETCONNPARAMS: + getopt_get_connectivity_params = true; + break; case 'n': getopt_nvstate_path = optarg; break; @@ -322,6 +329,14 @@ } else if (getopt_disable_emergency_profile) { /* Trigger return from emergency profile to previous profile */ ipa_disable_emergency_profile(ctx, getopt_refresh_flag); + } else if (getopt_get_connectivity_params) { + struct ipa_buf *http_params; + /* Trigger return from emergency profile to previous profile */ + rc = ipa_get_connnectivity_parameters(ctx, &http_params); + if (rc < 0) + goto leave; + IPA_LOGP(SMAIN, LINFO, "HTTP paramms: %s\n", ipa_buf_hexdump(http_params)); + ipa_buf_free(http_params); } else { IPA_LOGP(SMAIN, LINFO, "-----------------------------8<-----------------------------\n"); rc = eim_init(ctx);