コード例 #1
0
ファイル: config_transport.c プロジェクト: GGGO/asterisk
/*!
 * \internal
 * \brief Should only be called by the individual field handlers
 */
static struct ast_sip_transport_state *find_or_create_temporary_state(struct ast_sip_transport *transport)
{
	struct ast_sip_transport_state **state;
	struct ast_sip_transport_state *new_state;

	if ((new_state = find_temporary_state(transport))) {
		return new_state;
	}

	state = ast_threadstorage_get(&temp_state_store, sizeof(state));
	if (!state || *state) {
		return NULL;
	}

	new_state = ao2_alloc(sizeof(**state), sip_transport_state_destroy);
	if (!new_state) {
		return NULL;
	}
	new_state->id = ast_strdup(ast_sorcery_object_get_id(transport));
	new_state->type = transport->type;

	pjsip_tls_setting_default(&new_state->tls);
	new_state->tls.ciphers = new_state->ciphers;

	ao2_ref(new_state, +1);
	*state = new_state;

	return new_state;
}
コード例 #2
0
ファイル: func_curl.c プロジェクト: commshare/squeezeterisk
static int curl_internal(struct MemoryStruct *chunk, char *url, char *post)
{
	int ret;
	CURL **curl;

	if (!(curl = ast_threadstorage_get(&curl_instance, sizeof(*curl))))
		return -1;

	if (!*curl) {
		if (!(*curl = curl_easy_init()))
			return -1;
		curl_easy_setopt(*curl, CURLOPT_NOSIGNAL, 1);
		curl_easy_setopt(*curl, CURLOPT_TIMEOUT, 180);
		curl_easy_setopt(*curl, CURLOPT_WRITEFUNCTION, WriteMemoryCallback);
		curl_easy_setopt(*curl, CURLOPT_USERAGENT, global_useragent);
		curl_easy_setopt(*curl, CURLOPT_SSL_VERIFYHOST, 0);
		curl_easy_setopt(*curl, CURLOPT_SSL_VERIFYPEER, 0);
	}

	curl_easy_setopt(*curl, CURLOPT_URL, url);
	curl_easy_setopt(*curl, CURLOPT_WRITEDATA, (void *) chunk);

	if (post) {
		curl_easy_setopt(*curl, CURLOPT_POST, 1);
		curl_easy_setopt(*curl, CURLOPT_POSTFIELDS, post);
	}

	ret = curl_easy_perform(*curl);

	if (post)
		curl_easy_setopt(*curl, CURLOPT_POST, 0);

	return ret ? -1 : 0;
}
コード例 #3
0
/*!
 * \brief Retrieve authentication information from thread-local storage
 */
static struct ast_sip_auth *get_auth(void)
{
	struct ast_sip_auth **auth;
	auth = ast_threadstorage_get(&auth_store, sizeof(auth));
	if (auth && *auth) {
		ao2_ref(*auth, +1);
		return *auth;
	}
	return NULL;
}
コード例 #4
0
/*!
 * \brief Store authentication information in thread-local storage
 */
static int store_auth(struct ast_sip_auth *auth)
{
	struct ast_sip_auth **pointing;
	pointing = ast_threadstorage_get(&auth_store, sizeof(pointing));
	if (!pointing || *pointing) {
		return -1;
	}

	ao2_ref(auth, +1);
	*pointing = auth;
	return 0;
}
コード例 #5
0
/*!
 * \brief Remove authentication information from thread-local storage
 */
static int remove_auth(void)
{
	struct ast_sip_auth **pointing;
	pointing = ast_threadstorage_get(&auth_store, sizeof(pointing));
	if (!pointing) {
		return -1;
	}

	ao2_cleanup(*pointing);
	*pointing = NULL;
	return 0;
}
コード例 #6
0
ファイル: config_transport.c プロジェクト: GGGO/asterisk
static struct ast_sip_transport_state *find_temporary_state(struct ast_sip_transport *transport)
{
	struct ast_sip_transport_state **state;

	state = ast_threadstorage_get(&temp_state_store, sizeof(state));
	if (state && *state) {
		ao2_ref(*state, +1);
		return *state;
	}

	return NULL;
}
コード例 #7
0
ファイル: config_transport.c プロジェクト: GGGO/asterisk
static int remove_temporary_state(void)
{
	struct ast_sip_transport_state **state;

	state = ast_threadstorage_get(&temp_state_store, sizeof(state));
	if (!state) {
		return -1;
	}

	ao2_cleanup(*state);
	*state = NULL;
	return 0;
}
コード例 #8
0
ファイル: term.c プロジェクト: steelbrain/asterisk
const char *ast_term_color(int fgcolor, int bgcolor)
{
    struct commonbuf *cb = ast_threadstorage_get(&commonbuf, sizeof(*cb));
    char *buf;

    if (!cb) {
        return "";
    }
    buf = cb->buffer[cb->which++];
    if (cb->which == AST_TERM_MAX_ROTATING_BUFFERS) {
        cb->which = 0;
    }

    return term_color_code(buf, fgcolor, bgcolor, AST_TERM_MAX_ESCAPE_CHARS);
}
コード例 #9
0
ファイル: json.c プロジェクト: huangjingpei/asterisk
/*!
 * \brief Thread local list of \ref json_mem blocks to free at the end of an
 * unref.
 */
static struct json_mem_list *json_free_list(void)
{
	return ast_threadstorage_get(&json_free_list_ts,
		sizeof(struct json_mem_list));
}