[Asterisk-cvs] asterisk/channels chan_iax2.c, 1.184,
1.185 chan_sip.c, 1.506, 1.507
markster at lists.digium.com
markster at lists.digium.com
Thu Sep 16 12:17:32 CDT 2004
Update of /usr/cvsroot/asterisk/channels
In directory mongoose.digium.com:/tmp/cvs-serv2029/channels
Modified Files:
chan_iax2.c chan_sip.c
Log Message:
Add IAX2/SIP register events to system (bug #2117)
Index: chan_iax2.c
===================================================================
RCS file: /usr/cvsroot/asterisk/channels/chan_iax2.c,v
retrieving revision 1.184
retrieving revision 1.185
diff -u -d -r1.184 -r1.185
--- chan_iax2.c 15 Sep 2004 17:31:37 -0000 1.184
+++ chan_iax2.c 16 Sep 2004 16:18:53 -0000 1.185
@@ -4152,6 +4152,7 @@
snprintf(msgstatus, sizeof(msgstatus), " with no messages waiting\n");
snprintf(ourip, sizeof(ourip), "%s:%d", ast_inet_ntoa(iabuf, sizeof(iabuf), reg->us.sin_addr), ntohs(reg->us.sin_port));
ast_verbose(VERBOSE_PREFIX_3 "Registered to '%s', who sees us as %s%s\n", ast_inet_ntoa(iabuf, sizeof(iabuf), sin->sin_addr), ourip, msgstatus);
+ manager_event(EVENT_FLAG_SYSTEM, "Registry", "Channel: IAX2\r\nDomain: %s\r\nStatus: Registered\r\n", ast_inet_ntoa(iabuf, sizeof(iabuf), sin->sin_addr));
}
reg->regstate = REG_STATE_REGISTERED;
return 0;
@@ -4319,11 +4320,13 @@
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", ast_inet_ntoa(iabuf, sizeof(iabuf), sin->sin_addr), ntohs(sin->sin_port));
+ manager_event(EVENT_FLAG_SYSTEM, "PeerStatus", "Peer: IAX2/%s\r\nPeerStatus: Registered\r\n", p->name);+ manager_event(EVENT_FLAG_SYSTEM, "PeerStatus", "Peer: IAX2/%s\r\nPeerStatus: Registered\r\n", p->name);
register_peer_exten(p, 1);
} else {
if (option_verbose > 2)
ast_verbose(VERBOSE_PREFIX_3 "Unregistered '%s' (%s)\n", p->name,
iaxs[callno]->state & IAX_STATE_AUTHENTICATED ? "AUTHENTICATED" : "UNAUTHENTICATED");
+ manager_event(EVENT_FLAG_SYSTEM, "PeerStatus", "Peer: IAX2/%s\r\nPeerStatus: Unregistered\r\n", p->name);
register_peer_exten(p, 0);
ast_db_del("IAX/Registry", p->name);
}
@@ -5499,9 +5502,11 @@
if ((peer->lastms < 0) || (peer->lastms > peer->maxms)) {
if (iaxs[fr.callno]->pingtime <= peer->maxms)
ast_log(LOG_NOTICE, "Peer '%s' is now REACHABLE!\n", peer->name);
+ manager_event(EVENT_FLAG_SYSTEM, "PeerStatus", "Peer: IAX2/%s\r\nPeerStatus: Reachable\r\nTime: %d\r\n", peer->name,iaxs[fr.callno]->pingtime);
} else if ((peer->lastms > 0) && (peer->lastms <= 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);
+ manager_event(EVENT_FLAG_SYSTEM, "PeerStatus", "Peer: IAX2/%s\r\nPeerStatus: Lagged\r\nTime: %d\r\n", peer->name,iaxs[fr.callno]->pingtime);
}
peer->lastms = iaxs[fr.callno]->pingtime;
if (peer->pokeexpire > -1)
@@ -5694,8 +5699,10 @@
break;
case IAX_COMMAND_REGREJ:
if (iaxs[fr.callno]->reg) {
- if (authdebug)
+ if (authdebug) {
ast_log(LOG_NOTICE, "Registration of '%s' rejected: %s\n", iaxs[fr.callno]->reg->username, ies.cause ? ies.cause : "<unknown>");
+ manager_event(EVENT_FLAG_SYSTEM, "Registry", "Channel: IAX2\r\nUsername: %s\r\nStatus: Rejected\r\nCause: %s\r\n", iaxs[fr.callno]->reg->username, ies.cause ? ies.cause : "<unknown>");
+ }
iaxs[fr.callno]->reg->regstate = REG_STATE_REJECTED;
}
/* Send ack immediately, before we destroy */
@@ -5996,8 +6003,10 @@
{
struct iax2_peer *peer = data;
peer->pokeexpire = -1;
- if (peer->lastms > -1)
+ if (peer->lastms > -1) {
ast_log(LOG_NOTICE, "Peer '%s' is now UNREACHABLE!\n", peer->name);
+ manager_event(EVENT_FLAG_SYSTEM, "PeerStatus", "Peer: IAX2/%s\r\nPeerStatus: Unreachable\r\nTime: %d\r\n", peer->name,peer->lastms);
+ }
if (peer->callno > 0)
iax2_destroy(peer->callno);
peer->callno = 0;
Index: chan_sip.c
===================================================================
RCS file: /usr/cvsroot/asterisk/channels/chan_sip.c,v
retrieving revision 1.506
retrieving revision 1.507
diff -u -d -r1.506 -r1.507
--- chan_sip.c 16 Sep 2004 12:53:10 -0000 1.506
+++ chan_sip.c 16 Sep 2004 16:18:53 -0000 1.507
@@ -28,6 +28,7 @@
#include <asterisk/io.h>
#include <asterisk/rtp.h>
#include <asterisk/acl.h>
+#include <asterisk/manager.h>
#include <asterisk/callerid.h>
#include <asterisk/cli.h>
#include <asterisk/md5.h>
@@ -4019,6 +4020,7 @@
p->needdestroy = 1;
}
r->regstate=REG_STATE_UNREGISTERED;
+ manager_event(EVENT_FLAG_SYSTEM, "Registry", "Channel: SIP\r\nDomain: %s\r\nStatus: %s\r\n", r->hostname, regstate2str(r->regstate));
r->timeout = -1;
res=transmit_register(r, "REGISTER", NULL, NULL);
ast_mutex_unlock(®l.lock);
@@ -4271,6 +4273,7 @@
struct sip_peer *p = data;
memset(&p->addr, 0, sizeof(p->addr));
ast_db_del("SIP/Registry", p->name);
+ manager_event(EVENT_FLAG_SYSTEM, "PeerStatus", "Peer: SIP/%s\r\nPeerStatus: Unregistered\r\nCause: Expired\r\n", p->name);
register_peer_exten(p, 0);
p->expire = -1;
ast_device_state_changed("SIP/%s", p->name);
@@ -4395,6 +4398,7 @@
p->lastms = 0;
if (option_verbose > 2)
ast_verbose(VERBOSE_PREFIX_3 "Unregistered SIP '%s'\n", p->name);
+ manager_event(EVENT_FLAG_SYSTEM, "PeerStatus", "Peer: SIP/%s\r\nPeerStatus: Unregistered\r\n", p->name);
return 0;
}
strncpy(p->fullcontact, c, sizeof(p->fullcontact) - 1);
@@ -4455,6 +4459,7 @@
pvt->expiry = expiry;
snprintf(data, sizeof(data), "%s:%d:%d:%s:%s", ast_inet_ntoa(iabuf, sizeof(iabuf), p->addr.sin_addr), ntohs(p->addr.sin_port), expiry, p->username, p->fullcontact);
ast_db_put("SIP/Registry", p->name, data);
+ manager_event(EVENT_FLAG_SYSTEM, "PeerStatus", "Peer: SIP/%s\r\nPeerStatus: Registered\r\n", p->name);
if (inaddrcmp(&p->addr, &oldsin)) {
sip_poke_peer(p);
if (option_verbose > 2)
@@ -4849,6 +4854,7 @@
ast_log(LOG_WARNING, "Failed to parse contact info\n");
} else {
/* Say OK and ask subsystem to retransmit msg counter */
+ manager_event(EVENT_FLAG_SYSTEM, "PeerStatus", "Peer: SIP/%s\r\nPeerStatus: Registered\r\n", peer->name);
transmit_response_with_date(p, "200 OK", req);
peer->lastmsgssent = -1;
res = 0;
@@ -6559,6 +6565,7 @@
need to hang around for something more "difinitive" */
if (resp != 100) {
int statechanged = 0;
+ int newstate = 0;
peer = p->peerpoke;
gettimeofday(&tv, NULL);
pingtime = (tv.tv_sec - peer->ps.tv_sec) * 1000 +
@@ -6569,19 +6576,27 @@
if (pingtime <= peer->maxms) {
ast_log(LOG_NOTICE, "Peer '%s' is now REACHABLE!\n", peer->name);
statechanged = 1;
+ newstate = 1;
}
} else if ((peer->lastms > 0) && (peer->lastms <= peer->maxms)) {
if (pingtime > peer->maxms) {
ast_log(LOG_NOTICE, "Peer '%s' is now TOO LAGGED!\n", peer->name);
statechanged = 1;
+ newstate = 2;
}
}
if (!peer->lastms)
statechanged = 1;
peer->lastms = pingtime;
peer->call = NULL;
- if (statechanged)
- ast_device_state_changed("SIP/%s", peer->name);
+ if (statechanged) {
+ ast_device_state_changed("SIP/%s", peer->name);
+ if (newstate == 2) {
+ manager_event(EVENT_FLAG_SYSTEM, "PeerStatus", "Peer: SIP/%s\r\nPeerStatus: Lagged\r\nTime: %d\r\n", peer->name, pingtime);
+ } else {
+ manager_event(EVENT_FLAG_SYSTEM, "PeerStatus", "Peer: SIP/%s\r\nPeerStatus: Reachable\r\nTime: %d\r\n", peer->name, pingtime);
+ }
+ }
if (peer->pokeexpire > -1)
ast_sched_del(sched, peer->pokeexpire);
@@ -6669,6 +6684,7 @@
r=p->registry;
if (r) {
r->regstate=REG_STATE_REGISTERED;
+ manager_event(EVENT_FLAG_SYSTEM, "Registry", "Channel: SIP\r\nDomain: %s\r\nStatus: %s\r\n", r->hostname, regstate2str(r->regstate));
ast_log(LOG_DEBUG, "Registration successful\n");
if (r->timeout > -1) {
ast_log(LOG_DEBUG, "Cancelling timeout %d\n", r->timeout);
@@ -7817,8 +7833,10 @@
struct sip_peer *peer = data;
peer->pokeexpire = -1;
- if (peer->lastms > -1)
+ if (peer->lastms > -1) {
ast_log(LOG_NOTICE, "Peer '%s' is now UNREACHABLE!\n", peer->name);
+ manager_event(EVENT_FLAG_SYSTEM, "PeerStatus", "Peer: SIP/%s\r\nPeerStatus: Unreachable\r\nTime: %d\r\n", peer->name, -1);
+ }
if (peer->call)
sip_destroy(peer->call);
peer->call = NULL;
More information about the svn-commits
mailing list