Data Structures | Macros | Functions | Variables
delayer.c File Reference

This program delays queries made. More...

#include "config.h"
#include <sys/time.h>
#include "util/net_help.h"
#include "util/config_file.h"
#include "sldns/sbuffer.h"
#include <signal.h>

Data Structures

struct  ringbuf
 The ring buffer. More...
 
struct  proxy
 List of proxy fds that return replies from the server to our clients. More...
 
struct  tcp_send_list
 An item that has to be TCP relayed. More...
 
struct  tcp_proxy
 List of TCP proxy fd pairs to TCP connect client to server. More...
 

Macros

#define TRIES_PER_SELECT   100
 number of reads per select for delayer
 

Functions

static void usage (char *argv[])
 usage information for delayer
 
static int dl_tv_smaller (struct timeval *t1, const struct timeval *t2)
 timeval compare, t1 < t2
 
static void dl_tv_add (struct timeval *t1, const struct timeval *t2)
 timeval add, t1 += t2
 
static void dl_tv_subtract (struct timeval *t1, const struct timeval *t2)
 timeval subtract, t1 -= t2
 
static struct ringbufring_create (size_t sz)
 create new ring buffer
 
static void ring_delete (struct ringbuf *r)
 delete ring buffer
 
static void ring_add (struct ringbuf *r, sldns_buffer *pkt, struct timeval *now, struct timeval *delay, struct proxy *p)
 add entry to ringbuffer
 
static int ring_empty (struct ringbuf *r)
 see if the ringbuffer is empty
 
static struct timeval * ring_peek_time (struct ringbuf *r)
 peek at timevalue for next item in ring
 
static int ring_pop (struct ringbuf *r, sldns_buffer *pkt, struct timeval *tv, struct proxy **p)
 get entry from ringbuffer
 
static RETSIGTYPE delayer_sigh (int sig)
 signal handler for user quit
 
static void service_send (struct ringbuf *ring, struct timeval *now, sldns_buffer *pkt, struct sockaddr_storage *srv_addr, socklen_t srv_len)
 send out waiting packets
 
static void do_proxy (struct proxy *p, int retsock, sldns_buffer *pkt)
 do proxy for one readable client
 
static void service_proxy (fd_set *rset, int retsock, struct proxy *proxies, sldns_buffer *pkt, struct timeval *now)
 proxy return replies to clients
 
static struct proxyfind_create_proxy (struct sockaddr_storage *from, socklen_t from_len, fd_set *rorig, int *max, struct proxy **proxies, int serv_ip6, struct timeval *now, struct timeval *reuse_timeout)
 find or else create proxy for this remote client
 
static void service_recv (int s, struct ringbuf *ring, sldns_buffer *pkt, fd_set *rorig, int *max, struct proxy **proxies, struct sockaddr_storage *srv_addr, socklen_t srv_len, struct timeval *now, struct timeval *delay, struct timeval *reuse)
 recv new waiting packets
 
static void tcp_proxy_delete (struct tcp_proxy *p)
 delete tcp proxy
 
static void service_tcp_listen (int s, fd_set *rorig, int *max, struct tcp_proxy **proxies, struct sockaddr_storage *srv_addr, socklen_t srv_len, struct timeval *now, struct timeval *tcp_timeout)
 accept new TCP connections, and set them up
 
static int tcp_relay_read (int s, struct tcp_send_list **first, struct tcp_send_list **last, struct timeval *now, struct timeval *delay, sldns_buffer *pkt)
 relay TCP, read a part
 
static int tcp_relay_write (int s, struct tcp_send_list **first, struct tcp_send_list **last, struct timeval *now)
 relay TCP, write a part
 
static void service_tcp_relay (struct tcp_proxy **tcp_proxies, struct timeval *now, struct timeval *delay, struct timeval *tcp_timeout, sldns_buffer *pkt, fd_set *rset, fd_set *rorig, fd_set *worig)
 perform TCP relaying
 
static int service_findwait (struct timeval *now, struct timeval *wait, struct ringbuf *ring, struct tcp_proxy *tcplist)
 find waiting time
 
static void proxy_list_clear (struct proxy *p)
 clear proxy list
 
static void tcp_proxy_list_clear (struct tcp_proxy *p)
 clear TCP proxy list
 
static void service_loop (int udp_s, int listen_s, struct ringbuf *ring, struct timeval *delay, struct timeval *reuse, struct sockaddr_storage *srv_addr, socklen_t srv_len, sldns_buffer *pkt)
 delayer service loop
 
static void service (const char *bind_str, int bindport, const char *serv_str, size_t memsize, int delay_msec)
 delayer main service routine
 
int main (int argc, char **argv)
 main program for delayer
 

Variables

static volatile int do_quit = 0
 signal handler global info
 
int optind
 getopt global, in case header files fail to declare it. More...
 
char * optarg
 getopt global, in case header files fail to declare it. More...
 

Detailed Description

This program delays queries made.

It performs as a proxy to another server and delays queries to it.

Variable Documentation

◆ optind

int optind

getopt global, in case header files fail to declare it.

Referenced by main().

◆ optarg

char* optarg

getopt global, in case header files fail to declare it.

Referenced by main().