예제 #1
0
tnet_tls_socket_handle_t* tnet_tls_socket_create(tnet_fd_t fd, struct ssl_ctx_st* ssl_ctx)
{
#if !HAVE_OPENSSL
	TSK_DEBUG_ERROR("OpenSSL not enabled");
	return tsk_null;
#else
	tnet_tls_socket_t* socket;
	if(fd <= 0 || !ssl_ctx){
		TSK_DEBUG_ERROR("Invalid parameter");
		return tsk_null;
	}
	if((socket = tsk_object_new(tnet_tls_socket_def_t))){
		socket->fd = fd;
		if(!(socket->ssl = SSL_new(ssl_ctx))){
			TSK_DEBUG_ERROR("SSL_new(CTX) failed [%s]", ERR_error_string(ERR_get_error(), tsk_null));
			TSK_OBJECT_SAFE_FREE(socket);
			return tsk_null;
		}
		if(SSL_set_fd(socket->ssl, socket->fd) != 1){
			TSK_DEBUG_ERROR("SSL_set_fd(%d) failed [%s]", socket->fd, ERR_error_string(ERR_get_error(), tsk_null));
			TSK_OBJECT_SAFE_FREE(socket);
			return tsk_null;
		}
	}
	return socket;
#endif
}
예제 #2
0
tnet_transport_t* tnet_transport_create(const char* host, tnet_port_t port, tnet_socket_type_t type, const char* description)
{		
	tnet_transport_t* transport;

	if((transport = tsk_object_new(tnet_transport_def_t))){
		transport->description = tsk_strdup(description);
		transport->local_host = tsk_strdup(host);
		transport->req_local_port = port;
		transport->type = type;
		transport->context = tnet_transport_context_create();
		
		if((transport->master = tnet_socket_create(transport->local_host, transport->req_local_port, transport->type))){
			transport->local_ip = tsk_strdup(transport->master->ip);
			transport->bind_local_port = transport->master->port;
		}
		else{
			TSK_DEBUG_ERROR("Failed to create master socket");
			TSK_OBJECT_SAFE_FREE(transport);
		}

		if(_tnet_transport_ssl_init(transport) != 0){
			TSK_DEBUG_ERROR("Failed to initialize TLS and/or DTLS caps");
			TSK_OBJECT_SAFE_FREE(transport);
		}
		// set priority
		tsk_runnable_set_priority(TSK_RUNNABLE(transport), TSK_THREAD_PRIORITY_TIME_CRITICAL);
	}

	return transport;
}
예제 #3
0
/**@ingroup tnet_nat_group
* Creates new NAT context.
*/
struct tnet_nat_ctx_s* tnet_nat_context_create(tnet_socket_type_t socket_type, const char* pc_username, const char* pc_password)
{
    extern const tsk_object_def_t *tnet_nat_context_def_t;
    struct tnet_nat_ctx_s* p_ctx;

    if (!(p_ctx = tsk_object_new(tnet_nat_context_def_t)) || !(p_ctx->stun_bindings = tsk_list_create())) {
        TSK_OBJECT_SAFE_FREE(p_ctx);
        TSK_DEBUG_ERROR("Failed to create NAT context");
        return tsk_null;
    }

    p_ctx->socket_type = socket_type;
    p_ctx->username = tsk_strdup(pc_username);
    p_ctx->password = tsk_strdup(pc_password);
    p_ctx->server_port = kStunPortDefaultTcpUdp;
    /*	7.2.1.  Sending over UDP
    	In fixed-line access links, a value of 500 ms is RECOMMENDED.
    */
    p_ctx->RTO = kStunRTO;
    /*	7.2.1.  Sending over UDP
    	Rc SHOULD be configurable and SHOULD have a default of 7.
    */
    p_ctx->Rc = kStunRC;

