|
|
@ -163,7 +163,8 @@ static int iaxdefaulttimeout = 5; /* Default to wait no more than 5 seconds for
|
|
|
|
|
|
|
|
|
|
|
|
static int tos = 0;
|
|
|
|
static int tos = 0;
|
|
|
|
|
|
|
|
|
|
|
|
static int expirey = IAX_DEFAULT_REG_EXPIRE;
|
|
|
|
static int min_reg_expire;
|
|
|
|
|
|
|
|
static int max_reg_expire;
|
|
|
|
|
|
|
|
|
|
|
|
static int timingfd = -1; /* Timing file descriptor */
|
|
|
|
static int timingfd = -1; /* Timing file descriptor */
|
|
|
|
|
|
|
|
|
|
|
@ -311,8 +312,8 @@ struct iax2_peer {
|
|
|
|
char cid_num[AST_MAX_EXTENSION]; /* Default context (for transfer really) */
|
|
|
|
char cid_num[AST_MAX_EXTENSION]; /* Default context (for transfer really) */
|
|
|
|
char cid_name[AST_MAX_EXTENSION]; /* Default context (for transfer really) */
|
|
|
|
char cid_name[AST_MAX_EXTENSION]; /* Default context (for transfer really) */
|
|
|
|
|
|
|
|
|
|
|
|
int expire; /* Schedule entry for expirey */
|
|
|
|
int expire; /* Schedule entry for expiry */
|
|
|
|
int expirey; /* How soon to expire */
|
|
|
|
int expiry; /* How soon to expire */
|
|
|
|
int capability; /* Capability */
|
|
|
|
int capability; /* Capability */
|
|
|
|
char zonetag[80]; /* Time Zone */
|
|
|
|
char zonetag[80]; /* Time Zone */
|
|
|
|
|
|
|
|
|
|
|
@ -485,8 +486,8 @@ struct chan_iax2_pvt {
|
|
|
|
struct ast_channel *owner;
|
|
|
|
struct ast_channel *owner;
|
|
|
|
/* What's our state? */
|
|
|
|
/* What's our state? */
|
|
|
|
int state;
|
|
|
|
int state;
|
|
|
|
/* Expirey (optional) */
|
|
|
|
/* Expiry (optional) */
|
|
|
|
int expirey;
|
|
|
|
int expiry;
|
|
|
|
/* Next outgoing sequence number */
|
|
|
|
/* Next outgoing sequence number */
|
|
|
|
unsigned char oseqno;
|
|
|
|
unsigned char oseqno;
|
|
|
|
/* Next sequence number they have not yet acknowledged */
|
|
|
|
/* Next sequence number they have not yet acknowledged */
|
|
|
@ -625,7 +626,7 @@ static struct iax2_dpcache {
|
|
|
|
char peercontext[AST_MAX_CONTEXT];
|
|
|
|
char peercontext[AST_MAX_CONTEXT];
|
|
|
|
char exten[AST_MAX_EXTENSION];
|
|
|
|
char exten[AST_MAX_EXTENSION];
|
|
|
|
struct timeval orig;
|
|
|
|
struct timeval orig;
|
|
|
|
struct timeval expirey;
|
|
|
|
struct timeval expiry;
|
|
|
|
int flags;
|
|
|
|
int flags;
|
|
|
|
unsigned short callno;
|
|
|
|
unsigned short callno;
|
|
|
|
int waiters[256];
|
|
|
|
int waiters[256];
|
|
|
@ -1068,7 +1069,7 @@ static int find_callno(unsigned short callno, unsigned short dcallno, struct soc
|
|
|
|
iaxs[x]->peercallno = callno;
|
|
|
|
iaxs[x]->peercallno = callno;
|
|
|
|
iaxs[x]->callno = x;
|
|
|
|
iaxs[x]->callno = x;
|
|
|
|
iaxs[x]->pingtime = DEFAULT_RETRY_TIME;
|
|
|
|
iaxs[x]->pingtime = DEFAULT_RETRY_TIME;
|
|
|
|
iaxs[x]->expirey = expirey;
|
|
|
|
iaxs[x]->expiry = min_reg_expire;
|
|
|
|
iaxs[x]->pingid = ast_sched_add(sched, ping_time * 1000, send_ping, (void *)(long)x);
|
|
|
|
iaxs[x]->pingid = ast_sched_add(sched, ping_time * 1000, send_ping, (void *)(long)x);
|
|
|
|
iaxs[x]->lagid = ast_sched_add(sched, lagrq_time * 1000, send_lagrq, (void *)(long)x);
|
|
|
|
iaxs[x]->lagid = ast_sched_add(sched, lagrq_time * 1000, send_lagrq, (void *)(long)x);
|
|
|
|
iaxs[x]->amaflags = amaflags;
|
|
|
|
iaxs[x]->amaflags = amaflags;
|
|
|
@ -1981,7 +1982,7 @@ static int iax2_show_cache(int fd, int argc, char *argv[])
|
|
|
|
dp = dpcache;
|
|
|
|
dp = dpcache;
|
|
|
|
ast_cli(fd, "%-20.20s %-12.12s %-9.9s %-8.8s %s\n", "Peer/Context", "Exten", "Exp.", "Wait.", "Flags");
|
|
|
|
ast_cli(fd, "%-20.20s %-12.12s %-9.9s %-8.8s %s\n", "Peer/Context", "Exten", "Exp.", "Wait.", "Flags");
|
|
|
|
while(dp) {
|
|
|
|
while(dp) {
|
|
|
|
s = dp->expirey.tv_sec - tv.tv_sec;
|
|
|
|
s = dp->expiry.tv_sec - tv.tv_sec;
|
|
|
|
tmp[0] = '\0';
|
|
|
|
tmp[0] = '\0';
|
|
|
|
if (dp->flags & CACHE_FLAG_EXISTS)
|
|
|
|
if (dp->flags & CACHE_FLAG_EXISTS)
|
|
|
|
strncat(tmp, "EXISTS|", sizeof(tmp) - strlen(tmp) - 1);
|
|
|
|
strncat(tmp, "EXISTS|", sizeof(tmp) - strlen(tmp) - 1);
|
|
|
@ -5056,9 +5057,9 @@ static int register_verify(int callno, struct sockaddr_in *sin, struct iax_ies *
|
|
|
|
return -1;
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
ast_copy_string(iaxs[callno]->peer, peer, sizeof(iaxs[callno]->peer));
|
|
|
|
ast_copy_string(iaxs[callno]->peer, peer, sizeof(iaxs[callno]->peer));
|
|
|
|
/* Choose lowest expirey number */
|
|
|
|
/* Choose lowest expiry number */
|
|
|
|
if (expire && (expire < iaxs[callno]->expirey))
|
|
|
|
if (expire && (expire < iaxs[callno]->expiry))
|
|
|
|
iaxs[callno]->expirey = expire;
|
|
|
|
iaxs[callno]->expiry = expire;
|
|
|
|
|
|
|
|
|
|
|
|
ast_device_state_changed("IAX2/%s", p->name); /* Activate notification */
|
|
|
|
ast_device_state_changed("IAX2/%s", p->name); /* Activate notification */
|
|
|
|
|
|
|
|
|
|
|
@ -5216,7 +5217,7 @@ static int complete_dpreply(struct chan_iax2_pvt *pvt, struct iax_ies *ies)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
char exten[256] = "";
|
|
|
|
char exten[256] = "";
|
|
|
|
int status = CACHE_FLAG_UNKNOWN;
|
|
|
|
int status = CACHE_FLAG_UNKNOWN;
|
|
|
|
int expirey = iaxdefaultdpcache;
|
|
|
|
int expiry = iaxdefaultdpcache;
|
|
|
|
int x;
|
|
|
|
int x;
|
|
|
|
int matchmore = 0;
|
|
|
|
int matchmore = 0;
|
|
|
|
struct iax2_dpcache *dp, *prev;
|
|
|
|
struct iax2_dpcache *dp, *prev;
|
|
|
@ -5235,7 +5236,7 @@ static int complete_dpreply(struct chan_iax2_pvt *pvt, struct iax_ies *ies)
|
|
|
|
/* Don't really do anything with this */
|
|
|
|
/* Don't really do anything with this */
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (ies->refresh)
|
|
|
|
if (ies->refresh)
|
|
|
|
expirey = ies->refresh;
|
|
|
|
expiry = ies->refresh;
|
|
|
|
if (ies->dpstatus & IAX_DPSTATUS_MATCHMORE)
|
|
|
|
if (ies->dpstatus & IAX_DPSTATUS_MATCHMORE)
|
|
|
|
matchmore = CACHE_FLAG_MATCHMORE;
|
|
|
|
matchmore = CACHE_FLAG_MATCHMORE;
|
|
|
|
ast_mutex_lock(&dpcache_lock);
|
|
|
|
ast_mutex_lock(&dpcache_lock);
|
|
|
@ -5250,7 +5251,7 @@ static int complete_dpreply(struct chan_iax2_pvt *pvt, struct iax_ies *ies)
|
|
|
|
pvt->dpentries = dp->peer;
|
|
|
|
pvt->dpentries = dp->peer;
|
|
|
|
dp->peer = NULL;
|
|
|
|
dp->peer = NULL;
|
|
|
|
dp->callno = 0;
|
|
|
|
dp->callno = 0;
|
|
|
|
dp->expirey.tv_sec = dp->orig.tv_sec + expirey;
|
|
|
|
dp->expiry.tv_sec = dp->orig.tv_sec + expiry;
|
|
|
|
if (dp->flags & CACHE_FLAG_PENDING) {
|
|
|
|
if (dp->flags & CACHE_FLAG_PENDING) {
|
|
|
|
dp->flags &= ~CACHE_FLAG_PENDING;
|
|
|
|
dp->flags &= ~CACHE_FLAG_PENDING;
|
|
|
|
dp->flags |= status;
|
|
|
|
dp->flags |= status;
|
|
|
@ -5352,7 +5353,7 @@ static int iax2_ack_registry(struct iax_ies *ies, struct sockaddr_in *sin, int c
|
|
|
|
}
|
|
|
|
}
|
|
|
|
reg = iaxs[callno]->reg;
|
|
|
|
reg = iaxs[callno]->reg;
|
|
|
|
if (!reg) {
|
|
|
|
if (!reg) {
|
|
|
|
ast_log(LOG_WARNING, "Registry acknowledge on unknown registery '%s'\n", peer);
|
|
|
|
ast_log(LOG_WARNING, "Registry acknowledge on unknown registry '%s'\n", peer);
|
|
|
|
return -1;
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
memcpy(&oldus, ®->us, sizeof(oldus));
|
|
|
|
memcpy(&oldus, ®->us, sizeof(oldus));
|
|
|
@ -5363,13 +5364,13 @@ static int iax2_ack_registry(struct iax_ies *ies, struct sockaddr_in *sin, int c
|
|
|
|
}
|
|
|
|
}
|
|
|
|
memcpy(®->us, &us, sizeof(reg->us));
|
|
|
|
memcpy(®->us, &us, sizeof(reg->us));
|
|
|
|
reg->messages = ies->msgcount;
|
|
|
|
reg->messages = ies->msgcount;
|
|
|
|
if (refresh && (reg->refresh > refresh)) {
|
|
|
|
/* always refresh the registration at the interval requested by the server
|
|
|
|
/* Refresh faster if necessary */
|
|
|
|
we are registering to
|
|
|
|
|
|
|
|
*/
|
|
|
|
reg->refresh = refresh;
|
|
|
|
reg->refresh = refresh;
|
|
|
|
if (reg->expire > -1)
|
|
|
|
if (reg->expire > -1)
|
|
|
|
ast_sched_del(sched, reg->expire);
|
|
|
|
ast_sched_del(sched, reg->expire);
|
|
|
|
reg->expire = ast_sched_add(sched, (5 * reg->refresh / 6) * 1000, iax2_do_register_s, reg);
|
|
|
|
reg->expire = ast_sched_add(sched, (5 * reg->refresh / 6) * 1000, iax2_do_register_s, reg);
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((inaddrcmp(&oldus, ®->us) || (reg->messages != oldmsgs)) && (option_verbose > 2)) {
|
|
|
|
if ((inaddrcmp(&oldus, ®->us) || (reg->messages != oldmsgs)) && (option_verbose > 2)) {
|
|
|
|
if (reg->messages > 65534)
|
|
|
|
if (reg->messages > 65534)
|
|
|
|
snprintf(msgstatus, sizeof(msgstatus), " with message(s) waiting\n");
|
|
|
|
snprintf(msgstatus, sizeof(msgstatus), " with message(s) waiting\n");
|
|
|
@ -5468,8 +5469,8 @@ static int expire_registry(void *data)
|
|
|
|
memset(&p->addr, 0, sizeof(p->addr));
|
|
|
|
memset(&p->addr, 0, sizeof(p->addr));
|
|
|
|
/* Reset expire notice */
|
|
|
|
/* Reset expire notice */
|
|
|
|
p->expire = -1;
|
|
|
|
p->expire = -1;
|
|
|
|
/* Reset expirey value */
|
|
|
|
/* Reset expiry value */
|
|
|
|
p->expirey = expirey;
|
|
|
|
p->expiry = min_reg_expire;
|
|
|
|
if (!ast_test_flag(p, IAX_TEMPONLY))
|
|
|
|
if (!ast_test_flag(p, IAX_TEMPONLY))
|
|
|
|
ast_db_del("IAX/Registry", p->name);
|
|
|
|
ast_db_del("IAX/Registry", p->name);
|
|
|
|
register_peer_exten(p, 0);
|
|
|
|
register_peer_exten(p, 0);
|
|
|
@ -5508,7 +5509,7 @@ static void reg_source_db(struct iax2_peer *p)
|
|
|
|
ast_verbose(VERBOSE_PREFIX_3 "Seeding '%s' at %s:%d for %d\n", p->name,
|
|
|
|
ast_verbose(VERBOSE_PREFIX_3 "Seeding '%s' at %s:%d for %d\n", p->name,
|
|
|
|
ast_inet_ntoa(iabuf, sizeof(iabuf), in), atoi(c), atoi(d));
|
|
|
|
ast_inet_ntoa(iabuf, sizeof(iabuf), in), atoi(c), atoi(d));
|
|
|
|
iax2_poke_peer(p, 0);
|
|
|
|
iax2_poke_peer(p, 0);
|
|
|
|
p->expirey = atoi(d);
|
|
|
|
p->expiry = atoi(d);
|
|
|
|
memset(&p->addr, 0, sizeof(p->addr));
|
|
|
|
memset(&p->addr, 0, sizeof(p->addr));
|
|
|
|
p->addr.sin_family = AF_INET;
|
|
|
|
p->addr.sin_family = AF_INET;
|
|
|
|
p->addr.sin_addr = in;
|
|
|
|
p->addr.sin_addr = in;
|
|
|
@ -5516,7 +5517,7 @@ static void reg_source_db(struct iax2_peer *p)
|
|
|
|
if (p->expire > -1)
|
|
|
|
if (p->expire > -1)
|
|
|
|
ast_sched_del(sched, p->expire);
|
|
|
|
ast_sched_del(sched, p->expire);
|
|
|
|
ast_device_state_changed("IAX2/%s", p->name); /* Activate notification */
|
|
|
|
ast_device_state_changed("IAX2/%s", p->name); /* Activate notification */
|
|
|
|
p->expire = ast_sched_add(sched, (p->expirey + 10) * 1000, expire_registry, (void *)p);
|
|
|
|
p->expire = ast_sched_add(sched, (p->expiry + 10) * 1000, expire_registry, (void *)p);
|
|
|
|
if (iax2_regfunk)
|
|
|
|
if (iax2_regfunk)
|
|
|
|
iax2_regfunk(p->name, 1);
|
|
|
|
iax2_regfunk(p->name, 1);
|
|
|
|
register_peer_exten(p, 1);
|
|
|
|
register_peer_exten(p, 1);
|
|
|
@ -5527,7 +5528,7 @@ static void reg_source_db(struct iax2_peer *p)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int update_registry(char *name, struct sockaddr_in *sin, int callno, char *devtype, int fd)
|
|
|
|
static int update_registry(char *name, struct sockaddr_in *sin, int callno, char *devtype, int fd, unsigned short refresh)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
/* Called from IAX thread only, with proper iaxsl lock */
|
|
|
|
/* Called from IAX thread only, with proper iaxsl lock */
|
|
|
|
struct iax_ie_data ied;
|
|
|
|
struct iax_ie_data ied;
|
|
|
@ -5536,15 +5537,20 @@ static int update_registry(char *name, struct sockaddr_in *sin, int callno, char
|
|
|
|
char data[80];
|
|
|
|
char data[80];
|
|
|
|
char iabuf[INET_ADDRSTRLEN];
|
|
|
|
char iabuf[INET_ADDRSTRLEN];
|
|
|
|
int version;
|
|
|
|
int version;
|
|
|
|
|
|
|
|
|
|
|
|
memset(&ied, 0, sizeof(ied));
|
|
|
|
memset(&ied, 0, sizeof(ied));
|
|
|
|
p = find_peer(name, 1);
|
|
|
|
|
|
|
|
if (p) {
|
|
|
|
if (!(p = find_peer(name, 1))) {
|
|
|
|
|
|
|
|
ast_log(LOG_WARNING, "No such peer '%s'\n", name);
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (ast_test_flag((&globalflags), IAX_RTUPDATE) && (ast_test_flag(p, IAX_TEMPONLY|IAX_RTCACHEFRIENDS)))
|
|
|
|
if (ast_test_flag((&globalflags), IAX_RTUPDATE) && (ast_test_flag(p, IAX_TEMPONLY|IAX_RTCACHEFRIENDS)))
|
|
|
|
realtime_update_peer(name, sin);
|
|
|
|
realtime_update_peer(name, sin);
|
|
|
|
if (inaddrcmp(&p->addr, sin)) {
|
|
|
|
if (inaddrcmp(&p->addr, sin)) {
|
|
|
|
if (iax2_regfunk)
|
|
|
|
if (iax2_regfunk)
|
|
|
|
iax2_regfunk(p->name, 1);
|
|
|
|
iax2_regfunk(p->name, 1);
|
|
|
|
snprintf(data, sizeof(data), "%s:%d:%d", ast_inet_ntoa(iabuf, sizeof(iabuf), sin->sin_addr), ntohs(sin->sin_port), p->expirey);
|
|
|
|
snprintf(data, sizeof(data), "%s:%d:%d", ast_inet_ntoa(iabuf, sizeof(iabuf), sin->sin_addr), ntohs(sin->sin_port), p->expiry);
|
|
|
|
if (!ast_test_flag(p, IAX_TEMPONLY) && sin->sin_addr.s_addr) {
|
|
|
|
if (!ast_test_flag(p, IAX_TEMPONLY) && sin->sin_addr.s_addr) {
|
|
|
|
ast_db_put("IAX/Registry", p->name, data);
|
|
|
|
ast_db_put("IAX/Registry", p->name, data);
|
|
|
|
if (option_verbose > 2)
|
|
|
|
if (option_verbose > 2)
|
|
|
@ -5569,15 +5575,26 @@ static int update_registry(char *name, struct sockaddr_in *sin, int callno, char
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/* Store socket fd */
|
|
|
|
/* Store socket fd */
|
|
|
|
p->sockfd = fd;
|
|
|
|
p->sockfd = fd;
|
|
|
|
/* Setup the expirey */
|
|
|
|
/* Setup the expiry */
|
|
|
|
if (p->expire > -1)
|
|
|
|
if (p->expire > -1)
|
|
|
|
ast_sched_del(sched, p->expire);
|
|
|
|
ast_sched_del(sched, p->expire);
|
|
|
|
if (p->expirey && sin->sin_addr.s_addr)
|
|
|
|
if (refresh > max_reg_expire) {
|
|
|
|
p->expire = ast_sched_add(sched, (p->expirey + 10) * 1000, expire_registry, (void *)p);
|
|
|
|
ast_log(LOG_NOTICE, "Restricting registration for peer '%s' to %d seconds (requested %d)\n",
|
|
|
|
|
|
|
|
p->name, max_reg_expire, refresh);
|
|
|
|
|
|
|
|
p->expiry = max_reg_expire;
|
|
|
|
|
|
|
|
} else if (refresh < min_reg_expire) {
|
|
|
|
|
|
|
|
ast_log(LOG_NOTICE, "Restricting registration for peer '%s' to %d seconds (requested %d)\n",
|
|
|
|
|
|
|
|
p->name, min_reg_expire, refresh);
|
|
|
|
|
|
|
|
p->expiry = min_reg_expire;
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
p->expiry = refresh;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (p->expiry && sin->sin_addr.s_addr)
|
|
|
|
|
|
|
|
p->expire = ast_sched_add(sched, (p->expiry + 10) * 1000, expire_registry, (void *)p);
|
|
|
|
iax_ie_append_str(&ied, IAX_IE_USERNAME, p->name);
|
|
|
|
iax_ie_append_str(&ied, IAX_IE_USERNAME, p->name);
|
|
|
|
iax_ie_append_int(&ied, IAX_IE_DATETIME, iax2_datetime(p->zonetag));
|
|
|
|
iax_ie_append_int(&ied, IAX_IE_DATETIME, iax2_datetime(p->zonetag));
|
|
|
|
if (sin->sin_addr.s_addr) {
|
|
|
|
if (sin->sin_addr.s_addr) {
|
|
|
|
iax_ie_append_short(&ied, IAX_IE_REFRESH, p->expirey);
|
|
|
|
iax_ie_append_short(&ied, IAX_IE_REFRESH, p->expiry);
|
|
|
|
iax_ie_append_addr(&ied, IAX_IE_APPARENT_ADDR, &p->addr);
|
|
|
|
iax_ie_append_addr(&ied, IAX_IE_APPARENT_ADDR, &p->addr);
|
|
|
|
if (!ast_strlen_zero(p->mailbox)) {
|
|
|
|
if (!ast_strlen_zero(p->mailbox)) {
|
|
|
|
if (ast_test_flag(p, IAX_MESSAGEDETAIL)) {
|
|
|
|
if (ast_test_flag(p, IAX_MESSAGEDETAIL)) {
|
|
|
@ -5606,9 +5623,6 @@ static int update_registry(char *name, struct sockaddr_in *sin, int callno, char
|
|
|
|
if (ast_test_flag(p, IAX_TEMPONLY))
|
|
|
|
if (ast_test_flag(p, IAX_TEMPONLY))
|
|
|
|
destroy_peer(p);
|
|
|
|
destroy_peer(p);
|
|
|
|
return send_command_final(iaxs[callno], AST_FRAME_IAX, IAX_COMMAND_REGACK, 0, ied.buf, ied.pos, -1);
|
|
|
|
return send_command_final(iaxs[callno], AST_FRAME_IAX, IAX_COMMAND_REGACK, 0, ied.buf, ied.pos, -1);
|
|
|
|
}
|
|
|
|
|
|
|
|
ast_log(LOG_WARNING, "No such peer '%s'\n", name);
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int registry_authrequest(char *name, int callno)
|
|
|
|
static int registry_authrequest(char *name, int callno)
|
|
|
@ -7268,7 +7282,7 @@ retryowner2:
|
|
|
|
if ((ast_strlen_zero(iaxs[fr.callno]->secret) && ast_strlen_zero(iaxs[fr.callno]->inkeys)) || (iaxs[fr.callno]->state & IAX_STATE_AUTHENTICATED)) {
|
|
|
|
if ((ast_strlen_zero(iaxs[fr.callno]->secret) && ast_strlen_zero(iaxs[fr.callno]->inkeys)) || (iaxs[fr.callno]->state & IAX_STATE_AUTHENTICATED)) {
|
|
|
|
if (f.subclass == IAX_COMMAND_REGREL)
|
|
|
|
if (f.subclass == IAX_COMMAND_REGREL)
|
|
|
|
memset(&sin, 0, sizeof(sin));
|
|
|
|
memset(&sin, 0, sizeof(sin));
|
|
|
|
if (update_registry(iaxs[fr.callno]->peer, &sin, fr.callno, ies.devicetype, fd))
|
|
|
|
if (update_registry(iaxs[fr.callno]->peer, &sin, fr.callno, ies.devicetype, fd, ies.refresh))
|
|
|
|
ast_log(LOG_WARNING, "Registry error\n");
|
|
|
|
ast_log(LOG_WARNING, "Registry error\n");
|
|
|
|
if (ies.provverpres && ies.serviceident && sin.sin_addr.s_addr)
|
|
|
|
if (ies.provverpres && ies.serviceident && sin.sin_addr.s_addr)
|
|
|
|
check_provisioning(&sin, fd, ies.serviceident, ies.provver);
|
|
|
|
check_provisioning(&sin, fd, ies.serviceident, ies.provver);
|
|
|
@ -8021,7 +8035,7 @@ static struct iax2_peer *build_peer(const char *name, struct ast_variable *v, in
|
|
|
|
if (!found) {
|
|
|
|
if (!found) {
|
|
|
|
ast_copy_string(peer->name, name, sizeof(peer->name));
|
|
|
|
ast_copy_string(peer->name, name, sizeof(peer->name));
|
|
|
|
peer->addr.sin_port = htons(IAX_DEFAULT_PORTNO);
|
|
|
|
peer->addr.sin_port = htons(IAX_DEFAULT_PORTNO);
|
|
|
|
peer->expirey = expirey;
|
|
|
|
peer->expiry = min_reg_expire;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
peer->prefs = prefs;
|
|
|
|
peer->prefs = prefs;
|
|
|
|
peer->capability = iax2_capability;
|
|
|
|
peer->capability = iax2_capability;
|
|
|
@ -8480,6 +8494,9 @@ static int set_config(char *config_file, int reload)
|
|
|
|
nochecksums = 0;
|
|
|
|
nochecksums = 0;
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
min_reg_expire = IAX_DEFAULT_REG_EXPIRE;
|
|
|
|
|
|
|
|
max_reg_expire = IAX_DEFAULT_REG_EXPIRE;
|
|
|
|
|
|
|
|
|
|
|
|
v = ast_variable_browse(cfg, "general");
|
|
|
|
v = ast_variable_browse(cfg, "general");
|
|
|
|
|
|
|
|
|
|
|
|
/* Seed initial tos value */
|
|
|
|
/* Seed initial tos value */
|
|
|
@ -8525,6 +8542,10 @@ static int set_config(char *config_file, int reload)
|
|
|
|
lagrq_time = atoi(v->value);
|
|
|
|
lagrq_time = atoi(v->value);
|
|
|
|
else if (!strcasecmp(v->name, "dropcount"))
|
|
|
|
else if (!strcasecmp(v->name, "dropcount"))
|
|
|
|
iax2_dropcount = atoi(v->value);
|
|
|
|
iax2_dropcount = atoi(v->value);
|
|
|
|
|
|
|
|
else if (!strcasecmp(v->name, "maxregexpire"))
|
|
|
|
|
|
|
|
max_reg_expire = atoi(v->value);
|
|
|
|
|
|
|
|
else if (!strcasecmp(v->name, "minregexpire"))
|
|
|
|
|
|
|
|
min_reg_expire = atoi(v->value);
|
|
|
|
else if (!strcasecmp(v->name, "bindaddr")) {
|
|
|
|
else if (!strcasecmp(v->name, "bindaddr")) {
|
|
|
|
if (reload) {
|
|
|
|
if (reload) {
|
|
|
|
ast_log(LOG_NOTICE, "Ignoring bindaddr on reload\n");
|
|
|
|
ast_log(LOG_NOTICE, "Ignoring bindaddr on reload\n");
|
|
|
@ -8635,6 +8656,11 @@ static int set_config(char *config_file, int reload)
|
|
|
|
/* ast_log(LOG_WARNING, "Ignoring %s\n", v->name); */
|
|
|
|
/* ast_log(LOG_WARNING, "Ignoring %s\n", v->name); */
|
|
|
|
v = v->next;
|
|
|
|
v = v->next;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (min_reg_expire > max_reg_expire) {
|
|
|
|
|
|
|
|
ast_log(LOG_WARNING, "Minimum registration interval of %d is more than maximum of %d, resetting minimum to %d\n",
|
|
|
|
|
|
|
|
min_reg_expire, max_reg_expire, max_reg_expire);
|
|
|
|
|
|
|
|
min_reg_expire = max_reg_expire;
|
|
|
|
|
|
|
|
}
|
|
|
|
iax2_capability = capability;
|
|
|
|
iax2_capability = capability;
|
|
|
|
cat = ast_category_browse(cfg, NULL);
|
|
|
|
cat = ast_category_browse(cfg, NULL);
|
|
|
|
while(cat) {
|
|
|
|
while(cat) {
|
|
|
@ -8797,7 +8823,7 @@ static struct iax2_dpcache *find_cache(struct ast_channel *chan, const char *dat
|
|
|
|
while(dp) {
|
|
|
|
while(dp) {
|
|
|
|
next = dp->next;
|
|
|
|
next = dp->next;
|
|
|
|
/* Expire old caches */
|
|
|
|
/* Expire old caches */
|
|
|
|
if (ast_tvcmp(tv, dp->expirey) > 0) {
|
|
|
|
if (ast_tvcmp(tv, dp->expiry) > 0) {
|
|
|
|
/* It's expired, let it disappear */
|
|
|
|
/* It's expired, let it disappear */
|
|
|
|
if (prev)
|
|
|
|
if (prev)
|
|
|
|
prev->next = dp->next;
|
|
|
|
prev->next = dp->next;
|
|
|
@ -8834,10 +8860,10 @@ static struct iax2_dpcache *find_cache(struct ast_channel *chan, const char *dat
|
|
|
|
memset(dp, 0, sizeof(struct iax2_dpcache));
|
|
|
|
memset(dp, 0, sizeof(struct iax2_dpcache));
|
|
|
|
ast_copy_string(dp->peercontext, data, sizeof(dp->peercontext));
|
|
|
|
ast_copy_string(dp->peercontext, data, sizeof(dp->peercontext));
|
|
|
|
ast_copy_string(dp->exten, exten, sizeof(dp->exten));
|
|
|
|
ast_copy_string(dp->exten, exten, sizeof(dp->exten));
|
|
|
|
gettimeofday(&dp->expirey, NULL);
|
|
|
|
gettimeofday(&dp->expiry, NULL);
|
|
|
|
dp->orig = dp->expirey;
|
|
|
|
dp->orig = dp->expiry;
|
|
|
|
/* Expires in 30 mins by default */
|
|
|
|
/* Expires in 30 mins by default */
|
|
|
|
dp->expirey.tv_sec += iaxdefaultdpcache;
|
|
|
|
dp->expiry.tv_sec += iaxdefaultdpcache;
|
|
|
|
dp->next = dpcache;
|
|
|
|
dp->next = dpcache;
|
|
|
|
dp->flags = CACHE_FLAG_PENDING;
|
|
|
|
dp->flags = CACHE_FLAG_PENDING;
|
|
|
|
for (x=0;x<sizeof(dp->waiters) / sizeof(dp->waiters[0]); x++)
|
|
|
|
for (x=0;x<sizeof(dp->waiters) / sizeof(dp->waiters[0]); x++)
|
|
|
@ -8915,7 +8941,7 @@ static struct iax2_dpcache *find_cache(struct ast_channel *chan, const char *dat
|
|
|
|
dp->flags |= CACHE_FLAG_TIMEOUT;
|
|
|
|
dp->flags |= CACHE_FLAG_TIMEOUT;
|
|
|
|
/* Expire after only 60 seconds now. This is designed to help reduce backlog in heavily loaded
|
|
|
|
/* Expire after only 60 seconds now. This is designed to help reduce backlog in heavily loaded
|
|
|
|
systems without leaving it unavailable once the server comes back online */
|
|
|
|
systems without leaving it unavailable once the server comes back online */
|
|
|
|
dp->expirey.tv_sec = dp->orig.tv_sec + 60;
|
|
|
|
dp->expiry.tv_sec = dp->orig.tv_sec + 60;
|
|
|
|
for (x=0;x<sizeof(dp->waiters) / sizeof(dp->waiters[0]); x++)
|
|
|
|
for (x=0;x<sizeof(dp->waiters) / sizeof(dp->waiters[0]); x++)
|
|
|
|
if (dp->waiters[x] > -1)
|
|
|
|
if (dp->waiters[x] > -1)
|
|
|
|
write(dp->waiters[x], "asdf", 4);
|
|
|
|
write(dp->waiters[x], "asdf", 4);
|
|
|
|