aboutsummaryrefslogtreecommitdiffstats
path: root/channels
diff options
context:
space:
mode:
authortilghman <tilghman@f38db490-d61c-443f-a65b-d21fe96a405b>2009-10-01 20:43:38 +0000
committertilghman <tilghman@f38db490-d61c-443f-a65b-d21fe96a405b>2009-10-01 20:43:38 +0000
commit7d2f53e55782a0a3086ef17f52a97a507d4351e7 (patch)
tree8c2745d464258c3552b468a2b74100a428020a87 /channels
parentae2dd119da23a728f52f23b9a683f9cfa4283cae (diff)
Merged revisions 221705 via svnmerge from
https://origsvn.digium.com/svn/asterisk/trunk ........ r221705 | tilghman | 2009-10-01 15:09:46 -0500 (Thu, 01 Oct 2009) | 2 lines Revision 220906 (a merge from 1.4) was not merged correctly, causing a problem with non-dynamic peers. ........ git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.6.2@221744 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'channels')
-rw-r--r--channels/chan_sip.c210
1 files changed, 104 insertions, 106 deletions
diff --git a/channels/chan_sip.c b/channels/chan_sip.c
index 783e674e6..6e85fa1b9 100644
--- a/channels/chan_sip.c
+++ b/channels/chan_sip.c
@@ -23186,22 +23186,6 @@ static struct sip_peer *build_peer(const char *name, struct ast_variable *v, str
ast_get_time_t(v->value, &regseconds, 0, NULL);
} else if (realtime && !strcasecmp(v->name, "name")) {
ast_copy_string(peer->name, v->value, sizeof(peer->name));
- } else if (realtime && !strcasecmp(v->name, "fullcontact")) {
- if (alt_fullcontact && !alt) {
- /* Reset, because the alternate also has a fullcontact and we
- * do NOT want the field value to be doubled. It might be
- * tempting to skip this, but the first table might not have
- * fullcontact and since we're here, we know that the alternate
- * absolutely does. */
- alt_fullcontact = 0;
- ast_str_reset(fullcontact);
- }
- /* Reconstruct field, because realtime separates our value at the ';' */
- if (fullcontact->used > 0) {
- ast_str_append(&fullcontact, 0, ";%s", v->value);
- } else {
- ast_str_set(&fullcontact, 0, "%s", v->value);
- }
} else if (!strcasecmp(v->name, "type")) {
if (!strcasecmp(v->value, "peer")) {
peer->type |= SIP_TYPE_PEER;
@@ -23462,6 +23446,22 @@ static struct sip_peer *build_peer(const char *name, struct ast_variable *v, str
sscanf(v->value, "%30d", &peer->lastms);
} else if (realtime && !strcasecmp(v->name, "ipaddr") && !ast_strlen_zero(v->value) ) {
inet_aton(v->value, &(peer->addr.sin_addr));
+ } else if (realtime && !strcasecmp(v->name, "fullcontact")) {
+ if (alt_fullcontact && !alt) {
+ /* Reset, because the alternate also has a fullcontact and we
+ * do NOT want the field value to be doubled. It might be
+ * tempting to skip this, but the first table might not have
+ * fullcontact and since we're here, we know that the alternate
+ * absolutely does. */
+ alt_fullcontact = 0;
+ ast_str_reset(fullcontact);
+ }
+ /* Reconstruct field, because realtime separates our value at the ';' */
+ if (fullcontact->used > 0) {
+ ast_str_append(&fullcontact, 0, ";%s", v->value);
+ } else {
+ ast_str_set(&fullcontact, 0, "%s", v->value);
+ }
} else if (!strcasecmp(v->name, "qualify")) {
if (!strcasecmp(v->value, "no")) {
peer->maxms = 0;
@@ -23494,113 +23494,111 @@ static struct sip_peer *build_peer(const char *name, struct ast_variable *v, str
}
}
- if (!devstate_only) {
- if (!peer->default_outbound_transport) {
- /* Set default set of transports */
- peer->transports = default_transports;
- /* Set default primary transport */
- peer->default_outbound_transport = default_primary_transport;
- }
+ if (!peer->default_outbound_transport) {
+ /* Set default set of transports */
+ peer->transports = default_transports;
+ /* Set default primary transport */
+ peer->default_outbound_transport = default_primary_transport;
+ }
- /* The default transport type set during build_peer should only replace the socket.type when...
- * 1. Registration is not present and the socket.type and default transport types are different.
- * 2. The socket.type is not an acceptable transport type after rebuilding peer.
- * 3. The socket.type is not set yet. */
- if (((peer->socket.type != peer->default_outbound_transport) && (peer->expire == -1)) ||
- !(peer->socket.type & peer->transports) || !(peer->socket.type)) {
+ /* The default transport type set during build_peer should only replace the socket.type when...
+ * 1. Registration is not present and the socket.type and default transport types are different.
+ * 2. The socket.type is not an acceptable transport type after rebuilding peer.
+ * 3. The socket.type is not set yet. */
+ if (((peer->socket.type != peer->default_outbound_transport) && (peer->expire == -1)) ||
+ !(peer->socket.type & peer->transports) || !(peer->socket.type)) {
- set_socket_transport(&peer->socket, peer->default_outbound_transport);
- }
+ set_socket_transport(&peer->socket, peer->default_outbound_transport);
+ }
- if (port && !realtime && peer->host_dynamic) {
- peer->defaddr.sin_port = htons(port);
- } else if (port) {
- peer->addr.sin_port = htons(port);
- }
+ if (port && !realtime && peer->host_dynamic) {
+ peer->defaddr.sin_port = htons(port);
+ } else if (port) {
+ peer->addr.sin_port = htons(port);
+ }
- if (ast_str_strlen(fullcontact)) {
- ast_string_field_set(peer, fullcontact, ast_str_buffer(fullcontact));
- peer->rt_fromcontact = TRUE;
- /* We have a hostname in the fullcontact, but if we don't have an
- * address listed on the entry (or if it's 'dynamic'), then we need to
- * parse the entry to obtain the IP address, so a dynamic host can be
- * contacted immediately after reload (as opposed to waiting for it to
- * register once again). But if we have an address for this peer and NAT was
- * specified, use that address instead. */
- /* XXX May need to revisit the final argument; does the realtime DB store whether
- * the original contact was over TLS or not? XXX */
- if (!ast_test_flag(&peer->flags[0], SIP_NAT_ROUTE) || !peer->addr.sin_addr.s_addr) {
- __set_address_from_contact(fullcontact->str, &peer->addr, 0);
- }
+ if (ast_str_strlen(fullcontact)) {
+ ast_string_field_set(peer, fullcontact, ast_str_buffer(fullcontact));
+ peer->rt_fromcontact = TRUE;
+ /* We have a hostname in the fullcontact, but if we don't have an
+ * address listed on the entry (or if it's 'dynamic'), then we need to
+ * parse the entry to obtain the IP address, so a dynamic host can be
+ * contacted immediately after reload (as opposed to waiting for it to
+ * register once again). But if we have an address for this peer and NAT was
+ * specified, use that address instead. */
+ /* XXX May need to revisit the final argument; does the realtime DB store whether
+ * the original contact was over TLS or not? XXX */
+ if (!ast_test_flag(&peer->flags[0], SIP_NAT_ROUTE) || !peer->addr.sin_addr.s_addr) {
+ __set_address_from_contact(fullcontact->str, &peer->addr, 0);
}
+ }
- if (srvlookup && peer->dnsmgr == NULL) {
- char transport[MAXHOSTNAMELEN];
- char _srvlookup[MAXHOSTNAMELEN];
- char *params;
+ if (srvlookup && peer->dnsmgr == NULL) {
+ char transport[MAXHOSTNAMELEN];
+ char _srvlookup[MAXHOSTNAMELEN];
+ char *params;
- ast_copy_string(_srvlookup, srvlookup, sizeof(_srvlookup));
- if ((params = strchr(_srvlookup, ';'))) {
- *params++ = '\0';
- }
+ ast_copy_string(_srvlookup, srvlookup, sizeof(_srvlookup));
+ if ((params = strchr(_srvlookup, ';'))) {
+ *params++ = '\0';
+ }
- snprintf(transport, sizeof(transport), "_sip._%s", get_transport(peer->socket.type));
+ snprintf(transport, sizeof(transport), "_sip._%s", get_transport(peer->socket.type));
- if (ast_dnsmgr_lookup(_srvlookup, &peer->addr, &peer->dnsmgr, sip_cfg.srvlookup && !peer->portinuri ? transport : NULL)) {
- ast_log(LOG_ERROR, "srvlookup failed for host: %s, on peer %s, removing peer\n", _srvlookup, peer->name);
- unref_peer(peer, "getting rid of a peer pointer");
- return NULL;
- }
-
- ast_string_field_set(peer, tohost, srvlookup);
+ if (ast_dnsmgr_lookup(_srvlookup, &peer->addr, &peer->dnsmgr, sip_cfg.srvlookup && !peer->portinuri ? transport : NULL)) {
+ ast_log(LOG_ERROR, "srvlookup failed for host: %s, on peer %s, removing peer\n", _srvlookup, peer->name);
+ unref_peer(peer, "getting rid of a peer pointer");
+ return NULL;
}
- if (!peer->addr.sin_port) {
- peer->addr.sin_port = htons(((peer->socket.type & SIP_TRANSPORT_TLS) ? STANDARD_TLS_PORT : STANDARD_SIP_PORT));
- }
- if (!peer->defaddr.sin_port) {
- peer->defaddr.sin_port = htons(((peer->socket.type & SIP_TRANSPORT_TLS) ? STANDARD_TLS_PORT : STANDARD_SIP_PORT));
- }
- if (!peer->socket.port) {
- peer->socket.port = htons(((peer->socket.type & SIP_TRANSPORT_TLS) ? STANDARD_TLS_PORT : STANDARD_SIP_PORT));
- }
+ ast_string_field_set(peer, tohost, srvlookup);
+ }
- if (!sip_cfg.ignore_regexpire && peer->host_dynamic && realtime) {
- time_t nowtime = time(NULL);
+ if (!peer->addr.sin_port) {
+ peer->addr.sin_port = htons(((peer->socket.type & SIP_TRANSPORT_TLS) ? STANDARD_TLS_PORT : STANDARD_SIP_PORT));
+ }
+ if (!peer->defaddr.sin_port) {
+ peer->defaddr.sin_port = htons(((peer->socket.type & SIP_TRANSPORT_TLS) ? STANDARD_TLS_PORT : STANDARD_SIP_PORT));
+ }
+ if (!peer->socket.port) {
+ peer->socket.port = htons(((peer->socket.type & SIP_TRANSPORT_TLS) ? STANDARD_TLS_PORT : STANDARD_SIP_PORT));
+ }
- if ((nowtime - regseconds) > 0) {
- destroy_association(peer);
- memset(&peer->addr, 0, sizeof(peer->addr));
- peer->lastms = -1;
- ast_debug(1, "Bah, we're expired (%d/%d/%d)!\n", (int)(nowtime - regseconds), (int)regseconds, (int)nowtime);
- }
- }
+ if (!sip_cfg.ignore_regexpire && peer->host_dynamic && realtime) {
+ time_t nowtime = time(NULL);
- /* Startup regular pokes */
- if (realtime && peer->lastms > 0) {
- ref_peer(peer, "schedule qualify");
- sip_poke_peer(peer, 0);
+ if ((nowtime - regseconds) > 0) {
+ destroy_association(peer);
+ memset(&peer->addr, 0, sizeof(peer->addr));
+ peer->lastms = -1;
+ ast_debug(1, "Bah, we're expired (%d/%d/%d)!\n", (int)(nowtime - regseconds), (int)regseconds, (int)nowtime);
}
+ }
- ast_copy_flags(&peer->flags[0], &peerflags[0], mask[0].flags);
- ast_copy_flags(&peer->flags[1], &peerflags[1], mask[1].flags);
- if (ast_test_flag(&peer->flags[1], SIP_PAGE2_ALLOWSUBSCRIBE)) {
- sip_cfg.allowsubscribe = TRUE; /* No global ban any more */
- }
- if (!found && peer->host_dynamic && !peer->is_realtime) {
- reg_source_db(peer);
- }
+ /* Startup regular pokes */
+ if (!devstate_only && realtime && peer->lastms > 0) {
+ ref_peer(peer, "schedule qualify");
+ sip_poke_peer(peer, 0);
+ }
- /* If they didn't request that MWI is sent *only* on subscribe, go ahead and
- * subscribe to it now. */
- if (!ast_test_flag(&peer->flags[1], SIP_PAGE2_SUBSCRIBEMWIONLY) &&
- !AST_LIST_EMPTY(&peer->mailboxes)) {
- add_peer_mwi_subs(peer);
- /* Send MWI from the event cache only. This is so we can send initial
- * MWI if app_voicemail got loaded before chan_sip. If it is the other
- * way, then we will get events when app_voicemail gets loaded. */
- sip_send_mwi_to_peer(peer, NULL, 1);
- }
+ ast_copy_flags(&peer->flags[0], &peerflags[0], mask[0].flags);
+ ast_copy_flags(&peer->flags[1], &peerflags[1], mask[1].flags);
+ if (ast_test_flag(&peer->flags[1], SIP_PAGE2_ALLOWSUBSCRIBE)) {
+ sip_cfg.allowsubscribe = TRUE; /* No global ban any more */
+ }
+ if (!found && peer->host_dynamic && !peer->is_realtime) {
+ reg_source_db(peer);
+ }
+
+ /* If they didn't request that MWI is sent *only* on subscribe, go ahead and
+ * subscribe to it now. */
+ if (!devstate_only && !ast_test_flag(&peer->flags[1], SIP_PAGE2_SUBSCRIBEMWIONLY) &&
+ !AST_LIST_EMPTY(&peer->mailboxes)) {
+ add_peer_mwi_subs(peer);
+ /* Send MWI from the event cache only. This is so we can send initial
+ * MWI if app_voicemail got loaded before chan_sip. If it is the other
+ * way, then we will get events when app_voicemail gets loaded. */
+ sip_send_mwi_to_peer(peer, NULL, 1);
}
peer->the_mark = 0;