- Updated subnet list handling. Subnets are added to two lists now, the
[tinc] / src / connlist.h
1 /*
2     connlist.h -- header for connlist.c
3     Copyright (C) 2000 Guus Sliepen <guus@sliepen.warande.net>,
4                   2000 Ivo Timmermans <itimmermans@bigfoot.com>
5
6     This program is free software; you can redistribute it and/or modify
7     it under the terms of the GNU General Public License as published by
8     the Free Software Foundation; either version 2 of the License, or
9     (at your option) any later version.
10
11     This program is distributed in the hope that it will be useful,
12     but WITHOUT ANY WARRANTY; without even the implied warranty of
13     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14     GNU General Public License for more details.
15
16     You should have received a copy of the GNU General Public License
17     along with this program; if not, write to the Free Software
18     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19
20     $Id: connlist.h,v 1.1.2.5 2000/10/28 16:41:37 guus Exp $
21 */
22
23 #ifndef __TINC_CONNLIST_H__
24 #define __TINC_CONNLIST_H__
25
26 #include <openssl/evp.h>
27 #include <openssl/rsa.h>
28
29 #include "net.h"
30 #include "conf.h"
31
32 typedef struct conn_list_t {
33   char *name;                      /* name of this connection */
34   ipv4_t address;                    /* his real (internet) ip */
35   char *hostname;                  /* the hostname of its real ip */
36   short unsigned int port;         /* his portnumber */
37   int protocol_version;            /* used protocol */
38   int options;                     /* options turned on for this connection */
39
40   int flags;                       /* his flags */
41   int socket;                      /* our udp vpn socket */
42   int meta_socket;                 /* our tcp meta socket */
43   status_bits_t status;            /* status info */
44   packet_queue_t *sq;              /* pending outgoing packets */
45   packet_queue_t *rq;              /* pending incoming packets (they have no
46                                       valid key to be decrypted with) */
47   RSA *rsa_key;                    /* the public/private key */
48
49   EVP_CIPHER_CTX *cipher_inctx;    /* Context of encrypted meta data that will come from him to us */
50   EVP_CIPHER_CTX *cipher_outctx;   /* Context of encrypted meta data that will be sent from us to him */
51
52   EVP_CIPHER_CTX *cipher_pktctx;   /* Context of encrypted vpn packets that will be sent to him */
53   EVP_CIPHER *cipher_pkttype;      /* Cipher type for encrypted vpn packets */ 
54   char *cipher_pktkey;             /* Cipher key */
55
56   char *buffer;                    /* metadata input buffer */
57   int buflen;                      /* bytes read into buffer */
58   int reqlen;                      /* length of first request in buffer */
59   int allow_request;               /* defined if there's only one request possible */
60
61   time_t last_ping_time;           /* last time we saw some activity from the other end */  
62   int want_ping;                   /* 0 if there's no need to check for activity. Shouldn't this go into status? (GS) */
63
64   char *mychallenge;               /* challenge we received from him */
65   char *hischallenge;              /* challenge we sent to him */
66
67   struct conn_list_t *nexthop;     /* nearest meta-hop in this direction, will be changed to myuplink (GS) */
68   struct conn_list_t *hisuplink;   /* his nearest meta-hop in our direction */
69   struct conn_list_t *myuplink;    /* our nearest meta-hop in his direction */
70
71   struct subnet_t *subnets;        /* Pointer to a list of subnets belonging to this connection */
72
73   struct config_t *config;         /* Pointer to configuration tree belonging to this host */
74
75   struct conn_list_t *next;        /* after all, it's a list of connections */
76   struct conn_list_t *prev;        /* doubly linked for O(1) deletions */
77 } conn_list_t;
78
79 #include "subnet.h"
80
81 extern conn_list_t *conn_list;
82 extern conn_list_t *myself;
83
84 extern conn_list_t *new_conn_list();
85 extern void free_conn_list(conn_list_t *);
86 extern void add_conn_list(conn_list_t *);
87 extern void del_conn_list(conn_list_t *);
88 extern conn_list_t *lookup_id(char *);
89 extern void dump_conn_list(void);
90 extern int read_host_config(conn_list_t *);
91
92 #endif /* __TINC_CONNLIST_H__ */