From: Guus Sliepen Date: Sun, 6 Jul 2003 23:16:29 +0000 (+0000) Subject: Sprinkling the source with static and attributes. X-Git-Tag: release-1.0~72 X-Git-Url: https://tinc-vpn.org/git/browse?p=tinc;a=commitdiff_plain;h=1401faf608e1c8af0d0754e545b0ec79d2bd5d93 Sprinkling the source with static and attributes. --- diff --git a/lib/avl_tree.c b/lib/avl_tree.c index 7bacc20e..53d82eb4 100644 --- a/lib/avl_tree.c +++ b/lib/avl_tree.c @@ -29,7 +29,7 @@ library for inclusion into tinc (http://tinc.nl.linux.org/) by Guus Sliepen . - $Id: avl_tree.c,v 1.1.2.13 2003/06/11 19:39:02 guus Exp $ + $Id: avl_tree.c,v 1.1.2.14 2003/07/06 23:16:27 guus Exp $ */ #include @@ -53,7 +53,9 @@ #endif #ifndef AVL_DEPTH -int lg(unsigned int u) +static int lg(unsigned int u) __attribute__ ((const)); + +static int lg(unsigned int u) { int r = 1; @@ -89,7 +91,7 @@ int lg(unsigned int u) /* Internal helper functions */ -int avl_check_balance(avl_node_t *node) +static int avl_check_balance(avl_node_t *node) { #ifdef AVL_DEPTH int d; @@ -117,7 +119,7 @@ int avl_check_balance(avl_node_t *node) #endif } -void avl_rebalance(avl_tree_t *tree, avl_node_t *node) +static void avl_rebalance(avl_tree_t *tree, avl_node_t *node) { avl_node_t *child; avl_node_t *gchild; diff --git a/lib/fake-getaddrinfo.h b/lib/fake-getaddrinfo.h index 6b1744c9..3f24375c 100644 --- a/lib/fake-getaddrinfo.h +++ b/lib/fake-getaddrinfo.h @@ -1,4 +1,4 @@ -/* $Id: fake-getaddrinfo.h,v 1.1.2.1 2002/07/12 11:45:21 guus Exp $ */ +/* $Id: fake-getaddrinfo.h,v 1.1.2.2 2003/07/06 23:16:27 guus Exp $ */ #ifndef _FAKE_GETADDRINFO_H #define _FAKE_GETADDRINFO_H @@ -22,6 +22,10 @@ # define NI_NUMERICSERV 8 #endif +#ifndef AI_NUMERICHOST +#define AI_NUMERICHOST 4 +#endif + #ifndef HAVE_STRUCT_ADDRINFO struct addrinfo { int ai_flags; /* AI_PASSIVE, AI_CANONNAME */ diff --git a/lib/list.h b/lib/list.h index df08e492..175d640e 100644 --- a/lib/list.h +++ b/lib/list.h @@ -17,7 +17,7 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - $Id: list.h,v 1.1.2.8 2002/09/09 22:32:27 guus Exp $ + $Id: list.h,v 1.1.2.9 2003/07/06 23:16:28 guus Exp $ */ #ifndef __TINC_LIST_H__ @@ -47,7 +47,7 @@ typedef struct list_t { /* (De)constructors */ -extern list_t *list_alloc(list_action_t); +extern list_t *list_alloc(list_action_t) __attribute__ ((malloc)); extern void list_free(list_t *); extern list_node_t *list_alloc_node(void); extern void list_free_node(list_t *, list_node_t *); diff --git a/lib/xalloc.h b/lib/xalloc.h index caf0f37d..dbba254a 100644 --- a/lib/xalloc.h +++ b/lib/xalloc.h @@ -18,9 +18,9 @@ extern char *const xalloc_msg_memory_exhausted; /* FIXME: describe */ extern void (*xalloc_fail_func) (); -void *xmalloc PARAMS ((size_t n)); -void *xmalloc_and_zero PARAMS ((size_t n)); +void *xmalloc PARAMS ((size_t n)) __attribute__ ((malloc)); +void *xmalloc_and_zero PARAMS ((size_t n)) __attribute__ ((malloc)); void *xcalloc PARAMS ((size_t n, size_t s)); -void *xrealloc PARAMS ((void *p, size_t n)); +void *xrealloc PARAMS ((void *p, size_t n)) __attribute__ ((malloc)); -char *xstrdup PARAMS ((const char *s)); +char *xstrdup PARAMS ((const char *s)) __attribute__ ((malloc)); diff --git a/src/conf.c b/src/conf.c index ef1ee50f..09e72a5b 100644 --- a/src/conf.c +++ b/src/conf.c @@ -19,7 +19,7 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - $Id: conf.c,v 1.9.4.62 2003/07/06 22:11:31 guus Exp $ + $Id: conf.c,v 1.9.4.63 2003/07/06 23:16:28 guus Exp $ */ #include "config.h" @@ -51,7 +51,7 @@ int pingtimeout = 0; /* seconds before timeout */ char *confbase = NULL; /* directory in which all config files are */ char *netname = NULL; /* name of the vpn network */ -int config_compare(config_t *a, config_t *b) +static int config_compare(config_t *a, config_t *b) { int result; @@ -270,7 +270,7 @@ int get_config_subnet(config_t *cfg, subnet_t ** result) given, and buf needs to be expanded, the var pointed to by buflen will be increased. */ -char *readline(FILE * fp, char **buf, size_t *buflen) +static char *readline(FILE * fp, char **buf, size_t *buflen) { char *newline = NULL; char *p; @@ -429,7 +429,7 @@ int read_server_config() return x; } -int isadir(const char *f) +static int isadir(const char *f) { struct stat s; diff --git a/src/conf.h b/src/conf.h index 64c87753..5dc4c930 100644 --- a/src/conf.h +++ b/src/conf.h @@ -17,7 +17,7 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - $Id: conf.h,v 1.6.4.36 2003/07/06 22:11:31 guus Exp $ + $Id: conf.h,v 1.6.4.37 2003/07/06 23:16:28 guus Exp $ */ #ifndef __TINC_CONF_H__ @@ -48,7 +48,7 @@ extern char *netname; extern void init_configuration(avl_tree_t **); extern void exit_configuration(avl_tree_t **); -extern config_t *new_config(void); +extern config_t *new_config(void) __attribute__ ((malloc)); extern void free_config(config_t *); extern void config_add(avl_tree_t *, config_t *); extern config_t *lookup_config(avl_tree_t *, char *); diff --git a/src/connection.c b/src/connection.c index 4d6e30b2..adfe73b5 100644 --- a/src/connection.c +++ b/src/connection.c @@ -17,7 +17,7 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - $Id: connection.c,v 1.1.2.37 2003/07/06 22:11:31 guus Exp $ + $Id: connection.c,v 1.1.2.38 2003/07/06 23:16:28 guus Exp $ */ #include "config.h" @@ -42,7 +42,7 @@ avl_tree_t *connection_tree; /* Meta connections */ connection_t *broadcast; -int connection_compare(connection_t *a, connection_t *b) +static int connection_compare(connection_t *a, connection_t *b) { return (void *)a - (void *)b; } diff --git a/src/connection.h b/src/connection.h index 97552275..bcf0708d 100644 --- a/src/connection.h +++ b/src/connection.h @@ -17,7 +17,7 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - $Id: connection.h,v 1.1.2.31 2002/09/09 21:24:31 guus Exp $ + $Id: connection.h,v 1.1.2.32 2003/07/06 23:16:28 guus Exp $ */ #ifndef __TINC_CONNECTION_H__ @@ -113,7 +113,7 @@ extern connection_t *broadcast; extern void init_connections(void); extern void exit_connections(void); -extern connection_t *new_connection(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 *); diff --git a/src/edge.c b/src/edge.c index f9d4d98d..88fbd1c0 100644 --- a/src/edge.c +++ b/src/edge.c @@ -17,7 +17,7 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - $Id: edge.c,v 1.1.2.19 2003/07/06 22:11:31 guus Exp $ + $Id: edge.c,v 1.1.2.20 2003/07/06 23:16:28 guus Exp $ */ #include "config.h" @@ -42,12 +42,12 @@ avl_tree_t *edge_weight_tree; /* Tree with all edges, sorted on weight */ -int edge_compare(edge_t *a, edge_t *b) +static int edge_compare(edge_t *a, edge_t *b) { return strcmp(a->to->name, b->to->name); } -int edge_weight_compare(edge_t *a, edge_t *b) +static int edge_weight_compare(edge_t *a, edge_t *b) { int result; diff --git a/src/edge.h b/src/edge.h index 875b1aa2..8e42385c 100644 --- a/src/edge.h +++ b/src/edge.h @@ -17,7 +17,7 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - $Id: edge.h,v 1.1.2.11 2002/09/09 21:24:31 guus Exp $ + $Id: edge.h,v 1.1.2.12 2003/07/06 23:16:28 guus Exp $ */ #ifndef __TINC_EDGE_H__ @@ -45,9 +45,9 @@ extern avl_tree_t *edge_weight_tree; /* Tree with all known edges sorted on weig extern void init_edges(void); extern void exit_edges(void); -extern edge_t *new_edge(void); +extern edge_t *new_edge(void) __attribute__ ((malloc)); extern void free_edge(edge_t *); -extern avl_tree_t *new_edge_tree(void); +extern avl_tree_t *new_edge_tree(void) __attribute__ ((malloc)); extern void free_edge_tree(avl_tree_t *); extern void edge_add(edge_t *); extern void edge_del(edge_t *); diff --git a/src/event.c b/src/event.c index a91be86d..5663170c 100644 --- a/src/event.c +++ b/src/event.c @@ -17,7 +17,7 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - $Id: event.c,v 1.1.4.6 2002/09/09 22:32:30 guus Exp $ + $Id: event.c,v 1.1.4.7 2003/07/06 23:16:28 guus Exp $ */ #include "config.h" @@ -38,7 +38,7 @@ extern time_t now; int id; -int event_compare(event_t *a, event_t *b) +static int event_compare(event_t *a, event_t *b) { if(a->time > b->time) return 1; diff --git a/src/event.h b/src/event.h index 25eb9667..ad31e15b 100644 --- a/src/event.h +++ b/src/event.h @@ -17,7 +17,7 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - $Id: event.h,v 1.1.4.4 2002/09/09 22:32:36 guus Exp $ + $Id: event.h,v 1.1.4.5 2003/07/06 23:16:28 guus Exp $ */ #ifndef __TINC_EVENT_H__ @@ -26,7 +26,7 @@ #include #include -avl_tree_t *event_tree; +extern avl_tree_t *event_tree; typedef void (*event_handler_t)(void *); @@ -39,7 +39,7 @@ typedef struct { extern void init_events(void); extern void exit_events(void); -extern event_t *new_event(void); +extern event_t *new_event(void) __attribute__ ((malloc)); extern void free_event(event_t *); extern void event_add(event_t *); extern void event_del(event_t *); diff --git a/src/logger.c b/src/logger.c index de662270..8029565f 100644 --- a/src/logger.c +++ b/src/logger.c @@ -17,12 +17,13 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - $Id: logger.c,v 1.1.2.1 2003/07/06 22:11:31 guus Exp $ + $Id: logger.c,v 1.1.2.2 2003/07/06 23:16:28 guus Exp $ */ #include #include #include +#include #include "conf.h" #include "logger.h" @@ -30,15 +31,13 @@ #include "system.h" volatile int debug_level = DEBUG_NOTHING; -int logmode = LOGMODE_STDERR; -pid_t logpid; +static int logmode = LOGMODE_STDERR; +static pid_t logpid; extern char *logfilename; -FILE *logfile = NULL; -const char *logident = NULL; +static FILE *logfile = NULL; +static const char *logident = NULL; void openlogger(const char *ident, int mode) { - char *fname; - logident = ident; logmode = mode; @@ -65,7 +64,7 @@ void vlogger(int priority, const char *format, va_list ap) { fprintf(stderr, "\n"); break; case LOGMODE_FILE: - fprintf(logfile, "%d %s[%d]: ", time(NULL), logident, logpid); + fprintf(logfile, "%ld %s[%d]: ", time(NULL), logident, logpid); vfprintf(logfile, format, ap); fprintf(logfile, "\n"); break; diff --git a/src/net.c b/src/net.c index 0f354cd7..fa798f8d 100644 --- a/src/net.c +++ b/src/net.c @@ -17,7 +17,7 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - $Id: net.c,v 1.35.4.188 2003/07/06 22:11:32 guus Exp $ + $Id: net.c,v 1.35.4.189 2003/07/06 23:16:28 guus Exp $ */ #include "config.h" @@ -82,7 +82,7 @@ time_t now = 0; /* Purge edges and subnets of unreachable nodes. Use carefully. */ -void purge(void) +static void purge(void) { avl_node_t *nnode, *nnext, *enode, *enext, *snode, *snext; node_t *n; @@ -124,7 +124,7 @@ void purge(void) put all file descriptors in an fd_set array While we're at it, purge stuff that needs to be removed. */ -int build_fdset(fd_set * fs) +static int build_fdset(fd_set * fs) { avl_node_t *node, *next; connection_t *c; @@ -218,7 +218,7 @@ void terminate_connection(connection_t *c, int report) end does not reply in time, we consider them dead and close the connection. */ -void check_dead_connections(void) +static void check_dead_connections(void) { avl_node_t *node, *next; connection_t *c; @@ -258,7 +258,7 @@ void check_dead_connections(void) check all connections to see if anything happened on their sockets */ -void check_network_activity(fd_set * f) +static void check_network_activity(fd_set * f) { connection_t *c; avl_node_t *node; diff --git a/src/net.h b/src/net.h index 083cb235..48516492 100644 --- a/src/net.h +++ b/src/net.h @@ -17,7 +17,7 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - $Id: net.h,v 1.9.4.59 2003/07/06 17:15:25 guus Exp $ + $Id: net.h,v 1.9.4.60 2003/07/06 23:16:28 guus Exp $ */ #ifndef __TINC_NET_H__ @@ -121,9 +121,6 @@ extern int maxtimeout; extern int seconds_till_retry; extern int addressfamily; -extern char *request_name[]; -extern char *status_text[]; - #include "connection.h" /* Yes, very strange placement indeed, but otherwise the typedefs get all tangled up */ extern listen_socket_t listen_socket[MAXSOCKETS]; @@ -144,7 +141,6 @@ extern int handle_new_meta_connection(int); extern int setup_listen_socket(sockaddr_t *); extern int setup_vpn_in_socket(sockaddr_t *); extern void send_packet(struct node_t *, vpn_packet_t *); -extern void receive_packet(struct node_t *, vpn_packet_t *); extern void receive_tcppacket(struct connection_t *, char *, int); extern void broadcast_packet(struct node_t *, vpn_packet_t *); extern int setup_network_connections(void); diff --git a/src/net_packet.c b/src/net_packet.c index 98151d16..79d3b18a 100644 --- a/src/net_packet.c +++ b/src/net_packet.c @@ -17,7 +17,7 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - $Id: net_packet.c,v 1.1.2.31 2003/07/06 22:11:32 guus Exp $ + $Id: net_packet.c,v 1.1.2.32 2003/07/06 23:16:28 guus Exp $ */ #include "config.h" @@ -82,12 +82,12 @@ int keylifetime = 0; int keyexpires = 0; EVP_CIPHER_CTX packet_ctx; -char lzo_wrkmem[LZO1X_999_MEM_COMPRESS > LZO1X_1_MEM_COMPRESS ? LZO1X_999_MEM_COMPRESS : LZO1X_1_MEM_COMPRESS]; +static char lzo_wrkmem[LZO1X_999_MEM_COMPRESS > LZO1X_1_MEM_COMPRESS ? LZO1X_999_MEM_COMPRESS : LZO1X_1_MEM_COMPRESS]; #define MAX_SEQNO 1073741824 -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; @@ -108,7 +108,7 @@ length_t compress_packet(uint8_t *dest, const uint8_t *source, length_t len, int return -1; } -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; @@ -129,7 +129,17 @@ length_t uncompress_packet(uint8_t *dest, const uint8_t *source, length_t len, i /* VPN packet I/O */ -void receive_udppacket(node_t *n, vpn_packet_t *inpkt) +static void receive_packet(node_t *n, vpn_packet_t *packet) +{ + cp(); + + logger(DEBUG_TRAFFIC, LOG_DEBUG, _("Received packet of %d bytes from %s (%s)"), + packet->len, n->name, n->hostname); + + route_incoming(n, packet); +} + +static void receive_udppacket(node_t *n, vpn_packet_t *inpkt) { vpn_packet_t pkt1, pkt2; vpn_packet_t *pkt[] = { &pkt1, &pkt2, &pkt1, &pkt2 }; @@ -227,17 +237,7 @@ void receive_tcppacket(connection_t *c, char *buffer, int len) receive_packet(c->node, &outpkt); } -void receive_packet(node_t *n, vpn_packet_t *packet) -{ - cp(); - - logger(DEBUG_TRAFFIC, LOG_DEBUG, _("Received packet of %d bytes from %s (%s)"), - packet->len, n->name, n->hostname); - - route_incoming(n, packet); -} - -void send_udppacket(node_t *n, vpn_packet_t *inpkt) +static void send_udppacket(node_t *n, vpn_packet_t *inpkt) { vpn_packet_t pkt1, pkt2; vpn_packet_t *pkt[] = { &pkt1, &pkt2, &pkt1, &pkt2 }; diff --git a/src/node.c b/src/node.c index edad62bb..350d02d8 100644 --- a/src/node.c +++ b/src/node.c @@ -17,7 +17,7 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - $Id: node.c,v 1.1.2.20 2003/07/06 22:11:32 guus Exp $ + $Id: node.c,v 1.1.2.21 2003/07/06 23:16:28 guus Exp $ */ #include "config.h" @@ -40,12 +40,12 @@ avl_tree_t *node_udp_tree; /* Known nodes, sorted by address and port */ node_t *myself; -int node_compare(node_t *a, node_t *b) +static int node_compare(node_t *a, node_t *b) { return strcmp(a->name, b->name); } -int node_udp_compare(node_t *a, node_t *b) +static int node_udp_compare(node_t *a, node_t *b) { int result; diff --git a/src/node.h b/src/node.h index 800c6dee..b5cd8a74 100644 --- a/src/node.h +++ b/src/node.h @@ -17,7 +17,7 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - $Id: node.h,v 1.1.2.22 2003/05/06 21:13:18 guus Exp $ + $Id: node.h,v 1.1.2.23 2003/07/06 23:16:28 guus Exp $ */ #ifndef __TINC_NODE_H__ @@ -83,7 +83,7 @@ extern avl_tree_t *node_udp_tree; extern void init_nodes(void); extern void exit_nodes(void); -extern node_t *new_node(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 *); diff --git a/src/process.c b/src/process.c index e43d9f86..45acc5c2 100644 --- a/src/process.c +++ b/src/process.c @@ -17,7 +17,7 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - $Id: process.c,v 1.1.2.51 2003/07/06 22:11:32 guus Exp $ + $Id: process.c,v 1.1.2.52 2003/07/06 23:16:28 guus Exp $ */ #include "config.h" @@ -65,7 +65,7 @@ extern int sighup; extern int sigalrm; extern int do_purge; -void memory_full(int size) +static void memory_full(int size) { logger(DEBUG_ALWAYS, LOG_ERR, _("Memory exhausted (couldn't allocate %d bytes), exitting."), size); cp_trace(); @@ -75,7 +75,7 @@ void memory_full(int size) /* Some functions the less gifted operating systems might lack... */ #ifndef HAVE_FCLOSEALL -int fcloseall(void) +static int fcloseall(void) { fflush(stdin); fflush(stdout); @@ -108,7 +108,7 @@ void cleanup_and_exit(int c) /* check for an existing tinc for this net, and write pid to pidfile */ -int write_pidfile(void) +static int write_pidfile(void) { int pid; @@ -213,9 +213,9 @@ int detach(void) /* Execute the program name, with sane environment. */ -void _execute_script(const char *scriptname, char **envp) +static void _execute_script(const char *scriptname, char **envp) __attribute__ ((noreturn)); -void _execute_script(const char *scriptname, char **envp) +static void _execute_script(const char *scriptname, char **envp) { cp(); @@ -304,20 +304,20 @@ int execute_script(const char *name, char **envp) Signal handlers. */ -RETSIGTYPE sigterm_handler(int a) +static RETSIGTYPE sigterm_handler(int a) { logger(DEBUG_ALWAYS, LOG_NOTICE, _("Got TERM signal")); cleanup_and_exit(0); } -RETSIGTYPE sigquit_handler(int a) +static RETSIGTYPE sigquit_handler(int a) { logger(DEBUG_ALWAYS, LOG_NOTICE, _("Got QUIT signal")); cleanup_and_exit(0); } -RETSIGTYPE fatal_signal_square(int a) +static RETSIGTYPE fatal_signal_square(int a) { logger(DEBUG_ALWAYS, LOG_ERR, _("Got another fatal signal %d (%s): not restarting."), a, strsignal(a)); @@ -325,7 +325,7 @@ RETSIGTYPE fatal_signal_square(int a) exit(1); } -RETSIGTYPE fatal_signal_handler(int a) +static RETSIGTYPE fatal_signal_handler(int a) { struct sigaction act; logger(DEBUG_ALWAYS, LOG_ERR, _("Got fatal signal %d (%s)"), a, strsignal(a)); @@ -349,13 +349,13 @@ RETSIGTYPE fatal_signal_handler(int a) } } -RETSIGTYPE sighup_handler(int a) +static RETSIGTYPE sighup_handler(int a) { logger(DEBUG_ALWAYS, LOG_NOTICE, _("Got HUP signal")); sighup = 1; } -RETSIGTYPE sigint_handler(int a) +static RETSIGTYPE sigint_handler(int a) { if(saved_debug_level != -1) { logger(DEBUG_ALWAYS, LOG_NOTICE, _("Reverting to old debug level (%d)"), @@ -371,18 +371,18 @@ RETSIGTYPE sigint_handler(int a) } } -RETSIGTYPE sigalrm_handler(int a) +static RETSIGTYPE sigalrm_handler(int a) { logger(DEBUG_ALWAYS, LOG_NOTICE, _("Got ALRM signal")); sigalrm = 1; } -RETSIGTYPE sigusr1_handler(int a) +static RETSIGTYPE sigusr1_handler(int a) { dump_connections(); } -RETSIGTYPE sigusr2_handler(int a) +static RETSIGTYPE sigusr2_handler(int a) { dump_device_stats(); dump_nodes(); @@ -390,24 +390,24 @@ RETSIGTYPE sigusr2_handler(int a) dump_subnets(); } -RETSIGTYPE sigwinch_handler(int a) +static RETSIGTYPE sigwinch_handler(int a) { extern int do_purge; do_purge = 1; } -RETSIGTYPE unexpected_signal_handler(int a) +static RETSIGTYPE unexpected_signal_handler(int a) { logger(DEBUG_ALWAYS, LOG_WARNING, _("Got unexpected signal %d (%s)"), a, strsignal(a)); cp_trace(); } -RETSIGTYPE ignore_signal_handler(int a) +static RETSIGTYPE ignore_signal_handler(int a) { logger(DEBUG_SCARY_THINGS, LOG_DEBUG, _("Ignored signal %d (%s)"), a, strsignal(a)); } -struct { +static struct { int signal; void (*handler)(int); } sighandlers[] = { diff --git a/src/process.h b/src/process.h index dd794e40..0844ed20 100644 --- a/src/process.h +++ b/src/process.h @@ -17,7 +17,7 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - $Id: process.h,v 1.1.2.13 2002/09/09 21:24:41 guus Exp $ + $Id: process.h,v 1.1.2.14 2003/07/06 23:16:28 guus Exp $ */ #ifndef __TINC_PROCESS_H__ @@ -31,6 +31,6 @@ extern void setup_signals(void); extern int execute_script(const char *, char **); extern int detach(void); extern int kill_other(int); -extern void cleanup_and_exit(int); +extern void cleanup_and_exit(int) __attribute__ ((noreturn)); #endif /* __TINC_PROCESS_H__ */ diff --git a/src/protocol.c b/src/protocol.c index 9ac5a1fb..a6485475 100644 --- a/src/protocol.c +++ b/src/protocol.c @@ -17,7 +17,7 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - $Id: protocol.c,v 1.28.4.138 2003/07/06 22:11:32 guus Exp $ + $Id: protocol.c,v 1.28.4.139 2003/07/06 23:16:28 guus Exp $ */ #include "config.h" @@ -41,7 +41,28 @@ #include "system.h" -avl_tree_t *past_request_tree; +/* Jumptable for the request handlers */ + +static int (*request_handlers[])(connection_t *) = { + id_h, metakey_h, challenge_h, chal_reply_h, ack_h, + status_h, error_h, termreq_h, + ping_h, pong_h, + add_subnet_h, del_subnet_h, + add_edge_h, del_edge_h, + key_changed_h, req_key_h, ans_key_h, tcppacket_h, +}; + +/* Request names */ + +static char (*request_name[]) = { + "ID", "METAKEY", "CHALLENGE", "CHAL_REPLY", "ACK", + "STATUS", "ERROR", "TERMREQ", + "PING", "PONG", + "ADD_SUBNET", "DEL_SUBNET", + "ADD_EDGE", "DEL_EDGE", "KEY_CHANGED", "REQ_KEY", "ANS_KEY", "PACKET", +}; + +static avl_tree_t *past_request_tree; int check_id(char *id) { @@ -170,12 +191,12 @@ int receive_request(connection_t *c) return 0; } -int past_request_compare(past_request_t *a, past_request_t *b) +static int past_request_compare(past_request_t *a, past_request_t *b) { return strcmp(a->request, b->request); } -void free_past_request(past_request_t *r) +static void free_past_request(past_request_t *r) { cp(); @@ -241,24 +262,3 @@ void age_past_requests(void) logger(DEBUG_SCARY_THINGS, LOG_DEBUG, _("Aging past requests: deleted %d, left %d\n"), deleted, left); } - -/* Jumptable for the request handlers */ - -int (*request_handlers[])(connection_t *) = { - id_h, metakey_h, challenge_h, chal_reply_h, ack_h, - status_h, error_h, termreq_h, - ping_h, pong_h, - add_subnet_h, del_subnet_h, - add_edge_h, del_edge_h, - key_changed_h, req_key_h, ans_key_h, tcppacket_h, -}; - -/* Request names */ - -char (*request_name[]) = { - "ID", "METAKEY", "CHALLENGE", "CHAL_REPLY", "ACK", - "STATUS", "ERROR", "TERMREQ", - "PING", "PONG", - "ADD_SUBNET", "DEL_SUBNET", - "ADD_EDGE", "DEL_EDGE", "KEY_CHANGED", "REQ_KEY", "ANS_KEY", "PACKET", -}; diff --git a/src/protocol.h b/src/protocol.h index 67fcb325..6e71f810 100644 --- a/src/protocol.h +++ b/src/protocol.h @@ -17,7 +17,7 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - $Id: protocol.h,v 1.5.4.37 2002/09/09 22:41:56 guus Exp $ + $Id: protocol.h,v 1.5.4.38 2003/07/06 23:16:28 guus Exp $ */ #ifndef __TINC_PROTOCOL_H__ @@ -93,8 +93,6 @@ extern int send_tcppacket(connection_t *, vpn_packet_t *); /* Request handlers */ -extern int (*request_handlers[])(connection_t *); - extern int id_h(connection_t *); extern int metakey_h(connection_t *); extern int challenge_h(connection_t *); diff --git a/src/protocol_auth.c b/src/protocol_auth.c index f117550d..28c6fea0 100644 --- a/src/protocol_auth.c +++ b/src/protocol_auth.c @@ -17,7 +17,7 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - $Id: protocol_auth.c,v 1.1.4.21 2003/07/06 22:11:32 guus Exp $ + $Id: protocol_auth.c,v 1.1.4.22 2003/07/06 23:16:29 guus Exp $ */ #include "config.h" @@ -481,7 +481,7 @@ int send_ack(connection_t *c) return x; } -void send_everything(connection_t *c) +static void send_everything(connection_t *c) { avl_node_t *node, *node2; node_t *n; diff --git a/src/protocol_misc.c b/src/protocol_misc.c index 36054f0a..18155e94 100644 --- a/src/protocol_misc.c +++ b/src/protocol_misc.c @@ -17,7 +17,7 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - $Id: protocol_misc.c,v 1.1.4.8 2003/07/06 22:11:33 guus Exp $ + $Id: protocol_misc.c,v 1.1.4.9 2003/07/06 23:16:29 guus Exp $ */ #include "config.h" @@ -40,6 +40,18 @@ #include "system.h" +/* Status strings */ + +static char (*status_text[]) = { + "Warning", +}; + +/* Error strings */ + +static char (*error_text[]) = { + "Error", +}; + /* Status and error notification routines */ int send_status(connection_t *c, int statusno, char *statusstring) @@ -192,15 +204,3 @@ int tcppacket_h(connection_t *c) return 0; } - -/* Status strings */ - -char (*status_text[]) = { - "Warning", -}; - -/* Error strings */ - -char (*error_text[]) = { - "Error", -}; diff --git a/src/route.c b/src/route.c index 1fd1d8ef..1cdf964a 100644 --- a/src/route.c +++ b/src/route.c @@ -17,7 +17,7 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - $Id: route.c,v 1.1.2.54 2003/07/06 22:11:33 guus Exp $ + $Id: route.c,v 1.1.2.55 2003/07/06 23:16:29 guus Exp $ */ #include "config.h" @@ -84,11 +84,11 @@ int routing_mode = RMODE_ROUTER; int priorityinheritance = 0; int macexpire = 600; int overwrite_mac = 0; -mac_t mymac = {{0xFE, 0xFD, 0, 0, 0, 0}}; +static mac_t mymac = {{0xFE, 0xFD, 0, 0, 0, 0}}; /* RFC 1071 */ -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; @@ -107,7 +107,7 @@ uint16_t inet_checksum(void *data, int len, uint16_t prevsum) return ~checksum; } -int ratelimit(void) { +static int ratelimit(void) { static time_t lasttime = 0; if(lasttime == now) @@ -117,7 +117,7 @@ int ratelimit(void) { return 0; } -void learn_mac(mac_t *address) +static void learn_mac(mac_t *address) { subnet_t *subnet; avl_node_t *node; @@ -179,7 +179,7 @@ void age_mac(void) } } -node_t *route_mac(vpn_packet_t *packet) +static node_t *route_mac(vpn_packet_t *packet) { subnet_t *subnet; @@ -201,7 +201,7 @@ node_t *route_mac(vpn_packet_t *packet) /* RFC 792 */ -void route_ipv4_unreachable(vpn_packet_t *packet, uint8_t code) +static void route_ipv4_unreachable(vpn_packet_t *packet, uint8_t code) { struct ip *hdr; struct icmp *icmp; @@ -260,7 +260,7 @@ void route_ipv4_unreachable(vpn_packet_t *packet, uint8_t code) write_packet(packet); } -node_t *route_ipv4(vpn_packet_t *packet) +static node_t *route_ipv4(vpn_packet_t *packet) { subnet_t *subnet; @@ -290,7 +290,7 @@ node_t *route_ipv4(vpn_packet_t *packet) /* RFC 2463 */ -void route_ipv6_unreachable(vpn_packet_t *packet, uint8_t code) +static void route_ipv6_unreachable(vpn_packet_t *packet, uint8_t code) { struct ip6_hdr *hdr; struct icmp6_hdr *icmp; @@ -358,7 +358,7 @@ void route_ipv6_unreachable(vpn_packet_t *packet, uint8_t code) #endif -node_t *route_ipv6(vpn_packet_t *packet) +static node_t *route_ipv6(vpn_packet_t *packet) { subnet_t *subnet; @@ -395,7 +395,7 @@ node_t *route_ipv6(vpn_packet_t *packet) /* RFC 2461 */ -void route_neighborsol(vpn_packet_t *packet) +static void route_neighborsol(vpn_packet_t *packet) { struct ip6_hdr *hdr; struct nd_neighbor_solicit *ns; @@ -508,7 +508,7 @@ void route_neighborsol(vpn_packet_t *packet) /* RFC 826 */ -void route_arp(vpn_packet_t *packet) +static void route_arp(vpn_packet_t *packet) { struct ether_arp *arp; subnet_t *subnet; diff --git a/src/subnet.c b/src/subnet.c index ed5e1ac8..6a7cf78e 100644 --- a/src/subnet.c +++ b/src/subnet.c @@ -17,7 +17,7 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - $Id: subnet.c,v 1.1.2.44 2003/07/06 22:11:33 guus Exp $ + $Id: subnet.c,v 1.1.2.45 2003/07/06 23:16:29 guus Exp $ */ #include "config.h" @@ -48,7 +48,7 @@ avl_tree_t *subnet_tree; /* Subnet comparison */ -int subnet_compare_mac(subnet_t *a, subnet_t *b) +static int subnet_compare_mac(subnet_t *a, subnet_t *b) { int result; @@ -60,7 +60,7 @@ int subnet_compare_mac(subnet_t *a, subnet_t *b) return strcmp(a->owner->name, b->owner->name); } -int subnet_compare_ipv4(subnet_t *a, subnet_t *b) +static int subnet_compare_ipv4(subnet_t *a, subnet_t *b) { int result; @@ -77,7 +77,7 @@ int subnet_compare_ipv4(subnet_t *a, subnet_t *b) return strcmp(a->owner->name, b->owner->name); } -int subnet_compare_ipv6(subnet_t *a, subnet_t *b) +static int subnet_compare_ipv6(subnet_t *a, subnet_t *b) { int result; @@ -94,7 +94,7 @@ int subnet_compare_ipv6(subnet_t *a, subnet_t *b) return strcmp(a->owner->name, b->owner->name); } -int subnet_compare(subnet_t *a, subnet_t *b) +static int subnet_compare(subnet_t *a, subnet_t *b) { int result; diff --git a/src/subnet.h b/src/subnet.h index 30d13ca4..a7acbae0 100644 --- a/src/subnet.h +++ b/src/subnet.h @@ -17,7 +17,7 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - $Id: subnet.h,v 1.1.2.20 2002/09/09 21:25:16 guus Exp $ + $Id: subnet.h,v 1.1.2.21 2003/07/06 23:16:29 guus Exp $ */ #ifndef __TINC_SUBNET_H__ @@ -64,11 +64,11 @@ typedef struct subnet_t { } net; } subnet_t; -extern subnet_t *new_subnet(void); +extern subnet_t *new_subnet(void) __attribute__ ((malloc)); extern void free_subnet(subnet_t *); extern void init_subnets(void); extern void exit_subnets(void); -extern avl_tree_t *new_subnet_tree(void); +extern avl_tree_t *new_subnet_tree(void) __attribute__ ((malloc)); extern void free_subnet_tree(avl_tree_t *); extern void subnet_add(struct node_t *, subnet_t *); extern void subnet_del(struct node_t *, subnet_t *); diff --git a/src/tincd.c b/src/tincd.c index 6d1f4e2d..bcbd54a6 100644 --- a/src/tincd.c +++ b/src/tincd.c @@ -17,7 +17,7 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - $Id: tincd.c,v 1.10.4.70 2003/07/06 22:11:33 guus Exp $ + $Id: tincd.c,v 1.10.4.71 2003/07/06 23:16:29 guus Exp $ */ #include "config.h" @@ -133,7 +133,7 @@ static void usage(int status) exit(status); } -void parse_options(int argc, char **argv, char **envp) +static void parse_options(int argc, char **argv, char **envp) { int r; int option_index = 0; @@ -230,7 +230,7 @@ void parse_options(int argc, char **argv, char **envp) /* This function prettyprints the key generation process */ -void indicator(int a, int b, void *p) +static void indicator(int a, int b, void *p) { switch (a) { case 0: @@ -269,7 +269,7 @@ void indicator(int a, int b, void *p) Generate a public/private RSA keypair, and ask for a file to store them in. */ -int keygen(int bits) +static int keygen(int bits) { RSA *rsa_key; FILE *f; @@ -323,7 +323,7 @@ int keygen(int bits) /* Set all files and paths according to netname */ -void make_names(void) +static void make_names(void) { if(netname) { if(!pidfilename)