Asterisk - The Open Source Telephony Project GIT-master-27fb039
Loading...
Searching...
No Matches
Data Structures | Macros | Functions | Variables
res_stir_shaken.c File Reference
#include "asterisk.h"
#include "asterisk/app.h"
#include "asterisk/cli.h"
#include "asterisk/conversions.h"
#include "asterisk/module.h"
#include "asterisk/global_datastores.h"
#include "asterisk/pbx.h"
#include "asterisk/vector.h"
#include "res_stir_shaken/stir_shaken.h"
Include dependency graph for res_stir_shaken.c:

Go to the source code of this file.

Data Structures

struct  verification_vector
 

Macros

#define _TRACE_PREFIX_   "rss",__LINE__, ""
 
#define TN_AUTH_LIST_LONG   "TNAuthorizationList"
 
#define TN_AUTH_LIST_OID   "1.3.6.1.5.5.7.1.26"
 
#define TN_AUTH_LIST_SHORT   "TNAuthList"
 

Functions

static void __reg_module (void)
 
static void __unreg_module (void)
 
struct ast_moduleAST_MODULE_SELF_SYM (void)
 
int ast_stir_shaken_add_result_to_channel (struct ast_stir_shaken_vs_ctx *ctx)
 Add a STIR/SHAKEN verification result to a channel.
 
struct stir_shaken_attestation_dsast_stir_shaken_get_attestation_datastore (struct ast_channel *chan)
 
static void attestation_ds_destroy (void *data)
 
static int check_for_old_config (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 int load_module (void)
 
static int reload_module (void)
 
static int unload_module (void)
 
static void verification_ds_destroy_cb (void *data)
 The callback to destroy a stir_shaken_datastore.
 
static void verification_ds_free (struct stir_shaken_verification_ds *datastore)
 Frees a stir_shaken_datastore structure.
 

Variables

static struct ast_module_info __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_GLOBAL_SYMBOLS | AST_MODFLAG_LOAD_ORDER , .description = "STIR/SHAKEN Module for Asterisk" , .key = ASTERISK_GPL_KEY , .buildopt_sum = AST_BUILDOPT_SUM, .support_level = AST_MODULE_SUPPORT_CORE, .load = load_module, .unload = unload_module, .reload = reload_module, .load_pri = AST_MODPRI_CHANNEL_DEPEND - 1, .requires = "res_curl", }
 
static const struct ast_module_infoast_module_info = &__mod_info
 
static const struct ast_datastore_info attestation_ds_info
 
static struct ast_custom_function stir_shaken_attestation
 
static struct ast_custom_function stir_shaken_verification
 
static int tn_auth_list_nid
 
static const struct ast_datastore_info verification_ds_info
 

Macro Definition Documentation

◆ _TRACE_PREFIX_

#define _TRACE_PREFIX_   "rss",__LINE__, ""

Definition at line 26 of file res_stir_shaken.c.

◆ TN_AUTH_LIST_LONG

#define TN_AUTH_LIST_LONG   "TNAuthorizationList"

Definition at line 429 of file res_stir_shaken.c.

◆ TN_AUTH_LIST_OID

#define TN_AUTH_LIST_OID   "1.3.6.1.5.5.7.1.26"

Definition at line 427 of file res_stir_shaken.c.

◆ TN_AUTH_LIST_SHORT

#define TN_AUTH_LIST_SHORT   "TNAuthList"

Definition at line 428 of file res_stir_shaken.c.

Function Documentation

◆ __reg_module()

static void __reg_module ( void  )
static

Definition at line 525 of file res_stir_shaken.c.

◆ __unreg_module()

static void __unreg_module ( void  )
static

Definition at line 525 of file res_stir_shaken.c.

◆ AST_MODULE_SELF_SYM()

struct ast_module * AST_MODULE_SELF_SYM ( void  )

Definition at line 525 of file res_stir_shaken.c.

◆ ast_stir_shaken_add_result_to_channel()

int ast_stir_shaken_add_result_to_channel ( struct ast_stir_shaken_vs_ctx ctx)

Add a STIR/SHAKEN verification result to a channel.

