Asterisk - The Open Source Telephony Project  18.5.0
Functions
config_domain_aliases.c File Reference
#include "asterisk.h"
#include <pjsip.h>
#include <pjlib.h>
#include "asterisk/res_pjsip.h"
#include "include/res_pjsip_private.h"
#include "asterisk/logger.h"
#include "asterisk/sorcery.h"
Include dependency graph for config_domain_aliases.c:

Go to the source code of this file.

Functions

int ast_sip_initialize_sorcery_domain_alias (void)
 Initialize sorcery with domain alias support. More...
 
static void * domain_alias_alloc (const char *name)
 
static int domain_alias_apply (const struct ast_sorcery *sorcery, void *obj)
 Apply handler for domain_alias type. More...
 
static void domain_alias_destroy (void *obj)
 

Function Documentation

◆ ast_sip_initialize_sorcery_domain_alias()

int ast_sip_initialize_sorcery_domain_alias ( void  )

Initialize sorcery with domain alias support.

Definition at line 71 of file config_domain_aliases.c.

References ast_sip_get_sorcery(), ast_sorcery_apply_default, ast_sorcery_object_field_register, ast_sorcery_object_register, domain_alias_alloc(), domain_alias_apply(), NULL, OPT_NOOP_T, OPT_STRINGFIELD_T, SIP_SORCERY_DOMAIN_ALIAS_TYPE, sorcery, and STRFLDSET.

Referenced by ast_res_pjsip_initialize_configuration().

72 {
74 
75  ast_sorcery_apply_default(sorcery, SIP_SORCERY_DOMAIN_ALIAS_TYPE, "config", "pjsip.conf,criteria=type=domain_alias");
76 
79  return -1;
80  }
81 
83  OPT_NOOP_T, 0, 0);
86 
87  return 0;
88 }
Full structure for sorcery.
Definition: sorcery.c:230
Type for a default handler that should do nothing.
#define SIP_SORCERY_DOMAIN_ALIAS_TYPE
Definition: res_pjsip.h:254
static int domain_alias_apply(const struct ast_sorcery *sorcery, void *obj)
Apply handler for domain_alias type.
#define NULL
Definition: resample.c:96
Domain data structure.
Definition: sip.h:888
#define ast_sorcery_object_register(sorcery, type, alloc, transform, apply)
Register an object type.
Definition: sorcery.h:838
#define ast_sorcery_apply_default(sorcery, type, name, data)
Definition: sorcery.h:477
#define STRFLDSET(type,...)
Convert a struct and a list of stringfield fields to an argument list of field offsets.
#define ast_sorcery_object_field_register(sorcery, type, name, default_val, opt_type, flags,...)
Register a field within an object.
Definition: sorcery.h:955
static struct ast_sorcery * sorcery
struct ast_sorcery * ast_sip_get_sorcery(void)
Get a pointer to the SIP sorcery structure.
Type for default option handler for stringfields.
static void * domain_alias_alloc(const char *name)

◆ domain_alias_alloc()

static void* domain_alias_alloc ( const char *  name)
static

Definition at line 36 of file config_domain_aliases.c.

References ao2_cleanup, ast_sorcery_generic_alloc(), ast_string_field_init, domain_alias_destroy(), and NULL.

Referenced by ast_sip_initialize_sorcery_domain_alias().

37 {
38  struct ast_sip_domain_alias *alias;
39 
40  alias = ast_sorcery_generic_alloc(sizeof(*alias), domain_alias_destroy);
41  if (!alias) {
42  return NULL;
43  }
44 
45  if (ast_string_field_init(alias, 256)) {
46  ao2_cleanup(alias);
47  return NULL;
48  }
49 
50  return alias;
51 }
#define NULL
Definition: resample.c:96
#define ast_string_field_init(x, size)
Initialize a field pool and fields.
Definition: stringfields.h:353
#define ao2_cleanup(obj)
Definition: astobj2.h:1958
void * ast_sorcery_generic_alloc(size_t size, ao2_destructor_fn destructor)
Allocate a generic sorcery capable object.
Definition: sorcery.c:1728
static void domain_alias_destroy(void *obj)

◆ domain_alias_apply()

static int domain_alias_apply ( const struct ast_sorcery sorcery,
void *  obj 
)
static

Apply handler for domain_alias type.

Definition at line 54 of file config_domain_aliases.c.

References ast_log, ast_sorcery_object_get_id(), ast_strlen_zero, ast_sip_domain_alias::domain, LOG_ERROR, and SIP_SORCERY_DOMAIN_ALIAS_TYPE.

Referenced by ast_sip_initialize_sorcery_domain_alias().

55 {
56  struct ast_sip_domain_alias *alias = obj;
57 
58  if (ast_strlen_zero(alias->domain)) {
59  /*
60  * What is the point of defining an alias and not saying
61  * what is being aliased?
62  */
63  ast_log(LOG_ERROR, "%s '%s' missing required domain being aliased.\n",
65  return -1;
66  }
67  return 0;
68 }
#define SIP_SORCERY_DOMAIN_ALIAS_TYPE
Definition: res_pjsip.h:254
#define ast_strlen_zero(foo)
Definition: strings.h:52
#define ast_log
Definition: astobj2.c:42
const char * ast_sorcery_object_get_id(const void *object)
Get the unique identifier of a sorcery object.
Definition: sorcery.c:2312
#define LOG_ERROR
Definition: logger.h:285
const ast_string_field domain
Definition: res_pjsip.h:265

◆ domain_alias_destroy()

static void domain_alias_destroy ( void *  obj)
static

Definition at line 29 of file config_domain_aliases.c.

References ast_string_field_free_memory.

Referenced by domain_alias_alloc().

30 {
31  struct ast_sip_domain_alias *alias = obj;
32 
34 }
#define ast_string_field_free_memory(x)
free all memory - to be called before destroying the object
Definition: stringfields.h:368