Asterisk - The Open Source Telephony Project
18.5.0
|
#include "asterisk.h"
#include "asterisk/utils.h"
#include "asterisk/logger.h"
#include "curl.h"
#include "general.h"
#include "stir_shaken.h"
#include <curl/curl.h>
#include <sys/stat.h>
Go to the source code of this file.
Data Structures | |
struct | curl_cb_data |
Macros | |
#define | GLOBAL_USERAGENT "asterisk-libcurl-agent/1.0" |
#define | MAX_HEADER_LENGTH 1023 |
Functions | |
static int | create_temp_file (const char *path, char **filename) |
Create a temporary file located at path. More... | |
struct curl_cb_data * | curl_cb_data_create (void) |
Allocate memory for a curl_cb_data struct. More... | |
void | curl_cb_data_free (struct curl_cb_data *data) |
Free a curl_cb_data struct. More... | |
char * | curl_cb_data_get_cache_control (const struct curl_cb_data *data) |
Get the cache_control field from a curl_cb_data struct. More... | |
char * | curl_cb_data_get_expires (const struct curl_cb_data *data) |
Get the expires field from a curl_cb_data struct. More... | |
static size_t | curl_header_callback (char *buffer, size_t size, size_t nitems, void *data) |
Called when a CURL request completes. More... | |
char * | curl_public_key (const char *public_cert_url, const char *path, struct curl_cb_data *data) |
CURL the public key from the provided URL to the specified path. More... | |
static CURL * | get_curl_instance (struct curl_cb_data *data) |
Prepare a CURL instance to use. More... | |
#define GLOBAL_USERAGENT "asterisk-libcurl-agent/1.0" |
Definition at line 34 of file curl.c.
Referenced by get_curl_instance().
#define MAX_HEADER_LENGTH 1023 |
Definition at line 31 of file curl.c.
Referenced by curl_header_callback().
|
static |
Create a temporary file located at path.
path | The directory path to create the file in |
filename | Function allocates memory and stores full filename (including path) here |
-1 | on failure |
file | descriptor on success |
Definition at line 164 of file curl.c.
References ast_asprintf, ast_free, ast_log, ast_mkdir(), LOG_ERROR, and LOG_NOTICE.
Referenced by curl_public_key().
struct curl_cb_data* curl_cb_data_create | ( | void | ) |
Allocate memory for a curl_cb_data struct.
NULL | on failure |
curl_cb_struct | on success |
Definition at line 42 of file curl.c.
References ast_calloc.
Referenced by run_curl().
void curl_cb_data_free | ( | struct curl_cb_data * | data | ) |
Free a curl_cb_data struct.
data | The curl_cb_data struct to free |
Definition at line 51 of file curl.c.
References ast_free, curl_cb_data::cache_control, and curl_cb_data::expires.
Referenced by run_curl().
char* curl_cb_data_get_cache_control | ( | const struct curl_cb_data * | data | ) |
Get the cache_control field from a curl_cb_data struct.
data | The curl_cb_data |
cache_control | on success |
NULL | otherwise |
Definition at line 63 of file curl.c.
References curl_cb_data::cache_control, and NULL.
Referenced by set_public_key_expiration().
char* curl_cb_data_get_expires | ( | const struct curl_cb_data * | data | ) |
Get the expires field from a curl_cb_data struct.
data | The curl_cb_data |
expires | on success |
NULL | otherwise |
Definition at line 72 of file curl.c.
References curl_cb_data::expires, and NULL.
Referenced by set_public_key_expiration().
|
static |
Called when a CURL request completes.
data | The curl_cb_data structure to store expiration info |
Definition at line 86 of file curl.c.
References ast_alloca, ast_log, ast_skip_blanks(), ast_strdup, ast_trim_blanks(), curl_cb_data::cache_control, curl_cb_data::expires, LOG_WARNING, MAX_HEADER_LENGTH, and value.
Referenced by get_curl_instance().
char* curl_public_key | ( | const char * | public_cert_url, |
const char * | path, | ||
struct curl_cb_data * | data | ||
) |
CURL the public key from the provided URL to the specified path.
public_cert_url | The public cert URL |
path | The path to download the file to |
data | The curl_cb_data |
NULL | on failure |
full | path filename on success |
Definition at line 185 of file curl.c.
References ast_asprintf, ast_free, ast_log, create_temp_file(), errno, get_curl_instance(), LOG_ERROR, NULL, RAII_VAR, and stir_shaken_get_serial_number_x509().
Referenced by run_curl().
|
static |
Prepare a CURL instance to use.
data | The CURL callback data |
NULL | on failure |
CURL | instance on success |
Definition at line 128 of file curl.c.
References ao2_cleanup, ast_stir_shaken_curl_timeout(), curl_header_callback(), stir_shaken_general::curl_timeout, GLOBAL_USERAGENT, NULL, and stir_shaken_general_get().
Referenced by curl_public_key().