Parameters
ctxVS context
Return values
-1on failure
0on success

Definition at line 83 of file res_stir_shaken.c.

85{
86 struct stir_shaken_verification_ds *stir_datastore;
87 struct ast_datastore *chan_datastore;
88 struct verification_vector *verifies;
89 const char *chan_name;
90 int res = 0;
91
92 if (!ctx->chan) {
93 ast_log(LOG_ERROR, "Channel is required to add verification\n");
94 return -1;
95 }
96
97 chan_name = ast_channel_name(ctx->chan);
98
99 if (!ctx->identity_hdr) {
100 ast_log(LOG_ERROR, "%s: No identity to add to datastore\n",
101 chan_name);
102 return -1;
103 }
104
105 if (!ctx->attestation) {
106 ast_log(LOG_ERROR, "%s: Attestation cannot be NULL\n", chan_name);
107 return -1;
108 }
109
110 stir_datastore = ast_calloc(1, sizeof(*stir_datastore));
111 if (!stir_datastore) {
112 return -1;
113 }
114
115 stir_datastore->identity = ast_strdup(ctx->identity_hdr);
116 if (!stir_datastore->identity) {
117 verification_ds_free(stir_datastore);
118 return -1;
119 }
120
121 stir_datastore->attestation = ast_strdup(ctx->attestation);
122 if (!stir_datastore->attestation) {
123 verification_ds_free(stir_datastore);
124 return -1;
125 }
126
127 stir_datastore->verify_result = ctx->failure_reason;
128
131 if (chan_datastore) {
132 verifies = chan_datastore->data;
133 res = AST_VECTOR_APPEND(verifies, stir_datastore);
134 if (res != 0) {
135 verification_ds_free(stir_datastore);
136 }
138 return res;
139 }
140
142 if (!chan_datastore) {
143 verification_ds_free(stir_datastore);
144 return -1;
145 }
146 /*
147 * We don't pass this datastore to other channels at the current time.
148 * Inheritance is disabled by default but it's called out here for clarity.
149 */
150 chan_datastore->inheritance = 0;
151
152 verifies = ast_calloc(sizeof(*verifies), 1);
153 if (!verifies) {
155 verification_ds_free(stir_datastore);
156 ast_datastore_free(chan_datastore);
157 return -1;
158 }
159 AST_VECTOR_INIT(verifies, 0);
160
161 res = AST_VECTOR_APPEND(verifies, stir_datastore);
162 if (res != 0) {
163 ast_free(verifies);
164 verification_ds_free(stir_datastore);
165 } else {
166 chan_datastore->data = verifies;
167 ast_channel_datastore_add(ctx->chan, chan_datastore);
168 }
170
171 return res;
172}
#define ast_free(a)
Definition astmm.h:180
#define ast_strdup(str)
A wrapper for strdup()
Definition astmm.h:241
#define ast_calloc(num, len)
A wrapper for calloc()
Definition astmm.h:202
#define ast_log
Definition astobj2.c:42
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.
Definition channel.c:2375
#define ast_channel_lock(chan)
Definition channel.h:2982
#define ast_channel_unlock(chan)
Definition channel.h:2983
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.
Definition channel.c:2389
#define ast_datastore_alloc(info, uid)
Definition datastore.h:85
int ast_datastore_free(struct ast_datastore *datastore)
Free a data store object.
Definition datastore.c:68
#define LOG_ERROR
static const struct ast_datastore_info verification_ds_info
static void verification_ds_free(struct stir_shaken_verification_ds *datastore)
Frees a stir_shaken_datastore structure.
#define NULL
Definition resample.c:96
Structure for a data store object.
Definition datastore.h:64
void * data
Definition datastore.h:66
unsigned int inheritance
Definition datastore.h:69
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
Definition stir_shaken.h:39
#define AST_VECTOR_INIT(vec, size)
Initialize a vector.
Definition vector.h:124
#define AST_VECTOR_APPEND(vec, elem)
Append an element to a vector, growing the vector if needed.
Definition vector.h:267

