NCBI C++ ToolKit
Classes | Macros | Typedefs | Functions | Variables
ncbi_lbdns.c File Reference
#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>
+ Include dependency graph for ncbi_lbdns.c:

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_Infos_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_VTableSERV_LBDNS_Open (SERV_ITER iter, SSERV_Info **info)
 

Variables

static const SSERV_VTable kLbdnsOp
 

Macro Definition Documentation

◆ isdash

#define isdash (   s)    ((s) == '-' || (s) == '_')

Definition at line 1430 of file ncbi_lbdns.c.

◆ LBDNS_INITIAL_ALLOC

#define LBDNS_INITIAL_ALLOC   32

Definition at line 69 of file ncbi_lbdns.c.

◆ max

#define max (   a,
  b 
)    ((a) > (b) ? (a) : (b))

Definition at line 65 of file ncbi_lbdns.c.

◆ NCBI_USE_ERRCODE_X

#define NCBI_USE_ERRCODE_X   Connect_LBSM /* errors: 32 and up */

Definition at line 58 of file ncbi_lbdns.c.

◆ SERVNSD_TXT_RR_PORT_LEN

#define SERVNSD_TXT_RR_PORT_LEN   (sizeof(SERVNSD_TXT_RR_PORT)-1)

Definition at line 67 of file ncbi_lbdns.c.

◆ SizeOf

#define SizeOf (   a)    (sizeof(a) / sizeof((a)[0]))

Definition at line 61 of file ncbi_lbdns.c.

Typedef Documentation

◆ ns_rr_srv

typedef struct ns_rr_srv_ ns_rr_srv

Definition at line 572 of file ncbi_lbdns.c.

◆ TSOCK_socklen_t

Definition at line 75 of file ncbi_lbdns.c.

Function Documentation

◆ dns_a()

static int dns_a ( SERV_ITER  iter,
ns_type  qtype,
ns_type  rtype,
const char *  fqdn,
unsigned short  rdlen,
const unsigned char *  rdata 
)
static

◆ dns_cname()

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

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, strdup, and strlwr.

Referenced by x_ProcessReply().

◆ dns_srv()

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

◆ dns_txt()

static void dns_txt ( SERV_ITER  iter,
const char *  fqdn,
unsigned short  rdlen,
const unsigned char *  rdata 
)
static

◆ s_Close()

static void s_Close ( SERV_ITER  iter)
static

◆ s_GetNextInfo()

static SSERV_Info * s_GetNextInfo ( SERV_ITER  iter,
HOST_INFO host_info 
)
static

◆ s_Reset()

static void s_Reset ( SERV_ITER  iter)
static

◆ s_Resolve()

static int s_Resolve ( SERV_ITER  iter)
static

◆ s_SysGetDomainName()

static const char* s_SysGetDomainName ( char *  domain,
size_t  domainsize 
)
static

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().

◆ same_domain()

static int same_domain ( const char *  a,
const char *  b 
)
static

Definition at line 792 of file ncbi_lbdns.c.

References a, b, and strncasecmp.

Referenced by x_NoDataReply(), x_ProcessReply(), and x_VerifyReply().

◆ SERV_LBDNS_Open()

const SSERV_VTable* SERV_LBDNS_Open ( SERV_ITER  iter,
SSERV_Info **  info 
)

◆ skip_rr()

static int skip_rr ( const unsigned char *  ptr,
const unsigned char *  eom,
int  qd 
)
static

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().

◆ strherror()

static const char* strherror ( int  err)
static

Definition at line 216 of file ncbi_lbdns.c.

Referenced by x_ResolveType().

◆ unpack_rr()

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

◆ x_AddInfo()

static int x_AddInfo ( SERV_ITER  iter,
SSERV_Info info 
)
static

◆ x_BlankInfo()

static void x_BlankInfo ( SSERV_Info info,
ESERV_Type  type 
)
static

◆ x_CheckDomain()

static int x_CheckDomain ( const char *  domain)
static

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().

◆ x_ClassStr()

static const char* x_ClassStr ( ns_class  aclass,
char *  buf 
)
static

Definition at line 157 of file ncbi_lbdns.c.

References buf.

Referenced by x_DumpRR(), and x_VerifyReply().

◆ x_CopyDomain()

static const char* x_CopyDomain ( const char *  domain)
static

Definition at line 1476 of file ncbi_lbdns.c.

References assert, SLBDNS_Data::domain, len, strncasecmp, and strndup.

