Another big chunk of changes from the RSW branch. Bunch of stuff from main/

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@137082 65c4cc65-6c06-0410-ace0-fbb531ad65f3
1.6.1
Sean Bright 17 years ago
parent 3ffb39833b
commit b69c8e6ab5

@ -551,16 +551,16 @@ void ast_jb_destroy(struct ast_channel *chan)
} }
static long get_now(struct ast_jb *jb, struct timeval *tv) static long get_now(struct ast_jb *jb, struct timeval *when)
{ {
struct timeval now; struct timeval now;
if (!tv) { if (!when) {
tv = &now; when = &now;
gettimeofday(tv, NULL); gettimeofday(when, NULL);
} }
return ast_tvdiff_ms(*tv, jb->timebase); return ast_tvdiff_ms(*when, jb->timebase);
} }

@ -246,18 +246,18 @@ struct ast_ha *ast_duplicate_ha_list(struct ast_ha *original)
{ {
struct ast_ha *start = original; struct ast_ha *start = original;
struct ast_ha *ret = NULL; struct ast_ha *ret = NULL;
struct ast_ha *link, *prev = NULL; struct ast_ha *current, *prev = NULL;
while (start) { while (start) {
link = ast_duplicate_ha(start); /* Create copy of this object */ current = ast_duplicate_ha(start); /* Create copy of this object */
if (prev) if (prev)
prev->next = link; /* Link previous to this object */ prev->next = current; /* Link previous to this object */
if (!ret) if (!ret)
ret = link; /* Save starting point */ ret = current; /* Save starting point */
start = start->next; /* Go to next object */ start = start->next; /* Go to next object */
prev = link; /* Save pointer to this object */ prev = current; /* Save pointer to this object */
} }
return ret; /* Return start of list */ return ret; /* Return start of list */
} }