References ast_calloc, ast_channel_datastore_add(), ast_channel_datastore_find(), ast_channel_lock, ast_channel_name(), ast_channel_unlock, ast_datastore_alloc, ast_datastore_free(), ast_free, ast_log, ast_strdup, AST_VECTOR_APPEND, AST_VECTOR_INIT, stir_shaken_verification_ds::attestation, ast_stir_shaken_vs_ctx::attestation, ast_stir_shaken_vs_ctx::chan, ast_datastore::data, ast_stir_shaken_vs_ctx::failure_reason, stir_shaken_verification_ds::identity, ast_stir_shaken_vs_ctx::identity_hdr, ast_datastore::inheritance, LOG_ERROR, NULL, verification_ds_free(), verification_ds_info, and stir_shaken_verification_ds::verify_result.

Referenced by process_failure(), and stir_shaken_incoming_request().

◆ ast_stir_shaken_get_attestation_datastore()

struct stir_shaken_attestation_ds * ast_stir_shaken_get_attestation_datastore ( struct ast_channel chan)

Definition at line 314 of file res_stir_shaken.c.

316{
317 struct stir_shaken_attestation_ds *attestation_ds;
318 struct ast_datastore *chan_datastore;
319
320 chan_datastore = ast_channel_datastore_find(chan, &attestation_ds_info, NULL);
321 if (!chan_datastore) {
322 return NULL;
323 }
324 attestation_ds = chan_datastore->data;
325 return attestation_ds;
326}
static const struct ast_datastore_info attestation_ds_info

References ast_channel_datastore_find(), attestation_ds_info, ast_datastore::data, and NULL.

Referenced by stir_shaken_outgoing_request().

◆ attestation_ds_destroy()

static void attestation_ds_destroy ( void *  data)
static

Definition at line 304 of file res_stir_shaken.c.

305{
306 ast_free(data);
307}

References ast_free.

Referenced by func_write_attestation().

◆ check_for_old_config()

static int check_for_old_config ( void  )
static

Definition at line 431 of file res_stir_shaken.c.

432{
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.";
439 struct ast_flags config_flags = { 0 };
440 char *cat = NULL;
441
442 cfg = ast_config_load("stir_shaken.conf", config_flags);
443 if (cfg == CONFIG_STATUS_FILEMISSING) {
444 /*
445 * They may be loading from realtime so the fact that there's
446 * no stir-shaken.conf file isn't an issue for this purpose.
447 */
449 } else if (cfg == CONFIG_STATUS_FILEINVALID) {
450 cfg = NULL;
451 ast_log(LOG_ERROR, "The stir_shaken.conf file is invalid\n");
453 } else if (cfg == CONFIG_STATUS_FILEUNCHANGED) {
454 /* This can never happen but is included for completeness */
455 cfg = NULL;
457 }
458
459 while ((cat = ast_category_browse(cfg, cat))) {
460 const char *val;
461 if (strcasecmp(cat, "general") == 0) {
462 ast_log(LOG_ERROR, "%s\n", error_msg);
464 }
465 val = ast_variable_retrieve(cfg, cat, "type");
466 if (val && (strcasecmp(val, "store") == 0 ||
467 strcasecmp(val, "certificate") == 0)) {
468 ast_log(LOG_ERROR, "%s\n", error_msg);
470 }
471 }
472
474}
#define ast_config_load(filename, flags)
Load a config file.
char * ast_category_browse(struct ast_config *config, const char *prev_name)
Browse categories.
Definition extconf.c:3324
#define CONFIG_STATUS_FILEMISSING
#define CONFIG_STATUS_FILEUNCHANGED
#define CONFIG_STATUS_FILEINVALID
void ast_config_destroy(struct ast_config *cfg)
Destroys a config.
Definition extconf.c:1287
const char * ast_variable_retrieve(struct ast_config *config, const char *category, const char *variable)
@ AST_MODULE_LOAD_SUCCESS
Definition module.h:70
@ AST_MODULE_LOAD_DECLINE
Module has failed to load, may be in an inconsistent state.
Definition module.h:78
Structure used to handle boolean flags.
Definition utils.h:220
#define RAII_VAR(vartype, varname, initval, dtor)
Declare a variable that will call a destructor function when it goes out of scope.
Definition utils.h:981

