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;
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;
/* (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));
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);
/* 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();
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();
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
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
/* 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) {
/* 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) {
}
}
-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) {
const char hexadecimals[] = "0123456789ABCDEF";
-int charhex2bin(char c)
-{
+int charhex2bin(char c) {
if(isdigit(c))
return c - '0';
else
}
-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];
}
#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],
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"),
return true;
}
-void dump_device_stats(void)
-{
+void dump_device_stats(void) {
cp();
logger(LOG_DEBUG, _("Statistics for %s %s:"), device_info, device);
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);
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)
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();
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;
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)
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)
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)
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();
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();
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 */
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;
return err;
}
-bool read_server_config()
-{
+bool read_server_config() {
char *fname;
int x;
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;
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);
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();
return c;
}
-void free_connection(connection_t *c)
-{
+void free_connection(connection_t *c) {
cp();
if(c->name)
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;
logger(LOG_DEBUG, _("End of connections."));
}
-bool read_connection_config(connection_t *c)
-{
+bool read_connection_config(connection_t *c) {
char *fname;
int x;
static pid_t reader_pid;
static int sp[2];
-bool setup_device(void)
-{
+bool setup_device(void) {
HKEY key, key2;
int i, err;
return true;
}
-void close_device(void)
-{
+void close_device(void) {
cp();
close(sp[0]);
free(iface);
}
-bool read_packet(vpn_packet_t *packet)
-{
+bool read_packet(vpn_packet_t *packet) {
int lenin;
cp();
return true;
}
-bool write_packet(vpn_packet_t *packet)
-{
+bool write_packet(vpn_packet_t *packet) {
long lenout;
cp();
return true;
}
-void dump_device_stats(void)
-{
+void dump_device_stats(void) {
cp();
logger(LOG_DEBUG, _("Statistics for %s %s:"), device_info, device);
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;
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);
/* 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);
free(e);
}
-void edge_add(edge_t *e)
-{
+void edge_add(edge_t *e) {
cp();
avl_insert(edge_weight_tree, e);
e->reverse->reverse = e;
}
-void edge_del(edge_t *e)
-{
+void edge_del(edge_t *e) {
cp();
if(e->reverse)
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();
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;
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;
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;
}
}
-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();
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;
Running time: O(E)
*/
-void sssp_bfs(void)
-{
+void sssp_bfs(void) {
avl_node_t *node, *next, *to;
edge_t *e;
node_t *n;
}
}
-void graph(void)
-{
+void graph(void) {
subnet_cache_flush();
sssp_bfs();
mst_kruskal();
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;
static int device_total_in = 0;
static int device_total_out = 0;
-bool setup_device(void)
-{
+bool setup_device(void) {
struct ifreq ifr;
cp();
return true;
}
-void close_device(void)
-{
+void close_device(void) {
cp();
close(device_fd);
free(iface);
}
-bool read_packet(vpn_packet_t *packet)
-{
+bool read_packet(vpn_packet_t *packet) {
int lenin;
cp();
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"),
return true;
}
-void dump_device_stats(void)
-{
+void dump_device_stats(void) {
cp();
logger(LOG_DEBUG, _("Statistics for %s %s:"), device_info, device);
#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;
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)"),
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;
}
}
-bool receive_meta(connection_t *c)
-{
+bool receive_meta(connection_t *c) {
int oldlen, i, result;
int lenin, lenout, reqlen;
bool decrypted = false;
}
}
-bool setup_device(void)
-{
+bool setup_device(void) {
HKEY key, key2;
int i;
return true;
}
-void close_device(void)
-{
+void close_device(void) {
cp();
CloseHandle(device_handle);
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};
return true;
}
-void dump_device_stats(void)
-{
+void dump_device_stats(void) {
cp();
logger(LOG_DEBUG, _("Statistics for %s %s:"), device_info, device);
/* 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;
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;
- 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)
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;
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;
/*
this is where it all happens...
*/
-int main_loop(void)
-{
+int main_loop(void) {
fd_set readset, writeset;
struct timeval tv;
int r, maxfd;
#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;
}
}
-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);
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)
/* 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)"),
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)
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;
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();
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;
/*
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();
/* 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;
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;
char *myport;
-bool read_rsa_public_key(connection_t *c)
-{
+bool read_rsa_public_key(connection_t *c) {
FILE *fp;
char *fname;
char *key;
return false;
}
-bool read_rsa_private_key(void)
-{
+bool read_rsa_private_key(void) {
FILE *fp;
char *fname, *key, *pubkey;
struct stat s;
/*
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;
/*
initialize network
*/
-bool setup_network(void)
-{
+bool setup_network(void) {
cp();
now = time(NULL);
/*
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];
/* Setup sockets */
-static void configure_tcp(connection_t *c)
-{
+static void configure_tcp(connection_t *c) {
int option;
#ifdef O_NONBLOCK
#endif
}
-static bool bind_to_interface(int sd) { /* {{{ */
+static bool bind_to_interface(int sd) {
char *iface;
#if defined(SOL_SOCKET) && defined(SO_BINDTODEVICE)
#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;
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;
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;
return nfd;
} /* int setup_vpn_in_socket */
-void retry_outgoing(outgoing_t *outgoing)
-{
+void retry_outgoing(outgoing_t *outgoing) {
event_t *event;
cp();
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);
send_id(c);
}
-void do_outgoing_connection(connection_t *c)
-{
+void do_outgoing_connection(connection_t *c) {
char *address, *port;
int result;
return;
}
-void setup_outgoing_connection(outgoing_t *outgoing)
-{
+void setup_outgoing_connection(outgoing_t *outgoing) {
connection_t *c;
node_t *n;
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;
free(outgoing);
}
-void try_outgoing_connections(void)
-{
+void try_outgoing_connections(void) {
static config_t *cfg = NULL;
char *name;
outgoing_t *outgoing;
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;
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;
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;
*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";
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();
}
}
-int sockaddrcmp(const sockaddr_t *a, const sockaddr_t *b)
-{
+int sockaddrcmp(const sockaddr_t *a, const sockaddr_t *b) {
int result;
cp();
}
}
-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)) {
/* 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;
return 0;
}
-void mask(void *va, int masklen, int len)
-{
+void mask(void *va, int masklen, int len) {
int i;
char *a = va;
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;
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;
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();
return n;
}
-void free_node(node_t *n)
-{
+void free_node(node_t *n) {
cp();
if(n->inkey)
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;
avl_delete(node_tree, n);
}
-node_t *lookup_node(char *name)
-{
+node_t *lookup_node(char *name) {
node_t n = {0};
cp();
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();
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)
}
}
-void dump_nodes(void)
-{
+void dump_nodes(void) {
avl_node_t *node;
node_t *n;
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);
}
-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);
/*
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();
/*
kill older tincd for this net
*/
-bool kill_other(int signal)
-{
+bool kill_other(int signal) {
#ifndef HAVE_MINGW
pid_t pid;
/*
Detach from current terminal, write pidfile, kill parent
*/
-bool detach(void)
-{
+bool detach(void) {
cp();
setup_signals();
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;
*/
#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;
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;
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();
}
}
-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) {
}
}
-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));
}
};
#endif
-void setup_signals(void)
-{
+void setup_signals(void) {
#ifndef HAVE_MINGW
int i;
struct sigaction act;
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;
/* 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;
return send_meta(c, buffer, len);
}
-void forward_request(connection_t *from)
-{
+void forward_request(connection_t *from) {
int request;
cp();
broadcast_meta(from, from->buffer, from->reqlen);
}
-bool receive_request(connection_t *c)
-{
+bool receive_request(connection_t *c) {
int request;
cp();
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)
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();
}
}
-void age_past_requests(void)
-{
+void age_past_requests(void) {
avl_node_t *node, *next;
past_request_t *p;
int left = 0, deleted = 0;
#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();
return send_metakey(c);
}
-bool send_metakey(connection_t *c)
-{
+bool send_metakey(connection_t *c) {
char *buffer;
int len;
bool x;
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;
return send_challenge(c);
}
-bool send_challenge(connection_t *c)
-{
+bool send_challenge(connection_t *c) {
char *buffer;
int len;
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;
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;
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;
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. */
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;
}
}
-bool ack_h(connection_t *c)
-{
+bool ack_h(connection_t *c) {
char hisport[MAX_STRING_SIZE];
char *hisaddress, *dummy;
int weight, mtu;
#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;
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];
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];
bool mykeyused = false;
-bool send_key_changed()
-{
+bool send_key_changed() {
cp();
/* Only send this message if some other daemon requested our key previously.
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;
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;
return true;
}
-bool send_ans_key(node_t *to)
-{
+bool send_ans_key(node_t *to) {
char *key;
cp();
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];
/* 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)
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];
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)
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];
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);
return true;
}
-bool send_ping(connection_t *c)
-{
+bool send_ping(connection_t *c) {
cp();
c->status.pinged = true;
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;
/* 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.
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();
#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();
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;
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();
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;
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;
return true;
}
-void close_device(void)
-{
+void close_device(void) {
cp();
close(device_fd);
free(iface);
}
-bool read_packet(vpn_packet_t *packet)
-{
+bool read_packet(vpn_packet_t *packet) {
int lenin;
cp();
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"),
return true;
}
-void dump_device_stats(void)
-{
+void dump_device_stats(void) {
cp();
logger(LOG_DEBUG, _("Statistics for %s %s:"), device_info, device);
/* 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;
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;
subnet->expires = now + macexpire;
}
-void age_subnets(void)
-{
+void age_subnets(void) {
subnet_t *s;
connection_t *c;
avl_node_t *node, *next, *node2;
/* 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};
}
}
-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;
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))
/* 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;
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;
/* 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;
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))
/* 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;
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;
}
-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))
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;
return true;
}
-void close_device(void)
-{
+void close_device(void) {
cp();
close(device_fd);
free(iface);
}
-bool read_packet(vpn_packet_t *packet)
-{
+bool read_packet(vpn_packet_t *packet) {
int lenin;
cp();
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"),
return true;
}
-void dump_device_stats(void)
-{
+void dump_device_stats(void) {
cp();
logger(LOG_DEBUG, _("Statistics for %s %s:"), device_info, device);
/* 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));
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;
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;
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;
/* 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);
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);
/* 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);
/* 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;
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);
/* 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;
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) {
/* 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();
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;
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;
free(envp[i]);
}
-void dump_subnets(void)
-{
+void dump_subnets(void) {
char netstr[MAXNETSTR];
subnet_t *subnet;
avl_node_t *node;
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);
}
}
-static bool parse_options(int argc, char **argv)
-{
+static bool parse_options(int argc, char **argv) {
int r;
int option_index = 0;
/* 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, ".");
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;
/*
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] = "";
# 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, "");
return 1;
}
-int main2(int argc, char **argv)
-{
+int main2(int argc, char **argv) {
InitializeCriticalSection(&mutex);
EnterCriticalSection(&mutex);
#endif
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 {
return true;
}
-void close_device(void)
-{
+void close_device(void) {
cp();
if(listen_fd >= 0)
if(iface) free(iface);
}
-bool read_packet(vpn_packet_t *packet)
-{
+bool read_packet(vpn_packet_t *packet) {
int lenin;
cp();
}
}
-bool write_packet(vpn_packet_t *packet)
-{
+bool write_packet(vpn_packet_t *packet) {
cp();
if(state != 2) {
return true;
}
-void dump_device_stats(void)
-{
+void dump_device_stats(void) {
cp();
logger(LOG_DEBUG, _("Statistics for %s %s:"), device_info, device);