#include "my_config.h"
#include <sys/types.h>
#include <list>
#include <memory>
#include "my_hostname.h"
#include "my_inttypes.h"
#include "mysql_com.h"
#include <netinet/in.h>
 
Go to the source code of this file.
◆ HOST_ENTRY_KEY_SIZE
      
        
          | #define HOST_ENTRY_KEY_SIZE   INET6_ADDRSTRLEN | 
        
      
 
Size of IP address string in the hash cache. 
 
 
◆ RC_BLOCKED_HOST
      
        
          | #define RC_BLOCKED_HOST   1 | 
        
      
 
 
◆ RC_LONG_HOSTNAME
      
        
          | #define RC_LONG_HOSTNAME   2 | 
        
      
 
 
◆ RC_OK
◆ hostname_cache_begin()
      
        
          | std::list< std::unique_ptr< Host_entry > >::iterator hostname_cache_begin  | 
          ( | 
           | ) | 
           | 
        
      
 
 
◆ hostname_cache_end()
      
        
          | std::list< std::unique_ptr< Host_entry > >::iterator hostname_cache_end  | 
          ( | 
           | ) | 
           | 
        
      
 
 
◆ hostname_cache_free()
      
        
          | void hostname_cache_free  | 
          ( | 
           | ) | 
           | 
        
      
 
 
◆ hostname_cache_init()
      
        
          | bool hostname_cache_init  | 
          ( | 
          uint  | 
          size | ) | 
           | 
        
      
 
 
◆ hostname_cache_lock()
      
        
          | void hostname_cache_lock  | 
          ( | 
           | ) | 
           | 
        
      
 
 
◆ hostname_cache_refresh()
      
        
          | void hostname_cache_refresh  | 
          ( | 
          void  | 
           | ) | 
           | 
        
      
 
 
◆ hostname_cache_resize()
      
        
          | void hostname_cache_resize  | 
          ( | 
          uint  | 
          size | ) | 
           | 
        
      
 
 
◆ hostname_cache_size()
      
        
          | uint hostname_cache_size  | 
          ( | 
           | ) | 
           | 
        
      
 
 
◆ hostname_cache_unlock()
      
        
          | void hostname_cache_unlock  | 
          ( | 
           | ) | 
           | 
        
      
 
 
◆ inc_host_errors()
      
        
          | void inc_host_errors  | 
          ( | 
          const char *  | 
          ip_string,  | 
        
        
           | 
           | 
          Host_errors *  | 
          errors  | 
        
        
           | 
          ) | 
           |  | 
        
      
 
 
◆ ip_to_hostname()
      
        
          | int ip_to_hostname  | 
          ( | 
          struct sockaddr_storage *  | 
          ip_storage,  | 
        
        
           | 
           | 
          const char *  | 
          ip_string,  | 
        
        
           | 
           | 
          char **  | 
          hostname,  | 
        
        
           | 
           | 
          uint *  | 
          connect_errors  | 
        
        
           | 
          ) | 
           |  | 
        
      
 
Resolve IP-address to host name. 
This function does the following things:
- resolves IP-address;
 
- employs Forward Confirmed Reverse DNS technique to validate IP-address;
 
- returns host name if IP-address is validated;
 
- set value to out-variable connect_errors – this variable represents the number of connection errors from the specified IP-address.
 
- update the host_cache statistics
 
NOTE: connect_errors are counted (are supported) only for the clients where IP-address can be resolved and FCrDNS check is passed.
- Parameters
 - 
  
    | [in] | ip_storage | IP address (sockaddr). Must be set.  | 
    | [in] | ip_string | IP address (string). Must be set.  | 
    | [out] | hostname | Hostname if IP-address is valid.  | 
    | [out] | connect_errors | Represents number of connection errors. | 
  
   
- Returns
 - Error status 
 
- Return values
 - 
  
    | 0 | Success  | 
    | RC_BLOCKED_HOST | The host is blocked.  | 
    | RC_LONG_HOSTNAME | The hostname is longer than HOSTNAME_LENGTH. | 
  
   
The function does not set/report MySQL server error in case of failure. It's caller's responsibility to handle failures of this function properly. 
 
 
◆ reset_host_connect_errors()
      
        
          | void reset_host_connect_errors  | 
          ( | 
          const char *  | 
          ip_string | ) | 
           |