2 connlist.h -- header for connlist.c
3 Copyright (C) 2000 Guus Sliepen <guus@sliepen.warande.net>,
4 2000 Ivo Timmermans <itimmermans@bigfoot.com>
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.
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.
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.
20 $Id: connlist.h,v 1.1.2.10 2000/11/03 22:35:10 zarq Exp $
23 #ifndef __TINC_CONNLIST_H__
24 #define __TINC_CONNLIST_H__
26 #include <openssl/evp.h>
27 #include <openssl/rsa.h>
32 typedef struct status_bits_t {
33 int pinged:1; /* sent ping */
34 int got_pong:1; /* received pong */
35 int meta:1; /* meta connection exists */
36 int active:1; /* 1 if active.. */
37 int outgoing:1; /* I myself asked for this conn */
38 int termreq:1; /* the termination of this connection was requested */
39 int remove:1; /* Set to 1 if you want this connection removed */
40 int timeout:1; /* 1 if gotten timeout */
41 int validkey:1; /* 1 if we currently have a valid key for him */
42 int waitingforkey:1; /* 1 if we already sent out a request */
43 int dataopen:1; /* 1 if we have a valid UDP connection open */
44 int encryptout:1; /* 1 if we can encrypt outgoing traffic */
45 int decryptin:1; /* 1 if we have to decrypt incoming traffic */
49 typedef struct option_bits_t {
53 typedef struct conn_list_t {
54 char *name; /* name of this connection */
55 ipv4_t address; /* his real (internet) ip */
56 char *hostname; /* the hostname of its real ip */
57 short unsigned int port; /* his portnumber */
58 int protocol_version; /* used protocol */
59 long int options; /* options turned on for this connection */
61 int flags; /* his flags */
62 int socket; /* our udp vpn socket */
63 int meta_socket; /* our tcp meta socket */
64 status_bits_t status; /* status info */
65 packet_queue_t *sq; /* pending outgoing packets */
66 packet_queue_t *rq; /* pending incoming packets (they have no
67 valid key to be decrypted with) */
68 RSA *rsa_key; /* the public/private key */
70 EVP_CIPHER_CTX *cipher_inctx; /* Context of encrypted meta data that will come from him to us */
71 EVP_CIPHER_CTX *cipher_outctx; /* Context of encrypted meta data that will be sent from us to him */
72 char *cipher_inkey; /* His symmetric meta key */
73 char *cipher_outkey; /* Our symmetric meta key */
75 EVP_CIPHER *cipher_pkttype; /* Cipher type for encrypted vpn packets */
76 char *cipher_pktkey; /* Cipher key and iv */
77 int cipher_pktkeylength; /* Cipher key and iv length*/
79 char *buffer; /* metadata input buffer */
80 int buflen; /* bytes read into buffer */
81 int reqlen; /* length of first request in buffer */
82 int allow_request; /* defined if there's only one request possible */
84 time_t last_ping_time; /* last time we saw some activity from the other end */
85 int want_ping; /* 0 if there's no need to check for activity. Shouldn't this go into status? (GS) */
87 char *mychallenge; /* challenge we received from him */
88 char *hischallenge; /* challenge we sent to him */
90 struct conn_list_t *nexthop; /* nearest meta-hop in this direction */
92 struct subnet_t *subnets; /* Pointer to a list of subnets belonging to this connection */
94 struct config_t *config; /* Pointer to configuration tree belonging to this host */
96 struct conn_list_t *next; /* after all, it's a list of connections */
97 struct conn_list_t *prev; /* doubly linked for O(1) deletions */
102 extern conn_list_t *conn_list;
103 extern conn_list_t *myself;
105 extern conn_list_t *new_conn_list();
106 extern void free_conn_list(conn_list_t *);
107 extern void conn_list_add(conn_list_t *);
108 extern void conn_list_del(conn_list_t *);
109 extern conn_list_t *lookup_id(char *);
110 extern void dump_conn_list(void);
111 extern int read_host_config(conn_list_t *);
112 extern void destroy_conn_list(void);
113 extern void prune_conn_list(void);
115 #endif /* __TINC_CONNLIST_H__ */