Cedar.h 51 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219
  1. // SoftEther VPN Source Code
  2. // Cedar Communication Module
  3. //
  4. // SoftEther VPN Server, Client and Bridge are free software under GPLv2.
  5. //
  6. // Copyright (c) 2012-2014 Daiyuu Nobori.
  7. // Copyright (c) 2012-2014 SoftEther VPN Project, University of Tsukuba, Japan.
  8. // Copyright (c) 2012-2014 SoftEther Corporation.
  9. //
  10. // All Rights Reserved.
  11. //
  12. // http://www.softether.org/
  13. //
  14. // Author: Daiyuu Nobori
  15. // Comments: Tetsuo Sugiyama, Ph.D.
  16. //
  17. // This program is free software; you can redistribute it and/or
  18. // modify it under the terms of the GNU General Public License
  19. // version 2 as published by the Free Software Foundation.
  20. //
  21. // This program is distributed in the hope that it will be useful,
  22. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  23. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  24. // GNU General Public License for more details.
  25. //
  26. // You should have received a copy of the GNU General Public License version 2
  27. // along with this program; if not, write to the Free Software
  28. // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  29. //
  30. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  31. // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  32. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
  33. // IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
  34. // CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
  35. // TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
  36. // SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  37. //
  38. // THE LICENSE AGREEMENT IS ATTACHED ON THE SOURCE-CODE PACKAGE
  39. // AS "LICENSE.TXT" FILE. READ THE TEXT FILE IN ADVANCE TO USE THE SOFTWARE.
  40. //
  41. //
  42. // THIS SOFTWARE IS DEVELOPED IN JAPAN, AND DISTRIBUTED FROM JAPAN,
  43. // UNDER JAPANESE LAWS. YOU MUST AGREE IN ADVANCE TO USE, COPY, MODIFY,
  44. // MERGE, PUBLISH, DISTRIBUTE, SUBLICENSE, AND/OR SELL COPIES OF THIS
  45. // SOFTWARE, THAT ANY JURIDICAL DISPUTES WHICH ARE CONCERNED TO THIS
  46. // SOFTWARE OR ITS CONTENTS, AGAINST US (SOFTETHER PROJECT, SOFTETHER
  47. // CORPORATION, DAIYUU NOBORI OR OTHER SUPPLIERS), OR ANY JURIDICAL
  48. // DISPUTES AGAINST US WHICH ARE CAUSED BY ANY KIND OF USING, COPYING,
  49. // MODIFYING, MERGING, PUBLISHING, DISTRIBUTING, SUBLICENSING, AND/OR
  50. // SELLING COPIES OF THIS SOFTWARE SHALL BE REGARDED AS BE CONSTRUED AND
  51. // CONTROLLED BY JAPANESE LAWS, AND YOU MUST FURTHER CONSENT TO
  52. // EXCLUSIVE JURISDICTION AND VENUE IN THE COURTS SITTING IN TOKYO,
  53. // JAPAN. YOU MUST WAIVE ALL DEFENSES OF LACK OF PERSONAL JURISDICTION
  54. // AND FORUM NON CONVENIENS. PROCESS MAY BE SERVED ON EITHER PARTY IN
  55. // THE MANNER AUTHORIZED BY APPLICABLE LAW OR COURT RULE.
  56. //
  57. // USE ONLY IN JAPAN. DO NOT USE IT IN OTHER COUNTRIES. IMPORTING THIS
  58. // SOFTWARE INTO OTHER COUNTRIES IS AT YOUR OWN RISK. SOME COUNTRIES
  59. // PROHIBIT ENCRYPTED COMMUNICATIONS. USING THIS SOFTWARE IN OTHER
  60. // COUNTRIES MIGHT BE RESTRICTED.
  61. //
  62. //
  63. // SOURCE CODE CONTRIBUTION
  64. // ------------------------
  65. //
  66. // Your contribution to SoftEther VPN Project is much appreciated.
  67. // Please send patches to us through GitHub.
  68. // Read the SoftEther VPN Patch Acceptance Policy in advance:
  69. // http://www.softether.org/5-download/src/9.patch
  70. //
  71. //
  72. // DEAR SECURITY EXPERTS
  73. // ---------------------
  74. //
  75. // If you find a bug or a security vulnerability please kindly inform us
  76. // about the problem immediately so that we can fix the security problem
  77. // to protect a lot of users around the world as soon as possible.
  78. //
  79. // Our e-mail address for security reports is:
  80. // softether-vpn-security [at] softether.org
  81. //
  82. // Please note that the above e-mail address is not a technical support
  83. // inquiry address. If you need technical assistance, please visit
  84. // http://www.softether.org/ and ask your question on the users forum.
  85. //
  86. // Thank you for your cooperation.
  87. //
  88. //
  89. // NO MEMORY OR RESOURCE LEAKS
  90. // ---------------------------
  91. //
  92. // The memory-leaks and resource-leaks verification under the stress
  93. // test has been passed before release this source code.
  94. // Cedar.h
  95. // Header of Cedar.c
  96. #ifndef CEDAR_H
  97. #define CEDAR_H
  98. //////////////////////////////////////////////////////////////////////
  99. //
  100. // Products related constants
  101. //
  102. //////////////////////////////////////////////////////////////////////
  103. // Replace the function name
  104. #ifdef VPN_SPEED
  105. #define DecryptSecurePacket __dsp
  106. #define CreateSecurePacket __csp
  107. #define GetSecureRandomSize __gsrs
  108. #endif // VPN_SPEED
  109. #define bool UINT
  110. #define BOOL UINT
  111. // Version number
  112. #define CEDAR_VER 406
  113. // Build Number
  114. #define CEDAR_BUILD 9430
  115. // Beta number
  116. //#define BETA_NUMBER 3
  117. // RC or not
  118. #define RELEASE_CANDIDATE
  119. // Specify the name of the person in charge building
  120. #ifndef BUILDER_NAME
  121. #define BUILDER_NAME "yagi"
  122. #endif // BUILDER_NAME
  123. // Specify the location to build
  124. #ifndef BUILD_PLACE
  125. #define BUILD_PLACE "pc25"
  126. #endif // BUILD_PLACE
  127. // Specifies the build date
  128. #define BUILD_DATE_Y 2014
  129. #define BUILD_DATE_M 3
  130. #define BUILD_DATE_D 20
  131. #define BUILD_DATE_HO 4
  132. #define BUILD_DATE_MI 8
  133. #define BUILD_DATE_SE 6
  134. // Tolerable time difference
  135. #define ALLOW_TIMESTAMP_DIFF (UINT64)(3 * 24 * 60 * 60 * 1000)
  136. // Configuration of communication related control switch
  137. #define USE_DOS_ATTACK_DETECTION // Enable the DOS attack detection
  138. //#define USE_SECURE_PACKET // Enable the scrambled packet
  139. // Designate the IDS detection signatures
  140. #define CEDAR_SIGNATURE_STR "SE-VPN4-PROTOCOL"
  141. // Default RSA certificate name of the smart card
  142. #define SECURE_DEFAULT_CERT_NAME "VPN_RSA_CERT"
  143. // Default RSA private key name of the smart card
  144. #define SECURE_DEFAULT_KEY_NAME "VPN_RSA_KEY"
  145. // Hidden password string of 8 characters
  146. #define HIDDEN_PASSWORD "********"
  147. //////////////////////////////////////////////////////////////////////
  148. //
  149. // Definition of the maximum length of various string
  150. //
  151. //////////////////////////////////////////////////////////////////////
  152. #define MAX_ACCOUNT_NAME_LEN 255 // Maximum account name length
  153. #define MAX_USERNAME_LEN 255 // User name maximum length
  154. #define MAX_PASSWORD_LEN 255 // Password name maximum length
  155. #define MAX_PROXY_USERNAME_LEN 255 // Proxy user name maximum length
  156. #define MAX_PROXY_PASSWORD_LEN 255 // Proxy Password maximum length
  157. #define MAX_SERVER_STR_LEN 255 // Maximum length of server string
  158. #define MAX_CLIENT_STR_LEN 255 // Maximum length of client string
  159. #define MAX_HUBNAME_LEN 255 // Maximum length of HUB name
  160. #define MAX_SESSION_NAME_LEN 255 // Session name maximum length
  161. #define MAX_CONNECTION_NAME_LEN 255 // Maximum length of connection name
  162. #define MAX_DEVICE_NAME_LEN 31 // Device name maximum length
  163. #define MAX_DEVICE_NAME_LEN_9X 4 // Maximum length of Virtual LAN card name in Win9x
  164. #define MAX_ACCESSLIST_NOTE_LEN 255 // Maximum length of the note of access list entry
  165. #define MAX_SECURE_DEVICE_FILE_LEN 255 // Secure device file name maximum length
  166. #define MAX_ADMIN_OPTION_NAME_LEN 63 // Management option name
  167. #define MAX_REDIRECT_URL_LEN 255 // URL length to redirect
  168. //////////////////////////////////////////////////////////////////////
  169. //
  170. // Server and session management related constants
  171. //
  172. //////////////////////////////////////////////////////////////////////
  173. #define SERVER_MAX_SESSIONS 4096 // Maximum number of sessions that the server supports
  174. #define SERVER_MAX_SESSIONS_FOR_CARRIER_EDITION 100000 // Maximum number of sessions that the server supports (Carrier Edition)
  175. #define NAT_MAX_SESSIONS 4096 // Maximum number of sessions that are supported by NAT
  176. #define NAT_MAX_SESSIONS_KERNEL 65536 // Maximum number of sessions that are supported by NAT (In the case of kernel-mode NAT)
  177. #define MAX_HUBS 4096 // The maximum number of virtual HUB
  178. #define MAX_HUBS_FOR_CARRIER_EDITION 100000 // The maximum number of virtual HUB (Carrier Edition)
  179. #define MAX_ACCESSLISTS (4096 * 8) // Maximum number of access list entries
  180. #define MAX_USERS 10000 // The maximum number of users
  181. #define MAX_GROUPS 10000 // Maximum number of groups
  182. #define MAX_MAC_TABLES 65536 // Maximum number of MAC address table entries
  183. #define MAX_IP_TABLES 65536 // Maximum number of IP address table entries
  184. #define MAX_HUB_CERTS 4096 // Maximum number of Root CA that can be registered
  185. #define MAX_HUB_CRLS 4096 // Maximum number of CRL that can be registered
  186. #define MAX_HUB_ACS 4096 // Maximum number of AC that can be registered
  187. #define MAX_HUB_LINKS 128 // Maximum number of Cascade that can be registered
  188. #define MAX_HUB_ADMIN_OPTIONS 4096 // Maximum number of Virtual HUB management options that can be registered
  189. #define MAX_PACKET_SIZE 1560 // Maximum packet size
  190. #define UDP_BUF_SIZE (32 * 1024) // Aim of the UDP packet size
  191. #define MAX_SEND_SOCKET_QUEUE_SIZE (1600 * 1600 * 1) // Maximum transmit queue size
  192. #define MIN_SEND_SOCKET_QUEUE_SIZE (1600 * 200 * 1)
  193. #define MAX_SEND_SOCKET_QUEUE_NUM 128 // Maximum transmission queue items
  194. #define MAX_TCP_CONNECTION 32 // The maximum number of TCP connections
  195. #define NUM_TCP_CONNECTION_FOR_UDP_RECOVERY 2 // Maximum number of connections when using UDP recovery
  196. #define SELECT_TIME 256
  197. #define SELECT_TIME_FOR_NAT 30
  198. #define SELECT_TIME_FOR_DELAYED_PKT 1 // If there is a delayed packet
  199. #define MAX_STORED_QUEUE_NUM 1024 // The number of queues that can be stored in each session
  200. #define MAX_BUFFERING_PACKET_SIZE (1600 * 1600) // Maximum packet size can be buffered
  201. #define TIMEOUT_MIN (5 * 1000) // Minimum timeout in seconds
  202. #define TIMEOUT_MAX (60 * 1000) // Maximum timeout in seconds
  203. #define TIMEOUT_DEFAULT (30 * 1000) // Default number of seconds to timeout
  204. #define CONNECTING_TIMEOUT (15 * 1000) // Timeout in seconds of being connected
  205. #define CONNECTING_TIMEOUT_PROXY (4 * 1000) // Timeout in seconds of being connected (Proxy)
  206. #define CONNECTING_POOLING_SPAN (3 * 1000) // Polling interval of connected
  207. #define MIN_RETRY_INTERVAL (5 * 1000) // Minimum retry interval
  208. #define MAX_RETRY_INTERVAL (300 * 1000) // Maximum retry interval
  209. #define RETRY_INTERVAL_SPECIAL (60 * 1000) // Reconnection interval of a special case
  210. #define MAX_ADDITONAL_CONNECTION_FAILED_COUNTER 16 // Allowable number that can be serially failed to additional connection
  211. #define ADDITIONAL_CONNECTION_COUNTER_RESET_INTERVAL (30 * 60 * 1000) // Reset period of additional connection failure counter
  212. #define MAC_MIN_LIMIT_COUNT 3 // Minimum number of MAC addresses
  213. #define IP_MIN_LIMIT_COUNT 4 // Number of IPv4 addresses minimum
  214. #define IP_MIN_LIMIT_COUNT_V6 5 // Number of IPv6 addresses minimum
  215. #define IP_LIMIT_WHEN_NO_ROUTING_V6 15 // Maximum number of IPv6 addresses when NoRouting policy is enabled
  216. #define MAC_TABLE_EXCLUSIVE_TIME (13 * 1000) // Period that can occupy the MAC address
  217. #define IP_TABLE_EXCLUSIVE_TIME (13 * 1000) // Period that can occupy the IP address
  218. #define MAC_TABLE_EXPIRE_TIME (600 * 1000) // MAC address table expiration date
  219. #define IP_TABLE_EXPIRE_TIME (60 * 1000) // IP address table expiration date
  220. #define IP_TABLE_EXPIRE_TIME_DHCP (5 * 60 * 1000) // IP address table expiration date (In the case of DHCP)
  221. #define HUB_ARP_SEND_INTERVAL (5 * 1000) // ARP packet transmission interval (alive check)
  222. #define LIMITER_SAMPLING_SPAN 1000 // Sampling interval of the traffic limiting device
  223. #define STORM_CHECK_SPAN 500 // Broadcast storm check interval
  224. #define STORM_DISCARD_VALUE_START 3 // Broadcast packet discard value start value
  225. #define STORM_DISCARD_VALUE_END 1024 // Broadcast packet discard value end value
  226. #define KEEP_INTERVAL_MIN 5 // Packet transmission interval minimum value
  227. #define KEEP_INTERVAL_DEFAULT 50 // Packet transmission interval default value
  228. #define KEEP_INTERVAL_MAX 600 // Packet transmission interval maximum value
  229. #define KEEP_TCP_TIMEOUT 1000 // TCP time-out value
  230. #define TICKET_EXPIRES (60 * 1000) // Expiration date of ticket
  231. #define SEND_KILL_NUM_X 256 // Number of 'X' characters to send the Kill
  232. #define FARM_BASE_POINT 100000 // Reference value of the cluster score
  233. #define FARM_DEFAULT_WEIGHT 100 // Standard performance ratio
  234. #define SE_UDP_SIGN "SE2P" // Not used (only old UDP mode)
  235. // R-UDP service name
  236. #define VPN_RUDP_SVC_NAME "SoftEther_VPN"
  237. // Traffic information update interval
  238. #define INCREMENT_TRAFFIC_INTERVAL (10 * 1000)
  239. // State of the client session
  240. #define CLIENT_STATUS_CONNECTING 0 // Connecting
  241. #define CLIENT_STATUS_NEGOTIATION 1 // Negotiating
  242. #define CLIENT_STATUS_AUTH 2 // During user authentication
  243. #define CLIENT_STATUS_ESTABLISHED 3 // Connection complete
  244. #define CLIENT_STATUS_RETRY 4 // Wait to retry
  245. #define CLIENT_STATUS_IDLE 5 // Idle state
  246. // Expiration date of the black list
  247. #define BLACK_LIST_EXPIRES (30 * 10000)
  248. // Number Blacklist entries
  249. #define MAX_BLACK_LIST 4096
  250. #define BLACK_LIST_CHECK_SPAN 1000
  251. // Blocks to be transmitted at one during the file transfer
  252. #define FTP_BLOCK_SIZE (640 * 1024)
  253. // Syslog configuration
  254. #define SYSLOG_NONE 0 // Do not use syslog
  255. #define SYSLOG_SERVER_LOG 1 // Only server log
  256. #define SYSLOG_SERVER_AND_HUB_SECURITY_LOG 2 // Server and Virtual HUB security log
  257. #define SYSLOG_SERVER_AND_HUB_ALL_LOG 3 // Server, Virtual HUB security, and packet log
  258. #define SYSLOG_PORT 514 // Syslog port number
  259. #define SYSLOG_POLL_IP_INTERVAL (UINT64)(3600 * 1000) // Interval to examine the IP address
  260. #define SYSLOG_POLL_IP_INTERVAL_NG (UINT64)(60 * 1000) // Interval to examine the IP address (previous failure)
  261. //////////////////////////////////////////////////////////////////////
  262. //
  263. // Connection-related constant
  264. //
  265. //////////////////////////////////////////////////////////////////////
  266. // Internet connection maintenance function (KeepAlive)
  267. #define KEEP_RETRY_INTERVAL (60 * 1000) // Reconnection interval on connection failure
  268. #define KEEP_MIN_PACKET_SIZE 1 // Minimum packet size
  269. #define KEEP_MAX_PACKET_SIZE 128 // Maximum packet size
  270. #define KEEP_POLLING_INTERVAL 250 // KEEP polling interval
  271. // Constants
  272. #define RECV_BUF_SIZE 65536 // Buffer size to be received at a time
  273. // Type of proxy
  274. #define PROXY_DIRECT 0 // Direct TCP connection
  275. #define PROXY_HTTP 1 // Connection via HTTP proxy server
  276. #define PROXY_SOCKS 2 // Connection via SOCKS proxy server
  277. // Direction of data flow
  278. #define TCP_BOTH 0 // Bi-directional
  279. #define TCP_SERVER_TO_CLIENT 1 // Only server -> client direction
  280. #define TCP_CLIENT_TO_SERVER 2 // Only client -> server direction
  281. // Type of connection
  282. #define CONNECTION_TYPE_CLIENT 0 // Client
  283. #define CONNECTION_TYPE_INIT 1 // During initialization
  284. #define CONNECTION_TYPE_LOGIN 2 // Login connection
  285. #define CONNECTION_TYPE_ADDITIONAL 3 // Additional connection
  286. #define CONNECTION_TYPE_FARM_RPC 4 // RPC for server farm
  287. #define CONNECTION_TYPE_ADMIN_RPC 5 // RPC for Management
  288. #define CONNECTION_TYPE_ENUM_HUB 6 // HUB enumeration
  289. #define CONNECTION_TYPE_PASSWORD 7 // Password change
  290. #define CONNECTION_TYPE_SSTP 8 // SSTP
  291. #define CONNECTION_TYPE_OPENVPN 9 // OpenVPN
  292. // Protocol
  293. #define CONNECTION_TCP 0 // TCP protocol
  294. #define CONNECTION_UDP 1 // UDP protocol
  295. #define CONNECTION_HUB_LAYER3 6 // Layer-3 switch session
  296. #define CONNECTION_HUB_BRIDGE 7 // Bridge session
  297. #define CONNECTION_HUB_SECURE_NAT 8 // Secure NAT session
  298. #define CONNECTION_HUB_LINK_SERVER 9 // HUB link session
  299. // Status
  300. #define CONNECTION_STATUS_ACCEPTED 0 // The connection is accepted (client side)
  301. #define CONNECTION_STATUS_NEGOTIATION 1 // Negotiating
  302. #define CONNECTION_STATUS_USERAUTH 2 // During user authentication
  303. #define CONNECTION_STATUS_ESTABLISHED 3 // Connection has been established
  304. #define CONNECTION_STATUS_CONNECTING 0 // Connecting (client side)
  305. // Magic number of KeepAlive packet
  306. #define KEEP_ALIVE_MAGIC 0xffffffff
  307. #define MAX_KEEPALIVE_SIZE 512
  308. //////////////////////////////////////////////////////////////////////
  309. //
  310. // Virtual HUB-related constant
  311. //
  312. //////////////////////////////////////////////////////////////////////
  313. #define SE_HUB_MAC_ADDR_SIGN 0xAE // Sign virtual HUB MAC address
  314. // Traffic difference value
  315. #define TRAFFIC_DIFF_USER 0 // User
  316. #define TRAFFIC_DIFF_HUB 1 // Virtual HUB
  317. #define MAX_TRAFFIC_DIFF 30000 // Maximum number of items
  318. // Type of HUB
  319. #define HUB_TYPE_STANDALONE 0 // Stand-alone HUB
  320. #define HUB_TYPE_FARM_STATIC 1 // Static HUB
  321. #define HUB_TYPE_FARM_DYNAMIC 2 // Dynamic HUB
  322. // Related to delay, jitter, packet loss in the access list
  323. #define HUB_ACCESSLIST_DELAY_MAX 10000 // Maximum delay
  324. #define HUB_ACCESSLIST_JITTER_MAX 100 // Maximum jitter
  325. #define HUB_ACCESSLIST_LOSS_MAX 100 // Maximum packet loss
  326. // Message related
  327. #define HUB_MAXMSG_LEN 20000 // The maximum number of characters in a message
  328. //////////////////////////////////////////////////////////////////////
  329. //
  330. // Type of user authentication
  331. //
  332. //////////////////////////////////////////////////////////////////////
  333. // Constant in the server-side
  334. #define AUTHTYPE_ANONYMOUS 0 // Anonymous authentication
  335. #define AUTHTYPE_PASSWORD 1 // Password authentication
  336. #define AUTHTYPE_USERCERT 2 // User certificate authentication
  337. #define AUTHTYPE_ROOTCERT 3 // Root certificate which is issued by trusted Certificate Authority
  338. #define AUTHTYPE_RADIUS 4 // Radius authentication
  339. #define AUTHTYPE_NT 5 // Windows NT authentication
  340. #define AUTHTYPE_TICKET 99 // Ticket authentication
  341. // Constant of the client side
  342. #define CLIENT_AUTHTYPE_ANONYMOUS 0 // Anonymous authentication
  343. #define CLIENT_AUTHTYPE_PASSWORD 1 // Password authentication
  344. #define CLIENT_AUTHTYPE_PLAIN_PASSWORD 2 // Plain password authentication
  345. #define CLIENT_AUTHTYPE_CERT 3 // Certificate authentication
  346. #define CLIENT_AUTHTYPE_SECURE 4 // Secure device authentication
  347. //////////////////////////////////////////////////////////////////////
  348. //
  349. // TCP listener related constants
  350. //
  351. //////////////////////////////////////////////////////////////////////
  352. // Retries in case it fails to Listen
  353. #define LISTEN_RETRY_TIME (2 * 1000) // If fail to Listen normally
  354. #define LISTEN_RETRY_TIME_NOIPV6 (60 * 1000) // If IPv6 support is disabled
  355. #define DOS_TABLE_EXPIRES_FIRST 250 // Initial value of the expiration date of DOS attack list
  356. #define DOS_TABLE_EXPIRES_MAX 1000 // Maximum value of the expiration date of DOS attack list
  357. #define DOS_TABLE_REFRESH_INTERVAL (10 * 1000) // Interval to update the DOS attack list
  358. #define DOS_TABLE_MAX_LIMIT_PER_IP 16 // Accessible number per an IP
  359. #define DOS_TABLE_EXPIRES_TOTAL (3000 * 1000) // Time to force delete the entry
  360. // Protocol to be used for the listener
  361. #define LISTENER_TCP 0 // TCP/IP
  362. #define LISTENER_UDP 1 // UDP/IP (not being used)
  363. #define LISTENER_INPROC 2 // In-process communication
  364. #define LISTENER_RUDP 3 // R-UDP with NAT-T
  365. #define LISTENER_ICMP 4 // VPN over ICMP
  366. #define LISTENER_DNS 5 // VPN over DNS
  367. #define LISTENER_REVERSE 6 // Reverse socket
  368. // Status of the listener
  369. #define LISTENER_STATUS_TRYING 0 // While attempting
  370. #define LISTENER_STATUS_LISTENING 1 // Listening
  371. // Largest packet size of UDP
  372. #define UDP_PACKET_SIZE 65536
  373. // Number of standard connections per IP address
  374. #define DEFAULT_MAX_CONNECTIONS_PER_IP 256
  375. #define MIN_MAX_CONNECTIONS_PER_IP 10 // Minimum value
  376. // Allowed number of outstanding connections
  377. #define DEFAULT_MAX_UNESTABLISHED_CONNECTIONS 1000
  378. #define MIN_MAX_UNESTABLISHED_CONNECTIONS 30 // Minimum value
  379. //////////////////////////////////////////////////////////////////////
  380. //
  381. // Log related constant
  382. //
  383. //////////////////////////////////////////////////////////////////////
  384. #define LOG_ENGINE_SAVE_START_CACHE_COUNT 100000 // Number to start saving forcibly
  385. #define LOG_ENGINE_BUFFER_CACHE_SIZE_MAX (10 * 1024 * 1024) // Write cache size
  386. // Constant such as a file name
  387. #define SERVER_LOG_DIR_NAME "@server_log"
  388. #define BRIDGE_LOG_DIR_NAME SERVER_LOG_DIR_NAME
  389. #define SERVER_LOG_PERFIX "vpn"
  390. #define HUB_SECURITY_LOG_DIR_NAME "@security_log"
  391. #define HUB_SECURITY_LOG_FILE_NAME "@security_log/%s"
  392. #define HUB_SECURITY_LOG_PREFIX "sec"
  393. #define HUB_PACKET_LOG_DIR_NAME "@packet_log"
  394. #define HUB_PACKET_LOG_FILE_NAME "@packet_log/%s"
  395. #define HUB_PACKET_LOG_PREFIX "pkt"
  396. #define NAT_LOG_DIR_NAME "@secure_nat_log"
  397. #define NAT_LOG_FILE_NAME "@secure_nat_log/%s"
  398. #define NAT_LOG_PREFIX "snat"
  399. #define CLIENT_LOG_DIR_NAME "@client_log"
  400. #define CLIENT_LOG_PREFIX "client"
  401. // Packet log settings
  402. #define NUM_PACKET_LOG 16
  403. #define PACKET_LOG_TCP_CONN 0 // TCP connection log
  404. #define PACKET_LOG_TCP 1 // TCP packet log
  405. #define PACKET_LOG_DHCP 2 // DHCP Log
  406. #define PACKET_LOG_UDP 3 // UDP log
  407. #define PACKET_LOG_ICMP 4 // ICMP log
  408. #define PACKET_LOG_IP 5 // IP log
  409. #define PACKET_LOG_ARP 6 // ARP log
  410. #define PACKET_LOG_ETHERNET 7 // Ethernet log
  411. #define PACKET_LOG_NONE 0 // Not save
  412. #define PACKET_LOG_HEADER 1 // Only header
  413. #define PACKET_LOG_ALL 2 // Store also data
  414. // Timing of log switching
  415. #define LOG_SWITCH_NO 0 // Without switching
  416. #define LOG_SWITCH_SECOND 1 // Secondly basis
  417. #define LOG_SWITCH_MINUTE 2 // Minutely basis
  418. #define LOG_SWITCH_HOUR 3 // Hourly basis
  419. #define LOG_SWITCH_DAY 4 // Daily basis
  420. #define LOG_SWITCH_MONTH 5 // Monthly basis
  421. // Minimum amount of free disk space
  422. #define DISK_FREE_SPACE_MIN 1048576 // 1 MBytes
  423. #define DISK_FREE_SPACE_DEFAULT (DISK_FREE_SPACE_MIN * 100) // 100 Mbytes
  424. #define DISK_FREE_SPACE_DEFAULT_WINDOWS ((UINT64)(8ULL * 1024ULL * 1024ULL * 1024ULL)) // 8GBytes
  425. // Interval to check the free space
  426. #define DISK_FREE_CHECK_INTERVAL (5 * 60 * 1000)
  427. // Simple log
  428. #define TINY_LOG_DIRNAME "@tiny_log"
  429. #define TINY_LOG_FILENAME "@tiny_log/%04u%02u%02u_%02u%02u%02u.log"
  430. //////////////////////////////////////////////////////////////////////
  431. //
  432. // Constant related to Carrier Edition
  433. //
  434. //////////////////////////////////////////////////////////////////////
  435. #define CE_SNAPSHOT_INTERVAL ((UINT64)(3600 * 1000))
  436. //#define CE_SNAPSHOT_INTERVAL ((UINT64)(3000))
  437. #define CE_SNAPSHOT_POLLING_INTERVAL (1 * 1000)
  438. #define CE_SNAPSHOT_POLLING_INTERVAL_LICENSE (30 * 1000)
  439. #define CE_SNAPSHOT_DIR_NAME "@carrier_log"
  440. #define CE_SNAPSHOT_PREFIX "carrier"
  441. //////////////////////////////////////////////////////////////////////
  442. //
  443. // Communication protocol related constant
  444. //
  445. //////////////////////////////////////////////////////////////////////
  446. // Administrator Username
  447. #define ADMINISTRATOR_USERNAME "administrator"
  448. // Maximum value of random size
  449. #define RAND_SIZE_MAX 4096
  450. // Expiration date of random size cache
  451. #define RAND_SIZE_CACHE_EXPIRE (24 * 60 * 60 * 1000)
  452. // Management allowed IP address list file name
  453. #define ADMINIP_TXT "@adminip.txt"
  454. #define NON_SSL_MIN_COUNT 60
  455. #define NON_SSL_ENTRY_EXPIRES (10 * 60 * 1000)
  456. //////////////////////////////////////////////////////////////////////
  457. //
  458. // The cascade related constants
  459. //
  460. //////////////////////////////////////////////////////////////////////
  461. #define LINK_DEVICE_NAME "_SEHUBLINKCLI_"
  462. #define LINK_USER_NAME "link"
  463. #define LINK_USER_NAME_PRINT "Cascade"
  464. //////////////////////////////////////////////////////////////////////
  465. //
  466. // Constant related to SecureNAT connection
  467. //
  468. //////////////////////////////////////////////////////////////////////
  469. #define SNAT_DEVICE_NAME "_SEHUBSECURENAT_"
  470. #define SNAT_USER_NAME "securenat"
  471. #define SNAT_USER_NAME_PRINT "SecureNAT"
  472. //////////////////////////////////////////////////////////////////////
  473. //
  474. // Constant related to bridge connection
  475. //
  476. //////////////////////////////////////////////////////////////////////
  477. #define BRIDGE_DEVICE_NAME "_SEHUBBRIDGE_"
  478. #define BRIDGE_USER_NAME "localbridge"
  479. #define BRIDGE_USER_NAME_PRINT "Local Bridge"
  480. #define BRIDGE_TRY_SPAN 1000
  481. #define BRIDGE_NUM_DEVICE_CHECK_SPAN (5 * 60 * 1000)
  482. #define BRIDGE_NETWORK_CONNECTION_STR L"%s [%S]"
  483. //////////////////////////////////////////////////////////////////////
  484. //
  485. // EtherLogger related constants
  486. //
  487. //////////////////////////////////////////////////////////////////////
  488. #define EL_ADMIN_PORT 22888
  489. #define EL_CONFIG_FILENAME "@etherlogger.config"
  490. #define EL_PACKET_LOG_DIR_NAME "@etherlogger_log"
  491. #define EL_PACKET_LOG_FILE_NAME "@etherlogger_log/%s"
  492. #define EL_PACKET_LOG_PREFIX "pkt"
  493. #define EL_LICENSE_CHECK_SPAN (10 * 1000)
  494. //////////////////////////////////////////////////////////////////////
  495. //
  496. // Layer-3 Switch related constants
  497. //
  498. //////////////////////////////////////////////////////////////////////
  499. #define MAX_NUM_L3_SWITCH 4096
  500. #define MAX_NUM_L3_IF 4096
  501. #define MAX_NUM_L3_TABLE 4096
  502. //////////////////////////////////////////////////////////////////////
  503. //
  504. // Constant related to User-mode Router
  505. //
  506. //////////////////////////////////////////////////////////////////////
  507. #define ARP_ENTRY_EXPIRES (30 * 1000) // ARP table expiration date
  508. #define ARP_ENTRY_POLLING_TIME (1 * 1000) // ARP table cleaning timer
  509. #define ARP_REQUEST_TIMEOUT (200) // ARP request time-out period
  510. #define ARP_REQUEST_GIVEUP (5 * 1000) // Time to give up sending the ARP request
  511. #define IP_WAIT_FOR_ARP_TIMEOUT (5 * 1000) // Total time that an IP packet waiting for ARP table
  512. #define IP_COMBINE_TIMEOUT (10 * 1000) // Time-out of IP packet combining
  513. #define NAT_TCP_MAX_TIMEOUT (2000000 * 1000) // Maximum TCP session timeout in seconds
  514. #define NAT_UDP_MAX_TIMEOUT (2000000 * 1000) // Maximum UDP session timeout in seconds
  515. #define NAT_TCP_MIN_TIMEOUT (1 * 60 * 1000) // Minimum TCP session timeout in seconds
  516. #define NAT_UDP_MIN_TIMEOUT (10 * 1000) // Minimum UDP session timeout in seconds
  517. #define NAT_TCP_RECV_WINDOW_SIZE 64512 // TCP receive window size
  518. #define NAT_TCP_SYNACK_SEND_TIMEOUT 250 // Sending TCP SYN+ACK interval
  519. #define NAT_ICMP_TIMEOUT (10 * 1000) // ICMP timeout in seconds
  520. #define NAT_ICMP_TIMEOUT_WITH_API (3 * 1000) // Timeout in seconds in the case of using the ICMP API
  521. #define NAT_SEND_BUF_SIZE (64 * 1024) // TCP send buffer size
  522. #define NAT_RECV_BUF_SIZE (64 * 1024) // TCP receive buffer size
  523. #define NAT_TMPBUF_SIZE (128 * 1024) // TCP temporally memory area size
  524. #define NAT_ACK_KEEPALIVE_SPAN (5 * 1000) // ACK transmission interval for TCP keep alive
  525. #define NAT_INITIAL_RTT_VALUE 500 // Initial RTT value
  526. #define NAT_FIN_SEND_INTERVAL 1000 // FIN transmission interval
  527. #define NAT_FIN_SEND_MAX_COUNT 5 // Total number of FIN transmissions
  528. #define NAT_DNS_PROXY_PORT 53 // DNS proxy port number
  529. #define NAT_DNS_RESPONSE_TTL (20 * 60) // TTL of the DNS response
  530. #define NAT_DHCP_SERVER_PORT 67 // DHCP server port number
  531. #define NAT_DHCP_CLIENT_PORT 68 // DHCP client port number
  532. #define DHCP_MIN_EXPIRE_TIMESPAN (15 * 1000) // DHCP minimum expiration date
  533. #define DHCP_POLLING_INTERVAL 1000 // DHCP polling interval
  534. #define X32 ((UINT64)4294967296ULL) // 32bit + 1
  535. #define NAT_DNS_QUERY_TIMEOUT (512) // Time-out value of DNS queries
  536. // Beacon transmission interval
  537. #define BEACON_SEND_INTERVAL (5 * 1000)
  538. // Total size quota allowed in the queue for the combining the IP packet
  539. #define IP_COMBINE_WAIT_QUEUE_SIZE_QUOTA (50 * 1024 * 1024)
  540. // Header size constant
  541. #define MAC_HEADER_SIZE (sizeof(MAC_HEADER))
  542. #define ARP_HEADER_SIZE (sizeof(ARP_HEADER))
  543. #define IP_HEADER_SIZE (sizeof(IPV4_HEADER))
  544. #define TCP_HEADER_SIZE (sizeof(TCP_HEADER))
  545. #define UDP_HEADER_SIZE (sizeof(UDP_HEADER))
  546. // Data maximum size constant
  547. #define MAX_L3_DATA_SIZE (1500)
  548. #define MAX_IP_DATA_SIZE (MAX_L3_DATA_SIZE - IP_HEADER_SIZE)
  549. #define MAX_TCP_DATA_SIZE (MAX_IP_DATA_SIZE - TCP_HEADER_SIZE)
  550. #define MAX_UDP_DATA_SIZE (MAX_IP_DATA_SIZE - UDP_HEADER_SIZE)
  551. #define MAX_IP_DATA_SIZE_TOTAL (65535)
  552. // IP packet option constant
  553. #define DEFAULT_IP_TOS 0 // TOS in the IP header
  554. #define DEFAULT_IP_TTL 128 // TTL in the IP header
  555. // Type of NAT session
  556. #define NAT_TCP 0 // TCP NAT
  557. #define NAT_UDP 1 // UDP NAT
  558. #define NAT_DNS 2 // DNS NAT
  559. #define NAT_ICMP 3 // ICMP NAT
  560. // State of NAT session
  561. #define NAT_TCP_CONNECTING 0 // Connecting
  562. #define NAT_TCP_SEND_RESET 1 // Send the RST (Connection failure or disconnected)
  563. #define NAT_TCP_CONNECTED 2 // Connection complete
  564. #define NAT_TCP_ESTABLISHED 3 // Connection established
  565. #define NAT_TCP_WAIT_DISCONNECT 4 // Wait for socket disconnection
  566. //////////////////////////////////////////////////////////////////////
  567. //
  568. // For UNIX virtual LAN card related constant
  569. //
  570. //////////////////////////////////////////////////////////////////////
  571. #define TAP_FILENAME_1 "/dev/net/tun"
  572. #define TAP_FILENAME_2 "/dev/tun"
  573. #ifdef UNIX_MACOS
  574. #ifdef NO_VLAN
  575. #define TAP_MACOS_FILENAME "/dev/tap0"
  576. #else // NO_VLAN
  577. #define TAP_MACOS_FILENAME "tap"
  578. #endif // NO_VLAN
  579. #define TAP_MACOS_DIR "/dev/"
  580. #define TAP_MACOS_NUMBER (16)
  581. #endif // UNIX_MACOS
  582. #define LICENSE_EDITION_VPN3_NO_LICENSE 0 // Without license
  583. #define LICENSE_MAX_PRODUCT_NAME_LEN 255 // Maximum length of license product name
  584. #define LICENSE_NUM_SHA 10000 // Number of times to hash with SHA
  585. #define LICENSE_SYSTEM_KEY_NUM 2048 // Key number for system
  586. #define LICENSE_SYSTEM_KEYSIZE_BIT 144 // Number of key bits for system
  587. #define LICENSE_PRODUCT_KEY_NUM 16384 // Number of keys for product
  588. #define LICENSE_PRODUCT_KEYSIZE_BIT 56 // Number of key bits for product
  589. #define LICENSE_PRODUCT_COMMON_KEYSIZE_BIT 48 // Number of common key bits for product
  590. #define LICENSE_MASTER_KEYSIZE_BIT 1024 // Number of master key bits
  591. #define LICENSE_SYSTEM_ID_MIN 0ULL // System ID minimum value
  592. #define LICENSE_SYSTEM_ID_MAX 549755813887ULL // System ID maximum value
  593. #define LICENSE_SERIAL_ID_MIN 0 // Serial ID minimum value
  594. #define LICENSE_SERIAL_ID_MAX 65535 // Serial ID maximum value
  595. #define LICENSE_EXPIRES_MIN 0 // Expiration date minimum
  596. #define LICENSE_EXPIRES_MAX 16383 // Expiration date maximum
  597. #define LICENSE_KEYSTR_LEN 41 // Length of the license key
  598. #define LICENSE_LICENSEID_STR_LEN 33 // Length of the license ID
  599. #define LICENSE_STATUS_OK 0 // Enabled
  600. #define LICENSE_STATUS_EXPIRED 1 // Invalid (expired)
  601. #define LICENSE_STATUS_ID_DIFF 2 // Invalid (System ID mismatch)
  602. #define LICENSE_STATUS_DUP 3 // Invalid (duplicated)
  603. #define LICENSE_STATUS_INSUFFICIENT 4 // Invalid (other necessary license shortage)
  604. #define LICENSE_STATUS_COMPETITION 5 // Invalid (conflict with other licenses)
  605. #define LICENSE_STATUS_NONSENSE 6 // Invalid (meaningless in the current edition)
  606. #define LICENSE_STATUS_CPU 7 // Invalid (CPU type mismatch)
  607. #define BIT_TO_BYTE(x) (((x) + 7) / 8)
  608. #define BYTE_TO_BIT(x) ((x) * 8)
  609. //////////////////////////////////////////////////////////////////////
  610. //
  611. // Error code
  612. //
  613. //////////////////////////////////////////////////////////////////////
  614. #define ERR_NO_ERROR 0 // No error
  615. #define ERR_CONNECT_FAILED 1 // Connection to the server has failed
  616. #define ERR_SERVER_IS_NOT_VPN 2 // The destination server is not a VPN server
  617. #define ERR_DISCONNECTED 3 // The connection has been interrupted
  618. #define ERR_PROTOCOL_ERROR 4 // Protocol error
  619. #define ERR_CLIENT_IS_NOT_VPN 5 // Connecting client is not a VPN client
  620. #define ERR_USER_CANCEL 6 // User cancel
  621. #define ERR_AUTHTYPE_NOT_SUPPORTED 7 // Specified authentication method is not supported
  622. #define ERR_HUB_NOT_FOUND 8 // The HUB does not exist
  623. #define ERR_AUTH_FAILED 9 // Authentication failure
  624. #define ERR_HUB_STOPPING 10 // HUB is stopped
  625. #define ERR_SESSION_REMOVED 11 // Session has been deleted
  626. #define ERR_ACCESS_DENIED 12 // Access denied
  627. #define ERR_SESSION_TIMEOUT 13 // Session times out
  628. #define ERR_INVALID_PROTOCOL 14 // Protocol is invalid
  629. #define ERR_TOO_MANY_CONNECTION 15 // Too many connections
  630. #define ERR_HUB_IS_BUSY 16 // Too many sessions of the HUB
  631. #define ERR_PROXY_CONNECT_FAILED 17 // Connection to the proxy server fails
  632. #define ERR_PROXY_ERROR 18 // Proxy Error
  633. #define ERR_PROXY_AUTH_FAILED 19 // Failed to authenticate on the proxy server
  634. #define ERR_TOO_MANY_USER_SESSION 20 // Too many sessions of the same user
  635. #define ERR_LICENSE_ERROR 21 // License error
  636. #define ERR_DEVICE_DRIVER_ERROR 22 // Device driver error
  637. #define ERR_INTERNAL_ERROR 23 // Internal error
  638. #define ERR_SECURE_DEVICE_OPEN_FAILED 24 // The secure device cannot be opened
  639. #define ERR_SECURE_PIN_LOGIN_FAILED 25 // PIN code is incorrect
  640. #define ERR_SECURE_NO_CERT 26 // Specified certificate is not stored
  641. #define ERR_SECURE_NO_PRIVATE_KEY 27 // Specified private key is not stored
  642. #define ERR_SECURE_CANT_WRITE 28 // Write failure
  643. #define ERR_OBJECT_NOT_FOUND 29 // Specified object can not be found
  644. #define ERR_VLAN_ALREADY_EXISTS 30 // Virtual LAN card with the specified name already exists
  645. #define ERR_VLAN_INSTALL_ERROR 31 // Specified virtual LAN card cannot be created
  646. #define ERR_VLAN_INVALID_NAME 32 // Specified name of the virtual LAN card is invalid
  647. #define ERR_NOT_SUPPORTED 33 // Unsupported
  648. #define ERR_ACCOUNT_ALREADY_EXISTS 34 // Account already exists
  649. #define ERR_ACCOUNT_ACTIVE 35 // Account is operating
  650. #define ERR_ACCOUNT_NOT_FOUND 36 // Specified account doesn't exist
  651. #define ERR_ACCOUNT_INACTIVE 37 // Account is offline
  652. #define ERR_INVALID_PARAMETER 38 // Parameter is invalid
  653. #define ERR_SECURE_DEVICE_ERROR 39 // Error has occurred in the operation of the secure device
  654. #define ERR_NO_SECURE_DEVICE_SPECIFIED 40 // Secure device is not specified
  655. #define ERR_VLAN_IS_USED 41 // Virtual LAN card in use by account
  656. #define ERR_VLAN_FOR_ACCOUNT_NOT_FOUND 42 // Virtual LAN card of the account can not be found
  657. #define ERR_VLAN_FOR_ACCOUNT_USED 43 // Virtual LAN card of the account is already in use
  658. #define ERR_VLAN_FOR_ACCOUNT_DISABLED 44 // Virtual LAN card of the account is disabled
  659. #define ERR_INVALID_VALUE 45 // Value is invalid
  660. #define ERR_NOT_FARM_CONTROLLER 46 // Not a farm controller
  661. #define ERR_TRYING_TO_CONNECT 47 // Attempting to connect
  662. #define ERR_CONNECT_TO_FARM_CONTROLLER 48 // Failed to connect to the farm controller
  663. #define ERR_COULD_NOT_HOST_HUB_ON_FARM 49 // A virtual HUB on farm could not be created
  664. #define ERR_FARM_MEMBER_HUB_ADMIN 50 // HUB cannot be managed on a farm member
  665. #define ERR_NULL_PASSWORD_LOCAL_ONLY 51 // Accepting only local connections for an empty password
  666. #define ERR_NOT_ENOUGH_RIGHT 52 // Right is insufficient
  667. #define ERR_LISTENER_NOT_FOUND 53 // Listener can not be found
  668. #define ERR_LISTENER_ALREADY_EXISTS 54 // Listener already exists
  669. #define ERR_NOT_FARM_MEMBER 55 // Not a farm member
  670. #define ERR_CIPHER_NOT_SUPPORTED 56 // Encryption algorithm is not supported
  671. #define ERR_HUB_ALREADY_EXISTS 57 // HUB already exists
  672. #define ERR_TOO_MANY_HUBS 58 // Too many HUBs
  673. #define ERR_LINK_ALREADY_EXISTS 59 // Link already exists
  674. #define ERR_LINK_CANT_CREATE_ON_FARM 60 // The link can not be created on the server farm
  675. #define ERR_LINK_IS_OFFLINE 61 // Link is off-line
  676. #define ERR_TOO_MANY_ACCESS_LIST 62 // Too many access list
  677. #define ERR_TOO_MANY_USER 63 // Too many users
  678. #define ERR_TOO_MANY_GROUP 64 // Too many Groups
  679. #define ERR_GROUP_NOT_FOUND 65 // Group can not be found
  680. #define ERR_USER_ALREADY_EXISTS 66 // User already exists
  681. #define ERR_GROUP_ALREADY_EXISTS 67 // Group already exists
  682. #define ERR_USER_AUTHTYPE_NOT_PASSWORD 68 // Authentication method of the user is not a password authentication
  683. #define ERR_OLD_PASSWORD_WRONG 69 // The user does not exist or the old password is wrong
  684. #define ERR_LINK_CANT_DISCONNECT 73 // Cascade session cannot be disconnected
  685. #define ERR_ACCOUNT_NOT_PRESENT 74 // Not completed configure the connection to the VPN server
  686. #define ERR_ALREADY_ONLINE 75 // It is already online
  687. #define ERR_OFFLINE 76 // It is offline
  688. #define ERR_NOT_RSA_1024 77 // The certificate is not RSA 1024bit
  689. #define ERR_SNAT_CANT_DISCONNECT 78 // SecureNAT session cannot be disconnected
  690. #define ERR_SNAT_NEED_STANDALONE 79 // SecureNAT works only in stand-alone HUB
  691. #define ERR_SNAT_NOT_RUNNING 80 // SecureNAT function is not working
  692. #define ERR_SE_VPN_BLOCK 81 // Stopped by PacketiX VPN Block
  693. #define ERR_BRIDGE_CANT_DISCONNECT 82 // Bridge session can not be disconnected
  694. #define ERR_LOCAL_BRIDGE_STOPPING 83 // Bridge function is stopped
  695. #define ERR_LOCAL_BRIDGE_UNSUPPORTED 84 // Bridge feature is not supported
  696. #define ERR_CERT_NOT_TRUSTED 85 // Certificate of the destination server can not be trusted
  697. #define ERR_PRODUCT_CODE_INVALID 86 // Product code is different
  698. #define ERR_VERSION_INVALID 87 // Version is different
  699. #define ERR_CAPTURE_DEVICE_ADD_ERROR 88 // Adding capture device failure
  700. #define ERR_VPN_CODE_INVALID 89 // VPN code is different
  701. #define ERR_CAPTURE_NOT_FOUND 90 // Capture device can not be found
  702. #define ERR_LAYER3_CANT_DISCONNECT 91 // Layer-3 session cannot be disconnected
  703. #define ERR_LAYER3_SW_EXISTS 92 // L3 switch of the same already exists
  704. #define ERR_LAYER3_SW_NOT_FOUND 93 // Layer-3 switch can not be found
  705. #define ERR_INVALID_NAME 94 // Name is invalid
  706. #define ERR_LAYER3_IF_ADD_FAILED 95 // Failed to add interface
  707. #define ERR_LAYER3_IF_DEL_FAILED 96 // Failed to delete the interface
  708. #define ERR_LAYER3_IF_EXISTS 97 // Interface that you specified already exists
  709. #define ERR_LAYER3_TABLE_ADD_FAILED 98 // Failed to add routing table
  710. #define ERR_LAYER3_TABLE_DEL_FAILED 99 // Failed to delete the routing table
  711. #define ERR_LAYER3_TABLE_EXISTS 100 // Routing table entry that you specified already exists
  712. #define ERR_BAD_CLOCK 101 // Time is queer
  713. #define ERR_LAYER3_CANT_START_SWITCH 102 // The Virtual Layer 3 Switch can not be started
  714. #define ERR_CLIENT_LICENSE_NOT_ENOUGH 103 // Client connection licenses shortage
  715. #define ERR_BRIDGE_LICENSE_NOT_ENOUGH 104 // Bridge connection licenses shortage
  716. #define ERR_SERVER_CANT_ACCEPT 105 // Not Accept on the technical issues
  717. #define ERR_SERVER_CERT_EXPIRES 106 // Destination VPN server has expired
  718. #define ERR_MONITOR_MODE_DENIED 107 // Monitor port mode was rejected
  719. #define ERR_BRIDGE_MODE_DENIED 108 // Bridge-mode or Routing-mode was rejected
  720. #define ERR_IP_ADDRESS_DENIED 109 // Client IP address is denied
  721. #define ERR_TOO_MANT_ITEMS 110 // Too many items
  722. #define ERR_MEMORY_NOT_ENOUGH 111 // Out of memory
  723. #define ERR_OBJECT_EXISTS 112 // Object already exists
  724. #define ERR_FATAL 113 // A fatal error occurred
  725. #define ERR_SERVER_LICENSE_FAILED 114 // License violation has occurred on the server side
  726. #define ERR_SERVER_INTERNET_FAILED 115 // Server side is not connected to the Internet
  727. #define ERR_CLIENT_LICENSE_FAILED 116 // License violation occurs on the client side
  728. #define ERR_BAD_COMMAND_OR_PARAM 117 // Command or parameter is invalid
  729. #define ERR_INVALID_LICENSE_KEY 118 // License key is invalid
  730. #define ERR_NO_VPN_SERVER_LICENSE 119 // There is no valid license for the VPN Server
  731. #define ERR_NO_VPN_CLUSTER_LICENSE 120 // There is no cluster license
  732. #define ERR_NOT_ADMINPACK_SERVER 121 // Not trying to connect to a server with the Administrator Pack license
  733. #define ERR_NOT_ADMINPACK_SERVER_NET 122 // Not trying to connect to a server with the Administrator Pack license (for .NET)
  734. #define ERR_BETA_EXPIRES 123 // Destination Beta VPN Server has expired
  735. #define ERR_BRANDED_C_TO_S 124 // Branding string of connection limit is different (Authentication on the server side)
  736. #define ERR_BRANDED_C_FROM_S 125 // Branding string of connection limit is different (Authentication for client-side)
  737. #define ERR_AUTO_DISCONNECTED 126 // VPN session is disconnected for a certain period of time has elapsed
  738. #define ERR_CLIENT_ID_REQUIRED 127 // Client ID does not match
  739. #define ERR_TOO_MANY_USERS_CREATED 128 // Too many created users
  740. #define ERR_SUBSCRIPTION_IS_OLDER 129 // Subscription expiration date Is earlier than the build date of the VPN Server
  741. #define ERR_ILLEGAL_TRIAL_VERSION 130 // Many trial license is used continuously
  742. #define ERR_NAT_T_TWO_OR_MORE 131 // There are multiple servers in the back of a global IP address in the NAT-T connection
  743. #define ERR_DUPLICATE_DDNS_KEY 132 // DDNS host key duplicate
  744. #define ERR_DDNS_HOSTNAME_EXISTS 133 // Specified DDNS host name already exists
  745. #define ERR_DDNS_HOSTNAME_INVALID_CHAR 134 // Characters that can not be used for the host name is included
  746. #define ERR_DDNS_HOSTNAME_TOO_LONG 135 // Host name is too long
  747. #define ERR_DDNS_HOSTNAME_IS_EMPTY 136 // Host name is not specified
  748. #define ERR_DDNS_HOSTNAME_TOO_SHORT 137 // Host name is too short
  749. #define ERR_MSCHAP2_PASSWORD_NEED_RESET 138 // Necessary that password is changed
  750. #define ERR_DDNS_DISCONNECTED 139 // Communication to the dynamic DNS server is disconnected
  751. #define ERR_SPECIAL_LISTENER_ICMP_ERROR 140 // The ICMP socket can not be opened
  752. #define ERR_SPECIAL_LISTENER_DNS_ERROR 141 // Socket for DNS port can not be opened
  753. #define ERR_OPENVPN_IS_NOT_ENABLED 142 // OpenVPN server feature is not enabled
  754. #define ERR_NOT_SUPPORTED_AUTH_ON_OPENSOURCE 143 // It is the type of user authentication that are not supported in the open source version
  755. #define ERR_VPNGATE 144 // Operation on VPN Gate Server is not available
  756. #define ERR_VPNGATE_CLIENT 145 // Operation on VPN Gate Client is not available
  757. #define ERR_VPNGATE_INCLIENT_CANT_STOP 146 // Can not be stopped if operating within VPN Client mode
  758. #define ERR_NOT_SUPPORTED_FUNCTION_ON_OPENSOURCE 147 // It is a feature that is not supported in the open source version
  759. ////////////////////////////
  760. // Generally used structure
  761. // Network Services
  762. typedef struct NETSVC
  763. {
  764. bool Udp; // false=TCP, true=UDP
  765. UINT Port; // Port number
  766. char *Name; // Name
  767. } NETSVC;
  768. // Traffic data entry
  769. typedef struct TRAFFIC_ENTRY
  770. {
  771. UINT64 BroadcastCount; // Number of broadcast packets
  772. UINT64 BroadcastBytes; // Broadcast bytes
  773. UINT64 UnicastCount; // Unicast count
  774. UINT64 UnicastBytes; // Unicast bytes
  775. } TRAFFIC_ENTRY;
  776. // Traffic data
  777. typedef struct TRAFFIC
  778. {
  779. TRAFFIC_ENTRY Send; // Transmitted data
  780. TRAFFIC_ENTRY Recv; // Received data
  781. } TRAFFIC;
  782. // Non-SSL connection source
  783. typedef struct NON_SSL
  784. {
  785. IP IpAddress; // IP address
  786. UINT64 EntryExpires; // Expiration date of entry
  787. UINT Count; // Number of connection count
  788. } NON_SSL;
  789. // Simple log storage
  790. typedef struct TINY_LOG
  791. {
  792. char FileName[MAX_PATH]; // File name
  793. IO *io; // File
  794. LOCK *Lock; // Lock
  795. } TINY_LOG;
  796. // CEDAR structure
  797. typedef struct CEDAR
  798. {
  799. LOCK *lock; // Lock
  800. REF *ref; // Reference counter
  801. COUNTER *AcceptingSockets; // Number of sockets in Accept
  802. UINT Type; // Type
  803. LIST *ListenerList; // Listener list
  804. LIST *HubList; // HUB list
  805. LIST *ConnectionList; // Negotiating connection list
  806. LIST *CaList; // List of CA
  807. volatile bool Halt; // Halt flag
  808. COUNTER *ConnectionIncrement; // Connection increment counter
  809. X *ServerX; // Server certificate
  810. K *ServerK; // Private key of the server certificate
  811. char *CipherList; // List of encryption algorithms
  812. UINT Version; // Version information
  813. UINT Build; // Build Number
  814. char *ServerStr; // Server string
  815. char *MachineName; // Computer name
  816. char *HttpUserAgent; // HTTP user agent
  817. char *HttpAccept; // HTTP Accept
  818. char *HttpAcceptLanguage; // HTTP Accept Language
  819. char *HttpAcceptEncoding; // HTTP Accept Encoding
  820. TRAFFIC *Traffic; // Traffic information
  821. LOCK *TrafficLock; // Traffic information lock
  822. LIST *UDPEntryList; // UDP entry list
  823. COUNTER *CurrentSessions; // The current number of sessions
  824. COUNTER *CurrentTcpConnections; // Number of current TCP connections
  825. LIST *NetSvcList; // Network service list
  826. char *VerString; // Version string
  827. char *BuildInfo; // Build Information
  828. struct CLIENT *Client; // Client
  829. struct SERVER *Server; // Server
  830. UINT64 CreatedTick; // Generation date and time
  831. bool CheckExpires; // Check the expiration date
  832. LIST *TrafficDiffList; // Traffic difference list
  833. struct LOG *DebugLog; // Debug log
  834. UCHAR UniqueId[16]; // Unique ID
  835. LIST *LocalBridgeList; // Local bridge list
  836. bool Bridge; // Bridge version
  837. LIST *L3SwList; // Layer-3 switch list
  838. COUNTER *AssignedClientLicense; // Number of assigned client licenses
  839. COUNTER *AssignedBridgeLicense; // Number of assigned bridge licenses
  840. UINT64 LicenseViolationTick; // License violation occurs
  841. LIST *NonSslList; // Non-SSL connection list
  842. struct WEBUI *WebUI; // Data for WebUI service
  843. UINT Beta; // Beta number
  844. LOCK *CedarSuperLock; // Cedar super lock!
  845. bool DisableIPv6Listener; // Disable IPv6 listener
  846. UINT ClientId; // Client ID
  847. UINT64 BuiltDate; // Build Date
  848. LIST *UdpPortList; // UDP port list in use
  849. char CurrentDDnsFqdn[MAX_SIZE]; // FQDN of the current DDNS
  850. char OpenVPNPublicPorts[MAX_SIZE]; // OpenVPN public UDP port list
  851. LOCK *OpenVPNPublicPortsLock; // Lock of OpenVPN public UDP port list
  852. LOCK *CurrentRegionLock; // Current region lock
  853. char CurrentRegion[128]; // Current region
  854. } CEDAR;
  855. // Type of CEDAR
  856. #define CEDAR_CLIENT 0 // Client
  857. #define CEDAR_STANDALONE_SERVER 1 // Stand-alone server
  858. #define CEDAR_FARM_CONTROLLER 2 // Server farm controller
  859. #define CEDAR_FARM_MEMBER 3 // Server farm member
  860. ////////////////////////////
  861. // Read the header file
  862. // Type
  863. #include <Cedar/CedarType.h>
  864. // Account Manager
  865. #include <Cedar/Account.h>
  866. // Listener module
  867. #include <Cedar/Listener.h>
  868. // Log storage module
  869. #include <Cedar/Logging.h>
  870. // Connection management
  871. #include <Cedar/Connection.h>
  872. // Session Management
  873. #include <Cedar/Session.h>
  874. // RPC
  875. #include <Cedar/Remote.h>
  876. // HUB management
  877. #include <Cedar/Hub.h>
  878. // Security Accounts Manager
  879. #include <Cedar/Sam.h>
  880. // Radius authentication module
  881. #include <Cedar/Radius.h>
  882. // Protocol
  883. #include <Cedar/Protocol.h>
  884. // Inter-HUB link
  885. #include <Cedar/Link.h>
  886. // User-mode virtual host
  887. #include <Cedar/Virtual.h>
  888. // SecureNAT
  889. #include <Cedar/SecureNAT.h>
  890. // Digital watermark
  891. #include <Cedar/WaterMark.h>
  892. // Secure data
  893. #include <Cedar/SecureInfo.h>
  894. // Console service
  895. #include <Cedar/Console.h>
  896. // Vpncmd utility
  897. #include <Cedar/Command.h>
  898. // RPC over HTTP
  899. #include <Cedar/Wpc.h>
  900. // IPsec
  901. #include <Cedar/IPsec.h>
  902. #include <Cedar/IPsec_L2TP.h>
  903. #include <Cedar/IPsec_PPP.h>
  904. #include <Cedar/IPsec_IPC.h>
  905. #include <Cedar/IPsec_IkePacket.h>
  906. #include <Cedar/IPsec_IKE.h>
  907. #include <Cedar/IPsec_Win7.h>
  908. #include <Cedar/IPsec_EtherIP.h>
  909. // SSTP
  910. #include <Cedar/Interop_SSTP.h>
  911. // OpenVPN
  912. #include <Cedar/Interop_OpenVPN.h>
  913. // UDP Acceleration
  914. #include <Cedar/UdpAccel.h>
  915. // DDNS Client
  916. #include <Cedar/DDNS.h>
  917. // VPN Azure Client
  918. #include <Cedar/AzureClient.h>
  919. // VPN Azure Server
  920. #include <Cedar/AzureServer.h>
  921. // Native IP Stack
  922. #include <Cedar/NativeStack.h>
  923. #ifdef OS_WIN32
  924. // Neo device driver
  925. #include <Neo/Neo.h>
  926. // SeLow User-mode
  927. #include <Cedar/SeLowUser.h>
  928. #endif // OS_WIN32
  929. // Neo device driver manipulation library
  930. #include <Cedar/VLan.h>
  931. // Bridge
  932. #include <Cedar/Bridge.h>
  933. // Layer-3 switch
  934. #include <Cedar/Layer3.h>
  935. // Virtual LAN card for test
  936. #include <Cedar/NullLan.h>
  937. // Client
  938. #include <Cedar/Client.h>
  939. // Server
  940. #include <Cedar/Server.h>
  941. // License database
  942. #include <Cedar/Database.h>
  943. // EtherLogger
  944. #include <Cedar/EtherLog.h>
  945. // Management RPC
  946. #include <Cedar/Admin.h>
  947. // User-mode Router
  948. #include <Cedar/Nat.h>
  949. // Web UI
  950. #include <Cedar/WebUI.h>
  951. // VPN Gate Plugin DLL
  952. #include <VGate/VGateCommon.h>
  953. // VPN Gate Main Implementation
  954. #include <Cedar/VG.h>
  955. #ifdef OS_WIN32
  956. // Win32 user interface
  957. #include <Cedar/WinUi.h>
  958. // Win32 Client Connection Manager
  959. #include <Cedar/CM.h>
  960. // Win32 Server Manager
  961. #include <Cedar/SM.h>
  962. // Win32 User-mode Router Manager
  963. #include <Cedar/NM.h>
  964. // Win32 EtherLogger Manager
  965. #include <Cedar/EM.h>
  966. // Win32 Network Utility
  967. #include <Cedar/UT.h>
  968. // Win32 Setup Wizard
  969. #include <Cedar/SW.h>
  970. // Win32 COM calling module
  971. #include <Cedar/Win32Com.h>
  972. #endif
  973. ////////////////////////////
  974. // Function prototype
  975. TRAFFIC *NewTraffic();
  976. void FreeTraffic(TRAFFIC *t);
  977. CEDAR *NewCedar(X *server_x, K *server_k);
  978. void CedarForceLink();
  979. void SetCedarVpnBridge(CEDAR *c);
  980. void SetCedarCert(CEDAR *c, X *server_x, K *server_k);
  981. void ReleaseCedar(CEDAR *c);
  982. void CleanupCedar(CEDAR *c);
  983. void StopCedar(CEDAR *c);
  984. void AddListener(CEDAR *c, LISTENER *r);
  985. void StopAllListener(CEDAR *c);
  986. void AddTraffic(TRAFFIC *dst, TRAFFIC *diff);
  987. void AddHub(CEDAR *c, HUB *h);
  988. void DelHub(CEDAR *c, HUB *h);
  989. void DelHubEx(CEDAR *c, HUB *h, bool no_lock);
  990. void StopAllHub(CEDAR *c);
  991. void StopAllConnection(CEDAR *c);
  992. void AddConnection(CEDAR *cedar, CONNECTION *c);
  993. UINT GetUnestablishedConnections(CEDAR *cedar);
  994. void DelConnection(CEDAR *cedar, CONNECTION *c);
  995. void SetCedarCipherList(CEDAR *cedar, char *name);
  996. void InitCedar();
  997. void FreeCedar();
  998. void AddCa(CEDAR *cedar, X *x);
  999. bool DeleteCa(CEDAR *cedar, UINT ptr);
  1000. bool CheckSignatureByCa(CEDAR *cedar, X *x);
  1001. bool CheckSignatureByCaLinkMode(SESSION *s, X *x);
  1002. X *FindCaSignedX(LIST *o, X *x);
  1003. void InitNetSvcList(CEDAR *cedar);
  1004. void FreeNetSvcList(CEDAR *cedar);
  1005. int CompareNetSvc(void *p1, void *p2);
  1006. char *GetSvcName(CEDAR *cedar, bool udp, UINT port);
  1007. void InitHiddenPassword(char *str, UINT size);
  1008. bool IsHiddenPasswordChanged(char *str);
  1009. UINT64 GetTrafficPacketSize(TRAFFIC *t);
  1010. UINT64 GetTrafficPacketNum(TRAFFIC *t);
  1011. void EnableDebugLog(CEDAR *c);
  1012. void StartCedarLog();
  1013. void StopCedarLog();
  1014. void CedarLog(char *str);
  1015. int CompareNoSslList(void *p1, void *p2);
  1016. void InitNoSslList(CEDAR *c);
  1017. void FreeNoSslList(CEDAR *c);
  1018. bool AddNoSsl(CEDAR *c, IP *ip);
  1019. void DecrementNoSsl(CEDAR *c, IP *ip, UINT num_dec);
  1020. void DeleteOldNoSsl(CEDAR *c);
  1021. NON_SSL *SearchNoSslList(CEDAR *c, IP *ip);
  1022. bool IsInNoSsl(CEDAR *c, IP *ip);
  1023. void FreeTinyLog(TINY_LOG *t);
  1024. void WriteTinyLog(TINY_LOG *t, char *str);
  1025. TINY_LOG *NewTinyLog();
  1026. void GetWinVer(RPC_WINVER *v);
  1027. bool IsSupportedWinVer(RPC_WINVER *v);
  1028. bool IsLaterBuild(CEDAR *c, UINT64 t);
  1029. SOCK *GetInProcListeningSock(CEDAR *c);
  1030. SOCK *GetReverseListeningSock(CEDAR *c);
  1031. void GetCedarVersion(char *tmp, UINT size);
  1032. UINT64 GetCurrentBuildDate();
  1033. #endif // CEDAR_H
  1034. // Developed by SoftEther VPN Project at University of Tsukuba in Japan.
  1035. // Department of Computer Science has dozens of overly-enthusiastic geeks.
  1036. // Join us: http://www.tsukuba.ac.jp/english/admission/