References ast_category_browse(), ast_config_destroy(), ast_config_load, ast_log, AST_MODULE_LOAD_DECLINE, AST_MODULE_LOAD_SUCCESS, ast_variable_retrieve(), CONFIG_STATUS_FILEINVALID, CONFIG_STATUS_FILEMISSING, CONFIG_STATUS_FILEUNCHANGED, LOG_ERROR, NULL, and RAII_VAR.

Referenced by load_module().

◆ func_read_verification()

static int func_read_verification ( struct ast_channel chan,
const char *  function,
char *  data,
char *  buf,
size_t  len 
)
static

Retrieves STIR/SHAKEN verification information for the channel via dialplan. Examples:

STIR_SHAKEN(count) STIR_SHAKEN(0, identity) STIR_SHAKEN(1, attestation) STIR_SHAKEN(27, verify_result)

Return values
-1on failure
0on success

Definition at line 186 of file res_stir_shaken.c.

188{
189 struct stir_shaken_verification_ds *stir_datastore;
190 struct ast_datastore *chan_datastore;
191 struct verification_vector *verifies;
192 const char *chan_name;
193 char *parse;
194 char *first;
195 char *second;
196 unsigned int target_index = 0;
197 int res = 0;
199 AST_APP_ARG(first_param);
200 AST_APP_ARG(second_param);
201 );
202
203 if (ast_strlen_zero(data)) {
204 ast_log(LOG_WARNING, "%s requires at least one argument\n", function);
205 return -1;
206 }
207
208 if (!chan) {
209 ast_log(LOG_ERROR, "No channel for %s function\n", function);
210 return -1;
211 }
212 chan_name = ast_channel_name(chan);
213
214 parse = ast_strdupa(data);
215
217
218 first = ast_strip(args.first_param);
219 if (ast_strlen_zero(first)) {
220 ast_log(LOG_ERROR, "%s: An argument must be passed to %s\n",
221 chan_name, function);
222 return -1;
223 }
224
225 second = ast_strip(args.second_param);
226
227 /* Check if we are only looking for the number of STIR/SHAKEN verification results */
228 if (!strcasecmp(first, "count")) {
229 size_t count = 0;
230
231 if (!ast_strlen_zero(second)) {
232 ast_log(LOG_ERROR, "%s: %s only takes 1 paramater for 'count'\n",
233 chan_name, function);
234 return -1;
235 }
236
237 ast_channel_lock(chan);
238 chan_datastore = ast_channel_datastore_find(chan, &verification_ds_info, NULL);
239 if (chan_datastore && chan_datastore->data) {
240 verifies = chan_datastore->data;
241 count = AST_VECTOR_SIZE(verifies);
242 }
243 ast_channel_unlock(chan);
244
245 snprintf(buf, len, "%zu", count);
246 return 0;
247 }
248
249 /* If we aren't doing a count, then there should be two parameters. The field
250 * we are searching for will be the second parameter. The index is the first.
251 */
252 if (ast_strlen_zero(second)) {
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);
255 return -1;
256 }
257
258 if (ast_str_to_uint(first, &target_index)) {
259 ast_log(LOG_ERROR, "%s: Failed to convert index %s to integer for function %s\n",
260 chan_name, first, function);
261 return -1;
262 }
263
264 ast_channel_lock(chan);
265 chan_datastore = ast_channel_datastore_find(chan, &verification_ds_info, NULL);
266 if (!chan_datastore || !chan_datastore->data) {
267 ast_channel_unlock(chan);
268 ast_log(LOG_WARNING, "%s: No STIR/SHAKEN results for index '%s'\n",
269 chan_name, first);
270 return -1;
271 }
272 verifies = chan_datastore->data;
273 if (target_index >= AST_VECTOR_SIZE(verifies)) {
274 ast_channel_unlock(chan);
275 ast_log(LOG_WARNING, "%s: No STIR/SHAKEN results for index '%s'\n",
276 chan_name, first);
277 return -1;
278 }
279 stir_datastore = AST_VECTOR_GET(verifies, target_index);
280
281 if (!strcasecmp(second, "identity")) {
282 ast_copy_string(buf, stir_datastore->identity, len);
283 } else if (!strcasecmp(second, "attestation")) {
284 ast_copy_string(buf, stir_datastore->attestation, len);
285 } else if (!strcasecmp(second, "verify_result")) {
287 } else {
288 ast_log(LOG_ERROR, "%s: No such value '%s' for %s\n",
289 chan_name, second, function);
290 res = -1;
291 }
292
293 ast_channel_unlock(chan);
294
295 return res;
296}
struct sla_ringing_trunk * first
Definition app_sla.c:338
#define ast_strdupa(s)
duplicate a string in memory from the stack
Definition astmm.h:298
int ast_str_to_uint(const char *str, unsigned int *res)
Convert the given string to an unsigned integer.
Definition conversions.c:56
char buf[BUFSIZE]
Definition eagi_proxy.c:66
static int len(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)
#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 LOG_WARNING
static struct @519 args
const char * vs_response_code_to_str(enum ast_stir_shaken_vs_response_code vs_rc)
Return string version of VS response code.
static force_inline int attribute_pure ast_strlen_zero(const char *s)
Definition strings.h:65
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
Definition strings.h:425
char * ast_strip(char *s)
Strip leading/trailing whitespace from a string.
Definition strings.h:223
#define AST_VECTOR_SIZE(vec)
Get the number of elements in a vector.
Definition vector.h:620
#define AST_VECTOR_GET(vec, idx)
Get an element from a vector.
Definition vector.h:691

