[asterisk-commits] branch oej/test-this-branch r11844 -
/team/oej/test-this-branch/channels/
asterisk-commits at lists.digium.com
asterisk-commits at lists.digium.com
Sun Mar 5 01:44:09 MST 2006
Author: oej
Date: Sun Mar 5 02:44:07 2006
New Revision: 11844
URL: http://svn.digium.com/view/asterisk?rev=11844&view=rev
Log:
Update of peermatch branch
Modified:
team/oej/test-this-branch/channels/chan_sip.c
Modified: team/oej/test-this-branch/channels/chan_sip.c
URL: http://svn.digium.com/view/asterisk/team/oej/test-this-branch/channels/chan_sip.c?rev=11844&r1=11843&r2=11844&view=diff
==============================================================================
--- team/oej/test-this-branch/channels/chan_sip.c (original)
+++ team/oej/test-this-branch/channels/chan_sip.c Sun Mar 5 02:44:07 2006
@@ -189,7 +189,6 @@
enum objecttype {
SIP_USER = (1 << 0), /* USER places calls to the PBX */
SIP_PEER = (1 << 1), /* Peer receives calls from PBX (and places calls) */
- SIP_FRIEND = (1 << 2), /* Friend receives calls from PBX (and places calls) */
};
enum subscriptiontype {
@@ -1705,7 +1704,7 @@
static void sip_destroy_device(struct sip_peer *device)
{
if (option_debug > 2)
- ast_log(LOG_DEBUG, "Destroying SIP %s %s\n", device->type == SIP_USER ? "user" : "peer", device->name);
+ ast_log(LOG_DEBUG, "Destroying SIP %s %s\n", device->type & SIP_USER ? "user" : "peer", device->name);
/* Delete it, it needs to disappear */
if (device->call)
@@ -1719,7 +1718,8 @@
if (device->pokeexpire > -1)
ast_sched_del(sched, device->pokeexpire);
ast_free_ha(device->ha);
- if ( device->type == SIP_PEER) {
+
+ if (device->type & SIP_PEER) {
register_peer_exten(device, FALSE);
clear_realm_authentication(device->auth);
if (ast_test_flag((&device->flags_page2), SIP_PAGE2_SELFDESTRUCT))
@@ -1728,7 +1728,8 @@
rpeerobjs--;
else
speerobjs--;
- } else { /* SIP_USER */
+ }
+ if (device->type & SIP_USER) { /* SIP_USER */
if (ast_test_flag(device, SIP_REALTIME))
ruserobjs--;
else
@@ -2335,13 +2336,13 @@
device->inUse= 0;
}
if (option_debug > 1 || sipdebug) {
- ast_log(LOG_DEBUG, "Call %s %s '%s' removed from call limit %d\n", outgoing ? "to" : "from", device->type == SIP_USER ? "user":"peer", name, device->call_limit);
+ ast_log(LOG_DEBUG, "Call %s %s '%s' removed from call limit %d\n", outgoing ? "to" : "from", device->type & SIP_USER ? "user":"peer", name, device->call_limit);
}
break;
case INC_CALL_LIMIT:
if (device->call_limit > 0 ) {
if (device->inUse >= device->call_limit) {
- ast_log(LOG_ERROR, "Call %s %s '%s' rejected due to usage limit of %d\n", outgoing ? "to" : "from", device->type == SIP_USER ? "user":"peer", name, device->call_limit);
+ ast_log(LOG_ERROR, "Call %s %s '%s' rejected due to usage limit of %d\n", outgoing ? "to" : "from", device->type & SIP_USER ? "user":"peer", name, device->call_limit);
ASTOBJ_UNREF(device, sip_destroy_device);
return -1;
}
@@ -2349,7 +2350,7 @@
device->inUse++;
ast_set_flag(fup, SIP_INC_COUNT);
if (option_debug > 1 || sipdebug) {
- ast_log(LOG_DEBUG, "Call %s %s '%s' is %d out of %d\n", outgoing ? "to" : "from", device->type == SIP_USER ? "user":"peer", name, device->inUse, device->call_limit);
+ ast_log(LOG_DEBUG, "Call %s %s '%s' is %d out of %d\n", outgoing ? "to" : "from", device->type & SIP_USER ? "user" : "peer", name, device->inUse, device->call_limit);
}
break;
default:
@@ -7230,6 +7231,7 @@
char calleridname[50];
int debug=sip_debug_test_addr(sin);
struct ast_variable *tmpvar = NULL, *v = NULL;
+ enum objecttype devicematch = SIP_UNKNOWN;
/* Terminate URI */
t = uri;
@@ -7294,6 +7296,8 @@
ASTOBJ_UNREF(device,sip_destroy_device);
device = NULL;
}
+ if (device)
+ devicematch = SIP_USER; /* We matched on a user */
if (!device) {
/* Secondly, match on peer name */
@@ -7315,6 +7319,8 @@
ASTOBJ_UNREF(device,sip_destroy_device);
device = NULL;
}
+ if (device)
+ devicematch = SIP_PEER; /* We matched on a peer */
}
/* No user or peer found */
@@ -7406,7 +7412,7 @@
}
if (!ast_strlen_zero(device->cid_name) && !ast_strlen_zero(p->cid_num))
ast_string_field_set(p, cid_name, device->cid_name);
- if (device->type == SIP_USER) {
+ if (devicematch == SIP_USER) {
ast_string_field_set(p, username, device->name);
} else { /* SIP_PEER */
ast_string_field_set(p, peersecret, device->secret);
@@ -7451,7 +7457,7 @@
}
}
if (device && debug)
- ast_verbose("Found %s '%s'\n", device->type == SIP_USER ? "user" : "peer", device->name);
+ ast_verbose("Found %s '%s'\n", device->type & SIP_USER ? "user" : "peer", device->name);
if (device)
ASTOBJ_UNREF(device, sip_destroy_device);
@@ -12165,7 +12171,7 @@
suserobjs++;
ASTOBJ_INIT(user);
- user->type = SIP_USER;
+ user->type &= SIP_USER;
ast_copy_string(user->name, name, sizeof(user->name));
oldha = user->ha;
user->ha = NULL;
@@ -12307,7 +12313,7 @@
peer->expire = -1;
peer->pokeexpire = -1;
}
- peer->type = SIP_PEER;
+ peer->type &= SIP_PEER;
/* Note that our peer HAS had its reference count incrased */
@@ -12544,7 +12550,7 @@
{
struct ast_config *cfg;
struct ast_variable *v;
- struct sip_peer *device;
+ struct sip_peer *device = (struct sip_peer *) NULL;
struct ast_hostent ahp;
char *cat;
struct hostent *hp;
@@ -12874,17 +12880,18 @@
continue;
} else {
enum objecttype type;
+
if (!strcasecmp(utype, "user"))
type = SIP_USER;
else if (!strcasecmp(utype, "friend"))
- type = SIP_FRIEND;
+ type = SIP_USER | SIP_PEER;
else if (!strcasecmp(utype, "peer"))
type = SIP_PEER;
else {
ast_log(LOG_WARNING, "Unknown type '%s' for '%s' in %s\n", utype, cat, "sip.conf");
continue;
}
- if (type == SIP_PEER || type == SIP_FRIEND) {
+ if (type & SIP_PEER) {
device = build_peer(cat, ast_variable_browse(cfg, cat), 0);
if (device) {
ASTOBJ_CONTAINER_LINK(&peerl,device);
@@ -12892,9 +12899,9 @@
peer_count++;
}
}
- if (type == SIP_USER || type == SIP_FRIEND) {
+ if (type & SIP_USER) {
/* We already have a device for a friend, link it in again */
- if (type != SIP_FRIEND)
+ if (!(type & SIP_PEER)) /* Friend ? Don't build a new object, just re-use the peer object */
device = build_user(cat, ast_variable_browse(cfg, cat), 0);
if (device) {
ASTOBJ_CONTAINER_LINK(&userl,device);
More information about the asterisk-commits
mailing list