aboutsummaryrefslogtreecommitdiff
path: root/src/server.h
blob: d9fc5a0be1a9a4f278b90ec0869e08015bfa8dc5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
/* server.h
 * (c) Jonas Gunz, 2020
 * License: MIT
 * */

#pragma once

#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <string.h>
#include <stdint.h>
#include <sys/types.h>

#include <sys/socket.h>
#include <netinet/ip.h>
#include <netinet/in.h>
#include <arpa/inet.h>

#include <unistd.h>

#include <signal.h>

#include <sys/select.h>

#include "dns.h"
#include "log.h"
#include "database.h"

#define UDP_BUFFER_LEN 512

typedef struct server_config {
	char* bind_ip;
	uint16_t bind_port;
	char* zonefile;
	char* user;
} server_config_t;

void server_start ( server_config_t* _config );

void server_handle_connection ( int _socket, database_t* _zone_db );

int server_get_socket ( char* _bind_ip, uint16_t _bind_port );

void signal_term ( int _sig );