References args, AST_APP_ARG, ast_channel_datastore_find(), ast_channel_lock, ast_channel_name(), ast_channel_unlock, ast_copy_string(), AST_DECLARE_APP_ARGS, ast_log, AST_STANDARD_APP_ARGS, ast_str_to_uint(), ast_strdupa, ast_strip(), ast_strlen_zero(), AST_VECTOR_GET, AST_VECTOR_SIZE, stir_shaken_verification_ds::attestation, buf, ast_datastore::data, first, stir_shaken_verification_ds::identity, len(), LOG_ERROR, LOG_WARNING, NULL, verification_ds_info, stir_shaken_verification_ds::verify_result, and vs_response_code_to_str().

◆ func_write_attestation()

static int func_write_attestation ( struct ast_channel chan,
const char *  function,
char *  data,
const char *  value 
)
static

Definition at line 329 of file res_stir_shaken.c.

331{
332 struct stir_shaken_attestation_ds *attestation_ds;
333 struct ast_datastore *chan_datastore;
334 char *parse;
335 char *field;
336 char *stripped_value;
337 const char *channel_name = chan ? ast_channel_name(chan) : "unknown_channel";
339 AST_APP_ARG(field);
340 );
341
342 if (!chan) {
343 ast_log(LOG_ERROR, "No channel for %s function\n", function);
344 return -1;
345 }
346
347 if (ast_strlen_zero(data)) {
348 ast_log(LOG_WARNING, "%s: %s requires a field to set\n", channel_name, function);
349 return -1;
350 }
351
352 parse = ast_strdupa(data);
353
355
356 field = ast_strip(args.field);
357 if (ast_strlen_zero(field)) {
358 ast_log(LOG_WARNING, "%s: %s requires a field to set\n", channel_name, function);
359 return -1;
360 }
361
362 if (!ast_strings_equal(field, "suppress")) {
363 ast_log(LOG_ERROR, "%s: %s was passed invalid field '%s'\n",
364 channel_name, function, field);
365 return -1;
366 }
367
368 stripped_value = ast_strip(ast_strdupa(value));
369 if (ast_strlen_zero(stripped_value)) {
370 ast_log(LOG_ERROR, "%s: %s requires a boolean value\n", channel_name, function);
371 return -1;
372 }
373
374 ast_channel_lock(chan);
375 chan_datastore = ast_channel_datastore_find(chan, &attestation_ds_info, NULL);
376
377 if (chan_datastore) {
378 attestation_ds = chan_datastore->data;
379 } else {
380 attestation_ds = ast_calloc(1, sizeof(*attestation_ds));
381 chan_datastore = ast_datastore_alloc(&attestation_ds_info, NULL);
382 if (!attestation_ds || !chan_datastore) {
383 ast_channel_unlock(chan);
384 attestation_ds_destroy(attestation_ds);
385 ast_datastore_free(chan_datastore);
386 return -1;
387 }
388
389 chan_datastore->data = attestation_ds;
390 chan_datastore->inheritance = 0;
391
392 ast_channel_datastore_add(chan, chan_datastore);
393 }
394
395 attestation_ds->suppress = ast_true(stripped_value);
396 ast_channel_unlock(chan);
397
398 return 0;
399}
static void attestation_ds_destroy(void *data)
int ast_strings_equal(const char *str1, const char *str2)
Compare strings for equality checking for NULL.
Definition strings.c:238
int attribute_pure ast_true(const char *val)
Make sure something is true. Determine if a string containing a boolean value is "true"....
Definition utils.c:2235
int value
Definition syslog.c:37

