NCBI C++ ToolKit
|
#include "ncbi_ansi_ext.h"
#include "ncbi_lbdns.h"
#include "ncbi_once.h"
#include "ncbi_lb.h"
#include <connect/ncbi_ipv6.h>
#include <ctype.h>
#include <errno.h>
#include <math.h>
#include <netdb.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <arpa/inet.h>
#include <arpa/nameser.h>
#include <netinet/in.h>
#include <resolv.h>
Go to the source code of this file.
Go to the SVN repository for this file.
Classes | |
struct | SLBDNS_Data |
struct | ns_rr_srv_ |
Macros | |
#define | NCBI_USE_ERRCODE_X Connect_LBSM /* errors: 32 and up */ |
#define | SizeOf(a) (sizeof(a) / sizeof((a)[0])) |
#define | max(a, b) ((a) > (b) ? (a) : (b)) |
#define | SERVNSD_TXT_RR_PORT_LEN (sizeof(SERVNSD_TXT_RR_PORT)-1) |
#define | LBDNS_INITIAL_ALLOC 32 |
#define | isdash(s) ((s) == '-' || (s) == '_') |
Typedefs | |
typedef int | TSOCK_socklen_t |
typedef struct ns_rr_srv_ | ns_rr_srv |
Functions | |
static SSERV_Info * | s_GetNextInfo (SERV_ITER, HOST_INFO *) |
static void | s_Reset (SERV_ITER) |
static void | s_Close (SERV_ITER) |
static const char * | x_TypeStr (ns_type atype, char *buf) |
static const char * | x_ClassStr (ns_class aclass, char *buf) |
static const char * | x_RcodeStr (unsigned short rcode, char *buf) |
static const char * | x_OpcodeStr (unsigned short opcode, char *buf) |
static const char * | strherror (int err) |
static const char * | x_FlagsStr (const HEADER *hdr, char *buf) |
static void | x_DumpHdr (const HEADER *hdr, const unsigned short count[4]) |
static void | x_DumpRR (const ns_rr *rr, const char *part, unsigned short n) |
static int | unpack_rr (const unsigned char *msg, const unsigned char *eom, const unsigned char *ptr, ns_rr *rr, int qd, ELOG_Level level) |
static int | skip_rr (const unsigned char *ptr, const unsigned char *eom, int qd) |
static const unsigned char * | x_DumpMsg (const unsigned char *msg, const unsigned char *eom) |
static int | x_AddInfo (SERV_ITER iter, SSERV_Info *info) |
static int | x_UpdateHost (SERV_ITER iter, const char *fqdn, const TNCBI_IPv6Addr *addr) |
static void | x_UpdatePort (SERV_ITER iter, unsigned short port) |
static void | x_BlankInfo (SSERV_Info *info, ESERV_Type type) |
static double | x_RoundUp (double rate) |
static int | dns_srv (SERV_ITER iter, const unsigned char *msg, const unsigned char *eom, const char *fqdn, unsigned short rdlen, const unsigned char *rdata) |
static void | dns_txt (SERV_ITER iter, const char *fqdn, unsigned short rdlen, const unsigned char *rdata) |
static int | dns_a (SERV_ITER iter, ns_type qtype, ns_type rtype, const char *fqdn, unsigned short rdlen, const unsigned char *rdata) |
static const char * | dns_cname (unsigned int debug, const unsigned char *msg, const unsigned char *eom, const char *fqdn, unsigned short rdlen, const unsigned char *rdata) |
static int | same_domain (const char *a, const char *b) |
static const unsigned char * | x_ProcessReply (SERV_ITER iter, const struct SLBDNS_Data *data, const char *fqdn, ns_type type, const unsigned char *msg, const unsigned char *eom, const unsigned char *ptr, unsigned short count[3]) |
static const unsigned char * | x_VerifyReply (const char *fqdn, const unsigned char *msg, const unsigned char *eom, unsigned short count[3]) |
static int | x_NoDataReply (const char *fqdn, ns_type type, const unsigned char *msg, const unsigned char *eom) |
static const char * | x_FormFQDN (char fqdn[NS_MAXCDNAME+1], const char *prefix, size_t pfxlen, ns_type type, const char *domain, size_t domlen) |
static int | x_ResolveType (SERV_ITER iter, ns_type type) |
static void | x_Finalize (SERV_ITER iter) |
static int | x_Resolve (SERV_ITER iter) |
static int | s_Resolve (SERV_ITER iter) |
static const char * | s_SysGetDomainName (char *domain, size_t domainsize) |
static int | x_CheckDomain (const char *domain) |
static const char * | x_CopyDomain (const char *domain) |
const SSERV_VTable * | SERV_LBDNS_Open (SERV_ITER iter, SSERV_Info **info) |
Variables | |
static const SSERV_VTable | kLbdnsOp |
#define isdash | ( | s | ) | ((s) == '-' || (s) == '_') |
Definition at line 1430 of file ncbi_lbdns.c.
#define LBDNS_INITIAL_ALLOC 32 |
Definition at line 69 of file ncbi_lbdns.c.
#define NCBI_USE_ERRCODE_X Connect_LBSM /* errors: 32 and up */ |
Definition at line 58 of file ncbi_lbdns.c.
#define SERVNSD_TXT_RR_PORT_LEN (sizeof(SERVNSD_TXT_RR_PORT)-1) |
Definition at line 67 of file ncbi_lbdns.c.
Definition at line 61 of file ncbi_lbdns.c.
typedef struct ns_rr_srv_ ns_rr_srv |
Definition at line 572 of file ncbi_lbdns.c.
typedef int TSOCK_socklen_t |
Definition at line 75 of file ncbi_lbdns.c.
|
static |
Definition at line 685 of file ncbi_lbdns.c.
References assert, buf, CORE_LOGF, SSERV_IterTag::data, data, eLOG_Error, eLOG_Note, eLOG_Warning, fSERV_Dns, int, LBSM_DEFAULT_RATE, len, NcbiIPv4ToIPv6(), NcbiIPv6ToIPv4(), NcbiIPv6ToString(), NcbiIsEmptyIPv6(), SERV_CopyInfoEx(), SOCK_ntoa(), SSERV_IterTag::time, verify, x_AddInfo(), x_BlankInfo(), x_TypeStr(), and x_UpdateHost().
Referenced by x_ProcessReply().
|
static |
Definition at line 753 of file ncbi_lbdns.c.
References assert, CORE_LOG, CORE_LOGF, CORE_LOGF_ERRNO, debug(), eLOG_Error, eLOG_Note, eLOG_Warning, msg(), strdup, and strlwr.
Referenced by x_ProcessReply().
|
static |
Definition at line 591 of file ncbi_lbdns.c.
References assert, CORE_LOG, CORE_LOGF, SSERV_IterTag::data, eLOG_Error, eLOG_Note, eLOG_Warning, fSERV_Standalone, LBSM_DEFAULT_RATE, max, msg(), SSERV_Info::port, ns_rr_srv_::port, ns_rr_srv_::priority, SSERV_Info::rate, SERV_CopyInfoEx(), SERV_MAXIMAL_RATE, SSERV_Info::time, SSERV_IterTag::time, ns_rr_srv_::weight, x_AddInfo(), x_BlankInfo(), and x_RoundUp().
Referenced by x_ProcessReply().
|
static |
Definition at line 649 of file ncbi_lbdns.c.
References assert, buf, CORE_LOG, CORE_LOGF, SSERV_IterTag::data, eLOG_Error, eLOG_Note, isdigit(), len, n, ns_rr_srv_::port, SERVNSD_TXT_RR_PORT, SERVNSD_TXT_RR_PORT_LEN, strncasecmp, and x_UpdatePort().
Referenced by x_ProcessReply().
Definition at line 1385 of file ncbi_lbdns.c.
References assert, CORE_TRACEF, SSERV_IterTag::data, data, free(), and SSERV_IterTag::name.
Referenced by SERV_LBDNS_Open().
|
static |
Definition at line 1335 of file ncbi_lbdns.c.
References assert, CORE_TRACEF, SSERV_IterTag::data, data, if(), info, memmove, SSERV_IterTag::name, s_Resolve(), and SERV_NameOfInfo().
Definition at line 1367 of file ncbi_lbdns.c.
References assert, CORE_TRACEF, SSERV_IterTag::data, data, free(), n, and SSERV_IterTag::name.
Referenced by SERV_LBDNS_Open().
Definition at line 1267 of file ncbi_lbdns.c.
References assert, CORE_LOCK_WRITE, CORE_Once, CORE_UNLOCK, SSERV_IterTag::data, data, r(), s_Init(), and x_Resolve().
Referenced by s_GetNextInfo(), and SERV_LBDNS_Open().
Definition at line 1397 of file ncbi_lbdns.c.
References assert, CORE_LOCK_READ, CORE_UNLOCK, SLBDNS_Data::domain, n, SOCK_gethostbyaddr(), and strcasecmp.
Referenced by SERV_LBDNS_Open().
Definition at line 792 of file ncbi_lbdns.c.
References a, b, and strncasecmp.
Referenced by x_NoDataReply(), x_ProcessReply(), and x_VerifyReply().
const SSERV_VTable* SERV_LBDNS_Open | ( | SERV_ITER | iter, |
SSERV_Info ** | info | ||
) |
Definition at line 1505 of file ncbi_lbdns.c.
References SSERV_IterTag::arg, SSERV_IterTag::arglen, assert, calloc(), CONN_HOST_LEN, ConnNetInfo_Boolean(), ConnNetInfo_GetValueInternal(), CORE_LOG, CORE_LOG_ERRNO, CORE_LOGF, CORE_LOGF_ERRNO, CORE_TRACEF, SSERV_IterTag::data, data, SLBDNS_Data::domain, eLOG_Critical, eLOG_Error, eLOG_Note, eLOG_Trace, SSERV_IterTag::external, fSERV_Any, fSERV_Dns, fSERV_Standalone, fSERV_Stateless, info, isdigit(), SSERV_IterTag::ismask, kLbdnsOp, LBDNS_INITIAL_ALLOC, len, SSERV_IterTag::name, SSERV_IterTag::op, out(), SLBDNS_Data::port, REG_CONN_LBDNS_DEBUG, REG_CONN_LBDNS_DOMAIN, REG_CONN_LBDNS_HOST, REG_CONN_LBDNS_PORT, s_Close(), s_Reset(), s_Resolve(), s_SysGetDomainName(), SOCK_gethostbyname(), SOCK_HostPortToString(), strcasecmp, SSERV_IterTag::types, types, val, SSERV_IterTag::val, x_CheckDomain(), and x_CopyDomain().
Referenced by x_Open().
Definition at line 357 of file ncbi_lbdns.c.
References CORE_LOG, CORE_LOGF, eLOG_Error, len, and ncbi::grid::netcache::search::fields::size.
Referenced by x_ProcessReply().
Definition at line 216 of file ncbi_lbdns.c.
Referenced by x_ResolveType().
|
static |
Definition at line 314 of file ncbi_lbdns.c.
References assert, buf, CORE_LOGF, eLOG_Trace, eLOG_Warning, len, msg(), ncbi::grid::netcache::search::fields::size, and x_TypeStr().
Referenced by x_DumpMsg(), x_NoDataReply(), x_ProcessReply(), and x_VerifyReply().
|
static |
Definition at line 420 of file ncbi_lbdns.c.
References assert, CORE_LOGF, CORE_LOGF_ERRNO, SSERV_IterTag::data, data, eLOG_Error, eLOG_Note, eLOG_Warning, free(), fSERV_Dns, fSERV_Standalone, if(), info, n, SSERV_IterTag::name, SERV_EqualInfo(), SERV_NameOfInfo(), SERV_WriteInfo(), and strcasecmp.
Referenced by dns_a(), dns_srv(), and x_UpdateHost().
|
static |
Definition at line 558 of file ncbi_lbdns.c.
References assert, eENCOD_None, eMIME_T_Undefined, eMIME_Undefined, fSERV_Dns, fSERV_Local, fSERV_Standalone, info, LBSM_DEFAULT_TIME, SERV_DEFAULT_ALGO, and type.
Referenced by dns_a(), dns_srv(), and x_Finalize().
Definition at line 1432 of file ncbi_lbdns.c.
References assert, SLBDNS_Data::domain, isalpha(), isdash, isdigit(), len, NcbiStringToIPv4(), and verify.
Referenced by SERV_LBDNS_Open().
Definition at line 157 of file ncbi_lbdns.c.
References buf.
Referenced by x_DumpRR(), and x_VerifyReply().
Definition at line 1476 of file ncbi_lbdns.c.
References assert, SLBDNS_Data::domain, len, strncasecmp, and strndup.
Referenced by SERV_LBDNS_Open().
Definition at line 281 of file ncbi_lbdns.c.
References buf, CORE_LOGF, count, eLOG_Note, and x_FlagsStr().
Referenced by x_DumpMsg().
|
static |
Definition at line 387 of file ncbi_lbdns.c.
References assert, count, eLOG_Trace, msg(), n, SizeOf, unpack_rr(), x_DumpHdr(), and x_DumpRR().
Referenced by x_ResolveType().
Definition at line 296 of file ncbi_lbdns.c.
References CORE_LOGF, eLOG_Note, n, x_ClassStr(), and x_TypeStr().
Referenced by x_DumpMsg().
Definition at line 1148 of file ncbi_lbdns.c.
References assert, CORE_LOGF, CORE_TRACEF, SSERV_IterTag::data, data, eLOG_Error, eLOG_Note, free(), fSERV_Dns, fSERV_Standalone, SSERV_Info::host, if(), info, SSERV_IterTag::last, memmove, n, SLBDNS_Data::n_cand, SSERV_IterTag::n_skip, SSERV_IterTag::name, SSERV_Info::port, SSERV_IterTag::reverse_dns, SERV_CopyInfoEx(), SERV_EqualInfo(), SERV_NameOfInfo(), SERV_WriteInfo(), SSERV_IterTag::skip, strcasecmp, strupr, SSERV_Info::time, SSERV_IterTag::time, SSERV_Info::type, SSERV_IterTag::types, verify, and x_BlankInfo().
Referenced by x_Resolve().
Definition at line 252 of file ncbi_lbdns.c.
References buf, len, x_OpcodeStr(), and x_RcodeStr().
Referenced by x_DumpHdr().
|
static |
Definition at line 1011 of file ncbi_lbdns.c.
References assert, SLBDNS_Data::domain, SLBDNS_Data::domlen, and strlwr.
Referenced by x_ResolveType().
|
static |
Definition at line 980 of file ncbi_lbdns.c.
References eLOG_Trace, msg(), same_domain(), type, and unpack_rr().
Referenced by x_ResolveType().
Definition at line 195 of file ncbi_lbdns.c.
References buf.
Referenced by x_FlagsStr(), and x_VerifyReply().
|
static |
Definition at line 804 of file ncbi_lbdns.c.
References assert, CORE_LOG, CORE_LOGF, count, SSERV_IterTag::data, data, dns_a(), dns_cname(), dns_srv(), dns_txt(), done, eLOG_Error, eLOG_Warning, free(), msg(), n, SLBDNS_Data::n_cand, out(), same_domain(), skip_rr(), and unpack_rr().
Referenced by x_ResolveType().
Definition at line 172 of file ncbi_lbdns.c.
References buf.
Referenced by x_FlagsStr(), and x_VerifyReply().
Definition at line 1249 of file ncbi_lbdns.c.
References assert, CORE_TRACEF, SSERV_IterTag::data, fSERV_Dns, fSERV_Standalone, fSERV_Stateless, SSERV_IterTag::name, SSERV_IterTag::types, x_Finalize(), and x_ResolveType().
Referenced by s_Resolve().
Definition at line 1049 of file ncbi_lbdns.c.
References assert, CORE_LOGF, CORE_LOGF_ERRNO, CORE_TRACE, CORE_TRACEF, count, SSERV_IterTag::data, data, eLOG_Error, eLOG_Trace, eLOG_Warning, int, len, memcchr, msg(), SSERV_IterTag::name, strcasecmp, strherror(), x_DumpMsg(), x_FormFQDN(), x_NoDataReply(), x_ProcessReply(), x_TypeStr(), and x_VerifyReply().
Referenced by x_Resolve().
|
static |
Definition at line 572 of file ncbi_lbdns.c.
Referenced by dns_srv().
Definition at line 112 of file ncbi_lbdns.c.
References buf.
Referenced by dns_a(), unpack_rr(), x_DumpRR(), x_ResolveType(), and x_VerifyReply().
Definition at line 476 of file ncbi_lbdns.c.
References SSERV_Info::addr, assert, buf, CORE_LOGF, SSERV_IterTag::data, data, done, eLOG_Note, eLOG_Warning, SSERV_Info::host, SLBDNS_Data::host, info, int, n, NcbiAddrToString(), NcbiIPv4ToIPv6(), NcbiIPv6ToIPv4(), NcbiIsEmptyIPv6(), SERV_CopyInfoEx(), SERV_NameOfInfo(), strcasecmp, and x_AddInfo().
Referenced by dns_a().
Definition at line 538 of file ncbi_lbdns.c.
References assert, CORE_LOGF, SSERV_IterTag::data, data, eLOG_Note, fSERV_Dns, if(), info, n, SLBDNS_Data::port, and SERV_NameOfInfo().
Referenced by dns_txt().
|
static |
Definition at line 903 of file ncbi_lbdns.c.
References assert, buf, CORE_LOG, CORE_LOGF, count, eLOG_Error, msg(), same_domain(), unpack_rr(), x_ClassStr(), x_OpcodeStr(), x_RcodeStr(), and x_TypeStr().
Referenced by x_ResolveType().
|
static |