Sprinkling the source with static and attributes.

This commit is contained in:
Guus Sliepen 2003-07-06 23:16:29 +00:00
parent 0b9175e998
commit 1401faf608
28 changed files with 159 additions and 160 deletions

View file

@ -29,7 +29,7 @@
library for inclusion into tinc (http://tinc.nl.linux.org/) by library for inclusion into tinc (http://tinc.nl.linux.org/) by
Guus Sliepen <guus@sliepen.eu.org>. Guus Sliepen <guus@sliepen.eu.org>.
$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 <stdio.h> #include <stdio.h>
@ -53,7 +53,9 @@
#endif #endif
#ifndef AVL_DEPTH #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; int r = 1;
@ -89,7 +91,7 @@ int lg(unsigned int u)
/* Internal helper functions */ /* Internal helper functions */
int avl_check_balance(avl_node_t *node) static int avl_check_balance(avl_node_t *node)
{ {
#ifdef AVL_DEPTH #ifdef AVL_DEPTH
int d; int d;
@ -117,7 +119,7 @@ int avl_check_balance(avl_node_t *node)
#endif #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 *child;
avl_node_t *gchild; avl_node_t *gchild;

View file

@ -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 #ifndef _FAKE_GETADDRINFO_H
#define _FAKE_GETADDRINFO_H #define _FAKE_GETADDRINFO_H
@ -22,6 +22,10 @@
# define NI_NUMERICSERV 8 # define NI_NUMERICSERV 8
#endif #endif
#ifndef AI_NUMERICHOST
#define AI_NUMERICHOST 4
#endif
#ifndef HAVE_STRUCT_ADDRINFO #ifndef HAVE_STRUCT_ADDRINFO
struct addrinfo { struct addrinfo {
int ai_flags; /* AI_PASSIVE, AI_CANONNAME */ int ai_flags; /* AI_PASSIVE, AI_CANONNAME */

View file

@ -17,7 +17,7 @@
along with this program; if not, write to the Free Software along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 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__ #ifndef __TINC_LIST_H__
@ -47,7 +47,7 @@ typedef struct list_t {
/* (De)constructors */ /* (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 void list_free(list_t *);
extern list_node_t *list_alloc_node(void); 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_node_t *);

View file

@ -18,9 +18,9 @@ extern char *const xalloc_msg_memory_exhausted;
/* FIXME: describe */ /* FIXME: describe */
extern void (*xalloc_fail_func) (); extern void (*xalloc_fail_func) ();
void *xmalloc PARAMS ((size_t n)); void *xmalloc PARAMS ((size_t n)) __attribute__ ((malloc));
void *xmalloc_and_zero PARAMS ((size_t n)); void *xmalloc_and_zero PARAMS ((size_t n)) __attribute__ ((malloc));
void *xcalloc PARAMS ((size_t n, size_t s)); 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));

View file

@ -19,7 +19,7 @@
along with this program; if not, write to the Free Software along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 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" #include "config.h"
@ -51,7 +51,7 @@ int pingtimeout = 0; /* seconds before timeout */
char *confbase = NULL; /* directory in which all config files are */ char *confbase = NULL; /* directory in which all config files are */
char *netname = NULL; /* name of the vpn network */ 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; 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 given, and buf needs to be expanded, the var pointed to by buflen
will be increased. 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 *newline = NULL;
char *p; char *p;
@ -429,7 +429,7 @@ int read_server_config()
return x; return x;
} }
int isadir(const char *f) static int isadir(const char *f)
{ {
struct stat s; struct stat s;

View file

@ -17,7 +17,7 @@
along with this program; if not, write to the Free Software along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 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__ #ifndef __TINC_CONF_H__
@ -48,7 +48,7 @@ extern char *netname;
extern void init_configuration(avl_tree_t **); extern void init_configuration(avl_tree_t **);
extern void exit_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 free_config(config_t *);
extern void config_add(avl_tree_t *, config_t *); extern void config_add(avl_tree_t *, config_t *);
extern config_t *lookup_config(avl_tree_t *, char *); extern config_t *lookup_config(avl_tree_t *, char *);

View file

@ -17,7 +17,7 @@
along with this program; if not, write to the Free Software along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 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" #include "config.h"
@ -42,7 +42,7 @@
avl_tree_t *connection_tree; /* Meta connections */ avl_tree_t *connection_tree; /* Meta connections */
connection_t *broadcast; 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; return (void *)a - (void *)b;
} }

View file

@ -17,7 +17,7 @@
along with this program; if not, write to the Free Software along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 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__ #ifndef __TINC_CONNECTION_H__
@ -113,7 +113,7 @@ extern connection_t *broadcast;
extern void init_connections(void); extern void init_connections(void);
extern void exit_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 free_connection(connection_t *);
extern void connection_add(connection_t *); extern void connection_add(connection_t *);
extern void connection_del(connection_t *); extern void connection_del(connection_t *);

View file

@ -17,7 +17,7 @@
along with this program; if not, write to the Free Software along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 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" #include "config.h"
@ -42,12 +42,12 @@
avl_tree_t *edge_weight_tree; /* Tree with all edges, sorted on weight */ 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); 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; int result;

View file

@ -17,7 +17,7 @@
along with this program; if not, write to the Free Software along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 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__ #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 init_edges(void);
extern void exit_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 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 free_edge_tree(avl_tree_t *);
extern void edge_add(edge_t *); extern void edge_add(edge_t *);
extern void edge_del(edge_t *); extern void edge_del(edge_t *);

View file

@ -17,7 +17,7 @@
along with this program; if not, write to the Free Software along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 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" #include "config.h"
@ -38,7 +38,7 @@ extern time_t now;
int id; 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) if(a->time > b->time)
return 1; return 1;

