p->expire = -1;
/* Reset expirey value */
p->expirey = expirey;
- ast_db_del("IAX2/Registry", p->name);
+ ast_db_del("IAX/Registry", p->name);
if (iax2_regfunk)
iax2_regfunk(p->name, 0);
return 0;
char data[80];
struct in_addr in;
char *c, *d;
- if (!ast_db_get("IAX2/Registry", p->name, data, sizeof(data))) {
+ if (!ast_db_get("IAX/Registry", p->name, data, sizeof(data))) {
c = strchr(data, ':');
if (c) {
*c = '\0';
if (p->expire > -1)
ast_sched_del(sched, p->expire);
p->expire = ast_sched_add(sched, p->expirey * 1000, expire_registry, (void *)p);
+ if (iax2_regfunk)
+ iax2_regfunk(p->name, 1);
}
}
if (iax2_regfunk)
iax2_regfunk(p->name, 1);
snprintf(data, sizeof(data), "%s:%d:%d", inet_ntoa(sin->sin_addr), ntohs(sin->sin_port), p->expirey);
- ast_db_put("IAX2/Registry", p->name, data);
+ ast_db_put("IAX/Registry", p->name, data);
if (option_verbose > 2)
ast_verbose(VERBOSE_PREFIX_3 "Registered '%s' (%s) at %s:%d\n", p->name,
iaxs[callno]->state & IAX_STATE_AUTHENTICATED ? "AUTHENTICATED" : "UNAUTHENTICATED", inet_ntoa(sin->sin_addr), ntohs(sin->sin_port));
#include <asterisk/parking.h>
#include <asterisk/acl.h>
#include <asterisk/srv.h>
+#include <asterisk/astdb.h>
#include <sys/socket.h>
#include <sys/ioctl.h>
#include <net/if.h>
{
struct sip_peer *p = data;
memset(&p->addr, 0, sizeof(p->addr));
+ ast_db_del("SIP/Registry", p->name);
p->expire = -1;
ast_device_state_changed("SIP/%s", p->name);
return 0;
static int sip_poke_peer(struct sip_peer *peer);
+static void reg_source_db(struct sip_peer *p)
+{
+ char data[80];
+ struct in_addr in;
+ char *c, *d;
+ int expiry;
+ if (!ast_db_get("SIP/Registry", p->name, data, sizeof(data))) {
+ c = strchr(data, ':');
+ if (c) {
+ *c = '\0';
+ c++;
+ if (inet_aton(data, &in)) {
+ d = strchr(c, ':');
+ if (d) {
+ *d = '\0';
+ d++;
+ ast_verbose(VERBOSE_PREFIX_3 "SIP Seeding '%s' at %s:%d for %d\n", p->name,
+ inet_ntoa(in), atoi(c), atoi(d));
+ sip_poke_peer(p);
+ expiry = atoi(d);
+ memset(&p->addr, 0, sizeof(p->addr));
+ p->addr.sin_family = AF_INET;
+ p->addr.sin_addr = in;
+ p->addr.sin_port = htons(atoi(c));
+ if (p->expire > -1)
+ ast_sched_del(sched, p->expire);
+ p->expire = ast_sched_add(sched, (expiry + 10) * 1000, expire_register, (void *)p);
+ }
+
+ }
+ }
+ }
+}
+
static int parse_contact(struct sip_pvt *pvt, struct sip_peer *p, struct sip_request *req)
{
char contact[80]= "";
+ char data[256];
char *expires = get_header(req, "Expires");
int expiry = atoi(expires);
char *c, *n, *pt;
ast_sched_del(sched, p->expire);
p->expire = -1;
if (option_verbose > 2)
- ast_verbose(VERBOSE_PREFIX_3 "Unregistered SIP '%s'\n", p->username);
+ ast_verbose(VERBOSE_PREFIX_3 "Unregistered SIP '%s'\n", p->name);
return 0;
}
/* Make sure it's a SIP URL */
pvt->expiry = expiry;
if (inaddrcmp(&p->addr, &oldsin)) {
sip_poke_peer(p);
+ snprintf(data, sizeof(data), "%s:%d:%d", inet_ntoa(p->addr.sin_addr), ntohs(p->addr.sin_port), expiry);
+ ast_db_put("SIP/Registry", p->name, data);
if (option_verbose > 2)
- ast_verbose(VERBOSE_PREFIX_3 "Registered SIP '%s' at %s port %d expires %d\n", p->username, inet_ntoa(p->addr.sin_addr), ntohs(p->addr.sin_port), expiry);
+ ast_verbose(VERBOSE_PREFIX_3 "Registered SIP '%s' at %s port %d expires %d\n", p->name, inet_ntoa(p->addr.sin_addr), ntohs(p->addr.sin_port), expiry);
}
return 0;
}
}
if (!strlen(peer->methods))
strcpy(peer->methods, "md5,plaintext");
+ if (!found && peer->dynamic)
+ reg_source_db(peer);
peer->delme = 0;
}
return peer;
int res;
struct sip_peer *peer;
struct sip_registry *reg;
+ sched = sched_context_create();
+ if (!sched) {
+ ast_log(LOG_WARNING, "Unable to create schedule context\n");
+ }
+ io = io_context_create();
+ if (!io) {
+ ast_log(LOG_WARNING, "Unable to create I/O context\n");
+ }
+
res = reload_config();
if (!res) {
/* Make sure we can register our sip channel type */
ast_cli_register(&cli_inuse_show);
sip_rtp.type = type;
ast_rtp_proto_register(&sip_rtp);
- sched = sched_context_create();
- if (!sched) {
- ast_log(LOG_WARNING, "Unable to create schedule context\n");
- }
- io = io_context_create();
- if (!io) {
- ast_log(LOG_WARNING, "Unable to create I/O context\n");
- }
-
ast_mutex_lock(&peerl.lock);
for (peer = peerl.peers; peer; peer = peer->next)
sip_poke_peer(peer);