diff --git a/apps/app_channelredirect.c b/apps/app_channelredirect.c index bea7a91f1c..8c98ed7b72 100644 --- a/apps/app_channelredirect.c +++ b/apps/app_channelredirect.c @@ -97,7 +97,7 @@ static int asyncgoto_exec(struct ast_channel *chan, const char *data) } if (ast_channel_pbx(chan2)) { - ast_set_flag(chan2, AST_FLAG_BRIDGE_HANGUP_DONT); /* don't let the after-bridge code run the h-exten */ + ast_set_flag(ast_channel_flags(chan2), AST_FLAG_BRIDGE_HANGUP_DONT); /* don't let the after-bridge code run the h-exten */ } res = ast_async_parseable_goto(chan2, args.label); diff --git a/apps/app_chanspy.c b/apps/app_chanspy.c index e773c47895..cafc62b395 100644 --- a/apps/app_chanspy.c +++ b/apps/app_chanspy.c @@ -489,7 +489,7 @@ static int start_spying(struct ast_autochan *autochan, const char *spychan_name, ast_set_flag(audiohook, AST_AUDIOHOOK_TRIGGER_SYNC | AST_AUDIOHOOK_SMALL_QUEUE); res = ast_audiohook_attach(autochan->chan, audiohook); - if (!res && ast_test_flag(autochan->chan, AST_FLAG_NBRIDGE) && (peer = ast_bridged_channel(autochan->chan))) { + if (!res && ast_test_flag(ast_channel_flags(autochan->chan), AST_FLAG_NBRIDGE) && (peer = ast_bridged_channel(autochan->chan))) { ast_softhangup(peer, AST_SOFTHANGUP_UNBRIDGE); } return res; @@ -583,7 +583,7 @@ static int channel_spy(struct ast_channel *chan, struct ast_autochan *spyee_auto } ast_channel_lock(chan); - ast_set_flag(chan, AST_FLAG_END_DTMF_ONLY); + ast_set_flag(ast_channel_flags(chan), AST_FLAG_END_DTMF_ONLY); ast_channel_unlock(chan); csth.volfactor = *volfactor; @@ -699,7 +699,7 @@ static int channel_spy(struct ast_channel *chan, struct ast_autochan *spyee_auto ast_deactivate_generator(chan); ast_channel_lock(chan); - ast_clear_flag(chan, AST_FLAG_END_DTMF_ONLY); + ast_clear_flag(ast_channel_flags(chan), AST_FLAG_END_DTMF_ONLY); ast_channel_unlock(chan); if (ast_test_flag(flags, OPTION_WHISPER | OPTION_BARGE | OPTION_DTMF_SWITCH_MODES)) { @@ -787,7 +787,7 @@ static int common_exec(struct ast_channel *chan, struct ast_flags *flags, if (ast_channel_state(chan) != AST_STATE_UP) ast_answer(chan); - ast_set_flag(chan, AST_FLAG_SPYING); /* so nobody can spy on us while we are spying */ + ast_set_flag(ast_channel_flags(chan), AST_FLAG_SPYING); /* so nobody can spy on us while we are spying */ waitms = 100; @@ -800,7 +800,7 @@ static int common_exec(struct ast_channel *chan, struct ast_flags *flags, if (!res) res = ast_waitstream(chan, ""); else if (res < 0) { - ast_clear_flag(chan, AST_FLAG_SPYING); + ast_clear_flag(ast_channel_flags(chan), AST_FLAG_SPYING); break; } if (!ast_strlen_zero(exitcontext)) { @@ -831,7 +831,7 @@ static int common_exec(struct ast_channel *chan, struct ast_flags *flags, res = ast_waitfordigit(chan, waitms); if (res < 0) { iter = ast_channel_iterator_destroy(iter); - ast_clear_flag(chan, AST_FLAG_SPYING); + ast_clear_flag(ast_channel_flags(chan), AST_FLAG_SPYING); break; } if (!ast_strlen_zero(exitcontext)) { @@ -873,7 +873,7 @@ static int common_exec(struct ast_channel *chan, struct ast_flags *flags, continue; } - if (ast_check_hangup(autochan->chan) || ast_test_flag(autochan->chan, AST_FLAG_SPYING)) { + if (ast_check_hangup(autochan->chan) || ast_test_flag(ast_channel_flags(autochan->chan), AST_FLAG_SPYING)) { continue; } @@ -1024,7 +1024,7 @@ static int common_exec(struct ast_channel *chan, struct ast_flags *flags, } exit: - ast_clear_flag(chan, AST_FLAG_SPYING); + ast_clear_flag(ast_channel_flags(chan), AST_FLAG_SPYING); ast_channel_setoption(chan, AST_OPTION_TXGAIN, &zero_volume, sizeof(zero_volume), 0); diff --git a/apps/app_confbridge.c b/apps/app_confbridge.c index 89c4354b32..866042cdd6 100644 --- a/apps/app_confbridge.c +++ b/apps/app_confbridge.c @@ -1142,7 +1142,7 @@ static int alloc_playback_chan(struct conference_bridge *conference_bridge) } cap = ast_format_cap_destroy(cap); - conference_bridge->playback_chan->bridge = conference_bridge->bridge; + ast_channel_internal_bridge_set(conference_bridge->playback_chan, conference_bridge->bridge); if (ast_call(conference_bridge->playback_chan, "", 0)) { ast_hangup(conference_bridge->playback_chan); diff --git a/apps/app_dial.c b/apps/app_dial.c index 46330fc650..9ae9ea4890 100644 --- a/apps/app_dial.c +++ b/apps/app_dial.c @@ -693,7 +693,7 @@ static void hanguptree(struct chanlist *outgoing, struct ast_channel *exception, if (outgoing->chan && (outgoing->chan != exception)) { if (answered_elsewhere) { /* The flag is used for local channel inheritance and stuff */ - ast_set_flag(outgoing->chan, AST_FLAG_ANSWERED_ELSEWHERE); + ast_set_flag(ast_channel_flags(outgoing->chan), AST_FLAG_ANSWERED_ELSEWHERE); /* This is for the channel drivers */ ast_channel_hangupcause_set(outgoing->chan, AST_CAUSE_ANSWERED_ELSEWHERE); } @@ -2327,12 +2327,12 @@ static int dial_exec_full(struct ast_channel *chan, const char *data, struct ast if (outbound_group) ast_app_group_set_channel(tc, outbound_group); /* If the calling channel has the ANSWERED_ELSEWHERE flag set, inherit it. This is to support local channels */ - if (ast_test_flag(chan, AST_FLAG_ANSWERED_ELSEWHERE)) - ast_set_flag(tc, AST_FLAG_ANSWERED_ELSEWHERE); + if (ast_test_flag(ast_channel_flags(chan), AST_FLAG_ANSWERED_ELSEWHERE)) + ast_set_flag(ast_channel_flags(tc), AST_FLAG_ANSWERED_ELSEWHERE); /* Check if we're forced by configuration */ if (ast_test_flag64(&opts, OPT_CANCEL_ELSEWHERE)) - ast_set_flag(tc, AST_FLAG_ANSWERED_ELSEWHERE); + ast_set_flag(ast_channel_flags(tc), AST_FLAG_ANSWERED_ELSEWHERE); /* Inherit context and extension */ @@ -2509,13 +2509,13 @@ static int dial_exec_full(struct ast_channel *chan, const char *data, struct ast ast_log(LOG_ERROR, "error streaming file '%s' to callee\n", opt_args[OPT_ARG_ANNOUNCE]); } - ast_set_flag(peer, AST_FLAG_END_DTMF_ONLY); + ast_set_flag(ast_channel_flags(peer), AST_FLAG_END_DTMF_ONLY); while (ast_channel_stream(peer)) { int ms; ms = ast_sched_wait(ast_channel_sched(peer)); - if (ms < 0 && !peer->timingfunc) { + if (ms < 0 && !ast_channel_timingfunc(peer)) { ast_stopstream(peer); break; } @@ -2557,7 +2557,7 @@ static int dial_exec_full(struct ast_channel *chan, const char *data, struct ast } ast_sched_runq(ast_channel_sched(peer)); } - ast_clear_flag(peer, AST_FLAG_END_DTMF_ONLY); + ast_clear_flag(ast_channel_flags(peer), AST_FLAG_END_DTMF_ONLY); } if (chan && peer && ast_test_flag64(&opts, OPT_GOTO) && !ast_strlen_zero(opt_args[OPT_ARG_GOTO])) { @@ -2847,8 +2847,8 @@ static int dial_exec_full(struct ast_channel *chan, const char *data, struct ast ast_channel_exten_set(peer, "h"); ast_channel_priority_set(peer, 1); - autoloopflag = ast_test_flag(peer, AST_FLAG_IN_AUTOLOOP); /* save value to restore at the end */ - ast_set_flag(peer, AST_FLAG_IN_AUTOLOOP); + autoloopflag = ast_test_flag(ast_channel_flags(peer), AST_FLAG_IN_AUTOLOOP); /* save value to restore at the end */ + ast_set_flag(ast_channel_flags(peer), AST_FLAG_IN_AUTOLOOP); while ((res9 = ast_spawn_extension(peer, ast_channel_context(peer), ast_channel_exten(peer), ast_channel_priority(peer), @@ -2862,7 +2862,7 @@ static int dial_exec_full(struct ast_channel *chan, const char *data, struct ast ast_debug(1, "Spawn extension (%s,%s,%d) exited non-zero on '%s'\n", ast_channel_context(peer), ast_channel_exten(peer), ast_channel_priority(peer), ast_channel_name(peer)); ast_verb(2, "Spawn extension (%s, %s, %d) exited non-zero on '%s'\n", ast_channel_context(peer), ast_channel_exten(peer), ast_channel_priority(peer), ast_channel_name(peer)); } - ast_set2_flag(peer, autoloopflag, AST_FLAG_IN_AUTOLOOP); /* set it back the way it was */ + ast_set2_flag(ast_channel_flags(peer), autoloopflag, AST_FLAG_IN_AUTOLOOP); /* set it back the way it was */ } if (!ast_check_hangup(peer) && ast_test_flag64(&opts, OPT_CALLEE_GO_ON)) { if(!ast_strlen_zero(opt_args[OPT_ARG_CALLEE_GO_ON])) { @@ -2985,7 +2985,7 @@ static int retrydial_exec(struct ast_channel *chan, const char *data) int continue_exec; ast_channel_data_set(chan, "Retrying"); - if (ast_test_flag(chan, AST_FLAG_MOH)) + if (ast_test_flag(ast_channel_flags(chan), AST_FLAG_MOH)) ast_moh_stop(chan); res = dial_exec_full(chan, args.dialdata, &peerflags, &continue_exec); @@ -3002,7 +3002,7 @@ static int retrydial_exec(struct ast_channel *chan, const char *data) ast_log(LOG_WARNING, "Announce file \"%s\" specified in Retrydial does not exist\n", args.announce); } if (!res && sleepms) { - if (!ast_test_flag(chan, AST_FLAG_MOH)) + if (!ast_test_flag(ast_channel_flags(chan), AST_FLAG_MOH)) ast_moh_start(chan, NULL, NULL); res = ast_waitfordigit(chan, sleepms); } @@ -3015,7 +3015,7 @@ static int retrydial_exec(struct ast_channel *chan, const char *data) ast_log(LOG_WARNING, "Announce file \"%s\" specified in Retrydial does not exist\n", args.announce); } if (sleepms) { - if (!ast_test_flag(chan, AST_FLAG_MOH)) + if (!ast_test_flag(ast_channel_flags(chan), AST_FLAG_MOH)) ast_moh_start(chan, NULL, NULL); if (!res) res = ast_waitfordigit(chan, sleepms); @@ -3038,7 +3038,7 @@ static int retrydial_exec(struct ast_channel *chan, const char *data) else if (res == 1) res = 0; - if (ast_test_flag(chan, AST_FLAG_MOH)) + if (ast_test_flag(ast_channel_flags(chan), AST_FLAG_MOH)) ast_moh_stop(chan); done: return res; diff --git a/apps/app_disa.c b/apps/app_disa.c index 0432a0b619..b38da76542 100644 --- a/apps/app_disa.c +++ b/apps/app_disa.c @@ -204,7 +204,7 @@ static int disa_exec(struct ast_channel *chan, const char *data) play_dialtone(chan, args.mailbox); - ast_set_flag(chan, AST_FLAG_END_DTMF_ONLY); + ast_set_flag(ast_channel_flags(chan), AST_FLAG_END_DTMF_ONLY); for (;;) { /* if outa time, give em reorder */ @@ -220,7 +220,7 @@ static int disa_exec(struct ast_channel *chan, const char *data) } if (!(f = ast_read(chan))) { - ast_clear_flag(chan, AST_FLAG_END_DTMF_ONLY); + ast_clear_flag(ast_channel_flags(chan), AST_FLAG_END_DTMF_ONLY); return -1; } @@ -228,7 +228,7 @@ static int disa_exec(struct ast_channel *chan, const char *data) if (f->data.uint32) ast_channel_hangupcause_set(chan, f->data.uint32); ast_frfree(f); - ast_clear_flag(chan, AST_FLAG_END_DTMF_ONLY); + ast_clear_flag(ast_channel_flags(chan), AST_FLAG_END_DTMF_ONLY); return -1; } @@ -257,7 +257,7 @@ static int disa_exec(struct ast_channel *chan, const char *data) fp = fopen(args.passcode,"r"); if (!fp) { ast_log(LOG_WARNING,"DISA password file %s not found on chan %s\n",args.passcode,ast_channel_name(chan)); - ast_clear_flag(chan, AST_FLAG_END_DTMF_ONLY); + ast_clear_flag(ast_channel_flags(chan), AST_FLAG_END_DTMF_ONLY); return -1; } pwline[0] = 0; @@ -353,7 +353,7 @@ static int disa_exec(struct ast_channel *chan, const char *data) } } - ast_clear_flag(chan, AST_FLAG_END_DTMF_ONLY); + ast_clear_flag(ast_channel_flags(chan), AST_FLAG_END_DTMF_ONLY); if (k == 3) { int recheck = 0; diff --git a/apps/app_dumpchan.c b/apps/app_dumpchan.c index 403c9e079c..4a80a3d13e 100644 --- a/apps/app_dumpchan.c +++ b/apps/app_dumpchan.c @@ -158,7 +158,7 @@ static int serialize_showchan(struct ast_channel *c, char *buf, size_t size) hour, min, sec, - c->_bridge ? ast_channel_name(c->_bridge) : "", + ast_channel_internal_bridged_channel(c) ? ast_channel_name(ast_channel_internal_bridged_channel(c)) : "", ast_bridged_channel(c) ? ast_channel_name(ast_bridged_channel(c)) : "", ast_channel_context(c), ast_channel_exten(c), @@ -167,7 +167,7 @@ static int serialize_showchan(struct ast_channel *c, char *buf, size_t size) ast_print_group(pgrp, sizeof(pgrp), ast_channel_pickupgroup(c)), ast_channel_appl(c) ? ast_channel_appl(c) : "(N/A)", ast_channel_data(c) ? S_OR(ast_channel_data(c), "(Empty)") : "(None)", - (ast_test_flag(c, AST_FLAG_BLOCKING) ? ast_channel_blockproc(c) : "(Not Blocking)")); + (ast_test_flag(ast_channel_flags(c), AST_FLAG_BLOCKING) ? ast_channel_blockproc(c) : "(Not Blocking)")); return 0; } diff --git a/apps/app_externalivr.c b/apps/app_externalivr.c index 5873a64084..0dee58ceaa 100644 --- a/apps/app_externalivr.c +++ b/apps/app_externalivr.c @@ -640,7 +640,7 @@ static int eivr_comm(struct ast_channel *chan, struct ivr_localuser *u, } while (1) { - if (ast_test_flag(chan, AST_FLAG_ZOMBIE)) { + if (ast_test_flag(ast_channel_flags(chan), AST_FLAG_ZOMBIE)) { ast_chan_log(LOG_ERROR, chan, "Is a zombie\n"); break; } diff --git a/apps/app_followme.c b/apps/app_followme.c index c4d1a2d673..5afa978fb3 100644 --- a/apps/app_followme.c +++ b/apps/app_followme.c @@ -645,7 +645,7 @@ static struct ast_channel *wait_for_winner(struct findme_user_listptr *findme_us tmpto = ast_sched_wait(ast_channel_sched(tmpuser->ochan)); if (tmpto > 0 && tmpto < to) to = tmpto; - else if (tmpto < 0 && !tmpuser->ochan->timingfunc) { + else if (tmpto < 0 && !ast_channel_timingfunc(tmpuser->ochan)) { ast_stopstream(tmpuser->ochan); if (tmpuser->state == 1) { ast_verb(3, "Playback of the call-from file appears to be done.\n"); diff --git a/apps/app_macro.c b/apps/app_macro.c index cebfae7afc..8f10d119e0 100644 --- a/apps/app_macro.c +++ b/apps/app_macro.c @@ -373,8 +373,8 @@ static int _macro_exec(struct ast_channel *chan, const char *data, int exclusive argc++; } ast_channel_unlock(chan); - autoloopflag = ast_test_flag(chan, AST_FLAG_IN_AUTOLOOP); - ast_set_flag(chan, AST_FLAG_IN_AUTOLOOP); + autoloopflag = ast_test_flag(ast_channel_flags(chan), AST_FLAG_IN_AUTOLOOP); + ast_set_flag(ast_channel_flags(chan), AST_FLAG_IN_AUTOLOOP); while (ast_exists_extension(chan, ast_channel_context(chan), ast_channel_exten(chan), ast_channel_priority(chan), S_COR(ast_channel_caller(chan)->id.number.valid, ast_channel_caller(chan)->id.number.str, NULL))) { struct ast_context *c; @@ -512,7 +512,7 @@ static int _macro_exec(struct ast_channel *chan, const char *data, int exclusive /* Reset the depth back to what it was when the routine was entered (like if we called Macro recursively) */ snprintf(depthc, sizeof(depthc), "%d", depth); pbx_builtin_setvar_helper(chan, "MACRO_DEPTH", depthc); - ast_set2_flag(chan, autoloopflag, AST_FLAG_IN_AUTOLOOP); + ast_set2_flag(ast_channel_flags(chan), autoloopflag, AST_FLAG_IN_AUTOLOOP); for (x = 1; x < argc; x++) { /* Restore old arguments and delete ours */ diff --git a/apps/app_mixmonitor.c b/apps/app_mixmonitor.c index 88c8f88df0..a89b6cc5dd 100644 --- a/apps/app_mixmonitor.c +++ b/apps/app_mixmonitor.c @@ -375,7 +375,7 @@ static int startmon(struct ast_channel *chan, struct ast_audiohook *audiohook) ast_audiohook_attach(chan, audiohook); - if (!res && ast_test_flag(chan, AST_FLAG_NBRIDGE) && (peer = ast_bridged_channel(chan))) + if (!res && ast_test_flag(ast_channel_flags(chan), AST_FLAG_NBRIDGE) && (peer = ast_bridged_channel(chan))) ast_softhangup(peer, AST_SOFTHANGUP_UNBRIDGE); return res; diff --git a/apps/app_parkandannounce.c b/apps/app_parkandannounce.c index dce000970b..172f0236cd 100644 --- a/apps/app_parkandannounce.c +++ b/apps/app_parkandannounce.c @@ -137,7 +137,7 @@ static int parkandannounce_exec(struct ast_channel *chan, const char *data) ast_verb(3, "Dial Tech,String: (%s,%s)\n", dialtech, args.dial); if (!ast_strlen_zero(args.return_context)) { - ast_clear_flag(chan, AST_FLAG_IN_AUTOLOOP); + ast_clear_flag(ast_channel_flags(chan), AST_FLAG_IN_AUTOLOOP); ast_parseable_goto(chan, args.return_context); } diff --git a/apps/app_queue.c b/apps/app_queue.c index 7871a3d12e..ef3223b53a 100644 --- a/apps/app_queue.c +++ b/apps/app_queue.c @@ -3023,7 +3023,7 @@ static void hangupcalls(struct callattempt *outgoing, struct ast_channel *except /* Hangup any existing lines we have open */ if (outgoing->chan && (outgoing->chan != exception)) { if (exception || cancel_answered_elsewhere) - ast_set_flag(outgoing->chan, AST_FLAG_ANSWERED_ELSEWHERE); + ast_set_flag(ast_channel_flags(outgoing->chan), AST_FLAG_ANSWERED_ELSEWHERE); ast_hangup(outgoing->chan); } oo = outgoing; @@ -3273,7 +3273,7 @@ static int ring_entry(struct queue_ent *qe, struct callattempt *tmp, int *busies ast_channel_lock_both(tmp->chan, qe->chan); if (qe->cancel_answered_elsewhere) { - ast_set_flag(tmp->chan, AST_FLAG_ANSWERED_ELSEWHERE); + ast_set_flag(ast_channel_flags(tmp->chan), AST_FLAG_ANSWERED_ELSEWHERE); } ast_channel_appl_set(tmp->chan, "AppQueue"); ast_channel_data_set(tmp->chan, "(Outgoing Line)"); @@ -4646,7 +4646,7 @@ static int try_calling(struct queue_ent *qe, const struct ast_flags opts, char * /* if the calling channel has the ANSWERED_ELSEWHERE flag set, make sure this is inherited. (this is mainly to support chan_local) */ - if (ast_test_flag(qe->chan, AST_FLAG_ANSWERED_ELSEWHERE)) { + if (ast_test_flag(ast_channel_flags(qe->chan), AST_FLAG_ANSWERED_ELSEWHERE)) { qe->cancel_answered_elsewhere = 1; } diff --git a/apps/app_speech_utils.c b/apps/app_speech_utils.c index fdf67bb90e..62a8d729a1 100644 --- a/apps/app_speech_utils.c +++ b/apps/app_speech_utils.c @@ -721,7 +721,7 @@ static int speech_background(struct ast_channel *chan, const char *data) /* Okay it's streaming so go into a loop grabbing frames! */ while (done == 0) { /* If the filename is null and stream is not running, start up a new sound file */ - if (!quieted && (ast_channel_streamid(chan) == -1 && chan->timingfunc == NULL) && (filename = strsep(&filename_tmp, "&"))) { + if (!quieted && (ast_channel_streamid(chan) == -1 && ast_channel_timingfunc(chan) == NULL) && (filename = strsep(&filename_tmp, "&"))) { /* Discard old stream information */ ast_stopstream(chan); /* Start new stream */ @@ -769,7 +769,7 @@ static int speech_background(struct ast_channel *chan, const char *data) switch (speech->state) { case AST_SPEECH_STATE_READY: /* If audio playback has stopped do a check for timeout purposes */ - if (ast_channel_streamid(chan) == -1 && chan->timingfunc == NULL) + if (ast_channel_streamid(chan) == -1 && ast_channel_timingfunc(chan) == NULL) ast_stopstream(chan); if (!quieted && ast_channel_stream(chan) == NULL && timeout && started == 0 && !filename_tmp) { if (timeout == -1) { @@ -795,7 +795,7 @@ static int speech_background(struct ast_channel *chan, const char *data) speech_streamfile(chan, speech->processing_sound, ast_channel_language(chan)); } } - } else if (ast_channel_streamid(chan) == -1 && chan->timingfunc == NULL) { + } else if (ast_channel_streamid(chan) == -1 && ast_channel_timingfunc(chan) == NULL) { ast_stopstream(chan); if (speech->processing_sound != NULL) { if (strlen(speech->processing_sound) > 0 && strcasecmp(speech->processing_sound, "none")) { diff --git a/apps/app_stack.c b/apps/app_stack.c index 28bd3cfb4c..8f7ab0e784 100644 --- a/apps/app_stack.c +++ b/apps/app_stack.c @@ -445,10 +445,10 @@ static int gosub_exec(struct ast_channel *chan, const char *data) } if (!ast_exists_extension(chan, ast_channel_context(chan), ast_channel_exten(chan), - ast_test_flag(chan, AST_FLAG_IN_AUTOLOOP) ? ast_channel_priority(chan) + 1 : ast_channel_priority(chan), + ast_test_flag(ast_channel_flags(chan), AST_FLAG_IN_AUTOLOOP) ? ast_channel_priority(chan) + 1 : ast_channel_priority(chan), S_COR(ast_channel_caller(chan)->id.number.valid, ast_channel_caller(chan)->id.number.str, NULL))) { ast_log(LOG_ERROR, "Attempt to reach a non-existent destination for gosub: (Context:%s, Extension:%s, Priority:%d)\n", - ast_channel_context(chan), ast_channel_exten(chan), ast_test_flag(chan, AST_FLAG_IN_AUTOLOOP) ? ast_channel_priority(chan) + 1 : ast_channel_priority(chan)); + ast_channel_context(chan), ast_channel_exten(chan), ast_test_flag(ast_channel_flags(chan), AST_FLAG_IN_AUTOLOOP) ? ast_channel_priority(chan) + 1 : ast_channel_priority(chan)); ast_channel_context_set(chan, newframe->context); ast_channel_exten_set(chan, newframe->extension); ast_channel_priority_set(chan, newframe->priority - 1); diff --git a/apps/app_talkdetect.c b/apps/app_talkdetect.c index 791081db56..5ef80c33c0 100644 --- a/apps/app_talkdetect.c +++ b/apps/app_talkdetect.c @@ -151,7 +151,7 @@ static int background_detect_exec(struct ast_channel *chan, const char *data) detection_start = ast_tvnow(); while (ast_channel_stream(chan)) { res = ast_sched_wait(ast_channel_sched(chan)); - if ((res < 0) && !chan->timingfunc) { + if ((res < 0) && !ast_channel_timingfunc(chan)) { res = 0; break; } diff --git a/bridges/bridge_multiplexed.c b/bridges/bridge_multiplexed.c index 8d18ab548f..cd3026647d 100644 --- a/bridges/bridge_multiplexed.c +++ b/bridges/bridge_multiplexed.c @@ -236,11 +236,11 @@ static void *multiplexed_thread_function(void *data) } } } - if (winner && winner->bridge) { - struct ast_bridge *bridge = winner->bridge; + if (winner && ast_channel_internal_bridge(winner)) { + struct ast_bridge *bridge = ast_channel_internal_bridge(winner); int stop = 0; ao2_unlock(multiplexed_thread); - while ((bridge = winner->bridge) && ao2_trylock(bridge)) { + while ((bridge = ast_channel_internal_bridge(winner)) && ao2_trylock(bridge)) { sched_yield(); if (multiplexed_thread->thread == AST_PTHREADT_STOP) { stop = 1; diff --git a/channels/chan_agent.c b/channels/chan_agent.c index 836154092d..0c79a66de3 100644 --- a/channels/chan_agent.c +++ b/channels/chan_agent.c @@ -601,7 +601,7 @@ static struct ast_frame *agent_read(struct ast_channel *ast) p->start = cur_time; } if (p->chan) { - ast_copy_flags(p->chan, ast, AST_FLAG_EXCEPTION); + ast_copy_flags(ast_channel_flags(p->chan), ast_channel_flags(ast), AST_FLAG_EXCEPTION); ast_channel_fdno_set(p->chan, (ast_channel_fdno(ast) == AST_AGENT_FD) ? AST_TIMING_FD : ast_channel_fdno(ast)); f = ast_read(p->chan); } else @@ -609,7 +609,7 @@ static struct ast_frame *agent_read(struct ast_channel *ast) if (!f) { /* If there's a channel, make it NULL */ if (p->chan) { - p->chan->_bridge = NULL; + ast_channel_internal_bridged_channel_set(p->chan, NULL); p->chan = NULL; ast_devstate_changed(AST_DEVICE_UNAVAILABLE, "Agent/%s", p->agent); p->acknowledged = 0; @@ -697,11 +697,11 @@ static struct ast_frame *agent_read(struct ast_channel *ast) } CLEANUP(ast,p); - if (p->chan && !p->chan->_bridge) { + if (p->chan && !ast_channel_internal_bridged_channel(p->chan)) { if (strcasecmp(ast_channel_tech(p->chan)->type, "Local")) { - p->chan->_bridge = ast; + ast_channel_internal_bridged_channel_set(p->chan, ast); if (p->chan) - ast_debug(1, "Bridge on '%s' being set to '%s' (3)\n", ast_channel_name(p->chan), ast_channel_name(p->chan->_bridge)); + ast_debug(1, "Bridge on '%s' being set to '%s' (3)\n", ast_channel_name(p->chan), ast_channel_name(ast_channel_internal_bridged_channel(p->chan))); } } ast_mutex_unlock(&p->lock); @@ -964,7 +964,7 @@ static int agent_hangup(struct ast_channel *ast) } else p->start = 0; if (p->chan) { - p->chan->_bridge = NULL; + ast_channel_internal_bridged_channel_set(p->chan, NULL); /* If they're dead, go ahead and hang up on the agent now */ if (p->dead) { ast_channel_lock(p->chan); @@ -1083,8 +1083,8 @@ static struct ast_channel *agent_bridgedchannel(struct ast_channel *chan, struct if (p) { if (chan == p->chan) - ret = bridge->_bridge; - else if (chan == bridge->_bridge) + ret = ast_channel_internal_bridged_channel(bridge); + else if (chan == ast_channel_internal_bridged_channel(bridge)) ret = p->chan; } @@ -1586,7 +1586,7 @@ static int action_agents(struct mansession *s, const struct message *m) if (p->chan) { loginChan = ast_strdupa(ast_channel_name(p->chan)); - if (owner && owner->_bridge) { + if (owner && ast_channel_internal_bridged_channel(owner)) { talkingto = S_COR(ast_channel_caller(p->chan)->id.number.valid, ast_channel_caller(p->chan)->id.number.str, "n/a"); if ((bridge = ast_bridged_channel(owner))) { diff --git a/channels/chan_bridge.c b/channels/chan_bridge.c index 3ec157601c..1670cba650 100644 --- a/channels/chan_bridge.c +++ b/channels/chan_bridge.c @@ -121,12 +121,12 @@ static int bridge_call(struct ast_channel *ast, const char *dest, int timeout) struct bridge_pvt *p = ast_channel_tech_pvt(ast); /* If no bridge has been provided on the input channel, bail out */ - if (!ast->bridge) { + if (!ast_channel_internal_bridge(ast)) { return -1; } /* Impart the output channel upon the given bridge of the input channel */ - ast_bridge_impart(p->input->bridge, p->output, NULL, NULL, 0); + ast_bridge_impart(ast_channel_internal_bridge(p->input), p->output, NULL, NULL, 0); return 0; } diff --git a/channels/chan_dahdi.c b/channels/chan_dahdi.c index 6751d0d0c6..5dad539101 100644 --- a/channels/chan_dahdi.c +++ b/channels/chan_dahdi.c @@ -7741,7 +7741,7 @@ static int attempt_transfer(struct dahdi_pvt *p) } else { ast_debug(1, "Neither %s nor %s are in a bridge, nothing to transfer\n", ast_channel_name(p->subs[SUB_REAL].owner), ast_channel_name(p->subs[SUB_THREEWAY].owner)); - ast_channel_softhangup_internal_flag_set(p->subs[SUB_THREEWAY].owner, ast_channel_softhangup_internal_flag(p->subs[SUB_THREEWAY].owner) | AST_SOFTHANGUP_DEV); + ast_channel_softhangup_internal_flag_add(p->subs[SUB_THREEWAY].owner, AST_SOFTHANGUP_DEV); return -1; } return 0; @@ -9150,7 +9150,7 @@ static struct ast_frame *dahdi_read(struct ast_channel *ast) readbuf = ((unsigned char *)p->subs[idx].buffer) + AST_FRIENDLY_OFFSET; CHECK_BLOCKING(ast); res = read(p->subs[idx].dfd, readbuf, p->subs[idx].linear ? READ_SIZE * 2 : READ_SIZE); - ast_clear_flag(ast, AST_FLAG_BLOCKING); + ast_clear_flag(ast_channel_flags(ast), AST_FLAG_BLOCKING); /* Check for hangup */ if (res < 0) { f = NULL; @@ -10549,7 +10549,7 @@ static void *analog_ss_thread(void *data) * emulation. The DTMF digits can come so fast that emulation * can drop some of them. */ - ast_set_flag(chan, AST_FLAG_END_DTMF_ONLY); + ast_set_flag(ast_channel_flags(chan), AST_FLAG_END_DTMF_ONLY); res = 4000;/* This is a typical OFF time between rings. */ for (;;) { struct ast_frame *f; @@ -10580,7 +10580,7 @@ static void *analog_ss_thread(void *data) ast_channel_state(chan) == AST_STATE_RINGING) break; /* Got ring */ } - ast_clear_flag(chan, AST_FLAG_END_DTMF_ONLY); + ast_clear_flag(ast_channel_flags(chan), AST_FLAG_END_DTMF_ONLY); dtmfbuf[k] = '\0'; dahdi_setlinear(p->subs[idx].dfd, p->subs[idx].linear); /* Got cid and ring. */ diff --git a/channels/chan_local.c b/channels/chan_local.c index c6780d223c..c0657c97be 100644 --- a/channels/chan_local.c +++ b/channels/chan_local.c @@ -339,8 +339,8 @@ static struct ast_channel *local_bridgedchannel(struct ast_channel *chan, struct /* Now see if the opposite channel is bridged to anything */ if (!bridged) { bridged = bridge; - } else if (bridged->_bridge) { - bridged = bridged->_bridge; + } else if (ast_channel_internal_bridged_channel(bridged)) { + bridged = ast_channel_internal_bridged_channel(bridged); } } @@ -502,7 +502,7 @@ static void check_bridge(struct local_pvt *p) /* since we had to unlock p to get the bridged chan, validate our * data once again and verify the bridged channel is what we expect * it to be in order to perform this optimization */ - if (ast_test_flag(p, LOCAL_ALREADY_MASQED) || !p->owner || !p->chan || (p->chan->_bridge != bridged_chan)) { + if (ast_test_flag(p, LOCAL_ALREADY_MASQED) || !p->owner || !p->chan || (ast_channel_internal_bridged_channel(p->chan) != bridged_chan)) { return; } @@ -511,24 +511,24 @@ static void check_bridge(struct local_pvt *p) frames on the owner channel (because they would be transferred to the outbound channel during the masquerade) */ - if (p->chan->_bridge /* Not ast_bridged_channel! Only go one step! */ && AST_LIST_EMPTY(ast_channel_readq(p->owner))) { + if (ast_channel_internal_bridged_channel(p->chan) /* Not ast_bridged_channel! Only go one step! */ && AST_LIST_EMPTY(ast_channel_readq(p->owner))) { /* Masquerade bridged channel into owner */ /* Lock everything we need, one by one, and give up if we can't get everything. Remember, we'll get another chance in just a little bit */ - if (!ast_channel_trylock(p->chan->_bridge)) { - if (!ast_check_hangup(p->chan->_bridge)) { + if (!ast_channel_trylock(ast_channel_internal_bridged_channel(p->chan))) { + if (!ast_check_hangup(ast_channel_internal_bridged_channel(p->chan))) { if (!ast_channel_trylock(p->owner)) { if (!ast_check_hangup(p->owner)) { - if (ast_channel_monitor(p->owner) && !ast_channel_monitor(p->chan->_bridge)) { + if (ast_channel_monitor(p->owner) && !ast_channel_monitor(ast_channel_internal_bridged_channel(p->chan))) { /* If a local channel is being monitored, we don't want a masquerade * to cause the monitor to go away. Since the masquerade swaps the monitors, * pre-swapping the monitors before the masquerade will ensure that the monitor * ends up where it is expected. */ tmp = ast_channel_monitor(p->owner); - ast_channel_monitor_set(p->owner, ast_channel_monitor(p->chan->_bridge)); - ast_channel_monitor_set(p->chan->_bridge, tmp); + ast_channel_monitor_set(p->owner, ast_channel_monitor(ast_channel_internal_bridged_channel(p->chan))); + ast_channel_monitor_set(ast_channel_internal_bridged_channel(p->chan), tmp); } if (ast_channel_audiohooks(p->chan)) { struct ast_audiohook_list *audiohooks_swapper; @@ -547,26 +547,26 @@ static void check_bridge(struct local_pvt *p) if (ast_channel_caller(p->owner)->id.name.valid || ast_channel_caller(p->owner)->id.number.valid || ast_channel_caller(p->owner)->id.subaddress.valid || ast_channel_caller(p->owner)->ani.name.valid || ast_channel_caller(p->owner)->ani.number.valid || ast_channel_caller(p->owner)->ani.subaddress.valid) { - SWAP(*ast_channel_caller(p->owner), *ast_channel_caller(p->chan->_bridge)); + SWAP(*ast_channel_caller(p->owner), *ast_channel_caller(ast_channel_internal_bridged_channel(p->chan))); } if (ast_channel_redirecting(p->owner)->from.name.valid || ast_channel_redirecting(p->owner)->from.number.valid || ast_channel_redirecting(p->owner)->from.subaddress.valid || ast_channel_redirecting(p->owner)->to.name.valid || ast_channel_redirecting(p->owner)->to.number.valid || ast_channel_redirecting(p->owner)->to.subaddress.valid) { - SWAP(*ast_channel_redirecting(p->owner), *ast_channel_redirecting(p->chan->_bridge)); + SWAP(*ast_channel_redirecting(p->owner), *ast_channel_redirecting(ast_channel_internal_bridged_channel(p->chan))); } if (ast_channel_dialed(p->owner)->number.str || ast_channel_dialed(p->owner)->subaddress.valid) { - SWAP(*ast_channel_dialed(p->owner), *ast_channel_dialed(p->chan->_bridge)); + SWAP(*ast_channel_dialed(p->owner), *ast_channel_dialed(ast_channel_internal_bridged_channel(p->chan))); } ast_app_group_update(p->chan, p->owner); - ast_channel_masquerade(p->owner, p->chan->_bridge); + ast_channel_masquerade(p->owner, ast_channel_internal_bridged_channel(p->chan)); ast_set_flag(p, LOCAL_ALREADY_MASQED); } ast_channel_unlock(p->owner); } } - ast_channel_unlock(p->chan->_bridge); + ast_channel_unlock(ast_channel_internal_bridged_channel(p->chan)); } } } @@ -629,7 +629,7 @@ static int local_fixup(struct ast_channel *oldchan, struct ast_channel *newchan) } /* Do not let a masquerade cause a Local channel to be bridged to itself! */ - if (!ast_check_hangup(newchan) && ((p->owner && p->owner->_bridge == p->chan) || (p->chan && p->chan->_bridge == p->owner))) { + if (!ast_check_hangup(newchan) && ((p->owner && ast_channel_internal_bridged_channel(p->owner) == p->chan) || (p->chan && ast_channel_internal_bridged_channel(p->chan) == p->owner))) { ast_log(LOG_WARNING, "You can not bridge a Local channel to itself!\n"); ao2_unlock(p); ast_queue_hangup(newchan); @@ -859,8 +859,8 @@ static int local_call(struct ast_channel *ast, const char *dest, int timeout) ast_channel_cc_params_init(chan, ast_channel_get_cc_config_params(owner)); /* Make sure we inherit the ANSWERED_ELSEWHERE flag if it's set on the queue/dial call request in the dialplan */ - if (ast_test_flag(ast, AST_FLAG_ANSWERED_ELSEWHERE)) { - ast_set_flag(chan, AST_FLAG_ANSWERED_ELSEWHERE); + if (ast_test_flag(ast_channel_flags(ast), AST_FLAG_ANSWERED_ELSEWHERE)) { + ast_set_flag(ast_channel_flags(chan), AST_FLAG_ANSWERED_ELSEWHERE); } /* copy the channel variables from the incoming channel to the outgoing channel */ @@ -980,8 +980,8 @@ static int local_hangup(struct ast_channel *ast) isoutbound = IS_OUTBOUND(ast, p); /* just comparing pointer of ast */ - if (p->chan && ast_test_flag(ast, AST_FLAG_ANSWERED_ELSEWHERE)) { - ast_set_flag(p->chan, AST_FLAG_ANSWERED_ELSEWHERE); + if (p->chan && ast_test_flag(ast_channel_flags(ast), AST_FLAG_ANSWERED_ELSEWHERE)) { + ast_set_flag(ast_channel_flags(p->chan), AST_FLAG_ANSWERED_ELSEWHERE); ast_debug(2, "This local call has the ANSWERED_ELSEWHERE flag set.\n"); } diff --git a/channels/chan_phone.c b/channels/chan_phone.c index f7e7c335eb..a781b232a9 100644 --- a/channels/chan_phone.c +++ b/channels/chan_phone.c @@ -563,7 +563,7 @@ static struct ast_frame *phone_read(struct ast_channel *ast) /* Try to read some data... */ CHECK_BLOCKING(ast); res = read(p->fd, p->buf, PHONE_MAX_BUF); - ast_clear_flag(ast, AST_FLAG_BLOCKING); + ast_clear_flag(ast_channel_flags(ast), AST_FLAG_BLOCKING); if (res < 0) { #if 0 if (errno == EAGAIN) { diff --git a/channels/chan_sip.c b/channels/chan_sip.c index b955566a8b..3aa2bf2624 100644 --- a/channels/chan_sip.c +++ b/channels/chan_sip.c @@ -6328,7 +6328,7 @@ static int sip_hangup(struct ast_channel *ast) ast_debug(1, "Asked to hangup channel that was not connected\n"); return 0; } - if (ast_test_flag(ast, AST_FLAG_ANSWERED_ELSEWHERE) || ast_channel_hangupcause(ast) == AST_CAUSE_ANSWERED_ELSEWHERE) { + if (ast_test_flag(ast_channel_flags(ast), AST_FLAG_ANSWERED_ELSEWHERE) || ast_channel_hangupcause(ast) == AST_CAUSE_ANSWERED_ELSEWHERE) { ast_debug(1, "This call was answered elsewhere"); if (ast_channel_hangupcause(ast) == AST_CAUSE_ANSWERED_ELSEWHERE) { ast_debug(1, "####### It's the cause code, buddy. The cause code!!!\n"); @@ -6358,7 +6358,7 @@ static int sip_hangup(struct ast_channel *ast) return 0; } - if (ast_test_flag(ast, AST_FLAG_ZOMBIE)) { + if (ast_test_flag(ast_channel_flags(ast), AST_FLAG_ZOMBIE)) { if (p->refer) ast_debug(1, "SIP Transfer: Hanging up Zombie channel %s after transfer ... Call-ID: %s\n", ast_channel_name(ast), p->callid); else @@ -6690,9 +6690,9 @@ static int sip_fixup(struct ast_channel *oldchan, struct ast_channel *newchan) int ret = -1; struct sip_pvt *p; - if (newchan && ast_test_flag(newchan, AST_FLAG_ZOMBIE)) + if (newchan && ast_test_flag(ast_channel_flags(newchan), AST_FLAG_ZOMBIE)) ast_debug(1, "New channel is zombie\n"); - if (oldchan && ast_test_flag(oldchan, AST_FLAG_ZOMBIE)) + if (oldchan && ast_test_flag(ast_channel_flags(oldchan), AST_FLAG_ZOMBIE)) ast_debug(1, "Old channel is zombie\n"); if (!newchan || !ast_channel_tech_pvt(newchan)) { @@ -22415,7 +22415,7 @@ static int sip_pickup(struct ast_channel *chan) static void ast_quiet_chan(struct ast_channel *chan) { if (chan && ast_channel_state(chan) == AST_STATE_UP) { - if (ast_test_flag(chan, AST_FLAG_MOH)) + if (ast_test_flag(ast_channel_flags(chan), AST_FLAG_MOH)) ast_moh_stop(chan); else if (ast_channel_generatordata(chan)) ast_deactivate_generator(chan); diff --git a/channels/chan_unistim.c b/channels/chan_unistim.c index 48fde426b6..f131058655 100644 --- a/channels/chan_unistim.c +++ b/channels/chan_unistim.c @@ -2306,7 +2306,7 @@ static int write_history(struct unistimsession *pte, char way, char ismissed) static void unistim_quiet_chan(struct ast_channel *chan) { if (chan && ast_channel_state(chan) == AST_STATE_UP) { - if (ast_test_flag(chan, AST_FLAG_MOH)) { + if (ast_test_flag(ast_channel_flags(chan), AST_FLAG_MOH)) { ast_moh_stop(chan); } else if (ast_channel_generatordata(chan)) { ast_deactivate_generator(chan); @@ -2959,11 +2959,11 @@ static void swap_subs(struct unistim_subchannel *a, struct unistim_subchannel *b /* Step 1 : Music On Hold for peer, Dialing screen for us */ static void transfer_call_step1(struct unistimsession *pte) { - struct unistim_subchannel *sub, *sub_trans; + struct unistim_subchannel *sub /*, *sub_trans */; struct unistim_device *d = pte->device; sub = get_sub(d, SUB_REAL); - sub_trans = get_sub(d, SUB_THREEWAY); + /* sub_trans = get_sub(d, SUB_THREEWAY); */ if (!sub || !sub->owner) { ast_log(LOG_WARNING, "Unable to find subchannel for music on hold\n"); @@ -4856,7 +4856,7 @@ static int unistim_hangup(struct ast_channel *ast) refresh_all_favorite(s); /* Update favicons in case of DND keys */ if (s->state == STATE_RINGING && sub->subtype == SUB_RING) { send_no_ring(s); - if (!ast_test_flag(ast, AST_FLAG_ANSWERED_ELSEWHERE) && ast_channel_hangupcause(ast) != AST_CAUSE_ANSWERED_ELSEWHERE) { + if (!ast_test_flag(ast_channel_flags(ast), AST_FLAG_ANSWERED_ELSEWHERE) && ast_channel_hangupcause(ast) != AST_CAUSE_ANSWERED_ELSEWHERE) { d->missed_call++; write_history(s, 'i', 1); } @@ -5872,7 +5872,7 @@ static char *unistim_show_info(struct ast_cli_entry *e, int cmd, struct ast_cli_ if (!sub->owner) { tmp = (void *) -42; } else { - tmp = sub->owner->_bridge; + tmp = ast_channel_internal_bridged_channel(sub->owner); } ast_cli(a->fd, "-->subtype=%s chan=%p rtp=%p bridge=%p line=%p alreadygone=%d softkey=%d\n", diff --git a/channels/chan_vpb.cc b/channels/chan_vpb.cc index 465c244089..e54cebda00 100644 --- a/channels/chan_vpb.cc +++ b/channels/chan_vpb.cc @@ -2257,8 +2257,8 @@ static void *do_chanreads(void *pvt) bridgerec = 0; } else { ast_verb(5, "%s: chanreads: No native bridge.\n", p->dev); - if (p->owner->_bridge) { - ast_verb(5, "%s: chanreads: Got Asterisk bridge with [%s].\n", p->dev, ast_channel_name(p->owner->_bridge)); + if (ast_channel_internal_bridged_channel(p->owner)) { + ast_verb(5, "%s: chanreads: Got Asterisk bridge with [%s].\n", p->dev, ast_channel_name(ast_channel_internal_bridged_channel(p->owner))); bridgerec = 1; } else { bridgerec = 0; diff --git a/channels/sig_analog.c b/channels/sig_analog.c index 78963bb56d..7112cf29da 100644 --- a/channels/sig_analog.c +++ b/channels/sig_analog.c @@ -2402,7 +2402,7 @@ static void *__analog_ss_thread(void *data) * emulation. The DTMF digits can come so fast that emulation * can drop some of them. */ - ast_set_flag(chan, AST_FLAG_END_DTMF_ONLY); + ast_set_flag(ast_channel_flags(chan), AST_FLAG_END_DTMF_ONLY); res = 4000;/* This is a typical OFF time between rings. */ for (;;) { struct ast_frame *f; @@ -2435,7 +2435,7 @@ static void *__analog_ss_thread(void *data) break; /* Got ring */ } } - ast_clear_flag(chan, AST_FLAG_END_DTMF_ONLY); + ast_clear_flag(ast_channel_flags(chan), AST_FLAG_END_DTMF_ONLY); dtmfbuf[k] = '\0'; analog_set_linear_mode(p, idx, oldlinearity); diff --git a/include/asterisk/channel.h b/include/asterisk/channel.h index 7b3a1443e1..292640bb43 100644 --- a/include/asterisk/channel.h +++ b/include/asterisk/channel.h @@ -713,6 +713,7 @@ AST_LIST_HEAD_NOLOCK(ast_datastore_list, ast_datastore); AST_LIST_HEAD_NOLOCK(ast_autochan_list, ast_autochan); AST_LIST_HEAD_NOLOCK(ast_readq_list, ast_frame); +typedef int(*ast_timing_func_t)(const void *data); /*! * \page AstChannel ast_channel locking and reference tracking * @@ -764,151 +765,7 @@ AST_LIST_HEAD_NOLOCK(ast_readq_list, ast_frame); * gets called before the channel goes away. */ -/*! - * \brief Main Channel structure associated with a channel. - * - * \note XXX It is important to remember to increment .cleancount each time - * this structure is changed. XXX - * - * \note When adding fields to this structure, it is important to add the field - * 'in position' with like-aligned fields, so as to keep the compiler from - * having to add padding to align fields. The structure's fields are sorted - * in this order: pointers, structures, long, int/enum, short, char. This - * is especially important on 64-bit architectures, where mixing 4-byte - * and 8-byte fields causes 4 bytes of padding to be added before many - * 8-byte fields. - */ -struct ast_channel { - const struct ast_channel_tech *__do_not_use_tech; /*!< Technology (point to channel driver) */ - void *__do_not_use_tech_pvt; /*!< Private data used by the technology driver */ - void *__do_not_use_music_state; /*!< Music State*/ - void *__do_not_use_generatordata; /*!< Current generator data if there is any */ - struct ast_generator *__do_not_use_generator; /*!< Current active data generator */ - struct ast_channel * _bridge; /*!< Who are we bridged to, if we're bridged. - * Who is proxying for us, if we are proxied (i.e. chan_agent). - * Do not access directly, use ast_bridged_channel(chan) */ - struct ast_channel *__do_not_use_masq; /*!< Channel that will masquerade as us */ - struct ast_channel *__do_not_use_masqr; /*!< Who we are masquerading as */ - const char *__do_not_use_blockproc; /*!< Procedure causing blocking */ - const char *__do_not_use_appl; /*!< Current application */ - const char *__do_not_use_data; /*!< Data passed to current application */ - struct ast_sched_context *__do_not_use_sched; /*!< Schedule context */ - struct ast_filestream *__do_not_use_stream; /*!< Stream itself. */ - struct ast_filestream *__do_not_use_vstream; /*!< Video Stream itself. */ - int (*timingfunc)(const void *data); - void *__do_not_use_timingdata; - struct ast_pbx *__do_not_use_pbx; /*!< PBX private structure for this channel */ - struct ast_trans_pvt *__do_not_use_writetrans; /*!< Write translation path */ - struct ast_trans_pvt *__do_not_use_readtrans; /*!< Read translation path */ - struct ast_audiohook_list *__do_not_use_audiohooks; - struct ast_framehook_list *__do_not_use_framehooks; - struct ast_cdr *__do_not_use_cdr; /*!< Call Detail Record */ - struct ast_tone_zone *__do_not_use_zone; /*!< Tone zone as set in indications.conf or - * in the CHANNEL dialplan function */ - struct ast_channel_monitor *__do_not_use_monitor; /*!< Channel monitoring */ -#ifdef HAVE_EPOLL - struct ast_epoll_data *__do_not_use_epfd_data[AST_MAX_FDS]; -#endif - - AST_DECLARE_STRING_FIELDS( - AST_STRING_FIELD(__do_not_use_name); /*!< ASCII unique channel name */ - AST_STRING_FIELD(__do_not_use_language); /*!< Language requested for voice prompts */ - AST_STRING_FIELD(__do_not_use_musicclass); /*!< Default music class */ - AST_STRING_FIELD(__do_not_use_accountcode); /*!< Account code for billing */ - AST_STRING_FIELD(__do_not_use_peeraccount); /*!< Peer account code for billing */ - AST_STRING_FIELD(__do_not_use_userfield); /*!< Userfield for CEL billing */ - AST_STRING_FIELD(__do_not_use_call_forward); /*!< Where to forward to if asked to dial on this interface */ - AST_STRING_FIELD(__do_not_use_uniqueid); /*!< Unique Channel Identifier */ - AST_STRING_FIELD(__do_not_use_linkedid); /*!< Linked Channel Identifier -- gets propagated by linkage */ - AST_STRING_FIELD(__do_not_use_parkinglot); /*! Default parking lot, if empty, default parking lot */ - AST_STRING_FIELD(__do_not_use_hangupsource); /*! Who is responsible for hanging up this channel */ - AST_STRING_FIELD(__do_not_use_dialcontext); /*!< Dial: Extension context that we were called from */ - ); - - struct timeval __do_not_use_whentohangup; /*!< Non-zero, set to actual time when channel is to be hung up */ - pthread_t blocker; /*!< If anyone is blocking, this is them */ - - /*! - * \brief Dialed/Called information. - * \note Set on incoming channels to indicate the originally dialed party. - * \note Dialed Number Identifier (DNID) - */ - struct ast_party_dialed __do_not_use_dialed; - - /*! - * \brief Channel Caller ID information. - * \note The caller id information is the caller id of this - * channel when it is used to initiate a call. - */ - struct ast_party_caller __do_not_use_caller; - - /*! - * \brief Channel Connected Line ID information. - * \note The connected line information identifies the channel - * connected/bridged to this channel. - */ - struct ast_party_connected_line __do_not_use_connected; - - /*! \brief Redirecting/Diversion information */ - struct ast_party_redirecting __do_not_use_redirecting; - - struct ast_frame __do_not_use_dtmff; /*!< DTMF frame */ - struct varshead __do_not_use_varshead; /*!< A linked list for channel variables. See \ref AstChanVar */ - ast_group_t __do_not_use_callgroup; /*!< Call group for call pickups */ - ast_group_t __do_not_use_pickupgroup; /*!< Pickup group - which calls groups can be picked up? */ - struct ast_readq_list __do_not_use_readq; - struct ast_jb __do_not_use_jb; /*!< The jitterbuffer state */ - struct timeval __do_not_use_dtmf_tv; /*!< The time that an in process digit began, or the last digit ended */ - struct ast_datastore_list __do_not_use_datastores; /*!< Data stores on the channel */ - struct ast_autochan_list __do_not_use_autochans; /*!< Autochans on the channel */ - unsigned long __do_not_use_insmpl; /*!< Track the read/written samples for monitor use */ - unsigned long __do_not_use_outsmpl; /*!< Track the read/written samples for monitor use */ - - int __do_not_use_fds[AST_MAX_FDS]; /*!< File descriptors for channel -- Drivers will poll on - * these file descriptors, so at least one must be non -1. - * See \arg \ref AstFileDesc */ - int __do_not_use_softhangup; /*!< Whether or not we have been hung up... Do not set this value - * directly, use ast_softhangup() */ - int __do_not_use_fdno; /*!< Which fd had an event detected on */ - int __do_not_use_streamid; /*!< For streaming playback, the schedule ID */ - int __do_not_use_vstreamid; /*!< For streaming video playback, the schedule ID */ - struct ast_format __do_not_use_oldwriteformat; /*!< Original writer format */ - int __do_not_use_timingfd; /*!< Timing fd */ - enum ast_channel_state __do_not_use_state; /*!< State of line -- Don't write directly, use ast_setstate() */ - int __do_not_use_rings; /*!< Number of rings so far */ - int __do_not_use_priority; /*!< Dialplan: Current extension priority */ - int __do_not_use_macropriority; /*!< Macro: Current non-macro priority. See app_macro.c */ - int __do_not_use_amaflags; /*!< Set BEFORE PBX is started to determine AMA flags */ - enum ast_channel_adsicpe __do_not_use_adsicpe; /*!< Whether or not ADSI is detected on CPE */ - unsigned int __do_not_use_fin; /*!< Frames in counters. The high bit is a debug mask, so - * the counter is only in the remaining bits */ - unsigned int __do_not_use_fout; /*!< Frames out counters. The high bit is a debug mask, so - * the counter is only in the remaining bits */ - int __do_not_use_hangupcause; /*!< Why is the channel hanged up. See causes.h */ - unsigned int flags; /*!< channel flags of AST_FLAG_ type */ - int __do_not_use_alertpipe[2]; - struct ast_format_cap *__do_not_use_nativeformats; /*!< Kinds of data this channel can natively handle */ - struct ast_format __do_not_use_readformat; /*!< Requested read format (after translation) */ - struct ast_format __do_not_use_writeformat; /*!< Requested write format (after translation) */ - struct ast_format __do_not_use_rawreadformat; /*!< Raw read format (before translation) */ - struct ast_format __do_not_use_rawwriteformat; /*!< Raw write format (before translation) */ - unsigned int __do_not_use_emulate_dtmf_duration; /*!< Number of ms left to emulate DTMF for */ -#ifdef HAVE_EPOLL - int __do_not_use_epfd; -#endif - int __do_not_use_visible_indication; /*!< Indication currently playing on the channel */ - - unsigned short __do_not_use_transfercapability; /*!< ISDN Transfer Capability - AST_FLAG_DIGITAL is not enough */ - - struct ast_bridge *bridge; /*!< Bridge this channel is participating in */ - struct ast_timer *__do_not_use_timer; /*!< timer object that provided timingfd */ - - char __do_not_use_context[AST_MAX_CONTEXT]; /*!< Dialplan: Current extension context */ - char __do_not_use_exten[AST_MAX_EXTENSION]; /*!< Dialplan: Current extension number */ - char __do_not_use_macrocontext[AST_MAX_CONTEXT]; /*!< Macro: Current non-macro context. See app_macro.c */ - char __do_not_use_macroexten[AST_MAX_EXTENSION]; /*!< Macro: Current non-macro extension. See app_macro.c */ - char __do_not_use_dtmf_digit_to_emulate; /*!< Digit being emulated */ -}; +struct ast_channel; /*! \brief ast_channel_tech Properties */ enum { @@ -2473,12 +2330,12 @@ static inline enum ast_t38_state ast_channel_get_t38_state(struct ast_channel *c } #define CHECK_BLOCKING(c) do { \ - if (ast_test_flag(c, AST_FLAG_BLOCKING)) {\ - ast_debug(1, "Thread %ld Blocking '%s', already blocked by thread %ld in procedure %s\n", (long) pthread_self(), ast_channel_name(c), (long) (c)->blocker, ast_channel_blockproc(c)); \ + if (ast_test_flag(ast_channel_flags(c), AST_FLAG_BLOCKING)) {\ + ast_debug(1, "Thread %ld Blocking '%s', already blocked by thread %ld in procedure %s\n", (long) pthread_self(), ast_channel_name(c), (long) ast_channel_blocker(c), ast_channel_blockproc(c)); \ } else { \ - (c)->blocker = pthread_self(); \ + ast_channel_blocker_set((c), pthread_self()); \ ast_channel_blockproc_set((c), __PRETTY_FUNCTION__); \ - ast_set_flag(c, AST_FLAG_BLOCKING); \ + ast_set_flag(ast_channel_flags(c), AST_FLAG_BLOCKING); \ } } while (0) ast_group_t ast_get_group(const char *s); @@ -3739,50 +3596,50 @@ unsigned long ast_channel_insmpl(const struct ast_channel *chan); void ast_channel_insmpl_set(struct ast_channel *chan, unsigned long value); unsigned long ast_channel_outsmpl(const struct ast_channel *chan); void ast_channel_outsmpl_set(struct ast_channel *chan, unsigned long value); -void * ast_channel_generatordata(const struct ast_channel *chan); -void ast_channel_generatordata_set(struct ast_channel *chan, void * value); -void * ast_channel_music_state(const struct ast_channel *chan); -void ast_channel_music_state_set(struct ast_channel *chan, void * value); -void * ast_channel_tech_pvt(const struct ast_channel *chan); -void ast_channel_tech_pvt_set(struct ast_channel *chan, void * value); -void * ast_channel_timingdata(const struct ast_channel *chan); -void ast_channel_timingdata_set(struct ast_channel *chan, void * value); -struct ast_audiohook_list * ast_channel_audiohooks(const struct ast_channel *chan); -void ast_channel_audiohooks_set(struct ast_channel *chan, struct ast_audiohook_list * value); -struct ast_cdr * ast_channel_cdr(const struct ast_channel *chan); -void ast_channel_cdr_set(struct ast_channel *chan, struct ast_cdr * value); -struct ast_channel * ast_channel__bridge(const struct ast_channel *chan); -void ast_channel__bridge_set(struct ast_channel *chan, struct ast_channel * value); -struct ast_channel * ast_channel_masq(const struct ast_channel *chan); -void ast_channel_masq_set(struct ast_channel *chan, struct ast_channel * value); -struct ast_channel * ast_channel_masqr(const struct ast_channel *chan); -void ast_channel_masqr_set(struct ast_channel *chan, struct ast_channel * value); -struct ast_channel_monitor * ast_channel_monitor(const struct ast_channel *chan); -void ast_channel_monitor_set(struct ast_channel *chan, struct ast_channel_monitor * value); -struct ast_filestream * ast_channel_stream(const struct ast_channel *chan); -void ast_channel_stream_set(struct ast_channel *chan, struct ast_filestream * value); -struct ast_filestream * ast_channel_vstream(const struct ast_channel *chan); -void ast_channel_vstream_set(struct ast_channel *chan, struct ast_filestream * value); -struct ast_format_cap * ast_channel_nativeformats(const struct ast_channel *chan); -void ast_channel_nativeformats_set(struct ast_channel *chan, struct ast_format_cap * value); -struct ast_framehook_list * ast_channel_framehooks(const struct ast_channel *chan); -void ast_channel_framehooks_set(struct ast_channel *chan, struct ast_framehook_list * value); -struct ast_generator * ast_channel_generator(const struct ast_channel *chan); -void ast_channel_generator_set(struct ast_channel *chan, struct ast_generator * value); -struct ast_pbx * ast_channel_pbx(const struct ast_channel *chan); -void ast_channel_pbx_set(struct ast_channel *chan, struct ast_pbx * value); -struct ast_sched_context * ast_channel_sched(const struct ast_channel *chan); -void ast_channel_sched_set(struct ast_channel *chan, struct ast_sched_context * value); -struct ast_timer * ast_channel_timer(const struct ast_channel *chan); -void ast_channel_timer_set(struct ast_channel *chan, struct ast_timer * value); -struct ast_tone_zone * ast_channel_zone(const struct ast_channel *chan); -void ast_channel_zone_set(struct ast_channel *chan, struct ast_tone_zone * value); -struct ast_trans_pvt * ast_channel_readtrans(const struct ast_channel *chan); -void ast_channel_readtrans_set(struct ast_channel *chan, struct ast_trans_pvt * value); -struct ast_trans_pvt * ast_channel_writetrans(const struct ast_channel *chan); -void ast_channel_writetrans_set(struct ast_channel *chan, struct ast_trans_pvt * value); -const struct ast_channel_tech * ast_channel_tech(const struct ast_channel *chan); -void ast_channel_tech_set(struct ast_channel *chan, const struct ast_channel_tech * value); +void *ast_channel_generatordata(const struct ast_channel *chan); +void ast_channel_generatordata_set(struct ast_channel *chan, void *value); +void *ast_channel_music_state(const struct ast_channel *chan); +void ast_channel_music_state_set(struct ast_channel *chan, void *value); +void *ast_channel_tech_pvt(const struct ast_channel *chan); +void ast_channel_tech_pvt_set(struct ast_channel *chan, void *value); +void *ast_channel_timingdata(const struct ast_channel *chan); +void ast_channel_timingdata_set(struct ast_channel *chan, void *value); +struct ast_audiohook_list *ast_channel_audiohooks(const struct ast_channel *chan); +void ast_channel_audiohooks_set(struct ast_channel *chan, struct ast_audiohook_list *value); +struct ast_cdr *ast_channel_cdr(const struct ast_channel *chan); +void ast_channel_cdr_set(struct ast_channel *chan, struct ast_cdr *value); +struct ast_channel *ast_channel__bridge(const struct ast_channel *chan); +void ast_channel__bridge_set(struct ast_channel *chan, struct ast_channel *value); +struct ast_channel *ast_channel_masq(const struct ast_channel *chan); +void ast_channel_masq_set(struct ast_channel *chan, struct ast_channel *value); +struct ast_channel *ast_channel_masqr(const struct ast_channel *chan); +void ast_channel_masqr_set(struct ast_channel *chan, struct ast_channel *value); +struct ast_channel_monitor *ast_channel_monitor(const struct ast_channel *chan); +void ast_channel_monitor_set(struct ast_channel *chan, struct ast_channel_monitor *value); +struct ast_filestream *ast_channel_stream(const struct ast_channel *chan); +void ast_channel_stream_set(struct ast_channel *chan, struct ast_filestream *value); +struct ast_filestream *ast_channel_vstream(const struct ast_channel *chan); +void ast_channel_vstream_set(struct ast_channel *chan, struct ast_filestream *value); +struct ast_format_cap *ast_channel_nativeformats(const struct ast_channel *chan); +void ast_channel_nativeformats_set(struct ast_channel *chan, struct ast_format_cap *value); +struct ast_framehook_list *ast_channel_framehooks(const struct ast_channel *chan); +void ast_channel_framehooks_set(struct ast_channel *chan, struct ast_framehook_list *value); +struct ast_generator *ast_channel_generator(const struct ast_channel *chan); +void ast_channel_generator_set(struct ast_channel *chan, struct ast_generator *value); +struct ast_pbx *ast_channel_pbx(const struct ast_channel *chan); +void ast_channel_pbx_set(struct ast_channel *chan, struct ast_pbx *value); +struct ast_sched_context *ast_channel_sched(const struct ast_channel *chan); +void ast_channel_sched_set(struct ast_channel *chan, struct ast_sched_context *value); +struct ast_timer *ast_channel_timer(const struct ast_channel *chan); +void ast_channel_timer_set(struct ast_channel *chan, struct ast_timer *value); +struct ast_tone_zone *ast_channel_zone(const struct ast_channel *chan); +void ast_channel_zone_set(struct ast_channel *chan, struct ast_tone_zone *value); +struct ast_trans_pvt *ast_channel_readtrans(const struct ast_channel *chan); +void ast_channel_readtrans_set(struct ast_channel *chan, struct ast_trans_pvt *value); +struct ast_trans_pvt *ast_channel_writetrans(const struct ast_channel *chan); +void ast_channel_writetrans_set(struct ast_channel *chan, struct ast_trans_pvt *value); +const struct ast_channel_tech *ast_channel_tech(const struct ast_channel *chan); +void ast_channel_tech_set(struct ast_channel *chan, const struct ast_channel_tech *value); enum ast_channel_adsicpe ast_channel_adsicpe(const struct ast_channel *chan); void ast_channel_adsicpe_set(struct ast_channel *chan, enum ast_channel_adsicpe value); enum ast_channel_state ast_channel_state(const struct ast_channel *chan); @@ -3792,7 +3649,7 @@ void ast_channel_state_set(struct ast_channel *chan, enum ast_channel_state); void ast_channel_softhangup_internal_flag_set(struct ast_channel *chan, int value); void ast_channel_softhangup_internal_flag_add(struct ast_channel *chan, int value); void ast_channel_softhangup_internal_flag_clear(struct ast_channel *chan, int value); -int ast_channel_softhangup_internal_flag(struct ast_channel * chan); +int ast_channel_softhangup_internal_flag(struct ast_channel *chan); /* Format getters */ struct ast_format *ast_channel_oldwriteformat(struct ast_channel *chan); @@ -3865,4 +3722,18 @@ int ast_channel_fd_isset(const struct ast_channel *chan, int which); struct ast_epoll_data *ast_channel_internal_epfd_data(const struct ast_channel *chan, int which); void ast_channel_internal_epfd_data_set(struct ast_channel *chan, int which , struct ast_epoll_data *value); #endif + +pthread_t ast_channel_blocker(const struct ast_channel *chan); +void ast_channel_blocker_set(struct ast_channel *chan, pthread_t value); + +ast_timing_func_t ast_channel_timingfunc(const struct ast_channel *chan); +void ast_channel_timingfunc_set(struct ast_channel *chan, ast_timing_func_t value); + +struct ast_bridge *ast_channel_internal_bridge(const struct ast_channel *chan); +void ast_channel_internal_bridge_set(struct ast_channel *chan, struct ast_bridge *value); + +struct ast_channel *ast_channel_internal_bridged_channel(const struct ast_channel *chan); +void ast_channel_internal_bridged_channel_set(struct ast_channel *chan, struct ast_channel *value); + +struct ast_flags *ast_channel_flags(struct ast_channel *chan); #endif /* _ASTERISK_CHANNEL_H */ diff --git a/main/app.c b/main/app.c index 1719a11f1c..3cdb184325 100644 --- a/main/app.c +++ b/main/app.c @@ -558,9 +558,9 @@ static void *linear_alloc(struct ast_channel *chan, void *params) /* In this case, params is already malloc'd */ if (ls->allowoverride) { - ast_set_flag(chan, AST_FLAG_WRITE_INT); + ast_set_flag(ast_channel_flags(chan), AST_FLAG_WRITE_INT); } else { - ast_clear_flag(chan, AST_FLAG_WRITE_INT); + ast_clear_flag(ast_channel_flags(chan), AST_FLAG_WRITE_INT); } ast_format_copy(&ls->origwfmt, ast_channel_writeformat(chan)); diff --git a/main/autoservice.c b/main/autoservice.c index fca180f5cb..96d2c5c18d 100644 --- a/main/autoservice.c +++ b/main/autoservice.c @@ -198,9 +198,9 @@ int ast_autoservice_start(struct ast_channel *chan) as->use_count = 1; ast_channel_lock(chan); - as->orig_end_dtmf_flag = ast_test_flag(chan, AST_FLAG_END_DTMF_ONLY) ? 1 : 0; + as->orig_end_dtmf_flag = ast_test_flag(ast_channel_flags(chan), AST_FLAG_END_DTMF_ONLY) ? 1 : 0; if (!as->orig_end_dtmf_flag) - ast_set_flag(chan, AST_FLAG_END_DTMF_ONLY); + ast_set_flag(ast_channel_flags(chan), AST_FLAG_END_DTMF_ONLY); ast_channel_unlock(chan); AST_LIST_LOCK(&aslist); @@ -282,7 +282,7 @@ int ast_autoservice_stop(struct ast_channel *chan) } if (!as->orig_end_dtmf_flag) { - ast_clear_flag(chan, AST_FLAG_END_DTMF_ONLY); + ast_clear_flag(ast_channel_flags(chan), AST_FLAG_END_DTMF_ONLY); } ast_channel_lock(chan); diff --git a/main/bridging.c b/main/bridging.c index 9a549691f4..66881c3f8e 100644 --- a/main/bridging.c +++ b/main/bridging.c @@ -818,7 +818,7 @@ static void bridge_channel_feature(struct ast_bridge *bridge, struct ast_bridge_ int look_for_dtmf = 1, dtmf_len = 0; /* The channel is now under our control and we don't really want any begin frames to do our DTMF matching so disable 'em at the core level */ - ast_set_flag(bridge_channel->chan, AST_FLAG_END_DTMF_ONLY); + ast_set_flag(ast_channel_flags(bridge_channel->chan), AST_FLAG_END_DTMF_ONLY); /* Wait for DTMF on the channel and put it into a buffer. If the buffer matches any feature hook execute the hook. */ while (look_for_dtmf) { @@ -863,7 +863,7 @@ static void bridge_channel_feature(struct ast_bridge *bridge, struct ast_bridge_ } /* Since we are done bringing DTMF in return to using both begin and end frames */ - ast_clear_flag(bridge_channel->chan, AST_FLAG_END_DTMF_ONLY); + ast_clear_flag(ast_channel_flags(bridge_channel->chan), AST_FLAG_END_DTMF_ONLY); /* If a hook was actually matched execute it on this channel, otherwise stream up the DTMF to the other channels */ if (hook) { @@ -967,7 +967,7 @@ static enum ast_bridge_channel_state bridge_channel_join(struct ast_bridge_chann /* Actually execute the respective threading model, and keep our bridge thread alive */ while (bridge_channel->state == AST_BRIDGE_CHANNEL_STATE_WAIT) { /* Update bridge pointer on channel */ - bridge_channel->chan->bridge = bridge_channel->bridge; + ast_channel_internal_bridge_set(bridge_channel->chan, bridge_channel->bridge); /* If the technology requires a thread and one is not running, start it up */ if (bridge_channel->bridge->thread == AST_PTHREADT_NULL && (bridge_channel->bridge->technology->capabilities & AST_BRIDGE_CAPABILITY_THREAD)) { bridge_channel->bridge->stop = 0; @@ -1006,7 +1006,7 @@ static enum ast_bridge_channel_state bridge_channel_join(struct ast_bridge_chann } } - bridge_channel->chan->bridge = NULL; + ast_channel_internal_bridge_set(bridge_channel->chan, NULL); /* See if we need to dissolve the bridge itself if they hung up */ if (bridge_channel->state == AST_BRIDGE_CHANNEL_STATE_END) { diff --git a/main/channel.c b/main/channel.c index 5fdd9ce9fe..c1431c7ef3 100644 --- a/main/channel.c +++ b/main/channel.c @@ -67,6 +67,7 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$") #include "asterisk/stringfields.h" #include "asterisk/global_datastores.h" #include "asterisk/data.h" +#include "asterisk/channel_internal.h" #ifdef HAVE_EPOLL #include @@ -928,21 +929,12 @@ __ast_channel_alloc_ap(int needqueue, int state, const char *cid_num, const char struct ast_timer *timer; /* If shutting down, don't allocate any new channels */ - if (shutting_down) { + if (ast_shutting_down()) { ast_log(LOG_WARNING, "Channel allocation failed: Refusing due to active shutdown\n"); return NULL; } -#if defined(REF_DEBUG) - tmp = __ao2_alloc_debug(sizeof(*tmp), ast_channel_destructor, - AO2_ALLOC_OPT_LOCK_MUTEX, "", file, line, function, 1); -#elif defined(__AST_DEBUG_MALLOC) - tmp = __ao2_alloc_debug(sizeof(*tmp), ast_channel_destructor, - AO2_ALLOC_OPT_LOCK_MUTEX, "", file, line, function, 0); -#else - tmp = ao2_alloc(sizeof(*tmp), ast_channel_destructor); -#endif - if (!tmp) { + if (!(tmp = ast_channel_internal_alloc(ast_channel_destructor))) { /* Channel structure allocation failure. */ return NULL; } @@ -999,10 +991,6 @@ __ast_channel_alloc_ap(int needqueue, int state, const char *cid_num, const char ast_channel_timingfd_set(tmp, ast_timer_fd(ast_channel_timer(tmp))); } - if (needqueue && ast_channel_internal_alertpipe_init(tmp)) { - return ast_channel_unref(tmp); - } - /* * This is the last place the channel constructor can fail. * @@ -1010,7 +998,8 @@ __ast_channel_alloc_ap(int needqueue, int state, const char *cid_num, const char * AST_CEL_CHANNEL_END is not posted if we have not posted the * AST_CEL_CHANNEL_START yet. */ - if ((ast_string_field_init(tmp, 128))) { + + if (needqueue && ast_channel_internal_alertpipe_init(tmp)) { return ast_channel_unref(tmp); } @@ -1132,6 +1121,7 @@ __ast_channel_alloc_ap(int needqueue, int state, const char *cid_num, const char ast_channel_uniqueid(tmp)); } + ast_channel_internal_finalize(tmp); return tmp; } @@ -1164,24 +1154,11 @@ struct ast_channel *ast_dummy_channel_alloc(void) struct ast_channel *tmp; struct varshead *headp; -#if defined(REF_DEBUG) - tmp = __ao2_alloc_debug(sizeof(*tmp), ast_dummy_channel_destructor, - AO2_ALLOC_OPT_LOCK_MUTEX, "dummy channel", file, line, function, 1); -#elif defined(__AST_DEBUG_MALLOC) - tmp = __ao2_alloc_debug(sizeof(*tmp), ast_dummy_channel_destructor, - AO2_ALLOC_OPT_LOCK_MUTEX, "dummy channel", file, line, function, 0); -#else - tmp = ao2_alloc(sizeof(*tmp), ast_dummy_channel_destructor); -#endif - if (!tmp) { + if (!(tmp = ast_channel_internal_alloc(ast_dummy_channel_destructor))) { /* Dummy channel structure allocation failure. */ return NULL; } - if ((ast_string_field_init(tmp, 128))) { - return ast_channel_unref(tmp); - } - headp = ast_channel_varshead(tmp); AST_LIST_HEAD_INIT_NOLOCK(headp); @@ -1196,7 +1173,7 @@ static int __ast_queue_frame(struct ast_channel *chan, struct ast_frame *fin, in unsigned int new_voice_frames = 0; unsigned int queued_frames = 0; unsigned int queued_voice_frames = 0; - AST_LIST_HEAD_NOLOCK(, ast_frame) frames; + AST_LIST_HEAD_NOLOCK(,ast_frame) frames; ast_channel_lock(chan); @@ -1296,8 +1273,8 @@ static int __ast_queue_frame(struct ast_channel *chan, struct ast_frame *fin, in } } else if (ast_channel_timingfd(chan) > -1) { ast_timer_enable_continuous(ast_channel_timer(chan)); - } else if (ast_test_flag(chan, AST_FLAG_BLOCKING)) { - pthread_kill(chan->blocker, SIGURG); + } else if (ast_test_flag(ast_channel_flags(chan), AST_FLAG_BLOCKING)) { + pthread_kill(ast_channel_blocker(chan), SIGURG); } ast_channel_unlock(chan); @@ -1380,8 +1357,8 @@ int ast_channel_defer_dtmf(struct ast_channel *chan) int pre = 0; if (chan) { - pre = ast_test_flag(chan, AST_FLAG_DEFER_DTMF); - ast_set_flag(chan, AST_FLAG_DEFER_DTMF); + pre = ast_test_flag(ast_channel_flags(chan), AST_FLAG_DEFER_DTMF); + ast_set_flag(ast_channel_flags(chan), AST_FLAG_DEFER_DTMF); } return pre; } @@ -1390,7 +1367,7 @@ int ast_channel_defer_dtmf(struct ast_channel *chan) void ast_channel_undefer_dtmf(struct ast_channel *chan) { if (chan) - ast_clear_flag(chan, AST_FLAG_DEFER_DTMF); + ast_clear_flag(ast_channel_flags(chan), AST_FLAG_DEFER_DTMF); } struct ast_channel *ast_channel_callback(ao2_callback_data_fn *cb_fn, void *arg, @@ -2172,8 +2149,7 @@ static void ast_channel_destructor(void *obj) struct ast_datastore *datastore; char device_name[AST_CHANNEL_NAME]; - if (ast_channel_name(chan)) { - /* The string fields were initialized. */ + if (ast_channel_internal_is_finalized(chan)) { ast_cel_report_event(chan, AST_CEL_CHANNEL_END, NULL, NULL, NULL); ast_cel_check_retire_linkedid(chan); } @@ -2199,10 +2175,9 @@ static void ast_channel_destructor(void *obj) ast_sched_context_destroy(ast_channel_sched(chan)); } - if (ast_channel_name(chan)) { + if (ast_channel_internal_is_finalized(chan)) { char *dashptr; - /* The string fields were initialized. */ ast_copy_string(device_name, ast_channel_name(chan), sizeof(device_name)); if ((dashptr = strrchr(device_name, '-'))) { *dashptr = '\0'; @@ -2268,7 +2243,7 @@ static void ast_channel_destructor(void *obj) ast_channel_zone_set(chan, ast_tone_zone_unref(ast_channel_zone(chan))); } - ast_string_field_free_memory(chan); + ast_channel_internal_cleanup(chan); if (device_name[0]) { /* @@ -2308,7 +2283,7 @@ static void ast_dummy_channel_destructor(void *obj) ast_channel_cdr_set(chan, NULL); } - ast_string_field_free_memory(chan); + ast_channel_internal_cleanup(chan); } struct ast_datastore *ast_channel_datastore_alloc(const struct ast_datastore_info *info, const char *uid) @@ -2490,8 +2465,8 @@ int ast_softhangup_nolock(struct ast_channel *chan, int cause) ast_channel_softhangup_internal_flag_add(chan, cause); ast_queue_frame(chan, &ast_null_frame); /* Interrupt any poll call or such */ - if (ast_test_flag(chan, AST_FLAG_BLOCKING)) - pthread_kill(chan->blocker, SIGURG); + if (ast_test_flag(ast_channel_flags(chan), AST_FLAG_BLOCKING)) + pthread_kill(ast_channel_blocker(chan), SIGURG); return 0; } @@ -2597,14 +2572,14 @@ int ast_hangup(struct ast_channel *chan) * Mark it as a zombie already so ast_do_masquerade() will know * to free it later. */ - ast_set_flag(chan, AST_FLAG_ZOMBIE); + ast_set_flag(ast_channel_flags(chan), AST_FLAG_ZOMBIE); destroy_hooks(chan); ast_channel_unlock(chan); return 0; } - if (!(was_zombie = ast_test_flag(chan, AST_FLAG_ZOMBIE))) { - ast_set_flag(chan, AST_FLAG_ZOMBIE); + if (!(was_zombie = ast_test_flag(ast_channel_flags(chan), AST_FLAG_ZOMBIE))) { + ast_set_flag(ast_channel_flags(chan), AST_FLAG_ZOMBIE); } ast_channel_unlock(chan); @@ -2640,11 +2615,11 @@ int ast_hangup(struct ast_channel *chan) snprintf(extra_str, sizeof(extra_str), "%d,%s,%s", ast_channel_hangupcause(chan), ast_channel_hangupsource(chan), S_OR(pbx_builtin_getvar_helper(chan, "DIALSTATUS"), "")); ast_cel_report_event(chan, AST_CEL_HANGUP, NULL, extra_str, NULL); - if (ast_test_flag(chan, AST_FLAG_BLOCKING)) { + if (ast_test_flag(ast_channel_flags(chan), AST_FLAG_BLOCKING)) { ast_log(LOG_WARNING, "Hard hangup called by thread %ld on %s, while fd " "is blocked by thread %ld in procedure %s! Expect a failure\n", - (long) pthread_self(), ast_channel_name(chan), (long)chan->blocker, ast_channel_blockproc(chan)); - ast_assert(ast_test_flag(chan, AST_FLAG_BLOCKING) == 0); + (long) pthread_self(), ast_channel_name(chan), (long)ast_channel_blocker(chan), ast_channel_blockproc(chan)); + ast_assert(ast_test_flag(ast_channel_flags(chan), AST_FLAG_BLOCKING) == 0); } if (!was_zombie) { ast_debug(1, "Hanging up channel '%s'\n", ast_channel_name(chan)); @@ -2700,13 +2675,13 @@ int ast_raw_answer(struct ast_channel *chan, int cdr_answer) ast_channel_lock(chan); /* You can't answer an outbound call */ - if (ast_test_flag(chan, AST_FLAG_OUTGOING)) { + if (ast_test_flag(ast_channel_flags(chan), AST_FLAG_OUTGOING)) { ast_channel_unlock(chan); return 0; } /* Stop if we're a zombie or need a soft hangup */ - if (ast_test_flag(chan, AST_FLAG_ZOMBIE) || ast_check_hangup(chan)) { + if (ast_test_flag(ast_channel_flags(chan), AST_FLAG_ZOMBIE) || ast_check_hangup(chan)) { ast_channel_unlock(chan); return -1; } @@ -2860,7 +2835,7 @@ void ast_deactivate_generator(struct ast_channel *chan) ast_channel_generatordata_set(chan, NULL); ast_channel_generator_set(chan, NULL); ast_channel_set_fd(chan, AST_GENERATOR_FD, -1); - ast_clear_flag(chan, AST_FLAG_WRITE_INT); + ast_clear_flag(ast_channel_flags(chan), AST_FLAG_WRITE_INT); ast_settimeout(chan, 0, NULL, NULL); } ast_channel_unlock(chan); @@ -3044,7 +3019,7 @@ struct ast_channel *ast_waitfor_nandfds(struct ast_channel **c, int n, int *fds, res = ast_poll(pfds, max, rms); } for (x = 0; x < n; x++) - ast_clear_flag(c[x], AST_FLAG_BLOCKING); + ast_clear_flag(ast_channel_flags(c[x]), AST_FLAG_BLOCKING); if (res < 0) { /* Simulate a timeout if we were interrupted */ if (errno != EINTR) *ms = -1; @@ -3076,9 +3051,9 @@ struct ast_channel *ast_waitfor_nandfds(struct ast_channel **c, int n, int *fds, if (fdmap[x].chan >= 0) { /* this is a channel */ winner = c[fdmap[x].chan]; /* override previous winners */ if (res & POLLPRI) - ast_set_flag(winner, AST_FLAG_EXCEPTION); + ast_set_flag(ast_channel_flags(winner), AST_FLAG_EXCEPTION); else - ast_clear_flag(winner, AST_FLAG_EXCEPTION); + ast_clear_flag(ast_channel_flags(winner), AST_FLAG_EXCEPTION); ast_channel_fdno_set(winner, fdmap[x].fdno); } else { /* this is an fd */ if (outfd) @@ -3140,7 +3115,7 @@ static struct ast_channel *ast_waitfor_nandfds_simple(struct ast_channel *chan, res = epoll_wait(ast_channel_epfd(chan), ev, 1, rms); /* Stop blocking */ - ast_clear_flag(chan, AST_FLAG_BLOCKING); + ast_clear_flag(ast_channel_flags(chan), AST_FLAG_BLOCKING); /* Simulate a timeout if we were interrupted */ if (res < 0) { @@ -3167,9 +3142,9 @@ static struct ast_channel *ast_waitfor_nandfds_simple(struct ast_channel *chan, aed = ev[0].data.ptr; ast_channel_fdno_set(chan, aed->which); if (ev[0].events & EPOLLPRI) - ast_set_flag(chan, AST_FLAG_EXCEPTION); + ast_set_flag(ast_channel_flags(chan), AST_FLAG_EXCEPTION); else - ast_clear_flag(chan, AST_FLAG_EXCEPTION); + ast_clear_flag(ast_channel_flags(chan), AST_FLAG_EXCEPTION); if (*ms > 0) { *ms -= ast_tvdiff_ms(ast_tvnow(), start); @@ -3225,7 +3200,7 @@ static struct ast_channel *ast_waitfor_nandfds_complex(struct ast_channel **c, i res = epoll_wait(ast_channel_epfd(c[0]), ev, 25, rms); for (i = 0; i < n; i++) - ast_clear_flag(c[i], AST_FLAG_BLOCKING); + ast_clear_flag(ast_channel_flags(c[i]), AST_FLAG_BLOCKING); if (res < 0) { if (errno != EINTR) @@ -3257,9 +3232,9 @@ static struct ast_channel *ast_waitfor_nandfds_complex(struct ast_channel **c, i winner = aed->chan; if (ev[i].events & EPOLLPRI) - ast_set_flag(winner, AST_FLAG_EXCEPTION); + ast_set_flag(ast_channel_flags(winner), AST_FLAG_EXCEPTION); else - ast_clear_flag(winner, AST_FLAG_EXCEPTION); + ast_clear_flag(ast_channel_flags(winner), AST_FLAG_EXCEPTION); ast_channel_fdno_set(winner, aed->which); } @@ -3337,7 +3312,7 @@ int ast_settimeout(struct ast_channel *c, unsigned int rate, int (*func)(const v res = ast_timer_set_rate(ast_channel_timer(c), real_rate); - c->timingfunc = func; + ast_channel_timingfunc_set(c, func); ast_channel_timingdata_set(c, data); if (func == NULL && rate == 0 && ast_channel_fdno(c) == AST_TIMING_FD) { @@ -3358,11 +3333,11 @@ int ast_settimeout(struct ast_channel *c, unsigned int rate, int (*func)(const v int ast_waitfordigit_full(struct ast_channel *c, int ms, int audiofd, int cmdfd) { /* Stop if we're a zombie or need a soft hangup */ - if (ast_test_flag(c, AST_FLAG_ZOMBIE) || ast_check_hangup(c)) + if (ast_test_flag(ast_channel_flags(c), AST_FLAG_ZOMBIE) || ast_check_hangup(c)) return -1; /* Only look for the end of DTMF, don't bother with the beginning and don't emulate things */ - ast_set_flag(c, AST_FLAG_END_DTMF_ONLY); + ast_set_flag(ast_channel_flags(c), AST_FLAG_END_DTMF_ONLY); /* Wait for a digit, no more than ms milliseconds total. */ @@ -3377,12 +3352,12 @@ int ast_waitfordigit_full(struct ast_channel *c, int ms, int audiofd, int cmdfd) if (errno == 0 || errno == EINTR) continue; ast_log(LOG_WARNING, "Wait failed (%s)\n", strerror(errno)); - ast_clear_flag(c, AST_FLAG_END_DTMF_ONLY); + ast_clear_flag(ast_channel_flags(c), AST_FLAG_END_DTMF_ONLY); return -1; } else if (outfd > -1) { /* The FD we were watching has something waiting */ ast_log(LOG_WARNING, "The FD we were waiting for has something waiting. Waitfordigit returning numeric 1\n"); - ast_clear_flag(c, AST_FLAG_END_DTMF_ONLY); + ast_clear_flag(ast_channel_flags(c), AST_FLAG_END_DTMF_ONLY); return 1; } else if (rchan) { int res; @@ -3396,13 +3371,13 @@ int ast_waitfordigit_full(struct ast_channel *c, int ms, int audiofd, int cmdfd) case AST_FRAME_DTMF_END: res = f->subclass.integer; ast_frfree(f); - ast_clear_flag(c, AST_FLAG_END_DTMF_ONLY); + ast_clear_flag(ast_channel_flags(c), AST_FLAG_END_DTMF_ONLY); return res; case AST_FRAME_CONTROL: switch (f->subclass.integer) { case AST_CONTROL_HANGUP: ast_frfree(f); - ast_clear_flag(c, AST_FLAG_END_DTMF_ONLY); + ast_clear_flag(ast_channel_flags(c), AST_FLAG_END_DTMF_ONLY); return -1; case AST_CONTROL_RINGING: case AST_CONTROL_ANSWER: @@ -3436,7 +3411,7 @@ int ast_waitfordigit_full(struct ast_channel *c, int ms, int audiofd, int cmdfd) } } - ast_clear_flag(c, AST_FLAG_END_DTMF_ONLY); + ast_clear_flag(ast_channel_flags(c), AST_FLAG_END_DTMF_ONLY); return 0; /* Time is up */ } @@ -3462,7 +3437,7 @@ static void ast_read_generator_actions(struct ast_channel *chan, struct ast_fram int res; int samples; - if (chan->timingfunc) { + if (ast_channel_timingfunc(chan)) { ast_debug(1, "Generator got voice, switching to phase locked mode\n"); ast_settimeout(chan, 0, NULL, NULL); } @@ -3495,7 +3470,7 @@ static void ast_read_generator_actions(struct ast_channel *chan, struct ast_fram } } else if (f->frametype == AST_FRAME_CNG) { - if (ast_channel_generator(chan) && !chan->timingfunc && (ast_channel_timingfd(chan) > -1)) { + if (ast_channel_generator(chan) && !ast_channel_timingfunc(chan) && (ast_channel_timingfd(chan) > -1)) { ast_debug(1, "Generator got CNG, switching to timed mode\n"); ast_settimeout(chan, 50, generator_force, chan); } @@ -3522,7 +3497,7 @@ static inline void queue_dtmf_readq(struct ast_channel *chan, struct ast_frame * */ static inline int should_skip_dtmf(struct ast_channel *chan) { - if (ast_test_flag(chan, AST_FLAG_DEFER_DTMF | AST_FLAG_EMULATE_DTMF)) { + if (ast_test_flag(ast_channel_flags(chan), AST_FLAG_DEFER_DTMF | AST_FLAG_EMULATE_DTMF)) { /* We're in the middle of emulating a digit, or DTMF has been * explicitly deferred. Skip this digit, then. */ return 1; @@ -3582,7 +3557,7 @@ static struct ast_frame *__ast_read(struct ast_channel *chan, int dropaudio) ast_channel_lock(chan); /* Stop if we're a zombie or need a soft hangup */ - if (ast_test_flag(chan, AST_FLAG_ZOMBIE) || ast_check_hangup(chan)) { + if (ast_test_flag(ast_channel_flags(chan), AST_FLAG_ZOMBIE) || ast_check_hangup(chan)) { if (ast_channel_generator(chan)) ast_deactivate_generator(chan); @@ -3627,7 +3602,7 @@ static struct ast_frame *__ast_read(struct ast_channel *chan, int dropaudio) if (ast_channel_timingfd(chan) > -1 && ast_channel_fdno(chan) == AST_TIMING_FD) { enum ast_timer_event res; - ast_clear_flag(chan, AST_FLAG_EXCEPTION); + ast_clear_flag(ast_channel_flags(chan), AST_FLAG_EXCEPTION); res = ast_timer_get_event(ast_channel_timer(chan)); @@ -3635,9 +3610,9 @@ static struct ast_frame *__ast_read(struct ast_channel *chan, int dropaudio) case AST_TIMING_EVENT_EXPIRED: ast_timer_ack(ast_channel_timer(chan), 1); - if (chan->timingfunc) { + if (ast_channel_timingfunc(chan)) { /* save a copy of func/data before unlocking the channel */ - int (*func)(const void *) = chan->timingfunc; + ast_timing_func_t func = ast_channel_timingfunc(chan); void *data = ast_channel_timingdata(chan); ast_channel_fdno_set(chan, -1); ast_channel_unlock(chan); @@ -3671,7 +3646,7 @@ static struct ast_frame *__ast_read(struct ast_channel *chan, int dropaudio) ast_channel_fdno_set(chan, -1); goto done; } else if (ast_channel_fd_isset(chan, AST_JITTERBUFFER_FD) && ast_channel_fdno(chan) == AST_JITTERBUFFER_FD) { - ast_clear_flag(chan, AST_FLAG_EXCEPTION); + ast_clear_flag(ast_channel_flags(chan), AST_FLAG_EXCEPTION); } /* Read and ignore anything on the alertpipe, but read only @@ -3722,8 +3697,8 @@ static struct ast_frame *__ast_read(struct ast_channel *chan, int dropaudio) } } } else { - chan->blocker = pthread_self(); - if (ast_test_flag(chan, AST_FLAG_EXCEPTION)) { + ast_channel_blocker_set(chan, pthread_self()); + if (ast_test_flag(ast_channel_flags(chan), AST_FLAG_EXCEPTION)) { if (ast_channel_tech(chan)->exception) f = ast_channel_tech(chan)->exception(chan); else { @@ -3731,7 +3706,7 @@ static struct ast_frame *__ast_read(struct ast_channel *chan, int dropaudio) f = &ast_null_frame; } /* Clear the exception flag */ - ast_clear_flag(chan, AST_FLAG_EXCEPTION); + ast_clear_flag(ast_channel_flags(chan), AST_FLAG_EXCEPTION); } else if (ast_channel_tech(chan) && ast_channel_tech(chan)->read) f = ast_channel_tech(chan)->read(chan); else @@ -3765,7 +3740,7 @@ static struct ast_frame *__ast_read(struct ast_channel *chan, int dropaudio) switch (f->frametype) { case AST_FRAME_CONTROL: if (f->subclass.integer == AST_CONTROL_ANSWER) { - if (!ast_test_flag(chan, AST_FLAG_OUTGOING)) { + if (!ast_test_flag(ast_channel_flags(chan), AST_FLAG_OUTGOING)) { ast_debug(1, "Ignoring answer on an inbound call!\n"); ast_frfree(f); f = &ast_null_frame; @@ -3807,11 +3782,11 @@ static struct ast_frame *__ast_read(struct ast_channel *chan, int dropaudio) send_dtmf_event(chan, "Received", f->subclass.integer, "No", "Yes"); ast_log(LOG_DTMF, "DTMF end '%c' received on %s, duration %ld ms\n", f->subclass.integer, ast_channel_name(chan), f->len); /* Queue it up if DTMF is deferred, or if DTMF emulation is forced. */ - if (ast_test_flag(chan, AST_FLAG_DEFER_DTMF) || ast_test_flag(chan, AST_FLAG_EMULATE_DTMF)) { + if (ast_test_flag(ast_channel_flags(chan), AST_FLAG_DEFER_DTMF) || ast_test_flag(ast_channel_flags(chan), AST_FLAG_EMULATE_DTMF)) { queue_dtmf_readq(chan, f); ast_frfree(f); f = &ast_null_frame; - } else if (!ast_test_flag(chan, AST_FLAG_IN_DTMF | AST_FLAG_END_DTMF_ONLY)) { + } else if (!ast_test_flag(ast_channel_flags(chan), AST_FLAG_IN_DTMF | AST_FLAG_END_DTMF_ONLY)) { if (!ast_tvzero(*ast_channel_dtmf_tv(chan)) && ast_tvdiff_ms(ast_tvnow(), *ast_channel_dtmf_tv(chan)) < AST_MIN_DTMF_GAP) { /* If it hasn't been long enough, defer this digit */ @@ -3822,7 +3797,7 @@ static struct ast_frame *__ast_read(struct ast_channel *chan, int dropaudio) /* There was no begin, turn this into a begin and send the end later */ struct timeval tv = ast_tvnow(); f->frametype = AST_FRAME_DTMF_BEGIN; - ast_set_flag(chan, AST_FLAG_EMULATE_DTMF); + ast_set_flag(ast_channel_flags(chan), AST_FLAG_EMULATE_DTMF); ast_channel_dtmf_digit_to_emulate_set(chan, f->subclass.integer); ast_channel_dtmf_tv_set(chan, &tv); if (f->len) { @@ -3845,9 +3820,9 @@ static struct ast_frame *__ast_read(struct ast_channel *chan, int dropaudio) } } else { struct timeval now = ast_tvnow(); - if (ast_test_flag(chan, AST_FLAG_IN_DTMF)) { + if (ast_test_flag(ast_channel_flags(chan), AST_FLAG_IN_DTMF)) { ast_log(LOG_DTMF, "DTMF end accepted with begin '%c' on %s\n", f->subclass.integer, ast_channel_name(chan)); - ast_clear_flag(chan, AST_FLAG_IN_DTMF); + ast_clear_flag(ast_channel_flags(chan), AST_FLAG_IN_DTMF); if (!f->len) f->len = ast_tvdiff_ms(now, *ast_channel_dtmf_tv(chan)); @@ -3867,9 +3842,9 @@ static struct ast_frame *__ast_read(struct ast_channel *chan, int dropaudio) ast_log(LOG_DTMF, "DTMF end accepted without begin '%c' on %s\n", f->subclass.integer, ast_channel_name(chan)); f->len = AST_MIN_DTMF_DURATION; } - if (f->len < AST_MIN_DTMF_DURATION && !ast_test_flag(chan, AST_FLAG_END_DTMF_ONLY)) { + if (f->len < AST_MIN_DTMF_DURATION && !ast_test_flag(ast_channel_flags(chan), AST_FLAG_END_DTMF_ONLY)) { ast_log(LOG_DTMF, "DTMF end '%c' has duration %ld but want minimum %d, emulating on %s\n", f->subclass.integer, f->len, AST_MIN_DTMF_DURATION, ast_channel_name(chan)); - ast_set_flag(chan, AST_FLAG_EMULATE_DTMF); + ast_set_flag(ast_channel_flags(chan), AST_FLAG_EMULATE_DTMF); ast_channel_dtmf_digit_to_emulate_set(chan, f->subclass.integer); ast_channel_emulate_dtmf_duration_set(chan, AST_MIN_DTMF_DURATION - f->len); ast_frfree(f); @@ -3892,7 +3867,7 @@ static struct ast_frame *__ast_read(struct ast_channel *chan, int dropaudio) case AST_FRAME_DTMF_BEGIN: send_dtmf_event(chan, "Received", f->subclass.integer, "Yes", "No"); ast_log(LOG_DTMF, "DTMF begin '%c' received on %s\n", f->subclass.integer, ast_channel_name(chan)); - if ( ast_test_flag(chan, AST_FLAG_DEFER_DTMF | AST_FLAG_END_DTMF_ONLY | AST_FLAG_EMULATE_DTMF) || + if (ast_test_flag(ast_channel_flags(chan), AST_FLAG_DEFER_DTMF | AST_FLAG_END_DTMF_ONLY | AST_FLAG_EMULATE_DTMF) || (!ast_tvzero(*ast_channel_dtmf_tv(chan)) && ast_tvdiff_ms(ast_tvnow(), *ast_channel_dtmf_tv(chan)) < AST_MIN_DTMF_GAP) ) { ast_log(LOG_DTMF, "DTMF begin ignored '%c' on %s\n", f->subclass.integer, ast_channel_name(chan)); @@ -3900,7 +3875,7 @@ static struct ast_frame *__ast_read(struct ast_channel *chan, int dropaudio) f = &ast_null_frame; } else { struct timeval now = ast_tvnow(); - ast_set_flag(chan, AST_FLAG_IN_DTMF); + ast_set_flag(ast_channel_flags(chan), AST_FLAG_IN_DTMF); ast_channel_dtmf_tv_set(chan, &now); ast_log(LOG_DTMF, "DTMF begin passthrough '%c' on %s\n", f->subclass.integer, ast_channel_name(chan)); } @@ -3910,10 +3885,10 @@ static struct ast_frame *__ast_read(struct ast_channel *chan, int dropaudio) * is reached , because we want to make sure we pass at least one * voice frame through before starting the next digit, to ensure a gap * between DTMF digits. */ - if (ast_test_flag(chan, AST_FLAG_EMULATE_DTMF)) { + if (ast_test_flag(ast_channel_flags(chan), AST_FLAG_EMULATE_DTMF)) { struct timeval now = ast_tvnow(); if (!ast_channel_emulate_dtmf_duration(chan)) { - ast_clear_flag(chan, AST_FLAG_EMULATE_DTMF); + ast_clear_flag(ast_channel_flags(chan), AST_FLAG_EMULATE_DTMF); ast_channel_dtmf_digit_to_emulate_set(chan, 0); } else if (ast_tvdiff_ms(now, *ast_channel_dtmf_tv(chan)) >= ast_channel_emulate_dtmf_duration(chan)) { ast_channel_emulate_dtmf_duration_set(chan, 0); @@ -3923,7 +3898,7 @@ static struct ast_frame *__ast_read(struct ast_channel *chan, int dropaudio) f->subclass.integer = ast_channel_dtmf_digit_to_emulate(chan); f->len = ast_tvdiff_ms(now, *ast_channel_dtmf_tv(chan)); ast_channel_dtmf_tv_set(chan, &now); - ast_clear_flag(chan, AST_FLAG_EMULATE_DTMF); + ast_clear_flag(ast_channel_flags(chan), AST_FLAG_EMULATE_DTMF); ast_channel_dtmf_digit_to_emulate_set(chan, 0); ast_log(LOG_DTMF, "DTMF end emulation of '%c' queued on %s\n", f->subclass.integer, ast_channel_name(chan)); if (ast_channel_audiohooks(chan)) { @@ -3941,19 +3916,19 @@ static struct ast_frame *__ast_read(struct ast_channel *chan, int dropaudio) * is reached , because we want to make sure we pass at least one * voice frame through before starting the next digit, to ensure a gap * between DTMF digits. */ - if (ast_test_flag(chan, AST_FLAG_EMULATE_DTMF) && !ast_channel_emulate_dtmf_duration(chan)) { - ast_clear_flag(chan, AST_FLAG_EMULATE_DTMF); + if (ast_test_flag(ast_channel_flags(chan), AST_FLAG_EMULATE_DTMF) && !ast_channel_emulate_dtmf_duration(chan)) { + ast_clear_flag(ast_channel_flags(chan), AST_FLAG_EMULATE_DTMF); ast_channel_dtmf_digit_to_emulate_set(chan, 0); } - if (dropaudio || ast_test_flag(chan, AST_FLAG_IN_DTMF)) { + if (dropaudio || ast_test_flag(ast_channel_flags(chan), AST_FLAG_IN_DTMF)) { if (dropaudio) ast_read_generator_actions(chan, f); ast_frfree(f); f = &ast_null_frame; } - if (ast_test_flag(chan, AST_FLAG_EMULATE_DTMF) && !ast_test_flag(chan, AST_FLAG_IN_DTMF)) { + if (ast_test_flag(ast_channel_flags(chan), AST_FLAG_EMULATE_DTMF) && !ast_test_flag(ast_channel_flags(chan), AST_FLAG_IN_DTMF)) { struct timeval now = ast_tvnow(); if (ast_tvdiff_ms(now, *ast_channel_dtmf_tv(chan)) >= ast_channel_emulate_dtmf_duration(chan)) { ast_channel_emulate_dtmf_duration_set(chan, 0); @@ -4162,7 +4137,7 @@ int ast_indicate_data(struct ast_channel *chan, int _condition, ast_channel_lock(chan); /* Don't bother if the channel is about to go away, anyway. */ - if (ast_test_flag(chan, AST_FLAG_ZOMBIE) || ast_check_hangup(chan)) { + if (ast_test_flag(ast_channel_flags(chan), AST_FLAG_ZOMBIE) || ast_check_hangup(chan)) { res = -1; goto indicate_cleanup; } @@ -4388,7 +4363,7 @@ int ast_sendtext(struct ast_channel *chan, const char *text) ast_channel_lock(chan); /* Stop if we're a zombie or need a soft hangup */ - if (ast_test_flag(chan, AST_FLAG_ZOMBIE) || ast_check_hangup(chan)) { + if (ast_test_flag(ast_channel_flags(chan), AST_FLAG_ZOMBIE) || ast_check_hangup(chan)) { ast_channel_unlock(chan); return -1; } @@ -4415,7 +4390,7 @@ int ast_sendtext(struct ast_channel *chan, const char *text) } else if (ast_channel_tech(chan)->send_text) { res = ast_channel_tech(chan)->send_text(chan, text); } - ast_clear_flag(chan, AST_FLAG_BLOCKING); + ast_clear_flag(ast_channel_flags(chan), AST_FLAG_BLOCKING); ast_channel_unlock(chan); return res; } @@ -4636,7 +4611,7 @@ int ast_write(struct ast_channel *chan, struct ast_frame *fr) usleep(1); } /* Stop if we're a zombie or need a soft hangup */ - if (ast_test_flag(chan, AST_FLAG_ZOMBIE) || ast_check_hangup(chan)) + if (ast_test_flag(ast_channel_flags(chan), AST_FLAG_ZOMBIE) || ast_check_hangup(chan)) goto done; /* Handle any pending masquerades */ @@ -4661,14 +4636,14 @@ int ast_write(struct ast_channel *chan, struct ast_frame *fr) } if (ast_channel_generatordata(chan) && (!fr->src || strcasecmp(fr->src, "ast_prod"))) { - if (ast_test_flag(chan, AST_FLAG_WRITE_INT)) { + if (ast_test_flag(ast_channel_flags(chan), AST_FLAG_WRITE_INT)) { ast_deactivate_generator(chan); } else { if (fr->frametype == AST_FRAME_DTMF_END) { /* There is a generator running while we're in the middle of a digit. * It's probably inband DTMF, so go ahead and pass it so it can * stop the generator */ - ast_clear_flag(chan, AST_FLAG_BLOCKING); + ast_clear_flag(ast_channel_flags(chan), AST_FLAG_BLOCKING); ast_channel_unlock(chan); res = ast_senddigit_end(chan, fr->subclass.integer, fr->len); ast_channel_lock(chan); @@ -4699,7 +4674,7 @@ int ast_write(struct ast_channel *chan, struct ast_frame *fr) f = fr; } send_dtmf_event(chan, "Sent", fr->subclass.integer, "Yes", "No"); - ast_clear_flag(chan, AST_FLAG_BLOCKING); + ast_clear_flag(ast_channel_flags(chan), AST_FLAG_BLOCKING); ast_channel_unlock(chan); res = ast_senddigit_begin(chan, fr->subclass.integer); ast_channel_lock(chan); @@ -4715,7 +4690,7 @@ int ast_write(struct ast_channel *chan, struct ast_frame *fr) } } send_dtmf_event(chan, "Sent", fr->subclass.integer, "No", "Yes"); - ast_clear_flag(chan, AST_FLAG_BLOCKING); + ast_clear_flag(ast_channel_flags(chan), AST_FLAG_BLOCKING); ast_channel_unlock(chan); res = ast_senddigit_end(chan, fr->subclass.integer, fr->len); ast_channel_lock(chan); @@ -4908,7 +4883,7 @@ int ast_write(struct ast_channel *chan, struct ast_frame *fr) if (f && f != fr) ast_frfree(f); - ast_clear_flag(chan, AST_FLAG_BLOCKING); + ast_clear_flag(ast_channel_flags(chan), AST_FLAG_BLOCKING); /* Consider a write failure to force a soft hangup */ if (res < 0) { @@ -5208,7 +5183,7 @@ static void handle_cause(int cause, int *outstate) */ static void call_forward_inherit(struct ast_channel *new_chan, struct ast_channel *parent, struct ast_channel *orig) { - if (!ast_test_flag(parent, AST_FLAG_ZOMBIE) && !ast_check_hangup(parent)) { + if (!ast_test_flag(ast_channel_flags(parent), AST_FLAG_ZOMBIE) && !ast_check_hangup(parent)) { struct ast_party_redirecting redirecting; /* @@ -5633,13 +5608,13 @@ int ast_call(struct ast_channel *chan, const char *addr, int timeout) int res = -1; /* Stop if we're a zombie or need a soft hangup */ ast_channel_lock(chan); - if (!ast_test_flag(chan, AST_FLAG_ZOMBIE) && !ast_check_hangup(chan)) { + if (!ast_test_flag(ast_channel_flags(chan), AST_FLAG_ZOMBIE) && !ast_check_hangup(chan)) { if (ast_channel_cdr(chan)) { ast_set_flag(ast_channel_cdr(chan), AST_CDR_FLAG_DIALED); } if (ast_channel_tech(chan)->call) res = ast_channel_tech(chan)->call(chan, addr, timeout); - ast_set_flag(chan, AST_FLAG_OUTGOING); + ast_set_flag(ast_channel_flags(chan), AST_FLAG_OUTGOING); } ast_channel_unlock(chan); return res; @@ -5658,7 +5633,7 @@ int ast_transfer(struct ast_channel *chan, char *dest) /* Stop if we're a zombie or need a soft hangup */ ast_channel_lock(chan); - if (!ast_test_flag(chan, AST_FLAG_ZOMBIE) && !ast_check_hangup(chan)) { + if (!ast_test_flag(ast_channel_flags(chan), AST_FLAG_ZOMBIE) && !ast_check_hangup(chan)) { if (ast_channel_tech(chan)->transfer) { res = ast_channel_tech(chan)->transfer(chan, dest); if (!res) @@ -5714,7 +5689,7 @@ int ast_readstring_full(struct ast_channel *c, char *s, int len, int timeout, in struct ast_silence_generator *silgen = NULL; /* Stop if we're a zombie or need a soft hangup */ - if (ast_test_flag(c, AST_FLAG_ZOMBIE) || ast_check_hangup(c)) + if (ast_test_flag(ast_channel_flags(c), AST_FLAG_ZOMBIE) || ast_check_hangup(c)) return -1; if (!len) return -1; @@ -5870,8 +5845,8 @@ static int __ast_channel_masquerade(struct ast_channel *original, struct ast_cha ast_channel_lock_both(original, clonechan); - if (ast_test_flag(original, AST_FLAG_ZOMBIE) - || ast_test_flag(clonechan, AST_FLAG_ZOMBIE)) { + if (ast_test_flag(ast_channel_flags(original), AST_FLAG_ZOMBIE) + || ast_test_flag(ast_channel_flags(clonechan), AST_FLAG_ZOMBIE)) { /* Zombies! Run! */ ast_log(LOG_WARNING, "Can't setup masquerade. One or both channels is dead. (%s <-- %s)\n", @@ -5886,15 +5861,15 @@ static int __ast_channel_masquerade(struct ast_channel *original, struct ast_cha * (i.e. chan_agent) and if so, we don't really want to * masquerade it, but its proxy */ - if (original->_bridge - && (original->_bridge != ast_bridged_channel(original)) - && (original->_bridge->_bridge != original)) { - final_orig = original->_bridge; + if (ast_channel_internal_bridged_channel(original) + && (ast_channel_internal_bridged_channel(original) != ast_bridged_channel(original)) + && (ast_channel_internal_bridged_channel(ast_channel_internal_bridged_channel(original)) != original)) { + final_orig = ast_channel_internal_bridged_channel(original); } - if (clonechan->_bridge - && (clonechan->_bridge != ast_bridged_channel(clonechan)) - && (clonechan->_bridge->_bridge != clonechan)) { - final_clone = clonechan->_bridge; + if (ast_channel_internal_bridged_channel(clonechan) + && (ast_channel_internal_bridged_channel(clonechan) != ast_bridged_channel(clonechan)) + && (ast_channel_internal_bridged_channel(ast_channel_internal_bridged_channel(clonechan)) != clonechan)) { + final_clone = ast_channel_internal_bridged_channel(clonechan); } if (ast_channel_tech(final_clone)->get_base_channel && (base = ast_channel_tech(final_clone)->get_base_channel(final_clone))) { @@ -5927,8 +5902,8 @@ static int __ast_channel_masquerade(struct ast_channel *original, struct ast_cha original = final_orig; clonechan = final_clone; - if (ast_test_flag(original, AST_FLAG_ZOMBIE) - || ast_test_flag(clonechan, AST_FLAG_ZOMBIE)) { + if (ast_test_flag(ast_channel_flags(original), AST_FLAG_ZOMBIE) + || ast_test_flag(ast_channel_flags(clonechan), AST_FLAG_ZOMBIE)) { /* Zombies! Run! */ ast_log(LOG_WARNING, "Can't setup masquerade. One or both channels is dead. (%s <-- %s)\n", @@ -6263,14 +6238,14 @@ void ast_channel_set_linkgroup(struct ast_channel *chan, struct ast_channel *pee linkedid = oldest_linkedid(ast_channel_linkedid(chan), ast_channel_linkedid(peer)); linkedid = oldest_linkedid(linkedid, ast_channel_uniqueid(chan)); linkedid = oldest_linkedid(linkedid, ast_channel_uniqueid(peer)); - if (chan->_bridge) { + if (ast_channel_internal_bridged_channel(chan)) { bridged = ast_bridged_channel(chan); if (bridged != peer) { linkedid = oldest_linkedid(linkedid, ast_channel_linkedid(bridged)); linkedid = oldest_linkedid(linkedid, ast_channel_uniqueid(bridged)); } } - if (peer->_bridge) { + if (ast_channel_internal_bridged_channel(peer)) { bridged = ast_bridged_channel(peer); if (bridged != chan) { linkedid = oldest_linkedid(linkedid, ast_channel_linkedid(bridged)); @@ -6283,13 +6258,13 @@ void ast_channel_set_linkgroup(struct ast_channel *chan, struct ast_channel *pee ast_channel_change_linkedid(chan, linkedid); ast_channel_change_linkedid(peer, linkedid); - if (chan->_bridge) { + if (ast_channel_internal_bridged_channel(chan)) { bridged = ast_bridged_channel(chan); if (bridged != peer) { ast_channel_change_linkedid(bridged, linkedid); } } - if (peer->_bridge) { + if (ast_channel_internal_bridged_channel(peer)) { bridged = ast_bridged_channel(peer); if (bridged != chan) { ast_channel_change_linkedid(bridged, linkedid); @@ -6684,7 +6659,7 @@ int ast_do_masquerade(struct ast_channel *original) /* XXX What about blocking, softhangup, blocker, and lock and blockproc? XXX */ /* Application and data remain the same */ /* Clone exception becomes real one, as with fdno */ - ast_set_flag(original, ast_test_flag(clonechan, AST_FLAG_EXCEPTION | AST_FLAG_OUTGOING)); + ast_set_flag(ast_channel_flags(original), ast_test_flag(ast_channel_flags(clonechan), AST_FLAG_EXCEPTION | AST_FLAG_OUTGOING)); ast_channel_fdno_set(original, ast_channel_fdno(clonechan)); /* Schedule context remains the same */ /* Stream stuff stays the same */ @@ -6732,9 +6707,9 @@ int ast_do_masquerade(struct ast_channel *original) /* copy over accuntcode and set peeraccount across the bridge */ ast_channel_accountcode_set(original, S_OR(ast_channel_accountcode(clonechan), "")); - if (original->_bridge) { - /* XXX - should we try to lock original->_bridge here? */ - ast_channel_peeraccount_set(original->_bridge, S_OR(ast_channel_accountcode(clonechan), "")); + if (ast_channel_internal_bridged_channel(original)) { + /* XXX - should we try to lock original's bridged channel here? */ + ast_channel_peeraccount_set(ast_channel_internal_bridged_channel(original), S_OR(ast_channel_accountcode(clonechan), "")); ast_cel_report_event(original, AST_CEL_BRIDGE_UPDATE, NULL, NULL, NULL); } @@ -6769,7 +6744,7 @@ int ast_do_masquerade(struct ast_channel *original) /* 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 zombie, then free it now (since it already is considered invalid). */ - if (ast_test_flag(clonechan, AST_FLAG_ZOMBIE)) { + if (ast_test_flag(ast_channel_flags(clonechan), AST_FLAG_ZOMBIE)) { ast_debug(1, "Destroying channel clone '%s'\n", ast_channel_name(clonechan)); ast_channel_unlock(clonechan); ast_manager_event(clonechan, EVENT_FLAG_CALL, "Hangup", @@ -6785,13 +6760,13 @@ int ast_do_masquerade(struct ast_channel *original) clonechan = ast_channel_release(clonechan); } else { ast_debug(1, "Released clone lock on '%s'\n", ast_channel_name(clonechan)); - ast_set_flag(clonechan, AST_FLAG_ZOMBIE); + ast_set_flag(ast_channel_flags(clonechan), AST_FLAG_ZOMBIE); ast_queue_frame(clonechan, &ast_null_frame); } /* Signal any blocker */ - if (ast_test_flag(original, AST_FLAG_BLOCKING)) - pthread_kill(original->blocker, SIGURG); + if (ast_test_flag(ast_channel_flags(original), AST_FLAG_BLOCKING)) + pthread_kill(ast_channel_blocker(original), SIGURG); ast_debug(1, "Done Masquerading %s (%d)\n", ast_channel_name(original), ast_channel_state(original)); if ((bridged = ast_bridged_channel(original))) { @@ -6942,7 +6917,7 @@ int ast_setstate(struct ast_channel *chan, enum ast_channel_state state) struct ast_channel *ast_bridged_channel(struct ast_channel *chan) { struct ast_channel *bridged; - bridged = chan->_bridge; + bridged = ast_channel_internal_bridged_channel(chan); if (bridged && ast_channel_tech(bridged)->bridged_channel) bridged = ast_channel_tech(bridged)->bridged_channel(chan, bridged); return bridged; @@ -7086,8 +7061,8 @@ static enum ast_bridge_result ast_generic_bridge(struct ast_channel *c0, struct if (ast_channel_softhangup_internal_flag(c1) & AST_SOFTHANGUP_UNBRIDGE) { ast_channel_clear_softhangup(c1, AST_SOFTHANGUP_UNBRIDGE); } - c0->_bridge = c1; - c1->_bridge = c0; + ast_channel_internal_bridged_channel_set(c0, c1); + ast_channel_internal_bridged_channel_set(c1, c0); } continue; } @@ -7307,20 +7282,20 @@ enum ast_bridge_result ast_channel_bridge(struct ast_channel *c0, struct ast_cha *fo = NULL; - if (c0->_bridge) { + if (ast_channel_internal_bridged_channel(c0)) { ast_log(LOG_WARNING, "%s is already in a bridge with %s\n", - ast_channel_name(c0), ast_channel_name(c0->_bridge)); + ast_channel_name(c0), ast_channel_name(ast_channel_internal_bridged_channel(c0))); return -1; } - if (c1->_bridge) { + if (ast_channel_internal_bridged_channel(c1)) { ast_log(LOG_WARNING, "%s is already in a bridge with %s\n", - ast_channel_name(c1), ast_channel_name(c1->_bridge)); + ast_channel_name(c1), ast_channel_name(ast_channel_internal_bridged_channel(c1))); return -1; } /* Stop if we're a zombie or need a soft hangup */ - if (ast_test_flag(c0, AST_FLAG_ZOMBIE) || ast_check_hangup_locked(c0) || - ast_test_flag(c1, AST_FLAG_ZOMBIE) || ast_check_hangup_locked(c1)) + if (ast_test_flag(ast_channel_flags(c0), AST_FLAG_ZOMBIE) || ast_check_hangup_locked(c0) || + ast_test_flag(ast_channel_flags(c1), AST_FLAG_ZOMBIE) || ast_check_hangup_locked(c1)) return -1; o0nativeformats = ast_format_cap_dup(ast_channel_nativeformats(c0)); @@ -7348,8 +7323,8 @@ enum ast_bridge_result ast_channel_bridge(struct ast_channel *c0, struct ast_cha } /* Keep track of bridge */ - c0->_bridge = c1; - c1->_bridge = c0; + ast_channel_internal_bridged_channel_set(c0, c1); + ast_channel_internal_bridged_channel_set(c1, c0); ast_set_owners_and_peers(c0, c1); @@ -7375,9 +7350,9 @@ enum ast_bridge_result ast_channel_bridge(struct ast_channel *c0, struct ast_cha } if (!ast_channel_tech(c0)->send_digit_begin) - ast_set_flag(c1, AST_FLAG_END_DTMF_ONLY); + ast_set_flag(ast_channel_flags(c1), AST_FLAG_END_DTMF_ONLY); if (!ast_channel_tech(c1)->send_digit_begin) - ast_set_flag(c0, AST_FLAG_END_DTMF_ONLY); + ast_set_flag(ast_channel_flags(c0), AST_FLAG_END_DTMF_ONLY); manager_bridge_event(1, 1, c0, c1); /* Before we enter in and bridge these two together tell them both the source of audio has changed */ @@ -7442,22 +7417,22 @@ enum ast_bridge_result ast_channel_bridge(struct ast_channel *c0, struct ast_cha if (ast_channel_softhangup_internal_flag(c1) & AST_SOFTHANGUP_UNBRIDGE) { ast_channel_clear_softhangup(c1, AST_SOFTHANGUP_UNBRIDGE); } - c0->_bridge = c1; - c1->_bridge = c0; + ast_channel_internal_bridged_channel_set(c0, c1); + ast_channel_internal_bridged_channel_set(c1, c0); ast_debug(1, "Unbridge signal received. Ending native bridge.\n"); continue; } /* Stop if we're a zombie or need a soft hangup */ - if (ast_test_flag(c0, AST_FLAG_ZOMBIE) || ast_check_hangup_locked(c0) || - ast_test_flag(c1, AST_FLAG_ZOMBIE) || ast_check_hangup_locked(c1)) { + if (ast_test_flag(ast_channel_flags(c0), AST_FLAG_ZOMBIE) || ast_check_hangup_locked(c0) || + ast_test_flag(ast_channel_flags(c1), AST_FLAG_ZOMBIE) || ast_check_hangup_locked(c1)) { *fo = NULL; res = 0; ast_debug(1, "Bridge stops because we're zombie or need a soft hangup: c0=%s, c1=%s, flags: %s,%s,%s,%s\n", ast_channel_name(c0), ast_channel_name(c1), - ast_test_flag(c0, AST_FLAG_ZOMBIE) ? "Yes" : "No", + ast_test_flag(ast_channel_flags(c0), AST_FLAG_ZOMBIE) ? "Yes" : "No", ast_check_hangup(c0) ? "Yes" : "No", - ast_test_flag(c1, AST_FLAG_ZOMBIE) ? "Yes" : "No", + ast_test_flag(ast_channel_flags(c1), AST_FLAG_ZOMBIE) ? "Yes" : "No", ast_check_hangup(c1) ? "Yes" : "No"); break; } @@ -7476,27 +7451,27 @@ enum ast_bridge_result ast_channel_bridge(struct ast_channel *c0, struct ast_cha !ast_channel_masq(c0) && !ast_channel_masqr(c0) && !ast_channel_masq(c1) && !ast_channel_masqr(c1)) { int timeoutms = to - 1000 > 0 ? to - 1000 : to; /* Looks like they share a bridge method and nothing else is in the way */ - ast_set_flag(c0, AST_FLAG_NBRIDGE); - ast_set_flag(c1, AST_FLAG_NBRIDGE); + ast_set_flag(ast_channel_flags(c0), AST_FLAG_NBRIDGE); + ast_set_flag(ast_channel_flags(c1), AST_FLAG_NBRIDGE); if ((res = ast_channel_tech(c0)->bridge(c0, c1, config->flags, fo, rc, timeoutms)) == AST_BRIDGE_COMPLETE) { manager_bridge_event(0, 1, c0, c1); ast_debug(1, "Returning from native bridge, channels: %s, %s\n", ast_channel_name(c0), ast_channel_name(c1)); - ast_clear_flag(c0, AST_FLAG_NBRIDGE); - ast_clear_flag(c1, AST_FLAG_NBRIDGE); + ast_clear_flag(ast_channel_flags(c0), AST_FLAG_NBRIDGE); + ast_clear_flag(ast_channel_flags(c1), AST_FLAG_NBRIDGE); if ((ast_channel_softhangup_internal_flag(c0) | ast_channel_softhangup_internal_flag(c1)) & AST_SOFTHANGUP_UNBRIDGE) {/* Bit operators are intentional. */ continue; } - c0->_bridge = NULL; - c1->_bridge = NULL; + ast_channel_internal_bridged_channel_set(c0, NULL); + ast_channel_internal_bridged_channel_set(c1, NULL); ast_format_cap_destroy(o0nativeformats); ast_format_cap_destroy(o1nativeformats); return res; } else { - ast_clear_flag(c0, AST_FLAG_NBRIDGE); - ast_clear_flag(c1, AST_FLAG_NBRIDGE); + ast_clear_flag(ast_channel_flags(c0), AST_FLAG_NBRIDGE); + ast_clear_flag(ast_channel_flags(c1), AST_FLAG_NBRIDGE); } switch (res) { case AST_BRIDGE_RETRY: @@ -7540,15 +7515,15 @@ enum ast_bridge_result ast_channel_bridge(struct ast_channel *c0, struct ast_cha } } - ast_clear_flag(c0, AST_FLAG_END_DTMF_ONLY); - ast_clear_flag(c1, AST_FLAG_END_DTMF_ONLY); + ast_clear_flag(ast_channel_flags(c0), AST_FLAG_END_DTMF_ONLY); + ast_clear_flag(ast_channel_flags(c1), AST_FLAG_END_DTMF_ONLY); /* Now that we have broken the bridge the source will change yet again */ ast_indicate(c0, AST_CONTROL_SRCUPDATE); ast_indicate(c1, AST_CONTROL_SRCUPDATE); - c0->_bridge = NULL; - c1->_bridge = NULL; + ast_channel_internal_bridged_channel_set(c0, NULL); + ast_channel_internal_bridged_channel_set(c1, NULL); manager_bridge_event(0, 1, c0, c1); ast_debug(1, "Bridge stops bridging channels %s and %s\n", ast_channel_name(c0), ast_channel_name(c1)); @@ -7658,7 +7633,7 @@ static void *tonepair_alloc(struct ast_channel *chan, void *params) ts->modulate = 0; } /* Let interrupts interrupt :) */ - ast_set_flag(chan, AST_FLAG_WRITE_INT); + ast_set_flag(ast_channel_flags(chan), AST_FLAG_WRITE_INT); return ts; } diff --git a/main/channel_internal_api.c b/main/channel_internal_api.c index 0a7060e29e..4f89ca7886 100644 --- a/main/channel_internal_api.c +++ b/main/channel_internal_api.c @@ -38,6 +38,154 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$") #include "asterisk/stringfields.h" #include "asterisk/data.h" #include "asterisk/indications.h" +#include "asterisk/channel_internal.h" + +/*! + * \brief Main Channel structure associated with a channel. + * + * \note XXX It is important to remember to increment .cleancount each time + * this structure is changed. XXX + * + * \note When adding fields to this structure, it is important to add the field + * 'in position' with like-aligned fields, so as to keep the compiler from + * having to add padding to align fields. The structure's fields are sorted + * in this order: pointers, structures, long, int/enum, short, char. This + * is especially important on 64-bit architectures, where mixing 4-byte + * and 8-byte fields causes 4 bytes of padding to be added before many + * 8-byte fields. + */ +struct ast_channel { + const struct ast_channel_tech *tech; /*!< Technology (point to channel driver) */ + void *tech_pvt; /*!< Private data used by the technology driver */ + void *music_state; /*!< Music State*/ + void *generatordata; /*!< Current generator data if there is any */ + struct ast_generator *generator; /*!< Current active data generator */ + struct ast_channel * bridged_channel; /*!< Who are we bridged to, if we're bridged. + * Who is proxying for us, if we are proxied (i.e. chan_agent). + * Do not access directly, use ast_bridged_channel(chan) */ + struct ast_channel *masq; /*!< Channel that will masquerade as us */ + struct ast_channel *masqr; /*!< Who we are masquerading as */ + const char *blockproc; /*!< Procedure causing blocking */ + const char *appl; /*!< Current application */ + const char *data; /*!< Data passed to current application */ + struct ast_sched_context *sched; /*!< Schedule context */ + struct ast_filestream *stream; /*!< Stream itself. */ + struct ast_filestream *vstream; /*!< Video Stream itself. */ + ast_timing_func_t timingfunc; + void *timingdata; + struct ast_pbx *pbx; /*!< PBX private structure for this channel */ + struct ast_trans_pvt *writetrans; /*!< Write translation path */ + struct ast_trans_pvt *readtrans; /*!< Read translation path */ + struct ast_audiohook_list *audiohooks; + struct ast_framehook_list *framehooks; + struct ast_cdr *cdr; /*!< Call Detail Record */ + struct ast_tone_zone *zone; /*!< Tone zone as set in indications.conf or + * in the CHANNEL dialplan function */ + struct ast_channel_monitor *monitor; /*!< Channel monitoring */ +#ifdef HAVE_EPOLL + struct ast_epoll_data *epfd_data[AST_MAX_FDS]; +#endif + + AST_DECLARE_STRING_FIELDS( + AST_STRING_FIELD(name); /*!< ASCII unique channel name */ + AST_STRING_FIELD(language); /*!< Language requested for voice prompts */ + AST_STRING_FIELD(musicclass); /*!< Default music class */ + AST_STRING_FIELD(accountcode); /*!< Account code for billing */ + AST_STRING_FIELD(peeraccount); /*!< Peer account code for billing */ + AST_STRING_FIELD(userfield); /*!< Userfield for CEL billing */ + AST_STRING_FIELD(call_forward); /*!< Where to forward to if asked to dial on this interface */ + AST_STRING_FIELD(uniqueid); /*!< Unique Channel Identifier */ + AST_STRING_FIELD(linkedid); /*!< Linked Channel Identifier -- gets propagated by linkage */ + AST_STRING_FIELD(parkinglot); /*! Default parking lot, if empty, default parking lot */ + AST_STRING_FIELD(hangupsource); /*! Who is responsible for hanging up this channel */ + AST_STRING_FIELD(dialcontext); /*!< Dial: Extension context that we were called from */ + ); + + struct timeval whentohangup; /*!< Non-zero, set to actual time when channel is to be hung up */ + pthread_t blocker; /*!< If anyone is blocking, this is them */ + + /*! + * \brief Dialed/Called information. + * \note Set on incoming channels to indicate the originally dialed party. + * \note Dialed Number Identifier (DNID) + */ + struct ast_party_dialed dialed; + + /*! + * \brief Channel Caller ID information. + * \note The caller id information is the caller id of this + * channel when it is used to initiate a call. + */ + struct ast_party_caller caller; + + /*! + * \brief Channel Connected Line ID information. + * \note The connected line information identifies the channel + * connected/bridged to this channel. + */ + struct ast_party_connected_line connected; + + /*! \brief Redirecting/Diversion information */ + struct ast_party_redirecting redirecting; + + struct ast_frame dtmff; /*!< DTMF frame */ + struct varshead varshead; /*!< A linked list for channel variables. See \ref AstChanVar */ + ast_group_t callgroup; /*!< Call group for call pickups */ + ast_group_t pickupgroup; /*!< Pickup group - which calls groups can be picked up? */ + struct ast_readq_list readq; + struct ast_jb jb; /*!< The jitterbuffer state */ + struct timeval dtmf_tv; /*!< The time that an in process digit began, or the last digit ended */ + struct ast_datastore_list datastores; /*!< Data stores on the channel */ + struct ast_autochan_list autochans; /*!< Autochans on the channel */ + unsigned long insmpl; /*!< Track the read/written samples for monitor use */ + unsigned long outsmpl; /*!< Track the read/written samples for monitor use */ + + int fds[AST_MAX_FDS]; /*!< File descriptors for channel -- Drivers will poll on + * these file descriptors, so at least one must be non -1. + * See \arg \ref AstFileDesc */ + int softhangup; /*!< Whether or not we have been hung up... Do not set this value + * directly, use ast_softhangup() */ + int fdno; /*!< Which fd had an event detected on */ + int streamid; /*!< For streaming playback, the schedule ID */ + int vstreamid; /*!< For streaming video playback, the schedule ID */ + struct ast_format oldwriteformat; /*!< Original writer format */ + int timingfd; /*!< Timing fd */ + enum ast_channel_state state; /*!< State of line -- Don't write directly, use ast_setstate() */ + int rings; /*!< Number of rings so far */ + int priority; /*!< Dialplan: Current extension priority */ + int macropriority; /*!< Macro: Current non-macro priority. See app_macro.c */ + int amaflags; /*!< Set BEFORE PBX is started to determine AMA flags */ + enum ast_channel_adsicpe adsicpe; /*!< Whether or not ADSI is detected on CPE */ + unsigned int fin; /*!< Frames in counters. The high bit is a debug mask, so + * the counter is only in the remaining bits */ + unsigned int fout; /*!< Frames out counters. The high bit is a debug mask, so + * the counter is only in the remaining bits */ + int hangupcause; /*!< Why is the channel hanged up. See causes.h */ + unsigned int finalized:1; /*!< Whether or not the channel has been successfully allocated */ + struct ast_flags flags; /*!< channel flags of AST_FLAG_ type */ + int alertpipe[2]; + struct ast_format_cap *nativeformats; /*!< Kinds of data this channel can natively handle */ + struct ast_format readformat; /*!< Requested read format (after translation) */ + struct ast_format writeformat; /*!< Requested write format (after translation) */ + struct ast_format rawreadformat; /*!< Raw read format (before translation) */ + struct ast_format rawwriteformat; /*!< Raw write format (before translation) */ + unsigned int emulate_dtmf_duration; /*!< Number of ms left to emulate DTMF for */ +#ifdef HAVE_EPOLL + int epfd; +#endif + int visible_indication; /*!< Indication currently playing on the channel */ + + unsigned short transfercapability; /*!< ISDN Transfer Capability - AST_FLAG_DIGITAL is not enough */ + + struct ast_bridge *bridge; /*!< Bridge this channel is participating in */ + struct ast_timer *timer; /*!< timer object that provided timingfd */ + + char context[AST_MAX_CONTEXT]; /*!< Dialplan: Current extension context */ + char exten[AST_MAX_EXTENSION]; /*!< Dialplan: Current extension number */ + char macrocontext[AST_MAX_CONTEXT]; /*!< Macro: Current non-macro context. See app_macro.c */ + char macroexten[AST_MAX_EXTENSION]; /*!< Macro: Current non-macro extension. See app_macro.c */ + char dtmf_digit_to_emulate; /*!< Digit being emulated */ +}; /* AST_DATA definitions, which will probably have to be re-thought since the channel will be opaque */ @@ -55,57 +203,57 @@ AST_DATA_STRUCTURE(ast_callerid, DATA_EXPORT_CALLERID); #endif #define DATA_EXPORT_CHANNEL(MEMBER) \ - MEMBER(ast_channel, __do_not_use_blockproc, AST_DATA_STRING) \ - MEMBER(ast_channel, __do_not_use_appl, AST_DATA_STRING) \ - MEMBER(ast_channel, __do_not_use_data, AST_DATA_STRING) \ - MEMBER(ast_channel, __do_not_use_name, AST_DATA_STRING) \ - MEMBER(ast_channel, __do_not_use_language, AST_DATA_STRING) \ - MEMBER(ast_channel, __do_not_use_musicclass, AST_DATA_STRING) \ - MEMBER(ast_channel, __do_not_use_accountcode, AST_DATA_STRING) \ - MEMBER(ast_channel, __do_not_use_peeraccount, AST_DATA_STRING) \ - MEMBER(ast_channel, __do_not_use_userfield, AST_DATA_STRING) \ - MEMBER(ast_channel, __do_not_use_call_forward, AST_DATA_STRING) \ - MEMBER(ast_channel, __do_not_use_uniqueid, AST_DATA_STRING) \ - MEMBER(ast_channel, __do_not_use_linkedid, AST_DATA_STRING) \ - MEMBER(ast_channel, __do_not_use_parkinglot, AST_DATA_STRING) \ - MEMBER(ast_channel, __do_not_use_hangupsource, AST_DATA_STRING) \ - MEMBER(ast_channel, __do_not_use_dialcontext, AST_DATA_STRING) \ - MEMBER(ast_channel, __do_not_use_rings, AST_DATA_INTEGER) \ - MEMBER(ast_channel, __do_not_use_priority, AST_DATA_INTEGER) \ - MEMBER(ast_channel, __do_not_use_macropriority, AST_DATA_INTEGER) \ - MEMBER(ast_channel, __do_not_use_adsicpe, AST_DATA_INTEGER) \ - MEMBER(ast_channel, __do_not_use_fin, AST_DATA_UNSIGNED_INTEGER) \ - MEMBER(ast_channel, __do_not_use_fout, AST_DATA_UNSIGNED_INTEGER) \ - MEMBER(ast_channel, __do_not_use_emulate_dtmf_duration, AST_DATA_UNSIGNED_INTEGER) \ - MEMBER(ast_channel, __do_not_use_visible_indication, AST_DATA_INTEGER) \ - MEMBER(ast_channel, __do_not_use_context, AST_DATA_STRING) \ - MEMBER(ast_channel, __do_not_use_exten, AST_DATA_STRING) \ - MEMBER(ast_channel, __do_not_use_macrocontext, AST_DATA_STRING) \ - MEMBER(ast_channel, __do_not_use_macroexten, AST_DATA_STRING) + MEMBER(ast_channel, blockproc, AST_DATA_STRING) \ + MEMBER(ast_channel, appl, AST_DATA_STRING) \ + MEMBER(ast_channel, data, AST_DATA_STRING) \ + MEMBER(ast_channel, name, AST_DATA_STRING) \ + MEMBER(ast_channel, language, AST_DATA_STRING) \ + MEMBER(ast_channel, musicclass, AST_DATA_STRING) \ + MEMBER(ast_channel, accountcode, AST_DATA_STRING) \ + MEMBER(ast_channel, peeraccount, AST_DATA_STRING) \ + MEMBER(ast_channel, userfield, AST_DATA_STRING) \ + MEMBER(ast_channel, call_forward, AST_DATA_STRING) \ + MEMBER(ast_channel, uniqueid, AST_DATA_STRING) \ + MEMBER(ast_channel, linkedid, AST_DATA_STRING) \ + MEMBER(ast_channel, parkinglot, AST_DATA_STRING) \ + MEMBER(ast_channel, hangupsource, AST_DATA_STRING) \ + MEMBER(ast_channel, dialcontext, AST_DATA_STRING) \ + MEMBER(ast_channel, rings, AST_DATA_INTEGER) \ + MEMBER(ast_channel, priority, AST_DATA_INTEGER) \ + MEMBER(ast_channel, macropriority, AST_DATA_INTEGER) \ + MEMBER(ast_channel, adsicpe, AST_DATA_INTEGER) \ + MEMBER(ast_channel, fin, AST_DATA_UNSIGNED_INTEGER) \ + MEMBER(ast_channel, fout, AST_DATA_UNSIGNED_INTEGER) \ + MEMBER(ast_channel, emulate_dtmf_duration, AST_DATA_UNSIGNED_INTEGER) \ + MEMBER(ast_channel, visible_indication, AST_DATA_INTEGER) \ + MEMBER(ast_channel, context, AST_DATA_STRING) \ + MEMBER(ast_channel, exten, AST_DATA_STRING) \ + MEMBER(ast_channel, macrocontext, AST_DATA_STRING) \ + MEMBER(ast_channel, macroexten, AST_DATA_STRING) AST_DATA_STRUCTURE(ast_channel, DATA_EXPORT_CHANNEL); static void channel_data_add_flags(struct ast_data *tree, struct ast_channel *chan) { - ast_data_add_bool(tree, "DEFER_DTMF", ast_test_flag(chan, AST_FLAG_DEFER_DTMF)); - ast_data_add_bool(tree, "WRITE_INT", ast_test_flag(chan, AST_FLAG_WRITE_INT)); - ast_data_add_bool(tree, "BLOCKING", ast_test_flag(chan, AST_FLAG_BLOCKING)); - ast_data_add_bool(tree, "ZOMBIE", ast_test_flag(chan, AST_FLAG_ZOMBIE)); - ast_data_add_bool(tree, "EXCEPTION", ast_test_flag(chan, AST_FLAG_EXCEPTION)); - ast_data_add_bool(tree, "MOH", ast_test_flag(chan, AST_FLAG_MOH)); - ast_data_add_bool(tree, "SPYING", ast_test_flag(chan, AST_FLAG_SPYING)); - ast_data_add_bool(tree, "NBRIDGE", ast_test_flag(chan, AST_FLAG_NBRIDGE)); - ast_data_add_bool(tree, "IN_AUTOLOOP", ast_test_flag(chan, AST_FLAG_IN_AUTOLOOP)); - ast_data_add_bool(tree, "OUTGOING", ast_test_flag(chan, AST_FLAG_OUTGOING)); - ast_data_add_bool(tree, "IN_DTMF", ast_test_flag(chan, AST_FLAG_IN_DTMF)); - ast_data_add_bool(tree, "EMULATE_DTMF", ast_test_flag(chan, AST_FLAG_EMULATE_DTMF)); - ast_data_add_bool(tree, "END_DTMF_ONLY", ast_test_flag(chan, AST_FLAG_END_DTMF_ONLY)); - ast_data_add_bool(tree, "ANSWERED_ELSEWHERE", ast_test_flag(chan, AST_FLAG_ANSWERED_ELSEWHERE)); - ast_data_add_bool(tree, "MASQ_NOSTREAM", ast_test_flag(chan, AST_FLAG_MASQ_NOSTREAM)); - ast_data_add_bool(tree, "BRIDGE_HANGUP_RUN", ast_test_flag(chan, AST_FLAG_BRIDGE_HANGUP_RUN)); - ast_data_add_bool(tree, "BRIDGE_HANGUP_DONT", ast_test_flag(chan, AST_FLAG_BRIDGE_HANGUP_DONT)); - ast_data_add_bool(tree, "DISABLE_WORKAROUNDS", ast_test_flag(chan, AST_FLAG_DISABLE_WORKAROUNDS)); + ast_data_add_bool(tree, "DEFER_DTMF", ast_test_flag(ast_channel_flags(chan), AST_FLAG_DEFER_DTMF)); + ast_data_add_bool(tree, "WRITE_INT", ast_test_flag(ast_channel_flags(chan), AST_FLAG_WRITE_INT)); + ast_data_add_bool(tree, "BLOCKING", ast_test_flag(ast_channel_flags(chan), AST_FLAG_BLOCKING)); + ast_data_add_bool(tree, "ZOMBIE", ast_test_flag(ast_channel_flags(chan), AST_FLAG_ZOMBIE)); + ast_data_add_bool(tree, "EXCEPTION", ast_test_flag(ast_channel_flags(chan), AST_FLAG_EXCEPTION)); + ast_data_add_bool(tree, "MOH", ast_test_flag(ast_channel_flags(chan), AST_FLAG_MOH)); + ast_data_add_bool(tree, "SPYING", ast_test_flag(ast_channel_flags(chan), AST_FLAG_SPYING)); + ast_data_add_bool(tree, "NBRIDGE", ast_test_flag(ast_channel_flags(chan), AST_FLAG_NBRIDGE)); + ast_data_add_bool(tree, "IN_AUTOLOOP", ast_test_flag(ast_channel_flags(chan), AST_FLAG_IN_AUTOLOOP)); + ast_data_add_bool(tree, "OUTGOING", ast_test_flag(ast_channel_flags(chan), AST_FLAG_OUTGOING)); + ast_data_add_bool(tree, "IN_DTMF", ast_test_flag(ast_channel_flags(chan), AST_FLAG_IN_DTMF)); + ast_data_add_bool(tree, "EMULATE_DTMF", ast_test_flag(ast_channel_flags(chan), AST_FLAG_EMULATE_DTMF)); + ast_data_add_bool(tree, "END_DTMF_ONLY", ast_test_flag(ast_channel_flags(chan), AST_FLAG_END_DTMF_ONLY)); + ast_data_add_bool(tree, "ANSWERED_ELSEWHERE", ast_test_flag(ast_channel_flags(chan), AST_FLAG_ANSWERED_ELSEWHERE)); + ast_data_add_bool(tree, "MASQ_NOSTREAM", ast_test_flag(ast_channel_flags(chan), AST_FLAG_MASQ_NOSTREAM)); + ast_data_add_bool(tree, "BRIDGE_HANGUP_RUN", ast_test_flag(ast_channel_flags(chan), AST_FLAG_BRIDGE_HANGUP_RUN)); + ast_data_add_bool(tree, "BRIDGE_HANGUP_DONT", ast_test_flag(ast_channel_flags(chan), AST_FLAG_BRIDGE_HANGUP_DONT)); + ast_data_add_bool(tree, "DISABLE_WORKAROUNDS", ast_test_flag(ast_channel_flags(chan), AST_FLAG_DISABLE_WORKAROUNDS)); } int ast_channel_data_add_structure(struct ast_data *tree, @@ -251,12 +399,12 @@ int ast_channel_data_cmp_structure(const struct ast_data_search *tree, #define DEFINE_STRINGFIELD_SETTERS_FOR(field) \ void ast_channel_##field##_set(struct ast_channel *chan, const char *value) \ { \ - ast_string_field_set(chan, __do_not_use_##field, value); \ + ast_string_field_set(chan, field, value); \ } \ \ void ast_channel_##field##_build_va(struct ast_channel *chan, const char *fmt, va_list ap) \ { \ - ast_string_field_build_va(chan, __do_not_use_##field, fmt, ap); \ + ast_string_field_build_va(chan, field, fmt, ap); \ } \ void ast_channel_##field##_build(struct ast_channel *chan, const char *fmt, ...) \ { \ @@ -266,573 +414,571 @@ void ast_channel_##field##_build(struct ast_channel *chan, const char *fmt, ...) va_end(ap); \ } -DEFINE_STRINGFIELD_SETTERS_FOR(name) -DEFINE_STRINGFIELD_SETTERS_FOR(language) -DEFINE_STRINGFIELD_SETTERS_FOR(musicclass) -DEFINE_STRINGFIELD_SETTERS_FOR(accountcode) -DEFINE_STRINGFIELD_SETTERS_FOR(peeraccount) -DEFINE_STRINGFIELD_SETTERS_FOR(userfield) -DEFINE_STRINGFIELD_SETTERS_FOR(call_forward) -DEFINE_STRINGFIELD_SETTERS_FOR(uniqueid) -DEFINE_STRINGFIELD_SETTERS_FOR(linkedid) -DEFINE_STRINGFIELD_SETTERS_FOR(parkinglot) -DEFINE_STRINGFIELD_SETTERS_FOR(hangupsource) -DEFINE_STRINGFIELD_SETTERS_FOR(dialcontext) +DEFINE_STRINGFIELD_SETTERS_FOR(name); +DEFINE_STRINGFIELD_SETTERS_FOR(language); +DEFINE_STRINGFIELD_SETTERS_FOR(musicclass); +DEFINE_STRINGFIELD_SETTERS_FOR(accountcode); +DEFINE_STRINGFIELD_SETTERS_FOR(peeraccount); +DEFINE_STRINGFIELD_SETTERS_FOR(userfield); +DEFINE_STRINGFIELD_SETTERS_FOR(call_forward); +DEFINE_STRINGFIELD_SETTERS_FOR(uniqueid); +DEFINE_STRINGFIELD_SETTERS_FOR(linkedid); +DEFINE_STRINGFIELD_SETTERS_FOR(parkinglot); +DEFINE_STRINGFIELD_SETTERS_FOR(hangupsource); +DEFINE_STRINGFIELD_SETTERS_FOR(dialcontext); #define DEFINE_STRINGFIELD_GETTER_FOR(field) const char *ast_channel_##field(const struct ast_channel *chan) \ { \ - return chan->__do_not_use_##field; \ -} - -DEFINE_STRINGFIELD_GETTER_FOR(name) -DEFINE_STRINGFIELD_GETTER_FOR(language) -DEFINE_STRINGFIELD_GETTER_FOR(musicclass) -DEFINE_STRINGFIELD_GETTER_FOR(accountcode) -DEFINE_STRINGFIELD_GETTER_FOR(peeraccount) -DEFINE_STRINGFIELD_GETTER_FOR(userfield) -DEFINE_STRINGFIELD_GETTER_FOR(call_forward) -DEFINE_STRINGFIELD_GETTER_FOR(uniqueid) -DEFINE_STRINGFIELD_GETTER_FOR(linkedid) -DEFINE_STRINGFIELD_GETTER_FOR(parkinglot) -DEFINE_STRINGFIELD_GETTER_FOR(hangupsource) -DEFINE_STRINGFIELD_GETTER_FOR(dialcontext) + return chan->field; \ +} + +DEFINE_STRINGFIELD_GETTER_FOR(name); +DEFINE_STRINGFIELD_GETTER_FOR(language); +DEFINE_STRINGFIELD_GETTER_FOR(musicclass); +DEFINE_STRINGFIELD_GETTER_FOR(accountcode); +DEFINE_STRINGFIELD_GETTER_FOR(peeraccount); +DEFINE_STRINGFIELD_GETTER_FOR(userfield); +DEFINE_STRINGFIELD_GETTER_FOR(call_forward); +DEFINE_STRINGFIELD_GETTER_FOR(uniqueid); +DEFINE_STRINGFIELD_GETTER_FOR(linkedid); +DEFINE_STRINGFIELD_GETTER_FOR(parkinglot); +DEFINE_STRINGFIELD_GETTER_FOR(hangupsource); +DEFINE_STRINGFIELD_GETTER_FOR(dialcontext); const char *ast_channel_appl(const struct ast_channel *chan) { - return chan->__do_not_use_appl; + return chan->appl; } void ast_channel_appl_set(struct ast_channel *chan, const char *value) { - chan->__do_not_use_appl = value; + chan->appl = value; } const char *ast_channel_blockproc(const struct ast_channel *chan) { - return chan->__do_not_use_blockproc; + return chan->blockproc; } void ast_channel_blockproc_set(struct ast_channel *chan, const char *value) { - chan->__do_not_use_blockproc = value; + chan->blockproc = value; } const char *ast_channel_data(const struct ast_channel *chan) { - return chan->__do_not_use_data; + return chan->data; } void ast_channel_data_set(struct ast_channel *chan, const char *value) { - chan->__do_not_use_data = value; + chan->data = value; } - const char *ast_channel_context(const struct ast_channel *chan) { - return chan->__do_not_use_context; + return chan->context; } void ast_channel_context_set(struct ast_channel *chan, const char *value) { - ast_copy_string(chan->__do_not_use_context, value, sizeof(chan->__do_not_use_context)); + ast_copy_string(chan->context, value, sizeof(chan->context)); } const char *ast_channel_exten(const struct ast_channel *chan) { - return chan->__do_not_use_exten; + return chan->exten; } void ast_channel_exten_set(struct ast_channel *chan, const char *value) { - ast_copy_string(chan->__do_not_use_exten, value, sizeof(chan->__do_not_use_exten)); + ast_copy_string(chan->exten, value, sizeof(chan->exten)); } const char *ast_channel_macrocontext(const struct ast_channel *chan) { - return chan->__do_not_use_macrocontext; + return chan->macrocontext; } void ast_channel_macrocontext_set(struct ast_channel *chan, const char *value) { - ast_copy_string(chan->__do_not_use_macrocontext, value, sizeof(chan->__do_not_use_macrocontext)); + ast_copy_string(chan->macrocontext, value, sizeof(chan->macrocontext)); } const char *ast_channel_macroexten(const struct ast_channel *chan) { - return chan->__do_not_use_macroexten; + return chan->macroexten; } void ast_channel_macroexten_set(struct ast_channel *chan, const char *value) { - ast_copy_string(chan->__do_not_use_macroexten, value, sizeof(chan->__do_not_use_macroexten)); + ast_copy_string(chan->macroexten, value, sizeof(chan->macroexten)); } - char ast_channel_dtmf_digit_to_emulate(const struct ast_channel *chan) { - return chan->__do_not_use_dtmf_digit_to_emulate; + return chan->dtmf_digit_to_emulate; } void ast_channel_dtmf_digit_to_emulate_set(struct ast_channel *chan, char value) { - chan->__do_not_use_dtmf_digit_to_emulate = value; + chan->dtmf_digit_to_emulate = value; } int ast_channel_amaflags(const struct ast_channel *chan) { - return chan->__do_not_use_amaflags; + return chan->amaflags; } void ast_channel_amaflags_set(struct ast_channel *chan, int value) { - chan->__do_not_use_amaflags = value; + chan->amaflags = value; } #ifdef HAVE_EPOLL int ast_channel_epfd(const struct ast_channel *chan) { - return chan->__do_not_use_epfd; + return chan->epfd; } void ast_channel_epfd_set(struct ast_channel *chan, int value) { - chan->__do_not_use_epfd = value; + chan->epfd = value; } #endif int ast_channel_fdno(const struct ast_channel *chan) { - return chan->__do_not_use_fdno; + return chan->fdno; } void ast_channel_fdno_set(struct ast_channel *chan, int value) { - chan->__do_not_use_fdno = value; + chan->fdno = value; } int ast_channel_hangupcause(const struct ast_channel *chan) { - return chan->__do_not_use_hangupcause; + return chan->hangupcause; } void ast_channel_hangupcause_set(struct ast_channel *chan, int value) { - chan->__do_not_use_hangupcause = value; + chan->hangupcause = value; } int ast_channel_macropriority(const struct ast_channel *chan) { - return chan->__do_not_use_macropriority; + return chan->macropriority; } void ast_channel_macropriority_set(struct ast_channel *chan, int value) { - chan->__do_not_use_macropriority = value; + chan->macropriority = value; } int ast_channel_priority(const struct ast_channel *chan) { - return chan->__do_not_use_priority; + return chan->priority; } void ast_channel_priority_set(struct ast_channel *chan, int value) { - chan->__do_not_use_priority = value; + chan->priority = value; } int ast_channel_rings(const struct ast_channel *chan) { - return chan->__do_not_use_rings; + return chan->rings; } void ast_channel_rings_set(struct ast_channel *chan, int value) { - chan->__do_not_use_rings = value; + chan->rings = value; } int ast_channel_streamid(const struct ast_channel *chan) { - return chan->__do_not_use_streamid; + return chan->streamid; } void ast_channel_streamid_set(struct ast_channel *chan, int value) { - chan->__do_not_use_streamid = value; + chan->streamid = value; } int ast_channel_timingfd(const struct ast_channel *chan) { - return chan->__do_not_use_timingfd; + return chan->timingfd; } void ast_channel_timingfd_set(struct ast_channel *chan, int value) { - chan->__do_not_use_timingfd = value; + chan->timingfd = value; } int ast_channel_visible_indication(const struct ast_channel *chan) { - return chan->__do_not_use_visible_indication; + return chan->visible_indication; } void ast_channel_visible_indication_set(struct ast_channel *chan, int value) { - chan->__do_not_use_visible_indication = value; + chan->visible_indication = value; } int ast_channel_vstreamid(const struct ast_channel *chan) { - return chan->__do_not_use_vstreamid; + return chan->vstreamid; } void ast_channel_vstreamid_set(struct ast_channel *chan, int value) { - chan->__do_not_use_vstreamid = value; + chan->vstreamid = value; } unsigned short ast_channel_transfercapability(const struct ast_channel *chan) { - return chan->__do_not_use_transfercapability; + return chan->transfercapability; } void ast_channel_transfercapability_set(struct ast_channel *chan, unsigned short value) { - chan->__do_not_use_transfercapability = value; + chan->transfercapability = value; } unsigned int ast_channel_emulate_dtmf_duration(const struct ast_channel *chan) { - return chan->__do_not_use_emulate_dtmf_duration; + return chan->emulate_dtmf_duration; } void ast_channel_emulate_dtmf_duration_set(struct ast_channel *chan, unsigned int value) { - chan->__do_not_use_emulate_dtmf_duration = value; + chan->emulate_dtmf_duration = value; } unsigned int ast_channel_fin(const struct ast_channel *chan) { - return chan->__do_not_use_fin; + return chan->fin; } void ast_channel_fin_set(struct ast_channel *chan, unsigned int value) { - chan->__do_not_use_fin = value; + chan->fin = value; } unsigned int ast_channel_fout(const struct ast_channel *chan) { - return chan->__do_not_use_fout; + return chan->fout; } void ast_channel_fout_set(struct ast_channel *chan, unsigned int value) { - chan->__do_not_use_fout = value; + chan->fout = value; } unsigned long ast_channel_insmpl(const struct ast_channel *chan) { - return chan->__do_not_use_insmpl; + return chan->insmpl; } void ast_channel_insmpl_set(struct ast_channel *chan, unsigned long value) { - chan->__do_not_use_insmpl = value; + chan->insmpl = value; } unsigned long ast_channel_outsmpl(const struct ast_channel *chan) { - return chan->__do_not_use_outsmpl; + return chan->outsmpl; } void ast_channel_outsmpl_set(struct ast_channel *chan, unsigned long value) { - chan->__do_not_use_outsmpl = value; + chan->outsmpl = value; } void *ast_channel_generatordata(const struct ast_channel *chan) { - return chan->__do_not_use_generatordata; + return chan->generatordata; } void ast_channel_generatordata_set(struct ast_channel *chan, void *value) { - chan->__do_not_use_generatordata = value; + chan->generatordata = value; } void *ast_channel_music_state(const struct ast_channel *chan) { - return chan->__do_not_use_music_state; + return chan->music_state; } void ast_channel_music_state_set(struct ast_channel *chan, void *value) { - chan->__do_not_use_music_state = value; + chan->music_state = value; } void *ast_channel_tech_pvt(const struct ast_channel *chan) { - return chan->__do_not_use_tech_pvt; + return chan->tech_pvt; } void ast_channel_tech_pvt_set(struct ast_channel *chan, void *value) { - chan->__do_not_use_tech_pvt = value; + chan->tech_pvt = value; } void *ast_channel_timingdata(const struct ast_channel *chan) { - return chan->__do_not_use_timingdata; + return chan->timingdata; } void ast_channel_timingdata_set(struct ast_channel *chan, void *value) { - chan->__do_not_use_timingdata = value; + chan->timingdata = value; } struct ast_audiohook_list *ast_channel_audiohooks(const struct ast_channel *chan) { - return chan->__do_not_use_audiohooks; + return chan->audiohooks; } void ast_channel_audiohooks_set(struct ast_channel *chan, struct ast_audiohook_list *value) { - chan->__do_not_use_audiohooks = value; + chan->audiohooks = value; } struct ast_cdr *ast_channel_cdr(const struct ast_channel *chan) { - return chan->__do_not_use_cdr; + return chan->cdr; } void ast_channel_cdr_set(struct ast_channel *chan, struct ast_cdr *value) { - chan->__do_not_use_cdr = value; + chan->cdr = value; } struct ast_channel *ast_channel_masq(const struct ast_channel *chan) { - return chan->__do_not_use_masq; + return chan->masq; } void ast_channel_masq_set(struct ast_channel *chan, struct ast_channel *value) { - chan->__do_not_use_masq = value; + chan->masq = value; } struct ast_channel *ast_channel_masqr(const struct ast_channel *chan) { - return chan->__do_not_use_masqr; + return chan->masqr; } void ast_channel_masqr_set(struct ast_channel *chan, struct ast_channel *value) { - chan->__do_not_use_masqr = value; + chan->masqr = value; } struct ast_channel_monitor *ast_channel_monitor(const struct ast_channel *chan) { - return chan->__do_not_use_monitor; + return chan->monitor; } void ast_channel_monitor_set(struct ast_channel *chan, struct ast_channel_monitor *value) { - chan->__do_not_use_monitor = value; + chan->monitor = value; } struct ast_filestream *ast_channel_stream(const struct ast_channel *chan) { - return chan->__do_not_use_stream; + return chan->stream; } void ast_channel_stream_set(struct ast_channel *chan, struct ast_filestream *value) { - chan->__do_not_use_stream = value; + chan->stream = value; } struct ast_filestream *ast_channel_vstream(const struct ast_channel *chan) { - return chan->__do_not_use_vstream; + return chan->vstream; } void ast_channel_vstream_set(struct ast_channel *chan, struct ast_filestream *value) { - chan->__do_not_use_vstream = value; + chan->vstream = value; } struct ast_format_cap *ast_channel_nativeformats(const struct ast_channel *chan) { - return chan->__do_not_use_nativeformats; + return chan->nativeformats; } void ast_channel_nativeformats_set(struct ast_channel *chan, struct ast_format_cap *value) { - chan->__do_not_use_nativeformats = value; + chan->nativeformats = value; } struct ast_framehook_list *ast_channel_framehooks(const struct ast_channel *chan) { - return chan->__do_not_use_framehooks; + return chan->framehooks; } void ast_channel_framehooks_set(struct ast_channel *chan, struct ast_framehook_list *value) { - chan->__do_not_use_framehooks = value; + chan->framehooks = value; } struct ast_generator *ast_channel_generator(const struct ast_channel *chan) { - return chan->__do_not_use_generator; + return chan->generator; } void ast_channel_generator_set(struct ast_channel *chan, struct ast_generator *value) { - chan->__do_not_use_generator = value; + chan->generator = value; } struct ast_pbx *ast_channel_pbx(const struct ast_channel *chan) { - return chan->__do_not_use_pbx; + return chan->pbx; } void ast_channel_pbx_set(struct ast_channel *chan, struct ast_pbx *value) { - chan->__do_not_use_pbx = value; + chan->pbx = value; } struct ast_sched_context *ast_channel_sched(const struct ast_channel *chan) { - return chan->__do_not_use_sched; + return chan->sched; } void ast_channel_sched_set(struct ast_channel *chan, struct ast_sched_context *value) { - chan->__do_not_use_sched = value; + chan->sched = value; } struct ast_timer *ast_channel_timer(const struct ast_channel *chan) { - return chan->__do_not_use_timer; + return chan->timer; } void ast_channel_timer_set(struct ast_channel *chan, struct ast_timer *value) { - chan->__do_not_use_timer = value; + chan->timer = value; } struct ast_tone_zone *ast_channel_zone(const struct ast_channel *chan) { - return chan->__do_not_use_zone; + return chan->zone; } void ast_channel_zone_set(struct ast_channel *chan, struct ast_tone_zone *value) { - chan->__do_not_use_zone = value; + chan->zone = value; } struct ast_trans_pvt *ast_channel_readtrans(const struct ast_channel *chan) { - return chan->__do_not_use_readtrans; + return chan->readtrans; } void ast_channel_readtrans_set(struct ast_channel *chan, struct ast_trans_pvt *value) { - chan->__do_not_use_readtrans = value; + chan->readtrans = value; } struct ast_trans_pvt *ast_channel_writetrans(const struct ast_channel *chan) { - return chan->__do_not_use_writetrans; + return chan->writetrans; } void ast_channel_writetrans_set(struct ast_channel *chan, struct ast_trans_pvt *value) { - chan->__do_not_use_writetrans = value; + chan->writetrans = value; } const struct ast_channel_tech *ast_channel_tech(const struct ast_channel *chan) { - return chan->__do_not_use_tech; + return chan->tech; } void ast_channel_tech_set(struct ast_channel *chan, const struct ast_channel_tech *value) { - chan->__do_not_use_tech = value; + chan->tech = value; } enum ast_channel_adsicpe ast_channel_adsicpe(const struct ast_channel *chan) { - return chan->__do_not_use_adsicpe; + return chan->adsicpe; } void ast_channel_adsicpe_set(struct ast_channel *chan, enum ast_channel_adsicpe value) { - chan->__do_not_use_adsicpe = value; + chan->adsicpe = value; } enum ast_channel_state ast_channel_state(const struct ast_channel *chan) { - return chan->__do_not_use_state; + return chan->state; } void ast_channel_state_set(struct ast_channel *chan, enum ast_channel_state value) { - chan->__do_not_use_state = value; + chan->state = value; } struct ast_format *ast_channel_oldwriteformat(struct ast_channel *chan) { - return &chan->__do_not_use_oldwriteformat; + return &chan->oldwriteformat; } struct ast_format *ast_channel_rawreadformat(struct ast_channel *chan) { - return &chan->__do_not_use_rawreadformat; + return &chan->rawreadformat; } struct ast_format *ast_channel_rawwriteformat(struct ast_channel *chan) { - return &chan->__do_not_use_rawwriteformat; + return &chan->rawwriteformat; } struct ast_format *ast_channel_readformat(struct ast_channel *chan) { - return &chan->__do_not_use_readformat; + return &chan->readformat; } struct ast_format *ast_channel_writeformat(struct ast_channel *chan) { - return &chan->__do_not_use_writeformat; + return &chan->writeformat; } struct ast_datastore_list *ast_channel_datastores(struct ast_channel *chan) { - return &chan->__do_not_use_datastores; + return &chan->datastores; } struct ast_autochan_list *ast_channel_autochans(struct ast_channel *chan) { - return &chan->__do_not_use_autochans; + return &chan->autochans; } struct ast_readq_list *ast_channel_readq(struct ast_channel *chan) { - return &chan->__do_not_use_readq; + return &chan->readq; } struct ast_frame *ast_channel_dtmff(struct ast_channel *chan) { - return &chan->__do_not_use_dtmff; + return &chan->dtmff; } struct ast_jb *ast_channel_jb(struct ast_channel *chan) { - return &chan->__do_not_use_jb; + return &chan->jb; } struct ast_party_caller *ast_channel_caller(struct ast_channel *chan) { - return &chan->__do_not_use_caller; + return &chan->caller; } struct ast_party_connected_line *ast_channel_connected(struct ast_channel *chan) { - return &chan->__do_not_use_connected; + return &chan->connected; } struct ast_party_dialed *ast_channel_dialed(struct ast_channel *chan) { - return &chan->__do_not_use_dialed; + return &chan->dialed; } struct ast_party_redirecting *ast_channel_redirecting(struct ast_channel *chan) { - return &chan->__do_not_use_redirecting; + return &chan->redirecting; } struct timeval *ast_channel_dtmf_tv(struct ast_channel *chan) { - return &chan->__do_not_use_dtmf_tv; + return &chan->dtmf_tv; } struct timeval *ast_channel_whentohangup(struct ast_channel *chan) { - return &chan->__do_not_use_whentohangup; + return &chan->whentohangup; } struct varshead *ast_channel_varshead(struct ast_channel *chan) { - return &chan->__do_not_use_varshead; + return &chan->varshead; } void ast_channel_dtmff_set(struct ast_channel *chan, struct ast_frame *value) { - memcpy(&chan->__do_not_use_dtmff, value, sizeof(chan->__do_not_use_dtmff)); + chan->dtmff = *value; } void ast_channel_jb_set(struct ast_channel *chan, struct ast_jb *value) { - memcpy(&chan->__do_not_use_jb, value, sizeof(chan->__do_not_use_jb)); + chan->jb = *value; } void ast_channel_caller_set(struct ast_channel *chan, struct ast_party_caller *value) { - memcpy(&chan->__do_not_use_caller, value, sizeof(chan->__do_not_use_caller)); + chan->caller = *value; } void ast_channel_connected_set(struct ast_channel *chan, struct ast_party_connected_line *value) { - memcpy(&chan->__do_not_use_connected, value, sizeof(chan->__do_not_use_connected)); + chan->connected = *value; } void ast_channel_dialed_set(struct ast_channel *chan, struct ast_party_dialed *value) { - memcpy(&chan->__do_not_use_dialed, value, sizeof(chan->__do_not_use_dialed)); + chan->dialed = *value; } void ast_channel_redirecting_set(struct ast_channel *chan, struct ast_party_redirecting *value) { - memcpy(&chan->__do_not_use_redirecting, value, sizeof(chan->__do_not_use_redirecting)); + chan->redirecting = *value; } void ast_channel_dtmf_tv_set(struct ast_channel *chan, struct timeval *value) { - memcpy(&chan->__do_not_use_dtmf_tv, value, sizeof(chan->__do_not_use_dtmf_tv)); + chan->dtmf_tv = *value; } void ast_channel_whentohangup_set(struct ast_channel *chan, struct timeval *value) { - memcpy(&chan->__do_not_use_whentohangup, value, sizeof(chan->__do_not_use_whentohangup)); + chan->whentohangup = *value; } void ast_channel_varshead_set(struct ast_channel *chan, struct varshead *value) { - memcpy(&chan->__do_not_use_varshead, value, sizeof(chan->__do_not_use_varshead)); + chan->varshead = *value; } /* Evil softhangup accessors */ -int ast_channel_softhangup_internal_flag(struct ast_channel * chan) +int ast_channel_softhangup_internal_flag(struct ast_channel *chan) { - return chan->__do_not_use_softhangup; + return chan->softhangup; } void ast_channel_softhangup_internal_flag_set(struct ast_channel *chan, int value) { - chan->__do_not_use_softhangup = value; + chan->softhangup = value; } void ast_channel_softhangup_internal_flag_add(struct ast_channel *chan, int value) { - chan->__do_not_use_softhangup |= value; + chan->softhangup |= value; } void ast_channel_softhangup_internal_flag_clear(struct ast_channel *chan, int value) { - chan ->__do_not_use_softhangup &= ~value; + chan ->softhangup &= ~value; } /* Typedef accessors */ ast_group_t ast_channel_callgroup(const struct ast_channel *chan) { - return chan->__do_not_use_callgroup; + return chan->callgroup; } void ast_channel_callgroup_set(struct ast_channel *chan, ast_group_t value) { - chan->__do_not_use_callgroup = value; + chan->callgroup = value; } ast_group_t ast_channel_pickupgroup(const struct ast_channel *chan) { - return chan->__do_not_use_pickupgroup; + return chan->pickupgroup; } void ast_channel_pickupgroup_set(struct ast_channel *chan, ast_group_t value) { - chan->__do_not_use_pickupgroup = value; + chan->pickupgroup = value; } /* Alertpipe functions */ int ast_channel_alert_write(struct ast_channel *chan) { char blah = 0x7F; - return ast_channel_alert_writable(chan) && write(chan->__do_not_use_alertpipe[1], &blah, sizeof(blah)) != sizeof(blah); + return ast_channel_alert_writable(chan) && write(chan->alertpipe[1], &blah, sizeof(blah)) != sizeof(blah); } ast_alert_status_t ast_channel_internal_alert_read(struct ast_channel *chan) @@ -844,17 +990,17 @@ ast_alert_status_t ast_channel_internal_alert_read(struct ast_channel *chan) return AST_ALERT_NOT_READABLE; } - flags = fcntl(chan->__do_not_use_alertpipe[0], F_GETFL); + flags = fcntl(chan->alertpipe[0], F_GETFL); /* For some odd reason, the alertpipe occasionally loses nonblocking status, * which immediately causes a deadlock scenario. Detect and prevent this. */ if ((flags & O_NONBLOCK) == 0) { ast_log(LOG_ERROR, "Alertpipe on channel %s lost O_NONBLOCK?!!\n", ast_channel_name(chan)); - if (fcntl(chan->__do_not_use_alertpipe[0], F_SETFL, flags | O_NONBLOCK) < 0) { + if (fcntl(chan->alertpipe[0], F_SETFL, flags | O_NONBLOCK) < 0) { ast_log(LOG_WARNING, "Unable to set alertpipe nonblocking! (%d: %s)\n", errno, strerror(errno)); return AST_ALERT_READ_FATAL; } } - if (read(chan->__do_not_use_alertpipe[0], &blah, sizeof(blah)) < 0) { + if (read(chan->alertpipe[0], &blah, sizeof(blah)) < 0) { if (errno != EINTR && errno != EAGAIN) { ast_log(LOG_WARNING, "read() failed: %s\n", strerror(errno)); return AST_ALERT_READ_FAIL; @@ -866,42 +1012,42 @@ ast_alert_status_t ast_channel_internal_alert_read(struct ast_channel *chan) int ast_channel_alert_writable(struct ast_channel *chan) { - return chan->__do_not_use_alertpipe[1] > -1; + return chan->alertpipe[1] > -1; } int ast_channel_internal_alert_readable(struct ast_channel *chan) { - return chan->__do_not_use_alertpipe[0] > -1; + return chan->alertpipe[0] > -1; } void ast_channel_internal_alertpipe_clear(struct ast_channel *chan) { - chan->__do_not_use_alertpipe[0] = chan->__do_not_use_alertpipe[1] = -1; + chan->alertpipe[0] = chan->alertpipe[1] = -1; } void ast_channel_internal_alertpipe_close(struct ast_channel *chan) { if (ast_channel_internal_alert_readable(chan)) { - close(chan->__do_not_use_alertpipe[0]); + close(chan->alertpipe[0]); } if (ast_channel_alert_writable(chan)) { - close(chan->__do_not_use_alertpipe[1]); + close(chan->alertpipe[1]); } } int ast_channel_internal_alertpipe_init(struct ast_channel *chan) { - if (pipe(chan->__do_not_use_alertpipe)) { + if (pipe(chan->alertpipe)) { ast_log(LOG_WARNING, "Channel allocation failed: Can't create alert pipe! Try increasing max file descriptors with ulimit -n\n"); return -1; } else { - int flags = fcntl(chan->__do_not_use_alertpipe[0], F_GETFL); - if (fcntl(chan->__do_not_use_alertpipe[0], F_SETFL, flags | O_NONBLOCK) < 0) { + int flags = fcntl(chan->alertpipe[0], F_GETFL); + if (fcntl(chan->alertpipe[0], F_SETFL, flags | O_NONBLOCK) < 0) { ast_log(LOG_WARNING, "Channel allocation failed: Unable to set alertpipe nonblocking! (%d: %s)\n", errno, strerror(errno)); return -1; } - flags = fcntl(chan->__do_not_use_alertpipe[1], F_GETFL); - if (fcntl(chan->__do_not_use_alertpipe[1], F_SETFL, flags | O_NONBLOCK) < 0) { + flags = fcntl(chan->alertpipe[1], F_GETFL); + if (fcntl(chan->alertpipe[1], F_SETFL, flags | O_NONBLOCK) < 0) { ast_log(LOG_WARNING, "Channel allocation failed: Unable to set alertpipe nonblocking! (%d: %s)\n", errno, strerror(errno)); return -1; } @@ -911,21 +1057,21 @@ int ast_channel_internal_alertpipe_init(struct ast_channel *chan) int ast_channel_internal_alert_readfd(struct ast_channel *chan) { - return chan->__do_not_use_alertpipe[0]; + return chan->alertpipe[0]; } void ast_channel_internal_alertpipe_swap(struct ast_channel *chan1, struct ast_channel *chan2) { int i; - for (i = 0; i < ARRAY_LEN(chan1->__do_not_use_alertpipe); i++) { - SWAP(chan1->__do_not_use_alertpipe[i], chan2->__do_not_use_alertpipe[i]); + for (i = 0; i < ARRAY_LEN(chan1->alertpipe); i++) { + SWAP(chan1->alertpipe[i], chan2->alertpipe[i]); } } /* file descriptor array accessors */ void ast_channel_internal_fd_set(struct ast_channel *chan, int which, int value) { - chan->__do_not_use_fds[which] = value; + chan->fds[which] = value; } void ast_channel_internal_fd_clear(struct ast_channel *chan, int which) { @@ -940,7 +1086,7 @@ void ast_channel_internal_fd_clear_all(struct ast_channel *chan) } int ast_channel_fd(const struct ast_channel *chan, int which) { - return chan->__do_not_use_fds[which]; + return chan->fds[which]; } int ast_channel_fd_isset(const struct ast_channel *chan, int which) { @@ -950,10 +1096,86 @@ int ast_channel_fd_isset(const struct ast_channel *chan, int which) #ifdef HAVE_EPOLL struct ast_epoll_data *ast_channel_internal_epfd_data(const struct ast_channel *chan, int which) { - return chan->__do_not_use_epfd_data[which]; + return chan->epfd_data[which]; } void ast_channel_internal_epfd_data_set(struct ast_channel *chan, int which , struct ast_epoll_data *value) { - chan->__do_not_use_epfd_data[which] = value; + chan->epfd_data[which] = value; } #endif + +pthread_t ast_channel_blocker(const struct ast_channel *chan) +{ + return chan->blocker; +} +void ast_channel_blocker_set(struct ast_channel *chan, pthread_t value) +{ + chan->blocker = value; +} + +ast_timing_func_t ast_channel_timingfunc(const struct ast_channel *chan) +{ + return chan->timingfunc; +} +void ast_channel_timingfunc_set(struct ast_channel *chan, ast_timing_func_t value) +{ + chan->timingfunc = value; +} + +struct ast_bridge *ast_channel_internal_bridge(const struct ast_channel *chan) +{ + return chan->bridge; +} +void ast_channel_internal_bridge_set(struct ast_channel *chan, struct ast_bridge *value) +{ + chan->bridge = value; +} + +struct ast_channel *ast_channel_internal_bridged_channel(const struct ast_channel *chan) +{ + return chan->bridged_channel; +} +void ast_channel_internal_bridged_channel_set(struct ast_channel *chan, struct ast_channel *value) +{ + chan->bridged_channel = value; +} + +struct ast_flags *ast_channel_flags(struct ast_channel *chan) +{ + return &chan->flags; +} + +struct ast_channel *__ast_channel_internal_alloc(void (*destructor)(void *obj), const char *file, int line, const char *function) +{ + struct ast_channel *tmp; +#if defined(REF_DEBUG) + tmp = __ao2_alloc_debug(sizeof(*tmp), destructor, + AO2_ALLOC_OPT_LOCK_MUTEX, "", file, line, function, 1); +#elif defined(__AST_DEBUG_MALLOC) + tmp = __ao2_alloc_debug(sizeof(*tmp), destructor, + AO2_ALLOC_OPT_LOCK_MUTEX, "", file, line, function, 0); +#else + tmp = ao2_alloc(sizeof(*tmp), destructor); +#endif + + if ((ast_string_field_init(tmp, 128))) { + return ast_channel_unref(tmp); + } + + return tmp; +} + +void ast_channel_internal_cleanup(struct ast_channel *chan) +{ + ast_string_field_free_memory(chan); +} + +void ast_channel_internal_finalize(struct ast_channel *chan) +{ + chan->finalized = 1; +} + +int ast_channel_internal_is_finalized(struct ast_channel *chan) +{ + return chan->finalized; +} diff --git a/main/cli.c b/main/cli.c index 591f6d556a..2480949272 100644 --- a/main/cli.c +++ b/main/cli.c @@ -1494,10 +1494,10 @@ static char *handle_showchan(struct ast_cli_entry *e, int cmd, struct ast_cli_ar ast_channel_fin(c) & ~DEBUGCHAN_FLAG, (ast_channel_fin(c) & DEBUGCHAN_FLAG) ? " (DEBUGGED)" : "", ast_channel_fout(c) & ~DEBUGCHAN_FLAG, (ast_channel_fout(c) & DEBUGCHAN_FLAG) ? " (DEBUGGED)" : "", (long)ast_channel_whentohangup(c)->tv_sec, - cdrtime, c->_bridge ? ast_channel_name(c->_bridge) : "", ast_bridged_channel(c) ? ast_channel_name(ast_bridged_channel(c)) : "", + cdrtime, ast_channel_internal_bridged_channel(c) ? ast_channel_name(ast_channel_internal_bridged_channel(c)) : "", ast_bridged_channel(c) ? ast_channel_name(ast_bridged_channel(c)) : "", ast_channel_context(c), ast_channel_exten(c), ast_channel_priority(c), ast_channel_callgroup(c), ast_channel_pickupgroup(c), (ast_channel_appl(c) ? ast_channel_appl(c) : "(N/A)" ), (ast_channel_data(c) ? S_OR(ast_channel_data(c), "(Empty)") : "(None)"), - (ast_test_flag(c, AST_FLAG_BLOCKING) ? ast_channel_blockproc(c) : "(Not Blocking)")); + (ast_test_flag(ast_channel_flags(c), AST_FLAG_BLOCKING) ? ast_channel_blockproc(c) : "(Not Blocking)")); if (pbx_builtin_serialize_variables(c, &obuf)) { ast_str_append(&output, 0, " Variables:\n%s\n", ast_str_buffer(obuf)); diff --git a/main/features.c b/main/features.c index 03627ee385..7e8a978a0e 100644 --- a/main/features.c +++ b/main/features.c @@ -892,7 +892,7 @@ static void check_goto_on_transfer(struct ast_channel *chan) } ast_parseable_goto(xferchan, goto_on_transfer); ast_channel_state_set(xferchan, AST_STATE_UP); - ast_clear_flag(xferchan, AST_FLAGS_ALL); + ast_clear_flag(ast_channel_flags(xferchan), AST_FLAGS_ALL); ast_channel_clear_softhangup(xferchan, AST_SOFTHANGUP_ALL); if (ast_do_masquerade(xferchan) || ast_pbx_start(xferchan)) { @@ -1547,10 +1547,10 @@ static int park_call_full(struct ast_channel *chan, struct ast_channel *peer, st * parking space number do not continue playing it back. This * is the case if an attended transfer occurs. */ - ast_set_flag(peer, AST_FLAG_MASQ_NOSTREAM); + ast_set_flag(ast_channel_flags(peer), AST_FLAG_MASQ_NOSTREAM); /* Tell the peer channel the number of the parking space */ ast_say_digits(peer, pu->parkingnum, "", ast_channel_language(peer)); - ast_clear_flag(peer, AST_FLAG_MASQ_NOSTREAM); + ast_clear_flag(ast_channel_flags(peer), AST_FLAG_MASQ_NOSTREAM); } if (peer == chan) { /* pu->notquiteyet = 1 */ /* Wake up parking thread if we're really done */ @@ -2354,7 +2354,7 @@ static int builtin_blindtransfer(struct ast_channel *chan, struct ast_channel *p } else { /* Set the transferee's new extension, since it exists, using transferer context */ ast_debug(1, "About to explicit goto %s, it has a PBX.\n", ast_channel_name(transferee)); - ast_set_flag(transferee, AST_FLAG_BRIDGE_HANGUP_DONT); /* don't let the after-bridge code run the h-exten */ + ast_set_flag(ast_channel_flags(transferee), AST_FLAG_BRIDGE_HANGUP_DONT); /* don't let the after-bridge code run the h-exten */ set_c_e_p(transferee, transferer_real_context, xferto, 0); /* @@ -2586,13 +2586,13 @@ static int builtin_atxfer(struct ast_channel *chan, struct ast_channel *peer, st /* ast_bridge_call clears AST_FLAG_BRIDGE_HANGUP_DONT, but we don't want that to happen here because we're also in another bridge already */ - if (ast_test_flag(chan, AST_FLAG_BRIDGE_HANGUP_DONT)) { + if (ast_test_flag(ast_channel_flags(chan), AST_FLAG_BRIDGE_HANGUP_DONT)) { hangup_dont = 1; } /* Let party B and party C talk as long as they want. */ ast_bridge_call(transferer, newchan, &bconfig); if (hangup_dont) { - ast_set_flag(chan, AST_FLAG_BRIDGE_HANGUP_DONT); + ast_set_flag(ast_channel_flags(chan), AST_FLAG_BRIDGE_HANGUP_DONT); } if (ast_check_hangup(newchan) || !ast_check_hangup(transferer)) { @@ -2733,13 +2733,13 @@ static int builtin_atxfer(struct ast_channel *chan, struct ast_channel *peer, st ast_channel_masquerade(xferchan, transferee); ast_explicit_goto(xferchan, ast_channel_context(transferee), ast_channel_exten(transferee), ast_channel_priority(transferee)); ast_channel_state_set(xferchan, AST_STATE_UP); - ast_clear_flag(xferchan, AST_FLAGS_ALL); + ast_clear_flag(ast_channel_flags(xferchan), AST_FLAGS_ALL); /* Do the masquerade manually to make sure that is is completed. */ ast_do_masquerade(xferchan); ast_channel_state_set(newchan, AST_STATE_UP); - ast_clear_flag(newchan, AST_FLAGS_ALL); + ast_clear_flag(ast_channel_flags(newchan), AST_FLAGS_ALL); tobj = ast_calloc(1, sizeof(*tobj)); if (!tobj) { ast_hangup(xferchan); @@ -3714,13 +3714,13 @@ void ast_channel_log(char *title, struct ast_channel *chan) /* for debug, this i ast_channel_accountcode(chan), ast_channel_dialcontext(chan), ast_channel_amaflags(chan), ast_channel_macrocontext(chan), ast_channel_macroexten(chan), ast_channel_macropriority(chan)); ast_log(LOG_NOTICE, "CHAN: masq: %p; masqr: %p; _bridge: %p; uniqueID: %s; linkedID:%s\n", ast_channel_masq(chan), ast_channel_masqr(chan), - chan->_bridge, ast_channel_uniqueid(chan), ast_channel_linkedid(chan)); + ast_channel_internal_bridged_channel(chan), ast_channel_uniqueid(chan), ast_channel_linkedid(chan)); if (ast_channel_masqr(chan)) { ast_log(LOG_NOTICE, "CHAN: masquerading as: %s; cdr: %p;\n", ast_channel_name(ast_channel_masqr(chan)), ast_channel_cdr(ast_channel_masqr(chan))); } - if (chan->_bridge) { - ast_log(LOG_NOTICE, "CHAN: Bridged to %s\n", ast_channel_name(chan->_bridge)); + if (ast_channel_internal_bridged_channel(chan)) { + ast_log(LOG_NOTICE, "CHAN: Bridged to %s\n", ast_channel_name(ast_channel_internal_bridged_channel(chan))); } ast_log(LOG_NOTICE, "===== done ====\n"); @@ -4024,7 +4024,7 @@ int ast_bridge_call(struct ast_channel *chan, struct ast_channel *peer, struct a ast_cdr_answer(chan_cdr); /* for the sake of cli status checks */ } } - if (ast_test_flag(chan,AST_FLAG_BRIDGE_HANGUP_DONT) && (chan_cdr || peer_cdr)) { + if (ast_test_flag(ast_channel_flags(chan), AST_FLAG_BRIDGE_HANGUP_DONT) && (chan_cdr || peer_cdr)) { if (chan_cdr) { ast_set_flag(chan_cdr, AST_CDR_FLAG_BRIDGED); } @@ -4051,8 +4051,8 @@ int ast_bridge_call(struct ast_channel *chan, struct ast_channel *peer, struct a res = ast_channel_bridge(chan, peer, config, &f, &who); - if (ast_test_flag(chan, AST_FLAG_ZOMBIE) - || ast_test_flag(peer, AST_FLAG_ZOMBIE)) { + if (ast_test_flag(ast_channel_flags(chan), AST_FLAG_ZOMBIE) + || ast_test_flag(ast_channel_flags(peer), AST_FLAG_ZOMBIE)) { /* Zombies are present time to leave! */ res = -1; if (f) { @@ -4122,7 +4122,7 @@ int ast_bridge_call(struct ast_channel *chan, struct ast_channel *peer, struct a } } if (res < 0) { - if (!ast_test_flag(chan, AST_FLAG_ZOMBIE) && !ast_test_flag(peer, AST_FLAG_ZOMBIE) && !ast_check_hangup(chan) && !ast_check_hangup(peer)) { + if (!ast_test_flag(ast_channel_flags(chan), AST_FLAG_ZOMBIE) && !ast_test_flag(ast_channel_flags(peer), AST_FLAG_ZOMBIE) && !ast_check_hangup(chan) && !ast_check_hangup(peer)) { ast_log(LOG_WARNING, "Bridge failed on channels %s and %s\n", ast_channel_name(chan), ast_channel_name(peer)); } goto before_you_go; @@ -4139,7 +4139,7 @@ int ast_bridge_call(struct ast_channel *chan, struct ast_channel *peer, struct a */ ast_channel_lock(chan); if (ast_channel_softhangup_internal_flag(chan) & (AST_SOFTHANGUP_ASYNCGOTO | AST_SOFTHANGUP_UNBRIDGE)) { - ast_set_flag(chan, AST_FLAG_BRIDGE_HANGUP_DONT); + ast_set_flag(ast_channel_flags(chan), AST_FLAG_BRIDGE_HANGUP_DONT); } ast_channel_unlock(chan); res = -1; @@ -4300,8 +4300,8 @@ before_you_go: silgen = NULL; } - if (ast_test_flag(chan,AST_FLAG_BRIDGE_HANGUP_DONT)) { - ast_clear_flag(chan,AST_FLAG_BRIDGE_HANGUP_DONT); /* its job is done */ + if (ast_test_flag(ast_channel_flags(chan), AST_FLAG_BRIDGE_HANGUP_DONT)) { + ast_clear_flag(ast_channel_flags(chan), AST_FLAG_BRIDGE_HANGUP_DONT); /* its job is done */ if (bridge_cdr) { ast_cdr_discard(bridge_cdr); /* QUESTION: should we copy bridge_cdr fields to the peer before we throw it away? */ @@ -4345,8 +4345,8 @@ before_you_go: */ ast_softhangup(chan, AST_SOFTHANGUP_APPUNLOAD); - autoloopflag = ast_test_flag(chan, AST_FLAG_IN_AUTOLOOP); - ast_set_flag(chan, AST_FLAG_IN_AUTOLOOP); + autoloopflag = ast_test_flag(ast_channel_flags(chan), AST_FLAG_IN_AUTOLOOP); + ast_set_flag(ast_channel_flags(chan), AST_FLAG_IN_AUTOLOOP); if (bridge_cdr && ast_opt_end_cdr_before_h_exten) { ast_cdr_end(bridge_cdr); } @@ -4395,7 +4395,7 @@ before_you_go: } } /* An "h" exten has been run, so indicate that one has been run. */ - ast_set_flag(chan, AST_FLAG_BRIDGE_HANGUP_RUN); + ast_set_flag(ast_channel_flags(chan), AST_FLAG_BRIDGE_HANGUP_RUN); ast_channel_unlock(chan); /* protect the lastapp/lastdata against the effects of the hangup/dialplan code */ @@ -4403,7 +4403,7 @@ before_you_go: ast_copy_string(bridge_cdr->lastapp, savelastapp, sizeof(bridge_cdr->lastapp)); ast_copy_string(bridge_cdr->lastdata, savelastdata, sizeof(bridge_cdr->lastdata)); } - ast_set2_flag(chan, autoloopflag, AST_FLAG_IN_AUTOLOOP); + ast_set2_flag(ast_channel_flags(chan), autoloopflag, AST_FLAG_IN_AUTOLOOP); } /* obey the NoCDR() wishes. -- move the DISABLED flag to the bridge CDR if it was set on the channel during the bridge... */ @@ -4747,9 +4747,9 @@ static int manage_parked_call(struct parkeduser *pu, const struct pollfd *pfds, } if (pfds[y].revents & POLLPRI) { - ast_set_flag(chan, AST_FLAG_EXCEPTION); + ast_set_flag(ast_channel_flags(chan), AST_FLAG_EXCEPTION); } else { - ast_clear_flag(chan, AST_FLAG_EXCEPTION); + ast_clear_flag(ast_channel_flags(chan), AST_FLAG_EXCEPTION); } ast_channel_fdno_set(chan, x); @@ -7227,7 +7227,7 @@ static const struct ast_datastore_info pickup_active = { int ast_can_pickup(struct ast_channel *chan) { - if (!ast_channel_pbx(chan) && !ast_channel_masq(chan) && !ast_test_flag(chan, AST_FLAG_ZOMBIE) + if (!ast_channel_pbx(chan) && !ast_channel_masq(chan) && !ast_test_flag(ast_channel_flags(chan), AST_FLAG_ZOMBIE) && (ast_channel_state(chan) == AST_STATE_RINGING || ast_channel_state(chan) == AST_STATE_RING /* @@ -7353,7 +7353,7 @@ int ast_do_pickup(struct ast_channel *chan, struct ast_channel *target) } /* setting this flag to generate a reason header in the cancel message to the ringing channel */ - ast_set_flag(chan, AST_FLAG_ANSWERED_ELSEWHERE); + ast_set_flag(ast_channel_flags(chan), AST_FLAG_ANSWERED_ELSEWHERE); if (ast_channel_masquerade(target, chan)) { ast_log(LOG_WARNING, "Unable to masquerade '%s' into '%s'\n", chan_name, diff --git a/main/file.c b/main/file.c index 82f2aab86d..aaccb11feb 100644 --- a/main/file.c +++ b/main/file.c @@ -1040,7 +1040,7 @@ int ast_streamfile(struct ast_channel *chan, const char *filename, const char *p ast_debug(1, "Ooh, found a video stream, too, format %s\n", ast_getformatname(&vfs->fmt->format)); } - if (ast_test_flag(chan, AST_FLAG_MASQ_NOSTREAM)) + if (ast_test_flag(ast_channel_flags(chan), AST_FLAG_MASQ_NOSTREAM)) fs->orig_chan_name = ast_strdup(ast_channel_name(chan)); if (ast_applystream(chan, fs)) return -1; @@ -1252,9 +1252,9 @@ static int waitstream_core(struct ast_channel *c, const char *breakon, reverse = ""; /* 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(ast_channel_flags(c), AST_FLAG_END_DTMF_ONLY); - if (ast_test_flag(c, AST_FLAG_MASQ_NOSTREAM)) + if (ast_test_flag(ast_channel_flags(c), AST_FLAG_MASQ_NOSTREAM)) orig_chan_name = ast_strdupa(ast_channel_name(c)); while (ast_channel_stream(c)) { @@ -1269,7 +1269,7 @@ static int waitstream_core(struct ast_channel *c, const char *breakon, ms = ast_sched_wait(ast_channel_sched(c)); - if (ms < 0 && !c->timingfunc) { + if (ms < 0 && !ast_channel_timingfunc(c)) { ast_stopstream(c); break; } @@ -1279,7 +1279,7 @@ static int waitstream_core(struct ast_channel *c, const char *breakon, res = ast_waitfor(c, ms); if (res < 0) { ast_log(LOG_WARNING, "Select failed (%s)\n", strerror(errno)); - ast_clear_flag(c, AST_FLAG_END_DTMF_ONLY); + ast_clear_flag(ast_channel_flags(c), AST_FLAG_END_DTMF_ONLY); return res; } } else { @@ -1290,11 +1290,11 @@ static int waitstream_core(struct ast_channel *c, const char *breakon, if (errno == EINTR) continue; ast_log(LOG_WARNING, "Wait failed (%s)\n", strerror(errno)); - ast_clear_flag(c, AST_FLAG_END_DTMF_ONLY); + ast_clear_flag(ast_channel_flags(c), AST_FLAG_END_DTMF_ONLY); return -1; } else if (outfd > -1) { /* this requires cmdfd set */ /* The FD we were watching has something waiting */ - ast_clear_flag(c, AST_FLAG_END_DTMF_ONLY); + ast_clear_flag(ast_channel_flags(c), AST_FLAG_END_DTMF_ONLY); return 1; } /* if rchan is set, it is 'c' */ @@ -1303,7 +1303,7 @@ static int waitstream_core(struct ast_channel *c, const char *breakon, if (res > 0) { struct ast_frame *fr = ast_read(c); if (!fr) { - ast_clear_flag(c, AST_FLAG_END_DTMF_ONLY); + ast_clear_flag(ast_channel_flags(c), AST_FLAG_END_DTMF_ONLY); return -1; } switch (fr->frametype) { @@ -1314,7 +1314,7 @@ static int waitstream_core(struct ast_channel *c, const char *breakon, S_COR(ast_channel_caller(c)->id.number.valid, ast_channel_caller(c)->id.number.str, NULL))) { res = fr->subclass.integer; ast_frfree(fr); - ast_clear_flag(c, AST_FLAG_END_DTMF_ONLY); + ast_clear_flag(ast_channel_flags(c), AST_FLAG_END_DTMF_ONLY); return res; } } else { @@ -1332,7 +1332,7 @@ static int waitstream_core(struct ast_channel *c, const char *breakon, ast_stream_rewind(ast_channel_stream(c), skip_ms); } else if (strchr(breakon, res)) { ast_frfree(fr); - ast_clear_flag(c, AST_FLAG_END_DTMF_ONLY); + ast_clear_flag(ast_channel_flags(c), AST_FLAG_END_DTMF_ONLY); return res; } } @@ -1343,7 +1343,7 @@ static int waitstream_core(struct ast_channel *c, const char *breakon, case AST_CONTROL_BUSY: case AST_CONTROL_CONGESTION: ast_frfree(fr); - ast_clear_flag(c, AST_FLAG_END_DTMF_ONLY); + ast_clear_flag(ast_channel_flags(c), AST_FLAG_END_DTMF_ONLY); return -1; case AST_CONTROL_RINGING: case AST_CONTROL_ANSWER: @@ -1379,7 +1379,7 @@ static int waitstream_core(struct ast_channel *c, const char *breakon, ast_sched_runq(ast_channel_sched(c)); } - ast_clear_flag(c, AST_FLAG_END_DTMF_ONLY); + ast_clear_flag(ast_channel_flags(c), AST_FLAG_END_DTMF_ONLY); return (err || ast_channel_softhangup_internal_flag(c)) ? -1 : 0; } diff --git a/main/indications.c b/main/indications.c index 20ce4b894b..c62a495c67 100644 --- a/main/indications.c +++ b/main/indications.c @@ -163,9 +163,9 @@ static void *playtones_alloc(struct ast_channel *chan, void *params) /* Let interrupts interrupt :) */ if (pd->interruptible) { - ast_set_flag(chan, AST_FLAG_WRITE_INT); + ast_set_flag(ast_channel_flags(chan), AST_FLAG_WRITE_INT); } else { - ast_clear_flag(chan, AST_FLAG_WRITE_INT); + ast_clear_flag(ast_channel_flags(chan), AST_FLAG_WRITE_INT); } return ps; diff --git a/main/manager.c b/main/manager.c index 482496dca1..a5e30b06c1 100644 --- a/main/manager.c +++ b/main/manager.c @@ -3321,8 +3321,8 @@ static int action_status(struct mansession *s, const struct message *m) } channels++; - if (c->_bridge) { - snprintf(bridge, sizeof(bridge), "BridgedChannel: %s\r\nBridgedUniqueid: %s\r\n", ast_channel_name(c->_bridge), ast_channel_uniqueid(c->_bridge)); + if (ast_channel_internal_bridged_channel(c)) { + snprintf(bridge, sizeof(bridge), "BridgedChannel: %s\r\nBridgedUniqueid: %s\r\n", ast_channel_name(ast_channel_internal_bridged_channel(c)), ast_channel_uniqueid(ast_channel_internal_bridged_channel(c))); } else { bridge[0] = '\0'; } @@ -3502,7 +3502,7 @@ static int action_redirect(struct mansession *s, const struct message *m) if (ast_channel_pbx(chan)) { ast_channel_lock(chan); - ast_set_flag(chan, AST_FLAG_BRIDGE_HANGUP_DONT); /* don't let the after-bridge code run the h-exten */ + ast_set_flag(ast_channel_flags(chan), AST_FLAG_BRIDGE_HANGUP_DONT); /* don't let the after-bridge code run the h-exten */ ast_channel_unlock(chan); } @@ -3512,7 +3512,7 @@ static int action_redirect(struct mansession *s, const struct message *m) if (chan2) { if (ast_channel_pbx(chan2)) { ast_channel_lock(chan2); - ast_set_flag(chan2, AST_FLAG_BRIDGE_HANGUP_DONT); /* don't let the after-bridge code run the h-exten */ + ast_set_flag(ast_channel_flags(chan2), AST_FLAG_BRIDGE_HANGUP_DONT); /* don't let the after-bridge code run the h-exten */ ast_channel_unlock(chan2); } if (!ast_strlen_zero(context2)) { diff --git a/main/pbx.c b/main/pbx.c index d848fc3b61..221e5173f8 100644 --- a/main/pbx.c +++ b/main/pbx.c @@ -5119,8 +5119,8 @@ static enum ast_pbx_result __ast_pbx_run(struct ast_channel *c, ast_channel_pbx(c)->rtimeoutms = 10000; ast_channel_pbx(c)->dtimeoutms = 5000; - autoloopflag = ast_test_flag(c, AST_FLAG_IN_AUTOLOOP); /* save value to restore at the end */ - ast_set_flag(c, AST_FLAG_IN_AUTOLOOP); + autoloopflag = ast_test_flag(ast_channel_flags(c), AST_FLAG_IN_AUTOLOOP); /* save value to restore at the end */ + ast_set_flag(ast_channel_flags(c), AST_FLAG_IN_AUTOLOOP); if (ast_strlen_zero(ast_channel_exten(c))) { /* If not successful fall back to 's' - but only if there is no given exten */ @@ -5370,7 +5370,7 @@ static enum ast_pbx_result __ast_pbx_run(struct ast_channel *c, } if ((!args || !args->no_hangup_chan) - && !ast_test_flag(c, AST_FLAG_BRIDGE_HANGUP_RUN) + && !ast_test_flag(ast_channel_flags(c), AST_FLAG_BRIDGE_HANGUP_RUN) && ast_exists_extension(c, ast_channel_context(c), "h", 1, S_COR(ast_channel_caller(c)->id.number.valid, ast_channel_caller(c)->id.number.str, NULL))) { set_ext_pri(c, "h", 1); @@ -5388,8 +5388,8 @@ static enum ast_pbx_result __ast_pbx_run(struct ast_channel *c, ast_verb(2, "Spawn extension (%s, %s, %d) exited non-zero on '%s'\n", ast_channel_context(c), ast_channel_exten(c), ast_channel_priority(c), ast_channel_name(c)); } } - ast_set2_flag(c, autoloopflag, AST_FLAG_IN_AUTOLOOP); - ast_clear_flag(c, AST_FLAG_BRIDGE_HANGUP_RUN); /* from one round to the next, make sure this gets cleared */ + ast_set2_flag(ast_channel_flags(c), autoloopflag, AST_FLAG_IN_AUTOLOOP); + ast_clear_flag(ast_channel_flags(c), AST_FLAG_BRIDGE_HANGUP_RUN); /* from one round to the next, make sure this gets cleared */ pbx_destroy(ast_channel_pbx(c)); ast_channel_pbx_set(c, NULL); @@ -8302,7 +8302,7 @@ int ast_explicit_goto(struct ast_channel *chan, const char *context, const char if (priority > -1) { ast_channel_priority_set(chan, priority); /* see flag description in channel.h for explanation */ - if (ast_test_flag(chan, AST_FLAG_IN_AUTOLOOP)) { + if (ast_test_flag(ast_channel_flags(chan), AST_FLAG_IN_AUTOLOOP)) { ast_channel_priority_set(chan, ast_channel_priority(chan) - 1); } } @@ -9977,7 +9977,7 @@ static int pbx_builtin_background(struct ast_channel *chan, const char *data) * users can EXEC Background and reasonably expect that the DTMF code will * be returned (see #16434). */ - if (!ast_test_flag(chan, AST_FLAG_DISABLE_WORKAROUNDS) + if (!ast_test_flag(ast_channel_flags(chan), AST_FLAG_DISABLE_WORKAROUNDS) && (exten[0] = res) && ast_canmatch_extension(chan, args.context, exten, 1, S_COR(ast_channel_caller(chan)->id.number.valid, ast_channel_caller(chan)->id.number.str, NULL)) diff --git a/main/rtp_engine.c b/main/rtp_engine.c index e739c7014a..fc3118d31e 100644 --- a/main/rtp_engine.c +++ b/main/rtp_engine.c @@ -1245,7 +1245,7 @@ static enum ast_bridge_result remote_bridge_loop(struct ast_channel *c0, cs[1] = cs[2]; } - if (ast_test_flag(c0, AST_FLAG_ZOMBIE)) { + if (ast_test_flag(ast_channel_flags(c0), AST_FLAG_ZOMBIE)) { ast_debug(1, "Channel '%s' Zombie cleardown from bridge\n", ast_channel_name(c0)); } else if (ast_channel_tech_pvt(c0) != pvt0) { ast_debug(1, "Channel c0->'%s' pvt changed, in bridge with c1->'%s'\n", ast_channel_name(c0), ast_channel_name(c1)); @@ -1254,7 +1254,7 @@ static enum ast_bridge_result remote_bridge_loop(struct ast_channel *c0, } else if (glue0->update_peer(c0, NULL, NULL, NULL, 0, 0)) { ast_log(LOG_WARNING, "Channel '%s' failed to break RTP bridge\n", ast_channel_name(c0)); } - if (ast_test_flag(c1, AST_FLAG_ZOMBIE)) { + if (ast_test_flag(ast_channel_flags(c1), AST_FLAG_ZOMBIE)) { ast_debug(1, "Channel '%s' Zombie cleardown from bridge\n", ast_channel_name(c1)); } else if (ast_channel_tech_pvt(c1) != pvt1) { ast_debug(1, "Channel c1->'%s' pvt changed, in bridge with c0->'%s'\n", ast_channel_name(c1), ast_channel_name(c0)); diff --git a/res/res_agi.c b/res/res_agi.c index acac4c89ac..1a5ff7fbf2 100644 --- a/res/res_agi.c +++ b/res/res_agi.c @@ -2496,8 +2496,8 @@ static int handle_exec(struct ast_channel *chan, AGI *agi, int argc, const char ast_verb(3, "AGI Script Executing Application: (%s) Options: (%s)\n", argv[1], argc >= 3 ? argv[2] : ""); if ((app_to_exec = pbx_findapp(argv[1]))) { - if (!(workaround = ast_test_flag(chan, AST_FLAG_DISABLE_WORKAROUNDS))) { - ast_set_flag(chan, AST_FLAG_DISABLE_WORKAROUNDS); + if (!(workaround = ast_test_flag(ast_channel_flags(chan), AST_FLAG_DISABLE_WORKAROUNDS))) { + ast_set_flag(ast_channel_flags(chan), AST_FLAG_DISABLE_WORKAROUNDS); } if (ast_compat_res_agi && argc >= 3 && !ast_strlen_zero(argv[2])) { char *compat = alloca(strlen(argv[2]) * 2 + 1), *cptr; @@ -2518,7 +2518,7 @@ static int handle_exec(struct ast_channel *chan, AGI *agi, int argc, const char res = pbx_exec(chan, app_to_exec, argc == 2 ? "" : argv[2]); } if (!workaround) { - ast_clear_flag(chan, AST_FLAG_DISABLE_WORKAROUNDS); + ast_clear_flag(ast_channel_flags(chan), AST_FLAG_DISABLE_WORKAROUNDS); } } else { ast_log(LOG_WARNING, "Could not find application (%s)\n", argv[1]); @@ -3008,7 +3008,7 @@ static int handle_speechrecognize(struct ast_channel *chan, AGI *agi, int argc, switch (speech->state) { case AST_SPEECH_STATE_READY: /* If the stream is done, start timeout calculation */ - if ((timeout > 0) && start == 0 && ((!ast_channel_stream(chan)) || (ast_channel_streamid(chan) == -1 && chan->timingfunc == NULL))) { + if ((timeout > 0) && start == 0 && ((!ast_channel_stream(chan)) || (ast_channel_streamid(chan) == -1 && ast_channel_timingfunc(chan) == NULL))) { ast_stopstream(chan); time(&start); } @@ -3018,7 +3018,7 @@ static int handle_speechrecognize(struct ast_channel *chan, AGI *agi, int argc, break; case AST_SPEECH_STATE_WAIT: /* Cue waiting sound if not already playing */ - if ((!ast_channel_stream(chan)) || (ast_channel_streamid(chan) == -1 && chan->timingfunc == NULL)) { + if ((!ast_channel_stream(chan)) || (ast_channel_streamid(chan) == -1 && ast_channel_timingfunc(chan) == NULL)) { ast_stopstream(chan); /* If a processing sound exists, or is not none - play it */ if (!ast_strlen_zero(speech->processing_sound) && strcasecmp(speech->processing_sound, "none")) diff --git a/res/res_musiconhold.c b/res/res_musiconhold.c index 37d3478099..639c3b05f7 100644 --- a/res/res_musiconhold.c +++ b/res/res_musiconhold.c @@ -1562,7 +1562,7 @@ static int local_ast_moh_start(struct ast_channel *chan, const char *mclass, con ast_channel_name(chan), ast_channel_uniqueid(chan), mohclass->name); - ast_set_flag(chan, AST_FLAG_MOH); + ast_set_flag(ast_channel_flags(chan), AST_FLAG_MOH); if (mohclass->total_files) { res = ast_activate_generator(chan, &moh_file_stream, mohclass); @@ -1577,7 +1577,7 @@ static int local_ast_moh_start(struct ast_channel *chan, const char *mclass, con static void local_ast_moh_stop(struct ast_channel *chan) { - ast_clear_flag(chan, AST_FLAG_MOH); + ast_clear_flag(ast_channel_flags(chan), AST_FLAG_MOH); ast_deactivate_generator(chan); ast_channel_lock(chan); diff --git a/res/snmp/agent.c b/res/snmp/agent.c index 9989ae17e2..3cc630471f 100644 --- a/res/snmp/agent.c +++ b/res/snmp/agent.c @@ -503,10 +503,10 @@ static u_char *ast_var_channels_table(struct variable *vp, oid *name, size_t *le case ASTCHANFLAGS: bits_ret[0] = 0; for (bit = 0; bit < 8; bit++) - bits_ret[0] |= ((chan->flags & (1 << bit)) >> bit) << (7 - bit); + bits_ret[0] |= ((ast_channel_flags(chan)->flags & (1 << bit)) >> bit) << (7 - bit); bits_ret[1] = 0; for (bit = 0; bit < 8; bit++) - bits_ret[1] |= (((chan->flags >> 8) & (1 << bit)) >> bit) << (7 - bit); + bits_ret[1] |= (((ast_channel_flags(chan)->flags >> 8) & (1 << bit)) >> bit) << (7 - bit); *var_len = 2; ret = bits_ret; break;