config_domain_aliases.c

Go to the documentation of this file.
00001 /*
00002  * Asterisk -- An open source telephony toolkit.
00003  *
00004  * Copyright (C) 2013, Digium, Inc.
00005  *
00006  * Joshua Colp <jcolp@digium.com>
00007  *
00008  * See http://www.asterisk.org for more information about
00009  * the Asterisk project. Please do not directly contact
00010  * any of the maintainers of this project for assistance;
00011  * the project provides a web site, mailing lists and IRC
00012  * channels for your use.
00013  *
00014  * This program is free software, distributed under the terms of
00015  * the GNU General Public License Version 2. See the LICENSE file
00016  * at the top of the source tree.
00017  */
00018 
00019 #include "asterisk.h"
00020 
00021 #include "pjsip.h"
00022 #include "pjlib.h"
00023 #include "asterisk/res_pjsip.h"
00024 #include "include/res_pjsip_private.h"
00025 #include "asterisk/logger.h"
00026 #include "asterisk/sorcery.h"
00027 
00028 static void domain_alias_destroy(void *obj)
00029 {
00030    struct ast_sip_domain_alias *alias = obj;
00031 
00032    ast_string_field_free_memory(alias);
00033 }
00034 
00035 static void *domain_alias_alloc(const char *name)
00036 {
00037         struct ast_sip_domain_alias *alias = ast_sorcery_generic_alloc(sizeof(*alias), domain_alias_destroy);
00038 
00039    if (!alias) {
00040       return NULL;
00041    }
00042 
00043    if (ast_string_field_init(alias, 256)) {
00044       ao2_cleanup(alias);
00045       return NULL;
00046    }
00047 
00048    return alias;
00049 }
00050 
00051 /*! \brief Initialize sorcery with domain alias support */
00052 int ast_sip_initialize_sorcery_domain_alias(void)
00053 {
00054    struct ast_sorcery *sorcery = ast_sip_get_sorcery();
00055 
00056    ast_sorcery_apply_default(sorcery, SIP_SORCERY_DOMAIN_ALIAS_TYPE, "config", "pjsip.conf,criteria=type=domain_alias");
00057 
00058    if (ast_sorcery_object_register(sorcery, SIP_SORCERY_DOMAIN_ALIAS_TYPE, domain_alias_alloc, NULL, NULL)) {
00059       return -1;
00060    }
00061 
00062    ast_sorcery_object_field_register(sorcery, SIP_SORCERY_DOMAIN_ALIAS_TYPE, "type", "",
00063          OPT_NOOP_T, 0, 0);
00064    ast_sorcery_object_field_register(sorcery, SIP_SORCERY_DOMAIN_ALIAS_TYPE, "domain",
00065          "", OPT_STRINGFIELD_T, 0, STRFLDSET(struct ast_sip_domain_alias, domain));
00066 
00067    return 0;
00068 }

Generated on Thu Apr 16 06:27:31 2015 for Asterisk - The Open Source Telephony Project by  doxygen 1.5.6