Fix GCC warnings
This commit is contained in:
parent
d96205b245
commit
2190d46a14
|
@ -30,6 +30,9 @@
|
|||
#include "tsk_memory.h"
|
||||
#include "tsk_debug.h"
|
||||
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
static tsk_object_t* tdav_video_frame_ctor(tsk_object_t * self, va_list * app)
|
||||
{
|
||||
tdav_video_frame_t *frame = self;
|
||||
|
|
|
@ -259,9 +259,9 @@ tsk_size_t thttp_auth_ws_response(const char* key, thttp_auth_ws_keystring_t* re
|
|||
tsk_strcat_2(&tmp, "%s258EAFA5-E914-47DA-95CA-C5AB0DC85B11", key);
|
||||
|
||||
tsk_sha1compute(tmp, tsk_strlen(tmp), &sha1result);
|
||||
size = tsk_strlen(sha1result);
|
||||
size = tsk_strlen((char*)sha1result);
|
||||
for(i = 0; i<size; i+=2){
|
||||
if(sscanf(&sha1result[i], "%2x", (unsigned int *)&ret) != EOF){;
|
||||
if(sscanf((const char*)&sha1result[i], "%2x", (unsigned int*)&ret) != EOF){;
|
||||
result[i >> 1] = (char)ret;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -263,8 +263,8 @@ int tmedia_parse_video_imageattr(const char* imageattr, tmedia_pref_video_size_t
|
|||
}
|
||||
|
||||
|
||||
for(i = 0; i < attr.send.count; ++i) _imageattr_get_best_size(&attr.send.sets[i], out_width, out_height);
|
||||
for(i = 0; i < attr.recv.count; ++i) _imageattr_get_best_size(&attr.recv.sets[i], in_width, in_height);
|
||||
for(i = 0; i < attr.send.count; ++i) _imageattr_get_best_size(&attr.send.sets[i], (xyvalue_t*)out_width, (xyvalue_t*)out_height);
|
||||
for(i = 0; i < attr.recv.count; ++i) _imageattr_get_best_size(&attr.recv.sets[i], (xyvalue_t*)in_width, (xyvalue_t*)in_height);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
|
||||
// /!\ These are global values shared by all sessions and stacks. Could be set (update) per session using "session_set()"
|
||||
|
||||
static tmedia_profile_t __profile = tmedia_profile_rtcweb;
|
||||
static tmedia_profile_t __profile = tmedia_profile_default;
|
||||
static tmedia_bandwidth_level_t __bl = tmedia_bl_unrestricted;
|
||||
static tmedia_pref_video_size_t __pref_video_size = tmedia_pref_video_size_cif; // 352 x 288: Android, iOS, WP7
|
||||
static int32_t __jb_margin_ms = -1; // disable
|
||||
|
@ -70,10 +70,10 @@ tmedia_bandwidth_level_t tmedia_defaults_get_bl(){
|
|||
return __bl;
|
||||
}
|
||||
|
||||
int tmedia_defaults_set_pref_video_size(tmedia_pref_video_size_t pref_video_size){
|
||||
__pref_video_size = pref_video_size;
|
||||
return 0;
|
||||
}
|
||||
int tmedia_defaults_set_pref_video_size(tmedia_pref_video_size_t pref_video_size){
|
||||
__pref_video_size = pref_video_size;
|
||||
return 0;
|
||||
}
|
||||
tmedia_pref_video_size_t tmedia_defaults_get_pref_video_size(){
|
||||
return __pref_video_size;
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -29,6 +29,10 @@
|
|||
#include "tsk_string.h"
|
||||
#include "tsk_debug.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
|
||||
static int _tnet_ice_candidate_tostring(
|
||||
uint8_t* foundation,
|
||||
uint32_t comp_id,
|
||||
|
@ -47,55 +51,55 @@ static const char* _tnet_ice_candidate_get_transport_str(tnet_socket_type_t tran
|
|||
static tnet_socket_type_t _tnet_ice_candidate_get_transport_type(tsk_bool_t ipv6, const char* transport_str);
|
||||
static const char* _tnet_ice_candidate_get_candtype_str(tnet_ice_cand_type_t candtype_e);
|
||||
static tnet_ice_cand_type_t _tnet_ice_candtype_get_transport_type(const char* candtype_str);
|
||||
|
||||
static tsk_object_t* tnet_ice_candidate_ctor(tsk_object_t * self, va_list * app)
|
||||
{
|
||||
tnet_ice_candidate_t *candidate = self;
|
||||
if(candidate){
|
||||
candidate->extension_att_list = tsk_list_create();
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
static tsk_object_t* tnet_ice_candidate_dtor(tsk_object_t * self)
|
||||
{
|
||||
tnet_ice_candidate_t *candidate = self;
|
||||
if(candidate){
|
||||
TSK_SAFE_FREE(candidate->transport_str);
|
||||
TSK_SAFE_FREE(candidate->cand_type_str);
|
||||
TSK_OBJECT_SAFE_FREE(candidate->extension_att_list);
|
||||
TSK_OBJECT_SAFE_FREE(candidate->socket);
|
||||
|
||||
TSK_SAFE_FREE(candidate->stun.nonce);
|
||||
TSK_SAFE_FREE(candidate->stun.realm);
|
||||
TSK_SAFE_FREE(candidate->stun.srflx_addr);
|
||||
|
||||
|
||||
static tsk_object_t* tnet_ice_candidate_ctor(tsk_object_t * self, va_list * app)
|
||||
{
|
||||
tnet_ice_candidate_t *candidate = self;
|
||||
if(candidate){
|
||||
candidate->extension_att_list = tsk_list_create();
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
static tsk_object_t* tnet_ice_candidate_dtor(tsk_object_t * self)
|
||||
{
|
||||
tnet_ice_candidate_t *candidate = self;
|
||||
if(candidate){
|
||||
TSK_SAFE_FREE(candidate->transport_str);
|
||||
TSK_SAFE_FREE(candidate->cand_type_str);
|
||||
TSK_OBJECT_SAFE_FREE(candidate->extension_att_list);
|
||||
TSK_OBJECT_SAFE_FREE(candidate->socket);
|
||||
|
||||
TSK_SAFE_FREE(candidate->stun.nonce);
|
||||
TSK_SAFE_FREE(candidate->stun.realm);
|
||||
TSK_SAFE_FREE(candidate->stun.srflx_addr);
|
||||
|
||||
TSK_SAFE_FREE(candidate->ufrag);
|
||||
TSK_SAFE_FREE(candidate->pwd);
|
||||
|
||||
TSK_SAFE_FREE(candidate->tostring);
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
static int tnet_ice_candidate_cmp(const tsk_object_t *_s1, const tsk_object_t *_s2)
|
||||
{
|
||||
const tnet_ice_candidate_t *c1 = _s1;
|
||||
const tnet_ice_candidate_t *c2 = _s2;
|
||||
|
||||
if(c1 && c2){
|
||||
return (c2 - c1);
|
||||
}
|
||||
else if(!c1 && !c2) return 0;
|
||||
else return -1;
|
||||
}
|
||||
|
||||
static const tsk_object_def_t tnet_ice_candidate_def_s =
|
||||
{
|
||||
sizeof(tnet_ice_candidate_t),
|
||||
tnet_ice_candidate_ctor,
|
||||
tnet_ice_candidate_dtor,
|
||||
tnet_ice_candidate_cmp,
|
||||
TSK_SAFE_FREE(candidate->pwd);
|
||||
|
||||
TSK_SAFE_FREE(candidate->tostring);
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
static int tnet_ice_candidate_cmp(const tsk_object_t *_s1, const tsk_object_t *_s2)
|
||||
{
|
||||
const tnet_ice_candidate_t *c1 = _s1;
|
||||
const tnet_ice_candidate_t *c2 = _s2;
|
||||
|
||||
if(c1 && c2){
|
||||
return (c2 - c1);
|
||||
}
|
||||
else if(!c1 && !c2) return 0;
|
||||
else return -1;
|
||||
}
|
||||
|
||||
static const tsk_object_def_t tnet_ice_candidate_def_s =
|
||||
{
|
||||
sizeof(tnet_ice_candidate_t),
|
||||
tnet_ice_candidate_ctor,
|
||||
tnet_ice_candidate_dtor,
|
||||
tnet_ice_candidate_cmp,
|
||||
};
|
||||
|
||||
tnet_ice_candidate_t* tnet_ice_candidate_create(tnet_ice_cand_type_t type_e, tnet_socket_t* socket, tsk_bool_t is_ice_jingle, tsk_bool_t is_rtp, tsk_bool_t is_video, const char* ufrag, const char* pwd)
|
||||
|
@ -264,7 +268,7 @@ int tnet_ice_candidate_set_local_pref(tnet_ice_candidate_t* self, uint16_t local
|
|||
|
||||
const char* tnet_ice_candidate_tostring(tnet_ice_candidate_t* self)
|
||||
{
|
||||
char* _transport_str;
|
||||
const char* _transport_str;
|
||||
char __str[16]; // always allocated: bad idea :(
|
||||
|
||||
if(!self){
|
||||
|
|
|
@ -44,6 +44,9 @@
|
|||
#include "tsk_fsm.h"
|
||||
#include "tsk_debug.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#ifndef LONG_MAX
|
||||
# define LONG_MAX 2147483647L
|
||||
#endif
|
||||
|
@ -168,26 +171,26 @@ typedef enum _fsm_action_e
|
|||
}
|
||||
_fsm_action_t;
|
||||
|
||||
static tsk_object_t* tnet_ice_action_ctor(tsk_object_t * self, va_list * app)
|
||||
{
|
||||
tnet_ice_action_t *action = self;
|
||||
if(action){
|
||||
}
|
||||
return self;
|
||||
}
|
||||
static tsk_object_t* tnet_ice_action_dtor(tsk_object_t * self)
|
||||
{
|
||||
tnet_ice_action_t *action = self;
|
||||
if(action){
|
||||
}
|
||||
return self;
|
||||
}
|
||||
static const tsk_object_def_t tnet_ice_action_def_s =
|
||||
{
|
||||
sizeof(tnet_ice_action_t),
|
||||
tnet_ice_action_ctor,
|
||||
tnet_ice_action_dtor,
|
||||
tsk_null,
|
||||
static tsk_object_t* tnet_ice_action_ctor(tsk_object_t * self, va_list * app)
|
||||
{
|
||||
tnet_ice_action_t *action = self;
|
||||
if(action){
|
||||
}
|
||||
return self;
|
||||
}
|
||||
static tsk_object_t* tnet_ice_action_dtor(tsk_object_t * self)
|
||||
{
|
||||
tnet_ice_action_t *action = self;
|
||||
if(action){
|
||||
}
|
||||
return self;
|
||||
}
|
||||
static const tsk_object_def_t tnet_ice_action_def_s =
|
||||
{
|
||||
sizeof(tnet_ice_action_t),
|
||||
tnet_ice_action_ctor,
|
||||
tnet_ice_action_dtor,
|
||||
tsk_null,
|
||||
};
|
||||
static tnet_ice_action_t* tnet_ice_action_create(tsk_fsm_action_id id)
|
||||
{
|
||||
|
@ -201,36 +204,36 @@ static tnet_ice_action_t* tnet_ice_action_create(tsk_fsm_action_id id)
|
|||
|
||||
|
||||
|
||||
static tsk_object_t* tnet_ice_ctx_ctor(tsk_object_t * self, va_list * app)
|
||||
{
|
||||
tnet_ice_ctx_t *ctx = self;
|
||||
if(ctx){
|
||||
if(!(ctx->h_timer_mgr = tsk_timer_manager_create())){
|
||||
TSK_DEBUG_ERROR("Failed to create timer manager");
|
||||
return tsk_null;
|
||||
}
|
||||
if(!(ctx->fsm = tsk_fsm_create(_fsm_state_Started, _fsm_state_Terminated))){
|
||||
TSK_DEBUG_ERROR("Failed to create state machine");
|
||||
return tsk_null;
|
||||
}
|
||||
if(!(ctx->candidates_local = tsk_list_create())){
|
||||
TSK_DEBUG_ERROR("Failed to create candidates list");
|
||||
return tsk_null;
|
||||
}
|
||||
if(!(ctx->candidates_remote = tsk_list_create())){
|
||||
TSK_DEBUG_ERROR("Failed to create candidates list");
|
||||
return tsk_null;
|
||||
}
|
||||
if(!(ctx->candidates_pairs = tsk_list_create())){
|
||||
TSK_DEBUG_ERROR("Failed to create candidates list");
|
||||
return tsk_null;
|
||||
}
|
||||
|
||||
static tsk_object_t* tnet_ice_ctx_ctor(tsk_object_t * self, va_list * app)
|
||||
{
|
||||
tnet_ice_ctx_t *ctx = self;
|
||||
if(ctx){
|
||||
if(!(ctx->h_timer_mgr = tsk_timer_manager_create())){
|
||||
TSK_DEBUG_ERROR("Failed to create timer manager");
|
||||
return tsk_null;
|
||||
}
|
||||
if(!(ctx->fsm = tsk_fsm_create(_fsm_state_Started, _fsm_state_Terminated))){
|
||||
TSK_DEBUG_ERROR("Failed to create state machine");
|
||||
return tsk_null;
|
||||
}
|
||||
if(!(ctx->candidates_local = tsk_list_create())){
|
||||
TSK_DEBUG_ERROR("Failed to create candidates list");
|
||||
return tsk_null;
|
||||
}
|
||||
if(!(ctx->candidates_remote = tsk_list_create())){
|
||||
TSK_DEBUG_ERROR("Failed to create candidates list");
|
||||
return tsk_null;
|
||||
}
|
||||
if(!(ctx->candidates_pairs = tsk_list_create())){
|
||||
TSK_DEBUG_ERROR("Failed to create candidates list");
|
||||
return tsk_null;
|
||||
}
|
||||
|
||||
TSK_SAFE_FREE(ctx->ufrag);
|
||||
TSK_SAFE_FREE(ctx->pwd);
|
||||
|
||||
tsk_runnable_set_important(TSK_RUNNABLE(self), tsk_true);
|
||||
|
||||
TSK_SAFE_FREE(ctx->pwd);
|
||||
|
||||
tsk_runnable_set_important(TSK_RUNNABLE(self), tsk_true);
|
||||
|
||||
/* 7.2.1. Sending over UDP
|
||||
In fixed-line access links, a value of 500 ms is RECOMMENDED.
|
||||
*/
|
||||
|
@ -239,133 +242,133 @@ static tsk_object_t* tnet_ice_ctx_ctor(tsk_object_t * self, va_list * app)
|
|||
/* 7.2.1. Sending over UDP
|
||||
Rc SHOULD be configurable and SHOULD have a default of 7.
|
||||
*/
|
||||
ctx->Rc = TNET_ICE_DEFAULT_RC;
|
||||
|
||||
ctx->tie_breaker = ((tsk_time_now() << 32) ^ tsk_time_now());
|
||||
ctx->is_ice_jingle = tsk_false;
|
||||
|
||||
ctx->concheck_timeout = LONG_MAX;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
static tsk_object_t* tnet_ice_ctx_dtor(tsk_object_t * self)
|
||||
{
|
||||
tnet_ice_ctx_t *ctx = self;
|
||||
if(ctx){
|
||||
tnet_ice_ctx_stop(ctx);
|
||||
if(ctx->h_timer_mgr){
|
||||
tsk_timer_manager_destroy(&ctx->h_timer_mgr);
|
||||
}
|
||||
|
||||
TSK_SAFE_FREE(ctx->stun.username);
|
||||
TSK_SAFE_FREE(ctx->stun.password);
|
||||
TSK_SAFE_FREE(ctx->stun.software);
|
||||
TSK_SAFE_FREE(ctx->stun.server_addr);
|
||||
|
||||
TSK_OBJECT_SAFE_FREE(ctx->fsm);
|
||||
TSK_OBJECT_SAFE_FREE(ctx->candidates_local);
|
||||
TSK_OBJECT_SAFE_FREE(ctx->candidates_remote);
|
||||
TSK_OBJECT_SAFE_FREE(ctx->candidates_pairs);
|
||||
}
|
||||
return self;
|
||||
}
|
||||
static const tsk_object_def_t tnet_ice_ctx_def_s =
|
||||
{
|
||||
sizeof(tnet_ice_ctx_t),
|
||||
tnet_ice_ctx_ctor,
|
||||
tnet_ice_ctx_dtor,
|
||||
tsk_null,
|
||||
};
|
||||
|
||||
|
||||
tnet_ice_ctx_t* tnet_ice_ctx_create(tsk_bool_t is_ice_jingle, tsk_bool_t use_ipv6, tsk_bool_t use_rtcp, tsk_bool_t is_video, tnet_ice_callback_f callback, const void* userdata)
|
||||
{
|
||||
tnet_ice_ctx_t* ctx;
|
||||
|
||||
if(!(ctx = tsk_object_new(&tnet_ice_ctx_def_s))){
|
||||
TSK_DEBUG_ERROR("Failed to create ICE context object");
|
||||
return tsk_null;
|
||||
}
|
||||
|
||||
ctx->is_ice_jingle = is_ice_jingle;
|
||||
ctx->use_ipv6 = use_ipv6;
|
||||
ctx->use_rtcp = use_rtcp;
|
||||
ctx->is_video = is_video;
|
||||
ctx->callback = callback;
|
||||
ctx->userdata = userdata;
|
||||
ctx->Rc = TNET_ICE_DEFAULT_RC;
|
||||
|
||||
ctx->tie_breaker = ((tsk_time_now() << 32) ^ tsk_time_now());
|
||||
ctx->is_ice_jingle = tsk_false;
|
||||
|
||||
ctx->concheck_timeout = LONG_MAX;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
static tsk_object_t* tnet_ice_ctx_dtor(tsk_object_t * self)
|
||||
{
|
||||
tnet_ice_ctx_t *ctx = self;
|
||||
if(ctx){
|
||||
tnet_ice_ctx_stop(ctx);
|
||||
if(ctx->h_timer_mgr){
|
||||
tsk_timer_manager_destroy(&ctx->h_timer_mgr);
|
||||
}
|
||||
|
||||
TSK_SAFE_FREE(ctx->stun.username);
|
||||
TSK_SAFE_FREE(ctx->stun.password);
|
||||
TSK_SAFE_FREE(ctx->stun.software);
|
||||
TSK_SAFE_FREE(ctx->stun.server_addr);
|
||||
|
||||
TSK_OBJECT_SAFE_FREE(ctx->fsm);
|
||||
TSK_OBJECT_SAFE_FREE(ctx->candidates_local);
|
||||
TSK_OBJECT_SAFE_FREE(ctx->candidates_remote);
|
||||
TSK_OBJECT_SAFE_FREE(ctx->candidates_pairs);
|
||||
}
|
||||
return self;
|
||||
}
|
||||
static const tsk_object_def_t tnet_ice_ctx_def_s =
|
||||
{
|
||||
sizeof(tnet_ice_ctx_t),
|
||||
tnet_ice_ctx_ctor,
|
||||
tnet_ice_ctx_dtor,
|
||||
tsk_null,
|
||||
};
|
||||
|
||||
|
||||
tnet_ice_ctx_t* tnet_ice_ctx_create(tsk_bool_t is_ice_jingle, tsk_bool_t use_ipv6, tsk_bool_t use_rtcp, tsk_bool_t is_video, tnet_ice_callback_f callback, const void* userdata)
|
||||
{
|
||||
tnet_ice_ctx_t* ctx;
|
||||
|
||||
if(!(ctx = tsk_object_new(&tnet_ice_ctx_def_s))){
|
||||
TSK_DEBUG_ERROR("Failed to create ICE context object");
|
||||
return tsk_null;
|
||||
}
|
||||
|
||||
ctx->is_ice_jingle = is_ice_jingle;
|
||||
ctx->use_ipv6 = use_ipv6;
|
||||
ctx->use_rtcp = use_rtcp;
|
||||
ctx->is_video = is_video;
|
||||
ctx->callback = callback;
|
||||
ctx->userdata = userdata;
|
||||
ctx->unicast = tsk_true;
|
||||
ctx->anycast = tsk_false;
|
||||
ctx->multicast = tsk_false;
|
||||
|
||||
tnet_ice_utils_set_ufrag(&ctx->ufrag);
|
||||
tnet_ice_utils_set_pwd(&ctx->pwd);
|
||||
|
||||
tsk_fsm_set_callback_terminated(ctx->fsm, TSK_FSM_ONTERMINATED_F(_tnet_ice_ctx_fsm_OnTerminated), (const void*)ctx);
|
||||
tsk_fsm_set(ctx->fsm,
|
||||
// (Started) -> (GatherHostCandidates) -> (GatheringHostCandidates)
|
||||
TSK_FSM_ADD_ALWAYS(_fsm_state_Started, _fsm_action_GatherHostCandidates, _fsm_state_GatheringHostCandidates, _tnet_ice_ctx_fsm_Started_2_GatheringHostCandidates_X_GatherHostCandidates, "ICE_Started_2_GatheringHostCandidates_X_GatherHostCandidates"),
|
||||
// (GatheringHostCandidates) -> (Success) -> (GatheringHostCandidatesDone)
|
||||
TSK_FSM_ADD_ALWAYS(_fsm_state_GatheringHostCandidates, _fsm_action_Success, _fsm_state_GatheringHostCandidatesDone, _tnet_ice_ctx_fsm_GatheringHostCandidates_2_GatheringHostCandidatesDone_X_Success, "ICE_GatheringHostCandidates_2_GatheringHostCandidatesDone_X_Success"),
|
||||
// (GatheringHostCandidates) -> (Failure) -> (Terminated)
|
||||
TSK_FSM_ADD_ALWAYS(_fsm_state_GatheringHostCandidates, _fsm_action_Failure, _fsm_state_Terminated, _tnet_ice_ctx_fsm_GatheringHostCandidates_2_Terminated_X_Failure, "ICE_GatheringHostCandidates_2_Terminated_X_Failure"),
|
||||
|
||||
// (GatheringHostCandidatesDone) -> (GatherReflexiveCandidates) -> (GatheringReflexiveCandidates)
|
||||
TSK_FSM_ADD_ALWAYS(_fsm_state_GatheringHostCandidatesDone, _fsm_action_GatherReflexiveCandidates, _fsm_state_GatheringReflexiveCandidates, _tnet_ice_ctx_fsm_GatheringHostCandidatesDone_2_GatheringReflexiveCandidates_X_GatherReflexiveCandidates, "ICE_GatheringHostCandidatesDone_2_GatheringReflexiveCandidates_X_GatherReflexiveCandidates"),
|
||||
// (GatheringReflexiveCandidates) -> (Success) -> GatheringReflexiveCandidatesDone
|
||||
TSK_FSM_ADD_ALWAYS(_fsm_state_GatheringReflexiveCandidates, _fsm_action_Success, _fsm_state_GatheringReflexiveCandidatesDone, _tnet_ice_ctx_fsm_GatheringReflexiveCandidates_2_GatheringReflexiveCandidatesDone_X_Success, "ICE_fsm_GatheringReflexiveCandidates_2_GatheringReflexiveCandidatesDone_X_Success"),
|
||||
// (GatheringReflexiveCandidates) -> (Failure) -> Terminated
|
||||
TSK_FSM_ADD_ALWAYS(_fsm_state_GatheringReflexiveCandidates, _fsm_action_Failure, _fsm_state_Terminated, _tnet_ice_ctx_fsm_GatheringReflexiveCandidates_2_Terminated_X_Failure, "ICE_GatheringReflexiveCandidates_2_Terminated_X_Failure"),
|
||||
|
||||
// (GatheringComplet) -> (ConnCheck) -> ConnChecking
|
||||
TSK_FSM_ADD_ALWAYS(_fsm_state_GatheringCompleted, _fsm_action_ConnCheck, _fsm_state_ConnChecking, _tnet_ice_ctx_fsm_GatheringComplet_2_ConnChecking_X_ConnCheck, "ICE_GatheringComplet_2_ConnChecking_X_ConnCheck"),
|
||||
// (ConnChecking) -> (Success) -> ConnCheckingCompleted
|
||||
TSK_FSM_ADD_ALWAYS(_fsm_state_ConnChecking, _fsm_action_Success, _fsm_state_ConnCheckingCompleted, _tnet_ice_ctx_fsm_ConnChecking_2_ConnCheckingCompleted_X_Success, "ICE_ConnChecking_2_ConnCheckingCompleted_X_Success"),
|
||||
// (ConnChecking) -> (Failure) -> Terminated
|
||||
TSK_FSM_ADD_ALWAYS(_fsm_state_ConnChecking, _fsm_action_Failure, _fsm_state_Terminated, _tnet_ice_ctx_fsm_ConnChecking_2_Terminated_X_Failure, "ICE_ConnChecking_2_Terminated_X_Failure"),
|
||||
|
||||
// (Any) -> (GatheringComplet) -> GatheringCompleted
|
||||
TSK_FSM_ADD_ALWAYS(tsk_fsm_state_any, _fsm_action_GatheringComplet, _fsm_state_GatheringCompleted, _tnet_ice_ctx_fsm_Any_2_GatheringCompleted_X_GatheringComplet, "ICE_Any_2_GatheringCompleted_X_GatheringComplet"),
|
||||
// (Any) -> (Cancel) -> Started
|
||||
TSK_FSM_ADD_ALWAYS(tsk_fsm_state_any, _fsm_action_Cancel, _fsm_state_Started, _tnet_ice_ctx_fsm_Any_2_Started_X_Cancel, "ICE_Any_2_Started_X_Cancel"),
|
||||
// (Any) -> (AnyNotStarted) -> Terminated
|
||||
TSK_FSM_ADD(tsk_fsm_state_any, tsk_fsm_action_any, _tnet_ice_ctx_fsm_cond_NotStarted, _fsm_state_Terminated, _tnet_ice_ctx_fsm_Any_2_Terminated_X_AnyNotStarted, "ICE_fsm_Any_2_Terminated_X_AnyNotStarted")
|
||||
);
|
||||
|
||||
return ctx;
|
||||
}
|
||||
|
||||
int tnet_ice_ctx_set_userdata(tnet_ice_ctx_t* self, const void* userdata)
|
||||
{
|
||||
if(!self){
|
||||
TSK_DEBUG_ERROR("Invalid parameter");
|
||||
return -1;
|
||||
}
|
||||
self->userdata = userdata;
|
||||
return 0;
|
||||
}
|
||||
|
||||
ctx->multicast = tsk_false;
|
||||
|
||||
tnet_ice_utils_set_ufrag(&ctx->ufrag);
|
||||
tnet_ice_utils_set_pwd(&ctx->pwd);
|
||||
|
||||
tsk_fsm_set_callback_terminated(ctx->fsm, TSK_FSM_ONTERMINATED_F(_tnet_ice_ctx_fsm_OnTerminated), (const void*)ctx);
|
||||
tsk_fsm_set(ctx->fsm,
|
||||
// (Started) -> (GatherHostCandidates) -> (GatheringHostCandidates)
|
||||
TSK_FSM_ADD_ALWAYS(_fsm_state_Started, _fsm_action_GatherHostCandidates, _fsm_state_GatheringHostCandidates, _tnet_ice_ctx_fsm_Started_2_GatheringHostCandidates_X_GatherHostCandidates, "ICE_Started_2_GatheringHostCandidates_X_GatherHostCandidates"),
|
||||
// (GatheringHostCandidates) -> (Success) -> (GatheringHostCandidatesDone)
|
||||
TSK_FSM_ADD_ALWAYS(_fsm_state_GatheringHostCandidates, _fsm_action_Success, _fsm_state_GatheringHostCandidatesDone, _tnet_ice_ctx_fsm_GatheringHostCandidates_2_GatheringHostCandidatesDone_X_Success, "ICE_GatheringHostCandidates_2_GatheringHostCandidatesDone_X_Success"),
|
||||
// (GatheringHostCandidates) -> (Failure) -> (Terminated)
|
||||
TSK_FSM_ADD_ALWAYS(_fsm_state_GatheringHostCandidates, _fsm_action_Failure, _fsm_state_Terminated, _tnet_ice_ctx_fsm_GatheringHostCandidates_2_Terminated_X_Failure, "ICE_GatheringHostCandidates_2_Terminated_X_Failure"),
|
||||
|
||||
// (GatheringHostCandidatesDone) -> (GatherReflexiveCandidates) -> (GatheringReflexiveCandidates)
|
||||
TSK_FSM_ADD_ALWAYS(_fsm_state_GatheringHostCandidatesDone, _fsm_action_GatherReflexiveCandidates, _fsm_state_GatheringReflexiveCandidates, _tnet_ice_ctx_fsm_GatheringHostCandidatesDone_2_GatheringReflexiveCandidates_X_GatherReflexiveCandidates, "ICE_GatheringHostCandidatesDone_2_GatheringReflexiveCandidates_X_GatherReflexiveCandidates"),
|
||||
// (GatheringReflexiveCandidates) -> (Success) -> GatheringReflexiveCandidatesDone
|
||||
TSK_FSM_ADD_ALWAYS(_fsm_state_GatheringReflexiveCandidates, _fsm_action_Success, _fsm_state_GatheringReflexiveCandidatesDone, _tnet_ice_ctx_fsm_GatheringReflexiveCandidates_2_GatheringReflexiveCandidatesDone_X_Success, "ICE_fsm_GatheringReflexiveCandidates_2_GatheringReflexiveCandidatesDone_X_Success"),
|
||||
// (GatheringReflexiveCandidates) -> (Failure) -> Terminated
|
||||
TSK_FSM_ADD_ALWAYS(_fsm_state_GatheringReflexiveCandidates, _fsm_action_Failure, _fsm_state_Terminated, _tnet_ice_ctx_fsm_GatheringReflexiveCandidates_2_Terminated_X_Failure, "ICE_GatheringReflexiveCandidates_2_Terminated_X_Failure"),
|
||||
|
||||
// (GatheringComplet) -> (ConnCheck) -> ConnChecking
|
||||
TSK_FSM_ADD_ALWAYS(_fsm_state_GatheringCompleted, _fsm_action_ConnCheck, _fsm_state_ConnChecking, _tnet_ice_ctx_fsm_GatheringComplet_2_ConnChecking_X_ConnCheck, "ICE_GatheringComplet_2_ConnChecking_X_ConnCheck"),
|
||||
// (ConnChecking) -> (Success) -> ConnCheckingCompleted
|
||||
TSK_FSM_ADD_ALWAYS(_fsm_state_ConnChecking, _fsm_action_Success, _fsm_state_ConnCheckingCompleted, _tnet_ice_ctx_fsm_ConnChecking_2_ConnCheckingCompleted_X_Success, "ICE_ConnChecking_2_ConnCheckingCompleted_X_Success"),
|
||||
// (ConnChecking) -> (Failure) -> Terminated
|
||||
TSK_FSM_ADD_ALWAYS(_fsm_state_ConnChecking, _fsm_action_Failure, _fsm_state_Terminated, _tnet_ice_ctx_fsm_ConnChecking_2_Terminated_X_Failure, "ICE_ConnChecking_2_Terminated_X_Failure"),
|
||||
|
||||
// (Any) -> (GatheringComplet) -> GatheringCompleted
|
||||
TSK_FSM_ADD_ALWAYS(tsk_fsm_state_any, _fsm_action_GatheringComplet, _fsm_state_GatheringCompleted, _tnet_ice_ctx_fsm_Any_2_GatheringCompleted_X_GatheringComplet, "ICE_Any_2_GatheringCompleted_X_GatheringComplet"),
|
||||
// (Any) -> (Cancel) -> Started
|
||||
TSK_FSM_ADD_ALWAYS(tsk_fsm_state_any, _fsm_action_Cancel, _fsm_state_Started, _tnet_ice_ctx_fsm_Any_2_Started_X_Cancel, "ICE_Any_2_Started_X_Cancel"),
|
||||
// (Any) -> (AnyNotStarted) -> Terminated
|
||||
TSK_FSM_ADD(tsk_fsm_state_any, tsk_fsm_action_any, _tnet_ice_ctx_fsm_cond_NotStarted, _fsm_state_Terminated, _tnet_ice_ctx_fsm_Any_2_Terminated_X_AnyNotStarted, "ICE_fsm_Any_2_Terminated_X_AnyNotStarted")
|
||||
);
|
||||
|
||||
return ctx;
|
||||
}
|
||||
|
||||
int tnet_ice_ctx_set_userdata(tnet_ice_ctx_t* self, const void* userdata)
|
||||
{
|
||||
if(!self){
|
||||
TSK_DEBUG_ERROR("Invalid parameter");
|
||||
return -1;
|
||||
}
|
||||
self->userdata = userdata;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int tnet_ice_ctx_set_stun(
|
||||
tnet_ice_ctx_t* self,
|
||||
const char* server_addr,
|
||||
uint16_t server_port,
|
||||
const char* software,
|
||||
const char* username,
|
||||
const char* password)
|
||||
{
|
||||
if(!self){
|
||||
TSK_DEBUG_ERROR("Invalid parameter");
|
||||
return -1;
|
||||
}
|
||||
|
||||
tsk_strupdate(&self->stun.server_addr, server_addr);
|
||||
self->stun.server_port = server_port;
|
||||
tsk_strupdate(&self->stun.software, software);
|
||||
tsk_strupdate(&self->stun.username, username);
|
||||
tsk_strupdate(&self->stun.password, password);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
const char* password)
|
||||
{
|
||||
if(!self){
|
||||
TSK_DEBUG_ERROR("Invalid parameter");
|
||||
return -1;
|
||||
}
|
||||
|
||||
tsk_strupdate(&self->stun.server_addr, server_addr);
|
||||
self->stun.server_port = server_port;
|
||||
tsk_strupdate(&self->stun.software, software);
|
||||
tsk_strupdate(&self->stun.username, username);
|
||||
tsk_strupdate(&self->stun.password, password);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int tnet_ice_ctx_start(tnet_ice_ctx_t* self)
|
||||
{
|
||||
int ret;
|
||||
|
@ -387,26 +390,26 @@ int tnet_ice_ctx_start(tnet_ice_ctx_t* self)
|
|||
return 0;
|
||||
}
|
||||
|
||||
/* === Timer manager === */
|
||||
if((ret = tsk_timer_manager_start(self->h_timer_mgr))){
|
||||
err = "Failed to start timer manager";
|
||||
TSK_DEBUG_ERROR("%s", err);
|
||||
goto bail;
|
||||
/* === Timer manager === */
|
||||
if((ret = tsk_timer_manager_start(self->h_timer_mgr))){
|
||||
err = "Failed to start timer manager";
|
||||
TSK_DEBUG_ERROR("%s", err);
|
||||
goto bail;
|
||||
}
|
||||
timer_mgr_started = tsk_true;
|
||||
|
||||
/* === Runnable === */
|
||||
TSK_RUNNABLE(self)->run = _tnet_ice_ctx_run;
|
||||
if((ret = tsk_runnable_start(TSK_RUNNABLE(self), tnet_ice_event_def_t))){
|
||||
err = "Failed to start runnable";
|
||||
TSK_DEBUG_ERROR("%s", err);
|
||||
goto bail;
|
||||
/* === Runnable === */
|
||||
TSK_RUNNABLE(self)->run = _tnet_ice_ctx_run;
|
||||
if((ret = tsk_runnable_start(TSK_RUNNABLE(self), tnet_ice_event_def_t))){
|
||||
err = "Failed to start runnable";
|
||||
TSK_DEBUG_ERROR("%s", err);
|
||||
goto bail;
|
||||
}
|
||||
runnable_started = tsk_true;
|
||||
|
||||
if((ret = _tnet_ice_ctx_fsm_act_async(self, _fsm_action_GatherHostCandidates))){
|
||||
err = "FSM execution failed";
|
||||
TSK_DEBUG_ERROR("%s", err);
|
||||
err = "FSM execution failed";
|
||||
TSK_DEBUG_ERROR("%s", err);
|
||||
goto bail;
|
||||
}
|
||||
|
||||
|
@ -690,10 +693,10 @@ int tnet_ice_ctx_cancel(tnet_ice_ctx_t* self)
|
|||
return _tnet_ice_ctx_fsm_act_async(self, _fsm_action_Cancel);
|
||||
}
|
||||
|
||||
int tnet_ice_ctx_stop(tnet_ice_ctx_t* self)
|
||||
{
|
||||
int ret;
|
||||
|
||||
int tnet_ice_ctx_stop(tnet_ice_ctx_t* self)
|
||||
{
|
||||
int ret;
|
||||
|
||||
if(!self){
|
||||
TSK_DEBUG_ERROR("Invalid parameter");
|
||||
return -1;
|
||||
|
@ -708,9 +711,9 @@ int tnet_ice_ctx_stop(tnet_ice_ctx_t* self)
|
|||
ret = tsk_timer_manager_stop(self->h_timer_mgr);
|
||||
ret = tsk_runnable_stop(TSK_RUNNABLE(self));
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------
|
||||
// == STATE MACHINE BEGIN ==
|
||||
//--------------------------------------------------------
|
||||
|
@ -1310,23 +1313,23 @@ static tsk_bool_t _tnet_ice_ctx_fsm_cond_NotStarted(tnet_ice_ctx_t* self, const
|
|||
return (!self || !self->is_started);
|
||||
}
|
||||
|
||||
static int _tnet_ice_ctx_restart(tnet_ice_ctx_t* self)
|
||||
{
|
||||
int ret = 0;
|
||||
if(!self){
|
||||
static int _tnet_ice_ctx_restart(tnet_ice_ctx_t* self)
|
||||
{
|
||||
int ret = 0;
|
||||
if(!self){
|
||||
TSK_DEBUG_ERROR("Invalid parameter");
|
||||
return -1;
|
||||
}
|
||||
|
||||
tsk_list_lock(self->candidates_local);
|
||||
tsk_list_clear_items(self->candidates_local);
|
||||
tsk_list_unlock(self->candidates_local);
|
||||
|
||||
ret = tsk_fsm_set_current_state(self->fsm, _fsm_state_Started);
|
||||
ret = _tnet_ice_ctx_fsm_act_async(self, _fsm_action_GatherHostCandidates);
|
||||
|
||||
self->is_active = (ret == 0);
|
||||
return ret;
|
||||
return -1;
|
||||
}
|
||||
|
||||
tsk_list_lock(self->candidates_local);
|
||||
tsk_list_clear_items(self->candidates_local);
|
||||
tsk_list_unlock(self->candidates_local);
|
||||
|
||||
ret = tsk_fsm_set_current_state(self->fsm, _fsm_state_Started);
|
||||
ret = _tnet_ice_ctx_fsm_act_async(self, _fsm_action_GatherHostCandidates);
|
||||
|
||||
self->is_active = (ret == 0);
|
||||
return ret;
|
||||
}
|
||||
|
||||
// build pairs as per RFC 5245 section "5.7.1. Forming Candidate Pairs"
|
||||
|
@ -1423,44 +1426,44 @@ static int _tnet_ice_ctx_signal_async(tnet_ice_ctx_t* self, tnet_ice_event_type_
|
|||
}
|
||||
}
|
||||
|
||||
static void *_tnet_ice_ctx_run(void* self)
|
||||
{
|
||||
tsk_list_item_t *curr;
|
||||
tnet_ice_ctx_t *ctx = self;
|
||||
tnet_ice_event_t *e;
|
||||
|
||||
TSK_DEBUG_INFO("ICE CTX::run -- START");
|
||||
|
||||
TSK_RUNNABLE_RUN_BEGIN(ctx);
|
||||
|
||||
if((curr = TSK_RUNNABLE_POP_FIRST(ctx))){
|
||||
e = (tnet_ice_event_t*)curr->data;
|
||||
switch(e->type){
|
||||
case tnet_ice_event_type_action:
|
||||
{
|
||||
if(e->action){
|
||||
tsk_fsm_act(ctx->fsm, e->action->id, ctx, e->action, ctx, e->action);
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
if(ctx->callback){
|
||||
ctx->callback(e);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
tsk_object_unref(curr);
|
||||
}
|
||||
|
||||
TSK_RUNNABLE_RUN_END(ctx);
|
||||
|
||||
TSK_DEBUG_INFO("ICE CTX::run -- STOP");
|
||||
|
||||
static void *_tnet_ice_ctx_run(void* self)
|
||||
{
|
||||
tsk_list_item_t *curr;
|
||||
tnet_ice_ctx_t *ctx = self;
|
||||
tnet_ice_event_t *e;
|
||||
|
||||
TSK_DEBUG_INFO("ICE CTX::run -- START");
|
||||
|
||||
TSK_RUNNABLE_RUN_BEGIN(ctx);
|
||||
|
||||
if((curr = TSK_RUNNABLE_POP_FIRST(ctx))){
|
||||
e = (tnet_ice_event_t*)curr->data;
|
||||
switch(e->type){
|
||||
case tnet_ice_event_type_action:
|
||||
{
|
||||
if(e->action){
|
||||
tsk_fsm_act(ctx->fsm, e->action->id, ctx, e->action, ctx, e->action);
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
if(ctx->callback){
|
||||
ctx->callback(e);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
tsk_object_unref(curr);
|
||||
}
|
||||
|
||||
TSK_RUNNABLE_RUN_END(ctx);
|
||||
|
||||
TSK_DEBUG_INFO("ICE CTX::run -- STOP");
|
||||
|
||||
tsk_list_clear_items(ctx->candidates_local);
|
||||
tsk_list_clear_items(ctx->candidates_remote);
|
||||
tsk_list_clear_items(ctx->candidates_pairs);
|
||||
|
||||
return 0;
|
||||
}
|
||||
tsk_list_clear_items(ctx->candidates_pairs);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -13,52 +13,55 @@
|
|||
#include "tsk_string.h"
|
||||
#include "tsk_debug.h"
|
||||
|
||||
static int __pred_find_by_pair(const tsk_list_item_t *item, const void *pair)
|
||||
{
|
||||
if(item && item->data){
|
||||
const tnet_ice_pair_t *_pair = item->data;
|
||||
return (_pair - ((const tnet_ice_pair_t *)pair));
|
||||
}
|
||||
return -1;
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
static int __pred_find_by_pair(const tsk_list_item_t *item, const void *pair)
|
||||
{
|
||||
if(item && item->data){
|
||||
const tnet_ice_pair_t *_pair = item->data;
|
||||
return (_pair - ((const tnet_ice_pair_t *)pair));
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
static tsk_object_t* tnet_ice_pair_ctor(tsk_object_t * self, va_list * app)
|
||||
{
|
||||
tnet_ice_pair_t *pair = self;
|
||||
if(pair){
|
||||
pair->state_offer = tnet_ice_pair_state_frozen;
|
||||
pair->state_answer = tnet_ice_pair_state_frozen;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
static tsk_object_t* tnet_ice_pair_dtor(tsk_object_t * self)
|
||||
{
|
||||
tnet_ice_pair_t *pair = self;
|
||||
if(pair){
|
||||
TSK_OBJECT_SAFE_FREE(pair->candidate_offer);
|
||||
TSK_OBJECT_SAFE_FREE(pair->candidate_answer);
|
||||
TSK_OBJECT_SAFE_FREE(pair->last_request);
|
||||
}
|
||||
return self;
|
||||
}
|
||||
static int tnet_ice_pair_cmp(const tsk_object_t *_p1, const tsk_object_t *_p2)
|
||||
{
|
||||
const tnet_ice_pair_t *p1 = _p1;
|
||||
const tnet_ice_pair_t *p2 = _p2;
|
||||
|
||||
if(p1 && p2){
|
||||
return (int)(p1->priority - p2->priority);
|
||||
}
|
||||
else if(!p1 && !p2) return 0;
|
||||
else return -1;
|
||||
}
|
||||
static const tsk_object_def_t tnet_ice_pair_def_s =
|
||||
{
|
||||
sizeof(tnet_ice_pair_t),
|
||||
tnet_ice_pair_ctor,
|
||||
tnet_ice_pair_dtor,
|
||||
tnet_ice_pair_cmp,
|
||||
static tsk_object_t* tnet_ice_pair_ctor(tsk_object_t * self, va_list * app)
|
||||
{
|
||||
tnet_ice_pair_t *pair = self;
|
||||
if(pair){
|
||||
pair->state_offer = tnet_ice_pair_state_frozen;
|
||||
pair->state_answer = tnet_ice_pair_state_frozen;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
static tsk_object_t* tnet_ice_pair_dtor(tsk_object_t * self)
|
||||
{
|
||||
tnet_ice_pair_t *pair = self;
|
||||
if(pair){
|
||||
TSK_OBJECT_SAFE_FREE(pair->candidate_offer);
|
||||
TSK_OBJECT_SAFE_FREE(pair->candidate_answer);
|
||||
TSK_OBJECT_SAFE_FREE(pair->last_request);
|
||||
}
|
||||
return self;
|
||||
}
|
||||
static int tnet_ice_pair_cmp(const tsk_object_t *_p1, const tsk_object_t *_p2)
|
||||
{
|
||||
const tnet_ice_pair_t *p1 = _p1;
|
||||
const tnet_ice_pair_t *p2 = _p2;
|
||||
|
||||
if(p1 && p2){
|
||||
return (int)(p1->priority - p2->priority);
|
||||
}
|
||||
else if(!p1 && !p2) return 0;
|
||||
else return -1;
|
||||
}
|
||||
static const tsk_object_def_t tnet_ice_pair_def_s =
|
||||
{
|
||||
sizeof(tnet_ice_pair_t),
|
||||
tnet_ice_pair_ctor,
|
||||
tnet_ice_pair_dtor,
|
||||
tnet_ice_pair_cmp,
|
||||
};
|
||||
|
||||
tnet_ice_pair_t* tnet_ice_pair_create(const tnet_ice_candidate_t* candidate_offer, const tnet_ice_candidate_t* candidate_answer, tsk_bool_t is_controlling, uint64_t tie_breaker, tsk_bool_t is_ice_jingle)
|
||||
|
@ -219,11 +222,11 @@ int tnet_ice_pair_send_response(tnet_ice_pair_t *self, const tnet_stun_request_t
|
|||
message->fingerprint = !self->is_ice_jingle;
|
||||
|
||||
// ERROR
|
||||
if(is_error){
|
||||
tnet_stun_attribute_errorcode_t* stun_att_err;
|
||||
if(is_error){
|
||||
tnet_stun_attribute_errorcode_t* stun_att_err;
|
||||
if((stun_att_err = tnet_stun_attribute_errorcode_create(tsk_null, 0))){
|
||||
stun_att_err->_class = ((code / 100) & 0x07);
|
||||
stun_att_err->number = (code - ((code / 100) * 100));
|
||||
stun_att_err->_class = ((code / 100) & 0x07);
|
||||
stun_att_err->number = (code - ((code / 100) * 100));
|
||||
stun_att_err->reason_phrase = tsk_strdup(phrase);
|
||||
TNET_STUN_ATTRIBUTE(stun_att_err)->length = 4 + tsk_strlen(phrase);
|
||||
tnet_stun_message_add_attribute(message, (tnet_stun_attribute_t**)&stun_att_err);
|
||||
|
@ -242,16 +245,16 @@ int tnet_ice_pair_send_response(tnet_ice_pair_t *self, const tnet_stun_request_t
|
|||
}
|
||||
|
||||
// MAPPED-ADDRESS
|
||||
if((stun_att_ma = tnet_stun_attribute_mapped_address_create(tsk_null, 0))){
|
||||
if((stun_att_ma = tnet_stun_attribute_mapped_address_create(tsk_null, 0))){
|
||||
uint32_t addr;
|
||||
if(TNET_SOCKET_TYPE_IS_IPV6(self->candidate_offer->socket->type)){
|
||||
tsk_size_t i;
|
||||
const struct sockaddr_in6* sin6 = (const struct sockaddr_in6*)remote_addr;
|
||||
stun_att_ma->family = stun_ipv6;
|
||||
stun_att_ma->port = tnet_ntohs(sin6->sin6_port);
|
||||
for(i = 0; i < 16; i+=4){
|
||||
addr = tnet_ntohl_2(&sin6->sin6_addr.s6_addr[i]);
|
||||
memcpy(&stun_att_ma->address[i], &addr, 4);
|
||||
for(i = 0; i < 16; i+=4){
|
||||
addr = tnet_ntohl_2(&sin6->sin6_addr.s6_addr[i]);
|
||||
memcpy(&stun_att_ma->address[i], &addr, 4);
|
||||
}
|
||||
TNET_STUN_ATTRIBUTE(stun_att_ma)->length = 4 + 16;
|
||||
}
|
||||
|
@ -270,7 +273,7 @@ int tnet_ice_pair_send_response(tnet_ice_pair_t *self, const tnet_stun_request_t
|
|||
// XOR-MAPPED-ADDRESS
|
||||
if((stun_att_xma = tnet_stun_attribute_xmapped_address_create(tsk_null, 0))){//JINGLE_ICE
|
||||
tsk_size_t addr_size;
|
||||
tsk_size_t i;
|
||||
tsk_size_t i;
|
||||
uint32_t addr;
|
||||
if(TNET_SOCKET_TYPE_IS_IPV6(self->candidate_offer->socket->type)){
|
||||
addr_size = 16;
|
||||
|
@ -279,20 +282,20 @@ int tnet_ice_pair_send_response(tnet_ice_pair_t *self, const tnet_stun_request_t
|
|||
else{
|
||||
addr_size = 4;
|
||||
stun_att_xma->family = stun_ipv4;
|
||||
}
|
||||
|
||||
if(stun_att_xma->family == stun_ipv4){
|
||||
const struct sockaddr_in* sin = (const struct sockaddr_in*)remote_addr;
|
||||
stun_att_xma->xport = tnet_ntohs(sin->sin_port) ^ 0x2112;
|
||||
addr = (tnet_ntohl(sin->sin_addr.s_addr) ^ TNET_STUN_MAGIC_COOKIE);
|
||||
memcpy(&stun_att_xma->xaddress[0], &addr, 4);
|
||||
}
|
||||
else{
|
||||
const struct sockaddr_in6* sin6 = (const struct sockaddr_in6*)remote_addr;
|
||||
stun_att_xma->xport = tnet_ntohs(sin6->sin6_port) ^ 0x2112;
|
||||
for(i = 0; i < addr_size; i+=4){
|
||||
addr = (tnet_ntohl_2(&sin6->sin6_addr.s6_addr[i]) ^ TNET_STUN_MAGIC_COOKIE);
|
||||
memcpy(&stun_att_xma->xaddress[i], &addr, 4);
|
||||
}
|
||||
|
||||
if(stun_att_xma->family == stun_ipv4){
|
||||
const struct sockaddr_in* sin = (const struct sockaddr_in*)remote_addr;
|
||||
stun_att_xma->xport = tnet_ntohs(sin->sin_port) ^ 0x2112;
|
||||
addr = (tnet_ntohl(sin->sin_addr.s_addr) ^ TNET_STUN_MAGIC_COOKIE);
|
||||
memcpy(&stun_att_xma->xaddress[0], &addr, 4);
|
||||
}
|
||||
else{
|
||||
const struct sockaddr_in6* sin6 = (const struct sockaddr_in6*)remote_addr;
|
||||
stun_att_xma->xport = tnet_ntohs(sin6->sin6_port) ^ 0x2112;
|
||||
for(i = 0; i < addr_size; i+=4){
|
||||
addr = (tnet_ntohl_2(&sin6->sin6_addr.s6_addr[i]) ^ TNET_STUN_MAGIC_COOKIE);
|
||||
memcpy(&stun_att_xma->xaddress[i], &addr, 4);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -27,6 +27,9 @@
|
|||
#include "tsk_memory.h"
|
||||
#include "tsk_debug.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#define TRTP_RTCP_PACKET_FB_MIN_SIZE (TRTP_RTCP_HEADER_SIZE + 4 + 4)
|
||||
|
||||
static int _trtp_rtcp_report_fb_deserialize(const void* data, tsk_size_t _size, trtp_rtcp_header_t** header, uint32_t* ssrc_sender, uint32_t* ssrc_media_src)
|
||||
|
|
|
@ -135,13 +135,13 @@ const tsk_object_def_t *trtp_rtcp_source_def_t = &trtp_rtcp_source_def_s;
|
|||
static int _trtp_rtcp_source_init_seq(trtp_rtcp_source_t* self, uint16_t seq, uint32_t ts);
|
||||
static tsk_bool_t _trtp_rtcp_source_update_seq(trtp_rtcp_source_t* self, uint16_t seq, uint32_t ts);
|
||||
|
||||
static int __pred_find_source_by_ssrc(const tsk_list_item_t *item, const void *pssrc)
|
||||
{
|
||||
if(item && item->data){
|
||||
trtp_rtcp_source_t *source = item->data;
|
||||
return source->ssrc - *((uint32_t*)pssrc);
|
||||
}
|
||||
return -1;
|
||||
static int __pred_find_source_by_ssrc(const tsk_list_item_t *item, const void *pssrc)
|
||||
{
|
||||
if(item && item->data){
|
||||
trtp_rtcp_source_t *source = item->data;
|
||||
return source->ssrc - *((uint32_t*)pssrc);
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
static trtp_rtcp_source_t* _trtp_rtcp_source_create(uint32_t ssrc, uint16_t seq, uint32_t ts)
|
||||
|
@ -849,7 +849,7 @@ static void _trtp_rtcp_session_set_cname(trtp_rtcp_session_t* self, const void*
|
|||
*((uint32_t*)&_cname[i]) ^= rand();
|
||||
}
|
||||
|
||||
tsk_md5compute(_cname, sizeof(_cname), &self->cname);
|
||||
tsk_md5compute((char*)_cname, sizeof(_cname), &self->cname);
|
||||
self->is_cname_defined = tsk_true;
|
||||
}
|
||||
|
||||
|
|
|
@ -157,7 +157,7 @@ static int _trtp_manager_recv_data(const trtp_manager_t* self, const uint8_t* da
|
|||
if(self->rtcp.session){
|
||||
#if HAVE_SRTP
|
||||
if(self->srtp_ctx_neg_remote){
|
||||
if(srtp_unprotect_rtcp(self->srtp_ctx_neg_remote->session, (void*)data_ptr, &data_size) != err_status_ok){
|
||||
if(srtp_unprotect_rtcp(self->srtp_ctx_neg_remote->session, (void*)data_ptr, (int*)&data_size) != err_status_ok){
|
||||
TSK_DEBUG_ERROR("srtp_unprotect() failed");
|
||||
return -1;
|
||||
}
|
||||
|
@ -174,7 +174,7 @@ static int _trtp_manager_recv_data(const trtp_manager_t* self, const uint8_t* da
|
|||
#if HAVE_SRTP
|
||||
err_status_t status;
|
||||
if(self->srtp_ctx_neg_remote){
|
||||
if((status = srtp_unprotect(self->srtp_ctx_neg_remote->session, (void*)data_ptr, &data_size)) != err_status_ok){
|
||||
if((status = srtp_unprotect(self->srtp_ctx_neg_remote->session, (void*)data_ptr, (int*)&data_size)) != err_status_ok){
|
||||
TSK_DEBUG_ERROR("srtp_unprotect() failed with error code=%d", (int)status);
|
||||
return -1;
|
||||
}
|
||||
|
|
|
@ -68,7 +68,7 @@ int tsk_hmac_xxxcompute(const uint8_t* input, tsk_size_t input_size, const char*
|
|||
TSK_MD5_DIGEST_CALC(key, key_size, (uint8_t*)hkey);
|
||||
}
|
||||
else if(type == sha1){
|
||||
TSK_SHA1_DIGEST_CALC((uint8_t*)key, key_size, hkey);
|
||||
TSK_SHA1_DIGEST_CALC((uint8_t*)key, key_size, (uint8_t*)hkey);
|
||||
}
|
||||
else return -3;
|
||||
|
||||
|
@ -101,7 +101,7 @@ digest_compute:
|
|||
TSK_MD5_DIGEST_CALC(TSK_BUFFER_TO_U8(passx), TSK_BUFFER_SIZE(passx), digest);
|
||||
}
|
||||
else{
|
||||
TSK_SHA1_DIGEST_CALC(TSK_BUFFER_TO_U8(passx), TSK_BUFFER_SIZE(passx), (char*)digest);
|
||||
TSK_SHA1_DIGEST_CALC(TSK_BUFFER_TO_U8(passx), TSK_BUFFER_SIZE(passx), digest);
|
||||
}
|
||||
|
||||
if(pass1_done){
|
||||
|
@ -198,7 +198,7 @@ int hmac_sha1_compute(const uint8_t* input, tsk_size_t input_size, const char* k
|
|||
if((ret = hmac_sha1digest_compute(input, input_size, key, key_size, digest))){
|
||||
return ret;
|
||||
}
|
||||
tsk_str_from_hex((uint8_t*)digest, TSK_SHA1_DIGEST_SIZE, *result);
|
||||
tsk_str_from_hex((uint8_t*)digest, TSK_SHA1_DIGEST_SIZE, (char*)*result);
|
||||
(*result)[TSK_SHA1_STRING_SIZE] = '\0';
|
||||
|
||||
return 0;
|
||||
|
|
|
@ -445,11 +445,11 @@ tsk_sha1_errcode_t tsk_sha1compute(const char* input, tsk_size_t size, tsk_sha1s
|
|||
else if ( (ret = tsk_sha1input(&sha, (uint8_t*)input, size)) != shaSuccess ){
|
||||
return ret;
|
||||
}
|
||||
else if( (ret = tsk_sha1result(&sha, (char*)digest)) != shaSuccess ){
|
||||
else if( (ret = tsk_sha1result(&sha, digest)) != shaSuccess ){
|
||||
return ret;
|
||||
}
|
||||
|
||||
tsk_str_from_hex(digest, TSK_SHA1_DIGEST_SIZE, *result);
|
||||
tsk_str_from_hex(digest, TSK_SHA1_DIGEST_SIZE, (char*)*result);
|
||||
|
||||
return shaSuccess;
|
||||
}
|
||||
|
|
|
@ -128,7 +128,7 @@ tsk_bool_t tcomp_compressordisp_compress(tcomp_compressordisp_t *dispatcher, uin
|
|||
|
||||
tsk_sha1reset(&sha);
|
||||
tsk_sha1input(&sha, (const uint8_t*)output_ptr, *output_size);
|
||||
tsk_sha1result(&sha, (char*)nackId);
|
||||
tsk_sha1result(&sha, (uint8_t*)nackId);
|
||||
tcomp_compartment_addNack(lpCompartment, nackId);
|
||||
}
|
||||
|
||||
|
|
|
@ -106,7 +106,7 @@ void tcomp_state_makeValid(tcomp_state_t* state)
|
|||
|
||||
tsk_sha1input(&sha, firstPart, 8);
|
||||
tsk_sha1input(&sha, tcomp_buffer_getBuffer(state->value), tcomp_buffer_getSize(state->value));
|
||||
err = tsk_sha1result(&sha, (char*)tcomp_buffer_getBuffer(state->identifier));
|
||||
err = tsk_sha1result(&sha, (uint8_t*)tcomp_buffer_getBuffer(state->identifier));
|
||||
}
|
||||
|
||||
/* unlock */
|
||||
|
|
|
@ -580,7 +580,7 @@ tsk_bool_t TCOMP_UDVM_EXEC_INST__SHA_1(tcomp_udvm_t *udvm, uint16_t position, ui
|
|||
goto bail;
|
||||
}
|
||||
|
||||
if( (err = tsk_sha1result(&sha, (char*)Message_Digest)) ){
|
||||
if( (err = tsk_sha1result(&sha, (uint8_t*)Message_Digest)) ){
|
||||
ok = tsk_false;
|
||||
tcomp_udvm_createNackInfo2(udvm, NACK_INTERNAL_ERROR);
|
||||
goto bail;
|
||||
|
|
|
@ -88,7 +88,7 @@ void tcomp_udvm_createNackInfo(tcomp_udvm_t *udvm, uint8_t reasonCode, tcomp_buf
|
|||
*/
|
||||
tsk_sha1reset(&sha);
|
||||
tsk_sha1input(&sha, udvm->sigCompMessage->startPtr, udvm->sigCompMessage->totalSize);
|
||||
tsk_sha1result(&sha, (char*)(nackbuffer_ptr + NACK_SHA1_INDEX));
|
||||
tsk_sha1result(&sha, (uint8_t*)(nackbuffer_ptr + NACK_SHA1_INDEX));
|
||||
|
||||
/*
|
||||
* Details
|
||||
|
|
Loading…
Reference in New Issue