[lpa]1.补提交遗漏的头文件

This commit is contained in:
alisa 2023-08-23 01:50:19 +08:00
parent f441ef1d98
commit 847c97e07a
46 changed files with 8164 additions and 2 deletions

View File

@ -31,6 +31,7 @@ endif
SIFAR_DIR = $(LIBRARY_DIR)/source/sifar/code SIFAR_DIR = $(LIBRARY_DIR)/source/sifar/code
SIFAR_APP_DIR = $(APP_DIR)/source/sf_app/code/include SIFAR_APP_DIR = $(APP_DIR)/source/sf_app/code/include
SIFAR_APP_LPA_DIR = $(APP_DIR)/source/sf_app/code/source/sf_lpa/LPA_SDK/include
#LIB DIRs for C_LDFLAGS #LIB DIRs for C_LDFLAGS
EXTRA_LIB_DIR += \ EXTRA_LIB_DIR += \
@ -75,6 +76,7 @@ EXTRA_INCLUDE += \
-I$(NVT_HDAL_DIR)/vendor/media/include \ -I$(NVT_HDAL_DIR)/vendor/media/include \
-I$(NVT_HDAL_DIR)/vendor/common/include \ -I$(NVT_HDAL_DIR)/vendor/common/include \
-I$(SIFAR_APP_DIR) \ -I$(SIFAR_APP_DIR) \
-I$(SIFAR_APP_LPA_DIR) \
-I$(APP_DIR)/sifarsdk/out/libs/include \ -I$(APP_DIR)/sifarsdk/out/libs/include \
# application local includes # application local includes
@ -220,6 +222,30 @@ EXTRA_LIB += \
# system # system
SRC = \ SRC = \
./code/source/sf_lpa/Extra/base64/base64.c \
./code/source/sf_lpa/Extra/sha256/sha-256.c \
./code/source/sf_lpa/LPA_SDK/src/lpasdk_api.c \
./code/source/sf_lpa/LPA_SDK/src/lpasdk_api_error.c \
./code/source/sf_lpa/LPA_SDK/src/driver/httpmedia_curl.c \
./code/source/sf_lpa/LPA_SDK/src/driver/semedia_genericmodem.c \
./code/source/sf_lpa/LPA_SDK/src/driver/semedia_winscard.c \
./code/source/sf_lpa/LPA_SDK/src/core/bertlv_object.c \
./code/source/sf_lpa/LPA_SDK/src/core/httpmedia_base.c \
./code/source/sf_lpa/LPA_SDK/src/core/httpmedia_manager.c \
./code/source/sf_lpa/LPA_SDK/src/core/isdr_applet_manager.c \
./code/source/sf_lpa/LPA_SDK/src/core/lpa_config_file.c \
./code/source/sf_lpa/LPA_SDK/src/core/lpa_log.c \
./code/source/sf_lpa/LPA_SDK/src/core/lpa_manager.c \
./code/source/sf_lpa/LPA_SDK/src/core/lpa_manager_api.c \
./code/source/sf_lpa/LPA_SDK/src/core/lpa_manager_es9plus.c \
./code/source/sf_lpa/LPA_SDK/src/core/lpa_manager_es10b.c \
./code/source/sf_lpa/LPA_SDK/src/core/lpa_manager_es10c.c \
./code/source/sf_lpa/LPA_SDK/src/core/lpa_manager_helper.c \
./code/source/sf_lpa/LPA_SDK/src/core/lpa_memory.c \
./code/source/sf_lpa/LPA_SDK/src/core/rawdata_object.c \
./code/source/sf_lpa/LPA_SDK/src/core/semedia_base.c \
./code/source/sf_lpa/LPA_SDK/src/core/semedia_manager.c \
./code/source/sf_lpa/LPA_SDK/src/core/util.c \
./code/source/app/sf_device.c \ ./code/source/app/sf_device.c \
./code/source/app/sf_app.c \ ./code/source/app/sf_app.c \
./code/source/app/sf_common.c \ ./code/source/app/sf_common.c \
@ -253,6 +279,8 @@ SRC = \
./code/source/qrcodeMng/split.c \ ./code/source/qrcodeMng/split.c \
./code/source/storeMng/sf_storeMng.c \ ./code/source/storeMng/sf_storeMng.c \
./code/source/ttyusb/sf_hal_ttyusb.c \ ./code/source/ttyusb/sf_hal_ttyusb.c \
./code/source/4gMng/sf_4g_lpa.c \
./code/source/4gMng/sf_4G_sms_lpa_cmd.c \
./code/source/4gMng/sf_eg91_gps.c \ ./code/source/4gMng/sf_eg91_gps.c \
./code/source/4gMng/sf_eg91_server.c \ ./code/source/4gMng/sf_eg91_server.c \
./code/source/4gMng/sf_eg91_sim.c \ ./code/source/4gMng/sf_eg91_sim.c \

View File

@ -0,0 +1,44 @@
/*
base64.c - by Joe DF (joedf@ahkscript.org)
Released under the MIT License
Revision: 2015-06-12 01:26:51
Thank you for inspiration:
http://www.codeproject.com/Tips/813146/Fast-base-functions-for-encode-decode
*/
#include <stdio.h>
//Base64 char table function - used internally for decoding
unsigned int b64_int(unsigned int ch);
// in_size : the number bytes to be encoded.
// Returns the recommended memory size to be allocated for the output buffer excluding the null byte
unsigned int b64e_size(unsigned int in_size);
// in_size : the number bytes to be decoded.
// Returns the recommended memory size to be allocated for the output buffer
unsigned int b64d_size(unsigned int in_size);
// in : buffer of "raw" binary to be encoded.
// in_len : number of bytes to be encoded.
// out : pointer to buffer with enough memory, user is responsible for memory allocation, receives null-terminated string
// returns size of output including null byte
unsigned int b64_encode(const unsigned char* in, unsigned int in_len, unsigned char* out);
// in : buffer of base64 string to be decoded.
// in_len : number of bytes to be decoded.
// out : pointer to buffer with enough memory, user is responsible for memory allocation, receives "raw" binary
// returns size of output excluding null byte
unsigned int b64_decode(const unsigned char* in, unsigned int in_len, unsigned char* out);
// file-version b64_encode
// Input : filenames
// returns size of output
unsigned int b64_encodef(char *InFile, char *OutFile);
// file-version b64_decode
// Input : filenames
// returns size of output
unsigned int b64_decodef(char *InFile, char *OutFile);

View File

@ -0,0 +1,285 @@
/*
Copyright (c) 2009-2017 Dave Gamble and cJSON contributors
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
#ifndef cJSON__h
#define cJSON__h
#ifdef __cplusplus
extern "C"
{
#endif
#if !defined(__WINDOWS__) && (defined(WIN32) || defined(WIN64) || defined(_MSC_VER) || defined(_WIN32))
#define __WINDOWS__
#endif
#ifdef __WINDOWS__
/* When compiling for windows, we specify a specific calling convention to avoid issues where we are being called from a project with a different default calling convention. For windows you have 3 define options:
CJSON_HIDE_SYMBOLS - Define this in the case where you don't want to ever dllexport symbols
CJSON_EXPORT_SYMBOLS - Define this on library build when you want to dllexport symbols (default)
CJSON_IMPORT_SYMBOLS - Define this if you want to dllimport symbol
For *nix builds that support visibility attribute, you can define similar behavior by
setting default visibility to hidden by adding
-fvisibility=hidden (for gcc)
or
-xldscope=hidden (for sun cc)
to CFLAGS
then using the CJSON_API_VISIBILITY flag to "export" the same symbols the way CJSON_EXPORT_SYMBOLS does
*/
#define CJSON_CDECL __cdecl
#define CJSON_STDCALL __stdcall
/* export symbols by default, this is necessary for copy pasting the C and header file */
#if !defined(CJSON_HIDE_SYMBOLS) && !defined(CJSON_IMPORT_SYMBOLS) && !defined(CJSON_EXPORT_SYMBOLS)
#define CJSON_EXPORT_SYMBOLS
#endif
#if defined(CJSON_HIDE_SYMBOLS)
#define CJSON_PUBLIC(type) type CJSON_STDCALL
#elif defined(CJSON_EXPORT_SYMBOLS)
#define CJSON_PUBLIC(type) __declspec(dllexport) type CJSON_STDCALL
#elif defined(CJSON_IMPORT_SYMBOLS)
#define CJSON_PUBLIC(type) __declspec(dllimport) type CJSON_STDCALL
#endif
#else /* !__WINDOWS__ */
#define CJSON_CDECL
#define CJSON_STDCALL
#if (defined(__GNUC__) || defined(__SUNPRO_CC) || defined (__SUNPRO_C)) && defined(CJSON_API_VISIBILITY)
#define CJSON_PUBLIC(type) __attribute__((visibility("default"))) type
#else
#define CJSON_PUBLIC(type) type
#endif
#endif
/* project version */
#define CJSON_VERSION_MAJOR 1
#define CJSON_VERSION_MINOR 7
#define CJSON_VERSION_PATCH 10
#include <stddef.h>
/* cJSON Types: */
#define cJSON_Invalid (0)
#define cJSON_False (1 << 0)
#define cJSON_True (1 << 1)
#define cJSON_NULL (1 << 2)
#define cJSON_Number (1 << 3)
#define cJSON_String (1 << 4)
#define cJSON_Array (1 << 5)
#define cJSON_Object (1 << 6)
#define cJSON_Raw (1 << 7) /* raw json */
#define cJSON_IsReference 256
#define cJSON_StringIsConst 512
/* The cJSON structure: */
typedef struct cJSON
{
/* next/prev allow you to walk array/object chains. Alternatively, use GetArraySize/GetArrayItem/GetObjectItem */
struct cJSON *next;
struct cJSON *prev;
/* An array or object item will have a child pointer pointing to a chain of the items in the array/object. */
struct cJSON *child;
/* The type of the item, as above. */
int type;
/* The item's string, if type==cJSON_String and type == cJSON_Raw */
char *valuestring;
/* writing to valueint is DEPRECATED, use cJSON_SetNumberValue instead */
int valueint;
/* The item's number, if type==cJSON_Number */
double valuedouble;
/* The item's name string, if this item is the child of, or is in the list of subitems of an object. */
char *string;
} cJSON;
typedef struct cJSON_Hooks
{
/* malloc/free are CDECL on Windows regardless of the default calling convention of the compiler, so ensure the hooks allow passing those functions directly. */
void *(CJSON_CDECL *malloc_fn)(size_t sz);
void (CJSON_CDECL *free_fn)(void *ptr);
} cJSON_Hooks;
typedef int cJSON_bool;
/* Limits how deeply nested arrays/objects can be before cJSON rejects to parse them.
* This is to prevent stack overflows. */
#ifndef CJSON_NESTING_LIMIT
#define CJSON_NESTING_LIMIT 1000
#endif
/* returns the version of cJSON as a string */
CJSON_PUBLIC(const char*) cJSON_Version(void);
/* Supply malloc, realloc and free functions to cJSON */
CJSON_PUBLIC(void) cJSON_InitHooks(cJSON_Hooks* hooks);
/* Memory Management: the caller is always responsible to free the results from all variants of cJSON_Parse (with cJSON_Delete) and cJSON_Print (with stdlib free, cJSON_Hooks.free_fn, or cJSON_free as appropriate). The exception is cJSON_PrintPreallocated, where the caller has full responsibility of the buffer. */
/* Supply a block of JSON, and this returns a cJSON object you can interrogate. */
CJSON_PUBLIC(cJSON *) cJSON_Parse(const char *value);
/* ParseWithOpts allows you to require (and check) that the JSON is null terminated, and to retrieve the pointer to the final byte parsed. */
/* If you supply a ptr in return_parse_end and parsing fails, then return_parse_end will contain a pointer to the error so will match cJSON_GetErrorPtr(). */
CJSON_PUBLIC(cJSON *) cJSON_ParseWithOpts(const char *value, const char **return_parse_end, cJSON_bool require_null_terminated);
/* Render a cJSON entity to text for transfer/storage. */
CJSON_PUBLIC(char *) cJSON_Print(const cJSON *item);
/* Render a cJSON entity to text for transfer/storage without any formatting. */
CJSON_PUBLIC(char *) cJSON_PrintUnformatted(const cJSON *item);
/* Render a cJSON entity to text using a buffered strategy. prebuffer is a guess at the final size. guessing well reduces reallocation. fmt=0 gives unformatted, =1 gives formatted */
CJSON_PUBLIC(char *) cJSON_PrintBuffered(const cJSON *item, int prebuffer, cJSON_bool fmt);
/* Render a cJSON entity to text using a buffer already allocated in memory with given length. Returns 1 on success and 0 on failure. */
/* NOTE: cJSON is not always 100% accurate in estimating how much memory it will use, so to be safe allocate 5 bytes more than you actually need */
CJSON_PUBLIC(cJSON_bool) cJSON_PrintPreallocated(cJSON *item, char *buffer, const int length, const cJSON_bool format);
/* Delete a cJSON entity and all subentities. */
CJSON_PUBLIC(void) cJSON_Delete(cJSON *c);
/* Returns the number of items in an array (or object). */
CJSON_PUBLIC(int) cJSON_GetArraySize(const cJSON *array);
/* Retrieve item number "index" from array "array". Returns NULL if unsuccessful. */
CJSON_PUBLIC(cJSON *) cJSON_GetArrayItem(const cJSON *array, int index);
/* Get item "string" from object. Case insensitive. */
CJSON_PUBLIC(cJSON *) cJSON_GetObjectItem(const cJSON * const object, const char * const string);
CJSON_PUBLIC(cJSON *) cJSON_GetObjectItemCaseSensitive(const cJSON * const object, const char * const string);
CJSON_PUBLIC(cJSON_bool) cJSON_HasObjectItem(const cJSON *object, const char *string);
/* For analysing failed parses. This returns a pointer to the parse error. You'll probably need to look a few chars back to make sense of it. Defined when cJSON_Parse() returns 0. 0 when cJSON_Parse() succeeds. */
CJSON_PUBLIC(const char *) cJSON_GetErrorPtr(void);
/* Check if the item is a string and return its valuestring */
CJSON_PUBLIC(char *) cJSON_GetStringValue(cJSON *item);
/* These functions check the type of an item */
CJSON_PUBLIC(cJSON_bool) cJSON_IsInvalid(const cJSON * const item);
CJSON_PUBLIC(cJSON_bool) cJSON_IsFalse(const cJSON * const item);
CJSON_PUBLIC(cJSON_bool) cJSON_IsTrue(const cJSON * const item);
CJSON_PUBLIC(cJSON_bool) cJSON_IsBool(const cJSON * const item);
CJSON_PUBLIC(cJSON_bool) cJSON_IsNull(const cJSON * const item);
CJSON_PUBLIC(cJSON_bool) cJSON_IsNumber(const cJSON * const item);
CJSON_PUBLIC(cJSON_bool) cJSON_IsString(const cJSON * const item);
CJSON_PUBLIC(cJSON_bool) cJSON_IsArray(const cJSON * const item);
CJSON_PUBLIC(cJSON_bool) cJSON_IsObject(const cJSON * const item);
CJSON_PUBLIC(cJSON_bool) cJSON_IsRaw(const cJSON * const item);
/* These calls create a cJSON item of the appropriate type. */
CJSON_PUBLIC(cJSON *) cJSON_CreateNull(void);
CJSON_PUBLIC(cJSON *) cJSON_CreateTrue(void);
CJSON_PUBLIC(cJSON *) cJSON_CreateFalse(void);
CJSON_PUBLIC(cJSON *) cJSON_CreateBool(cJSON_bool boolean);
CJSON_PUBLIC(cJSON *) cJSON_CreateNumber(double num);
CJSON_PUBLIC(cJSON *) cJSON_CreateString(const char *string);
/* raw json */
CJSON_PUBLIC(cJSON *) cJSON_CreateRaw(const char *raw);
CJSON_PUBLIC(cJSON *) cJSON_CreateArray(void);
CJSON_PUBLIC(cJSON *) cJSON_CreateObject(void);
/* Create a string where valuestring references a string so
* it will not be freed by cJSON_Delete */
CJSON_PUBLIC(cJSON *) cJSON_CreateStringReference(const char *string);
/* Create an object/arrray that only references it's elements so
* they will not be freed by cJSON_Delete */
CJSON_PUBLIC(cJSON *) cJSON_CreateObjectReference(const cJSON *child);
CJSON_PUBLIC(cJSON *) cJSON_CreateArrayReference(const cJSON *child);
/* These utilities create an Array of count items. */
CJSON_PUBLIC(cJSON *) cJSON_CreateIntArray(const int *numbers, int count);
CJSON_PUBLIC(cJSON *) cJSON_CreateFloatArray(const float *numbers, int count);
CJSON_PUBLIC(cJSON *) cJSON_CreateDoubleArray(const double *numbers, int count);
CJSON_PUBLIC(cJSON *) cJSON_CreateStringArray(const char **strings, int count);
/* Append item to the specified array/object. */
CJSON_PUBLIC(void) cJSON_AddItemToArray(cJSON *array, cJSON *item);
CJSON_PUBLIC(void) cJSON_AddItemToObject(cJSON *object, const char *string, cJSON *item);
/* Use this when string is definitely const (i.e. a literal, or as good as), and will definitely survive the cJSON object.
* WARNING: When this function was used, make sure to always check that (item->type & cJSON_StringIsConst) is zero before
* writing to `item->string` */
CJSON_PUBLIC(void) cJSON_AddItemToObjectCS(cJSON *object, const char *string, cJSON *item);
/* Append reference to item to the specified array/object. Use this when you want to add an existing cJSON to a new cJSON, but don't want to corrupt your existing cJSON. */
CJSON_PUBLIC(void) cJSON_AddItemReferenceToArray(cJSON *array, cJSON *item);
CJSON_PUBLIC(void) cJSON_AddItemReferenceToObject(cJSON *object, const char *string, cJSON *item);
/* Remove/Detatch items from Arrays/Objects. */
CJSON_PUBLIC(cJSON *) cJSON_DetachItemViaPointer(cJSON *parent, cJSON * const item);
CJSON_PUBLIC(cJSON *) cJSON_DetachItemFromArray(cJSON *array, int which);
CJSON_PUBLIC(void) cJSON_DeleteItemFromArray(cJSON *array, int which);
CJSON_PUBLIC(cJSON *) cJSON_DetachItemFromObject(cJSON *object, const char *string);
CJSON_PUBLIC(cJSON *) cJSON_DetachItemFromObjectCaseSensitive(cJSON *object, const char *string);
CJSON_PUBLIC(void) cJSON_DeleteItemFromObject(cJSON *object, const char *string);
CJSON_PUBLIC(void) cJSON_DeleteItemFromObjectCaseSensitive(cJSON *object, const char *string);
/* Update array items. */
CJSON_PUBLIC(void) cJSON_InsertItemInArray(cJSON *array, int which, cJSON *newitem); /* Shifts pre-existing items to the right. */
CJSON_PUBLIC(cJSON_bool) cJSON_ReplaceItemViaPointer(cJSON * const parent, cJSON * const item, cJSON * replacement);
CJSON_PUBLIC(void) cJSON_ReplaceItemInArray(cJSON *array, int which, cJSON *newitem);
CJSON_PUBLIC(void) cJSON_ReplaceItemInObject(cJSON *object, const char *string, cJSON *newitem);
CJSON_PUBLIC(void) cJSON_ReplaceItemInObjectCaseSensitive(cJSON *object, const char *string, cJSON *newitem);
/* Duplicate a cJSON item */
CJSON_PUBLIC(cJSON *) cJSON_Duplicate(const cJSON *item, cJSON_bool recurse);
/* Duplicate will create a new, identical cJSON item to the one you pass, in new memory that will
need to be released. With recurse!=0, it will duplicate any children connected to the item.
The item->next and ->prev pointers are always zero on return from Duplicate. */
/* Recursively compare two cJSON items for equality. If either a or b is NULL or invalid, they will be considered unequal.
* case_sensitive determines if object keys are treated case sensitive (1) or case insensitive (0) */
CJSON_PUBLIC(cJSON_bool) cJSON_Compare(const cJSON * const a, const cJSON * const b, const cJSON_bool case_sensitive);
CJSON_PUBLIC(void) cJSON_Minify(char *json);
/* Helper functions for creating and adding items to an object at the same time.
* They return the added item or NULL on failure. */
CJSON_PUBLIC(cJSON*) cJSON_AddNullToObject(cJSON * const object, const char * const name);
CJSON_PUBLIC(cJSON*) cJSON_AddTrueToObject(cJSON * const object, const char * const name);
CJSON_PUBLIC(cJSON*) cJSON_AddFalseToObject(cJSON * const object, const char * const name);
CJSON_PUBLIC(cJSON*) cJSON_AddBoolToObject(cJSON * const object, const char * const name, const cJSON_bool boolean);
CJSON_PUBLIC(cJSON*) cJSON_AddNumberToObject(cJSON * const object, const char * const name, const double number);
CJSON_PUBLIC(cJSON*) cJSON_AddStringToObject(cJSON * const object, const char * const name, const char * const string);
CJSON_PUBLIC(cJSON*) cJSON_AddRawToObject(cJSON * const object, const char * const name, const char * const raw);
CJSON_PUBLIC(cJSON*) cJSON_AddObjectToObject(cJSON * const object, const char * const name);
CJSON_PUBLIC(cJSON*) cJSON_AddArrayToObject(cJSON * const object, const char * const name);
/* When assigning an integer value, it needs to be propagated to valuedouble too. */
#define cJSON_SetIntValue(object, number) ((object) ? (object)->valueint = (object)->valuedouble = (number) : (number))
/* helper for the cJSON_SetNumberValue macro */
CJSON_PUBLIC(double) cJSON_SetNumberHelper(cJSON *object, double number);
#define cJSON_SetNumberValue(object, number) ((object != NULL) ? cJSON_SetNumberHelper(object, (double)number) : (number))
/* Macro for iterating over an array or object */
#define cJSON_ArrayForEach(element, array) for(element = (array != NULL) ? (array)->child : NULL; element != NULL; element = element->next)
/* malloc/free objects using the malloc/free functions that have been set with cJSON_InitHooks */
CJSON_PUBLIC(void *) cJSON_malloc(size_t size);
CJSON_PUBLIC(void) cJSON_free(void *object);
#ifdef __cplusplus
}
#endif
#endif

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,77 @@
#ifndef __CURL_CURLVER_H
#define __CURL_CURLVER_H
/***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2018, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
* are also available at https://curl.haxx.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
* furnished to do so, under the terms of the COPYING file.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
***************************************************************************/
/* This header file contains nothing but libcurl version info, generated by
a script at release-time. This was made its own header file in 7.11.2 */
/* This is the global package copyright */
#define LIBCURL_COPYRIGHT "1996 - 2018 Daniel Stenberg, <daniel@haxx.se>."
/* This is the version number of the libcurl package from which this header
file origins: */
#define LIBCURL_VERSION "7.64.0"
/* The numeric version number is also available "in parts" by using these
defines: */
#define LIBCURL_VERSION_MAJOR 7
#define LIBCURL_VERSION_MINOR 64
#define LIBCURL_VERSION_PATCH 0
/* This is the numeric version of the libcurl version number, meant for easier
parsing and comparions by programs. The LIBCURL_VERSION_NUM define will
always follow this syntax:
0xXXYYZZ
Where XX, YY and ZZ are the main version, release and patch numbers in
hexadecimal (using 8 bits each). All three numbers are always represented
using two digits. 1.2 would appear as "0x010200" while version 9.11.7
appears as "0x090b07".
This 6-digit (24 bits) hexadecimal number does not show pre-release number,
and it is always a greater number in a more recent release. It makes
comparisons with greater than and less than work.
Note: This define is the full hex number and _does not_ use the
CURL_VERSION_BITS() macro since curl's own configure script greps for it
and needs it to contain the full number.
*/
#define LIBCURL_VERSION_NUM 0x074000
/*
* This is the date and time when the full source package was created. The
* timestamp is not stored in git, as the timestamp is properly set in the
* tarballs by the maketgz script.
*
* The format of the date follows this template:
*
* "2007-11-23"
*/
#define LIBCURL_TIMESTAMP "2019-02-06"
#define CURL_VERSION_BITS(x,y,z) ((x)<<16|(y)<<8|z)
#define CURL_AT_LEAST_VERSION(x,y,z) \
(LIBCURL_VERSION_NUM >= CURL_VERSION_BITS(x, y, z))
#endif /* __CURL_CURLVER_H */

View File

@ -0,0 +1,112 @@
#ifndef __CURL_EASY_H
#define __CURL_EASY_H
/***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
* are also available at https://curl.haxx.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
* furnished to do so, under the terms of the COPYING file.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
***************************************************************************/
#ifdef __cplusplus
extern "C" {
#endif
CURL_EXTERN CURL *curl_easy_init(void);
CURL_EXTERN CURLcode curl_easy_setopt(CURL *curl, CURLoption option, ...);
CURL_EXTERN CURLcode curl_easy_perform(CURL *curl);
CURL_EXTERN void curl_easy_cleanup(CURL *curl);
/*
* NAME curl_easy_getinfo()
*
* DESCRIPTION
*
* Request internal information from the curl session with this function. The
* third argument MUST be a pointer to a long, a pointer to a char * or a
* pointer to a double (as the documentation describes elsewhere). The data
* pointed to will be filled in accordingly and can be relied upon only if the
* function returns CURLE_OK. This function is intended to get used *AFTER* a
* performed transfer, all results from this function are undefined until the
* transfer is completed.
*/
CURL_EXTERN CURLcode curl_easy_getinfo(CURL *curl, CURLINFO info, ...);
/*
* NAME curl_easy_duphandle()
*
* DESCRIPTION
*
* Creates a new curl session handle with the same options set for the handle
* passed in. Duplicating a handle could only be a matter of cloning data and
* options, internal state info and things like persistent connections cannot
* be transferred. It is useful in multithreaded applications when you can run
* curl_easy_duphandle() for each new thread to avoid a series of identical
* curl_easy_setopt() invokes in every thread.
*/
CURL_EXTERN CURL *curl_easy_duphandle(CURL *curl);
/*
* NAME curl_easy_reset()
*
* DESCRIPTION
*
* Re-initializes a CURL handle to the default values. This puts back the
* handle to the same state as it was in when it was just created.
*
* It does keep: live connections, the Session ID cache, the DNS cache and the
* cookies.
*/
CURL_EXTERN void curl_easy_reset(CURL *curl);
/*
* NAME curl_easy_recv()
*
* DESCRIPTION
*
* Receives data from the connected socket. Use after successful
* curl_easy_perform() with CURLOPT_CONNECT_ONLY option.
*/
CURL_EXTERN CURLcode curl_easy_recv(CURL *curl, void *buffer, size_t buflen,
size_t *n);
/*
* NAME curl_easy_send()
*
* DESCRIPTION
*
* Sends data over the connected socket. Use after successful
* curl_easy_perform() with CURLOPT_CONNECT_ONLY option.
*/
CURL_EXTERN CURLcode curl_easy_send(CURL *curl, const void *buffer,
size_t buflen, size_t *n);
/*
* NAME curl_easy_upkeep()
*
* DESCRIPTION
*
* Performs connection upkeep for the given session handle.
*/
CURL_EXTERN CURLcode curl_easy_upkeep(CURL *curl);
#ifdef __cplusplus
}
#endif
#endif

View File

@ -0,0 +1,50 @@
#ifndef __CURL_MPRINTF_H
#define __CURL_MPRINTF_H
/***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
* are also available at https://curl.haxx.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
* furnished to do so, under the terms of the COPYING file.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
***************************************************************************/
#include <stdarg.h>
#include <stdio.h> /* needed for FILE */
#include "curl.h" /* for CURL_EXTERN */
#ifdef __cplusplus
extern "C" {
#endif
CURL_EXTERN int curl_mprintf(const char *format, ...);
CURL_EXTERN int curl_mfprintf(FILE *fd, const char *format, ...);
CURL_EXTERN int curl_msprintf(char *buffer, const char *format, ...);
CURL_EXTERN int curl_msnprintf(char *buffer, size_t maxlength,
const char *format, ...);
CURL_EXTERN int curl_mvprintf(const char *format, va_list args);
CURL_EXTERN int curl_mvfprintf(FILE *fd, const char *format, va_list args);
CURL_EXTERN int curl_mvsprintf(char *buffer, const char *format, va_list args);
CURL_EXTERN int curl_mvsnprintf(char *buffer, size_t maxlength,
const char *format, va_list args);
CURL_EXTERN char *curl_maprintf(const char *format, ...);
CURL_EXTERN char *curl_mvaprintf(const char *format, va_list args);
#ifdef __cplusplus
}
#endif
#endif /* __CURL_MPRINTF_H */

View File

