Version 0.1.3 from FTP

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@207 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
Mark Spencer
2000-03-26 01:59:06 +00:00
parent c44f9f168a
commit 5e0525cc65
7 changed files with 365 additions and 12 deletions

View File

@@ -125,6 +125,7 @@ struct iax_peer {
char username[80];
char secret[80];
struct sockaddr_in addr;
int formats;
struct in_addr mask;
struct iax_peer *next;
};
@@ -668,8 +669,8 @@ static int attempt_transmit(void *data)
/* Attempt transmission */
send_packet(f);
f->retries++;
/* Try again later after 2 times as long */
f->retrytime *= 2;
/* Try again later after 10 times as long */
f->retrytime *= 10;
if (f->retrytime > MAX_RETRY_TIME)
f->retrytime = MAX_RETRY_TIME;
ast_sched_add(sched, f->retrytime, attempt_transmit, f);
@@ -854,6 +855,13 @@ static int iax_digit(struct ast_channel *c, char digit)
return send_command(c->pvt->pvt, AST_FRAME_DTMF, digit, 0, NULL, 0, -1);
}
static int iax_sendtext(struct ast_channel *c, char *text)
{
return send_command(c->pvt->pvt, AST_FRAME_TEXT,
0, 0, text, strlen(text) + 1, -1);
}
static int create_addr(struct sockaddr_in *sin, char *peer)
{
struct hostent *hp;
@@ -1023,6 +1031,7 @@ static struct ast_channel *ast_iax_new(struct chan_iax_pvt *i, int state)
tmp->format = iax_capability;
tmp->pvt->pvt = i;
tmp->pvt->send_digit = iax_digit;
tmp->pvt->send_text = iax_sendtext;
tmp->pvt->call = iax_call;
tmp->pvt->hangup = iax_hangup;
tmp->pvt->answer = iax_answer;

View File

@@ -57,6 +57,7 @@ static int silencesuppression = 0;
static int silencethreshold = 1000;
static char digits[80] = "";
static char text2send[80] = "";
static pthread_mutex_t usecnt_lock = PTHREAD_MUTEX_INITIALIZER;
@@ -66,6 +67,7 @@ static char *tdesc = "OSS Console Channel Driver";
static char *config = "oss.conf";
static char context[AST_MAX_EXTENSION] = "default";
static char language[MAX_LANGUAGE] = "";
static char exten[AST_MAX_EXTENSION] = "s";
/* Some pipes to prevent overflow */
@@ -341,6 +343,12 @@ static int oss_digit(struct ast_channel *c, char digit)
return 0;
}
static int oss_text(struct ast_channel *c, char *text)
{
ast_verbose( " << Console Received text %s >> \n", text);
return 0;
}
static int oss_call(struct ast_channel *c, char *dest, int timeout)
{
ast_verbose( " << Call placed to '%s' on console >> \n", dest);
@@ -477,6 +485,14 @@ static struct ast_frame *oss_read(struct ast_channel *chan)
if (needhangup) {
return NULL;
}
if (strlen(text2send)) {
f.frametype = AST_FRAME_TEXT;
f.subclass = 0;
f.data = text2send;
f.datalen = strlen(text2send);
strcpy(text2send,"");
return &f;
}
if (strlen(digits)) {
f.frametype = AST_FRAME_DTMF;
f.subclass = digits[0];
@@ -535,14 +551,18 @@ static struct ast_channel *oss_new(struct chan_oss_pvt *p, int state)
tmp->format = AST_FORMAT_SLINEAR;
tmp->pvt->pvt = p;
tmp->pvt->send_digit = oss_digit;
tmp->pvt->send_text = oss_text;
tmp->pvt->hangup = oss_hangup;
tmp->pvt->answer = oss_answer;
tmp->pvt->read = oss_read;
tmp->pvt->call = oss_call;
tmp->pvt->write = oss_write;
if (strlen(p->context))
strncpy(tmp->context, p->context, sizeof(tmp->context));
if (strlen(p->exten))
strncpy(tmp->exten, p->exten, sizeof(tmp->exten));
if (strlen(language))
strncpy(tmp->language, language, sizeof(tmp->language));
p->owner = tmp;
tmp->state = state;
pthread_mutex_lock(&usecnt_lock);
@@ -563,6 +583,7 @@ static struct ast_channel *oss_new(struct chan_oss_pvt *p, int state)
static struct ast_channel *oss_request(char *type, int format, void *data)
{
int oldformat = format;
struct ast_channel *tmp;
format &= AST_FORMAT_SLINEAR;
if (!format) {
ast_log(LOG_NOTICE, "Asked to get a channel of format '%d'\n", oldformat);
@@ -572,7 +593,11 @@ static struct ast_channel *oss_request(char *type, int format, void *data)
ast_log(LOG_NOTICE, "Already have a call on the OSS channel\n");
return NULL;
}
return oss_new(&oss, AST_STATE_DOWN);
tmp= oss_new(&oss, AST_STATE_DOWN);
if (!tmp) {
ast_log(LOG_WARNING, "Unable to create new OSS channel\n");
}
return tmp;
}
static int console_autoanswer(int fd, int argc, char *argv[])
@@ -629,6 +654,30 @@ static int console_answer(int fd, int argc, char *argv[])
return RESULT_SUCCESS;
}
static char sendtext_usage[] =
"Usage: send text <message>\n"
" Sends a text message for display on the remote terminal.\n";
static int console_sendtext(int fd, int argc, char *argv[])
{
int tmparg = 1;
if (argc < 1)
return RESULT_SHOWUSAGE;
if (!oss.owner) {
ast_cli(fd, "No one is calling us\n");
return RESULT_FAILURE;
}
if (strlen(text2send))
ast_cli(fd, "Warning: message already waiting to be sent, overwriting\n");
strcpy(text2send, "");
while(tmparg <= argc) {
strncat(text2send, argv[tmparg++], sizeof(text2send) - strlen(text2send));
strncat(text2send, " ", sizeof(text2send) - strlen(text2send));
}
needanswer++;
return RESULT_SUCCESS;
}
static char answer_usage[] =
"Usage: answer\n"
" Answers an incoming call on the console (OSS) channel.\n";
@@ -694,6 +743,7 @@ static struct ast_cli_entry myclis[] = {
{ { "answer", NULL }, console_answer, "Answer an incoming console call", answer_usage },
{ { "hangup", NULL }, console_hangup, "Hangup a call on the console", hangup_usage },
{ { "dial", NULL }, console_dial, "Dial an extension on the console", dial_usage },
{ { "send text", NULL }, console_sendtext, "Send text to the remote device", sendtext_usage },
{ { "autoanswer", NULL }, console_autoanswer, "Sets/displays autoanswer", autoanswer_usage, autoanswer_complete }
};
@@ -744,6 +794,8 @@ int load_module()
silencethreshold = atoi(v->value);
else if (!strcasecmp(v->name, "context"))
strncpy(context, v->value, sizeof(context));
else if (!strcasecmp(v->name, "language"))
strncpy(language, v->value, sizeof(language));
else if (!strcasecmp(v->name, "extension"))
strncpy(exten, v->value, sizeof(exten));
v=v->next;