library for inclusion into tinc (http://tinc.nl.linux.org/) by
Guus Sliepen <guus@sliepen.eu.org>.
- $Id: avl_tree.c,v 1.1.2.10 2002/09/09 21:49:16 guus Exp $
+ $Id: avl_tree.c,v 1.1.2.11 2002/09/09 22:32:24 guus Exp $
*/
#include <stdio.h>
/* Internal helper functions */
-int avl_check_balance(avl_node_t * node)
+int avl_check_balance(avl_node_t *node)
{
#ifdef AVL_DEPTH
int d;
#endif
}
-void avl_rebalance(avl_tree_t * tree, avl_node_t * node)
+void avl_rebalance(avl_tree_t *tree, avl_node_t *node)
{
avl_node_t *child;
avl_node_t *gchild;
return tree;
}
-void avl_free_tree(avl_tree_t * tree)
+void avl_free_tree(avl_tree_t *tree)
{
free(tree);
}
return (avl_node_t *)xmalloc_and_zero(sizeof(avl_node_t));
}
-void avl_free_node(avl_tree_t * tree, avl_node_t * node)
+void avl_free_node(avl_tree_t *tree, avl_node_t *node)
{
if(node->data && tree->delete)
tree->delete(node->data);
/* Searching */
-void *avl_search(const avl_tree_t * tree, const void *data)
+void *avl_search(const avl_tree_t *tree, const void *data)
{
avl_node_t *node;
return node ? node->data : NULL;
}
-void *avl_search_closest(const avl_tree_t * tree, const void *data, int *result)
+void *avl_search_closest(const avl_tree_t *tree, const void *data, int *result)
{
avl_node_t *node;
return node ? node->data : NULL;
}
-void *avl_search_closest_smaller(const avl_tree_t * tree, const void *data)
+void *avl_search_closest_smaller(const avl_tree_t *tree, const void *data)
{
avl_node_t *node;
return node ? node->data : NULL;
}
-void *avl_search_closest_greater(const avl_tree_t * tree, const void *data)
+void *avl_search_closest_greater(const avl_tree_t *tree, const void *data)
{
avl_node_t *node;
return node ? node->data : NULL;
}
-avl_node_t *avl_search_node(const avl_tree_t * tree, const void *data)
+avl_node_t *avl_search_node(const avl_tree_t *tree, const void *data)
{
avl_node_t *node;
int result;
return result ? NULL : node;
}
-avl_node_t *avl_search_closest_node(const avl_tree_t * tree, const void *data,
+avl_node_t *avl_search_closest_node(const avl_tree_t *tree, const void *data,
int *result)
{
avl_node_t *node;
return node;
}
-avl_node_t *avl_search_closest_smaller_node(const avl_tree_t * tree,
+avl_node_t *avl_search_closest_smaller_node(const avl_tree_t *tree,
const void *data)
{
avl_node_t *node;
return node;
}
-avl_node_t *avl_search_closest_greater_node(const avl_tree_t * tree,
+avl_node_t *avl_search_closest_greater_node(const avl_tree_t *tree,
const void *data)
{
avl_node_t *node;
/* Insertion and deletion */
-avl_node_t *avl_insert(avl_tree_t * tree, void *data)
+avl_node_t *avl_insert(avl_tree_t *tree, void *data)
{
avl_node_t *closest, *new;
int result;
return new;
}
-avl_node_t *avl_insert_node(avl_tree_t * tree, avl_node_t * node)
+avl_node_t *avl_insert_node(avl_tree_t *tree, avl_node_t *node)
{
avl_node_t *closest;
int result;
return node;
}
-void avl_insert_top(avl_tree_t * tree, avl_node_t * node)
+void avl_insert_top(avl_tree_t *tree, avl_node_t *node)
{
node->prev = node->next = node->parent = NULL;
tree->head = tree->tail = tree->root = node;
}
-void avl_insert_before(avl_tree_t * tree, avl_node_t * before,
- avl_node_t * node)
+void avl_insert_before(avl_tree_t *tree, avl_node_t *before,
+ avl_node_t *node)
{
if(!before)
return tree->tail ? avl_insert_after(tree, tree->tail, node) : avl_insert_top(tree, node);
avl_rebalance(tree, before->parent);
}
-void avl_insert_after(avl_tree_t * tree, avl_node_t * after, avl_node_t * node)
+void avl_insert_after(avl_tree_t *tree, avl_node_t *after, avl_node_t *node)
{
if(!after)
return tree->head ? avl_insert_before(tree, tree->head,
avl_rebalance(tree, after->parent);
}
-avl_node_t *avl_unlink(avl_tree_t * tree, void *data)
+avl_node_t *avl_unlink(avl_tree_t *tree, void *data)
{
avl_node_t *node;
return node;
}
-void avl_unlink_node(avl_tree_t * tree, avl_node_t * node)
+void avl_unlink_node(avl_tree_t *tree, avl_node_t *node)
{
avl_node_t *parent;
avl_node_t **superparent;
#endif
}
-void avl_delete_node(avl_tree_t * tree, avl_node_t * node)
+void avl_delete_node(avl_tree_t *tree, avl_node_t *node)
{
avl_unlink_node(tree, node);
avl_free_node(tree, node);
}
-void avl_delete(avl_tree_t * tree, void *data)
+void avl_delete(avl_tree_t *tree, void *data)
{
avl_node_t *node;
/* Fast tree cleanup */
-void avl_delete_tree(avl_tree_t * tree)
+void avl_delete_tree(avl_tree_t *tree)
{
avl_node_t *node, *next;
/* Tree walking */
-void avl_foreach(avl_tree_t * tree, avl_action_t action)
+void avl_foreach(avl_tree_t *tree, avl_action_t action)
{
avl_node_t *node, *next;
}
}
-void avl_foreach_node(avl_tree_t * tree, avl_action_t action)
+void avl_foreach_node(avl_tree_t *tree, avl_action_t action)
{
avl_node_t *node, *next;
/* Indexing */
#ifdef AVL_COUNT
-unsigned int avl_count(avl_tree_t * tree)
+unsigned int avl_count(avl_tree_t *tree)
{
return AVL_NODE_COUNT(tree->root);
}
-avl_node_t *avl_get_node(const avl_tree_t * tree, unsigned int index)
+avl_node_t *avl_get_node(const avl_tree_t *tree, unsigned int index)
{
avl_node_t *node;
unsigned int c;
return NULL;
}
-unsigned int avl_index(const avl_node_t * node)
+unsigned int avl_index(const avl_node_t *node)
{
avl_node_t *next;
unsigned int index;
}
#endif
#ifdef AVL_DEPTH
-unsigned int avl_depth(avl_tree_t * tree)
+unsigned int avl_depth(avl_tree_t *tree)
{
return AVL_NODE_DEPTH(tree->root);
}
library for inclusion into tinc (http://tinc.nl.linux.org/) by
Guus Sliepen <guus@sliepen.eu.org>.
- $Id: avl_tree.h,v 1.1.2.6 2002/09/09 21:49:16 guus Exp $
+ $Id: avl_tree.h,v 1.1.2.7 2002/09/09 22:32:27 guus Exp $
*/
} avl_node_t;
-typedef int (*avl_compare_t) (const void *, const void *);
-typedef void (*avl_action_t) (const void *);
-typedef void (*avl_action_node_t) (const avl_node_t *);
+typedef int (*avl_compare_t)(const void *, const void *);
+typedef void (*avl_action_t)(const void *);
+typedef void (*avl_action_node_t)(const avl_node_t *);
typedef struct avl_tree_t {
extern void avl_free_tree(avl_tree_t *);
extern avl_node_t *avl_alloc_node(void);
-extern void avl_free_node(avl_tree_t * tree, avl_node_t *);
+extern void avl_free_node(avl_tree_t *tree, avl_node_t *);
/* Insertion and deletion */
extern void avl_insert_after(avl_tree_t *, avl_node_t *, avl_node_t *);
extern avl_node_t *avl_unlink(avl_tree_t *, void *);
-extern void avl_unlink_node(avl_tree_t * tree, avl_node_t *);
+extern void avl_unlink_node(avl_tree_t *tree, avl_node_t *);
extern void avl_delete(avl_tree_t *, void *);
extern void avl_delete_node(avl_tree_t *, avl_node_t *);
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- $Id: list.c,v 1.1.2.12 2002/09/09 21:49:16 guus Exp $
+ $Id: list.c,v 1.1.2.13 2002/09/09 22:32:27 guus Exp $
*/
#include "config.h"
return list;
}
-void list_free(list_t * list)
+void list_free(list_t *list)
{
free(list);
}
return (list_node_t *)xmalloc_and_zero(sizeof(list_node_t));
}
-void list_free_node(list_t * list, list_node_t * node)
+void list_free_node(list_t *list, list_node_t *node)
{
if(node->data && list->delete)
list->delete(node->data);
/* Insertion and deletion */
-list_node_t *list_insert_head(list_t * list, void *data)
+list_node_t *list_insert_head(list_t *list, void *data)
{
list_node_t *node;
return node;
}
-list_node_t *list_insert_tail(list_t * list, void *data)
+list_node_t *list_insert_tail(list_t *list, void *data)
{
list_node_t *node;
return node;
}
-void list_unlink_node(list_t * list, list_node_t * node)
+void list_unlink_node(list_t *list, list_node_t *node)
{
if(node->prev)
node->prev->next = node->next;
list->count--;
}
-void list_delete_node(list_t * list, list_node_t * node)
+void list_delete_node(list_t *list, list_node_t *node)
{
list_unlink_node(list, node);
list_free_node(list, node);
}
-void list_delete_head(list_t * list)
+void list_delete_head(list_t *list)
{
list_delete_node(list, list->head);
}
-void list_delete_tail(list_t * list)
+void list_delete_tail(list_t *list)
{
list_delete_node(list, list->tail);
}
/* Head/tail lookup */
-void *list_get_head(list_t * list)
+void *list_get_head(list_t *list)
{
if(list->head)
return list->head->data;
return NULL;
}
-void *list_get_tail(list_t * list)
+void *list_get_tail(list_t *list)
{
if(list->tail)
return list->tail->data;
/* Fast list deletion */
-void list_delete_list(list_t * list)
+void list_delete_list(list_t *list)
{
list_node_t *node, *next;
/* Traversing */
-void list_foreach_node(list_t * list, list_action_node_t action)
+void list_foreach_node(list_t *list, list_action_node_t action)
{
list_node_t *node, *next;
}
}
-void list_foreach(list_t * list, list_action_t action)
+void list_foreach(list_t *list, list_action_t action)
{
list_node_t *node, *next;
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.7 2002/09/09 21:49:16 guus Exp $
+ $Id: list.h,v 1.1.2.8 2002/09/09 22:32:27 guus Exp $
*/
#ifndef __TINC_LIST_H__
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 *);
+typedef void (*list_action_node_t)(const list_node_t *);
typedef struct list_t {
list_node_t *head;
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.59 2002/09/09 21:24:25 guus Exp $
+ $Id: conf.c,v 1.9.4.60 2002/09/09 22:32:30 guus Exp $
*/
#include "config.h"
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)
+int config_compare(config_t *a, config_t *b)
{
int result;
return (config_t *) xmalloc_and_zero(sizeof(config_t));
}
-void free_config(config_t * cfg)
+void free_config(config_t *cfg)
{
cp();
free(cfg);
}
-void config_add(avl_tree_t * config_tree, config_t * cfg)
+void config_add(avl_tree_t *config_tree, config_t *cfg)
{
cp();
avl_insert(config_tree, cfg);
}
-config_t *lookup_config(avl_tree_t * config_tree, char *variable)
+config_t *lookup_config(avl_tree_t *config_tree, char *variable)
{
config_t cfg, *found;
return found;
}
-config_t *lookup_config_next(avl_tree_t * config_tree, config_t * cfg)
+config_t *lookup_config_next(avl_tree_t *config_tree, config_t *cfg)
{
avl_node_t *node;
config_t *found;
return NULL;
}
-int get_config_bool(config_t * cfg, int *result)
+int get_config_bool(config_t *cfg, int *result)
{
cp();
return 0;
}
-int get_config_int(config_t * cfg, int *result)
+int get_config_int(config_t *cfg, int *result)
{
cp();
return 0;
}
-int get_config_string(config_t * cfg, char **result)
+int get_config_string(config_t *cfg, char **result)
{
cp();
return 1;
}
-int get_config_address(config_t * cfg, struct addrinfo **result)
+int get_config_address(config_t *cfg, struct addrinfo **result)
{
struct addrinfo *ai;
return 0;
}
-int get_config_port(config_t * cfg, port_t * result)
+int get_config_port(config_t *cfg, port_t *result)
{
cp();
return 0;
}
-int get_config_subnet(config_t * cfg, subnet_t ** result)
+int get_config_subnet(config_t *cfg, subnet_t ** result)
{
subnet_t *subnet;
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)
+char *readline(FILE * fp, char **buf, size_t *buflen)
{
char *newline = NULL;
char *p;
Parse a configuration file and put the results in the configuration tree
starting at *base.
*/
-int read_config_file(avl_tree_t * config_tree, const char *fname)
+int read_config_file(avl_tree_t *config_tree, const char *fname)
{
int err = -2; /* Parse error */
FILE *fp;
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.33 2002/09/09 21:24:31 guus Exp $
+ $Id: connection.c,v 1.1.2.34 2002/09/09 22:32:30 guus Exp $
*/
#include "config.h"
avl_tree_t *connection_tree; /* Meta connections */
connection_t *broadcast;
-int connection_compare(connection_t * a, connection_t * b)
+int connection_compare(connection_t *a, connection_t *b)
{
return a - b;
}
return c;
}
-void free_connection(connection_t * c)
+void free_connection(connection_t *c)
{
cp();
free(c);
}
-void connection_add(connection_t * c)
+void connection_add(connection_t *c)
{
cp();
avl_insert(connection_tree, c);
}
-void connection_del(connection_t * c)
+void connection_del(connection_t *c)
{
cp();
syslog(LOG_DEBUG, _("End of connections."));
}
-int read_connection_config(connection_t * c)
+int read_connection_config(connection_t *c)
{
char *fname;
int x;
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- $Id: device.c,v 1.1.2.2 2002/09/09 21:25:18 guus Exp $
+ $Id: device.c,v 1.1.2.3 2002/09/09 22:33:21 guus Exp $
*/
#include "config.h"
cp close(device_fd);
}
-int read_packet(vpn_packet_t * packet)
+int read_packet(vpn_packet_t *packet)
{
int lenin;
cp if((lenin = read(device_fd, packet->data, MTU)) <= 0) {
return 0;
cp}
-int write_packet(vpn_packet_t * packet)
+int write_packet(vpn_packet_t *packet)
{
cp if(debug_lvl >= DEBUG_TRAFFIC)
syslog(LOG_DEBUG, _("Writing packet of %d bytes to %s"),
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- $Id: device.c,v 1.1.2.3 2002/09/09 21:25:19 guus Exp $
+ $Id: device.c,v 1.1.2.4 2002/09/09 22:33:23 guus Exp $
*/
#include "config.h"
read, encrypt and send data that is
available through the ethertap device
*/
-int read_packet(vpn_packet_t * packet)
+int read_packet(vpn_packet_t *packet)
{
int lenin;
cp if((lenin = read(device_fd, packet->data + 14, MTU - 14)) <= 0) {
return 0;
cp}
-int write_packet(vpn_packet_t * packet)
+int write_packet(vpn_packet_t *packet)
{
cp if(debug_lvl >= DEBUG_TRAFFIC)
syslog(LOG_DEBUG, _("Writing packet of %d bytes to %s"),
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.16 2002/09/09 21:24:31 guus Exp $
+ $Id: edge.c,v 1.1.2.17 2002/09/09 22:32:30 guus Exp $
*/
#include "config.h"
avl_tree_t *edge_weight_tree; /* Tree with all edges, sorted on weight */
-int edge_compare(edge_t * a, edge_t * b)
+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)
+int edge_weight_compare(edge_t *a, edge_t *b)
{
int result;
return avl_alloc_tree((avl_compare_t) edge_compare, NULL);
}
-void free_edge_tree(avl_tree_t * edge_tree)
+void free_edge_tree(avl_tree_t *edge_tree)
{
cp();
return (edge_t *) xmalloc_and_zero(sizeof(edge_t));
}
-void free_edge(edge_t * e)
+void free_edge(edge_t *e)
{
cp();
free(e);
}
-void edge_add(edge_t * e)
+void edge_add(edge_t *e)
{
cp();
e->reverse->reverse = e;
}
-void edge_del(edge_t * e)
+void edge_del(edge_t *e)
{
cp();
avl_delete(edge_weight_tree, e);
}
-edge_t *lookup_edge(node_t * from, node_t * to)
+edge_t *lookup_edge(node_t *from, node_t *to)
{
edge_t v;
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.5 2002/09/09 21:24:31 guus Exp $
+ $Id: event.c,v 1.1.4.6 2002/09/09 22:32:30 guus Exp $
*/
#include "config.h"
int id;
-int event_compare(event_t * a, event_t * b)
+int event_compare(event_t *a, event_t *b)
{
if(a->time > b->time)
return 1;
return (event_t *) xmalloc_and_zero(sizeof(event_t));
}
-void free_event(event_t * event)
+void free_event(event_t *event)
{
cp();
free(event);
}
-void event_add(event_t * event)
+void event_add(event_t *event)
{
cp();
avl_insert(event_tree, event);
}
-void event_del(event_t * event)
+void event_del(event_t *event)
{
cp();
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.3 2002/09/09 21:24:34 guus Exp $
+ $Id: event.h,v 1.1.4.4 2002/09/09 22:32:36 guus Exp $
*/
#ifndef __TINC_EVENT_H__
avl_tree_t *event_tree;
-typedef void (*event_handler_t) (void *);
+typedef void (*event_handler_t)(void *);
typedef struct {
time_t time;
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- $Id: device.c,v 1.1.2.6 2002/09/09 21:25:19 guus Exp $
+ $Id: device.c,v 1.1.2.7 2002/09/09 22:33:23 guus Exp $
*/
#include "config.h"
read, encrypt and send data that is
available through the ethertap device
*/
-int read_packet(vpn_packet_t * packet)
+int read_packet(vpn_packet_t *packet)
{
int lenin;
cp if((lenin = read(device_fd, packet->data, MTU)) <= 0) {
return 0;
cp}
-int write_packet(vpn_packet_t * packet)
+int write_packet(vpn_packet_t *packet)
{
cp if(debug_lvl >= DEBUG_TRAFFIC)
syslog(LOG_DEBUG, _("Writing packet of %d bytes to %s"),
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- $Id: device.c,v 1.1.2.11 2002/09/09 21:25:23 guus Exp $
+ $Id: device.c,v 1.1.2.12 2002/09/09 22:33:24 guus Exp $
*/
#include "config.h"
{
struct ifreq ifr;
- cp if(!get_config_string(lookup_config(config_tree, "Device"), &device))
+ cp();
+
+ if(!get_config_string(lookup_config(config_tree, "Device"), &device))
device = DEFAULT_DEVICE;
if(!get_config_string(lookup_config(config_tree, "Interface"), &interface))
#else
interface = rindex(device, '/') ? rindex(device, '/') + 1 : device;
#endif
- cp device_fd = open(device, O_RDWR | O_NONBLOCK);
+ device_fd = open(device, O_RDWR | O_NONBLOCK);
if(device_fd < 0) {
syslog(LOG_ERR, _("Could not open %s: %s"), device, strerror(errno));
return -1;
}
- cp
- /* Set default MAC address for ethertap devices */
- mymac.type = SUBNET_MAC;
+
+ /* Set default MAC address for ethertap devices */
+ mymac.type = SUBNET_MAC;
mymac.net.mac.address.x[0] = 0xfe;
mymac.net.mac.address.x[1] = 0xfd;
mymac.net.mac.address.x[2] = 0x00;
/* Ok now check if this is an old ethertap or a new tun/tap thingie */
memset(&ifr, 0, sizeof(ifr));
- cp ifr.ifr_flags = IFF_TAP | IFF_NO_PI;
+ ifr.ifr_flags = IFF_TAP | IFF_NO_PI;
+
if(interface)
strncpy(ifr.ifr_name, interface, IFNAMSIZ);
- cp if(!ioctl(device_fd, TUNSETIFF, (void *) &ifr)) {
+
+ if(!ioctl(device_fd, TUNSETIFF, (void *) &ifr)) {
device_info = _("Linux tun/tap device");
device_type = DEVICE_TYPE_TUNTAP;
strncpy(ifrname, ifr.ifr_name, IFNAMSIZ);
}
syslog(LOG_INFO, _("%s is a %s"), device, device_info);
- cp return 0;
+
+ return 0;
}
void close_device(void)
{
- cp close(device_fd);
+ cp();
+
+ close(device_fd);
}
/*
read, encrypt and send data that is
available through the ethertap device
*/
-int read_packet(vpn_packet_t * packet)
+int read_packet(vpn_packet_t *packet)
{
int lenin;
- cp if(device_type == DEVICE_TYPE_TUNTAP) {
+
+ cp();
+
+ if(device_type == DEVICE_TYPE_TUNTAP) {
lenin = read(device_fd, packet->data, MTU);
if(lenin <= 0) {
}
return 0;
-cp}
+}
-int write_packet(vpn_packet_t * packet)
+int write_packet(vpn_packet_t *packet)
{
- cp if(debug_lvl >= DEBUG_TRAFFIC)
+ cp();
+
+ if(debug_lvl >= DEBUG_TRAFFIC)
syslog(LOG_DEBUG, _("Writing packet of %d bytes to %s"),
packet->len, device_info);
return -1;
}
} else { /* ethertap */
+ *(short int *)(packet->data - 2) = packet->len;
- *(short int *) (packet->data - 2) = packet->len;
if(write(device_fd, packet->data - 2, packet->len + 2) < 0) {
syslog(LOG_ERR, _("Can't write to %s %s: %s"), device_info, device,
strerror(errno));
}
device_total_out += packet->len;
- cp return 0;
+
+ return 0;
}
void dump_device_stats(void)
{
- cp syslog(LOG_DEBUG, _("Statistics for %s %s:"), device_info, device);
+ cp();
+
+ syslog(LOG_DEBUG, _("Statistics for %s %s:"), device_info, device);
syslog(LOG_DEBUG, _(" total bytes in: %10d"), device_total_in);
syslog(LOG_DEBUG, _(" total bytes out: %10d"), device_total_out);
-cp}
+}
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- $Id: meta.c,v 1.1.2.29 2002/09/09 21:24:34 guus Exp $
+ $Id: meta.c,v 1.1.2.30 2002/09/09 22:32:39 guus Exp $
*/
#include "config.h"
#include "system.h"
#include "protocol.h"
-int send_meta(connection_t * c, char *buffer, int length)
+int send_meta(connection_t *c, char *buffer, int length)
{
char *bufp;
int outlen;
return 0;
}
-void broadcast_meta(connection_t * from, char *buffer, int length)
+void broadcast_meta(connection_t *from, char *buffer, int length)
{
avl_node_t *node;
connection_t *c;
}
}
-int receive_meta(connection_t * c)
+int receive_meta(connection_t *c)
{
int x, l = sizeof(x);
int oldlen, i;
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.180 2002/09/09 21:24:34 guus Exp $
+ $Id: net.c,v 1.35.4.181 2002/09/09 22:32:39 guus Exp $
*/
#include "config.h"
- Check if we need to retry making an outgoing connection
- Deactivate the host
*/
-void terminate_connection(connection_t * c, int report)
+void terminate_connection(connection_t *c, int report)
{
cp();
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.22 2002/09/09 21:24:41 guus Exp $
+ $Id: net_packet.c,v 1.1.2.23 2002/09/09 22:32:44 guus Exp $
*/
#include "config.h"
/* VPN packet I/O */
-void receive_udppacket(node_t * n, vpn_packet_t * inpkt)
+void receive_udppacket(node_t *n, vpn_packet_t *inpkt)
{
vpn_packet_t pkt1, pkt2;
vpn_packet_t *pkt[] = { &pkt1, &pkt2, &pkt1, &pkt2 };
receive_packet(n, inpkt);
}
-void receive_tcppacket(connection_t * c, char *buffer, int len)
+void receive_tcppacket(connection_t *c, char *buffer, int len)
{
vpn_packet_t outpkt;
receive_packet(c->node, &outpkt);
}
-void receive_packet(node_t * n, vpn_packet_t * packet)
+void receive_packet(node_t *n, vpn_packet_t *packet)
{
cp();
route_incoming(n, packet);
}
-void send_udppacket(node_t * n, vpn_packet_t * inpkt)
+void send_udppacket(node_t *n, vpn_packet_t *inpkt)
{
vpn_packet_t pkt1, pkt2;
vpn_packet_t *pkt[] = { &pkt1, &pkt2, &pkt1, &pkt2 };
/*
send a packet to the given vpn ip.
*/
-void send_packet(node_t * n, vpn_packet_t * packet)
+void send_packet(node_t *n, vpn_packet_t *packet)
{
node_t *via;
/* Broadcast a packet using the minimum spanning tree */
-void broadcast_packet(node_t * from, vpn_packet_t * packet)
+void broadcast_packet(node_t *from, vpn_packet_t *packet)
{
avl_node_t *node;
connection_t *c;
}
}
-void flush_queue(node_t * n)
+void flush_queue(node_t *n)
{
list_node_t *node, *next;
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- $Id: net_setup.c,v 1.1.2.25 2002/09/09 21:24:41 guus Exp $
+ $Id: net_setup.c,v 1.1.2.26 2002/09/09 22:32:44 guus Exp $
*/
#include "config.h"
char *myport;
-int read_rsa_public_key(connection_t * c)
+int read_rsa_public_key(connection_t *c)
{
FILE *fp;
char *fname;
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- $Id: net_socket.c,v 1.1.2.20 2002/09/09 21:24:41 guus Exp $
+ $Id: net_socket.c,v 1.1.2.21 2002/09/09 22:32:44 guus Exp $
*/
#include "config.h"
/* Setup sockets */
-int setup_listen_socket(sockaddr_t * sa)
+int setup_listen_socket(sockaddr_t *sa)
{
int nfd, flags;
char *addrstr;
return nfd;
}
-int setup_vpn_in_socket(sockaddr_t * sa)
+int setup_vpn_in_socket(sockaddr_t *sa)
{
int nfd, flags;
char *addrstr;
return nfd;
}
-void retry_outgoing(outgoing_t * outgoing)
+void retry_outgoing(outgoing_t *outgoing)
{
event_t *event;
outgoing->timeout);
}
-int setup_outgoing_socket(connection_t * c)
+int setup_outgoing_socket(connection_t *c)
{
int option;
}
-void finish_connecting(connection_t * c)
+void finish_connecting(connection_t *c)
{
cp();
send_id(c);
}
-void do_outgoing_connection(connection_t * c)
+void do_outgoing_connection(connection_t *c)
{
char *address, *port;
int option, result, flags;
return;
}
-void setup_outgoing_connection(outgoing_t * outgoing)
+void setup_outgoing_connection(outgoing_t *outgoing)
{
connection_t *c;
node_t *n;
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- $Id: device.c,v 1.1.2.5 2002/09/09 21:25:23 guus Exp $
+ $Id: device.c,v 1.1.2.6 2002/09/09 22:33:24 guus Exp $
*/
#include "config.h"
cp close(device_fd);
cp}
-int read_packet(vpn_packet_t * packet)
+int read_packet(vpn_packet_t *packet)
{
int lenin;
cp if((lenin = read(device_fd, packet->data + 14, MTU - 14)) <= 0) {
return 0;
cp}
-int write_packet(vpn_packet_t * packet)
+int write_packet(vpn_packet_t *packet)
{
cp if(debug_lvl >= DEBUG_TRAFFIC)
syslog(LOG_DEBUG, _("Writing packet of %d bytes to %s"),
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- $Id: netutl.c,v 1.12.4.43 2002/09/09 21:24:41 guus Exp $
+ $Id: netutl.c,v 1.12.4.44 2002/09/09 22:32:44 guus Exp $
*/
#include "config.h"
return result;
}
-void sockaddr2str(sockaddr_t * sa, char **addrstr, char **portstr)
+void sockaddr2str(sockaddr_t *sa, char **addrstr, char **portstr)
{
char address[NI_MAXHOST];
char port[NI_MAXSERV];
*portstr = xstrdup(port);
}
-char *sockaddr2hostname(sockaddr_t * sa)
+char *sockaddr2hostname(sockaddr_t *sa)
{
char *str;
char address[NI_MAXHOST] = "unknown";
return str;
}
-int sockaddrcmp(sockaddr_t * a, sockaddr_t * b)
+int sockaddrcmp(sockaddr_t *a, sockaddr_t *b)
{
int result;
}
}
-void sockaddrunmap(sockaddr_t * sa)
+void sockaddrunmap(sockaddr_t *sa)
{
if(sa->sa.sa_family == AF_INET6 && IN6_IS_ADDR_V4MAPPED(&sa->in6.sin6_addr)) {
sa->in.sin_addr.s_addr = ((uint32_t *) & sa->in6.sin6_addr)[3];
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.17 2002/09/09 21:24:41 guus Exp $
+ $Id: node.c,v 1.1.2.18 2002/09/09 22:32:49 guus Exp $
*/
#include "config.h"
node_t *myself;
-int node_compare(node_t * a, node_t * b)
+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)
+int node_udp_compare(node_t *a, node_t *b)
{
int result;
return n;
}
-void free_node(node_t * n)
+void free_node(node_t *n)
{
cp();
free(n);
}
-void node_add(node_t * n)
+void node_add(node_t *n)
{
cp();
avl_insert(node_udp_tree, n);
}
-void node_del(node_t * n)
+void node_del(node_t *n)
{
avl_node_t *node, *next;
edge_t *e;
return avl_search(node_tree, &n);
}
-node_t *lookup_node_udp(sockaddr_t * sa)
+node_t *lookup_node_udp(sockaddr_t *sa)
{
node_t n;
cp();
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- $Id: device.c,v 1.1.2.10 2002/09/09 21:25:26 guus Exp $
+ $Id: device.c,v 1.1.2.11 2002/09/09 22:33:27 guus Exp $
*/
#include "config.h"
cp close(device_fd);
cp}
-int read_packet(vpn_packet_t * packet)
+int read_packet(vpn_packet_t *packet)
{
int lenin;
u_int32_t type;
return 0;
cp}
-int write_packet(vpn_packet_t * packet)
+int write_packet(vpn_packet_t *packet)
{
u_int32_t type;
struct iovec vector[2];
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.46 2002/09/09 21:24:41 guus Exp $
+ $Id: process.c,v 1.1.2.47 2002/09/09 22:32:49 guus Exp $
*/
#include "config.h"
struct {
int signal;
- void (*handler) (int);
+ void (*handler)(int);
} sighandlers[] = {
{
SIGHUP, sighup_handler}, {
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.136 2002/09/09 21:24:41 guus Exp $
+ $Id: protocol.c,v 1.28.4.137 2002/09/09 22:32:49 guus Exp $
*/
#include "config.h"
/* Generic request routines - takes care of logging and error
detection as well */
-int send_request(connection_t * c, const char *format, ...)
+int send_request(connection_t *c, const char *format, ...)
{
va_list args;
char buffer[MAXBUFSIZE];
return send_meta(c, buffer, len);
}
-int forward_request(connection_t * from)
+int forward_request(connection_t *from)
{
int request;
cp();
return broadcast_meta(from, from->buffer, from->reqlen);
}
-int receive_request(connection_t * c)
+int receive_request(connection_t *c)
{
int request;
return 0;
}
-int past_request_compare(past_request_t * a, past_request_t * b)
+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)
+void free_past_request(past_request_t *r)
{
cp();
/* Jumptable for the request handlers */
-int (*request_handlers[]) (connection_t *) = {
+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,
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.35 2002/09/09 21:24:42 guus Exp $
+ $Id: protocol.h,v 1.5.4.36 2002/09/09 22:32:55 guus Exp $
*/
#ifndef __TINC_PROTOCOL_H__
/* Request handlers */
-extern int (*request_handlers[]) (connection_t *);
+extern int (*request_handlers[])(connection_t *);
extern int id_h(connection_t *);
extern int metakey_h(connection_t *);
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.16 2002/09/09 21:24:45 guus Exp $
+ $Id: protocol_auth.c,v 1.1.4.17 2002/09/09 22:32:59 guus Exp $
*/
#include "config.h"
#include "system.h"
-int send_id(connection_t * c)
+int send_id(connection_t *c)
{
cp();
myself->connection->protocol_version);
}
-int id_h(connection_t * c)
+int id_h(connection_t *c)
{
char name[MAX_STRING_SIZE];
int bla;
return send_metakey(c);
}
-int send_metakey(connection_t * c)
+int send_metakey(connection_t *c)
{
char buffer[MAX_STRING_SIZE];
int len, x;
return x;
}
-int metakey_h(connection_t * c)
+int metakey_h(connection_t *c)
{
char buffer[MAX_STRING_SIZE];
int cipher, digest, maclength, compression;
return send_challenge(c);
}
-int send_challenge(connection_t * c)
+int send_challenge(connection_t *c)
{
char buffer[MAX_STRING_SIZE];
int len, x;
return x;
}
-int challenge_h(connection_t * c)
+int challenge_h(connection_t *c)
{
char buffer[MAX_STRING_SIZE];
int len;
return send_chal_reply(c);
}
-int send_chal_reply(connection_t * c)
+int send_chal_reply(connection_t *c)
{
char hash[EVP_MAX_MD_SIZE * 2 + 1];
EVP_MD_CTX ctx;
return send_request(c, "%d %s", CHAL_REPLY, hash);
}
-int chal_reply_h(connection_t * c)
+int chal_reply_h(connection_t *c)
{
char hishash[MAX_STRING_SIZE];
char myhash[EVP_MAX_MD_SIZE];
return send_ack(c);
}
-int send_ack(connection_t * c)
+int send_ack(connection_t *c)
{
/* ACK message contains rest of the information the other end needs
to create node_t and edge_t structures. */
return x;
}
-void send_everything(connection_t * c)
+void send_everything(connection_t *c)
{
avl_node_t *node, *node2;
node_t *n;
}
}
-int ack_h(connection_t * c)
+int ack_h(connection_t *c)
{
char hisport[MAX_STRING_SIZE];
char *hisaddress, *dummy;
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- $Id: protocol_edge.c,v 1.1.4.12 2002/09/09 21:24:48 guus Exp $
+ $Id: protocol_edge.c,v 1.1.4.13 2002/09/09 22:33:02 guus Exp $
*/
#include "config.h"
#include "system.h"
-int send_add_edge(connection_t * c, edge_t * e)
+int send_add_edge(connection_t *c, edge_t *e)
{
int x;
char *address, *port;
return x;
}
-int add_edge_h(connection_t * c)
+int add_edge_h(connection_t *c)
{
edge_t *e;
node_t *from, *to;
return 0;
}
-int send_del_edge(connection_t * c, edge_t * e)
+int send_del_edge(connection_t *c, edge_t *e)
{
cp();
e->from->name, e->to->name);
}
-int del_edge_h(connection_t * c)
+int del_edge_h(connection_t *c)
{
edge_t *e;
char from_name[MAX_STRING_SIZE];
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- $Id: protocol_key.c,v 1.1.4.13 2002/09/09 21:24:56 guus Exp $
+ $Id: protocol_key.c,v 1.1.4.14 2002/09/09 22:33:03 guus Exp $
*/
#include "config.h"
int mykeyused = 0;
-int send_key_changed(connection_t * c, node_t * n)
+int send_key_changed(connection_t *c, node_t *n)
{
cp();
return send_request(c, "%d %lx %s", KEY_CHANGED, random(), n->name);
}
-int key_changed_h(connection_t * c)
+int key_changed_h(connection_t *c)
{
char name[MAX_STRING_SIZE];
node_t *n;
return 0;
}
-int send_req_key(connection_t * c, node_t * from, node_t * to)
+int send_req_key(connection_t *c, node_t *from, node_t *to)
{
cp();
return send_request(c, "%d %s %s", REQ_KEY, from->name, to->name);
}
-int req_key_h(connection_t * c)
+int req_key_h(connection_t *c)
{
char from_name[MAX_STRING_SIZE];
char to_name[MAX_STRING_SIZE];
return 0;
}
-int send_ans_key(connection_t * c, node_t * from, node_t * to)
+int send_ans_key(connection_t *c, node_t *from, node_t *to)
{
char key[MAX_STRING_SIZE];
from->compression);
}
-int ans_key_h(connection_t * c)
+int ans_key_h(connection_t *c)
{
char from_name[MAX_STRING_SIZE];
char to_name[MAX_STRING_SIZE];
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.6 2002/09/09 21:25:02 guus Exp $
+ $Id: protocol_misc.c,v 1.1.4.7 2002/09/09 22:33:04 guus Exp $
*/
#include "config.h"
/* 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)
{
cp();
return send_request(c, "%d %d %s", STATUS, statusno, statusstring);
}
-int status_h(connection_t * c)
+int status_h(connection_t *c)
{
int statusno;
char statusstring[MAX_STRING_SIZE];
return 0;
}
-int send_error(connection_t * c, int err, char *errstring)
+int send_error(connection_t *c, int err, char *errstring)
{
cp();
return send_request(c, "%d %d %s", ERROR, err, errstring);
}
-int error_h(connection_t * c)
+int error_h(connection_t *c)
{
int err;
char errorstring[MAX_STRING_SIZE];
return 0;
}
-int send_termreq(connection_t * c)
+int send_termreq(connection_t *c)
{
cp();
return send_request(c, "%d", TERMREQ);
}
-int termreq_h(connection_t * c)
+int termreq_h(connection_t *c)
{
cp();
return 0;
}
-int send_ping(connection_t * c)
+int send_ping(connection_t *c)
{
cp();
return send_request(c, "%d", PING);
}
-int ping_h(connection_t * c)
+int ping_h(connection_t *c)
{
cp();
return send_pong(c);
}
-int send_pong(connection_t * c)
+int send_pong(connection_t *c)
{
cp();
return send_request(c, "%d", PONG);
}
-int pong_h(connection_t * c)
+int pong_h(connection_t *c)
{
cp();
/* Sending and receiving packets via TCP */
-int send_tcppacket(connection_t * c, vpn_packet_t * packet)
+int send_tcppacket(connection_t *c, vpn_packet_t *packet)
{
int x;
return send_meta(c, packet->data, packet->len);
}
-int tcppacket_h(connection_t * c)
+int tcppacket_h(connection_t *c)
{
short int len;
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- $Id: protocol_node.c,v 1.1.4.8 2002/09/09 21:25:02 guus Exp $
+ $Id: protocol_node.c,v 1.1.4.9 2002/09/09 22:33:08 guus Exp $
*/
#include "config.h"
#include "system.h"
-int send_add_node(connection_t * c, node_t * n)
+int send_add_node(connection_t *c, node_t *n)
{
int x;
char *address, *port;
return x;
}
-int add_node_h(connection_t * c)
+int add_node_h(connection_t *c)
{
connection_t *other;
node_t *n, *prevhop, *via;
return 0;
}
-int send_del_node(connection_t * c, node_t * n)
+int send_del_node(connection_t *c, node_t *n)
{
cp();
return send_request(c, "%d %s %s", DEL_NODE, n->name, n->prevhop->name);
}
-int del_node_h(connection_t * c)
+int del_node_h(connection_t *c)
{
char name[MAX_STRING_SIZE];
char prevhopname[MAX_STRING_SIZE];
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- $Id: protocol_subnet.c,v 1.1.4.8 2002/09/09 21:25:02 guus Exp $
+ $Id: protocol_subnet.c,v 1.1.4.9 2002/09/09 22:33:13 guus Exp $
*/
#include "config.h"
#include "system.h"
-int send_add_subnet(connection_t * c, subnet_t * subnet)
+int send_add_subnet(connection_t *c, subnet_t *subnet)
{
int x;
char *netstr;
return x;
}
-int add_subnet_h(connection_t * c)
+int add_subnet_h(connection_t *c)
{
char subnetstr[MAX_STRING_SIZE];
char name[MAX_STRING_SIZE];
return 0;
}
-int send_del_subnet(connection_t * c, subnet_t * s)
+int send_del_subnet(connection_t *c, subnet_t *s)
{
int x;
char *netstr;
return x;
}
-int del_subnet_h(connection_t * c)
+int del_subnet_h(connection_t *c)
{
char subnetstr[MAX_STRING_SIZE];
char name[MAX_STRING_SIZE];
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- $Id: device.c,v 1.1.2.2 2002/09/09 21:25:28 guus Exp $
+ $Id: device.c,v 1.1.2.3 2002/09/09 22:33:31 guus Exp $
*/
#include "config.h"
read, encrypt and send data that is
available through the ethertap device
*/
-int read_packet(vpn_packet_t * packet)
+int read_packet(vpn_packet_t *packet)
{
int lenin;
cp if((lenin = read(device_fd, packet->data, MTU)) <= 0) {
return 0;
cp}
-int write_packet(vpn_packet_t * packet)
+int write_packet(vpn_packet_t *packet)
{
cp if(debug_lvl >= DEBUG_TRAFFIC)
syslog(LOG_DEBUG, _("Writing packet of %d bytes to %s"),
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.45 2002/09/09 21:25:07 guus Exp $
+ $Id: route.c,v 1.1.2.46 2002/09/09 22:33:16 guus Exp $
*/
#include "config.h"
int macexpire = 600;
subnet_t mymac;
-void learn_mac(mac_t * address)
+void learn_mac(mac_t *address)
{
subnet_t *subnet;
avl_node_t *node;
}
}
-node_t *route_mac(vpn_packet_t * packet)
+node_t *route_mac(vpn_packet_t *packet)
{
subnet_t *subnet;
/* Learn source address */
- learn_mac((mac_t *) (&packet->data[6]));
+ learn_mac((mac_t *)(&packet->data[6]));
/* Lookup destination address */
- subnet = lookup_subnet_mac((mac_t *) (&packet->data[0]));
+ subnet = lookup_subnet_mac((mac_t *)(&packet->data[0]));
if(subnet)
return subnet->owner;
return NULL;
}
-node_t *route_ipv4(vpn_packet_t * packet)
+node_t *route_ipv4(vpn_packet_t *packet)
{
subnet_t *subnet;
return subnet->owner;
}
-node_t *route_ipv6(vpn_packet_t * packet)
+node_t *route_ipv6(vpn_packet_t *packet)
{
subnet_t *subnet;
return subnet->owner;
}
-uint16_t inet_checksum(uint16_t * data, int len, uint16_t prevsum)
+uint16_t inet_checksum(uint16_t *data, int len, uint16_t prevsum)
{
uint32_t checksum = prevsum ^ 0xFFFF;
return checksum ^ 0xFFFF;
}
-void route_neighborsol(vpn_packet_t * packet)
+void route_neighborsol(vpn_packet_t *packet)
{
struct ip6_hdr *hdr;
struct nd_neighbor_solicit *ns;
cp();
- hdr = (struct ip6_hdr *) (packet->data + 14);
- ns = (struct nd_neighbor_solicit *) (packet->data + 14 + sizeof(*hdr));
- opt = (struct nd_opt_hdr *) (packet->data + 14 + sizeof(*hdr) + sizeof(*ns));
+ hdr = (struct ip6_hdr *)(packet->data + 14);
+ ns = (struct nd_neighbor_solicit *)(packet->data + 14 + sizeof(*hdr));
+ opt = (struct nd_opt_hdr *)(packet->data + 14 + sizeof(*hdr) + sizeof(*ns));
/* First, snatch the source address from the neighbor solicitation packet */
write_packet(packet);
}
-void route_arp(vpn_packet_t * packet)
+void route_arp(vpn_packet_t *packet)
{
struct ether_arp *arp;
subnet_t *subnet;
Most of the code here is taken from choparp.c by Takamichi Tateoka (tree@mma.club.uec.ac.jp)
*/
- arp = (struct ether_arp *) (packet->data + 14);
+ arp = (struct ether_arp *)(packet->data + 14);
/* Check if this is a valid ARP request */
write_packet(packet);
}
-void route_outgoing(vpn_packet_t * packet)
+void route_outgoing(vpn_packet_t *packet)
{
uint16_t type;
node_t *n = NULL;
switch (routing_mode) {
case RMODE_ROUTER:
- type = ntohs(*((uint16_t *) (&packet->data[12])));
+ type = ntohs(*((uint16_t *)(&packet->data[12])));
switch (type) {
case 0x0800:
n = route_ipv4(packet);
}
}
-void route_incoming(node_t * source, vpn_packet_t * packet)
+void route_incoming(node_t *source, vpn_packet_t *packet)
{
switch (routing_mode) {
case RMODE_ROUTER:
node_t *n = NULL;
uint16_t type;
- type = ntohs(*((uint16_t *) (&packet->data[12])));
+ type = ntohs(*((uint16_t *)(&packet->data[12])));
switch (type) {
case 0x0800:
n = route_ipv4(packet);
{
subnet_t *subnet;
- subnet = lookup_subnet_mac((mac_t *) (&packet->data[0]));
+ subnet = lookup_subnet_mac((mac_t *)(&packet->data[0]));
if(subnet) {
if(subnet->owner == myself)
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- $Id: device.c,v 1.1.2.9 2002/09/09 21:25:28 guus Exp $
+ $Id: device.c,v 1.1.2.10 2002/09/09 22:33:31 guus Exp $
*/
cp close(device_fd);
}
-int read_packet(vpn_packet_t * packet)
+int read_packet(vpn_packet_t *packet)
{
int lenin;
cp if((lenin = read(device_fd, packet->data + 14, MTU - 14)) <= 0) {
return 0;
cp}
-int write_packet(vpn_packet_t * packet)
+int write_packet(vpn_packet_t *packet)
{
cp if(debug_lvl >= DEBUG_TRAFFIC)
syslog(LOG_DEBUG, _("Writing packet of %d bytes to %s"),
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.41 2002/09/09 21:25:10 guus Exp $
+ $Id: subnet.c,v 1.1.2.42 2002/09/09 22:33:21 guus Exp $
*/
#include "config.h"
/* Subnet comparison */
-int subnet_compare_mac(subnet_t * a, subnet_t * b)
+int subnet_compare_mac(subnet_t *a, subnet_t *b)
{
int result;
return strcmp(a->owner->name, b->owner->name);
}
-int subnet_compare_ipv4(subnet_t * a, subnet_t * b)
+int subnet_compare_ipv4(subnet_t *a, subnet_t *b)
{
int result;
return strcmp(a->owner->name, b->owner->name);
}
-int subnet_compare_ipv6(subnet_t * a, subnet_t * b)
+int subnet_compare_ipv6(subnet_t *a, subnet_t *b)
{
int result;
return strcmp(a->owner->name, b->owner->name);
}
-int subnet_compare(subnet_t * a, subnet_t * b)
+int subnet_compare(subnet_t *a, subnet_t *b)
{
int result;
return avl_alloc_tree((avl_compare_t) subnet_compare, NULL);
}
-void free_subnet_tree(avl_tree_t * subnet_tree)
+void free_subnet_tree(avl_tree_t *subnet_tree)
{
cp();
return (subnet_t *) xmalloc_and_zero(sizeof(subnet_t));
}
-void free_subnet(subnet_t * subnet)
+void free_subnet(subnet_t *subnet)
{
cp();
/* Adding and removing subnets */
-void subnet_add(node_t * n, subnet_t * subnet)
+void subnet_add(node_t *n, subnet_t *subnet)
{
cp();
avl_insert(n->subnet_tree, subnet);
}
-void subnet_del(node_t * n, subnet_t * subnet)
+void subnet_del(node_t *n, subnet_t *subnet)
{
cp();
return NULL;
}
-char *net2str(subnet_t * subnet)
+char *net2str(subnet_t *subnet)
{
char *netstr;
/* Subnet lookup routines */
-subnet_t *lookup_subnet(node_t * owner, subnet_t * subnet)
+subnet_t *lookup_subnet(node_t *owner, subnet_t *subnet)
{
cp();
return avl_search(owner->subnet_tree, subnet);
}
-subnet_t *lookup_subnet_mac(mac_t * address)
+subnet_t *lookup_subnet_mac(mac_t *address)
{
subnet_t subnet, *p;
return p;
}
-subnet_t *lookup_subnet_ipv4(ipv4_t * address)
+subnet_t *lookup_subnet_ipv4(ipv4_t *address)
{
subnet_t subnet, *p;
return p;
}
-subnet_t *lookup_subnet_ipv6(ipv6_t * address)
+subnet_t *lookup_subnet_ipv6(ipv6_t *address)
{
subnet_t subnet, *p;