@ -0,0 +1,441 @@
#ifndef __CURL_MULTI_H
#define __CURL_MULTI_H
/***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
* are also available at https://curl.haxx.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
* furnished to do so, under the terms of the COPYING file.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
***************************************************************************/
/*
This is an "external" header file. Don't give away any internals here!
GOALS
o Enable a "pull" interface. The application that uses libcurl decides where
and when to ask libcurl to get/send data.
o Enable multiple simultaneous transfers in the same thread without making it
complicated for the application.
o Enable the application to select() on its own file descriptors and curl's
file descriptors simultaneous easily.
*/
/*
* This header file should not really need to include "curl.h" since curl.h
* itself includes this file and we expect user applications to do #include
* <curl/curl.h> without the need for especially including multi.h.
*
* For some reason we added this include here at one point, and rather than to
* break existing (wrongly written) libcurl applications, we leave it as-is
* but with this warning attached.
*/
#include "curl.h"
#ifdef __cplusplus
extern "C" {
#endif
#if defined(BUILDING_LIBCURL) || defined(CURL_STRICTER)
typedef struct Curl_multi CURLM;
#else
typedef void CURLM;
#endif
typedef enum {
CURLM_CALL_MULTI_PERFORM = -1, /* please call curl_multi_perform() or
curl_multi_socket*() soon */
CURLM_OK,
CURLM_BAD_HANDLE, /* the passed-in handle is not a valid CURLM handle */
CURLM_BAD_EASY_HANDLE, /* an easy handle was not good/valid */
CURLM_OUT_OF_MEMORY, /* if you ever get this, you're in deep sh*t */
CURLM_INTERNAL_ERROR, /* this is a libcurl bug */
CURLM_BAD_SOCKET, /* the passed in socket argument did not match */
CURLM_UNKNOWN_OPTION, /* curl_multi_setopt() with unsupported option */
CURLM_ADDED_ALREADY, /* an easy handle already added to a multi handle was
attempted to get added - again */
CURLM_RECURSIVE_API_CALL, /* an api function was called from inside a
callback */
CURLM_LAST
} CURLMcode;
/* just to make code nicer when using curl_multi_socket() you can now check
for CURLM_CALL_MULTI_SOCKET too in the same style it works for
curl_multi_perform() and CURLM_CALL_MULTI_PERFORM */
#define CURLM_CALL_MULTI_SOCKET CURLM_CALL_MULTI_PERFORM
/* bitmask bits for CURLMOPT_PIPELINING */
#define CURLPIPE_NOTHING 0L
#define CURLPIPE_HTTP1 1L
#define CURLPIPE_MULTIPLEX 2L
typedef enum {
CURLMSG_NONE, /* first, not used */
CURLMSG_DONE, /* This easy handle has completed. 'result' contains
the CURLcode of the transfer */
CURLMSG_LAST /* last, not used */
} CURLMSG;
struct CURLMsg {
CURLMSG msg; /* what this message means */
CURL *easy_handle; /* the handle it concerns */
union {
void *whatever; /* message-specific data */
CURLcode result; /* return code for transfer */
} data;
};
typedef struct CURLMsg CURLMsg;
/* Based on poll(2) structure and values.
* We don't use pollfd and POLL* constants explicitly
* to cover platforms without poll(). */
#define CURL_WAIT_POLLIN 0x0001
#define CURL_WAIT_POLLPRI 0x0002
#define CURL_WAIT_POLLOUT 0x0004
struct curl_waitfd {
curl_socket_t fd;
short events;
short revents; /* not supported yet */
};
/*
* Name: curl_multi_init()
*
* Desc: inititalize multi-style curl usage
*
* Returns: a new CURLM handle to use in all 'curl_multi' functions.
*/
CURL_EXTERN CURLM *curl_multi_init(void);
/*
* Name: curl_multi_add_handle()
*
* Desc: add a standard curl handle to the multi stack
*
* Returns: CURLMcode type, general multi error code.
*/
CURL_EXTERN CURLMcode curl_multi_add_handle(CURLM *multi_handle,
CURL *curl_handle);
/*
* Name: curl_multi_remove_handle()
*
* Desc: removes a curl handle from the multi stack again
*
* Returns: CURLMcode type, general multi error code.
*/
CURL_EXTERN CURLMcode curl_multi_remove_handle(CURLM *multi_handle,
CURL *curl_handle);
/*
* Name: curl_multi_fdset()
*
* Desc: Ask curl for its fd_set sets. The app can use these to select() or
* poll() on. We want curl_multi_perform() called as soon as one of
* them are ready.
*
* Returns: CURLMcode type, general multi error code.
*/
CURL_EXTERN CURLMcode curl_multi_fdset(CURLM *multi_handle,
fd_set *read_fd_set,
fd_set *write_fd_set,
fd_set *exc_fd_set,
int *max_fd);
/*
* Name: curl_multi_wait()
*
* Desc: Poll on all fds within a CURLM set as well as any
* additional fds passed to the function.
*
* Returns: CURLMcode type, general multi error code.
*/
CURL_EXTERN CURLMcode curl_multi_wait(CURLM *multi_handle,
struct curl_waitfd extra_fds[],
unsigned int extra_nfds,
int timeout_ms,
int *ret);
/*
* Name: curl_multi_perform()
*
* Desc: When the app thinks there's data available for curl it calls this
* function to read/write whatever there is right now. This returns
* as soon as the reads and writes are done. This function does not
* require that there actually is data available for reading or that
* data can be written, it can be called just in case. It returns
* the number of handles that still transfer data in the second
* argument's integer-pointer.
*
* Returns: CURLMcode type, general multi error code. *NOTE* that this only
* returns errors etc regarding the whole multi stack. There might
* still have occurred problems on individual transfers even when
* this returns OK.
*/
CURL_EXTERN CURLMcode curl_multi_perform(CURLM *multi_handle,
int *running_handles);
/*
* Name: curl_multi_cleanup()
*
* Desc: Cleans up and removes a whole multi stack. It does not free or
* touch any individual easy handles in any way. We need to define
* in what state those handles will be if this function is called
* in the middle of a transfer.
*
* Returns: CURLMcode type, general multi error code.
*/
CURL_EXTERN CURLMcode curl_multi_cleanup(CURLM *multi_handle);
/*
* Name: curl_multi_info_read()
*
* Desc: Ask the multi handle if there's any messages/informationals from
* the individual transfers. Messages include informationals such as
* error code from the transfer or just the fact that a transfer is
* completed. More details on these should be written down as well.
*
* Repeated calls to this function will return a new struct each
* time, until a special "end of msgs" struct is returned as a signal
* that there is no more to get at this point.
*
* The data the returned pointer points to will not survive calling
* curl_multi_cleanup().
*
* The 'CURLMsg' struct is meant to be very simple and only contain
* very basic information. If more involved information is wanted,
* we will provide the particular "transfer handle" in that struct
* and that should/could/would be used in subsequent
* curl_easy_getinfo() calls (or similar). The point being that we
* must never expose complex structs to applications, as then we'll
* undoubtably get backwards compatibility problems in the future.
*
* Returns: A pointer to a filled-in struct, or NULL if it failed or ran out
* of structs. It also writes the number of messages left in the
* queue (after this read) in the integer the second argument points
* to.
*/
CURL_EXTERN CURLMsg *curl_multi_info_read(CURLM *multi_handle,
int *msgs_in_queue);
/*
* Name: curl_multi_strerror()
*
* Desc: The curl_multi_strerror function may be used to turn a CURLMcode
* value into the equivalent human readable error string. This is
* useful for printing meaningful error messages.
*
* Returns: A pointer to a zero-terminated error message.
*/
CURL_EXTERN const char *curl_multi_strerror(CURLMcode);
/*
* Name: curl_multi_socket() and
* curl_multi_socket_all()
*
* Desc: An alternative version of curl_multi_perform() that allows the
* application to pass in one of the file descriptors that have been
* detected to have "action" on them and let libcurl perform.
* See man page for details.
*/
#define CURL_POLL_NONE 0
#define CURL_POLL_IN 1
#define CURL_POLL_OUT 2
#define CURL_POLL_INOUT 3
#define CURL_POLL_REMOVE 4
#define CURL_SOCKET_TIMEOUT CURL_SOCKET_BAD
#define CURL_CSELECT_IN 0x01
#define CURL_CSELECT_OUT 0x02
#define CURL_CSELECT_ERR 0x04
typedef int (*curl_socket_callback)(CURL *easy, /* easy handle */
curl_socket_t s, /* socket */
int what, /* see above */
void *userp, /* private callback
pointer */
void *socketp); /* private socket
pointer */
/*
* Name: curl_multi_timer_callback
*
* Desc: Called by libcurl whenever the library detects a change in the
* maximum number of milliseconds the app is allowed to wait before
* curl_multi_socket() or curl_multi_perform() must be called
* (to allow libcurl's timed events to take place).
*
* Returns: The callback should return zero.
*/
typedef int (*curl_multi_timer_callback)(CURLM *multi, /* multi handle */
long timeout_ms, /* see above */
void *userp); /* private callback
pointer */
CURL_EXTERN CURLMcode curl_multi_socket(CURLM *multi_handle, curl_socket_t s,
int *running_handles);
CURL_EXTERN CURLMcode curl_multi_socket_action(CURLM *multi_handle,
curl_socket_t s,
int ev_bitmask,
int *running_handles);
CURL_EXTERN CURLMcode curl_multi_socket_all(CURLM *multi_handle,
int *running_handles);
#ifndef CURL_ALLOW_OLD_MULTI_SOCKET
/* This macro below was added in 7.16.3 to push users who recompile to use
the new curl_multi_socket_action() instead of the old curl_multi_socket()
*/
#define curl_multi_socket(x,y,z) curl_multi_socket_action(x,y,0,z)
#endif
/*
* Name: curl_multi_timeout()
*
* Desc: Returns the maximum number of milliseconds the app is allowed to
* wait before curl_multi_socket() or curl_multi_perform() must be
* called (to allow libcurl's timed events to take place).
*
* Returns: CURLM error code.
*/
CURL_EXTERN CURLMcode curl_multi_timeout(CURLM *multi_handle,
long *milliseconds);
#undef CINIT /* re-using the same name as in curl.h */
#ifdef CURL_ISOCPP
#define CINIT(name,type,num) CURLMOPT_ ## name = CURLOPTTYPE_ ## type + num
#else
/* The macro "##" is ISO C, we assume pre-ISO C doesn't support it. */
#define LONG CURLOPTTYPE_LONG
#define OBJECTPOINT CURLOPTTYPE_OBJECTPOINT
#define FUNCTIONPOINT CURLOPTTYPE_FUNCTIONPOINT
#define OFF_T CURLOPTTYPE_OFF_T
#define CINIT(name,type,number) CURLMOPT_/**/name = type + number
#endif
typedef enum {
/* This is the socket callback function pointer */
CINIT(SOCKETFUNCTION, FUNCTIONPOINT, 1),
/* This is the argument passed to the socket callback */
CINIT(SOCKETDATA, OBJECTPOINT, 2),
/* set to 1 to enable pipelining for this multi handle */
CINIT(PIPELINING, LONG, 3),
/* This is the timer callback function pointer */
CINIT(TIMERFUNCTION, FUNCTIONPOINT, 4),
/* This is the argument passed to the timer callback */
CINIT(TIMERDATA, OBJECTPOINT, 5),
/* maximum number of entries in the connection cache */
CINIT(MAXCONNECTS, LONG, 6),
/* maximum number of (pipelining) connections to one host */
CINIT(MAX_HOST_CONNECTIONS, LONG, 7),
/* maximum number of requests in a pipeline */
CINIT(MAX_PIPELINE_LENGTH, LONG, 8),
/* a connection with a content-length longer than this
will not be considered for pipelining */
CINIT(CONTENT_LENGTH_PENALTY_SIZE, OFF_T, 9),
/* a connection with a chunk length longer than this
will not be considered for pipelining */
CINIT(CHUNK_LENGTH_PENALTY_SIZE, OFF_T, 10),
/* a list of site names(+port) that are blacklisted from
pipelining */
CINIT(PIPELINING_SITE_BL, OBJECTPOINT, 11),
/* a list of server types that are blacklisted from
pipelining */
CINIT(PIPELINING_SERVER_BL, OBJECTPOINT, 12),
/* maximum number of open connections in total */
CINIT(MAX_TOTAL_CONNECTIONS, LONG, 13),
/* This is the server push callback function pointer */
CINIT(PUSHFUNCTION, FUNCTIONPOINT, 14),
/* This is the argument passed to the server push callback */
CINIT(PUSHDATA, OBJECTPOINT, 15),
CURLMOPT_LASTENTRY /* the last unused */
} CURLMoption;
/*
* Name: curl_multi_setopt()
*
* Desc: Sets options for the multi handle.
*
* Returns: CURLM error code.
*/
CURL_EXTERN CURLMcode curl_multi_setopt(CURLM *multi_handle,
CURLMoption option, ...);
/*
* Name: curl_multi_assign()
*
* Desc: This function sets an association in the multi handle between the
* given socket and a private pointer of the application. This is
* (only) useful for curl_multi_socket uses.
*
* Returns: CURLM error code.
*/
CURL_EXTERN CURLMcode curl_multi_assign(CURLM *multi_handle,
curl_socket_t sockfd, void *sockp);
/*
* Name: curl_push_callback
*
* Desc: This callback gets called when a new stream is being pushed by the
* server. It approves or denies the new stream.
*
* Returns: CURL_PUSH_OK or CURL_PUSH_DENY.
*/
#define CURL_PUSH_OK 0
#define CURL_PUSH_DENY 1
struct curl_pushheaders; /* forward declaration only */
CURL_EXTERN char *curl_pushheader_bynum(struct curl_pushheaders *h,
size_t num);
CURL_EXTERN char *curl_pushheader_byname(struct curl_pushheaders *h,
const char *name);
typedef int (*curl_push_callback)(CURL *parent,
CURL *easy,
size_t num_headers,
struct curl_pushheaders *headers,
void *userp);
#ifdef __cplusplus
} /* end of extern "C" */
#endif
#endif

View File

@ -0,0 +1,33 @@
#ifndef __STDC_HEADERS_H
#define __STDC_HEADERS_H
/***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
* are also available at https://curl.haxx.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
* furnished to do so, under the terms of the COPYING file.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
***************************************************************************/
#include <sys/types.h>
size_t fread(void *, size_t, size_t, FILE *);
size_t fwrite(const void *, size_t, size_t, FILE *);
int strcasecmp(const char *, const char *);
int strncasecmp(const char *, const char *, size_t);
#endif /* __STDC_HEADERS_H */

View File

@ -0,0 +1,493 @@
#ifndef __CURL_SYSTEM_H
#define __CURL_SYSTEM_H
/***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
* are also available at https://curl.haxx.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
* furnished to do so, under the terms of the COPYING file.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
***************************************************************************/
/*
* Try to keep one section per platform, compiler and architecture, otherwise,
* if an existing section is reused for a different one and later on the
* original is adjusted, probably the piggybacking one can be adversely
* changed.
*
* In order to differentiate between platforms/compilers/architectures use
* only compiler built in predefined preprocessor symbols.
*
* curl_off_t
* ----------
*
* For any given platform/compiler curl_off_t must be typedef'ed to a 64-bit
* wide signed integral data type. The width of this data type must remain
* constant and independent of any possible large file support settings.
*
* As an exception to the above, curl_off_t shall be typedef'ed to a 32-bit
* wide signed integral data type if there is no 64-bit type.
*
* As a general rule, curl_off_t shall not be mapped to off_t. This rule shall
* only be violated if off_t is the only 64-bit data type available and the
* size of off_t is independent of large file support settings. Keep your
* build on the safe side avoiding an off_t gating. If you have a 64-bit
* off_t then take for sure that another 64-bit data type exists, dig deeper
* and you will find it.
*
*/
#if defined(__DJGPP__) || defined(__GO32__)
# if defined(__DJGPP__) && (__DJGPP__ > 1)
# define CURL_TYPEOF_CURL_OFF_T long long
# define CURL_FORMAT_CURL_OFF_T "lld"
# define CURL_FORMAT_CURL_OFF_TU "llu"
# define CURL_SUFFIX_CURL_OFF_T LL
# define CURL_SUFFIX_CURL_OFF_TU ULL
# else
# define CURL_TYPEOF_CURL_OFF_T long
# define CURL_FORMAT_CURL_OFF_T "ld"
# define CURL_FORMAT_CURL_OFF_TU "lu"
# define CURL_SUFFIX_CURL_OFF_T L
# define CURL_SUFFIX_CURL_OFF_TU UL
# endif
# define CURL_TYPEOF_CURL_SOCKLEN_T int
#elif defined(__SALFORDC__)
# define CURL_TYPEOF_CURL_OFF_T long
# define CURL_FORMAT_CURL_OFF_T "ld"
# define CURL_FORMAT_CURL_OFF_TU "lu"
# define CURL_SUFFIX_CURL_OFF_T L
# define CURL_SUFFIX_CURL_OFF_TU UL
# define CURL_TYPEOF_CURL_SOCKLEN_T int
#elif defined(__BORLANDC__)
# if (__BORLANDC__ < 0x520)
# define CURL_TYPEOF_CURL_OFF_T long
# define CURL_FORMAT_CURL_OFF_T "ld"
# define CURL_FORMAT_CURL_OFF_TU "lu"
# define CURL_SUFFIX_CURL_OFF_T L
# define CURL_SUFFIX_CURL_OFF_TU UL
# else
# define CURL_TYPEOF_CURL_OFF_T __int64
# define CURL_FORMAT_CURL_OFF_T "I64d"
# define CURL_FORMAT_CURL_OFF_TU "I64u"
# define CURL_SUFFIX_CURL_OFF_T i64
# define CURL_SUFFIX_CURL_OFF_TU ui64
# endif
# define CURL_TYPEOF_CURL_SOCKLEN_T int
#elif defined(__TURBOC__)
# define CURL_TYPEOF_CURL_OFF_T long
# define CURL_FORMAT_CURL_OFF_T "ld"
# define CURL_FORMAT_CURL_OFF_TU "lu"
# define CURL_SUFFIX_CURL_OFF_T L
# define CURL_SUFFIX_CURL_OFF_TU UL
# define CURL_TYPEOF_CURL_SOCKLEN_T int
#elif defined(__WATCOMC__)
# if defined(__386__)
# define CURL_TYPEOF_CURL_OFF_T __int64
# define CURL_FORMAT_CURL_OFF_T "I64d"
# define CURL_FORMAT_CURL_OFF_TU "I64u"
# define CURL_SUFFIX_CURL_OFF_T i64
# define CURL_SUFFIX_CURL_OFF_TU ui64
# else
# define CURL_TYPEOF_CURL_OFF_T long
# define CURL_FORMAT_CURL_OFF_T "ld"
# define CURL_FORMAT_CURL_OFF_TU "lu"
# define CURL_SUFFIX_CURL_OFF_T L
# define CURL_SUFFIX_CURL_OFF_TU UL
# endif
# define CURL_TYPEOF_CURL_SOCKLEN_T int
#elif defined(__POCC__)
# if (__POCC__ < 280)
# define CURL_TYPEOF_CURL_OFF_T long
# define CURL_FORMAT_CURL_OFF_T "ld"
# define CURL_FORMAT_CURL_OFF_TU "lu"
# define CURL_SUFFIX_CURL_OFF_T L
# define CURL_SUFFIX_CURL_OFF_TU UL
# elif defined(_MSC_VER)
# define CURL_TYPEOF_CURL_OFF_T __int64
# define CURL_FORMAT_CURL_OFF_T "I64d"
# define CURL_FORMAT_CURL_OFF_TU "I64u"
# define CURL_SUFFIX_CURL_OFF_T i64
# define CURL_SUFFIX_CURL_OFF_TU ui64
# else
# define CURL_TYPEOF_CURL_OFF_T long long
# define CURL_FORMAT_CURL_OFF_T "lld"
# define CURL_FORMAT_CURL_OFF_TU "llu"
# define CURL_SUFFIX_CURL_OFF_T LL
# define CURL_SUFFIX_CURL_OFF_TU ULL
# endif
# define CURL_TYPEOF_CURL_SOCKLEN_T int
#elif defined(__LCC__)
# define CURL_TYPEOF_CURL_OFF_T long
# define CURL_FORMAT_CURL_OFF_T "ld"
# define CURL_FORMAT_CURL_OFF_TU "lu"
# define CURL_SUFFIX_CURL_OFF_T L
# define CURL_SUFFIX_CURL_OFF_TU UL
# define CURL_TYPEOF_CURL_SOCKLEN_T int
#elif defined(__SYMBIAN32__)
# if defined(__EABI__) /* Treat all ARM compilers equally */
# define CURL_TYPEOF_CURL_OFF_T long long
# define CURL_FORMAT_CURL_OFF_T "lld"
# define CURL_FORMAT_CURL_OFF_TU "llu"
# define CURL_SUFFIX_CURL_OFF_T LL
# define CURL_SUFFIX_CURL_OFF_TU ULL
# elif defined(__CW32__)
# pragma longlong on
# define CURL_TYPEOF_CURL_OFF_T long long
# define CURL_FORMAT_CURL_OFF_T "lld"
# define CURL_FORMAT_CURL_OFF_TU "llu"
# define CURL_SUFFIX_CURL_OFF_T LL
# define CURL_SUFFIX_CURL_OFF_TU ULL
# elif defined(__VC32__)
# define CURL_TYPEOF_CURL_OFF_T __int64
# define CURL_FORMAT_CURL_OFF_T "lld"
# define CURL_FORMAT_CURL_OFF_TU "llu"
# define CURL_SUFFIX_CURL_OFF_T LL
# define CURL_SUFFIX_CURL_OFF_TU ULL
# endif
# define CURL_TYPEOF_CURL_SOCKLEN_T unsigned int
#elif defined(__MWERKS__)
# define CURL_TYPEOF_CURL_OFF_T long long
# define CURL_FORMAT_CURL_OFF_T "lld"
# define CURL_FORMAT_CURL_OFF_TU "llu"
# define CURL_SUFFIX_CURL_OFF_T LL
# define CURL_SUFFIX_CURL_OFF_TU ULL
# define CURL_TYPEOF_CURL_SOCKLEN_T int
#elif defined(_WIN32_WCE)
# define CURL_TYPEOF_CURL_OFF_T __int64
# define CURL_FORMAT_CURL_OFF_T "I64d"
# define CURL_FORMAT_CURL_OFF_TU "I64u"
# define CURL_SUFFIX_CURL_OFF_T i64
# define CURL_SUFFIX_CURL_OFF_TU ui64
# define CURL_TYPEOF_CURL_SOCKLEN_T int
#elif defined(__MINGW32__)
# define CURL_TYPEOF_CURL_OFF_T long long
# define CURL_FORMAT_CURL_OFF_T "I64d"
# define CURL_FORMAT_CURL_OFF_TU "I64u"
# define CURL_SUFFIX_CURL_OFF_T LL
# define CURL_SUFFIX_CURL_OFF_TU ULL
# define CURL_TYPEOF_CURL_SOCKLEN_T socklen_t
# define CURL_PULL_SYS_TYPES_H 1
# define CURL_PULL_WS2TCPIP_H 1
#elif defined(__VMS)
# if defined(__VAX)
# define CURL_TYPEOF_CURL_OFF_T long
# define CURL_FORMAT_CURL_OFF_T "ld"
# define CURL_FORMAT_CURL_OFF_TU "lu"
# define CURL_SUFFIX_CURL_OFF_T L
# define CURL_SUFFIX_CURL_OFF_TU UL
# else
# define CURL_TYPEOF_CURL_OFF_T long long
# define CURL_FORMAT_CURL_OFF_T "lld"
# define CURL_FORMAT_CURL_OFF_TU "llu"
# define CURL_SUFFIX_CURL_OFF_T LL
# define CURL_SUFFIX_CURL_OFF_TU ULL
# endif
# define CURL_TYPEOF_CURL_SOCKLEN_T unsigned int
#elif defined(__OS400__)
# if defined(__ILEC400__)
# define CURL_TYPEOF_CURL_OFF_T long long
# define CURL_FORMAT_CURL_OFF_T "lld"
# define CURL_FORMAT_CURL_OFF_TU "llu"
# define CURL_SUFFIX_CURL_OFF_T LL
# define CURL_SUFFIX_CURL_OFF_TU ULL
# define CURL_TYPEOF_CURL_SOCKLEN_T socklen_t
# define CURL_PULL_SYS_TYPES_H 1
# define CURL_PULL_SYS_SOCKET_H 1
# endif
#elif defined(__MVS__)
# if defined(__IBMC__) || defined(__IBMCPP__)
# if defined(_ILP32)
# elif defined(_LP64)
# endif
# if defined(_LONG_LONG)
# define CURL_TYPEOF_CURL_OFF_T long long
# define CURL_FORMAT_CURL_OFF_T "lld"
# define CURL_FORMAT_CURL_OFF_TU "llu"
# define CURL_SUFFIX_CURL_OFF_T LL
# define CURL_SUFFIX_CURL_OFF_TU ULL
# elif defined(_LP64)
# define CURL_TYPEOF_CURL_OFF_T long
# define CURL_FORMAT_CURL_OFF_T "ld"
# define CURL_FORMAT_CURL_OFF_TU "lu"
# define CURL_SUFFIX_CURL_OFF_T L
# define CURL_SUFFIX_CURL_OFF_TU UL
# else
# define CURL_TYPEOF_CURL_OFF_T long
# define CURL_FORMAT_CURL_OFF_T "ld"
# define CURL_FORMAT_CURL_OFF_TU "lu"
# define CURL_SUFFIX_CURL_OFF_T L
# define CURL_SUFFIX_CURL_OFF_TU UL
# endif
# define CURL_TYPEOF_CURL_SOCKLEN_T socklen_t
# define CURL_PULL_SYS_TYPES_H 1
# define CURL_PULL_SYS_SOCKET_H 1
# endif
#elif defined(__370__)
# if defined(__IBMC__) || defined(__IBMCPP__)
# if defined(_ILP32)
# elif defined(_LP64)
# endif
# if defined(_LONG_LONG)
# define CURL_TYPEOF_CURL_OFF_T long long
# define CURL_FORMAT_CURL_OFF_T "lld"
# define CURL_FORMAT_CURL_OFF_TU "llu"
# define CURL_SUFFIX_CURL_OFF_T LL
# define CURL_SUFFIX_CURL_OFF_TU ULL
# elif defined(_LP64)
# define CURL_TYPEOF_CURL_OFF_T long
# define CURL_FORMAT_CURL_OFF_T "ld"
# define CURL_FORMAT_CURL_OFF_TU "lu"
# define CURL_SUFFIX_CURL_OFF_T L
# define CURL_SUFFIX_CURL_OFF_TU UL
# else
# define CURL_TYPEOF_CURL_OFF_T long
# define CURL_FORMAT_CURL_OFF_T "ld"
# define CURL_FORMAT_CURL_OFF_TU "lu"
# define CURL_SUFFIX_CURL_OFF_T L
# define CURL_SUFFIX_CURL_OFF_TU UL
# endif
# define CURL_TYPEOF_CURL_SOCKLEN_T socklen_t
# define CURL_PULL_SYS_TYPES_H 1
# define CURL_PULL_SYS_SOCKET_H 1
# endif
#elif defined(TPF)
# define CURL_TYPEOF_CURL_OFF_T long
# define CURL_FORMAT_CURL_OFF_T "ld"
# define CURL_FORMAT_CURL_OFF_TU "lu"
# define CURL_SUFFIX_CURL_OFF_T L
# define CURL_SUFFIX_CURL_OFF_TU UL
# define CURL_TYPEOF_CURL_SOCKLEN_T int
#elif defined(__TINYC__) /* also known as tcc */
# define CURL_TYPEOF_CURL_OFF_T long long
# define CURL_FORMAT_CURL_OFF_T "lld"
# define CURL_FORMAT_CURL_OFF_TU "llu"
# define CURL_SUFFIX_CURL_OFF_T LL
# define CURL_SUFFIX_CURL_OFF_TU ULL
# define CURL_TYPEOF_CURL_SOCKLEN_T socklen_t
# define CURL_PULL_SYS_TYPES_H 1
# define CURL_PULL_SYS_SOCKET_H 1
#elif defined(__SUNPRO_C) || defined(__SUNPRO_CC) /* Oracle Solaris Studio */
# if !defined(__LP64) && (defined(__ILP32) || \
defined(__i386) || \
defined(__sparcv8) || \
defined(__sparcv8plus))
# define CURL_TYPEOF_CURL_OFF_T long long
# define CURL_FORMAT_CURL_OFF_T "lld"
# define CURL_FORMAT_CURL_OFF_TU "llu"
# define CURL_SUFFIX_CURL_OFF_T LL
# define CURL_SUFFIX_CURL_OFF_TU ULL
# elif defined(__LP64) || \
defined(__amd64) || defined(__sparcv9)
# define CURL_TYPEOF_CURL_OFF_T long
# define CURL_FORMAT_CURL_OFF_T "ld"
# define CURL_FORMAT_CURL_OFF_TU "lu"
# define CURL_SUFFIX_CURL_OFF_T L
# define CURL_SUFFIX_CURL_OFF_TU UL
# endif
# define CURL_TYPEOF_CURL_SOCKLEN_T socklen_t
# define CURL_PULL_SYS_TYPES_H 1
# define CURL_PULL_SYS_SOCKET_H 1
#elif defined(__xlc__) /* IBM xlc compiler */
# if !defined(_LP64)
# define CURL_TYPEOF_CURL_OFF_T long long
# define CURL_FORMAT_CURL_OFF_T "lld"
# define CURL_FORMAT_CURL_OFF_TU "llu"
# define CURL_SUFFIX_CURL_OFF_T LL
# define CURL_SUFFIX_CURL_OFF_TU ULL
# else
# define CURL_TYPEOF_CURL_OFF_T long
# define CURL_FORMAT_CURL_OFF_T "ld"
# define CURL_FORMAT_CURL_OFF_TU "lu"
# define CURL_SUFFIX_CURL_OFF_T L
# define CURL_SUFFIX_CURL_OFF_TU UL
# endif
# define CURL_TYPEOF_CURL_SOCKLEN_T socklen_t
# define CURL_PULL_SYS_TYPES_H 1
# define CURL_PULL_SYS_SOCKET_H 1
/* ===================================== */
/* KEEP MSVC THE PENULTIMATE ENTRY */
/* ===================================== */
#elif defined(_MSC_VER)
# if (_MSC_VER >= 900) && (_INTEGRAL_MAX_BITS >= 64)
# define CURL_TYPEOF_CURL_OFF_T __int64
# define CURL_FORMAT_CURL_OFF_T "I64d"
# define CURL_FORMAT_CURL_OFF_TU "I64u"
# define CURL_SUFFIX_CURL_OFF_T i64
# define CURL_SUFFIX_CURL_OFF_TU ui64
# else
# define CURL_TYPEOF_CURL_OFF_T long
# define CURL_FORMAT_CURL_OFF_T "ld"
# define CURL_FORMAT_CURL_OFF_TU "lu"
# define CURL_SUFFIX_CURL_OFF_T L
# define CURL_SUFFIX_CURL_OFF_TU UL
# endif
# define CURL_TYPEOF_CURL_SOCKLEN_T int
/* ===================================== */
/* KEEP GENERIC GCC THE LAST ENTRY */
/* ===================================== */
#elif defined(__GNUC__) && !defined(_SCO_DS)
# if !defined(__LP64__) && \
(defined(__ILP32__) || defined(__i386__) || defined(__hppa__) || \
defined(__ppc__) || defined(__powerpc__) || defined(__arm__) || \
defined(__sparc__) || defined(__mips__) || defined(__sh__) || \
defined(__XTENSA__) || \
(defined(__SIZEOF_LONG__) && __SIZEOF_LONG__ == 4) || \
(defined(__LONG_MAX__) && __LONG_MAX__ == 2147483647L))
# define CURL_TYPEOF_CURL_OFF_T long long
# define CURL_FORMAT_CURL_OFF_T "lld"
# define CURL_FORMAT_CURL_OFF_TU "llu"
# define CURL_SUFFIX_CURL_OFF_T LL
# define CURL_SUFFIX_CURL_OFF_TU ULL
# elif defined(__LP64__) || \
defined(__x86_64__) || defined(__ppc64__) || defined(__sparc64__) || \
(defined(__SIZEOF_LONG__) && __SIZEOF_LONG__ == 8) || \
(defined(__LONG_MAX__) && __LONG_MAX__ == 9223372036854775807L)
# define CURL_TYPEOF_CURL_OFF_T long
# define CURL_FORMAT_CURL_OFF_T "ld"
# define CURL_FORMAT_CURL_OFF_TU "lu"
# define CURL_SUFFIX_CURL_OFF_T L
# define CURL_SUFFIX_CURL_OFF_TU UL
# endif
# define CURL_TYPEOF_CURL_SOCKLEN_T socklen_t
# define CURL_PULL_SYS_TYPES_H 1
# define CURL_PULL_SYS_SOCKET_H 1
#else
/* generic "safe guess" on old 32 bit style */
# define CURL_TYPEOF_CURL_OFF_T long
# define CURL_FORMAT_CURL_OFF_T "ld"
# define CURL_FORMAT_CURL_OFF_TU "lu"
# define CURL_SUFFIX_CURL_OFF_T L
# define CURL_SUFFIX_CURL_OFF_TU UL
# define CURL_TYPEOF_CURL_SOCKLEN_T int
#endif
#ifdef _AIX
/* AIX needs <sys/poll.h> */
#define CURL_PULL_SYS_POLL_H
#endif
/* CURL_PULL_WS2TCPIP_H is defined above when inclusion of header file */
/* ws2tcpip.h is required here to properly make type definitions below. */
#ifdef CURL_PULL_WS2TCPIP_H
# include <winsock2.h>
# include <windows.h>
# include <ws2tcpip.h>
#endif
/* CURL_PULL_SYS_TYPES_H is defined above when inclusion of header file */
/* sys/types.h is required here to properly make type definitions below. */
#ifdef CURL_PULL_SYS_TYPES_H
# include <sys/types.h>
#endif
/* CURL_PULL_SYS_SOCKET_H is defined above when inclusion of header file */
/* sys/socket.h is required here to properly make type definitions below. */
#ifdef CURL_PULL_SYS_SOCKET_H
# include <sys/socket.h>
#endif
/* CURL_PULL_SYS_POLL_H is defined above when inclusion of header file */
/* sys/poll.h is required here to properly make type definitions below. */
#ifdef CURL_PULL_SYS_POLL_H
# include <sys/poll.h>
#endif
/* Data type definition of curl_socklen_t. */
#ifdef CURL_TYPEOF_CURL_SOCKLEN_T
typedef CURL_TYPEOF_CURL_SOCKLEN_T curl_socklen_t;
#endif
/* Data type definition of curl_off_t. */
#ifdef CURL_TYPEOF_CURL_OFF_T
typedef CURL_TYPEOF_CURL_OFF_T curl_off_t;
#endif
/*
* CURL_ISOCPP and CURL_OFF_T_C definitions are done here in order to allow
* these to be visible and exported by the external libcurl interface API,
* while also making them visible to the library internals, simply including
* curl_setup.h, without actually needing to include curl.h internally.
* If some day this section would grow big enough, all this should be moved
* to its own header file.
*/
/*
* Figure out if we can use the ## preprocessor operator, which is supported
* by ISO/ANSI C and C++. Some compilers support it without setting __STDC__
* or __cplusplus so we need to carefully check for them too.
*/
#if defined(__STDC__) || defined(_MSC_VER) || defined(__cplusplus) || \
defined(__HP_aCC) || defined(__BORLANDC__) || defined(__LCC__) || \
defined(__POCC__) || defined(__SALFORDC__) || defined(__HIGHC__) || \
defined(__ILEC400__)
/* This compiler is believed to have an ISO compatible preprocessor */
#define CURL_ISOCPP
#else
/* This compiler is believed NOT to have an ISO compatible preprocessor */
#undef CURL_ISOCPP
#endif
/*
* Macros for minimum-width signed and unsigned curl_off_t integer constants.
*/
#if defined(__BORLANDC__) && (__BORLANDC__ == 0x0551)
# define __CURL_OFF_T_C_HLPR2(x) x
# define __CURL_OFF_T_C_HLPR1(x) __CURL_OFF_T_C_HLPR2(x)
# define CURL_OFF_T_C(Val) __CURL_OFF_T_C_HLPR1(Val) ## \
__CURL_OFF_T_C_HLPR1(CURL_SUFFIX_CURL_OFF_T)
# define CURL_OFF_TU_C(Val) __CURL_OFF_T_C_HLPR1(Val) ## \
__CURL_OFF_T_C_HLPR1(CURL_SUFFIX_CURL_OFF_TU)
#else
# ifdef CURL_ISOCPP
# define __CURL_OFF_T_C_HLPR2(Val,Suffix) Val ## Suffix
# else
# define __CURL_OFF_T_C_HLPR2(Val,Suffix) Val/**/Suffix
# endif
# define __CURL_OFF_T_C_HLPR1(Val,Suffix) __CURL_OFF_T_C_HLPR2(Val,Suffix)
# define CURL_OFF_T_C(Val) __CURL_OFF_T_C_HLPR1(Val,CURL_SUFFIX_CURL_OFF_T)
# define CURL_OFF_TU_C(Val) __CURL_OFF_T_C_HLPR1(Val,CURL_SUFFIX_CURL_OFF_TU)
#endif
#endif /* __CURL_SYSTEM_H */

