Asterisk - The Open Source Telephony Project GIT-master-f36a736
Functions | Variables
func_hangupcause.c File Reference

Functions related to retreiving per-channel hangupcause information. More...

#include "asterisk.h"
#include "asterisk/module.h"
#include "asterisk/channel.h"
#include "asterisk/pbx.h"
#include "asterisk/utils.h"
#include "asterisk/app.h"
Include dependency graph for func_hangupcause.c:

Go to the source code of this file.

Functions

static void __reg_module (void)
 
static void __unreg_module (void)
 
struct ast_moduleAST_MODULE_SELF_SYM (void)
 
static int hangupcause_clear_exec (struct ast_channel *chan, const char *data)
 
static int hangupcause_keys_read (struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len)
 
static int hangupcause_read (struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len)
 
static int load_module (void)
 
static int unload_module (void)
 

Variables

static struct ast_module_info __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_LOAD_ORDER , .description = "HANGUPCAUSE related functions and applications" , .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 const char app [] = "HangupCauseClear"
 
static const struct ast_module_infoast_module_info = &__mod_info
 
static struct ast_custom_function hangupcause_function
 
static struct ast_custom_function hangupcause_keys_function
 

Detailed Description

Functions related to retreiving per-channel hangupcause information.

Author
Kinsey Moore kmoor.nosp@m.e@di.nosp@m.gium..nosp@m.com

See Also:

Definition in file func_hangupcause.c.

Function Documentation

◆ __reg_module()

static void __reg_module ( void  )
static

Definition at line 256 of file func_hangupcause.c.

◆ __unreg_module()

static void __unreg_module ( void  )
static

Definition at line 256 of file func_hangupcause.c.

◆ AST_MODULE_SELF_SYM()

struct ast_module * AST_MODULE_SELF_SYM ( void  )

Definition at line 256 of file func_hangupcause.c.

◆ hangupcause_clear_exec()

static int hangupcause_clear_exec ( struct ast_channel chan,
const char *  data 
)
static

Definition at line 202 of file func_hangupcause.c.

202 {
203 ast_channel_lock(chan);
205 ast_channel_unlock(chan);
206 return 0;
207}
#define ast_channel_lock(chan)
Definition: channel.h:2968
void ast_channel_dialed_causes_clear(const struct ast_channel *chan)
Clear all cause information from the channel.
#define ast_channel_unlock(chan)
Definition: channel.h:2969

References ast_channel_dialed_causes_clear(), ast_channel_lock, and ast_channel_unlock.

Referenced by load_module().

◆ hangupcause_keys_read()

static int hangupcause_keys_read ( struct ast_channel chan,
const char *  cmd,
char *  data,
char *  buf,
size_t  len 
)
static

Definition at line 169 of file func_hangupcause.c.

170{
171 struct ast_str *chanlist;
172
173 /* Ensure that the buffer is empty */
174 *buf = 0;
175
176 if (!chan) {
177 return -1;
178 }
179
180 ast_channel_lock(chan);
182 ast_channel_unlock(chan);
183
186 }
187
189 return 0;
190}
#define ast_free(a)
Definition: astmm.h:180
struct ast_str * ast_channel_dialed_causes_channels(const struct ast_channel *chan)
Retrieve a comma-separated list of channels for which dialed cause information is available.
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)
char * ast_str_buffer(const struct ast_str *buf)
Returns the string buffer within the ast_str buf.
Definition: strings.h:761
size_t ast_str_strlen(const struct ast_str *buf)
Returns the current length of the string stored within buf.
Definition: strings.h:730
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
Definition: strings.h:425
Support for dynamic strings.
Definition: strings.h:623
List of channel drivers.
Definition: app_dial.c:797

References ast_channel_dialed_causes_channels(), ast_channel_lock, ast_channel_unlock, ast_copy_string(), ast_free, ast_str_buffer(), ast_str_strlen(), buf, and len().

◆ hangupcause_read()

static int hangupcause_read ( struct ast_channel chan,
const char *  cmd,
char *  data,
char *  buf,
size_t  len 
)
static

< Channel name

< Type of information requested (ast or tech)

Definition at line 108 of file func_hangupcause.c.

