mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-23 14:44:28 +00:00
ensure that calls to gethostbyname are null terminated,
also use MAXHOSTNAMELEN where appropriate (bug #4198) (bug #4212) git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/v1-0@5675 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
4
acl.c
4
acl.c
@@ -381,7 +381,7 @@ int ast_ouraddrfor(struct in_addr *them, struct in_addr *us)
|
|||||||
|
|
||||||
int ast_find_ourip(struct in_addr *ourip, struct sockaddr_in bindaddr)
|
int ast_find_ourip(struct in_addr *ourip, struct sockaddr_in bindaddr)
|
||||||
{
|
{
|
||||||
char ourhost[256];
|
char ourhost[MAXHOSTNAMELEN]="";
|
||||||
struct ast_hostent ahp;
|
struct ast_hostent ahp;
|
||||||
struct hostent *hp;
|
struct hostent *hp;
|
||||||
struct in_addr saddr;
|
struct in_addr saddr;
|
||||||
@@ -392,7 +392,7 @@ int ast_find_ourip(struct in_addr *ourip, struct sockaddr_in bindaddr)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
/* try to use our hostname */
|
/* try to use our hostname */
|
||||||
if (gethostname(ourhost, sizeof(ourhost))) {
|
if (gethostname(ourhost, sizeof(ourhost)-1)) {
|
||||||
ast_log(LOG_WARNING, "Unable to get hostname\n");
|
ast_log(LOG_WARNING, "Unable to get hostname\n");
|
||||||
} else {
|
} else {
|
||||||
hp = ast_gethostbyname(ourhost, &ahp);
|
hp = ast_gethostbyname(ourhost, &ahp);
|
||||||
|
@@ -862,7 +862,7 @@ static int sendmail(char *srcemail, struct ast_vm_user *vmu, int msgnum, char *m
|
|||||||
FILE *p=NULL;
|
FILE *p=NULL;
|
||||||
int pfd;
|
int pfd;
|
||||||
char date[256];
|
char date[256];
|
||||||
char host[256];
|
char host[MAXHOSTNAMELEN] = "";
|
||||||
char who[256];
|
char who[256];
|
||||||
char bound[256];
|
char bound[256];
|
||||||
char fname[256];
|
char fname[256];
|
||||||
@@ -890,7 +890,7 @@ static int sendmail(char *srcemail, struct ast_vm_user *vmu, int msgnum, char *m
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (p) {
|
if (p) {
|
||||||
gethostname(host, sizeof(host));
|
gethostname(host, sizeof(host)-1);
|
||||||
if (strchr(srcemail, '@'))
|
if (strchr(srcemail, '@'))
|
||||||
strncpy(who, srcemail, sizeof(who)-1);
|
strncpy(who, srcemail, sizeof(who)-1);
|
||||||
else {
|
else {
|
||||||
@@ -1020,7 +1020,7 @@ static int sendpage(char *srcemail, char *pager, int msgnum, char *mailbox, char
|
|||||||
FILE *p=NULL;
|
FILE *p=NULL;
|
||||||
int pfd;
|
int pfd;
|
||||||
char date[256];
|
char date[256];
|
||||||
char host[256];
|
char host[MAXHOSTNAMELEN]="";
|
||||||
char who[256];
|
char who[256];
|
||||||
char dur[256];
|
char dur[256];
|
||||||
char tmp[80] = "/tmp/astmail-XXXXXX";
|
char tmp[80] = "/tmp/astmail-XXXXXX";
|
||||||
@@ -1039,7 +1039,7 @@ static int sendpage(char *srcemail, char *pager, int msgnum, char *mailbox, char
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (p) {
|
if (p) {
|
||||||
gethostname(host, sizeof(host));
|
gethostname(host, sizeof(host)-1);
|
||||||
if (strchr(srcemail, '@'))
|
if (strchr(srcemail, '@'))
|
||||||
strncpy(who, srcemail, sizeof(who)-1);
|
strncpy(who, srcemail, sizeof(who)-1);
|
||||||
else {
|
else {
|
||||||
|
10
asterisk.c
10
asterisk.c
@@ -264,12 +264,12 @@ static pthread_t lthread;
|
|||||||
static void *netconsole(void *vconsole)
|
static void *netconsole(void *vconsole)
|
||||||
{
|
{
|
||||||
struct console *con = vconsole;
|
struct console *con = vconsole;
|
||||||
char hostname[256];
|
char hostname[MAXHOSTNAMELEN]="";
|
||||||
char tmp[512];
|
char tmp[512];
|
||||||
int res;
|
int res;
|
||||||
struct pollfd fds[2];
|
struct pollfd fds[2];
|
||||||
|
|
||||||
if (gethostname(hostname, sizeof(hostname)))
|
if (gethostname(hostname, sizeof(hostname)-1))
|
||||||
strncpy(hostname, "<Unknown>", sizeof(hostname)-1);
|
strncpy(hostname, "<Unknown>", sizeof(hostname)-1);
|
||||||
snprintf(tmp, sizeof(tmp), "%s/%d/%s\n", hostname, ast_mainpid, ASTERISK_VERSION);
|
snprintf(tmp, sizeof(tmp), "%s/%d/%s\n", hostname, ast_mainpid, ASTERISK_VERSION);
|
||||||
fdprint(con->fd, tmp);
|
fdprint(con->fd, tmp);
|
||||||
@@ -964,7 +964,7 @@ static char *cli_prompt(EditLine *el)
|
|||||||
memset(prompt, 0, sizeof(prompt));
|
memset(prompt, 0, sizeof(prompt));
|
||||||
while (*t != '\0' && *p < sizeof(prompt)) {
|
while (*t != '\0' && *p < sizeof(prompt)) {
|
||||||
if (*t == '%') {
|
if (*t == '%') {
|
||||||
char hostname[256];
|
char hostname[MAXHOSTNAMELEN]="";
|
||||||
int i;
|
int i;
|
||||||
struct timeval tv;
|
struct timeval tv;
|
||||||
struct tm tm;
|
struct tm tm;
|
||||||
@@ -1572,7 +1572,7 @@ int main(int argc, char *argv[])
|
|||||||
{
|
{
|
||||||
int c;
|
int c;
|
||||||
char filename[80] = "";
|
char filename[80] = "";
|
||||||
char hostname[256];
|
char hostname[MAXHOSTNAMELEN]="";
|
||||||
char tmp[80];
|
char tmp[80];
|
||||||
char * xarg = NULL;
|
char * xarg = NULL;
|
||||||
int x;
|
int x;
|
||||||
@@ -1597,7 +1597,7 @@ int main(int argc, char *argv[])
|
|||||||
option_remote++;
|
option_remote++;
|
||||||
option_nofork++;
|
option_nofork++;
|
||||||
}
|
}
|
||||||
if (gethostname(hostname, sizeof(hostname)))
|
if (gethostname(hostname, sizeof(hostname)-1))
|
||||||
strncpy(hostname, "<Unknown>", sizeof(hostname)-1);
|
strncpy(hostname, "<Unknown>", sizeof(hostname)-1);
|
||||||
ast_mainpid = getpid();
|
ast_mainpid = getpid();
|
||||||
ast_ulaw_init();
|
ast_ulaw_init();
|
||||||
|
@@ -239,7 +239,7 @@ static int restart_monitor(void);
|
|||||||
static int capability = AST_FORMAT_ULAW;
|
static int capability = AST_FORMAT_ULAW;
|
||||||
static int nonCodecCapability = AST_RTP_DTMF;
|
static int nonCodecCapability = AST_RTP_DTMF;
|
||||||
|
|
||||||
static char ourhost[256];
|
static char ourhost[MAXHOSTNAMELEN];
|
||||||
static struct in_addr __ourip;
|
static struct in_addr __ourip;
|
||||||
static int ourport;
|
static int ourport;
|
||||||
|
|
||||||
@@ -3944,7 +3944,7 @@ static int reload_config(void)
|
|||||||
struct ast_hostent ahp; struct hostent *hp;
|
struct ast_hostent ahp; struct hostent *hp;
|
||||||
int format;
|
int format;
|
||||||
|
|
||||||
if (gethostname(ourhost, sizeof(ourhost))) {
|
if (gethostname(ourhost, sizeof(ourhost)-1)) {
|
||||||
ast_log(LOG_WARNING, "Unable to get hostname, MGCP disabled\n");
|
ast_log(LOG_WARNING, "Unable to get hostname, MGCP disabled\n");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@@ -205,7 +205,7 @@ static int recordhistory = 0;
|
|||||||
static int global_promiscredir;
|
static int global_promiscredir;
|
||||||
|
|
||||||
static char global_musicclass[MAX_LANGUAGE] = ""; /* Global music on hold class */
|
static char global_musicclass[MAX_LANGUAGE] = ""; /* Global music on hold class */
|
||||||
static char global_realm[AST_MAX_EXTENSION] = "asterisk"; /* Default realm */
|
static char global_realm[MAXHOSTNAMELEN] = "asterisk"; /* Default realm */
|
||||||
static char regcontext[AST_MAX_EXTENSION] = "";
|
static char regcontext[AST_MAX_EXTENSION] = "";
|
||||||
|
|
||||||
/* Expire slowly */
|
/* Expire slowly */
|
||||||
@@ -299,10 +299,10 @@ static struct sip_pvt {
|
|||||||
char from[256]; /* The From: header */
|
char from[256]; /* The From: header */
|
||||||
char useragent[256]; /* User agent in SIP request */
|
char useragent[256]; /* User agent in SIP request */
|
||||||
char context[AST_MAX_EXTENSION]; /* Context for this call */
|
char context[AST_MAX_EXTENSION]; /* Context for this call */
|
||||||
char fromdomain[AST_MAX_EXTENSION]; /* Domain to show in the from field */
|
char fromdomain[MAXHOSTNAMELEN]; /* Domain to show in the from field */
|
||||||
char fromuser[AST_MAX_EXTENSION]; /* User to show in the user field */
|
char fromuser[AST_MAX_EXTENSION]; /* User to show in the user field */
|
||||||
char fromname[AST_MAX_EXTENSION]; /* Name to show in the user field */
|
char fromname[AST_MAX_EXTENSION]; /* Name to show in the user field */
|
||||||
char tohost[AST_MAX_EXTENSION]; /* Host we should put in the "to" field */
|
char tohost[MAXHOSTNAMELEN]; /* Host we should put in the "to" field */
|
||||||
char language[MAX_LANGUAGE]; /* Default language for this call */
|
char language[MAX_LANGUAGE]; /* Default language for this call */
|
||||||
char musicclass[MAX_LANGUAGE]; /* Music on Hold class */
|
char musicclass[MAX_LANGUAGE]; /* Music on Hold class */
|
||||||
char rdnis[256]; /* Referring DNIS */
|
char rdnis[256]; /* Referring DNIS */
|
||||||
@@ -316,14 +316,14 @@ static struct sip_pvt {
|
|||||||
char callerid[256]; /* Caller*ID */
|
char callerid[256]; /* Caller*ID */
|
||||||
int restrictcid; /* hide presentation from remote user */
|
int restrictcid; /* hide presentation from remote user */
|
||||||
char via[256];
|
char via[256];
|
||||||
char fullcontact[128]; /* Extra parameters to go in the "To" header */
|
char fullcontact[128]; /* Extra parameters to go in the "To" header */
|
||||||
char accountcode[20]; /* Account code */
|
char accountcode[20]; /* Account code */
|
||||||
char our_contact[256]; /* Our contact header */
|
char our_contact[256]; /* Our contact header */
|
||||||
char realm[256]; /* Authorization realm */
|
char realm[MAXHOSTNAMELEN]; /* Authorization realm */
|
||||||
char nonce[256]; /* Authorization nonce */
|
char nonce[256]; /* Authorization nonce */
|
||||||
char opaque[256]; /* Opaque nonsense */
|
char opaque[256]; /* Opaque nonsense */
|
||||||
char qop[80]; /* Quality of Protection, since SIP wasn't complicated enough yet. */
|
char qop[80]; /* Quality of Protection, since SIP wasn't complicated enough yet. */
|
||||||
char domain[256]; /* Authorization domain */
|
char domain[MAXHOSTNAMELEN]; /* Authorization domain */
|
||||||
char lastmsg[256]; /* Last Message sent/received */
|
char lastmsg[256]; /* Last Message sent/received */
|
||||||
int amaflags; /* AMA Flags */
|
int amaflags; /* AMA Flags */
|
||||||
int pendinginvite; /* Any pending invite */
|
int pendinginvite; /* Any pending invite */
|
||||||
@@ -385,7 +385,7 @@ struct sip_user {
|
|||||||
char name[80];
|
char name[80];
|
||||||
char secret[80];
|
char secret[80];
|
||||||
char md5secret[80];
|
char md5secret[80];
|
||||||
char context[80];
|
char context[AST_MAX_EXTENSION];
|
||||||
char callerid[80];
|
char callerid[80];
|
||||||
char accountcode[20];
|
char accountcode[20];
|
||||||
char language[MAX_LANGUAGE];
|
char language[MAX_LANGUAGE];
|
||||||
@@ -424,13 +424,13 @@ struct sip_peer {
|
|||||||
char name[80];
|
char name[80];
|
||||||
char secret[80];
|
char secret[80];
|
||||||
char md5secret[80];
|
char md5secret[80];
|
||||||
char context[80]; /* JK02: peers need context too to allow parking etc */
|
char context[AST_MAX_EXTENSION]; /* JK02: peers need context too to allow parking etc */
|
||||||
char username[80];
|
char username[80];
|
||||||
char tohost[80];
|
char tohost[MAXHOSTNAMELEN];
|
||||||
char regexten[AST_MAX_EXTENSION]; /* Extension to register (if regcontext is used) */
|
char regexten[AST_MAX_EXTENSION]; /* Extension to register (if regcontext is used) */
|
||||||
char fromuser[80];
|
char fromuser[80];
|
||||||
char fromdomain[80];
|
char fromdomain[MAXHOSTNAMELEN];
|
||||||
char fullcontact[128];
|
char fullcontact[256];
|
||||||
char mailbox[AST_MAX_EXTENSION];
|
char mailbox[AST_MAX_EXTENSION];
|
||||||
char language[MAX_LANGUAGE];
|
char language[MAX_LANGUAGE];
|
||||||
char musicclass[MAX_LANGUAGE]; /* Music on Hold class */
|
char musicclass[MAX_LANGUAGE]; /* Music on Hold class */
|
||||||
@@ -496,10 +496,10 @@ struct sip_registry {
|
|||||||
int portno; /* Optional port override */
|
int portno; /* Optional port override */
|
||||||
char username[80]; /* Who we are registering as */
|
char username[80]; /* Who we are registering as */
|
||||||
char authuser[80]; /* Who we *authenticate* as */
|
char authuser[80]; /* Who we *authenticate* as */
|
||||||
char hostname[80];
|
char hostname[MAXHOSTNAMELEN];
|
||||||
char secret[80]; /* Password or key name in []'s */
|
char secret[80]; /* Password or key name in []'s */
|
||||||
char md5secret[80];
|
char md5secret[80];
|
||||||
char contact[80]; /* Contact extension */
|
char contact[256]; /* Contact extension */
|
||||||
char random[80];
|
char random[80];
|
||||||
int expire; /* Sched ID of expiration */
|
int expire; /* Sched ID of expiration */
|
||||||
int timeout; /* sched id of sip_reg_timeout */
|
int timeout; /* sched id of sip_reg_timeout */
|
||||||
@@ -512,9 +512,9 @@ struct sip_registry {
|
|||||||
struct sockaddr_in us; /* Who the server thinks we are */
|
struct sockaddr_in us; /* Who the server thinks we are */
|
||||||
|
|
||||||
/* Saved headers */
|
/* Saved headers */
|
||||||
char realm[256]; /* Authorization realm */
|
char realm[MAXHOSTNAMELEN]; /* Authorization realm */
|
||||||
char nonce[256]; /* Authorization nonce */
|
char nonce[256]; /* Authorization nonce */
|
||||||
char domain[256]; /* Authorization domain */
|
char domain[MAXHOSTNAMELEN]; /* Authorization domain */
|
||||||
char opaque[256]; /* Opaque nonsense */
|
char opaque[256]; /* Opaque nonsense */
|
||||||
char qop[80]; /* Quality of Protection. */
|
char qop[80]; /* Quality of Protection. */
|
||||||
|
|
||||||
@@ -1289,7 +1289,7 @@ static int create_addr(struct sip_pvt *r, char *opeer)
|
|||||||
char *port;
|
char *port;
|
||||||
char *callhost;
|
char *callhost;
|
||||||
int portno;
|
int portno;
|
||||||
char host[256], *hostn;
|
char host[MAXHOSTNAMELEN], *hostn;
|
||||||
char peer[256]="";
|
char peer[256]="";
|
||||||
|
|
||||||
strncpy(peer, opeer, sizeof(peer) - 1);
|
strncpy(peer, opeer, sizeof(peer) - 1);
|
||||||
@@ -1378,7 +1378,7 @@ static int create_addr(struct sip_pvt *r, char *opeer)
|
|||||||
else
|
else
|
||||||
portno = DEFAULT_SIP_PORT;
|
portno = DEFAULT_SIP_PORT;
|
||||||
if (srvlookup) {
|
if (srvlookup) {
|
||||||
char service[256];
|
char service[MAXHOSTNAMELEN];
|
||||||
int tportno;
|
int tportno;
|
||||||
int ret;
|
int ret;
|
||||||
snprintf(service, sizeof(service), "_sip._udp.%s", peer);
|
snprintf(service, sizeof(service), "_sip._udp.%s", peer);
|
||||||
|
4
logger.c
4
logger.c
@@ -65,7 +65,7 @@ static struct msglist {
|
|||||||
struct msglist *next;
|
struct msglist *next;
|
||||||
} *list = NULL, *last = NULL;
|
} *list = NULL, *last = NULL;
|
||||||
|
|
||||||
static char hostname[256];
|
static char hostname[MAXHOSTNAMELEN];
|
||||||
|
|
||||||
struct logchannel {
|
struct logchannel {
|
||||||
int logmask;
|
int logmask;
|
||||||
@@ -230,7 +230,7 @@ static void init_logger_chain(void)
|
|||||||
ast_mutex_lock(&loglock);
|
ast_mutex_lock(&loglock);
|
||||||
if ((s = ast_variable_retrieve(cfg, "general", "appendhostname"))) {
|
if ((s = ast_variable_retrieve(cfg, "general", "appendhostname"))) {
|
||||||
if(ast_true(s)) {
|
if(ast_true(s)) {
|
||||||
if(gethostname(hostname, sizeof(hostname))) {
|
if(gethostname(hostname, sizeof(hostname)-1)) {
|
||||||
strncpy(hostname, "unknown", sizeof(hostname)-1);
|
strncpy(hostname, "unknown", sizeof(hostname)-1);
|
||||||
ast_log(LOG_WARNING, "What box has no hostname???\n");
|
ast_log(LOG_WARNING, "What box has no hostname???\n");
|
||||||
}
|
}
|
||||||
|
@@ -58,6 +58,9 @@ static int parkingtime = DEFAULT_PARK_TIME;
|
|||||||
/* Context for which parking is made accessible */
|
/* Context for which parking is made accessible */
|
||||||
static char parking_con[AST_MAX_EXTENSION] = "parkedcalls";
|
static char parking_con[AST_MAX_EXTENSION] = "parkedcalls";
|
||||||
|
|
||||||
|
/* Context for dialback for parking (KLUDGE) */
|
||||||
|
static char parking_con_dial[AST_MAX_EXTENSION] = "park-dial";
|
||||||
|
|
||||||
/* Extension you type to park the call */
|
/* Extension you type to park the call */
|
||||||
static char parking_ext[AST_MAX_EXTENSION] = "700";
|
static char parking_ext[AST_MAX_EXTENSION] = "700";
|
||||||
|
|
||||||
@@ -112,6 +115,7 @@ struct parkeduser {
|
|||||||
int priority;
|
int priority;
|
||||||
int parkingtime;
|
int parkingtime;
|
||||||
int notquiteyet;
|
int notquiteyet;
|
||||||
|
char peername[1024];
|
||||||
unsigned char moh_trys;
|
unsigned char moh_trys;
|
||||||
struct parkeduser *next;
|
struct parkeduser *next;
|
||||||
};
|
};
|
||||||
@@ -190,6 +194,8 @@ int ast_park_call(struct ast_channel *chan, struct ast_channel *peer, int timeou
|
|||||||
pu->parkingtime = parkingtime;
|
pu->parkingtime = parkingtime;
|
||||||
if (extout)
|
if (extout)
|
||||||
*extout = x;
|
*extout = x;
|
||||||
|
if (peer)
|
||||||
|
strncpy(pu->peername, peer->name, sizeof(pu->peername) - 1);
|
||||||
/* Remember what had been dialed, so that if the parking
|
/* Remember what had been dialed, so that if the parking
|
||||||
expires, we try to come back to the same place */
|
expires, we try to come back to the same place */
|
||||||
if (!ast_strlen_zero(chan->macrocontext))
|
if (!ast_strlen_zero(chan->macrocontext))
|
||||||
@@ -560,19 +566,21 @@ static void *do_parking_thread(void *ignore)
|
|||||||
struct timeval tv;
|
struct timeval tv;
|
||||||
struct ast_frame *f;
|
struct ast_frame *f;
|
||||||
char exten[AST_MAX_EXTENSION];
|
char exten[AST_MAX_EXTENSION];
|
||||||
|
char *peername,*cp;
|
||||||
|
char returnexten[AST_MAX_EXTENSION];
|
||||||
struct ast_context *con;
|
struct ast_context *con;
|
||||||
int x;
|
int x;
|
||||||
fd_set rfds, efds;
|
fd_set rfds, efds;
|
||||||
fd_set nrfds, nefds;
|
fd_set nrfds, nefds;
|
||||||
FD_ZERO(&rfds);
|
FD_ZERO(&rfds);
|
||||||
FD_ZERO(&efds);
|
FD_ZERO(&efds);
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
ms = -1;
|
ms = -1;
|
||||||
max = -1;
|
max = -1;
|
||||||
ast_mutex_lock(&parking_lock);
|
ast_mutex_lock(&parking_lock);
|
||||||
pl = NULL;
|
pl = NULL;
|
||||||
pu = parkinglot;
|
pu = parkinglot;
|
||||||
gettimeofday(&tv, NULL);
|
|
||||||
FD_ZERO(&nrfds);
|
FD_ZERO(&nrfds);
|
||||||
FD_ZERO(&nefds);
|
FD_ZERO(&nefds);
|
||||||
while(pu) {
|
while(pu) {
|
||||||
@@ -582,17 +590,42 @@ static void *do_parking_thread(void *ignore)
|
|||||||
pu = pu->next;
|
pu = pu->next;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
gettimeofday(&tv, NULL);
|
||||||
tms = (tv.tv_sec - pu->start.tv_sec) * 1000 + (tv.tv_usec - pu->start.tv_usec) / 1000;
|
tms = (tv.tv_sec - pu->start.tv_sec) * 1000 + (tv.tv_usec - pu->start.tv_usec) / 1000;
|
||||||
if (tms > pu->parkingtime) {
|
if (tms > pu->parkingtime) {
|
||||||
/* They've been waiting too long, send them back to where they came. Theoretically they
|
|
||||||
should have their original extensions and such, but we copy to be on the safe side */
|
|
||||||
strncpy(pu->chan->exten, pu->exten, sizeof(pu->chan->exten)-1);
|
|
||||||
strncpy(pu->chan->context, pu->context, sizeof(pu->chan->context)-1);
|
|
||||||
pu->chan->priority = pu->priority;
|
|
||||||
if (option_verbose > 1)
|
|
||||||
ast_verbose(VERBOSE_PREFIX_2 "Timeout for %s parked on %d. Returning to %s,%s,%d\n", pu->chan->name, pu->parkingnum, pu->chan->context, pu->chan->exten, pu->chan->priority);
|
|
||||||
/* Stop music on hold */
|
/* Stop music on hold */
|
||||||
ast_moh_stop(pu->chan);
|
ast_moh_stop(pu->chan);
|
||||||
|
/* Get chan, exten from derived kludge */
|
||||||
|
if (pu->peername[0]) {
|
||||||
|
peername = ast_strdupa(pu->peername);
|
||||||
|
cp = strrchr(peername, '-');
|
||||||
|
if (cp)
|
||||||
|
*cp = 0;
|
||||||
|
con = ast_context_find(parking_con_dial);
|
||||||
|
if (!con) {
|
||||||
|
con = ast_context_create(NULL, parking_con_dial, registrar);
|
||||||
|
if (!con) {
|
||||||
|
ast_log(LOG_ERROR, "Parking dial context '%s' does not exist and unable to create\n", parking_con_dial);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (con) {
|
||||||
|
snprintf(returnexten, sizeof(returnexten), "%s||t", peername);
|
||||||
|
ast_add_extension2(con, 1, peername, 1, NULL, "Dial", strdup(returnexten), free, registrar);
|
||||||
|
}
|
||||||
|
strncpy(pu->chan->exten, peername, sizeof(pu->chan->exten) - 1);
|
||||||
|
strncpy(pu->chan->context, parking_con_dial, sizeof(pu->chan->context) - 1);
|
||||||
|
pu->chan->priority = 1;
|
||||||
|
|
||||||
|
} else {
|
||||||
|
/* They've been waiting too long, send them back to where they came. Theoretically they
|
||||||
|
should have their original extensions and such, but we copy to be on the safe side */
|
||||||
|
strncpy(pu->chan->exten, pu->exten, sizeof(pu->chan->exten)-1);
|
||||||
|
strncpy(pu->chan->context, pu->context, sizeof(pu->chan->context)-1);
|
||||||
|
pu->chan->priority = pu->priority;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (option_verbose > 1)
|
||||||
|
ast_verbose(VERBOSE_PREFIX_2 "Timeout for %s parked on %d. Returning to %s,%s,%d\n", pu->chan->name, pu->parkingnum, pu->chan->context, pu->chan->exten, pu->chan->priority);
|
||||||
/* Start up the PBX, or hang them up */
|
/* Start up the PBX, or hang them up */
|
||||||
if (ast_pbx_start(pu->chan)) {
|
if (ast_pbx_start(pu->chan)) {
|
||||||
ast_log(LOG_WARNING, "Unable to restart the PBX for user on '%s', hanging them up...\n", pu->chan->name);
|
ast_log(LOG_WARNING, "Unable to restart the PBX for user on '%s', hanging them up...\n", pu->chan->name);
|
||||||
@@ -614,14 +647,17 @@ static void *do_parking_thread(void *ignore)
|
|||||||
ast_log(LOG_WARNING, "Whoa, no parking context?\n");
|
ast_log(LOG_WARNING, "Whoa, no parking context?\n");
|
||||||
free(pt);
|
free(pt);
|
||||||
} else {
|
} else {
|
||||||
for (x=0;x<AST_MAX_FDS;x++) {
|
for (x=0; x<AST_MAX_FDS; x++) {
|
||||||
if ((pu->chan->fds[x] > -1) && (FD_ISSET(pu->chan->fds[x], &rfds) || FD_ISSET(pu->chan->fds[x], &efds))) {
|
if ((pu->chan->fds[x] > -1) && (FD_ISSET(pu->chan->fds[x], &rfds) || FD_ISSET(pu->chan->fds[x], &efds))) {
|
||||||
if (FD_ISSET(pu->chan->fds[x], &efds))
|
if (FD_ISSET(pu->chan->fds[x], &efds))
|
||||||
pu->chan->exception = 1;
|
pu->chan->exception = 1;
|
||||||
|
else
|
||||||
|
pu->chan->exception = 0;
|
||||||
pu->chan->fdno = x;
|
pu->chan->fdno = x;
|
||||||
/* See if they need servicing */
|
/* See if they need servicing */
|
||||||
f = ast_read(pu->chan);
|
f = ast_read(pu->chan);
|
||||||
if (!f || ((f->frametype == AST_FRAME_CONTROL) && (f->subclass == AST_CONTROL_HANGUP))) {
|
if (!f || ((f->frametype == AST_FRAME_CONTROL) && (f->subclass == AST_CONTROL_HANGUP))) {
|
||||||
|
|
||||||
/* There's a problem, hang them up*/
|
/* There's a problem, hang them up*/
|
||||||
if (option_verbose > 1)
|
if (option_verbose > 1)
|
||||||
ast_verbose(VERBOSE_PREFIX_2 "%s got tired of being parked\n", pu->chan->name);
|
ast_verbose(VERBOSE_PREFIX_2 "%s got tired of being parked\n", pu->chan->name);
|
||||||
@@ -646,7 +682,7 @@ static void *do_parking_thread(void *ignore)
|
|||||||
/* XXX Maybe we could do something with packets, like dial "0" for operator or something XXX */
|
/* XXX Maybe we could do something with packets, like dial "0" for operator or something XXX */
|
||||||
ast_frfree(f);
|
ast_frfree(f);
|
||||||
if (pu->moh_trys < 3 && !pu->chan->generatordata) {
|
if (pu->moh_trys < 3 && !pu->chan->generatordata) {
|
||||||
ast_log(LOG_DEBUG, "MOH on parked call stopped by outside source. Restarting\n");
|
ast_log(LOG_DEBUG, "MOH on parked call stopped by outside source. Restarting.\n");
|
||||||
ast_moh_start(pu->chan, NULL);
|
ast_moh_start(pu->chan, NULL);
|
||||||
pu->moh_trys++;
|
pu->moh_trys++;
|
||||||
}
|
}
|
||||||
@@ -655,7 +691,7 @@ static void *do_parking_thread(void *ignore)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (x >= AST_MAX_FDS) {
|
if (x >= AST_MAX_FDS) {
|
||||||
std: for (x=0;x<AST_MAX_FDS;x++) {
|
std: for (x=0; x<AST_MAX_FDS; x++) {
|
||||||
/* Keep this one for next one */
|
/* Keep this one for next one */
|
||||||
if (pu->chan->fds[x] > -1) {
|
if (pu->chan->fds[x] > -1) {
|
||||||
FD_SET(pu->chan->fds[x], &nrfds);
|
FD_SET(pu->chan->fds[x], &nrfds);
|
||||||
|
Reference in New Issue
Block a user