View File

@ -0,0 +1,699 @@
#ifndef __CURL_TYPECHECK_GCC_H
#define __CURL_TYPECHECK_GCC_H
/***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2018, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
* are also available at https://curl.haxx.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
* furnished to do so, under the terms of the COPYING file.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
***************************************************************************/
/* wraps curl_easy_setopt() with typechecking */
/* To add a new kind of warning, add an
* if(_curl_is_sometype_option(_curl_opt))
* if(!_curl_is_sometype(value))
* _curl_easy_setopt_err_sometype();
* block and define _curl_is_sometype_option, _curl_is_sometype and
* _curl_easy_setopt_err_sometype below
*
* NOTE: We use two nested 'if' statements here instead of the && operator, in
* order to work around gcc bug #32061. It affects only gcc 4.3.x/4.4.x
* when compiling with -Wlogical-op.
*
* To add an option that uses the same type as an existing option, you'll just
* need to extend the appropriate _curl_*_option macro
*/
#define curl_easy_setopt(handle, option, value) \
__extension__ ({ \
__typeof__(option) _curl_opt = option; \
if(__builtin_constant_p(_curl_opt)) { \
if(_curl_is_long_option(_curl_opt)) \
if(!_curl_is_long(value)) \
_curl_easy_setopt_err_long(); \
if(_curl_is_off_t_option(_curl_opt)) \
if(!_curl_is_off_t(value)) \
_curl_easy_setopt_err_curl_off_t(); \
if(_curl_is_string_option(_curl_opt)) \
if(!_curl_is_string(value)) \
_curl_easy_setopt_err_string(); \
if(_curl_is_write_cb_option(_curl_opt)) \
if(!_curl_is_write_cb(value)) \
_curl_easy_setopt_err_write_callback(); \
if((_curl_opt) == CURLOPT_RESOLVER_START_FUNCTION) \
if(!_curl_is_resolver_start_callback(value)) \
_curl_easy_setopt_err_resolver_start_callback(); \
if((_curl_opt) == CURLOPT_READFUNCTION) \
if(!_curl_is_read_cb(value)) \
_curl_easy_setopt_err_read_cb(); \
if((_curl_opt) == CURLOPT_IOCTLFUNCTION) \
if(!_curl_is_ioctl_cb(value)) \
_curl_easy_setopt_err_ioctl_cb(); \
if((_curl_opt) == CURLOPT_SOCKOPTFUNCTION) \
if(!_curl_is_sockopt_cb(value)) \
_curl_easy_setopt_err_sockopt_cb(); \
if((_curl_opt) == CURLOPT_OPENSOCKETFUNCTION) \
if(!_curl_is_opensocket_cb(value)) \
_curl_easy_setopt_err_opensocket_cb(); \
if((_curl_opt) == CURLOPT_PROGRESSFUNCTION) \
if(!_curl_is_progress_cb(value)) \
_curl_easy_setopt_err_progress_cb(); \
if((_curl_opt) == CURLOPT_DEBUGFUNCTION) \
if(!_curl_is_debug_cb(value)) \
_curl_easy_setopt_err_debug_cb(); \
if((_curl_opt) == CURLOPT_SSL_CTX_FUNCTION) \
if(!_curl_is_ssl_ctx_cb(value)) \
_curl_easy_setopt_err_ssl_ctx_cb(); \
if(_curl_is_conv_cb_option(_curl_opt)) \
if(!_curl_is_conv_cb(value)) \
_curl_easy_setopt_err_conv_cb(); \
if((_curl_opt) == CURLOPT_SEEKFUNCTION) \
if(!_curl_is_seek_cb(value)) \
_curl_easy_setopt_err_seek_cb(); \
if(_curl_is_cb_data_option(_curl_opt)) \
if(!_curl_is_cb_data(value)) \
_curl_easy_setopt_err_cb_data(); \
if((_curl_opt) == CURLOPT_ERRORBUFFER) \
if(!_curl_is_error_buffer(value)) \
_curl_easy_setopt_err_error_buffer(); \
if((_curl_opt) == CURLOPT_STDERR) \
if(!_curl_is_FILE(value)) \
_curl_easy_setopt_err_FILE(); \
if(_curl_is_postfields_option(_curl_opt)) \
if(!_curl_is_postfields(value)) \
_curl_easy_setopt_err_postfields(); \
if((_curl_opt) == CURLOPT_HTTPPOST) \
if(!_curl_is_arr((value), struct curl_httppost)) \
_curl_easy_setopt_err_curl_httpost(); \
if((_curl_opt) == CURLOPT_MIMEPOST) \
if(!_curl_is_ptr((value), curl_mime)) \
_curl_easy_setopt_err_curl_mimepost(); \
if(_curl_is_slist_option(_curl_opt)) \
if(!_curl_is_arr((value), struct curl_slist)) \
_curl_easy_setopt_err_curl_slist(); \
if((_curl_opt) == CURLOPT_SHARE) \
if(!_curl_is_ptr((value), CURLSH)) \
_curl_easy_setopt_err_CURLSH(); \
} \
curl_easy_setopt(handle, _curl_opt, value); \
})
/* wraps curl_easy_getinfo() with typechecking */
/* FIXME: don't allow const pointers */
#define curl_easy_getinfo(handle, info, arg) \
__extension__ ({ \
__typeof__(info) _curl_info = info; \
if(__builtin_constant_p(_curl_info)) { \
if(_curl_is_string_info(_curl_info)) \
if(!_curl_is_arr((arg), char *)) \
_curl_easy_getinfo_err_string(); \
if(_curl_is_long_info(_curl_info)) \
if(!_curl_is_arr((arg), long)) \
_curl_easy_getinfo_err_long(); \
if(_curl_is_double_info(_curl_info)) \
if(!_curl_is_arr((arg), double)) \
_curl_easy_getinfo_err_double(); \
if(_curl_is_slist_info(_curl_info)) \
if(!_curl_is_arr((arg), struct curl_slist *)) \
_curl_easy_getinfo_err_curl_slist(); \
if(_curl_is_tlssessioninfo_info(_curl_info)) \
if(!_curl_is_arr((arg), struct curl_tlssessioninfo *)) \
_curl_easy_getinfo_err_curl_tlssesssioninfo(); \
if(_curl_is_certinfo_info(_curl_info)) \
if(!_curl_is_arr((arg), struct curl_certinfo *)) \
_curl_easy_getinfo_err_curl_certinfo(); \
if(_curl_is_socket_info(_curl_info)) \
if(!_curl_is_arr((arg), curl_socket_t)) \
_curl_easy_getinfo_err_curl_socket(); \
if(_curl_is_off_t_info(_curl_info)) \
if(!_curl_is_arr((arg), curl_off_t)) \
_curl_easy_getinfo_err_curl_off_t(); \
} \
curl_easy_getinfo(handle, _curl_info, arg); \
})
/* TODO: typechecking for curl_share_setopt() and curl_multi_setopt(),
* for now just make sure that the functions are called with three
* arguments
*/
#define curl_share_setopt(share,opt,param) curl_share_setopt(share,opt,param)
#define curl_multi_setopt(handle,opt,param) curl_multi_setopt(handle,opt,param)
/* the actual warnings, triggered by calling the _curl_easy_setopt_err*
* functions */
/* To define a new warning, use _CURL_WARNING(identifier, "message") */
#define _CURL_WARNING(id, message) \
static void __attribute__((__warning__(message))) \
__attribute__((__unused__)) __attribute__((__noinline__)) \
id(void) { __asm__(""); }
_CURL_WARNING(_curl_easy_setopt_err_long,
"curl_easy_setopt expects a long argument for this option")
_CURL_WARNING(_curl_easy_setopt_err_curl_off_t,
"curl_easy_setopt expects a curl_off_t argument for this option")
_CURL_WARNING(_curl_easy_setopt_err_string,
"curl_easy_setopt expects a "
"string ('char *' or char[]) argument for this option"
)
_CURL_WARNING(_curl_easy_setopt_err_write_callback,
"curl_easy_setopt expects a curl_write_callback argument for this option")
_CURL_WARNING(_curl_easy_setopt_err_resolver_start_callback,
"curl_easy_setopt expects a "
"curl_resolver_start_callback argument for this option"
)
_CURL_WARNING(_curl_easy_setopt_err_read_cb,
"curl_easy_setopt expects a curl_read_callback argument for this option")
_CURL_WARNING(_curl_easy_setopt_err_ioctl_cb,
"curl_easy_setopt expects a curl_ioctl_callback argument for this option")
_CURL_WARNING(_curl_easy_setopt_err_sockopt_cb,
"curl_easy_setopt expects a curl_sockopt_callback argument for this option")
_CURL_WARNING(_curl_easy_setopt_err_opensocket_cb,
"curl_easy_setopt expects a "
"curl_opensocket_callback argument for this option"
)
_CURL_WARNING(_curl_easy_setopt_err_progress_cb,
"curl_easy_setopt expects a curl_progress_callback argument for this option")
_CURL_WARNING(_curl_easy_setopt_err_debug_cb,
"curl_easy_setopt expects a curl_debug_callback argument for this option")
_CURL_WARNING(_curl_easy_setopt_err_ssl_ctx_cb,
"curl_easy_setopt expects a curl_ssl_ctx_callback argument for this option")
_CURL_WARNING(_curl_easy_setopt_err_conv_cb,
"curl_easy_setopt expects a curl_conv_callback argument for this option")
_CURL_WARNING(_curl_easy_setopt_err_seek_cb,
"curl_easy_setopt expects a curl_seek_callback argument for this option")
_CURL_WARNING(_curl_easy_setopt_err_cb_data,
"curl_easy_setopt expects a "
"private data pointer as argument for this option")
_CURL_WARNING(_curl_easy_setopt_err_error_buffer,
"curl_easy_setopt expects a "
"char buffer of CURL_ERROR_SIZE as argument for this option")
_CURL_WARNING(_curl_easy_setopt_err_FILE,
"curl_easy_setopt expects a 'FILE *' argument for this option")
_CURL_WARNING(_curl_easy_setopt_err_postfields,
"curl_easy_setopt expects a 'void *' or 'char *' argument for this option")
_CURL_WARNING(_curl_easy_setopt_err_curl_httpost,
"curl_easy_setopt expects a 'struct curl_httppost *' "
"argument for this option")
_CURL_WARNING(_curl_easy_setopt_err_curl_mimepost,
"curl_easy_setopt expects a 'curl_mime *' "
"argument for this option")
_CURL_WARNING(_curl_easy_setopt_err_curl_slist,
"curl_easy_setopt expects a 'struct curl_slist *' argument for this option")
_CURL_WARNING(_curl_easy_setopt_err_CURLSH,
"curl_easy_setopt expects a CURLSH* argument for this option")
_CURL_WARNING(_curl_easy_getinfo_err_string,
"curl_easy_getinfo expects a pointer to 'char *' for this info")
_CURL_WARNING(_curl_easy_getinfo_err_long,
"curl_easy_getinfo expects a pointer to long for this info")
_CURL_WARNING(_curl_easy_getinfo_err_double,
"curl_easy_getinfo expects a pointer to double for this info")
_CURL_WARNING(_curl_easy_getinfo_err_curl_slist,
"curl_easy_getinfo expects a pointer to 'struct curl_slist *' for this info")
_CURL_WARNING(_curl_easy_getinfo_err_curl_tlssesssioninfo,
"curl_easy_getinfo expects a pointer to "
"'struct curl_tlssessioninfo *' for this info")
_CURL_WARNING(_curl_easy_getinfo_err_curl_certinfo,
"curl_easy_getinfo expects a pointer to "
"'struct curl_certinfo *' for this info")
_CURL_WARNING(_curl_easy_getinfo_err_curl_socket,
"curl_easy_getinfo expects a pointer to curl_socket_t for this info")
_CURL_WARNING(_curl_easy_getinfo_err_curl_off_t,
"curl_easy_getinfo expects a pointer to curl_off_t for this info")
/* groups of curl_easy_setops options that take the same type of argument */
/* To add a new option to one of the groups, just add
* (option) == CURLOPT_SOMETHING
* to the or-expression. If the option takes a long or curl_off_t, you don't
* have to do anything
*/
/* evaluates to true if option takes a long argument */
#define _curl_is_long_option(option) \
(0 < (option) && (option) < CURLOPTTYPE_OBJECTPOINT)
#define _curl_is_off_t_option(option) \
((option) > CURLOPTTYPE_OFF_T)
/* evaluates to true if option takes a char* argument */
#define _curl_is_string_option(option) \
((option) == CURLOPT_ABSTRACT_UNIX_SOCKET || \
(option) == CURLOPT_ACCEPT_ENCODING || \
(option) == CURLOPT_CAINFO || \
(option) == CURLOPT_CAPATH || \
(option) == CURLOPT_COOKIE || \
(option) == CURLOPT_COOKIEFILE || \
(option) == CURLOPT_COOKIEJAR || \
(option) == CURLOPT_COOKIELIST || \
(option) == CURLOPT_CRLFILE || \
(option) == CURLOPT_CUSTOMREQUEST || \
(option) == CURLOPT_DEFAULT_PROTOCOL || \
(option) == CURLOPT_DNS_INTERFACE || \
(option) == CURLOPT_DNS_LOCAL_IP4 || \
(option) == CURLOPT_DNS_LOCAL_IP6 || \
(option) == CURLOPT_DNS_SERVERS || \
(option) == CURLOPT_DOH_URL || \
(option) == CURLOPT_EGDSOCKET || \
(option) == CURLOPT_FTPPORT || \
(option) == CURLOPT_FTP_ACCOUNT || \
(option) == CURLOPT_FTP_ALTERNATIVE_TO_USER || \
(option) == CURLOPT_INTERFACE || \
(option) == CURLOPT_ISSUERCERT || \
(option) == CURLOPT_KEYPASSWD || \
(option) == CURLOPT_KRBLEVEL || \
(option) == CURLOPT_LOGIN_OPTIONS || \
(option) == CURLOPT_MAIL_AUTH || \
(option) == CURLOPT_MAIL_FROM || \
(option) == CURLOPT_NETRC_FILE || \
(option) == CURLOPT_NOPROXY || \
(option) == CURLOPT_PASSWORD || \
(option) == CURLOPT_PINNEDPUBLICKEY || \
(option) == CURLOPT_PRE_PROXY || \
(option) == CURLOPT_PROXY || \
(option) == CURLOPT_PROXYPASSWORD || \
(option) == CURLOPT_PROXYUSERNAME || \
(option) == CURLOPT_PROXYUSERPWD || \
(option) == CURLOPT_PROXY_CAINFO || \
(option) == CURLOPT_PROXY_CAPATH || \
(option) == CURLOPT_PROXY_CRLFILE || \
(option) == CURLOPT_PROXY_KEYPASSWD || \
(option) == CURLOPT_PROXY_PINNEDPUBLICKEY || \
(option) == CURLOPT_PROXY_SERVICE_NAME || \
(option) == CURLOPT_PROXY_SSLCERT || \
(option) == CURLOPT_PROXY_SSLCERTTYPE || \
(option) == CURLOPT_PROXY_SSLKEY || \
(option) == CURLOPT_PROXY_SSLKEYTYPE || \
(option) == CURLOPT_PROXY_SSL_CIPHER_LIST || \
(option) == CURLOPT_PROXY_TLSAUTH_PASSWORD || \
(option) == CURLOPT_PROXY_TLSAUTH_USERNAME || \
(option) == CURLOPT_PROXY_TLSAUTH_TYPE || \
(option) == CURLOPT_RANDOM_FILE || \
(option) == CURLOPT_RANGE || \
(option) == CURLOPT_REFERER || \
(option) == CURLOPT_RTSP_SESSION_ID || \
(option) == CURLOPT_RTSP_STREAM_URI || \
(option) == CURLOPT_RTSP_TRANSPORT || \
(option) == CURLOPT_SERVICE_NAME || \
(option) == CURLOPT_SOCKS5_GSSAPI_SERVICE || \
(option) == CURLOPT_SSH_HOST_PUBLIC_KEY_MD5 || \
(option) == CURLOPT_SSH_KNOWNHOSTS || \
(option) == CURLOPT_SSH_PRIVATE_KEYFILE || \
(option) == CURLOPT_SSH_PUBLIC_KEYFILE || \
(option) == CURLOPT_SSLCERT || \
(option) == CURLOPT_SSLCERTTYPE || \
(option) == CURLOPT_SSLENGINE || \
(option) == CURLOPT_SSLKEY || \
(option) == CURLOPT_SSLKEYTYPE || \
(option) == CURLOPT_SSL_CIPHER_LIST || \
(option) == CURLOPT_TLSAUTH_PASSWORD || \
(option) == CURLOPT_TLSAUTH_TYPE || \
(option) == CURLOPT_TLSAUTH_USERNAME || \
(option) == CURLOPT_UNIX_SOCKET_PATH || \
(option) == CURLOPT_URL || \
(option) == CURLOPT_USERAGENT || \
(option) == CURLOPT_USERNAME || \
(option) == CURLOPT_USERPWD || \
(option) == CURLOPT_XOAUTH2_BEARER || \
0)
/* evaluates to true if option takes a curl_write_callback argument */
#define _curl_is_write_cb_option(option) \
((option) == CURLOPT_HEADERFUNCTION || \
(option) == CURLOPT_WRITEFUNCTION)
/* evaluates to true if option takes a curl_conv_callback argument */
#define _curl_is_conv_cb_option(option) \
((option) == CURLOPT_CONV_TO_NETWORK_FUNCTION || \
(option) == CURLOPT_CONV_FROM_NETWORK_FUNCTION || \
(option) == CURLOPT_CONV_FROM_UTF8_FUNCTION)
/* evaluates to true if option takes a data argument to pass to a callback */
#define _curl_is_cb_data_option(option) \
((option) == CURLOPT_CHUNK_DATA || \
(option) == CURLOPT_CLOSESOCKETDATA || \
(option) == CURLOPT_DEBUGDATA || \
(option) == CURLOPT_FNMATCH_DATA || \
(option) == CURLOPT_HEADERDATA || \
(option) == CURLOPT_INTERLEAVEDATA || \
(option) == CURLOPT_IOCTLDATA || \
(option) == CURLOPT_OPENSOCKETDATA || \
(option) == CURLOPT_PRIVATE || \
(option) == CURLOPT_PROGRESSDATA || \
(option) == CURLOPT_READDATA || \
(option) == CURLOPT_SEEKDATA || \
(option) == CURLOPT_SOCKOPTDATA || \
(option) == CURLOPT_SSH_KEYDATA || \
(option) == CURLOPT_SSL_CTX_DATA || \
(option) == CURLOPT_WRITEDATA || \
(option) == CURLOPT_RESOLVER_START_DATA || \
(option) == CURLOPT_CURLU || \
0)
/* evaluates to true if option takes a POST data argument (void* or char*) */
#define _curl_is_postfields_option(option) \
((option) == CURLOPT_POSTFIELDS || \
(option) == CURLOPT_COPYPOSTFIELDS || \
0)
/* evaluates to true if option takes a struct curl_slist * argument */
#define _curl_is_slist_option(option) \
((option) == CURLOPT_HTTP200ALIASES || \
(option) == CURLOPT_HTTPHEADER || \
(option) == CURLOPT_MAIL_RCPT || \
(option) == CURLOPT_POSTQUOTE || \
(option) == CURLOPT_PREQUOTE || \
(option) == CURLOPT_PROXYHEADER || \
(option) == CURLOPT_QUOTE || \
(option) == CURLOPT_RESOLVE || \
(option) == CURLOPT_TELNETOPTIONS || \
0)
/* groups of curl_easy_getinfo infos that take the same type of argument */
/* evaluates to true if info expects a pointer to char * argument */
#define _curl_is_string_info(info) \
(CURLINFO_STRING < (info) && (info) < CURLINFO_LONG)
/* evaluates to true if info expects a pointer to long argument */
#define _curl_is_long_info(info) \
(CURLINFO_LONG < (info) && (info) < CURLINFO_DOUBLE)
/* evaluates to true if info expects a pointer to double argument */
#define _curl_is_double_info(info) \
(CURLINFO_DOUBLE < (info) && (info) < CURLINFO_SLIST)
/* true if info expects a pointer to struct curl_slist * argument */
#define _curl_is_slist_info(info) \
(((info) == CURLINFO_SSL_ENGINES) || ((info) == CURLINFO_COOKIELIST))
/* true if info expects a pointer to struct curl_tlssessioninfo * argument */
#define _curl_is_tlssessioninfo_info(info) \
(((info) == CURLINFO_TLS_SSL_PTR) || ((info) == CURLINFO_TLS_SESSION))
/* true if info expects a pointer to struct curl_certinfo * argument */
#define _curl_is_certinfo_info(info) ((info) == CURLINFO_CERTINFO)
/* true if info expects a pointer to struct curl_socket_t argument */
#define _curl_is_socket_info(info) \
(CURLINFO_SOCKET < (info) && (info) < CURLINFO_OFF_T)
/* true if info expects a pointer to curl_off_t argument */
#define _curl_is_off_t_info(info) \
(CURLINFO_OFF_T < (info))
/* typecheck helpers -- check whether given expression has requested type*/
/* For pointers, you can use the _curl_is_ptr/_curl_is_arr macros,
* otherwise define a new macro. Search for __builtin_types_compatible_p
* in the GCC manual.
* NOTE: these macros MUST NOT EVALUATE their arguments! The argument is
* the actual expression passed to the curl_easy_setopt macro. This
* means that you can only apply the sizeof and __typeof__ operators, no
* == or whatsoever.
*/
/* XXX: should evaluate to true if expr is a pointer */
#define _curl_is_any_ptr(expr) \
(sizeof(expr) == sizeof(void *))
/* evaluates to true if expr is NULL */
/* XXX: must not evaluate expr, so this check is not accurate */
#define _curl_is_NULL(expr) \
(__builtin_types_compatible_p(__typeof__(expr), __typeof__(NULL)))
/* evaluates to true if expr is type*, const type* or NULL */
#define _curl_is_ptr(expr, type) \
(_curl_is_NULL(expr) || \
__builtin_types_compatible_p(__typeof__(expr), type *) || \
__builtin_types_compatible_p(__typeof__(expr), const type *))
/* evaluates to true if expr is one of type[], type*, NULL or const type* */
#define _curl_is_arr(expr, type) \
(_curl_is_ptr((expr), type) || \
__builtin_types_compatible_p(__typeof__(expr), type []))
/* evaluates to true if expr is a string */
#define _curl_is_string(expr) \
(_curl_is_arr((expr), char) || \
_curl_is_arr((expr), signed char) || \
_curl_is_arr((expr), unsigned char))
/* evaluates to true if expr is a long (no matter the signedness)
* XXX: for now, int is also accepted (and therefore short and char, which
* are promoted to int when passed to a variadic function) */
#define _curl_is_long(expr) \
(__builtin_types_compatible_p(__typeof__(expr), long) || \
__builtin_types_compatible_p(__typeof__(expr), signed long) || \
__builtin_types_compatible_p(__typeof__(expr), unsigned long) || \
__builtin_types_compatible_p(__typeof__(expr), int) || \
__builtin_types_compatible_p(__typeof__(expr), signed int) || \
__builtin_types_compatible_p(__typeof__(expr), unsigned int) || \
__builtin_types_compatible_p(__typeof__(expr), short) || \
__builtin_types_compatible_p(__typeof__(expr), signed short) || \
__builtin_types_compatible_p(__typeof__(expr), unsigned short) || \
__builtin_types_compatible_p(__typeof__(expr), char) || \
__builtin_types_compatible_p(__typeof__(expr), signed char) || \
__builtin_types_compatible_p(__typeof__(expr), unsigned char))
/* evaluates to true if expr is of type curl_off_t */
#define _curl_is_off_t(expr) \
(__builtin_types_compatible_p(__typeof__(expr), curl_off_t))
/* evaluates to true if expr is abuffer suitable for CURLOPT_ERRORBUFFER */
/* XXX: also check size of an char[] array? */
#define _curl_is_error_buffer(expr) \
(_curl_is_NULL(expr) || \
__builtin_types_compatible_p(__typeof__(expr), char *) || \
__builtin_types_compatible_p(__typeof__(expr), char[]))
/* evaluates to true if expr is of type (const) void* or (const) FILE* */
#if 0
#define _curl_is_cb_data(expr) \
(_curl_is_ptr((expr), void) || \
_curl_is_ptr((expr), FILE))
#else /* be less strict */
#define _curl_is_cb_data(expr) \
_curl_is_any_ptr(expr)
#endif
/* evaluates to true if expr is of type FILE* */
#define _curl_is_FILE(expr) \
(_curl_is_NULL(expr) || \
(__builtin_types_compatible_p(__typeof__(expr), FILE *)))
/* evaluates to true if expr can be passed as POST data (void* or char*) */
#define _curl_is_postfields(expr) \
(_curl_is_ptr((expr), void) || \
_curl_is_arr((expr), char) || \
_curl_is_arr((expr), unsigned char))
/* FIXME: the whole callback checking is messy...
* The idea is to tolerate char vs. void and const vs. not const
* pointers in arguments at least
*/
/* helper: __builtin_types_compatible_p distinguishes between functions and
* function pointers, hide it */
#define _curl_callback_compatible(func, type) \
(__builtin_types_compatible_p(__typeof__(func), type) || \
__builtin_types_compatible_p(__typeof__(func) *, type))
/* evaluates to true if expr is of type curl_resolver_start_callback */
#define _curl_is_resolver_start_callback(expr) \
(_curl_is_NULL(expr) || \
_curl_callback_compatible((expr), curl_resolver_start_callback))
/* evaluates to true if expr is of type curl_read_callback or "similar" */
#define _curl_is_read_cb(expr) \
(_curl_is_NULL(expr) || \
_curl_callback_compatible((expr), __typeof__(fread) *) || \
_curl_callback_compatible((expr), curl_read_callback) || \
_curl_callback_compatible((expr), _curl_read_callback1) || \
_curl_callback_compatible((expr), _curl_read_callback2) || \
_curl_callback_compatible((expr), _curl_read_callback3) || \
_curl_callback_compatible((expr), _curl_read_callback4) || \
_curl_callback_compatible((expr), _curl_read_callback5) || \
_curl_callback_compatible((expr), _curl_read_callback6))
typedef size_t (*_curl_read_callback1)(char *, size_t, size_t, void *);
typedef size_t (*_curl_read_callback2)(char *, size_t, size_t, const void *);
typedef size_t (*_curl_read_callback3)(char *, size_t, size_t, FILE *);
typedef size_t (*_curl_read_callback4)(void *, size_t, size_t, void *);
typedef size_t (*_curl_read_callback5)(void *, size_t, size_t, const void *);
typedef size_t (*_curl_read_callback6)(void *, size_t, size_t, FILE *);
/* evaluates to true if expr is of type curl_write_callback or "similar" */
#define _curl_is_write_cb(expr) \
(_curl_is_read_cb(expr) || \
_curl_callback_compatible((expr), __typeof__(fwrite) *) || \
_curl_callback_compatible((expr), curl_write_callback) || \
_curl_callback_compatible((expr), _curl_write_callback1) || \
_curl_callback_compatible((expr), _curl_write_callback2) || \
_curl_callback_compatible((expr), _curl_write_callback3) || \
_curl_callback_compatible((expr), _curl_write_callback4) || \
_curl_callback_compatible((expr), _curl_write_callback5) || \
_curl_callback_compatible((expr), _curl_write_callback6))
typedef size_t (*_curl_write_callback1)(const char *, size_t, size_t, void *);
typedef size_t (*_curl_write_callback2)(const char *, size_t, size_t,
const void *);
typedef size_t (*_curl_write_callback3)(const char *, size_t, size_t, FILE *);
typedef size_t (*_curl_write_callback4)(const void *, size_t, size_t, void *);
typedef size_t (*_curl_write_callback5)(const void *, size_t, size_t,
const void *);
typedef size_t (*_curl_write_callback6)(const void *, size_t, size_t, FILE *);
/* evaluates to true if expr is of type curl_ioctl_callback or "similar" */
#define _curl_is_ioctl_cb(expr) \
(_curl_is_NULL(expr) || \
_curl_callback_compatible((expr), curl_ioctl_callback) || \
_curl_callback_compatible((expr), _curl_ioctl_callback1) || \
_curl_callback_compatible((expr), _curl_ioctl_callback2) || \
_curl_callback_compatible((expr), _curl_ioctl_callback3) || \
_curl_callback_compatible((expr), _curl_ioctl_callback4))
typedef curlioerr (*_curl_ioctl_callback1)(CURL *, int, void *);
typedef curlioerr (*_curl_ioctl_callback2)(CURL *, int, const void *);
typedef curlioerr (*_curl_ioctl_callback3)(CURL *, curliocmd, void *);
typedef curlioerr (*_curl_ioctl_callback4)(CURL *, curliocmd, const void *);
/* evaluates to true if expr is of type curl_sockopt_callback or "similar" */
#define _curl_is_sockopt_cb(expr) \
(_curl_is_NULL(expr) || \
_curl_callback_compatible((expr), curl_sockopt_callback) || \
_curl_callback_compatible((expr), _curl_sockopt_callback1) || \
_curl_callback_compatible((expr), _curl_sockopt_callback2))
typedef int (*_curl_sockopt_callback1)(void *, curl_socket_t, curlsocktype);
typedef int (*_curl_sockopt_callback2)(const void *, curl_socket_t,
curlsocktype);
/* evaluates to true if expr is of type curl_opensocket_callback or
"similar" */
#define _curl_is_opensocket_cb(expr) \
(_curl_is_NULL(expr) || \
_curl_callback_compatible((expr), curl_opensocket_callback) || \
_curl_callback_compatible((expr), _curl_opensocket_callback1) || \
_curl_callback_compatible((expr), _curl_opensocket_callback2) || \
_curl_callback_compatible((expr), _curl_opensocket_callback3) || \
_curl_callback_compatible((expr), _curl_opensocket_callback4))
typedef curl_socket_t (*_curl_opensocket_callback1)
(void *, curlsocktype, struct curl_sockaddr *);
typedef curl_socket_t (*_curl_opensocket_callback2)
(void *, curlsocktype, const struct curl_sockaddr *);
typedef curl_socket_t (*_curl_opensocket_callback3)
(const void *, curlsocktype, struct curl_sockaddr *);
typedef curl_socket_t (*_curl_opensocket_callback4)
(const void *, curlsocktype, const struct curl_sockaddr *);
/* evaluates to true if expr is of type curl_progress_callback or "similar" */
#define _curl_is_progress_cb(expr) \
(_curl_is_NULL(expr) || \
_curl_callback_compatible((expr), curl_progress_callback) || \
_curl_callback_compatible((expr), _curl_progress_callback1) || \
_curl_callback_compatible((expr), _curl_progress_callback2))
typedef int (*_curl_progress_callback1)(void *,
double, double, double, double);
typedef int (*_curl_progress_callback2)(const void *,
double, double, double, double);
/* evaluates to true if expr is of type curl_debug_callback or "similar" */
#define _curl_is_debug_cb(expr) \
(_curl_is_NULL(expr) || \
_curl_callback_compatible((expr), curl_debug_callback) || \
_curl_callback_compatible((expr), _curl_debug_callback1) || \
_curl_callback_compatible((expr), _curl_debug_callback2) || \
_curl_callback_compatible((expr), _curl_debug_callback3) || \
_curl_callback_compatible((expr), _curl_debug_callback4) || \
_curl_callback_compatible((expr), _curl_debug_callback5) || \
_curl_callback_compatible((expr), _curl_debug_callback6) || \
_curl_callback_compatible((expr), _curl_debug_callback7) || \
_curl_callback_compatible((expr), _curl_debug_callback8))
typedef int (*_curl_debug_callback1) (CURL *,
curl_infotype, char *, size_t, void *);
typedef int (*_curl_debug_callback2) (CURL *,
curl_infotype, char *, size_t, const void *);
typedef int (*_curl_debug_callback3) (CURL *,
curl_infotype, const char *, size_t, void *);
typedef int (*_curl_debug_callback4) (CURL *,
curl_infotype, const char *, size_t, const void *);
typedef int (*_curl_debug_callback5) (CURL *,
curl_infotype, unsigned char *, size_t, void *);
typedef int (*_curl_debug_callback6) (CURL *,
curl_infotype, unsigned char *, size_t, const void *);
typedef int (*_curl_debug_callback7) (CURL *,
curl_infotype, const unsigned char *, size_t, void *);
typedef int (*_curl_debug_callback8) (CURL *,
curl_infotype, const unsigned char *, size_t, const void *);
/* evaluates to true if expr is of type curl_ssl_ctx_callback or "similar" */
/* this is getting even messier... */
#define _curl_is_ssl_ctx_cb(expr) \
(_curl_is_NULL(expr) || \
_curl_callback_compatible((expr), curl_ssl_ctx_callback) || \
_curl_callback_compatible((expr), _curl_ssl_ctx_callback1) || \
_curl_callback_compatible((expr), _curl_ssl_ctx_callback2) || \
_curl_callback_compatible((expr), _curl_ssl_ctx_callback3) || \
_curl_callback_compatible((expr), _curl_ssl_ctx_callback4) || \
_curl_callback_compatible((expr), _curl_ssl_ctx_callback5) || \
_curl_callback_compatible((expr), _curl_ssl_ctx_callback6) || \
_curl_callback_compatible((expr), _curl_ssl_ctx_callback7) || \
_curl_callback_compatible((expr), _curl_ssl_ctx_callback8))
typedef CURLcode (*_curl_ssl_ctx_callback1)(CURL *, void *, void *);
typedef CURLcode (*_curl_ssl_ctx_callback2)(CURL *, void *, const void *);
typedef CURLcode (*_curl_ssl_ctx_callback3)(CURL *, const void *, void *);
typedef CURLcode (*_curl_ssl_ctx_callback4)(CURL *, const void *,
const void *);
#ifdef HEADER_SSL_H
/* hack: if we included OpenSSL's ssl.h, we know about SSL_CTX
* this will of course break if we're included before OpenSSL headers...
*/
typedef CURLcode (*_curl_ssl_ctx_callback5)(CURL *, SSL_CTX, void *);
typedef CURLcode (*_curl_ssl_ctx_callback6)(CURL *, SSL_CTX, const void *);
typedef CURLcode (*_curl_ssl_ctx_callback7)(CURL *, const SSL_CTX, void *);
typedef CURLcode (*_curl_ssl_ctx_callback8)(CURL *, const SSL_CTX,
const void *);
#else
typedef _curl_ssl_ctx_callback1 _curl_ssl_ctx_callback5;
typedef _curl_ssl_ctx_callback1 _curl_ssl_ctx_callback6;
typedef _curl_ssl_ctx_callback1 _curl_ssl_ctx_callback7;
typedef _curl_ssl_ctx_callback1 _curl_ssl_ctx_callback8;
#endif
/* evaluates to true if expr is of type curl_conv_callback or "similar" */
#define _curl_is_conv_cb(expr) \
(_curl_is_NULL(expr) || \
_curl_callback_compatible((expr), curl_conv_callback) || \
_curl_callback_compatible((expr), _curl_conv_callback1) || \
_curl_callback_compatible((expr), _curl_conv_callback2) || \
_curl_callback_compatible((expr), _curl_conv_callback3) || \
_curl_callback_compatible((expr), _curl_conv_callback4))
typedef CURLcode (*_curl_conv_callback1)(char *, size_t length);
typedef CURLcode (*_curl_conv_callback2)(const char *, size_t length);
typedef CURLcode (*_curl_conv_callback3)(void *, size_t length);
typedef CURLcode (*_curl_conv_callback4)(const void *, size_t length);
/* evaluates to true if expr is of type curl_seek_callback or "similar" */
#define _curl_is_seek_cb(expr) \
(_curl_is_NULL(expr) || \
_curl_callback_compatible((expr), curl_seek_callback) || \
_curl_callback_compatible((expr), _curl_seek_callback1) || \
_curl_callback_compatible((expr), _curl_seek_callback2))
typedef CURLcode (*_curl_seek_callback1)(void *, curl_off_t, int);
typedef CURLcode (*_curl_seek_callback2)(const void *, curl_off_t, int);
#endif /* __CURL_TYPECHECK_GCC_H */

