#include "asterisk.h"
#include <regex.h>
#include "asterisk/module.h"
#include "asterisk/channel.h"
#include "asterisk/pbx.h"
#include "asterisk/utils.h"
#include "asterisk/app.h"
#include "asterisk/indications.h"
#include "asterisk/stringfields.h"
Include dependency graph for func_channel.c:

Go to the source code of this file.
Defines | |
| #define | locked_copy_string(chan, dest, source, len) |
| #define | locked_string_field_set(chan, field, source) |
Functions | |
| AST_MODULE_INFO_STANDARD (ASTERISK_GPL_KEY,"Channel information dialplan function") | |
| static int | func_channel_read (struct ast_channel *chan, char *function, char *data, char *buf, size_t len) |
| static int | func_channel_write (struct ast_channel *chan, char *function, char *data, const char *value) |
| static int | load_module (void) |
| static int | unload_module (void) |
Variables | |
| static struct ast_custom_function | channel_function |
| char * | transfercapability_table [0x20] |
Definition in file func_channel.c.
| #define locked_copy_string | ( | chan, | |||
| dest, | |||||
| source, | |||||
| len | ) |
Value:
do { \ ast_channel_lock(chan); \ ast_copy_string(dest, source, len); \ ast_channel_unlock(chan); \ } while (0)
Definition at line 39 of file func_channel.c.
Referenced by func_channel_read().
| #define locked_string_field_set | ( | chan, | |||
| field, | |||||
| source | ) |
Value:
do { \ ast_channel_lock(chan); \ ast_string_field_set(chan, field, source); \ ast_channel_unlock(chan); \ } while (0)
Definition at line 45 of file func_channel.c.
Referenced by func_channel_write().
| AST_MODULE_INFO_STANDARD | ( | ASTERISK_GPL_KEY | , | |
| "Channel information dialplan function" | ||||
| ) |
| static int func_channel_read | ( | struct ast_channel * | chan, | |
| char * | function, | |||
| char * | data, | |||
| char * | buf, | |||
| size_t | len | |||
| ) | [static] |
Definition at line 58 of file func_channel.c.
References ast_channel::_state, AST_FORMAT_AUDIO_MASK, AST_FORMAT_VIDEO_MASK, ast_getformatname(), ast_log(), ast_print_group(), ast_state2str(), ast_channel::callgroup, ind_tone_zone::country, ast_channel_tech::func_channel_read, locked_copy_string, LOG_WARNING, ast_channel::nativeformats, ast_channel::readformat, ast_channel::tech, ast_channel::transfercapability, ast_channel_tech::type, ast_channel::writeformat, and ast_channel::zone.
00060 { 00061 int ret = 0; 00062 00063 if (!strcasecmp(data, "audionativeformat")) 00064 /* use the _multiple version when chan->nativeformats holds multiple formats */ 00065 /* ast_getformatname_multiple(buf, len, chan->nativeformats & AST_FORMAT_AUDIO_MASK); */ 00066 ast_copy_string(buf, ast_getformatname(chan->nativeformats & AST_FORMAT_AUDIO_MASK), len); 00067 else if (!strcasecmp(data, "videonativeformat")) 00068 /* use the _multiple version when chan->nativeformats holds multiple formats */ 00069 /* ast_getformatname_multiple(buf, len, chan->nativeformats & AST_FORMAT_VIDEO_MASK); */ 00070 ast_copy_string(buf, ast_getformatname(chan->nativeformats & AST_FORMAT_VIDEO_MASK), len); 00071 else if (!strcasecmp(data, "audioreadformat")) 00072 ast_copy_string(buf, ast_getformatname(chan->readformat), len); 00073 else if (!strcasecmp(data, "audiowriteformat")) 00074 ast_copy_string(buf, ast_getformatname(chan->writeformat), len); 00075 else if (!strcasecmp(data, "tonezone") && chan->zone) 00076 locked_copy_string(chan, buf, chan->zone->country, len); 00077 else if (!strcasecmp(data, "language")) 00078 locked_copy_string(chan, buf, chan->language, len); 00079 else if (!strcasecmp(data, "musicclass")) 00080 locked_copy_string(chan, buf, chan->musicclass, len); 00081 else if (!strcasecmp(data, "state")) 00082 locked_copy_string(chan, buf, ast_state2str(chan->_state), len); 00083 else if (!strcasecmp(data, "channeltype")) 00084 locked_copy_string(chan, buf, chan->tech->type, len); 00085 else if (!strcasecmp(data, "transfercapability")) 00086 locked_copy_string(chan, buf, transfercapability_table[chan->transfercapability & 0x1f], len); 00087 else if (!strcasecmp(data, "callgroup")) { 00088 char groupbuf[256]; 00089 locked_copy_string(chan, buf, ast_print_group(groupbuf, sizeof(groupbuf), chan->callgroup), len); 00090 } else if (!chan->tech->func_channel_read 00091 || chan->tech->func_channel_read(chan, function, data, buf, len)) { 00092 ast_log(LOG_WARNING, "Unknown or unavailable item requested: '%s'\n", data); 00093 ret = -1; 00094 } 00095 00096 return ret; 00097 }
| static int func_channel_write | ( | struct ast_channel * | chan, | |
| char * | function, | |||
| char * | data, | |||
| const char * | value | |||
| ) | [static] |
Definition at line 99 of file func_channel.c.
References ast_channel_setoption(), ast_get_group(), ast_get_indication_zone(), ast_log(), AST_OPTION_RXGAIN, AST_OPTION_TXGAIN, ast_channel::callgroup, ast_channel_tech::func_channel_write, language, locked_string_field_set, LOG_ERROR, LOG_WARNING, musicclass, ast_channel::tech, ast_channel::transfercapability, and ast_channel::zone.
00101 { 00102 int ret = 0; 00103 signed char gainset; 00104 00105 if (!strcasecmp(data, "language")) 00106 locked_string_field_set(chan, language, value); 00107 else if (!strcasecmp(data, "musicclass")) 00108 locked_string_field_set(chan, musicclass, value); 00109 else if (!strcasecmp(data, "tonezone")) { 00110 struct ind_tone_zone *new_zone; 00111 if (!(new_zone = ast_get_indication_zone(value))) { 00112 ast_log(LOG_ERROR, "Unknown country code '%s' for tonezone. Check indications.conf for available country codes.\n", value); 00113 ret = -1; 00114 } else 00115 chan->zone = new_zone; 00116 } else if (!strcasecmp(data, "callgroup")) 00117 chan->callgroup = ast_get_group(value); 00118 else if (!strcasecmp(data, "txgain")) { 00119 sscanf(value, "%hhd", &gainset); 00120 ast_channel_setoption(chan, AST_OPTION_TXGAIN, &gainset, sizeof(gainset), 0); 00121 } else if (!strcasecmp(data, "rxgain")) { 00122 sscanf(value, "%hhd", &gainset); 00123 ast_channel_setoption(chan, AST_OPTION_RXGAIN, &gainset, sizeof(gainset), 0); 00124 } else if (!strcasecmp(data, "transfercapability")) { 00125 unsigned short i; 00126 for (i = 0; i < 0x20; i++) { 00127 if (!strcasecmp(transfercapability_table[i], value) && strcmp(value, "UNK")) { 00128 chan->transfercapability = i; 00129 break; 00130 } 00131 } 00132 } else if (!chan->tech->func_channel_write 00133 || chan->tech->func_channel_write(chan, function, data, value)) { 00134 ast_log(LOG_WARNING, "Unknown or unavailable item requested: '%s'\n", 00135 data); 00136 ret = -1; 00137 } 00138 00139 return ret; 00140 }
| static int load_module | ( | void | ) | [static] |
Definition at line 193 of file func_channel.c.
References ast_custom_function_register(), and channel_function.
00194 { 00195 return ast_custom_function_register(&channel_function); 00196 }
| static int unload_module | ( | void | ) | [static] |
Definition at line 188 of file func_channel.c.
References ast_custom_function_unregister(), and channel_function.
00189 { 00190 return ast_custom_function_unregister(&channel_function); 00191 }
struct ast_custom_function channel_function [static] |
| char* transfercapability_table[0x20] |
Initial value:
{
"SPEECH", "UNK", "UNK", "UNK", "UNK", "UNK", "UNK", "UNK",
"DIGITAL", "RESTRICTED_DIGITAL", "UNK", "UNK", "UNK", "UNK", "UNK", "UNK",
"3K1AUDIO", "DIGITAL_W_TONES", "UNK", "UNK", "UNK", "UNK", "UNK", "UNK",
"VIDEO", "UNK", "UNK", "UNK", "UNK", "UNK", "UNK", "UNK", }
Definition at line 52 of file func_channel.c.
1.5.1