My Project
Functions File Reference

Get hostname for an IP address. More...

#include "my_global.h"
#include "sql_priv.h"
#include "hostname.h"
#include "hash_filo.h"
#include <m_ctype.h>
#include "log.h"
#include "violite.h"
#include <sys/utsname.h>


void hostname_cache_refresh ()
uint hostname_cache_size ()
void hostname_cache_resize (uint size)
bool hostname_cache_init (uint size)
void hostname_cache_free ()
void hostname_cache_lock ()
void hostname_cache_unlock ()
Host_entryhostname_cache_first ()
void inc_host_errors (const char *ip_string, Host_errors *errors)
void reset_host_connect_errors (const char *ip_string)
int ip_to_hostname (struct sockaddr_storage *ip_storage, const char *ip_string, char **hostname, uint *connect_errors)

Detailed Description

Get hostname for an IP address.

Hostnames are checked with reverse name lookup and checked that they doesn't resemble an IP address.

Function Documentation

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.

[in]ip_storageIP address (sockaddr). Must be set.
[in]ip_stringIP address (string). Must be set.
Error status
Return values:
RC_BLOCKED_HOSTThe host is blocked.

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.

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines