remote.c File Reference

This file contains the remote control functionality for the daemon. More...

#include "config.h"
#include "daemon/remote.h"
#include "daemon/worker.h"
#include "daemon/daemon.h"
#include "daemon/stats.h"
#include "daemon/cachedump.h"
#include "util/log.h"
#include "util/config_file.h"
#include "util/net_help.h"
#include "util/module.h"
#include "services/listen_dnsport.h"
#include "services/cache/rrset.h"
#include "services/mesh.h"
#include "services/localzone.h"
#include "util/storage/slabhash.h"
#include "util/fptr_wlist.h"
#include "util/data/dname.h"
#include "validator/validator.h"
#include "validator/val_kcache.h"
#include "validator/val_kentry.h"
#include <sys/types.h>
#include <netdb.h>

Data Structures

struct  del_info
 Local info for deletion functions. More...

Defines

#define SQ   "="
 what to put on statistics lines between var and value, ": " or "="

Functions

static void log_crypto_err (const char *str)
 log ssl crypto err
static void timeval_subtract (struct timeval *d, const struct timeval *end, const struct timeval *start)
 subtract timers and the values do not overflow or become negative
static void timeval_divide (struct timeval *avg, const struct timeval *sum, size_t d)
 divide sum of timers to get average
struct daemon_remotedaemon_remote_create (struct worker *worker)
 Create new remote control state for the daemon.
void daemon_remote_delete (struct daemon_remote *rc)
 remote control state to delete.
static int add_open (const char *ip, int nr, struct listen_port **list, int noproto_is_err)
 Add and open a new control port.
struct listen_portdaemon_remote_open_ports (struct config_file *cfg)
 Open and create listening ports for remote control.
static int accept_open (struct daemon_remote *rc, int fd)
 open accept commpoint
int daemon_remote_open_accept (struct daemon_remote *rc, struct listen_port *ports)
 Setup comm points for accepting remote control connections.
int remote_accept_callback (struct comm_point *c, void *arg, int err, struct comm_reply *rep)
 handle remote control accept callbacks
static void state_list_remove_elem (struct rc_state **list, struct comm_point *c)
 delete from list
static void clean_point (struct daemon_remote *rc, struct rc_state *s)
 decrease active count and remove commpoint from busy list
int ssl_print_text (SSL *ssl, const char *text)
 Print fixed line of text over ssl connection in blocking mode.
static int ssl_print_vmsg (SSL *ssl, const char *format, va_list args)
 print text over the ssl connection
int ssl_printf (SSL *ssl, const char *format,...)
 printf style printing to the ssl connection
int ssl_read_line (SSL *ssl, char *buf, size_t max)
 Read until
is encountered If SSL signals EOF, the string up to then is returned (without
).
static char * skipwhite (char *str)
 skip whitespace, return new pointer into string
static void send_ok (SSL *ssl)
 send the OK to the control client
static void do_stop (SSL *ssl, struct daemon_remote *rc)
 do the stop command
static void do_reload (SSL *ssl, struct daemon_remote *rc)
 do the reload command
static void do_verbosity (SSL *ssl, char *str)
 do the verbosity command
static int print_stats (SSL *ssl, const char *nm, struct stats_info *s)
 print stats from statinfo
static int print_thread_stats (SSL *ssl, int i, struct stats_info *s)
 print stats for one thread
static int print_longnum (SSL *ssl, char *desc, size_t x)
 print long number
static int print_mem (SSL *ssl, struct worker *worker, struct daemon *daemon)
 print mem stats
static int print_uptime (SSL *ssl, struct worker *worker)
 print uptime stats
static int print_hist (SSL *ssl, struct stats_info *s)
 print extended histogram
static int print_ext (SSL *ssl, struct stats_info *s)
 print extended stats
static void do_stats (SSL *ssl, struct daemon_remote *rc)
 do the stats command
static int parse_arg_name (SSL *ssl, char *str, uint8_t **res, size_t *len, int *labs)
 parse commandline argument domain name
static int find_arg2 (SSL *ssl, char *arg, char **arg2)
 find second argument, modifies string
static void do_zone_add (SSL *ssl, struct worker *worker, char *arg)
 Add a new zone.
static void do_zone_remove (SSL *ssl, struct worker *worker, char *arg)
 Remove a zone.
static void do_data_add (SSL *ssl, struct worker *worker, char *arg)
 Add new RR data.
static void do_data_remove (SSL *ssl, struct worker *worker, char *arg)
 Remove RR data.
static void do_lookup (SSL *ssl, struct worker *worker, char *arg)
 cache lookup of nameservers
static void do_flush_type (SSL *ssl, struct worker *worker, char *arg)
 flush a type
static void zone_del_rrset (struct lruhash_entry *e, void *arg)
 callback to delete rrsets in a zone
static void zone_del_kcache (struct lruhash_entry *e, void *arg)
 callback to delete keys in zone
static void lruhash_traverse (struct lruhash *h, int wr, void(*func)(struct lruhash_entry *, void *), void *arg)
 traverse a lruhash
static void slabhash_traverse (struct slabhash *sh, int wr, void(*func)(struct lruhash_entry *, void *), void *arg)
 traverse a slabhash
static void do_flush_zone (SSL *ssl, struct worker *worker, char *arg)
 remove all rrsets and keys from zone from cache
static void do_flush_name (SSL *ssl, struct worker *worker, char *arg)
 remove name rrset from cache
static void do_status (SSL *ssl, struct worker *worker)
 do the status command
void distribute_cmd (struct daemon_remote *rc, SSL *ssl, char *cmd)
 tell other processes to execute the command
static void execute_cmd (struct daemon_remote *rc, SSL *ssl, char *cmd, struct worker *worker)
 execute a remote control command
void daemon_remote_exec (struct worker *worker)
 Handle nonthreaded remote cmd execution.
static void handle_req (struct daemon_remote *rc, struct rc_state *s, SSL *ssl)
 handle remote control request
int remote_control_callback (struct comm_point *c, void *arg, int err, struct comm_reply *rep)
 handle remote control data callbacks

Variables

static const int inhibit_zero = 1
 if true, inhibits a lot of =0 lines from the stats output


Detailed Description

This file contains the remote control functionality for the daemon.

The remote control can be performed using either the commandline unbound-control tool, or a SSLv3/TLS capable web browser. The channel is secured using SSLv3 or TLSv1, and certificates. Both the server and the client(control tool) have their own keys.


Function Documentation

struct daemon_remote* daemon_remote_create ( struct worker worker  )  [read]

Create new remote control state for the daemon.

Parameters:
worker,: worker with communication base. and links to command channels.
Returns:
new state, or NULL on failure.

Referenced by worker_init().

void daemon_remote_delete ( struct daemon_remote rc  ) 

remote control state to delete.

Parameters:
rc,: state to delete.

Referenced by daemon_remote_create(), and worker_delete().

static int add_open ( const char *  ip,
int  nr,
struct listen_port **  list,
int  noproto_is_err 
) [static]

Add and open a new control port.

Parameters:
ip,: ip str
nr,: port nr
list,: list head
noproto_is_err,: if lack of protocol support is an error.
Returns:
false on failure.

References create_tcp_accept_sock(), listen_port::fd, log_err(), and listen_port::next.

Referenced by daemon_remote_open_ports().

struct listen_port* daemon_remote_open_ports ( struct config_file cfg  )  [read]

Open and create listening ports for remote control.

Parameters:
cfg,: config options.
Returns:
list of ports or NULL on failure. can be freed with listening_ports_free().

Referenced by daemon_open_shared_ports().

int daemon_remote_open_accept ( struct daemon_remote rc,
struct listen_port ports 
)

Setup comm points for accepting remote control connections.

Parameters:
rc,: state
ports,: already opened ports.
Returns:
false on error.

Referenced by worker_init().

int ssl_print_text ( SSL *  ssl,
const char *  text 
)

Print fixed line of text over ssl connection in blocking mode.

Parameters:
ssl,: print to
text,: the text.
Returns:
false on connection failure.

References log_crypto_err(), VERB_QUERY, and verbose().

Referenced by ssl_print_vmsg().

int ssl_read_line ( SSL *  ssl,
char *  buf,
size_t  max 
)

Read until
is encountered If SSL signals EOF, the string up to then is returned (without
).

Parameters:
ssl,: the SSL connection to read from. blocking.
buf,: buffer to read to.
max,: size of buffer.
Returns:
false on connection failure.

References log_crypto_err(), and log_err().

Referenced by handle_req(), and ssl_read_buf().

void daemon_remote_exec ( struct worker worker  ) 

Handle nonthreaded remote cmd execution.

Parameters:
worker,: this worker (the remote worker).

Referenced by worker_handle_control_cmd().


Generated on Thu Mar 26 10:03:52 2009 for unbound by  doxygen 1.5.8