unbound 0.1
unbound-host.c File Reference

This file performs functionality like 'host', and also supports validation. More...

#include "config.h"
#include "libunbound/unbound.h"
#include "sldns/rrdef.h"
#include "sldns/wire2str.h"

Functions

static void usage (void)
 Give unbound-host usage, and exit (1).
static int isip4 (const char *nm, char **res)
 determine if str is ip4 and put into reverse lookup format
static int isip6 (const char *nm, char **res)
 determine if str is ip6 and put into reverse lookup format
static char * massage_qname (const char *nm, int *reverse)
 massage input name
static int massage_type (const char *t, int reverse, int *multi)
 massage input type
static int massage_class (const char *c)
 massage input class
static const char * secure_str (struct ub_result *result)
 nice security status string
static void pretty_type (char *s, size_t len, int t)
 nice string for type
static void pretty_class (char *s, size_t len, int c)
 nice string for class
static void pretty_rcode (char *s, size_t len, int r)
 nice string for rcode
static void print_rd (int t, char *data, size_t len)
 convert and print rdata
static void pretty_rdata (char *q, char *cstr, char *tstr, int t, const char *sec, char *data, size_t len)
 pretty line of RR data for results
static void pretty_output (char *q, int t, int c, struct ub_result *result, int docname)
 pretty line of output for results
static int dnslook (struct ub_ctx *ctx, char *q, int t, int c, int docname)
 perform a lookup and printout return if domain existed
static void lookup (struct ub_ctx *ctx, const char *nm, const char *qt, const char *qc)
 perform host lookup
static void check_ub_res (int r)
 print error if any
int main (int argc, char *argv[])
 Main routine for unbound-host.

Variables

static int verb = 0
 verbosity for unbound-host app
int optind
 getopt global, in case header files fail to declare it.
char * optarg
 getopt global, in case header files fail to declare it.

Detailed Description

This file performs functionality like 'host', and also supports validation.

It uses the libunbound library.

Function Documentation

◆ usage()

void usage ( void )
static

Give unbound-host usage, and exit (1).

References usage().

◆ isip4()

int isip4 ( const char * nm,
char ** res )
static

determine if str is ip4 and put into reverse lookup format

References isip4().

Referenced by isip4(), and massage_qname().

◆ isip6()

int isip6 ( const char * nm,
char ** res )
static

determine if str is ip6 and put into reverse lookup format

References isip6().

Referenced by isip6(), and massage_qname().

◆ massage_qname()

char * massage_qname ( const char * nm,
int * reverse )
static

massage input name

References isip4(), isip6(), massage_qname(), and reverse().

Referenced by lookup(), and massage_qname().

◆ massage_type()

int massage_type ( const char * t,
int reverse,
int * multi )
static

◆ massage_class()

int massage_class ( const char * c)
static

massage input class

References LDNS_RR_CLASS_IN, massage_class(), and sldns_get_rr_class_by_name().

Referenced by lookup(), and massage_class().

◆ secure_str()

const char * secure_str ( struct ub_result * result)
static

nice security status string

References ub_result::bogus, ub_result::rcode, ub_result::secure, and secure_str().

Referenced by pretty_output(), and secure_str().

◆ pretty_type()

void pretty_type ( char * s,
size_t len,
int t )
static

nice string for type

References pretty_type(), and sldns_wire2str_type_buf().

Referenced by pretty_output(), and pretty_type().

◆ pretty_class()

void pretty_class ( char * s,
size_t len,
int c )
static

nice string for class

References pretty_class(), and sldns_wire2str_class_buf().

Referenced by pretty_class(), and pretty_output().

◆ pretty_rcode()

void pretty_rcode ( char * s,
size_t len,
int r )
static

nice string for rcode

References pretty_rcode(), and sldns_wire2str_rcode_buf().

Referenced by pretty_output(), and pretty_rcode().

◆ print_rd()

void print_rd ( int t,
char * data,
size_t len )
static

convert and print rdata

References print_rd(), and sldns_wire2str_rdata_buf().

Referenced by pretty_rdata(), and print_rd().

◆ pretty_rdata()

void pretty_rdata ( char * q,
char * cstr,
char * tstr,
int t,
const char * sec,
char * data,
size_t len )
static

pretty line of RR data for results

References LDNS_RR_TYPE_A, LDNS_RR_TYPE_AAAA, LDNS_RR_TYPE_MX, LDNS_RR_TYPE_PTR, pretty_rdata(), print_rd(), and verb.

Referenced by pretty_output(), and pretty_rdata().

◆ pretty_output()

◆ dnslook()

int dnslook ( struct ub_ctx * ctx,
char * q,
int t,
int c,
int docname )
static

perform a lookup and printout return if domain existed

References dnslook(), ub_result::nxdomain, pretty_output(), ub_resolve(), ub_resolve_free(), and ub_strerror().

Referenced by dnslook(), and lookup().

◆ lookup()

void lookup ( struct ub_ctx * ctx,
const char * nm,
const char * qt,
const char * qc )
static

◆ check_ub_res()

void check_ub_res ( int r)
static

print error if any

References check_ub_res(), and ub_strerror().

Referenced by check_ub_res(), and main().

◆ main()