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.18 2003/07/30 21:52:41 guus Exp $
+ $Id: avl_tree.c,v 1.1.2.19 2003/08/28 21:05:09 guus Exp $
*/
#include "system.h"
avl_node_t *avl_alloc_node(void)
{
- return (avl_node_t *)xmalloc_and_zero(sizeof(avl_node_t));
+ return xmalloc_and_zero(sizeof(avl_node_t));
}
void avl_free_node(avl_tree_t *tree, avl_node_t *node)
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.16 2003/07/17 15:06:25 guus Exp $
+ $Id: list.c,v 1.1.2.17 2003/08/28 21:05:09 guus Exp $
*/
#include "system.h"
list_node_t *list_alloc_node(void)
{
- return (list_node_t *)xmalloc_and_zero(sizeof(list_node_t));
+ return xmalloc_and_zero(sizeof(list_node_t));
}
void list_free_node(list_t *list, list_node_t *node)
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.75 2003/08/08 22:11:54 guus Exp $
+ $Id: conf.c,v 1.9.4.76 2003/08/28 21:05:10 guus Exp $
*/
#include "system.h"
{
cp();
- return (config_t *) xmalloc_and_zero(sizeof(config_t));
+ return xmalloc_and_zero(sizeof(config_t));
}
void free_config(config_t *cfg)
if(node) {
if(node->next) {
- found = (config_t *) node->next->data;
+ found = node->next->data;
if(!strcasecmp(found->variable, cfg->variable))
return found;
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.43 2003/07/29 10:50:15 guus Exp $
+ $Id: connection.c,v 1.1.2.44 2003/08/28 21:05:10 guus Exp $
*/
#include "system.h"
cp();
- c = (connection_t *) xmalloc_and_zero(sizeof(connection_t));
+ c = xmalloc_and_zero(sizeof(connection_t));
if(!c)
return NULL;
logger(LOG_DEBUG, _("Connections:"));
for(node = connection_tree->head; node; node = node->next) {
- c = (connection_t *) node->data;
+ c = node->data;
logger(LOG_DEBUG, _(" %s at %s options %lx socket %d status %04x"),
c->name, c->hostname, c->options, c->socket, *(uint32_t *)&c->status);
}
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.26 2003/08/22 11:18:42 guus Exp $
+ $Id: edge.c,v 1.1.2.27 2003/08/28 21:05:10 guus Exp $
*/
#include "system.h"
{
cp();
- return (edge_t *) xmalloc_and_zero(sizeof(edge_t));
+ return xmalloc_and_zero(sizeof(edge_t));
}
void free_edge(edge_t *e)
logger(LOG_DEBUG, _("Edges:"));
for(node = node_tree->head; node; node = node->next) {
- n = (node_t *) node->data;
+ n = node->data;
for(node2 = n->edge_tree->head; node2; node2 = node2->next) {
- e = (edge_t *) node2->data;
+ e = node2->data;
address = sockaddr2hostname(&e->address);
logger(LOG_DEBUG, _(" %s to %s at %s options %lx weight %d"),
e->from->name, e->to->name, address, e->options, e->weight);
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.10 2003/07/24 12:08:15 guus Exp $
+ $Id: event.c,v 1.1.4.11 2003/08/28 21:05:10 guus Exp $
*/
#include "system.h"
{
cp();
- return (event_t *) xmalloc_and_zero(sizeof(event_t));
+ return xmalloc_and_zero(sizeof(event_t));
}
void free_event(event_t *event)
cp();
if(event_tree->head) {
- event = (event_t *) event_tree->head->data;
+ event = event_tree->head->data;
if(event->time < now) {
avl_delete(event_tree, event);
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- $Id: graph.c,v 1.1.2.28 2003/08/22 11:18:42 guus Exp $
+ $Id: graph.c,v 1.1.2.29 2003/08/28 21:05:10 guus Exp $
*/
/* We need to generate two trees from the graph:
/* Clear MST status on connections */
for(node = connection_tree->head; node; node = node->next) {
- c = (connection_t *) node->data;
+ c = node->data;
c->status.mst = false;
}
/* Clear visited status on nodes */
for(node = node_tree->head; node; node = node->next) {
- n = (node_t *) node->data;
+ n = node->data;
n->status.visited = false;
nodes++;
}
for(skipped = false, node = edge_weight_tree->head; node; node = next) {
next = node->next;
- e = (edge_t *) node->data;
+ e = node->data;
if(!e->reverse || e->from->status.visited == e->to->status.visited) {
skipped = true;
/* Clear visited status on nodes */
for(node = node_tree->head; node; node = node->next) {
- n = (node_t *) node->data;
+ n = node->data;
n->status.visited = false;
n->status.indirect = true;
}
while(todo_tree->head) {
for(from = todo_tree->head; from; from = next) { /* "from" is the node from which we start */
next = from->next;
- n = (node_t *) from->data;
+ n = from->data;
for(to = n->edge_tree->head; to; to = to->next) { /* "to" is the edge connected to "from" */
- e = (edge_t *) to->data;
+ e = to->data;
if(!e->reverse)
continue;
for(node = node_tree->head; node; node = next) {
next = node->next;
- n = (node_t *) node->data;
+ n = node->data;
if(n->status.visited != n->status.reachable) {
n->status.reachable = !n->status.reachable;
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.20 2003/07/22 20:55:21 guus Exp $
+ $Id: device.c,v 1.1.2.21 2003/08/28 21:05:11 guus Exp $
*/
#include "system.h"
if(iface)
strncpy(ifr.ifr_name, iface, IFNAMSIZ);
- if(!ioctl(device_fd, TUNSETIFF, (void *) &ifr)) {
+ if(!ioctl(device_fd, TUNSETIFF, &ifr)) {
strncpy(ifrname, ifr.ifr_name, IFNAMSIZ);
iface = ifrname;
- } else if(!ioctl(device_fd, (('T' << 8) | 202), (void *) &ifr)) {
+ } else if(!ioctl(device_fd, (('T' << 8) | 202), &ifr)) {
logger(LOG_WARNING, _("Old ioctl() request was needed for %s"), device);
strncpy(ifrname, ifr.ifr_name, IFNAMSIZ);
iface = ifrname;
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.43 2003/08/22 11:18:42 guus Exp $
+ $Id: meta.c,v 1.1.2.44 2003/08/28 21:05:10 guus Exp $
*/
#include "system.h"
cp();
for(node = connection_tree->head; node; node = node->next) {
- c = (connection_t *) node->data;
+ c = node->data;
if(c != from && c->status.active)
send_meta(c, buffer, length);
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.199 2003/08/28 15:27:11 guus Exp $
+ $Id: net.c,v 1.35.4.200 2003/08/28 21:05:10 guus Exp $
*/
#include "system.h"
for(nnode = node_tree->head; nnode; nnode = nnext) {
nnext = nnode->next;
- n = (node_t *) nnode->data;
+ n = nnode->data;
if(!n->status.reachable) {
ifdebug(SCARY_THINGS) logger(LOG_DEBUG, _("Purging node %s (%s)"), n->name,
for(snode = n->subnet_tree->head; snode; snode = snext) {
snext = snode->next;
- s = (subnet_t *) snode->data;
+ s = snode->data;
send_del_subnet(broadcast, s);
subnet_del(n, s);
}
for(enode = n->edge_tree->head; enode; enode = enext) {
enext = enode->next;
- e = (edge_t *) enode->data;
+ e = enode->data;
send_del_edge(broadcast, e);
edge_del(e);
}
for(nnode = node_tree->head; nnode; nnode = nnext) {
nnext = nnode->next;
- n = (node_t *) nnode->data;
+ n = nnode->data;
if(!n->status.reachable) {
for(enode = edge_weight_tree->head; enode; enode = enext) {
enext = enode->next;
- e = (edge_t *) enode->data;
+ e = enode->data;
if(e->to == n)
break;
for(node = connection_tree->head; node; node = next) {
next = node->next;
- c = (connection_t *) node->data;
+ c = node->data;
if(c->status.remove) {
connection_del(c);
for(node = connection_tree->head; node; node = next) {
next = node->next;
- c = (connection_t *) node->data;
+ c = node->data;
if(c->last_ping_time + pingtimeout < now) {
if(c->status.active) {
}
for(node = connection_tree->head; node; node = node->next) {
- c = (connection_t *) node->data;
+ c = node->data;
if(c->status.remove)
continue;
logger(LOG_INFO, _("Flushing event queue"));
while(event_tree->head) {
- event = (event_t *) event_tree->head->data;
+ event = event_tree->head->data;
event->handler(event->data);
event_del(event);
}
/* Close connections to hosts that have a changed or deleted host config file */
for(node = connection_tree->head; node; node = node->next) {
- c = (connection_t *) node->data;
+ c = node->data;
if(c->outgoing) {
free(c->outgoing->name);
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.39 2003/08/22 11:18:42 guus Exp $
+ $Id: net_packet.c,v 1.1.2.40 2003/08/28 21:05:10 guus Exp $
*/
#include "system.h"
packet->len, from->name, from->hostname);
for(node = connection_tree->head; node; node = node->next) {
- c = (connection_t *) node->data;
+ c = node->data;
if(c->status.active && c->status.mst && c != from->nexthop->connection)
send_packet(c->node, packet);
for(node = n->queue->head; node; node = next) {
next = node->next;
- send_udppacket(n, (vpn_packet_t *) node->data);
+ send_udppacket(n, node->data);
list_delete_node(n->queue, node);
}
}
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.43 2003/08/14 14:21:35 guus Exp $
+ $Id: net_setup.c,v 1.1.2.44 2003/08/28 21:05:10 guus Exp $
*/
#include "system.h"
myself->connection->outcipher = EVP_bf_ofb();
- myself->key = (char *) xmalloc(myself->keylength);
+ myself->key = xmalloc(myself->keylength);
RAND_pseudo_bytes(myself->key, myself->keylength);
if(!get_config_int(lookup_config(config_tree, "KeyExpire"), &keylifetime))
for(node = connection_tree->head; node; node = next) {
next = node->next;
- c = (connection_t *) node->data;
+ c = node->data;
if(c->outgoing)
free(c->outgoing->name), free(c->outgoing), c->outgoing = NULL;
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.27 2003/08/22 11:18:42 guus Exp $
+ $Id: node.c,v 1.1.2.28 2003/08/28 21:05:10 guus Exp $
*/
#include "system.h"
node_t *new_node(void)
{
- node_t *n = (node_t *) xmalloc_and_zero(sizeof(*n));
+ node_t *n = xmalloc_and_zero(sizeof(*n));
cp();
for(node = n->subnet_tree->head; node; node = next) {
next = node->next;
- s = (subnet_t *) node->data;
+ s = node->data;
subnet_del(n, s);
}
for(node = n->edge_tree->head; node; node = next) {
next = node->next;
- e = (edge_t *) node->data;
+ e = node->data;
edge_del(e);
}
logger(LOG_DEBUG, _("Nodes:"));
for(node = node_tree->head; node; node = node->next) {
- n = (node_t *) node->data;
+ n = node->data;
logger(LOG_DEBUG, _(" %s at %s cipher %d digest %d maclength %d compression %d options %lx status %04x nexthop %s via %s"),
n->name, n->hostname, n->cipher ? n->cipher->nid : 0,
n->digest ? n->digest->type : 0, n->maclength, n->compression,
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.146 2003/08/03 12:38:43 guus Exp $
+ $Id: protocol.c,v 1.28.4.147 2003/08/28 21:05:10 guus Exp $
*/
#include "system.h"
ifdebug(SCARY_THINGS) logger(LOG_DEBUG, _("Already seen request"));
return true;
} else {
- new = (past_request_t *) xmalloc(sizeof(*new));
+ new = xmalloc(sizeof(*new));
new->request = xstrdup(request);
new->firstseen = now;
avl_insert(past_request_tree, new);
for(node = past_request_tree->head; node; node = next) {
next = node->next;
- p = (past_request_t *) node->data;
+ p = node->data;
if(p->firstseen + pingtimeout < now)
avl_delete_node(past_request_tree, node), deleted++;
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.25 2003/07/22 20:55:20 guus Exp $
+ $Id: protocol_auth.c,v 1.1.4.26 2003/08/28 21:05:11 guus Exp $
*/
#include "system.h"
/* Send all known subnets and edges */
for(node = node_tree->head; node; node = node->next) {
- n = (node_t *) node->data;
+ n = node->data;
for(node2 = n->subnet_tree->head; node2; node2 = node2->next) {
- s = (subnet_t *) node2->data;
+ s = node2->data;
send_add_subnet(c, s);
}
for(node2 = n->edge_tree->head; node2; node2 = node2->next) {
- e = (edge_t *) node2->data;
+ e = node2->data;
send_add_edge(c, e);
}
}
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.63 2003/07/31 13:18:34 guus Exp $
+ $Id: route.c,v 1.1.2.64 2003/08/28 21:05:11 guus Exp $
*/
#include "system.h"
/* And tell all other tinc daemons it's our MAC */
for(node = connection_tree->head; node; node = node->next) {
- c = (connection_t *) node->data;
+ c = node->data;
if(c->status.active)
send_add_subnet(c, subnet);
}
for(node = myself->subnet_tree->head; node; node = next) {
next = node->next;
- s = (subnet_t *) node->data;
+ s = node->data;
if(s->type == SUBNET_MAC && s->net.mac.lastseen && s->net.mac.lastseen + macexpire < now) {
ifdebug(TRAFFIC) logger(LOG_INFO, _("MAC address %hx:%hx:%hx:%hx:%hx:%hx expired"),
s->net.mac.address.x[0], s->net.mac.address.x[1],
s->net.mac.address.x[4], s->net.mac.address.x[5]);
for(node2 = connection_tree->head; node2; node2 = node2->next) {
- c = (connection_t *) node2->data;
+ c = node2->data;
if(c->status.active)
send_del_subnet(c, s);
}
if(priorityinheritance)
packet->priority = packet->data[15];
- subnet = lookup_subnet_ipv4((ipv4_t *) & packet->data[30]);
+ subnet = lookup_subnet_ipv4((ipv4_t *) &packet->data[30]);
if(!subnet) {
ifdebug(TRAFFIC) logger(LOG_WARNING, _("Cannot route packet: unknown IPv4 destination address %d.%d.%d.%d"),
cp();
- subnet = lookup_subnet_ipv6((ipv6_t *) & packet->data[38]);
+ subnet = lookup_subnet_ipv6((ipv6_t *) &packet->data[38]);
if(!subnet) {
ifdebug(TRAFFIC) logger(LOG_WARNING, _("Cannot route packet: unknown IPv6 destination address %hx:%hx:%hx:%hx:%hx:%hx:%hx:%hx"),
- ntohs(*(uint16_t *) & packet->data[38]),
- ntohs(*(uint16_t *) & packet->data[40]),
- ntohs(*(uint16_t *) & packet->data[42]),
- ntohs(*(uint16_t *) & packet->data[44]),
- ntohs(*(uint16_t *) & packet->data[46]),
- ntohs(*(uint16_t *) & packet->data[48]),
- ntohs(*(uint16_t *) & packet->data[50]),
- ntohs(*(uint16_t *) & packet->data[52]));
+ ntohs(*(uint16_t *) &packet->data[38]),
+ ntohs(*(uint16_t *) &packet->data[40]),
+ ntohs(*(uint16_t *) &packet->data[42]),
+ ntohs(*(uint16_t *) &packet->data[44]),
+ ntohs(*(uint16_t *) &packet->data[46]),
+ ntohs(*(uint16_t *) &packet->data[48]),
+ ntohs(*(uint16_t *) &packet->data[50]),
+ ntohs(*(uint16_t *) &packet->data[52]));
route_ipv6_unreachable(packet, ICMP6_DST_UNREACH_ADDR);
return NULL;
/* Check if the IPv6 address exists on the VPN */
- subnet = lookup_subnet_ipv6((ipv6_t *) & ns->nd_ns_target);
+ subnet = lookup_subnet_ipv6((ipv6_t *) &ns->nd_ns_target);
if(!subnet) {
ifdebug(TRAFFIC) logger(LOG_WARNING, _("Cannot route packet: neighbor solicitation request for unknown address %hx:%hx:%hx:%hx:%hx:%hx:%hx:%hx"),
- ntohs(((uint16_t *) & ns->nd_ns_target)[0]),
- ntohs(((uint16_t *) & ns->nd_ns_target)[1]),
- ntohs(((uint16_t *) & ns->nd_ns_target)[2]),
- ntohs(((uint16_t *) & ns->nd_ns_target)[3]),
- ntohs(((uint16_t *) & ns->nd_ns_target)[4]),
- ntohs(((uint16_t *) & ns->nd_ns_target)[5]),
- ntohs(((uint16_t *) & ns->nd_ns_target)[6]),
- ntohs(((uint16_t *) & ns->nd_ns_target)[7]));
+ ntohs(((uint16_t *) &ns->nd_ns_target)[0]),
+ ntohs(((uint16_t *) &ns->nd_ns_target)[1]),
+ ntohs(((uint16_t *) &ns->nd_ns_target)[2]),
+ ntohs(((uint16_t *) &ns->nd_ns_target)[3]),
+ ntohs(((uint16_t *) &ns->nd_ns_target)[4]),
+ ntohs(((uint16_t *) &ns->nd_ns_target)[5]),
+ ntohs(((uint16_t *) &ns->nd_ns_target)[6]),
+ ntohs(((uint16_t *) &ns->nd_ns_target)[7]));
return;
}
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.49 2003/07/30 11:50:45 guus Exp $
+ $Id: subnet.c,v 1.1.2.50 2003/08/28 21:05:11 guus Exp $
*/
#include "system.h"
{
cp();
- return (subnet_t *) xmalloc_and_zero(sizeof(subnet_t));
+ return xmalloc_and_zero(sizeof(subnet_t));
}
void free_subnet(subnet_t *subnet)
subnet.net.mac.address = *address;
subnet.owner = NULL;
- p = (subnet_t *) avl_search(subnet_tree, &subnet);
+ p = avl_search(subnet_tree, &subnet);
return p;
}
do {
/* Go find subnet */
- p = (subnet_t *) avl_search_closest_smaller(subnet_tree, &subnet);
+ p = avl_search_closest_smaller(subnet_tree, &subnet);
/* Check if the found subnet REALLY matches */
do {
/* Go find subnet */
- p = (subnet_t *) avl_search_closest_smaller(subnet_tree, &subnet);
+ p = avl_search_closest_smaller(subnet_tree, &subnet);
/* Check if the found subnet REALLY matches */
logger(LOG_DEBUG, _("Subnet list:"));
for(node = subnet_tree->head; node; node = node->next) {
- subnet = (subnet_t *) node->data;
+ subnet = node->data;
netstr = net2str(subnet);
logger(LOG_DEBUG, _(" %s owner %s"), netstr, subnet->owner->name);
free(netstr);