options.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  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. /** Usually stdout, but can be altered by the user */
  75. char *log_path;
  76. FILE *log_file;
  77. /** Print more detailed traffic statistics if non zero value */
  78. int print_stats;
  79. /** Password (must be the same on proxy and client for authentica tion to succeed) */
  80. char *password;
  81. /** MD5 digest of challenge+password */
  82. md5_byte_t password_digest[kMD5_digest_size];
  83. /** use UDP instead of ICMP */
  84. int udp;
  85. /** unpriviledged mode */
  86. int unprivileged;
  87. #ifndef WIN32
  88. /** run as daemon if non zero value */
  89. int daemonize;
  90. /** PIDFILE if running as daemon */
  91. char *pid_path;
  92. FILE *pid_file;
  93. /** log to syslog if non zero value */
  94. int use_syslog;
  95. /** UID of the running process */
  96. uid_t uid;
  97. /** GID of the running process */
  98. gid_t gid;
  99. /** CHROOT dir */
  100. int chroot;
  101. char *root_dir;
  102. #endif
  103. #ifdef HAVE_SELINUX
  104. /** Non zero value if uer wants SeLinux */
  105. int selinux;
  106. /** SeLinux context name */
  107. char *selinux_context;
  108. #endif
  109. };
  110. extern struct options opts;
  111. void print_usage(const char *arg0);
  112. int parse_options(int argc, char **argv);
  113. #endif