app_forkcdr.c File Reference

Fork CDR application. More...

#include "asterisk.h"
#include "asterisk/file.h"
#include "asterisk/channel.h"
#include "asterisk/pbx.h"
#include "asterisk/cdr.h"
#include "asterisk/app.h"
#include "asterisk/module.h"
#include "asterisk/stasis.h"
#include "asterisk/stasis_message_router.h"

Include dependency graph for app_forkcdr.c:

Go to the source code of this file.

Data Structures

struct  fork_cdr_message_payload

Functions

static void __reg_module (void)
static void __unreg_module (void)
static void forkcdr_callback (void *data, struct stasis_subscription *sub, struct stasis_message *message)
static int forkcdr_exec (struct ast_channel *chan, const char *data)
static int load_module (void)
 STASIS_MESSAGE_TYPE_DEFN_LOCAL (forkcdr_message_type)
static int unload_module (void)

Variables

static struct ast_module_info __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_LOAD_ORDER , .description = "Fork The CDR into 2 separate entities" , .key = "This paragraph is copyright (c) 2006 by Digium, Inc. \In order for your module to load, it must return this \key via a function called \"key\". Any code which \includes this paragraph must be licensed under the GNU \General Public License version 2 or later (at your \option). In addition to Digium's general reservations \of rights, Digium expressly reserves the right to \allow other parties to license this paragraph under \different terms. Any use of Digium, Inc. trademarks or \logos (including \"Asterisk\" or \"Digium\") without \express written permission of Digium, Inc. is prohibited.\n" , .buildopt_sum = AST_BUILDOPT_SUM, .load = load_module, .unload = unload_module, .load_pri = AST_MODPRI_DEFAULT, .support_level = AST_MODULE_SUPPORT_CORE, }
static char * app = "ForkCDR"
static struct ast_module_infoast_module_info = &__mod_info
static struct ast_app_option forkcdr_exec_options [128] = { [ 'a' ] = { .flag = AST_CDR_FLAG_SET_ANSWER }, [ 'e' ] = { .flag = AST_CDR_FLAG_FINALIZE }, [ 'r' ] = { .flag = AST_CDR_FLAG_RESET }, [ 'v' ] = { .flag = AST_CDR_FLAG_KEEP_VARS },}


Detailed Description

Fork CDR application.

Author:
Anthony Minessale anthmct@yahoo.com
Note:
Development of this app Sponsored/Funded by TAAN Softworks Corp

Definition in file app_forkcdr.c.


Function Documentation

static void __reg_module ( void   )  [static]

Definition at line 218 of file app_forkcdr.c.

static void __unreg_module ( void   )  [static]

Definition at line 218 of file app_forkcdr.c.

static void forkcdr_callback ( void *  data,
struct stasis_subscription sub,
struct stasis_message message 
) [static]

Definition at line 117 of file app_forkcdr.c.

References ast_cdr_fork(), ast_log, AST_LOG_WARNING, fork_cdr_message_payload::channel_name, fork_cdr_message_payload::flags, stasis_message_data(), and stasis_message_type().

Referenced by load_module().

00118 {
00119    struct fork_cdr_message_payload *payload;
00120 
00121    if (stasis_message_type(message) != forkcdr_message_type()) {
00122       return;
00123    }
00124 
00125    payload = stasis_message_data(message);
00126    if (!payload) {
00127       return;
00128    }
00129 
00130    if (ast_cdr_fork(payload->channel_name, payload->flags)) {
00131       ast_log(AST_LOG_WARNING, "Failed to fork CDR for channel %s\n",
00132          payload->channel_name);
00133    }
00134 }

static int forkcdr_exec ( struct ast_channel chan,
const char *  data 
) [static]

Definition at line 136 of file app_forkcdr.c.

References ao2_alloc, ao2_cleanup, args, AST_APP_ARG, ast_app_parse_options(), ast_cdr_message_router(), ast_channel_name(), AST_DECLARE_APP_ARGS, ast_log, AST_LOG_WARNING, AST_STANDARD_APP_ARGS, ast_strdupa, ast_strlen_zero, forkcdr_exec_options, NULL, parse(), RAII_VAR, router, stasis_message_create(), and stasis_message_router_publish_sync().

Referenced by load_module().

