summaryrefslogtreecommitdiff
path: root/channels
diff options
context:
space:
mode:
Diffstat (limited to 'channels')
-rwxr-xr-xchannels/chan_agent.c131
-rwxr-xr-xchannels/chan_alsa.c59
-rwxr-xr-xchannels/chan_features.c85
-rwxr-xr-xchannels/chan_h323.c97
-rwxr-xr-xchannels/chan_iax2.c103
-rwxr-xr-xchannels/chan_local.c100
-rwxr-xr-xchannels/chan_mgcp.c90
-rwxr-xr-xchannels/chan_modem.c69
-rwxr-xr-xchannels/chan_nbs.c56
-rwxr-xr-xchannels/chan_oss.c58
-rwxr-xr-xchannels/chan_phone.c132
-rwxr-xr-xchannels/chan_sip.c114
-rwxr-xr-xchannels/chan_skinny.c90
-rwxr-xr-xchannels/chan_vpb.c100
-rwxr-xr-xchannels/chan_zap.c139
15 files changed, 848 insertions, 575 deletions
diff --git a/channels/chan_agent.c b/channels/chan_agent.c
index c6b137e73..6812e213e 100755
--- a/channels/chan_agent.c
+++ b/channels/chan_agent.c
@@ -15,7 +15,6 @@
#include <string.h>
#include <asterisk/lock.h>
#include <asterisk/channel.h>
-#include <asterisk/channel_pvt.h>
#include <asterisk/config.h>
#include <asterisk/logger.h>
#include <asterisk/module.h>
@@ -45,20 +44,20 @@
#include <arpa/inet.h>
#include <sys/signal.h>
-static char *desc = "Agent Proxy Channel";
-static char *channeltype = "Agent";
-static char *tdesc = "Call Agent Proxy Channel";
-static char *config = "agents.conf";
+static const char desc[] = "Agent Proxy Channel";
+static const char channeltype[] = "Agent";
+static const char tdesc[] = "Call Agent Proxy Channel";
+static const char config[] = "agents.conf";
-static char *app = "AgentLogin";
-static char *app2 = "AgentCallbackLogin";
-static char *app3 = "AgentMonitorOutgoing";
+static const char app[] = "AgentLogin";
+static const char app2[] = "AgentCallbackLogin";
+static const char app3[] = "AgentMonitorOutgoing";
-static char *synopsis = "Call agent login";
-static char *synopsis2 = "Call agent callback login";
-static char *synopsis3 = "Record agent's outgoing call";
+static const char synopsis[] = "Call agent login";
+static const char synopsis2[] = "Call agent callback login";
+static const char synopsis3[] = "Record agent's outgoing call";
-static char *descrip =
+static const char descrip[] =
" AgentLogin([AgentNo][|options]):\n"
"Asks the agent to login to the system. Always returns -1. While\n"
"logged in, the agent can receive calls and will hear a 'beep'\n"
@@ -67,17 +66,15 @@ static char *descrip =
"The option string may contain zero or more of the following characters:\n"
" 's' -- silent login - do not announce the login ok segment after agent logged in/off\n";
-static char *descrip2 =
+static const char descrip2[] =
" AgentCallbackLogin([AgentNo][|[options][exten]@context]):\n"
"Asks the agent to login to the system with callback.\n"
"The agent's callback extension is called (optionally with the specified\n"
"context).\n"
"The option string may contain zero or more of the following characters:\n"
" 's' -- silent login - do not announce the login ok segment agent logged in/off\n";
-
-
-static char *descrip3 =
+static const char descrip3[] =
" AgentMonitorOutgoing([options]):\n"
"Tries to figure out the id of the agent who is placing outgoing call based on\n"
"comparision of the callerid of the current interface and the global variable \n"
@@ -95,7 +92,7 @@ static char *descrip3 =
" agentid is not known.\n"
" It's handy if you want to have one context for agent and non-agent calls.\n";
-static char mandescr_agents[] =
+static const char mandescr_agents[] =
"Description: Will list info about all possible agents.\n"
"Variables: NONE\n";
@@ -106,15 +103,13 @@ static char moh[80] = "default";
#define AST_MAX_FILENAME_LEN 256
/* Persistent Agents astdb family */
-static const char *pa_family = "/Agents";
+static const char pa_family[] = "/Agents";
/* The maximum lengh of each persistent member agent database entry */
#define PA_MAX_LEN 2048
/* queues.conf [general] option */
static int persistent_agents = 0;
static void dump_agents(void);
-static int capability = -1;
-
static ast_group_t group;
static int autologoff;
static int wrapuptime;
@@ -176,10 +171,10 @@ static struct agent_pvt {
ast_set_read_format(ast, ast->readformat); \
ast_set_write_format(ast, ast->writeformat); \
} \
- if (p->chan->readformat != ast->pvt->rawreadformat) \
- ast_set_read_format(p->chan, ast->pvt->rawreadformat); \
- if (p->chan->writeformat != ast->pvt->rawwriteformat) \
- ast_set_write_format(p->chan, ast->pvt->rawwriteformat); \
+ if (p->chan->readformat != ast->rawreadformat) \
+ ast_set_read_format(p->chan, ast->rawreadformat); \
+ if (p->chan->writeformat != ast->rawwriteformat) \
+ ast_set_write_format(p->chan, ast->rawwriteformat); \
} \
} while(0)
@@ -198,7 +193,37 @@ static struct agent_pvt {
} \
} while(0)
-
+static struct ast_channel *agent_request(const char *type, int format, void *data, int *cause);
+static int agent_devicestate(void *data);
+static int agent_digit(struct ast_channel *ast, char digit);
+static int agent_call(struct ast_channel *ast, char *dest, int timeout);
+static int agent_hangup(struct ast_channel *ast);
+static int agent_answer(struct ast_channel *ast);
+static struct ast_frame *agent_read(struct ast_channel *ast);
+static int agent_write(struct ast_channel *ast, struct ast_frame *f);
+static int agent_sendhtml(struct ast_channel *ast, int subclass, char *data, int datalen);
+static int agent_indicate(struct ast_channel *ast, int condition);
+static int agent_fixup(struct ast_channel *oldchan, struct ast_channel *newchan);
+static struct ast_channel *agent_bridgedchannel(struct ast_channel *chan, struct ast_channel *bridge);
+
+static const struct ast_channel_tech agent_tech = {
+ .type = channeltype,
+ .description = tdesc,
+ .capabilities = -1,
+ .requester = agent_request,
+ .devicestate = agent_devicestate,
+ .send_digit = agent_digit,
+ .call = agent_call,
+ .hangup = agent_hangup,
+ .answer = agent_answer,
+ .read = agent_read,
+ .write = agent_write,
+ .send_html = agent_sendhtml,
+ .exception = agent_read,
+ .indicate = agent_indicate,
+ .fixup = agent_fixup,
+ .bridged_channel = agent_bridgedchannel,
+};
static void agent_unlink(struct agent_pvt *agent)
{
@@ -281,7 +306,7 @@ static int agent_cleanup(struct agent_pvt *p)
{
struct ast_channel *chan = p->owner;
p->owner = NULL;
- chan->pvt->pvt = NULL;
+ chan->tech_pvt = NULL;
p->app_sleep_cond = 1;
/* Release ownership of the agent to other threads (presumably running the login app). */
ast_mutex_unlock(&p->app_lock);
@@ -333,12 +358,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->pvt->pvt, needlock);
+ return __agent_start_monitoring(ast, ast->tech_pvt, needlock);
}
static struct ast_frame *agent_read(struct ast_channel *ast)
{
- struct agent_pvt *p = ast->pvt->pvt;
+ struct agent_pvt *p = ast->tech_pvt;
struct ast_frame *f = NULL;
static struct ast_frame null_frame = { AST_FRAME_NULL, };
static struct ast_frame answer_frame = { AST_FRAME_CONTROL, AST_CONTROL_ANSWER };
@@ -427,7 +452,7 @@ static struct ast_frame *agent_read(struct ast_channel *ast)
static int agent_sendhtml(struct ast_channel *ast, int subclass, char *data, int datalen)
{
- struct agent_pvt *p = ast->pvt->pvt;
+ struct agent_pvt *p = ast->tech_pvt;
int res = -1;
ast_mutex_lock(&p->lock);
if (p->chan)
@@ -438,7 +463,7 @@ static int agent_sendhtml(struct ast_channel *ast, int subclass, char *data, int
static int agent_write(struct ast_channel *ast, struct ast_frame *f)
{
- struct agent_pvt *p = ast->pvt->pvt;
+ struct agent_pvt *p = ast->tech_pvt;
int res = -1;
CHECK_FORMATS(ast, p);
ast_mutex_lock(&p->lock);
@@ -459,7 +484,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->pvt->pvt;
+ struct agent_pvt *p = newchan->tech_pvt;
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);
@@ -473,7 +498,7 @@ static int agent_fixup(struct ast_channel *oldchan, struct ast_channel *newchan)
static int agent_indicate(struct ast_channel *ast, int condition)
{
- struct agent_pvt *p = ast->pvt->pvt;
+ struct agent_pvt *p = ast->tech_pvt;
int res = -1;
ast_mutex_lock(&p->lock);
if (p->chan)
@@ -486,11 +511,11 @@ static int agent_indicate(struct ast_channel *ast, int condition)
static int agent_digit(struct ast_channel *ast, char digit)
{
- struct agent_pvt *p = ast->pvt->pvt;
+ struct agent_pvt *p = ast->tech_pvt;
int res = -1;
ast_mutex_lock(&p->lock);
if (p->chan)
- res = p->chan->pvt->send_digit(p->chan, digit);
+ res = p->chan->tech->send_digit(p->chan, digit);
else
res = 0;
ast_mutex_unlock(&p->lock);
@@ -499,7 +524,7 @@ static int agent_digit(struct ast_channel *ast, char digit)
static int agent_call(struct ast_channel *ast, char *dest, int timeout)
{
- struct agent_pvt *p = ast->pvt->pvt;
+ struct agent_pvt *p = ast->tech_pvt;
int res = -1;
int newstate=0;
ast_mutex_lock(&p->lock);
@@ -586,11 +611,11 @@ static int agent_call(struct ast_channel *ast, char *dest, int timeout)
static int agent_hangup(struct ast_channel *ast)
{
- struct agent_pvt *p = ast->pvt->pvt;
+ struct agent_pvt *p = ast->tech_pvt;
int howlong = 0;
ast_mutex_lock(&p->lock);
p->owner = NULL;
- ast->pvt->pvt = NULL;
+ ast->tech_pvt = NULL;
p->app_sleep_cond = 1;
p->acknowledged = 0;
@@ -783,7 +808,7 @@ static struct ast_channel *agent_bridgedchannel(struct ast_channel *chan, struct
struct ast_channel *ret=NULL;
- p = bridge->pvt->pvt;
+ p = bridge->tech_pvt;
if (chan == p->chan)
ret = bridge->_bridge;
else if (chan == bridge->_bridge)
@@ -806,21 +831,22 @@ static struct ast_channel *agent_new(struct agent_pvt *p, int state)
#endif
tmp = ast_channel_alloc(0);
if (tmp) {
+ tmp->tech = &agent_tech;
if (p->chan) {
tmp->nativeformats = p->chan->nativeformats;
tmp->writeformat = p->chan->writeformat;
- tmp->pvt->rawwriteformat = p->chan->writeformat;
+ tmp->rawwriteformat = p->chan->writeformat;
tmp->readformat = p->chan->readformat;
- tmp->pvt->rawreadformat = p->chan->readformat;
+ tmp->rawreadformat = p->chan->readformat;
strncpy(tmp->language, p->chan->language, sizeof(tmp->language)-1);
strncpy(tmp->context, p->chan->context, sizeof(tmp->context)-1);
strncpy(tmp->exten, p->chan->exten, sizeof(tmp->exten)-1);
} else {
tmp->nativeformats = AST_FORMAT_SLINEAR;
tmp->writeformat = AST_FORMAT_SLINEAR;
- tmp->pvt->rawwriteformat = AST_FORMAT_SLINEAR;
+ tmp->rawwriteformat = AST_FORMAT_SLINEAR;
tmp->readformat = AST_FORMAT_SLINEAR;
- tmp->pvt->rawreadformat = AST_FORMAT_SLINEAR;
+ tmp->rawreadformat = AST_FORMAT_SLINEAR;
}
if (p->pending)
snprintf(tmp->name, sizeof(tmp->name), "Agent/P%s-%d", p->agent, rand() & 0xffff);
@@ -829,18 +855,7 @@ static struct ast_channel *agent_new(struct agent_pvt *p, int state)
tmp->type = channeltype;
/* Safe, agentlock already held */
ast_setstate(tmp, state);
- tmp->pvt->pvt = p;
- tmp->pvt->send_digit = agent_digit;
- tmp->pvt->call = agent_call;
- tmp->pvt->hangup = agent_hangup;
- tmp->pvt->answer = agent_answer;
- tmp->pvt->read = agent_read;
- tmp->pvt->write = agent_write;
- tmp->pvt->send_html = agent_sendhtml;
- tmp->pvt->exception = agent_read;
- tmp->pvt->indicate = agent_indicate;
- tmp->pvt->fixup = agent_fixup;
- tmp->pvt->bridged_channel = agent_bridgedchannel;
+ tmp->tech_pvt = p;
p->owner = tmp;
ast_mutex_lock(&usecnt_lock);
usecnt++;
@@ -867,7 +882,7 @@ static struct ast_channel *agent_new(struct agent_pvt *p, int state)
{
ast_log(LOG_WARNING, "Agent disconnected while we were connecting the call\n");
p->owner = NULL;
- tmp->pvt->pvt = NULL;
+ tmp->tech_pvt = NULL;
p->app_sleep_cond = 1;
ast_channel_free( tmp );
ast_mutex_unlock(&p->lock); /* For other thread to read the condition. */
@@ -2092,7 +2107,7 @@ static int agent_devicestate(void *data)
int load_module()
{
/* Make sure we can register our agent channel type */
- if (ast_channel_register_ex(channeltype, tdesc, capability, agent_request, agent_devicestate)) {
+ if (ast_channel_register(&agent_tech)) {
ast_log(LOG_ERROR, "Unable to register channel class %s\n", channeltype);
return -1;
}
@@ -2134,7 +2149,7 @@ int unload_module()
/* Unregister manager command */
ast_manager_unregister("Agents");
/* Unregister channel */
- ast_channel_unregister(channeltype);
+ ast_channel_unregister(&agent_tech);
if (!ast_mutex_lock(&agentlock)) {
/* Hangup all interfaces if they have an owner */
p = agents;
@@ -2168,6 +2183,6 @@ char *key()
char *description()
{
- return desc;
+ return (char *) desc;
}
diff --git a/channels/chan_alsa.c b/channels/chan_alsa.c
index f1663336b..d907c1a83 100755
--- a/channels/chan_alsa.c
+++ b/channels/chan_alsa.c
@@ -13,7 +13,6 @@
#include <asterisk/logger.h>
#include <asterisk/channel.h>
#include <asterisk/module.h>
-#include <asterisk/channel_pvt.h>
#include <asterisk/options.h>
#include <asterisk/pbx.h>
#include <asterisk/config.h>
@@ -76,10 +75,10 @@ static int silencethreshold = 1000;
AST_MUTEX_DEFINE_STATIC(usecnt_lock);
AST_MUTEX_DEFINE_STATIC(alsalock);
-static char *type = "Console";
-static char *desc = "ALSA Console Channel Driver";
-static char *tdesc = "ALSA Console Channel Driver";
-static char *config = "alsa.conf";
+static const char type[] = "Console";
+static const char desc[] = "ALSA Console Channel Driver";
+static const char tdesc[] = "ALSA Console Channel Driver";
+static const char config[] = "alsa.conf";
static char context[AST_MAX_EXTENSION] = "default";
static char language[MAX_LANGUAGE] = "";
@@ -142,6 +141,34 @@ static int silencelen=0;
static int offset=0;
static int nosound=0;
+/* ZZ */
+static struct ast_channel *alsa_request(const char *type, int format, void *data, int *cause);
+static int alsa_digit(struct ast_channel *c, char digit);
+static int alsa_text(struct ast_channel *c, char *text);
+static int alsa_hangup(struct ast_channel *c);
+static int alsa_answer(struct ast_channel *c);
+static struct ast_frame *alsa_read(struct ast_channel *chan);
+static int alsa_call(struct ast_channel *c, char *dest, int timeout);
+static int alsa_write(struct ast_channel *chan, struct ast_frame *f);
+static int alsa_indicate(struct ast_channel *chan, int cond);
+static int alsa_fixup(struct ast_channel *oldchan, struct ast_channel *newchan);
+
+static const struct ast_channel_tech alsa_tech = {
+ .type = type,
+ .description = tdesc,
+ .capabilities = AST_FORMAT_SLINEAR,
+ .requester = alsa_request,
+ .send_digit = alsa_digit,
+ .send_text = alsa_text,
+ .hangup = alsa_hangup,
+ .answer = alsa_answer,
+ .read = alsa_read,
+ .call = alsa_call,
+ .write = alsa_write,
+ .indicate = alsa_indicate,
+ .fixup = alsa_fixup,
+};
+
static int send_sound(void)
{
short myframe[FRAME_SIZE];
@@ -520,7 +547,7 @@ static int alsa_hangup(struct ast_channel *c)
int res;
ast_mutex_lock(&alsalock);
cursound = -1;
- c->pvt->pvt = NULL;
+ c->tech_pvt = NULL;
alsa.owner = NULL;
ast_verbose( " << Hangup on console >> \n");
ast_mutex_lock(&usecnt_lock);
@@ -677,7 +704,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->pvt->pvt;
+ struct chan_alsa_pvt *p = newchan->tech_pvt;
ast_mutex_lock(&alsalock);
p->owner = newchan;
ast_mutex_unlock(&alsalock);
@@ -717,22 +744,14 @@ static struct ast_channel *alsa_new(struct chan_alsa_pvt *p, int state)
struct ast_channel *tmp;
tmp = ast_channel_alloc(1);
if (tmp) {
+ tmp->tech = &alsa_tech;
snprintf(tmp->name, sizeof(tmp->name), "ALSA/%s", indevname);
tmp->type = type;
tmp->fds[0] = readdev;
tmp->nativeformats = AST_FORMAT_SLINEAR;
tmp->readformat = AST_FORMAT_SLINEAR;
tmp->writeformat = AST_FORMAT_SLINEAR;
- tmp->pvt->pvt = p;
- tmp->pvt->send_digit = alsa_digit;
- tmp->pvt->send_text = alsa_text;
- tmp->pvt->hangup = alsa_hangup;
- tmp->pvt->answer = alsa_answer;
- tmp->pvt->read = alsa_read;
- tmp->pvt->call = alsa_call;
- tmp->pvt->write = alsa_write;
- tmp->pvt->indicate = alsa_indicate;
- tmp->pvt->fixup = alsa_fixup;
+ tmp->tech_pvt = p;
if (strlen(p->context))
strncpy(tmp->context, p->context, sizeof(tmp->context)-1);
if (strlen(p->exten))
@@ -1027,7 +1046,7 @@ int load_module()
return 0;
}
- res = ast_channel_register(type, tdesc, AST_FORMAT_SLINEAR, alsa_request);
+ res = ast_channel_register(&alsa_tech);
if (res < 0) {
ast_log(LOG_ERROR, "Unable to register channel class '%s'\n", type);
return -1;
@@ -1048,6 +1067,8 @@ int load_module()
int unload_module()
{
int x;
+
+ ast_channel_unregister(&alsa_tech);
for (x=0;x<sizeof(myclis)/sizeof(struct ast_cli_entry); x++)
ast_cli_unregister(myclis + x);
close(readdev);
@@ -1065,7 +1086,7 @@ int unload_module()
char *description()
{
- return desc;
+ return (char *) desc;
}
int usecount()
diff --git a/channels/chan_features.c b/channels/chan_features.c
index be1a88fa8..9ddfc5416 100755
--- a/channels/chan_features.c
+++ b/channels/chan_features.c
@@ -15,7 +15,6 @@
#include <string.h>
#include <asterisk/lock.h>
#include <asterisk/channel.h>
-#include <asterisk/channel_pvt.h>
#include <asterisk/config.h>
#include <asterisk/logger.h>
#include <asterisk/module.h>
@@ -42,11 +41,9 @@
#include <sys/signal.h>
-static char *desc = "Feature Proxy Channel";
-static char *type = "Feature";
-static char *tdesc = "Feature Proxy Channel Driver";
-
-static int capability = -1;
+static const char desc[] = "Feature Proxy Channel";
+static const char type[] = "Feature";
+static const char tdesc[] = "Feature Proxy Channel Driver";
static int usecnt =0;
AST_MUTEX_DEFINE_STATIC(usecnt_lock);
@@ -78,6 +75,32 @@ static struct feature_pvt {
#define SUB_CALLWAIT 1 /* Call-Waiting call on hold */
#define SUB_THREEWAY 2 /* Three-way call */
+static struct ast_channel *features_request(const char *type, int format, void *data, int *cause);
+static int features_digit(struct ast_channel *ast, char digit);
+static int features_call(struct ast_channel *ast, char *dest, int timeout);
+static int features_hangup(struct ast_channel *ast);
+static int features_answer(struct ast_channel *ast);
+static struct ast_frame *features_read(struct ast_channel *ast);
+static int features_write(struct ast_channel *ast, struct ast_frame *f);
+static int features_indicate(struct ast_channel *ast, int condition);
+static int features_fixup(struct ast_channel *oldchan, struct ast_channel *newchan);
+
+static const struct ast_channel_tech features_tech = {
+ .type = type,
+ .description = tdesc,
+ .capabilities = -1,
+ .requester = features_request,
+ .send_digit = features_digit,
+ .call = features_call,
+ .hangup = features_hangup,
+ .answer = features_answer,
+ .read = features_read,
+ .write = features_write,
+ .exception = features_read,
+ .indicate = features_indicate,
+ .fixup = features_fixup,
+};
+
static inline void init_sub(struct feature_sub *sub)
{
sub->inthreeway = 0;
@@ -123,8 +146,8 @@ static void restore_channel(struct feature_pvt *p, int index)
{
/* Restore timing/alertpipe */
p->subs[index].owner->timingfd = p->subs[index].timingfdbackup;
- p->subs[index].owner->pvt->alertpipe[0] = p->subs[index].alertpipebackup[0];
- p->subs[index].owner->pvt->alertpipe[1] = p->subs[index].alertpipebackup[1];
+ p->subs[index].owner->alertpipe[0] = p->subs[index].alertpipebackup[0];
+ p->subs[index].owner->alertpipe[1] = p->subs[index].alertpipebackup[1];
p->subs[index].owner->fds[AST_MAX_FDS-1] = p->subs[index].alertpipebackup[0];
p->subs[index].owner->fds[AST_MAX_FDS-2] = p->subs[index].timingfdbackup;
}
@@ -142,8 +165,8 @@ static void update_features(struct feature_pvt *p, int index)
if (!index) {
/* Copy timings from master channel */
p->subs[index].owner->timingfd = p->subchan->timingfd;
- p->subs[index].owner->pvt->alertpipe[0] = p->subchan->pvt->alertpipe[0];
- p->subs[index].owner->pvt->alertpipe[1] = p->subchan->pvt->alertpipe[1];
+ p->subs[index].owner->alertpipe[0] = p->subchan->alertpipe[0];
+ p->subs[index].owner->alertpipe[1] = p->subchan->alertpipe[1];
if (p->subs[index].owner->nativeformats != p->subchan->readformat) {
p->subs[index].owner->nativeformats = p->subchan->readformat;
if (p->subs[index].owner->readformat)
@@ -180,7 +203,7 @@ static void swap_subs(struct feature_pvt *p, int a, int b)
static int features_answer(struct ast_channel *ast)
{
- struct feature_pvt *p = ast->pvt->pvt;
+ struct feature_pvt *p = ast->tech_pvt;
int res = -1;
int x;
ast_mutex_lock(&p->lock);
@@ -194,7 +217,7 @@ static int features_answer(struct ast_channel *ast)
static struct ast_frame *features_read(struct ast_channel *ast)
{
static struct ast_frame null_frame = { AST_FRAME_NULL, };
- struct feature_pvt *p = ast->pvt->pvt;
+ struct feature_pvt *p = ast->tech_pvt;
struct ast_frame *f;
int x;
@@ -211,7 +234,7 @@ static struct ast_frame *features_read(struct ast_channel *ast)
static int features_write(struct ast_channel *ast, struct ast_frame *f)
{
- struct feature_pvt *p = ast->pvt->pvt;
+ struct feature_pvt *p = ast->tech_pvt;
int res = -1;
int x;
ast_mutex_lock(&p->lock);
@@ -224,7 +247,7 @@ static int features_write(struct ast_channel *ast, struct ast_frame *f)
static int features_fixup(struct ast_channel *oldchan, struct ast_channel *newchan)
{
- struct feature_pvt *p = newchan->pvt->pvt;
+ struct feature_pvt *p = newchan->tech_pvt;
int x;
ast_mutex_lock(&p->lock);
if (p->owner == oldchan)
@@ -239,7 +262,7 @@ static int features_fixup(struct ast_channel *oldchan, struct ast_channel *newch
static int features_indicate(struct ast_channel *ast, int condition)
{
- struct feature_pvt *p = ast->pvt->pvt;
+ struct feature_pvt *p = ast->tech_pvt;
int res = -1;
int x;
/* Queue up a frame representing the indication as a control frame */
@@ -253,7 +276,7 @@ static int features_indicate(struct ast_channel *ast, int condition)
static int features_digit(struct ast_channel *ast, char digit)
{
- struct feature_pvt *p = ast->pvt->pvt;
+ struct feature_pvt *p = ast->tech_pvt;
int res = -1;
int x;
/* Queue up a frame representing the indication as a control frame */
@@ -267,7 +290,7 @@ static int features_digit(struct ast_channel *ast, char digit)
static int features_call(struct ast_channel *ast, char *dest, int timeout)
{
- struct feature_pvt *p = ast->pvt->pvt;
+ struct feature_pvt *p = ast->tech_pvt;
int res = -1;
int x;
char *dest2;
@@ -311,7 +334,7 @@ static int features_call(struct ast_channel *ast, char *dest, int timeout)
static int features_hangup(struct ast_channel *ast)
{
- struct feature_pvt *p = ast->pvt->pvt;
+ struct feature_pvt *p = ast->tech_pvt;
struct feature_pvt *cur, *prev=NULL;
int x;
@@ -322,7 +345,7 @@ static int features_hangup(struct ast_channel *ast)
p->subs[x].owner = NULL;
/* XXX Re-arrange, unconference, etc XXX */
}
- ast->pvt->pvt = NULL;
+ ast->tech_pvt = NULL;
if (!p->subs[SUB_REAL].owner && !p->subs[SUB_CALLWAIT].owner && !p->subs[SUB_THREEWAY].owner) {
@@ -425,6 +448,7 @@ static struct ast_channel *features_new(struct feature_pvt *p, int state, int in
if (!tmp)
return NULL;
if (tmp) {
+ tmp->tech = &features_tech;
for (x=1;x<4;x++) {
snprintf(tmp->name, sizeof(tmp->name), "Feature/%s/%s-%d", p->tech, p->dest, x);
for (y=0;y<3;y++) {
@@ -438,21 +462,12 @@ static struct ast_channel *features_new(struct feature_pvt *p, int state, int in
}
tmp->type = type;
ast_setstate(tmp, state);
- tmp->writeformat = p->subchan->writeformat;;
- tmp->pvt->rawwriteformat = p->subchan->pvt->rawwriteformat;
+ tmp->writeformat = p->subchan->writeformat;
+ tmp->rawwriteformat = p->subchan->rawwriteformat;
tmp->readformat = p->subchan->readformat;
- tmp->pvt->rawreadformat = p->subchan->pvt->rawreadformat;
+ tmp->rawreadformat = p->subchan->rawreadformat;
tmp->nativeformats = p->subchan->readformat;
- tmp->pvt->pvt = p;
- tmp->pvt->send_digit = features_digit;
- tmp->pvt->call = features_call;
- tmp->pvt->hangup = features_hangup;
- tmp->pvt->answer = features_answer;
- tmp->pvt->read = features_read;
- tmp->pvt->write = features_write;
- tmp->pvt->exception = features_read;
- tmp->pvt->indicate = features_indicate;
- tmp->pvt->fixup = features_fixup;
+ tmp->tech_pvt = p;
p->subs[index].owner = tmp;
if (!p->owner)
p->owner = tmp;
@@ -509,7 +524,7 @@ static struct ast_cli_entry cli_show_features = {
int load_module()
{
/* Make sure we can register our sip channel type */
- if (ast_channel_register(type, tdesc, capability, features_request)) {
+ if (ast_channel_register(&features_tech)) {
ast_log(LOG_ERROR, "Unable to register channel class %s\n", type);
return -1;
}
@@ -527,7 +542,7 @@ int unload_module()
struct feature_pvt *p;
/* First, take us out of the channel loop */
ast_cli_unregister(&cli_show_features);
- ast_channel_unregister(type);
+ ast_channel_unregister(&features_tech);
if (!ast_mutex_lock(&featurelock)) {
/* Hangup all interfaces if they have an owner */
p = features;
@@ -561,6 +576,6 @@ char *key()
char *description()
{
- return desc;
+ return (char *) desc;
}
diff --git a/channels/chan_h323.c b/channels/chan_h323.c
index 812e932fb..9eeed08f6 100755
--- a/channels/chan_h323.c
+++ b/channels/chan_h323.c
@@ -52,7 +52,6 @@ extern "C" {
#include <asterisk/lock.h>
#include <asterisk/logger.h>
#include <asterisk/channel.h>
-#include <asterisk/channel_pvt.h>
#include <asterisk/config.h>
#include <asterisk/module.h>
#include <asterisk/pbx.h>
@@ -88,10 +87,10 @@ rfc2833_cb on_set_rfc2833_payload;
int h323debug;
/** Variables required by Asterisk */
-static char *type = "H323";
-static char *desc = "The NuFone Network's Open H.323 Channel Driver";
-static char *tdesc = "The NuFone Network's Open H.323 Channel Driver";
-static char *config = "h323.conf";
+static const char type[] = "H323";
+static const char desc[] = "The NuFone Network's Open H.323 Channel Driver";
+static const char tdesc[] = "The NuFone Network's Open H.323 Channel Driver";
+static const char config[] = "h323.conf";
static char default_context[AST_MAX_EXTENSION] = "default";
static struct sockaddr_in bindaddr;
@@ -184,6 +183,35 @@ static pthread_t monitor_thread = AST_PTHREADT_NULL;
static int restart_monitor(void);
static int h323_do_reload(void);
+static struct ast_channel *oh323_request(const char *type, int format, void *data, int *cause);
+static int oh323_digit(struct ast_channel *c, char digit);
+static int oh323_call(struct ast_channel *c, char *dest, int timeout);
+static int oh323_hangup(struct ast_channel *c);
+static int oh323_answer(struct ast_channel *c);
+static struct ast_frame *oh323_read(struct ast_channel *c);
+static int oh323_write(struct ast_channel *c, struct ast_frame *frame);
+static int oh323_indicate(struct ast_channel *c, int condition);
+static int oh323_fixup(struct ast_channel *oldchan, struct ast_channel *newchan);
+
+static const struct ast_channel_tech oh323_tech = {
+ .type = type,
+ .description = tdesc,
+ .capabilities = AST_FORMAT_ULAW,
+ .requester = oh323_request,
+ .send_digit = oh323_digit,
+ .call = oh323_call,
+ .hangup = oh323_hangup,
+ .answer = oh323_answer,
+ .read = oh323_read,
+ .write = oh323_write,
+ .indicate = oh323_indicate,
+ .fixup = oh323_fixup,
+ /* disable, for now */
+#if 0
+ .bridge = ast_rtp_bridge,
+#endif
+};
+
static void __oh323_destroy(struct oh323_pvt *p)
{
struct oh323_pvt *cur, *prev = NULL;
@@ -196,7 +224,7 @@ static void __oh323_destroy(struct oh323_pvt *p)
if (p->owner) {
ast_mutex_lock(&p->owner->lock);
ast_log(LOG_DEBUG, "Detaching from %s\n", p->owner->name);
- p->owner->pvt->pvt = NULL;
+ p->owner->tech_pvt = NULL;
ast_mutex_unlock(&p->owner->lock);
}
cur = iflist;
@@ -464,7 +492,7 @@ static struct oh323_peer *build_peer(char *name, struct ast_variable *v)
*/
static int oh323_digit(struct ast_channel *c, char digit)
{
- struct oh323_pvt *p = (struct oh323_pvt *) c->pvt->pvt;
+ struct oh323_pvt *p = (struct oh323_pvt *) c->tech_pvt;
if (p && p->rtp && (p->dtmfmode & H323_DTMF_RFC2833)) {
ast_rtp_senddigit(p->rtp, digit);
}
@@ -483,7 +511,7 @@ static int oh323_digit(struct ast_channel *c, char digit)
static int oh323_call(struct ast_channel *c, char *dest, int timeout)
{
int res = 0;
- struct oh323_pvt *pvt = (struct oh323_pvt *)c->pvt->pvt;
+ struct oh323_pvt *pvt = (struct oh323_pvt *)c->tech_pvt;
char addr[INET_ADDRSTRLEN];
char called_addr[1024];
@@ -528,7 +556,7 @@ static int oh323_call(struct ast_channel *c, char *dest, int timeout)
static int oh323_answer(struct ast_channel *c)
{
int res;
- struct oh323_pvt *pvt = (struct oh323_pvt *) c->pvt->pvt;
+ struct oh323_pvt *pvt = (struct oh323_pvt *) c->tech_pvt;
res = h323_answering_call(pvt->cd.call_token, 0);
@@ -540,11 +568,11 @@ static int oh323_answer(struct ast_channel *c)
static int oh323_hangup(struct ast_channel *c)
{
- struct oh323_pvt *pvt = (struct oh323_pvt *) c->pvt->pvt;
+ struct oh323_pvt *pvt = (struct oh323_pvt *) c->tech_pvt;
int needcancel = 0;
int q931cause = AST_CAUSE_NORMAL_CLEARING;
- if (!c->pvt->pvt) {
+ if (!c->tech_pvt) {
ast_log(LOG_DEBUG, "Asked to hangup channel not connected\n");
return 0;
}
@@ -558,14 +586,14 @@ static int oh323_hangup(struct ast_channel *c)
if (!c || (c->_state != AST_STATE_UP)) {
needcancel = 1;
}
- pvt = (struct oh323_pvt *)c->pvt->pvt;
+ pvt = (struct oh323_pvt *)c->tech_pvt;
/* Free dsp used for in-band DTMF detection */
if (pvt->vad) {
ast_dsp_free(pvt->vad);
}
pvt->owner = NULL;
- c->pvt->pvt = NULL;
+ c->tech_pvt = NULL;
if (c->hangupcause) {
q931cause = c->hangupcause;
@@ -648,7 +676,7 @@ 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->pvt->pvt;
+ struct oh323_pvt *pvt = (struct oh323_pvt *)c->tech_pvt;
ast_mutex_lock(&pvt->lock);
fr = oh323_rtp_read(pvt);
ast_mutex_unlock(&pvt->lock);
@@ -657,7 +685,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->pvt->pvt;
+ struct oh323_pvt *pvt = (struct oh323_pvt *) c->tech_pvt;
int res = 0;
if (frame->frametype != AST_FRAME_VOICE) {
if (frame->frametype == AST_FRAME_IMAGE) {
@@ -686,7 +714,7 @@ static int oh323_write(struct ast_channel *c, struct ast_frame *frame)
static int oh323_indicate(struct ast_channel *c, int condition)
{
- struct oh323_pvt *pvt = (struct oh323_pvt *) c->pvt->pvt;
+ struct oh323_pvt *pvt = (struct oh323_pvt *) c->tech_pvt;
ast_log(LOG_DEBUG, "OH323: Indicating %d on %s\n", condition, pvt->cd.call_token);
@@ -733,7 +761,7 @@ static int oh323_indicate(struct ast_channel *c, int condition)
static int oh323_fixup(struct ast_channel *oldchan, struct ast_channel *newchan)
{
- struct oh323_pvt *pvt = (struct oh323_pvt *) newchan->pvt->pvt;
+ struct oh323_pvt *pvt = (struct oh323_pvt *) newchan->tech_pvt;
ast_mutex_lock(&pvt->lock);
if (pvt->owner != oldchan) {
@@ -760,6 +788,7 @@ static struct ast_channel *oh323_new(struct oh323_pvt *pvt, int state, const cha
ast_update_use_count();
ast_mutex_lock(&pvt->lock);
if (ch) {
+ tmp->tech = &oh323_tech;
snprintf(ch->name, sizeof(ch->name), "H323/%s", host);
ch->nativeformats = pvt->capability;
if (!ch->nativeformats) {
@@ -772,28 +801,16 @@ static struct ast_channel *oh323_new(struct oh323_pvt *pvt, int state, const cha
ch->rings = 1;
}
ch->writeformat = fmt;
- ch->pvt->rawwriteformat = fmt;
+ ch->rawwriteformat = fmt;
ch->readformat = fmt;
- ch->pvt->rawreadformat = fmt;
+ ch->rawreadformat = fmt;
/* Allocate dsp for in-band DTMF support */
if (pvt->dtmfmode & H323_DTMF_INBAND) {
pvt->vad = ast_dsp_new();
ast_dsp_set_features(pvt->vad, DSP_FEATURE_DTMF_DETECT);
}
/* Register channel functions. */
- ch->pvt->pvt = pvt;
- ch->pvt->send_digit = oh323_digit;
- ch->pvt->call = oh323_call;
- ch->pvt->hangup = oh323_hangup;
- ch->pvt->answer = oh323_answer;
- ch->pvt->read = oh323_read;
- ch->pvt->write = oh323_write;
- ch->pvt->indicate = oh323_indicate;
- ch->pvt->fixup = oh323_fixup;
- /* disable, for now */
-#if 0
- ch->pvt->bridge = ast_rtp_bridge;
-#endif
+ ch->tech_pvt = pvt;
/* Set the owner of this channel */
pvt->owner = ch;
@@ -1990,7 +2007,7 @@ static struct ast_cli_entry cli_h323_reload =
static struct ast_rtp *oh323_get_rtp_peer(struct ast_channel *chan)
{
struct oh323_pvt *p;
- p = (struct oh323_pvt *) chan->pvt->pvt;
+ p = (struct oh323_pvt *) chan->tech_pvt;
if (p && p->rtp && p->bridge) {
return p->rtp;
}
@@ -2041,7 +2058,7 @@ static int oh323_set_rtp_peer(struct ast_channel *chan, struct ast_rtp *rtp, str
}
mode = convertcap(chan->writeformat);
- p = (struct oh323_pvt *) chan->pvt->pvt;
+ p = (struct oh323_pvt *) chan->tech_pvt;
if (!p) {
ast_log(LOG_ERROR, "No Private Structure, this is bad\n");
return -1;
@@ -2053,9 +2070,10 @@ static int oh323_set_rtp_peer(struct ast_channel *chan, struct ast_rtp *rtp, str
}
static struct ast_rtp_protocol oh323_rtp = {
- get_rtp_info: oh323_get_rtp_peer,
- get_vrtp_info: oh323_get_vrtp_peer,
- set_rtp_peer: oh323_set_rtp_peer,
+ .type = type,
+ .get_rtp_info = oh323_get_rtp_peer,
+ .get_vrtp_info = oh323_get_vrtp_peer,
+ .set_rtp_peer= oh323_set_rtp_peer,
};
int load_module()
@@ -2077,7 +2095,7 @@ int load_module()
return 0;
} else {
/* Make sure we can register our channel type */
- if (ast_channel_register(type, tdesc, capability, oh323_request)) {
+ if (ast_channel_register(&oh323_tech)) {
ast_log(LOG_ERROR, "Unable to register channel class %s\n", type);
h323_end_process();
return -1;
@@ -2092,7 +2110,6 @@ int load_module()
ast_cli_register(&cli_show_tokens);
ast_cli_register(&cli_h323_reload);
- oh323_rtp.type = type;
ast_rtp_proto_register(&oh323_rtp);
/* Register our callback functions */
@@ -2140,7 +2157,7 @@ int unload_module()
ast_cli_unregister(&cli_show_tokens);
ast_cli_unregister(&cli_h323_reload);
ast_rtp_proto_unregister(&oh323_rtp);
- ast_channel_unregister(type);
+ ast_channel_unregister(&oh323_tech);
if (!ast_mutex_lock(&iflock)) {
/* hangup all interfaces if they have an owner */
diff --git a/channels/chan_iax2.c b/channels/chan_iax2.c
index 8a3a61ac8..91b6416c8 100755
--- a/channels/chan_iax2.c
+++ b/channels/chan_iax2.c
@@ -14,7 +14,6 @@
#include <asterisk/lock.h>
#include <asterisk/frame.h>
#include <asterisk/channel.h>
-#include <asterisk/channel_pvt.h>
#include <asterisk/logger.h>
#include <asterisk/module.h>
#include <asterisk/pbx.h>
@@ -102,9 +101,9 @@
static struct ast_codec_pref prefs;
-static char *desc = "Inter Asterisk eXchange (Ver 2)";
-static char *tdesc = "Inter Asterisk eXchange Driver (Ver 2)";
-static char *channeltype = "IAX2";
+static const char desc[] = "Inter Asterisk eXchange (Ver 2)";
+static const char tdesc[] = "Inter Asterisk eXchange Driver (Ver 2)";
+static const char channeltype[] = "IAX2";
static char context[80] = "default";
@@ -609,6 +608,45 @@ static void prune_peers(void);
static int iax2_poke_peer(struct iax2_peer *peer, int heldcall);
static int iax2_provision(struct sockaddr_in *end, char *dest, const char *template, int force);
+static struct ast_channel *iax2_request(const char *type, int format, void *data, int *cause);
+static int iax2_devicestate(void *data);
+static int iax2_digit(struct ast_channel *c, char digit);
+static int iax2_sendtext(struct ast_channel *c, char *text);
+static int iax2_sendimage(struct ast_channel *c, struct ast_frame *img);
+static int iax2_sendhtml(struct ast_channel *c, int subclass, char *data, int datalen);
+static int iax2_call(struct ast_channel *c, char *dest, int timeout);
+static int iax2_hangup(struct ast_channel *c);
+static int iax2_answer(struct ast_channel *c);
+static struct ast_frame *iax2_read(struct ast_channel *c);
+static int iax2_write(struct ast_channel *c, struct ast_frame *f);
+static int iax2_indicate(struct ast_channel *c, int condition);
+static int iax2_setoption(struct ast_channel *c, int option, void *data, int datalen);
+static int iax2_bridge(struct ast_channel *c0, struct ast_channel *c1, int flags, struct ast_frame **fo, struct ast_channel **rc);
+static int iax2_transfer(struct ast_channel *c, char *dest);
+static int iax2_fixup(struct ast_channel *oldchannel, struct ast_channel *newchan);
+
+static const struct ast_channel_tech iax2_tech = {
+ .type = channeltype,
+ .description = tdesc,
+ .capabilities = IAX_CAPABILITY_FULLBANDWIDTH,
+ .requester = iax2_request,
+ .devicestate = iax2_devicestate,
+ .send_digit = iax2_digit,
+ .send_text = iax2_sendtext,
+ .send_image = iax2_sendimage,
+ .send_html = iax2_sendhtml,
+ .call = iax2_call,
+ .hangup = iax2_hangup,
+ .answer = iax2_answer,
+ .read = iax2_read,
+ .write = iax2_write,
+ .write_video = iax2_write,
+ .indicate = iax2_indicate,
+ .setoption = iax2_setoption,
+ .bridge = iax2_bridge,
+ .transfer = iax2_transfer,
+ .fixup = iax2_fixup,
+};
static int send_ping(void *data)
{
@@ -1410,7 +1448,7 @@ static int iax2_predestroy(int callno)
c = pvt->owner;
if (c) {
c->_softhangup |= AST_SOFTHANGUP_DEV;
- c->pvt->pvt = NULL;
+ c->tech_pvt = NULL;
ast_queue_hangup(c);
pvt->owner = NULL;
ast_mutex_lock(&usecnt_lock);
@@ -2174,29 +2212,29 @@ static int iax2_transmit(struct iax_frame *fr)
static int iax2_digit(struct ast_channel *c, char digit)
{
- return send_command_locked(PTR_TO_CALLNO(c->pvt->pvt), AST_FRAME_DTMF, digit, 0, NULL, 0, -1);
+ return send_command_locked(PTR_TO_CALLNO(c->tech_pvt), AST_FRAME_DTMF, digit, 0, NULL, 0, -1);
}
static int iax2_sendtext(struct ast_channel *c, char *text)
{
- return send_command_locked(PTR_TO_CALLNO(c->pvt->pvt), AST_FRAME_TEXT,
+ return send_command_locked(PTR_TO_CALLNO(c->tech_pvt), AST_FRAME_TEXT,
0, 0, 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->pvt->pvt), AST_FRAME_IMAGE, img->subclass, 0, img->data, img->datalen, -1);
+ return send_command_locked(PTR_TO_CALLNO(c->tech_pvt), AST_FRAME_IMAGE, img->subclass, 0, img->data, img->datalen, -1);
}
static int iax2_sendhtml(struct ast_channel *c, int subclass, char *data, int datalen)
{
- return send_command_locked(PTR_TO_CALLNO(c->pvt->pvt), AST_FRAME_HTML, subclass, 0, data, datalen, -1);
+ return send_command_locked(PTR_TO_CALLNO(c->tech_pvt), AST_FRAME_HTML, subclass, 0, data, datalen, -1);
}
static int iax2_fixup(struct ast_channel *oldchannel, struct ast_channel *newchan)
{
- unsigned short callno = PTR_TO_CALLNO(newchan->pvt->pvt);
+ unsigned short callno = PTR_TO_CALLNO(newchan->tech_pvt);
ast_mutex_lock(&iaxsl[callno]);
if (iaxs[callno])
iaxs[callno]->owner = newchan;
@@ -2487,7 +2525,7 @@ static int iax2_call(struct ast_channel *c, char *dest, int timeout)
char *portno = NULL;
char *opts = "";
int encmethods=iax2_encryption;
- unsigned short callno = PTR_TO_CALLNO(c->pvt->pvt);
+ unsigned short callno = PTR_TO_CALLNO(c->tech_pvt);
char *stringp=NULL;
char storedusern[80], storedsecret[80];
char tz[80] = "";
@@ -2629,7 +2667,7 @@ static int iax2_call(struct ast_channel *c, char *dest, int timeout)
static int iax2_hangup(struct ast_channel *c)
{
- unsigned short callno = PTR_TO_CALLNO(c->pvt->pvt);
+ unsigned short callno = PTR_TO_CALLNO(c->tech_pvt);
int alreadygone;
struct iax_ie_data ied;
memset(&ied, 0, sizeof(ied));
@@ -2664,7 +2702,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->pvt->pvt), AST_FRAME_CONTROL,
+ res = send_command_locked(PTR_TO_CALLNO(c->tech_pvt), AST_FRAME_CONTROL,
AST_CONTROL_OPTION, 0, (char *)h, datalen + sizeof(struct ast_option_header), -1);
free(h);
return res;
@@ -2731,8 +2769,8 @@ static int iax2_bridge(struct ast_channel *c0, struct ast_channel *c1, int flags
int res = -1;
int transferstarted=0;
struct ast_frame *f;
- unsigned short callno0 = PTR_TO_CALLNO(c0->pvt->pvt);
- unsigned short callno1 = PTR_TO_CALLNO(c1->pvt->pvt);
+ unsigned short callno0 = PTR_TO_CALLNO(c0->tech_pvt);
+ unsigned short callno1 = PTR_TO_CALLNO(c1->tech_pvt);
struct timeval waittimer = {0, 0}, tv;
lock_both(callno0, callno1);
@@ -2884,7 +2922,7 @@ tackygoto:
static int iax2_answer(struct ast_channel *c)
{
- unsigned short callno = PTR_TO_CALLNO(c->pvt->pvt);
+ unsigned short callno = PTR_TO_CALLNO(c->tech_pvt);
if (option_debug)
ast_log(LOG_DEBUG, "Answering\n");
return send_command_locked(callno, AST_FRAME_CONTROL, AST_CONTROL_ANSWER, 0, NULL, 0, -1);
@@ -2892,7 +2930,7 @@ static int iax2_answer(struct ast_channel *c)
static int iax2_indicate(struct ast_channel *c, int condition)
{
- unsigned short callno = PTR_TO_CALLNO(c->pvt->pvt);
+ unsigned short callno = PTR_TO_CALLNO(c->tech_pvt);
if (option_debug)
ast_log(LOG_DEBUG, "Indicating condition %d\n", condition);
return send_command_locked(callno, AST_FRAME_CONTROL, condition, 0, NULL, 0, -1);
@@ -2900,7 +2938,7 @@ static int iax2_indicate(struct ast_channel *c, int condition)
static int iax2_transfer(struct ast_channel *c, char *dest)
{
- unsigned short callno = PTR_TO_CALLNO(c->pvt->pvt);
+ unsigned short callno = PTR_TO_CALLNO(c->tech_pvt);
struct iax_ie_data ied;
char tmp[256] = "", *context;
strncpy(tmp, dest, sizeof(tmp) - 1);
@@ -2952,6 +2990,7 @@ static struct ast_channel *ast_iax2_new(int callno, int state, int capability)
ast_mutex_lock(&iaxsl[callno]);
i = iaxs[callno];
if (i && tmp) {
+ tmp->tech = &iax2_tech;
if (!ast_strlen_zero(i->username))
snprintf(tmp->name, sizeof(tmp->name), "IAX2/%s@%s-%d", i->username, i->host, i->callno);
else
@@ -2961,21 +3000,8 @@ static struct ast_channel *ast_iax2_new(int callno, int state, int capability)
tmp->nativeformats = capability;
tmp->readformat = ast_best_codec(capability);
tmp->writeformat = ast_best_codec(capability);
- tmp->pvt->pvt = CALLNO_TO_PTR(i->callno);
- tmp->pvt->send_digit = iax2_digit;
- tmp->pvt->send_text = iax2_sendtext;
- tmp->pvt->send_image = iax2_sendimage;
- tmp->pvt->send_html = iax2_sendhtml;
- tmp->pvt->call = iax2_call;
- tmp->pvt->hangup = iax2_hangup;
- tmp->pvt->answer = iax2_answer;
- tmp->pvt->read = iax2_read;
- tmp->pvt->write = iax2_write;
- tmp->pvt->write_video = iax2_write;
- tmp->pvt->indicate = iax2_indicate;
- tmp->pvt->setoption = iax2_setoption;
- tmp->pvt->bridge = iax2_bridge;
- tmp->pvt->transfer = iax2_transfer;
+ tmp->tech_pvt = CALLNO_TO_PTR(i->callno);
+
if (!ast_strlen_zero(i->cid_num))
tmp->cid.cid_num = strdup(i->cid_num);
if (!ast_strlen_zero(i->cid_name))
@@ -2996,7 +3022,6 @@ static struct ast_channel *ast_iax2_new(int callno, int state, int capability)
strncpy(tmp->context, i->context, sizeof(tmp->context)-1);
strncpy(tmp->exten, i->exten, sizeof(tmp->exten)-1);
tmp->adsicpe = i->peeradsicpe;
- tmp->pvt->fixup = iax2_fixup;
i->owner = tmp;
i->capability = capability;
ast_setstate(tmp, state);
@@ -4065,7 +4090,7 @@ static struct ast_cli_entry cli_no_debug =
static int iax2_write(struct ast_channel *c, struct ast_frame *f)
{
- unsigned short callno = PTR_TO_CALLNO(c->pvt->pvt);
+ unsigned short callno = PTR_TO_CALLNO(c->tech_pvt);
int res = -1;
ast_mutex_lock(&iaxsl[callno]);
if (iaxs[callno]) {
@@ -6999,7 +7024,7 @@ static int iax2_prov_app(struct ast_channel *chan, void *data)
char *sdata;
char *opts;
int force =0;
- unsigned short callno = PTR_TO_CALLNO(chan->pvt->pvt);
+ unsigned short callno = PTR_TO_CALLNO(chan->tech_pvt);
char iabuf[INET_ADDRSTRLEN];
if (!data || ast_strlen_zero(data))
data = "default";
@@ -8427,7 +8452,7 @@ static int __unload_module(void)
ast_cli_unregister(&cli_show_peer);
ast_cli_unregister(&cli_prune_realtime);
ast_unregister_switch(&iax2_switch);
- ast_channel_unregister(channeltype);
+ ast_channel_unregister(&iax2_tech);
delete_users();
iax_provision_unload();
return 0;
@@ -8516,7 +8541,7 @@ int load_module(void)
set_config(config, 0);
- if (ast_channel_register_ex(channeltype, tdesc, iax2_capability, iax2_request, iax2_devicestate)) {
+ if (ast_channel_register(&iax2_tech)) {
ast_log(LOG_ERROR, "Unable to register channel class %s\n", channeltype);
__unload_module();
return -1;
@@ -8560,7 +8585,7 @@ int load_module(void)
char *description()
{
- return desc;
+ return (char *) desc;
}
int usecount()
diff --git a/channels/chan_local.c b/channels/chan_local.c
index 288a418c2..994f900f3 100755
--- a/channels/chan_local.c
+++ b/channels/chan_local.c
@@ -15,7 +15,6 @@
#include <string.h>
#include <asterisk/lock.h>
#include <asterisk/channel.h>
-#include <asterisk/channel_pvt.h>
#include <asterisk/config.h>
#include <asterisk/logger.h>
#include <asterisk/module.h>
@@ -41,11 +40,9 @@
#include <arpa/inet.h>
#include <sys/signal.h>
-static char *desc = "Local Proxy Channel";
-static char *type = "Local";
-static char *tdesc = "Local Proxy Channel Driver";
-
-static int capability = -1;
+static const char desc[] = "Local Proxy Channel";
+static const char type[] = "Local";
+static const char tdesc[] = "Local Proxy Channel Driver";
static int usecnt =0;
AST_MUTEX_DEFINE_STATIC(usecnt_lock);
@@ -55,6 +52,34 @@ AST_MUTEX_DEFINE_STATIC(usecnt_lock);
/* Protect the interface list (of sip_pvt's) */
AST_MUTEX_DEFINE_STATIC(locallock);
+static struct ast_channel *local_request(const char *type, int format, void *data, int *cause);
+static int local_digit(struct ast_channel *ast, char digit);
+static int local_call(struct ast_channel *ast, char *dest, int timeout);
+static int local_hangup(struct ast_channel *ast);
+static int local_answer(struct ast_channel *ast);
+static struct ast_frame *local_read(struct ast_channel *ast);
+static int local_write(struct ast_channel *ast, struct ast_frame *f);
+static int local_indicate(struct ast_channel *ast, int condition);
+static int local_fixup(struct ast_channel *oldchan, struct ast_channel *newchan);
+static int local_sendhtml(struct ast_channel *ast, int subclass, char *data, int datalen);
+
+static const struct ast_channel_tech local_tech = {
+ .type = type,
+ .description = tdesc,
+ .capabilities = -1,
+ .requester = local_request,
+ .send_digit = local_digit,
+ .call = local_call,
+ .hangup = local_hangup,
+ .answer = local_answer,
+ .read = local_read,
+ .write = local_write,
+ .exception = local_read,
+ .indicate = local_indicate,
+ .fixup = local_fixup,
+ .send_html = local_sendhtml,
+};
+
static struct local_pvt {
ast_mutex_t lock; /* Channel private lock */
char context[AST_MAX_EXTENSION]; /* Context to call */
@@ -120,7 +145,7 @@ retrylock:
static int local_answer(struct ast_channel *ast)
{
- struct local_pvt *p = ast->pvt->pvt;
+ struct local_pvt *p = ast->tech_pvt;
int isoutbound;
int res = -1;
ast_mutex_lock(&p->lock);
@@ -139,7 +164,7 @@ static void check_bridge(struct local_pvt *p, int isoutbound)
{
if (p->alreadymasqed || p->nooptimization)
return;
- if (isoutbound && p->chan && p->chan->_bridge /* Not ast_bridged_channel! Only go one step! */ && p->owner && !p->owner->pvt->readq) {
+ if (isoutbound && p->chan && p->chan->_bridge /* Not ast_bridged_channel! Only go one step! */ && p->owner && !p->owner->readq) {
/* Masquerade bridged channel into owner */
/* Lock everything we need, one by one, and give up if
we can't get everything. Remember, we'll get another
@@ -152,7 +177,7 @@ static void check_bridge(struct local_pvt *p, int isoutbound)
}
ast_mutex_unlock(&(p->chan->_bridge)->lock);
}
- } else if (!isoutbound && p->owner && p->owner->_bridge && p->chan && !p->chan->pvt->readq) {
+ } else if (!isoutbound && p->owner && p->owner->_bridge && p->chan && !p->chan->readq) {
/* Masquerade bridged channel into chan */
if (!ast_mutex_trylock(&(p->owner->_bridge)->lock)) {
if (!ast_mutex_trylock(&p->chan->lock)) {
@@ -173,7 +198,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->pvt->pvt;
+ struct local_pvt *p = ast->tech_pvt;
int res = -1;
int isoutbound;
@@ -189,7 +214,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->pvt->pvt;
+ struct local_pvt *p = newchan->tech_pvt;
ast_mutex_lock(&p->lock);
if ((p->owner != oldchan) && (p->chan != oldchan)) {
ast_log(LOG_WARNING, "old channel wasn't %p but was %p/%p\n", oldchan, p->owner, p->chan);
@@ -206,7 +231,7 @@ static int local_fixup(struct ast_channel *oldchan, struct ast_channel *newchan)
static int local_indicate(struct ast_channel *ast, int condition)
{
- struct local_pvt *p = ast->pvt->pvt;
+ struct local_pvt *p = ast->tech_pvt;
int res = -1;
struct ast_frame f = { AST_FRAME_CONTROL, };
int isoutbound;
@@ -221,7 +246,7 @@ static int local_indicate(struct ast_channel *ast, int condition)
static int local_digit(struct ast_channel *ast, char digit)
{
- struct local_pvt *p = ast->pvt->pvt;
+ struct local_pvt *p = ast->tech_pvt;
int res = -1;
struct ast_frame f = { AST_FRAME_DTMF, };
int isoutbound;
@@ -235,7 +260,7 @@ static int local_digit(struct ast_channel *ast, char digit)
static int local_sendhtml(struct ast_channel *ast, int subclass, char *data, int datalen)
{
- struct local_pvt *p = ast->pvt->pvt;
+ struct local_pvt *p = ast->tech_pvt;
int res = -1;
struct ast_frame f = { AST_FRAME_HTML, };
int isoutbound;
@@ -251,7 +276,7 @@ static int local_sendhtml(struct ast_channel *ast, int subclass, char *data, int
static int local_call(struct ast_channel *ast, char *dest, int timeout)
{
- struct local_pvt *p = ast->pvt->pvt;
+ struct local_pvt *p = ast->tech_pvt;
int res;
ast_mutex_lock(&p->lock);
@@ -313,7 +338,7 @@ static void local_destroy(struct local_pvt *p)
static int local_hangup(struct ast_channel *ast)
{
- struct local_pvt *p = ast->pvt->pvt;
+ struct local_pvt *p = ast->tech_pvt;
int isoutbound;
struct ast_frame f = { AST_FRAME_CONTROL, AST_CONTROL_HANGUP };
struct local_pvt *cur, *prev=NULL;
@@ -326,7 +351,7 @@ static int local_hangup(struct ast_channel *ast)
p->launchedpbx = 0;
} else
p->owner = NULL;
- ast->pvt->pvt = NULL;
+ ast->tech_pvt = NULL;
ast_mutex_lock(&usecnt_lock);
usecnt--;
@@ -432,6 +457,7 @@ static struct ast_channel *local_new(struct local_pvt *p, int state)
tmp = NULL;
}
if (tmp) {
+ tmp2->tech = tmp->tech = &local_tech;
tmp->nativeformats = p->reqformat;
tmp2->nativeformats = p->reqformat;
snprintf(tmp->name, sizeof(tmp->name), "Local/%s@%s-%04x,1", p->exten, p->context, randnum);
@@ -442,34 +468,14 @@ static struct ast_channel *local_new(struct local_pvt *p, int state)
ast_setstate(tmp2, AST_STATE_RING);
tmp->writeformat = p->reqformat;;
tmp2->writeformat = p->reqformat;
- tmp->pvt->rawwriteformat = p->reqformat;
- tmp2->pvt->rawwriteformat = p->reqformat;
+ tmp->rawwriteformat = p->reqformat;
+ tmp2->rawwriteformat = p->reqformat;
tmp->readformat = p->reqformat;
tmp2->readformat = p->reqformat;
- tmp->pvt->rawreadformat = p->reqformat;
- tmp2->pvt->rawreadformat = p->reqformat;
- tmp->pvt->pvt = p;
- tmp2->pvt->pvt = p;
- tmp->pvt->send_digit = local_digit;
- tmp2->pvt->send_digit = local_digit;
- tmp->pvt->send_html = local_sendhtml;
- tmp2->pvt->send_html = local_sendhtml;
- tmp->pvt->call = local_call;
- tmp2->pvt->call = local_call;
- tmp->pvt->hangup = local_hangup;
- tmp2->pvt->hangup = local_hangup;
- tmp->pvt->answer = local_answer;
- tmp2->pvt->answer = local_answer;
- tmp->pvt->read = local_read;
- tmp2->pvt->read = local_read;
- tmp->pvt->write = local_write;
- tmp2->pvt->write = local_write;
- tmp->pvt->exception = local_read;
- tmp2->pvt->exception = local_read;
- tmp->pvt->indicate = local_indicate;
- tmp2->pvt->indicate = local_indicate;
- tmp->pvt->fixup = local_fixup;
- tmp2->pvt->fixup = local_fixup;
+ tmp->rawreadformat = p->reqformat;
+ tmp2->rawreadformat = p->reqformat;
+ tmp->tech_pvt = p;
+ tmp2->tech_pvt = p;
p->owner = tmp;
p->chan = tmp2;
ast_mutex_lock(&usecnt_lock);
@@ -528,8 +534,8 @@ static struct ast_cli_entry cli_show_locals = {
int load_module()
{
- /* Make sure we can register our sip channel type */
- if (ast_channel_register(type, tdesc, capability, local_request)) {
+ /* Make sure we can register our channel type */
+ if (ast_channel_register(&local_tech)) {
ast_log(LOG_ERROR, "Unable to register channel class %s\n", type);
return -1;
}
@@ -547,7 +553,7 @@ int unload_module()
struct local_pvt *p;
/* First, take us out of the channel loop */
ast_cli_unregister(&cli_show_locals);
- ast_channel_unregister(type);
+ ast_channel_unregister(&local_tech);
if (!ast_mutex_lock(&locallock)) {
/* Hangup all interfaces if they have an owner */
p = locals;
@@ -581,6 +587,6 @@ char *key()
char *description()
{
- return desc;
+ return (char *) desc;
}
diff --git a/channels/chan_mgcp.c b/channels/chan_mgcp.c
index f4e443cdd..16b7ee423 100755
--- a/channels/chan_mgcp.c
+++ b/channels/chan_mgcp.c
@@ -57,7 +57,6 @@
#include <string.h>
#include <asterisk/lock.h>
#include <asterisk/channel.h>
-#include <asterisk/channel_pvt.h>
#include <asterisk/config.h>
#include <asterisk/logger.h>
#include <asterisk/module.h>
@@ -114,10 +113,10 @@
#define INADDR_NONE (in_addr_t)(-1)
#endif
-static char *desc = "Media Gateway Control Protocol (MGCP)";
-static char *type = "MGCP";
-static char *tdesc = "Media Gateway Control Protocol (MGCP)";
-static char *config = "mgcp.conf";
+static const char desc[] = "Media Gateway Control Protocol (MGCP)";
+static const char type[] = "MGCP";
+static const char tdesc[] = "Media Gateway Control Protocol (MGCP)";
+static const char config[] = "mgcp.conf";
#define MGCP_DTMF_RFC2833 (1 << 0)
#define MGCP_DTMF_INBAND (1 << 1)
@@ -245,7 +244,6 @@ static pthread_t monitor_thread = AST_PTHREADT_NULL;
static int restart_monitor(void);
-/* Just about everybody seems to support ulaw, so make it a nice default */
static int capability = AST_FORMAT_ULAW;
static int nonCodecCapability = AST_RTP_DTMF;
@@ -467,6 +465,32 @@ static void dump_cmd_queues(struct mgcp_endpoint *p, struct mgcp_subchannel *sub
static int mgcp_do_reload(void);
static int mgcp_reload(int fd, int argc, char *argv[]);
+static struct ast_channel *mgcp_request(const char *type, int format, void *data, int *cause);
+static int mgcp_call(struct ast_channel *ast, char *dest, int timeout);
+static int mgcp_hangup(struct ast_channel *ast);
+static int mgcp_answer(struct ast_channel *ast);
+static struct ast_frame *mgcp_read(struct ast_channel *ast);
+static int mgcp_write(struct ast_channel *ast, struct ast_frame *frame);
+static int mgcp_indicate(struct ast_channel *ast, int ind);
+static int mgcp_fixup(struct ast_channel *oldchan, struct ast_channel *newchan);
+static int mgcp_senddigit(struct ast_channel *ast, char digit);
+
+static const struct ast_channel_tech mgcp_tech = {
+ .type = type,
+ .description = tdesc,
+ .capabilities = AST_FORMAT_ULAW,
+ .requester = mgcp_request,
+ .call = mgcp_call,
+ .hangup = mgcp_hangup,
+ .answer = mgcp_answer,
+ .read = mgcp_read,
+ .write = mgcp_write,
+ .indicate = mgcp_indicate,
+ .fixup = mgcp_fixup,
+ .send_digit = mgcp_senddigit,
+ .bridge = ast_rtp_bridge,
+};
+
static int has_voicemail(struct mgcp_endpoint *p)
{
return ast_app_has_voicemail(p->mailbox, NULL);
@@ -859,7 +883,7 @@ static int mgcp_call(struct ast_channel *ast, char *dest, int timeout)
if (mgcpdebug) {
ast_verbose(VERBOSE_PREFIX_3 "MGCP mgcp_call(%s)\n", ast->name);
}
- sub = ast->pvt->pvt;
+ sub = ast->tech_pvt;
p = sub->parent;
headp = &ast->varshead;
AST_LIST_TRAVERSE(headp,current,entries) {
@@ -941,13 +965,13 @@ static int mgcp_call(struct ast_channel *ast, char *dest, int timeout)
static int mgcp_hangup(struct ast_channel *ast)
{
- struct mgcp_subchannel *sub = ast->pvt->pvt;
+ struct mgcp_subchannel *sub = ast->tech_pvt;
struct mgcp_endpoint *p = sub->parent;
if (option_debug) {
ast_log(LOG_DEBUG, "mgcp_hangup(%s)\n", ast->name);
}
- if (!ast->pvt->pvt) {
+ if (!ast->tech_pvt) {
ast_log(LOG_DEBUG, "Asked to hangup channel not connected\n");
return 0;
}
@@ -999,7 +1023,7 @@ static int mgcp_hangup(struct ast_channel *ast)
transmit_notify_request(sub, "");
}
- ast->pvt->pvt = NULL;
+ ast->tech_pvt = NULL;
sub->alreadygone = 0;
sub->outgoing = 0;
sub->cxmode = MGCP_CX_INACTIVE;
@@ -1138,7 +1162,7 @@ static struct ast_cli_entry cli_audit_endpoint =
static int mgcp_answer(struct ast_channel *ast)
{
int res = 0;
- struct mgcp_subchannel *sub = ast->pvt->pvt;
+ struct mgcp_subchannel *sub = ast->tech_pvt;
struct mgcp_endpoint *p = sub->parent;
ast_mutex_lock(&sub->lock);
@@ -1199,7 +1223,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->pvt->pvt;
+ struct mgcp_subchannel *sub = ast->tech_pvt;
ast_mutex_lock(&sub->lock);
f = mgcp_rtp_read(sub);
ast_mutex_unlock(&sub->lock);
@@ -1208,7 +1232,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->pvt->pvt;
+ struct mgcp_subchannel *sub = ast->tech_pvt;
int res = 0;
if (frame->frametype != AST_FRAME_VOICE) {
if (frame->frametype == AST_FRAME_IMAGE)
@@ -1238,7 +1262,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->pvt->pvt;
+ struct mgcp_subchannel *sub = newchan->tech_pvt;
ast_mutex_lock(&sub->lock);
ast_log(LOG_NOTICE, "mgcp_fixup(%s, %s)\n", oldchan->name, newchan->name);
@@ -1254,7 +1278,7 @@ static int mgcp_fixup(struct ast_channel *oldchan, struct ast_channel *newchan)
static int mgcp_senddigit(struct ast_channel *ast, char digit)
{
- struct mgcp_subchannel *sub = ast->pvt->pvt;
+ struct mgcp_subchannel *sub = ast->tech_pvt;
char tmp[4];
tmp[0] = 'D';
@@ -1301,7 +1325,7 @@ static char *control2str(int ind) {
static int mgcp_indicate(struct ast_channel *ast, int ind)
{
- struct mgcp_subchannel *sub = ast->pvt->pvt;
+ struct mgcp_subchannel *sub = ast->tech_pvt;
int res = 0;
if (mgcpdebug) {
@@ -1343,6 +1367,7 @@ static struct ast_channel *mgcp_new(struct mgcp_subchannel *sub, int state)
i = sub->parent;
tmp = ast_channel_alloc(1);
if (tmp) {
+ tmp->tech = &mgcp_tech;
tmp->nativeformats = i->capability;
if (!tmp->nativeformats)
tmp->nativeformats = capability;
@@ -1363,19 +1388,10 @@ static struct ast_channel *mgcp_new(struct mgcp_subchannel *sub, int state)
if (state == AST_STATE_RING)
tmp->rings = 1;
tmp->writeformat = fmt;
- tmp->pvt->rawwriteformat = fmt;
+ tmp->rawwriteformat = fmt;
tmp->readformat = fmt;
- tmp->pvt->rawreadformat = fmt;
- tmp->pvt->pvt = sub;
- tmp->pvt->call = mgcp_call;
- tmp->pvt->hangup = mgcp_hangup;
- tmp->pvt->answer = mgcp_answer;
- tmp->pvt->read = mgcp_read;
- tmp->pvt->write = mgcp_write;
- tmp->pvt->indicate = mgcp_indicate;
- tmp->pvt->fixup = mgcp_fixup;
- tmp->pvt->send_digit = mgcp_senddigit;
- tmp->pvt->bridge = ast_rtp_bridge;
+ tmp->rawreadformat = fmt;
+ tmp->tech_pvt = sub;
if (strlen(i->language))
strncpy(tmp->language, i->language, sizeof(tmp->language)-1);
if (strlen(i->accountcode))
@@ -2528,7 +2544,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->pvt->pvt;
+ struct mgcp_subchannel *sub = chan->tech_pvt;
struct mgcp_endpoint *p = sub->parent;
char exten[AST_MAX_EXTENSION] = "";
int len = 0;
@@ -3881,7 +3897,7 @@ static struct mgcp_gateway *build_gateway(char *cat, struct ast_variable *v)
static struct ast_rtp *mgcp_get_rtp_peer(struct ast_channel *chan)
{
struct mgcp_subchannel *sub;
- sub = chan->pvt->pvt;
+ sub = chan->tech_pvt;
if (sub && sub->rtp && sub->parent->canreinvite)
return sub->rtp;
return NULL;
@@ -3891,7 +3907,7 @@ static int mgcp_set_rtp_peer(struct ast_channel *chan, struct ast_rtp *rtp, stru
{
/* XXX Is there such thing as video support with MGCP? XXX */
struct mgcp_subchannel *sub;
- sub = chan->pvt->pvt;
+ sub = chan->tech_pvt;
if (sub) {
transmit_modify_with_sdp(sub, rtp, codecs);
return 0;
@@ -3900,8 +3916,9 @@ static int mgcp_set_rtp_peer(struct ast_channel *chan, struct ast_rtp *rtp, stru
}
static struct ast_rtp_protocol mgcp_rtp = {
- get_rtp_info: mgcp_get_rtp_peer,
- set_rtp_peer: mgcp_set_rtp_peer,
+ .type = type,
+ .get_rtp_info = mgcp_get_rtp_peer,
+ .set_rtp_peer = mgcp_set_rtp_peer,
};
static int mgcp_do_debug(int fd, int argc, char *argv[])
@@ -4226,11 +4243,10 @@ int load_module()
if (!(res = reload_config())) {
/* Make sure we can register our mgcp channel type */
- if (ast_channel_register(type, tdesc, capability, mgcp_request)) {
+ if (ast_channel_register(&mgcp_tech)) {
ast_log(LOG_ERROR, "Unable to register channel class %s\n", type);
return -1;
}
- mgcp_rtp.type = type;
ast_rtp_proto_register(&mgcp_rtp);
ast_cli_register(&cli_show_endpoints);
ast_cli_register(&cli_audit_endpoint);
@@ -4274,7 +4290,7 @@ int unload_module()
#if 0
struct mgcp_endpoint *p, *pl;
/* First, take us out of the channel loop */
- ast_channel_unregister(type);
+ ast_channel_unregister(&mgcp_tech);
if (!ast_mutex_lock(&gatelock)) {
/* Hangup all interfaces if they have an owner */
p = iflist;
@@ -4339,5 +4355,5 @@ char *key()
char *description()
{
- return desc;
+ return (char *) desc;
}
diff --git a/channels/chan_modem.c b/channels/chan_modem.c
index 74f9ec7fc..64c73aa38 100755
--- a/channels/chan_modem.c
+++ b/channels/chan_modem.c
@@ -15,7 +15,6 @@
#include <string.h>
#include <asterisk/lock.h>
#include <asterisk/channel.h>
-#include <asterisk/channel_pvt.h>
#include <asterisk/config.h>
#include <asterisk/logger.h>
#include <asterisk/module.h>
@@ -39,10 +38,10 @@
/* Up to 10 seconds for an echo to arrive */
#define ECHO_TIMEOUT 10
-static char *desc = "Generic Voice Modem Driver";
-static char *tdesc = "Generic Voice Modem Channel Driver";
-static char *type = "Modem";
-static char *config = "modem.conf";
+static const char desc[] = "Generic Voice Modem Driver";
+static const char tdesc[] = "Generic Voice Modem Channel Driver";
+static const char type[] = "Modem";
+static const char config[] = "modem.conf";
static char dialtype = 'T';
static int gmode = MODEM_MODE_IMMEDIATE;
@@ -97,6 +96,29 @@ static pthread_t monitor_thread = AST_PTHREADT_NULL;
static int restart_monitor(void);
+static struct ast_channel *modem_request(const char *type, int format, void *data, int *cause);
+static int modem_digit(struct ast_channel *ast, char digit);
+static int modem_call(struct ast_channel *ast, char *idest, int timeout);
+static int modem_hangup(struct ast_channel *ast);
+static int modem_answer(struct ast_channel *ast);
+static struct ast_frame *modem_read(struct ast_channel *);
+static int modem_write(struct ast_channel *ast, struct ast_frame *frame);
+static int modem_fixup(struct ast_channel *oldchan, struct ast_channel *newchan);
+
+static const struct ast_channel_tech modem_tech = {
+ .type = type,
+ .description = tdesc,
+ .capabilities = AST_FORMAT_SLINEAR,
+ .requester = modem_request,
+ .send_digit = modem_digit,
+ .call = modem_call,
+ .hangup = modem_hangup,
+ .answer = modem_answer,
+ .read = modem_read,
+ .write = modem_write,
+ .fixup = modem_fixup,
+};
+
/* The private structures of the Phone Jack channels are linked for
selecting outgoing channels */
@@ -105,7 +127,7 @@ static struct ast_modem_pvt *iflist = NULL;
static int modem_digit(struct ast_channel *ast, char digit)
{
struct ast_modem_pvt *p;
- p = ast->pvt->pvt;
+ p = ast->tech_pvt;
if (p->mc->dialdigit)
return p->mc->dialdigit(p, digit);
ast_log(LOG_DEBUG, "Channel %s lacks digit dialing\n", ast->name);
@@ -114,8 +136,6 @@ static int modem_digit(struct ast_channel *ast, char digit)
static struct ast_modem_driver *drivers = NULL;
-static struct ast_frame *modem_read(struct ast_channel *);
-
static struct ast_modem_driver *find_capability(char *ident)
{
struct ast_modem_driver *mc;
@@ -191,7 +211,7 @@ static int modem_call(struct ast_channel *ast, char *idest, int timeout)
ast_log(LOG_WARNING, "Destination %s requres a real destination (device:destination)\n", idest);
return -1;
}
- p = ast->pvt->pvt;
+ p = ast->tech_pvt;
strncpy(dstr, where + p->stripmsd, sizeof(dstr) - 1);
/* if not a transfer or just sending tones, must be in correct state */
if (strcasecmp(rdest, "transfer") && strcasecmp(rdest,"sendtones")) {
@@ -421,7 +441,7 @@ static int modem_hangup(struct ast_channel *ast)
struct ast_modem_pvt *p;
if (option_debug)
ast_log(LOG_DEBUG, "modem_hangup(%s)\n", ast->name);
- p = ast->pvt->pvt;
+ p = ast->tech_pvt;
/* Hang up */
if (p->mc->hangup)
p->mc->hangup(p);
@@ -432,7 +452,7 @@ static int modem_hangup(struct ast_channel *ast)
memset(p->cid_num, 0, sizeof(p->cid_num));
memset(p->cid_name, 0, sizeof(p->cid_name));
memset(p->dnid, 0, sizeof(p->dnid));
- ((struct ast_modem_pvt *)(ast->pvt->pvt))->owner = NULL;
+ ((struct ast_modem_pvt *)(ast->tech_pvt))->owner = NULL;
ast_mutex_lock(&usecnt_lock);
usecnt--;
if (usecnt < 0)
@@ -441,7 +461,7 @@ static int modem_hangup(struct ast_channel *ast)
ast_update_use_count();
if (option_verbose > 2)
ast_verbose( VERBOSE_PREFIX_3 "Hungup '%s'\n", ast->name);
- ast->pvt->pvt = NULL;
+ ast->tech_pvt = NULL;
ast_setstate(ast, AST_STATE_DOWN);
restart_monitor();
return 0;
@@ -453,7 +473,7 @@ static int modem_answer(struct ast_channel *ast)
int res=0;
if (option_debug)
ast_log(LOG_DEBUG, "modem_answer(%s)\n", ast->name);
- p = ast->pvt->pvt;
+ p = ast->tech_pvt;
if (p->mc->answer) {
res = p->mc->answer(p);
}
@@ -479,7 +499,7 @@ static char modem_2digit(char c)
#endif
static struct ast_frame *modem_read(struct ast_channel *ast)
{
- struct ast_modem_pvt *p = ast->pvt->pvt;
+ struct ast_modem_pvt *p = ast->tech_pvt;
struct ast_frame *fr=NULL;
if (p->mc->read)
fr = p->mc->read(p);
@@ -490,7 +510,7 @@ static int modem_write(struct ast_channel *ast, struct ast_frame *frame)
{
int res=0;
long flags;
- struct ast_modem_pvt *p = ast->pvt->pvt;
+ struct ast_modem_pvt *p = ast->tech_pvt;
/* Modems tend to get upset when they receive data whilst in
* command mode. This makes esp. dial commands short lived.
@@ -512,7 +532,7 @@ static int modem_write(struct ast_channel *ast, struct ast_frame *frame)
static int modem_fixup(struct ast_channel *oldchan, struct ast_channel *newchan)
{
- struct ast_modem_pvt *p = newchan->pvt->pvt;
+ struct ast_modem_pvt *p = newchan->tech_pvt;
ast_log(LOG_WARNING, "fixup called\n");
if (p->owner!=oldchan) {
ast_log(LOG_WARNING, "old channel wasn't %p but was %p\n",oldchan,p->owner);
@@ -527,6 +547,7 @@ struct ast_channel *ast_modem_new(struct ast_modem_pvt *i, int state)
struct ast_channel *tmp;
tmp = ast_channel_alloc(1);
if (tmp) {
+ tmp->tech = &modem_tech;
snprintf(tmp->name, sizeof(tmp->name), "Modem[%s]/%s", i->mc->name, i->dev + 5);
tmp->type = type;
tmp->fds[0] = i->fd;
@@ -534,14 +555,7 @@ struct ast_channel *ast_modem_new(struct ast_modem_pvt *i, int state)
ast_setstate(tmp, state);
if (state == AST_STATE_RING)
tmp->rings = 1;
- tmp->pvt->pvt = i;
- tmp->pvt->send_digit = modem_digit;
- tmp->pvt->call = modem_call;
- tmp->pvt->hangup = modem_hangup;
- tmp->pvt->answer = modem_answer;
- tmp->pvt->read = modem_read;
- tmp->pvt->write = modem_write;
- tmp->pvt->fixup = modem_fixup;
+ tmp->tech_pvt = i;
strncpy(tmp->context, i->context, sizeof(tmp->context)-1);
if (!ast_strlen_zero(i->cid_num))
@@ -889,7 +903,7 @@ static int __unload_module(void)
{
struct ast_modem_pvt *p, *pl;
/* First, take us out of the channel loop */
- ast_channel_unregister(type);
+ ast_channel_unregister(&modem_tech);
if (!ast_mutex_lock(&iflock)) {
/* Hangup all interfaces if they have an owner */
p = iflist;
@@ -1052,8 +1066,7 @@ int load_module()
v = v->next;
}
ast_mutex_unlock(&iflock);
- if (ast_channel_register(type, tdesc, /* XXX Don't know our types -- maybe we should register more than one XXX */
- AST_FORMAT_SLINEAR, modem_request)) {
+ if (ast_channel_register(&modem_tech)) {
ast_log(LOG_ERROR, "Unable to register channel class %s\n", type);
ast_config_destroy(cfg);
__unload_module();
@@ -1076,7 +1089,7 @@ int usecount(void)
char *description()
{
- return desc;
+ return (char *) desc;
}
char *key()
diff --git a/channels/chan_nbs.c b/channels/chan_nbs.c
index b3fdfbf93..184b694dd 100755
--- a/channels/chan_nbs.c
+++ b/channels/chan_nbs.c
@@ -15,7 +15,6 @@
#include <string.h>
#include <asterisk/lock.h>
#include <asterisk/channel.h>
-#include <asterisk/channel_pvt.h>
#include <asterisk/config.h>
#include <asterisk/logger.h>
#include <asterisk/module.h>
@@ -31,9 +30,9 @@
#include <sys/ioctl.h>
#include <nbs.h>
-static char *desc = "Network Broadcast Sound Support";
-static char *type = "NBS";
-static char *tdesc = "Network Broadcast Sound Driver";
+static const char desc[] = "Network Broadcast Sound Support";
+static const char type[] = "NBS";
+static const char tdesc[] = "Network Broadcast Sound Driver";
static int usecnt =0;
@@ -54,11 +53,28 @@ struct nbs_pvt {
struct ast_frame fr; /* "null" frame */
};
+static struct ast_channel *nbs_request(const char *type, int format, void *data, int *cause);
+static int nbs_call(struct ast_channel *ast, char *dest, int timeout);
+static int nbs_hangup(struct ast_channel *ast);
+static struct ast_frame *nbs_xread(struct ast_channel *ast);
+static int nbs_xwrite(struct ast_channel *ast, struct ast_frame *frame);
+
+static const struct ast_channel_tech nbs_tech = {
+ .type = type,
+ .description = tdesc,
+ .capabilities = AST_FORMAT_SLINEAR,
+ .requester = nbs_request,
+ .call = nbs_call,
+ .hangup = nbs_hangup,
+ .read = nbs_xread,
+ .write = nbs_xwrite,
+};
+
static int nbs_call(struct ast_channel *ast, char *dest, int timeout)
{
struct nbs_pvt *p;
- p = ast->pvt->pvt;
+ p = ast->tech_pvt;
if ((ast->_state != AST_STATE_DOWN) && (ast->_state != AST_STATE_RESERVED)) {
ast_log(LOG_WARNING, "nbs_call called on %s, neither down nor reserved\n", ast->name);
@@ -135,22 +151,22 @@ static struct nbs_pvt *nbs_alloc(void *data)
static int nbs_hangup(struct ast_channel *ast)
{
struct nbs_pvt *p;
- p = ast->pvt->pvt;
+ p = ast->tech_pvt;
if (option_debug)
ast_log(LOG_DEBUG, "nbs_hangup(%s)\n", ast->name);
- if (!ast->pvt->pvt) {
+ if (!ast->tech_pvt) {
ast_log(LOG_WARNING, "Asked to hangup channel not connected\n");
return 0;
}
nbs_destroy(p);
- ast->pvt->pvt = NULL;
+ ast->tech_pvt = NULL;
ast_setstate(ast, AST_STATE_DOWN);
return 0;
}
static struct ast_frame *nbs_xread(struct ast_channel *ast)
{
- struct nbs_pvt *p = ast->pvt->pvt;
+ struct nbs_pvt *p = ast->tech_pvt;
/* Some nice norms */
@@ -170,7 +186,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->pvt->pvt;
+ struct nbs_pvt *p = ast->tech_pvt;
/* Write a frame of (presumably voice) data */
if (frame->frametype != AST_FRAME_VOICE) {
if (frame->frametype != AST_FRAME_IMAGE)
@@ -196,22 +212,19 @@ static struct ast_channel *nbs_new(struct nbs_pvt *i, int state)
struct ast_channel *tmp;
tmp = ast_channel_alloc(1);
if (tmp) {
+ tmp->tech = &nbs_tech;
snprintf(tmp->name, sizeof(tmp->name), "NBS/%s", i->stream);
tmp->type = type;
tmp->fds[0] = nbs_fd(i->nbs);
tmp->nativeformats = prefformat;
- tmp->pvt->rawreadformat = prefformat;
- tmp->pvt->rawwriteformat = prefformat;
+ tmp->rawreadformat = prefformat;
+ tmp->rawwriteformat = prefformat;
tmp->writeformat = prefformat;
tmp->readformat = prefformat;
ast_setstate(tmp, state);
if (state == AST_STATE_RING)
tmp->rings = 1;
- tmp->pvt->pvt = i;
- tmp->pvt->call = nbs_call;
- tmp->pvt->hangup = nbs_hangup;
- tmp->pvt->read = nbs_xread;
- tmp->pvt->write = nbs_xwrite;
+ tmp->tech_pvt = i;
strncpy(tmp->context, context, sizeof(tmp->context)-1);
strncpy(tmp->exten, "s", sizeof(tmp->exten) - 1);
tmp->language[0] = '\0';
@@ -256,7 +269,7 @@ static struct ast_channel *nbs_request(const char *type, int format, void *data,
static int __unload_module(void)
{
/* First, take us out of the channel loop */
- ast_channel_unregister(type);
+ ast_channel_unregister(&nbs_tech);
return 0;
}
@@ -267,9 +280,8 @@ int unload_module(void)
int load_module()
{
- /* Make sure we can register our Adtranphone channel type */
- if (ast_channel_register(type, tdesc,
- AST_FORMAT_SLINEAR, nbs_request)) {
+ /* Make sure we can register our channel type */
+ if (ast_channel_register(&nbs_tech)) {
ast_log(LOG_ERROR, "Unable to register channel class %s\n", type);
__unload_module();
return -1;
@@ -288,7 +300,7 @@ int usecount()
char *description()
{
- return desc;
+ return (char *) desc;
}
char *key()
diff --git a/channels/chan_oss.c b/channels/chan_oss.c
index b6dbeae22..1a34a5eb5 100755
--- a/channels/chan_oss.c
+++ b/channels/chan_oss.c
@@ -20,7 +20,6 @@
#include <asterisk/logger.h>
#include <asterisk/channel.h>
#include <asterisk/module.h>
-#include <asterisk/channel_pvt.h>
#include <asterisk/options.h>
#include <asterisk/pbx.h>
#include <asterisk/config.h>
@@ -75,10 +74,10 @@ static int playbackonly = 0;
AST_MUTEX_DEFINE_STATIC(usecnt_lock);
-static char *type = "Console";
-static char *desc = "OSS Console Channel Driver";
-static char *tdesc = "OSS Console Channel Driver";
-static char *config = "oss.conf";
+static const char type[] = "Console";
+static const char desc[] = "OSS Console Channel Driver";
+static const char tdesc[] = "OSS Console Channel Driver";
+static const char config[] = "oss.conf";
static char context[AST_MAX_EXTENSION] = "default";
static char language[MAX_LANGUAGE] = "";
@@ -116,6 +115,33 @@ static struct chan_oss_pvt {
char context[AST_MAX_EXTENSION];
} oss;
+static struct ast_channel *oss_request(const char *type, int format, void *data, int *cause);
+static int oss_digit(struct ast_channel *c, char digit);
+static int oss_text(struct ast_channel *c, char *text);
+static int oss_hangup(struct ast_channel *c);
+static int oss_answer(struct ast_channel *c);
+static struct ast_frame *oss_read(struct ast_channel *chan);
+static int oss_call(struct ast_channel *c, char *dest, int timeout);
+static int oss_write(struct ast_channel *chan, struct ast_frame *f);
+static int oss_indicate(struct ast_channel *chan, int cond);
+static int oss_fixup(struct ast_channel *oldchan, struct ast_channel *newchan);
+
+static const struct ast_channel_tech oss_tech = {
+ .type = type,
+ .description = tdesc,
+ .capabilities = AST_FORMAT_SLINEAR,
+ .requester = oss_request,
+ .send_digit = oss_digit,
+ .send_text = oss_text,
+ .hangup = oss_hangup,
+ .answer = oss_answer,
+ .read = oss_read,
+ .call = oss_call,
+ .write = oss_write,
+ .indicate = oss_indicate,
+ .fixup = oss_fixup,
+};
+
static int time_has_passed(void)
{
struct timeval tv;
@@ -500,7 +526,7 @@ static int oss_hangup(struct ast_channel *c)
{
int res = 0;
cursound = -1;
- c->pvt->pvt = NULL;
+ c->tech_pvt = NULL;
oss.owner = NULL;
ast_verbose( " << Hangup on console >> \n");
ast_mutex_lock(&usecnt_lock);
@@ -676,7 +702,7 @@ static struct ast_frame *oss_read(struct ast_channel *chan)
static int oss_fixup(struct ast_channel *oldchan, struct ast_channel *newchan)
{
- struct chan_oss_pvt *p = newchan->pvt->pvt;
+ struct chan_oss_pvt *p = newchan->tech_pvt;
p->owner = newchan;
return 0;
}
@@ -712,22 +738,14 @@ static struct ast_channel *oss_new(struct chan_oss_pvt *p, int state)
struct ast_channel *tmp;
tmp = ast_channel_alloc(1);
if (tmp) {
+ tmp->tech = &oss_tech;
snprintf(tmp->name, sizeof(tmp->name), "OSS/%s", DEV_DSP + 5);
tmp->type = type;
tmp->fds[0] = sounddev;
tmp->nativeformats = AST_FORMAT_SLINEAR;
tmp->readformat = AST_FORMAT_SLINEAR;
tmp->writeformat = AST_FORMAT_SLINEAR;
- tmp->pvt->pvt = p;
- tmp->pvt->send_digit = oss_digit;
- tmp->pvt->send_text = oss_text;
- tmp->pvt->hangup = oss_hangup;
- tmp->pvt->answer = oss_answer;
- tmp->pvt->read = oss_read;
- tmp->pvt->call = oss_call;
- tmp->pvt->write = oss_write;
- tmp->pvt->indicate = oss_indicate;
- tmp->pvt->fixup = oss_fixup;
+ tmp->tech_pvt = p;
if (strlen(p->context))
strncpy(tmp->context, p->context, sizeof(tmp->context)-1);
if (strlen(p->exten))
@@ -1019,7 +1037,7 @@ int load_module()
}
if (!full_duplex)
ast_log(LOG_WARNING, "XXX I don't work right with non-full duplex sound cards XXX\n");
- res = ast_channel_register(type, tdesc, AST_FORMAT_SLINEAR, oss_request);
+ res = ast_channel_register(&oss_tech);
if (res < 0) {
ast_log(LOG_ERROR, "Unable to register channel class '%s'\n", type);
return -1;
@@ -1056,6 +1074,8 @@ int load_module()
int unload_module()
{
int x;
+
+ ast_channel_unregister(&oss_tech);
for (x=0;x<sizeof(myclis)/sizeof(struct ast_cli_entry); x++)
ast_cli_unregister(myclis + x);
close(sounddev);
@@ -1072,7 +1092,7 @@ int unload_module()
char *description()
{
- return desc;
+ return (char *) desc;
}
int usecount()
diff --git a/channels/chan_phone.c b/channels/chan_phone.c
index 3493a4a1a..81958e078 100755
--- a/channels/chan_phone.c
+++ b/channels/chan_phone.c
@@ -16,7 +16,6 @@
#include <ctype.h>
#include <asterisk/lock.h>
#include <asterisk/channel.h>
-#include <asterisk/channel_pvt.h>
#include <asterisk/config.h>
#include <asterisk/logger.h>
#include <asterisk/module.h>
@@ -62,10 +61,10 @@
#define PHONE_MAX_BUF 480
#define DEFAULT_GAIN 0x100
-static char *desc = "Linux Telephony API Support";
-static char *type = "Phone";
-static char *tdesc = "Standard Linux Telephony API Driver";
-static char *config = "phone.conf";
+static const char desc[] = "Linux Telephony API Support";
+static const char type[] = "Phone";
+static const char tdesc[] = "Standard Linux Telephony API Driver";
+static const char config[] = "phone.conf";
/* Default context for dialtone mode */
static char context[AST_MAX_EXTENSION] = "default";
@@ -132,11 +131,52 @@ static struct phone_pvt {
static char cid_num[AST_MAX_EXTENSION];
static char cid_name[AST_MAX_EXTENSION];
+static struct ast_channel *phone_request(const char *type, int format, void *data, int *cause);
+static int phone_digit(struct ast_channel *ast, char digit);
+static int phone_call(struct ast_channel *ast, char *dest, int timeout);
+static int phone_hangup(struct ast_channel *ast);
+static int phone_answer(struct ast_channel *ast);
+static struct ast_frame *phone_read(struct ast_channel *ast);
+static int phone_write(struct ast_channel *ast, struct ast_frame *frame);
+static struct ast_frame *phone_exception(struct ast_channel *ast);
+static int phone_send_text(struct ast_channel *ast, char *text);
+
+static const struct ast_channel_tech phone_tech = {
+ .type = type,
+ .description = tdesc,
+ .capabilities = AST_FORMAT_G723_1 | AST_FORMAT_SLINEAR | AST_FORMAT_ULAW,
+ .requester = phone_request,
+ .send_digit = phone_digit,
+ .call = phone_call,
+ .hangup = phone_hangup,
+ .answer = phone_answer,
+ .read = phone_read,
+ .write = phone_write,
+ .exception = phone_exception,
+};
+
+static struct ast_channel_tech phone_tech_fxs = {
+ .type = type,
+ .description = tdesc,
+ .requester = phone_request,
+ .send_digit = phone_digit,
+ .call = phone_call,
+ .hangup = phone_hangup,
+ .answer = phone_answer,
+ .read = phone_read,
+ .write = phone_write,
+ .exception = phone_exception,
+ .write_video = phone_write,
+ .send_text = phone_send_text,
+};
+
+static struct ast_channel_tech *cur_tech;
+
static int phone_digit(struct ast_channel *ast, char digit)
{
struct phone_pvt *p;
int outdigit;
- p = ast->pvt->pvt;
+ p = ast->tech_pvt;
ast_log(LOG_NOTICE, "Dialed %c\n", digit);
switch(digit) {
case '0':
@@ -202,7 +242,7 @@ static int phone_call(struct ast_channel *ast, char *dest, int timeout)
if (ast->cid.cid_num)
strncpy(cid.number, ast->cid.cid_num, sizeof(cid.number) - 1);
- p = ast->pvt->pvt;
+ p = ast->tech_pvt;
if ((ast->_state != AST_STATE_DOWN) && (ast->_state != AST_STATE_RESERVED)) {
ast_log(LOG_WARNING, "phone_call called on %s, neither down nor reserved\n", ast->name);
@@ -233,10 +273,10 @@ static int phone_call(struct ast_channel *ast, char *dest, int timeout)
static int phone_hangup(struct ast_channel *ast)
{
struct phone_pvt *p;
- p = ast->pvt->pvt;
+ p = ast->tech_pvt;
if (option_debug)
ast_log(LOG_DEBUG, "phone_hangup(%s)\n", ast->name);
- if (!ast->pvt->pvt) {
+ if (!ast->tech_pvt) {
ast_log(LOG_WARNING, "Asked to hangup channel not connected\n");
return 0;
}
@@ -270,7 +310,7 @@ 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->pvt->pvt))->owner = NULL;
+ ((struct phone_pvt *)(ast->tech_pvt))->owner = NULL;
ast_mutex_lock(&usecnt_lock);
usecnt--;
if (usecnt < 0)
@@ -279,7 +319,7 @@ static int phone_hangup(struct ast_channel *ast)
ast_update_use_count();
if (option_verbose > 2)
ast_verbose( VERBOSE_PREFIX_3 "Hungup '%s'\n", ast->name);
- ast->pvt->pvt = NULL;
+ ast->tech_pvt = NULL;
ast_setstate(ast, AST_STATE_DOWN);
restart_monitor();
return 0;
@@ -288,10 +328,10 @@ static int phone_hangup(struct ast_channel *ast)
static int phone_setup(struct ast_channel *ast)
{
struct phone_pvt *p;
- p = ast->pvt->pvt;
+ p = ast->tech_pvt;
ioctl(p->fd, PHONE_CPT_STOP);
/* Nothing to answering really, just start recording */
- if (ast->pvt->rawreadformat == AST_FORMAT_G723_1) {
+ if (ast->rawreadformat == AST_FORMAT_G723_1) {
/* Prefer g723 */
ioctl(p->fd, PHONE_REC_STOP);
if (p->lastinput != AST_FORMAT_G723_1) {
@@ -301,7 +341,7 @@ static int phone_setup(struct ast_channel *ast)
return -1;
}
}
- } else if (ast->pvt->rawreadformat == AST_FORMAT_SLINEAR) {
+ } else if (ast->rawreadformat == AST_FORMAT_SLINEAR) {
ioctl(p->fd, PHONE_REC_STOP);
if (p->lastinput != AST_FORMAT_SLINEAR) {
p->lastinput = AST_FORMAT_SLINEAR;
@@ -310,7 +350,7 @@ static int phone_setup(struct ast_channel *ast)
return -1;
}
}
- } else if (ast->pvt->rawreadformat == AST_FORMAT_ULAW) {
+ } else if (ast->rawreadformat == AST_FORMAT_ULAW) {
ioctl(p->fd, PHONE_REC_STOP);
if (p->lastinput != AST_FORMAT_ULAW) {
p->lastinput = AST_FORMAT_ULAW;
@@ -321,16 +361,16 @@ static int phone_setup(struct ast_channel *ast)
}
} else if (p->mode == MODE_FXS) {
ioctl(p->fd, PHONE_REC_STOP);
- if (p->lastinput != ast->pvt->rawreadformat) {
- p->lastinput = ast->pvt->rawreadformat;
- if (ioctl(p->fd, PHONE_REC_CODEC, ast->pvt->rawreadformat)) {
+ if (p->lastinput != ast->rawreadformat) {
+ p->lastinput = ast->rawreadformat;
+ if (ioctl(p->fd, PHONE_REC_CODEC, ast->rawreadformat)) {
ast_log(LOG_WARNING, "Failed to set codec to %d\n",
- ast->pvt->rawreadformat);
+ ast->rawreadformat);
return -1;
}
}
} else {
- ast_log(LOG_WARNING, "Can't do format %s\n", ast_getformatname(ast->pvt->rawreadformat));
+ ast_log(LOG_WARNING, "Can't do format %s\n", ast_getformatname(ast->rawreadformat));
return -1;
}
if (ioctl(p->fd, PHONE_REC_START)) {
@@ -346,7 +386,7 @@ static int phone_setup(struct ast_channel *ast)
static int phone_answer(struct ast_channel *ast)
{
struct phone_pvt *p;
- p = ast->pvt->pvt;
+ p = ast->tech_pvt;
/* 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))
@@ -380,7 +420,7 @@ static struct ast_frame *phone_exception(struct ast_channel *ast)
{
int res;
union telephony_exception phonee;
- struct phone_pvt *p = ast->pvt->pvt;
+ struct phone_pvt *p = ast->tech_pvt;
char digit;
/* Some nice norms */
@@ -443,7 +483,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->pvt->pvt;
+ struct phone_pvt *p = ast->tech_pvt;
/* Some nice norms */
@@ -530,13 +570,13 @@ static int phone_write_buf(struct phone_pvt *p, char *buf, int len, int frlen)
static int phone_send_text(struct ast_channel *ast, char *text)
{
int length = strlen(text);
- return phone_write_buf(ast->pvt->pvt, text, length, length) ==
+ return phone_write_buf(ast->tech_pvt, text, length, length) ==
length ? 0 : -1;
}
static int phone_write(struct ast_channel *ast, struct ast_frame *frame)
{
- struct phone_pvt *p = ast->pvt->pvt;
+ struct phone_pvt *p = ast->tech_pvt;
int res;
int maxfr=0;
char *pos;
@@ -713,6 +753,7 @@ static struct ast_channel *phone_new(struct phone_pvt *i, int state, char *conte
struct phone_codec_data codec;
tmp = ast_channel_alloc(1);
if (tmp) {
+ tmp->tech = cur_tech;
snprintf(tmp->name, sizeof(tmp->name), "Phone/%s", i->dev + 5);
tmp->type = type;
tmp->fds[0] = i->fd;
@@ -721,36 +762,25 @@ static struct ast_channel *phone_new(struct phone_pvt *i, int state, char *conte
ioctl(i->fd, PHONE_QUERY_CODEC, &codec) == 0) {
if (codec.type == LINEAR16)
tmp->nativeformats =
- tmp->pvt->rawreadformat =
- tmp->pvt->rawwriteformat =
+ tmp->rawreadformat =
+ tmp->rawwriteformat =
AST_FORMAT_SLINEAR;
else {
tmp->nativeformats =
- tmp->pvt->rawreadformat =
- tmp->pvt->rawwriteformat =
+ tmp->rawreadformat =
+ tmp->rawwriteformat =
prefformat & ~AST_FORMAT_SLINEAR;
}
}
else {
tmp->nativeformats = prefformat;
- tmp->pvt->rawreadformat = prefformat;
- tmp->pvt->rawwriteformat = prefformat;
+ tmp->rawreadformat = prefformat;
+ tmp->rawwriteformat = prefformat;
}
ast_setstate(tmp, state);
if (state == AST_STATE_RING)
tmp->rings = 1;
- tmp->pvt->pvt = i;
- tmp->pvt->send_digit = phone_digit;
- tmp->pvt->call = phone_call;
- tmp->pvt->hangup = phone_hangup;
- tmp->pvt->answer = phone_answer;
- tmp->pvt->read = phone_read;
- tmp->pvt->write = phone_write;
- if (i->mode == MODE_FXS) {
- tmp->pvt->write_video = phone_write;
- tmp->pvt->send_text = phone_send_text;
- }
- tmp->pvt->exception = phone_exception;
+ tmp->tech_pvt = i;
strncpy(tmp->context, context, sizeof(tmp->context)-1);
if (strlen(i->ext))
strncpy(tmp->exten, i->ext, sizeof(tmp->exten)-1);
@@ -1172,7 +1202,7 @@ static int __unload_module(void)
{
struct phone_pvt *p, *pl;
/* First, take us out of the channel loop */
- ast_channel_unregister(type);
+ ast_channel_unregister(cur_tech);
if (!ast_mutex_lock(&iflock)) {
/* Hangup all interfaces if they have an owner */
p = iflist;
@@ -1312,10 +1342,16 @@ int load_module()
v = v->next;
}
ast_mutex_unlock(&iflock);
+
+ if (mode == MODE_FXS) {
+ phone_tech_fxs.capabilities = prefformat;
+ cur_tech = &phone_tech_fxs;
+ } else
+ cur_tech = (struct ast_channel_tech *) &phone_tech;
+
/* Make sure we can register our Adtranphone channel type */
- if (ast_channel_register(type, tdesc, mode != MODE_FXS ?
- AST_FORMAT_G723_1 | AST_FORMAT_SLINEAR |
- AST_FORMAT_ULAW : prefformat, phone_request)) {
+
+ if (ast_channel_register(cur_tech)) {
ast_log(LOG_ERROR, "Unable to register channel class %s\n", type);
ast_config_destroy(cfg);
__unload_module();
@@ -1338,7 +1374,7 @@ int usecount()
char *description()
{
- return desc;
+ return (char *) desc;
}
char *key()
diff --git a/channels/chan_sip.c b/channels/chan_sip.c
index 5eb4cd8e0..ad52a1da3 100755
--- a/channels/chan_sip.c
+++ b/channels/chan_sip.c
@@ -17,7 +17,6 @@
#include <string.h>
#include <asterisk/lock.h>
#include <asterisk/channel.h>
-#include <asterisk/channel_pvt.h>
#include <asterisk/config.h>
#include <asterisk/logger.h>
#include <asterisk/module.h>
@@ -110,11 +109,10 @@ static int default_expiry = DEFAULT_DEFAULT_EXPIRY;
#define DEBUG_READ 0 /* Recieved data */
#define DEBUG_SEND 1 /* Transmit data */
-static char *desc = "Session Initiation Protocol (SIP)";
-static char *channeltype = "SIP";
-static char *tdesc = "Session Initiation Protocol (SIP)";
-static char *config = "sip.conf";
-static char *notify_config = "sip_notify.conf";
+static const char desc[] = "Session Initiation Protocol (SIP)";
+static const char channeltype[] = "SIP";
+static const char config[] = "sip.conf";
+static const char notify_config[] = "sip_notify.conf";
#define DEFAULT_SIP_PORT 5060 /* From RFC 2543 */
#define SIP_MAX_PACKET 4096 /* Also from RFC 2543, should sub headers tho */
@@ -615,6 +613,40 @@ static int sip_do_reload(void);
static int expire_register(void *data);
static int callevents = 0;
+static struct ast_channel *sip_request(const char *type, int format, void *data, int *cause);
+static int sip_devicestate(void *data);
+static int sip_sendtext(struct ast_channel *ast, char *text);
+static int sip_call(struct ast_channel *ast, char *dest, int timeout);
+static int sip_hangup(struct ast_channel *ast);
+static int sip_answer(struct ast_channel *ast);
+static struct ast_frame *sip_read(struct ast_channel *ast);
+static int sip_write(struct ast_channel *ast, struct ast_frame *frame);
+static int sip_indicate(struct ast_channel *ast, int condition);
+static int sip_transfer(struct ast_channel *ast, char *dest);
+static int sip_fixup(struct ast_channel *oldchan, struct ast_channel *newchan);
+static int sip_senddigit(struct ast_channel *ast, char digit);
+static int sip_sendtext(struct ast_channel *ast, char *text);
+
+static const struct ast_channel_tech sip_tech = {
+ .type = channeltype,
+ .description = "Session Initiation Protocol (SIP)",
+ .capabilities = ((AST_FORMAT_MAX_AUDIO << 1) - 1),
+ .requester = sip_request,
+ .devicestate = sip_devicestate,
+ .call = sip_call,
+ .hangup = sip_hangup,
+ .answer = sip_answer,
+ .read = sip_read,
+ .write = sip_write,
+ .write_video = sip_write,
+ .indicate = sip_indicate,
+ .transfer = sip_transfer,
+ .fixup = sip_fixup,
+ .send_digit = sip_senddigit,
+ .bridge = ast_rtp_bridge,
+ .send_text = sip_sendtext,
+};
+
/*--- sip_debug_test_addr: See if we pass debug IP filter */
static inline int sip_debug_test_addr(struct sockaddr_in *addr)
{
@@ -1066,7 +1098,7 @@ static char *ditch_braces(char *tmp)
/* Called from PBX core text message functions */
static int sip_sendtext(struct ast_channel *ast, char *text)
{
- struct sip_pvt *p = ast->pvt->pvt;
+ struct sip_pvt *p = ast->tech_pvt;
int debug=sip_debug_test_pvt(p);
if (debug)
@@ -1452,7 +1484,7 @@ static int sip_call(struct ast_channel *ast, char *dest, int timeout)
struct ast_var_t *current;
int addsipheaders = 0;
- p = ast->pvt->pvt;
+ p = ast->tech_pvt;
if ((ast->_state != AST_STATE_DOWN) && (ast->_state != AST_STATE_RESERVED)) {
ast_log(LOG_WARNING, "sip_call called on %s, neither down nor reserved\n", ast->name);
return -1;
@@ -1563,7 +1595,7 @@ static void __sip_destroy(struct sip_pvt *p, int lockowner)
if (lockowner)
ast_mutex_lock(&p->owner->lock);
ast_log(LOG_DEBUG, "Detaching from %s\n", p->owner->name);
- p->owner->pvt->pvt = NULL;
+ p->owner->tech_pvt = NULL;
if (lockowner)
ast_mutex_unlock(&p->owner->lock);
}
@@ -1757,12 +1789,12 @@ static char *hangup_cause2sip(int cause)
/* Part of PBX interface */
static int sip_hangup(struct ast_channel *ast)
{
- struct sip_pvt *p = ast->pvt->pvt;
+ struct sip_pvt *p = ast->tech_pvt;
int needcancel = 0;
struct ast_flags locflags = {0};
if (option_debug)
ast_log(LOG_DEBUG, "sip_hangup(%s)\n", ast->name);
- if (!ast->pvt->pvt) {
+ if (!p) {
ast_log(LOG_DEBUG, "Asked to hangup channel not connected\n");
return 0;
}
@@ -1785,15 +1817,15 @@ static int sip_hangup(struct ast_channel *ast)
ast_mutex_unlock(&p->lock);
return 0;
}
- if (!ast || (ast->_state != AST_STATE_UP))
+ if (ast->_state != AST_STATE_UP)
needcancel = 1;
/* Disconnect */
- p = ast->pvt->pvt;
+ p = ast->tech_pvt;
if (p->vad) {
ast_dsp_free(p->vad);
}
p->owner = NULL;
- ast->pvt->pvt = NULL;
+ ast->tech_pvt = NULL;
ast_mutex_lock(&usecnt_lock);
usecnt--;
@@ -1850,7 +1882,7 @@ static int sip_answer(struct ast_channel *ast)
{
int res = 0,fmt;
char *codec;
- struct sip_pvt *p = ast->pvt->pvt;
+ struct sip_pvt *p = ast->tech_pvt;
ast_mutex_lock(&p->lock);
if (ast->_state != AST_STATE_UP) {
@@ -1883,7 +1915,7 @@ static int sip_answer(struct ast_channel *ast)
/*--- sip_write: Send response, support audio media ---*/
static int sip_write(struct ast_channel *ast, struct ast_frame *frame)
{
- struct sip_pvt *p = ast->pvt->pvt;
+ struct sip_pvt *p = ast->tech_pvt;
int res = 0;
if (frame->frametype == AST_FRAME_VOICE) {
if (!(frame->subclass & ast->nativeformats)) {
@@ -1930,7 +1962,7 @@ static int sip_write(struct ast_channel *ast, struct ast_frame *frame)
Basically update any ->owner links ----*/
static int sip_fixup(struct ast_channel *oldchan, struct ast_channel *newchan)
{
- struct sip_pvt *p = newchan->pvt->pvt;
+ struct sip_pvt *p = newchan->tech_pvt;
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);
@@ -1946,7 +1978,7 @@ static int sip_fixup(struct ast_channel *oldchan, struct ast_channel *newchan)
/* within one call, we're able to transmit in many methods simultaneously */
static int sip_senddigit(struct ast_channel *ast, char digit)
{
- struct sip_pvt *p = ast->pvt->pvt;
+ struct sip_pvt *p = ast->tech_pvt;
int res = 0;
ast_mutex_lock(&p->lock);
switch (ast_test_flag(p, SIP_DTMF)) {
@@ -1969,7 +2001,7 @@ static int sip_senddigit(struct ast_channel *ast, char digit)
/*--- sip_transfer: Transfer SIP call */
static int sip_transfer(struct ast_channel *ast, char *dest)
{
- struct sip_pvt *p = ast->pvt->pvt;
+ struct sip_pvt *p = ast->tech_pvt;
int res;
ast_mutex_lock(&p->lock);
@@ -1987,7 +2019,7 @@ static int sip_transfer(struct ast_channel *ast, char *dest)
the indication - busy signal, congestion etc */
static int sip_indicate(struct ast_channel *ast, int condition)
{
- struct sip_pvt *p = ast->pvt->pvt;
+ struct sip_pvt *p = ast->tech_pvt;
int res = 0;
ast_mutex_lock(&p->lock);
@@ -2061,6 +2093,7 @@ static struct ast_channel *sip_new(struct sip_pvt *i, int state, char *title)
tmp = ast_channel_alloc(1);
ast_mutex_lock(&i->lock);
if (tmp) {
+ tmp->tech = &sip_tech;
/* Select our native format based on codec preference until we receive
something from another device to the contrary. */
ast_mutex_lock(&i->lock);
@@ -2100,23 +2133,10 @@ static struct ast_channel *sip_new(struct sip_pvt *i, int state, char *title)
tmp->rings = 1;
tmp->adsicpe = AST_ADSI_UNAVAILABLE;
tmp->writeformat = fmt;
- tmp->pvt->rawwriteformat = fmt;
+ tmp->rawwriteformat = fmt;
tmp->readformat = fmt;
- tmp->pvt->rawreadformat = fmt;
- tmp->pvt->pvt = i;
- tmp->pvt->send_text = sip_sendtext;
- tmp->pvt->call = sip_call;
- tmp->pvt->hangup = sip_hangup;
- tmp->pvt->answer = sip_answer;
- tmp->pvt->read = sip_read;
- tmp->pvt->write = sip_write;
- tmp->pvt->write_video = sip_write;
- tmp->pvt->indicate = sip_indicate;
- tmp->pvt->transfer = sip_transfer;
- tmp->pvt->fixup = sip_fixup;
- tmp->pvt->send_digit = sip_senddigit;
-
- tmp->pvt->bridge = ast_rtp_bridge;
+ tmp->rawreadformat = fmt;
+ tmp->tech_pvt = i;
tmp->callgroup = i->callgroup;
tmp->pickupgroup = i->pickupgroup;
@@ -2337,7 +2357,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->pvt->pvt;
+ struct sip_pvt *p = ast->tech_pvt;
ast_mutex_lock(&p->lock);
fr = sip_rtp_read(ast, p);
time(&p->lastrtprx);
@@ -9762,7 +9782,7 @@ static struct ast_rtp *sip_get_rtp_peer(struct ast_channel *chan)
{
struct sip_pvt *p;
struct ast_rtp *rtp = NULL;
- p = chan->pvt->pvt;
+ p = chan->tech_pvt;
if (p) {
ast_mutex_lock(&p->lock);
if (p->rtp && ast_test_flag(p, SIP_CAN_REINVITE))
@@ -9776,7 +9796,7 @@ static struct ast_rtp *sip_get_vrtp_peer(struct ast_channel *chan)
{
struct sip_pvt *p;
struct ast_rtp *rtp = NULL;
- p = chan->pvt->pvt;
+ p = chan->tech_pvt;
if (p) {
ast_mutex_lock(&p->lock);
if (p->vrtp && ast_test_flag(p, SIP_CAN_REINVITE))
@@ -9790,7 +9810,7 @@ static struct ast_rtp *sip_get_vrtp_peer(struct ast_channel *chan)
static int sip_set_rtp_peer(struct ast_channel *chan, struct ast_rtp *rtp, struct ast_rtp *vrtp, int codecs)
{
struct sip_pvt *p;
- p = chan->pvt->pvt;
+ p = chan->tech_pvt;
if (p) {
ast_mutex_lock(&p->lock);
if (rtp)
@@ -9861,7 +9881,7 @@ static int sip_dtmfmode(struct ast_channel *chan, void *data)
ast_mutex_unlock(&chan->lock);
return 0;
}
- p = chan->pvt->pvt;
+ p = chan->tech_pvt;
if (p) {
ast_mutex_lock(&p->lock);
if (!strcasecmp(mode,"info")) {
@@ -9966,7 +9986,7 @@ static int sip_getheader(struct ast_channel *chan, void *data)
return 0;
}
- p = chan->pvt->pvt;
+ p = chan->tech_pvt;
content = get_header(&p->initreq, header); /* Get the header */
if (!ast_strlen_zero(content)) {
pbx_builtin_setvar_helper(chan, varname, content);
@@ -10064,12 +10084,13 @@ static int sip_sipredirect(struct sip_pvt *p, char *dest)
/*--- sip_get_codec: Return peers codec ---*/
static int sip_get_codec(struct ast_channel *chan)
{
- struct sip_pvt *p = chan->pvt->pvt;
+ struct sip_pvt *p = chan->tech_pvt;
return p->peercapability;
}
/*--- sip_rtp: Interface structure with callbacks used to connect to rtp module --*/
static struct ast_rtp_protocol sip_rtp = {
+ type: channeltype,
get_rtp_info: sip_get_rtp_peer,
get_vrtp_info: sip_get_vrtp_peer,
set_rtp_peer: sip_set_rtp_peer,
@@ -10170,7 +10191,7 @@ int load_module()
res = reload_config();
if (!res) {
/* Make sure we can register our sip channel type */
- if (ast_channel_register_ex(channeltype, tdesc, ((AST_FORMAT_MAX_AUDIO << 1) - 1), sip_request, sip_devicestate)) {
+ if (ast_channel_register(&sip_tech)) {
ast_log(LOG_ERROR, "Unable to register channel class %s\n", channeltype);
return -1;
}
@@ -10194,7 +10215,6 @@ int load_module()
ast_cli_register(&cli_no_history);
ast_cli_register(&cli_sip_reload);
ast_cli_register(&cli_inuse_show);
- sip_rtp.type = channeltype;
ast_rtp_proto_register(&sip_rtp);
ast_register_application(app_dtmfmode, sip_dtmfmode, synopsis_dtmfmode, descrip_dtmfmode);
ast_register_application(app_sipaddheader, sip_addheader, synopsis_sipaddheader, descrip_sipaddheader);
@@ -10237,7 +10257,7 @@ int unload_module()
ast_cli_unregister(&cli_sip_reload);
ast_cli_unregister(&cli_inuse_show);
ast_rtp_proto_unregister(&sip_rtp);
- ast_channel_unregister(channeltype);
+ ast_channel_unregister(&sip_tech);
if (!ast_mutex_lock(&iflock)) {
/* Hangup all interfaces if they have an owner */
p = iflist;
@@ -10310,7 +10330,7 @@ char *key()
char *description()
{
- return desc;
+ return (char *) desc;
}
diff --git a/channels/chan_skinny.c b/channels/chan_skinny.c
index 887646347..a5f849dc8 100755
--- a/channels/chan_skinny.c
+++ b/channels/chan_skinny.c
@@ -18,7 +18,6 @@
#include <string.h>
#include <asterisk/lock.h>
#include <asterisk/channel.h>
-#include <asterisk/channel_pvt.h>
#include <asterisk/config.h>
#include <asterisk/logger.h>
#include <asterisk/module.h>
@@ -56,10 +55,10 @@
/************************************************************************************/
/* Skinny/Asterisk Protocol Settings */
/************************************************************************************/
-static char *desc = "Skinny Client Control Protocol (Skinny)";
-static char *tdesc = "Skinny Client Control Protocol (Skinny)";
-static char *type = "Skinny";
-static char *config = "skinny.conf";
+static const char desc[] = "Skinny Client Control Protocol (Skinny)";
+static const char tdesc[] = "Skinny Client Control Protocol (Skinny)";
+static const char type[] = "Skinny";
+static const char config[] = "skinny.conf";
/* Just about everybody seems to support ulaw, so make it a nice default */
static int capability = AST_FORMAT_ULAW;
@@ -796,6 +795,32 @@ static struct skinnysession {
struct skinnysession *next;
} *sessions = NULL;
+static struct ast_channel *skinny_request(const char *type, int format, void *data, int *cause);
+static int skinny_call(struct ast_channel *ast, char *dest, int timeout);
+static int skinny_hangup(struct ast_channel *ast);
+static int skinny_answer(struct ast_channel *ast);
+static struct ast_frame *skinny_read(struct ast_channel *ast);
+static int skinny_write(struct ast_channel *ast, struct ast_frame *frame);
+static int skinny_indicate(struct ast_channel *ast, int ind);
+static int skinny_fixup(struct ast_channel *oldchan, struct ast_channel *newchan);
+static int skinny_senddigit(struct ast_channel *ast, char digit);
+
+static const struct ast_channel_tech skinny_tech = {
+ .type = type,
+ .description = tdesc,
+ .capabilities = AST_FORMAT_ULAW,
+ .requester = skinny_request,
+ .call = skinny_call,
+ .hangup = skinny_hangup,
+ .answer = skinny_answer,
+ .read = skinny_read,
+ .write = skinny_write,
+ .indicate = skinny_indicate,
+ .fixup = skinny_fixup,
+ .send_digit = skinny_senddigit,
+/* .bridge = ast_rtp_bridge, */
+};
+
static skinny_req *req_alloc(size_t size)
{
skinny_req *req;
@@ -1103,7 +1128,7 @@ static struct ast_rtp *skinny_get_vrtp_peer(struct ast_channel *chan)
static struct ast_rtp *skinny_get_rtp_peer(struct ast_channel *chan)
{
struct skinny_subchannel *sub;
- sub = chan->pvt->pvt;
+ sub = chan->tech_pvt;
if (sub && sub->rtp)
return sub->rtp;
return NULL;
@@ -1112,7 +1137,7 @@ static struct ast_rtp *skinny_get_rtp_peer(struct ast_channel *chan)
static int skinny_set_rtp_peer(struct ast_channel *chan, struct ast_rtp *rtp, struct ast_rtp *vrtp, int codecs)
{
struct skinny_subchannel *sub;
- sub = chan->pvt->pvt;
+ sub = chan->tech_pvt;
if (sub) {
/* transmit_modify_with_sdp(sub, rtp); @@FIXME@@ if needed */
return 0;
@@ -1121,9 +1146,10 @@ static int skinny_set_rtp_peer(struct ast_channel *chan, struct ast_rtp *rtp, st
}
static struct ast_rtp_protocol skinny_rtp = {
- get_rtp_info: skinny_get_rtp_peer,
- get_vrtp_info: skinny_get_vrtp_peer,
- set_rtp_peer: skinny_set_rtp_peer,
+ .type = type,
+ .get_rtp_info = skinny_get_rtp_peer,
+ .get_vrtp_info = skinny_get_vrtp_peer,
+ .set_rtp_peer = skinny_set_rtp_peer,
};
static int skinny_do_debug(int fd, int argc, char *argv[])
@@ -1403,7 +1429,7 @@ static void start_rtp(struct skinny_subchannel *sub)
static void *skinny_ss(void *data)
{
struct ast_channel *chan = data;
- struct skinny_subchannel *sub = chan->pvt->pvt;
+ struct skinny_subchannel *sub = chan->tech_pvt;
struct skinny_line *l = sub->parent;
struct skinnysession *s = l->parent->session;
char exten[AST_MAX_EXTENSION] = "";
@@ -1627,7 +1653,7 @@ static int skinny_call(struct ast_channel *ast, char *dest, int timeout)
struct skinny_subchannel *sub;
struct skinnysession *session;
- sub = ast->pvt->pvt;
+ sub = ast->tech_pvt;
l = sub->parent;
session = l->parent->session;
@@ -1736,14 +1762,14 @@ static int skinny_call(struct ast_channel *ast, char *dest, int timeout)
static int skinny_hangup(struct ast_channel *ast)
{
- struct skinny_subchannel *sub = ast->pvt->pvt;
+ struct skinny_subchannel *sub = ast->tech_pvt;
struct skinny_line *l = sub->parent;
struct skinnysession *s = l->parent->session;
if (skinnydebug) {
ast_verbose("skinny_hangup(%s) on %s@%s\n", ast->name, l->name, l->parent->name);
}
- if (!ast->pvt->pvt) {
+ if (!ast->tech_pvt) {
ast_log(LOG_DEBUG, "Asked to hangup channel not connected\n");
return 0;
}
@@ -1765,7 +1791,7 @@ static int skinny_hangup(struct ast_channel *ast)
}
ast_mutex_lock(&sub->lock);
sub->owner = NULL;
- ast->pvt->pvt = NULL;
+ ast->tech_pvt = NULL;
sub->alreadygone = 0;
sub->outgoing = 0;
if (sub->rtp) {
@@ -1779,7 +1805,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->pvt->pvt;
+ struct skinny_subchannel *sub = ast->tech_pvt;
struct skinny_line *l = sub->parent;
sub->cxmode = SKINNY_CX_SENDRECV;
if (!sub->rtp) {
@@ -1814,7 +1840,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->pvt->pvt;
+ struct skinny_subchannel *sub = ast->tech_pvt;
ast_mutex_lock(&sub->lock);
fr = skinny_rtp_read(sub);
ast_mutex_unlock(&sub->lock);
@@ -1823,7 +1849,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->pvt->pvt;
+ struct skinny_subchannel *sub = ast->tech_pvt;
int res = 0;
if (frame->frametype != AST_FRAME_VOICE) {
if (frame->frametype == AST_FRAME_IMAGE)
@@ -1851,7 +1877,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->pvt->pvt;
+ struct skinny_subchannel *sub = newchan->tech_pvt;
ast_log(LOG_NOTICE, "skinny_fixup(%s, %s)\n", oldchan->name, newchan->name);
if (sub->owner != oldchan) {
ast_log(LOG_WARNING, "old channel wasn't %p but was %p\n", oldchan, sub->owner);
@@ -1864,7 +1890,7 @@ static int skinny_fixup(struct ast_channel *oldchan, struct ast_channel *newchan
static int skinny_senddigit(struct ast_channel *ast, char digit)
{
#if 0
- struct skinny_subchannel *sub = ast->pvt->pvt;
+ struct skinny_subchannel *sub = ast->tech_pvt;
int tmp;
/* not right */
sprintf(tmp, "%d", digit);
@@ -1910,7 +1936,7 @@ static char *control2str(int ind) {
static int skinny_indicate(struct ast_channel *ast, int ind)
{
- struct skinny_subchannel *sub = ast->pvt->pvt;
+ struct skinny_subchannel *sub = ast->tech_pvt;
struct skinny_line *l = sub->parent;
struct skinnysession *s = l->parent->session;
@@ -1973,6 +1999,7 @@ static struct ast_channel *skinny_new(struct skinny_subchannel *sub, int state)
l = sub->parent;
tmp = ast_channel_alloc(1);
if (tmp) {
+ tmp->tech = &skinny_tech;
tmp->nativeformats = l->capability;
if (!tmp->nativeformats)
tmp->nativeformats = capability;
@@ -1985,19 +2012,10 @@ static struct ast_channel *skinny_new(struct skinny_subchannel *sub, int state)
if (state == AST_STATE_RING)
tmp->rings = 1;
tmp->writeformat = fmt;
- tmp->pvt->rawwriteformat = fmt;
+ tmp->rawwriteformat = fmt;
tmp->readformat = fmt;
- tmp->pvt->rawreadformat = fmt;
- tmp->pvt->pvt = sub;
- tmp->pvt->call = skinny_call;
- tmp->pvt->hangup = skinny_hangup;
- tmp->pvt->answer = skinny_answer;
- tmp->pvt->read = skinny_read;
- tmp->pvt->write = skinny_write;
- tmp->pvt->indicate = skinny_indicate;
- tmp->pvt->fixup = skinny_fixup;
- tmp->pvt->send_digit = skinny_senddigit;
-/* tmp->pvt->bridge = ast_rtp_bridge; */
+ tmp->rawreadformat = fmt;
+ tmp->tech_pvt = sub;
if (!ast_strlen_zero(l->language))
strncpy(tmp->language, l->language, sizeof(tmp->language)-1);
if (!ast_strlen_zero(l->accountcode))
@@ -3019,12 +3037,11 @@ int load_module()
/* Announce our presence to Asterisk */
if (!res) {
/* Make sure we can register our skinny channel type */
- if (ast_channel_register(type, tdesc, capability, skinny_request)) {
+ if (ast_channel_register(&skinny_tech)) {
ast_log(LOG_ERROR, "Unable to register channel class %s\n", type);
return -1;
}
}
- skinny_rtp.type = type;
ast_rtp_proto_register(&skinny_rtp);
ast_cli_register(&cli_show_lines);
ast_cli_register(&cli_debug);
@@ -3088,6 +3105,7 @@ int unload_module()
}
ast_rtp_proto_register(&skinny_rtp);
+ ast_channel_unregister(&skinny_tech);
ast_cli_register(&cli_show_lines);
ast_cli_register(&cli_debug);
ast_cli_register(&cli_no_debug);
@@ -3113,5 +3131,5 @@ char *key()
char *description()
{
- return desc;
+ return (char *) desc;
}
diff --git a/channels/chan_vpb.c b/channels/chan_vpb.c
index 8d1d11da9..a73e9f323 100755
--- a/channels/chan_vpb.c
+++ b/channels/chan_vpb.c
@@ -25,7 +25,6 @@ extern "C" {
#include <asterisk/lock.h>
#include <asterisk/utils.h>
#include <asterisk/channel.h>
-#include <asterisk/channel_pvt.h>
#include <asterisk/config.h>
#include <asterisk/logger.h>
#include <asterisk/module.h>
@@ -76,10 +75,10 @@ extern "C" {
#endif
/**/
-static char *desc = "VoiceTronix V6PCI/V12PCI/V4PCI API Support";
-static char *type = "vpb";
-static char *tdesc = "Standard VoiceTronix API Driver";
-static char *config = "vpb.conf";
+static const char desc[] = "VoiceTronix V6PCI/V12PCI/V4PCI API Support";
+static const char type[] = "vpb";
+static const char tdesc[] = "Standard VoiceTronix API Driver";
+static const char config[] = "vpb.conf";
/* Default context for dialtone mode */
static char context[AST_MAX_EXTENSION] = "default";
@@ -311,6 +310,33 @@ static struct vpb_pvt {
static struct ast_channel *vpb_new(struct vpb_pvt *i, int state, char *context);
static void *do_chanreads(void *pvt);
+static struct ast_channel *vpb_request(const char *type, int format, void *data, int *cause);
+static int vpb_digit(struct ast_channel *ast, char digit);
+static int vpb_call(struct ast_channel *ast, char *dest, int timeout);
+static int vpb_hangup(struct ast_channel *ast);
+static int vpb_answer(struct ast_channel *ast);
+static struct ast_frame *vpb_read(struct ast_channel *ast);
+static int vpb_write(struct ast_channel *ast, struct ast_frame *frame);
+static int vpb_bridge(struct ast_channel *c0, struct ast_channel *c1, int flags, struct ast_frame **fo, struct ast_channel **rc);
+static int vpb_indicate(struct ast_channel *ast, int condition);
+static int vpb_fixup(struct ast_channel *oldchan, struct ast_channel *newchan);
+
+static const struct ast_channel_tech vpb_tech = {
+ .type = type,
+ .description = tdesc,
+ .capabilities = AST_FORMAT_SLINEAR,
+ .requester = vpb_request,
+ .send_digit = vpb_digit,
+ .call = vpb_call,
+ .hangup = vpb_hangup,
+ .answer = vpb_answer,
+ .read = vpb_read,
+ .write = vpb_write,
+ .bridge = vpb_bridge,
+ .indicate = vpb_indicate,
+ .fixup = vpb_fixup,
+};
+
/* Can't get vpb_bridge() working on v4pci without either a horrible
* high pitched feedback noise or bad hiss noise depending on gain settings
* Get asterisk to do the bridging
@@ -325,8 +351,8 @@ static void *do_chanreads(void *pvt);
/* This is the Native bridge code, which Asterisk will try before using its own bridging code */
static int vpb_bridge(struct ast_channel *c0, struct ast_channel *c1, int flags, struct ast_frame **fo, struct ast_channel **rc)
{
- struct vpb_pvt *p0 = (struct vpb_pvt *)c0->pvt->pvt;
- struct vpb_pvt *p1 = (struct vpb_pvt *)c1->pvt->pvt;
+ struct vpb_pvt *p0 = (struct vpb_pvt *)c0->tech_pvt;
+ struct vpb_pvt *p1 = (struct vpb_pvt *)c1->tech_pvt;
int i, res;
struct ast_channel *cs[3];
@@ -449,11 +475,11 @@ static int vpb_bridge(struct ast_channel *c0, struct ast_channel *c1, int flags,
*rc = who;
ast_log(LOG_DEBUG, "%s: vpb_bridge: Got a [%s]\n",p0->dev, f ? "digit" : "hangup");
/*
- if ((c0->pvt->pvt == pvt0) && (!c0->_softhangup)) {
+ if ((c0->tech_pvt == pvt0) && (!c0->_softhangup)) {
if (pr0->set_rtp_peer(c0, NULL, NULL, 0))
ast_log(LOG_WARNING, "Channel '%s' failed to revert\n", c0->name);
}
- if ((c1->pvt->pvt == pvt1) && (!c1->_softhangup)) {
+ if ((c1->tech_pvt == pvt1) && (!c1->_softhangup)) {
if (pr1->set_rtp_peer(c1, NULL, NULL, 0))
ast_log(LOG_WARNING, "Channel '%s' failed to revert back\n", c1->name);
}
@@ -1556,10 +1582,13 @@ 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)
{
- struct vpb_pvt *p = (struct vpb_pvt *)ast->pvt->pvt;
+ struct vpb_pvt *p = (struct vpb_pvt *)ast->tech_pvt;
int res = 0;
int tmp = 0;
+ if (!use_ast_ind)
+ return 0;
+
if (option_verbose > 3)
ast_verbose(VERBOSE_PREFIX_4 "%s: vpb_indicate [%d] state[%d]\n", p->dev, condition,ast->_state);
/*
@@ -1623,7 +1652,7 @@ static int vpb_indicate(struct ast_channel *ast, int condition)
static int vpb_fixup(struct ast_channel *oldchan, struct ast_channel *newchan)
{
- struct vpb_pvt *p = (struct vpb_pvt *)newchan->pvt->pvt;
+ struct vpb_pvt *p = (struct vpb_pvt *)newchan->tech_pvt;
int res = 0;
/*
@@ -1653,10 +1682,13 @@ static int vpb_fixup(struct ast_channel *oldchan, struct ast_channel *newchan)
static int vpb_digit(struct ast_channel *ast, char digit)
{
- struct vpb_pvt *p = (struct vpb_pvt *)ast->pvt->pvt;
+ struct vpb_pvt *p = (struct vpb_pvt *)ast->tech_pvt;
char s[2];
int res = 0;
+ if (!use_ast_dtmf)
+ return 0;
+
/*
if (option_verbose > 3) ast_verbose("%s: LOCKING in digit \n", p->dev);
if (option_verbose > 3) ast_verbose("%s: LOCKING count[%d] owner[%d] \n", p->dev, p->lock.__m_count,p->lock.__m_owner);
@@ -1684,7 +1716,7 @@ static int vpb_digit(struct ast_channel *ast, char digit)
/* Places a call out of a VPB channel */
static int vpb_call(struct ast_channel *ast, char *dest, int timeout)
{
- struct vpb_pvt *p = (struct vpb_pvt *)ast->pvt->pvt;
+ struct vpb_pvt *p = (struct vpb_pvt *)ast->tech_pvt;
int res = 0,i;
char *s = strrchr(dest, '/');
char dialstring[254] = "";
@@ -1798,7 +1830,7 @@ static int vpb_call(struct ast_channel *ast, char *dest, int timeout)
static int vpb_hangup(struct ast_channel *ast)
{
- struct vpb_pvt *p = (struct vpb_pvt *)ast->pvt->pvt;
+ struct vpb_pvt *p = (struct vpb_pvt *)ast->tech_pvt;
VPB_EVENT je;
char str[VPB_MAX_STR];
int res =0 ;
@@ -1812,8 +1844,7 @@ static int vpb_hangup(struct ast_channel *ast)
if (option_verbose > 1)
ast_verbose(VERBOSE_PREFIX_2 "%s: Hangup requested\n", ast->name);
-
- if (!ast->pvt || !ast->pvt->pvt) {
+ if (!ast->tech || !ast->tech_pvt) {
ast_log(LOG_WARNING, "%s: channel not connected?\n", ast->name);
res = ast_mutex_unlock(&p->lock);
/*
@@ -1894,7 +1925,7 @@ static int vpb_hangup(struct ast_channel *ast)
p->dialtone = 0;
p->owner = NULL;
- ast->pvt->pvt=NULL;
+ ast->tech_pvt=NULL;
/* Free up ast dsp if we have one */
if ((use_ast_dtmfdet)&&(p->vad)) {
@@ -1924,7 +1955,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->pvt->pvt;
+ struct vpb_pvt *p = (struct vpb_pvt *)ast->tech_pvt;
VPB_EVENT je;
int ret;
int res = 0;
@@ -1998,7 +2029,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->pvt->pvt;
+ struct vpb_pvt *p = (struct vpb_pvt *)ast->tech_pvt;
static struct ast_frame f = {AST_FRAME_NULL};
f.src = type;
@@ -2073,7 +2104,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->pvt->pvt;
+ struct vpb_pvt *p = (struct vpb_pvt *)ast->tech_pvt;
int res = 0, fmt = 0;
struct timeval play_buf_time_start,play_buf_time_finish;
/* ast_mutex_lock(&p->lock); */
@@ -2279,9 +2310,9 @@ static void *do_chanreads(void *pvt)
}
ast_mutex_unlock(&p->play_dtmf_lock);
-/* afmt = (p->owner) ? p->owner->pvt->rawreadformat : AST_FORMAT_SLINEAR; */
+/* afmt = (p->owner) ? p->owner->rawreadformat : AST_FORMAT_SLINEAR; */
if (p->owner){
- afmt = p->owner->pvt->rawreadformat;
+ afmt = p->owner->rawreadformat;
/* ast_log(LOG_DEBUG,"%s: Record using owner format [%s]\n", p->dev, ast2vpbformatname(afmt)); */
}
else {
@@ -2437,6 +2468,7 @@ static struct ast_channel *vpb_new(struct vpb_pvt *me, int state, char *context)
tmp = ast_channel_alloc(1);
if (tmp) {
+ tmp->tech = &vpb_tech;
strncpy(tmp->name, me->dev, sizeof(tmp->name) - 1);
tmp->type = type;
@@ -2445,8 +2477,8 @@ static struct ast_channel *vpb_new(struct vpb_pvt *me, int state, char *context)
* linear since we can then adjust volume in this modules.
*/
tmp->nativeformats = prefformat;
- tmp->pvt->rawreadformat = AST_FORMAT_SLINEAR;
- tmp->pvt->rawwriteformat = AST_FORMAT_SLINEAR;
+ tmp->rawreadformat = AST_FORMAT_SLINEAR;
+ tmp->rawwriteformat = AST_FORMAT_SLINEAR;
ast_setstate(tmp, state);
if (state == AST_STATE_RING) {
tmp->rings = 1;
@@ -2455,19 +2487,7 @@ static struct ast_channel *vpb_new(struct vpb_pvt *me, int state, char *context)
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->pvt->pvt = me;
- /* set call backs */
- if (use_ast_dtmf == 0)
- tmp->pvt->send_digit = vpb_digit;
- tmp->pvt->call = vpb_call;
- tmp->pvt->hangup = vpb_hangup;
- tmp->pvt->answer = vpb_answer;
- tmp->pvt->read = vpb_read;
- tmp->pvt->write = vpb_write;
- tmp->pvt->bridge = vpb_bridge;
- if (use_ast_ind == 0)
- tmp->pvt->indicate = vpb_indicate;
- tmp->pvt->fixup = vpb_fixup;
+ tmp->tech_pvt = me;
strncpy(tmp->context, context, sizeof(tmp->context)-1);
if (strlen(me->ext))
@@ -2741,7 +2761,7 @@ int load_module()
ast_config_destroy(cfg);
- if (!error && ast_channel_register(type, tdesc, prefformat, vpb_request) != 0) {
+ if (!error && ast_channel_register(&vpb_tech) != 0) {
ast_log(LOG_ERROR, "Unable to register channel class %s\n", type);
error = -1;
}
@@ -2760,7 +2780,7 @@ int unload_module()
{
struct vpb_pvt *p;
/* First, take us out of the channel loop */
- ast_channel_unregister(type);
+ ast_channel_unregister(&vpb_tech);
ast_mutex_lock(&iflock); {
/* Hangup all interfaces if they have an owner */
@@ -2827,7 +2847,7 @@ int usecount()
char *description()
{
- return desc;
+ return (char *) desc;
}
char *key()
diff --git a/channels/chan_zap.c b/channels/chan_zap.c
index f27c2660d..3ad5b28e4 100755
--- a/channels/chan_zap.c
+++ b/channels/chan_zap.c
@@ -15,7 +15,6 @@
#include <string.h>
#include <asterisk/lock.h>
#include <asterisk/channel.h>
-#include <asterisk/channel_pvt.h>
#include <asterisk/config.h>
#include <asterisk/logger.h>
#include <asterisk/module.h>
@@ -97,7 +96,7 @@
#define AST_LAW(p) (((p)->law == ZT_LAW_ALAW) ? AST_FORMAT_ALAW : AST_FORMAT_ULAW)
-static char *desc = "Zapata Telephony"
+static const char desc[] = "Zapata Telephony"
#ifdef ZAPATA_PRI
" w/PRI"
#endif
@@ -106,7 +105,7 @@ static char *desc = "Zapata Telephony"
#endif
;
-static char *tdesc = "Zapata Telephony Driver"
+static const char tdesc[] = "Zapata Telephony Driver"
#ifdef ZAPATA_PRI
" w/PRI"
#endif
@@ -115,8 +114,8 @@ static char *tdesc = "Zapata Telephony Driver"
#endif
;
-static char *type = "Zap";
-static char *config = "zapata.conf";
+static const char type[] = "Zap";
+static const char config[] = "zapata.conf";
#define SIG_EM ZT_SIG_EM
#define SIG_EMWINK (0x100000 | ZT_SIG_EM)
@@ -614,6 +613,39 @@ static struct zt_pvt {
int polarity;
} *iflist = NULL, *ifend = NULL;
+static struct ast_channel *zt_request(const char *type, int format, void *data, int *cause);
+static int zt_digit(struct ast_channel *ast, char digit);
+static int zt_sendtext(struct ast_channel *c, char *text);
+static int zt_call(struct ast_channel *ast, char *rdest, int timeout);
+static int zt_hangup(struct ast_channel *ast);
+static int zt_answer(struct ast_channel *ast);
+struct ast_frame *zt_read(struct ast_channel *ast);
+static int zt_write(struct ast_channel *ast, struct ast_frame *frame);
+static int zt_bridge(struct ast_channel *c0, struct ast_channel *c1, int flags, struct ast_frame **fo, struct ast_channel **rc);
+struct ast_frame *zt_exception(struct ast_channel *ast);
+static int zt_indicate(struct ast_channel *chan, int condition);
+static int zt_fixup(struct ast_channel *oldchan, struct ast_channel *newchan);
+static int zt_setoption(struct ast_channel *chan, int option, void *data, int datalen);
+
+static const struct ast_channel_tech zap_tech = {
+ .type = type,
+ .description = tdesc,
+ .capabilities = AST_FORMAT_SLINEAR | AST_FORMAT_ULAW,
+ .requester = zt_request,
+ .send_digit = zt_digit,
+ .send_text = zt_sendtext,
+ .call = zt_call,
+ .hangup = zt_hangup,
+ .answer = zt_answer,
+ .read = zt_read,
+ .write = zt_write,
+ .bridge = zt_bridge,
+ .exception = zt_exception,
+ .indicate = zt_indicate,
+ .fixup = zt_fixup,
+ .setoption = zt_setoption,
+};
+
#ifdef ZAPATA_PRI
#define GET_CHANNEL(p) ((p)->bearer ? (p)->bearer->channel : p->channel)
#else
@@ -908,7 +940,7 @@ static int zt_digit(struct ast_channel *ast, char digit)
struct zt_pvt *p;
int res = 0;
int index;
- p = ast->pvt->pvt;
+ p = ast->tech_pvt;
ast_mutex_lock(&p->lock);
index = zt_get_index(ast, p, 0);
if ((index == SUB_REAL) && p->owner) {
@@ -1505,7 +1537,7 @@ static int send_callerid(struct zt_pvt *p)
static int zt_callwait(struct ast_channel *ast)
{
- struct zt_pvt *p = ast->pvt->pvt;
+ struct zt_pvt *p = ast->tech_pvt;
p->callwaitingrepeat = CALLWAITING_REPEAT_SAMPLES;
if (p->cidspill) {
ast_log(LOG_WARNING, "Spill already exists?!?\n");
@@ -1536,7 +1568,7 @@ static int zt_callwait(struct ast_channel *ast)
static int zt_call(struct ast_channel *ast, char *rdest, int timeout)
{
- struct zt_pvt *p = ast->pvt->pvt;
+ struct zt_pvt *p = ast->tech_pvt;
int x, res, index;
char *c, *n, *l;
#ifdef ZAPATA_PRI
@@ -2026,14 +2058,14 @@ static int zt_hangup(struct ast_channel *ast)
int res;
int index,x, law;
/*static int restore_gains(struct zt_pvt *p);*/
- struct zt_pvt *p = ast->pvt->pvt;
+ struct zt_pvt *p = ast->tech_pvt;
struct zt_pvt *tmp = NULL;
struct zt_pvt *prev = NULL;
ZT_PARAMS par;
if (option_debug)
ast_log(LOG_DEBUG, "zt_hangup(%s)\n", ast->name);
- if (!ast->pvt->pvt) {
+ if (!ast->tech_pvt) {
ast_log(LOG_WARNING, "Asked to hangup channel not connected\n");
return 0;
}
@@ -2314,7 +2346,7 @@ static int zt_hangup(struct ast_channel *ast)
p->callwaitingrepeat = 0;
p->cidcwexpire = 0;
- ast->pvt->pvt = NULL;
+ ast->tech_pvt = NULL;
ast_mutex_unlock(&p->lock);
ast_mutex_lock(&usecnt_lock);
usecnt--;
@@ -2345,7 +2377,7 @@ static int zt_hangup(struct ast_channel *ast)
static int zt_answer(struct ast_channel *ast)
{
- struct zt_pvt *p = ast->pvt->pvt;
+ struct zt_pvt *p = ast->tech_pvt;
int res=0;
int index;
int oldstate = ast->_state;
@@ -2437,7 +2469,7 @@ static int zt_setoption(struct ast_channel *chan, int option, void *data, int da
char *cp;
int x;
- struct zt_pvt *p = chan->pvt->pvt;
+ struct zt_pvt *p = chan->tech_pvt;
if ((option != AST_OPTION_TONE_VERIFY) && (option != AST_OPTION_AUDIO_MODE) &&
@@ -2680,8 +2712,8 @@ static int zt_bridge(struct ast_channel *c0, struct ast_channel *c1, int flags,
ast_mutex_lock(&c0->lock);
ast_mutex_lock(&c1->lock);
- p0 = c0->pvt->pvt;
- p1 = c1->pvt->pvt;
+ p0 = c0->tech_pvt;
+ p1 = c1->tech_pvt;
/* cant do pseudo-channels here */
if (!p0 || (!p0->sig) || !p1 || (!p1->sig)) {
ast_mutex_unlock(&c0->lock);
@@ -2689,8 +2721,8 @@ static int zt_bridge(struct ast_channel *c0, struct ast_channel *c1, int flags,
return -2;
}
- op0 = p0 = c0->pvt->pvt;
- op1 = p1 = c1->pvt->pvt;
+ op0 = p0 = c0->tech_pvt;
+ op1 = p1 = c1->tech_pvt;
ofd1 = c0->fds[0];
ofd2 = c1->fds[0];
oi1 = zt_get_index(c0, p0, 0);
@@ -2836,8 +2868,8 @@ static int zt_bridge(struct ast_channel *c0, struct ast_channel *c1, int flags,
and then balking if anything is wrong */
ast_mutex_lock(&c0->lock);
ast_mutex_lock(&c1->lock);
- p0 = c0->pvt->pvt;
- p1 = c1->pvt->pvt;
+ p0 = c0->tech_pvt;
+ p1 = c1->tech_pvt;
#ifdef PRI_2BCT
q931c0 = p0->call;
@@ -2880,14 +2912,14 @@ static int zt_bridge(struct ast_channel *c0, struct ast_channel *c1, int flags,
ast_log(LOG_DEBUG, "Ooh, empty read...\n");
continue;
}
- if (who->pvt->pvt == op0)
+ if (who->tech_pvt == op0)
op0->ignoredtmf = 1;
- else if (who->pvt->pvt == op1)
+ else if (who->tech_pvt == op1)
op1->ignoredtmf = 1;
f = ast_read(who);
- if (who->pvt->pvt == op0)
+ if (who->tech_pvt == op0)
op0->ignoredtmf = 0;
- else if (who->pvt->pvt == op1)
+ else if (who->tech_pvt == op1)
op1->ignoredtmf = 0;
if (!f) {
*fo = NULL;
@@ -2930,11 +2962,9 @@ static int zt_bridge(struct ast_channel *c0, struct ast_channel *c1, int flags,
}
}
-static int zt_indicate(struct ast_channel *chan, int condition);
-
static int zt_fixup(struct ast_channel *oldchan, struct ast_channel *newchan)
{
- struct zt_pvt *p = newchan->pvt->pvt;
+ struct zt_pvt *p = newchan->tech_pvt;
int x;
ast_mutex_lock(&p->lock);
ast_log(LOG_DEBUG, "New owner for channel %d is %s\n", p->channel, newchan->name);
@@ -3173,7 +3203,7 @@ static struct ast_frame *zt_handle_event(struct ast_channel *ast)
int res,x;
int index;
char *c;
- struct zt_pvt *p = ast->pvt->pvt;
+ struct zt_pvt *p = ast->tech_pvt;
pthread_t threadid;
pthread_attr_t attr;
struct ast_channel *chan;
@@ -3852,7 +3882,7 @@ static struct ast_frame *zt_handle_event(struct ast_channel *ast)
static struct ast_frame *__zt_exception(struct ast_channel *ast)
{
- struct zt_pvt *p = ast->pvt->pvt;
+ struct zt_pvt *p = ast->tech_pvt;
int res;
int usedindex=-1;
int index;
@@ -3957,7 +3987,7 @@ static struct ast_frame *__zt_exception(struct ast_channel *ast)
struct ast_frame *zt_exception(struct ast_channel *ast)
{
- struct zt_pvt *p = ast->pvt->pvt;
+ struct zt_pvt *p = ast->tech_pvt;
struct ast_frame *f;
ast_mutex_lock(&p->lock);
f = __zt_exception(ast);
@@ -3967,7 +3997,7 @@ struct ast_frame *zt_exception(struct ast_channel *ast)
struct ast_frame *zt_read(struct ast_channel *ast)
{
- struct zt_pvt *p = ast->pvt->pvt;
+ struct zt_pvt *p = ast->tech_pvt;
int res;
int index;
void *readbuf;
@@ -4082,15 +4112,15 @@ struct ast_frame *zt_read(struct ast_channel *ast)
return &p->subs[index].f;
}
- if (ast->pvt->rawreadformat == AST_FORMAT_SLINEAR) {
+ if (ast->rawreadformat == AST_FORMAT_SLINEAR) {
if (!p->subs[index].linear) {
p->subs[index].linear = 1;
res = zt_setlinear(p->subs[index].zfd, p->subs[index].linear);
if (res)
ast_log(LOG_WARNING, "Unable to set channel %d (index %d) to linear mode.\n", p->channel, index);
}
- } else if ((ast->pvt->rawreadformat == AST_FORMAT_ULAW) ||
- (ast->pvt->rawreadformat == AST_FORMAT_ALAW)) {
+ } else if ((ast->rawreadformat == AST_FORMAT_ULAW) ||
+ (ast->rawreadformat == AST_FORMAT_ALAW)) {
if (p->subs[index].linear) {
p->subs[index].linear = 0;
res = zt_setlinear(p->subs[index].zfd, p->subs[index].linear);
@@ -4098,7 +4128,7 @@ struct ast_frame *zt_read(struct ast_channel *ast)
ast_log(LOG_WARNING, "Unable to set channel %d (index %d) to campanded mode.\n", p->channel, index);
}
} else {
- ast_log(LOG_WARNING, "Don't know how to read frames in format %s\n", ast_getformatname(ast->pvt->rawreadformat));
+ ast_log(LOG_WARNING, "Don't know how to read frames in format %s\n", ast_getformatname(ast->rawreadformat));
ast_mutex_unlock(&p->lock);
return NULL;
}
@@ -4175,7 +4205,7 @@ struct ast_frame *zt_read(struct ast_channel *ast)
}
p->subs[index].f.frametype = AST_FRAME_VOICE;
- p->subs[index].f.subclass = ast->pvt->rawreadformat;
+ p->subs[index].f.subclass = ast->rawreadformat;
p->subs[index].f.samples = READ_SIZE;
p->subs[index].f.mallocd = 0;
p->subs[index].f.offset = AST_FRIENDLY_OFFSET;
@@ -4313,7 +4343,7 @@ static int my_zt_write(struct zt_pvt *p, unsigned char *buf, int len, int index,
static int zt_write(struct ast_channel *ast, struct ast_frame *frame)
{
- struct zt_pvt *p = ast->pvt->pvt;
+ struct zt_pvt *p = ast->tech_pvt;
int res;
unsigned char outbuf[4096];
int index;
@@ -4399,7 +4429,7 @@ static int zt_write(struct ast_channel *ast, struct ast_frame *frame)
static int zt_indicate(struct ast_channel *chan, int condition)
{
- struct zt_pvt *p = chan->pvt->pvt;
+ struct zt_pvt *p = chan->tech_pvt;
int res=-1;
int index;
int func = ZT_FLASH;
@@ -4606,6 +4636,7 @@ static struct ast_channel *zt_new(struct zt_pvt *i, int state, int startpbx, int
}
tmp = ast_channel_alloc(0);
if (tmp) {
+ tmp->tech = &zap_tech;
ps.channo = i->channel;
res = ioctl(i->subs[SUB_REAL].zfd, ZT_GET_PARAMS, &ps);
if (res) {
@@ -4643,9 +4674,9 @@ static struct ast_channel *zt_new(struct zt_pvt *i, int state, int startpbx, int
tmp->fds[0] = i->subs[index].zfd;
tmp->nativeformats = AST_FORMAT_SLINEAR | deflaw;
/* Start out assuming ulaw since it's smaller :) */
- tmp->pvt->rawreadformat = deflaw;
+ tmp->rawreadformat = deflaw;
tmp->readformat = deflaw;
- tmp->pvt->rawwriteformat = deflaw;
+ tmp->rawwriteformat = deflaw;
tmp->writeformat = deflaw;
i->subs[index].linear = 0;
zt_setlinear(i->subs[index].zfd, i->subs[index].linear);
@@ -4689,19 +4720,7 @@ static struct ast_channel *zt_new(struct zt_pvt *i, int state, int startpbx, int
if (state == AST_STATE_RING)
tmp->rings = 1;
- tmp->pvt->pvt = i;
- tmp->pvt->send_digit = zt_digit;
- tmp->pvt->send_text = zt_sendtext;
- tmp->pvt->call = zt_call;
- tmp->pvt->hangup = zt_hangup;
- tmp->pvt->answer = zt_answer;
- tmp->pvt->read = zt_read;
- tmp->pvt->write = zt_write;
- tmp->pvt->bridge = zt_bridge;
- tmp->pvt->exception = zt_exception;
- tmp->pvt->indicate = zt_indicate;
- tmp->pvt->fixup = zt_fixup;
- tmp->pvt->setoption = zt_setoption;
+ tmp->tech_pvt = 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;
@@ -4828,7 +4847,7 @@ static int zt_wink(struct zt_pvt *p, int index)
static void *ss_thread(void *data)
{
struct ast_channel *chan = data;
- struct zt_pvt *p = chan->pvt->pvt;
+ struct zt_pvt *p = chan->tech_pvt;
char exten[AST_MAX_EXTENSION]="";
char exten2[AST_MAX_EXTENSION]="";
unsigned char buf[256];
@@ -5310,7 +5329,7 @@ static void *ss_thread(void *data)
struct zt_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)->pvt->pvt;
+ pbridge = ast_bridged_channel(nbridge)->tech_pvt;
if (nbridge && pbridge &&
(!strcmp(nbridge->type,"Zap")) &&
(!strcmp(ast_bridged_channel(nbridge)->type, "Zap")) &&
@@ -7286,7 +7305,7 @@ static int pri_fixup_principle(struct zt_pri *pri, int principle, q931_call *c)
if (pri->pvts[principle]->owner) {
snprintf(pri->pvts[principle]->owner->name, sizeof(pri->pvts[principle]->owner->name),
"Zap/%d:%d-%d", pri->trunkgroup, pri->pvts[principle]->channel, 1);
- pri->pvts[principle]->owner->pvt->pvt = pri->pvts[principle];
+ pri->pvts[principle]->owner->tech_pvt = pri->pvts[principle];
pri->pvts[principle]->owner->fds[0] = pri->pvts[principle]->subs[SUB_REAL].zfd;
pri->pvts[principle]->subs[SUB_REAL].owner = pri->pvts[x]->subs[SUB_REAL].owner;
} else
@@ -7331,7 +7350,7 @@ static int pri_fixup_principle(struct zt_pri *pri, int principle, q931_call *c)
static void *do_idle_thread(void *vchan)
{
struct ast_channel *chan = vchan;
- struct zt_pvt *pvt = chan->pvt->pvt;
+ struct zt_pvt *pvt = chan->tech_pvt;
struct ast_frame *f;
char ex[80];
/* Wait up to 30 seconds for an answer */
@@ -9291,7 +9310,7 @@ static int __unload_module(void)
ast_manager_unregister( "ZapDNDon" );
ast_manager_unregister("ZapShowChannels");
ast_unregister_application(app_callingpres);
- ast_channel_unregister(type);
+ ast_channel_unregister(&zap_tech);
if (!ast_mutex_lock(&iflock)) {
/* Hangup all interfaces if they have an owner */
p = iflist;
@@ -10134,7 +10153,7 @@ int load_module(void)
if(res) {
return -1;
}
- if (ast_channel_register(type, tdesc, AST_FORMAT_SLINEAR | AST_FORMAT_ULAW, zt_request)) {
+ if (ast_channel_register(&zap_tech)) {
ast_log(LOG_ERROR, "Unable to register channel class %s\n", type);
__unload_module();
return -1;
@@ -10175,7 +10194,7 @@ static int zt_sendtext(struct ast_channel *c, char *text)
#define ASCII_BYTES_PER_CHAR 80
unsigned char *buf,*mybuf;
- struct zt_pvt *p = c->pvt->pvt;
+ struct zt_pvt *p = c->tech_pvt;
struct pollfd fds[1];
int size,res,fd,len,x;
int bytes=0;
@@ -10289,7 +10308,7 @@ int usecount()
char *description()
{
- return desc;
+ return (char *) desc;
}
char *key()