K&R style braces.
This is essentially commit f02d3ed3e1
from the
1.1 branch, making it easier to merge between master and 1.1.
This commit is contained in:
parent
ab7c61b06f
commit
5dde6461a3
32 changed files with 271 additions and 538 deletions
|
@ -36,8 +36,7 @@
|
|||
Unless the argument noclose is non-zero, daemon() will redirect
|
||||
standard input, standard output and standard error to /dev/null.
|
||||
*/
|
||||
int daemon(int nochdir, int noclose)
|
||||
{
|
||||
int daemon(int nochdir, int noclose) {
|
||||
#ifdef HAVE_FORK
|
||||
pid_t pid;
|
||||
int fd;
|
||||
|
@ -95,8 +94,7 @@ int daemon(int nochdir, int noclose)
|
|||
current directory name. If the environment variable PWD is set, and
|
||||
its value is correct, then that value will be returned.
|
||||
*/
|
||||
char *get_current_dir_name(void)
|
||||
{
|
||||
char *get_current_dir_name(void) {
|
||||
size_t size;
|
||||
char *buf;
|
||||
char *r;
|
||||
|
|
45
lib/list.c
45
lib/list.c
|
@ -25,8 +25,7 @@
|
|||
|
||||
/* (De)constructors */
|
||||
|
||||
list_t *list_alloc(list_action_t delete)
|
||||
{
|
||||
list_t *list_alloc(list_action_t delete) {
|
||||
list_t *list;
|
||||
|
||||
list = xmalloc_and_zero(sizeof(list_t));
|
||||
|
@ -35,18 +34,15 @@ list_t *list_alloc(list_action_t delete)
|
|||
return list;
|
||||
}
|
||||
|
||||
void list_free(list_t *list)
|
||||
{
|
||||
void list_free(list_t *list) {
|
||||
free(list);
|
||||
}
|
||||
|
||||
list_node_t *list_alloc_node(void)
|
||||
{
|
||||
list_node_t *list_alloc_node(void) {
|
||||
return xmalloc_and_zero(sizeof(list_node_t));
|
||||
}
|
||||
|
||||
void list_free_node(list_t *list, list_node_t *node)
|
||||
{
|
||||
void list_free_node(list_t *list, list_node_t *node) {
|
||||
if(node->data && list->delete)
|
||||
list->delete(node->data);
|
||||
|
||||
|
@ -55,8 +51,7 @@ void list_free_node(list_t *list, list_node_t *node)
|
|||
|
||||
/* Insertion and deletion */
|
||||
|
||||
list_node_t *list_insert_head(list_t *list, void *data)
|
||||
{
|
||||
list_node_t *list_insert_head(list_t *list, void *data) {
|
||||
list_node_t *node;
|
||||
|
||||
node = list_alloc_node();
|
||||
|
@ -76,8 +71,7 @@ list_node_t *list_insert_head(list_t *list, void *data)
|
|||
return node;
|
||||
}
|
||||
|
||||
list_node_t *list_insert_tail(list_t *list, void *data)
|
||||
{
|
||||
list_node_t *list_insert_tail(list_t *list, void *data) {
|
||||
list_node_t *node;
|
||||
|
||||
node = list_alloc_node();
|
||||
|
@ -97,8 +91,7 @@ list_node_t *list_insert_tail(list_t *list, void *data)
|
|||
return node;
|
||||
}
|
||||
|
||||
void list_unlink_node(list_t *list, list_node_t *node)
|
||||
{
|
||||
void list_unlink_node(list_t *list, list_node_t *node) {
|
||||
if(node->prev)
|
||||
node->prev->next = node->next;
|
||||
else
|
||||
|
@ -112,34 +105,29 @@ void list_unlink_node(list_t *list, list_node_t *node)
|
|||
list->count--;
|
||||
}
|
||||
|
||||
void list_delete_node(list_t *list, list_node_t *node)
|
||||
{
|
||||
void list_delete_node(list_t *list, list_node_t *node) {
|
||||
list_unlink_node(list, node);
|
||||
list_free_node(list, node);
|
||||
}
|
||||
|
||||
void list_delete_head(list_t *list)
|
||||
{
|
||||
void list_delete_head(list_t *list) {
|
||||
list_delete_node(list, list->head);
|
||||
}
|
||||
|
||||
void list_delete_tail(list_t *list)
|
||||
{
|
||||
void list_delete_tail(list_t *list) {
|
||||
list_delete_node(list, list->tail);
|
||||
}
|
||||
|
||||
/* Head/tail lookup */
|
||||
|
||||
void *list_get_head(list_t *list)
|
||||
{
|
||||
void *list_get_head(list_t *list) {
|
||||
if(list->head)
|
||||
return list->head->data;
|
||||
else
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void *list_get_tail(list_t *list)
|
||||
{
|
||||
void *list_get_tail(list_t *list) {
|
||||
if(list->tail)
|
||||
return list->tail->data;
|
||||
else
|
||||
|
@ -148,8 +136,7 @@ void *list_get_tail(list_t *list)
|
|||
|
||||
/* Fast list deletion */
|
||||
|
||||
void list_delete_list(list_t *list)
|
||||
{
|
||||
void list_delete_list(list_t *list) {
|
||||
list_node_t *node, *next;
|
||||
|
||||
for(node = list->head; node; node = next) {
|
||||
|
@ -162,8 +149,7 @@ void list_delete_list(list_t *list)
|
|||
|
||||
/* Traversing */
|
||||
|
||||
void list_foreach_node(list_t *list, list_action_node_t action)
|
||||
{
|
||||
void list_foreach_node(list_t *list, list_action_node_t action) {
|
||||
list_node_t *node, *next;
|
||||
|
||||
for(node = list->head; node; node = next) {
|
||||
|
@ -172,8 +158,7 @@ void list_foreach_node(list_t *list, list_action_node_t action)
|
|||
}
|
||||
}
|
||||
|
||||
void list_foreach(list_t *list, list_action_t action)
|
||||
{
|
||||
void list_foreach(list_t *list, list_action_t action) {
|
||||
list_node_t *node, *next;
|
||||
|
||||
for(node = list->head; node; node = next) {
|
||||
|
|
12
lib/utils.c
12
lib/utils.c
|
@ -31,8 +31,7 @@ volatile int cp_index = 0;
|
|||
|
||||
const char hexadecimals[] = "0123456789ABCDEF";
|
||||
|
||||
int charhex2bin(char c)
|
||||
{
|
||||
int charhex2bin(char c) {
|
||||
if(isdigit(c))
|
||||
return c - '0';
|
||||
else
|
||||
|
@ -40,15 +39,13 @@ int charhex2bin(char c)
|
|||
}
|
||||
|
||||
|
||||
void hex2bin(char *src, char *dst, int length)
|
||||
{
|
||||
void hex2bin(char *src, char *dst, int length) {
|
||||
int i;
|
||||
for(i = 0; i < length; i++)
|
||||
dst[i] = charhex2bin(src[i * 2]) * 16 + charhex2bin(src[i * 2 + 1]);
|
||||
}
|
||||
|
||||
void bin2hex(char *src, char *dst, int length)
|
||||
{
|
||||
void bin2hex(char *src, char *dst, int length) {
|
||||
int i;
|
||||
for(i = length - 1; i >= 0; i--) {
|
||||
dst[i * 2 + 1] = hexadecimals[(unsigned char) src[i] & 15];
|
||||
|
@ -57,8 +54,7 @@ void bin2hex(char *src, char *dst, int length)
|
|||
}
|
||||
|
||||
#ifdef ENABLE_TRACING
|
||||
void cp_trace()
|
||||
{
|
||||
void cp_trace() {
|
||||
logger(LOG_DEBUG, "Checkpoint trace: %s:%d <- %s:%d <- %s:%d <- %s:%d <- %s:%d <- %s:%d <- %s:%d <- %s:%d <- %s:%d <- %s:%d <- %s:%d <- %s:%d <- %s:%d <- %s:%d <- %s:%d <- %s:%d...",
|
||||
cp_file[(cp_index + 15) % 16], cp_line[(cp_index + 15) % 16],
|
||||
cp_file[(cp_index + 14) % 16], cp_line[(cp_index + 14) % 16],
|
||||
|
|
|
@ -277,8 +277,7 @@ bool read_packet(vpn_packet_t *packet) {
|
|||
return true;
|
||||
}
|
||||
|
||||
bool write_packet(vpn_packet_t *packet)
|
||||
{
|
||||
bool write_packet(vpn_packet_t *packet) {
|
||||
cp();
|
||||
|
||||
ifdebug(TRAFFIC) logger(LOG_DEBUG, _("Writing packet of %d bytes to %s"),
|
||||
|
@ -349,8 +348,7 @@ bool write_packet(vpn_packet_t *packet)
|
|||
return true;
|
||||
}
|
||||
|
||||
void dump_device_stats(void)
|
||||
{
|
||||
void dump_device_stats(void) {
|
||||
cp();
|
||||
|
||||
logger(LOG_DEBUG, _("Statistics for %s %s:"), device_info, device);
|
||||
|
|
51
src/conf.c
51
src/conf.c
|
@ -36,8 +36,7 @@ int pingtimeout = 0; /* seconds to wait for response */
|
|||
char *confbase = NULL; /* directory in which all config files are */
|
||||
char *netname = NULL; /* name of the vpn network */
|
||||
|
||||
static int config_compare(const config_t *a, const config_t *b)
|
||||
{
|
||||
static int config_compare(const config_t *a, const config_t *b) {
|
||||
int result;
|
||||
|
||||
result = strcasecmp(a->variable, b->variable);
|
||||
|
@ -53,30 +52,26 @@ static int config_compare(const config_t *a, const config_t *b)
|
|||
return strcmp(a->file, b->file);
|
||||
}
|
||||
|
||||
void init_configuration(avl_tree_t ** config_tree)
|
||||
{
|
||||
void init_configuration(avl_tree_t ** config_tree) {
|
||||
cp();
|
||||
|
||||
*config_tree = avl_alloc_tree((avl_compare_t) config_compare, (avl_action_t) free_config);
|
||||
}
|
||||
|
||||
void exit_configuration(avl_tree_t ** config_tree)
|
||||
{
|
||||
void exit_configuration(avl_tree_t ** config_tree) {
|
||||
cp();
|
||||
|
||||
avl_delete_tree(*config_tree);
|
||||
*config_tree = NULL;
|
||||
}
|
||||
|
||||
config_t *new_config(void)
|
||||
{
|
||||
config_t *new_config(void) {
|
||||
cp();
|
||||
|
||||
return xmalloc_and_zero(sizeof(config_t));
|
||||
}
|
||||
|
||||
void free_config(config_t *cfg)
|
||||
{
|
||||
void free_config(config_t *cfg) {
|
||||
cp();
|
||||
|
||||
if(cfg->variable)
|
||||
|
@ -91,15 +86,13 @@ void free_config(config_t *cfg)
|
|||
free(cfg);
|
||||
}
|
||||
|
||||
void config_add(avl_tree_t *config_tree, config_t *cfg)
|
||||
{
|
||||
void config_add(avl_tree_t *config_tree, config_t *cfg) {
|
||||
cp();
|
||||
|
||||
avl_insert(config_tree, cfg);
|
||||
}
|
||||
|
||||
config_t *lookup_config(avl_tree_t *config_tree, char *variable)
|
||||
{
|
||||
config_t *lookup_config(avl_tree_t *config_tree, char *variable) {
|
||||
config_t cfg, *found;
|
||||
|
||||
cp();
|
||||
|
@ -119,8 +112,7 @@ config_t *lookup_config(avl_tree_t *config_tree, char *variable)
|
|||
return found;
|
||||
}
|
||||
|
||||
config_t *lookup_config_next(avl_tree_t *config_tree, const config_t *cfg)
|
||||
{
|
||||
config_t *lookup_config_next(avl_tree_t *config_tree, const config_t *cfg) {
|
||||
avl_node_t *node;
|
||||
config_t *found;
|
||||
|
||||
|
@ -140,8 +132,7 @@ config_t *lookup_config_next(avl_tree_t *config_tree, const config_t *cfg)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
bool get_config_bool(const config_t *cfg, bool *result)
|
||||
{
|
||||
bool get_config_bool(const config_t *cfg, bool *result) {
|
||||
cp();
|
||||
|
||||
if(!cfg)
|
||||
|
@ -161,8 +152,7 @@ bool get_config_bool(const config_t *cfg, bool *result)
|
|||
return false;
|
||||
}
|
||||
|
||||
bool get_config_int(const config_t *cfg, int *result)
|
||||
{
|
||||
bool get_config_int(const config_t *cfg, int *result) {
|
||||
cp();
|
||||
|
||||
if(!cfg)
|
||||
|
@ -177,8 +167,7 @@ bool get_config_int(const config_t *cfg, int *result)
|
|||
return false;
|
||||
}
|
||||
|
||||
bool get_config_string(const config_t *cfg, char **result)
|
||||
{
|
||||
bool get_config_string(const config_t *cfg, char **result) {
|
||||
cp();
|
||||
|
||||
if(!cfg)
|
||||
|
@ -189,8 +178,7 @@ bool get_config_string(const config_t *cfg, char **result)
|
|||
return true;
|
||||
}
|
||||
|
||||
bool get_config_address(const config_t *cfg, struct addrinfo **result)
|
||||
{
|
||||
bool get_config_address(const config_t *cfg, struct addrinfo **result) {
|
||||
struct addrinfo *ai;
|
||||
|
||||
cp();
|
||||
|
@ -211,8 +199,7 @@ bool get_config_address(const config_t *cfg, struct addrinfo **result)
|
|||
return false;
|
||||
}
|
||||
|
||||
bool get_config_subnet(const config_t *cfg, subnet_t ** result)
|
||||
{
|
||||
bool get_config_subnet(const config_t *cfg, subnet_t ** result) {
|
||||
subnet_t subnet = {0};
|
||||
|
||||
cp();
|
||||
|
@ -252,8 +239,7 @@ bool get_config_subnet(const config_t *cfg, subnet_t ** result)
|
|||
given, and buf needs to be expanded, the var pointed to by buflen
|
||||
will be increased.
|
||||
*/
|
||||
static char *readline(FILE * fp, char **buf, size_t *buflen)
|
||||
{
|
||||
static char *readline(FILE * fp, char **buf, size_t *buflen) {
|
||||
char *newline = NULL;
|
||||
char *p;
|
||||
char *line; /* The array that contains everything that has been read so far */
|
||||
|
@ -317,8 +303,7 @@ static char *readline(FILE * fp, char **buf, size_t *buflen)
|
|||
Parse a configuration file and put the results in the configuration tree
|
||||
starting at *base.
|
||||
*/
|
||||
int read_config_file(avl_tree_t *config_tree, const char *fname)
|
||||
{
|
||||
int read_config_file(avl_tree_t *config_tree, const char *fname) {
|
||||
int err = -2; /* Parse error */
|
||||
FILE *fp;
|
||||
char *buffer, *line;
|
||||
|
@ -408,8 +393,7 @@ int read_config_file(avl_tree_t *config_tree, const char *fname)
|
|||
return err;
|
||||
}
|
||||
|
||||
bool read_server_config()
|
||||
{
|
||||
bool read_server_config() {
|
||||
char *fname;
|
||||
int x;
|
||||
|
||||
|
@ -427,8 +411,7 @@ bool read_server_config()
|
|||
return x == 0;
|
||||
}
|
||||
|
||||
FILE *ask_and_open(const char *filename, const char *what)
|
||||
{
|
||||
FILE *ask_and_open(const char *filename, const char *what) {
|
||||
FILE *r;
|
||||
char *directory;
|
||||
char *fn;
|
||||
|
|
|
@ -33,13 +33,11 @@
|
|||
avl_tree_t *connection_tree; /* Meta connections */
|
||||
connection_t *broadcast;
|
||||
|
||||
static int connection_compare(const connection_t *a, const connection_t *b)
|
||||
{
|
||||
static int connection_compare(const connection_t *a, const connection_t *b) {
|
||||
return a < b ? -1 : a == b ? 0 : 1;
|
||||
}
|
||||
|
||||
void init_connections(void)
|
||||
{
|
||||
void init_connections(void) {
|
||||
cp();
|
||||
|
||||
connection_tree = avl_alloc_tree((avl_compare_t) connection_compare, (avl_action_t) free_connection);
|
||||
|
@ -48,16 +46,14 @@ void init_connections(void)
|
|||
broadcast->hostname = xstrdup(_("BROADCAST"));
|
||||
}
|
||||
|
||||
void exit_connections(void)
|
||||
{
|
||||
void exit_connections(void) {
|
||||
cp();
|
||||
|
||||
avl_delete_tree(connection_tree);
|
||||
free_connection(broadcast);
|
||||
}
|
||||
|
||||
connection_t *new_connection(void)
|
||||
{
|
||||
connection_t *new_connection(void) {
|
||||
connection_t *c;
|
||||
|
||||
cp();
|
||||
|
@ -72,8 +68,7 @@ connection_t *new_connection(void)
|
|||
return c;
|
||||
}
|
||||
|
||||
void free_connection(connection_t *c)
|
||||
{
|
||||
void free_connection(connection_t *c) {
|
||||
cp();
|
||||
|
||||
if(c->name)
|
||||
|
@ -116,22 +111,19 @@ void free_connection(connection_t *c)
|
|||
free(c);
|
||||
}
|
||||
|
||||
void connection_add(connection_t *c)
|
||||
{
|
||||
void connection_add(connection_t *c) {
|
||||
cp();
|
||||
|
||||
avl_insert(connection_tree, c);
|
||||
}
|
||||
|
||||
void connection_del(connection_t *c)
|
||||
{
|
||||
void connection_del(connection_t *c) {
|
||||
cp();
|
||||
|
||||
avl_delete(connection_tree, c);
|
||||
}
|
||||
|
||||
void dump_connections(void)
|
||||
{
|
||||
void dump_connections(void) {
|
||||
avl_node_t *node;
|
||||
connection_t *c;
|
||||
|
||||
|
@ -149,8 +141,7 @@ void dump_connections(void)
|
|||
logger(LOG_DEBUG, _("End of connections."));
|
||||
}
|
||||
|
||||
bool read_connection_config(connection_t *c)
|
||||
{
|
||||
bool read_connection_config(connection_t *c) {
|
||||
char *fname;
|
||||
int x;
|
||||
|
||||
|
|
|
@ -44,8 +44,7 @@ static int device_total_out = 0;
|
|||
static pid_t reader_pid;
|
||||
static int sp[2];
|
||||
|
||||
bool setup_device(void)
|
||||
{
|
||||
bool setup_device(void) {
|
||||
HKEY key, key2;
|
||||
int i, err;
|
||||
|
||||
|
@ -216,8 +215,7 @@ bool setup_device(void)
|
|||
return true;
|
||||
}
|
||||
|
||||
void close_device(void)
|
||||
{
|
||||
void close_device(void) {
|
||||
cp();
|
||||
|
||||
close(sp[0]);
|
||||
|
@ -230,8 +228,7 @@ void close_device(void)
|
|||
free(iface);
|
||||
}
|
||||
|
||||
bool read_packet(vpn_packet_t *packet)
|
||||
{
|
||||
bool read_packet(vpn_packet_t *packet) {
|
||||
int lenin;
|
||||
|
||||
cp();
|
||||
|
@ -252,8 +249,7 @@ bool read_packet(vpn_packet_t *packet)
|
|||
return true;
|
||||
}
|
||||
|
||||
bool write_packet(vpn_packet_t *packet)
|
||||
{
|
||||
bool write_packet(vpn_packet_t *packet) {
|
||||
long lenout;
|
||||
|
||||
cp();
|
||||
|
@ -271,8 +267,7 @@ bool write_packet(vpn_packet_t *packet)
|
|||
return true;
|
||||
}
|
||||
|
||||
void dump_device_stats(void)
|
||||
{
|
||||
void dump_device_stats(void) {
|
||||
cp();
|
||||
|
||||
logger(LOG_DEBUG, _("Statistics for %s %s:"), device_info, device);
|
||||
|
|
36
src/edge.c
36
src/edge.c
|
@ -30,13 +30,11 @@
|
|||
|
||||
avl_tree_t *edge_weight_tree; /* Tree with all edges, sorted on weight */
|
||||
|
||||
static int edge_compare(const edge_t *a, const edge_t *b)
|
||||
{
|
||||
static int edge_compare(const edge_t *a, const edge_t *b) {
|
||||
return strcmp(a->to->name, b->to->name);
|
||||
}
|
||||
|
||||
static int edge_weight_compare(const edge_t *a, const edge_t *b)
|
||||
{
|
||||
static int edge_weight_compare(const edge_t *a, const edge_t *b) {
|
||||
int result;
|
||||
|
||||
result = a->weight - b->weight;
|
||||
|
@ -52,29 +50,25 @@ static int edge_weight_compare(const edge_t *a, const edge_t *b)
|
|||
return strcmp(a->to->name, b->to->name);
|
||||
}
|
||||
|
||||
void init_edges(void)
|
||||
{
|
||||
void init_edges(void) {
|
||||
cp();
|
||||
|
||||
edge_weight_tree = avl_alloc_tree((avl_compare_t) edge_weight_compare, NULL);
|
||||
}
|
||||
|
||||
avl_tree_t *new_edge_tree(void)
|
||||
{
|
||||
avl_tree_t *new_edge_tree(void) {
|
||||
cp();
|
||||
|
||||
return avl_alloc_tree((avl_compare_t) edge_compare, (avl_action_t) free_edge);
|
||||
}
|
||||
|
||||
void free_edge_tree(avl_tree_t *edge_tree)
|
||||
{
|
||||
void free_edge_tree(avl_tree_t *edge_tree) {
|
||||
cp();
|
||||
|
||||
avl_delete_tree(edge_tree);
|
||||
}
|
||||
|
||||
void exit_edges(void)
|
||||
{
|
||||
void exit_edges(void) {
|
||||
cp();
|
||||
|
||||
avl_delete_tree(edge_weight_tree);
|
||||
|
@ -82,15 +76,13 @@ void exit_edges(void)
|
|||
|
||||
/* Creation and deletion of connection elements */
|
||||
|
||||
edge_t *new_edge(void)
|
||||
{
|
||||
edge_t *new_edge(void) {
|
||||
cp();
|
||||
|
||||
return xmalloc_and_zero(sizeof(edge_t));
|
||||
}
|
||||
|
||||
void free_edge(edge_t *e)
|
||||
{
|
||||
void free_edge(edge_t *e) {
|
||||
cp();
|
||||
|
||||
sockaddrfree(&e->address);
|
||||
|
@ -98,8 +90,7 @@ void free_edge(edge_t *e)
|
|||
free(e);
|
||||
}
|
||||
|
||||
void edge_add(edge_t *e)
|
||||
{
|
||||
void edge_add(edge_t *e) {
|
||||
cp();
|
||||
|
||||
avl_insert(edge_weight_tree, e);
|
||||
|
@ -111,8 +102,7 @@ void edge_add(edge_t *e)
|
|||
e->reverse->reverse = e;
|
||||
}
|
||||
|
||||
void edge_del(edge_t *e)
|
||||
{
|
||||
void edge_del(edge_t *e) {
|
||||
cp();
|
||||
|
||||
if(e->reverse)
|
||||
|
@ -122,8 +112,7 @@ void edge_del(edge_t *e)
|
|||
avl_delete(e->from->edge_tree, e);
|
||||
}
|
||||
|
||||
edge_t *lookup_edge(node_t *from, node_t *to)
|
||||
{
|
||||
edge_t *lookup_edge(node_t *from, node_t *to) {
|
||||
edge_t v;
|
||||
|
||||
cp();
|
||||
|
@ -134,8 +123,7 @@ edge_t *lookup_edge(node_t *from, node_t *to)
|
|||
return avl_search(from->edge_tree, &v);
|
||||
}
|
||||
|
||||
void dump_edges(void)
|
||||
{
|
||||
void dump_edges(void) {
|
||||
avl_node_t *node, *node2;
|
||||
node_t *n;
|
||||
edge_t *e;
|
||||
|
|
27
src/event.c
27
src/event.c
|
@ -30,8 +30,7 @@ extern time_t now;
|
|||
|
||||
int id;
|
||||
|
||||
static int event_compare(const event_t *a, const event_t *b)
|
||||
{
|
||||
static int event_compare(const event_t *a, const event_t *b) {
|
||||
if(a->time > b->time)
|
||||
return 1;
|
||||
|
||||
|
@ -41,22 +40,19 @@ static int event_compare(const event_t *a, const event_t *b)
|
|||
return a->id - b->id;
|
||||
}
|
||||
|
||||
void init_events(void)
|
||||
{
|
||||
void init_events(void) {
|
||||
cp();
|
||||
|
||||
event_tree = avl_alloc_tree((avl_compare_t) event_compare, (avl_action_t) free_event);
|
||||
}
|
||||
|
||||
void exit_events(void)
|
||||
{
|
||||
void exit_events(void) {
|
||||
cp();
|
||||
|
||||
avl_delete_tree(event_tree);
|
||||
}
|
||||
|
||||
void expire_events(void)
|
||||
{
|
||||
void expire_events(void) {
|
||||
avl_node_t *node;
|
||||
event_t *event;
|
||||
time_t diff;
|
||||
|
@ -83,37 +79,32 @@ void expire_events(void)
|
|||
}
|
||||
}
|
||||
|
||||
event_t *new_event(void)
|
||||
{
|
||||
event_t *new_event(void) {
|
||||
cp();
|
||||
|
||||
return xmalloc_and_zero(sizeof(event_t));
|
||||
}
|
||||
|
||||
void free_event(event_t *event)
|
||||
{
|
||||
void free_event(event_t *event) {
|
||||
cp();
|
||||
|
||||
free(event);
|
||||
}
|
||||
|
||||
void event_add(event_t *event)
|
||||
{
|
||||
void event_add(event_t *event) {
|
||||
cp();
|
||||
|
||||
event->id = ++id;
|
||||
avl_insert(event_tree, event);
|
||||
}
|
||||
|
||||
void event_del(event_t *event)
|
||||
{
|
||||
void event_del(event_t *event) {
|
||||
cp();
|
||||
|
||||
avl_delete(event_tree, event);
|
||||
}
|
||||
|
||||
event_t *get_expired_event(void)
|
||||
{
|
||||
event_t *get_expired_event(void) {
|
||||
event_t *event;
|
||||
|
||||
cp();
|
||||
|
|
12
src/graph.c
12
src/graph.c
|
@ -64,8 +64,7 @@ static bool graph_changed = true;
|
|||
Please note that sorting on weight is already done by add_edge().
|
||||
*/
|
||||
|
||||
void mst_kruskal(void)
|
||||
{
|
||||
void mst_kruskal(void) {
|
||||
avl_node_t *node, *next;
|
||||
edge_t *e;
|
||||
node_t *n;
|
||||
|
@ -148,8 +147,7 @@ void mst_kruskal(void)
|
|||
Running time: O(E)
|
||||
*/
|
||||
|
||||
void sssp_bfs(void)
|
||||
{
|
||||
void sssp_bfs(void) {
|
||||
avl_node_t *node, *next, *to;
|
||||
edge_t *e;
|
||||
node_t *n;
|
||||
|
@ -296,8 +294,7 @@ void sssp_bfs(void)
|
|||
}
|
||||
}
|
||||
|
||||
void graph(void)
|
||||
{
|
||||
void graph(void) {
|
||||
subnet_cache_flush();
|
||||
sssp_bfs();
|
||||
mst_kruskal();
|
||||
|
@ -312,8 +309,7 @@ void graph(void)
|
|||
dot -Tpng graph_filename -o image_filename.png -Gconcentrate=true
|
||||
*/
|
||||
|
||||
void dump_graph(void)
|
||||
{
|
||||
void dump_graph(void) {
|
||||
avl_node_t *node;
|
||||
node_t *n;
|
||||
edge_t *e;
|
||||
|
|
|
@ -50,8 +50,7 @@ static char *device_info;
|
|||
static int device_total_in = 0;
|
||||
static int device_total_out = 0;
|
||||
|
||||
bool setup_device(void)
|
||||
{
|
||||
bool setup_device(void) {
|
||||
struct ifreq ifr;
|
||||
|
||||
cp();
|
||||
|
@ -116,8 +115,7 @@ bool setup_device(void)
|
|||
return true;
|
||||
}
|
||||
|
||||
void close_device(void)
|
||||
{
|
||||
void close_device(void) {
|
||||
cp();
|
||||
|
||||
close(device_fd);
|
||||
|
@ -126,8 +124,7 @@ void close_device(void)
|
|||
free(iface);
|
||||
}
|
||||
|
||||
bool read_packet(vpn_packet_t *packet)
|
||||
{
|
||||
bool read_packet(vpn_packet_t *packet) {
|
||||
int lenin;
|
||||
|
||||
cp();
|
||||
|
@ -176,8 +173,7 @@ bool read_packet(vpn_packet_t *packet)
|
|||
return true;
|
||||
}
|
||||
|
||||
bool write_packet(vpn_packet_t *packet)
|
||||
{
|
||||
bool write_packet(vpn_packet_t *packet) {
|
||||
cp();
|
||||
|
||||
ifdebug(TRAFFIC) logger(LOG_DEBUG, _("Writing packet of %d bytes to %s"),
|
||||
|
@ -215,8 +211,7 @@ bool write_packet(vpn_packet_t *packet)
|
|||
return true;
|
||||
}
|
||||
|
||||
void dump_device_stats(void)
|
||||
{
|
||||
void dump_device_stats(void) {
|
||||
cp();
|
||||
|
||||
logger(LOG_DEBUG, _("Statistics for %s %s:"), device_info, device);
|
||||
|
|
12
src/meta.c
12
src/meta.c
|
@ -32,8 +32,7 @@
|
|||
#include "utils.h"
|
||||
#include "xalloc.h"
|
||||
|
||||
bool send_meta(connection_t *c, const char *buffer, int length)
|
||||
{
|
||||
bool send_meta(connection_t *c, const char *buffer, int length) {
|
||||
int outlen;
|
||||
int result;
|
||||
|
||||
|
@ -82,8 +81,7 @@ bool send_meta(connection_t *c, const char *buffer, int length)
|
|||
return true;
|
||||
}
|
||||
|
||||
bool flush_meta(connection_t *c)
|
||||
{
|
||||
bool flush_meta(connection_t *c) {
|
||||
int result;
|
||||
|
||||
ifdebug(META) logger(LOG_DEBUG, _("Flushing %d bytes to %s (%s)"),
|
||||
|
@ -119,8 +117,7 @@ bool flush_meta(connection_t *c)
|
|||
return true;
|
||||
}
|
||||
|
||||
void broadcast_meta(connection_t *from, const char *buffer, int length)
|
||||
{
|
||||
void broadcast_meta(connection_t *from, const char *buffer, int length) {
|
||||
avl_node_t *node;
|
||||
connection_t *c;
|
||||
|
||||
|
@ -134,8 +131,7 @@ void broadcast_meta(connection_t *from, const char *buffer, int length)
|
|||
}
|
||||
}
|
||||
|
||||
bool receive_meta(connection_t *c)
|
||||
{
|
||||
bool receive_meta(connection_t *c) {
|
||||
int oldlen, i, result;
|
||||
int lenin, lenout, reqlen;
|
||||
bool decrypted = false;
|
||||
|
|
|
@ -82,8 +82,7 @@ static DWORD WINAPI tapreader(void *bla) {
|
|||
}
|
||||
}
|
||||
|
||||
bool setup_device(void)
|
||||
{
|
||||
bool setup_device(void) {
|
||||
HKEY key, key2;
|
||||
int i;
|
||||
|
||||
|
@ -220,8 +219,7 @@ bool setup_device(void)
|
|||
return true;
|
||||
}
|
||||
|
||||
void close_device(void)
|
||||
{
|
||||
void close_device(void) {
|
||||
cp();
|
||||
|
||||
CloseHandle(device_handle);
|
||||
|
@ -230,13 +228,11 @@ void close_device(void)
|
|||
free(iface);
|
||||
}
|
||||
|
||||
bool read_packet(vpn_packet_t *packet)
|
||||
{
|
||||
bool read_packet(vpn_packet_t *packet) {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool write_packet(vpn_packet_t *packet)
|
||||
{
|
||||
bool write_packet(vpn_packet_t *packet) {
|
||||
long lenout;
|
||||
OVERLAPPED overlapped = {0};
|
||||
|
||||
|
@ -255,8 +251,7 @@ bool write_packet(vpn_packet_t *packet)
|
|||
return true;
|
||||
}
|
||||
|
||||
void dump_device_stats(void)
|
||||
{
|
||||
void dump_device_stats(void) {
|
||||
cp();
|
||||
|
||||
logger(LOG_DEBUG, _("Statistics for %s %s:"), device_info, device);
|
||||
|
|
18
src/net.c
18
src/net.c
|
@ -46,8 +46,7 @@ time_t now = 0;
|
|||
|
||||
/* Purge edges and subnets of unreachable nodes. Use carefully. */
|
||||
|
||||
static void purge(void)
|
||||
{
|
||||
static void purge(void) {
|
||||
avl_node_t *nnode, *nnext, *enode, *enext, *snode, *snext;
|
||||
node_t *n;
|
||||
edge_t *e;
|
||||
|
@ -110,8 +109,7 @@ static void purge(void)
|
|||
put all file descriptors in an fd_set array
|
||||
While we're at it, purge stuff that needs to be removed.
|
||||
*/
|
||||
static int build_fdset(fd_set *readset, fd_set *writeset)
|
||||
{
|
||||
static int build_fdset(fd_set *readset, fd_set *writeset) {
|
||||
avl_node_t *node, *next;
|
||||
connection_t *c;
|
||||
int i, max = 0;
|
||||
|
@ -162,8 +160,7 @@ static int build_fdset(fd_set *readset, fd_set *writeset)
|
|||
- Check if we need to retry making an outgoing connection
|
||||
- Deactivate the host
|
||||
*/
|
||||
void terminate_connection(connection_t *c, bool report)
|
||||
{
|
||||
void terminate_connection(connection_t *c, bool report) {
|
||||
cp();
|
||||
|
||||
if(c->status.remove)
|
||||
|
@ -226,8 +223,7 @@ void terminate_connection(connection_t *c, bool report)
|
|||
end does not reply in time, we consider them dead
|
||||
and close the connection.
|
||||
*/
|
||||
static void check_dead_connections(void)
|
||||
{
|
||||
static void check_dead_connections(void) {
|
||||
avl_node_t *node, *next;
|
||||
connection_t *c;
|
||||
|
||||
|
@ -282,8 +278,7 @@ static void check_dead_connections(void)
|
|||
check all connections to see if anything
|
||||
happened on their sockets
|
||||
*/
|
||||
static void check_network_activity(fd_set * readset, fd_set * writeset)
|
||||
{
|
||||
static void check_network_activity(fd_set * readset, fd_set * writeset) {
|
||||
connection_t *c;
|
||||
avl_node_t *node;
|
||||
int result, i;
|
||||
|
@ -350,8 +345,7 @@ static void check_network_activity(fd_set * readset, fd_set * writeset)
|
|||
/*
|
||||
this is where it all happens...
|
||||
*/
|
||||
int main_loop(void)
|
||||
{
|
||||
int main_loop(void) {
|
||||
fd_set readset, writeset;
|
||||
struct timeval tv;
|
||||
int r, maxfd;
|
||||
|
|
|
@ -58,8 +58,7 @@ static void send_udppacket(node_t *, vpn_packet_t *);
|
|||
|
||||
#define MAX_SEQNO 1073741824
|
||||
|
||||
void send_mtu_probe(node_t *n)
|
||||
{
|
||||
void send_mtu_probe(node_t *n) {
|
||||
vpn_packet_t packet;
|
||||
int len, i;
|
||||
|
||||
|
@ -118,8 +117,7 @@ void mtu_probe_h(node_t *n, vpn_packet_t *packet, length_t len) {
|
|||
}
|
||||
}
|
||||
|
||||
static length_t compress_packet(uint8_t *dest, const uint8_t *source, length_t len, int level)
|
||||
{
|
||||
static length_t compress_packet(uint8_t *dest, const uint8_t *source, length_t len, int level) {
|
||||
if(level == 10) {
|
||||
lzo_uint lzolen = MAXSIZE;
|
||||
lzo1x_1_compress(source, len, dest, &lzolen, lzo_wrkmem);
|
||||
|
@ -139,8 +137,7 @@ static length_t compress_packet(uint8_t *dest, const uint8_t *source, length_t l
|
|||
return -1;
|
||||
}
|
||||
|
||||
static length_t uncompress_packet(uint8_t *dest, const uint8_t *source, length_t len, int level)
|
||||
{
|
||||
static length_t uncompress_packet(uint8_t *dest, const uint8_t *source, length_t len, int level) {
|
||||
if(level > 9) {
|
||||
lzo_uint lzolen = MAXSIZE;
|
||||
if(lzo1x_decompress_safe(source, len, dest, &lzolen, NULL) == LZO_E_OK)
|
||||
|
@ -160,8 +157,7 @@ static length_t uncompress_packet(uint8_t *dest, const uint8_t *source, length_t
|
|||
|
||||
/* VPN packet I/O */
|
||||
|
||||
static void receive_packet(node_t *n, vpn_packet_t *packet)
|
||||
{
|
||||
static void receive_packet(node_t *n, vpn_packet_t *packet) {
|
||||
cp();
|
||||
|
||||
ifdebug(TRAFFIC) logger(LOG_DEBUG, _("Received packet of %d bytes from %s (%s)"),
|
||||
|
@ -170,8 +166,7 @@ static void receive_packet(node_t *n, vpn_packet_t *packet)
|
|||
route(n, packet);
|
||||
}
|
||||
|
||||
static bool try_mac(const node_t *n, const vpn_packet_t *inpkt)
|
||||
{
|
||||
static bool try_mac(const node_t *n, const vpn_packet_t *inpkt) {
|
||||
unsigned char hmac[EVP_MAX_MD_SIZE];
|
||||
|
||||
if(!n->indigest || !n->inmaclength || !n->inkey || inpkt->len < sizeof inpkt->seqno + n->inmaclength)
|
||||
|
@ -182,8 +177,7 @@ static bool try_mac(const node_t *n, const vpn_packet_t *inpkt)
|
|||
return !memcmp(hmac, (char *) &inpkt->seqno + inpkt->len - n->inmaclength, n->inmaclength);
|
||||
}
|
||||
|
||||
static void receive_udppacket(node_t *n, vpn_packet_t *inpkt)
|
||||
{
|
||||
static void receive_udppacket(node_t *n, vpn_packet_t *inpkt) {
|
||||
vpn_packet_t pkt1, pkt2;
|
||||
vpn_packet_t *pkt[] = { &pkt1, &pkt2, &pkt1, &pkt2 };
|
||||
int nextpkt = 0;
|
||||
|
@ -300,8 +294,7 @@ static void receive_udppacket(node_t *n, vpn_packet_t *inpkt)
|
|||
receive_packet(n, inpkt);
|
||||
}
|
||||
|
||||
void receive_tcppacket(connection_t *c, char *buffer, int len)
|
||||
{
|
||||
void receive_tcppacket(connection_t *c, char *buffer, int len) {
|
||||
vpn_packet_t outpkt;
|
||||
|
||||
cp();
|
||||
|
@ -316,8 +309,7 @@ void receive_tcppacket(connection_t *c, char *buffer, int len)
|
|||
receive_packet(c->node, &outpkt);
|
||||
}
|
||||
|
||||
static void send_udppacket(node_t *n, vpn_packet_t *origpkt)
|
||||
{
|
||||
static void send_udppacket(node_t *n, vpn_packet_t *origpkt) {
|
||||
vpn_packet_t pkt1, pkt2;
|
||||
vpn_packet_t *pkt[] = { &pkt1, &pkt2, &pkt1, &pkt2 };
|
||||
vpn_packet_t *inpkt = origpkt;
|
||||
|
@ -449,8 +441,7 @@ end:
|
|||
/*
|
||||
send a packet to the given vpn ip.
|
||||
*/
|
||||
void send_packet(const node_t *n, vpn_packet_t *packet)
|
||||
{
|
||||
void send_packet(const node_t *n, vpn_packet_t *packet) {
|
||||
node_t *via;
|
||||
|
||||
cp();
|
||||
|
@ -486,8 +477,7 @@ void send_packet(const node_t *n, vpn_packet_t *packet)
|
|||
|
||||
/* Broadcast a packet using the minimum spanning tree */
|
||||
|
||||
void broadcast_packet(const node_t *from, vpn_packet_t *packet)
|
||||
{
|
||||
void broadcast_packet(const node_t *from, vpn_packet_t *packet) {
|
||||
avl_node_t *node;
|
||||
connection_t *c;
|
||||
|
||||
|
@ -537,8 +527,7 @@ static node_t *try_harder(const sockaddr_t *from, const vpn_packet_t *pkt) {
|
|||
return n;
|
||||
}
|
||||
|
||||
void handle_incoming_vpn_data(int sock)
|
||||
{
|
||||
void handle_incoming_vpn_data(int sock) {
|
||||
vpn_packet_t pkt;
|
||||
char *hostname;
|
||||
sockaddr_t from;
|
||||
|
|
|
@ -44,8 +44,7 @@
|
|||
|
||||
char *myport;
|
||||
|
||||
bool read_rsa_public_key(connection_t *c)
|
||||
{
|
||||
bool read_rsa_public_key(connection_t *c) {
|
||||
FILE *fp;
|
||||
char *fname;
|
||||
char *key;
|
||||
|
@ -145,8 +144,7 @@ bool read_rsa_public_key(connection_t *c)
|
|||
return false;
|
||||
}
|
||||
|
||||
bool read_rsa_private_key(void)
|
||||
{
|
||||
bool read_rsa_private_key(void) {
|
||||
FILE *fp;
|
||||
char *fname, *key, *pubkey;
|
||||
struct stat s;
|
||||
|
@ -209,8 +207,7 @@ bool read_rsa_private_key(void)
|
|||
/*
|
||||
Configure node_t myself and set up the local sockets (listen only)
|
||||
*/
|
||||
bool setup_myself(void)
|
||||
{
|
||||
bool setup_myself(void) {
|
||||
config_t *cfg;
|
||||
subnet_t *subnet;
|
||||
char *name, *hostname, *mode, *afname, *cipher, *digest;
|
||||
|
@ -506,8 +503,7 @@ bool setup_myself(void)
|
|||
/*
|
||||
initialize network
|
||||
*/
|
||||
bool setup_network(void)
|
||||
{
|
||||
bool setup_network(void) {
|
||||
cp();
|
||||
|
||||
now = time(NULL);
|
||||
|
@ -543,8 +539,7 @@ bool setup_network(void)
|
|||
/*
|
||||
close all open network connections
|
||||
*/
|
||||
void close_network_connections(void)
|
||||
{
|
||||
void close_network_connections(void) {
|
||||
avl_node_t *node, *next;
|
||||
connection_t *c;
|
||||
char *envp[5];
|
||||
|
|
|
@ -54,8 +54,7 @@ list_t *outgoing_list = NULL;
|
|||
|
||||
/* Setup sockets */
|
||||
|
||||
static void configure_tcp(connection_t *c)
|
||||
{
|
||||
static void configure_tcp(connection_t *c) {
|
||||
int option;
|
||||
|
||||
#ifdef O_NONBLOCK
|
||||
|
@ -83,7 +82,7 @@ static void configure_tcp(connection_t *c)
|
|||
#endif
|
||||
}
|
||||
|
||||
static bool bind_to_interface(int sd) { /* {{{ */
|
||||
static bool bind_to_interface(int sd) {
|
||||
char *iface;
|
||||
|
||||
#if defined(SOL_SOCKET) && defined(SO_BINDTODEVICE)
|
||||
|
@ -110,9 +109,9 @@ static bool bind_to_interface(int sd) { /* {{{ */
|
|||
#endif
|
||||
|
||||
return true;
|
||||
} /* }}} bool bind_to_interface */
|
||||
}
|
||||
|
||||
static bool bind_to_address(connection_t *c) { /* {{{ */
|
||||
static bool bind_to_address(connection_t *c) {
|
||||
char *node;
|
||||
struct addrinfo *ai_list;
|
||||
struct addrinfo *ai_ptr;
|
||||
|
@ -168,10 +167,9 @@ static bool bind_to_address(connection_t *c) { /* {{{ */
|
|||
freeaddrinfo(ai_list);
|
||||
|
||||
return status ? false : true;
|
||||
} /* }}} bool bind_to_address */
|
||||
}
|
||||
|
||||
int setup_listen_socket(const sockaddr_t *sa)
|
||||
{
|
||||
int setup_listen_socket(const sockaddr_t *sa) {
|
||||
int nfd;
|
||||
char *addrstr;
|
||||
int option;
|
||||
|
@ -234,8 +232,7 @@ int setup_listen_socket(const sockaddr_t *sa)
|
|||
return nfd;
|
||||
}
|
||||
|
||||
int setup_vpn_in_socket(const sockaddr_t *sa)
|
||||
{
|
||||
int setup_vpn_in_socket(const sockaddr_t *sa) {
|
||||
int nfd;
|
||||
char *addrstr;
|
||||
int option;
|
||||
|
@ -311,8 +308,7 @@ int setup_vpn_in_socket(const sockaddr_t *sa)
|
|||
return nfd;
|
||||
} /* int setup_vpn_in_socket */
|
||||
|
||||
void retry_outgoing(outgoing_t *outgoing)
|
||||
{
|
||||
void retry_outgoing(outgoing_t *outgoing) {
|
||||
event_t *event;
|
||||
|
||||
cp();
|
||||
|
@ -333,8 +329,7 @@ void retry_outgoing(outgoing_t *outgoing)
|
|||
outgoing->timeout);
|
||||
}
|
||||
|
||||
void finish_connecting(connection_t *c)
|
||||
{
|
||||
void finish_connecting(connection_t *c) {
|
||||
cp();
|
||||
|
||||
ifdebug(CONNECTIONS) logger(LOG_INFO, _("Connected to %s (%s)"), c->name, c->hostname);
|
||||
|
@ -346,8 +341,7 @@ void finish_connecting(connection_t *c)
|
|||
send_id(c);
|
||||
}
|
||||
|
||||
void do_outgoing_connection(connection_t *c)
|
||||
{
|
||||
void do_outgoing_connection(connection_t *c) {
|
||||
char *address, *port;
|
||||
int result;
|
||||
|
||||
|
@ -442,8 +436,7 @@ begin:
|
|||
return;
|
||||
}
|
||||
|
||||
void setup_outgoing_connection(outgoing_t *outgoing)
|
||||
{
|
||||
void setup_outgoing_connection(outgoing_t *outgoing) {
|
||||
connection_t *c;
|
||||
node_t *n;
|
||||
|
||||
|
@ -489,8 +482,7 @@ void setup_outgoing_connection(outgoing_t *outgoing)
|
|||
accept a new tcp connect and create a
|
||||
new connection
|
||||
*/
|
||||
bool handle_new_meta_connection(int sock)
|
||||
{
|
||||
bool handle_new_meta_connection(int sock) {
|
||||
connection_t *c;
|
||||
sockaddr_t sa;
|
||||
int fd;
|
||||
|
@ -542,8 +534,7 @@ void free_outgoing(outgoing_t *outgoing) {
|
|||
free(outgoing);
|
||||
}
|
||||
|
||||
void try_outgoing_connections(void)
|
||||
{
|
||||
void try_outgoing_connections(void) {
|
||||
static config_t *cfg = NULL;
|
||||
char *name;
|
||||
outgoing_t *outgoing;
|
||||
|
|
33
src/netutl.c
33
src/netutl.c
|
@ -32,8 +32,7 @@ bool hostnames = false;
|
|||
Turn a string into a struct addrinfo.
|
||||
Return NULL on failure.
|
||||
*/
|
||||
struct addrinfo *str2addrinfo(const char *address, const char *service, int socktype)
|
||||
{
|
||||
struct addrinfo *str2addrinfo(const char *address, const char *service, int socktype) {
|
||||
struct addrinfo *ai, hint = {0};
|
||||
int err;
|
||||
|
||||
|
@ -53,8 +52,7 @@ struct addrinfo *str2addrinfo(const char *address, const char *service, int sock
|
|||
return ai;
|
||||
}
|
||||
|
||||
sockaddr_t str2sockaddr(const char *address, const char *port)
|
||||
{
|
||||
sockaddr_t str2sockaddr(const char *address, const char *port) {
|
||||
struct addrinfo *ai, hint = {0};
|
||||
sockaddr_t result;
|
||||
int err;
|
||||
|
@ -82,8 +80,7 @@ sockaddr_t str2sockaddr(const char *address, const char *port)
|
|||
return result;
|
||||
}
|
||||
|
||||
void sockaddr2str(const sockaddr_t *sa, char **addrstr, char **portstr)
|
||||
{
|
||||
void sockaddr2str(const sockaddr_t *sa, char **addrstr, char **portstr) {
|
||||
char address[NI_MAXHOST];
|
||||
char port[NI_MAXSERV];
|
||||
char *scopeid;
|
||||
|
@ -116,8 +113,7 @@ void sockaddr2str(const sockaddr_t *sa, char **addrstr, char **portstr)
|
|||
*portstr = xstrdup(port);
|
||||
}
|
||||
|
||||
char *sockaddr2hostname(const sockaddr_t *sa)
|
||||
{
|
||||
char *sockaddr2hostname(const sockaddr_t *sa) {
|
||||
char *str;
|
||||
char address[NI_MAXHOST] = "unknown";
|
||||
char port[NI_MAXSERV] = "unknown";
|
||||
|
@ -142,8 +138,7 @@ char *sockaddr2hostname(const sockaddr_t *sa)
|
|||
return str;
|
||||
}
|
||||
|
||||
int sockaddrcmp_noport(const sockaddr_t *a, const sockaddr_t *b)
|
||||
{
|
||||
int sockaddrcmp_noport(const sockaddr_t *a, const sockaddr_t *b) {
|
||||
int result;
|
||||
|
||||
cp();
|
||||
|
@ -175,8 +170,7 @@ int sockaddrcmp_noport(const sockaddr_t *a, const sockaddr_t *b)
|
|||
}
|
||||
}
|
||||
|
||||
int sockaddrcmp(const sockaddr_t *a, const sockaddr_t *b)
|
||||
{
|
||||
int sockaddrcmp(const sockaddr_t *a, const sockaddr_t *b) {
|
||||
int result;
|
||||
|
||||
cp();
|
||||
|
@ -244,8 +238,7 @@ void sockaddrfree(sockaddr_t *a) {
|
|||
}
|
||||
}
|
||||
|
||||
void sockaddrunmap(sockaddr_t *sa)
|
||||
{
|
||||
void sockaddrunmap(sockaddr_t *sa) {
|
||||
cp();
|
||||
|
||||
if(sa->sa.sa_family == AF_INET6 && IN6_IS_ADDR_V4MAPPED(&sa->in6.sin6_addr)) {
|
||||
|
@ -256,8 +249,7 @@ void sockaddrunmap(sockaddr_t *sa)
|
|||
|
||||
/* Subnet mask handling */
|
||||
|
||||
int maskcmp(const void *va, const void *vb, int masklen)
|
||||
{
|
||||
int maskcmp(const void *va, const void *vb, int masklen) {
|
||||
int i, m, result;
|
||||
const char *a = va;
|
||||
const char *b = vb;
|
||||
|
@ -277,8 +269,7 @@ int maskcmp(const void *va, const void *vb, int masklen)
|
|||
return 0;
|
||||
}
|
||||
|
||||
void mask(void *va, int masklen, int len)
|
||||
{
|
||||
void mask(void *va, int masklen, int len) {
|
||||
int i;
|
||||
char *a = va;
|
||||
|
||||
|
@ -294,8 +285,7 @@ void mask(void *va, int masklen, int len)
|
|||
a[i] = 0;
|
||||
}
|
||||
|
||||
void maskcpy(void *va, const void *vb, int masklen, int len)
|
||||
{
|
||||
void maskcpy(void *va, const void *vb, int masklen, int len) {
|
||||
int i, m;
|
||||
char *a = va;
|
||||
const char *b = vb;
|
||||
|
@ -314,8 +304,7 @@ void maskcpy(void *va, const void *vb, int masklen, int len)
|
|||
a[i] = 0;
|
||||
}
|
||||
|
||||
bool maskcheck(const void *va, int masklen, int len)
|
||||
{
|
||||
bool maskcheck(const void *va, int masklen, int len) {
|
||||
int i;
|
||||
const char *a = va;
|
||||
|
||||
|
|
36
src/node.c
36
src/node.c
|
@ -33,34 +33,29 @@ avl_tree_t *node_udp_tree; /* Known nodes, sorted by address and port */
|
|||
|
||||
node_t *myself;
|
||||
|
||||
static int node_compare(const node_t *a, const node_t *b)
|
||||
{
|
||||
static int node_compare(const node_t *a, const node_t *b) {
|
||||
return strcmp(a->name, b->name);
|
||||
}
|
||||
|
||||
static int node_udp_compare(const node_t *a, const node_t *b)
|
||||
{
|
||||
static int node_udp_compare(const node_t *a, const node_t *b) {
|
||||
return sockaddrcmp(&a->address, &b->address);
|
||||
}
|
||||
|
||||
void init_nodes(void)
|
||||
{
|
||||
void init_nodes(void) {
|
||||
cp();
|
||||
|
||||
node_tree = avl_alloc_tree((avl_compare_t) node_compare, (avl_action_t) free_node);
|
||||
node_udp_tree = avl_alloc_tree((avl_compare_t) node_udp_compare, NULL);
|
||||
}
|
||||
|
||||
void exit_nodes(void)
|
||||
{
|
||||
void exit_nodes(void) {
|
||||
cp();
|
||||
|
||||
avl_delete_tree(node_udp_tree);
|
||||
avl_delete_tree(node_tree);
|
||||
}
|
||||
|
||||
node_t *new_node(void)
|
||||
{
|
||||
node_t *new_node(void) {
|
||||
node_t *n = xmalloc_and_zero(sizeof(*n));
|
||||
|
||||
cp();
|
||||
|
@ -75,8 +70,7 @@ node_t *new_node(void)
|
|||
return n;
|
||||
}
|
||||
|
||||
void free_node(node_t *n)
|
||||
{
|
||||
void free_node(node_t *n) {
|
||||
cp();
|
||||
|
||||
if(n->inkey)
|
||||
|
@ -108,15 +102,13 @@ void free_node(node_t *n)
|
|||
free(n);
|
||||
}
|
||||
|
||||
void node_add(node_t *n)
|
||||
{
|
||||
void node_add(node_t *n) {
|
||||
cp();
|
||||
|
||||
avl_insert(node_tree, n);
|
||||
}
|
||||
|
||||
void node_del(node_t *n)
|
||||
{
|
||||
void node_del(node_t *n) {
|
||||
avl_node_t *node, *next;
|
||||
edge_t *e;
|
||||
subnet_t *s;
|
||||
|
@ -139,8 +131,7 @@ void node_del(node_t *n)
|
|||
avl_delete(node_tree, n);
|
||||
}
|
||||
|
||||
node_t *lookup_node(char *name)
|
||||
{
|
||||
node_t *lookup_node(char *name) {
|
||||
node_t n = {0};
|
||||
|
||||
cp();
|
||||
|
@ -150,8 +141,7 @@ node_t *lookup_node(char *name)
|
|||
return avl_search(node_tree, &n);
|
||||
}
|
||||
|
||||
node_t *lookup_node_udp(const sockaddr_t *sa)
|
||||
{
|
||||
node_t *lookup_node_udp(const sockaddr_t *sa) {
|
||||
node_t n = {0};
|
||||
|
||||
cp();
|
||||
|
@ -162,8 +152,7 @@ node_t *lookup_node_udp(const sockaddr_t *sa)
|
|||
return avl_search(node_udp_tree, &n);
|
||||
}
|
||||
|
||||
void update_node_udp(node_t *n, const sockaddr_t *sa)
|
||||
{
|
||||
void update_node_udp(node_t *n, const sockaddr_t *sa) {
|
||||
avl_delete(node_udp_tree, n);
|
||||
|
||||
if(n->hostname)
|
||||
|
@ -181,8 +170,7 @@ void update_node_udp(node_t *n, const sockaddr_t *sa)
|
|||
}
|
||||
}
|
||||
|
||||
void dump_nodes(void)
|
||||
{
|
||||
void dump_nodes(void) {
|
||||
avl_node_t *node;
|
||||
node_t *n;
|
||||
|
||||
|
|
|
@ -47,8 +47,7 @@ sigset_t emptysigset;
|
|||
|
||||
static int saved_debug_level = -1;
|
||||
|
||||
static void memory_full(int size)
|
||||
{
|
||||
static void memory_full(int size) {
|
||||
logger(LOG_ERR, _("Memory exhausted (couldn't allocate %d bytes), exitting."), size);
|
||||
cp_trace();
|
||||
exit(1);
|
||||
|
@ -181,8 +180,7 @@ DWORD WINAPI controlhandler(DWORD request, DWORD type, LPVOID boe, LPVOID bah) {
|
|||
|
||||
}
|
||||
|
||||
VOID WINAPI run_service(DWORD argc, LPTSTR* argv)
|
||||
{
|
||||
VOID WINAPI run_service(DWORD argc, LPTSTR* argv) {
|
||||
int err = 1;
|
||||
extern int main2(int argc, char **argv);
|
||||
|
||||
|
@ -240,8 +238,7 @@ bool init_service(void) {
|
|||
/*
|
||||
check for an existing tinc for this net, and write pid to pidfile
|
||||
*/
|
||||
static bool write_pidfile(void)
|
||||
{
|
||||
static bool write_pidfile(void) {
|
||||
pid_t pid;
|
||||
|
||||
cp();
|
||||
|
@ -270,8 +267,7 @@ static bool write_pidfile(void)
|
|||
/*
|
||||
kill older tincd for this net
|
||||
*/
|
||||
bool kill_other(int signal)
|
||||
{
|
||||
bool kill_other(int signal) {
|
||||
#ifndef HAVE_MINGW
|
||||
pid_t pid;
|
||||
|
||||
|
@ -311,8 +307,7 @@ bool kill_other(int signal)
|
|||
/*
|
||||
Detach from current terminal, write pidfile, kill parent
|
||||
*/
|
||||
bool detach(void)
|
||||
{
|
||||
bool detach(void) {
|
||||
cp();
|
||||
|
||||
setup_signals();
|
||||
|
@ -358,8 +353,7 @@ bool detach(void)
|
|||
return true;
|
||||
}
|
||||
|
||||
bool execute_script(const char *name, char **envp)
|
||||
{
|
||||
bool execute_script(const char *name, char **envp) {
|
||||
#ifdef HAVE_SYSTEM
|
||||
int status, len;
|
||||
char *scriptname, *p;
|
||||
|
@ -443,8 +437,7 @@ bool execute_script(const char *name, char **envp)
|
|||
*/
|
||||
|
||||
#ifndef HAVE_MINGW
|
||||
static RETSIGTYPE sigterm_handler(int a)
|
||||
{
|
||||
static RETSIGTYPE sigterm_handler(int a) {
|
||||
logger(LOG_NOTICE, _("Got %s signal"), "TERM");
|
||||
if(running)
|
||||
running = false;
|
||||
|
@ -452,8 +445,7 @@ static RETSIGTYPE sigterm_handler(int a)
|
|||
exit(1);
|
||||
}
|
||||
|
||||
static RETSIGTYPE sigquit_handler(int a)
|
||||
{
|
||||
static RETSIGTYPE sigquit_handler(int a) {
|
||||
logger(LOG_NOTICE, _("Got %s signal"), "QUIT");
|
||||
if(running)
|
||||
running = false;
|
||||
|
@ -461,16 +453,14 @@ static RETSIGTYPE sigquit_handler(int a)
|
|||
exit(1);
|
||||
}
|
||||
|
||||
static RETSIGTYPE fatal_signal_square(int a)
|
||||
{
|
||||
static RETSIGTYPE fatal_signal_square(int a) {
|
||||
logger(LOG_ERR, _("Got another fatal signal %d (%s): not restarting."), a,
|
||||
strsignal(a));
|
||||
cp_trace();
|
||||
exit(1);
|
||||
}
|
||||
|
||||
static RETSIGTYPE fatal_signal_handler(int a)
|
||||
{
|
||||
static RETSIGTYPE fatal_signal_handler(int a) {
|
||||
struct sigaction act;
|
||||
logger(LOG_ERR, _("Got fatal signal %d (%s)"), a, strsignal(a));
|
||||
cp_trace();
|
||||
|
@ -493,14 +483,12 @@ static RETSIGTYPE fatal_signal_handler(int a)
|
|||
}
|
||||
}
|
||||
|
||||
static RETSIGTYPE sighup_handler(int a)
|
||||
{
|
||||
static RETSIGTYPE sighup_handler(int a) {
|
||||
logger(LOG_NOTICE, _("Got %s signal"), "HUP");
|
||||
sighup = true;
|
||||
}
|
||||
|
||||
static RETSIGTYPE sigint_handler(int a)
|
||||
{
|
||||
static RETSIGTYPE sigint_handler(int a) {
|
||||
logger(LOG_NOTICE, _("Got %s signal"), "INT");
|
||||
|
||||
if(saved_debug_level != -1) {
|
||||
|
@ -517,38 +505,32 @@ static RETSIGTYPE sigint_handler(int a)
|
|||
}
|
||||
}
|
||||
|
||||
static RETSIGTYPE sigalrm_handler(int a)
|
||||
{
|
||||
static RETSIGTYPE sigalrm_handler(int a) {
|
||||
logger(LOG_NOTICE, _("Got %s signal"), "ALRM");
|
||||
sigalrm = true;
|
||||
}
|
||||
|
||||
static RETSIGTYPE sigusr1_handler(int a)
|
||||
{
|
||||
static RETSIGTYPE sigusr1_handler(int a) {
|
||||
dump_connections();
|
||||
}
|
||||
|
||||
static RETSIGTYPE sigusr2_handler(int a)
|
||||
{
|
||||
static RETSIGTYPE sigusr2_handler(int a) {
|
||||
dump_device_stats();
|
||||
dump_nodes();
|
||||
dump_edges();
|
||||
dump_subnets();
|
||||
}
|
||||
|
||||
static RETSIGTYPE sigwinch_handler(int a)
|
||||
{
|
||||
static RETSIGTYPE sigwinch_handler(int a) {
|
||||
do_purge = true;
|
||||
}
|
||||
|
||||
static RETSIGTYPE unexpected_signal_handler(int a)
|
||||
{
|
||||
static RETSIGTYPE unexpected_signal_handler(int a) {
|
||||
logger(LOG_WARNING, _("Got unexpected signal %d (%s)"), a, strsignal(a));
|
||||
cp_trace();
|
||||
}
|
||||
|
||||
static RETSIGTYPE ignore_signal_handler(int a)
|
||||
{
|
||||
static RETSIGTYPE ignore_signal_handler(int a) {
|
||||
ifdebug(SCARY_THINGS) logger(LOG_DEBUG, _("Ignored signal %d (%s)"), a, strsignal(a));
|
||||
}
|
||||
|
||||
|
@ -573,8 +555,7 @@ static struct {
|
|||
};
|
||||
#endif
|
||||
|
||||
void setup_signals(void)
|
||||
{
|
||||
void setup_signals(void) {
|
||||
#ifndef HAVE_MINGW
|
||||
int i;
|
||||
struct sigaction act;
|
||||
|
|
|
@ -53,8 +53,7 @@ static char (*request_name[]) = {
|
|||
|
||||
static avl_tree_t *past_request_tree;
|
||||
|
||||
bool check_id(const char *id)
|
||||
{
|
||||
bool check_id(const char *id) {
|
||||
for(; *id; id++)
|
||||
if(!isalnum(*id) && *id != '_')
|
||||
return false;
|
||||
|
@ -65,8 +64,7 @@ bool check_id(const char *id)
|
|||
/* Generic request routines - takes care of logging and error
|
||||
detection as well */
|
||||
|
||||
bool send_request(connection_t *c, const char *format, ...)
|
||||
{
|
||||
bool send_request(connection_t *c, const char *format, ...) {
|
||||
va_list args;
|
||||
char buffer[MAXBUFSIZE];
|
||||
int len, request;
|
||||
|
@ -106,8 +104,7 @@ bool send_request(connection_t *c, const char *format, ...)
|
|||
return send_meta(c, buffer, len);
|
||||
}
|
||||
|
||||
void forward_request(connection_t *from)
|
||||
{
|
||||
void forward_request(connection_t *from) {
|
||||
int request;
|
||||
|
||||
cp();
|
||||
|
@ -128,8 +125,7 @@ void forward_request(connection_t *from)
|
|||
broadcast_meta(from, from->buffer, from->reqlen);
|
||||
}
|
||||
|
||||
bool receive_request(connection_t *c)
|
||||
{
|
||||
bool receive_request(connection_t *c) {
|
||||
int request;
|
||||
|
||||
cp();
|
||||
|
@ -178,13 +174,11 @@ bool receive_request(connection_t *c)
|
|||
return true;
|
||||
}
|
||||
|
||||
static int past_request_compare(const past_request_t *a, const past_request_t *b)
|
||||
{
|
||||
static int past_request_compare(const past_request_t *a, const past_request_t *b) {
|
||||
return strcmp(a->request, b->request);
|
||||
}
|
||||
|
||||
static void free_past_request(past_request_t *r)
|
||||
{
|
||||
static void free_past_request(past_request_t *r) {
|
||||
cp();
|
||||
|
||||
if(r->request)
|
||||
|
@ -193,22 +187,19 @@ static void free_past_request(past_request_t *r)
|
|||
free(r);
|
||||
}
|
||||
|
||||
void init_requests(void)
|
||||
{
|
||||
void init_requests(void) {
|
||||
cp();
|
||||
|
||||
past_request_tree = avl_alloc_tree((avl_compare_t) past_request_compare, (avl_action_t) free_past_request);
|
||||
}
|
||||
|
||||
void exit_requests(void)
|
||||
{
|
||||
void exit_requests(void) {
|
||||
cp();
|
||||
|
||||
avl_delete_tree(past_request_tree);
|
||||
}
|
||||
|
||||
bool seen_request(char *request)
|
||||
{
|
||||
bool seen_request(char *request) {
|
||||
past_request_t *new, p = {0};
|
||||
|
||||
cp();
|
||||
|
@ -227,8 +218,7 @@ bool seen_request(char *request)
|
|||
}
|
||||
}
|
||||
|
||||
void age_past_requests(void)
|
||||
{
|
||||
void age_past_requests(void) {
|
||||
avl_node_t *node, *next;
|
||||
past_request_t *p;
|
||||
int left = 0, deleted = 0;
|
||||
|
|
|
@ -38,16 +38,14 @@
|
|||
#include "utils.h"
|
||||
#include "xalloc.h"
|
||||
|
||||
bool send_id(connection_t *c)
|
||||
{
|
||||
bool send_id(connection_t *c) {
|
||||
cp();
|
||||
|
||||
return send_request(c, "%d %s %d", ID, myself->connection->name,
|
||||
myself->connection->protocol_version);
|
||||
}
|
||||
|
||||
bool id_h(connection_t *c)
|
||||
{
|
||||
bool id_h(connection_t *c) {
|
||||
char name[MAX_STRING_SIZE];
|
||||
|
||||
cp();
|
||||
|
@ -114,8 +112,7 @@ bool id_h(connection_t *c)
|
|||
return send_metakey(c);
|
||||
}
|
||||
|
||||
bool send_metakey(connection_t *c)
|
||||
{
|
||||
bool send_metakey(connection_t *c) {
|
||||
char *buffer;
|
||||
int len;
|
||||
bool x;
|
||||
|
@ -199,8 +196,7 @@ bool send_metakey(connection_t *c)
|
|||
return x;
|
||||
}
|
||||
|
||||
bool metakey_h(connection_t *c)
|
||||
{
|
||||
bool metakey_h(connection_t *c) {
|
||||
char buffer[MAX_STRING_SIZE];
|
||||
int cipher, digest, maclength, compression;
|
||||
int len;
|
||||
|
@ -298,8 +294,7 @@ bool metakey_h(connection_t *c)
|
|||
return send_challenge(c);
|
||||
}
|
||||
|
||||
bool send_challenge(connection_t *c)
|
||||
{
|
||||
bool send_challenge(connection_t *c) {
|
||||
char *buffer;
|
||||
int len;
|
||||
|
||||
|
@ -329,8 +324,7 @@ bool send_challenge(connection_t *c)
|
|||
return send_request(c, "%d %s", CHALLENGE, buffer);
|
||||
}
|
||||
|
||||
bool challenge_h(connection_t *c)
|
||||
{
|
||||
bool challenge_h(connection_t *c) {
|
||||
char buffer[MAX_STRING_SIZE];
|
||||
int len;
|
||||
|
||||
|
@ -367,8 +361,7 @@ bool challenge_h(connection_t *c)
|
|||
return send_chal_reply(c);
|
||||
}
|
||||
|
||||
bool send_chal_reply(connection_t *c)
|
||||
{
|
||||
bool send_chal_reply(connection_t *c) {
|
||||
char hash[EVP_MAX_MD_SIZE * 2 + 1];
|
||||
EVP_MD_CTX ctx;
|
||||
|
||||
|
@ -394,8 +387,7 @@ bool send_chal_reply(connection_t *c)
|
|||
return send_request(c, "%d %s", CHAL_REPLY, hash);
|
||||
}
|
||||
|
||||
bool chal_reply_h(connection_t *c)
|
||||
{
|
||||
bool chal_reply_h(connection_t *c) {
|
||||
char hishash[MAX_STRING_SIZE];
|
||||
char myhash[EVP_MAX_MD_SIZE];
|
||||
EVP_MD_CTX ctx;
|
||||
|
@ -454,8 +446,7 @@ bool chal_reply_h(connection_t *c)
|
|||
return send_ack(c);
|
||||
}
|
||||
|
||||
bool send_ack(connection_t *c)
|
||||
{
|
||||
bool send_ack(connection_t *c) {
|
||||
/* ACK message contains rest of the information the other end needs
|
||||
to create node_t and edge_t structures. */
|
||||
|
||||
|
@ -485,8 +476,7 @@ bool send_ack(connection_t *c)
|
|||
return send_request(c, "%d %s %d %lx", ACK, myport, c->estimated_weight, c->options);
|
||||
}
|
||||
|
||||
static void send_everything(connection_t *c)
|
||||
{
|
||||
static void send_everything(connection_t *c) {
|
||||
avl_node_t *node, *node2;
|
||||
node_t *n;
|
||||
subnet_t *s;
|
||||
|
@ -518,8 +508,7 @@ static void send_everything(connection_t *c)
|
|||
}
|
||||
}
|
||||
|
||||
bool ack_h(connection_t *c)
|
||||
{
|
||||
bool ack_h(connection_t *c) {
|
||||
char hisport[MAX_STRING_SIZE];
|
||||
char *hisaddress, *dummy;
|
||||
int weight, mtu;
|
||||
|
|
|
@ -35,8 +35,7 @@
|
|||
#include "utils.h"
|
||||
#include "xalloc.h"
|
||||
|
||||
bool send_add_edge(connection_t *c, const edge_t *e)
|
||||
{
|
||||
bool send_add_edge(connection_t *c, const edge_t *e) {
|
||||
bool x;
|
||||
char *address, *port;
|
||||
|
||||
|
@ -53,8 +52,7 @@ bool send_add_edge(connection_t *c, const edge_t *e)
|
|||
return x;
|
||||
}
|
||||
|
||||
bool add_edge_h(connection_t *c)
|
||||
{
|
||||
bool add_edge_h(connection_t *c) {
|
||||
edge_t *e;
|
||||
node_t *from, *to;
|
||||
char from_name[MAX_STRING_SIZE];
|
||||
|
@ -173,16 +171,14 @@ bool add_edge_h(connection_t *c)
|
|||
return true;
|
||||
}
|
||||
|
||||
bool send_del_edge(connection_t *c, const edge_t *e)
|
||||
{
|
||||
bool send_del_edge(connection_t *c, const edge_t *e) {
|
||||
cp();
|
||||
|
||||
return send_request(c, "%d %x %s %s", DEL_EDGE, rand(),
|
||||
e->from->name, e->to->name);
|
||||
}
|
||||
|
||||
bool del_edge_h(connection_t *c)
|
||||
{
|
||||
bool del_edge_h(connection_t *c) {
|
||||
edge_t *e;
|
||||
char from_name[MAX_STRING_SIZE];
|
||||
char to_name[MAX_STRING_SIZE];
|
||||
|
|
|
@ -36,8 +36,7 @@
|
|||
|
||||
bool mykeyused = false;
|
||||
|
||||
bool send_key_changed()
|
||||
{
|
||||
bool send_key_changed() {
|
||||
cp();
|
||||
|
||||
/* Only send this message if some other daemon requested our key previously.
|
||||
|
@ -50,8 +49,7 @@ bool send_key_changed()
|
|||
return send_request(broadcast, "%d %x %s", KEY_CHANGED, rand(), myself->name);
|
||||
}
|
||||
|
||||
bool key_changed_h(connection_t *c)
|
||||
{
|
||||
bool key_changed_h(connection_t *c) {
|
||||
char name[MAX_STRING_SIZE];
|
||||
node_t *n;
|
||||
|
||||
|
@ -85,15 +83,13 @@ bool key_changed_h(connection_t *c)
|
|||
return true;
|
||||
}
|
||||
|
||||
bool send_req_key(node_t *to)
|
||||
{
|
||||
bool send_req_key(node_t *to) {
|
||||
cp();
|
||||
|
||||
return send_request(to->nexthop->connection, "%d %s %s", REQ_KEY, myself->name, to->name);
|
||||
}
|
||||
|
||||
bool req_key_h(connection_t *c)
|
||||
{
|
||||
bool req_key_h(connection_t *c) {
|
||||
char from_name[MAX_STRING_SIZE];
|
||||
char to_name[MAX_STRING_SIZE];
|
||||
node_t *from, *to;
|
||||
|
@ -142,8 +138,7 @@ bool req_key_h(connection_t *c)
|
|||
return true;
|
||||
}
|
||||
|
||||
bool send_ans_key(node_t *to)
|
||||
{
|
||||
bool send_ans_key(node_t *to) {
|
||||
char *key;
|
||||
|
||||
cp();
|
||||
|
@ -180,8 +175,7 @@ bool send_ans_key(node_t *to)
|
|||
to->incompression);
|
||||
}
|
||||
|
||||
bool ans_key_h(connection_t *c)
|
||||
{
|
||||
bool ans_key_h(connection_t *c) {
|
||||
char from_name[MAX_STRING_SIZE];
|
||||
char to_name[MAX_STRING_SIZE];
|
||||
char key[MAX_STRING_SIZE];
|
||||
|
|
|
@ -33,8 +33,7 @@ int maxoutbufsize = 0;
|
|||
|
||||
/* Status and error notification routines */
|
||||
|
||||
bool send_status(connection_t *c, int statusno, const char *statusstring)
|
||||
{
|
||||
bool send_status(connection_t *c, int statusno, const char *statusstring) {
|
||||
cp();
|
||||
|
||||
if(!statusstring)
|
||||
|
@ -43,8 +42,7 @@ bool send_status(connection_t *c, int statusno, const char *statusstring)
|
|||
return send_request(c, "%d %d %s", STATUS, statusno, statusstring);
|
||||
}
|
||||
|
||||
bool status_h(connection_t *c)
|
||||
{
|
||||
bool status_h(connection_t *c) {
|
||||
int statusno;
|
||||
char statusstring[MAX_STRING_SIZE];
|
||||
|
||||
|
@ -62,8 +60,7 @@ bool status_h(connection_t *c)
|
|||
return true;
|
||||
}
|
||||
|
||||
bool send_error(connection_t *c, int err, const char *errstring)
|
||||
{
|
||||
bool send_error(connection_t *c, int err, const char *errstring) {
|
||||
cp();
|
||||
|
||||
if(!errstring)
|
||||
|
@ -72,8 +69,7 @@ bool send_error(connection_t *c, int err, const char *errstring)
|
|||
return send_request(c, "%d %d %s", ERROR, err, errstring);
|
||||
}
|
||||
|
||||
bool error_h(connection_t *c)
|
||||
{
|
||||
bool error_h(connection_t *c) {
|
||||
int err;
|
||||
char errorstring[MAX_STRING_SIZE];
|
||||
|
||||
|
@ -93,15 +89,13 @@ bool error_h(connection_t *c)
|
|||
return true;
|
||||
}
|
||||
|
||||
bool send_termreq(connection_t *c)
|
||||
{
|
||||
bool send_termreq(connection_t *c) {
|
||||
cp();
|
||||
|
||||
return send_request(c, "%d", TERMREQ);
|
||||
}
|
||||
|
||||
bool termreq_h(connection_t *c)
|
||||
{
|
||||
bool termreq_h(connection_t *c) {
|
||||
cp();
|
||||
|
||||
terminate_connection(c, c->status.active);
|
||||
|
@ -109,8 +103,7 @@ bool termreq_h(connection_t *c)
|
|||
return true;
|
||||
}
|
||||
|
||||
bool send_ping(connection_t *c)
|
||||
{
|
||||
bool send_ping(connection_t *c) {
|
||||
cp();
|
||||
|
||||
c->status.pinged = true;
|
||||
|
@ -119,22 +112,19 @@ bool send_ping(connection_t *c)
|
|||
return send_request(c, "%d", PING);
|
||||
}
|
||||
|
||||
bool ping_h(connection_t *c)
|
||||
{
|
||||
bool ping_h(connection_t *c) {
|
||||
cp();
|
||||
|
||||
return send_pong(c);
|
||||
}
|
||||
|
||||
bool send_pong(connection_t *c)
|
||||
{
|
||||
bool send_pong(connection_t *c) {
|
||||
cp();
|
||||
|
||||
return send_request(c, "%d", PONG);
|
||||
}
|
||||
|
||||
bool pong_h(connection_t *c)
|
||||
{
|
||||
bool pong_h(connection_t *c) {
|
||||
cp();
|
||||
|
||||
c->status.pinged = false;
|
||||
|
@ -149,8 +139,7 @@ bool pong_h(connection_t *c)
|
|||
|
||||
/* Sending and receiving packets via TCP */
|
||||
|
||||
bool send_tcppacket(connection_t *c, vpn_packet_t *packet)
|
||||
{
|
||||
bool send_tcppacket(connection_t *c, vpn_packet_t *packet) {
|
||||
cp();
|
||||
|
||||
/* If there already is a lot of data in the outbuf buffer, discard this packet.
|
||||
|
@ -165,8 +154,7 @@ bool send_tcppacket(connection_t *c, vpn_packet_t *packet)
|
|||
return send_meta(c, (char *)packet->data, packet->len);
|
||||
}
|
||||
|
||||
bool tcppacket_h(connection_t *c)
|
||||
{
|
||||
bool tcppacket_h(connection_t *c) {
|
||||
short int len;
|
||||
|
||||
cp();
|
||||
|
|
|
@ -32,8 +32,7 @@
|
|||
#include "utils.h"
|
||||
#include "xalloc.h"
|
||||
|
||||
bool send_add_subnet(connection_t *c, const subnet_t *subnet)
|
||||
{
|
||||
bool send_add_subnet(connection_t *c, const subnet_t *subnet) {
|
||||
char netstr[MAXNETSTR];
|
||||
|
||||
cp();
|
||||
|
@ -44,8 +43,7 @@ bool send_add_subnet(connection_t *c, const subnet_t *subnet)
|
|||
return send_request(c, "%d %x %s %s", ADD_SUBNET, rand(), subnet->owner->name, netstr);
|
||||
}
|
||||
|
||||
bool add_subnet_h(connection_t *c)
|
||||
{
|
||||
bool add_subnet_h(connection_t *c) {
|
||||
char subnetstr[MAX_STRING_SIZE];
|
||||
char name[MAX_STRING_SIZE];
|
||||
node_t *owner;
|
||||
|
@ -151,8 +149,7 @@ bool add_subnet_h(connection_t *c)
|
|||
return true;
|
||||
}
|
||||
|
||||
bool send_del_subnet(connection_t *c, const subnet_t *s)
|
||||
{
|
||||
bool send_del_subnet(connection_t *c, const subnet_t *s) {
|
||||
char netstr[MAXNETSTR];
|
||||
|
||||
cp();
|
||||
|
@ -163,8 +160,7 @@ bool send_del_subnet(connection_t *c, const subnet_t *s)
|
|||
return send_request(c, "%d %x %s %s", DEL_SUBNET, rand(), s->owner->name, netstr);
|
||||
}
|
||||
|
||||
bool del_subnet_h(connection_t *c)
|
||||
{
|
||||
bool del_subnet_h(connection_t *c) {
|
||||
char subnetstr[MAX_STRING_SIZE];
|
||||
char name[MAX_STRING_SIZE];
|
||||
node_t *owner;
|
||||
|
|
|
@ -38,8 +38,7 @@ static char *device_info;
|
|||
static int device_total_in = 0;
|
||||
static int device_total_out = 0;
|
||||
|
||||
bool setup_device(void)
|
||||
{
|
||||
bool setup_device(void) {
|
||||
struct ifreq ifr;
|
||||
struct sockaddr_ll sa;
|
||||
|
||||
|
@ -83,8 +82,7 @@ bool setup_device(void)
|
|||
return true;
|
||||
}
|
||||
|
||||
void close_device(void)
|
||||
{
|
||||
void close_device(void) {
|
||||
cp();
|
||||
|
||||
close(device_fd);
|
||||
|
@ -93,8 +91,7 @@ void close_device(void)
|
|||
free(iface);
|
||||
}
|
||||
|
||||
bool read_packet(vpn_packet_t *packet)
|
||||
{
|
||||
bool read_packet(vpn_packet_t *packet) {
|
||||
int lenin;
|
||||
|
||||
cp();
|
||||
|
@ -115,8 +112,7 @@ bool read_packet(vpn_packet_t *packet)
|
|||
return true;
|
||||
}
|
||||
|
||||
bool write_packet(vpn_packet_t *packet)
|
||||
{
|
||||
bool write_packet(vpn_packet_t *packet) {
|
||||
cp();
|
||||
|
||||
ifdebug(TRAFFIC) logger(LOG_DEBUG, _("Writing packet of %d bytes to %s"),
|
||||
|
@ -133,8 +129,7 @@ bool write_packet(vpn_packet_t *packet)
|
|||
return true;
|
||||
}
|
||||
|
||||
void dump_device_stats(void)
|
||||
{
|
||||
void dump_device_stats(void) {
|
||||
cp();
|
||||
|
||||
logger(LOG_DEBUG, _("Statistics for %s %s:"), device_info, device);
|
||||
|
|
39
src/route.c
39
src/route.c
|
@ -51,8 +51,7 @@ static const size_t opt_size = sizeof(struct nd_opt_hdr);
|
|||
|
||||
/* RFC 1071 */
|
||||
|
||||
static uint16_t inet_checksum(void *data, int len, uint16_t prevsum)
|
||||
{
|
||||
static uint16_t inet_checksum(void *data, int len, uint16_t prevsum) {
|
||||
uint16_t *p = data;
|
||||
uint32_t checksum = prevsum ^ 0xFFFF;
|
||||
|
||||
|
@ -100,8 +99,7 @@ static void swap_mac_addresses(vpn_packet_t *packet) {
|
|||
memcpy(&packet->data[6], &tmp, sizeof tmp);
|
||||
}
|
||||
|
||||
static void learn_mac(mac_t *address)
|
||||
{
|
||||
static void learn_mac(mac_t *address) {
|
||||
subnet_t *subnet;
|
||||
avl_node_t *node;
|
||||
connection_t *c;
|
||||
|
@ -136,8 +134,7 @@ static void learn_mac(mac_t *address)
|
|||
subnet->expires = now + macexpire;
|
||||
}
|
||||
|
||||
void age_subnets(void)
|
||||
{
|
||||
void age_subnets(void) {
|
||||
subnet_t *s;
|
||||
connection_t *c;
|
||||
avl_node_t *node, *next, *node2;
|
||||
|
@ -167,8 +164,7 @@ void age_subnets(void)
|
|||
|
||||
/* RFC 792 */
|
||||
|
||||
static void route_ipv4_unreachable(node_t *source, vpn_packet_t *packet, uint8_t type, uint8_t code)
|
||||
{
|
||||
static void route_ipv4_unreachable(node_t *source, vpn_packet_t *packet, uint8_t type, uint8_t code) {
|
||||
struct ip ip = {0};
|
||||
struct icmp icmp = {0};
|
||||
|
||||
|
@ -293,8 +289,7 @@ static void fragment_ipv4_packet(node_t *dest, vpn_packet_t *packet) {
|
|||
}
|
||||
}
|
||||
|
||||
static void route_ipv4_unicast(node_t *source, vpn_packet_t *packet)
|
||||
{
|
||||
static void route_ipv4_unicast(node_t *source, vpn_packet_t *packet) {
|
||||
subnet_t *subnet;
|
||||
node_t *via;
|
||||
ipv4_t dest;
|
||||
|
@ -344,8 +339,7 @@ static void route_ipv4_unicast(node_t *source, vpn_packet_t *packet)
|
|||
send_packet(subnet->owner, packet);
|
||||
}
|
||||
|
||||
static void route_ipv4(node_t *source, vpn_packet_t *packet)
|
||||
{
|
||||
static void route_ipv4(node_t *source, vpn_packet_t *packet) {
|
||||
cp();
|
||||
|
||||
if(!checklength(source, packet, ether_size + ip_size))
|
||||
|
@ -363,8 +357,7 @@ static void route_ipv4(node_t *source, vpn_packet_t *packet)
|
|||
|
||||
/* RFC 2463 */
|
||||
|
||||
static void route_ipv6_unreachable(node_t *source, vpn_packet_t *packet, uint8_t type, uint8_t code)
|
||||
{
|
||||
static void route_ipv6_unreachable(node_t *source, vpn_packet_t *packet, uint8_t type, uint8_t code) {
|
||||
struct ip6_hdr ip6;
|
||||
struct icmp6_hdr icmp6 = {0};
|
||||
uint16_t checksum;
|
||||
|
@ -444,8 +437,7 @@ static void route_ipv6_unreachable(node_t *source, vpn_packet_t *packet, uint8_t
|
|||
send_packet(source, packet);
|
||||
}
|
||||
|
||||
static void route_ipv6_unicast(node_t *source, vpn_packet_t *packet)
|
||||
{
|
||||
static void route_ipv6_unicast(node_t *source, vpn_packet_t *packet) {
|
||||
subnet_t *subnet;
|
||||
node_t *via;
|
||||
ipv6_t dest;
|
||||
|
@ -493,8 +485,7 @@ static void route_ipv6_unicast(node_t *source, vpn_packet_t *packet)
|
|||
|
||||
/* RFC 2461 */
|
||||
|
||||
static void route_neighborsol(node_t *source, vpn_packet_t *packet)
|
||||
{
|
||||
static void route_neighborsol(node_t *source, vpn_packet_t *packet) {
|
||||
struct ip6_hdr ip6;
|
||||
struct nd_neighbor_solicit ns;
|
||||
struct nd_opt_hdr opt;
|
||||
|
@ -635,8 +626,7 @@ static void route_neighborsol(node_t *source, vpn_packet_t *packet)
|
|||
send_packet(source, packet);
|
||||
}
|
||||
|
||||
static void route_ipv6(node_t *source, vpn_packet_t *packet)
|
||||
{
|
||||
static void route_ipv6(node_t *source, vpn_packet_t *packet) {
|
||||
cp();
|
||||
|
||||
if(!checklength(source, packet, ether_size + ip6_size))
|
||||
|
@ -655,8 +645,7 @@ static void route_ipv6(node_t *source, vpn_packet_t *packet)
|
|||
|
||||
/* RFC 826 */
|
||||
|
||||
static void route_arp(node_t *source, vpn_packet_t *packet)
|
||||
{
|
||||
static void route_arp(node_t *source, vpn_packet_t *packet) {
|
||||
struct ether_arp arp;
|
||||
subnet_t *subnet;
|
||||
struct in_addr addr;
|
||||
|
@ -722,8 +711,7 @@ static void route_arp(node_t *source, vpn_packet_t *packet)
|
|||
send_packet(source, packet);
|
||||
}
|
||||
|
||||
static void route_mac(node_t *source, vpn_packet_t *packet)
|
||||
{
|
||||
static void route_mac(node_t *source, vpn_packet_t *packet) {
|
||||
subnet_t *subnet;
|
||||
mac_t dest;
|
||||
|
||||
|
@ -779,8 +767,7 @@ static void route_mac(node_t *source, vpn_packet_t *packet)
|
|||
}
|
||||
|
||||
|
||||
void route(node_t *source, vpn_packet_t *packet)
|
||||
{
|
||||
void route(node_t *source, vpn_packet_t *packet) {
|
||||
cp();
|
||||
|
||||
if(!checklength(source, packet, ether_size))
|
||||
|
|
|
@ -41,8 +41,7 @@ static char *device_info = NULL;
|
|||
static int device_total_in = 0;
|
||||
static int device_total_out = 0;
|
||||
|
||||
bool setup_device(void)
|
||||
{
|
||||
bool setup_device(void) {
|
||||
int ip_fd = -1, if_fd = -1;
|
||||
int ppa;
|
||||
char *ptr;
|
||||
|
@ -107,8 +106,7 @@ bool setup_device(void)
|
|||
return true;
|
||||
}
|
||||
|
||||
void close_device(void)
|
||||
{
|
||||
void close_device(void) {
|
||||
cp();
|
||||
|
||||
close(device_fd);
|
||||
|
@ -117,8 +115,7 @@ void close_device(void)
|
|||
free(iface);
|
||||
}
|
||||
|
||||
bool read_packet(vpn_packet_t *packet)
|
||||
{
|
||||
bool read_packet(vpn_packet_t *packet) {
|
||||
int lenin;
|
||||
|
||||
cp();
|
||||
|
@ -155,8 +152,7 @@ bool read_packet(vpn_packet_t *packet)
|
|||
return true;
|
||||
}
|
||||
|
||||
bool write_packet(vpn_packet_t *packet)
|
||||
{
|
||||
bool write_packet(vpn_packet_t *packet) {
|
||||
cp();
|
||||
|
||||
ifdebug(TRAFFIC) logger(LOG_DEBUG, _("Writing packet of %d bytes to %s"),
|
||||
|
@ -173,8 +169,7 @@ bool write_packet(vpn_packet_t *packet)
|
|||
return true;
|
||||
}
|
||||
|
||||
void dump_device_stats(void)
|
||||
{
|
||||
void dump_device_stats(void) {
|
||||
cp();
|
||||
|
||||
logger(LOG_DEBUG, _("Statistics for %s %s:"), device_info, device);
|
||||
|
|
57
src/subnet.c
57
src/subnet.c
|
@ -54,8 +54,7 @@ void subnet_cache_flush() {
|
|||
|
||||
/* Subnet comparison */
|
||||
|
||||
static int subnet_compare_mac(const subnet_t *a, const subnet_t *b)
|
||||
{
|
||||
static int subnet_compare_mac(const subnet_t *a, const subnet_t *b) {
|
||||
int result;
|
||||
|
||||
result = memcmp(&a->net.mac.address, &b->net.mac.address, sizeof(mac_t));
|
||||
|
@ -71,8 +70,7 @@ static int subnet_compare_mac(const subnet_t *a, const subnet_t *b)
|
|||
return strcmp(a->owner->name, b->owner->name);
|
||||
}
|
||||
|
||||
static int subnet_compare_ipv4(const subnet_t *a, const subnet_t *b)
|
||||
{
|
||||
static int subnet_compare_ipv4(const subnet_t *a, const subnet_t *b) {
|
||||
int result;
|
||||
|
||||
result = b->net.ipv4.prefixlength - a->net.ipv4.prefixlength;
|
||||
|
@ -93,8 +91,7 @@ static int subnet_compare_ipv4(const subnet_t *a, const subnet_t *b)
|
|||
return strcmp(a->owner->name, b->owner->name);
|
||||
}
|
||||
|
||||
static int subnet_compare_ipv6(const subnet_t *a, const subnet_t *b)
|
||||
{
|
||||
static int subnet_compare_ipv6(const subnet_t *a, const subnet_t *b) {
|
||||
int result;
|
||||
|
||||
result = b->net.ipv6.prefixlength - a->net.ipv6.prefixlength;
|
||||
|
@ -115,8 +112,7 @@ static int subnet_compare_ipv6(const subnet_t *a, const subnet_t *b)
|
|||
return strcmp(a->owner->name, b->owner->name);
|
||||
}
|
||||
|
||||
int subnet_compare(const subnet_t *a, const subnet_t *b)
|
||||
{
|
||||
int subnet_compare(const subnet_t *a, const subnet_t *b) {
|
||||
int result;
|
||||
|
||||
result = a->type - b->type;
|
||||
|
@ -143,8 +139,7 @@ int subnet_compare(const subnet_t *a, const subnet_t *b)
|
|||
|
||||
/* Initialising trees */
|
||||
|
||||
void init_subnets(void)
|
||||
{
|
||||
void init_subnets(void) {
|
||||
cp();
|
||||
|
||||
subnet_tree = avl_alloc_tree((avl_compare_t) subnet_compare, (avl_action_t) free_subnet);
|
||||
|
@ -152,22 +147,19 @@ void init_subnets(void)
|
|||
subnet_cache_flush();
|
||||
}
|
||||
|
||||
void exit_subnets(void)
|
||||
{
|
||||
void exit_subnets(void) {
|
||||
cp();
|
||||
|
||||
avl_delete_tree(subnet_tree);
|
||||
}
|
||||
|
||||
avl_tree_t *new_subnet_tree(void)
|
||||
{
|
||||
avl_tree_t *new_subnet_tree(void) {
|
||||
cp();
|
||||
|
||||
return avl_alloc_tree((avl_compare_t) subnet_compare, NULL);
|
||||
}
|
||||
|
||||
void free_subnet_tree(avl_tree_t *subnet_tree)
|
||||
{
|
||||
void free_subnet_tree(avl_tree_t *subnet_tree) {
|
||||
cp();
|
||||
|
||||
avl_delete_tree(subnet_tree);
|
||||
|
@ -175,15 +167,13 @@ void free_subnet_tree(avl_tree_t *subnet_tree)
|
|||
|
||||
/* Allocating and freeing space for subnets */
|
||||
|
||||
subnet_t *new_subnet(void)
|
||||
{
|
||||
subnet_t *new_subnet(void) {
|
||||
cp();
|
||||
|
||||
return xmalloc_and_zero(sizeof(subnet_t));
|
||||
}
|
||||
|
||||
void free_subnet(subnet_t *subnet)
|
||||
{
|
||||
void free_subnet(subnet_t *subnet) {
|
||||
cp();
|
||||
|
||||
free(subnet);
|
||||
|
@ -191,8 +181,7 @@ void free_subnet(subnet_t *subnet)
|
|||
|
||||
/* Adding and removing subnets */
|
||||
|
||||
void subnet_add(node_t *n, subnet_t *subnet)
|
||||
{
|
||||
void subnet_add(node_t *n, subnet_t *subnet) {
|
||||
cp();
|
||||
|
||||
subnet->owner = n;
|
||||
|
@ -203,8 +192,7 @@ void subnet_add(node_t *n, subnet_t *subnet)
|
|||
subnet_cache_flush();
|
||||
}
|
||||
|
||||
void subnet_del(node_t *n, subnet_t *subnet)
|
||||
{
|
||||
void subnet_del(node_t *n, subnet_t *subnet) {
|
||||
cp();
|
||||
|
||||
avl_delete(n->subnet_tree, subnet);
|
||||
|
@ -215,8 +203,7 @@ void subnet_del(node_t *n, subnet_t *subnet)
|
|||
|
||||
/* Ascii representation of subnets */
|
||||
|
||||
bool str2net(subnet_t *subnet, const char *subnetstr)
|
||||
{
|
||||
bool str2net(subnet_t *subnet, const char *subnetstr) {
|
||||
int i, l;
|
||||
uint16_t x[8];
|
||||
int weight = 10;
|
||||
|
@ -297,8 +284,7 @@ bool str2net(subnet_t *subnet, const char *subnetstr)
|
|||
return false;
|
||||
}
|
||||
|
||||
bool net2str(char *netstr, int len, const subnet_t *subnet)
|
||||
{
|
||||
bool net2str(char *netstr, int len, const subnet_t *subnet) {
|
||||
cp();
|
||||
|
||||
if(!netstr || !subnet) {
|
||||
|
@ -355,15 +341,13 @@ bool net2str(char *netstr, int len, const subnet_t *subnet)
|
|||
|
||||
/* Subnet lookup routines */
|
||||
|
||||
subnet_t *lookup_subnet(const node_t *owner, const subnet_t *subnet)
|
||||
{
|
||||
subnet_t *lookup_subnet(const node_t *owner, const subnet_t *subnet) {
|
||||
cp();
|
||||
|
||||
return avl_search(owner->subnet_tree, subnet);
|
||||
}
|
||||
|
||||
subnet_t *lookup_subnet_mac(const mac_t *address)
|
||||
{
|
||||
subnet_t *lookup_subnet_mac(const mac_t *address) {
|
||||
subnet_t *p, subnet = {0};
|
||||
|
||||
cp();
|
||||
|
@ -377,8 +361,7 @@ subnet_t *lookup_subnet_mac(const mac_t *address)
|
|||
return p;
|
||||
}
|
||||
|
||||
subnet_t *lookup_subnet_ipv4(const ipv4_t *address)
|
||||
{
|
||||
subnet_t *lookup_subnet_ipv4(const ipv4_t *address) {
|
||||
subnet_t *p, *r = NULL, subnet = {0};
|
||||
avl_node_t *n;
|
||||
int i;
|
||||
|
@ -424,8 +407,7 @@ subnet_t *lookup_subnet_ipv4(const ipv4_t *address)
|
|||
return r;
|
||||
}
|
||||
|
||||
subnet_t *lookup_subnet_ipv6(const ipv6_t *address)
|
||||
{
|
||||
subnet_t *lookup_subnet_ipv6(const ipv6_t *address) {
|
||||
subnet_t *p, *r = NULL, subnet = {0};
|
||||
avl_node_t *n;
|
||||
int i;
|
||||
|
@ -538,8 +520,7 @@ void subnet_update(node_t *owner, subnet_t *subnet, bool up) {
|
|||
free(envp[i]);
|
||||
}
|
||||
|
||||
void dump_subnets(void)
|
||||
{
|
||||
void dump_subnets(void) {
|
||||
char netstr[MAXNETSTR];
|
||||
subnet_t *subnet;
|
||||
avl_node_t *node;
|
||||
|
|
21
src/tincd.c
21
src/tincd.c
|
@ -117,8 +117,7 @@ static struct WSAData wsa_state;
|
|||
CRITICAL_SECTION mutex;
|
||||
#endif
|
||||
|
||||
static void usage(bool status)
|
||||
{
|
||||
static void usage(bool status) {
|
||||
if(status)
|
||||
fprintf(stderr, _("Try `%s --help\' for more information.\n"),
|
||||
program_name);
|
||||
|
@ -141,8 +140,7 @@ static void usage(bool status)
|
|||
}
|
||||
}
|
||||
|
||||
static bool parse_options(int argc, char **argv)
|
||||
{
|
||||
static bool parse_options(int argc, char **argv) {
|
||||
int r;
|
||||
int option_index = 0;
|
||||
|
||||
|
@ -275,8 +273,7 @@ static bool parse_options(int argc, char **argv)
|
|||
|
||||
/* This function prettyprints the key generation process */
|
||||
|
||||
static void indicator(int a, int b, void *p)
|
||||
{
|
||||
static void indicator(int a, int b, void *p) {
|
||||
switch (a) {
|
||||
case 0:
|
||||
fprintf(stderr, ".");
|
||||
|
@ -314,8 +311,7 @@ static void indicator(int a, int b, void *p)
|
|||
Generate a public/private RSA keypair, and ask for a file to store
|
||||
them in.
|
||||
*/
|
||||
static bool keygen(int bits)
|
||||
{
|
||||
static bool keygen(int bits) {
|
||||
RSA *rsa_key;
|
||||
FILE *f;
|
||||
char *name = NULL;
|
||||
|
@ -380,8 +376,7 @@ static bool keygen(int bits)
|
|||
/*
|
||||
Set all files and paths according to netname
|
||||
*/
|
||||
static void make_names(void)
|
||||
{
|
||||
static void make_names(void) {
|
||||
#ifdef HAVE_MINGW
|
||||
HKEY key;
|
||||
char installdir[1024] = "";
|
||||
|
@ -493,8 +488,7 @@ static bool drop_privs() {
|
|||
# define setpriority(level) nice(level)
|
||||
#endif
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
int main(int argc, char **argv) {
|
||||
program_name = argv[0];
|
||||
|
||||
setlocale(LC_ALL, "");
|
||||
|
@ -566,8 +560,7 @@ int main(int argc, char **argv)
|
|||
return 1;
|
||||
}
|
||||
|
||||
int main2(int argc, char **argv)
|
||||
{
|
||||
int main2(int argc, char **argv) {
|
||||
InitializeCriticalSection(&mutex);
|
||||
EnterCriticalSection(&mutex);
|
||||
#endif
|
||||
|
|
|
@ -55,8 +55,7 @@ static struct request {
|
|||
|
||||
static struct sockaddr_un data_sun;
|
||||
|
||||
bool setup_device(void)
|
||||
{
|
||||
bool setup_device(void) {
|
||||
struct sockaddr_un listen_sun;
|
||||
static const int one = 1;
|
||||
struct {
|
||||
|
@ -152,8 +151,7 @@ bool setup_device(void)
|
|||
return true;
|
||||
}
|
||||
|
||||
void close_device(void)
|
||||
{
|
||||
void close_device(void) {
|
||||
cp();
|
||||
|
||||
if(listen_fd >= 0)
|
||||
|
@ -174,8 +172,7 @@ void close_device(void)
|
|||
if(iface) free(iface);
|
||||
}
|
||||
|
||||
bool read_packet(vpn_packet_t *packet)
|
||||
{
|
||||
bool read_packet(vpn_packet_t *packet) {
|
||||
int lenin;
|
||||
|
||||
cp();
|
||||
|
@ -255,8 +252,7 @@ bool read_packet(vpn_packet_t *packet)
|
|||
}
|
||||
}
|
||||
|
||||
bool write_packet(vpn_packet_t *packet)
|
||||
{
|
||||
bool write_packet(vpn_packet_t *packet) {
|
||||
cp();
|
||||
|
||||
if(state != 2) {
|
||||
|
@ -282,8 +278,7 @@ bool write_packet(vpn_packet_t *packet)
|
|||
return true;
|
||||
}
|
||||
|
||||
void dump_device_stats(void)
|
||||
{
|
||||
void dump_device_stats(void) {
|
||||
cp();
|
||||
|
||||
logger(LOG_DEBUG, _("Statistics for %s %s:"), device_info, device);
|
||||
|
|
Loading…
Reference in a new issue