54 #define DEFAULT_ADSI_MAX_RETRIES 3
56 #define ADSI_MAX_INTRO 20
57 #define ADSI_MAX_SPEED_DIAL 6
59 #define ADSI_FLAG_DATAMODE (1 << 8)
64 #define ADSI_SPEED_DIAL 10
69 #define SPEEDDIAL_MAX_LEN 20
96 static int adsi_display(
unsigned char *buf,
int page,
int line,
int just,
int wrap,
char *col1,
char *col2);
97 static int adsi_set_line(
unsigned char *buf,
int page,
int line);
98 static int adsi_load_soft_key(
unsigned char *buf,
int key,
const char *llabel,
const char *slabel,
char *ret,
int data);
101 static int adsi_input_format(
unsigned char *buf,
int num,
int dir,
int wrap,
char *format1,
char *format2);
105 int sum, x, bytes = 0;
107 float cr = 1.0, ci = 0.0, scont = 0.0;
115 for (x = 0; x < 150; x++) {
133 for (x = 0; x < msglen; x++) {
144 for (x = 0; x < 50; x++) {
161 memset(&outf, 0,
sizeof(outf));
163 if (remain && *remain) {
170 *remain = *remain - amt;
236 unsigned char buf[24000 * 5];
237 int pos = 0, res, x, start = 0, retries = 0, waittime, rem = 0, def;
247 while (retries < maxretries) {
262 ast_debug(1,
"No ADSI CPE detected (%d)\n", res);
283 ast_debug(1,
"Off-hook capable CPE only, not ADSI\n");
298 ast_debug(1,
"ADSI Compatible CPE Detected\n");
308 while ((x < 6) && msg[x]) {
313 ast_debug(1,
"Message %d, of %d input bytes, %d output bytes\n", x + 1, msglen[x], res);
328 ast_debug(1,
"Sent total spill of %d bytes\n", pos);
330 memset(ack, 0,
sizeof(ack));
336 ast_debug(1,
"Acked up to message %d\n", atoi(ack + 1)); start += atoi(ack + 1);
341 ast_debug(1,
"Retransmitting (%d), from %d\n", retries, start + 1);
348 if (retries >= maxretries) {
359 unsigned char buf[256];
374 ast_debug(1,
"Download was denied by CPE\n");
381 unsigned char buf[256];
394 unsigned char *msgs[5] = { NULL, NULL, NULL, NULL, NULL };
397 for (x = 0; x < msglen; x += (msg[x+1]+2)) {
399 ast_debug(1,
"Switch to data is sent!\n");
405 ast_debug(1,
"Switch to voice is sent!\n");
413 msgtypes[0] = msgtype;
439 ast_debug(1,
"Wait for switch is '%d'\n", waitforswitch);
468 static inline int ccopy(
unsigned char *dst,
const unsigned char *
src,
int max)
472 while ((x < max) && src[x] && (src[x] != 0xff)) {
484 if ((key < 2) || (key > 33)) {
495 bytes +=
ccopy(buf + bytes, (
const unsigned char *)llabel, 18);
501 bytes +=
ccopy(buf + bytes, (
const unsigned char *)slabel, 7);
512 bytes +=
ccopy(buf + bytes, (
const unsigned char *)ret, 20);
531 for (x = 0; x < 4; x++) {
532 buf[bytes++] = fdn[x];
535 buf[bytes++] = ver & 0xff;
555 bytes+=
ccopy(buf + bytes, (
unsigned char *)service, 18);
560 for (x = 0; x < 4; x++) {
561 buf[bytes++] = fdn[x];
564 for (x = 0; x < 4; x++) {
565 buf[bytes++] = sec[x];
568 buf[bytes++] = ver & 0xff;
613 int bytes = 0, res, gotstar = 0, pos = 0;
614 unsigned char current = 0;
616 memset(buf, 0, maxlen);
618 while (bytes <= maxlen) {
628 if ((res <
'0') || (res >
'9')) {
637 buf[bytes++] = (res << 4) | current;
650 unsigned char buf[256] =
"";
681 unsigned char buf[256] =
"";
692 if ((res =
ast_readstring(chan, (
char *) buf, 2, 1000, 500,
"")) < 0) {
695 if (strlen((
char *) buf) != 2) {
702 *width = atoi((
char *) buf);
705 memset(buf, 0,
sizeof(buf));
707 if ((res =
ast_readstring(chan, (
char *) buf, 2, 1000, 500,
"")) < 0) {
710 if (strlen((
char *) buf) != 2) {
717 *height = atoi((
char *) buf);
721 memset(buf, 0,
sizeof(buf));
723 if ((res =
ast_readstring(chan, (
char *) buf, 1, 1000, 500,
"")) < 0) {
726 if (strlen((
char *) buf) != 1) {
733 *buttons = atoi((
char *) buf);
801 buf[bytes++] = when & 0x7f;
810 int cpe = chan->
adsicpe & 0xff;
833 static int adsi_display(
unsigned char *buf,
int page,
int line,
int just,
int wrap,
834 char *col1,
char *col2)
841 if (line > 4)
return -1;
843 if (line > 33)
return -1;
856 buf[bytes++] = ((page & 0x1) << 7) | ((wrap & 0x1) << 6) | (line & 0x3f);
859 buf[bytes++] = (just & 0x3) << 5;
865 bytes+=
ccopy(buf + bytes, (
unsigned char *)col1, 20);
871 bytes +=
ccopy(buf + bytes, (
unsigned char *)col2, 20);
885 if (line > 4)
return -1;
887 if (line > 33)
return -1;
896 buf[bytes++] = ((page & 1) << 7) | (line & 0x3f);
897 buf[bytes++] = ((display & 1) << 7) | ((just & 0x3) << 4) | (format & 0x7);
903 static int adsi_input_format(
unsigned char *buf,
int num,
int dir,
int wrap,
char *format1,
char *format2)
913 buf[bytes++] = ((dir & 1) << 7) | ((wrap & 1) << 6) | (num & 0x7);
914 bytes +=
ccopy(buf + bytes, (
unsigned char *) format1, 20);
917 bytes +=
ccopy(buf + bytes, (
unsigned char *) format2, 20);
932 for (x = 0; x < 6; x++) {
933 buf[bytes++] = (keys[x] & 0x3f) ? keys[x] : (keys[x] | 0x1);
946 if (line > 4)
return -1;
948 if (line > 33)
return -1;
961 buf[bytes++] = ((page & 0x1) << 7) | (line & 0x3f);
972 unsigned char dsp[256] =
"", keyd[6] =
"";
982 for (x = 0; x <
speeds; x++) {
994 unsigned char buf[4096];
995 int bytes = 0, res, x;
997 for (x = 0; lines[x]; x++) {
1014 unsigned char dsp[256] =
"";
1034 ast_debug(1,
"No response from CPE about version. Assuming not there.\n");
1037 if (!strcmp(resp,
"B")) {
1038 ast_debug(1,
"CPE has script '%s' version %d already loaded\n", app, ver);
1040 }
else if (!strcmp(resp,
"A")) {
1041 ast_debug(1,
"CPE hasn't script '%s' version %d already loaded\n", app, ver);
1053 unsigned char dsp[256] =
"";
1070 if (!strncasecmp(s,
"l", 1)) {
1072 }
else if (!strncasecmp(s,
"r", 1)) {
1074 }
else if (!strncasecmp(s,
"i", 1)) {
1096 memset(speeddial, 0,
sizeof(speeddial));
1114 if (!strcasecmp(v->
name,
"alignment")) {
1116 }
else if (!strcasecmp(v->
name,
"greeting")) {
1122 }
else if (!strcasecmp(v->
name,
"maxretries")) {
1123 if (atoi(v->
value) > 0) {
1124 maxretries = atoi(v->
value);
1135 char *stringp = buf;
1137 name =
strsep(&stringp,
",");
1138 sname =
strsep(&stringp,
",");
static int adsi_query_cpeinfo(unsigned char *buf)
A-Law to Signed linear conversion.
int ast_safe_sleep(struct ast_channel *chan, int ms)
Wait for a specified amount of time, looking for hangups.
union ast_frame_subclass subclass
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)
char * strsep(char **str, const char *delims)
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...
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)
#define ADSI_LOAD_SOFTKEY
#define ADSI_DISC_SESSION
#define ADSI_DOWNLOAD_DISC
static int adsi_clear_soft_keys(unsigned char *buf)
struct ast_variable * ast_variable_browse(const struct ast_config *config, const char *category)
Goes through variables.
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)
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)
Configuration File Parser.
static int adsi_end_download(struct ast_channel *chan)
static int ccopy(unsigned char *dst, const unsigned char *src, int max)
#define AST_MODULE_INFO(keystr, flags_to_set, desc, fields...)
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)
enum ast_channel_adsicpe adsicpe
#define DEFAULT_ADSI_MAX_RETRIES
void ast_config_destroy(struct ast_config *config)
Destroys a config.
static int aligns[ADSI_MAX_INTRO]
int ast_channel_defer_dtmf(struct ast_channel *chan)
Defers DTMF so that you only read things like hangups and audio.
#define CONFIG_STATUS_FILEMISSING
int ast_set_write_format(struct ast_channel *chan, format_t format)
Sets write format on channel chan Set write format for channel to whichever component of "format" is ...
int ast_set_read_format(struct ast_channel *chan, format_t format)
Sets read format on channel chan Set read format for channel to whichever component of "format" is be...
#define ast_debug(level,...)
Log a DEBUG message.
u-Law to Signed linear conversion
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)
#define ast_config_load(filename, flags)
Load a config file.
static force_inline int attribute_pure ast_strlen_zero(const char *s)
struct sla_ringing_trunk * last
static int adsi_load_session(struct ast_channel *chan, unsigned char *app, int ver, int data)
#define ADSI_LINE_CONTROL
#define ADSI_INPUT_FORMAT
static int str2align(const char *s)
#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 int adsi_generate(unsigned char *buf, int msgtype, unsigned char *msg, int msglen, int msgnum, int last, format_t codec)
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
const ast_string_field name
void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Used for sending a log message This is the standard logger function. Probably the only way you will i...
#define ADSI_SWITCH_TO_DATA2
static int adsi_data_mode(unsigned char *buf)
static int unload_module(void)
static int adsi_voice_mode(unsigned char *buf, int when)
int ast_gen_cas(unsigned char *outbuf, int sas, int len, format_t codec)
Generate a CAS (CPE Alert Signal) tone for 'n' samples.
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)
static char speeddial[ADSI_MAX_SPEED_DIAL][3][SPEEDDIAL_MAX_LEN]
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)
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.
#define ADSI_CLEAR_SCREEN
Data structure associated with a single frame of data.
enum ast_frame_type frametype
struct ast_variable * next
#define ADSI_SWITCH_TO_DATA
#define CONFIG_STATUS_FILEINVALID
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)
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.
static snd_pcm_format_t format
union ast_frame::@172 data
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
#define ASTERISK_FILE_VERSION(file, version)
Register/unregister a source code file with the core.
#define CONFIG_STATUS_FILEUNCHANGED
#define ADSI_CONNECT_SESSION