1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
Index: channels/chan_sip.c
===================================================================
--- a/channels/chan_sip.c (revision 351503)
+++ b/channels/chan_sip.c (working copy)
@@ -13246,17 +13246,8 @@
}
if (r->dnsmgr) {
- struct sip_peer *peer;
/* If the registration has timed out, maybe the IP changed. Force a refresh. */
ast_dnsmgr_refresh(r->dnsmgr);
- /* If we are resolving a peer, we have to make sure the refreshed address gets copied */
- if ((peer = sip_find_peer(r->hostname, NULL, TRUE, FINDPEERS, FALSE, 0))) {
- ast_sockaddr_copy(&peer->addr, &r->us);
- if (r->portno) {
- ast_sockaddr_set_port(&peer->addr, r->portno);
- }
- peer = sip_unref_peer(peer, "unref after sip_find_peer");
- }
}
/* If the initial tranmission failed, we may not have an existing dialog,
@@ -13371,15 +13362,15 @@
}
/* Use port number specified if no SRV record was found */
- if (!ast_sockaddr_port(&r->us) && r->portno) {
+ if (!ast_sockaddr_isnull(&r->us) && !ast_sockaddr_port(&r->us) && r->portno) {
ast_sockaddr_set_port(&r->us, r->portno);
}
/* It is possible that DNS is unavailable at the time the peer is created. Here, if
* we've updated the address in the registry, we copy it to the peer so that
* create_addr() can copy it to the dialog via create_addr_from_peer */
- if ((peer = sip_find_peer(r->hostname, NULL, TRUE, FINDPEERS, FALSE, 0))) {
- if (ast_sockaddr_isnull(&peer->addr) && !(ast_sockaddr_isnull(&r->us))) {
+ if ((peer = sip_find_peer(S_OR(r->peername, r->hostname), NULL, TRUE, FINDPEERS, FALSE, 0))) {
+ if ((ast_sockaddr_isnull(&peer->addr) || !ast_sockaddr_port(&peer->addr)) && !(ast_sockaddr_isnull(&r->us))) {
ast_sockaddr_copy(&peer->addr, &r->us);
}
peer = sip_unref_peer(peer, "unref after sip_find_peer");
@@ -14244,7 +14235,7 @@
/* Don't trust the contact field. Just use what they came to us
with */
ast_debug(1, "Store REGISTER's src-IP:port for call routing.\n");
- peer->addr = pvt->recv;
+ ast_sockaddr_copy(&peer->addr, &pvt->recv);
}
/* Check that they're allowed to register at this IP */
|