protocol.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. /*
  2. protocol.h -- header for protocol.c
  3. Copyright (C) 1999-2001 Ivo Timmermans <itimmermans@bigfoot.com>,
  4. 2000,2001 Guus Sliepen <guus@sliepen.warande.net>
  5. This program is free software; you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation; either version 2 of the License, or
  8. (at your option) any later version.
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with this program; if not, write to the Free Software
  15. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  16. $Id: protocol.h,v 1.5.4.25 2002/02/10 21:57:54 guus Exp $
  17. */
  18. #ifndef __TINC_PROTOCOL_H__
  19. #define __TINC_PROTOCOL_H__
  20. #include "net.h"
  21. #include "node.h"
  22. #include "subnet.h"
  23. /* Protocol version. Different versions are incompatible,
  24. incompatible version have different protocols.
  25. */
  26. #define PROT_CURRENT 12
  27. /* Request numbers */
  28. enum {
  29. ALL = -1, /* Guardian for allow_request */
  30. ID = 0, METAKEY, CHALLENGE, CHAL_REPLY, ACK,
  31. STATUS, ERROR, TERMREQ,
  32. PING, PONG,
  33. // ADD_NODE, DEL_NODE,
  34. ADD_SUBNET, DEL_SUBNET,
  35. ADD_EDGE, DEL_EDGE,
  36. KEY_CHANGED, REQ_KEY, ANS_KEY,
  37. PACKET,
  38. LAST /* Guardian for the highest request number */
  39. };
  40. /* Maximum size of strings in a request */
  41. #define MAX_STRING_SIZE 1024
  42. #define MAX_STRING "%1024s"
  43. /* Basic functions */
  44. extern int send_request(connection_t*, const char*, ...);
  45. extern int receive_request(connection_t *);
  46. extern int check_id(char *);
  47. /* Requests */
  48. extern int send_id(connection_t *);
  49. extern int send_metakey(connection_t *);
  50. extern int send_challenge(connection_t *);
  51. extern int send_chal_reply(connection_t *);
  52. extern int send_ack(connection_t *);
  53. extern int send_status(connection_t *, int, char *);
  54. extern int send_error(connection_t *, int, char *);
  55. extern int send_termreq(connection_t *);
  56. extern int send_ping(connection_t *);
  57. extern int send_pong(connection_t *);
  58. // extern int send_add_node(connection_t *, node_t *);
  59. // extern int send_del_node(connection_t *, node_t *);
  60. extern int send_add_subnet(connection_t *, subnet_t *);
  61. extern int send_del_subnet(connection_t *, subnet_t *);
  62. extern int send_add_edge(connection_t *, edge_t *);
  63. extern int send_del_edge(connection_t *, edge_t *);
  64. extern int send_key_changed(connection_t *, node_t *);
  65. extern int send_req_key(connection_t *, node_t *, node_t *);
  66. extern int send_ans_key(connection_t *, node_t *, node_t *);
  67. extern int send_tcppacket(connection_t *, vpn_packet_t *);
  68. /* Request handlers */
  69. extern int (*request_handlers[])(connection_t *);
  70. extern int id_h(connection_t *);
  71. extern int metakey_h(connection_t *);
  72. extern int challenge_h(connection_t *);
  73. extern int chal_reply_h(connection_t *);
  74. extern int ack_h(connection_t *);
  75. extern int status_h(connection_t *);
  76. extern int error_h(connection_t *);
  77. extern int termreq_h(connection_t *);
  78. extern int ping_h(connection_t *);
  79. extern int pong_h(connection_t *);
  80. // extern int add_node_h(connection_t *);
  81. // extern int del_node_h(connection_t *);
  82. extern int add_subnet_h(connection_t *);
  83. extern int del_subnet_h(connection_t *);
  84. extern int add_edge_h(connection_t *);
  85. extern int del_edge_h(connection_t *);
  86. extern int key_changed_h(connection_t *);
  87. extern int req_key_h(connection_t *);
  88. extern int ans_key_h(connection_t *);
  89. extern int tcppacket_h(connection_t *);
  90. #endif /* __TINC_PROTOCOL_H__ */