pconfig.h 3.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. #ifndef PCONFIG_H
  2. #define PCONFIG_H 1
  3. enum {
  4. /** Ping tunnel's operating mode (client) */
  5. kMode_forward = 0,
  6. /** Ping tunnel's operating mode (server) */
  7. kMode_proxy,
  8. /** Set this constant to the number of
  9. * concurrent connections you wish to handle by default.
  10. */
  11. kMax_tunnels = 10,
  12. /** Different verbosity levels. */
  13. kNo_log = -1,
  14. kLog_error = 0,
  15. kLog_info,
  16. kLog_event,
  17. kLog_verbose,
  18. kLog_debug,
  19. kLog_sendrecv,
  20. /** Major (0.xx) and minor (x.70) version */
  21. kMajor_version = 0,
  22. /** numbers */
  23. kMinor_version = 72,
  24. kIP_packet_max_size = 576,
  25. /** In bytes, mind you */
  26. kIP_header_size = 20,
  27. kIP_actual_size = (kIP_packet_max_size - kIP_header_size) - ((kIP_packet_max_size - kIP_header_size) % 8),
  28. /** Also in bytes */
  29. kICMP_header_size = 8,
  30. /** This constant control the maximum size of
  31. * the payload-portion of the ICMP packets
  32. * we send. Note that this does not include
  33. * the IP or ICMP headers!
  34. */
  35. kDefault_buf_size = 1024,
  36. /** Type code for echo request and replies */
  37. kICMP_echo_request = 8,
  38. kICMP_echo_reply = 0,
  39. /** number of packets we can have in our send/receive ring */
  40. kPing_window_size = 64,
  41. /** Tunnels are automatically closed after one minute of inactivity. Since
  42. * we continously send acknowledgements between the two peers, this mechanism
  43. * won't disconnect "valid" connections.
  44. */
  45. kAutomatic_close_timeout = 60, // Seconds!
  46. /** size of md5 digest in bytes */
  47. kMD5_digest_size = 16,
  48. /** These constants are used to indicate the protocol state. The protocol
  49. * works as follows:
  50. * - The identifier is used by both the proxy and the forwarder
  51. * to identify the session (and thus the relevant sockets).
  52. * - The seq-no of the ping packet is used in a sliding-window-esque
  53. * way, and to identify the order of data.
  54. *
  55. * The protocol can be in any of the following states:
  56. * kProxy_start Causes the proxy to open a connection to the given
  57. * host and port, associating the ID with the socket,
  58. * before the data on the socket are transmitted.
  59. * kProxy_data Indicates that the packet contains data from the proxy.
  60. * Data ordering is indicated by the seq-no, which will start
  61. * at 0. (The proxy and forwarder maintain different seq-nos.)
  62. * kUser_data This packet contains user data.
  63. * kConnection_close Indicates that the connection is being closed.
  64. * kProxy_ack and Acknowledges the packet (and all packets before it) with seq_no = ack.
  65. * kUser_ack This is used if there are no implicit acknowledgements due to data
  66. * being sent.
  67. *
  68. * Acknowledgements work by the remote peer acknowledging the last
  69. * continuous seq no it has received.
  70. *
  71. * Note: A proxy receiving a kProxy_data packet, or a user receiving a
  72. * kUser_data packet, should ignore it, as it is the host operating system
  73. * actually returning the ping. This is mostly relevant for users, and for
  74. * proxies running in unprivileged mode.
  75. */
  76. kProxy_start = 0,
  77. kProto_ack,
  78. kProto_data,
  79. kProto_close,
  80. kProto_authenticate,
  81. kNum_proto_types,
  82. /** set when packet comes from a user */
  83. kUser_flag = 1 << 30,
  84. /** set when packet comes from the proxy */
  85. kProxy_flag = 1 << 31,
  86. kFlag_mask = kUser_flag | kProxy_flag,
  87. kDNS_port = 53
  88. };
  89. #endif