ast_channel opaquification of pointers and integral types
authorTerry Wilson <twilson@digium.com>
Mon, 20 Feb 2012 23:43:27 +0000 (23:43 +0000)
committerTerry Wilson <twilson@digium.com>
Mon, 20 Feb 2012 23:43:27 +0000 (23:43 +0000)
Review: https://reviewboard.asterisk.org/r/1753/

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@356042 65c4cc65-6c06-0410-ace0-fbb531ad65f3

123 files changed:
addons/chan_mobile.c
addons/chan_ooh323.c
apps/app_alarmreceiver.c
apps/app_authenticate.c
apps/app_cdr.c
apps/app_chanisavail.c
apps/app_channelredirect.c
apps/app_chanspy.c
apps/app_confbridge.c
apps/app_dahdibarge.c
apps/app_dahdiras.c
apps/app_dial.c
apps/app_dictate.c
apps/app_directory.c
apps/app_disa.c
apps/app_dumpchan.c
apps/app_echo.c
apps/app_externalivr.c
apps/app_fax.c
apps/app_festival.c
apps/app_flash.c
apps/app_followme.c
apps/app_forkcdr.c
apps/app_ices.c
apps/app_ivrdemo.c
apps/app_macro.c
apps/app_meetme.c
apps/app_milliwatt.c
apps/app_minivm.c
apps/app_osplookup.c
apps/app_parkandannounce.c
apps/app_playback.c
apps/app_playtones.c
apps/app_privacy.c
apps/app_queue.c
apps/app_read.c
apps/app_readexten.c
apps/app_record.c
apps/app_rpt.c
apps/app_sayunixtime.c
apps/app_sendtext.c
apps/app_sms.c
apps/app_softhangup.c
apps/app_speech_utils.c
apps/app_stack.c
apps/app_talkdetect.c
apps/app_test.c
apps/app_transfer.c
apps/app_verbose.c
apps/app_voicemail.c
apps/app_waitforsilence.c
apps/app_while.c
apps/app_zapateller.c
bridges/bridge_builtin_features.c
bridges/bridge_multiplexed.c
bridges/bridge_simple.c
cdr/cdr_custom.c
cdr/cdr_manager.c
cdr/cdr_sqlite3_custom.c
cdr/cdr_syslog.c
channels/chan_agent.c
channels/chan_alsa.c
channels/chan_bridge.c
channels/chan_console.c
channels/chan_dahdi.c
channels/chan_gtalk.c
channels/chan_h323.c
channels/chan_iax2.c
channels/chan_jingle.c
channels/chan_local.c
channels/chan_mgcp.c
channels/chan_misdn.c
channels/chan_multicast_rtp.c
channels/chan_nbs.c
channels/chan_oss.c
channels/chan_phone.c
channels/chan_sip.c
channels/chan_skinny.c
channels/chan_unistim.c
channels/chan_usbradio.c
channels/chan_vpb.cc
channels/sig_analog.c
channels/sig_pri.c
channels/sig_ss7.c
channels/sip/dialplan_functions.c
funcs/func_callerid.c
funcs/func_cdr.c
funcs/func_channel.c
funcs/func_jitterbuffer.c
funcs/func_timeout.c
include/asterisk/channel.h
include/asterisk/sched.h
main/abstract_jb.c
main/app.c
main/audiohook.c
main/bridging.c
main/ccss.c
main/cdr.c
main/cel.c
main/channel.c
main/channel_internal_api.c
main/cli.c
main/devicestate.c
main/dial.c
main/features.c
main/file.c
main/framehook.c
main/image.c
main/manager.c
main/message.c
main/pbx.c
main/rtp_engine.c
main/udptl.c
pbx/pbx_lua.c
pbx/pbx_realtime.c
res/res_adsi.c
res/res_agi.c
res/res_calendar.c
res/res_fax.c
res/res_monitor.c
res/res_musiconhold.c
res/res_rtp_asterisk.c
res/snmp/agent.c

index 3f849d1..e0f95e1 100644 (file)
@@ -843,16 +843,16 @@ static struct ast_channel *mbl_new(int state, struct mbl_pvt *pvt, char *cid_num
                goto e_return;
        }
 
-       chn->tech = &mbl_tech;
-       ast_format_cap_add(chn->nativeformats, &prefformat);
+       ast_channel_tech_set(chn, &mbl_tech);
+       ast_format_cap_add(ast_channel_nativeformats(chn), &prefformat);
        ast_format_copy(&chn->rawreadformat, &prefformat);
        ast_format_copy(&chn->rawwriteformat, &prefformat);
        ast_format_copy(&chn->writeformat, &prefformat);
        ast_format_copy(&chn->readformat, &prefformat);
-       chn->tech_pvt = pvt;
+       ast_channel_tech_pvt_set(chn, pvt);
 
        if (state == AST_STATE_RING)
-               chn->rings = 1;
+               ast_channel_rings_set(chn, 1);
 
        ast_channel_language_set(chn, "en");
        pvt->owner = chn;
@@ -947,7 +947,7 @@ static int mbl_call(struct ast_channel *ast, const char *dest, int timeout)
 
        dest_dev = ast_strdupa(dest);
 
-       pvt = ast->tech_pvt;
+       pvt = ast_channel_tech_pvt(ast);
 
        if (pvt->type == MBL_TYPE_PHONE) {
                dest_num = strchr(dest_dev, '/');
@@ -958,7 +958,7 @@ static int mbl_call(struct ast_channel *ast, const char *dest, int timeout)
                *dest_num++ = 0x00;
        }
 
