int url_IsSameServer(const URLInfo* u1, const URLInfo* u2, int index) { if (u1->port != u2->port) { return 0; } return apr_sockaddr_equal(getConn(u1, index), getConn(u2, index)); }
static apr_status_t cpe_filter_localhost(apr_sockaddr_t *incoming) { if (apr_sockaddr_equal(incoming, g_cpe_sockaddr_localhost)) { return APR_SUCCESS; } return APR_EGENERAL; }
static authz_status local_check_authorization(request_rec *r, const char *require_line, const void *parsed_require_line) { if ( apr_sockaddr_equal(r->connection->local_addr, r->useragent_addr) || apr_ipsubnet_test(localhost_v4, r->useragent_addr) #if APR_HAVE_IPV6 || apr_ipsubnet_test(localhost_v6, r->useragent_addr) #endif ) { return AUTHZ_GRANTED; } return AUTHZ_DENIED; }
static mrcp_connection_t* mrcp_client_agent_connection_find(mrcp_connection_agent_t *agent, mrcp_control_descriptor_t *descriptor) { apr_sockaddr_t *sockaddr; mrcp_connection_t *connection; for(connection = APR_RING_FIRST(&agent->connection_list); connection != APR_RING_SENTINEL(&agent->connection_list, mrcp_connection_t, link); connection = APR_RING_NEXT(connection, link)) { if(apr_sockaddr_info_get(&sockaddr,descriptor->ip.buf,APR_INET,descriptor->port,0,connection->pool) == APR_SUCCESS) { if(apr_sockaddr_equal(sockaddr,connection->r_sockaddr) != 0 && descriptor->port == connection->r_sockaddr->port) { return connection; } } } return NULL; }
static mrcp_connection_t* mrcp_client_agent_connection_find(mrcp_connection_agent_t *agent, mrcp_control_descriptor_t *descriptor) { apr_sockaddr_t *sockaddr; mrcp_connection_t *connection = NULL; apt_list_elem_t *elem = apt_list_first_elem_get(agent->connection_list); /* walk through the list of connections */ while(elem) { connection = apt_list_elem_object_get(elem); if(connection) { if(apr_sockaddr_info_get(&sockaddr,descriptor->ip.buf,APR_INET,descriptor->port,0,connection->pool) == APR_SUCCESS) { if(apr_sockaddr_equal(sockaddr,connection->sockaddr) != 0) { return connection; } } } elem = apt_list_next_elem_get(agent->connection_list,elem); } return NULL; }
SWITCH_DECLARE(int) switch_sockaddr_equal(const switch_sockaddr_t *sa1, const switch_sockaddr_t *sa2) { return apr_sockaddr_equal(sa1, sa2); }
static authz_status forward_dns_check_authorization(request_rec *r, const char *require_line, const void *parsed_require_line) { const char *err = NULL; const ap_expr_info_t *expr = parsed_require_line; const char *require, *t; char *w; /* the require line is an expression, which is evaluated now. */ require = ap_expr_str_exec(r, expr, &err); if (err) { ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(03354) "authz_host authorize: require forward-dns: " "Can't evaluate require expression: %s", err); return AUTHZ_DENIED; } /* tokenize expected list of names */ t = require; while ((w = ap_getword_conf(r->pool, &t)) && w[0]) { apr_sockaddr_t *sa; apr_status_t rv; char *hash_ptr; /* stop on apache configuration file comments */ if ((hash_ptr = ap_strchr(w, '#'))) { if (hash_ptr == w) { break; } *hash_ptr = '\0'; } /* does the client ip match one of the names? */ rv = apr_sockaddr_info_get(&sa, w, APR_UNSPEC, 0, 0, r->pool); if (rv == APR_SUCCESS) { while (sa) { int match = apr_sockaddr_equal(sa, r->useragent_addr); ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, APLOGNO(03355) "access check for %s as '%s': %s", r->useragent_ip, w, match? "yes": "no"); if (match) { return AUTHZ_GRANTED; } sa = sa->next; } } else { ap_log_rerror(APLOG_MARK, APLOG_WARNING, 0, r, APLOGNO(03356) "No sockaddr info for \"%s\"", w); } /* stop processing, we are in a comment */ if (hash_ptr) { break; } } return AUTHZ_DENIED; }