Index: app.c =================================================================== RCS file: /usr/cvsroot/asterisk/app.c,v retrieving revision 1.42 diff -u -r1.42 app.c --- app.c 9 Jan 2005 09:01:40 -0000 1.42 +++ app.c 10 Jan 2005 06:37:13 -0000 @@ -1061,7 +1061,7 @@ return x; } -int ast_record_review(struct ast_channel *chan, const char *playfile, const char *recordfile, int maxtime, const char *fmt, int *duration) +int ast_record_review(struct ast_channel *chan, char *playfile, char *recordfile, int maxtime, char *fmt, int *duration) { int silencethreshold = 128; int maxsilence=0; Index: cdr.c =================================================================== RCS file: /usr/cvsroot/asterisk/cdr.c,v retrieving revision 1.27 diff -u -r1.27 cdr.c --- cdr.c 27 Oct 2004 03:33:14 -0000 1.27 +++ cdr.c 10 Jan 2005 06:37:13 -0000 @@ -110,7 +110,7 @@ while (cdr) { next = cdr->next; chan = !ast_strlen_zero(cdr->channel) ? cdr->channel : ""; - if (!ast_cdr_has_flag(cdr,AST_CDR_FLAG_POSTED)) + if (!ast_test_flag(cdr, AST_CDR_FLAG_POSTED)) ast_log(LOG_WARNING, "CDR on channel '%s' not posted\n", chan); if (!cdr->end.tv_sec && !cdr->end.tv_usec) ast_log(LOG_WARNING, "CDR on channel '%s' lacks end\n", chan); @@ -135,9 +135,9 @@ { char *chan; while (cdr) { - if (!ast_cdr_has_flag(cdr,AST_CDR_FLAG_LOCKED)) { + if (!ast_test_flag(cdr, AST_CDR_FLAG_LOCKED)) { chan = !ast_strlen_zero(cdr->channel) ? cdr->channel : ""; - if (ast_cdr_has_flag(cdr,AST_CDR_FLAG_POSTED)) + if (ast_test_flag(cdr, AST_CDR_FLAG_POSTED)) ast_log(LOG_WARNING, "CDR on channel '%s' already posted\n", chan); if (cdr->start.tv_sec || cdr->start.tv_usec) ast_log(LOG_WARNING, "CDR on channel '%s' already started\n", chan); @@ -152,7 +152,7 @@ char *chan; while (cdr) { chan = !ast_strlen_zero(cdr->channel) ? cdr->channel : ""; - if (ast_cdr_has_flag(cdr,AST_CDR_FLAG_POSTED)) + if (ast_test_flag(cdr, AST_CDR_FLAG_POSTED)) ast_log(LOG_WARNING, "CDR on channel '%s' already posted\n", chan); if (cdr->disposition < AST_CDR_ANSWERED) cdr->disposition = AST_CDR_ANSWERED; @@ -167,9 +167,9 @@ { char *chan; while (cdr) { - if (!ast_cdr_has_flag(cdr,AST_CDR_FLAG_LOCKED)) { + if (!ast_test_flag(cdr, AST_CDR_FLAG_LOCKED)) { chan = !ast_strlen_zero(cdr->channel) ? cdr->channel : ""; - if (ast_cdr_has_flag(cdr,AST_CDR_FLAG_POSTED)) + if (ast_test_flag(cdr, AST_CDR_FLAG_POSTED)) ast_log(LOG_WARNING, "CDR on channel '%s' already posted\n", chan); if (cdr->disposition < AST_CDR_BUSY) cdr->disposition = AST_CDR_BUSY; @@ -183,9 +183,9 @@ char *chan; while (cdr) { chan = !ast_strlen_zero(cdr->channel) ? cdr->channel : ""; - if (ast_cdr_has_flag(cdr,AST_CDR_FLAG_POSTED)) + if (ast_test_flag(cdr, AST_CDR_FLAG_POSTED)) ast_log(LOG_WARNING, "CDR on channel '%s' already posted\n", chan); - if(!ast_cdr_has_flag(cdr,AST_CDR_FLAG_LOCKED)) + if(!ast_test_flag(cdr, AST_CDR_FLAG_LOCKED)) cdr->disposition = AST_CDR_FAILED; cdr = cdr->next; } @@ -221,9 +221,9 @@ char *chan; while (cdr) { chan = !ast_strlen_zero(cdr->channel) ? cdr->channel : ""; - if (ast_cdr_has_flag(cdr,AST_CDR_FLAG_POSTED)) + if (ast_test_flag(cdr, AST_CDR_FLAG_POSTED)) ast_log(LOG_WARNING, "CDR on channel '%s' already posted\n", chan); - if(!ast_cdr_has_flag(cdr,AST_CDR_FLAG_LOCKED)) + if(!ast_test_flag(cdr, AST_CDR_FLAG_LOCKED)) strncpy(cdr->dstchannel, chann, sizeof(cdr->dstchannel) - 1); cdr = cdr->next; } @@ -233,9 +233,9 @@ { char *chan; while (cdr) { - if(!ast_cdr_has_flag(cdr,AST_CDR_FLAG_LOCKED)) { + if(!ast_test_flag(cdr, AST_CDR_FLAG_LOCKED)) { chan = !ast_strlen_zero(cdr->channel) ? cdr->channel : ""; - if (ast_cdr_has_flag(cdr,AST_CDR_FLAG_POSTED)) + if (ast_test_flag(cdr, AST_CDR_FLAG_POSTED)) ast_log(LOG_WARNING, "CDR on channel '%s' already posted\n", chan); if (!app) app = ""; @@ -253,7 +253,7 @@ char tmp[AST_MAX_EXTENSION] = ""; char *num; while (cdr) { - if(!ast_cdr_has_flag(cdr,AST_CDR_FLAG_LOCKED)) { + if(!ast_test_flag(cdr, AST_CDR_FLAG_LOCKED)) { /* Grab source from ANI or normal Caller*ID */ if (c->cid.cid_ani) num = c->cid.cid_ani; @@ -285,7 +285,7 @@ char *num; char tmp[AST_MAX_EXTENSION] = ""; while (cdr) { - if(!ast_cdr_has_flag(cdr,AST_CDR_FLAG_LOCKED)) { + if(!ast_test_flag(cdr, AST_CDR_FLAG_LOCKED)) { chan = !ast_strlen_zero(cdr->channel) ? cdr->channel : ""; if (!ast_strlen_zero(cdr->channel)) ast_log(LOG_WARNING, "CDR already initialized on '%s'\n", chan); @@ -335,7 +335,7 @@ char *chan; while (cdr) { chan = !ast_strlen_zero(cdr->channel) ? cdr->channel : ""; - if (ast_cdr_has_flag(cdr,AST_CDR_FLAG_POSTED)) + if (ast_test_flag(cdr, AST_CDR_FLAG_POSTED)) ast_log(LOG_WARNING, "CDR on channel '%s' already posted\n", chan); if (!cdr->start.tv_sec && !cdr->start.tv_usec) ast_log(LOG_WARNING, "CDR on channel '%s' has not started\n", chan); @@ -380,7 +380,7 @@ strncpy(chan->accountcode, account, sizeof(chan->accountcode) - 1); while (cdr) { - if(!ast_cdr_has_flag(cdr,AST_CDR_FLAG_LOCKED)) + if(!ast_test_flag(cdr, AST_CDR_FLAG_LOCKED)) strncpy(cdr->accountcode, chan->accountcode, sizeof(cdr->accountcode) - 1); cdr = cdr->next; } @@ -404,7 +404,7 @@ struct ast_cdr *cdr = chan->cdr; while (cdr) { - if(!ast_cdr_has_flag(cdr,AST_CDR_FLAG_LOCKED)) + if(!ast_test_flag(cdr, AST_CDR_FLAG_LOCKED)) strncpy(cdr->userfield, userfield, sizeof(cdr->userfield) - 1); cdr = cdr->next; } @@ -419,7 +419,7 @@ { int len = strlen(cdr->userfield); - if(!ast_cdr_has_flag(cdr,AST_CDR_FLAG_LOCKED)) + if(!ast_test_flag(cdr, AST_CDR_FLAG_LOCKED)) strncpy(cdr->userfield+len, userfield, sizeof(cdr->userfield) - len - 1); cdr = cdr->next; } @@ -433,7 +433,7 @@ char tmp[AST_MAX_EXTENSION] = ""; /* Grab source from ANI or normal Caller*ID */ while (cdr) { - if(!ast_cdr_has_flag(cdr,AST_CDR_FLAG_LOCKED)) { + if(!ast_test_flag(cdr, AST_CDR_FLAG_LOCKED)) { /* Grab source from ANI or normal Caller*ID */ if (c->cid.cid_ani) num = c->cid.cid_ani; @@ -491,7 +491,7 @@ struct ast_cdr_beitem *i; while (cdr) { chan = !ast_strlen_zero(cdr->channel) ? cdr->channel : ""; - if (ast_cdr_has_flag(cdr,AST_CDR_FLAG_POSTED)) + if (ast_test_flag(cdr, AST_CDR_FLAG_POSTED)) ast_log(LOG_WARNING, "CDR on channel '%s' already posted\n", chan); if (!cdr->end.tv_sec && !cdr->end.tv_usec) ast_log(LOG_WARNING, "CDR on channel '%s' lacks end\n", chan); @@ -502,7 +502,7 @@ cdr->billsec = cdr->end.tv_sec - cdr->answer.tv_sec + (cdr->end.tv_usec - cdr->answer.tv_usec) / 1000000; } else cdr->billsec = 0; - ast_cdr_add_flag(cdr,AST_CDR_FLAG_POSTED); + ast_set_flag(cdr, AST_CDR_FLAG_POSTED); ast_mutex_lock(&cdrlock); i = bes; while(i) { @@ -516,15 +516,16 @@ void ast_cdr_reset(struct ast_cdr *cdr, int flags) { + struct ast_flags tmp = {flags}; while (cdr) { /* Post if requested */ - if (ast_cdr_compare_flag(flags,AST_CDR_FLAG_LOCKED) || !ast_cdr_has_flag(cdr,AST_CDR_FLAG_LOCKED)) { - if (ast_cdr_compare_flag(flags,AST_CDR_FLAG_POSTED)) { + if (ast_test_flag(&tmp, AST_CDR_FLAG_LOCKED) || !ast_test_flag(cdr, AST_CDR_FLAG_LOCKED)) { + if (ast_test_flag(&tmp, AST_CDR_FLAG_POSTED)) { ast_cdr_end(cdr); ast_cdr_post(cdr); } /* Reset to initial state */ - cdr->flags=0; + ast_clear_flag(cdr, AST_FLAGS_ALL); memset(&cdr->start, 0, sizeof(cdr->start)); memset(&cdr->end, 0, sizeof(cdr->end)); memset(&cdr->answer, 0, sizeof(cdr->answer)); Index: channel.c =================================================================== RCS file: /usr/cvsroot/asterisk/channel.c,v retrieving revision 1.163 diff -u -r1.163 channel.c --- channel.c 10 Jan 2005 04:23:39 -0000 1.163 +++ channel.c 10 Jan 2005 06:37:14 -0000 @@ -2675,9 +2675,9 @@ gettimeofday(&start_time,NULL); time_left_ms = config->timelimit; - if ((config->features_caller & AST_FEATURE_PLAY_WARNING) && config->start_sound && firstpass) + if ((ast_test_flag(&(config->features_caller), AST_FEATURE_PLAY_WARNING)) && config->start_sound && firstpass) bridge_playfile(c0,c1,config->start_sound,time_left_ms / 1000); - if ((config->features_callee & AST_FEATURE_PLAY_WARNING) && config->start_sound && firstpass) + if ((ast_test_flag(&(config->features_callee), AST_FEATURE_PLAY_WARNING)) && config->start_sound && firstpass) bridge_playfile(c1,c0,config->start_sound,time_left_ms / 1000); /* Stop if we're a zombie or need a soft hangup */ @@ -2715,7 +2715,7 @@ elapsed_ms = tvdiff(&precise_now,&start_time); time_left_ms = config->timelimit - elapsed_ms; - if (playitagain && ((config->features_caller & AST_FEATURE_PLAY_WARNING) || (config->features_callee & AST_FEATURE_PLAY_WARNING)) && (config->play_warning && time_left_ms <= config->play_warning)) { + if (playitagain && ((ast_test_flag(&(config->features_caller), AST_FEATURE_PLAY_WARNING)) || (ast_test_flag(&(config->features_callee), AST_FEATURE_PLAY_WARNING))) && (config->play_warning && time_left_ms <= config->play_warning)) { /* narrowing down to the end */ if (config->warning_freq == 0) { playit = 1; @@ -2731,9 +2731,9 @@ } } if (time_left_ms <= 0) { - if ((config->features_caller & AST_FEATURE_PLAY_WARNING) && config->end_sound) + if ((ast_test_flag(&(config->features_caller), AST_FEATURE_PLAY_WARNING)) && config->end_sound) bridge_playfile(c0,c1,config->end_sound,0); - if ((config->features_callee & AST_FEATURE_PLAY_WARNING) && config->end_sound) + if ((ast_test_flag(&(config->features_callee), AST_FEATURE_PLAY_WARNING)) && config->end_sound) bridge_playfile(c1,c0,config->end_sound,0); *fo = NULL; if (who) *rc = who; @@ -2741,9 +2741,9 @@ break; } if (time_left_ms >= 5000 && playit) { - if ((config->features_caller & AST_FEATURE_PLAY_WARNING) && config->warning_sound && config->play_warning) + if ((ast_test_flag(&(config->features_caller), AST_FEATURE_PLAY_WARNING)) && config->warning_sound && config->play_warning) bridge_playfile(c0,c1,config->warning_sound,time_left_ms / 1000); - if ((config->features_callee & AST_FEATURE_PLAY_WARNING) && config->warning_sound && config->play_warning) + if ((ast_test_flag(&(config->features_callee), AST_FEATURE_PLAY_WARNING)) && config->warning_sound && config->play_warning) bridge_playfile(c1,c0,config->warning_sound,time_left_ms / 1000); playit = 0; } Index: apps/app_dial.c =================================================================== RCS file: /usr/cvsroot/asterisk/apps/app_dial.c,v retrieving revision 1.123 diff -u -r1.123 app_dial.c --- apps/app_dial.c 8 Jan 2005 17:23:29 -0000 1.123 +++ apps/app_dial.c 10 Jan 2005 06:37:15 -0000 @@ -1085,21 +1085,21 @@ if (!res) { memset(&config,0,sizeof(struct ast_bridge_config)); if (play_to_caller) - config.features_caller |= AST_FEATURE_PLAY_WARNING; + ast_set_flag(&(config.features_caller), AST_FEATURE_PLAY_WARNING); if (play_to_callee) - config.features_callee |= AST_FEATURE_PLAY_WARNING; + ast_set_flag(&(config.features_callee), AST_FEATURE_PLAY_WARNING); if (ast_test_flag(&peerflags, DIAL_ALLOWREDIRECT_IN)) - config.features_callee |= AST_FEATURE_REDIRECT; + ast_set_flag(&(config.features_callee), AST_FEATURE_REDIRECT); if (ast_test_flag(&peerflags, DIAL_ALLOWREDIRECT_OUT)) - config.features_caller |= AST_FEATURE_REDIRECT; + ast_set_flag(&(config.features_caller), AST_FEATURE_REDIRECT); if (ast_test_flag(&peerflags, DIAL_ALLOWDISCONNECT_IN)) - config.features_callee |= AST_FEATURE_DISCONNECT; + ast_set_flag(&(config.features_callee), AST_FEATURE_DISCONNECT); if (ast_test_flag(&peerflags, DIAL_ALLOWDISCONNECT_OUT)) - config.features_caller |= AST_FEATURE_DISCONNECT; + ast_set_flag(&(config.features_caller), AST_FEATURE_DISCONNECT); if (ast_test_flag(&peerflags, DIAL_MONITOR_IN)) - config.features_callee |= AST_FEATURE_AUTOMON; + ast_set_flag(&(config.features_callee), AST_FEATURE_AUTOMON); if (ast_test_flag(&peerflags, DIAL_MONITOR_OUT)) - config.features_caller |= AST_FEATURE_AUTOMON; + ast_set_flag(&(config.features_caller), AST_FEATURE_AUTOMON); config.timelimit = timelimit; config.play_warning = play_warning; config.warning_freq = warning_freq; Index: apps/app_forkcdr.c =================================================================== RCS file: /usr/cvsroot/asterisk/apps/app_forkcdr.c,v retrieving revision 1.3 diff -u -r1.3 app_forkcdr.c --- apps/app_forkcdr.c 19 Nov 2004 17:52:53 -0000 1.3 +++ apps/app_forkcdr.c 10 Jan 2005 06:37:15 -0000 @@ -41,7 +41,7 @@ gettimeofday(&newcdr->start, NULL); memset(&newcdr->answer, 0, sizeof(newcdr->answer)); newcdr->disposition = AST_CDR_NOANSWER; - ast_cdr_add_flag(cdr,AST_CDR_FLAG_CHILD|AST_CDR_FLAG_LOCKED); + ast_set_flag(cdr, AST_CDR_FLAG_CHILD|AST_CDR_FLAG_LOCKED); } static void ast_cdr_fork(struct ast_channel *chan) { Index: apps/app_queue.c =================================================================== RCS file: /usr/cvsroot/asterisk/apps/app_queue.c,v retrieving revision 1.113 diff -u -r1.113 app_queue.c --- apps/app_queue.c 8 Jan 2005 19:00:46 -0000 1.113 +++ apps/app_queue.c 10 Jan 2005 06:37:16 -0000 @@ -1543,13 +1543,13 @@ memset(&config,0,sizeof(struct ast_bridge_config)); if (ast_test_flag(&flags, QUEUE_FLAG_REDIR_IN)) - config.features_callee |= AST_FEATURE_REDIRECT; + ast_set_flag(&(config.features_callee), AST_FEATURE_REDIRECT); if (ast_test_flag(&flags, QUEUE_FLAG_REDIR_OUT)) - config.features_caller |= AST_FEATURE_REDIRECT; + ast_set_flag(&(config.features_caller), AST_FEATURE_REDIRECT); if (ast_test_flag(&flags, QUEUE_FLAG_DISCON_IN)) - config.features_callee |= AST_FEATURE_DISCONNECT; + ast_set_flag(&(config.features_callee), AST_FEATURE_DISCONNECT); if (ast_test_flag(&flags, QUEUE_FLAG_DISCON_OUT)) - config.features_caller |= AST_FEATURE_DISCONNECT; + ast_set_flag(&(config.features_caller), AST_FEATURE_DISCONNECT); bridge = ast_bridge_call(qe->chan,peer,&config); if (strcasecmp(oldcontext, qe->chan->context) || strcasecmp(oldexten, qe->chan->exten)) { Index: include/asterisk/app.h =================================================================== RCS file: /usr/cvsroot/asterisk/include/asterisk/app.h,v retrieving revision 1.23 diff -u -r1.23 app.h --- include/asterisk/app.h 9 Jan 2005 09:01:40 -0000 1.23 +++ include/asterisk/app.h 10 Jan 2005 06:37:16 -0000 @@ -94,7 +94,7 @@ int ast_app_dtget(struct ast_channel *chan, const char *context, char *collect, size_t size, int maxlen, int timeout); //! Allow to record message and have a review option -int ast_record_review(struct ast_channel *chan, const char *playfile, const char *recordfile, int maxtime, const char *fmt, int *duration); +int ast_record_review(struct ast_channel *chan, char *playfile, char *recordfile, int maxtime, char *fmt, int *duration); #if defined(__cplusplus) || defined(c_plusplus) } Index: include/asterisk/cdr.h =================================================================== RCS file: /usr/cvsroot/asterisk/include/asterisk/cdr.h,v retrieving revision 1.16 diff -u -r1.16 cdr.h --- include/asterisk/cdr.h 27 Oct 2004 03:33:14 -0000 1.16 +++ include/asterisk/cdr.h 10 Jan 2005 06:37:16 -0000 @@ -73,7 +73,7 @@ /*! What account number to use */ char accountcode[20]; /*! flags */ - int flags; + unsigned int flags; /* Unique Channel Identifier */ char uniqueid[32]; /* User field */ @@ -249,11 +249,6 @@ extern char ast_default_accountcode[20]; -#define ast_cdr_compare_flag(flags, flag) (flags & (flag)) -#define ast_cdr_has_flag(cdr, flag) ((cdr)->flags & (flag)) -#define ast_cdr_add_flag(cdr, flag) ((cdr)->flags |= (flag)) -#define ast_cdr_del_flag(cdr, flag) ((cdr)->flags &= ~(flag)) - extern struct ast_cdr *ast_cdr_append(struct ast_cdr *cdr, struct ast_cdr *newcdr); #endif /* _CDR_H */ Index: include/asterisk/channel.h =================================================================== RCS file: /usr/cvsroot/asterisk/include/asterisk/channel.h,v retrieving revision 1.70 diff -u -r1.70 channel.h --- include/asterisk/channel.h 9 Jan 2005 19:40:01 -0000 1.70 +++ include/asterisk/channel.h 10 Jan 2005 06:37:16 -0000 @@ -36,6 +36,7 @@ #include #include +#include #define AST_CHANNEL_NAME 80 @@ -238,8 +239,8 @@ #define AST_FEATURE_FLAG_NEEDSDTMF (1 << 0) struct ast_bridge_config { - unsigned int features_caller; - unsigned int features_callee; + struct ast_flags features_caller; + struct ast_flags features_callee; long timelimit; long play_warning; long warning_freq; Index: pbx/pbx_dundi.c =================================================================== RCS file: /usr/cvsroot/asterisk/pbx/pbx_dundi.c,v retrieving revision 1.24 diff -u -r1.24 pbx_dundi.c --- pbx/pbx_dundi.c 6 Jan 2005 06:07:44 -0000 1.24 +++ pbx/pbx_dundi.c 10 Jan 2005 06:37:18 -0000 @@ -164,7 +164,7 @@ dundi_eid them_eid; /* Their EID, to us */ aes_encrypt_ctx ecx; /* AES 128 Encryption context */ aes_decrypt_ctx dcx; /* AES 128 Decryption context */ - int flags; /* Has final packet been sent */ + unsigned int flags; /* Has final packet been sent */ int ttl; /* Remaining TTL for queries on this one */ int thread; /* We have a calling thread */ int retranstimer; /* How long to wait before retransmissions */ @@ -461,7 +461,7 @@ trans->oiseqno = 0; trans->oseqno = 0; trans->aseqno = 0; - trans->flags &= ~FLAG_FINAL; + ast_clear_flag(trans, FLAG_FINAL); return 0; } @@ -507,39 +507,38 @@ static int dundi_lookup_local(struct dundi_result *dr, struct dundi_mapping *map, char *called_number, dundi_eid *us_eid, int anscnt, struct dundi_hint_metadata *hmd) { - int flags; + struct ast_flags flags = {0}; int x; if (!ast_strlen_zero(map->lcontext)) { - flags = 0; if (ast_exists_extension(NULL, map->lcontext, called_number, 1, NULL)) - flags |= DUNDI_FLAG_EXISTS; + ast_set_flag(&flags, DUNDI_FLAG_EXISTS); if (ast_canmatch_extension(NULL, map->lcontext, called_number, 1, NULL)) - flags |= DUNDI_FLAG_CANMATCH; + ast_set_flag(&flags, DUNDI_FLAG_CANMATCH); if (ast_matchmore_extension(NULL, map->lcontext, called_number, 1, NULL)) - flags |= DUNDI_FLAG_MATCHMORE; + ast_set_flag(&flags, DUNDI_FLAG_MATCHMORE); if (ast_ignore_pattern(map->lcontext, called_number)) - flags |= DUNDI_FLAG_IGNOREPAT; + ast_set_flag(&flags, DUNDI_FLAG_IGNOREPAT); /* Clearly we can't say 'don't ask' anymore if we found anything... */ - if (flags) - hmd->flags &= ~DUNDI_HINT_DONT_ASK; + if (ast_test_flag(&flags, AST_FLAGS_ALL)) + ast_clear_flag(hmd, DUNDI_HINT_DONT_ASK); if (map->options & DUNDI_FLAG_INTERNAL_NOPARTIAL) { /* Skip partial answers */ - flags &= ~(DUNDI_FLAG_MATCHMORE|DUNDI_FLAG_CANMATCH); + ast_clear_flag(&flags, DUNDI_FLAG_MATCHMORE|DUNDI_FLAG_CANMATCH); } - if (flags) { + if (ast_test_flag(&flags, AST_FLAGS_ALL)) { struct varshead headp; struct ast_var_t *newvariable; - flags |= map->options & 0xffff; - dr[anscnt].flags = flags; + ast_set_flag(&flags, map->options & 0xffff); + ast_copy_flags(dr + anscnt, &flags, AST_FLAGS_ALL); dr[anscnt].techint = map->tech; dr[anscnt].weight = map->weight; dr[anscnt].expiration = DUNDI_DEFAULT_CACHE_TIME; strncpy(dr[anscnt].tech, tech2str(map->tech), sizeof(dr[anscnt].tech)); dr[anscnt].eid = *us_eid; dundi_eid_to_str(dr[anscnt].eid_str, sizeof(dr[anscnt].eid_str), &dr[anscnt].eid); - if (flags & DUNDI_FLAG_EXISTS) { + if (ast_test_flag(&flags, DUNDI_FLAG_EXISTS)) { AST_LIST_HEAD_INIT(&headp); newvariable = ast_var_assign("NUMBER", called_number); AST_LIST_INSERT_HEAD(&headp, newvariable, entries); @@ -622,9 +621,9 @@ } ast_mutex_lock(&peerlock); /* Truncate if "don't ask" isn't present */ - if (!(hmd.flags & DUNDI_HINT_DONT_ASK)) + if (!ast_test_flag(&hmd, DUNDI_HINT_DONT_ASK)) hmd.exten[0] = '\0'; - if (st->trans->flags & FLAG_DEAD) { + if (ast_test_flag(st->trans, FLAG_DEAD)) { ast_log(LOG_DEBUG, "Our transaction went away!\n"); st->trans->thread = 0; destroy_trans(st->trans, 0); @@ -661,9 +660,9 @@ ast_mutex_lock(&peerlock); /* Truncate if "don't ask" isn't present */ - if (!(hmd.flags & DUNDI_HINT_DONT_ASK)) + if (!ast_test_flag(&hmd, DUNDI_HINT_DONT_ASK)) hmd.exten[0] = '\0'; - if (st->trans->flags & FLAG_DEAD) { + if (ast_test_flag(st->trans, FLAG_DEAD)) { ast_log(LOG_DEBUG, "Our transaction went away!\n"); st->trans->thread = 0; destroy_trans(st->trans, 0); @@ -714,7 +713,7 @@ res = dundi_query_eid_internal(&dei, st->called_context, &st->reqeid, &hmd, st->ttl, 1, st->eids); } ast_mutex_lock(&peerlock); - if (st->trans->flags & FLAG_DEAD) { + if (ast_test_flag(st->trans, FLAG_DEAD)) { ast_log(LOG_DEBUG, "Our transaction went away!\n"); st->trans->thread = 0; destroy_trans(st->trans, 0); @@ -812,10 +811,10 @@ expiration = DUNDI_DEFAULT_CACHE_TIME; /* Only cache hint if "don't ask" is there... */ - if (!(ntohs(hint->flags)& DUNDI_HINT_DONT_ASK)) + if (!ast_test_flag(hint, htons(DUNDI_HINT_DONT_ASK))) return 0; - unaffected = ntohs(hint->flags) & DUNDI_HINT_UNAFFECTED; + unaffected = ast_test_flag(hint, htons(DUNDI_HINT_UNAFFECTED)); dundi_eid_to_str_short(eidpeer_str, sizeof(eidpeer_str), eidpeer); dundi_eid_to_str_short(eidroot_str, sizeof(eidroot_str), &req->root_eid); @@ -933,7 +932,7 @@ strncpy(trans->parent->dr[trans->parent->respcount].tech, tech2str(ies->answers[x]->protocol), sizeof(trans->parent->dr[trans->parent->respcount].tech)); trans->parent->respcount++; - trans->parent->hmd->flags &= ~DUNDI_HINT_DONT_ASK; + ast_clear_flag(trans->parent->hmd, DUNDI_HINT_DONT_ASK); } else if (trans->parent->dr[z].weight > ies->answers[x]->weight) { /* Update weight if appropriate */ trans->parent->dr[z].weight = ies->answers[x]->weight; @@ -1126,7 +1125,7 @@ char data[1024]=""; char *ptr, *term, *src; int tech; - int flags; + struct ast_flags flags; int weight; int length; int z; @@ -1141,7 +1140,7 @@ if (expiration > 0) { ast_log(LOG_DEBUG, "Found cache expiring in %d seconds!\n", (int)(timeout - now)); ptr += length; - while((sscanf(ptr, "%d/%d/%d/%n", &flags, &weight, &tech, &length) == 3)) { + while((sscanf(ptr, "%d/%d/%d/%n", &(flags.flags), &weight, &tech, &length) == 3)) { ptr += length; term = strchr(ptr, '|'); if (term) { @@ -1153,7 +1152,7 @@ } else src = ""; ast_log(LOG_DEBUG, "Found cached answer '%s/%s' originally from '%s' with flags '%s' on behalf of '%s'\n", - tech2str(tech), ptr, src, dundi_flags2str(fs, sizeof(fs), flags), eid_str_full); + tech2str(tech), ptr, src, dundi_flags2str(fs, sizeof(fs), flags.flags), eid_str_full); /* Make sure it's not already there */ for (z=0;zrespcount;z++) { if ((req->dr[z].techint == tech) && @@ -1162,7 +1161,7 @@ } if (z == req->respcount) { /* Copy into parent responses */ - req->dr[req->respcount].flags = flags; + ast_copy_flags(&(req->dr[req->respcount]), &flags, AST_FLAGS_ALL); req->dr[req->respcount].weight = weight; req->dr[req->respcount].techint = tech; req->dr[req->respcount].expiration = expiration; @@ -1174,7 +1173,7 @@ strncpy(req->dr[req->respcount].tech, tech2str(tech), sizeof(req->dr[req->respcount].tech)); req->respcount++; - req->hmd->flags &= ~DUNDI_HINT_DONT_ASK; + ast_clear_flag(req->hmd, DUNDI_HINT_DONT_ASK); } else if (req->dr[z].weight > weight) req->dr[z].weight = weight; ptr = term + 1; @@ -1253,7 +1252,7 @@ trans->them_eid = p->eid; /* Enable encryption if appropriate */ if (!ast_strlen_zero(p->inkey)) - trans->flags |= FLAG_ENCRYPT; + ast_set_flag(trans, FLAG_ENCRYPT); if (p->maxms) { trans->autokilltimeout = p->maxms; trans->retranstimer = DUNDI_DEFAULT_RETRANS_TIMER; @@ -1406,10 +1405,10 @@ if (update_key(peer)) return -1; if (!peer->sentfullkey) - trans->flags |= FLAG_SENDFULLKEY; + ast_set_flag(trans, FLAG_SENDFULLKEY); /* Append key data */ dundi_ie_append_eid(&ied, DUNDI_IE_EID, &trans->us_eid); - if (trans->flags & FLAG_SENDFULLKEY) { + if (ast_test_flag(trans, FLAG_SENDFULLKEY)) { dundi_ie_append_raw(&ied, DUNDI_IE_SHAREDKEY, peer->txenckey, 128); dundi_ie_append_raw(&ied, DUNDI_IE_SIGNATURE, peer->txenckey + 128, 128); } else { @@ -1634,7 +1633,7 @@ if (ies.cause < 1) { /* Success of some sort */ ast_log(LOG_DEBUG, "Looks like success of some sort (%d), %d answers\n", ies.cause, ies.anscount); - if (trans->flags & FLAG_ENCRYPT) { + if (ast_test_flag(trans, FLAG_ENCRYPT)) { authpass = encrypted; } else authpass = 1; @@ -1668,7 +1667,7 @@ strncpy(trans->parent->dr[trans->parent->respcount].tech, tech2str(ies.answers[x]->protocol), sizeof(trans->parent->dr[trans->parent->respcount].tech)); trans->parent->respcount++; - trans->parent->hmd->flags &= ~DUNDI_HINT_DONT_ASK; + ast_clear_flag(trans->parent->hmd, DUNDI_HINT_DONT_ASK); } else if (trans->parent->dr[z].weight > ies.answers[x]->weight) { /* Update weight if appropriate */ trans->parent->dr[z].weight = ies.answers[x]->weight; @@ -1680,18 +1679,18 @@ /* Save all the results (if any) we had. Even if no results, still cache lookup. Let the cache know if this request was unaffected by our entity list. */ cache_save(&trans->them_eid, trans->parent, y, - ies.hint ? ntohs(ies.hint->flags) & DUNDI_HINT_UNAFFECTED : 0, ies.expiration, 0); + ies.hint ? ast_test_flag(ies.hint, htons(DUNDI_HINT_UNAFFECTED)) : 0, ies.expiration, 0); if (ies.hint) { cache_save_hint(&trans->them_eid, trans->parent, ies.hint, ies.expiration); - if (ntohs(ies.hint->flags) & DUNDI_HINT_TTL_EXPIRED) - trans->parent->hmd->flags |= DUNDI_HINT_TTL_EXPIRED; - if (ntohs(ies.hint->flags) & DUNDI_HINT_DONT_ASK) { + if (ast_test_flag(ies.hint, htons(DUNDI_HINT_TTL_EXPIRED))) + ast_set_flag(trans->parent->hmd, DUNDI_HINT_TTL_EXPIRED); + if (ast_test_flag(ies.hint, htons(DUNDI_HINT_DONT_ASK))) { if (strlen(ies.hint->data) > strlen(trans->parent->hmd->exten)) { strncpy(trans->parent->hmd->exten, ies.hint->data, sizeof(trans->parent->hmd->exten) - 1); } } else { - trans->parent->hmd->flags &= ~DUNDI_HINT_DONT_ASK; + ast_clear_flag(trans->parent->hmd, DUNDI_HINT_DONT_ASK); } } if (ies.expiration > 0) { @@ -1718,7 +1717,7 @@ if (ies.cause < 1) { /* Success of some sort */ ast_log(LOG_DEBUG, "Looks like success of some sort (%d)\n", ies.cause); - if (trans->flags & FLAG_ENCRYPT) { + if (ast_test_flag(trans, FLAG_ENCRYPT)) { authpass = encrypted; } else authpass = 1; @@ -1750,8 +1749,8 @@ } } if (ies.hint) { - if (ntohs(ies.hint->flags) & DUNDI_HINT_TTL_EXPIRED) - trans->parent->hmd->flags |= DUNDI_HINT_TTL_EXPIRED; + if (ast_test_flag(ies.hint, htons(DUNDI_HINT_TTL_EXPIRED))) + ast_set_flag(trans->parent->hmd, DUNDI_HINT_TTL_EXPIRED); } } /* Close connection if not final */ @@ -1772,7 +1771,7 @@ if (ies.cause < 1) { int hasauth; /* Success of some sort */ - if (trans->flags & FLAG_ENCRYPT) { + if (ast_test_flag(trans, FLAG_ENCRYPT)) { hasauth = encrypted; } else hasauth = 1; @@ -1805,13 +1804,13 @@ dundi_send(trans, DUNDI_COMMAND_CANCEL, 0, 1, NULL); break; case DUNDI_COMMAND_ENCREJ: - if ((trans->flags & FLAG_SENDFULLKEY) || !trans->lasttrans || !(peer = find_peer(&trans->them_eid))) { + if ((ast_test_flag(trans, FLAG_SENDFULLKEY)) || !trans->lasttrans || !(peer = find_peer(&trans->them_eid))) { /* No really, it's over at this point */ if (!final) dundi_send(trans, DUNDI_COMMAND_CANCEL, 0, 1, NULL); } else { /* Send with full key */ - trans->flags |= FLAG_SENDFULLKEY; + ast_set_flag(trans, FLAG_SENDFULLKEY); if (final) { /* Ooops, we got a final message, start by sending ACK... */ dundi_ack(trans, hdr->cmdresp & 0x80); @@ -1853,7 +1852,7 @@ trans->ecx = peer->them_ecx; trans->dcx = peer->them_dcx; } - if ((trans->flags & FLAG_ENCRYPT) && ies.encblock && ies.enclen) { + if (ast_test_flag(trans, FLAG_ENCRYPT) && ies.encblock && ies.enclen) { struct dundi_hdr *dhdr; unsigned char decoded[MAX_PACKET_SIZE]; int ddatalen; @@ -1873,7 +1872,7 @@ } if (!final) { /* Turn off encryption */ - trans->flags &= ~FLAG_ENCRYPT; + ast_clear_flag(trans, FLAG_ENCRYPT); dundi_send(trans, DUNDI_COMMAND_ENCREJ, 0, 1, NULL); } break; @@ -1936,7 +1935,7 @@ /* Got a transaction, see where this header fits in */ if (h->oseqno == trans->iseqno) { /* Just what we were looking for... Anything but ack increments iseqno */ - if (ack_trans(trans, h->iseqno) && (trans->flags & FLAG_FINAL)) { + if (ack_trans(trans, h->iseqno) && ast_test_flag(trans, FLAG_FINAL)) { /* If final, we're done */ destroy_trans(trans, 0); return 0; @@ -2759,14 +2758,14 @@ memset(trans, 0, sizeof(struct dundi_transaction)); if (global_storehistory) { gettimeofday(&trans->start, NULL); - trans->flags |= FLAG_STOREHIST; + ast_set_flag(trans, FLAG_STOREHIST); } trans->retranstimer = DUNDI_DEFAULT_RETRANS_TIMER; trans->autokillid = -1; if (p) { apply_peer(trans, p); if (!p->sentfullkey) - trans->flags |= FLAG_SENDFULLKEY; + ast_set_flag(trans, FLAG_SENDFULLKEY); } trans->strans = tid; trans->allnext = alltrans; @@ -2829,7 +2828,7 @@ int x; int cnt; char eid_str[20]; - if (trans->flags & (FLAG_ISREG | FLAG_ISQUAL | FLAG_STOREHIST)) { + if (ast_test_flag(trans, FLAG_ISREG | FLAG_ISQUAL | FLAG_STOREHIST)) { peer = peers; while (peer) { if (peer->regtrans == trans) @@ -2857,7 +2856,7 @@ } peer->qualtrans = NULL; } - if (trans->flags & FLAG_STOREHIST) { + if (ast_test_flag(trans, FLAG_STOREHIST)) { if (trans->parent && !ast_strlen_zero(trans->parent->number)) { if (!dundi_eid_cmp(&trans->them_eid, &peer->eid)) { peer->avgms = 0; @@ -2932,7 +2931,7 @@ trans->autokillid = -1; if (trans->thread) { /* If used by a thread, mark as dead and be done */ - trans->flags |= FLAG_DEAD; + ast_set_flag(trans, FLAG_DEAD); } else free(trans); } @@ -2946,7 +2945,7 @@ pack = data; if (pack->retrans < 1) { pack->retransid = -1; - if (!(pack->parent->flags & FLAG_ISQUAL)) + if (!ast_test_flag(pack->parent, FLAG_ISQUAL)) ast_log(LOG_NOTICE, "Max retries exceeded to host '%s:%d' msg %d on call %d\n", ast_inet_ntoa(iabuf, sizeof(iabuf), pack->parent->addr.sin_addr), ntohs(pack->parent->addr.sin_port), pack->h->oseqno, ntohs(pack->h->strans)); @@ -2970,7 +2969,7 @@ char eid_str[20]; len = sizeof(struct dundi_packet) + sizeof(struct dundi_hdr) + (ied ? ied->pos : 0); /* Reserve enough space for encryption */ - if (trans->flags & FLAG_ENCRYPT) + if (ast_test_flag(trans, FLAG_ENCRYPT)) len += 384; pack = malloc(len); if (pack) { @@ -2995,7 +2994,7 @@ } if (final) { pack->h->cmdresp |= DUNDI_COMMAND_FINAL; - trans->flags |= FLAG_FINAL; + ast_set_flag(trans, FLAG_FINAL); } pack->h->cmdflags = flags; if (cmdresp != DUNDI_COMMAND_ACK) { @@ -3004,7 +3003,7 @@ } trans->aseqno = trans->iseqno; /* If we have their public key, encrypt */ - if (trans->flags & FLAG_ENCRYPT) { + if (ast_test_flag(trans, FLAG_ENCRYPT)) { switch(cmdresp) { case DUNDI_COMMAND_REGREQ: case DUNDI_COMMAND_REGRESPONSE: @@ -3211,7 +3210,7 @@ trans = dr->trans; while(trans) { - if (!(trans->flags & FLAG_DEAD)) + if (!ast_test_flag(trans, FLAG_DEAD)) precache_trans(trans, maps, mapcount, expiration, foundanswers); trans = trans->next; } @@ -3222,7 +3221,7 @@ while(trans) { transn = trans->next; trans->thread = 0; - if (trans->flags & FLAG_DEAD) { + if (ast_test_flag(trans, FLAG_DEAD)) { ast_log(LOG_DEBUG, "Our transaction went away!\n"); destroy_trans(trans, 0); } @@ -3395,7 +3394,7 @@ if (!dundi_eid_cmp(avoid[x], &p->eid) || !dundi_eid_cmp(avoid[x], &p->us_eid)) { /* If not a direct connection, it affects our answer */ if (directs && !directs[x]) - dr->hmd->flags &= ~DUNDI_HINT_UNAFFECTED; + ast_clear_flag(dr->hmd, DUNDI_HINT_UNAFFECTED); break; } } @@ -3575,7 +3574,7 @@ do this earlier because we didn't know if we were going to have transactions or not. */ if (!ttl) { - hmd->flags |= DUNDI_HINT_TTL_EXPIRED; + ast_set_flag(hmd, DUNDI_HINT_TTL_EXPIRED); abort_request(&dr); unregister_request(&dr); close(dr.pfds[0]); @@ -3799,7 +3798,7 @@ do this earlier because we didn't know if we were going to have transactions or not. */ if (!ttl) { - hmd->flags |= DUNDI_HINT_TTL_EXPIRED; + ast_set_flag(hmd, DUNDI_HINT_TTL_EXPIRED); return 0; } @@ -3863,7 +3862,7 @@ if (results > 0) { sort_results(dr, results); for (x=0;xregtrans, 0); peer->regtrans = create_transaction(peer); if (peer->regtrans) { - peer->regtrans->flags |= FLAG_ISREG; + ast_set_flag(peer->regtrans, FLAG_ISREG); memset(&ied, 0, sizeof(ied)); dundi_ie_append_short(&ied, DUNDI_IE_VERSION, DUNDI_DEFAULT_VERSION); dundi_ie_append_eid(&ied, DUNDI_IE_EID, &peer->regtrans->us_eid); @@ -4130,7 +4129,7 @@ peer->qualtrans = create_transaction(peer); if (peer->qualtrans) { gettimeofday(&peer->qualtx, NULL); - peer->qualtrans->flags |= FLAG_ISQUAL; + ast_set_flag(peer->qualtrans, FLAG_ISQUAL); dundi_send(peer->qualtrans, DUNDI_COMMAND_NULL, 0, 1, NULL); } } @@ -4346,7 +4345,7 @@ } res = dundi_lookup(results, MAX_RESULTS, chan, data, exten, 0); for (x=0;x= priority) @@ -4399,7 +4398,7 @@ if (res > 0) { sort_results(results, res); for (x=0;x_softhangup || newchan->_state != AST_STATE_UP) { ast_hangup(newchan); @@ -671,7 +671,7 @@ ast_channel_masquerade(xferchan, transferee); ast_explicit_goto(xferchan, transferee->context, transferee->exten, transferee->priority); xferchan->_state = AST_STATE_UP; - xferchan->flags = 0; + ast_clear_flag(xferchan, AST_FLAGS_ALL); xferchan->_softhangup = 0; if ((f = ast_read(xferchan))) { @@ -685,7 +685,7 @@ } newchan->_state = AST_STATE_UP; - newchan->flags = 0; + ast_clear_flag(newchan, AST_FLAGS_ALL); newchan->_softhangup = 0; tobj = malloc(sizeof(struct ast_bridge_thread_obj)); @@ -789,16 +789,16 @@ static int ast_feature_interpret(struct ast_channel *chan, struct ast_channel *peer, struct ast_bridge_config *config, char *code, int sense) { int x; - unsigned int features; + struct ast_flags features; int res = FEATURE_RETURN_PASSDIGITS; if (sense == FEATURE_SENSE_CHAN) - features = config->features_caller; + ast_copy_flags(&features, &(config->features_caller), AST_FLAGS_ALL); else - features = config->features_callee; - ast_log(LOG_DEBUG, "Feature interpret: chan=%s, peer=%s, sense=%d, features=%d\n", chan->name, peer->name, sense, features); + ast_copy_flags(&features, &(config->features_callee), AST_FLAGS_ALL); + ast_log(LOG_DEBUG, "Feature interpret: chan=%s, peer=%s, sense=%d, features=%d\n", chan->name, peer->name, sense, features.flags); for (x=0;xflags = 0; + ast_clear_flag(config, AST_FLAGS_ALL); for (x=0;xfeatures_caller & builtin_features[x].feature_mask) { - if (builtin_features[x].flags & AST_FEATURE_FLAG_NEEDSDTMF) + if (ast_test_flag(&(config->features_caller), builtin_features[x].feature_mask)) { + if (ast_test_flag(builtin_features + x, AST_FEATURE_FLAG_NEEDSDTMF)) ast_set_flag(config, AST_BRIDGE_DTMF_CHANNEL_0); } - if (config->features_callee & builtin_features[x].feature_mask) { - if (builtin_features[x].flags & AST_FEATURE_FLAG_NEEDSDTMF) + if (ast_test_flag(&(config->features_callee), builtin_features[x].feature_mask)) { + if (ast_test_flag(builtin_features + x, AST_FEATURE_FLAG_NEEDSDTMF)) ast_set_flag(config, AST_BRIDGE_DTMF_CHANNEL_1); } } @@ -866,10 +866,10 @@ pbx_exec(peer, monitor_app, monitor_exec, 1); } - allowdisconnect_in = (config->features_callee & AST_FEATURE_DISCONNECT); - allowdisconnect_out = (config->features_caller & AST_FEATURE_DISCONNECT); - allowredirect_in = (config->features_callee & AST_FEATURE_REDIRECT); - allowredirect_out = (config->features_caller & AST_FEATURE_REDIRECT); + allowdisconnect_in = ast_test_flag(&(config->features_callee), AST_FEATURE_DISCONNECT); + allowdisconnect_out = ast_test_flag(&(config->features_caller), AST_FEATURE_DISCONNECT); + allowredirect_in = ast_test_flag(&(config->features_callee), AST_FEATURE_REDIRECT); + allowredirect_out = ast_test_flag(&(config->features_caller), AST_FEATURE_REDIRECT); set_config_flags(config); config->firstpass = 1; @@ -1030,8 +1030,8 @@ memcpy(&backup_config, config, sizeof(struct ast_bridge_config)); /* Setup temporary config options */ config->play_warning = 0; - config->features_caller &= ~(AST_FEATURE_PLAY_WARNING); - config->features_callee &= ~(AST_FEATURE_PLAY_WARNING); + ast_clear_flag(&(config->features_caller), AST_FEATURE_PLAY_WARNING); + ast_clear_flag(&(config->features_callee),AST_FEATURE_PLAY_WARNING); config->warning_freq = 0; config->warning_sound = NULL; config->end_sound = NULL; @@ -1301,8 +1301,8 @@ ast_verbose(VERBOSE_PREFIX_3 "Channel %s connected to parked call %d\n", chan->name, park); memset(&config,0,sizeof(struct ast_bridge_config)); - config.features_callee |= AST_FEATURE_REDIRECT; - config.features_caller |= AST_FEATURE_REDIRECT; + ast_set_flag(&(config.features_callee), AST_FEATURE_REDIRECT); + ast_set_flag(&(config.features_caller), AST_FEATURE_REDIRECT); config.timelimit = 0; config.play_warning = 0; config.warning_freq = 0;