Asterisk - The Open Source Telephony Project GIT-master-20e40a9
Loading...
Searching...
No Matches
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 = ASTERISK_GPL_KEY , .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 265 of file func_hangupcause.c.

◆ __unreg_module()

static void __unreg_module ( void  )
static

Definition at line 265 of file func_hangupcause.c.

◆ AST_MODULE_SELF_SYM()

struct ast_module * AST_MODULE_SELF_SYM ( void  )

Definition at line 265 of file func_hangupcause.c.

◆ hangupcause_clear_exec()

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

Definition at line 211 of file func_hangupcause.c.

211 {
212 ast_channel_lock(chan);
214 ast_channel_unlock(chan);
215 return 0;
216}
#define ast_channel_lock(chan)
Definition channel.h:2982
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:2983

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 178 of file func_hangupcause.c.

179{
180 struct ast_str *chanlist;
181
182 /* Ensure that the buffer is empty */
183 *buf = 0;
184
185 if (!chan) {
186 return -1;
187 }
188
189 ast_channel_lock(chan);
191 ast_channel_unlock(chan);
192
195 }
196
198 return 0;
199}
#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)
size_t attribute_pure ast_str_strlen(const struct ast_str *buf)
Returns the current length of the string stored within buf.
Definition strings.h:730
char *attribute_pure ast_str_buffer(const struct ast_str *buf)
Returns the string buffer within the ast_str buf.
Definition strings.h:761
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:804

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 117 of file func_hangupcause.c.

118{
119 char *parms;
120 struct ast_control_pvt_cause_code *cause_code;
121 int res = 0;
123 AST_APP_ARG(channel); /*!< Channel name */
124 AST_APP_ARG(type); /*!< Type of information requested (ast or tech) */
125 );
126
127 /* Ensure that the buffer is empty */
128 *buf = 0;
129
130 if (!chan) {
131 return -1;
132 }
133
134 parms = ast_strdupa(data);
136 if (args.argc != 2) {
137 /* Must have two arguments. */
138 ast_log(LOG_WARNING, "The HANGUPCAUSE function must have 2 parameters, not %u\n", args.argc);
139 return -1;
140 }
141
142 ast_channel_lock(chan);
143 cause_code = ast_channel_dialed_causes_find(chan, args.channel);
144 ast_channel_unlock(chan);
145
146 if (!cause_code) {
147 ast_log(LOG_WARNING, "Unable to find information for channel %s\n", args.channel);
148 return -1;
149 }
150
151 if (!strcmp(args.type, "ast")) {
153 } else if (!strcmp(args.type, "tech")) {
154 ast_copy_string(buf, cause_code->code, len);
155 } else {
156 ast_log(LOG_WARNING, "Information type not recognized (%s)\n", args.type);
157 res = -1;
158 }
159
160 ao2_ref(cause_code, -1);
161
162 return res;
163}
#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[]
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
static struct @519 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 254 of file func_hangupcause.c.

255{
256 int res;
257
262}
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:1562

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 237 of file func_hangupcause.c.

238{
239 int res;
240
244 return res;
245}
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 = ASTERISK_GPL_KEY , .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 265 of file func_hangupcause.c.

◆ app

const char app[] = "HangupCauseClear"
static

Definition at line 228 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 265 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 218 of file func_hangupcause.c.

218 {
219 .name = "HANGUPCAUSE",
220 .read = hangupcause_read,
221};

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 223 of file func_hangupcause.c.

223 {
224 .name = "HANGUPCAUSE_KEYS",
225 .read = hangupcause_keys_read,
226};

Referenced by load_module(), and unload_module().