#include "asterisk.h"
#include <time.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <math.h>
#include <errno.h>
#include "asterisk/ulaw.h"
#include "asterisk/alaw.h"
#include "asterisk/callerid.h"
#include "asterisk/logger.h"
#include "asterisk/fskmodem.h"
#include "asterisk/channel.h"
#include "asterisk/adsi.h"
#include "asterisk/module.h"
#include "asterisk/config.h"
#include "asterisk/file.h"
Include dependency graph for res_adsi.c:
Go to the source code of this file.
Defines | |
#define | ADSI_FLAG_DATAMODE (1 << 8) |
#define | ADSI_MAX_INTRO 20 |
#define | ADSI_MAX_SPEED_DIAL 6 |
#define | ADSI_SPEED_DIAL 10 |
#define | DEFAULT_ADSI_MAX_RETRIES 3 |
Functions | |
static int | __adsi_transmit_messages (struct ast_channel *chan, unsigned char **msg, int *msglen, int *msgtype) |
static int | adsi_careful_send (struct ast_channel *chan, unsigned char *buf, int len, int *remainder) |
static int | adsi_generate (unsigned char *buf, int msgtype, unsigned char *msg, int msglen, int msgnum, int last, int codec) |
static void | adsi_load (void) |
int | ast_adsi_available (struct ast_channel *chan) |
int | ast_adsi_begin_download (struct ast_channel *chan, char *service, unsigned char *fdn, unsigned char *sec, int version) |
int | ast_adsi_channel_restore (struct ast_channel *chan) |
int | ast_adsi_clear_screen (unsigned char *buf) |
int | ast_adsi_clear_soft_keys (unsigned char *buf) |
int | ast_adsi_connect_session (unsigned char *buf, unsigned char *fdn, int ver) |
int | ast_adsi_data_mode (unsigned char *buf) |
int | ast_adsi_disconnect_session (unsigned char *buf) |
int | ast_adsi_display (unsigned char *buf, int page, int line, int just, int wrap, char *col1, char *col2) |
int | ast_adsi_download_connect (unsigned char *buf, char *service, unsigned char *fdn, unsigned char *sec, int ver) |
int | ast_adsi_download_disconnect (unsigned char *buf) |
int | ast_adsi_end_download (struct ast_channel *chan) |
int | ast_adsi_get_cpeid (struct ast_channel *chan, unsigned char *cpeid, int voice) |
int | ast_adsi_get_cpeinfo (struct ast_channel *chan, int *width, int *height, int *buttons, int voice) |
int | ast_adsi_input_control (unsigned char *buf, int page, int line, int display, int format, int just) |
int | ast_adsi_input_format (unsigned char *buf, int num, int dir, int wrap, char *format1, char *format2) |
int | ast_adsi_load_session (struct ast_channel *chan, unsigned char *app, int ver, int data) |
int | ast_adsi_load_soft_key (unsigned char *buf, int key, const char *llabel, const char *slabel, const char *ret, int data) |
int | ast_adsi_print (struct ast_channel *chan, char **lines, int *aligns, int voice) |
int | ast_adsi_query_cpeid (unsigned char *buf) |
int | ast_adsi_query_cpeinfo (unsigned char *buf) |
int | ast_adsi_read_encoded_dtmf (struct ast_channel *chan, unsigned char *buf, int maxlen) |
int | ast_adsi_set_keys (unsigned char *buf, unsigned char *keys) |
int | ast_adsi_set_line (unsigned char *buf, int page, int line) |
int | ast_adsi_transmit_message (struct ast_channel *chan, unsigned char *msg, int msglen, int msgtype) |
int | ast_adsi_transmit_message_full (struct ast_channel *chan, unsigned char *msg, int msglen, int msgtype, int dowait) |
int | ast_adsi_unload_session (struct ast_channel *chan) |
int | ast_adsi_voice_mode (unsigned char *buf, int when) |
AST_MODULE_INFO (ASTERISK_GPL_KEY, AST_MODFLAG_GLOBAL_SYMBOLS,"ADSI Resource (not optional)",.load=load_module,.unload=unload_module,.reload=reload,) | |
static int | ccopy (unsigned char *dst, const unsigned char *src, int max) |
static void | init_state (void) |
static int | load_module (void) |
static int | reload (void) |
static int | str2align (char *s) |
static int | unload_module (void) |
Variables | |
static int | alignment = 0 |
static int | aligns [ADSI_MAX_INTRO] |
static char | intro [ADSI_MAX_INTRO][20] |
static int | maxretries = DEFAULT_ADSI_MAX_RETRIES |
static char | speeddial [ADSI_MAX_SPEED_DIAL][3][20] |
static int | speeds = 0 |
static int | total = 0 |
Definition in file res_adsi.c.
#define ADSI_FLAG_DATAMODE (1 << 8) |
Definition at line 61 of file res_adsi.c.
Referenced by __adsi_transmit_messages(), and ast_adsi_transmit_message_full().
#define ADSI_MAX_INTRO 20 |
#define ADSI_MAX_SPEED_DIAL 6 |
#define ADSI_SPEED_DIAL 10 |
#define DEFAULT_ADSI_MAX_RETRIES 3 |
Definition at line 56 of file res_adsi.c.
static int __adsi_transmit_messages | ( | struct ast_channel * | chan, | |
unsigned char ** | msg, | |||
int * | msglen, | |||
int * | msgtype | |||
) | [static] |
Definition at line 196 of file res_adsi.c.
References adsi_careful_send(), ADSI_FLAG_DATAMODE, adsi_generate(), ast_channel::adsicpe, AST_ADSI_AVAILABLE, AST_ADSI_UNAVAILABLE, ast_channel_defer_dtmf(), ast_channel_undefer_dtmf(), AST_FORMAT_ULAW, AST_FRAME_DTMF, ast_frfree(), ast_gen_cas(), ast_log(), ast_read(), ast_readstring(), ast_waitfor(), f, LOG_DEBUG, and LOG_WARNING.
Referenced by ast_adsi_transmit_message_full().
00197 { 00198 /* msglen must be no more than 256 bits, each */ 00199 unsigned char buf[24000 * 5]; 00200 int pos = 0, res; 00201 int x; 00202 int start=0; 00203 int retries = 0; 00204 00205 char ack[3]; 00206 00207 /* Wait up to 500 ms for initial ACK */ 00208 int waittime; 00209 struct ast_frame *f; 00210 int rem = 0; 00211 int def; 00212 00213 if (chan->adsicpe == AST_ADSI_UNAVAILABLE) { 00214 /* Don't bother if we know they don't support ADSI */ 00215 errno = ENOSYS; 00216 return -1; 00217 } 00218 00219 while(retries < maxretries) { 00220 if (!(chan->adsicpe & ADSI_FLAG_DATAMODE)) { 00221 /* Generate CAS (no SAS) */ 00222 ast_gen_cas(buf, 0, 680, AST_FORMAT_ULAW); 00223 00224 /* Send CAS */ 00225 if (adsi_careful_send(chan, buf, 680, NULL)) { 00226 ast_log(LOG_WARNING, "Unable to send CAS\n"); 00227 } 00228 /* Wait For DTMF result */ 00229 waittime = 500; 00230 for(;;) { 00231 if (((res = ast_waitfor(chan, waittime)) < 1)) { 00232 /* Didn't get back DTMF A in time */ 00233 ast_log(LOG_DEBUG, "No ADSI CPE detected (%d)\n", res); 00234 if (!chan->adsicpe) 00235 chan->adsicpe = AST_ADSI_UNAVAILABLE; 00236 errno = ENOSYS; 00237 return -1; 00238 } 00239 waittime = res; 00240 f = ast_read(chan); 00241 if (!f) { 00242 ast_log(LOG_DEBUG, "Hangup in ADSI\n"); 00243 return -1; 00244 } 00245 if (f->frametype == AST_FRAME_DTMF) { 00246 if (f->subclass == 'A') { 00247 /* Okay, this is an ADSI CPE. Note this for future reference, too */ 00248 if (!chan->adsicpe) 00249 chan->adsicpe = AST_ADSI_AVAILABLE; 00250 break; 00251 } else { 00252 if (f->subclass == 'D') { 00253 ast_log(LOG_DEBUG, "Off-hook capable CPE only, not ADSI\n"); 00254 } else 00255 ast_log(LOG_WARNING, "Unknown ADSI response '%c'\n", f->subclass); 00256 if (!chan->adsicpe) 00257 chan->adsicpe = AST_ADSI_UNAVAILABLE; 00258 errno = ENOSYS; 00259 return -1; 00260 } 00261 } 00262 ast_frfree(f); 00263 } 00264 00265 ast_log(LOG_DEBUG, "ADSI Compatible CPE Detected\n"); 00266 } else 00267 ast_log(LOG_DEBUG, "Already in data mode\n"); 00268 00269 x = 0; 00270 pos = 0; 00271 #if 1 00272 def= ast_channel_defer_dtmf(chan); 00273 #endif 00274 while((x < 6) && msg[x]) { 00275 res = adsi_generate(buf + pos, msgtype[x], msg[x], msglen[x], x+1 - start, (x == 5) || !msg[x+1], AST_FORMAT_ULAW); 00276 if (res < 0) { 00277 ast_log(LOG_WARNING, "Failed to generate ADSI message %d on channel %s\n", x + 1, chan->name); 00278 return -1; 00279 } 00280 ast_log(LOG_DEBUG, "Message %d, of %d input bytes, %d output bytes\n", 00281 x + 1, msglen[x], res); 00282 pos += res; 00283 x++; 00284 } 00285 00286 00287 rem = 0; 00288 res = adsi_careful_send(chan, buf, pos, &rem); 00289 if (!def) 00290 ast_channel_undefer_dtmf(chan); 00291 if (res) 00292 return -1; 00293 00294 ast_log(LOG_DEBUG, "Sent total spill of %d bytes\n", pos); 00295 00296 memset(ack, 0, sizeof(ack)); 00297 /* Get real result */ 00298 res = ast_readstring(chan, ack, 2, 1000, 1000, ""); 00299 /* Check for hangup */ 00300 if (res < 0) 00301 return -1; 00302 if (ack[0] == 'D') { 00303 ast_log(LOG_DEBUG, "Acked up to message %d\n", atoi(ack + 1)); 00304 start += atoi(ack + 1); 00305 if (start >= x) 00306 break; 00307 else { 00308 retries++; 00309 ast_log(LOG_DEBUG, "Retransmitting (%d), from %d\n", retries, start + 1); 00310 } 00311 } else { 00312 retries++; 00313 ast_log(LOG_WARNING, "Unexpected response to ack: %s (retry %d)\n", ack, retries); 00314 } 00315 } 00316 if (retries >= maxretries) { 00317 ast_log(LOG_WARNING, "Maximum ADSI Retries (%d) exceeded\n", maxretries); 00318 errno = ETIMEDOUT; 00319 return -1; 00320 } 00321 return 0; 00322 00323 }
static int adsi_careful_send | ( | struct ast_channel * | chan, | |
unsigned char * | buf, | |||
int | len, | |||
int * | remainder | |||
) | [static] |
Definition at line 125 of file res_adsi.c.
References AST_FORMAT_ULAW, AST_FRAME_VOICE, ast_frfree(), ast_log(), ast_read(), ast_waitfor(), ast_write(), ast_frame::datalen, ast_frame::frametype, LOG_WARNING, and ast_frame::subclass.
Referenced by __adsi_transmit_messages().
00126 { 00127 /* Sends carefully on a full duplex channel by using reading for 00128 timing */ 00129 struct ast_frame *inf, outf; 00130 int amt; 00131 00132 /* Zero out our outgoing frame */ 00133 memset(&outf, 0, sizeof(outf)); 00134 00135 if (remainder && *remainder) { 00136 amt = len; 00137 00138 /* Send remainder if provided */ 00139 if (amt > *remainder) 00140 amt = *remainder; 00141 else 00142 *remainder = *remainder - amt; 00143 outf.frametype = AST_FRAME_VOICE; 00144 outf.subclass = AST_FORMAT_ULAW; 00145 outf.data = buf; 00146 outf.datalen = amt; 00147 outf.samples = amt; 00148 if (ast_write(chan, &outf)) { 00149 ast_log(LOG_WARNING, "Failed to carefully write frame\n"); 00150 return -1; 00151 } 00152 /* Update pointers and lengths */ 00153 buf += amt; 00154 len -= amt; 00155 } 00156 00157 while(len) { 00158 amt = len; 00159 /* If we don't get anything at all back in a second, forget 00160 about it */ 00161 if (ast_waitfor(chan, 1000) < 1) 00162 return -1; 00163 inf = ast_read(chan); 00164 /* Detect hangup */ 00165 if (!inf) 00166 return -1; 00167 if (inf->frametype == AST_FRAME_VOICE) { 00168 /* Read a voice frame */ 00169 if (inf->subclass != AST_FORMAT_ULAW) { 00170 ast_log(LOG_WARNING, "Channel not in ulaw?\n"); 00171 return -1; 00172 } 00173 /* Send no more than they sent us */ 00174 if (amt > inf->datalen) 00175 amt = inf->datalen; 00176 else if (remainder) 00177 *remainder = inf->datalen - amt; 00178 outf.frametype = AST_FRAME_VOICE; 00179 outf.subclass = AST_FORMAT_ULAW; 00180 outf.data = buf; 00181 outf.datalen = amt; 00182 outf.samples = amt; 00183 if (ast_write(chan, &outf)) { 00184 ast_log(LOG_WARNING, "Failed to carefully write frame\n"); 00185 return -1; 00186 } 00187 /* Update pointers and lengths */ 00188 buf += amt; 00189 len -= amt; 00190 } 00191 ast_frfree(inf); 00192 } 00193 return 0; 00194 }
static int adsi_generate | ( | unsigned char * | buf, | |
int | msgtype, | |||
unsigned char * | msg, | |||
int | msglen, | |||
int | msgnum, | |||
int | last, | |||
int | codec | |||
) | [static] |
Definition at line 75 of file res_adsi.c.
References PUT_CLID, and PUT_CLID_MARKMS.
Referenced by __adsi_transmit_messages().
00076 { 00077 int sum; 00078 int x; 00079 int bytes=0; 00080 /* Initial carrier (imaginary) */ 00081 float cr = 1.0; 00082 float ci = 0.0; 00083 float scont = 0.0; 00084 00085 if (msglen > 255) 00086 msglen = 255; 00087 00088 /* If first message, Send 150ms of MARK's */ 00089 if (msgnum == 1) { 00090 for (x=0;x<150;x++) /* was 150 */ 00091 PUT_CLID_MARKMS; 00092 } 00093 /* Put message type */ 00094 PUT_CLID(msgtype); 00095 sum = msgtype; 00096 00097 /* Put message length (plus one for the message number) */ 00098 PUT_CLID(msglen + 1); 00099 sum += msglen + 1; 00100 00101 /* Put message number */ 00102 PUT_CLID(msgnum); 00103 sum += msgnum; 00104 00105 /* Put actual message */ 00106 for (x=0;x<msglen;x++) { 00107 PUT_CLID(msg[x]); 00108 sum += msg[x]; 00109 } 00110 00111 /* Put 2's compliment of sum */ 00112 PUT_CLID(256-(sum & 0xff)); 00113 00114 #if 0 00115 if (last) { 00116 /* Put trailing marks */ 00117 for (x=0;x<50;x++) 00118 PUT_CLID_MARKMS; 00119 } 00120 #endif 00121 return bytes; 00122 00123 }
static void adsi_load | ( | void | ) | [static] |
Definition at line 1061 of file res_adsi.c.
References ADSI_MAX_INTRO, ADSI_MAX_SPEED_DIAL, ast_config_destroy(), ast_config_load(), ast_variable_browse(), init_state(), ast_variable::name, name, ast_variable::next, str2align(), strsep(), and ast_variable::value.
Referenced by load_module(), and reload().
01062 { 01063 int x; 01064 struct ast_config *conf; 01065 struct ast_variable *v; 01066 char *name, *sname; 01067 init_state(); 01068 conf = ast_config_load("adsi.conf"); 01069 if (conf) { 01070 x=0; 01071 for (v = ast_variable_browse(conf, "intro"); v; v = v->next) { 01072 if (!strcasecmp(v->name, "alignment")) 01073 alignment = str2align(v->value); 01074 else if (!strcasecmp(v->name, "greeting")) { 01075 if (x < ADSI_MAX_INTRO) { 01076 aligns[x] = alignment; 01077 ast_copy_string(intro[x], v->value, sizeof(intro[x])); 01078 x++; 01079 } 01080 } else if (!strcasecmp(v->name, "maxretries")) { 01081 if (atoi(v->value) > 0) 01082 maxretries = atoi(v->value); 01083 } 01084 } 01085 if (x) 01086 total = x; 01087 x = 0; 01088 for (v = ast_variable_browse(conf, "speeddial"); v; v = v->next) { 01089 char *stringp = v->value; 01090 name = strsep(&stringp, ","); 01091 sname = strsep(&stringp, ","); 01092 if (!sname) 01093 sname = name; 01094 if (x < ADSI_MAX_SPEED_DIAL) { 01095 ast_copy_string(speeddial[x][0], v->name, sizeof(speeddial[x][0])); 01096 ast_copy_string(speeddial[x][1], name, 18); 01097 ast_copy_string(speeddial[x][2], sname, 7); 01098 x++; 01099 } 01100 } 01101 if (x) 01102 speeds = x; 01103 ast_config_destroy(conf); 01104 } 01105 }
int ast_adsi_available | ( | struct ast_channel * | chan | ) |
chan | Channel to check |
Definition at line 768 of file res_adsi.c.
References ast_channel::adsicpe, AST_ADSI_AVAILABLE, and AST_ADSI_UNKNOWN.
Referenced by adsi_begin(), adsi_delete(), adsi_exec(), adsi_folders(), adsi_goodbye(), adsi_login(), adsi_message(), adsi_password(), adsi_status(), adsi_status2(), ast_park_call(), vm_newuser(), vm_options(), and vm_tempgreeting().
00769 { 00770 int cpe = chan->adsicpe & 0xff; 00771 if ((cpe == AST_ADSI_AVAILABLE) || 00772 (cpe == AST_ADSI_UNKNOWN)) 00773 return 1; 00774 return 0; 00775 }
int ast_adsi_begin_download | ( | struct ast_channel * | chan, | |
char * | service, | |||
unsigned char * | fdn, | |||
unsigned char * | sec, | |||
int | version | |||
) |
Definition at line 325 of file res_adsi.c.
References ADSI_MSG_DOWNLOAD, ast_adsi_download_connect(), ast_adsi_transmit_message_full(), ast_log(), ast_readstring(), and LOG_DEBUG.
Referenced by adsi_load_vmail(), and adsi_prog().
00326 { 00327 int bytes; 00328 unsigned char buf[256]; 00329 char ack[2]; 00330 bytes = 0; 00331 /* Setup the resident soft key stuff, a piece at a time */ 00332 /* Upload what scripts we can for voicemail ahead of time */ 00333 bytes += ast_adsi_download_connect(buf + bytes, service, fdn, sec, version); 00334 if (ast_adsi_transmit_message_full(chan, buf, bytes, ADSI_MSG_DOWNLOAD, 0)) 00335 return -1; 00336 if (ast_readstring(chan, ack, 1, 10000, 10000, "")) 00337 return -1; 00338 if (ack[0] == 'B') 00339 return 0; 00340 ast_log(LOG_DEBUG, "Download was denied by CPE\n"); 00341 return -1; 00342 }
int ast_adsi_channel_restore | ( | struct ast_channel * | chan | ) |
chan | Channel to restore |
Definition at line 926 of file res_adsi.c.
References ADSI_INFO_PAGE, ADSI_MSG_DISPLAY, ADSI_SPEED_DIAL, ast_adsi_set_keys(), ast_adsi_set_line(), and ast_adsi_transmit_message_full().
00927 { 00928 unsigned char dsp[256]; 00929 int bytes; 00930 int x; 00931 unsigned char keyd[6]; 00932 00933 memset(dsp, 0, sizeof(dsp)); 00934 00935 /* Start with initial display setup */ 00936 bytes = 0; 00937 bytes += ast_adsi_set_line(dsp + bytes, ADSI_INFO_PAGE, 1); 00938 00939 /* Prepare key setup messages */ 00940 00941 if (speeds) { 00942 memset(keyd, 0, sizeof(keyd)); 00943 for (x=0;x<speeds;x++) { 00944 keyd[x] = ADSI_SPEED_DIAL + x; 00945 } 00946 bytes += ast_adsi_set_keys(dsp + bytes, keyd); 00947 } 00948 ast_adsi_transmit_message_full(chan, dsp, bytes, ADSI_MSG_DISPLAY, 0); 00949 return 0; 00950 00951 }
int ast_adsi_clear_screen | ( | unsigned char * | buf | ) |
Definition at line 736 of file res_adsi.c.
References ADSI_CLEAR_SCREEN.
00737 { 00738 int bytes=0; 00739 00740 /* Message type */ 00741 buf[bytes++] = ADSI_CLEAR_SCREEN; 00742 00743 /* Reserve space for length */ 00744 bytes++; 00745 00746 buf[1] = bytes - 2; 00747 return bytes; 00748 00749 }
int ast_adsi_clear_soft_keys | ( | unsigned char * | buf | ) |
Definition at line 721 of file res_adsi.c.
References ADSI_CLEAR_SOFTKEY.
00722 { 00723 int bytes=0; 00724 00725 /* Message type */ 00726 buf[bytes++] = ADSI_CLEAR_SOFTKEY; 00727 00728 /* Reserve space for length */ 00729 bytes++; 00730 00731 buf[1] = bytes - 2; 00732 return bytes; 00733 00734 }
int ast_adsi_connect_session | ( | unsigned char * | buf, | |
unsigned char * | fdn, | |||
int | ver | |||
) |
buf | Character buffer to create parameter in (must have at least 256 free) | |
fdn | Optional 4 byte Feature Download Number (for loading soft keys) | |
ver | Optional version number (0-255, or -1 to omit) |
Definition at line 486 of file res_adsi.c.
References ADSI_CONNECT_SESSION.
Referenced by ast_adsi_load_session().
00487 { 00488 int bytes=0; 00489 int x; 00490 00491 /* Message type */ 00492 buf[bytes++] = ADSI_CONNECT_SESSION; 00493 00494 /* Reserve space for length */ 00495 bytes++; 00496 00497 if (fdn) { 00498 for (x=0;x<4;x++) 00499 buf[bytes++] = fdn[x]; 00500 if (ver > -1) 00501 buf[bytes++] = ver & 0xff; 00502 } 00503 00504 buf[1] = bytes - 2; 00505 return bytes; 00506 00507 }
int ast_adsi_data_mode | ( | unsigned char * | buf | ) |
buf | Character buffer to create parameter in (must have at least 256 free) |
Definition at line 706 of file res_adsi.c.
References ADSI_SWITCH_TO_DATA.
Referenced by adsi_load_vmail(), ast_adsi_get_cpeid(), ast_adsi_get_cpeinfo(), and ast_adsi_load_session().
00707 { 00708 int bytes=0; 00709 00710 /* Message type */ 00711 buf[bytes++] = ADSI_SWITCH_TO_DATA; 00712 00713 /* Reserve space for length */ 00714 bytes++; 00715 00716 buf[1] = bytes - 2; 00717 return bytes; 00718 00719 }
int ast_adsi_disconnect_session | ( | unsigned char * | buf | ) |
buf | Character buffer to create parameter in (must have at least 256 free) |
Definition at line 539 of file res_adsi.c.
References ADSI_DISC_SESSION.
Referenced by ast_adsi_unload_session().
00540 { 00541 int bytes=0; 00542 00543 /* Message type */ 00544 buf[bytes++] = ADSI_DISC_SESSION; 00545 00546 /* Reserve space for length */ 00547 bytes++; 00548 00549 buf[1] = bytes - 2; 00550 return bytes; 00551 00552 }
int ast_adsi_display | ( | unsigned char * | buf, | |
int | page, | |||
int | line, | |||
int | just, | |||
int | wrap, | |||
char * | col1, | |||
char * | col2 | |||
) |
buf | Character buffer to create parameter in (must have at least 256 free) | |
page | Page to load (ADSI_COMM_PAGE or ADSI_INFO_PAGE) | |
line | Line number to load (1-4 for Comm page, 1-33 for info page) | |
just | Line justification (ADSI_JUST_LEFT, ADSI_JUST_RIGHT, ADSI_JUST_CENT, ADSI_JUST_IND) | |
wrap | Wrap (1 = yes, 0 = no) | |
col1 | Text to place in first column | |
col2 | Text to place in second column |
Definition at line 792 of file res_adsi.c.
References ADSI_LOAD_VIRTUAL_DISP, and ccopy().
Referenced by adsi_folders(), adsi_goodbye(), adsi_load_vmail(), adsi_login(), adsi_logo(), adsi_status(), adsi_status2(), ast_adsi_print(), vm_newuser(), vm_options(), and vm_tempgreeting().
00794 { 00795 int bytes=0; 00796 00797 /* Sanity check line number */ 00798 00799 if (page) { 00800 if (line > 4) return -1; 00801 } else { 00802 if (line > 33) return -1; 00803 } 00804 00805 if (line < 1) 00806 return -1; 00807 /* Parameter type */ 00808 buf[bytes++] = ADSI_LOAD_VIRTUAL_DISP; 00809 00810 /* Reserve space for size */ 00811 bytes++; 00812 00813 /* Page and wrap indicator */ 00814 buf[bytes++] = ((page & 0x1) << 7) | ((wrap & 0x1) << 6) | (line & 0x3f); 00815 00816 /* Justification */ 00817 buf[bytes++] = (just & 0x3) << 5; 00818 00819 /* Omit highlight mode definition */ 00820 buf[bytes++] = 0xff; 00821 00822 /* Primary column */ 00823 bytes+= ccopy(buf + bytes, (unsigned char *)col1, 20); 00824 00825 /* Delimiter */ 00826 buf[bytes++] = 0xff; 00827 00828 /* Secondary column */ 00829 bytes += ccopy(buf + bytes, (unsigned char *)col2, 20); 00830 00831 /* Update length */ 00832 buf[1] = bytes - 2; 00833 00834 return bytes; 00835 00836 }
int ast_adsi_download_connect | ( | unsigned char * | buf, | |
char * | service, | |||
unsigned char * | fdn, | |||
unsigned char * | sec, | |||
int | ver | |||
) |
buf | Character buffer to create parameter in (must have at least 256 free) | |
service | a 1-18 byte name of the feature | |
fdn | 4 byte Feature Download Number (for loading soft keys) | |
sec | 4 byte vendor security code | |
ver | version number (0-255, or -1 to omit) |
Definition at line 509 of file res_adsi.c.
References ADSI_DOWNLOAD_CONNECT, and ccopy().
Referenced by ast_adsi_begin_download().
00510 { 00511 int bytes=0; 00512 int x; 00513 00514 /* Message type */ 00515 buf[bytes++] = ADSI_DOWNLOAD_CONNECT; 00516 00517 /* Reserve space for length */ 00518 bytes++; 00519 00520 /* Primary column */ 00521 bytes+= ccopy(buf + bytes, (unsigned char *)service, 18); 00522 00523 /* Delimiter */ 00524 buf[bytes++] = 0xff; 00525 00526 for (x=0;x<4;x++) { 00527 buf[bytes++] = fdn[x]; 00528 } 00529 for (x=0;x<4;x++) 00530 buf[bytes++] = sec[x]; 00531 buf[bytes++] = ver & 0xff; 00532 00533 buf[1] = bytes - 2; 00534 00535 return bytes; 00536 00537 }
int ast_adsi_download_disconnect | ( | unsigned char * | buf | ) |
buf | Character buffer to create parameter in (must have at least 256 free) |
Definition at line 777 of file res_adsi.c.
References ADSI_DOWNLOAD_DISC.
Referenced by adsi_load_vmail(), and ast_adsi_end_download().
00778 { 00779 int bytes=0; 00780 00781 /* Message type */ 00782 buf[bytes++] = ADSI_DOWNLOAD_DISC; 00783 00784 /* Reserve space for length */ 00785 bytes++; 00786 00787 buf[1] = bytes - 2; 00788 return bytes; 00789 00790 }
int ast_adsi_end_download | ( | struct ast_channel * | chan | ) |
Definition at line 344 of file res_adsi.c.
References ADSI_MSG_DOWNLOAD, ast_adsi_download_disconnect(), and ast_adsi_transmit_message_full().
Referenced by adsi_load_vmail().
00345 { 00346 int bytes; 00347 unsigned char buf[256]; 00348 bytes = 0; 00349 /* Setup the resident soft key stuff, a piece at a time */ 00350 /* Upload what scripts we can for voicemail ahead of time */ 00351 bytes += ast_adsi_download_disconnect(buf + bytes); 00352 if (ast_adsi_transmit_message_full(chan, buf, bytes, ADSI_MSG_DOWNLOAD, 0)) 00353 return -1; 00354 return 0; 00355 }
int ast_adsi_get_cpeid | ( | struct ast_channel * | chan, | |
unsigned char * | cpeid, | |||
int | voice | |||
) |
Returns 1 on success, storing 4 bytes of CPE ID at buf or -1 on hangup, or 0 if there was no hangup but it failed to find the device ID. Returns to voice mode if "voice" is non-zero.
Definition at line 609 of file res_adsi.c.
References ADSI_MSG_DISPLAY, ast_adsi_data_mode(), ast_adsi_query_cpeid(), ast_adsi_read_encoded_dtmf(), ast_adsi_transmit_message_full(), ast_adsi_voice_mode(), ast_log(), ast_waitfordigit(), and LOG_WARNING.
Referenced by cpeid_exec().
00610 { 00611 unsigned char buf[256]; 00612 int bytes = 0; 00613 int res; 00614 bytes += ast_adsi_data_mode(buf); 00615 ast_adsi_transmit_message_full(chan, buf, bytes, ADSI_MSG_DISPLAY, 0); 00616 00617 bytes = 0; 00618 bytes += ast_adsi_query_cpeid(buf); 00619 ast_adsi_transmit_message_full(chan, buf, bytes, ADSI_MSG_DISPLAY, 0); 00620 00621 /* Get response */ 00622 memset(buf, 0, sizeof(buf)); 00623 res = ast_adsi_read_encoded_dtmf(chan, cpeid, 4); 00624 if (res != 4) { 00625 ast_log(LOG_WARNING, "Got %d bytes back of encoded DTMF, expecting 4\n", res); 00626 res = 0; 00627 } else { 00628 res = 1; 00629 } 00630 00631 if (voice) { 00632 bytes = 0; 00633 bytes += ast_adsi_voice_mode(buf, 0); 00634 ast_adsi_transmit_message_full(chan, buf, bytes, ADSI_MSG_DISPLAY, 0); 00635 /* Ignore the resulting DTMF B announcing it's in voice mode */ 00636 ast_waitfordigit(chan, 1000); 00637 } 00638 return res; 00639 }
int ast_adsi_get_cpeinfo | ( | struct ast_channel * | chan, | |
int * | width, | |||
int * | height, | |||
int * | buttons, | |||
int | voice | |||
) |
Definition at line 641 of file res_adsi.c.
References ADSI_MSG_DISPLAY, ast_adsi_data_mode(), ast_adsi_query_cpeinfo(), ast_adsi_transmit_message_full(), ast_adsi_voice_mode(), ast_log(), ast_readstring(), ast_waitfordigit(), and LOG_WARNING.
Referenced by cpeid_exec().
00642 { 00643 unsigned char buf[256]; 00644 int bytes = 0; 00645 int res; 00646 bytes += ast_adsi_data_mode(buf); 00647 ast_adsi_transmit_message_full(chan, buf, bytes, ADSI_MSG_DISPLAY, 0); 00648 00649 bytes = 0; 00650 bytes += ast_adsi_query_cpeinfo(buf); 00651 ast_adsi_transmit_message_full(chan, buf, bytes, ADSI_MSG_DISPLAY, 0); 00652 00653 /* Get width */ 00654 memset(buf, 0, sizeof(buf)); 00655 res = ast_readstring(chan, (char *)buf, 2, 1000, 500, ""); 00656 if (res < 0) 00657 return res; 00658 if (strlen((char *)buf) != 2) { 00659 ast_log(LOG_WARNING, "Got %d bytes of width, expecting 2\n", res); 00660 res = 0; 00661 } else { 00662 res = 1; 00663 } 00664 if (width) 00665 *width = atoi((char *)buf); 00666 /* Get height */ 00667 memset(buf, 0, sizeof(buf)); 00668 if (res) { 00669 res = ast_readstring(chan, (char *)buf, 2, 1000, 500, ""); 00670 if (res < 0) 00671 return res; 00672 if (strlen((char *)buf) != 2) { 00673 ast_log(LOG_WARNING, "Got %d bytes of height, expecting 2\n", res); 00674 res = 0; 00675 } else { 00676 res = 1; 00677 } 00678 if (height) 00679 *height= atoi((char *)buf); 00680 } 00681 /* Get buttons */ 00682 memset(buf, 0, sizeof(buf)); 00683 if (res) { 00684 res = ast_readstring(chan, (char *)buf, 1, 1000, 500, ""); 00685 if (res < 0) 00686 return res; 00687 if (strlen((char *)buf) != 1) { 00688 ast_log(LOG_WARNING, "Got %d bytes of buttons, expecting 1\n", res); 00689 res = 0; 00690 } else { 00691 res = 1; 00692 } 00693 if (buttons) 00694 *buttons = atoi((char *)buf); 00695 } 00696 if (voice) { 00697 bytes = 0; 00698 bytes += ast_adsi_voice_mode(buf, 0); 00699 ast_adsi_transmit_message_full(chan, buf, bytes, ADSI_MSG_DISPLAY, 0); 00700 /* Ignore the resulting DTMF B announcing it's in voice mode */ 00701 ast_waitfordigit(chan, 1000); 00702 } 00703 return res; 00704 }
int ast_adsi_input_control | ( | unsigned char * | buf, | |
int | page, | |||
int | line, | |||
int | display, | |||
int | format, | |||
int | just | |||
) |
buf | Character buffer to create parameter in (must have at least 256 free) | |
page | Which page to input on (ADSI_COMM_PAGE or ADSI_INFO_PAGE) | |
line | Line number to input on | |
display | Set to zero to obscure input, or 1 to leave visible | |
format | Format number to use (0-7) | |
just | Justification (left, right center, indent) |
Definition at line 838 of file res_adsi.c.
References ADSI_INPUT_CONTROL.
Referenced by adsi_login(), and adsi_password().
00839 { 00840 int bytes=0; 00841 00842 if (page) { 00843 if (line > 4) return -1; 00844 } else { 00845 if (line > 33) return -1; 00846 } 00847 00848 if (line < 1) 00849 return -1; 00850 00851 buf[bytes++] = ADSI_INPUT_CONTROL; 00852 bytes++; 00853 buf[bytes++] = ((page & 1) << 7) | (line & 0x3f); 00854 buf[bytes++] = ((display & 1) << 7) | ((just & 0x3) << 4) | (format & 0x7); 00855 00856 buf[1] = bytes - 2; 00857 return bytes; 00858 00859 }
int ast_adsi_input_format | ( | unsigned char * | buf, | |
int | num, | |||
int | dir, | |||
int | wrap, | |||
char * | format1, | |||
char * | format2 | |||
) |
buf | Character buffer to create parameter in (must have at least 256 free) | |
num | Which format we are setting | |
dir | Which direction (ADSI_DIR_FROM_LEFT or ADSI_DIR_FROM_RIGHT) | |
wrap | Set to 1 to permit line wrap, or 0 if not | |
format1 | Format for column 1 | |
format2 | Format for column 2 |
Definition at line 861 of file res_adsi.c.
References ADSI_INPUT_FORMAT, and ccopy().
Referenced by adsi_login(), and adsi_password().
00862 { 00863 int bytes = 0; 00864 00865 if (!strlen((char *)format1)) 00866 return -1; 00867 00868 buf[bytes++] = ADSI_INPUT_FORMAT; 00869 bytes++; 00870 buf[bytes++] = ((dir & 1) << 7) | ((wrap & 1) << 6) | (num & 0x7); 00871 bytes += ccopy(buf + bytes, (unsigned char *)format1, 20); 00872 buf[bytes++] = 0xff; 00873 if (format2 && strlen((char *)format2)) { 00874 bytes += ccopy(buf + bytes, (unsigned char *)format2, 20); 00875 } 00876 buf[1] = bytes - 2; 00877 return bytes; 00878 }
int ast_adsi_load_session | ( | struct ast_channel * | chan, | |
unsigned char * | app, | |||
int | ver, | |||
int | data | |||
) |
chan | Channel to test for loaded app | |
app | Four character app name (must be unique to your application) | |
ver | optional version number | |
data | Non-zero if you want to be put in data mode |
Definition at line 973 of file res_adsi.c.
References ADSI_MSG_DISPLAY, ast_adsi_connect_session(), ast_adsi_data_mode(), ast_adsi_transmit_message_full(), ast_log(), ast_readstring(), LOG_DEBUG, and LOG_WARNING.
Referenced by adsi_announce_park(), adsi_begin(), adsi_load_vmail(), adsi_prog(), and cpeid_exec().
00974 { 00975 unsigned char dsp[256]; 00976 int bytes; 00977 int res; 00978 char resp[2]; 00979 00980 memset(dsp, 0, sizeof(dsp)); 00981 00982 /* Connect to session */ 00983 bytes = 0; 00984 bytes += ast_adsi_connect_session(dsp + bytes, app, ver); 00985 00986 if (data) 00987 bytes += ast_adsi_data_mode(dsp + bytes); 00988 00989 /* Prepare key setup messages */ 00990 if (ast_adsi_transmit_message_full(chan, dsp, bytes, ADSI_MSG_DISPLAY, 0)) 00991 return -1; 00992 if (app) { 00993 res = ast_readstring(chan, resp, 1, 1200, 1200, ""); 00994 if (res < 0) 00995 return -1; 00996 if (res) { 00997 ast_log(LOG_DEBUG, "No response from CPE about version. Assuming not there.\n"); 00998 return 0; 00999 } 01000 if (!strcmp(resp, "B")) { 01001 ast_log(LOG_DEBUG, "CPE has script '%s' version %d already loaded\n", app, ver); 01002 return 1; 01003 } else if (!strcmp(resp, "A")) { 01004 ast_log(LOG_DEBUG, "CPE hasn't script '%s' version %d already loaded\n", app, ver); 01005 } else { 01006 ast_log(LOG_WARNING, "Unexpected CPE response to script query: %s\n", resp); 01007 } 01008 } else 01009 return 1; 01010 return 0; 01011 01012 }
int ast_adsi_load_soft_key | ( | unsigned char * | buf, | |
int | key, | |||
const char * | llabel, | |||
const char * | slabel, | |||
const char * | ret, | |||
int | data | |||
) |
buf | Character buffer to create parameter in (must have at least 256 free) | |
key | Key code from 2 to 33, for which key we are loading | |
llabel | Long label for key (1-18 bytes) | |
slabel | Short label for key (1-7 bytes) | |
ret | Optional return sequence (NULL for none) | |
data | whether to put CPE in data mode before sending digits |
Definition at line 447 of file res_adsi.c.
References ADSI_LOAD_SOFTKEY, ADSI_SWITCH_TO_DATA2, and ccopy().
Referenced by adsi_load_vmail(), and adsi_login().
00448 { 00449 int bytes=0; 00450 00451 /* Abort if invalid key specified */ 00452 if ((key < 2) || (key > 33)) 00453 return -1; 00454 buf[bytes++] = ADSI_LOAD_SOFTKEY; 00455 /* Reserve for length */ 00456 bytes++; 00457 /* Which key */ 00458 buf[bytes++] = key; 00459 00460 /* Carefully copy long label */ 00461 bytes += ccopy(buf + bytes, (const unsigned char *)llabel, 18); 00462 00463 /* Place delimiter */ 00464 buf[bytes++] = 0xff; 00465 00466 /* Short label */ 00467 bytes += ccopy(buf + bytes, (const unsigned char *)slabel, 7); 00468 00469 00470 /* If specified, copy return string */ 00471 if (ret) { 00472 /* Place delimiter */ 00473 buf[bytes++] = 0xff; 00474 if (data) 00475 buf[bytes++] = ADSI_SWITCH_TO_DATA2; 00476 /* Carefully copy return string */ 00477 bytes += ccopy(buf + bytes, (const unsigned char *)ret, 20); 00478 00479 } 00480 /* Replace parameter length */ 00481 buf[1] = bytes - 2; 00482 return bytes; 00483 00484 }
int ast_adsi_print | ( | struct ast_channel * | chan, | |
char ** | lines, | |||
int * | align, | |||
int | voice | |||
) |
chan | Channel to display on | |
lines | NULL-terminated list of things to print (no more than 4 recommended) | |
align | list of alignments to use (ADSI_JUST_LEFT, ADSI_JUST_RIGHT, ADSI_JUST_CEN, etc..) | |
voice | whether to jump into voice mode when finished |
Definition at line 953 of file res_adsi.c.
References ADSI_INFO_PAGE, ADSI_MSG_DISPLAY, ast_adsi_display(), ast_adsi_set_line(), ast_adsi_transmit_message_full(), ast_adsi_voice_mode(), and ast_waitfordigit().
Referenced by adsi_announce_park(), and cpeid_setstatus().
00954 { 00955 unsigned char buf[4096]; 00956 int bytes=0; 00957 int res; 00958 int x; 00959 for(x=0;lines[x];x++) 00960 bytes += ast_adsi_display(buf + bytes, ADSI_INFO_PAGE, x+1, aligns[x], 0, lines[x], ""); 00961 bytes += ast_adsi_set_line(buf + bytes, ADSI_INFO_PAGE, 1); 00962 if (voice) { 00963 bytes += ast_adsi_voice_mode(buf + bytes, 0); 00964 } 00965 res = ast_adsi_transmit_message_full(chan, buf, bytes, ADSI_MSG_DISPLAY, 0); 00966 if (voice) { 00967 /* Ignore the resulting DTMF B announcing it's in voice mode */ 00968 ast_waitfordigit(chan, 1000); 00969 } 00970 return res; 00971 }
int ast_adsi_query_cpeid | ( | unsigned char * | buf | ) |
Returns number of bytes added to message
Definition at line 554 of file res_adsi.c.
References ADSI_QUERY_CPEID.
Referenced by ast_adsi_get_cpeid().
00555 { 00556 int bytes = 0; 00557 buf[bytes++] = ADSI_QUERY_CPEID; 00558 /* Reserve space for length */ 00559 bytes++; 00560 buf[1] = bytes - 2; 00561 return bytes; 00562 }
int ast_adsi_query_cpeinfo | ( | unsigned char * | buf | ) |
Definition at line 564 of file res_adsi.c.
References ADSI_QUERY_CONFIG.
Referenced by ast_adsi_get_cpeinfo().
00565 { 00566 int bytes = 0; 00567 buf[bytes++] = ADSI_QUERY_CONFIG; 00568 /* Reserve space for length */ 00569 bytes++; 00570 buf[1] = bytes - 2; 00571 return bytes; 00572 }
int ast_adsi_read_encoded_dtmf | ( | struct ast_channel * | chan, | |
unsigned char * | buf, | |||
int | maxlen | |||
) |
Returns number of bytes received
Definition at line 574 of file res_adsi.c.
References ast_waitfordigit().
Referenced by ast_adsi_get_cpeid().
00575 { 00576 int bytes = 0; 00577 int res; 00578 unsigned char current = 0; 00579 int gotstar = 0; 00580 int pos = 0; 00581 memset(buf, 0, sizeof(buf)); 00582 while(bytes <= maxlen) { 00583 /* Wait up to a second for a digit */ 00584 res = ast_waitfordigit(chan, 1000); 00585 if (!res) 00586 break; 00587 if (res == '*') { 00588 gotstar = 1; 00589 continue; 00590 } 00591 /* Ignore anything other than a digit */ 00592 if ((res < '0') || (res > '9')) 00593 continue; 00594 res -= '0'; 00595 if (gotstar) 00596 res += 9; 00597 if (pos) { 00598 pos = 0; 00599 buf[bytes++] = (res << 4) | current; 00600 } else { 00601 pos = 1; 00602 current = res; 00603 } 00604 gotstar = 0; 00605 } 00606 return bytes; 00607 }
int ast_adsi_set_keys | ( | unsigned char * | buf, | |
unsigned char * | keys | |||
) |
buf | Character buffer to create parameter in (must have at least 256 free) | |
keys | Array of 8 unsigned chars with the key numbers, may be OR'd with ADSI_KEY_HILITE But remember, the last two keys aren't real keys, they're for scrolling |
Definition at line 880 of file res_adsi.c.
References ADSI_INIT_SOFTKEY_LINE.
Referenced by adsi_folders(), adsi_login(), adsi_password(), adsi_status(), adsi_status2(), and ast_adsi_channel_restore().
00881 { 00882 int bytes=0; 00883 int x; 00884 /* Message type */ 00885 buf[bytes++] = ADSI_INIT_SOFTKEY_LINE; 00886 /* Space for size */ 00887 bytes++; 00888 /* Key definitions */ 00889 for (x=0;x<6;x++) 00890 buf[bytes++] = (keys[x] & 0x3f) ? keys[x] : (keys[x] | 0x1); 00891 buf[1] = bytes - 2; 00892 return bytes; 00893 }
int ast_adsi_set_line | ( | unsigned char * | buf, | |
int | page, | |||
int | line | |||
) |
buf | Character buffer to create parameter in (must have at least 256 free) | |
page | Which page (ADSI_COMM_PAGE or ADSI_INFO_PAGE) | |
line | Line number (1-33 for info page, 1-4 for comm page) |
Definition at line 895 of file res_adsi.c.
References ADSI_LINE_CONTROL.
Referenced by adsi_folders(), adsi_goodbye(), adsi_load_vmail(), adsi_login(), adsi_password(), adsi_status(), adsi_status2(), ast_adsi_channel_restore(), ast_adsi_print(), vm_newuser(), vm_options(), and vm_tempgreeting().
00896 { 00897 int bytes=0; 00898 00899 /* Sanity check line number */ 00900 00901 if (page) { 00902 if (line > 4) return -1; 00903 } else { 00904 if (line > 33) return -1; 00905 } 00906 00907 if (line < 1) 00908 return -1; 00909 /* Parameter type */ 00910 buf[bytes++] = ADSI_LINE_CONTROL; 00911 00912 /* Reserve space for size */ 00913 bytes++; 00914 00915 /* Page and line */ 00916 buf[bytes++] = ((page & 0x1) << 7) | (line & 0x3f); 00917 00918 buf[1] = bytes - 2; 00919 return bytes; 00920 00921 };
int ast_adsi_transmit_message | ( | struct ast_channel * | chan, | |
unsigned char * | msg, | |||
int | msglen, | |||
int | msgtype | |||
) |
Definition at line 431 of file res_adsi.c.
References ast_adsi_transmit_message_full().
Referenced by adsi_folders(), adsi_goodbye(), adsi_load_vmail(), adsi_login(), adsi_password(), adsi_prog(), adsi_status(), adsi_status2(), vm_newuser(), vm_options(), and vm_tempgreeting().
00432 { 00433 return ast_adsi_transmit_message_full(chan, msg, msglen, msgtype, 1); 00434 }
int ast_adsi_transmit_message_full | ( | struct ast_channel * | chan, | |
unsigned char * | msg, | |||
int | msglen, | |||
int | msgtype, | |||
int | dowait | |||
) |
Definition at line 357 of file res_adsi.c.
References __adsi_transmit_messages(), ADSI_FLAG_DATAMODE, ADSI_SWITCH_TO_DATA, ADSI_SWITCH_TO_VOICE, ast_channel::adsicpe, AST_FORMAT_ULAW, ast_log(), ast_safe_sleep(), ast_set_read_format(), ast_set_write_format(), ast_stopstream(), ast_waitfordigit(), LOG_DEBUG, LOG_WARNING, ast_channel::readformat, and ast_channel::writeformat.
Referenced by ast_adsi_begin_download(), ast_adsi_channel_restore(), ast_adsi_end_download(), ast_adsi_get_cpeid(), ast_adsi_get_cpeinfo(), ast_adsi_load_session(), ast_adsi_print(), ast_adsi_transmit_message(), and ast_adsi_unload_session().
00358 { 00359 unsigned char *msgs[5] = { NULL, NULL, NULL, NULL, NULL }; 00360 int msglens[5]; 00361 int msgtypes[5]; 00362 int newdatamode; 00363 int res; 00364 int x; 00365 int writeformat, readformat; 00366 int waitforswitch = 0; 00367 00368 writeformat = chan->writeformat; 00369 readformat = chan->readformat; 00370 00371 newdatamode = chan->adsicpe & ADSI_FLAG_DATAMODE; 00372 00373 for (x=0;x<msglen;x+=(msg[x+1]+2)) { 00374 if (msg[x] == ADSI_SWITCH_TO_DATA) { 00375 ast_log(LOG_DEBUG, "Switch to data is sent!\n"); 00376 waitforswitch++; 00377 newdatamode = ADSI_FLAG_DATAMODE; 00378 } 00379 00380 if (msg[x] == ADSI_SWITCH_TO_VOICE) { 00381 ast_log(LOG_DEBUG, "Switch to voice is sent!\n"); 00382 waitforswitch++; 00383 newdatamode = 0; 00384 } 00385 } 00386 msgs[0] = msg; 00387 00388 msglens[0] = msglen; 00389 msgtypes[0] = msgtype; 00390 00391 if (msglen > 253) { 00392 ast_log(LOG_WARNING, "Can't send ADSI message of %d bytes, too large\n", msglen); 00393 return -1; 00394 } 00395 00396 ast_stopstream(chan); 00397 00398 if (ast_set_write_format(chan, AST_FORMAT_ULAW)) { 00399 ast_log(LOG_WARNING, "Unable to set write format to ULAW\n"); 00400 return -1; 00401 } 00402 00403 if (ast_set_read_format(chan, AST_FORMAT_ULAW)) { 00404 ast_log(LOG_WARNING, "Unable to set read format to ULAW\n"); 00405 if (writeformat) { 00406 if (ast_set_write_format(chan, writeformat)) 00407 ast_log(LOG_WARNING, "Unable to restore write format to %d\n", writeformat); 00408 } 00409 return -1; 00410 } 00411 res = __adsi_transmit_messages(chan, msgs, msglens, msgtypes); 00412 00413 if (dowait) { 00414 ast_log(LOG_DEBUG, "Wait for switch is '%d'\n", waitforswitch); 00415 while(waitforswitch-- && ((res = ast_waitfordigit(chan, 1000)) > 0)) { res = 0; ast_log(LOG_DEBUG, "Waiting for 'B'...\n"); } 00416 } 00417 00418 if (!res) 00419 chan->adsicpe = (chan->adsicpe & ~ADSI_FLAG_DATAMODE) | newdatamode; 00420 00421 if (writeformat) 00422 ast_set_write_format(chan, writeformat); 00423 if (readformat) 00424 ast_set_read_format(chan, readformat); 00425 00426 if (!res) 00427 res = ast_safe_sleep(chan, 100 ); 00428 return res; 00429 }
int ast_adsi_unload_session | ( | struct ast_channel * | chan | ) |
Definition at line 1014 of file res_adsi.c.
References ADSI_MSG_DISPLAY, ast_adsi_disconnect_session(), ast_adsi_transmit_message_full(), and ast_adsi_voice_mode().
Referenced by ast_park_call(), cpeid_exec(), and vm_execmain().
01015 { 01016 unsigned char dsp[256]; 01017 int bytes; 01018 01019 memset(dsp, 0, sizeof(dsp)); 01020 01021 /* Connect to session */ 01022 bytes = 0; 01023 bytes += ast_adsi_disconnect_session(dsp + bytes); 01024 bytes += ast_adsi_voice_mode(dsp + bytes, 0); 01025 01026 /* Prepare key setup messages */ 01027 if (ast_adsi_transmit_message_full(chan, dsp, bytes, ADSI_MSG_DISPLAY, 0)) 01028 return -1; 01029 return 0; 01030 }
int ast_adsi_voice_mode | ( | unsigned char * | buf, | |
int | when | |||
) |
buf | Character buffer to create parameter in (must have at least 256 free) | |
when | (a time in seconds) to make the switch |
Definition at line 751 of file res_adsi.c.
References ADSI_SWITCH_TO_VOICE.
Referenced by adsi_folders(), adsi_goodbye(), adsi_load_vmail(), adsi_login(), adsi_password(), adsi_status(), adsi_status2(), ast_adsi_get_cpeid(), ast_adsi_get_cpeinfo(), ast_adsi_print(), ast_adsi_unload_session(), vm_newuser(), vm_options(), and vm_tempgreeting().
00752 { 00753 int bytes=0; 00754 00755 /* Message type */ 00756 buf[bytes++] = ADSI_SWITCH_TO_VOICE; 00757 00758 /* Reserve space for length */ 00759 bytes++; 00760 00761 buf[bytes++] = when & 0x7f; 00762 00763 buf[1] = bytes - 2; 00764 return bytes; 00765 00766 }
AST_MODULE_INFO | ( | ASTERISK_GPL_KEY | , | |
AST_MODFLAG_GLOBAL_SYMBOLS | , | |||
"ADSI Resource (not optional)" | , | |||
. | load = load_module , |
|||
. | unload = unload_module , |
|||
. | reload = reload | |||
) |
static int ccopy | ( | unsigned char * | dst, | |
const unsigned char * | src, | |||
int | max | |||
) | [inline, static] |
Definition at line 436 of file res_adsi.c.
Referenced by ast_adsi_display(), ast_adsi_download_connect(), ast_adsi_input_format(), and ast_adsi_load_soft_key().
00437 { 00438 int x=0; 00439 /* Carefully copy the requested data */ 00440 while ((x < max) && src[x] && (src[x] != 0xff)) { 00441 dst[x] = src[x]; 00442 x++; 00443 } 00444 return x; 00445 }
static void init_state | ( | void | ) | [static] |
Definition at line 1044 of file res_adsi.c.
References ADSI_JUST_CENT, and ADSI_MAX_INTRO.
Referenced by adsi_load().
01045 { 01046 int x; 01047 01048 for (x=0;x<ADSI_MAX_INTRO;x++) 01049 aligns[x] = ADSI_JUST_CENT; 01050 ast_copy_string(intro[0], "Welcome to the", sizeof(intro[0])); 01051 ast_copy_string(intro[1], "Asterisk", sizeof(intro[1])); 01052 ast_copy_string(intro[2], "Open Source PBX", sizeof(intro[2])); 01053 total = 3; 01054 speeds = 0; 01055 for (x=3;x<ADSI_MAX_INTRO;x++) 01056 intro[x][0] = '\0'; 01057 memset(speeddial, 0, sizeof(speeddial)); 01058 alignment = ADSI_JUST_CENT; 01059 }
static int load_module | ( | void | ) | [static] |
Definition at line 1113 of file res_adsi.c.
References adsi_load().
01114 { 01115 adsi_load(); 01116 return 0; 01117 }
static int reload | ( | void | ) | [static] |
Definition at line 1107 of file res_adsi.c.
References adsi_load().
01108 { 01109 adsi_load(); 01110 return 0; 01111 }
static int str2align | ( | char * | s | ) | [static] |
Definition at line 1032 of file res_adsi.c.
References ADSI_JUST_CENT, ADSI_JUST_IND, ADSI_JUST_LEFT, and ADSI_JUST_RIGHT.
Referenced by adsi_load().
01033 { 01034 if (!strncasecmp(s, "l", 1)) 01035 return ADSI_JUST_LEFT; 01036 else if (!strncasecmp(s, "r", 1)) 01037 return ADSI_JUST_RIGHT; 01038 else if (!strncasecmp(s, "i", 1)) 01039 return ADSI_JUST_IND; 01040 else 01041 return ADSI_JUST_CENT; 01042 }
static int unload_module | ( | void | ) | [static] |
int alignment = 0 [static] |
Definition at line 73 of file res_adsi.c.
int aligns[ADSI_MAX_INTRO] [static] |
Definition at line 69 of file res_adsi.c.
char intro[ADSI_MAX_INTRO][20] [static] |
Definition at line 68 of file res_adsi.c.
int maxretries = DEFAULT_ADSI_MAX_RETRIES [static] |
Definition at line 63 of file res_adsi.c.
Referenced by ast_ivr_menu_run_internal(), and privacy_exec().
char speeddial[ADSI_MAX_SPEED_DIAL][3][20] [static] |
Definition at line 71 of file res_adsi.c.
int speeds = 0 [static] |
Definition at line 924 of file res_adsi.c.
int total = 0 [static] |
Definition at line 923 of file res_adsi.c.
Referenced by ast_cdr_serialize_variables(), manager_sip_show_peers(), meetme_cmd(), pbx_builtin_serialize_variables(), and send_sound().