View File

@ -0,0 +1,122 @@
#ifndef __CURL_URLAPI_H
#define __CURL_URLAPI_H
/***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 2018 - 2019, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
* are also available at https://curl.haxx.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
* furnished to do so, under the terms of the COPYING file.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
***************************************************************************/
#include "curl.h"
#ifdef __cplusplus
extern "C" {
#endif
/* the error codes for the URL API */
typedef enum {
CURLUE_OK,
CURLUE_BAD_HANDLE, /* 1 */
CURLUE_BAD_PARTPOINTER, /* 2 */
CURLUE_MALFORMED_INPUT, /* 3 */
CURLUE_BAD_PORT_NUMBER, /* 4 */
CURLUE_UNSUPPORTED_SCHEME, /* 5 */
CURLUE_URLDECODE, /* 6 */
CURLUE_OUT_OF_MEMORY, /* 7 */
CURLUE_USER_NOT_ALLOWED, /* 8 */
CURLUE_UNKNOWN_PART, /* 9 */
CURLUE_NO_SCHEME, /* 10 */
CURLUE_NO_USER, /* 11 */
CURLUE_NO_PASSWORD, /* 12 */
CURLUE_NO_OPTIONS, /* 13 */
CURLUE_NO_HOST, /* 14 */
CURLUE_NO_PORT, /* 15 */
CURLUE_NO_QUERY, /* 16 */
CURLUE_NO_FRAGMENT /* 17 */
} CURLUcode;
typedef enum {
CURLUPART_URL,
CURLUPART_SCHEME,
CURLUPART_USER,
CURLUPART_PASSWORD,
CURLUPART_OPTIONS,
CURLUPART_HOST,
CURLUPART_PORT,
CURLUPART_PATH,
CURLUPART_QUERY,
CURLUPART_FRAGMENT
} CURLUPart;
#define CURLU_DEFAULT_PORT (1<<0) /* return default port number */
#define CURLU_NO_DEFAULT_PORT (1<<1) /* act as if no port number was set,
if the port number matches the
default for the scheme */
#define CURLU_DEFAULT_SCHEME (1<<2) /* return default scheme if
missing */
#define CURLU_NON_SUPPORT_SCHEME (1<<3) /* allow non-supported scheme */
#define CURLU_PATH_AS_IS (1<<4) /* leave dot sequences */
#define CURLU_DISALLOW_USER (1<<5) /* no user+password allowed */
#define CURLU_URLDECODE (1<<6) /* URL decode on get */
#define CURLU_URLENCODE (1<<7) /* URL encode on set */
#define CURLU_APPENDQUERY (1<<8) /* append a form style part */
#define CURLU_GUESS_SCHEME (1<<9) /* legacy curl-style guessing */
typedef struct Curl_URL CURLU;
/*
* curl_url() creates a new CURLU handle and returns a pointer to it.
* Must be freed with curl_url_cleanup().
*/
CURL_EXTERN CURLU *curl_url(void);
/*
* curl_url_cleanup() frees the CURLU handle and related resources used for
* the URL parsing. It will not free strings previously returned with the URL
* API.
*/
CURL_EXTERN void curl_url_cleanup(CURLU *handle);
/*
* curl_url_dup() duplicates a CURLU handle and returns a new copy. The new
* handle must also be freed with curl_url_cleanup().
*/
CURL_EXTERN CURLU *curl_url_dup(CURLU *in);
/*
* curl_url_get() extracts a specific part of the URL from a CURLU
* handle. Returns error code. The returned pointer MUST be freed with
* curl_free() afterwards.
*/
CURL_EXTERN CURLUcode curl_url_get(CURLU *handle, CURLUPart what,
char **part, unsigned int flags);
/*
* curl_url_set() sets a specific part of the URL in a CURLU handle. Returns
* error code. The passed in string will be copied. Passing a NULL instead of
* a part string, clears that part.
*/
CURL_EXTERN CURLUcode curl_url_set(CURLU *handle, CURLUPart what,
const char *part, unsigned int flags);
#ifdef __cplusplus
} /* end of extern "C" */
#endif
#endif

View File

