From 329e11194712b3effe92c8bdfc47acb565be371a Mon Sep 17 00:00:00 2001 From: Walter Doekes Date: Tue, 5 Sep 2017 16:16:01 +0200 Subject: res/res_pjsip: Standardize/fix localnet checks across pjsip. In 2dee95cc (ASTERISK-27024) and 776ffd77 (ASTERISK-26879) there was confusion about whether the transport_state->localnet ACL has ALLOW or DENY semantics. For the record: the localnet has DENY semantics, meaning that "not in the list" means ALLOW, and the local nets are in the list. Therefore, checks like this look wrong, but are right: /* See if where we are sending this request is local or not, and if not that we can get a Contact URI to modify */ if (ast_apply_ha(transport_state->localnet, &addr) != AST_SENSE_ALLOW) { ast_debug(5, "Request is being sent to local address, " "skipping NAT manipulation\n"); (In the list == localnet == DENY == skip NAT manipulation.) And conversely, other checks that looked right, were wrong. This change adds two macro's to reduce the confusion and uses those instead: ast_sip_transport_is_nonlocal(transport_state, addr) ast_sip_transport_is_local(transport_state, addr) ASTERISK-27248 #close Change-Id: Ie7767519eb5a822c4848e531a53c0fd054fae934 --- main/acl.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'main/acl.c') diff --git a/main/acl.c b/main/acl.c index 31945676b..6868ea12e 100644 --- a/main/acl.c +++ b/main/acl.c @@ -737,8 +737,8 @@ enum ast_acl_sense ast_apply_ha(const struct ast_ha *ha, const struct ast_sockad char iabuf[INET_ADDRSTRLEN]; char iabuf2[INET_ADDRSTRLEN]; /* DEBUG */ - ast_copy_string(iabuf, ast_inet_ntoa(sin->sin_addr), sizeof(iabuf)); - ast_copy_string(iabuf2, ast_inet_ntoa(ha->netaddr), sizeof(iabuf2)); + ast_copy_string(iabuf, ast_sockaddr_stringify(addr), sizeof(iabuf)); + ast_copy_string(iabuf2, ast_sockaddr_stringify(¤t_ha->addr), sizeof(iabuf2)); ast_debug(1, "##### Testing %s with %s\n", iabuf, iabuf2); #endif if (ast_sockaddr_is_ipv4(¤t_ha->addr)) { -- cgit v1.2.3