References args, AST_APP_ARG, ast_calloc, ast_channel_datastore_add(), ast_channel_datastore_find(), ast_channel_lock, ast_channel_name(), ast_channel_unlock, ast_datastore_alloc, ast_datastore_free(), AST_DECLARE_APP_ARGS, ast_log, AST_STANDARD_APP_ARGS, ast_strdupa, ast_strings_equal(), ast_strip(), ast_strlen_zero(), ast_true(), attestation_ds_destroy(), attestation_ds_info, ast_datastore::data, ast_datastore::inheritance, LOG_ERROR, LOG_WARNING, NULL, stir_shaken_attestation_ds::suppress, and value.

◆ get_tn_auth_nid()

int get_tn_auth_nid ( void  )

Retrieves the OpenSSL NID for the TN Auth list extension.

Return values
TheNID

Definition at line 44 of file res_stir_shaken.c.

45{
46 return tn_auth_list_nid;
47}
static int tn_auth_list_nid

References tn_auth_list_nid.

Referenced by check_tn_auth_list().

◆ load_module()

static int load_module ( void  )
static

Definition at line 476 of file res_stir_shaken.c.

477{
478 int res = 0;
479
480 res = check_for_old_config();
481 if (res != AST_MODULE_LOAD_SUCCESS) {
482 return res;
483 }
484
485 res = crypto_load();
486 if (res != AST_MODULE_LOAD_SUCCESS) {
487 return res;
488 }
489
492 if (tn_auth_list_nid < 0) {
495 }
496
497 res = common_config_load();
498 if (res != AST_MODULE_LOAD_SUCCESS) {
500 return res;
501 }
502
504 if (res != 0) {
507 }
508
510 if (res != 0) {
513 }
514
516}
int common_config_load(void)
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.
#define ast_custom_function_register(acf)
Register a custom function.
Definition pbx.h:1562
#define TN_AUTH_LIST_SHORT
static struct ast_custom_function stir_shaken_attestation
#define TN_AUTH_LIST_OID
#define TN_AUTH_LIST_LONG
static struct ast_custom_function stir_shaken_verification
static int check_for_old_config(void)
static int unload_module(void)

References ast_custom_function_register, AST_MODULE_LOAD_DECLINE, AST_MODULE_LOAD_SUCCESS, check_for_old_config(), common_config_load(), crypto_load(), crypto_register_x509_extension(), stir_shaken_attestation, stir_shaken_verification, TN_AUTH_LIST_LONG, tn_auth_list_nid, TN_AUTH_LIST_OID, TN_AUTH_LIST_SHORT, and unload_module().

◆ reload_module()

static int reload_module ( void  )
static

Definition at line 411 of file res_stir_shaken.c.

412{
413 return common_config_reload();
414}
int common_config_reload(void)

References common_config_reload().

◆ unload_module()

static int unload_module ( void  )
static

Definition at line 416 of file res_stir_shaken.c.

