[svn-commits] file: branch file/stasis_peerevent r389203 - /team/file/stasis_peerevent/chan...
SVN commits to the Digium repositories
svn-commits at lists.digium.com
Mon May 20 08:58:36 CDT 2013
Author: file
Date: Mon May 20 08:58:32 2013
New Revision: 389203
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=389203
Log:
Add to IAX2 and Skinny.
Modified:
team/file/stasis_peerevent/channels/chan_iax2.c
team/file/stasis_peerevent/channels/chan_sip.c
team/file/stasis_peerevent/channels/chan_skinny.c
Modified: team/file/stasis_peerevent/channels/chan_iax2.c
URL: http://svnview.digium.com/svn/asterisk/team/file/stasis_peerevent/channels/chan_iax2.c?view=diff&rev=389203&r1=389202&r2=389203
==============================================================================
--- team/file/stasis_peerevent/channels/chan_iax2.c (original)
+++ team/file/stasis_peerevent/channels/chan_iax2.c Mon May 20 08:58:32 2013
@@ -102,6 +102,7 @@
#include "asterisk/data.h"
#include "asterisk/netsock2.h"
#include "asterisk/security_events.h"
+#include "asterisk/stasis_endpoints.h"
#include "iax2/include/iax2.h"
#include "iax2/include/firmware.h"
@@ -552,6 +553,8 @@
struct ast_acl_list *acl;
enum calltoken_peer_enum calltoken_required; /*!< Is calltoken validation required or not, can be YES, NO, or AUTO */
+
+ struct ast_endpoint *endpoint; /*!< Endpoint structure for this peer */
};
#define IAX2_TRUNK_PREFACE (sizeof(struct iax_frame) + sizeof(struct ast_iax2_meta_hdr) + sizeof(struct ast_iax2_meta_trunk_hdr))
@@ -8553,6 +8556,7 @@
ast_debug(1, "Expiring registration for peer '%s'\n", peer->name);
if (ast_test_flag64((&globalflags), IAX_RTUPDATE) && (ast_test_flag64(peer, IAX_TEMPONLY|IAX_RTCACHEFRIENDS)))
realtime_update_peer(peer->name, &peer->addr, 0);
+ ast_endpoint_set_state(peer->endpoint, AST_ENDPOINT_OFFLINE);
manager_event(EVENT_FLAG_SYSTEM, "PeerStatus", "ChannelType: IAX2\r\nPeer: IAX2/%s\r\nPeerStatus: Unregistered\r\nCause: Expired\r\n", peer->name);
/* modify entry in peercnts table as _not_ registered */
peercnt_modify(0, 0, &peer->addr);
@@ -8693,12 +8697,14 @@
ast_db_put("IAX/Registry", p->name, data);
ast_verb(3, "Registered IAX2 '%s' (%s) at %s:%d\n", p->name,
ast_test_flag(&iaxs[callno]->state, IAX_STATE_AUTHENTICATED) ? "AUTHENTICATED" : "UNAUTHENTICATED", ast_inet_ntoa(sin->sin_addr), ntohs(sin->sin_port));
+ ast_endpoint_set_state(p->endpoint, AST_ENDPOINT_ONLINE);
manager_event(EVENT_FLAG_SYSTEM, "PeerStatus", "ChannelType: IAX2\r\nPeer: IAX2/%s\r\nPeerStatus: Registered\r\nAddress: %s\r\nPort: %d\r\n", p->name, ast_inet_ntoa(sin->sin_addr), ntohs(sin->sin_port));
register_peer_exten(p, 1);
ast_devstate_changed(AST_DEVICE_UNKNOWN, AST_DEVSTATE_CACHABLE, "IAX2/%s", p->name); /* Activate notification */
} else if (!ast_test_flag64(p, IAX_TEMPONLY)) {
ast_verb(3, "Unregistered IAX2 '%s' (%s)\n", p->name,
ast_test_flag(&iaxs[callno]->state, IAX_STATE_AUTHENTICATED) ? "AUTHENTICATED" : "UNAUTHENTICATED");
+ ast_endpoint_set_state(p->endpoint, AST_ENDPOINT_OFFLINE);
manager_event(EVENT_FLAG_SYSTEM, "PeerStatus", "ChannelType: IAX2\r\nPeer: IAX2/%s\r\nPeerStatus: Unregistered\r\n", p->name);
register_peer_exten(p, 0);
ast_db_del("IAX/Registry", p->name);
@@ -10913,12 +10919,14 @@
if ((peer->lastms < 0) || (peer->historicms > peer->maxms)) {
if (iaxs[fr->callno]->pingtime <= peer->maxms) {
ast_log(LOG_NOTICE, "Peer '%s' is now REACHABLE! Time: %d\n", peer->name, iaxs[fr->callno]->pingtime);
+ ast_endpoint_set_state(peer->endpoint, AST_ENDPOINT_ONLINE);
manager_event(EVENT_FLAG_SYSTEM, "PeerStatus", "ChannelType: IAX2\r\nPeer: IAX2/%s\r\nPeerStatus: Reachable\r\nTime: %d\r\n", peer->name, iaxs[fr->callno]->pingtime);
ast_devstate_changed(AST_DEVICE_NOT_INUSE, AST_DEVSTATE_CACHABLE, "IAX2/%s", peer->name); /* Activate notification */
}
} else if ((peer->historicms > 0) && (peer->historicms <= peer->maxms)) {
if (iaxs[fr->callno]->pingtime > peer->maxms) {
ast_log(LOG_NOTICE, "Peer '%s' is now TOO LAGGED (%d ms)!\n", peer->name, iaxs[fr->callno]->pingtime);
+ ast_endpoint_set_state(peer->endpoint, AST_ENDPOINT_ONLINE);
manager_event(EVENT_FLAG_SYSTEM, "PeerStatus", "ChannelType: IAX2\r\nPeer: IAX2/%s\r\nPeerStatus: Lagged\r\nTime: %d\r\n", peer->name, iaxs[fr->callno]->pingtime);
ast_devstate_changed(AST_DEVICE_UNAVAILABLE, AST_DEVSTATE_CACHABLE, "IAX2/%s", peer->name); /* Activate notification */
}
@@ -12003,6 +12011,7 @@
if (peer->lastms > -1) {
ast_log(LOG_NOTICE, "Peer '%s' is now UNREACHABLE! Time: %d\n", peer->name, peer->lastms);
+ ast_endpoint_set_state(peer->endpoint, AST_ENDPOINT_OFFLINE);
manager_event(EVENT_FLAG_SYSTEM, "PeerStatus", "ChannelType: IAX2\r\nPeer: IAX2/%s\r\nPeerStatus: Unreachable\r\nTime: %d\r\n", peer->name, peer->lastms);
ast_devstate_changed(AST_DEVICE_UNAVAILABLE, AST_DEVSTATE_CACHABLE, "IAX2/%s", peer->name); /* Activate notification */
}
@@ -12423,6 +12432,8 @@
peer->mwi_event_sub = stasis_unsubscribe(peer->mwi_event_sub);
ast_string_field_free_memory(peer);
+
+ ast_endpoint_shutdown(peer->endpoint);
}
/*! \brief Create peer structure based on configuration */
@@ -12456,6 +12467,9 @@
peer->addr.len = sizeof(struct sockaddr_in);
if (ast_string_field_init(peer, 32))
peer = peer_unref(peer);
+ if (!(peer->endpoint = ast_endpoint_create("IAX2", name))) {
+ peer = peer_unref(peer);
+ }
}
if (peer) {
Modified: team/file/stasis_peerevent/channels/chan_sip.c
URL: http://svnview.digium.com/svn/asterisk/team/file/stasis_peerevent/channels/chan_sip.c?view=diff&rev=389203&r1=389202&r2=389203
==============================================================================
--- team/file/stasis_peerevent/channels/chan_sip.c (original)
+++ team/file/stasis_peerevent/channels/chan_sip.c Mon May 20 08:58:32 2013
@@ -17223,6 +17223,7 @@
ast_string_field_set(p, fullcontact, peer->fullcontact);
/* Say OK and ask subsystem to retransmit msg counter */
transmit_response_with_date(p, "200 OK", req);
+ ast_endpoint_set_state(peer->endpoint, AST_ENDPOINT_ONLINE);
manager_event(EVENT_FLAG_SYSTEM, "PeerStatus", "ChannelType: SIP\r\nPeer: SIP/%s\r\nPeerStatus: Registered\r\nAddress: %s\r\n", peer->name, ast_sockaddr_stringify(addr));
send_mwi = 1;
res = 0;
@@ -23823,11 +23824,10 @@
manager_event(EVENT_FLAG_SYSTEM, "PeerStatus",
"ChannelType: SIP\r\nPeer: SIP/%s\r\nPeerStatus: %s\r\nTime: %d\r\n",
peer->name, s, pingtime);
- if (is_reachable) {
- if (sip_cfg.regextenonqualify)
- register_peer_exten(peer, TRUE);
- ast_endpoint_set_state(peer->endpoint, AST_ENDPOINT_ONLINE);
- }
+ if (is_reachable && sip_cfg.regextenonqualify)
+ register_peer_exten(peer, TRUE);
+
+ ast_endpoint_set_state(peer->endpoint, AST_ENDPOINT_ONLINE);
}
pvt_set_needdestroy(p, "got OPTIONS response");
Modified: team/file/stasis_peerevent/channels/chan_skinny.c
URL: http://svnview.digium.com/svn/asterisk/team/file/stasis_peerevent/channels/chan_skinny.c?view=diff&rev=389203&r1=389202&r2=389203
==============================================================================
--- team/file/stasis_peerevent/channels/chan_skinny.c (original)
+++ team/file/stasis_peerevent/channels/chan_skinny.c Mon May 20 08:58:32 2013
@@ -81,6 +81,7 @@
#include "asterisk/event.h"
#include "asterisk/indications.h"
#include "asterisk/linkedlists.h"
+#include "asterisk/stasis_endpoints.h"
/*** DOCUMENTATION
<manager name="SKINNYdevices" language="en_US">
@@ -1582,6 +1583,7 @@
struct skinny_line *activeline;
struct ast_format_cap *cap;
struct ast_format_cap *confcap;
+ struct ast_endpoint *endpoint;
AST_LIST_HEAD(, skinny_line) lines;
AST_LIST_HEAD(, skinny_speeddial) speeddials;
AST_LIST_HEAD(, skinny_serviceurl) serviceurls;
@@ -1686,7 +1688,7 @@
ast_free(l);
return NULL;
}
-static struct skinny_device *skinny_device_alloc(void)
+static struct skinny_device *skinny_device_alloc(const char *dname)
{
struct skinny_device *d;
if (!(d = ast_calloc(1, sizeof(*d)))) {
@@ -1695,18 +1697,23 @@
d->cap = ast_format_cap_alloc_nolock();
d->confcap = ast_format_cap_alloc_nolock();
- if (!d->cap || !d->confcap) {
+ d->endpoint = ast_endpoint_create("Skinny", dname);
+ if (!d->cap || !d->confcap || !d->endpoint) {
d->cap = ast_format_cap_destroy(d->cap);
d->confcap = ast_format_cap_destroy(d->confcap);
ast_free(d);
return NULL;
}
+
+ ast_copy_string(d->name, dname, sizeof(d->name));
+
return d;
}
static struct skinny_device *skinny_device_destroy(struct skinny_device *d)
{
d->cap = ast_format_cap_destroy(d->cap);
d->confcap = ast_format_cap_destroy(d->confcap);
+ ast_endpoint_shutdown(d->endpoint);
ast_free(d);
return NULL;
}
@@ -2286,6 +2293,7 @@
ast_devstate_changed(AST_DEVICE_NOT_INUSE, AST_DEVSTATE_CACHABLE, "Skinny/%s", l->name);
--instance;
}
+ ast_endpoint_set_state(d->endpoint, AST_ENDPOINT_ONLINE);
break;
}
}
@@ -2321,6 +2329,8 @@
ast_devstate_changed(AST_DEVICE_UNAVAILABLE, AST_DEVSTATE_CACHABLE, "Skinny/%s", l->name);
}
}
+
+ ast_endpoint_set_state(d->endpoint, AST_ENDPOINT_OFFLINE);
}
return -1; /* main loop will destroy the session */
@@ -8253,7 +8263,7 @@
}
}
- if (!(d = skinny_device_alloc())) {
+ if (!(d = skinny_device_alloc(dname))) {
ast_verb(1, "Unable to allocate memory for device %s.\n", dname);
AST_LIST_UNLOCK(&devices);
return NULL;
@@ -8663,6 +8673,7 @@
manager_event(EVENT_FLAG_SYSTEM, "PeerStatus", "ChannelType: Skinny\r\nPeer: Skinny/%s@%s\r\nPeerStatus: Unregistered\r\n", l->name, d->name);
unregister_exten(l);
}
+ ast_endpoint_set_state(d->endpoint, AST_ENDPOINT_OFFLINE);
if (s->fd > -1)
close(s->fd);
pthread_cancel(s->t);
More information about the svn-commits
mailing list