]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
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 3f849d1c68a423b2028d753b932ff3e445be9715..e0f95e175c27ff2254cf0312357a6fc21bf885e0 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 74b7a2f63d1d0c02a1b07efd8e4677bf00530a05..b91fac35da4dcf6175d662df06240edfe8a640a5 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 44782f0c754f67e1ab53564cc8c6eb6335ca2ac9..c4309e065db3f5cf3bcfca8cf77ba0479cffa40e 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 45e6d9602332beb5cbc2502c2590cd29b1144f08..fbb430089524a38723f1bf789aabdc1a8462131a 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 2f227b0490bff2a5e4d8bd89ad4ee134646768bd..3c244712bb8a217b3fbd03c552fc06b598768abe 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 37ba214cad2dd781462655a4d88f8c05fbdc7f99..fd88b91e1fd8e37c1963ac2cb5e9eafec97ea9a8 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 8fe543dab1fc62d2fac61027a07463dbcc1bd459..bea7a91f1c9c066e675161bcb8a7813b68c04249 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 b56672dd21a73757738ca1ba6720331c081363b4..621f98b2c825023cddac41d10e90f9a8a0fde473 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 8c03509c93c74b9d4d76831d824dd0dc92543a87..4e9d5a5e05f67cb5558cf34ec73876b1774b59d0 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 5384c681438c3e203b6da72093631f8084e5409d..4fde4668748c442fd32b5124a0ed823f10e38490 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 dcf0cafb337ce70afc4da8126ddf4da4b1f6b176..e6b080f815fb9afed691ca03f03fd3916368a254 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 7543bd22b27089b97ee5d2070a8736760aa38c2b..03eae32ea1d132d4e8d0db834b8d5655fe002ea4 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 6b200177427aa42ea2cb7c1e90670a0035f76c2b..2158b8c861b5f61329e13dea784d8043d0689381 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 4db404cff4cf27e797ba3aedcce215136d661bee..52e8722c2fc475bae82e7d3c0b212b982617480c 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 7d92b76428ed403d3ec237a1b88f4e2710ac247e..5de3acfa51b5d331d4522ccacfac12e2409ae440 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 8e9c749aea289b34e452d68148601258560578e9..27e79e1980a63c50dfb66c0f4e18b2e78f746e85 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 2f34b9fe4cf3c8cad43896bbb139cb3acd3fede5..a8a7fd84d7bf9b0a534ed0afda2886963d1e0f3e 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 9377d2320e7f22dd675b2bea4d41b5caf7ff5c1d..5873a64084934e9e52392edd540bef41b026e87a 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 3183a5638da422336622df215dae248f12132aac..2c2960e782784ccbe31b0e22f189587a5e30affd 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 d609b3fe45761d116474cfb1a1f9edb76e04495b..cd1cfa05182a0a0972cec1787dbd7f295ad2991e 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 283953b390027031219e35b2fd5d9a213e212972..1ee834bbfb5083ec40ccfc16da3a28b0eb62f9f9 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 878e2eef1ab0078b380ca1420df1a63c4f62f9d1..1bf9547a92f9e6dd10f0c2beccad3cb295ca101d 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 ffeeca8ece52e86f66fa5d90a9416a19c7fe7a86..c75553c347a45535b0002c17760cc66ad2ee3ada 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 52c03ae09ead43bd090babeb5fcffe9a4b15e2f1..13b27fe2580a7a7a769f6192275322b796d2bac2 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 d035df91f9318c754eba4de8e9b1a752607335d0..099c67d4844c547cb68d0bee067c04a73278de2c 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 e2b9c92a7c9183d00fcad16d997cb10c9f1e52f4..c324a36c3d762e5cbcc5788829e30cee126d8ae2 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 3c8b73f206b889ea00cc6e30acc03e9f4ea648e0..b6e0c13cb4d0707d753a2a3d783ebe5c6db9467f 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 412ac1ef4ed2cd15cf9fd9ff7ff7b0dfd7eb3bd9..42141412617de8540561103338af715304fc1ef4 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 9c87a7464570092adf15367fa4d0af4a431f1d7b..bf408f81fee5535ec263e4728b150574c4195849 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 a74d1b50172289a198a07b6e5c8964382477ee19..23f8838bc2900fb847fffd09a10766b6e88a23da 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 4b779bd32eb2d4ac71316be481341b90e510d82e..508c31a5b9d914f302ea3135418e9c9978fd0329 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 e9d4d87520394d4a7025d97f2269881a677e38e0..18d4c8eb55d0e0f94fa54fb45a7ea7b302cc800b 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 1e142de2322c8ee8cd3beb01e483b27b894ebc9d..fd947dd661bd2570b317070c62427151a5e0ad85 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 6c2c95814efdd5dad14775029470985917d3813d..d287c56fd6c87ce2df5094f041b9f83efb8d330a 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 2a8b5132243d963759d5d65ba3bb1b1ca3d5a87d..0add6c2097b5e97e52049a2aead03cc7abb663dc 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 813d3756541e08531d866ddeae0baf0371f46add..d2a1de7b64badd3d02d6df9b6562b80adc454dad 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 5e6f3ed4486637c92d2dd4858fb317a7a9970362..a894ba48c3a63df520f526292f2a6c21e1d6c7de 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 420ed0e62ba8fa7916e2de35dce34fb5aa6b0e8d..b7c6bfab7cc4e5138907ba0a4bcc9b9db5c3a3ea 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 5556a8d7d04d570fa94aabc56af6898edacd1f23..48d31d2a4da23d83353cecc6ed397863ee46e31b 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 32119aca0287dd393e3e4f8517d28fe8d26871b1..7d34ed9cda370bec342fdefe72ca16d771853df6 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 a723de5b9eda9dd3dcf96c1c3e1d23e74c5b25e7..98b7b2fad4fb60f7c86a1a8a3b46a177728041ee 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 68770da3061a9d38186fb7f111fc4678d6457cc1..946677a61518c70b75ea98a970df83d0d6160afd 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 2a4befa9ed14abf85f90715e6dfb1f684695d302..f3fc4c18fc0a27a5e6160b321bfc3f322eb5629b 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 078fcf2e9a24d67dae45ffc3be895c176f2f26ee..8e6113be89bce33d43af52606116001cf455f5cd 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 f45c0781770a43c0a3ec03fe4b14b759b53f4c06..06febbaeb7a3b249ed026d2c06079d614faae0ac 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 5c0ee339bed76f3d3bb3302e90edede8a545c605..0250f2262ffbabc94685c907d32d9eecc10ba19a 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 9e118669e46be93187b8b1c42ba7b763771df5bb..bf66824ec08962400b6b7f3ca571b59ff0135a8b 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 f072eb27f534b6523a531400f54da4eea65977be..15c3245dd771b70cf8bbfbcb1932991d5d49dd02 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 14ff2fb05404fcd681e067f4e8772044cf09c821..b981fb9c86bcadd0c9a03c85fcfdffa7e342023f 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 484f4499f8f2135468aab0a4b3d3f1589e21537e..3a90b9944b5b8d924e7987921f099be29cf4ac35 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 3d3aa75dfc7b17f46e2dd03a387fd90bdb725557..1964376aa2fb0c8417ce69561e0c366748bf2635 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 25d7c433bf38b227b0895c5c1b30f915b1af139a..5e8fb9bb4052c9e3b561d2ec91ec9f0ff32fb20a 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 b102ea4260046583658ed752e427c3521043a9d4..775fd55a3fe9fd029cd901da3a414f733c7e95c7 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 98a11caa3e3e206e9f2ed946f8500fc0ba4b32d0..5ef9b84c1fa960824c544f71a5a8d6feb60af1be 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 9ca6aa45b851c0fb56c0c1de1c47a072468cfc6f..89bf5842fc6fa3a2dc194e32e24f6cc75b50aabf 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 14864df4d7f154a303afed779818a044e0857900..19bcd295ab8dd24c77ae34dde6b988a7779d67bf 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 ee423d3e63097760c5f1c1dc4b438a4e3c3d2645..b56b7bed15c9d5d144c508b492f5fb821a584764 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 1d9eb6a6ab2d85abe3aa4675de4b990bf3e50cd9..0d9f46dc41092a8a7f09237ed1564b94676dc2ec 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 65ef5b8a2a8195a80e01a4729ac669f07a7291e7..4351c1e697b8afedfc03bc99074e06159719b2e9 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 adf260594b813b02887ce8a17c69b0c26afd195c..e59381280ca7b81ad4aa31012ae6aef5b2fd20c3 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 a0fd09a98044eba5d231d4526d592cb92fc41a60..b2744af0008a6a70e7b9c1597632a33644912688 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 38ef917b7b0fd77856bcc86d49d3127e9b1f927e..4424ef18db20898a9c832d2107b35ef78aedeb41 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 c57f117a9c65070b72e8a0cc82047917666aa883..67af0737e630ad9d4b4e0d2950d1867b69d9212b 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 9d2b17d44bdec4b6d13eed04a0603120ed1ea5a5..a47f898260309c4ac7b4f59e467834ed744fb351 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 73bfcfe8c8eaac033d94f62054d1a2eaeae15076..59e1ff09dc64109f7e9c9ac17ddc6fcda2efe696 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;
                                        }
@@ -8607,7 +8607,7 @@ static struct ast_frame *dahdi_handle_event(struct ast_channel *ast)
                                        /* Call is already up, drop the last person */
                                        ast_debug(1, "Got flash with three way call up, dropping last call on %d\n", p->channel);
                                        /* If the primary call isn't answered yet, use it */
-                                       if ((p->subs[SUB_REAL].owner->_state != AST_STATE_UP) && (p->subs[SUB_THREEWAY].owner->_state == AST_STATE_UP)) {
+                                       if ((ast_channel_state(p->subs[SUB_REAL].owner) != AST_STATE_UP) && (ast_channel_state(p->subs[SUB_THREEWAY].owner) == AST_STATE_UP)) {
                                                /* Swap back -- we're dropping the real 3-way that isn't finished yet*/
                                                swap_subs(p, SUB_THREEWAY, SUB_REAL);
                                                p->owner = p->subs[SUB_REAL].owner;
@@ -8619,8 +8619,8 @@ static struct ast_frame *dahdi_handle_event(struct ast_channel *ast)
                                        p->subs[SUB_THREEWAY].inthreeway = 0;
                                } else {
                                        /* Lets see what we're up to */
-                                       if (((ast->pbx) || (ast->_state == AST_STATE_UP)) &&
-                                               (p->transfertobusy || (ast->_state != AST_STATE_BUSY))) {
+                                       if (((ast_channel_pbx(ast)) || (ast_channel_state(ast) == AST_STATE_UP)) &&
+                                               (p->transfertobusy || (ast_channel_state(ast) != AST_STATE_BUSY))) {
                                                int otherindex = SUB_THREEWAY;
 
                                                ast_verb(3, "Building conference call with %s and %s\n",
@@ -8629,7 +8629,7 @@ static struct ast_frame *dahdi_handle_event(struct ast_channel *ast)
                                                /* Put them in the threeway, and flip */
                                                p->subs[SUB_THREEWAY].inthreeway = 1;
                                                p->subs[SUB_REAL].inthreeway = 1;
-                                               if (ast->_state == AST_STATE_UP) {
+                                               if (ast_channel_state(ast) == AST_STATE_UP) {
                                                        swap_subs(p, SUB_THREEWAY, SUB_REAL);
                                                        otherindex = SUB_REAL;
                                                }
@@ -8663,7 +8663,7 @@ winkflashdone:
                        if (p->dialing)
                                ast_debug(1, "Ignoring wink on channel %d\n", p->channel);
                        else
-                               ast_debug(1, "Got wink in weird state %d on channel %d\n", ast->_state, p->channel);
+                               ast_debug(1, "Got wink in weird state %d on channel %d\n", ast_channel_state(ast), p->channel);
                        break;
                case SIG_FEATDMF_TA:
                        switch (p->whichwink) {
@@ -8760,38 +8760,38 @@ winkflashdone:
                if (p->polarity == POLARITY_IDLE) {
                        p->polarity = POLARITY_REV;
                        if (p->answeronpolarityswitch &&
-                               ((ast->_state == AST_STATE_DIALING) ||
-                               (ast->_state == AST_STATE_RINGING))) {
+                               ((ast_channel_state(ast) == AST_STATE_DIALING) ||
+                               (ast_channel_state(ast) == AST_STATE_RINGING))) {
                                ast_debug(1, "Answering on polarity switch!\n");
                                ast_setstate(p->owner, AST_STATE_UP);
                                if (p->hanguponpolarityswitch) {
                                        p->polaritydelaytv = ast_tvnow();
                                }
                        } else
-                               ast_debug(1, "Ignore switch to REVERSED Polarity on channel %d, state %d\n", p->channel, ast->_state);
+                               ast_debug(1, "Ignore switch to REVERSED Polarity on channel %d, state %d\n", p->channel, ast_channel_state(ast));
                }
                /* Removed else statement from here as it was preventing hangups from ever happening*/
                /* Added AST_STATE_RING in if statement below to deal with calling party hangups that take place when ringing */
                if (p->hanguponpolarityswitch &&
                        (p->polarityonanswerdelay > 0) &&
                        (p->polarity == POLARITY_REV) &&
-                       ((ast->_state == AST_STATE_UP) || (ast->_state == AST_STATE_RING)) ) {
+                       ((ast_channel_state(ast) == AST_STATE_UP) || (ast_channel_state(ast) == AST_STATE_RING)) ) {
                        /* Added log_debug information below to provide a better indication of what is going on */
-                       ast_debug(1, "Polarity Reversal event occured - DEBUG 1: channel %d, state %d, pol= %d, aonp= %d, honp= %d, pdelay= %d, tv= %" PRIi64 "\n", p->channel, ast->_state, p->polarity, p->answeronpolarityswitch, p->hanguponpolarityswitch, p->polarityonanswerdelay, ast_tvdiff_ms(ast_tvnow(), p->polaritydelaytv) );
+                       ast_debug(1, "Polarity Reversal event occured - DEBUG 1: channel %d, state %d, pol= %d, aonp= %d, honp= %d, pdelay= %d, tv= %" PRIi64 "\n", p->channel, ast_channel_state(ast), p->polarity, p->answeronpolarityswitch, p->hanguponpolarityswitch, p->polarityonanswerdelay, ast_tvdiff_ms(ast_tvnow(), p->polaritydelaytv) );
 
                        if (ast_tvdiff_ms(ast_tvnow(), p->polaritydelaytv) > p->polarityonanswerdelay) {
                                ast_debug(1, "Polarity Reversal detected and now Hanging up on channel %d\n", p->channel);
                                ast_softhangup(p->owner, AST_SOFTHANGUP_EXPLICIT);
                                p->polarity = POLARITY_IDLE;
                        } else
-                               ast_debug(1, "Polarity Reversal detected but NOT hanging up (too close to answer event) on channel %d, state %d\n", p->channel, ast->_state);
+                               ast_debug(1, "Polarity Reversal detected but NOT hanging up (too close to answer event) on channel %d, state %d\n", p->channel, ast_channel_state(ast));
 
                } else {
                        p->polarity = POLARITY_IDLE;
-                       ast_debug(1, "Ignoring Polarity switch to IDLE on channel %d, state %d\n", p->channel, ast->_state);
+                       ast_debug(1, "Ignoring Polarity switch to IDLE on channel %d, state %d\n", p->channel, ast_channel_state(ast));
                }
                /* Added more log_debug information below to provide a better indication of what is going on */
-               ast_debug(1, "Polarity Reversal event occured - DEBUG 2: channel %d, state %d, pol= %d, aonp= %d, honp= %d, pdelay= %d, tv= %" PRIi64 "\n", p->channel, ast->_state, p->polarity, p->answeronpolarityswitch, p->hanguponpolarityswitch, p->polarityonanswerdelay, ast_tvdiff_ms(ast_tvnow(), p->polaritydelaytv) );
+               ast_debug(1, "Polarity Reversal event occured - DEBUG 2: channel %d, state %d, pol= %d, aonp= %d, honp= %d, pdelay= %d, tv= %" PRIi64 "\n", p->channel, ast_channel_state(ast), p->polarity, p->answeronpolarityswitch, p->hanguponpolarityswitch, p->polarityonanswerdelay, ast_tvdiff_ms(ast_tvnow(), p->polaritydelaytv) );
                break;
        default:
                ast_debug(1, "Dunno what to do with event %d on channel %d\n", res, p->channel);
@@ -8805,7 +8805,7 @@ static struct ast_frame *__dahdi_exception(struct ast_channel *ast)
        int idx;
        struct ast_frame *f;
        int usedindex = -1;
-       struct dahdi_pvt *p = ast->tech_pvt;
+       struct dahdi_pvt *p = ast_channel_tech_pvt(ast);
 
        idx = dahdi_get_index(ast, p, 1);
 
@@ -8856,7 +8856,7 @@ static struct ast_frame *__dahdi_exception(struct ast_channel *ast)
                case DAHDI_EVENT_RINGOFFHOOK:
                        dahdi_enable_ec(p);
                        dahdi_set_hook(p->subs[SUB_REAL].dfd, DAHDI_OFFHOOK);
-                       if (p->owner && (p->owner->_state == AST_STATE_RINGING)) {
+                       if (p->owner && (ast_channel_state(p->owner) == AST_STATE_RINGING)) {
                                p->subs[SUB_REAL].needanswer = 1;
                                p->dialing = 0;
                        }
@@ -8870,7 +8870,7 @@ static struct ast_frame *__dahdi_exception(struct ast_channel *ast)
                        p->flashtime = ast_tvnow();
                        if (p->owner) {
                                ast_verb(3, "Channel %d flashed to other channel %s\n", p->channel, ast_channel_name(p->owner));
-                               if (p->owner->_state != AST_STATE_UP) {
+                               if (ast_channel_state(p->owner) != AST_STATE_UP) {
                                        /* Answer if necessary */
                                        usedindex = dahdi_get_index(p->owner, p, 0);
                                        if (usedindex > -1) {
@@ -8914,7 +8914,7 @@ static struct ast_frame *__dahdi_exception(struct ast_channel *ast)
 
 static struct ast_frame *dahdi_exception(struct ast_channel *ast)
 {
-       struct dahdi_pvt *p = ast->tech_pvt;
+       struct dahdi_pvt *p = ast_channel_tech_pvt(ast);
        struct ast_frame *f;
        ast_mutex_lock(&p->lock);
        if (analog_lib_handles(p->sig, p->radio, p->oprmode)) {
@@ -8940,7 +8940,7 @@ static struct ast_frame *dahdi_read(struct ast_channel *ast)
         * analog ports can have more than one Asterisk channel using
         * the same private structure.
         */
-       p = ast->tech_pvt;
+       p = ast_channel_tech_pvt(ast);
        while (ast_mutex_trylock(&p->lock)) {
                CHANNEL_DEADLOCK_AVOIDANCE(ast);
 
@@ -8949,7 +8949,7 @@ static struct ast_frame *dahdi_read(struct ast_channel *ast)
                 * the call could move to another B channel while the Asterisk
                 * channel is unlocked.
                 */
-               p = ast->tech_pvt;
+               p = ast_channel_tech_pvt(ast);
        }
 
        idx = dahdi_get_index(ast, p, 0);
@@ -9015,7 +9015,7 @@ static struct ast_frame *dahdi_read(struct ast_channel *ast)
                         * now enqueue a progress frame to bridge the media up */
                        if (p->mfcr2_call_accepted &&
                                !p->mfcr2_progress_sent && 
-                               ast->_state == AST_STATE_RINGING) {
+                               ast_channel_state(ast) == AST_STATE_RINGING) {
                                ast_debug(1, "Enqueuing progress frame after R2 accept in chan %d\n", p->channel);
                                ast_queue_frame(p->owner, &fr);
                                p->mfcr2_progress_sent = 1;
@@ -9233,7 +9233,7 @@ static struct ast_frame *dahdi_read(struct ast_channel *ast)
        ast_debug(1, "Read %d of voice on %s\n", p->subs[idx].f.datalen, ast->name);
 #endif
        if (p->dialing ||  p->radio || /* Transmitting something */
-               (idx && (ast->_state != AST_STATE_UP)) || /* Three-way or callwait that isn't up */
+               (idx && (ast_channel_state(ast) != AST_STATE_UP)) || /* Three-way or callwait that isn't up */
                ((idx == SUB_CALLWAIT) && !p->subs[SUB_CALLWAIT].inthreeway) /* Inactive and non-confed call-wait */
                ) {
                /* Whoops, we're still dialing, or in a state where we shouldn't transmit....
@@ -9261,7 +9261,7 @@ static struct ast_frame *dahdi_read(struct ast_channel *ast)
 
                if (f) {
                        if ((f->frametype == AST_FRAME_CONTROL) && (f->subclass.integer == AST_CONTROL_BUSY)) {
-                               if ((ast->_state == AST_STATE_UP) && !p->outgoing) {
+                               if ((ast_channel_state(ast) == AST_STATE_UP) && !p->outgoing) {
                                        /* Treat this as a "hangup" instead of a "busy" on the assumption that
                                           a busy */
                                        f = NULL;
@@ -9375,7 +9375,7 @@ static int my_dahdi_write(struct dahdi_pvt *p, unsigned char *buf, int len, int
 
 static int dahdi_write(struct ast_channel *ast, struct ast_frame *frame)
 {
-       struct dahdi_pvt *p = ast->tech_pvt;
+       struct dahdi_pvt *p = ast_channel_tech_pvt(ast);
        int res;
        int idx;
        idx = dahdi_get_index(ast, p, 0);
@@ -9440,7 +9440,7 @@ static int dahdi_write(struct ast_channel *ast, struct ast_frame *frame)
 
 static int dahdi_indicate(struct ast_channel *chan, int condition, const void *data, size_t datalen)
 {
-       struct dahdi_pvt *p = chan->tech_pvt;
+       struct dahdi_pvt *p = ast_channel_tech_pvt(chan);
        int res=-1;
        int idx;
        int func = DAHDI_FLASH;
@@ -9480,8 +9480,8 @@ static int dahdi_indicate(struct ast_channel *chan, int condition, const void *d
                case AST_CONTROL_RINGING:
                        res = tone_zone_play_tone(p->subs[idx].dfd, DAHDI_TONE_RINGTONE);
 
-                       if (chan->_state != AST_STATE_UP) {
-                               if ((chan->_state != AST_STATE_RING) ||
+                       if (ast_channel_state(chan) != AST_STATE_UP) {
+                               if ((ast_channel_state(chan) != AST_STATE_RING) ||
                                        ((p->sig != SIG_FXSKS) &&
                                 (p->sig != SIG_FXSLS) &&
                                 (p->sig != SIG_FXSGS)))
@@ -9505,12 +9505,12 @@ static int dahdi_indicate(struct ast_channel *chan, int condition, const void *d
                        break;
                case AST_CONTROL_CONGESTION:
                        /* There are many cause codes that generate an AST_CONTROL_CONGESTION. */
-                       switch (chan->hangupcause) {
+                       switch (ast_channel_hangupcause(chan)) {
                        case AST_CAUSE_USER_BUSY:
                        case AST_CAUSE_NORMAL_CLEARING:
                        case 0:/* Cause has not been set. */
                                /* Supply a more appropriate cause. */
-                               chan->hangupcause = AST_CAUSE_CONGESTION;
+                               ast_channel_hangupcause_set(chan, AST_CAUSE_CONGESTION);
                                break;
                        default:
                                break;
@@ -9641,7 +9641,7 @@ static struct ast_channel *dahdi_new(struct dahdi_pvt *i, int state, int startpb
        ast_free(chan_name);
        if (!tmp)
                return NULL;
-       tmp->tech = &dahdi_tech;
+       ast_channel_tech_set(tmp, &dahdi_tech);
 #if defined(HAVE_PRI)
        if (i->pri) {
                ast_cc_copy_config_params(i->cc_params, i->pri->cc_params);
@@ -9673,7 +9673,7 @@ static struct ast_channel *dahdi_new(struct dahdi_pvt *i, int state, int startpb
                }
        }
        ast_channel_set_fd(tmp, 0, i->subs[idx].dfd);
-       ast_format_cap_add(tmp->nativeformats, &deflaw);
+       ast_format_cap_add(ast_channel_nativeformats(tmp), &deflaw);
        /* Start out assuming ulaw since it's smaller :) */
        ast_format_copy(&tmp->rawreadformat, &deflaw);
        ast_format_copy(&tmp->readformat, &deflaw);
@@ -9734,8 +9734,8 @@ static struct ast_channel *dahdi_new(struct dahdi_pvt *i, int state, int startpb
        }
 
        if (state == AST_STATE_RING)
-               tmp->rings = 1;
-       tmp->tech_pvt = i;
+               ast_channel_rings_set(tmp, 1);
+       ast_channel_tech_pvt_set(tmp, i);
        if ((i->sig == SIG_FXOKS) || (i->sig == SIG_FXOGS) || (i->sig == SIG_FXOLS)) {
                /* Only FXO signalled stuff can be picked up */
                tmp->callgroup = i->callgroup;
@@ -9750,7 +9750,7 @@ static struct ast_channel *dahdi_new(struct dahdi_pvt *i, int state, int startpb
        if (!ast_strlen_zero(i->accountcode))
                ast_channel_accountcode_set(tmp, i->accountcode);
        if (i->amaflags)
-               tmp->amaflags = i->amaflags;
+               ast_channel_amaflags_set(tmp, i->amaflags);
        i->subs[idx].owner = tmp;
        ast_channel_context_set(tmp, i->context);
        if (!analog_lib_handles(i->sig, i->radio, i->oprmode)) {
@@ -9758,7 +9758,7 @@ static struct ast_channel *dahdi_new(struct dahdi_pvt *i, int state, int startpb
        }
        /* If we've been told "no ADSI" then enforce it */
        if (!i->adsi)
-               tmp->adsicpe = AST_ADSI_UNAVAILABLE;
+               ast_channel_adsicpe_set(tmp, AST_ADSI_UNAVAILABLE);
        if (!ast_strlen_zero(i->exten))
                ast_channel_exten_set(tmp, i->exten);
        if (!ast_strlen_zero(i->rdnis)) {
@@ -9927,7 +9927,7 @@ static int canmatch_featurecode(const char *exten)
 static void *analog_ss_thread(void *data)
 {
        struct ast_channel *chan = data;
-       struct dahdi_pvt *p = chan->tech_pvt;
+       struct dahdi_pvt *p = ast_channel_tech_pvt(chan);
        char exten[AST_MAX_EXTENSION] = "";
        char exten2[AST_MAX_EXTENSION] = "";
        unsigned char buf[256];
@@ -10437,10 +10437,10 @@ static void *analog_ss_thread(void *data)
                                struct dahdi_pvt *pbridge = NULL;
                                /* set up the private struct of the bridged one, if any */
                                if (nbridge && ast_bridged_channel(nbridge))
-                                       pbridge = ast_bridged_channel(nbridge)->tech_pvt;
+                                       pbridge = ast_channel_tech_pvt(ast_bridged_channel(nbridge));
                                if (nbridge && pbridge &&
-                                       (nbridge->tech == &dahdi_tech) &&
-                                       (ast_bridged_channel(nbridge)->tech == &dahdi_tech) &&
+                                       (ast_channel_tech(nbridge) == &dahdi_tech) &&
+                                       (ast_channel_tech(ast_bridged_channel(nbridge)) == &dahdi_tech) &&
                                        ISTRUNK(pbridge)) {
                                        int func = DAHDI_FLASH;
                                        /* Clear out the dial buffer */
@@ -10508,7 +10508,7 @@ static void *analog_ss_thread(void *data)
                /* If we want caller id, we're in a prering state due to a polarity reversal
                 * and we're set to use a polarity reversal to trigger the start of caller id,
                 * grab the caller id and wait for ringing to start... */
-               } else if (p->use_callerid && (chan->_state == AST_STATE_PRERING &&
+               } else if (p->use_callerid && (ast_channel_state(chan) == AST_STATE_PRERING &&
                                                 (p->cid_start == CID_START_POLARITY || p->cid_start == CID_START_POLARITY_IN || p->cid_start == CID_START_DTMF_NOALERT))) {
                        /* If set to use DTMF CID signalling, listen for DTMF */
                        if (p->cid_signalling == CID_SIG_DTMF) {
@@ -10549,8 +10549,8 @@ static void *analog_ss_thread(void *data)
                                                res = 4000;/* This is a typical OFF time between rings. */
                                        }
                                        ast_frfree(f);
-                                       if (chan->_state == AST_STATE_RING ||
-                                               chan->_state == AST_STATE_RINGING)
+                                       if (ast_channel_state(chan) == AST_STATE_RING ||
+                                               ast_channel_state(chan) == AST_STATE_RINGING)
                                                break; /* Got ring */
                                }
                                ast_clear_flag(chan, AST_FLAG_END_DTMF_ONLY);
@@ -10661,8 +10661,8 @@ static void *analog_ss_thread(void *data)
                                                        goto quit;
                                                }
                                                ast_frfree(f);
-                                               if (chan->_state == AST_STATE_RING ||
-                                                       chan->_state == AST_STATE_RINGING)
+                                               if (ast_channel_state(chan) == AST_STATE_RING ||
+                                                       ast_channel_state(chan) == AST_STATE_RINGING)
                                                        break; /* Got ring */
                                        }
 
@@ -11027,7 +11027,7 @@ static void *analog_ss_thread(void *data)
                my_handle_notify_message(chan, p, flags, -1);
 
                ast_setstate(chan, AST_STATE_RING);
-               chan->rings = 1;
+               ast_channel_rings_set(chan, 1);
                p->ringt = p->ringt_base;
                res = ast_pbx_run(chan);
                if (res) {
@@ -16689,9 +16689,9 @@ static int dahdi_pri_cc_agent_init(struct ast_cc_agent *agent, struct ast_channe
        struct sig_pri_chan *pvt_chan;
        int res;
 
-       ast_assert(!strcmp(chan->tech->type, "DAHDI"));
+       ast_assert(!strcmp(ast_channel_tech(chan)->type, "DAHDI"));
 
-       pvt = chan->tech_pvt;
+       pvt = ast_channel_tech_pvt(chan);
        if (dahdi_sig_pri_lib_handles(pvt->sig)) {
                pvt_chan = pvt->sig_pvt;
        } else {
@@ -18904,7 +18904,7 @@ static int dahdi_sendtext(struct ast_channel *c, const char *text)
 #define        ASCII_BYTES_PER_CHAR 80
 
        unsigned char *buf,*mybuf;
-       struct dahdi_pvt *p = c->tech_pvt;
+       struct dahdi_pvt *p = ast_channel_tech_pvt(c);
        struct pollfd fds[1];
        int size,res,fd,len,x;
        int bytes=0;
index 9b41ab10651d7a07cb833f863078eba55e808f2d..3b5354caecf20f11537c5503596eb07e2e61e19d 100644 (file)
@@ -530,7 +530,7 @@ static int gtalk_ringing_ack(void *data, ikspak *pak)
 
 static int gtalk_answer(struct ast_channel *ast)
 {
-       struct gtalk_pvt *p = ast->tech_pvt;
+       struct gtalk_pvt *p = ast_channel_tech_pvt(ast);
        int res = 0;
 
        ast_debug(1, "Answer!\n");
@@ -544,7 +544,7 @@ static int gtalk_answer(struct ast_channel *ast)
 
 static enum ast_rtp_glue_result gtalk_get_rtp_peer(struct ast_channel *chan, struct ast_rtp_instance **instance)
 {
-       struct gtalk_pvt *p = chan->tech_pvt;
+       struct gtalk_pvt *p = ast_channel_tech_pvt(chan);
        enum ast_rtp_glue_result res = AST_RTP_GLUE_RESULT_FORBID;
 
        if (!p)
@@ -563,7 +563,7 @@ static enum ast_rtp_glue_result gtalk_get_rtp_peer(struct ast_channel *chan, str
 
 static void gtalk_get_codec(struct ast_channel *chan, struct ast_format_cap *result)
 {
-       struct gtalk_pvt *p = chan->tech_pvt;
+       struct gtalk_pvt *p = ast_channel_tech_pvt(chan);
        ast_mutex_lock(&p->lock);
        ast_format_cap_copy(result, p->peercap);
        ast_mutex_unlock(&p->lock);
@@ -573,7 +573,7 @@ static int gtalk_set_rtp_peer(struct ast_channel *chan, struct ast_rtp_instance
 {
        struct gtalk_pvt *p;
 
-       p = chan->tech_pvt;
+       p = ast_channel_tech_pvt(chan);
        if (!p)
                return -1;
        ast_mutex_lock(&p->lock);
@@ -1129,7 +1129,7 @@ static struct ast_channel *gtalk_new(struct gtalk *client, struct gtalk_pvt *i,
                ast_log(LOG_WARNING, "Unable to allocate Gtalk channel structure!\n");
                return NULL;
        }
-       tmp->tech = &gtalk_tech;
+       ast_channel_tech_set(tmp, &gtalk_tech);
 
        /* Select our native format based on codec preference until we receive
           something from another device to the contrary. */
@@ -1147,12 +1147,12 @@ static struct ast_channel *gtalk_new(struct gtalk *client, struct gtalk_pvt *i,
        }
 
        ast_codec_choose(&i->prefs, what, 1, &tmpfmt);
-       ast_format_cap_add(tmp->nativeformats, &tmpfmt);
+       ast_format_cap_add(ast_channel_nativeformats(tmp), &tmpfmt);
 
        ast_format_cap_iter_start(i->jointcap);
        while (!(ast_format_cap_iter_next(i->jointcap, &tmpfmt))) {
                if (AST_FORMAT_GET_TYPE(tmpfmt.id) == AST_FORMAT_TYPE_VIDEO) {
-                       ast_format_cap_add(tmp->nativeformats, &tmpfmt);
+                       ast_format_cap_add(ast_channel_nativeformats(tmp), &tmpfmt);
                }
        }
        ast_format_cap_iter_end(i->jointcap);
@@ -1166,15 +1166,15 @@ static struct ast_channel *gtalk_new(struct gtalk *client, struct gtalk_pvt *i,
                ast_channel_set_fd(tmp, 3, ast_rtp_instance_fd(i->vrtp, 1));
        }
        if (state == AST_STATE_RING)
-               tmp->rings = 1;
-       tmp->adsicpe = AST_ADSI_UNAVAILABLE;
+               ast_channel_rings_set(tmp, 1);
+       ast_channel_adsicpe_set(tmp, AST_ADSI_UNAVAILABLE);
 
-       ast_best_codec(tmp->nativeformats, &tmpfmt);
+       ast_best_codec(ast_channel_nativeformats(tmp), &tmpfmt);
        ast_format_copy(&tmp->writeformat, &tmpfmt);
        ast_format_copy(&tmp->rawwriteformat, &tmpfmt);
        ast_format_copy(&tmp->readformat, &tmpfmt);
        ast_format_copy(&tmp->rawreadformat, &tmpfmt);
-       tmp->tech_pvt = i;
+       ast_channel_tech_pvt_set(tmp, i);
 
        tmp->callgroup = client->callgroup;
        tmp->pickupgroup = client->pickupgroup;
@@ -1183,7 +1183,7 @@ static struct ast_channel *gtalk_new(struct gtalk *client, struct gtalk_pvt *i,
        if (!ast_strlen_zero(client->accountcode))
                ast_channel_accountcode_set(tmp, client->accountcode);
        if (client->amaflags)
-               tmp->amaflags = client->amaflags;
+               ast_channel_amaflags_set(tmp, client->amaflags);
        if (!ast_strlen_zero(client->language))
                ast_channel_language_set(tmp, client->language);
        if (!ast_strlen_zero(client->musicclass))
@@ -1198,12 +1198,12 @@ static struct ast_channel *gtalk_new(struct gtalk *client, struct gtalk_pvt *i,
        if (!ast_strlen_zero(i->exten) && strcmp(i->exten, "s")) {
                tmp->dialed.number.str = ast_strdup(i->exten);
        }
-       tmp->priority = 1;
+       ast_channel_priority_set(tmp, 1);
        if (i->rtp)
                ast_jb_configure(tmp, &global_jbconf);
        if (state != AST_STATE_DOWN && ast_pbx_start(tmp)) {
                ast_log(LOG_WARNING, "Unable to start PBX on %s\n", ast_channel_name(tmp));
-               tmp->hangupcause = AST_CAUSE_SWITCH_CONGESTION;
+               ast_channel_hangupcause_set(tmp, AST_CAUSE_SWITCH_CONGESTION);
                ast_hangup(tmp);
                tmp = NULL;
        } else {
@@ -1624,10 +1624,10 @@ static struct ast_frame *gtalk_rtp_read(struct ast_channel *ast, struct gtalk_pv
        if (p->owner) {
                /* We already hold the channel lock */
                if (f->frametype == AST_FRAME_VOICE) {
-                       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, format changed to %s\n", ast_getformatname(&f->subclass.format));
-                               ast_format_cap_remove_bytype(p->owner->nativeformats, AST_FORMAT_TYPE_AUDIO);
-                               ast_format_cap_add(p->owner->nativeformats, &f->subclass.format);
+                               ast_format_cap_remove_bytype(ast_channel_nativeformats(p->owner), AST_FORMAT_TYPE_AUDIO);
+                               ast_format_cap_add(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);
                        }
@@ -1644,7 +1644,7 @@ static struct ast_frame *gtalk_rtp_read(struct ast_channel *ast, struct gtalk_pv
 static struct ast_frame *gtalk_read(struct ast_channel *ast)
 {
        struct ast_frame *fr;
-       struct gtalk_pvt *p = ast->tech_pvt;
+       struct gtalk_pvt *p = ast_channel_tech_pvt(ast);
 
        ast_mutex_lock(&p->lock);
        fr = gtalk_rtp_read(ast, p);
@@ -1655,17 +1655,17 @@ static struct ast_frame *gtalk_read(struct ast_channel *ast)
 /*! \brief Send frame to media channel (rtp) */
 static int gtalk_write(struct ast_channel *ast, struct ast_frame *frame)
 {
-       struct gtalk_pvt *p = ast->tech_pvt;
+       struct gtalk_pvt *p = ast_channel_tech_pvt(ast);
        int res = 0;
        char buf[256];
 
        switch (frame->frametype) {
        case AST_FRAME_VOICE:
-               if (!(ast_format_cap_iscompatible(ast->nativeformats, &frame->subclass.format))) {
+               if (!(ast_format_cap_iscompatible(ast_channel_nativeformats(ast), &frame->subclass.format))) {
                        ast_log(LOG_WARNING,
                                        "Asked to transmit frame type %s, while native formats is %s (read/write = %s/%s)\n",
                                        ast_getformatname(&frame->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));
                        return 0;
@@ -1701,7 +1701,7 @@ static int gtalk_write(struct ast_channel *ast, struct ast_frame *frame)
 
 static int gtalk_fixup(struct ast_channel *oldchan, struct ast_channel *newchan)
 {
-       struct gtalk_pvt *p = newchan->tech_pvt;
+       struct gtalk_pvt *p = ast_channel_tech_pvt(newchan);
        ast_mutex_lock(&p->lock);
 
        if ((p->owner != oldchan)) {
@@ -1737,7 +1737,7 @@ static int gtalk_sendtext(struct ast_channel *chan, const char *text)
 {
        int res = 0;
        struct aji_client *client = NULL;
-       struct gtalk_pvt *p = chan->tech_pvt;
+       struct gtalk_pvt *p = ast_channel_tech_pvt(chan);
 
        if (!p->parent) {
                ast_log(LOG_ERROR, "Parent channel not found\n");
@@ -1754,7 +1754,7 @@ static int gtalk_sendtext(struct ast_channel *chan, const char *text)
 
 static int gtalk_digit_begin(struct ast_channel *chan, char digit)
 {
-       struct gtalk_pvt *p = chan->tech_pvt;
+       struct gtalk_pvt *p = ast_channel_tech_pvt(chan);
        int res = 0;
 
        ast_mutex_lock(&p->lock);
@@ -1770,7 +1770,7 @@ static int gtalk_digit_begin(struct ast_channel *chan, char digit)
 
 static int gtalk_digit_end(struct ast_channel *chan, char digit, unsigned int duration)
 {
-       struct gtalk_pvt *p = chan->tech_pvt;
+       struct gtalk_pvt *p = ast_channel_tech_pvt(chan);
        int res = 0;
 
        ast_mutex_lock(&p->lock);
@@ -1854,9 +1854,9 @@ static int gtalk_sendhtml(struct ast_channel *ast, int subclass, const char *dat
  * dest is the dial string */
 static int gtalk_call(struct ast_channel *ast, const char *dest, int timeout)
 {
-       struct gtalk_pvt *p = ast->tech_pvt;
+       struct gtalk_pvt *p = ast_channel_tech_pvt(ast);
 
-       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, "gtalk_call called on %s, neither down nor reserved\n", ast_channel_name(ast));
                return -1;
        }
@@ -1878,13 +1878,13 @@ static int gtalk_call(struct ast_channel *ast, const char *dest, int timeout)
 /*! \brief Hangup a call through the gtalk proxy channel */
 static int gtalk_hangup(struct ast_channel *ast)
 {
-       struct gtalk_pvt *p = ast->tech_pvt;
+       struct gtalk_pvt *p = ast_channel_tech_pvt(ast);
        struct gtalk *client;
 
        ast_mutex_lock(&p->lock);
        client = p->parent;
        p->owner = NULL;
-       ast->tech_pvt = NULL;
+       ast_channel_tech_pvt_set(ast, NULL);
        if (!p->alreadygone) {
                gtalk_action(client, p, "terminate");
        }
index 388c17caaf58a0b4b009bdc03d10337784ccd71e..7da2e929552329de08156f3406d544241eff0787 100644 (file)
@@ -341,11 +341,11 @@ static int oh323_simulate_dtmf_end(const void *data)
 /*! \brief Channel and private structures should be already locked */
 static void __oh323_update_info(struct ast_channel *c, struct oh323_pvt *pvt)
 {
-       h323_format chan_nativeformats_bits = ast_format_cap_to_old_bitfield(c->nativeformats);
+       h323_format chan_nativeformats_bits = ast_format_cap_to_old_bitfield(ast_channel_nativeformats(c));
        if (chan_nativeformats_bits != pvt->nativeformats) {
                if (h323debug)
                        ast_debug(1, "Preparing %s for new native format\n", ast_channel_name(c));
-               ast_format_cap_from_old_bitfield(c->nativeformats, pvt->nativeformats);
+               ast_format_cap_from_old_bitfield(ast_channel_nativeformats(c), pvt->nativeformats);
                ast_set_read_format(c, &c->readformat);
                ast_set_write_format(c, &c->writeformat);
        }
@@ -353,7 +353,7 @@ static void __oh323_update_info(struct ast_channel *c, struct oh323_pvt *pvt)
                if (h323debug)
                        ast_debug(1, "Process pending hangup for %s\n", ast_channel_name(c));
                c->_softhangup |= AST_SOFTHANGUP_DEV;
-               c->hangupcause = pvt->hangupcause;
+               ast_channel_hangupcause_set(c, pvt->hangupcause);
                ast_queue_hangup_with_cause(c, pvt->hangupcause);
                pvt->needhangup = 0;
                pvt->newstate = pvt->newcontrol = pvt->newdigit = pvt->DTMFsched = -1;
@@ -406,7 +406,7 @@ static void __oh323_update_info(struct ast_channel *c, struct oh323_pvt *pvt)
 /*! \brief Only channel structure should be locked */
 static void oh323_update_info(struct ast_channel *c)
 {
-       struct oh323_pvt *pvt = c->tech_pvt;
+       struct oh323_pvt *pvt = ast_channel_tech_pvt(c);
 
        if (pvt) {
                ast_mutex_lock(&pvt->lock);
@@ -472,7 +472,7 @@ static void __oh323_destroy(struct oh323_pvt *pvt)
                ast_channel_lock(pvt->owner);
                if (h323debug)
                        ast_debug(1, "Detaching from %s\n", ast_channel_name(pvt->owner));
-               pvt->owner->tech_pvt = NULL;
+               ast_channel_tech_pvt_set(pvt->owner, NULL);
                ast_channel_unlock(pvt->owner);
        }
        cur = iflist;
@@ -509,7 +509,7 @@ static void oh323_destroy(struct oh323_pvt *pvt)
 
 static int oh323_digit_begin(struct ast_channel *c, char digit)
 {
-       struct oh323_pvt *pvt = (struct oh323_pvt *) c->tech_pvt;
+       struct oh323_pvt *pvt = (struct oh323_pvt *) ast_channel_tech_pvt(c);
        char *token;
 
        if (!pvt) {
@@ -550,7 +550,7 @@ static int oh323_digit_begin(struct ast_channel *c, char digit)
  */
 static int oh323_digit_end(struct ast_channel *c, char digit, unsigned int duration)
 {
-       struct oh323_pvt *pvt = (struct oh323_pvt *) c->tech_pvt;
+       struct oh323_pvt *pvt = (struct oh323_pvt *) ast_channel_tech_pvt(c);
        char *token;
 
        if (!pvt) {
@@ -590,14 +590,14 @@ static int oh323_digit_end(struct ast_channel *c, char digit, unsigned int durat
 static int oh323_call(struct ast_channel *c, const char *dest, int timeout)
 {
        int res = 0;
-       struct oh323_pvt *pvt = (struct oh323_pvt *)c->tech_pvt;
+       struct oh323_pvt *pvt = (struct oh323_pvt *)ast_channel_tech_pvt(c);
        const char *addr;
        char called_addr[1024];
 
        if (h323debug) {
                ast_debug(1, "Calling to %s on %s\n", dest, ast_channel_name(c));
        }
-       if ((c->_state != AST_STATE_DOWN) && (c->_state != AST_STATE_RESERVED)) {
+       if ((ast_channel_state(c) != AST_STATE_DOWN) && (ast_channel_state(c) != AST_STATE_RESERVED)) {
                ast_log(LOG_WARNING, "Line is already in use (%s)\n", ast_channel_name(c));
                return -1;
        }
@@ -649,12 +649,12 @@ static int oh323_call(struct ast_channel *c, const char *dest, int timeout)
        } else
                pvt->options.redirect_reason = -1;
 
-       pvt->options.transfer_capability = c->transfercapability;
+       pvt->options.transfer_capability = ast_channel_transfercapability(c);
 
        /* indicate that this is an outgoing call */
        pvt->outgoing = 1;
 
-       ast_verb(3, "Requested transfer capability: 0x%.2x - %s\n", c->transfercapability, ast_transfercapability2str(c->transfercapability));
+       ast_verb(3, "Requested transfer capability: 0x%.2x - %s\n", ast_channel_transfercapability(c), ast_transfercapability2str(ast_channel_transfercapability(c)));
        if (h323debug)
                ast_debug(1, "Placing outgoing call to %s, %d/%d\n", called_addr, pvt->options.dtmfcodec[0], pvt->options.dtmfcodec[1]);
        ast_mutex_unlock(&pvt->lock);
@@ -670,7 +670,7 @@ static int oh323_call(struct ast_channel *c, const char *dest, int timeout)
 static int oh323_answer(struct ast_channel *c)
 {
        int res;
-       struct oh323_pvt *pvt = (struct oh323_pvt *) c->tech_pvt;
+       struct oh323_pvt *pvt = (struct oh323_pvt *) ast_channel_tech_pvt(c);
        char *token;
 
        if (h323debug)
@@ -684,7 +684,7 @@ static int oh323_answer(struct ast_channel *c)
                ast_free(token);
 
        oh323_update_info(c);
-       if (c->_state != AST_STATE_UP) {
+       if (ast_channel_state(c) != AST_STATE_UP) {
                ast_setstate(c, AST_STATE_UP);
        }
        return res;
@@ -692,7 +692,7 @@ static int oh323_answer(struct ast_channel *c)
 
 static int oh323_hangup(struct ast_channel *c)
 {
-       struct oh323_pvt *pvt = (struct oh323_pvt *) c->tech_pvt;
+       struct oh323_pvt *pvt = (struct oh323_pvt *) ast_channel_tech_pvt(c);
        int q931cause = AST_CAUSE_NORMAL_CLEARING;
        char *call_token;
 
@@ -700,7 +700,7 @@ static int oh323_hangup(struct ast_channel *c)
        if (h323debug)
                ast_debug(1, "Hanging up and scheduling destroy of call %s\n", ast_channel_name(c));
 
-       if (!c->tech_pvt) {
+       if (!ast_channel_tech_pvt(c)) {
                ast_log(LOG_WARNING, "Asked to hangup channel not connected\n");
                return 0;
        }
@@ -713,10 +713,10 @@ static int oh323_hangup(struct ast_channel *c)
        }
 
        pvt->owner = NULL;
-       c->tech_pvt = NULL;
+       ast_channel_tech_pvt_set(c, NULL);
 
-       if (c->hangupcause) {
-               q931cause = c->hangupcause;
+       if (ast_channel_hangupcause(c)) {
+               q931cause = ast_channel_hangupcause(c);
        } else {
                const char *cause = pbx_builtin_getvar_helper(c, "DIALSTATUS");
                if (cause) {
@@ -775,7 +775,7 @@ static struct ast_frame *oh323_rtp_read(struct oh323_pvt *pvt)
        if (f && pvt->owner) {
                /* We already hold the channel lock */
                if (f->frametype == AST_FRAME_VOICE) {
-                       if (!ast_format_cap_iscompatible(pvt->owner->nativeformats, &f->subclass.format)) {
+                       if (!ast_format_cap_iscompatible(ast_channel_nativeformats(pvt->owner), &f->subclass.format)) {
                                /* Try to avoid deadlock */
                                if (ast_channel_trylock(pvt->owner)) {
                                        ast_log(LOG_NOTICE, "Format changed but channel is locked. Ignoring frame...\n");
@@ -783,7 +783,7 @@ static struct ast_frame *oh323_rtp_read(struct oh323_pvt *pvt)
                                }
                                if (h323debug)
                                        ast_debug(1, "Oooh, format changed to '%s'\n", ast_getformatname(&f->subclass.format));
-                               ast_format_cap_set(pvt->owner->nativeformats, &f->subclass.format);
+                               ast_format_cap_set(ast_channel_nativeformats(pvt->owner), &f->subclass.format);
 
                                pvt->nativeformats = ast_format_to_old_bitfield(&f->subclass.format);
 
@@ -817,10 +817,10 @@ static struct ast_frame *oh323_rtp_read(struct oh323_pvt *pvt)
 static struct ast_frame *oh323_read(struct ast_channel *c)
 {
        struct ast_frame *fr;
-       struct oh323_pvt *pvt = (struct oh323_pvt *)c->tech_pvt;
+       struct oh323_pvt *pvt = (struct oh323_pvt *)ast_channel_tech_pvt(c);
        ast_mutex_lock(&pvt->lock);
        __oh323_update_info(c, pvt);
-       switch(c->fdno) {
+       switch(ast_channel_fdno(c)) {
        case 0:
                fr = oh323_rtp_read(pvt);
                break;
@@ -831,7 +831,7 @@ static struct ast_frame *oh323_read(struct ast_channel *c)
                        fr = &ast_null_frame;
                break;
        default:
-               ast_log(LOG_ERROR, "Unable to handle fd %d on channel %s\n", c->fdno, ast_channel_name(c));
+               ast_log(LOG_ERROR, "Unable to handle fd %d on channel %s\n", ast_channel_fdno(c), ast_channel_name(c));
                fr = &ast_null_frame;
                break;
        }
@@ -841,7 +841,7 @@ static struct ast_frame *oh323_read(struct ast_channel *c)
 
 static int oh323_write(struct ast_channel *c, struct ast_frame *frame)
 {
-       struct oh323_pvt *pvt = (struct oh323_pvt *) c->tech_pvt;
+       struct oh323_pvt *pvt = (struct oh323_pvt *) ast_channel_tech_pvt(c);
        int res = 0;
        if (frame->frametype != AST_FRAME_VOICE) {
                if (frame->frametype == AST_FRAME_IMAGE) {
@@ -851,10 +851,10 @@ static int oh323_write(struct ast_channel *c, struct ast_frame *frame)
                        return 0;
                }
        } else {
-               if (!(ast_format_cap_iscompatible(c->nativeformats, &frame->subclass.format))) {
+               if (!(ast_format_cap_iscompatible(ast_channel_nativeformats(c), &frame->subclass.format))) {
                        char tmp[256];
                        ast_log(LOG_WARNING, "Asked to transmit frame type '%s', while native formats is '%s' (read/write = %s/%s)\n",
-                               ast_getformatname(&frame->subclass.format), ast_getformatname_multiple(tmp, sizeof(tmp), c->nativeformats), ast_getformatname(&c->readformat), ast_getformatname(&c->writeformat));
+                               ast_getformatname(&frame->subclass.format), ast_getformatname_multiple(tmp, sizeof(tmp), ast_channel_nativeformats(c)), ast_getformatname(&c->readformat), ast_getformatname(&c->writeformat));
                        return 0;
                }
        }
@@ -871,7 +871,7 @@ static int oh323_write(struct ast_channel *c, struct ast_frame *frame)
 static int oh323_indicate(struct ast_channel *c, int condition, const void *data, size_t datalen)
 {
 
-       struct oh323_pvt *pvt = (struct oh323_pvt *) c->tech_pvt;
+       struct oh323_pvt *pvt = (struct oh323_pvt *) ast_channel_tech_pvt(c);
        char *token = (char *)NULL;
        int res = -1;
        int got_progress;
@@ -890,13 +890,13 @@ static int oh323_indicate(struct ast_channel *c, int condition, const void *data
 
        switch(condition) {
        case AST_CONTROL_RINGING:
-               if (c->_state == AST_STATE_RING || c->_state == AST_STATE_RINGING) {
+               if (ast_channel_state(c) == AST_STATE_RING || ast_channel_state(c) == AST_STATE_RINGING) {
                        h323_send_alerting(token);
                        res = (got_progress ? 0 : -1);  /* Do not simulate any audio tones if we got PROGRESS message */
                }
                break;
        case AST_CONTROL_PROGRESS:
-               if (c->_state != AST_STATE_UP) {
+               if (ast_channel_state(c) != AST_STATE_UP) {
                        /* Do not send PROGRESS message more than once */
                        if (!got_progress)
                                h323_send_progress(token);
@@ -904,7 +904,7 @@ static int oh323_indicate(struct ast_channel *c, int condition, const void *data
                }
                break;
        case AST_CONTROL_BUSY:
-               if (c->_state != AST_STATE_UP) {
+               if (ast_channel_state(c) != AST_STATE_UP) {
                        h323_answering_call(token, 1);
                        ast_softhangup_nolock(c, AST_SOFTHANGUP_DEV);
                        res = 0;
@@ -915,7 +915,7 @@ static int oh323_indicate(struct ast_channel *c, int condition, const void *data
                 * at this time.  Treat a response of Incomplete as if it were congestion.
                 */
        case AST_CONTROL_CONGESTION:
-               if (c->_state != AST_STATE_UP) {
+               if (ast_channel_state(c) != AST_STATE_UP) {
                        h323_answering_call(token, 1);
                        ast_softhangup_nolock(c, AST_SOFTHANGUP_DEV);
                        res = 0;
@@ -959,7 +959,7 @@ static int oh323_indicate(struct ast_channel *c, int condition, const void *data
 
 static int oh323_fixup(struct ast_channel *oldchan, struct ast_channel *newchan)
 {
-       struct oh323_pvt *pvt = (struct oh323_pvt *) newchan->tech_pvt;
+       struct oh323_pvt *pvt = (struct oh323_pvt *) ast_channel_tech_pvt(newchan);
 
        ast_mutex_lock(&pvt->lock);
        if (pvt->owner != oldchan) {
@@ -1049,17 +1049,17 @@ static struct ast_channel *__oh323_new(struct oh323_pvt *pvt, int state, const c
        ast_module_ref(ast_module_info->self);
        ast_mutex_lock(&pvt->lock);
        if (ch) {
-               ch->tech = &oh323_tech;
+               ast_channel_tech_set(ch, &oh323_tech);
                if (!(fmt = pvt->jointcapability) && !(fmt = pvt->options.capability))
                        fmt = global_options.capability;
 
-               ast_format_cap_from_old_bitfield(ch->nativeformats, fmt);
-               ast_codec_choose(&pvt->options.prefs, ch->nativeformats, 1, &tmpfmt)/* | (pvt->jointcapability & AST_FORMAT_VIDEO_MASK)*/;
+               ast_format_cap_from_old_bitfield(ast_channel_nativeformats(ch), fmt);
+               ast_codec_choose(&pvt->options.prefs, ast_channel_nativeformats(ch), 1, &tmpfmt)/* | (pvt->jointcapability & AST_FORMAT_VIDEO_MASK)*/;
 
-               ast_format_cap_set(ch->nativeformats, &tmpfmt);
+               ast_format_cap_set(ast_channel_nativeformats(ch), &tmpfmt);
 
-               pvt->nativeformats = ast_format_cap_to_old_bitfield(ch->nativeformats);
-               ast_best_codec(ch->nativeformats, &tmpfmt);
+               pvt->nativeformats = ast_format_cap_to_old_bitfield(ast_channel_nativeformats(ch));
+               ast_best_codec(ast_channel_nativeformats(ch), &tmpfmt);
                ast_format_copy(&ch->writeformat, &tmpfmt);
                ast_format_copy(&ch->rawwriteformat, &tmpfmt);
                ast_format_copy(&ch->readformat, &tmpfmt);
@@ -1082,7 +1082,7 @@ static struct ast_channel *__oh323_new(struct oh323_pvt *pvt, int state, const c
                }
 #endif
                if (state == AST_STATE_RING) {
-                       ch->rings = 1;
+                       ast_channel_rings_set(ch, 1);
                }
                /* Allocate dsp for in-band DTMF support */
                if (pvt->options.dtmfmode & H323_DTMF_INBAND) {
@@ -1090,18 +1090,18 @@ static struct ast_channel *__oh323_new(struct oh323_pvt *pvt, int state, const c
                        ast_dsp_set_features(pvt->vad, DSP_FEATURE_DIGIT_DETECT);
                }
                /* Register channel functions. */
-               ch->tech_pvt = pvt;
+               ast_channel_tech_pvt_set(ch, pvt);
                /* Set the owner of this channel */
                pvt->owner = ch;
 
                ast_channel_context_set(ch, pvt->context);
                ast_channel_exten_set(ch, pvt->exten);
-               ch->priority = 1;
+               ast_channel_priority_set(ch, 1);
                if (!ast_strlen_zero(pvt->accountcode)) {
                        ast_channel_accountcode_set(ch, pvt->accountcode);
                }
                if (pvt->amaflags) {
-                       ch->amaflags = pvt->amaflags;
+                       ast_channel_amaflags_set(ch, pvt->amaflags);
                }
 
                /* Don't use ast_set_callerid() here because it will
@@ -1124,7 +1124,7 @@ static struct ast_channel *__oh323_new(struct oh323_pvt *pvt, int state, const c
                        ch->dialed.number.str = ast_strdup(pvt->exten);
                }
                if (pvt->cd.transfer_capability >= 0)
-                       ch->transfercapability = pvt->cd.transfer_capability;
+                       ast_channel_transfercapability_set(ch, pvt->cd.transfer_capability);
                if (state != AST_STATE_DOWN) {
                        if (ast_pbx_start(ch)) {
                                ast_log(LOG_WARNING, "Unable to start PBX on %s\n", ast_channel_name(ch));
@@ -2074,12 +2074,12 @@ static void setup_rtp_connection(unsigned call_reference, const char *remoteIp,
                        ast_format_cap_from_old_bitfield(pvt_native, pvt->nativeformats);
 
                        /* Re-build translation path only if native format(s) has been changed */
-                       if (!(ast_format_cap_identical(pvt->owner->nativeformats, pvt_native))) {
+                       if (!(ast_format_cap_identical(ast_channel_nativeformats(pvt->owner), pvt_native))) {
                                if (h323debug) {
                                        char tmp[256], tmp2[256];
-                                       ast_debug(1, "Native format changed to '%s' from '%s', read format is %s, write format is %s\n", ast_getformatname_multiple(tmp, sizeof(tmp), pvt_native), ast_getformatname_multiple(tmp2, sizeof(tmp2), pvt->owner->nativeformats), ast_getformatname(&pvt->owner->readformat), ast_getformatname(&pvt->owner->writeformat));
+                                       ast_debug(1, "Native format changed to '%s' from '%s', read format is %s, write format is %s\n", ast_getformatname_multiple(tmp, sizeof(tmp), pvt_native), ast_getformatname_multiple(tmp2, sizeof(tmp2), ast_channel_nativeformats(pvt->owner)), ast_getformatname(&pvt->owner->readformat), ast_getformatname(&pvt->owner->writeformat));
                                }
-                               ast_format_cap_copy(pvt->owner->nativeformats, pvt_native);
+                               ast_format_cap_copy(ast_channel_nativeformats(pvt->owner), pvt_native);
                                ast_set_read_format(pvt->owner, &pvt->owner->readformat);
                                ast_set_write_format(pvt->owner, &pvt->owner->writeformat);
                        }
@@ -2481,7 +2481,7 @@ static void hangup_connection(unsigned int call_reference, const char *token, in
        }
        if (pvt->owner && !ast_channel_trylock(pvt->owner)) {
                pvt->owner->_softhangup |= AST_SOFTHANGUP_DEV;
-               pvt->owner->hangupcause = pvt->hangupcause = cause;
+               ast_channel_hangupcause_set(pvt->owner, pvt->hangupcause = cause);
                ast_queue_hangup_with_cause(pvt->owner, cause);
                ast_channel_unlock(pvt->owner);
        }
@@ -3218,7 +3218,7 @@ static enum ast_rtp_glue_result oh323_get_rtp_peer(struct ast_channel *chan, str
        struct oh323_pvt *pvt;
        enum ast_rtp_glue_result res = AST_RTP_GLUE_RESULT_LOCAL;
 
-       if (!(pvt = (struct oh323_pvt *)chan->tech_pvt))
+       if (!(pvt = (struct oh323_pvt *)ast_channel_tech_pvt(chan)))
                return AST_RTP_GLUE_RESULT_FORBID;
 
        ast_mutex_lock(&pvt->lock);
@@ -3280,7 +3280,7 @@ static int oh323_set_rtp_peer(struct ast_channel *chan, struct ast_rtp_instance
        mode = convertcap(&chan->writeformat);
 #endif
 
-       pvt = (struct oh323_pvt *) chan->tech_pvt;
+       pvt = (struct oh323_pvt *) ast_channel_tech_pvt(chan);
        if (!pvt) {
                ast_log(LOG_ERROR, "No Private Structure, this is bad\n");
                return -1;
index 9bed3b8b358ac008e0dd5e84ae601c21879015ff..6a50b8ba21c78524e7c65188d22784efdecb1040 100644 (file)
@@ -3370,7 +3370,7 @@ static int iax2_predestroy(int callno)
        }
 
        if ((c = pvt->owner)) {
-               c->tech_pvt = NULL;
+               ast_channel_tech_pvt_set(c, NULL);
                iax2_queue_hangup(callno);
                pvt->owner = NULL;
                ast_module_unref(ast_module_info->self);
@@ -3498,7 +3498,7 @@ static void __attempt_transmit(const void *data)
                                                        iax2_queue_frame(callno, &fr); /* XXX */
                                                        /* Remember, owner could disappear */
                                                        if (iaxs[callno] && iaxs[callno]->owner)
-                                                               iaxs[callno]->owner->hangupcause = AST_CAUSE_DESTINATION_OUT_OF_ORDER;
+                                                               ast_channel_hangupcause_set(iaxs[callno]->owner, AST_CAUSE_DESTINATION_OUT_OF_ORDER);
                                                } else {
                                                        if (iaxs[callno]->reg) {
                                                                memset(&iaxs[callno]->reg->us, 0, sizeof(iaxs[callno]->reg->us));
@@ -4188,7 +4188,7 @@ static int schedule_delivery(struct iax_frame *fr, int updatehistory, int fromtr
 
        /* if the user hasn't requested we force the use of the jitterbuffer, and we're bridged to
         * a channel that can accept jitter, then flush and suspend the jb, and send this frame straight through */
-       if ( (!ast_test_flag64(iaxs[fr->callno], IAX_FORCEJITTERBUF)) && owner && bridge && (bridge->tech->properties & AST_CHAN_TP_WANTSJITTER) ) {
+       if ( (!ast_test_flag64(iaxs[fr->callno], IAX_FORCEJITTERBUF)) && owner && bridge && (ast_channel_tech(bridge)->properties & AST_CHAN_TP_WANTSJITTER) ) {
                jb_frame frame;
 
                ast_channel_unlock(owner);
@@ -4270,34 +4270,34 @@ static int iax2_transmit(struct iax_frame *fr)
 
 static int iax2_digit_begin(struct ast_channel *c, char digit)
 {
-       return send_command_locked(PTR_TO_CALLNO(c->tech_pvt), AST_FRAME_DTMF_BEGIN, digit, 0, NULL, 0, -1);
+       return send_command_locked(PTR_TO_CALLNO(ast_channel_tech_pvt(c)), AST_FRAME_DTMF_BEGIN, digit, 0, NULL, 0, -1);
 }
 
 static int iax2_digit_end(struct ast_channel *c, char digit, unsigned int duration)
 {
-       return send_command_locked(PTR_TO_CALLNO(c->tech_pvt), AST_FRAME_DTMF_END, digit, 0, NULL, 0, -1);
+       return send_command_locked(PTR_TO_CALLNO(ast_channel_tech_pvt(c)), AST_FRAME_DTMF_END, digit, 0, NULL, 0, -1);
 }
 
 static int iax2_sendtext(struct ast_channel *c, const char *text)
 {
        
-       return send_command_locked(PTR_TO_CALLNO(c->tech_pvt), AST_FRAME_TEXT,
+       return send_command_locked(PTR_TO_CALLNO(ast_channel_tech_pvt(c)), AST_FRAME_TEXT,
                0, 0, (unsigned char *)text, strlen(text) + 1, -1);
 }
 
 static int iax2_sendimage(struct ast_channel *c, struct ast_frame *img)
 {
-       return send_command_locked(PTR_TO_CALLNO(c->tech_pvt), AST_FRAME_IMAGE, img->subclass.integer, 0, img->data.ptr, img->datalen, -1);
+       return send_command_locked(PTR_TO_CALLNO(ast_channel_tech_pvt(c)), AST_FRAME_IMAGE, img->subclass.integer, 0, img->data.ptr, img->datalen, -1);
 }
 
 static int iax2_sendhtml(struct ast_channel *c, int subclass, const char *data, int datalen)
 {
-       return send_command_locked(PTR_TO_CALLNO(c->tech_pvt), AST_FRAME_HTML, subclass, 0, (unsigned char *)data, datalen, -1);
+       return send_command_locked(PTR_TO_CALLNO(ast_channel_tech_pvt(c)), AST_FRAME_HTML, subclass, 0, (unsigned char *)data, datalen, -1);
 }
 
 static int iax2_fixup(struct ast_channel *oldchannel, struct ast_channel *newchan)
 {
-       unsigned short callno = PTR_TO_CALLNO(newchan->tech_pvt);
+       unsigned short callno = PTR_TO_CALLNO(ast_channel_tech_pvt(newchan));
        ast_mutex_lock(&iaxsl[callno]);
        if (iaxs[callno])
                iaxs[callno]->owner = newchan;
@@ -4572,11 +4572,11 @@ static int create_addr(const char *peername, struct ast_channel *c, struct socka
                memcpy(&ourprefs, &prefs, sizeof(ourprefs));
                if (c) {
                        struct ast_format tmpfmt;
-                       ast_format_cap_iter_start(c->nativeformats);
-                       while (!(ast_format_cap_iter_next(c->nativeformats, &tmpfmt))) {
+                       ast_format_cap_iter_start(ast_channel_nativeformats(c));
+                       while (!(ast_format_cap_iter_next(ast_channel_nativeformats(c), &tmpfmt))) {
                                ast_codec_pref_prepend(&ourprefs, &tmpfmt, 1);
                        }
-                       ast_format_cap_iter_end(c->nativeformats);
+                       ast_format_cap_iter_end(ast_channel_nativeformats(c));
                }
                ast_codec_pref_convert(&ourprefs, cai->prefs, sizeof(cai->prefs), 1);
                return 0;
@@ -4605,12 +4605,12 @@ static int create_addr(const char *peername, struct ast_channel *c, struct socka
        /* Move the calling channel's native codec to the top of the preference list */
        if (c) {
                struct ast_format tmpfmt;
-               ast_format_cap_iter_start(c->nativeformats);
-               while (!(ast_format_cap_iter_next(c->nativeformats, &tmpfmt))) {
+               ast_format_cap_iter_start(ast_channel_nativeformats(c));
+               while (!(ast_format_cap_iter_next(ast_channel_nativeformats(c), &tmpfmt))) {
                        ast_debug(1, "prepending %s to prefs\n", ast_getformatname(&tmpfmt));
                        ast_codec_pref_prepend(&ourprefs, &tmpfmt, 1);
                }
-               ast_format_cap_iter_end(c->nativeformats);
+               ast_format_cap_iter_end(ast_channel_nativeformats(c));
        }
        ast_codec_pref_convert(&ourprefs, cai->prefs, sizeof(cai->prefs), 1);
        ast_copy_string(cai->context, peer->context, sizeof(cai->context));
@@ -5013,7 +5013,7 @@ static int iax2_call(struct ast_channel *c, const char *dest, int timeout)
        char *l=NULL, *n=NULL, *tmpstr;
        struct iax_ie_data ied;
        char *defaultrdest = "s";
-       unsigned short callno = PTR_TO_CALLNO(c->tech_pvt);
+       unsigned short callno = PTR_TO_CALLNO(ast_channel_tech_pvt(c));
        struct parsed_dial_string pds;
        struct create_addr_info cai;
        struct ast_var_t *var;
@@ -5025,7 +5025,7 @@ static int iax2_call(struct ast_channel *c, const char *dest, int timeout)
        unsigned char osp_buffer[256];
        iax2_format iax2_tmpfmt;
 
-       if ((c->_state != AST_STATE_DOWN) && (c->_state != AST_STATE_RESERVED)) {
+       if ((ast_channel_state(c) != AST_STATE_DOWN) && (ast_channel_state(c) != AST_STATE_RESERVED)) {
                ast_log(LOG_WARNING, "Channel is already in use (%s)?\n", ast_channel_name(c));
                return -1;
        }
@@ -5050,7 +5050,7 @@ static int iax2_call(struct ast_channel *c, const char *dest, int timeout)
        }
        if (ast_test_flag64(iaxs[callno], IAX_FORCE_ENCRYPT) && !cai.encmethods) {
                ast_log(LOG_WARNING, "Encryption forced for call, but not enabled\n");
-               c->hangupcause = AST_CAUSE_BEARERCAPABILITY_NOTAVAIL;
+               ast_channel_hangupcause_set(c, AST_CAUSE_BEARERCAPABILITY_NOTAVAIL);
                return -1;
        }
        if (ast_strlen_zero(cai.secret) && ast_test_flag64(iaxs[callno], IAX_FORCE_ENCRYPT)) {
@@ -5150,13 +5150,13 @@ static int iax2_call(struct ast_channel *c, const char *dest, int timeout)
        if (pds.password)
                ast_string_field_set(iaxs[callno], secret, pds.password);
 
-       iax2_tmpfmt = ast_format_cap_to_old_bitfield(c->nativeformats);
+       iax2_tmpfmt = ast_format_cap_to_old_bitfield(ast_channel_nativeformats(c));
        iax_ie_append_int(&ied, IAX_IE_FORMAT, (int) iax2_tmpfmt);
        iax_ie_append_versioned_uint64(&ied, IAX_IE_FORMAT2, 0, iax2_tmpfmt);
 
        iax_ie_append_int(&ied, IAX_IE_CAPABILITY, (int) iaxs[callno]->capability);
        iax_ie_append_versioned_uint64(&ied, IAX_IE_CAPABILITY2, 0, iaxs[callno]->capability);
-       iax_ie_append_short(&ied, IAX_IE_ADSICPE, c->adsicpe);
+       iax_ie_append_short(&ied, IAX_IE_ADSICPE, ast_channel_adsicpe(c));
        iax_ie_append_int(&ied, IAX_IE_DATETIME, iax2_datetime(cai.timezone));
 
        if (iaxs[callno]->maxtime) {
@@ -5220,7 +5220,7 @@ static int iax2_call(struct ast_channel *c, const char *dest, int timeout)
 
 static int iax2_hangup(struct ast_channel *c)
 {
-       unsigned short callno = PTR_TO_CALLNO(c->tech_pvt);
+       unsigned short callno = PTR_TO_CALLNO(ast_channel_tech_pvt(c));
        struct iax_ie_data ied;
        int alreadygone;
        memset(&ied, 0, sizeof(ied));
@@ -5229,7 +5229,7 @@ static int iax2_hangup(struct ast_channel *c)
                ast_debug(1, "We're hanging up %s now...\n", ast_channel_name(c));
                alreadygone = ast_test_flag64(iaxs[callno], IAX_ALREADYGONE);
                /* Send the hangup unless we have had a transmission error or are already gone */
-               iax_ie_append_byte(&ied, IAX_IE_CAUSECODE, (unsigned char)c->hangupcause);
+               iax_ie_append_byte(&ied, IAX_IE_CAUSECODE, (unsigned char)ast_channel_hangupcause(c));
                if (!iaxs[callno]->error && !alreadygone) {
                        if (send_command_final(iaxs[callno], AST_FRAME_IAX, IAX_COMMAND_HANGUP, 0, ied.buf, ied.pos, -1)) {
                                ast_log(LOG_WARNING, "No final packet could be sent for callno %d\n", callno);
@@ -5251,12 +5251,12 @@ static int iax2_hangup(struct ast_channel *c)
                                iax2_destroy(callno);
                        }
                }
-       } else if (c->tech_pvt) {
+       } else if (ast_channel_tech_pvt(c)) {
                /* If this call no longer exists, but the channel still
                 * references it we need to set the channel's tech_pvt to null
                 * to avoid ast_channel_free() trying to free it.
                 */
-               c->tech_pvt = NULL;
+               ast_channel_tech_pvt_set(c, NULL);
        }
        ast_mutex_unlock(&iaxsl[callno]);
        ast_verb(3, "Hungup '%s'\n", ast_channel_name(c));
@@ -5302,7 +5302,7 @@ static int iax2_setoption(struct ast_channel *c, int option, void *data, int dat
        case AST_OPTION_SECURE_SIGNALING:
        case AST_OPTION_SECURE_MEDIA:
        {
-               unsigned short callno = PTR_TO_CALLNO(c->tech_pvt);
+               unsigned short callno = PTR_TO_CALLNO(ast_channel_tech_pvt(c));
                ast_mutex_lock(&iaxsl[callno]);
                if ((*(int *) data)) {
                        ast_set_flag64(iaxs[callno], IAX_FORCE_ENCRYPT);
@@ -5323,7 +5323,7 @@ static int iax2_setoption(struct ast_channel *c, int option, void *data, int dat
        case AST_OPTION_DIGIT_DETECT:
        case AST_OPTION_FAX_DETECT:
        {
-               unsigned short callno = PTR_TO_CALLNO(c->tech_pvt);
+               unsigned short callno = PTR_TO_CALLNO(ast_channel_tech_pvt(c));
                struct chan_iax2_pvt *pvt;
 
                ast_mutex_lock(&iaxsl[callno]);
@@ -5343,7 +5343,7 @@ static int iax2_setoption(struct ast_channel *c, int option, void *data, int dat
                h->flag = AST_OPTION_FLAG_REQUEST;
                h->option = htons(option);
                memcpy(h->data, data, datalen);
-               res = send_command_locked(PTR_TO_CALLNO(c->tech_pvt), AST_FRAME_CONTROL,
+               res = send_command_locked(PTR_TO_CALLNO(ast_channel_tech_pvt(c)), AST_FRAME_CONTROL,
                                          AST_CONTROL_OPTION, 0, (unsigned char *) h,
                                          datalen + sizeof(*h), -1);
                ast_free(h);
@@ -5363,7 +5363,7 @@ static int iax2_queryoption(struct ast_channel *c, int option, void *data, int *
        case AST_OPTION_SECURE_SIGNALING:
        case AST_OPTION_SECURE_MEDIA:
        {
-               unsigned short callno = PTR_TO_CALLNO(c->tech_pvt);
+               unsigned short callno = PTR_TO_CALLNO(ast_channel_tech_pvt(c));
                ast_mutex_lock(&iaxsl[callno]);
                *((int *) data) = ast_test_flag64(iaxs[callno], IAX_FORCE_ENCRYPT) ? 1 : 0;
                ast_mutex_unlock(&iaxsl[callno]);
@@ -5469,8 +5469,8 @@ static enum ast_bridge_result iax2_bridge(struct ast_channel *c0, struct ast_cha
        int res = -1;
        int transferstarted=0;
        struct ast_frame *f;
-       unsigned short callno0 = PTR_TO_CALLNO(c0->tech_pvt);
-       unsigned short callno1 = PTR_TO_CALLNO(c1->tech_pvt);
+       unsigned short callno0 = PTR_TO_CALLNO(ast_channel_tech_pvt(c0));
+       unsigned short callno1 = PTR_TO_CALLNO(ast_channel_tech_pvt(c1));
        struct timeval waittimer = {0, 0};
 
        /* We currently do not support native bridging if a timeoutms value has been provided */
@@ -5497,26 +5497,26 @@ static enum ast_bridge_result iax2_bridge(struct ast_channel *c0, struct ast_cha
        cs[1] = c1;
        for (/* ever */;;) {
                /* Check in case we got masqueraded into */
-               if ((c0->tech != &iax2_tech) || (c1->tech != &iax2_tech)) {
+               if ((ast_channel_tech(c0) != &iax2_tech) || (ast_channel_tech(c1) != &iax2_tech)) {
                        ast_verb(3, "Can't masquerade, we're different...\n");
                        /* Remove from native mode */
-                       if (c0->tech == &iax2_tech) {
+                       if (ast_channel_tech(c0) == &iax2_tech) {
                                ast_mutex_lock(&iaxsl[callno0]);
                                iaxs[callno0]->bridgecallno = 0;
                                ast_mutex_unlock(&iaxsl[callno0]);
                        }
-                       if (c1->tech == &iax2_tech) {
+                       if (ast_channel_tech(c1) == &iax2_tech) {
                                ast_mutex_lock(&iaxsl[callno1]);
                                iaxs[callno1]->bridgecallno = 0;
                                ast_mutex_unlock(&iaxsl[callno1]);
                        }
                        return AST_BRIDGE_FAILED_NOWARN;
                }
-               if (!(ast_format_cap_identical(c0->nativeformats, c1->nativeformats))) {
+               if (!(ast_format_cap_identical(ast_channel_nativeformats(c0), ast_channel_nativeformats(c1)))) {
                        char buf0[256];
                        char buf1[256];
-                       ast_getformatname_multiple(buf0, sizeof(buf0), c0->nativeformats);
-                       ast_getformatname_multiple(buf1, sizeof(buf1), c1->nativeformats);
+                       ast_getformatname_multiple(buf0, sizeof(buf0), ast_channel_nativeformats(c0));
+                       ast_getformatname_multiple(buf1, sizeof(buf1), ast_channel_nativeformats(c1));
                        ast_verb(3, "Operating with different codecs [%s] [%s] , can't native bridge...\n", buf0, buf1);
                        /* Remove from native mode */
                        lock_both(callno0, callno1);
@@ -5618,7 +5618,7 @@ static enum ast_bridge_result iax2_bridge(struct ast_channel *c0, struct ast_cha
 
 static int iax2_answer(struct ast_channel *c)
 {
-       unsigned short callno = PTR_TO_CALLNO(c->tech_pvt);
+       unsigned short callno = PTR_TO_CALLNO(ast_channel_tech_pvt(c));
        ast_debug(1, "Answering IAX2 call\n");
        ast_mutex_lock(&iaxsl[callno]);
        if (iaxs[callno])
@@ -5629,7 +5629,7 @@ static int iax2_answer(struct ast_channel *c)
 
 static int iax2_indicate(struct ast_channel *c, int condition, const void *data, size_t datalen)
 {
-       unsigned short callno = PTR_TO_CALLNO(c->tech_pvt);
+       unsigned short callno = PTR_TO_CALLNO(ast_channel_tech_pvt(c));
        struct chan_iax2_pvt *pvt;
        int res = 0;
 
@@ -5673,7 +5673,7 @@ done:
 
 static int iax2_transfer(struct ast_channel *c, const char *dest)
 {
-       unsigned short callno = PTR_TO_CALLNO(c->tech_pvt);
+       unsigned short callno = PTR_TO_CALLNO(ast_channel_tech_pvt(c));
        struct iax_ie_data ied = { "", };
        char tmp[256], *context;
        enum ast_control_transfer message = AST_TRANSFER_SUCCESS;
@@ -5745,17 +5745,17 @@ static struct ast_channel *ast_iax2_new(int callno, int state, iax2_format capab
        iax2_ami_channelupdate(i);
        if (!tmp)
                return NULL;
-       tmp->tech = &iax2_tech;
+       ast_channel_tech_set(tmp, &iax2_tech);
        /* We can support any format by default, until we get restricted */
-       ast_format_cap_from_old_bitfield(tmp->nativeformats, capability);
-       ast_best_codec(tmp->nativeformats, &tmpfmt);
+       ast_format_cap_from_old_bitfield(ast_channel_nativeformats(tmp), capability);
+       ast_best_codec(ast_channel_nativeformats(tmp), &tmpfmt);
 
        ast_format_copy(&tmp->readformat, &tmpfmt);
        ast_format_copy(&tmp->rawreadformat, &tmpfmt);
        ast_format_copy(&tmp->writeformat, &tmpfmt);
        ast_format_copy(&tmp->rawwriteformat, &tmpfmt);
 
-       tmp->tech_pvt = CALLNO_TO_PTR(i->callno);
+       ast_channel_tech_pvt_set(tmp, CALLNO_TO_PTR(i->callno));
 
        if (!ast_strlen_zero(i->parkinglot))
                ast_channel_parkinglot_set(tmp, i->parkinglot);
@@ -5782,13 +5782,13 @@ static struct ast_channel *ast_iax2_new(int callno, int state, iax2_format capab
        if (!ast_strlen_zero(i->accountcode))
                ast_channel_accountcode_set(tmp, i->accountcode);
        if (i->amaflags)
-               tmp->amaflags = i->amaflags;
+               ast_channel_amaflags_set(tmp, i->amaflags);
        ast_channel_context_set(tmp, i->context);
        ast_channel_exten_set(tmp, i->exten);
        if (i->adsi)
-               tmp->adsicpe = i->peeradsicpe;
+               ast_channel_adsicpe_set(tmp, i->peeradsicpe);
        else
-               tmp->adsicpe = AST_ADSI_UNAVAILABLE;
+               ast_channel_adsicpe_set(tmp, AST_ADSI_UNAVAILABLE);
        i->owner = tmp;
        i->capability = capability;
 
@@ -7445,7 +7445,7 @@ static char *handle_cli_iax2_set_debug_jb(struct ast_cli_entry *e, int cmd, stru
 
 static int iax2_write(struct ast_channel *c, struct ast_frame *f)
 {
-       unsigned short callno = PTR_TO_CALLNO(c->tech_pvt);
+       unsigned short callno = PTR_TO_CALLNO(ast_channel_tech_pvt(c));
        int res = -1;
        ast_mutex_lock(&iaxsl[callno]);
        if (iaxs[callno]) {
@@ -9322,8 +9322,8 @@ static int iax_park(struct ast_channel *chan1, struct ast_channel *chan2, const
        struct ast_channel *chan1m, *chan2m;/* Chan2m: The transferer, chan1m: The transferee */
        pthread_t th;
 
-       chan1m = ast_channel_alloc(0, AST_STATE_DOWN, 0, 0, ast_channel_accountcode(chan2), ast_channel_exten(chan1), ast_channel_context(chan1), ast_channel_linkedid(chan1), chan1->amaflags, "Parking/%s", ast_channel_name(chan1));
-       chan2m = ast_channel_alloc(0, AST_STATE_DOWN, 0, 0, ast_channel_accountcode(chan2), ast_channel_exten(chan2), ast_channel_context(chan2), ast_channel_linkedid(chan2), chan2->amaflags, "IAXPeer/%s", ast_channel_name(chan2));
+       chan1m = ast_channel_alloc(0, AST_STATE_DOWN, 0, 0, ast_channel_accountcode(chan2), ast_channel_exten(chan1), ast_channel_context(chan1), ast_channel_linkedid(chan1), ast_channel_amaflags(chan1), "Parking/%s", ast_channel_name(chan1));
+       chan2m = ast_channel_alloc(0, AST_STATE_DOWN, 0, 0, ast_channel_accountcode(chan2), ast_channel_exten(chan2), ast_channel_context(chan2), ast_channel_linkedid(chan2), ast_channel_amaflags(chan2), "IAXPeer/%s", ast_channel_name(chan2));
        d = ast_calloc(1, sizeof(*d));
        if (!chan1m || !chan2m || !d) {
                if (chan1m) {
@@ -9363,7 +9363,7 @@ static int iax_park(struct ast_channel *chan1, struct ast_channel *chan2, const
        /* Setup the extensions and such */
        ast_channel_context_set(chan1m, ast_channel_context(chan1));
        ast_channel_exten_set(chan1m, ast_channel_exten(chan1));
-       chan1m->priority = chan1->priority;
+       ast_channel_priority_set(chan1m, ast_channel_priority(chan1));
 
        ast_do_masquerade(chan1m);
 
@@ -9388,7 +9388,7 @@ static int iax_park(struct ast_channel *chan1, struct ast_channel *chan2, const
        /* Setup the extensions and such */
        ast_channel_context_set(chan2m, ast_channel_context(chan2));
        ast_channel_exten_set(chan2m, ast_channel_exten(chan2));
-       chan2m->priority = chan2->priority;
+       ast_channel_priority_set(chan2m, ast_channel_priority(chan2));
 
        ast_do_masquerade(chan2m);
 
@@ -9876,7 +9876,7 @@ static void set_hangup_source_and_cause(int callno, unsigned char causecode)
        iax2_lock_owner(callno);
        if (iaxs[callno] && iaxs[callno]->owner) {
                if (causecode) {
-                       iaxs[callno]->owner->hangupcause = causecode;
+                       ast_channel_hangupcause_set(iaxs[callno]->owner, causecode);
                }
                ast_set_hangupsource(iaxs[callno]->owner, ast_channel_name(iaxs[callno]->owner), 0);
                ast_channel_unlock(iaxs[callno]->owner);
@@ -10357,8 +10357,8 @@ static int socket_process(struct iax2_thread *thread)
                                                iax2_lock_owner(fr->callno);
                                                if (iaxs[fr->callno]) {
                                                        if (iaxs[fr->callno]->owner) {
-                                                               struct ast_format_cap *orignative = ast_format_cap_dup(iaxs[fr->callno]->owner->nativeformats);
-                                                               struct ast_format_cap *native = iaxs[fr->callno]->owner->nativeformats;
+                                                               struct ast_format_cap *orignative = ast_format_cap_dup(ast_channel_nativeformats(iaxs[fr->callno]->owner));
+                                                               struct ast_format_cap *native = ast_channel_nativeformats(iaxs[fr->callno]->owner);
                                                                if (orignative) {
                                                                        ast_format_cap_set(native, &f.subclass.format);
                                                                        if (iaxs[fr->callno]->owner->readformat.id) {
@@ -10391,9 +10391,9 @@ static int socket_process(struct iax2_thread *thread)
                }
                if (f.frametype == AST_FRAME_CONTROL && iaxs[fr->callno]->owner) {
                        if (f.subclass.integer == AST_CONTROL_BUSY) {
-                               iaxs[fr->callno]->owner->hangupcause = AST_CAUSE_BUSY;
+                               ast_channel_hangupcause_set(iaxs[fr->callno]->owner, AST_CAUSE_BUSY);
                        } else if (f.subclass.integer == AST_CONTROL_CONGESTION) {
-                               iaxs[fr->callno]->owner->hangupcause = AST_CAUSE_CONGESTION;
+                               ast_channel_hangupcause_set(iaxs[fr->callno]->owner, AST_CAUSE_CONGESTION);
                        }
                }
                if (f.frametype == AST_FRAME_IAX) {
@@ -10837,7 +10837,7 @@ static int socket_process(struct iax2_thread *thread)
                                        iaxs[fr->callno]->peerformat = ies.format;
                                } else {
                                        if (iaxs[fr->callno]->owner)
-                                               iaxs[fr->callno]->peerformat = ast_format_cap_to_old_bitfield(iaxs[fr->callno]->owner->nativeformats);
+                                               iaxs[fr->callno]->peerformat = ast_format_cap_to_old_bitfield(ast_channel_nativeformats(iaxs[fr->callno]->owner));
                                        else
                                                iaxs[fr->callno]->peerformat = iaxs[fr->callno]->capability;
                                }
@@ -10863,8 +10863,8 @@ static int socket_process(struct iax2_thread *thread)
                                        if (iaxs[fr->callno] && iaxs[fr->callno]->owner) {
                                                char tmp[256];
                                                /* Switch us to use a compatible format */
-                                               ast_format_cap_from_old_bitfield(iaxs[fr->callno]->owner->nativeformats, iaxs[fr->callno]->peerformat);
-                                               ast_verb(3, "Format for call is %s\n", ast_getformatname_multiple(tmp, sizeof(tmp), iaxs[fr->callno]->owner->nativeformats));
+                                               ast_format_cap_from_old_bitfield(ast_channel_nativeformats(iaxs[fr->callno]->owner), iaxs[fr->callno]->peerformat);
+                                               ast_verb(3, "Format for call is %s\n", ast_getformatname_multiple(tmp, sizeof(tmp), ast_channel_nativeformats(iaxs[fr->callno]->owner)));
 
                                                /* Setup read/write formats properly. */
                                                if (iaxs[fr->callno]->owner->writeformat.id)
@@ -11915,7 +11915,7 @@ static int iax2_prov_app(struct ast_channel *chan, const char *data)
        char *sdata;
        char *opts;
        int force =0;
-       unsigned short callno = PTR_TO_CALLNO(chan->tech_pvt);
+       unsigned short callno = PTR_TO_CALLNO(ast_channel_tech_pvt(chan));
        if (ast_strlen_zero(data))
                data = "default";
        sdata = ast_strdupa(data);
@@ -11923,7 +11923,7 @@ static int iax2_prov_app(struct ast_channel *chan, const char *data)
        if (opts)
                *opts='\0';
 
-       if (chan->tech != &iax2_tech) {
+       if (ast_channel_tech(chan) != &iax2_tech) {
                ast_log(LOG_NOTICE, "Can't provision a non-IAX device!\n");
                return -1;
        } 
@@ -12159,24 +12159,24 @@ static struct ast_channel *iax2_request(const char *type, struct ast_format_cap
                struct ast_format_cap *joint;
 
                /* Choose a format we can live with */
-               if ((joint = ast_format_cap_joint(c->nativeformats, cap))) {
-                       ast_format_cap_copy(c->nativeformats, joint);
+               if ((joint = ast_format_cap_joint(ast_channel_nativeformats(c), cap))) {
+                       ast_format_cap_copy(ast_channel_nativeformats(c), joint);
                        joint = ast_format_cap_destroy(joint);
                } else {
                        struct ast_format best_fmt_cap;
                        struct ast_format best_fmt_native;
-                       res = ast_translator_best_choice(cap, c->nativeformats, &best_fmt_cap, &best_fmt_native);
+                       res = ast_translator_best_choice(cap, ast_channel_nativeformats(c), &best_fmt_cap, &best_fmt_native);
                        if (res < 0) {
                                char tmp[256];
                                char tmp2[256];
                                ast_log(LOG_WARNING, "Unable to create translator path for %s to %s on %s\n",
-                                       ast_getformatname_multiple(tmp, sizeof(tmp), c->nativeformats), ast_getformatname_multiple(tmp2, sizeof(tmp2), cap), ast_channel_name(c));
+                                       ast_getformatname_multiple(tmp, sizeof(tmp), ast_channel_nativeformats(c)), ast_getformatname_multiple(tmp2, sizeof(tmp2), cap), ast_channel_name(c));
                                ast_hangup(c);
                                return NULL;
                        }
-                       ast_format_cap_set(c->nativeformats, &best_fmt_native);
+                       ast_format_cap_set(ast_channel_nativeformats(c), &best_fmt_native);
                }
-               ast_best_codec(c->nativeformats, &c->readformat);
+               ast_best_codec(ast_channel_nativeformats(c), &c->readformat);
                ast_format_copy(&c->writeformat, &c->readformat);
        }
 
@@ -13897,9 +13897,9 @@ static int function_iaxpeer(struct ast_channel *chan, const char *cmd, char *dat
        /* if our channel, return the IP address of the endpoint of current channel */
        if (!strcmp(peername,"CURRENTCHANNEL")) {
                unsigned short callno;
-               if (chan->tech != &iax2_tech)
+               if (ast_channel_tech(chan) != &iax2_tech)
                        return -1;
-               callno = PTR_TO_CALLNO(chan->tech_pvt); 
+               callno = PTR_TO_CALLNO(ast_channel_tech_pvt(chan));     
                ast_copy_string(buf, iaxs[callno]->addr.sin_addr.s_addr ? ast_inet_ntoa(iaxs[callno]->addr.sin_addr) : "", len);
                return 0;
        }
@@ -13964,12 +13964,12 @@ static int acf_channel_read(struct ast_channel *chan, const char *funcname, char
        unsigned int callno;
        int res = 0;
 
-       if (!chan || chan->tech != &iax2_tech) {
+       if (!chan || ast_channel_tech(chan) != &iax2_tech) {
                ast_log(LOG_ERROR, "This function requires a valid IAX2 channel\n");
                return -1;
        }
 
-       callno = PTR_TO_CALLNO(chan->tech_pvt);
+       callno = PTR_TO_CALLNO(ast_channel_tech_pvt(chan));
        ast_mutex_lock(&iaxsl[callno]);
        if (!(pvt = iaxs[callno])) {
                ast_mutex_unlock(&iaxsl[callno]);
index 9825f73d8c429074cc2b59a3b11530b23555b561..a683a41607d1f5a2ac23ce8e932c217c5af69bf2 100644 (file)
@@ -386,7 +386,7 @@ static int jingle_ringing_ack(void *data, ikspak *pak)
 
 static int jingle_answer(struct ast_channel *ast)
 {
-       struct jingle_pvt *p = ast->tech_pvt;
+       struct jingle_pvt *p = ast_channel_tech_pvt(ast);
        struct jingle *client = p->parent;
        int res = 0;
 
@@ -399,7 +399,7 @@ static int jingle_answer(struct ast_channel *ast)
 
 static enum ast_rtp_glue_result jingle_get_rtp_peer(struct ast_channel *chan, struct ast_rtp_instance **instance)
 {
-       struct jingle_pvt *p = chan->tech_pvt;
+       struct jingle_pvt *p = ast_channel_tech_pvt(chan);
        enum ast_rtp_glue_result res = AST_RTP_GLUE_RESULT_FORBID;
 
        if (!p)
@@ -418,7 +418,7 @@ static enum ast_rtp_glue_result jingle_get_rtp_peer(struct ast_channel *chan, st
 
 static void jingle_get_codec(struct ast_channel *chan, struct ast_format_cap *result)
 {
-       struct jingle_pvt *p = chan->tech_pvt;
+       struct jingle_pvt *p = ast_channel_tech_pvt(chan);
        ast_mutex_lock(&p->lock);
        ast_format_cap_copy(result, p->peercap);
        ast_mutex_unlock(&p->lock);
@@ -428,7 +428,7 @@ static int jingle_set_rtp_peer(struct ast_channel *chan, struct ast_rtp_instance
 {
        struct jingle_pvt *p;
 
-       p = chan->tech_pvt;
+       p = ast_channel_tech_pvt(chan);
        if (!p)
                return -1;
        ast_mutex_lock(&p->lock);
@@ -842,7 +842,7 @@ static struct ast_channel *jingle_new(struct jingle *client, struct jingle_pvt *
                ast_log(LOG_WARNING, "Unable to allocate Jingle channel structure!\n");
                return NULL;
        }
-       tmp->tech = &jingle_tech;
+       ast_channel_tech_set(tmp, &jingle_tech);
 
        /* Select our native format based on codec preference until we receive
           something from another device to the contrary. */
@@ -858,12 +858,12 @@ static struct ast_channel *jingle_new(struct jingle *client, struct jingle_pvt *
                ast_rtp_codecs_packetization_set(ast_rtp_instance_get_codecs(i->rtp), i->rtp, &i->prefs);
 
        ast_codec_choose(&i->prefs, what, 1, &tmpfmt);
-       ast_format_cap_add(tmp->nativeformats, &tmpfmt);
+       ast_format_cap_add(ast_channel_nativeformats(tmp), &tmpfmt);
 
        ast_format_cap_iter_start(i->jointcap);
        while (!(ast_format_cap_iter_next(i->jointcap, &tmpfmt))) {
                if (AST_FORMAT_GET_TYPE(tmpfmt.id) == AST_FORMAT_TYPE_VIDEO) {
-                       ast_format_cap_add(tmp->nativeformats, &tmpfmt);
+                       ast_format_cap_add(ast_channel_nativeformats(tmp), &tmpfmt);
                }
        }
        ast_format_cap_iter_end(i->jointcap);
@@ -877,16 +877,16 @@ static struct ast_channel *jingle_new(struct jingle *client, struct jingle_pvt *
                ast_channel_set_fd(tmp, 3, ast_rtp_instance_fd(i->vrtp, 1));
        }
        if (state == AST_STATE_RING)
-               tmp->rings = 1;
-       tmp->adsicpe = AST_ADSI_UNAVAILABLE;
+               ast_channel_rings_set(tmp, 1);
+       ast_channel_adsicpe_set(tmp, AST_ADSI_UNAVAILABLE);
 
 
-       ast_best_codec(tmp->nativeformats, &tmpfmt);
+       ast_best_codec(ast_channel_nativeformats(tmp), &tmpfmt);
        ast_format_copy(&tmp->writeformat, &tmpfmt);
        ast_format_copy(&tmp->rawwriteformat, &tmpfmt);
        ast_format_copy(&tmp->readformat, &tmpfmt);
        ast_format_copy(&tmp->rawreadformat, &tmpfmt);
-       tmp->tech_pvt = i;
+       ast_channel_tech_pvt_set(tmp, i);
 
        tmp->callgroup = client->callgroup;
        tmp->pickupgroup = client->pickupgroup;
@@ -895,7 +895,7 @@ static struct ast_channel *jingle_new(struct jingle *client, struct jingle_pvt *
        if (!ast_strlen_zero(client->accountcode))
                ast_channel_accountcode_set(tmp, client->accountcode);
        if (client->amaflags)
-               tmp->amaflags = client->amaflags;
+               ast_channel_amaflags_set(tmp, client->amaflags);
        if (!ast_strlen_zero(client->language))
                ast_channel_language_set(tmp, client->language);
        if (!ast_strlen_zero(client->musicclass))
@@ -912,12 +912,12 @@ static struct ast_channel *jingle_new(struct jingle *client, struct jingle_pvt *
        if (!ast_strlen_zero(i->exten) && strcmp(i->exten, "s")) {
                tmp->dialed.number.str = ast_strdup(i->exten);
        }
-       tmp->priority = 1;
+       ast_channel_priority_set(tmp, 1);
        if (i->rtp)
                ast_jb_configure(tmp, &global_jbconf);
        if (state != AST_STATE_DOWN && ast_pbx_start(tmp)) {
                ast_log(LOG_WARNING, "Unable to start PBX on %s\n", ast_channel_name(tmp));
-               tmp->hangupcause = AST_CAUSE_SWITCH_CONGESTION;
+               ast_channel_hangupcause_set(tmp, AST_CAUSE_SWITCH_CONGESTION);
                ast_hangup(tmp);
                tmp = NULL;
        }
@@ -1229,10 +1229,10 @@ static struct ast_frame *jingle_rtp_read(struct ast_channel *ast, struct jingle_
        if (p->owner) {
                /* We already hold the channel lock */
                if (f->frametype == AST_FRAME_VOICE) {
-                       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, format changed to %s\n", ast_getformatname(&f->subclass.format));
-                               ast_format_cap_remove_bytype(p->owner->nativeformats, AST_FORMAT_TYPE_AUDIO);
-                               ast_format_cap_add(p->owner->nativeformats, &f->subclass.format);
+                               ast_format_cap_remove_bytype(ast_channel_nativeformats(p->owner), AST_FORMAT_TYPE_AUDIO);
+                               ast_format_cap_add(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);
                        }
@@ -1249,7 +1249,7 @@ static struct ast_frame *jingle_rtp_read(struct ast_channel *ast, struct jingle_
 static struct ast_frame *jingle_read(struct ast_channel *ast)
 {
        struct ast_frame *fr;
-       struct jingle_pvt *p = ast->tech_pvt;
+       struct jingle_pvt *p = ast_channel_tech_pvt(ast);
 
        ast_mutex_lock(&p->lock);
        fr = jingle_rtp_read(ast, p);
@@ -1260,17 +1260,17 @@ static struct ast_frame *jingle_read(struct ast_channel *ast)
 /*! \brief Send frame to media channel (rtp) */
 static int jingle_write(struct ast_channel *ast, struct ast_frame *frame)
 {
-       struct jingle_pvt *p = ast->tech_pvt;
+       struct jingle_pvt *p = ast_channel_tech_pvt(ast);
        int res = 0;
        char buf[256];
 
        switch (frame->frametype) {
        case AST_FRAME_VOICE:
-               if (!(ast_format_cap_iscompatible(ast->nativeformats, &frame->subclass.format))) {
+               if (!(ast_format_cap_iscompatible(ast_channel_nativeformats(ast), &frame->subclass.format))) {
                        ast_log(LOG_WARNING,
                                        "Asked to transmit frame type %s, while native formats is %s (read/write = %s/%s)\n",
                                        ast_getformatname(&frame->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));
                        return 0;
@@ -1306,7 +1306,7 @@ static int jingle_write(struct ast_channel *ast, struct ast_frame *frame)
 
 static int jingle_fixup(struct ast_channel *oldchan, struct ast_channel *newchan)
 {
-       struct jingle_pvt *p = newchan->tech_pvt;
+       struct jingle_pvt *p = ast_channel_tech_pvt(newchan);
        ast_mutex_lock(&p->lock);
 
        if ((p->owner != oldchan)) {
@@ -1342,7 +1342,7 @@ static int jingle_sendtext(struct ast_channel *chan, const char *text)
 {
        int res = 0;
        struct aji_client *client = NULL;
-       struct jingle_pvt *p = chan->tech_pvt;
+       struct jingle_pvt *p = ast_channel_tech_pvt(chan);
 
 
        if (!p->parent) {
@@ -1360,7 +1360,7 @@ static int jingle_sendtext(struct ast_channel *chan, const char *text)
 
 static int jingle_digit(struct ast_channel *ast, char digit, unsigned int duration)
 {
-       struct jingle_pvt *p = ast->tech_pvt;
+       struct jingle_pvt *p = ast_channel_tech_pvt(ast);
        struct jingle *client = p->parent;
        iks *iq, *jingle, *dtmf;
        char buffer[2] = {digit, '\0'};
@@ -1500,9 +1500,9 @@ static int jingle_auto_congest(void *nothing)
  *     dest is the dial string */
 static int jingle_call(struct ast_channel *ast, const char *dest, int timeout)
 {
-       struct jingle_pvt *p = ast->tech_pvt;
+       struct jingle_pvt *p = ast_channel_tech_pvt(ast);
 
-       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, "jingle_call called on %s, neither down nor reserved\n", ast_channel_name(ast));
                return -1;
        }
@@ -1525,13 +1525,13 @@ static int jingle_call(struct ast_channel *ast, const char *dest, int timeout)
 /*! \brief Hangup a call through the jingle proxy channel */
 static int jingle_hangup(struct ast_channel *ast)
 {
-       struct jingle_pvt *p = ast->tech_pvt;
+       struct jingle_pvt *p = ast_channel_tech_pvt(ast);
        struct jingle *client;
 
        ast_mutex_lock(&p->lock);
        client = p->parent;
        p->owner = NULL;
-       ast->tech_pvt = NULL;
+       ast_channel_tech_pvt_set(ast, NULL);
        if (!p->alreadygone)
                jingle_action(client, p, JINGLE_TERMINATE);
        ast_mutex_unlock(&p->lock);
index ba116d03acad16ae9158305495e3b992ab0cb346..6123e5484c1d9ef5aabe5e579ac7ce77e6795c6e 100644 (file)
@@ -241,7 +241,7 @@ static int local_setoption(struct ast_channel *ast, int option, void * data, int
        }
 
        /* get the tech pvt */
-       if (!(p = ast->tech_pvt)) {
+       if (!(p = ast_channel_tech_pvt(ast))) {
                return -1;
        }
        ao2_ref(p, 1);
@@ -321,7 +321,7 @@ static int local_devicestate(const char *data)
 /*! \brief Return the bridged channel of a Local channel */
 static struct ast_channel *local_bridgedchannel(struct ast_channel *chan, struct ast_channel *bridge)
 {
-       struct local_pvt *p = bridge->tech_pvt;
+       struct local_pvt *p = ast_channel_tech_pvt(bridge);
        struct ast_channel *bridged = bridge;
 
        if (!p) {
@@ -363,7 +363,7 @@ static int local_queryoption(struct ast_channel *ast, int option, void *data, in
        }
 
        /* for some reason the channel is not locked in channel.c when this function is called */
-       if (!(p = ast->tech_pvt)) {
+       if (!(p = ast_channel_tech_pvt(ast))) {
                return -1;
        }
 
@@ -419,7 +419,7 @@ static int local_queue_frame(struct local_pvt *p, int isoutbound, struct ast_fra
        }
 
        /* do not queue frame if generator is on both local channels */
-       if (us && us->generator && other->generator) {
+       if (us && ast_channel_generator(us) && ast_channel_generator(other)) {
                return 0;
        }
 
@@ -447,7 +447,7 @@ static int local_queue_frame(struct local_pvt *p, int isoutbound, struct ast_fra
 
 static int local_answer(struct ast_channel *ast)
 {
-       struct local_pvt *p = ast->tech_pvt;
+       struct local_pvt *p = ast_channel_tech_pvt(ast);
        int isoutbound;
        int res = -1;
 
@@ -520,21 +520,21 @@ static void check_bridge(struct local_pvt *p)
                        if (!ast_check_hangup(p->chan->_bridge)) {
                                if (!ast_channel_trylock(p->owner)) {
                                        if (!ast_check_hangup(p->owner)) {
-                                               if (p->owner->monitor && !p->chan->_bridge->monitor) {
+                                               if (ast_channel_monitor(p->owner) && !ast_channel_monitor(p->chan->_bridge)) {
                                                        /* If a local channel is being monitored, we don't want a masquerade
                                                         * to cause the monitor to go away. Since the masquerade swaps the monitors,
                                                         * pre-swapping the monitors before the masquerade will ensure that the monitor
                                                         * ends up where it is expected.
                                                         */
-                                                       tmp = p->owner->monitor;
-                                                       p->owner->monitor = p->chan->_bridge->monitor;
-                                                       p->chan->_bridge->monitor = tmp;
+                                                       tmp = ast_channel_monitor(p->owner);
+                                                       ast_channel_monitor_set(p->owner, ast_channel_monitor(p->chan->_bridge));
+                                                       ast_channel_monitor_set(p->chan->_bridge, tmp);
                                                }
-                                               if (p->chan->audiohooks) {
+                                               if (ast_channel_audiohooks(p->chan)) {
                                                        struct ast_audiohook_list *audiohooks_swapper;
-                                                       audiohooks_swapper = p->chan->audiohooks;
-                                                       p->chan->audiohooks = p->owner->audiohooks;
-                                                       p->owner->audiohooks = audiohooks_swapper;
+                                                       audiohooks_swapper = ast_channel_audiohooks(p->chan);
+                                                       ast_channel_audiohooks_set(p->chan, ast_channel_audiohooks(p->owner));
+                                                       ast_channel_audiohooks_set(p->owner, audiohooks_swapper);
                                                }
 
                                                /* If any Caller ID was set, preserve it after masquerade like above. We must check
@@ -587,7 +587,7 @@ static struct ast_frame  *local_read(struct ast_channel *ast)
 
 static int local_write(struct ast_channel *ast, struct ast_frame *f)
 {
-       struct local_pvt *p = ast->tech_pvt;
+       struct local_pvt *p = ast_channel_tech_pvt(ast);
        int res = -1;
        int isoutbound;
 
@@ -618,7 +618,7 @@ static int local_write(struct ast_channel *ast, struct ast_frame *f)
 
 static int local_fixup(struct ast_channel *oldchan, struct ast_channel *newchan)
 {
-       struct local_pvt *p = newchan->tech_pvt;
+       struct local_pvt *p = ast_channel_tech_pvt(newchan);
 
        if (!p) {
                return -1;
@@ -651,7 +651,7 @@ static int local_fixup(struct ast_channel *oldchan, struct ast_channel *newchan)
 
 static int local_indicate(struct ast_channel *ast, int condition, const void *data, size_t datalen)
 {
-       struct local_pvt *p = ast->tech_pvt;
+       struct local_pvt *p = ast_channel_tech_pvt(ast);
        int res = 0;
        struct ast_frame f = { AST_FRAME_CONTROL, };
        int isoutbound;
@@ -718,7 +718,7 @@ static int local_indicate(struct ast_channel *ast, int condition, const void *da
 
 static int local_digit_begin(struct ast_channel *ast, char digit)
 {
-       struct local_pvt *p = ast->tech_pvt;
+       struct local_pvt *p = ast_channel_tech_pvt(ast);
        int res = -1;
        struct ast_frame f = { AST_FRAME_DTMF_BEGIN, };
        int isoutbound;
@@ -740,7 +740,7 @@ static int local_digit_begin(struct ast_channel *ast, char digit)
 
 static int local_digit_end(struct ast_channel *ast, char digit, unsigned int duration)
 {
-       struct local_pvt *p = ast->tech_pvt;
+       struct local_pvt *p = ast_channel_tech_pvt(ast);
        int res = -1;
        struct ast_frame f = { AST_FRAME_DTMF_END, };
        int isoutbound;
@@ -763,7 +763,7 @@ static int local_digit_end(struct ast_channel *ast, char digit, unsigned int dur
 
 static int local_sendtext(struct ast_channel *ast, const char *text)
 {
-       struct local_pvt *p = ast->tech_pvt;
+       struct local_pvt *p = ast_channel_tech_pvt(ast);
        int res = -1;
        struct ast_frame f = { AST_FRAME_TEXT, };
        int isoutbound;
@@ -785,7 +785,7 @@ static int local_sendtext(struct ast_channel *ast, const char *text)
 
 static int local_sendhtml(struct ast_channel *ast, int subclass, const char *data, int datalen)
 {
-       struct local_pvt *p = ast->tech_pvt;
+       struct local_pvt *p = ast_channel_tech_pvt(ast);
        int res = -1;
        struct ast_frame f = { AST_FRAME_HTML, };
        int isoutbound;
@@ -811,7 +811,7 @@ static int local_sendhtml(struct ast_channel *ast, int subclass, const char *dat
  *         dest is the dial string */
 static int local_call(struct ast_channel *ast, const char *dest, int timeout)
 {
-       struct local_pvt *p = ast->tech_pvt;
+       struct local_pvt *p = ast_channel_tech_pvt(ast);
        int pvt_locked = 0;
 
        struct ast_channel *owner = NULL;
@@ -961,11 +961,11 @@ return_cleanup:
 /*! \brief Hangup a call through the local proxy channel */
 static int local_hangup(struct ast_channel *ast)
 {
-       struct local_pvt *p = ast->tech_pvt;
+       struct local_pvt *p = ast_channel_tech_pvt(ast);
        int isoutbound;
        int hangup_chan = 0;
        int res = 0;
-       struct ast_frame f = { AST_FRAME_CONTROL, { AST_CONTROL_HANGUP }, .data.uint32 = ast->hangupcause };
+       struct ast_frame f = { AST_FRAME_CONTROL, { AST_CONTROL_HANGUP }, .data.uint32 = ast_channel_hangupcause(ast) };
        struct ast_channel *owner = NULL;
        struct ast_channel *chan = NULL;
 
@@ -997,7 +997,7 @@ static int local_hangup(struct ast_channel *ast)
        if (isoutbound) {
                const char *status = pbx_builtin_getvar_helper(p->chan, "DIALSTATUS");
                if ((status) && (p->owner)) {
-                       p->owner->hangupcause = p->chan->hangupcause;
+                       ast_channel_hangupcause_set(p->owner, ast_channel_hangupcause(p->chan));
                        pbx_builtin_setvar_helper(p->owner, "CHANLOCALSTATUS", status);
                }
 
@@ -1012,7 +1012,7 @@ static int local_hangup(struct ast_channel *ast)
                p->owner = NULL;
        }
 
-       ast->tech_pvt = NULL; /* this is one of our locked channels, doesn't matter which */
+       ast_channel_tech_pvt_set(ast, NULL); /* this is one of our locked channels, doesn't matter which */
 
        if (!p->owner && !p->chan) {
                ao2_unlock(p);
@@ -1137,7 +1137,7 @@ static struct ast_channel *local_new(struct local_pvt *p, int state, const char
                t = "";
 
        if (p->owner)
-               ama = p->owner->amaflags;
+               ama = ast_channel_amaflags(p->owner);
        else
                ama = 0;
        if (!(tmp = ast_channel_alloc(1, state, 0, 0, t, p->exten, p->context, linkedid, ama, "Local/%s@%s-%04x;1", p->exten, p->context, randnum))
@@ -1149,10 +1149,11 @@ static struct ast_channel *local_new(struct local_pvt *p, int state, const char
                return NULL;
        }
 
-       tmp2->tech = tmp->tech = &local_tech;
+       ast_channel_tech_set(tmp, &local_tech);
+       ast_channel_tech_set(tmp2, &local_tech);
 
-       ast_format_cap_copy(tmp->nativeformats, p->reqcap);
-       ast_format_cap_copy(tmp2->nativeformats, p->reqcap);
+       ast_format_cap_copy(ast_channel_nativeformats(tmp), p->reqcap);
+       ast_format_cap_copy(ast_channel_nativeformats(tmp2), p->reqcap);
 
        /* Determine our read/write format and set it on each channel */
        ast_best_codec(p->reqcap, &fmt);
@@ -1165,8 +1166,8 @@ static struct ast_channel *local_new(struct local_pvt *p, int state, const char
        ast_format_copy(&tmp->rawreadformat, &fmt);
        ast_format_copy(&tmp2->rawreadformat, &fmt);
 
-       tmp->tech_pvt = p;
-       tmp2->tech_pvt = p;
+       ast_channel_tech_pvt_set(tmp, p);
+       ast_channel_tech_pvt_set(tmp2, p);
 
        p->owner = tmp;
        p->chan = tmp2;
@@ -1176,8 +1177,8 @@ static struct ast_channel *local_new(struct local_pvt *p, int state, const char
        ast_channel_context_set(tmp, p->context);
        ast_channel_context_set(tmp2, p->context);
        ast_channel_exten_set(tmp2, p->exten);
-       tmp->priority = 1;
-       tmp2->priority = 1;
+       ast_channel_priority_set(tmp, 1);
+       ast_channel_priority_set(tmp2, 1);
 
        ast_jb_configure(tmp, &p->jb_conf);
 
@@ -1268,7 +1269,7 @@ static int manager_optimize_away(struct mansession *s, const struct message *m)
                return 0;
        }
 
-       p = c->tech_pvt;
+       p = ast_channel_tech_pvt(c);
        ast_channel_unref(c);
        c = NULL;
 
index 3b544f63118734fb19bd4622b2cede1c1f7ec17c..b73ccd24c26baa3f23d321b96ac1f6e6376ad3f6 100644 (file)
@@ -843,7 +843,7 @@ static int mgcp_call(struct ast_channel *ast, const char *dest, int timeout)
        struct ast_var_t *current;
 
        ast_debug(3, "MGCP mgcp_call(%s)\n", ast_channel_name(ast));
-       sub = ast->tech_pvt;
+       sub = ast_channel_tech_pvt(ast);
        p = sub->parent;
        headp = &ast->varshead;
        AST_LIST_TRAVERSE(headp,current,entries) {
@@ -876,7 +876,7 @@ static int mgcp_call(struct ast_channel *ast, const char *dest, int timeout)
                break;
        }
 
-       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, "mgcp_call called on %s, neither down nor reserved\n", ast_channel_name(ast));
                ast_mutex_unlock(&sub->lock);
                return -1;
@@ -919,12 +919,12 @@ static int mgcp_call(struct ast_channel *ast, const char *dest, int timeout)
 
 static int mgcp_hangup(struct ast_channel *ast)
 {
-       struct mgcp_subchannel *sub = ast->tech_pvt;
+       struct mgcp_subchannel *sub = ast_channel_tech_pvt(ast);
        struct mgcp_endpoint *p = sub->parent;
        struct ast_channel *bridged;
 
        ast_debug(1, "mgcp_hangup(%s)\n", ast_channel_name(ast));
-       if (!ast->tech_pvt) {
+       if (!ast_channel_tech_pvt(ast)) {
                ast_debug(1, "Asked to hangup channel not connected\n");
                return 0;
        }
@@ -997,7 +997,7 @@ static int mgcp_hangup(struct ast_channel *ast)
                transmit_notify_request(sub, "");
        }
 
-       ast->tech_pvt = NULL;
+       ast_channel_tech_pvt_set(ast, NULL);
        sub->alreadygone = 0;
        sub->outgoing = 0;
        sub->cxmode = MGCP_CX_INACTIVE;
@@ -1175,7 +1175,7 @@ static struct ast_cli_entry cli_mgcp[] = {
 static int mgcp_answer(struct ast_channel *ast)
 {
        int res = 0;
-       struct mgcp_subchannel *sub = ast->tech_pvt;
+       struct mgcp_subchannel *sub = ast_channel_tech_pvt(ast);
        struct mgcp_endpoint *p = sub->parent;
 
        ast_mutex_lock(&sub->lock);
@@ -1187,7 +1187,7 @@ static int mgcp_answer(struct ast_channel *ast)
        }
        ast_verb(3, "MGCP mgcp_answer(%s) on %s@%s-%d\n",
                        ast_channel_name(ast), p->name, p->parent->name, sub->id);
-       if (ast->_state != AST_STATE_UP) {
+       if (ast_channel_state(ast) != AST_STATE_UP) {
                ast_setstate(ast, AST_STATE_UP);
                ast_debug(1, "mgcp_answer(%s)\n", ast_channel_name(ast));
                transmit_notify_request(sub, "");
@@ -1209,9 +1209,9 @@ static struct ast_frame *mgcp_rtp_read(struct mgcp_subchannel *sub)
        if (sub->owner) {
                /* We already hold the channel lock */
                if (f->frametype == AST_FRAME_VOICE) {
-                       if (!ast_format_cap_iscompatible(sub->owner->nativeformats, &f->subclass.format)) {
+                       if (!ast_format_cap_iscompatible(ast_channel_nativeformats(sub->owner), &f->subclass.format)) {
                                ast_debug(1, "Oooh, format changed to %s\n", ast_getformatname(&f->subclass.format));
-                               ast_format_cap_set(sub->owner->nativeformats, &f->subclass.format);
+                               ast_format_cap_set(ast_channel_nativeformats(sub->owner), &f->subclass.format);
                                ast_set_read_format(sub->owner, &sub->owner->readformat);
                                ast_set_write_format(sub->owner, &sub->owner->writeformat);
                        }
@@ -1231,7 +1231,7 @@ static struct ast_frame *mgcp_rtp_read(struct mgcp_subchannel *sub)
 static struct ast_frame *mgcp_read(struct ast_channel *ast)
 {
        struct ast_frame *f;
-       struct mgcp_subchannel *sub = ast->tech_pvt;
+       struct mgcp_subchannel *sub = ast_channel_tech_pvt(ast);
        ast_mutex_lock(&sub->lock);
        f = mgcp_rtp_read(sub);
        ast_mutex_unlock(&sub->lock);
@@ -1240,7 +1240,7 @@ static struct ast_frame *mgcp_read(struct ast_channel *ast)
 
 static int mgcp_write(struct ast_channel *ast, struct ast_frame *frame)
 {
-       struct mgcp_subchannel *sub = ast->tech_pvt;
+       struct mgcp_subchannel *sub = ast_channel_tech_pvt(ast);
        int res = 0;
        char buf[256];
 
@@ -1252,10 +1252,10 @@ static int mgcp_write(struct ast_channel *ast, struct ast_frame *frame)
                        return 0;
                }
        } else {
-               if (!(ast_format_cap_iscompatible(ast->nativeformats, &frame->subclass.format))) {
+               if (!(ast_format_cap_iscompatible(ast_channel_nativeformats(ast), &frame->subclass.format))) {
                        ast_log(LOG_WARNING, "Asked to transmit frame type %s, while native formats is %s (read/write = %s/%s)\n",
                                ast_getformatname(&frame->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));
                        /* return -1; */
@@ -1281,7 +1281,7 @@ static int mgcp_write(struct ast_channel *ast, struct ast_frame *frame)
 
 static int mgcp_fixup(struct ast_channel *oldchan, struct ast_channel *newchan)
 {
-       struct mgcp_subchannel *sub = newchan->tech_pvt;
+       struct mgcp_subchannel *sub = ast_channel_tech_pvt(newchan);
 
        ast_mutex_lock(&sub->lock);
        ast_log(LOG_NOTICE, "mgcp_fixup(%s, %s)\n", ast_channel_name(oldchan), ast_channel_name(newchan));
@@ -1297,7 +1297,7 @@ static int mgcp_fixup(struct ast_channel *oldchan, struct ast_channel *newchan)
 
 static int mgcp_senddigit_begin(struct ast_channel *ast, char digit)
 {
-       struct mgcp_subchannel *sub = ast->tech_pvt;
+       struct mgcp_subchannel *sub = ast_channel_tech_pvt(ast);
        struct mgcp_endpoint *p = sub->parent;
        int res = 0;
 
@@ -1318,7 +1318,7 @@ static int mgcp_senddigit_begin(struct ast_channel *ast, char digit)
 
 static int mgcp_senddigit_end(struct ast_channel *ast, char digit, unsigned int duration)
 {
-       struct mgcp_subchannel *sub = ast->tech_pvt;
+       struct mgcp_subchannel *sub = ast_channel_tech_pvt(ast);
        struct mgcp_endpoint *p = sub->parent;
        int res = 0;
        char tmp[4];
@@ -1437,7 +1437,7 @@ static char *control2str(int ind) {
 
 static int mgcp_indicate(struct ast_channel *ast, int ind, const void *data, size_t datalen)
 {
-       struct mgcp_subchannel *sub = ast->tech_pvt;
+       struct mgcp_subchannel *sub = ast_channel_tech_pvt(ast);
        int res = 0;
 
        ast_debug(3, "MGCP asked to indicate %d '%s' condition on channel %s\n",
@@ -1498,10 +1498,10 @@ static struct ast_channel *mgcp_new(struct mgcp_subchannel *sub, int state, cons
 
        tmp = ast_channel_alloc(1, state, i->cid_num, i->cid_name, linkedid, i->accountcode, i->exten, i->context, i->amaflags, "MGCP/%s@%s-%d", i->name, i->parent->name, sub->id);
        if (tmp) {
-               tmp->tech = &mgcp_tech;
-               ast_format_cap_copy(tmp->nativeformats, i->cap);
-               if (ast_format_cap_is_empty(tmp->nativeformats)) {
-                       ast_format_cap_copy(tmp->nativeformats, global_capability);
+               ast_channel_tech_set(tmp, &mgcp_tech);
+               ast_format_cap_copy(ast_channel_nativeformats(tmp), i->cap);
+               if (ast_format_cap_is_empty(ast_channel_nativeformats(tmp))) {
+                       ast_format_cap_copy(ast_channel_nativeformats(tmp), global_capability);
                }
                if (sub->rtp) {
                        ast_channel_set_fd(tmp, 0, ast_rtp_instance_fd(sub->rtp, 0));
@@ -1515,20 +1515,20 @@ static struct ast_channel *mgcp_new(struct mgcp_subchannel *sub, int state, cons
                        i->dsp = NULL;
                }
                if (state == AST_STATE_RING)
-                       tmp->rings = 1;
+                       ast_channel_rings_set(tmp, 1);
 
-               ast_best_codec(tmp->nativeformats, &tmpfmt);
+               ast_best_codec(ast_channel_nativeformats(tmp), &tmpfmt);
                ast_format_copy(&tmp->writeformat, &tmpfmt);
                ast_format_copy(&tmp->rawwriteformat, &tmpfmt);
                ast_format_copy(&tmp->readformat, &tmpfmt);
                ast_format_copy(&tmp->rawreadformat, &tmpfmt);
-               tmp->tech_pvt = sub;
+               ast_channel_tech_pvt_set(tmp, sub);
                if (!ast_strlen_zero(i->language))
                        ast_channel_language_set(tmp, i->language);
                if (!ast_strlen_zero(i->accountcode))
                        ast_channel_accountcode_set(tmp, i->accountcode);
                if (i->amaflags)
-                       tmp->amaflags = i->amaflags;
+                       ast_channel_amaflags_set(tmp, i->amaflags);
                sub->owner = tmp;
                ast_module_ref(ast_module_info->self);
                tmp->callgroup = i->callgroup;
@@ -1545,9 +1545,9 @@ static struct ast_channel *mgcp_new(struct mgcp_subchannel *sub, int state, cons
                }
 
                if (!i->adsi) {
-                       tmp->adsicpe = AST_ADSI_UNAVAILABLE;
+                       ast_channel_adsicpe_set(tmp, AST_ADSI_UNAVAILABLE);
                }
-               tmp->priority = 1;
+               ast_channel_priority_set(tmp, 1);
 
                /* Set channel variables for this call from configuration */
                for (v = i->chanvars ; v ; v = v->next) {
@@ -2624,7 +2624,7 @@ static void add_header_offhook(struct mgcp_subchannel *sub, struct mgcp_request
        }
 
        if (p && p->sub && p->sub->owner &&
-                       p->sub->owner->_state >= AST_STATE_RINGING &&
+                       ast_channel_state(p->sub->owner) >= AST_STATE_RINGING &&
                        (p->dtmfmode & (MGCP_DTMF_INBAND | MGCP_DTMF_HYBRID))) {
            add_header(resp, "R", "L/hu(N),L/hf(N)");
 
@@ -2829,7 +2829,7 @@ static void handle_response(struct mgcp_endpoint *p, struct mgcp_subchannel *sub
                if (result == 200 && (req->cmd == MGCP_CMD_CRCX || req->cmd == MGCP_CMD_MDCX)) {
                                if (sub) {
                                        transmit_response(sub, "000", resp, "OK");
-                                       if (sub->owner && sub->owner->_state == AST_STATE_RINGING) {
+                                       if (sub->owner && ast_channel_state(sub->owner) == AST_STATE_RINGING) {
                                                ast_queue_control(sub->owner, AST_CONTROL_RINGING);
                                        }
                                }
@@ -2963,7 +2963,7 @@ static void start_rtp(struct mgcp_subchannel *sub)
 static void *mgcp_ss(void *data)
 {
        struct ast_channel *chan = data;
-       struct mgcp_subchannel *sub = chan->tech_pvt;
+       struct mgcp_subchannel *sub = ast_channel_tech_pvt(chan);
        struct mgcp_endpoint *p = sub->parent;
        /* char exten[AST_MAX_EXTENSION] = ""; */
        int len = 0;
@@ -3229,7 +3229,7 @@ static int attempt_transfer(struct mgcp_endpoint *p)
                   stop if now if appropriate */
                if (ast_bridged_channel(p->sub->next->owner))
                        ast_queue_control(p->sub->next->owner, AST_CONTROL_UNHOLD);
-               if (p->sub->owner->_state == AST_STATE_RINGING) {
+               if (ast_channel_state(p->sub->owner) == AST_STATE_RINGING) {
                        ast_indicate(ast_bridged_channel(p->sub->next->owner), AST_CONTROL_RINGING);
                }
                if (ast_channel_masquerade(p->sub->next->owner, ast_bridged_channel(p->sub->owner))) {
@@ -3240,7 +3240,7 @@ static int attempt_transfer(struct mgcp_endpoint *p)
                /* Orphan the channel */
                unalloc_sub(p->sub->next);
        } else if (ast_bridged_channel(p->sub->next->owner)) {
-               if (p->sub->owner->_state == AST_STATE_RINGING) {
+               if (ast_channel_state(p->sub->owner) == AST_STATE_RINGING) {
                        ast_indicate(ast_bridged_channel(p->sub->next->owner), AST_CONTROL_RINGING);
                }
                ast_queue_control(p->sub->next->owner, AST_CONTROL_UNHOLD);
@@ -3439,7 +3439,7 @@ static int handle_request(struct mgcp_subchannel *sub, struct mgcp_request *req,
                                return -1;
                        }
                        /* do not let * conference two down channels */
-                       if (sub->owner && sub->owner->_state == AST_STATE_DOWN && !sub->next->owner)
+                       if (sub->owner && ast_channel_state(sub->owner) == AST_STATE_DOWN && !sub->next->owner)
                                return -1;
 
                        if (p->callwaiting || p->transfer || p->threewaycalling) {
@@ -3563,7 +3563,7 @@ static int handle_request(struct mgcp_subchannel *sub, struct mgcp_request *req,
                                (((ev[0] >= '0') && (ev[0] <= '9')) ||
                                 ((ev[0] >= 'A') && (ev[0] <= 'D')) ||
                                  (ev[0] == '*') || (ev[0] == '#'))) {
-                       if (sub && sub->owner && (sub->owner->_state >=  AST_STATE_UP)) {
+                       if (sub && sub->owner && (ast_channel_state(sub->owner) >=  AST_STATE_UP)) {
                                f.frametype = AST_FRAME_DTMF;
                                f.subclass.integer = ev[0];
                                f.src = "mgcp";
@@ -4418,7 +4418,7 @@ static enum ast_rtp_glue_result mgcp_get_rtp_peer(struct ast_channel *chan, stru
 {
        struct mgcp_subchannel *sub = NULL;
 
-       if (!(sub = chan->tech_pvt) || !(sub->rtp))
+       if (!(sub = ast_channel_tech_pvt(chan)) || !(sub->rtp))
                return AST_RTP_GLUE_RESULT_FORBID;
 
        *instance = sub->rtp ? ao2_ref(sub->rtp, +1), sub->rtp : NULL;
@@ -4433,7 +4433,7 @@ static int mgcp_set_rtp_peer(struct ast_channel *chan, struct ast_rtp_instance *
 {
        /* XXX Is there such thing as video support with MGCP? XXX */
        struct mgcp_subchannel *sub;
-       sub = chan->tech_pvt;
+       sub = ast_channel_tech_pvt(chan);
        if (sub && !sub->alreadygone) {
                transmit_modify_with_sdp(sub, rtp, cap);
                return 0;
@@ -4443,7 +4443,7 @@ static int mgcp_set_rtp_peer(struct ast_channel *chan, struct ast_rtp_instance *
 
 static void mgcp_get_codec(struct ast_channel *chan, struct ast_format_cap *result)
 {
-       struct mgcp_subchannel *sub = chan->tech_pvt;
+       struct mgcp_subchannel *sub = ast_channel_tech_pvt(chan);
        struct mgcp_endpoint *p = sub->parent;
        ast_format_cap_copy(result, p->cap);
 }
@@ -4458,11 +4458,11 @@ static struct ast_rtp_glue mgcp_rtp_glue = {
 
 static int acf_channel_read(struct ast_channel *chan, const char *funcname, char *args, char *buf, size_t buflen)
 {
-       struct mgcp_subchannel *sub = chan->tech_pvt;
+       struct mgcp_subchannel *sub = ast_channel_tech_pvt(chan);
        int res = 0;
 
        /* Sanity check */
-       if (!chan || chan->tech != &mgcp_tech) {
+       if (!chan || ast_channel_tech(chan) != &mgcp_tech) {
                ast_log(LOG_ERROR, "This function requires a valid MGCP channel\n");
                return -1;
        }
index 7b3d448c2788617540e8b41053c34617bdb46915..535fee4cb42c7bc23f7f73be8bcd8be2d50458a5 100644 (file)
@@ -6506,9 +6506,9 @@ static int misdn_call(struct ast_channel *ast, const char *dest, int timeout)
                return -1;
        }
 
-       if (((ast->_state != AST_STATE_DOWN) && (ast->_state != AST_STATE_RESERVED)) || !dest) {
+       if (((ast_channel_state(ast) != AST_STATE_DOWN) && (ast_channel_state(ast) != AST_STATE_RESERVED)) || !dest) {
                ast_log(LOG_WARNING, " --> ! misdn_call called on %s, neither down nor reserved (or dest==NULL)\n", ast_channel_name(ast));
-               ast->hangupcause = AST_CAUSE_NORMAL_TEMPORARY_FAILURE;
+               ast_channel_hangupcause_set(ast, AST_CAUSE_NORMAL_TEMPORARY_FAILURE);
                ast_setstate(ast, AST_STATE_DOWN);
                return -1;
        }
@@ -6516,7 +6516,7 @@ static int misdn_call(struct ast_channel *ast, const char *dest, int timeout)
        ch = MISDN_ASTERISK_TECH_PVT(ast);
        if (!ch) {
                ast_log(LOG_WARNING, " --> ! misdn_call called on %s, chan_list *ch==NULL\n", ast_channel_name(ast));
-               ast->hangupcause = AST_CAUSE_NORMAL_TEMPORARY_FAILURE;
+               ast_channel_hangupcause_set(ast, AST_CAUSE_NORMAL_TEMPORARY_FAILURE);
                ast_setstate(ast, AST_STATE_DOWN);
                return -1;
        }
@@ -6524,7 +6524,7 @@ static int misdn_call(struct ast_channel *ast, const char *dest, int timeout)
        newbc = ch->bc;
        if (!newbc) {
                ast_log(LOG_WARNING, " --> ! misdn_call called on %s, newbc==NULL\n", ast_channel_name(ast));
-               ast->hangupcause = AST_CAUSE_NORMAL_TEMPORARY_FAILURE;
+               ast_channel_hangupcause_set(ast, AST_CAUSE_NORMAL_TEMPORARY_FAILURE);
                ast_setstate(ast, AST_STATE_DOWN);
                return -1;
        }
@@ -6546,7 +6546,7 @@ static int misdn_call(struct ast_channel *ast, const char *dest, int timeout)
                if (!cc_record) {
                        AST_LIST_UNLOCK(&misdn_cc_records_db);
                        ast_log(LOG_WARNING, " --> ! misdn_call called on %s, cc_record==NULL\n", ast_channel_name(ast));
-                       ast->hangupcause = AST_CAUSE_NORMAL_TEMPORARY_FAILURE;
+                       ast_channel_hangupcause_set(ast, AST_CAUSE_NORMAL_TEMPORARY_FAILURE);
                        ast_setstate(ast, AST_STATE_DOWN);
                        return -1;
                }
@@ -6633,9 +6633,9 @@ static int misdn_call(struct ast_channel *ast, const char *dest, int timeout)
                }
                debug_numtype(port, newbc->caller.number_type, "LTON");
 
-               newbc->capability = ast->transfercapability;
+               newbc->capability = ast_channel_transfercapability(ast);
                pbx_builtin_setvar_helper(ast, "TRANSFERCAPABILITY", ast_transfercapability2str(newbc->capability));
-               if (ast->transfercapability == INFO_CAPABILITY_DIGITAL_UNRESTRICTED) {
+               if (ast_channel_transfercapability(ast) == INFO_CAPABILITY_DIGITAL_UNRESTRICTED) {
                        chan_misdn_log(2, port, " --> * Call with flag Digital\n");
                }
 
@@ -6714,7 +6714,7 @@ static int misdn_call(struct ast_channel *ast, const char *dest, int timeout)
 
                snprintf(tmp, sizeof(tmp), "%d", exceed);
                pbx_builtin_setvar_helper(ast, "MAX_OVERFLOW", tmp);
-               ast->hangupcause = AST_CAUSE_NORMAL_TEMPORARY_FAILURE;
+               ast_channel_hangupcause_set(ast, AST_CAUSE_NORMAL_TEMPORARY_FAILURE);
                ast_setstate(ast, AST_STATE_DOWN);
                return -1;
        }
@@ -6732,7 +6732,7 @@ static int misdn_call(struct ast_channel *ast, const char *dest, int timeout)
        if (r == -ENOCHAN) {
                chan_misdn_log(0, port, " --> * Theres no Channel at the moment .. !\n");
                chan_misdn_log(1, port, " --> * SEND: State Down pid:%d\n", newbc ? newbc->pid : -1);
-               ast->hangupcause = AST_CAUSE_NORMAL_CIRCUIT_CONGESTION;
+               ast_channel_hangupcause_set(ast, AST_CAUSE_NORMAL_CIRCUIT_CONGESTION);
                ast_setstate(ast, AST_STATE_DOWN);
                return -1;
        }
@@ -6740,7 +6740,7 @@ static int misdn_call(struct ast_channel *ast, const char *dest, int timeout)
        chan_misdn_log(2, port, " --> * SEND: State Dialing pid:%d\n", newbc ? newbc->pid : 1);
 
        ast_setstate(ast, AST_STATE_DIALING);
-       ast->hangupcause = AST_CAUSE_NORMAL_CLEARING;
+       ast_channel_hangupcause_set(ast, AST_CAUSE_NORMAL_CLEARING);
 
        if (newbc->nt) {
                stop_bc_tones(ch);
@@ -7084,7 +7084,7 @@ static int misdn_hangup(struct ast_channel *ast)
                }
        }
 
-       if (ast->_state == AST_STATE_RESERVED || p->state == MISDN_NOTHING) {
+       if (ast_channel_state(ast) == AST_STATE_RESERVED || p->state == MISDN_NOTHING) {
                /* between request and call */
                ast_debug(1, "State Reserved (or nothing) => chanIsAvail\n");
                release_chan_early(p);
@@ -7113,7 +7113,7 @@ static int misdn_hangup(struct ast_channel *ast)
                stop_bc_tones(p);
        }
 
-       bc->out_cause = ast->hangupcause ? ast->hangupcause : AST_CAUSE_NORMAL_CLEARING;
+       bc->out_cause = ast_channel_hangupcause(ast) ? ast_channel_hangupcause(ast) : AST_CAUSE_NORMAL_CLEARING;
 
        /* Channel lock is already held when we are called. */
        //ast_channel_lock(ast);
@@ -7642,7 +7642,7 @@ static int dialtone_indicate(struct chan_list *cl)
 
        chan_misdn_log(3, cl->bc->port, " --> Dial\n");
 
-       cl->ts = ast_get_indication_tone(ast->zone, "dial");
+       cl->ts = ast_get_indication_tone(ast_channel_zone(ast), "dial");
 
        if (cl->ts) {
                cl->notxtone = 0;
@@ -8135,7 +8135,7 @@ static struct ast_channel *misdn_new(struct chan_list *chlist, int state,  char
                chan_misdn_log(2, 0, " --> * NEW CHANNEL dialed:%s caller:%s\n", exten, callerid);
 
                ast_best_codec(cap, &tmpfmt);
-               ast_format_cap_add(tmp->nativeformats, &prefformat);
+               ast_format_cap_add(ast_channel_nativeformats(tmp), &prefformat);
                ast_format_copy(&tmp->writeformat, &tmpfmt);
                ast_format_copy(&tmp->rawwriteformat, &tmpfmt);
                ast_format_copy(&tmp->readformat, &tmpfmt);
@@ -8147,9 +8147,9 @@ static struct ast_channel *misdn_new(struct chan_list *chlist, int state,  char
                chlist->ast = tmp;
 
                misdn_cfg_get(0, MISDN_GEN_BRIDGING, &bridging, sizeof(bridging));
-               tmp->tech = bridging ? &misdn_tech : &misdn_tech_wo_bridge;
+               ast_channel_tech_set(tmp, bridging ? &misdn_tech : &misdn_tech_wo_bridge);
 
-               tmp->priority = 1;
+               ast_channel_priority_set(tmp, 1);
 
                if (exten) {
                        ast_channel_exten_set(tmp, exten);
@@ -8169,7 +8169,7 @@ static struct ast_channel *misdn_new(struct chan_list *chlist, int state,  char
                }
                ast_channel_set_fd(tmp, 0, chlist->pipe[0]);
 
-               tmp->rings = (state == AST_STATE_RING) ? 1 : 0;
+               ast_channel_rings_set(tmp, (state == AST_STATE_RING) ? 1 : 0);
 
                ast_jb_configure(tmp, misdn_get_global_jbconf());
        } else {
@@ -8454,7 +8454,7 @@ static void release_chan(struct chan_list *ch, struct misdn_bchannel *bc)
                        S_COR(ast->caller.id.name.valid, ast->caller.id.name.str, ""),
                        S_COR(ast->caller.id.number.valid, ast->caller.id.number.str, ""));
 
-               if (ast->_state != AST_STATE_RESERVED) {
+               if (ast_channel_state(ast) != AST_STATE_RESERVED) {
                        chan_misdn_log(3, bc->port, " --> Setting AST State to down\n");
                        ast_setstate(ast, AST_STATE_DOWN);
                }
@@ -8511,7 +8511,7 @@ static void release_chan_early(struct chan_list *ch)
                ast_ch = MISDN_ASTERISK_TECH_PVT(ast);
                MISDN_ASTERISK_TECH_PVT(ast) = NULL;
 
-               if (ast->_state != AST_STATE_RESERVED) {
+               if (ast_channel_state(ast) != AST_STATE_RESERVED) {
                        ast_setstate(ast, AST_STATE_DOWN);
                }
                ast_channel_unlock(ast);
@@ -8695,7 +8695,7 @@ static int send_cause2ast(struct ast_channel *ast, struct misdn_bchannel *bc, st
                return 0;
        }
 
-       ast->hangupcause = bc->cause;
+       ast_channel_hangupcause_set(ast, bc->cause);
 
        can_hangup = -1;
        switch (bc->cause) {
@@ -8923,7 +8923,7 @@ static void misdn_cc_pbx_notify(long record_id, const struct misdn_cc_notify *no
                ast_log(LOG_ERROR, "Unable to allocate channel!\n");
                return;
        }
-       chan->priority = notify->priority;
+       ast_channel_priority_set(chan, notify->priority);
        ast_free(chan->dialed.number.str);
        chan->dialed.number.str = ast_strdup(notify->exten);
 
@@ -10169,7 +10169,7 @@ cb_events(enum event_e event, struct misdn_bchannel *bc, void *user_data)
 
                export_ch(chan, bc, ch);
 
-               ch->ast->rings = 1;
+               ast_channel_rings_set(ch->ast, 1);
                ast_setstate(ch->ast, AST_STATE_RINGING);
 
                /* Update asterisk channel caller information */
@@ -10204,7 +10204,7 @@ cb_events(enum event_e event, struct misdn_bchannel *bc, void *user_data)
                }
 
                pbx_builtin_setvar_helper(chan, "TRANSFERCAPABILITY", ast_transfercapability2str(bc->capability));
-               chan->transfercapability = bc->capability;
+               ast_channel_transfercapability_set(chan, bc->capability);
 
                switch (bc->capability) {
                case INFO_CAPABILITY_DIGITAL_UNRESTRICTED:
@@ -10585,7 +10585,7 @@ cb_events(enum event_e event, struct misdn_bchannel *bc, void *user_data)
                                start_bc_tones(ch);
 
                                if (ch->ast) {
-                                       ch->ast->hangupcause = bc->cause;
+                                       ast_channel_hangupcause_set(ch->ast, bc->cause);
                                        if (bc->cause == AST_CAUSE_USER_BUSY) {
                                                ast_queue_control(ch->ast, AST_CONTROL_BUSY);
                                        }
@@ -10724,13 +10724,13 @@ cb_events(enum event_e event, struct misdn_bchannel *bc, void *user_data)
                        break;
                }
 
-               if (!ast->generator) {
+               if (!ast_channel_generator(ast)) {
                        break;
                }
 
-               tmp = ast->generatordata;
-               ast->generatordata = NULL;
-               generate = ast->generator->generate;
+               tmp = ast_channel_generatordata(ast);
+               ast_channel_generatordata_set(ast, NULL);
+               generate = ast_channel_generator(ast)->generate;
 
                if (tone_len < 0 || tone_len > 512) {
                        ast_log(LOG_NOTICE, "TONE_GEN: len was %d, set to 128\n", tone_len);
@@ -10738,7 +10738,7 @@ cb_events(enum event_e event, struct misdn_bchannel *bc, void *user_data)
                }
 
                res = generate(ast, tmp, tone_len, tone_len);
-               ast->generatordata = tmp;
+               ast_channel_generatordata_set(ast, tmp);
 
                if (res) {
                        ast_log(LOG_WARNING, "Auto-deactivating generator\n");
@@ -10885,7 +10885,7 @@ cb_events(enum event_e event, struct misdn_bchannel *bc, void *user_data)
 
                bridged = ast_bridged_channel(ch->ast);
                if (bridged) {
-                       chan_misdn_log(2, bc->port, "Bridge Partner is of type: %s\n", bridged->tech->type);
+                       chan_misdn_log(2, bc->port, "Bridge Partner is of type: %s\n", ast_channel_tech(bridged)->type);
                        ch->l3id = bc->l3_id;
 
                        /* forget the channel now */
@@ -12028,7 +12028,7 @@ static int misdn_command_exec(struct ast_channel *chan, const char *data)
                if (strcasecmp(misdn_commands[index].name, subcommand.name) == 0) {
                        strcpy(subcommand.name, misdn_commands[index].name);
                        if (misdn_commands[index].misdn_only
-                               && strcasecmp(chan->tech->type, misdn_type) != 0) {
+                               && strcasecmp(ast_channel_tech(chan)->type, misdn_type) != 0) {
                                ast_log(LOG_WARNING,
                                        "%s(%s) only makes sense with %s channels!\n",
                                        misdn_command_name, subcommand.name, misdn_type);
@@ -12055,9 +12055,9 @@ static int misdn_facility_exec(struct ast_channel *chan, const char *data)
                AST_APP_ARG(arg)[99];
        );
 
-       chan_misdn_log(0, 0, "TYPE: %s\n", chan->tech->type);
+       chan_misdn_log(0, 0, "TYPE: %s\n", ast_channel_tech(chan)->type);
 
-       if (strcasecmp(chan->tech->type, misdn_type)) {
+       if (strcasecmp(ast_channel_tech(chan)->type, misdn_type)) {
                ast_log(LOG_WARNING, "misdn_facility only makes sense with %s channels!\n", misdn_type);
                return -1;
        }
@@ -12252,7 +12252,7 @@ static int misdn_set_opt_exec(struct ast_channel *chan, const char *data)
        int txgain = 0;
        int change_jitter = 0;
 
-       if (strcasecmp(chan->tech->type, misdn_type)) {
+       if (strcasecmp(ast_channel_tech(chan)->type, misdn_type)) {
                ast_log(LOG_WARNING, "misdn_set_opt makes sense only with %s channels!\n", misdn_type);
                return -1;
        }
index c635b105619c22668a53a04103d4c5cbe00a94c6..6ebacaa840019baebd7f91a6c693916a01fdc6f0 100644 (file)
@@ -82,7 +82,7 @@ static struct ast_frame  *multicast_rtp_read(struct ast_channel *ast)
 /*! \brief Function called when we should write a frame to the channel */
 static int multicast_rtp_write(struct ast_channel *ast, struct ast_frame *f)
 {
-       struct ast_rtp_instance *instance = ast->tech_pvt;
+       struct ast_rtp_instance *instance = ast_channel_tech_pvt(ast);
 
        return ast_rtp_instance_write(instance, f);
 }
@@ -90,7 +90,7 @@ static int multicast_rtp_write(struct ast_channel *ast, struct ast_frame *f)
 /*! \brief Function called when we should actually call the destination */
 static int multicast_rtp_call(struct ast_channel *ast, const char *dest, int timeout)
 {
-       struct ast_rtp_instance *instance = ast->tech_pvt;
+       struct ast_rtp_instance *instance = ast_channel_tech_pvt(ast);
 
        ast_queue_control(ast, AST_CONTROL_ANSWER);
 
@@ -100,11 +100,11 @@ static int multicast_rtp_call(struct ast_channel *ast, const char *dest, int tim
 /*! \brief Function called when we should hang the channel up */
 static int multicast_rtp_hangup(struct ast_channel *ast)
 {
-       struct ast_rtp_instance *instance = ast->tech_pvt;
+       struct ast_rtp_instance *instance = ast_channel_tech_pvt(ast);
 
        ast_rtp_instance_destroy(instance);
 
-       ast->tech_pvt = NULL;
+       ast_channel_tech_pvt_set(ast, NULL);
 
        return 0;
 }
@@ -156,15 +156,15 @@ static struct ast_channel *multicast_rtp_request(const char *type, struct ast_fo
 
        ast_rtp_instance_set_remote_address(instance, &destination_address);
 
-       chan->tech = &multicast_rtp_tech;
+       ast_channel_tech_set(chan, &multicast_rtp_tech);
 
-       ast_format_cap_add(chan->nativeformats, &fmt);
+       ast_format_cap_add(ast_channel_nativeformats(chan), &fmt);
        ast_format_copy(&chan->writeformat, &fmt);
        ast_format_copy(&chan->rawwriteformat, &fmt);
        ast_format_copy(&chan->readformat, &fmt);
        ast_format_copy(&chan->rawreadformat, &fmt);
 
-       chan->tech_pvt = instance;
+       ast_channel_tech_pvt_set(chan, instance);
 
        return chan;
 
index 4bb88e6618da8b66d5cea6d9cfa6003a1484b1f1..882e165f8f91cfa9eb2f9e717e3eaa122ed99488 100644 (file)
@@ -87,9 +87,9 @@ static int nbs_call(struct ast_channel *ast, const char *dest, int timeout)
 {
        struct nbs_pvt *p;
 
-       p = ast->tech_pvt;
+       p = ast_channel_tech_pvt(ast);
 
-       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, "nbs_call called on %s, neither down nor reserved\n", ast_channel_name(ast));
                return -1;
        }
@@ -164,21 +164,21 @@ static struct nbs_pvt *nbs_alloc(const char *data)
 static int nbs_hangup(struct ast_channel *ast)
 {
        struct nbs_pvt *p;
-       p = ast->tech_pvt;
+       p = ast_channel_tech_pvt(ast);
        ast_debug(1, "nbs_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;
        }
        nbs_destroy(p);
-       ast->tech_pvt = NULL;
+       ast_channel_tech_pvt_set(ast, NULL);
        ast_setstate(ast, AST_STATE_DOWN);
        return 0;
 }
 
 static struct ast_frame  *nbs_xread(struct ast_channel *ast)
 {
-       struct nbs_pvt *p = ast->tech_pvt;
+       struct nbs_pvt *p = ast_channel_tech_pvt(ast);
        
 
        /* Some nice norms */
@@ -198,7 +198,7 @@ static struct ast_frame  *nbs_xread(struct ast_channel *ast)
 
 static int nbs_xwrite(struct ast_channel *ast, struct ast_frame *frame)
 {
-       struct nbs_pvt *p = ast->tech_pvt;
+       struct nbs_pvt *p = ast_channel_tech_pvt(ast);
        /* Write a frame of (presumably voice) data */
        if (frame->frametype != AST_FRAME_VOICE) {
                if (frame->frametype != AST_FRAME_IMAGE)
@@ -209,7 +209,7 @@ static int nbs_xwrite(struct ast_channel *ast, struct ast_frame *frame)
                ast_log(LOG_WARNING, "Cannot handle frames in %s format\n", ast_getformatname(&frame->subclass.format));
                return 0;
        }
-       if (ast->_state != AST_STATE_UP) {
+       if (ast_channel_state(ast) != AST_STATE_UP) {
                /* Don't try tos end audio on-hook */
                return 0;
        }
@@ -223,17 +223,17 @@ static struct ast_channel *nbs_new(struct nbs_pvt *i, int state, const char *lin
        struct ast_channel *tmp;
        tmp = ast_channel_alloc(1, state, 0, 0, "", "s", context, linkedid, 0, "NBS/%s", i->stream);
        if (tmp) {
-               tmp->tech = &nbs_tech;
+               ast_channel_tech_set(tmp, &nbs_tech);
                ast_channel_set_fd(tmp, 0, nbs_fd(i->nbs));
 
-               ast_format_cap_add(tmp->nativeformats, &prefformat);
+               ast_format_cap_add(ast_channel_nativeformats(tmp), &prefformat);
                ast_format_copy(&tmp->rawreadformat, &prefformat);
                ast_format_copy(&tmp->rawwriteformat, &prefformat);
                ast_format_copy(&tmp->writeformat, &prefformat);
                ast_format_copy(&tmp->readformat, &prefformat);
                if (state == AST_STATE_RING)
-                       tmp->rings = 1;
-               tmp->tech_pvt = i;
+                       ast_channel_rings_set(tmp, 1);
+               ast_channel_tech_pvt_set(tmp, i);
                ast_channel_context_set(tmp, context);
                ast_channel_exten_set(tmp, "s");
                ast_channel_language_set(tmp, "");
index dc35329313f3cb5eac413e464170d4fb467d81e5..2d7cda82ad63b446ae430f197de5637511e0e82c 100644 (file)
@@ -308,7 +308,7 @@ static char *oss_active;     /*!< the active device */
 /*! \brief return the pointer to the video descriptor */
 struct video_desc *get_video_desc(struct ast_channel *c)
 {
-       struct chan_oss_pvt *o = c ? c->tech_pvt : find_desc(oss_active);
+       struct chan_oss_pvt *o = c ? ast_channel_tech_pvt(c) : find_desc(oss_active);
        return o ? o->env : NULL;
 }
 static struct chan_oss_pvt oss_default = {
@@ -592,7 +592,7 @@ static int oss_text(struct ast_channel *c, const char *text)
  */
 static int oss_call(struct ast_channel *c, const char *dest, int timeout)
 {
-       struct chan_oss_pvt *o = c->tech_pvt;
+       struct chan_oss_pvt *o = ast_channel_tech_pvt(c);
        struct ast_frame f = { AST_FRAME_CONTROL, };
        AST_DECLARE_APP_ARGS(args,
                AST_APP_ARG(name);
@@ -634,7 +634,7 @@ static int oss_call(struct ast_channel *c, const char *dest, int timeout)
  */
 static int oss_answer(struct ast_channel *c)
 {
-       struct chan_oss_pvt *o = c->tech_pvt;
+       struct chan_oss_pvt *o = ast_channel_tech_pvt(c);
        ast_verbose(" << Console call has been answered >> \n");
        ast_setstate(c, AST_STATE_UP);
        o->hookstate = 1;
@@ -643,9 +643,9 @@ static int oss_answer(struct ast_channel *c)
 
 static int oss_hangup(struct ast_channel *c)
 {
-       struct chan_oss_pvt *o = c->tech_pvt;
+       struct chan_oss_pvt *o = ast_channel_tech_pvt(c);
 
-       c->tech_pvt = NULL;
+       ast_channel_tech_pvt_set(c, NULL);
        o->owner = NULL;
        ast_verbose(" << Hangup on console >> \n");
        console_video_uninit(o->env);
@@ -664,7 +664,7 @@ static int oss_hangup(struct ast_channel *c)
 static int oss_write(struct ast_channel *c, struct ast_frame *f)
 {
        int src;
-       struct chan_oss_pvt *o = c->tech_pvt;
+       struct chan_oss_pvt *o = ast_channel_tech_pvt(c);
 
        /*
         * we could receive a block which is not a multiple of our
@@ -695,7 +695,7 @@ static int oss_write(struct ast_channel *c, struct ast_frame *f)
 static struct ast_frame *oss_read(struct ast_channel *c)
 {
        int res;
-       struct chan_oss_pvt *o = c->tech_pvt;
+       struct chan_oss_pvt *o = ast_channel_tech_pvt(c);
        struct ast_frame *f = &o->read_f;
 
        /* XXX can be simplified returning &ast_null_frame */
@@ -716,7 +716,7 @@ static struct ast_frame *oss_read(struct ast_channel *c)
                return f;
 
        o->readpos = AST_FRIENDLY_OFFSET;       /* reset read pointer for next frame */
-       if (c->_state != AST_STATE_UP)  /* drop data if frame is not up */
+       if (ast_channel_state(c) != AST_STATE_UP)       /* drop data if frame is not up */
                return f;
        /* ok we can build and deliver the frame to the caller */
        f->frametype = AST_FRAME_VOICE;
@@ -743,14 +743,14 @@ static struct ast_frame *oss_read(struct ast_channel *c)
 
 static int oss_fixup(struct ast_channel *oldchan, struct ast_channel *newchan)
 {
-       struct chan_oss_pvt *o = newchan->tech_pvt;
+       struct chan_oss_pvt *o = ast_channel_tech_pvt(newchan);
        o->owner = newchan;
        return 0;
 }
 
 static int oss_indicate(struct ast_channel *c, int cond, const void *data, size_t datalen)
 {
-       struct chan_oss_pvt *o = c->tech_pvt;
+       struct chan_oss_pvt *o = ast_channel_tech_pvt(c);
        int res = 0;
 
        switch (cond) {
@@ -792,20 +792,20 @@ static struct ast_channel *oss_new(struct chan_oss_pvt *o, char *ext, char *ctx,
        c = ast_channel_alloc(1, state, o->cid_num, o->cid_name, "", ext, ctx, linkedid, 0, "Console/%s", o->device + 5);
        if (c == NULL)
                return NULL;
-       c->tech = &oss_tech;
+       ast_channel_tech_set(c, &oss_tech);
        if (o->sounddev < 0)
                setformat(o, O_RDWR);
        ast_channel_set_fd(c, 0, o->sounddev); /* -1 if device closed, override later */
 
        ast_format_set(&c->readformat, AST_FORMAT_SLINEAR, 0);
        ast_format_set(&c->writeformat, AST_FORMAT_SLINEAR, 0);
-       ast_format_cap_add(c->nativeformats, &c->readformat);
+       ast_format_cap_add(ast_channel_nativeformats(c), &c->readformat);
 
        /* if the console makes the call, add video to the offer */
        /* if (state == AST_STATE_RINGING) TODO XXX CONSOLE VIDEO IS DISABLED UNTIL IT GETS A MAINTAINER
                c->nativeformats |= console_video_formats; */
 
-       c->tech_pvt = o;
+       ast_channel_tech_pvt_set(c, o);
 
        if (!ast_strlen_zero(o->language))
                ast_channel_language_set(c, o->language);
index 55f43f39ab5f3a75e1fea8a3440a10402ff9b5b9..6f8f5a4bc24b79f5df31c71dd7401f41ce48f26e 100644 (file)
@@ -202,7 +202,7 @@ static struct ast_channel_tech *cur_tech;
 
 static int phone_indicate(struct ast_channel *chan, int condition, const void *data, size_t datalen)
 {
-       struct phone_pvt *p = chan->tech_pvt;
+       struct phone_pvt *p = ast_channel_tech_pvt(chan);
        int res=-1;
        ast_debug(1, "Requested indication %d on channel %s\n", condition, ast_channel_name(chan));
        switch(condition) {
@@ -230,7 +230,7 @@ static int phone_indicate(struct ast_channel *chan, int condition, const void *d
 
 static int phone_fixup(struct ast_channel *old, struct ast_channel *new)
 {
-       struct phone_pvt *pvt = old->tech_pvt;
+       struct phone_pvt *pvt = ast_channel_tech_pvt(old);
        if (pvt && pvt->owner == old)
                pvt->owner = new;
        return 0;
@@ -246,7 +246,7 @@ static int phone_digit_end(struct ast_channel *ast, char digit, unsigned int dur
 {
        struct phone_pvt *p;
        int outdigit;
-       p = ast->tech_pvt;
+       p = ast_channel_tech_pvt(ast);
        ast_debug(1, "Dialed %c\n", digit);
        switch(digit) {
        case '0':
@@ -312,9 +312,9 @@ static int phone_call(struct ast_channel *ast, const char *dest, int timeout)
                ast_copy_string(cid.number, ast->connected.id.number.str, sizeof(cid.number));
        }
 
-       p = ast->tech_pvt;
+       p = ast_channel_tech_pvt(ast);
 
-       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, "phone_call called on %s, neither down nor reserved\n", ast_channel_name(ast));
                return -1;
        }
@@ -342,9 +342,9 @@ static int phone_call(struct ast_channel *ast, const char *dest, int timeout)
 static int phone_hangup(struct ast_channel *ast)
 {
        struct phone_pvt *p;
-       p = ast->tech_pvt;
+       p = ast_channel_tech_pvt(ast);
        ast_debug(1, "phone_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;
        }
@@ -377,10 +377,10 @@ static int phone_hangup(struct ast_channel *ast)
        p->obuflen = 0;
        p->dialtone = 0;
        memset(p->ext, 0, sizeof(p->ext));
-       ((struct phone_pvt *)(ast->tech_pvt))->owner = NULL;
+       ((struct phone_pvt *)(ast_channel_tech_pvt(ast)))->owner = NULL;
        ast_module_unref(ast_module_info->self);
        ast_verb(3, "Hungup '%s'\n", ast_channel_name(ast));
-       ast->tech_pvt = NULL;
+       ast_channel_tech_pvt_set(ast, NULL);
        ast_setstate(ast, AST_STATE_DOWN);
        restart_monitor();
        return 0;
@@ -389,7 +389,7 @@ static int phone_hangup(struct ast_channel *ast)
 static int phone_setup(struct ast_channel *ast)
 {
        struct phone_pvt *p;
-       p = ast->tech_pvt;
+       p = ast_channel_tech_pvt(ast);
        ioctl(p->fd, PHONE_CPT_STOP);
        /* Nothing to answering really, just start recording */
        if (ast->rawreadformat.id == AST_FORMAT_G729A) {
@@ -456,7 +456,7 @@ static int phone_setup(struct ast_channel *ast)
 static int phone_answer(struct ast_channel *ast)
 {
        struct phone_pvt *p;
-       p = ast->tech_pvt;
+       p = ast_channel_tech_pvt(ast);
        /* In case it's a LineJack, take it off hook */
        if (p->mode == MODE_FXO) {
                if (ioctl(p->fd, PHONE_PSTN_SET_STATE, PSTN_OFF_HOOK))
@@ -466,7 +466,7 @@ static int phone_answer(struct ast_channel *ast)
        }
        phone_setup(ast);
        ast_debug(1, "phone_answer(%s)\n", ast_channel_name(ast));
-       ast->rings = 0;
+       ast_channel_rings_set(ast, 0);
        ast_setstate(ast, AST_STATE_UP);
        return 0;
 }
@@ -489,7 +489,7 @@ static struct ast_frame  *phone_exception(struct ast_channel *ast)
 {
        int res;
        union telephony_exception phonee;
-       struct phone_pvt *p = ast->tech_pvt;
+       struct phone_pvt *p = ast_channel_tech_pvt(ast);
        char digit;
 
        /* Some nice norms */
@@ -519,7 +519,7 @@ static struct ast_frame  *phone_exception(struct ast_channel *ast)
                if (!res && (p->mode != MODE_FXO))
                        return NULL;
                else {
-                       if (ast->_state == AST_STATE_RINGING) {
+                       if (ast_channel_state(ast) == AST_STATE_RINGING) {
                                /* They've picked up the phone */
                                p->fr.frametype = AST_FRAME_CONTROL;
                                p->fr.subclass.integer = AST_CONTROL_ANSWER;
@@ -527,7 +527,7 @@ static struct ast_frame  *phone_exception(struct ast_channel *ast)
                                ast_setstate(ast, AST_STATE_UP);
                                return &p->fr;
                        }  else 
-                               ast_log(LOG_WARNING, "Got off hook in weird state %d\n", ast->_state);
+                               ast_log(LOG_WARNING, "Got off hook in weird state %d\n", ast_channel_state(ast));
                }
        }
 #if 1
@@ -548,7 +548,7 @@ static struct ast_frame  *phone_exception(struct ast_channel *ast)
 static struct ast_frame  *phone_read(struct ast_channel *ast)
 {
        int res;
-       struct phone_pvt *p = ast->tech_pvt;
+       struct phone_pvt *p = ast_channel_tech_pvt(ast);
        
 
        /* Some nice norms */
@@ -639,13 +639,13 @@ static int phone_write_buf(struct phone_pvt *p, const char *buf, int len, int fr
 static int phone_send_text(struct ast_channel *ast, const char *text)
 {
     int length = strlen(text);
-    return phone_write_buf(ast->tech_pvt, text, length, length, 0) == 
+    return phone_write_buf(ast_channel_tech_pvt(ast), text, length, length, 0) == 
            length ? 0 : -1;
 }
 
 static int phone_write(struct ast_channel *ast, struct ast_frame *frame)
 {
-       struct phone_pvt *p = ast->tech_pvt;
+       struct phone_pvt *p = ast_channel_tech_pvt(ast);
        int res;
        int maxfr=0;
        char *pos;
@@ -674,7 +674,7 @@ static int phone_write(struct ast_channel *ast, struct ast_frame *frame)
                phone_setup(ast);
        }
 #else
-       if (ast->_state != AST_STATE_UP) {
+       if (ast_channel_state(ast) != AST_STATE_UP) {
                /* Don't try tos end audio on-hook */
                return 0;
        }
@@ -852,28 +852,28 @@ static struct ast_channel *phone_new(struct phone_pvt *i, int state, char *cntx,
        struct ast_format tmpfmt;
        tmp = ast_channel_alloc(1, state, i->cid_num, i->cid_name, "", i->ext, i->context, linkedid, 0, "Phone/%s", i->dev + 5);
        if (tmp) {
-               tmp->tech = cur_tech;
+               ast_channel_tech_set(tmp, cur_tech);
                ast_channel_set_fd(tmp, 0, i->fd);
                /* XXX Switching formats silently causes kernel panics XXX */
                if (i->mode == MODE_FXS &&
                    ioctl(i->fd, PHONE_QUERY_CODEC, &queried_codec) == 0) {
                        if (queried_codec.type == LINEAR16) {
-                               ast_format_cap_add(tmp->nativeformats, ast_format_set(&tmpfmt, AST_FORMAT_SLINEAR, 0));
+                               ast_format_cap_add(ast_channel_nativeformats(tmp), ast_format_set(&tmpfmt, AST_FORMAT_SLINEAR, 0));
                                ast_format_copy(&tmp->rawreadformat, &tmpfmt);
                                ast_format_copy(&tmp->rawwriteformat, &tmpfmt);
                        } else {
                                ast_format_cap_remove(prefcap, ast_format_set(&tmpfmt, AST_FORMAT_SLINEAR, 0));
                        }
                } else {
-                       ast_format_cap_copy(tmp->nativeformats, prefcap);
-                       ast_best_codec(tmp->nativeformats, &tmpfmt);
+                       ast_format_cap_copy(ast_channel_nativeformats(tmp), prefcap);
+                       ast_best_codec(ast_channel_nativeformats(tmp), &tmpfmt);
                        ast_format_copy(&tmp->rawreadformat, &tmpfmt);
                        ast_format_copy(&tmp->rawwriteformat, &tmpfmt);
                }
                /* no need to call ast_setstate: the channel_alloc already did its job */
                if (state == AST_STATE_RING)
-                       tmp->rings = 1;
-               tmp->tech_pvt = i;
+                       ast_channel_rings_set(tmp, 1);
+               ast_channel_tech_pvt_set(tmp, i);
                ast_channel_context_set(tmp, cntx);
                if (!ast_strlen_zero(i->ext))
                        ast_channel_exten_set(tmp, i->ext);
index d846737b2ab741bc25e02aaca97e0e216e80d44c..57b9df28e25fe4844d74337b17fb343a1250d773 100644 (file)
@@ -1714,13 +1714,13 @@ static struct ast_cc_agent *find_sip_cc_agent_by_original_callid(struct sip_pvt
 static int sip_cc_agent_init(struct ast_cc_agent *agent, struct ast_channel *chan)
 {
        struct sip_cc_agent_pvt *agent_pvt = ast_calloc(1, sizeof(*agent_pvt));
-       struct sip_pvt *call_pvt = chan->tech_pvt;
+       struct sip_pvt *call_pvt = ast_channel_tech_pvt(chan);
 
        if (!agent_pvt) {
                return -1;
        }
 
-       ast_assert(!strcmp(chan->tech->type, "SIP"));
+       ast_assert(!strcmp(ast_channel_tech(chan)->type, "SIP"));
 
        ast_copy_string(agent_pvt->original_callid, call_pvt->callid, sizeof(agent_pvt->original_callid));
        ast_copy_string(agent_pvt->original_exten, call_pvt->exten, sizeof(agent_pvt->original_exten));
@@ -2983,7 +2983,7 @@ void dialog_unlink_all(struct sip_pvt *dialog)
        owner = sip_pvt_lock_full(dialog);
        if (owner) {
                ast_debug(1, "Detaching from channel %s\n", ast_channel_name(owner));
-               owner->tech_pvt = dialog_unref(owner->tech_pvt, "resetting channel dialog ptr in unlink_all");
+               ast_channel_tech_pvt_set(owner, dialog_unref(ast_channel_tech_pvt(owner), "resetting channel dialog ptr in unlink_all"));
                ast_channel_unlock(owner);
                ast_channel_unref(owner);
                dialog->owner = NULL;
@@ -3688,8 +3688,8 @@ static int retrans_pkt(const void *data)
                        usleep(1);
                        sip_pvt_lock(pkt->owner);
                }
-               if (pkt->owner->owner && !pkt->owner->owner->hangupcause) {
-                       pkt->owner->owner->hangupcause = AST_CAUSE_NO_USER_RESPONSE;
+               if (pkt->owner->owner && !ast_channel_hangupcause(pkt->owner->owner)) {
+                       ast_channel_hangupcause_set(pkt->owner->owner, AST_CAUSE_NO_USER_RESPONSE);
                }
                if (pkt->owner->owner) {
                        ast_log(LOG_WARNING, "Hanging up call %s - no reply to our critical packet (see https://wiki.asterisk.org/wiki/display/AST/SIP+Retransmissions).\n", pkt->owner->callid);
@@ -4306,7 +4306,7 @@ static void disable_dsp_detect(struct sip_pvt *p)
 static int sip_setoption(struct ast_channel *chan, int option, void *data, int datalen)
 {
        int res = -1;
-       struct sip_pvt *p = chan->tech_pvt;
+       struct sip_pvt *p = ast_channel_tech_pvt(chan);
 
         if (!p) {
                ast_log(LOG_ERROR, "Attempt to Ref a null pointer.  sip private structure is gone!\n");
@@ -4367,7 +4367,7 @@ static int sip_queryoption(struct ast_channel *chan, int option, void *data, int
 {
        int res = -1;
        enum ast_t38_state state = T38_STATE_UNAVAILABLE;
-       struct sip_pvt *p = (struct sip_pvt *) chan->tech_pvt;
+       struct sip_pvt *p = (struct sip_pvt *) ast_channel_tech_pvt(chan);
        char *cp;
 
        sip_pvt_lock(p);
@@ -4452,7 +4452,7 @@ const char *find_closing_quote(const char *start, const char *lim)
 /*! \brief Send message with Access-URL header, if this is an HTML URL only! */
 static int sip_sendhtml(struct ast_channel *chan, int subclass, const char *data, int datalen)
 {
-       struct sip_pvt *p = chan->tech_pvt;
+       struct sip_pvt *p = ast_channel_tech_pvt(chan);
 
        if (subclass != AST_HTML_URL)
                return -1;
@@ -4460,9 +4460,9 @@ static int sip_sendhtml(struct ast_channel *chan, int subclass, const char *data
        ast_string_field_build(p, url, "<%s>;mode=active", data);
 
        if (sip_debug_test_pvt(p))
-               ast_debug(1, "Send URL %s, state = %d!\n", data, chan->_state);
+               ast_debug(1, "Send URL %s, state = %d!\n", data, ast_channel_state(chan));
 
-       switch (chan->_state) {
+       switch (ast_channel_state(chan)) {
        case AST_STATE_RING:
                transmit_response(p, "100 Trying", &p->initreq);
                break;
@@ -4477,7 +4477,7 @@ static int sip_sendhtml(struct ast_channel *chan, int subclass, const char *data
                }
                break;
        default:
-               ast_log(LOG_WARNING, "Don't know how to send URI when state is %d!\n", chan->_state);
+               ast_log(LOG_WARNING, "Don't know how to send URI when state is %d!\n", ast_channel_state(chan));
        }
 
        return 0;
@@ -4486,7 +4486,7 @@ static int sip_sendhtml(struct ast_channel *chan, int subclass, const char *data
 /*! \brief Deliver SIP call ID for the call */
 static const char *sip_get_callid(struct ast_channel *chan)
 {
-       return chan->tech_pvt ? ((struct sip_pvt *) chan->tech_pvt)->callid : "";
+       return ast_channel_tech_pvt(chan) ? ((struct sip_pvt *) ast_channel_tech_pvt(chan))->callid : "";
 }
 
 /*!
@@ -4496,7 +4496,7 @@ static const char *sip_get_callid(struct ast_channel *chan)
  */
 static int sip_sendtext(struct ast_channel *ast, const char *text)
 {
-       struct sip_pvt *dialog = ast->tech_pvt;
+       struct sip_pvt *dialog = ast_channel_tech_pvt(ast);
        int debug;
 
        if (!dialog) {
@@ -5618,14 +5618,14 @@ static int auto_congest(const void *arg)
 static int sip_call(struct ast_channel *ast, const char *dest, int timeout)
 {
        int res;
-       struct sip_pvt *p = ast->tech_pvt;      /* chan is locked, so the reference cannot go away */
+       struct sip_pvt *p = ast_channel_tech_pvt(ast);  /* chan is locked, so the reference cannot go away */
        struct varshead *headp;
        struct ast_var_t *current;
        const char *referer = NULL;   /* SIP referrer */
        int cc_core_id;
        char uri[SIPBUFSIZE] = "";
 
-       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, "sip_call called on %s, neither down nor reserved\n", ast_channel_name(ast));
                return -1;
        }
@@ -5674,7 +5674,7 @@ static int sip_call(struct ast_channel *ast, const char *dest, int timeout)
        /* Check to see if we should try to force encryption */
        if (p->req_secure_signaling && p->socket.type != SIP_TRANSPORT_TLS) {
           ast_log(LOG_WARNING, "Encrypted signaling is required\n");
-          ast->hangupcause = AST_CAUSE_BEARERCAPABILITY_NOTAVAIL;
+          ast_channel_hangupcause_set(ast, AST_CAUSE_BEARERCAPABILITY_NOTAVAIL);
           return -1;
        }
 
@@ -5724,7 +5724,7 @@ static int sip_call(struct ast_channel *ast, const char *dest, int timeout)
        res = update_call_counter(p, INC_CALL_RINGING);
 
        if (res == -1) {
-               ast->hangupcause = AST_CAUSE_USER_BUSY;
+               ast_channel_hangupcause_set(ast, AST_CAUSE_USER_BUSY);
                return res;
        }
        p->callingpres = ast_party_id_presentation(&ast->caller.id);
@@ -5843,7 +5843,7 @@ void __sip_destroy(struct sip_pvt *p, int lockowner, int lockdialoglist)
                if (lockowner)
                        ast_channel_lock(p->owner);
                ast_debug(1, "Detaching from %s\n", ast_channel_name(p->owner));
-               p->owner->tech_pvt = NULL;
+               ast_channel_tech_pvt_set(p->owner, NULL);
                /* Make sure that the channel knows its backend is going away */
                p->owner->_softhangup |= AST_SOFTHANGUP_DEV;
                if (lockowner)
@@ -6319,7 +6319,7 @@ const char *hangup_cause2sip(int cause)
  * Part of PBX interface, called from ast_hangup */
 static int sip_hangup(struct ast_channel *ast)
 {
-       struct sip_pvt *p = ast->tech_pvt;
+       struct sip_pvt *p = ast_channel_tech_pvt(ast);
        int needcancel = FALSE;
        int needdestroy = 0;
        struct ast_channel *oldowner = ast;
@@ -6328,9 +6328,9 @@ static int sip_hangup(struct ast_channel *ast)
                ast_debug(1, "Asked to hangup channel that was not connected\n");
                return 0;
        }
-       if (ast_test_flag(ast, AST_FLAG_ANSWERED_ELSEWHERE) || ast->hangupcause == AST_CAUSE_ANSWERED_ELSEWHERE) {
+       if (ast_test_flag(ast, AST_FLAG_ANSWERED_ELSEWHERE) || ast_channel_hangupcause(ast) == AST_CAUSE_ANSWERED_ELSEWHERE) {
                ast_debug(1, "This call was answered elsewhere");
-               if (ast->hangupcause == AST_CAUSE_ANSWERED_ELSEWHERE) {
+               if (ast_channel_hangupcause(ast) == AST_CAUSE_ANSWERED_ELSEWHERE) {
                        ast_debug(1, "####### It's the cause code, buddy. The cause code!!!\n");
                }
                append_history(p, "Cancel", "Call answered elsewhere");
@@ -6339,7 +6339,7 @@ static int sip_hangup(struct ast_channel *ast)
 
        /* Store hangupcause locally in PVT so we still have it before disconnect */
        if (p->owner)
-               p->hangupcause = p->owner->hangupcause;
+               p->hangupcause = ast_channel_hangupcause(p->owner);
 
        if (ast_test_flag(&p->flags[0], SIP_DEFER_BYE_ON_TRANSFER)) {
                if (ast_test_flag(&p->flags[0], SIP_INC_COUNT) || ast_test_flag(&p->flags[1], SIP_PAGE2_CALL_ONHOLD)) {
@@ -6350,7 +6350,7 @@ static int sip_hangup(struct ast_channel *ast)
                ast_debug(4, "SIP Transfer: Not hanging up right now... Rescheduling hangup for %s.\n", p->callid);
                sip_scheddestroy(p, DEFAULT_TRANS_TIMEOUT);
                ast_clear_flag(&p->flags[0], SIP_DEFER_BYE_ON_TRANSFER);        /* Really hang up next time */
-               p->owner->tech_pvt = dialog_unref(p->owner->tech_pvt, "unref p->owner->tech_pvt");
+               ast_channel_tech_pvt_set(p->owner, dialog_unref(ast_channel_tech_pvt(p->owner), "unref p->owner->tech_pvt"));
                sip_pvt_lock(p);
                p->owner = NULL;  /* Owner will be gone after we return, so take it away */
                sip_pvt_unlock(p);
@@ -6381,9 +6381,9 @@ static int sip_hangup(struct ast_channel *ast)
        }
        /* If the call is not UP, we need to send CANCEL instead of BYE */
        /* In case of re-invites, the call might be UP even though we have an incomplete invite transaction */
-       if (p->invitestate < INV_COMPLETED && p->owner->_state != AST_STATE_UP) {
+       if (p->invitestate < INV_COMPLETED && ast_channel_state(p->owner) != AST_STATE_UP) {
                needcancel = TRUE;
-               ast_debug(4, "Hanging up channel in state %s (not UP)\n", ast_state2str(ast->_state));
+               ast_debug(4, "Hanging up channel in state %s (not UP)\n", ast_state2str(ast_channel_state(ast)));
        }
 
        stop_media_flows(p); /* Immediately stop RTP, VRTP and UDPTL as applicable */
@@ -6394,7 +6394,7 @@ static int sip_hangup(struct ast_channel *ast)
        disable_dsp_detect(p);
 
        p->owner = NULL;
-       ast->tech_pvt = dialog_unref(ast->tech_pvt, "unref ast->tech_pvt");
+       ast_channel_tech_pvt_set(ast, dialog_unref(ast_channel_tech_pvt(ast), "unref ast->tech_pvt"));
 
        ast_module_unref(ast_module_info->self);
        /* Do not destroy this pvt until we have timeout or
@@ -6467,9 +6467,9 @@ static int sip_hangup(struct ast_channel *ast)
                                }
 
                                if (bridge) {
-                                       struct sip_pvt *q = bridge->tech_pvt;
+                                       struct sip_pvt *q = ast_channel_tech_pvt(bridge);
 
-                                       if (IS_SIP_TECH(bridge->tech) && q && q->rtp) {
+                                       if (IS_SIP_TECH(ast_channel_tech(bridge)) && q && q->rtp) {
                                                ast_rtp_instance_set_stats_vars(bridge, q->rtp);
                                        }
                                        ast_channel_unlock(bridge);
@@ -6503,7 +6503,7 @@ static int sip_hangup(struct ast_channel *ast)
                                }
 
                                /* Send a hangup */
-                               if (oldowner->_state == AST_STATE_UP) {
+                               if (ast_channel_state(oldowner) == AST_STATE_UP) {
                                        transmit_request_with_auth(p, SIP_BYE, 0, XMIT_RELIABLE, 1);
                                }
 
@@ -6560,10 +6560,10 @@ static void try_suggested_sip_codec(struct sip_pvt *p)
 static int sip_answer(struct ast_channel *ast)
 {
        int res = 0;
-       struct sip_pvt *p = ast->tech_pvt;
+       struct sip_pvt *p = ast_channel_tech_pvt(ast);
 
        sip_pvt_lock(p);
-       if (ast->_state != AST_STATE_UP) {
+       if (ast_channel_state(ast) != AST_STATE_UP) {
                try_suggested_sip_codec(p);
 
                ast_setstate(ast, AST_STATE_UP);
@@ -6579,16 +6579,16 @@ static int sip_answer(struct ast_channel *ast)
 /*! \brief Send frame to media channel (rtp) */
 static int sip_write(struct ast_channel *ast, struct ast_frame *frame)
 {
-       struct sip_pvt *p = ast->tech_pvt;
+       struct sip_pvt *p = ast_channel_tech_pvt(ast);
        int res = 0;
 
        switch (frame->frametype) {
        case AST_FRAME_VOICE:
-               if (!(ast_format_cap_iscompatible(ast->nativeformats, &frame->subclass.format))) {
+               if (!(ast_format_cap_iscompatible(ast_channel_nativeformats(ast), &frame->subclass.format))) {
                        char s1[512];
                        ast_log(LOG_WARNING, "Asked to transmit frame type %s, while native formats is %s read/write = %s/%s\n",
                                ast_getformatname(&frame->subclass.format),
-                               ast_getformatname_multiple(s1, sizeof(s1), ast->nativeformats),
+                               ast_getformatname_multiple(s1, sizeof(s1), ast_channel_nativeformats(ast)),
                                ast_getformatname(&ast->readformat),
                                ast_getformatname(&ast->writeformat));
                        return 0;
@@ -6601,7 +6601,7 @@ static int sip_write(struct ast_channel *ast, struct ast_frame *frame)
                                break;
                        } else if (p->rtp) {
                                /* If channel is not up, activate early media session */
-                               if ((ast->_state != AST_STATE_UP) &&
+                               if ((ast_channel_state(ast) != AST_STATE_UP) &&
                                    !ast_test_flag(&p->flags[0], SIP_PROGRESS_SENT) &&
                                    !ast_test_flag(&p->flags[0], SIP_OUTGOING)) {
                                        ast_rtp_instance_update_source(p->rtp);
@@ -6622,7 +6622,7 @@ static int sip_write(struct ast_channel *ast, struct ast_frame *frame)
                        sip_pvt_lock(p);
                        if (p->vrtp) {
                                /* Activate video early media */
-                               if ((ast->_state != AST_STATE_UP) &&
+                               if ((ast_channel_state(ast) != AST_STATE_UP) &&
                                    !ast_test_flag(&p->flags[0], SIP_PROGRESS_SENT) &&
                                    !ast_test_flag(&p->flags[0], SIP_OUTGOING)) {
                                        p->invitestate = INV_EARLY_MEDIA;
@@ -6643,7 +6643,7 @@ static int sip_write(struct ast_channel *ast, struct ast_frame *frame)
                        } else {
                                if (p->trtp) {
                                        /* Activate text early media */
-                                       if ((ast->_state != AST_STATE_UP) &&
+                                       if ((ast_channel_state(ast) != AST_STATE_UP) &&
                                            !ast_test_flag(&p->flags[0], SIP_PROGRESS_SENT) &&
                                            !ast_test_flag(&p->flags[0], SIP_OUTGOING)) {
                                                p->invitestate = INV_EARLY_MEDIA;
@@ -6667,7 +6667,7 @@ static int sip_write(struct ast_channel *ast, struct ast_frame *frame)
                                we simply forget the frames if we get modem frames before the bridge is up.
                                Fax will re-transmit.
                        */
-                       if ((ast->_state == AST_STATE_UP) &&
+                       if ((ast_channel_state(ast) == AST_STATE_UP) &&
                            p->udptl &&
                            (p->t38.state == T38_ENABLED)) {
                                res = ast_udptl_write(p->udptl, frame);
@@ -6695,14 +6695,14 @@ static int sip_fixup(struct ast_channel *oldchan, struct ast_channel *newchan)
        if (oldchan && ast_test_flag(oldchan, AST_FLAG_ZOMBIE))
                ast_debug(1, "Old channel is zombie\n");
 
-       if (!newchan || !newchan->tech_pvt) {
+       if (!newchan || !ast_channel_tech_pvt(newchan)) {
                if (!newchan)
                        ast_log(LOG_WARNING, "No new channel! Fixup of %s failed.\n", ast_channel_name(oldchan));
                else
                        ast_log(LOG_WARNING, "No SIP tech_pvt! Fixup of %s failed.\n", ast_channel_name(oldchan));
                return -1;
        }
-       p = newchan->tech_pvt;
+       p = ast_channel_tech_pvt(newchan);
 
        sip_pvt_lock(p);
        append_history(p, "Masq", "Old channel: %s\n", ast_channel_name(oldchan));
@@ -6728,7 +6728,7 @@ static int sip_fixup(struct ast_channel *oldchan, struct ast_channel *newchan)
 
 static int sip_senddigit_begin(struct ast_channel *ast, char digit)
 {
-       struct sip_pvt *p = ast->tech_pvt;
+       struct sip_pvt *p = ast_channel_tech_pvt(ast);
        int res = 0;
 
        sip_pvt_lock(p);
@@ -6752,7 +6752,7 @@ static int sip_senddigit_begin(struct ast_channel *ast, char digit)
        within one call, we're able to transmit in many methods simultaneously */
 static int sip_senddigit_end(struct ast_channel *ast, char digit, unsigned int duration)
 {
-       struct sip_pvt *p = ast->tech_pvt;
+       struct sip_pvt *p = ast_channel_tech_pvt(ast);
        int res = 0;
 
        sip_pvt_lock(p);
@@ -6777,13 +6777,13 @@ static int sip_senddigit_end(struct ast_channel *ast, char digit, unsigned int d
 /*! \brief Transfer SIP call */
 static int sip_transfer(struct ast_channel *ast, const char *dest)
 {
-       struct sip_pvt *p = ast->tech_pvt;
+       struct sip_pvt *p = ast_channel_tech_pvt(ast);
        int res;
 
        if (dest == NULL)       /* functions below do not take a NULL */
                dest = "";
        sip_pvt_lock(p);
-       if (ast->_state == AST_STATE_RING)
+       if (ast_channel_state(ast) == AST_STATE_RING)
                res = sip_sipredirect(p, dest);
        else
                res = transmit_refer(p, dest);
@@ -6925,13 +6925,13 @@ static int initialize_udptl(struct sip_pvt *p)
 */
 static int sip_indicate(struct ast_channel *ast, int condition, const void *data, size_t datalen)
 {
-       struct sip_pvt *p = ast->tech_pvt;
+       struct sip_pvt *p = ast_channel_tech_pvt(ast);
        int res = 0;
 
        sip_pvt_lock(p);
        switch(condition) {
        case AST_CONTROL_RINGING:
-               if (ast->_state == AST_STATE_RING) {
+               if (ast_channel_state(ast) == AST_STATE_RING) {
                        p->invitestate = INV_EARLY_MEDIA;
                        if (!ast_test_flag(&p->flags[0], SIP_PROGRESS_SENT) ||
                            (ast_test_flag(&p->flags[0], SIP_PROG_INBAND) == SIP_PROG_INBAND_NEVER)) {                          
@@ -6947,7 +6947,7 @@ static int sip_indicate(struct ast_channel *ast, int condition, const void *data
                res = -1;
                break;
        case AST_CONTROL_BUSY:
-               if (ast->_state != AST_STATE_UP) {
+               if (ast_channel_state(ast) != AST_STATE_UP) {
                        transmit_response_reliable(p, "486 Busy Here", &p->initreq);
                        p->invitestate = INV_COMPLETED;
                        sip_alreadygone(p);
@@ -6957,7 +6957,7 @@ static int sip_indicate(struct ast_channel *ast, int condition, const void *data
                res = -1;
                break;
        case AST_CONTROL_CONGESTION:
-               if (ast->_state != AST_STATE_UP) {
+               if (ast_channel_state(ast) != AST_STATE_UP) {
                        transmit_response_reliable(p, "503 Service Unavailable", &p->initreq);
                        p->invitestate = INV_COMPLETED;
                        sip_alreadygone(p);
@@ -6967,7 +6967,7 @@ static int sip_indicate(struct ast_channel *ast, int condition, const void *data
                res = -1;
                break;
        case AST_CONTROL_INCOMPLETE:
-               if (ast->_state != AST_STATE_UP) {
+               if (ast_channel_state(ast) != AST_STATE_UP) {
                        switch (ast_test_flag(&p->flags[1], SIP_PAGE2_ALLOWOVERLAP)) {
                        case SIP_PAGE2_ALLOWOVERLAP_YES:
                                transmit_response_reliable(p, "484 Address Incomplete", &p->initreq);
@@ -6989,7 +6989,7 @@ static int sip_indicate(struct ast_channel *ast, int condition, const void *data
                }
                break;
        case AST_CONTROL_PROCEEDING:
-               if ((ast->_state != AST_STATE_UP) &&
+               if ((ast_channel_state(ast) != AST_STATE_UP) &&
                    !ast_test_flag(&p->flags[0], SIP_PROGRESS_SENT) &&
                    !ast_test_flag(&p->flags[0], SIP_OUTGOING)) {
                        transmit_response(p, "100 Trying", &p->initreq);
@@ -6999,7 +6999,7 @@ static int sip_indicate(struct ast_channel *ast, int condition, const void *data
                res = -1;
                break;
        case AST_CONTROL_PROGRESS:
-               if ((ast->_state != AST_STATE_UP) &&
+               if ((ast_channel_state(ast) != AST_STATE_UP) &&
                    !ast_test_flag(&p->flags[0], SIP_PROGRESS_SENT) &&
                    !ast_test_flag(&p->flags[0], SIP_OUTGOING)) {
                        p->invitestate = INV_EARLY_MEDIA;
@@ -7141,7 +7141,7 @@ static struct ast_channel *sip_new(struct sip_pvt *i, int state, const char *tit
        ast_channel_cc_params_init(tmp, i->cc_params);
        tmp->caller.id.tag = ast_strdup(i->cid_tag);
 
-       tmp->tech = ( ast_test_flag(&i->flags[0], SIP_DTMF) == SIP_DTMF_INFO || ast_test_flag(&i->flags[0], SIP_DTMF) == SIP_DTMF_SHORTINFO) ?  &sip_tech_info : &sip_tech;
+       ast_channel_tech_set(tmp, (ast_test_flag(&i->flags[0], SIP_DTMF) == SIP_DTMF_INFO || ast_test_flag(&i->flags[0], SIP_DTMF) == SIP_DTMF_SHORTINFO) ? &sip_tech_info : &sip_tech);
 
        /* Select our native format based on codec preference until we receive
           something from another device to the contrary. */
@@ -7154,13 +7154,13 @@ static struct ast_channel *sip_new(struct sip_pvt *i, int state, const char *tit
        }
 
        /* Set the native formats */
-       ast_format_cap_copy(tmp->nativeformats, what);
+       ast_format_cap_copy(ast_channel_nativeformats(tmp), what);
        /* choose and use only the best audio format for our native formats */
-       ast_codec_choose(&i->prefs, tmp->nativeformats, 1, &fmt); /* get the best audio format */
-       ast_format_cap_remove_bytype(tmp->nativeformats, AST_FORMAT_TYPE_AUDIO); /* remove only the other audio formats */
-       ast_format_cap_add(tmp->nativeformats, &fmt); /* add our best choice back */
+       ast_codec_choose(&i->prefs, ast_channel_nativeformats(tmp), 1, &fmt); /* get the best audio format */
+       ast_format_cap_remove_bytype(ast_channel_nativeformats(tmp), AST_FORMAT_TYPE_AUDIO); /* remove only the other audio formats */
+       ast_format_cap_add(ast_channel_nativeformats(tmp), &fmt); /* add our best choice back */
 
-       ast_debug(3, "*** Our native formats are %s \n", ast_getformatname_multiple(buf, SIPBUFSIZE, tmp->nativeformats));
+       ast_debug(3, "*** Our native formats are %s \n", ast_getformatname_multiple(buf, SIPBUFSIZE, ast_channel_nativeformats(tmp)));
        ast_debug(3, "*** Joint capabilities are %s \n", ast_getformatname_multiple(buf, SIPBUFSIZE, i->jointcaps));
        ast_debug(3, "*** Our capabilities are %s \n", ast_getformatname_multiple(buf, SIPBUFSIZE, i->caps));
        ast_debug(3, "*** AST_CODEC_CHOOSE formats are %s \n", ast_getformatname(&fmt));
@@ -7226,9 +7226,9 @@ static struct ast_channel *sip_new(struct sip_pvt *i, int state, const char *tit
        }
 
        if (state == AST_STATE_RING) {
-               tmp->rings = 1;
+               ast_channel_rings_set(tmp, 1);
        }
-       tmp->adsicpe = AST_ADSI_UNAVAILABLE;
+       ast_channel_adsicpe_set(tmp, AST_ADSI_UNAVAILABLE);
 
        ast_format_copy(&tmp->writeformat, &fmt);
        ast_format_copy(&tmp->rawwriteformat, &fmt);
@@ -7238,7 +7238,7 @@ static struct ast_channel *sip_new(struct sip_pvt *i, int state, const char *tit
        ast_format_copy(&tmp->rawreadformat, &fmt);
        ast_rtp_instance_set_read_format(i->rtp, &fmt);
 
-       tmp->tech_pvt = dialog_ref(i, "sip_new: set chan->tech_pvt to i");
+       ast_channel_tech_pvt_set(tmp, dialog_ref(i, "sip_new: set chan->tech_pvt to i"));
 
        tmp->callgroup = i->callgroup;
        tmp->pickupgroup = i->pickupgroup;
@@ -7251,15 +7251,17 @@ static struct ast_channel *sip_new(struct sip_pvt *i, int state, const char *tit
                ast_channel_accountcode_set(tmp, i->accountcode);
        }
        if (i->amaflags) {
-               tmp->amaflags = i->amaflags;
+               ast_channel_amaflags_set(tmp, i->amaflags);
        }
        if (!ast_strlen_zero(i->language)) {
                ast_channel_language_set(tmp, i->language);
        }
        if (!ast_strlen_zero(i->zone)) {
-               if (!(tmp->zone = ast_get_indication_zone(i->zone))) {
+               struct ast_tone_zone *zone;
+               if (!(zone = ast_get_indication_zone(i->zone))) {
                        ast_log(LOG_ERROR, "Unknown country code '%s' for tonezone. Check indications.conf for available country codes.\n", i->zone);
                } 
+               ast_channel_zone_set(tmp, zone);
        }
        i->owner = tmp;
        ast_module_ref(ast_module_info->self);
@@ -7293,7 +7295,7 @@ static struct ast_channel *sip_new(struct sip_pvt *i, int state, const char *tit
                tmp->dialed.number.str = ast_strdup(i->exten);
        }
 
-       tmp->priority = 1;
+       ast_channel_priority_set(tmp, 1);
        if (!ast_strlen_zero(i->uri)) {
                pbx_builtin_setvar_helper(tmp, "SIPURI", i->uri);
        }
@@ -7514,7 +7516,7 @@ static struct ast_frame *sip_rtp_read(struct ast_channel *ast, struct sip_pvt *p
                return &ast_null_frame;
        }
 
-       switch(ast->fdno) {
+       switch(ast_channel_fdno(ast)) {
        case 0:
                f = ast_rtp_instance_read(p->rtp, 0);   /* RTP Audio */
                break;
@@ -7567,7 +7569,7 @@ static struct ast_frame *sip_rtp_read(struct ast_channel *ast, struct sip_pvt *p
                return f;
        }
 
-       if (f && !ast_format_cap_iscompatible(p->owner->nativeformats, &f->subclass.format)) {
+       if (f && !ast_format_cap_iscompatible(ast_channel_nativeformats(p->owner), &f->subclass.format)) {
                if (!ast_format_cap_iscompatible(p->jointcaps, &f->subclass.format)) {
                        ast_debug(1, "Bogus frame of format '%s' received from '%s'!\n",
                                ast_getformatname(&f->subclass.format), ast_channel_name(p->owner));
@@ -7575,8 +7577,8 @@ static struct ast_frame *sip_rtp_read(struct ast_channel *ast, struct sip_pvt *p
                }
                ast_debug(1, "Oooh, format changed to %s\n",
                        ast_getformatname(&f->subclass.format));
-               ast_format_cap_remove_bytype(p->owner->nativeformats, AST_FORMAT_TYPE_AUDIO);
-               ast_format_cap_add(p->owner->nativeformats, &f->subclass.format);
+               ast_format_cap_remove_bytype(ast_channel_nativeformats(p->owner), AST_FORMAT_TYPE_AUDIO);
+               ast_format_cap_add(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);
        }
@@ -7607,7 +7609,7 @@ static struct ast_frame *sip_rtp_read(struct ast_channel *ast, struct sip_pvt *p
 static struct ast_frame *sip_read(struct ast_channel *ast)
 {
        struct ast_frame *fr;
-       struct sip_pvt *p = ast->tech_pvt;
+       struct sip_pvt *p = ast_channel_tech_pvt(ast);
        int faxdetected = FALSE;
 
        sip_pvt_lock(p);
@@ -7644,7 +7646,7 @@ static struct ast_frame *sip_read(struct ast_channel *ast)
        }
 
        /* Only allow audio through if they sent progress with SDP, or if the channel is actually answered */
-       if (fr && fr->frametype == AST_FRAME_VOICE && p->invitestate != INV_EARLY_MEDIA && ast->_state != AST_STATE_UP) {
+       if (fr && fr->frametype == AST_FRAME_VOICE && p->invitestate != INV_EARLY_MEDIA && ast_channel_state(ast) != AST_STATE_UP) {
                fr = &ast_null_frame;
        }
 
@@ -9645,14 +9647,14 @@ static int process_sdp(struct sip_pvt *p, struct sip_request *req, int t38action
                        char s1[SIPBUFSIZE], s2[SIPBUFSIZE];
                        ast_debug(1, "Setting native formats after processing SDP. peer joint formats %s, old nativeformats %s\n",
                                ast_getformatname_multiple(s1, SIPBUFSIZE, p->jointcaps),
-                               ast_getformatname_multiple(s2, SIPBUFSIZE, p->owner->nativeformats));
+                               ast_getformatname_multiple(s2, SIPBUFSIZE, ast_channel_nativeformats(p->owner)));
                }
 
                ast_codec_choose(&p->prefs, p->jointcaps, 1, &tmp_fmt);
 
-               ast_format_cap_set(p->owner->nativeformats, &tmp_fmt);
-               ast_format_cap_joint_append(p->caps, vpeercapability, p->owner->nativeformats);
-               ast_format_cap_joint_append(p->caps, tpeercapability, p->owner->nativeformats);
+               ast_format_cap_set(ast_channel_nativeformats(p->owner), &tmp_fmt);
+               ast_format_cap_joint_append(p->caps, vpeercapability, ast_channel_nativeformats(p->owner));
+               ast_format_cap_joint_append(p->caps, tpeercapability, ast_channel_nativeformats(p->owner));
 
                ast_set_read_format(p->owner, &p->owner->readformat);
                ast_set_write_format(p->owner, &p->owner->writeformat);
@@ -10767,8 +10769,8 @@ static int __transmit_response(struct sip_pvt *p, const char *msg, const struct
                if (ast_test_flag(&p->flags[1], SIP_PAGE2_Q850_REASON)) {
                        int hangupcause = 0;
 
-                       if (p->owner && p->owner->hangupcause) {
-                               hangupcause = p->owner->hangupcause;
+                       if (p->owner && ast_channel_hangupcause(p->owner)) {
+                               hangupcause = ast_channel_hangupcause(p->owner);
                        } else if (p->hangupcause) {
                                hangupcause = p->hangupcause;
                        } else {
@@ -10783,9 +10785,9 @@ static int __transmit_response(struct sip_pvt *p, const char *msg, const struct
                        }
                }
 
-               if (p->owner && p->owner->hangupcause) {
-                       add_header(&resp, "X-Asterisk-HangupCause", ast_cause2str(p->owner->hangupcause));
-                       snprintf(buf, sizeof(buf), "%d", p->owner->hangupcause);
+               if (p->owner && ast_channel_hangupcause(p->owner)) {
+                       add_header(&resp, "X-Asterisk-HangupCause", ast_cause2str(ast_channel_hangupcause(p->owner)));
+                       snprintf(buf, sizeof(buf), "%d", ast_channel_hangupcause(p->owner));
                        add_header(&resp, "X-Asterisk-HangupCauseCode", buf);
                }
        }
@@ -12949,7 +12951,7 @@ static int find_calling_channel(void *obj, void *arg, void *data, int flags)
 
        ast_channel_lock(c);
 
-       res = (c->pbx &&
+       res = (ast_channel_pbx(c) &&
                        (!strcasecmp(ast_channel_macroexten(c), p->exten) || !strcasecmp(ast_channel_exten(c), p->exten)) &&
                        (sip_cfg.notifycid == IGNORE_CONTEXT || !strcasecmp(ast_channel_context(c), p->context)));
 
@@ -13394,7 +13396,7 @@ static void update_redirecting(struct sip_pvt *p, const void *data, size_t datal
 {
        struct sip_request resp;
 
-       if (p->owner->_state == AST_STATE_UP || ast_test_flag(&p->flags[0], SIP_OUTGOING)) {
+       if (ast_channel_state(p->owner) == AST_STATE_UP || ast_test_flag(&p->flags[0], SIP_OUTGOING)) {
                return;
        }
 
@@ -13420,7 +13422,7 @@ static void update_connectedline(struct sip_pvt *p, const void *data, size_t dat
                S_COR(p->owner->connected.id.name.valid, p->owner->connected.id.name.str, ""),
                S_COR(p->owner->connected.id.number.valid, p->owner->connected.id.number.str, ""));
 
-       if (p->owner->_state == AST_STATE_UP || ast_test_flag(&p->flags[0], SIP_OUTGOING)) {
+       if (ast_channel_state(p->owner) == AST_STATE_UP || ast_test_flag(&p->flags[0], SIP_OUTGOING)) {
                struct sip_request req;
 
                if (p->invitestate == INV_CONFIRMED || p->invitestate == INV_TERMINATED) {
@@ -13450,20 +13452,20 @@ static void update_connectedline(struct sip_pvt *p, const void *data, size_t dat
                if (ast_test_flag(&p->flags[1], SIP_PAGE2_RPID_IMMEDIATE)) {
                        struct sip_request resp;
 
-                       if ((p->owner->_state == AST_STATE_RING) && !ast_test_flag(&p->flags[0], SIP_PROGRESS_SENT)) {
+                       if ((ast_channel_state(p->owner) == AST_STATE_RING) && !ast_test_flag(&p->flags[0], SIP_PROGRESS_SENT)) {
                                ast_clear_flag(&p->flags[1], SIP_PAGE2_CONNECTLINEUPDATE_PEND);
                                respprep(&resp, p, "180 Ringing", &p->initreq);
                                add_rpid(&resp, p);
                                send_response(p, &resp, XMIT_UNRELIABLE, 0);
                                ast_set_flag(&p->flags[0], SIP_RINGING);
-                       } else if (p->owner->_state == AST_STATE_RINGING) {
+                       } else if (ast_channel_state(p->owner) == AST_STATE_RINGING) {
                                ast_clear_flag(&p->flags[1], SIP_PAGE2_CONNECTLINEUPDATE_PEND);
                                respprep(&resp, p, "183 Session Progress", &p->initreq);
                                add_rpid(&resp, p);
                                send_response(p, &resp, XMIT_UNRELIABLE, 0);
                                ast_set_flag(&p->flags[0], SIP_PROGRESS_SENT);
                        } else {
-                               ast_debug(1, "Unable able to send update to '%s' in state '%s'\n", ast_channel_name(p->owner), ast_state2str(p->owner->_state));
+                               ast_debug(1, "Unable able to send update to '%s' in state '%s'\n", ast_channel_name(p->owner), ast_state2str(ast_channel_state(p->owner)));
                        }
                }
        }
@@ -18662,8 +18664,8 @@ static int show_chanstats_cb(void *__cur, void *__arg, int flags)
 
        ast_rtp_instance_get_stats(cur->rtp, &stats, AST_RTP_INSTANCE_STAT_ALL);
 
-       if (c && c->cdr && !ast_tvzero(c->cdr->start)) {
-               duration = (int)(ast_tvdiff_ms(ast_tvnow(), c->cdr->start) / 1000);
+       if (c && ast_channel_cdr(c) && !ast_tvzero(ast_channel_cdr(c)->start)) {
+               duration = (int)(ast_tvdiff_ms(ast_tvnow(), ast_channel_cdr(c)->start) / 1000);
                durh = duration / 3600;
                durm = (duration % 3600) / 60;
                durs = duration % 60;
@@ -19039,7 +19041,7 @@ static int show_channels_cb(void *__cur, void *__arg, int flags)
                ast_cli(arg->fd, FORMAT, ast_sockaddr_stringify_addr(dst),
                                S_OR(cur->username, S_OR(cur->cid_num, "(None)")),
                                cur->callid,
-                               cur->owner ? ast_getformatname_multiple(formatbuf, sizeof(formatbuf), cur->owner->nativeformats) : "(nothing)",
+                               cur->owner ? ast_getformatname_multiple(formatbuf, sizeof(formatbuf), ast_channel_nativeformats(cur->owner)) : "(nothing)",
                                AST_CLI_YESNO(ast_test_flag(&cur->flags[1], SIP_PAGE2_CALL_ONHOLD)),
                                cur->needdestroy ? "(d)" : "",
                                cur->lastmsg ,
@@ -19292,7 +19294,7 @@ static char *sip_show_channel(struct ast_cli_entry *e, int cmd, struct ast_cli_a
                        ast_cli(a->fd, "  Non-Codec Capability (DTMF):   %d\n", cur->noncodeccapability);
                        ast_cli(a->fd, "  Their Codec Capability:   %s\n", ast_getformatname_multiple(formatbuf, sizeof(formatbuf), cur->peercaps));
                        ast_cli(a->fd, "  Joint Codec Capability:   %s\n", ast_getformatname_multiple(formatbuf, sizeof(formatbuf), cur->jointcaps));
-                       ast_cli(a->fd, "  Format:                 %s\n", cur->owner ? ast_getformatname_multiple(formatbuf, sizeof(formatbuf), cur->owner->nativeformats) : "(nothing)" );
+                       ast_cli(a->fd, "  Format:                 %s\n", cur->owner ? ast_getformatname_multiple(formatbuf, sizeof(formatbuf), ast_channel_nativeformats(cur->owner)) : "(nothing)" );
                        ast_cli(a->fd, "  T.38 support            %s\n", AST_CLI_YESNO(cur->udptl != NULL));
                        ast_cli(a->fd, "  Video support           %s\n", AST_CLI_YESNO(cur->vrtp != NULL));
                        ast_cli(a->fd, "  MaxCallBR:              %d kbps\n", cur->maxcallbitrate);
@@ -19592,10 +19594,10 @@ static void handle_request_info(struct sip_pvt *p, struct sip_request *req)
        } else if (!ast_strlen_zero(c = sip_get_header(req, "X-ClientCode"))) {
                /* Client code (from SNOM phone) */
                if (ast_test_flag(&p->flags[0], SIP_USECLIENTCODE)) {
-                       if (p->owner && p->owner->cdr) {
+                       if (p->owner && ast_channel_cdr(p->owner)) {
                                ast_cdr_setuserfield(p->owner, c);
                        }
-                       if (p->owner && ast_bridged_channel(p->owner) && ast_bridged_channel(p->owner)->cdr) {
+                       if (p->owner && ast_bridged_channel(p->owner) && ast_channel_cdr(ast_bridged_channel(p->owner))) {
                                ast_cdr_setuserfield(ast_bridged_channel(p->owner), c);
                        }
                        transmit_response(p, "200 OK", req);
@@ -20111,7 +20113,7 @@ static int func_header_read(struct ast_channel *chan, const char *function, char
        }
 
        ast_channel_lock(chan);
-       if (!IS_SIP_TECH(chan->tech)) {
+       if (!IS_SIP_TECH(ast_channel_tech(chan))) {
                ast_log(LOG_WARNING, "This function can only be used on SIP channels.\n");
                ast_channel_unlock(chan);
                return -1;
@@ -20126,7 +20128,7 @@ static int func_header_read(struct ast_channel *chan, const char *function, char
                        number = 1;
        }
 
-       p = chan->tech_pvt;
+       p = ast_channel_tech_pvt(chan);
 
        /* If there is no private structure, this channel is no longer alive */
        if (!p) {
@@ -20285,7 +20287,7 @@ static int function_sipchaninfo_read(struct ast_channel *chan, const char *cmd,
        }
 
        ast_channel_lock(chan);
-       if (!IS_SIP_TECH(chan->tech)) {
+       if (!IS_SIP_TECH(ast_channel_tech(chan))) {
                ast_log(LOG_WARNING, "This function can only be used on SIP channels.\n");
                ast_channel_unlock(chan);
                return -1;
@@ -20296,7 +20298,7 @@ static int function_sipchaninfo_read(struct ast_channel *chan, const char *cmd,
                ast_log(LOG_WARNING, "SIPCHANINFO() is deprecated.  Please transition to using CHANNEL().\n");
        }
 
-       p = chan->tech_pvt;
+       p = ast_channel_tech_pvt(chan);
 
        /* If there is no private structure, this channel is no longer alive */
        if (!p) {
@@ -20709,7 +20711,7 @@ static void handle_response_invite(struct sip_pvt *p, int resp, const char *rest
        int outgoing = ast_test_flag(&p->flags[0], SIP_OUTGOING);
        int res = 0;
        int xmitres = 0;
-       int reinvite = (p->owner && p->owner->_state == AST_STATE_UP);
+       int reinvite = (p->owner && ast_channel_state(p->owner) == AST_STATE_UP);
        char *p_hdrval;
        int rtn;
        struct ast_party_connected_line connected;
@@ -20808,7 +20810,7 @@ static void handle_response_invite(struct sip_pvt *p, int resp, const char *rest
                        }
                        sip_handle_cc(p, req, AST_CC_CCNR);
                        ast_queue_control(p->owner, AST_CONTROL_RINGING);
-                       if (p->owner->_state != AST_STATE_UP) {
+                       if (ast_channel_state(p->owner) != AST_STATE_UP) {
                                ast_setstate(p->owner, AST_STATE_RINGING);
                        }
                }
@@ -21143,7 +21145,7 @@ static void handle_response_invite(struct sip_pvt *p, int resp, const char *rest
        case 491: /* Pending */
                xmitres = transmit_request(p, SIP_ACK, seqno, XMIT_UNRELIABLE, FALSE);
                if (p->owner && !req->ignore) {
-                       if (p->owner->_state != AST_STATE_UP) {
+                       if (ast_channel_state(p->owner) != AST_STATE_UP) {
                                ast_queue_hangup_with_cause(p->owner, AST_CAUSE_CONGESTION);
                        } else {
                                /* This is a re-invite that failed. */
@@ -21772,21 +21774,22 @@ static void handle_response(struct sip_pvt *p, int resp, const char *rest, struc
        if (owner) {
                const char *rp = NULL, *rh = NULL;
 
-               owner->hangupcause = 0;
+               ast_channel_hangupcause_set(owner, 0);
                if (ast_test_flag(&p->flags[1], SIP_PAGE2_Q850_REASON) && (rh = sip_get_header(req, "Reason"))) {
                        rh = ast_skip_blanks(rh);
                        if (!strncasecmp(rh, "Q.850", 5)) {
+                               int cause = ast_channel_hangupcause(owner);
                                rp = strstr(rh, "cause=");
-                               if (rp && sscanf(rp + 6, "%30d", &owner->hangupcause) == 1) {
-                                       owner->hangupcause &= 0x7f;
+                               if (rp && sscanf(rp + 6, "%30d", &cause) == 1) {
+                                       ast_channel_hangupcause_set(owner, cause & 0x7f);
                                        if (req->debug)
-                                               ast_verbose("Using Reason header for cause code: %d\n", owner->hangupcause);
+                                               ast_verbose("Using Reason header for cause code: %d\n", ast_channel_hangupcause(owner));
                                }
                        }
                }
 
-               if (!owner->hangupcause)
-                       owner->hangupcause = hangup_sip2cause(resp);
+               if (!ast_channel_hangupcause(owner))
+                       ast_channel_hangupcause_set(owner, hangup_sip2cause(resp));
        }
 
        if (p->socket.type == SIP_TRANSPORT_UDP) {
@@ -22213,18 +22216,18 @@ static void *sip_park_thread(void *stuff)
 
        res = ast_park_call_exten(transferee, transferer, d->park_exten, d->park_context, 0, &ext);
 
-       sip_pvt_lock(transferer->tech_pvt);
+       sip_pvt_lock(ast_channel_tech_pvt(transferer));
 #ifdef WHEN_WE_KNOW_THAT_THE_CLIENT_SUPPORTS_MESSAGE
        if (res) {
-               destroy_msg_headers(transferer->tech_pvt);
-               ast_string_field_set(transferer->tech_pvt, msg_body, "Unable to park call.");
-               transmit_message(transferer->tech_pvt, 0, 0);
+               destroy_msg_headers(ast_channel_tech_pvt(transferer));
+               ast_string_field_set(ast_channel_tech_pvt(transferer), msg_body, "Unable to park call.");
+               transmit_message(ast_channel_tech_pvt(transferer), 0, 0);
        } else {
                /* Then tell the transferer what happened */
-               destroy_msg_headers(transferer->tech_pvt);
+               destroy_msg_headers(ast_channel_tech_pvt(transferer));
                sprintf(buf, "Call parked on extension '%d'.", ext);
-               ast_string_field_set(transferer->tech_pvt, msg_body, buf);
-               transmit_message(transferer->tech_pvt, 0, 0);
+               ast_string_field_set(ast_channel_tech_pvt(transferer), msg_body, buf);
+               transmit_message(ast_channel_tech_pvt(transferer), 0, 0);
        }
 #endif
 
@@ -22232,16 +22235,16 @@ static void *sip_park_thread(void *stuff)
        /* Transmit response to the REFER request */
        if (!res)       {
                /* Transfer succeeded */
-               append_history(transferer->tech_pvt, "SIPpark", "Parked call on %d", ext);
-               transmit_notify_with_sipfrag(transferer->tech_pvt, d->seqno, "200 OK", TRUE);
-               sip_pvt_unlock(transferer->tech_pvt);
-               transferer->hangupcause = AST_CAUSE_NORMAL_CLEARING;
+               append_history(ast_channel_tech_pvt(transferer), "SIPpark", "Parked call on %d", ext);
+               transmit_notify_with_sipfrag(ast_channel_tech_pvt(transferer), d->seqno, "200 OK", TRUE);
+               sip_pvt_unlock(ast_channel_tech_pvt(transferer));
+               ast_channel_hangupcause_set(transferer, AST_CAUSE_NORMAL_CLEARING);
                ast_hangup(transferer); /* This will cause a BYE */
                ast_debug(1, "SIP Call parked on extension '%d'\n", ext);
        } else {
-               transmit_notify_with_sipfrag(transferer->tech_pvt, d->seqno, "503 Service Unavailable", TRUE);
-               append_history(transferer->tech_pvt, "SIPpark", "Parking failed\n");
-               sip_pvt_unlock(transferer->tech_pvt);
+               transmit_notify_with_sipfrag(ast_channel_tech_pvt(transferer), d->seqno, "503 Service Unavailable", TRUE);
+               append_history(ast_channel_tech_pvt(transferer), "SIPpark", "Parking failed\n");
+               sip_pvt_unlock(ast_channel_tech_pvt(transferer));
                ast_debug(1, "SIP Call parked failed \n");
                /* Do not hangup call */
        }
@@ -22259,8 +22262,8 @@ static int sip_park(struct ast_channel *chan1, struct ast_channel *chan2, struct
        struct ast_channel *transferee, *transferer;
        pthread_t th;
 
-       transferee = ast_channel_alloc(0, AST_STATE_DOWN, 0, 0, ast_channel_accountcode(chan1), ast_channel_exten(chan1), ast_channel_context(chan1), ast_channel_linkedid(chan1), chan1->amaflags, "Parking/%s", ast_channel_name(chan1));
-       transferer = ast_channel_alloc(0, AST_STATE_DOWN, 0, 0, ast_channel_accountcode(chan2), ast_channel_exten(chan2), ast_channel_context(chan2), ast_channel_linkedid(chan2), chan2->amaflags, "SIPPeer/%s", ast_channel_name(chan2));
+       transferee = ast_channel_alloc(0, AST_STATE_DOWN, 0, 0, ast_channel_accountcode(chan1), ast_channel_exten(chan1), ast_channel_context(chan1), ast_channel_linkedid(chan1), ast_channel_amaflags(chan1), "Parking/%s", ast_channel_name(chan1));
+       transferer = ast_channel_alloc(0, AST_STATE_DOWN, 0, 0, ast_channel_accountcode(chan2), ast_channel_exten(chan2), ast_channel_context(chan2), ast_channel_linkedid(chan2), ast_channel_amaflags(chan2), "SIPPeer/%s", ast_channel_name(chan2));
        d = ast_calloc(1, sizeof(*d));
        if (!transferee || !transferer || !d) {
                if (transferee) {
@@ -22300,7 +22303,7 @@ static int sip_park(struct ast_channel *chan1, struct ast_channel *chan2, struct
        /* Setup the extensions and such */
        ast_channel_context_set(transferee, ast_channel_context(chan1));
        ast_channel_exten_set(transferee, ast_channel_exten(chan1));
-       transferee->priority = chan1->priority;
+       ast_channel_priority_set(transferee, ast_channel_priority(chan1));
 
        ast_do_masquerade(transferee);
 
@@ -22324,7 +22327,7 @@ static int sip_park(struct ast_channel *chan1, struct ast_channel *chan2, struct
        /* Setup the extensions and such */
        ast_channel_context_set(transferer, ast_channel_context(chan2));
        ast_channel_exten_set(transferer, ast_channel_exten(chan2));
-       transferer->priority = chan2->priority;
+       ast_channel_priority_set(transferer, ast_channel_priority(chan2));
 
        ast_do_masquerade(transferer);
 
@@ -22355,9 +22358,9 @@ static void *sip_pickup_thread(void *stuff)
        chan = stuff;
 
        if (ast_pickup_call(chan)) {
-               chan->hangupcause = AST_CAUSE_CALL_REJECTED;
+               ast_channel_hangupcause_set(chan, AST_CAUSE_CALL_REJECTED);
        } else {
-               chan->hangupcause = AST_CAUSE_NORMAL_CLEARING;
+               ast_channel_hangupcause_set(chan, AST_CAUSE_NORMAL_CLEARING);
        }
        ast_hangup(chan);
        ast_channel_unref(chan);
@@ -22389,10 +22392,10 @@ static int sip_pickup(struct ast_channel *chan)
 */
 static void ast_quiet_chan(struct ast_channel *chan)
 {
-       if (chan && chan->_state == AST_STATE_UP) {
+       if (chan && ast_channel_state(chan) == AST_STATE_UP) {
                if (ast_test_flag(chan, AST_FLAG_MOH))
                        ast_moh_stop(chan);
-               else if (chan->generatordata)
+               else if (ast_channel_generatordata(chan))
                        ast_deactivate_generator(chan);
        }
 }
@@ -22412,19 +22415,19 @@ static int attempt_transfer(struct sip_dual *transferer, struct sip_dual *target
           all channels to the transferer */
        ast_debug(4, "Sip transfer:--------------------\n");
        if (transferer->chan1)
-               ast_debug(4, "-- Transferer to PBX channel: %s State %s\n", ast_channel_name(transferer->chan1), ast_state2str(transferer->chan1->_state));
+               ast_debug(4, "-- Transferer to PBX channel: %s State %s\n", ast_channel_name(transferer->chan1), ast_state2str(ast_channel_state(transferer->chan1)));
        else
                ast_debug(4, "-- No transferer first channel - odd??? \n");
        if (target->chan1)
-               ast_debug(4, "-- Transferer to PBX second channel (target): %s State %s\n", ast_channel_name(target->chan1), ast_state2str(target->chan1->_state));
+               ast_debug(4, "-- Transferer to PBX second channel (target): %s State %s\n", ast_channel_name(target->chan1), ast_state2str(ast_channel_state(target->chan1)));
        else
                ast_debug(4, "-- No target first channel ---\n");
        if (transferer->chan2)
-               ast_debug(4, "-- Bridged call to transferee: %s State %s\n", ast_channel_name(transferer->chan2), ast_state2str(transferer->chan2->_state));
+               ast_debug(4, "-- Bridged call to transferee: %s State %s\n", ast_channel_name(transferer->chan2), ast_state2str(ast_channel_state(transferer->chan2)));
        else
                ast_debug(4, "-- No bridged call to transferee\n");
        if (target->chan2)
-               ast_debug(4, "-- Bridged call to transfer target: %s State %s\n", target->chan2 ? ast_channel_name(target->chan2) : "<none>", target->chan2 ? ast_state2str(target->chan2->_state) : "(none)");
+               ast_debug(4, "-- Bridged call to transfer target: %s State %s\n", target->chan2 ? ast_channel_name(target->chan2) : "<none>", target->chan2 ? ast_state2str(ast_channel_state(target->chan2)) : "(none)");
        else
                ast_debug(4, "-- No target second channel ---\n");
        ast_debug(4, "-- END Sip transfer:--------------------\n");
@@ -22816,7 +22819,7 @@ static int handle_invite_replaces(struct sip_pvt *p, struct sip_request *req, in
        struct ast_channel *targetcall;         /* The bridge to the take-over target */
 
        /* Check if we're in ring state */
-       if (replacecall->_state == AST_STATE_RING)
+       if (ast_channel_state(replacecall) == AST_STATE_RING)
                earlyreplace = 1;
 
        /* Check if we have a bridge */
@@ -22827,7 +22830,7 @@ static int handle_invite_replaces(struct sip_pvt *p, struct sip_request *req, in
                        oneleggedreplace = 1;
                }
        }
-       if (targetcall && targetcall->_state == AST_STATE_RINGING)
+       if (targetcall && ast_channel_state(targetcall) == AST_STATE_RINGING)
                ast_debug(4, "SIP transfer: Target channel is in ringing state\n");
 
        if (targetcall)
@@ -22912,13 +22915,13 @@ static int handle_invite_replaces(struct sip_pvt *p, struct sip_request *req, in
        }
        ast_channel_lock(c);
        if (earlyreplace || oneleggedreplace ) {
-               c->hangupcause = AST_CAUSE_SWITCH_CONGESTION;
+               ast_channel_hangupcause_set(c, AST_CAUSE_SWITCH_CONGESTION);
        }
        ast_setstate(c, AST_STATE_DOWN);
        ast_channel_unlock(c);
 
        /* The call should be down with no ast_channel, so hang it up */
-       c->tech_pvt = dialog_unref(c->tech_pvt, "unref dialog c->tech_pvt");
+       ast_channel_tech_pvt_set(c, dialog_unref(ast_channel_tech_pvt(c), "unref dialog c->tech_pvt"));
 
        /* c and c's tech pvt must be unlocked at this point for ast_hangup */
        ast_hangup(c);
@@ -23088,7 +23091,7 @@ static int handle_request_invite(struct sip_pvt *p, struct sip_request *req, int
        p->reqsipoptions = required_profile;
 
        /* Check if this is a loop */
-       if (ast_test_flag(&p->flags[0], SIP_OUTGOING) && p->owner && (p->invitestate != INV_TERMINATED && p->invitestate != INV_CONFIRMED) && p->owner->_state != AST_STATE_UP) {
+       if (ast_test_flag(&p->flags[0], SIP_OUTGOING) && p->owner && (p->invitestate != INV_TERMINATED && p->invitestate != INV_CONFIRMED) && ast_channel_state(p->owner) != AST_STATE_UP) {
                /* This is a call to ourself.  Send ourselves an error code and stop
                processing immediately, as SIP really has no good mechanism for
                being able to call yourself */
@@ -23287,7 +23290,7 @@ static int handle_request_invite(struct sip_pvt *p, struct sip_request *req, int
                        error = 1;
                }
 
-               if (!error && ast_strlen_zero(pickup.exten) && p->refer->refer_call->owner->_state != AST_STATE_RINGING && p->refer->refer_call->owner->_state != AST_STATE_RING && p->refer->refer_call->owner->_state != AST_STATE_UP) {
+               if (!error && ast_strlen_zero(pickup.exten) && ast_channel_state(p->refer->refer_call->owner) != AST_STATE_RINGING && ast_channel_state(p->refer->refer_call->owner) != AST_STATE_RING && ast_channel_state(p->refer->refer_call->owner) != AST_STATE_UP) {
                        ast_log(LOG_NOTICE, "Supervised transfer attempted to replace non-ringing or active call id (%s)!\n", replace_id);
                        transmit_response_reliable(p, "603 Declined (Replaces)", req);
                        error = 1;
@@ -23742,7 +23745,7 @@ static int handle_request_invite(struct sip_pvt *p, struct sip_request *req, int
 
 
        if (c) {        /* We have a call  -either a new call or an old one (RE-INVITE) */
-               enum ast_channel_state c_state = c->_state;
+               enum ast_channel_state c_state = ast_channel_state(c);
 
                if (c_state != AST_STATE_UP && reinvite &&
                        (p->invitestate == INV_TERMINATED || p->invitestate == INV_CONFIRMED)) {
@@ -23801,7 +23804,7 @@ static int handle_request_invite(struct sip_pvt *p, struct sip_request *req, int
                                        ast_log(LOG_WARNING, "Failed to start Group pickup by %s\n", ast_channel_name(c));
                                        transmit_response_reliable(p, "480 Temporarily Unavailable", req);
                                        sip_alreadygone(p);
-                                       c->hangupcause = AST_CAUSE_FAILURE;
+                                       ast_channel_hangupcause_set(c, AST_CAUSE_FAILURE);
 
                                        /* Unlock locks so ast_hangup can do its magic */
                                        ast_channel_unlock(c);
@@ -23852,7 +23855,7 @@ static int handle_request_invite(struct sip_pvt *p, struct sip_request *req, int
                        p->invitestate = INV_TERMINATED;
                        break;
                default:
-                       ast_log(LOG_WARNING, "Don't know how to handle INVITE in state %d\n", c->_state);
+                       ast_log(LOG_WARNING, "Don't know how to handle INVITE in state %d\n", ast_channel_state(c));
                        transmit_response(p, "100 Trying", req);
                        break;
                }
@@ -23948,11 +23951,11 @@ static int local_attended_transfer(struct sip_pvt *transferer, struct sip_dual *
        target.chan1 = targetcall_pvt->owner;                           /* Transferer to Asterisk */
        target.chan2 = ast_bridged_channel(targetcall_pvt->owner);      /* Asterisk to target */
 
-       if (!target.chan2 || !(target.chan2->_state == AST_STATE_UP || target.chan2->_state == AST_STATE_RINGING) ) {
+       if (!target.chan2 || !(ast_channel_state(target.chan2) == AST_STATE_UP || ast_channel_state(target.chan2) == AST_STATE_RINGING) ) {
                /* Wrong state of new channel */
                if (target.chan2)
-                       ast_debug(4, "SIP attended transfer: Error: Wrong state of target call: %s\n", ast_state2str(target.chan2->_state));
-               else if (target.chan1->_state != AST_STATE_RING)
+                       ast_debug(4, "SIP attended transfer: Error: Wrong state of target call: %s\n", ast_state2str(ast_channel_state(target.chan2)));
+               else if (ast_channel_state(target.chan1) != AST_STATE_RING)
                        ast_debug(4, "SIP attended transfer: Error: No target channel\n");
                else
                        ast_debug(4, "SIP attended transfer: Attempting transfer in ringing state\n");
@@ -24041,7 +24044,7 @@ static int local_attended_transfer(struct sip_pvt *transferer, struct sip_dual *
                        ast_indicate(target.chan2, AST_CONTROL_UNHOLD);
                }
 
-               if (current->chan2 && current->chan2->_state == AST_STATE_RING) {
+               if (current->chan2 && ast_channel_state(current->chan2) == AST_STATE_RING) {
                        ast_indicate(target.chan1, AST_CONTROL_RINGING);
                }
 
@@ -24515,7 +24518,7 @@ static int handle_request_refer(struct sip_pvt *p, struct sip_request *req, int
                        p->refer->status = REFER_200OK;
                }
                if (p->owner) {
-                       p->owner->hangupcause = AST_CAUSE_NORMAL_CLEARING;
+                       ast_channel_hangupcause_set(p->owner, AST_CAUSE_NORMAL_CLEARING);
                }
                append_history(p, "Xfer", "Refer succeeded.");
                ast_clear_flag(&p->flags[0], SIP_GOTREFER);
@@ -24553,7 +24556,7 @@ static int handle_request_cancel(struct sip_pvt *p, struct sip_request *req)
        check_via(p, req);
        sip_alreadygone(p);
 
-       if (p->owner && p->owner->_state == AST_STATE_UP) {
+       if (p->owner && ast_channel_state(p->owner) == AST_STATE_UP) {
                /* This call is up, cancel is ignored, we need a bye */
                transmit_response(p, "200 OK", req);
                ast_debug(1, "Got CANCEL on an answered call. Ignoring... \n");
@@ -24680,9 +24683,9 @@ static int handle_request_bye(struct sip_pvt *p, struct sip_request *req)
                }
 
                if (bridge) {
-                       struct sip_pvt *q = bridge->tech_pvt;
+                       struct sip_pvt *q = ast_channel_tech_pvt(bridge);
 
-                       if (IS_SIP_TECH(bridge->tech) && q && q->rtp) {
+                       if (IS_SIP_TECH(ast_channel_tech(bridge)) && q && q->rtp) {
                                ast_rtp_instance_set_stats_vars(bridge, q->rtp);
                        }
                        ast_channel_unlock(bridge);
@@ -26744,7 +26747,7 @@ static int check_rtp_timeout(struct sip_pvt *dialog, time_t t)
                return CMP_MATCH;
        }
        /* If the call is not in UP state return for later check. */
-       if (dialog->owner->_state != AST_STATE_UP) {
+       if (ast_channel_state(dialog->owner) != AST_STATE_UP) {
                return 0;
        }
 
@@ -26999,7 +27002,7 @@ static int proc_session_timer(const void *vp)
                goto return_unref;
        }
 
-       if ((p->stimer->st_active != TRUE) || (p->owner->_state != AST_STATE_UP)) {
+       if ((p->stimer->st_active != TRUE) || (ast_channel_state(p->owner) != AST_STATE_UP)) {
                goto return_unref;
        }
 
@@ -30138,7 +30141,7 @@ static struct ast_udptl *sip_get_udptl_peer(struct ast_channel *chan)
        struct sip_pvt *p;
        struct ast_udptl *udptl = NULL;
        
-       p = chan->tech_pvt;
+       p = ast_channel_tech_pvt(chan);
        if (!p) {
                return NULL;
        }
@@ -30159,7 +30162,7 @@ static int sip_set_udptl_peer(struct ast_channel *chan, struct ast_udptl *udptl)
 
        /* Lock the channel and the private safely. */
        ast_channel_lock(chan);
-       p = chan->tech_pvt;
+       p = ast_channel_tech_pvt(chan);
        if (!p) {
                ast_channel_unlock(chan);
                return -1;
@@ -30201,7 +30204,7 @@ static enum ast_rtp_glue_result sip_get_rtp_peer(struct ast_channel *chan, struc
        struct sip_pvt *p = NULL;
        enum ast_rtp_glue_result res = AST_RTP_GLUE_RESULT_LOCAL;
 
-       if (!(p = chan->tech_pvt)) {
+       if (!(p = ast_channel_tech_pvt(chan))) {
                return AST_RTP_GLUE_RESULT_FORBID;
        }
 
@@ -30239,7 +30242,7 @@ static enum ast_rtp_glue_result sip_get_vrtp_peer(struct ast_channel *chan, stru
        struct sip_pvt *p = NULL;
        enum ast_rtp_glue_result res = AST_RTP_GLUE_RESULT_FORBID;
 
-       if (!(p = chan->tech_pvt)) {
+       if (!(p = ast_channel_tech_pvt(chan))) {
                return AST_RTP_GLUE_RESULT_FORBID;
        }
 
@@ -30269,7 +30272,7 @@ static enum ast_rtp_glue_result sip_get_trtp_peer(struct ast_channel *chan, stru
        struct sip_pvt *p = NULL;
        enum ast_rtp_glue_result res = AST_RTP_GLUE_RESULT_FORBID;
 
-       if (!(p = chan->tech_pvt)) {
+       if (!(p = ast_channel_tech_pvt(chan))) {
                return AST_RTP_GLUE_RESULT_FORBID;
        }
 
@@ -30301,7 +30304,7 @@ static int sip_set_rtp_peer(struct ast_channel *chan, struct ast_rtp_instance *i
 
        /* Lock the channel and the private safely. */
        ast_channel_lock(chan);
-       p = chan->tech_pvt;
+       p = ast_channel_tech_pvt(chan);
        if (!p) {
                ast_channel_unlock(chan);
                return -1;
@@ -30363,7 +30366,7 @@ static int sip_set_rtp_peer(struct ast_channel *chan, struct ast_rtp_instance *i
                changed = 1;
        }
        if (changed && !ast_test_flag(&p->flags[0], SIP_GOTREFER) && !ast_test_flag(&p->flags[0], SIP_DEFER_BYE_ON_TRANSFER)) {
-               if (chan->_state != AST_STATE_UP) {     /* We are in early state */
+               if (ast_channel_state(chan) != AST_STATE_UP) {     /* We are in early state */
                        if (p->do_history)
                                append_history(p, "ExtInv", "Initial invite sent with remote bridge proposal.");
                        ast_debug(1, "Early remote bridge setting SIP '%s' - Sending media to %s\n", p->callid, ast_sockaddr_stringify(instance ? &p->redirip : &p->ourip));
@@ -30385,7 +30388,7 @@ static int sip_set_rtp_peer(struct ast_channel *chan, struct ast_rtp_instance *i
 
 static void sip_get_codec(struct ast_channel *chan, struct ast_format_cap *result)
 {
-       struct sip_pvt *p = chan->tech_pvt;
+       struct sip_pvt *p = ast_channel_tech_pvt(chan);
        ast_format_cap_append(result, ast_format_cap_is_empty(p->peercaps) ? p->caps : p->peercaps);
 }
 
@@ -30413,12 +30416,12 @@ static int sip_dtmfmode(struct ast_channel *chan, const char *data)
                return 0;
        }
        ast_channel_lock(chan);
-       if (!IS_SIP_TECH(chan->tech)) {
+       if (!IS_SIP_TECH(ast_channel_tech(chan))) {
                ast_log(LOG_WARNING, "Call this application only on SIP incoming calls\n");
                ast_channel_unlock(chan);
                return 0;
        }
-       p = chan->tech_pvt;
+       p = ast_channel_tech_pvt(chan);
        if (!p) {
                ast_channel_unlock(chan);
                return 0;
index 0bfce4dfd99edf14366a0c6406916e9531785d4e..a63fb6ec64304f50a409856c87d8743d68e1b9f0 100644 (file)
@@ -3154,7 +3154,7 @@ static void update_connectedline(struct skinny_subchannel *sub, const void *data
        }
        
        send_callinfo(sub);
-       if (sub->owner->_state == AST_STATE_UP) {
+       if (ast_channel_state(sub->owner) == AST_STATE_UP) {
                transmit_callstate(d, l->instance, sub->callid, SKINNY_CONNECTED);
                transmit_displaypromptstatus(d, "Connected", 0, l->instance, sub->callid);
        } else {
@@ -3220,7 +3220,7 @@ static enum ast_rtp_glue_result skinny_get_vrtp_peer(struct ast_channel *c, stru
 {
        struct skinny_subchannel *sub = NULL;
 
-       if (!(sub = c->tech_pvt) || !(sub->vrtp))
+       if (!(sub = ast_channel_tech_pvt(c)) || !(sub->vrtp))
                return AST_RTP_GLUE_RESULT_FORBID;
 
        ao2_ref(sub->vrtp, +1);
@@ -3239,7 +3239,7 @@ static enum ast_rtp_glue_result skinny_get_rtp_peer(struct ast_channel *c, struc
                ast_verb(1, "skinny_get_rtp_peer() Channel = %s\n", ast_channel_name(c));
 
 
-       if (!(sub = c->tech_pvt))
+       if (!(sub = ast_channel_tech_pvt(c)))
                return AST_RTP_GLUE_RESULT_FORBID;
 
        ast_mutex_lock(&sub->lock);
@@ -3277,9 +3277,9 @@ static int skinny_set_rtp_peer(struct ast_channel *c, struct ast_rtp_instance *r
        struct ast_sockaddr them_tmp;
        struct ast_sockaddr us_tmp;
        
-       sub = c->tech_pvt;
+       sub = ast_channel_tech_pvt(c);
 
-       if (c->_state != AST_STATE_UP)
+       if (ast_channel_state(c) != AST_STATE_UP)
                return 0;
 
        if (!sub) {
@@ -4222,7 +4222,7 @@ static void start_rtp(struct skinny_subchannel *sub)
 static void *skinny_newcall(void *data)
 {
        struct ast_channel *c = data;
-       struct skinny_subchannel *sub = c->tech_pvt;
+       struct skinny_subchannel *sub = ast_channel_tech_pvt(c);
        struct skinny_line *l = sub->line;
        struct skinny_device *d = l->device;
        int res = 0;
@@ -4255,7 +4255,7 @@ static void *skinny_newcall(void *data)
 static void *skinny_ss(void *data)
 {
        struct ast_channel *c = data;
-       struct skinny_subchannel *sub = c->tech_pvt;
+       struct skinny_subchannel *sub = ast_channel_tech_pvt(c);
        struct skinny_line *l = sub->line;
        struct skinny_device *d = l->device;
        int len = 0;
@@ -4305,7 +4305,7 @@ static void *skinny_ss(void *data)
                                        ast_safe_sleep(c, 1000);
                                        len = 0;
                                        l->getforward = 0;
-                                       if (sub->owner && sub->owner->_state != AST_STATE_UP) {
+                                       if (sub->owner && ast_channel_state(sub->owner) != AST_STATE_UP) {
                                                ast_indicate(c, -1);
                                                ast_hangup(c);
                                        }
@@ -4326,7 +4326,7 @@ static void *skinny_ss(void *data)
                        if (d->hookstate == SKINNY_OFFHOOK) {
                                transmit_start_tone(d, SKINNY_REORDER, l->instance, sub->callid);
                        }
-                       if (sub->owner && sub->owner->_state != AST_STATE_UP) {
+                       if (sub->owner && ast_channel_state(sub->owner) != AST_STATE_UP) {
                                ast_indicate(c, -1);
                                ast_hangup(c);
                        }
@@ -4367,7 +4367,7 @@ static int skinny_autoanswer_cb(const void *data)
 static int skinny_call(struct ast_channel *ast, const char *dest, int timeout)
 {
        int res = 0;
-       struct skinny_subchannel *sub = ast->tech_pvt;
+       struct skinny_subchannel *sub = ast_channel_tech_pvt(ast);
        struct skinny_line *l = sub->line;
        struct skinny_device *d = l->device;
        struct ast_var_t *current;
@@ -4378,7 +4378,7 @@ static int skinny_call(struct ast_channel *ast, const char *dest, int timeout)
                return -1;
        }
 
-       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, "skinny_call called on %s, neither down nor reserved\n", ast_channel_name(ast));
                return -1;
        }
@@ -4434,7 +4434,7 @@ static int skinny_call(struct ast_channel *ast, const char *dest, int timeout)
 
 static int skinny_hangup(struct ast_channel *ast)
 {
-       struct skinny_subchannel *sub = ast->tech_pvt;
+       struct skinny_subchannel *sub = ast_channel_tech_pvt(ast);
 
        if (!sub) {
                ast_debug(1, "Asked to hangup channel not connected\n");
@@ -4448,7 +4448,7 @@ static int skinny_hangup(struct ast_channel *ast)
 
        ast_mutex_lock(&sub->lock);
        sub->owner = NULL;
-       ast->tech_pvt = NULL;
+       ast_channel_tech_pvt_set(ast, NULL);
        if (sub->rtp) {
                ast_rtp_instance_destroy(sub->rtp);
                sub->rtp = NULL;
@@ -4462,7 +4462,7 @@ static int skinny_hangup(struct ast_channel *ast)
 static int skinny_answer(struct ast_channel *ast)
 {
        int res = 0;
-       struct skinny_subchannel *sub = ast->tech_pvt;
+       struct skinny_subchannel *sub = ast_channel_tech_pvt(ast);
        struct skinny_line *l = sub->line;
        struct skinny_device *d = l->device;
 
@@ -4496,7 +4496,7 @@ static struct ast_frame *skinny_rtp_read(struct skinny_subchannel *sub)
                return &ast_null_frame;
        }
 
-       switch(ast->fdno) {
+       switch(ast_channel_fdno(ast)) {
        case 0:
                f = ast_rtp_instance_read(sub->rtp, 0); /* RTP Audio */
                break;
@@ -4522,9 +4522,9 @@ static struct ast_frame *skinny_rtp_read(struct skinny_subchannel *sub)
        if (ast) {
                /* We already hold the channel lock */
                if (f->frametype == AST_FRAME_VOICE) {
-                       if (!(ast_format_cap_iscompatible(ast->nativeformats, &f->subclass.format))) {
+                       if (!(ast_format_cap_iscompatible(ast_channel_nativeformats(ast), &f->subclass.format))) {
                                ast_debug(1, "Oooh, format changed to %s\n", ast_getformatname(&f->subclass.format));
-                               ast_format_cap_set(ast->nativeformats, &f->subclass.format);
+                               ast_format_cap_set(ast_channel_nativeformats(ast), &f->subclass.format);
                                ast_set_read_format(ast, &ast->readformat);
                                ast_set_write_format(ast, &ast->writeformat);
                        }
@@ -4536,7 +4536,7 @@ static struct ast_frame *skinny_rtp_read(struct skinny_subchannel *sub)
 static struct ast_frame *skinny_read(struct ast_channel *ast)
 {
        struct ast_frame *fr;
-       struct skinny_subchannel *sub = ast->tech_pvt;
+       struct skinny_subchannel *sub = ast_channel_tech_pvt(ast);
        ast_mutex_lock(&sub->lock);
        fr = skinny_rtp_read(sub);
        ast_mutex_unlock(&sub->lock);
@@ -4545,7 +4545,7 @@ static struct ast_frame *skinny_read(struct ast_channel *ast)
 
 static int skinny_write(struct ast_channel *ast, struct ast_frame *frame)
 {
-       struct skinny_subchannel *sub = ast->tech_pvt;
+       struct skinny_subchannel *sub = ast_channel_tech_pvt(ast);
        int res = 0;
        if (frame->frametype != AST_FRAME_VOICE) {
                if (frame->frametype == AST_FRAME_IMAGE) {
@@ -4555,11 +4555,11 @@ static int skinny_write(struct ast_channel *ast, struct ast_frame *frame)
                        return 0;
                }
        } else {
-               if (!(ast_format_cap_iscompatible(ast->nativeformats, &frame->subclass.format))) {
+               if (!(ast_format_cap_iscompatible(ast_channel_nativeformats(ast), &frame->subclass.format))) {
                        char buf[256];
                        ast_log(LOG_WARNING, "Asked to transmit frame type %s, while native formats is %s (read/write = %s/%s)\n",
                                ast_getformatname(&frame->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));
                        return -1;
@@ -4577,7 +4577,7 @@ static int skinny_write(struct ast_channel *ast, struct ast_frame *frame)
 
 static int skinny_fixup(struct ast_channel *oldchan, struct ast_channel *newchan)
 {
-       struct skinny_subchannel *sub = newchan->tech_pvt;
+       struct skinny_subchannel *sub = ast_channel_tech_pvt(newchan);
        ast_log(LOG_NOTICE, "skinny_fixup(%s, %s)\n", ast_channel_name(oldchan), ast_channel_name(newchan));
        if (sub->owner != oldchan) {
                ast_log(LOG_WARNING, "old channel wasn't %p but was %p\n", oldchan, sub->owner);
@@ -4726,9 +4726,9 @@ static int skinny_transfer(struct skinny_subchannel *sub)
                        if (ast_bridged_channel(xferee->owner)) {
                                ast_queue_control(xferee->owner, AST_CONTROL_UNHOLD);
                        }
-                       if (xferor->owner->_state == AST_STATE_RING) {
+                       if (ast_channel_state(xferor->owner) == AST_STATE_RING) {
                                /* play ringing inband */
-                               if ((ts = ast_get_indication_tone(xferor->owner->zone, "ring"))) {
+                               if ((ts = ast_get_indication_tone(ast_channel_zone(xferor->owner), "ring"))) {
                                        ast_playtones_start(xferor->owner, 0, ts->data, 1);
                                        ts = ast_tone_zone_sound_unref(ts);
                                }
@@ -4743,9 +4743,9 @@ static int skinny_transfer(struct skinny_subchannel *sub)
                        }
                } else if (ast_bridged_channel(xferee->owner)) {
                        ast_queue_control(xferee->owner, AST_CONTROL_UNHOLD);
-                       if (xferor->owner->_state == AST_STATE_RING) {
+                       if (ast_channel_state(xferor->owner) == AST_STATE_RING) {
                                /* play ringing inband */
-                               if ((ts = ast_get_indication_tone(xferor->owner->zone, "ring"))) {
+                               if ((ts = ast_get_indication_tone(ast_channel_zone(xferor->owner), "ring"))) {
                                        ast_playtones_start(xferor->owner, 0, ts->data, 1);
                                        ts = ast_tone_zone_sound_unref(ts);
                                }
@@ -4769,7 +4769,7 @@ static int skinny_transfer(struct skinny_subchannel *sub)
 
 static int skinny_indicate(struct ast_channel *ast, int ind, const void *data, size_t datalen)
 {
-       struct skinny_subchannel *sub = ast->tech_pvt;
+       struct skinny_subchannel *sub = ast_channel_tech_pvt(ast);
        struct skinny_line *l = sub->line;
        struct skinny_device *d = l->device;
        struct skinnysession *s = d->session;
@@ -4880,25 +4880,25 @@ static struct ast_channel *skinny_new(struct skinny_line *l, struct skinny_subli
                        AST_LIST_INSERT_HEAD(&l->sub, sub, list);
                        //l->activesub = sub;
                }
-               tmp->tech = &skinny_tech;
-               tmp->tech_pvt = sub;
-               ast_format_cap_copy(tmp->nativeformats, l->cap);
-               if (ast_format_cap_is_empty(tmp->nativeformats)) {
+               ast_channel_tech_set(tmp, &skinny_tech);
+               ast_channel_tech_pvt_set(tmp, sub);
+               ast_format_cap_copy(ast_channel_nativeformats(tmp), l->cap);
+               if (ast_format_cap_is_empty(ast_channel_nativeformats(tmp))) {
                        // Should throw an error
-                       ast_format_cap_copy(tmp->nativeformats, default_cap);
+                       ast_format_cap_copy(ast_channel_nativeformats(tmp), default_cap);
                }
-               ast_best_codec(tmp->nativeformats, &tmpfmt);
+               ast_best_codec(ast_channel_nativeformats(tmp), &tmpfmt);
                if (skinnydebug) {
                        char buf[256];
                        ast_verb(1, "skinny_new: tmp->nativeformats=%s fmt=%s\n",
-                               ast_getformatname_multiple(buf, sizeof(buf), tmp->nativeformats),
+                               ast_getformatname_multiple(buf, sizeof(buf), ast_channel_nativeformats(tmp)),
                                ast_getformatname(&tmpfmt));
                }
                if (sub->rtp) {
                        ast_channel_set_fd(tmp, 0, ast_rtp_instance_fd(sub->rtp, 0));
                }
                if (state == AST_STATE_RING) {
-                       tmp->rings = 1;
+                       ast_channel_rings_set(tmp, 1);
                }
                ast_format_copy(&tmp->writeformat, &tmpfmt);
                ast_format_copy(&tmp->rawwriteformat, &tmpfmt);
@@ -4912,7 +4912,7 @@ static struct ast_channel *skinny_new(struct skinny_line *l, struct skinny_subli
                if (!ast_strlen_zero(l->parkinglot))
                        ast_channel_parkinglot_set(tmp, l->parkinglot);
                if (l->amaflags)
-                       tmp->amaflags = l->amaflags;
+                       ast_channel_amaflags_set(tmp, l->amaflags);
 
                ast_module_ref(ast_module_info->self);
                tmp->callgroup = l->callgroup;
@@ -4941,8 +4941,8 @@ static struct ast_channel *skinny_new(struct skinny_line *l, struct skinny_subli
                        tmp->caller.ani.number.str = ast_strdup(l->cid_num);
                }
 
-               tmp->priority = 1;
-               tmp->adsicpe = AST_ADSI_UNAVAILABLE;
+               ast_channel_priority_set(tmp, 1);
+               ast_channel_adsicpe_set(tmp, AST_ADSI_UNAVAILABLE);
 
                if (sub->rtp)
                        ast_jb_configure(tmp, &global_jbconf);
@@ -5101,7 +5101,7 @@ static void setsubstate(struct skinny_subchannel *sub, int state)
                        if (sub->substate == SUBSTATE_DIALING || sub->substate == SUBSTATE_RINGOUT) {
                                transmit_dialednumber(d, l->lastnumberdialed, l->instance, sub->callid);
                        }
-                       if (sub->owner->_state != AST_STATE_UP) {
+                       if (ast_channel_state(sub->owner) != AST_STATE_UP) {
                                ast_setstate(sub->owner, AST_STATE_UP);
                        }
                        sub->substate = SUBSTATE_CONNECTED;
@@ -5317,7 +5317,7 @@ static void setsubstate(struct skinny_subchannel *sub, int state)
                if (sub->substate == SUBSTATE_DIALING || sub->substate == SUBSTATE_RINGOUT) {
                        transmit_dialednumber(d, l->lastnumberdialed, l->instance, sub->callid);
                }
-               if (sub->owner->_state != AST_STATE_UP) {
+               if (ast_channel_state(sub->owner) != AST_STATE_UP) {
                        ast_setstate(sub->owner, AST_STATE_UP);
                }
                sub->substate = SUBSTATE_CONNECTED;
@@ -5517,7 +5517,7 @@ static int handle_transfer_button(struct skinny_subchannel *sub)
                }
                c = skinny_new(l, NULL, AST_STATE_DOWN, NULL, SKINNY_OUTGOING);
                if (c) {
-                       newsub = c->tech_pvt;
+                       newsub = ast_channel_tech_pvt(c);
                        /* point the sub and newsub at each other so we know they are related */
                        newsub->related = sub;
                        sub->related = newsub;
@@ -5535,7 +5535,7 @@ static int handle_transfer_button(struct skinny_subchannel *sub)
                        /* we really need some indications */
                } else {
                        /* We were doing attended transfer */
-                       if (sub->owner->_state == AST_STATE_DOWN || sub->related->owner->_state == AST_STATE_DOWN) {
+                       if (ast_channel_state(sub->owner) == AST_STATE_DOWN || ast_channel_state(sub->related->owner) == AST_STATE_DOWN) {
                                /* one of the subs so we cant transfer yet, toggle blindxfer on */
                                sub->blindxfer = 1;
                                sub->related->blindxfer = 1;
@@ -5574,7 +5574,7 @@ static int handle_callforward_button(struct skinny_subchannel *sub, int cfwdtype
                transmit_selectsoftkeys(d, 0, 0, KEYDEF_ONHOOK);
                transmit_activatecallplane(d, l);
                transmit_displaynotify(d, "CFwd disabled", 10);
-               if (sub->owner && sub->owner->_state != AST_STATE_UP) {
+               if (sub->owner && ast_channel_state(sub->owner) != AST_STATE_UP) {
                        ast_indicate(c, -1);
                        ast_hangup(c);
                }
@@ -5639,7 +5639,7 @@ static int handle_keypad_button_message(struct skinny_req *req, struct skinnyses
 
        l = sub->line;
        if (sub->owner) {
-               if (sub->owner->_state == 0) {
+               if (ast_channel_state(sub->owner) == 0) {
                        f.frametype = AST_FRAME_DTMF_BEGIN;
                        ast_queue_frame(sub->owner, &f);
                }
@@ -5648,7 +5648,7 @@ static int handle_keypad_button_message(struct skinny_req *req, struct skinnyses
                ast_queue_frame(sub->owner, &f);
                /* XXX This seriously needs to be fixed */
                if (AST_LIST_NEXT(sub, list) && AST_LIST_NEXT(sub, list)->owner) {
-                       if (sub->owner->_state == 0) {
+                       if (ast_channel_state(sub->owner) == 0) {
                                f.frametype = AST_FRAME_DTMF_BEGIN;
                                ast_queue_frame(AST_LIST_NEXT(sub, list)->owner, &f);
                        }
@@ -5707,7 +5707,7 @@ static int handle_stimulus_message(struct skinny_req *req, struct skinnysession
                if (!c) {
                        ast_log(LOG_WARNING, "Unable to create channel for %s@%s\n", l->name, d->name);
                } else {
-                       sub = c->tech_pvt;
+                       sub = ast_channel_tech_pvt(c);
                        l = sub->line;
                        dialandactivatesub(sub, l->lastnumberdialed);
                }
@@ -5730,7 +5730,7 @@ static int handle_stimulus_message(struct skinny_req *req, struct skinnysession
                if (!c) {
                        ast_log(LOG_WARNING, "Unable to create channel for %s@%s\n", l->name, d->name);
                } else {
-                       sub = c->tech_pvt;
+                       sub = ast_channel_tech_pvt(c);
                        dialandactivatesub(sub, sd->exten);
                }
            }
@@ -5769,7 +5769,7 @@ static int handle_stimulus_message(struct skinny_req *req, struct skinnysession
                        break;
                }
                
-               sub = c->tech_pvt;
+               sub = ast_channel_tech_pvt(c);
                if (sub->substate == SUBSTATE_UNSET || sub->substate == SUBSTATE_OFFHOOK){
                        dialandactivatesub(sub, l->vmexten);
                }
@@ -5782,7 +5782,7 @@ static int handle_stimulus_message(struct skinny_req *req, struct skinnysession
                if (skinnydebug)
                        ast_verb(1, "Received Stimulus: Park Call(%d/%d)\n", instance, callreference);
 
-               if ((sub && sub->owner) && (sub->owner->_state ==  AST_STATE_UP)){
+               if ((sub && sub->owner) && (ast_channel_state(sub->owner) ==  AST_STATE_UP)){
                        c = sub->owner;
                        if (ast_bridged_channel(c)) {
                                if (!ast_masq_park_call(ast_bridged_channel(c), c, 0, &extout)) {
@@ -5829,7 +5829,7 @@ static int handle_stimulus_message(struct skinny_req *req, struct skinnysession
                if (!c) {
                        ast_log(LOG_WARNING, "Unable to create channel for %s@%s\n", l->name, d->name);
                } else {
-                       sub = c->tech_pvt;
+                       sub = ast_channel_tech_pvt(c);
                        handle_callforward_button(sub, SKINNY_CFWD_ALL);
                }
                break;
@@ -5846,7 +5846,7 @@ static int handle_stimulus_message(struct skinny_req *req, struct skinnysession
                if (!c) {
                        ast_log(LOG_WARNING, "Unable to create channel for %s@%s\n", l->name, d->name);
                } else {
-                       sub = c->tech_pvt;
+                       sub = ast_channel_tech_pvt(c);
                        handle_callforward_button(sub, SKINNY_CFWD_BUSY);
                }
                break;
@@ -5901,7 +5901,7 @@ static int handle_stimulus_message(struct skinny_req *req, struct skinnysession
                        } else {
                                c = skinny_new(l, NULL, AST_STATE_DOWN, NULL, SKINNY_OUTGOING);
                                if (c) {
-                                       setsubstate(c->tech_pvt, SUBSTATE_OFFHOOK);
+                                       setsubstate(ast_channel_tech_pvt(c), SUBSTATE_OFFHOOK);
                                } else {
                                        ast_log(LOG_WARNING, "Unable to create channel for %s@%s\n", l->name, d->name);
                                }
@@ -5976,7 +5976,7 @@ static int handle_offhook_message(struct skinny_req *req, struct skinnysession *
                } else {
                        c = skinny_new(l, NULL, AST_STATE_DOWN, NULL, SKINNY_OUTGOING);
                        if (c) {
-                               setsubstate(c->tech_pvt, SUBSTATE_OFFHOOK);
+                               setsubstate(ast_channel_tech_pvt(c), SUBSTATE_OFFHOOK);
                        } else {
                                ast_log(LOG_WARNING, "Unable to create channel for %s@%s\n", l->name, d->name);
                        }
@@ -6017,7 +6017,7 @@ static int handle_onhook_message(struct skinny_req *req, struct skinnysession *s
                return 0;
        }
 
-       if (l->transfer && sub->xferor && sub->owner->_state >= AST_STATE_RING) {
+       if (l->transfer && sub->xferor && ast_channel_state(sub->owner) >= AST_STATE_RING) {
                /* We're allowed to transfer, we have two active calls and
                   we made at least one of the calls.  Let's try and transfer */
                handle_transfer_button(sub);
@@ -6323,7 +6323,7 @@ static int handle_enbloc_call_message(struct skinny_req *req, struct skinnysessi
        } else {
                d->hookstate = SKINNY_OFFHOOK;
 
-               sub = c->tech_pvt;
+               sub = ast_channel_tech_pvt(c);
                dialandactivatesub(sub, req->data.enbloccallmessage.calledParty);
        }
        
@@ -6387,7 +6387,7 @@ static int handle_soft_key_event_message(struct skinny_req *req, struct skinnyse
                if (!c) {
                        ast_log(LOG_WARNING, "Unable to create channel for %s@%s\n", l->name, d->name);
                } else {
-                       sub = c->tech_pvt;
+                       sub = ast_channel_tech_pvt(c);
                        dialandactivatesub(sub, l->lastnumberdialed);
                }
                break;
@@ -6397,7 +6397,7 @@ static int handle_soft_key_event_message(struct skinny_req *req, struct skinnyse
 
                /* New Call ALWAYS gets a new sub-channel */
                c = skinny_new(l, NULL, AST_STATE_DOWN, NULL, SKINNY_OUTGOING);
-               sub = c->tech_pvt;
+               sub = ast_channel_tech_pvt(c);
 
                if (!c) {
                        ast_log(LOG_WARNING, "Unable to create channel for %s@%s\n", l->name, d->name);
@@ -6458,7 +6458,7 @@ static int handle_soft_key_event_message(struct skinny_req *req, struct skinnyse
                if (!c) {
                        ast_log(LOG_WARNING, "Unable to create channel for %s@%s\n", l->name, d->name);
                } else {
-                       sub = c->tech_pvt;
+                       sub = ast_channel_tech_pvt(c);
                        l->activesub = sub;
                        handle_callforward_button(sub, SKINNY_CFWD_ALL);
                }
@@ -6476,7 +6476,7 @@ static int handle_soft_key_event_message(struct skinny_req *req, struct skinnyse
                if (!c) {
                        ast_log(LOG_WARNING, "Unable to create channel for %s@%s\n", l->name, d->name);
                } else {
-                       sub = c->tech_pvt;
+                       sub = ast_channel_tech_pvt(c);
                        l->activesub = sub;
                        handle_callforward_button(sub, SKINNY_CFWD_BUSY);
                }
@@ -6509,7 +6509,7 @@ static int handle_soft_key_event_message(struct skinny_req *req, struct skinnyse
                if (skinnydebug)
                        ast_verb(1, "Received Softkey Event: End Call(%d/%d)\n", instance, callreference);
 
-               if (l->transfer && sub && sub->xferor && sub->owner->_state >= AST_STATE_RING) {
+               if (l->transfer && sub && sub->xferor && ast_channel_state(sub->owner) >= AST_STATE_RING) {
                        /* We're allowed to transfer, we have two active calls and
                            we made at least one of the calls.  Let's try and transfer */
                        handle_transfer_button(sub);
@@ -6546,7 +6546,7 @@ static int handle_soft_key_event_message(struct skinny_req *req, struct skinnyse
                        if (!c) {
                                ast_log(LOG_WARNING, "Unable to create channel for %s@%s\n", l->name, d->name);
                        } else {
-                               sub = c->tech_pvt;
+                               sub = ast_channel_tech_pvt(c);
                                dialandactivatesub(sub, subline->exten);
                        }
                }
@@ -6583,7 +6583,7 @@ static int handle_soft_key_event_message(struct skinny_req *req, struct skinnyse
                if (skinnydebug)
                        ast_verb(1, "Received Softkey Event: Park Call(%d/%d)\n", instance, callreference);
 
-               if ((sub && sub->owner) && (sub->owner->_state ==  AST_STATE_UP)){
+               if ((sub && sub->owner) && (ast_channel_state(sub->owner) ==  AST_STATE_UP)){
                        c = sub->owner;
                        if (ast_bridged_channel(c)) {
                                if (!ast_masq_park_call(ast_bridged_channel(c), c, 0, &extout)) {
@@ -6611,7 +6611,7 @@ static int handle_soft_key_event_message(struct skinny_req *req, struct skinnyse
                        if (!c) {
                                ast_log(LOG_WARNING, "Unable to create channel for %s@%s\n", l->name, d->name);
                        } else {
-                               sub = c->tech_pvt;
+                               sub = ast_channel_tech_pvt(c);
                                dialandactivatesub(sub, subline->exten);
                        }
                }
@@ -6691,7 +6691,7 @@ static int handle_message(struct skinny_req *req, struct skinnysession *s)
                        sub = d->activeline->activesub;
                }
 
-               if (sub && ((sub->owner && sub->owner->_state <  AST_STATE_UP) || sub->substate == SUBSTATE_HOLD)) {
+               if (sub && ((sub->owner && ast_channel_state(sub->owner) <  AST_STATE_UP) || sub->substate == SUBSTATE_HOLD)) {
                        char dgt;
                        int digit = letohl(req->data.keypad.button);
 
@@ -7105,7 +7105,7 @@ static struct ast_channel *skinny_request(const char *type, struct ast_format_ca
        if (!tmpc) {
                ast_log(LOG_WARNING, "Unable to make channel for '%s'\n", tmp);
        } else if (subline) {
-               struct skinny_subchannel *sub = tmpc->tech_pvt;
+               struct skinny_subchannel *sub = ast_channel_tech_pvt(tmpc);
                subline->sub = sub;
                subline->calldirection = SKINNY_INCOMING;
                subline->substate = SUBSTATE_UNSET;
index 6eca792ec2dbc75461c52310b14cc437b580a465..a059d5cb1488835168a2396a76a55f260ebd532a 100644 (file)
@@ -1957,19 +1957,19 @@ static int attempt_transfer(struct unistim_subchannel *p1, struct unistim_subcha
                   ast_quiet_chan(peerc);
                   ast_quiet_chan(peerd); */
 
-               if (peera->cdr && peerb->cdr) {
-                       peerb->cdr = ast_cdr_append(peerb->cdr, peera->cdr);
-               } else if (peera->cdr) {
-                       peerb->cdr = peera->cdr;
+               if (ast_channel_cdr(peera) && ast_channel_cdr(peerb)) {
+                       ast_channel_cdr_set(peerb, ast_cdr_append(ast_channel_cdr(peerb), ast_channel_cdr(peera)));
+               } else if (ast_channel_cdr(peera)) {
+                       ast_channel_cdr_set(peerb, ast_channel_cdr(peera));
                }
-               peera->cdr = NULL;
+               ast_channel_cdr_set(peera, NULL);
 
-               if (peerb->cdr && peerc->cdr) {
-                       peerb->cdr = ast_cdr_append(peerb->cdr, peerc->cdr);
-               } else if (peerc->cdr) {
-                       peerb->cdr = peerc->cdr;
+               if (ast_channel_cdr(peerb) && ast_channel_cdr(peerc)) {
+                       ast_channel_cdr_set(peerb, ast_cdr_append(ast_channel_cdr(peerb), ast_channel_cdr(peerc)));
+               } else if (ast_channel_cdr(peerc)) {
+                       ast_channel_cdr_set(peerb, ast_channel_cdr(peerc));
                }
-               peerc->cdr = NULL;
+               ast_channel_cdr_set(peerc, NULL);
 
                if (ast_channel_masquerade(peerb, peerc)) {
                        ast_log(LOG_WARNING, "Failed to masquerade %s into %s\n", ast_channel_name(peerb),
@@ -2050,7 +2050,7 @@ static void IgnoreCall(struct unistimsession *pte)
 static void *unistim_ss(void *data)
 {
        struct ast_channel *chan = data;
-       struct unistim_subchannel *sub = chan->tech_pvt;
+       struct unistim_subchannel *sub = ast_channel_tech_pvt(chan);
        struct unistim_line *l = sub->parent;
        struct unistimsession *s = l->parent->session;
        int res;
@@ -2129,15 +2129,15 @@ static void start_rtp(struct unistim_subchannel *sub)
        sin.sin_port = htons(sub->parent->parent->rtp_port);
        ast_sockaddr_from_sin(&sin_tmp, &sin);
        ast_rtp_instance_set_remote_address(sub->rtp, &sin_tmp);
-       if (!(ast_format_cap_iscompatible(sub->owner->nativeformats, &sub->owner->readformat))) {
+       if (!(ast_format_cap_iscompatible(ast_channel_nativeformats(sub->owner), &sub->owner->readformat))) {
                struct ast_format tmpfmt;
                char tmp[256];
-               ast_best_codec(sub->owner->nativeformats, &tmpfmt);
+               ast_best_codec(ast_channel_nativeformats(sub->owner), &tmpfmt);
                ast_log(LOG_WARNING,
                                "Our read/writeformat has been changed to something incompatible: %s, using %s best codec from %s\n",
                                ast_getformatname(&sub->owner->readformat),
                                ast_getformatname(&tmpfmt),
-                               ast_getformatname_multiple(tmp, sizeof(tmp), sub->owner->nativeformats));
+                               ast_getformatname_multiple(tmp, sizeof(tmp), ast_channel_nativeformats(sub->owner)));
                ast_format_copy(&sub->owner->readformat, &tmpfmt);
                ast_format_copy(&sub->owner->writeformat, &tmpfmt);
        }
@@ -3721,11 +3721,11 @@ static struct unistimsession *channel_to_session(struct ast_channel *ast)
                ast_log(LOG_WARNING, "Unistim callback function called with a null channel\n");
                return NULL;
        }
-       if (!ast->tech_pvt) {
+       if (!ast_channel_tech_pvt(ast)) {
                ast_log(LOG_WARNING, "Unistim callback function called without a tech_pvt\n");
                return NULL;
        }
-       sub = ast->tech_pvt;
+       sub = ast_channel_tech_pvt(ast);
 
        if (!sub->parent) {
                ast_log(LOG_WARNING, "Unistim callback function called without a line\n");
@@ -3756,8 +3756,8 @@ static int unistim_call(struct ast_channel *ast, const char *dest, int timeout)
                return -1;
        }
 
-       sub = ast->tech_pvt;
-       if ((ast->_state != AST_STATE_DOWN) && (ast->_state != AST_STATE_RESERVED)) {
+       sub = ast_channel_tech_pvt(ast);
+       if ((ast_channel_state(ast) != AST_STATE_DOWN) && (ast_channel_state(ast) != AST_STATE_RESERVED)) {
                ast_log(LOG_WARNING, "unistim_call called on %s, neither down nor reserved\n",
                                ast_channel_name(ast));
                return -1;
@@ -3821,12 +3821,12 @@ static int unistim_hangup(struct ast_channel *ast)
        struct unistimsession *s;
 
        s = channel_to_session(ast);
-       sub = ast->tech_pvt;
+       sub = ast_channel_tech_pvt(ast);
        if (!s) {
                ast_debug(1, "Asked to hangup channel not connected\n");
                ast_mutex_lock(&sub->lock);
                sub->owner = NULL;
-               ast->tech_pvt = NULL;
+               ast_channel_tech_pvt_set(ast, NULL);
                sub->alreadygone = 0;
                ast_mutex_unlock(&sub->lock);
                if (sub->rtp) {
@@ -3845,7 +3845,7 @@ static int unistim_hangup(struct ast_channel *ast)
                if (unistimdebug)
                        ast_verb(0, "Real call disconnected while talking to threeway\n");
                sub->owner = NULL;
-               ast->tech_pvt = NULL;
+               ast_channel_tech_pvt_set(ast, NULL);
                return 0;
        }
        if ((l->subs[SUB_REAL]->owner) && (sub->subtype == SUB_THREEWAY) &&
@@ -3861,14 +3861,14 @@ static int unistim_hangup(struct ast_channel *ast)
                l->parent->moh = 0;
                ast_mutex_lock(&sub->lock);
                sub->owner = NULL;
-               ast->tech_pvt = NULL;
+               ast_channel_tech_pvt_set(ast, NULL);
                ast_mutex_unlock(&sub->lock);
                unalloc_sub(l, SUB_THREEWAY);
                return 0;
        }
        ast_mutex_lock(&sub->lock);
        sub->owner = NULL;
-       ast->tech_pvt = NULL;
+       ast_channel_tech_pvt_set(ast, NULL);
        sub->alreadygone = 0;
        ast_mutex_unlock(&sub->lock);
        if (!s) {
@@ -3932,7 +3932,7 @@ static int unistim_answer(struct ast_channel *ast)
                ast_log(LOG_WARNING, "unistim_answer on a disconnected device ?\n");
                return -1;
        }
-       sub = ast->tech_pvt;
+       sub = ast_channel_tech_pvt(ast);
        l = sub->parent;
 
        if ((!sub->rtp) && (!l->subs[SUB_THREEWAY]))
@@ -3946,7 +3946,7 @@ static int unistim_answer(struct ast_channel *ast)
        else
                send_text_status(l->parent->session, "Hangup Transf");
        send_start_timer(l->parent->session);
-       if (ast->_state != AST_STATE_UP)
+       if (ast_channel_state(ast) != AST_STATE_UP)
                ast_setstate(ast, AST_STATE_UP);
        return res;
 }
@@ -4027,7 +4027,7 @@ static struct ast_frame *unistim_rtp_read(const struct ast_channel *ast,
                return &ast_null_frame;
        }
 
-       switch (ast->fdno) {
+       switch (ast_channel_fdno(ast)) {
        case 0:
                f = ast_rtp_instance_read(sub->rtp, 0);     /* RTP Audio */
                break;
@@ -4041,14 +4041,14 @@ static struct ast_frame *unistim_rtp_read(const struct ast_channel *ast,
        if (sub->owner) {
                /* We already hold the channel lock */
                if (f->frametype == AST_FRAME_VOICE) {
-                       if (!(ast_format_cap_iscompatible(sub->owner->nativeformats, &f->subclass.format))) {
+                       if (!(ast_format_cap_iscompatible(ast_channel_nativeformats(sub->owner), &f->subclass.format))) {
                                char tmp[256];
                                ast_debug(1,
                                                "Oooh, format changed from %s to %s\n",
-                                               ast_getformatname_multiple(tmp, sizeof(tmp), sub->owner->nativeformats),
+                                               ast_getformatname_multiple(tmp, sizeof(tmp), ast_channel_nativeformats(sub->owner)),
                                                ast_getformatname(&f->subclass.format));
 
-                               ast_format_cap_set(sub->owner->nativeformats, &f->subclass.format);
+                               ast_format_cap_set(ast_channel_nativeformats(sub->owner), &f->subclass.format);
                                ast_set_read_format(sub->owner, &sub->owner->readformat);
                                ast_set_write_format(sub->owner, &sub->owner->writeformat);
                        }
@@ -4061,7 +4061,7 @@ static struct ast_frame *unistim_rtp_read(const struct ast_channel *ast,
 static struct ast_frame *unistim_read(struct ast_channel *ast)
 {
        struct ast_frame *fr;
-       struct unistim_subchannel *sub = ast->tech_pvt;
+       struct unistim_subchannel *sub = ast_channel_tech_pvt(ast);
 
        ast_mutex_lock(&sub->lock);
        fr = unistim_rtp_read(ast, sub);
@@ -4072,7 +4072,7 @@ static struct ast_frame *unistim_read(struct ast_channel *ast)
 
 static int unistim_write(struct ast_channel *ast, struct ast_frame *frame)
 {
-       struct unistim_subchannel *sub = ast->tech_pvt;
+       struct unistim_subchannel *sub = ast_channel_tech_pvt(ast);
        int res = 0;
 
        if (frame->frametype != AST_FRAME_VOICE) {
@@ -4084,12 +4084,12 @@ static int unistim_write(struct ast_channel *ast, struct ast_frame *frame)
                        return 0;
                }
        } else {
-               if (!(ast_format_cap_iscompatible(ast->nativeformats, &frame->subclass.format))) {
+               if (!(ast_format_cap_iscompatible(ast_channel_nativeformats(ast), &frame->subclass.format))) {
                        char tmp[256];
                        ast_log(LOG_WARNING,
                                        "Asked to transmit frame type %s, while native formats is %s (read/write = (%s/%s)\n",
                                        ast_getformatname(&frame->subclass.format),
-                                       ast_getformatname_multiple(tmp, sizeof(tmp), ast->nativeformats),
+                                       ast_getformatname_multiple(tmp, sizeof(tmp), ast_channel_nativeformats(ast)),
                                        ast_getformatname(&ast->readformat),
                                        ast_getformatname(&ast->writeformat));
                        return -1;
@@ -4109,7 +4109,7 @@ static int unistim_write(struct ast_channel *ast, struct ast_frame *frame)
 
 static int unistim_fixup(struct ast_channel *oldchan, struct ast_channel *newchan)
 {
-       struct unistim_subchannel *p = newchan->tech_pvt;
+       struct unistim_subchannel *p = ast_channel_tech_pvt(newchan);
        struct unistim_line *l = p->parent;
 
        ast_mutex_lock(&p->lock);
@@ -4195,12 +4195,12 @@ static int unistim_indicate(struct ast_channel *ast, int ind, const void *data,
        if (!s)
                return -1;
 
-       sub = ast->tech_pvt;
+       sub = ast_channel_tech_pvt(ast);
        l = sub->parent;
 
        switch (ind) {
        case AST_CONTROL_RINGING:
-               if (ast->_state != AST_STATE_UP) {
+               if (ast_channel_state(ast) != AST_STATE_UP) {
                        send_text(TEXT_LINE2, TEXT_NORMAL, s, "Ringing...");
                        in_band_indication(ast, l->parent->tz, "ring");
                        s->device->missed_call = -1;
@@ -4208,7 +4208,7 @@ static int unistim_indicate(struct ast_channel *ast, int ind, const void *data,
                }
                return -1;
        case AST_CONTROL_BUSY:
-               if (ast->_state != AST_STATE_UP) {
+               if (ast_channel_state(ast) != AST_STATE_UP) {
                        sub->alreadygone = 1;
                        send_text(TEXT_LINE2, TEXT_NORMAL, s, "Busy");
                        in_band_indication(ast, l->parent->tz, "busy");
@@ -4221,7 +4221,7 @@ static int unistim_indicate(struct ast_channel *ast, int ind, const void *data,
                 * of incomplete as congestion
                 */
        case AST_CONTROL_CONGESTION:
-               if (ast->_state != AST_STATE_UP) {
+               if (ast_channel_state(ast) != AST_STATE_UP) {
                        sub->alreadygone = 1;
                        send_text(TEXT_LINE2, TEXT_NORMAL, s, "Congestion");
                        in_band_indication(ast, l->parent->tz, "congestion");
@@ -4560,15 +4560,15 @@ static struct ast_channel *unistim_new(struct unistim_subchannel *sub, int state
                return NULL;
        }
 
-       ast_format_cap_copy(tmp->nativeformats, l->cap);
-       if (ast_format_cap_is_empty(tmp->nativeformats))
-               ast_format_cap_copy(tmp->nativeformats, global_cap);
-       ast_best_codec(tmp->nativeformats, &tmpfmt);
+       ast_format_cap_copy(ast_channel_nativeformats(tmp), l->cap);
+       if (ast_format_cap_is_empty(ast_channel_nativeformats(tmp)))
+               ast_format_cap_copy(ast_channel_nativeformats(tmp), global_cap);
+       ast_best_codec(ast_channel_nativeformats(tmp), &tmpfmt);
        if (unistimdebug) {
                char tmp1[256], tmp2[256], tmp3[256];
                ast_verb(0, "Best codec = %s from nativeformats %s (line cap=%s global=%s)\n",
                        ast_getformatname(&tmpfmt),
-                       ast_getformatname_multiple(tmp1, sizeof(tmp1), tmp->nativeformats),
+                       ast_getformatname_multiple(tmp1, sizeof(tmp1), ast_channel_nativeformats(tmp)),
                        ast_getformatname_multiple(tmp2, sizeof(tmp2), l->cap),
                        ast_getformatname_multiple(tmp3, sizeof(tmp3), global_cap));
        }
@@ -4584,14 +4584,14 @@ static struct ast_channel *unistim_new(struct unistim_subchannel *sub, int state
 /*      tmp->type = type; */
        ast_setstate(tmp, state);
        if (state == AST_STATE_RING)
-               tmp->rings = 1;
-       tmp->adsicpe = AST_ADSI_UNAVAILABLE;
+               ast_channel_rings_set(tmp, 1);
+       ast_channel_adsicpe_set(tmp, AST_ADSI_UNAVAILABLE);
        ast_format_copy(&tmp->writeformat, &tmpfmt);
        ast_format_copy(&tmp->rawwriteformat, &tmpfmt);
        ast_format_copy(&tmp->readformat, &tmpfmt);
        ast_format_copy(&tmp->rawreadformat, &tmpfmt);
-       tmp->tech_pvt = sub;
-       tmp->tech = &unistim_tech;
+       ast_channel_tech_pvt_set(tmp, sub);
+       ast_channel_tech_set(tmp, &unistim_tech);
        if (!ast_strlen_zero(l->language))
                ast_channel_language_set(tmp, l->language);
        sub->owner = tmp;
@@ -4616,7 +4616,7 @@ static struct ast_channel *unistim_new(struct unistim_subchannel *sub, int state
                        ast_free(instr);
                }
        }
-       tmp->priority = 1;
+       ast_channel_priority_set(tmp, 1);
        if (state != AST_STATE_DOWN) {
                if (unistimdebug)
                        ast_verb(0, "Starting pbx in unistim_new\n");
@@ -5653,7 +5653,7 @@ static int reload_config(void)
 
 static enum ast_rtp_glue_result unistim_get_rtp_peer(struct ast_channel *chan, struct ast_rtp_instance **instance)
 {
-       struct unistim_subchannel *sub = chan->tech_pvt;
+       struct unistim_subchannel *sub = ast_channel_tech_pvt(chan);
 
        ao2_ref(sub->rtp, +1);
        *instance = sub->rtp;
index 51bf91119c2083e3002d2740855c44a6bffb7973..22dd93bbb856a511b578d4542d9c1031846cfcf4 100644 (file)
@@ -1684,7 +1684,7 @@ static void ring(struct chan_usbradio_pvt *o, int x)
  */
 static int usbradio_call(struct ast_channel *c, const char *dest, int timeout)
 {
-       struct chan_usbradio_pvt *o = c->tech_pvt;
+       struct chan_usbradio_pvt *o = ast_channel_tech_pvt(c);
 
        o->stophid = 0;
        time(&o->lasthidtime);
@@ -1699,7 +1699,7 @@ static int usbradio_call(struct ast_channel *c, const char *dest, int timeout)
 static int usbradio_answer(struct ast_channel *c)
 {
 #ifndef        NEW_ASTERISK
-       struct chan_usbradio_pvt *o = c->tech_pvt;
+       struct chan_usbradio_pvt *o = ast_channel_tech_pvt(c);
 #endif
 
        ast_setstate(c, AST_STATE_UP);
@@ -1712,14 +1712,14 @@ static int usbradio_answer(struct ast_channel *c)
 
 static int usbradio_hangup(struct ast_channel *c)
 {
-       struct chan_usbradio_pvt *o = c->tech_pvt;
+       struct chan_usbradio_pvt *o = ast_channel_tech_pvt(c);
 
        //ast_log(LOG_NOTICE, "usbradio_hangup()\n");
 #ifndef        NEW_ASTERISK
        o->cursound = -1;
        o->nosound = 0;
 #endif
-       c->tech_pvt = NULL;
+       ast_channel_tech_pvt_set(c, NULL);
        o->owner = NULL;
        ast_module_unref(ast_module_info->self);
        if (o->hookstate) {
@@ -1741,7 +1741,7 @@ static int usbradio_hangup(struct ast_channel *c)
 /* used for data coming from the network */
 static int usbradio_write(struct ast_channel *c, struct ast_frame *f)
 {
-       struct chan_usbradio_pvt *o = c->tech_pvt;
+       struct chan_usbradio_pvt *o = ast_channel_tech_pvt(c);
 
        traceusb2(("usbradio_write() o->nosound= %i\n",o->nosound));
 
@@ -1786,7 +1786,7 @@ static struct ast_frame *usbradio_read(struct ast_channel *c)
 {
        int res, src, datalen, oldpttout;
        int cd,sd;
-       struct chan_usbradio_pvt *o = c->tech_pvt;
+       struct chan_usbradio_pvt *o = ast_channel_tech_pvt(c);
        struct ast_frame *f = &o->read_f,*f1;
        struct ast_frame wf = { AST_FRAME_CONTROL };
        time_t now;
@@ -2059,7 +2059,7 @@ static struct ast_frame *usbradio_read(struct ast_channel *c)
        }
 
        o->readpos = AST_FRIENDLY_OFFSET;       /* reset read pointer for next frame */
-       if (c->_state != AST_STATE_UP)  /* drop data if frame is not up */
+       if (ast_channel_state(c) != AST_STATE_UP)       /* drop data if frame is not up */
                return f;
        /* ok we can build and deliver the frame to the caller */
        f->frametype = AST_FRAME_VOICE;
@@ -2103,7 +2103,7 @@ static struct ast_frame *usbradio_read(struct ast_channel *c)
 
 static int usbradio_fixup(struct ast_channel *oldchan, struct ast_channel *newchan)
 {
-       struct chan_usbradio_pvt *o = newchan->tech_pvt;
+       struct chan_usbradio_pvt *o = ast_channel_tech_pvt(newchan);
        ast_log(LOG_WARNING,"usbradio_fixup()\n");
        o->owner = newchan;
        return 0;
@@ -2111,7 +2111,7 @@ static int usbradio_fixup(struct ast_channel *oldchan, struct ast_channel *newch
 
 static int usbradio_indicate(struct ast_channel *c, int cond, const void *data, size_t datalen)
 {
-       struct chan_usbradio_pvt *o = c->tech_pvt;
+       struct chan_usbradio_pvt *o = ast_channel_tech_pvt(c);
        int res = -1;
 
        switch (cond) {
@@ -2178,14 +2178,14 @@ static struct ast_channel *usbradio_new(struct chan_usbradio_pvt *o, char *ext,
        c = ast_channel_alloc(1, state, o->cid_num, o->cid_name, "", ext, ctx, linkedid, 0, "Radio/%s", o->name);
        if (c == NULL)
                return NULL;
-       c->tech = &usbradio_tech;
+       ast_channel_tech_set(c, &usbradio_tech);
        if (o->sounddev < 0)
                setformat(o, O_RDWR);
        c->fds[0] = o->sounddev;        /* -1 if device closed, override later */
-       ast_format_cap_add(c->nativeformats, &slin);
+       ast_format_cap_add(ast_channel_nativeformats(c), &slin);
        ast_format_set(&c->readformat, AST_FORMAT_SLINEAR, 0);
        ast_format_set(&c->writeformat, AST_FORMAT_SLINEAR, 0);
-       c->tech_pvt = o;
+       ast_channel_tech_pvt_set(c, o);
 
        if (!ast_strlen_zero(o->language))
                ast_channel_language_set(c, o->language);
index 9a5a1265d687d77b98a968d35432ab0ca3aa8987..551738d37ef5c5331674a9d001a52ae6edab5c8a 100644 (file)
@@ -425,8 +425,8 @@ static struct ast_channel_tech vpb_tech_indicate = {
 /* This is the Native bridge code, which Asterisk will try before using its own bridging code */
 static enum ast_bridge_result ast_vpb_bridge(struct ast_channel *c0, struct ast_channel *c1, int flags, struct ast_frame **fo, struct ast_channel **rc, int timeoutms)
 {
-       struct vpb_pvt *p0 = (struct vpb_pvt *)c0->tech_pvt;
-       struct vpb_pvt *p1 = (struct vpb_pvt *)c1->tech_pvt;
+       struct vpb_pvt *p0 = (struct vpb_pvt *)ast_channel_tech_pvt(c0);
+       struct vpb_pvt *p1 = (struct vpb_pvt *)ast_channel_tech_pvt(c1);
        int i;
        int res;
        struct ast_channel *cs[3];
@@ -861,7 +861,7 @@ static inline int monitor_handle_owned(struct vpb_pvt *p, VPB_EVENT *e)
                        f.frametype = AST_FRAME_NULL;
                } else if (e->data == p->ring_timer_id) {
                        /* We didnt get another ring in time! */
-                       if (p->owner->_state != AST_STATE_UP)  {
+                       if (ast_channel_state(p->owner) != AST_STATE_UP)  {
                                 /* Assume caller has hung up */
                                vpb_timer_stop(p->ring_timer);
                                f.subclass.integer = AST_CONTROL_HANGUP;
@@ -879,7 +879,7 @@ static inline int monitor_handle_owned(struct vpb_pvt *p, VPB_EVENT *e)
        case VPB_DTMF:
                if (use_ast_dtmfdet) {
                        f.frametype = AST_FRAME_NULL;
-               } else if (p->owner->_state == AST_STATE_UP) {
+               } else if (ast_channel_state(p->owner) == AST_STATE_UP) {
                        f.frametype = AST_FRAME_DTMF;
                        f.subclass.integer = e->data;
                } else
@@ -889,7 +889,7 @@ static inline int monitor_handle_owned(struct vpb_pvt *p, VPB_EVENT *e)
        case VPB_TONEDETECT:
                if (e->data == VPB_BUSY || e->data == VPB_BUSY_308 || e->data == VPB_BUSY_AUST ) {
                        ast_debug(4, "%s: handle_owned: got event: BUSY\n", p->dev);
-                       if (p->owner->_state == AST_STATE_UP) {
+                       if (ast_channel_state(p->owner) == AST_STATE_UP) {
                                f.subclass.integer = AST_CONTROL_HANGUP;
                        } else {
                                f.subclass.integer = AST_CONTROL_BUSY;
@@ -955,7 +955,7 @@ static inline int monitor_handle_owned(struct vpb_pvt *p, VPB_EVENT *e)
 
        case VPB_DROP:
                if ((p->mode == MODE_FXO) && (UseLoopDrop)) { /* ignore loop drop on stations */
-                       if (p->owner->_state == AST_STATE_UP) {
+                       if (ast_channel_state(p->owner) == AST_STATE_UP) {
                                f.subclass.integer = AST_CONTROL_HANGUP;
                        } else {
                                f.frametype = AST_FRAME_NULL;
@@ -963,7 +963,7 @@ static inline int monitor_handle_owned(struct vpb_pvt *p, VPB_EVENT *e)
                }
                break;
        case VPB_LOOP_ONHOOK:
-               if (p->owner->_state == AST_STATE_UP) {
+               if (ast_channel_state(p->owner) == AST_STATE_UP) {
                        f.subclass.integer = AST_CONTROL_HANGUP;
                } else {
                        f.frametype = AST_FRAME_NULL;
@@ -1189,7 +1189,7 @@ static inline int monitor_handle_notowned(struct vpb_pvt *p, VPB_EVENT *e)
                } else if (e->data == p->ring_timer_id) {
                        /* We didnt get another ring in time! */
                        if (p->owner) {
-                               if (p->owner->_state != AST_STATE_UP) {
+                               if (ast_channel_state(p->owner) != AST_STATE_UP) {
                                         /* Assume caller has hung up */
                                        vpb_timer_stop(p->ring_timer);
                                }
@@ -1653,7 +1653,7 @@ static struct vpb_pvt *mkif(int board, int channel, int mode, int gains, float t
 
 static int vpb_indicate(struct ast_channel *ast, int condition, const void *data, size_t datalen)
 {
-       struct vpb_pvt *p = (struct vpb_pvt *)ast->tech_pvt;
+       struct vpb_pvt *p = (struct vpb_pvt *)ast_channel_tech_pvt(ast);
        int res = 0;
 
        if (use_ast_ind == 1) {
@@ -1661,7 +1661,7 @@ static int vpb_indicate(struct ast_channel *ast, int condition, const void *data
                return 0;
        }
 
-       ast_verb(4, "%s: vpb_indicate [%d] state[%d]\n", p->dev, condition,ast->_state);
+       ast_verb(4, "%s: vpb_indicate [%d] state[%d]\n", p->dev, condition,ast_channel_state(ast));
 /*
        if (ast->_state != AST_STATE_UP) {
                ast_verb(4, "%s: vpb_indicate Not in AST_STATE_UP\n", p->dev, condition,ast->_state);
@@ -1677,7 +1677,7 @@ static int vpb_indicate(struct ast_channel *ast, int condition, const void *data
        switch (condition) {
        case AST_CONTROL_BUSY:
        case AST_CONTROL_CONGESTION:
-               if (ast->_state == AST_STATE_UP) {
+               if (ast_channel_state(ast) == AST_STATE_UP) {
                        playtone(p->handle, &Busytone);
                        p->state = VPB_STATE_PLAYBUSY;
                        vpb_timer_stop(p->busy_timer); 
@@ -1685,7 +1685,7 @@ static int vpb_indicate(struct ast_channel *ast, int condition, const void *data
                }
                break;
        case AST_CONTROL_RINGING:
-               if (ast->_state == AST_STATE_UP) {
+               if (ast_channel_state(ast) == AST_STATE_UP) {
                        playtone(p->handle, &Ringbacktone);
                        p->state = VPB_STATE_PLAYRING;
                        ast_verb(4, "%s: vpb indicate: setting ringback timer [%d]\n", p->dev,p->ringback_timer_id);
@@ -1701,7 +1701,7 @@ static int vpb_indicate(struct ast_channel *ast, int condition, const void *data
                stoptone(p->handle);
                break;
        case AST_CONTROL_HANGUP:
-               if (ast->_state == AST_STATE_UP) {
+               if (ast_channel_state(ast) == AST_STATE_UP) {
                        playtone(p->handle, &Busytone);
                        p->state = VPB_STATE_PLAYBUSY;
                        vpb_timer_stop(p->busy_timer);
@@ -1724,7 +1724,7 @@ static int vpb_indicate(struct ast_channel *ast, int condition, const void *data
 
 static int vpb_fixup(struct ast_channel *oldchan, struct ast_channel *newchan)
 {
-       struct vpb_pvt *p = (struct vpb_pvt *)newchan->tech_pvt;
+       struct vpb_pvt *p = (struct vpb_pvt *)ast_channel_tech_pvt(newchan);
 
 /*
        ast_verb(4, "%s: LOCKING in fixup \n", p->dev);
@@ -1737,7 +1737,7 @@ static int vpb_fixup(struct ast_channel *oldchan, struct ast_channel *newchan)
                p->owner = newchan;
        }
 
-       if (newchan->_state == AST_STATE_RINGING){
+       if (ast_channel_state(newchan) == AST_STATE_RINGING){
                if (use_ast_ind == 1) {
                        ast_verb(4, "%s: vpb_fixup Calling ast_indicate\n", p->dev);
                        ast_indicate(newchan, AST_CONTROL_RINGING);
@@ -1758,7 +1758,7 @@ static int vpb_digit_begin(struct ast_channel *ast, char digit)
 }
 static int vpb_digit_end(struct ast_channel *ast, char digit, unsigned int duration)
 {
-       struct vpb_pvt *p = (struct vpb_pvt *)ast->tech_pvt;
+       struct vpb_pvt *p = (struct vpb_pvt *)ast_channel_tech_pvt(ast);
        char s[2];
 
        if (use_ast_dtmf) {
@@ -1789,7 +1789,7 @@ static int vpb_digit_end(struct ast_channel *ast, char digit, unsigned int durat
 /* Places a call out of a VPB channel */
 static int vpb_call(struct ast_channel *ast, const char *dest, int timeout)
 {
-       struct vpb_pvt *p = (struct vpb_pvt *)ast->tech_pvt;
+       struct vpb_pvt *p = (struct vpb_pvt *)ast_channel_tech_pvt(ast);
        int res = 0, i;
        const char *s = strrchr(dest, '/');
        char dialstring[254] = "";
@@ -1813,7 +1813,7 @@ static int vpb_call(struct ast_channel *ast, const char *dest, int timeout)
                        dialstring[i] = '&';
        }
 
-       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, "vpb_call on %s neither down nor reserved!\n", ast_channel_name(ast));
                ast_mutex_unlock(&p->lock);
                return -1;
@@ -1890,7 +1890,7 @@ static int vpb_call(struct ast_channel *ast, const char *dest, int timeout)
 
 static int vpb_hangup(struct ast_channel *ast)
 {
-       struct vpb_pvt *p = (struct vpb_pvt *)ast->tech_pvt;
+       struct vpb_pvt *p = (struct vpb_pvt *)ast_channel_tech_pvt(ast);
        VPB_EVENT je;
        char str[VPB_MAX_STR];
 
@@ -1902,7 +1902,7 @@ static int vpb_hangup(struct ast_channel *ast)
 */
        ast_verb(2, "%s: Hangup requested\n", ast_channel_name(ast));
 
-       if (!ast->tech || !ast->tech_pvt) {
+       if (!ast_channel_tech(ast) || !ast_channel_tech_pvt(ast)) {
                ast_log(LOG_WARNING, "%s: channel not connected?\n", ast_channel_name(ast));
                ast_mutex_unlock(&p->lock);
                /* Free up ast dsp if we have one */
@@ -1978,7 +1978,7 @@ static int vpb_hangup(struct ast_channel *ast)
        p->dialtone = 0;
 
        p->owner = NULL;
-       ast->tech_pvt = NULL;
+       ast_channel_tech_pvt_set(ast, NULL);
 
        /* Free up ast dsp if we have one */
        if (use_ast_dtmfdet && p->vad) {
@@ -1995,7 +1995,7 @@ static int vpb_hangup(struct ast_channel *ast)
 
 static int vpb_answer(struct ast_channel *ast)
 {
-       struct vpb_pvt *p = (struct vpb_pvt *)ast->tech_pvt;
+       struct vpb_pvt *p = (struct vpb_pvt *)ast_channel_tech_pvt(ast);
 /*
        VPB_EVENT je;
        int ret;
@@ -2011,7 +2011,7 @@ static int vpb_answer(struct ast_channel *ast)
                vpb_disable_event(p->handle, VPB_MDROP);
        }
 
-       if (ast->_state != AST_STATE_UP) {
+       if (ast_channel_state(ast) != AST_STATE_UP) {
                if (p->mode == MODE_FXO) {
                        vpb_sethook_sync(p->handle, VPB_OFFHOOK);
                        p->state = VPB_STATE_OFFHOOK;
@@ -2028,7 +2028,7 @@ static int vpb_answer(struct ast_channel *ast)
                ast_verb(2, "%s: Answered call on %s [%s]\n", p->dev,
                                         ast_channel_name(ast), (p->mode == MODE_FXO) ? "FXO" : "FXS");
 
-               ast->rings = 0;
+               ast_channel_rings_set(ast, 0);
                if (!p->readthread) {
        /*              res = ast_mutex_unlock(&p->lock); */
        /*              ast_verbose("%s: unLOCKING in answer [%d]\n", p->dev,res); */
@@ -2052,7 +2052,7 @@ static int vpb_answer(struct ast_channel *ast)
 
 static struct ast_frame *vpb_read(struct ast_channel *ast)
 {
-       struct vpb_pvt *p = (struct vpb_pvt *)ast->tech_pvt
+       struct vpb_pvt *p = (struct vpb_pvt *)ast_channel_tech_pvt(ast)
        static struct ast_frame f = { AST_FRAME_NULL }; 
 
        f.src = "vpb";
@@ -2126,7 +2126,7 @@ int a_gain_vector(float g, short *v, int n)
 /* Writes a frame of voice data to a VPB channel */
 static int vpb_write(struct ast_channel *ast, struct ast_frame *frame)
 {
-       struct vpb_pvt *p = (struct vpb_pvt *)ast->tech_pvt
+       struct vpb_pvt *p = (struct vpb_pvt *)ast_channel_tech_pvt(ast)
        int res = 0;
        AudioCompress fmt = VPB_RAW;
        struct timeval play_buf_time_start;
@@ -2139,8 +2139,8 @@ static int vpb_write(struct ast_channel *ast, struct ast_frame *frame)
                ast_verb(4, "%s: vpb_write: Don't know how to handle from type %d\n", ast_channel_name(ast), frame->frametype);
 /*             ast_mutex_unlock(&p->lock); */
                return 0;
-       } else if (ast->_state != AST_STATE_UP) {
-               ast_verb(4, "%s: vpb_write: Attempt to Write frame type[%d]subclass[%s] on not up chan(state[%d])\n", ast_channel_name(ast), frame->frametype, ast_getformatname(&frame->subclass.format), ast->_state);
+       } else if (ast_channel_state(ast) != AST_STATE_UP) {
+               ast_verb(4, "%s: vpb_write: Attempt to Write frame type[%d]subclass[%s] on not up chan(state[%d])\n", ast_channel_name(ast), frame->frametype, ast_getformatname(&frame->subclass.format), ast_channel_state(ast));
                p->lastoutput = -1;
 /*             ast_mutex_unlock(&p->lock); */
                return 0;
@@ -2266,9 +2266,9 @@ static void *do_chanreads(void *pvt)
                }
 
 /*             if ((p->owner->_state != AST_STATE_UP) || !bridgerec) */
-               if ((p->owner->_state != AST_STATE_UP)) {
-                       if (p->owner->_state != AST_STATE_UP) {
-                               ast_verb(5, "%s: chanreads: Im not up[%d]\n", p->dev, p->owner->_state);
+               if ((ast_channel_state(p->owner) != AST_STATE_UP)) {
+                       if (ast_channel_state(p->owner) != AST_STATE_UP) {
+                               ast_verb(5, "%s: chanreads: Im not up[%d]\n", p->dev, ast_channel_state(p->owner));
                        } else {
                                ast_verb(5, "%s: chanreads: No bridgerec[%d]\n", p->dev, bridgerec);
                        }
@@ -2370,7 +2370,7 @@ static void *do_chanreads(void *pvt)
                         * (ast_hangup() immediately gets lock)
                         */
                        if (p->owner && !p->stopreads) {
-                               ast_verb(6, "%s: chanreads: queueing buffer on read frame q (state[%d])\n", p->dev, p->owner->_state);
+                               ast_verb(6, "%s: chanreads: queueing buffer on read frame q (state[%d])\n", p->dev, ast_channel_state(p->owner));
                                do {
                                        res = ast_channel_trylock(p->owner);
                                        trycnt++;
@@ -2445,9 +2445,9 @@ static struct ast_channel *vpb_new(struct vpb_pvt *me, enum ast_channel_state st
        tmp = ast_channel_alloc(1, state, 0, 0, "", me->ext, me->context, linkedid, 0, "%s", me->dev);
        if (tmp) {
                if (use_ast_ind == 1){
-                       tmp->tech = &vpb_tech_indicate;
+                       ast_channel_tech_set(tmp, &vpb_tech_indicate);
                } else {
-                       tmp->tech = &vpb_tech;
+                       ast_channel_tech_set(tmp, &vpb_tech);
                }
 
                tmp->callgroup = me->callgroup;
@@ -2457,17 +2457,17 @@ static struct ast_channel *vpb_new(struct vpb_pvt *me, enum ast_channel_state st
                 * they are all converted to/from linear in the vpb code. Best for us to use
                 * linear since we can then adjust volume in this modules.
                 */
-               ast_format_cap_add(tmp->nativeformats, ast_format_set(&tmpfmt, AST_FORMAT_SLINEAR, 0));
+               ast_format_cap_add(ast_channel_nativeformats(tmp), ast_format_set(&tmpfmt, AST_FORMAT_SLINEAR, 0));
                ast_format_copy(&tmp->rawreadformat, &tmpfmt);
                ast_format_copy(&tmp->rawwriteformat, &tmpfmt);
                if (state == AST_STATE_RING) {
-                       tmp->rings = 1;
+                       ast_channel_rings_set(tmp, 1);
                        cid_name[0] = '\0';
                        cid_num[0] = '\0';
                        ast_callerid_split(me->callerid, cid_name, sizeof(cid_name), cid_num, sizeof(cid_num));
                        ast_set_callerid(tmp, cid_num, cid_name, cid_num);
                }
-               tmp->tech_pvt = me;
+               ast_channel_tech_pvt_set(tmp, me);
                
                ast_channel_context_set(tmp, context);
                if (!ast_strlen_zero(me->ext))
index 21a96317a4c365c0baaaab4f996b58186a276187..01cac4b76df727ed40fd403c6eba96394d342302 100644 (file)
@@ -710,8 +710,8 @@ static int analog_attempt_transfer(struct analog_pvt *p, int inthreeway)
        if (bridge_3way) {
                ast_verb(3, "TRANSFERRING %s to %s\n", ast_channel_name(owner_3way), ast_channel_name(owner_real));
                ast_cel_report_event(owner_3way,
-                       (owner_real->_state == AST_STATE_RINGING
-                               || owner_3way->_state == AST_STATE_RINGING)
+                       (ast_channel_state(owner_real) == AST_STATE_RINGING
+                               || ast_channel_state(owner_3way) == AST_STATE_RINGING)
                                ? AST_CEL_BLINDTRANSFER : AST_CEL_ATTENDEDTRANSFER,
                        NULL, ast_channel_linkedid(owner_3way), NULL);
 
@@ -736,8 +736,8 @@ static int analog_attempt_transfer(struct analog_pvt *p, int inthreeway)
                /* Try transferring the other way. */
                ast_verb(3, "TRANSFERRING %s to %s\n", ast_channel_name(owner_real), ast_channel_name(owner_3way));
                ast_cel_report_event(owner_3way,
-                       (owner_real->_state == AST_STATE_RINGING
-                               || owner_3way->_state == AST_STATE_RINGING)
+                       (ast_channel_state(owner_real) == AST_STATE_RINGING
+                               || ast_channel_state(owner_3way) == AST_STATE_RINGING)
                                ? AST_CEL_BLINDTRANSFER : AST_CEL_ATTENDEDTRANSFER,
                        NULL, ast_channel_linkedid(owner_3way), NULL);
 
@@ -864,8 +864,8 @@ int analog_available(struct analog_pvt *p)
                return 0;
        }
 
-       if ((p->owner->_state != AST_STATE_UP) &&
-           ((p->owner->_state != AST_STATE_RINGING) || p->outgoing)) {
+       if ((ast_channel_state(p->owner) != AST_STATE_UP) &&
+           ((ast_channel_state(p->owner) != AST_STATE_RINGING) || p->outgoing)) {
                /* If the current call is not up, then don't allow the call */
                return 0;
        }
@@ -1023,12 +1023,12 @@ int analog_call(struct analog_pvt *p, struct ast_channel *ast, const char *rdest
        ast_copy_string(dest, rdest, sizeof(dest));
        ast_copy_string(p->dialdest, rdest, sizeof(p->dialdest));
 
-       if ((ast->_state == AST_STATE_BUSY)) {
+       if ((ast_channel_state(ast) == AST_STATE_BUSY)) {
                ast_queue_control(p->subs[ANALOG_SUB_REAL].owner, AST_CONTROL_BUSY);
                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, "analog_call called on %s, neither down nor reserved\n", ast_channel_name(ast));
                return -1;
        }
@@ -1283,7 +1283,7 @@ int analog_hangup(struct analog_pvt *p, struct ast_channel *ast)
        int idx, x;
 
        ast_debug(1, "%s %d\n", __FUNCTION__, p->channel);
-       if (!ast->tech_pvt) {
+       if (!ast_channel_tech_pvt(ast)) {
                ast_log(LOG_WARNING, "Asked to hangup channel not connected\n");
                return 0;
        }
@@ -1352,7 +1352,7 @@ int analog_hangup(struct analog_pvt *p, struct ast_channel *ast)
                                analog_swap_subs(p, ANALOG_SUB_CALLWAIT, ANALOG_SUB_REAL);
                                analog_unalloc_sub(p, ANALOG_SUB_CALLWAIT);
                                analog_set_new_owner(p, p->subs[ANALOG_SUB_REAL].owner);
-                               if (p->owner->_state != AST_STATE_UP) {
+                               if (ast_channel_state(p->owner) != AST_STATE_UP) {
                                        ast_queue_control(p->subs[ANALOG_SUB_REAL].owner, AST_CONTROL_ANSWER);
                                }
                                if (ast_bridged_channel(p->subs[ANALOG_SUB_REAL].owner)) {
@@ -1463,7 +1463,7 @@ int analog_hangup(struct analog_pvt *p, struct ast_channel *ast)
                case ANALOG_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;
                        }
@@ -1497,7 +1497,7 @@ int analog_answer(struct analog_pvt *p, struct ast_channel *ast)
 {
        int res = 0;
        int idx;
-       int oldstate = ast->_state;
+       int oldstate = ast_channel_state(ast);
 
        ast_debug(1, "%s %d\n", __FUNCTION__, p->channel);
        ast_setstate(ast, AST_STATE_UP);
@@ -1778,7 +1778,7 @@ static void *__analog_ss_thread(void *data)
        /* in the bizarre case where the channel has become a zombie before we
           even get started here, abort safely
        */
-       if (!chan->tech_pvt) {
+       if (!ast_channel_tech_pvt(chan)) {
                ast_log(LOG_WARNING, "Channel became a zombie before simple switch could be started (%s)\n", ast_channel_name(chan));
                ast_hangup(chan);
                goto quit;
@@ -2312,8 +2312,8 @@ static void *__analog_ss_thread(void *data)
                                        pbridge = analog_get_bridged_channel(p, nbridge);
                                }
                                if (nbridge && pbridge &&
-                                   (nbridge->tech == p->chan_tech) &&
-                                   (ast_bridged_channel(nbridge)->tech == p->chan_tech) &&
+                                   (ast_channel_tech(nbridge) == p->chan_tech) &&
+                                   (ast_channel_tech(ast_bridged_channel(nbridge)) == p->chan_tech) &&
                                    ISTRUNK(pbridge)) {
                                        /* Clear out the dial buffer */
                                        p->dop.dialstr[0] = '\0';
@@ -2383,7 +2383,7 @@ static void *__analog_ss_thread(void *data)
                /* If we want caller id, we're in a prering state due to a polarity reversal
                 * and we're set to use a polarity reversal to trigger the start of caller id,
                 * grab the caller id and wait for ringing to start... */
-               } else if (p->use_callerid && (chan->_state == AST_STATE_PRERING
+               } else if (p->use_callerid && (ast_channel_state(chan) == AST_STATE_PRERING
                        && (p->cid_start == ANALOG_CID_START_POLARITY
                                || p->cid_start == ANALOG_CID_START_POLARITY_IN
                                || p->cid_start == ANALOG_CID_START_DTMF_NOALERT))) {
@@ -2430,8 +2430,8 @@ static void *__analog_ss_thread(void *data)
                                                res = 4000;/* This is a typical OFF time between rings. */
                                        }
                                        ast_frfree(f);
-                                       if (chan->_state == AST_STATE_RING ||
-                                               chan->_state == AST_STATE_RINGING) {
+                                       if (ast_channel_state(chan) == AST_STATE_RING ||
+                                               ast_channel_state(chan) == AST_STATE_RINGING) {
                                                break; /* Got ring */
                                        }
                                }
@@ -2514,8 +2514,8 @@ static void *__analog_ss_thread(void *data)
                                                        goto quit;
                                                }
                                                ast_frfree(f);
-                                               if (chan->_state == AST_STATE_RING ||
-                                                       chan->_state == AST_STATE_RINGING)
+                                               if (ast_channel_state(chan) == AST_STATE_RING ||
+                                                       ast_channel_state(chan) == AST_STATE_RINGING)
                                                        break; /* Got ring */
                                        }
 
@@ -2618,7 +2618,7 @@ static void *__analog_ss_thread(void *data)
                analog_handle_notify_message(chan, p, flags, -1);
 
                ast_setstate(chan, AST_STATE_RING);
-               chan->rings = 1;
+               ast_channel_rings_set(chan, 1);
                analog_set_ringtimeout(p, p->ringt_base);
                res = ast_pbx_run(chan);
                if (res) {
@@ -2730,7 +2730,7 @@ static struct ast_frame *__analog_handle_event(struct analog_pvt *p, struct ast_
 #endif
        case ANALOG_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))
                        analog_play_tone(p, ANALOG_SUB_REAL, -1);
                break;
        case ANALOG_EVENT_DIALCOMPLETE:
@@ -2750,7 +2750,7 @@ static struct ast_frame *__analog_handle_event(struct analog_pvt *p, struct ast_
                                analog_set_dialing(p, 0);
                                if ((mysig == ANALOG_SIG_E911) || (mysig == ANALOG_SIG_FGC_CAMA) || (mysig == ANALOG_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;
@@ -2760,7 +2760,7 @@ static struct ast_frame *__analog_handle_event(struct analog_pvt *p, struct ast_
                                                ast_setstate(ast,AST_STATE_DIALING_OFFHOOK);
                                        }
                                }
-                               if (ast->_state == AST_STATE_DIALING) {
+                               if (ast_channel_state(ast) == AST_STATE_DIALING) {
                                        if (analog_have_progressdetect(p)) {
                                                ast_debug(1, "Done dialing, but waiting for progress detection before doing more...\n");
                                        } else if (analog_check_confirmanswer(p) || (!p->dialednone
@@ -2821,7 +2821,7 @@ static struct ast_frame *__analog_handle_event(struct analog_pvt *p, struct ast_
                                        analog_stop_callwait(p);
                                        analog_set_new_owner(p, NULL);
                                        /* Don't start streaming audio yet if the incoming call isn't up yet */
-                                       if (p->subs[ANALOG_SUB_REAL].owner->_state != AST_STATE_UP) {
+                                       if (ast_channel_state(p->subs[ANALOG_SUB_REAL].owner) != AST_STATE_UP) {
                                                analog_set_dialing(p, 1);
                                        }
                                        /* Unlock the call-waiting call that we swapped to real-call. */
@@ -2853,7 +2853,7 @@ static struct ast_frame *__analog_handle_event(struct analog_pvt *p, struct ast_
                                                ast_queue_hangup_with_cause(p->subs[ANALOG_SUB_THREEWAY].owner, AST_CAUSE_NO_ANSWER);
                                                ast_softhangup_nolock(p->subs[ANALOG_SUB_THREEWAY].owner, AST_SOFTHANGUP_DEV);
                                                ast_channel_unlock(p->subs[ANALOG_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) {
                                                        int inthreeway;
 
@@ -2864,7 +2864,7 @@ static struct ast_frame *__analog_handle_event(struct analog_pvt *p, struct ast_
                                                        analog_set_inthreeway(p, ANALOG_SUB_THREEWAY, 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) {
                                                                /* Swap subs and dis-own channel */
                                                                analog_swap_subs(p, ANALOG_SUB_THREEWAY, ANALOG_SUB_REAL);
                                                                /* Unlock the 3-way call that we swapped to real-call. */
@@ -2912,7 +2912,7 @@ static struct ast_frame *__analog_handle_event(struct analog_pvt *p, struct ast_
                }
                /* for E911, its supposed to wait for offhook then dial
                   the second half of the dial string */
-               if (((mysig == ANALOG_SIG_E911) || (mysig == ANALOG_SIG_FGC_CAMA) || (mysig == ANALOG_SIG_FGC_CAMAMF)) && (ast->_state == AST_STATE_DIALING_OFFHOOK)) {
+               if (((mysig == ANALOG_SIG_E911) || (mysig == ANALOG_SIG_FGC_CAMA) || (mysig == ANALOG_SIG_FGC_CAMAMF)) && (ast_channel_state(ast) == AST_STATE_DIALING_OFFHOOK)) {
                        c = strchr(p->dialdest, '/');
                        if (c) {
                                c++;
@@ -2947,7 +2947,7 @@ static struct ast_frame *__analog_handle_event(struct analog_pvt *p, struct ast_
                case ANALOG_SIG_FXOGS:
                case ANALOG_SIG_FXOKS:
                        p->fxsoffhookstate = 1;
-                       switch (ast->_state) {
+                       switch (ast_channel_state(ast)) {
                        case AST_STATE_RINGING:
                                analog_set_echocanceller(p, 1);
                                analog_train_echocanceller(p);
@@ -2989,7 +2989,7 @@ static struct ast_frame *__analog_handle_event(struct analog_pvt *p, struct 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);
@@ -3011,13 +3011,13 @@ static struct ast_frame *__analog_handle_event(struct analog_pvt *p, struct ast_
                                }
                                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 ANALOG_SIG_FXSLS:
                case ANALOG_SIG_FXSGS:
                case ANALOG_SIG_FXSKS:
-                       if (ast->_state == AST_STATE_RING) {
+                       if (ast_channel_state(ast) == AST_STATE_RING) {
                                analog_set_ringtimeout(p, p->ringt_base);
                        }
 
@@ -3037,7 +3037,7 @@ static struct ast_frame *__analog_handle_event(struct analog_pvt *p, struct ast_
                case ANALOG_SIG_SF_FEATD:
                case ANALOG_SIG_SF_FEATDMF:
                case ANALOG_SIG_SF_FEATB:
-                       switch (ast->_state) {
+                       switch (ast_channel_state(ast)) {
                        case AST_STATE_PRERING:
                                ast_setstate(ast, AST_STATE_RING);
                                /* Fall through */
@@ -3063,7 +3063,7 @@ static struct ast_frame *__analog_handle_event(struct analog_pvt *p, struct ast_
                                }
                                /* Fall through */
                        default:
-                               ast_log(LOG_WARNING, "Ring/Off-hook in strange state %d on channel %d\n", ast->_state, p->channel);
+                               ast_log(LOG_WARNING, "Ring/Off-hook in strange state %d on channel %d\n", ast_channel_state(ast), p->channel);
                                break;
                        }
                        break;
@@ -3077,7 +3077,7 @@ static struct ast_frame *__analog_handle_event(struct analog_pvt *p, struct ast_
                case ANALOG_SIG_FXSLS:
                case ANALOG_SIG_FXSGS:
                case ANALOG_SIG_FXSKS:
-                       if (ast->_state == AST_STATE_RING) {
+                       if (ast_channel_state(ast) == AST_STATE_RING) {
                                analog_set_ringtimeout(p, p->ringt_base);
                        }
                        break;
@@ -3087,12 +3087,12 @@ static struct ast_frame *__analog_handle_event(struct analog_pvt *p, struct ast_
                break;
        case ANALOG_EVENT_RINGEROFF:
                if (p->inalarm) break;
-               ast->rings++;
-               if (ast->rings == p->cidrings) {
+               ast_channel_rings_set(ast, ast_channel_rings(ast) + 1);
+               if (ast_channel_rings(ast) == p->cidrings) {
                        analog_send_callerid(p, 0, &p->caller);
                }
 
-               if (ast->rings > p->cidrings) {
+               if (ast_channel_rings(ast) > p->cidrings) {
                        analog_cancel_cidspill(p);
                        p->callwaitcas = 0;
                }
@@ -3146,7 +3146,7 @@ static struct ast_frame *__analog_handle_event(struct analog_pvt *p, struct ast_
                                analog_play_tone(p, ANALOG_SUB_REAL, -1);
                                analog_set_new_owner(p, p->subs[ANALOG_SUB_REAL].owner);
                                ast_debug(1, "Making %s the new owner\n", ast_channel_name(p->owner));
-                               if (p->subs[ANALOG_SUB_REAL].owner->_state == AST_STATE_RINGING) {
+                               if (ast_channel_state(p->subs[ANALOG_SUB_REAL].owner) == AST_STATE_RINGING) {
                                        ast_setstate(p->subs[ANALOG_SUB_REAL].owner, AST_STATE_UP);
                                        ast_queue_control(p->subs[ANALOG_SUB_REAL].owner, AST_CONTROL_ANSWER);
                                }
@@ -3192,9 +3192,9 @@ static struct ast_frame *__analog_handle_event(struct analog_pvt *p, struct 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;
                                        }
@@ -3267,8 +3267,8 @@ static struct ast_frame *__analog_handle_event(struct analog_pvt *p, struct ast_
                                        /* Call is already up, drop the last person */
                                        ast_debug(1, "Got flash with three way call up, dropping last call on %d\n", p->channel);
                                        /* If the primary call isn't answered yet, use it */
-                                       if ((p->subs[ANALOG_SUB_REAL].owner->_state != AST_STATE_UP) &&
-                                               (p->subs[ANALOG_SUB_THREEWAY].owner->_state == AST_STATE_UP)) {
+                                       if ((ast_channel_state(p->subs[ANALOG_SUB_REAL].owner) != AST_STATE_UP) &&
+                                               (ast_channel_state(p->subs[ANALOG_SUB_THREEWAY].owner) == AST_STATE_UP)) {
                                                /* Swap back -- we're dropping the real 3-way that isn't finished yet*/
                                                analog_swap_subs(p, ANALOG_SUB_THREEWAY, ANALOG_SUB_REAL);
                                                orig_3way_sub = ANALOG_SUB_REAL;
@@ -3281,15 +3281,15 @@ static struct ast_frame *__analog_handle_event(struct analog_pvt *p, struct ast_
                                        analog_set_inthreeway(p, ANALOG_SUB_THREEWAY, 0);
                                } else {
                                        /* Lets see what we're up to */
-                                       if (((ast->pbx) || (ast->_state == AST_STATE_UP)) &&
-                                               (p->transfertobusy || (ast->_state != AST_STATE_BUSY))) {
+                                       if (((ast_channel_pbx(ast)) || (ast_channel_state(ast) == AST_STATE_UP)) &&
+                                               (p->transfertobusy || (ast_channel_state(ast) != AST_STATE_BUSY))) {
                                                ast_verb(3, "Building conference call with %s and %s\n",
                                                        ast_channel_name(p->subs[ANALOG_SUB_THREEWAY].owner),
                                                        ast_channel_name(p->subs[ANALOG_SUB_REAL].owner));
                                                /* Put them in the threeway, and flip */
                                                analog_set_inthreeway(p, ANALOG_SUB_THREEWAY, 1);
                                                analog_set_inthreeway(p, ANALOG_SUB_REAL, 1);
-                                               if (ast->_state == AST_STATE_UP) {
+                                               if (ast_channel_state(ast) == AST_STATE_UP) {
                                                        analog_swap_subs(p, ANALOG_SUB_THREEWAY, ANALOG_SUB_REAL);
                                                        orig_3way_sub = ANALOG_SUB_REAL;
                                                }
@@ -3325,7 +3325,7 @@ winkflashdone:
                        if (p->dialing) {
                                ast_debug(1, "Ignoring wink on channel %d\n", p->channel);
                        } else {
-                               ast_debug(1, "Got wink in weird state %d on channel %d\n", ast->_state, p->channel);
+                               ast_debug(1, "Got wink in weird state %d on channel %d\n", ast_channel_state(ast), p->channel);
                        }
                        break;
                case ANALOG_SIG_FEATDMF_TA:
@@ -3429,7 +3429,7 @@ winkflashdone:
                if (p->polarityonanswerdelay > 0) {
                        /* check if event is not too soon after OffHook or Answer */
                        if (ast_tvdiff_ms(ast_tvnow(), p->polaritydelaytv) > p->polarityonanswerdelay) {
-                               switch (ast->_state) {
+                               switch (ast_channel_state(ast)) {
                                case AST_STATE_DIALING:                 /*!< Digits (or equivalent) have been dialed */
                                case AST_STATE_RINGING:                 /*!< Remote end is ringing */
                                        if (p->answeronpolarityswitch) {
@@ -3463,31 +3463,31 @@ winkflashdone:
                                case AST_STATE_PRERING:                         /*!< Channel has detected an incoming call and is waiting for ring */
                                default:
                                        if (p->answeronpolarityswitch || p->hanguponpolarityswitch) {
-                                               ast_debug(1, "Ignoring Polarity switch on channel %d, state %d\n", p->channel, ast->_state);
+                                               ast_debug(1, "Ignoring Polarity switch on channel %d, state %d\n", p->channel, ast_channel_state(ast));
                                        }
                                        break;
                                }
 
                        } else {
                                /* event is too soon after OffHook or Answer */
-                               switch (ast->_state) {
+                               switch (ast_channel_state(ast)) {
                                case AST_STATE_DIALING:         /*!< Digits (or equivalent) have been dialed */
                                case AST_STATE_RINGING:         /*!< Remote end is ringing */
                                        if (p->answeronpolarityswitch) {
-                                               ast_debug(1, "Polarity switch detected but NOT answering (too close to OffHook event) on channel %d, state %d\n", p->channel, ast->_state);
+                                               ast_debug(1, "Polarity switch detected but NOT answering (too close to OffHook event) on channel %d, state %d\n", p->channel, ast_channel_state(ast));
                                        }
                                        break;
 
                                case AST_STATE_UP:                      /*!< Line is up */
                                case AST_STATE_RING:            /*!< Line is ringing */
                                        if (p->hanguponpolarityswitch) {
-                                               ast_debug(1, "Polarity switch detected but NOT hanging up (too close to Answer event) on channel %d, state %d\n", p->channel, ast->_state);
+                                               ast_debug(1, "Polarity switch detected but NOT hanging up (too close to Answer event) on channel %d, state %d\n", p->channel, ast_channel_state(ast));
                                        }
                                        break;
 
                                default:
                                        if (p->answeronpolarityswitch || p->hanguponpolarityswitch) {
-                                               ast_debug(1, "Polarity switch detected (too close to previous event) on channel %d, state %d\n", p->channel, ast->_state);
+                                               ast_debug(1, "Polarity switch detected (too close to previous event) on channel %d, state %d\n", p->channel, ast_channel_state(ast));
                                        }
                                        break;
                                }
@@ -3495,7 +3495,7 @@ winkflashdone:
                }
 
                /* Added more log_debug information below to provide a better indication of what is going on */
-               ast_debug(1, "Polarity Reversal event occured - DEBUG 2: channel %d, state %d, pol= %d, aonp= %d, honp= %d, pdelay= %d, tv= %" PRIi64 "\n", p->channel, ast->_state, p->polarity, p->answeronpolarityswitch, p->hanguponpolarityswitch, p->polarityonanswerdelay, ast_tvdiff_ms(ast_tvnow(), p->polaritydelaytv) );
+               ast_debug(1, "Polarity Reversal event occured - DEBUG 2: channel %d, state %d, pol= %d, aonp= %d, honp= %d, pdelay= %d, tv= %" PRIi64 "\n", p->channel, ast_channel_state(ast), p->polarity, p->answeronpolarityswitch, p->hanguponpolarityswitch, p->polarityonanswerdelay, ast_tvdiff_ms(ast_tvnow(), p->polaritydelaytv) );
                break;
        default:
                ast_debug(1, "Dunno what to do with event %d on channel %d\n", res, p->channel);
@@ -3567,7 +3567,7 @@ struct ast_frame *analog_exception(struct analog_pvt *p, struct ast_channel *ast
                case ANALOG_EVENT_RINGOFFHOOK:
                        analog_set_echocanceller(p, 1);
                        analog_off_hook(p);
-                       if (p->owner && (p->owner->_state == AST_STATE_RINGING)) {
+                       if (p->owner && (ast_channel_state(p->owner) == AST_STATE_RINGING)) {
                                ast_queue_control(p->owner, AST_CONTROL_ANSWER);
                                analog_set_dialing(p, 0);
                        }
@@ -3581,7 +3581,7 @@ struct ast_frame *analog_exception(struct analog_pvt *p, struct ast_channel *ast
                        gettimeofday(&p->flashtime, NULL);
                        if (p->owner) {
                                ast_verb(3, "Channel %d flashed to other channel %s\n", p->channel, ast_channel_name(p->owner));
-                               if (p->owner->_state != AST_STATE_UP) {
+                               if (ast_channel_state(p->owner) != AST_STATE_UP) {
                                        /* Answer if necessary */
                                        ast_queue_control(p->owner, AST_CONTROL_ANSWER);
                                        ast_setstate(p->owner, AST_STATE_UP);
index 5c70179ef555d22dec2d6c4457633ca9ff9a5361..6d48a5d1140424032cdf8c9e12e15f526f4cc773 100644 (file)
@@ -952,7 +952,7 @@ static struct ast_channel *sig_pri_new_ast_channel(struct sig_pri_chan *p, int s
                p->owner = c;
        p->isidlecall = 0;
        p->alreadyhungup = 0;
-       c->transfercapability = transfercapability;
+       ast_channel_transfercapability_set(c, transfercapability);
        pbx_builtin_setvar_helper(c, "TRANSFERCAPABILITY",
                ast_transfercapability2str(transfercapability));
        if (transfercapability & AST_TRANS_CAP_DIGITAL) {
@@ -1302,7 +1302,7 @@ static void sig_pri_kill_call(struct sig_pri_span *pri, q931_call *call, int cau
                sig_pri_span_devstate_changed(pri);
                return;
        }
-       pri->pvts[chanpos]->owner->hangupcause = cause;
+       ast_channel_hangupcause_set(pri->pvts[chanpos]->owner, cause);
        pri_queue_control(pri, chanpos, AST_CONTROL_HANGUP);
        sig_pri_unlock_private(pri->pvts[chanpos]);
 }
@@ -1839,7 +1839,7 @@ static void *do_idle_thread(void *v_pvt)
                                /* Launch the PBX */
                                ast_channel_exten_set(chan, pvt->pri->idleext);
                                ast_channel_context_set(chan, pvt->pri->idlecontext);
-                               chan->priority = 1;
+                               ast_channel_priority_set(chan, 1);
                                ast_verb(4, "Idle channel '%s' answered, sending to %s@%s\n", ast_channel_name(chan), ast_channel_exten(chan), ast_channel_context(chan));
                                ast_pbx_run(chan);
                                /* It's already hungup, return immediately */
@@ -1878,7 +1878,7 @@ static void *pri_ss_thread(void *data)
         * In the bizarre case where the channel has become a zombie before we
         * even get started here, abort safely.
         */
-       if (!chan->tech_pvt) {
+       if (!ast_channel_tech_pvt(chan)) {
                ast_log(LOG_WARNING, "Channel became a zombie before simple switch could be started (%s)\n", ast_channel_name(chan));
                ast_hangup(chan);
                return NULL;
@@ -1973,7 +1973,7 @@ static void *pri_ss_thread(void *data)
                }
        } else {
                ast_debug(1, "No such possible extension '%s' in context '%s'\n", exten, ast_channel_context(chan));
-               chan->hangupcause = AST_CAUSE_UNALLOCATED;
+               ast_channel_hangupcause_set(chan, AST_CAUSE_UNALLOCATED);
                ast_hangup(chan);
                p->exten[0] = '\0';
                /* Since we send release complete here, we won't get one */
@@ -6409,7 +6409,7 @@ static void *pri_dchannel(void *vpri)
                                                if (pri->pvts[chanpos]->owner) {
                                                        ast_verb(3, "PROGRESS with 'user busy' received, signaling AST_CONTROL_BUSY instead of AST_CONTROL_PROGRESS\n");
 
-                                                       pri->pvts[chanpos]->owner->hangupcause = e->proceeding.cause;
+                                                       ast_channel_hangupcause_set(pri->pvts[chanpos]->owner, e->proceeding.cause);
                                                        pri_queue_control(pri, chanpos, AST_CONTROL_BUSY);
                                                }
                                        }
@@ -6545,8 +6545,8 @@ static void *pri_dchannel(void *vpri)
                                                        sig_pri_cc_generic_check(pri, chanpos, AST_CC_CCBS);
                                                        sig_pri_lock_owner(pri, chanpos);
                                                        if (pri->pvts[chanpos]->owner) {
-                                                               pri->pvts[chanpos]->owner->hangupcause = PRI_CAUSE_NORMAL_CIRCUIT_CONGESTION;
-                                                               switch (pri->pvts[chanpos]->owner->_state) {
+                                                               ast_channel_hangupcause_set(pri->pvts[chanpos]->owner, PRI_CAUSE_NORMAL_CIRCUIT_CONGESTION);
+                                                               switch (ast_channel_state(pri->pvts[chanpos]->owner)) {
                                                                case AST_STATE_BUSY:
                                                                case AST_STATE_UP:
                                                                        ast_softhangup_nolock(pri->pvts[chanpos]->owner, AST_SOFTHANGUP_DEV);
@@ -6691,8 +6691,8 @@ static void *pri_dchannel(void *vpri)
                                                int do_hangup = 0;
 
                                                /* Queue a BUSY instead of a hangup if our cause is appropriate */
-                                               pri->pvts[chanpos]->owner->hangupcause = e->hangup.cause;
-                                               switch (pri->pvts[chanpos]->owner->_state) {
+                                               ast_channel_hangupcause_set(pri->pvts[chanpos]->owner, e->hangup.cause);
+                                               switch (ast_channel_state(pri->pvts[chanpos]->owner)) {
                                                case AST_STATE_BUSY:
                                                case AST_STATE_UP:
                                                        do_hangup = 1;
@@ -6839,8 +6839,8 @@ static void *pri_dchannel(void *vpri)
                                if (pri->pvts[chanpos]->owner) {
                                        int do_hangup = 0;
 
-                                       pri->pvts[chanpos]->owner->hangupcause = e->hangup.cause;
-                                       switch (pri->pvts[chanpos]->owner->_state) {
+                                       ast_channel_hangupcause_set(pri->pvts[chanpos]->owner, e->hangup.cause);
+                                       switch (ast_channel_state(pri->pvts[chanpos]->owner)) {
                                        case AST_STATE_BUSY:
                                        case AST_STATE_UP:
                                                do_hangup = 1;
@@ -7231,7 +7231,7 @@ void sig_pri_init_pri(struct sig_pri_span *pri)
 int sig_pri_hangup(struct sig_pri_chan *p, struct ast_channel *ast)
 {
        ast_debug(1, "%s %d\n", __FUNCTION__, p->channel);
-       if (!ast->tech_pvt) {
+       if (!ast_channel_tech_pvt(ast)) {
                ast_log(LOG_WARNING, "Asked to hangup channel not connected\n");
                return 0;
        }
@@ -7278,7 +7278,7 @@ int sig_pri_hangup(struct sig_pri_chan *p, struct ast_channel *ast)
                        p->call = NULL;
                } else {
                        const char *cause = pbx_builtin_getvar_helper(ast,"PRI_CAUSE");
-                       int icause = ast->hangupcause ? ast->hangupcause : -1;
+                       int icause = ast_channel_hangupcause(ast) ? ast_channel_hangupcause(ast) : -1;
 
                        p->alreadyhungup = 1;
                        if (!ast_strlen_zero(cause)) {
@@ -7442,7 +7442,7 @@ int sig_pri_call(struct sig_pri_chan *p, struct ast_channel *ast, const char *rd
                return -1;
        }
 
-       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, "sig_pri_call called on %s, neither down nor reserved\n", ast_channel_name(ast));
                return -1;
        }
@@ -7544,7 +7544,7 @@ int sig_pri_call(struct sig_pri_chan *p, struct ast_channel *ast, const char *rd
                return -1;
        }
 
-       sig_pri_set_digital(p, IS_DIGITAL(ast->transfercapability));    /* push up to parent for EC */
+       sig_pri_set_digital(p, IS_DIGITAL(ast_channel_transfercapability(ast)));        /* push up to parent for EC */
 
 #if defined(HAVE_PRI_CALL_WAITING)
        if (p->is_call_waiting) {
@@ -7565,13 +7565,13 @@ int sig_pri_call(struct sig_pri_chan *p, struct ast_channel *ast, const char *rd
                pri_sr_set_channel(sr, PVT_TO_CHANNEL(p), exclusive, 1);
        }
 
-       pri_sr_set_bearer(sr, p->digital ? PRI_TRANS_CAP_DIGITAL : ast->transfercapability,
+       pri_sr_set_bearer(sr, p->digital ? PRI_TRANS_CAP_DIGITAL : ast_channel_transfercapability(ast),
                (p->digital ? -1 : layer1));
 
        if (p->pri->facilityenable)
                pri_facility_enable(p->pri->pri);
 
-       ast_verb(3, "Requested transfer capability: 0x%.2x - %s\n", ast->transfercapability, ast_transfercapability2str(ast->transfercapability));
+       ast_verb(3, "Requested transfer capability: 0x%.2x - %s\n", ast_channel_transfercapability(ast), ast_transfercapability2str(ast_channel_transfercapability(ast)));
        dp_strip = 0;
        pridialplan = p->pri->dialplan - 1;
        if (pridialplan == -2 || pridialplan == -3) { /* compute dynamically */
@@ -7862,19 +7862,19 @@ int sig_pri_indicate(struct sig_pri_chan *p, struct ast_channel *chan, int condi
        switch (condition) {
        case AST_CONTROL_BUSY:
                if (p->priindication_oob || p->no_b_channel) {
-                       chan->hangupcause = AST_CAUSE_USER_BUSY;
+                       ast_channel_hangupcause_set(chan, AST_CAUSE_USER_BUSY);
                        chan->_softhangup |= AST_SOFTHANGUP_DEV;
                        res = 0;
                        break;
                }
                res = sig_pri_play_tone(p, SIG_PRI_TONE_BUSY);
                if (p->call_level < SIG_PRI_CALL_LEVEL_ALERTING && !p->outgoing) {
-                       chan->hangupcause = AST_CAUSE_USER_BUSY;
+                       ast_channel_hangupcause_set(chan, AST_CAUSE_USER_BUSY);
                        p->progress = 1;/* No need to send plain PROGRESS after this. */
                        if (p->pri && p->pri->pri) {
                                pri_grab(p, p->pri);
 #ifdef HAVE_PRI_PROG_W_CAUSE
-                               pri_progress_with_cause(p->pri->pri, p->call, PVT_TO_CHANNEL(p), 1, chan->hangupcause);
+                               pri_progress_with_cause(p->pri->pri, p->call, PVT_TO_CHANNEL(p), 1, ast_channel_hangupcause(chan));
 #else
                                pri_progress(p->pri->pri,p->call, PVT_TO_CHANNEL(p), 1);
 #endif
@@ -7893,8 +7893,8 @@ int sig_pri_indicate(struct sig_pri_chan *p, struct ast_channel *chan, int condi
                        }
                }
                res = sig_pri_play_tone(p, SIG_PRI_TONE_RINGTONE);
-               if (chan->_state != AST_STATE_UP) {
-                       if (chan->_state != AST_STATE_RING)
+               if (ast_channel_state(chan) != AST_STATE_UP) {
+                       if (ast_channel_state(chan) != AST_STATE_RING)
                                ast_setstate(chan, AST_STATE_RINGING);
                }
                break;
@@ -7941,17 +7941,17 @@ int sig_pri_indicate(struct sig_pri_chan *p, struct ast_channel *chan, int condi
                        break;
                }
                /* Otherwise, treat as congestion */
-               chan->hangupcause = AST_CAUSE_INVALID_NUMBER_FORMAT;
+               ast_channel_hangupcause_set(chan, AST_CAUSE_INVALID_NUMBER_FORMAT);
                /* Falls through */
        case AST_CONTROL_CONGESTION:
                if (p->priindication_oob || p->no_b_channel) {
                        /* There are many cause codes that generate an AST_CONTROL_CONGESTION. */
-                       switch (chan->hangupcause) {
+                       switch (ast_channel_hangupcause(chan)) {
                        case AST_CAUSE_USER_BUSY:
                        case AST_CAUSE_NORMAL_CLEARING:
                        case 0:/* Cause has not been set. */
                                /* Supply a more appropriate cause. */
-                               chan->hangupcause = AST_CAUSE_SWITCH_CONGESTION;
+                               ast_channel_hangupcause_set(chan, AST_CAUSE_SWITCH_CONGESTION);
                                break;
                        default:
                                break;
@@ -7963,12 +7963,12 @@ int sig_pri_indicate(struct sig_pri_chan *p, struct ast_channel *chan, int condi
                res = sig_pri_play_tone(p, SIG_PRI_TONE_CONGESTION);
                if (p->call_level < SIG_PRI_CALL_LEVEL_ALERTING && !p->outgoing) {
                        /* There are many cause codes that generate an AST_CONTROL_CONGESTION. */
-                       switch (chan->hangupcause) {
+                       switch (ast_channel_hangupcause(chan)) {
                        case AST_CAUSE_USER_BUSY:
                        case AST_CAUSE_NORMAL_CLEARING:
                        case 0:/* Cause has not been set. */
                                /* Supply a more appropriate cause. */
-                               chan->hangupcause = AST_CAUSE_SWITCH_CONGESTION;
+                               ast_channel_hangupcause_set(chan, AST_CAUSE_SWITCH_CONGESTION);
                                break;
                        default:
                                break;
@@ -7977,7 +7977,7 @@ int sig_pri_indicate(struct sig_pri_chan *p, struct ast_channel *chan, int condi
                        if (p->pri && p->pri->pri) {
                                pri_grab(p, p->pri);
 #ifdef HAVE_PRI_PROG_W_CAUSE
-                               pri_progress_with_cause(p->pri->pri, p->call, PVT_TO_CHANNEL(p), 1, chan->hangupcause);
+                               pri_progress_with_cause(p->pri->pri, p->call, PVT_TO_CHANNEL(p), 1, ast_channel_hangupcause(chan));
 #else
                                pri_progress(p->pri->pri,p->call, PVT_TO_CHANNEL(p), 1);
 #endif
@@ -8279,7 +8279,7 @@ int sig_pri_available(struct sig_pri_chan **pvt, int is_specific_channel)
  * functions should handle it normally (generate inband DTMF) */
 int sig_pri_digit_begin(struct sig_pri_chan *pvt, struct ast_channel *ast, char digit)
 {
-       if (ast->_state == AST_STATE_DIALING) {
+       if (ast_channel_state(ast) == AST_STATE_DIALING) {
                if (pvt->call_level < SIG_PRI_CALL_LEVEL_OVERLAP) {
                        unsigned int len;
 
index 9edb04bbb7d2bf4fe9681fd56078f473e0e20601..c37cf619c1ddc34fbccbaed9f6b55ccaed5a4e8d 100644 (file)
@@ -257,7 +257,7 @@ static struct ast_channel *sig_ss7_new_ast_channel(struct sig_ss7_chan *p, int s
                p->owner = ast;
        }
        p->alreadyhungup = 0;
-       ast->transfercapability = transfercapability;
+       ast_channel_transfercapability_set(ast, transfercapability);
        pbx_builtin_setvar_helper(ast, "TRANSFERCAPABILITY",
                ast_transfercapability2str(transfercapability));
        if (transfercapability & AST_TRANS_CAP_DIGITAL) {
@@ -893,7 +893,7 @@ void *ss7_linkset(void *data)
                                        }
                                        p->call_level = SIG_SS7_CALL_LEVEL_GLARE;
                                        if (p->owner) {
-                                               p->owner->hangupcause = AST_CAUSE_NORMAL_CLEARING;
+                                               ast_channel_hangupcause_set(p->owner, AST_CAUSE_NORMAL_CLEARING);
                                                ast_softhangup_nolock(p->owner, AST_SOFTHANGUP_DEV);
                                                ast_channel_unlock(p->owner);
                                        }
@@ -1036,7 +1036,7 @@ void *ss7_linkset(void *data)
                                sig_ss7_lock_private(p);
                                sig_ss7_lock_owner(linkset, chanpos);
                                if (p->owner) {
-                                       p->owner->hangupcause = e->rel.cause;
+                                       ast_channel_hangupcause_set(p->owner, e->rel.cause);
                                        ast_softhangup_nolock(p->owner, AST_SOFTHANGUP_DEV);
                                        ast_channel_unlock(p->owner);
                                }
@@ -1571,7 +1571,7 @@ int sig_ss7_hangup(struct sig_ss7_chan *p, struct ast_channel *ast)
 {
        int res = 0;
 
-       if (!ast->tech_pvt) {
+       if (!ast_channel_tech_pvt(ast)) {
                ast_log(LOG_WARNING, "Asked to hangup channel not connected\n");
                return 0;
        }
@@ -1588,7 +1588,7 @@ int sig_ss7_hangup(struct sig_ss7_chan *p, struct ast_channel *ast)
        if (p->ss7call) {
                if (!p->alreadyhungup) {
                        const char *cause = pbx_builtin_getvar_helper(ast,"SS7_CAUSE");
-                       int icause = ast->hangupcause ? ast->hangupcause : -1;
+                       int icause = ast_channel_hangupcause(ast) ? ast_channel_hangupcause(ast) : -1;
 
                        if (cause) {
                                if (atoi(cause)) {
@@ -1682,7 +1682,7 @@ int sig_ss7_indicate(struct sig_ss7_chan *p, struct ast_channel *chan, int condi
 
                res = sig_ss7_play_tone(p, SIG_SS7_TONE_RINGTONE);
 
-               if (chan->_state != AST_STATE_UP && chan->_state != AST_STATE_RING) {
+               if (ast_channel_state(chan) != AST_STATE_UP && ast_channel_state(chan) != AST_STATE_RING) {
                        ast_setstate(chan, AST_STATE_RINGING);
                }
                break;
@@ -1690,7 +1690,7 @@ int sig_ss7_indicate(struct sig_ss7_chan *p, struct ast_channel *chan, int condi
                ast_debug(1,"Received AST_CONTROL_PROCEEDING on %s\n",ast_channel_name(chan));
                ss7_grab(p, p->ss7);
                /* This IF sends the FAR for an answered ALEG call */
-               if (chan->_state == AST_STATE_UP && (p->rlt != 1)){
+               if (ast_channel_state(chan) == AST_STATE_UP && (p->rlt != 1)){
                        if ((isup_far(p->ss7->ss7, p->ss7call)) != -1) {
                                p->rlt = 1;
                        }
@@ -1726,10 +1726,10 @@ int sig_ss7_indicate(struct sig_ss7_chan *p, struct ast_channel *chan, int condi
                        res = 0;
                        break;
                }
-               chan->hangupcause = AST_CAUSE_INVALID_NUMBER_FORMAT;
+               ast_channel_hangupcause_set(chan, AST_CAUSE_INVALID_NUMBER_FORMAT);
                break;
        case AST_CONTROL_CONGESTION:
-               chan->hangupcause = AST_CAUSE_CONGESTION;
+               ast_channel_hangupcause_set(chan, AST_CAUSE_CONGESTION);
                break;
        case AST_CONTROL_HOLD:
                ast_moh_start(chan, data, p->mohinterpret);
index 0d019c543884c1e925723dd58b65f6344e013151..152f7caa4e890c5a3ec10dd3402d764c9821af83 100644 (file)
@@ -39,7 +39,7 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
 
 int sip_acf_channel_read(struct ast_channel *chan, const char *funcname, char *preparse, char *buf, size_t buflen)
 {
-       struct sip_pvt *p = chan->tech_pvt;
+       struct sip_pvt *p = ast_channel_tech_pvt(chan);
        char *parse = ast_strdupa(preparse);
        int res = 0;
        AST_DECLARE_APP_ARGS(args,
@@ -57,7 +57,7 @@ int sip_acf_channel_read(struct ast_channel *chan, const char *funcname, char *p
        AST_STANDARD_APP_ARGS(args, parse);
 
        /* Sanity check */
-       if (!IS_SIP_TECH(chan->tech)) {
+       if (!IS_SIP_TECH(ast_channel_tech(chan))) {
                ast_log(LOG_ERROR, "Cannot call %s on a non-SIP channel\n", funcname);
                return 0;
        }
@@ -348,8 +348,8 @@ AST_TEST_DEFINE(test_sip_rtpqos_1)
                res = AST_TEST_NOT_RUN;
                goto done;
        }
-       chan->tech = &sip_tech;
-       chan->tech_pvt = p;
+       ast_channel_tech_set(chan, &sip_tech);
+       ast_channel_tech_pvt_set(chan, p);
        p->owner = chan;
 
        varstr = ast_str_create(16);
index 1a3fc6f196f96218d686fff63ecb2184897822d0..bd6d8aef215ef97b6bca964dcb893c7a5c2ed59a 100644 (file)
@@ -1043,8 +1043,8 @@ static int callerid_write(struct ast_channel *chan, const char *cmd, char *data,
                chan->redirecting.from.number.valid = 1;
                ast_free(chan->redirecting.from.number.str);
                chan->redirecting.from.number.str = ast_strdup(value);
-               if (chan->cdr) {
-                       ast_cdr_setcid(chan->cdr, chan);
+               if (ast_channel_cdr(chan)) {
+                       ast_cdr_setcid(ast_channel_cdr(chan), chan);
                }
        } else if (!strcasecmp("dnid", member.argv[0])) {
                ast_party_dialed_set_init(&dialed, &chan->dialed);
@@ -1063,8 +1063,8 @@ static int callerid_write(struct ast_channel *chan, const char *cmd, char *data,
                                dialed.number.str = ast_strdup(value);
                                ast_trim_blanks(dialed.number.str);
                                ast_party_dialed_set(&chan->dialed, &dialed);
-                               if (chan->cdr) {
-                                       ast_cdr_setcid(chan->cdr, chan);
+                               if (ast_channel_cdr(chan)) {
+                                       ast_cdr_setcid(ast_channel_cdr(chan), chan);
                                }
                        } else if (member.argc == 3 && !strcasecmp("plan", member.argv[2])) {
                                /* dnid-num-plan */
@@ -1073,8 +1073,8 @@ static int callerid_write(struct ast_channel *chan, const char *cmd, char *data,
 
                                if (('0' <= val[0]) && (val[0] <= '9')) {
                                        chan->dialed.number.plan = atoi(val);
-                                       if (chan->cdr) {
-                                               ast_cdr_setcid(chan->cdr, chan);
+                                       if (ast_channel_cdr(chan)) {
+                                               ast_cdr_setcid(ast_channel_cdr(chan), chan);
                                        }
                                } else {
                                        ast_log(LOG_ERROR,
@@ -1093,8 +1093,8 @@ static int callerid_write(struct ast_channel *chan, const char *cmd, char *data,
                        switch (status) {
                        case ID_FIELD_VALID:
                                ast_party_dialed_set(&chan->dialed, &dialed);
-                               if (chan->cdr) {
-                                       ast_cdr_setcid(chan->cdr, chan);
+                               if (ast_channel_cdr(chan)) {
+                                       ast_cdr_setcid(ast_channel_cdr(chan), chan);
                                }
                                break;
                        case ID_FIELD_INVALID:
@@ -1113,8 +1113,8 @@ static int callerid_write(struct ast_channel *chan, const char *cmd, char *data,
 
                if (('0' <= val[0]) && (val[0] <= '9')) {
                        chan->caller.ani2 = atoi(val);
-                       if (chan->cdr) {
-                               ast_cdr_setcid(chan->cdr, chan);
+                       if (ast_channel_cdr(chan)) {
+                               ast_cdr_setcid(ast_channel_cdr(chan), chan);
                        }
                } else {
                        ast_log(LOG_ERROR, "Unknown callerid ani2 '%s', value unchanged\n", val);
@@ -1130,8 +1130,8 @@ static int callerid_write(struct ast_channel *chan, const char *cmd, char *data,
                switch (status) {
                case ID_FIELD_VALID:
                        ast_party_caller_set(&chan->caller, &caller, NULL);
-                       if (chan->cdr) {
-                               ast_cdr_setcid(chan->cdr, chan);
+                       if (ast_channel_cdr(chan)) {
+                               ast_cdr_setcid(ast_channel_cdr(chan), chan);
                        }
                        break;
                case ID_FIELD_INVALID:
@@ -1147,8 +1147,8 @@ static int callerid_write(struct ast_channel *chan, const char *cmd, char *data,
                switch (status) {
                case ID_FIELD_VALID:
                        ast_channel_set_caller_event(chan, &caller, NULL);
-                       if (chan->cdr) {
-                               ast_cdr_setcid(chan->cdr, chan);
+                       if (ast_channel_cdr(chan)) {
+                               ast_cdr_setcid(ast_channel_cdr(chan), chan);
                        }
                        break;
                case ID_FIELD_INVALID:
index 25e10a2fa4340a6dac49c6b28ca3169e9c5bc9ec..ff57cdedd9e342cd766057d1d3da9596ba374788 100644 (file)
@@ -209,7 +209,7 @@ static int cdr_read(struct ast_channel *chan, const char *cmd, char *parse,
                return -1;
 
        ast_channel_lock(chan);
-       cdr = chan->cdr;
+       cdr = ast_channel_cdr(chan);
        if (!cdr) {
                ast_channel_unlock(chan);
                return -1;
@@ -279,7 +279,7 @@ static int cdr_write(struct ast_channel *chan, const char *cmd, char *parse,
                return -1;
 
        ast_channel_lock(chan);
-       cdr = chan->cdr;
+       cdr = ast_channel_cdr(chan);
        if (!cdr) {
                ast_channel_unlock(chan);
                return -1;
index a792b895b1f0da36cd1b03902b7b0f6042eea076..ca9741533a428d3cd0593752908ff76541c1ea99 100644 (file)
@@ -307,12 +307,12 @@ static int func_channel_read(struct ast_channel *chan, const char *function,
        struct ast_format_cap *tmpcap;
 
        if (!strcasecmp(data, "audionativeformat")) {
-               if ((tmpcap = ast_format_cap_get_type(chan->nativeformats, AST_FORMAT_TYPE_AUDIO))) {
+               if ((tmpcap = ast_format_cap_get_type(ast_channel_nativeformats(chan), AST_FORMAT_TYPE_AUDIO))) {
                        ast_copy_string(buf, ast_getformatname_multiple(tmp, sizeof(tmp), tmpcap), len);
                        tmpcap = ast_format_cap_destroy(tmpcap);
                }
        } else if (!strcasecmp(data, "videonativeformat")) {
-               if ((tmpcap = ast_format_cap_get_type(chan->nativeformats, AST_FORMAT_TYPE_VIDEO))) {
+               if ((tmpcap = ast_format_cap_get_type(ast_channel_nativeformats(chan), AST_FORMAT_TYPE_VIDEO))) {
                        ast_copy_string(buf, ast_getformatname_multiple(tmp, sizeof(tmp), tmpcap), len);
                        tmpcap = ast_format_cap_destroy(tmpcap);
                }
@@ -326,8 +326,8 @@ static int func_channel_read(struct ast_channel *chan, const char *function,
                ast_copy_string(buf, ast_channel_trace_is_enabled(chan) ? "1" : "0", len);
                ast_channel_unlock(chan);
 #endif
-       } else if (!strcasecmp(data, "tonezone") && chan->zone)
-               locked_copy_string(chan, buf, chan->zone->country, len);
+       } else if (!strcasecmp(data, "tonezone") && ast_channel_zone(chan))
+               locked_copy_string(chan, buf, ast_channel_zone(chan)->country, len);
        else if (!strcasecmp(data, "language"))
                locked_copy_string(chan, buf, ast_channel_language(chan), len);
        else if (!strcasecmp(data, "musicclass"))
@@ -337,9 +337,9 @@ static int func_channel_read(struct ast_channel *chan, const char *function,
        } else if (!strcasecmp(data, "parkinglot"))
                locked_copy_string(chan, buf, ast_channel_parkinglot(chan), len);
        else if (!strcasecmp(data, "state"))
-               locked_copy_string(chan, buf, ast_state2str(chan->_state), len);
+               locked_copy_string(chan, buf, ast_state2str(ast_channel_state(chan)), len);
        else if (!strcasecmp(data, "channeltype"))
-               locked_copy_string(chan, buf, chan->tech->type, len);
+               locked_copy_string(chan, buf, ast_channel_tech(chan)->type, len);
        else if (!strcasecmp(data, "accountcode"))
                locked_copy_string(chan, buf, ast_channel_accountcode(chan), len);
        else if (!strcasecmp(data, "checkhangup")) {
@@ -376,7 +376,7 @@ static int func_channel_read(struct ast_channel *chan, const char *function,
                struct ast_channel *p;
                ast_channel_lock(chan);
                p = ast_bridged_channel(chan);
-               if (p || chan->tech || chan->cdr) /* dummy channel? if so, we hid the peer name in the language */
+               if (p || ast_channel_tech(chan) || ast_channel_cdr(chan)) /* dummy channel? if so, we hid the peer name in the language */
                        ast_copy_string(buf, (p ? ast_channel_name(p) : ""), len);
                else {
                        /* a dummy channel can still pass along bridged peer info via
@@ -391,7 +391,7 @@ static int func_channel_read(struct ast_channel *chan, const char *function,
        } else if (!strcasecmp(data, "uniqueid")) {
                locked_copy_string(chan, buf, ast_channel_uniqueid(chan), len);
        } else if (!strcasecmp(data, "transfercapability")) {
-               locked_copy_string(chan, buf, transfercapability_table[chan->transfercapability & 0x1f], len);
+               locked_copy_string(chan, buf, transfercapability_table[ast_channel_transfercapability(chan) & 0x1f], len);
        } else if (!strcasecmp(data, "callgroup")) {
                char groupbuf[256];
                locked_copy_string(chan, buf,  ast_print_group(groupbuf, sizeof(groupbuf), chan->callgroup), len);
@@ -400,7 +400,7 @@ static int func_channel_read(struct ast_channel *chan, const char *function,
                locked_copy_string(chan, buf,  ast_print_group(groupbuf, sizeof(groupbuf), chan->pickupgroup), len);
        } else if (!strcasecmp(data, "amaflags")) {
                char amabuf[256];
-               snprintf(amabuf,sizeof(amabuf), "%d", chan->amaflags);
+               snprintf(amabuf,sizeof(amabuf), "%d", ast_channel_amaflags(chan));
                locked_copy_string(chan, buf, amabuf, len);
        } else if (!strncasecmp(data, "secure_bridge_", 14)) {
                struct ast_datastore *ds;
@@ -414,7 +414,7 @@ static int func_channel_read(struct ast_channel *chan, const char *function,
                        }
                }
                ast_channel_unlock(chan);
-       } else if (!chan->tech || !chan->tech->func_channel_read || chan->tech->func_channel_read(chan, function, data, buf, len)) {
+       } else if (!ast_channel_tech(chan) || !ast_channel_tech(chan)->func_channel_read || ast_channel_tech(chan)->func_channel_read(chan, function, data, buf, len)) {
                ast_log(LOG_WARNING, "Unknown or unavailable item requested: '%s'\n", data);
                ret = -1;
        }
@@ -441,13 +441,15 @@ static int func_channel_write_real(struct ast_channel *chan, const char *functio
        else if (!strcasecmp(data, "amaflags")) {
                ast_channel_lock(chan);
                if(isdigit(*value)) {
-                       sscanf(value, "%30d", &chan->amaflags);
+                       int amaflags;
+                       sscanf(value, "%30d", &amaflags);
+                       ast_channel_amaflags_set(chan, amaflags);
                } else if (!strcasecmp(value,"OMIT")){
-                       chan->amaflags = 1;
+                       ast_channel_amaflags_set(chan, 1);
                } else if (!strcasecmp(value,"BILLING")){
-                       chan->amaflags = 2;
+                       ast_channel_amaflags_set(chan, 2);
                } else if (!strcasecmp(value,"DOCUMENTATION")){
-                       chan->amaflags = 3;
+                       ast_channel_amaflags_set(chan, 3);
                }
                ast_channel_unlock(chan);
        } else if (!strcasecmp(data, "peeraccount"))
@@ -476,10 +478,10 @@ static int func_channel_write_real(struct ast_channel *chan, const char *functio
                        ret = -1;       
                } else {
                        ast_channel_lock(chan);
-                       if (chan->zone) {
-                               chan->zone = ast_tone_zone_unref(chan->zone);
+                       if (ast_channel_zone(chan)) {
+                               ast_channel_zone_set(chan, ast_tone_zone_unref(ast_channel_zone(chan)));
                        }
-                       chan->zone = ast_tone_zone_ref(new_zone);
+                       ast_channel_zone_set(chan, ast_tone_zone_ref(new_zone));
                        ast_channel_unlock(chan);
                        new_zone = ast_tone_zone_unref(new_zone);
                }
@@ -497,7 +499,7 @@ static int func_channel_write_real(struct ast_channel *chan, const char *functio
                unsigned short i;
                for (i = 0; i < 0x20; i++) {
                        if (!strcasecmp(transfercapability_table[i], value) && strcmp(value, "UNK")) {
-                               chan->transfercapability = i;
+                               ast_channel_transfercapability_set(chan, i);
                                break;
                        }
                }
@@ -532,8 +534,8 @@ static int func_channel_write_real(struct ast_channel *chan, const char *functio
                } else if (!strcasecmp(data, "secure_bridge_media")) {
                        store->media = ast_true(value) ? 1 : 0;
                }
-       } else if (!chan->tech->func_channel_write
-                || chan->tech->func_channel_write(chan, function, data, value)) {
+       } else if (!ast_channel_tech(chan)->func_channel_write
+                || ast_channel_tech(chan)->func_channel_write(chan, function, data, value)) {
                ast_log(LOG_WARNING, "Unknown or unavailable item requested: '%s'\n",
                                data);
                ret = -1;
index f10af961d66afe682fc2b79d0766d0cad4243be5..f21d5905f939ea3cbaf35cfcf00809a693a48f6f 100644 (file)
@@ -218,7 +218,7 @@ static struct ast_frame *hook_event_cb(struct ast_channel *chan, struct ast_fram
                return frame;
        }
 
-       if (chan->fdno == AST_JITTERBUFFER_FD && framedata->timer) {
+       if (ast_channel_fdno(chan) == AST_JITTERBUFFER_FD && framedata->timer) {
                ast_timer_ack(framedata->timer, 1);
        }
 
index 0f5f369e5fd77a5fb6a95a40432f15e1b49e6ac1..aef0a403391fc0a5287d661b87465ba058efaf18 100644 (file)
@@ -100,15 +100,15 @@ static int timeout_read(struct ast_channel *chan, const char *cmd, char *data,
 
        case 'r':
        case 'R':
-               if (chan->pbx) {
-                       snprintf(buf, len, "%.3f", chan->pbx->rtimeoutms / 1000.0);
+               if (ast_channel_pbx(chan)) {
+                       snprintf(buf, len, "%.3f", ast_channel_pbx(chan)->rtimeoutms / 1000.0);
                }
                break;
 
        case 'd':
        case 'D':
-               if (chan->pbx) {
-                       snprintf(buf, len, "%.3f", chan->pbx->dtimeoutms / 1000.0);
+               if (ast_channel_pbx(chan)) {
+                       snprintf(buf, len, "%.3f", ast_channel_pbx(chan)->dtimeoutms / 1000.0);
                }
                break;
 
@@ -168,17 +168,17 @@ static int timeout_write(struct ast_channel *chan, const char *cmd, char *data,
 
        case 'r':
        case 'R':
-               if (chan->pbx) {
-                       chan->pbx->rtimeoutms = when.tv_sec * 1000 + when.tv_usec / 1000;
-                       ast_verb(3, "Response timeout set to %.3f\n", chan->pbx->rtimeoutms / 1000.0);
+               if (ast_channel_pbx(chan)) {
+                       ast_channel_pbx(chan)->rtimeoutms = when.tv_sec * 1000 + when.tv_usec / 1000;
+                       ast_verb(3, "Response timeout set to %.3f\n", ast_channel_pbx(chan)->rtimeoutms / 1000.0);
                }
                break;
 
        case 'd':
        case 'D':
-               if (chan->pbx) {
-                       chan->pbx->dtimeoutms = when.tv_sec * 1000 + when.tv_usec / 1000;
-                       ast_verb(3, "Digit timeout set to %.3f\n", chan->pbx->dtimeoutms / 1000.0);
+               if (ast_channel_pbx(chan)) {
+                       ast_channel_pbx(chan)->dtimeoutms = when.tv_sec * 1000 + when.tv_usec / 1000;
+                       ast_verb(3, "Digit timeout set to %.3f\n", ast_channel_pbx(chan)->dtimeoutms / 1000.0);
                }
                break;
 
index 34b2b3c546f5dda6e933de3af330a251a416be4f..f80ccfe58e4e189930fba2e08efecd9d5af36dd5 100644 (file)
@@ -775,33 +775,33 @@ enum ast_t38_state {
  *       8-byte fields.
  */
 struct ast_channel {
-       const struct ast_channel_tech *tech;            /*!< Technology (point to channel driver) */
-       void *tech_pvt;                                 /*!< Private data used by the technology driver */
-       void *music_state;                              /*!< Music State*/
-       void *generatordata;                            /*!< Current generator data if there is any */
-       struct ast_generator *generator;                /*!< Current active data generator */
-       struct ast_channel *_bridge;                    /*!< Who are we bridged to, if we're bridged.
+       const struct ast_channel_tech *__do_not_use_tech;               /*!< Technology (point to channel driver) */
+       void *__do_not_use_tech_pvt;                                    /*!< Private data used by the technology driver */
+       void *__do_not_use_music_state;                         /*!< Music State*/
+       void *__do_not_use_generatordata;                               /*!< Current generator data if there is any */
+       struct ast_generator *__do_not_use_generator;           /*!< Current active data generator */
+       struct ast_channel * _bridge;                   /*!< Who are we bridged to, if we're bridged.
                                                         *   Who is proxying for us, if we are proxied (i.e. chan_agent).
                                                         *   Do not access directly, use ast_bridged_channel(chan) */
-       struct ast_channel *masq;                       /*!< Channel that will masquerade as us */
-       struct ast_channel *masqr;                      /*!< Who we are masquerading as */
+       struct ast_channel *__do_not_use_masq;                  /*!< Channel that will masquerade as us */
+       struct ast_channel *__do_not_use_masqr;                 /*!< Who we are masquerading as */
        const char *__do_not_use_blockproc;                             /*!< Procedure causing blocking */
        const char *__do_not_use_appl;                          /*!< Current application */
        const char *__do_not_use_data;                          /*!< Data passed to current application */
-       struct ast_sched_context *sched;                /*!< Schedule context */
-       struct ast_filestream *stream;                  /*!< Stream itself. */
-       struct ast_filestream *vstream;                 /*!< Video Stream itself. */
+       struct ast_sched_context *__do_not_use_sched;                /*!< Schedule context */
+       struct ast_filestream *__do_not_use_stream;                     /*!< Stream itself. */
+       struct ast_filestream *__do_not_use_vstream;                    /*!< Video Stream itself. */
        int (*timingfunc)(const void *data);
-       void *timingdata;
-       struct ast_pbx *pbx;                            /*!< PBX private structure for this channel */
-       struct ast_trans_pvt *writetrans;               /*!< Write translation path */
-       struct ast_trans_pvt *readtrans;                /*!< Read translation path */
-       struct ast_audiohook_list *audiohooks;
-       struct ast_framehook_list *framehooks;
-       struct ast_cdr *cdr;                            /*!< Call Detail Record */
-       struct ast_tone_zone *zone;                     /*!< Tone zone as set in indications.conf or
+       void *__do_not_use_timingdata;
+       struct ast_pbx *__do_not_use_pbx;                               /*!< PBX private structure for this channel */
+       struct ast_trans_pvt *__do_not_use_writetrans;          /*!< Write translation path */
+       struct ast_trans_pvt *__do_not_use_readtrans;           /*!< Read translation path */
+       struct ast_audiohook_list *__do_not_use_audiohooks;
+       struct ast_framehook_list *__do_not_use_framehooks;
+       struct ast_cdr *__do_not_use_cdr;                               /*!< Call Detail Record */
+       struct ast_tone_zone *__do_not_use_zone;                        /*!< Tone zone as set in indications.conf or
                                                         *   in the CHANNEL dialplan function */
-       struct ast_channel_monitor *monitor;            /*!< Channel monitoring */
+       struct ast_channel_monitor *__do_not_use_monitor;               /*!< Channel monitoring */
 #ifdef HAVE_EPOLL
        struct ast_epoll_data *epfd_data[AST_MAX_FDS];
 #endif
@@ -858,53 +858,53 @@ struct ast_channel {
        AST_LIST_HEAD_NOLOCK(datastores, ast_datastore) datastores; /*!< Data stores on the channel */
        AST_LIST_HEAD_NOLOCK(autochans, ast_autochan) autochans; /*!< Autochans on the channel */
 
-       unsigned long insmpl;                           /*!< Track the read/written samples for monitor use */
-       unsigned long outsmpl;                          /*!< Track the read/written samples for monitor use */
+       unsigned long __do_not_use_insmpl;                              /*!< Track the read/written samples for monitor use */
+       unsigned long __do_not_use_outsmpl;                             /*!< Track the read/written samples for monitor use */
 
        int fds[AST_MAX_FDS];                           /*!< File descriptors for channel -- Drivers will poll on
                                                         *   these file descriptors, so at least one must be non -1.
                                                         *   See \arg \ref AstFileDesc */
        int _softhangup;                                /*!< Whether or not we have been hung up...  Do not set this value
                                                         *   directly, use ast_softhangup() */
-       int fdno;                                       /*!< Which fd had an event detected on */
-       int streamid;                                   /*!< For streaming playback, the schedule ID */
-       int vstreamid;                                  /*!< For streaming video playback, the schedule ID */
+       int __do_not_use_fdno;                                  /*!< Which fd had an event detected on */
+       int __do_not_use_streamid;                                      /*!< For streaming playback, the schedule ID */
+       int __do_not_use_vstreamid;                                     /*!< For streaming video playback, the schedule ID */
        struct ast_format oldwriteformat;  /*!< Original writer format */
-       int timingfd;                                   /*!< Timing fd */
-       enum ast_channel_state _state;                  /*!< State of line -- Don't write directly, use ast_setstate() */
-       int rings;                                      /*!< Number of rings so far */
-       int priority;                                   /*!< Dialplan: Current extension priority */
-       int macropriority;                              /*!< Macro: Current non-macro priority. See app_macro.c */
-       int amaflags;                                   /*!< Set BEFORE PBX is started to determine AMA flags */
-       enum ast_channel_adsicpe adsicpe;               /*!< Whether or not ADSI is detected on CPE */
-       unsigned int fin;                               /*!< Frames in counters. The high bit is a debug mask, so
+       int __do_not_use_timingfd;                                      /*!< Timing fd */
+       enum ast_channel_state __do_not_use_state;                      /*!< State of line -- Don't write directly, use ast_setstate() */
+       int __do_not_use_rings;                                 /*!< Number of rings so far */
+       int __do_not_use_priority;                                      /*!< Dialplan: Current extension priority */
+       int __do_not_use_macropriority;                         /*!< Macro: Current non-macro priority. See app_macro.c */
+       int __do_not_use_amaflags;                                      /*!< Set BEFORE PBX is started to determine AMA flags */
+       enum ast_channel_adsicpe __do_not_use_adsicpe;          /*!< Whether or not ADSI is detected on CPE */
+       unsigned int __do_not_use_fin;                          /*!< Frames in counters. The high bit is a debug mask, so
                                                         *   the counter is only in the remaining bits */
-       unsigned int fout;                              /*!< Frames out counters. The high bit is a debug mask, so
+       unsigned int __do_not_use_fout;                         /*!< Frames out counters. The high bit is a debug mask, so
                                                         *   the counter is only in the remaining bits */
-       int hangupcause;                                /*!< Why is the channel hanged up. See causes.h */
+       int __do_not_use_hangupcause;                           /*!< Why is the channel hanged up. See causes.h */
        unsigned int flags;                             /*!< channel flags of AST_FLAG_ type */
        int alertpipe[2];
-       struct ast_format_cap *nativeformats;         /*!< Kinds of data this channel can natively handle */
+       struct ast_format_cap *__do_not_use_nativeformats;         /*!< Kinds of data this channel can natively handle */
        struct ast_format readformat;            /*!< Requested read format (after translation) */
        struct ast_format writeformat;           /*!< Requested write format (after translation) */
        struct ast_format rawreadformat;         /*!< Raw read format (before translation) */
        struct ast_format rawwriteformat;        /*!< Raw write format (before translation) */
-       unsigned int emulate_dtmf_duration;             /*!< Number of ms left to emulate DTMF for */
+       unsigned int __do_not_use_emulate_dtmf_duration;                /*!< Number of ms left to emulate DTMF for */
 #ifdef HAVE_EPOLL
-       int epfd;
+       int __do_not_use_epfd;
 #endif
-       int visible_indication;                         /*!< Indication currently playing on the channel */
+       int __do_not_use_visible_indication;                         /*!< Indication currently playing on the channel */
 
-       unsigned short transfercapability;              /*!< ISDN Transfer Capability - AST_FLAG_DIGITAL is not enough */
+       unsigned short __do_not_use_transfercapability;         /*!< ISDN Transfer Capability - AST_FLAG_DIGITAL is not enough */
 
        struct ast_bridge *bridge;                      /*!< Bridge this channel is participating in */
-       struct ast_timer *timer;                        /*!< timer object that provided timingfd */
+       struct ast_timer *__do_not_use_timer;                   /*!< timer object that provided timingfd */
 
        char __do_not_use_context[AST_MAX_CONTEXT];                     /*!< Dialplan: Current extension context */
        char __do_not_use_exten[AST_MAX_EXTENSION];                     /*!< Dialplan: Current extension number */
        char __do_not_use_macrocontext[AST_MAX_CONTEXT];                /*!< Macro: Current non-macro context. See app_macro.c */
        char __do_not_use_macroexten[AST_MAX_EXTENSION];                /*!< Macro: Current non-macro extension. See app_macro.c */
-       char emulate_dtmf_digit;                        /*!< Digit being emulated */
+       char __do_not_use_emulate_dtmf_digit;                   /*!< Digit being emulated */
 };
 
 /*! \brief ast_channel_tech Properties */
@@ -3645,4 +3645,90 @@ const char *ast_channel_macrocontext(const struct ast_channel *chan);
 void ast_channel_macrocontext_set(struct ast_channel *chan, const char *value);
 const char *ast_channel_macroexten(const struct ast_channel *chan);
 void ast_channel_macroexten_set(struct ast_channel *chan, const char *value);
+
+char ast_channel_emulate_dtmf_digit(const struct ast_channel *chan);
+void ast_channel_emulate_dtmf_digit_set(struct ast_channel *chan, char value);
+int ast_channel_amaflags(const struct ast_channel *chan);
+void ast_channel_amaflags_set(struct ast_channel *chan, int value);
+int ast_channel_epfd(const struct ast_channel *chan);
+void ast_channel_epfd_set(struct ast_channel *chan, int value);
+int ast_channel_fdno(const struct ast_channel *chan);
+void ast_channel_fdno_set(struct ast_channel *chan, int value);
+int ast_channel_hangupcause(const struct ast_channel *chan);
+void ast_channel_hangupcause_set(struct ast_channel *chan, int value);
+int ast_channel_macropriority(const struct ast_channel *chan);
+void ast_channel_macropriority_set(struct ast_channel *chan, int value);
+int ast_channel_priority(const struct ast_channel *chan);
+void ast_channel_priority_set(struct ast_channel *chan, int value);
+int ast_channel_rings(const struct ast_channel *chan);
+void ast_channel_rings_set(struct ast_channel *chan, int value);
+int ast_channel_streamid(const struct ast_channel *chan);
+void ast_channel_streamid_set(struct ast_channel *chan, int value);
+int ast_channel_timingfd(const struct ast_channel *chan);
+void ast_channel_timingfd_set(struct ast_channel *chan, int value);
+int ast_channel_visible_indication(const struct ast_channel *chan);
+void ast_channel_visible_indication_set(struct ast_channel *chan, int value);
+int ast_channel_vstreamid(const struct ast_channel *chan);
+void ast_channel_vstreamid_set(struct ast_channel *chan, int value);
+unsigned short ast_channel_transfercapability(const struct ast_channel *chan);
+void ast_channel_transfercapability_set(struct ast_channel *chan, unsigned short value);
+unsigned int ast_channel_emulate_dtmf_duration(const struct ast_channel *chan);
+void ast_channel_emulate_dtmf_duration_set(struct ast_channel *chan, unsigned int value);
+unsigned int ast_channel_fin(const struct ast_channel *chan);
+void ast_channel_fin_set(struct ast_channel *chan, unsigned int value);
+unsigned int ast_channel_fout(const struct ast_channel *chan);
+void ast_channel_fout_set(struct ast_channel *chan, unsigned int value);
+unsigned long ast_channel_insmpl(const struct ast_channel *chan);
+void ast_channel_insmpl_set(struct ast_channel *chan, unsigned long value);
+unsigned long ast_channel_outsmpl(const struct ast_channel *chan);
+void ast_channel_outsmpl_set(struct ast_channel *chan, unsigned long value);
+void * ast_channel_generatordata(const struct ast_channel *chan);
+void ast_channel_generatordata_set(struct ast_channel *chan, void * value);
+void * ast_channel_music_state(const struct ast_channel *chan);
+void ast_channel_music_state_set(struct ast_channel *chan, void * value);
+void * ast_channel_tech_pvt(const struct ast_channel *chan);
+void ast_channel_tech_pvt_set(struct ast_channel *chan, void * value);
+void * ast_channel_timingdata(const struct ast_channel *chan);
+void ast_channel_timingdata_set(struct ast_channel *chan, void * value);
+struct ast_audiohook_list * ast_channel_audiohooks(const struct ast_channel *chan);
+void ast_channel_audiohooks_set(struct ast_channel *chan, struct ast_audiohook_list * value);
+struct ast_cdr * ast_channel_cdr(const struct ast_channel *chan);
+void ast_channel_cdr_set(struct ast_channel *chan, struct ast_cdr * value);
+struct ast_channel * ast_channel__bridge(const struct ast_channel *chan);
+void ast_channel__bridge_set(struct ast_channel *chan, struct ast_channel * value);
+struct ast_channel * ast_channel_masq(const struct ast_channel *chan);
+void ast_channel_masq_set(struct ast_channel *chan, struct ast_channel * value);
+struct ast_channel * ast_channel_masqr(const struct ast_channel *chan);
+void ast_channel_masqr_set(struct ast_channel *chan, struct ast_channel * value);
+struct ast_channel_monitor * ast_channel_monitor(const struct ast_channel *chan);
+void ast_channel_monitor_set(struct ast_channel *chan, struct ast_channel_monitor * value);
+struct ast_filestream * ast_channel_stream(const struct ast_channel *chan);
+void ast_channel_stream_set(struct ast_channel *chan, struct ast_filestream * value);
+struct ast_filestream * ast_channel_vstream(const struct ast_channel *chan);
+void ast_channel_vstream_set(struct ast_channel *chan, struct ast_filestream * value);
+struct ast_format_cap * ast_channel_nativeformats(const struct ast_channel *chan);
+void ast_channel_nativeformats_set(struct ast_channel *chan, struct ast_format_cap * value);
+struct ast_framehook_list * ast_channel_framehooks(const struct ast_channel *chan);
+void ast_channel_framehooks_set(struct ast_channel *chan, struct ast_framehook_list * value);
+struct ast_generator * ast_channel_generator(const struct ast_channel *chan);
+void ast_channel_generator_set(struct ast_channel *chan, struct ast_generator * value);
+struct ast_pbx * ast_channel_pbx(const struct ast_channel *chan);
+void ast_channel_pbx_set(struct ast_channel *chan, struct ast_pbx * value);
+struct ast_sched_context * ast_channel_sched(const struct ast_channel *chan);
+void ast_channel_sched_set(struct ast_channel *chan, struct ast_sched_context * value);
+struct ast_timer * ast_channel_timer(const struct ast_channel *chan);
+void ast_channel_timer_set(struct ast_channel *chan, struct ast_timer * value);
+struct ast_tone_zone * ast_channel_zone(const struct ast_channel *chan);
+void ast_channel_zone_set(struct ast_channel *chan, struct ast_tone_zone * value);
+struct ast_trans_pvt * ast_channel_readtrans(const struct ast_channel *chan);
+void ast_channel_readtrans_set(struct ast_channel *chan, struct ast_trans_pvt * value);
+struct ast_trans_pvt * ast_channel_writetrans(const struct ast_channel *chan);
+void ast_channel_writetrans_set(struct ast_channel *chan, struct ast_trans_pvt * value);
+const struct ast_channel_tech * ast_channel_tech(const struct ast_channel *chan);
+void ast_channel_tech_set(struct ast_channel *chan, const struct ast_channel_tech * value);
+enum ast_channel_adsicpe ast_channel_adsicpe(const struct ast_channel *chan);
+void ast_channel_adsicpe_set(struct ast_channel *chan, enum ast_channel_adsicpe value);
+enum ast_channel_state ast_channel_state(const struct ast_channel *chan);
+/* XXX Internal use only, make sure to move later */
+void ast_channel_state_set(struct ast_channel *chan, enum ast_channel_state);
 #endif /* _ASTERISK_CHANNEL_H */
index b16421a882c0e02ad1532fe03b844ecc5d87adf2..aac6dc82b1ff3a4837bf6b178cfccd723a3b1af1 100644 (file)
@@ -56,6 +56,19 @@ extern "C" {
                (_sched_res); \
        })
 
+#define AST_SCHED_DEL_ACCESSOR(sched, obj, getter, setter) \
+       ({ \
+               int _count = 0; \
+               int _sched_res = -1; \
+               while (getter(obj) > -1 && (_sched_res = ast_sched_del(sched, getter(obj))) && ++_count < 10) \
+                       usleep(1); \
+               if (_count == 10) { \
+                       ast_debug(3, "Unable to cancel schedule ID %d.\n", getter(obj)); \
+               } \
+               setter(obj, -1); \
+               (_sched_res); \
+       })
+
 /*!
  * \brief schedule task to get deleted and call unref function
  * \sa AST_SCHED_DEL
index 3ae3e03315a042b1a7697ce041e4fffd3c18a874..c35b1d8aa635ce7b6d6f619448315e787621333f 100644 (file)
@@ -160,14 +160,14 @@ int ast_jb_do_usecheck(struct ast_channel *c0, struct ast_channel *c1)
        struct ast_jb *jb1 = &c1->jb;
        struct ast_jb_conf *conf0 = &jb0->conf;
        struct ast_jb_conf *conf1 = &jb1->conf;
-       int c0_wants_jitter = c0->tech->properties & AST_CHAN_TP_WANTSJITTER;
-       int c0_creates_jitter = c0->tech->properties & AST_CHAN_TP_CREATESJITTER;
+       int c0_wants_jitter = ast_channel_tech(c0)->properties & AST_CHAN_TP_WANTSJITTER;
+       int c0_creates_jitter = ast_channel_tech(c0)->properties & AST_CHAN_TP_CREATESJITTER;
        int c0_jb_enabled = ast_test_flag(conf0, AST_JB_ENABLED);
        int c0_force_jb = ast_test_flag(conf0, AST_JB_FORCED);
        int c0_jb_timebase_initialized = ast_test_flag(jb0, JB_TIMEBASE_INITIALIZED);
        int c0_jb_created = ast_test_flag(jb0, JB_CREATED);
-       int c1_wants_jitter = c1->tech->properties & AST_CHAN_TP_WANTSJITTER;
-       int c1_creates_jitter = c1->tech->properties & AST_CHAN_TP_CREATESJITTER;
+       int c1_wants_jitter = ast_channel_tech(c1)->properties & AST_CHAN_TP_WANTSJITTER;
+       int c1_creates_jitter = ast_channel_tech(c1)->properties & AST_CHAN_TP_CREATESJITTER;
        int c1_jb_enabled = ast_test_flag(conf1, AST_JB_ENABLED);
        int c1_force_jb = ast_test_flag(conf1, AST_JB_FORCED);
        int c1_jb_timebase_initialized = ast_test_flag(jb1, JB_TIMEBASE_INITIALIZED);
index d7c14858179a2b8b45c588c4a7781aabad0173a6..821c2fbfb2ec4c1e92d36fac1fd6ace89fed53fb 100644 (file)
@@ -122,14 +122,14 @@ int ast_app_dtget(struct ast_channel *chan, const char *context, char *collect,
        }
 
        if (!timeout) {
-               if (chan->pbx && chan->pbx->dtimeoutms) {
-                       timeout = chan->pbx->dtimeoutms;
+               if (ast_channel_pbx(chan) && ast_channel_pbx(chan)->dtimeoutms) {
+                       timeout = ast_channel_pbx(chan)->dtimeoutms;
                } else {
                        timeout = 5000;
                }
        }
 
-       if ((ts = ast_get_indication_tone(chan->zone, "dial"))) {
+       if ((ts = ast_get_indication_tone(ast_channel_zone(chan), "dial"))) {
                res = ast_playtones_start(chan, 0, ts->data, 0);
                ts = ast_tone_zone_sound_unref(ts);
        } else {
@@ -193,8 +193,8 @@ enum ast_getdata_result ast_app_getdata(struct ast_channel *c, const char *promp
                }
                if (ast_strlen_zero(filename)) {
                        /* set timeouts for the last prompt */
-                       fto = c->pbx ? c->pbx->rtimeoutms : 6000;
-                       to = c->pbx ? c->pbx->dtimeoutms : 2000;
+                       fto = ast_channel_pbx(c) ? ast_channel_pbx(c)->rtimeoutms : 6000;
+                       to = ast_channel_pbx(c) ? ast_channel_pbx(c)->dtimeoutms : 2000;
 
                        if (timeout > 0) {
                                fto = to = timeout;
@@ -207,7 +207,7 @@ enum ast_getdata_result ast_app_getdata(struct ast_channel *c, const char *promp
                         * get rid of the long timeout between
                         * prompts, and make it 50ms */
                        fto = 50;
-                       to = c->pbx ? c->pbx->dtimeoutms : 2000;
+                       to = ast_channel_pbx(c) ? ast_channel_pbx(c)->dtimeoutms : 2000;
                }
                res = ast_readstring(c, s, maxlen, to, fto, "#");
                if (res == AST_GETDATA_EMPTY_END_TERMINATED) {
@@ -599,7 +599,7 @@ int ast_control_streamfile(struct ast_channel *chan, const char *file,
                        strcat(breaks, restart);
                }
        }
-       if (chan->_state != AST_STATE_UP) {
+       if (ast_channel_state(chan) != AST_STATE_UP) {
                res = ast_answer(chan);
        }
 
@@ -617,7 +617,7 @@ int ast_control_streamfile(struct ast_channel *chan, const char *file,
                res = ast_streamfile(chan, file, ast_channel_language(chan));
                if (!res) {
                        if (pause_restart_point) {
-                               ast_seekstream(chan->stream, pause_restart_point, SEEK_SET);
+                               ast_seekstream(ast_channel_stream(chan), pause_restart_point, SEEK_SET);
                                pause_restart_point = 0;
                        }
                        else if (end || offset < 0) {
@@ -626,12 +626,12 @@ int ast_control_streamfile(struct ast_channel *chan, const char *file,
                                }
                                ast_verb(3, "ControlPlayback seek to offset %ld from end\n", offset);
 
-                               ast_seekstream(chan->stream, offset, SEEK_END);
+                               ast_seekstream(ast_channel_stream(chan), offset, SEEK_END);
                                end = NULL;
                                offset = 0;
                        } else if (offset) {
                                ast_verb(3, "ControlPlayback seek to offset %ld\n", offset);
-                               ast_seekstream(chan->stream, offset, SEEK_SET);
+                               ast_seekstream(ast_channel_stream(chan), offset, SEEK_SET);
                                offset = 0;
                        }
                        res = ast_waitstream_fr(chan, breaks, fwd, rev, skipms);
@@ -649,7 +649,7 @@ int ast_control_streamfile(struct ast_channel *chan, const char *file,
                }
 
                if (suspend && strchr(suspend, res)) {
-                       pause_restart_point = ast_tellstream(chan->stream);
+                       pause_restart_point = ast_tellstream(ast_channel_stream(chan));
                        for (;;) {
                                ast_stopstream(chan);
                                if (!(res = ast_waitfordigit(chan, 1000))) {
@@ -677,8 +677,8 @@ int ast_control_streamfile(struct ast_channel *chan, const char *file,
        if (pause_restart_point) {
                offset = pause_restart_point;
        } else {
-               if (chan->stream) {
-                       offset = ast_tellstream(chan->stream);
+               if (ast_channel_stream(chan)) {
+                       offset = ast_tellstream(ast_channel_stream(chan));
                } else {
                        offset = -8;  /* indicate end of file */
                }
@@ -689,7 +689,7 @@ int ast_control_streamfile(struct ast_channel *chan, const char *file,
        }
 
        /* If we are returning a digit cast it as char */
-       if (res > 0 || chan->stream) {
+       if (res > 0 || ast_channel_stream(chan)) {
                res = (char)res;
        }
 
@@ -1692,7 +1692,7 @@ static int ivr_dispatch(struct ast_channel *chan, struct ast_ivr_option *option,
                }
                return res;
        case AST_ACTION_WAITOPTION:
-               if (!(res = ast_waitfordigit(chan, chan->pbx ? chan->pbx->rtimeoutms : 10000))) {
+               if (!(res = ast_waitfordigit(chan, ast_channel_pbx(chan) ? ast_channel_pbx(chan)->rtimeoutms : 10000))) {
                        return 't';
                }
                return res;
@@ -1750,7 +1750,7 @@ static int read_newoption(struct ast_channel *chan, struct ast_ivr_menu *menu, c
        int res = 0;
        int ms;
        while (option_matchmore(menu, exten)) {
-               ms = chan->pbx ? chan->pbx->dtimeoutms : 5000;
+               ms = ast_channel_pbx(chan) ? ast_channel_pbx(chan)->dtimeoutms : 5000;
                if (strlen(exten) >= maxexten - 1) {
                        break;
                }
index 83fec318fbcf9a638fe1f8201289b9b71d221a9d..da80f0aea00ea98d812f8595d1550ff27b938604 100644 (file)
@@ -434,30 +434,32 @@ int ast_audiohook_attach(struct ast_channel *chan, struct ast_audiohook *audioho
 {
        ast_channel_lock(chan);
 
-       if (!chan->audiohooks) {
+       if (!ast_channel_audiohooks(chan)) {
+               struct ast_audiohook_list *ahlist;
                /* Whoops... allocate a new structure */
-               if (!(chan->audiohooks = ast_calloc(1, sizeof(*chan->audiohooks)))) {
+               if (!(ahlist = ast_calloc(1, sizeof(*ahlist)))) {
                        ast_channel_unlock(chan);
                        return -1;
                }
-               AST_LIST_HEAD_INIT_NOLOCK(&chan->audiohooks->spy_list);
-               AST_LIST_HEAD_INIT_NOLOCK(&chan->audiohooks->whisper_list);
-               AST_LIST_HEAD_INIT_NOLOCK(&chan->audiohooks->manipulate_list);
+               ast_channel_audiohooks_set(chan, ahlist);
+               AST_LIST_HEAD_INIT_NOLOCK(&ast_channel_audiohooks(chan)->spy_list);
+               AST_LIST_HEAD_INIT_NOLOCK(&ast_channel_audiohooks(chan)->whisper_list);
+               AST_LIST_HEAD_INIT_NOLOCK(&ast_channel_audiohooks(chan)->manipulate_list);
                /* This sample rate will adjust as necessary when writing to the list. */
-               chan->audiohooks->list_internal_samp_rate = 8000;
+               ast_channel_audiohooks(chan)->list_internal_samp_rate = 8000;
        }
 
        /* Drop into respective list */
        if (audiohook->type == AST_AUDIOHOOK_TYPE_SPY)
-               AST_LIST_INSERT_TAIL(&chan->audiohooks->spy_list, audiohook, list);
+               AST_LIST_INSERT_TAIL(&ast_channel_audiohooks(chan)->spy_list, audiohook, list);
        else if (audiohook->type == AST_AUDIOHOOK_TYPE_WHISPER)
-               AST_LIST_INSERT_TAIL(&chan->audiohooks->whisper_list, audiohook, list);
+               AST_LIST_INSERT_TAIL(&ast_channel_audiohooks(chan)->whisper_list, audiohook, list);
        else if (audiohook->type == AST_AUDIOHOOK_TYPE_MANIPULATE)
-               AST_LIST_INSERT_TAIL(&chan->audiohooks->manipulate_list, audiohook, list);
+               AST_LIST_INSERT_TAIL(&ast_channel_audiohooks(chan)->manipulate_list, audiohook, list);
 
 
-       audiohook_set_internal_rate(audiohook, chan->audiohooks->list_internal_samp_rate, 1);
-       audiohook_list_set_samplerate_compatibility(chan->audiohooks);
+       audiohook_set_internal_rate(audiohook, ast_channel_audiohooks(chan)->list_internal_samp_rate, 1);
+       audiohook_list_set_samplerate_compatibility(ast_channel_audiohooks(chan));
 
        /* Change status over to running since it is now attached */
        ast_audiohook_update_status(audiohook, AST_AUDIOHOOK_STATUS_RUNNING);
@@ -573,7 +575,7 @@ void ast_audiohook_move_by_source(struct ast_channel *old_chan, struct ast_chann
        struct ast_audiohook *audiohook;
        enum ast_audiohook_status oldstatus;
 
-       if (!old_chan->audiohooks || !(audiohook = find_audiohook_by_source(old_chan->audiohooks, source))) {
+       if (!ast_channel_audiohooks(old_chan) || !(audiohook = find_audiohook_by_source(ast_channel_audiohooks(old_chan), source))) {
                return;
        }
 
@@ -604,12 +606,12 @@ int ast_audiohook_detach_source(struct ast_channel *chan, const char *source)
        ast_channel_lock(chan);
 
        /* Ensure the channel has audiohooks on it */
-       if (!chan->audiohooks) {
+       if (!ast_channel_audiohooks(chan)) {
                ast_channel_unlock(chan);
                return -1;
        }
 
-       audiohook = find_audiohook_by_source(chan->audiohooks, source);
+       audiohook = find_audiohook_by_source(ast_channel_audiohooks(chan), source);
 
        ast_channel_unlock(chan);
 
@@ -633,19 +635,19 @@ int ast_audiohook_remove(struct ast_channel *chan, struct ast_audiohook *audioho
 {
        ast_channel_lock(chan);
 
-       if (!chan->audiohooks) {
+       if (!ast_channel_audiohooks(chan)) {
                ast_channel_unlock(chan);
                return -1;
        }
 
        if (audiohook->type == AST_AUDIOHOOK_TYPE_SPY)
-               AST_LIST_REMOVE(&chan->audiohooks->spy_list, audiohook, list);
+               AST_LIST_REMOVE(&ast_channel_audiohooks(chan)->spy_list, audiohook, list);
        else if (audiohook->type == AST_AUDIOHOOK_TYPE_WHISPER)
-               AST_LIST_REMOVE(&chan->audiohooks->whisper_list, audiohook, list);
+               AST_LIST_REMOVE(&ast_channel_audiohooks(chan)->whisper_list, audiohook, list);
        else if (audiohook->type == AST_AUDIOHOOK_TYPE_MANIPULATE)
-               AST_LIST_REMOVE(&chan->audiohooks->manipulate_list, audiohook, list);
+               AST_LIST_REMOVE(&ast_channel_audiohooks(chan)->manipulate_list, audiohook, list);
 
-       audiohook_list_set_samplerate_compatibility(chan->audiohooks);
+       audiohook_list_set_samplerate_compatibility(ast_channel_audiohooks(chan));
        ast_audiohook_update_status(audiohook, AST_AUDIOHOOK_STATUS_DONE);
 
        ast_channel_unlock(chan);
@@ -939,26 +941,26 @@ int ast_channel_audiohook_count_by_source(struct ast_channel *chan, const char *
        int count = 0;
        struct ast_audiohook *ah = NULL;
 
-       if (!chan->audiohooks)
+       if (!ast_channel_audiohooks(chan))
                return -1;
 
        switch (type) {
                case AST_AUDIOHOOK_TYPE_SPY:
-                       AST_LIST_TRAVERSE(&chan->audiohooks->spy_list, ah, list) {
+                       AST_LIST_TRAVERSE(&ast_channel_audiohooks(chan)->spy_list, ah, list) {
                                if (!strcmp(ah->source, source)) {
                                        count++;
                                }
                        }
                        break;
                case AST_AUDIOHOOK_TYPE_WHISPER:
-                       AST_LIST_TRAVERSE(&chan->audiohooks->whisper_list, ah, list) {
+                       AST_LIST_TRAVERSE(&ast_channel_audiohooks(chan)->whisper_list, ah, list) {
                                if (!strcmp(ah->source, source)) {
                                        count++;
                                }
                        }
                        break;
                case AST_AUDIOHOOK_TYPE_MANIPULATE:
-                       AST_LIST_TRAVERSE(&chan->audiohooks->manipulate_list, ah, list) {
+                       AST_LIST_TRAVERSE(&ast_channel_audiohooks(chan)->manipulate_list, ah, list) {
                                if (!strcmp(ah->source, source)) {
                                        count++;
                                }
@@ -977,24 +979,24 @@ int ast_channel_audiohook_count_by_source_running(struct ast_channel *chan, cons
 {
        int count = 0;
        struct ast_audiohook *ah = NULL;
-       if (!chan->audiohooks)
+       if (!ast_channel_audiohooks(chan))
                return -1;
 
        switch (type) {
                case AST_AUDIOHOOK_TYPE_SPY:
-                       AST_LIST_TRAVERSE(&chan->audiohooks->spy_list, ah, list) {
+                       AST_LIST_TRAVERSE(&ast_channel_audiohooks(chan)->spy_list, ah, list) {
                                if ((!strcmp(ah->source, source)) && (ah->status == AST_AUDIOHOOK_STATUS_RUNNING))
                                        count++;
                        }
                        break;
                case AST_AUDIOHOOK_TYPE_WHISPER:
-                       AST_LIST_TRAVERSE(&chan->audiohooks->whisper_list, ah, list) {
+                       AST_LIST_TRAVERSE(&ast_channel_audiohooks(chan)->whisper_list, ah, list) {
                                if ((!strcmp(ah->source, source)) && (ah->status == AST_AUDIOHOOK_STATUS_RUNNING))
                                        count++;
                        }
                        break;
                case AST_AUDIOHOOK_TYPE_MANIPULATE:
-                       AST_LIST_TRAVERSE(&chan->audiohooks->manipulate_list, ah, list) {
+                       AST_LIST_TRAVERSE(&ast_channel_audiohooks(chan)->manipulate_list, ah, list) {
                                if ((!strcmp(ah->source, source)) && (ah->status == AST_AUDIOHOOK_STATUS_RUNNING))
                                        count++;
                        }
@@ -1207,12 +1209,12 @@ int ast_audiohook_set_mute(struct ast_channel *chan, const char *source, enum as
        ast_channel_lock(chan);
 
        /* Ensure the channel has audiohooks on it */
-       if (!chan->audiohooks) {
+       if (!ast_channel_audiohooks(chan)) {
                ast_channel_unlock(chan);
                return -1;
        }
 
-       audiohook = find_audiohook_by_source(chan->audiohooks, source);
+       audiohook = find_audiohook_by_source(ast_channel_audiohooks(chan), source);
 
        if (audiohook) {
                if (clear) {
index b97150f04174c14a409779fa3758c02b02e9bb2b..8fecd53b72369fd9e8abced8306bfa96b8bffced 100644 (file)
@@ -1531,7 +1531,7 @@ void ast_bridge_update_talker_src_video_mode(struct ast_bridge *bridge, struct a
 {
        struct ast_bridge_video_talker_src_data *data;
        /* If the channel doesn't support video, we don't care about it */
-       if (!ast_format_cap_has_type(chan->nativeformats, AST_FORMAT_TYPE_VIDEO)) {
+       if (!ast_format_cap_has_type(ast_channel_nativeformats(chan), AST_FORMAT_TYPE_VIDEO)) {
                return;
        }
 
index e0925ab0a280fe119699bd08f25230c1211654f6..b1ec63a891338c8a18567d1dca484eacc45eb20b 100644 (file)
@@ -2686,7 +2686,7 @@ static void *generic_recall(void *data)
 
        ast_channel_exten_set(chan, generic_pvt->exten);
        ast_channel_context_set(chan, generic_pvt->context);
-       chan->priority = 1;
+       ast_channel_priority_set(chan, 1);
 
        pbx_builtin_setvar_helper(chan, "CC_EXTEN", generic_pvt->exten);
        pbx_builtin_setvar_helper(chan, "CC_CONTEXT", generic_pvt->context);
@@ -4045,7 +4045,7 @@ void ast_cc_call_failed(struct ast_channel *incoming, struct ast_channel *outgoi
        struct cc_control_payload payload;
        struct ast_cc_config_params *cc_params;
 
-       if (outgoing->hangupcause != AST_CAUSE_BUSY && outgoing->hangupcause != AST_CAUSE_CONGESTION) {
+       if (ast_channel_hangupcause(outgoing) != AST_CAUSE_BUSY && ast_channel_hangupcause(outgoing) != AST_CAUSE_CONGESTION) {
                /* It doesn't make sense to try to offer CCBS to the caller if the reason for ast_call
                 * failing is something other than busy or congestion
                 */
index 0c50a13d8c92882249d3a95420f8a59218c7df98..af6885308ebc0f833a8a02850b4be99411fc2ba0 100644 (file)
@@ -930,8 +930,8 @@ int ast_cdr_init(struct ast_cdr *cdr, struct ast_channel *c)
                        set_one_cid(cdr, c);
                        cdr_seq_inc(cdr);
 
-                       cdr->disposition = (c->_state == AST_STATE_UP) ?  AST_CDR_ANSWERED : AST_CDR_NOANSWER;
-                       cdr->amaflags = c->amaflags ? c->amaflags :  ast_default_amaflags;
+                       cdr->disposition = (ast_channel_state(c) == AST_STATE_UP) ?  AST_CDR_ANSWERED : AST_CDR_NOANSWER;
+                       cdr->amaflags = ast_channel_amaflags(c) ? ast_channel_amaflags(c) :  ast_default_amaflags;
                        ast_copy_string(cdr->accountcode, ast_channel_accountcode(c), sizeof(cdr->accountcode));
                        ast_copy_string(cdr->peeraccount, ast_channel_peeraccount(c), sizeof(cdr->peeraccount));
                        /* Destination information */
@@ -1019,7 +1019,7 @@ char *ast_cdr_flags2str(int flag)
 
 int ast_cdr_setaccount(struct ast_channel *chan, const char *account)
 {
-       struct ast_cdr *cdr = chan->cdr;
+       struct ast_cdr *cdr = ast_channel_cdr(chan);
        const char *old_acct = "";
 
        if (!ast_strlen_zero(ast_channel_accountcode(chan))) {
@@ -1045,7 +1045,7 @@ int ast_cdr_setaccount(struct ast_channel *chan, const char *account)
 
 int ast_cdr_setpeeraccount(struct ast_channel *chan, const char *account)
 {
-       struct ast_cdr *cdr = chan->cdr;
+       struct ast_cdr *cdr = ast_channel_cdr(chan);
        const char *old_acct = "";
 
        if (!ast_strlen_zero(ast_channel_peeraccount(chan))) {
@@ -1074,7 +1074,7 @@ int ast_cdr_setamaflags(struct ast_channel *chan, const char *flag)
        struct ast_cdr *cdr;
        int newflag = ast_cdr_amaflags2int(flag);
        if (newflag) {
-               for (cdr = chan->cdr; cdr; cdr = cdr->next) {
+               for (cdr = ast_channel_cdr(chan); cdr; cdr = cdr->next) {
                        if (!ast_test_flag(cdr, AST_CDR_FLAG_LOCKED)) {
                                cdr->amaflags = newflag;
                        }
@@ -1086,7 +1086,7 @@ int ast_cdr_setamaflags(struct ast_channel *chan, const char *flag)
 
 int ast_cdr_setuserfield(struct ast_channel *chan, const char *userfield)
 {
-       struct ast_cdr *cdr = chan->cdr;
+       struct ast_cdr *cdr = ast_channel_cdr(chan);
 
        for ( ; cdr ; cdr = cdr->next) {
                if (!ast_test_flag(cdr, AST_CDR_FLAG_LOCKED))
@@ -1098,7 +1098,7 @@ int ast_cdr_setuserfield(struct ast_channel *chan, const char *userfield)
 
 int ast_cdr_appenduserfield(struct ast_channel *chan, const char *userfield)
 {
-       struct ast_cdr *cdr = chan->cdr;
+       struct ast_cdr *cdr = ast_channel_cdr(chan);
 
        for ( ; cdr ; cdr = cdr->next) {
                int len = strlen(cdr->userfield);
@@ -1112,7 +1112,7 @@ int ast_cdr_appenduserfield(struct ast_channel *chan, const char *userfield)
 
 int ast_cdr_update(struct ast_channel *c)
 {
-       struct ast_cdr *cdr = c->cdr;
+       struct ast_cdr *cdr = ast_channel_cdr(c);
 
        for ( ; cdr ; cdr = cdr->next) {
                if (!ast_test_flag(cdr, AST_CDR_FLAG_LOCKED)) {
index feb67ed2407d242451553fcf6452e4b7d305c143..fdf1bf0f1e314d5ebd2a5285faeb39e5b336780f 100644 (file)
@@ -477,7 +477,7 @@ struct ast_channel *ast_cel_fabricate_channel_from_event(const struct ast_event
 
        ast_channel_appl_set(tchan, ast_strdup(record.application_name));
        ast_channel_data_set(tchan, ast_strdup(record.application_data));
-       tchan->amaflags = record.amaflag;
+       ast_channel_amaflags_set(tchan, record.amaflag);
 
        return tchan;
 }
@@ -566,7 +566,7 @@ int ast_cel_report_event(struct ast_channel *chan, enum ast_cel_event_type event
                AST_EVENT_IE_CEL_CHANNAME, AST_EVENT_IE_PLTYPE_STR, ast_channel_name(chan),
                AST_EVENT_IE_CEL_APPNAME, AST_EVENT_IE_PLTYPE_STR, S_OR(ast_channel_appl(chan), ""),
                AST_EVENT_IE_CEL_APPDATA, AST_EVENT_IE_PLTYPE_STR, S_OR(ast_channel_data(chan), ""),
-               AST_EVENT_IE_CEL_AMAFLAGS, AST_EVENT_IE_PLTYPE_UINT, chan->amaflags,
+               AST_EVENT_IE_CEL_AMAFLAGS, AST_EVENT_IE_PLTYPE_UINT, ast_channel_amaflags(chan),
                AST_EVENT_IE_CEL_ACCTCODE, AST_EVENT_IE_PLTYPE_STR, ast_channel_accountcode(chan),
                AST_EVENT_IE_CEL_PEERACCT, AST_EVENT_IE_PLTYPE_STR, ast_channel_peeraccount(chan),
                AST_EVENT_IE_CEL_UNIQUEID, AST_EVENT_IE_PLTYPE_STR, ast_channel_uniqueid(chan),
index bd560f50cd140eabc2fbe546d14a4df08c0e8835..a7cca1cadbd10f451c03b4ee83be5dd6ebb645bb 100644 (file)
@@ -431,7 +431,7 @@ static int kill_fixup(struct ast_channel *oldchan, struct ast_channel *newchan)
 
 static int kill_hangup(struct ast_channel *chan)
 {
-       chan->tech_pvt = NULL;
+       ast_channel_tech_pvt_set(chan, NULL);
        return 0;
 }
 
@@ -531,7 +531,7 @@ static int ast_channel_trace_data_update(struct ast_channel *chan, struct ast_ch
                /* save the current location and store it in the trace list */
                ast_copy_string(trace->context, ast_channel_context(chan), sizeof(trace->context));
                ast_copy_string(trace->exten, ast_channel_exten(chan), sizeof(trace->exten));
-               trace->priority = chan->priority;
+               trace->priority = ast_channel_priority(chan);
                AST_LIST_INSERT_HEAD(&traced->trace, trace, entry);
        }
        return 0;
@@ -920,6 +920,9 @@ __ast_channel_alloc_ap(int needqueue, int state, const char *cid_num, const char
        int flags;
        struct varshead *headp;
        char *tech = "", *tech2 = NULL;
+       struct ast_format_cap *nativeformats;
+       struct ast_sched_context *schedctx;
+       struct ast_timer *timer;
 
        /* If shutting down, don't allocate any new channels */
        if (shutting_down) {
@@ -940,17 +943,18 @@ __ast_channel_alloc_ap(int needqueue, int state, const char *cid_num, const char
                /* Channel structure allocation failure. */
                return NULL;
        }
-       if (!(tmp->nativeformats = ast_format_cap_alloc())) {
+       if (!(nativeformats = ast_format_cap_alloc())) {
                ao2_ref(tmp, -1);
                /* format capabilities structure allocation failure */
                return NULL;
        }
+       ast_channel_nativeformats_set(tmp, nativeformats);
 
        /*
         * Init file descriptors to unopened state so
         * the destructor can know not to close them.
         */
-       tmp->timingfd = -1;
+       ast_channel_timingfd_set(tmp, -1);
        for (x = 0; x < ARRAY_LEN(tmp->alertpipe); ++x) {
                tmp->alertpipe[x] = -1;
        }
@@ -958,13 +962,14 @@ __ast_channel_alloc_ap(int needqueue, int state, const char *cid_num, const char
                tmp->fds[x] = -1;
        }
 #ifdef HAVE_EPOLL
-       tmp->epfd = epoll_create(25);
+       ast_channel_epfd(tmp) = epoll_create(25);
 #endif
 
-       if (!(tmp->sched = ast_sched_context_create())) {
+       if (!(schedctx = ast_sched_context_create())) {
                ast_log(LOG_WARNING, "Channel allocation failed: Unable to create schedule context\n");
                return ast_channel_unref(tmp);
        }
+       ast_channel_sched_set(tmp, schedctx);
        
        ast_party_dialed_init(&tmp->dialed);
        ast_party_caller_init(&tmp->caller);
@@ -986,11 +991,12 @@ __ast_channel_alloc_ap(int needqueue, int state, const char *cid_num, const char
                }
        }
 
-       if ((tmp->timer = ast_timer_open())) {
-               if (strcmp(ast_timer_get_name(tmp->timer), "timerfd")) {
+       if ((timer = ast_timer_open())) {
+               ast_channel_timer_set(tmp, timer);
+               if (strcmp(ast_timer_get_name(ast_channel_timer(tmp)), "timerfd")) {
                        needqueue = 0;
                }
-               tmp->timingfd = ast_timer_fd(tmp->timer);
+               ast_channel_timingfd_set(tmp, ast_timer_fd(ast_channel_timer(tmp)));
        }
 
        if (needqueue) {
@@ -1025,15 +1031,15 @@ __ast_channel_alloc_ap(int needqueue, int state, const char *cid_num, const char
        /* Always watch the alertpipe */
        ast_channel_set_fd(tmp, AST_ALERT_FD, tmp->alertpipe[0]);
        /* And timing pipe */
-       ast_channel_set_fd(tmp, AST_TIMING_FD, tmp->timingfd);
+       ast_channel_set_fd(tmp, AST_TIMING_FD, ast_channel_timingfd(tmp));
 
        /* Initial state */
-       tmp->_state = state;
+       ast_channel_state_set(tmp, state);
 
-       tmp->streamid = -1;
+       ast_channel_streamid_set(tmp, -1);
        
-       tmp->fin = global_fin;
-       tmp->fout = global_fout;
+       ast_channel_fin_set(tmp, global_fin);
+       ast_channel_fout_set(tmp, global_fout);
 
        if (ast_strlen_zero(ast_config_AST_SYSTEM_NAME)) {
                ast_channel_uniqueid_build(tmp, "%li.%d", (long) time(NULL), 
@@ -1078,10 +1084,11 @@ __ast_channel_alloc_ap(int needqueue, int state, const char *cid_num, const char
        /* Reminder for the future: under what conditions do we NOT want to track cdrs on channels? */
 
        /* These 4 variables need to be set up for the cdr_init() to work right */
-       if (amaflag)
-               tmp->amaflags = amaflag;
-       else
-               tmp->amaflags = ast_default_amaflags;
+       if (amaflag) {
+               ast_channel_amaflags_set(tmp, amaflag);
+       } else {
+               ast_channel_amaflags_set(tmp, ast_default_amaflags);
+       }
        
        if (!ast_strlen_zero(acctcode))
                ast_channel_accountcode_set(tmp, acctcode);
@@ -1090,11 +1097,11 @@ __ast_channel_alloc_ap(int needqueue, int state, const char *cid_num, const char
                
        ast_channel_context_set(tmp, S_OR(context, "default"));
        ast_channel_exten_set(tmp, S_OR(exten, "s"));
-       tmp->priority = 1;
+       ast_channel_priority_set(tmp, -1);
 
-       tmp->cdr = ast_cdr_alloc();
-       ast_cdr_init(tmp->cdr, tmp);
-       ast_cdr_start(tmp->cdr);
+       ast_channel_cdr_set(tmp, ast_cdr_alloc());
+       ast_cdr_init(ast_channel_cdr(tmp), tmp);
+       ast_cdr_start(ast_channel_cdr(tmp));
 
        ast_cel_report_event(tmp, AST_CEL_CHANNEL_START, NULL, NULL, NULL);
 
@@ -1107,7 +1114,7 @@ __ast_channel_alloc_ap(int needqueue, int state, const char *cid_num, const char
        
        ast_channel_language_set(tmp, defaultlanguage);
 
-       tmp->tech = &null_tech;
+       ast_channel_tech_set(tmp, &null_tech);
 
        ao2_link(channels, tmp);
 
@@ -1304,8 +1311,8 @@ static int __ast_queue_frame(struct ast_channel *chan, struct ast_frame *fin, in
                        ast_log(LOG_WARNING, "Unable to write to alert pipe on %s (qlen = %d): %s!\n",
                                ast_channel_name(chan), queued_frames, strerror(errno));
                }
-       } else if (chan->timingfd > -1) {
-               ast_timer_enable_continuous(chan->timer);
+       } else if (ast_channel_timingfd(chan) > -1) {
+               ast_timer_enable_continuous(ast_channel_timer(chan));
        } else if (ast_test_flag(chan, AST_FLAG_BLOCKING)) {
                pthread_kill(chan->blocker, SIGURG);
        }
@@ -1354,7 +1361,7 @@ int ast_queue_hangup_with_cause(struct ast_channel *chan, int cause)
        if (!ast_channel_trylock(chan)) {
                chan->_softhangup |= AST_SOFTHANGUP_DEV;
                if (cause < 0)
-                       f.data.uint32 = chan->hangupcause;
+                       f.data.uint32 = ast_channel_hangupcause(chan);
 
                manager_event(EVENT_FLAG_CALL, "HangupRequest",
                        "Channel: %s\r\n"
@@ -1629,7 +1636,7 @@ int ast_safe_sleep_conditional(struct ast_channel *chan, int ms, int (*cond)(voi
        AST_LIST_HEAD_INIT_NOLOCK(&deferred_frames);
 
        /* If no other generator is present, start silencegen while waiting */
-       if (ast_opt_transmit_silence && !chan->generatordata) {
+       if (ast_opt_transmit_silence && !ast_channel_generatordata(chan)) {
                silgen = ast_channel_start_silence_generator(chan);
        }
 
@@ -2201,13 +2208,13 @@ static void ast_channel_destructor(void *obj)
        ast_channel_lock(chan);
        ast_channel_unlock(chan);
 
-       if (chan->tech_pvt) {
+       if (ast_channel_tech_pvt(chan)) {
                ast_log(LOG_WARNING, "Channel '%s' may not have been hung up properly\n", ast_channel_name(chan));
-               ast_free(chan->tech_pvt);
+               ast_free(ast_channel_tech_pvt(chan));
        }
 
-       if (chan->sched) {
-               ast_sched_context_destroy(chan->sched);
+       if (ast_channel_sched(chan)) {
+               ast_sched_context_destroy(ast_channel_sched(chan));
        }
 
        if (ast_channel_name(chan)) {
@@ -2223,19 +2230,19 @@ static void ast_channel_destructor(void *obj)
        }
 
        /* Stop monitoring */
-       if (chan->monitor)
-               chan->monitor->stop( chan, 0 );
+       if (ast_channel_monitor(chan))
+               ast_channel_monitor(chan)->stop( chan, 0 );
 
        /* If there is native format music-on-hold state, free it */
-       if (chan->music_state)
+       if (ast_channel_music_state(chan))
                ast_moh_cleanup(chan);
 
        /* Free translators */
-       if (chan->readtrans)
-               ast_translator_free_path(chan->readtrans);
-       if (chan->writetrans)
-               ast_translator_free_path(chan->writetrans);
-       if (chan->pbx)
+       if (ast_channel_readtrans(chan))
+               ast_translator_free_path(ast_channel_readtrans(chan));
+       if (ast_channel_writetrans(chan))
+               ast_translator_free_path(ast_channel_writetrans(chan));
+       if (ast_channel_pbx(chan))
                ast_log(LOG_WARNING, "PBX may not have been terminated properly on '%s'\n", ast_channel_name(chan));
 
        ast_party_dialed_free(&chan->dialed);
@@ -2248,15 +2255,15 @@ static void ast_channel_destructor(void *obj)
                close(fd);
        if ((fd = chan->alertpipe[1]) > -1)
                close(fd);
-       if (chan->timer) {
-               ast_timer_close(chan->timer);
+       if (ast_channel_timer(chan)) {
+               ast_timer_close(ast_channel_timer(chan));
        }
 #ifdef HAVE_EPOLL
        for (i = 0; i < AST_MAX_FDS; i++) {
                if (chan->epfd_data[i])
                        free(chan->epfd_data[i]);
        }
-       close(chan->epfd);
+       close(ast_channel_epfd(chan));
 #endif
        while ((f = AST_LIST_REMOVE_HEAD(&chan->readq, frame_list)))
                ast_frfree(f);
@@ -2272,13 +2279,13 @@ static void ast_channel_destructor(void *obj)
        /* Destroy the jitterbuffer */
        ast_jb_destroy(chan);
 
-       if (chan->cdr) {
-               ast_cdr_discard(chan->cdr);
-               chan->cdr = NULL;
+       if (ast_channel_cdr(chan)) {
+               ast_cdr_discard(ast_channel_cdr(chan));
+               ast_channel_cdr_set(chan, NULL);
        }
 
-       if (chan->zone) {
-               chan->zone = ast_tone_zone_unref(chan->zone);
+       if (ast_channel_zone(chan)) {
+               ast_channel_zone_set(chan, ast_tone_zone_unref(ast_channel_zone(chan)));
        }
 
        ast_string_field_free_memory(chan);
@@ -2294,7 +2301,7 @@ static void ast_channel_destructor(void *obj)
                ast_devstate_changed_literal(AST_DEVICE_UNKNOWN, device_name);
        }
 
-       chan->nativeformats = ast_format_cap_destroy(chan->nativeformats);
+       ast_channel_nativeformats_set(chan, ast_format_cap_destroy(ast_channel_nativeformats(chan)));
 }
 
 /*! \brief Free a dummy channel structure */
@@ -2316,9 +2323,9 @@ static void ast_dummy_channel_destructor(void *obj)
        while ((vardata = AST_LIST_REMOVE_HEAD(headp, entries)))
                ast_var_delete(vardata);
 
-       if (chan->cdr) {
-               ast_cdr_discard(chan->cdr);
-               chan->cdr = NULL;
+       if (ast_channel_cdr(chan)) {
+               ast_cdr_discard(ast_channel_cdr(chan));
+               ast_channel_cdr_set(chan, NULL);
        }
 
        ast_string_field_free_memory(chan);
@@ -2399,7 +2406,7 @@ void ast_channel_set_fd(struct ast_channel *chan, int which, int fd)
        struct ast_epoll_data *aed = NULL;
 
        if (chan->fds[which] > -1) {
-               epoll_ctl(chan->epfd, EPOLL_CTL_DEL, chan->fds[which], &ev);
+               epoll_ctl(ast_channel_epfd(chan), EPOLL_CTL_DEL, chan->fds[which], &ev);
                aed = chan->epfd_data[which];
        }
 
@@ -2414,7 +2421,7 @@ void ast_channel_set_fd(struct ast_channel *chan, int which, int fd)
                
                ev.events = EPOLLIN | EPOLLPRI | EPOLLERR | EPOLLHUP;
                ev.data.ptr = aed;
-               epoll_ctl(chan->epfd, EPOLL_CTL_ADD, fd, &ev);
+               epoll_ctl(ast_channel_epfd(chan), EPOLL_CTL_ADD, fd, &ev);
        } else if (aed) {
                /* We don't have to keep around this epoll data structure now */
                free(aed);
@@ -2432,7 +2439,7 @@ void ast_poll_channel_add(struct ast_channel *chan0, struct ast_channel *chan1)
        struct epoll_event ev;
        int i = 0;
 
-       if (chan0->epfd == -1)
+       if (ast_channel_epfd(chan0) == -1)
                return;
 
        /* Iterate through the file descriptors on chan1, adding them to chan0 */
@@ -2441,7 +2448,7 @@ void ast_poll_channel_add(struct ast_channel *chan0, struct ast_channel *chan1)
                        continue;
                ev.events = EPOLLIN | EPOLLPRI | EPOLLERR | EPOLLHUP;
                ev.data.ptr = chan1->epfd_data[i];
-               epoll_ctl(chan0->epfd, EPOLL_CTL_ADD, chan1->fds[i], &ev);
+               epoll_ctl(ast_channel_epfd(chan0), EPOLL_CTL_ADD, chan1->fds[i], &ev);
        }
 
 #endif
@@ -2455,13 +2462,13 @@ void ast_poll_channel_del(struct ast_channel *chan0, struct ast_channel *chan1)
        struct epoll_event ev;
        int i = 0;
 
-       if (chan0->epfd == -1)
+       if (ast_channel_epfd(chan0) == -1)
                return;
 
        for (i = 0; i < AST_MAX_FDS; i++) {
                if (chan1->fds[i] == -1)
                        continue;
-               epoll_ctl(chan0->epfd, EPOLL_CTL_DEL, chan1->fds[i], &ev);
+               epoll_ctl(ast_channel_epfd(chan0), EPOLL_CTL_DEL, chan1->fds[i], &ev);
        }
 
 #endif
@@ -2527,18 +2534,18 @@ int ast_softhangup(struct ast_channel *chan, int cause)
 
 static void free_translation(struct ast_channel *clonechan)
 {
-       if (clonechan->writetrans)
-               ast_translator_free_path(clonechan->writetrans);
-       if (clonechan->readtrans)
-               ast_translator_free_path(clonechan->readtrans);
-       clonechan->writetrans = NULL;
-       clonechan->readtrans = NULL;
-       if (ast_format_cap_is_empty(clonechan->nativeformats)) {
+       if (ast_channel_writetrans(clonechan))
+               ast_translator_free_path(ast_channel_writetrans(clonechan));
+       if (ast_channel_readtrans(clonechan))
+               ast_translator_free_path(ast_channel_readtrans(clonechan));
+       ast_channel_writetrans_set(clonechan, NULL);
+       ast_channel_readtrans_set(clonechan, NULL);
+       if (ast_format_cap_is_empty(ast_channel_nativeformats(clonechan))) {
                ast_format_clear(&clonechan->rawwriteformat);
                ast_format_clear(&clonechan->rawreadformat);
        } else {
                struct ast_format tmpfmt;
-               ast_best_codec(clonechan->nativeformats, &tmpfmt);
+               ast_best_codec(ast_channel_nativeformats(clonechan), &tmpfmt);
                ast_format_copy(&clonechan->rawwriteformat, &tmpfmt);
                ast_format_copy(&clonechan->rawreadformat, &tmpfmt);
        }
@@ -2564,9 +2571,9 @@ void ast_set_hangupsource(struct ast_channel *chan, const char *source, int forc
 
 static void destroy_hooks(struct ast_channel *chan)
 {
-       if (chan->audiohooks) {
-               ast_audiohook_detach_list(chan->audiohooks);
-               chan->audiohooks = NULL;
+       if (ast_channel_audiohooks(chan)) {
+               ast_audiohook_detach_list(ast_channel_audiohooks(chan));
+               ast_channel_audiohooks_set(chan, NULL);
        }
 
        ast_framehook_list_destroy(chan);
@@ -2590,7 +2597,7 @@ int ast_hangup(struct ast_channel *chan)
         * prevent __ast_channel_masquerade() from setting up a
         * masquerade with a dead channel.
         */
-       while (chan->masq) {
+       while (ast_channel_masq(chan)) {
                ast_channel_unlock(chan);
                if (ast_do_masquerade(chan)) {
                        ast_log(LOG_WARNING, "Failed to perform masquerade\n");
@@ -2602,7 +2609,7 @@ int ast_hangup(struct ast_channel *chan)
                ast_channel_lock(chan);
        }
 
-       if (chan->masqr) {
+       if (ast_channel_masqr(chan)) {
                /*
                 * This channel is one which will be masqueraded into something.
                 * Mark it as a zombie already so ast_do_masquerade() will know
@@ -2626,29 +2633,29 @@ int ast_hangup(struct ast_channel *chan)
 
        free_translation(chan);
        /* Close audio stream */
-       if (chan->stream) {
-               ast_closestream(chan->stream);
-               chan->stream = NULL;
+       if (ast_channel_stream(chan)) {
+               ast_closestream(ast_channel_stream(chan));
+               ast_channel_stream_set(chan, NULL);
        }
        /* Close video stream */
-       if (chan->vstream) {
-               ast_closestream(chan->vstream);
-               chan->vstream = NULL;
+       if (ast_channel_vstream(chan)) {
+               ast_closestream(ast_channel_vstream(chan));
+               ast_channel_vstream_set(chan, NULL);
        }
-       if (chan->sched) {
-               ast_sched_context_destroy(chan->sched);
-               chan->sched = NULL;
+       if (ast_channel_sched(chan)) {
+               ast_sched_context_destroy(ast_channel_sched(chan));
+               ast_channel_sched_set(chan, NULL);
        }
 
-       if (chan->generatordata) {      /* Clear any tone stuff remaining */
-               if (chan->generator && chan->generator->release) {
-                       chan->generator->release(chan, chan->generatordata);
+       if (ast_channel_generatordata(chan)) {  /* Clear any tone stuff remaining */
+               if (ast_channel_generator(chan) && ast_channel_generator(chan)->release) {
+                       ast_channel_generator(chan)->release(chan, ast_channel_generatordata(chan));
                }
        }
-       chan->generatordata = NULL;
-       chan->generator = NULL;
+       ast_channel_generatordata_set(chan, NULL);
+       ast_channel_generator_set(chan, NULL);
 
-       snprintf(extra_str, sizeof(extra_str), "%d,%s,%s", chan->hangupcause, ast_channel_hangupsource(chan), S_OR(pbx_builtin_getvar_helper(chan, "DIALSTATUS"), ""));
+       snprintf(extra_str, sizeof(extra_str), "%d,%s,%s", ast_channel_hangupcause(chan), ast_channel_hangupsource(chan), S_OR(pbx_builtin_getvar_helper(chan, "DIALSTATUS"), ""));
        ast_cel_report_event(chan, AST_CEL_HANGUP, NULL, extra_str, NULL);
 
        if (ast_test_flag(chan, AST_FLAG_BLOCKING)) {
@@ -2660,8 +2667,8 @@ int ast_hangup(struct ast_channel *chan)
        if (!was_zombie) {
                ast_debug(1, "Hanging up channel '%s'\n", ast_channel_name(chan));
 
-               if (chan->tech->hangup) {
-                       chan->tech->hangup(chan);
+               if (ast_channel_tech(chan)->hangup) {
+                       ast_channel_tech(chan)->hangup(chan);
                }
        } else {
                ast_debug(1, "Hanging up zombie '%s'\n", ast_channel_name(chan));
@@ -2685,17 +2692,17 @@ int ast_hangup(struct ast_channel *chan)
                S_COR(chan->caller.id.name.valid, chan->caller.id.name.str, "<unknown>"),
                S_COR(chan->connected.id.number.valid, chan->connected.id.number.str, "<unknown>"),
                S_COR(chan->connected.id.name.valid, chan->connected.id.name.str, "<unknown>"),
-               chan->hangupcause,
-               ast_cause2str(chan->hangupcause)
+               ast_channel_hangupcause(chan),
+               ast_cause2str(ast_channel_hangupcause(chan))
                );
 
-       if (chan->cdr && !ast_test_flag(chan->cdr, AST_CDR_FLAG_BRIDGED) &&
-               !ast_test_flag(chan->cdr, AST_CDR_FLAG_POST_DISABLED) &&
-               (chan->cdr->disposition != AST_CDR_NULL || ast_test_flag(chan->cdr, AST_CDR_FLAG_DIALED))) {
+       if (ast_channel_cdr(chan) && !ast_test_flag(ast_channel_cdr(chan), AST_CDR_FLAG_BRIDGED) &&
+               !ast_test_flag(ast_channel_cdr(chan), AST_CDR_FLAG_POST_DISABLED) &&
+               (ast_channel_cdr(chan)->disposition != AST_CDR_NULL || ast_test_flag(ast_channel_cdr(chan), AST_CDR_FLAG_DIALED))) {
                ast_channel_lock(chan);
-               ast_cdr_end(chan->cdr);
-               ast_cdr_detach(chan->cdr);
-               chan->cdr = NULL;
+               ast_cdr_end(ast_channel_cdr(chan));
+               ast_cdr_detach(ast_channel_cdr(chan));
+               ast_channel_cdr_set(chan, NULL);
                ast_channel_unlock(chan);
        }
 
@@ -2724,16 +2731,16 @@ int ast_raw_answer(struct ast_channel *chan, int cdr_answer)
 
        ast_channel_unlock(chan);
 
-       switch (chan->_state) {
+       switch (ast_channel_state(chan)) {
        case AST_STATE_RINGING:
        case AST_STATE_RING:
                ast_channel_lock(chan);
-               if (chan->tech->answer) {
-                       res = chan->tech->answer(chan);
+               if (ast_channel_tech(chan)->answer) {
+                       res = ast_channel_tech(chan)->answer(chan);
                }
                ast_setstate(chan, AST_STATE_UP);
                if (cdr_answer) {
-                       ast_cdr_answer(chan->cdr);
+                       ast_cdr_answer(ast_channel_cdr(chan));
                }
                ast_cel_report_event(chan, AST_CEL_ANSWER, NULL, NULL, NULL);
                ast_channel_unlock(chan);
@@ -2744,7 +2751,7 @@ int ast_raw_answer(struct ast_channel *chan, int cdr_answer)
                 * is essentially a no-op, so it is safe.
                 */
                if (cdr_answer) {
-                       ast_cdr_answer(chan->cdr);
+                       ast_cdr_answer(ast_channel_cdr(chan));
                }
                break;
        default:
@@ -2761,7 +2768,7 @@ int __ast_answer(struct ast_channel *chan, unsigned int delay, int cdr_answer)
        int res = 0;
        enum ast_channel_state old_state;
 
-       old_state = chan->_state;
+       old_state = ast_channel_state(chan);
        if ((res = ast_raw_answer(chan, cdr_answer))) {
                return res;
        }
@@ -2865,11 +2872,11 @@ int ast_answer(struct ast_channel *chan)
 void ast_deactivate_generator(struct ast_channel *chan)
 {
        ast_channel_lock(chan);
-       if (chan->generatordata) {
-               if (chan->generator && chan->generator->release)
-                       chan->generator->release(chan, chan->generatordata);
-               chan->generatordata = NULL;
-               chan->generator = NULL;
+       if (ast_channel_generatordata(chan)) {
+               if (ast_channel_generator(chan) && ast_channel_generator(chan)->release)
+                       ast_channel_generator(chan)->release(chan, ast_channel_generatordata(chan));
+               ast_channel_generatordata_set(chan, NULL);
+               ast_channel_generator_set(chan, NULL);
                ast_channel_set_fd(chan, AST_GENERATOR_FD, -1);
                ast_clear_flag(chan, AST_FLAG_WRITE_INT);
                ast_settimeout(chan, 0, NULL, NULL);
@@ -2880,8 +2887,8 @@ void ast_deactivate_generator(struct ast_channel *chan)
 static void generator_write_format_change(struct ast_channel *chan)
 {
        ast_channel_lock(chan);
-       if (chan->generator && chan->generator->write_format_change) {
-               chan->generator->write_format_change(chan, chan->generatordata);
+       if (ast_channel_generator(chan) && ast_channel_generator(chan)->write_format_change) {
+               ast_channel_generator(chan)->write_format_change(chan, ast_channel_generatordata(chan));
        }
        ast_channel_unlock(chan);
 }
@@ -2895,10 +2902,10 @@ static int generator_force(const void *data)
        struct ast_channel *chan = (struct ast_channel *)data;
 
        ast_channel_lock(chan);
-       tmp = chan->generatordata;
-       chan->generatordata = NULL;
-       if (chan->generator)
-               generate = chan->generator->generate;
+       tmp = ast_channel_generatordata(chan);
+       ast_channel_generatordata_set(chan, NULL);
+       if (ast_channel_generator(chan))
+               generate = ast_channel_generator(chan)->generate;
        ast_channel_unlock(chan);
 
        if (!tmp || !generate)
@@ -2906,7 +2913,7 @@ static int generator_force(const void *data)
 
        res = generate(chan, tmp, 0, ast_format_rate(&chan->writeformat) / 50);
 
-       chan->generatordata = tmp;
+       ast_channel_generatordata_set(chan, tmp);
 
        if (res) {
                ast_debug(1, "Auto-deactivating generator\n");
@@ -2919,19 +2926,21 @@ static int generator_force(const void *data)
 int ast_activate_generator(struct ast_channel *chan, struct ast_generator *gen, void *params)
 {
        int res = 0;
+       void *generatordata;
 
        ast_channel_lock(chan);
-       if (chan->generatordata) {
-               if (chan->generator && chan->generator->release)
-                       chan->generator->release(chan, chan->generatordata);
-               chan->generatordata = NULL;
+       if (ast_channel_generatordata(chan)) {
+               if (ast_channel_generator(chan) && ast_channel_generator(chan)->release)
+                       ast_channel_generator(chan)->release(chan, ast_channel_generatordata(chan));
+               ast_channel_generatordata_set(chan, NULL);
        }
-       if (gen->alloc && !(chan->generatordata = gen->alloc(chan, params))) {
+       if (gen->alloc && !(generatordata = gen->alloc(chan, params))) {
                res = -1;
        }
        if (!res) {
                ast_settimeout(chan, 50, generator_force, chan);
-               chan->generator = gen;
+               ast_channel_generatordata_set(chan, generatordata);
+               ast_channel_generator_set(chan, gen);
        }
        ast_channel_unlock(chan);
 
@@ -2983,7 +2992,7 @@ struct ast_channel *ast_waitfor_nandfds(struct ast_channel **c, int n, int *fds,
        
        /* Perform any pending masquerades */
        for (x = 0; x < n; x++) {
-               if (c[x]->masq && ast_do_masquerade(c[x])) {
+               if (ast_channel_masq(c[x]) && ast_do_masquerade(c[x])) {
                        ast_log(LOG_WARNING, "Masquerade failed\n");
                        *ms = -1;
                        return NULL;
@@ -3088,7 +3097,7 @@ struct ast_channel *ast_waitfor_nandfds(struct ast_channel **c, int n, int *fds,
                                ast_set_flag(winner, AST_FLAG_EXCEPTION);
                        else
                                ast_clear_flag(winner, AST_FLAG_EXCEPTION);
-                       winner->fdno = fdmap[x].fdno;
+                       ast_channel_fdno_set(winner, fdmap[x].fdno);
                } else {                        /* this is an fd */
                        if (outfd)
                                *outfd = pfds[x].fd;
@@ -3117,7 +3126,7 @@ static struct ast_channel *ast_waitfor_nandfds_simple(struct ast_channel *chan,
 
 
        /* See if this channel needs to be masqueraded */
-       if (chan->masq && ast_do_masquerade(chan)) {
+       if (ast_channel_masq(chan) && ast_do_masquerade(chan)) {
                ast_log(LOG_WARNING, "Failed to perform masquerade on %s\n", ast_channel_name(chan));
                *ms = -1;
                return NULL;
@@ -3146,7 +3155,7 @@ static struct ast_channel *ast_waitfor_nandfds_simple(struct ast_channel *chan,
                start = ast_tvnow();
 
        /* We don't have to add any file descriptors... they are already added, we just have to wait! */
-       res = epoll_wait(chan->epfd, ev, 1, rms);
+       res = epoll_wait(ast_channel_epfd(chan), ev, 1, rms);
 
        /* Stop blocking */
        ast_clear_flag(chan, AST_FLAG_BLOCKING);
@@ -3174,7 +3183,7 @@ static struct ast_channel *ast_waitfor_nandfds_simple(struct ast_channel *chan,
 
        /* See what events are pending */
        aed = ev[0].data.ptr;
-       chan->fdno = aed->which;
+       ast_channel_fdno_set(chan, aed->which);
        if (ev[0].events & EPOLLPRI)
                ast_set_flag(chan, AST_FLAG_EXCEPTION);
        else
@@ -3199,7 +3208,7 @@ static struct ast_channel *ast_waitfor_nandfds_complex(struct ast_channel **c, i
        struct ast_channel *winner = NULL;
 
        for (i = 0; i < n; i++) {
-               if (c[i]->masq && ast_do_masquerade(c[i])) {
+               if (ast_channel_masq(c[i]) && ast_do_masquerade(c[i])) {
                        ast_log(LOG_WARNING, "Masquerade failed\n");
                        *ms = -1;
                        return NULL;
@@ -3231,7 +3240,7 @@ static struct ast_channel *ast_waitfor_nandfds_complex(struct ast_channel **c, i
        if (*ms > 0)
                start = ast_tvnow();
 
-       res = epoll_wait(c[0]->epfd, ev, 25, rms);
+       res = epoll_wait(ast_channel_epfd(c[0]), ev, 25, rms);
 
        for (i = 0; i < n; i++)
                ast_clear_flag(c[i], AST_FLAG_BLOCKING);
@@ -3269,7 +3278,7 @@ static struct ast_channel *ast_waitfor_nandfds_complex(struct ast_channel **c, i
                        ast_set_flag(winner, AST_FLAG_EXCEPTION);
                else
                        ast_clear_flag(winner, AST_FLAG_EXCEPTION);
-               winner->fdno = aed->which;
+               ast_channel_fdno_set(winner, aed->which);
        }
 
        if (*ms > 0) {
@@ -3291,7 +3300,7 @@ struct ast_channel *ast_waitfor_nandfds(struct ast_channel **c, int n, int *fds,
                *exception = 0;
 
        /* If no epoll file descriptor is available resort to classic nandfds */
-       if (!n || nfds || c[0]->epfd == -1)
+       if (!n || nfds || ast_channel_epfd(c[0]) == -1)
                return ast_waitfor_nandfds_classic(c, n, fds, nfds, exception, outfd, ms);
        else if (!nfds && n == 1)
                return ast_waitfor_nandfds_simple(c[0], ms);
@@ -3328,7 +3337,7 @@ int ast_settimeout(struct ast_channel *c, unsigned int rate, int (*func)(const v
 
        ast_channel_lock(c);
 
-       if (c->timingfd == -1) {
+       if (ast_channel_timingfd(c) == -1) {
                ast_channel_unlock(c);
                return -1;
        }
@@ -3338,16 +3347,16 @@ int ast_settimeout(struct ast_channel *c, unsigned int rate, int (*func)(const v
                data = NULL;
        }
 
-       if (rate && rate > (max_rate = ast_timer_get_max_rate(c->timer))) {
+       if (rate && rate > (max_rate = ast_timer_get_max_rate(ast_channel_timer(c)))) {
                real_rate = max_rate;
        }
 
        ast_debug(1, "Scheduling timer at (%u requested / %u actual) timer ticks per second\n", rate, real_rate);
 
-       res = ast_timer_set_rate(c->timer, real_rate);
+       res = ast_timer_set_rate(ast_channel_timer(c), real_rate);
 
        c->timingfunc = func;
-       c->timingdata = data;
+       ast_channel_timingdata_set(c, data);
 
        ast_channel_unlock(c);
 
@@ -3453,9 +3462,9 @@ static void send_dtmf_event(struct ast_channel *chan, const char *direction, con
 
 static void ast_read_generator_actions(struct ast_channel *chan, struct ast_frame *f)
 {
-       if (chan->generator && chan->generator->generate && chan->generatordata &&  !ast_internal_timing_enabled(chan)) {
-               void *tmp = chan->generatordata;
-               int (*generate)(struct ast_channel *chan, void *tmp, int datalen, int samples) = chan->generator->generate;
+       if (ast_channel_generator(chan) && ast_channel_generator(chan)->generate && ast_channel_generatordata(chan) &&  !ast_internal_timing_enabled(chan)) {
+               void *tmp = ast_channel_generatordata(chan);
+               int (*generate)(struct ast_channel *chan, void *tmp, int datalen, int samples) = ast_channel_generator(chan)->generate;
                int res;
                int samples;
 
@@ -3464,7 +3473,7 @@ static void ast_read_generator_actions(struct ast_channel *chan, struct ast_fram
                        ast_settimeout(chan, 0, NULL, NULL);
                }
 
-               chan->generatordata = NULL;     /* reset, to let writes go through */
+               ast_channel_generatordata_set(chan, NULL);     /* reset, to let writes go through */
 
                if (ast_format_cmp(&f->subclass.format, &chan->writeformat) == AST_FORMAT_CMP_NOT_EQUAL) {
                        float factor;
@@ -3485,14 +3494,14 @@ static void ast_read_generator_actions(struct ast_channel *chan, struct ast_fram
                ast_channel_unlock(chan);
                res = generate(chan, tmp, f->datalen, samples);
                ast_channel_lock(chan);
-               chan->generatordata = tmp;
+               ast_channel_generatordata_set(chan, tmp);
                if (res) {
                        ast_debug(1, "Auto-deactivating generator\n");
                        ast_deactivate_generator(chan);
                }
 
        } else if (f->frametype == AST_FRAME_CNG) {
-               if (chan->generator && !chan->timingfunc && (chan->timingfd > -1)) {
+               if (ast_channel_generator(chan) && !chan->timingfunc && (ast_channel_timingfd(chan) > -1)) {
                        ast_debug(1, "Generator got CNG, switching to timed mode\n");
                        ast_settimeout(chan, 50, generator_force, chan);
                }
@@ -3568,7 +3577,7 @@ static struct ast_frame *__ast_read(struct ast_channel *chan, int dropaudio)
         * point at the end (there are only two exceptions to this).
         */
 
-       if (chan->masq) {
+       if (ast_channel_masq(chan)) {
                if (ast_do_masquerade(chan))
                        ast_log(LOG_WARNING, "Failed to perform masquerade\n");
                else
@@ -3581,7 +3590,7 @@ static struct ast_frame *__ast_read(struct ast_channel *chan, int dropaudio)
 
        /* Stop if we're a zombie or need a soft hangup */
        if (ast_test_flag(chan, AST_FLAG_ZOMBIE) || ast_check_hangup(chan)) {
-               if (chan->generator)
+               if (ast_channel_generator(chan))
                        ast_deactivate_generator(chan);
 
                /*
@@ -3612,7 +3621,7 @@ static struct ast_frame *__ast_read(struct ast_channel *chan, int dropaudio)
                 *
                 * One of the potential problems is blocking on a dead channel.
                 */
-               if (chan->fdno == -1) {
+               if (ast_channel_fdno(chan) == -1) {
                        ast_log(LOG_ERROR,
                                "ast_read() on chan '%s' called with no recorded file descriptor.\n",
                                ast_channel_name(chan));
@@ -3620,7 +3629,7 @@ static struct ast_frame *__ast_read(struct ast_channel *chan, int dropaudio)
 #endif
        }
 
-       prestate = chan->_state;
+       prestate = ast_channel_state(chan);
 
        /* Read and ignore anything on the alertpipe, but read only
           one sizeof(blah) per frame that we send from it */
@@ -3642,27 +3651,27 @@ static struct ast_frame *__ast_read(struct ast_channel *chan, int dropaudio)
                }
        }
 
-       if (chan->timingfd > -1 && chan->fdno == AST_TIMING_FD) {
+       if (ast_channel_timingfd(chan) > -1 && ast_channel_fdno(chan) == AST_TIMING_FD) {
                enum ast_timer_event res;
 
                ast_clear_flag(chan, AST_FLAG_EXCEPTION);
 
-               res = ast_timer_get_event(chan->timer);
+               res = ast_timer_get_event(ast_channel_timer(chan));
 
                switch (res) {
                case AST_TIMING_EVENT_EXPIRED:
-                       ast_timer_ack(chan->timer, 1);
+                       ast_timer_ack(ast_channel_timer(chan), 1);
 
                        if (chan->timingfunc) {
                                /* save a copy of func/data before unlocking the channel */
                                int (*func)(const void *) = chan->timingfunc;
-                               void *data = chan->timingdata;
-                               chan->fdno = -1;
+                               void *data = ast_channel_timingdata(chan);
+                               ast_channel_fdno_set(chan, -1);
                                ast_channel_unlock(chan);
                                func(data);
                        } else {
-                               ast_timer_set_rate(chan->timer, 0);
-                               chan->fdno = -1;
+                               ast_timer_set_rate(ast_channel_timer(chan), 0);
+                               ast_channel_fdno_set(chan, -1);
                                ast_channel_unlock(chan);
                        }
 
@@ -3672,23 +3681,23 @@ static struct ast_frame *__ast_read(struct ast_channel *chan, int dropaudio)
                case AST_TIMING_EVENT_CONTINUOUS:
                        if (AST_LIST_EMPTY(&chan->readq) || 
                                !AST_LIST_NEXT(AST_LIST_FIRST(&chan->readq), frame_list)) {
-                               ast_timer_disable_continuous(chan->timer);
+                               ast_timer_disable_continuous(ast_channel_timer(chan));
                        }
                        break;
                }
 
-       } else if (chan->fds[AST_GENERATOR_FD] > -1 && chan->fdno == AST_GENERATOR_FD) {
+       } else if (chan->fds[AST_GENERATOR_FD] > -1 && ast_channel_fdno(chan) == AST_GENERATOR_FD) {
                /* if the AST_GENERATOR_FD is set, call the generator with args
                 * set to -1 so it can do whatever it needs to.
                 */
-               void *tmp = chan->generatordata;
-               chan->generatordata = NULL;     /* reset to let ast_write get through */
-               chan->generator->generate(chan, tmp, -1, -1);
-               chan->generatordata = tmp;
+               void *tmp = ast_channel_generatordata(chan);
+               ast_channel_generatordata_set(chan, NULL);     /* reset to let ast_write get through */
+               ast_channel_generator(chan)->generate(chan, tmp, -1, -1);
+               ast_channel_generatordata_set(chan, tmp);
                f = &ast_null_frame;
-               chan->fdno = -1;
+               ast_channel_fdno_set(chan, -1);
                goto done;
-       } else if (chan->fds[AST_JITTERBUFFER_FD] > -1 && chan->fdno == AST_JITTERBUFFER_FD) {
+       } else if (chan->fds[AST_JITTERBUFFER_FD] > -1 && ast_channel_fdno(chan) == AST_JITTERBUFFER_FD) {
                ast_clear_flag(chan, AST_FLAG_EXCEPTION);
        }
 
@@ -3742,29 +3751,29 @@ static struct ast_frame *__ast_read(struct ast_channel *chan, int dropaudio)
        } else {
                chan->blocker = pthread_self();
                if (ast_test_flag(chan, AST_FLAG_EXCEPTION)) {
-                       if (chan->tech->exception)
-                               f = chan->tech->exception(chan);
+                       if (ast_channel_tech(chan)->exception)
+                               f = ast_channel_tech(chan)->exception(chan);
                        else {
                                ast_log(LOG_WARNING, "Exception flag set on '%s', but no exception handler\n", ast_channel_name(chan));
                                f = &ast_null_frame;
                        }
                        /* Clear the exception flag */
                        ast_clear_flag(chan, AST_FLAG_EXCEPTION);
-               } else if (chan->tech && chan->tech->read)
-                       f = chan->tech->read(chan);
+               } else if (ast_channel_tech(chan) && ast_channel_tech(chan)->read)
+                       f = ast_channel_tech(chan)->read(chan);
                else
                        ast_log(LOG_WARNING, "No read routine on channel %s\n", ast_channel_name(chan));
        }
 
        /* Perform the framehook read event here. After the frame enters the framehook list
         * there is no telling what will happen, <insert mad scientist laugh here>!!! */
-       f = ast_framehook_list_read_event(chan->framehooks, f);
+       f = ast_framehook_list_read_event(ast_channel_framehooks(chan), f);
 
        /*
         * Reset the recorded file descriptor that triggered this read so that we can
         * easily detect when ast_read() is called without properly using ast_waitfor().
         */
-       chan->fdno = -1;
+       ast_channel_fdno_set(chan, -1);
 
        if (f) {
                struct ast_frame *readq_tail = AST_LIST_LAST(&chan->readq);
@@ -3839,23 +3848,23 @@ static struct ast_frame *__ast_read(struct ast_channel *chan, int dropaudio)
                                        /* There was no begin, turn this into a begin and send the end later */
                                        f->frametype = AST_FRAME_DTMF_BEGIN;
                                        ast_set_flag(chan, AST_FLAG_EMULATE_DTMF);
-                                       chan->emulate_dtmf_digit = f->subclass.integer;
+                                       ast_channel_emulate_dtmf_digit_set(chan, f->subclass.integer);
                                        chan->dtmf_tv = ast_tvnow();
                                        if (f->len) {
                                                if (f->len > AST_MIN_DTMF_DURATION)
-                                                       chan->emulate_dtmf_duration = f->len;
+                                                       ast_channel_emulate_dtmf_duration_set(chan, f->len);
                                                else 
-                                                       chan->emulate_dtmf_duration = AST_MIN_DTMF_DURATION;
+                                                       ast_channel_emulate_dtmf_duration_set(chan, AST_MIN_DTMF_DURATION);
                                        } else
-                                               chan->emulate_dtmf_duration = AST_DEFAULT_EMULATE_DTMF_DURATION;
-                                       ast_log(LOG_DTMF, "DTMF begin emulation of '%c' with duration %u queued on %s\n", f->subclass.integer, chan->emulate_dtmf_duration, ast_channel_name(chan));
+                                               ast_channel_emulate_dtmf_duration_set(chan, AST_DEFAULT_EMULATE_DTMF_DURATION);
+                                       ast_log(LOG_DTMF, "DTMF begin emulation of '%c' with duration %u queued on %s\n", f->subclass.integer, ast_channel_emulate_dtmf_duration(chan), ast_channel_name(chan));
                                }
-                               if (chan->audiohooks) {
+                               if (ast_channel_audiohooks(chan)) {
                                        struct ast_frame *old_frame = f;
                                        /*!
                                         * \todo XXX It is possible to write a digit to the audiohook twice
                                         * if the digit was originally read while the channel was in autoservice. */
-                                       f = ast_audiohook_write_list(chan, chan->audiohooks, AST_AUDIOHOOK_DIRECTION_READ, f);
+                                       f = ast_audiohook_write_list(chan, ast_channel_audiohooks(chan), AST_AUDIOHOOK_DIRECTION_READ, f);
                                        if (old_frame != f)
                                                ast_frfree(old_frame);
                                }
@@ -3886,8 +3895,8 @@ static struct ast_frame *__ast_read(struct ast_channel *chan, int dropaudio)
                                if (f->len < AST_MIN_DTMF_DURATION && !ast_test_flag(chan, AST_FLAG_END_DTMF_ONLY)) {
                                        ast_log(LOG_DTMF, "DTMF end '%c' has duration %ld but want minimum %d, emulating on %s\n", f->subclass.integer, f->len, AST_MIN_DTMF_DURATION, ast_channel_name(chan));
                                        ast_set_flag(chan, AST_FLAG_EMULATE_DTMF);
-                                       chan->emulate_dtmf_digit = f->subclass.integer;
-                                       chan->emulate_dtmf_duration = AST_MIN_DTMF_DURATION - f->len;
+                                       ast_channel_emulate_dtmf_digit_set(chan, f->subclass.integer);
+                                       ast_channel_emulate_dtmf_duration_set(chan, AST_MIN_DTMF_DURATION - f->len);
                                        ast_frfree(f);
                                        f = &ast_null_frame;
                                } else {
@@ -3897,9 +3906,9 @@ static struct ast_frame *__ast_read(struct ast_channel *chan, int dropaudio)
                                        }
                                        chan->dtmf_tv = now;
                                }
-                               if (chan->audiohooks) {
+                               if (ast_channel_audiohooks(chan)) {
                                        struct ast_frame *old_frame = f;
-                                       f = ast_audiohook_write_list(chan, chan->audiohooks, AST_AUDIOHOOK_DIRECTION_READ, f);
+                                       f = ast_audiohook_write_list(chan, ast_channel_audiohooks(chan), AST_AUDIOHOOK_DIRECTION_READ, f);
                                        if (old_frame != f)
                                                ast_frfree(old_frame);
                                }
@@ -3927,23 +3936,23 @@ static struct ast_frame *__ast_read(struct ast_channel *chan, int dropaudio)
                         * between DTMF digits. */
                        if (ast_test_flag(chan, AST_FLAG_EMULATE_DTMF)) {
                                struct timeval now = ast_tvnow();
-                               if (!chan->emulate_dtmf_duration) {
+                               if (!ast_channel_emulate_dtmf_duration(chan)) {
                                        ast_clear_flag(chan, AST_FLAG_EMULATE_DTMF);
-                                       chan->emulate_dtmf_digit = 0;
-                               } else if (ast_tvdiff_ms(now, chan->dtmf_tv) >= chan->emulate_dtmf_duration) {
-                                       chan->emulate_dtmf_duration = 0;
+                                       ast_channel_emulate_dtmf_digit_set(chan, 0);
+                               } else if (ast_tvdiff_ms(now, chan->dtmf_tv) >= ast_channel_emulate_dtmf_duration(chan)) {
+                                       ast_channel_emulate_dtmf_duration_set(chan, 0);
                                        ast_frfree(f);
                                        f = &chan->dtmff;
                                        f->frametype = AST_FRAME_DTMF_END;
-                                       f->subclass.integer = chan->emulate_dtmf_digit;
+                                       f->subclass.integer = ast_channel_emulate_dtmf_digit(chan);
                                        f->len = ast_tvdiff_ms(now, chan->dtmf_tv);
                                        chan->dtmf_tv = now;
                                        ast_clear_flag(chan, AST_FLAG_EMULATE_DTMF);
-                                       chan->emulate_dtmf_digit = 0;
+                                       ast_channel_emulate_dtmf_digit_set(chan, 0);
                                        ast_log(LOG_DTMF, "DTMF end emulation of '%c' queued on %s\n", f->subclass.integer, ast_channel_name(chan));
-                                       if (chan->audiohooks) {
+                                       if (ast_channel_audiohooks(chan)) {
                                                struct ast_frame *old_frame = f;
-                                               f = ast_audiohook_write_list(chan, chan->audiohooks, AST_AUDIOHOOK_DIRECTION_READ, f);
+                                               f = ast_audiohook_write_list(chan, ast_channel_audiohooks(chan), AST_AUDIOHOOK_DIRECTION_READ, f);
                                                if (old_frame != f) {
                                                        ast_frfree(old_frame);
                                                }
@@ -3956,9 +3965,9 @@ static struct ast_frame *__ast_read(struct ast_channel *chan, int dropaudio)
                         * is reached , because we want to make sure we pass at least one
                         * voice frame through before starting the next digit, to ensure a gap
                         * between DTMF digits. */
-                       if (ast_test_flag(chan, AST_FLAG_EMULATE_DTMF) && !chan->emulate_dtmf_duration) {
+                       if (ast_test_flag(chan, AST_FLAG_EMULATE_DTMF) && !ast_channel_emulate_dtmf_duration(chan)) {
                                ast_clear_flag(chan, AST_FLAG_EMULATE_DTMF);
-                               chan->emulate_dtmf_digit = 0;
+                               ast_channel_emulate_dtmf_digit_set(chan, 0);
                        }
 
                        if (dropaudio || ast_test_flag(chan, AST_FLAG_IN_DTMF)) {
@@ -3970,17 +3979,17 @@ static struct ast_frame *__ast_read(struct ast_channel *chan, int dropaudio)
 
                        if (ast_test_flag(chan, AST_FLAG_EMULATE_DTMF) && !ast_test_flag(chan, AST_FLAG_IN_DTMF)) {
                                struct timeval now = ast_tvnow();
-                               if (ast_tvdiff_ms(now, chan->dtmf_tv) >= chan->emulate_dtmf_duration) {
-                                       chan->emulate_dtmf_duration = 0;
+                               if (ast_tvdiff_ms(now, chan->dtmf_tv) >= ast_channel_emulate_dtmf_duration(chan)) {
+                                       ast_channel_emulate_dtmf_duration_set(chan, 0);
                                        ast_frfree(f);
                                        f = &chan->dtmff;
                                        f->frametype = AST_FRAME_DTMF_END;
-                                       f->subclass.integer = chan->emulate_dtmf_digit;
+                                       f->subclass.integer = ast_channel_emulate_dtmf_digit(chan);
                                        f->len = ast_tvdiff_ms(now, chan->dtmf_tv);
                                        chan->dtmf_tv = now;
-                                       if (chan->audiohooks) {
+                                       if (ast_channel_audiohooks(chan)) {
                                                struct ast_frame *old_frame = f;
-                                               f = ast_audiohook_write_list(chan, chan->audiohooks, AST_AUDIOHOOK_DIRECTION_READ, f);
+                                               f = ast_audiohook_write_list(chan, ast_channel_audiohooks(chan), AST_AUDIOHOOK_DIRECTION_READ, f);
                                                if (old_frame != f)
                                                        ast_frfree(old_frame);
                                        }
@@ -3990,48 +3999,50 @@ static struct ast_frame *__ast_read(struct ast_channel *chan, int dropaudio)
                                        ast_frfree(f);
                                        f = &ast_null_frame;
                                }
-                       } else if ((f->frametype == AST_FRAME_VOICE) && !ast_format_cap_iscompatible(chan->nativeformats, &f->subclass.format)) {
+                       } else if ((f->frametype == AST_FRAME_VOICE) && !ast_format_cap_iscompatible(ast_channel_nativeformats(chan), &f->subclass.format)) {
                                /* This frame is not one of the current native formats -- drop it on the floor */
                                char to[200];
                                ast_log(LOG_NOTICE, "Dropping incompatible voice frame on %s of format %s since our native format has changed to %s\n",
-                                       ast_channel_name(chan), ast_getformatname(&f->subclass.format), ast_getformatname_multiple(to, sizeof(to), chan->nativeformats));
+                                       ast_channel_name(chan), ast_getformatname(&f->subclass.format), ast_getformatname_multiple(to, sizeof(to), ast_channel_nativeformats(chan)));
                                ast_frfree(f);
                                f = &ast_null_frame;
                        } else if ((f->frametype == AST_FRAME_VOICE)) {
                                /* Send frame to audiohooks if present */
-                               if (chan->audiohooks) {
+                               if (ast_channel_audiohooks(chan)) {
                                        struct ast_frame *old_frame = f;
-                                       f = ast_audiohook_write_list(chan, chan->audiohooks, AST_AUDIOHOOK_DIRECTION_READ, f);
+                                       f = ast_audiohook_write_list(chan, ast_channel_audiohooks(chan), AST_AUDIOHOOK_DIRECTION_READ, f);
                                        if (old_frame != f)
                                                ast_frfree(old_frame);
                                }
-                               if (chan->monitor && chan->monitor->read_stream ) {
+                               if (ast_channel_monitor(chan) && ast_channel_monitor(chan)->read_stream ) {
                                        /* XXX what does this do ? */
 #ifndef MONITOR_CONSTANT_DELAY
-                                       int jump = chan->outsmpl - chan->insmpl - 4 * f->samples;
+                                       int jump = ast_channel_outsmpl(chan) - ast_channel_insmpl(chan) - 4 * f->samples;
                                        if (jump >= 0) {
-                                               jump = calc_monitor_jump((chan->outsmpl - chan->insmpl), ast_format_rate(&f->subclass.format), ast_format_rate(&chan->monitor->read_stream->fmt->format));
-                                               if (ast_seekstream(chan->monitor->read_stream, jump, SEEK_FORCECUR) == -1)
+                                               jump = calc_monitor_jump((ast_channel_outsmpl(chan) - ast_channel_insmpl(chan)), ast_format_rate(&f->subclass.format), ast_format_rate(&ast_channel_monitor(chan)->read_stream->fmt->format));
+                                               if (ast_seekstream(ast_channel_monitor(chan)->read_stream, jump, SEEK_FORCECUR) == -1) {
                                                        ast_log(LOG_WARNING, "Failed to perform seek in monitoring read stream, synchronization between the files may be broken\n");
-                                               chan->insmpl += (chan->outsmpl - chan->insmpl) + f->samples;
-                                       } else
-                                               chan->insmpl+= f->samples;
+                                               }
+                                               ast_channel_insmpl_set(chan, ast_channel_insmpl(chan) + (ast_channel_outsmpl(chan) - ast_channel_insmpl(chan)) + f->samples);
+                                       } else {
+                                               ast_channel_insmpl_set(chan, ast_channel_insmpl(chan) + f->samples);
+                                       }
 #else
-                                       int jump = calc_monitor_jump((chan->outsmpl - chan->insmpl), ast_format_rate(f->subclass.codec), ast_format_rate(chan->monitor->read_stream->fmt->format));
+                                       int jump = calc_monitor_jump((ast_channel_outsmpl(chan) - ast_channel_insmpl(chan)), ast_format_rate(f->subclass.codec), ast_format_rate(ast_channel_monitor(chan)->read_stream->fmt->format));
                                        if (jump - MONITOR_DELAY >= 0) {
-                                               if (ast_seekstream(chan->monitor->read_stream, jump - f->samples, SEEK_FORCECUR) == -1)
+                                               if (ast_seekstream(ast_channel_monitor(chan)->read_stream, jump - f->samples, SEEK_FORCECUR) == -1)
                                                        ast_log(LOG_WARNING, "Failed to perform seek in monitoring read stream, synchronization between the files may be broken\n");
-                                               chan->insmpl += chan->outsmpl - chan->insmpl;
+                                               ast_channel_insmpl(chan) += ast_channel_outsmpl(chan) - ast_channel_insmpl(chan);
                                        } else
-                                               chan->insmpl += f->samples;
+                                               ast_channel_insmpl(chan) += f->samples;
 #endif
-                                       if (chan->monitor->state == AST_MONITOR_RUNNING) {
-                                               if (ast_writestream(chan->monitor->read_stream, f) < 0)
+                                       if (ast_channel_monitor(chan)->state == AST_MONITOR_RUNNING) {
+                                               if (ast_writestream(ast_channel_monitor(chan)->read_stream, f) < 0)
                                                        ast_log(LOG_WARNING, "Failed to write data to channel monitor read stream\n");
                                        }
                                }
 
-                               if (chan->readtrans && (f = ast_translate(chan->readtrans, f, 1)) == NULL) {
+                               if (ast_channel_readtrans(chan) && (f = ast_translate(ast_channel_readtrans(chan), f, 1)) == NULL) {
                                        f = &ast_null_frame;
                                }
 
@@ -4067,25 +4078,25 @@ static struct ast_frame *__ast_read(struct ast_channel *chan, int dropaudio)
                        chan->_softhangup |= AST_SOFTHANGUP_DEV;
                }
                if (cause)
-                       chan->hangupcause = cause;
-               if (chan->generator)
+                       ast_channel_hangupcause_set(chan, cause);
+               if (ast_channel_generator(chan))
                        ast_deactivate_generator(chan);
                /* We no longer End the CDR here */
        }
 
        /* High bit prints debugging */
-       if (chan->fin & DEBUGCHAN_FLAG)
+       if (ast_channel_fin(chan) & DEBUGCHAN_FLAG)
                ast_frame_dump(ast_channel_name(chan), f, "<<");
-       chan->fin = FRAMECOUNT_INC(chan->fin);
+       ast_channel_fin_set(chan, FRAMECOUNT_INC(ast_channel_fin(chan)));
 
 done:
-       if (chan->music_state && chan->generator && chan->generator->digit && f && f->frametype == AST_FRAME_DTMF_END)
-               chan->generator->digit(chan, f->subclass.integer);
+       if (ast_channel_music_state(chan) && ast_channel_generator(chan) && ast_channel_generator(chan)->digit && f && f->frametype == AST_FRAME_DTMF_END)
+               ast_channel_generator(chan)->digit(chan, f->subclass.integer);
 
-       if (chan->audiohooks && ast_audiohook_write_list_empty(chan->audiohooks)) {
+       if (ast_channel_audiohooks(chan) && ast_audiohook_write_list_empty(ast_channel_audiohooks(chan))) {
                /* The list gets recreated if audiohooks are added again later */
-               ast_audiohook_detach_list(chan->audiohooks);
-               chan->audiohooks = NULL;
+               ast_audiohook_detach_list(ast_channel_audiohooks(chan));
+               ast_channel_audiohooks_set(chan, NULL);
        }
        ast_channel_unlock(chan);
        return f;
@@ -4093,7 +4104,7 @@ done:
 
 int ast_internal_timing_enabled(struct ast_channel *chan)
 {
-       return (ast_opt_internal_timing && chan->timingfd > -1);
+       return (ast_opt_internal_timing && ast_channel_timingfd(chan) > -1);
 }
 
 struct ast_frame *ast_read(struct ast_channel *chan)
@@ -4180,7 +4191,7 @@ int ast_indicate_data(struct ast_channel *chan, int _condition,
                goto indicate_cleanup;
        }
 
-       if (!ast_framehook_list_is_empty(chan->framehooks)) {
+       if (!ast_framehook_list_is_empty(ast_channel_framehooks(chan))) {
                /* Do framehooks now, do it, go, go now */
                struct ast_frame frame = {
                        .frametype = AST_FRAME_CONTROL,
@@ -4193,7 +4204,7 @@ int ast_indicate_data(struct ast_channel *chan, int _condition,
                awesome_frame = ast_frdup(&frame);
 
                /* who knows what we will get back! the anticipation is killing me. */
-               if (!(awesome_frame = ast_framehook_list_write_event(chan->framehooks, awesome_frame))
+               if (!(awesome_frame = ast_framehook_list_write_event(ast_channel_framehooks(chan), awesome_frame))
                        || awesome_frame->frametype != AST_FRAME_CONTROL) {
 
                        res = 0;
@@ -4238,15 +4249,15 @@ int ast_indicate_data(struct ast_channel *chan, int _condition,
 
        if (is_visible_indication(condition)) {
                /* A new visible indication is requested. */
-               chan->visible_indication = condition;
+               ast_channel_visible_indication_set(chan, condition);
        } else if (condition == AST_CONTROL_UNHOLD || _condition < 0) {
                /* Visible indication is cleared/stopped. */
-               chan->visible_indication = 0;
+               ast_channel_visible_indication_set(chan, 0);
        }
 
-       if (chan->tech->indicate) {
+       if (ast_channel_tech(chan)->indicate) {
                /* See if the channel driver can handle this condition. */
-               res = chan->tech->indicate(chan, condition, data, datalen);
+               res = ast_channel_tech(chan)->indicate(chan, condition, data, datalen);
        } else {
                res = -1;
        }
@@ -4286,7 +4297,7 @@ int ast_indicate_data(struct ast_channel *chan, int _condition,
                 * has some meaning.*/
                goto indicate_cleanup;
        case AST_CONTROL_RINGING:
-               ts = ast_get_indication_tone(chan->zone, "ring");
+               ts = ast_get_indication_tone(ast_channel_zone(chan), "ring");
                /* It is common practice for channel drivers to return -1 if trying
                 * to indicate ringing on a channel which is up. The idea is to let the
                 * core generate the ringing inband. However, we don't want the
@@ -4294,16 +4305,16 @@ int ast_indicate_data(struct ast_channel *chan, int _condition,
                 * to print nor do we want ast_indicate_data to return an "error" for this
                 * condition
                 */
-               if (chan->_state == AST_STATE_UP) {
+               if (ast_channel_state(chan) == AST_STATE_UP) {
                        res = 0;
                }
                break;
        case AST_CONTROL_BUSY:
-               ts = ast_get_indication_tone(chan->zone, "busy");
+               ts = ast_get_indication_tone(ast_channel_zone(chan), "busy");
                break;
        case AST_CONTROL_INCOMPLETE:
        case AST_CONTROL_CONGESTION:
-               ts = ast_get_indication_tone(chan->zone, "congestion");
+               ts = ast_get_indication_tone(ast_channel_zone(chan), "congestion");
                break;
        case AST_CONTROL_PROGRESS:
        case AST_CONTROL_PROCEEDING:
@@ -4412,7 +4423,7 @@ int ast_sendtext(struct ast_channel *chan, const char *text)
        }
 
        CHECK_BLOCKING(chan);
-       if (chan->tech->write_text && (ast_format_cap_has_type(chan->nativeformats, AST_FORMAT_TYPE_TEXT))) {
+       if (ast_channel_tech(chan)->write_text && (ast_format_cap_has_type(ast_channel_nativeformats(chan), AST_FORMAT_TYPE_TEXT))) {
                struct ast_frame f;
 
                f.frametype = AST_FRAME_TEXT;
@@ -4424,9 +4435,9 @@ int ast_sendtext(struct ast_channel *chan, const char *text)
                f.seqno = 0;
 
                ast_format_set(&f.subclass.format, AST_FORMAT_T140, 0);
-               res = chan->tech->write_text(chan, &f);
-       } else if (chan->tech->send_text) {
-               res = chan->tech->send_text(chan, text);
+               res = ast_channel_tech(chan)->write_text(chan, &f);
+       } else if (ast_channel_tech(chan)->send_text) {
+               res = ast_channel_tech(chan)->send_text(chan, text);
        }
        ast_clear_flag(chan, AST_FLAG_BLOCKING);
        ast_channel_unlock(chan);
@@ -4456,10 +4467,10 @@ int ast_senddigit_begin(struct ast_channel *chan, char digit)
                "941+1477"  /* # */
        };
 
-       if (!chan->tech->send_digit_begin)
+       if (!ast_channel_tech(chan)->send_digit_begin)
                return 0;
 
-       if (!chan->tech->send_digit_begin(chan, digit))
+       if (!ast_channel_tech(chan)->send_digit_begin(chan, digit))
                return 0;
 
        if (digit >= '0' && digit <='9')
@@ -4482,10 +4493,10 @@ int ast_senddigit_end(struct ast_channel *chan, char digit, unsigned int duratio
 {
        int res = -1;
 
-       if (chan->tech->send_digit_end)
-               res = chan->tech->send_digit_end(chan, digit, duration);
+       if (ast_channel_tech(chan)->send_digit_end)
+               res = ast_channel_tech(chan)->send_digit_end(chan, digit, duration);
 
-       if (res && chan->generator)
+       if (res && ast_channel_generator(chan))
                ast_playtones_stop(chan);
 
        return 0;
@@ -4493,7 +4504,7 @@ int ast_senddigit_end(struct ast_channel *chan, char digit, unsigned int duratio
 
 int ast_senddigit(struct ast_channel *chan, char digit, unsigned int duration)
 {
-       if (chan->tech->send_digit_begin) {
+       if (ast_channel_tech(chan)->send_digit_begin) {
                ast_senddigit_begin(chan, digit);
                ast_safe_sleep(chan, (duration >= AST_DEFAULT_EMULATE_DTMF_DURATION ? duration : AST_DEFAULT_EMULATE_DTMF_DURATION));
        }
@@ -4507,7 +4518,7 @@ int ast_prod(struct ast_channel *chan)
        char nothing[128];
 
        /* Send an empty audio frame to get things moving */
-       if (chan->_state != AST_STATE_UP) {
+       if (ast_channel_state(chan) != AST_STATE_UP) {
                ast_debug(1, "Prodding channel '%s'\n", ast_channel_name(chan));
                ast_format_copy(&a.subclass.format, &chan->rawwriteformat);
                a.data.ptr = nothing + AST_FRIENDLY_OFFSET;
@@ -4521,7 +4532,7 @@ int ast_prod(struct ast_channel *chan)
 int ast_write_video(struct ast_channel *chan, struct ast_frame *fr)
 {
        int res;
-       if (!chan->tech->write_video)
+       if (!ast_channel_tech(chan)->write_video)
                return 0;
        res = ast_write(chan, fr);
        if (!res)
@@ -4653,7 +4664,7 @@ int ast_write(struct ast_channel *chan, struct ast_frame *fr)
                goto done;
 
        /* Handle any pending masquerades */
-       if (chan->masq) {
+       if (ast_channel_masq(chan)) {
                ast_channel_unlock(chan);
                if (ast_do_masquerade(chan)) {
                        ast_log(LOG_WARNING, "Failed to perform masquerade\n");
@@ -4661,19 +4672,19 @@ int ast_write(struct ast_channel *chan, struct ast_frame *fr)
                }
                ast_channel_lock(chan);
        }
-       if (chan->masqr) {
+       if (ast_channel_masqr(chan)) {
                res = 0;        /* XXX explain, why 0 ? */
                goto done;
        }
 
        /* Perform the framehook write event here. After the frame enters the framehook list
         * there is no telling what will happen, how awesome is that!!! */
-       if (!(fr = ast_framehook_list_write_event(chan->framehooks, fr))) {
+       if (!(fr = ast_framehook_list_write_event(ast_channel_framehooks(chan), fr))) {
                res = 0;
                goto done;
        }
 
-       if (chan->generatordata && (!fr->src || strcasecmp(fr->src, "ast_prod"))) {
+       if (ast_channel_generatordata(chan) && (!fr->src || strcasecmp(fr->src, "ast_prod"))) {
                if (ast_test_flag(chan, AST_FLAG_WRITE_INT)) {
                                ast_deactivate_generator(chan);
                } else {
@@ -4688,26 +4699,26 @@ int ast_write(struct ast_channel *chan, struct ast_frame *fr)
                                CHECK_BLOCKING(chan);
                        } else if (fr->frametype == AST_FRAME_CONTROL && fr->subclass.integer == AST_CONTROL_UNHOLD) {
                                /* This is a side case where Echo is basically being called and the person put themselves on hold and took themselves off hold */
-                               res = (chan->tech->indicate == NULL) ? 0 :
-                                       chan->tech->indicate(chan, fr->subclass.integer, fr->data.ptr, fr->datalen);
+                               res = (ast_channel_tech(chan)->indicate == NULL) ? 0 :
+                                       ast_channel_tech(chan)->indicate(chan, fr->subclass.integer, fr->data.ptr, fr->datalen);
                        }
                        res = 0;        /* XXX explain, why 0 ? */
                        goto done;
                }
        }
        /* High bit prints debugging */
-       if (chan->fout & DEBUGCHAN_FLAG)
+       if (ast_channel_fout(chan) & DEBUGCHAN_FLAG)
                ast_frame_dump(ast_channel_name(chan), fr, ">>");
        CHECK_BLOCKING(chan);
        switch (fr->frametype) {
        case AST_FRAME_CONTROL:
-               res = (chan->tech->indicate == NULL) ? 0 :
-                       chan->tech->indicate(chan, fr->subclass.integer, fr->data.ptr, fr->datalen);
+               res = (ast_channel_tech(chan)->indicate == NULL) ? 0 :
+                       ast_channel_tech(chan)->indicate(chan, fr->subclass.integer, fr->data.ptr, fr->datalen);
                break;
        case AST_FRAME_DTMF_BEGIN:
-               if (chan->audiohooks) {
+               if (ast_channel_audiohooks(chan)) {
                        struct ast_frame *old_frame = fr;
-                       fr = ast_audiohook_write_list(chan, chan->audiohooks, AST_AUDIOHOOK_DIRECTION_WRITE, fr);
+                       fr = ast_audiohook_write_list(chan, ast_channel_audiohooks(chan), AST_AUDIOHOOK_DIRECTION_WRITE, fr);
                        if (old_frame != fr)
                                f = fr;
                }
@@ -4719,10 +4730,10 @@ int ast_write(struct ast_channel *chan, struct ast_frame *fr)
                CHECK_BLOCKING(chan);
                break;
        case AST_FRAME_DTMF_END:
-               if (chan->audiohooks) {
+               if (ast_channel_audiohooks(chan)) {
                        struct ast_frame *new_frame = fr;
 
-                       new_frame = ast_audiohook_write_list(chan, chan->audiohooks, AST_AUDIOHOOK_DIRECTION_WRITE, fr);
+                       new_frame = ast_audiohook_write_list(chan, ast_channel_audiohooks(chan), AST_AUDIOHOOK_DIRECTION_WRITE, fr);
                        if (new_frame != fr) {
                                ast_frfree(new_frame);
                        }
@@ -4736,28 +4747,28 @@ int ast_write(struct ast_channel *chan, struct ast_frame *fr)
                break;
        case AST_FRAME_TEXT:
                if (fr->subclass.integer == AST_FORMAT_T140) {
-                       res = (chan->tech->write_text == NULL) ? 0 :
-                               chan->tech->write_text(chan, fr);
+                       res = (ast_channel_tech(chan)->write_text == NULL) ? 0 :
+                               ast_channel_tech(chan)->write_text(chan, fr);
                } else {
-                       res = (chan->tech->send_text == NULL) ? 0 :
-                               chan->tech->send_text(chan, (char *) fr->data.ptr);
+                       res = (ast_channel_tech(chan)->send_text == NULL) ? 0 :
+                               ast_channel_tech(chan)->send_text(chan, (char *) fr->data.ptr);
                }
                break;
        case AST_FRAME_HTML:
-               res = (chan->tech->send_html == NULL) ? 0 :
-                       chan->tech->send_html(chan, fr->subclass.integer, (char *) fr->data.ptr, fr->datalen);
+               res = (ast_channel_tech(chan)->send_html == NULL) ? 0 :
+                       ast_channel_tech(chan)->send_html(chan, fr->subclass.integer, (char *) fr->data.ptr, fr->datalen);
                break;
        case AST_FRAME_VIDEO:
                /* XXX Handle translation of video codecs one day XXX */
-               res = (chan->tech->write_video == NULL) ? 0 :
-                       chan->tech->write_video(chan, fr);
+               res = (ast_channel_tech(chan)->write_video == NULL) ? 0 :
+                       ast_channel_tech(chan)->write_video(chan, fr);
                break;
        case AST_FRAME_MODEM:
-               res = (chan->tech->write == NULL) ? 0 :
-                       chan->tech->write(chan, fr);
+               res = (ast_channel_tech(chan)->write == NULL) ? 0 :
+                       ast_channel_tech(chan)->write(chan, fr);
                break;
        case AST_FRAME_VOICE:
-               if (chan->tech->write == NULL)
+               if (ast_channel_tech(chan)->write == NULL)
                        break;  /*! \todo XXX should return 0 maybe ? */
 
                if (ast_opt_generic_plc && fr->subclass.format.id == AST_FORMAT_SLINEAR) {
@@ -4774,16 +4785,16 @@ int ast_write(struct ast_channel *chan, struct ast_frame *fr)
                         * eliminate user impact and help identify the problem areas
                         * JIRA issues related to this :-
                         * ASTERISK-14384, ASTERISK-17502, ASTERISK-17541, ASTERISK-18063, ASTERISK-18325, ASTERISK-18422*/
-                       if ((!ast_format_cap_iscompatible(chan->nativeformats, &fr->subclass.format)) &&
+                       if ((!ast_format_cap_iscompatible(ast_channel_nativeformats(chan), &fr->subclass.format)) &&
                            (ast_format_cmp(&chan->writeformat, &fr->subclass.format) != AST_FORMAT_CMP_EQUAL)) {
                                char nf[512];
                                ast_log(LOG_WARNING, "Codec mismatch on channel %s setting write format to %s from %s native formats %s\n",
                                        ast_channel_name(chan), ast_getformatname(&fr->subclass.format), ast_getformatname(&chan->writeformat),
-                                       ast_getformatname_multiple(nf, sizeof(nf), chan->nativeformats));
+                                       ast_getformatname_multiple(nf, sizeof(nf), ast_channel_nativeformats(chan)));
                                ast_set_write_format_by_id(chan, fr->subclass.format.id);
                        }
 
-                       f = (chan->writetrans) ? ast_translate(chan->writetrans, fr, 0) : fr;
+                       f = (ast_channel_writetrans(chan)) ? ast_translate(ast_channel_writetrans(chan), fr, 0) : fr;
                }
 
                if (!f) {
@@ -4791,7 +4802,7 @@ int ast_write(struct ast_channel *chan, struct ast_frame *fr)
                        break;
                }
 
-               if (chan->audiohooks) {
+               if (ast_channel_audiohooks(chan)) {
                        struct ast_frame *prev = NULL, *new_frame, *cur, *dup;
                        int freeoldlist = 0;
 
@@ -4803,7 +4814,7 @@ int ast_write(struct ast_channel *chan, struct ast_frame *fr)
                         * an item in a list of frames, create a new list adding each cur frame back to it
                         * regardless if the cur frame changes or not. */
                        for (cur = f; cur; cur = AST_LIST_NEXT(cur, frame_list)) {
-                               new_frame = ast_audiohook_write_list(chan, chan->audiohooks, AST_AUDIOHOOK_DIRECTION_WRITE, cur);
+                               new_frame = ast_audiohook_write_list(chan, ast_channel_audiohooks(chan), AST_AUDIOHOOK_DIRECTION_WRITE, cur);
 
                                /* if this frame is different than cur, preserve the end of the list,
                                 * free the old frames, and set cur to be the new frame */
@@ -4840,33 +4851,35 @@ int ast_write(struct ast_channel *chan, struct ast_frame *fr)
                /* the translator on chan->writetrans may have returned multiple frames
                   from the single frame we passed in; if so, feed each one of them to the
                   monitor */
-               if (chan->monitor && chan->monitor->write_stream) {
+               if (ast_channel_monitor(chan) && ast_channel_monitor(chan)->write_stream) {
                        struct ast_frame *cur;
 
                        for (cur = f; cur; cur = AST_LIST_NEXT(cur, frame_list)) {
                        /* XXX must explain this code */
 #ifndef MONITOR_CONSTANT_DELAY
-                               int jump = chan->insmpl - chan->outsmpl - 4 * cur->samples;
+                               int jump = ast_channel_insmpl(chan) - ast_channel_outsmpl(chan) - 4 * cur->samples;
                                if (jump >= 0) {
-                                       jump = calc_monitor_jump((chan->insmpl - chan->outsmpl), ast_format_rate(&f->subclass.format), ast_format_rate(&chan->monitor->read_stream->fmt->format));
-                                       if (ast_seekstream(chan->monitor->write_stream, jump, SEEK_FORCECUR) == -1)
+                                       jump = calc_monitor_jump((ast_channel_insmpl(chan) - ast_channel_outsmpl(chan)), ast_format_rate(&f->subclass.format), ast_format_rate(&ast_channel_monitor(chan)->read_stream->fmt->format));
+                                       if (ast_seekstream(ast_channel_monitor(chan)->write_stream, jump, SEEK_FORCECUR) == -1) {
                                                ast_log(LOG_WARNING, "Failed to perform seek in monitoring write stream, synchronization between the files may be broken\n");
-                                       chan->outsmpl += (chan->insmpl - chan->outsmpl) + cur->samples;
+                                       }
+                                       ast_channel_outsmpl_set(chan, ast_channel_outsmpl(chan) + (ast_channel_insmpl(chan) - ast_channel_outsmpl(chan)) + cur->samples);
                                } else {
-                                       chan->outsmpl += cur->samples;
+                                       ast_channel_outsmpl_set(chan, ast_channel_outsmpl(chan) + cur->samples);
                                }
 #else
-                               int jump = calc_monitor_jump((chan->insmpl - chan->outsmpl), ast_format_rate(f->subclass.codec), ast_format_rate(chan->monitor->read_stream->fmt->format));
+                               int jump = calc_monitor_jump((ast_channel_insmpl(chan) - ast_channel_outsmpl(chan)), ast_format_rate(f->subclass.codec), ast_format_rate(ast_channel_monitor(chan)->read_stream->fmt->format));
                                if (jump - MONITOR_DELAY >= 0) {
-                                       if (ast_seekstream(chan->monitor->write_stream, jump - cur->samples, SEEK_FORCECUR) == -1)
+                                       if (ast_seekstream(ast_channel_monitor(chan)->write_stream, jump - cur->samples, SEEK_FORCECUR) == -1) {
                                                ast_log(LOG_WARNING, "Failed to perform seek in monitoring write stream, synchronization between the files may be broken\n");
-                                       chan->outsmpl += chan->insmpl - chan->outsmpl;
+                                       }
+                                       ast_channel_outsmpl_set(chan, ast_channel_outsmpl(chan) + ast_channel_insmpl(chan) - ast_channel_outsmpl(chan));
                                } else {
-                                       chan->outsmpl += cur->samples;
+                                       ast_channel_outsmpl_set(chan, ast_channel_outsmpl(chan) + cur->samples);
                                }
 #endif
-                               if (chan->monitor->state == AST_MONITOR_RUNNING) {
-                                       if (ast_writestream(chan->monitor->write_stream, cur) < 0)
+                               if (ast_channel_monitor(chan)->state == AST_MONITOR_RUNNING) {
+                                       if (ast_writestream(ast_channel_monitor(chan)->write_stream, cur) < 0)
                                                ast_log(LOG_WARNING, "Failed to write data to channel monitor write stream\n");
                                }
                        }
@@ -4884,14 +4897,14 @@ int ast_write(struct ast_channel *chan, struct ast_frame *fr)
                                next = AST_LIST_NEXT(cur, frame_list);
                                AST_LIST_NEXT(cur, frame_list) = NULL;
                                if (!skip) {
-                                       if ((res = chan->tech->write(chan, cur)) < 0) {
+                                       if ((res = ast_channel_tech(chan)->write(chan, cur)) < 0) {
                                                chan->_softhangup |= AST_SOFTHANGUP_DEV;
                                                skip = 1;
                                        } else if (next) {
                                                /* don't do this for the last frame in the list,
                                                   as the code outside the loop will do it once
                                                */
-                                               chan->fout = FRAMECOUNT_INC(chan->fout);
+                                               ast_channel_fout_set(chan, FRAMECOUNT_INC(ast_channel_fout(chan)));
                                        }
                                }
                                ast_frfree(cur);
@@ -4901,7 +4914,7 @@ int ast_write(struct ast_channel *chan, struct ast_frame *fr)
                        /* reset f so the code below doesn't attempt to free it */
                        f = NULL;
                } else {
-                       res = chan->tech->write(chan, f);
+                       res = ast_channel_tech(chan)->write(chan, f);
                }
                break;
        case AST_FRAME_NULL:
@@ -4913,7 +4926,7 @@ int ast_write(struct ast_channel *chan, struct ast_frame *fr)
                /* At this point, fr is the incoming frame and f is NULL.  Channels do
                 * not expect to get NULL as a frame pointer and will segfault.  Hence,
                 * we output the original frame passed in. */
-               res = chan->tech->write(chan, fr);
+               res = ast_channel_tech(chan)->write(chan, fr);
                break;
        }
 
@@ -4925,13 +4938,13 @@ int ast_write(struct ast_channel *chan, struct ast_frame *fr)
        if (res < 0) {
                chan->_softhangup |= AST_SOFTHANGUP_DEV;
        } else {
-               chan->fout = FRAMECOUNT_INC(chan->fout);
+               ast_channel_fout_set(chan, FRAMECOUNT_INC(ast_channel_fout(chan)));
        }
 done:
-       if (chan->audiohooks && ast_audiohook_write_list_empty(chan->audiohooks)) {
+       if (ast_channel_audiohooks(chan) && ast_audiohook_write_list_empty(ast_channel_audiohooks(chan))) {
                /* The list gets recreated if audiohooks are added again later */
-               ast_audiohook_detach_list(chan->audiohooks);
-               chan->audiohooks = NULL;
+               ast_audiohook_detach_list(ast_channel_audiohooks(chan));
+               ast_channel_audiohooks_set(chan, NULL);
        }
        ast_channel_unlock(chan);
        return res;
@@ -4944,7 +4957,7 @@ static int set_format(struct ast_channel *chan,
        struct ast_trans_pvt **trans,
        const int direction)
 {
-       struct ast_format_cap *cap_native = chan->nativeformats;
+       struct ast_format_cap *cap_native = ast_channel_nativeformats(chan);
        struct ast_format best_set_fmt;
        struct ast_format best_native_fmt;
        int res;
@@ -4960,7 +4973,7 @@ static int set_format(struct ast_channel *chan,
                ast_channel_lock(chan);
                ast_format_copy(format, &best_set_fmt);
                ast_format_copy(rawformat, &best_set_fmt);
-               ast_format_cap_set(chan->nativeformats, &best_set_fmt);
+               ast_format_cap_set(ast_channel_nativeformats(chan), &best_set_fmt);
                ast_channel_unlock(chan);
 
                if (*trans) {
@@ -4969,7 +4982,7 @@ static int set_format(struct ast_channel *chan,
                *trans = NULL;
                /* If there is a generator on the channel, it needs to know about this
                 * change if it is the write format. */
-               if (direction && chan->generatordata) {
+               if (direction && ast_channel_generatordata(chan)) {
                        generator_write_format_change(chan);
                }
                return 0;
@@ -5039,7 +5052,7 @@ static int set_format(struct ast_channel *chan,
        
        /* If there is a generator on the channel, it needs to know about this
         * change if it is the write format. */
-       if (direction && chan->generatordata) {
+       if (direction && ast_channel_generatordata(chan)) {
                generator_write_format_change(chan);
        }
        return res;
@@ -5048,6 +5061,7 @@ static int set_format(struct ast_channel *chan,
 int ast_set_read_format(struct ast_channel *chan, struct ast_format *format)
 {
        struct ast_format_cap *cap = ast_format_cap_alloc_nolock();
+       struct ast_trans_pvt *trans = NULL;
        int res;
        if (!cap) {
                return -1;
@@ -5058,9 +5072,10 @@ int ast_set_read_format(struct ast_channel *chan, struct ast_format *format)
                cap,
                &chan->rawreadformat,
                &chan->readformat,
-               &chan->readtrans,
+               &trans,
                0);
 
+       ast_channel_readtrans_set(chan, trans);
        ast_format_cap_destroy(cap);
        return res;
 }
@@ -5069,6 +5084,7 @@ int ast_set_read_format_by_id(struct ast_channel *chan, enum ast_format_id id)
 {
        struct ast_format_cap *cap = ast_format_cap_alloc_nolock();
        struct ast_format tmp_format;
+       struct ast_trans_pvt *trans = NULL;
        int res;
        if (!cap) {
                return -1;
@@ -5079,26 +5095,32 @@ int ast_set_read_format_by_id(struct ast_channel *chan, enum ast_format_id id)
                cap,
                &chan->rawreadformat,
                &chan->readformat,
-               &chan->readtrans,
+               &trans,
                0);
 
+       ast_channel_readtrans_set(chan, trans);
        ast_format_cap_destroy(cap);
        return res;
 }
 
 int ast_set_read_format_from_cap(struct ast_channel *chan, struct ast_format_cap *cap)
 {
-       return set_format(chan,
+       struct ast_trans_pvt *trans = NULL;
+       int res;
+       res = set_format(chan,
                cap,
                &chan->rawreadformat,
                &chan->readformat,
-               &chan->readtrans,
+               &trans,
                0);
+       ast_channel_readtrans_set(chan, trans);
+       return res;
 }
 
 int ast_set_write_format(struct ast_channel *chan, struct ast_format *format)
 {
        struct ast_format_cap *cap = ast_format_cap_alloc_nolock();
+       struct ast_trans_pvt *trans = NULL;
        int res;
        if (!cap) {
                return -1;
@@ -5109,9 +5131,10 @@ int ast_set_write_format(struct ast_channel *chan, struct ast_format *format)
                cap,
                &chan->rawwriteformat,
                &chan->writeformat,
-               &chan->writetrans,
+               &trans,
                1);
 
+       ast_channel_writetrans_set(chan, trans);
        ast_format_cap_destroy(cap);
        return res;
 }
@@ -5120,6 +5143,7 @@ int ast_set_write_format_by_id(struct ast_channel *chan, enum ast_format_id id)
 {
        struct ast_format_cap *cap = ast_format_cap_alloc_nolock();
        struct ast_format tmp_format;
+       struct ast_trans_pvt *trans = NULL;
        int res;
        if (!cap) {
                return -1;
@@ -5130,21 +5154,26 @@ int ast_set_write_format_by_id(struct ast_channel *chan, enum ast_format_id id)
                cap,
                &chan->rawwriteformat,
                &chan->writeformat,
-               &chan->writetrans,
+               &trans,
                1);
 
+       ast_channel_writetrans_set(chan, trans);
        ast_format_cap_destroy(cap);
        return res;
 }
 
 int ast_set_write_format_from_cap(struct ast_channel *chan, struct ast_format_cap *cap)
 {
-       return set_format(chan,
+       struct ast_trans_pvt *trans = NULL;
+       int res;
+       res = set_format(chan,
                cap,
                &chan->rawwriteformat,
                &chan->writeformat,
-               &chan->writetrans,
+               &trans,
                1);
+       ast_channel_writetrans_set(chan, trans);
+       return res;
 }
 
 const char *ast_channel_reason2str(int reason)
@@ -5267,7 +5296,7 @@ struct ast_channel *ast_call_forward(struct ast_channel *caller, struct ast_chan
        }
 
        ast_channel_lock_both(orig, new_chan);
-       ast_copy_flags(new_chan->cdr, orig->cdr, AST_CDR_FLAG_ORIGINATED);
+       ast_copy_flags(ast_channel_cdr(new_chan), ast_channel_cdr(orig), AST_CDR_FLAG_ORIGINATED);
        ast_channel_accountcode_set(new_chan, ast_channel_accountcode(orig));
        ast_party_connected_line_copy(&new_chan->connected, &orig->connected);
        ast_party_redirecting_copy(&new_chan->redirecting, &orig->redirecting);
@@ -5338,7 +5367,7 @@ struct ast_channel *__ast_request_and_dial(const char *type, struct ast_format_c
                }
        }
 
-       ast_set_flag(chan->cdr, AST_CDR_FLAG_ORIGINATED);
+       ast_set_flag(ast_channel_cdr(chan), AST_CDR_FLAG_ORIGINATED);
        ast_party_connected_line_set_init(&connected, &chan->connected);
        if (cid_num) {
                connected.id.number.valid = 1;
@@ -5356,7 +5385,7 @@ struct ast_channel *__ast_request_and_dial(const char *type, struct ast_format_c
                ast_log(LOG_NOTICE, "Unable to call channel %s/%s\n", type, addr);
        } else {
                res = 1;        /* mark success in case chan->_state is already AST_STATE_UP */
-               while (timeout && chan->_state != AST_STATE_UP) {
+               while (timeout && ast_channel_state(chan) != AST_STATE_UP) {
                        struct ast_frame *f;
                        res = ast_waitfor(chan, timeout);
                        if (res == 0) { /* timeout, treat it like ringing */
@@ -5387,25 +5416,25 @@ struct ast_channel *__ast_request_and_dial(const char *type, struct ast_format_c
                                        break;
 
                                case AST_CONTROL_BUSY:
-                                       ast_cdr_busy(chan->cdr);
+                                       ast_cdr_busy(ast_channel_cdr(chan));
                                        *outstate = f->subclass.integer;
                                        timeout = 0;
                                        break;
 
                                case AST_CONTROL_INCOMPLETE:
-                                       ast_cdr_failed(chan->cdr);
+                                       ast_cdr_failed(ast_channel_cdr(chan));
                                        *outstate = AST_CONTROL_CONGESTION;
                                        timeout = 0;
                                        break;
 
                                case AST_CONTROL_CONGESTION:
-                                       ast_cdr_failed(chan->cdr);
+                                       ast_cdr_failed(ast_channel_cdr(chan));
                                        *outstate = f->subclass.integer;
                                        timeout = 0;
                                        break;
 
                                case AST_CONTROL_ANSWER:
-                                       ast_cdr_answer(chan->cdr);
+                                       ast_cdr_answer(ast_channel_cdr(chan));
                                        *outstate = f->subclass.integer;
                                        timeout = 0;            /* trick to force exit from the while() */
                                        break;
@@ -5440,30 +5469,32 @@ struct ast_channel *__ast_request_and_dial(const char *type, struct ast_format_c
                if (!ast_strlen_zero(oh->exten))
                        ast_channel_exten_set(chan, oh->exten);
                if (oh->priority)       
-                       chan->priority = oh->priority;
+                       ast_channel_priority_set(chan, oh->priority);
        }
-       if (chan->_state == AST_STATE_UP)
+       if (ast_channel_state(chan) == AST_STATE_UP)
                *outstate = AST_CONTROL_ANSWER;
 
        if (res <= 0) {
+               struct ast_cdr *chancdr;
                ast_channel_lock(chan);
                if (AST_CONTROL_RINGING == last_subclass) {
-                       chan->hangupcause = AST_CAUSE_NO_ANSWER;
+                       ast_channel_hangupcause_set(chan, AST_CAUSE_NO_ANSWER);
                }
-               if (!chan->cdr && (chan->cdr = ast_cdr_alloc())) {
-                       ast_cdr_init(chan->cdr, chan);
+               if (!ast_channel_cdr(chan) && (chancdr = ast_cdr_alloc())) {
+                       ast_channel_cdr_set(chan, chancdr);
+                       ast_cdr_init(ast_channel_cdr(chan), chan);
                }
-               if (chan->cdr) {
+               if (ast_channel_cdr(chan)) {
                        char tmp[256];
 
                        snprintf(tmp, sizeof(tmp), "%s/%s", type, addr);
-                       ast_cdr_setapp(chan->cdr, "Dial", tmp);
+                       ast_cdr_setapp(ast_channel_cdr(chan), "Dial", tmp);
                        ast_cdr_update(chan);
-                       ast_cdr_start(chan->cdr);
-                       ast_cdr_end(chan->cdr);
+                       ast_cdr_start(ast_channel_cdr(chan));
+                       ast_cdr_end(ast_channel_cdr(chan));
                        /* If the cause wasn't handled properly */
-                       if (ast_cdr_disposition(chan->cdr, chan->hangupcause)) {
-                               ast_cdr_failed(chan->cdr);
+                       if (ast_cdr_disposition(ast_channel_cdr(chan), ast_channel_hangupcause(chan))) {
+                               ast_cdr_failed(ast_channel_cdr(chan));
                        }
                }
                ast_channel_unlock(chan);
@@ -5608,11 +5639,11 @@ int ast_call(struct ast_channel *chan, const char *addr, int timeout)
        /* Stop if we're a zombie or need a soft hangup */
        ast_channel_lock(chan);
        if (!ast_test_flag(chan, AST_FLAG_ZOMBIE) && !ast_check_hangup(chan)) {
-               if (chan->cdr) {
-                       ast_set_flag(chan->cdr, AST_CDR_FLAG_DIALED);
+               if (ast_channel_cdr(chan)) {
+                       ast_set_flag(ast_channel_cdr(chan), AST_CDR_FLAG_DIALED);
                }
-               if (chan->tech->call)
-                       res = chan->tech->call(chan, addr, timeout);
+               if (ast_channel_tech(chan)->call)
+                       res = ast_channel_tech(chan)->call(chan, addr, timeout);
                ast_set_flag(chan, AST_FLAG_OUTGOING);
        }
        ast_channel_unlock(chan);
@@ -5633,8 +5664,8 @@ int ast_transfer(struct ast_channel *chan, char *dest)
        /* Stop if we're a zombie or need a soft hangup */
        ast_channel_lock(chan);
        if (!ast_test_flag(chan, AST_FLAG_ZOMBIE) && !ast_check_hangup(chan)) {
-               if (chan->tech->transfer) {
-                       res = chan->tech->transfer(chan, dest);
+               if (ast_channel_tech(chan)->transfer) {
+                       res = ast_channel_tech(chan)->transfer(chan, dest);
                        if (!res)
                                res = 1;
                } else
@@ -5694,7 +5725,7 @@ int ast_readstring_full(struct ast_channel *c, char *s, int len, int timeout, in
                return -1;
        for (;;) {
                int d;
-               if (c->stream) {
+               if (ast_channel_stream(c)) {
                        d = ast_waitstream_full(c, AST_DIGIT_ANY, audiofd, ctrlfd);
                        ast_stopstream(c);
                        if (!silgen && ast_opt_transmit_silence)
@@ -5742,13 +5773,13 @@ int ast_readstring_full(struct ast_channel *c, char *s, int len, int timeout, in
 
 int ast_channel_supports_html(struct ast_channel *chan)
 {
-       return (chan->tech->send_html) ? 1 : 0;
+       return (ast_channel_tech(chan)->send_html) ? 1 : 0;
 }
 
 int ast_channel_sendhtml(struct ast_channel *chan, int subclass, const char *data, int datalen)
 {
-       if (chan->tech->send_html)
-               return chan->tech->send_html(chan, subclass, data, datalen);
+       if (ast_channel_tech(chan)->send_html)
+               return ast_channel_tech(chan)->send_html(chan, subclass, data, datalen);
        return -1;
 }
 
@@ -5760,14 +5791,14 @@ int ast_channel_sendurl(struct ast_channel *chan, const char *url)
 /*! \brief Set up translation from one channel to another */
 static int ast_channel_make_compatible_helper(struct ast_channel *from, struct ast_channel *to)
 {
-       struct ast_format_cap *src_cap = from->nativeformats; /* shallow copy, do not destroy */
-       struct ast_format_cap *dst_cap = to->nativeformats;   /* shallow copy, do not destroy */
+       struct ast_format_cap *src_cap = ast_channel_nativeformats(from); /* shallow copy, do not destroy */
+       struct ast_format_cap *dst_cap = ast_channel_nativeformats(to);   /* shallow copy, do not destroy */
        struct ast_format best_src_fmt;
        struct ast_format best_dst_fmt;
        int use_slin;
 
        /* See if the channel driver can natively make these two channels compatible */
-       if (from->tech->bridge && from->tech->bridge == to->tech->bridge &&
+       if (ast_channel_tech(from)->bridge && ast_channel_tech(from)->bridge == ast_channel_tech(to)->bridge &&
            !ast_channel_setoption(from, AST_OPTION_MAKE_COMPATIBLE, to, sizeof(struct ast_channel *), 0)) {
                return 0;
        }
@@ -5870,8 +5901,8 @@ static int __ast_channel_masquerade(struct ast_channel *original, struct ast_cha
                        && (clonechan->_bridge->_bridge != clonechan)) {
                        final_clone = clonechan->_bridge;
                }
-               if (final_clone->tech->get_base_channel
-                       && (base = final_clone->tech->get_base_channel(final_clone))) {
+               if (ast_channel_tech(final_clone)->get_base_channel
+                       && (base = ast_channel_tech(final_clone)->get_base_channel(final_clone))) {
                        final_clone = base;
                }
 
@@ -5925,9 +5956,9 @@ static int __ast_channel_masquerade(struct ast_channel *original, struct ast_cha
        ast_debug(1, "Planning to masquerade channel %s into the structure of %s\n",
                ast_channel_name(clonechan), ast_channel_name(original));
 
-       if (!original->masqr && !original->masq && !clonechan->masq && !clonechan->masqr) {
-               original->masq = clonechan;
-               clonechan->masqr = original;
+       if (!ast_channel_masqr(original) && !ast_channel_masq(original) && !ast_channel_masq(clonechan) && !ast_channel_masqr(clonechan)) {
+               ast_channel_masq_set(original, clonechan);
+               ast_channel_masqr_set(clonechan, original);
                if (xfer_ds) {
                        ast_channel_datastore_add(original, xfer_ds);
                }
@@ -5935,19 +5966,19 @@ static int __ast_channel_masquerade(struct ast_channel *original, struct ast_cha
                ast_queue_frame(clonechan, &ast_null_frame);
                ast_debug(1, "Done planning to masquerade channel %s into the structure of %s\n", ast_channel_name(clonechan), ast_channel_name(original));
                res = 0;
-       } else if (original->masq) {
+       } else if (ast_channel_masq(original)) {
                ast_log(LOG_WARNING, "%s is already going to masquerade as %s\n",
-                       ast_channel_name(original->masq), ast_channel_name(original));
-       } else if (original->masqr) {
+                       ast_channel_name(ast_channel_masq(original)), ast_channel_name(original));
+       } else if (ast_channel_masqr(original)) {
                /* not yet as a previously planned masq hasn't yet happened */
                ast_log(LOG_WARNING, "%s is already going to masquerade as %s\n",
-                       ast_channel_name(original), ast_channel_name(original->masqr));
-       } else if (clonechan->masq) {
+                       ast_channel_name(original), ast_channel_name(ast_channel_masqr(original)));
+       } else if (ast_channel_masq(clonechan)) {
                ast_log(LOG_WARNING, "%s is already going to masquerade as %s\n",
-                       ast_channel_name(clonechan->masq), ast_channel_name(clonechan));
+                       ast_channel_name(ast_channel_masq(clonechan)), ast_channel_name(clonechan));
        } else { /* (clonechan->masqr) */
                ast_log(LOG_WARNING, "%s is already going to masquerade as %s\n",
-               ast_channel_name(clonechan), ast_channel_name(clonechan->masqr));
+               ast_channel_name(clonechan), ast_channel_name(ast_channel_masqr(clonechan)));
        }
 
        ast_channel_unlock(clonechan);
@@ -6447,7 +6478,7 @@ int ast_do_masquerade(struct ast_channel *original)
         * verifies whether or not the masquerade has already been
         * completed by another thread.
         */
-       while ((clonechan = original->masq) && ast_channel_trylock(clonechan)) {
+       while ((clonechan = ast_channel_masq(original)) && ast_channel_trylock(clonechan)) {
                /*
                 * A masq is needed but we could not get the clonechan lock
                 * immediately.  Since this function already holds the global
@@ -6489,21 +6520,21 @@ int ast_do_masquerade(struct ast_channel *original)
        }
 
        /* clear the masquerade channels */
-       original->masq = NULL;
-       clonechan->masqr = NULL;
+       ast_channel_masq_set(original, NULL);
+       ast_channel_masqr_set(clonechan, NULL);
 
        /* unlink from channels container as name (which is the hash value) will change */
        ao2_unlink(channels, original);
        ao2_unlink(channels, clonechan);
 
        ast_debug(4, "Actually Masquerading %s(%d) into the structure of %s(%d)\n",
-               ast_channel_name(clonechan), clonechan->_state, ast_channel_name(original), original->_state);
+               ast_channel_name(clonechan), ast_channel_state(clonechan), ast_channel_name(original), ast_channel_state(original));
 
        /*
         * Stop any visible indiction on the original channel so we can
         * transfer it to the clonechan taking the original's place.
         */
-       visible_indication = original->visible_indication;
+       visible_indication = ast_channel_visible_indication(original);
        ast_indicate(original, -1);
 
        chans[0] = clonechan;
@@ -6513,7 +6544,7 @@ int ast_do_masquerade(struct ast_channel *original)
                "CloneState: %s\r\n"
                "Original: %s\r\n"
                "OriginalState: %s\r\n",
-               ast_channel_name(clonechan), ast_state2str(clonechan->_state), ast_channel_name(original), ast_state2str(original->_state));
+               ast_channel_name(clonechan), ast_state2str(ast_channel_state(clonechan)), ast_channel_name(original), ast_state2str(ast_channel_state(original)));
 
        /* Having remembered the original read/write formats, we turn off any translation on either
           one */
@@ -6537,18 +6568,18 @@ int ast_do_masquerade(struct ast_channel *original)
        ast_channel_set_linkgroup(original, clonechan);
 
        /* Swap the technologies */
-       t = original->tech;
-       original->tech = clonechan->tech;
-       clonechan->tech = t;
+       t = ast_channel_tech(original);
+       ast_channel_tech_set(original, ast_channel_tech(clonechan));
+       ast_channel_tech_set(clonechan, t);
 
        /* Swap the cdrs */
-       cdr = original->cdr;
-       original->cdr = clonechan->cdr;
-       clonechan->cdr = cdr;
+       cdr = ast_channel_cdr(original);
+       ast_channel_cdr_set(original, ast_channel_cdr(clonechan));
+       ast_channel_cdr_set(clonechan, cdr);
 
-       t_pvt = original->tech_pvt;
-       original->tech_pvt = clonechan->tech_pvt;
-       clonechan->tech_pvt = t_pvt;
+       t_pvt = ast_channel_tech_pvt(original);
+       ast_channel_tech_pvt_set(original, ast_channel_tech_pvt(clonechan));
+       ast_channel_tech_pvt_set(clonechan, t_pvt);
 
        /* Swap the alertpipes */
        for (i = 0; i < 2; i++) {
@@ -6602,16 +6633,16 @@ int ast_do_masquerade(struct ast_channel *original)
           call ast_setstate since the event manager doesn't really consider
           these separate.  We do this early so that the clone has the proper
           state of the original channel. */
-       origstate = original->_state;
-       original->_state = clonechan->_state;
-       clonechan->_state = origstate;
+       origstate = ast_channel_state(original);
+       ast_channel_state_set(original, ast_channel_state(clonechan));
+       ast_channel_state_set(clonechan, origstate);
 
-       if (clonechan->tech->fixup && clonechan->tech->fixup(original, clonechan)) {
+       if (ast_channel_tech(clonechan)->fixup && ast_channel_tech(clonechan)->fixup(original, clonechan)) {
                ast_log(LOG_WARNING, "Fixup failed on channel %s, strange things may happen.\n", ast_channel_name(clonechan));
        }
 
        /* Start by disconnecting the original's physical side */
-       if (clonechan->tech->hangup && clonechan->tech->hangup(clonechan)) {
+       if (ast_channel_tech(clonechan)->hangup && ast_channel_tech(clonechan)->hangup(clonechan)) {
                ast_log(LOG_WARNING, "Hangup failed!  Strange things may happen!\n");
                res = -1;
                goto done;
@@ -6621,16 +6652,16 @@ int ast_do_masquerade(struct ast_channel *original)
         * We just hung up the physical side of the channel.  Set the
         * new zombie to use the kill channel driver for safety.
         */
-       clonechan->tech = &ast_kill_tech;
+       ast_channel_tech_set(clonechan, &ast_kill_tech);
 
        /* Mangle the name of the clone channel */
        snprintf(zombn, sizeof(zombn), "%s<ZOMBIE>", orig); /* quick, hide the brains! */
        __ast_change_name_nolink(clonechan, zombn);
 
        /* Update the type. */
-       t_pvt = original->monitor;
-       original->monitor = clonechan->monitor;
-       clonechan->monitor = t_pvt;
+       t_pvt = ast_channel_monitor(original);
+       ast_channel_monitor_set(original, ast_channel_monitor(clonechan));
+       ast_channel_monitor_set(clonechan, t_pvt);
 
        /* Keep the same language.  */
        ast_channel_language_set(original, ast_channel_language(clonechan));
@@ -6660,14 +6691,14 @@ int ast_do_masquerade(struct ast_channel *original)
 
        clone_variables(original, clonechan);
        /* Presense of ADSI capable CPE follows clone */
-       original->adsicpe = clonechan->adsicpe;
+       ast_channel_adsicpe_set(original, ast_channel_adsicpe(clonechan));
        /* Bridge remains the same */
        /* CDR fields remain the same */
        /* XXX What about blocking, softhangup, blocker, and lock and blockproc? XXX */
        /* Application and data remain the same */
        /* Clone exception  becomes real one, as with fdno */
        ast_set_flag(original, ast_test_flag(clonechan, AST_FLAG_EXCEPTION | AST_FLAG_OUTGOING));
-       original->fdno = clonechan->fdno;
+       ast_channel_fdno_set(original, ast_channel_fdno(clonechan));
        /* Schedule context remains the same */
        /* Stream stuff stays the same */
        /* Keep the original state.  The fixup code will need to work with it most likely */
@@ -6695,10 +6726,10 @@ int ast_do_masquerade(struct ast_channel *original)
        report_new_callerid(original);
 
        /* Restore original timing file descriptor */
-       ast_channel_set_fd(original, AST_TIMING_FD, original->timingfd);
+       ast_channel_set_fd(original, AST_TIMING_FD, ast_channel_timingfd(original));
 
        /* Our native formats are different now */
-       ast_format_cap_copy(original->nativeformats, clonechan->nativeformats);
+       ast_format_cap_copy(ast_channel_nativeformats(original), ast_channel_nativeformats(clonechan));
 
        /* Context, extension, priority, app data, jump table,  remain the same */
        /* pvt switches.  pbx stays the same, as does next */
@@ -6725,16 +6756,16 @@ int ast_do_masquerade(struct ast_channel *original)
 
        /* Okay.  Last thing is to let the channel driver know about all this mess, so he
           can fix up everything as best as possible */
-       if (original->tech->fixup) {
-               if (original->tech->fixup(clonechan, original)) {
+       if (ast_channel_tech(original)->fixup) {
+               if (ast_channel_tech(original)->fixup(clonechan, original)) {
                        ast_log(LOG_WARNING, "Channel for type '%s' could not fixup channel %s\n",
-                               original->tech->type, ast_channel_name(original));
+                               ast_channel_tech(original)->type, ast_channel_name(original));
                        res = -1;
                        goto done;
                }
        } else
                ast_log(LOG_WARNING, "Channel type '%s' does not have a fixup routine (for %s)!  Bad things may happen.\n",
-                       original->tech->type, ast_channel_name(original));
+                       ast_channel_tech(original)->type, ast_channel_name(original));
 
        /* 
         * If an indication is currently playing, maintain it on the channel 
@@ -6761,8 +6792,8 @@ int ast_do_masquerade(struct ast_channel *original)
                        "Cause-txt: %s\r\n",
                        ast_channel_name(clonechan),
                        ast_channel_uniqueid(clonechan),
-                       clonechan->hangupcause,
-                       ast_cause2str(clonechan->hangupcause)
+                       ast_channel_hangupcause(clonechan),
+                       ast_cause2str(ast_channel_hangupcause(clonechan))
                        );
                clonechan = ast_channel_release(clonechan);
        } else {
@@ -6774,7 +6805,7 @@ int ast_do_masquerade(struct ast_channel *original)
        /* Signal any blocker */
        if (ast_test_flag(original, AST_FLAG_BLOCKING))
                pthread_kill(original->blocker, SIGURG);
-       ast_debug(1, "Done Masquerading %s (%d)\n", ast_channel_name(original), original->_state);
+       ast_debug(1, "Done Masquerading %s (%d)\n", ast_channel_name(original), ast_channel_state(original));
 
        if ((bridged = ast_bridged_channel(original))) {
                ast_channel_lock(bridged);
@@ -6831,8 +6862,8 @@ void ast_set_callerid(struct ast_channel *chan, const char *cid_num, const char
                ast_free(chan->caller.ani.number.str);
                chan->caller.ani.number.str = ast_strdup(cid_ani);
        }
-       if (chan->cdr) {
-               ast_cdr_setcid(chan->cdr, chan);
+       if (ast_channel_cdr(chan)) {
+               ast_cdr_setcid(ast_channel_cdr(chan), chan);
        }
 
        report_new_callerid(chan);
@@ -6874,15 +6905,15 @@ void ast_channel_set_caller_event(struct ast_channel *chan, const struct ast_par
                /* The caller id name or number changed. */
                report_new_callerid(chan);
        }
-       if (chan->cdr) {
-               ast_cdr_setcid(chan->cdr, chan);
+       if (ast_channel_cdr(chan)) {
+               ast_cdr_setcid(ast_channel_cdr(chan), chan);
        }
        ast_channel_unlock(chan);
 }
 
 int ast_setstate(struct ast_channel *chan, enum ast_channel_state state)
 {
-       int oldstate = chan->_state;
+       int oldstate = ast_channel_state(chan);
        char name[AST_CHANNEL_NAME], *dashptr;
 
        if (oldstate == state)
@@ -6893,7 +6924,7 @@ int ast_setstate(struct ast_channel *chan, enum ast_channel_state state)
                *dashptr = '\0';
        }
 
-       chan->_state = state;
+       ast_channel_state_set(chan, state);
 
        /* We have to pass AST_DEVICE_UNKNOWN here because it is entirely possible that the channel driver
         * for this channel is using the callback method for device state. If we pass in an actual state here
@@ -6910,7 +6941,7 @@ int ast_setstate(struct ast_channel *chan, enum ast_channel_state state)
                "ConnectedLineNum: %s\r\n"
                "ConnectedLineName: %s\r\n"
                "Uniqueid: %s\r\n",
-               ast_channel_name(chan), chan->_state, ast_state2str(chan->_state),
+               ast_channel_name(chan), ast_channel_state(chan), ast_state2str(ast_channel_state(chan)),
                S_COR(chan->caller.id.number.valid, chan->caller.id.number.str, ""),
                S_COR(chan->caller.id.name.valid, chan->caller.id.name.str, ""),
                S_COR(chan->connected.id.number.valid, chan->connected.id.number.str, ""),
@@ -6925,8 +6956,8 @@ struct ast_channel *ast_bridged_channel(struct ast_channel *chan)
 {
        struct ast_channel *bridged;
        bridged = chan->_bridge;
-       if (bridged && bridged->tech->bridged_channel)
-               bridged = bridged->tech->bridged_channel(chan, bridged);
+       if (bridged && ast_channel_tech(bridged)->bridged_channel)
+               bridged = ast_channel_tech(bridged)->bridged_channel(chan, bridged);
        return bridged;
 }
 
@@ -6982,8 +7013,8 @@ static enum ast_bridge_result ast_generic_bridge(struct ast_channel *c0, struct
        int jb_in_use;
        int to;
 
-       o0nativeformats = ast_format_cap_dup(c0->nativeformats);
-       o1nativeformats = ast_format_cap_dup(c1->nativeformats);
+       o0nativeformats = ast_format_cap_dup(ast_channel_nativeformats(c0));
+       o1nativeformats = ast_format_cap_dup(ast_channel_nativeformats(c1));
 
        if (!o0nativeformats || !o1nativeformats) {
                ast_format_cap_destroy(o0nativeformats); /* NULL safe */
@@ -6993,8 +7024,8 @@ static enum ast_bridge_result ast_generic_bridge(struct ast_channel *c0, struct
 
        cs[0] = c0;
        cs[1] = c1;
-       pvt0 = c0->tech_pvt;
-       pvt1 = c1->tech_pvt;
+       pvt0 = ast_channel_tech_pvt(c0);
+       pvt1 = ast_channel_tech_pvt(c1);
        watch_c0_dtmf = config->flags & AST_BRIDGE_DTMF_CHANNEL_0;
        watch_c1_dtmf = config->flags & AST_BRIDGE_DTMF_CHANNEL_1;
 
@@ -7015,9 +7046,9 @@ static enum ast_bridge_result ast_generic_bridge(struct ast_channel *c0, struct
        for (;;) {
                struct ast_channel *who, *other;
 
-               if ((c0->tech_pvt != pvt0) || (c1->tech_pvt != pvt1) ||
-                   (!ast_format_cap_identical(o0nativeformats, c0->nativeformats)) ||
-                   (!ast_format_cap_identical(o1nativeformats, c1->nativeformats))) {
+               if ((ast_channel_tech_pvt(c0) != pvt0) || (ast_channel_tech_pvt(c1) != pvt1) ||
+                   (!ast_format_cap_identical(o0nativeformats, ast_channel_nativeformats(c0))) ||
+                   (!ast_format_cap_identical(o1nativeformats, ast_channel_nativeformats(c1)))) {
                        /* Check for Masquerade, codec changes, etc */
                        res = AST_BRIDGE_RETRY;
                        break;
@@ -7178,10 +7209,10 @@ static enum ast_bridge_result ast_generic_bridge(struct ast_channel *c0, struct
 int ast_channel_early_bridge(struct ast_channel *c0, struct ast_channel *c1)
 {
        /* Make sure we can early bridge, if not error out */
-       if (!c0->tech->early_bridge || (c1 && (!c1->tech->early_bridge || c0->tech->early_bridge != c1->tech->early_bridge)))
+       if (!ast_channel_tech(c0)->early_bridge || (c1 && (!ast_channel_tech(c1)->early_bridge || ast_channel_tech(c0)->early_bridge != ast_channel_tech(c1)->early_bridge)))
                return -1;
 
-       return c0->tech->early_bridge(c0, c1);
+       return ast_channel_tech(c0)->early_bridge(c0, c1);
 }
 
 /*! \brief Send manager event for bridge link and unlink events.
@@ -7219,8 +7250,8 @@ static void update_bridge_vars(struct ast_channel *c0, struct ast_channel *c1)
 
        ast_channel_lock(c1);
        c1_name = ast_strdupa(ast_channel_name(c1));
-       if (c1->tech->get_pvt_uniqueid) {
-               c1_pvtid = ast_strdupa(c1->tech->get_pvt_uniqueid(c1));
+       if (ast_channel_tech(c1)->get_pvt_uniqueid) {
+               c1_pvtid = ast_strdupa(ast_channel_tech(c1)->get_pvt_uniqueid(c1));
        }
        ast_channel_unlock(c1);
 
@@ -7232,8 +7263,8 @@ static void update_bridge_vars(struct ast_channel *c0, struct ast_channel *c1)
                pbx_builtin_setvar_helper(c0, "BRIDGEPVTCALLID", c1_pvtid);
        }
        c0_name = ast_strdupa(ast_channel_name(c0));
-       if (c0->tech->get_pvt_uniqueid) {
-               c0_pvtid = ast_strdupa(c0->tech->get_pvt_uniqueid(c0));
+       if (ast_channel_tech(c0)->get_pvt_uniqueid) {
+               c0_pvtid = ast_strdupa(ast_channel_tech(c0)->get_pvt_uniqueid(c0));
        }
        ast_channel_unlock(c0);
 
@@ -7303,8 +7334,8 @@ enum ast_bridge_result ast_channel_bridge(struct ast_channel *c0, struct ast_cha
            ast_test_flag(c1, AST_FLAG_ZOMBIE) || ast_check_hangup_locked(c1))
                return -1;
 
-       o0nativeformats = ast_format_cap_dup(c0->nativeformats);
-       o1nativeformats = ast_format_cap_dup(c1->nativeformats);
+       o0nativeformats = ast_format_cap_dup(ast_channel_nativeformats(c0));
+       o1nativeformats = ast_format_cap_dup(ast_channel_nativeformats(c1));
        if (!o0nativeformats || !o1nativeformats) {
                ast_format_cap_destroy(o0nativeformats);
                ast_format_cap_destroy(o1nativeformats);
@@ -7354,9 +7385,9 @@ enum ast_bridge_result ast_channel_bridge(struct ast_channel *c0, struct ast_cha
                config->nexteventts.tv_usec = 0;
        }
 
-       if (!c0->tech->send_digit_begin)
+       if (!ast_channel_tech(c0)->send_digit_begin)
                ast_set_flag(c1, AST_FLAG_END_DTMF_ONLY);
-       if (!c1->tech->send_digit_begin)
+       if (!ast_channel_tech(c1)->send_digit_begin)
                ast_set_flag(c0, AST_FLAG_END_DTMF_ONLY);
        manager_bridge_event(1, 1, c0, c1);
 
@@ -7446,19 +7477,19 @@ enum ast_bridge_result ast_channel_bridge(struct ast_channel *c0, struct ast_cha
 
                bridge_play_sounds(c0, c1);
 
-               if (c0->tech->bridge &&
+               if (ast_channel_tech(c0)->bridge &&
                        /* if < 1 ms remains use generic bridging for accurate timing */
                        (!config->timelimit || to > 1000 || to == 0) &&
-                   (c0->tech->bridge == c1->tech->bridge) &&
-                   !c0->monitor && !c1->monitor &&
-                   !c0->audiohooks && !c1->audiohooks &&
-                   ast_framehook_list_is_empty(c0->framehooks) && ast_framehook_list_is_empty(c1->framehooks) &&
-                   !c0->masq && !c0->masqr && !c1->masq && !c1->masqr) {
+                   (ast_channel_tech(c0)->bridge == ast_channel_tech(c1)->bridge) &&
+                   !ast_channel_monitor(c0) && !ast_channel_monitor(c1) &&
+                   !ast_channel_audiohooks(c0) && !ast_channel_audiohooks(c1) &&
+                   ast_framehook_list_is_empty(ast_channel_framehooks(c0)) && ast_framehook_list_is_empty(ast_channel_framehooks(c1)) &&
+                   !ast_channel_masq(c0) && !ast_channel_masqr(c0) && !ast_channel_masq(c1) && !ast_channel_masqr(c1)) {
                        int timeoutms = to - 1000 > 0 ? to - 1000 : to;
                        /* Looks like they share a bridge method and nothing else is in the way */
                        ast_set_flag(c0, AST_FLAG_NBRIDGE);
                        ast_set_flag(c1, AST_FLAG_NBRIDGE);
-                       if ((res = c0->tech->bridge(c0, c1, config->flags, fo, rc, timeoutms)) == AST_BRIDGE_COMPLETE) {
+                       if ((res = ast_channel_tech(c0)->bridge(c0, c1, config->flags, fo, rc, timeoutms)) == AST_BRIDGE_COMPLETE) {
                                manager_bridge_event(0, 1, c0, c1);
                                ast_debug(1, "Returning from native bridge, channels: %s, %s\n", ast_channel_name(c0), ast_channel_name(c1));
 
@@ -7494,9 +7525,9 @@ enum ast_bridge_result ast_channel_bridge(struct ast_channel *c0, struct ast_cha
 
                if (((ast_format_cmp(&c1->readformat, &c0->writeformat) == AST_FORMAT_CMP_NOT_EQUAL) ||
                        (ast_format_cmp(&c0->readformat, &c1->writeformat) == AST_FORMAT_CMP_NOT_EQUAL) ||
-                   !ast_format_cap_identical(c0->nativeformats, o0nativeformats) ||
-                       !ast_format_cap_identical(c1->nativeformats, o1nativeformats)) &&
-                   !(c0->generator || c1->generator)) {
+                   !ast_format_cap_identical(ast_channel_nativeformats(c0), o0nativeformats) ||
+                       !ast_format_cap_identical(ast_channel_nativeformats(c1), o1nativeformats)) &&
+                   !(ast_channel_generator(c0) || ast_channel_generator(c1))) {
                        if (ast_channel_make_compatible(c0, c1)) {
                                ast_log(LOG_WARNING, "Can't make %s and %s compatible\n", ast_channel_name(c0), ast_channel_name(c1));
                                manager_bridge_event(0, 1, c0, c1);
@@ -7505,8 +7536,8 @@ enum ast_bridge_result ast_channel_bridge(struct ast_channel *c0, struct ast_cha
                                return AST_BRIDGE_FAILED;
                        }
 
-                       ast_format_cap_copy(o0nativeformats, c0->nativeformats);
-                       ast_format_cap_copy(o1nativeformats, c1->nativeformats);
+                       ast_format_cap_copy(o0nativeformats, ast_channel_nativeformats(c0));
+                       ast_format_cap_copy(o1nativeformats, ast_channel_nativeformats(c1));
                }
 
                update_bridge_vars(c0, c1);
@@ -7544,7 +7575,7 @@ int ast_channel_setoption(struct ast_channel *chan, int option, void *data, int
        int res;
 
        ast_channel_lock(chan);
-       if (!chan->tech->setoption) {
+       if (!ast_channel_tech(chan)->setoption) {
                errno = ENOSYS;
                ast_channel_unlock(chan);
                return -1;
@@ -7553,7 +7584,7 @@ int ast_channel_setoption(struct ast_channel *chan, int option, void *data, int
        if (block)
                ast_log(LOG_ERROR, "XXX Blocking not implemented yet XXX\n");
 
-       res = chan->tech->setoption(chan, option, data, datalen);
+       res = ast_channel_tech(chan)->setoption(chan, option, data, datalen);
        ast_channel_unlock(chan);
 
        return res;
@@ -7564,7 +7595,7 @@ int ast_channel_queryoption(struct ast_channel *chan, int option, void *data, in
        int res;
 
        ast_channel_lock(chan);
-       if (!chan->tech->queryoption) {
+       if (!ast_channel_tech(chan)->queryoption) {
                errno = ENOSYS;
                ast_channel_unlock(chan);
                return -1;
@@ -7573,7 +7604,7 @@ int ast_channel_queryoption(struct ast_channel *chan, int option, void *data, in
        if (block)
                ast_log(LOG_ERROR, "XXX Blocking not implemented yet XXX\n");
 
-       res = chan->tech->queryoption(chan, option, data, datalen);
+       res = ast_channel_tech(chan)->queryoption(chan, option, data, datalen);
        ast_channel_unlock(chan);
 
        return res;
@@ -7721,7 +7752,7 @@ int ast_tonepair(struct ast_channel *chan, int freq1, int freq2, int duration, i
                return res;
 
        /* Give us some wiggle room */
-       while (chan->generatordata && ast_waitfor(chan, 100) >= 0) {
+       while (ast_channel_generatordata(chan) && ast_waitfor(chan, 100) >= 0) {
                struct ast_frame *f = ast_read(chan);
                if (f)
                        ast_frfree(f);
index 6fc116a310ead3ad429a90094c36e6a5a2c72993..5a2061952601f21cd539285655ad30515774b1f2 100644 (file)
@@ -1,30 +1,30 @@
 /*
- * Asterisk -- An open source telephony toolkit.
+ *Asterisk -- An open source telephony toolkit.
  *
- * Copyright (C) 2012, Digium, Inc.
+ *Copyright (C) 2012, Digium, Inc.
  *
- * Mark Spencer <markster@digium.com>
+ *Mark Spencer <markster@digium.com>
  *
- * See http://www.asterisk.org for more information about
- * the Asterisk project. Please do not directly contact
- * any of the maintainers of this project for assistance;
- * the project provides a web site, mailing lists and IRC
- * channels for your use.
+ *See http://www.asterisk.org for more information about
+ *the Asterisk project. Please do not directly contact
+ *any of the maintainers of this project for assistance;
+ *the project provides a web site, mailing lists and IRC
+ *channels for your use.
  *
- * This program is free software, distributed under the terms of
- * the GNU General Public License Version 2. See the LICENSE file
- * at the top of the source tree.
+ *This program is free software, distributed under the terms of
+ *the GNU General Public License Version 2. See the LICENSE file
+ *at the top of the source tree.
  */
 
 /*! \file
  *
- * \brief Channel Accessor API
+ *\brief Channel Accessor API
  *
- * This file is intended to be the only file that ever accesses the
- * internals of an ast_channel. All other files should use the
- * accessor functions defined here.
+ *This file is intended to be the only file that ever accesses the
+ *internals of an ast_channel. All other files should use the
+ *accessor functions defined here.
  *
- * \author Terry Wilson
+ *\author Terry Wilson
  */
 
 #include "asterisk.h"
@@ -67,14 +67,14 @@ AST_DATA_STRUCTURE(ast_callerid, DATA_EXPORT_CALLERID);
        MEMBER(ast_channel, __do_not_use_parkinglot, AST_DATA_STRING)                   \
        MEMBER(ast_channel, __do_not_use_hangupsource, AST_DATA_STRING)                 \
        MEMBER(ast_channel, __do_not_use_dialcontext, AST_DATA_STRING)                  \
-       MEMBER(ast_channel, rings, AST_DATA_INTEGER)                            \
-       MEMBER(ast_channel, priority, AST_DATA_INTEGER)                         \
-       MEMBER(ast_channel, macropriority, AST_DATA_INTEGER)                    \
-       MEMBER(ast_channel, adsicpe, AST_DATA_INTEGER)                          \
-       MEMBER(ast_channel, fin, AST_DATA_UNSIGNED_INTEGER)                     \
-       MEMBER(ast_channel, fout, AST_DATA_UNSIGNED_INTEGER)                    \
-       MEMBER(ast_channel, emulate_dtmf_duration, AST_DATA_UNSIGNED_INTEGER)   \
-       MEMBER(ast_channel, visible_indication, AST_DATA_INTEGER)               \
+       MEMBER(ast_channel, __do_not_use_rings, AST_DATA_INTEGER)                               \
+       MEMBER(ast_channel, __do_not_use_priority, AST_DATA_INTEGER)                            \
+       MEMBER(ast_channel, __do_not_use_macropriority, AST_DATA_INTEGER)                       \
+       MEMBER(ast_channel, __do_not_use_adsicpe, AST_DATA_INTEGER)                             \
+       MEMBER(ast_channel, __do_not_use_fin, AST_DATA_UNSIGNED_INTEGER)                        \
+       MEMBER(ast_channel, __do_not_use_fout, AST_DATA_UNSIGNED_INTEGER)                       \
+       MEMBER(ast_channel, __do_not_use_emulate_dtmf_duration, AST_DATA_UNSIGNED_INTEGER)      \
+       MEMBER(ast_channel, __do_not_use_visible_indication, AST_DATA_INTEGER)          \
        MEMBER(ast_channel, __do_not_use_context, AST_DATA_STRING)                              \
        MEMBER(ast_channel, __do_not_use_exten, AST_DATA_STRING)                                \
        MEMBER(ast_channel, __do_not_use_macrocontext, AST_DATA_STRING)                 \
@@ -142,39 +142,39 @@ int ast_channel_data_add_structure(struct ast_data *tree,
        ast_data_add_codec(tree, "writeformat", &chan->writeformat);
        ast_data_add_codec(tree, "rawreadformat", &chan->rawreadformat);
        ast_data_add_codec(tree, "rawwriteformat", &chan->rawwriteformat);
-       ast_data_add_codecs(tree, "nativeformats", chan->nativeformats);
+       ast_data_add_codecs(tree, "nativeformats", ast_channel_nativeformats(chan));
 
        /* state */
        enum_node = ast_data_add_node(tree, "state");
        if (!enum_node) {
                return -1;
        }
-       ast_data_add_str(enum_node, "text", ast_state2str(chan->_state));
-       ast_data_add_int(enum_node, "value", chan->_state);
+       ast_data_add_str(enum_node, "text", ast_state2str(ast_channel_state(chan)));
+       ast_data_add_int(enum_node, "value", ast_channel_state(chan));
 
        /* hangupcause */
        enum_node = ast_data_add_node(tree, "hangupcause");
        if (!enum_node) {
                return -1;
        }
-       ast_data_add_str(enum_node, "text", ast_cause2str(chan->hangupcause));
-       ast_data_add_int(enum_node, "value", chan->hangupcause);
+       ast_data_add_str(enum_node, "text", ast_cause2str(ast_channel_hangupcause(chan)));
+       ast_data_add_int(enum_node, "value", ast_channel_hangupcause(chan));
 
        /* amaflags */
        enum_node = ast_data_add_node(tree, "amaflags");
        if (!enum_node) {
                return -1;
        }
-       ast_data_add_str(enum_node, "text", ast_cdr_flags2str(chan->amaflags));
-       ast_data_add_int(enum_node, "value", chan->amaflags);
+       ast_data_add_str(enum_node, "text", ast_cdr_flags2str(ast_channel_amaflags(chan)));
+       ast_data_add_int(enum_node, "value", ast_channel_amaflags(chan));
 
        /* transfercapability */
        enum_node = ast_data_add_node(tree, "transfercapability");
        if (!enum_node) {
                return -1;
        }
-       ast_data_add_str(enum_node, "text", ast_transfercapability2str(chan->transfercapability));
-       ast_data_add_int(enum_node, "value", chan->transfercapability);
+       ast_data_add_str(enum_node, "text", ast_transfercapability2str(ast_channel_transfercapability(chan)));
+       ast_data_add_int(enum_node, "value", ast_channel_transfercapability(chan));
 
        /* _softphangup */
        data_softhangup = ast_data_add_node(tree, "softhangup");
@@ -218,12 +218,12 @@ int ast_channel_data_add_structure(struct ast_data *tree,
 #endif
 
        /* tone zone */
-       if (chan->zone) {
+       if (ast_channel_zone(chan)) {
                data_zones = ast_data_add_node(tree, "zone");
                if (!data_zones) {
                        return -1;
                }
-               ast_tone_zone_data_add_structure(data_zones, chan->zone);
+               ast_tone_zone_data_add_structure(data_zones, ast_channel_zone(chan));
        }
 
        /* insert cdr */
@@ -232,7 +232,7 @@ int ast_channel_data_add_structure(struct ast_data *tree,
                return -1;
        }
 
-       ast_cdr_data_add_structure(data_cdr, chan->cdr, 1);
+       ast_cdr_data_add_structure(data_cdr, ast_channel_cdr(chan), 1);
 
        return 0;
 }
@@ -352,3 +352,335 @@ void ast_channel_macroexten_set(struct ast_channel *chan, const char *value)
 {
        ast_copy_string(chan->__do_not_use_macroexten, value, sizeof(chan->__do_not_use_macroexten));
 }
+
+
+char ast_channel_emulate_dtmf_digit(const struct ast_channel *chan)
+{
+       return chan->__do_not_use_emulate_dtmf_digit;
+}
+void ast_channel_emulate_dtmf_digit_set(struct ast_channel *chan, char value)
+{
+       chan->__do_not_use_emulate_dtmf_digit = value;
+}
+int ast_channel_amaflags(const struct ast_channel *chan)
+{
+       return chan->__do_not_use_amaflags;
+}
+void ast_channel_amaflags_set(struct ast_channel *chan, int value)
+{
+       chan->__do_not_use_amaflags = value;
+}
+#ifdef HAVE_EPOLL
+int ast_channel_epfd(const struct ast_channel *chan)
+{
+       return chan->__do_not_use_epfd;
+}
+void ast_channel_epfd_set(struct ast_channel *chan, int value)
+{
+       chan->__do_not_use_epfd = value;
+}
+#endif
+int ast_channel_fdno(const struct ast_channel *chan)
+{
+       return chan->__do_not_use_fdno;
+}
+void ast_channel_fdno_set(struct ast_channel *chan, int value)
+{
+       chan->__do_not_use_fdno = value;
+}
+int ast_channel_hangupcause(const struct ast_channel *chan)
+{
+       return chan->__do_not_use_hangupcause;
+}
+void ast_channel_hangupcause_set(struct ast_channel *chan, int value)
+{
+       chan->__do_not_use_hangupcause = value;
+}
+int ast_channel_macropriority(const struct ast_channel *chan)
+{
+       return chan->__do_not_use_macropriority;
+}
+void ast_channel_macropriority_set(struct ast_channel *chan, int value)
+{
+       chan->__do_not_use_macropriority = value;
+}
+int ast_channel_priority(const struct ast_channel *chan)
+{
+       return chan->__do_not_use_priority;
+}
+void ast_channel_priority_set(struct ast_channel *chan, int value)
+{
+       chan->__do_not_use_priority = value;
+}
+int ast_channel_rings(const struct ast_channel *chan)
+{
+       return chan->__do_not_use_rings;
+}
+void ast_channel_rings_set(struct ast_channel *chan, int value)
+{
+       chan->__do_not_use_rings = value;
+}
+int ast_channel_streamid(const struct ast_channel *chan)
+{
+       return chan->__do_not_use_streamid;
+}
+void ast_channel_streamid_set(struct ast_channel *chan, int value)
+{
+       chan->__do_not_use_streamid = value;
+}
+int ast_channel_timingfd(const struct ast_channel *chan)
+{
+       return chan->__do_not_use_timingfd;
+}
+void ast_channel_timingfd_set(struct ast_channel *chan, int value)
+{
+       chan->__do_not_use_timingfd = value;
+}
+int ast_channel_visible_indication(const struct ast_channel *chan)
+{
+       return chan->__do_not_use_visible_indication;
+}
+void ast_channel_visible_indication_set(struct ast_channel *chan, int value)
+{
+       chan->__do_not_use_visible_indication = value;
+}
+int ast_channel_vstreamid(const struct ast_channel *chan)
+{
+       return chan->__do_not_use_vstreamid;
+}
+void ast_channel_vstreamid_set(struct ast_channel *chan, int value)
+{
+       chan->__do_not_use_vstreamid = value;
+}
+unsigned short ast_channel_transfercapability(const struct ast_channel *chan)
+{
+       return chan->__do_not_use_transfercapability;
+}
+void ast_channel_transfercapability_set(struct ast_channel *chan, unsigned short value)
+{
+       chan->__do_not_use_transfercapability = value;
+}
+unsigned int ast_channel_emulate_dtmf_duration(const struct ast_channel *chan)
+{
+       return chan->__do_not_use_emulate_dtmf_duration;
+}
+void ast_channel_emulate_dtmf_duration_set(struct ast_channel *chan, unsigned int value)
+{
+       chan->__do_not_use_emulate_dtmf_duration = value;
+}
+unsigned int ast_channel_fin(const struct ast_channel *chan)
+{
+       return chan->__do_not_use_fin;
+}
+void ast_channel_fin_set(struct ast_channel *chan, unsigned int value)
+{
+       chan->__do_not_use_fin = value;
+}
+unsigned int ast_channel_fout(const struct ast_channel *chan)
+{
+       return chan->__do_not_use_fout;
+}
+void ast_channel_fout_set(struct ast_channel *chan, unsigned int value)
+{
+       chan->__do_not_use_fout = value;
+}
+unsigned long ast_channel_insmpl(const struct ast_channel *chan)
+{
+       return chan->__do_not_use_insmpl;
+}
+void ast_channel_insmpl_set(struct ast_channel *chan, unsigned long value)
+{
+       chan->__do_not_use_insmpl = value;
+}
+unsigned long ast_channel_outsmpl(const struct ast_channel *chan)
+{
+       return chan->__do_not_use_outsmpl;
+}
+void ast_channel_outsmpl_set(struct ast_channel *chan, unsigned long value)
+{
+       chan->__do_not_use_outsmpl = value;
+}
+void *ast_channel_generatordata(const struct ast_channel *chan)
+{
+       return chan->__do_not_use_generatordata;
+}
+void ast_channel_generatordata_set(struct ast_channel *chan, void *value)
+{
+       chan->__do_not_use_generatordata = value;
+}
+void *ast_channel_music_state(const struct ast_channel *chan)
+{
+       return chan->__do_not_use_music_state;
+}
+void ast_channel_music_state_set(struct ast_channel *chan, void *value)
+{
+       chan->__do_not_use_music_state = value;
+}
+void *ast_channel_tech_pvt(const struct ast_channel *chan)
+{
+       return chan->__do_not_use_tech_pvt;
+}
+void ast_channel_tech_pvt_set(struct ast_channel *chan, void *value)
+{
+       chan->__do_not_use_tech_pvt = value;
+}
+void *ast_channel_timingdata(const struct ast_channel *chan)
+{
+       return chan->__do_not_use_timingdata;
+}
+void ast_channel_timingdata_set(struct ast_channel *chan, void *value)
+{
+       chan->__do_not_use_timingdata = value;
+}
+struct ast_audiohook_list *ast_channel_audiohooks(const struct ast_channel *chan)
+{
+       return chan->__do_not_use_audiohooks;
+}
+void ast_channel_audiohooks_set(struct ast_channel *chan, struct ast_audiohook_list *value)
+{
+       chan->__do_not_use_audiohooks = value;
+}
+struct ast_cdr *ast_channel_cdr(const struct ast_channel *chan)
+{
+       return chan->__do_not_use_cdr;
+}
+void ast_channel_cdr_set(struct ast_channel *chan, struct ast_cdr *value)
+{
+       chan->__do_not_use_cdr = value;
+}
+struct ast_channel *ast_channel_masq(const struct ast_channel *chan)
+{
+       return chan->__do_not_use_masq;
+}
+void ast_channel_masq_set(struct ast_channel *chan, struct ast_channel *value)
+{
+       chan->__do_not_use_masq = value;
+}
+struct ast_channel *ast_channel_masqr(const struct ast_channel *chan)
+{
+       return chan->__do_not_use_masqr;
+}
+void ast_channel_masqr_set(struct ast_channel *chan, struct ast_channel *value)
+{
+       chan->__do_not_use_masqr = value;
+}
+struct ast_channel_monitor *ast_channel_monitor(const struct ast_channel *chan)
+{
+       return chan->__do_not_use_monitor;
+}
+void ast_channel_monitor_set(struct ast_channel *chan, struct ast_channel_monitor *value)
+{
+       chan->__do_not_use_monitor = value;
+}
+struct ast_filestream *ast_channel_stream(const struct ast_channel *chan)
+{
+       return chan->__do_not_use_stream;
+}
+void ast_channel_stream_set(struct ast_channel *chan, struct ast_filestream *value)
+{
+       chan->__do_not_use_stream = value;
+}
+struct ast_filestream *ast_channel_vstream(const struct ast_channel *chan)
+{
+       return chan->__do_not_use_vstream;
+}
+void ast_channel_vstream_set(struct ast_channel *chan, struct ast_filestream *value)
+{
+       chan->__do_not_use_vstream = value;
+}
+struct ast_format_cap *ast_channel_nativeformats(const struct ast_channel *chan)
+{
+       return chan->__do_not_use_nativeformats;
+}
+void ast_channel_nativeformats_set(struct ast_channel *chan, struct ast_format_cap *value)
+{
+       chan->__do_not_use_nativeformats = value;
+}
+struct ast_framehook_list *ast_channel_framehooks(const struct ast_channel *chan)
+{
+       return chan->__do_not_use_framehooks;
+}
+void ast_channel_framehooks_set(struct ast_channel *chan, struct ast_framehook_list *value)
+{
+       chan->__do_not_use_framehooks = value;
+}
+struct ast_generator *ast_channel_generator(const struct ast_channel *chan)
+{
+       return chan->__do_not_use_generator;
+}
+void ast_channel_generator_set(struct ast_channel *chan, struct ast_generator *value)
+{
+       chan->__do_not_use_generator = value;
+}
+struct ast_pbx *ast_channel_pbx(const struct ast_channel *chan)
+{
+       return chan->__do_not_use_pbx;
+}
+void ast_channel_pbx_set(struct ast_channel *chan, struct ast_pbx *value)
+{
+       chan->__do_not_use_pbx = value;
+}
+struct ast_sched_context *ast_channel_sched(const struct ast_channel *chan)
+{
+       return chan->__do_not_use_sched;
+}
+void ast_channel_sched_set(struct ast_channel *chan, struct ast_sched_context *value)
+{
+       chan->__do_not_use_sched = value;
+}
+struct ast_timer *ast_channel_timer(const struct ast_channel *chan)
+{
+       return chan->__do_not_use_timer;
+}
+void ast_channel_timer_set(struct ast_channel *chan, struct ast_timer *value)
+{
+       chan->__do_not_use_timer = value;
+}
+struct ast_tone_zone *ast_channel_zone(const struct ast_channel *chan)
+{
+       return chan->__do_not_use_zone;
+}
+void ast_channel_zone_set(struct ast_channel *chan, struct ast_tone_zone *value)
+{
+       chan->__do_not_use_zone = value;
+}
+struct ast_trans_pvt *ast_channel_readtrans(const struct ast_channel *chan)
+{
+       return chan->__do_not_use_readtrans;
+}
+void ast_channel_readtrans_set(struct ast_channel *chan, struct ast_trans_pvt *value)
+{
+       chan->__do_not_use_readtrans = value;
+}
+struct ast_trans_pvt *ast_channel_writetrans(const struct ast_channel *chan)
+{
+       return chan->__do_not_use_writetrans;
+}
+void ast_channel_writetrans_set(struct ast_channel *chan, struct ast_trans_pvt *value)
+{
+       chan->__do_not_use_writetrans = value;
+}
+const struct ast_channel_tech *ast_channel_tech(const struct ast_channel *chan)
+{
+       return chan->__do_not_use_tech;
+}
+void ast_channel_tech_set(struct ast_channel *chan, const struct ast_channel_tech *value)
+{
+       chan->__do_not_use_tech = value;
+}
+enum ast_channel_adsicpe ast_channel_adsicpe(const struct ast_channel *chan)
+{
+       return chan->__do_not_use_adsicpe;
+}
+void ast_channel_adsicpe_set(struct ast_channel *chan, enum ast_channel_adsicpe value)
+{
+       chan->__do_not_use_adsicpe = value;
+}
+enum ast_channel_state ast_channel_state(const struct ast_channel *chan)
+{
+       return chan->__do_not_use_state;
+}
+void ast_channel_state_set(struct ast_channel *chan, enum ast_channel_state value)
+{
+       chan->__do_not_use_state = value;
+}
index dd4ccf9b9a5bcfce6e4dc364ec4d3e890dd4db5f..c6355835be53eab85351fc97c8f15b070d10bdc1 100644 (file)
@@ -902,8 +902,8 @@ static char *handle_chanlist(struct ast_cli_entry *e, int cmd, struct ast_cli_ar
                bc = ast_bridged_channel(c);
 
                if (!count) {
-                       if ((concise || verbose)  && c->cdr && !ast_tvzero(c->cdr->start)) {
-                               int duration = (int)(ast_tvdiff_ms(ast_tvnow(), c->cdr->start) / 1000);
+                       if ((concise || verbose)  && ast_channel_cdr(c) && !ast_tvzero(ast_channel_cdr(c)->start)) {
+                               int duration = (int)(ast_tvdiff_ms(ast_tvnow(), ast_channel_cdr(c)->start) / 1000);
                                if (verbose) {
                                        int durh = duration / 3600;
                                        int durm = (duration % 3600) / 60;
@@ -914,18 +914,18 @@ static char *handle_chanlist(struct ast_cli_entry *e, int cmd, struct ast_cli_ar
                                }                               
                        }
                        if (concise) {
-                               ast_cli(a->fd, CONCISE_FORMAT_STRING, ast_channel_name(c), ast_channel_context(c), ast_channel_exten(c), c->priority, ast_state2str(c->_state),
+                               ast_cli(a->fd, CONCISE_FORMAT_STRING, ast_channel_name(c), ast_channel_context(c), ast_channel_exten(c), ast_channel_priority(c), ast_state2str(ast_channel_state(c)),
                                        ast_channel_appl(c) ? ast_channel_appl(c) : "(None)",
                                        S_OR(ast_channel_data(c), ""),  /* XXX different from verbose ? */
                                        S_COR(c->caller.id.number.valid, c->caller.id.number.str, ""),
                                        S_OR(ast_channel_accountcode(c), ""),
                                        S_OR(ast_channel_peeraccount(c), ""),
-                                       c->amaflags
+                                       ast_channel_amaflags(c)
                                        durbuf,
                                        bc ? ast_channel_name(bc) : "(None)",
                                        ast_channel_uniqueid(c));
                        } else if (verbose) {
-                               ast_cli(a->fd, VERBOSE_FORMAT_STRING, ast_channel_name(c), ast_channel_context(c), ast_channel_exten(c), c->priority, ast_state2str(c->_state),
+                               ast_cli(a->fd, VERBOSE_FORMAT_STRING, ast_channel_name(c), ast_channel_context(c), ast_channel_exten(c), ast_channel_priority(c), ast_state2str(ast_channel_state(c)),
                                        ast_channel_appl(c) ? ast_channel_appl(c) : "(None)",
                                        ast_channel_data(c) ? S_OR(ast_channel_data(c), "(Empty)" ): "(None)",
                                        S_COR(c->caller.id.number.valid, c->caller.id.number.str, ""),
@@ -938,10 +938,10 @@ static char *handle_chanlist(struct ast_cli_entry *e, int cmd, struct ast_cli_ar
                                char appdata[40] = "(None)";
                                
                                if (!ast_strlen_zero(ast_channel_context(c)) && !ast_strlen_zero(ast_channel_exten(c))) 
-                                       snprintf(locbuf, sizeof(locbuf), "%s@%s:%d", ast_channel_exten(c), ast_channel_context(c), c->priority);
+                                       snprintf(locbuf, sizeof(locbuf), "%s@%s:%d", ast_channel_exten(c), ast_channel_context(c), ast_channel_priority(c));
                                if (ast_channel_appl(c))
                                        snprintf(appdata, sizeof(appdata), "%s(%s)", ast_channel_appl(c), S_OR(ast_channel_data(c), ""));
-                               ast_cli(a->fd, FORMAT_STRING, ast_channel_name(c), locbuf, ast_state2str(c->_state), appdata);
+                               ast_cli(a->fd, FORMAT_STRING, ast_channel_name(c), locbuf, ast_state2str(ast_channel_state(c)), appdata);
                        }
                }
                ast_channel_unlock(c);
@@ -1280,13 +1280,13 @@ static int channel_set_debug(void *obj, void *arg, void *data, int flags)
 
        ast_channel_lock(chan);
 
-       if (!(chan->fin & DEBUGCHAN_FLAG) || !(chan->fout & DEBUGCHAN_FLAG)) {
+       if (!(ast_channel_fin(chan) & DEBUGCHAN_FLAG) || !(ast_channel_fout(chan) & DEBUGCHAN_FLAG)) {
                if (args->is_off) {
-                       chan->fin &= ~DEBUGCHAN_FLAG;
-                       chan->fout &= ~DEBUGCHAN_FLAG;
+                       ast_channel_fin_set(chan, ast_channel_fin(chan) & ~DEBUGCHAN_FLAG);
+                       ast_channel_fout_set(chan, ast_channel_fout(chan) & ~DEBUGCHAN_FLAG);
                } else {
-                       chan->fin |= DEBUGCHAN_FLAG;
-                       chan->fout |= DEBUGCHAN_FLAG;
+                       ast_channel_fin_set(chan, ast_channel_fin(chan) | DEBUGCHAN_FLAG);
+                       ast_channel_fout_set(chan, ast_channel_fout(chan) | DEBUGCHAN_FLAG);
                }
                ast_cli(args->fd, "Debugging %s on channel %s\n", args->is_off ? "disabled" : "enabled",
                                ast_channel_name(chan));
@@ -1430,8 +1430,8 @@ static char *handle_showchan(struct ast_cli_entry *e, int cmd, struct ast_cli_ar
 
        ast_channel_lock(c);
 
-       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;
@@ -1475,27 +1475,27 @@ static char *handle_showchan(struct ast_cli_entry *e, int cmd, struct ast_cli_ar
                "    Application: %s\n"
                "           Data: %s\n"
                "    Blocking in: %s\n",
-               ast_channel_name(c), c->tech->type, ast_channel_uniqueid(c), ast_channel_linkedid(c),
+               ast_channel_name(c), 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)"),
                S_COR(c->caller.id.name.valid, c->caller.id.name.str, "(N/A)"),
                S_COR(c->connected.id.number.valid, c->connected.id.number.str, "(N/A)"),
                S_COR(c->connected.id.name.valid, c->connected.id.name.str, "(N/A)"),
                S_OR(c->dialed.number.str, "(N/A)"),
                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),
-               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,
                cdrtime, c->_bridge ? ast_channel_name(c->_bridge) : "<none>", ast_bridged_channel(c) ? ast_channel_name(ast_bridged_channel(c)) : "<none>", 
-               ast_channel_context(c), ast_channel_exten(c), c->priority, c->callgroup, c->pickupgroup, (ast_channel_appl(c) ? ast_channel_appl(c) : "(N/A)" ),
+               ast_channel_context(c), ast_channel_exten(c), ast_channel_priority(c), c->callgroup, c->pickupgroup, (ast_channel_appl(c) ? ast_channel_appl(c) : "(N/A)" ),
                (ast_channel_data(c) ? S_OR(ast_channel_data(c), "(Empty)") : "(None)"),
                (ast_test_flag(c, AST_FLAG_BLOCKING) ? ast_channel_blockproc(c) : "(Not Blocking)"));
        
@@ -1503,7 +1503,7 @@ static char *handle_showchan(struct ast_cli_entry *e, int cmd, struct ast_cli_ar
                ast_str_append(&output, 0, "      Variables:\n%s\n", ast_str_buffer(obuf));
        }
 
-       if (c->cdr && ast_cdr_serialize_variables(c->cdr, &obuf, '=', '\n', 1)) {
+       if (ast_channel_cdr(c) && ast_cdr_serialize_variables(ast_channel_cdr(c), &obuf, '=', '\n', 1)) {
                ast_str_append(&output, 0, "  CDR Variables:\n%s\n", ast_str_buffer(obuf));
        }
 
index ab5225bea3db31bf1862e72ad585444720a1b6b9..1002e3810772f14e0e2f4f12c72150aaa6755ad7 100644 (file)
@@ -274,7 +274,7 @@ enum ast_device_state ast_parse_device_state(const char *device)
                return AST_DEVICE_UNKNOWN;
        }
 
-       res = (chan->_state == AST_STATE_RINGING) ? AST_DEVICE_RINGING : AST_DEVICE_INUSE;
+       res = (ast_channel_state(chan) == AST_STATE_RINGING) ? AST_DEVICE_RINGING : AST_DEVICE_INUSE;
        
        chan = ast_channel_unref(chan);
 
index 528aa18bc80bb45224e343185feb0640b64bb724..3455ca329eadc0e676a4235a10d14895b9df92cc 100644 (file)
@@ -255,7 +255,7 @@ static int begin_dial_channel(struct ast_dial_channel *channel, struct ast_chann
        ast_copy_string(numsubst, channel->device, sizeof(numsubst));
 
        if (chan) {
-               cap_request = chan->nativeformats;
+               cap_request = ast_channel_nativeformats(chan);
        } else {
                cap_all_audio = ast_format_cap_alloc_nolock();
                ast_format_cap_add_all_by_type(cap_all_audio, AST_FORMAT_TYPE_AUDIO);
@@ -291,8 +291,8 @@ static int begin_dial_channel(struct ast_dial_channel *channel, struct ast_chann
                if (ast_strlen_zero(ast_channel_musicclass(channel->owner)))
                        ast_channel_musicclass_set(channel->owner, ast_channel_musicclass(chan));
 
-               channel->owner->adsicpe = chan->adsicpe;
-               channel->owner->transfercapability = chan->transfercapability;
+               ast_channel_adsicpe_set(channel->owner, ast_channel_adsicpe(chan));
+               ast_channel_transfercapability_set(channel->owner, ast_channel_transfercapability(chan));
        }
 
        /* Attempt to actually call this device */
index bf5282ca8a9ba18cab5ae80f34849050adc73b90..d3c98a4744c76bf5355bd2775637fe60b6830499 100644 (file)
@@ -672,18 +672,18 @@ static void set_kill_chan_tech(struct ast_channel *chan)
        ast_channel_lock(chan);
 
        /* Hangup the channel's physical side */
-       if (chan->tech->hangup) {
-               chan->tech->hangup(chan);
+       if (ast_channel_tech(chan)->hangup) {
+               ast_channel_tech(chan)->hangup(chan);
        }
-       if (chan->tech_pvt) {
+       if (ast_channel_tech_pvt(chan)) {
                ast_log(LOG_WARNING, "Channel '%s' may not have been hung up properly\n",
                        ast_channel_name(chan));
-               ast_free(chan->tech_pvt);
-               chan->tech_pvt = NULL;
+               ast_free(ast_channel_tech_pvt(chan));
+               ast_channel_tech_pvt_set(chan, NULL);
        }
 
        /* Install the kill technology and wake up anyone waiting on it. */
-       chan->tech = &ast_kill_tech;
+       ast_channel_tech_set(chan, &ast_kill_tech);
        for (idx = 0; idx < AST_MAX_FDS; ++idx) {
                switch (idx) {
                case AST_ALERT_FD:
@@ -839,7 +839,7 @@ static void set_c_e_p(struct ast_channel *chan, const char *context, const char
 {
        ast_channel_context_set(chan, context);
        ast_channel_exten_set(chan, ext);
-       chan->priority = pri;
+       ast_channel_priority_set(chan, pri);
 }
 
 /*!
@@ -890,7 +890,7 @@ static void check_goto_on_transfer(struct ast_channel *chan)
                }
        }
        ast_parseable_goto(xferchan, goto_on_transfer);
-       xferchan->_state = AST_STATE_UP;
+       ast_channel_state_set(xferchan, AST_STATE_UP);
        ast_clear_flag(xferchan, AST_FLAGS_ALL);        
        ast_channel_clear_softhangup(xferchan, AST_SOFTHANGUP_ALL);
 
@@ -1431,7 +1431,7 @@ static int park_call_full(struct ast_channel *chan, struct ast_channel *peer, st
                 * the same name we can be tricky and just grab the bridged
                 * channel from the other side of the local.
                 */
-               if (!strcasecmp(peer->tech->type, "Local")) {
+               if (!strcasecmp(ast_channel_tech(peer)->type, "Local")) {
                        struct ast_channel *tmpchan, *base_peer;
                        char other_side[AST_CHANNEL_NAME];
                        char *c;
@@ -1472,7 +1472,7 @@ static int park_call_full(struct ast_channel *chan, struct ast_channel *peer, st
                S_OR(args->return_ext, S_OR(ast_channel_macroexten(chan), ast_channel_exten(chan))), 
                sizeof(pu->exten));
        pu->priority = args->return_pri ? args->return_pri : 
-               (chan->macropriority ? chan->macropriority : chan->priority);
+               (ast_channel_macropriority(chan) ? ast_channel_macropriority(chan) : ast_channel_priority(chan));
 
        /*
         * If parking a channel directly, don't quite yet get parking
@@ -1636,7 +1636,7 @@ static int masq_park_call(struct ast_channel *rchan, struct ast_channel *peer, s
 
        /* Make a new, channel that we'll use to masquerade in the real one */
        chan = ast_channel_alloc(0, AST_STATE_DOWN, 0, 0, ast_channel_accountcode(rchan), ast_channel_exten(rchan),
-               ast_channel_context(rchan), ast_channel_linkedid(rchan), rchan->amaflags, "Parked/%s", ast_channel_name(rchan));
+               ast_channel_context(rchan), ast_channel_linkedid(rchan), ast_channel_amaflags(rchan), "Parked/%s", ast_channel_name(rchan));
        if (!chan) {
                ast_log(LOG_WARNING, "Unable to create parked channel\n");
                if (!ast_test_flag(args, AST_PARK_OPT_SILENCE)) {
@@ -1687,12 +1687,12 @@ static int masq_park_call(struct ast_channel *rchan, struct ast_channel *peer, s
        }
 
        /* Setup the extensions and such */
-       set_c_e_p(chan, ast_channel_context(rchan), ast_channel_exten(rchan), rchan->priority);
+       set_c_e_p(chan, ast_channel_context(rchan), ast_channel_exten(rchan), ast_channel_priority(rchan));
 
        /* Setup the macro extension and such */
        ast_channel_macrocontext_set(chan, ast_channel_macrocontext(rchan));
        ast_channel_macroexten_set(chan, ast_channel_macroexten(rchan));
-       chan->macropriority = rchan->macropriority;
+       ast_channel_macropriority_set(chan, ast_channel_macropriority(rchan));
 
        /* Manually do the masquerade to make sure it is complete. */
        ast_do_masquerade(chan);
@@ -1896,7 +1896,7 @@ static int builtin_parkcall(struct ast_channel *chan, struct ast_channel *peer,
         */
 
        /* Answer if call is not up */
-       if (chan->_state != AST_STATE_UP) {
+       if (ast_channel_state(chan) != AST_STATE_UP) {
                /*
                 * XXX Why are we doing this?  Both of the channels should be up
                 * since you cannot do DTMF features unless you are bridged.
@@ -2034,12 +2034,12 @@ static int builtin_automonitor(struct ast_channel *chan, struct ast_channel *pee
                }
        }
        
-       if (callee_chan->monitor) {
+       if (ast_channel_monitor(callee_chan)) {
                ast_verb(4, "User hit '%s' to stop recording call.\n", code);
                if (!ast_strlen_zero(automon_message_stop)) {
                        play_message_in_bridged_call(caller_chan, callee_chan, automon_message_stop);
                }
-               callee_chan->monitor->stop(callee_chan, 1);
+               ast_channel_monitor(callee_chan)->stop(callee_chan, 1);
                return AST_FEATURE_RETURN_SUCCESS;
        }
 
@@ -2312,32 +2312,32 @@ static int builtin_blindtransfer(struct ast_channel *chan, struct ast_channel *p
        pbx_builtin_setvar_helper(transferee, "BLINDTRANSFER", ast_channel_name(transferer));
        finishup(transferee);
        ast_channel_lock(transferer);
-       if (!transferer->cdr) { /* this code should never get called (in a perfect world) */
-               transferer->cdr = ast_cdr_alloc();
-               if (transferer->cdr) {
-                       ast_cdr_init(transferer->cdr, transferer); /* initialize our channel's cdr */
-                       ast_cdr_start(transferer->cdr);
+       if (!ast_channel_cdr(transferer)) { /* this code should never get called (in a perfect world) */
+               ast_channel_cdr_set(transferer, ast_cdr_alloc());
+               if (ast_channel_cdr(transferer)) {
+                       ast_cdr_init(ast_channel_cdr(transferer), transferer); /* initialize our channel's cdr */
+                       ast_cdr_start(ast_channel_cdr(transferer));
                }
        }
        ast_channel_unlock(transferer);
-       if (transferer->cdr) {
-               struct ast_cdr *swap = transferer->cdr;
+       if (ast_channel_cdr(transferer)) {
+               struct ast_cdr *swap = ast_channel_cdr(transferer);
 
                ast_debug(1,
                        "transferer=%s; transferee=%s; lastapp=%s; lastdata=%s; chan=%s; dstchan=%s\n",
-                       ast_channel_name(transferer), ast_channel_name(transferee), transferer->cdr->lastapp,
-                       transferer->cdr->lastdata, transferer->cdr->channel,
-                       transferer->cdr->dstchannel);
+                       ast_channel_name(transferer), ast_channel_name(transferee), ast_channel_cdr(transferer)->lastapp,
+                       ast_channel_cdr(transferer)->lastdata, ast_channel_cdr(transferer)->channel,
+                       ast_channel_cdr(transferer)->dstchannel);
                ast_debug(1, "TRANSFEREE; lastapp=%s; lastdata=%s, chan=%s; dstchan=%s\n",
-                       transferee->cdr->lastapp, transferee->cdr->lastdata, transferee->cdr->channel,
-                       transferee->cdr->dstchannel);
+                       ast_channel_cdr(transferee)->lastapp, ast_channel_cdr(transferee)->lastdata, ast_channel_cdr(transferee)->channel,
+                       ast_channel_cdr(transferee)->dstchannel);
                ast_debug(1, "transferer_real_context=%s; xferto=%s\n",
                        transferer_real_context, xferto);
                /* swap cdrs-- it will save us some time & work */
-               transferer->cdr = transferee->cdr;
-               transferee->cdr = swap;
+               ast_channel_cdr_set(transferer, ast_channel_cdr(transferee));
+               ast_channel_cdr_set(transferee, swap);
        }
-       if (!transferee->pbx) {
+       if (!ast_channel_pbx(transferee)) {
                /* Doh!  Use our handy async_goto functions */
                ast_debug(1, "About to ast_async_goto %s.\n", ast_channel_name(transferee));
                if (ast_async_goto(transferee, transferer_real_context, xferto, 1)) {
@@ -2532,7 +2532,7 @@ static int builtin_atxfer(struct ast_channel *chan, struct ast_channel *peer, st
 
        /* Dial party C */
        newchan = feature_request_and_dial(transferer, transferer_name_orig, transferer,
-               transferee, "Local", transferer->nativeformats, xferto,
+               transferee, "Local", ast_channel_nativeformats(transferer), xferto,
                atxfernoanswertimeout, &outstate, ast_channel_language(transferer));
        ast_debug(2, "Dial party C result: newchan:%d, outstate:%d\n", !!newchan, outstate);
 
@@ -2639,7 +2639,7 @@ static int builtin_atxfer(struct ast_channel *chan, struct ast_channel *peer, st
                                        transferer_tech, transferer_name);
                                newchan = feature_request_and_dial(transferer, transferer_name_orig,
                                        transferee, transferee, transferer_tech,
-                                       transferee->nativeformats, transferer_name,
+                                       ast_channel_nativeformats(transferee), transferer_name,
                                        atxfernoanswertimeout, &outstate, ast_channel_language(transferer));
                                ast_debug(2, "Dial party B result: newchan:%d, outstate:%d\n",
                                        !!newchan, outstate);
@@ -2668,7 +2668,7 @@ static int builtin_atxfer(struct ast_channel *chan, struct ast_channel *peer, st
                                ast_debug(1, "We're retrying to call %s/%s\n", "Local", xferto);
                                newchan = feature_request_and_dial(transferer, transferer_name_orig,
                                        transferer, transferee, "Local",
-                                       transferee->nativeformats, xferto,
+                                       ast_channel_nativeformats(transferee), xferto,
                                        atxfernoanswertimeout, &outstate, ast_channel_language(transferer));
                                ast_debug(2, "Redial party C result: newchan:%d, outstate:%d\n",
                                        !!newchan, outstate);
@@ -2718,21 +2718,21 @@ static int builtin_atxfer(struct ast_channel *chan, struct ast_channel *peer, st
        }
 
        /* Give party A a momentary ringback tone during transfer. */
-       xferchan->visible_indication = AST_CONTROL_RINGING;
+       ast_channel_visible_indication_set(xferchan, AST_CONTROL_RINGING);
 
        /* Make formats okay */
        xferchan->readformat = transferee->readformat;
        xferchan->writeformat = transferee->writeformat;
 
        ast_channel_masquerade(xferchan, transferee);
-       ast_explicit_goto(xferchan, ast_channel_context(transferee), ast_channel_exten(transferee), transferee->priority);
-       xferchan->_state = AST_STATE_UP;
+       ast_explicit_goto(xferchan, ast_channel_context(transferee), ast_channel_exten(transferee), ast_channel_priority(transferee));
+       ast_channel_state_set(xferchan, AST_STATE_UP);
        ast_clear_flag(xferchan, AST_FLAGS_ALL);
 
        /* Do the masquerade manually to make sure that is is completed. */
        ast_do_masquerade(xferchan);
 
-       newchan->_state = AST_STATE_UP;
+       ast_channel_state_set(newchan, AST_STATE_UP);
        ast_clear_flag(newchan, AST_FLAGS_ALL);
        tobj = ast_calloc(1, sizeof(*tobj));
        if (!tobj) {
@@ -3454,7 +3454,7 @@ static struct ast_channel *feature_request_and_dial(struct ast_channel *caller,
 
        if (ast_call(chan, addr, timeout)) {
                ast_log(LOG_NOTICE, "Unable to call channel %s/%s\n", type, addr);
-               switch (chan->hangupcause) {
+               switch (ast_channel_hangupcause(chan)) {
                case AST_CAUSE_BUSY:
                        state = AST_CONTROL_BUSY;
                        break;
@@ -3489,7 +3489,7 @@ static struct ast_channel *feature_request_and_dial(struct ast_channel *caller,
        ast_poll_channel_add(caller, chan);
 
        transferee_hungup = 0;
-       while (!ast_check_hangup(transferee) && (chan->_state != AST_STATE_UP)) {
+       while (!ast_check_hangup(transferee) && (ast_channel_state(chan) != AST_STATE_UP)) {
                int num_chans = 0;
 
                monitor_chans[num_chans++] = transferee;
@@ -3557,7 +3557,7 @@ static struct ast_channel *feature_request_and_dial(struct ast_channel *caller,
                        }
                        f = ast_read(chan);
                        if (f == NULL) { /*doh! where'd he go?*/
-                               switch (chan->hangupcause) {
+                               switch (ast_channel_hangupcause(chan)) {
                                case AST_CAUSE_BUSY:
                                        state = AST_CONTROL_BUSY;
                                        break;
@@ -3678,7 +3678,7 @@ static struct ast_channel *feature_request_and_dial(struct ast_channel *caller,
 
 done:
        ast_indicate(caller, -1);
-       if (chan && (ready || chan->_state == AST_STATE_UP)) {
+       if (chan && (ready || ast_channel_state(chan) == AST_STATE_UP)) {
                state = AST_CONTROL_ANSWER;
        } else if (chan) {
                ast_hangup(chan);
@@ -3699,15 +3699,15 @@ void ast_channel_log(char *title, struct ast_channel *chan) /* for debug, this i
 {
        ast_log(LOG_NOTICE, "______ %s (%lx)______\n", title, (unsigned long) chan);
        ast_log(LOG_NOTICE, "CHAN: name: %s;  appl: %s; data: %s; contxt: %s;  exten: %s; pri: %d;\n",
-               ast_channel_name(chan), ast_channel_appl(chan), ast_channel_data(chan), ast_channel_context(chan), ast_channel_exten(chan), chan->priority);
+               ast_channel_name(chan), ast_channel_appl(chan), ast_channel_data(chan), ast_channel_context(chan), ast_channel_exten(chan), ast_channel_priority(chan));
        ast_log(LOG_NOTICE, "CHAN: acctcode: %s;  dialcontext: %s; amaflags: %x; maccontxt: %s;  macexten: %s; macpri: %d;\n",
-               ast_channel_accountcode(chan), ast_channel_dialcontext(chan), chan->amaflags, ast_channel_macrocontext(chan), ast_channel_macroexten(chan), chan->macropriority);
+               ast_channel_accountcode(chan), ast_channel_dialcontext(chan), ast_channel_amaflags(chan), ast_channel_macrocontext(chan), ast_channel_macroexten(chan), ast_channel_macropriority(chan));
        ast_log(LOG_NOTICE, "CHAN: masq: %p;  masqr: %p; _bridge: %p; uniqueID: %s; linkedID:%s\n",
-               chan->masq, chan->masqr,
+               ast_channel_masq(chan), ast_channel_masqr(chan),
                chan->_bridge, ast_channel_uniqueid(chan), ast_channel_linkedid(chan));
-       if (chan->masqr) {
+       if (ast_channel_masqr(chan)) {
                ast_log(LOG_NOTICE, "CHAN: masquerading as: %s;  cdr: %p;\n",
-                       ast_channel_name(chan->masqr), chan->masqr->cdr);
+                       ast_channel_name(ast_channel_masqr(chan)), ast_channel_cdr(ast_channel_masqr(chan)));
        }
        if (chan->_bridge) {
                ast_log(LOG_NOTICE, "CHAN: Bridged to %s\n", ast_channel_name(chan->_bridge));
@@ -3867,8 +3867,8 @@ int ast_bridge_call(struct ast_channel *chan, struct ast_channel *peer, struct a
        int we_disabled_peer_cdr = 0;
        struct ast_option_header *aoh;
        struct ast_cdr *bridge_cdr = NULL;
-       struct ast_cdr *chan_cdr = chan->cdr; /* the proper chan cdr, if there are forked cdrs */
-       struct ast_cdr *peer_cdr = peer->cdr; /* the proper chan cdr, if there are forked cdrs */
+       struct ast_cdr *chan_cdr = ast_channel_cdr(chan); /* the proper chan cdr, if there are forked cdrs */
+       struct ast_cdr *peer_cdr = ast_channel_cdr(peer); /* the proper chan cdr, if there are forked cdrs */
        struct ast_cdr *new_chan_cdr = NULL; /* the proper chan cdr, if there are forked cdrs */
        struct ast_cdr *new_peer_cdr = NULL; /* the proper chan cdr, if there are forked cdrs */
        struct ast_silence_generator *silgen = NULL;
@@ -3883,7 +3883,7 @@ int ast_bridge_call(struct ast_channel *chan, struct ast_channel *peer, struct a
        /* This is an interesting case.  One example is if a ringing channel gets redirected to
         * an extension that picks up a parked call.  This will make sure that the call taken
         * out of parking gets told that the channel it just got bridged to is still ringing. */
-       if (chan->_state == AST_STATE_RINGING && peer->visible_indication != AST_CONTROL_RINGING) {
+       if (ast_channel_state(chan) == AST_STATE_RINGING && ast_channel_visible_indication(peer) != AST_CONTROL_RINGING) {
                ast_indicate(peer, AST_CONTROL_RINGING);
        }
 
@@ -3907,7 +3907,7 @@ int ast_bridge_call(struct ast_channel *chan, struct ast_channel *peer, struct a
        set_config_flags(chan, config);
 
        /* Answer if need be */
-       if (chan->_state != AST_STATE_UP) {
+       if (ast_channel_state(chan) != AST_STATE_UP) {
                if (ast_raw_answer(chan, 1)) {
                        return -1;
                }
@@ -3922,19 +3922,19 @@ int ast_bridge_call(struct ast_channel *chan, struct ast_channel *peer, struct a
        ast_channel_set_linkgroup(chan,peer);
 
        /* copy the userfield from the B-leg to A-leg if applicable */
-       if (chan->cdr && peer->cdr && !ast_strlen_zero(peer->cdr->userfield)) {
+       if (ast_channel_cdr(chan) && ast_channel_cdr(peer) && !ast_strlen_zero(ast_channel_cdr(peer)->userfield)) {
                char tmp[256];
 
                ast_channel_lock(chan);
-               if (!ast_strlen_zero(chan->cdr->userfield)) {
-                       snprintf(tmp, sizeof(tmp), "%s;%s", chan->cdr->userfield, peer->cdr->userfield);
+               if (!ast_strlen_zero(ast_channel_cdr(chan)->userfield)) {
+                       snprintf(tmp, sizeof(tmp), "%s;%s", ast_channel_cdr(chan)->userfield, ast_channel_cdr(peer)->userfield);
                        ast_cdr_appenduserfield(chan, tmp);
                } else {
-                       ast_cdr_setuserfield(chan, peer->cdr->userfield);
+                       ast_cdr_setuserfield(chan, ast_channel_cdr(peer)->userfield);
                }
                ast_channel_unlock(chan);
                /* Don't delete the CDR; just disable it. */
-               ast_set_flag(peer->cdr, AST_CDR_FLAG_POST_DISABLED);
+               ast_set_flag(ast_channel_cdr(peer), AST_CDR_FLAG_POST_DISABLED);
                we_disabled_peer_cdr = 1;
        }
        ast_copy_string(orig_channame,ast_channel_name(chan),sizeof(orig_channame));
@@ -3965,8 +3965,8 @@ int ast_bridge_call(struct ast_channel *chan, struct ast_channel *peer, struct a
                        ast_copy_string(bridge_cdr->lastapp, S_OR(ast_channel_appl(chan), ""), sizeof(bridge_cdr->lastapp));
                        ast_copy_string(bridge_cdr->lastdata, S_OR(ast_channel_data(chan), ""), sizeof(bridge_cdr->lastdata));
                        ast_cdr_setcid(bridge_cdr, chan);
-                       bridge_cdr->disposition = (chan->_state == AST_STATE_UP) ?  AST_CDR_ANSWERED : AST_CDR_NULL;
-                       bridge_cdr->amaflags = chan->amaflags ? chan->amaflags :  ast_default_amaflags;
+                       bridge_cdr->disposition = (ast_channel_state(chan) == AST_STATE_UP) ?  AST_CDR_ANSWERED : AST_CDR_NULL;
+                       bridge_cdr->amaflags = ast_channel_amaflags(chan) ? ast_channel_amaflags(chan) :  ast_default_amaflags;
                        ast_copy_string(bridge_cdr->accountcode, ast_channel_accountcode(chan), sizeof(bridge_cdr->accountcode));
                        /* Destination information */
                        ast_copy_string(bridge_cdr->dst, ast_channel_exten(chan), sizeof(bridge_cdr->dst));
@@ -4341,41 +4341,41 @@ before_you_go:
                   dialplan code operate on it */
                ast_channel_lock(chan);
                if (bridge_cdr) {
-                       swapper = chan->cdr;
+                       swapper = ast_channel_cdr(chan);
                        ast_copy_string(savelastapp, bridge_cdr->lastapp, sizeof(bridge_cdr->lastapp));
                        ast_copy_string(savelastdata, bridge_cdr->lastdata, sizeof(bridge_cdr->lastdata));
-                       chan->cdr = bridge_cdr;
+                       ast_channel_cdr_set(chan, bridge_cdr);
                }
                ast_copy_string(save_context, ast_channel_context(chan), sizeof(save_context));
                ast_copy_string(save_exten, ast_channel_exten(chan), sizeof(save_exten));
-               save_prio = chan->priority;
+               save_prio = ast_channel_priority(chan);
                if (h_context != ast_channel_context(chan)) {
                        ast_channel_context_set(chan, h_context);
                }
                ast_channel_exten_set(chan, "h");
-               chan->priority = 1;
+               ast_channel_priority_set(chan, 1);
                ast_channel_unlock(chan);
 
                while ((spawn_error = ast_spawn_extension(chan, 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, NULL),
                        &found, 1)) == 0) {
-                       chan->priority++;
+                       ast_channel_priority_set(chan, ast_channel_priority(chan) + 1);
                }
                if (found && spawn_error) {
                        /* 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(chan), ast_channel_exten(chan), chan->priority, ast_channel_name(chan));
-                       ast_verb(2, "Spawn extension (%s, %s, %d) exited non-zero on '%s'\n", ast_channel_context(chan), ast_channel_exten(chan), chan->priority, ast_channel_name(chan));
+                       ast_debug(1, "Spawn extension (%s,%s,%d) exited non-zero on '%s'\n", ast_channel_context(chan), ast_channel_exten(chan), ast_channel_priority(chan), ast_channel_name(chan));
+                       ast_verb(2, "Spawn extension (%s, %s, %d) exited non-zero on '%s'\n", ast_channel_context(chan), ast_channel_exten(chan), ast_channel_priority(chan), ast_channel_name(chan));
                }
 
                /* swap it back */
                ast_channel_lock(chan);
                ast_channel_context_set(chan, save_context);
                ast_channel_exten_set(chan, save_exten);
-               chan->priority = save_prio;
+               ast_channel_priority_set(chan, save_prio);
                if (bridge_cdr) {
-                       if (chan->cdr == bridge_cdr) {
-                               chan->cdr = swapper;
+                       if (ast_channel_cdr(chan) == bridge_cdr) {
+                               ast_channel_cdr_set(chan, swapper);
                        } else {
                                bridge_cdr = NULL;
                        }
@@ -4393,7 +4393,7 @@ before_you_go:
        }
        
        /* obey the NoCDR() wishes. -- move the DISABLED flag to the bridge CDR if it was set on the channel during the bridge... */
-       new_chan_cdr = pick_unlocked_cdr(chan->cdr); /* the proper chan cdr, if there are forked cdrs */
+       new_chan_cdr = pick_unlocked_cdr(ast_channel_cdr(chan)); /* the proper chan cdr, if there are forked cdrs */
        if (bridge_cdr && new_chan_cdr && ast_test_flag(new_chan_cdr, AST_CDR_FLAG_POST_DISABLED))
                ast_set_flag(bridge_cdr, AST_CDR_FLAG_POST_DISABLED);
 
@@ -4436,7 +4436,7 @@ before_you_go:
                                ast_channel_lock(chan_ptr);
                                if (!ast_bridged_channel(chan_ptr)) {
                                        struct ast_cdr *cur;
-                                       for (cur = chan_ptr->cdr; cur; cur = cur->next) {
+                                       for (cur = ast_channel_cdr(chan_ptr); cur; cur = cur->next) {
                                                if (cur == chan_cdr) {
                                                        break;
                                                }
@@ -4451,13 +4451,13 @@ before_you_go:
                        /* new channel */
                        ast_cdr_specialized_reset(new_chan_cdr, 0);
                } else {
-                       ast_cdr_specialized_reset(chan->cdr, 0); /* nothing changed, reset the chan cdr  */
+                       ast_cdr_specialized_reset(ast_channel_cdr(chan), 0); /* nothing changed, reset the chan cdr  */
                }
        }
 
        {
                struct ast_channel *chan_ptr = NULL;
-               new_peer_cdr = pick_unlocked_cdr(peer->cdr); /* the proper chan cdr, if there are forked cdrs */
+               new_peer_cdr = pick_unlocked_cdr(ast_channel_cdr(peer)); /* the proper chan cdr, if there are forked cdrs */
                if (new_chan_cdr && ast_test_flag(new_chan_cdr, AST_CDR_FLAG_POST_DISABLED) && new_peer_cdr && !ast_test_flag(new_peer_cdr, AST_CDR_FLAG_POST_DISABLED))
                        ast_set_flag(new_peer_cdr, AST_CDR_FLAG_POST_DISABLED); /* DISABLED is viral-- it will propagate across a bridge */
                if (strcasecmp(orig_peername, ast_channel_name(peer)) != 0) { 
@@ -4466,7 +4466,7 @@ before_you_go:
                                ast_channel_lock(chan_ptr);
                                if (!ast_bridged_channel(chan_ptr)) {
                                        struct ast_cdr *cur;
-                                       for (cur = chan_ptr->cdr; cur; cur = cur->next) {
+                                       for (cur = ast_channel_cdr(chan_ptr); cur; cur = cur->next) {
                                                if (cur == peer_cdr) {
                                                        break;
                                                }
@@ -4484,9 +4484,9 @@ before_you_go:
                        }
                } else {
                        if (we_disabled_peer_cdr) {
-                               ast_clear_flag(peer->cdr, AST_CDR_FLAG_POST_DISABLED);
+                               ast_clear_flag(ast_channel_cdr(peer), AST_CDR_FLAG_POST_DISABLED);
                        }
-                       ast_cdr_specialized_reset(peer->cdr, 0); /* nothing changed, reset the peer cdr  */
+                       ast_cdr_specialized_reset(ast_channel_cdr(peer), 0); /* nothing changed, reset the peer cdr  */
                }
        }
        
@@ -4687,7 +4687,7 @@ static int manage_parked_call(struct parkeduser *pu, const struct pollfd *pfds,
 
                ast_verb(2, "Timeout for %s parked on %d (%s). Returning to %s,%s,%d\n",
                        ast_channel_name(pu->chan), pu->parkingnum, pu->parkinglot->name, ast_channel_context(pu->chan),
-                       ast_channel_exten(pu->chan), pu->chan->priority);
+                       ast_channel_exten(pu->chan), ast_channel_priority(pu->chan));
 
                /* Start up the PBX, or hang them up */
                if (ast_pbx_start(chan))  {
@@ -4729,7 +4729,7 @@ static int manage_parked_call(struct parkeduser *pu, const struct pollfd *pfds,
                        } else {
                                ast_clear_flag(chan, AST_FLAG_EXCEPTION);
                        }
-                       chan->fdno = x;
+                       ast_channel_fdno_set(chan, x);
 
                        /* See if they need servicing */
                        f = ast_read(pu->chan);
@@ -4755,7 +4755,7 @@ static int manage_parked_call(struct parkeduser *pu, const struct pollfd *pfds,
                                ast_frfree(f);
                                if (pu->hold_method == AST_CONTROL_HOLD
                                        && pu->moh_trys < 3
-                                       && !chan->generatordata) {
+                                       && !ast_channel_generatordata(chan)) {
                                        ast_debug(1,
                                                "MOH on parked call stopped by outside source.  Restarting on channel %s.\n",
                                                ast_channel_name(chan));
@@ -4936,7 +4936,7 @@ static int park_call_exec(struct ast_channel *chan, const char *data)
        struct park_app_args app_args;
 
        /* Answer if call is not up */
-       if (chan->_state != AST_STATE_UP) {
+       if (ast_channel_state(chan) != AST_STATE_UP) {
                if (ast_answer(chan)) {
                        return -1;
                }
@@ -4978,9 +4978,9 @@ static int park_call_exec(struct ast_channel *chan, const char *data)
         * this call should return.
         */
        ast_copy_string(orig_exten, ast_channel_exten(chan), sizeof(orig_exten));
-       orig_priority = chan->priority;
+       orig_priority = ast_channel_priority(chan);
        ast_channel_exten_set(chan, "s");
-       chan->priority = 1;
+       ast_channel_priority_set(chan, 1);
 
        /* Park the call */
        if (!ast_strlen_zero(app_args.pl_name)) {
@@ -5010,7 +5010,7 @@ static int park_call_exec(struct ast_channel *chan, const char *data)
        if (res) {
                /* Park failed, try to continue in the dialplan. */
                ast_channel_exten_set(chan, orig_exten);
-               chan->priority = orig_priority;
+               ast_channel_priority_set(chan, orig_priority);
                res = 0;
        } else {
                /* Park succeeded. */
@@ -5061,7 +5061,7 @@ static int parked_call_exec(struct ast_channel *chan, const char *data)
                parkinglot = find_parkinglot(pl_name);
                if (!parkinglot) {
                        /* It helps to answer the channel if not already up. :) */
-                       if (chan->_state != AST_STATE_UP) {
+                       if (ast_channel_state(chan) != AST_STATE_UP) {
                                ast_answer(chan);
                        }
                        if (ast_stream_and_wait(chan, "pbx-invalidpark", "")) {
@@ -5078,7 +5078,7 @@ static int parked_call_exec(struct ast_channel *chan, const char *data)
        AST_LIST_LOCK(&parkinglot->parkings);
        AST_LIST_TRAVERSE_SAFE_BEGIN(&parkinglot->parkings, pu, list) {
                if ((ast_strlen_zero(app_args.pl_space) || pu->parkingnum == park)
-                       && !pu->notquiteyet && !pu->chan->pbx) {
+                       && !pu->notquiteyet && !ast_channel_pbx(pu->chan)) {
                        /* The parking space has a call and can be picked up now. */
                        AST_LIST_REMOVE_CURRENT(list);
                        break;
@@ -5171,7 +5171,7 @@ static int parked_call_exec(struct ast_channel *chan, const char *data)
        }
 
        /* JK02: it helps to answer the channel if not already up */
-       if (chan->_state != AST_STATE_UP) {
+       if (ast_channel_state(chan) != AST_STATE_UP) {
                ast_answer(chan);
        }
 
@@ -5216,7 +5216,7 @@ static int parked_call_exec(struct ast_channel *chan, const char *data)
                ast_verb(3, "Channel %s connected to parked call %d\n", ast_channel_name(chan), park);
 
                pbx_builtin_setvar_helper(chan, "PARKEDCHANNEL", ast_channel_name(peer));
-               ast_cdr_setdestchan(chan->cdr, ast_channel_name(peer));
+               ast_cdr_setdestchan(ast_channel_cdr(chan), ast_channel_name(peer));
                memset(&config, 0, sizeof(struct ast_bridge_config));
 
                /* Get datastore for peer and apply it's features to the callee side of the bridge config */
@@ -5266,7 +5266,7 @@ static int parked_call_exec(struct ast_channel *chan, const char *data)
                res = ast_bridge_call(chan, peer, &config);
 
                pbx_builtin_setvar_helper(chan, "PARKEDCHANNEL", ast_channel_name(peer));
-               ast_cdr_setdestchan(chan->cdr, ast_channel_name(peer));
+               ast_cdr_setdestchan(ast_channel_cdr(chan), ast_channel_name(peer));
 
                /* Simulate the PBX hanging up */
                ast_hangup(peer);
@@ -6811,7 +6811,7 @@ static void do_bridge_masquerade(struct ast_channel *chan, struct ast_channel *t
 {
        ast_moh_stop(chan);
        ast_channel_lock_both(chan, tmpchan);
-       ast_setstate(tmpchan, chan->_state);
+       ast_setstate(tmpchan, ast_channel_state(chan));
        tmpchan->readformat = chan->readformat;
        tmpchan->writeformat = chan->writeformat;
        ast_channel_unlock(chan);
@@ -6823,7 +6823,7 @@ static void do_bridge_masquerade(struct ast_channel *chan, struct ast_channel *t
        ast_do_masquerade(tmpchan);
 
        /* when returning from bridge, the channel will continue at the next priority */
-       ast_explicit_goto(tmpchan, ast_channel_context(chan), ast_channel_exten(chan), chan->priority + 1);
+       ast_explicit_goto(tmpchan, ast_channel_context(chan), ast_channel_exten(chan), ast_channel_priority(chan) + 1);
 }
 
 /*!
@@ -6867,7 +6867,7 @@ static int action_bridge(struct mansession *s, const struct message *m)
        }
 
        /* Answer the channels if needed */
-       if (chana->_state != AST_STATE_UP)
+       if (ast_channel_state(chana) != AST_STATE_UP)
                ast_answer(chana);
 
        /* create the placeholder channels and grab the other channels */
@@ -6894,7 +6894,7 @@ static int action_bridge(struct mansession *s, const struct message *m)
        }
 
        /* Answer the channels if needed */
-       if (chanb->_state != AST_STATE_UP)
+       if (ast_channel_state(chanb) != AST_STATE_UP)
                ast_answer(chanb);
 
        /* create the placeholder channels and grab the other channels */
@@ -7196,16 +7196,16 @@ static const struct ast_datastore_info pickup_active = {
 
 int ast_can_pickup(struct ast_channel *chan)
 {
-       if (!chan->pbx && !chan->masq && !ast_test_flag(chan, AST_FLAG_ZOMBIE)
-               && (chan->_state == AST_STATE_RINGING
-                       || chan->_state == AST_STATE_RING
+       if (!ast_channel_pbx(chan) && !ast_channel_masq(chan) && !ast_test_flag(chan, AST_FLAG_ZOMBIE)
+               && (ast_channel_state(chan) == AST_STATE_RINGING
+                       || ast_channel_state(chan) == AST_STATE_RING
                        /*
                         * Check the down state as well because some SIP devices do not
                         * give 180 ringing when they can just give 183 session progress
                         * instead.  Issue 14005.  (Some ISDN switches as well for that
                         * matter.)
                         */
-                       || chan->_state == AST_STATE_DOWN)
+                       || ast_channel_state(chan) == AST_STATE_DOWN)
                && !ast_channel_datastore_find(chan, &pickup_active, NULL)) {
                return 1;
        }
@@ -7557,7 +7557,7 @@ static int bridge_exec(struct ast_channel *chan, const char *data)
        }
 
        /* answer the channel if needed */
-       if (current_dest_chan->_state != AST_STATE_UP) {
+       if (ast_channel_state(current_dest_chan) != AST_STATE_UP) {
                ast_answer(current_dest_chan);
        }
 
@@ -7637,7 +7637,7 @@ static int bridge_exec(struct ast_channel *chan, const char *data)
        if (!ast_check_hangup(final_dest_chan) && !ast_test_flag(&opts, OPT_CALLEE_KILL)) {
                ast_debug(1, "starting new PBX in %s,%s,%d for chan %s\n",
                        ast_channel_context(final_dest_chan), ast_channel_exten(final_dest_chan),
-                       final_dest_chan->priority, ast_channel_name(final_dest_chan));
+                       ast_channel_priority(final_dest_chan), ast_channel_name(final_dest_chan));
 
                if (ast_pbx_start(final_dest_chan) != AST_PBX_SUCCESS) {
                        ast_log(LOG_WARNING, "FAILED continuing PBX on dest chan %s\n", ast_channel_name(final_dest_chan));
@@ -7919,14 +7919,14 @@ static struct ast_channel *create_test_channel(const struct ast_channel_tech *fa
        }
 
        /* normally this is done in the channel driver */
-       ast_format_cap_add(test_channel1->nativeformats, ast_format_set(&tmp_fmt, AST_FORMAT_GSM, 0));
+       ast_format_cap_add(ast_channel_nativeformats(test_channel1), ast_format_set(&tmp_fmt, AST_FORMAT_GSM, 0));
 
        ast_format_set(&test_channel1->writeformat, AST_FORMAT_GSM, 0);
        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);
 
        return test_channel1;
 }
index 3befcaedfdc2c3ed6a9a3991be78a35d9dbd7be9..5341e8f18c3f5d14cc9e78404f769b2d3761ff29 100644 (file)
@@ -128,16 +128,16 @@ int ast_stopstream(struct ast_channel *tmp)
        ast_channel_lock(tmp);
 
        /* Stop a running stream if there is one */
-       if (tmp->stream) {
-               ast_closestream(tmp->stream);
-               tmp->stream = NULL;
+       if (ast_channel_stream(tmp)) {
+               ast_closestream(ast_channel_stream(tmp));
+               ast_channel_stream_set(tmp, NULL);
                if (tmp->oldwriteformat.id && ast_set_write_format(tmp, &tmp->oldwriteformat))
                        ast_log(LOG_WARNING, "Unable to restore format back to %s\n", ast_getformatname(&tmp->oldwriteformat));
        }
        /* Stop the video stream too */
-       if (tmp->vstream != NULL) {
-               ast_closestream(tmp->vstream);
-               tmp->vstream = NULL;
+       if (ast_channel_vstream(tmp) != NULL) {
+               ast_closestream(ast_channel_vstream(tmp));
+               ast_channel_vstream_set(tmp, NULL);
        }
 
        ast_channel_unlock(tmp);
@@ -300,13 +300,13 @@ static void filestream_close(struct ast_filestream *f)
        switch (format_type)
        {
        case AST_FORMAT_TYPE_AUDIO:
-               f->owner->stream = NULL;
-               AST_SCHED_DEL(f->owner->sched, f->owner->streamid);
+               ast_channel_stream_set(f->owner, NULL);
+               AST_SCHED_DEL_ACCESSOR(ast_channel_sched(f->owner), f->owner, ast_channel_streamid, ast_channel_streamid_set);
                ast_settimeout(f->owner, 0, NULL, NULL);
                break;
        case AST_FORMAT_TYPE_VIDEO:
-               f->owner->vstream = NULL;
-               AST_SCHED_DEL(f->owner->sched, f->owner->vstreamid);
+               ast_channel_vstream_set(f->owner, NULL);
+               AST_SCHED_DEL_ACCESSOR(ast_channel_sched(f->owner), f->owner, ast_channel_vstreamid, ast_channel_vstreamid_set);
                break;
        default:
                ast_log(AST_LOG_WARNING, "Unable to schedule deletion of filestream with unsupported type %s\n", f->fmt->name);
@@ -498,13 +498,13 @@ static int filehelper(const char *filename, const void *arg2, const char *fmt, c
                                s->trans = NULL;
                                s->filename = NULL;
                                if (AST_FORMAT_GET_TYPE(s->fmt->format.id) == AST_FORMAT_TYPE_AUDIO) {
-                                       if (chan->stream)
-                                               ast_closestream(chan->stream);
-                                       chan->stream = s;
+                                       if (ast_channel_stream(chan))
+                                               ast_closestream(ast_channel_stream(chan));
+                                       ast_channel_stream_set(chan, s);
                                } else {
-                                       if (chan->vstream)
-                                               ast_closestream(chan->vstream);
-                                       chan->vstream = s;
+                                       if (ast_channel_vstream(chan))
+                                               ast_closestream(ast_channel_vstream(chan));
+                                       ast_channel_vstream_set(chan, s);
                                }
                                ast_free(fn);
                                break;
@@ -679,7 +679,7 @@ struct ast_filestream *ast_openstream_full(struct ast_channel *chan, const char
        if (!asis) {
                /* do this first, otherwise we detect the wrong writeformat */
                ast_stopstream(chan);
-               if (chan->generator)
+               if (ast_channel_generator(chan))
                        ast_deactivate_generator(chan);
        }
        if (preflang == NULL)
@@ -712,7 +712,7 @@ struct ast_filestream *ast_openstream_full(struct ast_channel *chan, const char
        }
        res = filehelper(buf, chan, NULL, ACTION_OPEN);
        if (res >= 0)
-               return chan->stream;
+               return ast_channel_stream(chan);
        return NULL;
 }
 
@@ -736,7 +736,7 @@ struct ast_filestream *ast_openvstream(struct ast_channel *chan, const char *fil
                return NULL;
 
        /* is the channel capable of video without translation ?*/
-       if (!ast_format_cap_has_type(chan->nativeformats, AST_FORMAT_TYPE_VIDEO)) {
+       if (!ast_format_cap_has_type(ast_channel_nativeformats(chan), AST_FORMAT_TYPE_VIDEO)) {
                return NULL;
        }
        if (!(tmp_cap = ast_format_cap_alloc_nolock())) {
@@ -753,7 +753,7 @@ struct ast_filestream *ast_openvstream(struct ast_channel *chan, const char *fil
        while (!ast_format_cap_iter_next(tmp_cap, &tmp_fmt)) {
                fmt = ast_getformatname(&tmp_fmt);
                if ((AST_FORMAT_GET_TYPE(tmp_fmt.id) != AST_FORMAT_TYPE_VIDEO) ||
-                       !ast_format_cap_iscompatible(chan->nativeformats, &tmp_fmt)) {
+                       !ast_format_cap_iscompatible(ast_channel_nativeformats(chan), &tmp_fmt)) {
                        continue;
                }
 
@@ -761,7 +761,7 @@ struct ast_filestream *ast_openvstream(struct ast_channel *chan, const char *fil
                if (fd >= 0) {
                        ast_format_cap_iter_end(tmp_cap);
                        tmp_cap = ast_format_cap_destroy(tmp_cap);
-                       return chan->vstream;
+                       return ast_channel_vstream(chan);
                }
                ast_log(LOG_WARNING, "File %s has video but couldn't be opened\n", filename);
        }
@@ -838,7 +838,7 @@ static enum fsread_res ast_readaudio_callback(struct ast_filestream *s)
        }
 
        if (whennext != s->lasttimeout) {
-               if (s->owner->timingfd > -1) {
+               if (ast_channel_timingfd(s->owner) > -1) {
                        float samp_rate = (float) ast_format_rate(&s->fmt->format);
                        unsigned int rate;
 
@@ -846,8 +846,7 @@ static enum fsread_res ast_readaudio_callback(struct ast_filestream *s)
 
                        ast_settimeout(s->owner, rate, ast_fsread_audio, s);
                } else {
-                       s->owner->streamid = ast_sched_add(s->owner->sched, 
-                               whennext / (ast_format_rate(&s->fmt->format) / 1000), ast_fsread_audio, s);
+                       ast_channel_streamid_set(s->owner, ast_sched_add(ast_channel_sched(s->owner), whennext / (ast_format_rate(&s->fmt->format) / 1000), ast_fsread_audio, s));
                }
                s->lasttimeout = whennext;
                return FSREAD_SUCCESS_NOSCHED;
@@ -855,7 +854,7 @@ static enum fsread_res ast_readaudio_callback(struct ast_filestream *s)
        return FSREAD_SUCCESS_SCHED;
 
 return_failure:
-       s->owner->streamid = -1;
+       ast_channel_streamid_set(s->owner, -1);
        ast_settimeout(s->owner, 0, NULL, NULL);
        return FSREAD_FAILURE;
 }
@@ -887,7 +886,7 @@ static enum fsread_res ast_readvideo_callback(struct ast_filestream *s)
                                ast_log(LOG_WARNING, "Failed to write frame\n");
                                ast_frfree(fr);
                        }
-                       s->owner->vstreamid = -1;
+                       ast_channel_vstreamid_set(s->owner, -1);
                        return FSREAD_FAILURE;
                }
 
@@ -897,9 +896,7 @@ static enum fsread_res ast_readvideo_callback(struct ast_filestream *s)
        }
 
        if (whennext != s->lasttimeout) {
-               s->owner->vstreamid = ast_sched_add(s->owner->sched, 
-                       whennext / (ast_format_rate(&s->fmt->format) / 1000), 
-                       ast_fsread_video, s);
+               ast_channel_vstreamid_set(s->owner, ast_sched_add(ast_channel_sched(s->owner), whennext / (ast_format_rate(&s->fmt->format) / 1000), ast_fsread_video, s));
                s->lasttimeout = whennext;
                return FSREAD_SUCCESS_NOSCHED;
        }
@@ -1018,7 +1015,7 @@ int ast_streamfile(struct ast_channel *chan, const char *filename, const char *p
 
        fs = ast_openstream(chan, filename, preflang);
        if (!fs) {
-               ast_log(LOG_WARNING, "Unable to open %s (format %s): %s\n", filename, ast_getformatname_multiple(fmt, sizeof(fmt), chan->nativeformats), strerror(errno));
+               ast_log(LOG_WARNING, "Unable to open %s (format %s): %s\n", filename, ast_getformatname_multiple(fmt, sizeof(fmt), ast_channel_nativeformats(chan)), strerror(errno));
                return -1;
        }
 
@@ -1260,7 +1257,7 @@ static int waitstream_core(struct ast_channel *c, const char *breakon,
        if (ast_test_flag(c, AST_FLAG_MASQ_NOSTREAM))
                orig_chan_name = ast_strdupa(ast_channel_name(c));
 
-       while (c->stream) {
+       while (ast_channel_stream(c)) {
                int res;
                int ms;
 
@@ -1270,7 +1267,7 @@ static int waitstream_core(struct ast_channel *c, const char *breakon,
                        break;
                }
 
-               ms = ast_sched_wait(c->sched);
+               ms = ast_sched_wait(ast_channel_sched(c));
 
                if (ms < 0 && !c->timingfunc) {
                        ast_stopstream(c);
@@ -1324,15 +1321,15 @@ static int waitstream_core(struct ast_channel *c, const char *breakon,
                                        res = fr->subclass.integer;
                                        if (strchr(forward, res)) {
                                                int eoftest;
-                                               ast_stream_fastforward(c->stream, skip_ms);
-                                               eoftest = fgetc(c->stream->f);
-                                               if (feof(c->stream->f)) {
-                                                       ast_stream_rewind(c->stream, skip_ms);
+                                               ast_stream_fastforward(ast_channel_stream(c), skip_ms);
+                                               eoftest = fgetc(ast_channel_stream(c)->f);
+                                               if (feof(ast_channel_stream(c)->f)) {
+                                                       ast_stream_rewind(ast_channel_stream(c), skip_ms);
                                                } else {
-                                                       ungetc(eoftest, c->stream->f);
+                                                       ungetc(eoftest, ast_channel_stream(c)->f);
                                                }
                                        } else if (strchr(reverse, res)) {
-                                               ast_stream_rewind(c->stream, skip_ms);
+                                               ast_stream_rewind(ast_channel_stream(c), skip_ms);
                                        } else if (strchr(breakon, res)) {
                                                ast_frfree(fr);
                                                ast_clear_flag(c, AST_FLAG_END_DTMF_ONLY);
@@ -1379,7 +1376,7 @@ static int waitstream_core(struct ast_channel *c, const char *breakon,
                        }
                        ast_frfree(fr);
                }
-               ast_sched_runq(c->sched);
+               ast_sched_runq(ast_channel_sched(c));
        }
 
        ast_clear_flag(c, AST_FLAG_END_DTMF_ONLY);
index 2d5fd5a472046d29f3d3be280bf97a2ad6dca062..14f61986646bfd4e099bd6906cb883c79f2e971e 100644 (file)
@@ -90,6 +90,7 @@ static struct ast_frame *framehook_list_push_event(struct ast_framehook_list *fr
 int ast_framehook_attach(struct ast_channel *chan, struct ast_framehook_interface *i)
 {
        struct ast_framehook *framehook;
+       struct ast_framehook_list *fh_list;
        struct ast_frame *frame;
        if (i->version != AST_FRAMEHOOK_INTERFACE_VERSION) {
                ast_log(LOG_ERROR, "Version '%hu' of framehook interface not what we compiled against (%hu)\n",
@@ -103,13 +104,14 @@ int ast_framehook_attach(struct ast_channel *chan, struct ast_framehook_interfac
        framehook->chan = chan;
 
        /* create the framehook list if it didn't already exist */
-       if (!chan->framehooks && !(chan->framehooks = ast_calloc(1, sizeof(*chan->framehooks)))) {
+       if (!ast_channel_framehooks(chan) && !(fh_list = ast_calloc(1, sizeof(*ast_channel_framehooks(chan))))) {
                ast_free(framehook);
                return -1;
        }
 
-       framehook->id = ++chan->framehooks->id_count;
-       AST_LIST_INSERT_TAIL(&chan->framehooks->list, framehook, list);
+       ast_channel_framehooks_set(chan, fh_list);
+       framehook->id = ++ast_channel_framehooks(chan)->id_count;
+       AST_LIST_INSERT_TAIL(&ast_channel_framehooks(chan)->list, framehook, list);
 
        /* Tell the event callback we're live and rocking */
        frame = framehook->i.event_cb(framehook->chan, NULL, AST_FRAMEHOOK_EVENT_ATTACHED, framehook->i.data);
@@ -128,11 +130,11 @@ int ast_framehook_detach(struct ast_channel *chan, int id)
        struct ast_framehook *framehook;
        int res = -1;
 
-       if (!chan->framehooks) {
+       if (!ast_channel_framehooks(chan)) {
                return res;
        }
 
-       AST_LIST_TRAVERSE_SAFE_BEGIN(&chan->framehooks->list, framehook, list) {
+       AST_LIST_TRAVERSE_SAFE_BEGIN(&ast_channel_framehooks(chan)->list, framehook, list) {
                if (framehook->id == id) {
                        /* we mark for detachment rather than doing explicitly here because
                         * it needs to be safe for this function to be called within the
@@ -152,16 +154,16 @@ int ast_framehook_list_destroy(struct ast_channel *chan)
 {
        struct ast_framehook *framehook;
 
-       if (!chan->framehooks) {
+       if (!ast_channel_framehooks(chan)) {
                return 0;
        }
-       AST_LIST_TRAVERSE_SAFE_BEGIN(&chan->framehooks->list, framehook, list) {
+       AST_LIST_TRAVERSE_SAFE_BEGIN(&ast_channel_framehooks(chan)->list, framehook, list) {
                AST_LIST_REMOVE_CURRENT(list);
                framehook_detach_and_destroy(framehook);
        }
        AST_LIST_TRAVERSE_SAFE_END;
-       ast_free(chan->framehooks);
-       chan->framehooks = NULL;
+       ast_free(ast_channel_framehooks(chan));
+       ast_channel_framehooks_set(chan, NULL);
        return 0;
 }
 
index 0e956b0c9946b3b465bee9756b7d788749fce2d2..35e8d6d5c5b41f4f3899f8dfd39605be00f527a2 100644 (file)
@@ -64,9 +64,9 @@ void ast_image_unregister(struct ast_imager *img)
 
 int ast_supports_images(struct ast_channel *chan)
 {
-       if (!chan || !chan->tech)
+       if (!chan || !ast_channel_tech(chan))
                return 0;
-       if (!chan->tech->send_image)
+       if (!ast_channel_tech(chan)->send_image)
                return 0;
        return 1;
 }
@@ -157,10 +157,10 @@ int ast_send_image(struct ast_channel *chan, const char *filename)
 {
        struct ast_frame *f;
        int res = -1;
-       if (chan->tech->send_image) {
+       if (ast_channel_tech(chan)->send_image) {
                f = ast_read_image(filename, ast_channel_language(chan), NULL);
                if (f) {
-                       res = chan->tech->send_image(chan, f);
+                       res = ast_channel_tech(chan)->send_image(chan, f);
                        ast_frfree(f);
                }
        }
index c538a29f000e0f8d722e50cafdc0c3e1c05fb74e..8fa1041c451ed83f5bdc4f3a85026facd01138fb 100644 (file)
@@ -3157,8 +3157,8 @@ static int action_hangup(struct mansession *s, const struct message *m)
        ast_channel_lock(c);
        if (causecode > 0) {
                ast_debug(1, "Setting hangupcause of channel %s to %d (is %d now)\n",
-                               ast_channel_name(c), causecode, c->hangupcause);
-               c->hangupcause = causecode;
+                               ast_channel_name(c), causecode, ast_channel_hangupcause(c));
+               ast_channel_hangupcause_set(c, causecode);
        }
        ast_softhangup_nolock(c, AST_SOFTHANGUP_EXPLICIT);
        ast_channel_unlock(c);
@@ -3326,9 +3326,9 @@ static int action_status(struct mansession *s, const struct message *m)
                } else {
                        bridge[0] = '\0';
                }
-               if (c->pbx) {
-                       if (c->cdr) {
-                               elapsed_seconds = now.tv_sec - c->cdr->start.tv_sec;
+               if (ast_channel_pbx(c)) {
+                       if (ast_channel_cdr(c)) {
+                               elapsed_seconds = now.tv_sec - ast_channel_cdr(c)->start.tv_sec;
                        }
                        astman_append(s,
                        "Event: Status\r\n"
@@ -3356,9 +3356,9 @@ static int action_status(struct mansession *s, const struct message *m)
                        S_COR(c->connected.id.number.valid, c->connected.id.number.str, "<unknown>"),
                        S_COR(c->connected.id.name.valid, c->connected.id.name.str, "<unknown>"),
                        ast_channel_accountcode(c),
-                       c->_state,
-                       ast_state2str(c->_state), ast_channel_context(c),
-                       ast_channel_exten(c), c->priority, (long)elapsed_seconds, bridge, ast_channel_uniqueid(c), ast_str_buffer(str), idText);
+                       ast_channel_state(c),
+                       ast_state2str(ast_channel_state(c)), ast_channel_context(c),
+                       ast_channel_exten(c), ast_channel_priority(c), (long)elapsed_seconds, bridge, ast_channel_uniqueid(c), ast_str_buffer(str), idText);
                } else {
                        astman_append(s,
                                "Event: Status\r\n"
@@ -3381,7 +3381,7 @@ static int action_status(struct mansession *s, const struct message *m)
                                S_COR(c->connected.id.number.valid, c->connected.id.number.str, "<unknown>"),
                                S_COR(c->connected.id.name.valid, c->connected.id.name.str, "<unknown>"),
                                ast_channel_accountcode(c),
-                               ast_state2str(c->_state), bridge, ast_channel_uniqueid(c),
+                               ast_state2str(ast_channel_state(c)), bridge, ast_channel_uniqueid(c),
                                ast_str_buffer(str), idText);
                }
 
@@ -3500,7 +3500,7 @@ static int action_redirect(struct mansession *s, const struct message *m)
                return 0;
        }
 
-       if (chan->pbx) {
+       if (ast_channel_pbx(chan)) {
                ast_channel_lock(chan);
                ast_set_flag(chan, AST_FLAG_BRIDGE_HANGUP_DONT); /* don't let the after-bridge code run the h-exten */
                ast_channel_unlock(chan);
@@ -3510,7 +3510,7 @@ static int action_redirect(struct mansession *s, const struct message *m)
        if (!res) {
                if (!ast_strlen_zero(name2)) {
                        if (chan2) {
-                               if (chan2->pbx) {
+                               if (ast_channel_pbx(chan2)) {
                                        ast_channel_lock(chan2);
                                        ast_set_flag(chan2, AST_FLAG_BRIDGE_HANGUP_DONT); /* don't let the after-bridge code run the h-exten */
                                        ast_channel_unlock(chan2);
@@ -4577,8 +4577,8 @@ static int action_coreshowchannels(struct mansession *s, const struct message *m
                ast_channel_lock(c);
 
                bc = ast_bridged_channel(c);
-               if (c->cdr && !ast_tvzero(c->cdr->start)) {
-                       duration = (int)(ast_tvdiff_ms(ast_tvnow(), c->cdr->start) / 1000);
+               if (ast_channel_cdr(c) && !ast_tvzero(ast_channel_cdr(c)->start)) {
+                       duration = (int)(ast_tvdiff_ms(ast_tvnow(), ast_channel_cdr(c)->start) / 1000);
                        durh = duration / 3600;
                        durm = (duration % 3600) / 60;
                        durs = duration % 60;
@@ -4605,8 +4605,8 @@ static int action_coreshowchannels(struct mansession *s, const struct message *m
                        "AccountCode: %s\r\n"
                        "BridgedChannel: %s\r\n"
                        "BridgedUniqueID: %s\r\n"
-                       "\r\n", idText, ast_channel_name(c), ast_channel_uniqueid(c), ast_channel_context(c), ast_channel_exten(c), c->priority, c->_state,
-                       ast_state2str(c->_state), ast_channel_appl(c) ? ast_channel_appl(c) : "", ast_channel_data(c) ? S_OR(ast_channel_data(c), "") : "",
+                       "\r\n", idText, ast_channel_name(c), ast_channel_uniqueid(c), ast_channel_context(c), ast_channel_exten(c), ast_channel_priority(c), ast_channel_state(c),
+                       ast_state2str(ast_channel_state(c)), ast_channel_appl(c) ? ast_channel_appl(c) : "", ast_channel_data(c) ? S_OR(ast_channel_data(c), "") : "",
                        S_COR(c->caller.id.number.valid, c->caller.id.number.str, ""),
                        S_COR(c->caller.id.name.valid, c->caller.id.name.str, ""),
                        S_COR(c->connected.id.number.valid, c->connected.id.number.str, ""),
index c4d2c43724f7c60ee2359483bff69b4da6423eeb..1e575f2e264f3bdbc3b5b033e901758fb610f799 100644 (file)
@@ -616,7 +616,7 @@ static struct ast_channel *create_msg_q_chan(void)
 
        ast_channel_unlink(chan);
 
-       chan->tech = &msg_chan_tech_hack;
+       ast_channel_tech_set(chan, &msg_chan_tech_hack);
 
        if (!(ds = ast_datastore_alloc(&msg_datastore, NULL))) {
                ast_hangup(chan);
index 436dc87da0fddf26b051d84daca05312739eb285..626d6e8aac093bc3b18ce1377f3c380f8f44e62a 100644 (file)
@@ -1529,8 +1529,8 @@ int pbx_exec(struct ast_channel *c,       /*!< Channel */
        const char *saved_c_appl;
        const char *saved_c_data;
 
-       if (c->cdr && !ast_check_hangup(c))
-               ast_cdr_setapp(c->cdr, app->name, data);
+       if (ast_channel_cdr(c) && !ast_check_hangup(c))
+               ast_cdr_setapp(ast_channel_cdr(c), app->name, data);
 
        /* save channel values */
        saved_c_appl= ast_channel_appl(c);
@@ -3314,14 +3314,14 @@ const char *ast_str_retrieve_variable(struct ast_str **str, ssize_t maxlen, stru
                } else if (!strcmp(var, "CONTEXT")) {
                        s = ast_channel_context(c);
                } else if (!strcmp(var, "PRIORITY")) {
-                       ast_str_set(str, maxlen, "%d", c->priority);
+                       ast_str_set(str, maxlen, "%d", ast_channel_priority(c));
                        s = ast_str_buffer(*str);
                } else if (!strcmp(var, "CHANNEL")) {
                        s = ast_channel_name(c);
                } else if (!strcmp(var, "UNIQUEID")) {
                        s = ast_channel_uniqueid(c);
                } else if (!strcmp(var, "HANGUPCAUSE")) {
-                       ast_str_set(str, maxlen, "%d", c->hangupcause);
+                       ast_str_set(str, maxlen, "%d", ast_channel_hangupcause(c));
                        s = ast_str_buffer(*str);
                }
        }
@@ -3438,7 +3438,7 @@ static int raise_exception(struct ast_channel *chan, const char *reason, int pri
        ast_string_field_set(exception, reason, reason);
        ast_string_field_set(exception, context, ast_channel_context(chan));
        ast_string_field_set(exception, exten, ast_channel_exten(chan));
-       exception->priority = chan->priority;
+       exception->priority = ast_channel_priority(chan);
        set_ext_pri(chan, "e", priority);
        return 0;
 }
@@ -4363,7 +4363,7 @@ static int pbx_extension_helper(struct ast_channel *c, struct ast_context *con,
                                ast_channel_context_set(c, context);
                        if (ast_channel_exten(c) != exten)
                                ast_channel_exten_set(c, exten);
-                       c->priority = priority;
+                       ast_channel_priority_set(c, priority);
                        pbx_substitute_variables(passdata, sizeof(passdata), c, e);
 #ifdef CHANNEL_TRACE
                        ast_channel_trace_update(c);
@@ -4386,7 +4386,7 @@ static int pbx_extension_helper(struct ast_channel *c, struct ast_context *con,
                                        "Application: %s\r\n"
                                        "AppData: %s\r\n"
                                        "Uniqueid: %s\r\n",
-                                       ast_channel_name(c), ast_channel_context(c), ast_channel_exten(c), c->priority, app->name, passdata, ast_channel_uniqueid(c));
+                                       ast_channel_name(c), ast_channel_context(c), ast_channel_exten(c), ast_channel_priority(c), app->name, passdata, ast_channel_uniqueid(c));
                        return pbx_exec(c, app, passdata);      /* 0 on success, -1 on failure */
                }
        } else if (q.swo) {     /* not found here, but in another switch */
@@ -5058,7 +5058,7 @@ static void set_ext_pri(struct ast_channel *c, const char *exten, int pri)
 {
        ast_channel_lock(c);
        ast_channel_exten_set(c, exten);
-       c->priority = pri;
+       ast_channel_priority_set(c, pri);
        ast_channel_unlock(c);
 }
 
@@ -5090,7 +5090,7 @@ static int collect_digits(struct ast_channel *c, int waittime, char *buf, int bu
                                buf[pos++] = digit;
                                buf[pos] = '\0';
                        }
-                       waittime = c->pbx->dtimeoutms;
+                       waittime = ast_channel_pbx(c)->dtimeoutms;
                }
        }
        return 0;
@@ -5103,25 +5103,28 @@ static enum ast_pbx_result __ast_pbx_run(struct ast_channel *c,
        int res = 0;
        int autoloopflag;
        int error = 0;          /* set an error conditions */
+       struct ast_pbx *pbx;
 
        /* A little initial setup here */
-       if (c->pbx) {
+       if (ast_channel_pbx(c)) {
                ast_log(LOG_WARNING, "%s already has PBX structure??\n", ast_channel_name(c));
                /* XXX and now what ? */
-               ast_free(c->pbx);
+               ast_free(ast_channel_pbx(c));
        }
-       if (!(c->pbx = ast_calloc(1, sizeof(*c->pbx))))
+       if (!(pbx = ast_calloc(1, sizeof(*pbx)))) {
                return -1;
+       }
+       ast_channel_pbx_set(c, pbx);
        /* Set reasonable defaults */
-       c->pbx->rtimeoutms = 10000;
-       c->pbx->dtimeoutms = 5000;
+       ast_channel_pbx(c)->rtimeoutms = 10000;
+       ast_channel_pbx(c)->dtimeoutms = 5000;
 
        autoloopflag = ast_test_flag(c, AST_FLAG_IN_AUTOLOOP);  /* save value to restore at the end */
        ast_set_flag(c, AST_FLAG_IN_AUTOLOOP);
 
        if (ast_strlen_zero(ast_channel_exten(c))) {
                /* If not successful fall back to 's' - but only if there is no given exten  */
-               ast_verb(2, "Starting %s at %s,%s,%d failed so falling back to exten 's'\n", ast_channel_name(c), ast_channel_context(c), ast_channel_exten(c), c->priority);
+               ast_verb(2, "Starting %s at %s,%s,%d failed so falling back to exten 's'\n", ast_channel_name(c), ast_channel_context(c), ast_channel_exten(c), ast_channel_priority(c));
                /* XXX the original code used the existing priority in the call to
                 * ast_exists_extension(), and reset it to 1 afterwards.
                 * I believe the correct thing is to set it to 1 immediately.
@@ -5130,7 +5133,7 @@ static enum ast_pbx_result __ast_pbx_run(struct ast_channel *c,
        }
 
        ast_channel_lock(c);
-       if (c->cdr) {
+       if (ast_channel_cdr(c)) {
                /* allow CDR variables that have been collected after channel was created to be visible during call */
                ast_cdr_update(c);
        }
@@ -5143,11 +5146,11 @@ static enum ast_pbx_result __ast_pbx_run(struct ast_channel *c,
                int timeout = 0;
 
                /* loop on priorities in this context/exten */
-               while (!(res = ast_spawn_extension(c, ast_channel_context(c), ast_channel_exten(c), c->priority,
+               while (!(res = ast_spawn_extension(c, ast_channel_context(c), ast_channel_exten(c), ast_channel_priority(c),
                        S_COR(c->caller.id.number.valid, c->caller.id.number.str, NULL),
                        &found, 1))) {
                        if (!ast_check_hangup(c)) {
-                               ++c->priority;
+                               ast_channel_priority_set(c, ast_channel_priority(c) + 1);
                                continue;
                        }
 
@@ -5178,7 +5181,7 @@ static enum ast_pbx_result __ast_pbx_run(struct ast_channel *c,
                                break;
                        }
                        ast_debug(1, "Extension %s, priority %d returned normally even though call was hung up\n",
-                               ast_channel_exten(c), c->priority);
+                               ast_channel_exten(c), ast_channel_priority(c));
                        error = 1;
                        break;
                } /* end while  - from here on we can use 'break' to go out */
@@ -5190,8 +5193,8 @@ static enum ast_pbx_result __ast_pbx_run(struct ast_channel *c,
                                dst_exten[pos++] = digit = res;
                                dst_exten[pos] = '\0';
                        } else if (res == AST_PBX_INCOMPLETE) {
-                               ast_debug(1, "Spawn extension (%s,%s,%d) exited INCOMPLETE on '%s'\n", ast_channel_context(c), ast_channel_exten(c), c->priority, ast_channel_name(c));
-                               ast_verb(2, "Spawn extension (%s, %s, %d) exited INCOMPLETE on '%s'\n", ast_channel_context(c), ast_channel_exten(c), c->priority, ast_channel_name(c));
+                               ast_debug(1, "Spawn extension (%s,%s,%d) exited INCOMPLETE on '%s'\n", ast_channel_context(c), ast_channel_exten(c), ast_channel_priority(c), ast_channel_name(c));
+                               ast_verb(2, "Spawn extension (%s, %s, %d) exited INCOMPLETE on '%s'\n", ast_channel_context(c), ast_channel_exten(c), ast_channel_priority(c), ast_channel_name(c));
 
                                /* Don't cycle on incomplete - this will happen if the only extension that matches is our "incomplete" extension */
                                if (!ast_matchmore_extension(c, ast_channel_context(c), ast_channel_exten(c), 1,
@@ -5203,15 +5206,15 @@ static enum ast_pbx_result __ast_pbx_run(struct ast_channel *c,
                                        pos = strlen(dst_exten);
                                }
                        } else {
-                               ast_debug(1, "Spawn extension (%s,%s,%d) exited non-zero on '%s'\n", ast_channel_context(c), ast_channel_exten(c), c->priority, ast_channel_name(c));
-                               ast_verb(2, "Spawn extension (%s, %s, %d) exited non-zero on '%s'\n", ast_channel_context(c), ast_channel_exten(c), c->priority, ast_channel_name(c));
+                               ast_debug(1, "Spawn extension (%s,%s,%d) exited non-zero on '%s'\n", ast_channel_context(c), ast_channel_exten(c), ast_channel_priority(c), ast_channel_name(c));
+                               ast_verb(2, "Spawn extension (%s, %s, %d) exited non-zero on '%s'\n", ast_channel_context(c), ast_channel_exten(c), ast_channel_priority(c), ast_channel_name(c));
 
                                if ((res == AST_PBX_ERROR)
                                        && ast_exists_extension(c, ast_channel_context(c), "e", 1,
                                                S_COR(c->caller.id.number.valid, c->caller.id.number.str, NULL))) {
                                        /* if we are already on the 'e' exten, don't jump to it again */
                                        if (!strcmp(ast_channel_exten(c), "e")) {
-                                               ast_verb(2, "Spawn extension (%s, %s, %d) exited ERROR while already on 'e' exten on '%s'\n", ast_channel_context(c), ast_channel_exten(c), c->priority, ast_channel_name(c));
+                                               ast_verb(2, "Spawn extension (%s, %s, %d) exited ERROR while already on 'e' exten on '%s'\n", ast_channel_context(c), ast_channel_exten(c), ast_channel_priority(c), ast_channel_name(c));
                                                error = 1;
                                        } else {
                                                raise_exception(c, "ERROR", 1);
@@ -5242,7 +5245,7 @@ static enum ast_pbx_result __ast_pbx_run(struct ast_channel *c,
                                        /* Call timed out with no special extension to jump to. */
                                }
                                ast_channel_lock(c);
-                               if (c->cdr) {
+                               if (ast_channel_cdr(c)) {
                                        ast_cdr_update(c);
                                }
                                ast_channel_unlock(c);
@@ -5286,9 +5289,9 @@ static enum ast_pbx_result __ast_pbx_run(struct ast_channel *c,
                } else {        /* keypress received, get more digits for a full extension */
                        int waittime = 0;
                        if (digit)
-                               waittime = c->pbx->dtimeoutms;
+                               waittime = ast_channel_pbx(c)->dtimeoutms;
                        else if (!autofallthrough)
-                               waittime = c->pbx->rtimeoutms;
+                               waittime = ast_channel_pbx(c)->rtimeoutms;
                        if (!waittime) {
                                const char *status = pbx_builtin_getvar_helper(c, "DIALSTATUS");
                                if (!status)
@@ -5350,7 +5353,7 @@ static enum ast_pbx_result __ast_pbx_run(struct ast_channel *c,
                                }
                        }
                        ast_channel_lock(c);
-                       if (c->cdr) {
+                       if (ast_channel_cdr(c)) {
                                ast_verb(2, "CDR updated on %s\n",ast_channel_name(c));
                                ast_cdr_update(c);
                        }
@@ -5371,24 +5374,24 @@ static enum ast_pbx_result __ast_pbx_run(struct ast_channel *c,
                && ast_exists_extension(c, ast_channel_context(c), "h", 1,
                        S_COR(c->caller.id.number.valid, c->caller.id.number.str, NULL))) {
                set_ext_pri(c, "h", 1);
-               if (c->cdr && ast_opt_end_cdr_before_h_exten) {
-                       ast_cdr_end(c->cdr);
+               if (ast_channel_cdr(c) && ast_opt_end_cdr_before_h_exten) {
+                       ast_cdr_end(ast_channel_cdr(c));
                }
-               while ((res = ast_spawn_extension(c, ast_channel_context(c), ast_channel_exten(c), c->priority,
+               while ((res = ast_spawn_extension(c, ast_channel_context(c), ast_channel_exten(c), ast_channel_priority(c),
                        S_COR(c->caller.id.number.valid, c->caller.id.number.str, NULL),
                        &found, 1)) == 0) {
-                       c->priority++;
+                       ast_channel_priority_set(c, ast_channel_priority(c) + 1);
                }
                if (found && res) {
                        /* 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(c), ast_channel_exten(c), c->priority, ast_channel_name(c));
-                       ast_verb(2, "Spawn extension (%s, %s, %d) exited non-zero on '%s'\n", ast_channel_context(c), ast_channel_exten(c), c->priority, ast_channel_name(c));
+                       ast_debug(1, "Spawn extension (%s,%s,%d) exited non-zero on '%s'\n", ast_channel_context(c), ast_channel_exten(c), ast_channel_priority(c), ast_channel_name(c));
+                       ast_verb(2, "Spawn extension (%s, %s, %d) exited non-zero on '%s'\n", ast_channel_context(c), ast_channel_exten(c), ast_channel_priority(c), ast_channel_name(c));
                }
        }
        ast_set2_flag(c, autoloopflag, AST_FLAG_IN_AUTOLOOP);
        ast_clear_flag(c, AST_FLAG_BRIDGE_HANGUP_RUN); /* from one round to the next, make sure this gets cleared */
-       pbx_destroy(c->pbx);
-       c->pbx = NULL;
+       pbx_destroy(ast_channel_pbx(c));
+       ast_channel_pbx_set(c, NULL);
 
        if (!args || !args->no_hangup_chan) {
                ast_hangup(c);
@@ -8297,10 +8300,11 @@ int ast_explicit_goto(struct ast_channel *chan, const char *context, const char
        if (!ast_strlen_zero(exten))
                ast_channel_exten_set(chan, exten);
        if (priority > -1) {
-               chan->priority = priority;
+               ast_channel_priority_set(chan, priority);
                /* see flag description in channel.h for explanation */
-               if (ast_test_flag(chan, AST_FLAG_IN_AUTOLOOP))
-                       chan->priority--;
+               if (ast_test_flag(chan, AST_FLAG_IN_AUTOLOOP)) {
+                       ast_channel_priority_set(chan, ast_channel_priority(chan) - 1);
+               }
        }
 
        ast_channel_unlock(chan);
@@ -8326,7 +8330,7 @@ int ast_async_goto(struct ast_channel *chan, const char *context, const char *ex
        } tmpvars = { 0, };
 
        ast_channel_lock(chan);
-       if (chan->pbx) { /* This channel is currently in the PBX */
+       if (ast_channel_pbx(chan)) { /* This channel is currently in the PBX */
                ast_explicit_goto(chan, context, exten, priority + 1);
                ast_softhangup_nolock(chan, AST_SOFTHANGUP_ASYNCGOTO);
                ast_channel_unlock(chan);
@@ -8341,11 +8345,11 @@ int ast_async_goto(struct ast_channel *chan, const char *context, const char *ex
        tmpvars.context = ast_strdupa(ast_channel_context(chan));
        tmpvars.linkedid = ast_strdupa(ast_channel_linkedid(chan));
        tmpvars.name = ast_strdupa(ast_channel_name(chan));
-       tmpvars.amaflags = chan->amaflags;
-       tmpvars.state = chan->_state;
+       tmpvars.amaflags = ast_channel_amaflags(chan);
+       tmpvars.state = ast_channel_state(chan);
        ast_format_copy(&tmpvars.writeformat, &chan->writeformat);
        ast_format_copy(&tmpvars.readformat, &chan->readformat);
-       tmpvars.cdr = chan->cdr ? ast_cdr_dup(chan->cdr) : NULL;
+       tmpvars.cdr = ast_channel_cdr(chan) ? ast_cdr_dup(ast_channel_cdr(chan)) : NULL;
 
        ast_channel_unlock(chan);
 
@@ -8358,8 +8362,8 @@ int ast_async_goto(struct ast_channel *chan, const char *context, const char *ex
 
        /* copy the cdr info over */
        if (tmpvars.cdr) {
-               ast_cdr_discard(tmpchan->cdr);
-               tmpchan->cdr = tmpvars.cdr;
+               ast_cdr_discard(ast_channel_cdr(tmpchan));
+               ast_channel_cdr_set(tmpchan, tmpvars.cdr);
                tmpvars.cdr = NULL;
        }
 
@@ -8856,7 +8860,7 @@ static void *async_wait(void *data)
        struct ast_frame *f;
        struct ast_app *app;
 
-       while (timeout && (chan->_state != AST_STATE_UP)) {
+       while (timeout && (ast_channel_state(chan) != AST_STATE_UP)) {
                res = ast_waitfor(chan, timeout);
                if (res < 1)
                        break;
@@ -8874,7 +8878,7 @@ static void *async_wait(void *data)
                }
                ast_frfree(f);
        }
-       if (chan->_state == AST_STATE_UP) {
+       if (ast_channel_state(chan) == AST_STATE_UP) {
                if (!ast_strlen_zero(as->app)) {
                        app = pbx_findapp(as->app);
                        if (app) {
@@ -8888,7 +8892,7 @@ static void *async_wait(void *data)
                        if (!ast_strlen_zero(as->exten))
                                ast_channel_exten_set(chan, as->exten);
                        if (as->priority > 0)
-                               chan->priority = as->priority;
+                               ast_channel_priority_set(chan, as->priority);
                        /* Run the PBX */
                        if (ast_pbx_run(chan)) {
                                ast_log(LOG_ERROR, "Failed to start PBX on %s\n", ast_channel_name(chan));
@@ -8916,20 +8920,20 @@ static int ast_pbx_outgoing_cdr_failed(void)
        if (!chan)
                return -1;  /* failure */
 
-       chan->cdr = ast_cdr_alloc();
-       if (!chan->cdr) {
+       ast_channel_cdr_set(chan, ast_cdr_alloc());
+       if (!ast_channel_cdr(chan)) {
                /* allocation of the cdr failed */
                chan = ast_channel_unref(chan);   /* free the channel */
                return -1;                /* return failure */
        }
 
        /* allocation of the cdr was successful */
-       ast_cdr_init(chan->cdr, chan);  /* initialize our channel's cdr */
-       ast_cdr_start(chan->cdr);       /* record the start and stop time */
-       ast_cdr_end(chan->cdr);
-       ast_cdr_failed(chan->cdr);      /* set the status to failed */
-       ast_cdr_detach(chan->cdr);      /* post and free the record */
-       chan->cdr = NULL;
+       ast_cdr_init(ast_channel_cdr(chan), chan);  /* initialize our channel's cdr */
+       ast_cdr_start(ast_channel_cdr(chan));       /* record the start and stop time */
+       ast_cdr_end(ast_channel_cdr(chan));
+       ast_cdr_failed(ast_channel_cdr(chan));      /* set the status to failed */
+       ast_cdr_detach(ast_channel_cdr(chan));      /* post and free the record */
+       ast_channel_cdr_set(chan, NULL);
        chan = ast_channel_unref(chan);         /* free the channel */
 
        return 0;  /* success */
@@ -8959,7 +8963,7 @@ int ast_pbx_outgoing_exten(const char *type, struct ast_format_cap *cap, const c
                                ast_channel_lock(chan);
                }
                if (chan) {
-                       if (chan->_state == AST_STATE_UP) {
+                       if (ast_channel_state(chan) == AST_STATE_UP) {
                                        res = 0;
                                ast_verb(4, "Channel %s was answered.\n", ast_channel_name(chan));
 
@@ -8989,11 +8993,11 @@ int ast_pbx_outgoing_exten(const char *type, struct ast_format_cap *cap, const c
                        } else {
                                ast_verb(4, "Channel %s was never answered.\n", ast_channel_name(chan));
 
-                               if (chan->cdr) { /* update the cdr */
+                               if (ast_channel_cdr(chan)) { /* update the cdr */
                                        /* here we update the status of the call, which sould be busy.
                                         * if that fails then we set the status to failed */
-                                       if (ast_cdr_disposition(chan->cdr, chan->hangupcause))
-                                               ast_cdr_failed(chan->cdr);
+                                       if (ast_cdr_disposition(ast_channel_cdr(chan), ast_channel_hangupcause(chan)))
+                                               ast_cdr_failed(ast_channel_cdr(chan));
                                }
 
                                if (channel) {
@@ -9127,7 +9131,7 @@ int ast_pbx_outgoing_app(const char *type, struct ast_format_cap *cap, const cha
                        ast_set_variables(chan, vars);
                        if (account)
                                ast_cdr_setaccount(chan, account);
-                       if (chan->_state == AST_STATE_UP) {
+                       if (ast_channel_state(chan) == AST_STATE_UP) {
                                res = 0;
                                ast_verb(4, "Channel %s was answered.\n", ast_channel_name(chan));
                                tmp = ast_calloc(1, sizeof(*tmp));
@@ -9163,11 +9167,11 @@ int ast_pbx_outgoing_app(const char *type, struct ast_format_cap *cap, const cha
                                }
                        } else {
                                ast_verb(4, "Channel %s was never answered.\n", ast_channel_name(chan));
-                               if (chan->cdr) { /* update the cdr */
+                               if (ast_channel_cdr(chan)) { /* update the cdr */
                                        /* here we update the status of the call, which sould be busy.
                                         * if that fails then we set the status to failed */
-                                       if (ast_cdr_disposition(chan->cdr, chan->hangupcause))
-                                               ast_cdr_failed(chan->cdr);
+                                       if (ast_cdr_disposition(ast_channel_cdr(chan), ast_channel_hangupcause(chan)))
+                                               ast_cdr_failed(ast_channel_cdr(chan));
                                }
                                ast_hangup(chan);
                        }
@@ -9499,9 +9503,9 @@ static int pbx_builtin_busy(struct ast_channel *chan, const char *data)
        ast_indicate(chan, AST_CONTROL_BUSY);
        /* Don't change state of an UP channel, just indicate
           busy in audio */
-       if (chan->_state != AST_STATE_UP) {
+       if (ast_channel_state(chan) != AST_STATE_UP) {
                ast_setstate(chan, AST_STATE_BUSY);
-               ast_cdr_busy(chan->cdr);
+               ast_cdr_busy(ast_channel_cdr(chan));
        }
        wait_for_hangup(chan, data);
        return -1;
@@ -9515,9 +9519,9 @@ static int pbx_builtin_congestion(struct ast_channel *chan, const char *data)
        ast_indicate(chan, AST_CONTROL_CONGESTION);
        /* Don't change state of an UP channel, just indicate
           congestion in audio */
-       if (chan->_state != AST_STATE_UP) {
+       if (ast_channel_state(chan) != AST_STATE_UP) {
                ast_setstate(chan, AST_STATE_BUSY);
-               ast_cdr_congestion(chan->cdr);
+               ast_cdr_congestion(ast_channel_cdr(chan));
        }
        wait_for_hangup(chan, data);
        return -1;
@@ -9544,7 +9548,7 @@ static int pbx_builtin_answer(struct ast_channel *chan, const char *data)
 
        AST_STANDARD_APP_ARGS(args, parse);
 
-       if (!ast_strlen_zero(args.delay) && (chan->_state != AST_STATE_UP))
+       if (!ast_strlen_zero(args.delay) && (ast_channel_state(chan) != AST_STATE_UP))
                delay = atoi(data);
 
        if (delay < 0) {
@@ -9571,7 +9575,7 @@ static int pbx_builtin_incomplete(struct ast_channel *chan, const char *data)
        /* If the channel is hungup, stop waiting */
        if (ast_check_hangup(chan)) {
                return -1;
-       } else if (chan->_state != AST_STATE_UP && answer) {
+       } else if (ast_channel_state(chan) != AST_STATE_UP && answer) {
                __ast_answer(chan, 0, 1);
        }
 
@@ -9600,7 +9604,7 @@ static int pbx_builtin_resetcdr(struct ast_channel *chan, const char *data)
                ast_app_parse_options(resetcdr_opts, &flags, NULL, args);
        }
 
-       ast_cdr_reset(chan->cdr, &flags);
+       ast_cdr_reset(ast_channel_cdr(chan), &flags);
 
        return 0;
 }
@@ -9629,21 +9633,21 @@ static int pbx_builtin_hangup(struct ast_channel *chan, const char *data)
                char *endptr;
 
                if ((cause = ast_str2cause(data)) > -1) {
-                       chan->hangupcause = cause;
+                       ast_channel_hangupcause_set(chan, cause);
                        return -1;
                }
 
                cause = strtol((const char *) data, &endptr, 10);
                if (cause != 0 || (data != endptr)) {
-                       chan->hangupcause = cause;
+                       ast_channel_hangupcause_set(chan, cause);
                        return -1;
                }
 
                ast_log(LOG_WARNING, "Invalid cause given to Hangup(): \"%s\"\n", (char *) data);
        }
 
-       if (!chan->hangupcause) {
-               chan->hangupcause = AST_CAUSE_NORMAL_CLEARING;
+       if (!ast_channel_hangupcause(chan)) {
+               ast_channel_hangupcause_set(chan, AST_CAUSE_NORMAL_CLEARING);
        }
 
        return -1;
@@ -9827,7 +9831,7 @@ static int pbx_builtin_waitexten(struct ast_channel *chan, const char *data)
        } else if (ast_test_flag(&flags, WAITEXTEN_MOH)) {
                ast_indicate_data(chan, AST_CONTROL_HOLD, S_OR(opts[0], NULL), strlen(opts[0]));
        } else if (ast_test_flag(&flags, WAITEXTEN_DIALTONE)) {
-               struct ast_tone_zone_sound *ts = ast_get_indication_tone(chan->zone, "dial");
+               struct ast_tone_zone_sound *ts = ast_get_indication_tone(ast_channel_zone(chan), "dial");
                if (ts) {
                        ast_playtones_start(chan, 0, ts->data, 0);
                        ts = ast_tone_zone_sound_unref(ts);
@@ -9838,8 +9842,8 @@ static int pbx_builtin_waitexten(struct ast_channel *chan, const char *data)
        /* Wait for "n" seconds */
        if (!ast_app_parse_timelen(args.timeout, &ms, TIMELEN_SECONDS) && ms > 0) {
                /* Yay! */
-       } else if (chan->pbx) {
-               ms = chan->pbx->rtimeoutms;
+       } else if (ast_channel_pbx(chan)) {
+               ms = ast_channel_pbx(chan)->rtimeoutms;
        } else {
                ms = 10000;
        }
@@ -9849,7 +9853,7 @@ static int pbx_builtin_waitexten(struct ast_channel *chan, const char *data)
                if (ast_check_hangup(chan)) {
                        /* Call is hungup for some reason. */
                        res = -1;
-               } else if (ast_exists_extension(chan, ast_channel_context(chan), ast_channel_exten(chan), chan->priority + 1,
+               } else if (ast_exists_extension(chan, ast_channel_context(chan), ast_channel_exten(chan), ast_channel_priority(chan) + 1,
                        S_COR(chan->caller.id.number.valid, chan->caller.id.number.str, NULL))) {
                        ast_verb(3, "Timeout on %s, continuing...\n", ast_channel_name(chan));
                } else if (ast_exists_extension(chan, ast_channel_context(chan), "t", 1,
@@ -9923,7 +9927,7 @@ static int pbx_builtin_background(struct ast_channel *chan, const char *data)
        }
 
        /* Answer if need be */
-       if (chan->_state != AST_STATE_UP) {
+       if (ast_channel_state(chan) != AST_STATE_UP) {
                if (ast_test_flag(&flags, BACKGROUND_SKIP)) {
                        goto done;
                } else if (!ast_test_flag(&flags, BACKGROUND_NOANSWER)) {
@@ -9983,7 +9987,7 @@ static int pbx_builtin_background(struct ast_channel *chan, const char *data)
                snprintf(buf, sizeof(buf), "%c", res);
                ast_channel_exten_set(chan, buf);
                ast_channel_context_set(chan, args.context);
-               chan->priority = 0;
+               ast_channel_priority_set(chan, 0);
                res = 0;
        }
 done:
@@ -9998,7 +10002,7 @@ static int pbx_builtin_goto(struct ast_channel *chan, const char *data)
 {
        int res = ast_parseable_goto(chan, data);
        if (!res)
-               ast_verb(3, "Goto (%s,%s,%d)\n", ast_channel_context(chan), ast_channel_exten(chan), chan->priority + 1);
+               ast_verb(3, "Goto (%s,%s,%d)\n", ast_channel_context(chan), ast_channel_exten(chan), ast_channel_priority(chan) + 1);
        return res;
 }
 
@@ -10223,7 +10227,7 @@ int pbx_builtin_setvar_multiple(struct ast_channel *chan, const char *vdata)
                } else if (!chan) {
                        ast_log(LOG_WARNING, "MSet: ignoring entry '%s' with no '='\n", pair.name);
                } else {
-                       ast_log(LOG_WARNING, "MSet: ignoring entry '%s' with no '=' (in %s@%s:%d\n", pair.name, ast_channel_exten(chan), ast_channel_context(chan), chan->priority);
+                       ast_log(LOG_WARNING, "MSet: ignoring entry '%s' with no '=' (in %s@%s:%d\n", pair.name, ast_channel_exten(chan), ast_channel_context(chan), ast_channel_priority(chan));
                }
        }
 
@@ -10756,7 +10760,7 @@ static int pbx_parseable_goto(struct ast_channel *chan, const char *goto_string,
        /* At this point we have a priority and maybe an extension and a context */
 
        if (mode)
-               ipri = chan->priority + (ipri * mode);
+               ipri = ast_channel_priority(chan) + (ipri * mode);
 
        if (async)
                ast_async_goto(chan, context, exten, ipri);
index 3e2e39ba8868dbdc52ed0163260fbda25effebb9..518ac140c6bc44c63918d4ff15c9deb45c758674 100644 (file)
@@ -843,17 +843,17 @@ static enum ast_bridge_result local_bridge_loop(struct ast_channel *c0, struct a
                        break;
                }
                /* Check if anything changed */
-               if ((c0->tech_pvt != pvt0) ||
-                   (c1->tech_pvt != pvt1) ||
-                   (c0->masq || c0->masqr || c1->masq || c1->masqr) ||
-                   (c0->monitor || c0->audiohooks || c1->monitor || c1->audiohooks) ||
-                   (!ast_framehook_list_is_empty(c0->framehooks) || !ast_framehook_list_is_empty(c1->framehooks))) {
+               if ((ast_channel_tech_pvt(c0) != pvt0) ||
+                   (ast_channel_tech_pvt(c1) != pvt1) ||
+                   (ast_channel_masq(c0) || ast_channel_masqr(c0) || ast_channel_masq(c1) || ast_channel_masqr(c1)) ||
+                   (ast_channel_monitor(c0) || ast_channel_audiohooks(c0) || ast_channel_monitor(c1) || ast_channel_audiohooks(c1)) ||
+                   (!ast_framehook_list_is_empty(ast_channel_framehooks(c0)) || !ast_framehook_list_is_empty(ast_channel_framehooks(c1)))) {
                        ast_debug(1, "rtp-engine-local-bridge: Oooh, something is weird, backing out\n");
                        /* If a masquerade needs to happen we have to try to read in a frame so that it actually happens. Without this we risk being called again and going into a loop */
-                       if ((c0->masq || c0->masqr) && (fr = ast_read(c0))) {
+                       if ((ast_channel_masq(c0) || ast_channel_masqr(c0)) && (fr = ast_read(c0))) {
                                ast_frfree(fr);
                        }
-                       if ((c1->masq || c1->masqr) && (fr = ast_read(c1))) {
+                       if ((ast_channel_masq(c1) || ast_channel_masqr(c1)) && (fr = ast_read(c1))) {
                                ast_frfree(fr);
                        }
                        res = AST_BRIDGE_RETRY;
@@ -1041,11 +1041,11 @@ static enum ast_bridge_result remote_bridge_loop(struct ast_channel *c0,
        cs[2] = NULL;
        for (;;) {
                /* Check if anything changed */
-               if ((c0->tech_pvt != pvt0) ||
-                   (c1->tech_pvt != pvt1) ||
-                   (c0->masq || c0->masqr || c1->masq || c1->masqr) ||
-                   (c0->monitor || c0->audiohooks || c1->monitor || c1->audiohooks) ||
-                   (!ast_framehook_list_is_empty(c0->framehooks) || !ast_framehook_list_is_empty(c1->framehooks))) {
+               if ((ast_channel_tech_pvt(c0) != pvt0) ||
+                   (ast_channel_tech_pvt(c1) != pvt1) ||
+                   (ast_channel_masq(c0) || ast_channel_masqr(c0) || ast_channel_masq(c1) || ast_channel_masqr(c1)) ||
+                   (ast_channel_monitor(c0) || ast_channel_audiohooks(c0) || ast_channel_monitor(c1) || ast_channel_audiohooks(c1)) ||
+                   (!ast_framehook_list_is_empty(ast_channel_framehooks(c0)) || !ast_framehook_list_is_empty(ast_channel_framehooks(c1)))) {
                        ast_debug(1, "Oooh, something is weird, backing out\n");
                        res = AST_BRIDGE_RETRY;
                        break;
@@ -1187,14 +1187,14 @@ static enum ast_bridge_result remote_bridge_loop(struct ast_channel *c0,
                                ast_rtp_instance_get_remote_address(instance1, &t1);
                                ast_sockaddr_copy(&ac1, &t1);
                                /* Update codec information */
-                               if (glue0->get_codec && c0->tech_pvt) {
+                               if (glue0->get_codec && ast_channel_tech_pvt(c0)) {
                                        ast_format_cap_remove_all(cap0);
                                        ast_format_cap_remove_all(oldcap0);
                                        glue0->get_codec(c0, cap0);
                                        ast_format_cap_append(oldcap0, cap0);
 
                                }
-                               if (glue1->get_codec && c1->tech_pvt) {
+                               if (glue1->get_codec && ast_channel_tech_pvt(c1)) {
                                        ast_format_cap_remove_all(cap1);
                                        ast_format_cap_remove_all(oldcap1);
                                        glue0->get_codec(c1, cap1);
@@ -1243,18 +1243,18 @@ static enum ast_bridge_result remote_bridge_loop(struct ast_channel *c0,
 
        if (ast_test_flag(c0, AST_FLAG_ZOMBIE)) {
                ast_debug(1, "Channel '%s' Zombie cleardown from bridge\n", ast_channel_name(c0));
-       } else if (c0->tech_pvt != pvt0) {
+       } else if (ast_channel_tech_pvt(c0) != pvt0) {
                ast_debug(1, "Channel c0->'%s' pvt changed, in bridge with c1->'%s'\n", ast_channel_name(c0), ast_channel_name(c1));
-       } else if (glue0 != ast_rtp_instance_get_glue(c0->tech->type)) {
+       } else if (glue0 != ast_rtp_instance_get_glue(ast_channel_tech(c0)->type)) {
                ast_debug(1, "Channel c0->'%s' technology changed, in bridge with c1->'%s'\n", ast_channel_name(c0), ast_channel_name(c1));
        } else if (glue0->update_peer(c0, NULL, NULL, NULL, 0, 0)) {
                ast_log(LOG_WARNING, "Channel '%s' failed to break RTP bridge\n", ast_channel_name(c0));
        }
        if (ast_test_flag(c1, AST_FLAG_ZOMBIE)) {
                ast_debug(1, "Channel '%s' Zombie cleardown from bridge\n", ast_channel_name(c1));
-       } else if (c1->tech_pvt != pvt1) {
+       } else if (ast_channel_tech_pvt(c1) != pvt1) {
                ast_debug(1, "Channel c1->'%s' pvt changed, in bridge with c0->'%s'\n", ast_channel_name(c1), ast_channel_name(c0));
-       } else if (glue1 != ast_rtp_instance_get_glue(c1->tech->type)) {
+       } else if (glue1 != ast_rtp_instance_get_glue(ast_channel_tech(c1)->type)) {
                ast_debug(1, "Channel c1->'%s' technology changed, in bridge with c0->'%s'\n", ast_channel_name(c1), ast_channel_name(c0));
        } else if (glue1->update_peer(c1, NULL, NULL, NULL, 0, 0)) {
                ast_log(LOG_WARNING, "Channel '%s' failed to break RTP bridge\n", ast_channel_name(c1));
@@ -1318,7 +1318,7 @@ enum ast_bridge_result ast_rtp_instance_bridge(struct ast_channel *c0, struct as
        }
 
        /* Grab glue that binds each channel to something using the RTP engine */
-       if (!(glue0 = ast_rtp_instance_get_glue(c0->tech->type)) || !(glue1 = ast_rtp_instance_get_glue(c1->tech->type))) {
+       if (!(glue0 = ast_rtp_instance_get_glue(ast_channel_tech(c0)->type)) || !(glue1 = ast_rtp_instance_get_glue(ast_channel_tech(c1)->type))) {
                ast_debug(1, "Can't find native functions for channel '%s'\n", glue0 ? ast_channel_name(c1) : ast_channel_name(c0));
                goto done;
        }
@@ -1397,12 +1397,12 @@ enum ast_bridge_result ast_rtp_instance_bridge(struct ast_channel *c0, struct as
        /* Depending on the end result for bridging either do a local bridge or remote bridge */
        if (audio_glue0_res == AST_RTP_GLUE_RESULT_LOCAL || audio_glue1_res == AST_RTP_GLUE_RESULT_LOCAL) {
                ast_verb(3, "Locally bridging %s and %s\n", ast_channel_name(c0), ast_channel_name(c1));
-               res = local_bridge_loop(c0, c1, instance0, instance1, timeoutms, flags, fo, rc, c0->tech_pvt, c1->tech_pvt);
+               res = local_bridge_loop(c0, c1, instance0, instance1, timeoutms, flags, fo, rc, ast_channel_tech_pvt(c0), ast_channel_tech_pvt(c1));
        } else {
                ast_verb(3, "Remotely bridging %s and %s\n", ast_channel_name(c0), ast_channel_name(c1));
                res = remote_bridge_loop(c0, c1, instance0, instance1, vinstance0, vinstance1,
                                tinstance0, tinstance1, glue0, glue1, cap0, cap1, timeoutms, flags,
-                               fo, rc, c0->tech_pvt, c1->tech_pvt);
+                               fo, rc, ast_channel_tech_pvt(c0), ast_channel_tech_pvt(c1));
        }
 
        instance0->glue = NULL;
@@ -1460,7 +1460,7 @@ void ast_rtp_instance_early_bridge_make_compatible(struct ast_channel *c0, struc
        }
 
        /* Grab glue that binds each channel to something using the RTP engine */
-       if (!(glue0 = ast_rtp_instance_get_glue(c0->tech->type)) || !(glue1 = ast_rtp_instance_get_glue(c1->tech->type))) {
+       if (!(glue0 = ast_rtp_instance_get_glue(ast_channel_tech(c0)->type)) || !(glue1 = ast_rtp_instance_get_glue(ast_channel_tech(c1)->type))) {
                ast_debug(1, "Can't find native functions for channel '%s'\n", glue0 ? ast_channel_name(c1) : ast_channel_name(c0));
                goto done;
        }
@@ -1561,7 +1561,7 @@ int ast_rtp_instance_early_bridge(struct ast_channel *c0, struct ast_channel *c1
        }
 
        /* Grab glue that binds each channel to something using the RTP engine */
-       if (!(glue0 = ast_rtp_instance_get_glue(c0->tech->type)) || !(glue1 = ast_rtp_instance_get_glue(c1->tech->type))) {
+       if (!(glue0 = ast_rtp_instance_get_glue(ast_channel_tech(c0)->type)) || !(glue1 = ast_rtp_instance_get_glue(ast_channel_tech(c1)->type))) {
                ast_log(LOG_WARNING, "Can't find native functions for channel '%s'\n", glue0 ? ast_channel_name(c1) : ast_channel_name(c0));
                goto done;
        }
@@ -1735,7 +1735,7 @@ int ast_rtp_instance_make_compatible(struct ast_channel *chan, struct ast_rtp_in
 
        ast_channel_lock(peer);
 
-       if (!(glue = ast_rtp_instance_get_glue(peer->tech->type))) {
+       if (!(glue = ast_rtp_instance_get_glue(ast_channel_tech(peer)->type))) {
                ast_channel_unlock(peer);
                return -1;
        }
index be5fff10d610b4b8c1d9677a6dc5b403a622f0d8..6502cbc54c30ea69de023662d754add76b69c449 100644 (file)
@@ -1125,7 +1125,7 @@ static struct ast_udptl_protocol *get_proto(struct ast_channel *chan)
 
        AST_RWLIST_RDLOCK(&protos);
        AST_RWLIST_TRAVERSE(&protos, cur, list) {
-               if (cur->type == chan->tech->type)
+               if (cur->type == ast_channel_tech(chan)->type)
                        break;
        }
        AST_RWLIST_UNLOCK(&protos);
@@ -1170,8 +1170,8 @@ int ast_udptl_bridge(struct ast_channel *c0, struct ast_channel *c1, int flags,
                ast_channel_unlock(c1);
                return -1;
        }
-       pvt0 = c0->tech_pvt;
-       pvt1 = c1->tech_pvt;
+       pvt0 = ast_channel_tech_pvt(c0);
+       pvt1 = ast_channel_tech_pvt(c1);
        p0 = pr0->get_udptl_info(c0);
        p1 = pr1->get_udptl_info(c1);
        if (!p0 || !p1) {
@@ -1200,9 +1200,9 @@ int ast_udptl_bridge(struct ast_channel *c0, struct ast_channel *c1, int flags,
        cs[1] = c1;
        cs[2] = NULL;
        for (;;) {
-               if ((c0->tech_pvt != pvt0) ||
-                       (c1->tech_pvt != pvt1) ||
-                       (c0->masq || c0->masqr || c1->masq || c1->masqr)) {
+               if ((ast_channel_tech_pvt(c0) != pvt0) ||
+                       (ast_channel_tech_pvt(c1) != pvt1) ||
+                       (ast_channel_masq(c0) || ast_channel_masqr(c0) || ast_channel_masq(c1) || ast_channel_masqr(c1))) {
                                ast_debug(1, "Oooh, something is weird, backing out\n");
                                /* Tell it to try again later */
                                return -3;
index 276e4f51dc557f6081b51897e39d70ebc803a612..725fde923df22d8cdcb87aea2bc7838a7b05279b 100644 (file)
@@ -214,7 +214,7 @@ static int lua_pbx_exec(lua_State *L)
        
        context = ast_strdupa(ast_channel_context(chan));
        exten = ast_strdupa(ast_channel_exten(chan));
-       priority = chan->priority;
+       priority = ast_channel_priority(chan);
        
        lua_concat_args(L, 2, nargs);
        data = lua_tostring(L, -1);
@@ -254,9 +254,9 @@ static int lua_pbx_exec(lua_State *L)
                lua_pushstring(L, exten);
                lua_pushstring(L, ast_channel_exten(chan));
                lua_pushliteral(L, "exten");
-       } else if (priority != chan->priority) {
+       } else if (priority != ast_channel_priority(chan)) {
                lua_pushinteger(L, priority);
-               lua_pushinteger(L, chan->priority);
+               lua_pushinteger(L, ast_channel_priority(chan));
                lua_pushliteral(L, "priority");
        } else {
                /* no goto - restore the original position back
index 0ec850cd4f152973aac68d7a4ff3c6e4a7292410..cc8bfc503365c208264c3978650fe932078b3b1b 100644 (file)
@@ -352,7 +352,7 @@ static int realtime_exec(struct ast_channel *chan, const char *context, const ch
                                if(!ast_strlen_zero(tmp))
                                        pbx_substitute_variables_helper(chan, tmp, appdata, sizeof(appdata) - 1);
                                ast_verb(3, "Executing [%s@%s:%d] %s(\"%s\", \"%s\")\n",
-                                               ast_channel_exten(chan), ast_channel_context(chan), chan->priority,
+                                               ast_channel_exten(chan), ast_channel_context(chan), ast_channel_priority(chan),
                                                 term_color(tmp1, app, COLOR_BRCYAN, 0, sizeof(tmp1)),
                                                 term_color(tmp2, ast_channel_name(chan), COLOR_BRMAGENTA, 0, sizeof(tmp2)),
                                                 term_color(tmp3, S_OR(appdata, ""), COLOR_BRMAGENTA, 0, sizeof(tmp3)));
@@ -364,7 +364,7 @@ static int realtime_exec(struct ast_channel *chan, const char *context, const ch
                                                          "Application: %s\r\n"
                                                          "AppData: %s\r\n"
                                                          "Uniqueid: %s\r\n",
-                                                         ast_channel_name(chan), ast_channel_context(chan), ast_channel_exten(chan), chan->priority, app, !ast_strlen_zero(appdata) ? appdata : "(NULL)", ast_channel_uniqueid(chan));
+                                                         ast_channel_name(chan), ast_channel_context(chan), ast_channel_exten(chan), ast_channel_priority(chan), app, !ast_strlen_zero(appdata) ? appdata : "(NULL)", ast_channel_uniqueid(chan));
                                
                                res = pbx_exec(chan, a, appdata);
                        } else
index 327ab130d127e243b2e6d6cec46e1d582b02714e..0987b494a2f00e8158f547365ad6797fa2c1343c 100644 (file)
@@ -211,7 +211,7 @@ static int __adsi_transmit_messages(struct ast_channel *chan, unsigned char **ms
        char ack[3];
        struct ast_frame *f;
 
-       if (chan->adsicpe == AST_ADSI_UNAVAILABLE) {
+       if (ast_channel_adsicpe(chan) == AST_ADSI_UNAVAILABLE) {
                /* Don't bother if we know they don't support ADSI */
                errno = ENOSYS;
                return -1;
@@ -219,7 +219,7 @@ static int __adsi_transmit_messages(struct ast_channel *chan, unsigned char **ms
 
        while (retries < maxretries) {
                struct ast_format tmpfmt;
-               if (!(chan->adsicpe & ADSI_FLAG_DATAMODE)) {
+               if (!(ast_channel_adsicpe(chan) & ADSI_FLAG_DATAMODE)) {
                        /* Generate CAS (no SAS) */
                        ast_format_set(&tmpfmt, AST_FORMAT_ULAW, 0);
                        ast_gen_cas(buf, 0, 680, &tmpfmt);
@@ -235,8 +235,8 @@ static int __adsi_transmit_messages(struct ast_channel *chan, unsigned char **ms
                                if (((res = ast_waitfor(chan, waittime)) < 1)) {
                                        /* Didn't get back DTMF A in time */
                                        ast_debug(1, "No ADSI CPE detected (%d)\n", res);
-                                       if (!chan->adsicpe) {
-                                               chan->adsicpe = AST_ADSI_UNAVAILABLE;
+                                       if (!ast_channel_adsicpe(chan)) {
+                                               ast_channel_adsicpe_set(chan, AST_ADSI_UNAVAILABLE);
                                        }
                                        errno = ENOSYS;
                                        return -1;
@@ -249,8 +249,8 @@ static int __adsi_transmit_messages(struct ast_channel *chan, unsigned char **ms
                                if (f->frametype == AST_FRAME_DTMF) {
                                        if (f->subclass.integer == 'A') {
                                                /* Okay, this is an ADSI CPE.  Note this for future reference, too */
-                                               if (!chan->adsicpe) {
-                                                       chan->adsicpe = AST_ADSI_AVAILABLE;
+                                               if (!ast_channel_adsicpe(chan)) {
+                                                       ast_channel_adsicpe_set(chan, AST_ADSI_AVAILABLE);
                                                }
                                                break;
                                        } else {
@@ -259,8 +259,8 @@ static int __adsi_transmit_messages(struct ast_channel *chan, unsigned char **ms
                                                } else {
                                                        ast_log(LOG_WARNING, "Unknown ADSI response '%c'\n", f->subclass.integer);
                                                }
-                                               if (!chan->adsicpe) {
-                                                       chan->adsicpe = AST_ADSI_UNAVAILABLE;
+                                               if (!ast_channel_adsicpe(chan)) {
+                                                       ast_channel_adsicpe_set(chan, AST_ADSI_UNAVAILABLE);
                                                }
                                                errno = ENOSYS;
                                                ast_frfree(f);
@@ -367,7 +367,7 @@ int AST_OPTIONAL_API_NAME(ast_adsi_end_download)(struct ast_channel *chan)
 int AST_OPTIONAL_API_NAME(ast_adsi_transmit_message_full)(struct ast_channel *chan, unsigned char *msg, int msglen, int msgtype, int dowait)
 {
        unsigned char *msgs[5] = { NULL, NULL, NULL, NULL, NULL };
-       int msglens[5], msgtypes[5], newdatamode = (chan->adsicpe & ADSI_FLAG_DATAMODE), res, x, waitforswitch = 0;
+       int msglens[5], msgtypes[5], newdatamode = (ast_channel_adsicpe(chan) & ADSI_FLAG_DATAMODE), res, x, waitforswitch = 0;
        struct ast_format writeformat;
        struct ast_format readformat;
 
@@ -424,7 +424,7 @@ int AST_OPTIONAL_API_NAME(ast_adsi_transmit_message_full)(struct ast_channel *ch
        }
 
        if (!res) {
-               chan->adsicpe = (chan->adsicpe & ~ADSI_FLAG_DATAMODE) | newdatamode;
+               ast_channel_adsicpe_set(chan, (ast_channel_adsicpe(chan) & ~ADSI_FLAG_DATAMODE) | newdatamode);
        }
 
        if (writeformat.id) {
@@ -787,7 +787,7 @@ int AST_OPTIONAL_API_NAME(ast_adsi_voice_mode)(unsigned char *buf, int when)
 
 int AST_OPTIONAL_API_NAME(ast_adsi_available)(struct ast_channel *chan)
 {
-       int cpe = chan->adsicpe & 0xff;
+       int cpe = ast_channel_adsicpe(chan) & 0xff;
        if ((cpe == AST_ADSI_AVAILABLE) ||
            (cpe == AST_ADSI_UNKNOWN)) {
                return 1;
index 4440291612e1790d20b87d9b5338537e7d21fcdd..b8c39f929ad040e49fd4b478eda5528b71120483 100644 (file)
@@ -1726,7 +1726,7 @@ static void setup_env(struct ast_channel *chan, char *request, int fd, int enhan
        ast_agi_send(fd, chan, "agi_request: %s\n", request);
        ast_agi_send(fd, chan, "agi_channel: %s\n", ast_channel_name(chan));
        ast_agi_send(fd, chan, "agi_language: %s\n", ast_channel_language(chan));
-       ast_agi_send(fd, chan, "agi_type: %s\n", chan->tech->type);
+       ast_agi_send(fd, chan, "agi_type: %s\n", ast_channel_tech(chan)->type);
        ast_agi_send(fd, chan, "agi_uniqueid: %s\n", ast_channel_uniqueid(chan));
        ast_agi_send(fd, chan, "agi_version: %s\n", ast_get_version());
 
@@ -1747,7 +1747,7 @@ static void setup_env(struct ast_channel *chan, char *request, int fd, int enhan
        /* Context information */
        ast_agi_send(fd, chan, "agi_context: %s\n", ast_channel_context(chan));
        ast_agi_send(fd, chan, "agi_extension: %s\n", ast_channel_exten(chan));
-       ast_agi_send(fd, chan, "agi_priority: %d\n", chan->priority);
+       ast_agi_send(fd, chan, "agi_priority: %d\n", ast_channel_priority(chan));
        ast_agi_send(fd, chan, "agi_enhanced: %s\n", enhanced ? "1.0" : "0.0");
 
        /* User information */
@@ -1768,7 +1768,7 @@ static int handle_answer(struct ast_channel *chan, AGI *agi, int argc, const cha
        int res = 0;
 
        /* Answer the channel */
-       if (chan->_state != AST_STATE_UP)
+       if (ast_channel_state(chan) != AST_STATE_UP)
                res = ast_answer(chan);
 
        ast_agi_send(agi->fd, chan, "200 result=%d\n", res);
@@ -1975,7 +1975,7 @@ static int handle_streamfile(struct ast_channel *chan, AGI *agi, int argc, const
        res = ast_waitstream_full(chan, argv[3], agi->audio, agi->ctrl);
        /* this is to check for if ast_waitstream closed the stream, we probably are at
         * the end of the stream, return that amount, else check for the amount */
-       sample_offset = (chan->stream) ? ast_tellstream(fs) : max_length;
+       sample_offset = (ast_channel_stream(chan)) ? ast_tellstream(fs) : max_length;
        ast_stopstream(chan);
        if (res == 1) {
                /* Stop this command, don't print a result line, as there is a new command */
@@ -2002,9 +2002,9 @@ static int handle_getoption(struct ast_channel *chan, AGI *agi, int argc, const
 
        if ( argc == 5 )
                timeout = atoi(argv[4]);
-       else if (chan->pbx->dtimeoutms) {
+       else if (ast_channel_pbx(chan)->dtimeoutms) {
                /* by default dtimeout is set to 5sec */
-               timeout = chan->pbx->dtimeoutms; /* in msec */
+               timeout = ast_channel_pbx(chan)->dtimeoutms; /* in msec */
        }
 
        if (!(fs = ast_openstream(chan, argv[2], ast_channel_language(chan)))) {
@@ -2031,7 +2031,7 @@ static int handle_getoption(struct ast_channel *chan, AGI *agi, int argc, const
        res = ast_waitstream_full(chan, argv[3], agi->audio, agi->ctrl);
        /* this is to check for if ast_waitstream closed the stream, we probably are at
         * the end of the stream, return that amount, else check for the amount */
-       sample_offset = (chan->stream)?ast_tellstream(fs):max_length;
+       sample_offset = (ast_channel_stream(chan))?ast_tellstream(fs):max_length;
        ast_stopstream(chan);
        if (res == 1) {
                /* Stop this command, don't print a result line, as there is a new command */
@@ -2331,7 +2331,7 @@ static int handle_recordfile(struct ast_channel *chan, AGI *agi, int argc, const
                /* Request a video update */
                ast_indicate(chan, AST_CONTROL_VIDUPDATE);
 
-               chan->stream = fs;
+               ast_channel_stream_set(chan, fs);
                ast_applystream(chan,fs);
                /* really should have checks */
                ast_seekstream(fs, sample_offset, SEEK_SET);
@@ -2542,12 +2542,12 @@ static int handle_channelstatus(struct ast_channel *chan, AGI *agi, int argc, co
        struct ast_channel *c;
        if (argc == 2) {
                /* no argument: supply info on the current channel */
-               ast_agi_send(agi->fd, chan, "200 result=%d\n", chan->_state);
+               ast_agi_send(agi->fd, chan, "200 result=%d\n", ast_channel_state(chan));
                return RESULT_SUCCESS;
        } else if (argc == 3) {
                /* one argument: look for info on the specified channel */
                if ((c = ast_channel_get_by_name(argv[2]))) {
-                       ast_agi_send(agi->fd, chan, "200 result=%d\n", c->_state);
+                       ast_agi_send(agi->fd, chan, "200 result=%d\n", ast_channel_state(c));
                        c = ast_channel_unref(c);
                        return RESULT_SUCCESS;
                }
@@ -2955,10 +2955,10 @@ static int handle_speechrecognize(struct ast_channel *chan, AGI *agi, int argc,
        /* Go into loop reading in frames, passing to speech thingy, checking for hangup, all that jazz */
        while (ast_strlen_zero(reason)) {
                /* Run scheduled items */
-                ast_sched_runq(chan->sched);
+                ast_sched_runq(ast_channel_sched(chan));
 
                /* See maximum time of waiting */
-               if ((res = ast_sched_wait(chan->sched)) < 0)
+               if ((res = ast_sched_wait(ast_channel_sched(chan))) < 0)
                        res = 1000;
 
                /* Wait for frame */
@@ -2984,8 +2984,8 @@ static int handle_speechrecognize(struct ast_channel *chan, AGI *agi, int argc,
                ast_mutex_lock(&speech->lock);
 
                /* See if we need to quiet the audio stream playback */
-               if (ast_test_flag(speech, AST_SPEECH_QUIET) && chan->stream) {
-                       current_offset = ast_tellstream(chan->stream);
+               if (ast_test_flag(speech, AST_SPEECH_QUIET) && ast_channel_stream(chan)) {
+                       current_offset = ast_tellstream(ast_channel_stream(chan));
                        ast_stopstream(chan);
                        ast_clear_flag(speech, AST_SPEECH_QUIET);
                }
@@ -2994,7 +2994,7 @@ static int handle_speechrecognize(struct ast_channel *chan, AGI *agi, int argc,
                switch (speech->state) {
                case AST_SPEECH_STATE_READY:
                        /* If the stream is done, start timeout calculation */
-                       if ((timeout > 0) && start == 0 && ((!chan->stream) || (chan->streamid == -1 && chan->timingfunc == NULL))) {
+                       if ((timeout > 0) && start == 0 && ((!ast_channel_stream(chan)) || (ast_channel_streamid(chan) == -1 && chan->timingfunc == NULL))) {
                                ast_stopstream(chan);
                                time(&start);
                        }
@@ -3004,7 +3004,7 @@ static int handle_speechrecognize(struct ast_channel *chan, AGI *agi, int argc,
                        break;
                case AST_SPEECH_STATE_WAIT:
                        /* Cue waiting sound if not already playing */
-                       if ((!chan->stream) || (chan->streamid == -1 && chan->timingfunc == NULL)) {
+                       if ((!ast_channel_stream(chan)) || (ast_channel_streamid(chan) == -1 && chan->timingfunc == NULL)) {
                                ast_stopstream(chan);
                                /* If a processing sound exists, or is not none - play it */
                                if (!ast_strlen_zero(speech->processing_sound) && strcasecmp(speech->processing_sound, "none"))
@@ -3393,8 +3393,8 @@ static enum agi_result agi_handle_command(struct ast_channel *chan, AGI *agi, ch
                        ast_module_ref(c->mod);
                /* If the AGI command being executed is an actual application (using agi exec)
                the app field will be updated in pbx_exec via handle_exec */
-               if (chan->cdr && !ast_check_hangup(chan) && strcasecmp(argv[0], "EXEC"))
-                       ast_cdr_setapp(chan->cdr, "AGI", buf);
+               if (ast_channel_cdr(chan) && !ast_check_hangup(chan) && strcasecmp(argv[0], "EXEC"))
+                       ast_cdr_setapp(ast_channel_cdr(chan), "AGI", buf);
 
                res = c->handler(chan, agi, argc, argv);
                if (c->mod != ast_module_info->self)
index 382d34e087d73d600eb4b88c81861da8e165b749..e5a0d929ee73b94de212049b9800358392997c9a 100644 (file)
@@ -743,13 +743,13 @@ static void *do_notify(void *data)
                goto notify_cleanup;
        }
 
-       chan->tech = &null_tech;
+       ast_channel_tech_set(chan, &null_tech);
        ast_format_set(&chan->writeformat, AST_FORMAT_SLINEAR, 0);
        ast_format_set(&chan->readformat, AST_FORMAT_SLINEAR, 0);
        ast_format_set(&chan->rawwriteformat, AST_FORMAT_SLINEAR, 0);
        ast_format_set(&chan->rawreadformat, AST_FORMAT_SLINEAR, 0);
        /* clear native formats and set to slinear. write format is signlear so just use that to set it */
-       ast_format_cap_set(chan->nativeformats, &chan->writeformat);
+       ast_format_cap_set(ast_channel_nativeformats(chan), &chan->writeformat);
 
        if (!(datastore = ast_datastore_alloc(&event_notification_datastore, NULL))) {
                ast_log(LOG_ERROR, "Could not allocate datastore, notification not being sent!\n");
@@ -793,7 +793,7 @@ static void *do_notify(void *data)
                if (ast_strlen_zero(event->owner->notify_app)) {
                        ast_channel_context_set(answered, event->owner->notify_context);
                        ast_channel_exten_set(answered, event->owner->notify_extension);
-                       answered->priority = 1;
+                       ast_channel_priority_set(answered, 1);
                        ast_pbx_run(answered);
                }
        }
index 28b46a3cef4f3eeef71f2c41293b47ea845fddaf..cea74b726d55744d4d5269ca318e5f0397b8c025 100644 (file)
@@ -1882,7 +1882,7 @@ static int receivefax_exec(struct ast_channel *chan, const char *data)
        }
 
        /* make sure the channel is up */
-       if (chan->_state != AST_STATE_UP) {
+       if (ast_channel_state(chan) != AST_STATE_UP) {
                if (ast_answer(chan)) {
                        ast_string_field_set(details, resultstr, "error answering channel");
                        set_channel_variables(chan, details);
@@ -2374,7 +2374,7 @@ static int sendfax_exec(struct ast_channel *chan, const char *data)
        }
 
        /* make sure the channel is up */
-       if (chan->_state != AST_STATE_UP) {
+       if (ast_channel_state(chan) != AST_STATE_UP) {
                if (ast_answer(chan)) {
                        ast_string_field_set(details, resultstr, "error answering channel");
                        set_channel_variables(chan, details);
@@ -3097,7 +3097,7 @@ static struct ast_frame *fax_gateway_framehook(struct ast_channel *chan, struct
                /* framehooks are called in __ast_read() before frame format
                 * translation is done, so we need to translate here */
                if ((f->frametype == AST_FRAME_VOICE) && (f->subclass.format.id != AST_FORMAT_SLINEAR)) {
-                       if (active->readtrans && (f = ast_translate(active->readtrans, f, 1)) == NULL) {
+                       if (ast_channel_readtrans(active) && (f = ast_translate(ast_channel_readtrans(active), f, 1)) == NULL) {
                                f = &ast_null_frame;
                                ao2_ref(details, -1);
                                return f;
@@ -3109,7 +3109,7 @@ static struct ast_frame *fax_gateway_framehook(struct ast_channel *chan, struct
                 * write would fail, or even if a failure would be fatal so for
                 * now we'll just ignore the return value. */
                gateway->s->tech->write(gateway->s, f);
-               if ((f->frametype == AST_FRAME_VOICE) && (f->subclass.format.id != AST_FORMAT_SLINEAR) && active->readtrans) {
+               if ((f->frametype == AST_FRAME_VOICE) && (f->subclass.format.id != AST_FORMAT_SLINEAR) && ast_channel_readtrans(active)) {
                        /* Only free the frame if we translated / duplicated it - otherwise,
                         * let whatever is outside the frame hook do it */
                        ast_frfree(f);
index b87d0e7570780bfd10e9f8c15908635ebb5cb28a..045fa6aa71aaaa17df8c47bd06d58c977626a788 100644 (file)
@@ -267,11 +267,11 @@ static unsigned long seq = 0;
 static int ast_monitor_set_state(struct ast_channel *chan, int state)
 {
        LOCK_IF_NEEDED(chan, 1);
-       if (!chan->monitor) {
+       if (!ast_channel_monitor(chan)) {
                UNLOCK_IF_NEEDED(chan, 1);
                return -1;
        }
-       chan->monitor->state = state;
+       ast_channel_monitor(chan)->state = state;
        UNLOCK_IF_NEEDED(chan, 1);
        return 0;
 }
@@ -294,7 +294,7 @@ int AST_OPTIONAL_API_NAME(ast_monitor_start)(struct ast_channel *chan, const cha
 
        LOCK_IF_NEEDED(chan, need_lock);
 
-       if (!(chan->monitor)) {
+       if (!(ast_channel_monitor(chan))) {
                struct ast_channel_monitor *monitor;
                char *channel_name, *p;
 
@@ -386,7 +386,7 @@ int AST_OPTIONAL_API_NAME(ast_monitor_start)(struct ast_channel *chan, const cha
                } else
                        monitor->write_stream = NULL;
 
-               chan->monitor = monitor;
+               ast_channel_monitor_set(chan, monitor);
                ast_monitor_set_state(chan, AST_MONITOR_RUNNING);
                /* so we know this call has been monitored in case we need to bill for it or something */
                pbx_builtin_setvar_helper(chan, "__MONITORED","true");
@@ -438,43 +438,43 @@ int AST_OPTIONAL_API_NAME(ast_monitor_stop)(struct ast_channel *chan, int need_l
 
        LOCK_IF_NEEDED(chan, need_lock);
 
-       if (chan->monitor) {
+       if (ast_channel_monitor(chan)) {
                char filename[ FILENAME_MAX ];
 
-               if (chan->monitor->read_stream) {
-                       ast_closestream(chan->monitor->read_stream);
+               if (ast_channel_monitor(chan)->read_stream) {
+                       ast_closestream(ast_channel_monitor(chan)->read_stream);
                }
-               if (chan->monitor->write_stream) {
-                       ast_closestream(chan->monitor->write_stream);
+               if (ast_channel_monitor(chan)->write_stream) {
+                       ast_closestream(ast_channel_monitor(chan)->write_stream);
                }
 
-               if (chan->monitor->filename_changed && !ast_strlen_zero(chan->monitor->filename_base)) {
-                       if (ast_fileexists(chan->monitor->read_filename,NULL,NULL) > 0) {
-                               snprintf(filename, FILENAME_MAX, "%s-in", chan->monitor->filename_base);
+               if (ast_channel_monitor(chan)->filename_changed && !ast_strlen_zero(ast_channel_monitor(chan)->filename_base)) {
+                       if (ast_fileexists(ast_channel_monitor(chan)->read_filename,NULL,NULL) > 0) {
+                               snprintf(filename, FILENAME_MAX, "%s-in", ast_channel_monitor(chan)->filename_base);
                                if (ast_fileexists(filename, NULL, NULL) > 0) {
                                        ast_filedelete(filename, NULL);
                                }
-                               ast_filerename(chan->monitor->read_filename, filename, chan->monitor->format);
+                               ast_filerename(ast_channel_monitor(chan)->read_filename, filename, ast_channel_monitor(chan)->format);
                        } else {
-                               ast_log(LOG_WARNING, "File %s not found\n", chan->monitor->read_filename);
+                               ast_log(LOG_WARNING, "File %s not found\n", ast_channel_monitor(chan)->read_filename);
                        }
 
-                       if (ast_fileexists(chan->monitor->write_filename,NULL,NULL) > 0) {
-                               snprintf(filename, FILENAME_MAX, "%s-out", chan->monitor->filename_base);
+                       if (ast_fileexists(ast_channel_monitor(chan)->write_filename,NULL,NULL) > 0) {
+                               snprintf(filename, FILENAME_MAX, "%s-out", ast_channel_monitor(chan)->filename_base);
                                if (ast_fileexists(filename, NULL, NULL) > 0) {
                                        ast_filedelete(filename, NULL);
                                }
-                               ast_filerename(chan->monitor->write_filename, filename, chan->monitor->format);
+                               ast_filerename(ast_channel_monitor(chan)->write_filename, filename, ast_channel_monitor(chan)->format);
                        } else {
-                               ast_log(LOG_WARNING, "File %s not found\n", chan->monitor->write_filename);
+                               ast_log(LOG_WARNING, "File %s not found\n", ast_channel_monitor(chan)->write_filename);
                        }
                }
 
-               if (chan->monitor->joinfiles && !ast_strlen_zero(chan->monitor->filename_base)) {
+               if (ast_channel_monitor(chan)->joinfiles && !ast_strlen_zero(ast_channel_monitor(chan)->filename_base)) {
                        char tmp[1024];
                        char tmp2[1024];
-                       const char *format = !strcasecmp(chan->monitor->format,"wav49") ? "WAV" : chan->monitor->format;
-                       char *fname_base = chan->monitor->filename_base;
+                       const char *format = !strcasecmp(ast_channel_monitor(chan)->format,"wav49") ? "WAV" : ast_channel_monitor(chan)->format;
+                       char *fname_base = ast_channel_monitor(chan)->filename_base;
                        const char *execute, *execute_args;
                        /* at this point, fname_base really is the full path */
 
@@ -505,9 +505,9 @@ int AST_OPTIONAL_API_NAME(ast_monitor_stop)(struct ast_channel *chan, int need_l
                                ast_log(LOG_WARNING, "Execute of %s failed.\n",tmp);
                }
                
-               ast_free(chan->monitor->format);
-               ast_free(chan->monitor);
-               chan->monitor = NULL;
+               ast_free(ast_channel_monitor(chan)->format);
+               ast_free(ast_channel_monitor(chan));
+               ast_channel_monitor_set(chan, NULL);
 
                ast_manager_event(chan, EVENT_FLAG_CALL, "MonitorStop",
                                        "Channel: %s\r\n"
@@ -566,11 +566,11 @@ int AST_OPTIONAL_API_NAME(ast_monitor_change_fname)(struct ast_channel *chan, co
 
        LOCK_IF_NEEDED(chan, need_lock);
 
-       if (chan->monitor) {
+       if (ast_channel_monitor(chan)) {
                int directory = strchr(fname_base, '/') ? 1 : 0;
                const char *absolute = *fname_base == '/' ? "" : ast_config_AST_MONITOR_DIR;
                const char *absolute_suffix = *fname_base == '/' ? "" : "/";
-               char tmpstring[sizeof(chan->monitor->filename_base)] = "";
+               char tmpstring[sizeof(ast_channel_monitor(chan)->filename_base)] = "";
                int i, fd[2] = { -1, -1 }, doexit = 0;
 
                /* before continuing, see if we're trying to rename the file to itself... */
@@ -594,10 +594,10 @@ int AST_OPTIONAL_API_NAME(ast_monitor_change_fname)(struct ast_channel *chan, co
                 * the file without the format suffix), so it does not already exist
                 * and we aren't interfering with the recording itself.
                 */
-               ast_debug(2, "comparing tmpstring %s to filename_base %s\n", tmpstring, chan->monitor->filename_base);
+               ast_debug(2, "comparing tmpstring %s to filename_base %s\n", tmpstring, ast_channel_monitor(chan)->filename_base);
                
                if ((fd[0] = open(tmpstring, O_CREAT | O_WRONLY, 0644)) < 0 ||
-                       (fd[1] = open(chan->monitor->filename_base, O_CREAT | O_EXCL | O_WRONLY, 0644)) < 0) {
+                       (fd[1] = open(ast_channel_monitor(chan)->filename_base, O_CREAT | O_EXCL | O_WRONLY, 0644)) < 0) {
                        if (fd[0] < 0) {
                                ast_log(LOG_ERROR, "Unable to compare filenames: %s\n", strerror(errno));
                        } else {
@@ -614,15 +614,15 @@ int AST_OPTIONAL_API_NAME(ast_monitor_change_fname)(struct ast_channel *chan, co
                }
                unlink(tmpstring);
                /* if previous monitor file existed in a subdirectory, the directory will not be removed */
-               unlink(chan->monitor->filename_base);
+               unlink(ast_channel_monitor(chan)->filename_base);
 
                if (doexit) {
                        UNLOCK_IF_NEEDED(chan, need_lock);
                        return 0;
                }
 
-               ast_copy_string(chan->monitor->filename_base, tmpstring, sizeof(chan->monitor->filename_base));
-               chan->monitor->filename_changed = 1;
+               ast_copy_string(ast_channel_monitor(chan)->filename_base, tmpstring, sizeof(ast_channel_monitor(chan)->filename_base));
+               ast_channel_monitor(chan)->filename_changed = 1;
        } else {
                ast_log(LOG_WARNING, "Cannot change monitor filename of channel %s to %s, monitoring not started\n", ast_channel_name(chan), fname_base);
        }
@@ -685,13 +685,15 @@ static int start_monitor_exec(struct ast_channel *chan, const char *data)
        }
 
        if (!ast_strlen_zero(urlprefix) && !ast_strlen_zero(args.fname_base)) {
+               struct ast_cdr *chan_cdr;
                snprintf(tmp, sizeof(tmp), "%s/%s.%s", urlprefix, args.fname_base,
                        ((strcmp(args.format, "gsm")) ? "wav" : "gsm"));
                ast_channel_lock(chan);
-               if (!chan->cdr && !(chan->cdr = ast_cdr_alloc())) {
+               if (!ast_channel_cdr(chan) && !(chan_cdr = ast_cdr_alloc())) {
                        ast_channel_unlock(chan);
                        return -1;
                }
+               ast_channel_cdr_set(chan, chan_cdr);
                ast_cdr_setuserfield(chan, tmp);
                ast_channel_unlock(chan);
        }
@@ -860,8 +862,8 @@ static int change_monitor_action(struct mansession *s, const struct message *m)
 
 void AST_OPTIONAL_API_NAME(ast_monitor_setjoinfiles)(struct ast_channel *chan, int turnon)
 {
-       if (chan->monitor)
-               chan->monitor->joinfiles = turnon;
+       if (ast_channel_monitor(chan))
+               ast_channel_monitor(chan)->joinfiles = turnon;
 }
 
 enum MONITOR_PAUSING_ACTION
index e505c3ee17c36420249c824465142e924c3f44bd..eb4330e21792e7ce33e5a976d7d656c48e662408 100644 (file)
@@ -260,15 +260,15 @@ static void moh_files_release(struct ast_channel *chan, void *data)
 {
        struct moh_files_state *state;
 
-       if (!chan || !chan->music_state) {
+       if (!chan || !ast_channel_music_state(chan)) {
                return;
        }
 
-       state = chan->music_state;
+       state = ast_channel_music_state(chan);
 
-       if (chan->stream) {
-               ast_closestream(chan->stream);
-               chan->stream = NULL;
+       if (ast_channel_stream(chan)) {
+               ast_closestream(ast_channel_stream(chan));
+               ast_channel_stream_set(chan, NULL);
        }
        
        ast_verb(3, "Stopped music on hold on %s\n", ast_channel_name(chan));
@@ -286,13 +286,13 @@ static void moh_files_release(struct ast_channel *chan, void *data)
 
 static int ast_moh_files_next(struct ast_channel *chan) 
 {
-       struct moh_files_state *state = chan->music_state;
+       struct moh_files_state *state = ast_channel_music_state(chan);
        int tries;
 
        /* Discontinue a stream if it is running already */
-       if (chan->stream) {
-               ast_closestream(chan->stream);
-               chan->stream = NULL;
+       if (ast_channel_stream(chan)) {
+               ast_closestream(ast_channel_stream(chan));
+               ast_channel_stream_set(chan, NULL);
        }
 
        if (ast_test_flag(state->class, MOH_ANNOUNCEMENT) && state->announcement == 0) {
@@ -357,13 +357,13 @@ static int ast_moh_files_next(struct ast_channel *chan)
        if (state->samples) {
                size_t loc;
                /* seek *SHOULD* be good since it's from a known location */
-               ast_seekstream(chan->stream, state->samples, SEEK_SET);
+               ast_seekstream(ast_channel_stream(chan), state->samples, SEEK_SET);
                /* if the seek failed then recover because if there is not a valid read,
                 * moh_files_generate will return -1 and MOH will stop */
-               loc = ast_tellstream(chan->stream);
+               loc = ast_tellstream(ast_channel_stream(chan));
                if (state->samples > loc && loc) {
                        /* seek one sample from the end for one guaranteed valid read */
-                       ast_seekstream(chan->stream, 1, SEEK_END);
+                       ast_seekstream(ast_channel_stream(chan), 1, SEEK_END);
                }
        }
 
@@ -374,9 +374,9 @@ static struct ast_frame *moh_files_readframe(struct ast_channel *chan)
 {
        struct ast_frame *f = NULL;
 
-       if (!(chan->stream && (f = ast_readframe(chan->stream)))) {
+       if (!(ast_channel_stream(chan) && (f = ast_readframe(ast_channel_stream(chan))))) {
                if (!ast_moh_files_next(chan))
-                       f = ast_readframe(chan->stream);
+                       f = ast_readframe(ast_channel_stream(chan));
        }
 
        return f;
@@ -384,7 +384,7 @@ static struct ast_frame *moh_files_readframe(struct ast_channel *chan)
 
 static void moh_files_write_format_change(struct ast_channel *chan, void *data)
 {
-       struct moh_files_state *state = chan->music_state;
+       struct moh_files_state *state = ast_channel_music_state(chan);
 
        /* In order to prevent a recursive call to this function as a result
         * of setting the moh write format back on the channel. Clear
@@ -403,7 +403,7 @@ static void moh_files_write_format_change(struct ast_channel *chan, void *data)
 
 static int moh_files_generator(struct ast_channel *chan, void *data, int len, int samples)
 {
-       struct moh_files_state *state = chan->music_state;
+       struct moh_files_state *state = ast_channel_music_state(chan);
        struct ast_frame *f = NULL;
        int res = 0;
 
@@ -443,11 +443,11 @@ static void *moh_files_alloc(struct ast_channel *chan, void *params)
        struct moh_files_state *state;
        struct mohclass *class = params;
 
-       if (!chan->music_state && (state = ast_calloc(1, sizeof(*state)))) {
-               chan->music_state = state;
+       if (!ast_channel_music_state(chan) && (state = ast_calloc(1, sizeof(*state)))) {
+               ast_channel_music_state_set(chan, state);
                ast_module_ref(ast_module_info->self);
        } else {
-               state = chan->music_state;
+               state = ast_channel_music_state(chan);
                if (!state) {
                        return NULL;
                }
@@ -479,7 +479,7 @@ static void *moh_files_alloc(struct ast_channel *chan, void *params)
 
        ast_verb(3, "Started music on hold, class '%s', on %s\n", class->name, ast_channel_name(chan));
        
-       return chan->music_state;
+       return ast_channel_music_state(chan);
 }
 
 static int moh_digit_match(void *obj, void *arg, int flags)
@@ -956,7 +956,7 @@ static void moh_release(struct ast_channel *chan, void *data)
        if (chan) {
                struct moh_files_state *state;
 
-               state = chan->music_state;
+               state = ast_channel_music_state(chan);
                if (state && state->class) {
                        state->class = mohclass_unref(state->class, "Unreffing channel's music class upon deactivation of generator");
                }
@@ -976,11 +976,11 @@ static void *moh_alloc(struct ast_channel *chan, void *params)
        struct moh_files_state *state;
 
        /* Initiating music_state for current channel. Channel should know name of moh class */
-       if (!chan->music_state && (state = ast_calloc(1, sizeof(*state)))) {
-               chan->music_state = state;
+       if (!ast_channel_music_state(chan) && (state = ast_calloc(1, sizeof(*state)))) {
+               ast_channel_music_state_set(chan, state);
                ast_module_ref(ast_module_info->self);
        } else {
-               state = chan->music_state;
+               state = ast_channel_music_state(chan);
                if (!state) {
                        return NULL;
                }
@@ -1312,7 +1312,7 @@ static int _moh_register(struct mohclass *moh, int reload, int unref, const char
 
 static void local_ast_moh_cleanup(struct ast_channel *chan)
 {
-       struct moh_files_state *state = chan->music_state;
+       struct moh_files_state *state = ast_channel_music_state(chan);
 
        if (state) {
                if (state->class) {
@@ -1321,8 +1321,8 @@ static void local_ast_moh_cleanup(struct ast_channel *chan)
                                mohclass_unref(state->class, "Uh Oh. Cleaning up MOH with an active class");
                        ast_log(LOG_WARNING, "Uh Oh. Cleaning up MOH with an active class\n");
                }
-               ast_free(chan->music_state);
-               chan->music_state = NULL;
+               ast_free(ast_channel_music_state(chan));
+               ast_channel_music_state_set(chan, NULL);
                /* Only held a module reference if we had a music state */
                ast_module_unref(ast_module_info->self);
        }
@@ -1355,7 +1355,7 @@ static struct mohclass *_moh_class_malloc(const char *file, int line, const char
 static int local_ast_moh_start(struct ast_channel *chan, const char *mclass, const char *interpclass)
 {
        struct mohclass *mohclass = NULL;
-       struct moh_files_state *state = chan->music_state;
+       struct moh_files_state *state = ast_channel_music_state(chan);
        struct ast_variable *var = NULL;
        int res;
        int realtime_possible = ast_check_realtime("musiconhold");
@@ -1578,10 +1578,10 @@ static void local_ast_moh_stop(struct ast_channel *chan)
        ast_deactivate_generator(chan);
 
        ast_channel_lock(chan);
-       if (chan->music_state) {
-               if (chan->stream) {
-                       ast_closestream(chan->stream);
-                       chan->stream = NULL;
+       if (ast_channel_music_state(chan)) {
+               if (ast_channel_stream(chan)) {
+                       ast_closestream(ast_channel_stream(chan));
+                       ast_channel_stream_set(chan, NULL);
                }
        }
 
index d804d2cb0bde0ac888d840c8745585a12874328e..17e3980b06a84bdddbb6793db9612285729d5240 100644 (file)
@@ -2716,7 +2716,7 @@ static int ast_rtp_dtmf_compatible(struct ast_channel *chan0, struct ast_rtp_ins
         * --------------------------------------------------
         */
        return (((ast_rtp_instance_get_prop(instance0, AST_RTP_PROPERTY_DTMF) != ast_rtp_instance_get_prop(instance1, AST_RTP_PROPERTY_DTMF)) ||
-                (!chan0->tech->send_digit_begin != !chan1->tech->send_digit_begin)) ? 0 : 1);
+                (!ast_channel_tech(chan0)->send_digit_begin != !ast_channel_tech(chan1)->send_digit_begin)) ? 0 : 1);
 }
 
 static void ast_rtp_stun_request(struct ast_rtp_instance *instance, struct ast_sockaddr *suggestion, const char *username)
index 9d02a7a5bc3595d563eb98656d52099531d1cf98..3c0c48e1be747754bbb84e1bd2dc0086c5bcfe20 100644 (file)
@@ -284,7 +284,7 @@ static u_char *ast_var_channels_table(struct variable *vp, oid *name, size_t *le
                }
                break;
        case ASTCHANTYPE:
-               strncpy(string_ret, chan->tech->type, sizeof(string_ret));
+               strncpy(string_ret, ast_channel_tech(chan)->type, sizeof(string_ret));
                string_ret[sizeof(string_ret) - 1] = '\0';
                *var_len = strlen(string_ret);
                ret = (u_char *)string_ret;
@@ -306,16 +306,16 @@ static u_char *ast_var_channels_table(struct variable *vp, oid *name, size_t *le
                }
                break;
        case ASTCHANMASQ:
-               if (chan->masq && !ast_strlen_zero(ast_channel_name(chan->masq))) {
-                       strncpy(string_ret, ast_channel_name(chan->masq), sizeof(string_ret));
+               if (ast_channel_masq(chan) && !ast_strlen_zero(ast_channel_name(ast_channel_masq(chan)))) {
+                       strncpy(string_ret, ast_channel_name(ast_channel_masq(chan)), sizeof(string_ret));
                        string_ret[sizeof(string_ret) - 1] = '\0';
                        *var_len = strlen(string_ret);
                        ret = (u_char *)string_ret;
                }
                break;
        case ASTCHANMASQR:
-               if (chan->masqr && !ast_strlen_zero(ast_channel_name(chan->masqr))) {
-                       strncpy(string_ret, ast_channel_name(chan->masqr), sizeof(string_ret));
+               if (ast_channel_masqr(chan) && !ast_strlen_zero(ast_channel_name(ast_channel_masqr(chan)))) {
+                       strncpy(string_ret, ast_channel_name(ast_channel_masqr(chan)), sizeof(string_ret));
                        string_ret[sizeof(string_ret) - 1] = '\0';
                        *var_len = strlen(string_ret);
                        ret = (u_char *)string_ret;
@@ -363,7 +363,7 @@ static u_char *ast_var_channels_table(struct variable *vp, oid *name, size_t *le
                ret = (u_char *)string_ret;
                break;
        case ASTCHANMACROPRI:
-               long_ret = chan->macropriority;
+               long_ret = ast_channel_macropriority(chan);
                ret = (u_char *)&long_ret;
                break;
        case ASTCHANEXTEN:
@@ -373,7 +373,7 @@ static u_char *ast_var_channels_table(struct variable *vp, oid *name, size_t *le
                ret = (u_char *)string_ret;
                break;
        case ASTCHANPRI:
-               long_ret = chan->priority;
+               long_ret = ast_channel_priority(chan);
                ret = (u_char *)&long_ret;
                break;
        case ASTCHANACCOUNTCODE:
@@ -407,15 +407,15 @@ static u_char *ast_var_channels_table(struct variable *vp, oid *name, size_t *le
                ret = (u_char *)&long_ret;
                break;
        case ASTCHANSTATE:
-               long_ret = chan->_state & 0xffff;
+               long_ret = ast_channel_state(chan) & 0xffff;
                ret = (u_char *)&long_ret;
                break;
        case ASTCHANMUTED:
-               long_ret = chan->_state & AST_STATE_MUTE ? 1 : 2;
+               long_ret = ast_channel_state(chan) & AST_STATE_MUTE ? 1 : 2;
                ret = (u_char *)&long_ret;
                break;
        case ASTCHANRINGS:
-               long_ret = chan->rings;
+               long_ret = ast_channel_rings(chan);
                ret = (u_char *)&long_ret;
                break;
        case ASTCHANCIDDNID:
@@ -475,23 +475,23 @@ static u_char *ast_var_channels_table(struct variable *vp, oid *name, size_t *le
                ret = (u_char *)&long_ret;
                break;
        case ASTCHANAMAFLAGS:
-               long_ret = chan->amaflags;
+               long_ret = ast_channel_amaflags(chan);
                ret = (u_char *)&long_ret;
                break;
        case ASTCHANADSI:
-               long_ret = chan->adsicpe;
+               long_ret = ast_channel_adsicpe(chan);
                ret = (u_char *)&long_ret;
                break;
        case ASTCHANTONEZONE:
-               if (chan->zone) {
-                       strncpy(string_ret, chan->zone->country, sizeof(string_ret));
+               if (ast_channel_zone(chan)) {
+                       strncpy(string_ret, ast_channel_zone(chan)->country, sizeof(string_ret));
                        string_ret[sizeof(string_ret) - 1] = '\0';
                        *var_len = strlen(string_ret);
                        ret = (u_char *)string_ret;
                }
                break;
        case ASTCHANHANGUPCAUSE:
-               long_ret = chan->hangupcause;
+               long_ret = ast_channel_hangupcause(chan);
                ret = (u_char *)&long_ret;
                break;
        case ASTCHANVARIABLES:
@@ -511,7 +511,7 @@ static u_char *ast_var_channels_table(struct variable *vp, oid *name, size_t *le
                ret = bits_ret;
                break;
        case ASTCHANTRANSFERCAP:
-               long_ret = chan->transfercapability;
+               long_ret = ast_channel_transfercapability(chan);
                ret = (u_char *)&long_ret;
        default:
                break;
@@ -593,7 +593,7 @@ static u_char *ast_var_channel_types_table(struct variable *vp, oid *name, size_
                }
 
                while ((chan = ast_channel_iterator_next(iter))) {
-                       if (chan->tech == tech) {
+                       if (ast_channel_tech(chan) == tech) {
                                long_ret++;
                        }
                        chan = ast_channel_unref(chan);