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.25 2003/07/30 11:50:45 guus Exp $
+ $Id: edge.c,v 1.1.2.26 2003/08/22 11:18:42 guus Exp $
*/
#include "system.h"
{
cp();
- edge_weight_tree =
- avl_alloc_tree((avl_compare_t) edge_weight_compare, NULL);
+ edge_weight_tree = avl_alloc_tree((avl_compare_t) edge_weight_compare, NULL);
}
avl_tree_t *new_edge_tree(void)
{
cp();
- return avl_alloc_tree((avl_compare_t) edge_compare, NULL);
+ return avl_alloc_tree((avl_compare_t) edge_compare, (avl_action_t) free_edge);
}
void free_edge_tree(avl_tree_t *edge_tree)
void free_edge(edge_t *e)
{
cp();
+
+ sockaddrfree(&e->address);
free(e);
}
if(e->reverse)
e->reverse->reverse = NULL;
- avl_delete(e->from->edge_tree, e);
avl_delete(edge_weight_tree, e);
+ avl_delete(e->from->edge_tree, e);
}
edge_t *lookup_edge(node_t *from, node_t *to)
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.27 2003/07/22 20:55:19 guus Exp $
+ $Id: graph.c,v 1.1.2.28 2003/08/22 11:18:42 guus Exp $
*/
/* We need to generate two trees from the graph:
if(sockaddrcmp(&e->to->address, &e->address)) {
node = avl_unlink(node_udp_tree, e->to);
- e->to->address = e->address;
+ sockaddrfree(&e->to->address);
+ sockaddrcpy(&e->to->address, &e->address);
if(e->to->hostname)
free(e->to->hostname);
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.42 2003/08/16 12:40:00 guus Exp $
+ $Id: meta.c,v 1.1.2.43 2003/08/22 11:18:42 guus Exp $
*/
#include "system.h"
bool receive_meta(connection_t *c)
{
- int x;
- socklen_t l = sizeof(x);
int oldlen, i;
int lenin, reqlen;
bool decrypted = false;
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- $Id: net.h,v 1.9.4.69 2003/08/02 20:50:38 guus Exp $
+ $Id: net.h,v 1.9.4.70 2003/08/22 11:18:42 guus Exp $
*/
#ifndef __TINC_NET_H__
typedef short length_t;
+#define AF_UNKNOWN 0xFFFF
+
+struct sockaddr_unknown {
+ uint16_t family;
+ uint16_t pad1;
+ uint32_t pad2;
+ char *address;
+ char *port;
+};
+
typedef union sockaddr_t {
struct sockaddr sa;
struct sockaddr_in in;
struct sockaddr_in6 in6;
+ struct sockaddr_unknown unknown;
#ifdef HAVE_STRUCT_SOCKADDR_STORAGE
struct sockaddr_storage storage;
#endif
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.38 2003/08/16 12:40:01 guus Exp $
+ $Id: net_packet.c,v 1.1.2.39 2003/08/22 11:18:42 guus Exp $
*/
#include "system.h"
void handle_incoming_vpn_data(int sock)
{
vpn_packet_t pkt;
- int x, l = sizeof(x);
char *hostname;
sockaddr_t from;
socklen_t fromlen = sizeof(from);
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.52 2003/08/03 12:38:43 guus Exp $
+ $Id: netutl.c,v 1.12.4.53 2003/08/22 11:18:42 guus Exp $
*/
#include "system.h"
err = getaddrinfo(address, port, &hint, &ai);
if(err || !ai) {
- logger(LOG_ERR, _("Error looking up %s port %s: %s"), address, port,
- gai_strerror(err));
- cp_trace();
- raise(SIGFPE);
- exit(0);
+ ifdebug(SCARY_THINGS)
+ logger(LOG_DEBUG, "Unknown type address %s port %s", address, port);
+ result.sa.sa_family = AF_UNKNOWN;
+ result.unknown.address = xstrdup(address);
+ result.unknown.port = xstrdup(port);
+ return result;
}
result = *(sockaddr_t *) ai->ai_addr;
cp();
+ if(sa->sa.sa_family == AF_UNKNOWN) {
+ *addrstr = xstrdup(sa->unknown.address);
+ *portstr = xstrdup(sa->unknown.port);
+ return;
+ }
+
err = getnameinfo(&sa->sa, SALEN(sa->sa), address, sizeof(address), port, sizeof(port), NI_NUMERICHOST | NI_NUMERICSERV);
if(err) {
cp();
+ if(sa->sa.sa_family == AF_UNKNOWN) {
+ asprintf(&str, _("%s port %s"), sa->unknown.address, sa->unknown.port);
+ return str;
+ }
+
err = getnameinfo(&sa->sa, SALEN(sa->sa), address, sizeof(address), port, sizeof(port),
hostnames ? 0 : (NI_NUMERICHOST | NI_NUMERICSERV));
if(err) {
case AF_UNSPEC:
return 0;
+ case AF_UNKNOWN:
+ result = strcmp(a->unknown.address, b->unknown.address);
+
+ if(result)
+ return result;
+
+ return strcmp(a->unknown.port, b->unknown.port);
+
case AF_INET:
result = memcmp(&a->in.sin_addr, &b->in.sin_addr, sizeof(a->in.sin_addr));
}
}
+void sockaddrcpy(sockaddr_t *a, const sockaddr_t *b) {
+ if(b->sa.sa_family != AF_UNKNOWN) {
+ *a = *b;
+ } else {
+ a->unknown.family = AF_UNKNOWN;
+ a->unknown.address = xstrdup(b->unknown.address);
+ a->unknown.port = xstrdup(b->unknown.port);
+ }
+}
+
+void sockaddrfree(sockaddr_t *a) {
+ if(a->sa.sa_family == AF_UNKNOWN) {
+ free(a->unknown.address);
+ free(a->unknown.port);
+ }
+}
+
void sockaddrunmap(sockaddr_t *sa)
{
if(sa->sa.sa_family == AF_INET6 && IN6_IS_ADDR_V4MAPPED(&sa->in6.sin6_addr)) {
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- $Id: netutl.h,v 1.2.4.18 2003/07/24 12:08:15 guus Exp $
+ $Id: netutl.h,v 1.2.4.19 2003/08/22 11:18:42 guus Exp $
*/
#ifndef __TINC_NETUTL_H__
extern char *sockaddr2hostname(const sockaddr_t *);
extern int sockaddrcmp(const sockaddr_t *, const sockaddr_t *);
extern void sockaddrunmap(sockaddr_t *);
+extern void sockaddrfree(sockaddr_t *);
+extern void sockaddrcpy(sockaddr_t *, const sockaddr_t *);
extern int maskcmp(const void *, const void *, int, int);
extern void maskcpy(void *, const void *, int, int);
extern void mask(void *, int, int);
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.26 2003/07/30 11:50:45 guus Exp $
+ $Id: node.c,v 1.1.2.27 2003/08/22 11:18:42 guus Exp $
*/
#include "system.h"
{
cp();
- node_tree = avl_alloc_tree((avl_compare_t) node_compare, NULL);
+ node_tree = avl_alloc_tree((avl_compare_t) node_compare, (avl_action_t) free_node);
node_udp_tree = avl_alloc_tree((avl_compare_t) node_udp_compare, NULL);
}
{
cp();
- avl_delete_tree(node_tree);
avl_delete_tree(node_udp_tree);
+ avl_delete_tree(node_tree);
}
node_t *new_node(void)
if(n->edge_tree)
free_edge_tree(n->edge_tree);
+ sockaddrfree(&n->address);
+
EVP_CIPHER_CTX_cleanup(&n->packet_ctx);
free(n);