#include "asterisk/frame.h"
#include "asterisk/channel.h"
Go to the source code of this file.
Data Structures | |
| struct | ast_modem_driver |
| struct | ast_modem_pvt |
Defines | |
| #define | AST_MAX_INIT_STR 256 |
| #define | CHAR_DC4 0x14 |
| #define | CHAR_DLE 0x10 |
| #define | CHAR_ETX 0x03 |
| #define | MODEM_DEV_HANDSET 9 |
| #define | MODEM_DEV_SPKRPHONE 6 |
| #define | MODEM_DEV_TELCO 0 |
| #define | MODEM_DEV_TELCO_SPK 4 |
| #define | MODEM_DTMF_AST (1 << 1) |
| #define | MODEM_DTMF_I4L (1 << 2) |
| #define | MODEM_DTMF_NONE (1 << 0) |
| #define | MODEM_MAX_BUF MODEM_MAX_LEN * 16 |
| #define | MODEM_MAX_LEN 30 |
| #define | MODEM_MODE_IMMEDIATE 0 |
| #define | MODEM_MODE_WAIT_ANSWER 2 |
| #define | MODEM_MODE_WAIT_RING 1 |
Functions | |
| int | ast_modem_expect (struct ast_modem_pvt *p, char *result, int timeout) |
| ast_channel * | ast_modem_new (struct ast_modem_pvt *i, int state) |
| int | ast_modem_read_response (struct ast_modem_pvt *p, int timeout) |
| int | ast_modem_send (struct ast_modem_pvt *p, char *cmd, int len) |
| void | ast_modem_trim (char *s) |
| int | ast_register_modem_driver (struct ast_modem_driver *mc) |
| int | ast_unregister_modem_driver (struct ast_modem_driver *mc) |
Definition in file vmodem.h.
|
|
|
|
|
|
|
|
Definition at line 29 of file vmodem.h. Referenced by i4l_read(). |
|
|
Definition at line 30 of file vmodem.h. Referenced by aopen_handle_escape(), bestdata_handle_escape(), and i4l_handle_escape(). |
|
|
Definition at line 36 of file vmodem.h. Referenced by modem_call(). |
|
|
|
|
|
|
|
|
Definition at line 34 of file vmodem.h. Referenced by modem_call(). |
|
|
|
|
|
Definition at line 40 of file vmodem.h. Referenced by load_module(). |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
||||||||||||||||
|
Wait for result to occur. Return non-zero if times out or error, last response is stored in p->response Definition at line 345 of file chan_modem.c. References ast_waitfor_n_fd(), ast_modem_pvt::f, ast_modem_pvt::fd, ast_modem_pvt::response, and result. Referenced by aopen_answer(), aopen_break(), aopen_dialdigit(), aopen_hangup(), aopen_identify(), aopen_init(), aopen_setdev(), aopen_startrec(), bestdata_answer(), bestdata_break(), bestdata_dialdigit(), bestdata_hangup(), bestdata_identify(), bestdata_init(), bestdata_startplay(), bestdata_startrec(), i4l_answer(), i4l_break(), i4l_hangup(), i4l_init(), i4l_setdev(), i4l_startrec(), and modem_setup(). 00346 {
00347 int res = -1;
00348 timeout *= 1000;
00349 strncpy(p->response, "(No Response)", sizeof(p->response)-1);
00350 do {
00351 res = ast_waitfor_n_fd(&p->fd, 1, &timeout, NULL);
00352 if (res < 0) {
00353 return -1;
00354 }
00355 /* Read a response */
00356 fgets(p->response, sizeof(p->response), p->f);
00357 #if 0
00358 fprintf(stderr, "Modem said: %s", p->response);
00359 #endif
00360 if (!strncasecmp(p->response, result, strlen(result)))
00361 return 0;
00362 } while(timeout > 0);
00363 return -1;
00364 }
|
|
||||||||||||
|
Used by modem drivers to start up the PBX on a RING Definition at line 563 of file chan_modem.c. References ast_channel_alloc(), ast_hangup(), ast_log(), ast_mutex_lock(), ast_mutex_unlock(), ast_pbx_start(), ast_setstate(), ast_strlen_zero(), ast_update_use_count(), ast_channel::cid, ast_modem_pvt::cid_name, ast_callerid::cid_name, ast_modem_pvt::cid_num, ast_callerid::cid_num, ast_channel::context, ast_modem_pvt::context, ast_modem_pvt::dev, ast_modem_pvt::dnid, ast_channel::exten, ast_modem_pvt::fd, ast_channel::fds, ast_modem_driver::formats, ast_modem_pvt::language, ast_channel::language, LOG_WARNING, ast_modem_pvt::mc, ast_channel::name, ast_modem_driver::name, ast_channel::nativeformats, ast_modem_pvt::owner, ast_channel::rings, strdup, ast_channel::tech, ast_channel::tech_pvt, ast_channel::type, and usecnt. Referenced by modem_mini_packet(), and modem_request(). 00564 {
00565 struct ast_channel *tmp;
00566 tmp = ast_channel_alloc(1);
00567 if (tmp) {
00568 tmp->tech = &modem_tech;
00569 snprintf(tmp->name, sizeof(tmp->name), "Modem[%s]/%s", i->mc->name, i->dev + 5);
00570 tmp->type = type;
00571 tmp->fds[0] = i->fd;
00572 tmp->nativeformats = i->mc->formats;
00573 ast_setstate(tmp, state);
00574 if (state == AST_STATE_RING)
00575 tmp->rings = 1;
00576 tmp->tech_pvt = i;
00577 strncpy(tmp->context, i->context, sizeof(tmp->context)-1);
00578
00579 if (!ast_strlen_zero(i->cid_num))
00580 tmp->cid.cid_num = strdup(i->cid_num);
00581 if (!ast_strlen_zero(i->cid_name))
00582 tmp->cid.cid_name = strdup(i->cid_name);
00583
00584 if (!ast_strlen_zero(i->language))
00585 strncpy(tmp->language,i->language, sizeof(tmp->language)-1);
00586 if (!ast_strlen_zero(i->dnid))
00587 strncpy(tmp->exten, i->dnid, sizeof(tmp->exten) - 1);
00588 i->owner = tmp;
00589 ast_mutex_lock(&usecnt_lock);
00590 usecnt++;
00591 ast_mutex_unlock(&usecnt_lock);
00592 ast_update_use_count();
00593 if (state != AST_STATE_DOWN) {
00594 if (ast_pbx_start(tmp)) {
00595 ast_log(LOG_WARNING, "Unable to start PBX on %s\n", tmp->name);
00596 ast_hangup(tmp);
00597 tmp = NULL;
00598 }
00599 }
00600 } else
00601 ast_log(LOG_WARNING, "Unable to allocate channel structure\n");
00602 return tmp;
00603 }
|
|
||||||||||||
|
Wait for result to occur. response is stored in p->response Definition at line 296 of file chan_modem.c. References ast_waitfor_n_fd(), ast_modem_pvt::f, ast_modem_pvt::fd, and ast_modem_pvt::response. Referenced by aopen_break(), aopen_identify(), aopen_setdev(), bestdata_break(), bestdata_handle_escape(), bestdata_identify(), i4l_break(), i4l_setdev(), and modem_setup(). 00297 {
00298 int res = -1,c,i;
00299 timeout *= 1000;
00300 p->response[0] = 0;
00301 c = i = 0;
00302 do {
00303 res = ast_waitfor_n_fd(&p->fd, 1, &timeout, NULL);
00304 if (res < 0) {
00305 strncpy(p->response, "(No Response)", sizeof(p->response)-1);
00306 return -1;
00307 }
00308 /* get no more then buffer length */
00309 while(i < sizeof(p->response) - 1)
00310 {
00311 c = fgetc(p->f); /* get a char */
00312 if (c < 1) /* if error */
00313 {
00314 /* if nothing in buffer, go back into timeout stuff */
00315 if (errno == EWOULDBLOCK) break;
00316 /* return as error */
00317 strncpy(p->response, "(No Response)", sizeof(p->response)-1);
00318 return -1;
00319 }
00320 /* save char */
00321 p->response[i++] = c;
00322 p->response[i] = 0;
00323 /* if end of input */
00324 if (c == '\n') break;
00325 }
00326 if (c >= 0) /* if input terminated normally */
00327 {
00328 /* ignore just CR/LF */
00329 if (!strcmp(p->response,"\r\n"))
00330 {
00331 /* reset input buffer stuff */
00332 i = 0;
00333 p->response[0] = 0;
00334 }
00335 else /* otherwise return with info in buffer */
00336 {
00337 return 0;
00338 }
00339 }
00340 } while(timeout > 0);
00341 strncpy(p->response, "(No Response)", sizeof(p->response)-1);
00342 return -1;
00343 }
|
|
||||||||||||||||
|
Send the command cmd (length len, or 0 if pure ascii) on modem Definition at line 272 of file chan_modem.c. References ast_modem_pvt::f. Referenced by aopen_answer(), aopen_break(), aopen_dial(), aopen_dialdigit(), aopen_handle_escape(), aopen_hangup(), aopen_identify(), aopen_init(), aopen_setdev(), aopen_startrec(), bestdata_answer(), bestdata_break(), bestdata_dial(), bestdata_dialdigit(), bestdata_handle_escape(), bestdata_hangup(), bestdata_identify(), bestdata_init(), bestdata_startplay(), bestdata_startrec(), i4l_answer(), i4l_break(), i4l_dial(), i4l_handle_escape(), i4l_hangup(), i4l_init(), i4l_setdev(), i4l_startrec(), and modem_setup(). 00273 {
00274 int i;
00275 usleep(5000);
00276 if (!len) {
00277 for(i = 0; cmd[i];)
00278 {
00279 if (fwrite(cmd + i,1,1,p->f) != 1)
00280 {
00281 if (errno == EWOULDBLOCK) continue;
00282 return -1;
00283 }
00284 i++;
00285 }
00286 tcdrain(fileno(p->f));
00287 fprintf(p->f,"\r\n");
00288 return 0;
00289 } else {
00290 if (fwrite(cmd, 1, len, p->f) < len)
00291 return -1;
00292 return 0;
00293 }
00294 }
|
|
|
Trim off trailing mess Definition at line 366 of file chan_modem.c. References s. Referenced by aopen_identify(), aopen_read(), aopen_setdev(), bestdata_handle_escape(), bestdata_identify(), bestdata_read(), i4l_read(), i4l_setdev(), and modem_setup(). 00367 {
00368 int x;
00369 x = strlen(s) - 1;
00370 while(x >= 0) {
00371 if ((s[x] != '\r') && (s[x] != '\n') && (s[x] != ' '))
00372 break;
00373 s[x] = '\0';
00374 x--;
00375 }
00376 }
|
|
|
Register a driver Definition at line 194 of file chan_modem.c. References drivers, and ast_modem_driver::next. Referenced by load_module().
|
|
|
Unregister a driver Definition at line 201 of file chan_modem.c. References drivers, and ast_modem_driver::next. Referenced by unload_module(). 00202 {
00203 struct ast_modem_driver *last = NULL, *cur;
00204 cur = drivers;
00205 while(cur) {
00206 if (cur == mc) {
00207 if (last)
00208 last->next = mc->next;
00209 else
00210 drivers = mc->next;
00211 return 0;
00212 }
00213 cur = cur->next;
00214 }
00215 return -1;
00216 }
|
1.3.9.1