Asterisk - The Open Source Telephony Project GIT-master-7921072
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.

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);
85 "", OPT_STRINGFIELD_T, 0, STRFLDSET(struct ast_sip_domain_alias, domain));
86
87 return 0;
88}
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.
#define STRFLDSET(type,...)
Convert a struct and a list of stringfield fields to an argument list of field offsets.
@ OPT_NOOP_T
Type for a default handler that should do nothing.
@ OPT_STRINGFIELD_T
Type for default option handler for stringfields.
struct ast_sorcery * ast_sip_get_sorcery(void)
Get a pointer to the SIP sorcery structure.
#define SIP_SORCERY_DOMAIN_ALIAS_TYPE
Definition: res_pjsip.h:312
static struct ast_sorcery * sorcery
#define NULL
Definition: resample.c:96
#define ast_sorcery_object_register(sorcery, type, alloc, transform, apply)
Register an object type.
Definition: sorcery.h:837
#define ast_sorcery_object_field_register(sorcery, type, name, default_val, opt_type, flags,...)
Register a field within an object.
Definition: sorcery.h:955
#define ast_sorcery_apply_default(sorcery, type, name, data)
Definition: sorcery.h:476
Full structure for sorcery.
Definition: sorcery.c:230

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().

◆ domain_alias_alloc()

static void * domain_alias_alloc ( const char *  name)
static

Definition at line 36 of file config_domain_aliases.c.

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 ao2_cleanup(obj)
Definition: astobj2.h:1934
static void domain_alias_destroy(void *obj)
void * ast_sorcery_generic_alloc(size_t size, ao2_destructor_fn destructor)
Allocate a generic sorcery capable object.
Definition: sorcery.c:1728
#define ast_string_field_init(x, size)
Initialize a field pool and fields.
Definition: stringfields.h:359

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

Referenced by ast_sip_initialize_sorcery_domain_alias().

◆ 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.

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 ast_log
Definition: astobj2.c:42
#define LOG_ERROR
const char * ast_sorcery_object_get_id(const void *object)
Get the unique identifier of a sorcery object.
Definition: sorcery.c:2312
static force_inline int attribute_pure ast_strlen_zero(const char *s)
Definition: strings.h:65
const ast_string_field domain
Definition: res_pjsip.h:323

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().

◆ domain_alias_destroy()

static void domain_alias_destroy ( void *  obj)
static

Definition at line 29 of file config_domain_aliases.c.

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:374

References ast_string_field_free_memory.

Referenced by domain_alias_alloc().