mirror of
https://github.com/asterisk/asterisk.git
synced 2025-11-08 19:08:14 +00:00
Backport Appropiate NAT Setting Cleanup
In ASTERISK-20904, the focus was around the changes to NAT that took place in
Asterisk 11. Since the report stated that 1.8 was fine, we didn't take a look
at 1.8 at the time.
While working on ASTERISK-21225, I could see that 1.8 would benefit from having
some of those changes applied to it.
This patch does the following:
* The important part of this patch is that it sets the peer's flags earlier in
build_peer so that the code properly uses the peer's flags based on the peer's
configuration.
* constify req parameter in check_via()
* update realtime schemas under the contrib directory to handle properly the NAT
settings available in 1.8 as well as to handle the changes made in 11 to make
upgrading easier when installing newer versions of Asterisk
(closes issue ASTERISK-21243)
Reported by: Michael L. Young
Patches:
asterisk-20904-changes_for_1.8.diff Michael L. Young (license 5026)
Review: https://reviewboard.asterisk.org/r/2422/
git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.8@384779 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
@@ -1491,7 +1491,7 @@ static int get_refer_info(struct sip_pvt *transferer, struct sip_request *outgoi
|
||||
static int get_also_info(struct sip_pvt *p, struct sip_request *oreq);
|
||||
static int parse_ok_contact(struct sip_pvt *pvt, struct sip_request *req);
|
||||
static int set_address_from_contact(struct sip_pvt *pvt);
|
||||
static void check_via(struct sip_pvt *p, struct sip_request *req);
|
||||
static void check_via(struct sip_pvt *p, const struct sip_request *req);
|
||||
static int get_rpid(struct sip_pvt *p, struct sip_request *oreq);
|
||||
static int get_rdnis(struct sip_pvt *p, struct sip_request *oreq, char **name, char **number, int *reason);
|
||||
static enum sip_get_dest_result get_destination(struct sip_pvt *p, struct sip_request *oreq, int *cc_recall_core_id);
|
||||
@@ -16448,7 +16448,7 @@ static attribute_unused void check_via_response(struct sip_pvt *p, struct sip_re
|
||||
}
|
||||
|
||||
/*! \brief check Via: header for hostname, port and rport request/answer */
|
||||
static void check_via(struct sip_pvt *p, struct sip_request *req)
|
||||
static void check_via(struct sip_pvt *p, const struct sip_request *req)
|
||||
{
|
||||
char via[512];
|
||||
char *c, *maddr;
|
||||
@@ -26077,7 +26077,10 @@ static int handle_request_do(struct sip_request *req, struct ast_sockaddr *addr)
|
||||
owner_chan_ref = sip_pvt_lock_full(p);
|
||||
|
||||
copy_socket_data(&p->socket, &req->socket);
|
||||
ast_sockaddr_copy(&p->recv, addr);
|
||||
|
||||
if (ast_sockaddr_isnull(&p->recv)) { /* This may already be set before getting here */
|
||||
ast_sockaddr_copy(&p->recv, addr);
|
||||
}
|
||||
|
||||
/* if we have an owner, then this request has been authenticated */
|
||||
if (p->owner) {
|
||||
@@ -28147,7 +28150,7 @@ static struct sip_peer *build_peer(const char *name, struct ast_variable *v, str
|
||||
} else if (!strcasecmp(v->name, "host")) {
|
||||
if (!strcasecmp(v->value, "dynamic")) {
|
||||
/* They'll register with us */
|
||||
if ((!found && !realtime) || !peer->host_dynamic) {
|
||||
if ((!found && !ast_test_flag(&global_flags[1], SIP_PAGE2_RTCACHEFRIENDS)) || !peer->host_dynamic) {
|
||||
/* Initialize stuff if this is a new peer, or if it used to
|
||||
* not be dynamic before the reload. */
|
||||
ast_sockaddr_setnull(&peer->addr);
|
||||
@@ -28467,6 +28470,10 @@ static struct sip_peer *build_peer(const char *name, struct ast_variable *v, str
|
||||
set_socket_transport(&peer->socket, peer->default_outbound_transport);
|
||||
}
|
||||
|
||||
ast_copy_flags(&peer->flags[0], &peerflags[0], mask[0].flags);
|
||||
ast_copy_flags(&peer->flags[1], &peerflags[1], mask[1].flags);
|
||||
ast_copy_flags(&peer->flags[2], &peerflags[2], mask[2].flags);
|
||||
|
||||
if (ast_str_strlen(fullcontact)) {
|
||||
ast_string_field_set(peer, fullcontact, ast_str_buffer(fullcontact));
|
||||
peer->rt_fromcontact = TRUE;
|
||||
@@ -28560,9 +28567,6 @@ static struct sip_peer *build_peer(const char *name, struct ast_variable *v, str
|
||||
sip_poke_peer(peer, 0);
|
||||
}
|
||||
|
||||
ast_copy_flags(&peer->flags[0], &peerflags[0], mask[0].flags);
|
||||
ast_copy_flags(&peer->flags[1], &peerflags[1], mask[1].flags);
|
||||
ast_copy_flags(&peer->flags[2], &peerflags[2], mask[2].flags);
|
||||
if (ast_test_flag(&peer->flags[1], SIP_PAGE2_ALLOWSUBSCRIBE)) {
|
||||
sip_cfg.allowsubscribe = TRUE; /* No global ban any more */
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ CREATE TABLE IF NOT EXISTS `sippeers` (
|
||||
`transport` enum('udp','tcp','udp,tcp','tcp,udp') DEFAULT NULL,
|
||||
`dtmfmode` enum('rfc2833','info','shortinfo','inband','auto') DEFAULT NULL,
|
||||
`directmedia` enum('yes','no','nonat','update') DEFAULT NULL,
|
||||
`nat` enum('yes','no','never','route') DEFAULT NULL,
|
||||
`nat` varchar(29) DEFAULT NULL,
|
||||
`callgroup` varchar(40) DEFAULT NULL,
|
||||
`pickupgroup` varchar(40) DEFAULT NULL,
|
||||
`language` varchar(40) DEFAULT NULL,
|
||||
|
||||
@@ -48,7 +48,7 @@ insecure character varying(4),
|
||||
"language" character varying(2),
|
||||
mailbox character varying(50),
|
||||
md5secret character varying(80),
|
||||
nat character varying(5) DEFAULT 'no' NOT NULL,
|
||||
nat character varying(29) DEFAULT '' NOT NULL,
|
||||
permit character varying(95),
|
||||
deny character varying(95),
|
||||
mask character varying(95),
|
||||
|
||||
Reference in New Issue
Block a user