109{
110 char *parms;
111 struct ast_control_pvt_cause_code *cause_code;
112 int res = 0;
114 AST_APP_ARG(channel); /*!< Channel name */
115 AST_APP_ARG(type); /*!< Type of information requested (ast or tech) */
116 );
117
118 /* Ensure that the buffer is empty */
119 *buf = 0;
120
121 if (!chan) {
122 return -1;
123 }
124
125 parms = ast_strdupa(data);
127 if (args.argc != 2) {
128 /* Must have two arguments. */
129 ast_log(LOG_WARNING, "The HANGUPCAUSE function must have 2 parameters, not %u\n", args.argc);
130 return -1;
131 }
132
133 ast_channel_lock(chan);
134 cause_code = ast_channel_dialed_causes_find(chan, args.channel);
135 ast_channel_unlock(chan);
136
137 if (!cause_code) {
138 ast_log(LOG_WARNING, "Unable to find information for channel %s\n", args.channel);
139 return -1;
140 }
141
142 if (!strcmp(args.type, "ast")) {
144 } else if (!strcmp(args.type, "tech")) {
145 ast_copy_string(buf, cause_code->code, len);
146 } else {
147 ast_log(LOG_WARNING, "Information type not recognized (%s)\n", args.type);
148 res = -1;
149 }
150
151 ao2_ref(cause_code, -1);
152
153 return res;
154}
#define ast_strdupa(s)
duplicate a string in memory from the stack
Definition: astmm.h:298
#define ast_log
Definition: astobj2.c:42
#define ao2_ref(o, delta)
Reference/unreference an object and return the old refcount.
Definition: astobj2.h:459
static const char type[]
Definition: chan_ooh323.c:109
struct ast_control_pvt_cause_code * ast_channel_dialed_causes_find(const struct ast_channel *chan, const char *chan_name)
Retrieve a ref-counted cause code information structure.
const char * ast_cause2str(int cause) attribute_pure
Gives the string form of a given cause code.
Definition: channel.c:612
#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
const char * args

References ao2_ref, args, AST_APP_ARG, ast_control_pvt_cause_code::ast_cause, ast_cause2str(), ast_channel_dialed_causes_find(), ast_channel_lock, ast_channel_unlock, ast_copy_string(), AST_DECLARE_APP_ARGS, ast_log, AST_STANDARD_APP_ARGS, ast_strdupa, buf, ast_control_pvt_cause_code::code, len(), LOG_WARNING, and type.

◆ load_module()

static int load_module ( void  )
static

Definition at line 245 of file func_hangupcause.c.

246{
247 int res;
248
253}
static const char app[]
static int hangupcause_clear_exec(struct ast_channel *chan, const char *data)
static struct ast_custom_function hangupcause_function
static struct ast_custom_function hangupcause_keys_function
@ 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
#define ast_register_application_xml(app, execute)
Register an application using XML documentation.
Definition: module.h:640
#define ast_custom_function_register(acf)
Register a custom function.
Definition: pbx.h:1558

References app, ast_custom_function_register, AST_MODULE_LOAD_DECLINE, AST_MODULE_LOAD_SUCCESS, ast_register_application_xml, hangupcause_clear_exec(), hangupcause_function, and hangupcause_keys_function.

◆ unload_module()

static int unload_module ( void  )
static

Definition at line 228 of file func_hangupcause.c.

229{
230 int res;
231
235 return res;
236}
int ast_unregister_application(const char *app)
Unregister an application.
Definition: pbx_app.c:392
int ast_custom_function_unregister(struct ast_custom_function *acf)
Unregister a custom function.

References app, ast_custom_function_unregister(), ast_unregister_application(), hangupcause_function, and hangupcause_keys_function.

Variable Documentation

◆ __mod_info

struct ast_module_info __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_LOAD_ORDER , .description = "HANGUPCAUSE related functions and applications" , .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 256 of file func_hangupcause.c.

◆ app

const char app[] = "HangupCauseClear"
static

Definition at line 219 of file func_hangupcause.c.

Referenced by load_module(), and unload_module().

◆ ast_module_info

const struct ast_module_info* ast_module_info = &__mod_info
static

Definition at line 256 of file func_hangupcause.c.

◆ hangupcause_function

struct ast_custom_function hangupcause_function
static
Initial value:
= {
.name = "HANGUPCAUSE",
}
static int hangupcause_read(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len)

Definition at line 209 of file func_hangupcause.c.

Referenced by load_module(), and unload_module().

◆ hangupcause_keys_function

struct ast_custom_function hangupcause_keys_function
static
Initial value:
= {
.name = "HANGUPCAUSE_KEYS",
}
static int hangupcause_keys_read(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len)

Definition at line 214 of file func_hangupcause.c.

Referenced by load_module(), and unload_module().