Skip to content
Snippets Groups Projects
acl.c 26.3 KiB
Newer Older
  • Learn to ignore specific revisions
  • 	int res, port = ast_sockaddr_port(ourip);
    
    
    	/* just use the bind address if it is nonzero */
    
    Mark Michelson's avatar
    Mark Michelson committed
    	if (!ast_sockaddr_is_any(bindaddr)) {
    		ast_sockaddr_copy(ourip, bindaddr);
    
    		ast_debug(3, "Attached to given IP address\n");
    
    		return 0;
    	}
    	/* try to use our hostname */
    
    	if (gethostname(ourhost, sizeof(ourhost) - 1)) {
    
    		ast_log(LOG_WARNING, "Unable to get hostname\n");
    	} else {
    
    		if (resolve_first(ourip, ourhost, PARSE_PORT_FORBID, family) == 0) {
    
    			/* reset port since resolve_first wipes this out */
    			ast_sockaddr_set_port(ourip, port);
    
    	ast_debug(3, "Trying to check A.ROOT-SERVERS.NET and get our IP address for that connection\n");
    
    	/* A.ROOT-SERVERS.NET. */
    
    Mark Michelson's avatar
    Mark Michelson committed
    	if (!resolve_first(&root, "A.ROOT-SERVERS.NET", PARSE_PORT_FORBID, 0) &&
    	    !ast_ouraddrfor(&root, ourip)) {
    
    		/* reset port since resolve_first wipes this out */
    		ast_sockaddr_set_port(ourip, port);
    
    	res = get_local_address(ourip);
    	ast_sockaddr_set_port(ourip, port);
    	return res;