aboutsummaryrefslogtreecommitdiffstats
path: root/channels
diff options
context:
space:
mode:
authorkpfleming <kpfleming@f38db490-d61c-443f-a65b-d21fe96a405b>2006-02-01 23:05:28 +0000
committerkpfleming <kpfleming@f38db490-d61c-443f-a65b-d21fe96a405b>2006-02-01 23:05:28 +0000
commit21d21f89c04ebaad6822311ceadd13275b357513 (patch)
tree86a6664b5cba70b924fdd1cef2ecbf93226e7d58 /channels
parent4d4470fe1560a6d00b17db78798f0cc9790fe74b (diff)
use string fields for some stuff in ast_channel
const-ify some more APIs remove 'type' field from ast_channel, in favor of the one in the channel's tech structure allow string field module users to specify the 'chunk size' for pool allocations update chan_alsa to be compatible with recent const-ification patches git-svn-id: http://svn.digium.com/svn/asterisk/trunk@9060 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'channels')
-rw-r--r--channels/chan_agent.c15
-rw-r--r--channels/chan_alsa.c19
-rw-r--r--channels/chan_features.c13
-rw-r--r--channels/chan_iax2.c30
-rw-r--r--channels/chan_local.c16
-rw-r--r--channels/chan_mgcp.c17
-rw-r--r--channels/chan_oss.c35
-rw-r--r--channels/chan_phone.c18
-rw-r--r--channels/chan_sip.c46
-rw-r--r--channels/chan_skinny.c26
-rw-r--r--channels/chan_zap.c37
-rw-r--r--channels/iax2-parser.c6
-rw-r--r--channels/iax2-parser.h36
13 files changed, 151 insertions, 163 deletions
diff --git a/channels/chan_agent.c b/channels/chan_agent.c
index e99a6f483..ff0308b7b 100644
--- a/channels/chan_agent.c
+++ b/channels/chan_agent.c
@@ -71,9 +71,9 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
#include "asterisk/astdb.h"
#include "asterisk/devicestate.h"
#include "asterisk/monitor.h"
+#include "asterisk/stringfields.h"
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";
@@ -257,7 +257,7 @@ static struct ast_channel *agent_bridgedchannel(struct ast_channel *chan, struct
static void set_agentbycallerid(const char *callerid, const char *agent);
static const struct ast_channel_tech agent_tech = {
- .type = channeltype,
+ .type = "Agent",
.description = tdesc,
.capabilities = -1,
.requester = agent_request,
@@ -520,7 +520,7 @@ static struct ast_frame *agent_read(struct ast_channel *ast)
CLEANUP(ast,p);
if (p->chan && !p->chan->_bridge) {
- if (strcasecmp(p->chan->type, "Local")) {
+ if (strcasecmp(p->chan->tech->type, "Local")) {
p->chan->_bridge = ast;
if (p->chan)
ast_log(LOG_DEBUG, "Bridge on '%s' being set to '%s' (3)\n", p->chan->name, p->chan->_bridge->name);
@@ -913,7 +913,7 @@ static struct ast_channel *agent_new(struct agent_pvt *p, int state)
tmp->rawwriteformat = p->chan->writeformat;
tmp->readformat = p->chan->readformat;
tmp->rawreadformat = p->chan->readformat;
- ast_copy_string(tmp->language, p->chan->language, sizeof(tmp->language));
+ ast_string_field_set(tmp, language, p->chan->language);
ast_copy_string(tmp->context, p->chan->context, sizeof(tmp->context));
ast_copy_string(tmp->exten, p->chan->exten, sizeof(tmp->exten));
} else {
@@ -924,10 +924,9 @@ static struct ast_channel *agent_new(struct agent_pvt *p, int state)
tmp->rawreadformat = AST_FORMAT_SLINEAR;
}
if (p->pending)
- snprintf(tmp->name, sizeof(tmp->name), "Agent/P%s-%d", p->agent, rand() & 0xffff);
+ ast_string_field_build(tmp, name, "Agent/P%s-%d", p->agent, rand() & 0xffff);
else
- snprintf(tmp->name, sizeof(tmp->name), "Agent/%s", p->agent);
- tmp->type = channeltype;
+ ast_string_field_build(tmp, name, "Agent/%s", p->agent);
/* Safe, agentlock already held */
ast_setstate(tmp, state);
tmp->tech_pvt = p;
@@ -2491,7 +2490,7 @@ int load_module()
{
/* Make sure we can register our agent channel type */
if (ast_channel_register(&agent_tech)) {
- ast_log(LOG_ERROR, "Unable to register channel class %s\n", channeltype);
+ ast_log(LOG_ERROR, "Unable to register channel class 'Agent'\n");
return -1;
}
/* Dialplan applications */
diff --git a/channels/chan_alsa.c b/channels/chan_alsa.c
index a41eb93f2..6e097ca2a 100644
--- a/channels/chan_alsa.c
+++ b/channels/chan_alsa.c
@@ -56,6 +56,7 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
#include "asterisk/utils.h"
#include "asterisk/causes.h"
#include "asterisk/endian.h"
+#include "asterisk/stringfields.h"
#include "busy.h"
#include "ringtone.h"
@@ -105,7 +106,6 @@ static int silencethreshold = 1000;
AST_MUTEX_DEFINE_STATIC(usecnt_lock);
AST_MUTEX_DEFINE_STATIC(alsalock);
-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";
@@ -184,7 +184,7 @@ 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,
+ .type = "Console",
.description = tdesc,
.capabilities = AST_FORMAT_SLINEAR,
.requester = alsa_request,
@@ -681,7 +681,7 @@ static struct ast_frame *alsa_read(struct ast_channel *chan)
f.datalen = 0;
f.data = NULL;
f.offset = 0;
- f.src = type;
+ f.src = "Console";
f.mallocd = 0;
f.delivery.tv_sec = 0;
f.delivery.tv_usec = 0;
@@ -727,7 +727,7 @@ static struct ast_frame *alsa_read(struct ast_channel *chan)
f.datalen = FRAME_SIZE * 2;
f.data = buf;
f.offset = AST_FRIENDLY_OFFSET;
- f.src = type;
+ f.src = "Console";
f.mallocd = 0;
#ifdef ALSA_MONITOR
alsa_monitor_read((char *)buf, FRAME_SIZE * 2);
@@ -784,8 +784,7 @@ static struct ast_channel *alsa_new(struct chan_alsa_pvt *p, int state)
tmp = ast_channel_alloc(1);
if (tmp) {
tmp->tech = &alsa_tech;
- snprintf(tmp->name, sizeof(tmp->name), "ALSA/%s", indevname);
- tmp->type = type;
+ ast_string_field_build(tmp, name, "ALSA/%s", indevname);
tmp->fds[0] = readdev;
tmp->nativeformats = AST_FORMAT_SLINEAR;
tmp->readformat = AST_FORMAT_SLINEAR;
@@ -796,7 +795,7 @@ static struct ast_channel *alsa_new(struct chan_alsa_pvt *p, int state)
if (!ast_strlen_zero(p->exten))
ast_copy_string(tmp->exten, p->exten, sizeof(tmp->exten));
if (!ast_strlen_zero(language))
- ast_copy_string(tmp->language, language, sizeof(tmp->language));
+ ast_string_field_set(tmp, language, language);
p->owner = tmp;
ast_setstate(tmp, state);
ast_mutex_lock(&usecnt_lock);
@@ -857,7 +856,7 @@ static int console_autoanswer(int fd, int argc, char *argv[])
return res;
}
-static char *autoanswer_complete(char *line, char *word, int pos, int state)
+static char *autoanswer_complete(const char *line, const char *word, int pos, int state)
{
#ifndef MIN
#define MIN(a,b) ((a) < (b) ? (a) : (b))
@@ -875,7 +874,7 @@ static char *autoanswer_complete(char *line, char *word, int pos, int state)
return NULL;
}
-static char autoanswer_usage[] =
+static const char autoanswer_usage[] =
"Usage: autoanswer [on|off]\n"
" Enables or disables autoanswer feature. If used without\n"
" argument, displays the current on/off status of autoanswer.\n"
@@ -1088,7 +1087,7 @@ int load_module()
res = ast_channel_register(&alsa_tech);
if (res < 0) {
- ast_log(LOG_ERROR, "Unable to register channel class '%s'\n", type);
+ ast_log(LOG_ERROR, "Unable to register channel class 'Console'\n");
return -1;
}
for (x=0;x<sizeof(myclis)/sizeof(struct ast_cli_entry); x++)
diff --git a/channels/chan_features.c b/channels/chan_features.c
index 5f6ff2ca6..f8047d323 100644
--- a/channels/chan_features.c
+++ b/channels/chan_features.c
@@ -61,9 +61,9 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
#include "asterisk/app.h"
#include "asterisk/musiconhold.h"
#include "asterisk/manager.h"
+#include "asterisk/stringfields.h"
static const char desc[] = "Feature Proxy Channel";
-static const char type[] = "Feature";
static const char tdesc[] = "Feature Proxy Channel Driver";
static int usecnt =0;
@@ -106,7 +106,7 @@ 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,
+ .type = "Feature",
.description = tdesc,
.capabilities = -1,
.requester = features_request,
@@ -349,8 +349,8 @@ static int features_call(struct ast_channel *ast, char *dest, int timeout)
p->subchan->cid.cid_ani = NULL;
p->subchan->cid.cid_pres = p->owner->cid.cid_pres;
- strncpy(p->subchan->language, p->owner->language, sizeof(p->subchan->language) - 1);
- strncpy(p->subchan->accountcode, p->owner->accountcode, sizeof(p->subchan->accountcode) - 1);
+ ast_string_field_set(p->subchan, language, p->owner->language);
+ ast_string_field_set(p->subchan, accountcode, p->owner->accountcode);
p->subchan->cdrflags = p->owner->cdrflags;
res = ast_call(p->subchan, dest2, timeout);
update_features(p, x);
@@ -464,7 +464,7 @@ static struct ast_channel *features_new(struct feature_pvt *p, int state, int in
}
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);
+ ast_string_field_build(tmp, name, "Feature/%s/%s-%d", p->tech, p->dest, x);
for (y=0;y<3;y++) {
if (y == index)
continue;
@@ -474,7 +474,6 @@ static struct ast_channel *features_new(struct feature_pvt *p, int state, int in
if (y >= 3)
break;
}
- tmp->type = type;
ast_setstate(tmp, state);
tmp->writeformat = p->subchan->writeformat;
tmp->rawwriteformat = p->subchan->rawwriteformat;
@@ -540,7 +539,7 @@ int load_module()
{
/* Make sure we can register our sip channel type */
if (ast_channel_register(&features_tech)) {
- ast_log(LOG_ERROR, "Unable to register channel class %s\n", type);
+ ast_log(LOG_ERROR, "Unable to register channel class 'Feature'\n");
return -1;
}
ast_cli_register(&cli_show_features);
diff --git a/channels/chan_iax2.c b/channels/chan_iax2.c
index ee167be5c..61aaff749 100644
--- a/channels/chan_iax2.c
+++ b/channels/chan_iax2.c
@@ -90,6 +90,7 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
#include "asterisk/dnsmgr.h"
#include "asterisk/devicestate.h"
#include "asterisk/netsock.h"
+#include "asterisk/stringfields.h"
#include "iax2.h"
#include "iax2-parser.h"
@@ -141,7 +142,6 @@ static struct ast_codec_pref prefs;
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";
@@ -747,7 +747,7 @@ static int iax2_transfer(struct ast_channel *c, const char *dest);
static int iax2_fixup(struct ast_channel *oldchannel, struct ast_channel *newchan);
static const struct ast_channel_tech iax2_tech = {
- .type = channeltype,
+ .type = "IAX2",
.description = tdesc,
.capabilities = IAX_CAPABILITY_FULLBANDWIDTH,
.properties = AST_CHAN_TP_WANTSJITTER,
@@ -3175,16 +3175,16 @@ static enum ast_bridge_result iax2_bridge(struct ast_channel *c0, struct ast_cha
cs[1] = c1;
for (/* ever */;;) {
/* Check in case we got masqueraded into */
- if ((c0->type != channeltype) || (c1->type != channeltype)) {
+ if ((c0->tech != &iax2_tech) || (c1->tech != &iax2_tech)) {
if (option_verbose > 2)
ast_verbose(VERBOSE_PREFIX_3 "Can't masquerade, we're different...\n");
/* Remove from native mode */
- if (c0->type == channeltype) {
+ if (c0->tech == &iax2_tech) {
ast_mutex_lock(&iaxsl[callno0]);
iaxs[callno0]->bridgecallno = 0;
ast_mutex_unlock(&iaxsl[callno0]);
}
- if (c1->type == channeltype) {
+ if (c1->tech == &iax2_tech) {
ast_mutex_lock(&iaxsl[callno1]);
iaxs[callno1]->bridgecallno = 0;
ast_mutex_unlock(&iaxsl[callno1]);
@@ -3387,8 +3387,7 @@ static struct ast_channel *ast_iax2_new(int callno, int state, int capability)
i = iaxs[callno];
if (i && tmp) {
tmp->tech = &iax2_tech;
- snprintf(tmp->name, sizeof(tmp->name), "IAX2/%s-%d", i->host, i->callno);
- tmp->type = channeltype;
+ ast_string_field_build(tmp, name, "IAX2/%s-%d", i->host, i->callno);
/* We can support any format by default, until we get restricted */
tmp->nativeformats = capability;
tmp->readformat = ast_best_codec(capability);
@@ -3402,7 +3401,7 @@ static struct ast_channel *ast_iax2_new(int callno, int state, int capability)
if (!ast_strlen_zero(i->ani))
tmp->cid.cid_ani = ast_strdup(i->ani);
if (!ast_strlen_zero(i->language))
- ast_copy_string(tmp->language, i->language, sizeof(tmp->language));
+ ast_string_field_set(tmp, language, i->language);
if (!ast_strlen_zero(i->dnid))
tmp->cid.cid_dnid = ast_strdup(i->dnid);
if (!ast_strlen_zero(i->rdnis))
@@ -3411,7 +3410,7 @@ static struct ast_channel *ast_iax2_new(int callno, int state, int capability)
tmp->cid.cid_ton = i->calling_ton;
tmp->cid.cid_tns = i->calling_tns;
if (!ast_strlen_zero(i->accountcode))
- ast_copy_string(tmp->accountcode, i->accountcode, sizeof(tmp->accountcode));
+ ast_string_field_set(tmp, accountcode, i->accountcode);
if (i->amaflags)
tmp->amaflags = i->amaflags;
ast_copy_string(tmp->context, i->context, sizeof(tmp->context));
@@ -5538,7 +5537,8 @@ static void register_peer_exten(struct iax2_peer *peer, int onoff)
while((ext = strsep(&stringp, "&"))) {
if (onoff) {
if (!ast_exists_extension(NULL, regcontext, ext, 1, NULL))
- ast_add_extension(regcontext, 1, ext, 1, NULL, NULL, "Noop", ast_strdup(peer->name), free, channeltype);
+ ast_add_extension(regcontext, 1, ext, 1, NULL, NULL,
+ "Noop", ast_strdup(peer->name), free, "IAX2");
} else
ast_context_remove_extension(regcontext, ext, 1, NULL);
}
@@ -6140,7 +6140,7 @@ static int iax_park(struct ast_channel *chan1, struct ast_channel *chan2)
chan1m = ast_channel_alloc(0);
chan2m = ast_channel_alloc(0);
if (chan2m && chan1m) {
- snprintf(chan1m->name, sizeof(chan1m->name), "Parking/%s", chan1->name);
+ ast_string_field_build(chan1m, name, "Parking/%s", chan1->name);
/* Make formats okay */
chan1m->readformat = chan1->readformat;
chan1m->writeformat = chan1->writeformat;
@@ -6152,7 +6152,7 @@ static int iax_park(struct ast_channel *chan1, struct ast_channel *chan2)
/* We make a clone of the peer channel too, so we can play
back the announcement */
- snprintf(chan2m->name, sizeof (chan2m->name), "IAXPeer/%s",chan2->name);
+ ast_string_field_build(chan2m, name, "IAXPeer/%s",chan2->name);
/* Make formats okay */
chan2m->readformat = chan2->readformat;
chan2m->writeformat = chan2->writeformat;
@@ -7716,7 +7716,7 @@ static int iax2_prov_app(struct ast_channel *chan, void *data)
if (opts)
*opts='\0';
- if (chan->type != channeltype) {
+ if (chan->tech != &iax2_tech) {
ast_log(LOG_NOTICE, "Can't provision a non-IAX device!\n");
return -1;
}
@@ -8728,7 +8728,7 @@ static int set_config(char *config_file, int reload)
ast_copy_string(regcontext, v->value, sizeof(regcontext));
/* Create context if it doesn't exist already */
if (!ast_context_find(regcontext))
- ast_context_create(NULL, regcontext, channeltype);
+ ast_context_create(NULL, regcontext, "IAX2");
} else if (!strcasecmp(v->name, "tos")) {
if (ast_str2tos(v->value, &tos))
ast_log(LOG_WARNING, "Invalid tos value at line %d, should be 'lowdelay', 'throughput', 'reliability', 'mincost', or 'none'\n", v->lineno);
@@ -9562,7 +9562,7 @@ int load_module(void)
set_config(config, 0);
if (ast_channel_register(&iax2_tech)) {
- ast_log(LOG_ERROR, "Unable to register channel class %s\n", channeltype);
+ ast_log(LOG_ERROR, "Unable to register channel class %s\n", "IAX2");
__unload_module();
return -1;
}
diff --git a/channels/chan_local.c b/channels/chan_local.c
index bc082a29a..bff3ab54d 100644
--- a/channels/chan_local.c
+++ b/channels/chan_local.c
@@ -59,9 +59,9 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
#include "asterisk/app.h"
#include "asterisk/musiconhold.h"
#include "asterisk/manager.h"
+#include "asterisk/stringfields.h"
static const char desc[] = "Local Proxy Channel";
-static const char type[] = "Local";
static const char tdesc[] = "Local Proxy Channel Driver";
static int usecnt =0;
@@ -85,7 +85,7 @@ static int local_sendhtml(struct ast_channel *ast, int subclass, const char *dat
/* PBX interface structure for channel registration */
static const struct ast_channel_tech local_tech = {
- .type = type,
+ .type = "Local",
.description = tdesc,
.capabilities = -1,
.requester = local_request,
@@ -330,8 +330,8 @@ static int local_call(struct ast_channel *ast, char *dest, int timeout)
p->chan->cid.cid_rdnis = ast_strdup(p->owner->cid.cid_rdnis);
p->chan->cid.cid_ani = ast_strdup(p->owner->cid.cid_ani);
- strncpy(p->chan->language, p->owner->language, sizeof(p->chan->language) - 1);
- strncpy(p->chan->accountcode, p->owner->accountcode, sizeof(p->chan->accountcode) - 1);
+ ast_string_field_set(p->chan, language, p->owner->language);
+ ast_string_field_set(p->chan, accountcode, p->owner->accountcode);
p->chan->cdrflags = p->owner->cdrflags;
/* copy the channel variables from the incoming channel to the outgoing channel */
@@ -513,10 +513,8 @@ static struct ast_channel *local_new(struct local_pvt *p, int state)
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);
- snprintf(tmp2->name, sizeof(tmp2->name), "Local/%s@%s-%04x,2", p->exten, p->context, randnum);
- tmp->type = type;
- tmp2->type = type;
+ ast_string_field_build(tmp, name, "Local/%s@%s-%04x,1", p->exten, p->context, randnum);
+ ast_string_field_build(tmp2, name, "Local/%s@%s-%04x,2", p->exten, p->context, randnum);
ast_setstate(tmp, state);
ast_setstate(tmp2, AST_STATE_RING);
tmp->writeformat = p->reqformat;
@@ -592,7 +590,7 @@ int load_module()
{
/* 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);
+ ast_log(LOG_ERROR, "Unable to register channel class 'Local'\n");
return -1;
}
ast_cli_register(&cli_show_locals);
diff --git a/channels/chan_mgcp.c b/channels/chan_mgcp.c
index 65f614580..27161507d 100644
--- a/channels/chan_mgcp.c
+++ b/channels/chan_mgcp.c
@@ -116,6 +116,7 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
#include "asterisk/causes.h"
#include "asterisk/dsp.h"
#include "asterisk/devicestate.h"
+#include "asterisk/stringfields.h"
#ifndef IPTOS_MINCOST
#define IPTOS_MINCOST 0x02
@@ -137,7 +138,6 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
#endif
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";
@@ -503,7 +503,7 @@ static int mgcp_senddigit(struct ast_channel *ast, char digit);
static int mgcp_devicestate(void *data);
static const struct ast_channel_tech mgcp_tech = {
- .type = type,
+ .type = "MGCP",
.description = tdesc,
.capabilities = AST_FORMAT_ULAW,
.properties = AST_CHAN_TP_WANTSJITTER,
@@ -1454,10 +1454,9 @@ static struct ast_channel *mgcp_new(struct mgcp_subchannel *sub, int state)
if (!tmp->nativeformats)
tmp->nativeformats = capability;
fmt = ast_best_codec(tmp->nativeformats);
- snprintf(tmp->name, sizeof(tmp->name), "MGCP/%s@%s-%d", i->name, i->parent->name, sub->id);
+ ast_string_field_build(tmp, name, "MGCP/%s@%s-%d", i->name, i->parent->name, sub->id);
if (sub->rtp)
tmp->fds[0] = ast_rtp_fd(sub->rtp);
- tmp->type = type;
if (i->dtmfmode & (MGCP_DTMF_INBAND | MGCP_DTMF_HYBRID)) {
i->dsp = ast_dsp_new();
ast_dsp_set_features(i->dsp,DSP_FEATURE_DTMF_DETECT);
@@ -1475,9 +1474,9 @@ static struct ast_channel *mgcp_new(struct mgcp_subchannel *sub, int state)
tmp->rawreadformat = fmt;
tmp->tech_pvt = sub;
if (!ast_strlen_zero(i->language))
- strncpy(tmp->language, i->language, sizeof(tmp->language)-1);
+ ast_string_field_set(tmp, language, i->language);
if (!ast_strlen_zero(i->accountcode))
- strncpy(tmp->accountcode, i->accountcode, sizeof(tmp->accountcode)-1);
+ ast_string_field_set(tmp, accountcode, i->accountcode);
if (i->amaflags)
tmp->amaflags = i->amaflags;
sub->owner = tmp;
@@ -1487,7 +1486,7 @@ static struct ast_channel *mgcp_new(struct mgcp_subchannel *sub, int state)
ast_update_use_count();
tmp->callgroup = i->callgroup;
tmp->pickupgroup = i->pickupgroup;
- strncpy(tmp->call_forward, i->call_forward, sizeof(tmp->call_forward) - 1);
+ ast_string_field_set(tmp, call_forward, i->call_forward);
strncpy(tmp->context, i->context, sizeof(tmp->context)-1);
strncpy(tmp->exten, i->exten, sizeof(tmp->exten)-1);
if (!ast_strlen_zero(i->cid_num))
@@ -4017,7 +4016,7 @@ static int mgcp_set_rtp_peer(struct ast_channel *chan, struct ast_rtp *rtp, stru
}
static struct ast_rtp_protocol mgcp_rtp = {
- .type = type,
+ .type = "MGCP",
.get_rtp_info = mgcp_get_rtp_peer,
.set_rtp_peer = mgcp_set_rtp_peer,
};
@@ -4346,7 +4345,7 @@ int load_module()
if (!(res = reload_config())) {
/* Make sure we can register our mgcp channel type */
if (ast_channel_register(&mgcp_tech)) {
- ast_log(LOG_ERROR, "Unable to register channel class %s\n", type);
+ ast_log(LOG_ERROR, "Unable to register channel class 'MGCP'\n");
return -1;
}
ast_rtp_proto_register(&mgcp_rtp);
diff --git a/channels/chan_oss.c b/channels/chan_oss.c
index bbfa70ac6..858411de7 100644
--- a/channels/chan_oss.c
+++ b/channels/chan_oss.c
@@ -69,6 +69,7 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
#include "asterisk/utils.h"
#include "asterisk/causes.h"
#include "asterisk/endian.h"
+#include "asterisk/stringfields.h"
/* ringtones we use */
#include "busy.h"
@@ -247,7 +248,6 @@ static struct sound sounds[] = {
struct chan_oss_pvt {
struct chan_oss_pvt *next;
- char *type; /* XXX maybe take the one from oss_tech */
char *name;
/*
* cursound indicates which in struct sound we play. -1 means nothing,
@@ -303,7 +303,6 @@ struct chan_oss_pvt {
};
static struct chan_oss_pvt oss_default = {
- .type = "Console",
.cursound = -1,
.sounddev = -1,
.duplex = M_UNSET, /* XXX check this */
@@ -334,19 +333,19 @@ 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 = "Console",
+ .type = "Console",
.description = "OSS Console Channel Driver",
.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,
+ .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,
};
/*
@@ -807,7 +806,7 @@ static struct ast_frame *oss_read(struct ast_channel *c)
/* prepare a NULL frame in case we don't have enough data to return */
bzero(f, sizeof(struct ast_frame));
f->frametype = AST_FRAME_NULL;
- f->src = o->type;
+ f->src = oss_tech.type;
res = read(o->sounddev, o->oss_read_buf + o->readpos,
sizeof(o->oss_read_buf) - o->readpos);
@@ -884,8 +883,7 @@ static struct ast_channel *oss_new(struct chan_oss_pvt *o,
if (c == NULL)
return NULL;
c->tech = &oss_tech;
- snprintf(c->name, sizeof(c->name), "OSS/%s", o->device + 5);
- c->type = o->type;
+ ast_string_field_build(c, name, "OSS/%s", o->device + 5);
c->fds[0] = o->sounddev; /* -1 if device closed, override later */
c->nativeformats = AST_FORMAT_SLINEAR;
c->readformat = AST_FORMAT_SLINEAR;
@@ -897,7 +895,7 @@ static struct ast_channel *oss_new(struct chan_oss_pvt *o,
if (!ast_strlen_zero(ext))
ast_copy_string(c->exten, ext, sizeof(c->exten));
if (!ast_strlen_zero(o->language))
- ast_copy_string(c->language, o->language, sizeof(c->language));
+ ast_string_field_set(c, language, o->language);
if (!ast_strlen_zero(o->cid_num))
c->cid.cid_num = ast_strdup(o->cid_num);
if (!ast_strlen_zero(o->cid_name))
@@ -1403,8 +1401,7 @@ int load_module(void)
}
i = ast_channel_register(&oss_tech);
if (i < 0) {
- ast_log(LOG_ERROR, "Unable to register channel class '%s'\n",
- oss_default.type);
+ ast_log(LOG_ERROR, "Unable to register channel class 'Console'\n");
/* XXX should cleanup allocated memory etc. */
return -1;
}
diff --git a/channels/chan_phone.c b/channels/chan_phone.c
index 8f732e9ae..1d440d8d9 100644
--- a/channels/chan_phone.c
+++ b/channels/chan_phone.c
@@ -58,6 +58,8 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
#include "asterisk/utils.h"
#include "asterisk/callerid.h"
#include "asterisk/causes.h"
+#include "asterisk/stringfields.h"
+
#include "DialTone.h"
#ifdef QTI_PHONEJACK_TJ_PCI /* check for the newer quicknet driver v.3.1.0 which has this symbol */
@@ -81,7 +83,6 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
#define DEFAULT_GAIN 0x100
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";
@@ -163,7 +164,7 @@ static int phone_fixup(struct ast_channel *old, struct ast_channel *new);
static int phone_indicate(struct ast_channel *chan, int condition);
static const struct ast_channel_tech phone_tech = {
- .type = type,
+ .type = "Phone",
.description = tdesc,
.capabilities = AST_FORMAT_G723_1 | AST_FORMAT_SLINEAR | AST_FORMAT_ULAW,
.requester = phone_request,
@@ -179,7 +180,7 @@ static const struct ast_channel_tech phone_tech = {
};
static struct ast_channel_tech phone_tech_fxs = {
- .type = type,
+ .type = "Phone",
.description = tdesc,
.requester = phone_request,
.send_digit = phone_digit,
@@ -479,7 +480,7 @@ static struct ast_frame *phone_exception(struct ast_channel *ast)
p->fr.datalen = 0;
p->fr.samples = 0;
p->fr.data = NULL;
- p->fr.src = type;
+ p->fr.src = "Phone";
p->fr.offset = 0;
p->fr.mallocd=0;
p->fr.delivery = ast_tv(0,0);
@@ -541,7 +542,7 @@ static struct ast_frame *phone_read(struct ast_channel *ast)
p->fr.datalen = 0;
p->fr.samples = 0;
p->fr.data = NULL;
- p->fr.src = type;
+ p->fr.src = "Phone";
p->fr.offset = 0;
p->fr.mallocd=0;
p->fr.delivery = ast_tv(0,0);
@@ -815,8 +816,7 @@ static struct ast_channel *phone_new(struct phone_pvt *i, int state, char *conte
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;
+ ast_string_field_build(tmp, name, "Phone/%s", i->dev + 5);
tmp->fds[0] = i->fd;
/* XXX Switching formats silently causes kernel panics XXX */
if (i->mode == MODE_FXS &&
@@ -848,7 +848,7 @@ static struct ast_channel *phone_new(struct phone_pvt *i, int state, char *conte
else
strncpy(tmp->exten, "s", sizeof(tmp->exten) - 1);
if (!ast_strlen_zero(i->language))
- strncpy(tmp->language, i->language, sizeof(tmp->language)-1);
+ ast_string_field_set(tmp, language, i->language);
if (!ast_strlen_zero(i->cid_num))
tmp->cid.cid_num = strdup(i->cid_num);
if (!ast_strlen_zero(i->cid_name))
@@ -1411,7 +1411,7 @@ int load_module()
/* Make sure we can register our Adtranphone channel type */
if (ast_channel_register(cur_tech)) {
- ast_log(LOG_ERROR, "Unable to register channel class %s\n", type);
+ ast_log(LOG_ERROR, "Unable to register channel class 'Phone'\n");
ast_config_destroy(cfg);
__unload_module();
return -1;
diff --git a/channels/chan_sip.c b/channels/chan_sip.c
index c1556e0e2..61538d9a4 100644
--- a/channels/chan_sip.c
+++ b/channels/chan_sip.c
@@ -155,7 +155,6 @@ static int expiry = DEFAULT_EXPIRY;
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";
static int usecnt = 0;
@@ -979,7 +978,7 @@ static int sip_get_codec(struct ast_channel *chan);
/*! \brief Definition of this channel for PBX channel registration */
static const struct ast_channel_tech sip_tech = {
- .type = channeltype,
+ .type = "SIP",
.description = "Session Initiation Protocol (SIP)",
.capabilities = ((AST_FORMAT_MAX_AUDIO << 1) - 1),
.properties = AST_CHAN_TP_WANTSJITTER,
@@ -1001,7 +1000,7 @@ static const struct ast_channel_tech sip_tech = {
/*! \brief Interface structure with callbacks used to connect to RTP module */
static struct ast_rtp_protocol sip_rtp = {
- type: channeltype,
+ type: "SIP",
get_rtp_info: sip_get_rtp_peer,
get_vrtp_info: sip_get_vrtp_peer,
set_rtp_peer: sip_set_rtp_peer,
@@ -1665,7 +1664,8 @@ static void register_peer_exten(struct sip_peer *peer, int onoff)
stringp = multi;
while((ext = strsep(&stringp, "&"))) {
if (onoff)
- ast_add_extension(regcontext, 1, ext, 1, NULL, NULL, "Noop", ast_strdup(peer->name), free, channeltype);
+ ast_add_extension(regcontext, 1, ext, 1, NULL, NULL, "Noop",
+ ast_strdup(peer->name), free, "SIP");
else
ast_context_remove_extension(regcontext, ext, 1, NULL);
}
@@ -2866,13 +2866,12 @@ static struct ast_channel *sip_new(struct sip_pvt *i, int state, const char *tit
fmt = ast_best_codec(tmp->nativeformats);
if (title)
- snprintf(tmp->name, sizeof(tmp->name), "SIP/%s-%04x", title, thread_safe_rand() & 0xffff);
+ ast_string_field_build(tmp, name, "SIP/%s-%04x", title, thread_safe_rand() & 0xffff);
else if (strchr(i->fromdomain,':'))
- snprintf(tmp->name, sizeof(tmp->name), "SIP/%s-%08x", strchr(i->fromdomain,':')+1, (int)(long)(i));
+ ast_string_field_build(tmp, name, "SIP/%s-%08x", strchr(i->fromdomain,':')+1, (int)(long)(i));
else
- snprintf(tmp->name, sizeof(tmp->name), "SIP/%s-%08x", i->fromdomain, (int)(long)(i));
+ ast_string_field_build(tmp, name, "SIP/%s-%08x", i->fromdomain, (int)(long)(i));
- tmp->type = channeltype;
if (ast_test_flag(i, SIP_DTMF) == SIP_DTMF_INBAND) {
i->vad = ast_dsp_new();
ast_dsp_set_features(i->vad, DSP_FEATURE_DTMF_DETECT);
@@ -2900,13 +2899,13 @@ static struct ast_channel *sip_new(struct sip_pvt *i, int state, const char *tit
tmp->pickupgroup = i->pickupgroup;
tmp->cid.cid_pres = i->callingpres;
if (!ast_strlen_zero(i->accountcode))
- ast_copy_string(tmp->accountcode, i->accountcode, sizeof(tmp->accountcode));
+ ast_string_field_set(tmp, accountcode, i->accountcode);
if (i->amaflags)
tmp->amaflags = i->amaflags;
if (!ast_strlen_zero(i->language))
- ast_copy_string(tmp->language, i->language, sizeof(tmp->language));
+ ast_string_field_set(tmp, language, i->language);
if (!ast_strlen_zero(i->musicclass))
- ast_copy_string(tmp->musicclass, i->musicclass, sizeof(tmp->musicclass));
+ ast_string_field_set(tmp, musicclass, i->musicclass);
i->owner = tmp;
ast_mutex_lock(&usecnt_lock);
usecnt++;
@@ -3165,7 +3164,7 @@ static struct sip_pvt *sip_alloc(ast_string_field callid, struct sockaddr_in *si
if (!(p = ast_calloc(1, sizeof(*p))))
return NULL;
- if (ast_string_field_init(p)) {
+ if (ast_string_field_init(p, 512)) {
free(p);
return NULL;
}
@@ -3381,7 +3380,7 @@ static int sip_register(char *value, int lineno)
return -1;
}
- if (ast_string_field_init(reg)) {
+ if (ast_string_field_init(reg, 256)) {
ast_log(LOG_ERROR, "Out of memory. Can't allocate SIP registry strings\n");
free(reg);
return -1;
@@ -9275,7 +9274,7 @@ static char *func_header_read(struct ast_channel *chan, char *cmd, char *data, c
}
ast_mutex_lock(&chan->lock);
- if (chan->type != channeltype) {
+ if (chan->tech != &sip_tech) {
ast_log(LOG_WARNING, "This function can only be used on SIP channels.\n");
ast_mutex_unlock(&chan->lock);
return NULL;
@@ -9446,7 +9445,7 @@ static char *function_sipchaninfo_read(struct ast_channel *chan, char *cmd, char
}
ast_mutex_lock(&chan->lock);
- if (chan->type != channeltype) {
+ if (chan->tech != &sip_tech) {
ast_log(LOG_WARNING, "This function can only be used on SIP channels.\n");
ast_mutex_unlock(&chan->lock);
return NULL;
@@ -9517,7 +9516,7 @@ static void parse_moved_contact(struct sip_pvt *p, struct sip_request *req)
*e = '\0';
ast_log(LOG_DEBUG, "Found promiscuous redirection to 'SIP/%s'\n", s);
if (p->owner)
- snprintf(p->owner->call_forward, sizeof(p->owner->call_forward), "SIP/%s", s);
+ ast_string_field_build(p->owner, call_forward, "SIP/%s", s);
} else {
e = strchr(tmp, '@');
if (e)
@@ -9529,7 +9528,7 @@ static void parse_moved_contact(struct sip_pvt *p, struct sip_request *req)
s += 4;
ast_log(LOG_DEBUG, "Found 302 Redirect to extension '%s'\n", s);
if (p->owner)
- ast_copy_string(p->owner->call_forward, s, sizeof(p->owner->call_forward));
+ ast_string_field_set(p->owner, call_forward, s);
}
}
@@ -10031,7 +10030,8 @@ static void handle_response(struct sip_pvt *p, int resp, char *rest, struct sip_
forward and hope we end up at the right place... */
ast_log(LOG_DEBUG, "Hairpin detected, setting up call forward for what it's worth\n");
if (p->owner)
- snprintf(p->owner->call_forward, sizeof(p->owner->call_forward), "Local/%s@%s", p->username, p->context);
+ ast_string_field_build(p->owner, call_forward,
+ "Local/%s@%s", p->username, p->context);
/* Fall through */
case 488: /* Not acceptable here - codec error */
case 480: /* Temporarily Unavailable */
@@ -10183,7 +10183,7 @@ static int sip_park(struct ast_channel *chan1, struct ast_channel *chan2, struct
ast_hangup(chan2m);
return -1;
}
- snprintf(chan1m->name, sizeof(chan1m->name), "Parking/%s", chan1->name);
+ ast_string_field_build(chan1m, name, "Parking/%s", chan1->name);
/* Make formats okay */
chan1m->readformat = chan1->readformat;
chan1m->writeformat = chan1->writeformat;
@@ -10195,7 +10195,7 @@ static int sip_park(struct ast_channel *chan1, struct ast_channel *chan2, struct
/* We make a clone of the peer channel too, so we can play
back the announcement */
- snprintf(chan2m->name, sizeof (chan2m->name), "SIPPeer/%s",chan2->name);
+ ast_string_field_build(chan2m, name, "SIPPeer/%s",chan2->name);
/* Make formats okay */
chan2m->readformat = chan2->readformat;
chan2m->writeformat = chan2->writeformat;
@@ -12504,7 +12504,7 @@ static int reload_config(enum channelreloadreason reason)
ast_copy_string(regcontext, v->value, sizeof(regcontext));
/* Create context if it doesn't exist already */
if (!ast_context_find(regcontext))
- ast_context_create(NULL, regcontext, channeltype);
+ ast_context_create(NULL, regcontext, "SIP");
} else if (!strcasecmp(v->name, "callerid")) {
ast_copy_string(default_callerid, v->value, sizeof(default_callerid));
} else if (!strcasecmp(v->name, "fromdomain")) {
@@ -12871,7 +12871,7 @@ static int sip_dtmfmode(struct ast_channel *chan, void *data)
return 0;
}
ast_mutex_lock(&chan->lock);
- if (chan->type != channeltype) {
+ if (chan->tech != &sip_tech) {
ast_log(LOG_WARNING, "Call this application only on SIP incoming calls\n");
ast_mutex_unlock(&chan->lock);
return 0;
@@ -13170,7 +13170,7 @@ int load_module()
/* Make sure we can register our sip channel type */
if (ast_channel_register(&sip_tech)) {
- ast_log(LOG_ERROR, "Unable to register channel type %s\n", channeltype);
+ ast_log(LOG_ERROR, "Unable to register channel type 'SIP'\n");
return -1;
}
diff --git a/channels/chan_skinny.c b/channels/chan_skinny.c
index 37321a355..6a6702af0 100644
--- a/channels/chan_skinny.c
+++ b/channels/chan_skinny.c
@@ -68,13 +68,13 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
#include "asterisk/musiconhold.h"
#include "asterisk/utils.h"
#include "asterisk/dsp.h"
+#include "asterisk/stringfields.h"
/************************************************************************************/
/* Skinny/Asterisk Protocol Settings */
/************************************************************************************/
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 */
@@ -908,7 +908,7 @@ 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,
+ .type = "Skinny",
.description = tdesc,
.capabilities = AST_FORMAT_ULAW,
.properties = AST_CHAN_TP_WANTSJITTER,
@@ -1355,7 +1355,7 @@ static int skinny_set_rtp_peer(struct ast_channel *chan, struct ast_rtp *rtp, st
}
static struct ast_rtp_protocol skinny_rtp = {
- .type = type,
+ .type = "Skinny",
.get_rtp_info = skinny_get_rtp_peer,
.get_vrtp_info = skinny_get_vrtp_peer,
.set_rtp_peer = skinny_set_rtp_peer,
@@ -2263,11 +2263,10 @@ static struct ast_channel *skinny_new(struct skinny_subchannel *sub, int state)
tmp->nativeformats = capability;
fmt = ast_best_codec(tmp->nativeformats);
ast_verbose("skinny_new: tmp->nativeformats=%d fmt=%d\n", tmp->nativeformats, fmt);
- snprintf(tmp->name, sizeof(tmp->name), "Skinny/%s@%s-%d", l->name, l->parent->name, sub->callid);
+ ast_string_field_build(tmp, name, "Skinny/%s@%s-%d", l->name, l->parent->name, sub->callid);
if (sub->rtp) {
tmp->fds[0] = ast_rtp_fd(sub->rtp);
}
- tmp->type = type;
ast_setstate(tmp, state);
if (state == AST_STATE_RING) {
tmp->rings = 1;
@@ -2277,15 +2276,12 @@ static struct ast_channel *skinny_new(struct skinny_subchannel *sub, int state)
tmp->readformat = fmt;
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)) {
- strncpy(tmp->accountcode, l->accountcode, sizeof(tmp->accountcode)-1);
- }
- if (l->amaflags) {
+ if (!ast_strlen_zero(l->language))
+ ast_string_field_set(tmp, language, l->language);
+ if (!ast_strlen_zero(l->accountcode))
+ ast_string_field_set(tmp, accountcode, l->accountcode);
+ if (l->amaflags)
tmp->amaflags = l->amaflags;
- }
sub->owner = tmp;
ast_mutex_lock(&usecnt_lock);
usecnt++;
@@ -2293,7 +2289,7 @@ static struct ast_channel *skinny_new(struct skinny_subchannel *sub, int state)
ast_update_use_count();
tmp->callgroup = l->callgroup;
tmp->pickupgroup = l->pickupgroup;
- strncpy(tmp->call_forward, l->call_forward, sizeof(tmp->call_forward) - 1);
+ ast_string_field_set(tmp, call_forward, l->call_forward);
strncpy(tmp->context, l->context, sizeof(tmp->context)-1);
strncpy(tmp->exten,l->exten, sizeof(tmp->exten)-1);
if (!ast_strlen_zero(l->cid_num)) {
@@ -3303,7 +3299,7 @@ int load_module()
if (!res) {
/* Make sure we can register our skinny channel type */
if (ast_channel_register(&skinny_tech)) {
- ast_log(LOG_ERROR, "Unable to register channel class %s\n", type);
+ ast_log(LOG_ERROR, "Unable to register channel class 'Skinny'\n");
return -1;
}
}
diff --git a/channels/chan_zap.c b/channels/chan_zap.c
index fc44bd4f6..52195c9d9 100644
--- a/channels/chan_zap.c
+++ b/channels/chan_zap.c
@@ -100,9 +100,10 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
#include "asterisk/term.h"
#include "asterisk/utils.h"
#include "asterisk/transcap.h"
+#include "asterisk/stringfields.h"
#ifndef ZT_SIG_EM_E1
-#error "Your zaptel is too old. please cvs update"
+#error "Your zaptel is too old. please update"
#endif
#ifndef ZT_TONEDETECT
@@ -160,7 +161,6 @@ static const char tdesc[] = "Zapata Telephony Driver"
#endif
;
-static const char type[] = "Zap";
static const char config[] = "zapata.conf";
#define SIG_EM ZT_SIG_EM
@@ -307,7 +307,7 @@ static char localprefix[20] = "";
static char privateprefix[20] = "";
static char unknownprefix[20] = "";
static long resetinterval = 3600; /*!< How often (in seconds) to reset unused channels. Default 1 hour. */
-static struct ast_channel inuse = { "GR-303InUse" };
+static struct ast_channel inuse;
#ifdef PRI_GETSET_TIMERS
static int pritimers[PRI_MAX_TIMERS];
#endif
@@ -709,7 +709,7 @@ 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,
+ .type = "Zap",
.description = tdesc,
.capabilities = AST_FORMAT_SLINEAR | AST_FORMAT_ULAW | AST_FORMAT_ALAW,
.requester = zt_request,
@@ -5083,20 +5083,19 @@ static struct ast_channel *zt_new(struct zt_pvt *i, int state, int startpbx, int
do {
#ifdef ZAPATA_PRI
if (i->bearer || (i->pri && (i->sig == SIG_FXSKS)))
- snprintf(tmp->name, sizeof(tmp->name), "Zap/%d:%d-%d", i->pri->trunkgroup, i->channel, y);
+ ast_string_field_build(tmp, name, "Zap/%d:%d-%d", i->pri->trunkgroup, i->channel, y);
else
#endif
if (i->channel == CHAN_PSEUDO)
- snprintf(tmp->name, sizeof(tmp->name), "Zap/pseudo-%d", rand());
+ ast_string_field_build(tmp, name, "Zap/pseudo-%d", rand());
else
- snprintf(tmp->name, sizeof(tmp->name), "Zap/%d-%d", i->channel, y);
+ ast_string_field_build(tmp, name, "Zap/%d-%d", i->channel, y);
for (x=0;x<3;x++) {
if ((index != x) && i->subs[x].owner && !strcasecmp(tmp->name, i->subs[x].owner->name))
break;
}
y++;
} while (x < 3);
- tmp->type = type;
tmp->fds[0] = i->subs[index].zfd;
tmp->nativeformats = AST_FORMAT_SLINEAR | deflaw;
/* Start out assuming ulaw since it's smaller :) */
@@ -5168,19 +5167,18 @@ static struct ast_channel *zt_new(struct zt_pvt *i, int state, int startpbx, int
tmp->pickupgroup = i->pickupgroup;
}
if (!ast_strlen_zero(i->language))
- ast_copy_string(tmp->language, i->language, sizeof(tmp->language));
+ ast_string_field_set(tmp, language, i->language);
if (!ast_strlen_zero(i->musicclass))
- ast_copy_string(tmp->musicclass, i->musicclass, sizeof(tmp->musicclass));
+ ast_string_field_set(tmp, musicclass, i->musicclass);
if (!i->owner)
i->owner = tmp;
if (!ast_strlen_zero(i->accountcode))
- ast_copy_string(tmp->accountcode, i->accountcode, sizeof(tmp->accountcode));
+ ast_string_field_set(tmp, accountcode, i->accountcode);
if (i->amaflags)
tmp->amaflags = i->amaflags;
i->subs[index].owner = tmp;
ast_copy_string(tmp->context, i->context, sizeof(tmp->context));
- /* Copy call forward info */
- ast_copy_string(tmp->call_forward, i->call_forward, sizeof(tmp->call_forward));
+ ast_string_field_set(tmp, call_forward, i->call_forward);
/* If we've been told "no ADSI" then enforce it */
if (!i->adsi)
tmp->adsicpe = AST_ADSI_UNAVAILABLE;
@@ -5856,8 +5854,8 @@ lax);
if (nbridge && ast_bridged_channel(nbridge))
pbridge = ast_bridged_channel(nbridge)->tech_pvt;
if (nbridge && pbridge &&
- (!strcmp(nbridge->type,"Zap")) &&
- (!strcmp(ast_bridged_channel(nbridge)->type, "Zap")) &&
+ (nbridge->tech == &zap_tech) &&
+ (ast_bridged_channel(nbridge)->tech == &zap_tech) &&
ISTRUNK(pbridge)) {
int func = ZT_FLASH;
/* Clear out the dial buffer */
@@ -7893,8 +7891,9 @@ static int pri_fixup_principle(struct zt_pri *pri, int principle, q931_call *c)
/* Fix it all up now */
pri->pvts[principle]->owner = pri->pvts[x]->owner;
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);
+ ast_string_field_build(pri->pvts[principle]->owner, name,
+ "Zap/%d:%d-%d", pri->trunkgroup,
+ pri->pvts[principle]->channel, 1);
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;
@@ -11095,7 +11094,7 @@ int load_module(void)
return -1;
}
if (ast_channel_register(&zap_tech)) {
- ast_log(LOG_ERROR, "Unable to register channel class %s\n", type);
+ ast_log(LOG_ERROR, "Unable to register channel class 'Zap'\n");
__unload_module();
return -1;
}
@@ -11114,6 +11113,8 @@ int load_module(void)
ast_manager_register( "ZapDNDon", 0, action_zapdndon, "Toggle Zap channel Do Not Disturb status ON" );
ast_manager_register( "ZapDNDoff", 0, action_zapdndoff, "Toggle Zap channel Do Not Disturb status OFF" );
ast_manager_register("ZapShowChannels", 0, action_zapshowchannels, "Show status zapata channels");
+ ast_string_field_init(&inuse, 16);
+ ast_string_field_set(&inuse, name, "GR-303InUse");
return res;
}
diff --git a/channels/iax2-parser.c b/channels/iax2-parser.c
index ff13da936..15a8a8b17 100644
--- a/channels/iax2-parser.c
+++ b/channels/iax2-parser.c
@@ -525,7 +525,7 @@ void iax_showframe(struct iax_frame *f, struct ast_iax2_full_hdr *fhi, int rx, s
dump_ies(fh->iedata, datalen);
}
-int iax_ie_append_raw(struct iax_ie_data *ied, unsigned char ie, void *data, int datalen)
+int iax_ie_append_raw(struct iax_ie_data *ied, unsigned char ie, const void *data, int datalen)
{
char tmp[256];
if (datalen > ((int)sizeof(ied->buf) - ied->pos)) {
@@ -540,7 +540,7 @@ int iax_ie_append_raw(struct iax_ie_data *ied, unsigned char ie, void *data, int
return 0;
}
-int iax_ie_append_addr(struct iax_ie_data *ied, unsigned char ie, struct sockaddr_in *sin)
+int iax_ie_append_addr(struct iax_ie_data *ied, unsigned char ie, const struct sockaddr_in *sin)
{
return iax_ie_append_raw(ied, ie, sin, (int)sizeof(struct sockaddr_in));
}
@@ -559,7 +559,7 @@ int iax_ie_append_short(struct iax_ie_data *ied, unsigned char ie, unsigned shor
return iax_ie_append_raw(ied, ie, &newval, (int)sizeof(newval));
}
-int iax_ie_append_str(struct iax_ie_data *ied, unsigned char ie, char *str)
+int iax_ie_append_str(struct iax_ie_data *ied, unsigned char ie, const char *str)
{
return iax_ie_append_raw(ied, ie, str, strlen(str));
}
diff --git a/channels/iax2-parser.h b/channels/iax2-parser.h
index dd90682c2..b926b4b94 100644
--- a/channels/iax2-parser.h
+++ b/channels/iax2-parser.h
@@ -129,27 +129,27 @@ struct iax_ie_data {
};
/* Choose a different function for output */
-extern void iax_set_output(void (*output)(const char *data));
+void iax_set_output(void (*output)(const char *data));
/* Choose a different function for errors */
-extern void iax_set_error(void (*output)(const char *data));
-extern void iax_showframe(struct iax_frame *f, struct ast_iax2_full_hdr *fhi, int rx, struct sockaddr_in *sin, int datalen);
+void iax_set_error(void (*output)(const char *data));
+void iax_showframe(struct iax_frame *f, struct ast_iax2_full_hdr *fhi, int rx, struct sockaddr_in *sin, int datalen);
-extern const char *iax_ie2str(int ie);
+const char *iax_ie2str(int ie);
-extern int iax_ie_append_raw(struct iax_ie_data *ied, unsigned char ie, void *data, int datalen);
-extern int iax_ie_append_addr(struct iax_ie_data *ied, unsigned char ie, struct sockaddr_in *sin);
-extern int iax_ie_append_int(struct iax_ie_data *ied, unsigned char ie, unsigned int value);
-extern int iax_ie_append_short(struct iax_ie_data *ied, unsigned char ie, unsigned short value);
-extern int iax_ie_append_str(struct iax_ie_data *ied, unsigned char ie, char *str);
-extern int iax_ie_append_byte(struct iax_ie_data *ied, unsigned char ie, unsigned char dat);
-extern int iax_ie_append(struct iax_ie_data *ied, unsigned char ie);
-extern int iax_parse_ies(struct iax_ies *ies, unsigned char *data, int datalen);
+int iax_ie_append_raw(struct iax_ie_data *ied, unsigned char ie, const void *data, int datalen);
+int iax_ie_append_addr(struct iax_ie_data *ied, unsigned char ie, const struct sockaddr_in *sin);
+int iax_ie_append_int(struct iax_ie_data *ied, unsigned char ie, unsigned int value);
+int iax_ie_append_short(struct iax_ie_data *ied, unsigned char ie, unsigned short value);
+int iax_ie_append_str(struct iax_ie_data *ied, unsigned char ie, const char *str);
+int iax_ie_append_byte(struct iax_ie_data *ied, unsigned char ie, unsigned char dat);
+int iax_ie_append(struct iax_ie_data *ied, unsigned char ie);
+int iax_parse_ies(struct iax_ies *ies, unsigned char *data, int datalen);
-extern int iax_get_frames(void);
-extern int iax_get_iframes(void);
-extern int iax_get_oframes(void);
+int iax_get_frames(void);
+int iax_get_iframes(void);
+int iax_get_oframes(void);
-extern void iax_frame_wrap(struct iax_frame *fr, struct ast_frame *f);
-extern struct iax_frame *iax_frame_new(int direction, int datalen);
-extern void iax_frame_free(struct iax_frame *fr);
+void iax_frame_wrap(struct iax_frame *fr, struct ast_frame *f);
+struct iax_frame *iax_frame_new(int direction, int datalen);
+void iax_frame_free(struct iax_frame *fr);
#endif