Prevent definitions from messing up attributes.
[tinc] / src / protocol.h
1 /*
2     protocol.h -- header for protocol.c
3     Copyright (C) 1999-2001 Ivo Timmermans <ivo@o2w.nl>,
4                   2000,2001 Guus Sliepen <guus@sliepen.eu.org>
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.44 2003/07/30 21:52:41 guus Exp $
21 */
22
23 #ifndef __TINC_PROTOCOL_H__
24 #define __TINC_PROTOCOL_H__
25
26 /* Protocol version. Different versions are incompatible,
27    incompatible version have different protocols.
28  */
29
30 #define PROT_CURRENT 17
31
32 /* Silly Windows */
33
34 #ifdef ERROR
35 #undef ERROR
36 #endif
37
38 /* Request numbers */
39
40 typedef enum request_t {
41         ALL = -1,                                       /* Guardian for allow_request */
42         ID = 0, METAKEY, CHALLENGE, CHAL_REPLY, ACK,
43         STATUS, ERROR, TERMREQ,
44         PING, PONG,
45         ADD_SUBNET, DEL_SUBNET,
46         ADD_EDGE, DEL_EDGE,
47         KEY_CHANGED, REQ_KEY, ANS_KEY,
48         PACKET,
49         LAST                                            /* Guardian for the highest request number */
50 } request_t;
51
52 typedef struct past_request_t {
53         char *request;
54         time_t firstseen;
55 } past_request_t;
56
57 /* Maximum size of strings in a request */
58
59 #define MAX_STRING_SIZE 2048
60 #define MAX_STRING "%2048s"
61
62 #include "edge.h"
63 #include "net.h"
64 #include "node.h"
65 #include "subnet.h"
66
67 /* Basic functions */
68
69 extern bool send_request(struct connection_t *, const char *, ...) __attribute__ ((__format__(printf, 2, 3)));
70 extern void forward_request(struct connection_t *);
71 extern bool receive_request(struct connection_t *);
72 extern bool check_id(const char *);
73
74 extern void init_requests(void);
75 extern void exit_requests(void);
76 extern bool seen_request(char *);
77 extern void age_past_requests(void);
78
79 /* Requests */
80
81 extern bool send_id(struct connection_t *);
82 extern bool send_metakey(struct connection_t *);
83 extern bool send_challenge(struct connection_t *);
84 extern bool send_chal_reply(struct connection_t *);
85 extern bool send_ack(struct connection_t *);
86 extern bool send_status(struct connection_t *, int, const char *);
87 extern bool send_error(struct connection_t *, int,const  char *);
88 extern bool send_termreq(struct connection_t *);
89 extern bool send_ping(struct connection_t *);
90 extern bool send_pong(struct connection_t *);
91 extern bool send_add_subnet(struct connection_t *, const struct subnet_t *);
92 extern bool send_del_subnet(struct connection_t *, const struct subnet_t *);
93 extern bool send_add_edge(struct connection_t *, const struct edge_t *);
94 extern bool send_del_edge(struct connection_t *, const struct edge_t *);
95 extern bool send_key_changed(struct connection_t *, const struct node_t *);
96 extern bool send_req_key(struct connection_t *, const struct node_t *, const struct node_t *);
97 extern bool send_ans_key(struct connection_t *, const struct node_t *, const struct node_t *);
98 extern bool send_tcppacket(struct connection_t *, struct vpn_packet_t *);
99
100 /* Request handlers  */
101
102 extern bool id_h(struct connection_t *);
103 extern bool metakey_h(struct connection_t *);
104 extern bool challenge_h(struct connection_t *);
105 extern bool chal_reply_h(struct connection_t *);
106 extern bool ack_h(struct connection_t *);
107 extern bool status_h(struct connection_t *);
108 extern bool error_h(struct connection_t *);
109 extern bool termreq_h(struct connection_t *);
110 extern bool ping_h(struct connection_t *);
111 extern bool pong_h(struct connection_t *);
112 extern bool add_subnet_h(struct connection_t *);
113 extern bool del_subnet_h(struct connection_t *);
114 extern bool add_edge_h(struct connection_t *);
115 extern bool del_edge_h(struct connection_t *);
116 extern bool key_changed_h(struct connection_t *);
117 extern bool req_key_h(struct connection_t *);
118 extern bool ans_key_h(struct connection_t *);
119 extern bool tcppacket_h(struct connection_t *);
120
121 #endif                                                  /* __TINC_PROTOCOL_H__ */