53 #define DEFAULT_ADSI_MAX_RETRIES 3 55 #define ADSI_MAX_INTRO 20 56 #define ADSI_MAX_SPEED_DIAL 6 58 #define ADSI_FLAG_DATAMODE (1 << 8) 63 #define ADSI_SPEED_DIAL 10 68 #define SPEEDDIAL_MAX_LEN 20 95 static int adsi_display(
unsigned char *
buf,
int page,
int line,
int just,
int wrap,
char *col1,
char *col2);
97 static int adsi_load_soft_key(
unsigned char *
buf,
int key,
const char *llabel,
const char *slabel,
char *ret,
int data);
100 static int adsi_input_format(
unsigned char *
buf,
int num,
int dir,
int wrap,
char *format1,
char *format2);
104 int sum, x, bytes = 0;
106 float cr = 1.0, ci = 0.0, scont = 0.0;
114 for (x = 0; x < 150; x++) {
132 for (x = 0; x < msglen; x++) {
143 for (x = 0; x < 50; x++) {
164 if (remain && *remain) {
171 *remain = *remain - amt;
232 unsigned char buf[24000 * 5];
233 int pos = 0, res, x, start = 0, retries = 0, waittime, rem = 0, def;
258 ast_debug(1,
"No ADSI CPE detected (%d)\n", res);
279 ast_debug(1,
"Off-hook capable CPE only, not ADSI\n");
294 ast_debug(1,
"ADSI Compatible CPE Detected\n");
304 while ((x < 6) && msg[x]) {
309 ast_debug(1,
"Message %d, of %d input bytes, %d output bytes\n", x + 1, msglen[x], res);
324 ast_debug(1,
"Sent total spill of %d bytes\n", pos);
326 memset(ack, 0,
sizeof(ack));
332 ast_debug(1,
"Acked up to message %d\n", atoi(ack + 1)); start += atoi(ack + 1);
337 ast_debug(1,
"Retransmitting (%d), from %d\n", retries, start + 1);
355 unsigned char buf[256];
370 ast_debug(1,
"Download was denied by CPE\n");
377 unsigned char buf[256];
395 for (x = 0; x < msglen; x += (msg[x+1]+2)) {
397 ast_debug(1,
"Switch to data is sent!\n");
403 ast_debug(1,
"Switch to voice is sent!\n");
411 msgtypes[0] = msgtype;
440 ast_debug(1,
"Wait for switch is '%d'\n", waitforswitch);
469 static inline int ccopy(
unsigned char *dst,
const unsigned char *
src,
int max)
473 while ((x < max) && src[x] && (src[x] != 0xff)) {
485 if ((key < 2) || (key > 33)) {
496 bytes +=
ccopy(buf + bytes, (
const unsigned char *)llabel, 18);
502 bytes +=
ccopy(buf + bytes, (
const unsigned char *)slabel, 7);
513 bytes +=
ccopy(buf + bytes, (
const unsigned char *)ret, 20);
532 for (x = 0; x < 4; x++) {
533 buf[bytes++] = fdn[x];
536 buf[bytes++] = ver & 0xff;
556 bytes+=
ccopy(buf + bytes, (
unsigned char *)service, 18);
561 for (x = 0; x < 4; x++) {
562 buf[bytes++] = fdn[x];
565 for (x = 0; x < 4; x++) {
566 buf[bytes++] = sec[x];
569 buf[bytes++] = ver & 0xff;
614 int bytes = 0, res, gotstar = 0, pos = 0;
615 unsigned char current = 0;
617 memset(buf, 0, maxlen);
619 while (bytes <= maxlen) {
629 if ((res <
'0') || (res >
'9')) {
638 buf[bytes++] = (res << 4) | current;
651 unsigned char buf[256] =
"";
682 unsigned char buf[256] =
"";
693 if ((res =
ast_readstring(chan, (
char *) buf, 2, 1000, 500,
"")) < 0) {
696 if (strlen((
char *) buf) != 2) {
703 *width = atoi((
char *) buf);
706 memset(buf, 0,
sizeof(buf));
708 if ((res =
ast_readstring(chan, (
char *) buf, 2, 1000, 500,
"")) < 0) {
711 if (strlen((
char *) buf) != 2) {
718 *height = atoi((
char *) buf);
722 memset(buf, 0,
sizeof(buf));
724 if ((res =
ast_readstring(chan, (
char *) buf, 1, 1000, 500,
"")) < 0) {
727 if (strlen((
char *) buf) != 1) {
734 *buttons = atoi((
char *) buf);
802 buf[bytes++] = when & 0x7f;
835 char *col1,
char *col2)
842 if (line > 4)
return -1;
844 if (line > 33)
return -1;
857 buf[bytes++] = ((page & 0x1) << 7) | ((wrap & 0x1) << 6) | (line & 0x3f);
860 buf[bytes++] = (just & 0x3) << 5;
866 bytes+=
ccopy(buf + bytes, (
unsigned char *)col1, 20);
872 bytes +=
ccopy(buf + bytes, (
unsigned char *)col2, 20);
886 if (line > 4)
return -1;
888 if (line > 33)
return -1;
897 buf[bytes++] = ((page & 1) << 7) | (line & 0x3f);
898 buf[bytes++] = ((display & 1) << 7) | ((just & 0x3) << 4) | (format & 0x7);
914 buf[bytes++] = ((dir & 1) << 7) | ((wrap & 1) << 6) | (num & 0x7);
915 bytes +=
ccopy(buf + bytes, (
unsigned char *) format1, 20);
918 bytes +=
ccopy(buf + bytes, (
unsigned char *) format2, 20);
933 for (x = 0; x < 6; x++) {
934 buf[bytes++] = (keys[x] & 0x3f) ? keys[x] : (keys[x] | 0x1);
947 if (line > 4)
return -1;
949 if (line > 33)
return -1;
962 buf[bytes++] = ((page & 0x1) << 7) | (line & 0x3f);
973 unsigned char dsp[256] =
"", keyd[6] =
"";
983 for (x = 0; x <
speeds; x++) {
995 unsigned char buf[4096];
996 int bytes = 0, res, x;
998 for (x = 0; lines[x]; x++) {
1015 unsigned char dsp[256] =
"";
1035 ast_debug(1,
"No response from CPE about version. Assuming not there.\n");
1038 if (!strcmp(resp,
"B")) {
1039 ast_debug(1,
"CPE has script '%s' version %d already loaded\n", app, ver);
1041 }
else if (!strcmp(resp,
"A")) {
1042 ast_debug(1,
"CPE hasn't script '%s' version %d already loaded\n", app, ver);
1054 unsigned char dsp[256] =
"";
1071 if (!strncasecmp(s,
"l", 1)) {
1073 }
else if (!strncasecmp(s,
"r", 1)) {
1075 }
else if (!strncasecmp(s,
"i", 1)) {
1115 if (!strcasecmp(v->
name,
"alignment")) {
1117 }
else if (!strcasecmp(v->
name,
"greeting")) {
1123 }
else if (!strcasecmp(v->
name,
"maxretries")) {
1124 if (atoi(v->
value) > 0) {
1136 char *stringp =
buf;
1138 name =
strsep(&stringp,
",");
1139 sname =
strsep(&stringp,
",");
static int adsi_query_cpeinfo(unsigned char *buf)
A-Law to Signed linear conversion.
struct ast_variable * next
int ast_safe_sleep(struct ast_channel *chan, int ms)
Wait for a specified amount of time, looking for hangups.
Main Channel structure associated with a channel.
static int adsi_disconnect_session(unsigned char *buf)
Asterisk main include file. File version handling, generic pbx functions.
static int adsi_get_cpeid(struct ast_channel *chan, unsigned char *cpeid, int voice)
static int load_module(void)
static int adsi_input_format(unsigned char *buf, int num, int dir, int wrap, char *format1, char *format2)
CallerID (and other GR30) management and generation Includes code and algorithms from the Zapata libr...
struct ast_variable * ast_variable_browse(const struct ast_config *config, const char *category_name)
static int __adsi_transmit_messages(struct ast_channel *chan, unsigned char **msg, int *msglen, int *msgtype)
static int adsi_get_cpeinfo(struct ast_channel *chan, int *width, int *height, int *buttons, int voice)
Time-related functions and macros.
#define ADSI_LOAD_SOFTKEY
#define ADSI_DISC_SESSION
#define ADSI_DOWNLOAD_DISC
static int adsi_clear_soft_keys(unsigned char *buf)
static char intro[ADSI_MAX_INTRO][20]
static int adsi_set_keys(unsigned char *buf, unsigned char *keys)
static int adsi_clear_screen(unsigned char *buf)
#define CONFIG_STATUS_FILEINVALID
Structure for variables, used for configurations and for channel variables.
static int adsi_begin_download(struct ast_channel *chan, char *service, unsigned char *fdn, unsigned char *sec, int version)
struct ast_frame * ast_read(struct ast_channel *chan)
Reads a frame.
static int adsi_print(struct ast_channel *chan, char **lines, int *align, int voice)
enum ast_cc_service_type service
static void adsi_load(int reload)
static int adsi_end_download(struct ast_channel *chan)
static int ccopy(unsigned char *dst, const unsigned char *src, int max)
Generic File Format Support. Should be included by clients of the file handling routines. File service providers should instead include mod_format.h.
#define ADSI_QUERY_CONFIG
ADSI Support (built upon Caller*ID)
#define ADSI_FLAG_DATAMODE
static int adsi_unload_session(struct ast_channel *chan)
#define DEFAULT_ADSI_MAX_RETRIES
struct ast_frame_subclass subclass
static int aligns[ADSI_MAX_INTRO]
#define ast_strlen_zero(foo)
struct ast_format * ast_channel_readformat(struct ast_channel *chan)
All configuration options for statsd client.
int ast_channel_defer_dtmf(struct ast_channel *chan)
Defers DTMF so that you only read things like hangups and audio.
Configuration File Parser.
#define ast_debug(level,...)
Log a DEBUG message.
u-Law to Signed linear conversion
#define ast_config_load(filename, flags)
Load a config file.
static int adsi_transmit_message_full(struct ast_channel *chan, unsigned char *msg, int msglen, int msgtype, int dowait)
General Asterisk PBX channel definitions.
static int adsi_available(struct ast_channel *chan)
void ast_channel_undefer_dtmf(struct ast_channel *chan)
Unset defer DTMF flag on channel.
static int adsi_read_encoded_dtmf(struct ast_channel *chan, unsigned char *buf, int maxlen)
int ast_set_read_format(struct ast_channel *chan, struct ast_format *format)
Sets read format on channel chan.
#define RAII_VAR(vartype, varname, initval, dtor)
Declare a variable that will call a destructor function when it goes out of scope.
struct sla_ringing_trunk * last
static int adsi_load_session(struct ast_channel *chan, unsigned char *app, int ver, int data)
void ast_config_destroy(struct ast_config *config)
Destroys a config.
#define ADSI_LINE_CONTROL
#define ADSI_INPUT_FORMAT
int ast_set_write_format(struct ast_channel *chan, struct ast_format *format)
Sets write format on channel chan.
void ast_channel_adsicpe_set(struct ast_channel *chan, enum ast_channel_adsicpe value)
static int str2align(const char *s)
#define CONFIG_STATUS_FILEUNCHANGED
#define ADSI_DOWNLOAD_CONNECT
#define ADSI_LOAD_VIRTUAL_DISP
static int adsi_transmit_message(struct ast_channel *chan, unsigned char *msg, int msglen, int msgtype)
static struct adsi_funcs res_adsi_funcs
#define ADSI_MAX_SPEED_DIAL
static int adsi_display(unsigned char *buf, int page, int line, int just, int wrap, char *col1, char *col2)
static int adsi_connect_session(unsigned char *buf, unsigned char *fdn, int ver)
static int len(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)
static int adsi_channel_restore(struct ast_channel *chan)
#define ADSI_CLEAR_SOFTKEY
#define ADSI_SWITCH_TO_DATA2
static int adsi_data_mode(unsigned char *buf)
static int unload_module(void)
static char version[AST_MAX_EXTENSION]
static int adsi_voice_mode(unsigned char *buf, int when)
static int adsi_load_soft_key(unsigned char *buf, int key, const char *llabel, const char *slabel, char *ret, int data)
#define ADSI_SWITCH_TO_VOICE
int ast_write(struct ast_channel *chan, struct ast_frame *frame)
Write a frame to a channel This function writes the given frame to the indicated channel.
#define ADSI_MSG_DOWNLOAD
Structure used to handle boolean flags.
void ast_adsi_install_funcs(const struct adsi_funcs *funcs)
AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_GLOBAL_SYMBOLS|AST_MODFLAG_LOAD_ORDER, "HTTP Phone Provisioning",.support_level=AST_MODULE_SUPPORT_EXTENDED,.load=load_module,.unload=unload_module,.reload=reload,.load_pri=AST_MODPRI_CHANNEL_DEPEND,.requires="http",)
static char speeddial[ADSI_MAX_SPEED_DIAL][3][SPEEDDIAL_MAX_LEN]
#define CONFIG_STATUS_FILEMISSING
static int adsi_input_control(unsigned char *buf, int page, int line, int display, int format, int just)
int ast_waitfordigit(struct ast_channel *c, int ms)
Waits for a digit.
static int adsi_download_disconnect(unsigned char *buf)
char * strsep(char **str, const char *delims)
static int adsi_careful_send(struct ast_channel *chan, unsigned char *buf, int len, int *remain)
int ast_waitfor(struct ast_channel *chan, int ms)
Wait for input on a channel.
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
const char * ast_channel_name(const struct ast_channel *chan)
#define ADSI_CLEAR_SCREEN
Data structure associated with a single frame of data.
union ast_frame::@263 data
enum ast_frame_type frametype
#define ADSI_SWITCH_TO_DATA
int ast_readstring(struct ast_channel *c, char *s, int len, int timeout, int rtimeout, char *enders)
Reads multiple digits.
static int adsi_query_cpeid(unsigned char *buf)
struct ast_format * format
static int adsi_set_line(unsigned char *buf, int page, int line)
#define ASTERISK_GPL_KEY
The text the key() function should return.
Asterisk module definitions.
struct ast_format * ast_channel_writeformat(struct ast_channel *chan)
static snd_pcm_format_t format
static int adsi_download_connect(unsigned char *buf, char *service, unsigned char *fdn, unsigned char *sec, int ver)
#define SPEEDDIAL_MAX_LEN
static void init_state(void)
#define ADSI_INIT_SOFTKEY_LINE
int ast_stopstream(struct ast_channel *c)
Stops a stream.
#define ADSI_INPUT_CONTROL
static int adsi_generate(unsigned char *buf, int msgtype, unsigned char *msg, int msglen, int msgnum, int last, struct ast_format *codec)
int ast_gen_cas(unsigned char *outbuf, int sas, int len, struct ast_format *codec)
Generate a CAS (CPE Alert Signal) tone for 'n' samples.
#define ADSI_CONNECT_SESSION