[asterisk-commits] oej: branch oej/pinetree-trunk r216672 - in /team/oej/pinetree-trunk: ./ apps...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Mon Sep 7 07:21:18 CDT 2009
Author: oej
Date: Mon Sep 7 07:21:15 2009
New Revision: 216672
URL: http://svn.asterisk.org/svn-view/asterisk?view=rev&rev=216672
Log:
Reset automerge on this branch
Modified:
team/oej/pinetree-trunk/ (props changed)
team/oej/pinetree-trunk/apps/app_voicemail.c
team/oej/pinetree-trunk/channels/chan_sip.c
Propchange: team/oej/pinetree-trunk/
------------------------------------------------------------------------------
automerge = http://www.codename-pineapple.org/
Propchange: team/oej/pinetree-trunk/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Mon Sep 7 07:21:15 2009
@@ -1,1 +1,1 @@
-/trunk:1-216580
+/trunk:1-216657
Modified: team/oej/pinetree-trunk/apps/app_voicemail.c
URL: http://svn.asterisk.org/svn-view/asterisk/team/oej/pinetree-trunk/apps/app_voicemail.c?view=diff&rev=216672&r1=216671&r2=216672
==============================================================================
--- team/oej/pinetree-trunk/apps/app_voicemail.c (original)
+++ team/oej/pinetree-trunk/apps/app_voicemail.c Mon Sep 7 07:21:15 2009
@@ -2357,7 +2357,7 @@
ast_variables_destroy(var);
return vmu;
} else {
- free(vmu);
+ ast_free(vmu);
return NULL;
}
}
Modified: team/oej/pinetree-trunk/channels/chan_sip.c
URL: http://svn.asterisk.org/svn-view/asterisk/team/oej/pinetree-trunk/channels/chan_sip.c?view=diff&rev=216672&r1=216671&r2=216672
==============================================================================
--- team/oej/pinetree-trunk/channels/chan_sip.c (original)
+++ team/oej/pinetree-trunk/channels/chan_sip.c Mon Sep 7 07:21:15 2009
@@ -2178,7 +2178,7 @@
}
/*!
- * \note the peer's addr struct provides to fields combined to make a key: the sin_addr.s_addr and sin_port fields.
+ * \note the peer's ip address field is used to create key.
*/
static int peer_iphash_cb(const void *obj, const int flags)
{
@@ -2186,12 +2186,8 @@
int ret1 = peer->addr.sin_addr.s_addr;
if (ret1 < 0)
ret1 = -ret1;
-
- if (ast_test_flag(&peer->flags[0], SIP_INSECURE_PORT)) {
- return ret1;
- } else {
- return ret1 + peer->addr.sin_port;
- }
+
+ return ret1;
}
/*!
@@ -2208,6 +2204,8 @@
* pass for full IP+port matching, and a second pass in case there is a match
* that meets the insecure=port criteria.
*
+ * \note Connections coming in over TCP or TLS should never be matched by port.
+ *
* \note the peer's addr struct provides to fields combined to make a key: the sin_addr.s_addr and sin_port fields.
*/
static int peer_ipcmp_cb(void *obj, void *arg, int flags)
@@ -2219,17 +2217,18 @@
return 0;
}
- /* We matched the IP, now check the port if appropriate. */
-
- if (ast_test_flag(&peer2->flags[0], SIP_INSECURE_PORT)) {
+ /* We matched the IP, check to see if we need to match by port as well. */
+ if ((peer->transports & peer2->transports) & (SIP_TRANSPORT_TLS | SIP_TRANSPORT_TCP)) {
+ /* peer matching on port is not possible with TCP/TLS */
+ return CMP_MATCH | CMP_STOP;
+ } else if (ast_test_flag(&peer2->flags[0], SIP_INSECURE_PORT)) {
/* We are allowing match without port for peers configured that
* way in this pass through the peers. */
return ast_test_flag(&peer->flags[0], SIP_INSECURE_PORT) ?
(CMP_MATCH | CMP_STOP) : 0;
}
- /* Only return a match if the port matches, as well. */
-
+ /* Now only return a match if the port matches, as well. */
return peer->addr.sin_port == peer2->addr.sin_port ? (CMP_MATCH | CMP_STOP) : 0;
}
@@ -2611,7 +2610,7 @@
static void set_peer_defaults(struct sip_peer *peer);
static struct sip_peer *temp_peer(const char *name);
static void register_peer_exten(struct sip_peer *peer, int onoff);
-static struct sip_peer *find_peer(const char *peer, struct sockaddr_in *sin, int realtime, int forcenamematch, int devstate_only);
+static struct sip_peer *find_peer(const char *peer, struct sockaddr_in *sin, int realtime, int forcenamematch, int devstate_only, int transport);
static int sip_poke_peer_s(const void *data);
static enum parse_register_result parse_register_contact(struct sip_pvt *pvt, struct sip_peer *p, struct sip_request *req);
static void reg_source_db(struct sip_peer *peer);
@@ -4944,7 +4943,7 @@
* \note Avoid using this function in new functions if there is a way to avoid it,
* since it might cause a database lookup.
*/
-static struct sip_peer *find_peer(const char *peer, struct sockaddr_in *sin, int realtime, int which_objects, int devstate_only)
+static struct sip_peer *find_peer(const char *peer, struct sockaddr_in *sin, int realtime, int which_objects, int devstate_only, int transport)
{
struct sip_peer *p = NULL;
struct sip_peer tmp_peer;
@@ -4956,6 +4955,7 @@
tmp_peer.addr.sin_addr.s_addr = sin->sin_addr.s_addr;
tmp_peer.addr.sin_port = sin->sin_port;
tmp_peer.flags[0].flags = 0;
+ tmp_peer.transports = transport;
p = ao2_t_find(peers_by_ip, &tmp_peer, OBJ_POINTER, "ao2_find in peers_by_ip table"); /* WAS: p = ASTOBJ_CONTAINER_FIND_FULL(&peerl, sin, name, sip_addr_hashfunc, 1, sip_addrcmp); */
if (!p) {
ast_set_flag(&tmp_peer.flags[0], SIP_INSECURE_PORT);
@@ -5293,7 +5293,7 @@
dialog->sa.sin_family = AF_INET;
dialog->timer_t1 = global_t1; /* Default SIP retransmission timer T1 (RFC 3261) */
dialog->timer_b = global_timer_b; /* Default SIP transaction timer B (RFC 3261) */
- peer = find_peer(peername, NULL, TRUE, FINDPEERS, FALSE);
+ peer = find_peer(peername, NULL, TRUE, FINDPEERS, FALSE, 0);
if (peer) {
int res;
@@ -5667,7 +5667,7 @@
ast_copy_string(name, fup->username, sizeof(name));
/* Check the list of devices */
- if ((p = find_peer(ast_strlen_zero(fup->peername) ? name : fup->peername, NULL, TRUE, FINDALLDEVICES, FALSE))) {
+ if ((p = find_peer(ast_strlen_zero(fup->peername) ? name : fup->peername, NULL, TRUE, FINDALLDEVICES, FALSE, 0))) {
inuse = &p->inUse;
call_limit = &p->call_limit;
inringing = &p->inRinging;
@@ -11866,7 +11866,7 @@
if (r->dnsmgr == NULL) {
char transport[MAXHOSTNAMELEN];
- peer = find_peer(r->hostname, NULL, TRUE, FINDPEERS, FALSE);
+ peer = find_peer(r->hostname, NULL, TRUE, FINDPEERS, FALSE, 0);
snprintf(transport, sizeof(transport), "_sip._%s", get_transport(r->transport)); /* have to use static get_transport function */
ast_dnsmgr_lookup(peer ? peer->tohost : r->hostname, &r->us, &r->dnsmgr, sip_cfg.srvlookup ? transport : NULL);
if (peer) {
@@ -11901,7 +11901,7 @@
append_history(p, "RegistryInit", "Account: %s@%s", r->username, r->hostname);
if (!ast_strlen_zero(r->peername)) {
- if (!(peer = find_peer(r->peername, NULL, 1, FINDPEERS, FALSE))) {
+ if (!(peer = find_peer(r->peername, NULL, 1, FINDPEERS, FALSE, 0))) {
ast_log(LOG_WARNING, "Could not find peer %s in transmit_register\n", r->peername);
}
}
@@ -13001,7 +13001,7 @@
/*! \brief Change onhold state of a peer using a pvt structure */
static void sip_peer_hold(struct sip_pvt *p, int hold)
{
- struct sip_peer *peer = find_peer(p->peername, NULL, 1, FINDALLDEVICES, FALSE);
+ struct sip_peer *peer = find_peer(p->peername, NULL, 1, FINDALLDEVICES, FALSE, 0);
if (!peer)
return;
@@ -13240,7 +13240,7 @@
ast_string_field_set(p, exten, name);
build_contact(p);
- peer = find_peer(name, NULL, TRUE, FINDPEERS, FALSE);
+ peer = find_peer(name, NULL, TRUE, FINDPEERS, FALSE, 0);
if (!(peer && ast_apply_ha(peer->ha, sin))) {
/* Peer fails ACL check */
if (peer) {
@@ -14209,7 +14209,7 @@
static void check_via(struct sip_pvt *p, const struct sip_request *req)
{
char via[512];
- char *c, *pt;
+ char *c;
ast_copy_string(via, get_header(req, "Via"), sizeof(via));
@@ -14299,29 +14299,14 @@
/* For subscribes, match on device name only; for other methods,
* match on IP address-port of the incoming request.
*/
- peer = find_peer(of, NULL, TRUE, FINDALLDEVICES, FALSE);
+ peer = find_peer(of, NULL, TRUE, FINDALLDEVICES, FALSE, 0);
} else {
/* First find devices based on username (avoid all type=peer's) */
- peer = find_peer(of, NULL, TRUE, FINDUSERS, FALSE);
+ peer = find_peer(of, NULL, TRUE, FINDUSERS, FALSE, 0);
/* Then find devices based on IP */
if (!peer) {
- peer = find_peer(NULL, &p->recv, TRUE, FINDPEERS, FALSE);
- }
- /* If the peer is still not found, try the address and port from the
- * contact header. If the transport type is TCP or TLS it is not possible
- * to find the peer using p->recv. Because of the way TCP works, the received
- * packet's destination port will not match the one the peer table is
- * built with. */
- if (!peer && (p->socket.type != SIP_TRANSPORT_UDP)) {
- struct sockaddr_in tmpsin;
- char contact[SIPBUFSIZE];
- char *tmp;
- memcpy(&tmpsin, &p->recv, sizeof(tmpsin));
- ast_copy_string(contact, get_header(req, "Contact"), sizeof(contact));
- tmp = get_in_brackets(contact);
- __set_address_from_contact(tmp, &tmpsin, 1);
- peer = find_peer(NULL, &tmpsin, TRUE, FINDPEERS, FALSE);
+ peer = find_peer(NULL, &p->recv, TRUE, FINDPEERS, FALSE, p->socket.type);
}
/*
If this peer have a matching principle that says we need to check
@@ -14332,7 +14317,7 @@
struct sockaddr_in matchaddr;
/* Go find the peer */
find_via_address(peer->matchrule == MATCH_SECONDVIA, p, req, &matchaddr);
- peer = find_peer(NULL, &matchaddr, TRUE, FINDPEERS, FALSE);
+ peer = find_peer(NULL, &matchaddr, TRUE, FINDPEERS, FALSE, 0);
}
}
@@ -15637,7 +15622,7 @@
return CLI_SHOWUSAGE;
load_realtime = (argc == 5 && !strcmp(argv[4], "load")) ? TRUE : FALSE;
- if ((peer = find_peer(argv[3], NULL, load_realtime, FINDPEERS, FALSE))) {
+ if ((peer = find_peer(argv[3], NULL, load_realtime, FINDPEERS, FALSE, 0))) {
sip_poke_peer(peer, 1);
unref_peer(peer, "qualify: done with peer");
} else if (type == 0) {
@@ -15719,7 +15704,7 @@
return CLI_SHOWUSAGE;
load_realtime = (argc == 5 && !strcmp(argv[4], "load")) ? TRUE : FALSE;
- peer = find_peer(argv[3], NULL, load_realtime, FINDPEERS, FALSE);
+ peer = find_peer(argv[3], NULL, load_realtime, FINDPEERS, FALSE, 0);
if (s) { /* Manager */
if (peer) {
@@ -16003,7 +15988,7 @@
/* Load from realtime storage? */
load_realtime = (a->argc == 5 && !strcmp(a->argv[4], "load")) ? TRUE : FALSE;
- if ((user = find_peer(a->argv[3], NULL, load_realtime, FINDUSERS, FALSE))) {
+ if ((user = find_peer(a->argv[3], NULL, load_realtime, FINDUSERS, FALSE, 0))) {
ao2_lock(user);
ast_cli(a->fd, "\n\n");
ast_cli(a->fd, " * Name : %s\n", user->name);
@@ -16164,7 +16149,7 @@
if (a->argc != 3)
return CLI_SHOWUSAGE;
- if ((peer = find_peer(a->argv[2], NULL, load_realtime, FINDPEERS, TRUE))) {
+ if ((peer = find_peer(a->argv[2], NULL, load_realtime, FINDPEERS, TRUE, 0))) {
if (peer->expire > 0) {
AST_SCHED_DEL_UNREF(sched, peer->expire,
unref_peer(peer, "remove register expire ref"));
@@ -17173,7 +17158,7 @@
/*! \brief Turn on SIP debugging for a given peer */
static char *sip_do_debug_peer(int fd, const char *arg)
{
- struct sip_peer *peer = find_peer(arg, NULL, TRUE, FINDPEERS, FALSE);
+ struct sip_peer *peer = find_peer(arg, NULL, TRUE, FINDPEERS, FALSE, 0);
if (!peer)
ast_cli(fd, "No such peer '%s'\n", arg);
else if (peer->addr.sin_addr.s_addr == 0)
@@ -17628,7 +17613,7 @@
else
colname = "ip";
- if (!(peer = find_peer(data, NULL, TRUE, FINDPEERS, FALSE)))
+ if (!(peer = find_peer(data, NULL, TRUE, FINDPEERS, FALSE, 0)))
return -1;
if (!strcasecmp(colname, "ip")) {
@@ -19070,7 +19055,7 @@
case 405:
case 501: /* Not Implemented */
mark_method_unallowed(&p->allowed_methods, sipmethod);
- if ((peer = find_peer(p->peername, 0, 1, FINDPEERS, FALSE))) {
+ if ((peer = find_peer(p->peername, 0, 1, FINDPEERS, FALSE, 0))) {
mark_method_allowed(&peer->disallowed_methods, sipmethod);
unref_peer(peer, "handle_response: marking a specific method as unallowed");
}
@@ -23355,7 +23340,7 @@
if (p->stimer->st_cached_max_se) {
return p->stimer->st_cached_max_se;
} else if (p->peername) {
- struct sip_peer *pp = find_peer(p->peername, NULL, TRUE, FINDPEERS, FALSE);
+ struct sip_peer *pp = find_peer(p->peername, NULL, TRUE, FINDPEERS, FALSE, 0);
if (pp) {
p->stimer->st_cached_max_se = pp->stimer.st_max_se;
unref_peer(pp, "unref peer pointer from find_peer call in st_get_se");
@@ -23364,20 +23349,21 @@
}
p->stimer->st_cached_max_se = global_max_se;
return (p->stimer->st_cached_max_se);
- } else {
- if (p->stimer->st_cached_min_se) {
- return p->stimer->st_cached_min_se;
- } else if (p->peername) {
- struct sip_peer *pp = find_peer(p->peername, NULL, TRUE, FINDPEERS, FALSE);
- if (pp) {
- p->stimer->st_cached_min_se = pp->stimer.st_min_se;
- unref_peer(pp, "unref peer pointer from find_peer call in st_get_se (2)");
- return (p->stimer->st_cached_min_se);
- }
- }
- p->stimer->st_cached_min_se = global_min_se;
- return (p->stimer->st_cached_min_se);
- }
+ }
+ /* Find Min SE timer */
+ if (p->stimer->st_cached_min_se) {
+ return p->stimer->st_cached_min_se;
+ }
+ if (p->peername) {
+ struct sip_peer *pp = find_peer(p->peername, NULL, TRUE, FINDPEERS, FALSE, 0);
+ if (pp) {
+ p->stimer->st_cached_min_se = pp->stimer.st_min_se;
+ unref_peer(pp, "unref peer pointer from find_peer call in st_get_se (2)");
+ return (p->stimer->st_cached_min_se);
+ }
+ }
+ p->stimer->st_cached_min_se = global_min_se;
+ return (p->stimer->st_cached_min_se);
}
@@ -23390,7 +23376,7 @@
return p->stimer->st_cached_ref;
if (p->peername) {
- struct sip_peer *pp = find_peer(p->peername, NULL, TRUE, FINDPEERS, FALSE);
+ struct sip_peer *pp = find_peer(p->peername, NULL, TRUE, FINDPEERS, FALSE, 0);
if (pp) {
p->stimer->st_cached_ref = pp->stimer.st_ref;
unref_peer(pp, "unref peer pointer from find_peer call in st_get_refresher");
@@ -23415,7 +23401,7 @@
return p->stimer->st_cached_mode;
if (p->peername) {
- struct sip_peer *pp = find_peer(p->peername, NULL, TRUE, FINDPEERS, FALSE);
+ struct sip_peer *pp = find_peer(p->peername, NULL, TRUE, FINDPEERS, FALSE, 0);
if (pp) {
p->stimer->st_cached_mode = pp->stimer.st_mode_oper;
unref_peer(pp, "unref peer pointer from find_peer call in st_get_mode");
@@ -23606,7 +23592,7 @@
* load it BACK into memory, thus defeating the point of trying to clear dead
* hosts out of memory.
*/
- if ((p = find_peer(host, NULL, FALSE, FINDALLDEVICES, TRUE))) {
+ if ((p = find_peer(host, NULL, FALSE, FINDALLDEVICES, TRUE, 0))) {
if (p->addr.sin_addr.s_addr || p->defaddr.sin_addr.s_addr) {
/* we have an address for the peer */
More information about the asterisk-commits
mailing list