The article represents the approach suitable for the electronic circuit of the hierarchical clustering and division. The concept is complemented with the representation of fuzzy clustering. Each login server will connect you to the same realm, but the path that each server takes is geographically different. This means that you can try each realmlist and see which one provides you with the lowest latency. You should be able to connect to Kronos now.
PermalinkJoin GitHub today
GitHub is home to over 36 million developers working together to host and review code, manage projects, and build software together.
Sign up
Find file Copy path
Cannot retrieve contributors at this time
/* Copyright 1998, 2009 by the Massachusetts Institute of Technology. |
* Copyright (C) 2007-2011 by Daniel Stenberg |
* |
* Permission to use, copy, modify, and distribute this |
* software and its documentation for any purpose and without |
* fee is hereby granted, provided that the above copyright |
* notice appear in all copies and that both that copyright |
* notice and this permission notice appear in supporting |
* documentation, and that the name of M.I.T. not be used in |
* advertising or publicity pertaining to distribution of the |
* software without specific, written prior permission. |
* M.I.T. makes no representations about the suitability of |
* this software for any purpose. It is provided 'as is' |
* without express or implied warranty. |
*/ |
#ifndef ARES__H |
#defineARES__H |
#include'ares_version.h'/* c-ares version defines */ |
/* |
* Define WIN32 when build target is Win32 API |
*/ |
#if (defined(_WIN32) || defined(__WIN32__)) && |
!defined(WIN32) && !defined(__SYMBIAN32__) |
# defineWIN32 |
#endif |
/*************************** libuv patch ***************/ |
/* |
* We want to avoid autoconf altogether since there are a finite number of |
* operating systems and simply build c-ares. Therefore we do not want the |
* configurations provided by ares_build.h since we are always statically |
* linking c-ares into libuv. Having a system dependent ares_build.h forces |
* all users of ares.h to include the correct ares_build.h. We do not care |
* about the linking checks provided by ares_rules.h. This would complicate |
* the libuv build process. |
*/ |
#if defined(WIN32) |
/* Configure process defines this to 1 when it finds out that system */ |
/* header file ws2tcpip.h must be included by the external interface. */ |
/* #undef CARES_PULL_WS2TCPIP_H */ |
# include<winsock2.h> |
# include<ws2tcpip.h> |
# include<windows.h> |
#else/* Not Windows */ |
# include<sys/time.h> |
# include<sys/types.h> |
# include<sys/socket.h> |
#endif |
#if0 |
/* The size of `long', as computed by sizeof. */ |
#define CARES_SIZEOF_LONG 4 |
#endif |
/* Integral data type used for ares_socklen_t. */ |
#defineCARES_TYPEOF_ARES_SOCKLEN_Tsocklen_t |
#if0 |
/* The size of `ares_socklen_t', as computed by sizeof. */ |
#define CARES_SIZEOF_ARES_SOCKLEN_T 4 |
#endif |
/* Data type definition of ares_socklen_t. */ |
typedefintares_socklen_t; |
#if0 /* libuv disabled */ |
#include 'ares_rules.h' /* c-ares rules enforcement */ |
#endif |
/*********************** end libuv patch ***************/ |
#include<sys/types.h> |
/* HP-UX systems version 9, 10 and 11 lack sys/select.h and so does oldish |
libc5-based Linux systems. Only include it on system that are known to |
require it! */ |
#if defined(_AIX) || defined(__NOVELL_LIBC__) || defined(__NetBSD__) || |
defined(__minix) || defined(__SYMBIAN32__) || defined(__INTEGRITY) || |
defined(ANDROID) || defined(__ANDROID__) |
#include<sys/select.h> |
#endif |
#if (defined(NETWARE) && !defined(__NOVELL_LIBC__)) |
#include<sys/bsdskt.h> |
#endif |
#if defined(WATT32) |
# include<netinet/in.h> |
# include<sys/socket.h> |
# include<tcp.h> |
#elif defined(_WIN32_WCE) |
# ifndef WIN32_LEAN_AND_MEAN |
# defineWIN32_LEAN_AND_MEAN |
# endif |
# include<windows.h> |
# include<winsock.h> |
#elif defined(WIN32) |
# ifndef WIN32_LEAN_AND_MEAN |
# defineWIN32_LEAN_AND_MEAN |
# endif |
# include<windows.h> |
# include<winsock2.h> |
# include<ws2tcpip.h> |
#else |
# include<sys/socket.h> |
# include<netinet/in.h> |
#endif |
#ifdef __cplusplus |
extern'C' { |
#endif |
/* |
** c-ares external API function linkage decorations. |
*/ |
#if !defined(CARES_STATICLIB) && |
(defined(WIN32) || defined(_WIN32) || defined(__SYMBIAN32__)) |
/* __declspec function decoration for Win32 and Symbian DLL's */ |
# if defined(CARES_BUILDING_LIBRARY) |
# defineCARES_EXTERN__declspec(dllexport) |
# else |
# defineCARES_EXTERN__declspec(dllimport) |
# endif |
#else |
/* visibility function decoration for other cases */ |
# if !defined(CARES_SYMBOL_HIDING) || |
defined(WIN32) || defined(_WIN32) || defined(__SYMBIAN32__) |
# defineCARES_EXTERN |
# else |
# defineCARES_EXTERN CARES_SYMBOL_SCOPE_EXTERN |
# endif |
#endif |
#defineARES_SUCCESS0 |
/* Server error codes (ARES_ENODATA indicates no relevant answer) */ |
#defineARES_ENODATA1 |
#defineARES_EFORMERR2 |
#defineARES_ESERVFAIL3 |
#defineARES_ENOTFOUND4 |
#defineARES_ENOTIMP5 |
#defineARES_EREFUSED6 |
/* Locally generated error codes */ |
#defineARES_EBADQUERY7 |
#defineARES_EBADNAME8 |
#defineARES_EBADFAMILY9 |
#defineARES_EBADRESP10 |
#defineARES_ECONNREFUSED11 |
#defineARES_ETIMEOUT12 |
#defineARES_EOF13 |
#defineARES_EFILE14 |
#defineARES_ENOMEM15 |
#defineARES_EDESTRUCTION16 |
#defineARES_EBADSTR17 |
/* ares_getnameinfo error codes */ |
#defineARES_EBADFLAGS18 |
/* ares_getaddrinfo error codes */ |
#defineARES_ENONAME19 |
#defineARES_EBADHINTS20 |
/* Uninitialized library error code */ |
#defineARES_ENOTINITIALIZED21/* introduced in 1.7.0 */ |
/* ares_library_init error codes */ |
#defineARES_ELOADIPHLPAPI22/* introduced in 1.7.0 */ |
#defineARES_EADDRGETNETWORKPARAMS23/* introduced in 1.7.0 */ |
/* More error codes */ |
#defineARES_ECANCELLED24/* introduced in 1.7.0 */ |
/* Flag values */ |
#defineARES_FLAG_USEVC (1 << 0) |
#defineARES_FLAG_PRIMARY (1 << 1) |
#defineARES_FLAG_IGNTC (1 << 2) |
#defineARES_FLAG_NORECURSE (1 << 3) |
#defineARES_FLAG_STAYOPEN (1 << 4) |
#defineARES_FLAG_NOSEARCH (1 << 5) |
#defineARES_FLAG_NOALIASES (1 << 6) |
#defineARES_FLAG_NOCHECKRESP (1 << 7) |
/* Option mask values */ |
#defineARES_OPT_FLAGS (1 << 0) |
#defineARES_OPT_TIMEOUT (1 << 1) |
#defineARES_OPT_TRIES (1 << 2) |
#defineARES_OPT_NDOTS (1 << 3) |
#defineARES_OPT_UDP_PORT (1 << 4) |
#defineARES_OPT_TCP_PORT (1 << 5) |
#defineARES_OPT_SERVERS (1 << 6) |
#defineARES_OPT_DOMAINS (1 << 7) |
#defineARES_OPT_LOOKUPS (1 << 8) |
#defineARES_OPT_SOCK_STATE_CB (1 << 9) |
#defineARES_OPT_SORTLIST (1 << 10) |
#defineARES_OPT_SOCK_SNDBUF (1 << 11) |
#defineARES_OPT_SOCK_RCVBUF (1 << 12) |
#defineARES_OPT_TIMEOUTMS (1 << 13) |
#defineARES_OPT_ROTATE (1 << 14) |
/* Nameinfo flag values */ |
#defineARES_NI_NOFQDN (1 << 0) |
#defineARES_NI_NUMERICHOST (1 << 1) |
#defineARES_NI_NAMEREQD (1 << 2) |
#defineARES_NI_NUMERICSERV (1 << 3) |
#defineARES_NI_DGRAM (1 << 4) |
#defineARES_NI_TCP0 |
#defineARES_NI_UDP ARES_NI_DGRAM |
#defineARES_NI_SCTP (1 << 5) |
#defineARES_NI_DCCP (1 << 6) |
#defineARES_NI_NUMERICSCOPE (1 << 7) |
#defineARES_NI_LOOKUPHOST (1 << 8) |
#defineARES_NI_LOOKUPSERVICE (1 << 9) |
/* Reserved for future use */ |
#defineARES_NI_IDN (1 << 10) |
#defineARES_NI_IDN_ALLOW_UNASSIGNED (1 << 11) |
#defineARES_NI_IDN_USE_STD3_ASCII_RULES (1 << 12) |
/* Addrinfo flag values */ |
#defineARES_AI_CANONNAME (1 << 0) |
#defineARES_AI_NUMERICHOST (1 << 1) |
#defineARES_AI_PASSIVE (1 << 2) |
#defineARES_AI_NUMERICSERV (1 << 3) |
#defineARES_AI_V4MAPPED (1 << 4) |
#defineARES_AI_ALL (1 << 5) |
#defineARES_AI_ADDRCONFIG (1 << 6) |
/* Reserved for future use */ |
#defineARES_AI_IDN (1 << 10) |
#defineARES_AI_IDN_ALLOW_UNASSIGNED (1 << 11) |
#defineARES_AI_IDN_USE_STD3_ASCII_RULES (1 << 12) |
#defineARES_AI_CANONIDN (1 << 13) |
#defineARES_AI_MASK (ARES_AI_CANONNAME|ARES_AI_NUMERICHOST|ARES_AI_PASSIVE| |
ARES_AI_NUMERICSERV|ARES_AI_V4MAPPED|ARES_AI_ALL| |
ARES_AI_ADDRCONFIG) |
#defineARES_GETSOCK_MAXNUM16/* ares_getsock() can return info about this |
many sockets */ |
#defineARES_GETSOCK_READABLE(bits,num) (bits & (1<< (num))) |
#defineARES_GETSOCK_WRITABLE(bits,num) (bits & (1 << ((num) + |
ARES_GETSOCK_MAXNUM))) |
/* c-ares library initialization flag values */ |
#defineARES_LIB_INIT_NONE (0) |
#defineARES_LIB_INIT_WIN32 (1 << 0) |
#defineARES_LIB_INIT_ALL (ARES_LIB_INIT_WIN32) |
/* |
* Typedef our socket type |
*/ |
#ifndef ares_socket_typedef |
#ifdef WIN32 |
typedef SOCKET ares_socket_t; |
#defineARES_SOCKET_BAD INVALID_SOCKET |
#else |
typedefintares_socket_t; |
#defineARES_SOCKET_BAD -1 |
#endif |
#defineares_socket_typedef |
#endif/* ares_socket_typedef */ |
typedefvoid (*ares_sock_state_cb)(void *data, |
ares_socket_t socket_fd, |
int readable, |
int writable); |
struct apattern; |
/* NOTE about the ares_options struct to users and developers. |
This struct will remain looking like this. It will not be extended nor |
shrunk in future releases, but all new options will be set by ares_set_*() |
options instead of with the ares_init_options() function. |
Eventually (in a galaxy far far away), all options will be settable by |
ares_set_*() options and the ares_init_options() function will become |
deprecated. |
When new options are added to c-ares, they are not added to this |
struct. And they are not 'saved' with the ares_save_options() function but |
instead we encourage the use of the ares_dup() function. Needless to say, |
if you add config options to c-ares you need to make sure ares_dup() |
duplicates this new option. |
*/ |
struct ares_options { |
int flags; |
int timeout; /* in seconds or milliseconds, depending on options */ |
int tries; |
int ndots; |
unsignedshort udp_port; |
unsignedshort tcp_port; |
int socket_send_buffer_size; |
int socket_receive_buffer_size; |
struct in_addr *servers; |
int nservers; |
char **domains; |
int ndomains; |
char *lookups; |
ares_sock_state_cb sock_state_cb; |
void *sock_state_cb_data; |
struct apattern *sortlist; |
int nsort; |
}; |
struct hostent; |
structtimeval; |
struct sockaddr; |
struct ares_channeldata; |
typedefstruct ares_channeldata *ares_channel; |
typedefvoid (*ares_callback)(void *arg, |
int status, |
int timeouts, |
unsignedchar *abuf, |
int alen); |
typedefvoid (*ares_host_callback)(void *arg, |
int status, |
int timeouts, |
struct hostent *hostent); |
typedefvoid (*ares_nameinfo_callback)(void *arg, |
int status, |
int timeouts, |
char *node, |
char *service); |
typedefint (*ares_sock_create_callback)(ares_socket_t socket_fd, |
int type, |
void *data); |
CARES_EXTERN intares_library_init(int flags); |
CARES_EXTERN voidares_library_cleanup(void); |
CARES_EXTERN constchar *ares_version(int *version); |
CARES_EXTERN intares_init(ares_channel *channelptr); |
CARES_EXTERN intares_init_options(ares_channel *channelptr, |
struct ares_options *options, |
int optmask); |
CARES_EXTERN intares_save_options(ares_channel channel, |
struct ares_options *options, |
int *optmask); |
CARES_EXTERN voidares_destroy_options(struct ares_options *options); |
CARES_EXTERN intares_dup(ares_channel *dest, |
ares_channel src); |
CARES_EXTERN voidares_destroy(ares_channel channel); |
CARES_EXTERN voidares_cancel(ares_channel channel); |
/* These next 3 configure local binding for the out-going socket |
* connection. Use these to specify source IP and/or network device |
* on multi-homed systems. |
*/ |
CARES_EXTERN voidares_set_local_ip4(ares_channel channel, unsignedint local_ip); |
/* local_ip6 should be 16 bytes in length */ |
CARES_EXTERN voidares_set_local_ip6(ares_channel channel, |
constunsignedchar* local_ip6); |
/* local_dev_name should be null terminated. */ |
CARES_EXTERN voidares_set_local_dev(ares_channel channel, |
constchar* local_dev_name); |
CARES_EXTERN voidares_set_socket_callback(ares_channel channel, |
ares_sock_create_callback callback, |
void *user_data); |
CARES_EXTERN voidares_send(ares_channel channel, |
constunsignedchar *qbuf, |
int qlen, |
ares_callback callback, |
void *arg); |
CARES_EXTERN voidares_query(ares_channel channel, |
constchar *name, |
int dnsclass, |
int type, |
ares_callback callback, |
void *arg); |
CARES_EXTERN voidares_search(ares_channel channel, |
constchar *name, |
int dnsclass, |
int type, |
ares_callback callback, |
void *arg); |
CARES_EXTERN voidares_gethostbyname(ares_channel channel, |
constchar *name, |
int family, |
ares_host_callback callback, |
void *arg); |
CARES_EXTERN intares_gethostbyname_file(ares_channel channel, |
constchar *name, |
int family, |
struct hostent **host); |
CARES_EXTERN voidares_gethostbyaddr(ares_channel channel, |
constvoid *addr, |
int addrlen, |
int family, |
ares_host_callback callback, |
void *arg); |
CARES_EXTERN voidares_getnameinfo(ares_channel channel, |
conststruct sockaddr *sa, |
ares_socklen_t salen, |
int flags, |
ares_nameinfo_callback callback, |
void *arg); |
CARES_EXTERN intares_fds(ares_channel channel, |
fd_set *read_fds, |
fd_set *write_fds); |
CARES_EXTERN intares_getsock(ares_channel channel, |
ares_socket_t *socks, |
int numsocks); |
CARES_EXTERN structtimeval *ares_timeout(ares_channel channel, |
structtimeval *maxtv, |
structtimeval *tv); |
CARES_EXTERN voidares_process(ares_channel channel, |
fd_set *read_fds, |
fd_set *write_fds); |
CARES_EXTERN voidares_process_fd(ares_channel channel, |
ares_socket_t read_fd, |
ares_socket_t write_fd); |
CARES_EXTERN intares_mkquery(constchar *name, |
int dnsclass, |
int type, |
unsignedshort id, |
int rd, |
unsignedchar **buf, |
int *buflen); |
CARES_EXTERN intares_expand_name(constunsignedchar *encoded, |
constunsignedchar *abuf, |
int alen, |
char **s, |
long *enclen); |
CARES_EXTERN intares_expand_string(constunsignedchar *encoded, |
constunsignedchar *abuf, |
int alen, |
unsignedchar **s, |
long *enclen); |
/* |
* NOTE: before c-ares 1.7.0 we would most often use the system in6_addr |
* struct below when ares itself was built, but many apps would use this |
* private version since the header checked a HAVE_* define for it. Starting |
* with 1.7.0 we always declare and use our own to stop relying on the |
* system's one. |
*/ |
struct ares_in6_addr { |
union { |
unsignedchar _S6_u8[16]; |
} _S6_un; |
}; |
struct ares_addrttl { |
struct in_addr ipaddr; |
int ttl; |
}; |
struct ares_addr6ttl { |
struct ares_in6_addr ip6addr; |
int ttl; |
}; |
struct ares_srv_reply { |
struct ares_srv_reply *next; |
char *host; |
unsignedshort priority; |
unsignedshort weight; |
unsignedshort port; |
}; |
struct ares_mx_reply { |
struct ares_mx_reply *next; |
char *host; |
unsignedshort priority; |
}; |
struct ares_txt_reply { |
struct ares_txt_reply *next; |
unsignedchar *txt; |
size_t length; /* length excludes null termination */ |
}; |
struct ares_naptr_reply { |
struct ares_naptr_reply *next; |
unsignedchar *flags; |
unsignedchar *service; |
unsignedchar *regexp; |
char *replacement; |
unsignedshort order; |
unsignedshort preference; |
}; |
struct ares_soa_reply { |
char *nsname; |
char *hostmaster; |
unsignedint serial; |
unsignedint refresh; |
unsignedint retry; |
unsignedint expire; |
unsignedint minttl; |
}; |
/* |
** Parse the buffer, starting at *abuf and of length alen bytes, previously |
** obtained from an ares_search call. Put the results in *host, if nonnull. |
** Also, if addrttls is nonnull, put up to *naddrttls IPv4 addresses along with |
** their TTLs in that array, and set *naddrttls to the number of addresses |
** so written. |
*/ |
CARES_EXTERN intares_parse_a_reply(constunsignedchar *abuf, |
int alen, |
struct hostent **host, |
struct ares_addrttl *addrttls, |
int *naddrttls); |
CARES_EXTERN intares_parse_aaaa_reply(constunsignedchar *abuf, |
int alen, |
struct hostent **host, |
struct ares_addr6ttl *addrttls, |
int *naddrttls); |
CARES_EXTERN intares_parse_ptr_reply(constunsignedchar *abuf, |
int alen, |
constvoid *addr, |
int addrlen, |
int family, |
struct hostent **host); |
CARES_EXTERN intares_parse_ns_reply(constunsignedchar *abuf, |
int alen, |
struct hostent **host); |
CARES_EXTERN intares_parse_srv_reply(constunsignedchar* abuf, |
int alen, |
struct ares_srv_reply** srv_out); |
CARES_EXTERN intares_parse_mx_reply(constunsignedchar* abuf, |
int alen, |
struct ares_mx_reply** mx_out); |
CARES_EXTERN intares_parse_txt_reply(constunsignedchar* abuf, |
int alen, |
struct ares_txt_reply** txt_out); |
CARES_EXTERN intares_parse_naptr_reply(constunsignedchar* abuf, |
int alen, |
struct ares_naptr_reply** naptr_out); |
CARES_EXTERN intares_parse_soa_reply(constunsignedchar* abuf, |
int alen, |
struct ares_soa_reply** soa_out); |
CARES_EXTERN voidares_free_string(void *str); |
CARES_EXTERN voidares_free_hostent(struct hostent *host); |
CARES_EXTERN voidares_free_soa(struct ares_soa_reply *soa); |
CARES_EXTERN voidares_free_data(void *dataptr); |
CARES_EXTERN constchar *ares_strerror(int code); |
/* TODO: Hold port here as well. */ |
struct ares_addr_node { |
struct ares_addr_node *next; |
int family; |
union { |
struct in_addr addr4; |
struct ares_in6_addr addr6; |
} addr; |
}; |
CARES_EXTERN intares_set_servers(ares_channel channel, |
struct ares_addr_node *servers); |
/* Incomming string format: host[:port][,host[:port]]... */ |
CARES_EXTERN intares_set_servers_csv(ares_channel channel, |
constchar* servers); |
CARES_EXTERN intares_get_servers(ares_channel channel, |
struct ares_addr_node **servers); |
#ifdef __cplusplus |
} |
#endif |
#endif/* ARES__H */ |
Copy lines Copy permalink