#include "asterisk/frame.h"
#include "asterisk/channel.h"
Include dependency graph for vmodem.h:
This graph shows which files directly or indirectly include this file:
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 aopen_read(), bestdata_read(), i4l_dialdigit(), i4l_read(), and i4l_write(). |
|
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 33 of file vmodem.h. Referenced by i4l_setdev(). |
|
Definition at line 34 of file vmodem.h. Referenced by i4l_setdev(), and modem_call(). |
|
Definition at line 39 of file vmodem.h. Referenced by i4l_answer(), i4l_dialdigit(), i4l_startrec(), and load_module(). |
|
Definition at line 40 of file vmodem.h. Referenced by i4l_dialdigit(), and load_module(). |
|
Definition at line 38 of file vmodem.h. Referenced by load_module(). |
|
|
|
|
|
Definition at line 74 of file vmodem.h. Referenced by aopen_read(), bestdata_read(), and load_module(). |
|
Definition at line 76 of file vmodem.h. Referenced by load_module(). |
|
Definition at line 75 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, and ast_modem_pvt::response. 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 }
|
|
|
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_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. 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, last, 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 }
|