Referenced by SERV_LBDNS_Open().

◆ x_DumpHdr()

static void x_DumpHdr ( const HEADER *  hdr,
const unsigned short  count[4] 
)
static

Definition at line 281 of file ncbi_lbdns.c.

References buf, CORE_LOGF, eLOG_Note, and x_FlagsStr().

Referenced by x_DumpMsg().

◆ x_DumpMsg()

static const unsigned char* x_DumpMsg ( const unsigned char *  msg,
const unsigned char *  eom 
)
static

Definition at line 387 of file ncbi_lbdns.c.

References assert, eLOG_Trace, n, SizeOf, unpack_rr(), x_DumpHdr(), and x_DumpRR().

Referenced by x_ResolveType().

◆ x_DumpRR()

static void x_DumpRR ( const ns_rr *  rr,
const char *  part,
unsigned short  n 
)
static

Definition at line 296 of file ncbi_lbdns.c.

References CORE_LOGF, eLOG_Note, n, x_ClassStr(), and x_TypeStr().

Referenced by x_DumpMsg().

◆ x_Finalize()

static void x_Finalize ( SERV_ITER  iter)
static

◆ x_FlagsStr()

static const char* x_FlagsStr ( const HEADER *  hdr,
char *  buf 
)
static

Definition at line 252 of file ncbi_lbdns.c.

References buf, len, x_OpcodeStr(), and x_RcodeStr().

Referenced by x_DumpHdr().

◆ x_FormFQDN()

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

Definition at line 1011 of file ncbi_lbdns.c.

References assert, SLBDNS_Data::domain, SLBDNS_Data::domlen, prefix, and strlwr.

Referenced by x_ResolveType().

◆ x_NoDataReply()

static int x_NoDataReply ( const char *  fqdn,
ns_type  type,
const unsigned char *  msg,
const unsigned char *  eom 
)
static

Definition at line 980 of file ncbi_lbdns.c.

References eLOG_Trace, same_domain(), type, and unpack_rr().

Referenced by x_ResolveType().

◆ x_OpcodeStr()

static const char* x_OpcodeStr ( unsigned short  opcode,
char *  buf 
)
static

Definition at line 195 of file ncbi_lbdns.c.

References buf.

Referenced by x_FlagsStr(), and x_VerifyReply().

◆ x_ProcessReply()

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

◆ x_RcodeStr()

static const char* x_RcodeStr ( unsigned short  rcode,
char *  buf 
)
static

Definition at line 172 of file ncbi_lbdns.c.

References buf.

Referenced by x_FlagsStr(), and x_VerifyReply().

◆ x_Resolve()

static int x_Resolve ( SERV_ITER  iter)
static

◆ x_ResolveType()

static int x_ResolveType ( SERV_ITER  iter,
ns_type  type 
)
static

◆ x_RoundUp()

static double x_RoundUp ( double  rate)
static

Definition at line 572 of file ncbi_lbdns.c.

Referenced by dns_srv().

◆ x_TypeStr()

static const char* x_TypeStr ( ns_type  atype,
char *  buf 
)
static

Definition at line 112 of file ncbi_lbdns.c.

References buf.

Referenced by dns_a(), unpack_rr(), x_DumpRR(), x_ResolveType(), and x_VerifyReply().

◆ x_UpdateHost()

static int x_UpdateHost ( SERV_ITER  iter,
const char *  fqdn,
const TNCBI_IPv6Addr addr 
)
static

◆ x_UpdatePort()

static void x_UpdatePort ( SERV_ITER  iter,
unsigned short  port 
)
static

◆ x_VerifyReply()

static const unsigned char* x_VerifyReply ( const char *  fqdn,
const unsigned char *  msg,
const unsigned char *  eom,
unsigned short  count[3] 
)
static

Variable Documentation

◆ kLbdnsOp

const SSERV_VTable kLbdnsOp
static
Initial value:
= {
s_GetNextInfo, 0, 0, s_Reset, s_Close, "LBDNS"
}
static void s_Close(SERV_ITER)
Definition: ncbi_lbdns.c:1385
static void s_Reset(SERV_ITER)
Definition: ncbi_lbdns.c:1367
static SSERV_Info * s_GetNextInfo(SERV_ITER, HOST_INFO *)
Definition: ncbi_lbdns.c:1335

Definition at line 87 of file ncbi_lbdns.c.

Referenced by SERV_LBDNS_Open().

Modified on Sat Feb 24 07:47:54 2024 by modify_doxy.py rev. 669887