417{
420
423
424 return 0;
425}
int common_config_unload(void)
int crypto_unload(void)
Clean up the crypto utils.
int ast_custom_function_unregister(struct ast_custom_function *acf)
Unregister a custom function.

References ast_custom_function_unregister(), common_config_unload(), crypto_unload(), stir_shaken_attestation, and stir_shaken_verification.

Referenced by load_module().

◆ verification_ds_destroy_cb()

static void verification_ds_destroy_cb ( void *  data)
static

The callback to destroy a stir_shaken_datastore.

Parameters
dataThe stir_shaken_datastore

Definition at line 70 of file res_stir_shaken.c.

71{
72 struct verification_vector *verifies = data;
73
75 ast_free(verifies);
76}
#define AST_VECTOR_RESET(vec, cleanup)
Reset vector.
Definition vector.h:636

References ast_free, AST_VECTOR_RESET, and verification_ds_free().

◆ verification_ds_free()

static void verification_ds_free ( struct stir_shaken_verification_ds datastore)
static

Frees a stir_shaken_datastore structure.

Parameters
datastoreThe datastore to free

Definition at line 54 of file res_stir_shaken.c.

55{
56 if (!datastore) {
57 return;
58 }
59
60 ast_free(datastore->identity);
61 ast_free(datastore->attestation);
62 ast_free(datastore);
63}

References ast_free, stir_shaken_verification_ds::attestation, and stir_shaken_verification_ds::identity.

Referenced by ast_stir_shaken_add_result_to_channel(), and verification_ds_destroy_cb().

Variable Documentation

◆ __mod_info

struct ast_module_info __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_GLOBAL_SYMBOLS | AST_MODFLAG_LOAD_ORDER , .description = "STIR/SHAKEN Module for Asterisk" , .key = ASTERISK_GPL_KEY , .buildopt_sum = AST_BUILDOPT_SUM, .support_level = AST_MODULE_SUPPORT_CORE, .load = load_module, .unload = unload_module, .reload = reload_module, .load_pri = AST_MODPRI_CHANNEL_DEPEND - 1, .requires = "res_curl", }
static

Definition at line 525 of file res_stir_shaken.c.

◆ ast_module_info

const struct ast_module_info* ast_module_info = &__mod_info
static

Definition at line 525 of file res_stir_shaken.c.

◆ attestation_ds_info

const struct ast_datastore_info attestation_ds_info
static
Initial value:
= {
}
#define STIR_SHAKEN_ATTESTATION_DS
Definition stir_shaken.h:42

Definition at line 309 of file res_stir_shaken.c.

309 {
311 .destroy = attestation_ds_destroy,
312};

Referenced by ast_stir_shaken_get_attestation_datastore(), and func_write_attestation().

◆ stir_shaken_attestation

struct ast_custom_function stir_shaken_attestation
static
Initial value:
= {
.name = "STIR_SHAKEN_ATTESTATION",
}
static int func_write_attestation(struct ast_channel *chan, const char *function, char *data, const char *value)

Definition at line 406 of file res_stir_shaken.c.

406 {
407 .name = "STIR_SHAKEN_ATTESTATION",
408 .write = func_write_attestation,
409};

Referenced by load_module(), and unload_module().

◆ stir_shaken_verification

struct ast_custom_function stir_shaken_verification
static
Initial value:
= {
.name = "STIR_SHAKEN",
}
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:

Definition at line 401 of file res_stir_shaken.c.

401 {
402 .name = "STIR_SHAKEN",
404};

Referenced by load_module(), and unload_module().

◆ tn_auth_list_nid

int tn_auth_list_nid
static

Definition at line 42 of file res_stir_shaken.c.

Referenced by get_tn_auth_nid(), and load_module().

◆ verification_ds_info

const struct ast_datastore_info verification_ds_info
static
Initial value:
= {
}
static void verification_ds_destroy_cb(void *data)
The callback to destroy a stir_shaken_datastore.
#define STIR_SHAKEN_VERIFICATION_DS
Definition stir_shaken.h:32

Definition at line 78 of file res_stir_shaken.c.

78 {
81};

Referenced by ast_stir_shaken_add_result_to_channel(), and func_read_verification().