File host_lookup.c¶
FileList > connection > host_lookup.c
Go to the source code of this file
#include <stdio.h>#include <stdlib.h>#include <math.h>#include <string.h>#include <limits.h>#include <errno.h>#include <unordered_map>#include <arpa/inet.h>#include <netdb.h>#include <pthread.h>#include "host_lookup.h"#include "porting.h"#include "system_parameter.h"#include "environment_variable.h"#include "message_catalog.h"#include "memory_wrapper.hpp"
Public Types¶
| Type | Name |
|---|---|
| enum | HOSTENT_INSERT_TYPE |
| enum | HOSTS_CONF_LOAD_STATUS |
| enum | HOST_LOOKUP_TYPE |
| enum | LOOKUP_TYPE |
Public Attributes¶
| Type | Name |
|---|---|
| return_phase | __pad0__ |
else = /* multi line expression */ |
Public Static Attributes¶
| Type | Name |
|---|---|
| struct hostent * | hostent_Cache |
| std::unordered_map< std::string, int > | user_host_Map |
Public Functions¶
| Type | Name |
|---|---|
| void | freeaddrinfo_uhost (struct addrinfo * res) |
| int | getaddrinfo_uhost (char * node, char * service, struct addrinfo * hints, struct addrinfo ** res) |
| struct hostent * | gethostbyname_uhost (const char * name) |
| int | getnameinfo_uhost (struct sockaddr * addr, socklen_t addrlen, char * host, size_t hostlen, char * serv, size_t servlen, int flags) |
| if (prm_get_bool_value(PRM_ID_USE_USER_HOSTS)==USE_GLIBC_HOSTS) |
|
| bool | validate_uhost_conf (void) |
Public Static Functions¶
| Type | Name |
|---|---|
| int | add_user_host_map (const char * ipaddr, const char * hostname, int cache_idx) |
| bool | handle_uhost_conf (int action_type) |
| struct hostent * | host_lookup_internal (const char * hostname, struct sockaddr * saddr, LOOKUP_TYPE lookup_type) |
| struct hostent * | hostent_alloc (const char * ipaddr, const char * hostname) |
| int | is_valid_fqdn (const char * fqdn) |
| bool | is_valid_ipv4 (const char * ip_addr) |
| int | is_valid_label (const char * label) |
| int | load_hosts_file (void) |
| void | strcpy_ucase (char * dst, size_t len, const char * src) |
Macros¶
| Type | Name |
|---|---|
| define | ADD_ENTRY_SUCCESS 0 |
| define | CUBRID_HOSTS_CONF "cubrid\_hosts.conf" |
| define | DUPLICATE_ENTRY 1 |
| define | ERROR_ALLOC -1 |
| define | FREE_MEM (PTR) /* multi line expression */ |
| define | HOSTNAME_LEN (256) |
| define | IPADDR_LEN (17) |
| define | IPv4_ADDR_LEN (4) |
| define | LINE_BUF_SIZE (512) |
| define | MALLOC (SIZE) [**malloc**](memory__cwrapper_8h.md#define-malloc)(SIZE) |
| define | MAX_FQDN_LEN (255) |
| define | MAX_LABEL_LEN (63) |
| define | MAX_NUM_HOSTS (256) |
| define | MAX_NUM_IPADDR_PER_HOST (1) |
| define | MTIME_DIGITS (10) |
| define | NUM_DIGIT (VAL) ([**size\_t**](broker__monitor_8c.md#function-timeout))([**log10**](broker__monitor_8c.md#function-timeout) ([**VAL**](broker__monitor_8c.md#function-timeout)) + 1) |
| define | NUM_IPADDR_DOT (3) |
| define | UHOST_CONF_LOAD 2 |
| define | UHOST_CONF_VALID_CHECK 1 |
Public Types Documentation¶
enum HOSTENT_INSERT_TYPE¶
enum HOSTS_CONF_LOAD_STATUS¶
enum HOST_LOOKUP_TYPE¶
enum LOOKUP_TYPE¶
Public Attributes Documentation¶
variable __pad0__¶
variable else¶
Public Static Attributes Documentation¶
variable hostent_Cache¶
variable user_host_Map¶
Public Functions Documentation¶
function freeaddrinfo_uhost¶
function getaddrinfo_uhost¶
int getaddrinfo_uhost (
char * node,
char * service,
struct addrinfo * hints,
struct addrinfo ** res
)
function gethostbyname_uhost¶
function getnameinfo_uhost¶
int getnameinfo_uhost (
struct sockaddr * addr,
socklen_t addrlen,
char * host,
size_t hostlen,
char * serv,
size_t servlen,
int flags
)
function if¶
function validate_uhost_conf¶
Public Static Functions Documentation¶
function add_user_host_map¶
Adds a valid IP and hostname to the user_host_Map and updates the cache.
function handle_uhost_conf¶
This function processes the uhosts.conf file based on the specified action_type. It can either:
* Load the IP addresses and hostnames from the configuration file into the user_host_Map.
* Check the validity of the IP addresses and hostnames in the configuration file.
- UHOST_CONF_VALID_CHECK: Validates the IP addresses and hostnames in the cubrid_uhosts.conf file.
- UHOST_CONF_LOAD: Loads the valid IP addresses and hostnames.
function host_lookup_internal¶
static struct hostent * host_lookup_internal (
const char * hostname,
struct sockaddr * saddr,
LOOKUP_TYPE lookup_type
)
function hostent_alloc¶
function is_valid_fqdn¶
Checks if a given string is a valid Fully Qualified Domain Name (FQDN).
An FQDN must: * Not exceed 253 characters in length. * Have labels that are 1 to 63 characters long. * Contain only alphanumeric characters and hyphens. * Not start or end with a hyphen in any label. * Not be empty or NULL.
function is_valid_ipv4¶
function is_valid_label¶
function load_hosts_file¶
function strcpy_ucase¶
Macro Definition Documentation¶
define ADD_ENTRY_SUCCESS¶
define CUBRID_HOSTS_CONF¶
define DUPLICATE_ENTRY¶
define ERROR_ALLOC¶
define FREE_MEM¶
define HOSTNAME_LEN¶
define IPADDR_LEN¶
define IPv4_ADDR_LEN¶
define LINE_BUF_SIZE¶
define MALLOC¶
define MAX_FQDN_LEN¶
define MAX_LABEL_LEN¶
define MAX_NUM_HOSTS¶
define MAX_NUM_IPADDR_PER_HOST¶
define MTIME_DIGITS¶
define NUM_DIGIT¶
define NUM_IPADDR_DOT¶
define UHOST_CONF_LOAD¶
define UHOST_CONF_VALID_CHECK¶
The documentation for this class was generated from the following file cubrid/src/connection/host_lookup.c