@ -0,0 +1,758 @@
/*
* Copyright 2018-2021 THALES group. All Rights Reserved.
*
* Project name: LPASDK.
* Platform: Windows, Linux.
* Language: C/C++
*
* Except if otherwise stated in a NOTICE file provided by Thales together with the software, below conditions are applicable by default.
*
* This computer program includes confidential and proprietary information of Thales and is a trade secret of
* Thales. All use, disclosure, and/or reproduction is prohibited unless authorized in writing by Thales.
*
* The computer program is provided "AS IS" without warranty of any kind. Thales makes no
* warranties to any person or entity with respect to the computer program and disclaims all other warranties,
* expressed or implied. Thales expressly disclaims any implied warranty of merchantability, fitness for particular
* purpose and any warranty which may arise from course of performance, course of dealing, or usage of trade. Further
* Thales does not warrant that the computer program will meet requirements or that operation of the computer program
* will be uninterrupted or error-free.
*
*/
#ifndef LPA_SDK__CORE_API_H
#define LPA_SDK__CORE_API_H
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include <stdint.h>
#include "lpasdk/api/semedia/semedia.h"
/////////////////////////////////
// API versionning
/////////////////////////////////
#define LPA_API_MAJOR_VERSION 1
#define LPA_API_MINOR_VERSION 9
typedef struct
{
int major; // Update it when API compatibility is not "supported"
int minor; // Update it when function added without impact on API compatibility
}LPA_API_VERSION;
/////////////////////////////////
// LPA Type
/////////////////////////////////
typedef int16_t LPA_Integer;
typedef char* LPA_StringPtr;
/////////////////////////////////
// API definition
/////////////////////////////////
#define LPA_CFG_DEVICE_INFO_TLV_MAX_SIZE 385 // 384 + CR
#define LPA_CFG_DEVICE_INFO_TLV_BYTE_ARRAY_MAX_SIZE ((LPA_CFG_DEVICE_INFO_TLV_MAX_SIZE >> 1) + 1)
#define LPA_CFG_CERT_PATH_MAX_SIZE LPA_MAX_PATH
#define LPA_CFG_LINE_ENTRY_MAX_SIZE 1024
/*
Maximum profile info size retrieved from eUICC (Max length used):
Tag/size bytes + max data lengths
Header tag E3 5 bytes
iccid tag 5A 2 + 10 = 12 bytes
profileState tag 9F70 3 + 1 = 4 bytes
profileNickName tag 90 2 + 64 = 66 bytes
serviceProviderName tag 91 2 + 32 = 34 bytes
profileName tag 92 2 + 64 = 66 bytes
iconType tag 93 2 + 1 = 3 bytes
icon tag 94 4 + 1024 = 1028 bytes
profileClass tag 95 2 + 1 = 3 bytes
profilePolicyRules tag 99 2 + 2 = 4 bytes
TOTAL -------------------------------------- 1225 bytes - Set at 1300 for rounding / security
Note: Other tags (4F, B6, B7 & B8) not requested in current request, so not taken in account
*/
#define LPA_PROFILE_INFO_BUFFER_MAX_SIZE 1300 // Size of profile raw data
#define LPA_MAX_EVENT_RECORD 16
// All profile fields limits match maximum defined in SGP.22
// LPA_PROFILE_STATE_MAX_SIZE, LPA_PROFILE_CLASS_MAX_SIZE, LPA_PROFILE_ICON_TYPE_MAX_SIZE defined as ASN1 'INTEGER'
#define LPA_ASN1_INTEGER_MAX_SIZE 2
#define LPA_PROFILE_ICCID_BUFFER_MAX_SIZE 10
#define LPA_PROFILE_STATE_MAX_SIZE LPA_ASN1_INTEGER_MAX_SIZE
#define LPA_PROFILE_SERVICE_PROVIDER_NAME_MAX_SIZE 32
#define LPA_PROFILE_NAME_MAX_SIZE 64
#define LPA_PROFILE_CLASS_MAX_SIZE LPA_ASN1_INTEGER_MAX_SIZE
#define LPA_PROFILE_ICON_MAX_SIZE 1024
#define LPA_PROFILE_ICON_TYPE_MAX_SIZE LPA_ASN1_INTEGER_MAX_SIZE
#define LPA_PROFILE_NICKNAME_MAX_SIZE 64
#define LPA_PROFILE_POLICY_RULES_MAX_SIZE 2
#define LPA_GET_EID_BUFFER_SIZE 20 // Previously 64, 16 is the typical size, set 20 to keep a security
#define LPA_GET_EUICC_BUFFER_MAX_SIZE 900 //255 then 384 previously
/* Size calculation to evaluate EUICCInfo2. Some fields of list size have no limit defined, so decisions have been taken here:
Note: TL = Tag Length
Size ASN1 object + Explanation
5 EUICCInfo2 Main Tag BF22, length coded on 3 bytes considering total data size => 5 bytes
5 profileVersion [1] "VersionType" object, 3 bytes value, 5 with TL
5 svn [2] "VersionType" object, 3 bytes value, 5 with TL
5 euiccFirmwareVer [3] "VersionType" object, 3 bytes value, 5 with TL
16 extCardResource [4] "Extended Card Resource Information according to ETSI TS 102 226" (Chapter 8.2.1.7.2) - 3 concatenated TLV, first refer "application number", typical 1 byte, 2 others are free memory status, typically coded on 4 bytes. Total typical size = 16
6 uiccCapability [5] BITSTRING object, max 6 bytes with TL
5 ts102241Version [6] "VersionType" object, 3 bytes value, 5 with TL
5 globalplatformVersion [7] "VersionType" object, 3 bytes value, 5 with TL
4 rspCapability [8] BITSTRING object, 4 bytes with TL
3 euiccCiPKIdListForVerification [9] List of "SubjectKeyIdentifier", fixed to up to 6 elements (Typical use in Asia 5 elements): TL + Size coded on 2 bytes (132 bytes data) => 3 bytes
132 6x > SubjectKeyIdentifier "CI Public Key Identifier" => 20 bytes + 2 bytes TL => 22 bytes
3 euiccCiPKIdListForSigning [10] List of "SubjectKeyIdentifier", fixed to up to 6 elements (Typical use in Asia 5 elements): TL + Size coded on 2 bytes (132 bytes data) => 3 bytes
132 6x > SubjectKeyIdentifier "CI Public Key Identifier" => 20 bytes + 2 bytes TL => 22 bytes
3 euiccCategory [11] Integer, typically 1 byte value, 3 with TL
4 forbiddenProfilePolicyRules [25] BITSTRING object, 4 bytes with TL
5 ppVersion "VersionType" object, 3 bytes value, 5 with TL
66 sasAcreditationNumber String, limited to 64 characters max, 66 with TL
4 certificationDataObject [12] List of 2 strings, length coded on 3 bytes considering data size => 4 bytes
102 > platformLabel Coded on form "<OID platform manufacturer>/<Unique Identifier of the platform>", example "1.2.840.114283/My_Platform_Label_1a" - Considering real label size, set at 100 characters max + 2 bytes TL => 102 bytes
258 > discoveryBaseURL Based on the fact that some URL like Activation Code SM-DP address are limited to 255 characters, we will use the same limit => 258 bytes with TL
4 treProperties [13] BITSTRING object, 4 bytes with TL
52 treProductReference [14] String, "unique reference of the Integrated TRE product that the eUICC is based upon" - Set at 50 characters considering references actually used => 52 bytes with TL
2 additionalEuiccProfilePackageVersions [15] List of "VersionType" fixed to up to 12 elements: TL + Size coded on 1 byte (60 bytes data) => 2 bytes - "List higher major versions including associated highest minor version number of additional eUICC Profile Package specification(s) supported by eUICC
60 12x > VersionType "VersionType" object, 3 bytes value, 5 with TL
TOTAL 886 bytes
*/
#define LPA_CANCEL_SESSION_RESPONSE_BUFFER_SIZE 160
// For memory: Full Activation Code is 1$lpa_SM-Dx_address$matchingId$oid_object$ccRequiredFlag
#define LPA_ACTIVATION_CODE_MAX_SIZE (2 + LPA_SMDP_ADDRESS_SIZE + 1 + LPA_MATCHING_ID_SIZE + 1 + LPA_OID_SIZE + 1 + LPA_CC_REQUIRED_FLAG_SIZE)
#define LPA_ACTIVATION_CODE_MAX_STRING_BUFFER_SIZE ( LPA_ACTIVATION_CODE_MAX_SIZE + 1 ) // Adding 1 bytes to End of String
#define LPA_SMDP_ADDRESS_SIZE 128 // Max 127 characters with End Of String
#define LPA_SMDS_ADDRESS_SIZE LPA_SMDP_ADDRESS_SIZE
#define LPA_ADDRESS_MAX_SIZE 255
#define LPA_MATCHING_ID_SIZE 255
#define LPA_OID_SIZE 128
#define LPA_CC_REQUIRED_FLAG_SIZE 2 // Include end of string
#define LPA_MAX_PROFILE_NOTIFICATION_LIST_ELEMENT 16
#define LPA_MAX_NOTIFICATION_ADDRESS_RAW_DATA_SIZE 128
// Managing Confirmation Code during downloadProfile
#define LPA_CONFIRMATION_CODE_MAX_SIZE 50
// Maximum number of parameters for parameter list generation
// ! CAUTION: Have to take care that list is long enough to store all parameters and element size long enough to fit longest parameters names
#define LPA_MAX_PARAMETERS_LIST 25
#define LPA_MAX_PARAMETERS_LIST_ELEMENT_SIZE 40
typedef struct
{
int major;
int minor;
int patch;
int build;
}LPA_VERSION;
// Support of Notification Error during a download profile
// Application owner should manage LPA_EVENT_REQUEST_CONFIRMATION_CODE callback
typedef enum
{
LPA_EVENT_EXECUTION_SERVER_ERROR_TYPE = 1, // Error send by server
LPA_EVENT_EXECUTION_HTTP_ERROR_TYPE = 2, // HTTP error during communication with server
LPA_EVENT_EXECUTION_CURL_ERROR_TYPE = 3, // Curl error
LPA_EVENT_EXECUTION_SEMEDIA_DRIVER_ERROR_TYPE = 4 // SEMEDIA_DRIVER error
}LPA_EVENT_EXECUTION_ERROR_TYPE;
typedef enum
{
LPA_EVENT_EXECUTION_ERROR_NO_DETAIL_MASK = 0x0000, // 0b00000000
LPA_EVENT_EXECUTION_ERROR_SUBJECT_CODE_MASK = 0x0001, // 0b00000001
LPA_EVENT_EXECUTION_ERROR_REASON_CODE_MASK = 0x0002, // 0b00000010
LPA_EVENT_EXECUTION_ERROR_EXTRA_INFO_MASK = 0x0004, // 0b00000100
}LPA_EVENT_EXECUTION_ERROR_DETAIL_MASK;
typedef struct
{
LPA_EVENT_EXECUTION_ERROR_TYPE executionErrorType;
LPA_EVENT_EXECUTION_ERROR_DETAIL_MASK detailErrorMask;
const char* ptrErrorSubjectCode;
const char* ptrErrorReasonCode;
const char* ptrErrorExtraInfo;
} LPA_EVENT_EXECUTION_ERROR_INFO;
// Support of Confirmation Code requested by LPA SDK
// Application owner should manage LPA_EVENT_EXECUTION_ERROR callback
typedef struct
{
// Confirmation code value updated by application
char confirmationCode[LPA_CONFIRMATION_CODE_MAX_SIZE];
// Size of CC buffer (with final '\0')
size_t confirmationCodeMaxBufferSize;
// Updated by LPA Application
unsigned int reasonCodeNoCC; // used if no Confirmation Code
} LPA_REQUEST_CONFIRMATION_CODE;
// @Since LPASDK API 1.6
typedef struct
{
unsigned char userCallBackType; // Set information(s) to display. Values masks defined in LPA_USER_CONSENT_TYPES enum. Each bit set an info to display.
char profileName[LPA_PROFILE_NAME_MAX_SIZE + 2]; // Profile name that may be displayed. String coded. +1 byte for EOS, +1 byte for security
bool downloadAllowed; // Confirm user accepted download (True) or refused (False)
unsigned int cancelSessionReason; // Values defined in LPA_CANCEL_SESSION_REASON enum. Value has no importance if downloadAllowed returned "true"
}LPA_REQUEST_USER_CONSENT_FOR_LOADING_PROFILE;
// Since LPASDK API 1.8
typedef struct
{
bool profileMetadataAvailable; // Set to true if SM-DP server returned profile Metadata, else false
unsigned char iccid[LPA_PROFILE_ICCID_BUFFER_MAX_SIZE]; // ICCID. Raw bytes
size_t iccidSize; // ICCID size. Given as confirmation but shall be always equal to 0x0A
char profileName[LPA_PROFILE_NAME_MAX_SIZE + 2]; // Profile name. String coded. +1 byte for EOS, +1 byte for security
char serviceProviderName[LPA_PROFILE_SERVICE_PROVIDER_NAME_MAX_SIZE + 2]; // Service provider name. String coded. +1 byte for EOS, +1 byte for security
unsigned char profileIcon[LPA_PROFILE_ICON_MAX_SIZE]; // Icon. Raw bytes
size_t profileIconSize; // Icon size. If equal 0 the 2 other icon fields have no meaning
unsigned char profileIconType; // Icon type value
unsigned int profilePPR; // PPR value (ASN1 bitstring value). If equal 0 the PPR is not defined (Or empty or set to 0 but this shall not happen)
}LPA_EVENT_INCOMING_PROFILE_INFORMATION;
// LPA Event mechanism
// eventType is dependant of LPA SDK API used. Mainly give equivalent of progression order
// Zero, some or all LPA Event functions can be registered
// Function <lpaEventProgessValue> is used to manage a Progress Value
typedef void (*LPA_EVENT_PROGRESS_VALUE) (const void* ptrAppParameter, size_t eventType, size_t valueMin, size_t currentValue, size_t valueMax);
// Function <lpaEventProgressText> is used to communicate a text message to the application
typedef void(*LPA_EVENT_PROGRESS_TEXT) (const void* ptrAppParameter, size_t eventType, const char* ptrText);
// Function <lpaEventRequestConfirmationCode> is used to communicate a text message to the application
// Return true if CC entered correctly, otherwise return false and update reasonCodeNoCC field
typedef bool(*LPA_EVENT_REQUEST_CONFIRMATION_CODE) (const void* ptrAppParameter, LPA_REQUEST_CONFIRMATION_CODE* ptrRequestConfirmationCode);
// Function <lpaEventExecutionError> is used to communicate some execution error information (subjectCode, reasonCode...) to the application
typedef void(*LPA_EVENT_EXECUTION_ERROR) (const void* ptrAppParameter, const LPA_EVENT_EXECUTION_ERROR_INFO* ptrEventExecutionErrorInfo);
// Function <lpaEventRequestUserConsentForLoadingProfile> is used to request a User Consent before loading a profile by Activation Code
// Since LPASDK API 1.6
// Since LPASDK API 1.9, systematically called on each download
typedef bool(*LPA_EVENT_REQUEST_USER_CONSENT_FOR_LOADING_PROFILE) (const void* ptrAppParameter, LPA_REQUEST_USER_CONSENT_FOR_LOADING_PROFILE* ptrRequestUserConsentForLoadingProfile);
// Function <lpaEventDisplayIncomingProfileInformation> is used to display informations about profile currently downloaded
// Since LPASDK API 1.8
typedef void(*LPA_EVENT_DISPLAY_INCOMING_PROFILE_INFORMATION) (const void* ptrAppParameter, size_t eventType, LPA_EVENT_INCOMING_PROFILE_INFORMATION* ptrIncomingProfileInformation);
typedef struct
{
// LPA SDK event parameter
void* _appParameter; // NULL if not used, otherwise specific application parameter (using it at first parameter value of event function
// In C++ application, could be instance of a class
// LPA SDK Event callback functions - Must be initialized to NULL if not used.
LPA_EVENT_PROGRESS_VALUE _lpaEventProgressValue;
LPA_EVENT_PROGRESS_TEXT _lpaEventProgressText;
LPA_EVENT_EXECUTION_ERROR _lpaEventExecutionError;
// When LPA SDK request a Confirmation Code during a DownloadProfile
LPA_EVENT_REQUEST_CONFIRMATION_CODE _lpaEventRequestConfirmationCode;
// Event for managing User Consent before loading profile
LPA_EVENT_REQUEST_USER_CONSENT_FOR_LOADING_PROFILE _lpaEventRequestUserConsentForLoadingProfile;
// Displaying of incoming profile information during download
LPA_EVENT_DISPLAY_INCOMING_PROFILE_INFORMATION _lpaEventDisplayIncomingProfileInformation;
}LPA_EventCallback;
typedef struct
{
// Profile Info Record
unsigned char rawData[LPA_PROFILE_INFO_BUFFER_MAX_SIZE];
size_t rawDataSize;
unsigned char iccid[LPA_PROFILE_ICCID_BUFFER_MAX_SIZE];
size_t iccidSize;
unsigned char profileState[LPA_PROFILE_STATE_MAX_SIZE];
size_t profileStateSize;
unsigned char serviceProviderName[LPA_PROFILE_SERVICE_PROVIDER_NAME_MAX_SIZE];
size_t serviceProviderNameSize;
unsigned char profileName[LPA_PROFILE_NAME_MAX_SIZE];
size_t profileNameSize;
unsigned char profileClass[LPA_PROFILE_CLASS_MAX_SIZE];
size_t profileClassSize;
unsigned char profileNickname[LPA_PROFILE_NICKNAME_MAX_SIZE];
size_t profileNicknameSize;
unsigned char profileIcon[LPA_PROFILE_ICON_MAX_SIZE];
size_t profileIconSize;
unsigned char profileIconType[LPA_PROFILE_ICON_TYPE_MAX_SIZE];
size_t profileIconTypeSize;
unsigned char profilePolicyRules[LPA_PROFILE_POLICY_RULES_MAX_SIZE];
size_t profilePolicyRulesSize;
}LPA_PROFILE_INFO;
typedef struct
{
// Get Profile Info All
size_t countProfileInfo; // Number of profiles effectively retrieved and available in profileInfoList
size_t numberProfileInfoFound; // Number of profiles found in eUICC. Can be higher than value returned in "countProfileInfo"
size_t maxNumberProfileInfo; // Maximum number of profiles that can be stored in profileInfoList
unsigned char * profileInfoList; // Data area storing profiles information list. Must be allocated with (maxNumberProfileInfo * sizeof(LPA_PROFILE_INFO)) size.
}LPA_GET_PROFILES_INFO;
typedef struct
{
// EID
unsigned char EID_Data[LPA_GET_EID_BUFFER_SIZE];
size_t EID_DataSize;
}LPA_GET_EID;
typedef struct
{
// EUICC Info
unsigned char EUICC_Info_Data[LPA_GET_EUICC_BUFFER_MAX_SIZE];
size_t EUICC_Info_DataSize;
}LPA_GET_EUICC_INFO;
typedef struct
{
size_t countProfileInstalled;
size_t countProfileTotal;
} LPA_DOWNLOAD_PROFILE_RESULT;
typedef struct
{
size_t countNotificationDetected; // Before sending
size_t countNotificationSend; // really send
} LPA_SENDING_NOTIFICATION_RESULT;
typedef enum
{
LPA_NOTIFICATION_INSTALL = 0,
LPA_NOTIFICATION_ENABLE = 1,
LPA_NOTIFICATION_DISABLE = 2,
LPA_NOTIFICATION_DELETE = 3,
LPA_NOTIFICATION_UNKNOWN = 0xFF
} LPA_NOTIFICATION_EVENT;
typedef struct {
bool resultOK;
unsigned char cancelSessionResponse_RawData[LPA_CANCEL_SESSION_RESPONSE_BUFFER_SIZE];
size_t cancelSessionResponse_RawDataSize;
}CANCEL_SESSION_RESPONSE;
typedef struct
{
// SMDP Address
char smdxAddr[LPA_SMDP_ADDRESS_SIZE];
// activation code
char matchingId[LPA_MATCHING_ID_SIZE];
// OID
char oid[LPA_OID_SIZE];
// Confirmation Code Required Flag
char ccRequiredFlag[LPA_CC_REQUIRED_FLAG_SIZE];
} ACTIVATION_CODE;
typedef struct {
char eventId[LPA_MATCHING_ID_SIZE];
char rspServerAddress[LPA_SMDP_ADDRESS_SIZE];
unsigned char EID_RawData[LPA_GET_EID_BUFFER_SIZE];
bool forwardingIndicator;
}LPA_EVENT_RECORD;
typedef struct {
size_t countEvent;
LPA_EVENT_RECORD eventRecordList[LPA_MAX_EVENT_RECORD];
}EVENT_RECORD_LIST;
typedef struct {
char address_Data[LPA_SMDP_ADDRESS_SIZE];
size_t address_DataSize;
}ADDRESS_DATA;
typedef enum
{
LPA_DELETE_NOTIFICATION_OK = 0,
LPA_DELETE_NOTIFICATION_NOTHING_TO_DELETE = 1,
LPA_DELETE_NOTIFICATION_UNDEFINED_ERROR = 127,
LPA_DELETE_NOTIFICATION_UNKNOWN = 0xFF
}LPA_DELETE_NOTIFICATION_STATUS;
typedef struct
{
uint16_t seqNumber;
LPA_NOTIFICATION_EVENT profileManagementOperation;
unsigned char notificationAddressRawData[LPA_MAX_NOTIFICATION_ADDRESS_RAW_DATA_SIZE];
size_t notificationAddressRawDataSize;
}LPA_PROFILE_NOTIFICATION_METADATA;
typedef struct
{
size_t countNotification;
LPA_PROFILE_NOTIFICATION_METADATA notificationMetadataList[LPA_MAX_PROFILE_NOTIFICATION_LIST_ELEMENT];
} LPA_PROFILE_NOTIFICATION_LIST;
typedef enum
{
LPA_MEMORY_RESET_OK = 0,
LPA_MEMORY_RESET_NOTHING_TO_DELETE = 1,
LPA_MEMORY_RESET_CAT_BUSY = 5,
LPA_MEMORY_RESET_UNDEFINED_ERROR = 127,
LPA_MEMORY_RESET_UNKNOWN = 0xFF
}LPA_MEMORY_RESET_STATUS;
// Cancel Session codes
typedef enum
{
LPA_CANCEL_SESSION_END_USER_REJECTION = 0,
LPA_CANCEL_SESSION_POSTPONED = 1,
LPA_CANCEL_SESSION_TIME_OUT = 2,
LPA_CANCEL_SESSION_PPR_NOT_ALLOWED = 3,
LPA_CANCEL_SESSION_METADATA_MISMATCH = 4,
LPA_CANCEL_SESSION_LOAD_BPP_EXECUTION_ERROR = 5,
LPA_CANCEL_SESSION_UNDEFINED_REASON = 127
}LPA_CANCEL_SESSION_REASON;
static const unsigned int LPA_ALLOWED_CANCEL_SESSION_CODE_LIST[] = {0, 1, 2, 3, 4, 5, 127};
#define LPA_ALLOWED_CANCEL_SESSION_CODE_LIST_SIZE 7
// User consent type for Callback. These are binary mask, they can be mixed together or checked individually.
typedef enum
{
LPA_USR_CONSENT_NO_PPR = 0x00,
LPA_USR_CONSENT_PPR1 = 0x01,
LPA_USR_CONSENT_PPR2 = 0x02,
LPA_USR_CONSENT_PROFILE_WITH_PPR1_ENABLED_PRESENT = 0x04
}LPA_USER_CONSENT_TYPES;
// Management of retry for chained GetResponse issue with modems (0x6D00 issue, other SW may be discovered) through LPA_SDK__NUMBER_OF_RETRY_FOR_CHAINED_GET_RESPONSE
// If not defined or minus than 1 retry mechanism will be disabled
#ifndef LPA_SDK__NUMBER_OF_RETRY_FOR_CHAINED_GET_RESPONSE
#define LPA_RETRY_CHAINED_GET_RESPONSE_MGT false // Do not modify this value!
#define LPA_LOOP_NUMBER_FOR_CHAINED_GET_RESPONSE 1 // Do not modify this value ! Must be AT LEAST value "1" else commands will be NOT played.
#elif LPA_SDK__NUMBER_OF_RETRY_FOR_CHAINED_GET_RESPONSE < 1
#define LPA_RETRY_CHAINED_GET_RESPONSE_MGT false // Do not modify this value!
#define LPA_LOOP_NUMBER_FOR_CHAINED_GET_RESPONSE 1 // Do not modify this value! Must be AT LEAST value "1" else commands will be NOT played.
#else
#define LPA_RETRY_CHAINED_GET_RESPONSE_MGT true // Do not modify this value!
#define LPA_LOOP_NUMBER_FOR_CHAINED_GET_RESPONSE LPA_SDK__NUMBER_OF_RETRY_FOR_CHAINED_GET_RESPONSE + 1 // Do not modify this expression ! Must be +1 to include initial command run to retries.
#endif // defined LPA_SDK__NUMBER_OF_RETRY_FOR_CHAINED_GET_RESPONSE
// Management of maximum size of data send through APDU. Need to limit size due to some modems not supporting 261 bytes (So 522 characters) in case 4 APDU
// If not defined default value of 0xFF will be used.
// If out of bounds will issue an error and stop compilation. If #error ignored by compiler used, value will be set to 0xFF to show that something is wrong.
// Boundaries for usable limits shall not be changed.
// Minimum size is fixed to 0x52 (82) due to eUICC limitations that does not support chained Store Data for some commands. 1 byte has been reserved for security.
// - Set Nickname: 0x51 (81) bytes minimum needed
// - Enable / Disable / Delete profile: 0x14 (20) bytes minimum needed
// - Any download command, Set default DP, Send Notification: Tested OK with 10 bytes size limitation
#ifndef LPA_SDK__MAX_SIZE_OF_DATA_IN_STORE_DATA_APDU
#define LPA_STORE_DATA_APDU_DATA_SIZE_MAX 0xFF
#elif LPA_SDK__MAX_SIZE_OF_DATA_IN_STORE_DATA_APDU < 0x52 // Lower limit given by Set Nickname
#define LPA_STORE_DATA_APDU_DATA_SIZE_MAX 0xFF
#error LPA_SDK__MAX_SIZE_OF_DATA_IN_STORE_DATA_APDU is out of authorized range ( decimal: [82,255 ] , hexa: [0x52,0xFF] ).
#elif LPA_SDK__MAX_SIZE_OF_DATA_IN_STORE_DATA_APDU > 0xFF // Upper limit, max possible in an APDU
#define LPA_STORE_DATA_APDU_DATA_SIZE_MAX 0xFF
#error LPA_SDK__MAX_SIZE_OF_DATA_IN_STORE_DATA_APDU is out of authorized range ( decimal: [82,255 ] , hexa: [0x52,0xFF] ).
#else
#define LPA_STORE_DATA_APDU_DATA_SIZE_MAX LPA_SDK__MAX_SIZE_OF_DATA_IN_STORE_DATA_APDU
#endif
// List of tags allowed in deviceCapabilities object when extensibility is not supported
static const unsigned char LPA_LIST_ALLOWED_DEVICE_TAGS_NO_EXTENSIBILITY_SUPPORT[] = {0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87};
#define LPA_LIST_ALLOWED_DEVICE_TAGS_NO_EXTENSIBILITY_SUPPORT_SIZE 8
/////////////////////////////////
// API ERROR
/////////////////////////////////
typedef enum {
LPA_NO_ERROR = 0,
// 0x0001 - 0x0999 => Sifar custom error
SF_LPA_CUSTOM_ERROR_CMD_UNKNOWN = 0x0001, //Unknow command
SF_LPA_CUSTOM_ERROR_MEMORY, //Memory error
SF_LPA_CUSTOM_ERROR_USBNET, //Network error
SF_LPA_CUSTOM_ERROR_LPA_ERROR, //LPA initialization failed
SF_LPA_CUSTOM_ERROR_SIM_NOT_SUPPORTED, //SIM not supported
SF_LPA_CUSTOM_ERROR_SIM_EID, //SIM EID error
SF_LPA_CUSTOM_ERROR_HASH, //LPA command hash error
SF_LPA_CUSTOM_ERROR_ACTIVATION_CODE, //LPA sms command activation code error
SF_LPA_CUSTOM_ERROR_INVALID_ICCID, //LPA sms command invalid ICCID
SF_LPA_CUSTOM_ERROR_PROFILE_ENABLED, //The profile has been enabled
SF_LPA_CUSTOM_ERROR_NETWORK_REJECTED, //Network rejected
// 0x1001 - 0x1999 => Configuration error
LPA_NOT_INITIALIZED = 0x1001,
// 0x2001 - 0x2FFF => Common error
LPA_ERROR_INVALID_PARAMETER = 0x2001,
LPA_ERROR_INSUFFICIENT_BUFFER,
LPA_ERROR_INVALID_SW,
LPA_ERROR_ISDR_NOT_SELECTED,
LPA_ERROR_ISDR_ALREADY_SELECTED,
LPA_ERROR_SE_MEDIA_NOT_INITIALIZED,
LPA_ERROR_SE_MEDIA_CONTEXT_NOT_ESTABLISHED,
LPA_ERROR_SE_MEDIA_READER_CONNECTION,
LPA_ERROR_SE_MEDIA_CONTEXT_NOT_RELEASED,
LPA_ERROR_SE_MEDIA_READER_NOT_DISCONNECTED,
LPA_ERROR_SE_MEDIA_UNABLE_TO_SELECT_ISDR,
LPA_ERROR_INVALID_GET_PROFILES_INFO_EXCHANGE,
LPA_ERROR_INVALID_GET_EID_EXCHANGE,
LPA_ERROR_INVALID_GET_EUICC_ADDRESS,
LPA_ERROR_INVALID_MEMORY_RESET_EXCHANGE,
LPA_ERROR_INVALID_SET_DEFAULT_SMDP_ADDRESS,
LPA_ERROR_INVALID_GET_SMDP_ADDRESS,
LPA_ERROR_INVALID_GET_SMDS_ADDRESS,
LPA_ERROR_PARAMETER_NOT_AUTHORIZED,
LPA_ERROR_UNKNOWN_PARAMETER,
LPA_ERROR_INVALID_PARAMETER_TYPE,
LPA_ERROR_INCORRECT_PARAMETER_TYPE,
LPA_ERROR_PARAMETER_INTERNAL_ERROR,
LPA_ERROR_UNABLE_TO_INIT_LOG,
LPA_ERROR_MISSING_CONFIG_FILE, // 23/12/2019 No longer used
LPA_ERROR_UNABLE_TO_LOAD_CONFIG_FILE, // 23/12/2019 No longer used
LPA_ERROR_CONFIG_FILE_MISSING_MANDATORY_KEY, // 06/06/2019 No longer used
LPA_ERROR_CONFIG_FILE_INCORRECT_KEY_VALUE,
LPA_ERROR_UNABLE_TO_INITIALIZE_LPA_MANAGER,
LPA_ERROR_UNABLE_TO_INITIALIZE_HTTP_MEDIA,
LPA_ERROR_EXTENDED_API_UNAVAILABLE,
LPA_ERROR_PROCESSING_ERROR,
// Local Profile Management
LPA_ERROR_LOCAL_PROFILE_NOT_FOUND = 0x2101,
LPA_ERROR_LOCAL_PROFILE_INCORRECT_STATE,
LPA_ERROR_LOCAL_PROFILE_CAT_BUSY,
LPA_ERROR_LOCAL_PROFILE_INCORRECT_CARD_RESPONSE,
LPA_ERROR_LOCAL_PROFILE_UNKNOWN_ERROR,
LPA_ERROR_LOCAL_PROFILE_NOTHING_TO_DELETE,
LPA_ERROR_LOCAL_PROFILE_UNDEFINED_ERROR,
LPA_ERROR_LOCAL_PROFILE_UNABLE_TO_EXTRACT_DATA,
LPA_ERROR_LOCAL_PROFILE_ICCID_OR_AID_NOT_FOUND, // enableResult => iccidOrAidNotFound
LPA_ERROR_LOCAL_PROFILE_NOT_IN_DISABLE_STATE, // enableResult => profileNotInDisabledState
LPA_ERROR_LOCAL_PROFILE_DISALLOWED_BY_POLICY, // enableResult => disallowedByPolicy
LPA_ERROR_LOCAL_PROFILE_WRONG_PROFILE_REENABLING, // enableResult => wrongProfileReenabling
LPA_ERROR_LOCAL_PROFILE_NOT_IN_ENABLE_STATE, // disableResult => profileNotInEnabledState
LPA_ERROR_LOCAL_PROFILE_INVALID_DATA_EXCHANGE,
// Notification management
LPA_ERROR_NOTIFICATION_INCORRECT_CARD_RESPONSE = 0x2201,
LPA_ERROR_NOTIFICATION_NOTHING_TO_DELETE,
LPA_ERROR_NOTIFICATION_UNDEFINED_ERROR,
LPA_ERROR_NOTIFICATION_UNKNOWN_ERROR,
LPA_ERROR_NOTIFICATION_INVALID_CARD_DATA,
// Download Profile management
LPA_ERROR_DOWNLOAD_PROFILE_PARAMETER_ERROR = 0x2301,
LPA_ERROR_INVALID_GET_EUICC_INFO,
LPA_ERROR_INVALID_GET_UICC_CHALLENGE,
LPA_ERROR_INVALID_SERVER_ADDRESS,
LPA_ERROR_FAILED_INITIAL_AUTHENTICATION,
LPA_ERROR_FAILED_AUTHENTICATE_SERVER,
LPA_ERROR_FAILED_AUTHENTICATE_CLIENT,
LPA_ERROR_AUTHENTICATE_CLIENT_EXCHANGE,
LPA_ERROR_FAILED_PREPARE_DOWNLOAD,
LPA_ERROR_INVALID_ACTIVATION_CODE,
LPA_ERROR_INVALID_CTX_PARAM,
LPA_ERROR_INVALID_TRANSACTIONID,
LPA_ERROR_INVALID_AUTHENTICATE_SERVER_RESPONSE,
LPA_ERROR_INVALID_PREPARE_DOWNLOAD_RESPONSE,
LPA_ERROR_INVALID_MATCHINGID_OR_DEVICE_INFO_TLV, // 03/09/2020 Confirmed not used anymore
LPA_ERROR_INVALID_DEVICE_INFO_TLV,
LPA_ERROR_FAILED_GET_BOUND_PROFILE_PACKAGE,
LPA_ERROR_FAILED_LOAD_BPP,
LPA_ERROR_FAILED_INITIAL_SECURITY_CHANNEL,
LPA_ERROR_FAILED_CONFIGURE_ISDP,
LPA_ERROR_FAILED_STORE_META_DATA,
LPA_ERROR_FAILED_REPLACE_SESSION_KEY,
LPA_ERROR_FAILED_LOAD_PROFILE_ELEMENTS,
LPA_ERROR_FAILED_GET_DATA_FROM_ACTIVATION_CODE,
LPA_ERROR_INVALID_PIR_RESPONSE,
LPA_ERROR_GET_INTERNAL_SERVER_ERROR,
LPA_ERROR_CJSON_PARSE_FAILURE,
LPA_ERROR_FAILED_SEND_NOTIFICATION_OR_NOT_GET_STATUS_CODE,
LPA_ERROR_SERVER_COMMUNICATION_ISSUE,
LPA_ERROR_INVALID_EVENT_ID,
LPA_ERROR_INVALID_RSP_SERVER_ADDRESS,
LPA_ERROR_INVALID_EVENT_ENTRIES,
LPA_ERROR_NO_EVENT_RECORD_FOUND, // This error code is now obsolete since V1.6
LPA_ERROR_CONFIRMATION_CODE_MISSING_OR_EMPTY,
LPA_ERROR_SERVER_RETURN_404_STATUS_CODE,
LPA_ERROR_SERVER_RETURN_500_STATUS_CODE,
LPA_ERROR_SE_MEDIA_UNABLE_TO_UNSELECT_ISDR,
LPA_ERROR_INVALID_SERVERSIGNED1,
LPA_ERROR_INVALID_SERVERSIGNATURE1,
LPA_ERROR_INVALID_EUICCCIPKIDTOBEUSED,
LPA_ERROR_INVALID_SERVERCERTIFICATE,
LPA_ERROR_INVALID_SERVER_RESPONSE,
LPA_ERROR_FAILED_CANCEL_SESSION,
LPA_ERROR_INVALID_PROFILE_METADATA,
LPA_ERROR_INVALID_GET_RAT,
LPA_ERROR_PPR_NOT_ALLOWED,
LPA_ERROR_DOWNLOAD_SESSION_CANCELED_BY_USER,
LPA_ERROR_OID_MISMATCH,
LPA_ERROR_INVALID_BPP_DATA,
LPA_ERROR_SERVER_RETURN_ERROR_STATUS, // This apply when server return an error, in JSON code for example
// 0x8000 - 0x9999 => SE Media error
SE_MEDIA_ERROR_BROKEN_PIPE = 0x8000,
SE_MEDIA_E_CANCELLED,
SE_MEDIA_E_CANT_DISPOSE,
SE_MEDIA_E_CARD_UNSUPPORTED,
SE_MEDIA_E_DUPLICATE_READER,
SE_MEDIA_E_FILE_NOT_FOUND,
SE_MEDIA_E_INSUFFICIENT_BUFFER,
SE_MEDIA_E_INVALID_ATR,
SE_MEDIA_E_INVALID_HANDLE,
SE_MEDIA_E_INVALID_PARAMETER,
SE_MEDIA_E_INVALID_TARGET,
SE_MEDIA_E_INVALID_VALUE,
SE_MEDIA_E_NO_MEMORY,
SE_MEDIA_E_NO_READERS_AVAILABLE,
SE_MEDIA_E_NO_SMARTCARD,
SE_MEDIA_E_NOT_READY,
SE_MEDIA_E_PROTO_MISMATCH,
SE_MEDIA_E_READER_UNAVAILABLE,
SE_MEDIA_E_READER_UNSUPPORTED,
SE_MEDIA_E_SERVER_TOO_BUSY,
SE_MEDIA_E_SERVICE_STOPPED,
SE_MEDIA_E_SHARING_VIOLATION,
SE_MEDIA_E_SYSTEM_CANCELLED,
SE_MEDIA_E_TIMEOUT,
SE_MEDIA_E_UNEXPECTED,
SE_MEDIA_E_UNKNOWN_CARD,
SE_MEDIA_E_UNKNOWN_READER,
SE_MEDIA_W_REMOVED_CARD,
SE_MEDIA_W_RESET_CARD,
SE_MEDIA_W_UNSUPPORTED_CARD,
SE_MEDIA_E_CHAINING_GET_RESPONSE, // Can be issued only if LPA_SDK__DEACTIVATE_RETRY_FOR_CHAINED_GET_RESPONSE is not defined
} LPA_API_ERROR;
typedef enum
{
LPA_PARAMETER_TYPE_BOOL, // bool
LPA_PARAMETER_TYPE_LONG, // long
LPA_PARAMETER_TYPE_STRING, // char*
LPA_PARAMETER_TYPE_UNKNOWN = 1664, // Unknown type; Must be the latest on the enum
} LPA_PARAMETER_TYPE;
// List of settable parameters. Memory contain initialization is done by lpaManagerGetFullParametersList()
// Size constants are fixed in lpasdk_api.h, shall fit all available parameters.
typedef struct
{
size_t parametersCount;
char parametersList[LPA_MAX_PARAMETERS_LIST][LPA_MAX_PARAMETERS_LIST_ELEMENT_SIZE];
LPA_PARAMETER_TYPE parametersTypeList[LPA_MAX_PARAMETERS_LIST];
}LPA_PARAMETERS_LIST;
typedef struct
{
LPA_API_ERROR apiErrorCode;
char* ptrApiErrorDescription;
} LPA_API_ERROR_DESCRIPTION;
#if defined (LPA_SDK__PLATFORM_WIN) || defined (LPA_SDK__PLATFORM_CYGWIN)
#define EXPORT_DLL __declspec(dllexport)
#else
// to add default visibility on LINUX
//#define EXPORT_DLL __attribute__ ((visibility ("default") ))
#define EXPORT_DLL
#endif
// LPA SDK API versionning
EXPORT_DLL const LPA_API_VERSION* lpaGetApiVersion();
// LPA SDK Initialization
EXPORT_DLL bool lpaInitialize(const char* ptrLpaFolder);
// @Since: API 1.6
EXPORT_DLL bool lpaInitializeWithInputOutputFolder(const char* ptrLpaInputFolder, const char* ptrLpaOutputFolder);
// Manage LPA SDK versionning
EXPORT_DLL bool lpaGetVersion(LPA_VERSION* ptrLpaVersion);
// LPA SDK Uninitialization
EXPORT_DLL bool lpaUninitialize();
// LPA SDK IS initialized
EXPORT_DLL bool lpaIsInitialized();
// LPA SDK => GetErrorCode
EXPORT_DLL LPA_API_ERROR lpaGetErrorCode();
EXPORT_DLL const char* lpaGetErrorCodeDescription(LPA_API_ERROR apiError);
// LPA SDK Configuration
EXPORT_DLL bool lpaSetConfigParameter(const char* ptrParameterName, LPA_PARAMETER_TYPE parameterType, const void* ptrParameterValue);
EXPORT_DLL bool lpaGetConfigParameter(const char* ptrParameterName, LPA_PARAMETER_TYPE parameterType, void* ptrParameterValue, size_t parameterValueMaxSize);
EXPORT_DLL bool lpaIsConfigParameterExist(const char* ptrParameterName, LPA_PARAMETER_TYPE* ptrParameterType, bool* ptrIsExist);
// LPA SDK Reader
EXPORT_DLL bool lpaGetReaderList(LPA_SE_MEDIA_READER_NAME_INFO * readerNameInfoList, size_t readerNameInfoMax, size_t* countReader);
EXPORT_DLL bool lpaGetProfilesInfo(LPA_GET_PROFILES_INFO*);
EXPORT_DLL bool lpaGetProfilesNumber(size_t*);
EXPORT_DLL bool lpaGetEID(LPA_GET_EID*);
EXPORT_DLL bool lpaGetEUICCInfo(LPA_GET_EUICC_INFO* ptrGetEUICCInfo);
EXPORT_DLL bool lpaMemoryReset(const unsigned char* memoryResetOptionParameter, const size_t memoryResetOptionSize);
EXPORT_DLL bool lpaSendPendingNotification(LPA_EventCallback* ptrLpaEventCallback, LPA_SENDING_NOTIFICATION_RESULT* ptrSendingNotificationResult);
EXPORT_DLL bool lpaEnableProfileByIccid(const unsigned char* ptrProfileId, size_t profileIdSize);
EXPORT_DLL bool lpaDisableProfileByIccid(const unsigned char* ptrProfileId, size_t profileIdSize);
EXPORT_DLL bool lpaDeleteProfileByIccid(const unsigned char* ptrProfileId, size_t profileIdSize);
EXPORT_DLL bool lpaSetDefaultSMDPAddress(const char* ptrSMDPAddr);
EXPORT_DLL bool lpaGetSMDPAddress(ADDRESS_DATA* ptrAddressData);
EXPORT_DLL bool lpaGetSMDSAddress(ADDRESS_DATA* ptrAddressData);
EXPORT_DLL bool lpaDownloadProfile(const char * ptrActivationCodeStr, const LPA_EventCallback* ptrLpaEventCallback, LPA_DOWNLOAD_PROFILE_RESULT* ptrDownloadProfileResult);
EXPORT_DLL bool lpaDownloadProfileWithConfirmationCode(const char * ptrActivationCodeStr, const char * ptrConfirmationCodeStr, const LPA_EventCallback* ptrLpaEventCallback, LPA_DOWNLOAD_PROFILE_RESULT* ptrDownloadProfileResult);
EXPORT_DLL bool lpaDownloadProfileWithDefaultSMDPAddress(const LPA_EventCallback* ptrLpaEventCallback, LPA_DOWNLOAD_PROFILE_RESULT* ptrDownloadProfileResult);
EXPORT_DLL bool lpaDownloadProfileWithSMDSAddress( const LPA_EventCallback* ptrLpaEventCallback, LPA_DOWNLOAD_PROFILE_RESULT* ptrDownloadProfileResult);
EXPORT_DLL bool lpaSetNicknameByIccid(const unsigned char* ptrProfileId, size_t profileIdSize, const unsigned char* ptrNickname, size_t nickNameSize);
EXPORT_DLL void lpaSetLogLevel(unsigned char logLevel);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif // LPA_SDK__CORE_API_H

View File

@ -0,0 +1,73 @@
/*
* Copyright 2018-2021 THALES group. All Rights Reserved.
*
* Project name: LPASDK.
* Platform: Windows, Linux.
* Language: C/C++
*
* Except if otherwise stated in a NOTICE file provided by Thales together with the software, below conditions are applicable by default.
*
* This computer program includes confidential and proprietary information of Thales and is a trade secret of
* Thales. All use, disclosure, and/or reproduction is prohibited unless authorized in writing by Thales.
*
* The computer program is provided "AS IS" without warranty of any kind. Thales makes no
* warranties to any person or entity with respect to the computer program and disclaims all other warranties,
* expressed or implied. Thales expressly disclaims any implied warranty of merchantability, fitness for particular
* purpose and any warranty which may arise from course of performance, course of dealing, or usage of trade. Further
* Thales does not warrant that the computer program will meet requirements or that operation of the computer program
* will be uninterrupted or error-free.
*
*/
#ifndef LPA_SDK__CORE_EX_API_H
#define LPA_SDK__CORE_EX_API_H
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
#include "lpasdk/api/lpasdk_api.h"
#include <stdint.h>
typedef struct
{
long countMemoryAllocCall;
long countMemoryFreeCall;
long currentMemoryBlockAllocated;
long currentMemoryAllocated;
long totalMemoryAllocated;
long maxMemoryAllocated;
long maxMemoryBlockAllocated;
}LPA_MEMORY_STATUS;
// Extented API
/////////////////////////////////////////////
EXPORT_DLL bool lpaExGetExtraVersion(char* ptrVersionBuffer, size_t versionBufferMaxSize);
// Since LPASDK 1.5, moved on Extended API
EXPORT_DLL bool lpaExGetFullParametersList(LPA_PARAMETERS_LIST * ptrLpaParametersList);
// LPA SDK SE Media Card Reset
EXPORT_DLL bool lpaExCardReset();
EXPORT_DLL bool lpaExGetProfileNotificationList(LPA_PROFILE_NOTIFICATION_LIST* ptrProfileNotificationList);
EXPORT_DLL bool lpaExClearProfileNotification(uint16_t sequenceNumber);
EXPORT_DLL bool lpaExWriteMemoryStatusDumpToLog();
EXPORT_DLL bool lpaExGetMemoryStatus(LPA_MEMORY_STATUS* prtMemoryStatus);
EXPORT_DLL bool lpaExCheckMemoryAllocated();
EXPORT_DLL LPA_API_ERROR_DESCRIPTION* lpaExGetListErrorCodeDescription();
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif // LPA_SDK__CORE_EX_API_H

View File

@ -0,0 +1,59 @@
/*
* Copyright 2018-2021 THALES group. All Rights Reserved.
*
* Project name: LPASDK.
* Platform: Windows, Linux.
* Language: C/C++
*
* Except if otherwise stated in a NOTICE file provided by Thales together with the software, below conditions are applicable by default.
*
* This computer program includes confidential and proprietary information of Thales and is a trade secret of
* Thales. All use, disclosure, and/or reproduction is prohibited unless authorized in writing by Thales.
*
* The computer program is provided "AS IS" without warranty of any kind. Thales makes no
* warranties to any person or entity with respect to the computer program and disclaims all other warranties,
* expressed or implied. Thales expressly disclaims any implied warranty of merchantability, fitness for particular
* purpose and any warranty which may arise from course of performance, course of dealing, or usage of trade. Further
* Thales does not warrant that the computer program will meet requirements or that operation of the computer program
* will be uninterrupted or error-free.
*
*/
#ifndef LPA_SDK__API_SE_MEDIA_H
#define LPA_SDK__API_SE_MEDIA_H
// Increase size of Reader Name buffer in Debug mode to allow more space for test command when Windows test driver DLL is used
#if defined(_DEBUG) && defined(LPA_SDK__PLATFORM_WIN) && defined(LPA_SDK__SEMEDIA_DRIVER_EXTERNAL)
#define LPA_CFG_READER_NAME_MAX_SIZE 255
#else
#define LPA_CFG_READER_NAME_MAX_SIZE 100
#endif // _DEBUG & LPA_SDK__PLATFORM_WIN & LPA_SDK__SEMEDIA_DRIVER_EXTERNAL
typedef struct
{
char readerName[LPA_CFG_READER_NAME_MAX_SIZE];
} LPA_SE_MEDIA_READER_NAME_INFO;
typedef enum seMediaCardStatus
{
SE_MEDIA_STATUS_SCARD_UNKNOWN = 0x0001,
SE_MEDIA_STATUS_SCARD_ABSENT = 0x0002, // There is no card in the reader.
SE_MEDIA_STATUS_SCARD_PRESENT = 0x0004, // There is a card in the reader, but it has not been moved into position for use.
SE_MEDIA_STATUS_SCARD_SWALLOWED = 0x0008, // There is a card in the reader in position for use.The card is not powered.
SE_MEDIA_STATUS_SCARD_POWERED = 0x0010, // Power is being provided to the card, but the reader driver is unaware of the mode of the card.
SE_MEDIA_STATUS_SCARD_NEGOTIABLE = 0x0020, // The card has been reset and is awaiting PTS negotiation.
SE_MEDIA_STATUS_SCARD_SPECIFIC = 0x0040, // The card has been reset and specific communication protocols have been established.
SE_MEDIA_STATUS_REMOVED_CARD = 0x80001, // The smart card has been removed(SCARD_W_REMOVED_CARD)
SE_MEDIA_RESET_CARD, // The smart card has been reset(SCARD_W_RESET_CARD)
}SE_MEDIA_CARD_STATUS;
typedef enum seMediaDisconnectCardParam
{
SE_MEDIA_DISCONNECT_LEAVE_CARD = 0, // Don't do anything special on close
SE_MEDIA_DISCONNECT_RESET_CARD, // Reset the card on close
SE_MEDIA_DISCONNECT_UNPOWER_CARD, // Power down the card on close
}SE_MEDIA_DISCONNECT_CARD_PARAM;
#endif // LPA_SDK__API_SE_MEDIA_H

View File

@ -0,0 +1,71 @@
/*
* Copyright 2018-2021 THALES group. All Rights Reserved.
*
* Project name: LPASDK.
* Platform: Windows, Linux.
* Language: C/C++
*
* Except if otherwise stated in a NOTICE file provided by Thales together with the software, below conditions are applicable by default.
*
* This computer program includes confidential and proprietary information of Thales and is a trade secret of
* Thales. All use, disclosure, and/or reproduction is prohibited unless authorized in writing by Thales.
*
* The computer program is provided "AS IS" without warranty of any kind. Thales makes no
* warranties to any person or entity with respect to the computer program and disclaims all other warranties,
* expressed or implied. Thales expressly disclaims any implied warranty of merchantability, fitness for particular
* purpose and any warranty which may arise from course of performance, course of dealing, or usage of trade. Further
* Thales does not warrant that the computer program will meet requirements or that operation of the computer program
* will be uninterrupted or error-free.
*
*/
#ifndef LPA_SDK__CORE_BERTLV_H
#define LPA_SDK__CORE_BERTLV_H
#include <stdint.h>
#include <stdlib.h>
#include <stdbool.h>
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
#include "lpasdk/core/lpa_core.h"
#include "lpasdk/core/rawdata_object.h"
typedef struct
{
uint16_t tag;
uint32_t length;
unsigned char* value;
}BeerTLV, *PtrBeerTLV;
//typedef struct BerTLVList BerTLVList;
typedef struct BerTLVList
{
uint16_t index;
BeerTLV* berTLV;
struct BerTLVList* ptrNext;
} BerTLVList;
UT_EXPORT_DLL BeerTLV* berTLV_create(uint16_t tag, uint32_t length, const unsigned char* ptrValue);
UT_EXPORT_DLL BeerTLV* berTLV_extractTagUInt8(uint8_t tag, const unsigned char* ptrRawData, uint32_t rawDataSize, bool* ptrIsTagFound);
UT_EXPORT_DLL BeerTLV* berTLV_extractTagUInt16(uint16_t tag, const unsigned char* ptrRawData, uint32_t rawDataSize, bool* ptrIsTagFound);
UT_EXPORT_DLL BerTLVList* berTLV_extractList(const unsigned char* ptrRawData, uint32_t rawDataSize, uint8_t* ptrCountTLVFound);
UT_EXPORT_DLL RawDataObject* berTLV_buildRawDataObject(const BeerTLV* ptrBerTlv);
UT_EXPORT_DLL RawDataObject* berTLV_createAndBuildRawDataObject(uint16_t tag, uint32_t length, const unsigned char* ptrValue);
UT_EXPORT_DLL bool berTLV_freeBerTLV(BeerTLV* ptrBerTLV);
UT_EXPORT_DLL bool berTLV_freeBerTLVList(BerTLVList* ptrBerTLVList);
// Some macro to help memory cleanup
#define ERASE_BERTLV(_ptr) if ((_ptr) != NULL) { berTLV_freeBerTLV( (_ptr) ); (_ptr) = NULL;}
#define ERASE_BERTLV_LIST(_ptr) if ((_ptr) != NULL) { berTLV_freeBerTLVList( (_ptr) ); (_ptr) = NULL;}
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif // LPA_SDK__CORE_BERTLV_H

View File