    return p_ctx;
}
예제 #4
0
tnet_transport_t* tnet_transport_create_2(tnet_socket_t *master, const char* description)
{
	tnet_transport_t* transport;
	if(!master){
		TSK_DEBUG_ERROR("Invalid parameter");
		return tsk_null;
	}

	if((transport = tsk_object_new(tnet_transport_def_t))){
		transport->description = tsk_strdup(description);
		transport->local_host = tsk_strdup(master->ip);
		transport->req_local_port = master->port;
		transport->type = master->type;
		
		transport->master = tsk_object_ref(master);
		transport->local_ip = tsk_strdup(transport->master->ip);
		transport->bind_local_port = transport->master->port;

		transport->context = tnet_transport_context_create();

		if(_tnet_transport_ssl_init(transport) != 0){
			TSK_DEBUG_ERROR("Failed to initialize TLS and/or DTLS caps");
			TSK_OBJECT_SAFE_FREE(transport);
		}

		// set priority
		tsk_runnable_set_priority(TSK_RUNNABLE(transport), TSK_THREAD_PRIORITY_TIME_CRITICAL);
	}

	return transport;
}
예제 #5
0
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, const char *foundation)
{
	tnet_ice_candidate_t* candidate;

	if(!(candidate = tsk_object_new(&tnet_ice_candidate_def_s))){
		TSK_DEBUG_ERROR("Failed to create candidate");
		return tsk_null;
	}
	
	candidate->type_e = type_e;
	candidate->socket = tsk_object_ref(socket);
	candidate->local_pref = 0xFFFF;
	candidate->is_ice_jingle = is_ice_jingle;
	candidate->is_rtp = is_rtp;
	candidate->is_video = is_video;
	candidate->comp_id = is_rtp ? TNET_ICE_CANDIDATE_COMPID_RTP : TNET_ICE_CANDIDATE_COMPID_RTCP;
	if(foundation){
		memcpy(candidate->foundation, foundation, TSK_MIN(tsk_strlen(foundation), TNET_ICE_CANDIDATE_FOUND_SIZE_PREF));
	}
	else{
		tnet_ice_utils_compute_foundation((char*)candidate->foundation, TSK_MIN(sizeof(candidate->foundation), TNET_ICE_CANDIDATE_FOUND_SIZE_PREF));
	}
	candidate->priority = tnet_ice_utils_get_priority(candidate->type_e, candidate->local_pref, candidate->is_rtp);
	if(candidate->socket){
		memcpy(candidate->connection_addr, candidate->socket->ip, sizeof(candidate->socket->ip));
		candidate->port = candidate->socket->port;
		candidate->transport_e = socket->type;
	}
	tnet_ice_candidate_set_credential(candidate, ufrag, pwd);
	
	return candidate;
}
예제 #6
0
tnet_dtls_socket_handle_t* tnet_dtls_socket_create(struct tnet_socket_s* wrapped_sock, struct ssl_ctx_st* ssl_ctx)
{
#if !HAVE_OPENSSL || !HAVE_OPENSSL_DTLS
	TSK_DEBUG_ERROR("OpenSSL or DTLS not enabled");
	return tsk_null;
#else
	tnet_dtls_socket_t* socket;

	if (!wrapped_sock || !ssl_ctx){
		TSK_DEBUG_ERROR("Invalid parameter");
		return tsk_null;
	}
	if ((socket = tsk_object_new(tnet_dtls_socket_def_t))) {
		const tsk_bool_t set_mtu = TNET_SOCKET_TYPE_IS_DGRAM(wrapped_sock->type) || 1; //!\ This is required even if the local transport is TCP/TLS because the relayed (TURN) transport could be UDP
		socket->wrapped_sock = tsk_object_ref(wrapped_sock);
		if (!(socket->ssl = SSL_new(ssl_ctx))) {
			TSK_DEBUG_ERROR("SSL_new(CTX) failed [%s]", ERR_error_string(ERR_get_error(), tsk_null));
			TSK_OBJECT_SAFE_FREE(socket);
			return tsk_null;
		}
		if (set_mtu) {
			SSL_set_options(socket->ssl, SSL_OP_NO_QUERY_MTU);
			SSL_set_mtu(socket->ssl, TNET_DTLS_MTU - 28);
			socket->ssl->d1->mtu = TNET_DTLS_MTU - 28;
		}
		if (!(socket->rbio = BIO_new(BIO_s_mem())) || !(socket->wbio = BIO_new(BIO_s_mem()))){
			TSK_DEBUG_ERROR("BIO_new_socket(%d) failed [%s]", socket->wrapped_sock->fd, ERR_error_string(ERR_get_error(), tsk_null));
			if (socket->rbio){
				BIO_free(socket->rbio);
			}
			if (socket->wbio){
				BIO_free(socket->wbio);
			}
			TSK_OBJECT_SAFE_FREE(socket);
			return tsk_null;
		}
		BIO_set_mem_eof_return(socket->rbio, -1);
		BIO_set_mem_eof_return(socket->wbio, -1);
		SSL_set_bio(socket->ssl, socket->rbio, socket->wbio);
		SSL_set_mode(socket->ssl, SSL_MODE_AUTO_RETRY);
		SSL_set_read_ahead(socket->ssl, 1);
		if (set_mtu) {
			BIO_ctrl(SSL_get_wbio(socket->ssl), BIO_CTRL_DGRAM_SET_MTU, TNET_DTLS_MTU - 28, NULL);
		}

		if ((socket->verify_peer = (SSL_CTX_get_verify_mode(ssl_ctx) != SSL_VERIFY_NONE))){
			TSK_DEBUG_INFO("SSL cert verify: ON");
			socket->verify_peer = tsk_true;
			SSL_set_verify(socket->ssl, (SSL_VERIFY_PEER | SSL_VERIFY_FAIL_IF_NO_PEER_CERT), _tnet_dtls_verify_cert);
		}
		else {
			TSK_DEBUG_ERROR("Verity not enabled");
		}

		SSL_set_app_data(socket->ssl, socket);
	}
	return socket;
#endif
}
예제 #7
0
trtp_rtp_packet_t* trtp_rtp_packet_create(uint32_t ssrc, uint16_t seq_num, uint32_t timestamp, uint8_t payload_type, tsk_bool_t marker)
{
	trtp_rtp_packet_t* packet;
	if((packet = tsk_object_new(trtp_rtp_packet_def_t))){
		packet->header = trtp_rtp_header_create(ssrc, seq_num, timestamp, payload_type, marker);
	}
	return packet;
}
예제 #8
0
trtp_rtcp_packet_t* trtp_rtcp_packet_create(struct trtp_rtcp_header_s* header)
{
	trtp_rtcp_packet_t* packet;
	if((packet = tsk_object_new(trtp_rtcp_packet_def_t)) && header){
		packet->header = tsk_object_ref(header);
	}
	return packet;
}
예제 #9
0
static struct tsip_transac_dst_s* tsip_transac_dst_create(tsip_transac_dst_type_t type, struct tsip_stack_s* stack)
{
	struct tsip_transac_dst_s* dst = tsk_object_new(tsip_transac_dst_def_t);
	if(dst){
		dst->type = type;
		dst->stack = tsk_object_ref(stack);
	}
	return dst;
}
예제 #10
0
tdav_runnable_video_t* tdav_runnable_video_create(tsk_runnable_func_run run_f, const void* userdata)
{
	tdav_runnable_video_t* runnable;

	if((runnable = tsk_object_new(tdav_runnable_video_def_t))){
		TSK_RUNNABLE(runnable)->run = run_f;
		runnable->userdata = userdata;
	}
	return runnable;
}
예제 #11
0
/**@ingroup tsms_tpdu_group
* Creates new @a SMS-DELIVER message.
* @a SMS-DELIVER messages are used to convey short messages from the SC (Service Center) to the MS (Mobile Station).<br>
* For more information, please refer to 3GPP TS 23.040 section 9.2.2.1.
* @param smsc SMSC address. e.g. "+331253688".
* @param orig The Originator address. e.g. "+331253688".
* @retval SMS-DELIVER message.
*
* See For more information, see @ref tsms_tpdu_group_DELIVER "SMS-DELIVER".
*/
tsms_tpdu_deliver_t* tsms_tpdu_deliver_create(const tsms_address_string_t smsc, const tsms_address_string_t orig)
{
	tsms_tpdu_deliver_t* ret = tsk_null;
	
	if(!(ret = tsk_object_new(tsms_tpdu_deliver_def_t, smsc, orig))){
		goto bail;
	}
	
bail:
	return ret;
}
예제 #12
0
tdav_video_jb_t* tdav_video_jb_create()
{
	tdav_video_jb_t* jb;

	if((jb = tsk_object_new(&tdav_video_jb_def_s))){
		jb->fps = TDAV_VIDEO_JB_FPS;
		jb->fps_prob = TDAV_VIDEO_JB_FPS_PROB;
		jb->tail_max = TDAV_VIDEO_JB_TAIL_MAX;
	}
	return jb;
}
예제 #13
0
tdav_video_jb_t* tdav_video_jb_create()
{
    tdav_video_jb_t* jb;

    if ((jb = tsk_object_new(&tdav_video_jb_def_s))) {
        if (_tdav_video_jb_set_defaults(jb) != 0) {
            TSK_OBJECT_SAFE_FREE(jb);
        }
    }
    return jb;
}
예제 #14
0
trtp_rtp_packet_t* trtp_rtp_packet_create_2(const trtp_rtp_header_t* header)
{
	trtp_rtp_packet_t* packet;

	if(!header){
		TSK_DEBUG_ERROR("Invalid parameter");
		return tsk_null;
	}
	if((packet = tsk_object_new(trtp_rtp_packet_def_t))){
		packet->header = tsk_object_ref(TSK_OBJECT(header));
	}
	return packet;
}
예제 #15
0
tmsrp_event_t* tmsrp_event_create(const void* callback_data, tsk_bool_t outgoing, tmsrp_event_type_t type, tmsrp_message_t* message)
{
	tmsrp_event_t* _event;
	if((_event = tsk_object_new(tmsrp_event_def_t))){
		_event->callback_data = callback_data;
		_event->outgoing = outgoing;
		_event->type = type;
		_event->message = tsk_object_ref(message);
	}
	else{
		TSK_DEBUG_ERROR("Faile to create new MSRP event");
	}

	return _event;
}
예제 #16
0
tsk_plugin_t* tsk_plugin_create(const char* path)
{
	tsk_plugin_t* plugin;
	symbol_get_def_count funcptr_get_def_count;
	tsk_plugin_handle_t* handle;

#if TSK_UNDER_WINDOWS
#	if TSK_UNDER_WINDOWS_RT
	wchar_t* szPath = (wchar_t*)tsk_calloc(tsk_strlen(path) + 1, sizeof(wchar_t));
	static const wchar_t* szFormat = L"%hs";
	swprintf(szPath, tsk_strlen(path) * sizeof(wchar_t), szFormat, path);
	handle = LoadPackagedLibrary(szPath, 0x00000000);
	TSK_FREE(szPath);
#	else /* Windows desktop */
	UINT currErrMode = SetErrorMode(SEM_FAILCRITICALERRORS); // save current ErrorMode. GetErrorMode() not supported on XP.
	SetErrorMode(currErrMode | SEM_FAILCRITICALERRORS);
	handle = LoadLibraryA(path);
	SetErrorMode(currErrMode); // restore ErrorMode
#	endif
#else
	handle = dlopen(path, RTLD_NOW);
#endif

	if(!handle){
		TSK_DEBUG_ERROR("Failed to load library with path=%s", path);
		return tsk_null;
	}

	if(!(funcptr_get_def_count = (symbol_get_def_count)_tsk_plugin_handle_get_symbol(handle, TSK_PLUGIN_FUNC_NAME_DEF_COUNT))){
		TSK_DEBUG_ERROR("Cannot find function with name=%s", TSK_PLUGIN_FUNC_NAME_DEF_COUNT);
		_tsk_plugin_handle_destroy(&handle);
		return tsk_null;
	}

	if(!(plugin = (tsk_plugin_t*)tsk_object_new(&tsk_plugin_def_s))){
		TSK_DEBUG_ERROR("Failed to create plugin object");
		_tsk_plugin_handle_destroy(&handle);
		return tsk_null;
	}

	plugin->handle = handle;
	plugin->def_count = funcptr_get_def_count();
	plugin->path = tsk_strdup(path);

	TSK_DEBUG_INFO("Plugin with path=[%s] created with [%d] defs", plugin->path, plugin->def_count);

	return plugin;
}
예제 #17
0
tnet_ice_event_t* tnet_ice_event_create(const struct tnet_ice_ctx_s* ctx, tnet_ice_event_type_t type, const char* phrase, const void* userdata)
{
	tnet_ice_event_t* e;

	if((e = tsk_object_new(tnet_ice_event_def_t))){
		e->ctx = ctx;
		e->type = type;
		e->phrase = tsk_strdup(phrase);
		e->userdata = userdata;
	}
	else{
		TSK_DEBUG_ERROR("Failed to create ICE event");
	}

	return e;
}
예제 #18
0
tsip_transac_nict_t* tsip_transac_nict_create(int32_t cseq_value, const char* cseq_method, const char* callid, tsip_transac_dst_t* dst)
{
	tsip_transac_nict_t* transac = tsk_object_new(tsip_transac_nict_def_t);
	if(transac){
		// initialize base class
		tsip_transac_init(TSIP_TRANSAC(transac), tsip_transac_type_nict, cseq_value, cseq_method, callid, dst, _fsm_state_Started, _fsm_state_Terminated);

		// init FSM
		TSIP_TRANSAC_GET_FSM(transac)->debug = DEBUG_STATE_MACHINE;
		tsk_fsm_set_callback_terminated(TSIP_TRANSAC_GET_FSM(transac), TSK_FSM_ONTERMINATED_F(tsip_transac_nict_OnTerminated), (const void*)transac);

		// initialize NICT object
		tsip_transac_nict_init(transac);
	}
	return transac;
}
예제 #19
0
tmedia_param_t* tmedia_param_create(tmedia_param_access_type_t access_type, 
									tmedia_type_t media_type, 
									tmedia_param_plugin_type_t plugin_type, 
									tmedia_param_value_type_t value_type,
									const char* key,
									void* value)
{
	tmedia_param_t* param;
	
	if(!key ||!value){
		TSK_DEBUG_ERROR("Invalid parameter");
		return tsk_null;
	}

	if((param = tsk_object_new(tmedia_param_def_t))){
		param->access_type = access_type;
		param->media_type = media_type;
		param->plugin_type = plugin_type;
		param->value_type = value_type;
		param->key = tsk_strdup(key);
		switch(value_type){
			case tmedia_pvt_int32:
				if(param->value = tsk_calloc(1, sizeof(int32_t))){
					memcpy(param->value, value, sizeof(int32_t));
					//*((int32_t*)param->value) = *((int32_t*)value);
				}
				break;
			case tmedia_pvt_pobject:
				param->value = tsk_object_ref(value);
				break;
			case tmedia_pvt_pchar:
				param->value = tsk_strdup(value);
				break;
			case tmedia_pvt_int64:
				if(param->value = tsk_calloc(1, sizeof(int64_t))){
					memcpy(param->value, value, sizeof(int64_t));
					//*((int64_t*)param->value) = *((int64_t*)value);
				}
				break;
		}
	}
	else{
		TSK_DEBUG_ERROR("Failed to create media parameter");
	}
	return param;
}
예제 #20
0
/**@ingroup tmedia_codec_group
* Creates a new codec using an already registered plugin.
* @param format The format of the codec to create (e.g. "0" for PCMU or "8" for PCMA or "*" for MSRP)
* @sa @ref tmedia_codec_plugin_register()
*/
tmedia_codec_t* tmedia_codec_create(const char* format)
{
    tmedia_codec_t* codec = tsk_null;
    const tmedia_codec_plugin_def_t* plugin;
    tsk_size_t i = 0;

    while((i < TMED_CODEC_MAX_PLUGINS) && (plugin = __tmedia_codec_plugins[i++])) {
        if(plugin->objdef && tsk_striequals(plugin->format, format)) {
            if((codec = tsk_object_new(plugin->objdef))) {
                /* initialize the newly created codec */
                codec->id = plugin->codec_id;
                codec->dyn = plugin->dyn;
                codec->plugin = plugin;
                codec->bl = tmedia_bl_medium;
                switch(plugin->type) {
                case tmedia_audio: {
                    /* Audio codec */
                    tmedia_codec_audio_t* audio = TMEDIA_CODEC_AUDIO(codec);
                    tmedia_codec_audio_init(TMEDIA_CODEC(audio), plugin->name, plugin->desc, plugin->format);
                    break;
                }
                case tmedia_video: {
                    /* Video codec */
                    tmedia_codec_video_t* video = TMEDIA_CODEC_VIDEO(codec);
                    tmedia_codec_video_init(TMEDIA_CODEC(video), plugin->name, plugin->desc, plugin->format);
                    break;
                }
                case tmedia_msrp: {
                    /* Msrp codec */
                    tmedia_codec_msrp_init(codec, plugin->name, plugin->desc);
                    break;
                }
                default: {
                    /* Any other codec */
                    tmedia_codec_init(codec, plugin->type, plugin->name, plugin->desc, plugin->format);
                    break;
                }
                }
                break;
            }
        }
    }

    return codec;
}
예제 #21
0
tmedia_jitterbuffer_t* tmedia_jitterbuffer_create(tmedia_type_t type)
{
	tmedia_jitterbuffer_t* jitter_buffer = tsk_null;
	const tmedia_jitterbuffer_plugin_def_t* plugin;
	tsk_size_t i = 0;

	while((i < TMED_JITTER_BUFFER_MAX_PLUGINS) && (plugin = __tmedia_jitterbuffer_plugins[i++])){
		if(plugin->objdef && plugin->type == type){
			if((jitter_buffer = tsk_object_new(plugin->objdef))){
				/* initialize the newly created jitter_buffer */
				jitter_buffer->plugin = plugin;
				break;
			}
		}
	}

	return jitter_buffer;
}
예제 #22
0
/**@ingroup tmedia_consumer_group
* Creates a new consumer using an already registered plugin.
* @param type The type of the consumer to create
* @param session_id
* @sa @ref tmedia_consumer_plugin_register()
*/
tmedia_consumer_t* tmedia_consumer_create(tmedia_type_t type, uint64_t session_id)
{
	tmedia_consumer_t* consumer = tsk_null;
	const tmedia_consumer_plugin_def_t* plugin;
	tsk_size_t i = 0;

	while((i < TMED_CONSUMER_MAX_PLUGINS) && (plugin = __tmedia_consumer_plugins[i++])){
		if(plugin->objdef && plugin->type == type){
			if((consumer = tsk_object_new(plugin->objdef))){
				/* initialize the newly created consumer */
				consumer->plugin = plugin;
				consumer->session_id = session_id;
				break;
			}
		}
	}

	return consumer;
}
예제 #23
0
/** internal function used to create new SIP action */
tsip_action_t* _tsip_action_create(tsip_action_type_t type, va_list* app)
{
	tsip_action_t* action = tsk_null;

	/* create the action */
	if(!(action = tsk_object_new(tsip_action_def_t))){
		TSK_DEBUG_ERROR("Failed to create new SIP action.");
		return tsk_null;
	}
	else{
		action->type = type;
	}

	/* configure the action */
	if(_tsip_action_set(action, app)){
		TSK_DEBUG_ERROR("Invalid parameter");
		TSK_OBJECT_SAFE_FREE(action);
	}	
	
	return action;
}
예제 #24
0
파일: txcap.c 프로젝트: NewComerBH/doubango
/**@ingroup txcap_stack_group
* Creates new XCAP stack.
* @param callback Poiner to the callback function to call when new messages come to the transport layer.
* Can be set to Null if you don't want to be alerted.
* @param xui user's id as per RFC 4825 subclause 4. Also used to fill @b "X-3GPP-Intended-Identity" header.
* This paramter is mandatory and must not be null. If for any reason you'd like to update the user's id, then use @ref TXCAP_STACK_SET_XUI().
* @param password user's password used to authenticate to the XDMS.
* This parameter is not mandatory. If for any reason you'd like to update the password, then use @ref TXCAP_STACK_SET_PASSWORD().
* @param xcap_root xcap-root URI as per RFC 4825 subclause 6.1, used to build all request-uris. 
* This parameter is not mandatory and must be a valid HTPP/HTTPS URL.
* @param ... User configuration. You must use @a TXCAP_STACK_SET_*() macros to set these options.
* The list of options must always end with @ref TXCAP_STACK_SET_NULL() even if these is no option to pass to the stack.
* @retval A Pointer to the newly created stack if succeed and @a Null otherwise.
* A stack is a well-defined object.
*
* @code
int test_stack_callback(const thttp_event_t *httpevent);

txcap_stack_handle_t* stack = txcap_stack_create(test_stack_callback, "sip:[email protected]", "mysecret", "http://doubango.org:8080/services",
		
		// stack-level options
		TXCAP_STACK_SET_OPTION(TXCAP_STACK_OPTION_TIMEOUT, "6000"),
		
		// stack-level headers
		TXCAP_STACK_SET_HEADER("Connection", "Keep-Alive"),
		TXCAP_STACK_SET_HEADER("User-Agent", "XDM-client/OMA1.1"),
		TXCAP_STACK_SET_HEADER("X-3GPP-Intended-Identity", XUI),
		
		TXCAP_STACK_SET_NULL());
* @endcode
*
* @sa @ref txcap_stack_set
*/
txcap_stack_handle_t* txcap_stack_create(thttp_stack_callback_f callback, const char* xui, const char* password, const char* xcap_root, ...)
{
	txcap_stack_t* ret = tsk_null;

	if(!xui || !xcap_root){
		TSK_DEBUG_ERROR("Both xui and xcap_root are mandatory and should be non-null");
		goto bail;
	}

	/* check url validity */
	if(!thttp_url_isvalid(xcap_root)){
		TSK_DEBUG_ERROR("%s is not a valid HTTP/HTTPS url", xcap_root);
		goto bail;
	}

	if(!(ret = tsk_object_new(txcap_stack_def_t, callback, xui, password, xcap_root))){
		TSK_DEBUG_FATAL("Failed to create the XCAP stack");
		goto bail;
	}
	else{
		/* set parameters */
		va_list ap;
		va_start(ap, xcap_root);
		__txcap_stack_set(ret, &ap);
		va_end(ap);
		/* credendials */
		tsk_strupdate(&ret->xui, xui);
		tsk_strupdate(&ret->password, password);
		if(ret->http_session){
			thttp_session_set(ret->http_session,
				THTTP_SESSION_SET_CRED(ret->xui, ret->password),
				THTTP_SESSION_SET_NULL());
		}
	}

bail:
	return ret;
}
예제 #25
0
thttp_challenge_t* thttp_challenge_create(tsk_bool_t isproxy, const char* scheme, const char* realm, const char* nonce, const char* opaque, const char* algorithm, const char* qop)
{
    thttp_challenge_t* challenge = tsk_object_new(thttp_challenge_def_t);
    if (challenge) {

        challenge->isproxy = isproxy;
        challenge->scheme = tsk_strdup(scheme);
        challenge->realm = tsk_strdup(realm);
        challenge->nonce = tsk_strdup(nonce);
        challenge->opaque = tsk_strdup(opaque);
        challenge->algorithm = tsk_strdup(algorithm);

        if (!tsk_strnullORempty(qop)) {
            challenge->qop = tsk_strcontains(qop, tsk_strlen(qop), "auth-int") ? "auth-int" :
                             (tsk_strcontains(qop, tsk_strlen(qop), "auth") ? "auth" : tsk_null);
        }

        if (challenge->qop) {
            _thttp_challenge_reset_cnonce(challenge);
        }
    }
    return challenge;
}
예제 #26
0
/**@ingroup tsk_list_group
* Create and initialize an item to be added to a @ref tsk_list_t "linked list". 
* You should not need to call this function by yourself. See @ref _Anchor_TinySAK_Linked_List_Add_Remove "here" for more information on how to add items.<br />
* You <b>MUST</b> use @ref TSK_OBJECT_SAFE_FREE() to safely free the returned @ref _Page_TinySAK_AnsiC_Object_Programming "well-defined" object. <br />
* @return The newly created @ref tsk_list_item_t "item" object.
*/
tsk_list_item_t* tsk_list_item_create()
{
	return (tsk_list_item_t*)tsk_object_new(tsk_list_item_def_t);
}
예제 #27
0
thttp_challenge_t* thttp_challenge_create(tsk_bool_t isproxy, const char* scheme, const char* realm, const char* nonce, const char* opaque, const char* algorithm, const char* qop)
{
	return tsk_object_new(thttp_challenge_def_t, isproxy, scheme, realm, nonce, opaque, algorithm, qop);
}
예제 #28
0
/**@ingroup tnet_socket_group
* Creates a new socket.
* To check that the returned socket is valid use @ref TNET_SOCKET_IS_VALID function.
* @param host FQDN (e.g. www.doubango.org) or IPv4/IPv6 IP string.
* @param port The local/remote port used to receive/send data. Set the port value to @ref TNET_SOCKET_PORT_ANY to bind to a random port.
* @param type The type of the socket. See @ref tnet_socket_type_t.
* @param nonblocking Indicates whether to create non-blocking socket.
* @param bindsocket Indicates whether to bind the newly created socket or not.
* @retval @ref tnet_socket_t object.
* @sa @ref tnet_socket_create.
*/
tnet_socket_t* tnet_socket_create_2(const char*host, tnet_port_t port, tnet_socket_type_t type, tsk_bool_t nonblocking, tsk_bool_t bindsocket)
{
	return tsk_object_new(tnet_socket_def_t, host, port, type, nonblocking, bindsocket);
}
예제 #29
0
tnet_dhcp_option_dns_t* tnet_dhcp_option_dns_create(const void* payload, tsk_size_t payload_size)
{
	return tsk_object_new(tnet_dhcp_option_dns_def_t, payload, payload_size);
}
예제 #30
0
tnet_dhcp_option_paramslist_t* tnet_dhcp_option_paramslist_create()
{
	return tsk_object_new(tnet_dhcp_option_paramslist_def_t);
}