michael@0: /* michael@0: Copyright (c) 2007, Adobe Systems, Incorporated michael@0: All rights reserved. michael@0: michael@0: Redistribution and use in source and binary forms, with or without michael@0: modification, are permitted provided that the following conditions are michael@0: met: michael@0: michael@0: * Redistributions of source code must retain the above copyright michael@0: notice, this list of conditions and the following disclaimer. michael@0: michael@0: * Redistributions in binary form must reproduce the above copyright michael@0: notice, this list of conditions and the following disclaimer in the michael@0: documentation and/or other materials provided with the distribution. michael@0: michael@0: * Neither the name of Adobe Systems, Network Resonance nor the names of its michael@0: contributors may be used to endorse or promote products derived from michael@0: this software without specific prior written permission. michael@0: michael@0: THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS michael@0: "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT michael@0: LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR michael@0: A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT michael@0: OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, michael@0: SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT michael@0: LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, michael@0: DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY michael@0: THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT michael@0: (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE michael@0: OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. michael@0: */ michael@0: michael@0: michael@0: #ifndef _stun_build_h michael@0: #define _stun_build_h michael@0: michael@0: #include "stun.h" michael@0: michael@0: #define NR_STUN_MODE_STUN 1 michael@0: #ifdef USE_STUND_0_96 michael@0: #define NR_STUN_MODE_STUND_0_96 2 /* backwards compatibility mode */ michael@0: #endif /* USE_STUND_0_96 */ michael@0: int nr_stun_form_request_or_indication(int mode, int msg_type, nr_stun_message **msg); michael@0: michael@0: typedef struct nr_stun_client_stun_binding_request_params_ { michael@0: char *username; michael@0: Data *password; michael@0: char *nonce; michael@0: char *realm; michael@0: } nr_stun_client_stun_binding_request_params; michael@0: michael@0: int nr_stun_build_req_lt_auth(nr_stun_client_stun_binding_request_params *params, nr_stun_message **msg); michael@0: int nr_stun_build_req_st_auth(nr_stun_client_stun_binding_request_params *params, nr_stun_message **msg); michael@0: int nr_stun_build_req_no_auth(nr_stun_client_stun_binding_request_params *params, nr_stun_message **msg); michael@0: michael@0: michael@0: typedef struct nr_stun_client_stun_keepalive_params_ { michael@0: #if defined(WIN32) || defined(__clang__) michael@0: // VC++ and clang give error and warning respectively if no members michael@0: int dummy; michael@0: #endif michael@0: } nr_stun_client_stun_keepalive_params; michael@0: michael@0: int nr_stun_build_keepalive(nr_stun_client_stun_keepalive_params *params, nr_stun_message **msg); michael@0: michael@0: michael@0: #ifdef USE_STUND_0_96 michael@0: typedef struct nr_stun_client_stun_binding_request_stund_0_96_params_ { michael@0: #ifdef WIN32 // silly VC++ gives error if no members michael@0: int dummy; michael@0: #endif michael@0: } nr_stun_client_stun_binding_request_stund_0_96_params; michael@0: michael@0: int nr_stun_build_req_stund_0_96(nr_stun_client_stun_binding_request_stund_0_96_params *params, nr_stun_message **msg); michael@0: #endif /* USE_STUND_0_96 */ michael@0: michael@0: michael@0: #ifdef USE_ICE michael@0: typedef struct nr_stun_client_ice_use_candidate_params_ { michael@0: char *username; michael@0: Data password; michael@0: UINT4 priority; michael@0: UINT8 tiebreaker; michael@0: } nr_stun_client_ice_use_candidate_params; michael@0: michael@0: int nr_stun_build_use_candidate(nr_stun_client_ice_use_candidate_params *params, nr_stun_message **msg); michael@0: michael@0: michael@0: typedef struct nr_stun_client_ice_binding_request_params_ { michael@0: char *username; michael@0: Data password; michael@0: UINT4 priority; michael@0: int control; michael@0: #define NR_ICE_CONTROLLING 1 michael@0: #define NR_ICE_CONTROLLED 2 michael@0: UINT8 tiebreaker; michael@0: } nr_stun_client_ice_binding_request_params; michael@0: michael@0: int nr_stun_build_req_ice(nr_stun_client_ice_binding_request_params *params, nr_stun_message **msg); michael@0: #endif /* USE_ICE */ michael@0: michael@0: michael@0: typedef struct nr_stun_client_auth_params_ { michael@0: char authenticate; michael@0: char *username; michael@0: char *realm; michael@0: char *nonce; michael@0: Data password; michael@0: } nr_stun_client_auth_params; michael@0: michael@0: #ifdef USE_TURN michael@0: typedef struct nr_stun_client_allocate_request_params_ { michael@0: UINT4 lifetime_secs; michael@0: } nr_stun_client_allocate_request_params; michael@0: michael@0: int nr_stun_build_allocate_request(nr_stun_client_auth_params *auth, nr_stun_client_allocate_request_params *params, nr_stun_message **msg); michael@0: michael@0: michael@0: typedef struct nr_stun_client_refresh_request_params_ { michael@0: UINT4 lifetime_secs; michael@0: } nr_stun_client_refresh_request_params; michael@0: michael@0: int nr_stun_build_refresh_request(nr_stun_client_auth_params *auth, nr_stun_client_refresh_request_params *params, nr_stun_message **msg); michael@0: michael@0: michael@0: michael@0: typedef struct nr_stun_client_permission_request_params_ { michael@0: nr_transport_addr remote_addr; michael@0: } nr_stun_client_permission_request_params; michael@0: michael@0: int nr_stun_build_permission_request(nr_stun_client_auth_params *auth, nr_stun_client_permission_request_params *params, nr_stun_message **msg); michael@0: michael@0: michael@0: typedef struct nr_stun_client_send_indication_params_ { michael@0: nr_transport_addr remote_addr; michael@0: Data data; michael@0: } nr_stun_client_send_indication_params; michael@0: michael@0: int nr_stun_build_send_indication(nr_stun_client_send_indication_params *params, nr_stun_message **msg); michael@0: michael@0: typedef struct nr_stun_client_data_indication_params_ { michael@0: nr_transport_addr remote_addr; michael@0: Data data; michael@0: } nr_stun_client_data_indication_params; michael@0: michael@0: int nr_stun_build_data_indication(nr_stun_client_data_indication_params *params, nr_stun_message **msg); michael@0: #endif /* USE_TURN */ michael@0: michael@0: int nr_stun_form_success_response(nr_stun_message *req, nr_transport_addr *from, Data *password, nr_stun_message *res); michael@0: void nr_stun_form_error_response(nr_stun_message *request, nr_stun_message* response, int number, char* msg); michael@0: int nr_stun_compute_lt_message_integrity_password(const char *username, const char *realm, michael@0: Data *password, Data *hmac_key); michael@0: michael@0: #endif