@ -0,0 +1,51 @@
/*
* Copyright 2018-2021 THALES group. All Rights Reserved.
*
* Project name: LPASDK.
* Platform: Windows, Linux.
* Language: C/C++
*
* Except if otherwise stated in a NOTICE file provided by Thales together with the software, below conditions are applicable by default.
*
* This computer program includes confidential and proprietary information of Thales and is a trade secret of
* Thales. All use, disclosure, and/or reproduction is prohibited unless authorized in writing by Thales.
*
* The computer program is provided "AS IS" without warranty of any kind. Thales makes no
* warranties to any person or entity with respect to the computer program and disclaims all other warranties,
* expressed or implied. Thales expressly disclaims any implied warranty of merchantability, fitness for particular
* purpose and any warranty which may arise from course of performance, course of dealing, or usage of trade. Further
* Thales does not warrant that the computer program will meet requirements or that operation of the computer program
* will be uninterrupted or error-free.
*
*/
#ifndef HTTPMEDIA_BASE_H
#define HTTPMEDIA_BASE_H
#include <stdbool.h>
#include "lpasdk/core/httpmedia_option_type.h"
#include "lpasdk/api/lpasdk_api.h"
typedef struct THTTPMedia {
void* _childStruct;
bool (*httpMediaHttpExecuteInit) (const struct THTTPMedia*);
bool (*httpMediaPost) (const struct THTTPMedia*, const char* ptrCertificatePath, const char* ptrTargetURL, const char* ptrPostdata, long* ptrHttpCode);
void (*httpMediaHttpExecuteCleanup) (const struct THTTPMedia*);
char* (*httpMediaGetBufferResponse) (const struct THTTPMedia*);
bool (*httpMediaSetBooleanOption) (const struct THTTPMedia*, HttpMediaOptionType optionType, bool enabled);
bool (*httpMediaGetBooleanOption) (const struct THTTPMedia*, HttpMediaOptionType optionType, bool* ptrEnabled);
bool (*httpMediaSetLongOption) (const struct THTTPMedia*, HttpMediaOptionType optionType, long value);
bool (*httpMediaGetLongOption) (const struct THTTPMedia*, HttpMediaOptionType optionType, long* ptrValue);
// EventErrorCallback support
bool(*httpMediaSetCallbackEventExecutionError) (const struct THTTPMedia*, LPA_EVENT_EXECUTION_ERROR lpaEventExecutionErrorCallback);
} THTTPMedia;
THTTPMedia* New_HTTPMediaBase();
#endif /* HTTPMEDIA_BASE_H */

View File

@ -0,0 +1,66 @@
/*
* Copyright 2018-2021 THALES group. All Rights Reserved.
*
* Project name: LPASDK.
* Platform: Windows, Linux.
* Language: C/C++
*
* Except if otherwise stated in a NOTICE file provided by Thales together with the software, below conditions are applicable by default.
*
* This computer program includes confidential and proprietary information of Thales and is a trade secret of
* Thales. All use, disclosure, and/or reproduction is prohibited unless authorized in writing by Thales.
*
* The computer program is provided "AS IS" without warranty of any kind. Thales makes no
* warranties to any person or entity with respect to the computer program and disclaims all other warranties,
* expressed or implied. Thales expressly disclaims any implied warranty of merchantability, fitness for particular
* purpose and any warranty which may arise from course of performance, course of dealing, or usage of trade. Further
* Thales does not warrant that the computer program will meet requirements or that operation of the computer program
* will be uninterrupted or error-free.
*
*/
#ifndef HTTPMEDIAMANAGER_H
#define HTTPMEDIAMANAGER_H
#include <stdbool.h>
#include "lpasdk/core/httpmedia_option_type.h"
#include "lpasdk/core/lpa_core.h"
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
UT_EXPORT_DLL bool httpMediaManagerInitialize();
UT_EXPORT_DLL bool httpMediaManagerIsInitialized();
UT_EXPORT_DLL bool httpMediaManagerDelete();
bool httpMediaManagerConfigure();
bool httpMediaManagerSetBooleanOption(HttpMediaOptionType optionType, bool enabled);
bool httpMediaManagerGetBooleanOption(HttpMediaOptionType optionType, bool* ptrEnabled);
bool httpMediaManagerSetLongOption(HttpMediaOptionType optionType, long value);
bool httpMediaManagerGetLongOption(HttpMediaOptionType optionType, long* ptrValue);
bool httpMediaManagerSetCallbackEventExecutionError(LPA_EVENT_EXECUTION_ERROR lpaEventExecutionErrorCallback);
char* httpMediaManagerPost(const char* ptrCertificatePath, const char* ptrTargetURL, const char* ptrPostdata, bool* ptrIsSuccess, long* ptrHttpCode);
char* httpMediaManagerHTTPExecutePost(bool* ptrIsSuccess, long* ptrHttpCode);
bool httpMediaManagerSetTargetUrl( char* ptrTargetURL);
bool httpMediaManagerSetCertificatePath( char* ptrCertificatePath);
bool httpMediaManagerSetPostData( char* ptrPostdata);
bool httpMediaManagerSetHeaders();
bool httpMediaManagerSetCallback();
bool httpMediaManagerSetWriteData();
bool httpMediaManagerHttpExecuteInit();
bool httpMediaManagerHttpExecuteCleanup();
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* HTTPMEDIAMANAGER_H */

View File

@ -0,0 +1,35 @@
/*
* Copyright 2018-2021 THALES group. All Rights Reserved.
*
* Project name: LPASDK.
* Platform: Windows, Linux.
* Language: C/C++
*
* Except if otherwise stated in a NOTICE file provided by Thales together with the software, below conditions are applicable by default.
*
* This computer program includes confidential and proprietary information of Thales and is a trade secret of
* Thales. All use, disclosure, and/or reproduction is prohibited unless authorized in writing by Thales.
*
* The computer program is provided "AS IS" without warranty of any kind. Thales makes no
* warranties to any person or entity with respect to the computer program and disclaims all other warranties,
* expressed or implied. Thales expressly disclaims any implied warranty of merchantability, fitness for particular
* purpose and any warranty which may arise from course of performance, course of dealing, or usage of trade. Further
* Thales does not warrant that the computer program will meet requirements or that operation of the computer program
* will be uninterrupted or error-free.
*
*/
#ifndef LPA_SDK__HTTP_MEDIA_OPTION_TYPE_H
#define LPA_SDK__HTTP_MEDIA_OPTION_TYPE_H
typedef enum
{
// CURL option
HTTP_MEDIA_OPTION_TYPE_CURL_SSL_VERIFYPEER,
HTTP_MEDIA_OPTION_TYPE_CURL_SSL_VERIFYHOST,
HTTP_MEDIA_OPTION_TYPE_CURL_VERBOSE,
HTTP_MEDIA_OPTION_TYPE_CURL_CONNECT_TIMEOUT,
HTTP_MEDIA_OPTION_TYPE_CURL_TIMEOUT
} HttpMediaOptionType;
#endif // LPA_SDK__HTTP_MEDIA_OPTION_TYPE_H

View File

@ -0,0 +1,32 @@
/*
* Copyright 2018-2021 THALES group. All Rights Reserved.
*
* Project name: LPASDK.
* Platform: Windows, Linux.
* Language: C/C++
*
* Except if otherwise stated in a NOTICE file provided by Thales together with the software, below conditions are applicable by default.
*
* This computer program includes confidential and proprietary information of Thales and is a trade secret of
* Thales. All use, disclosure, and/or reproduction is prohibited unless authorized in writing by Thales.
*
* The computer program is provided "AS IS" without warranty of any kind. Thales makes no
* warranties to any person or entity with respect to the computer program and disclaims all other warranties,
* expressed or implied. Thales expressly disclaims any implied warranty of merchantability, fitness for particular
* purpose and any warranty which may arise from course of performance, course of dealing, or usage of trade. Further
* Thales does not warrant that the computer program will meet requirements or that operation of the computer program
* will be uninterrupted or error-free.
*
*/
#ifndef LPA_SDK__ISDR_APPLET_MANAGER_H
#define LPA_SDK__ISDR_APPLET_MANAGER_H
#include <stdbool.h>
bool selectISDRApplet();
bool isISDRAppletSelected();
bool unselectISDRApplet();
#endif // LPA_SDK__ISDR_APPLET_MANAGER_H

View File

@ -0,0 +1,43 @@
/*
* Copyright 2018-2021 THALES group. All Rights Reserved.
*
* Project name: LPASDK.
* Platform: Windows, Linux.
* Language: C/C++
*
* Except if otherwise stated in a NOTICE file provided by Thales together with the software, below conditions are applicable by default.
*
* This computer program includes confidential and proprietary information of Thales and is a trade secret of
* Thales. All use, disclosure, and/or reproduction is prohibited unless authorized in writing by Thales.
*
* The computer program is provided "AS IS" without warranty of any kind. Thales makes no
* warranties to any person or entity with respect to the computer program and disclaims all other warranties,
* expressed or implied. Thales expressly disclaims any implied warranty of merchantability, fitness for particular
* purpose and any warranty which may arise from course of performance, course of dealing, or usage of trade. Further
* Thales does not warrant that the computer program will meet requirements or that operation of the computer program
* will be uninterrupted or error-free.
*
*/
#ifndef LPA_SDK__CONFIG_FILE_H
#define LPA_SDK__CONFIG_FILE_H
#include <stdio.h>
#include <stdlib.h>
#include "lpasdk/core/lpa_core.h"
#include "lpasdk/api/lpasdk_api.h"
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
#include "lpasdk/core/lpa_config_interface.h"
bool lpaConfigFileLoad(const char* ptrConfigFileName, bool* ptrConfigFilePresent);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif // LPA_SDK__CONFIG_H

View File

@ -0,0 +1,48 @@
/*
* Copyright 2018-2021 THALES group. All Rights Reserved.
*
* Project name: LPASDK.
* Platform: Windows, Linux.
* Language: C/C++
*
* Except if otherwise stated in a NOTICE file provided by Thales together with the software, below conditions are applicable by default.
*
* This computer program includes confidential and proprietary information of Thales and is a trade secret of
* Thales. All use, disclosure, and/or reproduction is prohibited unless authorized in writing by Thales.
*
* The computer program is provided "AS IS" without warranty of any kind. Thales makes no
* warranties to any person or entity with respect to the computer program and disclaims all other warranties,
* expressed or implied. Thales expressly disclaims any implied warranty of merchantability, fitness for particular
* purpose and any warranty which may arise from course of performance, course of dealing, or usage of trade. Further
* Thales does not warrant that the computer program will meet requirements or that operation of the computer program
* will be uninterrupted or error-free.
*
*/
#ifndef LPA_SDK__CONFIG_INTERFACE_H
#define LPA_SDK__CONFIG_INTERFACE_H
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include "lpasdk/core/lpa_log_interface.h"
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
typedef struct LPA_CONFIG_INTERFACE LPA_CONFIG_INTERFACE;
struct LPA_CONFIG_INTERFACE
{
bool (*setLog)(const LPA_LOG_INTERFACE* ptrLogInterface);
bool (*setConfigFileName)(const char*ptrConfigFileName);
bool (*load) ();
};
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif // LPA_SDK__CONFIG_INTERFACE_H

View File

@ -0,0 +1,64 @@
/*
* Copyright 2018-2021 THALES group. All Rights Reserved.
*
* Project name: LPASDK.
* Platform: Windows, Linux.
* Language: C/C++
*
* Except if otherwise stated in a NOTICE file provided by Thales together with the software, below conditions are applicable by default.
*
* This computer program includes confidential and proprietary information of Thales and is a trade secret of
* Thales. All use, disclosure, and/or reproduction is prohibited unless authorized in writing by Thales.
*
* The computer program is provided "AS IS" without warranty of any kind. Thales makes no
* warranties to any person or entity with respect to the computer program and disclaims all other warranties,
* expressed or implied. Thales expressly disclaims any implied warranty of merchantability, fitness for particular
* purpose and any warranty which may arise from course of performance, course of dealing, or usage of trade. Further
* Thales does not warrant that the computer program will meet requirements or that operation of the computer program
* will be uninterrupted or error-free.
*
*/
#ifndef LPA_SDK__LPA_CORE_H
#define LPA_SDK__LPA_CORE_H
#define LPA_SDK__PLATFORM_RASPBIAN
#ifdef LPA_SDK__PLATFORM_WIN
#include "lpasdk/core/win/lpa_core.h"
#endif //
#ifdef LPA_SDK__PLATFORM_CYGWIN
#include "lpasdk/core/cygwin/lpa_core.h"
#endif //LPA_SDK__PLATFORM_CYGWIN
#ifdef LPA_SDK__PLATFORM_RASPBIAN
#include "lpasdk/core/raspbian/lpa_core.h"
#endif //LPA_SDK__PLATFORM_RASPBIAN
// Define generic MACRO & Constant
///////////////////////////////////////
#define LPA_RES_TRUE_STRING "true"
#define LPA_RES_FALSE_STRING "false"
// Check that macro exits for specific platform
///////////////////////////////////////
#ifndef UT_EXPORT_DLL
#error "UT_EXPORT_DLL not defined for current platform"
//#define UT_EXPORT_DLL // Nothing specific for this platform
#endif // UT_EXPORT_DLL
#ifndef LPA_SDK_INLINE_FUNCTION
#error "LPA_SDK_INLINE_FUNCTION not defined for current platform"
//#define LPA_SDK_INLINE_FUNCTION // Nothing specific for this platform
#endif // LPA_SDK_INLINE_FUNCTION
#endif // LPA_SDK__LPA_CORE_H

View File

@ -0,0 +1,65 @@
/*
* Copyright 2018-2021 THALES group. All Rights Reserved.
*
* Project name: LPASDK.
* Platform: Windows, Linux.
* Language: C/C++
*
* Except if otherwise stated in a NOTICE file provided by Thales together with the software, below conditions are applicable by default.
*
* This computer program includes confidential and proprietary information of Thales and is a trade secret of
* Thales. All use, disclosure, and/or reproduction is prohibited unless authorized in writing by Thales.
*
* The computer program is provided "AS IS" without warranty of any kind. Thales makes no
* warranties to any person or entity with respect to the computer program and disclaims all other warranties,
* expressed or implied. Thales expressly disclaims any implied warranty of merchantability, fitness for particular
* purpose and any warranty which may arise from course of performance, course of dealing, or usage of trade. Further
* Thales does not warrant that the computer program will meet requirements or that operation of the computer program
* will be uninterrupted or error-free.
*
*/
#ifndef LPA_SDK__CORE_LOG_H
#define LPA_SDK__CORE_LOG_H
#include <stdio.h>
#include <stdbool.h>
#include "lpasdk/core/lpa_core.h"
#include "lpasdk/core/lpa_log_interface.h"
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
UT_EXPORT_DLL bool lpaCoreLogInit();
UT_EXPORT_DLL bool lpaCoreLogInitEx(LPA_LOG_INTERFACE* lpaLogInterface);
UT_EXPORT_DLL bool lpaCoreLogIsInitialized();
UT_EXPORT_DLL bool lpaCoreLogRelease();
UT_EXPORT_DLL void lpaCoreLogOpen(const char* ptrFileName, const char* prtBackupFileName);
UT_EXPORT_DLL void lpaCoreLogFlush();
UT_EXPORT_DLL void lpaCoreLogClose();
UT_EXPORT_DLL bool lpaCoreLogIsOpen();
UT_EXPORT_DLL void lpaCoreActivateLogLimitation(bool activated);
UT_EXPORT_DLL void lpaCoreSetLogLevel(LpaLogLevel logLevel);
UT_EXPORT_DLL LpaLogLevel lpaCoreGetLogLevel(void);
UT_EXPORT_DLL bool lpaCoreSetLogMaxSize(long logMaxSize);
UT_EXPORT_DLL long lpaCoreGetLogMaxSize();
UT_EXPORT_DLL const char* lpaCoreGetLogLevelName(LpaLogLevel logLevel, bool* ptrIsFound);
UT_EXPORT_DLL bool lpaCoreSetLogLevelString(const char* logLevelString);
UT_EXPORT_DLL void lpaCoreLogAppend(LpaLogLevel logLevel, const char* ptrMessage, ...);
UT_EXPORT_DLL void lpaCoreLogAppendLongText(LpaLogLevel logLevel, const char* ptrHeaderMessage, const char* ptrLongTextToLog, const size_t LongTextToLogSize);
UT_EXPORT_DLL void lpaCoreLogAppendByteArray(LpaLogLevel logLevel, const char* ptrMessage, const char* ptrByteArrayName, unsigned char* ptrByteArray, size_t byteArraySize);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif // LPA_SDK__CORE_LOG_H

View File

@ -0,0 +1,71 @@
/*
* Copyright 2018-2021 THALES group. All Rights Reserved.
*
* Project name: LPASDK.
* Platform: Windows, Linux.
* Language: C/C++
*
* Except if otherwise stated in a NOTICE file provided by Thales together with the software, below conditions are applicable by default.
*
* This computer program includes confidential and proprietary information of Thales and is a trade secret of
* Thales. All use, disclosure, and/or reproduction is prohibited unless authorized in writing by Thales.
*
* The computer program is provided "AS IS" without warranty of any kind. Thales makes no
* warranties to any person or entity with respect to the computer program and disclaims all other warranties,
* expressed or implied. Thales expressly disclaims any implied warranty of merchantability, fitness for particular
* purpose and any warranty which may arise from course of performance, course of dealing, or usage of trade. Further
* Thales does not warrant that the computer program will meet requirements or that operation of the computer program
* will be uninterrupted or error-free.
*
*/
#ifndef LPA_SDK__CORE_LOG_INTERFACE_H
#define LPA_SDK__CORE_LOG_INTERFACE_H
#include <stdio.h>
#include <stdint.h>
#include <stdarg.h>
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
typedef enum
{
SDK_LOG_LEVEL_UNKNOWN,
SDK_LOG_LEVEL_VERBOSE,
SDK_LOG_LEVEL_DEBUG,
SDK_LOG_LEVEL_INFO,
SDK_LOG_LEVEL_WARNING,
SDK_LOG_LEVEL_ERROR,
SDK_LOG_LEVEL_SYSTEM // Use only internally
} LpaLogLevel;
typedef struct LPA_LOG_INTERFACE LPA_LOG_INTERFACE;
struct LPA_LOG_INTERFACE
{
void (*openLog) (const char* ptrFileName, const char* prtBackupFileName);
void (*flushLog)();
bool (*isLogOpened)();
void(*closeLog)();
void (*activateLogLimitation) (bool activated);
void (*setLogLevel) (LpaLogLevel logLevel);
LpaLogLevel (*getLogLevel)(void);
bool (*setLogMaxSize)(long logMaxSize);
long (*getLogMaxSize)();
void (*appendToLog)(LpaLogLevel logLevel, const char* ptrMessage, va_list argptr);
void (*appendLongTextToLog)(LpaLogLevel logLevel, const char* ptrHeaderMessage, const char* ptrLongTextToLog, const size_t LongTextToLogSize);
void (*appendByteArrayToLog)(LpaLogLevel logLevel, const char* ptrMessage, const char* ptrByteArrayName, unsigned char* ptrByteArray, size_t byteArraySize);
};
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif // LPA_SDK__CORE_LOG_INTERFACE_H

View File

@ -0,0 +1,106 @@
/*
* Copyright 2018-2021 THALES group. All Rights Reserved.
*
* Project name: LPASDK.
* Platform: Windows, Linux.
* Language: C/C++
*
* Except if otherwise stated in a NOTICE file provided by Thales together with the software, below conditions are applicable by default.
*
* This computer program includes confidential and proprietary information of Thales and is a trade secret of
* Thales. All use, disclosure, and/or reproduction is prohibited unless authorized in writing by Thales.
*
* The computer program is provided "AS IS" without warranty of any kind. Thales makes no
* warranties to any person or entity with respect to the computer program and disclaims all other warranties,
* expressed or implied. Thales expressly disclaims any implied warranty of merchantability, fitness for particular
* purpose and any warranty which may arise from course of performance, course of dealing, or usage of trade. Further
* Thales does not warrant that the computer program will meet requirements or that operation of the computer program
* will be uninterrupted or error-free.
*
*/
#ifndef LPA_SDK__LPA_MANAGER_H
#define LPA_SDK__LPA_MANAGER_H
#include "lpasdk/api/lpasdk_api.h"
#include "lpasdk/lpasdk_internal_api.h"
#ifdef LPA_SDK__USING_EX_API
//#include "lpasdk/lpasdk_ex_api.h"
#endif // LPA_SDK__USING_EX_API
#include "lpasdk/core/lpa_core.h"
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
#define MAX_LPA_MANAGER_APDU_BUFFER_SIZE 8192
bool lpaManagerInitialize(const char* ptrLpaFolder);
bool lpaManagerInitializeSEMedia();
bool lpaManagerInitializeHttpMedia();
bool lpaManagerSetConfigParameter(const char* ptrParameterName, LPA_PARAMETER_TYPE parameterType, const void* ptrParameterValue, bool internalCall);
bool lpaManagerGetConfigParameter(const char* ptrParameterName, LPA_PARAMETER_TYPE parameterType, void* ptrParameterValue, size_t parameterValueMaxSize);
bool lpaManagerIsConfigParameterExist(const char* ptrParameterName, LPA_PARAMETER_TYPE* ptrParameterType, bool* ptrIsExist, bool* ptrAccessGranted);
bool lpaManagerGetFullParametersList(LPA_PARAMETERS_LIST * ptrLpaParametersList);
// SEMedia manager redirections through lpa_manager.c
bool lpaManagerSEMediaManagerIsInitialized();
bool lpaManagerSEMediaManagerUninitialize();
// Reconnect SEMedia
bool lpaManagerSEMediaCardReset();
// httpMedia manager redirections through lpa_manager.c
bool lpaManagerHttpMediaManagerIsInitialized();
bool lpaManagerHttpMediaManagerDelete();
// Exchange with ISDR applet
bool lpaManagerGetReaderList(LPA_SE_MEDIA_READER_NAME_INFO * ptrReaderNameInfoList, size_t readerNameInfoMax, size_t* ptrCountReader);
bool lpaManagerGetProfilesInfo(LPA_GET_PROFILES_INFO* );
bool lpaManagerGetProfilesNumber(size_t* );
bool lpaManagerGetEID(LPA_GET_EID* );
bool lpaManagerGetEUICCInfo2(LPA_GET_EUICC_INFO* ptrGetEUICCInfo);
bool lpaManagerMemoryReset(const unsigned char* memoryResetOptionParameter, const size_t memoryResetOptionSize);
bool lpaManagerSendPendingNotification(LPA_EventCallback* ptrLpaEventCallback, LPA_SENDING_NOTIFICATION_RESULT* ptrSendingNotificationResult);
// Manage Enable/Disable/Delete Profile
bool lpaManagerEnableProfileByIccid(const unsigned char* ptrProfileId, size_t profileIdSize);
bool lpaManagerDisableProfileByIccid(const unsigned char* ptrProfileId, size_t profileIdSize);
bool lpaManagerDeleteProfileByIccid(const unsigned char* ptrProfileId, size_t profileIdSize);
// Manage notification list
bool lpaManagerGetProfileNotificationList(LPA_PROFILE_NOTIFICATION_LIST* ptrProfileNotificationList);
bool lpaManagerClearProfileNotification(uint16_t sequenceNumber);
bool lpaManagerSetDefaultSMDPAddress(const char* ptrSMDPAddr);
bool lpaManagerGetSMDPAddress(ADDRESS_DATA* ptrAddressData);
bool lpaManagerGetSMDSAddress(ADDRESS_DATA* ptrAddressData);
bool lpaManagerDownloadProfile(const char * ptrActivationCodeStr, const LPA_EventCallback* ptrLpaEventCallback, LPA_DOWNLOAD_PROFILE_RESULT* ptrDownloadProfileResult);
bool lpaManagerDownloadProfileWithConfirmationCode(const char * ptrActivationCodeStr, const char * ptrConfirmationCodeStr, const LPA_EventCallback* ptrLpaEventCallback, LPA_DOWNLOAD_PROFILE_RESULT* ptrDownloadProfileResult);
bool lpaManagerDownloadProfileWithDefaultSMDPAddress(const LPA_EventCallback* ptrLpaEventCallback, LPA_DOWNLOAD_PROFILE_RESULT* ptrDownloadProfileResult);
bool lpaManagerDownloadProfileWithSMDSAddress( const LPA_EventCallback* ptrLpaEventCallback, LPA_DOWNLOAD_PROFILE_RESULT* ptrDownloadProfileResult);
bool lpaManagerGetProfileNotificationList(LPA_PROFILE_NOTIFICATION_LIST* ptrProfileNotificationList);
bool lpaManagerClearProfileNotification(uint16_t sequenceNumber);
// Nickname management
bool lpaManagerSetNickname(const unsigned char* ptrProfileId, size_t profileIdSize, const unsigned char* ptrNickname, size_t nickNameSize);
bool lpaManagerConnectReaderAndSelectISDR();
bool lpaManagerUnselectISDRAndDisconnectReader();
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif // LPA_SDK__LPA_MANAGER_H

View File

@ -0,0 +1,123 @@
/*
* Copyright 2018-2021 THALES group. All Rights Reserved.
*
* Project name: LPASDK.
* Platform: Windows, Linux.
* Language: C/C++
*
* Except if otherwise stated in a NOTICE file provided by Thales together with the software, below conditions are applicable by default.
*
* This computer program includes confidential and proprietary information of Thales and is a trade secret of
* Thales. All use, disclosure, and/or reproduction is prohibited unless authorized in writing by Thales.
*
* The computer program is provided "AS IS" without warranty of any kind. Thales makes no
* warranties to any person or entity with respect to the computer program and disclaims all other warranties,
* expressed or implied. Thales expressly disclaims any implied warranty of merchantability, fitness for particular
* purpose and any warranty which may arise from course of performance, course of dealing, or usage of trade. Further
* Thales does not warrant that the computer program will meet requirements or that operation of the computer program
* will be uninterrupted or error-free.
*
*/
#ifndef LPA_SDK__LPA_MANAGER_API_H
#define LPA_SDK__LPA_MANAGER_API_H
#include "lpasdk/api/lpasdk_api.h"
#include "lpasdk/lpasdk_internal_api.h"
#ifdef LPA_SDK__USING_EX_API
#include "lpasdk/api/lpasdk_ex_api.h"
#endif // LPA_SDK__USING_EX_API
#include "lpasdk/core/lpa_core.h"
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
// PARAMETER KEY NAMES
// Parameter list itself is defined in lpa_manager.c
#define LPA_SDK_CONFIG_PARAM_READER_NAME "readerName"
#define LPA_SDK_CONFIG_PARAM_DEVICE_INFO_TLV "deviceInfoTlv"
#define LPA_SDK_CONFIG_PARAM_CERT_PATH "certPath"
#define LPA_SDK_CONFIG_PARAM_SEND_PIR_DURING_DOWNLOAD_PROFILE "sendPIRDuringDownloadProfile"
#define LPA_SDK_CONFIG_PARAM_USING_HTTPS_REQUEST "usingHTTPSRequest"
#define LPA_SDK_CONFIG_PARAM_ACTIVATE_CURL_DEBUG_MODE "activateCURLDebugMode"
#define LPA_SDK_CONFIG_PARAM_ADD_LE_TO_APDU_CASE_4 "addLeToApduCase4"
#define LPA_SDK_CONFIG_PARAM_LOG_LEVEL "logLevel"
#define LPA_SDK_CONFIG_PARAM_LOG_MAX_SIZE "logMaxSize"
#define LPA_SDK_CONFIG_PARAM_PROFILE_REFRESH_FLAG "profileRefreshFlag"
#define LPA_SDK_CONFIG_PARAM_CURL_SSL_SSL_VERIFYPEER "CURL_SSL_VERIFYPEER"
#define LPA_SDK_CONFIG_PARAM_CURL_SSL_SSL_VERIFYHOST "CURL_SSL_VERIFYHOST"
#define LPA_SDK_CONFIG_PARAM_CURL_CONNECT_TIMEOUT "CURL_CONNECT_TIMEOUT"
#define LPA_SDK_CONFIG_PARAM_CURL_TIMEOUT "CURL_TIMEOUT"
#define LPA_SDK_CONFIG_PARAM_DEVICE_CAPABILITIES_FILTERING "deviceCapabilitiesFiltering"
#define LPA_SDK_CONFIG_PARAM_DEVICE_SMDS_ADDRESS "deviceSMDSAddress"
#define LPA_SDK_CONFIG_PARAM_DEVICE_DEFAULT_SMDP_ADDRESS "deviceDefaultSMDPAddress"
#define LPA_SDK_CONFIG_PARAM_BYPASS_DEFAULT_USER_CONSENT_WITH_NO_PPR "bypassDefaultUserConsentWithNoPPR"
#define LPA_SDK_CONFIG_PARAM_SUPPORT_DOWLOAD_PROFILES_WITH_PPR "supportDownloadOfProfilesWithPPR"
UT_EXPORT_DLL bool lpaManagerApiInitialize(const char* ptrLpaFolder);
UT_EXPORT_DLL bool lpaManagerApiSetConfigParameter(const char* ptrParameterName, LPA_PARAMETER_TYPE parameterType, const void* ptrParameterValue, bool internalCall);
UT_EXPORT_DLL bool lpaManagerApiGetConfigParameter(const char* ptrParameterName, LPA_PARAMETER_TYPE parameterType, void* ptrParameterValue, size_t parameterValueMaxSize);
UT_EXPORT_DLL bool lpaManagerApiIsConfigParameterExist(const char* ptrParameterName, LPA_PARAMETER_TYPE* ptrParameterType, bool* ptrIsExist);
UT_EXPORT_DLL bool lpaManagerApiGetFullParametersList(LPA_PARAMETERS_LIST * ptrLpaParametersList);
// Reconnect SEMedia
UT_EXPORT_DLL bool lpaManagerApiSEMediaCardReset();
// Exchange with ISDR applet
UT_EXPORT_DLL bool lpaManagerApiGetReaderList(LPA_SE_MEDIA_READER_NAME_INFO * ptrReaderNameInfoList, size_t readerNameInfoMax, size_t* ptrCountReader);
UT_EXPORT_DLL bool lpaManagerApiGetProfilesInfo(LPA_GET_PROFILES_INFO*);
UT_EXPORT_DLL bool lpaManagerApiGetProfilesNumber(size_t*);
UT_EXPORT_DLL bool lpaManagerApiGetEID(LPA_GET_EID*);
UT_EXPORT_DLL bool lpaManagerApiGetEUICCInfo(LPA_GET_EUICC_INFO* ptrGetEUICCInfo);
UT_EXPORT_DLL bool lpaManagerApiMemoryReset(const unsigned char* memoryResetOptionParameter, const size_t memoryResetOptionSize);
UT_EXPORT_DLL bool lpaManagerApiSendPendingNotification(LPA_EventCallback* ptrLpaEventCallback, LPA_SENDING_NOTIFICATION_RESULT* ptrSendingNotificationResult);
// Manage Enable/Disable/Delete Profile
UT_EXPORT_DLL bool lpaManagerApiEnableProfileByIccid(const unsigned char* ptrProfileId, size_t profileIdSize);
UT_EXPORT_DLL bool lpaManagerApiDisableProfileByIccid(const unsigned char* ptrProfileId, size_t profileIdSize);
UT_EXPORT_DLL bool lpaManagerApiDeleteProfileByIccid(const unsigned char* ptrProfileId, size_t profileIdSize);
// Manage notification list
UT_EXPORT_DLL bool lpaManagerApiGetProfileNotificationList(LPA_PROFILE_NOTIFICATION_LIST* ptrProfileNotificationList);
UT_EXPORT_DLL bool lpaManagerApiClearProfileNotification(uint16_t sequenceNumber);
UT_EXPORT_DLL bool lpaManagerApiSetDefaultSMDPAddress(const char* ptrSMDPAddr);
UT_EXPORT_DLL bool lpaManagerApiGetSMDPAddress(ADDRESS_DATA* ptrAddressData);
UT_EXPORT_DLL bool lpaManagerApiGetSMDSAddress(ADDRESS_DATA* ptrAddressData);
UT_EXPORT_DLL bool lpaManagerApiDownloadProfile(const char * ptrActivationCodeStr, const LPA_EventCallback* ptrLpaEventCallback, LPA_DOWNLOAD_PROFILE_RESULT* ptrDownloadProfileResult);
UT_EXPORT_DLL bool lpaManagerApiDownloadProfileWithConfirmationCode(const char * ptrActivationCodeStr, const char * ptrConfirmationCodeStr, const LPA_EventCallback* ptrLpaEventCallback, LPA_DOWNLOAD_PROFILE_RESULT* ptrDownloadProfileResult);
UT_EXPORT_DLL bool lpaManagerApiDownloadProfileWithDefaultSMDPAddress(const LPA_EventCallback* ptrLpaEventCallback, LPA_DOWNLOAD_PROFILE_RESULT* ptrDownloadProfileResult);
UT_EXPORT_DLL bool lpaManagerApiDownloadProfileWithSMDSAddress(const LPA_EventCallback* ptrLpaEventCallback, LPA_DOWNLOAD_PROFILE_RESULT* ptrDownloadProfileResult);
UT_EXPORT_DLL bool lpaManagerApiSetNickname(const unsigned char* ptrProfileId, size_t profileIdSize, const unsigned char* ptrNickname, size_t nickNameSize);
UT_EXPORT_DLL bool lpaManagerApiSEMediaManagerIsInitialized();
UT_EXPORT_DLL bool lpaManagerApiSEMediaManagerUninitialize();
UT_EXPORT_DLL bool lpaManagerApiHttpMediaManagerIsInitialized();
UT_EXPORT_DLL bool lpaManagerApiHttpMediaManagerDelete();
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif // LPA_SDK__LPA_MANAGER_API_H

