options.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. /*
  2. * options.h
  3. * ptunnel is licensed under the BSD license:
  4. *
  5. * Copyright (c) 2017-2019, Toni Uhlig <matzeton@googlemail.com>
  6. *
  7. * Redistribution and use in source and binary forms, with or without
  8. * modification, are permitted provided that the following conditions are met:
  9. *
  10. * - Redistributions of source code must retain the above copyright notice,
  11. * this list of conditions and the following disclaimer.
  12. *
  13. * - Redistributions in binary form must reproduce the above copyright notice,
  14. * this list of conditions and the following disclaimer in the documentation
  15. * and/or other materials provided with the distribution.
  16. *
  17. * - Neither the name of the Yellow Lemon Software nor the names of its
  18. * contributors may be used to endorse or promote products derived from this
  19. * software without specific prior written permission.
  20. *
  21. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  22. * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  23. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  24. * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
  25. * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  26. * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  27. * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  28. * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
  29. * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  30. * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  31. * POSSIBILITY OF SUCH DAMAGE.
  32. */
  33. #ifndef OPTIONS_H
  34. #define OPTIONS_H 1
  35. #include <stdio.h>
  36. #include <stdint.h>
  37. #include <stdbool.h>
  38. #ifndef WIN32
  39. #include <pwd.h>
  40. #include <grp.h>
  41. #endif
  42. #ifdef HAVE_SELINUX
  43. #include <selinux/selinux.h>
  44. #endif
  45. #include "md5.h"
  46. #include "pconfig.h"
  47. struct options {
  48. /** user defined magic value (prevent Cisco WSA/IronPort fingerprint scan) */
  49. uint32_t magic;
  50. /** proxy or forwarder? */
  51. int mode;
  52. /** Proxy's internet address */
  53. char *given_proxy_hostname;
  54. uint32_t given_proxy_ip;
  55. /** Port the client listens on */
  56. uint32_t tcp_listen_port;
  57. /** restrict Forward/Proxy destination internet address */
  58. int restrict_dst_ip;
  59. char *given_dst_hostname;
  60. uint32_t given_dst_ip;
  61. /** restrict Forward/Proxy destination port */
  62. int restrict_dst_port;
  63. uint32_t given_dst_port;
  64. /** Default maximum number of tunnels to support at once */
  65. uint32_t max_tunnels;
  66. /** Default log level */
  67. int log_level;
  68. #ifdef HAVE_PCAP
  69. /** Non zero value if user wants packet capturing */
  70. int pcap;
  71. /** Device to capture packets from */
  72. char *pcap_device;
  73. #endif
  74. /** Force SHA512 based challenge response. */
  75. int force_sha512;
  76. /** List all available pcap devices and exit */
  77. int list_pcap_devices;
  78. /** Usually stdout, but can be altered by the user */
  79. char *log_path;
  80. FILE *log_file;
  81. /** Print more detailed traffic statistics if non zero value */
  82. int print_stats;
  83. /** Password (must be the same on proxy and client for authentica tion to succeed) */
  84. char *password;
  85. /** MD5 digest of password */
  86. md5_byte_t md5_password_digest[kMD5_digest_size];
  87. /** SHA512 digest of password */
  88. unsigned char sha512_password_digest[kSHA512_digest_size];
  89. /** use UDP instead of ICMP */
  90. int udp;
  91. /** unpriviledged mode */
  92. int unprivileged;
  93. #ifndef WIN32
  94. /** run as daemon if non zero value */
  95. int daemonize;
  96. /** PIDFILE if running as daemon */
  97. char *pid_path;
  98. FILE *pid_file;
  99. /** log to syslog if non zero value */
  100. int use_syslog;
  101. /** UID of the running process */
  102. uid_t uid;
  103. /** GID of the running process */
  104. gid_t gid;
  105. /** CHROOT dir */
  106. int chroot;
  107. char *root_dir;
  108. #endif
  109. #ifdef HAVE_SELINUX
  110. /** Non zero value if uer wants SeLinux */
  111. int selinux;
  112. /** SeLinux context name */
  113. char *selinux_context;
  114. #endif
  115. };
  116. extern struct options opts;
  117. void print_usage(const char *arg0);
  118. int parse_options(int argc, char **argv);
  119. #endif