Ensure all parameters have names in header files.
[oweals/tinc.git] / 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-2017 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 #include "ecdsa.h"
25
26 /* Protocol version. Different major versions are incompatible. */
27
28 #define PROT_MAJOR 17
29 #define PROT_MINOR 7 /* Should not exceed 255! */
30
31 /* Silly Windows */
32
33 #ifdef ERROR
34 #undef ERROR
35 #endif
36
37 /* Request numbers */
38
39 typedef enum request_t {
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         /* Tinc 1.1 requests */
49         CONTROL,
50         REQ_PUBKEY, ANS_PUBKEY,
51         SPTPS_PACKET,
52         UDP_INFO, MTU_INFO,
53         LAST                                            /* Guardian for the highest request number */
54 } request_t;
55
56 typedef struct past_request_t {
57         const char *request;
58         time_t firstseen;
59 } past_request_t;
60
61 extern bool tunnelserver;
62 extern bool strictsubnets;
63 extern bool experimental;
64
65 extern int invitation_lifetime;
66 extern ecdsa_t *invitation_key;
67
68 /* Maximum size of strings in a request.
69  * scanf terminates %2048s with a NUL character,
70  * but the NUL character can be written after the 2048th non-NUL character.
71  */
72
73 #define MAX_STRING_SIZE 2049
74 #define MAX_STRING "%2048s"
75
76 #include "edge.h"
77 #include "net.h"
78 #include "node.h"
79 #include "subnet.h"
80
81 /* Basic functions */
82
83 extern bool send_request(struct connection_t *c, const char *format, ...) __attribute__((__format__(printf, 2, 3)));
84 extern void forward_request(struct connection_t *c, const char *request);
85 extern bool receive_request(struct connection_t *c, const char *request);
86
87 extern void init_requests(void);
88 extern void exit_requests(void);
89 extern bool seen_request(const char *request);
90
91 /* Requests */
92
93 extern bool send_id(struct connection_t *c);
94 extern bool send_metakey(struct connection_t *c);
95 extern bool send_metakey_ec(struct connection_t *c);
96 extern bool send_challenge(struct connection_t *c);
97 extern bool send_chal_reply(struct connection_t *c);
98 extern bool send_ack(struct connection_t *c);
99 extern bool send_termreq(struct connection_t *c);
100 extern bool send_ping(struct connection_t *c);
101 extern bool send_pong(struct connection_t *c);
102 extern bool send_add_subnet(struct connection_t *c, const struct subnet_t *subnet);
103 extern bool send_del_subnet(struct connection_t *c, const struct subnet_t *subnet);
104 extern bool send_add_edge(struct connection_t *c, const struct edge_t *e);
105 extern bool send_del_edge(struct connection_t *c, const struct edge_t *e);
106 extern void send_key_changed(void);
107 extern bool send_req_key(struct node_t *to);
108 extern bool send_ans_key(struct node_t *to);
109 extern bool send_tcppacket(struct connection_t *c, const struct vpn_packet_t *packet);
110 extern bool send_sptps_tcppacket(struct connection_t *c, const char *packet, int len);
111 extern bool send_udp_info(struct node_t *from, struct node_t *to);
112 extern bool send_mtu_info(struct node_t *from, struct node_t *to, int mtu);
113
114 /* Request handlers  */
115
116 extern bool id_h(struct connection_t *c, const char *request);
117 extern bool metakey_h(struct connection_t *c, const char *request);
118 extern bool challenge_h(struct connection_t *c, const char *request);
119 extern bool chal_reply_h(struct connection_t *c, const char *request);
120 extern bool ack_h(struct connection_t *c, const char *request);
121 extern bool status_h(struct connection_t *c, const char *request);
122 extern bool error_h(struct connection_t *c, const char *request);
123 extern bool termreq_h(struct connection_t *c, const char *request);
124 extern bool ping_h(struct connection_t *c, const char *request);
125 extern bool pong_h(struct connection_t *c, const char *request);
126 extern bool add_subnet_h(struct connection_t *c, const char *request);
127 extern bool del_subnet_h(struct connection_t *c, const char *request);
128 extern bool add_edge_h(struct connection_t *c, const char *request);
129 extern bool del_edge_h(struct connection_t *c, const char *request);
130 extern bool key_changed_h(struct connection_t *c, const char *request);
131 extern bool req_key_h(struct connection_t *c, const char *request);
132 extern bool ans_key_h(struct connection_t *c, const char *request);
133 extern bool tcppacket_h(struct connection_t *c, const char *request);
134 extern bool sptps_tcppacket_h(struct connection_t *c, const char *request);
135 extern bool control_h(struct connection_t *c, const char *request);
136 extern bool udp_info_h(struct connection_t *c, const char *request);
137 extern bool mtu_info_h(struct connection_t *c, const char *request);
138
139 #endif