View File

@ -0,0 +1,50 @@
/*
* Copyright 2018-2021 THALES group. All Rights Reserved.
*
* Project name: LPASDK.
* Platform: Windows, Linux.
* Language: C/C++
*
* Except if otherwise stated in a NOTICE file provided by Thales together with the software, below conditions are applicable by default.
*
* This computer program includes confidential and proprietary information of Thales and is a trade secret of
* Thales. All use, disclosure, and/or reproduction is prohibited unless authorized in writing by Thales.
*
* The computer program is provided "AS IS" without warranty of any kind. Thales makes no
* warranties to any person or entity with respect to the computer program and disclaims all other warranties,
* expressed or implied. Thales expressly disclaims any implied warranty of merchantability, fitness for particular
* purpose and any warranty which may arise from course of performance, course of dealing, or usage of trade. Further
* Thales does not warrant that the computer program will meet requirements or that operation of the computer program
* will be uninterrupted or error-free.
*
*/
#ifndef LPA_SDK__LPA_MANAGER_ES10B_H
#define LPA_SDK__LPA_MANAGER_ES10B_H
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include "lpasdk/api/lpasdk_api.h"
#include "lpasdk/lpasdk_internal_api.h"
#include "lpasdk/core/rawdata_object.h"
typedef struct
{
RawDataObject* ptrRawDataObjectTLV_transactionId;
RawDataObject* ptrRawDataObjectTLV_ccRequiredFlag;
RawDataObject* ptrRawDataObjectTLV_bppEuiccOtpk;
} SMDP_SIGNED2_DATA;
bool lpaManagerES10b_PrepareDownload(ptr_serverData, const LPA_EventCallback* ptrLpaEventCallback, const char * ptrStringHashCC, PREPARE_DOWNLOAD_RESPONSE*);
bool lpaManagerES10b_LoadBoundProfilePackage(ptr_serverData p_serverData, PROFILE_INSTALLATION_RESULT *pir, bool * cancelForBPPerrors);
bool lpaManagerES10b_GetEuiccChallenge(LPA_GET_EUICC* ptrGetEUICC);
bool lpaManagerES10b_GetEuiccInfo(const unsigned short eUICCinfoTag, LPA_GET_EUICC* ptrGetEUICC);
bool lpaManagerES10b_AuthenticateServer(ptr_serverData p_serverData, const LPA_EventCallback* ptrLpaEventCallback, RawDataObject * ptrCtxParam, AUTHENTICATE_SERVER_RESPONSE* ptrAnthServerResp);
bool lpaManagerES10b_CancelSession(const char * transactionID, const unsigned int p_reasonCode, CANCEL_SESSION_RESPONSE * ptrCancelSessionResp);
bool lpaManagerES10b_GetRAT(RawDataObject ** ptrGetRAT);
#endif // LPA_SDK__LPA_MANAGER_ES10C_H

View File

@ -0,0 +1,44 @@
/*
* Copyright 2018-2021 THALES group. All Rights Reserved.
*
* Project name: LPASDK.
* Platform: Windows, Linux.
* Language: C/C++
*
* Except if otherwise stated in a NOTICE file provided by Thales together with the software, below conditions are applicable by default.
*
* This computer program includes confidential and proprietary information of Thales and is a trade secret of
* Thales. All use, disclosure, and/or reproduction is prohibited unless authorized in writing by Thales.
*
* The computer program is provided "AS IS" without warranty of any kind. Thales makes no
* warranties to any person or entity with respect to the computer program and disclaims all other warranties,
* expressed or implied. Thales expressly disclaims any implied warranty of merchantability, fitness for particular
* purpose and any warranty which may arise from course of performance, course of dealing, or usage of trade. Further
* Thales does not warrant that the computer program will meet requirements or that operation of the computer program
* will be uninterrupted or error-free.
*
*/
#ifndef LPA_SDK__LPA_MANAGER_ES10C_H
#define LPA_SDK__LPA_MANAGER_ES10C_H
#include "lpasdk/api/lpasdk_api.h"
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
void lpaManagerES10c_SetRefreshFlag(bool refreshFlagActivated);
bool lpaManagerES10c_IsRefreshFlag();
bool lpaManagerES10c_GetProfilesInfo(LPA_GET_PROFILES_INFO* ptrLpaGetProfilesInfo, bool * continueRetry, bool requestForPPRmanagement);
bool lpaManagerES10c_GetProfilesNumber(size_t*);
bool lpaManagerES10c_EnableProfileByIccid(const unsigned char* ptrProfileId, size_t profileIdSize);
bool lpaManagerES10c_DisableProfileByIccid(const unsigned char* ptrProfileId, size_t profileIdSize);
bool lpaManagerES10c_DeleteProfileByIccid(const unsigned char* ptrProfileId, size_t profileIdSize);
bool lpaManagerES10c_MemoryReset(const unsigned char* memoryResetOptionParameter, const size_t memoryResetOptionSize);
bool lpaManagerES10c_GetEID(LPA_GET_EID*);
bool lpaManagerES10c_SetNickname(const unsigned char* ptrProfileId, size_t profileIdSize, const unsigned char* ptrNickname, size_t nickNameSize);
#endif // LPA_SDK__LPA_MANAGER_ES10C_H

View File

@ -0,0 +1,50 @@
/*
* Copyright 2018-2021 THALES group. All Rights Reserved.
*
* Project name: LPASDK.
* Platform: Windows, Linux.
* Language: C/C++
*
* Except if otherwise stated in a NOTICE file provided by Thales together with the software, below conditions are applicable by default.
*
* This computer program includes confidential and proprietary information of Thales and is a trade secret of
* Thales. All use, disclosure, and/or reproduction is prohibited unless authorized in writing by Thales.
*
* The computer program is provided "AS IS" without warranty of any kind. Thales makes no
* warranties to any person or entity with respect to the computer program and disclaims all other warranties,
* expressed or implied. Thales expressly disclaims any implied warranty of merchantability, fitness for particular
* purpose and any warranty which may arise from course of performance, course of dealing, or usage of trade. Further
* Thales does not warrant that the computer program will meet requirements or that operation of the computer program
* will be uninterrupted or error-free.
*
*/
#ifndef LPA_SDK__LPA_MANAGER_ES9_PLUS_H
#define LPA_SDK__LPA_MANAGER_ES9_PLUS_H
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include "lpasdk/api/lpasdk_api.h"
#include "lpasdk/lpasdk_internal_api.h"
bool lpaManagerES9Plus_InitiateAuthentication(ptr_serverData p_serverData, const LPA_EventCallback* ptrLpaEventCallback, const char * ptrEuiccChallenge, const char * ptrEuiccInfo1, const char* ptrSmdpAddress);
bool lpaManagerES9Plus_GetBoundProfilePackage(ptr_serverData p_serverData, const LPA_EventCallback* ptrLpaEventCallback, const char* ptrSmdpAddress, const unsigned char* ptrPrepareDownloadResponse, bool * cancelForBPPerrors);
bool lpaManagerES9Plus_AuthenticateClient(ptr_serverData p_serverData, const LPA_EventCallback* ptrLpaEventCallback, const char* ptrSmdpAddress, const unsigned char* ptrAuthenticateServerResponse);
bool lpaManagerES9Plus_HandleNotification(const char* ptrSmdpAddr, size_t smdpAddrSize, const unsigned char* ptrPendingNotification, const LPA_EventCallback* ptrLpaEventCallback, bool * ptrNormalAcknowledge);
bool lpaManagerES9Plus_EventRetrieval(const char* ptrTransactionId, const LPA_EventCallback* ptrLpaEventCallback, const char* ptrSmdsAddress, const unsigned char* ptrAuthenticateServerResponse, EVENT_RECORD_LIST* ptrEventRecordList);
bool lpaManagerES9plus_CancelSession(const char * transactionID, CANCEL_SESSION_RESPONSE * ptrCancelSessionResp, const char* ptrSmdpAddress, const LPA_EventCallback* ptrLpaEventCallback);
// From lpa_manager.c
char* lpaManagerES9Plus_ExecutePost(const char * ptrTargetURL, const char * ptrJsonRequest, bool* ptrIsSuccess, long *ptrHttpCode, const LPA_EventCallback* ptrLpaEventCallback);
// certPath support
void lpaManagerES9Plus_Init(const char * defaultCertPath);
bool lpaManagerES9Plus_setCertPath(const char* ptrCertPath);
size_t lpaManagerES9Plus_getCertPathSize();
bool lpaManagerES9Plus_getCertPath(char*ptrCertPath, size_t ptrCertPathMaxSize);
#endif // LPA_SDK__LPA_MANAGER_ES9_PLUS_H

View File

@ -0,0 +1,43 @@
/*
* Copyright 2018-2021 THALES group. All Rights Reserved.
*
* Project name: LPASDK.
* Platform: Windows, Linux.
* Language: C/C++
*
* Except if otherwise stated in a NOTICE file provided by Thales together with the software, below conditions are applicable by default.
*
* This computer program includes confidential and proprietary information of Thales and is a trade secret of
* Thales. All use, disclosure, and/or reproduction is prohibited unless authorized in writing by Thales.
*
* The computer program is provided "AS IS" without warranty of any kind. Thales makes no
* warranties to any person or entity with respect to the computer program and disclaims all other warranties,
* expressed or implied. Thales expressly disclaims any implied warranty of merchantability, fitness for particular
* purpose and any warranty which may arise from course of performance, course of dealing, or usage of trade. Further
* Thales does not warrant that the computer program will meet requirements or that operation of the computer program
* will be uninterrupted or error-free.
*
*/
#ifndef LPA_SDK__LPA_MANAGER_HELPER_H
#define LPA_SDK__LPA_MANAGER_HELPER_H
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include "lpasdk/core/bertlv_object.h"
void lpaManagerHelperSetLeToAddApduCase4(bool enable);
bool lpaManagerHelperIsLeAddedToApduCase4();
bool buildAndSendStoreDataCase3WithoutResponseData(const RawDataObject* ptrRawDataObject, uint16_t *ptrSW);
bool buildAndSendStoreDataCase3(const RawDataObject* ptrRawDataObject, uint16_t *ptrSW, unsigned char *ptrResponseApduData, size_t responseApduDataMaxSize, size_t *ptrResponseApduDataSize);
bool buildAndSendStoreDataCase4WithoutResponseData(const RawDataObject* ptrRawDataObject, uint16_t *ptrSW);
bool buildAndSendStoreDataCase4(const RawDataObject* ptrRawDataObject, uint16_t *ptrSW, unsigned char *ptrResponseApduData, size_t responseApduDataMaxSize, size_t *ptrResponseApduDataSize);
bool buildAndSendApduCase4(const RawDataObject* ptrRawDataObject, uint16_t *ptrSW, unsigned char *ptrResponseApduData, size_t responseApduDataMaxSize, size_t *ptrResponseApduDataSize);
bool buildAndSendApduCase4Ex(const unsigned char* ptrApduC, uint16_t apduCSize, uint16_t *ptrSW, unsigned char *ptrResponseApduData, size_t responseApduDataMaxSize, size_t *ptrResponseApduDataSize);
#endif // LPA_SDK__LPA_MANAGER_HELPER_H

View File

@ -0,0 +1,103 @@
/*
* Copyright 2018-2021 THALES group. All Rights Reserved.
*
* Project name: LPASDK.
* Platform: Windows, Linux.
* Language: C/C++
*
* Except if otherwise stated in a NOTICE file provided by Thales together with the software, below conditions are applicable by default.
*
* This computer program includes confidential and proprietary information of Thales and is a trade secret of
* Thales. All use, disclosure, and/or reproduction is prohibited unless authorized in writing by Thales.
*
* The computer program is provided "AS IS" without warranty of any kind. Thales makes no
* warranties to any person or entity with respect to the computer program and disclaims all other warranties,
* expressed or implied. Thales expressly disclaims any implied warranty of merchantability, fitness for particular
* purpose and any warranty which may arise from course of performance, course of dealing, or usage of trade. Further
* Thales does not warrant that the computer program will meet requirements or that operation of the computer program
* will be uninterrupted or error-free.
*
*/
#ifndef LPA_SDK__CORE_MEMORY_H
#define LPA_SDK__CORE_MEMORY_H
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <stdbool.h>
#ifdef LPA_SDK__USING_EX_API
#include "lpasdk/api/lpasdk_ex_api.h"
#endif // LPA_SDK__USING_EX_API
#include "lpasdk/core/lpa_core.h"
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
UT_EXPORT_DLL void lpaCoreMemoryInitialize();
#ifdef LPA_SDK__MEMORY
#define LPA_CORE_MEMORY_GENERATE_ERR_IF_MEMORY_COUNTER_EQ 1
#define LPA_CORE_MEMORY_GENERATE_ERR_IF_MEMORY_COUNTER_GT 2
#define LPA_CORE_MEMORY_GENERATE_ERR_IF_MEMORY_COUNTER_GE 3
#define LPA_CORE_MEMORY_GENERATE_ERR_IF_MEMORY_SIZE_REQUESTED_EQ 4
#define LPA_CORE_MEMORY_GENERATE_ERR_IF_MEMORY_SIZE_REQUESTED_GT 5
#define LPA_CORE_MEMORY_GENERATE_ERR_IF_MEMORY_SIZE_REQUESTED_GE 6
UT_EXPORT_DLL void lpaCoreMemoryResetParamGenerateErr();
UT_EXPORT_DLL bool lpaCoreMemorySetParamGenerateErr(uint8_t param, long value);
UT_EXPORT_DLL bool lpaCoreMemoryGetParamGenerateErr(uint8_t param, long* ptrValue);
#ifndef LPA_SDK__MEMORY_MONITORING
// Allocate memory
void* lpaCoreMemoryAlloc(size_t size);
void* lpaCoreMemoryCalloc(size_t count, size_t size);
void* lpaCoreMemoryRealloc(void* ptrMemoryBlock, size_t newSize);
// free memory
void lpaCoreMemoryFree(void* ptrMemoryBlock);
#else // LPA_SDK__MEMORY_MONITORING
UT_EXPORT_DLL void* lpaCoreMemoryMonitorAlloc(char* ptrFilename, int line, size_t size);
UT_EXPORT_DLL void* lpaCoreMemoryMonitorCalloc(char* ptrFilename, int line, size_t count, size_t size);
UT_EXPORT_DLL void* lpaCoreMemoryMonitorRealloc(char* ptrFilename, int line, void* ptrMemoryBlock, size_t newSize);
UT_EXPORT_DLL void lpaCoreMemoryMonitorFree(char* ptrFilename, int line, void* mem);
// Wrapper to monitor memory API call
#define lpaCoreMemoryAlloc(size) lpaCoreMemoryMonitorAlloc(__FILE__, __LINE__, size)
#define lpaCoreMemoryCalloc(count, size) lpaCoreMemoryMonitorCalloc(__FILE__, __LINE__,count,size)
#define lpaCoreMemoryRealloc(ptrMemoryBlock, newSize) lpaCoreMemoryMonitorRealloc(__FILE__, __LINE__,ptrMemoryBlock,newSize)
#define lpaCoreMemoryFree(mem) lpaCoreMemoryMonitorFree(__FILE__, __LINE__, mem)
#endif // LPA_SDK__MEMORY_MONITORING
#else // LPA_SDK__MEMORY
//Not using owner memory mecanism
#define lpaCoreMemoryAlloc(size) malloc(size)
#define lpaCoreMemoryCalloc(count, size) calloc(count,size)
#define lpaCoreMemoryRealloc(ptrMemoryBlock, newSize) realloc(ptrMemoryBlock,newSize)
#define lpaCoreMemoryFree(mem) free(mem)
#endif // LPA_SDK__MEMORY
#ifdef LPA_SDK__USING_EX_API
UT_EXPORT_DLL bool lpaCoreGetMemoryStatus(LPA_MEMORY_STATUS* prtMemoryStatus);
#endif // LPA_SDK__USING_EX_API
void lpaCoreMemoryDumpStatusIntoLog();
void lpaCoreMemoryCheckMemoryAllocated();
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif // LPA_SDK__CORE_MEMORY_H

View File

@ -0,0 +1,38 @@
/*
* Copyright 2018-2021 THALES group. All Rights Reserved.
*
* Project name: LPASDK.
* Platform: Windows, Linux.
* Language: C/C++
*
* Except if otherwise stated in a NOTICE file provided by Thales together with the software, below conditions are applicable by default.
*
* This computer program includes confidential and proprietary information of Thales and is a trade secret of
* Thales. All use, disclosure, and/or reproduction is prohibited unless authorized in writing by Thales.
*
* The computer program is provided "AS IS" without warranty of any kind. Thales makes no
* warranties to any person or entity with respect to the computer program and disclaims all other warranties,
* expressed or implied. Thales expressly disclaims any implied warranty of merchantability, fitness for particular
* purpose and any warranty which may arise from course of performance, course of dealing, or usage of trade. Further
* Thales does not warrant that the computer program will meet requirements or that operation of the computer program
* will be uninterrupted or error-free.
*
*/
#ifndef LPA_SDK__CORE_RASPBIAN__LPA_CORE_H
#define LPA_SDK__CORE_RASPBIAN__LPA_CORE_H
#ifndef LPA_SDK__PLATFORM_RASPBIAN
#error "Incorrect usage of lpasdk/core/raspbian/lpa_core.h (PLATFORM_RASPBIAN not defined)"
#endif
#define LPA_MAX_PATH 260 //MAX_PATH
#define LPA_PATH_SEPARATOR "/"
// Declare LPA MACRO & Constant (platform)
#define LPA_SDK_INLINE_FUNCTION static inline
#define UT_EXPORT_DLL // Nothing specific for this platform
#endif // LPA_SDK__CORE_RASPBIAN__LPA_CORE_H

View File

@ -0,0 +1,61 @@
/*
* Copyright 2018-2021 THALES group. All Rights Reserved.
*
* Project name: LPASDK.
* Platform: Windows, Linux.
* Language: C/C++
*
* Except if otherwise stated in a NOTICE file provided by Thales together with the software, below conditions are applicable by default.
*
* This computer program includes confidential and proprietary information of Thales and is a trade secret of
* Thales. All use, disclosure, and/or reproduction is prohibited unless authorized in writing by Thales.
*
* The computer program is provided "AS IS" without warranty of any kind. Thales makes no
* warranties to any person or entity with respect to the computer program and disclaims all other warranties,
* expressed or implied. Thales expressly disclaims any implied warranty of merchantability, fitness for particular
* purpose and any warranty which may arise from course of performance, course of dealing, or usage of trade. Further
* Thales does not warrant that the computer program will meet requirements or that operation of the computer program
* will be uninterrupted or error-free.
*
*/
#ifndef LPA_SDK__CORE_RAW_DATA_OBJECT_H
#define LPA_SDK__CORE_RAW_DATA_OBJECT_H
#include <stdint.h>
#include <stdlib.h>
#include <stdbool.h>
#include "lpasdk/core/lpa_core.h"
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
typedef struct
{
unsigned char* rawData;
size_t rawDataSize;
}RawDataObject, *PtrRawDataObject;
UT_EXPORT_DLL RawDataObject* rawDataObject_allocate();
UT_EXPORT_DLL RawDataObject* rawDataObject_create(const unsigned char* ptrRawData, size_t rawDataSize);
UT_EXPORT_DLL RawDataObject* rawDataObject_createAsLV(const unsigned char* ptrRawData, size_t rawDataSize);
UT_EXPORT_DLL RawDataObject* rawDataObject_createFromBase64(const char* ptrBase64Data, const size_t base64DataSize, const size_t maximumRawdataSize);
UT_EXPORT_DLL RawDataObject* rawDataObject_concat(const RawDataObject* ptrRawDataObject1, const RawDataObject*ptrRawDataObject2);
UT_EXPORT_DLL RawDataObject* rawDataObject_concatRawDataArray(const RawDataObject* ptrRawDataObject1, const unsigned char* ptrRawData2, size_t rawDataSize2);
UT_EXPORT_DLL RawDataObject* rawDataObject_concatPartially(const RawDataObject* ptrRawDataObject1, const RawDataObject*ptrRawDataObject2, size_t offset, size_t length);
UT_EXPORT_DLL bool rawDataObject_appendRawDataArray(RawDataObject* ptrRawDataObjectSource, const unsigned char* ptrRawDataAppend, size_t rawDataSizeAppend);
UT_EXPORT_DLL bool rawDataObject_update(RawDataObject* ptrRawDataObject, const unsigned char* ptrRawData, size_t rawDataSize);
UT_EXPORT_DLL void rawDataObject_clear(RawDataObject* ptrRawDataObject);
UT_EXPORT_DLL void rawDataObject_free(RawDataObject* ptrRawDataObject);
// Some macro to help memory cleanup
#define ERASE_RAWDATAOBJECT(_ptr) if ((_ptr) != NULL) { rawDataObject_free( (_ptr) ); (_ptr) = NULL;}
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif // LPA_SDK__CORE_RAW_DATA_OBJECT_H

View File

@ -0,0 +1,62 @@
/*
* Copyright 2018-2021 THALES group. All Rights Reserved.
*
* Project name: LPASDK.
* Platform: Windows, Linux.
* Language: C/C++
*
* Except if otherwise stated in a NOTICE file provided by Thales together with the software, below conditions are applicable by default.
*
* This computer program includes confidential and proprietary information of Thales and is a trade secret of
* Thales. All use, disclosure, and/or reproduction is prohibited unless authorized in writing by Thales.
*
* The computer program is provided "AS IS" without warranty of any kind. Thales makes no
* warranties to any person or entity with respect to the computer program and disclaims all other warranties,
* expressed or implied. Thales expressly disclaims any implied warranty of merchantability, fitness for particular
* purpose and any warranty which may arise from course of performance, course of dealing, or usage of trade. Further
* Thales does not warrant that the computer program will meet requirements or that operation of the computer program
* will be uninterrupted or error-free.
*
*/
#ifndef LPA_SDK__CORE_SEMEDIA_BASE_H
#define LPA_SDK__CORE_SEMEDIA_BASE_H
#include <stdio.h>
#include <stdbool.h>
#include "lpasdk/api/lpasdk_api.h"
#include "lpasdk/api/semedia/semedia.h"
typedef struct TSEMedia
{
// parameter part
/////////////////////////
void* _childStruct;
// function part
/////////////////////////
bool (*seMediaEstablishContext) (const struct TSEMedia*);
bool (*seMediaReleaseContext) (const struct TSEMedia*);
bool (*seMediaIsValidContext) (const struct TSEMedia*);
bool (*seMediaIsContextEstablished) (const struct TSEMedia*);
bool (*seMediaSetCallbackEventExecutionError) (const struct TSEMedia*, LPA_EVENT_EXECUTION_ERROR lpaEventExecutionErrorCallback);
bool (*seMediaListReader) (const struct TSEMedia*, LPA_SE_MEDIA_READER_NAME_INFO * ptrReaderNameInfoList, size_t readerNameInfoMax, size_t* ptrCountReader);
bool (*seMediaConnect) (const struct TSEMedia*, const char *ptrReaderName);
bool (*seMediaIsConnected) (const struct TSEMedia*);
bool (*seMediaTransmitApdu) (const struct TSEMedia*, const unsigned char* ptrApduCommandBytes, size_t apduCommandSize, unsigned char* ptrApduResponseBytes, size_t* ptrApduResponseMaxSize);
bool (*seMediaDisconnect) (const struct TSEMedia*);
bool (*seMediaDisconnectWithReset) (const struct TSEMedia*);
bool (*seMediaGetStatus) (const struct TSEMedia*, SE_MEDIA_CARD_STATUS* ptrStatus);
} TSEMedia;
TSEMedia* New_SEMediaBase();
#endif // LPA_SDK__CORE_SEMEDIA_BASE_H

View File

@ -0,0 +1,60 @@
/*
* Copyright 2018-2021 THALES group. All Rights Reserved.
*
* Project name: LPASDK.
* Platform: Windows, Linux.
* Language: C/C++
*
* Except if otherwise stated in a NOTICE file provided by Thales together with the software, below conditions are applicable by default.
*
* This computer program includes confidential and proprietary information of Thales and is a trade secret of
* Thales. All use, disclosure, and/or reproduction is prohibited unless authorized in writing by Thales.
*
* The computer program is provided "AS IS" without warranty of any kind. Thales makes no
* warranties to any person or entity with respect to the computer program and disclaims all other warranties,
* expressed or implied. Thales expressly disclaims any implied warranty of merchantability, fitness for particular
* purpose and any warranty which may arise from course of performance, course of dealing, or usage of trade. Further
* Thales does not warrant that the computer program will meet requirements or that operation of the computer program
* will be uninterrupted or error-free.
*
*/
#ifndef LPA_SDK__CORE_SEMEDIA_MANAGER_H
#define LPA_SDK__CORE_SEMEDIA_MANAGER_H
#include <stdio.h>
#include <stdbool.h>
#include "lpasdk/api/lpasdk_api.h"
#include "lpasdk/core/lpa_core.h"
#include "lpasdk/core/semedia_base.h"
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
UT_EXPORT_DLL bool seMediaManagerInitialize();
UT_EXPORT_DLL bool seMediaManagerIsInitialized();
UT_EXPORT_DLL bool seMediaManagerUninitialize();
UT_EXPORT_DLL bool seMediaManagerSetCallbackEventExecutionError(LPA_EVENT_EXECUTION_ERROR lpaEventExecutionErrorCallback);
bool seMediaManagerEstablishContext();
bool seMediaManagerReleaseContext();
bool seMediaManagerIsContextEstablished();
bool seMediaManagerIsValidContext();
bool seMediaManagerListReader(LPA_SE_MEDIA_READER_NAME_INFO * readerNameInfoList, size_t readerNameInfoMax, size_t* countReader);
bool seMediaManagerIsConnected();
bool seMediaManagerConnect(const char* readerName);
bool seMediaManagerTransmitApdu(const unsigned char* apduCommandBytes, size_t apduCommandSize, unsigned char* apduResponseBytes, size_t* apduResponseMaxSize);
bool seMediaManagerDisconnect();
bool seMediaManagerDisconnectWithReset();
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif // LPA_SDK__CORE_SEMEDIA_MANAGER_H

View File

@ -0,0 +1,54 @@
/*
* Copyright 2018-2021 THALES group. All Rights Reserved.
*
* Project name: LPASDK.
* Platform: Windows, Linux.
* Language: C/C++
*
* Except if otherwise stated in a NOTICE file provided by Thales together with the software, below conditions are applicable by default.
*
* This computer program includes confidential and proprietary information of Thales and is a trade secret of
* Thales. All use, disclosure, and/or reproduction is prohibited unless authorized in writing by Thales.
*
* The computer program is provided "AS IS" without warranty of any kind. Thales makes no
* warranties to any person or entity with respect to the computer program and disclaims all other warranties,
* expressed or implied. Thales expressly disclaims any implied warranty of merchantability, fitness for particular
* purpose and any warranty which may arise from course of performance, course of dealing, or usage of trade. Further
* Thales does not warrant that the computer program will meet requirements or that operation of the computer program
* will be uninterrupted or error-free.
*
*/
#ifndef LPA_SDK__CORE_UTIL_H
#define LPA_SDK__CORE_UTIL_H
#include <stdio.h>
#include <stdbool.h>
#include <stdint.h>
int formatBytesToHexaString(const unsigned char *ptrDataBytes, size_t dataSize, char* ptrBuffer, size_t bufferMaxSize);
bool writeIntegerValueToByteArray(uint16_t integerValue, unsigned char *ptrByteArray, size_t byteArrayMaxSize, size_t* byteArraySize );
bool extractIntegerFromByteArray(const unsigned char *ptrByteArray, size_t byteArraySize, uint16_t* ptrIntegerValue);
bool hexStr2ByteArray(const unsigned char * inHexString,int inLen, unsigned char * outHex, int* outLen);
bool encodeLength(int length, unsigned char* lengthTLV, const size_t lengthTLVsize, size_t * attributeLength);
bool generateLength(int length, unsigned char* lengthHex, const size_t lengthHexsize, size_t * attributeLength);
int oneHexCharToHex(char h);
bool split(char *src,const char *separator,char **dest,int *num);
bool findSubstr(char* source, char* target);
int countCharOccurencesInString(const char * pString, const char c);
bool isElementPresentInArrayUInt(const unsigned int *pReferenceArray, const size_t pArraySize, const unsigned int pValue);
bool isElementPresentInArrayByte(const unsigned char *pReferenceArray, const size_t pArraySize, const unsigned char pValue);
bool compareEqualStringIgnoringCase(const char * pString1, const char * pString2);
bool convertStringToBoolean(const char* ptrParameterValue, bool *ptrBooleanValue);
bool convertStringToLong(const char* ptrParameterValue, long *ptrLongValue);
bool convertStringToLower(const char * ptrSourceString, char * ptrDestString, size_t ptrDestStringSize);
bool extractOIDfromCertificate(const unsigned char * ptrCertificate, const size_t certificateLength, unsigned char * ptrOID, size_t * ptrOIDsize, const size_t oidSizeMax);
bool convertASN1_OIDtoText(const unsigned char * ptrOID, const size_t OIDsize, char * OIDtext, const size_t OIDtextMaxSize);
bool parseDataWithVLQnodes(const unsigned char * ptrSource, const size_t sourceLength, unsigned char * ptrExtractData, size_t * ptrExtractDatalength, const size_t extractDataMaxSize);
bool decodeVLQvalue(const unsigned char * ptrVLQvalue, const size_t VLQvalueSize, unsigned long long * ptrOutputValue);
bool base64_encode(const unsigned char *indata, size_t inlen, char *outdata, size_t *outlen, size_t maxSize);
bool base64_decode(const char *indata, size_t inlen, unsigned char *outdata, size_t *outlen, size_t destSize);
bool extractBitsSetListInStaticASN1BitString(const unsigned char * ptrASN1BitString, const size_t ASN1BitStringLength, unsigned char * ptrBitsSetList, const size_t maxBitsSetListSize, size_t * ptrNbBitsSetFound);
bool checkBitSetInStaticASN1BitString(const unsigned char * ptrASN1BitString, const size_t ASN1BitStringLength, const unsigned char bitToCheck, bool * ptrIsPresent);
#endif // LPA_SDK__CORE_UTIL_H

View File