View file

@ -17,7 +17,7 @@
along with this program; if not, write to the Free Software along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 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__ #ifndef __TINC_EVENT_H__
@ -26,7 +26,7 @@
#include <time.h> #include <time.h>
#include <avl_tree.h> #include <avl_tree.h>
avl_tree_t *event_tree; extern avl_tree_t *event_tree;
typedef void (*event_handler_t)(void *); typedef void (*event_handler_t)(void *);
@ -39,7 +39,7 @@ typedef struct {
extern void init_events(void); extern void init_events(void);
extern void exit_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 free_event(event_t *);
extern void event_add(event_t *); extern void event_add(event_t *);
extern void event_del(event_t *); extern void event_del(event_t *);

View file

@ -17,12 +17,13 @@
along with this program; if not, write to the Free Software along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 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 <stdio.h> #include <stdio.h>
#include <stdarg.h> #include <stdarg.h>
#include <syslog.h> #include <syslog.h>
#include <unistd.h>
#include "conf.h" #include "conf.h"
#include "logger.h" #include "logger.h"
@ -30,15 +31,13 @@
#include "system.h" #include "system.h"
volatile int debug_level = DEBUG_NOTHING; volatile int debug_level = DEBUG_NOTHING;
int logmode = LOGMODE_STDERR; static int logmode = LOGMODE_STDERR;
pid_t logpid; static pid_t logpid;
extern char *logfilename; extern char *logfilename;
FILE *logfile = NULL; static FILE *logfile = NULL;
const char *logident = NULL; static const char *logident = NULL;
void openlogger(const char *ident, int mode) { void openlogger(const char *ident, int mode) {
char *fname;
logident = ident; logident = ident;
logmode = mode; logmode = mode;
@ -65,7 +64,7 @@ void vlogger(int priority, const char *format, va_list ap) {
fprintf(stderr, "\n"); fprintf(stderr, "\n");
break; break;
case LOGMODE_FILE: 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); vfprintf(logfile, format, ap);
fprintf(logfile, "\n"); fprintf(logfile, "\n");
break; break;

View file

@ -17,7 +17,7 @@
along with this program; if not, write to the Free Software along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 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" #include "config.h"
@ -82,7 +82,7 @@ time_t now = 0;
/* Purge edges and subnets of unreachable nodes. Use carefully. */ /* 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; avl_node_t *nnode, *nnext, *enode, *enext, *snode, *snext;
node_t *n; node_t *n;
@ -124,7 +124,7 @@ void purge(void)
put all file descriptors in an fd_set array put all file descriptors in an fd_set array
While we're at it, purge stuff that needs to be removed. 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; avl_node_t *node, *next;
connection_t *c; 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 end does not reply in time, we consider them dead
and close the connection. and close the connection.
*/ */
void check_dead_connections(void) static void check_dead_connections(void)
{ {
avl_node_t *node, *next; avl_node_t *node, *next;
connection_t *c; connection_t *c;
@ -258,7 +258,7 @@ void check_dead_connections(void)
check all connections to see if anything check all connections to see if anything
happened on their sockets happened on their sockets
*/ */
void check_network_activity(fd_set * f) static void check_network_activity(fd_set * f)
{ {
connection_t *c; connection_t *c;
avl_node_t *node; avl_node_t *node;

View file

@ -17,7 +17,7 @@
along with this program; if not, write to the Free Software along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 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__ #ifndef __TINC_NET_H__
@ -121,9 +121,6 @@ extern int maxtimeout;
extern int seconds_till_retry; extern int seconds_till_retry;
extern int addressfamily; 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 */ #include "connection.h" /* Yes, very strange placement indeed, but otherwise the typedefs get all tangled up */
extern listen_socket_t listen_socket[MAXSOCKETS]; 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_listen_socket(sockaddr_t *);
extern int setup_vpn_in_socket(sockaddr_t *); extern int setup_vpn_in_socket(sockaddr_t *);
extern void send_packet(struct node_t *, vpn_packet_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 receive_tcppacket(struct connection_t *, char *, int);
extern void broadcast_packet(struct node_t *, vpn_packet_t *); extern void broadcast_packet(struct node_t *, vpn_packet_t *);
extern int setup_network_connections(void); extern int setup_network_connections(void);

View file

@ -17,7 +17,7 @@
along with this program; if not, write to the Free Software along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 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" #include "config.h"
@ -82,12 +82,12 @@
int keylifetime = 0; int keylifetime = 0;
int keyexpires = 0; int keyexpires = 0;
EVP_CIPHER_CTX packet_ctx; 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 #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) { if(level == 10) {
lzo_uint lzolen = MAXSIZE; 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; 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) { if(level > 9) {
lzo_uint lzolen = MAXSIZE; 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 */ /* 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 pkt1, pkt2;
vpn_packet_t *pkt[] = { &pkt1, &pkt2, &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); receive_packet(c->node, &outpkt);
} }
void receive_packet(node_t *n, vpn_packet_t *packet) static void send_udppacket(node_t *n, vpn_packet_t *inpkt)
{
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)
{ {
vpn_packet_t pkt1, pkt2; vpn_packet_t pkt1, pkt2;
vpn_packet_t *pkt[] = { &pkt1, &pkt2, &pkt1, &pkt2 }; vpn_packet_t *pkt[] = { &pkt1, &pkt2, &pkt1, &pkt2 };

View file

@ -17,7 +17,7 @@
along with this program; if not, write to the Free Software along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 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" #include "config.h"
@ -40,12 +40,12 @@ avl_tree_t *node_udp_tree; /* Known nodes, sorted by address and port */
node_t *myself; 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); 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; int result;

View file

@ -17,7 +17,7 @@
along with this program; if not, write to the Free Software along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 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__ #ifndef __TINC_NODE_H__
@ -83,7 +83,7 @@ extern avl_tree_t *node_udp_tree;
extern void init_nodes(void); extern void init_nodes(void);
extern void exit_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 free_node(node_t *);
extern void node_add(node_t *); extern void node_add(node_t *);
extern void node_del(node_t *); extern void node_del(node_t *);

View file

@ -17,7 +17,7 @@
along with this program; if not, write to the Free Software along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 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" #include "config.h"
@ -65,7 +65,7 @@ extern int sighup;
extern int sigalrm; extern int sigalrm;
extern int do_purge; 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); logger(DEBUG_ALWAYS, LOG_ERR, _("Memory exhausted (couldn't allocate %d bytes), exitting."), size);
cp_trace(); cp_trace();
@ -75,7 +75,7 @@ void memory_full(int size)
/* Some functions the less gifted operating systems might lack... */ /* Some functions the less gifted operating systems might lack... */
#ifndef HAVE_FCLOSEALL #ifndef HAVE_FCLOSEALL
int fcloseall(void) static int fcloseall(void)
{ {
fflush(stdin); fflush(stdin);
fflush(stdout); 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 check for an existing tinc for this net, and write pid to pidfile
*/ */
int write_pidfile(void) static int write_pidfile(void)
{ {
int pid; int pid;
@ -213,9 +213,9 @@ int detach(void)
/* /*
Execute the program name, with sane environment. 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)); __attribute__ ((noreturn));
void _execute_script(const char *scriptname, char **envp) static void _execute_script(const char *scriptname, char **envp)
{ {
cp(); cp();
@ -304,20 +304,20 @@ int execute_script(const char *name, char **envp)
Signal handlers. Signal handlers.
*/ */
RETSIGTYPE sigterm_handler(int a) static RETSIGTYPE sigterm_handler(int a)
{ {
logger(DEBUG_ALWAYS, LOG_NOTICE, _("Got TERM signal")); logger(DEBUG_ALWAYS, LOG_NOTICE, _("Got TERM signal"));
cleanup_and_exit(0); cleanup_and_exit(0);
} }
RETSIGTYPE sigquit_handler(int a) static RETSIGTYPE sigquit_handler(int a)
{ {
logger(DEBUG_ALWAYS, LOG_NOTICE, _("Got QUIT signal")); logger(DEBUG_ALWAYS, LOG_NOTICE, _("Got QUIT signal"));
cleanup_and_exit(0); 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, logger(DEBUG_ALWAYS, LOG_ERR, _("Got another fatal signal %d (%s): not restarting."), a,
strsignal(a)); strsignal(a));
@ -325,7 +325,7 @@ RETSIGTYPE fatal_signal_square(int a)
exit(1); exit(1);
} }
RETSIGTYPE fatal_signal_handler(int a) static RETSIGTYPE fatal_signal_handler(int a)
{ {
struct sigaction act; struct sigaction act;
logger(DEBUG_ALWAYS, LOG_ERR, _("Got fatal signal %d (%s)"), a, strsignal(a)); 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")); logger(DEBUG_ALWAYS, LOG_NOTICE, _("Got HUP signal"));
sighup = 1; sighup = 1;
} }
RETSIGTYPE sigint_handler(int a) static RETSIGTYPE sigint_handler(int a)
{ {
if(saved_debug_level != -1) { if(saved_debug_level != -1) {
logger(DEBUG_ALWAYS, LOG_NOTICE, _("Reverting to old debug level (%d)"), 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")); logger(DEBUG_ALWAYS, LOG_NOTICE, _("Got ALRM signal"));
sigalrm = 1; sigalrm = 1;
} }
RETSIGTYPE sigusr1_handler(int a) static RETSIGTYPE sigusr1_handler(int a)
{ {
dump_connections(); dump_connections();
} }
RETSIGTYPE sigusr2_handler(int a) static RETSIGTYPE sigusr2_handler(int a)
{ {
dump_device_stats(); dump_device_stats();
dump_nodes(); dump_nodes();
@ -390,24 +390,24 @@ RETSIGTYPE sigusr2_handler(int a)
dump_subnets(); dump_subnets();
} }
RETSIGTYPE sigwinch_handler(int a) static RETSIGTYPE sigwinch_handler(int a)
{ {
extern int do_purge; extern int do_purge;
do_purge = 1; 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)); logger(DEBUG_ALWAYS, LOG_WARNING, _("Got unexpected signal %d (%s)"), a, strsignal(a));
cp_trace(); 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)); logger(DEBUG_SCARY_THINGS, LOG_DEBUG, _("Ignored signal %d (%s)"), a, strsignal(a));
} }
struct { static struct {
int signal; int signal;
void (*handler)(int); void (*handler)(int);
} sighandlers[] = { } sighandlers[] = {

View file

@ -17,7 +17,7 @@
along with this program; if not, write to the Free Software along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 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__ #ifndef __TINC_PROCESS_H__
@ -31,6 +31,6 @@ extern void setup_signals(void);
extern int execute_script(const char *, char **); extern int execute_script(const char *, char **);
extern int detach(void); extern int detach(void);
extern int kill_other(int); extern int kill_other(int);
extern void cleanup_and_exit(int); extern void cleanup_and_exit(int) __attribute__ ((noreturn));
#endif /* __TINC_PROCESS_H__ */ #endif /* __TINC_PROCESS_H__ */

View file

@ -17,7 +17,7 @@
along with this program; if not, write to the Free Software along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 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" #include "config.h"
@ -41,7 +41,28 @@
#include "system.h" #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) int check_id(char *id)
{ {
@ -170,12 +191,12 @@ int receive_request(connection_t *c)
return 0; 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); return strcmp(a->request, b->request);
} }
void free_past_request(past_request_t *r) static void free_past_request(past_request_t *r)
{ {
cp(); cp();
@ -241,24 +262,3 @@ void age_past_requests(void)
logger(DEBUG_SCARY_THINGS, LOG_DEBUG, _("Aging past requests: deleted %d, left %d\n"), logger(DEBUG_SCARY_THINGS, LOG_DEBUG, _("Aging past requests: deleted %d, left %d\n"),
deleted, left); 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",
};

View file

@ -17,7 +17,7 @@
along with this program; if not, write to the Free Software along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 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__ #ifndef __TINC_PROTOCOL_H__
@ -93,8 +93,6 @@ extern int send_tcppacket(connection_t *, vpn_packet_t *);
/* Request handlers */ /* Request handlers */
extern int (*request_handlers[])(connection_t *);
extern int id_h(connection_t *); extern int id_h(connection_t *);
extern int metakey_h(connection_t *); extern int metakey_h(connection_t *);
extern int challenge_h(connection_t *); extern int challenge_h(connection_t *);

View file

@ -17,7 +17,7 @@
along with this program; if not, write to the Free Software along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 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" #include "config.h"
@ -481,7 +481,7 @@ int send_ack(connection_t *c)
return x; return x;
} }
void send_everything(connection_t *c) static void send_everything(connection_t *c)
{ {
avl_node_t *node, *node2; avl_node_t *node, *node2;
node_t *n; node_t *n;

View file

@ -17,7 +17,7 @@
along with this program; if not, write to the Free Software along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 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" #include "config.h"
@ -40,6 +40,18 @@
#include "system.h" #include "system.h"
/* Status strings */
static char (*status_text[]) = {
"Warning",
};
/* Error strings */
static char (*error_text[]) = {
"Error",
};
/* Status and error notification routines */ /* Status and error notification routines */
int send_status(connection_t *c, int statusno, char *statusstring) int send_status(connection_t *c, int statusno, char *statusstring)
@ -192,15 +204,3 @@ int tcppacket_h(connection_t *c)
return 0; return 0;
} }
/* Status strings */
char (*status_text[]) = {
"Warning",
};
/* Error strings */
char (*error_text[]) = {
"Error",
};

View file

@ -17,7 +17,7 @@
along with this program; if not, write to the Free Software along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 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" #include "config.h"
@ -84,11 +84,11 @@ int routing_mode = RMODE_ROUTER;
int priorityinheritance = 0; int priorityinheritance = 0;
int macexpire = 600; int macexpire = 600;
int overwrite_mac = 0; 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 */ /* 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; uint16_t *p = data;
uint32_t checksum = prevsum ^ 0xFFFF; uint32_t checksum = prevsum ^ 0xFFFF;
@ -107,7 +107,7 @@ uint16_t inet_checksum(void *data, int len, uint16_t prevsum)
return ~checksum; return ~checksum;
} }
int ratelimit(void) { static int ratelimit(void) {
static time_t lasttime = 0; static time_t lasttime = 0;
if(lasttime == now) if(lasttime == now)
@ -117,7 +117,7 @@ int ratelimit(void) {
return 0; return 0;
} }
void learn_mac(mac_t *address) static void learn_mac(mac_t *address)
{ {
subnet_t *subnet; subnet_t *subnet;
avl_node_t *node; 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; subnet_t *subnet;
@ -201,7 +201,7 @@ node_t *route_mac(vpn_packet_t *packet)
/* RFC 792 */ /* 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 ip *hdr;
struct icmp *icmp; struct icmp *icmp;
@ -260,7 +260,7 @@ void route_ipv4_unreachable(vpn_packet_t *packet, uint8_t code)
write_packet(packet); write_packet(packet);
} }
node_t *route_ipv4(vpn_packet_t *packet) static node_t *route_ipv4(vpn_packet_t *packet)
{ {
subnet_t *subnet; subnet_t *subnet;
@ -290,7 +290,7 @@ node_t *route_ipv4(vpn_packet_t *packet)
/* RFC 2463 */ /* 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 ip6_hdr *hdr;
struct icmp6_hdr *icmp; struct icmp6_hdr *icmp;
@ -358,7 +358,7 @@ void route_ipv6_unreachable(vpn_packet_t *packet, uint8_t code)
#endif #endif
node_t *route_ipv6(vpn_packet_t *packet) static node_t *route_ipv6(vpn_packet_t *packet)
{ {
subnet_t *subnet; subnet_t *subnet;
@ -395,7 +395,7 @@ node_t *route_ipv6(vpn_packet_t *packet)
/* RFC 2461 */ /* RFC 2461 */
void route_neighborsol(vpn_packet_t *packet) static void route_neighborsol(vpn_packet_t *packet)
{ {
struct ip6_hdr *hdr; struct ip6_hdr *hdr;
struct nd_neighbor_solicit *ns; struct nd_neighbor_solicit *ns;
@ -508,7 +508,7 @@ void route_neighborsol(vpn_packet_t *packet)
/* RFC 826 */ /* RFC 826 */
void route_arp(vpn_packet_t *packet) static void route_arp(vpn_packet_t *packet)
{ {
struct ether_arp *arp; struct ether_arp *arp;
subnet_t *subnet; subnet_t *subnet;

View file

@ -17,7 +17,7 @@
along with this program; if not, write to the Free Software along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 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" #include "config.h"
@ -48,7 +48,7 @@ avl_tree_t *subnet_tree;
/* Subnet comparison */ /* 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; int result;
@ -60,7 +60,7 @@ int subnet_compare_mac(subnet_t *a, subnet_t *b)
return strcmp(a->owner->name, b->owner->name); 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; int result;
@ -77,7 +77,7 @@ int subnet_compare_ipv4(subnet_t *a, subnet_t *b)
return strcmp(a->owner->name, b->owner->name); 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; int result;
@ -94,7 +94,7 @@ int subnet_compare_ipv6(subnet_t *a, subnet_t *b)
return strcmp(a->owner->name, b->owner->name); 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; int result;

View file

@ -17,7 +17,7 @@
along with this program; if not, write to the Free Software along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 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__ #ifndef __TINC_SUBNET_H__
@ -64,11 +64,11 @@ typedef struct subnet_t {
} net; } net;
} subnet_t; } subnet_t;
extern subnet_t *new_subnet(void); extern subnet_t *new_subnet(void) __attribute__ ((malloc));
extern void free_subnet(subnet_t *); extern void free_subnet(subnet_t *);
extern void init_subnets(void); extern void init_subnets(void);
extern void exit_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 free_subnet_tree(avl_tree_t *);
extern void subnet_add(struct node_t *, subnet_t *); extern void subnet_add(struct node_t *, subnet_t *);
extern void subnet_del(struct node_t *, subnet_t *); extern void subnet_del(struct node_t *, subnet_t *);

View file

@ -17,7 +17,7 @@
along with this program; if not, write to the Free Software along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 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" #include "config.h"
@ -133,7 +133,7 @@ static void usage(int status)
exit(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 r;
int option_index = 0; int option_index = 0;
@ -230,7 +230,7 @@ void parse_options(int argc, char **argv, char **envp)
/* This function prettyprints the key generation process */ /* 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) { switch (a) {
case 0: 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 Generate a public/private RSA keypair, and ask for a file to store
them in. them in.
*/ */
int keygen(int bits) static int keygen(int bits)
{ {
RSA *rsa_key; RSA *rsa_key;
FILE *f; FILE *f;
@ -323,7 +323,7 @@ int keygen(int bits)
/* /*
Set all files and paths according to netname Set all files and paths according to netname
*/ */
void make_names(void) static void make_names(void)
{ {
if(netname) { if(netname) {
if(!pidfilename) if(!pidfilename)