-       if ((ast->_state != AST_STATE_DOWN) && (ast->_state != AST_STATE_RESERVED)) {
+       if ((ast_channel_state(ast) != AST_STATE_DOWN) && (ast_channel_state(ast) != AST_STATE_RESERVED)) {
                ast_log(LOG_WARNING, "mbl_call called on %s, neither down nor reserved\n", ast_channel_name(ast));
                return -1;
        }
@@ -1001,11 +1001,11 @@ static int mbl_hangup(struct ast_channel *ast)
 
        struct mbl_pvt *pvt;
 
-       if (!ast->tech_pvt) {
+       if (!ast_channel_tech_pvt(ast)) {
                ast_log(LOG_WARNING, "Asked to hangup channel not connected\n");
                return 0;
        }
-       pvt = ast->tech_pvt;
+       pvt = ast_channel_tech_pvt(ast);
 
        ast_debug(1, "[%s] hanging up device\n", pvt->id);
 
@@ -1024,7 +1024,7 @@ static int mbl_hangup(struct ast_channel *ast)
        pvt->incoming = 0;
        pvt->needring = 0;
        pvt->owner = NULL;
-       ast->tech_pvt = NULL;
+       ast_channel_tech_pvt_set(ast, NULL);
 
        ast_mutex_unlock(&pvt->lock);
 
@@ -1039,7 +1039,7 @@ static int mbl_answer(struct ast_channel *ast)
 
        struct mbl_pvt *pvt;
 
-       pvt = ast->tech_pvt;
+       pvt = ast_channel_tech_pvt(ast);
 
        if (pvt->type == MBL_TYPE_HEADSET)
                return 0;
@@ -1058,7 +1058,7 @@ static int mbl_answer(struct ast_channel *ast)
 
 static int mbl_digit_end(struct ast_channel *ast, char digit, unsigned int duration)
 {
-       struct mbl_pvt *pvt = ast->tech_pvt;
+       struct mbl_pvt *pvt = ast_channel_tech_pvt(ast);
 
        if (pvt->type == MBL_TYPE_HEADSET)
                return 0;
@@ -1080,7 +1080,7 @@ static int mbl_digit_end(struct ast_channel *ast, char digit, unsigned int durat
 static struct ast_frame *mbl_read(struct ast_channel *ast)
 {
 
-       struct mbl_pvt *pvt = ast->tech_pvt;
+       struct mbl_pvt *pvt = ast_channel_tech_pvt(ast);
        struct ast_frame *fr = &ast_null_frame;
        int r;
 
@@ -1134,7 +1134,7 @@ e_return:
 static int mbl_write(struct ast_channel *ast, struct ast_frame *frame)
 {
 
-       struct mbl_pvt *pvt = ast->tech_pvt;
+       struct mbl_pvt *pvt = ast_channel_tech_pvt(ast);
        struct ast_frame *f;
 
        ast_debug(3, "*** mbl_write\n");
@@ -1162,7 +1162,7 @@ static int mbl_write(struct ast_channel *ast, struct ast_frame *frame)
 static int mbl_fixup(struct ast_channel *oldchan, struct ast_channel *newchan)
 {
 
-       struct mbl_pvt *pvt = newchan->tech_pvt;
+       struct mbl_pvt *pvt = ast_channel_tech_pvt(newchan);
 
        if (!pvt) {
                ast_debug(1, "fixup failed, no pvt on newchan\n");
index 74b7a2f..b91fac3 100644 (file)
@@ -382,26 +382,26 @@ static struct ast_channel *ooh323_new(struct ooh323_pvt *i, int state,
 
        if (ch) {
                ast_channel_lock(ch);
-               ch->tech = &ooh323_tech;
+               ast_channel_tech_set(ch, &ooh323_tech);
 
                if (cap)
                        ast_best_codec(cap, &tmpfmt);
                if (!tmpfmt.id)
                        ast_codec_pref_index(&i->prefs, 0, &tmpfmt);
 
-               ast_format_cap_add(ch->nativeformats, &tmpfmt);
+               ast_format_cap_add(ast_channel_nativeformats(ch), &tmpfmt);
                ast_format_copy(&ch->rawwriteformat, &tmpfmt);
                ast_format_copy(&ch->rawreadformat, &tmpfmt);
 
                ast_jb_configure(ch, &global_jbconf);
 
                if (state == AST_STATE_RING)
-                       ch->rings = 1;
+                       ast_channel_rings_set(ch, 1);
 
-               ch->adsicpe = AST_ADSI_UNAVAILABLE;
+               ast_channel_adsicpe_set(ch, AST_ADSI_UNAVAILABLE);
                ast_set_write_format(ch, &tmpfmt);
                ast_set_read_format(ch, &tmpfmt);
-               ch->tech_pvt = i;
+               ast_channel_tech_pvt_set(ch, i);
                i->owner = ch;
                ast_module_ref(myself);
 
@@ -439,7 +439,7 @@ static struct ast_channel *ooh323_new(struct ooh323_pvt *i, int state,
                ast_channel_context_set(ch, i->context);
                ast_channel_exten_set(ch, i->exten);
 
-               ch->priority = 1;
+               ast_channel_priority_set(ch, 1);
 
                if(!ast_test_flag(i, H323_OUTGOING)) {
                
@@ -464,7 +464,7 @@ static struct ast_channel *ooh323_new(struct ooh323_pvt *i, int state,
                        ast_channel_accountcode_set(ch, i->accountcode);
                
                if (i->amaflags)
-                       ch->amaflags = i->amaflags;
+                       ast_channel_amaflags_set(ch, i->amaflags);
 
                ast_setstate(ch, state);
                if (state != AST_STATE_DOWN) {
@@ -860,7 +860,7 @@ struct ooh323_peer *find_peer(const char * name, int port)
 static int ooh323_digit_begin(struct ast_channel *chan, char digit)
 {
        char dtmf[2];
-       struct ooh323_pvt *p = (struct ooh323_pvt *) chan->tech_pvt;
+       struct ooh323_pvt *p = (struct ooh323_pvt *) ast_channel_tech_pvt(chan);
        int res = 0;
        
        if (gH323Debug)
@@ -893,7 +893,7 @@ static int ooh323_digit_begin(struct ast_channel *chan, char digit)
 
 static int ooh323_digit_end(struct ast_channel *chan, char digit, unsigned int duration)
 {
-       struct ooh323_pvt *p = (struct ooh323_pvt *) chan->tech_pvt;
+       struct ooh323_pvt *p = (struct ooh323_pvt *) ast_channel_tech_pvt(chan);
        int res = 0;
 
        if (gH323Debug)
@@ -922,7 +922,7 @@ static int ooh323_digit_end(struct ast_channel *chan, char digit, unsigned int d
 
 static int ooh323_call(struct ast_channel *ast, const char *dest, int timeout)
 {
-       struct ooh323_pvt *p = ast->tech_pvt;
+       struct ooh323_pvt *p = ast_channel_tech_pvt(ast);
        char destination[256];
        int res=0, i;
        const char *val = NULL;
@@ -938,7 +938,7 @@ static int ooh323_call(struct ast_channel *ast, const char *dest, int timeout)
                ast_verb(0, "---   ooh323_call- %s\n", dest);
 
 
-       if ((ast->_state != AST_STATE_DOWN) && (ast->_state != AST_STATE_RESERVED)) {
+       if ((ast_channel_state(ast) != AST_STATE_DOWN) && (ast_channel_state(ast) != AST_STATE_RESERVED)) {
                ast_log(LOG_WARNING, "ooh323_call called on %s, neither down nor "
                                                                "reserved\n", ast_channel_name(ast));
                return -1;
@@ -994,7 +994,7 @@ static int ooh323_call(struct ast_channel *ast, const char *dest, int timeout)
 
        destination[sizeof(destination)-1]='\0';
 
-       opts.transfercap = ast->transfercapability;
+       opts.transfercap = ast_channel_transfercapability(ast);
        opts.fastStart = p->faststart;
        opts.tunneling = p->h245tunneling;
 
@@ -1019,7 +1019,7 @@ static int ooh323_call(struct ast_channel *ast, const char *dest, int timeout)
 
 static int ooh323_hangup(struct ast_channel *ast)
 {
-       struct ooh323_pvt *p = ast->tech_pvt;
+       struct ooh323_pvt *p = ast_channel_tech_pvt(ast);
        int q931cause = AST_CAUSE_NORMAL_CLEARING;
 
        if (gH323Debug)
@@ -1028,8 +1028,8 @@ static int ooh323_hangup(struct ast_channel *ast)
        if (p) {
                ast_mutex_lock(&p->lock);
 
-        if (ast->hangupcause) {
-                q931cause = ast->hangupcause;
+        if (ast_channel_hangupcause(ast)) {
+                q931cause = ast_channel_hangupcause(ast);
         } else {
                 const char *cause = pbx_builtin_getvar_helper(ast, "DIALSTATUS");
                 if (cause) {
@@ -1051,7 +1051,7 @@ static int ooh323_hangup(struct ast_channel *ast)
 
                if (gH323Debug)
                        ast_verb(0, "    hanging %s with cause: %d\n", p->username, q931cause);
-               ast->tech_pvt = NULL; 
+               ast_channel_tech_pvt_set(ast, NULL); 
                if (!ast_test_flag(p, H323_ALREADYGONE)) {
                        ooHangCall(p->callToken, 
                                ooh323_convert_hangupcause_asteriskToH323(q931cause), q931cause);
@@ -1061,7 +1061,7 @@ static int ooh323_hangup(struct ast_channel *ast)
                        ast_set_flag(p, H323_NEEDDESTROY);
                /* detach channel here */
                if (p->owner) {
-                       p->owner->tech_pvt = NULL;
+                       ast_channel_tech_pvt_set(p->owner, NULL);
                        p->owner = NULL;
                        ast_module_unref(myself);
                }
@@ -1086,7 +1086,7 @@ static int ooh323_hangup(struct ast_channel *ast)
 
 static int ooh323_answer(struct ast_channel *ast)
 {
-       struct ooh323_pvt *p = ast->tech_pvt;
+       struct ooh323_pvt *p = ast_channel_tech_pvt(ast);
        char *callToken = (char *)NULL;
 
        if (gH323Debug)
@@ -1096,7 +1096,7 @@ static int ooh323_answer(struct ast_channel *ast)
 
                ast_mutex_lock(&p->lock);
                callToken = (p->callToken ? strdup(p->callToken) : NULL);
-               if (ast->_state != AST_STATE_UP) {
+               if (ast_channel_state(ast) != AST_STATE_UP) {
                        ast_channel_lock(ast);
                        if (!p->alertsent) {
                                if (gH323Debug) {
@@ -1129,7 +1129,7 @@ static struct ast_frame *ooh323_read(struct ast_channel *ast)
 {
        struct ast_frame *fr;
        static struct ast_frame null_frame = { AST_FRAME_NULL, };
-       struct ooh323_pvt *p = ast->tech_pvt;
+       struct ooh323_pvt *p = ast_channel_tech_pvt(ast);
 
        if (!p) return &null_frame;
 
@@ -1145,7 +1145,7 @@ static struct ast_frame *ooh323_read(struct ast_channel *ast)
 
 static int ooh323_write(struct ast_channel *ast, struct ast_frame *f)
 {
-       struct ooh323_pvt *p = ast->tech_pvt;
+       struct ooh323_pvt *p = ast_channel_tech_pvt(ast);
        int res = 0;
        char buf[256];
 
@@ -1171,12 +1171,12 @@ static int ooh323_write(struct ast_channel *ast, struct ast_frame *f)
                        }
 
 
-                       if (!(ast_format_cap_iscompatible(ast->nativeformats, &f->subclass.format))) {
-                               if (!(ast_format_cap_is_empty(ast->nativeformats))) {
+                       if (!(ast_format_cap_iscompatible(ast_channel_nativeformats(ast), &f->subclass.format))) {
+                               if (!(ast_format_cap_is_empty(ast_channel_nativeformats(ast)))) {
                                        ast_log(LOG_WARNING,
                                                        "Asked to transmit frame type %s, while native formats is %s (read/write = %s/%s)\n",
                                                        ast_getformatname(&f->subclass.format),
-                                                       ast_getformatname_multiple(buf, sizeof(buf), ast->nativeformats),
+                                                       ast_getformatname_multiple(buf, sizeof(buf), ast_channel_nativeformats(ast)),
                                                        ast_getformatname(&ast->readformat),
                                                        ast_getformatname(&ast->writeformat));
 
@@ -1212,7 +1212,7 @@ static int ooh323_write(struct ast_channel *ast, struct ast_frame *f)
 static int ooh323_indicate(struct ast_channel *ast, int condition, const void *data, size_t datalen)
 {
 
-       struct ooh323_pvt *p = (struct ooh323_pvt *) ast->tech_pvt;
+       struct ooh323_pvt *p = (struct ooh323_pvt *) ast_channel_tech_pvt(ast);
        char *callToken = (char *)NULL;
        int res = -1;
 
@@ -1256,7 +1256,7 @@ static int ooh323_indicate(struct ast_channel *ast, int condition, const void *d
                ast_moh_stop(ast);
                break;
        case AST_CONTROL_PROGRESS:
-               if (ast->_state != AST_STATE_UP) {
+               if (ast_channel_state(ast) != AST_STATE_UP) {
                        if (!p->progsent) {
                                if (gH323Debug) {
                                        ast_debug(1, "Sending manual progress for %s, res = %d\n", callToken,
@@ -1269,7 +1269,7 @@ static int ooh323_indicate(struct ast_channel *ast, int condition, const void *d
                }
            break;
       case AST_CONTROL_RINGING:
-               if (ast->_state == AST_STATE_RING || ast->_state == AST_STATE_RINGING) {
+               if (ast_channel_state(ast) == AST_STATE_RING || ast_channel_state(ast) == AST_STATE_RINGING) {
                        if (!p->alertsent) {
                                if (gH323Debug) {
                                        ast_debug(1, "Sending manual ringback for %s, res = %d\n",
@@ -1391,7 +1391,7 @@ static int ooh323_indicate(struct ast_channel *ast, int condition, const void *d
 static int ooh323_queryoption(struct ast_channel *ast, int option, void *data, int *datalen)
 {
 
-       struct ooh323_pvt *p = (struct ooh323_pvt *) ast->tech_pvt;
+       struct ooh323_pvt *p = (struct ooh323_pvt *) ast_channel_tech_pvt(ast);
        int res = -1;
        enum ast_t38_state state = T38_STATE_UNAVAILABLE;
        char* cp;
@@ -1452,7 +1452,7 @@ static int ooh323_queryoption(struct ast_channel *ast, int option, void *data, i
 
 static int ooh323_fixup(struct ast_channel *oldchan, struct ast_channel *newchan)
 {
-       struct ooh323_pvt *p = newchan->tech_pvt;
+       struct ooh323_pvt *p = ast_channel_tech_pvt(newchan);
 
        if (!p) return -1;
 
@@ -1513,7 +1513,7 @@ void ooh323_set_write_format(ooCallData *call, struct ast_format *fmt, int txfra
                if (gH323Debug)
                        ast_verb(0, "Writeformat before update %s/%s\n", 
                          ast_getformatname(&p->owner->writeformat),
-                         ast_getformatname_multiple(formats, sizeof(formats), p->owner->nativeformats));
+                         ast_getformatname_multiple(formats, sizeof(formats), ast_channel_nativeformats(p->owner)));
                if (txframes)
                        ast_codec_pref_setsize(&p->prefs, fmt, txframes);
                ast_rtp_codecs_packetization_set(ast_rtp_instance_get_codecs(p->rtp), p->rtp, &p->prefs);
@@ -1526,7 +1526,7 @@ void ooh323_set_write_format(ooCallData *call, struct ast_format *fmt, int txfra
                                 p->rtp, p->dtmfcodec, "audio", "cisco-telephone-event", 0);
                }
 
-               ast_format_cap_set(p->owner->nativeformats, fmt);
+               ast_format_cap_set(ast_channel_nativeformats(p->owner), fmt);
                ast_set_write_format(p->owner, &p->owner->writeformat);
                ast_set_read_format(p->owner, &p->owner->readformat);
                ast_channel_unlock(p->owner);
@@ -1572,7 +1572,7 @@ void ooh323_set_read_format(ooCallData *call, struct ast_format *fmt)
                if (gH323Debug)
                        ast_verb(0, "Readformat before update %s\n", 
                                  ast_getformatname(&p->owner->readformat));
-               ast_format_cap_set(p->owner->nativeformats, fmt);
+               ast_format_cap_set(ast_channel_nativeformats(p->owner), fmt);
                ast_set_read_format(p->owner, &p->owner->readformat);
                ast_channel_unlock(p->owner);
        } else
@@ -1628,7 +1628,7 @@ int onAlerting(ooCallData *call)
                connected.source = AST_CONNECTED_LINE_UPDATE_SOURCE_ANSWER;
                ast_channel_queue_connected_line_update(c, &connected, &update_connected);
        }
-       if (c->_state != AST_STATE_UP)
+       if (ast_channel_state(c) != AST_STATE_UP)
                ast_setstate(c, AST_STATE_RINGING);
 
        ast_queue_control(c, AST_CONTROL_RINGING);
@@ -1684,7 +1684,7 @@ int onProgress(ooCallData *call)
                connected.source = AST_CONNECTED_LINE_UPDATE_SOURCE_ANSWER;
                ast_channel_queue_connected_line_update(c, &connected, &update_connected);
        }
-       if (c->_state != AST_STATE_UP)
+       if (ast_channel_state(c) != AST_STATE_UP)
                ast_setstate(c, AST_STATE_RINGING);
 
        ast_queue_control(c, AST_CONTROL_PROGRESS);
@@ -2154,14 +2154,14 @@ int onCallCleared(ooCallData *call)
                if (!ast_test_flag(p, H323_ALREADYGONE)) { 
 
                        ast_set_flag(p, H323_ALREADYGONE);
-                       p->owner->hangupcause = call->q931cause;
+                       ast_channel_hangupcause_set(p->owner, call->q931cause);
                        p->owner->_softhangup |= AST_SOFTHANGUP_DEV;
                        ast_queue_hangup_with_cause(p->owner,call->q931cause);
                }
        }
 
        if(p->owner) {
-               p->owner->tech_pvt = NULL;
+               ast_channel_tech_pvt_set(p->owner, NULL);
                ast_channel_unlock(p->owner);
                p->owner = NULL;
                ast_module_unref(myself);
@@ -3419,7 +3419,7 @@ static struct ast_cli_entry cli_ooh323[] = {
 /*! \brief OOH323 Dialplan function - reads ooh323 settings */
 static int function_ooh323_read(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len)
 {
-       struct ooh323_pvt *p = chan->tech_pvt;
+       struct ooh323_pvt *p = ast_channel_tech_pvt(chan);
 
        ast_channel_lock(chan);
        if (!p) {
@@ -3427,8 +3427,8 @@ static int function_ooh323_read(struct ast_channel *chan, const char *cmd, char
                return -1;
        }
 
-       if (strcmp(chan->tech->type, "OOH323")) {
-               ast_log(LOG_ERROR, "This function is only supported on OOH323 channels, Channel is %s\n", chan->tech->type);
+       if (strcmp(ast_channel_tech(chan)->type, "OOH323")) {
+               ast_log(LOG_ERROR, "This function is only supported on OOH323 channels, Channel is %s\n", ast_channel_tech(chan)->type);
                ast_channel_unlock(chan);
                return -1;
        }
@@ -3464,7 +3464,7 @@ static int function_ooh323_read(struct ast_channel *chan, const char *cmd, char
 /*! \brief OOH323 Dialplan function - writes ooh323 settings */
 static int function_ooh323_write(struct ast_channel *chan, const char *cmd, char *data, const char *value)
 {
-       struct ooh323_pvt *p = chan->tech_pvt;
+       struct ooh323_pvt *p = ast_channel_tech_pvt(chan);
        int res = -1;
 
        ast_channel_lock(chan);
@@ -3473,8 +3473,8 @@ static int function_ooh323_write(struct ast_channel *chan, const char *cmd, char
                return -1;
        }
 
-       if (strcmp(chan->tech->type, "OOH323")) {
-               ast_log(LOG_ERROR, "This function is only supported on OOH323 channels, Channel is %s\n", chan->tech->type);
+       if (strcmp(ast_channel_tech(chan)->type, "OOH323")) {
+               ast_log(LOG_ERROR, "This function is only supported on OOH323 channels, Channel is %s\n", ast_channel_tech(chan)->type);
                ast_channel_unlock(chan);
                return -1;
        }
@@ -3857,7 +3857,7 @@ int ooh323_destroy(struct ooh323_pvt *p)
                                DEADLOCK_AVOIDANCE(&cur->lock);
                        }           
                        ast_debug(1, "Detaching from %s\n", ast_channel_name(cur->owner));
-                       cur->owner->tech_pvt = NULL;
+                       ast_channel_tech_pvt_set(cur->owner, NULL);
                        ast_channel_unlock(cur->owner);
                        cur->owner = NULL;
                        ast_module_unref(myself);
@@ -4092,7 +4092,7 @@ static enum ast_rtp_glue_result ooh323_get_rtp_peer(struct ast_channel *chan, st
        struct ooh323_pvt *p = NULL;
        enum ast_rtp_glue_result res = AST_RTP_GLUE_RESULT_LOCAL;
 
-       if (!(p = (struct ooh323_pvt *) chan->tech_pvt))
+       if (!(p = (struct ooh323_pvt *) ast_channel_tech_pvt(chan)))
                return AST_RTP_GLUE_RESULT_FORBID;
 
        if (!(p->rtp)) {
@@ -4115,7 +4115,7 @@ static enum ast_rtp_glue_result ooh323_get_vrtp_peer(struct ast_channel *chan, s
        struct ooh323_pvt *p = NULL;
        enum ast_rtp_glue_result res = AST_RTP_GLUE_RESULT_LOCAL;
 
-       if (!(p = (struct ooh323_pvt *) chan->tech_pvt))
+       if (!(p = (struct ooh323_pvt *) ast_channel_tech_pvt(chan)))
                return AST_RTP_GLUE_RESULT_FORBID;
 
        if (!(p->rtp)) {
@@ -4200,7 +4200,7 @@ static int ooh323_set_rtp_peer(struct ast_channel *chan, struct ast_rtp_instance
                ast_log(LOG_WARNING, "Unknown format.\n");
                return -1;
        }
-       p = (struct ooh323_pvt *) chan->tech_pvt;
+       p = (struct ooh323_pvt *) ast_channel_tech_pvt(chan);
        if (!p) {
                ast_log(LOG_ERROR, "No Private Structure, this is bad\n");
                return -1;
@@ -4415,7 +4415,7 @@ static struct ast_udptl *ooh323_get_udptl_peer(struct ast_channel *chan)
        struct ooh323_pvt *p;
        struct ast_udptl *udptl = NULL;
 
-       p = chan->tech_pvt;
+       p = ast_channel_tech_pvt(chan);
        if (!p)
                return NULL;
 
@@ -4430,7 +4430,7 @@ static int ooh323_set_udptl_peer(struct ast_channel *chan, struct ast_udptl *udp
 {
        struct ooh323_pvt *p;
 
-       p = chan->tech_pvt;
+       p = ast_channel_tech_pvt(chan);
        if (!p)
                return -1;
        ast_mutex_lock(&p->lock);
@@ -4589,7 +4589,7 @@ struct ast_frame *ooh323_rtp_read(struct ast_channel *ast, struct ooh323_pvt *p)
        struct ast_frame *f;
        struct ast_frame *dfr = NULL;
        static struct ast_frame null_frame = { AST_FRAME_NULL, };
-       switch (ast->fdno) {
+       switch (ast_channel_fdno(ast)) {
        case 0:
                f = ast_rtp_instance_read(p->rtp, 0);   /* RTP Audio */
                break;
@@ -4616,9 +4616,9 @@ struct ast_frame *ooh323_rtp_read(struct ast_channel *ast, struct ooh323_pvt *p)
 
        if (f && p->owner && !p->faxmode && (f->frametype == AST_FRAME_VOICE)) {
                /* We already hold the channel lock */
-               if (!(ast_format_cap_iscompatible(p->owner->nativeformats, &f->subclass.format))) {
+               if (!(ast_format_cap_iscompatible(ast_channel_nativeformats(p->owner), &f->subclass.format))) {
                        ast_debug(1, "Oooh, voice format changed to %s\n", ast_getformatname(&f->subclass.format));
-                       ast_format_cap_set(p->owner->nativeformats, &f->subclass.format);
+                       ast_format_cap_set(ast_channel_nativeformats(p->owner), &f->subclass.format);
                        ast_set_read_format(p->owner, &p->owner->readformat);
                        ast_set_write_format(p->owner, &p->owner->writeformat);
                }
index 44782f0..c4309e0 100644 (file)
@@ -266,7 +266,7 @@ static int receive_dtmf_digits(struct ast_channel *chan, char *digit_string, int
                /* If they hung up, leave */
                if ((f->frametype == AST_FRAME_CONTROL) && (f->subclass.integer == AST_CONTROL_HANGUP)) {
                        if (f->data.uint32) {
-                               chan->hangupcause = f->data.uint32;
+                               ast_channel_hangupcause_set(chan, f->data.uint32);
                        }
                        ast_frfree(f);
                        res = -1;
@@ -597,7 +597,7 @@ static int alarmreceiver_exec(struct ast_channel *chan, const char *data)
 
        /* Answer the channel if it is not already */
        ast_verb(4, "AlarmReceiver: Answering channel\n");
-       if (chan->_state != AST_STATE_UP) {
+       if (ast_channel_state(chan) != AST_STATE_UP) {
                if ((res = ast_answer(chan)))
                        return -1;
        }
index 45e6d96..fbb4300 100644 (file)
@@ -133,7 +133,7 @@ static int auth_exec(struct ast_channel *chan, const char *data)
                return -1;
        }
 
-       if (chan->_state != AST_STATE_UP) {
+       if (ast_channel_state(chan) != AST_STATE_UP) {
                if ((res = ast_answer(chan)))
                        return -1;
        }
index 2f227b0..3c24471 100644 (file)
@@ -52,8 +52,8 @@ static const char nocdr_app[] = "NoCDR";
 
 static int nocdr_exec(struct ast_channel *chan, const char *data)
 {
-       if (chan->cdr)
-               ast_set_flag(chan->cdr, AST_CDR_FLAG_POST_DISABLED);
+       if (ast_channel_cdr(chan))
+               ast_set_flag(ast_channel_cdr(chan), AST_CDR_FLAG_POST_DISABLED);
 
        return 0;
 }
index 37ba214..fd88b91 100644 (file)
@@ -169,7 +169,7 @@ static int chanavail_exec(struct ast_channel *chan, const char *data)
                        }
                        snprintf(tmp, sizeof(tmp), "%d", status);
                        ast_str_append(&tmp_availstat, 0, "%s%s", ast_str_strlen(tmp_availstat) ? "&" : "", tmp);
-                       if ((inuse <= 1) && (tempchan = ast_request(tech, chan->nativeformats, chan, number, &status))) {
+                       if ((inuse <= 1) && (tempchan = ast_request(tech, ast_channel_nativeformats(chan), chan, number, &status))) {
                                        ast_str_append(&tmp_availchan, 0, "%s%s", ast_str_strlen(tmp_availchan) ? "&" : "", ast_channel_name(tempchan));
                                        
                                        snprintf(tmp, sizeof(tmp), "%s/%s", tech, number);
index 8fe543d..bea7a91 100644 (file)
@@ -96,7 +96,7 @@ static int asyncgoto_exec(struct ast_channel *chan, const char *data)
                return 0;
        }
 
-       if (chan2->pbx) {
+       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 */
        }
 
index b56672d..621f98b 100644 (file)
@@ -787,7 +787,7 @@ static int common_exec(struct ast_channel *chan, struct ast_flags *flags,
                ast_channel_unlock(chan);
        }
 
-       if (chan->_state != AST_STATE_UP)
+       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 */
index 8c03509..4e9d5a5 100644 (file)
@@ -378,8 +378,8 @@ static struct ast_channel *rec_request(const char *type, struct ast_format_cap *
                return NULL;
        }
        ast_format_set(&fmt, AST_FORMAT_SLINEAR, 0);
-       tmp->tech = &record_tech;
-       ast_format_cap_add_all(tmp->nativeformats);
+       ast_channel_tech_set(tmp, &record_tech);
+       ast_format_cap_add_all(ast_channel_nativeformats(tmp));
        ast_format_copy(&tmp->writeformat, &fmt);
        ast_format_copy(&tmp->rawwriteformat, &fmt);
        ast_format_copy(&tmp->readformat, &fmt);
@@ -873,7 +873,7 @@ static void destroy_conference_bridge(void *obj)
        ast_mutex_destroy(&conference_bridge->playback_lock);
 
        if (conference_bridge->playback_chan) {
-               struct ast_channel *underlying_channel = conference_bridge->playback_chan->tech->bridged_channel(conference_bridge->playback_chan, NULL);
+               struct ast_channel *underlying_channel = ast_channel_tech(conference_bridge->playback_chan)->bridged_channel(conference_bridge->playback_chan, NULL);
                if (underlying_channel) {
                        ast_hangup(underlying_channel);
                }
@@ -1159,10 +1159,10 @@ static int play_sound_helper(struct conference_bridge *conference_bridge, const
                        ast_mutex_unlock(&conference_bridge->playback_lock);
                        return -1;
                }
-               underlying_channel = conference_bridge->playback_chan->tech->bridged_channel(conference_bridge->playback_chan, NULL);
+               underlying_channel = ast_channel_tech(conference_bridge->playback_chan)->bridged_channel(conference_bridge->playback_chan, NULL);
        } else {
                /* Channel was already available so we just need to add it back into the bridge */
-               underlying_channel = conference_bridge->playback_chan->tech->bridged_channel(conference_bridge->playback_chan, NULL);
+               underlying_channel = ast_channel_tech(conference_bridge->playback_chan)->bridged_channel(conference_bridge->playback_chan, NULL);
                ast_bridge_impart(conference_bridge->bridge, underlying_channel, NULL, NULL, 0);
        }
 
@@ -1333,7 +1333,7 @@ static int confbridge_exec(struct ast_channel *chan, const char *data)
        );
        ast_bridge_features_init(&conference_bridge_user.features);
 
-       if (chan->_state != AST_STATE_UP) {
+       if (ast_channel_state(chan) != AST_STATE_UP) {
                ast_answer(chan);
        }
 
@@ -1729,14 +1729,14 @@ static int action_dialplan_exec(struct ast_bridge_channel *bridge_channel, struc
        /*save off*/
        exten = ast_strdupa(ast_channel_exten(bridge_channel->chan));
        context = ast_strdupa(ast_channel_context(bridge_channel->chan));
-       priority = bridge_channel->chan->priority;
-       pbx = bridge_channel->chan->pbx;
-       bridge_channel->chan->pbx = NULL;
+       priority = ast_channel_priority(bridge_channel->chan);
+       pbx = ast_channel_pbx(bridge_channel->chan);
+       ast_channel_pbx_set(bridge_channel->chan, NULL);
 
        /*set new*/
        ast_channel_exten_set(bridge_channel->chan, menu_action->data.dialplan_args.exten);
        ast_channel_context_set(bridge_channel->chan, menu_action->data.dialplan_args.context);
-       bridge_channel->chan->priority = menu_action->data.dialplan_args.priority;
+       ast_channel_priority_set(bridge_channel->chan, menu_action->data.dialplan_args.priority);
 
        ast_channel_unlock(bridge_channel->chan);
 
@@ -1748,8 +1748,8 @@ static int action_dialplan_exec(struct ast_bridge_channel *bridge_channel, struc
 
        ast_channel_exten_set(bridge_channel->chan, exten);
        ast_channel_context_set(bridge_channel->chan, context);
-       bridge_channel->chan->priority = priority;
-       bridge_channel->chan->pbx = pbx;
+       ast_channel_priority_set(bridge_channel->chan, priority);
+       ast_channel_pbx_set(bridge_channel->chan, pbx);
 
        ast_channel_unlock(bridge_channel->chan);
 
index 5384c68..4fde466 100644 (file)
@@ -127,7 +127,7 @@ static int conf_run(struct ast_channel *chan, int confno, int confflags)
                goto outrun;
        }
        ast_indicate(chan, -1);
-       retrydahdi = strcasecmp(chan->tech->type, "DAHDI");
+       retrydahdi = strcasecmp(ast_channel_tech(chan)->type, "DAHDI");
 dahdiretry:
        origfd = chan->fds[0];
        if (retrydahdi) {
@@ -277,7 +277,7 @@ static int conf_exec(struct ast_channel *chan, const char *data)
                }
        }
        
-       if (chan->_state != AST_STATE_UP)
+       if (ast_channel_state(chan) != AST_STATE_UP)
                ast_answer(chan);
 
        while(!confno && (++retrycnt < 4)) {
index dcf0caf..e6b080f 100644 (file)
@@ -200,9 +200,9 @@ static int dahdiras_exec(struct ast_channel *chan, const char *data)
        args = ast_strdupa(data);
        
        /* Answer the channel if it's not up */
-       if (chan->_state != AST_STATE_UP)
+       if (ast_channel_state(chan) != AST_STATE_UP)
                ast_answer(chan);
-       if (strcasecmp(chan->tech->type, "DAHDI")) {
+       if (strcasecmp(ast_channel_tech(chan)->type, "DAHDI")) {
                /* If it's not a DAHDI channel, we're done.  Wait a couple of
                   seconds and then hangup... */
                ast_verb(2, "Channel %s is not a DAHDI channel\n", ast_channel_name(chan));
index 7543bd2..03eae32 100644 (file)
@@ -658,8 +658,8 @@ END_OPTIONS );
        OPT_CALLER_HANGUP | OPT_CALLEE_TRANSFER | OPT_CALLER_TRANSFER | \
        OPT_CALLEE_MONITOR | OPT_CALLER_MONITOR | OPT_CALLEE_PARK |  \
        OPT_CALLER_PARK | OPT_ANNOUNCE | OPT_CALLEE_MACRO | OPT_CALLEE_GOSUB) && \
-       !chan->audiohooks && !peer->audiohooks && \
-       ast_framehook_list_is_empty(chan->framehooks) && ast_framehook_list_is_empty(peer->framehooks))
+       !ast_channel_audiohooks(chan) && !ast_channel_audiohooks(peer) && \
+       ast_framehook_list_is_empty(ast_channel_framehooks(chan)) && ast_framehook_list_is_empty(ast_channel_framehooks(peer)))
 
 /*
  * The list of active channels
@@ -695,7 +695,7 @@ static void hanguptree(struct chanlist *outgoing, struct ast_channel *exception,
                                /* The flag is used for local channel inheritance and stuff */
                                ast_set_flag(outgoing->chan, AST_FLAG_ANSWERED_ELSEWHERE);
                                /* This is for the channel drivers */
-                               outgoing->chan->hangupcause = AST_CAUSE_ANSWERED_ELSEWHERE;
+                               ast_channel_hangupcause_set(outgoing->chan, AST_CAUSE_ANSWERED_ELSEWHERE);
                        }
                        ast_hangup(outgoing->chan);
                }
@@ -719,7 +719,7 @@ struct cause_args {
 
 static void handle_cause(int cause, struct cause_args *num)
 {
-       struct ast_cdr *cdr = num->chan->cdr;
+       struct ast_cdr *cdr = ast_channel_cdr(num->chan);
 
        switch(cause) {
        case AST_CAUSE_BUSY:
@@ -869,7 +869,7 @@ static void do_forward(struct chanlist *o,
                cause = AST_CAUSE_BUSY;
        } else {
                /* Setup parameters */
-               c = o->chan = ast_request(tech, in->nativeformats, in, stuff, &cause);
+               c = o->chan = ast_request(tech, ast_channel_nativeformats(in), in, stuff, &cause);
                if (c) {
                        if (single)
                                ast_channel_make_compatible(o->chan, in);
@@ -1039,7 +1039,7 @@ static struct ast_channel *wait_for_answer(struct ast_channel *in,
                                 */
                                *to = -1;
                                strcpy(pa->status, "CONGESTION");
-                               ast_cdr_failed(in->cdr);
+                               ast_cdr_failed(ast_channel_cdr(in));
                                return NULL;
                        }
                }
@@ -1100,7 +1100,7 @@ static struct ast_channel *wait_for_answer(struct ast_channel *in,
 
                        if (c == NULL)
                                continue;
-                       if (ast_test_flag64(o, DIAL_STILLGOING) && c->_state == AST_STATE_UP) {
+                       if (ast_test_flag64(o, DIAL_STILLGOING) && ast_channel_state(c) == AST_STATE_UP) {
                                if (!peer) {
                                        ast_verb(3, "%s answered %s\n", ast_channel_name(c), ast_channel_name(in));
                                        if (!single && !ast_test_flag64(peerflags, OPT_IGNORE_CONNECTEDLINE)) {
@@ -1157,14 +1157,14 @@ static struct ast_channel *wait_for_answer(struct ast_channel *in,
                        }
                        f = ast_read(winner);
                        if (!f) {
-                               in->hangupcause = c->hangupcause;
+                               ast_channel_hangupcause_set(in, ast_channel_hangupcause(c));
 #ifdef HAVE_EPOLL
                                ast_poll_channel_del(in, c);
 #endif
                                ast_hangup(c);
                                c = o->chan = NULL;
                                ast_clear_flag64(o, DIAL_STILLGOING);
-                               handle_cause(in->hangupcause, &num);
+                               handle_cause(ast_channel_hangupcause(in), &num);
                                continue;
                        }
                        if (f->frametype == AST_FRAME_CONTROL) {
@@ -1196,9 +1196,9 @@ static struct ast_channel *wait_for_answer(struct ast_channel *in,
                                                        }
                                                }
                                                peer = c;
-                                               if (peer->cdr) {
-                                                       peer->cdr->answer = ast_tvnow();
-                                                       peer->cdr->disposition = AST_CDR_ANSWERED;
+                                               if (ast_channel_cdr(peer)) {
+                                                       ast_channel_cdr(peer)->answer = ast_tvnow();
+                                                       ast_channel_cdr(peer)->disposition = AST_CDR_ANSWERED;
                                                }
                                                ast_copy_flags64(peerflags, o,
                                                        OPT_CALLEE_TRANSFER | OPT_CALLER_TRANSFER |
@@ -1214,12 +1214,12 @@ static struct ast_channel *wait_for_answer(struct ast_channel *in,
                                                        ast_channel_early_bridge(in, peer);
                                        }
                                        /* If call has been answered, then the eventual hangup is likely to be normal hangup */
-                                       in->hangupcause = AST_CAUSE_NORMAL_CLEARING;
-                                       c->hangupcause = AST_CAUSE_NORMAL_CLEARING;
+                                       ast_channel_hangupcause_set(in, AST_CAUSE_NORMAL_CLEARING);
+                                       ast_channel_hangupcause_set(c, AST_CAUSE_NORMAL_CLEARING);
                                        break;
                                case AST_CONTROL_BUSY:
                                        ast_verb(3, "%s is busy\n", ast_channel_name(c));
-                                       in->hangupcause = c->hangupcause;
+                                       ast_channel_hangupcause_set(in, ast_channel_hangupcause(c));
                                        ast_hangup(c);
                                        c = o->chan = NULL;
                                        ast_clear_flag64(o, DIAL_STILLGOING);
@@ -1227,7 +1227,7 @@ static struct ast_channel *wait_for_answer(struct ast_channel *in,
                                        break;
                                case AST_CONTROL_CONGESTION:
                                        ast_verb(3, "%s is circuit-busy\n", ast_channel_name(c));
-                                       in->hangupcause = c->hangupcause;
+                                       ast_channel_hangupcause_set(in, ast_channel_hangupcause(c));
                                        ast_hangup(c);
                                        c = o->chan = NULL;
                                        ast_clear_flag64(o, DIAL_STILLGOING);
@@ -1404,10 +1404,10 @@ static struct ast_channel *wait_for_answer(struct ast_channel *in,
                                /* Got hung up */
                                *to = -1;
                                strcpy(pa->status, "CANCEL");
-                               ast_cdr_noanswer(in->cdr);
+                               ast_cdr_noanswer(ast_channel_cdr(in));
                                if (f) {
                                        if (f->data.uint32) {
-                                               in->hangupcause = f->data.uint32;
+                                               ast_channel_hangupcause_set(in, f->data.uint32);
                                        }
                                        ast_frfree(f);
                                }
@@ -1426,7 +1426,7 @@ static struct ast_channel *wait_for_answer(struct ast_channel *in,
                                        if (onedigit_goto(in, context, (char) f->subclass.integer, 1)) {
                                                ast_verb(3, "User hit %c to disconnect call.\n", f->subclass.integer);
                                                *to = 0;
-                                               ast_cdr_noanswer(in->cdr);
+                                               ast_cdr_noanswer(ast_channel_cdr(in));
                                                *result = f->subclass.integer;
                                                strcpy(pa->status, "CANCEL");
                                                ast_frfree(f);
@@ -1444,7 +1444,7 @@ static struct ast_channel *wait_for_answer(struct ast_channel *in,
                                        ast_verb(3, "User requested call disconnect.\n");
                                        *to = 0;
                                        strcpy(pa->status, "CANCEL");
-                                       ast_cdr_noanswer(in->cdr);
+                                       ast_cdr_noanswer(ast_channel_cdr(in));
                                        ast_frfree(f);
                                        if (is_cc_recall) {
                                                ast_cc_completed(in, "CC completed, but the caller hung up with DTMF");
@@ -1510,7 +1510,7 @@ static struct ast_channel *wait_for_answer(struct ast_channel *in,
                if (!*to)
                        ast_verb(3, "Nobody picked up in %d ms\n", orig);
                if (!*to || ast_check_hangup(in))
-                       ast_cdr_noanswer(in->cdr);
+                       ast_cdr_noanswer(ast_channel_cdr(in));
        }
 
 #ifdef HAVE_EPOLL
@@ -1807,20 +1807,20 @@ static void end_bridge_callback(void *data)
        time_t end;
        struct ast_channel *chan = data;
 
-       if (!chan->cdr) {
+       if (!ast_channel_cdr(chan)) {
                return;
        }
 
        time(&end);
 
        ast_channel_lock(chan);
-       if (chan->cdr->answer.tv_sec) {
-               snprintf(buf, sizeof(buf), "%ld", (long) end - chan->cdr->answer.tv_sec);
+       if (ast_channel_cdr(chan)->answer.tv_sec) {
+               snprintf(buf, sizeof(buf), "%ld", (long) end - ast_channel_cdr(chan)->answer.tv_sec);
                pbx_builtin_setvar_helper(chan, "ANSWEREDTIME", buf);
        }
 
-       if (chan->cdr->start.tv_sec) {
-               snprintf(buf, sizeof(buf), "%ld", (long) end - chan->cdr->start.tv_sec);
+       if (ast_channel_cdr(chan)->start.tv_sec) {
+               snprintf(buf, sizeof(buf), "%ld", (long) end - ast_channel_cdr(chan)->start.tv_sec);
                pbx_builtin_setvar_helper(chan, "DIALEDTIME", buf);
        }
        ast_channel_unlock(chan);
@@ -1841,7 +1841,7 @@ static int dial_handle_playtones(struct ast_channel *chan, const char *data)
                return -1;
        }
 
-       ts = ast_get_indication_tone(chan->zone, str);
+       ts = ast_get_indication_tone(ast_channel_zone(chan), str);
 
        if (ts && ts->data[0]) {
                res = ast_playtones_start(chan, 0, ts->data, 0);
@@ -2081,8 +2081,8 @@ static int dial_exec_full(struct ast_channel *chan, const char *data, struct ast
                ast_channel_unlock(chan);
        }
 
-       if (ast_test_flag64(&opts, OPT_RESETCDR) && chan->cdr)
-               ast_cdr_reset(chan->cdr, NULL);
+       if (ast_test_flag64(&opts, OPT_RESETCDR) && ast_channel_cdr(chan))
+               ast_cdr_reset(ast_channel_cdr(chan), NULL);
        if (ast_test_flag64(&opts, OPT_PRIVACY) && ast_strlen_zero(opt_args[OPT_ARG_PRIVACY]))
                opt_args[OPT_ARG_PRIVACY] = ast_strdupa(ast_channel_exten(chan));
 
@@ -2211,14 +2211,14 @@ static int dial_exec_full(struct ast_channel *chan, const char *data, struct ast
                        AST_LIST_UNLOCK(dialed_interfaces);
                }
 
-               tc = ast_request(tech, chan->nativeformats, chan, numsubst, &cause);
+               tc = ast_request(tech, ast_channel_nativeformats(chan), chan, numsubst, &cause);
                if (!tc) {
                        /* If we can't, just go on to the next call */
                        ast_log(LOG_WARNING, "Unable to create channel of type '%s' (cause %d - %s)\n",
                                tech, cause, ast_cause2str(cause));
                        handle_cause(cause, &num);
                        if (!rest) /* we are on the last destination */
-                               chan->hangupcause = cause;
+                               ast_channel_hangupcause_set(chan, cause);
                        chanlist_free(tmp);
                        if (!ignore_cc && (cause == AST_CAUSE_BUSY || cause == AST_CAUSE_CONGESTION)) {
                                if (!ast_cc_callback(chan, tech, numsubst, ast_cc_busy_interface)) {
@@ -2312,8 +2312,8 @@ static int dial_exec_full(struct ast_channel *chan, const char *data, struct ast
                        ast_channel_musicclass_set(tc, ast_channel_musicclass(chan));
 
                /* Pass ADSI CPE and transfer capability */
-               tc->adsicpe = chan->adsicpe;
-               tc->transfercapability = chan->transfercapability;
+               ast_channel_adsicpe_set(tc, ast_channel_adsicpe(chan));
+               ast_channel_transfercapability_set(tc, ast_channel_transfercapability(chan));
 
                /* If we have an outbound group, set this peer channel to it */
                if (outbound_group)
@@ -2340,16 +2340,16 @@ static int dial_exec_full(struct ast_channel *chan, const char *data, struct ast
                ast_channel_lock(chan);
 
                /* Save the info in cdr's that we called them */
-               if (chan->cdr)
-                       ast_cdr_setdestchan(chan->cdr, ast_channel_name(tc));
+               if (ast_channel_cdr(chan))
+                       ast_cdr_setdestchan(ast_channel_cdr(chan), ast_channel_name(tc));
 
                /* check the results of ast_call */
                if (res) {
                        /* Again, keep going even if there's an error */
                        ast_debug(1, "ast call on peer returned %d\n", res);
                        ast_verb(3, "Couldn't call %s/%s\n", tech, numsubst);
-                       if (tc->hangupcause) {
-                               chan->hangupcause = tc->hangupcause;
+                       if (ast_channel_hangupcause(tc)) {
+                               ast_channel_hangupcause_set(chan, ast_channel_hangupcause(tc));
                        }
                        ast_channel_unlock(chan);
                        ast_cc_call_failed(chan, tc, interface);
@@ -2370,7 +2370,7 @@ static int dial_exec_full(struct ast_channel *chan, const char *data, struct ast
                tmp->next = outgoing;
                outgoing = tmp;
                /* If this line is up, don't try anybody else */
-               if (outgoing->chan->_state == AST_STATE_UP)
+               if (ast_channel_state(outgoing->chan) == AST_STATE_UP)
                        break;
        }
        
@@ -2458,9 +2458,9 @@ static int dial_exec_full(struct ast_channel *chan, const char *data, struct ast
                hanguptree(outgoing, peer, 1);
                outgoing = NULL;
                /* If appropriate, log that we have a destination channel and set the answer time */
-               if (chan->cdr) {
-                       ast_cdr_setdestchan(chan->cdr, ast_channel_name(peer));
-                       ast_cdr_setanswer(chan->cdr, peer->cdr->answer);
+               if (ast_channel_cdr(chan)) {
+                       ast_cdr_setdestchan(ast_channel_cdr(chan), ast_channel_name(peer));
+                       ast_cdr_setanswer(ast_channel_cdr(chan), ast_channel_cdr(peer)->answer);
                }
                if (ast_channel_name(peer))
                        pbx_builtin_setvar_helper(chan, "DIALEDPEERNAME", ast_channel_name(peer));
@@ -2502,10 +2502,10 @@ static int dial_exec_full(struct ast_channel *chan, const char *data, struct ast
                        }
 
                        ast_set_flag(peer, AST_FLAG_END_DTMF_ONLY);
-                       while (peer->stream) {
+                       while (ast_channel_stream(peer)) {
                                int ms;
 
-                               ms = ast_sched_wait(peer->sched);
+                               ms = ast_sched_wait(ast_channel_sched(peer));
 
                                if (ms < 0 && !peer->timingfunc) {
                                        ast_stopstream(peer);
@@ -2547,7 +2547,7 @@ static int dial_exec_full(struct ast_channel *chan, const char *data, struct ast
                                        }
                                        ast_frfree(fr);
                                }
-                               ast_sched_runq(peer->sched);
+                               ast_sched_runq(ast_channel_sched(peer));
                        }
                        ast_clear_flag(peer, AST_FLAG_END_DTMF_ONLY);
                }
@@ -2555,15 +2555,15 @@ static int dial_exec_full(struct ast_channel *chan, const char *data, struct ast
                if (chan && peer && ast_test_flag64(&opts, OPT_GOTO) && !ast_strlen_zero(opt_args[OPT_ARG_GOTO])) {
                        /* chan and peer are going into the PBX, they both
                         * should probably get CDR records. */
-                       ast_clear_flag(chan->cdr, AST_CDR_FLAG_DIALED);
-                       ast_clear_flag(peer->cdr, AST_CDR_FLAG_DIALED);
+                       ast_clear_flag(ast_channel_cdr(chan), AST_CDR_FLAG_DIALED);
+                       ast_clear_flag(ast_channel_cdr(peer), AST_CDR_FLAG_DIALED);
 
                        replace_macro_delimiter(opt_args[OPT_ARG_GOTO]);
                        ast_parseable_goto(chan, opt_args[OPT_ARG_GOTO]);
                        /* peer goes to the same context and extension as chan, so just copy info from chan*/
                        ast_channel_context_set(peer, ast_channel_context(chan));
                        ast_channel_exten_set(peer, ast_channel_exten(chan));
-                       peer->priority = chan->priority + 2;
+                       ast_channel_priority_set(peer, ast_channel_priority(chan) + 2);
                        ast_pbx_start(peer);
                        hanguptree(outgoing, NULL, ast_test_flag64(&opts, OPT_CANCEL_ELSEWHERE) ? 1 : 0);
                        if (continue_exec)
@@ -2659,7 +2659,7 @@ static int dial_exec_full(struct ast_channel *chan, const char *data, struct ast
                                /* Set where we came from */
                                ast_channel_context_set(peer, "app_dial_gosub_virtual_context");
                                ast_channel_exten_set(peer, "s");
-                               peer->priority = 0;
+                               ast_channel_priority_set(peer, 0);
 
                                gosub_argstart = strchr(opt_args[OPT_ARG_CALLEE_GOSUB], ',');
                                if (gosub_argstart) {
@@ -2808,7 +2808,7 @@ static int dial_exec_full(struct ast_channel *chan, const char *data, struct ast
                        }
                        /* Be sure no generators are left on it and reset the visible indication */
                        ast_deactivate_generator(chan);
-                       chan->visible_indication = 0;
+                       ast_channel_visible_indication_set(chan, 0);
                        /* Make sure channels are compatible */
                        res = ast_channel_make_compatible(chan, peer);
                        if (res < 0) {
@@ -2838,21 +2838,21 @@ static int dial_exec_full(struct ast_channel *chan, const char *data, struct ast
                        int res9;
                        
                        ast_channel_exten_set(peer, "h");
-                       peer->priority = 1;
+                       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);
 
                        while ((res9 = ast_spawn_extension(peer, ast_channel_context(peer), ast_channel_exten(peer),
-                               peer->priority,
+                               ast_channel_priority(peer),
                                S_COR(peer->caller.id.number.valid, peer->caller.id.number.str, NULL),
                                &found, 1)) == 0) {
-                               peer->priority++;
+                               ast_channel_priority_set(peer, ast_channel_priority(peer) + 1);
                        }
 
                        if (found && res9) {
                                /* Something bad happened, or a hangup has been requested. */
-                               ast_debug(1, "Spawn extension (%s,%s,%d) exited non-zero on '%s'\n", ast_channel_context(peer), ast_channel_exten(peer), peer->priority, 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), peer->priority, ast_channel_name(peer));
+                               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 */
                }
@@ -2862,7 +2862,7 @@ static int dial_exec_full(struct ast_channel *chan, const char *data, struct ast
                                ast_parseable_goto(peer, opt_args[OPT_ARG_CALLEE_GO_ON]);
                        } else { /* F() */
                                int res;
-                               res = ast_goto_if_exists(peer, ast_channel_context(chan), ast_channel_exten(chan), (chan->priority) + 1); 
+                               res = ast_goto_if_exists(peer, ast_channel_context(chan), ast_channel_exten(chan), (ast_channel_priority(chan)) + 1); 
                                if (res == AST_PBX_GOTO_FAILED) {
                                        ast_hangup(peer);
                                        goto out;
@@ -2871,7 +2871,7 @@ static int dial_exec_full(struct ast_channel *chan, const char *data, struct ast
                        ast_pbx_start(peer);
                } else {
                        if (!ast_check_hangup(chan))
-                               chan->hangupcause = peer->hangupcause;
+                               ast_channel_hangupcause_set(chan, ast_channel_hangupcause(peer));
                        ast_hangup(peer);
                }
        }
index 6b20017..2158b8c 100644 (file)
@@ -132,7 +132,7 @@ static int dictate_exec(struct ast_channel *chan, const char *data)
                return -1;
        }
 
-       if (chan->_state != AST_STATE_UP) {
+       if (ast_channel_state(chan) != AST_STATE_UP) {
                ast_answer(chan);
        }
        ast_safe_sleep(chan, 200);
@@ -278,7 +278,7 @@ static int dictate_exec(struct ast_channel *chan, const char *data)
                                                        if (!(fs = ast_openstream(chan, path, ast_channel_language(chan))))
                                                                break;
                                                        ast_seekstream(fs, samples, SEEK_SET);
-                                                       chan->stream = NULL;
+                                                       ast_channel_stream_set(chan, NULL);
                                                }
                                                lastop = DMODE_PLAY;
                                        }
index 4db404c..52e8722 100644 (file)
@@ -824,7 +824,7 @@ static int directory_exec(struct ast_channel *chan, const char *data)
        }
        digits[7] = digit + '0';
 
-       if (chan->_state != AST_STATE_UP) {
+       if (ast_channel_state(chan) != AST_STATE_UP) {
                if (!ast_test_flag(&flags, OPT_NOANSWER)) {
                        /* Otherwise answer unless we're supposed to read while on-hook */
                        res = ast_answer(chan);
index 7d92b76..5de3acf 100644 (file)
@@ -131,9 +131,9 @@ static void play_dialtone(struct ast_channel *chan, char *mailbox)
        struct ast_tone_zone_sound *ts = NULL;
 
        if (ast_app_has_voicemail(mailbox, NULL)) {
-               ts = ast_get_indication_tone(chan->zone, "dialrecall");
+               ts = ast_get_indication_tone(ast_channel_zone(chan), "dialrecall");
        } else {
-               ts = ast_get_indication_tone(chan->zone, "dial");
+               ts = ast_get_indication_tone(ast_channel_zone(chan), "dial");
        }
 
        if (ts) {
@@ -147,8 +147,8 @@ static void play_dialtone(struct ast_channel *chan, char *mailbox)
 static int disa_exec(struct ast_channel *chan, const char *data)
 {
        int i = 0, j, k = 0, did_ignore = 0, special_noanswer = 0;
-       int firstdigittimeout = (chan->pbx ? chan->pbx->rtimeoutms : 20000);
-       int digittimeout = (chan->pbx ? chan->pbx->dtimeoutms : 10000);
+       int firstdigittimeout = (ast_channel_pbx(chan) ? ast_channel_pbx(chan)->rtimeoutms : 20000);
+       int digittimeout = (ast_channel_pbx(chan) ? ast_channel_pbx(chan)->dtimeoutms : 10000);
        struct ast_flags flags;
        char *tmp, exten[AST_MAX_EXTENSION] = "", acctcode[20]="";
        char pwline[256];
@@ -187,7 +187,7 @@ static int disa_exec(struct ast_channel *chan, const char *data)
        ast_debug(1, "Mailbox: %s\n",args.mailbox);
 
        if (!ast_test_flag(&flags, NOANSWER_FLAG)) {
-               if (chan->_state != AST_STATE_UP) {
+               if (ast_channel_state(chan) != AST_STATE_UP) {
                        /* answer */
                        ast_answer(chan);
                }
@@ -226,7 +226,7 @@ static int disa_exec(struct ast_channel *chan, const char *data)
 
                if ((f->frametype == AST_FRAME_CONTROL) && (f->subclass.integer == AST_CONTROL_HANGUP)) {
                        if (f->data.uint32)
-                               chan->hangupcause = f->data.uint32;
+                               ast_channel_hangupcause_set(chan, f->data.uint32);
                        ast_frfree(f);
                        ast_clear_flag(chan, AST_FLAG_END_DTMF_ONLY);
                        return -1;
@@ -380,7 +380,7 @@ static int disa_exec(struct ast_channel *chan, const char *data)
                                ast_channel_accountcode_set(chan, acctcode);
 
                        if (special_noanswer) cdr_flags.flags = 0;
-                       ast_cdr_reset(chan->cdr, &cdr_flags);
+                       ast_cdr_reset(ast_channel_cdr(chan), &cdr_flags);
                        ast_explicit_goto(chan, args.context, exten, 1);
                        return 0;
                }
index 8e9c749..27e79e1 100644 (file)
@@ -83,8 +83,8 @@ static int serialize_showchan(struct ast_channel *c, char *buf, size_t size)
        if (!c)
                return 0;
 
-       if (c->cdr) {
-               elapsed_seconds = now.tv_sec - c->cdr->start.tv_sec;
+       if (ast_channel_cdr(c)) {
+               elapsed_seconds = now.tv_sec - ast_channel_cdr(c)->start.tv_sec;
                hour = elapsed_seconds / 3600;
                min = (elapsed_seconds % 3600) / 60;
                sec = elapsed_seconds % 60;
@@ -128,7 +128,7 @@ static int serialize_showchan(struct ast_channel *c, char *buf, size_t size)
                "Data=               %s\n"
                "Blocking_in=        %s\n",
                ast_channel_name(c),
-               c->tech->type,
+               ast_channel_tech(c)->type,
                ast_channel_uniqueid(c),
                ast_channel_linkedid(c),
                S_COR(c->caller.id.number.valid, c->caller.id.number.str, "(N/A)"),
@@ -139,21 +139,21 @@ static int serialize_showchan(struct ast_channel *c, char *buf, size_t size)
                S_COR(c->redirecting.from.number.valid, c->redirecting.from.number.str, "(N/A)"),
                ast_channel_parkinglot(c),
                ast_channel_language(c),        
-               ast_state2str(c->_state),
-               c->_state,
-               c->rings, 
-               ast_getformatname_multiple(nf, sizeof(nf), c->nativeformats),
+               ast_state2str(ast_channel_state(c)),
+               ast_channel_state(c),
+               ast_channel_rings(c), 
+               ast_getformatname_multiple(nf, sizeof(nf), ast_channel_nativeformats(c)),
                ast_getformatname(&c->writeformat),
                ast_getformatname(&c->readformat),
                ast_getformatname(&c->rawwriteformat),
                ast_getformatname(&c->rawreadformat),
-               c->writetrans ? "Yes" : "No",
-               ast_translate_path_to_str(c->writetrans, &write_transpath),
-               c->readtrans ? "Yes" : "No",
-               ast_translate_path_to_str(c->readtrans, &read_transpath),
+               ast_channel_writetrans(c) ? "Yes" : "No",
+               ast_translate_path_to_str(ast_channel_writetrans(c), &write_transpath),
+               ast_channel_readtrans(c) ? "Yes" : "No",
+               ast_translate_path_to_str(ast_channel_readtrans(c), &read_transpath),
                c->fds[0],
-               c->fin & ~DEBUGCHAN_FLAG, (c->fin & DEBUGCHAN_FLAG) ? " (DEBUGGED)" : "",
-               c->fout & ~DEBUGCHAN_FLAG, (c->fout & DEBUGCHAN_FLAG) ? " (DEBUGGED)" : "",
+               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)c->whentohangup.tv_sec,
                hour,
                min,
@@ -162,7 +162,7 @@ static int serialize_showchan(struct ast_channel *c, char *buf, size_t size)
                ast_bridged_channel(c) ? ast_channel_name(ast_bridged_channel(c)) : "<none>", 
                ast_channel_context(c),
                ast_channel_exten(c),
-               c->priority,
+               ast_channel_priority(c),
                ast_print_group(cgrp, sizeof(cgrp), c->callgroup),
                ast_print_group(pgrp, sizeof(pgrp), c->pickupgroup),
                ast_channel_appl(c) ? ast_channel_appl(c) : "(N/A)",
index 2f34b9f..a8a7fd8 100644 (file)
@@ -59,7 +59,7 @@ static int echo_exec(struct ast_channel *chan, const char *data)
        int res = -1;
        struct ast_format format;
 
-       ast_best_codec(chan->nativeformats, &format);
+       ast_best_codec(ast_channel_nativeformats(chan), &format);
        ast_set_write_format(chan, &format);
        ast_set_read_format(chan, &format);
 
index 9377d23..5873a64 100644 (file)
@@ -188,7 +188,7 @@ static void gen_closestream(struct gen_state *state)
                return;
 
        ast_closestream(state->stream);
-       state->u->chan->stream = NULL;
+       ast_channel_stream_set(state->u->chan, NULL);
        state->stream = NULL;
 }
 
@@ -477,7 +477,7 @@ static int app_exec(struct ast_channel *chan, const char *data)
        
        if (!(ast_test_flag(&flags, noanswer))) {
                ast_verb(3, "Answering channel and starting generator\n");
-               if (chan->_state != AST_STATE_UP) {
+               if (ast_channel_state(chan) != AST_STATE_UP) {
                        if (ast_test_flag(&flags, run_dead)) {
                                ast_chan_log(LOG_ERROR, chan, "Running ExternalIVR with 'd'ead flag on non-hungup channel isn't supported\n");
                                goto exit;
@@ -663,7 +663,7 @@ static int eivr_comm(struct ast_channel *chan, struct ivr_localuser *u,
  
                rchan = ast_waitfor_nandfds(&chan, 1, waitfds, (eivr_errors_fd) ? 2 : 1, &exception, &ready_fd, &ms);
  
-               if (chan->_state == AST_STATE_UP && !AST_LIST_EMPTY(&u->finishlist)) {
+               if (ast_channel_state(chan) == AST_STATE_UP && !AST_LIST_EMPTY(&u->finishlist)) {
                        AST_LIST_LOCK(&u->finishlist);
                        while ((entry = AST_LIST_REMOVE_HEAD(&u->finishlist, list))) {
                                send_eivr_event(eivr_events, 'F', entry->filename, chan);
@@ -672,7 +672,7 @@ static int eivr_comm(struct ast_channel *chan, struct ivr_localuser *u,
                        AST_LIST_UNLOCK(&u->finishlist);
                }
  
-               if (chan->_state == AST_STATE_UP && !(ast_check_hangup(chan)) && rchan) {
+               if (ast_channel_state(chan) == AST_STATE_UP && !(ast_check_hangup(chan)) && rchan) {
                        /* the channel has something */
                        f = ast_read(chan);
                        if (!f) {
@@ -702,7 +702,7 @@ static int eivr_comm(struct ast_channel *chan, struct ivr_localuser *u,
                                ast_verb(3, "Got AST_CONTROL_HANGUP\n");
                                send_eivr_event(eivr_events, 'H', NULL, chan);
                                if (f->data.uint32) {
-                                       chan->hangupcause = f->data.uint32;
+                                       ast_channel_hangupcause_set(chan, f->data.uint32);
                                }
                                ast_frfree(f);
                                break;
@@ -735,7 +735,7 @@ static int eivr_comm(struct ast_channel *chan, struct ivr_localuser *u,
                                ast_eivr_senddtmf(chan, &input[2]);
                        } else if (input[0] == EIVR_CMD_ANS) {
                                ast_verb(3, "Answering channel if needed and starting generator\n");
-                               if (chan->_state != AST_STATE_UP) {
+                               if (ast_channel_state(chan) != AST_STATE_UP) {
                                        if (ast_test_flag(&flags, run_dead)) {
                                                ast_chan_log(LOG_WARNING, chan, "Running ExternalIVR with 'd'ead flag on non-hungup channel isn't supported\n");
                                                send_eivr_event(eivr_events, 'Z', "ANSWER_FAILURE", chan);
@@ -756,7 +756,7 @@ static int eivr_comm(struct ast_channel *chan, struct ivr_localuser *u,
                                        }
                                }
                        } else if (input[0] == EIVR_CMD_SQUE) {
-                               if (chan->_state != AST_STATE_UP || ast_check_hangup(chan)) {
+                               if (ast_channel_state(chan) != AST_STATE_UP || ast_check_hangup(chan)) {
                                        ast_chan_log(LOG_WARNING, chan, "Queue re'S'et called on unanswered channel\n");
                                        send_eivr_event(eivr_events, 'Z', NULL, chan);
                                        continue;
@@ -786,7 +786,7 @@ static int eivr_comm(struct ast_channel *chan, struct ivr_localuser *u,
                                        AST_LIST_UNLOCK(&u->playlist);
                                }
                        } else if (input[0] == EIVR_CMD_APND) {
-                               if (chan->_state != AST_STATE_UP || ast_check_hangup(chan)) {
+                               if (ast_channel_state(chan) != AST_STATE_UP || ast_check_hangup(chan)) {
                                        ast_chan_log(LOG_WARNING, chan, "Queue 'A'ppend called on unanswered channel\n");
                                        send_eivr_event(eivr_events, 'Z', NULL, chan);
                                        continue;
@@ -827,7 +827,7 @@ static int eivr_comm(struct ast_channel *chan, struct ivr_localuser *u,
                                send_eivr_event(eivr_events, 'H', NULL, chan);
                                break;
                        } else if (input[0] == EIVR_CMD_OPT) {
-                               if (chan->_state != AST_STATE_UP || ast_check_hangup(chan)) {
+                               if (ast_channel_state(chan) != AST_STATE_UP || ast_check_hangup(chan)) {
                                        ast_chan_log(LOG_WARNING, chan, "Option called on unanswered channel\n");
                                        send_eivr_event(eivr_events, 'Z', NULL, chan);
                                        continue;
index 3183a56..2c2960e 100644 (file)
@@ -797,7 +797,7 @@ static int transmit(fax_session *s)
        pbx_builtin_setvar_helper(s->chan, "FAXRESOLUTION", NULL);
        pbx_builtin_setvar_helper(s->chan, "FAXBITRATE", NULL); 
 
-       if (s->chan->_state != AST_STATE_UP) {
+       if (ast_channel_state(s->chan) != AST_STATE_UP) {
                /* Shouldn't need this, but checking to see if channel is already answered
                 * Theoretically asterisk should already have answered before running the app */
                res = ast_answer(s->chan);
index d609b3f..cd1cfa0 100644 (file)
@@ -185,7 +185,7 @@ static int send_waveform_to_channel(struct ast_channel *chan, char *waveform, in
        }
 
        /* Answer if it's not already going */
-       if (chan->_state != AST_STATE_UP)
+       if (ast_channel_state(chan) != AST_STATE_UP)
                ast_answer(chan);
        ast_stopstream(chan);
        ast_indicate(chan, -1);
index 283953b..1ee834b 100644 (file)
@@ -79,7 +79,7 @@ static int flash_exec(struct ast_channel *chan, const char *data)
        int x;
        struct dahdi_params dahdip;
 
-       if (strcasecmp(chan->tech->type, "DAHDI")) {
+       if (strcasecmp(ast_channel_tech(chan)->type, "DAHDI")) {
                ast_log(LOG_WARNING, "%s is not a DAHDI channel\n", ast_channel_name(chan));
                return -1;
        }
index 878e2ee..1bf9547 100644 (file)
@@ -520,23 +520,23 @@ static void clear_caller(struct findme_user *tmpuser)
        if (tmpuser && tmpuser->ochan && tmpuser->state >= 0) {
                outbound = tmpuser->ochan;
                ast_channel_lock(outbound);
-               if (!outbound->cdr) {
-                       outbound->cdr = ast_cdr_alloc();
-                       if (outbound->cdr) {
-                               ast_cdr_init(outbound->cdr, outbound);
+               if (!ast_channel_cdr(outbound)) {
+                       ast_channel_cdr_set(outbound, ast_cdr_alloc());
+                       if (ast_channel_cdr(outbound)) {
+                               ast_cdr_init(ast_channel_cdr(outbound), outbound);
                        }
                }
-               if (outbound->cdr) {
+               if (ast_channel_cdr(outbound)) {
                        char tmp[256];
 
                        snprintf(tmp, sizeof(tmp), "%s/%s", "Local", tmpuser->dialarg);
-                       ast_cdr_setapp(outbound->cdr, "FollowMe", tmp);
+                       ast_cdr_setapp(ast_channel_cdr(outbound), "FollowMe", tmp);
                        ast_cdr_update(outbound);
-                       ast_cdr_start(outbound->cdr);
-                       ast_cdr_end(outbound->cdr);
+                       ast_cdr_start(ast_channel_cdr(outbound));
+                       ast_cdr_end(ast_channel_cdr(outbound));
                        /* If the cause wasn't handled properly */
-                       if (ast_cdr_disposition(outbound->cdr, outbound->hangupcause)) {
-                               ast_cdr_failed(outbound->cdr);
+                       if (ast_cdr_disposition(ast_channel_cdr(outbound), ast_channel_hangupcause(outbound))) {
+                               ast_cdr_failed(ast_channel_cdr(outbound));
                        }
                } else {
                        ast_log(LOG_WARNING, "Unable to create Call Detail Record\n");
@@ -624,7 +624,7 @@ static struct ast_channel *wait_for_winner(struct findme_user_listptr *findme_us
                                                tmpuser->state = 1;
                                                tmpuser->digts = 0;
                                                if (!ast_streamfile(tmpuser->ochan, callfromname, ast_channel_language(tmpuser->ochan))) {
-                                                       ast_sched_runq(tmpuser->ochan->sched);
+                                                       ast_sched_runq(ast_channel_sched(tmpuser->ochan));
                                                } else {
                                                        ast_log(LOG_WARNING, "Unable to playback %s.\n", callfromname);
                                                        return NULL;
@@ -633,16 +633,16 @@ static struct ast_channel *wait_for_winner(struct findme_user_listptr *findme_us
                                                tmpuser->state = 2;
                                                tmpuser->digts = 0;
                                                if (!ast_streamfile(tmpuser->ochan, tpargs->norecordingprompt, ast_channel_language(tmpuser->ochan)))
-                                                       ast_sched_runq(tmpuser->ochan->sched);
+                                                       ast_sched_runq(ast_channel_sched(tmpuser->ochan));
                                                else {
                                                        ast_log(LOG_WARNING, "Unable to playback %s.\n", tpargs->norecordingprompt);
                                                        return NULL;
                                                }
                                        }
                                }
-                               if (tmpuser->ochan->stream) {
-                                       ast_sched_runq(tmpuser->ochan->sched);
-                                       tmpto = ast_sched_wait(tmpuser->ochan->sched);
+                               if (ast_channel_stream(tmpuser->ochan)) {
+                                       ast_sched_runq(ast_channel_sched(tmpuser->ochan));
+                                       tmpto = ast_sched_wait(ast_channel_sched(tmpuser->ochan));
                                        if (tmpto > 0 && tmpto < to)
                                                to = tmpto;
                                        else if (tmpto < 0 && !tmpuser->ochan->timingfunc) {
@@ -721,7 +721,7 @@ static struct ast_channel *wait_for_winner(struct findme_user_listptr *findme_us
                                        case AST_CONTROL_HANGUP:
                                                ast_verb(3, "%s received a hangup frame.\n", ast_channel_name(winner));
                                                if (f->data.uint32) {
-                                                       winner->hangupcause = f->data.uint32;
+                                                       ast_channel_hangupcause_set(winner, f->data.uint32);
                                                }
                                                if (dg == 0) {
                                                        ast_verb(3, "The calling channel hungup. Need to drop everyone else.\n");
@@ -732,13 +732,13 @@ static struct ast_channel *wait_for_winner(struct findme_user_listptr *findme_us
                                        case AST_CONTROL_ANSWER:
                                                ast_verb(3, "%s answered %s\n", ast_channel_name(winner), ast_channel_name(caller));
                                                /* If call has been answered, then the eventual hangup is likely to be normal hangup */ 
-                                               winner->hangupcause = AST_CAUSE_NORMAL_CLEARING;
-                                               caller->hangupcause = AST_CAUSE_NORMAL_CLEARING;
+                                               ast_channel_hangupcause_set(winner, AST_CAUSE_NORMAL_CLEARING);
+                                               ast_channel_hangupcause_set(caller, AST_CAUSE_NORMAL_CLEARING);
                                                ast_verb(3, "Starting playback of %s\n", callfromname);
                                                if (dg > 0) {
                                                        if (!ast_strlen_zero(namerecloc)) {
                                                                if (!ast_streamfile(winner, callfromname, ast_channel_language(winner))) {
-                                                                       ast_sched_runq(winner->sched);
+                                                                       ast_sched_runq(ast_channel_sched(winner));
                                                                        tmpuser->state = 1;
                                                                } else {
                                                                        ast_log(LOG_WARNING, "Unable to playback %s.\n", callfromname);
@@ -748,7 +748,7 @@ static struct ast_channel *wait_for_winner(struct findme_user_listptr *findme_us
                                                        } else {
                                                                tmpuser->state = 2;
                                                                if (!ast_streamfile(tmpuser->ochan, tpargs->norecordingprompt, ast_channel_language(tmpuser->ochan)))
-                                                                       ast_sched_runq(tmpuser->ochan->sched);
+                                                                       ast_sched_runq(ast_channel_sched(tmpuser->ochan));
                                                                else {
                                                                        ast_log(LOG_WARNING, "Unable to playback %s.\n", tpargs->norecordingprompt);
                                                                        ast_frfree(f);
@@ -838,7 +838,7 @@ static struct ast_channel *wait_for_winner(struct findme_user_listptr *findme_us
                                        }
                                } 
                                if (tmpuser && tmpuser->state == 3 && f->frametype == AST_FRAME_DTMF) {
-                                       if (winner->stream)
+                                       if (ast_channel_stream(winner))
                                                ast_stopstream(winner);
                                        tmpuser->digts = 0;
                                        ast_debug(1, "DTMF received: %c\n", (char) f->subclass.integer);
@@ -953,7 +953,7 @@ static void findmeexec(struct fm_args *tpargs)
                                continue;
                        }
 
-                       outbound = ast_request("Local", caller->nativeformats, caller, dialarg, &dg);
+                       outbound = ast_request("Local", ast_channel_nativeformats(caller), caller, dialarg, &dg);
                        if (outbound) {
                                ast_channel_lock_both(caller, outbound);
                                ast_connected_line_copy_from_caller(&outbound->connected, &caller->caller);
@@ -974,21 +974,21 @@ static void findmeexec(struct fm_args *tpargs)
                                } else {
                                        ast_verb(3, "couldn't reach at this number.\n");
                                        ast_channel_lock(outbound);
-                                       if (!outbound->cdr) {
-                                               outbound->cdr = ast_cdr_alloc();
+                                       if (!ast_channel_cdr(outbound)) {
+                                               ast_channel_cdr_set(outbound, ast_cdr_alloc());
                                        }
-                                       if (outbound->cdr) {
+                                       if (ast_channel_cdr(outbound)) {
                                                char tmp[256];
 
-                                               ast_cdr_init(outbound->cdr, outbound);
+                                               ast_cdr_init(ast_channel_cdr(outbound), outbound);
                                                snprintf(tmp, sizeof(tmp), "%s/%s", "Local", dialarg);
-                                               ast_cdr_setapp(outbound->cdr, "FollowMe", tmp);
+                                               ast_cdr_setapp(ast_channel_cdr(outbound), "FollowMe", tmp);
                                                ast_cdr_update(outbound);
-                                               ast_cdr_start(outbound->cdr);
-                                               ast_cdr_end(outbound->cdr);
+                                               ast_cdr_start(ast_channel_cdr(outbound));
+                                               ast_cdr_end(ast_channel_cdr(outbound));
                                                /* If the cause wasn't handled properly */
-                                               if (ast_cdr_disposition(outbound->cdr, outbound->hangupcause)) {
-                                                       ast_cdr_failed(outbound->cdr);
+                                               if (ast_cdr_disposition(ast_channel_cdr(outbound), ast_channel_hangupcause(outbound))) {
+                                                       ast_cdr_failed(ast_channel_cdr(outbound));
                                                }
                                        } else {
                                                ast_log(LOG_ERROR, "Unable to create Call Detail Record\n");
@@ -1130,13 +1130,13 @@ static void end_bridge_callback(void *data)
        time(&end);
 
        ast_channel_lock(chan);
-       if (chan->cdr->answer.tv_sec) {
-               snprintf(buf, sizeof(buf), "%ld", (long) end - chan->cdr->answer.tv_sec);
+       if (ast_channel_cdr(chan)->answer.tv_sec) {
+               snprintf(buf, sizeof(buf), "%ld", (long) end - ast_channel_cdr(chan)->answer.tv_sec);
                pbx_builtin_setvar_helper(chan, "ANSWEREDTIME", buf);
        }
 
-       if (chan->cdr->start.tv_sec) {
-               snprintf(buf, sizeof(buf), "%ld", (long) end - chan->cdr->start.tv_sec);
+       if (ast_channel_cdr(chan)->start.tv_sec) {
+               snprintf(buf, sizeof(buf), "%ld", (long) end - ast_channel_cdr(chan)->start.tv_sec);
                pbx_builtin_setvar_helper(chan, "DIALEDTIME", buf);
        }
        ast_channel_unlock(chan);
@@ -1223,7 +1223,7 @@ static int app_exec(struct ast_channel *chan, const char *data)
        ast_mutex_unlock(&f->lock);
 
        /* Forget the 'N' option if the call is already up. */
-       if (chan->_state == AST_STATE_UP) {
+       if (ast_channel_state(chan) == AST_STATE_UP) {
                ast_clear_flag(&targs.followmeflags, FOLLOWMEFLAG_NOANSWER);
        }
 
@@ -1232,7 +1232,7 @@ static int app_exec(struct ast_channel *chan, const char *data)
                ast_indicate(chan, AST_CONTROL_RINGING);
        } else {
                /* Answer the call */
-               if (chan->_state != AST_STATE_UP) {
+               if (ast_channel_state(chan) != AST_STATE_UP) {
                        ast_answer(chan);
                }
 
@@ -1279,7 +1279,7 @@ static int app_exec(struct ast_channel *chan, const char *data)
 
        if (targs.status != 100) {
                if (ast_test_flag(&targs.followmeflags, FOLLOWMEFLAG_NOANSWER)) {
-                       if (chan->_state != AST_STATE_UP) {
+                       if (ast_channel_state(chan) != AST_STATE_UP) {
                                ast_answer(chan);
                        }
                } else {
@@ -1310,7 +1310,7 @@ static int app_exec(struct ast_channel *chan, const char *data)
                }
 
                if (ast_test_flag(&targs.followmeflags, FOLLOWMEFLAG_NOANSWER)) {
-                       if (caller->_state != AST_STATE_UP) {
+                       if (ast_channel_state(caller) != AST_STATE_UP) {
                                ast_answer(caller);
                        }
                } else {
index ffeeca8..c75553c 100644 (file)
@@ -183,7 +183,7 @@ static void ast_cdr_fork(struct ast_channel *chan, struct ast_flags optflags, ch
        struct ast_cdr *newcdr;
        struct ast_flags flags = { AST_CDR_FLAG_KEEP_VARS };
 
-       cdr = chan->cdr;
+       cdr = ast_channel_cdr(chan);
 
        while (cdr->next)
                cdr = cdr->next;
@@ -240,7 +240,7 @@ static int forkcdr_exec(struct ast_channel *chan, const char *data)
                AST_APP_ARG(options);
        );
 
-       if (!chan->cdr) {
+       if (!ast_channel_cdr(chan)) {
                ast_log(LOG_WARNING, "Channel does not have a CDR\n");
                return 0;
        }
@@ -256,7 +256,7 @@ static int forkcdr_exec(struct ast_channel *chan, const char *data)
 
        if (!ast_strlen_zero(data)) {
                int keepvars = ast_test_flag(&flags, OPT_KEEPVARS) ? 1 : 0;
-               ast_set2_flag(chan->cdr, keepvars, AST_CDR_FLAG_KEEP_VARS);
+               ast_set2_flag(ast_channel_cdr(chan), keepvars, AST_CDR_FLAG_KEEP_VARS);
        }
        
        ast_cdr_fork(chan, flags, opts[OPT_ARG_VARSET]);
index 52c03ae..13b27fe 100644 (file)
@@ -135,7 +135,7 @@ static int ices_exec(struct ast_channel *chan, const char *data)
        
        ast_stopstream(chan);
 
-       if (chan->_state != AST_STATE_UP)
+       if (ast_channel_state(chan) != AST_STATE_UP)
                res = ast_answer(chan);
                
        if (res) {
index d035df9..099c67d 100644 (file)
@@ -108,7 +108,7 @@ static int skel_exec(struct ast_channel *chan, const char *data)
 
        /* Do our thing here */
 
-       if (chan->_state != AST_STATE_UP)
+       if (ast_channel_state(chan) != AST_STATE_UP)
                res = ast_answer(chan);
        if (!res)
                res = ast_ivr_menu_run(chan, &ivr_demo, tmp);
index e2b9c92..c324a36 100644 (file)
@@ -329,13 +329,13 @@ static int _macro_exec(struct ast_channel *chan, const char *data, int exclusive
        }
 
        /* Save old info */
-       oldpriority = chan->priority;
+       oldpriority = ast_channel_priority(chan);
        ast_copy_string(oldexten, ast_channel_exten(chan), sizeof(oldexten));
        ast_copy_string(oldcontext, ast_channel_context(chan), sizeof(oldcontext));
        if (ast_strlen_zero(ast_channel_macrocontext(chan))) {
                ast_channel_macrocontext_set(chan, ast_channel_context(chan));
                ast_channel_macroexten_set(chan, ast_channel_exten(chan));
-               chan->macropriority = chan->priority;
+               ast_channel_macropriority_set(chan, ast_channel_priority(chan));
                setmacrocontext=1;
        }
        argc = 1;
@@ -358,7 +358,7 @@ static int _macro_exec(struct ast_channel *chan, const char *data, int exclusive
        /* Setup environment for new run */
        ast_channel_exten_set(chan, "s");
        ast_channel_context_set(chan, fullmacro);
-       chan->priority = 1;
+       ast_channel_priority_set(chan, 1);
 
        ast_channel_lock(chan);
        while((cur = strsep(&rest, ",")) && (argc < MAX_ARGS)) {
@@ -375,7 +375,7 @@ static int _macro_exec(struct ast_channel *chan, const char *data, int exclusive
        ast_channel_unlock(chan);
        autoloopflag = ast_test_flag(chan, AST_FLAG_IN_AUTOLOOP);
        ast_set_flag(chan, AST_FLAG_IN_AUTOLOOP);
-       while (ast_exists_extension(chan, ast_channel_context(chan), ast_channel_exten(chan), chan->priority,
+       while (ast_exists_extension(chan, ast_channel_context(chan), ast_channel_exten(chan), ast_channel_priority(chan),
                S_COR(chan->caller.id.number.valid, chan->caller.id.number.str, NULL))) {
                struct ast_context *c;
                struct ast_exten *e;
@@ -392,7 +392,7 @@ static int _macro_exec(struct ast_channel *chan, const char *data, int exclusive
                                        if (ast_rdlock_context(c)) {
                                                ast_log(LOG_WARNING, "Unable to lock context?\n");
                                        } else {
-                                               e = find_matching_priority(c, ast_channel_exten(chan), chan->priority,
+                                               e = find_matching_priority(c, ast_channel_exten(chan), ast_channel_priority(chan),
                                                        S_COR(chan->caller.id.number.valid, chan->caller.id.number.str, NULL));
                                                if (e) { /* This will only be undefined for pbx_realtime, which is majorly broken. */
                                                        ast_copy_string(runningapp, ast_get_extension_app(e), sizeof(runningapp));
@@ -409,7 +409,7 @@ static int _macro_exec(struct ast_channel *chan, const char *data, int exclusive
                /* Reset the macro depth, if it was changed in the last iteration */
                pbx_builtin_setvar_helper(chan, "MACRO_DEPTH", depthc);
 
-               res = ast_spawn_extension(chan, ast_channel_context(chan), ast_channel_exten(chan), chan->priority,
+               res = ast_spawn_extension(chan, ast_channel_context(chan), ast_channel_exten(chan), ast_channel_priority(chan),
                        S_COR(chan->caller.id.number.valid, chan->caller.id.number.str, NULL),
                        &foundx, 1);
                if (res) {
@@ -425,8 +425,8 @@ static int _macro_exec(struct ast_channel *chan, const char *data, int exclusive
                                res = 0;
                                goto out;
                        default:
-                               ast_debug(2, "Spawn extension (%s,%s,%d) exited non-zero on '%s' in macro '%s'\n", ast_channel_context(chan), ast_channel_exten(chan), chan->priority, ast_channel_name(chan), macro);
-                               ast_verb(2, "Spawn extension (%s, %s, %d) exited non-zero on '%s' in macro '%s'\n", ast_channel_context(chan), ast_channel_exten(chan), chan->priority, ast_channel_name(chan), macro);
+                               ast_debug(2, "Spawn extension (%s,%s,%d) exited non-zero on '%s' in macro '%s'\n", ast_channel_context(chan), ast_channel_exten(chan), ast_channel_priority(chan), ast_channel_name(chan), macro);
+                               ast_verb(2, "Spawn extension (%s, %s, %d) exited non-zero on '%s' in macro '%s'\n", ast_channel_context(chan), ast_channel_exten(chan), ast_channel_priority(chan), ast_channel_name(chan), macro);
                                goto out;
                        }
                }
@@ -499,10 +499,10 @@ static int _macro_exec(struct ast_channel *chan, const char *data, int exclusive
 
                /* don't stop executing extensions when we're in "h" */
                if (ast_check_hangup(chan) && !inhangup) {
-                       ast_debug(1, "Extension %s, macroexten %s, priority %d returned normally even though call was hung up\n", ast_channel_exten(chan), ast_channel_macroexten(chan), chan->priority);
+                       ast_debug(1, "Extension %s, macroexten %s, priority %d returned normally even though call was hung up\n", ast_channel_exten(chan), ast_channel_macroexten(chan), ast_channel_priority(chan));
                        goto out;
                }
-               chan->priority++;
+               ast_channel_priority_set(chan, ast_channel_priority(chan) + 1);
        }
        out:
 
@@ -539,14 +539,14 @@ static int _macro_exec(struct ast_channel *chan, const char *data, int exclusive
        if (setmacrocontext) {
                ast_channel_macrocontext_set(chan, "");
                ast_channel_macroexten_set(chan, "");
-               chan->macropriority = 0;
+               ast_channel_macropriority_set(chan, 0);
        }
 
        if (!strcasecmp(ast_channel_context(chan), fullmacro)) {
                const char *offsets;
 
                /* If we're leaving the macro normally, restore original information */
-               chan->priority = oldpriority;
+               ast_channel_priority_set(chan, oldpriority);
                ast_channel_context_set(chan, oldcontext);
                ast_channel_exten_set(chan, oldexten);
                if ((offsets = pbx_builtin_getvar_helper(chan, "MACRO_OFFSET"))) {
@@ -554,9 +554,9 @@ static int _macro_exec(struct ast_channel *chan, const char *data, int exclusive
                        normally if there is any problem */
                        if (sscanf(offsets, "%30d", &offset) == 1) {
                                if (ast_exists_extension(chan, ast_channel_context(chan), ast_channel_exten(chan),
-                                       chan->priority + offset + 1,
+                                       ast_channel_priority(chan) + offset + 1,
                                        S_COR(chan->caller.id.number.valid, chan->caller.id.number.str, NULL))) {
-                                       chan->priority += offset;
+                                       ast_channel_priority_set(chan, ast_channel_priority(chan) + offset);
                                }
                        }
                }
index 3c8b73f..b6e0c13 100644 (file)
@@ -2174,7 +2174,7 @@ static int can_write(struct ast_channel *chan, struct ast_flags64 *confflags)
                return 1;
        }
 
-       return (chan->_state == AST_STATE_UP);
+       return (ast_channel_state(chan) == AST_STATE_UP);
 }
 
 static void send_talking_event(struct ast_channel *chan, struct ast_conference *conf, struct ast_conf_user *user, int talking)
@@ -2677,7 +2677,7 @@ static int conf_run(struct ast_channel *chan, struct ast_conference *conf, struc
                ast_func_write(chan, "DENOISE(rx)", "on");
        }
 
-       retrydahdi = (strcasecmp(chan->tech->type, "DAHDI") || (chan->audiohooks || chan->monitor) ? 1 : 0);
+       retrydahdi = (strcasecmp(ast_channel_tech(chan)->type, "DAHDI") || (ast_channel_audiohooks(chan) || ast_channel_monitor(chan)) ? 1 : 0);
        user->dahdichannel = !retrydahdi;
 
  dahdiretry:
@@ -3218,14 +3218,14 @@ static int conf_run(struct ast_channel *chan, struct ast_conference *conf, struc
                        if (c) {
                                char dtmfstr[2] = "";
 
-                               if (c->fds[0] != origfd || (user->dahdichannel && (c->audiohooks || c->monitor))) {
+                               if (c->fds[0] != origfd || (user->dahdichannel && (ast_channel_audiohooks(c) || ast_channel_monitor(c)))) {
                                        if (using_pseudo) {
                                                /* Kill old pseudo */
                                                close(fd);
                                                using_pseudo = 0;
                                        }
                                        ast_debug(1, "Ooh, something swapped out under us, starting over\n");
-                                       retrydahdi = (strcasecmp(c->tech->type, "DAHDI") || (c->audiohooks || c->monitor) ? 1 : 0);
+                                       retrydahdi = (strcasecmp(ast_channel_tech(c)->type, "DAHDI") || (ast_channel_audiohooks(c) || ast_channel_monitor(c)) ? 1 : 0);
                                        user->dahdichannel = !retrydahdi;
                                        goto dahdiretry;
                                }
@@ -4244,7 +4244,7 @@ static int count_exec(struct ast_channel *chan, const char *data)
                snprintf(val, sizeof(val), "%d", count);
                pbx_builtin_setvar_helper(chan, args.varname, val);
        } else {
-               if (chan->_state != AST_STATE_UP) {
+               if (ast_channel_state(chan) != AST_STATE_UP) {
                        ast_answer(chan);
                }
                res = ast_say_number(chan, count, "", ast_channel_language(chan), (char *) NULL); /* Needs gender */
@@ -4282,7 +4282,7 @@ static int conf_exec(struct ast_channel *chan, const char *data)
                notdata = data;
        }
        
-       if (chan->_state != AST_STATE_UP)
+       if (ast_channel_state(chan) != AST_STATE_UP)
                ast_answer(chan);
 
        info = ast_strdupa(notdata);
index 412ac1e..4214141 100644 (file)
@@ -127,7 +127,7 @@ static int old_milliwatt_exec(struct ast_channel *chan)
        ast_set_write_format_by_id(chan, AST_FORMAT_ULAW);
        ast_set_read_format_by_id(chan, AST_FORMAT_ULAW);
 
-       if (chan->_state != AST_STATE_UP) {
+       if (ast_channel_state(chan) != AST_STATE_UP) {
                ast_answer(chan);
        }
 
index 9c87a74..bf408f8 100644 (file)
@@ -1945,7 +1945,7 @@ static int leave_voicemail(struct ast_channel *chan, char *username, struct leav
                        ast_channel_context(chan),
                        ast_channel_macrocontext(chan), 
                        ast_channel_exten(chan),
-                       chan->priority,
+                       ast_channel_priority(chan),
                        ast_channel_name(chan),
                        callerid,
                        date, 
@@ -2172,7 +2172,7 @@ static int minivm_record_exec(struct ast_channel *chan, const char *data)
        memset(&leave_options, 0, sizeof(leave_options));
 
        /* Answer channel if it's not already answered */
-       if (chan->_state != AST_STATE_UP)
+       if (ast_channel_state(chan) != AST_STATE_UP)
                ast_answer(chan);
 
        if (ast_strlen_zero(data))  {
@@ -2274,7 +2274,7 @@ static int minivm_greet_exec(struct ast_channel *chan, const char *data)
        }
 
        /* Answer channel if it's not already answered */
-       if (chan->_state != AST_STATE_UP)
+       if (ast_channel_state(chan) != AST_STATE_UP)
                ast_answer(chan);
 
        /* Setup pre-file if appropriate */
@@ -2377,7 +2377,7 @@ static int minivm_greet_exec(struct ast_channel *chan, const char *data)
                } else if (ausemacro && !ast_strlen_zero(ast_channel_macrocontext(chan))) {
                        ast_channel_context_set(chan, ast_channel_macrocontext(chan));
                }
-               chan->priority = 0;
+               ast_channel_priority_set(chan, 0);
                pbx_builtin_setvar_helper(chan, "MVM_GREET_STATUS", "USEREXIT");
                res = 0;
        } else if (res == '0') { /* Check for a '0' here */
@@ -2389,7 +2389,7 @@ static int minivm_greet_exec(struct ast_channel *chan, const char *data)
                                ast_channel_context_set(chan, ast_channel_macrocontext(chan));
                        }
                        ast_play_and_wait(chan, "transfer");
-                       chan->priority = 0;
+                       ast_channel_priority_set(chan, 0);
                        pbx_builtin_setvar_helper(chan, "MVM_GREET_STATUS", "USEREXIT");
                }
                res =  0;
@@ -2518,7 +2518,7 @@ static int minivm_accmess_exec(struct ast_channel *chan, const char *data)
        }
 
        /* Answer channel if it's not already answered */
-       if (chan->_state != AST_STATE_UP)
+       if (ast_channel_state(chan) != AST_STATE_UP)
                ast_answer(chan);
        
        /* Here's where the action is */
index a74d1b5..23f8838 100644 (file)
@@ -2878,9 +2878,9 @@ static int ospfinished_exec(
        }
        ast_debug(1, "OSPFinish: cause '%d'\n", cause);
 
-       if (chan->cdr) {
-               start = chan->cdr->start.tv_sec;
-               connect = chan->cdr->answer.tv_sec;
+       if (ast_channel_cdr(chan)) {
+               start = ast_channel_cdr(chan)->start.tv_sec;
+               connect = ast_channel_cdr(chan)->answer.tv_sec;
                if (connect) {
                        end = time(NULL);
                } else {
index 4b779bd..508c31a 100644 (file)
@@ -142,9 +142,9 @@ static int parkandannounce_exec(struct ast_channel *chan, const char *data)
        }
 
        ast_verb(3, "Return Context: (%s,%s,%d) ID: %s\n", ast_channel_context(chan), ast_channel_exten(chan),
-               chan->priority,
+               ast_channel_priority(chan),
                S_COR(chan->caller.id.number.valid, chan->caller.id.number.str, ""));
-       if (!ast_exists_extension(chan, ast_channel_context(chan), ast_channel_exten(chan), chan->priority,
+       if (!ast_exists_extension(chan, ast_channel_context(chan), ast_channel_exten(chan), ast_channel_priority(chan),
                S_COR(chan->caller.id.number.valid, chan->caller.id.number.str, NULL))) {
                ast_verb(3, "Warning: Return Context Invalid, call will return to default|s\n");
        }
@@ -182,7 +182,7 @@ static int parkandannounce_exec(struct ast_channel *chan, const char *data)
        ast_variables_destroy(oh.vars);
        ast_party_id_free(&caller_id);
        if (dchan) {
-               if (dchan->_state == AST_STATE_UP) {
+               if (ast_channel_state(dchan) == AST_STATE_UP) {
                        ast_verb(4, "Channel %s was answered.\n", ast_channel_name(dchan));
                } else {
                        ast_verb(4, "Channel %s was never answered.\n", ast_channel_name(dchan));
index e9d4d87..18d4c8e 100644 (file)
@@ -454,7 +454,7 @@ static int playback_exec(struct ast_channel *chan, const char *data)
                if (strcasestr(args.options, "noanswer"))
                        option_noanswer = 1;
        } 
-       if (chan->_state != AST_STATE_UP) {
+       if (ast_channel_state(chan) != AST_STATE_UP) {
                if (option_skip) {
                        /* At the user's option, skip if the line is not up */
                        goto done;
index 1e142de..fd947dd 100644 (file)
@@ -87,7 +87,7 @@ static int handle_playtones(struct ast_channel *chan, const char *data)
                return -1;
        }
 
-       ts = ast_get_indication_tone(chan->zone, str);
+       ts = ast_get_indication_tone(ast_channel_zone(chan), str);
 
        if (ts) {
                res = ast_playtones_start(chan, 0, ts->data, 0);
index 6c2c958..d287c56 100644 (file)
@@ -108,7 +108,7 @@ static int privacy_exec(struct ast_channel *chan, const char *data)
                ast_verb(3, "CallerID number present: Skipping\n");
        } else {
                /*Answer the channel if it is not already*/
-               if (chan->_state != AST_STATE_UP) {
+               if (ast_channel_state(chan) != AST_STATE_UP) {
                        if ((res = ast_answer(chan))) {
                                return -1;
                        }
index 2a8b513..0add6c2 100644 (file)
@@ -3096,8 +3096,8 @@ static int ring_entry(struct queue_ent *qe, struct callattempt *tmp, int *busies
        /* on entry here, we know that tmp->chan == NULL */
        if (tmp->member->paused) {
                ast_debug(1, "%s paused, can't receive call\n", tmp->interface);
-               if (qe->chan->cdr) {
-                       ast_cdr_busy(qe->chan->cdr);
+               if (ast_channel_cdr(qe->chan)) {
+                       ast_cdr_busy(ast_channel_cdr(qe->chan));
                }
                tmp->stillgoing = 0;
                return 0;
@@ -3107,8 +3107,8 @@ static int ring_entry(struct queue_ent *qe, struct callattempt *tmp, int *busies
                (!tmp->lastqueue && qe->parent->wrapuptime && (time(NULL) - tmp->lastcall < qe->parent->wrapuptime))) {
                ast_debug(1, "Wrapuptime not yet expired on queue %s for %s\n",
                                (tmp->lastqueue ? tmp->lastqueue->name : qe->parent->name), tmp->interface);
-               if (qe->chan->cdr) {
-                       ast_cdr_busy(qe->chan->cdr);
+               if (ast_channel_cdr(qe->chan)) {
+                       ast_cdr_busy(ast_channel_cdr(qe->chan));
                }
                tmp->stillgoing = 0;
                (*busies)++;
@@ -3126,8 +3126,8 @@ static int ring_entry(struct queue_ent *qe, struct callattempt *tmp, int *busies
                }
                if ((tmp->member->status != AST_DEVICE_NOT_INUSE) && (tmp->member->status != AST_DEVICE_UNKNOWN)) {
                        ast_debug(1, "%s in use, can't receive call\n", tmp->interface);
-                       if (qe->chan->cdr) {
-                               ast_cdr_busy(qe->chan->cdr);
+                       if (ast_channel_cdr(qe->chan)) {
+                               ast_cdr_busy(ast_channel_cdr(qe->chan));
                        }
                        tmp->stillgoing = 0;
                        return 0;
@@ -3136,8 +3136,8 @@ static int ring_entry(struct queue_ent *qe, struct callattempt *tmp, int *busies
 
        if (use_weight && compare_weight(qe->parent,tmp->member)) {
                ast_debug(1, "Priority queue delaying call to %s:%s\n", qe->parent->name, tmp->interface);
-               if (qe->chan->cdr) {
-                       ast_cdr_busy(qe->chan->cdr);
+               if (ast_channel_cdr(qe->chan)) {
+                       ast_cdr_busy(ast_channel_cdr(qe->chan));
                }
                tmp->stillgoing = 0;
                (*busies)++;
@@ -3151,10 +3151,10 @@ static int ring_entry(struct queue_ent *qe, struct callattempt *tmp, int *busies
                location = "";
 
        /* Request the peer */
-       tmp->chan = ast_request(tech, qe->chan->nativeformats, qe->chan, location, &status);
+       tmp->chan = ast_request(tech, ast_channel_nativeformats(qe->chan), qe->chan, location, &status);
        if (!tmp->chan) {                       /* If we can't, just go on to the next call */
-               if (qe->chan->cdr) {
-                       ast_cdr_busy(qe->chan->cdr);
+               if (ast_channel_cdr(qe->chan)) {
+                       ast_cdr_busy(ast_channel_cdr(qe->chan));
                }
                tmp->stillgoing = 0;
 
@@ -3205,7 +3205,7 @@ static int ring_entry(struct queue_ent *qe, struct callattempt *tmp, int *busies
        ast_channel_datastore_inherit(qe->chan, tmp->chan);
 
        /* Presense of ADSI CPE on outgoing channel follows ours */
-       tmp->chan->adsicpe = qe->chan->adsicpe;
+       ast_channel_adsicpe_set(tmp->chan, ast_channel_adsicpe(qe->chan));
 
        /* Inherit context and extension */
        macrocontext = pbx_builtin_getvar_helper(qe->chan, "MACRO_CONTEXT");
@@ -3218,17 +3218,17 @@ static int ring_entry(struct queue_ent *qe, struct callattempt *tmp, int *busies
        if (ast_cdr_isset_unanswered()) {
                /* they want to see the unanswered dial attempts! */
                /* set up the CDR fields on all the CDRs to give sensical information */
-               ast_cdr_setdestchan(tmp->chan->cdr, ast_channel_name(tmp->chan));
-               strcpy(tmp->chan->cdr->clid, qe->chan->cdr->clid);
-               strcpy(tmp->chan->cdr->channel, qe->chan->cdr->channel);
-               strcpy(tmp->chan->cdr->src, qe->chan->cdr->src);
-               strcpy(tmp->chan->cdr->dst, ast_channel_exten(qe->chan));
-               strcpy(tmp->chan->cdr->dcontext, ast_channel_context(qe->chan));
-               strcpy(tmp->chan->cdr->lastapp, qe->chan->cdr->lastapp);
-               strcpy(tmp->chan->cdr->lastdata, qe->chan->cdr->lastdata);
-               tmp->chan->cdr->amaflags = qe->chan->cdr->amaflags;
-               strcpy(tmp->chan->cdr->accountcode, qe->chan->cdr->accountcode);
-               strcpy(tmp->chan->cdr->userfield, qe->chan->cdr->userfield);
+               ast_cdr_setdestchan(ast_channel_cdr(tmp->chan), ast_channel_name(tmp->chan));
+               strcpy(ast_channel_cdr(tmp->chan)->clid, ast_channel_cdr(qe->chan)->clid);
+               strcpy(ast_channel_cdr(tmp->chan)->channel, ast_channel_cdr(qe->chan)->channel);
+               strcpy(ast_channel_cdr(tmp->chan)->src, ast_channel_cdr(qe->chan)->src);
+               strcpy(ast_channel_cdr(tmp->chan)->dst, ast_channel_exten(qe->chan));
+               strcpy(ast_channel_cdr(tmp->chan)->dcontext, ast_channel_context(qe->chan));
+               strcpy(ast_channel_cdr(tmp->chan)->lastapp, ast_channel_cdr(qe->chan)->lastapp);
+               strcpy(ast_channel_cdr(tmp->chan)->lastdata, ast_channel_cdr(qe->chan)->lastdata);
+               ast_channel_cdr(tmp->chan)->amaflags = ast_channel_cdr(qe->chan)->amaflags;
+               strcpy(ast_channel_cdr(tmp->chan)->accountcode, ast_channel_cdr(qe->chan)->accountcode);
+               strcpy(ast_channel_cdr(tmp->chan)->userfield, ast_channel_cdr(qe->chan)->userfield);
        }
 
        ast_channel_unlock(tmp->chan);
@@ -3268,7 +3268,7 @@ static int ring_entry(struct queue_ent *qe, struct callattempt *tmp, int *busies
                        S_COR(qe->chan->caller.id.name.valid, qe->chan->caller.id.name.str, "unknown"),
                        S_COR(qe->chan->connected.id.number.valid, qe->chan->connected.id.number.str, "unknown"),
                        S_COR(qe->chan->connected.id.name.valid, qe->chan->connected.id.name.str, "unknown"),
-                       ast_channel_context(qe->chan), ast_channel_exten(qe->chan), qe->chan->priority, ast_channel_uniqueid(qe->chan),
+                       ast_channel_context(qe->chan), ast_channel_exten(qe->chan), ast_channel_priority(qe->chan), ast_channel_uniqueid(qe->chan),
                        qe->parent->eventwhencalled == QUEUE_EVENT_VARIABLES ? vars2manager(qe->chan, vars, sizeof(vars)) : "");
 
                ast_channel_unlock(tmp->chan);
@@ -3640,7 +3640,7 @@ static struct callattempt *wait_for_answer(struct queue_ent *qe, struct callatte
                                ast_copy_string(ochan_name, ast_channel_name(o->chan), sizeof(ochan_name));
                                ast_channel_unlock(o->chan);
                        }
-                       if (o->stillgoing && (o->chan) &&  (o->chan->_state == AST_STATE_UP)) {
+                       if (o->stillgoing && (o->chan) &&  (ast_channel_state(o->chan) == AST_STATE_UP)) {
                                if (!peer) {
                                        ast_verb(3, "%s answered %s\n", ochan_name, inchan_name);
                                        if (update_connectedline) {
@@ -3699,7 +3699,7 @@ static struct callattempt *wait_for_answer(struct queue_ent *qe, struct callatte
                                        /* Before processing channel, go ahead and check for forwarding */
                                        ast_verb(3, "Now forwarding %s to '%s/%s' (thanks to %s)\n", inchan_name, tech, stuff, ochan_name);
                                        /* Setup parameters */
-                                       o->chan = ast_request(tech, in->nativeformats, in, stuff, &status);
+                                       o->chan = ast_request(tech, ast_channel_nativeformats(in), in, stuff, &status);
                                        if (!o->chan) {
                                                ast_log(LOG_NOTICE,
                                                        "Forwarding failed to create channel to dial '%s/%s'\n",
@@ -3799,8 +3799,8 @@ static struct callattempt *wait_for_answer(struct queue_ent *qe, struct callatte
                                                        break;
                                                case AST_CONTROL_BUSY:
                                                        ast_verb(3, "%s is busy\n", ochan_name);
-                                                       if (in->cdr)
-                                                               ast_cdr_busy(in->cdr);
+                                                       if (ast_channel_cdr(in))
+                                                               ast_cdr_busy(ast_channel_cdr(in));
                                                        do_hang(o);
                                                        endtime = (long) time(NULL);
                                                        endtime -= starttime;
@@ -3818,8 +3818,8 @@ static struct callattempt *wait_for_answer(struct queue_ent *qe, struct callatte
                                                        break;
                                                case AST_CONTROL_CONGESTION:
                                                        ast_verb(3, "%s is circuit-busy\n", ochan_name);
-                                                       if (in->cdr)
-                                                               ast_cdr_busy(in->cdr);
+                                                       if (ast_channel_cdr(in))
+                                                               ast_cdr_busy(ast_channel_cdr(in));
                                                        endtime = (long) time(NULL);
                                                        endtime -= starttime;
                                                        rna(endtime * 1000, qe, on, membername, qe->parent->autopauseunavail);
@@ -3914,7 +3914,7 @@ static struct callattempt *wait_for_answer(struct queue_ent *qe, struct callatte
                                *to = -1;
                                if (f) {
                                        if (f->data.uint32) {
-                                               in->hangupcause = f->data.uint32;
+                                               ast_channel_hangupcause_set(in, f->data.uint32);
                                        }
                                        ast_frfree(f);
                                }
@@ -4648,7 +4648,7 @@ static int try_calling(struct queue_ent *qe, const char *options, char *announce
                        tmp->q_next = outgoing;
                        outgoing = tmp;         
                        /* If this line is up, don't try anybody else */
-                       if (outgoing->chan && (outgoing->chan->_state == AST_STATE_UP))
+                       if (outgoing->chan && (ast_channel_state(outgoing->chan) == AST_STATE_UP))
                                break;
                } else {
                        callattempt_free(tmp);
@@ -4717,8 +4717,8 @@ static int try_calling(struct queue_ent *qe, const char *options, char *announce
                                if (!o->chan) {
                                        continue;
                                }
-                               if (strcmp(o->chan->cdr->dstchannel, qe->chan->cdr->dstchannel) == 0) {
-                                       ast_set_flag(o->chan->cdr, AST_CDR_FLAG_POST_DISABLED);
+                               if (strcmp(ast_channel_cdr(o->chan)->dstchannel, ast_channel_cdr(qe->chan)->dstchannel) == 0) {
+                                       ast_set_flag(ast_channel_cdr(o->chan), AST_CDR_FLAG_POST_DISABLED);
                                        break;
                                }
                        }
@@ -4727,9 +4727,9 @@ static int try_calling(struct queue_ent *qe, const char *options, char *announce
                /* Ah ha!  Someone answered within the desired timeframe.  Of course after this
                   we will always return with -1 so that it is hung up properly after the
                   conversation.  */
-               if (!strcmp(qe->chan->tech->type, "DAHDI"))
+               if (!strcmp(ast_channel_tech(qe->chan)->type, "DAHDI"))
                        ast_channel_setoption(qe->chan, AST_OPTION_TONE_VERIFY, &nondataquality, sizeof(nondataquality), 0);
-               if (!strcmp(peer->tech->type, "DAHDI"))
+               if (!strcmp(ast_channel_tech(peer)->type, "DAHDI"))
                        ast_channel_setoption(peer, AST_OPTION_TONE_VERIFY, &nondataquality, sizeof(nondataquality), 0);
                /* Update parameters for the queue */
                time(&now);
@@ -4806,8 +4806,8 @@ static int try_calling(struct queue_ent *qe, const char *options, char *announce
                else
                        ast_moh_stop(qe->chan);
                /* If appropriate, log that we have a destination channel */
-               if (qe->chan->cdr) {
-                       ast_cdr_setdestchan(qe->chan->cdr, ast_channel_name(peer));
+               if (ast_channel_cdr(qe->chan)) {
+                       ast_cdr_setdestchan(ast_channel_cdr(qe->chan), ast_channel_name(peer));
                }
                /* Make sure channels are compatible */
                res = ast_channel_make_compatible(qe->chan, peer);
@@ -4815,7 +4815,7 @@ static int try_calling(struct queue_ent *qe, const char *options, char *announce
                        ast_queue_log(queuename, ast_channel_uniqueid(qe->chan), member->membername, "SYSCOMPAT", "%s", "");
                        ast_log(LOG_WARNING, "Had to drop call because I couldn't make %s compatible with %s\n", ast_channel_name(qe->chan), ast_channel_name(peer));
                        record_abandoned(qe);
-                       ast_cdr_failed(qe->chan->cdr);
+                       ast_cdr_failed(ast_channel_cdr(qe->chan));
                        ast_hangup(peer);
                        ao2_ref(member, -1);
                        return -1;
@@ -4872,8 +4872,8 @@ static int try_calling(struct queue_ent *qe, const char *options, char *announce
                                ast_channel_unlock(qe->chan);
                                if (monitorfilename) {
                                        ast_monitor_start(which, qe->parent->monfmt, monitorfilename, 1, X_REC_IN | X_REC_OUT);
-                               } else if (qe->chan->cdr) {
-                                       ast_monitor_start(which, qe->parent->monfmt, qe->chan->cdr->uniqueid, 1, X_REC_IN | X_REC_OUT);
+                               } else if (ast_channel_cdr(qe->chan)) {
+                                       ast_monitor_start(which, qe->parent->monfmt, ast_channel_cdr(qe->chan)->uniqueid, 1, X_REC_IN | X_REC_OUT);
                                } else {
                                        /* Last ditch effort -- no CDR, make up something */
                                        snprintf(tmpid, sizeof(tmpid), "chan-%lx", ast_random());
@@ -4888,8 +4888,8 @@ static int try_calling(struct queue_ent *qe, const char *options, char *announce
                                if (mixmonapp) {
                                        ast_debug(1, "Starting MixMonitor as requested.\n");
                                        if (!monitorfilename) {
-                                               if (qe->chan->cdr) {
-                                                       ast_copy_string(tmpid, qe->chan->cdr->uniqueid, sizeof(tmpid));
+                                               if (ast_channel_cdr(qe->chan)) {
+                                                       ast_copy_string(tmpid, ast_channel_cdr(qe->chan)->uniqueid, sizeof(tmpid));
                                                } else {
                                                        snprintf(tmpid, sizeof(tmpid), "chan-%lx", ast_random());
                                                }
@@ -4959,12 +4959,12 @@ static int try_calling(struct queue_ent *qe, const char *options, char *announce
                                        
                                        ast_debug(1, "Arguments being passed to MixMonitor: %s\n", mixmonargs);
                                        /* We purposely lock the CDR so that pbx_exec does not update the application data */
-                                       if (qe->chan->cdr) {
-                                               ast_set_flag(qe->chan->cdr, AST_CDR_FLAG_LOCKED);
+                                       if (ast_channel_cdr(qe->chan)) {
+                                               ast_set_flag(ast_channel_cdr(qe->chan), AST_CDR_FLAG_LOCKED);
                                        }
                                        pbx_exec(qe->chan, mixmonapp, mixmonargs);
-                                       if (qe->chan->cdr) {
-                                               ast_clear_flag(qe->chan->cdr, AST_CDR_FLAG_LOCKED);
+                                       if (ast_channel_cdr(qe->chan)) {
+                                               ast_clear_flag(ast_channel_cdr(qe->chan), AST_CDR_FLAG_LOCKED);
                                        }
                                } else {
                                        ast_log(LOG_WARNING, "Asked to run MixMonitor on this call, but cannot find the MixMonitor app!\n");
@@ -5039,7 +5039,7 @@ static int try_calling(struct queue_ent *qe, const char *options, char *announce
                                /* Set where we came from */
                                ast_channel_context_set(peer, "app_queue_gosub_virtual_context");
                                ast_channel_exten_set(peer, "s");
-                               peer->priority = 0;
+                               ast_channel_priority_set(peer, 0);
 
                                gosub_argstart = strchr(gosubexec, ',');
                                if (gosub_argstart) {
@@ -5102,12 +5102,12 @@ static int try_calling(struct queue_ent *qe, const char *options, char *announce
                ast_queue_log(queuename, ast_channel_uniqueid(qe->chan), member->membername, "CONNECT", "%ld|%s|%ld", (long) time(NULL) - qe->start, ast_channel_uniqueid(peer),
                                                                                                        (long)(orig - to > 0 ? (orig - to) / 1000 : 0));
 
-               if (qe->chan->cdr) {
+               if (ast_channel_cdr(qe->chan)) {
                        struct ast_cdr *cdr;
                        struct ast_cdr *newcdr;
 
                        /* Only work with the last CDR in the stack*/
-                       cdr = qe->chan->cdr;
+                       cdr = ast_channel_cdr(qe->chan);
                        while (cdr->next) {
                                cdr = cdr->next;
                        }
index 813d375..d2a1de7 100644 (file)
@@ -191,10 +191,10 @@ static int read_exec(struct ast_channel *chan, const char *data)
        }
        if (ast_test_flag(&flags, OPT_INDICATION)) {
                if (!ast_strlen_zero(arglist.filename)) {
-                       ts = ast_get_indication_tone(chan->zone, arglist.filename);
+                       ts = ast_get_indication_tone(ast_channel_zone(chan), arglist.filename);
                }
        }
-       if (chan->_state != AST_STATE_UP) {
+       if (ast_channel_state(chan) != AST_STATE_UP) {
                if (ast_test_flag(&flags, OPT_SKIP)) {
                        /* At the user's option, skip if the line is not up */
                        pbx_builtin_setvar_helper(chan, arglist.variable, "");
@@ -210,7 +210,7 @@ static int read_exec(struct ast_channel *chan, const char *data)
                        ast_stopstream(chan);
                        if (ts && ts->data[0]) {
                                if (!to)
-                                       to = chan->pbx ? chan->pbx->rtimeoutms : 6000;
+                                       to = ast_channel_pbx(chan) ? ast_channel_pbx(chan)->rtimeoutms : 6000;
                                res = ast_playtones_start(chan, 0, ts->data, 0);
                                for (x = 0; x < maxdigits; ) {
                                        res = ast_waitfordigit(chan, to);
index 5e6f3ed..a894ba4 100644 (file)
@@ -164,17 +164,17 @@ static int readexten_exec(struct ast_channel *chan, const char *data)
        }
 
        if (timeout <= 0)
-               timeout = chan->pbx ? chan->pbx->rtimeoutms : 10000;
+               timeout = ast_channel_pbx(chan) ? ast_channel_pbx(chan)->rtimeoutms : 10000;
 
        if (digit_timeout <= 0)
-               digit_timeout = chan->pbx ? chan->pbx->dtimeoutms : 5000;
+               digit_timeout = ast_channel_pbx(chan) ? ast_channel_pbx(chan)->dtimeoutms : 5000;
 
        if (ast_test_flag(&flags, OPT_INDICATION) && !ast_strlen_zero(arglist.filename)) {
-               ts = ast_get_indication_tone(chan->zone, arglist.filename);
+               ts = ast_get_indication_tone(ast_channel_zone(chan), arglist.filename);
        }
 
        do {
-               if (chan->_state != AST_STATE_UP) {
+               if (ast_channel_state(chan) != AST_STATE_UP) {
                        if (ast_test_flag(&flags, OPT_SKIP)) {
                                /* At the user's option, skip if the line is not up */
                                pbx_builtin_setvar_helper(chan, arglist.variable, "");
index 420ed0e..b7c6bfa 100644 (file)
@@ -260,7 +260,7 @@ static int record_exec(struct ast_channel *chan, const char *data)
                ast_copy_string(tmp, args.filename, sizeof(tmp));
        /* end of routine mentioned */
 
-       if (chan->_state != AST_STATE_UP) {
+       if (ast_channel_state(chan) != AST_STATE_UP) {
                if (ast_test_flag(&flags, OPTION_SKIP)) {
                        /* At the user's option, skip if the line is not up */
                        pbx_builtin_setvar_helper(chan, "RECORD_STATUS", "SKIP");
index 5556a8d..48d31d2 100644 (file)
@@ -1380,7 +1380,7 @@ static int priority_jump(struct rpt *myrpt, struct ast_channel *chan)
        int res=0;
 
        // if (ast_test_flag(&flags,OPT_JUMP) && ast_goto_if_exists(chan, chan->context, chan->exten, chan->priority + 101) == 0){
-       if (ast_goto_if_exists(chan, ast_channel_context(chan), ast_channel_exten(chan), chan->priority + 101) == 0){
+       if (ast_goto_if_exists(chan, ast_channel_context(chan), ast_channel_exten(chan), ast_channel_priority(chan) + 101) == 0){
                res = 0;
        } else {
                res = -1;
@@ -3278,7 +3278,7 @@ static int play_tone_pair(struct ast_channel *chan, int f1, int f2, int duration
         if ((res = ast_tonepair_start(chan, f1, f2, duration, amplitude)))
                 return res;
                                                                                                                                             
-        while(chan->generatordata) {
+        while(ast_channel_generatordata(chan)) {
                if (ast_safe_sleep(chan,1)) return -1;
        }
 
@@ -4035,8 +4035,8 @@ struct ast_format_cap *cap = NULL;
                pthread_exit(NULL);
        }
 #ifdef AST_CDR_FLAG_POST_DISABLED
-       if (mychannel->cdr) 
-               ast_set_flag(mychannel->cdr,AST_CDR_FLAG_POST_DISABLED);
+       if (ast_channel_cdr(mychannel)) 
+               ast_set_flag(ast_channel_cdr(mychannel),AST_CDR_FLAG_POST_DISABLED);
 #endif
        rpt_mutex_lock(&myrpt->lock);
        mytele->chan = mychannel;
@@ -5172,7 +5172,7 @@ struct ast_format_cap *cap = NULL;
                        myrpt->stopgen = 0;
                        break;
                }
-               while(mychannel->generatordata && (myrpt->stopgen <= 0)) {
+               while(ast_channel_generatordata(mychannel) && (myrpt->stopgen <= 0)) {
                        if (ast_safe_sleep(mychannel,1)) break;
                        imdone = 1;
                        }
@@ -5317,8 +5317,8 @@ struct ast_format_cap *cap = NULL;
                pthread_exit(NULL);
        }
 #ifdef AST_CDR_FLAG_POST_DISABLED
-       if (mychannel->cdr)
-               ast_set_flag(mychannel->cdr,AST_CDR_FLAG_POST_DISABLED);
+       if (ast_channel_cdr(mychannel))
+               ast_set_flag(ast_channel_cdr(mychannel),AST_CDR_FLAG_POST_DISABLED);
 #endif
        ci.chan = 0;
        ci.confno = myrpt->conf; /* use the pseudo conference */
@@ -5345,8 +5345,8 @@ struct ast_format_cap *cap = NULL;
                pthread_exit(NULL);
        }
 #ifdef AST_CDR_FLAG_POST_DISABLED
-       if (genchannel->cdr)
-               ast_set_flag(genchannel->cdr,AST_CDR_FLAG_POST_DISABLED);
+       if (ast_channel_cdr(genchannel))
+               ast_set_flag(ast_channel_cdr(genchannel),AST_CDR_FLAG_POST_DISABLED);
 #endif
        ci.chan = 0;
        ci.confno = myrpt->conf;
@@ -5492,7 +5492,7 @@ struct ast_format_cap *cap = NULL;
        
        if (myrpt->p.acctcode)
                ast_cdr_setaccount(mychannel,myrpt->p.acctcode);
-       mychannel->priority = 1;
+       ast_channel_priority_set(mychannel, 1);
        ast_channel_undefer_dtmf(mychannel);
        if (ast_pbx_start(mychannel) < 0)
        {
@@ -5542,7 +5542,7 @@ struct ast_format_cap *cap = NULL;
        }
        while(myrpt->callmode)
        {
-               if ((!mychannel->pbx) && (myrpt->callmode != 4))
+               if ((!ast_channel_pbx(mychannel)) && (myrpt->callmode != 4))
                {
                    /* If patch is setup for far end disconnect */
                        if(myrpt->patchfarenddisconnect || (myrpt->p.duplex < 2)){ 
@@ -5586,7 +5586,7 @@ struct ast_format_cap *cap = NULL;
                ast_log(LOG_NOTICE, "exit channel loop\n");
        rpt_mutex_unlock(&myrpt->lock);
        tone_zone_play_tone(genchannel->fds[0],-1);
-       if (mychannel->pbx) ast_softhangup(mychannel,AST_SOFTHANGUP_DEV);
+       if (ast_channel_pbx(mychannel)) ast_softhangup(mychannel,AST_SOFTHANGUP_DEV);
        ast_hangup(genchannel);
        rpt_mutex_lock(&myrpt->lock);
        myrpt->callmode = 0;
@@ -5819,8 +5819,8 @@ static int connect_link(struct rpt *myrpt, char* node, int mode, int perma)
                ast_set_read_format_by_id(l->chan, AST_FORMAT_SLINEAR);
                ast_set_write_format_by_id(l->chan, AST_FORMAT_SLINEAR);
 #ifdef AST_CDR_FLAG_POST_DISABLED
-               if (l->chan->cdr)
-                       ast_set_flag(l->chan->cdr,AST_CDR_FLAG_POST_DISABLED);
+               if (ast_channel_cdr(l->chan))
+                       ast_set_flag(ast_channel_cdr(l->chan),AST_CDR_FLAG_POST_DISABLED);
 #endif
 #ifndef        NEW_ASTERISK
                l->chan->whentohangup = 0;
@@ -5860,8 +5860,8 @@ static int connect_link(struct rpt *myrpt, char* node, int mode, int perma)
        ast_set_read_format_by_id(l->pchan, AST_FORMAT_SLINEAR);
        ast_set_write_format_by_id(l->pchan, AST_FORMAT_SLINEAR);
 #ifdef AST_CDR_FLAG_POST_DISABLED
-       if (l->pchan->cdr)
-               ast_set_flag(l->pchan->cdr,AST_CDR_FLAG_POST_DISABLED);
+       if (ast_channel_cdr(l->pchan))
+               ast_set_flag(ast_channel_cdr(l->pchan),AST_CDR_FLAG_POST_DISABLED);
 #endif
        /* make a conference for the tx */
        ci.chan = 0;
@@ -13366,7 +13366,7 @@ static int rpt_exec(struct ast_channel *chan, const char *data)
 
                if ((!myrpt->p.nobusyout) && m)
                {
-                       if (chan->_state != AST_STATE_UP)
+                       if (ast_channel_state(chan) != AST_STATE_UP)
                        {
                                ast_indicate(chan,AST_CONTROL_BUSY);
                        }
@@ -13374,7 +13374,7 @@ static int rpt_exec(struct ast_channel *chan, const char *data)
                        return -1;
                }
 
-               if (chan->_state != AST_STATE_UP)
+               if (ast_channel_state(chan) != AST_STATE_UP)
                {
                        ast_answer(chan);
                        if (!phone_mode) send_newkey(chan);
@@ -13429,7 +13429,7 @@ static int rpt_exec(struct ast_channel *chan, const char *data)
                        return -1;
                }
                /* At this point we have a priority and maybe an extension and a context */
-               chan->priority = atoi(priority);
+               ast_channel_priority_set(chan, atoi(priority));
 #ifdef OLD_ASTERISK
                if(exten && strcasecmp(exten, "BYEXTENSION"))
 #else
@@ -13439,13 +13439,13 @@ static int rpt_exec(struct ast_channel *chan, const char *data)
                if(context)
                        ast_channel_context_set(chan, context);
                } else {  /* increment the priority by default*/
-                       chan->priority++;
+                       ast_channel_priority(chan)++;
                }
 
                ast_verb(3, "Return Context: (%s,%s,%d) ID: %s\n",
-                       ast_channel_context(chan), ast_channel_exten(chan), chan->priority,
+                       ast_channel_context(chan), ast_channel_exten(chan), ast_channel_priority(chan),
                        S_COR(chan->caller.id.number.valid, chan->caller.id.number.str, ""));
-               if (!ast_exists_extension(chan, ast_channel_context(chan), ast_channel_exten(chan), chan->priority,
+               if (!ast_exists_extension(chan, ast_channel_context(chan), ast_channel_exten(chan), ast_channel_priority(chan),
                        S_COR(chan->caller.id.number.valid, chan->caller.id.number.str, NULL))) {
                        ast_verb(3, "Warning: Return Context Invalid, call will return to default|s\n");
                }
@@ -13673,8 +13673,8 @@ static int rpt_exec(struct ast_channel *chan, const char *data)
                ast_set_read_format_by_id(l->pchan,AST_FORMAT_SLINEAR);
                ast_set_write_format_by_id(l->pchan,AST_FORMAT_SLINEAR);
 #ifdef AST_CDR_FLAG_POST_DISABLED
-               if (l->pchan->cdr)
-                       ast_set_flag(l->pchan->cdr,AST_CDR_FLAG_POST_DISABLED);
+               if (ast_channel_cdr(l->pchan))
+                       ast_set_flag(ast_channel_cdr(l->pchan),AST_CDR_FLAG_POST_DISABLED);
 #endif
                /* make a conference for the tx */
                ci.chan = 0;
@@ -13693,7 +13693,7 @@ static int rpt_exec(struct ast_channel *chan, const char *data)
                insque((struct qelem *)l,(struct qelem *)myrpt->links.next);
                __kickshort(myrpt);
                rpt_mutex_unlock(&myrpt->lock);
-               if (chan->_state != AST_STATE_UP) {
+               if (ast_channel_state(chan) != AST_STATE_UP) {
                        ast_answer(chan);
                        if (!phone_mode) send_newkey(chan);
                }
@@ -13721,8 +13721,8 @@ static int rpt_exec(struct ast_channel *chan, const char *data)
                {
                        ast_log(LOG_WARNING, "Trying to use busy link on %s\n",tmp);
 #ifdef AST_CDR_FLAG_POST_DISABLED
-                       if (chan->cdr)
-                               ast_set_flag(chan->cdr,AST_CDR_FLAG_POST_DISABLED);
+                       if (ast_channel_cdr(chan))
+                               ast_set_flag(ast_channel_cdr(chan),AST_CDR_FLAG_POST_DISABLED);
 #endif
                        return -1;
                }               
@@ -13747,8 +13747,8 @@ static int rpt_exec(struct ast_channel *chan, const char *data)
                                        rpt_mutex_unlock(&myrpt->lock);
                                        ast_log(LOG_WARNING, "Trying to use busy link (repeater node %s) on %s\n",rpt_vars[i].name,tmp);
 #ifdef AST_CDR_FLAG_POST_DISABLED
-                                       if (chan->cdr)
-                                               ast_set_flag(chan->cdr,AST_CDR_FLAG_POST_DISABLED);
+                                       if (ast_channel_cdr(chan))
+                                               ast_set_flag(ast_channel_cdr(chan),AST_CDR_FLAG_POST_DISABLED);
 #endif
                                        return -1;
                                }
@@ -13764,8 +13764,8 @@ static int rpt_exec(struct ast_channel *chan, const char *data)
                                        if (ast_safe_sleep(chan,500) == -1)
                                        {
 #ifdef AST_CDR_FLAG_POST_DISABLED
-                                               if (chan->cdr)
-                                                       ast_set_flag(chan->cdr,AST_CDR_FLAG_POST_DISABLED);
+                                               if (ast_channel_cdr(chan))
+                                                       ast_set_flag(ast_channel_cdr(chan),AST_CDR_FLAG_POST_DISABLED);
 #endif
                                                return -1;
                                        }
@@ -13818,8 +13818,8 @@ static int rpt_exec(struct ast_channel *chan, const char *data)
                ast_set_read_format_by_id(myrpt->rxchannel,AST_FORMAT_SLINEAR);
                ast_set_write_format_by_id(myrpt->rxchannel,AST_FORMAT_SLINEAR);
 #ifdef AST_CDR_FLAG_POST_DISABLED
-               if (myrpt->rxchannel->cdr)
-                       ast_set_flag(myrpt->rxchannel->cdr,AST_CDR_FLAG_POST_DISABLED);
+               if (ast_channel_cdr(myrpt->rxchannel))
+                       ast_set_flag(ast_channel_cdr(myrpt->rxchannel),AST_CDR_FLAG_POST_DISABLED);
 #endif
 #ifndef        NEW_ASTERISK
                myrpt->rxchannel->whentohangup = 0;
@@ -13860,8 +13860,8 @@ static int rpt_exec(struct ast_channel *chan, const char *data)
                        ast_set_read_format_by_id(myrpt->txchannel,AST_FORMAT_SLINEAR);
                        ast_set_write_format_by_id(myrpt->txchannel,AST_FORMAT_SLINEAR);
 #ifdef AST_CDR_FLAG_POST_DISABLED
-                       if (myrpt->txchannel->cdr)
-                               ast_set_flag(myrpt->txchannel->cdr,AST_CDR_FLAG_POST_DISABLED);
+                       if (ast_channel_cdr(myrpt->txchannel))
+                               ast_set_flag(ast_channel_cdr(myrpt->txchannel),AST_CDR_FLAG_POST_DISABLED);
 #endif
 #ifndef        NEW_ASTERISK
                        myrpt->txchannel->whentohangup = 0;
@@ -13904,8 +13904,8 @@ static int rpt_exec(struct ast_channel *chan, const char *data)
        ast_set_read_format_by_id(myrpt->pchannel,AST_FORMAT_SLINEAR);
        ast_set_write_format_by_id(myrpt->pchannel,AST_FORMAT_SLINEAR);
 #ifdef AST_CDR_FLAG_POST_DISABLED
-       if (myrpt->pchannel->cdr)
-               ast_set_flag(myrpt->pchannel->cdr,AST_CDR_FLAG_POST_DISABLED);
+       if (ast_channel_cdr(myrpt->pchannel))
+               ast_set_flag(ast_channel_cdr(myrpt->pchannel),AST_CDR_FLAG_POST_DISABLED);
 #endif
        if (!myrpt->dahdirxchannel) myrpt->dahdirxchannel = myrpt->pchannel;
        if (!myrpt->dahditxchannel) myrpt->dahditxchannel = myrpt->pchannel;
@@ -14028,7 +14028,7 @@ static int rpt_exec(struct ast_channel *chan, const char *data)
                i = 128;
                ioctl(myrpt->dahdirxchannel->fds[0],DAHDI_ECHOCANCEL,&i);
        }
-       if (chan->_state != AST_STATE_UP) {
+       if (ast_channel_state(chan) != AST_STATE_UP) {
                ast_answer(chan);
                if (!phone_mode) send_newkey(chan);
        }
index 32119ac..7d34ed9 100644 (file)
@@ -148,7 +148,7 @@ static int sayunixtime_exec(struct ast_channel *chan, const char *data)
 
        ast_get_time_t(ast_strlen_zero(args.timeval) ? NULL : args.timeval, &unixtime, time(NULL), NULL);
 
-       if (chan->_state != AST_STATE_UP) {
+       if (ast_channel_state(chan) != AST_STATE_UP) {
                res = ast_answer(chan);
        }
 
index a723de5..98b7b2f 100644 (file)
@@ -95,7 +95,7 @@ static int sendtext_exec(struct ast_channel *chan, const char *data)
        ast_str_get_encoded_str(&str, -1, data);
 
        ast_channel_lock(chan);
-       if (!chan->tech->send_text) {
+       if (!ast_channel_tech(chan)->send_text) {
                ast_channel_unlock(chan);
                /* Does not support transport */
                pbx_builtin_setvar_helper(chan, "SENDTEXTSTATUS", status);
index 68770da..946677a 100644 (file)
@@ -1988,7 +1988,7 @@ static int sms_exec(struct ast_channel *chan, const char *data)
                goto done;
        }
        
-       if (chan->_state != AST_STATE_UP) {             /* make sure channel is answered before any TX */
+       if (ast_channel_state(chan) != AST_STATE_UP) {          /* make sure channel is answered before any TX */
                ast_answer(chan);
        }
 
index 2a4befa..f3fc4c1 100644 (file)
@@ -107,7 +107,7 @@ static int softhangup_exec(struct ast_channel *chan, const char *data)
                ast_copy_string(name, ast_channel_name(c), sizeof(name));
                if (ast_test_flag(&flags, OPTION_ALL)) {
                        /* CAPI is set up like CAPI[foo/bar]/clcnt */ 
-                       if (!strcmp(c->tech->type, "CAPI")) {
+                       if (!strcmp(ast_channel_tech(c)->type, "CAPI")) {
                                cut = strrchr(name, '/');
                        /* Basically everything else is Foo/Bar-Z */
                        } else {
index 078fcf2..8e6113b 100644 (file)
@@ -491,7 +491,7 @@ static int speech_create(struct ast_channel *chan, const char *data)
        struct ast_datastore *datastore = NULL;
 
        /* Request a speech object */
-       speech = ast_speech_new(data, chan->nativeformats);
+       speech = ast_speech_new(data, ast_channel_nativeformats(chan));
        if (speech == NULL) {
                /* Not available */
                pbx_builtin_setvar_helper(chan, "ERROR", "1");
@@ -672,7 +672,7 @@ static int speech_background(struct ast_channel *chan, const char *data)
        }
 
        /* If channel is not already answered, then answer it */
-       if (chan->_state != AST_STATE_UP && !ast_test_flag(&options, SB_OPT_NOANSWER)
+       if (ast_channel_state(chan) != AST_STATE_UP && !ast_test_flag(&options, SB_OPT_NOANSWER)
                && ast_answer(chan)) {
                        return -1;
        }
@@ -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 && (chan->streamid == -1 && chan->timingfunc == NULL) && (filename = strsep(&filename_tmp, "&"))) {
+               if (!quieted && (ast_channel_streamid(chan) == -1 && chan->timingfunc == NULL) && (filename = strsep(&filename_tmp, "&"))) {
                        /* Discard old stream information */
                        ast_stopstream(chan);
                        /* Start new stream */
@@ -729,10 +729,10 @@ static int speech_background(struct ast_channel *chan, const char *data)
                }
 
                /* Run scheduled stuff */
-               ast_sched_runq(chan->sched);
+               ast_sched_runq(ast_channel_sched(chan));
 
                /* Yay scheduling */
-               res = ast_sched_wait(chan->sched);
+               res = ast_sched_wait(ast_channel_sched(chan));
                if (res < 0)
                        res = 1000;
 
@@ -760,7 +760,7 @@ static int speech_background(struct ast_channel *chan, const char *data)
                /* Do checks on speech structure to see if it's changed */
                ast_mutex_lock(&speech->lock);
                if (ast_test_flag(speech, AST_SPEECH_QUIET)) {
-                       if (chan->stream)
+                       if (ast_channel_stream(chan))
                                ast_stopstream(chan);
                        ast_clear_flag(speech, AST_SPEECH_QUIET);
                        quieted = 1;
@@ -769,9 +769,9 @@ 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 (chan->streamid == -1 && chan->timingfunc == NULL)
+                       if (ast_channel_streamid(chan) == -1 && chan->timingfunc == NULL)
                                ast_stopstream(chan);
-                       if (!quieted && chan->stream == NULL && timeout && started == 0 && !filename_tmp) {
+                       if (!quieted && ast_channel_stream(chan) == NULL && timeout && started == 0 && !filename_tmp) {
                                if (timeout == -1) {
                                        done = 1;
                                        if (f)
@@ -789,13 +789,13 @@ static int speech_background(struct ast_channel *chan, const char *data)
                case AST_SPEECH_STATE_WAIT:
                        /* Cue up waiting sound if not already playing */
                        if (!strlen(dtmf)) {
-                               if (chan->stream == NULL) {
+                               if (ast_channel_stream(chan) == NULL) {
                                        if (speech->processing_sound != NULL) {
                                                if (strlen(speech->processing_sound) > 0 && strcasecmp(speech->processing_sound, "none")) {
                                                        speech_streamfile(chan, speech->processing_sound, ast_channel_language(chan));
                                                }
                                        }
-                               } else if (chan->streamid == -1 && chan->timingfunc == NULL) {
+                               } else if (ast_channel_streamid(chan) == -1 && chan->timingfunc == NULL) {
                                        ast_stopstream(chan);
                                        if (speech->processing_sound != NULL) {
                                                if (strlen(speech->processing_sound) > 0 && strcasecmp(speech->processing_sound, "none")) {
@@ -814,7 +814,7 @@ static int speech_background(struct ast_channel *chan, const char *data)
                                /* Break out of our background too */
                                done = 1;
                                /* Stop audio playback */
-                               if (chan->stream != NULL) {
+                               if (ast_channel_stream(chan) != NULL) {
                                        ast_stopstream(chan);
                                }
                        }
@@ -833,12 +833,12 @@ static int speech_background(struct ast_channel *chan, const char *data)
                                        done = 1;
                                } else {
                                        quieted = 1;
-                                       if (chan->stream != NULL) {
+                                       if (ast_channel_stream(chan) != NULL) {
                                                ast_stopstream(chan);
                                        }
                                        if (!started) {
                                                /* Change timeout to be 5 seconds for DTMF input */
-                                               timeout = (chan->pbx && chan->pbx->dtimeoutms) ? chan->pbx->dtimeoutms : 5000;
+                                               timeout = (ast_channel_pbx(chan) && ast_channel_pbx(chan)->dtimeoutms) ? ast_channel_pbx(chan)->dtimeoutms : 5000;
                                                started = 1;
                                        }
                                        start = ast_tvnow();
index f45c078..06febba 100644 (file)
@@ -402,7 +402,7 @@ static int gosub_exec(struct ast_channel *chan, const char *data)
        }
 
        /* Create the return address, but don't save it until we know that the Gosub destination exists */
-       newframe = gosub_allocate_frame(ast_channel_context(chan), ast_channel_exten(chan), chan->priority + 1, max_argc);
+       newframe = gosub_allocate_frame(ast_channel_context(chan), ast_channel_exten(chan), ast_channel_priority(chan) + 1, max_argc);
 
        if (!newframe) {
                return -1;
@@ -415,13 +415,13 @@ 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) ? chan->priority + 1 : chan->priority,
+               ast_test_flag(chan, AST_FLAG_IN_AUTOLOOP) ? ast_channel_priority(chan) + 1 : ast_channel_priority(chan),
                S_COR(chan->caller.id.number.valid, chan->caller.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) ? chan->priority + 1 : chan->priority);
+                               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_set(chan, newframe->context);
                ast_channel_exten_set(chan, newframe->extension);
-               chan->priority = newframe->priority;
+               ast_channel_priority_set(chan, newframe->priority);
                ast_free(newframe);
                return -1;
        }
@@ -607,7 +607,7 @@ static int handle_gosub(struct ast_channel *chan, AGI *agi, int argc, const char
        /* Save previous location, since we're going to change it */
        ast_copy_string(old_context, ast_channel_context(chan), sizeof(old_context));
        ast_copy_string(old_extension, ast_channel_exten(chan), sizeof(old_extension));
-       old_priority = chan->priority;
+       old_priority = ast_channel_priority(chan);
 
        if (!(theapp = pbx_findapp("Gosub"))) {
                ast_log(LOG_ERROR, "Gosub() cannot be found in the list of loaded applications\n");
@@ -622,12 +622,12 @@ static int handle_gosub(struct ast_channel *chan, AGI *agi, int argc, const char
         * call a Gosub for the CALLEE channel in Dial or Queue.
         */
        if (argc == 5) {
-               if (asprintf(&gosub_args, "%s,%s,%d(%s)", argv[1], argv[2], priority + (chan->pbx ? 1 : 0), argv[4]) < 0) {
+               if (asprintf(&gosub_args, "%s,%s,%d(%s)", argv[1], argv[2], priority + (ast_channel_pbx(chan) ? 1 : 0), argv[4]) < 0) {
                        ast_log(LOG_WARNING, "asprintf() failed: %s\n", strerror(errno));
                        gosub_args = NULL;
                }
        } else {
-               if (asprintf(&gosub_args, "%s,%s,%d", argv[1], argv[2], priority + (chan->pbx ? 1 : 0)) < 0) {
+               if (asprintf(&gosub_args, "%s,%s,%d", argv[1], argv[2], priority + (ast_channel_pbx(chan) ? 1 : 0)) < 0) {
                        ast_log(LOG_WARNING, "asprintf() failed: %s\n", strerror(errno));
                        gosub_args = NULL;
                }
@@ -639,7 +639,7 @@ static int handle_gosub(struct ast_channel *chan, AGI *agi, int argc, const char
                ast_debug(1, "Trying gosub with arguments '%s'\n", gosub_args);
 
                if ((res = pbx_exec(chan, theapp, gosub_args)) == 0) {
-                       struct ast_pbx *pbx = chan->pbx;
+                       struct ast_pbx *pbx = ast_channel_pbx(chan);
                        struct ast_pbx_args args;
                        struct ast_datastore *stack_store = ast_channel_datastore_find(chan, &stack_info, NULL);
                        AST_LIST_HEAD(, gosub_stack_frame) *oldlist = stack_store->data;
@@ -649,14 +649,14 @@ static int handle_gosub(struct ast_channel *chan, AGI *agi, int argc, const char
                        memset(&args, 0, sizeof(args));
                        args.no_hangup_chan = 1;
                        /* Suppress warning about PBX already existing */
-                       chan->pbx = NULL;
+                       ast_channel_pbx_set(chan, NULL);
                        ast_agi_send(agi->fd, chan, "100 result=0 Trying...\n");
                        ast_pbx_run_args(chan, &args);
                        ast_agi_send(agi->fd, chan, "200 result=0 Gosub complete\n");
-                       if (chan->pbx) {
-                               ast_free(chan->pbx);
+                       if (ast_channel_pbx(chan)) {
+                               ast_free(ast_channel_pbx(chan));
                        }
-                       chan->pbx = pbx;
+                       ast_channel_pbx_set(chan, pbx);
                } else {
                        ast_agi_send(agi->fd, chan, "200 result=%d Gosub failed\n", res);
                }
@@ -669,7 +669,7 @@ static int handle_gosub(struct ast_channel *chan, AGI *agi, int argc, const char
        /* Restore previous location */
        ast_channel_context_set(chan, old_context);
        ast_channel_exten_set(chan, old_extension);
-       chan->priority = old_priority;
+       ast_channel_priority_set(chan, old_priority);
 
        return RESULT_SUCCESS;
 }
index 5c0ee33..0250f22 100644 (file)
@@ -125,7 +125,7 @@ static int background_detect_exec(struct ast_channel *chan, const char *data)
 
        ast_debug(1, "Preparing detect of '%s', sil=%d, min=%d, max=%d, analysistime=%d\n", args.filename, sil, min, max, analysistime);
        do {
-               if (chan->_state != AST_STATE_UP) {
+               if (ast_channel_state(chan) != AST_STATE_UP) {
                        if ((res = ast_answer(chan))) {
                                break;
                        }
@@ -149,8 +149,8 @@ static int background_detect_exec(struct ast_channel *chan, const char *data)
                        break;
                }
                detection_start = ast_tvnow();
-               while (chan->stream) {
-                       res = ast_sched_wait(chan->sched);
+               while (ast_channel_stream(chan)) {
+                       res = ast_sched_wait(ast_channel_sched(chan));
                        if ((res < 0) && !chan->timingfunc) {
                                res = 0;
                                break;
@@ -227,7 +227,7 @@ static int background_detect_exec(struct ast_channel *chan, const char *data)
                                }
                                ast_frfree(fr);
                        }
-                       ast_sched_runq(chan->sched);
+                       ast_sched_runq(ast_channel_sched(chan));
                }
                ast_stopstream(chan);
        } while (0);
index 9e11866..bf66824 100644 (file)
@@ -162,7 +162,7 @@ static int testclient_exec(struct ast_channel *chan, const char *data)
                return -1;
        }
 
-       if (chan->_state != AST_STATE_UP)
+       if (ast_channel_state(chan) != AST_STATE_UP)
                res = ast_answer(chan);
 
        /* Wait a few just to be sure things get started */
@@ -329,7 +329,7 @@ static int testserver_exec(struct ast_channel *chan, const char *data)
        char testid[80]="";
        char fn[80];
        FILE *f;
-       if (chan->_state != AST_STATE_UP)
+       if (ast_channel_state(chan) != AST_STATE_UP)
                res = ast_answer(chan);
        /* Read version */
        ast_debug(1, "Read client version\n");
index f072eb2..15c3245 100644 (file)
@@ -106,14 +106,14 @@ static int transfer_exec(struct ast_channel *chan, const char *data)
                tech = dest;
                dest = slash + 1;
                /* Allow execution only if the Tech/destination agrees with the type of the channel */
-               if (strncasecmp(chan->tech->type, tech, len)) {
+               if (strncasecmp(ast_channel_tech(chan)->type, tech, len)) {
                        pbx_builtin_setvar_helper(chan, "TRANSFERSTATUS", "FAILURE");
                        return 0;
                }
        }
 
        /* Check if the channel supports transfer before we try it */
-       if (!chan->tech->transfer) {
+       if (!ast_channel_tech(chan)->transfer) {
                pbx_builtin_setvar_helper(chan, "TRANSFERSTATUS", "UNSUPPORTED");
                return 0;
        }
index 14ff2fb..b981fb9 100644 (file)
@@ -158,7 +158,7 @@ static int log_exec(struct ast_channel *chan, const char *data)
                snprintf(context, sizeof(context), "@ %s", ast_channel_context(chan));
                snprintf(extension, sizeof(extension), "Ext. %s", ast_channel_exten(chan));
 
-               ast_log(lnum, extension, chan->priority, context, "%s\n", args.msg);
+               ast_log(lnum, extension, ast_channel_priority(chan), context, "%s\n", args.msg);
        }
 
        return 0;
index 484f449..3a90b99 100644 (file)
@@ -4756,7 +4756,7 @@ static void make_email_file(FILE *p, char *srcemail, struct ast_vm_user *vmu, in
 #endif
                /* flag added for Urgent */
                fprintf(p, "X-Asterisk-VM-Flag: %s" ENDL, flag);
-               fprintf(p, "X-Asterisk-VM-Priority: %d" ENDL, chan->priority);
+               fprintf(p, "X-Asterisk-VM-Priority: %d" ENDL, ast_channel_priority(chan));
                fprintf(p, "X-Asterisk-VM-Caller-channel: %s" ENDL, ast_channel_name(chan));
                fprintf(p, "X-Asterisk-VM-Caller-ID-Num: %s" ENDL, enc_cidnum);
                fprintf(p, "X-Asterisk-VM-Caller-ID-Name: %s" ENDL, enc_cidname);
@@ -5897,7 +5897,7 @@ static int leave_voicemail(struct ast_channel *chan, char *ext, struct leave_vm_
                } else if (ausemacro && !ast_strlen_zero(ast_channel_macrocontext(chan))) {
                        ast_channel_context_set(chan, ast_channel_macrocontext(chan));
                }
-               chan->priority = 0;
+               ast_channel_priority_set(chan, 0);
                free_user(vmu);
                pbx_builtin_setvar_helper(chan, "VMSTATUS", "USEREXIT");
                ast_free(tmp);
@@ -5915,7 +5915,7 @@ static int leave_voicemail(struct ast_channel *chan, char *ext, struct leave_vm_
                                ast_channel_context_set(chan, ast_channel_macrocontext(chan));
                        }
                        ast_play_and_wait(chan, "transfer");
-                       chan->priority = 0;
+                       ast_channel_priority_set(chan, 0);
                        free_user(vmu);
                        pbx_builtin_setvar_helper(chan, "VMSTATUS", "USEREXIT");
                }
@@ -6009,7 +6009,7 @@ static int leave_voicemail(struct ast_channel *chan, char *ext, struct leave_vm_
                                
                /* Store information in real-time storage */
                if (ast_check_realtime("voicemail_data")) {
-                       snprintf(priority, sizeof(priority), "%d", chan->priority);
+                       snprintf(priority, sizeof(priority), "%d", ast_channel_priority(chan));
                        snprintf(origtime, sizeof(origtime), "%ld", (long) time(NULL));
                        get_date(date, sizeof(date));
                        ast_callerid_merge(callerid, sizeof(callerid),
@@ -6061,7 +6061,7 @@ static int leave_voicemail(struct ast_channel *chan, char *ext, struct leave_vm_
                                ast_channel_exten(chan),
                                S_COR(chan->redirecting.from.number.valid,
                                        chan->redirecting.from.number.str, "unknown"),
-                               chan->priority,
+                               ast_channel_priority(chan),
                                ast_channel_name(chan),
                                callerid,
                                date, (long) time(NULL),
@@ -7319,7 +7319,7 @@ static int forward_message(struct ast_channel *chan, char *context, struct vm_st
                                /* make backup copies */
                                old_context = ast_strdupa(ast_channel_context(chan));
                                old_exten = ast_strdupa(ast_channel_exten(chan));
-                               old_priority = chan->priority;
+                               old_priority = ast_channel_priority(chan);
 
                                /* call the the Directory, changes the channel */
                                snprintf(vmcontext, sizeof(vmcontext), "%s,,v", context ? context : "default");
@@ -7330,7 +7330,7 @@ static int forward_message(struct ast_channel *chan, char *context, struct vm_st
                                /* restore the old context, exten, and priority */
                                ast_channel_context_set(chan, old_context);
                                ast_channel_exten_set(chan, old_exten);
-                               chan->priority = old_priority;
+                               ast_channel_priority_set(chan, old_priority);
                        } else {
                                ast_log(AST_LOG_WARNING, "Could not find the Directory application, disabling directory_forward\n");
                                ast_clear_flag((&globalflags), VM_DIRECFORWARD);
@@ -9996,7 +9996,7 @@ static int vm_execmain(struct ast_channel *chan, const char *data)
        memset(&vmus, 0, sizeof(vmus));
 
        ast_test_suite_event_notify("START", "Message: vm_execmain started");
-       if (chan->_state != AST_STATE_UP) {
+       if (ast_channel_state(chan) != AST_STATE_UP) {
                ast_debug(1, "Before ast_answer\n");
                ast_answer(chan);
        }
@@ -10727,7 +10727,7 @@ static int vm_exec(struct ast_channel *chan, const char *data)
        
        memset(&leave_options, 0, sizeof(leave_options));
 
-       if (chan->_state != AST_STATE_UP)
+       if (ast_channel_state(chan) != AST_STATE_UP)
                ast_answer(chan);
 
        if (!ast_strlen_zero(data)) {
@@ -12789,6 +12789,7 @@ AST_TEST_DEFINE(test_voicemail_vmsayname)
 
        struct ast_channel *test_channel1 = NULL;
        int res = -1;
+       struct ast_format_cap *nativeformats;
 
        static const struct ast_channel_tech fake_tech = {
                .write = fake_write,
@@ -12814,11 +12815,12 @@ AST_TEST_DEFINE(test_voicemail_vmsayname)
 
        /* normally this is done in the channel driver */
        ast_format_set(&test_channel1->writeformat, AST_FORMAT_GSM, 0);
-       ast_format_cap_add(test_channel1->nativeformats, &test_channel1->writeformat);
+       nativeformats = ast_channel_nativeformats(test_channel1);
+       ast_format_cap_add(nativeformats, &test_channel1->writeformat);
        ast_format_set(&test_channel1->rawwriteformat, AST_FORMAT_GSM, 0);
        ast_format_set(&test_channel1->readformat, AST_FORMAT_GSM, 0);
        ast_format_set(&test_channel1->rawreadformat, AST_FORMAT_GSM, 0);
-       test_channel1->tech = &fake_tech;
+       ast_channel_tech_set(test_channel1, &fake_tech);
 
        ast_test_status_update(test, "Test playing of extension when greeting is not available...\n");
        snprintf(dir, sizeof(dir), "%s@%s", TEST_EXTENSION, TEST_CONTEXT); /* not a dir, don't get confused */
@@ -13446,7 +13448,7 @@ static int dialout(struct ast_channel *chan, struct ast_vm_user *vmu, char *num,
                ast_verb(3, "Placing outgoing call to extension '%s' in context '%s' from context '%s'\n", destination, outgoing_context, ast_channel_context(chan));
                ast_channel_exten_set(chan, destination);
                ast_channel_context_set(chan, outgoing_context);
-               chan->priority = 0;
+               ast_channel_priority_set(chan, 0);
                return 9;
        }
        return 0;
index 3d3aa75..1964376 100644 (file)
@@ -215,7 +215,7 @@ static int waitfor_exec(struct ast_channel *chan, const char *data, int wait_for
        time_t waitstart;
        struct ast_silence_generator *silgen = NULL;
 
-       if (chan->_state != AST_STATE_UP) {
+       if (ast_channel_state(chan) != AST_STATE_UP) {
                res = ast_answer(chan); /* Answer the channel */
        }
 
index 25d7c43..5e8fb9b 100644 (file)
@@ -165,7 +165,7 @@ static int find_matching_endwhile(struct ast_channel *chan)
                if (!ast_rdlock_context(c)) {
                        if (!strcmp(ast_get_context_name(c), ast_channel_context(chan))) {
                                /* This is the matching context we want */
-                               int cur_priority = chan->priority + 1, level=1;
+                               int cur_priority = ast_channel_priority(chan) + 1, level=1;
 
                                for (e = find_matching_priority(c, ast_channel_exten(chan), cur_priority,
                                        S_COR(chan->caller.id.number.valid, chan->caller.id.number.str, NULL));
@@ -238,7 +238,7 @@ static int _while_exec(struct ast_channel *chan, const char *data, int end)
        size = strlen(ast_channel_context(chan)) + strlen(ast_channel_exten(chan)) + 32;
        my_name = alloca(size);
        memset(my_name, 0, size);
-       snprintf(my_name, size, "%s_%s_%d", ast_channel_context(chan), ast_channel_exten(chan), chan->priority);
+       snprintf(my_name, size, "%s_%s_%d", ast_channel_context(chan), ast_channel_exten(chan), ast_channel_priority(chan));
        
        ast_channel_lock(chan);
        if (end) {
@@ -269,9 +269,9 @@ static int _while_exec(struct ast_channel *chan, const char *data, int end)
                        int pri = find_matching_endwhile(chan);
                        if (pri > 0) {
                                ast_verb(3, "Jumping to priority %d\n", pri);
-                               chan->priority = pri;
+                               ast_channel_priority_set(chan, pri);
                        } else {
-                               ast_log(LOG_WARNING, "Couldn't find matching EndWhile? (While at %s@%s priority %d)\n", ast_channel_context(chan), ast_channel_exten(chan), chan->priority);
+                               ast_log(LOG_WARNING, "Couldn't find matching EndWhile? (While at %s@%s priority %d)\n", ast_channel_context(chan), ast_channel_exten(chan), ast_channel_priority(chan));
                        }
                }
                ast_channel_unlock(chan);
@@ -283,7 +283,7 @@ static int _while_exec(struct ast_channel *chan, const char *data, int end)
                size = strlen(ast_channel_context(chan)) + strlen(ast_channel_exten(chan)) + 32;
                goto_str = alloca(size);
                memset(goto_str, 0, size);
-               snprintf(goto_str, size, "%s,%s,%d", ast_channel_context(chan), ast_channel_exten(chan), chan->priority);
+               snprintf(goto_str, size, "%s,%s,%d", ast_channel_context(chan), ast_channel_exten(chan), ast_channel_priority(chan));
                pbx_builtin_setvar_helper(chan, varname, goto_str);
        }
 
@@ -295,7 +295,7 @@ static int _while_exec(struct ast_channel *chan, const char *data, int end)
                        size = strlen(ast_channel_context(chan)) + strlen(ast_channel_exten(chan)) + 32;
                        goto_str = alloca(size);
                        memset(goto_str, 0, size);
-                       snprintf(goto_str, size, "%s,%s,%d", ast_channel_context(chan), ast_channel_exten(chan), chan->priority+1);
+                       snprintf(goto_str, size, "%s,%s,%d", ast_channel_context(chan), ast_channel_exten(chan), ast_channel_priority(chan)+1);
                        pbx_builtin_setvar_helper(chan, end_varname, goto_str);
                }
                ast_parseable_goto(chan, while_pri);
index b102ea4..775fd55 100644 (file)
@@ -98,7 +98,7 @@ static int zapateller_exec(struct ast_channel *chan, const char *data)
 
        pbx_builtin_setvar_helper(chan, "ZAPATELLERSTATUS", "NOTHING");
        ast_stopstream(chan);
-       if (chan->_state != AST_STATE_UP) {
+       if (ast_channel_state(chan) != AST_STATE_UP) {
                if (answer) {
                        res = ast_answer(chan);
                        pbx_builtin_setvar_helper(chan, "ZAPATELLERSTATUS", "ANSWERED");
index 98a11ca..5ef9b84 100644 (file)
@@ -79,7 +79,7 @@ static struct ast_channel *dial_transfer(struct ast_channel *caller, const char
        snprintf(destination, sizeof(destination), "%s@%s", exten, context);
 
        /* Now we request that chan_local prepare to call the destination */
-       if (!(chan = ast_request("Local", caller->nativeformats, caller, destination, &cause))) {
+       if (!(chan = ast_request("Local", ast_channel_nativeformats(caller), caller, destination, &cause))) {
                return NULL;
        }
 
index 9ca6aa4..89bf584 100644 (file)
@@ -329,7 +329,7 @@ static int multiplexed_bridge_join(struct ast_bridge *bridge, struct ast_bridge_
 
        if ((ast_format_cmp(&c0->writeformat, &c1->readformat) == AST_FORMAT_CMP_EQUAL) &&
                (ast_format_cmp(&c0->readformat, &c1->writeformat) == AST_FORMAT_CMP_EQUAL) &&
-               (ast_format_cap_identical(c0->nativeformats, c1->nativeformats))) {
+               (ast_format_cap_identical(ast_channel_nativeformats(c0), ast_channel_nativeformats(c1)))) {
                return 0;
        }
 
index 14864df..19bcd29 100644 (file)
@@ -57,7 +57,7 @@ static int simple_bridge_join(struct ast_bridge *bridge, struct ast_bridge_chann
        /* See if we need to make these compatible */
        if ((ast_format_cmp(&c0->writeformat, &c1->readformat) == AST_FORMAT_CMP_EQUAL) &&
                (ast_format_cmp(&c0->readformat, &c1->writeformat) == AST_FORMAT_CMP_EQUAL) &&
-               (ast_format_cap_identical(c0->nativeformats, c1->nativeformats))) {
+               (ast_format_cap_identical(ast_channel_nativeformats(c0), ast_channel_nativeformats(c1)))) {
                return 0;
        }
 
index ee423d3..b56b7be 100644 (file)
@@ -137,7 +137,7 @@ static int custom_log(struct ast_cdr *cdr)
        /* We need to dup here since the cdr actually belongs to the other channel,
           so when we release this channel we don't want the CDR getting cleaned
           up prematurely. */
-       dummy->cdr = ast_cdr_dup(cdr);
+       ast_channel_cdr_set(dummy, ast_cdr_dup(cdr));
 
        AST_RWLIST_RDLOCK(&sinks);
 
index 1d9eb6a..0d9f46d 100644 (file)
@@ -165,7 +165,7 @@ static int manager_log(struct ast_cdr *cdr)
                        ast_log(LOG_ERROR, "Unable to allocate channel for variable substitution.\n");
                        return 0;
                }
-               dummy->cdr = ast_cdr_dup(cdr);
+               ast_channel_cdr_set(dummy, ast_cdr_dup(cdr));
                pbx_substitute_variables_helper(dummy, ast_str_buffer(customfields), buf, sizeof(buf) - 1);
                ast_channel_unref(dummy);
        }
index 65ef5b8..4351c1e 100644 (file)
@@ -252,7 +252,7 @@ static int write_cdr(struct ast_cdr *cdr)
                        ast_mutex_unlock(&lock);
                        return 0;
                }
-               dummy->cdr = ast_cdr_dup(cdr);
+               ast_channel_cdr_set(dummy, ast_cdr_dup(cdr));
                AST_LIST_TRAVERSE(&sql_values, value, list) {
                        pbx_substitute_variables_helper(dummy, value->expression, subst_buf, sizeof(subst_buf) - 1);
                        escaped = sqlite3_mprintf("%q", subst_buf);
index adf2605..e593812 100644 (file)
@@ -93,7 +93,7 @@ static int syslog_log(struct ast_cdr *cdr)
        /* We need to dup here since the cdr actually belongs to the other channel,
           so when we release this channel we don't want the CDR getting cleaned
           up prematurely. */
-       dummy->cdr = ast_cdr_dup(cdr);
+       ast_channel_cdr_set(dummy, ast_cdr_dup(cdr));
 
        AST_RWLIST_RDLOCK(&sinks);
 
index a0fd09a..b2744af 100644 (file)
@@ -298,18 +298,18 @@ static AST_LIST_HEAD_STATIC(agents, agent_pvt);   /*!< Holds the list of agents (l
 
 #define CHECK_FORMATS(ast, p) do { \
        if (p->chan) {\
-               if (!(ast_format_cap_identical(ast->nativeformats, p->chan->nativeformats))) { \
+               if (!(ast_format_cap_identical(ast_channel_nativeformats(ast), ast_channel_nativeformats(p->chan)))) { \
                        char tmp1[256], tmp2[256]; \
-                       ast_debug(1, "Native formats changing from '%s' to '%s'\n", ast_getformatname_multiple(tmp1, sizeof(tmp1), ast->nativeformats), ast_getformatname_multiple(tmp2, sizeof(tmp2), p->chan->nativeformats)); \
+                       ast_debug(1, "Native formats changing from '%s' to '%s'\n", ast_getformatname_multiple(tmp1, sizeof(tmp1), ast_channel_nativeformats(ast)), ast_getformatname_multiple(tmp2, sizeof(tmp2), ast_channel_nativeformats(p->chan))); \
                        /* Native formats changed, reset things */ \
-                       ast_format_cap_copy(ast->nativeformats, p->chan->nativeformats); \
+                       ast_format_cap_copy(ast_channel_nativeformats(ast), ast_channel_nativeformats(p->chan)); \
                        ast_debug(1, "Resetting read to '%s' and write to '%s'\n", ast_getformatname(&ast->readformat), ast_getformatname(&ast->writeformat));\
                        ast_set_read_format(ast, &ast->readformat); \
                        ast_set_write_format(ast, &ast->writeformat); \
                } \
-               if ((ast_format_cmp(&p->chan->readformat, &ast->rawreadformat) != AST_FORMAT_CMP_EQUAL) && !p->chan->generator)  \
+               if ((ast_format_cmp(&p->chan->readformat, &ast->rawreadformat) != AST_FORMAT_CMP_EQUAL) && !ast_channel_generator(p->chan))  \
                        ast_set_read_format(p->chan, &ast->rawreadformat); \
-               if ((ast_format_cmp(&p->chan->writeformat, &ast->rawwriteformat) != AST_FORMAT_CMP_EQUAL) && !p->chan->generator) \
+               if ((ast_format_cmp(&p->chan->writeformat, &ast->rawwriteformat) != AST_FORMAT_CMP_EQUAL) && !ast_channel_generator(p->chan)) \
                        ast_set_write_format(p->chan, &ast->rawwriteformat); \
        } \
 } while(0)
@@ -525,7 +525,7 @@ static int agent_cleanup(struct agent_pvt *p)
        ast_mutex_lock(&p->lock);
        chan = p->owner;
        p->owner = NULL;
-       chan->tech_pvt = NULL;
+       ast_channel_tech_pvt_set(chan, NULL);
        /* Release ownership of the agent to other threads (presumably running the login app). */
        p->app_sleep_cond = 1;
        p->app_lock_flag = 0;
@@ -558,7 +558,7 @@ static int __agent_start_monitoring(struct ast_channel *ast, struct agent_pvt *p
        int res = -1;
        if (!p)
                return -1;
-       if (!ast->monitor) {
+       if (!ast_channel_monitor(ast)) {
                snprintf(filename, sizeof(filename), "agent-%s-%s",p->agent, ast_channel_uniqueid(ast));
                /* substitute . for - */
                if ((pointer = strchr(filename, '.')))
@@ -570,8 +570,8 @@ static int __agent_start_monitoring(struct ast_channel *ast, struct agent_pvt *p
 #if 0
                ast_verbose("name is %s, link is %s\n",tmp, tmp2);
 #endif
-               if (!ast->cdr)
-                       ast->cdr = ast_cdr_alloc();
+               if (!ast_channel_cdr(ast))
+                       ast_channel_cdr_set(ast, ast_cdr_alloc());
                ast_cdr_setuserfield(ast, tmp2);
                res = 0;
        } else
@@ -581,12 +581,12 @@ static int __agent_start_monitoring(struct ast_channel *ast, struct agent_pvt *p
 
 static int agent_start_monitoring(struct ast_channel *ast, int needlock)
 {
-       return __agent_start_monitoring(ast, ast->tech_pvt, needlock);
+       return __agent_start_monitoring(ast, ast_channel_tech_pvt(ast), needlock);
 }
 
 static struct ast_frame *agent_read(struct ast_channel *ast)
 {
-       struct agent_pvt *p = ast->tech_pvt;
+       struct agent_pvt *p = ast_channel_tech_pvt(ast);
        struct ast_frame *f = NULL;
        static struct ast_frame answer_frame = { AST_FRAME_CONTROL, { AST_CONTROL_ANSWER } };
        int cur_time = time(NULL);
@@ -601,7 +601,7 @@ static struct ast_frame *agent_read(struct ast_channel *ast)
        }
        if (p->chan) {
                ast_copy_flags(p->chan, ast, AST_FLAG_EXCEPTION);
-               p->chan->fdno = (ast->fdno == AST_AGENT_FD) ? AST_TIMING_FD : ast->fdno;
+               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
                f = &ast_null_frame;
@@ -616,7 +616,7 @@ static struct ast_frame *agent_read(struct ast_channel *ast)
        } else {
                /* if acknowledgement is not required, and the channel is up, we may have missed
                        an AST_CONTROL_ANSWER (if there was one), so mark the call acknowledged anyway */
-               if (!p->ackcall && !p->acknowledged && p->chan && (p->chan->_state == AST_STATE_UP)) {
+               if (!p->ackcall && !p->acknowledged && p->chan && (ast_channel_state(p->chan) == AST_STATE_UP)) {
                        p->acknowledged = 1;
                }
 
@@ -697,7 +697,7 @@ static struct ast_frame *agent_read(struct ast_channel *ast)
 
        CLEANUP(ast,p);
        if (p->chan && !p->chan->_bridge) {
-               if (strcasecmp(p->chan->tech->type, "Local")) {
+               if (strcasecmp(ast_channel_tech(p->chan)->type, "Local")) {
                        p->chan->_bridge = 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));
@@ -711,7 +711,7 @@ static struct ast_frame *agent_read(struct ast_channel *ast)
 
 static int agent_sendhtml(struct ast_channel *ast, int subclass, const char *data, int datalen)
 {
-       struct agent_pvt *p = ast->tech_pvt;
+       struct agent_pvt *p = ast_channel_tech_pvt(ast);
        int res = -1;
        ast_mutex_lock(&p->lock);
        if (p->chan) 
@@ -722,7 +722,7 @@ static int agent_sendhtml(struct ast_channel *ast, int subclass, const char *dat
 
 static int agent_sendtext(struct ast_channel *ast, const char *text)
 {
-       struct agent_pvt *p = ast->tech_pvt;
+       struct agent_pvt *p = ast_channel_tech_pvt(ast);
        int res = -1;
        ast_mutex_lock(&p->lock);
        if (p->chan) 
@@ -733,7 +733,7 @@ static int agent_sendtext(struct ast_channel *ast, const char *text)
 
 static int agent_write(struct ast_channel *ast, struct ast_frame *f)
 {
-       struct agent_pvt *p = ast->tech_pvt;
+       struct agent_pvt *p = ast_channel_tech_pvt(ast);
        int res = -1;
        CHECK_FORMATS(ast, p);
        ast_mutex_lock(&p->lock);
@@ -758,7 +758,7 @@ static int agent_write(struct ast_channel *ast, struct ast_frame *f)
 
 static int agent_fixup(struct ast_channel *oldchan, struct ast_channel *newchan)
 {
-       struct agent_pvt *p = newchan->tech_pvt;
+       struct agent_pvt *p = ast_channel_tech_pvt(newchan);
        ast_mutex_lock(&p->lock);
        if (p->owner != oldchan) {
                ast_log(LOG_WARNING, "old channel wasn't %p but was %p\n", oldchan, p->owner);
@@ -772,7 +772,7 @@ static int agent_fixup(struct ast_channel *oldchan, struct ast_channel *newchan)
 
 static int agent_indicate(struct ast_channel *ast, int condition, const void *data, size_t datalen)
 {
-       struct agent_pvt *p = ast->tech_pvt;
+       struct agent_pvt *p = ast_channel_tech_pvt(ast);
        int res = -1;
        ast_mutex_lock(&p->lock);
        if (p->chan && !ast_check_hangup(p->chan)) {
@@ -786,7 +786,7 @@ static int agent_indicate(struct ast_channel *ast, int condition, const void *da
                        usleep(1);
                        ast_channel_lock(ast);
                }
-               res = p->chan->tech->indicate ? p->chan->tech->indicate(p->chan, condition, data, datalen) : -1;
+               res = ast_channel_tech(p->chan)->indicate ? ast_channel_tech(p->chan)->indicate(p->chan, condition, data, datalen) : -1;
                ast_channel_unlock(p->chan);
        } else
                res = 0;
@@ -796,7 +796,7 @@ static int agent_indicate(struct ast_channel *ast, int condition, const void *da
 
 static int agent_digit_begin(struct ast_channel *ast, char digit)
 {
-       struct agent_pvt *p = ast->tech_pvt;
+       struct agent_pvt *p = ast_channel_tech_pvt(ast);
        ast_mutex_lock(&p->lock);
        if (p->chan) {
                ast_senddigit_begin(p->chan, digit);
@@ -807,7 +807,7 @@ static int agent_digit_begin(struct ast_channel *ast, char digit)
 
 static int agent_digit_end(struct ast_channel *ast, char digit, unsigned int duration)
 {
-       struct agent_pvt *p = ast->tech_pvt;
+       struct agent_pvt *p = ast_channel_tech_pvt(ast);
        ast_mutex_lock(&p->lock);
        if (p->chan) {
                ast_senddigit_end(p->chan, digit, duration);
@@ -818,7 +818,7 @@ static int agent_digit_end(struct ast_channel *ast, char digit, unsigned int dur
 
 static int agent_call(struct ast_channel *ast, const char *dest, int timeout)
 {
-       struct agent_pvt *p = ast->tech_pvt;
+       struct agent_pvt *p = ast_channel_tech_pvt(ast);
        int res = -1;
        int newstate=0;
        struct ast_channel *chan;
@@ -859,7 +859,7 @@ static int agent_call(struct ast_channel *ast, const char *dest, int timeout)
 
        if (!res) {
                struct ast_format tmpfmt;
-               res = ast_set_read_format_from_cap(p->chan, p->chan->nativeformats);
+               res = ast_set_read_format_from_cap(p->chan, ast_channel_nativeformats(p->chan));
                ast_debug(3, "Set read format, result '%d'\n", res);
                if (res)
                        ast_log(LOG_WARNING, "Unable to set read format to %s\n", ast_getformatname(&tmpfmt));
@@ -871,7 +871,7 @@ static int agent_call(struct ast_channel *ast, const char *dest, int timeout)
 
        if (!res) {
                struct ast_format tmpfmt;
-               res = ast_set_write_format_from_cap(p->chan, p->chan->nativeformats);
+               res = ast_set_write_format_from_cap(p->chan, ast_channel_nativeformats(p->chan));
                ast_debug(3, "Set write format, result '%d'\n", res);
                if (res)
                        ast_log(LOG_WARNING, "Unable to set write format to %s\n", ast_getformatname(&tmpfmt));
@@ -902,11 +902,11 @@ struct ast_channel* agent_get_base_channel(struct ast_channel *chan)
        struct ast_channel *base = chan;
 
        /* chan is locked by the calling function */
-       if (!chan || !chan->tech_pvt) {
-               ast_log(LOG_ERROR, "whoa, you need a channel (0x%ld) with a tech_pvt (0x%ld) to get a base channel.\n", (long)chan, (chan)?(long)chan->tech_pvt:(long)NULL);
+       if (!chan || !ast_channel_tech_pvt(chan)) {
+               ast_log(LOG_ERROR, "whoa, you need a channel (0x%ld) with a tech_pvt (0x%ld) to get a base channel.\n", (long)chan, (chan)?(long)ast_channel_tech_pvt(chan):(long)NULL);
                return NULL;
        }
-       p = chan->tech_pvt;
+       p = ast_channel_tech_pvt(chan);
        if (p->chan) 
                base = p->chan;
        return base;
@@ -920,7 +920,7 @@ int agent_set_base_channel(struct ast_channel *chan, struct ast_channel *base)
                ast_log(LOG_ERROR, "whoa, you need a channel (0x%ld) and a base channel (0x%ld) for setting.\n", (long)chan, (long)base);
                return -1;
        }
-       p = chan->tech_pvt;
+       p = ast_channel_tech_pvt(chan);
        if (!p) {
                ast_log(LOG_ERROR, "whoa, channel %s is missing his tech_pvt structure!!.\n", ast_channel_name(chan));
                return -1;
@@ -931,7 +931,7 @@ int agent_set_base_channel(struct ast_channel *chan, struct ast_channel *base)
 
 static int agent_hangup(struct ast_channel *ast)
 {
-       struct agent_pvt *p = ast->tech_pvt;
+       struct agent_pvt *p = ast_channel_tech_pvt(ast);
        struct ast_channel *indicate_chan = NULL;
        char *tmp_moh; /* moh buffer for indicating after unlocking p */
 
@@ -943,7 +943,7 @@ static int agent_hangup(struct ast_channel *ast)
 
        ast_mutex_lock(&p->lock);
        p->owner = NULL;
-       ast->tech_pvt = NULL;
+       ast_channel_tech_pvt_set(ast, NULL);
        p->app_sleep_cond = 1;
        p->acknowledged = 0;
 
@@ -958,8 +958,8 @@ static int agent_hangup(struct ast_channel *ast)
         * as in apps/app_chanisavail.c:chanavail_exec()
         */
 
-       ast_debug(1, "Hangup called for state %s\n", ast_state2str(ast->_state));
-       if (p->start && (ast->_state != AST_STATE_UP)) {
+       ast_debug(1, "Hangup called for state %s\n", ast_state2str(ast_channel_state(ast)));
+       if (p->start && (ast_channel_state(ast) != AST_STATE_UP)) {
                p->start = 0;
        } else
                p->start = 0;
@@ -1078,7 +1078,7 @@ static int agent_ack_sleep(void *data)
 
 static struct ast_channel *agent_bridgedchannel(struct ast_channel *chan, struct ast_channel *bridge)
 {
-       struct agent_pvt *p = bridge->tech_pvt;
+       struct agent_pvt *p = ast_channel_tech_pvt(bridge);
        struct ast_channel *ret = NULL;
 
        if (p) {
@@ -1111,9 +1111,9 @@ static struct ast_channel *agent_new(struct agent_pvt *p, int state, const char
                return NULL;
        }
 
-       tmp->tech = &agent_tech;
+       ast_channel_tech_set(tmp, &agent_tech);
        if (p->chan) {
-               ast_format_cap_copy(tmp->nativeformats, p->chan->nativeformats);
+               ast_format_cap_copy(ast_channel_nativeformats(tmp), ast_channel_nativeformats(p->chan));
                ast_format_copy(&tmp->writeformat, &p->chan->writeformat);
                ast_format_copy(&tmp->rawwriteformat, &p->chan->writeformat);
                ast_format_copy(&tmp->readformat, &p->chan->readformat);
@@ -1127,12 +1127,12 @@ static struct ast_channel *agent_new(struct agent_pvt *p, int state, const char
                ast_format_set(&tmp->rawwriteformat, AST_FORMAT_SLINEAR, 0);
                ast_format_set(&tmp->readformat, AST_FORMAT_SLINEAR, 0);
                ast_format_set(&tmp->rawreadformat, AST_FORMAT_SLINEAR, 0);
-               ast_format_cap_add(tmp->nativeformats, &tmp->writeformat);
+               ast_format_cap_add(ast_channel_nativeformats(tmp), &tmp->writeformat);
        }
        /* Safe, agentlock already held */
-       tmp->tech_pvt = p;
+       ast_channel_tech_pvt_set(tmp, p);
        p->owner = tmp;
-       tmp->priority = 1;
+       ast_channel_priority_set(tmp, 1);
        return tmp;
 }
 
@@ -1990,7 +1990,7 @@ static int login_exec(struct ast_channel *chan, const char *data)
                }
        }
 
-       if (chan->_state != AST_STATE_UP)
+       if (ast_channel_state(chan) != AST_STATE_UP)
                res = ast_answer(chan);
        if (!res) {
                if (!ast_strlen_zero(args.agent_id))
@@ -2097,14 +2097,14 @@ static int login_exec(struct ast_channel *chan, const char *data)
                                        ast_mutex_lock(&p->lock);
                                        if (!res) {
                                                struct ast_format tmpfmt;
-                                               res = ast_set_read_format_from_cap(chan, chan->nativeformats);
+                                               res = ast_set_read_format_from_cap(chan, ast_channel_nativeformats(chan));
                                                if (res) {
                                                        ast_log(LOG_WARNING, "Unable to set read format to %s\n", ast_getformatname(&tmpfmt));
                                                }
                                        }
                                        if (!res) {
                                                struct ast_format tmpfmt;
-                                               res = ast_set_write_format_from_cap(chan, chan->nativeformats);
+                                               res = ast_set_write_format_from_cap(chan, ast_channel_nativeformats(chan));
                                                if (res) {
                                                        ast_log(LOG_WARNING, "Unable to set write format to %s\n", ast_getformatname(&tmpfmt));
                                                }
@@ -2123,8 +2123,8 @@ static int login_exec(struct ast_channel *chan, const char *data)
                                                              "Channel: %s\r\n"
                                                              "Uniqueid: %s\r\n",
                                                              p->agent, ast_channel_name(chan), ast_channel_uniqueid(chan));
-                                               if (update_cdr && chan->cdr)
-                                                       snprintf(chan->cdr->channel, sizeof(chan->cdr->channel), "Agent/%s", p->agent);
+                                               if (update_cdr && ast_channel_cdr(chan))
+                                                       snprintf(ast_channel_cdr(chan)->channel, sizeof(ast_channel_cdr(chan)->channel), "Agent/%s", p->agent);
                                                ast_queue_log("NONE", ast_channel_uniqueid(chan), agent, "AGENTLOGIN", "%s", ast_channel_name(chan));
                                                ast_verb(2, "Agent '%s' logged in (format %s/%s)\n", p->agent,
                                                                    ast_getformatname(&chan->readformat), ast_getformatname(&chan->writeformat));
@@ -2294,7 +2294,7 @@ static int agentmonitoroutgoing_exec(struct ast_channel *chan, const char *data)
                        AST_LIST_LOCK(&agents);
                        AST_LIST_TRAVERSE(&agents, p, list) {
                                if (!strcasecmp(p->agent, tmp)) {
-                                       if (changeoutgoing) snprintf(chan->cdr->channel, sizeof(chan->cdr->channel), "Agent/%s", p->agent);
+                                       if (changeoutgoing) snprintf(ast_channel_cdr(chan)->channel, sizeof(ast_channel_cdr(chan)->channel), "Agent/%s", p->agent);
                                        __agent_start_monitoring(chan, p, 1);
                                        break;
                                }
index 38ef917..4424ef1 100644 (file)
@@ -366,7 +366,7 @@ static int alsa_answer(struct ast_channel *c)
 static int alsa_hangup(struct ast_channel *c)
 {
        ast_mutex_lock(&alsalock);
-       c->tech_pvt = NULL;
+       ast_channel_tech_pvt_set(c, NULL);
        alsa.owner = NULL;
        ast_verbose(" << Hangup on console >> \n");
        ast_module_unref(ast_module_info->self);
@@ -489,7 +489,7 @@ static struct ast_frame *alsa_read(struct ast_channel *chan)
                /* A real frame */
                readpos = 0;
                left = FRAME_SIZE;
-               if (chan->_state != AST_STATE_UP) {
+               if (ast_channel_state(chan) != AST_STATE_UP) {
                        /* Don't transmit unless it's up */
                        ast_mutex_unlock(&alsalock);
                        return &f;
@@ -517,7 +517,7 @@ static struct ast_frame *alsa_read(struct ast_channel *chan)
 
 static int alsa_fixup(struct ast_channel *oldchan, struct ast_channel *newchan)
 {
-       struct chan_alsa_pvt *p = newchan->tech_pvt;
+       struct chan_alsa_pvt *p = ast_channel_tech_pvt(newchan);
 
        ast_mutex_lock(&alsalock);
        p->owner = newchan;
@@ -570,13 +570,13 @@ static struct ast_channel *alsa_new(struct chan_alsa_pvt *p, int state, const ch
        if (!(tmp = ast_channel_alloc(1, state, 0, 0, "", p->exten, p->context, linkedid, 0, "ALSA/%s", indevname)))
                return NULL;
 
-       tmp->tech = &alsa_tech;
+       ast_channel_tech_set(tmp, &alsa_tech);
        ast_channel_set_fd(tmp, 0, readdev);
        ast_format_set(&tmp->readformat, AST_FORMAT_SLINEAR, 0);
        ast_format_set(&tmp->writeformat, AST_FORMAT_SLINEAR, 0);
-       ast_format_cap_add(tmp->nativeformats, &tmp->writeformat);
+       ast_format_cap_add(ast_channel_nativeformats(tmp), &tmp->writeformat);
 
-       tmp->tech_pvt = p;
+       ast_channel_tech_pvt_set(tmp, p);
        if (!ast_strlen_zero(p->context))
                ast_channel_context_set(tmp, p->context);
        if (!ast_strlen_zero(p->exten))
index c57f117..67af073 100644 (file)
@@ -79,7 +79,7 @@ struct bridge_pvt {
 /*! \brief Called when the user of this channel wants to get the actual channel in the bridge */
 static struct ast_channel *bridge_bridgedchannel(struct ast_channel *chan, struct ast_channel *bridge)
 {
-       struct bridge_pvt *p = chan->tech_pvt;
+       struct bridge_pvt *p = ast_channel_tech_pvt(chan);
        return (chan == p->input) ? p->output : bridge;
 }
 
@@ -92,7 +92,7 @@ static struct ast_frame  *bridge_read(struct ast_channel *ast)
 /*! \brief Called when a frame should be written out to a channel */
 static int bridge_write(struct ast_channel *ast, struct ast_frame *f)
 {
-       struct bridge_pvt *p = ast->tech_pvt;
+       struct bridge_pvt *p = ast_channel_tech_pvt(ast);
        struct ast_channel *other = NULL;
 
        ao2_lock(p);
@@ -118,7 +118,7 @@ static int bridge_write(struct ast_channel *ast, struct ast_frame *f)
 /*! \brief Called when the channel should actually be dialed */
 static int bridge_call(struct ast_channel *ast, const char *dest, int timeout)
 {
-       struct bridge_pvt *p = ast->tech_pvt;
+       struct bridge_pvt *p = ast_channel_tech_pvt(ast);
 
        /* If no bridge has been provided on the input channel, bail out */
        if (!ast->bridge) {
@@ -134,7 +134,7 @@ static int bridge_call(struct ast_channel *ast, const char *dest, int timeout)
 /*! \brief Called when a channel should be hung up */
 static int bridge_hangup(struct ast_channel *ast)
 {
-       struct bridge_pvt *p = ast->tech_pvt;
+       struct bridge_pvt *p = ast_channel_tech_pvt(ast);
 
        if (!p) {
                return 0;
@@ -148,7 +148,7 @@ static int bridge_hangup(struct ast_channel *ast)
        }
        ao2_unlock(p);
 
-       ast->tech_pvt = NULL;
+       ast_channel_tech_pvt_set(ast, NULL);
        ao2_ref(p, -1);
 
        return 0;
@@ -177,15 +177,17 @@ static struct ast_channel *bridge_request(const char *type, struct ast_format_ca
        }
 
        /* Setup parameters on both new channels */
-       p->input->tech = p->output->tech = &bridge_tech;
+       ast_channel_tech_set(p->input, &bridge_tech);
+       ast_channel_tech_set(p->output, &bridge_tech);
 
        ao2_ref(p, 2);
-       p->input->tech_pvt = p->output->tech_pvt = p;
+       ast_channel_tech_pvt_set(p->input, p);
+       ast_channel_tech_pvt_set(p->output, p);
 
        ast_format_set(&slin, AST_FORMAT_SLINEAR, 0);
 
-       ast_format_cap_add(p->input->nativeformats, &slin);
-       ast_format_cap_add(p->output->nativeformats, &slin);
+       ast_format_cap_add(ast_channel_nativeformats(p->input), &slin);
+       ast_format_cap_add(ast_channel_nativeformats(p->output), &slin);
        ast_format_copy(&p->input->readformat, &slin);
        ast_format_copy(&p->output->readformat, &slin);
        ast_format_copy(&p->input->rawreadformat, &slin);
index 9d2b17d..a47f898 100644 (file)
@@ -419,11 +419,11 @@ static struct ast_channel *console_new(struct console_pvt *pvt, const char *ext,
                return NULL;
        }
 
-       chan->tech = &console_tech;
+       ast_channel_tech_set(chan, &console_tech);
        ast_format_set(&chan->readformat, AST_FORMAT_SLINEAR16, 0);
        ast_format_set(&chan->writeformat, AST_FORMAT_SLINEAR16, 0);
-       ast_format_cap_add(chan->nativeformats, &chan->readformat);
-       chan->tech_pvt = ref_pvt(pvt);
+       ast_format_cap_add(ast_channel_nativeformats(chan), &chan->readformat);
+       ast_channel_tech_pvt_set(chan, ref_pvt(pvt));
 
        pvt->owner = chan;
 
@@ -434,7 +434,7 @@ static struct ast_channel *console_new(struct console_pvt *pvt, const char *ext,
 
        if (state != AST_STATE_DOWN) {
                if (ast_pbx_start(chan)) {
-                       chan->hangupcause = AST_CAUSE_SWITCH_CONGESTION;
+                       ast_channel_hangupcause_set(chan, AST_CAUSE_SWITCH_CONGESTION);
                        ast_hangup(chan);
                        chan = NULL;
                } else
@@ -503,7 +503,7 @@ static int console_text(struct ast_channel *c, const char *text)
 
 static int console_hangup(struct ast_channel *c)
 {
-       struct console_pvt *pvt = c->tech_pvt;
+       struct console_pvt *pvt = ast_channel_tech_pvt(c);
 
        ast_verb(1, V_BEGIN "Hangup on Console" V_END);
 
@@ -511,14 +511,14 @@ static int console_hangup(struct ast_channel *c)
        pvt->owner = NULL;
        stop_stream(pvt);
 
-       c->tech_pvt = unref_pvt(pvt);
+       ast_channel_tech_pvt_set(c, unref_pvt(pvt));
 
        return 0;
 }
 
 static int console_answer(struct ast_channel *c)
 {
-       struct console_pvt *pvt = c->tech_pvt;
+       struct console_pvt *pvt = ast_channel_tech_pvt(c);
 
        ast_verb(1, V_BEGIN "Call from Console has been Answered" V_END);
 
@@ -556,7 +556,7 @@ static struct ast_frame *console_read(struct ast_channel *chan)
 
 static int console_call(struct ast_channel *c, const char *dest, int timeout)
 {
-       struct console_pvt *pvt = c->tech_pvt;
+       struct console_pvt *pvt = ast_channel_tech_pvt(c);
        enum ast_control_frame_type ctrl;
 
        ast_verb(1, V_BEGIN "Call to device '%s' on console from '%s' <%s>" V_END,
@@ -586,7 +586,7 @@ static int console_call(struct ast_channel *c, const char *dest, int timeout)
 
 static int console_write(struct ast_channel *chan, struct ast_frame *f)
 {
-       struct console_pvt *pvt = chan->tech_pvt;
+       struct console_pvt *pvt = ast_channel_tech_pvt(chan);
 
        Pa_WriteStream(pvt->stream, f->data.ptr, f->samples);
 
@@ -595,7 +595,7 @@ static int console_write(struct ast_channel *chan, struct ast_frame *f)
 
 static int console_indicate(struct ast_channel *chan, int cond, const void *data, size_t datalen)
 {
-       struct console_pvt *pvt = chan->tech_pvt;
+       struct console_pvt *pvt = ast_channel_tech_pvt(chan);
        int res = 0;
 
        switch (cond) {
@@ -631,7 +631,7 @@ static int console_indicate(struct ast_channel *chan, int cond, const void *data
 
 static int console_fixup(struct ast_channel *oldchan, struct ast_channel *newchan)
 {
-       struct console_pvt *pvt = newchan->tech_pvt;
+       struct console_pvt *pvt = ast_channel_tech_pvt(newchan);
 
        pvt->owner = newchan;
 
index 73bfcfe..59e1ff0 100644 (file)
@@ -2233,7 +2233,7 @@ static void my_get_and_handle_alarms(void *pvt)
 
 static void *my_get_sigpvt_bridged_channel(struct ast_channel *chan)
 {
-       struct dahdi_pvt *p = ast_bridged_channel(chan)->tech_pvt;
+       struct dahdi_pvt *p = ast_channel_tech_pvt(ast_bridged_channel(chan));
        if (p)
                return p->sig_pvt;
        else
@@ -3077,7 +3077,7 @@ static void my_pri_fixup_chans(void *chan_old, void *chan_new)
        new_chan->owner = old_chan->owner;
        old_chan->owner = NULL;
        if (new_chan->owner) {
-               new_chan->owner->tech_pvt = new_chan;
+               ast_channel_tech_pvt_set(new_chan->owner, new_chan);
                new_chan->owner->fds[0] = new_chan->subs[SUB_REAL].dfd;
                new_chan->subs[SUB_REAL].owner = old_chan->subs[SUB_REAL].owner;
                old_chan->subs[SUB_REAL].owner = NULL;
@@ -3865,7 +3865,7 @@ static openr2_calling_party_category_t dahdi_r2_get_channel_category(struct ast_
 {
        openr2_calling_party_category_t cat;
        const char *catstr = pbx_builtin_getvar_helper(c, "MFCR2_CATEGORY");
-       struct dahdi_pvt *p = c->tech_pvt;
+       struct dahdi_pvt *p = ast_channel_tech_pvt(c);
        if (ast_strlen_zero(catstr)) {
                ast_debug(1, "No MFC/R2 category specified for chan %s, using default %s\n",
                                ast_channel_name(c), openr2_proto_get_category_string(p->mfcr2_category));
@@ -3935,7 +3935,7 @@ static void dahdi_r2_on_protocol_error(openr2_chan_t *r2chan, openr2_protocol_er
        struct dahdi_pvt *p = openr2_chan_get_client_data(r2chan);
        ast_log(LOG_ERROR, "MFC/R2 protocol error on chan %d: %s\n", openr2_chan_get_number(r2chan), openr2_proto_get_error(reason));
        if (p->owner) {
-               p->owner->hangupcause = AST_CAUSE_PROTOCOL_ERROR;
+               ast_channel_hangupcause_set(p->owner, AST_CAUSE_PROTOCOL_ERROR);
                p->owner->_softhangup |= AST_SOFTHANGUP_DEV;
        }
        ast_mutex_lock(&p->lock);
@@ -4109,7 +4109,7 @@ static void dahdi_r2_on_call_disconnect(openr2_chan_t *r2chan, openr2_call_disco
        }
        /* when we have an owner we don't call dahdi_r2_disconnect_call here, that will
           be done in dahdi_hangup */
-       if (p->owner->_state == AST_STATE_UP) {
+       if (ast_channel_state(p->owner) == AST_STATE_UP) {
                p->owner->_softhangup |= AST_SOFTHANGUP_DEV;
                ast_mutex_unlock(&p->lock);
        } else if (openr2_chan_get_direction(r2chan) == OR2_DIR_FORWARD) {
@@ -4468,7 +4468,7 @@ static int dahdi_digit_begin(struct ast_channel *chan, char digit)
        int dtmf = -1;
        int res;
 
-       pvt = chan->tech_pvt;
+       pvt = ast_channel_tech_pvt(chan);
 
        ast_mutex_lock(&pvt->lock);
 
@@ -4522,7 +4522,7 @@ static int dahdi_digit_end(struct ast_channel *chan, char digit, unsigned int du
        int idx;
        int x;
 
-       pvt = chan->tech_pvt;
+       pvt = ast_channel_tech_pvt(chan);
 
        ast_mutex_lock(&pvt->lock);
 
@@ -5334,7 +5334,7 @@ static int send_callerid(struct dahdi_pvt *p)
 
 static int dahdi_callwait(struct ast_channel *ast)
 {
-       struct dahdi_pvt *p = ast->tech_pvt;
+       struct dahdi_pvt *p = ast_channel_tech_pvt(ast);
        struct ast_format tmpfmt;
        p->callwaitingrepeat = CALLWAITING_REPEAT_SAMPLES;
        if (p->cidspill) {
@@ -5368,7 +5368,7 @@ static int dahdi_callwait(struct ast_channel *ast)
 
 static int dahdi_call(struct ast_channel *ast, const char *rdest, int timeout)
 {
-       struct dahdi_pvt *p = ast->tech_pvt;
+       struct dahdi_pvt *p = ast_channel_tech_pvt(ast);
        int x, res, mysig;
        char *dest;
        AST_DECLARE_APP_ARGS(args,
@@ -5405,12 +5405,12 @@ static int dahdi_call(struct ast_channel *ast, const char *rdest, int timeout)
                ast_copy_string(p->exten, args.ext, sizeof(p->exten));
        }
 
-       if ((ast->_state == AST_STATE_BUSY)) {
+       if ((ast_channel_state(ast) == AST_STATE_BUSY)) {
                p->subs[SUB_REAL].needbusy = 1;
                ast_mutex_unlock(&p->lock);
                return 0;
        }
-       if ((ast->_state != AST_STATE_DOWN) && (ast->_state != AST_STATE_RESERVED)) {
+       if ((ast_channel_state(ast) != AST_STATE_DOWN) && (ast_channel_state(ast) != AST_STATE_RESERVED)) {
                ast_log(LOG_WARNING, "dahdi_call called on %s, neither down nor reserved\n", ast_channel_name(ast));
                ast_mutex_unlock(&p->lock);
                return -1;
@@ -5430,7 +5430,7 @@ static int dahdi_call(struct ast_channel *ast, const char *rdest, int timeout)
                ast_log(LOG_WARNING, "Unable to flush input on channel %d: %s\n", p->channel, strerror(errno));
        p->outgoing = 1;
 
-       if (IS_DIGITAL(ast->transfercapability)){
+       if (IS_DIGITAL(ast_channel_transfercapability(ast))){
                set_actual_gain(p->subs[SUB_REAL].dfd, 0, 0, p->rxdrc, p->txdrc, p->law);
        } else {
                set_actual_gain(p->subs[SUB_REAL].dfd, p->rxgain, p->txgain, p->rxdrc, p->txdrc, p->law);
@@ -5837,7 +5837,7 @@ static void destroy_dahdi_pvt(struct dahdi_pvt *pvt)
        ast_mutex_destroy(&p->lock);
        dahdi_close_sub(p, SUB_REAL);
        if (p->owner)
-               p->owner->tech_pvt = NULL;
+               ast_channel_tech_pvt_set(p->owner, NULL);
        ast_free(p);
 }
 
@@ -5934,7 +5934,7 @@ static int dahdi_send_keypad_facility_exec(struct ast_channel *chan, const char
                return -1;
        }
 
-       p = (struct dahdi_pvt *)chan->tech_pvt;
+       p = (struct dahdi_pvt *)ast_channel_tech_pvt(chan);
 
        if (!p) {
                ast_debug(1, "Unable to find technology private\n");
@@ -5967,11 +5967,11 @@ static int dahdi_send_callrerouting_facility_exec(struct ast_channel *chan, cons
                ast_debug(1, "No data sent to application!\n");
                return -1;
        }
-       if (chan->tech != &dahdi_tech) {
+       if (ast_channel_tech(chan) != &dahdi_tech) {
                ast_debug(1, "Only DAHDI technology accepted!\n");
                return -1;
        }
-       pvt = (struct dahdi_pvt *) chan->tech_pvt;
+       pvt = (struct dahdi_pvt *) ast_channel_tech_pvt(chan);
        if (!pvt) {
                ast_debug(1, "Unable to find technology private\n");
                return -1;
@@ -6003,7 +6003,7 @@ static int dahdi_send_callrerouting_facility_exec(struct ast_channel *chan, cons
                args.reason = NULL;
        }
 
-       pri_send_callrerouting_facility_exec(pvt->sig_pvt, chan->_state, args.destination,
+       pri_send_callrerouting_facility_exec(pvt->sig_pvt, ast_channel_state(chan), args.destination,
                args.original, args.reason);
 
        return res;
@@ -6031,12 +6031,12 @@ static int dahdi_accept_r2_call_exec(struct ast_channel *chan, const char *data)
                return -1;
        }
 
-       if (chan->tech != &dahdi_tech) {
+       if (ast_channel_tech(chan) != &dahdi_tech) {
                ast_debug(1, "Only DAHDI technology accepted!\n");
                return -1;
        }
 
-       p = (struct dahdi_pvt *)chan->tech_pvt;
+       p = (struct dahdi_pvt *)ast_channel_tech_pvt(chan);
        if (!p) {
                ast_debug(1, "Unable to find technology private!\n");
                return -1;
@@ -6182,11 +6182,11 @@ static int dahdi_hangup(struct ast_channel *ast)
        int idx,x;
        int law;
        /*static int restore_gains(struct dahdi_pvt *p);*/
-       struct dahdi_pvt *p = ast->tech_pvt;
+       struct dahdi_pvt *p = ast_channel_tech_pvt(ast);
        struct dahdi_params par;
 
        ast_debug(1, "dahdi_hangup(%s)\n", ast_channel_name(ast));
-       if (!ast->tech_pvt) {
+       if (!ast_channel_tech_pvt(ast)) {
                ast_log(LOG_WARNING, "Asked to hangup channel not connected\n");
                return 0;
        }
@@ -6398,7 +6398,7 @@ static int dahdi_hangup(struct ast_channel *ast)
                                swap_subs(p, SUB_CALLWAIT, SUB_REAL);
                                unalloc_sub(p, SUB_CALLWAIT);
                                p->owner = p->subs[SUB_REAL].owner;
-                               if (p->owner->_state != AST_STATE_UP)
+                               if (ast_channel_state(p->owner) != AST_STATE_UP)
                                        p->subs[SUB_REAL].needanswer = 1;
                                if (ast_bridged_channel(p->subs[SUB_REAL].owner))
                                        ast_queue_control(p->subs[SUB_REAL].owner, AST_CONTROL_UNHOLD);
@@ -6486,7 +6486,7 @@ static int dahdi_hangup(struct ast_channel *ast)
                                const char *r2causestr = pbx_builtin_getvar_helper(ast, "MFCR2_CAUSE");
                                int r2cause_user = r2causestr ? atoi(r2causestr) : 0;
                                openr2_call_disconnect_cause_t r2cause = r2cause_user ? dahdi_ast_cause_to_r2_cause(r2cause_user)
-                                                                                     : dahdi_ast_cause_to_r2_cause(ast->hangupcause);
+                                                                                     : dahdi_ast_cause_to_r2_cause(ast_channel_hangupcause(ast));
                                dahdi_r2_disconnect_call(p, r2cause);
                        }
                } else if (p->mfcr2call) {
@@ -6535,7 +6535,7 @@ static int dahdi_hangup(struct ast_channel *ast)
                case SIG_FXSKS:
                        /* Make sure we're not made available for at least two seconds assuming
                        we were actually used for an inbound or outbound call. */
-                       if (ast->_state != AST_STATE_RESERVED) {
+                       if (ast_channel_state(ast) != AST_STATE_RESERVED) {
                                time(&p->guardtime);
                                p->guardtime += 2;
                        }
@@ -6577,7 +6577,7 @@ static int dahdi_hangup(struct ast_channel *ast)
        p->cid_suppress_expire = 0;
        p->oprmode = 0;
 hangup_out:
-       ast->tech_pvt = NULL;
+       ast_channel_tech_pvt_set(ast, NULL);
        ast_free(p->cidspill);
        p->cidspill = NULL;
 
@@ -6600,7 +6600,7 @@ hangup_out:
 
 static int dahdi_answer(struct ast_channel *ast)
 {
-       struct dahdi_pvt *p = ast->tech_pvt;
+       struct dahdi_pvt *p = ast_channel_tech_pvt(ast);
        int res = 0;
        int idx;
        ast_setstate(ast, AST_STATE_UP);/*! \todo XXX this is redundantly set by the analog and PRI submodules! */
@@ -6696,7 +6696,7 @@ static void enable_dtmf_detect(struct dahdi_pvt *p)
 static int dahdi_queryoption(struct ast_channel *chan, int option, void *data, int *datalen)
 {
        char *cp;
-       struct dahdi_pvt *p = chan->tech_pvt;
+       struct dahdi_pvt *p = ast_channel_tech_pvt(chan);
 
        /* all supported options require data */
        if (!p || !data || (*datalen < 1)) {
@@ -6740,7 +6740,7 @@ static int dahdi_setoption(struct ast_channel *chan, int option, void *data, int
        signed char *scp;
        int x;
        int idx;
-       struct dahdi_pvt *p = chan->tech_pvt, *pp;
+       struct dahdi_pvt *p = ast_channel_tech_pvt(chan), *pp;
        struct oprmode *oprmode;
 
 
@@ -6894,13 +6894,13 @@ static int dahdi_setoption(struct ast_channel *chan, int option, void *data, int
        case AST_OPTION_OPRMODE:  /* Operator services mode */
                oprmode = (struct oprmode *) data;
                /* We don't support operator mode across technologies */
-               if (strcasecmp(chan->tech->type, oprmode->peer->tech->type)) {
+               if (strcasecmp(ast_channel_tech(chan)->type, ast_channel_tech(oprmode->peer)->type)) {
                        ast_log(LOG_NOTICE, "Operator mode not supported on %s to %s calls.\n",
-                                       chan->tech->type, oprmode->peer->tech->type);
+                                       ast_channel_tech(chan)->type, ast_channel_tech(oprmode->peer)->type);
                        errno = EINVAL;
                        return -1;
                }
-               pp = oprmode->peer->tech_pvt;
+               pp = ast_channel_tech_pvt(oprmode->peer);
                p->oprmode = pp->oprmode = 0;
                /* setup peers */
                p->oprpeer = pp;
@@ -6955,7 +6955,7 @@ static int dahdi_setoption(struct ast_channel *chan, int option, void *data, int
 
 static int dahdi_func_read(struct ast_channel *chan, const char *function, char *data, char *buf, size_t len)
 {
-       struct dahdi_pvt *p = chan->tech_pvt;
+       struct dahdi_pvt *p = ast_channel_tech_pvt(chan);
        int res = 0;
 
        if (!p) {
@@ -7094,7 +7094,7 @@ static int parse_buffers_policy(const char *parse, int *num_buffers, int *policy
 
 static int dahdi_func_write(struct ast_channel *chan, const char *function, char *data, const char *value)
 {
-       struct dahdi_pvt *p = chan->tech_pvt;
+       struct dahdi_pvt *p = ast_channel_tech_pvt(chan);
        int res = 0;
 
        if (!p) {
@@ -7278,8 +7278,8 @@ static enum ast_bridge_result dahdi_bridge(struct ast_channel *c0, struct ast_ch
                CHANNEL_DEADLOCK_AVOIDANCE(c0);
        }
 
-       p0 = c0->tech_pvt;
-       p1 = c1->tech_pvt;
+       p0 = ast_channel_tech_pvt(c0);
+       p1 = ast_channel_tech_pvt(c1);
        /* cant do pseudo-channels here */
        if (!p0 || (!p0->sig) || !p1 || (!p1->sig)) {
                ast_channel_unlock(c0);
@@ -7295,8 +7295,8 @@ static enum ast_bridge_result dahdi_bridge(struct ast_channel *c0, struct ast_ch
                return AST_BRIDGE_FAILED;
        }
 
-       op0 = p0 = c0->tech_pvt;
-       op1 = p1 = c1->tech_pvt;
+       op0 = p0 = ast_channel_tech_pvt(c0);
+       op1 = p1 = ast_channel_tech_pvt(c1);
        ofd0 = c0->fds[0];
        ofd1 = c1->fds[0];
        oc0 = p0->owner;
@@ -7413,12 +7413,12 @@ static enum ast_bridge_result dahdi_bridge(struct ast_channel *c0, struct ast_ch
                        p1->subs[SUB_THREEWAY].inthreeway &&
                        p1->subs[SUB_REAL].owner &&
                        p1->subs[SUB_REAL].inthreeway &&
-                       (p1->subs[SUB_REAL].owner->_state == AST_STATE_RINGING)) {
+                       (ast_channel_state(p1->subs[SUB_REAL].owner) == AST_STATE_RINGING)) {
                        ast_debug(1,
                                "Playing ringback on %d/%d(%s) since %d/%d(%s) is in a ringing three-way\n",
                                p0->channel, oi0, ast_channel_name(c0), p1->channel, oi1, ast_channel_name(c1));
                        tone_zone_play_tone(p0->subs[oi0].dfd, DAHDI_TONE_RINGTONE);
-                       os1 = p1->subs[SUB_REAL].owner->_state;
+                       os1 = ast_channel_state(p1->subs[SUB_REAL].owner);
                } else {
                        ast_debug(1, "Stopping tones on %d/%d(%s) talking to %d/%d(%s)\n",
                                p0->channel, oi0, ast_channel_name(c0), p1->channel, oi1, ast_channel_name(c1));
@@ -7428,12 +7428,12 @@ static enum ast_bridge_result dahdi_bridge(struct ast_channel *c0, struct ast_ch
                        p0->subs[SUB_THREEWAY].inthreeway &&
                        p0->subs[SUB_REAL].owner &&
                        p0->subs[SUB_REAL].inthreeway &&
-                       (p0->subs[SUB_REAL].owner->_state == AST_STATE_RINGING)) {
+                       (ast_channel_state(p0->subs[SUB_REAL].owner) == AST_STATE_RINGING)) {
                        ast_debug(1,
                                "Playing ringback on %d/%d(%s) since %d/%d(%s) is in a ringing three-way\n",
                                p1->channel, oi1, ast_channel_name(c1), p0->channel, oi0, ast_channel_name(c0));
                        tone_zone_play_tone(p1->subs[oi1].dfd, DAHDI_TONE_RINGTONE);
-                       os0 = p0->subs[SUB_REAL].owner->_state;
+                       os0 = ast_channel_state(p0->subs[SUB_REAL].owner);
                } else {
                        ast_debug(1, "Stopping tones on %d/%d(%s) talking to %d/%d(%s)\n",
                                p1->channel, oi1, ast_channel_name(c1), p0->channel, oi0, ast_channel_name(c0));
@@ -7489,8 +7489,8 @@ static enum ast_bridge_result dahdi_bridge(struct ast_channel *c0, struct ast_ch
                        CHANNEL_DEADLOCK_AVOIDANCE(c0);
                }
 
-               p0 = c0->tech_pvt;
-               p1 = c1->tech_pvt;
+               p0 = ast_channel_tech_pvt(c0);
+               p1 = ast_channel_tech_pvt(c1);
 
                if (op0 == p0)
                        i0 = dahdi_get_index(c0, p0, 1);
@@ -7505,8 +7505,8 @@ static enum ast_bridge_result dahdi_bridge(struct ast_channel *c0, struct ast_ch
                        (op1 != p1) ||
                        (ofd0 != c0->fds[0]) ||
                        (ofd1 != c1->fds[0]) ||
-                       (p0->subs[SUB_REAL].owner && (os0 > -1) && (os0 != p0->subs[SUB_REAL].owner->_state)) ||
-                       (p1->subs[SUB_REAL].owner && (os1 > -1) && (os1 != p1->subs[SUB_REAL].owner->_state)) ||
+                       (p0->subs[SUB_REAL].owner && (os0 > -1) && (os0 != ast_channel_state(p0->subs[SUB_REAL].owner))) ||
+                       (p1->subs[SUB_REAL].owner && (os1 > -1) && (os1 != ast_channel_state(p1->subs[SUB_REAL].owner))) ||
                        (oc0 != p0->owner) ||
                        (oc1 != p1->owner) ||
                        (t0 != p0->subs[SUB_REAL].inthreeway) ||
@@ -7614,7 +7614,7 @@ return_from_bridge:
 
 static int dahdi_fixup(struct ast_channel *oldchan, struct ast_channel *newchan)
 {
-       struct dahdi_pvt *p = newchan->tech_pvt;
+       struct dahdi_pvt *p = ast_channel_tech_pvt(newchan);
        int x;
 
        ast_mutex_lock(&p->lock);
@@ -7646,7 +7646,7 @@ static int dahdi_fixup(struct ast_channel *oldchan, struct ast_channel *newchan)
 
        ast_mutex_unlock(&p->lock);
 
-       if (newchan->_state == AST_STATE_RINGING) {
+       if (ast_channel_state(newchan) == AST_STATE_RINGING) {
                dahdi_indicate(newchan, AST_CONTROL_RINGING, NULL, 0);
        }
        return 0;
@@ -7694,10 +7694,10 @@ static int attempt_transfer(struct dahdi_pvt *p)
                   stop if now if appropriate */
                if (ast_bridged_channel(p->subs[SUB_THREEWAY].owner))
                        ast_queue_control(p->subs[SUB_THREEWAY].owner, AST_CONTROL_UNHOLD);
-               if (p->subs[SUB_REAL].owner->_state == AST_STATE_RINGING) {
+               if (ast_channel_state(p->subs[SUB_REAL].owner) == AST_STATE_RINGING) {
                        ast_indicate(ast_bridged_channel(p->subs[SUB_REAL].owner), AST_CONTROL_RINGING);
                }
-               if (p->subs[SUB_THREEWAY].owner->_state == AST_STATE_RING) {
+               if (ast_channel_state(p->subs[SUB_THREEWAY].owner) == AST_STATE_RING) {
                        tone_zone_play_tone(p->subs[SUB_THREEWAY].dfd, DAHDI_TONE_RINGTONE);
                }
                 if (ast_channel_masquerade(p->subs[SUB_THREEWAY].owner, ast_bridged_channel(p->subs[SUB_REAL].owner))) {
@@ -7710,10 +7710,10 @@ static int attempt_transfer(struct dahdi_pvt *p)
                unalloc_sub(p, SUB_THREEWAY);
        } else if (ast_bridged_channel(p->subs[SUB_THREEWAY].owner)) {
                ast_queue_control(p->subs[SUB_REAL].owner, AST_CONTROL_UNHOLD);
-               if (p->subs[SUB_THREEWAY].owner->_state == AST_STATE_RINGING) {
+               if (ast_channel_state(p->subs[SUB_THREEWAY].owner) == AST_STATE_RINGING) {
                        ast_indicate(ast_bridged_channel(p->subs[SUB_THREEWAY].owner), AST_CONTROL_RINGING);
                }
-               if (p->subs[SUB_REAL].owner->_state == AST_STATE_RING) {
+               if (ast_channel_state(p->subs[SUB_REAL].owner) == AST_STATE_RING) {
                        tone_zone_play_tone(p->subs[SUB_REAL].dfd, DAHDI_TONE_RINGTONE);
                }
                if (ast_channel_masquerade(p->subs[SUB_REAL].owner, ast_bridged_channel(p->subs[SUB_THREEWAY].owner))) {
@@ -7791,7 +7791,7 @@ static int get_alarms(struct dahdi_pvt *p)
 
 static void dahdi_handle_dtmf(struct ast_channel *ast, int idx, struct ast_frame **dest)
 {
-       struct dahdi_pvt *p = ast->tech_pvt;
+       struct dahdi_pvt *p = ast_channel_tech_pvt(ast);
        struct ast_frame *f = *dest;
 
        ast_debug(1, "%s DTMF digit: 0x%02X '%c' on %s\n",
@@ -7913,7 +7913,7 @@ static struct ast_frame *dahdi_handle_event(struct ast_channel *ast)
        int res, x;
        int idx, mysig;
        char *c;
-       struct dahdi_pvt *p = ast->tech_pvt;
+       struct dahdi_pvt *p = ast_channel_tech_pvt(ast);
        pthread_t threadid;
        struct ast_channel *chan;
        struct ast_frame *f;
@@ -8015,7 +8015,7 @@ static struct ast_frame *dahdi_handle_event(struct ast_channel *ast)
 #endif
        case DAHDI_EVENT_PULSE_START:
                /* Stop tone if there's a pulse start and the PBX isn't started */
-               if (!ast->pbx)
+               if (!ast_channel_pbx(ast))
                        tone_zone_play_tone(p->subs[idx].dfd, -1);
                break;
        case DAHDI_EVENT_DIALCOMPLETE:
@@ -8043,7 +8043,7 @@ static struct ast_frame *dahdi_handle_event(struct ast_channel *ast)
                }
 #endif /* defined(HAVE_PRI) */
 #ifdef HAVE_OPENR2
-               if ((p->sig & SIG_MFCR2) && p->r2chan && ast->_state != AST_STATE_UP) {
+               if ((p->sig & SIG_MFCR2) && p->r2chan && ast_channel_state(ast) != AST_STATE_UP) {
                        /* we don't need to do anything for this event for R2 signaling
                           if the call is being setup */
                        break;
@@ -8067,7 +8067,7 @@ static struct ast_frame *dahdi_handle_event(struct ast_channel *ast)
                                p->dialing = 0;
                                if ((mysig == SIG_E911) || (mysig == SIG_FGC_CAMA) || (mysig == SIG_FGC_CAMAMF)) {
                                        /* if thru with dialing after offhook */
-                                       if (ast->_state == AST_STATE_DIALING_OFFHOOK) {
+                                       if (ast_channel_state(ast) == AST_STATE_DIALING_OFFHOOK) {
                                                ast_setstate(ast, AST_STATE_UP);
                                                p->subs[idx].f.frametype = AST_FRAME_CONTROL;
                                                p->subs[idx].f.subclass.integer = AST_CONTROL_ANSWER;
@@ -8077,7 +8077,7 @@ static struct ast_frame *dahdi_handle_event(struct ast_channel *ast)
                                                ast_setstate(ast,AST_STATE_DIALING_OFFHOOK);
                                        }
                                }
-                               if (ast->_state == AST_STATE_DIALING) {
+                               if (ast_channel_state(ast) == AST_STATE_DIALING) {
                                        if ((p->callprogress & CALLPROGRESS_PROGRESS) && CANPROGRESSDETECT(p) && p->dsp && p->outgoing) {
                                                ast_debug(1, "Done dialing, but waiting for progress detection before doing more...\n");
                                        } else if (p->confirmanswer || (!p->dialednone
@@ -8177,7 +8177,7 @@ static struct ast_frame *dahdi_handle_event(struct ast_channel *ast)
                                        p->cid_suppress_expire = 0;
                                        p->owner = NULL;
                                        /* Don't start streaming audio yet if the incoming call isn't up yet */
-                                       if (p->subs[SUB_REAL].owner->_state != AST_STATE_UP)
+                                       if (ast_channel_state(p->subs[SUB_REAL].owner) != AST_STATE_UP)
                                                p->dialing = 1;
                                        dahdi_ring_phone(p);
                                } else if (p->subs[SUB_THREEWAY].owner) {
@@ -8211,13 +8211,13 @@ static struct ast_frame *dahdi_handle_event(struct ast_channel *ast)
                                                p->subs[SUB_THREEWAY].owner->_softhangup |= AST_SOFTHANGUP_DEV;
                                                ast_debug(1, "Looks like a bounced flash, hanging up both calls on %d\n", p->channel);
                                                ast_channel_unlock(p->subs[SUB_THREEWAY].owner);
-                                       } else if ((ast->pbx) || (ast->_state == AST_STATE_UP)) {
+                                       } else if ((ast_channel_pbx(ast)) || (ast_channel_state(ast) == AST_STATE_UP)) {
                                                if (p->transfer) {
                                                        /* In any case this isn't a threeway call anymore */
                                                        p->subs[SUB_REAL].inthreeway = 0;
                                                        p->subs[SUB_THREEWAY].inthreeway = 0;
                                                        /* Only attempt transfer if the phone is ringing; why transfer to busy tone eh? */
-                                                       if (!p->transfertobusy && ast->_state == AST_STATE_BUSY) {
+                                                       if (!p->transfertobusy && ast_channel_state(ast) == AST_STATE_BUSY) {
                                                                ast_channel_unlock(p->subs[SUB_THREEWAY].owner);
                                                                /* Swap subs and dis-own channel */
                                                                swap_subs(p, SUB_THREEWAY, SUB_REAL);
@@ -8280,7 +8280,7 @@ static struct ast_frame *dahdi_handle_event(struct ast_channel *ast)
                }
                /* for E911, its supposed to wait for offhook then dial
                   the second half of the dial string */
-               if (((mysig == SIG_E911) || (mysig == SIG_FGC_CAMA) || (mysig == SIG_FGC_CAMAMF)) && (ast->_state == AST_STATE_DIALING_OFFHOOK)) {
+               if (((mysig == SIG_E911) || (mysig == SIG_FGC_CAMA) || (mysig == SIG_FGC_CAMAMF)) && (ast_channel_state(ast) == AST_STATE_DIALING_OFFHOOK)) {
                        c = strchr(p->dialdest, '/');
                        if (c)
                                c++;
@@ -8311,7 +8311,7 @@ static struct ast_frame *dahdi_handle_event(struct ast_channel *ast)
                case SIG_FXOLS:
                case SIG_FXOGS:
                case SIG_FXOKS:
-                       switch (ast->_state) {
+                       switch (ast_channel_state(ast)) {
                        case AST_STATE_RINGING:
                                dahdi_enable_ec(p);
                                dahdi_train_ec(p);
@@ -8353,7 +8353,7 @@ static struct ast_frame *dahdi_handle_event(struct ast_channel *ast)
                                return &p->subs[idx].f;
                        case AST_STATE_DOWN:
                                ast_setstate(ast, AST_STATE_RING);
-                               ast->rings = 1;
+                               ast_channel_rings_set(ast, 1);
                                p->subs[idx].f.frametype = AST_FRAME_CONTROL;
                                p->subs[idx].f.subclass.integer = AST_CONTROL_OFFHOOK;
                                ast_debug(1, "channel %d picked up\n", p->channel);
@@ -8374,13 +8374,13 @@ static struct ast_frame *dahdi_handle_event(struct ast_channel *ast)
                                        res = tone_zone_play_tone(p->subs[SUB_REAL].dfd, DAHDI_TONE_DIALTONE);
                                break;
                        default:
-                               ast_log(LOG_WARNING, "FXO phone off hook in weird state %d??\n", ast->_state);
+                               ast_log(LOG_WARNING, "FXO phone off hook in weird state %d??\n", ast_channel_state(ast));
                        }
                        break;
                case SIG_FXSLS:
                case SIG_FXSGS:
                case SIG_FXSKS:
-                       if (ast->_state == AST_STATE_RING) {
+                       if (ast_channel_state(ast) == AST_STATE_RING) {
                                p->ringt = p->ringt_base;
                        }
 
@@ -8407,13 +8407,13 @@ static struct ast_frame *dahdi_handle_event(struct ast_channel *ast)
                case SIG_SF_FEATD:
                case SIG_SF_FEATDMF:
                case SIG_SF_FEATB:
-                       if (ast->_state == AST_STATE_PRERING)
+                       if (ast_channel_state(ast) == AST_STATE_PRERING)
                                ast_setstate(ast, AST_STATE_RING);
-                       if ((ast->_state == AST_STATE_DOWN) || (ast->_state == AST_STATE_RING)) {
+                       if ((ast_channel_state(ast) == AST_STATE_DOWN) || (ast_channel_state(ast) == AST_STATE_RING)) {
                                ast_debug(1, "Ring detected\n");
                                p->subs[idx].f.frametype = AST_FRAME_CONTROL;
                                p->subs[idx].f.subclass.integer = AST_CONTROL_RING;
-                       } else if (p->outgoing && ((ast->_state == AST_STATE_RINGING) || (ast->_state == AST_STATE_DIALING))) {
+                       } else if (p->outgoing && ((ast_channel_state(ast) == AST_STATE_RINGING) || (ast_channel_state(ast) == AST_STATE_DIALING))) {
                                ast_debug(1, "Line answered\n");
                                if (p->confirmanswer) {
                                        p->subs[idx].f.frametype = AST_FRAME_NULL;
@@ -8423,8 +8423,8 @@ static struct ast_frame *dahdi_handle_event(struct ast_channel *ast)
                                        p->subs[idx].f.subclass.integer = AST_CONTROL_ANSWER;
                                        ast_setstate(ast, AST_STATE_UP);
                                }
-                       } else if (ast->_state != AST_STATE_RING)
-                               ast_log(LOG_WARNING, "Ring/Off-hook in strange state %d on channel %d\n", ast->_state, p->channel);
+                       } else if (ast_channel_state(ast) != AST_STATE_RING)
+                               ast_log(LOG_WARNING, "Ring/Off-hook in strange state %d on channel %d\n", ast_channel_state(ast), p->channel);
                        break;
                default:
                        ast_log(LOG_WARNING, "Don't know how to handle ring/off hook for signalling %d\n", p->sig);
@@ -8435,7 +8435,7 @@ static struct ast_frame *dahdi_handle_event(struct ast_channel *ast)
                case SIG_FXSLS:
                case SIG_FXSGS:
                case SIG_FXSKS:
-                       if (ast->_state == AST_STATE_RING) {
+                       if (ast_channel_state(ast) == AST_STATE_RING) {
                                p->ringt = p->ringt_base;
                        }
                        break;
@@ -8509,7 +8509,7 @@ static struct ast_frame *dahdi_handle_event(struct ast_channel *ast)
                                tone_zone_play_tone(p->subs[SUB_REAL].dfd, -1);
                                p->owner = p->subs[SUB_REAL].owner;
                                ast_debug(1, "Making %s the new owner\n", ast_channel_name(p->owner));
-                               if (p->owner->_state == AST_STATE_RINGING) {
+                               if (ast_channel_state(p->owner) == AST_STATE_RINGING) {
                                        ast_setstate(p->owner, AST_STATE_UP);
                                        p->subs[SUB_REAL].needanswer = 1;
                                }
@@ -8554,9 +8554,9 @@ static struct ast_frame *dahdi_handle_event(struct ast_channel *ast)
                                        }
                                        /* XXX This section needs much more error checking!!! XXX */
                                        /* Start a 3-way call if feasible */
-                                       if (!((ast->pbx) ||
-                                               (ast->_state == AST_STATE_UP) ||
-                                               (ast->_state == AST_STATE_RING))) {
+                                       if (!((ast_channel_pbx(ast)) ||
+                                               (ast_channel_state(ast) == AST_STATE_UP) ||
+                                               (ast_channel_state(ast) == AST_STATE_RING))) {
                                                ast_debug(1, "Flash when call not up or ringing\n");
                                                goto winkflashdone;