dect
/
asterisk
Archived
13
0
Fork 0

More RSW merges. This should do it for the channels/ dir.

git-svn-id: http://svn.digium.com/svn/asterisk/trunk@136917 f38db490-d61c-443f-a65b-d21fe96a405b
This commit is contained in:
seanbright 2008-08-09 14:12:34 +00:00
parent 428ca97131
commit 3d55cb9df3
8 changed files with 253 additions and 245 deletions

View File

@ -135,8 +135,8 @@ static const char tdesc[] = "Inter Asterisk eXchange Driver (Ver 2)";
static int global_max_trunk_mtu; /*!< Maximum MTU, 0 if not used */
static int trunk_timed, trunk_untimed, trunk_maxmtu, trunk_nmaxmtu ; /*!< Trunk MTU statistics */
#define DEFAULT_CONTEXT "default"
static char context[80] = "default";
static char default_parkinglot[AST_MAX_CONTEXT];
static char language[MAX_LANGUAGE] = "";
@ -164,9 +164,10 @@ static int iaxdefaultdpcache=10 * 60; /* Cache dialplan entries for 10 minutes b
static int iaxdefaulttimeout = 5; /* Default to wait no more than 5 seconds for a reply to come back */
static unsigned int tos = 0;
static unsigned int cos = 0;
static struct {
unsigned int tos;
unsigned int cos;
} qos = { 0, 0 };
static int min_reg_expire;
static int max_reg_expire;
@ -2793,7 +2794,7 @@ static char *handle_cli_iax2_show_cache(struct ast_cli_entry *e, int cmd, struct
struct iax2_dpcache *dp = NULL;
char tmp[1024], *pc = NULL;
int s, x, y;
struct timeval tv = ast_tvnow();
struct timeval now = ast_tvnow();
switch (cmd) {
case CLI_INIT:
@ -2811,7 +2812,7 @@ static char *handle_cli_iax2_show_cache(struct ast_cli_entry *e, int cmd, struct
ast_cli(a->fd, "%-20.20s %-12.12s %-9.9s %-8.8s %s\n", "Peer/Context", "Exten", "Exp.", "Wait.", "Flags");
AST_LIST_TRAVERSE(&dpcache, dp, cache_list) {
s = dp->expiry.tv_sec - tv.tv_sec;
s = dp->expiry.tv_sec - now.tv_sec;
tmp[0] = '\0';
if (dp->flags & CACHE_FLAG_EXISTS)
strncat(tmp, "EXISTS|", sizeof(tmp) - strlen(tmp) - 1);
@ -2919,9 +2920,9 @@ static void __get_from_jb(const void *p)
struct iax_frame *fr;
jb_frame frame;
int ret;
long now;
long ms;
long next;
struct timeval tv = ast_tvnow();
struct timeval now = ast_tvnow();
/* Make sure we have a valid private structure before going on */
ast_mutex_lock(&iaxsl[callno]);
@ -2937,12 +2938,12 @@ static void __get_from_jb(const void *p)
/* round up a millisecond since ast_sched_runq does; */
/* prevents us from spinning while waiting for our now */
/* to catch up with runq's now */
tv.tv_usec += 1000;
now.tv_usec += 1000;
now = ast_tvdiff_ms(tv, pvt->rxcore);
ms = ast_tvdiff_ms(now, pvt->rxcore);
if(now >= (next = jb_next(pvt->jb))) {
ret = jb_get(pvt->jb,&frame,now,ast_codec_interp_len(pvt->voiceformat));
if(ms >= (next = jb_next(pvt->jb))) {
ret = jb_get(pvt->jb,&frame,ms,ast_codec_interp_len(pvt->voiceformat));
switch(ret) {
case JB_OK:
fr = frame.data;
@ -3938,7 +3939,7 @@ static enum ast_bridge_result iax2_bridge(struct ast_channel *c0, struct ast_cha
struct ast_frame *f;
unsigned short callno0 = PTR_TO_CALLNO(c0->tech_pvt);
unsigned short callno1 = PTR_TO_CALLNO(c1->tech_pvt);
struct timeval waittimer = {0, 0}, tv;
struct timeval waittimer = {0, 0};
/* We currently do not support native bridging if a timeoutms value has been provided */
if (timeoutms > 0) {
@ -4008,10 +4009,10 @@ static enum ast_bridge_result iax2_bridge(struct ast_channel *c0, struct ast_cha
}
if ((iaxs[callno0]->transferring == TRANSFER_RELEASED) && (iaxs[callno1]->transferring == TRANSFER_RELEASED)) {
/* Call has been transferred. We're no longer involved */
tv = ast_tvnow();
struct timeval now = ast_tvnow();
if (ast_tvzero(waittimer)) {
waittimer = tv;
} else if (tv.tv_sec - waittimer.tv_sec > IAX_LINGER_TIMEOUT) {
waittimer = now;
} else if (now.tv_sec - waittimer.tv_sec > IAX_LINGER_TIMEOUT) {
c0->_softhangup |= AST_SOFTHANGUP_DEV;
c1->_softhangup |= AST_SOFTHANGUP_DEV;
*fo = NULL;
@ -4264,23 +4265,23 @@ static struct ast_channel *ast_iax2_new(int callno, int state, int capability)
return tmp;
}
static unsigned int calc_txpeerstamp(struct iax2_trunk_peer *tpeer, int sampms, struct timeval *tv)
static unsigned int calc_txpeerstamp(struct iax2_trunk_peer *tpeer, int sampms, struct timeval *now)
{
unsigned long int mssincetx; /* unsigned to handle overflows */
long int ms, pred;
tpeer->trunkact = *tv;
mssincetx = ast_tvdiff_ms(*tv, tpeer->lasttxtime);
tpeer->trunkact = *now;
mssincetx = ast_tvdiff_ms(*now, tpeer->lasttxtime);
if (mssincetx > 5000 || ast_tvzero(tpeer->txtrunktime)) {
/* If it's been at least 5 seconds since the last time we transmitted on this trunk, reset our timers */
tpeer->txtrunktime = *tv;
tpeer->txtrunktime = *now;
tpeer->lastsent = 999999;
}
/* Update last transmit time now */
tpeer->lasttxtime = *tv;
tpeer->lasttxtime = *now;
/* Calculate ms offset */
ms = ast_tvdiff_ms(*tv, tpeer->txtrunktime);
ms = ast_tvdiff_ms(*now, tpeer->txtrunktime);
/* Predict from last value */
pred = tpeer->lastsent + sampms;
if (abs(ms - pred) < MAX_TIMESTAMP_SKEW)
@ -4293,7 +4294,7 @@ static unsigned int calc_txpeerstamp(struct iax2_trunk_peer *tpeer, int sampms,
return ms;
}
static unsigned int fix_peerts(struct timeval *tv, int callno, unsigned int ts)
static unsigned int fix_peerts(struct timeval *rxtrunktime, int callno, unsigned int ts)
{
long ms; /* NOT unsigned */
if (ast_tvzero(iaxs[callno]->rxcore)) {
@ -4303,7 +4304,7 @@ static unsigned int fix_peerts(struct timeval *tv, int callno, unsigned int ts)
iaxs[callno]->rxcore.tv_usec -= iaxs[callno]->rxcore.tv_usec % 20000;
}
/* Calculate difference between trunk and channel */
ms = ast_tvdiff_ms(*tv, iaxs[callno]->rxcore);
ms = ast_tvdiff_ms(*rxtrunktime, iaxs[callno]->rxcore);
/* Return as the sum of trunk time and the difference between trunk and real time */
return ms + ts;
}
@ -5017,7 +5018,7 @@ static char *handle_cli_iax2_show_users(struct ast_cli_entry *e, int cmd, struct
pstr = ast_test_flag(user,IAX_CODEC_USER_FIRST) ? "Caller" : "Host";
ast_cli(a->fd, FORMAT2, user->name, auth, user->authmethods,
user->contexts ? user->contexts->context : context,
user->contexts ? user->contexts->context : DEFAULT_CONTEXT,
user->ha ? "Yes" : "No", pstr);
}
@ -5989,7 +5990,7 @@ static int check_access(int callno, struct sockaddr_in *sin, struct iax_ies *ies
if (user->contexts)
ast_string_field_set(iaxs[callno], context, user->contexts->context);
else
ast_string_field_set(iaxs[callno], context, context);
ast_string_field_set(iaxs[callno], context, DEFAULT_CONTEXT);
}
/* And any input keys */
ast_string_field_set(iaxs[callno], inkeys, user->inkeys);
@ -8466,10 +8467,10 @@ retryowner:
ast_set_flag(iaxs[fr->callno], IAX_QUELCH);
if (ies.musiconhold) {
if (iaxs[fr->callno]->owner && ast_bridged_channel(iaxs[fr->callno]->owner)) {
const char *mohsuggest = iaxs[fr->callno]->mohsuggest;
const char *moh_suggest = iaxs[fr->callno]->mohsuggest;
iax2_queue_control_data(fr->callno, AST_CONTROL_HOLD,
S_OR(mohsuggest, NULL),
!ast_strlen_zero(mohsuggest) ? strlen(mohsuggest) + 1 : 0);
S_OR(moh_suggest, NULL),
!ast_strlen_zero(moh_suggest) ? strlen(moh_suggest) + 1 : 0);
if (!iaxs[fr->callno]) {
ast_mutex_unlock(&iaxsl[fr->callno]);
return 1;
@ -9647,7 +9648,7 @@ static void iax2_process_thread_cleanup(void *data)
static void *iax2_process_thread(void *data)
{
struct iax2_thread *thread = data;
struct timeval tv;
struct timeval wait;
struct timespec ts;
int put_into_idle = 0;
@ -9667,9 +9668,9 @@ static void *iax2_process_thread(void *data)
if (thread->type == IAX_THREAD_TYPE_DYNAMIC) {
struct iax2_thread *t = NULL;
/* Wait to be signalled or time out */
tv = ast_tvadd(ast_tvnow(), ast_samp2tv(30000, 1000));
ts.tv_sec = tv.tv_sec;
ts.tv_nsec = tv.tv_usec * 1000;
wait = ast_tvadd(ast_tvnow(), ast_samp2tv(30000, 1000));
ts.tv_sec = wait.tv_sec;
ts.tv_nsec = wait.tv_usec * 1000;
if (ast_cond_timedwait(&thread->cond, &thread->lock, &ts) == ETIMEDOUT) {
/* This thread was never put back into the available dynamic
* thread list, so just go away. */
@ -9692,9 +9693,9 @@ static void *iax2_process_thread(void *data)
/* Someone grabbed our thread *right* after we timed out.
* Wait for them to set us up with something to do and signal
* us to continue. */
tv = ast_tvadd(ast_tvnow(), ast_samp2tv(30000, 1000));
ts.tv_sec = tv.tv_sec;
ts.tv_nsec = tv.tv_usec * 1000;
wait = ast_tvadd(ast_tvnow(), ast_samp2tv(30000, 1000));
ts.tv_sec = wait.tv_sec;
ts.tv_nsec = wait.tv_usec * 1000;
if (ast_cond_timedwait(&thread->cond, &thread->lock, &ts) == ETIMEDOUT)
{
ast_mutex_unlock(&thread->lock);
@ -10147,16 +10148,16 @@ static void *sched_thread(void *ignore)
{
int count;
int res;
struct timeval tv;
struct timeval wait;
struct timespec ts;
for (;;) {
res = ast_sched_wait(sched);
if ((res > 1000) || (res < 0))
res = 1000;
tv = ast_tvadd(ast_tvnow(), ast_samp2tv(res, 1000));
ts.tv_sec = tv.tv_sec;
ts.tv_nsec = tv.tv_usec * 1000;
wait = ast_tvadd(ast_tvnow(), ast_samp2tv(res, 1000));
ts.tv_sec = wait.tv_sec;
ts.tv_nsec = wait.tv_usec * 1000;
pthread_testcancel();
ast_mutex_lock(&sched_lock);
@ -10359,7 +10360,7 @@ static int peer_set_srcaddr(struct iax2_peer *peer, const char *srcaddr)
sin.sin_addr.s_addr = INADDR_ANY;
if (ast_netsock_find(netsock, &sin)) {
sin.sin_addr.s_addr = orig_saddr;
sock = ast_netsock_bind(outsock, io, srcaddr, port, tos, cos, socket_read, NULL);
sock = ast_netsock_bind(outsock, io, srcaddr, port, qos.tos, qos.cos, socket_read, NULL);
if (sock) {
sockfd = ast_netsock_sockfd(sock);
ast_netsock_unref(sock);
@ -11035,13 +11036,13 @@ static int set_config(char *config_file, int reload)
/* Seed initial tos value */
tosval = ast_variable_retrieve(cfg, "general", "tos");
if (tosval) {
if (ast_str2tos(tosval, &tos))
if (ast_str2tos(tosval, &qos.tos))
ast_log(LOG_WARNING, "Invalid tos value, refer to QoS documentation\n");
}
/* Seed initial cos value */
tosval = ast_variable_retrieve(cfg, "general", "cos");
if (tosval) {
if (ast_str2cos(tosval, &cos))
if (ast_str2cos(tosval, &qos.cos))
ast_log(LOG_WARNING, "Invalid cos value, refer to QoS documentation\n");
}
while(v) {
@ -11110,7 +11111,7 @@ static int set_config(char *config_file, int reload)
if (reload) {
ast_log(LOG_NOTICE, "Ignoring bindaddr on reload\n");
} else {
if (!(ns = ast_netsock_bind(netsock, io, v->value, portno, tos, cos, socket_read, NULL))) {
if (!(ns = ast_netsock_bind(netsock, io, v->value, portno, qos.tos, qos.cos, socket_read, NULL))) {
ast_log(LOG_WARNING, "Unable apply binding to '%s' at line %d\n", v->value, v->lineno);
} else {
if (strchr(v->value, ':'))
@ -11220,10 +11221,10 @@ static int set_config(char *config_file, int reload)
/* Create context if it doesn't exist already */
ast_context_find_or_create(NULL, NULL, regcontext, "IAX2");
} else if (!strcasecmp(v->name, "tos")) {
if (ast_str2tos(v->value, &tos))
if (ast_str2tos(v->value, &qos.tos))
ast_log(LOG_WARNING, "Invalid tos value at line %d, refer to QoS documentation\n", v->lineno);
} else if (!strcasecmp(v->name, "cos")) {
if (ast_str2cos(v->value, &cos))
if (ast_str2cos(v->value, &qos.cos))
ast_log(LOG_WARNING, "Invalid cos value at line %d, refer to QoS documentation\n", v->lineno);
} else if (!strcasecmp(v->name, "parkinglot")) {
ast_copy_string(default_parkinglot, v->value, sizeof(default_parkinglot));
@ -11256,7 +11257,7 @@ static int set_config(char *config_file, int reload)
}
if (defaultsockfd < 0) {
if (!(ns = ast_netsock_bind(netsock, io, "0.0.0.0", portno, tos, cos, socket_read, NULL))) {
if (!(ns = ast_netsock_bind(netsock, io, "0.0.0.0", portno, qos.tos, qos.cos, socket_read, NULL))) {
ast_log(LOG_ERROR, "Unable to create network socket: %s\n", strerror(errno));
} else {
ast_verb(2, "Binding IAX2 to default address 0.0.0.0:%d\n", portno);
@ -11504,13 +11505,13 @@ static int cache_get_callno_locked(const char *data)
static struct iax2_dpcache *find_cache(struct ast_channel *chan, const char *data, const char *context, const char *exten, int priority)
{
struct iax2_dpcache *dp = NULL;
struct timeval tv = ast_tvnow();
int x, com[2], timeout, old = 0, outfd, abort, callno;
struct timeval now = ast_tvnow();
int x, com[2], timeout, old = 0, outfd, doabort, callno;
struct ast_channel *c = NULL;
struct ast_frame *f = NULL;
AST_LIST_TRAVERSE_SAFE_BEGIN(&dpcache, dp, cache_list) {
if (ast_tvcmp(tv, dp->expiry) > 0) {
if (ast_tvcmp(now, dp->expiry) > 0) {
AST_LIST_REMOVE_CURRENT(cache_list);
if ((dp->flags & CACHE_FLAG_PENDING) || dp->callno)
ast_log(LOG_WARNING, "DP still has peer field or pending or callno (flags = %d, peer = blah, callno = %d)\n", dp->flags, dp->callno);
@ -11577,7 +11578,7 @@ static struct iax2_dpcache *find_cache(struct ast_channel *chan, const char *dat
/* Defer any dtmf */
if (chan)
old = ast_channel_defer_dtmf(chan);
abort = 0;
doabort = 0;
while(timeout) {
c = ast_waitfor_nandfds(&chan, chan ? 1 : 0, &com[0], 1, NULL, &outfd, &timeout);
if (outfd > -1)
@ -11585,7 +11586,7 @@ static struct iax2_dpcache *find_cache(struct ast_channel *chan, const char *dat
if (!c)
continue;
if (!(f = ast_read(c))) {
abort = 1;
doabort = 1;
break;
}
ast_frfree(f);
@ -11597,7 +11598,7 @@ static struct iax2_dpcache *find_cache(struct ast_channel *chan, const char *dat
dp->waiters[x] = -1;
close(com[1]);
close(com[0]);
if (abort) {
if (doabort) {
/* Don't interpret anything, just abort. Not sure what th epoint
of undeferring dtmf on a hung up channel is but hey whatever */
if (!old && chan)
@ -11793,7 +11794,7 @@ static int function_iaxpeer(struct ast_channel *chan, const char *cmd, char *dat
ast_getformatname_multiple(buf, len -1, peer->capability);
} else if (!strncasecmp(colname, "codec[", 6)) {
char *codecnum, *ptr;
int index = 0, codec = 0;
int codec = 0;
codecnum = strchr(colname, '[');
*codecnum = '\0';
@ -11801,8 +11802,7 @@ static int function_iaxpeer(struct ast_channel *chan, const char *cmd, char *dat
if ((ptr = strchr(codecnum, ']'))) {
*ptr = '\0';
}
index = atoi(codecnum);
if((codec = ast_codec_pref_index(&peer->prefs, index))) {
if((codec = ast_codec_pref_index(&peer->prefs, atoi(codecnum)))) {
ast_copy_string(buf, ast_getformatname(codec), len);
}
}

View File

@ -153,10 +153,12 @@ static int nat = 0;
static ast_group_t cur_callergroup = 0;
static ast_group_t cur_pickupgroup = 0;
static unsigned int tos = 0;
static unsigned int tos_audio = 0;
static unsigned int cos = 0;
static unsigned int cos_audio = 0;
static struct {
unsigned int tos;
unsigned int tos_audio;
unsigned int cos;
unsigned int cos_audio;
} qos = { 0, 0, 0, 0 };
static int immediate = 0;
@ -460,16 +462,16 @@ static int has_voicemail(struct mgcp_endpoint *p)
{
int new_msgs;
struct ast_event *event;
char *mailbox, *context;
char *mbox, *cntx;
context = mailbox = ast_strdupa(p->mailbox);
strsep(&context, "@");
if (ast_strlen_zero(context))
context = "default";
cntx = mbox = ast_strdupa(p->mailbox);
strsep(&cntx, "@");
if (ast_strlen_zero(cntx))
cntx = "default";
event = ast_event_get_cached(AST_EVENT_MWI,
AST_EVENT_IE_MAILBOX, AST_EVENT_IE_PLTYPE_STR, mailbox,
AST_EVENT_IE_CONTEXT, AST_EVENT_IE_PLTYPE_STR, context,
AST_EVENT_IE_MAILBOX, AST_EVENT_IE_PLTYPE_STR, mbox,
AST_EVENT_IE_CONTEXT, AST_EVENT_IE_PLTYPE_STR, cntx,
AST_EVENT_IE_NEWMSGS, AST_EVENT_IE_PLTYPE_EXISTS,
AST_EVENT_IE_END);
@ -694,7 +696,7 @@ static int mgcp_postrequest(struct mgcp_endpoint *p, struct mgcp_subchannel *sub
struct mgcp_message *msg;
struct mgcp_message *cur;
struct mgcp_gateway *gw;
struct timeval tv;
struct timeval now;
msg = ast_malloc(sizeof(*msg) + len);
if (!msg) {
@ -731,8 +733,8 @@ static int mgcp_postrequest(struct mgcp_endpoint *p, struct mgcp_subchannel *sub
gw->msgs = msg;
}
tv = ast_tvnow();
msg->expire = tv.tv_sec * 1000 + tv.tv_usec / 1000 + DEFAULT_RETRANS;
now = ast_tvnow();
msg->expire = now.tv_sec * 1000 + now.tv_usec / 1000 + DEFAULT_RETRANS;
if (gw->retransid == -1)
gw->retransid = ast_sched_add(sched, DEFAULT_RETRANS, retrans_pkt, (void *)gw);
@ -2644,7 +2646,7 @@ static void start_rtp(struct mgcp_subchannel *sub)
if (sub->rtp && sub->owner)
ast_channel_set_fd(sub->owner, 0, ast_rtp_fd(sub->rtp));
if (sub->rtp) {
ast_rtp_setqos(sub->rtp, tos_audio, cos_audio, "MGCP RTP");
ast_rtp_setqos(sub->rtp, qos.tos_audio, qos.cos_audio, "MGCP RTP");
ast_rtp_setnat(sub->rtp, sub->nat);
}
#if 0
@ -3750,14 +3752,14 @@ static struct mgcp_gateway *build_gateway(char *cat, struct ast_variable *v)
ast_copy_string(e->mailbox, mailbox, sizeof(e->mailbox));
ast_copy_string(e->parkinglot, parkinglot, sizeof(e->parkinglot));
if (!ast_strlen_zero(e->mailbox)) {
char *mailbox, *context;
context = mailbox = ast_strdupa(e->mailbox);
strsep(&context, "@");
if (ast_strlen_zero(context))
context = "default";
char *mbox, *cntx;
cntx = mbox = ast_strdupa(e->mailbox);
strsep(&cntx, "@");
if (ast_strlen_zero(cntx))
cntx = "default";
e->mwi_event_sub = ast_event_subscribe(AST_EVENT_MWI, mwi_event_cb, NULL,
AST_EVENT_IE_MAILBOX, AST_EVENT_IE_PLTYPE_STR, mailbox,
AST_EVENT_IE_CONTEXT, AST_EVENT_IE_PLTYPE_STR, context,
AST_EVENT_IE_MAILBOX, AST_EVENT_IE_PLTYPE_STR, mbox,
AST_EVENT_IE_CONTEXT, AST_EVENT_IE_PLTYPE_STR, cntx,
AST_EVENT_IE_NEWMSGS, AST_EVENT_IE_PLTYPE_EXISTS,
AST_EVENT_IE_END);
}
@ -4155,16 +4157,16 @@ static int reload_config(int reload)
else
capability &= ~format;
} else if (!strcasecmp(v->name, "tos")) {
if (ast_str2tos(v->value, &tos))
if (ast_str2tos(v->value, &qos.tos))
ast_log(LOG_WARNING, "Invalid tos value at line %d, refer to QoS documentation\n", v->lineno);
} else if (!strcasecmp(v->name, "tos_audio")) {
if (ast_str2tos(v->value, &tos_audio))
if (ast_str2tos(v->value, &qos.tos_audio))
ast_log(LOG_WARNING, "Invalid tos_audio value at line %d, refer to QoS documentation\n", v->lineno);
} else if (!strcasecmp(v->name, "cos")) {
if (ast_str2cos(v->value, &cos))
if (ast_str2cos(v->value, &qos.cos))
ast_log(LOG_WARNING, "Invalid cos value at line %d, refer to QoS documentation\n", v->lineno);
} else if (!strcasecmp(v->name, "cos_audio")) {
if (ast_str2cos(v->value, &cos_audio))
if (ast_str2cos(v->value, &qos.cos_audio))
ast_log(LOG_WARNING, "Invalid cos_audio value at line %d, refer to QoS documentation\n", v->lineno);
} else if (!strcasecmp(v->name, "port")) {
if (sscanf(v->value, "%d", &ourport) == 1) {
@ -4249,7 +4251,7 @@ static int reload_config(int reload)
} else {
ast_verb(2, "MGCP Listening on %s:%d\n",
ast_inet_ntoa(bindaddr.sin_addr), ntohs(bindaddr.sin_port));
ast_netsock_set_qos(mgcpsock, tos, cos, "MGCP");
ast_netsock_set_qos(mgcpsock, qos.tos, qos.cos, "MGCP");
}
}
ast_mutex_unlock(&netlock);

View File

@ -2073,7 +2073,7 @@ static int handle_common_options(struct ast_flags *flags, struct ast_flags *mask
/* Realtime device support */
static void realtime_update_peer(const char *peername, struct sockaddr_in *sin, const char *username, const char *fullcontact, const char *useragent, int expirey, int deprecated_username);
static void update_peer(struct sip_peer *p, int expiry);
static void update_peer(struct sip_peer *p, int expire);
static struct ast_variable *get_insecure_variable_from_config(struct ast_config *config);
static const char *get_name_from_variable(struct ast_variable *var, const char *newpeername);
static struct sip_peer *realtime_peer(const char *peername, struct sockaddr_in *sin);
@ -3814,26 +3814,26 @@ static void sip_destroy_peer(struct sip_peer *peer)
}
/*! \brief Update peer data in database (if used) */
static void update_peer(struct sip_peer *p, int expiry)
static void update_peer(struct sip_peer *p, int expire)
{
int rtcachefriends = ast_test_flag(&p->flags[1], SIP_PAGE2_RTCACHEFRIENDS);
if (sip_cfg.peer_rtupdate &&
(p->is_realtime || rtcachefriends)) {
realtime_update_peer(p->name, &p->addr, p->username, rtcachefriends ? p->fullcontact : NULL, p->useragent, expiry, p->deprecated_username);
realtime_update_peer(p->name, &p->addr, p->username, rtcachefriends ? p->fullcontact : NULL, p->useragent, expire, p->deprecated_username);
}
}
static struct ast_variable *get_insecure_variable_from_config(struct ast_config *config)
static struct ast_variable *get_insecure_variable_from_config(struct ast_config *cfg)
{
struct ast_variable *var = NULL;
struct ast_flags flags = {0};
char *cat = NULL;
const char *insecure;
while ((cat = ast_category_browse(config, cat))) {
insecure = ast_variable_retrieve(config, cat, "insecure");
while ((cat = ast_category_browse(cfg, cat))) {
insecure = ast_variable_retrieve(cfg, cat, "insecure");
set_insecure_flags(&flags, insecure, -1);
if (ast_test_flag(&flags, SIP_INSECURE_PORT)) {
var = ast_category_root(config, cat);
var = ast_category_root(cfg, cat);
break;
}
}
@ -6132,9 +6132,9 @@ struct find_call_cb_arg {
* code to determine whether this is the pvt that we are looking for.
* Return FALSE if not found, true otherwise. p is unlocked.
*/
static int find_call_cb(void *__p, void *__arg, int flags)
static int find_call_cb(void *__pvt, void *__arg, int flags)
{
struct sip_pvt *p = __p;
struct sip_pvt *p = __pvt;
struct find_call_cb_arg *arg = __arg;
/* In pedantic, we do not want packets with bad syntax to be connected to a PVT */
int found = FALSE;
@ -6302,7 +6302,7 @@ static int sip_register(const char *value, int lineno)
enum sip_transport transport = SIP_TRANSPORT_UDP;
char buf[256] = "";
char *username = NULL;
char *hostname=NULL, *secret=NULL, *authuser=NULL, *expiry=NULL;
char *hostname=NULL, *secret=NULL, *authuser=NULL, *expire=NULL;
char *callback=NULL;
if (!value)
@ -6329,9 +6329,9 @@ static int sip_register(const char *value, int lineno)
*authuser++ = '\0';
}
/* split host[:port][/contact] */
expiry = strchr(hostname, '~');
if (expiry)
*expiry++ = '\0';
expire = strchr(hostname, '~');
if (expire)
*expire++ = '\0';
callback = strchr(hostname, '/');
if (callback)
*callback++ = '\0';
@ -6361,7 +6361,7 @@ static int sip_register(const char *value, int lineno)
ast_string_field_set(reg, secret, secret);
reg->transport = transport;
reg->expire = -1;
reg->expiry = (expiry ? atoi(expiry) : default_expiry);
reg->expiry = (expire ? atoi(expire) : default_expiry);
reg->timeout = -1;
reg->refresh = reg->expiry;
reg->portno = portnum;
@ -8355,7 +8355,7 @@ static enum sip_result add_sdp(struct sip_request *resp, struct sip_pvt *p, int
char subject[256]; /* Subject of the session */
char owner[256]; /* Session owner/creator */
char connection[256]; /* Connection data */
char *stime = "t=0 0\r\n"; /* Time the session is active */
char *session_time = "t=0 0\r\n"; /* Time the session is active */
char bandwidth[256] = ""; /* Max bitrate */
char *hold;
struct ast_str *m_audio = ast_str_alloca(256); /* Media declaration line for audio */
@ -8584,7 +8584,7 @@ static enum sip_result add_sdp(struct sip_request *resp, struct sip_pvt *p, int
ast_str_append(&m_text, 0, "\r\n");
len = strlen(version) + strlen(subject) + strlen(owner) +
strlen(connection) + strlen(stime);
strlen(connection) + strlen(session_time);
if (needaudio)
len += m_audio->used + a_audio->used + strlen(hold);
if (needvideo) /* only if video response is appropriate */
@ -8600,7 +8600,7 @@ static enum sip_result add_sdp(struct sip_request *resp, struct sip_pvt *p, int
add_line(resp, connection);
if (needvideo) /* only if video response is appropriate */
add_line(resp, bandwidth);
add_line(resp, stime);
add_line(resp, session_time);
if (needaudio) {
add_line(resp, m_audio->str);
add_line(resp, a_audio->str);
@ -8651,11 +8651,11 @@ static void copy_request(struct sip_request *dst, const struct sip_request *src)
{
long offset;
int x;
struct ast_str *dup = dst->data;
struct ast_str *duplicate = dst->data;
/* First copy stuff */
memcpy(dst, src, sizeof(*dst));
dst->data = dup;
dst->data = duplicate;
/* All these + 1's are to account for the need to include the NULL terminator
* Using typical string functions like ast_copy_string or ast_str_set will not
@ -10110,7 +10110,7 @@ static void reg_source_db(struct sip_peer *peer)
{
char data[256];
struct in_addr in;
int expiry;
int expire;
int port;
char *scan, *addr, *port_str, *expiry_str, *username, *contact;
@ -10135,7 +10135,7 @@ static void reg_source_db(struct sip_peer *peer)
return;
if (expiry_str)
expiry = atoi(expiry_str);
expire = atoi(expiry_str);
else
return;
@ -10145,7 +10145,7 @@ static void reg_source_db(struct sip_peer *peer)
ast_copy_string(peer->fullcontact, contact, sizeof(peer->fullcontact));
ast_debug(2, "SIP Seeding peer from astdb: '%s' at %s@%s:%d for %d\n",
peer->name, peer->username, ast_inet_ntoa(in), port, expiry);
peer->name, peer->username, ast_inet_ntoa(in), port, expire);
memset(&peer->addr, 0, sizeof(peer->addr));
peer->addr.sin_family = AF_INET;
@ -10157,7 +10157,7 @@ static void reg_source_db(struct sip_peer *peer)
} else {
sip_poke_peer(peer, 0);
}
AST_SCHED_REPLACE(peer->expire, sched, (expiry + 10) * 1000, expire_register, peer);
AST_SCHED_REPLACE(peer->expire, sched, (expire + 10) * 1000, expire_register, peer);
register_peer_exten(peer, TRUE);
}
@ -10245,7 +10245,7 @@ static enum parse_register_result parse_register_contact(struct sip_pvt *pvt, st
char contact[SIPBUFSIZE];
char data[SIPBUFSIZE];
const char *expires = get_header(req, "Expires");
int expiry = atoi(expires);
int expire = atoi(expires);
char *curi, *host, *pt, *curi2;
int port;
const char *useragent;
@ -10259,11 +10259,11 @@ static enum parse_register_result parse_register_contact(struct sip_pvt *pvt, st
char *s = strcasestr(contact, ";expires=");
if (s) {
expires = strsep(&s, ";"); /* trim ; and beyond */
if (sscanf(expires + 9, "%d", &expiry) != 1)
expiry = default_expiry;
if (sscanf(expires + 9, "%d", &expire) != 1)
expire = default_expiry;
} else {
/* Nothing has been specified */
expiry = default_expiry;
expire = default_expiry;
}
}
@ -10287,7 +10287,7 @@ static enum parse_register_result parse_register_contact(struct sip_pvt *pvt, st
if (peer->expire > -1 && !ast_strlen_zero(peer->fullcontact))
pvt->expiry = ast_sched_when(sched, peer->expire);
return PARSE_REGISTER_QUERY;
} else if (!strcasecmp(curi, "*") || !expiry) { /* Unregister this peer */
} else if (!strcasecmp(curi, "*") || !expire) { /* Unregister this peer */
/* This means remove all registrations and return OK */
memset(&peer->addr, 0, sizeof(peer->addr));
AST_SCHED_DEL(sched, peer->expire);
@ -10348,14 +10348,14 @@ static enum parse_register_result parse_register_contact(struct sip_pvt *pvt, st
ast_copy_string(peer->username, curi, sizeof(peer->username));
AST_SCHED_DEL(sched, peer->expire);
if (expiry > max_expiry)
expiry = max_expiry;
if (expiry < min_expiry)
expiry = min_expiry;
if (expire > max_expiry)
expire = max_expiry;
if (expire < min_expiry)
expire = min_expiry;
peer->expire = peer->is_realtime && !ast_test_flag(&peer->flags[1], SIP_PAGE2_RTCACHEFRIENDS) ? -1 :
ast_sched_add(sched, (expiry + 10) * 1000, expire_register, peer);
pvt->expiry = expiry;
snprintf(data, sizeof(data), "%s:%d:%d:%s:%s", ast_inet_ntoa(peer->addr.sin_addr), ntohs(peer->addr.sin_port), expiry, peer->username, peer->fullcontact);
ast_sched_add(sched, (expire + 10) * 1000, expire_register, peer);
pvt->expiry = expire;
snprintf(data, sizeof(data), "%s:%d:%d:%s:%s", ast_inet_ntoa(peer->addr.sin_addr), ntohs(peer->addr.sin_port), expire, peer->username, peer->fullcontact);
/* Saving TCP connections is useless, we won't be able to reconnect
XXX WHY???? XXX
\todo check this
@ -10367,7 +10367,7 @@ static enum parse_register_result parse_register_contact(struct sip_pvt *pvt, st
/* Is this a new IP address for us? */
if (inaddrcmp(&peer->addr, &oldsin)) {
sip_poke_peer(peer, 0);
ast_verb(3, "Registered SIP '%s' at %s port %d expires %d\n", peer->name, ast_inet_ntoa(peer->addr.sin_addr), ntohs(peer->addr.sin_port), expiry);
ast_verb(3, "Registered SIP '%s' at %s port %d expires %d\n", peer->name, ast_inet_ntoa(peer->addr.sin_addr), ntohs(peer->addr.sin_port), expire);
register_peer_exten(peer, TRUE);
}
@ -13178,7 +13178,7 @@ static char *_sip_show_peer(int type, int fd, struct mansession *s, const struct
ast_cli(fd, "\n");
peer = unref_peer(peer, "sip_show_peer: unref_peer: done with peer ptr");
} else if (peer && type == 1) { /* manager listing */
char buf[256];
char buffer[256];
struct ast_str *mailbox_str = ast_str_alloca(512);
astman_append(s, "Channeltype: SIP\r\n");
astman_append(s, "ObjectName: %s\r\n", peer->name);
@ -13196,9 +13196,9 @@ static char *_sip_show_peer(int type, int fd, struct mansession *s, const struct
if (!ast_strlen_zero(peer->fromdomain))
astman_append(s, "SIP-FromDomain: %s\r\n", peer->fromdomain);
astman_append(s, "Callgroup: ");
astman_append(s, "%s\r\n", ast_print_group(buf, sizeof(buf), peer->callgroup));
astman_append(s, "%s\r\n", ast_print_group(buffer, sizeof(buffer), peer->callgroup));
astman_append(s, "Pickupgroup: ");
astman_append(s, "%s\r\n", ast_print_group(buf, sizeof(buf), peer->pickupgroup));
astman_append(s, "%s\r\n", ast_print_group(buffer, sizeof(buffer), peer->pickupgroup));
peer_mailboxes_to_str(&mailbox_str, peer);
astman_append(s, "VoiceMailbox: %s\r\n", mailbox_str->str);
astman_append(s, "TransferMode: %s\r\n", transfermode2str(peer->allowtransfer));
@ -14893,12 +14893,11 @@ static int function_sippeer(struct ast_channel *chan, const char *cmd, char *dat
ast_copy_string(buf, v->value, len);
} else if (!strncasecmp(colname, "codec[", 6)) {
char *codecnum;
int index = 0, codec = 0;
int codec = 0;
codecnum = colname + 6; /* move past the '[' */
codecnum = strsep(&codecnum, "]"); /* trim trailing ']' if any */
index = atoi(codecnum);
if((codec = ast_codec_pref_index(&peer->prefs, index))) {
if((codec = ast_codec_pref_index(&peer->prefs, atoi(codecnum)))) {
ast_copy_string(buf, ast_getformatname(codec), len);
}
}
@ -17579,11 +17578,11 @@ static int handle_request_invite(struct sip_pvt *p, struct sip_request *req, int
p->invitestate = INV_PROCEEDING;
ast_setstate(c, AST_STATE_RING);
if (strcmp(p->exten, ast_pickup_ext())) { /* Call to extension -start pbx on this call */
enum ast_pbx_result res;
enum ast_pbx_result result;
res = ast_pbx_start(c);
result = ast_pbx_start(c);
switch(res) {
switch(result) {
case AST_PBX_FAILED:
ast_log(LOG_WARNING, "Failed to start PBX :(\n");
p->invitestate = INV_COMPLETED;
@ -17599,7 +17598,7 @@ static int handle_request_invite(struct sip_pvt *p, struct sip_request *req, int
break;
}
if (res) {
if (result) {
/* Unlock locks so ast_hangup can do its magic */
ast_channel_unlock(c);
@ -18471,7 +18470,7 @@ static int handle_request_subscribe(struct sip_pvt *p, struct sip_request *req,
int firststate = AST_EXTENSION_REMOVED;
struct sip_peer *authpeer = NULL;
const char *eventheader = get_header(req, "Event"); /* Get Event package name */
const char *accept = get_header(req, "Accept");
const char *acceptheader = get_header(req, "Accept");
int resubscribe = (p->subscribed != NONE);
char *temp, *event;
struct ao2_iterator i;
@ -18602,16 +18601,16 @@ static int handle_request_subscribe(struct sip_pvt *p, struct sip_request *req,
*/
if (strstr(p->useragent, "Polycom")) {
p->subscribed = XPIDF_XML;
} else if (strstr(accept, "application/pidf+xml")) {
} else if (strstr(acceptheader, "application/pidf+xml")) {
p->subscribed = PIDF_XML; /* RFC 3863 format */
} else if (strstr(accept, "application/dialog-info+xml")) {
} else if (strstr(acceptheader, "application/dialog-info+xml")) {
p->subscribed = DIALOG_INFO_XML;
/* IETF draft: draft-ietf-sipping-dialog-package-05.txt */
} else if (strstr(accept, "application/cpim-pidf+xml")) {
} else if (strstr(acceptheader, "application/cpim-pidf+xml")) {
p->subscribed = CPIM_PIDF_XML; /* RFC 3863 format */
} else if (strstr(accept, "application/xpidf+xml")) {
} else if (strstr(acceptheader, "application/xpidf+xml")) {
p->subscribed = XPIDF_XML; /* Early pre-RFC 3863 format with MSN additions (Microsoft Messenger) */
} else if (ast_strlen_zero(accept)) {
} else if (ast_strlen_zero(acceptheader)) {
if (p->subscribed == NONE) { /* if the subscribed field is not already set, and there is no accept header... */
transmit_response(p, "489 Bad Event", req);
@ -18625,19 +18624,19 @@ static int handle_request_subscribe(struct sip_pvt *p, struct sip_request *req,
} else {
/* Can't find a format for events that we know about */
char mybuf[200];
snprintf(mybuf, sizeof(mybuf), "489 Bad Event (format %s)", accept);
snprintf(mybuf, sizeof(mybuf), "489 Bad Event (format %s)", acceptheader);
transmit_response(p, mybuf, req);
ast_log(LOG_WARNING, "SUBSCRIBE failure: unrecognized format: '%s' pvt: subscribed: %d, stateid: %d, laststate: %d, dialogver: %d, subscribecont: '%s', subscribeuri: '%s'\n",
accept, (int)p->subscribed, p->stateid, p->laststate, p->dialogver, p->subscribecontext, p->subscribeuri);
acceptheader, (int)p->subscribed, p->stateid, p->laststate, p->dialogver, p->subscribecontext, p->subscribeuri);
p->needdestroy = 1;
return 0;
}
} else if (!strcmp(event, "message-summary")) {
if (!ast_strlen_zero(accept) && strcmp(accept, "application/simple-message-summary")) {
if (!ast_strlen_zero(acceptheader) && strcmp(acceptheader, "application/simple-message-summary")) {
/* Format requested that we do not support */
transmit_response(p, "406 Not Acceptable", req);
ast_debug(2, "Received SIP mailbox subscription for unknown format: %s\n", accept);
ast_debug(2, "Received SIP mailbox subscription for unknown format: %s\n", acceptheader);
p->needdestroy = 1;
if (authpeer)
unref_peer(authpeer, "unref_peer, from handle_request_subscribe (authpeer 3)");
@ -21569,17 +21568,17 @@ static int reload_config(enum channelreloadreason reason)
auto_sip_domains = ast_true(v->value);
} else if (!strcasecmp(v->name, "domain")) {
char *domain = ast_strdupa(v->value);
char *context = strchr(domain, ',');
char *cntx = strchr(domain, ',');
if (context)
*context++ = '\0';
if (cntx)
*cntx++ = '\0';
if (ast_strlen_zero(context))
if (ast_strlen_zero(cntx))
ast_debug(1, "No context specified at line %d for domain '%s'\n", v->lineno, domain);
if (ast_strlen_zero(domain))
ast_log(LOG_WARNING, "Empty domain specified at line %d\n", v->lineno);
else
add_sip_domain(ast_strip(domain), SIP_DOMAIN_CONFIG, context ? ast_strip(context) : "");
add_sip_domain(ast_strip(domain), SIP_DOMAIN_CONFIG, cntx ? ast_strip(cntx) : "");
} else if (!strcasecmp(v->name, "register")) {
if (sip_register(v->value, v->lineno) == 0)
registry_count++;

View File

@ -93,12 +93,14 @@ enum skinny_codecs {
#define DEFAULT_SKINNY_BACKLOG 2
#define SKINNY_MAX_PACKET 1000
static unsigned int tos = 0;
static unsigned int tos_audio = 0;
static unsigned int tos_video = 0;
static unsigned int cos = 0;
static unsigned int cos_audio = 0;
static unsigned int cos_video = 0;
static struct {
unsigned int tos;
unsigned int tos_audio;
unsigned int tos_video;
unsigned int cos;
unsigned int cos_audio;
unsigned int cos_video;
} qos = { 0, 0, 0, 0, 0, 0 };
static int keep_alive = 120;
static char vmexten[AST_MAX_EXTENSION]; /* Voicemail pilot number */
@ -965,7 +967,7 @@ struct ast_hostent ahp;
struct hostent *hp;
static int skinnysock = -1;
static pthread_t accept_t;
static char context[AST_MAX_CONTEXT] = "default";
static char global_context[AST_MAX_CONTEXT] = "default";
static char language[MAX_LANGUAGE] = "";
static char mohinterpret[MAX_MUSICCLASS] = "default";
static char mohsuggest[MAX_MUSICCLASS] = "";
@ -2305,15 +2307,15 @@ static int has_voicemail(struct skinny_line *l)
{
int new_msgs;
struct ast_event *event;
char *mailbox, *context;
char *mbox, *context;
context = mailbox = ast_strdupa(l->mailbox);
context = mbox = ast_strdupa(l->mailbox);
strsep(&context, "@");
if (ast_strlen_zero(context))
context = "default";
event = ast_event_get_cached(AST_EVENT_MWI,
AST_EVENT_IE_MAILBOX, AST_EVENT_IE_PLTYPE_STR, mailbox,
AST_EVENT_IE_MAILBOX, AST_EVENT_IE_PLTYPE_STR, mbox,
AST_EVENT_IE_CONTEXT, AST_EVENT_IE_PLTYPE_STR, context,
AST_EVENT_IE_NEWMSGS, AST_EVENT_IE_PLTYPE_EXISTS,
AST_EVENT_IE_END);
@ -3040,7 +3042,7 @@ static struct skinny_device *build_device(const char *cat, struct ast_variable *
} else if (!strcasecmp(v->name, "vmexten")) {
ast_copy_string(device_vmexten, v->value, sizeof(device_vmexten));
} else if (!strcasecmp(v->name, "context")) {
ast_copy_string(context, v->value, sizeof(context));
ast_copy_string(global_context, v->value, sizeof(global_context));
} else if (!strcasecmp(v->name, "regexten")) {
ast_copy_string(regexten, v->value, sizeof(regexten));
} else if (!strcasecmp(v->name, "allow")) {
@ -3154,7 +3156,7 @@ static struct skinny_device *build_device(const char *cat, struct ast_variable *
ast_copy_string(l->name, v->value, sizeof(l->name));
/* XXX Should we check for uniqueness?? XXX */
ast_copy_string(l->context, context, sizeof(l->context));
ast_copy_string(l->context, global_context, sizeof(l->context));
ast_copy_string(l->cid_num, cid_num, sizeof(l->cid_num));
ast_copy_string(l->cid_name, cid_name, sizeof(l->cid_name));
ast_copy_string(l->label, linelabel, sizeof(l->label));
@ -3249,11 +3251,11 @@ static void start_rtp(struct skinny_subchannel *sub)
ast_channel_set_fd(sub->owner, 3, ast_rtcp_fd(sub->vrtp));
}
if (sub->rtp) {
ast_rtp_setqos(sub->rtp, tos_audio, cos_audio, "Skinny RTP");
ast_rtp_setqos(sub->rtp, qos.tos_audio, qos.cos_audio, "Skinny RTP");
ast_rtp_setnat(sub->rtp, l->nat);
}
if (sub->vrtp) {
ast_rtp_setqos(sub->vrtp, tos_video, cos_video, "Skinny VRTP");
ast_rtp_setqos(sub->vrtp, qos.tos_video, qos.cos_video, "Skinny VRTP");
ast_rtp_setnat(sub->vrtp, l->nat);
}
/* Set Frame packetization */
@ -4940,13 +4942,13 @@ static int handle_line_state_req_message(struct skinny_req *req, struct skinnyse
static int handle_time_date_req_message(struct skinny_req *req, struct skinnysession *s)
{
struct timeval tv = ast_tvnow();
struct timeval now = ast_tvnow();
struct ast_tm cmtime;
if (!(req = req_alloc(sizeof(struct definetimedate_message), DEFINETIMEDATE_MESSAGE)))
return -1;
ast_localtime(&tv, &cmtime, NULL);
ast_localtime(&now, &cmtime, NULL);
req->data.definetimedate.year = htolel(cmtime.tm_year+1900);
req->data.definetimedate.month = htolel(cmtime.tm_mon+1);
req->data.definetimedate.dayofweek = htolel(cmtime.tm_wday);
@ -4955,7 +4957,7 @@ static int handle_time_date_req_message(struct skinny_req *req, struct skinnyses
req->data.definetimedate.minute = htolel(cmtime.tm_min);
req->data.definetimedate.seconds = htolel(cmtime.tm_sec);
req->data.definetimedate.milliseconds = htolel(cmtime.tm_usec / 1000);
req->data.definetimedate.timestamp = htolel(tv.tv_sec);
req->data.definetimedate.timestamp = htolel(now.tv_sec);
transmit_response(s->device, req);
return 1;
}
@ -6211,22 +6213,22 @@ static int reload_config(void)
} else if (!strcasecmp(v->name, "dateformat")) {
memcpy(date_format, v->value, sizeof(date_format));
} else if (!strcasecmp(v->name, "tos")) {
if (ast_str2tos(v->value, &tos))
if (ast_str2tos(v->value, &qos.tos))
ast_log(LOG_WARNING, "Invalid tos value at line %d, refer to QoS documentation\n", v->lineno);
} else if (!strcasecmp(v->name, "tos_audio")) {
if (ast_str2tos(v->value, &tos_audio))
if (ast_str2tos(v->value, &qos.tos_audio))
ast_log(LOG_WARNING, "Invalid tos_audio value at line %d, refer to QoS documentation\n", v->lineno);
} else if (!strcasecmp(v->name, "tos_video")) {
if (ast_str2tos(v->value, &tos_video))
if (ast_str2tos(v->value, &qos.tos_video))
ast_log(LOG_WARNING, "Invalid tos_video value at line %d, refer to QoS documentation\n", v->lineno);
} else if (!strcasecmp(v->name, "cos")) {
if (ast_str2cos(v->value, &cos))
if (ast_str2cos(v->value, &qos.cos))
ast_log(LOG_WARNING, "Invalid cos value at line %d, refer to QoS documentation\n", v->lineno);
} else if (!strcasecmp(v->name, "cos_audio")) {
if (ast_str2cos(v->value, &cos_audio))
if (ast_str2cos(v->value, &qos.cos_audio))
ast_log(LOG_WARNING, "Invalid cos_audio value at line %d, refer to QoS documentation\n", v->lineno);
} else if (!strcasecmp(v->name, "cos_video")) {
if (ast_str2cos(v->value, &cos_video))
if (ast_str2cos(v->value, &qos.cos_video))
ast_log(LOG_WARNING, "Invalid cos_video value at line %d, refer to QoS documentation\n", v->lineno);
} else if (!strcasecmp(v->name, "allow")) {
ast_parse_allow_disallow(&default_prefs, &default_capability, v->value, 1);
@ -6312,7 +6314,7 @@ static int reload_config(void)
}
ast_verb(2, "Skinny listening on %s:%d\n",
ast_inet_ntoa(bindaddr.sin_addr), ntohs(bindaddr.sin_port));
ast_netsock_set_qos(skinnysock, tos, cos, "Skinny");
ast_netsock_set_qos(skinnysock, qos.tos, qos.cos, "Skinny");
ast_pthread_create_background(&accept_t, NULL, accept_thread, NULL);
}
}

View File

@ -180,7 +180,7 @@ enum autoprov_extn {
#define FAV_MAX_LENGTH 0x0A
static void dummy(char *dummy, ...)
static void dummy(char *unused, ...)
{
return;
}
@ -206,17 +206,21 @@ static int unistim_port;
static enum autoprovision autoprovisioning = AUTOPROVISIONING_NO;
static int unistim_keepalive;
static int unistimsock = -1;
static unsigned int tos = 0;
static unsigned int tos_audio = 0;
static unsigned int cos = 0;
static unsigned int cos_audio = 0;
static struct {
unsigned int tos;
unsigned int tos_audio;
unsigned int cos;
unsigned int cos_audio;
} qos = { 0, 0, 0, 0 };
static struct io_context *io;
static struct sched_context *sched;
static struct sockaddr_in public_ip = { 0, };
/*! give the IP address for the last packet received */
static struct sockaddr_in addr_from;
static struct sockaddr_in address_from;
/*! size of the sockaddr_in (in WSARecvFrom) */
static unsigned int size_addr_from = sizeof(addr_from);
static unsigned int size_addr_from = sizeof(address_from);
/*! Receive buffer address */
static unsigned char *buff;
static int unistim_reloading = 0;
@ -663,7 +667,7 @@ static unsigned char packet_send_ping[] =
#define BUFFSEND unsigned char buffsend[64] = { 0x00, 0x00, 0xaa, 0xbb, 0x02, 0x01 }
static const char tdesc[] = "UNISTIM Channel Driver";
static const char type[] = "USTM";
static const char channel_type[] = "USTM";
/*! Protos */
static struct ast_channel *unistim_new(struct unistim_subchannel *sub, int state);
@ -692,7 +696,7 @@ static int write_entry_history(struct unistimsession *pte, FILE * f, char c,
static void change_callerid(struct unistimsession *pte, int type, char *callerid);
static const struct ast_channel_tech unistim_tech = {
.type = type,
.type = channel_type,
.description = tdesc,
.capabilities = CAPABILITY,
.properties = AST_CHAN_TP_WANTSJITTER | AST_CHAN_TP_CREATESJITTER,
@ -723,9 +727,9 @@ static void display_last_error(const char *sz_msg)
static unsigned int get_tick_count(void)
{
struct timeval tv = ast_tvnow();
struct timeval now = ast_tvnow();
return (tv.tv_sec * 1000) + (tv.tv_usec / 1000);
return (now.tv_sec * 1000) + (now.tv_usec / 1000);
}
/* Send data to a phone without retransmit nor buffering */
@ -1356,13 +1360,13 @@ static void send_texttitle(struct unistimsession *pte, const char *text)
static void send_date_time(struct unistimsession *pte)
{
BUFFSEND;
struct timeval tv = ast_tvnow();
struct timeval now = ast_tvnow();
struct ast_tm atm = { 0, };
if (unistimdebug)
ast_verb(0, "Sending Time & Date\n");
memcpy(buffsend + SIZE_HEADER, packet_send_date_time, sizeof(packet_send_date_time));
ast_localtime(&tv, &atm, NULL);
ast_localtime(&now, &atm, NULL);
buffsend[10] = (unsigned char) atm.tm_mon + 1;
buffsend[11] = (unsigned char) atm.tm_mday;
buffsend[12] = (unsigned char) atm.tm_hour;
@ -1373,13 +1377,13 @@ static void send_date_time(struct unistimsession *pte)
static void send_date_time2(struct unistimsession *pte)
{
BUFFSEND;
struct timeval tv = ast_tvnow();
struct timeval now = ast_tvnow();
struct ast_tm atm = { 0, };
if (unistimdebug)
ast_verb(0, "Sending Time & Date #2\n");
memcpy(buffsend + SIZE_HEADER, packet_send_date_time2, sizeof(packet_send_date_time2));
ast_localtime(&tv, &atm, NULL);
ast_localtime(&now, &atm, NULL);
if (pte->device)
buffsend[9] = pte->device->datetimeformat;
else
@ -1394,13 +1398,13 @@ static void send_date_time2(struct unistimsession *pte)
static void send_date_time3(struct unistimsession *pte)
{
BUFFSEND;
struct timeval tv = ast_tvnow();
struct timeval now = ast_tvnow();
struct ast_tm atm = { 0, };
if (unistimdebug)
ast_verb(0, "Sending Time & Date #3\n");
memcpy(buffsend + SIZE_HEADER, packet_send_date_time3, sizeof(packet_send_date_time3));
ast_localtime(&tv, &atm, NULL);
ast_localtime(&now, &atm, NULL);
buffsend[10] = (unsigned char) atm.tm_mon + 1;
buffsend[11] = (unsigned char) atm.tm_mday;
buffsend[12] = (unsigned char) atm.tm_hour;
@ -1692,7 +1696,7 @@ static int write_history(struct unistimsession *pte, char way, char ismissed)
char count = 0, *histbuf;
int size;
FILE *f, *f2;
struct timeval tv = ast_tvnow();
struct timeval now = ast_tvnow();
struct ast_tm atm = { 0, };
if (!pte->device)
@ -1713,7 +1717,7 @@ static int write_history(struct unistimsession *pte, char way, char ismissed)
}
}
ast_localtime(&tv, &atm, NULL);
ast_localtime(&now, &atm, NULL);
if (ismissed) {
if (way == 'i')
strcpy(tmp2, "Miss");
@ -2064,7 +2068,7 @@ static void start_rtp(struct unistim_subchannel *sub)
sub->owner->fds[1] = ast_rtcp_fd(sub->rtp);
}
if (sub->rtp) {
ast_rtp_setqos(sub->rtp, tos_audio, cos_audio, "UNISTIM RTP");
ast_rtp_setqos(sub->rtp, qos.tos_audio, qos.cos_audio, "UNISTIM RTP");
ast_rtp_setnat(sub->rtp, sub->parent->parent->nat);
}
@ -2376,11 +2380,11 @@ static void HandleCallOutgoing(struct unistimsession *s)
} else { /* We already have a call, so we switch in a threeway call */
if (s->device->moh) {
struct unistim_subchannel *sub;
struct unistim_subchannel *subchannel;
struct unistim_line *p = s->device->lines;
sub = p->subs[SUB_REAL];
subchannel = p->subs[SUB_REAL];
if (!sub->owner) {
if (!subchannel->owner) {
ast_log(LOG_WARNING, "Unable to find subchannel for music on hold\n");
return;
}
@ -2397,7 +2401,7 @@ static void HandleCallOutgoing(struct unistimsession *s)
if (s->device->silence_generator) {
if (unistimdebug)
ast_verb(0, "Stopping silence generator\n");
ast_channel_stop_silence_generator(sub->owner,
ast_channel_stop_silence_generator(subchannel->owner,
s->device->silence_generator);
s->device->silence_generator = NULL;
}
@ -5318,16 +5322,16 @@ static int reload_config(void)
else if (!strcasecmp(v->name, "port"))
unistim_port = atoi(v->value);
else if (!strcasecmp(v->name, "tos")) {
if (ast_str2tos(v->value, &tos))
if (ast_str2tos(v->value, &qos.tos))
ast_log(LOG_WARNING, "Invalid tos value at line %d, refer to QoS documentation\n", v->lineno);
} else if (!strcasecmp(v->name, "tos_audio")) {
if (ast_str2tos(v->value, &tos_audio))
if (ast_str2tos(v->value, &qos.tos_audio))
ast_log(LOG_WARNING, "Invalid tos_audio value at line %d, refer to QoS documentation\n", v->lineno);
} else if (!strcasecmp(v->name, "cos")) {
if (ast_str2cos(v->value, &cos))
if (ast_str2cos(v->value, &qos.cos))
ast_log(LOG_WARNING, "Invalid cos value at line %d, refer to QoS documentation\n", v->lineno);
} else if (!strcasecmp(v->name, "cos_audio")) {
if (ast_str2cos(v->value, &cos_audio))
if (ast_str2cos(v->value, &qos.cos_audio))
ast_log(LOG_WARNING, "Invalid cos_audio value at line %d, refer to QoS documentation\n", v->lineno);
} else if (!strcasecmp(v->name, "autoprovisioning")) {
if (!strcasecmp(v->value, "no"))
@ -5506,7 +5510,7 @@ static int reload_config(void)
unistimsock = -1;
} else {
ast_verb(2, "UNISTIM Listening on %s:%d\n", ast_inet_ntoa(bindaddr.sin_addr), htons(bindaddr.sin_port));
ast_netsock_set_qos(unistimsock, tos, cos, "UNISTIM");
ast_netsock_set_qos(unistimsock, qos.tos, qos.cos, "UNISTIM");
}
return 0;
}
@ -5552,7 +5556,7 @@ static int unistim_set_rtp_peer(struct ast_channel *chan, struct ast_rtp *rtp,
}
static struct ast_rtp_protocol unistim_rtp = {
.type = type,
.type = channel_type,
.get_rtp_info = unistim_get_rtp_peer,
.get_vrtp_info = unistim_get_vrtp_peer,
.set_rtp_peer = unistim_set_rtp_peer,
@ -5584,7 +5588,7 @@ int load_module(void)
/* Make sure we can register our unistim channel type */
if (ast_channel_register(&unistim_tech)) {
ast_log(LOG_ERROR, "Unable to register channel type '%s'\n", type);
ast_log(LOG_ERROR, "Unable to register channel type '%s'\n", channel_type);
goto chanreg_failed;
}

View File

@ -224,7 +224,7 @@ static struct iax2_ie {
int ie;
char *name;
void (*dump)(char *output, int maxlen, void *value, int len);
} ies[] = {
} infoelts[] = {
{ IAX_IE_CALLED_NUMBER, "CALLED NUMBER", dump_string },
{ IAX_IE_CALLING_NUMBER, "CALLING NUMBER", dump_string },
{ IAX_IE_CALLING_ANI, "ANI", dump_string },
@ -302,9 +302,9 @@ static struct iax2_ie prov_ies[] = {
const char *iax_ie2str(int ie)
{
int x;
for (x=0;x<(int)sizeof(ies) / (int)sizeof(ies[0]); x++) {
if (ies[x].ie == ie)
return ies[x].name;
for (x = 0; x < ARRAY_LEN(infoelts); x++) {
if (infoelts[x].ie == ie)
return infoelts[x].name;
}
return "Unknown IE";
}
@ -381,18 +381,18 @@ static void dump_ies(unsigned char *iedata, int len)
return;
}
found = 0;
for (x=0;x<(int)sizeof(ies) / (int)sizeof(ies[0]); x++) {
if (ies[x].ie == ie) {
if (ies[x].dump) {
ies[x].dump(interp, (int)sizeof(interp), iedata + 2, ielen);
snprintf(tmp, (int)sizeof(tmp), " %-15.15s : %s\n", ies[x].name, interp);
for (x = 0; x < ARRAY_LEN(infoelts); x++) {
if (infoelts[x].ie == ie) {
if (infoelts[x].dump) {
infoelts[x].dump(interp, (int)sizeof(interp), iedata + 2, ielen);
snprintf(tmp, (int)sizeof(tmp), " %-15.15s : %s\n", infoelts[x].name, interp);
outputf(tmp);
} else {
if (ielen)
snprintf(interp, (int)sizeof(interp), "%d bytes", ielen);
else
strcpy(interp, "Present");
snprintf(tmp, (int)sizeof(tmp), " %-15.15s : %s\n", ies[x].name, interp);
snprintf(tmp, (int)sizeof(tmp), " %-15.15s : %s\n", infoelts[x].name, interp);
outputf(tmp);
}
found++;
@ -410,7 +410,7 @@ static void dump_ies(unsigned char *iedata, int len)
void iax_showframe(struct iax_frame *f, struct ast_iax2_full_hdr *fhi, int rx, struct sockaddr_in *sin, int datalen)
{
const char *frames[] = {
const char *framelist[] = {
"(0?)",
"DTMF_E ",
"VOICE ",
@ -523,11 +523,11 @@ void iax_showframe(struct iax_frame *f, struct ast_iax2_full_hdr *fhi, int rx, s
/* Don't mess with mini-frames */
return;
}
if (fh->type >= (int)sizeof(frames)/(int)sizeof(frames[0])) {
if (fh->type >= ARRAY_LEN(framelist)) {
snprintf(class2, sizeof(class2), "(%d?)", fh->type);
class = class2;
} else {
class = frames[(int)fh->type];
class = framelist[(int)fh->type];
}
if (fh->type == AST_FRAME_DTMF_BEGIN || fh->type == AST_FRAME_DTMF_END) {
sprintf(subclass2, "%c", fh->csub);
@ -926,9 +926,9 @@ int iax_parse_ies(struct iax_ies *ies, unsigned char *data, int datalen)
/* Existing variable or new variable? */
for (var2 = ies->vars, prev = NULL; var2; prev = var2, var2 = var2->next) {
if (strcmp(tmp, var2->name) == 0) {
int len = strlen(var2->value) + strlen(tmp2) + 1;
char *tmp3 = alloca(len);
snprintf(tmp3, len, "%s%s", var2->value, tmp2);
int length = strlen(var2->value) + strlen(tmp2) + 1;
char *tmp3 = alloca(length);
snprintf(tmp3, length, "%s%s", var2->value, tmp2);
var = ast_variable_new(tmp, tmp3, var2->file);
var->next = var2->next;
if (prev)
@ -1103,13 +1103,13 @@ void iax_frame_free(struct iax_frame *fr)
#if !defined(LOW_MEMORY)
static void frame_cache_cleanup(void *data)
{
struct iax_frames *frames = data;
struct iax_frame *cur;
struct iax_frames *framelist = data;
struct iax_frame *current;
while ((cur = AST_LIST_REMOVE_HEAD(&frames->list, list)))
ast_free(cur);
while ((current = AST_LIST_REMOVE_HEAD(&framelist->list, list)))
ast_free(current);
ast_free(frames);
ast_free(framelist);
}
#endif

View File

@ -76,13 +76,13 @@ static int ppdrvdev=0;
/*
Trace Routines
*/
void strace(i16 point, t_sdbg *sdbg, i16 index, i16 value)
void strace(i16 point, t_sdbg *sdbg, i16 idx, i16 value)
{
// make dbg_trace buffer in structure
if(!sdbg->mode || sdbg->point[point]<0){
return;
} else {
sdbg->buffer[(index*XPMR_DEBUG_CHANS) + sdbg->point[point]] = value;
sdbg->buffer[(idx*XPMR_DEBUG_CHANS) + sdbg->point[point]] = value;
}
}
/*
@ -268,8 +268,8 @@ i16 code_string_parse(t_pmr_chan *pChan)
// Do Receive Codes String
for(i=0;i<pChan->numrxcodes;i++)
{
i16 ii,ri,ti;
float f;
i16 ri,_ti;
float _f;
p=pChan->pStr=pChan->pRxCode[i];
@ -277,32 +277,33 @@ i16 code_string_parse(t_pmr_chan *pChan)
if(!xpmrx(pChan,XXO_LSDCODEPARSE_1))
#endif
{
sscanf(p,"%f",&f);
ri=CtcssFreqIndex(f);
sscanf(p,"%f",&_f);
ri=CtcssFreqIndex(_f);
if(ri>maxctcssindex)maxctcssindex=ri;
sscanf(pChan->pTxCode[i],"%f",&f);
ti=CtcssFreqIndex(f);
if(f>maxctcsstxfreq)maxctcsstxfreq=f;
sscanf(pChan->pTxCode[i],"%f",&_f);
_ti=CtcssFreqIndex(_f);
if(_f>maxctcsstxfreq)maxctcsstxfreq=_f;
if(ri>CTCSS_NULL && ti>CTCSS_NULL)
if(ri>CTCSS_NULL && _ti>CTCSS_NULL)
{
pChan->b.ctcssRxEnable=pChan->b.ctcssTxEnable=1;
pChan->rxCtcssMap[ri]=ti;
pChan->rxCtcssMap[ri]=_ti;
pChan->numrxctcssfreqs++;
TRACEF(1,("pChan->rxctcss[%i]=%s pChan->rxCtcssMap[%i]=%i\n",i,pChan->rxctcss[i],ri,ti));
TRACEF(1,("pChan->rxctcss[%i]=%s pChan->rxCtcssMap[%i]=%i\n",i,pChan->rxctcss[i],ri,_ti));
}
else if(ri>CTCSS_NULL && f==0)
else if(ri>CTCSS_NULL && _f==0)
{
pChan->b.ctcssRxEnable=1;
pChan->rxCtcssMap[ri]=CTCSS_RXONLY;
pChan->numrxctcssfreqs++;
TRACEF(1,("pChan->rxctcss[%i]=%s pChan->rxCtcssMap[%i]=%i RXONLY\n",i,pChan->rxctcss[i],ri,ti));
TRACEF(1,("pChan->rxctcss[%i]=%s pChan->rxCtcssMap[%i]=%i RXONLY\n",i,pChan->rxctcss[i],ri,_ti));
}
else
{
i16 _ii;
pChan->numrxctcssfreqs=0;
for(ii=0;ii<CTCSS_NUM_CODES;ii++) pChan->rxCtcssMap[ii]=CTCSS_NULL;
for(_ii=0;_ii<CTCSS_NUM_CODES;_ii++) pChan->rxCtcssMap[_ii]=CTCSS_NULL;
TRACEF(1,("WARNING: Invalid Channel code detected and ignored. %i %s %s \n",i,pChan->pRxCode[i],pChan->pTxCode[i]));
}
}
@ -825,7 +826,7 @@ i16 gp_diff(t_pmr_sps *mySps)
i32 i;
i32 temp0,temp1;
i16 x0;
i32 y0;
i32 _y0;
i16 a0,a1;
i16 b0;
i16 *coef;
@ -855,12 +856,12 @@ i16 gp_diff(t_pmr_sps *mySps)
temp0 = x0 * a1;
x0 = input[i];
temp1 = input[i] * a0;
y0 = (temp0 + temp1)/calcAdjust;
y0 =(y0*outputGain)/M_Q8;
_y0 = (temp0 + temp1)/calcAdjust;
_y0 = (_y0*outputGain)/M_Q8;
if(y0>32766)y0=32766;
else if(y0<-32766)y0=-32766;
output[i]=y0;
if(_y0>32766)_y0=32766;
else if(_y0<-32766)_y0=-32766;
output[i]=_y0;
}
x[0]=x0;

View File

@ -334,12 +334,12 @@ static void drop_translator(int dst, int src)
static void unregister_translators(void)
{
struct translator *cur;
struct translator *current;
AST_LIST_LOCK(&translators);
while ((cur = AST_LIST_REMOVE_HEAD(&translators, entry))) {
ast_unregister_translator(&cur->t);
ast_free(cur);
while ((current = AST_LIST_REMOVE_HEAD(&translators, entry))) {
ast_unregister_translator(&current->t);
ast_free(current);
}
AST_LIST_UNLOCK(&translators);
}