本文整理汇总了C++中pj_strdup_with_null函数的典型用法代码示例。如果您正苦于以下问题:C++ pj_strdup_with_null函数的具体用法?C++ pj_strdup_with_null怎么用?C++ pj_strdup_with_null使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了pj_strdup_with_null函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: has_auth_qop
/*
* Finds out if qop offer contains "auth" token.
*/
static pj_bool_t has_auth_qop( pj_pool_t *pool, const pj_str_t *qop_offer)
{
pj_str_t qop;
char *p;
pj_strdup_with_null( pool, &qop, qop_offer);
p = qop.ptr;
while (*p) {
*p = (char)tolower(*p);
++p;
}
p = qop.ptr;
while (*p) {
if (*p=='a' && *(p+1)=='u' && *(p+2)=='t' && *(p+3)=='h') {
int e = *(p+4);
if (e=='"' || e==',' || e==0)
return PJ_TRUE;
else
p += 4;
} else {
++p;
}
}
return PJ_FALSE;
}
开发者ID:svn2github,项目名称:pjproject,代码行数:30,代码来源:sip_auth.c
示例2: PJ_DEF
PJ_DEF(void) pjsip_cred_info_dup(pj_pool_t *pool,
pjsip_cred_info *dst,
const pjsip_cred_info *src)
{
pj_memcpy(dst, src, sizeof(pjsip_cred_info));
pj_strdup_with_null(pool, &dst->realm, &src->realm);
pj_strdup_with_null(pool, &dst->scheme, &src->scheme);
pj_strdup_with_null(pool, &dst->username, &src->username);
pj_strdup_with_null(pool, &dst->data, &src->data);
if ((dst->data_type & EXT_MASK) == PJSIP_CRED_DATA_EXT_AKA) {
dup_bin(pool, &dst->ext.aka.k, &src->ext.aka.k);
dup_bin(pool, &dst->ext.aka.op, &src->ext.aka.op);
dup_bin(pool, &dst->ext.aka.amf, &src->ext.aka.amf);
}
}
开发者ID:conght,项目名称:BLM-Lib,代码行数:17,代码来源:sip_auth_client.c
示例3: pjsip_messaging_create_session
pjsip_messaging_create_session( pjsip_endpoint *endpt, const pj_str_t *param_from,
const pj_str_t *param_to )
{
pj_pool_t *pool;
pjsip_messaging_session *ses;
pj_str_t tmp, to;
pool = pjsip_endpt_create_pool(endpt, "imsess", 1024, 1024);
if (!pool)
return NULL;
ses = pj_pool_calloc(pool, 1, sizeof(pjsip_messaging_session));
ses->pool = pool;
ses->endpt = endpt;
ses->call_id = pjsip_cid_hdr_create(pool);
pj_create_unique_string(pool, &ses->call_id->id);
ses->cseq = pjsip_cseq_hdr_create(pool);
ses->cseq->cseq = pj_rand();
ses->cseq->method = message_method;
ses->from = pjsip_from_hdr_create(pool);
pj_strdup_with_null(pool, &tmp, param_from);
ses->from->uri = pjsip_parse_uri(pool, tmp.ptr, tmp.slen, PJSIP_PARSE_URI_AS_NAMEADDR);
if (ses->from->uri == NULL) {
pjsip_endpt_destroy_pool(endpt, pool);
return NULL;
}
pj_create_unique_string(pool, &ses->from->tag);
ses->to = pjsip_to_hdr_create(pool);
pj_strdup_with_null(pool, &to, param_from);
ses->to->uri = pjsip_parse_uri(pool, to.ptr, to.slen, PJSIP_PARSE_URI_AS_NAMEADDR);
if (ses->to->uri == NULL) {
pjsip_endpt_destroy_pool(endpt, pool);
return NULL;
}
PJ_LOG(4,(THIS_FILE, "IM session created: recipient=%s", to.ptr));
return ses;
}
开发者ID:svn2github,项目名称:pjproject,代码行数:42,代码来源:messaging.c
示例4: PJ_DECL
PJ_DECL(pj_status_t) set_turn_credentials(const pj_str_t username, const pj_str_t password, const pj_str_t realm, pj_stun_auth_cred *turn_auth_cred) {
PJ_ASSERT_RETURN(turn_auth_cred, PJ_EINVAL);
/* Create memory pool for application. */
if(css_var.pool == NULL){
css_var.pool = pjsua_pool_create("css", 1000, 1000);
PJ_ASSERT_RETURN(css_var.pool, PJ_ENOMEM);
}
if (username.slen) {
turn_auth_cred->type = PJ_STUN_AUTH_CRED_STATIC;
pj_strdup_with_null(css_var.pool,
&turn_auth_cred->data.static_cred.username,
&username);
} else {
turn_auth_cred->data.static_cred.username.slen = 0;
}
if(password.slen) {
turn_auth_cred->data.static_cred.data_type = PJ_STUN_PASSWD_PLAIN;
pj_strdup_with_null(css_var.pool,
&turn_auth_cred->data.static_cred.data,
&password);
}else{
turn_auth_cred->data.static_cred.data.slen = 0;
}
if(realm.slen) {
pj_strdup_with_null(css_var.pool,
&turn_auth_cred->data.static_cred.realm,
&realm);
} else {
turn_auth_cred->data.static_cred.realm = pj_str("*");
}
return PJ_SUCCESS;
}
开发者ID:mycelial,项目名称:CSipSimple,代码行数:38,代码来源:pjsua_jni_addons.c
示例5: PJ_DEF
/*
* Duplicate SSL socket parameter.
*/
PJ_DEF(void) pj_ssl_sock_param_copy( pj_pool_t *pool,
pj_ssl_sock_param *dst,
const pj_ssl_sock_param *src)
{
/* Init secure socket param */
pj_memcpy(dst, src, sizeof(*dst));
if (src->ciphers_num > 0) {
unsigned i;
dst->ciphers = (pj_ssl_cipher*)
pj_pool_calloc(pool, src->ciphers_num,
sizeof(pj_ssl_cipher));
for (i = 0; i < src->ciphers_num; ++i)
dst->ciphers[i] = src->ciphers[i];
}
if (src->curves_num > 0) {
unsigned i;
dst->curves = (pj_ssl_curve *)pj_pool_calloc(pool, src->curves_num,
sizeof(pj_ssl_curve));
for (i = 0; i < src->curves_num; ++i)
dst->curves[i] = src->curves[i];
}
if (src->server_name.slen) {
/* Server name must be null-terminated */
pj_strdup_with_null(pool, &dst->server_name, &src->server_name);
}
if (src->sigalgs.slen) {
/* Sigalgs name must be null-terminated */
pj_strdup_with_null(pool, &dst->sigalgs, &src->sigalgs);
}
if (src->entropy_path.slen) {
/* Path name must be null-terminated */
pj_strdup_with_null(pool, &dst->entropy_path, &src->entropy_path);
}
}
开发者ID:RyanLee27,项目名称:pjproject,代码行数:41,代码来源:ssl_sock_common.c
示例6: PJ_DEF
PJ_DEF(pjmedia_sdp_attr*) pjmedia_sdp_attr_clone(pj_pool_t *pool,
const pjmedia_sdp_attr *rhs)
{
pjmedia_sdp_attr *attr;
PJ_ASSERT_RETURN(pool && rhs, NULL);
attr = PJ_POOL_ALLOC_T(pool, pjmedia_sdp_attr);
pj_strdup(pool, &attr->name, &rhs->name);
pj_strdup_with_null(pool, &attr->value, &rhs->value);
return attr;
}
开发者ID:AGProjects,项目名称:python-sipsimple,代码行数:14,代码来源:sdp.c
示例7: PJ_DEF
PJ_DEF(pjmedia_sdp_attr*) pjmedia_sdp_attr_clone(pj_pool_t *pool,
const pjmedia_sdp_attr *rhs)
{
pjmedia_sdp_attr *attr;
PJ_ASSERT_RETURN(pool && rhs, NULL);
attr = pj_pool_alloc(pool, sizeof(pjmedia_sdp_attr));
pj_strdup(pool, &attr->name, &rhs->name);
pj_strdup_with_null(pool, &attr->value, &rhs->value);
return attr;
}
开发者ID:tibastral,项目名称:symphonie,代码行数:14,代码来源:sdp.c
示例8: pj_strdup_with_null
/// Get the URI (either name-addr or addr-spec) from the string header
/// (e.g., P-Served-User), ignoring any parameters. If it's a bare
/// addr-spec, assume (like Contact) that parameters belong to the
/// header, not to the URI.
///
/// @return URI, or NULL if cannot be parsed.
pjsip_uri* PJUtils::uri_from_string_header(pjsip_generic_string_hdr* hdr,
pj_pool_t *pool)
{
// We must duplicate the string into memory from the specified pool first as
// pjsip_parse_uri does not clone the actual strings within the URI.
pj_str_t hvalue;
pj_strdup_with_null(pool, &hvalue, &hdr->hvalue);
char* end = strchr(hvalue.ptr, '>');
if (end != NULL)
{
*(end + 1) = '\0';
hvalue.slen = (end + 1 - hvalue.ptr);
}
return pjsip_parse_uri(pool, hvalue.ptr, hvalue.slen, 0);
}
开发者ID:triendeau,项目名称:sprout,代码行数:21,代码来源:pjutils.cpp
示例9: pj_strdup_with_null
static pjsip_fromto_hdr *get_diversion_header(pjsip_rx_data *rdata)
{
static const pj_str_t from_name = { "From", 4 };
pjsip_generic_string_hdr *hdr;
pj_str_t value;
int size;
if (!(hdr = pjsip_msg_find_hdr_by_name(rdata->msg_info.msg, &diversion_name, NULL))) {
return NULL;
}
pj_strdup_with_null(rdata->tp_info.pool, &value, &hdr->hvalue);
/* parse as a fromto header */
return pjsip_parse_hdr(rdata->tp_info.pool, &from_name, value.ptr,
pj_strlen(&value), &size);
}
开发者ID:litnimax,项目名称:asterisk,代码行数:18,代码来源:res_pjsip_diversion.c
示例10: PJ_LOG
Jt_Station::Jt_Station(jt_station_config_t *cfg)
{
PJ_LOG(3, ("station.cpp", "Jt_Station: build a station. id: %d, name: %s", cfg->id, cfg->name.ptr));
_pool = pj_pool_create(&g_cp.factory, cfg->name.ptr, INIT_POOL_STATION_SIZE, INC_POOL_STATION_SIZE, NULL);
pj_strdup_with_null(_pool, &_name, &cfg->name);
_id = cfg->id;
_fin = cfg->fin;
_rtinfo = pj_hash_create(_pool, MAX_SIGNAL_KIND_COUNTS);
jt_neighbour_config_t *nb = (jt_neighbour_config_t*)pj_pool_calloc(_pool, cfg->link_cnts, sizeof(jt_neighbour_config_t));
for(pj_uint32_t i=0; i<cfg->link_cnts; i++)
{
nb[i].event = cfg->link_cfg[i]->event;
nb[i].stt_id = cfg->link_cfg[i]->stt_id;
pj_hash_set(_pool, _rtinfo, &(nb[i].event), sizeof(pj_uint32_t), 0, &(nb[i]));
}
_car_tbl = pj_hash_create(_pool, MAX_CAR_COUNTS_PER_STATION);
_ops_tbl = pj_hash_create(_pool, MAX_SIGNAL_KIND_COUNTS);
}
开发者ID:joee33,项目名称:Jtrast,代码行数:19,代码来源:station.cpp
示例11: PJ_DEF
/*
* Find buddy.
*/
PJ_DEF(pjsua_buddy_id) pjsua_buddy_find(const pj_str_t *uri_str)
{
pj_str_t input;
pj_pool_t *pool;
pjsip_uri *uri;
pjsua_buddy_id buddy_id;
pool = pjsua_pool_create("buddyfind", 512, 512);
pj_strdup_with_null(pool, &input, uri_str);
uri = pjsip_parse_uri(pool, input.ptr, input.slen, 0);
if (!uri)
buddy_id = PJSUA_INVALID_ID;
else
buddy_id = pjsua_find_buddy(uri);
pj_pool_release(pool);
return buddy_id;
}
开发者ID:svn2github,项目名称:pjproject,代码行数:23,代码来源:pjsua_pres.c
示例12: pjsip_msg_find_hdr_by_name
/*!
* \internal
* \brief Get a P-Asserted-Identity or Remote-Party-ID header from an incoming message
*
* This function will parse the header as if it were a From header. This allows for us
* to easily manipulate the URI, as well as add, modify, or remove parameters from the
* header
*
* \param rdata The incoming message
* \param header_name The name of the ID header to find
* \retval NULL No ID header present or unable to parse ID header
* \retval non-NULL The parsed ID header
*/
static pjsip_fromto_hdr *get_id_header(pjsip_rx_data *rdata, const pj_str_t *header_name)
{
static const pj_str_t from = { "From", 4 };
pj_str_t header_content;
pjsip_fromto_hdr *parsed_hdr;
pjsip_generic_string_hdr *ident = pjsip_msg_find_hdr_by_name(rdata->msg_info.msg,
header_name, NULL);
int parsed_len;
if (!ident) {
return NULL;
}
pj_strdup_with_null(rdata->tp_info.pool, &header_content, &ident->hvalue);
parsed_hdr = pjsip_parse_hdr(rdata->tp_info.pool, &from, header_content.ptr,
pj_strlen(&header_content), &parsed_len);
if (!parsed_hdr) {
return NULL;
}
return parsed_hdr;
}
开发者ID:brandonshults01,项目名称:asterisk,代码行数:37,代码来源:res_pjsip_caller_id.c
示例13: udp_set_pub_name
/* Set the published address of the transport */
static void udp_set_pub_name(struct udp_transport *tp,
const pjsip_host_port *a_name)
{
enum { INFO_LEN = 80 };
char local_addr[PJ_INET6_ADDRSTRLEN+10];
pj_assert(a_name->host.slen != 0);
pj_strdup_with_null(tp->base.pool, &tp->base.local_name.host,
&a_name->host);
tp->base.local_name.port = a_name->port;
/* Update transport info. */
if (tp->base.info == NULL) {
tp->base.info = (char*) pj_pool_alloc(tp->base.pool, INFO_LEN);
}
pj_sockaddr_print(&tp->base.local_addr, local_addr, sizeof(local_addr), 3);
pj_ansi_snprintf(
tp->base.info, INFO_LEN, "udp %s [published as %s:%d]",
local_addr,
tp->base.local_name.host.ptr,
tp->base.local_name.port);
}
开发者ID:avble,项目名称:natClientEx,代码行数:25,代码来源:sip_transport_udp.c
示例14: PJ_DEF
/*
* Send instant messaging outside dialog, using the specified account for
* route set and authentication.
*/
PJ_DEF(pj_status_t) pjsua_im_send( pjsua_acc_id acc_id,
const pj_str_t *to,
const pj_str_t *mime_type,
const pj_str_t *content,
const pjsua_msg_data *msg_data,
void *user_data)
{
pjsip_tx_data *tdata;
const pj_str_t mime_text_plain = pj_str("text/plain");
pjsip_media_type media_type;
pjsua_im_data *im_data;
pjsua_acc *acc;
pj_status_t status;
/* To and message body must be specified. */
PJ_ASSERT_RETURN(to && content, PJ_EINVAL);
acc = &pjsua_var.acc[acc_id];
/* Create request. */
status = pjsip_endpt_create_request(pjsua_var.endpt,
&pjsip_message_method,
(msg_data && msg_data->target_uri.slen?
&msg_data->target_uri: to),
&acc->cfg.id,
to, NULL, NULL, -1, NULL, &tdata);
if (status != PJ_SUCCESS) {
pjsua_perror(THIS_FILE, "Unable to create request", status);
return status;
}
/* If account is locked to specific transport, then set transport to
* the request.
*/
if (acc->cfg.transport_id != PJSUA_INVALID_ID) {
pjsip_tpselector tp_sel;
pjsua_init_tpselector(acc->cfg.transport_id, &tp_sel);
pjsip_tx_data_set_transport(tdata, &tp_sel);
}
/* Add accept header. */
pjsip_msg_add_hdr( tdata->msg,
(pjsip_hdr*)pjsua_im_create_accept(tdata->pool));
/* Create suitable Contact header unless a Contact header has been
* set in the account.
*/
/* Ticket #1632: According to RFC 3428:
* MESSAGE requests do not initiate dialogs.
* User Agents MUST NOT insert Contact header fields into MESSAGE requests
*/
/*
if (acc->contact.slen) {
contact = acc->contact;
} else {
status = pjsua_acc_create_uac_contact(tdata->pool, &contact, acc_id, to);
if (status != PJ_SUCCESS) {
pjsua_perror(THIS_FILE, "Unable to generate Contact header", status);
pjsip_tx_data_dec_ref(tdata);
return status;
}
}
pjsip_msg_add_hdr( tdata->msg, (pjsip_hdr*)
pjsip_generic_string_hdr_create(tdata->pool,
&STR_CONTACT, &contact));
*/
/* Create IM data to keep message details and give it back to
* application on the callback
*/
im_data = PJ_POOL_ZALLOC_T(tdata->pool, pjsua_im_data);
im_data->acc_id = acc_id;
im_data->call_id = PJSUA_INVALID_ID;
pj_strdup_with_null(tdata->pool, &im_data->to, to);
pj_strdup_with_null(tdata->pool, &im_data->body, content);
im_data->user_data = user_data;
/* Set default media type if none is specified */
if (mime_type == NULL) {
mime_type = &mime_text_plain;
}
/* Parse MIME type */
pjsua_parse_media_type(tdata->pool, mime_type, &media_type);
/* Add message body */
tdata->msg->body = pjsip_msg_body_create( tdata->pool, &media_type.type,
&media_type.subtype,
&im_data->body);
if (tdata->msg->body == NULL) {
pjsua_perror(THIS_FILE, "Unable to create msg body", PJ_ENOMEM);
pjsip_tx_data_dec_ref(tdata);
return PJ_ENOMEM;
//.........这里部分代码省略.........
开发者ID:CloudStyleStudio,项目名称:csip,代码行数:101,代码来源:pjsua_im.c
示例15: PJ_DECL
//Wrap start & stop
PJ_DECL(pj_status_t) csipsimple_init(pjsua_config *ua_cfg,
pjsua_logging_config *log_cfg, pjsua_media_config *media_cfg,
csipsimple_config *css_cfg, jobject context) {
pj_status_t result;
unsigned i;
/* Create memory pool for application. */
if(css_var.pool == NULL){
css_var.pool = pjsua_pool_create("css", 1000, 1000);
PJ_ASSERT_RETURN(css_var.pool, PJ_ENOMEM);
}
// Finalize configuration
log_cfg->cb = &pj_android_log_msg;
// Static cfg
extern pj_bool_t pjsip_use_compact_form;
extern pj_bool_t pjsip_include_allow_hdr_in_dlg;
extern pj_bool_t pjmedia_add_rtpmap_for_static_pt;
extern pj_bool_t pjmedia_add_bandwidth_tias_in_sdp;
extern pj_bool_t pjsua_no_update;
extern pj_bool_t pjmedia_webrtc_use_ns;
pjsua_no_update = css_cfg->use_no_update ? PJ_TRUE : PJ_FALSE;
pjsip_use_compact_form =
css_cfg->use_compact_form_headers ? PJ_TRUE : PJ_FALSE;
/* do not transmit Allow header */
pjsip_include_allow_hdr_in_dlg =
css_cfg->use_compact_form_headers ? PJ_FALSE : PJ_TRUE;
/* Do not include rtpmap for static payload types (<96) */
pjmedia_add_rtpmap_for_static_pt =
css_cfg->use_compact_form_sdp ? PJ_FALSE : PJ_TRUE;
/* Do not enable bandwidth information inclusion in sdp */
pjmedia_add_bandwidth_tias_in_sdp =
css_cfg->add_bandwidth_tias_in_sdp ? PJ_TRUE : PJ_FALSE;
/* Use noise suppressor ? */
pjmedia_webrtc_use_ns =
css_cfg->use_noise_suppressor ? PJ_TRUE : PJ_FALSE;
css_tcp_keep_alive_interval = css_cfg->tcp_keep_alive_interval;
css_tls_keep_alive_interval = css_cfg->tls_keep_alive_interval;
// Transaction timeouts
pjsip_sip_cfg_var.tsx.t1 = css_cfg->tsx_t1_timeout;
pjsip_sip_cfg_var.tsx.t2 = css_cfg->tsx_t2_timeout;
pjsip_sip_cfg_var.tsx.t4 = css_cfg->tsx_t4_timeout;
pjsip_sip_cfg_var.tsx.td = css_cfg->tsx_td_timeout;
pjsip_sip_cfg_var.endpt.disable_tcp_switch = css_cfg->disable_tcp_switch;
pjsip_sip_cfg_var.endpt.disable_rport = css_cfg->disable_rport;
// Audio codec cfg
css_var.extra_aud_codecs_cnt = css_cfg->extra_aud_codecs_cnt;
for (i = 0; i < css_cfg->extra_aud_codecs_cnt; i++) {
dynamic_factory *css_codec = &css_var.extra_aud_codecs[i];
dynamic_factory *cfg_codec = &css_cfg->extra_aud_codecs[i];
pj_strdup_with_null(css_var.pool, &css_codec->shared_lib_path,
&cfg_codec->shared_lib_path);
pj_strdup_with_null(css_var.pool, &css_codec->init_factory_name,
&cfg_codec->init_factory_name);
}
// Video codec cfg -- For now only destroy is useful but for future
// hopefully vid codec mgr will behaves as audio does
// Also in this case destroy will become obsolete
css_var.extra_vid_codecs_cnt = css_cfg->extra_vid_codecs_cnt;
for (i = 0; i < css_cfg->extra_vid_codecs_cnt; i++) {
dynamic_factory *css_codec = &css_var.extra_vid_codecs[i];
dynamic_factory *cfg_codec = &css_cfg->extra_vid_codecs[i];
pj_strdup_with_null(css_var.pool, &css_codec->shared_lib_path,
&cfg_codec->shared_lib_path);
pj_strdup_with_null(css_var.pool, &css_codec->init_factory_name,
&cfg_codec->init_factory_name);
css_codec = &css_var.extra_vid_codecs_destroy[i];
cfg_codec = &css_cfg->extra_vid_codecs_destroy[i];
pj_strdup_with_null(css_var.pool, &css_codec->shared_lib_path,
&cfg_codec->shared_lib_path);
pj_strdup_with_null(css_var.pool, &css_codec->init_factory_name,
&cfg_codec->init_factory_name);
}
// ZRTP cfg
css_var.default_use_zrtp = css_cfg->use_zrtp;
ua_cfg->cb.on_create_media_transport = &on_transport_created_wrapper;
#if defined(PJMEDIA_HAS_ZRTP) && PJMEDIA_HAS_ZRTP!=0
pj_ansi_snprintf(css_var.zid_file, sizeof(css_var.zid_file),
"%.*s/simple.zid", css_cfg->storage_folder.slen,
css_cfg->storage_folder.ptr);
#endif
JNIEnv *jni_env = 0;
ATTACH_JVM(jni_env);
css_var.context = (*jni_env)->NewGlobalRef(jni_env, context);
//.........这里部分代码省略.........
开发者ID:ChrisKwon,项目名称:spore,代码行数:101,代码来源:pjsua_jni_addons.c
示例16: PJ_DEF
PJ_DEF(pj_status_t) pjsip_regc_init( pjsip_regc *regc,
const pj_str_t *srv_url,
const pj_str_t *from_url,
const pj_str_t *to_url,
int contact_cnt,
const pj_str_t contact[],
pj_uint32_t expires)
{
pj_str_t tmp;
pj_status_t status;
PJ_ASSERT_RETURN(regc && srv_url && from_url && to_url &&
expires, PJ_EINVAL);
/* Copy server URL. */
pj_strdup_with_null(regc->pool, ®c->str_srv_url, srv_url);
/* Set server URL. */
tmp = regc->str_srv_url;
regc->srv_url = pjsip_parse_uri( regc->pool, tmp.ptr, tmp.slen, 0);
if (regc->srv_url == NULL) {
return PJSIP_EINVALIDURI;
}
/* Set "From" header. */
pj_strdup_with_null(regc->pool, ®c->from_uri, from_url);
tmp = regc->from_uri;
regc->from_hdr = pjsip_from_hdr_create(regc->pool);
regc->from_hdr->uri = pjsip_parse_uri(regc->pool, tmp.ptr, tmp.slen,
PJSIP_PARSE_URI_AS_NAMEADDR);
if (!regc->from_hdr->uri) {
PJ_LOG(4,(THIS_FILE, "regc: invalid source URI %.*s",
from_url->slen, from_url->ptr));
return PJSIP_EINVALIDURI;
}
/* Set "To" header. */
pj_strdup_with_null(regc->pool, &tmp, to_url);
regc->to_hdr = pjsip_to_hdr_create(regc->pool);
regc->to_hdr->uri = pjsip_parse_uri(regc->pool, tmp.ptr, tmp.slen,
PJSIP_PARSE_URI_AS_NAMEADDR);
if (!regc->to_hdr->uri) {
PJ_LOG(4,(THIS_FILE, "regc: invalid target URI %.*s", to_url->slen, to_url->ptr));
return PJSIP_EINVALIDURI;
}
/* Set "Contact" header. */
status = set_contact( regc, contact_cnt, contact);
if (status != PJ_SUCCESS)
return status;
/* Set "Expires" header, if required. */
set_expires( regc, expires);
regc->delay_before_refresh = DELAY_BEFORE_REFRESH;
/* Set "Call-ID" header. */
regc->cid_hdr = pjsip_cid_hdr_create(regc->pool);
pj_create_unique_string(regc->pool, ®c->cid_hdr->id);
/* Set "CSeq" header. */
regc->cseq_hdr = pjsip_cseq_hdr_create(regc->pool);
regc->cseq_hdr->cseq = pj_rand() % 0xFFFF;
pjsip_method_set( ®c->cseq_hdr->method, PJSIP_REGISTER_METHOD);
/* Done. */
return PJ_SUCCESS;
}
开发者ID:iamroger,项目名称:voip,代码行数:68,代码来源:sip_reg.c
示例17: set_contact
static pj_status_t set_contact( pjsip_regc *regc,
int contact_cnt,
const pj_str_t contact[] )
{
const pj_str_t CONTACT = { "Contact", 7 };
pjsip_contact_hdr *h;
int i;
/* Save existing contact list to removed_contact_hdr_list and
* clear contact_hdr_list.
*/
pj_list_merge_last(®c->removed_contact_hdr_list,
®c->contact_hdr_list);
/* Set the expiration of Contacts in to removed_contact_hdr_list
* zero.
*/
h = regc->removed_contact_hdr_list.next;
while (h != ®c->removed_contact_hdr_list) {
h->expires = 0;
h = h->next;
}
/* Process new contacts */
for (i=0; i<contact_cnt; ++i) {
pjsip_contact_hdr *hdr;
pj_str_t tmp;
pj_strdup_with_null(regc->pool, &tmp, &contact[i]);
hdr = (pjsip_contact_hdr*)
pjsip_parse_hdr(regc->pool, &CONTACT, tmp.ptr, tmp.slen, NULL);
if (hdr == NULL) {
PJ_LOG(4,(THIS_FILE, "Invalid Contact: \"%.*s\"",
(int)tmp.slen, tmp.ptr));
return PJSIP_EINVALIDURI;
}
/* Find the new contact in old contact list. If found, remove
* the old header from the old header list.
*/
h = regc->removed_contact_hdr_list.next;
while (h != ®c->removed_contact_hdr_list) {
int rc;
rc = pjsip_uri_cmp(PJSIP_URI_IN_CONTACT_HDR,
h->uri, hdr->uri);
if (rc == 0) {
/* Match */
pj_list_erase(h);
break;
}
h = h->next;
}
/* If add_xuid_param option is enabled and Contact URI is sip/sips,
* add xuid parameter to assist matching the Contact URI in the
* REGISTER response later.
*/
if (regc->add_xuid_param && (PJSIP_URI_SCHEME_IS_SIP(hdr->uri) ||
PJSIP_URI_SCHEME_IS_SIPS(hdr->uri)))
{
pjsip_param *xuid_param;
pjsip_sip_uri *sip_uri;
xuid_param = PJ_POOL_ZALLOC_T(regc->pool, pjsip_param);
xuid_param->name = XUID_PARAM_NAME;
pj_create_unique_string(regc->pool, &xuid_param->value);
sip_uri = (pjsip_sip_uri*) pjsip_uri_get_uri(hdr->uri);
pj_list_push_back(&sip_uri->other_param, xuid_param);
}
pj_list_push_back(®c->contact_hdr_list, hdr);
}
return PJ_SUCCESS;
}
开发者ID:iamroger,项目名称:voip,代码行数:78,代码来源:sip_reg.c
示例18: PJ_DEF
/*
* Send instant messaging outside dialog, using the specified account for
* route set and authentication.
*/
PJ_DEF(pj_status_t) pjsua_im_send( pjsua_acc_id acc_id,
const pj_str_t *to,
const pj_str_t *mime_type,
const pj_str_t *content,
const pjsua_msg_data *msg_data,
void *user_data)
{
pjsip_tx_data *tdata;
const pj_str_t mime_text_plain = pj_str("text/plain");
const pj_str_t STR_CONTACT = { "Contact", 7 };
pjsip_media_type media_type;
pjsua_im_data *im_data;
pj_str_t contact;
pj_status_t status;
/* To and message body must be specified. */
PJ_ASSERT_RETURN(to && content, PJ_EINVAL);
/* Create request. */
status = pjsip_endpt_create_request(pjsua_var.endpt,
&pjsip_message_method, to,
&pjsua_var.acc[acc_id].cfg.id,
to, NULL, NULL, -1, NULL, &tdata);
if (status != PJ_SUCCESS) {
pjsua_perror(THIS_FILE, "Unable to create request", status);
return status;
}
/* If account is locked to specific transport, then set transport to
* the request.
*/
if (pjsua_var.acc[acc_id].cfg.transport_id != PJSUA_INVALID_ID) {
pjsip_tpselector tp_sel;
pjsua_init_tpselector(pjsua_var.acc[acc_id].cfg.transport_id, &tp_sel);
pjsip_tx_data_set_transport(tdata, &tp_sel);
}
/* Add accept header. */
pjsip_msg_add_hdr( tdata->msg,
(pjsip_hdr*)pjsua_im_create_accept(tdata->pool));
/* Add contact. */
status = pjsua_acc_create_uac_contact(tdata->pool, &contact, acc_id, to);
if (status != PJ_SUCCESS) {
pjsua_perror(THIS_FILE, "Unable to generate Contact header", status);
pjsip_tx_data_dec_ref(tdata);
return status;
}
pjsip_msg_add_hdr( tdata->msg, (pjsip_hdr*)
pjsip_generic_string_hdr_create(tdata->pool,
&STR_CONTACT, &contact));
/* Create IM data to keep message details and give it back to
* application on the callback
*/
im_data = PJ_POOL_ZALLOC_T(tdata->pool, pjsua_im_data);
im_data->acc_id = acc_id;
im_data->call_id = PJSUA_INVALID_ID;
pj_strdup_with_null(tdata->pool, &im_data->to, to);
pj_strdup_with_null(tdata->pool, &im_data->body, content);
im_data->user_data = user_data;
/* Set default media type if none is specified */
if (mime_type == NULL) {
mime_type = &mime_text_plain;
}
/* Parse MIME type */
pjsua_parse_media_type(tdata->pool, mime_type, &media_type);
/* Add message body */
tdata->msg->body = pjsip_msg_body_create( tdata->pool, &media_type.type,
&media_type.subtype,
&im_data->body);
if (tdata->msg->body == NULL) {
pjsua_perror(THIS_FILE, "Unable to create msg body", PJ_ENOMEM);
pjsip_tx_data_dec_ref(tdata);
return PJ_ENOMEM;
}
/* Add additional headers etc. */
pjsua_process_msg_data(tdata, msg_data);
/* Add route set */
pjsua_set_msg_route_set(tdata, &pjsua_var.acc[acc_id].route_set);
/* Send request (statefully) */
status = pjsip_endpt_send_request( pjsua_var.endpt, tdata, -1,
im_data, &im_callback);
if (status != PJ_SUCCESS) {
pjsua_perror(THIS_FILE, "Unable to send request", status);
return status;
}
//.........这里部分代码省略.........
开发者ID:Jopie64,项目名称:pjsip,代码行数:101,代码来源:pjsua_im.c
示例19: parse_attr_crypto
/* Parse crypto attribute line */
static pj_status_t parse_attr_crypto(pj_pool_t *pool,
const pjmedia_sdp_attr *attr,
pjmedia_srtp_crypto *crypto,
int *tag)
{
pj_str_t input;
char *token;
pj_str_t tmp;
pj_status_t status;
int itmp;
pj_bzero(crypto, sizeof(*crypto));
pj_strdup_with_null(pool, &input, &attr->value);
/* Tag */
token = strtok(input.ptr, " ");
if (!token) {
PJ_LOG(4,(THIS_FILE, "Attribute crypto expecting tag"));
return PJMEDIA_SDP_EINATTR;
}
*tag = atoi(token);
if (*tag == 0)
return PJMEDIA_SDP_EINATTR;
/* Crypto-suite */
token = strtok(NULL, " ");
if (!token) {
PJ_LOG(4,(THIS_FILE, "Attribute crypto expecting crypto suite"));
return PJMEDIA_SDP_EINATTR;
}
crypto->name = pj_str(token);
/* Key method */
token = strtok(NULL, ":");
if (!token) {
PJ_LOG(4,(THIS_FILE, "Attribute crypto expecting key method"));
return PJMEDIA_SDP_EINATTR;
}
if (pj_ansi_stricmp(token, "inline")) {
PJ_LOG(4,(THIS_FILE, "Attribute crypto key method '%s' not supported!",
token));
return PJMEDIA_SDP_EINATTR;
}
/* Key */
token = strtok(NULL, "| ");
if (!token) {
PJ_LOG(4,(THIS_FILE, "Attribute crypto expecting key"));
return PJMEDIA_SDP_EINATTR;
}
tmp = pj_str(token);
crypto->key.ptr = (char*) pj_pool_zalloc(pool, MAX_KEY_LEN);
/* Decode key */
itmp = MAX_KEY_LEN;
status = pj_base64_decode(&tmp, (pj_uint8_t*)crypto->key.ptr,
&itmp);
if (status != PJ_SUCCESS) {
PJ_LOG(4,(THIS_FILE, "Failed decoding crypto key from base64"));
return status;
}
crypto->key.slen = itmp;
return PJ_SUCCESS;
}
开发者ID:deveck,项目名称:Deveck.TAM,代码行数:66,代码来源:transport_srtp.c
示例20: parse_attr_crypto
/* Parse crypto attribute line */
static pj_status_t parse_attr_crypto(pj_pool_t *pool,
const pjmedia_sdp_attr *attr,
pjmedia_srtp_crypto *crypto,
int *tag)
{
pj_str_t input;
char *token;
int token_len;
pj_str_t tmp;
pj_status_t status;
int itmp;
pj_bzero(crypto, sizeof(*crypto));
pj_strdup_with_null(pool, &input, &attr->value);
/* Tag */
token = strtok(input.ptr, " ");
if (!token) {
PJ_LOG(4,(THIS_FILE, "Attribute crypto expecting tag"));
return PJMEDIA_SDP_EINATTR;
}
token_len = pj_ansi_strlen(token);
/* Tag must not use leading zeroes. */
if (token_len > 1 && *token == '0')
return PJMEDIA_SDP_EINATTR;
/* Tag must be decimal, i.e: contains only digit '0'-'9'. */
for (itmp = 0; itmp < token_len; ++itmp)
if (!pj_isdigit(token[itmp]))
return PJMEDIA_SDP_EINATTR;
/* Get tag value. */
*tag = atoi(token);
/* Crypto-suite */
token = strtok(NULL, " ");
if (!token) {
PJ_LOG(4,(THIS_FILE, "Attribute crypto expecting crypto suite"));
return PJMEDIA_SDP_EINATTR;
}
crypto->name = pj_str(token);
/* Key method */
token = strtok(NULL, ":");
if (!token) {
PJ_LOG(4,(THIS_FILE, "Attribute crypto expecting key method"));
return PJMEDIA_SDP_EINATTR;
}
if (pj_ansi_stricmp(token, "inline")) {
PJ_LOG(4,(THIS_FILE, "Attribute crypto key method '%s' not supported!",
token));
return PJMEDIA_SDP_EINATTR;
}
/* Key */
token = strtok(NULL, "| ");
if (!token) {
PJ_LOG(4,(THIS_FILE, "Attribute crypto expecting key"));
return PJMEDIA_SDP_EINATTR;
}
tmp = pj_str(token);
crypto->key.ptr = (char*) pj_pool_zalloc(pool, MAX_KEY_LEN);
/* Decode key */
itmp = MAX_KEY_LEN;
status = pj_base64_decode(&tmp, (pj_uint8_t*)crypto->key.ptr,
&itmp);
if (status != PJ_SUCCESS) {
PJ_LOG(4,(THIS_FILE, "Failed decoding crypto key from base64"));
return status;
}
crypto->key.slen = itmp;
return PJ_SUCCESS;
}
开发者ID:max3903,项目名称:SFLphone,代码行数:77,代码来源:transport_srtp.c
注:本文中的pj_strdup_with_null函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论