1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/media/mtransport/third_party/nICEr/src/stun/stun_build.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,154 @@ 1.4 +/* 1.5 +Copyright (c) 2007, Adobe Systems, Incorporated 1.6 +All rights reserved. 1.7 + 1.8 +Redistribution and use in source and binary forms, with or without 1.9 +modification, are permitted provided that the following conditions are 1.10 +met: 1.11 + 1.12 +* Redistributions of source code must retain the above copyright 1.13 + notice, this list of conditions and the following disclaimer. 1.14 + 1.15 +* Redistributions in binary form must reproduce the above copyright 1.16 + notice, this list of conditions and the following disclaimer in the 1.17 + documentation and/or other materials provided with the distribution. 1.18 + 1.19 +* Neither the name of Adobe Systems, Network Resonance nor the names of its 1.20 + contributors may be used to endorse or promote products derived from 1.21 + this software without specific prior written permission. 1.22 + 1.23 +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 1.24 +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 1.25 +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 1.26 +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 1.27 +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 1.28 +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 1.29 +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 1.30 +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 1.31 +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 1.32 +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 1.33 +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 1.34 +*/ 1.35 + 1.36 + 1.37 +#ifndef _stun_build_h 1.38 +#define _stun_build_h 1.39 + 1.40 +#include "stun.h" 1.41 + 1.42 +#define NR_STUN_MODE_STUN 1 1.43 +#ifdef USE_STUND_0_96 1.44 +#define NR_STUN_MODE_STUND_0_96 2 /* backwards compatibility mode */ 1.45 +#endif /* USE_STUND_0_96 */ 1.46 +int nr_stun_form_request_or_indication(int mode, int msg_type, nr_stun_message **msg); 1.47 + 1.48 +typedef struct nr_stun_client_stun_binding_request_params_ { 1.49 + char *username; 1.50 + Data *password; 1.51 + char *nonce; 1.52 + char *realm; 1.53 +} nr_stun_client_stun_binding_request_params; 1.54 + 1.55 +int nr_stun_build_req_lt_auth(nr_stun_client_stun_binding_request_params *params, nr_stun_message **msg); 1.56 +int nr_stun_build_req_st_auth(nr_stun_client_stun_binding_request_params *params, nr_stun_message **msg); 1.57 +int nr_stun_build_req_no_auth(nr_stun_client_stun_binding_request_params *params, nr_stun_message **msg); 1.58 + 1.59 + 1.60 +typedef struct nr_stun_client_stun_keepalive_params_ { 1.61 +#if defined(WIN32) || defined(__clang__) 1.62 + // VC++ and clang give error and warning respectively if no members 1.63 + int dummy; 1.64 +#endif 1.65 +} nr_stun_client_stun_keepalive_params; 1.66 + 1.67 +int nr_stun_build_keepalive(nr_stun_client_stun_keepalive_params *params, nr_stun_message **msg); 1.68 + 1.69 + 1.70 +#ifdef USE_STUND_0_96 1.71 +typedef struct nr_stun_client_stun_binding_request_stund_0_96_params_ { 1.72 +#ifdef WIN32 // silly VC++ gives error if no members 1.73 + int dummy; 1.74 +#endif 1.75 +} nr_stun_client_stun_binding_request_stund_0_96_params; 1.76 + 1.77 +int nr_stun_build_req_stund_0_96(nr_stun_client_stun_binding_request_stund_0_96_params *params, nr_stun_message **msg); 1.78 +#endif /* USE_STUND_0_96 */ 1.79 + 1.80 + 1.81 +#ifdef USE_ICE 1.82 +typedef struct nr_stun_client_ice_use_candidate_params_ { 1.83 + char *username; 1.84 + Data password; 1.85 + UINT4 priority; 1.86 + UINT8 tiebreaker; 1.87 +} nr_stun_client_ice_use_candidate_params; 1.88 + 1.89 +int nr_stun_build_use_candidate(nr_stun_client_ice_use_candidate_params *params, nr_stun_message **msg); 1.90 + 1.91 + 1.92 +typedef struct nr_stun_client_ice_binding_request_params_ { 1.93 + char *username; 1.94 + Data password; 1.95 + UINT4 priority; 1.96 + int control; 1.97 +#define NR_ICE_CONTROLLING 1 1.98 +#define NR_ICE_CONTROLLED 2 1.99 + UINT8 tiebreaker; 1.100 +} nr_stun_client_ice_binding_request_params; 1.101 + 1.102 +int nr_stun_build_req_ice(nr_stun_client_ice_binding_request_params *params, nr_stun_message **msg); 1.103 +#endif /* USE_ICE */ 1.104 + 1.105 + 1.106 +typedef struct nr_stun_client_auth_params_ { 1.107 + char authenticate; 1.108 + char *username; 1.109 + char *realm; 1.110 + char *nonce; 1.111 + Data password; 1.112 +} nr_stun_client_auth_params; 1.113 + 1.114 +#ifdef USE_TURN 1.115 +typedef struct nr_stun_client_allocate_request_params_ { 1.116 + UINT4 lifetime_secs; 1.117 +} nr_stun_client_allocate_request_params; 1.118 + 1.119 +int nr_stun_build_allocate_request(nr_stun_client_auth_params *auth, nr_stun_client_allocate_request_params *params, nr_stun_message **msg); 1.120 + 1.121 + 1.122 +typedef struct nr_stun_client_refresh_request_params_ { 1.123 + UINT4 lifetime_secs; 1.124 +} nr_stun_client_refresh_request_params; 1.125 + 1.126 +int nr_stun_build_refresh_request(nr_stun_client_auth_params *auth, nr_stun_client_refresh_request_params *params, nr_stun_message **msg); 1.127 + 1.128 + 1.129 + 1.130 +typedef struct nr_stun_client_permission_request_params_ { 1.131 + nr_transport_addr remote_addr; 1.132 +} nr_stun_client_permission_request_params; 1.133 + 1.134 +int nr_stun_build_permission_request(nr_stun_client_auth_params *auth, nr_stun_client_permission_request_params *params, nr_stun_message **msg); 1.135 + 1.136 + 1.137 +typedef struct nr_stun_client_send_indication_params_ { 1.138 + nr_transport_addr remote_addr; 1.139 + Data data; 1.140 +} nr_stun_client_send_indication_params; 1.141 + 1.142 +int nr_stun_build_send_indication(nr_stun_client_send_indication_params *params, nr_stun_message **msg); 1.143 + 1.144 +typedef struct nr_stun_client_data_indication_params_ { 1.145 + nr_transport_addr remote_addr; 1.146 + Data data; 1.147 +} nr_stun_client_data_indication_params; 1.148 + 1.149 +int nr_stun_build_data_indication(nr_stun_client_data_indication_params *params, nr_stun_message **msg); 1.150 +#endif /* USE_TURN */ 1.151 + 1.152 +int nr_stun_form_success_response(nr_stun_message *req, nr_transport_addr *from, Data *password, nr_stun_message *res); 1.153 +void nr_stun_form_error_response(nr_stun_message *request, nr_stun_message* response, int number, char* msg); 1.154 +int nr_stun_compute_lt_message_integrity_password(const char *username, const char *realm, 1.155 + Data *password, Data *hmac_key); 1.156 + 1.157 +#endif