f3119aa8b9fb0ac279afef5aa36ee99e81782ab9
[tinc] / src / protocol.h
1 /*
2     protocol.h -- header for protocol.c
3     Copyright (C) 1999,2000 Ivo Timmermans <itimmermans@bigfoot.com>,
4                        2000 Guus Sliepen <guus@sliepen.warande.net>
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: protocol.h,v 1.5.4.7 2000/09/11 10:05:35 guus Exp $
21 */
22
23 #ifndef __TINC_PROTOCOL_H__
24 #define __TINC_PROTOCOL_H__
25
26 #include "net.h"
27
28 /* Protocol version. Different versions are incompatible,
29    incompatible version have different protocols.
30  */
31
32 enum {
33   PROT_RESERVED = 0,                 /* reserved: do not use. */
34   PROT_NOT_IN_USE,
35   PROT_TOO_OLD = 2,
36   PROT_3,
37   PROT_4,
38   PROT_ECHELON,
39   PROT_6,
40   PROT_7,
41   PROT_CURRENT,                      /* protocol currently in use */
42 };
43
44 /* Request numbers */
45
46 enum {
47   ALL = -1,                          /* Guardian for allow_request */
48   ID = 0, CHALLENGE, CHAL_REPLY, ACK,
49   STATUS, ERROR, TERMREQ,
50   PING,  PONG,
51   ADD_HOST, DEL_HOST,
52   ADD_SUBNET, DEL_SUBNET,
53   KEY_CHANGED, REQ_KEY, ANS_KEY,
54   LAST                               /* Guardian for the highest request number */
55 };
56
57 extern int (*request_handlers[])(conn_list_t*);
58
59 extern int send_id(conn_list_t*);
60 extern int send_challenge(conn_list_t*);
61 extern int send_chal_reply(conn_list_t*, char*);
62 extern int send_ack(conn_list_t*);
63 extern int send_status(conn_list_t*, int, char*);
64 extern int send_error(conn_list_t*, int, char*);
65 extern int send_termreq(conn_list_t*);
66 extern int send_ping(conn_list_t*);
67 extern int send_pong(conn_list_t*);
68 extern int send_add_host(conn_list_t*, conn_list_t*);
69 extern int send_del_host(conn_list_t*, conn_list_t*);
70 extern int send_add_subnet(conn_list_t*, conn_list_t*, subnet_t*);
71 extern int send_del_subnet(conn_list_t*, conn_list_t*, subnet_t*);
72 extern int send_key_changed(conn_list_t*, conn_list_t*);
73 extern int send_req_key(conn_list_t*, conn_list_t*);
74 extern int send_ans_key(conn_list_t*, conn_list_t*, char*);
75
76 /* Old functions */
77
78 extern int send_tcppacket(conn_list_t *, void *, int);
79 extern int notify_others(conn_list_t *, conn_list_t *, int (*function)(conn_list_t*, conn_list_t*));
80
81 #endif /* __TINC_PROTOCOL_H__ */
82
83