uclient.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. /*
  2. * Copyright (C) 2011, 2012, 2013 Citrix Systems
  3. *
  4. * All rights reserved.
  5. *
  6. * Redistribution and use in source and binary forms, with or without
  7. * modification, are permitted provided that the following conditions
  8. * are met:
  9. * 1. Redistributions of source code must retain the above copyright
  10. * notice, this list of conditions and the following disclaimer.
  11. * 2. Redistributions in binary form must reproduce the above copyright
  12. * notice, this list of conditions and the following disclaimer in the
  13. * documentation and/or other materials provided with the distribution.
  14. * 3. Neither the name of the project nor the names of its contributors
  15. * may be used to endorse or promote products derived from this software
  16. * without specific prior written permission.
  17. *
  18. * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
  19. * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  20. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  21. * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
  22. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  23. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  24. * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  25. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  26. * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  27. * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  28. * SUCH DAMAGE.
  29. */
  30. #ifndef __UCLIENT_ECHO__
  31. #define __UCLIENT_ECHO__
  32. #include "ns_turn_utils.h"
  33. #include "stun_buffer.h"
  34. #include "session.h"
  35. #include <openssl/ssl.h>
  36. #include <openssl/dh.h>
  37. #include <openssl/bn.h>
  38. #ifdef __cplusplus
  39. extern "C" {
  40. #endif
  41. //////////////////////////////////////////////
  42. #define STOPPING_TIME (10)
  43. #define STARTING_TCP_RELAY_TIME (30)
  44. extern int clmessage_length;
  45. extern int do_not_use_channel;
  46. extern int clnet_verbose;
  47. extern int use_tcp;
  48. extern int use_sctp;
  49. extern int use_secure;
  50. extern char cert_file[1025];
  51. extern char pkey_file[1025];
  52. extern int hang_on;
  53. extern int c2c;
  54. extern ioa_addr peer_addr;
  55. extern int no_rtcp;
  56. extern int default_address_family;
  57. extern int dont_fragment;
  58. extern u08bits g_uname[STUN_MAX_USERNAME_SIZE+1];
  59. extern password_t g_upwd;
  60. extern char g_auth_secret[1025];
  61. extern int g_use_auth_secret_with_timestamp;
  62. extern int use_fingerprints;
  63. extern SSL_CTX *root_tls_ctx[32];
  64. extern int root_tls_ctx_num;
  65. extern int RTP_PACKET_INTERVAL;
  66. extern u08bits relay_transport;
  67. extern unsigned char client_ifname[1025];
  68. extern struct event_base* client_event_base;
  69. extern int passive_tcp;
  70. extern int mandatory_channel_padding;
  71. extern int negative_test;
  72. extern int negative_protocol_test;
  73. extern int dos;
  74. extern int random_disconnect;
  75. extern SHATYPE shatype;
  76. extern int mobility;
  77. extern int no_permissions;
  78. extern int extra_requests;
  79. extern band_limit_t bps;
  80. extern int dual_allocation;
  81. extern char origin[STUN_MAX_ORIGIN_SIZE+1];
  82. extern int oauth;
  83. extern oauth_key okey_array[3];
  84. #define UCLIENT_SESSION_LIFETIME (777)
  85. #define OAUTH_SESSION_LIFETIME (555)
  86. #define is_TCP_relay() (relay_transport == STUN_ATTRIBUTE_TRANSPORT_TCP_VALUE)
  87. void start_mclient(const char *remote_address, int port,
  88. const unsigned char* ifname, const char *local_address,
  89. int messagenumber, int mclient);
  90. int send_buffer(app_ur_conn_info *clnet_info, stun_buffer* message, int data_connection, app_tcp_conn_info *atc);
  91. int recv_buffer(app_ur_conn_info *clnet_info, stun_buffer* message, int sync, int data_connection, app_tcp_conn_info *atc, stun_buffer* request_message);
  92. void client_input_handler(evutil_socket_t fd, short what, void* arg);
  93. turn_credential_type get_turn_credentials_type(void);
  94. int add_integrity(app_ur_conn_info *clnet_info, stun_buffer *message);
  95. int check_integrity(app_ur_conn_info *clnet_info, stun_buffer *message);
  96. void recalculate_restapi_hmac(SHATYPE st);
  97. ////////////////////////////////////////////
  98. #ifdef __cplusplus
  99. }
  100. #endif
  101. #endif //__UCLIENT_ECHO__