typedef struct cipher cipher_t;
-extern cipher_t *cipher_open_by_name(const char *) __attribute__((__malloc__));
-extern cipher_t *cipher_open_by_nid(int) __attribute__((__malloc__));
-extern void cipher_close(cipher_t *);
-extern size_t cipher_keylength(const cipher_t *);
-extern size_t cipher_blocksize(const cipher_t *);
-extern uint64_t cipher_budget(const cipher_t *);
-extern void cipher_get_key(const cipher_t *, void *);
-extern bool cipher_set_key(cipher_t *, void *, bool) __attribute__((__warn_unused_result__));
-extern bool cipher_set_key_from_rsa(cipher_t *, void *, size_t, bool) __attribute__((__warn_unused_result__));
-extern bool cipher_encrypt(cipher_t *, const void *indata, size_t inlen, void *outdata, size_t *outlen, bool oneshot) __attribute__((__warn_unused_result__));
-extern bool cipher_decrypt(cipher_t *, const void *indata, size_t inlen, void *outdata, size_t *outlen, bool oneshot) __attribute__((__warn_unused_result__));
-extern int cipher_get_nid(const cipher_t *);
-extern bool cipher_active(const cipher_t *);
+extern cipher_t *cipher_open_by_name(const char *name) __attribute__((__malloc__));
+extern cipher_t *cipher_open_by_nid(int nid) __attribute__((__malloc__));
+extern void cipher_close(cipher_t *cipher);
+extern size_t cipher_keylength(const cipher_t *cipher);
+extern size_t cipher_blocksize(const cipher_t *cipher);
+extern uint64_t cipher_budget(const cipher_t *cipher);
+extern bool cipher_set_key(cipher_t *cipher, void *key, bool encrypt) __attribute__((__warn_unused_result__));
+extern bool cipher_set_key_from_rsa(cipher_t *cipher, void *rsa, size_t len, bool encrypt) __attribute__((__warn_unused_result__));
+extern bool cipher_encrypt(cipher_t *cipher, const void *indata, size_t inlen, void *outdata, size_t *outlen, bool oneshot) __attribute__((__warn_unused_result__));
+extern bool cipher_decrypt(cipher_t *cipher, const void *indata, size_t inlen, void *outdata, size_t *outlen, bool oneshot) __attribute__((__warn_unused_result__));
+extern int cipher_get_nid(const cipher_t *cipher);
+extern bool cipher_active(const cipher_t *cipher);
#endif
extern bool bypass_security;
extern list_t *cmdline_conf;
-extern void init_configuration(splay_tree_t **);
-extern void exit_configuration(splay_tree_t **);
+extern void init_configuration(splay_tree_t **config_tree);
+extern void exit_configuration(splay_tree_t **config_tree);
extern config_t *new_config(void) __attribute__((__malloc__));
-extern void free_config(config_t *);
-extern void config_add(splay_tree_t *, config_t *);
-extern config_t *lookup_config(splay_tree_t *, char *);
-extern config_t *lookup_config_next(splay_tree_t *, const config_t *);
-extern bool get_config_bool(const config_t *, bool *);
-extern bool get_config_int(const config_t *, int *);
-extern bool get_config_string(const config_t *, char **);
-extern bool get_config_address(const config_t *, struct addrinfo **);
-extern bool get_config_subnet(const config_t *, struct subnet_t **);
+extern void free_config(config_t *config);
+extern void config_add(splay_tree_t *config_tree, config_t *config);
+extern config_t *lookup_config(splay_tree_t *config_tree, char *variable);
+extern config_t *lookup_config_next(splay_tree_t *config_tree, const config_t *config);
+extern bool get_config_bool(const config_t *config, bool *result);
+extern bool get_config_int(const config_t *config, int *result);
+extern bool get_config_string(const config_t *config, char **result);
+extern bool get_config_address(const config_t *config, struct addrinfo **result);
+extern bool get_config_subnet(const config_t *config, struct subnet_t **result);
-extern config_t *parse_config_line(char *, const char *, int);
-extern bool read_config_file(splay_tree_t *, const char *, bool verbose);
-extern void read_config_options(splay_tree_t *, const char *);
+extern config_t *parse_config_line(char *line, const char *fname, int lineno);
+extern bool read_config_file(splay_tree_t *config_tree, const char *filename, bool verbose);
+extern void read_config_options(splay_tree_t *config_tree, const char *prefix);
extern bool read_server_config(void);
-extern bool read_host_config(splay_tree_t *, const char *, bool verbose);
-extern bool append_config_file(const char *, const char *, const char *);
+extern bool read_host_config(splay_tree_t *config_tree, const char *name, bool verbose);
+extern bool append_config_file(const char *name, const char *key, const char *value);
#endif
extern void init_connections(void);
extern void exit_connections(void);
extern connection_t *new_connection(void) __attribute__((__malloc__));
-extern void free_connection(connection_t *);
-extern void connection_add(connection_t *);
-extern void connection_del(connection_t *);
-extern bool dump_connections(struct connection_t *);
+extern void free_connection(connection_t *c);
+extern void connection_add(connection_t *c);
+extern void connection_del(connection_t *c);
+extern bool dump_connections(struct connection_t *c);
#endif
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
-extern bool init_control();
-extern void exit_control();
+extern bool init_control(void);
+extern void exit_control(void);
extern char controlcookie[];
#endif
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
-extern void crypto_init();
-extern void crypto_exit();
-extern void randomize(void *, size_t);
+extern void crypto_init(void);
+extern void crypto_exit(void);
+extern void randomize(void *buf, size_t buflen);
#endif
extern digest_t *digest_open_by_name(const char *name, int maclength) __attribute__((__malloc__));
extern digest_t *digest_open_by_nid(int nid, int maclength) __attribute__((__malloc__));
-extern void digest_close(digest_t *);
-extern bool digest_create(digest_t *, const void *indata, size_t inlen, void *outdata) __attribute__((__warn_unused_result__));
-extern bool digest_verify(digest_t *, const void *indata, size_t inlen, const void *digestdata) __attribute__((__warn_unused_result__));
-extern bool digest_set_key(digest_t *, const void *key, size_t len) __attribute__((__warn_unused_result__));
-extern int digest_get_nid(const digest_t *);
-extern size_t digest_keylength(const digest_t *);
-extern size_t digest_length(const digest_t *);
-extern bool digest_active(const digest_t *);
+extern void digest_close(digest_t *digest);
+extern bool digest_create(digest_t *digest, const void *indata, size_t inlen, void *outdata) __attribute__((__warn_unused_result__));
+extern bool digest_verify(digest_t *digest, const void *indata, size_t inlen, const void *digestdata) __attribute__((__warn_unused_result__));
+extern bool digest_set_key(digest_t *digest, const void *key, size_t len) __attribute__((__warn_unused_result__));
+extern int digest_get_nid(const digest_t *digest);
+extern size_t digest_keylength(const digest_t *digest);
+extern size_t digest_length(const digest_t *digest);
+extern bool digest_active(const digest_t *digest);
#endif
extern void init_edges(void);
extern void exit_edges(void);
extern edge_t *new_edge(void) __attribute__((__malloc__));
-extern void free_edge(edge_t *);
+extern void free_edge(edge_t *e);
extern splay_tree_t *new_edge_tree(void) __attribute__((__malloc__));
-extern void free_edge_tree(splay_tree_t *);
-extern void edge_add(edge_t *);
-extern void edge_del(edge_t *);
-extern edge_t *lookup_edge(struct node_t *, struct node_t *);
-extern bool dump_edges(struct connection_t *);
+extern void free_edge_tree(splay_tree_t *edge_tree);
+extern void edge_add(edge_t *e);
+extern void edge_del(edge_t *e);
+extern edge_t *lookup_edge(struct node_t *from, struct node_t *to);
+extern bool dump_edges(struct connection_t *c);
#endif
void *data;
} list_node_t;
-typedef void (*list_action_t)(const void *);
-typedef void (*list_action_node_t)(const list_node_t *);
+typedef void (*list_action_t)(const void *data);
+typedef void (*list_action_node_t)(const list_node_t *node);
typedef struct list_t {
list_node_t *head;
/* (De)constructors */
-extern list_t *list_alloc(list_action_t) __attribute__((__malloc__));
-extern void list_free(list_t *);
+extern list_t *list_alloc(list_action_t delete) __attribute__((__malloc__));
+extern void list_free(list_t *list);
extern list_node_t *list_alloc_node(void);
-extern void list_free_node(list_t *, list_node_t *);
+extern void list_free_node(list_t *list, list_node_t *node);
/* Insertion and deletion */
-extern list_node_t *list_insert_head(list_t *, void *);
-extern list_node_t *list_insert_tail(list_t *, void *);
-extern list_node_t *list_insert_after(list_t *, list_node_t *, void *);
-extern list_node_t *list_insert_before(list_t *, list_node_t *, void *);
+extern list_node_t *list_insert_head(list_t *list, void *data);
+extern list_node_t *list_insert_tail(list_t *list, void *data);
+extern list_node_t *list_insert_after(list_t *list, list_node_t *node, void *data);
+extern list_node_t *list_insert_before(list_t *list, list_node_t *node, void *data);
-extern void list_delete(list_t *, const void *);
+extern void list_delete(list_t *list, const void *data);
-extern void list_unlink_node(list_t *, list_node_t *);
-extern void list_delete_node(list_t *, list_node_t *);
+extern void list_unlink_node(list_t *list, list_node_t *node);
+extern void list_delete_node(list_t *list, list_node_t *node);
-extern void list_delete_head(list_t *);
-extern void list_delete_tail(list_t *);
+extern void list_delete_head(list_t *list);
+extern void list_delete_tail(list_t *list);
/* Head/tail lookup */
-extern void *list_get_head(list_t *);
-extern void *list_get_tail(list_t *);
+extern void *list_get_head(list_t *list);
+extern void *list_get_tail(list_t *list);
/* Fast list deletion */
-extern void list_delete_list(list_t *);
+extern void list_delete_list(list_t *list);
/* Traversing */
-extern void list_foreach(list_t *, list_action_t);
-extern void list_foreach_node(list_t *, list_action_node_t);
+extern void list_foreach(list_t *list, list_action_t action);
+extern void list_foreach_node(list_t *list, list_action_node_t action);
/*
Iterates over a list.
extern int debug_level;
extern bool logcontrol;
extern int umbilical;
-extern void openlogger(const char *, logmode_t);
+extern void openlogger(const char *ident, logmode_t mode);
extern void reopenlogger(void);
-extern void logger(int, int, const char *, ...) __attribute__((__format__(printf, 3, 4)));
+extern void logger(int level, int priority, const char *format, ...) __attribute__((__format__(printf, 3, 4)));
extern void closelogger(void);
#endif
#include "connection.h"
-extern bool send_meta(struct connection_t *, const char *, int);
-extern void send_meta_raw(struct connection_t *, const char *, int);
-extern bool send_meta_sptps(void *, uint8_t, const void *, size_t);
-extern bool receive_meta_sptps(void *, uint8_t, const void *, uint16_t);
-extern void broadcast_meta(struct connection_t *, const char *, int);
-extern bool receive_meta(struct connection_t *);
+extern bool send_meta(struct connection_t *c, const char *buffer, int length);
+extern void send_meta_raw(struct connection_t *c, const char *buffer, int length);
+extern bool send_meta_sptps(void *handle, uint8_t type, const void *data, size_t length);
+extern bool receive_meta_sptps(void *handle, uint8_t type, const void *data, uint16_t length);
+extern void broadcast_meta(struct connection_t *from, const char *buffer, int length);
+extern bool receive_meta(struct connection_t *c);
#endif
#include "connection.h"
#include "node.h"
-extern void retry_outgoing(outgoing_t *);
-extern void handle_incoming_vpn_data(void *, int);
-extern void finish_connecting(struct connection_t *);
-extern bool do_outgoing_connection(struct outgoing_t *);
-extern void handle_new_meta_connection(void *, int);
-extern void handle_new_unix_connection(void *, int);
-extern int setup_listen_socket(const sockaddr_t *);
-extern int setup_vpn_in_socket(const sockaddr_t *);
+extern void retry_outgoing(outgoing_t *outgoing);
+extern void handle_incoming_vpn_data(void *data, int flags);
+extern void finish_connecting(struct connection_t *c);
+extern bool do_outgoing_connection(struct outgoing_t *outgoing);
+extern void handle_new_meta_connection(void *data, int flags);
+extern void handle_new_unix_connection(void *data, int flags);
+extern int setup_listen_socket(const sockaddr_t *sa);
+extern int setup_vpn_in_socket(const sockaddr_t *sa);
extern bool send_sptps_data(node_t *to, node_t *from, int type, const void *data, size_t len);
extern bool receive_sptps_record(void *handle, uint8_t type, const void *data, uint16_t len);
-extern void send_packet(struct node_t *, vpn_packet_t *);
-extern void receive_tcppacket(struct connection_t *, const char *, int);
-extern bool receive_tcppacket_sptps(struct connection_t *, const char *, int);
-extern void broadcast_packet(const struct node_t *, vpn_packet_t *);
+extern void send_packet(struct node_t *n, vpn_packet_t *packet);
+extern void receive_tcppacket(struct connection_t *c, const char *buffer, int length);
+extern bool receive_tcppacket_sptps(struct connection_t *c, const char *buffer, int length);
+extern void broadcast_packet(const struct node_t *n, vpn_packet_t *packet);
extern char *get_name(void);
extern void device_enable(void);
extern void device_disable(void);
extern bool setup_myself_reloadable(void);
extern bool setup_network(void);
-extern void setup_outgoing_connection(struct outgoing_t *, bool verbose);
+extern void setup_outgoing_connection(struct outgoing_t *outgoing, bool verbose);
extern void try_outgoing_connections(void);
extern void close_network_connections(void);
extern int main_loop(void);
-extern void terminate_connection(struct connection_t *, bool);
-extern bool node_read_ecdsa_public_key(struct node_t *);
-extern bool read_ecdsa_public_key(struct connection_t *);
-extern bool read_rsa_public_key(struct connection_t *);
-extern void handle_device_data(void *, int);
-extern void handle_meta_connection_data(struct connection_t *);
+extern void terminate_connection(struct connection_t *c, bool report);
+extern bool node_read_ecdsa_public_key(struct node_t *n);
+extern bool read_ecdsa_public_key(struct connection_t *c);
+extern bool read_rsa_public_key(struct connection_t *c);
+extern void handle_device_data(void *data, int flags);
+extern void handle_meta_connection_data(struct connection_t *c);
extern void regenerate_key(void);
extern void purge(void);
extern void retry(void);
extern int reload_configuration(void);
extern void load_all_nodes(void);
-extern void try_tx(struct node_t *n, bool);
+extern void try_tx(struct node_t *n, bool mtu);
#ifndef HAVE_MINGW
#define closesocket(s) close(s)
extern bool hostnames;
-extern struct addrinfo *str2addrinfo(const char *, const char *, int) __attribute__((__malloc__));
-extern sockaddr_t str2sockaddr(const char *, const char *);
-extern void sockaddr2str(const sockaddr_t *, char **, char **);
-extern char *sockaddr2hostname(const sockaddr_t *) __attribute__((__malloc__));
-extern int sockaddrcmp(const sockaddr_t *, const sockaddr_t *);
-extern int sockaddrcmp_noport(const sockaddr_t *, const sockaddr_t *);
-extern void sockaddrunmap(sockaddr_t *);
-extern void sockaddrfree(sockaddr_t *);
-extern void sockaddrcpy(sockaddr_t *, const sockaddr_t *);
-extern void sockaddr_setport(sockaddr_t *, const char *);
+extern struct addrinfo *str2addrinfo(const char *address, const char *service, int socktype) __attribute__((__malloc__));
+extern sockaddr_t str2sockaddr(const char *address, const char *port);
+extern void sockaddr2str(const sockaddr_t *sa, char **address, char **port);
+extern char *sockaddr2hostname(const sockaddr_t *sa) __attribute__((__malloc__));
+extern int sockaddrcmp(const sockaddr_t *a, const sockaddr_t *b);
+extern int sockaddrcmp_noport(const sockaddr_t *a, const sockaddr_t *b);
+extern void sockaddrunmap(sockaddr_t *sa);
+extern void sockaddrfree(sockaddr_t *sa);
+extern void sockaddrcpy(sockaddr_t *dest, const sockaddr_t *src);
+extern void sockaddr_setport(sockaddr_t *sa, const char *port);
#endif
extern void init_nodes(void);
extern void exit_nodes(void);
extern node_t *new_node(void) __attribute__((__malloc__));
-extern void free_node(node_t *);
-extern void node_add(node_t *);
-extern void node_del(node_t *);
-extern node_t *lookup_node(char *);
-extern node_t *lookup_node_id(const node_id_t *);
-extern node_t *lookup_node_udp(const sockaddr_t *);
-extern bool dump_nodes(struct connection_t *);
-extern bool dump_traffic(struct connection_t *);
-extern void update_node_udp(node_t *, const sockaddr_t *);
+extern void free_node(node_t *n);
+extern void node_add(node_t *n);
+extern void node_del(node_t *n);
+extern node_t *lookup_node(char *name);
+extern node_t *lookup_node_id(const node_id_t *id);
+extern node_t *lookup_node_udp(const sockaddr_t *sa);
+extern bool dump_nodes(struct connection_t *c);
+extern bool dump_traffic(struct connection_t *c);
+extern void update_node_udp(node_t *n, const sockaddr_t *sa);
#endif
/* Basic functions */
-extern bool send_request(struct connection_t *, const char *, ...) __attribute__((__format__(printf, 2, 3)));
-extern void forward_request(struct connection_t *, const char *);
-extern bool receive_request(struct connection_t *, const char *);
+extern bool send_request(struct connection_t *c, const char *format, ...) __attribute__((__format__(printf, 2, 3)));
+extern void forward_request(struct connection_t *c, const char *request);
+extern bool receive_request(struct connection_t *c, const char *request);
extern void init_requests(void);
extern void exit_requests(void);
-extern bool seen_request(const char *);
+extern bool seen_request(const char *request);
/* Requests */
-extern bool send_id(struct connection_t *);
-extern bool send_metakey(struct connection_t *);
-extern bool send_metakey_ec(struct connection_t *);
-extern bool send_challenge(struct connection_t *);
-extern bool send_chal_reply(struct connection_t *);
-extern bool send_ack(struct connection_t *);
-extern bool send_termreq(struct connection_t *);
-extern bool send_ping(struct connection_t *);
-extern bool send_pong(struct connection_t *);
-extern bool send_add_subnet(struct connection_t *, const struct subnet_t *);
-extern bool send_del_subnet(struct connection_t *, const struct subnet_t *);
-extern bool send_add_edge(struct connection_t *, const struct edge_t *);
-extern bool send_del_edge(struct connection_t *, const struct edge_t *);
+extern bool send_id(struct connection_t *c);
+extern bool send_metakey(struct connection_t *c);
+extern bool send_metakey_ec(struct connection_t *c);
+extern bool send_challenge(struct connection_t *c);
+extern bool send_chal_reply(struct connection_t *c);
+extern bool send_ack(struct connection_t *c);
+extern bool send_termreq(struct connection_t *c);
+extern bool send_ping(struct connection_t *c);
+extern bool send_pong(struct connection_t *c);
+extern bool send_add_subnet(struct connection_t *c, const struct subnet_t *subnet);
+extern bool send_del_subnet(struct connection_t *c, const struct subnet_t *subnet);
+extern bool send_add_edge(struct connection_t *c, const struct edge_t *e);
+extern bool send_del_edge(struct connection_t *c, const struct edge_t *e);
extern void send_key_changed(void);
-extern bool send_req_key(struct node_t *);
-extern bool send_ans_key(struct node_t *);
-extern bool send_tcppacket(struct connection_t *, const struct vpn_packet_t *);
-extern bool send_sptps_tcppacket(struct connection_t *, const char *, int);
-extern bool send_udp_info(struct node_t *, struct node_t *);
-extern bool send_mtu_info(struct node_t *, struct node_t *, int);
+extern bool send_req_key(struct node_t *to);
+extern bool send_ans_key(struct node_t *to);
+extern bool send_tcppacket(struct connection_t *c, const struct vpn_packet_t *packet);
+extern bool send_sptps_tcppacket(struct connection_t *c, const char *packet, int len);
+extern bool send_udp_info(struct node_t *from, struct node_t *to);
+extern bool send_mtu_info(struct node_t *from, struct node_t *to, int mtu);
/* Request handlers */
-extern bool id_h(struct connection_t *, const char *);
-extern bool metakey_h(struct connection_t *, const char *);
-extern bool challenge_h(struct connection_t *, const char *);
-extern bool chal_reply_h(struct connection_t *, const char *);
-extern bool ack_h(struct connection_t *, const char *);
-extern bool status_h(struct connection_t *, const char *);
-extern bool error_h(struct connection_t *, const char *);
-extern bool termreq_h(struct connection_t *, const char *);
-extern bool ping_h(struct connection_t *, const char *);
-extern bool pong_h(struct connection_t *, const char *);
-extern bool add_subnet_h(struct connection_t *, const char *);
-extern bool del_subnet_h(struct connection_t *, const char *);
-extern bool add_edge_h(struct connection_t *, const char *);
-extern bool del_edge_h(struct connection_t *, const char *);
-extern bool key_changed_h(struct connection_t *, const char *);
-extern bool req_key_h(struct connection_t *, const char *);
-extern bool ans_key_h(struct connection_t *, const char *);
-extern bool tcppacket_h(struct connection_t *, const char *);
-extern bool sptps_tcppacket_h(struct connection_t *, const char *);
-extern bool control_h(struct connection_t *, const char *);
-extern bool udp_info_h(struct connection_t *, const char *);
-extern bool mtu_info_h(struct connection_t *, const char *);
+extern bool id_h(struct connection_t *c, const char *request);
+extern bool metakey_h(struct connection_t *c, const char *request);
+extern bool challenge_h(struct connection_t *c, const char *request);
+extern bool chal_reply_h(struct connection_t *c, const char *request);
+extern bool ack_h(struct connection_t *c, const char *request);
+extern bool status_h(struct connection_t *c, const char *request);
+extern bool error_h(struct connection_t *c, const char *request);
+extern bool termreq_h(struct connection_t *c, const char *request);
+extern bool ping_h(struct connection_t *c, const char *request);
+extern bool pong_h(struct connection_t *c, const char *request);
+extern bool add_subnet_h(struct connection_t *c, const char *request);
+extern bool del_subnet_h(struct connection_t *c, const char *request);
+extern bool add_edge_h(struct connection_t *c, const char *request);
+extern bool del_edge_h(struct connection_t *c, const char *request);
+extern bool key_changed_h(struct connection_t *c, const char *request);
+extern bool req_key_h(struct connection_t *c, const char *request);
+extern bool ans_key_h(struct connection_t *c, const char *request);
+extern bool tcppacket_h(struct connection_t *c, const char *request);
+extern bool sptps_tcppacket_h(struct connection_t *c, const char *request);
+extern bool control_h(struct connection_t *c, const char *request);
+extern bool udp_info_h(struct connection_t *c, const char *request);
+extern bool mtu_info_h(struct connection_t *c, const char *request);
#endif
extern mac_t mymac;
-extern void route(struct node_t *, struct vpn_packet_t *);
+extern void route(struct node_t *source, struct vpn_packet_t *packet);
#endif
} splay_node_t;
-typedef int (*splay_compare_t)(const void *, const void *);
-typedef void (*splay_action_t)(const void *);
-typedef void (*splay_action_node_t)(const splay_node_t *);
+typedef int (*splay_compare_t)(const void *data1, const void *data2);
+typedef void (*splay_action_t)(const void *data);
+typedef void (*splay_action_node_t)(const splay_node_t *node);
typedef struct splay_tree_t {
/* (De)constructors */
-extern splay_tree_t *splay_alloc_tree(splay_compare_t, splay_action_t) __attribute__((__malloc__));
-extern void splay_free_tree(splay_tree_t *);
+extern splay_tree_t *splay_alloc_tree(splay_compare_t compare, splay_action_t delete) __attribute__((__malloc__));
+extern void splay_free_tree(splay_tree_t *tree);
extern splay_node_t *splay_alloc_node(void) __attribute__((__malloc__));
-extern void splay_free_node(splay_tree_t *tree, splay_node_t *);
+extern void splay_free_node(splay_tree_t *tree, splay_node_t *node);
/* Insertion and deletion */
-extern splay_node_t *splay_insert(splay_tree_t *, void *);
-extern splay_node_t *splay_insert_node(splay_tree_t *, splay_node_t *);
+extern splay_node_t *splay_insert(splay_tree_t *tree, void *data);
+extern splay_node_t *splay_insert_node(splay_tree_t *tree, splay_node_t *node);
-extern void splay_insert_top(splay_tree_t *, splay_node_t *);
-extern void splay_insert_before(splay_tree_t *, splay_node_t *, splay_node_t *);
-extern void splay_insert_after(splay_tree_t *, splay_node_t *, splay_node_t *);
+extern void splay_insert_top(splay_tree_t *tree, splay_node_t *node);
+extern void splay_insert_before(splay_tree_t *tree, splay_node_t *before, splay_node_t *node);
+extern void splay_insert_after(splay_tree_t *tree, splay_node_t *after, splay_node_t *node);
-extern splay_node_t *splay_unlink(splay_tree_t *, void *);
-extern void splay_unlink_node(splay_tree_t *tree, splay_node_t *);
-extern void splay_delete(splay_tree_t *, void *);
-extern void splay_delete_node(splay_tree_t *, splay_node_t *);
+extern splay_node_t *splay_unlink(splay_tree_t *tree, void *data);
+extern void splay_unlink_node(splay_tree_t *tree, splay_node_t *node);
+extern void splay_delete(splay_tree_t *tree, void *data);
+extern void splay_delete_node(splay_tree_t *tree, splay_node_t *node);
/* Fast tree cleanup */
-extern void splay_delete_tree(splay_tree_t *);
+extern void splay_delete_tree(splay_tree_t *tree);
/* Searching */
-extern void *splay_search(splay_tree_t *, const void *);
-extern void *splay_search_closest(splay_tree_t *, const void *, int *);
-extern void *splay_search_closest_smaller(splay_tree_t *, const void *);
-extern void *splay_search_closest_greater(splay_tree_t *, const void *);
+extern void *splay_search(splay_tree_t *tree, const void *data);
+extern void *splay_search_closest(splay_tree_t *tree, const void *data, int *result);
+extern void *splay_search_closest_smaller(splay_tree_t *tree, const void *data);
+extern void *splay_search_closest_greater(splay_tree_t *tree, const void *data);
-extern splay_node_t *splay_search_node(splay_tree_t *, const void *);
-extern splay_node_t *splay_search_closest_node(splay_tree_t *, const void *, int *);
-extern splay_node_t *splay_search_closest_node_nosplay(const splay_tree_t *, const void *, int *);
-extern splay_node_t *splay_search_closest_smaller_node(splay_tree_t *, const void *);
-extern splay_node_t *splay_search_closest_greater_node(splay_tree_t *, const void *);
+extern splay_node_t *splay_search_node(splay_tree_t *tree, const void *data);
+extern splay_node_t *splay_search_closest_node(splay_tree_t *tree, const void *data, int *result);
+extern splay_node_t *splay_search_closest_node_nosplay(const splay_tree_t *tree, const void *data, int *result);
+extern splay_node_t *splay_search_closest_smaller_node(splay_tree_t *tree, const void *data);
+extern splay_node_t *splay_search_closest_greater_node(splay_tree_t *tree, const void *data);
/* Tree walking */
-extern void splay_foreach(const splay_tree_t *, splay_action_t);
-extern void splay_foreach_node(const splay_tree_t *, splay_action_t);
+extern void splay_foreach(const splay_tree_t *tree, splay_action_t action);
+extern void splay_foreach_node(const splay_tree_t *tree, splay_action_t action);
/*
Iterates over a tree.
extern splay_tree_t *subnet_tree;
-extern int subnet_compare(const struct subnet_t *, const struct subnet_t *);
+extern int subnet_compare(const struct subnet_t *a, const struct subnet_t *b);
extern subnet_t *new_subnet(void) __attribute__((__malloc__));
-extern void free_subnet(subnet_t *);
+extern void free_subnet(subnet_t *subnet);
extern void init_subnets(void);
extern void exit_subnets(void);
extern splay_tree_t *new_subnet_tree(void) __attribute__((__malloc__));
extern void free_subnet_tree(splay_tree_t *);
-extern void subnet_add(struct node_t *, subnet_t *);
-extern void subnet_del(struct node_t *, subnet_t *);
-extern void subnet_update(struct node_t *, subnet_t *, bool);
-extern int maskcmp(const void *, const void *, int);
-extern void maskcpy(void *, const void *, int, int);
-extern void mask(void *, int, int);
-extern bool maskcheck(const void *, int, int);
-extern bool net2str(char *, int, const subnet_t *);
-extern bool str2net(subnet_t *, const char *);
-extern subnet_t *lookup_subnet(const struct node_t *, const subnet_t *);
-extern subnet_t *lookup_subnet_mac(const struct node_t *, const mac_t *);
-extern subnet_t *lookup_subnet_ipv4(const ipv4_t *);
-extern subnet_t *lookup_subnet_ipv6(const ipv6_t *);
-extern bool dump_subnets(struct connection_t *);
+extern void subnet_add(struct node_t *owner, subnet_t *subnet);
+extern void subnet_del(struct node_t *owner, subnet_t *subnet);
+extern void subnet_update(struct node_t *owner, subnet_t *subnet, bool up);
+extern int maskcmp(const void *a, const void *b, int masklen);
+extern void maskcpy(void *dest, const void *src, int masklen, int len);
+extern void mask(void *mask, int masklen, int len);
+extern bool maskcheck(const void *mask, int masklen, int len);
+extern bool net2str(char *netstr, int len, const subnet_t *subnet);
+extern bool str2net(subnet_t *subnet, const char *netstr);
+extern subnet_t *lookup_subnet(const struct node_t *owner, const subnet_t *subnet);
+extern subnet_t *lookup_subnet_mac(const struct node_t *owner, const mac_t *address);
+extern subnet_t *lookup_subnet_ipv4(const ipv4_t *address);
+extern subnet_t *lookup_subnet_ipv6(const ipv6_t *address);
+extern bool dump_subnets(struct connection_t *c);
extern void subnet_cache_flush(void);
#endif
#include "system.h"
-extern void upnp_init(bool, bool);
+extern void upnp_init(bool tcp, bool udp);
#endif
extern unsigned int bitfield_to_int(const void *bitfield, size_t size);
-extern bool check_id(const char *);
-extern bool check_netname(const char *, bool strict);
+extern bool check_id(const char *id);
+extern bool check_netname(const char *netname, bool strict);
char *replace_name(const char *name);
#endif