00137 {
00138    RAII_VAR(struct stasis_message *, message, NULL, ao2_cleanup);
00139    RAII_VAR(struct fork_cdr_message_payload *, payload, NULL, ao2_cleanup);
00140    RAII_VAR(struct stasis_message_router *, router, ast_cdr_message_router(), ao2_cleanup);
00141 
00142    char *parse;
00143    struct ast_flags flags = { 0, };
00144    AST_DECLARE_APP_ARGS(args,
00145       AST_APP_ARG(options);
00146    );
00147 
00148    parse = ast_strdupa(data);
00149 
00150    AST_STANDARD_APP_ARGS(args, parse);
00151 
00152    if (!ast_strlen_zero(args.options)) {
00153       ast_app_parse_options(forkcdr_exec_options, &flags, NULL, args.options);
00154    }
00155 
00156    if (!forkcdr_message_type()) {
00157       ast_log(AST_LOG_WARNING, "Failed to manipulate CDR for channel %s: no message type\n",
00158          ast_channel_name(chan));
00159       return -1;
00160    }
00161 
00162    payload = ao2_alloc(sizeof(*payload), NULL);
00163    if (!payload) {
00164       return -1;
00165    }
00166 
00167    if (!router) {
00168       ast_log(AST_LOG_WARNING, "Failed to manipulate CDR for channel %s: no message router\n",
00169          ast_channel_name(chan));
00170       return -1;
00171    }
00172 
00173    payload->channel_name = ast_channel_name(chan);
00174    payload->flags = &flags;
00175    message = stasis_message_create(forkcdr_message_type(), payload);
00176    if (!message) {
00177       ast_log(AST_LOG_WARNING, "Failed to fork CDR for channel %s: unable to create message\n",
00178          ast_channel_name(chan));
00179       return -1;
00180    }
00181    stasis_message_router_publish_sync(router, message);
00182 
00183    return 0;
00184 }

static int load_module ( void   )  [static]

Definition at line 198 of file app_forkcdr.c.

References ao2_cleanup, ast_cdr_message_router(), AST_MODULE_LOAD_FAILURE, AST_MODULE_LOAD_SUCCESS, ast_register_application_xml, forkcdr_callback(), forkcdr_exec(), NULL, RAII_VAR, router, stasis_message_router_add(), and STASIS_MESSAGE_TYPE_INIT.

00199 {
00200    RAII_VAR(struct stasis_message_router *, router, ast_cdr_message_router(), ao2_cleanup);
00201    int res = 0;
00202 
00203    if (!router) {
00204       return AST_MODULE_LOAD_FAILURE;
00205    }
00206 
00207    res |= STASIS_MESSAGE_TYPE_INIT(forkcdr_message_type);
00208    res |= ast_register_application_xml(app, forkcdr_exec);
00209    res |= stasis_message_router_add(router, forkcdr_message_type(),
00210                                     forkcdr_callback, NULL);
00211 
00212    if (res) {
00213       return AST_MODULE_LOAD_FAILURE;
00214    }
00215    return AST_MODULE_LOAD_SUCCESS;
00216 }

STASIS_MESSAGE_TYPE_DEFN_LOCAL ( forkcdr_message_type   ) 

static int unload_module ( void   )  [static]

Definition at line 186 of file app_forkcdr.c.

References ao2_cleanup, ast_cdr_message_router(), ast_unregister_application(), RAII_VAR, router, stasis_message_router_remove(), and STASIS_MESSAGE_TYPE_CLEANUP.

00187 {
00188    RAII_VAR(struct stasis_message_router *, router, ast_cdr_message_router(), ao2_cleanup);
00189 
00190    if (router) {
00191       stasis_message_router_remove(router, forkcdr_message_type());
00192    }
00193    STASIS_MESSAGE_TYPE_CLEANUP(forkcdr_message_type);
00194    ast_unregister_application(app);
00195    return 0;
00196 }


Variable Documentation

struct ast_module_info __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_LOAD_ORDER , .description = "Fork The CDR into 2 separate entities" , .key = "This paragraph is copyright (c) 2006 by Digium, Inc. \In order for your module to load, it must return this \key via a function called \"key\". Any code which \includes this paragraph must be licensed under the GNU \General Public License version 2 or later (at your \option). In addition to Digium's general reservations \of rights, Digium expressly reserves the right to \allow other parties to license this paragraph under \different terms. Any use of Digium, Inc. trademarks or \logos (including \"Asterisk\" or \"Digium\") without \express written permission of Digium, Inc. is prohibited.\n" , .buildopt_sum = AST_BUILDOPT_SUM, .load = load_module, .unload = unload_module, .load_pri = AST_MODPRI_DEFAULT, .support_level = AST_MODULE_SUPPORT_CORE, } [static]

Definition at line 218 of file app_forkcdr.c.

char* app = "ForkCDR" [static]

Definition at line 98 of file app_forkcdr.c.

Definition at line 218 of file app_forkcdr.c.

struct ast_app_option forkcdr_exec_options[128] = { [ 'a' ] = { .flag = AST_CDR_FLAG_SET_ANSWER }, [ 'e' ] = { .flag = AST_CDR_FLAG_FINALIZE }, [ 'r' ] = { .flag = AST_CDR_FLAG_RESET }, [ 'v' ] = { .flag = AST_CDR_FLAG_KEEP_VARS },} [static]

Definition at line 105 of file app_forkcdr.c.

Referenced by forkcdr_exec().


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