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
95static int adsi_display(
unsigned char *
buf,
int page,
int line,
int just,
int wrap,
char *col1,
char *col2);
97static int adsi_load_soft_key(
unsigned char *
buf,
int key,
const char *llabel,
const char *slabel,
char *ret,
int data);
99static int adsi_input_control(
unsigned char *
buf,
int page,
int line,
int display,
int format,
int just);
100static 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++) {
163 if (remain && *remain) {
170 *remain = *remain - amt;
233 unsigned char buf[24000 * 5];
234 int pos = 0, res, x, start = 0, retries = 0, waittime, rem = 0, def;
260 ast_verb(4,
"No ADSI CPE detected (%d)\n", res);
281 ast_debug(1,
"Off-hook capable CPE only, not ADSI\n");
296 ast_verb(4,
"ADSI Compatible CPE Detected\n");
306 while ((x < 6) && msg[x]) {
311 ast_debug(1,
"Message %d, of %d input bytes, %d output bytes\n", x + 1, msglen[x], res);
326 ast_debug(1,
"Sent total spill of %d bytes\n", pos);
328 memset(ack, 0,
sizeof(ack));
334 ast_debug(1,
"Acked up to message %d\n", atoi(ack + 1)); start += atoi(ack + 1);
339 ast_debug(1,
"Retransmitting (%d), from %d\n", retries, start + 1);
357 unsigned char buf[256];
372 ast_debug(1,
"Download was denied by CPE\n");
379 unsigned char buf[256];
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;
442 ast_debug(1,
"Wait for switch is '%d'\n", waitforswitch);
471static inline int ccopy(
unsigned char *dst,
const unsigned char *
src,
int max)
475 while ((x <
max) &&
src[x] && (
src[x] != 0xff)) {
487 if ((key < 2) || (key > 33)) {
498 bytes +=
ccopy(
buf + bytes, (
const unsigned char *)llabel, 18);
504 bytes +=
ccopy(
buf + bytes, (
const unsigned char *)slabel, 7);
515 bytes +=
ccopy(
buf + bytes, (
const unsigned char *)ret, 20);
534 for (x = 0; x < 4; x++) {
535 buf[bytes++] = fdn[x];
538 buf[bytes++] = ver & 0xff;
563 for (x = 0; x < 4; x++) {
564 buf[bytes++] = fdn[x];
567 for (x = 0; x < 4; x++) {
568 buf[bytes++] = sec[x];
571 buf[bytes++] = ver & 0xff;
616 int bytes = 0, res, gotstar = 0, pos = 0;
619 memset(
buf, 0, maxlen);
621 while (bytes <= maxlen) {
631 if ((res <
'0') || (res >
'9')) {
653 unsigned char buf[256] =
"";
684 unsigned char buf[256] =
"";
698 if (strlen((
char *)
buf) != 2) {
705 *width = atoi((
char *)
buf);
708 memset(
buf, 0,
sizeof(
buf));
713 if (strlen((
char *)
buf) != 2) {
720 *height = atoi((
char *)
buf);
724 memset(
buf, 0,
sizeof(
buf));
729 if (strlen((
char *)
buf) != 1) {
736 *buttons = atoi((
char *)
buf);
804 buf[bytes++] = when & 0x7f;
837 char *col1,
char *col2)
844 if (line > 4)
return -1;
846 if (line > 33)
return -1;
859 buf[bytes++] = ((page & 0x1) << 7) | ((wrap & 0x1) << 6) | (line & 0x3f);
862 buf[bytes++] = (just & 0x3) << 5;
868 bytes+=
ccopy(
buf + bytes, (
unsigned char *)col1, 20);
874 bytes +=
ccopy(
buf + bytes, (
unsigned char *)col2, 20);
888 if (line > 4)
return -1;
890 if (line > 33)
return -1;
899 buf[bytes++] = ((page & 1) << 7) | (line & 0x3f);
900 buf[bytes++] = ((display & 1) << 7) | ((just & 0x3) << 4) | (format & 0x7);
916 buf[bytes++] = ((dir & 1) << 7) | ((wrap & 1) << 6) | (num & 0x7);
917 bytes +=
ccopy(
buf + bytes, (
unsigned char *) format1, 20);
920 bytes +=
ccopy(
buf + bytes, (
unsigned char *) format2, 20);
935 for (x = 0; x < 6; x++) {
949 if (line > 4)
return -1;
951 if (line > 33)
return -1;
964 buf[bytes++] = ((page & 0x1) << 7) | (line & 0x3f);
975 unsigned char dsp[256] =
"", keyd[6] =
"";
985 for (x = 0; x <
speeds; x++) {
997 unsigned char buf[4096];
998 int bytes = 0, res, x;
1000 for (x = 0; lines[x]; x++) {
1017 unsigned char dsp[256] =
"";
1037 ast_debug(1,
"No response from CPE about version. Assuming not there.\n");
1040 if (!strcmp(resp,
"B")) {
1041 ast_debug(1,
"CPE has script '%s' version %d already loaded\n",
app, ver);
1043 }
else if (!strcmp(resp,
"A")) {
1044 ast_debug(1,
"CPE hasn't script '%s' version %d already loaded\n",
app, ver);
1056 unsigned char dsp[256] =
"";
1073 if (!strncasecmp(s,
"l", 1)) {
1075 }
else if (!strncasecmp(s,
"r", 1)) {
1077 }
else if (!strncasecmp(s,
"i", 1)) {
1117 if (!strcasecmp(v->
name,
"alignment")) {
1119 }
else if (!strcasecmp(v->
name,
"greeting")) {
1125 }
else if (!strcasecmp(v->
name,
"maxretries")) {
1126 if (atoi(v->
value) > 0) {
1138 char *stringp =
buf;
1141 sname =
strsep(&stringp,
",");
ADSI Support (built upon Caller*ID)
#define ADSI_INPUT_CONTROL
#define ADSI_SWITCH_TO_DATA
#define ADSI_DOWNLOAD_CONNECT
#define ADSI_DISC_SESSION
#define ADSI_LINE_CONTROL
#define ADSI_MSG_DOWNLOAD
#define ADSI_CONNECT_SESSION
#define ADSI_DOWNLOAD_DISC
void ast_adsi_install_funcs(const struct adsi_funcs *funcs)
#define ADSI_CLEAR_SOFTKEY
#define ADSI_SWITCH_TO_VOICE
#define ADSI_SWITCH_TO_DATA2
#define ADSI_LOAD_SOFTKEY
#define ADSI_CLEAR_SCREEN
#define ADSI_INIT_SOFTKEY_LINE
#define ADSI_INPUT_FORMAT
#define ADSI_LOAD_VIRTUAL_DISP
#define ADSI_QUERY_CONFIG
A-Law to Signed linear conversion.
struct sla_ringing_trunk * last
Asterisk main include file. File version handling, generic pbx functions.
#define ao2_bump(obj)
Bump refcount on an AO2 object by one, returning the object.
CallerID (and other GR30) management and generation Includes code and algorithms from the Zapata libr...
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.
enum ast_cc_service_type service
static char version[AST_MAX_EXTENSION]
General Asterisk PBX channel definitions.
int ast_waitfordigit(struct ast_channel *c, int ms)
Waits for a digit.
const char * ast_channel_name(const struct ast_channel *chan)
int ast_waitfor(struct ast_channel *chan, int ms)
Wait for input on a channel.
void ast_channel_undefer_dtmf(struct ast_channel *chan)
Unset defer DTMF flag on channel.
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.
struct ast_frame * ast_read(struct ast_channel *chan)
Reads a frame.
int ast_set_read_format(struct ast_channel *chan, struct ast_format *format)
Sets read format on channel chan.
struct ast_format * ast_channel_writeformat(struct ast_channel *chan)
int ast_set_write_format(struct ast_channel *chan, struct ast_format *format)
Sets write format on channel chan.
int ast_readstring(struct ast_channel *c, char *s, int len, int timeout, int rtimeout, char *enders)
Reads multiple digits.
int ast_channel_defer_dtmf(struct ast_channel *chan)
Defers DTMF so that you only read things like hangups and audio.
void ast_channel_adsicpe_set(struct ast_channel *chan, enum ast_channel_adsicpe value)
int ast_safe_sleep(struct ast_channel *chan, int ms)
Wait for a specified amount of time, looking for hangups.
struct ast_format * ast_channel_readformat(struct ast_channel *chan)
Generic File Format Support. Should be included by clients of the file handling routines....
int ast_stopstream(struct ast_channel *c)
Stops a stream.
static int len(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)
char * strsep(char **str, const char *delims)
Configuration File Parser.
#define ast_config_load(filename, flags)
Load a config file.
#define CONFIG_STATUS_FILEMISSING
#define CONFIG_STATUS_FILEUNCHANGED
#define CONFIG_STATUS_FILEINVALID
void ast_config_destroy(struct ast_config *cfg)
Destroys a config.
struct ast_variable * ast_variable_browse(const struct ast_config *config, const char *category_name)
@ CONFIG_FLAG_FILEUNCHANGED
#define ast_debug(level,...)
Log a DEBUG message.
#define ast_verb(level,...)
Asterisk module definitions.
#define AST_MODULE_INFO(keystr, flags_to_set, desc, fields...)
@ AST_MODULE_SUPPORT_DEPRECATED
#define ASTERISK_GPL_KEY
The text the key() function should return.
@ AST_MODULE_LOAD_SUCCESS
static int adsi_set_keys(unsigned char *buf, unsigned char *keys)
static int adsi_input_format(unsigned char *buf, int num, int dir, int wrap, char *format1, char *format2)
static struct adsi_funcs res_adsi_funcs
static int adsi_read_encoded_dtmf(struct ast_channel *chan, unsigned char *buf, int maxlen)
#define ADSI_FLAG_DATAMODE
static int adsi_voice_mode(unsigned char *buf, int when)
static int adsi_channel_restore(struct ast_channel *chan)
static int adsi_query_cpeinfo(unsigned char *buf)
static int __adsi_transmit_messages(struct ast_channel *chan, unsigned char **msg, int *msglen, int *msgtype)
static int adsi_end_download(struct ast_channel *chan)
static int aligns[ADSI_MAX_INTRO]
static int adsi_download_disconnect(unsigned char *buf)
static int adsi_print(struct ast_channel *chan, char **lines, int *align, int voice)
static int adsi_get_cpeid(struct ast_channel *chan, unsigned char *cpeid, int voice)
static int adsi_set_line(unsigned char *buf, int page, int line)
static int adsi_data_mode(unsigned char *buf)
static int adsi_query_cpeid(unsigned char *buf)
static int adsi_disconnect_session(unsigned char *buf)
static int adsi_download_connect(unsigned char *buf, char *service, unsigned char *fdn, unsigned char *sec, int ver)
#define SPEEDDIAL_MAX_LEN
static int adsi_careful_send(struct ast_channel *chan, unsigned char *buf, int len, int *remain)
#define ADSI_MAX_SPEED_DIAL
static int adsi_load_soft_key(unsigned char *buf, int key, const char *llabel, const char *slabel, char *ret, int data)
static int adsi_input_control(unsigned char *buf, int page, int line, int display, int format, int just)
static int adsi_get_cpeinfo(struct ast_channel *chan, int *width, int *height, int *buttons, int voice)
static int adsi_clear_soft_keys(unsigned char *buf)
static char speeddial[ADSI_MAX_SPEED_DIAL][3][SPEEDDIAL_MAX_LEN]
static int adsi_transmit_message_full(struct ast_channel *chan, unsigned char *msg, int msglen, int msgtype, int dowait)
static int adsi_connect_session(unsigned char *buf, unsigned char *fdn, int ver)
static int adsi_begin_download(struct ast_channel *chan, char *service, unsigned char *fdn, unsigned char *sec, int version)
static int adsi_load_session(struct ast_channel *chan, unsigned char *app, int ver, int data)
static int adsi_unload_session(struct ast_channel *chan)
static void adsi_load(int reload)
static int adsi_clear_screen(unsigned char *buf)
static int load_module(void)
static char intro[ADSI_MAX_INTRO][20]
static int adsi_transmit_message(struct ast_channel *chan, unsigned char *msg, int msglen, int msgtype)
static int unload_module(void)
static void init_state(void)
static int adsi_generate(unsigned char *buf, int msgtype, unsigned char *msg, int msglen, int msgnum, int last, struct ast_format *codec)
static int str2align(const char *s)
static int ccopy(unsigned char *dst, const unsigned char *src, int max)
#define DEFAULT_ADSI_MAX_RETRIES
static int adsi_available(struct ast_channel *chan)
static int adsi_display(unsigned char *buf, int page, int line, int just, int wrap, char *col1, char *col2)
static force_inline int attribute_pure ast_strlen_zero(const char *s)
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
Main Channel structure associated with a channel.
Structure used to handle boolean flags.
struct ast_format * format
Data structure associated with a single frame of data.
struct ast_frame_subclass subclass
union ast_frame::@226 data
enum ast_frame_type frametype
Structure for variables, used for configurations and for channel variables.
struct ast_variable * next
All configuration options for http media cache.
Time-related functions and macros.
u-Law to Signed linear conversion
#define RAII_VAR(vartype, varname, initval, dtor)
Declare a variable that will call a destructor function when it goes out of scope.