2 protocol.h -- header for protocol.c
3 Copyright (C) 1999-2005 Ivo Timmermans,
4 2000-2013 Guus Sliepen <guus@tinc-vpn.org>
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 along
17 with this program; if not, write to the Free Software Foundation, Inc.,
18 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21 #ifndef __TINC_PROTOCOL_H__
22 #define __TINC_PROTOCOL_H__
26 /* Protocol version. Different major versions are incompatible. */
29 #define PROT_MINOR 4 /* Should not exceed 255! */
39 typedef enum request_t {
40 ALL = -1, /* Guardian for allow_request */
41 ID = 0, METAKEY, CHALLENGE, CHAL_REPLY, ACK,
42 STATUS, ERROR, TERMREQ,
44 ADD_SUBNET, DEL_SUBNET,
46 KEY_CHANGED, REQ_KEY, ANS_KEY,
48 /* Tinc 1.1 requests */
50 REQ_PUBKEY, ANS_PUBKEY,
52 LAST /* Guardian for the highest request number */
55 typedef struct past_request_t {
60 extern bool tunnelserver;
61 extern bool strictsubnets;
62 extern bool experimental;
64 extern ecdsa_t *invitation_key;
66 /* Maximum size of strings in a request.
67 * scanf terminates %2048s with a NUL character,
68 * but the NUL character can be written after the 2048th non-NUL character.
71 #define MAX_STRING_SIZE 2049
72 #define MAX_STRING "%2048s"
81 extern bool send_request(struct connection_t *, const char *, ...) __attribute__ ((__format__(printf, 2, 3)));
82 extern void forward_request(struct connection_t *, const char *);
83 extern bool receive_request(struct connection_t *, const char *);
85 extern void init_requests(void);
86 extern void exit_requests(void);
87 extern bool seen_request(const char *);
91 extern bool send_id(struct connection_t *);
92 extern bool send_metakey(struct connection_t *);
93 extern bool send_metakey_ec(struct connection_t *);
94 extern bool send_challenge(struct connection_t *);
95 extern bool send_chal_reply(struct connection_t *);
96 extern bool send_ack(struct connection_t *);
97 extern bool send_status(struct connection_t *, int, const char *);
98 extern bool send_error(struct connection_t *, int, const char *);
99 extern bool send_termreq(struct connection_t *);
100 extern bool send_ping(struct connection_t *);
101 extern bool send_pong(struct connection_t *);
102 extern bool send_add_subnet(struct connection_t *, const struct subnet_t *);
103 extern bool send_del_subnet(struct connection_t *, const struct subnet_t *);
104 extern bool send_add_edge(struct connection_t *, const struct edge_t *);
105 extern bool send_del_edge(struct connection_t *, const struct edge_t *);
106 extern void send_key_changed(void);
107 extern bool send_req_key(struct node_t *);
108 extern bool send_ans_key(struct node_t *);
109 extern bool send_tcppacket(struct connection_t *, const struct vpn_packet_t *);
111 /* Request handlers */
113 extern bool id_h(struct connection_t *, const char *);
114 extern bool metakey_h(struct connection_t *, const char *);
115 extern bool challenge_h(struct connection_t *, const char *);
116 extern bool chal_reply_h(struct connection_t *, const char *);
117 extern bool ack_h(struct connection_t *, const char *);
118 extern bool status_h(struct connection_t *, const char *);
119 extern bool error_h(struct connection_t *, const char *);
120 extern bool termreq_h(struct connection_t *, const char *);
121 extern bool ping_h(struct connection_t *, const char *);
122 extern bool pong_h(struct connection_t *, const char *);
123 extern bool add_subnet_h(struct connection_t *, const char *);
124 extern bool del_subnet_h(struct connection_t *, const char *);
125 extern bool add_edge_h(struct connection_t *, const char *);
126 extern bool del_edge_h(struct connection_t *, const char *);
127 extern bool key_changed_h(struct connection_t *, const char *);
128 extern bool req_key_h(struct connection_t *, const char *);
129 extern bool ans_key_h(struct connection_t *, const char *);
130 extern bool tcppacket_h(struct connection_t *, const char *);
131 extern bool control_h(struct connection_t *, const char *);
133 #endif /* __TINC_PROTOCOL_H__ */