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.12 2000/11/04 20:44:26 guus 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 meta:1; /* meta connection exists */
35 int active:1; /* 1 if active.. */
36 int outgoing:1; /* I myself asked for this conn */
37 int termreq:1; /* the termination of this connection was requested */
38 int remove:1; /* Set to 1 if you want this connection removed */
39 int timeout:1; /* 1 if gotten timeout */
40 int validkey:1; /* 1 if we currently have a valid key for him */
41 int waitingforkey:1; /* 1 if we already sent out a request */
42 int dataopen:1; /* 1 if we have a valid UDP connection open */
43 int encryptout:1; /* 1 if we can encrypt outgoing traffic */
44 int decryptin:1; /* 1 if we have to decrypt incoming traffic */
48 typedef struct option_bits_t {
52 typedef struct conn_list_t {
53 char *name; /* name of this connection */
54 ipv4_t address; /* his real (internet) ip */
55 char *hostname; /* the hostname of its real ip */
56 short unsigned int port; /* his portnumber */
57 int protocol_version; /* used protocol */
58 long unsigned int options; /* options turned on for this connection */
60 int flags; /* his flags */
61 int socket; /* our udp vpn socket */
62 int meta_socket; /* our tcp meta socket */
63 status_bits_t status; /* status info */
64 packet_queue_t *sq; /* pending outgoing packets */
65 packet_queue_t *rq; /* pending incoming packets (they have no
66 valid key to be decrypted with) */
67 RSA *rsa_key; /* the public/private key */
69 EVP_CIPHER_CTX *cipher_inctx; /* Context of encrypted meta data that will come from him to us */
70 EVP_CIPHER_CTX *cipher_outctx; /* Context of encrypted meta data that will be sent from us to him */
71 char *cipher_inkey; /* His symmetric meta key */
72 char *cipher_outkey; /* Our symmetric meta key */
74 EVP_CIPHER *cipher_pkttype; /* Cipher type for encrypted vpn packets */
75 char *cipher_pktkey; /* Cipher key and iv */
76 int cipher_pktkeylength; /* Cipher key and iv length*/
78 char *buffer; /* metadata input buffer */
79 int buflen; /* bytes read into buffer */
80 int reqlen; /* length of first request in buffer */
81 int allow_request; /* defined if there's only one request possible */
83 time_t last_ping_time; /* last time we saw some activity from the other end */
85 char *mychallenge; /* challenge we received from him */
86 char *hischallenge; /* challenge we sent to him */
88 struct conn_list_t *nexthop; /* nearest meta-hop in this direction */
90 struct subnet_t *subnets; /* Pointer to a list of subnets belonging to this connection */
92 struct config_t *config; /* Pointer to configuration tree belonging to this host */
94 struct conn_list_t *next; /* after all, it's a list of connections */
95 struct conn_list_t *prev; /* doubly linked for O(1) deletions */
100 extern conn_list_t *conn_list;
101 extern conn_list_t *myself;
103 extern conn_list_t *new_conn_list();
104 extern void free_conn_list(conn_list_t *);
105 extern void conn_list_add(conn_list_t *);
106 extern void conn_list_del(conn_list_t *);
107 extern conn_list_t *lookup_id(char *);
108 extern void dump_conn_list(void);
109 extern int read_host_config(conn_list_t *);
110 extern void destroy_conn_list(void);
111 extern void prune_conn_list(void);
113 #endif /* __TINC_CONNLIST_H__ */