2 * Asterisk -- An open source telephony toolkit.
4 * Copyright (C) 1999 - 2005, Digium, Inc.
6 * Mark Spencer <markster@digium.com>
8 * Includes code and algorithms from the Zapata library.
10 * See http://www.asterisk.org for more information about
11 * the Asterisk project. Please do not directly contact
12 * any of the maintainers of this project for assistance;
13 * the project provides a web site, mailing lists and IRC
14 * channels for your use.
16 * This program is free software, distributed under the terms of
17 * the GNU General Public License Version 2. See the LICENSE file
18 * at the top of the source tree.
25 * \author Mark Spencer <markster@digium.com>
27 * \note this module is required by app_voicemail and app_getcpeid
28 * \todo Move app_getcpeid into this module
29 * \todo Create a core layer so that app_voicemail does not require
35 ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
45 #include "asterisk/adsi.h"
46 #include "asterisk/ulaw.h"
47 #include "asterisk/alaw.h"
48 #include "asterisk/callerid.h"
49 #include "asterisk/logger.h"
50 #include "asterisk/fskmodem.h"
51 #include "asterisk/channel.h"
52 #include "asterisk/adsi.h"
53 #include "asterisk/module.h"
54 #include "asterisk/config.h"
55 #include "asterisk/file.h"
56 #include "asterisk/options.h"
58 #define DEFAULT_ADSI_MAX_RETRIES 3
60 #define ADSI_MAX_INTRO 20
61 #define ADSI_MAX_SPEED_DIAL 6
63 #define ADSI_FLAG_DATAMODE (1 << 8)
65 static int maxretries = DEFAULT_ADSI_MAX_RETRIES;
67 /* Asterisk ADSI button definitions */
68 #define ADSI_SPEED_DIAL 10 /* 10-15 are reserved for speed dial */
70 static char intro[ADSI_MAX_INTRO][20];
71 static int aligns[ADSI_MAX_INTRO];
73 static char speeddial[ADSI_MAX_SPEED_DIAL][3][20];
75 static int alignment = 0;
77 static int adsi_generate(unsigned char *buf, int msgtype, unsigned char *msg, int msglen, int msgnum, int last, int codec)
82 /* Initial carrier (imaginary) */
90 /* If first message, Send 150ms of MARK's */
92 for (x=0;x<150;x++) /* was 150 */
95 /* Put message type */
99 /* Put message length (plus one for the message number) */
100 PUT_CLID(msglen + 1);
103 /* Put message number */
107 /* Put actual message */
108 for (x=0;x<msglen;x++) {
113 /* Put 2's compliment of sum */
114 PUT_CLID(256-(sum & 0xff));
118 /* Put trailing marks */
127 static int adsi_careful_send(struct ast_channel *chan, unsigned char *buf, int len, int *remainder)
129 /* Sends carefully on a full duplex channel by using reading for
131 struct ast_frame *inf, outf;
134 /* Zero out our outgoing frame */
135 memset(&outf, 0, sizeof(outf));
137 if (remainder && *remainder) {
140 /* Send remainder if provided */
141 if (amt > *remainder)
144 *remainder = *remainder - amt;
145 outf.frametype = AST_FRAME_VOICE;
146 outf.subclass = AST_FORMAT_ULAW;
150 if (ast_write(chan, &outf)) {
151 ast_log(LOG_WARNING, "Failed to carefully write frame\n");
154 /* Update pointers and lengths */
161 /* If we don't get anything at all back in a second, forget
163 if (ast_waitfor(chan, 1000) < 1)
165 inf = ast_read(chan);
169 if (inf->frametype == AST_FRAME_VOICE) {
170 /* Read a voice frame */
171 if (inf->subclass != AST_FORMAT_ULAW) {
172 ast_log(LOG_WARNING, "Channel not in ulaw?\n");
175 /* Send no more than they sent us */
176 if (amt > inf->datalen)
179 *remainder = inf->datalen - amt;
180 outf.frametype = AST_FRAME_VOICE;
181 outf.subclass = AST_FORMAT_ULAW;
185 if (ast_write(chan, &outf)) {
186 ast_log(LOG_WARNING, "Failed to carefully write frame\n");
189 /* Update pointers and lengths */
198 static int __adsi_transmit_messages(struct ast_channel *chan, unsigned char **msg, int *msglen, int *msgtype)
200 /* msglen must be no more than 256 bits, each */
201 unsigned char buf[24000 * 5];
209 /* Wait up to 500 ms for initial ACK */
215 if (chan->adsicpe == AST_ADSI_UNAVAILABLE) {
216 /* Don't bother if we know they don't support ADSI */
221 while(retries < maxretries) {
222 if (!(chan->adsicpe & ADSI_FLAG_DATAMODE)) {
223 /* Generate CAS (no SAS) */
224 ast_gen_cas(buf, 0, 680, AST_FORMAT_ULAW);
227 if (adsi_careful_send(chan, buf, 680, NULL)) {
228 ast_log(LOG_WARNING, "Unable to send CAS\n");
230 /* Wait For DTMF result */
233 if (((res = ast_waitfor(chan, waittime)) < 1)) {
234 /* Didn't get back DTMF A in time */
236 ast_log(LOG_DEBUG, "No ADSI CPE detected (%d)\n", res);
238 chan->adsicpe = AST_ADSI_UNAVAILABLE;
246 ast_log(LOG_DEBUG, "Hangup in ADSI\n");
249 if (f->frametype == AST_FRAME_DTMF) {
250 if (f->subclass == 'A') {
251 /* Okay, this is an ADSI CPE. Note this for future reference, too */
253 chan->adsicpe = AST_ADSI_AVAILABLE;
256 if (f->subclass == 'D') {
258 ast_log(LOG_DEBUG, "Off-hook capable CPE only, not ADSI\n");
260 ast_log(LOG_WARNING, "Unknown ADSI response '%c'\n", f->subclass);
262 chan->adsicpe = AST_ADSI_UNAVAILABLE;
271 ast_log(LOG_DEBUG, "ADSI Compatible CPE Detected\n");
274 ast_log(LOG_DEBUG, "Already in data mode\n");
280 def= ast_channel_defer_dtmf(chan);
282 while((x < 6) && msg[x]) {
283 res = adsi_generate(buf + pos, msgtype[x], msg[x], msglen[x], x+1 - start, (x == 5) || !msg[x+1], AST_FORMAT_ULAW);
285 ast_log(LOG_WARNING, "Failed to generate ADSI message %d on channel %s\n", x + 1, chan->name);
289 ast_log(LOG_DEBUG, "Message %d, of %d input bytes, %d output bytes\n",
290 x + 1, msglen[x], res);
297 res = adsi_careful_send(chan, buf, pos, &rem);
299 ast_channel_undefer_dtmf(chan);
304 ast_log(LOG_DEBUG, "Sent total spill of %d bytes\n", pos);
306 memset(ack, 0, sizeof(ack));
307 /* Get real result */
308 res = ast_readstring(chan, ack, 2, 1000, 1000, "");
309 /* Check for hangup */
314 ast_log(LOG_DEBUG, "Acked up to message %d\n", atoi(ack + 1));
315 start += atoi(ack + 1);
321 ast_log(LOG_DEBUG, "Retransmitting (%d), from %d\n", retries, start + 1);
325 ast_log(LOG_WARNING, "Unexpected response to ack: %s (retry %d)\n", ack, retries);
328 if (retries >= maxretries) {
329 ast_log(LOG_WARNING, "Maximum ADSI Retries (%d) exceeded\n", maxretries);
337 static int _ast_adsi_begin_download(struct ast_channel *chan, char *service, unsigned char *fdn, unsigned char *sec, int version)
340 unsigned char buf[256];
343 /* Setup the resident soft key stuff, a piece at a time */
344 /* Upload what scripts we can for voicemail ahead of time */
345 bytes += ast_adsi_download_connect(buf + bytes, service, fdn, sec, version);
346 if (ast_adsi_transmit_message_full(chan, buf, bytes, ADSI_MSG_DOWNLOAD, 0))
348 if (ast_readstring(chan, ack, 1, 10000, 10000, ""))
353 ast_log(LOG_DEBUG, "Download was denied by CPE\n");
357 static int _ast_adsi_end_download(struct ast_channel *chan)
360 unsigned char buf[256];
362 /* Setup the resident soft key stuff, a piece at a time */
363 /* Upload what scripts we can for voicemail ahead of time */
364 bytes += ast_adsi_download_disconnect(buf + bytes);
365 if (ast_adsi_transmit_message_full(chan, buf, bytes, ADSI_MSG_DOWNLOAD, 0))
370 static int _ast_adsi_transmit_message_full(struct ast_channel *chan, unsigned char *msg, int msglen, int msgtype, int dowait)
372 unsigned char *msgs[5] = { NULL, NULL, NULL, NULL, NULL };
378 int writeformat, readformat;
379 int waitforswitch = 0;
381 writeformat = chan->writeformat;
382 readformat = chan->readformat;
384 newdatamode = chan->adsicpe & ADSI_FLAG_DATAMODE;
386 for (x=0;x<msglen;x+=(msg[x+1]+2)) {
387 if (msg[x] == ADSI_SWITCH_TO_DATA) {
389 ast_log(LOG_DEBUG, "Switch to data is sent!\n");
391 newdatamode = ADSI_FLAG_DATAMODE;
394 if (msg[x] == ADSI_SWITCH_TO_VOICE) {
396 ast_log(LOG_DEBUG, "Switch to voice is sent!\n");
404 msgtypes[0] = msgtype;
407 ast_log(LOG_WARNING, "Can't send ADSI message of %d bytes, too large\n", msglen);
411 ast_stopstream(chan);
413 if (ast_set_write_format(chan, AST_FORMAT_ULAW)) {
414 ast_log(LOG_WARNING, "Unable to set write format to ULAW\n");
418 if (ast_set_read_format(chan, AST_FORMAT_ULAW)) {
419 ast_log(LOG_WARNING, "Unable to set read format to ULAW\n");
421 if (ast_set_write_format(chan, writeformat))
422 ast_log(LOG_WARNING, "Unable to restore write format to %d\n", writeformat);
426 res = __adsi_transmit_messages(chan, msgs, msglens, msgtypes);
430 ast_log(LOG_DEBUG, "Wait for switch is '%d'\n", waitforswitch);
431 while (waitforswitch-- && ((res = ast_waitfordigit(chan, 1000)) > 0)) {
434 ast_log(LOG_DEBUG, "Waiting for 'B'...\n");
439 chan->adsicpe = (chan->adsicpe & ~ADSI_FLAG_DATAMODE) | newdatamode;
442 ast_set_write_format(chan, writeformat);
444 ast_set_read_format(chan, readformat);
447 res = ast_safe_sleep(chan, 100 );
451 static int _ast_adsi_transmit_message(struct ast_channel *chan, unsigned char *msg, int msglen, int msgtype)
453 return ast_adsi_transmit_message_full(chan, msg, msglen, msgtype, 1);
456 static inline int ccopy(unsigned char *dst, const unsigned char *src, int max)
459 /* Carefully copy the requested data */
460 while ((x < max) && src[x] && (src[x] != 0xff)) {
467 static int _ast_adsi_load_soft_key(unsigned char *buf, int key, const char *llabel, const char *slabel, char *ret, int data)
471 /* Abort if invalid key specified */
472 if ((key < 2) || (key > 33))
474 buf[bytes++] = ADSI_LOAD_SOFTKEY;
475 /* Reserve for length */
480 /* Carefully copy long label */
481 bytes += ccopy(buf + bytes, (const unsigned char *)llabel, 18);
483 /* Place delimiter */
487 bytes += ccopy(buf + bytes, (const unsigned char *)slabel, 7);
490 /* If specified, copy return string */
492 /* Place delimiter */
495 buf[bytes++] = ADSI_SWITCH_TO_DATA2;
496 /* Carefully copy return string */
497 bytes += ccopy(buf + bytes, (const unsigned char *)ret, 20);
500 /* Replace parameter length */
506 static int _ast_adsi_connect_session(unsigned char *buf, unsigned char *fdn, int ver)
512 buf[bytes++] = ADSI_CONNECT_SESSION;
514 /* Reserve space for length */
519 buf[bytes++] = fdn[x];
521 buf[bytes++] = ver & 0xff;
529 static int _ast_adsi_download_connect(unsigned char *buf, char *service, unsigned char *fdn, unsigned char *sec, int ver)
535 buf[bytes++] = ADSI_DOWNLOAD_CONNECT;
537 /* Reserve space for length */
541 bytes+= ccopy(buf + bytes, (unsigned char *)service, 18);
547 buf[bytes++] = fdn[x];
550 buf[bytes++] = sec[x];
551 buf[bytes++] = ver & 0xff;
559 static int _ast_adsi_disconnect_session(unsigned char *buf)
564 buf[bytes++] = ADSI_DISC_SESSION;
566 /* Reserve space for length */
574 static int _ast_adsi_query_cpeid(unsigned char *buf)
577 buf[bytes++] = ADSI_QUERY_CPEID;
578 /* Reserve space for length */
584 static int _ast_adsi_query_cpeinfo(unsigned char *buf)
587 buf[bytes++] = ADSI_QUERY_CONFIG;
588 /* Reserve space for length */
594 static int _ast_adsi_read_encoded_dtmf(struct ast_channel *chan, unsigned char *buf, int maxlen)
598 unsigned char current = 0;
601 memset(buf, 0, sizeof(buf));
602 while(bytes <= maxlen) {
603 /* Wait up to a second for a digit */
604 res = ast_waitfordigit(chan, 1000);
611 /* Ignore anything other than a digit */
612 if ((res < '0') || (res > '9'))
619 buf[bytes++] = (res << 4) | current;
629 static int _ast_adsi_get_cpeid(struct ast_channel *chan, unsigned char *cpeid, int voice)
631 unsigned char buf[256];
634 bytes += ast_adsi_data_mode(buf);
635 ast_adsi_transmit_message_full(chan, buf, bytes, ADSI_MSG_DISPLAY, 0);
638 bytes += ast_adsi_query_cpeid(buf);
639 ast_adsi_transmit_message_full(chan, buf, bytes, ADSI_MSG_DISPLAY, 0);
642 memset(buf, 0, sizeof(buf));
643 res = ast_adsi_read_encoded_dtmf(chan, cpeid, 4);
645 ast_log(LOG_WARNING, "Got %d bytes back of encoded DTMF, expecting 4\n", res);
653 bytes += ast_adsi_voice_mode(buf, 0);
654 ast_adsi_transmit_message_full(chan, buf, bytes, ADSI_MSG_DISPLAY, 0);
655 /* Ignore the resulting DTMF B announcing it's in voice mode */
656 ast_waitfordigit(chan, 1000);
661 static int _ast_adsi_get_cpeinfo(struct ast_channel *chan, int *width, int *height, int *buttons, int voice)
663 unsigned char buf[256];
666 bytes += ast_adsi_data_mode(buf);
667 ast_adsi_transmit_message_full(chan, buf, bytes, ADSI_MSG_DISPLAY, 0);
670 bytes += ast_adsi_query_cpeinfo(buf);
671 ast_adsi_transmit_message_full(chan, buf, bytes, ADSI_MSG_DISPLAY, 0);
674 memset(buf, 0, sizeof(buf));
675 res = ast_readstring(chan, (char *)buf, 2, 1000, 500, "");
678 if (strlen((char *)buf) != 2) {
679 ast_log(LOG_WARNING, "Got %d bytes of width, expecting 2\n", res);
685 *width = atoi((char *)buf);
687 memset(buf, 0, sizeof(buf));
689 res = ast_readstring(chan, (char *)buf, 2, 1000, 500, "");
692 if (strlen((char *)buf) != 2) {
693 ast_log(LOG_WARNING, "Got %d bytes of height, expecting 2\n", res);
699 *height= atoi((char *)buf);
702 memset(buf, 0, sizeof(buf));
704 res = ast_readstring(chan, (char *)buf, 1, 1000, 500, "");
707 if (strlen((char *)buf) != 1) {
708 ast_log(LOG_WARNING, "Got %d bytes of buttons, expecting 1\n", res);
714 *buttons = atoi((char *)buf);
718 bytes += ast_adsi_voice_mode(buf, 0);
719 ast_adsi_transmit_message_full(chan, buf, bytes, ADSI_MSG_DISPLAY, 0);
720 /* Ignore the resulting DTMF B announcing it's in voice mode */
721 ast_waitfordigit(chan, 1000);
726 static int _ast_adsi_data_mode(unsigned char *buf)
731 buf[bytes++] = ADSI_SWITCH_TO_DATA;
733 /* Reserve space for length */
741 static int _ast_adsi_clear_soft_keys(unsigned char *buf)
746 buf[bytes++] = ADSI_CLEAR_SOFTKEY;
748 /* Reserve space for length */
756 static int _ast_adsi_clear_screen(unsigned char *buf)
761 buf[bytes++] = ADSI_CLEAR_SCREEN;
763 /* Reserve space for length */
771 static int _ast_adsi_voice_mode(unsigned char *buf, int when)
776 buf[bytes++] = ADSI_SWITCH_TO_VOICE;
778 /* Reserve space for length */
781 buf[bytes++] = when & 0x7f;
788 static int _ast_adsi_available(struct ast_channel *chan)
790 int cpe = chan->adsicpe & 0xff;
791 if ((cpe == AST_ADSI_AVAILABLE) ||
792 (cpe == AST_ADSI_UNKNOWN))
797 static int _ast_adsi_download_disconnect(unsigned char *buf)
802 buf[bytes++] = ADSI_DOWNLOAD_DISC;
804 /* Reserve space for length */
812 static int _ast_adsi_display(unsigned char *buf, int page, int line, int just, int wrap,
813 char *col1, char *col2)
817 /* Sanity check line number */
820 if (line > 4) return -1;
822 if (line > 33) return -1;
828 buf[bytes++] = ADSI_LOAD_VIRTUAL_DISP;
830 /* Reserve space for size */
833 /* Page and wrap indicator */
834 buf[bytes++] = ((page & 0x1) << 7) | ((wrap & 0x1) << 6) | (line & 0x3f);
837 buf[bytes++] = (just & 0x3) << 5;
839 /* Omit highlight mode definition */
843 bytes+= ccopy(buf + bytes, (unsigned char *)col1, 20);
848 /* Secondary column */
849 bytes += ccopy(buf + bytes, (unsigned char *)col2, 20);
858 static int _ast_adsi_input_control(unsigned char *buf, int page, int line, int display, int format, int just)
863 if (line > 4) return -1;
865 if (line > 33) return -1;
871 buf[bytes++] = ADSI_INPUT_CONTROL;
873 buf[bytes++] = ((page & 1) << 7) | (line & 0x3f);
874 buf[bytes++] = ((display & 1) << 7) | ((just & 0x3) << 4) | (format & 0x7);
881 static int _ast_adsi_input_format(unsigned char *buf, int num, int dir, int wrap, char *format1, char *format2)
885 if (!strlen((char *)format1))
888 buf[bytes++] = ADSI_INPUT_FORMAT;
890 buf[bytes++] = ((dir & 1) << 7) | ((wrap & 1) << 6) | (num & 0x7);
891 bytes += ccopy(buf + bytes, (unsigned char *)format1, 20);
893 if (format2 && strlen((char *)format2)) {
894 bytes += ccopy(buf + bytes, (unsigned char *)format2, 20);
900 static int _ast_adsi_set_keys(unsigned char *buf, unsigned char *keys)
905 buf[bytes++] = ADSI_INIT_SOFTKEY_LINE;
908 /* Key definitions */
910 buf[bytes++] = (keys[x] & 0x3f) ? keys[x] : (keys[x] | 0x1);
915 static int _ast_adsi_set_line(unsigned char *buf, int page, int line)
919 /* Sanity check line number */
922 if (line > 4) return -1;
924 if (line > 33) return -1;
930 buf[bytes++] = ADSI_LINE_CONTROL;
932 /* Reserve space for size */
936 buf[bytes++] = ((page & 0x1) << 7) | (line & 0x3f);
943 static int total = 0;
944 static int speeds = 0;
946 static int _ast_adsi_channel_restore(struct ast_channel *chan)
948 unsigned char dsp[256];
951 unsigned char keyd[6];
953 memset(dsp, 0, sizeof(dsp));
955 /* Start with initial display setup */
957 bytes += ast_adsi_set_line(dsp + bytes, ADSI_INFO_PAGE, 1);
959 /* Prepare key setup messages */
962 memset(keyd, 0, sizeof(keyd));
963 for (x=0;x<speeds;x++) {
964 keyd[x] = ADSI_SPEED_DIAL + x;
966 bytes += ast_adsi_set_keys(dsp + bytes, keyd);
968 ast_adsi_transmit_message_full(chan, dsp, bytes, ADSI_MSG_DISPLAY, 0);
973 static int _ast_adsi_print(struct ast_channel *chan, char **lines, int *aligns, int voice)
975 unsigned char buf[4096];
979 for(x=0;lines[x];x++)
980 bytes += ast_adsi_display(buf + bytes, ADSI_INFO_PAGE, x+1, aligns[x], 0, lines[x], "");
981 bytes += ast_adsi_set_line(buf + bytes, ADSI_INFO_PAGE, 1);
983 bytes += ast_adsi_voice_mode(buf + bytes, 0);
985 res = ast_adsi_transmit_message_full(chan, buf, bytes, ADSI_MSG_DISPLAY, 0);
987 /* Ignore the resulting DTMF B announcing it's in voice mode */
988 ast_waitfordigit(chan, 1000);
993 static int _ast_adsi_load_session(struct ast_channel *chan, unsigned char *app, int ver, int data)
995 unsigned char dsp[256];
1000 memset(dsp, 0, sizeof(dsp));
1002 /* Connect to session */
1004 bytes += ast_adsi_connect_session(dsp + bytes, app, ver);
1007 bytes += ast_adsi_data_mode(dsp + bytes);
1009 /* Prepare key setup messages */
1010 if (ast_adsi_transmit_message_full(chan, dsp, bytes, ADSI_MSG_DISPLAY, 0))
1013 res = ast_readstring(chan, resp, 1, 1200, 1200, "");
1018 ast_log(LOG_DEBUG, "No response from CPE about version. Assuming not there.\n");
1021 if (!strcmp(resp, "B")) {
1023 ast_log(LOG_DEBUG, "CPE has script '%s' version %d already loaded\n", app, ver);
1025 } else if (!strcmp(resp, "A")) {
1027 ast_log(LOG_DEBUG, "CPE hasn't script '%s' version %d already loaded\n", app, ver);
1029 ast_log(LOG_WARNING, "Unexpected CPE response to script query: %s\n", resp);
1037 static int _ast_adsi_unload_session(struct ast_channel *chan)
1039 unsigned char dsp[256];
1042 memset(dsp, 0, sizeof(dsp));
1044 /* Connect to session */
1046 bytes += ast_adsi_disconnect_session(dsp + bytes);
1047 bytes += ast_adsi_voice_mode(dsp + bytes, 0);
1049 /* Prepare key setup messages */
1050 if (ast_adsi_transmit_message_full(chan, dsp, bytes, ADSI_MSG_DISPLAY, 0))
1055 static int str2align(char *s)
1057 if (!strncasecmp(s, "l", 1))
1058 return ADSI_JUST_LEFT;
1059 else if (!strncasecmp(s, "r", 1))
1060 return ADSI_JUST_RIGHT;
1061 else if (!strncasecmp(s, "i", 1))
1062 return ADSI_JUST_IND;
1064 return ADSI_JUST_CENT;
1067 static void init_state(void)
1071 for (x=0;x<ADSI_MAX_INTRO;x++)
1072 aligns[x] = ADSI_JUST_CENT;
1073 ast_copy_string(intro[0], "Welcome to the", sizeof(intro[0]));
1074 ast_copy_string(intro[1], "Asterisk", sizeof(intro[1]));
1075 ast_copy_string(intro[2], "Open Source PBX", sizeof(intro[2]));
1078 for (x=3;x<ADSI_MAX_INTRO;x++)
1080 memset(speeddial, 0, sizeof(speeddial));
1081 alignment = ADSI_JUST_CENT;
1084 static void adsi_load(void)
1087 struct ast_config *conf;
1088 struct ast_variable *v;
1091 conf = ast_config_load("adsi.conf");
1094 for (v = ast_variable_browse(conf, "intro"); v; v = v->next) {
1095 if (!strcasecmp(v->name, "alignment"))
1096 alignment = str2align(v->value);
1097 else if (!strcasecmp(v->name, "greeting")) {
1098 if (x < ADSI_MAX_INTRO) {
1099 aligns[x] = alignment;
1100 ast_copy_string(intro[x], v->value, sizeof(intro[x]));
1103 } else if (!strcasecmp(v->name, "maxretries")) {
1104 if (atoi(v->value) > 0)
1105 maxretries = atoi(v->value);
1111 for (v = ast_variable_browse(conf, "speeddial"); v; v = v->next) {
1112 char *stringp = v->value;
1113 name = strsep(&stringp, ",");
1114 sname = strsep(&stringp, ",");
1117 if (x < ADSI_MAX_SPEED_DIAL) {
1118 ast_copy_string(speeddial[x][0], v->name, sizeof(speeddial[x][0]));
1119 ast_copy_string(speeddial[x][1], name, 18);
1120 ast_copy_string(speeddial[x][2], sname, 7);
1126 ast_config_destroy(conf);
1130 static int reload(void)
1136 static int load_module(void)
1140 ast_adsi_begin_download = _ast_adsi_begin_download;
1141 ast_adsi_end_download = _ast_adsi_end_download;
1142 ast_adsi_channel_restore = _ast_adsi_channel_restore;
1143 ast_adsi_print = _ast_adsi_print;
1144 ast_adsi_load_session = _ast_adsi_load_session;
1145 ast_adsi_unload_session = _ast_adsi_unload_session;
1146 ast_adsi_transmit_message = _ast_adsi_transmit_message;
1147 ast_adsi_transmit_message_full = _ast_adsi_transmit_message_full;
1148 ast_adsi_read_encoded_dtmf = _ast_adsi_read_encoded_dtmf;
1149 ast_adsi_connect_session = _ast_adsi_connect_session;
1150 ast_adsi_query_cpeid = _ast_adsi_query_cpeid;
1151 ast_adsi_query_cpeinfo = _ast_adsi_query_cpeinfo;
1152 ast_adsi_get_cpeid = _ast_adsi_get_cpeid;
1153 ast_adsi_get_cpeinfo = _ast_adsi_get_cpeinfo;
1154 ast_adsi_download_connect = _ast_adsi_download_connect;
1155 ast_adsi_disconnect_session = _ast_adsi_disconnect_session;
1156 ast_adsi_download_disconnect = _ast_adsi_download_disconnect;
1157 ast_adsi_data_mode = _ast_adsi_data_mode;
1158 ast_adsi_clear_soft_keys = _ast_adsi_clear_soft_keys;
1159 ast_adsi_clear_screen = _ast_adsi_clear_screen;
1160 ast_adsi_voice_mode = _ast_adsi_voice_mode;
1161 ast_adsi_available = _ast_adsi_available;
1162 ast_adsi_display = _ast_adsi_display;
1163 ast_adsi_set_line = _ast_adsi_set_line;
1164 ast_adsi_load_soft_key = _ast_adsi_load_soft_key;
1165 ast_adsi_set_keys = _ast_adsi_set_keys;
1166 ast_adsi_input_control = _ast_adsi_input_control;
1167 ast_adsi_input_format = _ast_adsi_input_format;
1172 static int unload_module(void)
1174 /* Can't unload this once we're loaded */
1178 AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_GLOBAL_SYMBOLS, "ADSI Resource",
1179 .load = load_module,
1180 .unload = unload_module,