diff options
author | markster <markster@f38db490-d61c-443f-a65b-d21fe96a405b> | 2000-12-29 14:05:23 +0000 |
---|---|---|
committer | markster <markster@f38db490-d61c-443f-a65b-d21fe96a405b> | 2000-12-29 14:05:23 +0000 |
commit | fd09b39336da4d0d8b0dcd047b9689aeff5283b6 (patch) | |
tree | cb90395358442f4033d04d57a54a1e30d912134c | |
parent | 8011b6fef5ecc306c25468f52e4526b3c7380352 (diff) |
Version 0.1.6 from FTP
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@228 f38db490-d61c-443f-a65b-d21fe96a405b
-rwxr-xr-x | channels/chan_modem.c | 37 | ||||
-rwxr-xr-x | include/asterisk/vmodem.h | 4 |
2 files changed, 36 insertions, 5 deletions
diff --git a/channels/chan_modem.c b/channels/chan_modem.c index 052091ecb..fc45194d3 100755 --- a/channels/chan_modem.c +++ b/channels/chan_modem.c @@ -55,6 +55,9 @@ static char language[MAX_LANGUAGE] = ""; /* Initialization String */ static char initstr[AST_MAX_INIT_STR] = "ATE1Q0"; +/* Default MSN */ +static char msn[AST_MAX_EXTENSION]=""; + static int usecnt =0; static int baudrate = 115200; @@ -348,7 +351,8 @@ static int modem_setup(struct ast_modem_pvt *p, int baudrate) static int modem_hangup(struct ast_channel *ast) { struct ast_modem_pvt *p; - ast_log(LOG_DEBUG, "modem_hangup(%s)\n", ast->name); + if (option_debug) + ast_log(LOG_DEBUG, "modem_hangup(%s)\n", ast->name); p = ast->pvt->pvt; /* Hang up */ if (p->mc->hangup) @@ -377,7 +381,8 @@ static int modem_answer(struct ast_channel *ast) { struct ast_modem_pvt *p; int res=0; - ast_log(LOG_DEBUG, "modem_hangup(%s)\n", ast->name); + if (option_debug) + ast_log(LOG_DEBUG, "modem_answer(%s)\n", ast->name); p = ast->pvt->pvt; if (p->mc->answer) { res = p->mc->answer(p); @@ -467,7 +472,6 @@ static void modem_mini_packet(struct ast_modem_pvt *i) if (fr->frametype == AST_FRAME_CONTROL) { if (fr->subclass == AST_CONTROL_RING) { ast_modem_new(i, AST_STATE_RING); - restart_monitor(); } } } @@ -590,6 +594,21 @@ static int restart_monitor() return 0; } +static void stty(struct ast_modem_pvt *p) +{ + struct termios mode; + memset(&mode, 0, sizeof(mode)); + if (tcgetattr(p->fd, &mode)) { + ast_log(LOG_WARNING, "Unable to get serial parameters on %s: %s\n", p->dev, strerror(errno)); + return; + } + cfmakeraw(&mode); + cfsetspeed(&mode, B115200); + if (tcsetattr(p->fd, TCSANOW, &mode)) + ast_log(LOG_WARNING, "Unable to set serial parameters on %s: %s\n", p->dev, strerror(errno)); + +} + static struct ast_modem_pvt *mkif(char *iface) { /* Make a ast_modem_pvt structure for this interface */ @@ -599,6 +618,7 @@ static struct ast_modem_pvt *mkif(char *iface) #endif tmp = malloc(sizeof(struct ast_modem_pvt)); + memset(tmp, 0, sizeof(struct ast_modem_pvt)); if (tmp) { tmp->fd = open(iface, O_RDWR | O_NONBLOCK); if (tmp->fd < 0) { @@ -607,6 +627,11 @@ static struct ast_modem_pvt *mkif(char *iface) return NULL; } strncpy(tmp->language, language, sizeof(tmp->language)); + strncpy(tmp->msn, msn, sizeof(tmp->msn)); + strncpy(tmp->dev, iface, sizeof(tmp->dev)); + /* Maybe in the future we want to allow variable + serial settings */ + stty(tmp); tmp->f = fdopen(tmp->fd, "w+"); /* Disable buffering */ setvbuf(tmp->f, NULL, _IONBF,0); @@ -625,7 +650,6 @@ static struct ast_modem_pvt *mkif(char *iface) tmp->dialtype = dialtype; tmp->mode = gmode; memset(tmp->cid, 0, sizeof(tmp->cid)); - strncpy(tmp->dev, iface, sizeof(tmp->dev)); strncpy(tmp->context, context, sizeof(tmp->context)); strncpy(tmp->initstr, initstr, sizeof(tmp->initstr)); tmp->next = NULL; @@ -743,13 +767,16 @@ int load_module() dialtype = toupper(v->value[0]); } else if (!strcasecmp(v->name, "context")) { strncpy(context, v->value, sizeof(context)); + } else if (!strcasecmp(v->name, "msn")) { + strncpy(msn, v->value, sizeof(msn)); } else if (!strcasecmp(v->name, "language")) { strncpy(language, v->value, sizeof(language)); } v = v->next; } pthread_mutex_unlock(&iflock); - if (ast_channel_register(type, tdesc, /* XXX Don't know our types -- maybe we should register more than one XXX */ AST_FORMAT_SLINEAR, modem_request)) { + if (ast_channel_register(type, tdesc, /* XXX Don't know our types -- maybe we should register more than one XXX */ + AST_FORMAT_SLINEAR, modem_request)) { ast_log(LOG_ERROR, "Unable to register channel class %s\n", type); ast_destroy(cfg); unload_module(); diff --git a/include/asterisk/vmodem.h b/include/asterisk/vmodem.h index 920bd417d..8dd91486e 100755 --- a/include/asterisk/vmodem.h +++ b/include/asterisk/vmodem.h @@ -19,6 +19,7 @@ #define CHAR_DLE 0x10 #define CHAR_ETX 0x03 +#define CHAR_DC4 0x14 #define MODEM_DEV_TELCO 0 #define MODEM_DEV_TELCO_SPK 4 @@ -76,8 +77,11 @@ struct ast_modem_pvt { int mode; /* Immediate, or wait for an answer */ int ministate; /* State of modem in miniature */ int stripmsd; /* Digits to strip on outgoing numbers */ + int escape; /* Is the last thing we saw an escape */ char context[AST_MAX_EXTENSION]; + char msn[AST_MAX_EXTENSION]; /* Multiple Subscriber Number */ char cid[AST_MAX_EXTENSION]; /* Caller ID if available */ + char dnid[AST_MAX_EXTENSION]; /* Dialed Number if available */ char initstr[AST_MAX_INIT_STR]; /* Modem initialization String */ char language[MAX_LANGUAGE]; /* default language */ char response[256]; /* Static response buffer */ |