@ -0,0 +1,56 @@
/*
* Copyright 2018-2021 THALES group. All Rights Reserved.
*
* Project name: LPASDK.
* Platform: Windows, Linux.
* Language: C/C++
*
* Except if otherwise stated in a NOTICE file provided by Thales together with the software, below conditions are applicable by default.
*
* This computer program includes confidential and proprietary information of Thales and is a trade secret of
* Thales. All use, disclosure, and/or reproduction is prohibited unless authorized in writing by Thales.
*
* The computer program is provided "AS IS" without warranty of any kind. Thales makes no
* warranties to any person or entity with respect to the computer program and disclaims all other warranties,
* expressed or implied. Thales expressly disclaims any implied warranty of merchantability, fitness for particular
* purpose and any warranty which may arise from course of performance, course of dealing, or usage of trade. Further
* Thales does not warrant that the computer program will meet requirements or that operation of the computer program
* will be uninterrupted or error-free.
*
*/
#include <curl/curl.h>
#ifndef HTTPMEDIA_CURL_H
#define HTTPMEDIA_CURL_H
#ifdef __cplusplus
extern "C" {
#endif
typedef struct RespStruct {
char *resp;
size_t size;
} RespStruct;
typedef struct {
// Base part
/////////////////////////
THTTPMedia* _base;
// Specific part
/////////////////////////
CURL *_curl;
struct curl_slist *_headers;
struct RespStruct _respdata;
} THTTPMediaCURL;
THTTPMedia* New_HTTPMediaCurl();
void Delete_HTTPMediaCurl(THTTPMedia* httpMedia);
#ifdef __cplusplus
}
#endif
#endif /* HTTPMEDIA_CURL_H */

View File

@ -0,0 +1,65 @@
/*
* Copyright 2018-2021 THALES group. All Rights Reserved.
*
* Project name: LPASDK.
* Platform: Windows, Linux.
* Language: C/C++
*
* Except if otherwise stated in a NOTICE file provided by Thales together with the software, below conditions are applicable by default.
*
* This computer program includes confidential and proprietary information of Thales and is a trade secret of
* Thales. All use, disclosure, and/or reproduction is prohibited unless authorized in writing by Thales.
*
* The computer program is provided "AS IS" without warranty of any kind. Thales makes no
* warranties to any person or entity with respect to the computer program and disclaims all other warranties,
* expressed or implied. Thales expressly disclaims any implied warranty of merchantability, fitness for particular
* purpose and any warranty which may arise from course of performance, course of dealing, or usage of trade. Further
* Thales does not warrant that the computer program will meet requirements or that operation of the computer program
* will be uninterrupted or error-free.
*
*/
#ifndef LPA_SDK__DRIVER_SEMEDIA_GENERIC_MODEM_H
#define LPA_SDK__DRIVER_SEMEDIA_GENERIC_MODEM_H
// This driver is compiled only if LPA_SDK__SEMEDIA_DRIVER_GENERIC_MODEM build option exist
#ifdef LPA_SDK__SEMEDIA_DRIVER_GENERIC_MODEM
#if defined(LPA_SDK__PLATFORM_WIN) || defined(LPA_SDK__PLATFORM_CYGWIN) || defined(LPA_SDK__PLATFORM_RASPBIAN)
#include <stdio.h>
#include "lpasdk/core/semedia_manager.h"
#include "lpasdk/core/semedia_base.h"
typedef struct
{
// Base part
/////////////////////////
TSEMedia* _ptrBase;
// Specific part
/////////////////////////
#ifdef LPA_SDK__PLATFORM_WIN
HANDLE _modemHandle;
#else
int _modemFD;
#endif // LPA_SDK__PLATFORM_WIN
uint8_t _apduChannel;
char _apduChannelString[3];
bool _contextEstablished;
} TSEMediaGenericModem;
// Simulate object constructor
TSEMedia* New_SEMediaGenericModem();
// Simulate object destructor
void Delete_SEMediaGenericModem(TSEMedia* ptrTSEMedia);
#endif //def LPA_SDK__PLATFORM_WIN || LPA_SDK__PLATFORM_CYGWIN ||LPA_SDK__PLATFORM_RASPBIAN
#endif // LPA_SDK__SEMEDIA_DRIVER_GENERIC_MODEM
#endif // LPA_SDK__DRIVER_SEMEDIA_GENERIC_MODEM_H

View File

@ -0,0 +1,105 @@
/*
* Copyright 2018-2021 THALES group. All Rights Reserved.
*
* Project name: LPASDK.
* Platform: Windows, Linux.
* Language: C/C++
*
* Except if otherwise stated in a NOTICE file provided by Thales together with the software, below conditions are applicable by default.
*
* This computer program includes confidential and proprietary information of Thales and is a trade secret of
* Thales. All use, disclosure, and/or reproduction is prohibited unless authorized in writing by Thales.
*
* The computer program is provided "AS IS" without warranty of any kind. Thales makes no
* warranties to any person or entity with respect to the computer program and disclaims all other warranties,
* expressed or implied. Thales expressly disclaims any implied warranty of merchantability, fitness for particular
* purpose and any warranty which may arise from course of performance, course of dealing, or usage of trade. Further
* Thales does not warrant that the computer program will meet requirements or that operation of the computer program
* will be uninterrupted or error-free.
*
*/
#ifndef LPA_SDK__DRIVER_SEMEDIA_WINSCARD_H
#define LPA_SDK__DRIVER_SEMEDIA_WINSCARD_H
#ifdef LPA_SDK__SEMEDIA_DRIVER_WINSCARD
#if defined(LPA_SDK__PLATFORM_WIN) || defined(LPA_SDK__PLATFORM_CYGWIN) || defined(LPA_SDK__PLATFORM_RASPBIAN)
#include <stdio.h>
#ifdef LPA_SDK__PLATFORM_WIN
// Only available under Windows platform
#include <winscard.h>
#else
#ifdef LPA_SDK__PLATFORM_CYGWIN
// Only available under Cygwin platform
#include <w32api/winscard.h>
#else // LPA_SDK__PLATFORM_RASPBIAN
// Raspbian
#define TEXT(quote) __TEXT(quote) // r_winnt
#define __TEXT(quote) quote // r_winnt
// MessageId: ERROR_BROKEN_PIPE
//
// MessageText:
//
// The pipe has been ended.
//
#define ERROR_BROKEN_PIPE 109L
#define SCARD_AUTOALLOCATE (DWORD)(-1)
#define SCARD_SCOPE_USER 0 // The context is a user context, and any
// database operations are performed within the
// domain of the user.
#define SCARD_SCOPE_TERMINAL 1 // The context is that of the current terminal,
// and any database operations are performed
// within the domain of that terminal. (The
// calling application must have appropriate
// access permissions for any database actions.)
#define SCARD_SCOPE_SYSTEM 2 // The context is the system context, and any
// database operations are performed within the
// domain of the system. (The calling
// application must have appropriate access
// permissions for any database actions.)
#define SCARD_ALL_READERS TEXT("SCard$AllReaders\000")
#define SCARD_DEFAULT_READERS TEXT("SCard$DefaultReaders\000")
#define SCARD_LOCAL_READERS TEXT("SCard$LocalReaders\000")
#define SCARD_SYSTEM_READERS TEXT("SCard$SystemReaders\000")
#include <PCSC/wintypes.h>
#include <PCSC/winscard.h>
#endif // LPA_SDK__PLATFORM_CYGWIN
#endif //LPA_SDK__PLATFORM_WIN
#include "lpasdk/core/semedia_manager.h"
#include "lpasdk/core/semedia_base.h"
typedef struct
{
// Base part
/////////////////////////
TSEMedia* _ptrBase;
// Specific part
/////////////////////////
SCARDCONTEXT _scardContext;
SCARDHANDLE _scardHandle;
bool _contextEstablished;
uint8_t _apduChannel;
SE_MEDIA_DISCONNECT_CARD_PARAM _disconnectParam;
DWORD _connectSharedMode;
} TSEMediaWinSCard;
// Simulate object constructor
TSEMedia* New_SEMediaWinSCard();
// Simulate object destructor
void Delete_SEMediaWinSCard(TSEMedia* ptrTSEMedia);
#endif //def LPA_SDK__PLATFORM_WIN || LPA_SDK__PLATFORM_CYGWIN
#endif // LPA_SDK__SEMEDIA_DRIVER_WINSCARD
#endif // LPA_SDK__DRIVER_SEMEDIA_WINSCARD_H

View File

@ -0,0 +1,207 @@
/*
* Copyright 2018-2021 THALES group. All Rights Reserved.
*
* Project name: LPASDK.
* Platform: Windows, Linux.
* Language: C/C++
*
* Except if otherwise stated in a NOTICE file provided by Thales together with the software, below conditions are applicable by default.
*
* This computer program includes confidential and proprietary information of Thales and is a trade secret of
* Thales. All use, disclosure, and/or reproduction is prohibited unless authorized in writing by Thales.
*
* The computer program is provided "AS IS" without warranty of any kind. Thales makes no
* warranties to any person or entity with respect to the computer program and disclaims all other warranties,
* expressed or implied. Thales expressly disclaims any implied warranty of merchantability, fitness for particular
* purpose and any warranty which may arise from course of performance, course of dealing, or usage of trade. Further
* Thales does not warrant that the computer program will meet requirements or that operation of the computer program
* will be uninterrupted or error-free.
*
*/
#ifndef LPA_SDK__CORE_INTERNAL_API_H
#define LPA_SDK__CORE_INTERNAL_API_H
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include "lpasdk/api/lpasdk_api.h"
#include "lpasdk/core/rawdata_object.h"
#include "lpasdk/core/bertlv_object.h"
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
///////////////////////////////////
// MACRO PART
///////////////////////////////////
// Actually not used but can be still useful to free memory not reserved by lpaCoreMemoryAlloc()
#define FREEIF(ptr) do{\
if(ptr) free(ptr);\
ptr=NULL;\
}while(0)
///////////////////////////////////
// DEFINE PART
///////////////////////////////////
#define LPA_GET_EUICC_CHALLENGE_MAX_SIZE 30 // Shall not be grater than 23 bytes (Including SW), but keep some margin
#define LPA_AUTHENTICATE_SERVER_MAX_SIZE 4500
#define LPA_PIR_BUFFER_MAX_SIZE 400
//max size for the server data
#define LPA_TRANSACTION_ID_MAX_SIZE 40 // For both binary and string format
#define LPA_INITIAL_AUTHENTICATE_SERVER_SIGNED1_MAX_SIZE 350
#define LPA_INITIAL_AUTHENTICATE_SERVER_SIGNATURE1_MAX_SIZE 100
#define LPA_INITIAL_AUTHENTICATE_EUICC_CIPKID_TO_BE_USED_MAX_SIZE 40
#define LPA_INITIAL_AUTHENTICATE_SERVER_CERTIFICATE_MAX_SIZE 1536
#define LPA_AUTHENTICATE_CLIENT_SMDP_CERTIFICATE_MAX_SIZE 1536
#define LPA_AUTHENTICATE_CLIENT_SMDP_SIGNATURE2_MAX_SIZE 100
#define LPA_AUTHENTICATE_CLIENT_SMDP_SIGNED2_MAX_SIZE 350
#define LPA_AUTHENTICATE_CLIENT_PROFILE_METADATA_MAX_SIZE 2048
#define LPA_GET_BOUND_PROFILE_MAX_SIZE 135168 // 132 Kb
#define GET_EUICC_INFO1_DGI_TAG 0xBF20
#define GET_EUICC_INFO2_DGI_TAG 0xBF22
///////////////////////////////////
// STRUCTURE PART
///////////////////////////////////
typedef struct LPA_SERVER_DATA {
RawDataObject * _transactionId;
// Initiate Authentication objects
RawDataObject * _serverSigned1;
RawDataObject * _serverSignature1;
RawDataObject * _euiccCiPKIdToBeUsed;
RawDataObject * _serverCertificate;
// Authenticate Client objects
RawDataObject * _smdpCertificate;
RawDataObject * _smdpSignature2;
RawDataObject * _smdpSigned2;
RawDataObject * _profileMetadata;
BerTLVList * _boundProfilePackage;
size_t _boundProfilePackageLength;
uint8_t _boundProfilePackageContainerCount;
} LPA_SERVER_DATA, *ptr_serverData;
typedef struct {
// MatchingId + deviceInfoTLV
RawDataObject * ptrAuthenticateServerResponse;
RawDataObject * ptrAuthenticateServerResponse_Base64;
} AUTHENTICATE_SERVER_RESPONSE;
typedef struct {
// UICC challenge or UICC info
RawDataObject * ptrEUICC;
RawDataObject * prtEUICC_Base64;
} LPA_GET_EUICC;
typedef struct {
RawDataObject * ptrPrepareDownloadResponse;
RawDataObject * ptrPrepareDownloadResponse_Base64;
} PREPARE_DOWNLOAD_RESPONSE;
typedef struct {
bool hasResult;
RawDataObject * ptrProfileInstallationResultTlv;
RawDataObject * ptrProfileInstallationResultTlv_Base64;
} PROFILE_INSTALLATION_RESULT;
// PPR ASN1 bitstring values (PprIds object)
// Note: PPRUC means PprUpdateControl bit defined in PprIds ASN1 object and related to ES6 features
typedef enum
{
LPA_PPRDEF_PPR2 = 0x0520,
LPA_PPRDEF_PPR1_PPR2 = 0x0560,
LPA_PPRDEF_PPRUC_PPR2 = 0x05A0,
LPA_PPRDEF_PPRUC_PPR1_PPR2 = 0x05E0,
LPA_PPRDEF_PPR1 = 0x0640,
LPA_PPRDEF_PPRUC_PPR1 = 0x06C0,
LPA_PPRDEF_PPRUC = 0x0780
}LPA_PPR_ASN1_BIT_STRING_VALUES;
// Fields extracted from profile Metadata for PPR check
#define LPA_GID_MAX_SIZE 10 // TBC if bigger size can be encountered. Not fixed in 31.102. Saw at 4 bytes in SGP.23 examples.
typedef struct
{
unsigned int profilePPR; // Will store ASN1 coding of profile PPR. If value = 0 No PPR in profile
bool hasPPR1; // True if PPR1 is enabled
bool hasPPR2; // True if PPR2 is enabled
unsigned char mccMnc[3];
unsigned char gid1[LPA_GID_MAX_SIZE];
size_t gid1Size;
bool gid1Defined; // Allow to know if field exists, even if length = 0 (Used in PPR conditions)
unsigned char gid2[LPA_GID_MAX_SIZE];
size_t gid2Size;
bool gid2Defined; // Allow to know if field exists, even if length = 0 (Used in PPR conditions)
char profileName[LPA_PROFILE_NAME_MAX_SIZE + 2]; // Profile name that may be displayed to user. String coded. +1 byte for EOS, +1 byte for security
unsigned char userCallBackType; // Set information(s) to display to user. Values masks defined in LPA_USER_CONSENT_TYPES enum. Each bit set an info.
bool performCancelSession; // If true download is not allowed (PPR1 vs profile, RAT...) and Cancel Session will be performed
unsigned int cancelSessionReason; // Values defined in LPA_CANCEL_SESSION_REASON enum. Value has no importance while performCancelSession is not set
}LPA_DOWNLOADED_PROFILE_DATA_FOR_PPR;
typedef struct
{
unsigned char iccid[LPA_PROFILE_ICCID_BUFFER_MAX_SIZE];
size_t iccidSize;
unsigned char profileState[LPA_PROFILE_STATE_MAX_SIZE];
size_t profileStateSize;
unsigned char profileClass[LPA_PROFILE_CLASS_MAX_SIZE];
size_t profileClassSize;
unsigned char profilePolicyRules[LPA_PROFILE_POLICY_RULES_MAX_SIZE];
size_t profilePolicyRulesSize;
}LPA_PROFILE_INFO_FOR_PPR;
/*
Maximum profile info size retrieved from eUICC for PPR (Max length used):
Tag/size bytes + max data lengths
Header tag E3 5 bytes
iccid tag 5A 2 + 10 = 12 bytes
profileState tag 9F70 3 + 1 = 4 bytes
profileClass tag 95 2 + 1 = 3 bytes
profilePolicyRules tag 99 2 + 2 = 4 bytes
TOTAL -------------------------------------- 28 bytes - Set at 30 for rounding / security
*/
#define LPA_PROFILE_INFO_BUFFER_MAX_SIZE_FOR_PPR 30 // Size of profile raw data for PPR request
#define LPA_RAT_MAXIMUM_SIZE 1024 // Arbitrary fixed to 1024 bytes
// Structure used for PPR analysis, one for each PPR
typedef struct
{
bool pprValidated; // If true, means this PPR has been validated one time
int matchLevelMCC_MNC; // Match level for MCC / MNC digits: From 0 (Most generic) to 6 (Most accurate). Most accurate = Highest priority
bool matchedGID1; // If true an exact matching has been found for GID1 (Same or not defined). Has most priority than wildcard (Defined in rule with L = 0).
bool matchedGID2; // If true an exact matching has been found for GID2 (Same or not defined). Has most priority than wildcard (Defined in rule with L = 0).
int matchLevelGID; // Match level for GID: From 0 (No match, both accepted in rule with L = 0) to 2 (Both same value or not defined).
bool userConsentRequired; // If true user consent is required. Has most priority than no consent required
}LPA_PPR_RAT_ANALYSIS_FLAGS;
///////////////////////////////////
// FUNCTION PART
///////////////////////////////////
void lpaResetErrorCode();
LPA_API_ERROR lpaGetErrorCodeNoClear();
bool lpaIsError();
void lpaSetErrorCode(LPA_API_ERROR errorCode);
void lpaWriteErrorMessageOnLog(LPA_API_ERROR errorCode);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif // LPA_SDK__CORE_API_H

View File

@ -0,0 +1,33 @@
/*
* Copyright 2018-2021 THALES group. All Rights Reserved.
*
* Project name: LPASDK.
* Platform: Windows, Linux.
* Language: C/C++
*
* Except if otherwise stated in a NOTICE file provided by Thales together with the software, below conditions are applicable by default.
*
* This computer program includes confidential and proprietary information of Thales and is a trade secret of
* Thales. All use, disclosure, and/or reproduction is prohibited unless authorized in writing by Thales.
*
* The computer program is provided "AS IS" without warranty of any kind. Thales makes no
* warranties to any person or entity with respect to the computer program and disclaims all other warranties,
* expressed or implied. Thales expressly disclaims any implied warranty of merchantability, fitness for particular
* purpose and any warranty which may arise from course of performance, course of dealing, or usage of trade. Further
* Thales does not warrant that the computer program will meet requirements or that operation of the computer program
* will be uninterrupted or error-free.
*
*/
#ifndef LPA_SDK__VERSION_H
#define LPA_SDK__VERSION_H
#define LPA_SDK_VERSION_MAJOR 1
#define LPA_SDK_VERSION_MINOR 8
#define LPA_SDK_VERSION_PATCH 0
#define LPA_SDK_VERSION_BUILD 1 // 0 For a dev version (dev branch)
// Must be lower than 64 bytes
#define LPA_SDK_EXTRA_VERSION "1.8.0-Build01"
#endif // LPA_SDK__VERSION_H

View File

@ -0,0 +1,127 @@
/**************************************************************************
*
* Copyright (c) 2009-2023 by SiFar Technology, Inc.
*
* This software is copyrighted by and is the property of SiFar
* Technology, Inc.. All rights are reserved by SiFar Technology, Inc..
* This software may only be used in accordance with the corresponding
* license agreement. Any unauthorized use, duplication, distribution,
* or disclosure of this software is expressly forbidden.
*
* This Copyright notice MUST not be removed or modified without prior
* written consent of SiFar Technology, Inc..
*
* SiFar Technology, Inc. reserves the right to modify this software without notice.
*
* Author: HAC
* Ver: 1.0.0 2023.05.31
* Description: creat
**************************************************************************/
#ifndef __SF_4G_SMS_LPA_CMD_H__
#define __SF_4G_SMS_LPA_CMD_H__
#include "sf_common.h"
#define SF_SMS_LPA_APN_MAX_SIZE 39
#define SF_SMS_LPA_AC_MAX_SIZE 255
#define SF_SMS_LPA_AC_PRE_MAX_SIZE 4
#define SF_SMS_LPA_HASH_MAX_SIZE 64
#define SF_SMS_LPA_ICCID_MAX_SIZE 20
#define SF_SMS_LPA_URL_MAX_SIZE 255
#define SF_SMS_LPA_PARAM_BUFF_SIZE 256
#define SF_SMS_LPA_CMD_HASH_KEY_LENGTH 32
#define SF_SMS_LPA_CMD_SUCCESS 0
#define SF_SMS_LPA_CMD_FAIL 1
#define SF_SMS_LPA_CMD_ERROR_SOURCE_ESIM 0
#define SF_SMS_LPA_CMD_ERROR_SOURCE_SMDP 1
#define SF_SMS_LPA_CMD_ERROR_SOURCE_OTHER 2
#define SF_SMS_LPA_CMD_UNKNOWN 0
#define SF_SMS_LPA_CMD_DOWNLOAD_PROFILE_1 1
#define SF_SMS_LPA_CMD_DOWNLOAD_PROFILE_2 2
#define SF_SMS_LPA_CMD_DOWNLOAD_ENABLE_PROFILE_1 3
#define SF_SMS_LPA_CMD_DOWNLOAD_ENABLE_PROFILE_2 4
#define SF_SMS_LPA_CMD_ENABLE_PROFILE 5
#define SF_SMS_LPA_CMD_DELETE_PROFILE 6
#define SF_SMS_LPA_CMD_DELETE_PROFILE_NITIFY 7
#if 0
#define SF_LPA_LOG_FILE_PATH SF_SYS_INFO_DIR
#define SF_LPA_DOWNLOAD_PROFILE_AC_FILENEME (UINT8 *)"G:\\download_ac.txt"
#define SF_LPA_DOWNLOAD_ENABLE_PROFILE_AC_FILENEME (UINT8 *)"B:\\UDF\\download_enable_ac.txt"
#define SF_LPA_PROFILE_INFO_FILENEME (UINT8 *)"B:\\UDF\\profile_info.txt"
#define SF_LPA_PROFILE_INFO_BACKUP_FILENEME (UINT8 *)"B:\\UDF\\profile_info_backup.txt"
#else
#define SF_LPA_DOWNLOAD_PROFILE_AC_FILENEME "/tmp/download_ac.txt"
#define SF_LPA_DOWNLOAD_ENABLE_PROFILE_AC_FILENEME "/tmp/download_enable_ac.txt"
#define SF_LPA_PROFILE_INFO_FILENEME "/tmp/profile_info.txt"
#define SF_LPA_PROFILE_INFO_BACKUP_FILENEME "/mnt/sd/profile_info.txt"
#define SF_LPA_LOG_FILE_PATH "/mnt/sd/"
#endif
typedef struct SF_SMS_LPA_CMD_S{
UINT16 CmdVal;
SINT8 Param1Buff[SF_SMS_LPA_PARAM_BUFF_SIZE];
SINT8 Param2Buff[SF_SMS_LPA_PARAM_BUFF_SIZE];
SINT8 Param3Buff[SF_SMS_LPA_PARAM_BUFF_SIZE];
} SF_SMS_LPA_CMD_T;
typedef struct SF_SMS_LPA_CMD_LIST_S{
SF_SMS_LPA_CMD_T LpaCmd;
struct SF_SMS_LPA_CMD_LIST_S *pPre;
struct SF_SMS_LPA_CMD_LIST_S *pNext;
} SF_SMS_LPA_CMD_LIST_T;
SF_SMS_LPA_CMD_LIST_T *sf_sms_lpa_cmd_list_head_get(void);
void sf_sms_lpa_cmd_list_print(void);
UINT8 sf_sms_lpa_cmd_list_total_get(void);
SINT32 sf_sms_lpa_cmd_list_item_get(SF_SMS_LPA_CMD_T *pLpaCmd);
SINT32 sf_sms_lpa_cmd_list_item_add(SF_SMS_LPA_CMD_T *pLpaCmd);
SINT32 sf_sms_lpa_cmd_list_item_add_to_head(SF_SMS_LPA_CMD_T *pLpaCmd);
SINT32 sf_sms_lpa_command_info_extract(const SINT8 *cmdStr, UINT16 *cmdId, SINT8 *param1, SINT8 *param2, SINT8 *param3);
SINT32 sf_sms_lpa_command_log(SF_SMS_LPA_CMD_T* lpaCmd, SINT8 status, UINT16 errorCode, SINT8 source);
SINT32 sf_sms_lpa_command_recombination(SF_SMS_LPA_CMD_T *pLpaCmd);
SINT32 sf_sms_lpa_command_recombination_log(SINT8 status, UINT16 errorCode);
SINT8* sf_sms_lpa_log_file_name_get(void);
SINT32 sf_sms_lpa_hash_signature(const SINT8 *eid, const SINT8 *secret, SINT8 *signature);
SINT32 sf_sms_lpa_save_download_profile_activation_code(UINT16 cmdVal, const SINT8* activationCodeStr);
SINT32 sf_sms_lpa_load_download_profile_activation_code(UINT16 cmdVal, SINT8* activationCodeStr);
void sf_sms_lpa_delete_download_profile_activation_code(UINT16 cmdVal);
SINT32 sf_sms_lpa_save_download_profile_apn(UINT16 cmdVal, const SINT8* apn);
SINT32 sf_sms_lpa_load_download_profile_apn(UINT16 cmdVal, SINT8* apn);
SINT32 sf_sms_lpa_save_profile_info_item(const SINT8* iccid, const SINT8* apn, const SINT8* activationCodeStr);
SINT32 sf_sms_lpa_delete_profile_info_item(const SINT8* iccid);
SINT32 sf_sms_lpa_get_profile_info_item(const SINT8* iccid, SINT8* apn, SINT8* activationCodeStr);
SINT32 sf_sms_lpa_smdp_addr_get(const SINT8* activationCodeStr, SINT8 *smdpAddr);
void sf_sms_lpa_set_profile_switch_reboot_flg(UINT8 flg);
SF_BOOL sf_sms_lpa_is_need_profile_switch_reboot(void);
void sf_sms_lpa_set_send_lpa_log_flg(SF_BOOL flg);
SF_BOOL sf_sms_lpa_is_need_send_lpa_log(void);
SINT32 sf_sms_lpa_save_pre_active_profile_iccid(const SINT8* iccid);
void sf_sms_lpa_save_enable_profile_cmd_val(UINT16 cmdVal);
UINT16 sf_sms_lpa_get_enable_profile_cmd_val(void);
void sf_sms_lpa_clean_need_enable_iccid(void);
SINT32 sf_sms_lpa_set_need_enable_iccid(const SINT8* iccid);
SINT32 sf_sms_lpa_get_need_enable_iccid(SINT8* iccid);
SF_BOOL sf_sms_lpa_is_need_enable_profile(void);
void sf_sms_lpa_command_execute(void);
void sf_sms_lpa_command_enable_profile_handle(UINT16 cmdVal);
SINT32 sf_sms_lpa_load_profile_apn(const SINT8 *iccid, SINT8 *apn);
SINT32 sf_sms_lpa_profile_rool_back(const SINT8 *iccid);
SINT32 sf_sms_lpa_command_handle(SF_SMS_LPA_CMD_T *pLpaCmd);
SINT32 sf_sms_lpa_download_command_add_to_list(void);
void sf_sms_lpa_cmd_enable_test(void);
void sf_sms_lpa_cmd_test(UINT8 *sms);
void sf_sms_lpa_delete_lpa_log(void);
SF_BOOL sf_sms_lpa_is_lpa_log_exist(void);
#endif

View File

@ -0,0 +1,85 @@
#ifndef __SF_4G_LPA_H__
#define __SF_4G_LPA_H__
#include "sf_common.h"
#include "lpasdk/api/lpasdk_api.h"
#include "sf_sms.h"
#define INPUT_SUBFOLDER "mnt/sd/config"
#define OUTPUT_SUBFOLDER "mnt/sd/logs"
#ifndef true
#define true 1
#endif
#ifndef false
#define false 0
#endif
#define PROFILE_STATE_DISABLED 0
#define PROFILE_STATE_ENABLED 1
#define PROFILE_CLASS_TEST 0
#define PROFILE_CLASS_PROVISIONING 1
#define PROFILE_CLASS_OPERATIONAL 2
#define REQUEST_SMDS_ADDRESS true
#define REQUEST_DEFAULT_SMDP_ADDRESS false
#define SF_LPA_SUCCESS 0
#define SF_LPA_FAIL 1
#define SF_LPA_ERROR_PROFILE_NOT_FOUND 2
#define SF_LPA_ERROR_PROFILE_IS_ENABLE 3
#define SF_LPA_ERROR_PROFILE_CAT_BUSY 4
#define SF_LPA_ERROR_MEDIA_READER_CONNECTION 5
#define SF_MAX_PROFILE_NUM 3
#define SF_LPA_FOLDER SF_SD_DISK
#define SF_LPA_SDK 1
void sf_sample_lpa_init(void);
void sf_lpa_profile_info_refresh(void);
void sf_lpa_cmds(UINT32 argc, char *arg[], UINT32 v[]);
LPA_API_ERROR sf_enable_profile(UINT8 indexProfiles);
UINT32 sf_profile_name_paired(UINT8 *profileName, UINT8 *operatorName);
void sf_lpa_profile_active_change(void);
UINT8 sf_is_esim_card();
UINT8 sf_is_esim_init_finish();
UINT32 sf_get_profile_total(void);
UINT32 sf_is_profile_index_enable(UINT8 index);
UINT32 sf_get_profile_item(UINT8 index, LPA_PROFILE_INFO *profileInfo);
void sf_network_switch(void);
LPA_API_ERROR sf_lpa_enable_profile_from_iccid(const SINT8* iccid);
LPA_API_ERROR sf_lpa_enable_profile_from_iccid(const SINT8* iccid);
LPA_API_ERROR sf_lpa_delete_profile_from_iccid(const SINT8* iccid);
LPA_API_ERROR sf_lpa_download_profile(const SINT8* activationCodeStr);
LPA_API_ERROR sf_lpa_set_smdp_addr(const char* smdpAddr);
LPA_API_ERROR sf_lpa_send_pending_notifications(void);
SINT32 sf_lpa_get_all_iccid(SINT8* allIccid);
SINT32 sf_lpa_get_active_profile_iccid(SINT8* iccid);
SINT32 sf_lpa_get_download_profile_iccid(SINT8* iccid);
SINT32 sf_lpa_set_download_profile_iccid(SINT8* iccid);
void sf_set_wifi_socket(int fd);
int sf_get_wifi_socket(void);
void sf_set_wifi_cmd(UINT8 cmd);
UINT8 sf_get_wifi_cmd();
void sf_network_select(UINT8 profileId);
void sf_4g_operator_scan(UINT8 mode);
//UINT32 sf_sample_lpa_init(UINT8 refreshNetworkFlg);
#endif

View File

@ -0,0 +1,31 @@
// Source code from https://github.com/amosnier/sha-2
// License : https://github.com/amosnier/sha-2/blob/master/LICENSE
/*
This is free and unencumbered software released into the public domain.
Anyone is free to copy, modify, publish, use, compile, sell, or
distribute this software, either in source code form or as a compiled
binary, for any purpose, commercial or non-commercial, and by any
means.
In jurisdictions that recognize copyright laws, the author or authors
of this software dedicate any and all copyright interest in the
software to the public domain. We make this dedication for the benefit
of the public at large and to the detriment of our heirs and
successors. We intend this dedication to be an overt act of
relinquishment in perpetuity of all present and future rights to this
software under copyright law.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
For more information, please refer to <http://unlicense.org>
*/
void calc_sha_256(uint8_t hash[32], const void *input, size_t len);

View File

@ -315,7 +315,7 @@ void Modem_SendAPDU(unsigned char* apdu_cmd, unsigned char* apdu_resp)
#endif //SAMPLE__GENERIC_MODEM #endif //SAMPLE__GENERIC_MODEM
#if SF_LPA_SDK #if 1 //SF_LPA_SDK
#define SCANF_MAX_LEN 20 #define SCANF_MAX_LEN 20
#define SCANF_MAX_ARGC 10 #define SCANF_MAX_ARGC 10
static UINT8 ScanfStr[SCANF_MAX_ARGC][SCANF_MAX_LEN] = {{0}}; static UINT8 ScanfStr[SCANF_MAX_ARGC][SCANF_MAX_LEN] = {{0}};
@ -1421,7 +1421,7 @@ bool SampleLPA_MemoryReset()
return(res); return(res);
} }
#if SF_LPA_SDK #if 1 //SF_LPA_SDK
SF_BOOL sf_get_eid(UINT8 *eidStr) SF_BOOL sf_get_eid(UINT8 *eidStr)
{ {
if(eidStr== NULL) if(eidStr== NULL)