@ -452,7 +452,7 @@ int ast_linear_stream(struct ast_channel *chan, const char *filename, int fd, in
int ast_control_streamfile(struct ast_channel *chan, const char *file, int ast_control_streamfile(struct ast_channel *chan, const char *file,
const char *fwd, const char *rev, const char *fwd, const char *rev,
const char *stop, const char *pause, const char *stop, const char *suspend,
const char *restart, int skipms, long *offsetms) const char *restart, int skipms, long *offsetms)
{ {
char *breaks = NULL; char *breaks = NULL;
@ -467,8 +467,8 @@ int ast_control_streamfile(struct ast_channel *chan, const char *file,
if (stop) if (stop)
blen += strlen(stop); blen += strlen(stop);
if (pause) if (suspend)
blen += strlen(pause); blen += strlen(suspend);
if (restart) if (restart)
blen += strlen(restart); blen += strlen(restart);
@ -477,8 +477,8 @@ int ast_control_streamfile(struct ast_channel *chan, const char *file,
breaks[0] = '\0'; breaks[0] = '\0';
if (stop) if (stop)
strcat(breaks, stop); strcat(breaks, stop);
if (pause) if (suspend)
strcat(breaks, pause); strcat(breaks, suspend);
if (restart) if (restart)
strcat(breaks, restart); strcat(breaks, restart);
} }
@ -528,17 +528,17 @@ int ast_control_streamfile(struct ast_channel *chan, const char *file,
continue; continue;
} }
if (pause && strchr(pause, res)) { if (suspend && strchr(suspend, res)) {
pause_restart_point = ast_tellstream(chan->stream); pause_restart_point = ast_tellstream(chan->stream);
for (;;) { for (;;) {
ast_stopstream(chan); ast_stopstream(chan);
res = ast_waitfordigit(chan, 1000); res = ast_waitfordigit(chan, 1000);
if (!res) if (!res)
continue; continue;
else if (res == -1 || strchr(pause, res) || (stop && strchr(stop, res))) else if (res == -1 || strchr(suspend, res) || (stop && strchr(stop, res)))
break; break;
} }
if (res == *pause) { if (res == *suspend) {
res = 0; res = 0;
continue; continue;
} }

@ -644,14 +644,14 @@ static char *handle_show_profile(struct ast_cli_entry *e, int cmd, struct ast_cl
ast_cli(a->fd, "%6s %8s %10s %12s %12s %s\n", "ID", "Scale", "Events", ast_cli(a->fd, "%6s %8s %10s %12s %12s %s\n", "ID", "Scale", "Events",
"Value", "Average", "Name"); "Value", "Average", "Name");
for (i = min; i < max; i++) { for (i = min; i < max; i++) {
struct profile_entry *e = &prof_data->e[i]; struct profile_entry *entry = &prof_data->e[i];
if (!search || strstr(prof_data->e[i].name, search)) if (!search || strstr(prof_data->e[i].name, search))
ast_cli(a->fd, "%6d: [%8ld] %10ld %12lld %12lld %s\n", ast_cli(a->fd, "%6d: [%8ld] %10ld %12lld %12lld %s\n",
i, i,
(long)e->scale, (long)entry->scale,
(long)e->events, (long long)e->value, (long)entry->events, (long long)entry->value,
(long long)(e->events ? e->value / e->events : e->value), (long long)(entry->events ? entry->value / entry->events : entry->value),
e->name); entry->name);
} }
return CLI_SUCCESS; return CLI_SUCCESS;
} }
@ -817,7 +817,7 @@ static int fdprint(int fd, const char *s)
} }
/*! \brief NULL handler so we can collect the child exit status */ /*! \brief NULL handler so we can collect the child exit status */
static void null_sig_handler(int signal) static void null_sig_handler(int sig)
{ {
} }
@ -1326,7 +1326,7 @@ static void ast_run_atexits(void)
AST_RWLIST_UNLOCK(&atexits); AST_RWLIST_UNLOCK(&atexits);
} }
static void quit_handler(int num, int nice, int safeshutdown, int restart) static void quit_handler(int num, int niceness, int safeshutdown, int restart)
{ {
char filename[80] = ""; char filename[80] = "";
time_t s,e; time_t s,e;
@ -1335,7 +1335,7 @@ static void quit_handler(int num, int nice, int safeshutdown, int restart)
ast_cdr_engine_term(); ast_cdr_engine_term();
if (safeshutdown) { if (safeshutdown) {
shuttingdown = 1; shuttingdown = 1;
if (!nice) { if (!niceness) {
/* Begin shutdown routine, hanging up active channels */ /* Begin shutdown routine, hanging up active channels */
ast_begin_shutdown(1); ast_begin_shutdown(1);
if (option_verbose && ast_opt_console) if (option_verbose && ast_opt_console)
@ -1354,7 +1354,7 @@ static void quit_handler(int num, int nice, int safeshutdown, int restart)
usleep(100000); usleep(100000);
} }
} else { } else {
if (nice < 2) if (niceness < 2)
ast_begin_shutdown(0); ast_begin_shutdown(0);
if (option_verbose && ast_opt_console) if (option_verbose && ast_opt_console)
ast_verbose("Waiting for inactivity to perform %s...\n", restart ? "restart" : "halt"); ast_verbose("Waiting for inactivity to perform %s...\n", restart ? "restart" : "halt");
@ -1373,7 +1373,7 @@ static void quit_handler(int num, int nice, int safeshutdown, int restart)
return; return;
} }
if (nice) if (niceness)
ast_module_shutdown(); ast_module_shutdown();
} }
if (ast_opt_console || ast_opt_remote) { if (ast_opt_console || ast_opt_remote) {
@ -1899,7 +1899,7 @@ static struct ast_cli_entry cli_asterisk[] = {
#endif /* ! LOW_MEMORY */ #endif /* ! LOW_MEMORY */
}; };
static int ast_el_read_char(EditLine *el, char *cp) static int ast_el_read_char(EditLine *editline, char *cp)
{ {
int num_read = 0; int num_read = 0;
int lastpos = 0; int lastpos = 0;
@ -1993,7 +1993,7 @@ static int ast_el_read_char(EditLine *el, char *cp)
static struct ast_str *prompt = NULL; static struct ast_str *prompt = NULL;
static char *cli_prompt(EditLine *el) static char *cli_prompt(EditLine *editline)
{ {
char tmp[100]; char tmp[100];
char *pfmt; char *pfmt;
@ -2225,7 +2225,7 @@ static int ast_cli_display_match_list(char **matches, int len, int max)
} }
static char *cli_complete(EditLine *el, int ch) static char *cli_complete(EditLine *editline, int ch)
{ {
int len = 0; int len = 0;
char *ptr; char *ptr;
@ -2235,7 +2235,7 @@ static char *cli_complete(EditLine *el, int ch)
char buf[2048]; char buf[2048];
int res; int res;
LineInfo *lf = (LineInfo *)el_line(el); LineInfo *lf = (LineInfo *)el_line(editline);
*(char *)lf->cursor = '\0'; *(char *)lf->cursor = '\0';
ptr = (char *)lf->cursor; ptr = (char *)lf->cursor;
@ -2302,14 +2302,14 @@ static char *cli_complete(EditLine *el, int ch)
int matches_num, maxlen, match_len; int matches_num, maxlen, match_len;
if (matches[0][0] != '\0') { if (matches[0][0] != '\0') {
el_deletestr(el, (int) len); el_deletestr(editline, (int) len);
el_insertstr(el, matches[0]); el_insertstr(editline, matches[0]);
retval = CC_REFRESH; retval = CC_REFRESH;
} }
if (nummatches == 1) { if (nummatches == 1) {
/* Found an exact match */ /* Found an exact match */
el_insertstr(el, " "); el_insertstr(editline, " ");
retval = CC_REFRESH; retval = CC_REFRESH;
} else { } else {
/* Must be more than one match */ /* Must be more than one match */
@ -2324,7 +2324,7 @@ static char *cli_complete(EditLine *el, int ch)
ast_cli_display_match_list(matches, nummatches, maxlen); ast_cli_display_match_list(matches, nummatches, maxlen);
retval = CC_REDISPLAY; retval = CC_REDISPLAY;
} else { } else {
el_insertstr(el," "); el_insertstr(editline," ");
retval = CC_REFRESH; retval = CC_REFRESH;
} }
} }
@ -2427,7 +2427,6 @@ static void ast_remotecontrol(char * data)
char *cpid; char *cpid;
char *version; char *version;
int pid; int pid;
char tmp[80];
char *stringp = NULL; char *stringp = NULL;
char *ebuf; char *ebuf;
@ -2453,6 +2452,7 @@ static void ast_remotecontrol(char * data)
else else
pid = -1; pid = -1;
if (!data) { if (!data) {
char tmp[80];
snprintf(tmp, sizeof(tmp), "core set verbose atleast %d", option_verbose); snprintf(tmp, sizeof(tmp), "core set verbose atleast %d", option_verbose);
fdsend(ast_consock, tmp); fdsend(ast_consock, tmp);
snprintf(tmp, sizeof(tmp), "core set debug atleast %d", option_debug); snprintf(tmp, sizeof(tmp), "core set debug atleast %d", option_debug);
@ -2480,10 +2480,10 @@ static void ast_remotecontrol(char * data)
fds.events = POLLIN; fds.events = POLLIN;
fds.revents = 0; fds.revents = 0;
while (poll(&fds, 1, 500) > 0) { while (poll(&fds, 1, 500) > 0) {
char buf[512] = "", *curline = buf, *nextline; char buffer[512] = "", *curline = buffer, *nextline;
int not_written = 1; int not_written = 1;
if (read(ast_consock, buf, sizeof(buf) - 1) <= 0) { if (read(ast_consock, buffer, sizeof(buffer) - 1) <= 0) {
break; break;
} }
@ -2520,11 +2520,11 @@ static void ast_remotecontrol(char * data)
ebuf[strlen(ebuf)-1] = '\0'; ebuf[strlen(ebuf)-1] = '\0';
if (!remoteconsolehandler(ebuf)) { if (!remoteconsolehandler(ebuf)) {
/* Strip preamble from output */ /* Strip preamble from output */
char *tmp; char *temp;
for (tmp = ebuf; *tmp; tmp++) { for (temp = ebuf; *temp; temp++) {
if (*tmp == 127) { if (*temp == 127) {
memmove(tmp, tmp + 1, strlen(tmp)); memmove(temp, temp + 1, strlen(temp));
tmp--; temp--;
} }
} }
res = write(ast_consock, ebuf, strlen(ebuf) + 1); res = write(ast_consock, ebuf, strlen(ebuf) + 1);
@ -2831,15 +2831,15 @@ static void *monitor_sig_flags(void *unused)
static void *canary_thread(void *unused) static void *canary_thread(void *unused)
{ {
struct stat canary_stat; struct stat canary_stat;
struct timeval tv; struct timeval now;
/* Give the canary time to sing */ /* Give the canary time to sing */
sleep(120); sleep(120);
for (;;) { for (;;) {
stat(canary_filename, &canary_stat); stat(canary_filename, &canary_stat);
tv = ast_tvnow(); now = ast_tvnow();
if (tv.tv_sec > canary_stat.st_mtime + 60) { if (now.tv_sec > canary_stat.st_mtime + 60) {
ast_log(LOG_WARNING, "The canary is no more. He has ceased to be! He's expired and gone to meet his maker! He's a stiff! Bereft of life, he rests in peace. His metabolic processes are now history! He's off the twig! He's kicked the bucket. He's shuffled off his mortal coil, run down the curtain, and joined the bleeding choir invisible!! THIS is an EX-CANARY. (Reducing priority)\n"); ast_log(LOG_WARNING, "The canary is no more. He has ceased to be! He's expired and gone to meet his maker! He's a stiff! Bereft of life, he rests in peace. His metabolic processes are now history! He's off the twig! He's kicked the bucket. He's shuffled off his mortal coil, run down the curtain, and joined the bleeding choir invisible!! THIS is an EX-CANARY. (Reducing priority)\n");
ast_set_priority(0); ast_set_priority(0);
pthread_exit(NULL); pthread_exit(NULL);

@ -813,10 +813,10 @@ static void container_destruct(void *_c)
_ao2_callback(c, OBJ_UNLINK, cd_cb, NULL); _ao2_callback(c, OBJ_UNLINK, cd_cb, NULL);
for (i = 0; i < c->n_buckets; i++) { for (i = 0; i < c->n_buckets; i++) {
struct bucket_list *cur; struct bucket_list *current;
while ((cur = AST_LIST_REMOVE_HEAD(&c->buckets[i], entry))) { while ((current = AST_LIST_REMOVE_HEAD(&c->buckets[i], entry))) {
ast_free(cur); ast_free(current);
} }
} }
@ -833,10 +833,10 @@ static void container_destruct_debug(void *_c)
_ao2_callback_debug(c, OBJ_UNLINK, cd_cb_debug, NULL, "container_destruct_debug called", __FILE__, __LINE__, __PRETTY_FUNCTION__); _ao2_callback_debug(c, OBJ_UNLINK, cd_cb_debug, NULL, "container_destruct_debug called", __FILE__, __LINE__, __PRETTY_FUNCTION__);
for (i = 0; i < c->n_buckets; i++) { for (i = 0; i < c->n_buckets; i++) {
struct bucket_list *cur; struct bucket_list *current;
while ((cur = AST_LIST_REMOVE_HEAD(&c->buckets[i], entry))) { while ((current = AST_LIST_REMOVE_HEAD(&c->buckets[i], entry))) {
ast_free(cur); ast_free(current);
} }
} }

@ -122,13 +122,13 @@ int ast_audiohook_write_frame(struct ast_audiohook *audiohook, enum ast_audiohoo
{ {
struct ast_slinfactory *factory = (direction == AST_AUDIOHOOK_DIRECTION_READ ? &audiohook->read_factory : &audiohook->write_factory); struct ast_slinfactory *factory = (direction == AST_AUDIOHOOK_DIRECTION_READ ? &audiohook->read_factory : &audiohook->write_factory);
struct ast_slinfactory *other_factory = (direction == AST_AUDIOHOOK_DIRECTION_READ ? &audiohook->write_factory : &audiohook->read_factory); struct ast_slinfactory *other_factory = (direction == AST_AUDIOHOOK_DIRECTION_READ ? &audiohook->write_factory : &audiohook->read_factory);
struct timeval *time = (direction == AST_AUDIOHOOK_DIRECTION_READ ? &audiohook->read_time : &audiohook->write_time), previous_time = *time; struct timeval *rwtime = (direction == AST_AUDIOHOOK_DIRECTION_READ ? &audiohook->read_time : &audiohook->write_time), previous_time = *rwtime;
/* Update last feeding time to be current */ /* Update last feeding time to be current */
*time = ast_tvnow(); *rwtime = ast_tvnow();
/* If we are using a sync trigger and this factory suddenly got audio fed in after a lapse, then flush both factories to ensure they remain in sync */ /* If we are using a sync trigger and this factory suddenly got audio fed in after a lapse, then flush both factories to ensure they remain in sync */
if (ast_test_flag(audiohook, AST_AUDIOHOOK_TRIGGER_SYNC) && ast_slinfactory_available(other_factory) && (ast_tvdiff_ms(*time, previous_time) > (ast_slinfactory_available(other_factory) / 8))) { if (ast_test_flag(audiohook, AST_AUDIOHOOK_TRIGGER_SYNC) && ast_slinfactory_available(other_factory) && (ast_tvdiff_ms(*rwtime, previous_time) > (ast_slinfactory_available(other_factory) / 8))) {
if (option_debug) if (option_debug)
ast_log(LOG_DEBUG, "Flushing audiohook %p so it remains in sync\n", audiohook); ast_log(LOG_DEBUG, "Flushing audiohook %p so it remains in sync\n", audiohook);
ast_slinfactory_flush(factory); ast_slinfactory_flush(factory);
@ -666,12 +666,12 @@ struct ast_frame *ast_audiohook_write_list(struct ast_channel *chan, struct ast_
*/ */
void ast_audiohook_trigger_wait(struct ast_audiohook *audiohook) void ast_audiohook_trigger_wait(struct ast_audiohook *audiohook)
{ {
struct timeval tv; struct timeval wait;
struct timespec ts; struct timespec ts;
tv = ast_tvadd(ast_tvnow(), ast_samp2tv(50000, 1000)); wait = ast_tvadd(ast_tvnow(), ast_samp2tv(50000, 1000));
ts.tv_sec = tv.tv_sec; ts.tv_sec = wait.tv_sec;
ts.tv_nsec = tv.tv_usec * 1000; ts.tv_nsec = wait.tv_usec * 1000;
ast_cond_timedwait(&audiohook->trigger, &audiohook->lock, &ts); ast_cond_timedwait(&audiohook->trigger, &audiohook->lock, &ts);

@ -722,14 +722,14 @@ void callerid_free(struct callerid_state *cid)
static int callerid_genmsg(char *msg, int size, const char *number, const char *name, int flags) static int callerid_genmsg(char *msg, int size, const char *number, const char *name, int flags)
{ {
struct timeval tv = ast_tvnow(); struct timeval now = ast_tvnow();
struct ast_tm tm; struct ast_tm tm;
char *ptr; char *ptr;
int res; int res;
int i, x; int i, x;
/* Get the time */ /* Get the time */
ast_localtime(&tv, &tm, NULL); ast_localtime(&now, &tm, NULL);
ptr = msg; ptr = msg;

@ -201,15 +201,15 @@ static const char *ast_cdr_getvar_internal(struct ast_cdr *cdr, const char *name
return NULL; return NULL;
} }
static void cdr_get_tv(struct timeval tv, const char *fmt, char *buf, int bufsize) static void cdr_get_tv(struct timeval when, const char *fmt, char *buf, int bufsize)
{ {
if (fmt == NULL) { /* raw mode */ if (fmt == NULL) { /* raw mode */
snprintf(buf, bufsize, "%ld.%06ld", (long)tv.tv_sec, (long)tv.tv_usec); snprintf(buf, bufsize, "%ld.%06ld", (long)when.tv_sec, (long)when.tv_usec);
} else { } else {
if (tv.tv_sec) { if (when.tv_sec) {
struct ast_tm tm; struct ast_tm tm;
ast_localtime(&tv, &tm, NULL); ast_localtime(&when, &tm, NULL);
ast_strftime(buf, bufsize, fmt, &tm); ast_strftime(buf, bufsize, fmt, &tm);
} }
} }
@ -1034,7 +1034,7 @@ static void post_cdr(struct ast_cdr *cdr)
void ast_cdr_reset(struct ast_cdr *cdr, struct ast_flags *_flags) void ast_cdr_reset(struct ast_cdr *cdr, struct ast_flags *_flags)
{ {
struct ast_cdr *dup; struct ast_cdr *duplicate;
struct ast_flags flags = { 0 }; struct ast_flags flags = { 0 };
if (_flags) if (_flags)
@ -1045,8 +1045,8 @@ void ast_cdr_reset(struct ast_cdr *cdr, struct ast_flags *_flags)
if (ast_test_flag(&flags, AST_CDR_FLAG_LOCKED) || !ast_test_flag(cdr, AST_CDR_FLAG_LOCKED)) { if (ast_test_flag(&flags, AST_CDR_FLAG_LOCKED) || !ast_test_flag(cdr, AST_CDR_FLAG_LOCKED)) {
if (ast_test_flag(&flags, AST_CDR_FLAG_POSTED)) { if (ast_test_flag(&flags, AST_CDR_FLAG_POSTED)) {
ast_cdr_end(cdr); ast_cdr_end(cdr);
if ((dup = ast_cdr_dup(cdr))) { if ((duplicate = ast_cdr_dup(cdr))) {
ast_cdr_detach(dup); ast_cdr_detach(duplicate);
} }
ast_set_flag(cdr, AST_CDR_FLAG_POSTED); ast_set_flag(cdr, AST_CDR_FLAG_POSTED);
} }
@ -1150,7 +1150,7 @@ static void *do_batch_backend_process(void *data)
return NULL; return NULL;
} }
void ast_cdr_submit_batch(int shutdown) void ast_cdr_submit_batch(int do_shutdown)
{ {
struct ast_cdr_batch_item *oldbatchitems = NULL; struct ast_cdr_batch_item *oldbatchitems = NULL;
pthread_t batch_post_thread = AST_PTHREADT_NULL; pthread_t batch_post_thread = AST_PTHREADT_NULL;
@ -1167,7 +1167,7 @@ void ast_cdr_submit_batch(int shutdown)
/* if configured, spawn a new thread to post these CDRs, /* if configured, spawn a new thread to post these CDRs,
also try to save as much as possible if we are shutting down safely */ also try to save as much as possible if we are shutting down safely */
if (batchscheduleronly || shutdown) { if (batchscheduleronly || do_shutdown) {
ast_debug(1, "CDR single-threaded batch processing begins now\n"); ast_debug(1, "CDR single-threaded batch processing begins now\n");
do_batch_backend_process(oldbatchitems); do_batch_backend_process(oldbatchitems);
} else { } else {

@ -529,8 +529,8 @@ void ast_channel_setwhentohangup_tv(struct ast_channel *chan, struct timeval off
void ast_channel_setwhentohangup(struct ast_channel *chan, time_t offset) void ast_channel_setwhentohangup(struct ast_channel *chan, time_t offset)
{ {
struct timeval tv = { offset, }; struct timeval when = { offset, };
ast_channel_setwhentohangup_tv(chan, tv); ast_channel_setwhentohangup_tv(chan, when);
} }
/*! \brief Compare a offset with when to hangup channel */ /*! \brief Compare a offset with when to hangup channel */
@ -1540,16 +1540,16 @@ int ast_softhangup(struct ast_channel *chan, int cause)
return res; return res;
} }
static void free_translation(struct ast_channel *clone) static void free_translation(struct ast_channel *clonechan)
{ {
if (clone->writetrans) if (clonechan->writetrans)
ast_translator_free_path(clone->writetrans); ast_translator_free_path(clonechan->writetrans);
if (clone->readtrans) if (clonechan->readtrans)
ast_translator_free_path(clone->readtrans); ast_translator_free_path(clonechan->readtrans);
clone->writetrans = NULL; clonechan->writetrans = NULL;
clone->readtrans = NULL; clonechan->readtrans = NULL;
clone->rawwriteformat = clone->nativeformats; clonechan->rawwriteformat = clonechan->nativeformats;
clone->rawreadformat = clone->nativeformats; clonechan->rawreadformat = clonechan->nativeformats;
} }
/*! \brief Hangup a channel */ /*! \brief Hangup a channel */
@ -3617,17 +3617,17 @@ int ast_channel_make_compatible(struct ast_channel *chan, struct ast_channel *pe
return rc; return rc;
} }
int ast_channel_masquerade(struct ast_channel *original, struct ast_channel *clone) int ast_channel_masquerade(struct ast_channel *original, struct ast_channel *clonechan)
{ {
int res = -1; int res = -1;
struct ast_channel *final_orig, *final_clone, *base; struct ast_channel *final_orig, *final_clone, *base;
retrymasq: retrymasq:
final_orig = original; final_orig = original;
final_clone = clone; final_clone = clonechan;
ast_channel_lock(original); ast_channel_lock(original);
while (ast_channel_trylock(clone)) { while (ast_channel_trylock(clonechan)) {
ast_channel_unlock(original); ast_channel_unlock(original);
usleep(1); usleep(1);
ast_channel_lock(original); ast_channel_lock(original);
@ -3638,59 +3638,59 @@ retrymasq:
if (original->_bridge && (original->_bridge != ast_bridged_channel(original)) && (original->_bridge->_bridge != original)) if (original->_bridge && (original->_bridge != ast_bridged_channel(original)) && (original->_bridge->_bridge != original))
final_orig = original->_bridge; final_orig = original->_bridge;
if (clone->_bridge && (clone->_bridge != ast_bridged_channel(clone)) && (clone->_bridge->_bridge != clone)) if (clonechan->_bridge && (clonechan->_bridge != ast_bridged_channel(clonechan)) && (clonechan->_bridge->_bridge != clonechan))
final_clone = clone->_bridge; final_clone = clonechan->_bridge;
if (final_clone->tech->get_base_channel && (base = final_clone->tech->get_base_channel(final_clone))) { if (final_clone->tech->get_base_channel && (base = final_clone->tech->get_base_channel(final_clone))) {
final_clone = base; final_clone = base;
} }
if ((final_orig != original) || (final_clone != clone)) { if ((final_orig != original) || (final_clone != clonechan)) {
/* Lots and lots of deadlock avoidance. The main one we're competing with /* Lots and lots of deadlock avoidance. The main one we're competing with
* is ast_write(), which locks channels recursively, when working with a * is ast_write(), which locks channels recursively, when working with a
* proxy channel. */ * proxy channel. */
if (ast_channel_trylock(final_orig)) { if (ast_channel_trylock(final_orig)) {
ast_channel_unlock(clone); ast_channel_unlock(clonechan);
ast_channel_unlock(original); ast_channel_unlock(original);
goto retrymasq; goto retrymasq;
} }
if (ast_channel_trylock(final_clone)) { if (ast_channel_trylock(final_clone)) {
ast_channel_unlock(final_orig); ast_channel_unlock(final_orig);
ast_channel_unlock(clone); ast_channel_unlock(clonechan);
ast_channel_unlock(original); ast_channel_unlock(original);
goto retrymasq; goto retrymasq;
} }
ast_channel_unlock(clone); ast_channel_unlock(clonechan);
ast_channel_unlock(original); ast_channel_unlock(original);
original = final_orig; original = final_orig;
clone = final_clone; clonechan = final_clone;
} }
if (original == clone) { if (original == clonechan) {
ast_log(LOG_WARNING, "Can't masquerade channel '%s' into itself!\n", original->name); ast_log(LOG_WARNING, "Can't masquerade channel '%s' into itself!\n", original->name);
ast_channel_unlock(clone); ast_channel_unlock(clonechan);
ast_channel_unlock(original); ast_channel_unlock(original);
return -1; return -1;
} }
ast_debug(1, "Planning to masquerade channel %s into the structure of %s\n", ast_debug(1, "Planning to masquerade channel %s into the structure of %s\n",
clone->name, original->name); clonechan->name, original->name);
if (original->masq) { if (original->masq) {
ast_log(LOG_WARNING, "%s is already going to masquerade as %s\n", ast_log(LOG_WARNING, "%s is already going to masquerade as %s\n",
original->masq->name, original->name); original->masq->name, original->name);
} else if (clone->masqr) { } else if (clonechan->masqr) {
ast_log(LOG_WARNING, "%s is already going to masquerade as %s\n", ast_log(LOG_WARNING, "%s is already going to masquerade as %s\n",
clone->name, clone->masqr->name); clonechan->name, clonechan->masqr->name);
} else { } else {
original->masq = clone; original->masq = clonechan;
clone->masqr = original; clonechan->masqr = original;
ast_queue_frame(original, &ast_null_frame); ast_queue_frame(original, &ast_null_frame);
ast_queue_frame(clone, &ast_null_frame); ast_queue_frame(clonechan, &ast_null_frame);
ast_debug(1, "Done planning to masquerade channel %s into the structure of %s\n", clone->name, original->name); ast_debug(1, "Done planning to masquerade channel %s into the structure of %s\n", clonechan->name, original->name);
res = 0; res = 0;
} }
ast_channel_unlock(clone); ast_channel_unlock(clonechan);
ast_channel_unlock(original); ast_channel_unlock(original);
return res; return res;
@ -3751,20 +3751,20 @@ void ast_channel_inherit_variables(const struct ast_channel *parent, struct ast_
\note Assumes locks will be in place on both channels when called. \note Assumes locks will be in place on both channels when called.
*/ */
static void clone_variables(struct ast_channel *original, struct ast_channel *clone) static void clone_variables(struct ast_channel *original, struct ast_channel *clonechan)
{ {
struct ast_var_t *current, *newvar; struct ast_var_t *current, *newvar;
/* Append variables from clone channel into original channel */ /* Append variables from clone channel into original channel */
/* XXX Is this always correct? We have to in order to keep MACROS working XXX */ /* XXX Is this always correct? We have to in order to keep MACROS working XXX */
if (AST_LIST_FIRST(&clone->varshead)) if (AST_LIST_FIRST(&clonechan->varshead))
AST_LIST_APPEND_LIST(&original->varshead, &clone->varshead, entries); AST_LIST_APPEND_LIST(&original->varshead, &clonechan->varshead, entries);
/* then, dup the varshead list into the clone */ /* then, dup the varshead list into the clone */
AST_LIST_TRAVERSE(&original->varshead, current, entries) { AST_LIST_TRAVERSE(&original->varshead, current, entries) {
newvar = ast_var_assign(current->name, current->value); newvar = ast_var_assign(current->name, current->value);
if (newvar) if (newvar)
AST_LIST_INSERT_TAIL(&clone->varshead, newvar, entries); AST_LIST_INSERT_TAIL(&clonechan->varshead, newvar, entries);
} }
} }
@ -3778,11 +3778,11 @@ int ast_do_masquerade(struct ast_channel *original)
int x,i; int x,i;
int res=0; int res=0;
int origstate; int origstate;
struct ast_frame *cur; struct ast_frame *current;
const struct ast_channel_tech *t; const struct ast_channel_tech *t;
void *t_pvt; void *t_pvt;
struct ast_callerid tmpcid; struct ast_callerid tmpcid;
struct ast_channel *clone = original->masq; struct ast_channel *clonechan = original->masq;
struct ast_cdr *cdr; struct ast_cdr *cdr;
int rformat = original->readformat; int rformat = original->readformat;
int wformat = original->writeformat; int wformat = original->writeformat;
@ -3792,10 +3792,10 @@ int ast_do_masquerade(struct ast_channel *original)
char zombn[AST_CHANNEL_NAME]; char zombn[AST_CHANNEL_NAME];
ast_debug(4, "Actually Masquerading %s(%d) into the structure of %s(%d)\n", ast_debug(4, "Actually Masquerading %s(%d) into the structure of %s(%d)\n",
clone->name, clone->_state, original->name, original->_state); clonechan->name, clonechan->_state, original->name, original->_state);
manager_event(EVENT_FLAG_CALL, "Masquerade", "Clone: %s\r\nCloneState: %s\r\nOriginal: %s\r\nOriginalState: %s\r\n", manager_event(EVENT_FLAG_CALL, "Masquerade", "Clone: %s\r\nCloneState: %s\r\nOriginal: %s\r\nOriginalState: %s\r\n",
clone->name, ast_state2str(clone->_state), original->name, ast_state2str(original->_state)); clonechan->name, ast_state2str(clonechan->_state), original->name, ast_state2str(original->_state));
/* XXX This is a seriously wacked out operation. We're essentially putting the guts of /* XXX This is a seriously wacked out operation. We're essentially putting the guts of
the clone channel into the original channel. Start by killing off the original the clone channel into the original channel. Start by killing off the original
@ -3803,24 +3803,24 @@ int ast_do_masquerade(struct ast_channel *original)
while the features are nice, the cost is very high in terms of pure nastiness. XXX */ while the features are nice, the cost is very high in terms of pure nastiness. XXX */
/* We need the clone's lock, too */ /* We need the clone's lock, too */
ast_channel_lock(clone); ast_channel_lock(clonechan);
ast_debug(2, "Got clone lock for masquerade on '%s' at %p\n", clone->name, &clone->lock_dont_use); ast_debug(2, "Got clone lock for masquerade on '%s' at %p\n", clonechan->name, &clonechan->lock_dont_use);
/* Having remembered the original read/write formats, we turn off any translation on either /* Having remembered the original read/write formats, we turn off any translation on either
one */ one */
free_translation(clone); free_translation(clonechan);
free_translation(original); free_translation(original);
/* Unlink the masquerade */ /* Unlink the masquerade */
original->masq = NULL; original->masq = NULL;
clone->masqr = NULL; clonechan->masqr = NULL;
/* Save the original name */ /* Save the original name */
ast_copy_string(orig, original->name, sizeof(orig)); ast_copy_string(orig, original->name, sizeof(orig));
/* Save the new name */ /* Save the new name */
ast_copy_string(newn, clone->name, sizeof(newn)); ast_copy_string(newn, clonechan->name, sizeof(newn));
/* Create the masq name */ /* Create the masq name */
snprintf(masqn, sizeof(masqn), "%s<MASQ>", newn); snprintf(masqn, sizeof(masqn), "%s<MASQ>", newn);
@ -3828,31 +3828,31 @@ int ast_do_masquerade(struct ast_channel *original)
ast_string_field_set(original, name, newn); ast_string_field_set(original, name, newn);
/* Mangle the name of the clone channel */ /* Mangle the name of the clone channel */
ast_string_field_set(clone, name, masqn); ast_string_field_set(clonechan, name, masqn);
/* Notify any managers of the change, first the masq then the other */ /* Notify any managers of the change, first the masq then the other */
manager_event(EVENT_FLAG_CALL, "Rename", "Channel: %s\r\nNewname: %s\r\nUniqueid: %s\r\n", newn, masqn, clone->uniqueid); manager_event(EVENT_FLAG_CALL, "Rename", "Channel: %s\r\nNewname: %s\r\nUniqueid: %s\r\n", newn, masqn, clonechan->uniqueid);
manager_event(EVENT_FLAG_CALL, "Rename", "Channel: %s\r\nNewname: %s\r\nUniqueid: %s\r\n", orig, newn, original->uniqueid); manager_event(EVENT_FLAG_CALL, "Rename", "Channel: %s\r\nNewname: %s\r\nUniqueid: %s\r\n", orig, newn, original->uniqueid);
/* Swap the technologies */ /* Swap the technologies */
t = original->tech; t = original->tech;
original->tech = clone->tech; original->tech = clonechan->tech;
clone->tech = t; clonechan->tech = t;
/* Swap the cdrs */ /* Swap the cdrs */
cdr = original->cdr; cdr = original->cdr;
original->cdr = clone->cdr; original->cdr = clonechan->cdr;
clone->cdr = cdr; clonechan->cdr = cdr;
t_pvt = original->tech_pvt; t_pvt = original->tech_pvt;
original->tech_pvt = clone->tech_pvt; original->tech_pvt = clonechan->tech_pvt;
clone->tech_pvt = t_pvt; clonechan->tech_pvt = t_pvt;
/* Swap the alertpipes */ /* Swap the alertpipes */
for (i = 0; i < 2; i++) { for (i = 0; i < 2; i++) {
x = original->alertpipe[i]; x = original->alertpipe[i];
original->alertpipe[i] = clone->alertpipe[i]; original->alertpipe[i] = clonechan->alertpipe[i];
clone->alertpipe[i] = x; clonechan->alertpipe[i] = x;
} }
/* /*
@ -3871,10 +3871,10 @@ int ast_do_masquerade(struct ast_channel *original)
AST_LIST_HEAD_SET_NOLOCK(&tmp_readq, NULL); AST_LIST_HEAD_SET_NOLOCK(&tmp_readq, NULL);
AST_LIST_APPEND_LIST(&tmp_readq, &original->readq, frame_list); AST_LIST_APPEND_LIST(&tmp_readq, &original->readq, frame_list);
AST_LIST_APPEND_LIST(&original->readq, &clone->readq, frame_list); AST_LIST_APPEND_LIST(&original->readq, &clonechan->readq, frame_list);
while ((cur = AST_LIST_REMOVE_HEAD(&tmp_readq, frame_list))) { while ((current = AST_LIST_REMOVE_HEAD(&tmp_readq, frame_list))) {
AST_LIST_INSERT_TAIL(&original->readq, cur, frame_list); AST_LIST_INSERT_TAIL(&original->readq, current, frame_list);
if (original->alertpipe[1] > -1) { if (original->alertpipe[1] > -1) {
int poke = 0; int poke = 0;
write(original->alertpipe[1], &poke, sizeof(poke)); write(original->alertpipe[1], &poke, sizeof(poke));
@ -3884,77 +3884,77 @@ int ast_do_masquerade(struct ast_channel *original)
/* Swap the raw formats */ /* Swap the raw formats */
x = original->rawreadformat; x = original->rawreadformat;
original->rawreadformat = clone->rawreadformat; original->rawreadformat = clonechan->rawreadformat;
clone->rawreadformat = x; clonechan->rawreadformat = x;
x = original->rawwriteformat; x = original->rawwriteformat;
original->rawwriteformat = clone->rawwriteformat; original->rawwriteformat = clonechan->rawwriteformat;
clone->rawwriteformat = x; clonechan->rawwriteformat = x;
clone->_softhangup = AST_SOFTHANGUP_DEV; clonechan->_softhangup = AST_SOFTHANGUP_DEV;
/* And of course, so does our current state. Note we need not /* And of course, so does our current state. Note we need not
call ast_setstate since the event manager doesn't really consider call ast_setstate since the event manager doesn't really consider
these separate. We do this early so that the clone has the proper these separate. We do this early so that the clone has the proper
state of the original channel. */ state of the original channel. */
origstate = original->_state; origstate = original->_state;
original->_state = clone->_state; original->_state = clonechan->_state;
clone->_state = origstate; clonechan->_state = origstate;
if (clone->tech->fixup){ if (clonechan->tech->fixup){
res = clone->tech->fixup(original, clone); res = clonechan->tech->fixup(original, clonechan);
if (res) if (res)
ast_log(LOG_WARNING, "Fixup failed on channel %s, strange things may happen.\n", clone->name); ast_log(LOG_WARNING, "Fixup failed on channel %s, strange things may happen.\n", clonechan->name);
} }
/* Start by disconnecting the original's physical side */ /* Start by disconnecting the original's physical side */
if (clone->tech->hangup) if (clonechan->tech->hangup)
res = clone->tech->hangup(clone); res = clonechan->tech->hangup(clonechan);
if (res) { if (res) {
ast_log(LOG_WARNING, "Hangup failed! Strange things may happen!\n"); ast_log(LOG_WARNING, "Hangup failed! Strange things may happen!\n");
ast_channel_unlock(clone); ast_channel_unlock(clonechan);
return -1; return -1;
} }
snprintf(zombn, sizeof(zombn), "%s<ZOMBIE>", orig); snprintf(zombn, sizeof(zombn), "%s<ZOMBIE>", orig);
/* Mangle the name of the clone channel */ /* Mangle the name of the clone channel */
ast_string_field_set(clone, name, zombn); ast_string_field_set(clonechan, name, zombn);
manager_event(EVENT_FLAG_CALL, "Rename", "Channel: %s\r\nNewname: %s\r\nUniqueid: %s\r\n", masqn, zombn, clone->uniqueid); manager_event(EVENT_FLAG_CALL, "Rename", "Channel: %s\r\nNewname: %s\r\nUniqueid: %s\r\n", masqn, zombn, clonechan->uniqueid);
/* Update the type. */ /* Update the type. */
t_pvt = original->monitor; t_pvt = original->monitor;
original->monitor = clone->monitor; original->monitor = clonechan->monitor;
clone->monitor = t_pvt; clonechan->monitor = t_pvt;
/* Keep the same language. */ /* Keep the same language. */
ast_string_field_set(original, language, clone->language); ast_string_field_set(original, language, clonechan->language);
/* Copy the FD's other than the generator fd */ /* Copy the FD's other than the generator fd */
for (x = 0; x < AST_MAX_FDS; x++) { for (x = 0; x < AST_MAX_FDS; x++) {
if (x != AST_GENERATOR_FD) if (x != AST_GENERATOR_FD)
ast_channel_set_fd(original, x, clone->fds[x]); ast_channel_set_fd(original, x, clonechan->fds[x]);
} }
ast_app_group_update(clone, original); ast_app_group_update(clonechan, original);
/* Move data stores over */ /* Move data stores over */
if (AST_LIST_FIRST(&clone->datastores)) { if (AST_LIST_FIRST(&clonechan->datastores)) {
struct ast_datastore *ds; struct ast_datastore *ds;
AST_LIST_APPEND_LIST(&original->datastores, &clone->datastores, entry); AST_LIST_APPEND_LIST(&original->datastores, &clonechan->datastores, entry);
AST_LIST_TRAVERSE(&original->datastores, ds, entry) { AST_LIST_TRAVERSE(&original->datastores, ds, entry) {
if (ds->info->chan_fixup) if (ds->info->chan_fixup)
ds->info->chan_fixup(ds->data, clone, original); ds->info->chan_fixup(ds->data, clonechan, original);
} }
} }
clone_variables(original, clone); clone_variables(original, clonechan);
/* Presense of ADSI capable CPE follows clone */ /* Presense of ADSI capable CPE follows clone */
original->adsicpe = clone->adsicpe; original->adsicpe = clonechan->adsicpe;
/* Bridge remains the same */ /* Bridge remains the same */
/* CDR fields remain the same */ /* CDR fields remain the same */
/* XXX What about blocking, softhangup, blocker, and lock and blockproc? XXX */ /* XXX What about blocking, softhangup, blocker, and lock and blockproc? XXX */
/* Application and data remain the same */ /* Application and data remain the same */
/* Clone exception becomes real one, as with fdno */ /* Clone exception becomes real one, as with fdno */
ast_copy_flags(original, clone, AST_FLAG_EXCEPTION); ast_copy_flags(original, clonechan, AST_FLAG_EXCEPTION);
original->fdno = clone->fdno; original->fdno = clonechan->fdno;
/* Schedule context remains the same */ /* Schedule context remains the same */
/* Stream stuff stays the same */ /* Stream stuff stays the same */
/* Keep the original state. The fixup code will need to work with it most likely */ /* Keep the original state. The fixup code will need to work with it most likely */
@ -3962,14 +3962,14 @@ int ast_do_masquerade(struct ast_channel *original)
/* Just swap the whole structures, nevermind the allocations, they'll work themselves /* Just swap the whole structures, nevermind the allocations, they'll work themselves
out. */ out. */
tmpcid = original->cid; tmpcid = original->cid;
original->cid = clone->cid; original->cid = clonechan->cid;
clone->cid = tmpcid; clonechan->cid = tmpcid;
/* Restore original timing file descriptor */ /* Restore original timing file descriptor */
ast_channel_set_fd(original, AST_TIMING_FD, original->timingfd); ast_channel_set_fd(original, AST_TIMING_FD, original->timingfd);
/* Our native formats are different now */ /* Our native formats are different now */
original->nativeformats = clone->nativeformats; original->nativeformats = clonechan->nativeformats;
/* Context, extension, priority, app data, jump table, remain the same */ /* Context, extension, priority, app data, jump table, remain the same */
/* pvt switches. pbx stays the same, as does next */ /* pvt switches. pbx stays the same, as does next */
@ -3981,18 +3981,18 @@ int ast_do_masquerade(struct ast_channel *original)
ast_set_read_format(original, rformat); ast_set_read_format(original, rformat);
/* Copy the music class */ /* Copy the music class */
ast_string_field_set(original, musicclass, clone->musicclass); ast_string_field_set(original, musicclass, clonechan->musicclass);
ast_debug(1, "Putting channel %s in %d/%d formats\n", original->name, wformat, rformat); ast_debug(1, "Putting channel %s in %d/%d formats\n", original->name, wformat, rformat);
/* Okay. Last thing is to let the channel driver know about all this mess, so he /* Okay. Last thing is to let the channel driver know about all this mess, so he
can fix up everything as best as possible */ can fix up everything as best as possible */
if (original->tech->fixup) { if (original->tech->fixup) {
res = original->tech->fixup(clone, original); res = original->tech->fixup(clonechan, original);
if (res) { if (res) {
ast_log(LOG_WARNING, "Channel for type '%s' could not fixup channel %s\n", ast_log(LOG_WARNING, "Channel for type '%s' could not fixup channel %s\n",
original->tech->type, original->name); original->tech->type, original->name);
ast_channel_unlock(clone); ast_channel_unlock(clonechan);
return -1; return -1;
} }
} else } else
@ -4006,25 +4006,25 @@ int ast_do_masquerade(struct ast_channel *original)
/* Now, at this point, the "clone" channel is totally F'd up. We mark it as /* Now, at this point, the "clone" channel is totally F'd up. We mark it as
a zombie so nothing tries to touch it. If it's already been marked as a a zombie so nothing tries to touch it. If it's already been marked as a
zombie, then free it now (since it already is considered invalid). */ zombie, then free it now (since it already is considered invalid). */
if (ast_test_flag(clone, AST_FLAG_ZOMBIE)) { if (ast_test_flag(clonechan, AST_FLAG_ZOMBIE)) {
ast_debug(1, "Destroying channel clone '%s'\n", clone->name); ast_debug(1, "Destroying channel clone '%s'\n", clonechan->name);
ast_channel_unlock(clone); ast_channel_unlock(clonechan);
manager_event(EVENT_FLAG_CALL, "Hangup", manager_event(EVENT_FLAG_CALL, "Hangup",
"Channel: %s\r\n" "Channel: %s\r\n"
"Uniqueid: %s\r\n" "Uniqueid: %s\r\n"
"Cause: %d\r\n" "Cause: %d\r\n"
"Cause-txt: %s\r\n", "Cause-txt: %s\r\n",
clone->name, clonechan->name,
clone->uniqueid, clonechan->uniqueid,
clone->hangupcause, clonechan->hangupcause,
ast_cause2str(clone->hangupcause) ast_cause2str(clonechan->hangupcause)
); );
ast_channel_free(clone); ast_channel_free(clonechan);
} else { } else {
ast_debug(1, "Released clone lock on '%s'\n", clone->name); ast_debug(1, "Released clone lock on '%s'\n", clonechan->name);
ast_set_flag(clone, AST_FLAG_ZOMBIE); ast_set_flag(clonechan, AST_FLAG_ZOMBIE);
ast_queue_frame(clone, &ast_null_frame); ast_queue_frame(clonechan, &ast_null_frame);
ast_channel_unlock(clone); ast_channel_unlock(clonechan);
} }
/* Signal any blocker */ /* Signal any blocker */

@ -1060,10 +1060,10 @@ static int process_text_line(struct ast_config *cfg, struct ast_category **cat,
/* #exec </path/to/executable> /* #exec </path/to/executable>
We create a tmp file, then we #include it, then we delete it. */ We create a tmp file, then we #include it, then we delete it. */
if (!do_include) { if (!do_include) {
struct timeval tv = ast_tvnow(); struct timeval now = ast_tvnow();
if (!ast_test_flag(&flags, CONFIG_FLAG_NOCACHE)) if (!ast_test_flag(&flags, CONFIG_FLAG_NOCACHE))
config_cache_attribute(configfile, ATTRIBUTE_EXEC, NULL, who_asked); config_cache_attribute(configfile, ATTRIBUTE_EXEC, NULL, who_asked);
snprintf(exec_file, sizeof(exec_file), "/var/tmp/exec.%d%d.%ld", (int)tv.tv_sec, (int)tv.tv_usec, (long)pthread_self()); snprintf(exec_file, sizeof(exec_file), "/var/tmp/exec.%d%d.%ld", (int)now.tv_sec, (int)now.tv_usec, (long)pthread_self());
snprintf(cmd, sizeof(cmd), "%s > %s 2>&1", cur, exec_file); snprintf(cmd, sizeof(cmd), "%s > %s 2>&1", cur, exec_file);
ast_safe_system(cmd); ast_safe_system(cmd);
cur = exec_file; cur = exec_file;
@ -1260,17 +1260,17 @@ static struct ast_config *config_text_file_load(const char *database, const char
* incorrectly cause no reload to be necessary. */ * incorrectly cause no reload to be necessary. */
char fn2[256]; char fn2[256];
#ifdef AST_INCLUDE_GLOB #ifdef AST_INCLUDE_GLOB
int glob_ret; int glob_return;
glob_t globbuf = { .gl_offs = 0 }; glob_t glob_buf = { .gl_offs = 0 };
glob_ret = glob(cfinclude->include, MY_GLOB_FLAGS, NULL, &globbuf); glob_return = glob(cfinclude->include, MY_GLOB_FLAGS, NULL, &glob_buf);
/* On error, we reparse */ /* On error, we reparse */
if (glob_ret == GLOB_NOSPACE || glob_ret == GLOB_ABORTED) if (glob_return == GLOB_NOSPACE || glob_return == GLOB_ABORTED)
unchanged = 0; unchanged = 0;
else { else {
/* loop over expanded files */ /* loop over expanded files */
int j; int j;
for (j = 0; j < globbuf.gl_pathc; j++) { for (j = 0; j < glob_buf.gl_pathc; j++) {
ast_copy_string(fn2, globbuf.gl_pathv[j], sizeof(fn2)); ast_copy_string(fn2, glob_buf.gl_pathv[j], sizeof(fn2));
#else #else
ast_copy_string(fn2, cfinclude->include); ast_copy_string(fn2, cfinclude->include);
#endif #endif
@ -1387,9 +1387,9 @@ static struct ast_config *config_text_file_load(const char *database, const char
} }
if (process_buf) { if (process_buf) {
char *buf = ast_strip(process_buf); char *buffer = ast_strip(process_buf);
if (!ast_strlen_zero(buf)) { if (!ast_strlen_zero(buffer)) {
if (process_text_line(cfg, &cat, buf, lineno, fn, flags, comment_buffer, lline_buffer, suggested_include_file, &last_cat, &last_var, who_asked)) { if (process_text_line(cfg, &cat, buffer, lineno, fn, flags, comment_buffer, lline_buffer, suggested_include_file, &last_cat, &last_var, who_asked)) {
cfg = NULL; cfg = NULL;
break; break;
} }

@ -150,7 +150,7 @@ __bt_stkacq(t, hp, c)
EPG *e; EPG *e;
EPGNO *parent; EPGNO *parent;
PAGE *h; PAGE *h;
indx_t index = 0; indx_t idx = 0;
pgno_t pgno; pgno_t pgno;
recno_t nextpg, prevpg; recno_t nextpg, prevpg;
int exact, level; int exact, level;
@ -188,8 +188,8 @@ __bt_stkacq(t, hp, c)
/* Move to the next index. */ /* Move to the next index. */
if (parent->index != NEXTINDEX(h) - 1) { if (parent->index != NEXTINDEX(h) - 1) {
index = parent->index + 1; idx = parent->index + 1;
BT_PUSH(t, h->pgno, index); BT_PUSH(t, h->pgno, idx);
break; break;
} }
mpool_put(t->bt_mp, h, 0); mpool_put(t->bt_mp, h, 0);
@ -198,7 +198,7 @@ __bt_stkacq(t, hp, c)
/* Restore the stack. */ /* Restore the stack. */
while (level--) { while (level--) {
/* Push the next level down onto the stack. */ /* Push the next level down onto the stack. */
bi = GETBINTERNAL(h, index); bi = GETBINTERNAL(h, idx);
pgno = bi->pgno; pgno = bi->pgno;
BT_PUSH(t, pgno, 0); BT_PUSH(t, pgno, 0);
@ -208,7 +208,7 @@ __bt_stkacq(t, hp, c)
/* Get the next level down. */ /* Get the next level down. */
if ((h = mpool_get(t->bt_mp, pgno, 0)) == NULL) if ((h = mpool_get(t->bt_mp, pgno, 0)) == NULL)
return (1); return (1);
index = 0; idx = 0;
} }
mpool_put(t->bt_mp, h, 0); mpool_put(t->bt_mp, h, 0);
if ((h = mpool_get(t->bt_mp, nextpg, 0)) == NULL) if ((h = mpool_get(t->bt_mp, nextpg, 0)) == NULL)
@ -243,8 +243,8 @@ __bt_stkacq(t, hp, c)
/* Move to the next index. */ /* Move to the next index. */
if (parent->index != 0) { if (parent->index != 0) {
index = parent->index - 1; idx = parent->index - 1;
BT_PUSH(t, h->pgno, index); BT_PUSH(t, h->pgno, idx);
break; break;
} }
mpool_put(t->bt_mp, h, 0); mpool_put(t->bt_mp, h, 0);
@ -253,7 +253,7 @@ __bt_stkacq(t, hp, c)
/* Restore the stack. */ /* Restore the stack. */
while (level--) { while (level--) {
/* Push the next level down onto the stack. */ /* Push the next level down onto the stack. */
bi = GETBINTERNAL(h, index); bi = GETBINTERNAL(h, idx);
pgno = bi->pgno; pgno = bi->pgno;
/* Lose the currently pinned page. */ /* Lose the currently pinned page. */
@ -263,8 +263,8 @@ __bt_stkacq(t, hp, c)
if ((h = mpool_get(t->bt_mp, pgno, 0)) == NULL) if ((h = mpool_get(t->bt_mp, pgno, 0)) == NULL)
return (1); return (1);
index = NEXTINDEX(h) - 1; idx = NEXTINDEX(h) - 1;
BT_PUSH(t, pgno, index); BT_PUSH(t, pgno, idx);
} }
mpool_put(t->bt_mp, h, 0); mpool_put(t->bt_mp, h, 0);
if ((h = mpool_get(t->bt_mp, prevpg, 0)) == NULL) if ((h = mpool_get(t->bt_mp, prevpg, 0)) == NULL)
@ -382,7 +382,7 @@ __bt_pdelete(t, h)
BINTERNAL *bi; BINTERNAL *bi;
PAGE *pg; PAGE *pg;
EPGNO *parent; EPGNO *parent;
indx_t cnt, index, *ip, offset; indx_t cnt, idx, *ip, offset;
u_int32_t nksize; u_int32_t nksize;
char *from; char *from;
@ -403,8 +403,8 @@ __bt_pdelete(t, h)
if ((pg = mpool_get(t->bt_mp, parent->pgno, 0)) == NULL) if ((pg = mpool_get(t->bt_mp, parent->pgno, 0)) == NULL)
return (RET_ERROR); return (RET_ERROR);
index = parent->index; idx = parent->index;
bi = GETBINTERNAL(pg, index); bi = GETBINTERNAL(pg, idx);
/* Free any overflow pages. */ /* Free any overflow pages. */
if (bi->flags & P_BIGKEY && if (bi->flags & P_BIGKEY &&
@ -436,11 +436,11 @@ __bt_pdelete(t, h)
pg->upper += nksize; pg->upper += nksize;
/* Adjust indices' offsets, shift the indices down. */ /* Adjust indices' offsets, shift the indices down. */
offset = pg->linp[index]; offset = pg->linp[idx];
for (cnt = index, ip = &pg->linp[0]; cnt--; ++ip) for (cnt = idx, ip = &pg->linp[0]; cnt--; ++ip)
if (ip[0] < offset) if (ip[0] < offset)
ip[0] += nksize; ip[0] += nksize;
for (cnt = NEXTINDEX(pg) - index; --cnt; ++ip) for (cnt = NEXTINDEX(pg) - idx; --cnt; ++ip)
ip[0] = ip[1] < offset ? ip[1] + nksize : ip[1]; ip[0] = ip[1] < offset ? ip[1] + nksize : ip[1];
pg->lower -= sizeof(indx_t); pg->lower -= sizeof(indx_t);
} }
@ -471,11 +471,11 @@ __bt_pdelete(t, h)
* RET_SUCCESS, RET_ERROR. * RET_SUCCESS, RET_ERROR.
*/ */
int int
__bt_dleaf(t, key, h, index) __bt_dleaf(t, key, h, idx)
BTREE *t; BTREE *t;
const DBT *key; const DBT *key;
PAGE *h; PAGE *h;
u_int index; u_int idx;
{ {
BLEAF *bl; BLEAF *bl;
indx_t cnt, *ip, offset; indx_t cnt, *ip, offset;
@ -486,12 +486,12 @@ __bt_dleaf(t, key, h, index)
/* If this record is referenced by the cursor, delete the cursor. */ /* If this record is referenced by the cursor, delete the cursor. */
if (F_ISSET(&t->bt_cursor, CURS_INIT) && if (F_ISSET(&t->bt_cursor, CURS_INIT) &&
!F_ISSET(&t->bt_cursor, CURS_ACQUIRE) && !F_ISSET(&t->bt_cursor, CURS_ACQUIRE) &&
t->bt_cursor.pg.pgno == h->pgno && t->bt_cursor.pg.index == index && t->bt_cursor.pg.pgno == h->pgno && t->bt_cursor.pg.index == idx &&
__bt_curdel(t, key, h, index)) __bt_curdel(t, key, h, idx))
return (RET_ERROR); return (RET_ERROR);
/* If the entry uses overflow pages, make them available for reuse. */ /* If the entry uses overflow pages, make them available for reuse. */
to = bl = GETBLEAF(h, index); to = bl = GETBLEAF(h, idx);
if (bl->flags & P_BIGKEY && __ovfl_delete(t, bl->bytes) == RET_ERROR) if (bl->flags & P_BIGKEY && __ovfl_delete(t, bl->bytes) == RET_ERROR)
return (RET_ERROR); return (RET_ERROR);
if (bl->flags & P_BIGDATA && if (bl->flags & P_BIGDATA &&
@ -505,18 +505,18 @@ __bt_dleaf(t, key, h, index)
h->upper += nbytes; h->upper += nbytes;
/* Adjust the indices' offsets, shift the indices down. */ /* Adjust the indices' offsets, shift the indices down. */
offset = h->linp[index]; offset = h->linp[idx];
for (cnt = index, ip = &h->linp[0]; cnt--; ++ip) for (cnt = idx, ip = &h->linp[0]; cnt--; ++ip)
if (ip[0] < offset) if (ip[0] < offset)
ip[0] += nbytes; ip[0] += nbytes;
for (cnt = NEXTINDEX(h) - index; --cnt; ++ip) for (cnt = NEXTINDEX(h) - idx; --cnt; ++ip)
ip[0] = ip[1] < offset ? ip[1] + nbytes : ip[1]; ip[0] = ip[1] < offset ? ip[1] + nbytes : ip[1];
h->lower -= sizeof(indx_t); h->lower -= sizeof(indx_t);
/* If the cursor is on this page, adjust it as necessary. */ /* If the cursor is on this page, adjust it as necessary. */
if (F_ISSET(&t->bt_cursor, CURS_INIT) && if (F_ISSET(&t->bt_cursor, CURS_INIT) &&
!F_ISSET(&t->bt_cursor, CURS_ACQUIRE) && !F_ISSET(&t->bt_cursor, CURS_ACQUIRE) &&
t->bt_cursor.pg.pgno == h->pgno && t->bt_cursor.pg.index > index) t->bt_cursor.pg.pgno == h->pgno && t->bt_cursor.pg.index > idx)
--t->bt_cursor.pg.index; --t->bt_cursor.pg.index;
return (RET_SUCCESS); return (RET_SUCCESS);
@ -536,11 +536,11 @@ __bt_dleaf(t, key, h, index)
* RET_SUCCESS, RET_ERROR. * RET_SUCCESS, RET_ERROR.
*/ */
static int static int
__bt_curdel(t, key, h, index) __bt_curdel(t, key, h, idx)
BTREE *t; BTREE *t;
const DBT *key; const DBT *key;
PAGE *h; PAGE *h;
u_int index; u_int idx;
{ {
CURSOR *c; CURSOR *c;
EPG e; EPG e;
@ -563,7 +563,7 @@ __bt_curdel(t, key, h, index)
*/ */
if (key == NULL) { if (key == NULL) {
e.page = h; e.page = h;
e.index = index; e.index = idx;
if ((status = __bt_ret(t, &e, if ((status = __bt_ret(t, &e,
&c->key, &c->key, NULL, NULL, 1)) != RET_SUCCESS) &c->key, &c->key, NULL, NULL, 1)) != RET_SUCCESS)
return (status); return (status);
@ -571,25 +571,25 @@ __bt_curdel(t, key, h, index)
key = &c->key; key = &c->key;
} }
/* Check previous key, if not at the beginning of the page. */ /* Check previous key, if not at the beginning of the page. */
if (index > 0) { if (idx > 0) {
e.page = h; e.page = h;
e.index = index - 1; e.index = idx - 1;
if (__bt_cmp(t, key, &e) == 0) { if (__bt_cmp(t, key, &e) == 0) {
F_SET(c, CURS_BEFORE); F_SET(c, CURS_BEFORE);
goto dup2; goto dup2;
} }
} }
/* Check next key, if not at the end of the page. */ /* Check next key, if not at the end of the page. */
if (index < NEXTINDEX(h) - 1) { if (idx < NEXTINDEX(h) - 1) {
e.page = h; e.page = h;
e.index = index + 1; e.index = idx + 1;
if (__bt_cmp(t, key, &e) == 0) { if (__bt_cmp(t, key, &e) == 0) {
F_SET(c, CURS_AFTER); F_SET(c, CURS_AFTER);
goto dup2; goto dup2;
} }
} }
/* Check previous key if at the beginning of the page. */ /* Check previous key if at the beginning of the page. */
if (index == 0 && h->prevpg != P_INVALID) { if (idx == 0 && h->prevpg != P_INVALID) {
if ((pg = mpool_get(t->bt_mp, h->prevpg, 0)) == NULL) if ((pg = mpool_get(t->bt_mp, h->prevpg, 0)) == NULL)
return (RET_ERROR); return (RET_ERROR);
e.page = pg; e.page = pg;
@ -601,7 +601,7 @@ __bt_curdel(t, key, h, index)
mpool_put(t->bt_mp, pg, 0); mpool_put(t->bt_mp, pg, 0);
} }
/* Check next key if at the end of the page. */ /* Check next key if at the end of the page. */
if (index == NEXTINDEX(h) - 1 && h->nextpg != P_INVALID) { if (idx == NEXTINDEX(h) - 1 && h->nextpg != P_INVALID) {
if ((pg = mpool_get(t->bt_mp, h->nextpg, 0)) == NULL) if ((pg = mpool_get(t->bt_mp, h->nextpg, 0)) == NULL)
return (RET_ERROR); return (RET_ERROR);
e.page = pg; e.page = pg;
@ -617,7 +617,7 @@ dup2: c->pg.pgno = e.page->pgno;
} }
} }
e.page = h; e.page = h;
e.index = index; e.index = idx;
if (curcopy || (status = if (curcopy || (status =
__bt_ret(t, &e, &c->key, &c->key, NULL, NULL, 1)) == RET_SUCCESS) { __bt_ret(t, &e, &c->key, &c->key, NULL, NULL, 1)) == RET_SUCCESS) {
F_SET(c, CURS_ACQUIRE); F_SET(c, CURS_ACQUIRE);

@ -74,7 +74,7 @@ __bt_put(dbp, key, data, flags)
DBT tkey, tdata; DBT tkey, tdata;
EPG *e = 0; EPG *e = 0;
PAGE *h; PAGE *h;
indx_t index, nxtindex; indx_t idx, nxtindex;
pgno_t pg; pgno_t pg;
u_int32_t nbytes; u_int32_t nbytes;
int dflags, exact, status; int dflags, exact, status;
@ -153,7 +153,7 @@ storekey: if (__ovfl_put(t, key, &pg) == RET_ERROR)
if (flags == R_CURSOR) { if (flags == R_CURSOR) {
if ((h = mpool_get(t->bt_mp, t->bt_cursor.pg.pgno, 0)) == NULL) if ((h = mpool_get(t->bt_mp, t->bt_cursor.pg.pgno, 0)) == NULL)
return (RET_ERROR); return (RET_ERROR);
index = t->bt_cursor.pg.index; idx = t->bt_cursor.pg.index;
goto delete; goto delete;
} }
@ -165,7 +165,7 @@ storekey: if (__ovfl_put(t, key, &pg) == RET_ERROR)
if ((e = __bt_search(t, key, &exact)) == NULL) if ((e = __bt_search(t, key, &exact)) == NULL)
return (RET_ERROR); return (RET_ERROR);
h = e->page; h = e->page;
index = e->index; idx = e->index;
/* /*
* Add the key/data pair to the tree. If an identical key is already * Add the key/data pair to the tree. If an identical key is already
@ -187,7 +187,7 @@ storekey: if (__ovfl_put(t, key, &pg) == RET_ERROR)
* Note, the delete may empty the page, so we need to put a * Note, the delete may empty the page, so we need to put a
* new entry into the page immediately. * new entry into the page immediately.
*/ */
delete: if (__bt_dleaf(t, key, h, index) == RET_ERROR) { delete: if (__bt_dleaf(t, key, h, idx) == RET_ERROR) {
mpool_put(t->bt_mp, h, 0); mpool_put(t->bt_mp, h, 0);
return (RET_ERROR); return (RET_ERROR);
} }
@ -203,35 +203,35 @@ delete: if (__bt_dleaf(t, key, h, index) == RET_ERROR) {
nbytes = NBLEAFDBT(key->size, data->size); nbytes = NBLEAFDBT(key->size, data->size);
if ((u_int32_t) (h->upper - h->lower) < nbytes + sizeof(indx_t)) { if ((u_int32_t) (h->upper - h->lower) < nbytes + sizeof(indx_t)) {
if ((status = __bt_split(t, h, key, if ((status = __bt_split(t, h, key,
data, dflags, nbytes, index)) != RET_SUCCESS) data, dflags, nbytes, idx)) != RET_SUCCESS)
return (status); return (status);
goto success; goto success;
} }
if (index < (nxtindex = NEXTINDEX(h))) if (idx < (nxtindex = NEXTINDEX(h)))
memmove(h->linp + index + 1, h->linp + index, memmove(h->linp + idx + 1, h->linp + idx,
(nxtindex - index) * sizeof(indx_t)); (nxtindex - idx) * sizeof(indx_t));
h->lower += sizeof(indx_t); h->lower += sizeof(indx_t);
h->linp[index] = h->upper -= nbytes; h->linp[idx] = h->upper -= nbytes;
dest = (char *)h + h->upper; dest = (char *)h + h->upper;
WR_BLEAF(dest, key, data, dflags); WR_BLEAF(dest, key, data, dflags);
/* If the cursor is on this page, adjust it as necessary. */ /* If the cursor is on this page, adjust it as necessary. */
if (F_ISSET(&t->bt_cursor, CURS_INIT) && if (F_ISSET(&t->bt_cursor, CURS_INIT) &&
!F_ISSET(&t->bt_cursor, CURS_ACQUIRE) && !F_ISSET(&t->bt_cursor, CURS_ACQUIRE) &&
t->bt_cursor.pg.pgno == h->pgno && t->bt_cursor.pg.index >= index) t->bt_cursor.pg.pgno == h->pgno && t->bt_cursor.pg.index >= idx)
++t->bt_cursor.pg.index; ++t->bt_cursor.pg.index;
if (t->bt_order == NOT) { if (t->bt_order == NOT) {
if (h->nextpg == P_INVALID) { if (h->nextpg == P_INVALID) {
if (index == NEXTINDEX(h) - 1) { if (idx == NEXTINDEX(h) - 1) {
t->bt_order = FORWARD; t->bt_order = FORWARD;
t->bt_last.index = index; t->bt_last.index = idx;
t->bt_last.pgno = h->pgno; t->bt_last.pgno = h->pgno;
} }
} else if (h->prevpg == P_INVALID) { } else if (h->prevpg == P_INVALID) {
if (index == 0) { if (idx == 0) {
t->bt_order = BACK; t->bt_order = BACK;
t->bt_last.index = 0; t->bt_last.index = 0;
t->bt_last.pgno = h->pgno; t->bt_last.pgno = h->pgno;

@ -151,10 +151,10 @@ rec_rdelete(t, nrec)
* RET_SUCCESS, RET_ERROR. * RET_SUCCESS, RET_ERROR.
*/ */
int int
__rec_dleaf(t, h, index) __rec_dleaf(t, h, idx)
BTREE *t; BTREE *t;
PAGE *h; PAGE *h;
u_int32_t index; u_int32_t idx;
{ {
RLEAF *rl; RLEAF *rl;
indx_t *ip, cnt, offset; indx_t *ip, cnt, offset;
@ -172,7 +172,7 @@ __rec_dleaf(t, h, index)
* down, overwriting the deleted record and its index. If the record * down, overwriting the deleted record and its index. If the record
* uses overflow pages, make them available for reuse. * uses overflow pages, make them available for reuse.
*/ */
to = rl = GETRLEAF(h, index); to = rl = GETRLEAF(h, idx);
if (rl->flags & P_BIGDATA && __ovfl_delete(t, rl->bytes) == RET_ERROR) if (rl->flags & P_BIGDATA && __ovfl_delete(t, rl->bytes) == RET_ERROR)
return (RET_ERROR); return (RET_ERROR);
nbytes = NRLEAF(rl); nbytes = NRLEAF(rl);
@ -185,8 +185,8 @@ __rec_dleaf(t, h, index)
memmove(from + nbytes, from, (char *)to - from); memmove(from + nbytes, from, (char *)to - from);
h->upper += nbytes; h->upper += nbytes;
offset = h->linp[index]; offset = h->linp[idx];
for (cnt = &h->linp[index] - (ip = &h->linp[0]); cnt--; ++ip) for (cnt = &h->linp[idx] - (ip = &h->linp[0]); cnt--; ++ip)
if (ip[0] < offset) if (ip[0] < offset)
ip[0] += nbytes; ip[0] += nbytes;
for (cnt = &h->linp[NEXTINDEX(h)] - ip; --cnt; ++ip) for (cnt = &h->linp[NEXTINDEX(h)] - ip; --cnt; ++ip)

@ -196,7 +196,7 @@ __rec_iput(t, nrec, data, flags)
DBT tdata; DBT tdata;
EPG *e; EPG *e;
PAGE *h; PAGE *h;
indx_t index, nxtindex; indx_t idx, nxtindex;
pgno_t pg; pgno_t pg;
u_int32_t nbytes; u_int32_t nbytes;
int dflags, status; int dflags, status;
@ -227,7 +227,7 @@ __rec_iput(t, nrec, data, flags)
return (RET_ERROR); return (RET_ERROR);
h = e->page; h = e->page;
index = e->index; idx = e->index;
/* /*
* Add the specified key/data pair to the tree. The R_IAFTER and * Add the specified key/data pair to the tree. The R_IAFTER and
@ -237,13 +237,13 @@ __rec_iput(t, nrec, data, flags)
*/ */
switch (flags) { switch (flags) {
case R_IAFTER: case R_IAFTER:
++index; ++idx;
break; break;
case R_IBEFORE: case R_IBEFORE:
break; break;
default: default:
if (nrec < t->bt_nrecs && if (nrec < t->bt_nrecs &&
__rec_dleaf(t, h, index) == RET_ERROR) { __rec_dleaf(t, h, idx) == RET_ERROR) {
mpool_put(t->bt_mp, h, 0); mpool_put(t->bt_mp, h, 0);
return (RET_ERROR); return (RET_ERROR);
} }
@ -257,18 +257,18 @@ __rec_iput(t, nrec, data, flags)
*/ */
nbytes = NRLEAFDBT(data->size); nbytes = NRLEAFDBT(data->size);
if ((u_int32_t) (h->upper - h->lower) < nbytes + sizeof(indx_t)) { if ((u_int32_t) (h->upper - h->lower) < nbytes + sizeof(indx_t)) {
status = __bt_split(t, h, NULL, data, dflags, nbytes, index); status = __bt_split(t, h, NULL, data, dflags, nbytes, idx);
if (status == RET_SUCCESS) if (status == RET_SUCCESS)
++t->bt_nrecs; ++t->bt_nrecs;
return (status); return (status);
} }
if (index < (nxtindex = NEXTINDEX(h))) if (idx < (nxtindex = NEXTINDEX(h)))
memmove(h->linp + index + 1, h->linp + index, memmove(h->linp + idx + 1, h->linp + idx,
(nxtindex - index) * sizeof(indx_t)); (nxtindex - idx) * sizeof(indx_t));
h->lower += sizeof(indx_t); h->lower += sizeof(indx_t);
h->linp[index] = h->upper -= nbytes; h->linp[idx] = h->upper -= nbytes;
dest = (char *)h + h->upper; dest = (char *)h + h->upper;
WR_RLEAF(dest, data, dflags); WR_RLEAF(dest, data, dflags);

@ -268,22 +268,22 @@ enum ast_event_subscriber_res ast_event_check_subscriber(enum ast_event_type typ
ie_type != AST_EVENT_IE_END; ie_type != AST_EVENT_IE_END;
ie_type = va_arg(ap, enum ast_event_type)) ie_type = va_arg(ap, enum ast_event_type))
{ {
struct ast_event_ie_val *ie_val = alloca(sizeof(*ie_val)); struct ast_event_ie_val *ie_value = alloca(sizeof(*ie_value));
memset(ie_val, 0, sizeof(*ie_val)); memset(ie_value, 0, sizeof(*ie_value));
ie_val->ie_type = ie_type; ie_value->ie_type = ie_type;
ie_val->ie_pltype = va_arg(ap, enum ast_event_ie_pltype); ie_value->ie_pltype = va_arg(ap, enum ast_event_ie_pltype);
if (ie_val->ie_pltype == AST_EVENT_IE_PLTYPE_UINT) if (ie_value->ie_pltype == AST_EVENT_IE_PLTYPE_UINT)
ie_val->payload.uint = va_arg(ap, uint32_t); ie_value->payload.uint = va_arg(ap, uint32_t);
else if (ie_val->ie_pltype == AST_EVENT_IE_PLTYPE_STR) else if (ie_value->ie_pltype == AST_EVENT_IE_PLTYPE_STR)
ie_val->payload.str = ast_strdupa(va_arg(ap, const char *)); ie_value->payload.str = ast_strdupa(va_arg(ap, const char *));
else if (ie_val->ie_pltype == AST_EVENT_IE_PLTYPE_RAW) { else if (ie_value->ie_pltype == AST_EVENT_IE_PLTYPE_RAW) {
void *data = va_arg(ap, void *); void *data = va_arg(ap, void *);
size_t datalen = va_arg(ap, size_t); size_t datalen = va_arg(ap, size_t);
ie_val->payload.raw = alloca(datalen); ie_value->payload.raw = alloca(datalen);
memcpy(ie_val->payload.raw, data, datalen); memcpy(ie_value->payload.raw, data, datalen);
ie_val->raw_datalen = datalen; ie_value->raw_datalen = datalen;
} }
AST_LIST_INSERT_TAIL(&ie_vals, ie_val, entry); AST_LIST_INSERT_TAIL(&ie_vals, ie_value, entry);
} }
va_end(ap); va_end(ap);
@ -479,7 +479,7 @@ struct ast_event_sub *ast_event_subscribe_new(enum ast_event_type type,
} }
int ast_event_sub_append_ie_uint(struct ast_event_sub *sub, int ast_event_sub_append_ie_uint(struct ast_event_sub *sub,
enum ast_event_ie_type ie_type, uint32_t uint) enum ast_event_ie_type ie_type, uint32_t unsigned_int)
{ {
struct ast_event_ie_val *ie_val; struct ast_event_ie_val *ie_val;
@ -490,7 +490,7 @@ int ast_event_sub_append_ie_uint(struct ast_event_sub *sub,
return -1; return -1;
ie_val->ie_type = ie_type; ie_val->ie_type = ie_type;
ie_val->payload.uint = uint; ie_val->payload.uint = unsigned_int;
ie_val->ie_pltype = AST_EVENT_IE_PLTYPE_UINT; ie_val->ie_pltype = AST_EVENT_IE_PLTYPE_UINT;
AST_LIST_INSERT_TAIL(&sub->ie_vals, ie_val, entry); AST_LIST_INSERT_TAIL(&sub->ie_vals, ie_val, entry);
@ -612,8 +612,8 @@ struct ast_event_sub *ast_event_subscribe(enum ast_event_type type, ast_event_cb
break; break;
case AST_EVENT_IE_PLTYPE_UINT: case AST_EVENT_IE_PLTYPE_UINT:
{ {
uint32_t uint = va_arg(ap, uint32_t); uint32_t unsigned_int = va_arg(ap, uint32_t);
ast_event_sub_append_ie_uint(sub, ie_type, uint); ast_event_sub_append_ie_uint(sub, ie_type, unsigned_int);
break; break;
} }
case AST_EVENT_IE_PLTYPE_STR: case AST_EVENT_IE_PLTYPE_STR:
@ -799,22 +799,22 @@ struct ast_event *ast_event_new(enum ast_event_type type, ...)
ie_type != AST_EVENT_IE_END; ie_type != AST_EVENT_IE_END;
ie_type = va_arg(ap, enum ast_event_type)) ie_type = va_arg(ap, enum ast_event_type))
{ {
struct ast_event_ie_val *ie_val = alloca(sizeof(*ie_val)); struct ast_event_ie_val *ie_value = alloca(sizeof(*ie_value));
memset(ie_val, 0, sizeof(*ie_val)); memset(ie_value, 0, sizeof(*ie_value));
ie_val->ie_type = ie_type; ie_value->ie_type = ie_type;
ie_val->ie_pltype = va_arg(ap, enum ast_event_ie_pltype); ie_value->ie_pltype = va_arg(ap, enum ast_event_ie_pltype);
if (ie_val->ie_pltype == AST_EVENT_IE_PLTYPE_UINT) if (ie_value->ie_pltype == AST_EVENT_IE_PLTYPE_UINT)
ie_val->payload.uint = va_arg(ap, uint32_t); ie_value->payload.uint = va_arg(ap, uint32_t);
else if (ie_val->ie_pltype == AST_EVENT_IE_PLTYPE_STR) else if (ie_value->ie_pltype == AST_EVENT_IE_PLTYPE_STR)
ie_val->payload.str = ast_strdupa(va_arg(ap, const char *)); ie_value->payload.str = ast_strdupa(va_arg(ap, const char *));
else if (ie_val->ie_pltype == AST_EVENT_IE_PLTYPE_RAW) { else if (ie_value->ie_pltype == AST_EVENT_IE_PLTYPE_RAW) {
void *data = va_arg(ap, void *); void *data = va_arg(ap, void *);
size_t datalen = va_arg(ap, size_t); size_t datalen = va_arg(ap, size_t);
ie_val->payload.raw = alloca(datalen); ie_value->payload.raw = alloca(datalen);
memcpy(ie_val->payload.raw, data, datalen); memcpy(ie_value->payload.raw, data, datalen);
ie_val->raw_datalen = datalen; ie_value->raw_datalen = datalen;
} }
AST_LIST_INSERT_TAIL(&ie_vals, ie_val, entry); AST_LIST_INSERT_TAIL(&ie_vals, ie_value, entry);
} }
va_end(ap); va_end(ap);

@ -2567,9 +2567,9 @@ static void *do_parking_thread(void *ignore)
rfds = nrfds; rfds = nrfds;
efds = nefds; efds = nefds;
{ {
struct timeval tv = ast_samp2tv(ms, 1000); struct timeval wait = ast_samp2tv(ms, 1000);
/* Wait for something to happen */ /* Wait for something to happen */
ast_select(max + 1, &rfds, NULL, &efds, (ms > -1) ? &tv : NULL); ast_select(max + 1, &rfds, NULL, &efds, (ms > -1) ? &wait : NULL);
} }
pthread_testcancel(); pthread_testcancel();
} }

@ -1072,7 +1072,7 @@ struct ast_filestream *ast_writefile(const char *filename, const char *type, con
* \brief the core of all waitstream() functions * \brief the core of all waitstream() functions
*/ */
static int waitstream_core(struct ast_channel *c, const char *breakon, static int waitstream_core(struct ast_channel *c, const char *breakon,
const char *forward, const char *rewind, int skip_ms, const char *forward, const char *reverse, int skip_ms,
int audiofd, int cmdfd, const char *context) int audiofd, int cmdfd, const char *context)
{ {
const char *orig_chan_name = NULL; const char *orig_chan_name = NULL;
@ -1082,8 +1082,8 @@ static int waitstream_core(struct ast_channel *c, const char *breakon,
breakon = ""; breakon = "";
if (!forward) if (!forward)
forward = ""; forward = "";
if (!rewind) if (!reverse)
rewind = ""; reverse = "";
/* Switch the channel to end DTMF frame only. waitstream_core doesn't care about the start of DTMF. */ /* Switch the channel to end DTMF frame only. waitstream_core doesn't care about the start of DTMF. */
ast_set_flag(c, AST_FLAG_END_DTMF_ONLY); ast_set_flag(c, AST_FLAG_END_DTMF_ONLY);
@ -1154,7 +1154,7 @@ static int waitstream_core(struct ast_channel *c, const char *breakon,
res = fr->subclass; res = fr->subclass;
if (strchr(forward, res)) { if (strchr(forward, res)) {
ast_stream_fastforward(c->stream, skip_ms); ast_stream_fastforward(c->stream, skip_ms);
} else if (strchr(rewind, res)) { } else if (strchr(reverse, res)) {
ast_stream_rewind(c->stream, skip_ms); ast_stream_rewind(c->stream, skip_ms);
} else if (strchr(breakon, res)) { } else if (strchr(breakon, res)) {
ast_frfree(fr); ast_frfree(fr);
@ -1201,9 +1201,9 @@ static int waitstream_core(struct ast_channel *c, const char *breakon,
return (err || c->_softhangup) ? -1 : 0; return (err || c->_softhangup) ? -1 : 0;
} }
int ast_waitstream_fr(struct ast_channel *c, const char *breakon, const char *forward, const char *rewind, int ms) int ast_waitstream_fr(struct ast_channel *c, const char *breakon, const char *forward, const char *reverse, int ms)
{ {
return waitstream_core(c, breakon, forward, rewind, ms, return waitstream_core(c, breakon, forward, reverse, ms,
-1 /* no audiofd */, -1 /* no cmdfd */, NULL /* no context */); -1 /* no audiofd */, -1 /* no cmdfd */, NULL /* no context */);
} }

@ -159,7 +159,7 @@ static struct ast_str *static_callback(struct ast_tcptls_session_instance *ser,
struct stat st; struct stat st;
int len; int len;
int fd; int fd;
struct timeval tv = ast_tvnow(); struct timeval now = ast_tvnow();
char buf[256]; char buf[256];
struct ast_tm tm; struct ast_tm tm;
@ -207,7 +207,7 @@ static struct ast_str *static_callback(struct ast_tcptls_session_instance *ser,
goto out403; goto out403;
} }
ast_strftime(buf, sizeof(buf), "%a, %d %b %Y %H:%M:%S %Z", ast_localtime(&tv, &tm, "GMT")); ast_strftime(buf, sizeof(buf), "%a, %d %b %Y %H:%M:%S %Z", ast_localtime(&now, &tm, "GMT"));
fprintf(ser->f, "HTTP/1.1 200 OK\r\n" fprintf(ser->f, "HTTP/1.1 200 OK\r\n"
"Server: Asterisk/%s\r\n" "Server: Asterisk/%s\r\n"
"Date: %s\r\n" "Date: %s\r\n"
@ -734,11 +734,11 @@ static void *httpd_helper_thread(void *data)
} }
if (out) { if (out) {
struct timeval tv = ast_tvnow(); struct timeval now = ast_tvnow();
char timebuf[256]; char timebuf[256];
struct ast_tm tm; struct ast_tm tm;
ast_strftime(timebuf, sizeof(timebuf), "%a, %d %b %Y %H:%M:%S %Z", ast_localtime(&tv, &tm, "GMT")); ast_strftime(timebuf, sizeof(timebuf), "%a, %d %b %Y %H:%M:%S %Z", ast_localtime(&now, &tm, "GMT"));
fprintf(ser->f, fprintf(ser->f,
"HTTP/1.1 %d %s\r\n" "HTTP/1.1 %d %s\r\n"
"Server: Asterisk/%s\r\n" "Server: Asterisk/%s\r\n"

@ -277,7 +277,7 @@ static void history_calc_maxbuf(jitterbuf *jb)
static void history_get(jitterbuf *jb) static void history_get(jitterbuf *jb)
{ {
long max, min, jitter; long max, min, jitter;
int index; int idx;
int count; int count;
if (!jb->hist_maxbuf_valid) if (!jb->hist_maxbuf_valid)
@ -286,22 +286,21 @@ static void history_get(jitterbuf *jb)
/* count is how many items in history we're examining */ /* count is how many items in history we're examining */
count = (jb->hist_ptr < JB_HISTORY_SZ) ? jb->hist_ptr : JB_HISTORY_SZ; count = (jb->hist_ptr < JB_HISTORY_SZ) ? jb->hist_ptr : JB_HISTORY_SZ;
/* index is the "n"ths highest/lowest that we'll look for */ /* idx is the "n"ths highest/lowest that we'll look for */
index = count * JB_HISTORY_DROPPCT / 100; idx = count * JB_HISTORY_DROPPCT / 100;
/* sanity checks for index */ /* sanity checks for idx */
if (index > (JB_HISTORY_MAXBUF_SZ - 1)) if (idx > (JB_HISTORY_MAXBUF_SZ - 1))
index = JB_HISTORY_MAXBUF_SZ - 1; idx = JB_HISTORY_MAXBUF_SZ - 1;
if (idx < 0) {
if (index < 0) {
jb->info.min = 0; jb->info.min = 0;
jb->info.jitter = 0; jb->info.jitter = 0;
return; return;
} }
max = jb->hist_maxbuf[index]; max = jb->hist_maxbuf[idx];
min = jb->hist_minbuf[index]; min = jb->hist_minbuf[idx];
jitter = max - min; jitter = max - min;

@ -828,14 +828,14 @@ static const char *__astman_get_header(const struct message *m, char *var, int m
for (x = 0; x < m->hdrcount; x++) { for (x = 0; x < m->hdrcount; x++) {
const char *h = m->headers[x]; const char *h = m->headers[x];
if (!strncasecmp(var, h, l) && h[l] == ':' && h[l+1] == ' ') { if (!strncasecmp(var, h, l) && h[l] == ':' && h[l+1] == ' ') {
const char *x = h + l + 2; const char *value = h + l + 2;
/* found a potential candidate */ /* found a potential candidate */
if (mode & GET_HEADER_SKIP_EMPTY && ast_strlen_zero(x)) if (mode & GET_HEADER_SKIP_EMPTY && ast_strlen_zero(value))
continue; /* not interesting */ continue; /* not interesting */
if (mode & GET_HEADER_LAST_MATCH) if (mode & GET_HEADER_LAST_MATCH)
result = x; /* record the last match so far */ result = value; /* record the last match so far */
else else
return x; return value;
} }
} }
@ -2545,7 +2545,7 @@ static int action_timeout(struct mansession *s, const struct message *m)
struct ast_channel *c; struct ast_channel *c;
const char *name = astman_get_header(m, "Channel"); const char *name = astman_get_header(m, "Channel");
double timeout = atof(astman_get_header(m, "Timeout")); double timeout = atof(astman_get_header(m, "Timeout"));
struct timeval tv = { timeout, 0 }; struct timeval when = { timeout, 0 };
if (ast_strlen_zero(name)) { if (ast_strlen_zero(name)) {
astman_send_error(s, m, "No channel specified"); astman_send_error(s, m, "No channel specified");
@ -2561,8 +2561,8 @@ static int action_timeout(struct mansession *s, const struct message *m)
return 0; return 0;
} }
tv.tv_usec = (timeout - tv.tv_sec) * 1000000.0; when.tv_usec = (timeout - when.tv_sec) * 1000000.0;
ast_channel_setwhentohangup_tv(c, tv); ast_channel_setwhentohangup_tv(c, when);
ast_channel_unlock(c); ast_channel_unlock(c);
astman_send_ack(s, m, "Timeout Set"); astman_send_ack(s, m, "Timeout Set");
return 0; return 0;
@ -4147,11 +4147,11 @@ static int __init_manager(int reload)
user->displayconnects = ast_true(user_displayconnects); user->displayconnects = ast_true(user_displayconnects);
if (user_writetimeout) { if (user_writetimeout) {
int val = atoi(user_writetimeout); int value = atoi(user_writetimeout);
if (val < 100) if (value < 100)
ast_log(LOG_WARNING, "Invalid writetimeout value '%s' at users.conf line %d\n", var->value, var->lineno); ast_log(LOG_WARNING, "Invalid writetimeout value '%s' at users.conf line %d\n", var->value, var->lineno);
else else
user->writetimeout = val; user->writetimeout = value;
} }
} }
} }
@ -4205,11 +4205,11 @@ static int __init_manager(int reload)
} else if (!strcasecmp(var->name, "displayconnects") ) { } else if (!strcasecmp(var->name, "displayconnects") ) {
user->displayconnects = ast_true(var->value); user->displayconnects = ast_true(var->value);
} else if (!strcasecmp(var->name, "writetimeout")) { } else if (!strcasecmp(var->name, "writetimeout")) {
int val = atoi(var->value); int value = atoi(var->value);
if (val < 100) if (value < 100)
ast_log(LOG_WARNING, "Invalid writetimeout value '%s' at line %d\n", var->value, var->lineno); ast_log(LOG_WARNING, "Invalid writetimeout value '%s' at line %d\n", var->value, var->lineno);
else else
user->writetimeout = val; user->writetimeout = value;
} else } else
ast_debug(1, "%s is an unknown option.\n", var->name); ast_debug(1, "%s is an unknown option.\n", var->name);
} }

@ -460,7 +460,7 @@ static void append_attr_string(struct stun_attr **attr, int attrval, const char
} }
/*! \brief append an address to an STUN message */ /*! \brief append an address to an STUN message */
static void append_attr_address(struct stun_attr **attr, int attrval, struct sockaddr_in *sin, int *len, int *left) static void append_attr_address(struct stun_attr **attr, int attrval, struct sockaddr_in *sock_in, int *len, int *left)
{ {
int size = sizeof(**attr) + 8; int size = sizeof(**attr) + 8;
struct stun_addr *addr; struct stun_addr *addr;
@ -470,8 +470,8 @@ static void append_attr_address(struct stun_attr **attr, int attrval, struct soc
addr = (struct stun_addr *)((*attr)->value); addr = (struct stun_addr *)((*attr)->value);
addr->unused = 0; addr->unused = 0;
addr->family = 0x01; addr->family = 0x01;
addr->port = sin->sin_port; addr->port = sock_in->sin_port;
addr->addr = sin->sin_addr.s_addr; addr->addr = sock_in->sin_addr.s_addr;
(*attr) = (struct stun_attr *)((*attr)->value + 8); (*attr) = (struct stun_attr *)((*attr)->value + 8);
*len += size; *len += size;
*left -= size; *left -= size;
@ -707,11 +707,11 @@ void ast_rtp_stun_request(struct ast_rtp *rtp, struct sockaddr_in *suggestion, c
/*! \brief List of current sessions */ /*! \brief List of current sessions */
static AST_RWLIST_HEAD_STATIC(protos, ast_rtp_protocol); static AST_RWLIST_HEAD_STATIC(protos, ast_rtp_protocol);
static void timeval2ntp(struct timeval tv, unsigned int *msw, unsigned int *lsw) static void timeval2ntp(struct timeval when, unsigned int *msw, unsigned int *lsw)
{ {
unsigned int sec, usec, frac; unsigned int sec, usec, frac;
sec = tv.tv_sec + 2208988800u; /* Sec between 1900 and 1970 */ sec = when.tv_sec + 2208988800u; /* Sec between 1900 and 1970 */
usec = tv.tv_usec; usec = when.tv_usec;
frac = (usec << 12) + (usec << 8) - ((usec * 3650) >> 6); frac = (usec << 12) + (usec << 8) - ((usec * 3650) >> 6);
*msw = sec; *msw = sec;
*lsw = frac; *lsw = frac;
@ -1130,7 +1130,7 @@ struct ast_frame *ast_rtcp_read(struct ast_rtp *rtp)
socklen_t len; socklen_t len;
int position, i, packetwords; int position, i, packetwords;
int res; int res;
struct sockaddr_in sin; struct sockaddr_in sock_in;
unsigned int rtcpdata[8192 + AST_FRIENDLY_OFFSET]; unsigned int rtcpdata[8192 + AST_FRIENDLY_OFFSET];
unsigned int *rtcpheader; unsigned int *rtcpheader;
int pt; int pt;
@ -1155,10 +1155,10 @@ struct ast_frame *ast_rtcp_read(struct ast_rtp *rtp)
if (!rtp || !rtp->rtcp) if (!rtp || !rtp->rtcp)
return &ast_null_frame; return &ast_null_frame;
len = sizeof(sin); len = sizeof(sock_in);
res = recvfrom(rtp->rtcp->s, rtcpdata + AST_FRIENDLY_OFFSET, sizeof(rtcpdata) - sizeof(unsigned int) * AST_FRIENDLY_OFFSET, res = recvfrom(rtp->rtcp->s, rtcpdata + AST_FRIENDLY_OFFSET, sizeof(rtcpdata) - sizeof(unsigned int) * AST_FRIENDLY_OFFSET,
0, (struct sockaddr *)&sin, &len); 0, (struct sockaddr *)&sock_in, &len);
rtcpheader = (unsigned int *)(rtcpdata + AST_FRIENDLY_OFFSET); rtcpheader = (unsigned int *)(rtcpdata + AST_FRIENDLY_OFFSET);
if (res < 0) { if (res < 0) {
@ -1174,9 +1174,9 @@ struct ast_frame *ast_rtcp_read(struct ast_rtp *rtp)
if (rtp->nat) { if (rtp->nat) {
/* Send to whoever sent to us */ /* Send to whoever sent to us */
if ((rtp->rtcp->them.sin_addr.s_addr != sin.sin_addr.s_addr) || if ((rtp->rtcp->them.sin_addr.s_addr != sock_in.sin_addr.s_addr) ||
(rtp->rtcp->them.sin_port != sin.sin_port)) { (rtp->rtcp->them.sin_port != sock_in.sin_port)) {
memcpy(&rtp->rtcp->them, &sin, sizeof(rtp->rtcp->them)); memcpy(&rtp->rtcp->them, &sock_in, sizeof(rtp->rtcp->them));
if (option_debug || rtpdebug) if (option_debug || rtpdebug)
ast_debug(0, "RTCP NAT: Got RTCP from other end. Now sending to address %s:%d\n", ast_inet_ntoa(rtp->rtcp->them.sin_addr), ntohs(rtp->rtcp->them.sin_port)); ast_debug(0, "RTCP NAT: Got RTCP from other end. Now sending to address %s:%d\n", ast_inet_ntoa(rtp->rtcp->them.sin_addr), ntohs(rtp->rtcp->them.sin_port));
} }
@ -1199,8 +1199,8 @@ struct ast_frame *ast_rtcp_read(struct ast_rtp *rtp)
return &ast_null_frame; return &ast_null_frame;
} }
if (rtcp_debug_test_addr(&sin)) { if (rtcp_debug_test_addr(&sock_in)) {
ast_verbose("\n\nGot RTCP from %s:%d\n", ast_inet_ntoa(sin.sin_addr), ntohs(sin.sin_port)); ast_verbose("\n\nGot RTCP from %s:%d\n", ast_inet_ntoa(sock_in.sin_addr), ntohs(sock_in.sin_port));
ast_verbose("PT: %d(%s)\n", pt, (pt == 200) ? "Sender Report" : (pt == 201) ? "Receiver Report" : (pt == 192) ? "H.261 FUR" : "Unknown"); ast_verbose("PT: %d(%s)\n", pt, (pt == 200) ? "Sender Report" : (pt == 201) ? "Receiver Report" : (pt == 192) ? "H.261 FUR" : "Unknown");
ast_verbose("Reception reports: %d\n", rc); ast_verbose("Reception reports: %d\n", rc);
ast_verbose("SSRC of sender: %u\n", rtcpheader[i + 1]); ast_verbose("SSRC of sender: %u\n", rtcpheader[i + 1]);
@ -1215,7 +1215,7 @@ struct ast_frame *ast_rtcp_read(struct ast_rtp *rtp)
rtp->rtcp->soc = ntohl(rtcpheader[i + 4]); rtp->rtcp->soc = ntohl(rtcpheader[i + 4]);
rtp->rtcp->themrxlsr = ((ntohl(rtcpheader[i]) & 0x0000ffff) << 16) | ((ntohl(rtcpheader[i + 1]) & 0xffff0000) >> 16); /* Going to LSR in RR*/ rtp->rtcp->themrxlsr = ((ntohl(rtcpheader[i]) & 0x0000ffff) << 16) | ((ntohl(rtcpheader[i + 1]) & 0xffff0000) >> 16); /* Going to LSR in RR*/
if (rtcp_debug_test_addr(&sin)) { if (rtcp_debug_test_addr(&sock_in)) {
ast_verbose("NTP timestamp: %lu.%010lu\n", (unsigned long) ntohl(rtcpheader[i]), (unsigned long) ntohl(rtcpheader[i + 1]) * 4096); ast_verbose("NTP timestamp: %lu.%010lu\n", (unsigned long) ntohl(rtcpheader[i]), (unsigned long) ntohl(rtcpheader[i + 1]) * 4096);
ast_verbose("RTP timestamp: %lu\n", (unsigned long) ntohl(rtcpheader[i + 2])); ast_verbose("RTP timestamp: %lu\n", (unsigned long) ntohl(rtcpheader[i + 2]));
ast_verbose("SPC: %lu\tSOC: %lu\n", (unsigned long) ntohl(rtcpheader[i + 3]), (unsigned long) ntohl(rtcpheader[i + 4])); ast_verbose("SPC: %lu\tSOC: %lu\n", (unsigned long) ntohl(rtcpheader[i + 3]), (unsigned long) ntohl(rtcpheader[i + 4]));
@ -1266,7 +1266,7 @@ struct ast_frame *ast_rtcp_read(struct ast_rtp *rtp)
rtp->rtcp->normdevrtt = normdevrtt_current; rtp->rtcp->normdevrtt = normdevrtt_current;
rtp->rtcp->rtt_count++; rtp->rtcp->rtt_count++;
} else if (rtcp_debug_test_addr(&sin)) { } else if (rtcp_debug_test_addr(&sock_in)) {
ast_verbose("Internal RTCP NTP clock skew detected: " ast_verbose("Internal RTCP NTP clock skew detected: "
"lsr=%u, now=%u, dlsr=%u (%d:%03dms), " "lsr=%u, now=%u, dlsr=%u (%d:%03dms), "
"diff=%d\n", "diff=%d\n",
@ -1316,7 +1316,7 @@ struct ast_frame *ast_rtcp_read(struct ast_rtp *rtp)
rtp->rtcp->reported_jitter_count++; rtp->rtcp->reported_jitter_count++;
if (rtcp_debug_test_addr(&sin)) { if (rtcp_debug_test_addr(&sock_in)) {
ast_verbose(" Fraction lost: %ld\n", (((long) ntohl(rtcpheader[i + 1]) & 0xff000000) >> 24)); ast_verbose(" Fraction lost: %ld\n", (((long) ntohl(rtcpheader[i + 1]) & 0xff000000) >> 24));
ast_verbose(" Packets lost so far: %d\n", rtp->rtcp->reported_lost); ast_verbose(" Packets lost so far: %d\n", rtp->rtcp->reported_lost);
ast_verbose(" Highest sequence number: %ld\n", (long) (ntohl(rtcpheader[i + 2]) & 0xffff)); ast_verbose(" Highest sequence number: %ld\n", (long) (ntohl(rtcpheader[i + 2]) & 0xffff));
@ -1341,7 +1341,7 @@ struct ast_frame *ast_rtcp_read(struct ast_rtp *rtp)
"LastSR: %lu.%010lu\r\n" "LastSR: %lu.%010lu\r\n"
"DLSR: %4.4f(sec)\r\n" "DLSR: %4.4f(sec)\r\n"
"RTT: %llu(sec)\r\n", "RTT: %llu(sec)\r\n",
ast_inet_ntoa(sin.sin_addr), ntohs(sin.sin_port), ast_inet_ntoa(sock_in.sin_addr), ntohs(sock_in.sin_port),
pt, (pt == 200) ? "Sender Report" : (pt == 201) ? "Receiver Report" : (pt == 192) ? "H.261 FUR" : "Unknown", pt, (pt == 200) ? "Sender Report" : (pt == 201) ? "Receiver Report" : (pt == 192) ? "H.261 FUR" : "Unknown",
rc, rc,
rtcpheader[i + 1], rtcpheader[i + 1],
@ -1365,7 +1365,7 @@ struct ast_frame *ast_rtcp_read(struct ast_rtp *rtp)
"IAJitter: %u\r\n" "IAJitter: %u\r\n"
"LastSR: %lu.%010lu\r\n" "LastSR: %lu.%010lu\r\n"
"DLSR: %4.4f(sec)\r\n", "DLSR: %4.4f(sec)\r\n",
ast_inet_ntoa(sin.sin_addr), ntohs(sin.sin_port), ast_inet_ntoa(sock_in.sin_addr), ntohs(sock_in.sin_port),
pt, (pt == 200) ? "Sender Report" : (pt == 201) ? "Receiver Report" : (pt == 192) ? "H.261 FUR" : "Unknown", pt, (pt == 200) ? "Sender Report" : (pt == 201) ? "Receiver Report" : (pt == 192) ? "H.261 FUR" : "Unknown",
rc, rc,
rtcpheader[i + 1], rtcpheader[i + 1],
@ -1380,7 +1380,7 @@ struct ast_frame *ast_rtcp_read(struct ast_rtp *rtp)
} }
break; break;
case RTCP_PT_FUR: case RTCP_PT_FUR:
if (rtcp_debug_test_addr(&sin)) if (rtcp_debug_test_addr(&sock_in))
ast_verbose("Received an RTCP Fast Update Request\n"); ast_verbose("Received an RTCP Fast Update Request\n");
rtp->f.frametype = AST_FRAME_CONTROL; rtp->f.frametype = AST_FRAME_CONTROL;
rtp->f.subclass = AST_CONTROL_VIDUPDATE; rtp->f.subclass = AST_CONTROL_VIDUPDATE;
@ -1391,11 +1391,11 @@ struct ast_frame *ast_rtcp_read(struct ast_rtp *rtp)
f = &rtp->f; f = &rtp->f;
break; break;
case RTCP_PT_SDES: case RTCP_PT_SDES:
if (rtcp_debug_test_addr(&sin)) if (rtcp_debug_test_addr(&sock_in))
ast_verbose("Received an SDES from %s:%d\n", ast_inet_ntoa(rtp->rtcp->them.sin_addr), ntohs(rtp->rtcp->them.sin_port)); ast_verbose("Received an SDES from %s:%d\n", ast_inet_ntoa(rtp->rtcp->them.sin_addr), ntohs(rtp->rtcp->them.sin_port));
break; break;
case RTCP_PT_BYE: case RTCP_PT_BYE:
if (rtcp_debug_test_addr(&sin)) if (rtcp_debug_test_addr(&sock_in))
ast_verbose("Received a BYE from %s:%d\n", ast_inet_ntoa(rtp->rtcp->them.sin_addr), ntohs(rtp->rtcp->them.sin_port)); ast_verbose("Received a BYE from %s:%d\n", ast_inet_ntoa(rtp->rtcp->them.sin_addr), ntohs(rtp->rtcp->them.sin_port));
break; break;
default: default:
@ -1408,7 +1408,7 @@ struct ast_frame *ast_rtcp_read(struct ast_rtp *rtp)
return f; return f;
} }
static void calc_rxstamp(struct timeval *tv, struct ast_rtp *rtp, unsigned int timestamp, int mark) static void calc_rxstamp(struct timeval *when, struct ast_rtp *rtp, unsigned int timestamp, int mark)
{ {
struct timeval now; struct timeval now;
double transit; double transit;
@ -1436,11 +1436,11 @@ static void calc_rxstamp(struct timeval *tv, struct ast_rtp *rtp, unsigned int t
gettimeofday(&now,NULL); gettimeofday(&now,NULL);
/* rxcore is the mapping between the RTP timestamp and _our_ real time from gettimeofday() */ /* rxcore is the mapping between the RTP timestamp and _our_ real time from gettimeofday() */
tv->tv_sec = rtp->rxcore.tv_sec + timestamp / 8000; when->tv_sec = rtp->rxcore.tv_sec + timestamp / 8000;
tv->tv_usec = rtp->rxcore.tv_usec + (timestamp % 8000) * 125; when->tv_usec = rtp->rxcore.tv_usec + (timestamp % 8000) * 125;
if (tv->tv_usec >= 1000000) { if (when->tv_usec >= 1000000) {
tv->tv_usec -= 1000000; when->tv_usec -= 1000000;
tv->tv_sec += 1; when->tv_sec += 1;
} }
prog = (double)((timestamp-rtp->seedrxts)/8000.); prog = (double)((timestamp-rtp->seedrxts)/8000.);
dtv = (double)rtp->drxcore + (double)(prog); dtv = (double)rtp->drxcore + (double)(prog);
@ -1523,7 +1523,7 @@ static int bridge_p2p_rtp_write(struct ast_rtp *rtp, struct ast_rtp *bridged, un
struct ast_frame *ast_rtp_read(struct ast_rtp *rtp) struct ast_frame *ast_rtp_read(struct ast_rtp *rtp)
{ {
int res; int res;
struct sockaddr_in sin; struct sockaddr_in sock_in;
socklen_t len; socklen_t len;
unsigned int seqno; unsigned int seqno;
int version; int version;
@ -1544,23 +1544,23 @@ struct ast_frame *ast_rtp_read(struct ast_rtp *rtp)
if (rtp->sending_digit) if (rtp->sending_digit)
ast_rtp_senddigit_continuation(rtp); ast_rtp_senddigit_continuation(rtp);
len = sizeof(sin); len = sizeof(sock_in);
/* Cache where the header will go */ /* Cache where the header will go */
res = recvfrom(rtp->s, rtp->rawdata + AST_FRIENDLY_OFFSET, sizeof(rtp->rawdata) - AST_FRIENDLY_OFFSET, res = recvfrom(rtp->s, rtp->rawdata + AST_FRIENDLY_OFFSET, sizeof(rtp->rawdata) - AST_FRIENDLY_OFFSET,
0, (struct sockaddr *)&sin, &len); 0, (struct sockaddr *)&sock_in, &len);
/* If strict RTP protection is enabled see if we need to learn this address or if the packet should be dropped */ /* If strict RTP protection is enabled see if we need to learn this address or if the packet should be dropped */
if (rtp->strict_rtp_state == STRICT_RTP_LEARN) { if (rtp->strict_rtp_state == STRICT_RTP_LEARN) {
/* Copy over address that this packet was received on */ /* Copy over address that this packet was received on */
memcpy(&rtp->strict_rtp_address, &sin, sizeof(rtp->strict_rtp_address)); memcpy(&rtp->strict_rtp_address, &sock_in, sizeof(rtp->strict_rtp_address));
/* Now move over to actually protecting the RTP port */ /* Now move over to actually protecting the RTP port */
rtp->strict_rtp_state = STRICT_RTP_CLOSED; rtp->strict_rtp_state = STRICT_RTP_CLOSED;
ast_debug(1, "Learned remote address is %s:%d for strict RTP purposes, now protecting the port.\n", ast_inet_ntoa(rtp->strict_rtp_address.sin_addr), ntohs(rtp->strict_rtp_address.sin_port)); ast_debug(1, "Learned remote address is %s:%d for strict RTP purposes, now protecting the port.\n", ast_inet_ntoa(rtp->strict_rtp_address.sin_addr), ntohs(rtp->strict_rtp_address.sin_port));
} else if (rtp->strict_rtp_state == STRICT_RTP_CLOSED) { } else if (rtp->strict_rtp_state == STRICT_RTP_CLOSED) {
/* If the address we previously learned doesn't match the address this packet came in on simply drop it */ /* If the address we previously learned doesn't match the address this packet came in on simply drop it */
if ((rtp->strict_rtp_address.sin_addr.s_addr != sin.sin_addr.s_addr) || (rtp->strict_rtp_address.sin_port != sin.sin_port)) { if ((rtp->strict_rtp_address.sin_addr.s_addr != sock_in.sin_addr.s_addr) || (rtp->strict_rtp_address.sin_port != sock_in.sin_port)) {
ast_debug(1, "Received RTP packet from %s:%d, dropping due to strict RTP protection. Expected it to be from %s:%d\n", ast_inet_ntoa(sin.sin_addr), ntohs(sin.sin_port), ast_inet_ntoa(rtp->strict_rtp_address.sin_addr), ntohs(rtp->strict_rtp_address.sin_port)); ast_debug(1, "Received RTP packet from %s:%d, dropping due to strict RTP protection. Expected it to be from %s:%d\n", ast_inet_ntoa(sock_in.sin_addr), ntohs(sock_in.sin_port), ast_inet_ntoa(rtp->strict_rtp_address.sin_addr), ntohs(rtp->strict_rtp_address.sin_port));
return &ast_null_frame; return &ast_null_frame;
} }
} }
@ -1591,9 +1591,9 @@ struct ast_frame *ast_rtp_read(struct ast_rtp *rtp)
* answers to requests, and it returns STUN_ACCEPT * answers to requests, and it returns STUN_ACCEPT
* if the request is valid. * if the request is valid.
*/ */
if ((stun_handle_packet(rtp->s, &sin, rtp->rawdata + AST_FRIENDLY_OFFSET, res, NULL, NULL) == STUN_ACCEPT) && if ((stun_handle_packet(rtp->s, &sock_in, rtp->rawdata + AST_FRIENDLY_OFFSET, res, NULL, NULL) == STUN_ACCEPT) &&
(!rtp->them.sin_port && !rtp->them.sin_addr.s_addr)) { (!rtp->them.sin_port && !rtp->them.sin_addr.s_addr)) {
memcpy(&rtp->them, &sin, sizeof(rtp->them)); memcpy(&rtp->them, &sock_in, sizeof(rtp->them));
} }
return &ast_null_frame; return &ast_null_frame;
} }
@ -1606,11 +1606,11 @@ struct ast_frame *ast_rtp_read(struct ast_rtp *rtp)
/* Send to whoever send to us if NAT is turned on */ /* Send to whoever send to us if NAT is turned on */
if (rtp->nat) { if (rtp->nat) {
if ((rtp->them.sin_addr.s_addr != sin.sin_addr.s_addr) || if ((rtp->them.sin_addr.s_addr != sock_in.sin_addr.s_addr) ||
(rtp->them.sin_port != sin.sin_port)) { (rtp->them.sin_port != sock_in.sin_port)) {
rtp->them = sin; rtp->them = sock_in;
if (rtp->rtcp) { if (rtp->rtcp) {
memcpy(&rtp->rtcp->them, &sin, sizeof(rtp->rtcp->them)); memcpy(&rtp->rtcp->them, &sock_in, sizeof(rtp->rtcp->them));
rtp->rtcp->them.sin_port = htons(ntohs(rtp->them.sin_port)+1); rtp->rtcp->them.sin_port = htons(ntohs(rtp->them.sin_port)+1);
} }
rtp->rxseqno = 0; rtp->rxseqno = 0;
@ -1695,9 +1695,9 @@ struct ast_frame *ast_rtp_read(struct ast_rtp *rtp)
if (!rtp->themssrc) if (!rtp->themssrc)
rtp->themssrc = ntohl(rtpheader[2]); /* Record their SSRC to put in future RR */ rtp->themssrc = ntohl(rtpheader[2]); /* Record their SSRC to put in future RR */
if (rtp_debug_test_addr(&sin)) if (rtp_debug_test_addr(&sock_in))
ast_verbose("Got RTP packet from %s:%u (type %-2.2d, seq %-6.6u, ts %-6.6u, len %-6.6u)\n", ast_verbose("Got RTP packet from %s:%u (type %-2.2d, seq %-6.6u, ts %-6.6u, len %-6.6u)\n",
ast_inet_ntoa(sin.sin_addr), ntohs(sin.sin_port), payloadtype, seqno, timestamp,res - hdrlen); ast_inet_ntoa(sock_in.sin_addr), ntohs(sock_in.sin_port), payloadtype, seqno, timestamp,res - hdrlen);
rtpPT = ast_rtp_lookup_pt(rtp, payloadtype); rtpPT = ast_rtp_lookup_pt(rtp, payloadtype);
if (!rtpPT.isAstFormat) { if (!rtpPT.isAstFormat) {
@ -1706,7 +1706,7 @@ struct ast_frame *ast_rtp_read(struct ast_rtp *rtp)
/* This is special in-band data that's not one of our codecs */ /* This is special in-band data that's not one of our codecs */
if (rtpPT.code == AST_RTP_DTMF) { if (rtpPT.code == AST_RTP_DTMF) {
/* It's special -- rfc2833 process it */ /* It's special -- rfc2833 process it */
if (rtp_debug_test_addr(&sin)) { if (rtp_debug_test_addr(&sock_in)) {
unsigned char *data; unsigned char *data;
unsigned int event; unsigned int event;
unsigned int event_end; unsigned int event_end;
@ -1719,7 +1719,7 @@ struct ast_frame *ast_rtp_read(struct ast_rtp *rtp)
event_end >>= 24; event_end >>= 24;
duration = ntohl(*((unsigned int *)(data))); duration = ntohl(*((unsigned int *)(data)));
duration &= 0xFFFF; duration &= 0xFFFF;
ast_verbose("Got RTP RFC2833 from %s:%u (type %-2.2d, seq %-6.6u, ts %-6.6u, len %-6.6u, mark %d, event %08x, end %d, duration %-5.5d) \n", ast_inet_ntoa(sin.sin_addr), ntohs(sin.sin_port), payloadtype, seqno, timestamp, res - hdrlen, (mark?1:0), event, ((event_end & 0x80)?1:0), duration); ast_verbose("Got RTP RFC2833 from %s:%u (type %-2.2d, seq %-6.6u, ts %-6.6u, len %-6.6u, mark %d, event %08x, end %d, duration %-5.5d) \n", ast_inet_ntoa(sock_in.sin_addr), ntohs(sock_in.sin_port), payloadtype, seqno, timestamp, res - hdrlen, (mark?1:0), event, ((event_end & 0x80)?1:0), duration);
} }
f = process_rfc2833(rtp, rtp->rawdata + AST_FRIENDLY_OFFSET + hdrlen, res - hdrlen, seqno, timestamp); f = process_rfc2833(rtp, rtp->rawdata + AST_FRIENDLY_OFFSET + hdrlen, res - hdrlen, seqno, timestamp);
} else if (rtpPT.code == AST_RTP_CISCO_DTMF) { } else if (rtpPT.code == AST_RTP_CISCO_DTMF) {
@ -1768,7 +1768,7 @@ struct ast_frame *ast_rtp_read(struct ast_rtp *rtp)
unsigned char *header_end; unsigned char *header_end;
int num_generations; int num_generations;
int header_length; int header_length;
int len; int length;
int diff =(int)seqno - (prev_seqno+1); /* if diff = 0, no drop*/ int diff =(int)seqno - (prev_seqno+1); /* if diff = 0, no drop*/
int x; int x;
@ -1778,21 +1778,21 @@ struct ast_frame *ast_rtp_read(struct ast_rtp *rtp)
header_length = header_end - data; header_length = header_end - data;
num_generations = header_length / 4; num_generations = header_length / 4;
len = header_length; length = header_length;
if (!diff) { if (!diff) {
for (x = 0; x < num_generations; x++) for (x = 0; x < num_generations; x++)
len += data[x * 4 + 3]; length += data[x * 4 + 3];
if (!(rtp->f.datalen - len)) if (!(rtp->f.datalen - length))
return &ast_null_frame; return &ast_null_frame;
rtp->f.data.ptr += len; rtp->f.data.ptr += length;
rtp->f.datalen -= len; rtp->f.datalen -= length;
} else if (diff > num_generations && diff < 10) { } else if (diff > num_generations && diff < 10) {
len -= 3; length -= 3;
rtp->f.data.ptr += len; rtp->f.data.ptr += length;
rtp->f.datalen -= len; rtp->f.datalen -= length;
data = rtp->f.data.ptr; data = rtp->f.data.ptr;
*data++ = 0xEF; *data++ = 0xEF;
@ -1800,10 +1800,10 @@ struct ast_frame *ast_rtp_read(struct ast_rtp *rtp)
*data = 0xBD; *data = 0xBD;
} else { } else {
for ( x = 0; x < num_generations - diff; x++) for ( x = 0; x < num_generations - diff; x++)
len += data[x * 4 + 3]; length += data[x * 4 + 3];
rtp->f.data.ptr += len; rtp->f.data.ptr += length;
rtp->f.datalen -= len; rtp->f.datalen -= length;
} }
} }
@ -2530,9 +2530,9 @@ struct ast_rtp *ast_rtp_new(struct sched_context *sched, struct io_context *io,
return ast_rtp_new_with_bindaddr(sched, io, rtcpenable, callbackmode, ia); return ast_rtp_new_with_bindaddr(sched, io, rtcpenable, callbackmode, ia);
} }
int ast_rtp_setqos(struct ast_rtp *rtp, int tos, int cos, char *desc) int ast_rtp_setqos(struct ast_rtp *rtp, int type_of_service, int class_of_service, char *desc)
{ {
return ast_netsock_set_qos(rtp->s, tos, cos, desc); return ast_netsock_set_qos(rtp->s, type_of_service, class_of_service, desc);
} }
void ast_rtp_new_source(struct ast_rtp *rtp) void ast_rtp_new_source(struct ast_rtp *rtp)
@ -2548,7 +2548,8 @@ void ast_rtp_set_peer(struct ast_rtp *rtp, struct sockaddr_in *them)
rtp->them.sin_port = them->sin_port; rtp->them.sin_port = them->sin_port;
rtp->them.sin_addr = them->sin_addr; rtp->them.sin_addr = them->sin_addr;
if (rtp->rtcp) { if (rtp->rtcp) {
rtp->rtcp->them.sin_port = htons(ntohs(them->sin_port) + 1); int h = ntohs(them->sin_port);
rtp->rtcp->them.sin_port = htons(h + 1);
rtp->rtcp->them.sin_addr = them->sin_addr; rtp->rtcp->them.sin_addr = them->sin_addr;
} }
rtp->rxseqno = 0; rtp->rxseqno = 0;

@ -234,8 +234,8 @@ static inline float tdd_getcarrier(float *cr, float *ci, int bit)
} while(0) } while(0)
#define PUT_AUDIO_SAMPLE(y) do { \ #define PUT_AUDIO_SAMPLE(y) do { \
int index = (short)(rint(8192.0 * (y))); \ int __pas_idx = (short)(rint(8192.0 * (y))); \
*(buf++) = AST_LIN2MU(index); \ *(buf++) = AST_LIN2MU(__pas_idx); \
bytes++; \ bytes++; \
} while(0) } while(0)

Loading…
Cancel
Save