Fix spelling errors.
[tinc] / src / protocol.h
1 #ifndef TINC_PROTOCOL_H
2 #define TINC_PROTOCOL_H
3
4 /*
5     protocol.h -- header for protocol.c
6     Copyright (C) 1999-2005 Ivo Timmermans,
7                   2000-2015 Guus Sliepen <guus@tinc-vpn.org>
8
9     This program is free software; you can redistribute it and/or modify
10     it under the terms of the GNU General Public License as published by
11     the Free Software Foundation; either version 2 of the License, or
12     (at your option) any later version.
13
14     This program is distributed in the hope that it will be useful,
15     but WITHOUT ANY WARRANTY; without even the implied warranty of
16     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17     GNU General Public License for more details.
18
19     You should have received a copy of the GNU General Public License along
20     with this program; if not, write to the Free Software Foundation, Inc.,
21     51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
22 */
23
24 /* Protocol version. Different versions are incompatible,
25    incompatible version have different protocols.
26  */
27
28 #define PROT_CURRENT 17
29
30 /* Silly Windows */
31
32 #ifdef ERROR
33 #undef ERROR
34 #endif
35
36 /* Request numbers */
37
38 typedef enum request_t {
39         PROXY = -2,
40         ALL = -1,                                       /* Guardian for allow_request */
41         ID = 0, METAKEY, CHALLENGE, CHAL_REPLY, ACK,
42         STATUS, ERROR, TERMREQ,
43         PING, PONG,
44         ADD_SUBNET, DEL_SUBNET,
45         ADD_EDGE, DEL_EDGE,
46         KEY_CHANGED, REQ_KEY, ANS_KEY,
47         PACKET,
48         LAST                                            /* Guardian for the highest request number */
49 } request_t;
50
51 typedef struct past_request_t {
52         char *request;
53         time_t firstseen;
54 } past_request_t;
55
56 extern bool tunnelserver;
57 extern bool strictsubnets;
58
59 /* Maximum size of strings in a request.
60  * scanf terminates %2048s with a NUL character,
61  * but the NUL character can be written after the 2048th non-NUL character.
62  */
63
64 #define MAX_STRING_SIZE 2049
65 #define MAX_STRING "%2048s"
66
67 #include "edge.h"
68 #include "net.h"
69 #include "node.h"
70 #include "subnet.h"
71
72 /* Basic functions */
73
74 extern bool send_request(struct connection_t *c, const char *format, ...) __attribute__((__format__(printf, 2, 3)));
75 extern void forward_request(struct connection_t *c);
76 extern bool receive_request(struct connection_t *c);
77 extern bool check_id(const char *name);
78
79 extern void init_requests(void);
80 extern void exit_requests(void);
81 extern bool seen_request(char *request);
82 extern void age_past_requests(void);
83
84 /* Requests */
85
86 extern bool send_id(struct connection_t *c);
87 extern bool send_metakey(struct connection_t *c);
88 extern bool send_challenge(struct connection_t *c);
89 extern bool send_chal_reply(struct connection_t *c);
90 extern bool send_ack(struct connection_t *c);
91 extern bool send_ping(struct connection_t *c);
92 extern bool send_pong(struct connection_t *c);
93 extern bool send_add_subnet(struct connection_t *c, const struct subnet_t *subnet);
94 extern bool send_del_subnet(struct connection_t *c, const struct subnet_t *subnet);
95 extern bool send_add_edge(struct connection_t *c, const struct edge_t *e);
96 extern bool send_del_edge(struct connection_t *c, const struct edge_t *e);
97 extern void send_key_changed(void);
98 extern bool send_req_key(struct node_t *n);
99 extern bool send_ans_key(struct node_t *n);
100 extern bool send_tcppacket(struct connection_t *c, const struct vpn_packet_t *packet);
101
102 /* Request handlers  */
103
104 extern bool id_h(struct connection_t *c);
105 extern bool metakey_h(struct connection_t *c);
106 extern bool challenge_h(struct connection_t *c);
107 extern bool chal_reply_h(struct connection_t *c);
108 extern bool ack_h(struct connection_t *c);
109 extern bool ping_h(struct connection_t *c);
110 extern bool pong_h(struct connection_t *c);
111 extern bool add_subnet_h(struct connection_t *c);
112 extern bool del_subnet_h(struct connection_t *c);
113 extern bool add_edge_h(struct connection_t *c);
114 extern bool del_edge_h(struct connection_t *c);
115 extern bool key_changed_h(struct connection_t *c);
116 extern bool req_key_h(struct connection_t *c);
117 extern bool ans_key_h(struct connection_t *c);
118 extern bool tcppacket_h(struct connection_t *c);
119
120 #endif