- Lots o' buglets fixed (-Wall helps)
[tinc] / src / protocol.h
1 /*
2     protocol.h -- header for protocol.c
3     Copyright (C) 1999,2000 Ivo Timmermans <zarq@iname.com>
4
5     This program is free software; you can redistribute it and/or modify
6     it under the terms of the GNU General Public License as published by
7     the Free Software Foundation; either version 2 of the License, or
8     (at your option) any later version.
9
10     This program is distributed in the hope that it will be useful,
11     but WITHOUT ANY WARRANTY; without even the implied warranty of
12     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13     GNU General Public License for more details.
14
15     You should have received a copy of the GNU General Public License
16     along with this program; if not, write to the Free Software
17     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18
19     $Id: protocol.h,v 1.5.4.5 2000/08/07 16:27:29 guus Exp $
20 */
21
22 #ifndef __TINC_PROTOCOL_H__
23 #define __TINC_PROTOCOL_H__
24
25 #include "net.h"
26
27 enum {
28   PROT_RESERVED = 0,                 /* reserved: do not use. */
29   PROT_NOT_IN_USE,
30   PROT_TOO_OLD = 2,
31   PROT_3,
32   PROT_4,
33   PROT_ECHELON,
34   PROT_6,
35   PROT_CURRENT,                      /* protocol currently in use */
36 };
37
38 enum {
39   ACK = 1,              /* acknowledged */
40   AUTH_S_INIT = 10,     /* initiate authentication */
41   AUTH_C_INIT,
42   AUTH_S_SPP,           /* send passphrase */
43   AUTH_C_SPP,
44   AUTH_S_SKEY,          /* send g^k */
45   AUTH_C_SKEY,
46   AUTH_S_SACK,          /* send ack */
47   AUTH_C_RACK,          /* waiting for ack */
48   TERMREQ = 30,         /* terminate connection */
49   PINGTIMEOUT,          /* terminate due to ping t.o. */
50   DEL_HOST,             /* forward a termreq to others */
51   PING = 40,            /* ping */
52   PONG,
53   ADD_HOST = 60,        /* Add new given host to connection list */
54   BASIC_INFO,           /* some basic info follows */
55   PASSPHRASE,           /* encrypted passphrase */
56   PUBLIC_KEY,           /* public key in base-36 */
57   HOLD = 80,            /* don't send any data */
58   RESUME,               /* resume dataflow with new encryption key */
59   CALCULATE = 100,      /* calculate the following numer^privkey and send me the result */  
60   CALC_RES,             /* result of the above */
61   ALMOST_KEY,           /* this number^privkey is the shared key */
62   PACKET = 110,         /* TCP tunneled network packet */
63   REQ_KEY = 160,        /* request public key */
64   ANS_KEY,              /* answer to such request */
65   KEY_CHANGED,          /* public key has changed */
66 };
67
68 extern int (*request_handlers[256])(conn_list_t*);
69
70 extern int send_ping(conn_list_t*);
71 extern int send_basic_info(conn_list_t *);
72 extern int send_termreq(conn_list_t *);
73 extern int send_timeout(conn_list_t *);
74 extern int send_key_request(ip_t);
75 extern void send_key_changed_all(void);
76 extern int send_del_host(conn_list_t *, conn_list_t *);
77 extern int send_tcppacket(conn_list_t *, void *, int);
78 extern int notify_others(conn_list_t *, conn_list_t *, int (*function)(conn_list_t*, conn_list_t*));
79
80 #endif /* __TINC_PROTOCOL_H__ */
81
82