26#define _TRACE_PREFIX_ "rss",__LINE__, ""
89 const char *chan_name;
110 stir_datastore =
ast_calloc(1,
sizeof(*stir_datastore));
111 if (!stir_datastore) {
131 if (chan_datastore) {
132 verifies = chan_datastore->
data;
142 if (!chan_datastore) {
166 chan_datastore->
data = verifies;
187 char *data,
char *
buf,
size_t len)
192 const char *chan_name;
196 unsigned int target_index = 0;
221 chan_name, function);
228 if (!strcasecmp(
first,
"count")) {
233 chan_name, function);
239 if (chan_datastore && chan_datastore->
data) {
240 verifies = chan_datastore->
data;
245 snprintf(
buf,
len,
"%zu", count);
253 ast_log(
LOG_ERROR,
"%s: Retrieving a value using %s requires two paramaters (index, value) "
254 "- only index was given\n", chan_name, function);
259 ast_log(
LOG_ERROR,
"%s: Failed to convert index %s to integer for function %s\n",
260 chan_name,
first, function);
266 if (!chan_datastore || !chan_datastore->
data) {
272 verifies = chan_datastore->
data;
281 if (!strcasecmp(second,
"identity")) {
283 }
else if (!strcasecmp(second,
"attestation")) {
285 }
else if (!strcasecmp(second,
"verify_result")) {
289 chan_name, second, function);
321 if (!chan_datastore) {
324 attestation_ds = chan_datastore->
data;
325 return attestation_ds;
336 char *stripped_value;
337 const char *channel_name = chan ?
ast_channel_name(chan) :
"unknown_channel";
364 channel_name, function, field);
370 ast_log(
LOG_ERROR,
"%s: %s requires a boolean value\n", channel_name, function);
377 if (chan_datastore) {
378 attestation_ds = chan_datastore->
data;
380 attestation_ds =
ast_calloc(1,
sizeof(*attestation_ds));
382 if (!attestation_ds || !chan_datastore) {
389 chan_datastore->
data = attestation_ds;
402 .
name =
"STIR_SHAKEN",
407 .
name =
"STIR_SHAKEN_ATTESTATION",
427#define TN_AUTH_LIST_OID "1.3.6.1.5.5.7.1.26"
428#define TN_AUTH_LIST_SHORT "TNAuthList"
429#define TN_AUTH_LIST_LONG "TNAuthorizationList"
433 const char *error_msg =
"There appears to be a 'stir_shaken.conf' file"
434 " with old configuration options in it. Please see the new config"
435 " file format in the configs/samples/stir_shaken.conf.sample file"
436 " in the source tree at https://github.com/asterisk/asterisk/raw/master/configs/samples/stir_shaken.conf.sample"
437 " or visit https://docs.asterisk.org/Deployment/STIR-SHAKEN for more information.";
461 if (strcasecmp(cat,
"general") == 0) {
466 if (
val && (strcasecmp(
val,
"store") == 0 ||
467 strcasecmp(
val,
"certificate") == 0)) {
524 .
requires =
"res_curl",
struct sla_ringing_trunk * first
Asterisk main include file. File version handling, generic pbx functions.
#define ast_strdup(str)
A wrapper for strdup()
#define ast_strdupa(s)
duplicate a string in memory from the stack
#define ast_calloc(num, len)
A wrapper for calloc()
const char * ast_channel_name(const struct ast_channel *chan)
int ast_channel_datastore_add(struct ast_channel *chan, struct ast_datastore *datastore)
Add a datastore to a channel.
#define ast_channel_lock(chan)
#define ast_channel_unlock(chan)
struct ast_datastore * ast_channel_datastore_find(struct ast_channel *chan, const struct ast_datastore_info *info, const char *uid)
Find a datastore on a channel.
Standard Command Line Interface.
int common_config_unload(void)
int common_config_reload(void)
int common_config_load(void)
Conversion utility functions.
int ast_str_to_uint(const char *str, unsigned int *res)
Convert the given string to an unsigned integer.
int crypto_register_x509_extension(const char *oid, const char *short_name, const char *long_name)
Register a certificate extension to openssl.
int crypto_load(void)
Initialize the crypto utils.
int crypto_unload(void)
Clean up the crypto utils.
#define ast_datastore_alloc(info, uid)
int ast_datastore_free(struct ast_datastore *datastore)
Free a data store object.
static int len(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)
globally accessible channel datastores
Application convenience functions, designed to give consistent look and feel to Asterisk apps.
#define AST_APP_ARG(name)
Define an application argument.
#define AST_DECLARE_APP_ARGS(name, arglist)
Declare a structure to hold an application's arguments.
#define AST_STANDARD_APP_ARGS(args, parse)
Performs the 'standard' argument separation process for an application.
#define ast_config_load(filename, flags)
Load a config file.
char * ast_category_browse(struct ast_config *config, const char *prev_name)
Browse categories.
#define CONFIG_STATUS_FILEMISSING
#define CONFIG_STATUS_FILEUNCHANGED
#define CONFIG_STATUS_FILEINVALID
void ast_config_destroy(struct ast_config *cfg)
Destroys a config.
const char * ast_variable_retrieve(struct ast_config *config, const char *category, const char *variable)
Asterisk module definitions.
@ AST_MODFLAG_GLOBAL_SYMBOLS
#define AST_MODULE_INFO(keystr, flags_to_set, desc, fields...)
@ AST_MODPRI_CHANNEL_DEPEND
@ AST_MODULE_SUPPORT_CORE
#define ASTERISK_GPL_KEY
The text the key() function should return.
@ AST_MODULE_LOAD_SUCCESS
@ AST_MODULE_LOAD_DECLINE
Module has failed to load, may be in an inconsistent state.
Core PBX routines and definitions.
#define ast_custom_function_register(acf)
Register a custom function.
int ast_custom_function_unregister(struct ast_custom_function *acf)
Unregister a custom function.
struct stir_shaken_attestation_ds * ast_stir_shaken_get_attestation_datastore(struct ast_channel *chan)
#define TN_AUTH_LIST_SHORT
int ast_stir_shaken_add_result_to_channel(struct ast_stir_shaken_vs_ctx *ctx)
Add a STIR/SHAKEN verification result to a channel.
static struct ast_custom_function stir_shaken_attestation
static const struct ast_datastore_info verification_ds_info
#define TN_AUTH_LIST_LONG
static void attestation_ds_destroy(void *data)
static struct ast_custom_function stir_shaken_verification
static const struct ast_datastore_info attestation_ds_info
static int reload_module(void)
static int check_for_old_config(void)
static void verification_ds_free(struct stir_shaken_verification_ds *datastore)
Frees a stir_shaken_datastore structure.
static int tn_auth_list_nid
static int load_module(void)
static int unload_module(void)
static int func_read_verification(struct ast_channel *chan, const char *function, char *data, char *buf, size_t len)
Retrieves STIR/SHAKEN verification information for the channel via dialplan. Examples:
static int func_write_attestation(struct ast_channel *chan, const char *function, char *data, const char *value)
int get_tn_auth_nid(void)
Retrieves the OpenSSL NID for the TN Auth list extension.
static void verification_ds_destroy_cb(void *data)
The callback to destroy a stir_shaken_datastore.
const char * vs_response_code_to_str(enum ast_stir_shaken_vs_response_code vs_rc)
Return string version of VS response code.
#define STIR_SHAKEN_ATTESTATION_DS
#define STIR_SHAKEN_VERIFICATION_DS
int ast_strings_equal(const char *str1, const char *str2)
Compare strings for equality checking for NULL.
int attribute_pure ast_true(const char *val)
Make sure something is true. Determine if a string containing a boolean value is "true"....
static force_inline int attribute_pure ast_strlen_zero(const char *s)
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
char * ast_strip(char *s)
Strip leading/trailing whitespace from a string.
Main Channel structure associated with a channel.
Data structure associated with a custom dialplan function.
Structure for a data store type.
Structure for a data store object.
Structure used to handle boolean flags.
const ast_string_field attestation
const ast_string_field identity_hdr
struct ast_channel * chan
enum ast_stir_shaken_vs_response_code failure_reason
enum ast_stir_shaken_vs_response_code verify_result
#define RAII_VAR(vartype, varname, initval, dtor)
Declare a variable that will call a destructor function when it goes out of scope.
Vector container support.
#define AST_VECTOR_RESET(vec, cleanup)
Reset vector.
#define AST_VECTOR_SIZE(vec)
Get the number of elements in a vector.
#define AST_VECTOR_INIT(vec, size)
Initialize a vector.
#define AST_VECTOR_APPEND(vec, elem)
Append an element to a vector, growing the vector if needed.
#define AST_VECTOR(name, type)
Define a vector structure.
#define AST_VECTOR_GET(vec, idx)
Get an element from a vector.